telegram-purple/queries.h

162 lines
6.3 KiB
C
Raw Permalink Normal View History

2013-10-23 18:26:17 +04:00
/*
This file is part of telegram-client.
2014-07-26 11:55:45 +02:00
struct telegram-client is free software: you can redistribute it and/or modify
2013-10-23 18:26:17 +04:00
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.
2014-07-26 11:55:45 +02:00
struct telegram-client is distributed in the hope that it will be useful,
2013-10-23 18:26:17 +04:00
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-12 00:52:20 +04:00
#ifndef __QUERIES_H__
#define __QUERIES_H__
2014-08-06 19:45:46 +02:00
#pragma once
#include "structures.h"
2013-10-12 00:52:20 +04:00
2014-07-26 11:55:45 +02:00
struct telegram;
2014-08-06 19:45:46 +02:00
struct encr_video;
struct document;
struct secret_chat;
2014-09-01 21:25:41 +02:00
struct tree_query;
struct tree_timer;
2013-10-12 00:52:20 +04:00
#define QUERY_ACK_RECEIVED 1
struct query;
struct query_methods {
int (*on_answer)(struct query *q);
int (*on_error)(struct query *q, int error_code, int len, char *error);
int (*on_timeout)(struct query *q);
};
2014-09-20 23:20:14 +02:00
struct download_desc{
void *data;
int type;
};
struct download {
int offset;
int size;
long long volume;
long long secret;
long long access_hash;
int local_id;
int dc;
void *extra;
int fd;
char *name;
long long id;
unsigned char *iv;
unsigned char *key;
int type;
2014-10-02 12:29:02 +02:00
struct mtproto_connection *c;
2014-09-20 23:20:14 +02:00
};
2014-10-02 12:29:02 +02:00
void load_next_part (struct telegram *instance, struct download *D);
2014-09-20 23:20:14 +02:00
2013-10-12 00:52:20 +04:00
struct event_timer {
double timeout;
int (*alarm)(void *self);
void *self;
};
struct query {
long long msg_id;
int data_len;
int flags;
int seq_no;
2013-10-12 00:52:20 +04:00
void *data;
struct query_methods *methods;
struct event_timer ev;
struct dc *DC;
struct session *session;
2013-10-18 23:30:24 +04:00
void *extra;
2013-10-12 00:52:20 +04:00
};
2014-09-01 21:25:41 +02:00
struct query *send_query (struct telegram *instance, struct dc *DC, int len, void *data, struct query_methods *methods, void *extra);
void query_ack (struct telegram *instance, long long id);
void query_error (struct telegram *instance, long long id);
void query_result (struct telegram *instance, long long id);
void query_restart (struct telegram *instance, long long id);
2013-10-12 00:52:20 +04:00
2014-09-01 21:25:41 +02:00
void insert_event_timer (struct telegram *instance, struct event_timer *ev);
void remove_event_timer (struct telegram *instance, struct event_timer *ev);
double next_timer_in (struct telegram *instance);
void work_timers (struct telegram *instance);
2013-10-12 00:52:20 +04:00
extern struct query_methods help_get_config_methods;
2014-07-26 11:55:45 +02:00
void do_send_code (struct telegram *instance, const char *user);
void do_phone_call (struct telegram *instance, const char *user);
2014-08-23 02:50:11 +02:00
void do_send_code_result (struct telegram *instance, const char *code);
2013-10-12 00:52:20 +04:00
double get_double_time (void);
2014-07-26 11:55:45 +02:00
void do_update_contact_list (struct telegram *instance);
2013-10-16 23:19:39 +04:00
union user_chat;
2014-07-26 11:55:45 +02:00
void do_send_message (struct telegram *instance, peer_id_t id, const char *msg, int len);
void do_send_text (struct telegram *instance, peer_id_t id, char *file);
void do_get_history (struct telegram *instance, peer_id_t id, int limit);
void do_get_dialog_list (struct telegram*);
void do_get_dialog_list_ex (struct telegram*);
void do_send_photo (struct telegram *instance, int type, peer_id_t to_id, char *file_name);
void do_get_chat_info (struct telegram *instance, peer_id_t id);
void do_get_user_list_info_silent (struct telegram *instance, int num, int *list);
2014-09-20 23:20:14 +02:00
void do_get_user_info (struct telegram *instance, peer_id_t id, int showInfo);
2014-07-26 11:55:45 +02:00
void do_forward_message (struct telegram *instance, peer_id_t id, int n);
void do_rename_chat (struct telegram *instance, peer_id_t id, char *name);
2014-09-20 23:20:14 +02:00
void do_load_encr_video (struct telegram *instance, struct encr_video *V, void *extra);
2014-07-26 11:55:45 +02:00
void do_create_encr_chat_request (struct telegram *instance, int user_id);
void do_create_secret_chat (struct telegram *instance, peer_id_t id);
void do_create_group_chat (struct telegram *instance, peer_id_t id, char *chat_topic);
void do_get_suggested (struct telegram*);
struct photo;
struct video;
2014-09-20 23:20:14 +02:00
void do_load_photo (struct telegram *instance, struct photo *photo, int photoBig, void *extra);
void do_load_video_thumb (struct telegram *instance, struct video *video, void *extra);
void do_load_audio (struct telegram *instance, struct video *V, void *extra);
void do_load_video (struct telegram *instance, struct video *V, void *extra);
void do_load_document (struct telegram *instance, struct document *V, void *extra);
void do_load_document_thumb (struct telegram *instance, struct document *video, void *extra);
2014-07-26 11:55:45 +02:00
void do_help_get_config (struct telegram *instance);
void do_auth_check_phone (struct telegram *instance, const char *user);
2014-07-29 15:28:04 +02:00
void do_get_nearest_dc (struct telegram*);
2014-08-23 02:50:11 +02:00
void do_send_code_result_auth (struct telegram *instance, const char *code, const char *first_name, const char *last_name);
2014-10-02 12:29:02 +02:00
void do_import_auth (struct telegram *instance, int num, void (*cb)(void *extra), void *extra);
void do_export_auth (struct telegram *instance, int num, void (*cb)(char *export_auth_str, int len, void *extra), void *extra);
2014-07-26 11:55:45 +02:00
void do_add_contact (struct telegram *instance, const char *phone, int phone_len, const char *first_name, int first_name_len, const char *last_name, int last_name_len, int force);
void do_msg_search (struct telegram *instance, peer_id_t id, int from, int to, int limit, const char *s);
void do_accept_encr_chat_request (struct telegram *instance, struct secret_chat *E);
void do_get_difference (struct telegram*, int sync_from_start);
2014-07-26 11:55:45 +02:00
void do_mark_read (struct telegram *instance, peer_id_t id);
2014-09-01 21:25:41 +02:00
void do_visualize_key (struct binlog *bl, peer_id_t id);
void do_create_keys_end (struct telegram *, struct secret_chat *U);
2014-07-26 11:55:45 +02:00
void do_add_user_to_chat (struct telegram *instance, peer_id_t chat_id, peer_id_t id, int limit);
void do_del_user_from_chat (struct telegram *instance, peer_id_t chat_id, peer_id_t id);
void do_update_status (struct telegram *instance, int online);
void do_contacts_search (struct telegram *instance, int limit, const char *s);
void do_send_msg (struct telegram *instance, struct message *M);
void do_delete_msg (struct telegram *instance, long long id);
void do_restore_msg (struct telegram *instance, long long id);
2013-11-13 04:11:25 +04:00
// For binlog
int get_dh_config_on_answer (struct query *q);
2014-07-26 11:55:45 +02:00
void fetch_dc_option (struct telegram *instance);
2014-09-01 21:25:41 +02:00
void free_queries (struct telegram *instance);
void free_timers (struct telegram *instance);
2013-10-12 00:52:20 +04:00
#endif
const char *get_last_err();
2014-07-29 15:28:04 +02:00
int all_queries_done();