comparison libpurple/protocols/msn/msn.c @ 15823:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents 71af5b6209d5
children 391a79778f89 08db93bbd798 60bc06498746 4a099e4d0d09 be098f796b32
comparison
equal deleted inserted replaced
15822:84b0f9b23ede 15823:32c366eeeb99
1 /** 1 /**
2 * @file msn.c The MSN protocol plugin 2 * @file msn.c The MSN protocol plugin
3 * 3 *
4 * gaim 4 * purple
5 * 5 *
6 * Gaim is the legal property of its developers, whose names are too numerous 6 * Purple 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 7 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * source distribution. 8 * source distribution.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 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 11 * it under the terms of the GNU General Public License as published by
49 #include "imgstore.h" 49 #include "imgstore.h"
50 #endif 50 #endif
51 51
52 typedef struct 52 typedef struct
53 { 53 {
54 GaimConnection *gc; 54 PurpleConnection *gc;
55 const char *passport; 55 const char *passport;
56 56
57 } MsnMobileData; 57 } MsnMobileData;
58 58
59 typedef struct 59 typedef struct
60 { 60 {
61 GaimConnection *gc; 61 PurpleConnection *gc;
62 char *name; 62 char *name;
63 63
64 } MsnGetInfoData; 64 } MsnGetInfoData;
65 65
66 typedef struct 66 typedef struct
67 { 67 {
68 MsnGetInfoData *info_data; 68 MsnGetInfoData *info_data;
69 char *stripped; 69 char *stripped;
70 char *url_buffer; 70 char *url_buffer;
71 GaimNotifyUserInfo *user_info; 71 PurpleNotifyUserInfo *user_info;
72 char *photo_url_text; 72 char *photo_url_text;
73 73
74 } MsnGetInfoStepTwoData; 74 } MsnGetInfoStepTwoData;
75 75
76 static const char * 76 static const char *
77 msn_normalize(const GaimAccount *account, const char *str) 77 msn_normalize(const PurpleAccount *account, const char *str)
78 { 78 {
79 static char buf[BUF_LEN]; 79 static char buf[BUF_LEN];
80 char *tmp; 80 char *tmp;
81 81
82 g_return_val_if_fail(str != NULL, NULL); 82 g_return_val_if_fail(str != NULL, NULL);
89 g_free(tmp); 89 g_free(tmp);
90 90
91 return buf; 91 return buf;
92 } 92 }
93 93
94 static GaimCmdRet 94 static PurpleCmdRet
95 msn_cmd_nudge(GaimConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) 95 msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data)
96 { 96 {
97 GaimAccount *account = gaim_conversation_get_account(conv); 97 PurpleAccount *account = purple_conversation_get_account(conv);
98 GaimConnection *gc = gaim_account_get_connection(account); 98 PurpleConnection *gc = purple_account_get_connection(account);
99 MsnMessage *msg; 99 MsnMessage *msg;
100 MsnSession *session; 100 MsnSession *session;
101 MsnSwitchBoard *swboard; 101 MsnSwitchBoard *swboard;
102 102
103 msg = msn_message_new_nudge(); 103 msg = msn_message_new_nudge();
104 session = gc->proto_data; 104 session = gc->proto_data;
105 swboard = msn_session_get_swboard(session, gaim_conversation_get_name(conv), MSN_SB_FLAG_IM); 105 swboard = msn_session_get_swboard(session, purple_conversation_get_name(conv), MSN_SB_FLAG_IM);
106 106
107 if (swboard == NULL) 107 if (swboard == NULL)
108 return GAIM_CMD_RET_FAILED; 108 return PURPLE_CMD_RET_FAILED;
109 109
110 msn_switchboard_send_msg(swboard, msg, TRUE); 110 msn_switchboard_send_msg(swboard, msg, TRUE);
111 111
112 gaim_conversation_write(conv, NULL, _("You have just sent a Nudge!"), GAIM_MESSAGE_SYSTEM, time(NULL)); 112 purple_conversation_write(conv, NULL, _("You have just sent a Nudge!"), PURPLE_MESSAGE_SYSTEM, time(NULL));
113 113
114 return GAIM_CMD_RET_OK; 114 return PURPLE_CMD_RET_OK;
115 } 115 }
116 116
117 static void 117 static void
118 msn_act_id(GaimConnection *gc, const char *entry) 118 msn_act_id(PurpleConnection *gc, const char *entry)
119 { 119 {
120 MsnCmdProc *cmdproc; 120 MsnCmdProc *cmdproc;
121 MsnSession *session; 121 MsnSession *session;
122 GaimAccount *account; 122 PurpleAccount *account;
123 const char *alias; 123 const char *alias;
124 124
125 session = gc->proto_data; 125 session = gc->proto_data;
126 cmdproc = session->notification->cmdproc; 126 cmdproc = session->notification->cmdproc;
127 account = gaim_connection_get_account(gc); 127 account = purple_connection_get_account(gc);
128 128
129 if(entry && strlen(entry)) 129 if(entry && strlen(entry))
130 alias = gaim_url_encode(entry); 130 alias = purple_url_encode(entry);
131 else 131 else
132 alias = ""; 132 alias = "";
133 133
134 if (strlen(alias) > BUDDY_ALIAS_MAXLEN) 134 if (strlen(alias) > BUDDY_ALIAS_MAXLEN)
135 { 135 {
136 gaim_notify_error(gc, NULL, 136 purple_notify_error(gc, NULL,
137 _("Your new MSN friendly name is too long."), NULL); 137 _("Your new MSN friendly name is too long."), NULL);
138 return; 138 return;
139 } 139 }
140 140
141 msn_cmdproc_send(cmdproc, "REA", "%s %s", 141 msn_cmdproc_send(cmdproc, "REA", "%s %s",
142 gaim_account_get_username(account), 142 purple_account_get_username(account),
143 alias); 143 alias);
144 } 144 }
145 145
146 static void 146 static void
147 msn_set_prp(GaimConnection *gc, const char *type, const char *entry) 147 msn_set_prp(PurpleConnection *gc, const char *type, const char *entry)
148 { 148 {
149 MsnCmdProc *cmdproc; 149 MsnCmdProc *cmdproc;
150 MsnSession *session; 150 MsnSession *session;
151 151
152 session = gc->proto_data; 152 session = gc->proto_data;
157 msn_cmdproc_send(cmdproc, "PRP", "%s", type); 157 msn_cmdproc_send(cmdproc, "PRP", "%s", type);
158 } 158 }
159 else 159 else
160 { 160 {
161 msn_cmdproc_send(cmdproc, "PRP", "%s %s", type, 161 msn_cmdproc_send(cmdproc, "PRP", "%s %s", type,
162 gaim_url_encode(entry)); 162 purple_url_encode(entry));
163 } 163 }
164 } 164 }
165 165
166 static void 166 static void
167 msn_set_home_phone_cb(GaimConnection *gc, const char *entry) 167 msn_set_home_phone_cb(PurpleConnection *gc, const char *entry)
168 { 168 {
169 msn_set_prp(gc, "PHH", entry); 169 msn_set_prp(gc, "PHH", entry);
170 } 170 }
171 171
172 static void 172 static void
173 msn_set_work_phone_cb(GaimConnection *gc, const char *entry) 173 msn_set_work_phone_cb(PurpleConnection *gc, const char *entry)
174 { 174 {
175 msn_set_prp(gc, "PHW", entry); 175 msn_set_prp(gc, "PHW", entry);
176 } 176 }
177 177
178 static void 178 static void
179 msn_set_mobile_phone_cb(GaimConnection *gc, const char *entry) 179 msn_set_mobile_phone_cb(PurpleConnection *gc, const char *entry)
180 { 180 {
181 msn_set_prp(gc, "PHM", entry); 181 msn_set_prp(gc, "PHM", entry);
182 } 182 }
183 183
184 static void 184 static void
185 enable_msn_pages_cb(GaimConnection *gc) 185 enable_msn_pages_cb(PurpleConnection *gc)
186 { 186 {
187 msn_set_prp(gc, "MOB", "Y"); 187 msn_set_prp(gc, "MOB", "Y");
188 } 188 }
189 189
190 static void 190 static void
191 disable_msn_pages_cb(GaimConnection *gc) 191 disable_msn_pages_cb(PurpleConnection *gc)
192 { 192 {
193 msn_set_prp(gc, "MOB", "N"); 193 msn_set_prp(gc, "MOB", "N");
194 } 194 }
195 195
196 static void 196 static void
197 send_to_mobile(GaimConnection *gc, const char *who, const char *entry) 197 send_to_mobile(PurpleConnection *gc, const char *who, const char *entry)
198 { 198 {
199 MsnTransaction *trans; 199 MsnTransaction *trans;
200 MsnSession *session; 200 MsnSession *session;
201 MsnCmdProc *cmdproc; 201 MsnCmdProc *cmdproc;
202 MsnPage *page; 202 MsnPage *page;
234 } 234 }
235 235
236 /* -- */ 236 /* -- */
237 237
238 static void 238 static void
239 msn_show_set_friendly_name(GaimPluginAction *action) 239 msn_show_set_friendly_name(PurplePluginAction *action)
240 { 240 {
241 GaimConnection *gc; 241 PurpleConnection *gc;
242 242
243 gc = (GaimConnection *) action->context; 243 gc = (PurpleConnection *) action->context;
244 244
245 gaim_request_input(gc, NULL, _("Set your friendly name."), 245 purple_request_input(gc, NULL, _("Set your friendly name."),
246 _("This is the name that other MSN buddies will " 246 _("This is the name that other MSN buddies will "
247 "see you as."), 247 "see you as."),
248 gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, 248 purple_connection_get_display_name(gc), FALSE, FALSE, NULL,
249 _("OK"), G_CALLBACK(msn_act_id), 249 _("OK"), G_CALLBACK(msn_act_id),
250 _("Cancel"), NULL, gc); 250 _("Cancel"), NULL, gc);
251 } 251 }
252 252
253 static void 253 static void
254 msn_show_set_home_phone(GaimPluginAction *action) 254 msn_show_set_home_phone(PurplePluginAction *action)
255 { 255 {
256 GaimConnection *gc; 256 PurpleConnection *gc;
257 MsnSession *session; 257 MsnSession *session;
258 258
259 gc = (GaimConnection *) action->context; 259 gc = (PurpleConnection *) action->context;
260 session = gc->proto_data; 260 session = gc->proto_data;
261 261
262 gaim_request_input(gc, NULL, _("Set your home phone number."), NULL, 262 purple_request_input(gc, NULL, _("Set your home phone number."), NULL,
263 msn_user_get_home_phone(session->user), FALSE, FALSE, NULL, 263 msn_user_get_home_phone(session->user), FALSE, FALSE, NULL,
264 _("OK"), G_CALLBACK(msn_set_home_phone_cb), 264 _("OK"), G_CALLBACK(msn_set_home_phone_cb),
265 _("Cancel"), NULL, gc); 265 _("Cancel"), NULL, gc);
266 } 266 }
267 267
268 static void 268 static void
269 msn_show_set_work_phone(GaimPluginAction *action) 269 msn_show_set_work_phone(PurplePluginAction *action)
270 { 270 {
271 GaimConnection *gc; 271 PurpleConnection *gc;
272 MsnSession *session; 272 MsnSession *session;
273 273
274 gc = (GaimConnection *) action->context; 274 gc = (PurpleConnection *) action->context;
275 session = gc->proto_data; 275 session = gc->proto_data;
276 276
277 gaim_request_input(gc, NULL, _("Set your work phone number."), NULL, 277 purple_request_input(gc, NULL, _("Set your work phone number."), NULL,
278 msn_user_get_work_phone(session->user), FALSE, FALSE, NULL, 278 msn_user_get_work_phone(session->user), FALSE, FALSE, NULL,
279 _("OK"), G_CALLBACK(msn_set_work_phone_cb), 279 _("OK"), G_CALLBACK(msn_set_work_phone_cb),
280 _("Cancel"), NULL, gc); 280 _("Cancel"), NULL, gc);
281 } 281 }
282 282
283 static void 283 static void
284 msn_show_set_mobile_phone(GaimPluginAction *action) 284 msn_show_set_mobile_phone(PurplePluginAction *action)
285 { 285 {
286 GaimConnection *gc; 286 PurpleConnection *gc;
287 MsnSession *session; 287 MsnSession *session;
288 288
289 gc = (GaimConnection *) action->context; 289 gc = (PurpleConnection *) action->context;
290 session = gc->proto_data; 290 session = gc->proto_data;
291 291
292 gaim_request_input(gc, NULL, _("Set your mobile phone number."), NULL, 292 purple_request_input(gc, NULL, _("Set your mobile phone number."), NULL,
293 msn_user_get_mobile_phone(session->user), FALSE, FALSE, NULL, 293 msn_user_get_mobile_phone(session->user), FALSE, FALSE, NULL,
294 _("OK"), G_CALLBACK(msn_set_mobile_phone_cb), 294 _("OK"), G_CALLBACK(msn_set_mobile_phone_cb),
295 _("Cancel"), NULL, gc); 295 _("Cancel"), NULL, gc);
296 } 296 }
297 297
298 static void 298 static void
299 msn_show_set_mobile_pages(GaimPluginAction *action) 299 msn_show_set_mobile_pages(PurplePluginAction *action)
300 { 300 {
301 GaimConnection *gc; 301 PurpleConnection *gc;
302 302
303 gc = (GaimConnection *) action->context; 303 gc = (PurpleConnection *) action->context;
304 304
305 gaim_request_action(gc, NULL, _("Allow MSN Mobile pages?"), 305 purple_request_action(gc, NULL, _("Allow MSN Mobile pages?"),
306 _("Do you want to allow or disallow people on " 306 _("Do you want to allow or disallow people on "
307 "your buddy list to send you MSN Mobile pages " 307 "your buddy list to send you MSN Mobile pages "
308 "to your cell phone or other mobile device?"), 308 "to your cell phone or other mobile device?"),
309 -1, gc, 3, 309 -1, gc, 3,
310 _("Allow"), G_CALLBACK(enable_msn_pages_cb), 310 _("Allow"), G_CALLBACK(enable_msn_pages_cb),
311 _("Disallow"), G_CALLBACK(disable_msn_pages_cb), 311 _("Disallow"), G_CALLBACK(disable_msn_pages_cb),
312 _("Cancel"), NULL); 312 _("Cancel"), NULL);
313 } 313 }
314 314
315 static void 315 static void
316 msn_show_hotmail_inbox(GaimPluginAction *action) 316 msn_show_hotmail_inbox(PurplePluginAction *action)
317 { 317 {
318 GaimConnection *gc; 318 PurpleConnection *gc;
319 MsnSession *session; 319 MsnSession *session;
320 320
321 gc = (GaimConnection *) action->context; 321 gc = (PurpleConnection *) action->context;
322 session = gc->proto_data; 322 session = gc->proto_data;
323 323
324 if (session->passport_info.file == NULL) 324 if (session->passport_info.file == NULL)
325 { 325 {
326 gaim_notify_error(gc, NULL, 326 purple_notify_error(gc, NULL,
327 _("This Hotmail account may not be active."), NULL); 327 _("This Hotmail account may not be active."), NULL);
328 return; 328 return;
329 } 329 }
330 330
331 gaim_notify_uri(gc, session->passport_info.file); 331 purple_notify_uri(gc, session->passport_info.file);
332 } 332 }
333 333
334 static void 334 static void
335 show_send_to_mobile_cb(GaimBlistNode *node, gpointer ignored) 335 show_send_to_mobile_cb(PurpleBlistNode *node, gpointer ignored)
336 { 336 {
337 GaimBuddy *buddy; 337 PurpleBuddy *buddy;
338 GaimConnection *gc; 338 PurpleConnection *gc;
339 MsnSession *session; 339 MsnSession *session;
340 MsnMobileData *data; 340 MsnMobileData *data;
341 341
342 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); 342 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
343 343
344 buddy = (GaimBuddy *) node; 344 buddy = (PurpleBuddy *) node;
345 gc = gaim_account_get_connection(buddy->account); 345 gc = purple_account_get_connection(buddy->account);
346 346
347 session = gc->proto_data; 347 session = gc->proto_data;
348 348
349 data = g_new0(MsnMobileData, 1); 349 data = g_new0(MsnMobileData, 1);
350 data->gc = gc; 350 data->gc = gc;
351 data->passport = buddy->name; 351 data->passport = buddy->name;
352 352
353 gaim_request_input(gc, NULL, _("Send a mobile message."), NULL, 353 purple_request_input(gc, NULL, _("Send a mobile message."), NULL,
354 NULL, TRUE, FALSE, NULL, 354 NULL, TRUE, FALSE, NULL,
355 _("Page"), G_CALLBACK(send_to_mobile_cb), 355 _("Page"), G_CALLBACK(send_to_mobile_cb),
356 _("Close"), G_CALLBACK(close_mobile_page_cb), 356 _("Close"), G_CALLBACK(close_mobile_page_cb),
357 data); 357 data);
358 } 358 }
359 359
360 static void 360 static void
361 initiate_chat_cb(GaimBlistNode *node, gpointer data) 361 initiate_chat_cb(PurpleBlistNode *node, gpointer data)
362 { 362 {
363 GaimBuddy *buddy; 363 PurpleBuddy *buddy;
364 GaimConnection *gc; 364 PurpleConnection *gc;
365 365
366 MsnSession *session; 366 MsnSession *session;
367 MsnSwitchBoard *swboard; 367 MsnSwitchBoard *swboard;
368 368
369 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); 369 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
370 370
371 buddy = (GaimBuddy *) node; 371 buddy = (PurpleBuddy *) node;
372 gc = gaim_account_get_connection(buddy->account); 372 gc = purple_account_get_connection(buddy->account);
373 373
374 session = gc->proto_data; 374 session = gc->proto_data;
375 375
376 swboard = msn_switchboard_new(session); 376 swboard = msn_switchboard_new(session);
377 msn_switchboard_request(swboard); 377 msn_switchboard_request(swboard);
380 /* TODO: This might move somewhere else, after USR might be */ 380 /* TODO: This might move somewhere else, after USR might be */
381 swboard->chat_id = session->conv_seq++; 381 swboard->chat_id = session->conv_seq++;
382 swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat"); 382 swboard->conv = serv_got_joined_chat(gc, swboard->chat_id, "MSN Chat");
383 swboard->flag = MSN_SB_FLAG_IM; 383 swboard->flag = MSN_SB_FLAG_IM;
384 384
385 gaim_conv_chat_add_user(GAIM_CONV_CHAT(swboard->conv), 385 purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv),
386 gaim_account_get_username(buddy->account), NULL, GAIM_CBFLAGS_NONE, TRUE); 386 purple_account_get_username(buddy->account), NULL, PURPLE_CBFLAGS_NONE, TRUE);
387 } 387 }
388 388
389 static void 389 static void
390 t_msn_xfer_init(GaimXfer *xfer) 390 t_msn_xfer_init(PurpleXfer *xfer)
391 { 391 {
392 MsnSlpLink *slplink; 392 MsnSlpLink *slplink;
393 const char *filename; 393 const char *filename;
394 FILE *fp; 394 FILE *fp;
395 395
396 filename = gaim_xfer_get_local_filename(xfer); 396 filename = purple_xfer_get_local_filename(xfer);
397 397
398 slplink = xfer->data; 398 slplink = xfer->data;
399 399
400 if ((fp = g_fopen(filename, "rb")) == NULL) 400 if ((fp = g_fopen(filename, "rb")) == NULL)
401 { 401 {
402 GaimAccount *account; 402 PurpleAccount *account;
403 const char *who; 403 const char *who;
404 char *msg; 404 char *msg;
405 405
406 account = slplink->session->account; 406 account = slplink->session->account;
407 who = slplink->remote_user; 407 who = slplink->remote_user;
408 408
409 msg = g_strdup_printf(_("Error reading %s: \n%s.\n"), 409 msg = g_strdup_printf(_("Error reading %s: \n%s.\n"),
410 filename, strerror(errno)); 410 filename, strerror(errno));
411 gaim_xfer_error(gaim_xfer_get_type(xfer), account, xfer->who, msg); 411 purple_xfer_error(purple_xfer_get_type(xfer), account, xfer->who, msg);
412 gaim_xfer_cancel_local(xfer); 412 purple_xfer_cancel_local(xfer);
413 g_free(msg); 413 g_free(msg);
414 414
415 return; 415 return;
416 } 416 }
417 fclose(fp); 417 fclose(fp);
418 418
419 msn_slplink_request_ft(slplink, xfer); 419 msn_slplink_request_ft(slplink, xfer);
420 } 420 }
421 421
422 static GaimXfer* 422 static PurpleXfer*
423 msn_new_xfer(GaimConnection *gc, const char *who) 423 msn_new_xfer(PurpleConnection *gc, const char *who)
424 { 424 {
425 MsnSession *session; 425 MsnSession *session;
426 MsnSlpLink *slplink; 426 MsnSlpLink *slplink;
427 GaimXfer *xfer; 427 PurpleXfer *xfer;
428 428
429 session = gc->proto_data; 429 session = gc->proto_data;
430 430
431 xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who); 431 xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who);
432 if (xfer) 432 if (xfer)
433 { 433 {
434 slplink = msn_session_get_slplink(session, who); 434 slplink = msn_session_get_slplink(session, who);
435 435
436 xfer->data = slplink; 436 xfer->data = slplink;
437 437
438 gaim_xfer_set_init_fnc(xfer, t_msn_xfer_init); 438 purple_xfer_set_init_fnc(xfer, t_msn_xfer_init);
439 } 439 }
440 440
441 return xfer; 441 return xfer;
442 } 442 }
443 443
444 static void 444 static void
445 msn_send_file(GaimConnection *gc, const char *who, const char *file) 445 msn_send_file(PurpleConnection *gc, const char *who, const char *file)
446 { 446 {
447 GaimXfer *xfer = msn_new_xfer(gc, who); 447 PurpleXfer *xfer = msn_new_xfer(gc, who);
448 448
449 if (file) 449 if (file)
450 gaim_xfer_request_accepted(xfer, file); 450 purple_xfer_request_accepted(xfer, file);
451 else 451 else
452 gaim_xfer_request(xfer); 452 purple_xfer_request(xfer);
453 } 453 }
454 454
455 static gboolean 455 static gboolean
456 msn_can_receive_file(GaimConnection *gc, const char *who) 456 msn_can_receive_file(PurpleConnection *gc, const char *who)
457 { 457 {
458 GaimAccount *account; 458 PurpleAccount *account;
459 char *normal; 459 char *normal;
460 gboolean ret; 460 gboolean ret;
461 461
462 account = gaim_connection_get_account(gc); 462 account = purple_connection_get_account(gc);
463 463
464 normal = g_strdup(msn_normalize(account, gaim_account_get_username(account))); 464 normal = g_strdup(msn_normalize(account, purple_account_get_username(account)));
465 465
466 ret = strcmp(normal, msn_normalize(account, who)); 466 ret = strcmp(normal, msn_normalize(account, who));
467 467
468 g_free(normal); 468 g_free(normal);
469 469
473 /************************************************************************** 473 /**************************************************************************
474 * Protocol Plugin ops 474 * Protocol Plugin ops
475 **************************************************************************/ 475 **************************************************************************/
476 476
477 static const char * 477 static const char *
478 msn_list_icon(GaimAccount *a, GaimBuddy *b) 478 msn_list_icon(PurpleAccount *a, PurpleBuddy *b)
479 { 479 {
480 return "msn"; 480 return "msn";
481 } 481 }
482 482
483 static char * 483 static char *
484 msn_status_text(GaimBuddy *buddy) 484 msn_status_text(PurpleBuddy *buddy)
485 { 485 {
486 GaimPresence *presence; 486 PurplePresence *presence;
487 GaimStatus *status; 487 PurpleStatus *status;
488 488
489 presence = gaim_buddy_get_presence(buddy); 489 presence = purple_buddy_get_presence(buddy);
490 status = gaim_presence_get_active_status(presence); 490 status = purple_presence_get_active_status(presence);
491 491
492 if (!gaim_presence_is_available(presence) && !gaim_presence_is_idle(presence)) 492 if (!purple_presence_is_available(presence) && !purple_presence_is_idle(presence))
493 { 493 {
494 return g_strdup(gaim_status_get_name(status)); 494 return g_strdup(purple_status_get_name(status));
495 } 495 }
496 496
497 return NULL; 497 return NULL;
498 } 498 }
499 499
500 static void 500 static void
501 msn_tooltip_text(GaimBuddy *buddy, GaimNotifyUserInfo *user_info, gboolean full) 501 msn_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full)
502 { 502 {
503 MsnUser *user; 503 MsnUser *user;
504 GaimPresence *presence = gaim_buddy_get_presence(buddy); 504 PurplePresence *presence = purple_buddy_get_presence(buddy);
505 GaimStatus *status = gaim_presence_get_active_status(presence); 505 PurpleStatus *status = purple_presence_get_active_status(presence);
506 506
507 user = buddy->proto_data; 507 user = buddy->proto_data;
508 508
509 509
510 if (gaim_presence_is_online(presence)) 510 if (purple_presence_is_online(presence))
511 { 511 {
512 gaim_notify_user_info_add_pair(user_info, _("Status"), 512 purple_notify_user_info_add_pair(user_info, _("Status"),
513 (gaim_presence_is_idle(presence) ? _("Idle") : gaim_status_get_name(status))); 513 (purple_presence_is_idle(presence) ? _("Idle") : purple_status_get_name(status)));
514 } 514 }
515 515
516 if (full && user) 516 if (full && user)
517 { 517 {
518 gaim_notify_user_info_add_pair(user_info, _("Has you"), 518 purple_notify_user_info_add_pair(user_info, _("Has you"),
519 ((user->list_op & (1 << MSN_LIST_RL)) ? _("Yes") : _("No"))); 519 ((user->list_op & (1 << MSN_LIST_RL)) ? _("Yes") : _("No")));
520 } 520 }
521 521
522 /* XXX: This is being shown in non-full tooltips because the 522 /* XXX: This is being shown in non-full tooltips because the
523 * XXX: blocked icon overlay isn't always accurate for MSN. 523 * XXX: blocked icon overlay isn't always accurate for MSN.
524 * XXX: This can die as soon as gaim_privacy_check() knows that 524 * XXX: This can die as soon as purple_privacy_check() knows that
525 * XXX: this prpl always honors both the allow and deny lists. */ 525 * XXX: this prpl always honors both the allow and deny lists. */
526 if (user) 526 if (user)
527 { 527 {
528 gaim_notify_user_info_add_pair(user_info, _("Blocked"), 528 purple_notify_user_info_add_pair(user_info, _("Blocked"),
529 ((user->list_op & (1 << MSN_LIST_BL)) ? _("Yes") : _("No"))); 529 ((user->list_op & (1 << MSN_LIST_BL)) ? _("Yes") : _("No")));
530 } 530 }
531 } 531 }
532 532
533 static GList * 533 static GList *
534 msn_status_types(GaimAccount *account) 534 msn_status_types(PurpleAccount *account)
535 { 535 {
536 GaimStatusType *status; 536 PurpleStatusType *status;
537 GList *types = NULL; 537 GList *types = NULL;
538 538
539 status = gaim_status_type_new_full(GAIM_STATUS_AVAILABLE, 539 status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE,
540 NULL, NULL, FALSE, TRUE, FALSE); 540 NULL, NULL, FALSE, TRUE, FALSE);
541 types = g_list_append(types, status); 541 types = g_list_append(types, status);
542 542
543 status = gaim_status_type_new_full(GAIM_STATUS_AWAY, 543 status = purple_status_type_new_full(PURPLE_STATUS_AWAY,
544 NULL, NULL, FALSE, TRUE, FALSE); 544 NULL, NULL, FALSE, TRUE, FALSE);
545 types = g_list_append(types, status); 545 types = g_list_append(types, status);
546 546
547 status = gaim_status_type_new_full(GAIM_STATUS_AWAY, 547 status = purple_status_type_new_full(PURPLE_STATUS_AWAY,
548 "brb", _("Be Right Back"), FALSE, TRUE, FALSE); 548 "brb", _("Be Right Back"), FALSE, TRUE, FALSE);
549 types = g_list_append(types, status); 549 types = g_list_append(types, status);
550 550
551 status = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, 551 status = purple_status_type_new_full(PURPLE_STATUS_UNAVAILABLE,
552 "busy", _("Busy"), FALSE, TRUE, FALSE); 552 "busy", _("Busy"), FALSE, TRUE, FALSE);
553 types = g_list_append(types, status); 553 types = g_list_append(types, status);
554 554
555 status = gaim_status_type_new_full(GAIM_STATUS_UNAVAILABLE, 555 status = purple_status_type_new_full(PURPLE_STATUS_UNAVAILABLE,
556 "phone", _("On the Phone"), FALSE, TRUE, FALSE); 556 "phone", _("On the Phone"), FALSE, TRUE, FALSE);
557 types = g_list_append(types, status); 557 types = g_list_append(types, status);
558 558
559 status = gaim_status_type_new_full(GAIM_STATUS_AWAY, 559 status = purple_status_type_new_full(PURPLE_STATUS_AWAY,
560 "lunch", _("Out to Lunch"), FALSE, TRUE, FALSE); 560 "lunch", _("Out to Lunch"), FALSE, TRUE, FALSE);
561 types = g_list_append(types, status); 561 types = g_list_append(types, status);
562 562
563 status = gaim_status_type_new_full(GAIM_STATUS_INVISIBLE, 563 status = purple_status_type_new_full(PURPLE_STATUS_INVISIBLE,
564 NULL, NULL, FALSE, TRUE, FALSE); 564 NULL, NULL, FALSE, TRUE, FALSE);
565 types = g_list_append(types, status); 565 types = g_list_append(types, status);
566 566
567 status = gaim_status_type_new_full(GAIM_STATUS_OFFLINE, 567 status = purple_status_type_new_full(PURPLE_STATUS_OFFLINE,
568 NULL, NULL, FALSE, TRUE, FALSE); 568 NULL, NULL, FALSE, TRUE, FALSE);
569 types = g_list_append(types, status); 569 types = g_list_append(types, status);
570 570
571 status = gaim_status_type_new_full(GAIM_STATUS_MOBILE, 571 status = purple_status_type_new_full(PURPLE_STATUS_MOBILE,
572 "mobile", NULL, FALSE, FALSE, TRUE); 572 "mobile", NULL, FALSE, FALSE, TRUE);
573 types = g_list_append(types, status); 573 types = g_list_append(types, status);
574 574
575 return types; 575 return types;
576 } 576 }
577 577
578 static GList * 578 static GList *
579 msn_actions(GaimPlugin *plugin, gpointer context) 579 msn_actions(PurplePlugin *plugin, gpointer context)
580 { 580 {
581 GaimConnection *gc = (GaimConnection *)context; 581 PurpleConnection *gc = (PurpleConnection *)context;
582 GaimAccount *account; 582 PurpleAccount *account;
583 const char *user; 583 const char *user;
584 584
585 GList *m = NULL; 585 GList *m = NULL;
586 GaimPluginAction *act; 586 PurplePluginAction *act;
587 587
588 act = gaim_plugin_action_new(_("Set Friendly Name..."), 588 act = purple_plugin_action_new(_("Set Friendly Name..."),
589 msn_show_set_friendly_name); 589 msn_show_set_friendly_name);
590 m = g_list_append(m, act); 590 m = g_list_append(m, act);
591 m = g_list_append(m, NULL); 591 m = g_list_append(m, NULL);
592 592
593 act = gaim_plugin_action_new(_("Set Home Phone Number..."), 593 act = purple_plugin_action_new(_("Set Home Phone Number..."),
594 msn_show_set_home_phone); 594 msn_show_set_home_phone);
595 m = g_list_append(m, act); 595 m = g_list_append(m, act);
596 596
597 act = gaim_plugin_action_new(_("Set Work Phone Number..."), 597 act = purple_plugin_action_new(_("Set Work Phone Number..."),
598 msn_show_set_work_phone); 598 msn_show_set_work_phone);
599 m = g_list_append(m, act); 599 m = g_list_append(m, act);
600 600
601 act = gaim_plugin_action_new(_("Set Mobile Phone Number..."), 601 act = purple_plugin_action_new(_("Set Mobile Phone Number..."),
602 msn_show_set_mobile_phone); 602 msn_show_set_mobile_phone);
603 m = g_list_append(m, act); 603 m = g_list_append(m, act);
604 m = g_list_append(m, NULL); 604 m = g_list_append(m, NULL);
605 605
606 #if 0 606 #if 0
607 act = gaim_plugin_action_new(_("Enable/Disable Mobile Devices..."), 607 act = purple_plugin_action_new(_("Enable/Disable Mobile Devices..."),
608 msn_show_set_mobile_support); 608 msn_show_set_mobile_support);
609 m = g_list_append(m, act); 609 m = g_list_append(m, act);
610 #endif 610 #endif
611 611
612 act = gaim_plugin_action_new(_("Allow/Disallow Mobile Pages..."), 612 act = purple_plugin_action_new(_("Allow/Disallow Mobile Pages..."),
613 msn_show_set_mobile_pages); 613 msn_show_set_mobile_pages);
614 m = g_list_append(m, act); 614 m = g_list_append(m, act);
615 615
616 account = gaim_connection_get_account(gc); 616 account = purple_connection_get_account(gc);
617 user = msn_normalize(account, gaim_account_get_username(account)); 617 user = msn_normalize(account, purple_account_get_username(account));
618 618
619 if (strstr(user, "@hotmail.com") != NULL) 619 if (strstr(user, "@hotmail.com") != NULL)
620 { 620 {
621 m = g_list_append(m, NULL); 621 m = g_list_append(m, NULL);
622 act = gaim_plugin_action_new(_("Open Hotmail Inbox"), 622 act = purple_plugin_action_new(_("Open Hotmail Inbox"),
623 msn_show_hotmail_inbox); 623 msn_show_hotmail_inbox);
624 m = g_list_append(m, act); 624 m = g_list_append(m, act);
625 } 625 }
626 626
627 return m; 627 return m;
628 } 628 }
629 629
630 static GList * 630 static GList *
631 msn_buddy_menu(GaimBuddy *buddy) 631 msn_buddy_menu(PurpleBuddy *buddy)
632 { 632 {
633 MsnUser *user; 633 MsnUser *user;
634 634
635 GList *m = NULL; 635 GList *m = NULL;
636 GaimMenuAction *act; 636 PurpleMenuAction *act;
637 637
638 g_return_val_if_fail(buddy != NULL, NULL); 638 g_return_val_if_fail(buddy != NULL, NULL);
639 639
640 user = buddy->proto_data; 640 user = buddy->proto_data;
641 641
642 if (user != NULL) 642 if (user != NULL)
643 { 643 {
644 if (user->mobile) 644 if (user->mobile)
645 { 645 {
646 act = gaim_menu_action_new(_("Send to Mobile"), 646 act = purple_menu_action_new(_("Send to Mobile"),
647 GAIM_CALLBACK(show_send_to_mobile_cb), 647 PURPLE_CALLBACK(show_send_to_mobile_cb),
648 NULL, NULL); 648 NULL, NULL);
649 m = g_list_append(m, act); 649 m = g_list_append(m, act);
650 } 650 }
651 } 651 }
652 652
653 if (g_ascii_strcasecmp(buddy->name, 653 if (g_ascii_strcasecmp(buddy->name,
654 gaim_account_get_username(buddy->account))) 654 purple_account_get_username(buddy->account)))
655 { 655 {
656 act = gaim_menu_action_new(_("Initiate _Chat"), 656 act = purple_menu_action_new(_("Initiate _Chat"),
657 GAIM_CALLBACK(initiate_chat_cb), 657 PURPLE_CALLBACK(initiate_chat_cb),
658 NULL, NULL); 658 NULL, NULL);
659 m = g_list_append(m, act); 659 m = g_list_append(m, act);
660 } 660 }
661 661
662 return m; 662 return m;
663 } 663 }
664 664
665 static GList * 665 static GList *
666 msn_blist_node_menu(GaimBlistNode *node) 666 msn_blist_node_menu(PurpleBlistNode *node)
667 { 667 {
668 if(GAIM_BLIST_NODE_IS_BUDDY(node)) 668 if(PURPLE_BLIST_NODE_IS_BUDDY(node))
669 { 669 {
670 return msn_buddy_menu((GaimBuddy *) node); 670 return msn_buddy_menu((PurpleBuddy *) node);
671 } 671 }
672 else 672 else
673 { 673 {
674 return NULL; 674 return NULL;
675 } 675 }
676 } 676 }
677 677
678 static void 678 static void
679 msn_login(GaimAccount *account) 679 msn_login(PurpleAccount *account)
680 { 680 {
681 GaimConnection *gc; 681 PurpleConnection *gc;
682 MsnSession *session; 682 MsnSession *session;
683 const char *username; 683 const char *username;
684 const char *host; 684 const char *host;
685 gboolean http_method = FALSE; 685 gboolean http_method = FALSE;
686 int port; 686 int port;
687 687
688 gc = gaim_account_get_connection(account); 688 gc = purple_account_get_connection(account);
689 689
690 if (!gaim_ssl_is_supported()) 690 if (!purple_ssl_is_supported())
691 { 691 {
692 gc->wants_to_die = TRUE; 692 gc->wants_to_die = TRUE;
693 gaim_connection_error(gc, 693 purple_connection_error(gc,
694 _("SSL support is needed for MSN. Please install a supported " 694 _("SSL support is needed for MSN. Please install a supported "
695 "SSL library.")); 695 "SSL library."));
696 return; 696 return;
697 } 697 }
698 698
699 http_method = gaim_account_get_bool(account, "http_method", FALSE); 699 http_method = purple_account_get_bool(account, "http_method", FALSE);
700 700
701 host = gaim_account_get_string(account, "server", MSN_SERVER); 701 host = purple_account_get_string(account, "server", MSN_SERVER);
702 port = gaim_account_get_int(account, "port", MSN_PORT); 702 port = purple_account_get_int(account, "port", MSN_PORT);
703 703
704 session = msn_session_new(account); 704 session = msn_session_new(account);
705 705
706 gc->proto_data = session; 706 gc->proto_data = session;
707 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_FORMATTING_WBFO | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_FONTSIZE | GAIM_CONNECTION_NO_URLDESC; 707 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_FORMATTING_WBFO | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_FONTSIZE | PURPLE_CONNECTION_NO_URLDESC;
708 708
709 msn_session_set_login_step(session, MSN_LOGIN_STEP_START); 709 msn_session_set_login_step(session, MSN_LOGIN_STEP_START);
710 710
711 /* Hmm, I don't like this. */ 711 /* Hmm, I don't like this. */
712 /* XXX shx: Me neither */ 712 /* XXX shx: Me neither */
713 username = msn_normalize(account, gaim_account_get_username(account)); 713 username = msn_normalize(account, purple_account_get_username(account));
714 714
715 if (strcmp(username, gaim_account_get_username(account))) 715 if (strcmp(username, purple_account_get_username(account)))
716 gaim_account_set_username(account, username); 716 purple_account_set_username(account, username);
717 717
718 if (!msn_session_connect(session, host, port, http_method)) 718 if (!msn_session_connect(session, host, port, http_method))
719 gaim_connection_error(gc, _("Failed to connect to server.")); 719 purple_connection_error(gc, _("Failed to connect to server."));
720 } 720 }
721 721
722 static void 722 static void
723 msn_close(GaimConnection *gc) 723 msn_close(PurpleConnection *gc)
724 { 724 {
725 MsnSession *session; 725 MsnSession *session;
726 726
727 session = gc->proto_data; 727 session = gc->proto_data;
728 728
732 732
733 gc->proto_data = NULL; 733 gc->proto_data = NULL;
734 } 734 }
735 735
736 static int 736 static int
737 msn_send_im(GaimConnection *gc, const char *who, const char *message, 737 msn_send_im(PurpleConnection *gc, const char *who, const char *message,
738 GaimMessageFlags flags) 738 PurpleMessageFlags flags)
739 { 739 {
740 GaimAccount *account; 740 PurpleAccount *account;
741 GaimBuddy *buddy = gaim_find_buddy(gc->account, who); 741 PurpleBuddy *buddy = purple_find_buddy(gc->account, who);
742 MsnMessage *msg; 742 MsnMessage *msg;
743 char *msgformat; 743 char *msgformat;
744 char *msgtext; 744 char *msgtext;
745 745
746 account = gaim_connection_get_account(gc); 746 account = purple_connection_get_account(gc);
747 747
748 if (buddy) { 748 if (buddy) {
749 GaimPresence *p = gaim_buddy_get_presence(buddy); 749 PurplePresence *p = purple_buddy_get_presence(buddy);
750 if (gaim_presence_is_status_primitive_active(p, GAIM_STATUS_MOBILE)) { 750 if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) {
751 char *text = gaim_markup_strip_html(message); 751 char *text = purple_markup_strip_html(message);
752 send_to_mobile(gc, who, text); 752 send_to_mobile(gc, who, text);
753 g_free(text); 753 g_free(text);
754 return 1; 754 return 1;
755 } 755 }
756 } 756 }
769 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat); 769 msn_message_set_attr(msg, "X-MMS-IM-Format", msgformat);
770 770
771 g_free(msgformat); 771 g_free(msgformat);
772 g_free(msgtext); 772 g_free(msgtext);
773 773
774 if (g_ascii_strcasecmp(who, gaim_account_get_username(account))) 774 if (g_ascii_strcasecmp(who, purple_account_get_username(account)))
775 { 775 {
776 MsnSession *session; 776 MsnSession *session;
777 MsnSwitchBoard *swboard; 777 MsnSwitchBoard *swboard;
778 778
779 session = gc->proto_data; 779 session = gc->proto_data;
810 810
811 return 1; 811 return 1;
812 } 812 }
813 813
814 static unsigned int 814 static unsigned int
815 msn_send_typing(GaimConnection *gc, const char *who, GaimTypingState state) 815 msn_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state)
816 { 816 {
817 GaimAccount *account; 817 PurpleAccount *account;
818 MsnSession *session; 818 MsnSession *session;
819 MsnSwitchBoard *swboard; 819 MsnSwitchBoard *swboard;
820 MsnMessage *msg; 820 MsnMessage *msg;
821 821
822 account = gaim_connection_get_account(gc); 822 account = purple_connection_get_account(gc);
823 session = gc->proto_data; 823 session = gc->proto_data;
824 824
825 /* 825 /*
826 * TODO: I feel like this should be "if (state != GAIM_TYPING)" 826 * TODO: I feel like this should be "if (state != PURPLE_TYPING)"
827 * but this is how it was before, and I don't want to break 827 * but this is how it was before, and I don't want to break
828 * anything. --KingAnt 828 * anything. --KingAnt
829 */ 829 */
830 if (state == GAIM_NOT_TYPING) 830 if (state == PURPLE_NOT_TYPING)
831 return 0; 831 return 0;
832 832
833 if (!g_ascii_strcasecmp(who, gaim_account_get_username(account))) 833 if (!g_ascii_strcasecmp(who, purple_account_get_username(account)))
834 { 834 {
835 /* We'll just fake it, since we're sending to ourself. */ 835 /* We'll just fake it, since we're sending to ourself. */
836 serv_got_typing(gc, who, MSN_TYPING_RECV_TIMEOUT, GAIM_TYPING); 836 serv_got_typing(gc, who, MSN_TYPING_RECV_TIMEOUT, PURPLE_TYPING);
837 837
838 return MSN_TYPING_SEND_TIMEOUT; 838 return MSN_TYPING_SEND_TIMEOUT;
839 } 839 }
840 840
841 swboard = msn_session_find_swboard(session, who); 841 swboard = msn_session_find_swboard(session, who);
847 847
848 msg = msn_message_new(MSN_MSG_TYPING); 848 msg = msn_message_new(MSN_MSG_TYPING);
849 msn_message_set_content_type(msg, "text/x-msmsgscontrol"); 849 msn_message_set_content_type(msg, "text/x-msmsgscontrol");
850 msn_message_set_flag(msg, 'U'); 850 msn_message_set_flag(msg, 'U');
851 msn_message_set_attr(msg, "TypingUser", 851 msn_message_set_attr(msg, "TypingUser",
852 gaim_account_get_username(account)); 852 purple_account_get_username(account));
853 msn_message_set_bin_data(msg, "\r\n", 2); 853 msn_message_set_bin_data(msg, "\r\n", 2);
854 854
855 msn_switchboard_send_msg(swboard, msg, FALSE); 855 msn_switchboard_send_msg(swboard, msg, FALSE);
856 856
857 msn_message_destroy(msg); 857 msn_message_destroy(msg);
858 858
859 return MSN_TYPING_SEND_TIMEOUT; 859 return MSN_TYPING_SEND_TIMEOUT;
860 } 860 }
861 861
862 static void 862 static void
863 msn_set_status(GaimAccount *account, GaimStatus *status) 863 msn_set_status(PurpleAccount *account, PurpleStatus *status)
864 { 864 {
865 GaimConnection *gc; 865 PurpleConnection *gc;
866 MsnSession *session; 866 MsnSession *session;
867 867
868 gc = gaim_account_get_connection(account); 868 gc = purple_account_get_connection(account);
869 869
870 if (gc != NULL) 870 if (gc != NULL)
871 { 871 {
872 session = gc->proto_data; 872 session = gc->proto_data;
873 msn_change_status(session); 873 msn_change_status(session);
874 } 874 }
875 } 875 }
876 876
877 static void 877 static void
878 msn_set_idle(GaimConnection *gc, int idle) 878 msn_set_idle(PurpleConnection *gc, int idle)
879 { 879 {
880 MsnSession *session; 880 MsnSession *session;
881 881
882 session = gc->proto_data; 882 session = gc->proto_data;
883 883
933 user->list_op |= (1 << list_id); 933 user->list_op |= (1 << list_id);
934 } 934 }
935 #endif 935 #endif
936 936
937 static void 937 static void
938 msn_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) 938 msn_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
939 { 939 {
940 MsnSession *session; 940 MsnSession *session;
941 MsnUserList *userlist; 941 MsnUserList *userlist;
942 const char *who; 942 const char *who;
943 943
949 { 949 {
950 #if 0 950 #if 0
951 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL, 951 fake_userlist_add_buddy(session->sync_userlist, who, MSN_LIST_FL,
952 group ? group->name : NULL); 952 group ? group->name : NULL);
953 #else 953 #else
954 gaim_debug_error("msn", "msn_add_buddy called before connected\n"); 954 purple_debug_error("msn", "msn_add_buddy called before connected\n");
955 #endif 955 #endif
956 956
957 return; 957 return;
958 } 958 }
959 959
960 #if 0 960 #if 0
961 if (group != NULL && group->name != NULL) 961 if (group != NULL && group->name != NULL)
962 gaim_debug_info("msn", "msn_add_buddy: %s, %s\n", who, group->name); 962 purple_debug_info("msn", "msn_add_buddy: %s, %s\n", who, group->name);
963 else 963 else
964 gaim_debug_info("msn", "msn_add_buddy: %s\n", who); 964 purple_debug_info("msn", "msn_add_buddy: %s\n", who);
965 #endif 965 #endif
966 966
967 #if 0 967 #if 0
968 /* Which is the max? */ 968 /* Which is the max? */
969 if (session->fl_users_count >= 150) 969 if (session->fl_users_count >= 150)
970 { 970 {
971 gaim_debug_info("msn", "Too many buddies\n"); 971 purple_debug_info("msn", "Too many buddies\n");
972 /* Buddy list full */ 972 /* Buddy list full */
973 /* TODO: gaim should be notified of this */ 973 /* TODO: purple should be notified of this */
974 return; 974 return;
975 } 975 }
976 #endif 976 #endif
977 977
978 /* XXX - Would group ever be NULL here? I don't think so... 978 /* XXX - Would group ever be NULL here? I don't think so...
981 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL, 981 msn_userlist_add_buddy(userlist, who, MSN_LIST_FL,
982 group ? group->name : NULL); 982 group ? group->name : NULL);
983 } 983 }
984 984
985 static void 985 static void
986 msn_rem_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) 986 msn_rem_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
987 { 987 {
988 MsnSession *session; 988 MsnSession *session;
989 MsnUserList *userlist; 989 MsnUserList *userlist;
990 990
991 session = gc->proto_data; 991 session = gc->proto_data;
997 /* XXX - Does buddy->name need to be msn_normalize'd here? --KingAnt */ 997 /* XXX - Does buddy->name need to be msn_normalize'd here? --KingAnt */
998 msn_userlist_rem_buddy(userlist, buddy->name, MSN_LIST_FL, group->name); 998 msn_userlist_rem_buddy(userlist, buddy->name, MSN_LIST_FL, group->name);
999 } 999 }
1000 1000
1001 static void 1001 static void
1002 msn_add_permit(GaimConnection *gc, const char *who) 1002 msn_add_permit(PurpleConnection *gc, const char *who)
1003 { 1003 {
1004 MsnSession *session; 1004 MsnSession *session;
1005 MsnUserList *userlist; 1005 MsnUserList *userlist;
1006 MsnUser *user; 1006 MsnUser *user;
1007 1007
1017 1017
1018 msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL); 1018 msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL);
1019 } 1019 }
1020 1020
1021 static void 1021 static void
1022 msn_add_deny(GaimConnection *gc, const char *who) 1022 msn_add_deny(PurpleConnection *gc, const char *who)
1023 { 1023 {
1024 MsnSession *session; 1024 MsnSession *session;
1025 MsnUserList *userlist; 1025 MsnUserList *userlist;
1026 MsnUser *user; 1026 MsnUser *user;
1027 1027
1037 1037
1038 msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL); 1038 msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL);
1039 } 1039 }
1040 1040
1041 static void 1041 static void
1042 msn_rem_permit(GaimConnection *gc, const char *who) 1042 msn_rem_permit(PurpleConnection *gc, const char *who)
1043 { 1043 {
1044 MsnSession *session; 1044 MsnSession *session;
1045 MsnUserList *userlist; 1045 MsnUserList *userlist;
1046 MsnUser *user; 1046 MsnUser *user;
1047 1047
1058 if (user != NULL && user->list_op & MSN_LIST_RL_OP) 1058 if (user != NULL && user->list_op & MSN_LIST_RL_OP)
1059 msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL); 1059 msn_userlist_add_buddy(userlist, who, MSN_LIST_BL, NULL);
1060 } 1060 }
1061 1061
1062 static void 1062 static void
1063 msn_rem_deny(GaimConnection *gc, const char *who) 1063 msn_rem_deny(PurpleConnection *gc, const char *who)
1064 { 1064 {
1065 MsnSession *session; 1065 MsnSession *session;
1066 MsnUserList *userlist; 1066 MsnUserList *userlist;
1067 MsnUser *user; 1067 MsnUser *user;
1068 1068
1079 if (user != NULL && user->list_op & MSN_LIST_RL_OP) 1079 if (user != NULL && user->list_op & MSN_LIST_RL_OP)
1080 msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL); 1080 msn_userlist_add_buddy(userlist, who, MSN_LIST_AL, NULL);
1081 } 1081 }
1082 1082
1083 static void 1083 static void
1084 msn_set_permit_deny(GaimConnection *gc) 1084 msn_set_permit_deny(PurpleConnection *gc)
1085 { 1085 {
1086 GaimAccount *account; 1086 PurpleAccount *account;
1087 MsnSession *session; 1087 MsnSession *session;
1088 MsnCmdProc *cmdproc; 1088 MsnCmdProc *cmdproc;
1089 1089
1090 account = gaim_connection_get_account(gc); 1090 account = purple_connection_get_account(gc);
1091 session = gc->proto_data; 1091 session = gc->proto_data;
1092 cmdproc = session->notification->cmdproc; 1092 cmdproc = session->notification->cmdproc;
1093 1093
1094 if (account->perm_deny == GAIM_PRIVACY_ALLOW_ALL || 1094 if (account->perm_deny == PURPLE_PRIVACY_ALLOW_ALL ||
1095 account->perm_deny == GAIM_PRIVACY_DENY_USERS) 1095 account->perm_deny == PURPLE_PRIVACY_DENY_USERS)
1096 { 1096 {
1097 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL"); 1097 msn_cmdproc_send(cmdproc, "BLP", "%s", "AL");
1098 } 1098 }
1099 else 1099 else
1100 { 1100 {
1101 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL"); 1101 msn_cmdproc_send(cmdproc, "BLP", "%s", "BL");
1102 } 1102 }
1103 } 1103 }
1104 1104
1105 static void 1105 static void
1106 msn_chat_invite(GaimConnection *gc, int id, const char *msg, 1106 msn_chat_invite(PurpleConnection *gc, int id, const char *msg,
1107 const char *who) 1107 const char *who)
1108 { 1108 {
1109 MsnSession *session; 1109 MsnSession *session;
1110 MsnSwitchBoard *swboard; 1110 MsnSwitchBoard *swboard;
1111 1111
1117 { 1117 {
1118 /* if we have no switchboard, everyone else left the chat already */ 1118 /* if we have no switchboard, everyone else left the chat already */
1119 swboard = msn_switchboard_new(session); 1119 swboard = msn_switchboard_new(session);
1120 msn_switchboard_request(swboard); 1120 msn_switchboard_request(swboard);
1121 swboard->chat_id = id; 1121 swboard->chat_id = id;
1122 swboard->conv = gaim_find_chat(gc, id); 1122 swboard->conv = purple_find_chat(gc, id);
1123 } 1123 }
1124 1124
1125 swboard->flag |= MSN_SB_FLAG_IM; 1125 swboard->flag |= MSN_SB_FLAG_IM;
1126 1126
1127 msn_switchboard_request_add_user(swboard, who); 1127 msn_switchboard_request_add_user(swboard, who);
1128 } 1128 }
1129 1129
1130 static void 1130 static void
1131 msn_chat_leave(GaimConnection *gc, int id) 1131 msn_chat_leave(PurpleConnection *gc, int id)
1132 { 1132 {
1133 MsnSession *session; 1133 MsnSession *session;
1134 MsnSwitchBoard *swboard; 1134 MsnSwitchBoard *swboard;
1135 GaimConversation *conv; 1135 PurpleConversation *conv;
1136 1136
1137 session = gc->proto_data; 1137 session = gc->proto_data;
1138 1138
1139 swboard = msn_session_find_swboard_with_id(session, id); 1139 swboard = msn_session_find_swboard_with_id(session, id);
1140 1140
1154 swboard->conv = NULL; 1154 swboard->conv = NULL;
1155 } 1155 }
1156 } 1156 }
1157 1157
1158 static int 1158 static int
1159 msn_chat_send(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) 1159 msn_chat_send(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags)
1160 { 1160 {
1161 GaimAccount *account; 1161 PurpleAccount *account;
1162 MsnSession *session; 1162 MsnSession *session;
1163 MsnSwitchBoard *swboard; 1163 MsnSwitchBoard *swboard;
1164 MsnMessage *msg; 1164 MsnMessage *msg;
1165 char *msgformat; 1165 char *msgformat;
1166 char *msgtext; 1166 char *msgtext;
1167 1167
1168 account = gaim_connection_get_account(gc); 1168 account = purple_connection_get_account(gc);
1169 session = gc->proto_data; 1169 session = gc->proto_data;
1170 swboard = msn_session_find_swboard_with_id(session, id); 1170 swboard = msn_session_find_swboard_with_id(session, id);
1171 1171
1172 if (swboard == NULL) 1172 if (swboard == NULL)
1173 return -EINVAL; 1173 return -EINVAL;
1193 msn_message_destroy(msg); 1193 msn_message_destroy(msg);
1194 1194
1195 g_free(msgformat); 1195 g_free(msgformat);
1196 g_free(msgtext); 1196 g_free(msgtext);
1197 1197
1198 serv_got_chat_in(gc, id, gaim_account_get_username(account), 0, 1198 serv_got_chat_in(gc, id, purple_account_get_username(account), 0,
1199 message, time(NULL)); 1199 message, time(NULL));
1200 1200
1201 return 0; 1201 return 0;
1202 } 1202 }
1203 1203
1204 static void 1204 static void
1205 msn_keepalive(GaimConnection *gc) 1205 msn_keepalive(PurpleConnection *gc)
1206 { 1206 {
1207 MsnSession *session; 1207 MsnSession *session;
1208 1208
1209 session = gc->proto_data; 1209 session = gc->proto_data;
1210 1210
1217 msn_cmdproc_send_quick(cmdproc, "PNG", NULL, NULL); 1217 msn_cmdproc_send_quick(cmdproc, "PNG", NULL, NULL);
1218 } 1218 }
1219 } 1219 }
1220 1220
1221 static void 1221 static void
1222 msn_group_buddy(GaimConnection *gc, const char *who, 1222 msn_group_buddy(PurpleConnection *gc, const char *who,
1223 const char *old_group_name, const char *new_group_name) 1223 const char *old_group_name, const char *new_group_name)
1224 { 1224 {
1225 MsnSession *session; 1225 MsnSession *session;
1226 MsnUserList *userlist; 1226 MsnUserList *userlist;
1227 1227
1230 1230
1231 msn_userlist_move_buddy(userlist, who, old_group_name, new_group_name); 1231 msn_userlist_move_buddy(userlist, who, old_group_name, new_group_name);
1232 } 1232 }
1233 1233
1234 static void 1234 static void
1235 msn_rename_group(GaimConnection *gc, const char *old_name, 1235 msn_rename_group(PurpleConnection *gc, const char *old_name,
1236 GaimGroup *group, GList *moved_buddies) 1236 PurpleGroup *group, GList *moved_buddies)
1237 { 1237 {
1238 MsnSession *session; 1238 MsnSession *session;
1239 MsnCmdProc *cmdproc; 1239 MsnCmdProc *cmdproc;
1240 int old_gid; 1240 int old_gid;
1241 const char *enc_new_group_name; 1241 const char *enc_new_group_name;
1242 1242
1243 session = gc->proto_data; 1243 session = gc->proto_data;
1244 cmdproc = session->notification->cmdproc; 1244 cmdproc = session->notification->cmdproc;
1245 enc_new_group_name = gaim_url_encode(group->name); 1245 enc_new_group_name = purple_url_encode(group->name);
1246 1246
1247 old_gid = msn_userlist_find_group_id(session->userlist, old_name); 1247 old_gid = msn_userlist_find_group_id(session->userlist, old_name);
1248 1248
1249 if (old_gid >= 0) 1249 if (old_gid >= 0)
1250 { 1250 {
1256 msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name); 1256 msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name);
1257 } 1257 }
1258 } 1258 }
1259 1259
1260 static void 1260 static void
1261 msn_convo_closed(GaimConnection *gc, const char *who) 1261 msn_convo_closed(PurpleConnection *gc, const char *who)
1262 { 1262 {
1263 MsnSession *session; 1263 MsnSession *session;
1264 MsnSwitchBoard *swboard; 1264 MsnSwitchBoard *swboard;
1265 GaimConversation *conv; 1265 PurpleConversation *conv;
1266 1266
1267 session = gc->proto_data; 1267 session = gc->proto_data;
1268 1268
1269 swboard = msn_session_find_swboard(session, who); 1269 swboard = msn_session_find_swboard(session, who);
1270 1270
1288 swboard->conv = NULL; 1288 swboard->conv = NULL;
1289 } 1289 }
1290 } 1290 }
1291 1291
1292 static void 1292 static void
1293 msn_set_buddy_icon(GaimConnection *gc, const char *filename) 1293 msn_set_buddy_icon(PurpleConnection *gc, const char *filename)
1294 { 1294 {
1295 MsnSession *session; 1295 MsnSession *session;
1296 MsnUser *user; 1296 MsnUser *user;
1297 1297
1298 session = gc->proto_data; 1298 session = gc->proto_data;
1302 1302
1303 msn_change_status(session); 1303 msn_change_status(session);
1304 } 1304 }
1305 1305
1306 static void 1306 static void
1307 msn_remove_group(GaimConnection *gc, GaimGroup *group) 1307 msn_remove_group(PurpleConnection *gc, PurpleGroup *group)
1308 { 1308 {
1309 MsnSession *session; 1309 MsnSession *session;
1310 MsnCmdProc *cmdproc; 1310 MsnCmdProc *cmdproc;
1311 int group_id; 1311 int group_id;
1312 1312
1321 1321
1322 /** 1322 /**
1323 * Extract info text from info_data and add it to user_info 1323 * Extract info text from info_data and add it to user_info
1324 */ 1324 */
1325 static gboolean 1325 static gboolean
1326 msn_tooltip_extract_info_text(GaimNotifyUserInfo *user_info, MsnGetInfoData *info_data) 1326 msn_tooltip_extract_info_text(PurpleNotifyUserInfo *user_info, MsnGetInfoData *info_data)
1327 { 1327 {
1328 GaimBuddy *b; 1328 PurpleBuddy *b;
1329 1329
1330 b = gaim_find_buddy(gaim_connection_get_account(info_data->gc), 1330 b = purple_find_buddy(purple_connection_get_account(info_data->gc),
1331 info_data->name); 1331 info_data->name);
1332 1332
1333 if (b) 1333 if (b)
1334 { 1334 {
1335 char *tmp; 1335 char *tmp;
1336 1336
1337 if (b->alias && b->alias[0]) 1337 if (b->alias && b->alias[0])
1338 { 1338 {
1339 char *aliastext = g_markup_escape_text(b->alias, -1); 1339 char *aliastext = g_markup_escape_text(b->alias, -1);
1340 gaim_notify_user_info_add_pair(user_info, _("Alias"), aliastext); 1340 purple_notify_user_info_add_pair(user_info, _("Alias"), aliastext);
1341 g_free(aliastext); 1341 g_free(aliastext);
1342 } 1342 }
1343 1343
1344 if (b->server_alias) 1344 if (b->server_alias)
1345 { 1345 {
1346 char *nicktext = g_markup_escape_text(b->server_alias, -1); 1346 char *nicktext = g_markup_escape_text(b->server_alias, -1);
1347 tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext); 1347 tmp = g_strdup_printf("<font sml=\"msn\">%s</font><br>", nicktext);
1348 gaim_notify_user_info_add_pair(user_info, _("Nickname"), tmp); 1348 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp);
1349 g_free(tmp); 1349 g_free(tmp);
1350 g_free(nicktext); 1350 g_free(nicktext);
1351 } 1351 }
1352 1352
1353 /* Add the tooltip information */ 1353 /* Add the tooltip information */
1375 return g_strndup(p, q - p); 1375 return g_strndup(p, q - p);
1376 1376
1377 return NULL; 1377 return NULL;
1378 } 1378 }
1379 1379
1380 static void msn_got_photo(GaimUtilFetchUrlData *url_data, gpointer data, 1380 static void msn_got_photo(PurpleUtilFetchUrlData *url_data, gpointer data,
1381 const gchar *url_text, size_t len, const gchar *error_message); 1381 const gchar *url_text, size_t len, const gchar *error_message);
1382 1382
1383 #endif 1383 #endif
1384 1384
1385 #if 0 1385 #if 0
1386 static char *msn_info_date_reformat(const char *field, size_t len) 1386 static char *msn_info_date_reformat(const char *field, size_t len)
1387 { 1387 {
1388 char *tmp = g_strndup(field, len); 1388 char *tmp = g_strndup(field, len);
1389 time_t t = gaim_str_to_time(tmp, FALSE, NULL, NULL, NULL); 1389 time_t t = purple_str_to_time(tmp, FALSE, NULL, NULL, NULL);
1390 1390
1391 g_free(tmp); 1391 g_free(tmp);
1392 return g_strdup(gaim_date_format_short(localtime(&t))); 1392 return g_strdup(purple_date_format_short(localtime(&t)));
1393 } 1393 }
1394 #endif 1394 #endif
1395 1395
1396 #define MSN_GOT_INFO_GET_FIELD(a, b) \ 1396 #define MSN_GOT_INFO_GET_FIELD(a, b) \
1397 found = gaim_markup_extract_info_field(stripped, stripped_len, user_info, \ 1397 found = purple_markup_extract_info_field(stripped, stripped_len, user_info, \
1398 "\n" a ":", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \ 1398 "\n" a ":", 0, "\n", 0, "Undisclosed", b, 0, NULL, NULL); \
1399 if (found) \ 1399 if (found) \
1400 sect_info = TRUE; 1400 sect_info = TRUE;
1401 1401
1402 static void 1402 static void
1403 msn_got_info(GaimUtilFetchUrlData *url_data, gpointer data, 1403 msn_got_info(PurpleUtilFetchUrlData *url_data, gpointer data,
1404 const gchar *url_text, size_t len, const gchar *error_message) 1404 const gchar *url_text, size_t len, const gchar *error_message)
1405 { 1405 {
1406 MsnGetInfoData *info_data = (MsnGetInfoData *)data; 1406 MsnGetInfoData *info_data = (MsnGetInfoData *)data;
1407 GaimNotifyUserInfo *user_info; 1407 PurpleNotifyUserInfo *user_info;
1408 char *stripped, *p, *q, *tmp; 1408 char *stripped, *p, *q, *tmp;
1409 char *user_url = NULL; 1409 char *user_url = NULL;
1410 gboolean found; 1410 gboolean found;
1411 gboolean has_tooltip_text = FALSE; 1411 gboolean has_tooltip_text = FALSE;
1412 gboolean has_info = FALSE; 1412 gboolean has_info = FALSE;
1418 #if PHOTO_SUPPORT 1418 #if PHOTO_SUPPORT
1419 char *photo_url_text = NULL; 1419 char *photo_url_text = NULL;
1420 MsnGetInfoStepTwoData *info2_data = NULL; 1420 MsnGetInfoStepTwoData *info2_data = NULL;
1421 #endif 1421 #endif
1422 1422
1423 gaim_debug_info("msn", "In msn_got_info\n"); 1423 purple_debug_info("msn", "In msn_got_info\n");
1424 1424
1425 /* Make sure the connection is still valid */ 1425 /* Make sure the connection is still valid */
1426 if (g_list_find(gaim_connections_get_all(), info_data->gc) == NULL) 1426 if (g_list_find(purple_connections_get_all(), info_data->gc) == NULL)
1427 { 1427 {
1428 gaim_debug_warning("msn", "invalid connection. ignoring buddy info.\n"); 1428 purple_debug_warning("msn", "invalid connection. ignoring buddy info.\n");
1429 g_free(info_data->name); 1429 g_free(info_data->name);
1430 g_free(info_data); 1430 g_free(info_data);
1431 return; 1431 return;
1432 } 1432 }
1433 1433
1434 user_info = gaim_notify_user_info_new(); 1434 user_info = purple_notify_user_info_new();
1435 has_tooltip_text = msn_tooltip_extract_info_text(user_info, info_data); 1435 has_tooltip_text = msn_tooltip_extract_info_text(user_info, info_data);
1436 1436
1437 if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0) 1437 if (error_message != NULL || url_text == NULL || strcmp(url_text, "") == 0)
1438 { 1438 {
1439 tmp = g_strdup_printf("<b>%s</b>", _("Error retrieving profile")); 1439 tmp = g_strdup_printf("<b>%s</b>", _("Error retrieving profile"));
1440 gaim_notify_user_info_add_pair(user_info, NULL, tmp); 1440 purple_notify_user_info_add_pair(user_info, NULL, tmp);
1441 g_free(tmp); 1441 g_free(tmp);
1442 1442
1443 gaim_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); 1443 purple_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL);
1444 gaim_notify_user_info_destroy(user_info); 1444 purple_notify_user_info_destroy(user_info);
1445 1445
1446 g_free(info_data->name); 1446 g_free(info_data->name);
1447 g_free(info_data); 1447 g_free(info_data);
1448 return; 1448 return;
1449 } 1449 }
1450 1450
1451 url_buffer = g_strdup(url_text); 1451 url_buffer = g_strdup(url_text);
1452 1452
1453 /* If they have a homepage link, MSN masks it such that we need to 1453 /* If they have a homepage link, MSN masks it such that we need to
1454 * fetch the url out before gaim_markup_strip_html() nukes it */ 1454 * fetch the url out before purple_markup_strip_html() nukes it */
1455 /* I don't think this works with the new spaces profiles - Stu 3/2/06 */ 1455 /* I don't think this works with the new spaces profiles - Stu 3/2/06 */
1456 if ((p = strstr(url_text, 1456 if ((p = strstr(url_text,
1457 "Take a look at my </font><A class=viewDesc title=\"")) != NULL) 1457 "Take a look at my </font><A class=viewDesc title=\"")) != NULL)
1458 { 1458 {
1459 p += 50; 1459 p += 50;
1461 if ((q = strchr(p, '"')) != NULL) 1461 if ((q = strchr(p, '"')) != NULL)
1462 user_url = g_strndup(p, q - p); 1462 user_url = g_strndup(p, q - p);
1463 } 1463 }
1464 1464
1465 /* 1465 /*
1466 * gaim_markup_strip_html() doesn't strip out character entities like &nbsp; 1466 * purple_markup_strip_html() doesn't strip out character entities like &nbsp;
1467 * and &#183; 1467 * and &#183;
1468 */ 1468 */
1469 while ((p = strstr(url_buffer, "&nbsp;")) != NULL) 1469 while ((p = strstr(url_buffer, "&nbsp;")) != NULL)
1470 { 1470 {
1471 *p = ' '; /* Turn &nbsp;'s into ordinary blanks */ 1471 *p = ' '; /* Turn &nbsp;'s into ordinary blanks */
1479 memmove(p, p + 6, strlen(p + 6)); 1479 memmove(p, p + 6, strlen(p + 6));
1480 url_buffer[strlen(url_buffer) - 6] = '\0'; 1480 url_buffer[strlen(url_buffer) - 6] = '\0';
1481 } 1481 }
1482 1482
1483 /* Nuke the nasty \r's that just get in the way */ 1483 /* Nuke the nasty \r's that just get in the way */
1484 gaim_str_strip_char(url_buffer, '\r'); 1484 purple_str_strip_char(url_buffer, '\r');
1485 1485
1486 /* MSN always puts in &#39; for apostrophes...replace them */ 1486 /* MSN always puts in &#39; for apostrophes...replace them */
1487 while ((p = strstr(url_buffer, "&#39;")) != NULL) 1487 while ((p = strstr(url_buffer, "&#39;")) != NULL)
1488 { 1488 {
1489 *p = '\''; 1489 *p = '\'';
1490 memmove(p + 1, p + 5, strlen(p + 5)); 1490 memmove(p + 1, p + 5, strlen(p + 5));
1491 url_buffer[strlen(url_buffer) - 4] = '\0'; 1491 url_buffer[strlen(url_buffer) - 4] = '\0';
1492 } 1492 }
1493 1493
1494 /* Nuke the html, it's easier than trying to parse the horrid stuff */ 1494 /* Nuke the html, it's easier than trying to parse the horrid stuff */
1495 stripped = gaim_markup_strip_html(url_buffer); 1495 stripped = purple_markup_strip_html(url_buffer);
1496 stripped_len = strlen(stripped); 1496 stripped_len = strlen(stripped);
1497 1497
1498 gaim_debug_misc("msn", "stripped = %p\n", stripped); 1498 purple_debug_misc("msn", "stripped = %p\n", stripped);
1499 gaim_debug_misc("msn", "url_buffer = %p\n", url_buffer); 1499 purple_debug_misc("msn", "url_buffer = %p\n", url_buffer);
1500 1500
1501 /* Gonna re-use the memory we've already got for url_buffer */ 1501 /* Gonna re-use the memory we've already got for url_buffer */
1502 /* No we're not. */ 1502 /* No we're not. */
1503 s = g_string_sized_new(strlen(url_buffer)); 1503 s = g_string_sized_new(strlen(url_buffer));
1504 s2 = g_string_sized_new(strlen(url_buffer)); 1504 s2 = g_string_sized_new(strlen(url_buffer));
1505 1505
1506 /* General section header */ 1506 /* General section header */
1507 if (has_tooltip_text) 1507 if (has_tooltip_text)
1508 gaim_notify_user_info_add_section_break(user_info); 1508 purple_notify_user_info_add_section_break(user_info);
1509 1509
1510 gaim_notify_user_info_add_section_header(user_info, _("General")); 1510 purple_notify_user_info_add_section_header(user_info, _("General"));
1511 1511
1512 /* Extract their Name and put it in */ 1512 /* Extract their Name and put it in */
1513 MSN_GOT_INFO_GET_FIELD("Name", _("Name")); 1513 MSN_GOT_INFO_GET_FIELD("Name", _("Name"));
1514 1514
1515 /* General */ 1515 /* General */
1518 MSN_GOT_INFO_GET_FIELD("Gender", _("Gender")); 1518 MSN_GOT_INFO_GET_FIELD("Gender", _("Gender"));
1519 MSN_GOT_INFO_GET_FIELD("Occupation", _("Occupation")); 1519 MSN_GOT_INFO_GET_FIELD("Occupation", _("Occupation"));
1520 MSN_GOT_INFO_GET_FIELD("Location", _("Location")); 1520 MSN_GOT_INFO_GET_FIELD("Location", _("Location"));
1521 1521
1522 /* Extract their Interests and put it in */ 1522 /* Extract their Interests and put it in */
1523 found = gaim_markup_extract_info_field(stripped, stripped_len, user_info, 1523 found = purple_markup_extract_info_field(stripped, stripped_len, user_info,
1524 "\nInterests\t", 0, " (/default.aspx?page=searchresults", 0, 1524 "\nInterests\t", 0, " (/default.aspx?page=searchresults", 0,
1525 "Undisclosed", _("Hobbies and Interests") /* _("Interests") */, 1525 "Undisclosed", _("Hobbies and Interests") /* _("Interests") */,
1526 0, NULL, NULL); 1526 0, NULL, NULL);
1527 1527
1528 if (found) 1528 if (found)
1536 sect_info = FALSE; 1536 sect_info = FALSE;
1537 } 1537 }
1538 else 1538 else
1539 { 1539 {
1540 /* Remove the section header */ 1540 /* Remove the section header */
1541 gaim_notify_user_info_remove_last_item(user_info); 1541 purple_notify_user_info_remove_last_item(user_info);
1542 if (has_tooltip_text) 1542 if (has_tooltip_text)
1543 gaim_notify_user_info_remove_last_item(user_info); 1543 purple_notify_user_info_remove_last_item(user_info);
1544 } 1544 }
1545 1545
1546 /* Social */ 1546 /* Social */
1547 gaim_notify_user_info_add_section_break(user_info); 1547 purple_notify_user_info_add_section_break(user_info);
1548 gaim_notify_user_info_add_section_header(user_info, _("Social")); 1548 purple_notify_user_info_add_section_header(user_info, _("Social"));
1549 1549
1550 MSN_GOT_INFO_GET_FIELD("Marital status", _("Marital Status")); 1550 MSN_GOT_INFO_GET_FIELD("Marital status", _("Marital Status"));
1551 MSN_GOT_INFO_GET_FIELD("Interested in", _("Interests")); 1551 MSN_GOT_INFO_GET_FIELD("Interested in", _("Interests"));
1552 MSN_GOT_INFO_GET_FIELD("Pets", _("Pets")); 1552 MSN_GOT_INFO_GET_FIELD("Pets", _("Pets"));
1553 MSN_GOT_INFO_GET_FIELD("Hometown", _("Hometown")); 1553 MSN_GOT_INFO_GET_FIELD("Hometown", _("Hometown"));
1563 sect_info = FALSE; 1563 sect_info = FALSE;
1564 } 1564 }
1565 else 1565 else
1566 { 1566 {
1567 /* Remove the section header */ 1567 /* Remove the section header */
1568 gaim_notify_user_info_remove_last_item(user_info); 1568 purple_notify_user_info_remove_last_item(user_info);
1569 gaim_notify_user_info_remove_last_item(user_info); 1569 purple_notify_user_info_remove_last_item(user_info);
1570 } 1570 }
1571 1571
1572 /* Contact Info */ 1572 /* Contact Info */
1573 /* Personal */ 1573 /* Personal */
1574 gaim_notify_user_info_add_section_break(user_info); 1574 purple_notify_user_info_add_section_break(user_info);
1575 gaim_notify_user_info_add_section_header(user_info, _("Contact Info")); 1575 purple_notify_user_info_add_section_header(user_info, _("Contact Info"));
1576 gaim_notify_user_info_add_section_header(user_info, _("Personal")); 1576 purple_notify_user_info_add_section_header(user_info, _("Personal"));
1577 1577
1578 MSN_GOT_INFO_GET_FIELD("Name", _("Name")); 1578 MSN_GOT_INFO_GET_FIELD("Name", _("Name"));
1579 MSN_GOT_INFO_GET_FIELD("Significant other", _("Significant Other")); 1579 MSN_GOT_INFO_GET_FIELD("Significant other", _("Significant Other"));
1580 MSN_GOT_INFO_GET_FIELD("Home phone", _("Home Phone")); 1580 MSN_GOT_INFO_GET_FIELD("Home phone", _("Home Phone"));
1581 MSN_GOT_INFO_GET_FIELD("Home phone 2", _("Home Phone 2")); 1581 MSN_GOT_INFO_GET_FIELD("Home phone 2", _("Home Phone 2"));
1595 has_contact_info = TRUE; 1595 has_contact_info = TRUE;
1596 } 1596 }
1597 else 1597 else
1598 { 1598 {
1599 /* Remove the section header */ 1599 /* Remove the section header */
1600 gaim_notify_user_info_remove_last_item(user_info); 1600 purple_notify_user_info_remove_last_item(user_info);
1601 } 1601 }
1602 1602
1603 /* Business */ 1603 /* Business */
1604 gaim_notify_user_info_add_section_header(user_info, _("Work")); 1604 purple_notify_user_info_add_section_header(user_info, _("Work"));
1605 MSN_GOT_INFO_GET_FIELD("Name", _("Name")); 1605 MSN_GOT_INFO_GET_FIELD("Name", _("Name"));
1606 MSN_GOT_INFO_GET_FIELD("Job title", _("Job Title")); 1606 MSN_GOT_INFO_GET_FIELD("Job title", _("Job Title"));
1607 MSN_GOT_INFO_GET_FIELD("Company", _("Company")); 1607 MSN_GOT_INFO_GET_FIELD("Company", _("Company"));
1608 MSN_GOT_INFO_GET_FIELD("Department", _("Department")); 1608 MSN_GOT_INFO_GET_FIELD("Department", _("Department"));
1609 MSN_GOT_INFO_GET_FIELD("Profession", _("Profession")); 1609 MSN_GOT_INFO_GET_FIELD("Profession", _("Profession"));
1625 has_contact_info = TRUE; 1625 has_contact_info = TRUE;
1626 } 1626 }
1627 else 1627 else
1628 { 1628 {
1629 /* Remove the section header */ 1629 /* Remove the section header */
1630 gaim_notify_user_info_remove_last_item(user_info); 1630 purple_notify_user_info_remove_last_item(user_info);
1631 } 1631 }
1632 1632
1633 if (!has_contact_info) 1633 if (!has_contact_info)
1634 { 1634 {
1635 /* Remove the Contact Info section header */ 1635 /* Remove the Contact Info section header */
1636 gaim_notify_user_info_remove_last_item(user_info); 1636 purple_notify_user_info_remove_last_item(user_info);
1637 } 1637 }
1638 1638
1639 #if 0 /* these probably don't show up any more */ 1639 #if 0 /* these probably don't show up any more */
1640 /* 1640 /*
1641 * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies 1641 * The fields, 'A Little About Me', 'Favorite Things', 'Hobbies
1644 * certain order, so we can successively search to pin down the 1644 * certain order, so we can successively search to pin down the
1645 * distinct values. 1645 * distinct values.
1646 */ 1646 */
1647 1647
1648 /* Check if they have A Little About Me */ 1648 /* Check if they have A Little About Me */
1649 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1649 found = purple_markup_extract_info_field(stripped, stripped_len, s,
1650 " A Little About Me \n\n", 0, "Favorite Things", '\n', NULL, 1650 " A Little About Me \n\n", 0, "Favorite Things", '\n', NULL,
1651 _("A Little About Me"), 0, NULL, NULL); 1651 _("A Little About Me"), 0, NULL, NULL);
1652 1652
1653 if (!found) 1653 if (!found)
1654 { 1654 {
1655 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1655 found = purple_markup_extract_info_field(stripped, stripped_len, s,
1656 " A Little About Me \n\n", 0, "Hobbies and Interests", '\n', 1656 " A Little About Me \n\n", 0, "Hobbies and Interests", '\n',
1657 NULL, _("A Little About Me"), 0, NULL, NULL); 1657 NULL, _("A Little About Me"), 0, NULL, NULL);
1658 } 1658 }
1659 1659
1660 if (!found) 1660 if (!found)
1661 { 1661 {
1662 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1662 found = purple_markup_extract_info_field(stripped, stripped_len, s,
1663 " A Little About Me \n\n", 0, "Favorite Quote", '\n', NULL, 1663 " A Little About Me \n\n", 0, "Favorite Quote", '\n', NULL,
1664 _("A Little About Me"), 0, NULL, NULL); 1664 _("A Little About Me"), 0, NULL, NULL);
1665 } 1665 }
1666 1666
1667 if (!found) 1667 if (!found)
1668 { 1668 {
1669 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1669 found = purple_markup_extract_info_field(stripped, stripped_len, s,
1670 " A Little About Me \n\n", 0, "My Homepage \n\nTake a look", 1670 " A Little About Me \n\n", 0, "My Homepage \n\nTake a look",
1671 '\n', 1671 '\n',
1672 NULL, _("A Little About Me"), 0, NULL, NULL); 1672 NULL, _("A Little About Me"), 0, NULL, NULL);
1673 } 1673 }
1674 1674
1675 if (!found) 1675 if (!found)
1676 { 1676 {
1677 gaim_markup_extract_info_field(stripped, stripped_len, s, 1677 purple_markup_extract_info_field(stripped, stripped_len, s,
1678 " A Little About Me \n\n", 0, "last updated", '\n', NULL, 1678 " A Little About Me \n\n", 0, "last updated", '\n', NULL,
1679 _("A Little About Me"), 0, NULL, NULL); 1679 _("A Little About Me"), 0, NULL, NULL);
1680 } 1680 }
1681 1681
1682 if (found) 1682 if (found)
1683 has_info = TRUE; 1683 has_info = TRUE;
1684 1684
1685 /* Check if they have Favorite Things */ 1685 /* Check if they have Favorite Things */
1686 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1686 found = purple_markup_extract_info_field(stripped, stripped_len, s,
1687 " Favorite Things \n\n", 0, "Hobbies and Interests", '\n', NULL, 1687 " Favorite Things \n\n", 0, "Hobbies and Interests", '\n', NULL,
1688 _("Favorite Things"), 0, NULL, NULL); 1688 _("Favorite Things"), 0, NULL, NULL);
1689 1689
1690 if (!found) 1690 if (!found)
1691 { 1691 {
1692 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1692 found = purple_markup_extract_info_field(stripped, stripped_len, s,
1693 " Favorite Things \n\n", 0, "Favorite Quote", '\n', NULL, 1693 " Favorite Things \n\n", 0, "Favorite Quote", '\n', NULL,
1694 _("Favorite Things"), 0, NULL, NULL); 1694 _("Favorite Things"), 0, NULL, NULL);
1695 } 1695 }
1696 1696
1697 if (!found) 1697 if (!found)
1698 { 1698 {
1699 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1699 found = purple_markup_extract_info_field(stripped, stripped_len, s,
1700 " Favorite Things \n\n", 0, "My Homepage \n\nTake a look", '\n', 1700 " Favorite Things \n\n", 0, "My Homepage \n\nTake a look", '\n',
1701 NULL, _("Favorite Things"), 0, NULL, NULL); 1701 NULL, _("Favorite Things"), 0, NULL, NULL);
1702 } 1702 }
1703 1703
1704 if (!found) 1704 if (!found)
1705 { 1705 {
1706 gaim_markup_extract_info_field(stripped, stripped_len, s, 1706 purple_markup_extract_info_field(stripped, stripped_len, s,
1707 " Favorite Things \n\n", 0, "last updated", '\n', NULL, 1707 " Favorite Things \n\n", 0, "last updated", '\n', NULL,
1708 _("Favorite Things"), 0, NULL, NULL); 1708 _("Favorite Things"), 0, NULL, NULL);
1709 } 1709 }
1710 1710
1711 if (found) 1711 if (found)
1712 has_info = TRUE; 1712 has_info = TRUE;
1713 1713
1714 /* Check if they have Hobbies and Interests */ 1714 /* Check if they have Hobbies and Interests */
1715 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1715 found = purple_markup_extract_info_field(stripped, stripped_len, s,
1716 " Hobbies and Interests \n\n", 0, "Favorite Quote", '\n', NULL, 1716 " Hobbies and Interests \n\n", 0, "Favorite Quote", '\n', NULL,
1717 _("Hobbies and Interests"), 0, NULL, NULL); 1717 _("Hobbies and Interests"), 0, NULL, NULL);
1718 1718
1719 if (!found) 1719 if (!found)
1720 { 1720 {
1721 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1721 found = purple_markup_extract_info_field(stripped, stripped_len, s,
1722 " Hobbies and Interests \n\n", 0, "My Homepage \n\nTake a look", 1722 " Hobbies and Interests \n\n", 0, "My Homepage \n\nTake a look",
1723 '\n', NULL, _("Hobbies and Interests"), 0, NULL, NULL); 1723 '\n', NULL, _("Hobbies and Interests"), 0, NULL, NULL);
1724 } 1724 }
1725 1725
1726 if (!found) 1726 if (!found)
1727 { 1727 {
1728 gaim_markup_extract_info_field(stripped, stripped_len, s, 1728 purple_markup_extract_info_field(stripped, stripped_len, s,
1729 " Hobbies and Interests \n\n", 0, "last updated", '\n', NULL, 1729 " Hobbies and Interests \n\n", 0, "last updated", '\n', NULL,
1730 _("Hobbies and Interests"), 0, NULL, NULL); 1730 _("Hobbies and Interests"), 0, NULL, NULL);
1731 } 1731 }
1732 1732
1733 if (found) 1733 if (found)
1734 has_info = TRUE; 1734 has_info = TRUE;
1735 1735
1736 /* Check if they have Favorite Quote */ 1736 /* Check if they have Favorite Quote */
1737 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1737 found = purple_markup_extract_info_field(stripped, stripped_len, s,
1738 "Favorite Quote \n\n", 0, "My Homepage \n\nTake a look", '\n', NULL, 1738 "Favorite Quote \n\n", 0, "My Homepage \n\nTake a look", '\n', NULL,
1739 _("Favorite Quote"), 0, NULL, NULL); 1739 _("Favorite Quote"), 0, NULL, NULL);
1740 1740
1741 if (!found) 1741 if (!found)
1742 { 1742 {
1743 gaim_markup_extract_info_field(stripped, stripped_len, s, 1743 purple_markup_extract_info_field(stripped, stripped_len, s,
1744 "Favorite Quote \n\n", 0, "last updated", '\n', NULL, 1744 "Favorite Quote \n\n", 0, "last updated", '\n', NULL,
1745 _("Favorite Quote"), 0, NULL, NULL); 1745 _("Favorite Quote"), 0, NULL, NULL);
1746 } 1746 }
1747 1747
1748 if (found) 1748 if (found)
1749 has_info = TRUE; 1749 has_info = TRUE;
1750 1750
1751 /* Extract the last updated date and put it in */ 1751 /* Extract the last updated date and put it in */
1752 found = gaim_markup_extract_info_field(stripped, stripped_len, s, 1752 found = purple_markup_extract_info_field(stripped, stripped_len, s,
1753 " last updated:", 1, "\n", 0, NULL, _("Last Updated"), 0, 1753 " last updated:", 1, "\n", 0, NULL, _("Last Updated"), 0,
1754 NULL, msn_info_date_reformat); 1754 NULL, msn_info_date_reformat);
1755 1755
1756 if (found) 1756 if (found)
1757 has_info = TRUE; 1757 has_info = TRUE;
1759 1759
1760 /* If we were able to fetch a homepage url earlier, stick it in there */ 1760 /* If we were able to fetch a homepage url earlier, stick it in there */
1761 if (user_url != NULL) 1761 if (user_url != NULL)
1762 { 1762 {
1763 tmp = g_strdup_printf("<a href=\"%s\">%s</a>", user_url, user_url); 1763 tmp = g_strdup_printf("<a href=\"%s\">%s</a>", user_url, user_url);
1764 gaim_notify_user_info_add_pair(user_info, _("Homepage"), tmp); 1764 purple_notify_user_info_add_pair(user_info, _("Homepage"), tmp);
1765 g_free(tmp); 1765 g_free(tmp);
1766 g_free(user_url); 1766 g_free(user_url);
1767 1767
1768 has_info = TRUE; 1768 has_info = TRUE;
1769 } 1769 }
1777 */ 1777 */
1778 /* This doesn't work with the new spaces profiles - Stu 3/2/06 1778 /* This doesn't work with the new spaces profiles - Stu 3/2/06
1779 char *p = strstr(url_buffer, "Unknown Member </TITLE>"); 1779 char *p = strstr(url_buffer, "Unknown Member </TITLE>");
1780 * This might not work for long either ... */ 1780 * This might not work for long either ... */
1781 char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\""); 1781 char *p = strstr(url_buffer, "form id=\"SpacesSearch\" name=\"SpacesSearch\"");
1782 GaimBuddy *b = gaim_find_buddy 1782 PurpleBuddy *b = purple_find_buddy
1783 (gaim_connection_get_account(info_data->gc), info_data->name); 1783 (purple_connection_get_account(info_data->gc), info_data->name);
1784 gaim_notify_user_info_add_pair(user_info, _("Error retrieving profile"), 1784 purple_notify_user_info_add_pair(user_info, _("Error retrieving profile"),
1785 ((p && b) ? _("The user has not created a public profile.") : 1785 ((p && b) ? _("The user has not created a public profile.") :
1786 (p ? _("MSN reported not being able to find the user's profile. " 1786 (p ? _("MSN reported not being able to find the user's profile. "
1787 "This either means that the user does not exist, " 1787 "This either means that the user does not exist, "
1788 "or that the user exists " 1788 "or that the user exists "
1789 "but has not created a public profile.") : 1789 "but has not created a public profile.") :
1793 } 1793 }
1794 1794
1795 /* put a link to the actual profile URL */ 1795 /* put a link to the actual profile URL */
1796 tmp = g_strdup_printf("<a href=\"%s%s\">%s%s</a>", 1796 tmp = g_strdup_printf("<a href=\"%s%s\">%s%s</a>",
1797 PROFILE_URL, info_data->name, PROFILE_URL, info_data->name); 1797 PROFILE_URL, info_data->name, PROFILE_URL, info_data->name);
1798 gaim_notify_user_info_add_pair(user_info, _("Profile URL"), tmp); 1798 purple_notify_user_info_add_pair(user_info, _("Profile URL"), tmp);
1799 g_free(tmp); 1799 g_free(tmp);
1800 1800
1801 #if PHOTO_SUPPORT 1801 #if PHOTO_SUPPORT
1802 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */ 1802 /* Find the URL to the photo; must be before the marshalling [Bug 994207] */
1803 photo_url_text = msn_get_photo_url(url_text); 1803 photo_url_text = msn_get_photo_url(url_text);
1811 info2_data->photo_url_text = photo_url_text; 1811 info2_data->photo_url_text = photo_url_text;
1812 1812
1813 /* Try to put the photo in there too, if there's one */ 1813 /* Try to put the photo in there too, if there's one */
1814 if (photo_url_text) 1814 if (photo_url_text)
1815 { 1815 {
1816 gaim_util_fetch_url(photo_url_text, FALSE, NULL, FALSE, msn_got_photo, 1816 purple_util_fetch_url(photo_url_text, FALSE, NULL, FALSE, msn_got_photo,
1817 info2_data); 1817 info2_data);
1818 } 1818 }
1819 else 1819 else
1820 { 1820 {
1821 /* Emulate a callback */ 1821 /* Emulate a callback */
1823 msn_got_photo(NULL, info2_data, NULL, 0, NULL); 1823 msn_got_photo(NULL, info2_data, NULL, 0, NULL);
1824 } 1824 }
1825 } 1825 }
1826 1826
1827 static void 1827 static void
1828 msn_got_photo(GaimUtilFetchUrlData *url_data, gpointer user_data, 1828 msn_got_photo(PurpleUtilFetchUrlData *url_data, gpointer user_data,
1829 const gchar *url_text, size_t len, const gchar *error_message) 1829 const gchar *url_text, size_t len, const gchar *error_message)
1830 { 1830 {
1831 MsnGetInfoStepTwoData *info2_data = (MsnGetInfoStepTwoData *)user_data; 1831 MsnGetInfoStepTwoData *info2_data = (MsnGetInfoStepTwoData *)user_data;
1832 int id = -1; 1832 int id = -1;
1833 1833
1834 /* Unmarshall the saved state */ 1834 /* Unmarshall the saved state */
1835 MsnGetInfoData *info_data = info2_data->info_data; 1835 MsnGetInfoData *info_data = info2_data->info_data;
1836 char *stripped = info2_data->stripped; 1836 char *stripped = info2_data->stripped;
1837 char *url_buffer = info2_data->url_buffer; 1837 char *url_buffer = info2_data->url_buffer;
1838 GaimNotifyUserInfo *user_info = info2_data->user_info; 1838 PurpleNotifyUserInfo *user_info = info2_data->user_info;
1839 char *photo_url_text = info2_data->photo_url_text; 1839 char *photo_url_text = info2_data->photo_url_text;
1840 1840
1841 /* Make sure the connection is still valid if we got here by fetching a photo url */ 1841 /* Make sure the connection is still valid if we got here by fetching a photo url */
1842 if (url_text && (error_message != NULL || 1842 if (url_text && (error_message != NULL ||
1843 g_list_find(gaim_connections_get_all(), info_data->gc) == NULL)) 1843 g_list_find(purple_connections_get_all(), info_data->gc) == NULL))
1844 { 1844 {
1845 gaim_debug_warning("msn", "invalid connection. ignoring buddy photo info.\n"); 1845 purple_debug_warning("msn", "invalid connection. ignoring buddy photo info.\n");
1846 g_free(stripped); 1846 g_free(stripped);
1847 g_free(url_buffer); 1847 g_free(url_buffer);
1848 g_free(user_info); 1848 g_free(user_info);
1849 g_free(info_data->name); 1849 g_free(info_data->name);
1850 g_free(info_data); 1850 g_free(info_data);
1860 if (strstr(url_text, "400 Bad Request") 1860 if (strstr(url_text, "400 Bad Request")
1861 || strstr(url_text, "403 Forbidden") 1861 || strstr(url_text, "403 Forbidden")
1862 || strstr(url_text, "404 Not Found")) 1862 || strstr(url_text, "404 Not Found"))
1863 { 1863 {
1864 1864
1865 gaim_debug_info("msn", "Error getting %s: %s\n", 1865 purple_debug_info("msn", "Error getting %s: %s\n",
1866 photo_url_text, url_text); 1866 photo_url_text, url_text);
1867 } 1867 }
1868 else 1868 else
1869 { 1869 {
1870 char buf[1024]; 1870 char buf[1024];
1871 gaim_debug_info("msn", "%s is %d bytes\n", photo_url_text, len); 1871 purple_debug_info("msn", "%s is %d bytes\n", photo_url_text, len);
1872 id = gaim_imgstore_add(url_text, len, NULL); 1872 id = purple_imgstore_add(url_text, len, NULL);
1873 g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id); 1873 g_snprintf(buf, sizeof(buf), "<img id=\"%d\"><br>", id);
1874 gaim_notify_user_info_prepend_pair(user_info, NULL, buf); 1874 purple_notify_user_info_prepend_pair(user_info, NULL, buf);
1875 } 1875 }
1876 } 1876 }
1877 1877
1878 /* We continue here from msn_got_info, as if nothing has happened */ 1878 /* We continue here from msn_got_info, as if nothing has happened */
1879 #endif 1879 #endif
1880 gaim_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL); 1880 purple_notify_userinfo(info_data->gc, info_data->name, user_info, NULL, NULL);
1881 1881
1882 g_free(stripped); 1882 g_free(stripped);
1883 g_free(url_buffer); 1883 g_free(url_buffer);
1884 gaim_notify_user_info_destroy(user_info); 1884 purple_notify_user_info_destroy(user_info);
1885 g_free(info_data->name); 1885 g_free(info_data->name);
1886 g_free(info_data); 1886 g_free(info_data);
1887 #if PHOTO_SUPPORT 1887 #if PHOTO_SUPPORT
1888 g_free(photo_url_text); 1888 g_free(photo_url_text);
1889 g_free(info2_data); 1889 g_free(info2_data);
1890 if (id != -1) 1890 if (id != -1)
1891 gaim_imgstore_unref(id); 1891 purple_imgstore_unref(id);
1892 #endif 1892 #endif
1893 } 1893 }
1894 1894
1895 static void 1895 static void
1896 msn_get_info(GaimConnection *gc, const char *name) 1896 msn_get_info(PurpleConnection *gc, const char *name)
1897 { 1897 {
1898 MsnGetInfoData *data; 1898 MsnGetInfoData *data;
1899 char *url; 1899 char *url;
1900 1900
1901 data = g_new0(MsnGetInfoData, 1); 1901 data = g_new0(MsnGetInfoData, 1);
1902 data->gc = gc; 1902 data->gc = gc;
1903 data->name = g_strdup(name); 1903 data->name = g_strdup(name);
1904 1904
1905 url = g_strdup_printf("%s%s", PROFILE_URL, name); 1905 url = g_strdup_printf("%s%s", PROFILE_URL, name);
1906 1906
1907 gaim_util_fetch_url(url, FALSE, 1907 purple_util_fetch_url(url, FALSE,
1908 "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", 1908 "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
1909 TRUE, msn_got_info, data); 1909 TRUE, msn_got_info, data);
1910 1910
1911 g_free(url); 1911 g_free(url);
1912 } 1912 }
1913 1913
1914 static gboolean msn_load(GaimPlugin *plugin) 1914 static gboolean msn_load(PurplePlugin *plugin)
1915 { 1915 {
1916 msn_notification_init(); 1916 msn_notification_init();
1917 msn_switchboard_init(); 1917 msn_switchboard_init();
1918 msn_sync_init(); 1918 msn_sync_init();
1919 1919
1920 return TRUE; 1920 return TRUE;
1921 } 1921 }
1922 1922
1923 static gboolean msn_unload(GaimPlugin *plugin) 1923 static gboolean msn_unload(PurplePlugin *plugin)
1924 { 1924 {
1925 msn_notification_end(); 1925 msn_notification_end();
1926 msn_switchboard_end(); 1926 msn_switchboard_end();
1927 msn_sync_end(); 1927 msn_sync_end();
1928 1928
1929 return TRUE; 1929 return TRUE;
1930 } 1930 }
1931 1931
1932 static GaimAccount *find_acct(const char *prpl, const char *acct_id) 1932 static PurpleAccount *find_acct(const char *prpl, const char *acct_id)
1933 { 1933 {
1934 GaimAccount *acct = NULL; 1934 PurpleAccount *acct = NULL;
1935 1935
1936 /* If we have a specific acct, use it */ 1936 /* If we have a specific acct, use it */
1937 if (acct_id) { 1937 if (acct_id) {
1938 acct = gaim_accounts_find(acct_id, prpl); 1938 acct = purple_accounts_find(acct_id, prpl);
1939 if (acct && !gaim_account_is_connected(acct)) 1939 if (acct && !purple_account_is_connected(acct))
1940 acct = NULL; 1940 acct = NULL;
1941 } else { /* Otherwise find an active account for the protocol */ 1941 } else { /* Otherwise find an active account for the protocol */
1942 GList *l = gaim_accounts_get_all(); 1942 GList *l = purple_accounts_get_all();
1943 while (l) { 1943 while (l) {
1944 if (!strcmp(prpl, gaim_account_get_protocol_id(l->data)) 1944 if (!strcmp(prpl, purple_account_get_protocol_id(l->data))
1945 && gaim_account_is_connected(l->data)) { 1945 && purple_account_is_connected(l->data)) {
1946 acct = l->data; 1946 acct = l->data;
1947 break; 1947 break;
1948 } 1948 }
1949 l = l->next; 1949 l = l->next;
1950 } 1950 }
1954 } 1954 }
1955 1955
1956 static gboolean msn_uri_handler(const char *proto, const char *cmd, GHashTable *params) 1956 static gboolean msn_uri_handler(const char *proto, const char *cmd, GHashTable *params)
1957 { 1957 {
1958 char *acct_id = g_hash_table_lookup(params, "account"); 1958 char *acct_id = g_hash_table_lookup(params, "account");
1959 GaimAccount *acct; 1959 PurpleAccount *acct;
1960 1960
1961 if (g_ascii_strcasecmp(proto, "msnim")) 1961 if (g_ascii_strcasecmp(proto, "msnim"))
1962 return FALSE; 1962 return FALSE;
1963 1963
1964 acct = find_acct("prpl-msn", acct_id); 1964 acct = find_acct("prpl-msn", acct_id);
1968 1968
1969 /* msnim:chat?contact=user@domain.tld */ 1969 /* msnim:chat?contact=user@domain.tld */
1970 if (!g_ascii_strcasecmp(cmd, "Chat")) { 1970 if (!g_ascii_strcasecmp(cmd, "Chat")) {
1971 char *sname = g_hash_table_lookup(params, "contact"); 1971 char *sname = g_hash_table_lookup(params, "contact");
1972 if (sname) { 1972 if (sname) {
1973 GaimConversation *conv = gaim_find_conversation_with_account( 1973 PurpleConversation *conv = purple_find_conversation_with_account(
1974 GAIM_CONV_TYPE_IM, sname, acct); 1974 PURPLE_CONV_TYPE_IM, sname, acct);
1975 if (conv == NULL) 1975 if (conv == NULL)
1976 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, sname); 1976 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, sname);
1977 gaim_conversation_present(conv); 1977 purple_conversation_present(conv);
1978 } 1978 }
1979 /*else 1979 /*else
1980 **If pidgindialogs_im() was in the core, we could use it here. 1980 **If pidgindialogs_im() was in the core, we could use it here.
1981 * It is all gaim_request_* based, but I'm not sure it really belongs in the core 1981 * It is all purple_request_* based, but I'm not sure it really belongs in the core
1982 pidgindialogs_im();*/ 1982 pidgindialogs_im();*/
1983 1983
1984 return TRUE; 1984 return TRUE;
1985 } 1985 }
1986 /* msnim:add?contact=user@domain.tld */ 1986 /* msnim:add?contact=user@domain.tld */
1987 else if (!g_ascii_strcasecmp(cmd, "Add")) { 1987 else if (!g_ascii_strcasecmp(cmd, "Add")) {
1988 char *name = g_hash_table_lookup(params, "contact"); 1988 char *name = g_hash_table_lookup(params, "contact");
1989 gaim_blist_request_add_buddy(acct, name, NULL, NULL); 1989 purple_blist_request_add_buddy(acct, name, NULL, NULL);
1990 return TRUE; 1990 return TRUE;
1991 } 1991 }
1992 1992
1993 return FALSE; 1993 return FALSE;
1994 } 1994 }
1995 1995
1996 1996
1997 static GaimPluginProtocolInfo prpl_info = 1997 static PurplePluginProtocolInfo prpl_info =
1998 { 1998 {
1999 OPT_PROTO_MAIL_CHECK, 1999 OPT_PROTO_MAIL_CHECK,
2000 NULL, /* user_splits */ 2000 NULL, /* user_splits */
2001 NULL, /* protocol_options */ 2001 NULL, /* protocol_options */
2002 {"png", 0, 0, 96, 96, 0, GAIM_ICON_SCALE_SEND}, /* icon_spec */ 2002 {"png", 0, 0, 96, 96, 0, PURPLE_ICON_SCALE_SEND}, /* icon_spec */
2003 msn_list_icon, /* list_icon */ 2003 msn_list_icon, /* list_icon */
2004 NULL, /* list_emblems */ 2004 NULL, /* list_emblems */
2005 msn_status_text, /* status_text */ 2005 msn_status_text, /* status_text */
2006 msn_tooltip_text, /* tooltip_text */ 2006 msn_tooltip_text, /* tooltip_text */
2007 msn_status_types, /* away_states */ 2007 msn_status_types, /* away_states */
2058 NULL, /* whiteboard_prpl_ops */ 2058 NULL, /* whiteboard_prpl_ops */
2059 NULL, /* send_raw */ 2059 NULL, /* send_raw */
2060 NULL, /* roomlist_room_serialize */ 2060 NULL, /* roomlist_room_serialize */
2061 }; 2061 };
2062 2062
2063 static GaimPluginInfo info = 2063 static PurplePluginInfo info =
2064 { 2064 {
2065 GAIM_PLUGIN_MAGIC, 2065 PURPLE_PLUGIN_MAGIC,
2066 GAIM_MAJOR_VERSION, 2066 PURPLE_MAJOR_VERSION,
2067 GAIM_MINOR_VERSION, 2067 PURPLE_MINOR_VERSION,
2068 GAIM_PLUGIN_PROTOCOL, /**< type */ 2068 PURPLE_PLUGIN_PROTOCOL, /**< type */
2069 NULL, /**< ui_requirement */ 2069 NULL, /**< ui_requirement */
2070 0, /**< flags */ 2070 0, /**< flags */
2071 NULL, /**< dependencies */ 2071 NULL, /**< dependencies */
2072 GAIM_PRIORITY_DEFAULT, /**< priority */ 2072 PURPLE_PRIORITY_DEFAULT, /**< priority */
2073 2073
2074 "prpl-msn", /**< id */ 2074 "prpl-msn", /**< id */
2075 "MSN", /**< name */ 2075 "MSN", /**< name */
2076 VERSION, /**< version */ 2076 VERSION, /**< version */
2077 /** summary */ 2077 /** summary */
2078 N_("MSN Protocol Plugin"), 2078 N_("MSN Protocol Plugin"),
2079 /** description */ 2079 /** description */
2080 N_("MSN Protocol Plugin"), 2080 N_("MSN Protocol Plugin"),
2081 "Christian Hammond <chipx86@gnupdate.org>", /**< author */ 2081 "Christian Hammond <chipx86@gnupdate.org>", /**< author */
2082 GAIM_WEBSITE, /**< homepage */ 2082 PURPLE_WEBSITE, /**< homepage */
2083 2083
2084 msn_load, /**< load */ 2084 msn_load, /**< load */
2085 msn_unload, /**< unload */ 2085 msn_unload, /**< unload */
2086 NULL, /**< destroy */ 2086 NULL, /**< destroy */
2087 2087
2090 NULL, /**< prefs_info */ 2090 NULL, /**< prefs_info */
2091 msn_actions 2091 msn_actions
2092 }; 2092 };
2093 2093
2094 static void 2094 static void
2095 init_plugin(GaimPlugin *plugin) 2095 init_plugin(PurplePlugin *plugin)
2096 { 2096 {
2097 GaimAccountOption *option; 2097 PurpleAccountOption *option;
2098 2098
2099 option = gaim_account_option_string_new(_("Server"), "server", 2099 option = purple_account_option_string_new(_("Server"), "server",
2100 MSN_SERVER); 2100 MSN_SERVER);
2101 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, 2101 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2102 option); 2102 option);
2103 2103
2104 option = gaim_account_option_int_new(_("Port"), "port", 1863); 2104 option = purple_account_option_int_new(_("Port"), "port", 1863);
2105 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, 2105 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2106 option); 2106 option);
2107 2107
2108 option = gaim_account_option_bool_new(_("Use HTTP Method"), 2108 option = purple_account_option_bool_new(_("Use HTTP Method"),
2109 "http_method", FALSE); 2109 "http_method", FALSE);
2110 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, 2110 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2111 option); 2111 option);
2112 2112
2113 option = gaim_account_option_bool_new(_("Show custom smileys"), 2113 option = purple_account_option_bool_new(_("Show custom smileys"),
2114 "custom_smileys", TRUE); 2114 "custom_smileys", TRUE);
2115 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, 2115 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2116 option); 2116 option);
2117 2117
2118 gaim_cmd_register("nudge", "", GAIM_CMD_P_PRPL, 2118 purple_cmd_register("nudge", "", PURPLE_CMD_P_PRPL,
2119 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_PRPL_ONLY, 2119 PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY,
2120 "prpl-msn", msn_cmd_nudge, 2120 "prpl-msn", msn_cmd_nudge,
2121 _("nudge: nudge a user to get their attention"), NULL); 2121 _("nudge: nudge a user to get their attention"), NULL);
2122 2122
2123 gaim_prefs_remove("/plugins/prpl/msn"); 2123 purple_prefs_remove("/plugins/prpl/msn");
2124 2124
2125 gaim_signal_connect(gaim_get_core(), "uri-handler", plugin, 2125 purple_signal_connect(purple_get_core(), "uri-handler", plugin,
2126 GAIM_CALLBACK(msn_uri_handler), NULL); 2126 PURPLE_CALLBACK(msn_uri_handler), NULL);
2127 } 2127 }
2128 2128
2129 GAIM_INIT_PLUGIN(msn, init_plugin, info); 2129 PURPLE_INIT_PLUGIN(msn, init_plugin, info);