Use correct DC number for our updated application configuration

This commit is contained in:
mjentsch 2014-10-03 18:19:50 +02:00
parent e3d6f02a67
commit 84e549fc96
5 changed files with 11 additions and 19 deletions

5
loop.c
View file

@ -120,8 +120,8 @@ void empty_auth_file (const char *filename) {
memset(state.DC_list, 0, 11 * sizeof(void *));
debug("empty_auth_file()\n");
alloc_dc (state.DC_list, 1, tstrdup (TG_SERVER), 443);
state.dc_working_num = 1;
alloc_dc (state.DC_list, TG_DC_NUM, tstrdup (TG_SERVER), TG_PORT);
state.dc_working_num = TG_DC_NUM;
state.auth_state = 0;
write_auth_file (&state, filename);
}
@ -162,6 +162,7 @@ struct authorization_state read_auth_file (const char *filename) {
assert (x <= MAX_DC_ID);
assert (read (auth_file_fd, &state.dc_working_num, 4) == 4);
assert (read (auth_file_fd, &state.auth_state, 4) == 4);
debug ("dc_working_num=%d, auth_state=%d \n", state.dc_working_num, state.auth_state);
if (m == DC_SERIALIZED_MAGIC) {
state.auth_state = 700;
}

6
net.h
View file

@ -27,11 +27,13 @@ struct dc;
#include "telegram.h"
#include "queries.h"
#define TG_SERVER "149.154.167.50"
#define TG_SERVER "149.154.167.50"
#define TG_DC_NUM 2
#define TG_SERVER_TEST "149.154.167.40"
#define TG_PORT 443
#define TG_TEST_DC_NUM 2
#define TG_APP_HASH "99428c722d0ed59b9cd844e4577cb4bb"
#define TG_APP_ID 16154
#define TG_PORT 443
#define ACK_TIMEOUT 1
#define MAX_DC_ID 10

View file

@ -184,7 +184,7 @@ static void tgprpl_output_cb(gpointer data, gint source, PurpleInputCondition co
{
mtproto_handle *conn = data;
if (!conn->mtp) {
debug ("connection no loner existing, do nothing. \n");
debug ("connection no longer existing, do nothing. \n");
return;
}
if (mtp_write_output(conn->mtp) == 0) {
@ -242,13 +242,6 @@ static void tgprpl_has_input(void *handle)
}
}
static void init_dc_settings(PurpleAccount *acc, struct dc *DC)
{
DC->port = purple_account_get_int(acc, "port", TG_PORT);
DC->ip = g_strdup(purple_account_get_string(acc, "server", TG_SERVER));
DC->id = 0;
}
/**
* Telegram requests a new connectino to our configured proxy
*/
@ -453,11 +446,9 @@ static void tgprpl_login(PurpleAccount * acct)
purple_debug_info(PLUGIN_ID, "tgprpl_login()\n");
PurpleConnection *gc = purple_account_get_connection(acct);
char const *username = purple_account_get_username(acct);
struct dc DC;
init_dc_settings(acct, &DC);
// create a new instance of telegram
struct telegram *tg = telegram_new (&DC, username, &tgconf);
struct telegram *tg = telegram_new (username, &tgconf);
telegram_restore_session(tg);
// create handle to store additional info for libpurple in

View file

@ -188,11 +188,10 @@ void telegram_change_state (struct telegram *instance, int state, void *data)
}
}
struct telegram *telegram_new(struct dc *DC, const char* login, struct telegram_config *config)
struct telegram *telegram_new(const char* login, struct telegram_config *config)
{
struct telegram *this = talloc0(sizeof(struct telegram));
this->protocol_data = NULL;
this->auth.DC_list[0] = DC;
this->bl = talloc0 (sizeof(struct binlog));
this->config = config;

View file

@ -294,11 +294,10 @@ struct telegram {
/**
* Create a new telegram application
*
* @param DC The initial data center to use
* @param login The phone number to use as login name
* @param config Contains all callbacks used for the telegram instance
*/
struct telegram *telegram_new(struct dc *DC, const char* login, struct telegram_config *config);
struct telegram *telegram_new(const char* login, struct telegram_config *config);
void telegram_restore_session(struct telegram *instance);
void telegram_store_session(struct telegram *instance);