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