Mercurial > pidgin
comparison src/protocols/msn/cmdproc.c @ 10481:bcfea6c3d5c9
[gaim-migrate @ 11769]
Patch 1093958 from Felipe Contreras. It fixes stuff.
I also made some tweaks to make valgrind a bit happier.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Fri, 07 Jan 2005 02:48:33 +0000 |
parents | e5455f1dc9b6 |
children | 1a97d5e88d12 |
comparison
equal
deleted
inserted
replaced
10480:8e0a91d11362 | 10481:bcfea6c3d5c9 |
---|---|
41 void | 41 void |
42 msn_cmdproc_destroy(MsnCmdProc *cmdproc) | 42 msn_cmdproc_destroy(MsnCmdProc *cmdproc) |
43 { | 43 { |
44 MsnTransaction *trans; | 44 MsnTransaction *trans; |
45 | 45 |
46 if (cmdproc->last_trans != NULL) | |
47 g_free(cmdproc->last_trans); | |
48 | |
49 while ((trans = g_queue_pop_head(cmdproc->txqueue)) != NULL) | 46 while ((trans = g_queue_pop_head(cmdproc->txqueue)) != NULL) |
50 msn_transaction_destroy(trans); | 47 msn_transaction_destroy(trans); |
51 | 48 |
52 g_queue_free(cmdproc->txqueue); | 49 g_queue_free(cmdproc->txqueue); |
53 | 50 |
54 msn_history_destroy(cmdproc->history); | 51 msn_history_destroy(cmdproc->history); |
52 g_free(cmdproc); | |
55 } | 53 } |
56 | 54 |
57 void | 55 void |
58 msn_cmdproc_process_queue(MsnCmdProc *cmdproc) | 56 msn_cmdproc_process_queue(MsnCmdProc *cmdproc) |
59 { | 57 { |
60 MsnTransaction *trans; | 58 MsnTransaction *trans; |
61 | 59 |
62 while ((trans = g_queue_pop_head(cmdproc->txqueue)) != NULL && | 60 while ((trans = g_queue_pop_head(cmdproc->txqueue)) != NULL) |
63 cmdproc->error == 0) | |
64 { | |
65 msn_cmdproc_send_trans(cmdproc, trans); | 61 msn_cmdproc_send_trans(cmdproc, trans); |
66 } | |
67 } | 62 } |
68 | 63 |
69 void | 64 void |
70 msn_cmdproc_queue_trans(MsnCmdProc *cmdproc, MsnTransaction *trans) | 65 msn_cmdproc_queue_trans(MsnCmdProc *cmdproc, MsnTransaction *trans) |
71 { | 66 { |
107 MsnServConn *servconn; | 102 MsnServConn *servconn; |
108 char *data; | 103 char *data; |
109 size_t len; | 104 size_t len; |
110 | 105 |
111 g_return_if_fail(cmdproc != NULL); | 106 g_return_if_fail(cmdproc != NULL); |
112 g_return_if_fail(cmdproc->ready); | |
113 g_return_if_fail(trans != NULL); | 107 g_return_if_fail(trans != NULL); |
114 | 108 |
115 servconn = cmdproc->servconn; | 109 servconn = cmdproc->servconn; |
110 | |
111 if (!servconn->connected) | |
112 return; | |
113 | |
116 msn_history_add(cmdproc->history, trans); | 114 msn_history_add(cmdproc->history, trans); |
117 | 115 |
118 data = msn_transaction_to_string(trans); | 116 data = msn_transaction_to_string(trans); |
119 | |
120 if (cmdproc->last_trans != NULL) | |
121 g_free(cmdproc->last_trans); | |
122 | |
123 cmdproc->last_trans = g_strdup(data); | |
124 | 117 |
125 len = strlen(data); | 118 len = strlen(data); |
126 | 119 |
127 show_debug_cmd(cmdproc, FALSE, data); | 120 show_debug_cmd(cmdproc, FALSE, data); |
128 | 121 |
151 char *params = NULL; | 144 char *params = NULL; |
152 va_list arg; | 145 va_list arg; |
153 size_t len; | 146 size_t len; |
154 | 147 |
155 g_return_if_fail(cmdproc != NULL); | 148 g_return_if_fail(cmdproc != NULL); |
156 g_return_if_fail(cmdproc->ready); | |
157 g_return_if_fail(command != NULL); | 149 g_return_if_fail(command != NULL); |
158 | 150 |
159 servconn = cmdproc->servconn; | 151 servconn = cmdproc->servconn; |
152 | |
153 if (!servconn->connected) | |
154 return; | |
160 | 155 |
161 if (format != NULL) | 156 if (format != NULL) |
162 { | 157 { |
163 va_start(arg, format); | 158 va_start(arg, format); |
164 params = g_strdup_vprintf(format, arg); | 159 params = g_strdup_vprintf(format, arg); |
187 { | 182 { |
188 MsnTransaction *trans; | 183 MsnTransaction *trans; |
189 va_list arg; | 184 va_list arg; |
190 | 185 |
191 g_return_if_fail(cmdproc != NULL); | 186 g_return_if_fail(cmdproc != NULL); |
192 g_return_if_fail(cmdproc->ready); | |
193 g_return_if_fail(command != NULL); | 187 g_return_if_fail(command != NULL); |
188 | |
189 if (!cmdproc->servconn->connected) | |
190 return; | |
194 | 191 |
195 trans = g_new0(MsnTransaction, 1); | 192 trans = g_new0(MsnTransaction, 1); |
196 | 193 |
197 trans->command = g_strdup(command); | 194 trans->command = g_strdup(command); |
198 | 195 |
315 { | 312 { |
316 gaim_debug_warning("msn", "Unhandled command '%s'\n", | 313 gaim_debug_warning("msn", "Unhandled command '%s'\n", |
317 cmd->command); | 314 cmd->command); |
318 } | 315 } |
319 | 316 |
320 #if 1 | |
321 /* TODO this is really ugly */ | |
322 /* Since commands have not stored payload and we need it for pendent | |
323 * commands at the time we process again the same command we will try | |
324 * to read again the payload of payload_len size but we will actually | |
325 * read sometime else, and reading from server synchronization goes to | |
326 * hell. */ | |
327 /* Now we store the payload in the command when we queue them :D */ | |
328 | |
329 if (trans != NULL && trans->pendent_cmd != NULL) | 317 if (trans != NULL && trans->pendent_cmd != NULL) |
330 if (cmdproc->ready) | 318 msn_transaction_unqueue_cmd(trans, cmdproc); |
331 msn_transaction_unqueue_cmd(trans, cmdproc); | |
332 #endif | |
333 } | 319 } |
334 | 320 |
335 void | 321 void |
336 msn_cmdproc_process_cmd_text(MsnCmdProc *cmdproc, const char *command) | 322 msn_cmdproc_process_cmd_text(MsnCmdProc *cmdproc, const char *command) |
337 { | 323 { |
342 | 328 |
343 cmdproc->last_cmd = msn_command_from_string(command); | 329 cmdproc->last_cmd = msn_command_from_string(command); |
344 | 330 |
345 msn_cmdproc_process_cmd(cmdproc, cmdproc->last_cmd); | 331 msn_cmdproc_process_cmd(cmdproc, cmdproc->last_cmd); |
346 } | 332 } |
347 | |
348 void | |
349 msn_cmdproc_show_error(MsnCmdProc *cmdproc, int error) | |
350 { | |
351 GaimConnection *gc = | |
352 gaim_account_get_connection(cmdproc->session->account); | |
353 | |
354 char *tmp; | |
355 | |
356 tmp = NULL; | |
357 | |
358 switch (error) | |
359 { | |
360 case MSN_ERROR_MISC: | |
361 tmp = _("Miscellaneous error"); break; | |
362 case MSN_ERROR_SIGNOTHER: | |
363 gc->wants_to_die = TRUE; | |
364 tmp = _("You have signed on from another location."); break; | |
365 case MSN_ERROR_SERVDOWN: | |
366 tmp = _("The MSN servers are going down temporarily."); break; | |
367 default: | |
368 break; | |
369 } | |
370 | |
371 if (tmp != NULL) | |
372 { | |
373 gaim_connection_error(gc, tmp); | |
374 } | |
375 } |