Mercurial > pidgin
annotate src/protocols/msn/switchboard.c @ 10568:fed2a7c2471d
[gaim-migrate @ 11954]
Some MSN bits:
- Fix HTTP Method works when using an HTTP proxy that require authentication
(Bastien Durel)
- Better error reporting when the MSN servers are temporarily unavailable
- Prevent zombie failed switchboard connections swallowing up messages
- Fix win32 crashes receiving messages from aMSN with no formatting info
- Fix a crash when the connection to the nexus server fails
- maybe some other stuff, I forgot how much had piled up
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Thu, 03 Feb 2005 19:47:52 +0000 |
parents | ace8cd0de6ea |
children | f0fd35985cb0 |
rev | line source |
---|---|
4542 | 1 /** |
2 * @file switchboard.c MSN switchboard functions | |
3 * | |
4 * gaim | |
5 * | |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
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:
9194
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:
9194
diff
changeset
|
8 * source distribution. |
6668
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
9 * |
4542 | 10 * This program is free software; you can redistribute it and/or modify |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
8207
aa44049e8891
[gaim-migrate @ 8930]
Christian Hammond <chipx86@chipx86.com>
parents:
7639
diff
changeset
|
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
4542 | 23 */ |
24 #include "msn.h" | |
5626
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
25 #include "prefs.h" |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
26 #include "switchboard.h" |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
27 #include "notification.h" |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
28 #include "utils.h" |
4542 | 29 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
30 #include "error.h" |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
31 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
32 static MsnTable *cbs_table; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
33 |
10345 | 34 static void msg_error_helper(MsnCmdProc *cmdproc, MsnMessage *msg, |
35 MsnMsgErrorType error); | |
36 | |
37 /************************************************************************** | |
10481 | 38 * Main |
10345 | 39 **************************************************************************/ |
10481 | 40 |
10345 | 41 MsnSwitchBoard * |
42 msn_switchboard_new(MsnSession *session) | |
43 { | |
44 MsnSwitchBoard *swboard; | |
45 MsnServConn *servconn; | |
46 | |
47 g_return_val_if_fail(session != NULL, NULL); | |
48 | |
49 swboard = g_new0(MsnSwitchBoard, 1); | |
50 | |
51 swboard->session = session; | |
10481 | 52 swboard->servconn = servconn = msn_servconn_new(session, MSN_SERVCONN_SB); |
10463 | 53 swboard->cmdproc = servconn->cmdproc; |
10345 | 54 |
10481 | 55 swboard->msg_queue = g_queue_new(); |
10345 | 56 swboard->empty = TRUE; |
57 | |
10463 | 58 swboard->cmdproc->data = swboard; |
59 swboard->cmdproc->cbs_table = cbs_table; | |
10345 | 60 |
61 session->switches = g_list_append(session->switches, swboard); | |
62 | |
63 return swboard; | |
64 } | |
65 | |
66 void | |
67 msn_switchboard_destroy(MsnSwitchBoard *swboard) | |
68 { | |
69 MsnSession *session; | |
70 MsnMessage *msg; | |
71 GList *l; | |
72 | |
73 g_return_if_fail(swboard != NULL); | |
74 | |
75 /* If it linked us is because its looking for trouble */ | |
76 if (swboard->slplink != NULL) | |
77 msn_slplink_destroy(swboard->slplink); | |
78 | |
79 /* Destroy the message queue */ | |
10481 | 80 while ((msg = g_queue_pop_head(swboard->msg_queue)) != NULL) |
10345 | 81 { |
82 if (swboard->error != MSN_SB_ERROR_NONE) | |
83 { | |
84 /* The messages could not be sent due to a switchboard error */ | |
10463 | 85 msg_error_helper(swboard->cmdproc, msg, |
10345 | 86 MSN_MSG_ERROR_SB); |
87 } | |
10403 | 88 msn_message_unref(msg); |
10345 | 89 } |
90 | |
10481 | 91 g_queue_free(swboard->msg_queue); |
10345 | 92 |
10403 | 93 for (l = swboard->ack_list; l != NULL; l = l->next) |
94 msn_message_unref(l->data); | |
95 | |
10345 | 96 if (swboard->im_user != NULL) |
97 g_free(swboard->im_user); | |
98 | |
99 if (swboard->auth_key != NULL) | |
100 g_free(swboard->auth_key); | |
101 | |
102 if (swboard->session_id != NULL) | |
103 g_free(swboard->session_id); | |
104 | |
105 for (l = swboard->users; l != NULL; l = l->next) | |
106 g_free(l->data); | |
107 | |
108 session = swboard->session; | |
109 session->switches = g_list_remove(session->switches, swboard); | |
110 | |
10481 | 111 #if 0 |
112 /* This should never happen or we are in trouble. */ | |
10345 | 113 if (swboard->servconn != NULL) |
114 msn_servconn_destroy(swboard->servconn); | |
10481 | 115 #endif |
116 | |
117 swboard->cmdproc->data = NULL; | |
118 | |
119 msn_servconn_set_disconnect_cb(swboard->servconn, NULL); | |
120 | |
121 msn_servconn_destroy(swboard->servconn); | |
10345 | 122 |
123 g_free(swboard); | |
124 } | |
125 | |
126 void | |
127 msn_switchboard_set_auth_key(MsnSwitchBoard *swboard, const char *key) | |
128 { | |
129 g_return_if_fail(swboard != NULL); | |
130 g_return_if_fail(key != NULL); | |
131 | |
132 swboard->auth_key = g_strdup(key); | |
133 } | |
134 | |
135 const char * | |
136 msn_switchboard_get_auth_key(MsnSwitchBoard *swboard) | |
137 { | |
138 g_return_val_if_fail(swboard != NULL, NULL); | |
139 | |
140 return swboard->auth_key; | |
141 } | |
142 | |
143 void | |
144 msn_switchboard_set_session_id(MsnSwitchBoard *swboard, const char *id) | |
145 { | |
146 g_return_if_fail(swboard != NULL); | |
147 g_return_if_fail(id != NULL); | |
148 | |
149 if (swboard->session_id != NULL) | |
150 g_free(swboard->session_id); | |
151 | |
152 swboard->session_id = g_strdup(id); | |
153 } | |
154 | |
155 const char * | |
156 msn_switchboard_get_session_id(MsnSwitchBoard *swboard) | |
157 { | |
158 g_return_val_if_fail(swboard != NULL, NULL); | |
159 | |
160 return swboard->session_id; | |
161 } | |
162 | |
163 void | |
164 msn_switchboard_set_invited(MsnSwitchBoard *swboard, gboolean invited) | |
165 { | |
166 g_return_if_fail(swboard != NULL); | |
167 | |
168 swboard->invited = invited; | |
169 } | |
170 | |
171 gboolean | |
172 msn_switchboard_is_invited(MsnSwitchBoard *swboard) | |
173 { | |
174 g_return_val_if_fail(swboard != NULL, FALSE); | |
175 | |
176 return swboard->invited; | |
177 } | |
10225 | 178 |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
179 /************************************************************************** |
10481 | 180 * Utility |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
181 **************************************************************************/ |
10481 | 182 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
183 static void |
5793
952710ac6635
[gaim-migrate @ 6218]
Christian Hammond <chipx86@chipx86.com>
parents:
5679
diff
changeset
|
184 send_clientcaps(MsnSwitchBoard *swboard) |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
185 { |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
186 MsnMessage *msg; |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
187 |
10225 | 188 msg = msn_message_new(MSN_MSG_CAPS); |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
189 msn_message_set_content_type(msg, "text/x-clientcaps"); |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
190 msn_message_set_flag(msg, 'U'); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
191 msn_message_set_bin_data(msg, MSN_CLIENTINFO, strlen(MSN_CLIENTINFO)); |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
192 |
10481 | 193 msn_switchboard_send_msg(swboard, msg, TRUE); |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
194 |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
195 msn_message_destroy(msg); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
196 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
197 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
198 void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
199 msn_switchboard_add_user(MsnSwitchBoard *swboard, const char *user) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
200 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
201 MsnCmdProc *cmdproc; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
202 GaimAccount *account; |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
203 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
204 g_return_if_fail(swboard != NULL); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
205 |
10463 | 206 cmdproc = swboard->cmdproc; |
207 account = cmdproc->session->account; | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
208 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
209 swboard->users = g_list_prepend(swboard->users, g_strdup(user)); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
210 swboard->current_users++; |
10346 | 211 swboard->empty = FALSE; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
212 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
213 /* gaim_debug_info("msn", "user=[%s], total=%d\n", user, |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
214 * swboard->current_users); */ |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
215 |
10345 | 216 if ((swboard->conv != NULL) && |
217 (gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT)) | |
9363
997c28571364
[gaim-migrate @ 10171]
Christian Hammond <chipx86@chipx86.com>
parents:
9218
diff
changeset
|
218 { |
10345 | 219 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), user, NULL, |
220 GAIM_CBFLAGS_NONE, TRUE); | |
9363
997c28571364
[gaim-migrate @ 10171]
Christian Hammond <chipx86@chipx86.com>
parents:
9218
diff
changeset
|
221 } |
997c28571364
[gaim-migrate @ 10171]
Christian Hammond <chipx86@chipx86.com>
parents:
9218
diff
changeset
|
222 else if (swboard->current_users > 1 || swboard->total_users > 1) |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
223 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
224 if (swboard->conv == NULL || |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
225 gaim_conversation_get_type(swboard->conv) != GAIM_CONV_CHAT) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
226 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
227 GList *l; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
228 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
229 /* gaim_debug_info("msn", "[chat] Switching to chat.\n"); */ |
10533 | 230 #if 0 |
231 /* this is bad - it causes msn_switchboard_close to be called on the | |
232 * switchboard we're in the middle of using :( */ | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
233 if (swboard->conv != NULL) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
234 gaim_conversation_destroy(swboard->conv); |
10533 | 235 #endif |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
236 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
237 cmdproc->session->conv_seq++; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
238 swboard->chat_id = cmdproc->session->conv_seq; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
239 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
240 swboard->conv = serv_got_joined_chat(account->gc, |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
241 swboard->chat_id, |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
242 "MSN Chat"); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
243 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
244 for (l = swboard->users; l != NULL; l = l->next) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
245 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
246 const char *tmp_user; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
247 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
248 tmp_user = l->data; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
249 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
250 /* gaim_debug_info("msn", "[chat] Adding [%s].\n", |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
251 * tmp_user); */ |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
252 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
253 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), |
9846 | 254 tmp_user, NULL, GAIM_CBFLAGS_NONE, TRUE); |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
255 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
256 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
257 /* gaim_debug_info("msn", "[chat] We add ourselves.\n"); */ |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
258 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
259 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
260 gaim_account_get_username(account), |
9846 | 261 NULL, GAIM_CBFLAGS_NONE, TRUE); |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
262 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
263 g_free(swboard->im_user); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
264 swboard->im_user = NULL; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
265 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
266 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
267 else if (swboard->conv == NULL) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
268 { |
10246 | 269 /* XXX - I think this should probably be GAIM_CONV_CHAT, but I'm hedging */ |
270 swboard->conv = gaim_find_conversation_with_account(GAIM_CONV_ANY, | |
271 user, account); | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
272 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
273 else |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
274 { |
9363
997c28571364
[gaim-migrate @ 10171]
Christian Hammond <chipx86@chipx86.com>
parents:
9218
diff
changeset
|
275 gaim_debug_warning("msn", "This should not happen!" |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
276 "(msn_switchboard_add_user)\n"); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
277 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
278 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
279 |
10225 | 280 GaimConversation * |
281 msn_switchboard_get_conv(MsnSwitchBoard *swboard) | |
282 { | |
283 GaimAccount *account; | |
284 | |
285 g_return_val_if_fail(swboard != NULL, NULL); | |
286 | |
287 if (swboard->conv != NULL) | |
288 return swboard->conv; | |
289 | |
10346 | 290 gaim_debug_error("msn", "Switchboard with unassigned conversation\n"); |
10345 | 291 |
10225 | 292 account = swboard->session->account; |
293 | |
10246 | 294 /* XXX - I think this should probably be GAIM_CONV_IM, but I'm hedging */ |
295 return gaim_find_conversation_with_account(GAIM_CONV_IM, | |
296 swboard->im_user, account); | |
10225 | 297 } |
298 | |
299 void | |
300 msn_switchboard_report_user(MsnSwitchBoard *swboard, GaimMessageFlags flags, const char *msg) | |
301 { | |
302 GaimConversation *conv; | |
303 | |
304 g_return_if_fail(swboard != NULL); | |
305 g_return_if_fail(msg != NULL); | |
306 | |
307 if ((conv = msn_switchboard_get_conv(swboard)) != NULL) | |
308 { | |
309 gaim_conversation_write(conv, NULL, msg, flags, time(NULL)); | |
310 } | |
311 } | |
312 | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
313 static void |
10345 | 314 swboard_error_helper(MsnSwitchBoard *swboard, int reason, const char *passport) |
315 { | |
10451 | 316 g_return_if_fail(swboard != NULL); |
317 | |
10345 | 318 gaim_debug_info("msg", "Error: Unable to call the user %s\n", passport); |
319 | |
10533 | 320 /* TODO: if current_users > 0, this is probably a chat and an invite failed, |
321 * we should report that in the chat or something */ | |
322 if (swboard->current_users == 0) | |
10345 | 323 { |
324 swboard->error = reason; | |
10463 | 325 msn_switchboard_close(swboard); |
10345 | 326 } |
327 } | |
328 | |
329 static void | |
330 cal_error_helper(MsnTransaction *trans, int reason) | |
331 { | |
332 MsnSwitchBoard *swboard; | |
333 const char *passport; | |
334 char **params; | |
335 | |
336 params = g_strsplit(trans->params, " ", 0); | |
337 | |
338 passport = params[0]; | |
339 | |
340 swboard = trans->data; | |
341 | |
342 swboard_error_helper(swboard, reason, passport); | |
343 | |
344 g_strfreev(params); | |
345 } | |
346 | |
347 static void | |
348 msg_error_helper(MsnCmdProc *cmdproc, MsnMessage *msg, MsnMsgErrorType error) | |
349 { | |
10403 | 350 MsnSwitchBoard *swboard; |
351 | |
10345 | 352 g_return_if_fail(cmdproc != NULL); |
353 g_return_if_fail(msg != NULL); | |
354 | |
10403 | 355 if ((error != MSN_MSG_ERROR_SB) && (msg->nak_cb != NULL)) |
10345 | 356 msg->nak_cb(msg, msg->ack_data); |
357 | |
10463 | 358 swboard = cmdproc->data; |
10403 | 359 |
10345 | 360 if (msg->type == MSN_MSG_TEXT) |
361 { | |
10504 | 362 const char *format, *str_reason; |
10346 | 363 char *body_str, *body_enc, *pre, *post; |
10345 | 364 |
365 #if 0 | |
366 if (swboard->conv == NULL) | |
367 { | |
10346 | 368 if (msg->ack_ref) |
10403 | 369 msn_message_unref(msg); |
10346 | 370 |
10345 | 371 return; |
372 } | |
373 #endif | |
374 | |
10346 | 375 if (error == MSN_MSG_ERROR_TIMEOUT) |
10345 | 376 { |
377 str_reason = _("Message may have not been sent " | |
10451 | 378 "because a timeout occurred:"); |
10345 | 379 } |
10346 | 380 else if (error == MSN_MSG_ERROR_SB) |
10345 | 381 { |
382 switch (swboard->error) | |
383 { | |
384 case MSN_SB_ERROR_OFFLINE: | |
385 str_reason = _("Message could not be sent, " | |
10346 | 386 "not allowed while invisible:"); |
10345 | 387 break; |
388 case MSN_SB_ERROR_USER_OFFLINE: | |
389 str_reason = _("Message could not be sent " | |
10346 | 390 "because the user is offline:"); |
10345 | 391 break; |
392 case MSN_SB_ERROR_CONNECTION: | |
393 str_reason = _("Message could not be sent " | |
10391 | 394 "because a connection error occurred:"); |
10345 | 395 break; |
396 default: | |
397 str_reason = _("Message could not be sent " | |
398 "because an error with " | |
10391 | 399 "the switchboard occurred:"); |
10345 | 400 break; |
401 } | |
402 } | |
403 else | |
404 { | |
405 str_reason = _("Message may have not been sent " | |
10391 | 406 "because an unknown error occurred:"); |
10345 | 407 } |
408 | |
10346 | 409 body_str = msn_message_to_string(msg); |
410 body_enc = gaim_escape_html(body_str); | |
411 g_free(body_str); | |
412 | |
413 format = msn_message_get_attr(msg, "X-MMS-IM-Format"); | |
414 msn_parse_format(format, &pre, &post); | |
10568 | 415 body_str = g_strdup_printf("%s%s%s", pre ? pre : "", |
416 body_enc ? body_enc : "", post ? post : ""); | |
10346 | 417 g_free(body_enc); |
418 g_free(pre); | |
419 g_free(post); | |
10345 | 420 |
10403 | 421 msn_switchboard_report_user(swboard, GAIM_MESSAGE_ERROR, |
422 str_reason); | |
423 msn_switchboard_report_user(swboard, GAIM_MESSAGE_RAW, | |
424 body_str); | |
10345 | 425 |
10346 | 426 g_free(body_str); |
10345 | 427 } |
428 | |
10403 | 429 /* If a timeout occures we will want the msg around just in case we |
430 * receive the ACK after the timeout. */ | |
431 if (msg->ack_ref && error != MSN_MSG_ERROR_TIMEOUT) | |
432 { | |
433 swboard->ack_list = g_list_remove(swboard->ack_list, msg); | |
10346 | 434 msn_message_unref(msg); |
10403 | 435 } |
10345 | 436 } |
437 | |
438 /************************************************************************** | |
10481 | 439 * Message Stuff |
440 **************************************************************************/ | |
441 | |
442 /** Called when a message times out. */ | |
443 static void | |
444 msg_timeout(MsnCmdProc *cmdproc, MsnTransaction *trans) | |
445 { | |
446 MsnMessage *msg; | |
447 | |
448 msg = trans->data; | |
449 | |
450 msg_error_helper(cmdproc, msg, MSN_MSG_ERROR_TIMEOUT); | |
451 } | |
452 | |
453 /** Called when we receive an error of a message. */ | |
454 static void | |
455 msg_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
456 { | |
457 msg_error_helper(cmdproc, trans->data, MSN_MSG_ERROR_UNKNOWN); | |
458 } | |
459 | |
460 #if 0 | |
461 /** Called when we receive an ack of a special message. */ | |
462 static void | |
463 msg_ack(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
464 { | |
465 MsnMessage *msg; | |
466 | |
467 msg = cmd->trans->data; | |
468 | |
469 if (msg->ack_cb != NULL) | |
470 msg->ack_cb(msg->ack_data); | |
471 | |
472 msn_message_unref(msg); | |
473 } | |
474 | |
475 /** Called when we receive a nak of a special message. */ | |
476 static void | |
477 msg_nak(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
478 { | |
479 MsnMessage *msg; | |
480 | |
481 msg = cmd->trans->data; | |
482 | |
483 msn_message_unref(msg); | |
484 } | |
485 #endif | |
486 | |
487 static void | |
488 release_msg(MsnSwitchBoard *swboard, MsnMessage *msg) | |
489 { | |
490 MsnCmdProc *cmdproc; | |
491 MsnTransaction *trans; | |
492 char *payload; | |
493 gsize payload_len; | |
494 | |
495 g_return_if_fail(swboard != NULL); | |
496 g_return_if_fail(msg != NULL); | |
497 | |
498 cmdproc = swboard->cmdproc; | |
499 | |
500 payload = msn_message_gen_payload(msg, &payload_len); | |
501 | |
502 /* msn_message_show_readable(msg, "SB SEND", FALSE); */ | |
503 | |
504 trans = msn_transaction_new(cmdproc, "MSG", "%c %d", | |
505 msn_message_get_flag(msg), payload_len); | |
506 | |
507 /* Data for callbacks */ | |
508 msn_transaction_set_data(trans, msg); | |
509 | |
510 if (msg->type == MSN_MSG_TEXT) | |
511 { | |
512 msg->ack_ref = TRUE; | |
513 msn_message_ref(msg); | |
514 swboard->ack_list = g_list_append(swboard->ack_list, msg); | |
515 msn_transaction_set_timeout_cb(trans, msg_timeout); | |
516 } | |
517 else if (msg->type == MSN_MSG_SLP) | |
518 { | |
519 msg->ack_ref = TRUE; | |
520 msn_message_ref(msg); | |
521 swboard->ack_list = g_list_append(swboard->ack_list, msg); | |
522 msn_transaction_set_timeout_cb(trans, msg_timeout); | |
523 #if 0 | |
524 if (msg->ack_cb != NULL) | |
525 { | |
526 msn_transaction_add_cb(trans, "ACK", msg_ack); | |
527 msn_transaction_add_cb(trans, "NAK", msg_nak); | |
528 } | |
529 #endif | |
530 } | |
531 | |
532 trans->payload = payload; | |
533 trans->payload_len = payload_len; | |
534 | |
535 msg->trans = trans; | |
536 | |
537 msn_cmdproc_send_trans(cmdproc, trans); | |
538 } | |
539 | |
540 static void | |
541 queue_msg(MsnSwitchBoard *swboard, MsnMessage *msg) | |
542 { | |
543 g_return_if_fail(swboard != NULL); | |
544 g_return_if_fail(msg != NULL); | |
545 | |
546 gaim_debug_info("msn", "Appending message to queue.\n"); | |
547 | |
548 g_queue_push_tail(swboard->msg_queue, msg); | |
549 | |
550 msn_message_ref(msg); | |
551 } | |
552 | |
553 static void | |
554 process_queue(MsnSwitchBoard *swboard) | |
555 { | |
556 MsnMessage *msg; | |
557 | |
558 g_return_if_fail(swboard != NULL); | |
559 | |
560 gaim_debug_info("msn", "Processing queue\n"); | |
561 | |
562 while ((msg = g_queue_pop_head(swboard->msg_queue)) != NULL) | |
563 { | |
564 gaim_debug_info("msn", "Sending message\n"); | |
565 release_msg(swboard, msg); | |
566 msn_message_unref(msg); | |
567 } | |
568 } | |
569 | |
570 gboolean | |
571 msn_switchboard_can_send(MsnSwitchBoard *swboard) | |
572 { | |
573 g_return_val_if_fail(swboard != NULL, FALSE); | |
574 | |
575 if (swboard->empty || !g_queue_is_empty(swboard->msg_queue)) | |
576 return FALSE; | |
577 | |
578 return TRUE; | |
579 } | |
580 | |
581 void | |
582 msn_switchboard_send_msg(MsnSwitchBoard *swboard, MsnMessage *msg, | |
583 gboolean queue) | |
584 { | |
585 g_return_if_fail(swboard != NULL); | |
586 g_return_if_fail(msg != NULL); | |
587 | |
588 if (msn_switchboard_can_send(swboard)) | |
589 release_msg(swboard, msg); | |
590 else if (queue) | |
591 queue_msg(swboard, msg); | |
592 } | |
593 | |
594 /************************************************************************** | |
10345 | 595 * Switchboard Commands |
596 **************************************************************************/ | |
10481 | 597 |
10345 | 598 static void |
599 ans_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
600 { | |
601 MsnSwitchBoard *swboard; | |
602 | |
10463 | 603 swboard = cmdproc->data; |
10345 | 604 swboard->ready = TRUE; |
605 } | |
606 | |
607 static void | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
608 bye_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
609 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
610 MsnSwitchBoard *swboard; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
611 const char *user; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
612 |
10463 | 613 swboard = cmdproc->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
614 user = cmd->params[0]; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
615 |
10345 | 616 if (swboard->conv == NULL) |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
617 { |
10345 | 618 /* This is a helper switchboard */ |
10434 | 619 msn_switchboard_destroy(swboard); |
10345 | 620 } |
10533 | 621 else if ((swboard->current_users > 1) || |
622 (gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT)) | |
10345 | 623 { |
624 /* This is a switchboard used for a chat */ | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
625 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(swboard->conv), user, NULL); |
10533 | 626 swboard->current_users--; |
627 if (swboard->current_users == 0) | |
628 msn_switchboard_destroy(swboard); | |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
629 } |
8372
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
630 else |
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
631 { |
10345 | 632 /* This is a switchboard used for a im session */ |
633 | |
10504 | 634 if (cmd->param_count == 1) |
8372
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
635 { |
10504 | 636 char *username, *str; |
10487 | 637 GaimAccount *account; |
638 GaimBuddy *b; | |
10225 | 639 |
10487 | 640 account = cmdproc->session->account; |
10225 | 641 |
10487 | 642 if ((b = gaim_find_buddy(account, user)) != NULL) |
643 username = gaim_escape_html(gaim_buddy_get_alias(b)); | |
644 else | |
645 username = gaim_escape_html(user); | |
10225 | 646 |
10504 | 647 str = g_strdup_printf(_("%s has closed the conversation window."), |
648 username); | |
649 | |
10487 | 650 g_free(username); |
10504 | 651 msn_switchboard_report_user(swboard, GAIM_MESSAGE_SYSTEM, str); |
652 g_free(str); | |
5626
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
653 } |
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
654 |
10434 | 655 msn_switchboard_destroy(swboard); |
4542 | 656 } |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
657 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
658 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
659 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
660 iro_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
661 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
662 GaimAccount *account; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
663 GaimConnection *gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
664 MsnSwitchBoard *swboard; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
665 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
666 account = cmdproc->session->account; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
667 gc = account->gc; |
10463 | 668 swboard = cmdproc->data; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
669 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
670 swboard->total_users = atoi(cmd->params[2]); |
6026
01dd6b652c22
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
671 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
672 msn_switchboard_add_user(swboard, cmd->params[3]); |
4542 | 673 } |
674 | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
675 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
676 joi_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
4542 | 677 { |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
678 MsnSession *session; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
679 GaimAccount *account; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
680 GaimConnection *gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
681 MsnSwitchBoard *swboard; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
682 const char *passport; |
4542 | 683 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
684 passport = cmd->params[0]; |
4542 | 685 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
686 session = cmdproc->session; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
687 account = session->account; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
688 gc = account->gc; |
10463 | 689 swboard = cmdproc->data; |
6026
01dd6b652c22
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
690 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
691 msn_switchboard_add_user(swboard, passport); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
692 |
10481 | 693 process_queue(swboard); |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
694 |
10463 | 695 if (!session->http_method) |
696 send_clientcaps(swboard); | |
10403 | 697 |
698 if (swboard->closed) | |
699 msn_switchboard_close(swboard); | |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
700 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
701 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
702 static void |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
703 msg_cmd_post(MsnCmdProc *cmdproc, MsnCommand *cmd, char *payload, size_t len) |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
704 { |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
705 MsnMessage *msg; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
706 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
707 msg = msn_message_new_from_cmd(cmdproc->session, cmd); |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
708 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
709 msn_message_parse_payload(msg, payload, len); |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
710 /* msn_message_show_readable(msg, "SB RECV", FALSE); */ |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
711 |
10284 | 712 if (msg->remote_user != NULL) |
713 g_free (msg->remote_user); | |
714 | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
715 msg->remote_user = g_strdup(cmd->params[0]); |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
716 msn_cmdproc_process_msg(cmdproc, msg); |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
717 |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
718 msn_message_destroy(msg); |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
719 } |
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
720 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
721 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
722 msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
723 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
724 cmdproc->servconn->payload_len = atoi(cmd->params[2]); |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
725 cmdproc->last_cmd->payload_cb = msg_cmd_post; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
726 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
727 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
728 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
729 nak_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
730 { |
10345 | 731 MsnMessage *msg; |
732 | |
733 msg = cmd->trans->data; | |
734 g_return_if_fail(msg != NULL); | |
735 | |
736 msg_error_helper(cmdproc, msg, MSN_MSG_ERROR_NAK); | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
737 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
738 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
739 static void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
740 ack_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
741 { |
10403 | 742 MsnSwitchBoard *swboard; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
743 MsnMessage *msg; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
744 |
10345 | 745 msg = cmd->trans->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
746 |
10345 | 747 if (msg->ack_cb != NULL) |
748 msg->ack_cb(msg, msg->ack_data); | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
749 |
10463 | 750 swboard = cmdproc->data; |
10403 | 751 swboard->ack_list = g_list_remove(swboard->ack_list, msg); |
10345 | 752 msn_message_unref(msg); |
4542 | 753 } |
754 | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
755 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
756 out_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
757 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
758 GaimConnection *gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
759 MsnSwitchBoard *swboard; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
760 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
761 gc = cmdproc->session->account->gc; |
10463 | 762 swboard = cmdproc->data; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
763 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
764 if (swboard->current_users > 1) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
765 serv_got_chat_left(gc, swboard->chat_id); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
766 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
767 msn_switchboard_disconnect(swboard); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
768 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
769 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
770 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
771 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
4542 | 772 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
773 MsnSwitchBoard *swboard; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
774 |
10463 | 775 swboard = cmdproc->data; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
776 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
777 #if 0 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
778 GList *l; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
779 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
780 for (l = swboard->users; l != NULL; l = l->next) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
781 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
782 const char *user; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
783 user = l->data; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
784 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
785 msn_cmdproc_send(cmdproc, "CAL", "%s", user); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
786 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
787 #endif |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
788 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
789 swboard->ready = TRUE; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
790 msn_cmdproc_process_queue(cmdproc); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
791 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
792 |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
793 /************************************************************************** |
10345 | 794 * Message Handlers |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
795 **************************************************************************/ |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
796 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
797 plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
798 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
799 GaimConnection *gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
800 MsnSwitchBoard *swboard; |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
801 const char *body; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
802 char *body_str; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
803 char *body_enc; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
804 char *body_final; |
10112 | 805 size_t body_len; |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
806 const char *passport; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
807 const char *value; |
4542 | 808 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
809 gc = cmdproc->session->account->gc; |
10463 | 810 swboard = cmdproc->data; |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
811 |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
812 body = msn_message_get_bin_data(msg, &body_len); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
813 body_str = g_strndup(body, body_len); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
814 body_enc = gaim_escape_html(body_str); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
815 g_free(body_str); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
816 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
817 passport = msg->remote_user; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
818 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
819 if (!strcmp(passport, "messenger@microsoft.com") && |
6668
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
820 strstr(body, "immediate security update")) |
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
821 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
822 return; |
6668
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
823 } |
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
824 |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
825 #if 0 |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
826 if ((value = msn_message_get_attr(msg, "User-Agent")) != NULL) |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
827 { |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
828 gaim_debug_misc("msn", "User-Agent = '%s'\n", value); |
4542 | 829 } |
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
830 #endif |
4542 | 831 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
832 if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL) |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
833 { |
10568 | 834 char *pre, *post; |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
835 |
10568 | 836 msn_parse_format(value, &pre, &post); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
837 |
10568 | 838 body_final = g_strdup_printf("%s%s%s", pre ? pre : "", |
839 body_enc ? body_enc : "", post ? post : ""); | |
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
840 |
10568 | 841 g_free(pre); |
842 g_free(post); | |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
843 g_free(body_enc); |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
844 } |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
845 else |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
846 { |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
847 body_final = body_enc; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
848 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
849 |
10533 | 850 if (swboard->current_users > 1 || |
851 ((swboard->conv != NULL) && | |
852 gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT)) | |
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8442
diff
changeset
|
853 { |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
854 serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final, |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
855 time(NULL)); |
10533 | 856 if (swboard->conv == NULL) |
857 swboard->conv = gaim_find_chat(gc, swboard->chat_id); | |
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8442
diff
changeset
|
858 } |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
859 else |
10533 | 860 { |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
861 serv_got_im(gc, passport, body_final, 0, time(NULL)); |
10533 | 862 if (swboard->conv == NULL) |
863 swboard->conv = gaim_find_conversation_with_account(GAIM_CONV_IM, | |
864 passport, gaim_connection_get_account(gc)); | |
865 } | |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
866 |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
867 g_free(body_final); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
868 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
869 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
870 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
871 control_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
872 { |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
873 GaimConnection *gc; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
874 MsnSwitchBoard *swboard; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
875 const char *value; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
876 char *passport; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
877 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
878 gc = cmdproc->session->account->gc; |
10463 | 879 swboard = cmdproc->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
880 passport = msg->remote_user; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
881 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
882 if (swboard->current_users == 1 && |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
883 (value = msn_message_get_attr(msg, "TypingUser")) != NULL) |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
884 { |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
885 serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT, |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5793
diff
changeset
|
886 GAIM_TYPING); |
4542 | 887 } |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
888 } |
4542 | 889 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
890 static void |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
891 clientcaps_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
892 { |
6845
5de4d9a4e0e2
[gaim-migrate @ 7390]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
893 #if 0 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
894 MsnSession *session; |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
895 MsnSwitchBoard *swboard; |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
896 MsnUser *user; |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
897 GHashTable *clientcaps; |
5351
2aa7e4237142
[gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
5342
diff
changeset
|
898 const char *value; |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
899 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
900 char *passport = msg->sender; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
901 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
902 session = cmdproc->session; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
903 swboard = cmdproc->servconn->swboard; |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
904 |
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
905 clientcaps = msn_message_get_hashtable_from_body(msg); |
6845
5de4d9a4e0e2
[gaim-migrate @ 7390]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
906 #endif |
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
907 } |
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
908 |
10345 | 909 /************************************************************************** |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
910 * Connect stuff |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
911 **************************************************************************/ |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
912 static void |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
913 connect_cb(MsnServConn *servconn) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
914 { |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
915 MsnSwitchBoard *swboard; |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
916 MsnCmdProc *cmdproc; |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
917 GaimAccount *account; |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
918 |
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
919 cmdproc = servconn->cmdproc; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
920 g_return_if_fail(cmdproc != NULL); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
921 |
10463 | 922 account = cmdproc->session->account; |
923 swboard = cmdproc->data; | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
924 g_return_if_fail(swboard != NULL); |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
925 |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
926 if (msn_switchboard_is_invited(swboard)) |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
927 { |
10346 | 928 swboard->empty = FALSE; |
929 | |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
930 msn_cmdproc_send(cmdproc, "ANS", "%s %s %s", |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
931 gaim_account_get_username(account), |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
932 swboard->auth_key, swboard->session_id); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
933 } |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
934 else |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
935 { |
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
936 msn_cmdproc_send(cmdproc, "USR", "%s %s", |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
937 gaim_account_get_username(account), |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
938 swboard->auth_key); |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
939 } |
4542 | 940 } |
941 | |
942 static void | |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
943 disconnect_cb(MsnServConn *servconn) |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
944 { |
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
945 MsnSwitchBoard *swboard; |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
946 |
10463 | 947 swboard = servconn->cmdproc->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
948 g_return_if_fail(swboard != NULL); |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
949 |
10481 | 950 msn_servconn_set_disconnect_cb(swboard->servconn, NULL); |
951 | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
952 msn_switchboard_destroy(swboard); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
953 } |
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
954 |
10345 | 955 gboolean |
956 msn_switchboard_connect(MsnSwitchBoard *swboard, const char *host, int port) | |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
957 { |
10345 | 958 g_return_val_if_fail(swboard != NULL, FALSE); |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
959 |
10345 | 960 msn_servconn_set_connect_cb(swboard->servconn, connect_cb); |
10434 | 961 msn_servconn_set_disconnect_cb(swboard->servconn, disconnect_cb); |
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
962 |
10345 | 963 return msn_servconn_connect(swboard->servconn, host, port); |
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
964 } |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
965 |
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
966 void |
10345 | 967 msn_switchboard_disconnect(MsnSwitchBoard *swboard) |
4542 | 968 { |
10345 | 969 g_return_if_fail(swboard != NULL); |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
970 |
10345 | 971 msn_servconn_disconnect(swboard->servconn); |
4542 | 972 } |
973 | |
10345 | 974 /************************************************************************** |
975 * Call stuff | |
976 **************************************************************************/ | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
977 static void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
978 got_cal(MsnCmdProc *cmdproc, MsnCommand *cmd) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
979 { |
10403 | 980 #if 0 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
981 MsnSwitchBoard *swboard; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
982 const char *user; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
983 |
10463 | 984 swboard = cmdproc->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
985 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
986 user = cmd->params[0]; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
987 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
988 msn_switchboard_add_user(swboard, user); |
10403 | 989 #endif |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
990 } |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
991 |
10225 | 992 static void |
993 cal_timeout(MsnCmdProc *cmdproc, MsnTransaction *trans) | |
994 { | |
995 cal_error_helper(trans, MSN_SB_ERROR_UNKNOWN); | |
996 } | |
997 | |
998 static void | |
999 cal_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
1000 { | |
1001 int reason = MSN_SB_ERROR_UNKNOWN; | |
1002 | |
10451 | 1003 if (error == 215) |
1004 { | |
1005 gaim_debug_info("msn", "Invited user already in switchboard\n"); | |
1006 return; | |
1007 } | |
1008 else if (error == 217) | |
1009 { | |
10225 | 1010 reason = MSN_SB_ERROR_USER_OFFLINE; |
10451 | 1011 } |
10225 | 1012 |
1013 cal_error_helper(trans, reason); | |
1014 } | |
1015 | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1016 void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1017 msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1018 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1019 MsnTransaction *trans; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1020 MsnCmdProc *cmdproc; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1021 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1022 g_return_if_fail(swboard != NULL); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1023 |
10463 | 1024 cmdproc = swboard->cmdproc; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1025 |
10225 | 1026 trans = msn_transaction_new(cmdproc, "CAL", "%s", user); |
10403 | 1027 /* this doesn't do anything, but users seem to think that |
1028 * 'Unhandled command' is some kind of error, so we don't report it */ | |
1029 msn_transaction_add_cb(trans, "CAL", got_cal); | |
10225 | 1030 |
1031 msn_transaction_set_data(trans, swboard); | |
1032 msn_transaction_set_timeout_cb(trans, cal_timeout); | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1033 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1034 if (swboard->ready) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1035 msn_cmdproc_send_trans(cmdproc, trans); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1036 else |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1037 msn_cmdproc_queue_trans(cmdproc, trans); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1038 } |
4542 | 1039 |
10345 | 1040 /************************************************************************** |
1041 * Create & Transfer stuff | |
1042 **************************************************************************/ | |
10481 | 1043 |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1044 static void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1045 got_swboard(MsnCmdProc *cmdproc, MsnCommand *cmd) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1046 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1047 MsnSwitchBoard *swboard; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1048 char *host; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1049 int port; |
9218 | 1050 swboard = cmd->trans->data; |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1051 |
10403 | 1052 if (g_list_find(cmdproc->session->switches, swboard) == NULL) |
1053 /* The conversation window was closed. */ | |
1054 return; | |
1055 | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1056 msn_switchboard_set_auth_key(swboard, cmd->params[4]); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1057 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1058 msn_parse_socket(cmd->params[2], &host, &port); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1059 |
10568 | 1060 if (!msn_switchboard_connect(swboard, host, port)) |
1061 msn_switchboard_destroy(swboard); | |
10093 | 1062 |
1063 g_free(host); | |
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
1064 } |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1065 |
10225 | 1066 static void |
1067 xfr_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
1068 { | |
1069 MsnSwitchBoard *swboard; | |
1070 int reason = MSN_SB_ERROR_UNKNOWN; | |
1071 | |
1072 if (error == 913) | |
1073 reason = MSN_SB_ERROR_OFFLINE; | |
1074 | |
1075 swboard = trans->data; | |
1076 | |
1077 swboard_error_helper(swboard, reason, swboard->im_user); | |
1078 } | |
1079 | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1080 void |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1081 msn_switchboard_request(MsnSwitchBoard *swboard) |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1082 { |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1083 MsnCmdProc *cmdproc; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1084 MsnTransaction *trans; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1085 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1086 g_return_if_fail(swboard != NULL); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1087 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1088 cmdproc = swboard->session->notification->cmdproc; |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1089 |
10225 | 1090 trans = msn_transaction_new(cmdproc, "XFR", "%s", "SB"); |
1091 msn_transaction_add_cb(trans, "XFR", got_swboard); | |
10403 | 1092 |
10225 | 1093 msn_transaction_set_data(trans, swboard); |
1094 msn_transaction_set_error_cb(trans, xfr_error); | |
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1095 |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1096 msn_cmdproc_send_trans(cmdproc, trans); |
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1097 } |
10345 | 1098 |
10403 | 1099 void |
1100 msn_switchboard_close(MsnSwitchBoard *swboard) | |
1101 { | |
1102 g_return_if_fail(swboard != NULL); | |
1103 | |
10533 | 1104 /* forget any conversation that used to be associated with this swboard */ |
1105 swboard->conv = NULL; | |
1106 | |
10481 | 1107 if (swboard->error != MSN_SB_ERROR_NONE) |
1108 { | |
1109 msn_switchboard_destroy(swboard); | |
1110 } | |
1111 else if (g_queue_is_empty(swboard->msg_queue) || | |
1112 !swboard->session->connected) | |
10403 | 1113 { |
1114 MsnCmdProc *cmdproc; | |
10463 | 1115 cmdproc = swboard->cmdproc; |
10403 | 1116 msn_cmdproc_send_quick(cmdproc, "OUT", NULL, NULL); |
1117 | |
1118 msn_switchboard_destroy(swboard); | |
1119 } | |
1120 else | |
10481 | 1121 { |
10403 | 1122 swboard->closed = TRUE; |
10481 | 1123 } |
10403 | 1124 } |
1125 | |
10345 | 1126 /************************************************************************** |
1127 * Init stuff | |
1128 **************************************************************************/ | |
10481 | 1129 |
10345 | 1130 void |
1131 msn_switchboard_init(void) | |
1132 { | |
1133 cbs_table = msn_table_new(); | |
1134 | |
1135 msn_table_add_cmd(cbs_table, "ANS", "ANS", ans_cmd); | |
1136 msn_table_add_cmd(cbs_table, "ANS", "IRO", iro_cmd); | |
1137 | |
1138 msn_table_add_cmd(cbs_table, "MSG", "ACK", ack_cmd); | |
1139 msn_table_add_cmd(cbs_table, "MSG", "NAK", nak_cmd); | |
1140 | |
1141 msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd); | |
1142 | |
1143 msn_table_add_cmd(cbs_table, NULL, "MSG", msg_cmd); | |
1144 msn_table_add_cmd(cbs_table, NULL, "JOI", joi_cmd); | |
1145 msn_table_add_cmd(cbs_table, NULL, "BYE", bye_cmd); | |
1146 msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd); | |
1147 | |
1148 #if 0 | |
1149 /* They might skip the history */ | |
1150 msn_table_add_cmd(cbs_table, NULL, "ACK", NULL); | |
1151 #endif | |
1152 | |
1153 msn_table_add_error(cbs_table, "MSG", msg_error); | |
1154 msn_table_add_error(cbs_table, "CAL", cal_error); | |
1155 | |
1156 /* Register the message type callbacks. */ | |
1157 msn_table_add_msg_type(cbs_table, "text/plain", | |
1158 plain_msg); | |
1159 msn_table_add_msg_type(cbs_table, "text/x-msmsgscontrol", | |
1160 control_msg); | |
1161 msn_table_add_msg_type(cbs_table, "text/x-clientcaps", | |
1162 clientcaps_msg); | |
1163 msn_table_add_msg_type(cbs_table, "text/x-clientinfo", | |
1164 clientcaps_msg); | |
1165 msn_table_add_msg_type(cbs_table, "application/x-msnmsgrp2p", | |
1166 msn_p2p_msg); | |
1167 msn_table_add_msg_type(cbs_table, "text/x-mms-emoticon", | |
1168 msn_emoticon_msg); | |
1169 #if 0 | |
1170 msn_table_add_msg_type(cbs_table, "text/x-msmmsginvite", | |
1171 msn_invite_msg); | |
1172 #endif | |
1173 } | |
1174 | |
1175 void | |
1176 msn_switchboard_end(void) | |
1177 { | |
1178 msn_table_destroy(cbs_table); | |
1179 } |