Mercurial > pidgin
annotate libgaim/protocols/msn/msn.c @ 20390:d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
"This tarball brings soc-2006-msnp13 up to head. In addition to that it also
fixes a crash with sending offline messages.
I wasn't able to generate a diff against that branch, svn seems to insist
on diff'ing against HEAD after I run the merge command. After running `svn
merge -r 16309:HEAD https://gaim.svn.sourceforge.net/svnroot/gaim/trunk` on
the soc-2006-msnp13 you can replace the msn directory with the attached
tarball. The fix for offline messaging is on msn.c:901:
if (!session->oim)
session->oim = msn_oim_new(session)"
committer: Richard Laager <rlaager@wiktel.com>
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Sun, 15 Apr 2007 02:18:17 +0000 |
parents | e354528c4163 |
children | 0b0ecee55091 9755b2f7bb0f |
rev | line source |
---|---|
14192 | 1 /** |
2 * @file msn.c The MSN protocol plugin | |
3 * | |
4 * gaim | |
5 * | |
6 * Gaim is the legal property of its developers, whose names are too numerous | |
7 * to list here. Please refer to the COPYRIGHT file distributed with this | |
8 * source distribution. | |
9 * | |
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 | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 */ | |
24 #define PHOTO_SUPPORT 1 | |
25 | |
26 #include <glib.h> | |
27 | |
28 #include "msn.h" | |
29 #include "accountopt.h" | |
30 #include "msg.h" | |
31 #include "page.h" | |
32 #include "pluginpref.h" | |
33 #include "prefs.h" | |
34 #include "session.h" | |
35 #include "state.h" | |
36 #include "util.h" | |
37 #include "cmds.h" | |
38 #include "prpl.h" | |
39 #include "msn-utils.h" | |
40 #include "version.h" | |
41 | |
42 #include "switchboard.h" | |
43 #include "notification.h" | |
44 #include "sync.h" | |
45 #include "slplink.h" | |
46 | |
47 #if PHOTO_SUPPORT | |
48 #include "imgstore.h" | |
49 #endif | |
50 | |
51 typedef struct | |
52 { | |
53 GaimConnection *gc; | |
54 const char *passport; | |
55 | |
56 } MsnMobileData; | |
57 | |
58 typedef struct | |
59 { | |
60 GaimConnection *gc; | |
61 char *name; | |
62 | |
63 } MsnGetInfoData; | |
64 | |
65 typedef struct | |
66 { | |
67 MsnGetInfoData *info_data; | |
68 char *stripped; | |
69 char *url_buffer; | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
70 GaimNotifyUserInfo *user_info; |
14192 | 71 char *photo_url_text; |
72 | |
73 } MsnGetInfoStepTwoData; | |
74 | |
75 static const char * | |
76 msn_normalize(const GaimAccount *account, const char *str) | |
77 { | |
78 static char buf[BUF_LEN]; | |
79 char *tmp; | |
80 | |
81 g_return_val_if_fail(str != NULL, NULL); | |
82 | |
83 g_snprintf(buf, sizeof(buf), "%s%s", str, | |
84 (strchr(str, '@') ? "" : "@hotmail.com")); | |
85 | |
86 tmp = g_utf8_strdown(buf, -1); | |
87 strncpy(buf, tmp, sizeof(buf)); | |
88 g_free(tmp); | |
89 | |
90 return buf; | |
91 } | |
92 | |
93 static GaimCmdRet | |
94 msn_cmd_nudge(GaimConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) | |
95 { | |
96 GaimAccount *account = gaim_conversation_get_account(conv); | |
97 GaimConnection *gc = gaim_account_get_connection(account); | |
98 MsnMessage *msg; | |
99 MsnSession *session; | |
100 MsnSwitchBoard *swboard; | |
101 | |
102 msg = msn_message_new_nudge(); | |
103 session = gc->proto_data; | |
104 swboard = msn_session_get_swboard(session, gaim_conversation_get_name(conv), MSN_SB_FLAG_IM); | |
105 | |
106 if (swboard == NULL) | |
107 return GAIM_CMD_RET_FAILED; | |
108 | |
109 msn_switchboard_send_msg(swboard, msg, TRUE); | |
110 | |
111 gaim_conversation_write(conv, NULL, _("You have just sent a Nudge!"), GAIM_MESSAGE_SYSTEM, time(NULL)); | |
112 | |
113 return GAIM_CMD_RET_OK; | |
114 } | |
115 | |
116 static void | |
117 msn_act_id(GaimConnection *gc, const char *entry) | |
118 { | |
119 MsnCmdProc *cmdproc; | |
120 MsnSession *session; | |
121 GaimAccount *account; | |
122 const char *alias; | |
123 | |
124 session = gc->proto_data; | |
125 cmdproc = session->notification->cmdproc; | |
126 account = gaim_connection_get_account(gc); | |
127 | |
128 if(entry && strlen(entry)) | |
129 alias = gaim_url_encode(entry); | |
130 else | |
131 alias = ""; | |
132 | |
133 if (strlen(alias) > BUDDY_ALIAS_MAXLEN) | |
134 { | |
135 gaim_notify_error(gc, NULL, | |
136 _("Your new MSN friendly name is too long."), NULL); | |
137 return; | |
138 } | |
139 | |
140 msn_cmdproc_send(cmdproc, "REA", "%s %s", | |
141 gaim_account_get_username(account), | |
142 alias); | |
143 } | |
144 | |
145 static void | |
146 msn_set_prp(GaimConnection *gc, const char *type, const char *entry) | |
147 { | |
148 MsnCmdProc *cmdproc; | |
149 MsnSession *session; | |
150 | |
151 session = gc->proto_data; | |
152 cmdproc = session->notification->cmdproc; | |
153 | |
154 if (entry == NULL || *entry == '\0') | |
155 { | |
156 msn_cmdproc_send(cmdproc, "PRP", "%s", type); | |
157 } | |
158 else | |
159 { | |
160 msn_cmdproc_send(cmdproc, "PRP", "%s %s", type, | |
161 gaim_url_encode(entry)); | |
162 } | |
163 } | |
164 | |
165 static void | |
166 msn_set_home_phone_cb(GaimConnection *gc, const char *entry) | |
167 { | |
168 msn_set_prp(gc, "PHH", entry); | |
169 } | |
170 | |
171 static void | |
172 msn_set_work_phone_cb(GaimConnection *gc, const char *entry) | |
173 { | |
174 msn_set_prp(gc, "PHW", entry); | |
175 } | |
176 | |
177 static void | |
178 msn_set_mobile_phone_cb(GaimConnection *gc, const char *entry) | |
179 { | |
180 msn_set_prp(gc, "PHM", entry); | |
181 } | |
182 | |
183 static void | |
184 enable_msn_pages_cb(GaimConnection *gc) | |
185 { | |
186 msn_set_prp(gc, "MOB", "Y"); | |
187 } | |
188 | |
189 static void | |
190 disable_msn_pages_cb(GaimConnection *gc) | |
191 { | |
192 msn_set_prp(gc, "MOB", "N"); | |
193 } | |
194 | |
195 static void | |
196 send_to_mobile(GaimConnection *gc, const char *who, const char *entry) | |
197 { | |
198 MsnTransaction *trans; | |
199 MsnSession *session; | |
200 MsnCmdProc *cmdproc; | |
201 MsnPage *page; | |
202 char *payload; | |
203 size_t payload_len; | |
204 | |
205 session = gc->proto_data; | |
206 cmdproc = session->notification->cmdproc; | |
207 | |
208 page = msn_page_new(); | |
209 msn_page_set_body(page, entry); | |
210 | |
211 payload = msn_page_gen_payload(page, &payload_len); | |
212 | |
213 trans = msn_transaction_new(cmdproc, "PGD", "%s 1 %d", who, payload_len); | |
214 | |
215 msn_transaction_set_payload(trans, payload, payload_len); | |
216 | |
217 msn_page_destroy(page); | |
218 | |
219 msn_cmdproc_send_trans(cmdproc, trans); | |
220 } | |
221 | |
222 static void | |
223 send_to_mobile_cb(MsnMobileData *data, const char *entry) | |
224 { | |
225 send_to_mobile(data->gc, data->passport, entry); | |
226 g_free(data); | |
227 } | |
228 | |
229 static void | |
230 close_mobile_page_cb(MsnMobileData *data, const char *entry) | |
231 { | |
232 g_free(data); | |
233 } | |
234 | |
235 /* -- */ | |
236 | |
237 static void | |
238 msn_show_set_friendly_name(GaimPluginAction *action) | |
239 { | |
240 GaimConnection *gc; | |
241 | |
242 gc = (GaimConnection *) action->context; | |
243 | |
244 gaim_request_input(gc, NULL, _("Set your friendly name."), | |
245 _("This is the name that other MSN buddies will " | |
246 "see you as."), | |
247 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, | |
248 _("OK"), G_CALLBACK(msn_act_id), | |
249 _("Cancel"), NULL, gc); | |
250 } | |
251 | |
252 static void | |
253 msn_show_set_home_phone(GaimPluginAction *action) | |
254 { | |
255 GaimConnection *gc; | |
256 MsnSession *session; | |
257 | |
258 gc = (GaimConnection *) action->context; | |
259 session = gc->proto_data; | |
260 | |
261 gaim_request_input(gc, NULL, _("Set your home phone number."), NULL, | |
262 msn_user_get_home_phone(session->user), FALSE, FALSE, NULL, | |
263 _("OK"), G_CALLBACK(msn_set_home_phone_cb), | |
264 _("Cancel"), NULL, gc); | |
265 } | |
266 | |
267 static void | |
268 msn_show_set_work_phone(GaimPluginAction *action) | |
269 { | |
270 GaimConnection *gc; | |
271 MsnSession *session; | |
272 | |
273 gc = (GaimConnection *) action->context; | |
274 session = gc->proto_data; | |
275 | |
276 gaim_request_input(gc, NULL, _("Set your work phone number."), NULL, | |
277 msn_user_get_work_phone(session->user), FALSE, FALSE, NULL, | |
278 _("OK"), G_CALLBACK(msn_set_work_phone_cb), | |
279 _("Cancel"), NULL, gc); | |
280 } | |
281 | |
282 static void | |
283 msn_show_set_mobile_phone(GaimPluginAction *action) | |
284 { | |
285 GaimConnection *gc; | |
286 MsnSession *session; | |
287 | |
288 gc = (GaimConnection *) action->context; | |
289 session = gc->proto_data; | |
290 | |
291 gaim_request_input(gc, NULL, _("Set your mobile phone number."), NULL, | |
292 msn_user_get_mobile_phone(session->user), FALSE, FALSE, NULL, | |
293 _("OK"), G_CALLBACK(msn_set_mobile_phone_cb), | |
294 _("Cancel"), NULL, gc); | |
295 } | |
296 | |
297 static void | |
298 msn_show_set_mobile_pages(GaimPluginAction *action) | |
299 { | |
300 GaimConnection *gc; | |
301 | |
302 gc = (GaimConnection *) action->context; | |
303 | |
304 gaim_request_action(gc, NULL, _("Allow MSN Mobile pages?"), | |
305 _("Do you want to allow or disallow people on " | |
306 "your buddy list to send you MSN Mobile pages " | |
307 "to your cell phone or other mobile device?"), | |
308 -1, gc, 3, | |
309 _("Allow"), G_CALLBACK(enable_msn_pages_cb), | |
310 _("Disallow"), G_CALLBACK(disable_msn_pages_cb), | |
311 _("Cancel"), NULL); | |
312 } | |
313 | |
314 static void | |
315 msn_show_hotmail_inbox(GaimPluginAction *action) | |
316 { | |
317 GaimConnection *gc; | |
318 MsnSession *session; | |
319 | |
320 gc = (GaimConnection *) action->context; | |
321 session = gc->proto_data; | |
322 | |
323 if (session->passport_info.file == NULL) | |
324 { | |
325 gaim_notify_error(gc, NULL, | |
326 _("This Hotmail account may not be active."), NULL); | |
327 return; | |
328 } | |
329 | |
330 gaim_notify_uri(gc, session->passport_info.file); | |
331 } | |
332 | |
333 static void | |
334 show_send_to_mobile_cb(GaimBlistNode *node, gpointer ignored) | |
335 { | |
336 GaimBuddy *buddy; | |
337 GaimConnection *gc; | |
338 MsnSession *session; | |
339 MsnMobileData *data; | |
340 | |
341 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
342 | |
343 buddy = (GaimBuddy *) node; | |
344 gc = gaim_account_get_connection(buddy->account); | |
345 | |
346 session = gc->proto_data; | |
347 | |
348 data = g_new0(MsnMobileData, 1); | |
349 data->gc = gc; | |
350 data->passport = buddy->name; | |
351 | |
352 gaim_request_input(gc, NULL, _("Send a mobile message."), NULL, | |
353 NULL, TRUE, FALSE, NULL, | |
354 _("Page"), G_CALLBACK(send_to_mobile_cb), | |
355 _("Close"), G_CALLBACK(close_mobile_page_cb), | |
356 data); | |
357 } | |
358 | |
359 static void | |
360 initiate_chat_cb(GaimBlistNode *node, gpointer data) | |
361 { | |
362 GaimBuddy *buddy; | |
363 GaimConnection *gc; | |
364 | |
365 MsnSession *session; | |
366 MsnSwitchBoard *swboard; | |
367 | |
368 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
369 | |
370 buddy = (GaimBuddy *) node; | |
371 gc = gaim_account_get_connection(buddy->account); | |
372 | |
373 session = gc->proto_data; | |
374 | |
375 swboard = msn_switchboard_new(session); | |
376 msn_switchboard_request(swboard); | |
377 msn_switchboard_request_add_user(swboard, buddy->name); | |
378 | |
379 /* TODO: This might move somewhere else, after USR might be */ | |
380 swboard->chat_id = session->conv_seq++; | |
381 swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat"); | |
382 swboard->flag = MSN_SB_FLAG_IM; | |
383 | |
384 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), | |
385 gaim_account_get_username(buddy->account), NULL, GAIM_CBFLAGS_NONE, TRUE); | |
386 } | |
387 | |
388 static void | |
389 t_msn_xfer_init(GaimXfer *xfer) | |
390 { | |
391 MsnSlpLink *slplink; | |
392 const char *filename; | |
393 FILE *fp; | |
394 | |
395 filename = gaim_xfer_get_local_filename(xfer); | |
396 | |
397 slplink = xfer->data; | |
398 | |
399 if ((fp = g_fopen(filename, "rb")) == NULL) | |
400 { | |
401 GaimAccount *account; | |
402 const char *who; | |
403 char *msg; | |
404 | |
405 account = slplink->session->account; | |
406 who = slplink->remote_user; | |
407 | |
408 msg = g_strdup_printf(_("Error reading %s: \n%s.\n"), | |
409 filename, strerror(errno)); | |
410 gaim_xfer_error(gaim_xfer_get_type(xfer), account, xfer->who, msg); | |
411 gaim_xfer_cancel_local(xfer); | |
412 g_free(msg); | |
413 | |
414 return; | |
415 } | |
416 fclose(fp); | |
417 | |
418 msn_slplink_request_ft(slplink, xfer); | |
419 } | |
420 | |
421 static GaimXfer* | |
422 msn_new_xfer(GaimConnection *gc, const char *who) | |
423 { | |
424 MsnSession *session; | |
425 MsnSlpLink *slplink; | |
426 GaimXfer *xfer; | |
427 | |
428 session = gc->proto_data; | |
429 | |
430 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
431 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
432 slplink = msn_session_get_slplink(session, who); |
14192 | 433 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
434 xfer->data = slplink; |
14192 | 435 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
436 gaim_xfer_set_init_fnc(xfer, t_msn_xfer_init); |
14192 | 437 |
438 return xfer; | |
439 } | |
440 | |
441 static void | |
442 msn_send_file(GaimConnection *gc, const char *who, const char *file) | |
443 { | |
444 GaimXfer *xfer = msn_new_xfer(gc, who); | |
445 | |
446 if (file) | |
447 gaim_xfer_request_accepted(xfer, file); | |
448 else | |
449 gaim_xfer_request(xfer); | |
450 } | |
451 | |
452 static gboolean | |
453 msn_can_receive_file(GaimConnection *gc, const char *who) | |
454 { | |
455 GaimAccount *account; | |
456 char *normal; | |
457 gboolean ret; | |
458 | |
459 account = gaim_connection_get_account(gc); | |
460 | |
461 normal = g_strdup(msn_normalize(account, gaim_account_get_username(account))); | |
462 | |
463 ret = strcmp(normal, msn_normalize(account, who)); | |
464 | |
465 g_free(normal); | |
466 | |
467 return ret; | |
468 } | |
469 | |
470 /************************************************************************** | |
471 * Protocol Plugin ops | |
472 **************************************************************************/ | |
473 | |
474 static const char * | |
475 msn_list_icon(GaimAccount *a, GaimBuddy *b) | |
476 { | |
477 return "msn"; | |
478 } | |
479 | |
480 static void | |
481 msn_list_emblems(GaimBuddy *b, const char **se, const char **sw, | |
482 const char **nw, const char **ne) | |
483 { | |
484 MsnUser *user; | |
485 GaimPresence *presence; | |
486 const char *emblems[4] = { NULL, NULL, NULL, NULL }; | |
487 int i = 0; | |
488 | |
489 user = b->proto_data; | |
490 presence = gaim_buddy_get_presence(b); | |
491 | |
492 if (!gaim_presence_is_online(presence)) | |
493 emblems[i++] = "offline"; | |
494 else if (gaim_presence_is_status_active(presence, "busy") || | |
495 gaim_presence_is_status_active(presence, "phone")) | |
496 emblems[i++] = "occupied"; | |
497 else if (!gaim_presence_is_available(presence)) | |
498 emblems[i++] = "away"; | |
499 | |
500 if (user == NULL) | |
501 { | |
502 emblems[0] = "offline"; | |
503 } | |
504 else | |
505 { | |
506 if (user->mobile) | |
507 emblems[i++] = "wireless"; | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
508 if (!(user->list_op & (1 << MSN_LIST_RL))) |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
509 emblems[i++] = "nr"; |
14192 | 510 } |
511 | |
512 *se = emblems[0]; | |
513 *sw = emblems[1]; | |
514 *nw = emblems[2]; | |
515 *ne = emblems[3]; | |
516 } | |
517 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
518 /* |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
519 * Set the User status text |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
520 * Add the PSM String Using "Name - PSM String" format |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
521 */ |
14192 | 522 static char * |
523 msn_status_text(GaimBuddy *buddy) | |
524 { | |
525 GaimPresence *presence; | |
526 GaimStatus *status; | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
527 char *msg, *psm_str, *tmp2, *text, *name; |
14192 | 528 |
529 presence = gaim_buddy_get_presence(buddy); | |
530 status = gaim_presence_get_active_status(presence); | |
531 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
532 msg = gaim_status_get_attr_string(status, "message"); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
533 if (!gaim_presence_is_available(presence) && !gaim_presence_is_idle(presence)){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
534 name = gaim_status_get_name(status); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
535 }else{ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
536 name = NULL; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
537 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
538 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
539 if (msg != NULL) { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
540 tmp2 = gaim_markup_strip_html(msg); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
541 if (name){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
542 psm_str = g_strdup_printf("%s - %s", name, tmp2); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
543 g_free(tmp2); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
544 }else{ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
545 psm_str = tmp2; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
546 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
547 text = g_markup_escape_text(psm_str, -1); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
548 g_free(psm_str); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
549 return text; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
550 } else { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
551 if (!gaim_presence_is_available(presence) && !gaim_presence_is_idle(presence)){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
552 psm_str = g_strdup(gaim_status_get_name(status)); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
553 text = g_markup_escape_text(psm_str, -1); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
554 g_free(psm_str); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
555 return text; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
556 } |
14192 | 557 } |
558 | |
559 return NULL; | |
560 } | |
561 | |
562 static void | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
563 msn_tooltip_text(GaimBuddy *buddy, GaimNotifyUserInfo *user_info, gboolean full) |
14192 | 564 { |
565 MsnUser *user; | |
566 GaimPresence *presence = gaim_buddy_get_presence(buddy); | |
567 GaimStatus *status = gaim_presence_get_active_status(presence); | |
568 | |
569 user = buddy->proto_data; | |
570 | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
571 |
14192 | 572 if (gaim_presence_is_online(presence)) |
573 { | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
574 char *psm; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
575 psm = msn_status_text(buddy); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
576 |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
577 gaim_notify_user_info_add_pair(user_info, _("Status"), |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
578 (gaim_presence_is_idle(presence) ? _("Idle") : gaim_status_get_name(status))); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
579 if (psm) { |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
580 gaim_notify_user_info_add_pair(user_info, _("PSM"), psm); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
581 g_free(psm); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
582 } |
14192 | 583 } |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
584 |
14192 | 585 if (full && user) |
586 { | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
587 gaim_notify_user_info_add_pair(user_info, _("Has you"), |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
588 ((user->list_op & (1 << MSN_LIST_RL)) ? _("Yes") : _("No"))); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
589 } |
14192 | 590 |
591 /* XXX: This is being shown in non-full tooltips because the | |
592 * XXX: blocked icon overlay isn't always accurate for MSN. | |
593 * XXX: This can die as soon as gaim_privacy_check() knows that | |
594 * XXX: this prpl always honors both the allow and deny lists. */ | |
595 if (user) | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
596 { |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
597 gaim_notify_user_info_add_pair(user_info, _("Blocked"), |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
598 ((user->list_op & (1 << MSN_LIST_BL)) ? _("Yes") : _("No"))); |
14192 | 599 } |
600 } | |
601 | |
602 static GList * | |
603 msn_status_types(GaimAccount *account) | |
604 { | |
605 GaimStatusType *status; | |
606 GList *types = NULL; | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
607 #if 0 |
14192 | 608 status = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, |
609 NULL, NULL, FALSE, TRUE, FALSE); | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
610 #endif |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
611 status = gaim_status_type_new_with_attrs( |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
612 GAIM_STATUS_AVAILABLE, NULL, NULL, TRUE, TRUE, FALSE, |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
613 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
614 NULL); |
14192 | 615 types = g_list_append(types, status); |
616 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
617 status = gaim_status_type_new_with_attrs( |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
618 GAIM_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
619 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
620 NULL); |
14192 | 621 types = g_list_append(types, status); |
622 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
623 status = gaim_status_type_new_with_attrs( |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
624 GAIM_STATUS_AWAY, "brb", _("Be Right Back"), TRUE, TRUE, FALSE, |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
625 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
626 NULL); |
14192 | 627 types = g_list_append(types, status); |
628 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
629 status = gaim_status_type_new_with_attrs( |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
630 GAIM_STATUS_AWAY, "busy", _("Busy"), TRUE, TRUE, FALSE, |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
631 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
632 NULL); |
14192 | 633 types = g_list_append(types, status); |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
634 status = gaim_status_type_new_with_attrs( |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
635 GAIM_STATUS_AWAY, "phone", _("On the Phone"), TRUE, TRUE, FALSE, |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
636 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
637 NULL); |
14192 | 638 types = g_list_append(types, status); |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
639 status = gaim_status_type_new_with_attrs( |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
640 GAIM_STATUS_AWAY, "lunch", _("Out to Lunch"), TRUE, TRUE, FALSE, |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
641 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
642 NULL); |
14192 | 643 types = g_list_append(types, status); |
644 | |
645 status = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE, | |
646 NULL, NULL, FALSE, TRUE, FALSE); | |
647 types = g_list_append(types, status); | |
648 | |
649 status = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, | |
650 NULL, NULL, FALSE, TRUE, FALSE); | |
651 types = g_list_append(types, status); | |
652 | |
653 return types; | |
654 } | |
655 | |
656 static GList * | |
657 msn_actions(GaimPlugin *plugin, gpointer context) | |
658 { | |
659 GaimConnection *gc = (GaimConnection *)context; | |
660 GaimAccount *account; | |
661 const char *user; | |
662 | |
663 GList *m = NULL; | |
664 GaimPluginAction *act; | |
665 | |
666 act = gaim_plugin_action_new(_("Set Friendly Name..."), | |
667 msn_show_set_friendly_name); | |
668 m = g_list_append(m, act); | |
669 m = g_list_append(m, NULL); | |
670 | |
671 act = gaim_plugin_action_new(_("Set Home Phone Number..."), | |
672 msn_show_set_home_phone); | |
673 m = g_list_append(m, act); | |
674 | |
675 act = gaim_plugin_action_new(_("Set Work Phone Number..."), | |
676 msn_show_set_work_phone); | |
677 m = g_list_append(m, act); | |
678 | |
679 act = gaim_plugin_action_new(_("Set Mobile Phone Number..."), | |
680 msn_show_set_mobile_phone); | |
681 m = g_list_append(m, act); | |
682 m = g_list_append(m, NULL); | |
683 | |
684 #if 0 | |
685 act = gaim_plugin_action_new(_("Enable/Disable Mobile Devices..."), | |
686 msn_show_set_mobile_support); | |
687 m = g_list_append(m, act); | |
688 #endif | |
689 | |
690 act = gaim_plugin_action_new(_("Allow/Disallow Mobile Pages..."), | |
691 msn_show_set_mobile_pages); | |
692 m = g_list_append(m, act); | |
693 | |
694 account = gaim_connection_get_account(gc); | |
695 user = msn_normalize(account, gaim_account_get_username(account)); | |
696 | |
697 if (strstr(user, "@hotmail.com") != NULL) | |
698 { | |
699 m = g_list_append(m, NULL); | |
700 act = gaim_plugin_action_new(_("Open Hotmail Inbox"), | |
701 msn_show_hotmail_inbox); | |
702 m = g_list_append(m, act); | |
703 } | |
704 | |
705 return m; | |
706 } | |
707 | |
708 static GList * | |
709 msn_buddy_menu(GaimBuddy *buddy) | |
710 { | |
711 MsnUser *user; | |
712 | |
713 GList *m = NULL; | |
714 GaimMenuAction *act; | |
715 | |
716 g_return_val_if_fail(buddy != NULL, NULL); | |
717 | |
718 user = buddy->proto_data; | |
719 | |
720 if (user != NULL) | |
721 { | |
722 if (user->mobile) | |
723 { | |
724 act = gaim_menu_action_new(_("Send to Mobile"), | |
725 GAIM_CALLBACK(show_send_to_mobile_cb), | |
726 NULL, NULL); | |
727 m = g_list_append(m, act); | |
728 } | |
729 } | |
730 | |
731 if (g_ascii_strcasecmp(buddy->name, | |
732 gaim_account_get_username(buddy->account))) | |
733 { | |
734 act = gaim_menu_action_new(_("Initiate _Chat"), | |
735 GAIM_CALLBACK(initiate_chat_cb), | |
736 NULL, NULL); | |
737 m = g_list_append(m, act); | |
738 } | |
739 | |
740 return m; | |
741 } | |
742 | |
743 static GList * | |
744 msn_blist_node_menu(GaimBlistNode *node) | |
745 { | |
746 if(GAIM_BLIST_NODE_IS_BUDDY(node)) | |
747 { | |
748 return msn_buddy_menu((GaimBuddy *) node); | |
749 } | |
750 else | |
751 { | |
752 return NULL; | |
753 } | |
754 } | |
755 | |
756 static void | |
757 msn_login(GaimAccount *account) | |
758 { | |
759 GaimConnection *gc; | |
760 MsnSession *session; | |
761 const char *username; | |
762 const char *host; | |
763 gboolean http_method = FALSE; | |
764 int port; | |
765 | |
766 gc = gaim_account_get_connection(account); | |
767 | |
768 if (!gaim_ssl_is_supported()) | |
769 { | |
770 gc->wants_to_die = TRUE; | |
771 gaim_connection_error(gc, | |
772 _("SSL support is needed for MSN. Please install a supported " | |
773 "SSL library. See http://gaim.sf.net/faq-ssl.php for more " | |
774 "information.")); | |
775 | |
776 return; | |
777 } | |
778 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
779 if (gaim_account_get_bool(account, "http_method", FALSE)) |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
780 http_method = TRUE; |
14192 | 781 |
782 host = gaim_account_get_string(account, "server", MSN_SERVER); | |
783 port = gaim_account_get_int(account, "port", MSN_PORT); | |
784 | |
785 session = msn_session_new(account); | |
786 | |
787 gc->proto_data = session; | |
788 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_FORMATTING_WBFO | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_FONTSIZE | GAIM_CONNECTION_NO_URLDESC; | |
789 | |
790 msn_session_set_login_step(session, MSN_LOGIN_STEP_START); | |
791 | |
792 /* Hmm, I don't like this. */ | |
793 /* XXX shx: Me neither */ | |
794 username = msn_normalize(account, gaim_account_get_username(account)); | |
795 | |
796 if (strcmp(username, gaim_account_get_username(account))) | |
797 gaim_account_set_username(account, username); | |
798 | |
799 if (!msn_session_connect(session, host, port, http_method)) | |
800 gaim_connection_error(gc, _("Failed to connect to server.")); | |
801 } | |
802 | |
803 static void | |
804 msn_close(GaimConnection *gc) | |
805 { | |
806 MsnSession *session; | |
807 | |
808 session = gc->proto_data; | |
809 | |
810 g_return_if_fail(session != NULL); | |
811 | |
812 msn_session_destroy(session); | |
813 | |
814 gc->proto_data = NULL; | |
815 } | |
816 | |
817 static int | |
818 msn_send_im(GaimConnection *gc, const char *who, const char *message, | |
819 GaimMessageFlags flags) | |
820 { | |
821 GaimAccount *account; | |
822 MsnMessage *msg; | |
823 char *msgformat; | |
824 char *msgtext; | |
825 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
826 gaim_debug_info("MaYuan","send IM {%s} to %s\n",message,who); |
14192 | 827 account = gaim_connection_get_account(gc); |
828 | |
829 msn_import_html(message, &msgformat, &msgtext); | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
830 if(msn_user_is_online(account, who)|| |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
831 msn_user_is_yahoo(account, who)){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
832 /*User online,then send Online Instant Message*/ |
14192 | 833 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
834 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
835 { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
836 g_free(msgformat); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
837 g_free(msgtext); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
838 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
839 return -E2BIG; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
840 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
841 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
842 msg = msn_message_new_plain(msgtext); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
843 msg->remote_user = g_strdup(who); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
844 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
845 |
14192 | 846 g_free(msgformat); |
847 g_free(msgtext); | |
848 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
849 gaim_debug_info("MaYuan","prepare to send online Message\n"); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
850 if (g_ascii_strcasecmp(who, gaim_account_get_username(account))) |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
851 { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
852 MsnSession *session; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
853 MsnSwitchBoard *swboard; |
14192 | 854 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
855 session = gc->proto_data; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
856 if(msn_user_is_yahoo(account,who)){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
857 /*we send the online and offline Message to Yahoo User via UBM*/ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
858 gaim_debug_info("MaYuan","send to Yahoo User\n"); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
859 uum_send_msg(session,msg); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
860 }else{ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
861 gaim_debug_info("MaYuan","send via switchboard\n"); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
862 swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
863 msn_switchboard_send_msg(swboard, msg, TRUE); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
864 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
865 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
866 else |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
867 { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
868 char *body_str, *body_enc, *pre, *post; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
869 const char *format; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
870 /* |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
871 * In MSN, you can't send messages to yourself, so |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
872 * we'll fake like we received it ;) |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
873 */ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
874 body_str = msn_message_to_string(msg); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
875 body_enc = g_markup_escape_text(body_str, -1); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
876 g_free(body_str); |
14192 | 877 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
878 format = msn_message_get_attr(msg, "X-MMS-IM-Format"); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
879 msn_parse_format(format, &pre, &post); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
880 body_str = g_strdup_printf("%s%s%s", pre ? pre : "", |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
881 body_enc ? body_enc : "", post ? post : ""); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
882 g_free(body_enc); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
883 g_free(pre); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
884 g_free(post); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
885 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
886 serv_got_typing_stopped(gc, who); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
887 serv_got_im(gc, who, body_str, flags, time(NULL)); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
888 g_free(body_str); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
889 } |
14192 | 890 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
891 msn_message_destroy(msg); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
892 }else { |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
893 /*send Offline Instant Message,only to MSN Passport User*/ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
894 MsnSession *session; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
895 MsnOim *oim; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
896 char *friendname; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
897 |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
898 gaim_debug_info("MaYuan","prepare to send offline Message\n"); |
14192 | 899 session = gc->proto_data; |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
900 /* XXX/khc: hack */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
901 if (!session->oim) |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
902 session->oim = msn_oim_new(session); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
903 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
904 oim = session->oim; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
905 friendname = msn_encode_mime(account->username); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
906 msn_oim_prep_send_msg_info(oim, |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
907 gaim_account_get_username(account),friendname,who, |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
908 message); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
909 msn_oim_send_msg(oim); |
14192 | 910 } |
911 return 1; | |
912 } | |
913 | |
914 static unsigned int | |
915 msn_send_typing(GaimConnection *gc, const char *who, GaimTypingState state) | |
916 { | |
917 GaimAccount *account; | |
918 MsnSession *session; | |
919 MsnSwitchBoard *swboard; | |
920 MsnMessage *msg; | |
921 | |
922 account = gaim_connection_get_account(gc); | |
923 session = gc->proto_data; | |
924 | |
925 /* | |
926 * TODO: I feel like this should be "if (state != GAIM_TYPING)" | |
927 * but this is how it was before, and I don't want to break | |
928 * anything. --KingAnt | |
929 */ | |
930 if (state == GAIM_NOT_TYPING) | |
931 return 0; | |
932 | |
933 if (!g_ascii_strcasecmp(who, gaim_account_get_username(account))) | |
934 { | |
935 /* We'll just fake it, since we're sending to ourself. */ | |
936 serv_got_typing(gc, who, MSN_TYPING_RECV_TIMEOUT, GAIM_TYPING); | |
937 | |
938 return MSN_TYPING_SEND_TIMEOUT; | |
939 } | |
940 | |
941 swboard = msn_session_find_swboard(session, who); | |
942 | |
943 if (swboard == NULL || !msn_switchboard_can_send(swboard)) | |
944 return 0; | |
945 | |
946 swboard->flag |= MSN_SB_FLAG_IM; | |
947 | |
948 msg = msn_message_new(MSN_MSG_TYPING); | |
949 msn_message_set_content_type(msg, "text/x-msmsgscontrol"); | |
950 msn_message_set_flag(msg, 'U'); | |
951 msn_message_set_attr(msg, "TypingUser", | |
952 gaim_account_get_username(account)); | |
953 msn_message_set_bin_data(msg, "\r\n", 2); | |
954 | |
955 msn_switchboard_send_msg(swboard, msg, FALSE); | |
956 | |
957 msn_message_destroy(msg); | |
958 | |
959 return MSN_TYPING_SEND_TIMEOUT; | |
960 } | |
961 | |
962 static void | |
963 msn_set_status(GaimAccount *account, GaimStatus *status) | |
964 { | |
965 GaimConnection *gc; | |
966 MsnSession *session; | |
967 | |
968 gc = gaim_account_get_connection(account); | |
969 | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
970 if (gc != NULL){ |
14192 | 971 session = gc->proto_data; |
972 msn_change_status(session); | |
973 } | |
974 } | |
975 | |
976 static void | |
977 msn_set_idle(GaimConnection *gc, int idle) | |
978 { | |
979 MsnSession *session; | |
980 | |
981 session = gc->proto_data; | |
982 | |
983 msn_change_status(session); | |
984 } | |
985 | |
986 #if 0 | |
987 static void | |
988 fake_userlist_add_buddy(MsnUserList *userlist, | |
989 const char *who, int list_id, | |
990 const char *group_name) | |
991 { | |
992 MsnUser *user; | |
993 static int group_id_c = 1; | |
994 int group_id; | |
995 | |
996 group_id = -1; | |
997 | |
998 if (group_name != NULL) | |
999 { | |
1000 MsnGroup *group; | |
1001 group = msn_group_new(userlist, group_id_c, group_name); | |
1002 group_id = group_id_c++; | |
1003 } | |
1004 | |
1005 user = msn_userlist_find_user(userlist, who); | |
1006 | |
1007 if (user == NULL) | |
1008 { | |
1009 user = msn_user_new(userlist, who, NULL); | |
1010 msn_userlist_add_user(userlist, user); | |
1011 } | |
1012 else | |
1013 if (user->list_op & (1 << list_id)) | |
1014 { | |
1015 if (list_id == MSN_LIST_FL) | |
1016 { | |
1017 if (group_id >= 0) | |
1018 if (g_list_find(user->group_ids, | |
1019 GINT_TO_POINTER(group_id))) | |
1020 return; | |
1021 } | |
1022 else | |
1023 return; | |
1024 } | |
1025 | |
1026 if (group_id >= 0) | |
1027 { | |
1028 user->group_ids = g_list_append(user->group_ids, | |
1029 GINT_TO_POINTER(group_id)); | |
1030 } | |
1031 | |
1032 user->list_op |= (1 << list_id); | |
1033 } | |
1034 #endif | |
1035 | |
1036 static void | |
1037 msn_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | |
1038 { | |
1039 MsnSession *session; | |
1040 MsnUserList *userlist; | |
1041 const char *who; | |
1042 | |
1043 session = gc->proto_data; | |
1044 userlist = session->userlist; | |
1045 who = msn_normalize(gc->account, buddy->name); | |
1046 | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1047 gaim_debug_info("MaYuan","add user:{%s} to group:{%s}\n",who,group->name); |
14192 | 1048 if (!session->logged_in) |
1049 { | |
1050 #if 0 | |
1051 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, | |
1052 group ? group->name : NULL); | |
1053 #else | |
1054 gaim_debug_error("msn", "msn_add_buddy called before connected\n"); | |
1055 #endif | |
1056 | |
1057 return; | |
1058 } | |
1059 | |
1060 #if 0 | |
1061 if (group != NULL && group->name != NULL) | |
1062 gaim_debug_info("msn", "msn_add_buddy: %s, %s\n", who, group->name); | |
1063 else | |
1064 gaim_debug_info("msn", "msn_add_buddy: %s\n", who); | |
1065 #endif | |
1066 | |
1067 #if 0 | |
1068 /* Which is the max? */ | |
1069 if (session->fl_users_count >= 150) | |
1070 { | |
1071 gaim_debug_info("msn", "Too many buddies\n"); | |
1072 /* Buddy list full */ | |
1073 /* TODO: gaim should be notified of this */ | |
1074 return; | |
1075 } | |
1076 #endif | |
1077 | |
1078 /* XXX - Would group ever be NULL here? I don't think so... | |
1079 * shx: Yes it should; MSN handles non-grouped buddies, and this is only | |
1080 * internal. */ | |
1081 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, | |
1082 group ? group->name : NULL); | |
1083 } | |
1084 | |
1085 static void | |
1086 msn_rem_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | |
1087 { | |
1088 MsnSession *session; | |
1089 MsnUserList *userlist; | |
1090 | |
1091 session = gc->proto_data; | |
1092 userlist = session->userlist; | |
1093 | |
1094 if (!session->logged_in) | |
1095 return; | |
1096 | |
1097 /* XXX - Does buddy->name need to be msn_normalize'd here? --KingAnt */ | |
1098 msn_userlist_rem_buddy(userlist, buddy->name, MSN_LIST_FL, group->name); | |
1099 } | |
1100 | |
1101 static void | |
1102 msn_add_permit(GaimConnection *gc, const char *who) | |
1103 { | |
1104 MsnSession *session; | |
1105 MsnUserList *userlist; | |
1106 MsnUser *user; | |
1107 | |
1108 session = gc->proto_data; | |
1109 userlist = session->userlist; | |
1110 user = msn_userlist_find_user(userlist, who); | |
1111 | |
1112 if (!session->logged_in) | |
1113 return; | |
1114 | |
1115 if (user != NULL && user->list_op & MSN_LIST_BL_OP) | |
1116 msn_userlist_rem_buddy(userlist, who, MSN_LIST_BL, NULL); | |
1117 | |
1118 msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL); | |
1119 } | |
1120 | |
1121 static void | |
1122 msn_add_deny(GaimConnection *gc, const char *who) | |
1123 { | |
1124 MsnSession *session; | |
1125 MsnUserList *userlist; | |
1126 MsnUser *user; | |
1127 | |
1128 session = gc->proto_data; | |
1129 userlist = session->userlist; | |
1130 user = msn_userlist_find_user(userlist, who); | |
1131 | |
1132 if (!session->logged_in) | |
1133 return; | |
1134 | |
1135 if (user != NULL && user->list_op & MSN_LIST_AL_OP) | |
1136 msn_userlist_rem_buddy(userlist, who, MSN_LIST_AL, NULL); | |
1137 | |
1138 msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL); | |
1139 } | |
1140 | |
1141 static void | |
1142 msn_rem_permit(GaimConnection *gc, const char *who) | |
1143 { | |
1144 MsnSession *session; | |
1145 MsnUserList *userlist; | |
1146 MsnUser *user; | |
1147 | |
1148 session = gc->proto_data; | |
1149 userlist = session->userlist; | |
1150 | |
1151 if (!session->logged_in) | |
1152 return; | |
1153 | |
1154 user = msn_userlist_find_user(userlist, who); | |
1155 | |
1156 msn_userlist_rem_buddy(userlist, who, MSN_LIST_AL, NULL); | |
1157 | |
1158 if (user != NULL && user->list_op & MSN_LIST_RL_OP) | |
1159 msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL); | |
1160 } | |
1161 | |
1162 static void | |
1163 msn_rem_deny(GaimConnection *gc, const char *who) | |
1164 { | |
1165 MsnSession *session; | |
1166 MsnUserList *userlist; | |
1167 MsnUser *user; | |
1168 | |
1169 session = gc->proto_data; | |
1170 userlist = session->userlist; | |
1171 | |
1172 if (!session->logged_in) | |
1173 return; | |
1174 | |
1175 user = msn_userlist_find_user(userlist, who); | |
1176 | |
1177 msn_userlist_rem_buddy(userlist, who, MSN_LIST_BL, NULL); | |
1178 | |
1179 if (user != NULL && user->list_op & MSN_LIST_RL_OP) | |
1180 msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL); | |
1181 } | |
1182 | |
1183 static void | |
1184 msn_set_permit_deny(GaimConnection *gc) | |
1185 { | |
1186 GaimAccount *account; | |
1187 MsnSession *session; | |
1188 MsnCmdProc *cmdproc; | |
1189 | |
1190 account = gaim_connection_get_account(gc); | |
1191 session = gc->proto_data; | |
1192 cmdproc = session->notification->cmdproc; | |
1193 | |
1194 if (account->perm_deny == GAIM_PRIVACY_ALLOW_ALL || | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1195 account->perm_deny == GAIM_PRIVACY_DENY_USERS){ |
14192 | 1196 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1197 }else{ |
14192 | 1198 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); |
1199 } | |
1200 } | |
1201 | |
1202 static void | |
1203 msn_chat_invite(GaimConnection *gc, int id, const char *msg, | |
1204 const char *who) | |
1205 { | |
1206 MsnSession *session; | |
1207 MsnSwitchBoard *swboard; | |
1208 | |
1209 session = gc->proto_data; | |
1210 | |
1211 swboard = msn_session_find_swboard_with_id(session, id); | |
1212 | |
1213 if (swboard == NULL) | |
1214 { | |
1215 /* if we have no switchboard, everyone else left the chat already */ | |
1216 swboard = msn_switchboard_new(session); | |
1217 msn_switchboard_request(swboard); | |
1218 swboard->chat_id = id; | |
1219 swboard->conv = gaim_find_chat(gc, id); | |
1220 } | |
1221 | |
1222 swboard->flag |= MSN_SB_FLAG_IM; | |
1223 | |
1224 msn_switchboard_request_add_user(swboard, who); | |
1225 } | |
1226 | |
1227 static void | |
1228 msn_chat_leave(GaimConnection *gc, int id) | |
1229 { | |
1230 MsnSession *session; | |
1231 MsnSwitchBoard *swboard; | |
1232 GaimConversation *conv; | |
1233 | |
1234 session = gc->proto_data; | |
1235 | |
1236 swboard = msn_session_find_swboard_with_id(session, id); | |
1237 | |
1238 /* if swboard is NULL we were the only person left anyway */ | |
1239 if (swboard == NULL) | |
1240 return; | |
1241 | |
1242 conv = swboard->conv; | |
1243 | |
1244 msn_switchboard_release(swboard, MSN_SB_FLAG_IM); | |
1245 | |
1246 /* If other switchboards managed to associate themselves with this | |
1247 * conv, make sure they know it's gone! */ | |
1248 if (conv != NULL) | |
1249 { | |
1250 while ((swboard = msn_session_find_swboard_with_conv(session, conv)) != NULL) | |
1251 swboard->conv = NULL; | |
1252 } | |
1253 } | |
1254 | |
1255 static int | |
1256 msn_chat_send(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) | |
1257 { | |
1258 GaimAccount *account; | |
1259 MsnSession *session; | |
1260 MsnSwitchBoard *swboard; | |
1261 MsnMessage *msg; | |
1262 char *msgformat; | |
1263 char *msgtext; | |
1264 | |
1265 account = gaim_connection_get_account(gc); | |
1266 session = gc->proto_data; | |
1267 swboard = msn_session_find_swboard_with_id(session, id); | |
1268 | |
1269 if (swboard == NULL) | |
1270 return -EINVAL; | |
1271 | |
1272 if (!swboard->ready) | |
1273 return 0; | |
1274 | |
1275 swboard->flag |= MSN_SB_FLAG_IM; | |
1276 | |
1277 msn_import_html(message, &msgformat, &msgtext); | |
1278 | |
1279 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) | |
1280 { | |
1281 g_free(msgformat); | |
1282 g_free(msgtext); | |
1283 | |
1284 return -E2BIG; | |
1285 } | |
1286 | |
1287 msg = msn_message_new_plain(msgtext); | |
1288 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); | |
1289 msn_switchboard_send_msg(swboard, msg, FALSE); | |
1290 msn_message_destroy(msg); | |
1291 | |
1292 g_free(msgformat); | |
1293 g_free(msgtext); | |
1294 | |
1295 serv_got_chat_in(gc, id, gaim_account_get_username(account), 0, | |
1296 message, time(NULL)); | |
1297 | |
1298 return 0; | |
1299 } | |
1300 | |
1301 static void | |
1302 msn_keepalive(GaimConnection *gc) | |
1303 { | |
1304 MsnSession *session; | |
1305 | |
1306 session = gc->proto_data; | |
1307 | |
1308 if (!session->http_method) | |
1309 { | |
1310 MsnCmdProc *cmdproc; | |
1311 | |
1312 cmdproc = session->notification->cmdproc; | |
1313 | |
1314 msn_cmdproc_send_quick(cmdproc, "PNG", NULL, NULL); | |
1315 } | |
1316 } | |
1317 | |
1318 static void | |
1319 msn_group_buddy(GaimConnection *gc, const char *who, | |
1320 const char *old_group_name, const char *new_group_name) | |
1321 { | |
1322 MsnSession *session; | |
1323 MsnUserList *userlist; | |
1324 | |
1325 session = gc->proto_data; | |
1326 userlist = session->userlist; | |
1327 | |
1328 msn_userlist_move_buddy(userlist, who, old_group_name, new_group_name); | |
1329 } | |
1330 | |
1331 static void | |
1332 msn_rename_group(GaimConnection *gc, const char *old_name, | |
1333 GaimGroup *group, GList *moved_buddies) | |
1334 { | |
1335 MsnSession *session; | |
1336 MsnCmdProc *cmdproc; | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1337 const char *old_gid; |
14192 | 1338 const char *enc_new_group_name; |
1339 | |
1340 session = gc->proto_data; | |
1341 cmdproc = session->notification->cmdproc; | |
1342 enc_new_group_name = gaim_url_encode(group->name); | |
1343 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1344 gaim_debug_info("MaYuan","rename group:old{%s},new{%s}",old_name,enc_new_group_name); |
14192 | 1345 old_gid = msn_userlist_find_group_id(session->userlist, old_name); |
1346 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1347 if (old_gid != NULL){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1348 /*find a Group*/ |
14192 | 1349 msn_cmdproc_send(cmdproc, "REG", "%d %s 0", old_gid, |
1350 enc_new_group_name); | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1351 }else{ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1352 /*not found*/ |
14192 | 1353 msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name); |
1354 } | |
1355 } | |
1356 | |
1357 static void | |
1358 msn_convo_closed(GaimConnection *gc, const char *who) | |
1359 { | |
1360 MsnSession *session; | |
1361 MsnSwitchBoard *swboard; | |
1362 GaimConversation *conv; | |
1363 | |
1364 session = gc->proto_data; | |
1365 | |
1366 swboard = msn_session_find_swboard(session, who); | |
1367 | |
1368 /* | |
1369 * Don't perform an assertion here. If swboard is NULL, then the | |
1370 * switchboard was either closed by the other party, or the person | |
1371 * is talking to himself. | |
1372 */ | |
1373 if (swboard == NULL) | |
1374 return; | |
1375 | |
1376 conv = swboard->conv; | |
1377 | |
1378 msn_switchboard_release(swboard, MSN_SB_FLAG_IM); | |
1379 | |
1380 /* If other switchboards managed to associate themselves with this | |
1381 * conv, make sure they know it's gone! */ | |
1382 if (conv != NULL) | |
1383 { | |
1384 while ((swboard = msn_session_find_swboard_with_conv(session, conv)) != NULL) | |
1385 swboard->conv = NULL; | |
1386 } | |
1387 } | |
1388 | |
1389 static void | |
1390 msn_set_buddy_icon(GaimConnection *gc, const char *filename) | |
1391 { | |
1392 MsnSession *session; | |
1393 MsnUser *user; | |
1394 | |
1395 session = gc->proto_data; | |
1396 user = session->user; | |
1397 | |
1398 msn_user_set_buddy_icon(user, filename); | |
1399 | |
1400 msn_change_status(session); | |
1401 } | |
1402 | |
1403 static void | |
1404 msn_remove_group(GaimConnection *gc, GaimGroup *group) | |
1405 { | |
1406 MsnSession *session; | |
1407 MsnCmdProc *cmdproc; | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1408 const char *group_id; |
14192 | 1409 |
1410 session = gc->proto_data; | |
1411 cmdproc = session->notification->cmdproc; | |
1412 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1413 /*we can't delete the default group*/ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1414 if(!strcmp(group->name,MSN_INDIVIDUALS_GROUP_NAME)|| |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1415 !strcmp(group->name,MSN_NON_IM_GROUP_NAME)){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1416 return ; |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1417 } |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1418 group_id = msn_userlist_find_group_id(session->userlist, group->name); |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1419 if (group_id != NULL){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1420 msn_del_group(session,group_id); |
14192 | 1421 } |
1422 } | |
1423 | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1424 /** |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1425 * Extract info text from info_data and add it to user_info |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1426 */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1427 static gboolean |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1428 msn_tooltip_extract_info_text(GaimNotifyUserInfo *user_info, MsnGetInfoData *info_data) |
14192 | 1429 { |
1430 GaimBuddy *b; | |
1431 | |
1432 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), | |
1433 info_data->name); | |
1434 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1435 if (b){ |
14192 | 1436 char *tmp; |
1437 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1438 if (b->alias && b->alias[0]){ |
14192 | 1439 char *aliastext = g_markup_escape_text(b->alias, -1); |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1440 gaim_notify_user_info_add_pair(user_info, _("Alias"), aliastext); |
14192 | 1441 g_free(aliastext); |
1442 } | |
1443 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1444 if (b->server_alias){ |
14192 | 1445 char *nicktext = g_markup_escape_text(b->server_alias, -1); |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1446 tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1447 gaim_notify_user_info_add_pair(user_info, _("Nickname"), tmp); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1448 g_free(tmp); |
14192 | 1449 g_free(nicktext); |
1450 } | |
1451 | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1452 /* Add the tooltip information */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1453 msn_tooltip_text(b, user_info, TRUE); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1454 |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1455 return TRUE; |
14192 | 1456 } |
1457 | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1458 return FALSE; |
14192 | 1459 } |
1460 | |
1461 #if PHOTO_SUPPORT | |
1462 | |
1463 static char * | |
1464 msn_get_photo_url(const char *url_text) | |
1465 { | |
1466 char *p, *q; | |
1467 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1468 if ((p = strstr(url_text, PHOTO_URL)) != NULL){ |
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1469 p += strlen(PHOTO_URL); |
14192 | 1470 } |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1471 if (p && (strncmp(p, "http://",strlen("http://")) == 0) && ((q = strchr(p, '"')) != NULL)) |
14192 | 1472 return g_strndup(p, q - p); |
1473 | |
1474 return NULL; | |
1475 } | |
1476 | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1477 static void msn_got_photo(GaimUtilFetchUrlData *url_data, gpointer data, |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1478 const gchar *url_text, size_t len, const gchar *error_message); |
14192 | 1479 |
1480 #endif | |
1481 | |
1482 #if 0 | |
1483 static char *msn_info_date_reformat(const char *field, size_t len) | |
1484 { | |
1485 char *tmp = g_strndup(field, len); | |
1486 time_t t = gaim_str_to_time(tmp, FALSE, NULL, NULL, NULL); | |
1487 | |
1488 g_free(tmp); | |
1489 return g_strdup(gaim_date_format_short(localtime(&t))); | |
1490 } | |
1491 #endif | |
1492 | |
1493 #define MSN_GOT_INFO_GET_FIELD(a, b) \ | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1494 found = gaim_markup_extract_info_field(stripped, stripped_len, user_info, \ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1495 "\n" a ":", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \ |
14192 | 1496 if (found) \ |
1497 sect_info = TRUE; | |
1498 | |
1499 static void | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1500 msn_got_info(GaimUtilFetchUrlData *url_data, gpointer data, |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1501 const gchar *url_text, size_t len, const gchar *error_message) |
14192 | 1502 { |
1503 MsnGetInfoData *info_data = (MsnGetInfoData *)data; | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1504 GaimNotifyUserInfo *user_info; |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1505 char *stripped, *p, *q, *tmp; |
14192 | 1506 char *user_url = NULL; |
1507 gboolean found; | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1508 gboolean has_tooltip_text = FALSE; |
14192 | 1509 gboolean has_info = FALSE; |
1510 gboolean sect_info = FALSE; | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1511 gboolean has_contact_info = FALSE; |
14192 | 1512 char *url_buffer; |
1513 GString *s, *s2; | |
1514 int stripped_len; | |
1515 #if PHOTO_SUPPORT | |
1516 char *photo_url_text = NULL; | |
1517 MsnGetInfoStepTwoData *info2_data = NULL; | |
1518 #endif | |
1519 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1520 gaim_debug_info("msn", "In msn_got_info,url_text:{%s}\n",url_text); |
14192 | 1521 |
1522 /* Make sure the connection is still valid */ | |
1523 if (g_list_find(gaim_connections_get_all(), info_data->gc) == NULL) | |
1524 { | |
1525 gaim_debug_warning("msn", "invalid connection. ignoring buddy info.\n"); | |
1526 g_free(info_data->name); | |
1527 g_free(info_data); | |
1528 return; | |
1529 } | |
1530 | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1531 user_info = gaim_notify_user_info_new(); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1532 has_tooltip_text = msn_tooltip_extract_info_text(user_info, info_data); |
14192 | 1533 |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1534 if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0) |
14192 | 1535 { |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1536 tmp = g_strdup_printf("<b>%s</b>", _("Error retrieving profile")); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1537 gaim_notify_user_info_add_pair(user_info, NULL, tmp); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1538 g_free(tmp); |
14192 | 1539 |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1540 gaim_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1541 gaim_notify_user_info_destroy(user_info); |
14192 | 1542 |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1543 g_free(info_data->name); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1544 g_free(info_data); |
14192 | 1545 return; |
1546 } | |
1547 | |
1548 url_buffer = g_strdup(url_text); | |
1549 | |
1550 /* If they have a homepage link, MSN masks it such that we need to | |
1551 * fetch the url out before gaim_markup_strip_html() nukes it */ | |
1552 /* I don't think this works with the new spaces profiles - Stu 3/2/06 */ | |
1553 if ((p = strstr(url_text, | |
1554 "Take a look at my </font><A class=viewDesc title=\"")) != NULL) | |
1555 { | |
1556 p += 50; | |
1557 | |
1558 if ((q = strchr(p, '"')) != NULL) | |
1559 user_url = g_strndup(p, q - p); | |
1560 } | |
1561 | |
1562 /* | |
1563 * gaim_markup_strip_html() doesn't strip out character entities like | |
1564 * and · | |
1565 */ | |
1566 while ((p = strstr(url_buffer, " ")) != NULL) | |
1567 { | |
1568 *p = ' '; /* Turn 's into ordinary blanks */ | |
1569 p += 1; | |
1570 memmove(p, p + 5, strlen(p + 5)); | |
1571 url_buffer[strlen(url_buffer) - 5] = '\0'; | |
1572 } | |
1573 | |
1574 while ((p = strstr(url_buffer, "·")) != NULL) | |
1575 { | |
1576 memmove(p, p + 6, strlen(p + 6)); | |
1577 url_buffer[strlen(url_buffer) - 6] = '\0'; | |
1578 } | |
1579 | |
1580 /* Nuke the nasty \r's that just get in the way */ | |
1581 gaim_str_strip_char(url_buffer, '\r'); | |
1582 | |
1583 /* MSN always puts in ' for apostrophes...replace them */ | |
1584 while ((p = strstr(url_buffer, "'")) != NULL) | |
1585 { | |
1586 *p = '\''; | |
1587 memmove(p + 1, p + 5, strlen(p + 5)); | |
1588 url_buffer[strlen(url_buffer) - 4] = '\0'; | |
1589 } | |
1590 | |
1591 /* Nuke the html, it's easier than trying to parse the horrid stuff */ | |
1592 stripped = gaim_markup_strip_html(url_buffer); | |
1593 stripped_len = strlen(stripped); | |
1594 | |
1595 gaim_debug_misc("msn", "stripped = %p\n", stripped); | |
1596 gaim_debug_misc("msn", "url_buffer = %p\n", url_buffer); | |
1597 | |
1598 /* Gonna re-use the memory we've already got for url_buffer */ | |
1599 /* No we're not. */ | |
1600 s = g_string_sized_new(strlen(url_buffer)); | |
1601 s2 = g_string_sized_new(strlen(url_buffer)); | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1602 |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1603 /* General section header */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1604 if (has_tooltip_text) |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1605 gaim_notify_user_info_add_section_break(user_info); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1606 |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1607 gaim_notify_user_info_add_section_header(user_info, _("General")); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1608 |
14192 | 1609 /* Extract their Name and put it in */ |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1610 MSN_GOT_INFO_GET_FIELD("Name", _("Name")); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1611 |
14192 | 1612 /* General */ |
1613 MSN_GOT_INFO_GET_FIELD("Nickname", _("Nickname")); | |
1614 MSN_GOT_INFO_GET_FIELD("Age", _("Age")); | |
1615 MSN_GOT_INFO_GET_FIELD("Gender", _("Gender")); | |
1616 MSN_GOT_INFO_GET_FIELD("Occupation", _("Occupation")); | |
1617 MSN_GOT_INFO_GET_FIELD("Location", _("Location")); | |
1618 | |
1619 /* Extract their Interests and put it in */ | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1620 found = gaim_markup_extract_info_field(stripped, stripped_len, user_info, |
14192 | 1621 "\nInterests\t", 0, " (/default.aspx?page=searchresults", 0, |
1622 "Undisclosed", _("Hobbies and Interests") /* _("Interests") */, | |
1623 0, NULL, NULL); | |
1624 | |
1625 if (found) | |
1626 sect_info = TRUE; | |
1627 | |
1628 MSN_GOT_INFO_GET_FIELD("More about me", _("A Little About Me")); | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1629 |
14192 | 1630 if (sect_info) |
1631 { | |
1632 has_info = TRUE; | |
1633 sect_info = FALSE; | |
1634 } | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1635 else |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1636 { |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1637 /* Remove the section header */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1638 gaim_notify_user_info_remove_last_item(user_info); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1639 if (has_tooltip_text) |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1640 gaim_notify_user_info_remove_last_item(user_info); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1641 } |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1642 |
14192 | 1643 /* Social */ |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1644 gaim_notify_user_info_add_section_break(user_info); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1645 gaim_notify_user_info_add_section_header(user_info, _("Social")); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1646 |
14192 | 1647 MSN_GOT_INFO_GET_FIELD("Marital status", _("Marital Status")); |
1648 MSN_GOT_INFO_GET_FIELD("Interested in", _("Interests")); | |
1649 MSN_GOT_INFO_GET_FIELD("Pets", _("Pets")); | |
1650 MSN_GOT_INFO_GET_FIELD("Hometown", _("Hometown")); | |
1651 MSN_GOT_INFO_GET_FIELD("Places lived", _("Places Lived")); | |
1652 MSN_GOT_INFO_GET_FIELD("Fashion", _("Fashion")); | |
1653 MSN_GOT_INFO_GET_FIELD("Humor", _("Humor")); | |
1654 MSN_GOT_INFO_GET_FIELD("Music", _("Music")); | |
1655 MSN_GOT_INFO_GET_FIELD("Favorite quote", _("Favorite Quote")); | |
1656 | |
1657 if (sect_info) | |
1658 { | |
1659 has_info = TRUE; | |
1660 sect_info = FALSE; | |
1661 } | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1662 else |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1663 { |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1664 /* Remove the section header */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1665 gaim_notify_user_info_remove_last_item(user_info); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1666 gaim_notify_user_info_remove_last_item(user_info); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1667 } |
14192 | 1668 |
1669 /* Contact Info */ | |
1670 /* Personal */ | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1671 gaim_notify_user_info_add_section_break(user_info); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1672 gaim_notify_user_info_add_section_header(user_info, _("Contact Info")); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1673 gaim_notify_user_info_add_section_header(user_info, _("Personal")); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1674 |
14192 | 1675 MSN_GOT_INFO_GET_FIELD("Name", _("Name")); |
1676 MSN_GOT_INFO_GET_FIELD("Significant other", _("Significant Other")); | |
1677 MSN_GOT_INFO_GET_FIELD("Home phone", _("Home Phone")); | |
1678 MSN_GOT_INFO_GET_FIELD("Home phone 2", _("Home Phone 2")); | |
1679 MSN_GOT_INFO_GET_FIELD("Home address", _("Home Address")); | |
1680 MSN_GOT_INFO_GET_FIELD("Personal Mobile", _("Personal Mobile")); | |
1681 MSN_GOT_INFO_GET_FIELD("Home fax", _("Home Fax")); | |
1682 MSN_GOT_INFO_GET_FIELD("Personal e-mail", _("Personal E-Mail")); | |
1683 MSN_GOT_INFO_GET_FIELD("Personal IM", _("Personal IM")); | |
1684 MSN_GOT_INFO_GET_FIELD("Birthday", _("Birthday")); | |
1685 MSN_GOT_INFO_GET_FIELD("Anniversary", _("Anniversary")); | |
1686 MSN_GOT_INFO_GET_FIELD("Notes", _("Notes")); | |
1687 | |
1688 if (sect_info) | |
1689 { | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1690 has_info = TRUE; |
14192 | 1691 sect_info = FALSE; |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1692 has_contact_info = TRUE; |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1693 } |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1694 else |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1695 { |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1696 /* Remove the section header */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1697 gaim_notify_user_info_remove_last_item(user_info); |
14192 | 1698 } |
1699 | |
1700 /* Business */ | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1701 gaim_notify_user_info_add_section_header(user_info, _("Work")); |
14192 | 1702 MSN_GOT_INFO_GET_FIELD("Name", _("Name")); |
1703 MSN_GOT_INFO_GET_FIELD("Job title", _("Job Title")); | |
1704 MSN_GOT_INFO_GET_FIELD("Company", _("Company")); | |
1705 MSN_GOT_INFO_GET_FIELD("Department", _("Department")); | |
1706 MSN_GOT_INFO_GET_FIELD("Profession", _("Profession")); | |
1707 MSN_GOT_INFO_GET_FIELD("Work phone 1", _("Work Phone")); | |
1708 MSN_GOT_INFO_GET_FIELD("Work phone 2", _("Work Phone 2")); | |
1709 MSN_GOT_INFO_GET_FIELD("Work address", _("Work Address")); | |
1710 MSN_GOT_INFO_GET_FIELD("Work mobile", _("Work Mobile")); | |
1711 MSN_GOT_INFO_GET_FIELD("Work pager", _("Work Pager")); | |
1712 MSN_GOT_INFO_GET_FIELD("Work fax", _("Work Fax")); | |
1713 MSN_GOT_INFO_GET_FIELD("Work e-mail", _("Work E-Mail")); | |
1714 MSN_GOT_INFO_GET_FIELD("Work IM", _("Work IM")); | |
1715 MSN_GOT_INFO_GET_FIELD("Start date", _("Start Date")); | |
1716 MSN_GOT_INFO_GET_FIELD("Notes", _("Notes")); | |
1717 | |
1718 if (sect_info) | |
1719 { | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1720 has_info = TRUE; |
14192 | 1721 sect_info = FALSE; |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1722 has_contact_info = TRUE; |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1723 } |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1724 else |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1725 { |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1726 /* Remove the section header */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1727 gaim_notify_user_info_remove_last_item(user_info); |
14192 | 1728 } |
1729 | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1730 if (!has_contact_info) |
14192 | 1731 { |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1732 /* Remove the Contact Info section header */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1733 gaim_notify_user_info_remove_last_item(user_info); |
14192 | 1734 } |
1735 | |
1736 #if 0 /* these probably don't show up any more */ | |
1737 /* | |
1738 * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies | |
1739 * and Interests', 'Favorite Quote', and 'My Homepage' may or may | |
1740 * not appear, in any combination. However, they do appear in | |
1741 * certain order, so we can successively search to pin down the | |
1742 * distinct values. | |
1743 */ | |
1744 | |
1745 /* Check if they have A Little About Me */ | |
1746 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1747 " A Little About Me \n\n", 0, "Favorite Things", '\n', NULL, | |
1748 _("A Little About Me"), 0, NULL, NULL); | |
1749 | |
1750 if (!found) | |
1751 { | |
1752 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1753 " A Little About Me \n\n", 0, "Hobbies and Interests", '\n', | |
1754 NULL, _("A Little About Me"), 0, NULL, NULL); | |
1755 } | |
1756 | |
1757 if (!found) | |
1758 { | |
1759 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1760 " A Little About Me \n\n", 0, "Favorite Quote", '\n', NULL, | |
1761 _("A Little About Me"), 0, NULL, NULL); | |
1762 } | |
1763 | |
1764 if (!found) | |
1765 { | |
1766 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1767 " A Little About Me \n\n", 0, "My Homepage \n\nTake a look", | |
1768 '\n', | |
1769 NULL, _("A Little About Me"), 0, NULL, NULL); | |
1770 } | |
1771 | |
1772 if (!found) | |
1773 { | |
1774 gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1775 " A Little About Me \n\n", 0, "last updated", '\n', NULL, | |
1776 _("A Little About Me"), 0, NULL, NULL); | |
1777 } | |
1778 | |
1779 if (found) | |
1780 has_info = TRUE; | |
1781 | |
1782 /* Check if they have Favorite Things */ | |
1783 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1784 " Favorite Things \n\n", 0, "Hobbies and Interests", '\n', NULL, | |
1785 _("Favorite Things"), 0, NULL, NULL); | |
1786 | |
1787 if (!found) | |
1788 { | |
1789 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1790 " Favorite Things \n\n", 0, "Favorite Quote", '\n', NULL, | |
1791 _("Favorite Things"), 0, NULL, NULL); | |
1792 } | |
1793 | |
1794 if (!found) | |
1795 { | |
1796 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1797 " Favorite Things \n\n", 0, "My Homepage \n\nTake a look", '\n', | |
1798 NULL, _("Favorite Things"), 0, NULL, NULL); | |
1799 } | |
1800 | |
1801 if (!found) | |
1802 { | |
1803 gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1804 " Favorite Things \n\n", 0, "last updated", '\n', NULL, | |
1805 _("Favorite Things"), 0, NULL, NULL); | |
1806 } | |
1807 | |
1808 if (found) | |
1809 has_info = TRUE; | |
1810 | |
1811 /* Check if they have Hobbies and Interests */ | |
1812 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1813 " Hobbies and Interests \n\n", 0, "Favorite Quote", '\n', NULL, | |
1814 _("Hobbies and Interests"), 0, NULL, NULL); | |
1815 | |
1816 if (!found) | |
1817 { | |
1818 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1819 " Hobbies and Interests \n\n", 0, "My Homepage \n\nTake a look", | |
1820 '\n', NULL, _("Hobbies and Interests"), 0, NULL, NULL); | |
1821 } | |
1822 | |
1823 if (!found) | |
1824 { | |
1825 gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1826 " Hobbies and Interests \n\n", 0, "last updated", '\n', NULL, | |
1827 _("Hobbies and Interests"), 0, NULL, NULL); | |
1828 } | |
1829 | |
1830 if (found) | |
1831 has_info = TRUE; | |
1832 | |
1833 /* Check if they have Favorite Quote */ | |
1834 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1835 "Favorite Quote \n\n", 0, "My Homepage \n\nTake a look", '\n', NULL, | |
1836 _("Favorite Quote"), 0, NULL, NULL); | |
1837 | |
1838 if (!found) | |
1839 { | |
1840 gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1841 "Favorite Quote \n\n", 0, "last updated", '\n', NULL, | |
1842 _("Favorite Quote"), 0, NULL, NULL); | |
1843 } | |
1844 | |
1845 if (found) | |
1846 has_info = TRUE; | |
1847 | |
1848 /* Extract the last updated date and put it in */ | |
1849 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1850 " last updated:", 1, "\n", 0, NULL, _("Last Updated"), 0, | |
1851 NULL, msn_info_date_reformat); | |
1852 | |
1853 if (found) | |
1854 has_info = TRUE; | |
1855 #endif | |
1856 | |
1857 /* If we were able to fetch a homepage url earlier, stick it in there */ | |
1858 if (user_url != NULL) | |
1859 { | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1860 tmp = g_strdup_printf("<a href=\"%s\">%s</a>", user_url, user_url); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1861 gaim_notify_user_info_add_pair(user_info, _("Homepage"), tmp); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1862 g_free(tmp); |
14192 | 1863 g_free(user_url); |
1864 | |
1865 has_info = TRUE; | |
1866 } | |
1867 | |
1868 if (!has_info) | |
1869 { | |
1870 /* MSN doesn't actually distinguish between "unknown member" and | |
1871 * a known member with an empty profile. Try to explain this fact. | |
1872 * Note that if we have a nonempty tooltip_text, we know the user | |
1873 * exists. | |
1874 */ | |
1875 /* This doesn't work with the new spaces profiles - Stu 3/2/06 | |
1876 char *p = strstr(url_buffer, "Unknown Member </TITLE>"); | |
1877 * This might not work for long either ... */ | |
1878 char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\""); | |
1879 GaimBuddy *b = gaim_find_buddy | |
1880 (gaim_connection_get_account(info_data->gc), info_data->name); | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1881 gaim_notify_user_info_add_pair(user_info, _("Error retrieving profile"), |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1882 ((p && b) ? _("The user has not created a public profile.") : |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1883 (p ? _("MSN reported not being able to find the user's profile. " |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1884 "This either means that the user does not exist, " |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1885 "or that the user exists " |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1886 "but has not created a public profile.") : |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1887 _("Gaim could not find " /* This should never happen */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1888 "any information in the user's profile. " |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1889 "The user most likely does not exist.")))); |
14192 | 1890 } |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1891 |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1892 /* put a link to the actual profile URL */ |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1893 tmp = g_strdup_printf("<a href=\"%s%s\">%s%s</a>", |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1894 PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1895 gaim_notify_user_info_add_pair(user_info, _("Profile URL"), tmp); |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1896 g_free(tmp); |
14192 | 1897 |
1898 #if PHOTO_SUPPORT | |
1899 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ | |
1900 photo_url_text = msn_get_photo_url(url_text); | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
1901 gaim_debug_info("Ma Yuan","photo url:{%s}\n",photo_url_text); |
14192 | 1902 |
1903 /* Marshall the existing state */ | |
1904 info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData)); | |
1905 info2_data->info_data = info_data; | |
1906 info2_data->stripped = stripped; | |
1907 info2_data->url_buffer = url_buffer; | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1908 info2_data->user_info = user_info; |
14192 | 1909 info2_data->photo_url_text = photo_url_text; |
1910 | |
1911 /* Try to put the photo in there too, if there's one */ | |
1912 if (photo_url_text) | |
1913 { | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1914 gaim_util_fetch_url(photo_url_text, FALSE, NULL, FALSE, msn_got_photo, |
14192 | 1915 info2_data); |
1916 } | |
1917 else | |
1918 { | |
1919 /* Emulate a callback */ | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1920 /* TODO: Huh? */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1921 msn_got_photo(NULL, info2_data, NULL, 0, NULL); |
14192 | 1922 } |
1923 } | |
1924 | |
1925 static void | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1926 msn_got_photo(GaimUtilFetchUrlData *url_data, gpointer user_data, |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1927 const gchar *url_text, size_t len, const gchar *error_message) |
14192 | 1928 { |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1929 MsnGetInfoStepTwoData *info2_data = (MsnGetInfoStepTwoData *)user_data; |
14192 | 1930 int id = -1; |
1931 | |
1932 /* Unmarshall the saved state */ | |
1933 MsnGetInfoData *info_data = info2_data->info_data; | |
1934 char *stripped = info2_data->stripped; | |
1935 char *url_buffer = info2_data->url_buffer; | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1936 GaimNotifyUserInfo *user_info = info2_data->user_info; |
14192 | 1937 char *photo_url_text = info2_data->photo_url_text; |
1938 | |
1939 /* Make sure the connection is still valid if we got here by fetching a photo url */ | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1940 if (url_text && (error_message != NULL || |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1941 g_list_find(gaim_connections_get_all(), info_data->gc) == NULL)) |
14192 | 1942 { |
1943 gaim_debug_warning("msn", "invalid connection. ignoring buddy photo info.\n"); | |
1944 g_free(stripped); | |
1945 g_free(url_buffer); | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1946 g_free(user_info); |
14192 | 1947 g_free(info_data->name); |
1948 g_free(info_data); | |
1949 g_free(photo_url_text); | |
1950 g_free(info2_data); | |
1951 | |
1952 return; | |
1953 } | |
1954 | |
1955 /* Try to put the photo in there too, if there's one and is readable */ | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1956 if (user_data && url_text && len != 0) |
14192 | 1957 { |
1958 if (strstr(url_text, "400 Bad Request") | |
1959 || strstr(url_text, "403 Forbidden") | |
1960 || strstr(url_text, "404 Not Found")) | |
1961 { | |
1962 | |
1963 gaim_debug_info("msn", "Error getting %s: %s\n", | |
1964 photo_url_text, url_text); | |
1965 } | |
1966 else | |
1967 { | |
1968 char buf[1024]; | |
1969 gaim_debug_info("msn", "%s is %d bytes\n", photo_url_text, len); | |
1970 id = gaim_imgstore_add(url_text, len, NULL); | |
1971 g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id); | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1972 gaim_notify_user_info_prepend_pair(user_info, NULL, buf); |
14192 | 1973 } |
1974 } | |
1975 | |
1976 /* We continue here from msn_got_info, as if nothing has happened */ | |
1977 #endif | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1978 gaim_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); |
14192 | 1979 |
1980 g_free(stripped); | |
1981 g_free(url_buffer); | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
1982 gaim_notify_user_info_destroy(user_info); |
14192 | 1983 g_free(info_data->name); |
1984 g_free(info_data); | |
1985 #if PHOTO_SUPPORT | |
1986 g_free(photo_url_text); | |
1987 g_free(info2_data); | |
1988 if (id != -1) | |
1989 gaim_imgstore_unref(id); | |
1990 #endif | |
1991 } | |
1992 | |
1993 static void | |
1994 msn_get_info(GaimConnection *gc, const char *name) | |
1995 { | |
1996 MsnGetInfoData *data; | |
1997 char *url; | |
1998 | |
1999 data = g_new0(MsnGetInfoData, 1); | |
2000 data->gc = gc; | |
2001 data->name = g_strdup(name); | |
2002 | |
2003 url = g_strdup_printf("%s%s", PROFILE_URL, name); | |
2004 | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
2005 gaim_util_fetch_url(url, FALSE, |
14192 | 2006 "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", |
2007 TRUE, msn_got_info, data); | |
2008 | |
2009 g_free(url); | |
2010 } | |
2011 | |
2012 static gboolean msn_load(GaimPlugin *plugin) | |
2013 { | |
2014 msn_notification_init(); | |
2015 msn_switchboard_init(); | |
2016 msn_sync_init(); | |
2017 | |
2018 return TRUE; | |
2019 } | |
2020 | |
2021 static gboolean msn_unload(GaimPlugin *plugin) | |
2022 { | |
2023 msn_notification_end(); | |
2024 msn_switchboard_end(); | |
2025 msn_sync_end(); | |
2026 | |
2027 return TRUE; | |
2028 } | |
2029 | |
2030 static GaimPluginProtocolInfo prpl_info = | |
2031 { | |
2032 OPT_PROTO_MAIL_CHECK, | |
2033 NULL, /* user_splits */ | |
2034 NULL, /* protocol_options */ | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
2035 {"png", 0, 0, 96, 96, 0, GAIM_ICON_SCALE_SEND}, /* icon_spec */ |
14192 | 2036 msn_list_icon, /* list_icon */ |
2037 msn_list_emblems, /* list_emblems */ | |
2038 msn_status_text, /* status_text */ | |
2039 msn_tooltip_text, /* tooltip_text */ | |
2040 msn_status_types, /* away_states */ | |
2041 msn_blist_node_menu, /* blist_node_menu */ | |
2042 NULL, /* chat_info */ | |
2043 NULL, /* chat_info_defaults */ | |
2044 msn_login, /* login */ | |
2045 msn_close, /* close */ | |
2046 msn_send_im, /* send_im */ | |
2047 NULL, /* set_info */ | |
2048 msn_send_typing, /* send_typing */ | |
2049 msn_get_info, /* get_info */ | |
2050 msn_set_status, /* set_away */ | |
2051 msn_set_idle, /* set_idle */ | |
2052 NULL, /* change_passwd */ | |
2053 msn_add_buddy, /* add_buddy */ | |
2054 NULL, /* add_buddies */ | |
2055 msn_rem_buddy, /* remove_buddy */ | |
2056 NULL, /* remove_buddies */ | |
2057 msn_add_permit, /* add_permit */ | |
2058 msn_add_deny, /* add_deny */ | |
2059 msn_rem_permit, /* rem_permit */ | |
2060 msn_rem_deny, /* rem_deny */ | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
2061 msn_set_permit_deny, /* set_permit_deny */ |
14192 | 2062 NULL, /* join_chat */ |
2063 NULL, /* reject chat invite */ | |
2064 NULL, /* get_chat_name */ | |
2065 msn_chat_invite, /* chat_invite */ | |
2066 msn_chat_leave, /* chat_leave */ | |
2067 NULL, /* chat_whisper */ | |
2068 msn_chat_send, /* chat_send */ | |
2069 msn_keepalive, /* keepalive */ | |
2070 NULL, /* register_user */ | |
2071 NULL, /* get_cb_info */ | |
2072 NULL, /* get_cb_away */ | |
2073 NULL, /* alias_buddy */ | |
2074 msn_group_buddy, /* group_buddy */ | |
2075 msn_rename_group, /* rename_group */ | |
2076 NULL, /* buddy_free */ | |
2077 msn_convo_closed, /* convo_closed */ | |
2078 msn_normalize, /* normalize */ | |
2079 msn_set_buddy_icon, /* set_buddy_icon */ | |
2080 msn_remove_group, /* remove_group */ | |
2081 NULL, /* get_cb_real_name */ | |
2082 NULL, /* set_chat_topic */ | |
2083 NULL, /* find_blist_chat */ | |
2084 NULL, /* roomlist_get_list */ | |
2085 NULL, /* roomlist_cancel */ | |
2086 NULL, /* roomlist_expand_category */ | |
2087 msn_can_receive_file, /* can_receive_file */ | |
2088 msn_send_file, /* send_file */ | |
2089 msn_new_xfer, /* new_xfer */ | |
2090 NULL, /* offline_message */ | |
2091 NULL, /* whiteboard_prpl_ops */ | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
2092 NULL, /* send_raw */ |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
2093 NULL, /* roomlist_room_serialize */ |
14192 | 2094 }; |
2095 | |
2096 static GaimPluginInfo info = | |
2097 { | |
2098 GAIM_PLUGIN_MAGIC, | |
2099 GAIM_MAJOR_VERSION, | |
2100 GAIM_MINOR_VERSION, | |
2101 GAIM_PLUGIN_PROTOCOL, /**< type */ | |
2102 NULL, /**< ui_requirement */ | |
2103 0, /**< flags */ | |
2104 NULL, /**< dependencies */ | |
2105 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
2106 | |
2107 "prpl-msn", /**< id */ | |
2108 "MSN", /**< name */ | |
2109 VERSION, /**< version */ | |
2110 /** summary */ | |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
2111 N_("Windows Live Messenger Protocol Plugin"), |
14192 | 2112 /** description */ |
20390
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
2113 N_("Windows Live Messenger Protocol Plugin"), |
d634f88e25d8
msn.tgz from SF Patch #1621854 from Ka-Hing Cheung
Ka-Hing Cheung <khc@hxbc.us>
parents:
20389
diff
changeset
|
2114 "MaYuan <mayuan2006@gmail.com>", /**< author */ |
14192 | 2115 GAIM_WEBSITE, /**< homepage */ |
2116 | |
2117 msn_load, /**< load */ | |
2118 msn_unload, /**< unload */ | |
2119 NULL, /**< destroy */ | |
2120 | |
2121 NULL, /**< ui_info */ | |
2122 &prpl_info, /**< extra_info */ | |
2123 NULL, /**< prefs_info */ | |
2124 msn_actions | |
2125 }; | |
2126 | |
2127 static void | |
2128 init_plugin(GaimPlugin *plugin) | |
2129 { | |
2130 GaimAccountOption *option; | |
2131 | |
2132 option = gaim_account_option_string_new(_("Server"), "server", | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
2133 WLM_SERVER); |
14192 | 2134 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
2135 option); | |
2136 | |
20389
e354528c4163
propagate from branch 'im.pidgin.gaim' (head 70ac931e4936c7916eec18a07fe46a0af0fd7403)
Richard Laager <rlaager@wiktel.com>
parents:
15283
diff
changeset
|
2137 option = gaim_account_option_int_new(_("Port"), "port", WLM_PORT); |
14192 | 2138 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
2139 option); | |
2140 | |
2141 option = gaim_account_option_bool_new(_("Use HTTP Method"), | |
2142 "http_method", FALSE); | |
2143 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
2144 option); | |
2145 | |
2146 option = gaim_account_option_bool_new(_("Show custom smileys"), | |
2147 "custom_smileys", TRUE); | |
2148 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
2149 option); | |
2150 | |
2151 gaim_cmd_register("nudge", "", GAIM_CMD_P_PRPL, | |
2152 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_PRPL_ONLY, | |
2153 "prpl-msn", msn_cmd_nudge, | |
2154 _("nudge: nudge a user to get their attention"), NULL); | |
2155 | |
2156 gaim_prefs_remove("/plugins/prpl/msn"); | |
2157 } | |
2158 | |
2159 GAIM_INIT_PLUGIN(msn, init_plugin, info); |