annotate src/protocols/msn/transaction.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 b488205ad0bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8810
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
1 /**
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
2 * @file transaction.c MSN transaction functions
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
3 *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
4 * gaim
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
5 *
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
6 * Gaim is the legal property of its developers, whose names are too numerous
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
8 * source distribution.
8810
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
9 *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
13 * (at your option) any later version.
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
14 *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
18 * GNU General Public License for more details.
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
19 *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
23 */
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
24 #include "msn.h"
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
25 #include "transaction.h"
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
26
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
27 MsnTransaction *
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
28 msn_transaction_new(MsnCmdProc *cmdproc, const char *command,
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
29 const char *format, ...)
8810
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
30 {
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
31 MsnTransaction *trans;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
32 va_list arg;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
33
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
34 g_return_val_if_fail(command != NULL, NULL);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
35
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
36 trans = g_new0(MsnTransaction, 1);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
37
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
38 trans->cmdproc = cmdproc;
8810
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
39 trans->command = g_strdup(command);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
40
9158
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 8810
diff changeset
41 if (format != NULL)
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 8810
diff changeset
42 {
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 8810
diff changeset
43 va_start(arg, format);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 8810
diff changeset
44 trans->params = g_strdup_vprintf(format, arg);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 8810
diff changeset
45 va_end(arg);
c30d81b4dd22 [gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents: 8810
diff changeset
46 }
8810
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
47
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
48 /* trans->queue = g_queue_new(); */
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
49
8810
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
50 return trans;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
51 }
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
52
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
53 void
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
54 msn_transaction_destroy(MsnTransaction *trans)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
55 {
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
56 g_return_if_fail(trans != NULL);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
57
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
58 g_free(trans->command);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
59 g_free(trans->params);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
60 g_free(trans->payload);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
61
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
62 #if 0
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
63 if (trans->pendent_cmd != NULL)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
64 msn_message_unref(trans->pendent_msg);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
65 #endif
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
66
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
67 #if 0
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
68 MsnTransaction *elem;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
69 if (trans->queue != NULL)
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
70 {
8810
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
71 while ((elem = g_queue_pop_head(trans->queue)) != NULL)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
72 msn_transaction_destroy(elem);
9198
ab6636c5a136 [gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents: 9193
diff changeset
73
8810
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
74 g_queue_free(trans->queue);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
75 }
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
76 #endif
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
77
10284
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
78 if (trans->callbacks != NULL && trans->has_custom_callbacks)
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
79 g_hash_table_destroy(trans->callbacks);
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
80
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
81 if (trans->timer)
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
82 gaim_timeout_remove(trans->timer);
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
83
8810
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
84 g_free(trans);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
85 }
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
86
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
87 char *
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
88 msn_transaction_to_string(MsnTransaction *trans)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
89 {
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
90 char *str;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
91
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
92 g_return_val_if_fail(trans != NULL, FALSE);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
93
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
94 if (trans->params != NULL)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
95 str = g_strdup_printf("%s %u %s\r\n", trans->command, trans->trId, trans->params);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
96 else
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
97 str = g_strdup_printf("%s %u\r\n", trans->command, trans->trId);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
98
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
99 return str;
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
100 }
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
101
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
102 void
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
103 msn_transaction_queue_cmd(MsnTransaction *trans, MsnCommand *cmd)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
104 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
105 gaim_debug_info("msn", "queueing command.\n");
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
106 trans->pendent_cmd = cmd;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
107 msn_command_ref(cmd);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
108 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
109
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
110 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
111 msn_transaction_unqueue_cmd(MsnTransaction *trans, MsnCmdProc *cmdproc)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
112 {
9218
08e7ccb4610d [gaim-migrate @ 10014]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
113 MsnCommand *cmd;
08e7ccb4610d [gaim-migrate @ 10014]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
114
10481
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10403
diff changeset
115 if (!cmdproc->servconn->connected)
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10403
diff changeset
116 return;
bcfea6c3d5c9 [gaim-migrate @ 11769]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10403
diff changeset
117
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
118 gaim_debug_info("msn", "unqueueing command.\n");
9218
08e7ccb4610d [gaim-migrate @ 10014]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
119 cmd = trans->pendent_cmd;
08e7ccb4610d [gaim-migrate @ 10014]
Luke Schierer <lschiere@pidgin.im>
parents: 9198
diff changeset
120
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
121 g_return_if_fail(cmd != NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
122
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
123 msn_cmdproc_process_cmd(cmdproc, cmd);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
124 msn_command_unref(cmd);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
125
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
126 trans->pendent_cmd = NULL;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
127 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
128
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
129 #if 0
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
130 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
131 msn_transaction_queue(MsnTransaction *trans, MsnTransaction *elem)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
132 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
133 if (trans->queue == NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
134 trans->queue = g_queue_new();
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
135
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
136 g_queue_push_tail(trans->queue, elem);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
137 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
138
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
139 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
140 msn_transaction_unqueue(MsnTransaction *trans, MsnCmdProc *cmdproc)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
141 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
142 MsnTransaction *elem;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
143
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
144 while ((elem = g_queue_pop_head(trans->queue)) != NULL)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
145 msn_cmdproc_send_trans(cmdproc, elem);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
146 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
147 #endif
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
148
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
149 void
8810
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
150 msn_transaction_set_payload(MsnTransaction *trans,
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
151 const char *payload, int payload_len)
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
152 {
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
153 g_return_if_fail(trans != NULL);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
154 g_return_if_fail(payload != NULL);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
155
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
156 trans->payload = g_strdup(payload);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
157 trans->payload_len = payload_len ? payload_len : strlen(trans->payload);
a7affa2e2986 [gaim-migrate @ 9572]
Christian Hammond <chipx86@chipx86.com>
parents:
diff changeset
158 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
159
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
160 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
161 msn_transaction_set_data(MsnTransaction *trans, void *data)
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
162 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
163 g_return_if_fail(trans != NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
164
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
165 trans->data = data;
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
166 }
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
167
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
168 void
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
169 msn_transaction_add_cb(MsnTransaction *trans, char *answer,
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
170 MsnTransCb cb)
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
171 {
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
172 g_return_if_fail(trans != NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
173 g_return_if_fail(answer != NULL);
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
174
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
175 if (trans->callbacks == NULL)
10284
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
176 {
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
177 trans->has_custom_callbacks = TRUE;
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
178 trans->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
179 NULL);
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
180 }
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
181 else if (trans->has_custom_callbacks != TRUE)
f776e117c17b [gaim-migrate @ 11454]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10225
diff changeset
182 g_return_if_reached ();
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
183
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
184 g_hash_table_insert(trans->callbacks, answer, cb);
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
185 }
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
186
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
187 static gboolean
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
188 transaction_timeout(gpointer data)
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
189 {
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
190 MsnTransaction *trans;
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
191
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
192 trans = data;
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
193 g_return_val_if_fail(trans != NULL, FALSE);
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
194
10403
e5455f1dc9b6 [gaim-migrate @ 11648]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
195 #if 0
e5455f1dc9b6 [gaim-migrate @ 11648]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
196 gaim_debug_info("msn", "timed out: %s %d %s\n", trans->command, trans->trId, trans->params);
e5455f1dc9b6 [gaim-migrate @ 11648]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10284
diff changeset
197 #endif
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
198
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
199 if (trans->timeout_cb != NULL)
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
200 trans->timeout_cb(trans->cmdproc, trans);
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
201
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
202 return FALSE;
9193
502707ca1836 [gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents: 9158
diff changeset
203 }
10225
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
204
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
205 void
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
206 msn_transaction_set_timeout_cb(MsnTransaction *trans, MsnTimeoutCb cb)
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
207 {
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
208 if (trans->timer)
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
209 {
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
210 gaim_debug_error("msn", "This shouldn't be happening\n");
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
211 gaim_timeout_remove(trans->timer);
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
212 }
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
213 trans->timeout_cb = cb;
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
214 trans->timer = gaim_timeout_add(60000, transaction_timeout, trans);
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
215 }
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
216
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
217 void
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
218 msn_transaction_set_error_cb(MsnTransaction *trans, MsnErrorCb cb)
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
219 {
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
220 trans->error_cb = cb;
ecf3ce2e2ab1 [gaim-migrate @ 11357]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9218
diff changeset
221 }