Mercurial > pidgin
annotate src/protocols/msn/switchboard.c @ 10533:ace8cd0de6ea
[gaim-migrate @ 11862]
Some minor MSN reorganization from Felipe and a bunch of MSN chat related fixes
and improvements from me.
committer: Tailor Script <tailor@pidgin.im>
| author | Stu Tomlinson <stu@nosnilmot.com> |
|---|---|
| date | Thu, 20 Jan 2005 16:37:14 +0000 |
| parents | 1a97d5e88d12 |
| children | fed2a7c2471d |
| 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); | |
| 415 body_str = g_strdup_printf("%s%s%s", pre, body_enc, post); | |
| 416 g_free(body_enc); | |
| 417 g_free(pre); | |
| 418 g_free(post); | |
| 10345 | 419 |
| 10403 | 420 msn_switchboard_report_user(swboard, GAIM_MESSAGE_ERROR, |
| 421 str_reason); | |
| 422 msn_switchboard_report_user(swboard, GAIM_MESSAGE_RAW, | |
| 423 body_str); | |
| 10345 | 424 |
| 10346 | 425 g_free(body_str); |
| 10345 | 426 } |
| 427 | |
| 10403 | 428 /* If a timeout occures we will want the msg around just in case we |
| 429 * receive the ACK after the timeout. */ | |
| 430 if (msg->ack_ref && error != MSN_MSG_ERROR_TIMEOUT) | |
| 431 { | |
| 432 swboard->ack_list = g_list_remove(swboard->ack_list, msg); | |
| 10346 | 433 msn_message_unref(msg); |
| 10403 | 434 } |
| 10345 | 435 } |
| 436 | |
| 437 /************************************************************************** | |
| 10481 | 438 * Message Stuff |
| 439 **************************************************************************/ | |
| 440 | |
| 441 /** Called when a message times out. */ | |
| 442 static void | |
| 443 msg_timeout(MsnCmdProc *cmdproc, MsnTransaction *trans) | |
| 444 { | |
| 445 MsnMessage *msg; | |
| 446 | |
| 447 msg = trans->data; | |
| 448 | |
| 449 msg_error_helper(cmdproc, msg, MSN_MSG_ERROR_TIMEOUT); | |
| 450 } | |
| 451 | |
| 452 /** Called when we receive an error of a message. */ | |
| 453 static void | |
| 454 msg_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
| 455 { | |
| 456 msg_error_helper(cmdproc, trans->data, MSN_MSG_ERROR_UNKNOWN); | |
| 457 } | |
| 458 | |
| 459 #if 0 | |
| 460 /** Called when we receive an ack of a special message. */ | |
| 461 static void | |
| 462 msg_ack(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
| 463 { | |
| 464 MsnMessage *msg; | |
| 465 | |
| 466 msg = cmd->trans->data; | |
| 467 | |
| 468 if (msg->ack_cb != NULL) | |
| 469 msg->ack_cb(msg->ack_data); | |
| 470 | |
| 471 msn_message_unref(msg); | |
| 472 } | |
| 473 | |
| 474 /** Called when we receive a nak of a special message. */ | |
| 475 static void | |
| 476 msg_nak(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
| 477 { | |
| 478 MsnMessage *msg; | |
| 479 | |
| 480 msg = cmd->trans->data; | |
| 481 | |
| 482 msn_message_unref(msg); | |
| 483 } | |
| 484 #endif | |
| 485 | |
| 486 static void | |
| 487 release_msg(MsnSwitchBoard *swboard, MsnMessage *msg) | |
| 488 { | |
| 489 MsnCmdProc *cmdproc; | |
| 490 MsnTransaction *trans; | |
| 491 char *payload; | |
| 492 gsize payload_len; | |
| 493 | |
| 494 g_return_if_fail(swboard != NULL); | |
| 495 g_return_if_fail(msg != NULL); | |
| 496 | |
| 497 cmdproc = swboard->cmdproc; | |
| 498 | |
| 499 payload = msn_message_gen_payload(msg, &payload_len); | |
| 500 | |
| 501 /* msn_message_show_readable(msg, "SB SEND", FALSE); */ | |
| 502 | |
| 503 trans = msn_transaction_new(cmdproc, "MSG", "%c %d", | |
| 504 msn_message_get_flag(msg), payload_len); | |
| 505 | |
| 506 /* Data for callbacks */ | |
| 507 msn_transaction_set_data(trans, msg); | |
| 508 | |
| 509 if (msg->type == MSN_MSG_TEXT) | |
| 510 { | |
| 511 msg->ack_ref = TRUE; | |
| 512 msn_message_ref(msg); | |
| 513 swboard->ack_list = g_list_append(swboard->ack_list, msg); | |
| 514 msn_transaction_set_timeout_cb(trans, msg_timeout); | |
| 515 } | |
| 516 else if (msg->type == MSN_MSG_SLP) | |
| 517 { | |
| 518 msg->ack_ref = TRUE; | |
| 519 msn_message_ref(msg); | |
| 520 swboard->ack_list = g_list_append(swboard->ack_list, msg); | |
| 521 msn_transaction_set_timeout_cb(trans, msg_timeout); | |
| 522 #if 0 | |
| 523 if (msg->ack_cb != NULL) | |
| 524 { | |
| 525 msn_transaction_add_cb(trans, "ACK", msg_ack); | |
| 526 msn_transaction_add_cb(trans, "NAK", msg_nak); | |
| 527 } | |
| 528 #endif | |
| 529 } | |
| 530 | |
| 531 trans->payload = payload; | |
| 532 trans->payload_len = payload_len; | |
| 533 | |
| 534 msg->trans = trans; | |
| 535 | |
| 536 msn_cmdproc_send_trans(cmdproc, trans); | |
| 537 } | |
| 538 | |
| 539 static void | |
| 540 queue_msg(MsnSwitchBoard *swboard, MsnMessage *msg) | |
| 541 { | |
| 542 g_return_if_fail(swboard != NULL); | |
| 543 g_return_if_fail(msg != NULL); | |
| 544 | |
| 545 gaim_debug_info("msn", "Appending message to queue.\n"); | |
| 546 | |
| 547 g_queue_push_tail(swboard->msg_queue, msg); | |
| 548 | |
| 549 msn_message_ref(msg); | |
| 550 } | |
| 551 | |
| 552 static void | |
| 553 process_queue(MsnSwitchBoard *swboard) | |
| 554 { | |
| 555 MsnMessage *msg; | |
| 556 | |
| 557 g_return_if_fail(swboard != NULL); | |
| 558 | |
| 559 gaim_debug_info("msn", "Processing queue\n"); | |
| 560 | |
| 561 while ((msg = g_queue_pop_head(swboard->msg_queue)) != NULL) | |
| 562 { | |
| 563 gaim_debug_info("msn", "Sending message\n"); | |
| 564 release_msg(swboard, msg); | |
| 565 msn_message_unref(msg); | |
| 566 } | |
| 567 } | |
| 568 | |
| 569 gboolean | |
| 570 msn_switchboard_can_send(MsnSwitchBoard *swboard) | |
| 571 { | |
| 572 g_return_val_if_fail(swboard != NULL, FALSE); | |
| 573 | |
| 574 if (swboard->empty || !g_queue_is_empty(swboard->msg_queue)) | |
| 575 return FALSE; | |
| 576 | |
| 577 return TRUE; | |
| 578 } | |
| 579 | |
| 580 void | |
| 581 msn_switchboard_send_msg(MsnSwitchBoard *swboard, MsnMessage *msg, | |
| 582 gboolean queue) | |
| 583 { | |
| 584 g_return_if_fail(swboard != NULL); | |
| 585 g_return_if_fail(msg != NULL); | |
| 586 | |
| 587 if (msn_switchboard_can_send(swboard)) | |
| 588 release_msg(swboard, msg); | |
| 589 else if (queue) | |
| 590 queue_msg(swboard, msg); | |
| 591 } | |
| 592 | |
| 593 /************************************************************************** | |
| 10345 | 594 * Switchboard Commands |
| 595 **************************************************************************/ | |
| 10481 | 596 |
| 10345 | 597 static void |
| 598 ans_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
| 599 { | |
| 600 MsnSwitchBoard *swboard; | |
| 601 | |
| 10463 | 602 swboard = cmdproc->data; |
| 10345 | 603 swboard->ready = TRUE; |
| 604 } | |
| 605 | |
| 606 static void | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
607 bye_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
608 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
609 MsnSwitchBoard *swboard; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
610 const char *user; |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
611 |
| 10463 | 612 swboard = cmdproc->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
613 user = cmd->params[0]; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
614 |
| 10345 | 615 if (swboard->conv == NULL) |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
616 { |
| 10345 | 617 /* This is a helper switchboard */ |
| 10434 | 618 msn_switchboard_destroy(swboard); |
| 10345 | 619 } |
| 10533 | 620 else if ((swboard->current_users > 1) || |
| 621 (gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT)) | |
| 10345 | 622 { |
| 623 /* This is a switchboard used for a chat */ | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
624 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(swboard->conv), user, NULL); |
| 10533 | 625 swboard->current_users--; |
| 626 if (swboard->current_users == 0) | |
| 627 msn_switchboard_destroy(swboard); | |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
628 } |
|
8372
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
629 else |
|
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
630 { |
| 10345 | 631 /* This is a switchboard used for a im session */ |
| 632 | |
| 10504 | 633 if (cmd->param_count == 1) |
|
8372
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
634 { |
| 10504 | 635 char *username, *str; |
| 10487 | 636 GaimAccount *account; |
| 637 GaimBuddy *b; | |
| 10225 | 638 |
| 10487 | 639 account = cmdproc->session->account; |
| 10225 | 640 |
| 10487 | 641 if ((b = gaim_find_buddy(account, user)) != NULL) |
| 642 username = gaim_escape_html(gaim_buddy_get_alias(b)); | |
| 643 else | |
| 644 username = gaim_escape_html(user); | |
| 10225 | 645 |
| 10504 | 646 str = g_strdup_printf(_("%s has closed the conversation window."), |
| 647 username); | |
| 648 | |
| 10487 | 649 g_free(username); |
| 10504 | 650 msn_switchboard_report_user(swboard, GAIM_MESSAGE_SYSTEM, str); |
| 651 g_free(str); | |
|
5626
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
652 } |
|
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
653 |
| 10434 | 654 msn_switchboard_destroy(swboard); |
| 4542 | 655 } |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
656 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
657 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
658 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
659 iro_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
660 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
661 GaimAccount *account; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
662 GaimConnection *gc; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
663 MsnSwitchBoard *swboard; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
664 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
665 account = cmdproc->session->account; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
666 gc = account->gc; |
| 10463 | 667 swboard = cmdproc->data; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
668 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
669 swboard->total_users = atoi(cmd->params[2]); |
|
6026
01dd6b652c22
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
670 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
671 msn_switchboard_add_user(swboard, cmd->params[3]); |
| 4542 | 672 } |
| 673 | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
674 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
675 joi_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
| 4542 | 676 { |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
677 MsnSession *session; |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
678 GaimAccount *account; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
679 GaimConnection *gc; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
680 MsnSwitchBoard *swboard; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
681 const char *passport; |
| 4542 | 682 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
683 passport = cmd->params[0]; |
| 4542 | 684 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
685 session = cmdproc->session; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
686 account = session->account; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
687 gc = account->gc; |
| 10463 | 688 swboard = cmdproc->data; |
|
6026
01dd6b652c22
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
689 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
690 msn_switchboard_add_user(swboard, passport); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
691 |
| 10481 | 692 process_queue(swboard); |
|
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
693 |
| 10463 | 694 if (!session->http_method) |
| 695 send_clientcaps(swboard); | |
| 10403 | 696 |
| 697 if (swboard->closed) | |
| 698 msn_switchboard_close(swboard); | |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
699 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
700 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
701 static void |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
702 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
|
703 { |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
704 MsnMessage *msg; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
705 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
706 msg = msn_message_new_from_cmd(cmdproc->session, cmd); |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
707 |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
708 msn_message_parse_payload(msg, payload, len); |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
709 /* msn_message_show_readable(msg, "SB RECV", FALSE); */ |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
710 |
| 10284 | 711 if (msg->remote_user != NULL) |
| 712 g_free (msg->remote_user); | |
| 713 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
714 msg->remote_user = g_strdup(cmd->params[0]); |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
715 msn_cmdproc_process_msg(cmdproc, msg); |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
716 |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
717 msn_message_destroy(msg); |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
718 } |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
719 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
720 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
721 msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
722 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
723 cmdproc->servconn->payload_len = atoi(cmd->params[2]); |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
724 cmdproc->last_cmd->payload_cb = msg_cmd_post; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
725 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
726 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
727 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
728 nak_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
729 { |
| 10345 | 730 MsnMessage *msg; |
| 731 | |
| 732 msg = cmd->trans->data; | |
| 733 g_return_if_fail(msg != NULL); | |
| 734 | |
| 735 msg_error_helper(cmdproc, msg, MSN_MSG_ERROR_NAK); | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
736 } |
|
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 static void |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
739 ack_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
740 { |
| 10403 | 741 MsnSwitchBoard *swboard; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
742 MsnMessage *msg; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
743 |
| 10345 | 744 msg = cmd->trans->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
745 |
| 10345 | 746 if (msg->ack_cb != NULL) |
| 747 msg->ack_cb(msg, msg->ack_data); | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
748 |
| 10463 | 749 swboard = cmdproc->data; |
| 10403 | 750 swboard->ack_list = g_list_remove(swboard->ack_list, msg); |
| 10345 | 751 msn_message_unref(msg); |
| 4542 | 752 } |
| 753 | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
754 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
755 out_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
756 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
757 GaimConnection *gc; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
758 MsnSwitchBoard *swboard; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
759 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
760 gc = cmdproc->session->account->gc; |
| 10463 | 761 swboard = cmdproc->data; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
762 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
763 if (swboard->current_users > 1) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
764 serv_got_chat_left(gc, swboard->chat_id); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
765 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
766 msn_switchboard_disconnect(swboard); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
767 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
768 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
769 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
770 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
| 4542 | 771 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
772 MsnSwitchBoard *swboard; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
773 |
| 10463 | 774 swboard = cmdproc->data; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
775 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
776 #if 0 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
777 GList *l; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
778 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
779 for (l = swboard->users; l != NULL; l = l->next) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
780 { |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
781 const char *user; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
782 user = l->data; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
783 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
784 msn_cmdproc_send(cmdproc, "CAL", "%s", user); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
785 } |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
786 #endif |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
787 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
788 swboard->ready = TRUE; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
789 msn_cmdproc_process_queue(cmdproc); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
790 } |
|
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 /************************************************************************** |
| 10345 | 793 * Message Handlers |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
794 **************************************************************************/ |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
795 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
796 plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
797 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
798 GaimConnection *gc; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
799 MsnSwitchBoard *swboard; |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
800 const char *body; |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
801 char *body_str; |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
802 char *body_enc; |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
803 char *body_final; |
| 10112 | 804 size_t body_len; |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
805 const char *passport; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
806 const char *value; |
| 4542 | 807 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
808 gc = cmdproc->session->account->gc; |
| 10463 | 809 swboard = cmdproc->data; |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
810 |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
811 body = msn_message_get_bin_data(msg, &body_len); |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
812 body_str = g_strndup(body, body_len); |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
813 body_enc = gaim_escape_html(body_str); |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
814 g_free(body_str); |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
815 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
816 passport = msg->remote_user; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
817 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
818 if (!strcmp(passport, "messenger@microsoft.com") && |
|
6668
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
819 strstr(body, "immediate security update")) |
|
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
820 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
821 return; |
|
6668
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
822 } |
|
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
823 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
824 #if 0 |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
825 if ((value = msn_message_get_attr(msg, "User-Agent")) != NULL) |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
826 { |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
827 gaim_debug_misc("msn", "User-Agent = '%s'\n", value); |
| 4542 | 828 } |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
829 #endif |
| 4542 | 830 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
831 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
|
832 { |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
833 char *pre_format, *post_format; |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
834 |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
835 msn_parse_format(value, &pre_format, &post_format); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
836 |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
837 body_final = g_strdup_printf("%s%s%s", pre_format, body_enc, post_format); |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
838 |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
839 g_free(pre_format); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
840 g_free(post_format); |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
841 g_free(body_enc); |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
842 } |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
843 else |
|
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 body_final = body_enc; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
846 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
847 |
| 10533 | 848 if (swboard->current_users > 1 || |
| 849 ((swboard->conv != NULL) && | |
| 850 gaim_conversation_get_type(swboard->conv) == GAIM_CONV_CHAT)) | |
|
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8442
diff
changeset
|
851 { |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
852 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
|
853 time(NULL)); |
| 10533 | 854 if (swboard->conv == NULL) |
| 855 swboard->conv = gaim_find_chat(gc, swboard->chat_id); | |
|
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8442
diff
changeset
|
856 } |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
857 else |
| 10533 | 858 { |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
859 serv_got_im(gc, passport, body_final, 0, time(NULL)); |
| 10533 | 860 if (swboard->conv == NULL) |
| 861 swboard->conv = gaim_find_conversation_with_account(GAIM_CONV_IM, | |
| 862 passport, gaim_connection_get_account(gc)); | |
| 863 } | |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
864 |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
865 g_free(body_final); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
866 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
867 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
868 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
869 control_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
870 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
871 GaimConnection *gc; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
872 MsnSwitchBoard *swboard; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
873 const char *value; |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
874 char *passport; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
875 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
876 gc = cmdproc->session->account->gc; |
| 10463 | 877 swboard = cmdproc->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
878 passport = msg->remote_user; |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
879 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
880 if (swboard->current_users == 1 && |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
881 (value = msn_message_get_attr(msg, "TypingUser")) != NULL) |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
882 { |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
883 serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT, |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5793
diff
changeset
|
884 GAIM_TYPING); |
| 4542 | 885 } |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
886 } |
| 4542 | 887 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
888 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
889 clientcaps_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
|
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
890 { |
|
6845
5de4d9a4e0e2
[gaim-migrate @ 7390]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
891 #if 0 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
892 MsnSession *session; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
893 MsnSwitchBoard *swboard; |
|
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
894 MsnUser *user; |
|
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
895 GHashTable *clientcaps; |
|
5351
2aa7e4237142
[gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
5342
diff
changeset
|
896 const char *value; |
|
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
897 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
898 char *passport = msg->sender; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
899 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
900 session = cmdproc->session; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
901 swboard = cmdproc->servconn->swboard; |
|
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
902 |
|
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
903 clientcaps = msn_message_get_hashtable_from_body(msg); |
|
6845
5de4d9a4e0e2
[gaim-migrate @ 7390]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
904 #endif |
|
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
905 } |
|
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
906 |
| 10345 | 907 /************************************************************************** |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
908 * Connect stuff |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
909 **************************************************************************/ |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
910 static void |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
911 connect_cb(MsnServConn *servconn) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
912 { |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
913 MsnSwitchBoard *swboard; |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
914 MsnCmdProc *cmdproc; |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
915 GaimAccount *account; |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
916 |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
917 cmdproc = servconn->cmdproc; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
918 g_return_if_fail(cmdproc != NULL); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
919 |
| 10463 | 920 account = cmdproc->session->account; |
| 921 swboard = cmdproc->data; | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
922 g_return_if_fail(swboard != NULL); |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
923 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
924 if (msn_switchboard_is_invited(swboard)) |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
925 { |
| 10346 | 926 swboard->empty = FALSE; |
| 927 | |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
928 msn_cmdproc_send(cmdproc, "ANS", "%s %s %s", |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
929 gaim_account_get_username(account), |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
930 swboard->auth_key, swboard->session_id); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
931 } |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
932 else |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
933 { |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
934 msn_cmdproc_send(cmdproc, "USR", "%s %s", |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
935 gaim_account_get_username(account), |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
936 swboard->auth_key); |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
937 } |
| 4542 | 938 } |
| 939 | |
| 940 static void | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
941 disconnect_cb(MsnServConn *servconn) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
942 { |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
943 MsnSwitchBoard *swboard; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
944 |
| 10463 | 945 swboard = servconn->cmdproc->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
946 g_return_if_fail(swboard != NULL); |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
947 |
| 10481 | 948 msn_servconn_set_disconnect_cb(swboard->servconn, NULL); |
| 949 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
950 msn_switchboard_destroy(swboard); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
951 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
952 |
| 10345 | 953 gboolean |
| 954 msn_switchboard_connect(MsnSwitchBoard *swboard, const char *host, int port) | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
955 { |
| 10345 | 956 g_return_val_if_fail(swboard != NULL, FALSE); |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
957 |
| 10345 | 958 msn_servconn_set_connect_cb(swboard->servconn, connect_cb); |
| 10434 | 959 msn_servconn_set_disconnect_cb(swboard->servconn, disconnect_cb); |
|
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
960 |
| 10345 | 961 return msn_servconn_connect(swboard->servconn, host, port); |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
962 } |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
963 |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
964 void |
| 10345 | 965 msn_switchboard_disconnect(MsnSwitchBoard *swboard) |
| 4542 | 966 { |
| 10345 | 967 g_return_if_fail(swboard != NULL); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
968 |
| 10345 | 969 msn_servconn_disconnect(swboard->servconn); |
| 4542 | 970 } |
| 971 | |
| 10345 | 972 /************************************************************************** |
| 973 * Call stuff | |
| 974 **************************************************************************/ | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
975 static void |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
976 got_cal(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
977 { |
| 10403 | 978 #if 0 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
979 MsnSwitchBoard *swboard; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
980 const char *user; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
981 |
| 10463 | 982 swboard = cmdproc->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
983 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
984 user = cmd->params[0]; |
|
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 msn_switchboard_add_user(swboard, user); |
| 10403 | 987 #endif |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
988 } |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
989 |
| 10225 | 990 static void |
| 991 cal_timeout(MsnCmdProc *cmdproc, MsnTransaction *trans) | |
| 992 { | |
| 993 cal_error_helper(trans, MSN_SB_ERROR_UNKNOWN); | |
| 994 } | |
| 995 | |
| 996 static void | |
| 997 cal_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
| 998 { | |
| 999 int reason = MSN_SB_ERROR_UNKNOWN; | |
| 1000 | |
| 10451 | 1001 if (error == 215) |
| 1002 { | |
| 1003 gaim_debug_info("msn", "Invited user already in switchboard\n"); | |
| 1004 return; | |
| 1005 } | |
| 1006 else if (error == 217) | |
| 1007 { | |
| 10225 | 1008 reason = MSN_SB_ERROR_USER_OFFLINE; |
| 10451 | 1009 } |
| 10225 | 1010 |
| 1011 cal_error_helper(trans, reason); | |
| 1012 } | |
| 1013 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1014 void |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1015 msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1016 { |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1017 MsnTransaction *trans; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1018 MsnCmdProc *cmdproc; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1019 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1020 g_return_if_fail(swboard != NULL); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1021 |
| 10463 | 1022 cmdproc = swboard->cmdproc; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1023 |
| 10225 | 1024 trans = msn_transaction_new(cmdproc, "CAL", "%s", user); |
| 10403 | 1025 /* this doesn't do anything, but users seem to think that |
| 1026 * 'Unhandled command' is some kind of error, so we don't report it */ | |
| 1027 msn_transaction_add_cb(trans, "CAL", got_cal); | |
| 10225 | 1028 |
| 1029 msn_transaction_set_data(trans, swboard); | |
| 1030 msn_transaction_set_timeout_cb(trans, cal_timeout); | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1031 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1032 if (swboard->ready) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1033 msn_cmdproc_send_trans(cmdproc, trans); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1034 else |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1035 msn_cmdproc_queue_trans(cmdproc, trans); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1036 } |
| 4542 | 1037 |
| 10345 | 1038 /************************************************************************** |
| 1039 * Create & Transfer stuff | |
| 1040 **************************************************************************/ | |
| 10481 | 1041 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1042 static void |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1043 got_swboard(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1044 { |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1045 MsnSwitchBoard *swboard; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1046 char *host; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1047 int port; |
| 9218 | 1048 swboard = cmd->trans->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1049 |
| 10403 | 1050 if (g_list_find(cmdproc->session->switches, swboard) == NULL) |
| 1051 /* The conversation window was closed. */ | |
| 1052 return; | |
| 1053 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1054 msn_switchboard_set_auth_key(swboard, cmd->params[4]); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1055 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1056 msn_parse_socket(cmd->params[2], &host, &port); |
|
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_switchboard_connect(swboard, host, port); |
| 10093 | 1059 |
| 1060 g_free(host); | |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
1061 } |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1062 |
| 10225 | 1063 static void |
| 1064 xfr_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
| 1065 { | |
| 1066 MsnSwitchBoard *swboard; | |
| 1067 int reason = MSN_SB_ERROR_UNKNOWN; | |
| 1068 | |
| 1069 if (error == 913) | |
| 1070 reason = MSN_SB_ERROR_OFFLINE; | |
| 1071 | |
| 1072 swboard = trans->data; | |
| 1073 | |
| 1074 swboard_error_helper(swboard, reason, swboard->im_user); | |
| 1075 } | |
| 1076 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1077 void |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1078 msn_switchboard_request(MsnSwitchBoard *swboard) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1079 { |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1080 MsnCmdProc *cmdproc; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1081 MsnTransaction *trans; |
|
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 g_return_if_fail(swboard != NULL); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1084 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1085 cmdproc = swboard->session->notification->cmdproc; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1086 |
| 10225 | 1087 trans = msn_transaction_new(cmdproc, "XFR", "%s", "SB"); |
| 1088 msn_transaction_add_cb(trans, "XFR", got_swboard); | |
| 10403 | 1089 |
| 10225 | 1090 msn_transaction_set_data(trans, swboard); |
| 1091 msn_transaction_set_error_cb(trans, xfr_error); | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1092 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1093 msn_cmdproc_send_trans(cmdproc, trans); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1094 } |
| 10345 | 1095 |
| 10403 | 1096 void |
| 1097 msn_switchboard_close(MsnSwitchBoard *swboard) | |
| 1098 { | |
| 1099 g_return_if_fail(swboard != NULL); | |
| 1100 | |
| 10533 | 1101 /* forget any conversation that used to be associated with this swboard */ |
| 1102 swboard->conv = NULL; | |
| 1103 | |
| 10481 | 1104 if (swboard->error != MSN_SB_ERROR_NONE) |
| 1105 { | |
| 1106 msn_switchboard_destroy(swboard); | |
| 1107 } | |
| 1108 else if (g_queue_is_empty(swboard->msg_queue) || | |
| 1109 !swboard->session->connected) | |
| 10403 | 1110 { |
| 1111 MsnCmdProc *cmdproc; | |
| 10463 | 1112 cmdproc = swboard->cmdproc; |
| 10403 | 1113 msn_cmdproc_send_quick(cmdproc, "OUT", NULL, NULL); |
| 1114 | |
| 1115 msn_switchboard_destroy(swboard); | |
| 1116 } | |
| 1117 else | |
| 10481 | 1118 { |
| 10403 | 1119 swboard->closed = TRUE; |
| 10481 | 1120 } |
| 10403 | 1121 } |
| 1122 | |
| 10345 | 1123 /************************************************************************** |
| 1124 * Init stuff | |
| 1125 **************************************************************************/ | |
| 10481 | 1126 |
| 10345 | 1127 void |
| 1128 msn_switchboard_init(void) | |
| 1129 { | |
| 1130 cbs_table = msn_table_new(); | |
| 1131 | |
| 1132 msn_table_add_cmd(cbs_table, "ANS", "ANS", ans_cmd); | |
| 1133 msn_table_add_cmd(cbs_table, "ANS", "IRO", iro_cmd); | |
| 1134 | |
| 1135 msn_table_add_cmd(cbs_table, "MSG", "ACK", ack_cmd); | |
| 1136 msn_table_add_cmd(cbs_table, "MSG", "NAK", nak_cmd); | |
| 1137 | |
| 1138 msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd); | |
| 1139 | |
| 1140 msn_table_add_cmd(cbs_table, NULL, "MSG", msg_cmd); | |
| 1141 msn_table_add_cmd(cbs_table, NULL, "JOI", joi_cmd); | |
| 1142 msn_table_add_cmd(cbs_table, NULL, "BYE", bye_cmd); | |
| 1143 msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd); | |
| 1144 | |
| 1145 #if 0 | |
| 1146 /* They might skip the history */ | |
| 1147 msn_table_add_cmd(cbs_table, NULL, "ACK", NULL); | |
| 1148 #endif | |
| 1149 | |
| 1150 msn_table_add_error(cbs_table, "MSG", msg_error); | |
| 1151 msn_table_add_error(cbs_table, "CAL", cal_error); | |
| 1152 | |
| 1153 /* Register the message type callbacks. */ | |
| 1154 msn_table_add_msg_type(cbs_table, "text/plain", | |
| 1155 plain_msg); | |
| 1156 msn_table_add_msg_type(cbs_table, "text/x-msmsgscontrol", | |
| 1157 control_msg); | |
| 1158 msn_table_add_msg_type(cbs_table, "text/x-clientcaps", | |
| 1159 clientcaps_msg); | |
| 1160 msn_table_add_msg_type(cbs_table, "text/x-clientinfo", | |
| 1161 clientcaps_msg); | |
| 1162 msn_table_add_msg_type(cbs_table, "application/x-msnmsgrp2p", | |
| 1163 msn_p2p_msg); | |
| 1164 msn_table_add_msg_type(cbs_table, "text/x-mms-emoticon", | |
| 1165 msn_emoticon_msg); | |
| 1166 #if 0 | |
| 1167 msn_table_add_msg_type(cbs_table, "text/x-msmmsginvite", | |
| 1168 msn_invite_msg); | |
| 1169 #endif | |
| 1170 } | |
| 1171 | |
| 1172 void | |
| 1173 msn_switchboard_end(void) | |
| 1174 { | |
| 1175 msn_table_destroy(cbs_table); | |
| 1176 } |
