[msn-proxy-devel] SF.net SVN: msn-proxy:[98] trunk
Brought to you by:
loos-br
|
From: <lo...@us...> - 2009-01-24 17:23:40
|
Revision: 98
http://msn-proxy.svn.sourceforge.net/msn-proxy/?rev=98&view=rev
Author: loos-br
Date: 2009-01-24 17:23:36 +0000 (Sat, 24 Jan 2009)
Log Message:
-----------
corrige o erro 240/ADL. Adicionado um pequeno sistema de sincronizacao.
removido o debug extra de comandos que estava ligado por padrao (para ajudar no debug de problemas mais graves como esse do ADL).
corrigido o tratamento das atualizacoes de contatos nas versoes mais antigas (MSNP8 e MSNP12).
Modified Paths:
--------------
trunk/ChangeLog
trunk/command.c
trunk/command.h
trunk/contacts.c
trunk/contacts.h
trunk/msnp18.h
trunk/ns.c
trunk/protocol.c
trunk/protocol.h
trunk/sql.c
trunk/user.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-01-23 13:47:17 UTC (rev 97)
+++ trunk/ChangeLog 2009-01-24 17:23:36 UTC (rev 98)
@@ -1,3 +1,12 @@
+2009-01-24
+
+- Corrigidos varios bugs na parte de contatos e atualizacao de contatos para
+ as versoes mais antigas MSNP8 e MSNP12
+
+- Adicionado um sistema de sincronizacao para o envio mais espacado dos
+ comandos ADL, evitando o erro 240
+
+
2009-01-20
- Corrigido o suporte ao messenger 9 (MSNP18)
Modified: trunk/command.c
===================================================================
--- trunk/command.c 2009-01-23 13:47:17 UTC (rev 97)
+++ trunk/command.c 2009-01-24 17:23:36 UTC (rev 98)
@@ -332,10 +332,12 @@
}
+#ifdef CMDDEBUG
string slog;
slog.s = cmds->buf.p;
slog.len = cmds->buf.len;
log->debug("command read buf: [%s]\n", &slog);
+#endif
/* decode command */
if (command_prepare(cmds) == AGAIN) {
@@ -365,15 +367,8 @@
/*
* command read ok - schedule write to the client
- *
- * in case of ADL commands, wait do receive all ADL commands
- * (the ADL command are received in 8k blocks)
- * this is based on the patch provided by Pierre Santana
- * (pierresantana at gmail.com) in sf forum
- *
*/
- if (strcasecmp((char *)cmds->cmd_last->cmd.s, "ADL") != 0)
- sched_write(ev_write);
+ sched_write(ev_write);
/* done */
if (cmds->buf.len == 0)
Modified: trunk/command.h
===================================================================
--- trunk/command.h 2009-01-23 13:47:17 UTC (rev 97)
+++ trunk/command.h 2009-01-24 17:23:36 UTC (rev 98)
@@ -48,6 +48,7 @@
typedef struct _commands {
string buf; /* io command buffer */
string *arg; /* tmp pointer to last arg */
+ __uint32_t wait; /* trid to wait */
__uint32_t state; /* command state */
__uint32_t payload_size; /* payload size */
struct _command *tmp; /* tmp pointer to ongoing command */
@@ -61,6 +62,7 @@
__uint32_t has_payload(command *cmd);
string **args_alloc(void *ptr, size_t len);
string *command_add_arg(command *cmd);
+void has_trid(command *cmd);
void free_command(command *cmd);
void print_command(command *cmd);
void commands_init(commands *cmds);
Modified: trunk/contacts.c
===================================================================
--- trunk/contacts.c 2009-01-23 13:47:17 UTC (rev 97)
+++ trunk/contacts.c 2009-01-24 17:23:36 UTC (rev 98)
@@ -131,7 +131,7 @@
}
struct contact_ *
-contact_save(struct user_ *user, string *c) {
+contact_update(struct user_ *user, string *c) {
struct contact_ *contact;
struct contact_ *save;
struct contact_ find;
@@ -262,8 +262,8 @@
c.len = fmt_printf(c.s, "%s@%s", &name, &domain);
str_free(&name);
- if (c.len == 0) continue;
- contact = contact_save(user, &c);
+ if (c.len == 0) { str_free(&c); continue; }
+ contact = contact_update(user, &c);
str_free(&c);
if (contact == NULL) continue;
@@ -373,7 +373,7 @@
}
}
- save = contact_save(user, &c.c);
+ save = contact_update(user, &c.c);
if (save == NULL) {
contact_free(&c);
return(ROK);
@@ -389,7 +389,6 @@
if (c.lists > 0)
save->lists = c.lists;
- contact_free(&c);
if (user->contact_delete == 0)
user->contact_delete = 1;
return(ROK);
@@ -438,7 +437,7 @@
return(RFAIL);
}
- save = contact_save(user, &c.c);
+ save = contact_update(user, &c.c);
if (save == NULL) {
contact_free(&c);
return(ROK);
@@ -452,7 +451,6 @@
if (c.lists > 0)
save->lists = c.lists;
- contact_free(&c);
if (user->contact_delete == 0)
user->contact_delete = 1;
return(ROK);
@@ -516,7 +514,7 @@
contact = RB_FIND(contacts, &user->contacts, &find);
contact_free(&find);
- save = contact_save(user, c);
+ save = contact_update(user, c);
if (save == NULL)
return(ROK);
@@ -594,7 +592,7 @@
contact = RB_FIND(contacts, &user->contacts, &find);
contact_free(&find);
- save = contact_save(user, c);
+ save = contact_update(user, c);
if (save == NULL)
return(ROK);
@@ -666,7 +664,6 @@
} else {
if (str_copy(&find.c, c->s, c->len) == 0) die_nomem();
}
-contact_print(&find);
contact = RB_FIND(contacts, &user->contacts, &find);
contact_free(&find);
@@ -676,14 +673,13 @@
if (cmd->ignore)
return(ROK);
- save = contact_save(user, &contact->c);
+ save = contact_update(user, &contact->c);
if (save == NULL)
return(ROK);
if (str_copys(&save->status, (unsigned char *)"OFF") == 0) die_nomem();
save->deny &= ~CONTACT_BLOCKED;
-contact_print(save);
(void)sql_contact_save(user, save);
if (contact->deny & CONTACT_DENY)
@@ -731,7 +727,7 @@
if (contact == NULL || cmd->ignore)
return(ROK);
- save = contact_save(user, &contact->c);
+ save = contact_update(user, &contact->c);
if (save == NULL)
return(ROK);
@@ -796,7 +792,7 @@
if (contact == NULL || cmd->ignore)
return(ROK);
- save = contact_save(user, c);
+ save = contact_update(user, c);
if (save == NULL)
return(ROK);
@@ -874,7 +870,7 @@
if (contact == NULL || cmd->ignore)
return(ROK);
- save = contact_save(user, c);
+ save = contact_update(user, c);
if (save == NULL)
return(ROK);
@@ -1037,7 +1033,7 @@
}
int
-contact_update(struct user_ *user, struct contact_ *c) {
+contact_update_status(struct user_ *user, struct contact_ *c) {
struct contact_ *contact;
contact = RB_FIND(contacts, &user->contacts, c);
@@ -1136,7 +1132,7 @@
return(RFAIL);
}
- save = contact_save(user, &contact->c);
+ save = contact_update(user, &contact->c);
if (save == NULL) {
log->debug("debug: loaduser: fail to create save contact\n");
return(RFAIL);
@@ -1147,7 +1143,7 @@
return(RFAIL);
}
- if (contact_update(user, save) == RFAIL) {
+ if (contact_update_status(user, save) == RFAIL) {
log->debug("debug: loaduser: fail to save user data from sql\n");
return(RFAIL);
}
@@ -1155,7 +1151,7 @@
if (contact->deny & CONTACT_DENY &&
strcmp((char *)contact->status.s, "OFF") != 0) {
- save = contact_save(user, &contact->c);
+ save = contact_update(user, &contact->c);
if (save == NULL) {
log->debug("debug: loaduser: fail to create save contact\n");
return(RFAIL);
@@ -1168,7 +1164,7 @@
if ((contact->deny & CONTACT_DENY) == 0 &&
contact->deny & CONTACT_BLOCKED) {
- save = contact_save(user, &contact->c);
+ save = contact_update(user, &contact->c);
if (save == NULL) {
log->debug("debug: loaduser: fail to create save contact\n");
return(RFAIL);
Modified: trunk/contacts.h
===================================================================
--- trunk/contacts.h 2009-01-23 13:47:17 UTC (rev 97)
+++ trunk/contacts.h 2009-01-24 17:23:36 UTC (rev 98)
@@ -37,8 +37,8 @@
void contact_print(struct contact_ *contact);
void contacts_free(struct user_ *user);
struct contact_ *contact_add(struct user_ *user, string *c);
-struct contact_ *contact_save(struct user_ *user, string *c);
struct contact_ *contact_find(struct user_ *user, string *c);
+struct contact_ *contact_update(struct user_ *user, string *c);
int msnp13_save_contact(struct user_ *user, command *cmd, int args);
int msnp12_save_contact(struct user_ *user, command *cmd, int args);
int msnp8_save_contact(struct user_ *user, command *cmd, int args);
Modified: trunk/msnp18.h
===================================================================
--- trunk/msnp18.h 2009-01-23 13:47:17 UTC (rev 97)
+++ trunk/msnp18.h 2009-01-24 17:23:36 UTC (rev 98)
@@ -38,7 +38,7 @@
{ "241", 2, check_args },
{ "508", 2, check_args },
{ "509", 2, check_args },
- { "ADL", 2, check_args },
+ { "ADL", 0, msnp18_adl_sync },
{ "BLP", 2, check_args },
{ "CHG", 0, check_ok },
{ "CHL", 2, check_args },
Modified: trunk/ns.c
===================================================================
--- trunk/ns.c 2009-01-23 13:47:17 UTC (rev 97)
+++ trunk/ns.c 2009-01-24 17:23:36 UTC (rev 98)
@@ -169,7 +169,13 @@
strcasecmp((char *)client->commands.cmd->cmd.s, "ADL") == 0 &&
client->commands.cmd->payload.len > (CMD_BUF * 5)) {
+ command *cmd = client->commands.cmd;
client->commands.state |= SENDDELAY;
+ if (cmd) {
+ has_trid(cmd);
+ client->commands.wait = cmd->trid;
+ } else
+ client->commands.state &= ~SENDDELAY;
}
/* command >> 1 */
@@ -178,18 +184,9 @@
server_sched_read(server);
- if (!HAS_CMD(client))
+ if (!HAS_CMD(client) || (client->commands.state & SENDDELAY))
return;
- if (client->commands.state & SENDDELAY) {
-
- /* start timer */
- log->debug("debug: AQUII 240/ADL\n");
- client->commands.state &= ~SENDDELAY;
-
- //return;
- }
-
server_sched_write(server);
}
Modified: trunk/protocol.c
===================================================================
--- trunk/protocol.c 2009-01-23 13:47:17 UTC (rev 97)
+++ trunk/protocol.c 2009-01-24 17:23:36 UTC (rev 98)
@@ -655,3 +655,17 @@
return(ROK);
}
+
+int
+msnp18_adl_sync(struct user_ *user, command *cmd, int args) {
+ client_ *client = user->ns.client;
+ server_ *server = user->ns.server;
+
+ has_trid(cmd);
+ if (cmd->trid >= client->commands.wait) {
+ client->commands.state &= ~SENDDELAY;
+ server_sched_write(server);
+ }
+
+ return(ROK);
+}
Modified: trunk/protocol.h
===================================================================
--- trunk/protocol.h 2009-01-23 13:47:17 UTC (rev 97)
+++ trunk/protocol.h 2009-01-24 17:23:36 UTC (rev 98)
@@ -38,5 +38,6 @@
int msn_warning_msg_client(struct sb_ *sb);
int send_fln(struct user_ *user, struct contact_ *contact);
int send_nln(struct user_ *user, struct contact_ *contact);
+int msnp18_adl_sync(struct user_ *user, command *cmd, int args);
#endif
Modified: trunk/sql.c
===================================================================
--- trunk/sql.c 2009-01-23 13:47:17 UTC (rev 97)
+++ trunk/sql.c 2009-01-24 17:23:36 UTC (rev 98)
@@ -876,7 +876,7 @@
if ((contact->deny & CONTACT_REMOVED) == 0) {
- save = contact_save(user, &contact->c);
+ save = contact_update(user, &contact->c);
if (save == NULL)
continue;
Modified: trunk/user.c
===================================================================
--- trunk/user.c 2009-01-23 13:47:17 UTC (rev 97)
+++ trunk/user.c 2009-01-24 17:23:36 UTC (rev 98)
@@ -68,8 +68,8 @@
int
msn_update_status(struct user_ *user, command *cmd, int args) {
string *status = cmd->args[1];
- string *img = cmd->args[3];
- log_ *log = &config.log;
+ string *o = cmd->args[3];
+ log_ *log = &config.log;
if (cmd->args_len < 2 || status == NULL || status->len == 0)
return(RFAIL);
@@ -93,11 +93,20 @@
}
/* check img acl */
- if ( (user->commands & USEIMG) && cmd->args_len == 4) {
- str_free(img);
- free(img);
- cmd->args[3] = (string *)0;
- cmd->args_len--;
+ if ( (user->commands & USEIMG) && cmd->args_len == 4 && o) {
+ switch (user->version) {
+ case MSNP15:
+ case MSNP16:
+ case MSNP17:
+ case MSNP18:
+ if (str_copys(o, (unsigned char *)"0") == 0) exit (51);
+ break;
+ default:
+ str_free(o);
+ free(o);
+ cmd->args[3] = NULL;
+ cmd->args_len--;
+ }
}
return(ROK);
@@ -120,7 +129,7 @@
if (cmd->args_len < 1 || (c = get_arg(cmd, 0)) == NULL)
return(RFAIL);
- contact = contact_save(user, c);
+ contact = contact_update(user, c);
if (contact == NULL)
return(RFAIL);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|