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-31 19:18:34 -04:00
|
|
|
#include <assert.h>
|
2014-08-13 08:56:55 -04:00
|
|
|
#include "tgl-layout.h"
|
|
|
|
#include "tgl-fetch.h"
|
2013-10-31 19:18:34 -04:00
|
|
|
|
2014-08-13 08:56:55 -04:00
|
|
|
char *create_print_name (peer_id_t id, const char *a1, const char *a2, const char *a3, const char *a4);
|
2013-10-13 08:30:53 -04:00
|
|
|
|
2014-08-13 08:56:55 -04:00
|
|
|
struct message *message_alloc (long long id);
|
2013-11-29 16:43:56 -05:00
|
|
|
|
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
|
|
|
|
2013-11-14 19:08:24 -05:00
|
|
|
|
2014-08-13 08:56:55 -04:00
|
|
|
int tgl_print_stat (char *s, int len);
|
2014-08-13 06:09:52 -04:00
|
|
|
peer_t *peer_get (peer_id_t id);
|
2014-08-13 08:56:55 -04:00
|
|
|
peer_t *peer_lookup_name (const char *s);
|
2013-11-02 06:14:30 -04:00
|
|
|
struct message *message_get (long long id);
|
2014-08-13 08:56:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void message_insert_tree (struct message *M);
|
2013-11-02 06:14:30 -04:00
|
|
|
void update_message_id (struct message *M, long long 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);
|
2013-11-04 12:34:27 -05:00
|
|
|
void insert_encrypted_chat (peer_t *P);
|
2013-11-21 14:35:49 -05:00
|
|
|
void insert_user (peer_t *P);
|
2013-11-22 18:26:35 -05:00
|
|
|
void insert_chat (peer_t *P);
|
2013-11-29 16:43:56 -05:00
|
|
|
void message_insert_unsent (struct message *M);
|
|
|
|
void message_remove_unsent (struct message *M);
|
|
|
|
void send_all_unsent (void);
|
|
|
|
void message_remove_tree (struct message *M);
|
|
|
|
void message_add_peer (struct message *M);
|
|
|
|
void message_del_peer (struct message *M);
|
2013-12-02 12:19:08 -05:00
|
|
|
void free_message (struct message *M);
|
2014-01-11 11:01:01 -05:00
|
|
|
void message_del_use (struct message *M);
|
2014-01-31 11:03:40 -05:00
|
|
|
void peer_insert_name (peer_t *P);
|
|
|
|
void peer_delete_name (peer_t *P);
|
2014-08-13 08:56:55 -04:00
|
|
|
void peer_iterator_ex (void (*it)(peer_t *P, void *extra), void *extra);
|
2013-10-31 19:18:34 -04:00
|
|
|
|
2014-08-13 08:56:55 -04:00
|
|
|
int complete_user_list (int index, const char *text, int len, char **R);
|
|
|
|
int complete_chat_list (int index, const char *text, int len, char **R);
|
|
|
|
int complete_encr_chat_list (int index, const char *text, int len, char **R);
|
|
|
|
int complete_peer_list (int index, const char *text, int len, char **R);
|
2013-10-31 19:18:34 -04:00
|
|
|
#define PEER_USER 1
|
|
|
|
#define PEER_CHAT 2
|
2013-11-01 15:57:57 -04:00
|
|
|
#define PEER_GEO_CHAT 3
|
2013-11-02 06:14:30 -04:00
|
|
|
#define PEER_ENCR_CHAT 4
|
2013-10-31 19:18:34 -04:00
|
|
|
#define PEER_UNKNOWN 0
|
|
|
|
|
|
|
|
#define MK_USER(id) set_peer_id (PEER_USER,id)
|
|
|
|
#define MK_CHAT(id) set_peer_id (PEER_CHAT,id)
|
2013-11-01 15:57:57 -04:00
|
|
|
#define MK_GEO_CHAT(id) set_peer_id (PEER_GEO_CHAT,id)
|
2013-11-02 06:14:30 -04:00
|
|
|
#define MK_ENCR_CHAT(id) set_peer_id (PEER_ENCR_CHAT,id)
|
2013-10-31 19:18:34 -04:00
|
|
|
|
|
|
|
static inline int get_peer_type (peer_id_t id) {
|
2013-11-04 12:34:27 -05:00
|
|
|
return id.type;
|
2013-10-31 19:18:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int get_peer_id (peer_id_t id) {
|
2013-11-04 12:34:27 -05:00
|
|
|
return id.id;
|
2013-10-31 19:18:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline peer_id_t set_peer_id (int type, int id) {
|
|
|
|
peer_id_t ID;
|
2013-11-04 12:34:27 -05:00
|
|
|
ID.id = id;
|
|
|
|
ID.type = type;
|
|
|
|
return ID;
|
2013-10-31 19:18:34 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int cmp_peer_id (peer_id_t a, peer_id_t b) {
|
|
|
|
return memcmp (&a, &b, sizeof (a));
|
|
|
|
}
|
|
|
|
|
2013-10-11 16:52:20 -04:00
|
|
|
#endif
|