Mercurial > pidgin
comparison libpurple/protocols/msn/userlist.c @ 15822:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 5fe8042783c1 |
children | 1ca6c4b234ab 60bc06498746 4a099e4d0d09 |
comparison
equal
deleted
inserted
replaced
15821:84b0f9b23ede | 15822:32c366eeeb99 |
---|---|
1 /** | 1 /** |
2 * @file userlist.c MSN user list support | 2 * @file userlist.c MSN user list support |
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 |
26 | 26 |
27 const char *lists[] = { "FL", "AL", "BL", "RL" }; | 27 const char *lists[] = { "FL", "AL", "BL", "RL" }; |
28 | 28 |
29 typedef struct | 29 typedef struct |
30 { | 30 { |
31 GaimConnection *gc; | 31 PurpleConnection *gc; |
32 char *who; | 32 char *who; |
33 char *friendly; | 33 char *friendly; |
34 | 34 |
35 } MsnPermitAdd; | 35 } MsnPermitAdd; |
36 | 36 |
62 g_free(pa->friendly); | 62 g_free(pa->friendly); |
63 g_free(pa); | 63 g_free(pa); |
64 } | 64 } |
65 | 65 |
66 static void | 66 static void |
67 got_new_entry(GaimConnection *gc, const char *passport, const char *friendly) | 67 got_new_entry(PurpleConnection *gc, const char *passport, const char *friendly) |
68 { | 68 { |
69 MsnPermitAdd *pa; | 69 MsnPermitAdd *pa; |
70 | 70 |
71 pa = g_new0(MsnPermitAdd, 1); | 71 pa = g_new0(MsnPermitAdd, 1); |
72 pa->who = g_strdup(passport); | 72 pa->who = g_strdup(passport); |
73 pa->friendly = g_strdup(friendly); | 73 pa->friendly = g_strdup(friendly); |
74 pa->gc = gc; | 74 pa->gc = gc; |
75 | 75 |
76 gaim_account_request_authorization(gaim_connection_get_account(gc), passport, NULL, friendly, NULL, | 76 purple_account_request_authorization(purple_connection_get_account(gc), passport, NULL, friendly, NULL, |
77 gaim_find_buddy(gaim_connection_get_account(gc), passport) != NULL, | 77 purple_find_buddy(purple_connection_get_account(gc), passport) != NULL, |
78 G_CALLBACK(msn_accept_add_cb), G_CALLBACK(msn_cancel_add_cb), pa); | 78 G_CALLBACK(msn_accept_add_cb), G_CALLBACK(msn_cancel_add_cb), pa); |
79 } | 79 } |
80 | 80 |
81 /************************************************************************** | 81 /************************************************************************** |
82 * Utility functions | 82 * Utility functions |
127 g_return_val_if_fail(user != NULL, NULL); | 127 g_return_val_if_fail(user != NULL, NULL); |
128 | 128 |
129 store_name = msn_user_get_store_name(user); | 129 store_name = msn_user_get_store_name(user); |
130 | 130 |
131 if (store_name != NULL) | 131 if (store_name != NULL) |
132 store_name = gaim_url_encode(store_name); | 132 store_name = purple_url_encode(store_name); |
133 else | 133 else |
134 store_name = msn_user_get_passport(user); | 134 store_name = msn_user_get_passport(user); |
135 | 135 |
136 /* this might be a bit of a hack, but it should prevent notification server | 136 /* this might be a bit of a hack, but it should prevent notification server |
137 * disconnections for people who have buddies with insane friendly names | 137 * disconnections for people who have buddies with insane friendly names |
162 | 162 |
163 if (old_group_name) | 163 if (old_group_name) |
164 data->old_group_name = g_strdup(old_group_name); | 164 data->old_group_name = g_strdup(old_group_name); |
165 | 165 |
166 trans = msn_transaction_new(cmdproc, "ADG", "%s %d", | 166 trans = msn_transaction_new(cmdproc, "ADG", "%s %d", |
167 gaim_url_encode(new_group_name), | 167 purple_url_encode(new_group_name), |
168 0); | 168 0); |
169 | 169 |
170 msn_transaction_set_data(trans, data); | 170 msn_transaction_set_data(trans, data); |
171 | 171 |
172 msn_cmdproc_send_trans(cmdproc, trans); | 172 msn_cmdproc_send_trans(cmdproc, trans); |
193 | 193 |
194 void | 194 void |
195 msn_got_add_user(MsnSession *session, MsnUser *user, | 195 msn_got_add_user(MsnSession *session, MsnUser *user, |
196 MsnListId list_id, int group_id) | 196 MsnListId list_id, int group_id) |
197 { | 197 { |
198 GaimAccount *account; | 198 PurpleAccount *account; |
199 const char *passport; | 199 const char *passport; |
200 const char *friendly; | 200 const char *friendly; |
201 | 201 |
202 account = session->account; | 202 account = session->account; |
203 | 203 |
204 passport = msn_user_get_passport(user); | 204 passport = msn_user_get_passport(user); |
205 friendly = msn_user_get_friendly_name(user); | 205 friendly = msn_user_get_friendly_name(user); |
206 | 206 |
207 if (list_id == MSN_LIST_FL) | 207 if (list_id == MSN_LIST_FL) |
208 { | 208 { |
209 GaimConnection *gc; | 209 PurpleConnection *gc; |
210 | 210 |
211 gc = gaim_account_get_connection(account); | 211 gc = purple_account_get_connection(account); |
212 | 212 |
213 serv_got_alias(gc, passport, friendly); | 213 serv_got_alias(gc, passport, friendly); |
214 | 214 |
215 if (group_id >= 0) | 215 if (group_id >= 0) |
216 { | 216 { |
221 /* session->sync->fl_users_count++; */ | 221 /* session->sync->fl_users_count++; */ |
222 } | 222 } |
223 } | 223 } |
224 else if (list_id == MSN_LIST_AL) | 224 else if (list_id == MSN_LIST_AL) |
225 { | 225 { |
226 gaim_privacy_permit_add(account, passport, TRUE); | 226 purple_privacy_permit_add(account, passport, TRUE); |
227 } | 227 } |
228 else if (list_id == MSN_LIST_BL) | 228 else if (list_id == MSN_LIST_BL) |
229 { | 229 { |
230 gaim_privacy_deny_add(account, passport, TRUE); | 230 purple_privacy_deny_add(account, passport, TRUE); |
231 } | 231 } |
232 else if (list_id == MSN_LIST_RL) | 232 else if (list_id == MSN_LIST_RL) |
233 { | 233 { |
234 GaimConnection *gc; | 234 PurpleConnection *gc; |
235 GaimConversation *convo; | 235 PurpleConversation *convo; |
236 | 236 |
237 gc = gaim_account_get_connection(account); | 237 gc = purple_account_get_connection(account); |
238 | 238 |
239 gaim_debug_info("msn", | 239 purple_debug_info("msn", |
240 "%s has added you to his or her buddy list.\n", | 240 "%s has added you to his or her buddy list.\n", |
241 passport); | 241 passport); |
242 | 242 |
243 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, passport, account); | 243 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, passport, account); |
244 if (convo) { | 244 if (convo) { |
245 GaimBuddy *buddy; | 245 PurpleBuddy *buddy; |
246 char *msg; | 246 char *msg; |
247 | 247 |
248 buddy = gaim_find_buddy(account, passport); | 248 buddy = purple_find_buddy(account, passport); |
249 msg = g_strdup_printf( | 249 msg = g_strdup_printf( |
250 _("%s has added you to his or her buddy list."), | 250 _("%s has added you to his or her buddy list."), |
251 buddy ? gaim_buddy_get_contact_alias(buddy) : passport); | 251 buddy ? purple_buddy_get_contact_alias(buddy) : passport); |
252 gaim_conv_im_write(GAIM_CONV_IM(convo), passport, msg, | 252 purple_conv_im_write(PURPLE_CONV_IM(convo), passport, msg, |
253 GAIM_MESSAGE_SYSTEM, time(NULL)); | 253 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
254 g_free(msg); | 254 g_free(msg); |
255 } | 255 } |
256 | 256 |
257 if (!(user->list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))) | 257 if (!(user->list_op & (MSN_LIST_AL_OP | MSN_LIST_BL_OP))) |
258 { | 258 { |
264 got_new_entry(gc, passport, friendly); | 264 got_new_entry(gc, passport, friendly); |
265 } | 265 } |
266 } | 266 } |
267 | 267 |
268 user->list_op |= (1 << list_id); | 268 user->list_op |= (1 << list_id); |
269 /* gaim_user_add_list_id (user, list_id); */ | 269 /* purple_user_add_list_id (user, list_id); */ |
270 } | 270 } |
271 | 271 |
272 void | 272 void |
273 msn_got_rem_user(MsnSession *session, MsnUser *user, | 273 msn_got_rem_user(MsnSession *session, MsnUser *user, |
274 MsnListId list_id, int group_id) | 274 MsnListId list_id, int group_id) |
275 { | 275 { |
276 GaimAccount *account; | 276 PurpleAccount *account; |
277 const char *passport; | 277 const char *passport; |
278 | 278 |
279 account = session->account; | 279 account = session->account; |
280 | 280 |
281 passport = msn_user_get_passport(user); | 281 passport = msn_user_get_passport(user); |
293 /* session->sync->fl_users_count--; */ | 293 /* session->sync->fl_users_count--; */ |
294 } | 294 } |
295 } | 295 } |
296 else if (list_id == MSN_LIST_AL) | 296 else if (list_id == MSN_LIST_AL) |
297 { | 297 { |
298 gaim_privacy_permit_remove(account, passport, TRUE); | 298 purple_privacy_permit_remove(account, passport, TRUE); |
299 } | 299 } |
300 else if (list_id == MSN_LIST_BL) | 300 else if (list_id == MSN_LIST_BL) |
301 { | 301 { |
302 gaim_privacy_deny_remove(account, passport, TRUE); | 302 purple_privacy_deny_remove(account, passport, TRUE); |
303 } | 303 } |
304 else if (list_id == MSN_LIST_RL) | 304 else if (list_id == MSN_LIST_RL) |
305 { | 305 { |
306 GaimConversation *convo; | 306 PurpleConversation *convo; |
307 | 307 |
308 gaim_debug_info("msn", | 308 purple_debug_info("msn", |
309 "%s has removed you from his or her buddy list.\n", | 309 "%s has removed you from his or her buddy list.\n", |
310 passport); | 310 passport); |
311 | 311 |
312 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, passport, account); | 312 convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, passport, account); |
313 if (convo) { | 313 if (convo) { |
314 GaimBuddy *buddy; | 314 PurpleBuddy *buddy; |
315 char *msg; | 315 char *msg; |
316 | 316 |
317 buddy = gaim_find_buddy(account, passport); | 317 buddy = purple_find_buddy(account, passport); |
318 msg = g_strdup_printf( | 318 msg = g_strdup_printf( |
319 _("%s has removed you from his or her buddy list."), | 319 _("%s has removed you from his or her buddy list."), |
320 buddy ? gaim_buddy_get_contact_alias(buddy) : passport); | 320 buddy ? purple_buddy_get_contact_alias(buddy) : passport); |
321 gaim_conv_im_write(GAIM_CONV_IM(convo), passport, msg, | 321 purple_conv_im_write(PURPLE_CONV_IM(convo), passport, msg, |
322 GAIM_MESSAGE_SYSTEM, time(NULL)); | 322 PURPLE_MESSAGE_SYSTEM, time(NULL)); |
323 g_free(msg); | 323 g_free(msg); |
324 } | 324 } |
325 } | 325 } |
326 | 326 |
327 user->list_op &= ~(1 << list_id); | 327 user->list_op &= ~(1 << list_id); |
328 /* gaim_user_remove_list_id (user, list_id); */ | 328 /* purple_user_remove_list_id (user, list_id); */ |
329 | 329 |
330 if (user->list_op == 0) | 330 if (user->list_op == 0) |
331 { | 331 { |
332 gaim_debug_info("msn", "Buddy '%s' shall be deleted?.\n", | 332 purple_debug_info("msn", "Buddy '%s' shall be deleted?.\n", |
333 passport); | 333 passport); |
334 | 334 |
335 } | 335 } |
336 } | 336 } |
337 | 337 |
338 void | 338 void |
339 msn_got_lst_user(MsnSession *session, MsnUser *user, | 339 msn_got_lst_user(MsnSession *session, MsnUser *user, |
340 int list_op, GSList *group_ids) | 340 int list_op, GSList *group_ids) |
341 { | 341 { |
342 GaimConnection *gc; | 342 PurpleConnection *gc; |
343 GaimAccount *account; | 343 PurpleAccount *account; |
344 const char *passport; | 344 const char *passport; |
345 const char *store; | 345 const char *store; |
346 | 346 |
347 account = session->account; | 347 account = session->account; |
348 gc = gaim_account_get_connection(account); | 348 gc = purple_account_get_connection(account); |
349 | 349 |
350 passport = msn_user_get_passport(user); | 350 passport = msn_user_get_passport(user); |
351 store = msn_user_get_store_name(user); | 351 store = msn_user_get_store_name(user); |
352 | 352 |
353 if (list_op & MSN_LIST_FL_OP) | 353 if (list_op & MSN_LIST_FL_OP) |
366 } | 366 } |
367 | 367 |
368 if (list_op & MSN_LIST_AL_OP) | 368 if (list_op & MSN_LIST_AL_OP) |
369 { | 369 { |
370 /* These are users who are allowed to see our status. */ | 370 /* These are users who are allowed to see our status. */ |
371 gaim_privacy_deny_remove(account, passport, TRUE); | 371 purple_privacy_deny_remove(account, passport, TRUE); |
372 gaim_privacy_permit_add(account, passport, TRUE); | 372 purple_privacy_permit_add(account, passport, TRUE); |
373 } | 373 } |
374 | 374 |
375 if (list_op & MSN_LIST_BL_OP) | 375 if (list_op & MSN_LIST_BL_OP) |
376 { | 376 { |
377 /* These are users who are not allowed to see our status. */ | 377 /* These are users who are not allowed to see our status. */ |
378 gaim_privacy_permit_remove(account, passport, TRUE); | 378 purple_privacy_permit_remove(account, passport, TRUE); |
379 gaim_privacy_deny_add(account, passport, TRUE); | 379 purple_privacy_deny_add(account, passport, TRUE); |
380 } | 380 } |
381 | 381 |
382 if (list_op & MSN_LIST_RL_OP) | 382 if (list_op & MSN_LIST_RL_OP) |
383 { | 383 { |
384 /* These are users who have us on their buddy list. */ | 384 /* These are users who have us on their buddy list. */ |
440 g_list_free(userlist->groups); | 440 g_list_free(userlist->groups); |
441 | 441 |
442 g_queue_free(userlist->buddy_icon_requests); | 442 g_queue_free(userlist->buddy_icon_requests); |
443 | 443 |
444 if (userlist->buddy_icon_request_timer) | 444 if (userlist->buddy_icon_request_timer) |
445 gaim_timeout_remove(userlist->buddy_icon_request_timer); | 445 purple_timeout_remove(userlist->buddy_icon_request_timer); |
446 | 446 |
447 g_free(userlist); | 447 g_free(userlist); |
448 } | 448 } |
449 | 449 |
450 void | 450 void |
597 group_id = msn_userlist_find_group_id(userlist, group_name); | 597 group_id = msn_userlist_find_group_id(userlist, group_name); |
598 | 598 |
599 if (group_id < 0) | 599 if (group_id < 0) |
600 { | 600 { |
601 /* Whoa, there is no such group. */ | 601 /* Whoa, there is no such group. */ |
602 gaim_debug_error("msn", "Group doesn't exist: %s\n", group_name); | 602 purple_debug_error("msn", "Group doesn't exist: %s\n", group_name); |
603 return; | 603 return; |
604 } | 604 } |
605 } | 605 } |
606 | 606 |
607 /* First we're going to check if not there. */ | 607 /* First we're going to check if not there. */ |
608 if (!(user_is_there(user, list_id, group_id))) | 608 if (!(user_is_there(user, list_id, group_id))) |
609 { | 609 { |
610 list = lists[list_id]; | 610 list = lists[list_id]; |
611 gaim_debug_error("msn", "User '%s' is not there: %s\n", | 611 purple_debug_error("msn", "User '%s' is not there: %s\n", |
612 who, list); | 612 who, list); |
613 return; | 613 return; |
614 } | 614 } |
615 | 615 |
616 /* Then request the rem to the server. */ | 616 /* Then request the rem to the server. */ |
629 const char *list; | 629 const char *list; |
630 const char *store_name; | 630 const char *store_name; |
631 | 631 |
632 group_id = -1; | 632 group_id = -1; |
633 | 633 |
634 if (!gaim_email_is_valid(who)) | 634 if (!purple_email_is_valid(who)) |
635 { | 635 { |
636 /* only notify the user about problems adding to the friends list | 636 /* only notify the user about problems adding to the friends list |
637 * maybe we should do something else for other lists, but it probably | 637 * maybe we should do something else for other lists, but it probably |
638 * won't cause too many problems if we just ignore it */ | 638 * won't cause too many problems if we just ignore it */ |
639 if (list_id == MSN_LIST_FL) | 639 if (list_id == MSN_LIST_FL) |
640 { | 640 { |
641 char *str = g_strdup_printf(_("Unable to add \"%s\"."), who); | 641 char *str = g_strdup_printf(_("Unable to add \"%s\"."), who); |
642 gaim_notify_error(NULL, NULL, str, | 642 purple_notify_error(NULL, NULL, str, |
643 _("The screen name specified is invalid.")); | 643 _("The screen name specified is invalid.")); |
644 g_free(str); | 644 g_free(str); |
645 } | 645 } |
646 | 646 |
647 return; | 647 return; |
663 | 663 |
664 /* First we're going to check if it's already there. */ | 664 /* First we're going to check if it's already there. */ |
665 if (user_is_there(user, list_id, group_id)) | 665 if (user_is_there(user, list_id, group_id)) |
666 { | 666 { |
667 list = lists[list_id]; | 667 list = lists[list_id]; |
668 gaim_debug_error("msn", "User '%s' is already there: %s\n", who, list); | 668 purple_debug_error("msn", "User '%s' is already there: %s\n", who, list); |
669 return; | 669 return; |
670 } | 670 } |
671 | 671 |
672 store_name = (user != NULL) ? get_store_name(user) : who; | 672 store_name = (user != NULL) ? get_store_name(user) : who; |
673 | 673 |