Support sending messages
This commit is contained in:
parent
43a5a80c48
commit
f78adc8b96
4 changed files with 27 additions and 5 deletions
|
@ -66,7 +66,6 @@
|
|||
|
||||
#include "mtproto-common.h"
|
||||
|
||||
#include "tg-cli.h"
|
||||
|
||||
#define MAX_NET_RES (1L << 16)
|
||||
extern int log_level;
|
||||
|
|
|
@ -307,7 +307,7 @@ static int tgprpl_send_im(PurpleConnection * gc, const char *who, const char *me
|
|||
PurpleBuddy *b = purple_find_buddy(_pa, who);
|
||||
peer_id_t *peer = purple_buddy_get_protocol_data(b);
|
||||
do_send_message(*peer, message, strlen(message));
|
||||
// TODO: error handling
|
||||
flush_queries();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
22
queries.c
22
queries.c
|
@ -53,7 +53,6 @@
|
|||
|
||||
#include "no-preview.h"
|
||||
#include "binlog.h"
|
||||
#include "tg-cli.h"
|
||||
|
||||
#define sha1 SHA1
|
||||
|
||||
|
@ -75,7 +74,22 @@ long long cur_downloaded_bytes;
|
|||
extern int binlog_enabled;
|
||||
extern int sync_from_start;
|
||||
|
||||
int queries_num;
|
||||
int queries_num = 0;
|
||||
|
||||
int all_queries_done()
|
||||
{
|
||||
if (queries_num > 0) {
|
||||
logprintf("all_queries_done() == false\n");
|
||||
return 0;
|
||||
} else {
|
||||
logprintf("all_queries_done() == true\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
void flush_queries () {
|
||||
net_loop(0, all_queries_done);
|
||||
}
|
||||
|
||||
void out_peer_id (peer_id_t id);
|
||||
#define QUERY_TIMEOUT 6.0
|
||||
|
@ -162,6 +176,7 @@ struct query *send_query (struct dc *DC, int ints, void *data, struct query_meth
|
|||
|
||||
q->extra = extra;
|
||||
queries_num ++;
|
||||
logprintf("queries_num: %d\n", queries_num);
|
||||
return q;
|
||||
}
|
||||
|
||||
|
@ -201,6 +216,7 @@ void query_error (long long id) {
|
|||
tfree (q, sizeof (*q));
|
||||
}
|
||||
queries_num --;
|
||||
logprintf("queries_num: %d\n", queries_num);
|
||||
}
|
||||
|
||||
#define MAX_PACKED_SIZE (1 << 24)
|
||||
|
@ -255,6 +271,7 @@ void query_result (long long id UU) {
|
|||
in_end = eend;
|
||||
}
|
||||
queries_num --;
|
||||
logprintf("queries_num: %d\n", queries_num);
|
||||
}
|
||||
|
||||
#define event_timer_cmp(a,b) ((a)->timeout > (b)->timeout ? 1 : ((a)->timeout < (b)->timeout ? -1 : (memcmp (a, b, sizeof (struct event_timer)))))
|
||||
|
@ -2907,3 +2924,4 @@ void do_update_status (int online UU) {
|
|||
out_int (online ? CODE_bool_false : CODE_bool_true);
|
||||
send_query (DC_working, packet_ptr - packet_buffer, packet_buffer, &update_status_methods, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,11 @@ void parse_config ();
|
|||
void store_config ();
|
||||
void read_auth_file ();
|
||||
|
||||
/**
|
||||
* Read and write until all queries received a response or errored
|
||||
*/
|
||||
void flush_queries ();
|
||||
|
||||
/**
|
||||
* Connect to the telegram network with the given configuration
|
||||
*/
|
||||
|
@ -184,6 +189,6 @@ extern void *proxy_connection_data;
|
|||
void set_proxy_connection_source (void (*connection_source)(const char *host, int port, void (*on_connection_created)(int fd)), void* data);
|
||||
|
||||
/**
|
||||
* ?
|
||||
*
|
||||
*/
|
||||
void set_default_username ();
|
||||
|
|
Loading…
Add table
Reference in a new issue