Mercurial > pidgin
annotate src/protocols/msn/switchboard.c @ 10525:ddea15f4cbc2
[gaim-migrate @ 11842]
Kevin and Tim both pointed out that I'd missed some of the zoom stuff, so this should be the rest of it.
committer: Tailor Script <tailor@pidgin.im>
| author | Etan Reisner <pidgin@unreliablesource.net> |
|---|---|
| date | Tue, 18 Jan 2005 15:36:39 +0000 |
| parents | 1a97d5e88d12 |
| children | ace8cd0de6ea |
| 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"); */ |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
230 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
231 if (swboard->conv != NULL) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
232 gaim_conversation_destroy(swboard->conv); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
233 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
234 cmdproc->session->conv_seq++; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
235 swboard->chat_id = cmdproc->session->conv_seq; |
|
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 swboard->conv = serv_got_joined_chat(account->gc, |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
238 swboard->chat_id, |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
239 "MSN Chat"); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
240 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
241 for (l = swboard->users; l != NULL; l = l->next) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
242 { |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
243 const char *tmp_user; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
244 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
245 tmp_user = l->data; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
246 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
247 /* gaim_debug_info("msn", "[chat] Adding [%s].\n", |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
248 * tmp_user); */ |
|
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_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), |
| 9846 | 251 tmp_user, NULL, GAIM_CBFLAGS_NONE, TRUE); |
|
9193
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 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
254 /* gaim_debug_info("msn", "[chat] We add ourselves.\n"); */ |
|
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 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
257 gaim_account_get_username(account), |
| 9846 | 258 NULL, GAIM_CBFLAGS_NONE, TRUE); |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
259 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
260 g_free(swboard->im_user); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
261 swboard->im_user = NULL; |
|
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 } |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
264 else if (swboard->conv == NULL) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
265 { |
| 10246 | 266 /* XXX - I think this should probably be GAIM_CONV_CHAT, but I'm hedging */ |
| 267 swboard->conv = gaim_find_conversation_with_account(GAIM_CONV_ANY, | |
| 268 user, account); | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
269 } |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
270 else |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
271 { |
|
9363
997c28571364
[gaim-migrate @ 10171]
Christian Hammond <chipx86@chipx86.com>
parents:
9218
diff
changeset
|
272 gaim_debug_warning("msn", "This should not happen!" |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
273 "(msn_switchboard_add_user)\n"); |
|
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 } |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
276 |
| 10225 | 277 GaimConversation * |
| 278 msn_switchboard_get_conv(MsnSwitchBoard *swboard) | |
| 279 { | |
| 280 GaimAccount *account; | |
| 281 | |
| 282 g_return_val_if_fail(swboard != NULL, NULL); | |
| 283 | |
| 284 if (swboard->conv != NULL) | |
| 285 return swboard->conv; | |
| 286 | |
| 10346 | 287 gaim_debug_error("msn", "Switchboard with unassigned conversation\n"); |
| 10345 | 288 |
| 10225 | 289 account = swboard->session->account; |
| 290 | |
| 10246 | 291 /* XXX - I think this should probably be GAIM_CONV_IM, but I'm hedging */ |
| 292 return gaim_find_conversation_with_account(GAIM_CONV_IM, | |
| 293 swboard->im_user, account); | |
| 10225 | 294 } |
| 295 | |
| 296 void | |
| 297 msn_switchboard_report_user(MsnSwitchBoard *swboard, GaimMessageFlags flags, const char *msg) | |
| 298 { | |
| 299 GaimConversation *conv; | |
| 300 | |
| 301 g_return_if_fail(swboard != NULL); | |
| 302 g_return_if_fail(msg != NULL); | |
| 303 | |
| 304 if ((conv = msn_switchboard_get_conv(swboard)) != NULL) | |
| 305 { | |
| 306 gaim_conversation_write(conv, NULL, msg, flags, time(NULL)); | |
| 307 } | |
| 308 } | |
| 309 | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
310 static void |
| 10345 | 311 swboard_error_helper(MsnSwitchBoard *swboard, int reason, const char *passport) |
| 312 { | |
| 10451 | 313 g_return_if_fail(swboard != NULL); |
| 314 | |
| 10345 | 315 gaim_debug_info("msg", "Error: Unable to call the user %s\n", passport); |
| 316 | |
| 317 if (swboard->total_users == 0) | |
| 318 { | |
| 319 swboard->error = reason; | |
| 10463 | 320 msn_switchboard_close(swboard); |
| 10345 | 321 } |
| 322 } | |
| 323 | |
| 324 static void | |
| 325 cal_error_helper(MsnTransaction *trans, int reason) | |
| 326 { | |
| 327 MsnSwitchBoard *swboard; | |
| 328 const char *passport; | |
| 329 char **params; | |
| 330 | |
| 331 params = g_strsplit(trans->params, " ", 0); | |
| 332 | |
| 333 passport = params[0]; | |
| 334 | |
| 335 swboard = trans->data; | |
| 336 | |
| 337 swboard_error_helper(swboard, reason, passport); | |
| 338 | |
| 339 g_strfreev(params); | |
| 340 } | |
| 341 | |
| 342 static void | |
| 343 msg_error_helper(MsnCmdProc *cmdproc, MsnMessage *msg, MsnMsgErrorType error) | |
| 344 { | |
| 10403 | 345 MsnSwitchBoard *swboard; |
| 346 | |
| 10345 | 347 g_return_if_fail(cmdproc != NULL); |
| 348 g_return_if_fail(msg != NULL); | |
| 349 | |
| 10403 | 350 if ((error != MSN_MSG_ERROR_SB) && (msg->nak_cb != NULL)) |
| 10345 | 351 msg->nak_cb(msg, msg->ack_data); |
| 352 | |
| 10463 | 353 swboard = cmdproc->data; |
| 10403 | 354 |
| 10345 | 355 if (msg->type == MSN_MSG_TEXT) |
| 356 { | |
| 10504 | 357 const char *format, *str_reason; |
| 10346 | 358 char *body_str, *body_enc, *pre, *post; |
| 10345 | 359 |
| 360 #if 0 | |
| 361 if (swboard->conv == NULL) | |
| 362 { | |
| 10346 | 363 if (msg->ack_ref) |
| 10403 | 364 msn_message_unref(msg); |
| 10346 | 365 |
| 10345 | 366 return; |
| 367 } | |
| 368 #endif | |
| 369 | |
| 10346 | 370 if (error == MSN_MSG_ERROR_TIMEOUT) |
| 10345 | 371 { |
| 372 str_reason = _("Message may have not been sent " | |
| 10451 | 373 "because a timeout occurred:"); |
| 10345 | 374 } |
| 10346 | 375 else if (error == MSN_MSG_ERROR_SB) |
| 10345 | 376 { |
| 377 switch (swboard->error) | |
| 378 { | |
| 379 case MSN_SB_ERROR_OFFLINE: | |
| 380 str_reason = _("Message could not be sent, " | |
| 10346 | 381 "not allowed while invisible:"); |
| 10345 | 382 break; |
| 383 case MSN_SB_ERROR_USER_OFFLINE: | |
| 384 str_reason = _("Message could not be sent " | |
| 10346 | 385 "because the user is offline:"); |
| 10345 | 386 break; |
| 387 case MSN_SB_ERROR_CONNECTION: | |
| 388 str_reason = _("Message could not be sent " | |
| 10391 | 389 "because a connection error occurred:"); |
| 10345 | 390 break; |
| 391 default: | |
| 392 str_reason = _("Message could not be sent " | |
| 393 "because an error with " | |
| 10391 | 394 "the switchboard occurred:"); |
| 10345 | 395 break; |
| 396 } | |
| 397 } | |
| 398 else | |
| 399 { | |
| 400 str_reason = _("Message may have not been sent " | |
| 10391 | 401 "because an unknown error occurred:"); |
| 10345 | 402 } |
| 403 | |
| 10346 | 404 body_str = msn_message_to_string(msg); |
| 405 body_enc = gaim_escape_html(body_str); | |
| 406 g_free(body_str); | |
| 407 | |
| 408 format = msn_message_get_attr(msg, "X-MMS-IM-Format"); | |
| 409 msn_parse_format(format, &pre, &post); | |
| 410 body_str = g_strdup_printf("%s%s%s", pre, body_enc, post); | |
| 411 g_free(body_enc); | |
| 412 g_free(pre); | |
| 413 g_free(post); | |
| 10345 | 414 |
| 10403 | 415 msn_switchboard_report_user(swboard, GAIM_MESSAGE_ERROR, |
| 416 str_reason); | |
| 417 msn_switchboard_report_user(swboard, GAIM_MESSAGE_RAW, | |
| 418 body_str); | |
| 10345 | 419 |
| 10346 | 420 g_free(body_str); |
| 10345 | 421 } |
| 422 | |
| 10403 | 423 /* If a timeout occures we will want the msg around just in case we |
| 424 * receive the ACK after the timeout. */ | |
| 425 if (msg->ack_ref && error != MSN_MSG_ERROR_TIMEOUT) | |
| 426 { | |
| 427 swboard->ack_list = g_list_remove(swboard->ack_list, msg); | |
| 10346 | 428 msn_message_unref(msg); |
| 10403 | 429 } |
| 10345 | 430 } |
| 431 | |
| 432 /************************************************************************** | |
| 10481 | 433 * Message Stuff |
| 434 **************************************************************************/ | |
| 435 | |
| 436 /** Called when a message times out. */ | |
| 437 static void | |
| 438 msg_timeout(MsnCmdProc *cmdproc, MsnTransaction *trans) | |
| 439 { | |
| 440 MsnMessage *msg; | |
| 441 | |
| 442 msg = trans->data; | |
| 443 | |
| 444 msg_error_helper(cmdproc, msg, MSN_MSG_ERROR_TIMEOUT); | |
| 445 } | |
| 446 | |
| 447 /** Called when we receive an error of a message. */ | |
| 448 static void | |
| 449 msg_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
| 450 { | |
| 451 msg_error_helper(cmdproc, trans->data, MSN_MSG_ERROR_UNKNOWN); | |
| 452 } | |
| 453 | |
| 454 #if 0 | |
| 455 /** Called when we receive an ack of a special message. */ | |
| 456 static void | |
| 457 msg_ack(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
| 458 { | |
| 459 MsnMessage *msg; | |
| 460 | |
| 461 msg = cmd->trans->data; | |
| 462 | |
| 463 if (msg->ack_cb != NULL) | |
| 464 msg->ack_cb(msg->ack_data); | |
| 465 | |
| 466 msn_message_unref(msg); | |
| 467 } | |
| 468 | |
| 469 /** Called when we receive a nak of a special message. */ | |
| 470 static void | |
| 471 msg_nak(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
| 472 { | |
| 473 MsnMessage *msg; | |
| 474 | |
| 475 msg = cmd->trans->data; | |
| 476 | |
| 477 msn_message_unref(msg); | |
| 478 } | |
| 479 #endif | |
| 480 | |
| 481 static void | |
| 482 release_msg(MsnSwitchBoard *swboard, MsnMessage *msg) | |
| 483 { | |
| 484 MsnCmdProc *cmdproc; | |
| 485 MsnTransaction *trans; | |
| 486 char *payload; | |
| 487 gsize payload_len; | |
| 488 | |
| 489 g_return_if_fail(swboard != NULL); | |
| 490 g_return_if_fail(msg != NULL); | |
| 491 | |
| 492 cmdproc = swboard->cmdproc; | |
| 493 | |
| 494 payload = msn_message_gen_payload(msg, &payload_len); | |
| 495 | |
| 496 /* msn_message_show_readable(msg, "SB SEND", FALSE); */ | |
| 497 | |
| 498 trans = msn_transaction_new(cmdproc, "MSG", "%c %d", | |
| 499 msn_message_get_flag(msg), payload_len); | |
| 500 | |
| 501 /* Data for callbacks */ | |
| 502 msn_transaction_set_data(trans, msg); | |
| 503 | |
| 504 if (msg->type == MSN_MSG_TEXT) | |
| 505 { | |
| 506 msg->ack_ref = TRUE; | |
| 507 msn_message_ref(msg); | |
| 508 swboard->ack_list = g_list_append(swboard->ack_list, msg); | |
| 509 msn_transaction_set_timeout_cb(trans, msg_timeout); | |
| 510 } | |
| 511 else if (msg->type == MSN_MSG_SLP) | |
| 512 { | |
| 513 msg->ack_ref = TRUE; | |
| 514 msn_message_ref(msg); | |
| 515 swboard->ack_list = g_list_append(swboard->ack_list, msg); | |
| 516 msn_transaction_set_timeout_cb(trans, msg_timeout); | |
| 517 #if 0 | |
| 518 if (msg->ack_cb != NULL) | |
| 519 { | |
| 520 msn_transaction_add_cb(trans, "ACK", msg_ack); | |
| 521 msn_transaction_add_cb(trans, "NAK", msg_nak); | |
| 522 } | |
| 523 #endif | |
| 524 } | |
| 525 | |
| 526 trans->payload = payload; | |
| 527 trans->payload_len = payload_len; | |
| 528 | |
| 529 msg->trans = trans; | |
| 530 | |
| 531 msn_cmdproc_send_trans(cmdproc, trans); | |
| 532 } | |
| 533 | |
| 534 static void | |
| 535 queue_msg(MsnSwitchBoard *swboard, MsnMessage *msg) | |
| 536 { | |
| 537 g_return_if_fail(swboard != NULL); | |
| 538 g_return_if_fail(msg != NULL); | |
| 539 | |
| 540 gaim_debug_info("msn", "Appending message to queue.\n"); | |
| 541 | |
| 542 g_queue_push_tail(swboard->msg_queue, msg); | |
| 543 | |
| 544 msn_message_ref(msg); | |
| 545 } | |
| 546 | |
| 547 static void | |
| 548 process_queue(MsnSwitchBoard *swboard) | |
| 549 { | |
| 550 MsnMessage *msg; | |
| 551 | |
| 552 g_return_if_fail(swboard != NULL); | |
| 553 | |
| 554 gaim_debug_info("msn", "Processing queue\n"); | |
| 555 | |
| 556 while ((msg = g_queue_pop_head(swboard->msg_queue)) != NULL) | |
| 557 { | |
| 558 gaim_debug_info("msn", "Sending message\n"); | |
| 559 release_msg(swboard, msg); | |
| 560 msn_message_unref(msg); | |
| 561 } | |
| 562 } | |
| 563 | |
| 564 gboolean | |
| 565 msn_switchboard_can_send(MsnSwitchBoard *swboard) | |
| 566 { | |
| 567 g_return_val_if_fail(swboard != NULL, FALSE); | |
| 568 | |
| 569 if (swboard->empty || !g_queue_is_empty(swboard->msg_queue)) | |
| 570 return FALSE; | |
| 571 | |
| 572 return TRUE; | |
| 573 } | |
| 574 | |
| 575 void | |
| 576 msn_switchboard_send_msg(MsnSwitchBoard *swboard, MsnMessage *msg, | |
| 577 gboolean queue) | |
| 578 { | |
| 579 g_return_if_fail(swboard != NULL); | |
| 580 g_return_if_fail(msg != NULL); | |
| 581 | |
| 582 if (msn_switchboard_can_send(swboard)) | |
| 583 release_msg(swboard, msg); | |
| 584 else if (queue) | |
| 585 queue_msg(swboard, msg); | |
| 586 } | |
| 587 | |
| 588 /************************************************************************** | |
| 10345 | 589 * Switchboard Commands |
| 590 **************************************************************************/ | |
| 10481 | 591 |
| 10345 | 592 static void |
| 593 ans_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) | |
| 594 { | |
| 595 MsnSwitchBoard *swboard; | |
| 596 | |
| 10463 | 597 swboard = cmdproc->data; |
| 10345 | 598 swboard->ready = TRUE; |
| 599 } | |
| 600 | |
| 601 static void | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
602 bye_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
603 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
604 MsnSwitchBoard *swboard; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
605 const char *user; |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
606 |
| 10463 | 607 swboard = cmdproc->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
608 user = cmd->params[0]; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
609 |
| 10345 | 610 if (swboard->conv == NULL) |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
611 { |
| 10345 | 612 /* This is a helper switchboard */ |
| 10434 | 613 msn_switchboard_destroy(swboard); |
| 10345 | 614 } |
| 615 else if (swboard->current_users > 1) | |
| 616 { | |
| 617 /* This is a switchboard used for a chat */ | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
618 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(swboard->conv), user, NULL); |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
619 } |
|
8372
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
620 else |
|
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
621 { |
| 10345 | 622 /* This is a switchboard used for a im session */ |
| 623 | |
| 10504 | 624 if (cmd->param_count == 1) |
|
8372
bd16ed85cfc2
[gaim-migrate @ 9099]
Christian Hammond <chipx86@chipx86.com>
parents:
8207
diff
changeset
|
625 { |
| 10504 | 626 char *username, *str; |
| 10487 | 627 GaimAccount *account; |
| 628 GaimBuddy *b; | |
| 10225 | 629 |
| 10487 | 630 account = cmdproc->session->account; |
| 10225 | 631 |
| 10487 | 632 if ((b = gaim_find_buddy(account, user)) != NULL) |
| 633 username = gaim_escape_html(gaim_buddy_get_alias(b)); | |
| 634 else | |
| 635 username = gaim_escape_html(user); | |
| 10225 | 636 |
| 10504 | 637 str = g_strdup_printf(_("%s has closed the conversation window."), |
| 638 username); | |
| 639 | |
| 10487 | 640 g_free(username); |
| 10504 | 641 msn_switchboard_report_user(swboard, GAIM_MESSAGE_SYSTEM, str); |
| 642 g_free(str); | |
|
5626
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
643 } |
|
6275ac113622
[gaim-migrate @ 6033]
Christian Hammond <chipx86@chipx86.com>
parents:
5566
diff
changeset
|
644 |
| 10434 | 645 msn_switchboard_destroy(swboard); |
| 4542 | 646 } |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
647 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
648 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
649 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
650 iro_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
651 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
652 GaimAccount *account; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
653 GaimConnection *gc; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
654 MsnSwitchBoard *swboard; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
655 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
656 account = cmdproc->session->account; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
657 gc = account->gc; |
| 10463 | 658 swboard = cmdproc->data; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
659 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
660 swboard->total_users = atoi(cmd->params[2]); |
|
6026
01dd6b652c22
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
661 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
662 msn_switchboard_add_user(swboard, cmd->params[3]); |
| 4542 | 663 } |
| 664 | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
665 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
666 joi_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
| 4542 | 667 { |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
668 MsnSession *session; |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
669 GaimAccount *account; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
670 GaimConnection *gc; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
671 MsnSwitchBoard *swboard; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
672 const char *passport; |
| 4542 | 673 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
674 passport = cmd->params[0]; |
| 4542 | 675 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
676 session = cmdproc->session; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
677 account = session->account; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
678 gc = account->gc; |
| 10463 | 679 swboard = cmdproc->data; |
|
6026
01dd6b652c22
[gaim-migrate @ 6476]
Christian Hammond <chipx86@chipx86.com>
parents:
6025
diff
changeset
|
680 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
681 msn_switchboard_add_user(swboard, passport); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
682 |
| 10481 | 683 process_queue(swboard); |
|
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
684 |
| 10463 | 685 if (!session->http_method) |
| 686 send_clientcaps(swboard); | |
| 10403 | 687 |
| 688 if (swboard->closed) | |
| 689 msn_switchboard_close(swboard); | |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
690 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
691 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
692 static void |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
693 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
|
694 { |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
695 MsnMessage *msg; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
696 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
697 msg = msn_message_new_from_cmd(cmdproc->session, cmd); |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
698 |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
699 msn_message_parse_payload(msg, payload, len); |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
700 /* msn_message_show_readable(msg, "SB RECV", FALSE); */ |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
701 |
| 10284 | 702 if (msg->remote_user != NULL) |
| 703 g_free (msg->remote_user); | |
| 704 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
705 msg->remote_user = g_strdup(cmd->params[0]); |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
706 msn_cmdproc_process_msg(cmdproc, msg); |
|
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_destroy(msg); |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
709 } |
|
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
710 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
711 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
712 msg_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
713 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
714 cmdproc->servconn->payload_len = atoi(cmd->params[2]); |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
715 cmdproc->last_cmd->payload_cb = msg_cmd_post; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
716 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
717 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
718 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
719 nak_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
720 { |
| 10345 | 721 MsnMessage *msg; |
| 722 | |
| 723 msg = cmd->trans->data; | |
| 724 g_return_if_fail(msg != NULL); | |
| 725 | |
| 726 msg_error_helper(cmdproc, msg, MSN_MSG_ERROR_NAK); | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
727 } |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
728 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
729 static void |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
730 ack_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
731 { |
| 10403 | 732 MsnSwitchBoard *swboard; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
733 MsnMessage *msg; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
734 |
| 10345 | 735 msg = cmd->trans->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
736 |
| 10345 | 737 if (msg->ack_cb != NULL) |
| 738 msg->ack_cb(msg, msg->ack_data); | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
739 |
| 10463 | 740 swboard = cmdproc->data; |
| 10403 | 741 swboard->ack_list = g_list_remove(swboard->ack_list, msg); |
| 10345 | 742 msn_message_unref(msg); |
| 4542 | 743 } |
| 744 | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
745 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
746 out_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
747 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
748 GaimConnection *gc; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
749 MsnSwitchBoard *swboard; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
750 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
751 gc = cmdproc->session->account->gc; |
| 10463 | 752 swboard = cmdproc->data; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
753 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
754 if (swboard->current_users > 1) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
755 serv_got_chat_left(gc, swboard->chat_id); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
756 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
757 msn_switchboard_disconnect(swboard); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
758 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
759 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
760 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
761 usr_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd) |
| 4542 | 762 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
763 MsnSwitchBoard *swboard; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
764 |
| 10463 | 765 swboard = cmdproc->data; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
766 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
767 #if 0 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
768 GList *l; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
769 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
770 for (l = swboard->users; l != NULL; l = l->next) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
771 { |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
772 const char *user; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
773 user = l->data; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
774 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
775 msn_cmdproc_send(cmdproc, "CAL", "%s", user); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
776 } |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
777 #endif |
|
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 swboard->ready = TRUE; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
780 msn_cmdproc_process_queue(cmdproc); |
|
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 |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
783 /************************************************************************** |
| 10345 | 784 * Message Handlers |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
785 **************************************************************************/ |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
786 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
787 plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
788 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
789 GaimConnection *gc; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
790 MsnSwitchBoard *swboard; |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
791 const char *body; |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
792 char *body_str; |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
793 char *body_enc; |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
794 char *body_final; |
| 10112 | 795 size_t body_len; |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
796 const char *passport; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
797 const char *value; |
| 4542 | 798 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
799 gc = cmdproc->session->account->gc; |
| 10463 | 800 swboard = cmdproc->data; |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
801 |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
802 body = msn_message_get_bin_data(msg, &body_len); |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
803 body_str = g_strndup(body, body_len); |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
804 body_enc = gaim_escape_html(body_str); |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
805 g_free(body_str); |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
806 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
807 passport = msg->remote_user; |
|
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 if (!strcmp(passport, "messenger@microsoft.com") && |
|
6668
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
810 strstr(body, "immediate security update")) |
|
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
811 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
812 return; |
|
6668
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
813 } |
|
7e8a70c531a7
[gaim-migrate @ 7193]
Christian Hammond <chipx86@chipx86.com>
parents:
6640
diff
changeset
|
814 |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
815 #if 0 |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
816 if ((value = msn_message_get_attr(msg, "User-Agent")) != NULL) |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
817 { |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
818 gaim_debug_misc("msn", "User-Agent = '%s'\n", value); |
| 4542 | 819 } |
|
8646
1e211dde3cae
[gaim-migrate @ 9398]
Christian Hammond <chipx86@chipx86.com>
parents:
8583
diff
changeset
|
820 #endif |
| 4542 | 821 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
822 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
|
823 { |
|
6358
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
824 char *pre_format, *post_format; |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
825 |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
826 msn_parse_format(value, &pre_format, &post_format); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
827 |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
828 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
|
829 |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
830 g_free(pre_format); |
|
8ba58b296cc1
[gaim-migrate @ 6862]
Christian Hammond <chipx86@chipx86.com>
parents:
6148
diff
changeset
|
831 g_free(post_format); |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
832 g_free(body_enc); |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
833 } |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
834 else |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
835 { |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
836 body_final = body_enc; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
837 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
838 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
839 if (swboard->current_users > 1) |
|
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8442
diff
changeset
|
840 { |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
841 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
|
842 time(NULL)); |
|
8499
467b01d02f9c
[gaim-migrate @ 9235]
Christian Hammond <chipx86@chipx86.com>
parents:
8442
diff
changeset
|
843 } |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
844 else |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
845 serv_got_im(gc, passport, body_final, 0, time(NULL)); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
846 |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
847 g_free(body_final); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
848 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
849 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
850 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
851 control_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
852 { |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
853 GaimConnection *gc; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
854 MsnSwitchBoard *swboard; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
855 const char *value; |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
856 char *passport; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
857 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
858 gc = cmdproc->session->account->gc; |
| 10463 | 859 swboard = cmdproc->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
860 passport = msg->remote_user; |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
861 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
862 if (swboard->current_users == 1 && |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
863 (value = msn_message_get_attr(msg, "TypingUser")) != NULL) |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
864 { |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
865 serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT, |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5793
diff
changeset
|
866 GAIM_TYPING); |
| 4542 | 867 } |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
868 } |
| 4542 | 869 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
870 static void |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
871 clientcaps_msg(MsnCmdProc *cmdproc, MsnMessage *msg) |
|
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
872 { |
|
6845
5de4d9a4e0e2
[gaim-migrate @ 7390]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
873 #if 0 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
874 MsnSession *session; |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
875 MsnSwitchBoard *swboard; |
|
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
876 MsnUser *user; |
|
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
877 GHashTable *clientcaps; |
|
5351
2aa7e4237142
[gaim-migrate @ 5727]
Christian Hammond <chipx86@chipx86.com>
parents:
5342
diff
changeset
|
878 const char *value; |
|
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
879 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
880 char *passport = msg->sender; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
881 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
882 session = cmdproc->session; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
883 swboard = cmdproc->servconn->swboard; |
|
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
884 |
|
5475
ad9887c91a59
[gaim-migrate @ 5871]
Christian Hammond <chipx86@chipx86.com>
parents:
5454
diff
changeset
|
885 clientcaps = msn_message_get_hashtable_from_body(msg); |
|
6845
5de4d9a4e0e2
[gaim-migrate @ 7390]
Christian Hammond <chipx86@chipx86.com>
parents:
6842
diff
changeset
|
886 #endif |
|
5316
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
887 } |
|
d5690ed70085
[gaim-migrate @ 5688]
Christian Hammond <chipx86@chipx86.com>
parents:
5309
diff
changeset
|
888 |
| 10345 | 889 /************************************************************************** |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
890 * Connect stuff |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
891 **************************************************************************/ |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
892 static void |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
893 connect_cb(MsnServConn *servconn) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
894 { |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
895 MsnSwitchBoard *swboard; |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
896 MsnCmdProc *cmdproc; |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
897 GaimAccount *account; |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
898 |
|
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
899 cmdproc = servconn->cmdproc; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
900 g_return_if_fail(cmdproc != NULL); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
901 |
| 10463 | 902 account = cmdproc->session->account; |
| 903 swboard = cmdproc->data; | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
904 g_return_if_fail(swboard != NULL); |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
905 |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
906 if (msn_switchboard_is_invited(swboard)) |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
907 { |
| 10346 | 908 swboard->empty = FALSE; |
| 909 | |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
910 msn_cmdproc_send(cmdproc, "ANS", "%s %s %s", |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
911 gaim_account_get_username(account), |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
912 swboard->auth_key, swboard->session_id); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
913 } |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
914 else |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
915 { |
|
9158
c30d81b4dd22
[gaim-migrate @ 9942]
Christian Hammond <chipx86@chipx86.com>
parents:
9083
diff
changeset
|
916 msn_cmdproc_send(cmdproc, "USR", "%s %s", |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
917 gaim_account_get_username(account), |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
918 swboard->auth_key); |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
919 } |
| 4542 | 920 } |
| 921 | |
| 922 static void | |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
923 disconnect_cb(MsnServConn *servconn) |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
924 { |
|
8583
fc27237783ee
[gaim-migrate @ 9333]
Christian Hammond <chipx86@chipx86.com>
parents:
8499
diff
changeset
|
925 MsnSwitchBoard *swboard; |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
926 |
| 10463 | 927 swboard = servconn->cmdproc->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
928 g_return_if_fail(swboard != NULL); |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
929 |
| 10481 | 930 msn_servconn_set_disconnect_cb(swboard->servconn, NULL); |
| 931 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
932 msn_switchboard_destroy(swboard); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
933 } |
|
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
934 |
| 10345 | 935 gboolean |
| 936 msn_switchboard_connect(MsnSwitchBoard *swboard, const char *host, int port) | |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
937 { |
| 10345 | 938 g_return_val_if_fail(swboard != NULL, FALSE); |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
939 |
| 10345 | 940 msn_servconn_set_connect_cb(swboard->servconn, connect_cb); |
| 10434 | 941 msn_servconn_set_disconnect_cb(swboard->servconn, disconnect_cb); |
|
9198
ab6636c5a136
[gaim-migrate @ 9993]
Christian Hammond <chipx86@chipx86.com>
parents:
9194
diff
changeset
|
942 |
| 10345 | 943 return msn_servconn_connect(swboard->servconn, host, port); |
|
8808
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
944 } |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
945 |
|
bbd8cdaf0ad5
[gaim-migrate @ 9570]
Christian Hammond <chipx86@chipx86.com>
parents:
8663
diff
changeset
|
946 void |
| 10345 | 947 msn_switchboard_disconnect(MsnSwitchBoard *swboard) |
| 4542 | 948 { |
| 10345 | 949 g_return_if_fail(swboard != NULL); |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
950 |
| 10345 | 951 msn_servconn_disconnect(swboard->servconn); |
| 4542 | 952 } |
| 953 | |
| 10345 | 954 /************************************************************************** |
| 955 * Call stuff | |
| 956 **************************************************************************/ | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
957 static void |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
958 got_cal(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
959 { |
| 10403 | 960 #if 0 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
961 MsnSwitchBoard *swboard; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
962 const char *user; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
963 |
| 10463 | 964 swboard = cmdproc->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
965 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
966 user = cmd->params[0]; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
967 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
968 msn_switchboard_add_user(swboard, user); |
| 10403 | 969 #endif |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
970 } |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
971 |
| 10225 | 972 static void |
| 973 cal_timeout(MsnCmdProc *cmdproc, MsnTransaction *trans) | |
| 974 { | |
| 975 cal_error_helper(trans, MSN_SB_ERROR_UNKNOWN); | |
| 976 } | |
| 977 | |
| 978 static void | |
| 979 cal_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
| 980 { | |
| 981 int reason = MSN_SB_ERROR_UNKNOWN; | |
| 982 | |
| 10451 | 983 if (error == 215) |
| 984 { | |
| 985 gaim_debug_info("msn", "Invited user already in switchboard\n"); | |
| 986 return; | |
| 987 } | |
| 988 else if (error == 217) | |
| 989 { | |
| 10225 | 990 reason = MSN_SB_ERROR_USER_OFFLINE; |
| 10451 | 991 } |
| 10225 | 992 |
| 993 cal_error_helper(trans, reason); | |
| 994 } | |
| 995 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
996 void |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
997 msn_switchboard_request_add_user(MsnSwitchBoard *swboard, const char *user) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
998 { |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
999 MsnTransaction *trans; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1000 MsnCmdProc *cmdproc; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1001 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1002 g_return_if_fail(swboard != NULL); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1003 |
| 10463 | 1004 cmdproc = swboard->cmdproc; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1005 |
| 10225 | 1006 trans = msn_transaction_new(cmdproc, "CAL", "%s", user); |
| 10403 | 1007 /* this doesn't do anything, but users seem to think that |
| 1008 * 'Unhandled command' is some kind of error, so we don't report it */ | |
| 1009 msn_transaction_add_cb(trans, "CAL", got_cal); | |
| 10225 | 1010 |
| 1011 msn_transaction_set_data(trans, swboard); | |
| 1012 msn_transaction_set_timeout_cb(trans, cal_timeout); | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1013 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1014 if (swboard->ready) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1015 msn_cmdproc_send_trans(cmdproc, trans); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1016 else |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1017 msn_cmdproc_queue_trans(cmdproc, trans); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1018 } |
| 4542 | 1019 |
| 10345 | 1020 /************************************************************************** |
| 1021 * Create & Transfer stuff | |
| 1022 **************************************************************************/ | |
| 10481 | 1023 |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1024 static void |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1025 got_swboard(MsnCmdProc *cmdproc, MsnCommand *cmd) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1026 { |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1027 MsnSwitchBoard *swboard; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1028 char *host; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1029 int port; |
| 9218 | 1030 swboard = cmd->trans->data; |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1031 |
| 10403 | 1032 if (g_list_find(cmdproc->session->switches, swboard) == NULL) |
| 1033 /* The conversation window was closed. */ | |
| 1034 return; | |
| 1035 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1036 msn_switchboard_set_auth_key(swboard, cmd->params[4]); |
|
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_parse_socket(cmd->params[2], &host, &port); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1039 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1040 msn_switchboard_connect(swboard, host, port); |
| 10093 | 1041 |
| 1042 g_free(host); | |
|
5309
e2e53316a21d
[gaim-migrate @ 5681]
Christian Hammond <chipx86@chipx86.com>
parents:
5221
diff
changeset
|
1043 } |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1044 |
| 10225 | 1045 static void |
| 1046 xfr_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) | |
| 1047 { | |
| 1048 MsnSwitchBoard *swboard; | |
| 1049 int reason = MSN_SB_ERROR_UNKNOWN; | |
| 1050 | |
| 1051 if (error == 913) | |
| 1052 reason = MSN_SB_ERROR_OFFLINE; | |
| 1053 | |
| 1054 swboard = trans->data; | |
| 1055 | |
| 1056 swboard_error_helper(swboard, reason, swboard->im_user); | |
| 1057 } | |
| 1058 | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1059 void |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1060 msn_switchboard_request(MsnSwitchBoard *swboard) |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1061 { |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1062 MsnCmdProc *cmdproc; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1063 MsnTransaction *trans; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1064 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1065 g_return_if_fail(swboard != NULL); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1066 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1067 cmdproc = swboard->session->notification->cmdproc; |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1068 |
| 10225 | 1069 trans = msn_transaction_new(cmdproc, "XFR", "%s", "SB"); |
| 1070 msn_transaction_add_cb(trans, "XFR", got_swboard); | |
| 10403 | 1071 |
| 10225 | 1072 msn_transaction_set_data(trans, swboard); |
| 1073 msn_transaction_set_error_cb(trans, xfr_error); | |
|
9193
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1074 |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1075 msn_cmdproc_send_trans(cmdproc, trans); |
|
502707ca1836
[gaim-migrate @ 9988]
Christian Hammond <chipx86@chipx86.com>
parents:
9158
diff
changeset
|
1076 } |
| 10345 | 1077 |
| 10403 | 1078 void |
| 1079 msn_switchboard_close(MsnSwitchBoard *swboard) | |
| 1080 { | |
| 1081 g_return_if_fail(swboard != NULL); | |
| 1082 | |
| 10481 | 1083 if (swboard->error != MSN_SB_ERROR_NONE) |
| 1084 { | |
| 1085 msn_switchboard_destroy(swboard); | |
| 1086 } | |
| 1087 else if (g_queue_is_empty(swboard->msg_queue) || | |
| 1088 !swboard->session->connected) | |
| 10403 | 1089 { |
| 1090 MsnCmdProc *cmdproc; | |
| 10463 | 1091 cmdproc = swboard->cmdproc; |
| 10403 | 1092 msn_cmdproc_send_quick(cmdproc, "OUT", NULL, NULL); |
| 1093 | |
| 1094 msn_switchboard_destroy(swboard); | |
| 1095 } | |
| 1096 else | |
| 10481 | 1097 { |
| 10403 | 1098 swboard->closed = TRUE; |
| 10481 | 1099 } |
| 10403 | 1100 } |
| 1101 | |
| 10345 | 1102 /************************************************************************** |
| 1103 * Init stuff | |
| 1104 **************************************************************************/ | |
| 10481 | 1105 |
| 10345 | 1106 void |
| 1107 msn_switchboard_init(void) | |
| 1108 { | |
| 1109 cbs_table = msn_table_new(); | |
| 1110 | |
| 1111 msn_table_add_cmd(cbs_table, "ANS", "ANS", ans_cmd); | |
| 1112 msn_table_add_cmd(cbs_table, "ANS", "IRO", iro_cmd); | |
| 1113 | |
| 1114 msn_table_add_cmd(cbs_table, "MSG", "ACK", ack_cmd); | |
| 1115 msn_table_add_cmd(cbs_table, "MSG", "NAK", nak_cmd); | |
| 1116 | |
| 1117 msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd); | |
| 1118 | |
| 1119 msn_table_add_cmd(cbs_table, NULL, "MSG", msg_cmd); | |
| 1120 msn_table_add_cmd(cbs_table, NULL, "JOI", joi_cmd); | |
| 1121 msn_table_add_cmd(cbs_table, NULL, "BYE", bye_cmd); | |
| 1122 msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd); | |
| 1123 | |
| 1124 #if 0 | |
| 1125 /* They might skip the history */ | |
| 1126 msn_table_add_cmd(cbs_table, NULL, "ACK", NULL); | |
| 1127 #endif | |
| 1128 | |
| 1129 msn_table_add_error(cbs_table, "MSG", msg_error); | |
| 1130 msn_table_add_error(cbs_table, "CAL", cal_error); | |
| 1131 | |
| 1132 /* Register the message type callbacks. */ | |
| 1133 msn_table_add_msg_type(cbs_table, "text/plain", | |
| 1134 plain_msg); | |
| 1135 msn_table_add_msg_type(cbs_table, "text/x-msmsgscontrol", | |
| 1136 control_msg); | |
| 1137 msn_table_add_msg_type(cbs_table, "text/x-clientcaps", | |
| 1138 clientcaps_msg); | |
| 1139 msn_table_add_msg_type(cbs_table, "text/x-clientinfo", | |
| 1140 clientcaps_msg); | |
| 1141 msn_table_add_msg_type(cbs_table, "application/x-msnmsgrp2p", | |
| 1142 msn_p2p_msg); | |
| 1143 msn_table_add_msg_type(cbs_table, "text/x-mms-emoticon", | |
| 1144 msn_emoticon_msg); | |
| 1145 #if 0 | |
| 1146 msn_table_add_msg_type(cbs_table, "text/x-msmmsginvite", | |
| 1147 msn_invite_msg); | |
| 1148 #endif | |
| 1149 } | |
| 1150 | |
| 1151 void | |
| 1152 msn_switchboard_end(void) | |
| 1153 { | |
| 1154 msn_table_destroy(cbs_table); | |
| 1155 } |
