2013-10-23 10:26:17 -04:00
|
|
|
/*
|
|
|
|
This file is part of telegram-client.
|
|
|
|
|
|
|
|
Telegram-client is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Telegram-client is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this telegram-client. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
Copyright Vitaly Valtman 2013
|
|
|
|
*/
|
2013-10-11 16:52:20 -04:00
|
|
|
#ifndef __STRUCTURES_H__
|
|
|
|
#define __STRUCTURES_H__
|
|
|
|
|
2013-10-24 03:38:32 -04:00
|
|
|
#define FLAG_EMPTY 1
|
|
|
|
#define FLAG_DELETED 2
|
|
|
|
#define FLAG_FORBIDDEN 4
|
2013-10-24 13:04:44 -04:00
|
|
|
#define FLAG_HAS_PHOTO 8
|
2013-10-24 03:38:32 -04:00
|
|
|
|
|
|
|
#define FLAG_USER_SELF 128
|
|
|
|
#define FLAG_USER_FOREIGN 256
|
|
|
|
#define FLAG_USER_CONTACT 512
|
|
|
|
|
|
|
|
#define FLAG_CHAT_IN_CHAT 128
|
2013-10-11 16:52:20 -04:00
|
|
|
|
|
|
|
struct file_location {
|
|
|
|
int dc;
|
|
|
|
long long volume;
|
|
|
|
int local_id;
|
|
|
|
long long secret;
|
|
|
|
};
|
|
|
|
|
2013-10-24 13:04:44 -04:00
|
|
|
struct photo_size {
|
|
|
|
char *type;
|
|
|
|
struct file_location loc;
|
|
|
|
int w;
|
|
|
|
int h;
|
|
|
|
int size;
|
|
|
|
char *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct geo {
|
|
|
|
double longitude;
|
|
|
|
double latitude;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct photo {
|
|
|
|
long long id;
|
|
|
|
long long access_hash;
|
|
|
|
int user_id;
|
|
|
|
int date;
|
|
|
|
char *caption;
|
|
|
|
struct geo geo;
|
|
|
|
int sizes_num;
|
|
|
|
struct photo_size *sizes;
|
|
|
|
};
|
|
|
|
|
2013-10-11 16:52:20 -04:00
|
|
|
struct user_status {
|
|
|
|
int online;
|
|
|
|
int when;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct user {
|
|
|
|
int id;
|
|
|
|
int flags;
|
2013-10-14 13:26:25 -04:00
|
|
|
char *print_name;
|
|
|
|
struct file_location photo_big;
|
|
|
|
struct file_location photo_small;
|
2013-10-24 13:04:44 -04:00
|
|
|
struct photo photo;
|
2013-10-11 16:52:20 -04:00
|
|
|
char *first_name;
|
|
|
|
char *last_name;
|
|
|
|
char *phone;
|
|
|
|
long long access_hash;
|
|
|
|
struct user_status status;
|
|
|
|
};
|
|
|
|
|
2013-10-24 13:04:44 -04:00
|
|
|
struct chat_user {
|
|
|
|
int user_id;
|
|
|
|
int inviter_id;
|
|
|
|
int date;
|
|
|
|
};
|
|
|
|
|
2013-10-13 08:30:53 -04:00
|
|
|
struct chat {
|
|
|
|
int id;
|
|
|
|
int flags;
|
|
|
|
char *print_title;
|
2013-10-14 13:26:25 -04:00
|
|
|
struct file_location photo_big;
|
|
|
|
struct file_location photo_small;
|
2013-10-24 13:04:44 -04:00
|
|
|
struct photo photo;
|
2013-10-14 13:26:25 -04:00
|
|
|
char *title;
|
2013-10-24 13:04:44 -04:00
|
|
|
int users_num;
|
|
|
|
struct chat_user *users;
|
2013-10-13 08:30:53 -04:00
|
|
|
int date;
|
|
|
|
int version;
|
2013-10-23 06:24:59 -04:00
|
|
|
int admin_id;
|
2013-10-14 13:26:25 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
union user_chat {
|
|
|
|
struct {
|
|
|
|
int id;
|
|
|
|
int flags;
|
|
|
|
char *print_name;
|
|
|
|
struct file_location photo_big;
|
|
|
|
struct file_location photo_small;
|
2013-10-24 13:04:44 -04:00
|
|
|
struct photo photo;
|
2013-10-14 13:26:25 -04:00
|
|
|
};
|
|
|
|
struct user user;
|
|
|
|
struct chat chat;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct video {
|
|
|
|
long long id;
|
|
|
|
long long access_hash;
|
|
|
|
int user_id;
|
|
|
|
int date;
|
|
|
|
char *caption;
|
|
|
|
int duration;
|
|
|
|
int size;
|
|
|
|
struct photo_size thumb;
|
|
|
|
int dc_id;
|
|
|
|
int w;
|
|
|
|
int h;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct message_action {
|
|
|
|
int type;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
char *title;
|
|
|
|
int user_num;
|
|
|
|
int *users;
|
|
|
|
};
|
|
|
|
char *new_title;
|
|
|
|
struct photo photo;
|
|
|
|
int user;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct message_media {
|
|
|
|
int type;
|
|
|
|
union {
|
|
|
|
struct photo photo;
|
|
|
|
struct video video;
|
|
|
|
struct geo geo;
|
|
|
|
struct {
|
|
|
|
char *phone;
|
|
|
|
char *first_name;
|
|
|
|
char *last_name;
|
|
|
|
int user_id;
|
|
|
|
};
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
struct message {
|
|
|
|
struct message *next_use, *prev_use;
|
|
|
|
int id;
|
|
|
|
int flags;
|
|
|
|
int fwd_from_id;
|
|
|
|
int fwd_date;
|
|
|
|
int from_id;
|
|
|
|
int to_id;
|
|
|
|
int out;
|
|
|
|
int unread;
|
|
|
|
int date;
|
|
|
|
int service;
|
|
|
|
union {
|
|
|
|
struct message_action action;
|
|
|
|
struct {
|
|
|
|
char *message;
|
2013-10-22 11:28:41 -04:00
|
|
|
int message_len;
|
2013-10-14 13:26:25 -04:00
|
|
|
struct message_media media;
|
|
|
|
};
|
|
|
|
};
|
2013-10-13 08:30:53 -04:00
|
|
|
};
|
|
|
|
|
2013-10-11 16:52:20 -04:00
|
|
|
void fetch_file_location (struct file_location *loc);
|
2013-10-16 15:19:39 -04:00
|
|
|
void fetch_user_status (struct user_status *S);
|
2013-10-11 16:52:20 -04:00
|
|
|
void fetch_user (struct user *U);
|
2013-10-13 06:18:08 -04:00
|
|
|
struct user *fetch_alloc_user (void);
|
2013-10-14 13:26:25 -04:00
|
|
|
struct chat *fetch_alloc_chat (void);
|
2013-10-16 15:19:39 -04:00
|
|
|
struct message *fetch_alloc_message (void);
|
|
|
|
struct message *fetch_alloc_message_short (void);
|
|
|
|
struct message *fetch_alloc_message_short_chat (void);
|
2013-10-24 13:04:44 -04:00
|
|
|
struct chat *fetch_alloc_chat_full (void);
|
2013-10-18 12:00:47 -04:00
|
|
|
int fetch_peer_id (void);
|
2013-10-13 06:18:08 -04:00
|
|
|
|
|
|
|
void free_user (struct user *U);
|
2013-10-14 13:26:25 -04:00
|
|
|
void free_chat (struct chat *U);
|
2013-10-13 06:18:08 -04:00
|
|
|
|
|
|
|
int print_stat (char *s, int len);
|
2013-10-16 15:19:39 -04:00
|
|
|
union user_chat *user_chat_get (int id);
|
|
|
|
struct message *message_get (int id);
|
|
|
|
void update_message_id (struct message *M, int id);
|
2013-10-18 15:30:24 -04:00
|
|
|
void message_insert (struct message *M);
|
2013-10-24 13:04:44 -04:00
|
|
|
void free_photo (struct photo *P);
|
|
|
|
void fetch_photo (struct photo *P);
|
2013-10-11 16:52:20 -04:00
|
|
|
#endif
|