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