Mercurial > pidgin.yaz
annotate libgaim/protocols/msn/msn.c @ 15144:b81e4e44b509
[gaim-migrate @ 17929]
User Info and Tooltips now use the GaimNotifyUserInfo object and methods defined in notify.h. GaimNotifyUserInfo objects encapsulate a list of GaimNotifyUserInfoEntry objects, each of which may have a label, a value, and be specified to be a section header.
This moves the burden of UI generation of user information from the various prpls to the UI. The UI can choose how to display the information rather than being fenced into a particular HTML formatting. Consistency across the prpls' information presentation is now enforced, as well. gaim_notify_user_info_get_text_with_newline() generates text in the:
<b>label</b>: value
<b>label</b>: value
format as was passed by convention from prpls in the past.
committer: Tailor Script <tailor@pidgin.im>
author | Evan Schoenberg <evan.s@dreskin.net> |
---|---|
date | Sun, 10 Dec 2006 02:53:09 +0000 |
parents | 6d015bcd8d1d |
children | 4bf7801a2539 |
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; | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
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); | |
431 | |
432 slplink = msn_session_get_slplink(session, who); | |
433 | |
434 xfer->data = slplink; | |
435 | |
436 gaim_xfer_set_init_fnc(xfer, t_msn_xfer_init); | |
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"; | |
508 } | |
509 | |
510 *se = emblems[0]; | |
511 *sw = emblems[1]; | |
512 *nw = emblems[2]; | |
513 *ne = emblems[3]; | |
514 } | |
515 | |
516 static char * | |
517 msn_status_text(GaimBuddy *buddy) | |
518 { | |
519 GaimPresence *presence; | |
520 GaimStatus *status; | |
521 | |
522 presence = gaim_buddy_get_presence(buddy); | |
523 status = gaim_presence_get_active_status(presence); | |
524 | |
525 if (!gaim_presence_is_available(presence) && !gaim_presence_is_idle(presence)) | |
526 { | |
527 return g_strdup(gaim_status_get_name(status)); | |
528 } | |
529 | |
530 return NULL; | |
531 } | |
532 | |
533 static void | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
534 msn_tooltip_text(GaimBuddy *buddy, GaimNotifyUserInfo *user_info, gboolean full) |
14192 | 535 { |
536 MsnUser *user; | |
537 GaimPresence *presence = gaim_buddy_get_presence(buddy); | |
538 GaimStatus *status = gaim_presence_get_active_status(presence); | |
539 | |
540 user = buddy->proto_data; | |
541 | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
542 |
14192 | 543 if (gaim_presence_is_online(presence)) |
544 { | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
545 gaim_notify_user_info_add_pair(user_info, _("Status"), |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
546 (gaim_presence_is_idle(presence) ? _("Idle") : gaim_status_get_name(status))); |
14192 | 547 } |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
548 |
14192 | 549 if (full && user) |
550 { | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
551 gaim_notify_user_info_add_pair(user_info, _("Has you"), |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
552 ((user->list_op & (1 << MSN_LIST_RL)) ? _("Yes") : _("No"))); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
553 } |
14192 | 554 |
555 /* XXX: This is being shown in non-full tooltips because the | |
556 * XXX: blocked icon overlay isn't always accurate for MSN. | |
557 * XXX: This can die as soon as gaim_privacy_check() knows that | |
558 * XXX: this prpl always honors both the allow and deny lists. */ | |
559 if (user) | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
560 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
561 gaim_notify_user_info_add_pair(user_info, _("Blocked"), |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
562 ((user->list_op & (1 << MSN_LIST_BL)) ? _("Yes") : _("No"))); |
14192 | 563 } |
564 } | |
565 | |
566 static GList * | |
567 msn_status_types(GaimAccount *account) | |
568 { | |
569 GaimStatusType *status; | |
570 GList *types = NULL; | |
571 | |
572 status = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, | |
573 NULL, NULL, FALSE, TRUE, FALSE); | |
574 types = g_list_append(types, status); | |
575 | |
576 status = gaim_status_type_new_full(GAIM_STATUS_AWAY, | |
577 NULL, NULL, FALSE, TRUE, FALSE); | |
578 types = g_list_append(types, status); | |
579 | |
580 status = gaim_status_type_new_full(GAIM_STATUS_AWAY, | |
581 "brb", _("Be Right Back"), FALSE, TRUE, FALSE); | |
582 types = g_list_append(types, status); | |
583 | |
584 status = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, | |
585 "busy", _("Busy"), FALSE, TRUE, FALSE); | |
586 types = g_list_append(types, status); | |
587 | |
588 status = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, | |
589 "phone", _("On the Phone"), FALSE, TRUE, FALSE); | |
590 types = g_list_append(types, status); | |
591 | |
592 status = gaim_status_type_new_full(GAIM_STATUS_AWAY, | |
593 "lunch", _("Out to Lunch"), FALSE, TRUE, FALSE); | |
594 types = g_list_append(types, status); | |
595 | |
596 status = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE, | |
597 NULL, NULL, FALSE, TRUE, FALSE); | |
598 types = g_list_append(types, status); | |
599 | |
600 status = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, | |
601 NULL, NULL, FALSE, TRUE, FALSE); | |
602 types = g_list_append(types, status); | |
603 | |
604 return types; | |
605 } | |
606 | |
607 static GList * | |
608 msn_actions(GaimPlugin *plugin, gpointer context) | |
609 { | |
610 GaimConnection *gc = (GaimConnection *)context; | |
611 GaimAccount *account; | |
612 const char *user; | |
613 | |
614 GList *m = NULL; | |
615 GaimPluginAction *act; | |
616 | |
617 act = gaim_plugin_action_new(_("Set Friendly Name..."), | |
618 msn_show_set_friendly_name); | |
619 m = g_list_append(m, act); | |
620 m = g_list_append(m, NULL); | |
621 | |
622 act = gaim_plugin_action_new(_("Set Home Phone Number..."), | |
623 msn_show_set_home_phone); | |
624 m = g_list_append(m, act); | |
625 | |
626 act = gaim_plugin_action_new(_("Set Work Phone Number..."), | |
627 msn_show_set_work_phone); | |
628 m = g_list_append(m, act); | |
629 | |
630 act = gaim_plugin_action_new(_("Set Mobile Phone Number..."), | |
631 msn_show_set_mobile_phone); | |
632 m = g_list_append(m, act); | |
633 m = g_list_append(m, NULL); | |
634 | |
635 #if 0 | |
636 act = gaim_plugin_action_new(_("Enable/Disable Mobile Devices..."), | |
637 msn_show_set_mobile_support); | |
638 m = g_list_append(m, act); | |
639 #endif | |
640 | |
641 act = gaim_plugin_action_new(_("Allow/Disallow Mobile Pages..."), | |
642 msn_show_set_mobile_pages); | |
643 m = g_list_append(m, act); | |
644 | |
645 account = gaim_connection_get_account(gc); | |
646 user = msn_normalize(account, gaim_account_get_username(account)); | |
647 | |
648 if (strstr(user, "@hotmail.com") != NULL) | |
649 { | |
650 m = g_list_append(m, NULL); | |
651 act = gaim_plugin_action_new(_("Open Hotmail Inbox"), | |
652 msn_show_hotmail_inbox); | |
653 m = g_list_append(m, act); | |
654 } | |
655 | |
656 return m; | |
657 } | |
658 | |
659 static GList * | |
660 msn_buddy_menu(GaimBuddy *buddy) | |
661 { | |
662 MsnUser *user; | |
663 | |
664 GList *m = NULL; | |
665 GaimMenuAction *act; | |
666 | |
667 g_return_val_if_fail(buddy != NULL, NULL); | |
668 | |
669 user = buddy->proto_data; | |
670 | |
671 if (user != NULL) | |
672 { | |
673 if (user->mobile) | |
674 { | |
675 act = gaim_menu_action_new(_("Send to Mobile"), | |
676 GAIM_CALLBACK(show_send_to_mobile_cb), | |
677 NULL, NULL); | |
678 m = g_list_append(m, act); | |
679 } | |
680 } | |
681 | |
682 if (g_ascii_strcasecmp(buddy->name, | |
683 gaim_account_get_username(buddy->account))) | |
684 { | |
685 act = gaim_menu_action_new(_("Initiate _Chat"), | |
686 GAIM_CALLBACK(initiate_chat_cb), | |
687 NULL, NULL); | |
688 m = g_list_append(m, act); | |
689 } | |
690 | |
691 return m; | |
692 } | |
693 | |
694 static GList * | |
695 msn_blist_node_menu(GaimBlistNode *node) | |
696 { | |
697 if(GAIM_BLIST_NODE_IS_BUDDY(node)) | |
698 { | |
699 return msn_buddy_menu((GaimBuddy *) node); | |
700 } | |
701 else | |
702 { | |
703 return NULL; | |
704 } | |
705 } | |
706 | |
707 static void | |
708 msn_login(GaimAccount *account) | |
709 { | |
710 GaimConnection *gc; | |
711 MsnSession *session; | |
712 const char *username; | |
713 const char *host; | |
714 gboolean http_method = FALSE; | |
715 int port; | |
716 | |
717 gc = gaim_account_get_connection(account); | |
718 | |
719 if (!gaim_ssl_is_supported()) | |
720 { | |
721 gc->wants_to_die = TRUE; | |
722 gaim_connection_error(gc, | |
723 _("SSL support is needed for MSN. Please install a supported " | |
724 "SSL library. See http://gaim.sf.net/faq-ssl.php for more " | |
725 "information.")); | |
726 | |
727 return; | |
728 } | |
729 | |
730 http_method = gaim_account_get_bool(account, "http_method", FALSE); | |
731 | |
732 host = gaim_account_get_string(account, "server", MSN_SERVER); | |
733 port = gaim_account_get_int(account, "port", MSN_PORT); | |
734 | |
735 session = msn_session_new(account); | |
736 | |
737 gc->proto_data = session; | |
738 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_FORMATTING_WBFO | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_FONTSIZE | GAIM_CONNECTION_NO_URLDESC; | |
739 | |
740 msn_session_set_login_step(session, MSN_LOGIN_STEP_START); | |
741 | |
742 /* Hmm, I don't like this. */ | |
743 /* XXX shx: Me neither */ | |
744 username = msn_normalize(account, gaim_account_get_username(account)); | |
745 | |
746 if (strcmp(username, gaim_account_get_username(account))) | |
747 gaim_account_set_username(account, username); | |
748 | |
749 if (!msn_session_connect(session, host, port, http_method)) | |
750 gaim_connection_error(gc, _("Failed to connect to server.")); | |
751 } | |
752 | |
753 static void | |
754 msn_close(GaimConnection *gc) | |
755 { | |
756 MsnSession *session; | |
757 | |
758 session = gc->proto_data; | |
759 | |
760 g_return_if_fail(session != NULL); | |
761 | |
762 msn_session_destroy(session); | |
763 | |
764 gc->proto_data = NULL; | |
765 } | |
766 | |
767 static int | |
768 msn_send_im(GaimConnection *gc, const char *who, const char *message, | |
769 GaimMessageFlags flags) | |
770 { | |
771 GaimAccount *account; | |
772 MsnMessage *msg; | |
773 char *msgformat; | |
774 char *msgtext; | |
775 | |
776 account = gaim_connection_get_account(gc); | |
777 | |
778 msn_import_html(message, &msgformat, &msgtext); | |
779 | |
780 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) | |
781 { | |
782 g_free(msgformat); | |
783 g_free(msgtext); | |
784 | |
785 return -E2BIG; | |
786 } | |
787 | |
788 msg = msn_message_new_plain(msgtext); | |
789 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); | |
790 | |
791 g_free(msgformat); | |
792 g_free(msgtext); | |
793 | |
794 if (g_ascii_strcasecmp(who, gaim_account_get_username(account))) | |
795 { | |
796 MsnSession *session; | |
797 MsnSwitchBoard *swboard; | |
798 | |
799 session = gc->proto_data; | |
800 swboard = msn_session_get_swboard(session, who, MSN_SB_FLAG_IM); | |
801 | |
802 msn_switchboard_send_msg(swboard, msg, TRUE); | |
803 } | |
804 else | |
805 { | |
806 char *body_str, *body_enc, *pre, *post; | |
807 const char *format; | |
808 /* | |
809 * In MSN, you can't send messages to yourself, so | |
810 * we'll fake like we received it ;) | |
811 */ | |
812 body_str = msn_message_to_string(msg); | |
813 body_enc = g_markup_escape_text(body_str, -1); | |
814 g_free(body_str); | |
815 | |
816 format = msn_message_get_attr(msg, "X-MMS-IM-Format"); | |
817 msn_parse_format(format, &pre, &post); | |
818 body_str = g_strdup_printf("%s%s%s", pre ? pre : "", | |
819 body_enc ? body_enc : "", post ? post : ""); | |
820 g_free(body_enc); | |
821 g_free(pre); | |
822 g_free(post); | |
823 | |
824 serv_got_typing_stopped(gc, who); | |
825 serv_got_im(gc, who, body_str, flags, time(NULL)); | |
826 g_free(body_str); | |
827 } | |
828 | |
829 msn_message_destroy(msg); | |
830 | |
831 return 1; | |
832 } | |
833 | |
834 static unsigned int | |
835 msn_send_typing(GaimConnection *gc, const char *who, GaimTypingState state) | |
836 { | |
837 GaimAccount *account; | |
838 MsnSession *session; | |
839 MsnSwitchBoard *swboard; | |
840 MsnMessage *msg; | |
841 | |
842 account = gaim_connection_get_account(gc); | |
843 session = gc->proto_data; | |
844 | |
845 /* | |
846 * TODO: I feel like this should be "if (state != GAIM_TYPING)" | |
847 * but this is how it was before, and I don't want to break | |
848 * anything. --KingAnt | |
849 */ | |
850 if (state == GAIM_NOT_TYPING) | |
851 return 0; | |
852 | |
853 if (!g_ascii_strcasecmp(who, gaim_account_get_username(account))) | |
854 { | |
855 /* We'll just fake it, since we're sending to ourself. */ | |
856 serv_got_typing(gc, who, MSN_TYPING_RECV_TIMEOUT, GAIM_TYPING); | |
857 | |
858 return MSN_TYPING_SEND_TIMEOUT; | |
859 } | |
860 | |
861 swboard = msn_session_find_swboard(session, who); | |
862 | |
863 if (swboard == NULL || !msn_switchboard_can_send(swboard)) | |
864 return 0; | |
865 | |
866 swboard->flag |= MSN_SB_FLAG_IM; | |
867 | |
868 msg = msn_message_new(MSN_MSG_TYPING); | |
869 msn_message_set_content_type(msg, "text/x-msmsgscontrol"); | |
870 msn_message_set_flag(msg, 'U'); | |
871 msn_message_set_attr(msg, "TypingUser", | |
872 gaim_account_get_username(account)); | |
873 msn_message_set_bin_data(msg, "\r\n", 2); | |
874 | |
875 msn_switchboard_send_msg(swboard, msg, FALSE); | |
876 | |
877 msn_message_destroy(msg); | |
878 | |
879 return MSN_TYPING_SEND_TIMEOUT; | |
880 } | |
881 | |
882 static void | |
883 msn_set_status(GaimAccount *account, GaimStatus *status) | |
884 { | |
885 GaimConnection *gc; | |
886 MsnSession *session; | |
887 | |
888 gc = gaim_account_get_connection(account); | |
889 | |
890 if (gc != NULL) | |
891 { | |
892 session = gc->proto_data; | |
893 msn_change_status(session); | |
894 } | |
895 } | |
896 | |
897 static void | |
898 msn_set_idle(GaimConnection *gc, int idle) | |
899 { | |
900 MsnSession *session; | |
901 | |
902 session = gc->proto_data; | |
903 | |
904 msn_change_status(session); | |
905 } | |
906 | |
907 #if 0 | |
908 static void | |
909 fake_userlist_add_buddy(MsnUserList *userlist, | |
910 const char *who, int list_id, | |
911 const char *group_name) | |
912 { | |
913 MsnUser *user; | |
914 static int group_id_c = 1; | |
915 int group_id; | |
916 | |
917 group_id = -1; | |
918 | |
919 if (group_name != NULL) | |
920 { | |
921 MsnGroup *group; | |
922 group = msn_group_new(userlist, group_id_c, group_name); | |
923 group_id = group_id_c++; | |
924 } | |
925 | |
926 user = msn_userlist_find_user(userlist, who); | |
927 | |
928 if (user == NULL) | |
929 { | |
930 user = msn_user_new(userlist, who, NULL); | |
931 msn_userlist_add_user(userlist, user); | |
932 } | |
933 else | |
934 if (user->list_op & (1 << list_id)) | |
935 { | |
936 if (list_id == MSN_LIST_FL) | |
937 { | |
938 if (group_id >= 0) | |
939 if (g_list_find(user->group_ids, | |
940 GINT_TO_POINTER(group_id))) | |
941 return; | |
942 } | |
943 else | |
944 return; | |
945 } | |
946 | |
947 if (group_id >= 0) | |
948 { | |
949 user->group_ids = g_list_append(user->group_ids, | |
950 GINT_TO_POINTER(group_id)); | |
951 } | |
952 | |
953 user->list_op |= (1 << list_id); | |
954 } | |
955 #endif | |
956 | |
957 static void | |
958 msn_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | |
959 { | |
960 MsnSession *session; | |
961 MsnUserList *userlist; | |
962 const char *who; | |
963 | |
964 session = gc->proto_data; | |
965 userlist = session->userlist; | |
966 who = msn_normalize(gc->account, buddy->name); | |
967 | |
968 if (!session->logged_in) | |
969 { | |
970 #if 0 | |
971 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, | |
972 group ? group->name : NULL); | |
973 #else | |
974 gaim_debug_error("msn", "msn_add_buddy called before connected\n"); | |
975 #endif | |
976 | |
977 return; | |
978 } | |
979 | |
980 #if 0 | |
981 if (group != NULL && group->name != NULL) | |
982 gaim_debug_info("msn", "msn_add_buddy: %s, %s\n", who, group->name); | |
983 else | |
984 gaim_debug_info("msn", "msn_add_buddy: %s\n", who); | |
985 #endif | |
986 | |
987 #if 0 | |
988 /* Which is the max? */ | |
989 if (session->fl_users_count >= 150) | |
990 { | |
991 gaim_debug_info("msn", "Too many buddies\n"); | |
992 /* Buddy list full */ | |
993 /* TODO: gaim should be notified of this */ | |
994 return; | |
995 } | |
996 #endif | |
997 | |
998 /* XXX - Would group ever be NULL here? I don't think so... | |
999 * shx: Yes it should; MSN handles non-grouped buddies, and this is only | |
1000 * internal. */ | |
1001 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, | |
1002 group ? group->name : NULL); | |
1003 } | |
1004 | |
1005 static void | |
1006 msn_rem_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) | |
1007 { | |
1008 MsnSession *session; | |
1009 MsnUserList *userlist; | |
1010 | |
1011 session = gc->proto_data; | |
1012 userlist = session->userlist; | |
1013 | |
1014 if (!session->logged_in) | |
1015 return; | |
1016 | |
1017 /* XXX - Does buddy->name need to be msn_normalize'd here? --KingAnt */ | |
1018 msn_userlist_rem_buddy(userlist, buddy->name, MSN_LIST_FL, group->name); | |
1019 } | |
1020 | |
1021 static void | |
1022 msn_add_permit(GaimConnection *gc, const char *who) | |
1023 { | |
1024 MsnSession *session; | |
1025 MsnUserList *userlist; | |
1026 MsnUser *user; | |
1027 | |
1028 session = gc->proto_data; | |
1029 userlist = session->userlist; | |
1030 user = msn_userlist_find_user(userlist, who); | |
1031 | |
1032 if (!session->logged_in) | |
1033 return; | |
1034 | |
1035 if (user != NULL && user->list_op & MSN_LIST_BL_OP) | |
1036 msn_userlist_rem_buddy(userlist, who, MSN_LIST_BL, NULL); | |
1037 | |
1038 msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL); | |
1039 } | |
1040 | |
1041 static void | |
1042 msn_add_deny(GaimConnection *gc, const char *who) | |
1043 { | |
1044 MsnSession *session; | |
1045 MsnUserList *userlist; | |
1046 MsnUser *user; | |
1047 | |
1048 session = gc->proto_data; | |
1049 userlist = session->userlist; | |
1050 user = msn_userlist_find_user(userlist, who); | |
1051 | |
1052 if (!session->logged_in) | |
1053 return; | |
1054 | |
1055 if (user != NULL && user->list_op & MSN_LIST_AL_OP) | |
1056 msn_userlist_rem_buddy(userlist, who, MSN_LIST_AL, NULL); | |
1057 | |
1058 msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL); | |
1059 } | |
1060 | |
1061 static void | |
1062 msn_rem_permit(GaimConnection *gc, const char *who) | |
1063 { | |
1064 MsnSession *session; | |
1065 MsnUserList *userlist; | |
1066 MsnUser *user; | |
1067 | |
1068 session = gc->proto_data; | |
1069 userlist = session->userlist; | |
1070 | |
1071 if (!session->logged_in) | |
1072 return; | |
1073 | |
1074 user = msn_userlist_find_user(userlist, who); | |
1075 | |
1076 msn_userlist_rem_buddy(userlist, who, MSN_LIST_AL, NULL); | |
1077 | |
1078 if (user != NULL && user->list_op & MSN_LIST_RL_OP) | |
1079 msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL); | |
1080 } | |
1081 | |
1082 static void | |
1083 msn_rem_deny(GaimConnection *gc, const char *who) | |
1084 { | |
1085 MsnSession *session; | |
1086 MsnUserList *userlist; | |
1087 MsnUser *user; | |
1088 | |
1089 session = gc->proto_data; | |
1090 userlist = session->userlist; | |
1091 | |
1092 if (!session->logged_in) | |
1093 return; | |
1094 | |
1095 user = msn_userlist_find_user(userlist, who); | |
1096 | |
1097 msn_userlist_rem_buddy(userlist, who, MSN_LIST_BL, NULL); | |
1098 | |
1099 if (user != NULL && user->list_op & MSN_LIST_RL_OP) | |
1100 msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL); | |
1101 } | |
1102 | |
1103 static void | |
1104 msn_set_permit_deny(GaimConnection *gc) | |
1105 { | |
1106 GaimAccount *account; | |
1107 MsnSession *session; | |
1108 MsnCmdProc *cmdproc; | |
1109 | |
1110 account = gaim_connection_get_account(gc); | |
1111 session = gc->proto_data; | |
1112 cmdproc = session->notification->cmdproc; | |
1113 | |
1114 if (account->perm_deny == GAIM_PRIVACY_ALLOW_ALL || | |
1115 account->perm_deny == GAIM_PRIVACY_DENY_USERS) | |
1116 { | |
1117 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); | |
1118 } | |
1119 else | |
1120 { | |
1121 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); | |
1122 } | |
1123 } | |
1124 | |
1125 static void | |
1126 msn_chat_invite(GaimConnection *gc, int id, const char *msg, | |
1127 const char *who) | |
1128 { | |
1129 MsnSession *session; | |
1130 MsnSwitchBoard *swboard; | |
1131 | |
1132 session = gc->proto_data; | |
1133 | |
1134 swboard = msn_session_find_swboard_with_id(session, id); | |
1135 | |
1136 if (swboard == NULL) | |
1137 { | |
1138 /* if we have no switchboard, everyone else left the chat already */ | |
1139 swboard = msn_switchboard_new(session); | |
1140 msn_switchboard_request(swboard); | |
1141 swboard->chat_id = id; | |
1142 swboard->conv = gaim_find_chat(gc, id); | |
1143 } | |
1144 | |
1145 swboard->flag |= MSN_SB_FLAG_IM; | |
1146 | |
1147 msn_switchboard_request_add_user(swboard, who); | |
1148 } | |
1149 | |
1150 static void | |
1151 msn_chat_leave(GaimConnection *gc, int id) | |
1152 { | |
1153 MsnSession *session; | |
1154 MsnSwitchBoard *swboard; | |
1155 GaimConversation *conv; | |
1156 | |
1157 session = gc->proto_data; | |
1158 | |
1159 swboard = msn_session_find_swboard_with_id(session, id); | |
1160 | |
1161 /* if swboard is NULL we were the only person left anyway */ | |
1162 if (swboard == NULL) | |
1163 return; | |
1164 | |
1165 conv = swboard->conv; | |
1166 | |
1167 msn_switchboard_release(swboard, MSN_SB_FLAG_IM); | |
1168 | |
1169 /* If other switchboards managed to associate themselves with this | |
1170 * conv, make sure they know it's gone! */ | |
1171 if (conv != NULL) | |
1172 { | |
1173 while ((swboard = msn_session_find_swboard_with_conv(session, conv)) != NULL) | |
1174 swboard->conv = NULL; | |
1175 } | |
1176 } | |
1177 | |
1178 static int | |
1179 msn_chat_send(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) | |
1180 { | |
1181 GaimAccount *account; | |
1182 MsnSession *session; | |
1183 MsnSwitchBoard *swboard; | |
1184 MsnMessage *msg; | |
1185 char *msgformat; | |
1186 char *msgtext; | |
1187 | |
1188 account = gaim_connection_get_account(gc); | |
1189 session = gc->proto_data; | |
1190 swboard = msn_session_find_swboard_with_id(session, id); | |
1191 | |
1192 if (swboard == NULL) | |
1193 return -EINVAL; | |
1194 | |
1195 if (!swboard->ready) | |
1196 return 0; | |
1197 | |
1198 swboard->flag |= MSN_SB_FLAG_IM; | |
1199 | |
1200 msn_import_html(message, &msgformat, &msgtext); | |
1201 | |
1202 if (strlen(msgtext) + strlen(msgformat) + strlen(VERSION) > 1564) | |
1203 { | |
1204 g_free(msgformat); | |
1205 g_free(msgtext); | |
1206 | |
1207 return -E2BIG; | |
1208 } | |
1209 | |
1210 msg = msn_message_new_plain(msgtext); | |
1211 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); | |
1212 msn_switchboard_send_msg(swboard, msg, FALSE); | |
1213 msn_message_destroy(msg); | |
1214 | |
1215 g_free(msgformat); | |
1216 g_free(msgtext); | |
1217 | |
1218 serv_got_chat_in(gc, id, gaim_account_get_username(account), 0, | |
1219 message, time(NULL)); | |
1220 | |
1221 return 0; | |
1222 } | |
1223 | |
1224 static void | |
1225 msn_keepalive(GaimConnection *gc) | |
1226 { | |
1227 MsnSession *session; | |
1228 | |
1229 session = gc->proto_data; | |
1230 | |
1231 if (!session->http_method) | |
1232 { | |
1233 MsnCmdProc *cmdproc; | |
1234 | |
1235 cmdproc = session->notification->cmdproc; | |
1236 | |
1237 msn_cmdproc_send_quick(cmdproc, "PNG", NULL, NULL); | |
1238 } | |
1239 } | |
1240 | |
1241 static void | |
1242 msn_group_buddy(GaimConnection *gc, const char *who, | |
1243 const char *old_group_name, const char *new_group_name) | |
1244 { | |
1245 MsnSession *session; | |
1246 MsnUserList *userlist; | |
1247 | |
1248 session = gc->proto_data; | |
1249 userlist = session->userlist; | |
1250 | |
1251 msn_userlist_move_buddy(userlist, who, old_group_name, new_group_name); | |
1252 } | |
1253 | |
1254 static void | |
1255 msn_rename_group(GaimConnection *gc, const char *old_name, | |
1256 GaimGroup *group, GList *moved_buddies) | |
1257 { | |
1258 MsnSession *session; | |
1259 MsnCmdProc *cmdproc; | |
1260 int old_gid; | |
1261 const char *enc_new_group_name; | |
1262 | |
1263 session = gc->proto_data; | |
1264 cmdproc = session->notification->cmdproc; | |
1265 enc_new_group_name = gaim_url_encode(group->name); | |
1266 | |
1267 old_gid = msn_userlist_find_group_id(session->userlist, old_name); | |
1268 | |
1269 if (old_gid >= 0) | |
1270 { | |
1271 msn_cmdproc_send(cmdproc, "REG", "%d %s 0", old_gid, | |
1272 enc_new_group_name); | |
1273 } | |
1274 else | |
1275 { | |
1276 msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name); | |
1277 } | |
1278 } | |
1279 | |
1280 static void | |
1281 msn_convo_closed(GaimConnection *gc, const char *who) | |
1282 { | |
1283 MsnSession *session; | |
1284 MsnSwitchBoard *swboard; | |
1285 GaimConversation *conv; | |
1286 | |
1287 session = gc->proto_data; | |
1288 | |
1289 swboard = msn_session_find_swboard(session, who); | |
1290 | |
1291 /* | |
1292 * Don't perform an assertion here. If swboard is NULL, then the | |
1293 * switchboard was either closed by the other party, or the person | |
1294 * is talking to himself. | |
1295 */ | |
1296 if (swboard == NULL) | |
1297 return; | |
1298 | |
1299 conv = swboard->conv; | |
1300 | |
1301 msn_switchboard_release(swboard, MSN_SB_FLAG_IM); | |
1302 | |
1303 /* If other switchboards managed to associate themselves with this | |
1304 * conv, make sure they know it's gone! */ | |
1305 if (conv != NULL) | |
1306 { | |
1307 while ((swboard = msn_session_find_swboard_with_conv(session, conv)) != NULL) | |
1308 swboard->conv = NULL; | |
1309 } | |
1310 } | |
1311 | |
1312 static void | |
1313 msn_set_buddy_icon(GaimConnection *gc, const char *filename) | |
1314 { | |
1315 MsnSession *session; | |
1316 MsnUser *user; | |
1317 | |
1318 session = gc->proto_data; | |
1319 user = session->user; | |
1320 | |
1321 msn_user_set_buddy_icon(user, filename); | |
1322 | |
1323 msn_change_status(session); | |
1324 } | |
1325 | |
1326 static void | |
1327 msn_remove_group(GaimConnection *gc, GaimGroup *group) | |
1328 { | |
1329 MsnSession *session; | |
1330 MsnCmdProc *cmdproc; | |
1331 int group_id; | |
1332 | |
1333 session = gc->proto_data; | |
1334 cmdproc = session->notification->cmdproc; | |
1335 | |
1336 if ((group_id = msn_userlist_find_group_id(session->userlist, group->name)) >= 0) | |
1337 { | |
1338 msn_cmdproc_send(cmdproc, "RMG", "%d", group_id); | |
1339 } | |
1340 } | |
1341 | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1342 /** |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1343 * Extract info text from info_data and add it to user_info |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1344 */ |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1345 static gboolean |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1346 msn_tooltip_extract_info_text(GaimNotifyUserInfo *user_info, MsnGetInfoData *info_data) |
14192 | 1347 { |
1348 GaimBuddy *b; | |
1349 | |
1350 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), | |
1351 info_data->name); | |
1352 | |
1353 if (b) | |
1354 { | |
1355 char *tmp; | |
1356 | |
1357 if (b->alias && b->alias[0]) | |
1358 { | |
1359 char *aliastext = g_markup_escape_text(b->alias, -1); | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1360 gaim_notify_user_info_add_pair(user_info, _("Alias"), aliastext); |
14192 | 1361 g_free(aliastext); |
1362 } | |
1363 | |
1364 if (b->server_alias) | |
1365 { | |
1366 char *nicktext = g_markup_escape_text(b->server_alias, -1); | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1367 tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1368 gaim_notify_user_info_add_pair(user_info, _("Nickname"), tmp); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1369 g_free(tmp); |
14192 | 1370 g_free(nicktext); |
1371 } | |
1372 | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1373 /* Add the tooltip information */ |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1374 msn_tooltip_text(b, user_info, TRUE); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1375 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1376 return TRUE; |
14192 | 1377 } |
1378 | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1379 return FALSE; |
14192 | 1380 } |
1381 | |
1382 #if PHOTO_SUPPORT | |
1383 | |
1384 static char * | |
1385 msn_get_photo_url(const char *url_text) | |
1386 { | |
1387 char *p, *q; | |
1388 | |
1389 if ((p = strstr(url_text, " contactparams:photopreauthurl=\"")) != NULL) | |
1390 { | |
1391 p += strlen(" contactparams:photopreauthurl=\""); | |
1392 } | |
1393 | |
1394 if (p && (strncmp(p, "http://", 8) == 0) && ((q = strchr(p, '"')) != NULL)) | |
1395 return g_strndup(p, q - p); | |
1396 | |
1397 return NULL; | |
1398 } | |
1399 | |
14354 | 1400 static void msn_got_photo(GaimUtilFetchUrlData *url_data, gpointer data, |
1401 const gchar *url_text, size_t len, const gchar *error_message); | |
14192 | 1402 |
1403 #endif | |
1404 | |
1405 #if 0 | |
1406 static char *msn_info_date_reformat(const char *field, size_t len) | |
1407 { | |
1408 char *tmp = g_strndup(field, len); | |
1409 time_t t = gaim_str_to_time(tmp, FALSE, NULL, NULL, NULL); | |
1410 | |
1411 g_free(tmp); | |
1412 return g_strdup(gaim_date_format_short(localtime(&t))); | |
1413 } | |
1414 #endif | |
1415 | |
1416 #define MSN_GOT_INFO_GET_FIELD(a, b) \ | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1417 found = gaim_markup_extract_info_field(stripped, stripped_len, user_info, \ |
14368
705c76724ce2
[gaim-migrate @ 17074]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14354
diff
changeset
|
1418 "\n" a ":", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \ |
14192 | 1419 if (found) \ |
1420 sect_info = TRUE; | |
1421 | |
1422 static void | |
14354 | 1423 msn_got_info(GaimUtilFetchUrlData *url_data, gpointer data, |
1424 const gchar *url_text, size_t len, const gchar *error_message) | |
14192 | 1425 { |
1426 MsnGetInfoData *info_data = (MsnGetInfoData *)data; | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1427 GaimNotifyUserInfo *user_info; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1428 char *stripped, *p, *q, *tmp; |
14192 | 1429 char *user_url = NULL; |
1430 gboolean found; | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1431 gboolean has_tooltip_text = FALSE; |
14192 | 1432 gboolean has_info = FALSE; |
1433 gboolean sect_info = FALSE; | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1434 gboolean has_contact_info = FALSE; |
14192 | 1435 char *url_buffer; |
1436 GString *s, *s2; | |
1437 int stripped_len; | |
1438 #if PHOTO_SUPPORT | |
1439 char *photo_url_text = NULL; | |
1440 MsnGetInfoStepTwoData *info2_data = NULL; | |
1441 #endif | |
1442 | |
1443 gaim_debug_info("msn", "In msn_got_info\n"); | |
1444 | |
1445 /* Make sure the connection is still valid */ | |
1446 if (g_list_find(gaim_connections_get_all(), info_data->gc) == NULL) | |
1447 { | |
1448 gaim_debug_warning("msn", "invalid connection. ignoring buddy info.\n"); | |
1449 g_free(info_data->name); | |
1450 g_free(info_data); | |
1451 return; | |
1452 } | |
1453 | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1454 user_info = gaim_notify_user_info_new(); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1455 has_tooltip_text = msn_tooltip_extract_info_text(user_info, info_data); |
14192 | 1456 |
14354 | 1457 if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0) |
14192 | 1458 { |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1459 tmp = g_strdup_printf("<b>%s</b>", _("Error retrieving profile")); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1460 gaim_notify_user_info_add_pair(user_info, NULL, tmp); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1461 g_free(tmp); |
14192 | 1462 |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1463 gaim_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1464 gaim_notify_user_info_destroy(user_info); |
14192 | 1465 |
14368
705c76724ce2
[gaim-migrate @ 17074]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14354
diff
changeset
|
1466 g_free(info_data->name); |
705c76724ce2
[gaim-migrate @ 17074]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14354
diff
changeset
|
1467 g_free(info_data); |
14192 | 1468 return; |
1469 } | |
1470 | |
1471 url_buffer = g_strdup(url_text); | |
1472 | |
1473 /* If they have a homepage link, MSN masks it such that we need to | |
1474 * fetch the url out before gaim_markup_strip_html() nukes it */ | |
1475 /* I don't think this works with the new spaces profiles - Stu 3/2/06 */ | |
1476 if ((p = strstr(url_text, | |
1477 "Take a look at my </font><A class=viewDesc title=\"")) != NULL) | |
1478 { | |
1479 p += 50; | |
1480 | |
1481 if ((q = strchr(p, '"')) != NULL) | |
1482 user_url = g_strndup(p, q - p); | |
1483 } | |
1484 | |
1485 /* | |
1486 * gaim_markup_strip_html() doesn't strip out character entities like | |
1487 * and · | |
1488 */ | |
1489 while ((p = strstr(url_buffer, " ")) != NULL) | |
1490 { | |
1491 *p = ' '; /* Turn 's into ordinary blanks */ | |
1492 p += 1; | |
1493 memmove(p, p + 5, strlen(p + 5)); | |
1494 url_buffer[strlen(url_buffer) - 5] = '\0'; | |
1495 } | |
1496 | |
1497 while ((p = strstr(url_buffer, "·")) != NULL) | |
1498 { | |
1499 memmove(p, p + 6, strlen(p + 6)); | |
1500 url_buffer[strlen(url_buffer) - 6] = '\0'; | |
1501 } | |
1502 | |
1503 /* Nuke the nasty \r's that just get in the way */ | |
1504 gaim_str_strip_char(url_buffer, '\r'); | |
1505 | |
1506 /* MSN always puts in ' for apostrophes...replace them */ | |
1507 while ((p = strstr(url_buffer, "'")) != NULL) | |
1508 { | |
1509 *p = '\''; | |
1510 memmove(p + 1, p + 5, strlen(p + 5)); | |
1511 url_buffer[strlen(url_buffer) - 4] = '\0'; | |
1512 } | |
1513 | |
1514 /* Nuke the html, it's easier than trying to parse the horrid stuff */ | |
1515 stripped = gaim_markup_strip_html(url_buffer); | |
1516 stripped_len = strlen(stripped); | |
1517 | |
1518 gaim_debug_misc("msn", "stripped = %p\n", stripped); | |
1519 gaim_debug_misc("msn", "url_buffer = %p\n", url_buffer); | |
1520 | |
1521 /* Gonna re-use the memory we've already got for url_buffer */ | |
1522 /* No we're not. */ | |
1523 s = g_string_sized_new(strlen(url_buffer)); | |
1524 s2 = g_string_sized_new(strlen(url_buffer)); | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1525 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1526 /* General section header */ |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1527 if (has_tooltip_text) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1528 gaim_notify_user_info_add_section_break(user_info); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1529 |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1530 gaim_notify_user_info_add_section_header(user_info, _("General")); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1531 |
14192 | 1532 /* Extract their Name and put it in */ |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1533 MSN_GOT_INFO_GET_FIELD("Name", _("Name")); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1534 |
14192 | 1535 /* General */ |
1536 MSN_GOT_INFO_GET_FIELD("Nickname", _("Nickname")); | |
1537 MSN_GOT_INFO_GET_FIELD("Age", _("Age")); | |
1538 MSN_GOT_INFO_GET_FIELD("Gender", _("Gender")); | |
1539 MSN_GOT_INFO_GET_FIELD("Occupation", _("Occupation")); | |
1540 MSN_GOT_INFO_GET_FIELD("Location", _("Location")); | |
1541 | |
1542 /* Extract their Interests and put it in */ | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1543 found = gaim_markup_extract_info_field(stripped, stripped_len, user_info, |
14192 | 1544 "\nInterests\t", 0, " (/default.aspx?page=searchresults", 0, |
1545 "Undisclosed", _("Hobbies and Interests") /* _("Interests") */, | |
1546 0, NULL, NULL); | |
1547 | |
1548 if (found) | |
1549 sect_info = TRUE; | |
1550 | |
1551 MSN_GOT_INFO_GET_FIELD("More about me", _("A Little About Me")); | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1552 |
14192 | 1553 if (sect_info) |
1554 { | |
1555 has_info = TRUE; | |
1556 sect_info = FALSE; | |
1557 } | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1558 else |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1559 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1560 /* Remove the section header */ |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1561 gaim_notify_user_info_remove_last_item(user_info); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1562 if (has_tooltip_text) |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1563 gaim_notify_user_info_remove_last_item(user_info); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1564 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1565 |
14192 | 1566 /* Social */ |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1567 gaim_notify_user_info_add_section_break(user_info); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1568 gaim_notify_user_info_add_section_header(user_info, _("Social")); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1569 |
14192 | 1570 MSN_GOT_INFO_GET_FIELD("Marital status", _("Marital Status")); |
1571 MSN_GOT_INFO_GET_FIELD("Interested in", _("Interests")); | |
1572 MSN_GOT_INFO_GET_FIELD("Pets", _("Pets")); | |
1573 MSN_GOT_INFO_GET_FIELD("Hometown", _("Hometown")); | |
1574 MSN_GOT_INFO_GET_FIELD("Places lived", _("Places Lived")); | |
1575 MSN_GOT_INFO_GET_FIELD("Fashion", _("Fashion")); | |
1576 MSN_GOT_INFO_GET_FIELD("Humor", _("Humor")); | |
1577 MSN_GOT_INFO_GET_FIELD("Music", _("Music")); | |
1578 MSN_GOT_INFO_GET_FIELD("Favorite quote", _("Favorite Quote")); | |
1579 | |
1580 if (sect_info) | |
1581 { | |
1582 has_info = TRUE; | |
1583 sect_info = FALSE; | |
1584 } | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1585 else |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1586 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1587 /* Remove the section header */ |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1588 gaim_notify_user_info_remove_last_item(user_info); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1589 gaim_notify_user_info_remove_last_item(user_info); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1590 } |
14192 | 1591 |
1592 /* Contact Info */ | |
1593 /* Personal */ | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1594 gaim_notify_user_info_add_section_break(user_info); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1595 gaim_notify_user_info_add_section_header(user_info, _("Contact Info")); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1596 gaim_notify_user_info_add_section_header(user_info, _("Personal")); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1597 |
14192 | 1598 MSN_GOT_INFO_GET_FIELD("Name", _("Name")); |
1599 MSN_GOT_INFO_GET_FIELD("Significant other", _("Significant Other")); | |
1600 MSN_GOT_INFO_GET_FIELD("Home phone", _("Home Phone")); | |
1601 MSN_GOT_INFO_GET_FIELD("Home phone 2", _("Home Phone 2")); | |
1602 MSN_GOT_INFO_GET_FIELD("Home address", _("Home Address")); | |
1603 MSN_GOT_INFO_GET_FIELD("Personal Mobile", _("Personal Mobile")); | |
1604 MSN_GOT_INFO_GET_FIELD("Home fax", _("Home Fax")); | |
1605 MSN_GOT_INFO_GET_FIELD("Personal e-mail", _("Personal E-Mail")); | |
1606 MSN_GOT_INFO_GET_FIELD("Personal IM", _("Personal IM")); | |
1607 MSN_GOT_INFO_GET_FIELD("Birthday", _("Birthday")); | |
1608 MSN_GOT_INFO_GET_FIELD("Anniversary", _("Anniversary")); | |
1609 MSN_GOT_INFO_GET_FIELD("Notes", _("Notes")); | |
1610 | |
1611 if (sect_info) | |
1612 { | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1613 has_info = TRUE; |
14192 | 1614 sect_info = FALSE; |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1615 has_contact_info = TRUE; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1616 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1617 else |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1618 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1619 /* Remove the section header */ |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1620 gaim_notify_user_info_remove_last_item(user_info); |
14192 | 1621 } |
1622 | |
1623 /* Business */ | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1624 gaim_notify_user_info_add_section_header(user_info, _("Work")); |
14192 | 1625 MSN_GOT_INFO_GET_FIELD("Name", _("Name")); |
1626 MSN_GOT_INFO_GET_FIELD("Job title", _("Job Title")); | |
1627 MSN_GOT_INFO_GET_FIELD("Company", _("Company")); | |
1628 MSN_GOT_INFO_GET_FIELD("Department", _("Department")); | |
1629 MSN_GOT_INFO_GET_FIELD("Profession", _("Profession")); | |
1630 MSN_GOT_INFO_GET_FIELD("Work phone 1", _("Work Phone")); | |
1631 MSN_GOT_INFO_GET_FIELD("Work phone 2", _("Work Phone 2")); | |
1632 MSN_GOT_INFO_GET_FIELD("Work address", _("Work Address")); | |
1633 MSN_GOT_INFO_GET_FIELD("Work mobile", _("Work Mobile")); | |
1634 MSN_GOT_INFO_GET_FIELD("Work pager", _("Work Pager")); | |
1635 MSN_GOT_INFO_GET_FIELD("Work fax", _("Work Fax")); | |
1636 MSN_GOT_INFO_GET_FIELD("Work e-mail", _("Work E-Mail")); | |
1637 MSN_GOT_INFO_GET_FIELD("Work IM", _("Work IM")); | |
1638 MSN_GOT_INFO_GET_FIELD("Start date", _("Start Date")); | |
1639 MSN_GOT_INFO_GET_FIELD("Notes", _("Notes")); | |
1640 | |
1641 if (sect_info) | |
1642 { | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1643 has_info = TRUE; |
14192 | 1644 sect_info = FALSE; |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1645 has_contact_info = TRUE; |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1646 } |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1647 else |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1648 { |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1649 /* Remove the section header */ |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1650 gaim_notify_user_info_remove_last_item(user_info); |
14192 | 1651 } |
1652 | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1653 if (!has_contact_info) |
14192 | 1654 { |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1655 /* Remove the Contact Info section header */ |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1656 gaim_notify_user_info_remove_last_item(user_info); |
14192 | 1657 } |
1658 | |
1659 #if 0 /* these probably don't show up any more */ | |
1660 /* | |
1661 * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies | |
1662 * and Interests', 'Favorite Quote', and 'My Homepage' may or may | |
1663 * not appear, in any combination. However, they do appear in | |
1664 * certain order, so we can successively search to pin down the | |
1665 * distinct values. | |
1666 */ | |
1667 | |
1668 /* Check if they have A Little About Me */ | |
1669 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1670 " A Little About Me \n\n", 0, "Favorite Things", '\n', NULL, | |
1671 _("A Little About Me"), 0, NULL, NULL); | |
1672 | |
1673 if (!found) | |
1674 { | |
1675 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1676 " A Little About Me \n\n", 0, "Hobbies and Interests", '\n', | |
1677 NULL, _("A Little About Me"), 0, NULL, NULL); | |
1678 } | |
1679 | |
1680 if (!found) | |
1681 { | |
1682 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1683 " A Little About Me \n\n", 0, "Favorite Quote", '\n', NULL, | |
1684 _("A Little About Me"), 0, NULL, NULL); | |
1685 } | |
1686 | |
1687 if (!found) | |
1688 { | |
1689 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1690 " A Little About Me \n\n", 0, "My Homepage \n\nTake a look", | |
1691 '\n', | |
1692 NULL, _("A Little About Me"), 0, NULL, NULL); | |
1693 } | |
1694 | |
1695 if (!found) | |
1696 { | |
1697 gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1698 " A Little About Me \n\n", 0, "last updated", '\n', NULL, | |
1699 _("A Little About Me"), 0, NULL, NULL); | |
1700 } | |
1701 | |
1702 if (found) | |
1703 has_info = TRUE; | |
1704 | |
1705 /* Check if they have Favorite Things */ | |
1706 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1707 " Favorite Things \n\n", 0, "Hobbies and Interests", '\n', NULL, | |
1708 _("Favorite Things"), 0, NULL, NULL); | |
1709 | |
1710 if (!found) | |
1711 { | |
1712 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1713 " Favorite Things \n\n", 0, "Favorite Quote", '\n', NULL, | |
1714 _("Favorite Things"), 0, NULL, NULL); | |
1715 } | |
1716 | |
1717 if (!found) | |
1718 { | |
1719 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1720 " Favorite Things \n\n", 0, "My Homepage \n\nTake a look", '\n', | |
1721 NULL, _("Favorite Things"), 0, NULL, NULL); | |
1722 } | |
1723 | |
1724 if (!found) | |
1725 { | |
1726 gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1727 " Favorite Things \n\n", 0, "last updated", '\n', NULL, | |
1728 _("Favorite Things"), 0, NULL, NULL); | |
1729 } | |
1730 | |
1731 if (found) | |
1732 has_info = TRUE; | |
1733 | |
1734 /* Check if they have Hobbies and Interests */ | |
1735 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1736 " Hobbies and Interests \n\n", 0, "Favorite Quote", '\n', NULL, | |
1737 _("Hobbies and Interests"), 0, NULL, NULL); | |
1738 | |
1739 if (!found) | |
1740 { | |
1741 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1742 " Hobbies and Interests \n\n", 0, "My Homepage \n\nTake a look", | |
1743 '\n', NULL, _("Hobbies and Interests"), 0, NULL, NULL); | |
1744 } | |
1745 | |
1746 if (!found) | |
1747 { | |
1748 gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1749 " Hobbies and Interests \n\n", 0, "last updated", '\n', NULL, | |
1750 _("Hobbies and Interests"), 0, NULL, NULL); | |
1751 } | |
1752 | |
1753 if (found) | |
1754 has_info = TRUE; | |
1755 | |
1756 /* Check if they have Favorite Quote */ | |
1757 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1758 "Favorite Quote \n\n", 0, "My Homepage \n\nTake a look", '\n', NULL, | |
1759 _("Favorite Quote"), 0, NULL, NULL); | |
1760 | |
1761 if (!found) | |
1762 { | |
1763 gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1764 "Favorite Quote \n\n", 0, "last updated", '\n', NULL, | |
1765 _("Favorite Quote"), 0, NULL, NULL); | |
1766 } | |
1767 | |
1768 if (found) | |
1769 has_info = TRUE; | |
1770 | |
1771 /* Extract the last updated date and put it in */ | |
1772 found = gaim_markup_extract_info_field(stripped, stripped_len, s, | |
1773 " last updated:", 1, "\n", 0, NULL, _("Last Updated"), 0, | |
1774 NULL, msn_info_date_reformat); | |
1775 | |
1776 if (found) | |
1777 has_info = TRUE; | |
1778 #endif | |
1779 | |
1780 /* If we were able to fetch a homepage url earlier, stick it in there */ | |
1781 if (user_url != NULL) | |
1782 { | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1783 tmp = g_strdup_printf("<a href=\"%s\">%s</a>", user_url, user_url); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1784 gaim_notify_user_info_add_pair(user_info, _("Homepage"), tmp); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1785 g_free(tmp); |
14192 | 1786 g_free(user_url); |
1787 | |
1788 has_info = TRUE; | |
1789 } | |
1790 | |
1791 if (!has_info) | |
1792 { | |
1793 /* MSN doesn't actually distinguish between "unknown member" and | |
1794 * a known member with an empty profile. Try to explain this fact. | |
1795 * Note that if we have a nonempty tooltip_text, we know the user | |
1796 * exists. | |
1797 */ | |
1798 /* This doesn't work with the new spaces profiles - Stu 3/2/06 | |
1799 char *p = strstr(url_buffer, "Unknown Member </TITLE>"); | |
1800 * This might not work for long either ... */ | |
1801 char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\""); | |
1802 GaimBuddy *b = gaim_find_buddy | |
1803 (gaim_connection_get_account(info_data->gc), info_data->name); | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1804 gaim_notify_user_info_add_pair(user_info, _("Error retrieving profile"), |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1805 ((p && b) ? _("The user has not created a public profile.") : |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1806 (p ? _("MSN reported not being able to find the user's profile. " |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1807 "This either means that the user does not exist, " |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1808 "or that the user exists " |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1809 "but has not created a public profile.") : |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1810 _("Gaim could not find " /* This should never happen */ |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1811 "any information in the user's profile. " |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1812 "The user most likely does not exist.")))); |
14192 | 1813 } |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1814 |
14192 | 1815 /* put a link to the actual profile URL */ |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1816 tmp = g_strdup_printf("<a href=\"%s%s\">%s%s</a>", |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1817 PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1818 gaim_notify_user_info_add_pair(user_info, _("Profile URL"), tmp); |
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1819 g_free(tmp); |
14192 | 1820 |
1821 #if PHOTO_SUPPORT | |
1822 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ | |
1823 photo_url_text = msn_get_photo_url(url_text); | |
1824 | |
1825 /* Marshall the existing state */ | |
1826 info2_data = g_malloc0(sizeof(MsnGetInfoStepTwoData)); | |
1827 info2_data->info_data = info_data; | |
1828 info2_data->stripped = stripped; | |
1829 info2_data->url_buffer = url_buffer; | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1830 info2_data->user_info = user_info; |
14192 | 1831 info2_data->photo_url_text = photo_url_text; |
1832 | |
1833 /* Try to put the photo in there too, if there's one */ | |
1834 if (photo_url_text) | |
1835 { | |
14354 | 1836 gaim_util_fetch_url(photo_url_text, FALSE, NULL, FALSE, msn_got_photo, |
14192 | 1837 info2_data); |
1838 } | |
1839 else | |
1840 { | |
1841 /* Emulate a callback */ | |
14354 | 1842 /* TODO: Huh? */ |
1843 msn_got_photo(NULL, info2_data, NULL, 0, NULL); | |
14192 | 1844 } |
1845 } | |
1846 | |
1847 static void | |
14354 | 1848 msn_got_photo(GaimUtilFetchUrlData *url_data, gpointer user_data, |
1849 const gchar *url_text, size_t len, const gchar *error_message) | |
14192 | 1850 { |
14354 | 1851 MsnGetInfoStepTwoData *info2_data = (MsnGetInfoStepTwoData *)user_data; |
14192 | 1852 int id = -1; |
1853 | |
1854 /* Unmarshall the saved state */ | |
1855 MsnGetInfoData *info_data = info2_data->info_data; | |
1856 char *stripped = info2_data->stripped; | |
1857 char *url_buffer = info2_data->url_buffer; | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1858 GaimNotifyUserInfo *user_info = info2_data->user_info; |
14192 | 1859 char *photo_url_text = info2_data->photo_url_text; |
1860 | |
1861 /* Make sure the connection is still valid if we got here by fetching a photo url */ | |
14508
8bc34ef93e55
[gaim-migrate @ 17228]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14368
diff
changeset
|
1862 if (url_text && (error_message != NULL || |
8bc34ef93e55
[gaim-migrate @ 17228]
Evan Schoenberg <evan.s@dreskin.net>
parents:
14368
diff
changeset
|
1863 g_list_find(gaim_connections_get_all(), info_data->gc) == NULL)) |
14192 | 1864 { |
1865 gaim_debug_warning("msn", "invalid connection. ignoring buddy photo info.\n"); | |
1866 g_free(stripped); | |
1867 g_free(url_buffer); | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1868 g_free(user_info); |
14192 | 1869 g_free(info_data->name); |
1870 g_free(info_data); | |
1871 g_free(photo_url_text); | |
1872 g_free(info2_data); | |
1873 | |
1874 return; | |
1875 } | |
1876 | |
1877 /* Try to put the photo in there too, if there's one and is readable */ | |
14354 | 1878 if (user_data && url_text && len != 0) |
14192 | 1879 { |
1880 if (strstr(url_text, "400 Bad Request") | |
1881 || strstr(url_text, "403 Forbidden") | |
1882 || strstr(url_text, "404 Not Found")) | |
1883 { | |
1884 | |
1885 gaim_debug_info("msn", "Error getting %s: %s\n", | |
1886 photo_url_text, url_text); | |
1887 } | |
1888 else | |
1889 { | |
1890 char buf[1024]; | |
1891 gaim_debug_info("msn", "%s is %d bytes\n", photo_url_text, len); | |
1892 id = gaim_imgstore_add(url_text, len, NULL); | |
1893 g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id); | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1894 gaim_notify_user_info_prepend_pair(user_info, NULL, buf); |
14192 | 1895 } |
1896 } | |
1897 | |
1898 /* We continue here from msn_got_info, as if nothing has happened */ | |
1899 #endif | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1900 gaim_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); |
14192 | 1901 |
1902 g_free(stripped); | |
1903 g_free(url_buffer); | |
15144
b81e4e44b509
[gaim-migrate @ 17929]
Evan Schoenberg <evan.s@dreskin.net>
parents:
15131
diff
changeset
|
1904 gaim_notify_user_info_destroy(user_info); |
14192 | 1905 g_free(info_data->name); |
1906 g_free(info_data); | |
1907 #if PHOTO_SUPPORT | |
1908 g_free(photo_url_text); | |
1909 g_free(info2_data); | |
1910 if (id != -1) | |
1911 gaim_imgstore_unref(id); | |
1912 #endif | |
1913 } | |
1914 | |
1915 static void | |
1916 msn_get_info(GaimConnection *gc, const char *name) | |
1917 { | |
1918 MsnGetInfoData *data; | |
1919 char *url; | |
1920 | |
1921 data = g_new0(MsnGetInfoData, 1); | |
1922 data->gc = gc; | |
1923 data->name = g_strdup(name); | |
1924 | |
1925 url = g_strdup_printf("%s%s", PROFILE_URL, name); | |
1926 | |
14354 | 1927 gaim_util_fetch_url(url, FALSE, |
14192 | 1928 "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", |
1929 TRUE, msn_got_info, data); | |
1930 | |
1931 g_free(url); | |
1932 } | |
1933 | |
1934 static gboolean msn_load(GaimPlugin *plugin) | |
1935 { | |
1936 msn_notification_init(); | |
1937 msn_switchboard_init(); | |
1938 msn_sync_init(); | |
1939 | |
1940 return TRUE; | |
1941 } | |
1942 | |
1943 static gboolean msn_unload(GaimPlugin *plugin) | |
1944 { | |
1945 msn_notification_end(); | |
1946 msn_switchboard_end(); | |
1947 msn_sync_end(); | |
1948 | |
1949 return TRUE; | |
1950 } | |
1951 | |
1952 static GaimPluginProtocolInfo prpl_info = | |
1953 { | |
1954 OPT_PROTO_MAIL_CHECK, | |
1955 NULL, /* user_splits */ | |
1956 NULL, /* protocol_options */ | |
15131 | 1957 {"png", 0, 0, 96, 96, GAIM_ICON_SCALE_SEND}, /* icon_spec */ |
14192 | 1958 msn_list_icon, /* list_icon */ |
1959 msn_list_emblems, /* list_emblems */ | |
1960 msn_status_text, /* status_text */ | |
1961 msn_tooltip_text, /* tooltip_text */ | |
1962 msn_status_types, /* away_states */ | |
1963 msn_blist_node_menu, /* blist_node_menu */ | |
1964 NULL, /* chat_info */ | |
1965 NULL, /* chat_info_defaults */ | |
1966 msn_login, /* login */ | |
1967 msn_close, /* close */ | |
1968 msn_send_im, /* send_im */ | |
1969 NULL, /* set_info */ | |
1970 msn_send_typing, /* send_typing */ | |
1971 msn_get_info, /* get_info */ | |
1972 msn_set_status, /* set_away */ | |
1973 msn_set_idle, /* set_idle */ | |
1974 NULL, /* change_passwd */ | |
1975 msn_add_buddy, /* add_buddy */ | |
1976 NULL, /* add_buddies */ | |
1977 msn_rem_buddy, /* remove_buddy */ | |
1978 NULL, /* remove_buddies */ | |
1979 msn_add_permit, /* add_permit */ | |
1980 msn_add_deny, /* add_deny */ | |
1981 msn_rem_permit, /* rem_permit */ | |
1982 msn_rem_deny, /* rem_deny */ | |
1983 msn_set_permit_deny, /* set_permit_deny */ | |
1984 NULL, /* join_chat */ | |
1985 NULL, /* reject chat invite */ | |
1986 NULL, /* get_chat_name */ | |
1987 msn_chat_invite, /* chat_invite */ | |
1988 msn_chat_leave, /* chat_leave */ | |
1989 NULL, /* chat_whisper */ | |
1990 msn_chat_send, /* chat_send */ | |
1991 msn_keepalive, /* keepalive */ | |
1992 NULL, /* register_user */ | |
1993 NULL, /* get_cb_info */ | |
1994 NULL, /* get_cb_away */ | |
1995 NULL, /* alias_buddy */ | |
1996 msn_group_buddy, /* group_buddy */ | |
1997 msn_rename_group, /* rename_group */ | |
1998 NULL, /* buddy_free */ | |
1999 msn_convo_closed, /* convo_closed */ | |
2000 msn_normalize, /* normalize */ | |
2001 msn_set_buddy_icon, /* set_buddy_icon */ | |
2002 msn_remove_group, /* remove_group */ | |
2003 NULL, /* get_cb_real_name */ | |
2004 NULL, /* set_chat_topic */ | |
2005 NULL, /* find_blist_chat */ | |
2006 NULL, /* roomlist_get_list */ | |
2007 NULL, /* roomlist_cancel */ | |
2008 NULL, /* roomlist_expand_category */ | |
2009 msn_can_receive_file, /* can_receive_file */ | |
2010 msn_send_file, /* send_file */ | |
2011 msn_new_xfer, /* new_xfer */ | |
2012 NULL, /* offline_message */ | |
2013 NULL, /* whiteboard_prpl_ops */ | |
14543 | 2014 NULL, /* send_raw */ |
15124 | 2015 NULL, /* roomlist_room_serialize */ |
14192 | 2016 }; |
2017 | |
2018 static GaimPluginInfo info = | |
2019 { | |
2020 GAIM_PLUGIN_MAGIC, | |
2021 GAIM_MAJOR_VERSION, | |
2022 GAIM_MINOR_VERSION, | |
2023 GAIM_PLUGIN_PROTOCOL, /**< type */ | |
2024 NULL, /**< ui_requirement */ | |
2025 0, /**< flags */ | |
2026 NULL, /**< dependencies */ | |
2027 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
2028 | |
2029 "prpl-msn", /**< id */ | |
2030 "MSN", /**< name */ | |
2031 VERSION, /**< version */ | |
2032 /** summary */ | |
2033 N_("MSN Protocol Plugin"), | |
2034 /** description */ | |
2035 N_("MSN Protocol Plugin"), | |
2036 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ | |
2037 GAIM_WEBSITE, /**< homepage */ | |
2038 | |
2039 msn_load, /**< load */ | |
2040 msn_unload, /**< unload */ | |
2041 NULL, /**< destroy */ | |
2042 | |
2043 NULL, /**< ui_info */ | |
2044 &prpl_info, /**< extra_info */ | |
2045 NULL, /**< prefs_info */ | |
2046 msn_actions | |
2047 }; | |
2048 | |
2049 static void | |
2050 init_plugin(GaimPlugin *plugin) | |
2051 { | |
2052 GaimAccountOption *option; | |
2053 | |
2054 option = gaim_account_option_string_new(_("Server"), "server", | |
2055 MSN_SERVER); | |
2056 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
2057 option); | |
2058 | |
2059 option = gaim_account_option_int_new(_("Port"), "port", 1863); | |
2060 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
2061 option); | |
2062 | |
2063 option = gaim_account_option_bool_new(_("Use HTTP Method"), | |
2064 "http_method", FALSE); | |
2065 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
2066 option); | |
2067 | |
2068 option = gaim_account_option_bool_new(_("Show custom smileys"), | |
2069 "custom_smileys", TRUE); | |
2070 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
2071 option); | |
2072 | |
2073 gaim_cmd_register("nudge", "", GAIM_CMD_P_PRPL, | |
2074 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_PRPL_ONLY, | |
2075 "prpl-msn", msn_cmd_nudge, | |
2076 _("nudge: nudge a user to get their attention"), NULL); | |
2077 | |
2078 gaim_prefs_remove("/plugins/prpl/msn"); | |
2079 } | |
2080 | |
2081 GAIM_INIT_PLUGIN(msn, init_plugin, info); |