comparison src/protocols/novell/novell.c @ 9285:7a8aa87164ae

[gaim-migrate @ 10088] Ok I'm done. This started out as shx's patch to make add/remove buddy/buddies take GaimBuddy and GaimGroup's in various places. I think his diff was like 2000 lines and mine is like 5000. I tried to clean up blist.c a bit and make it more uniform. There are some more g_return_if_fail() checks. Removed some code that was deprecated--it's probably been long enough. Removed some #include <multi.h>'s. Make blist.xml saving happen on a timer, like prefs.xml and accounts.xml. Sorry if this doesn't merge cleanly with whatever you're doing. People should really test this a lot. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 15 Jun 2004 02:37:27 +0000
parents 54fb1f466953
children b3bda982996b
comparison
equal deleted inserted replaced
9284:fe0291162312 9285:7a8aa87164ae
2428 2428
2429 return -1; 2429 return -1;
2430 } 2430 }
2431 2431
2432 static void 2432 static void
2433 novell_add_buddy(GaimConnection * gc, const char *name, GaimGroup * group) 2433 novell_add_buddy(GaimConnection * gc, GaimBuddy *buddy, GaimGroup * group)
2434 { 2434 {
2435 GaimBuddy *buddy;
2436 NMFolder *folder = NULL; 2435 NMFolder *folder = NULL;
2437 NMContact *contact; 2436 NMContact *contact;
2438 NMUser *user; 2437 NMUser *user;
2439 NMERR_T rc = NM_OK; 2438 NMERR_T rc = NM_OK;
2440 2439 const char *alias;
2441 if (gc == NULL || name == NULL || group == NULL) 2440
2441 if (gc == NULL || buddy == NULL || group == NULL)
2442 return; 2442 return;
2443 2443
2444 user = (NMUser *) gc->proto_data; 2444 user = (NMUser *) gc->proto_data;
2445 if (user == NULL) 2445 if (user == NULL)
2446 return; 2446 return;
2447 2447
2448 contact = nm_create_contact(); 2448 contact = nm_create_contact();
2449 nm_contact_set_dn(contact, name); 2449 nm_contact_set_dn(contact, buddy->name);
2450 2450
2451 /* Remove the GaimBuddy (we will add it back after adding it 2451 /* Remove the GaimBuddy (we will add it back after adding it
2452 * to the server side list). Save the alias if there is one. 2452 * to the server side list). Save the alias if there is one.
2453 */ 2453 */
2454 buddy = gaim_find_buddy_in_group(user->client_data, name, group); 2454 alias = gaim_get_buddy_alias(buddy);
2455 if (buddy) { 2455 if (alias && strcmp(alias, buddy->name))
2456 const char *alias = gaim_get_buddy_alias(buddy); 2456 nm_contact_set_display_name(contact, alias);
2457 2457
2458 if (alias && strcmp(alias, name)) 2458 gaim_blist_remove_buddy(buddy);
2459 nm_contact_set_display_name(contact, gaim_get_buddy_alias(buddy)); 2459 buddy = NULL;
2460 gaim_blist_remove_buddy(buddy);
2461 buddy = NULL;
2462 }
2463
2464 2460
2465 folder = nm_find_folder(user, group->name); 2461 folder = nm_find_folder(user, group->name);
2466 if (folder) { 2462 if (folder) {
2467 2463
2468 /* We have everything that we need, so send the createcontact */ 2464 /* We have everything that we need, so send the createcontact */
2479 _check_for_disconnect(user, rc); 2475 _check_for_disconnect(user, rc);
2480 2476
2481 } 2477 }
2482 2478
2483 static void 2479 static void
2484 novell_remove_buddy(GaimConnection * gc, const char *name, const char *group_name) 2480 novell_remove_buddy(GaimConnection * gc, GaimBuddy *buddy, GaimGroup *group)
2485 { 2481 {
2486 NMContact *contact; 2482 NMContact *contact;
2487 NMFolder *folder; 2483 NMFolder *folder;
2488 NMUser *user; 2484 NMUser *user;
2489 const char *dn; 2485 const char *dn;
2490 NMERR_T rc = NM_OK; 2486 NMERR_T rc = NM_OK;
2491 2487
2492 if (gc == NULL || name == NULL || group_name == NULL) 2488 if (gc == NULL || buddy == NULL || group == NULL)
2493 return; 2489 return;
2494 2490
2495 user = (NMUser *) gc->proto_data; 2491 user = (NMUser *) gc->proto_data;
2496 if (user && (dn = nm_lookup_dn(user, name))) { 2492 if (user && (dn = nm_lookup_dn(user, buddy->name))) {
2497 2493
2498 folder = nm_find_folder(user, group_name); 2494 folder = nm_find_folder(user, group->name);
2499 if (folder) { 2495 if (folder) {
2500 contact = nm_folder_find_contact(folder, dn); 2496 contact = nm_folder_find_contact(folder, dn);
2501 if (contact) { 2497 if (contact) {
2502 2498
2503 /* Remove the buddy from the contact */ 2499 /* Remove the buddy from the contact */
2511 } 2507 }
2512 } 2508 }
2513 } 2509 }
2514 2510
2515 static void 2511 static void
2516 novell_remove_group(GaimConnection * gc, const char *name) 2512 novell_remove_group(GaimConnection * gc, GaimGroup *group)
2517 { 2513 {
2518 NMUser *user; 2514 NMUser *user;
2519 NMERR_T rc = NM_OK; 2515 NMERR_T rc = NM_OK;
2520 2516
2521 if (gc == NULL || name == NULL) 2517 if (gc == NULL || group == NULL)
2522 return; 2518 return;
2523 2519
2524 user = (NMUser *) gc->proto_data; 2520 user = (NMUser *) gc->proto_data;
2525 if (user) { 2521 if (user) {
2526 NMFolder *folder = nm_find_folder(user, name); 2522 NMFolder *folder = nm_find_folder(user, group->name);
2527 2523
2528 if (folder) { 2524 if (folder) {
2529 rc = nm_send_remove_folder(user, folder, 2525 rc = nm_send_remove_folder(user, folder,
2530 _remove_folder_resp_cb, NULL); 2526 _remove_folder_resp_cb, NULL);
2531 _check_for_disconnect(user, rc); 2527 _check_for_disconnect(user, rc);
2630 } 2626 }
2631 } 2627 }
2632 2628
2633 static void 2629 static void
2634 novell_rename_group(GaimConnection * gc, const char *old_name, 2630 novell_rename_group(GaimConnection * gc, const char *old_name,
2635 const char *new_name, GList * tobemoved) 2631 GaimGroup *group, GList *moved_buddies)
2636 { 2632 {
2637 NMERR_T rc = NM_OK; 2633 NMERR_T rc = NM_OK;
2638 NMFolder *folder; 2634 NMFolder *folder;
2639 NMUser *user; 2635 NMUser *user;
2640 2636
2641 if (gc == NULL || old_name == NULL || new_name == NULL || tobemoved == NULL) { 2637 if (gc == NULL || old_name == NULL || group == NULL || moved_buddies == NULL) {
2642 return; 2638 return;
2643 } 2639 }
2644 2640
2645 user = gc->proto_data; 2641 user = gc->proto_data;
2646 if (user) { 2642 if (user) {
2647 /* Does new folder exist already? */ 2643 /* Does new folder exist already? */
2648 if (nm_find_folder(user, new_name)) { 2644 if (nm_find_folder(user, group->name)) {
2649 /* Gaim currently calls novell_group_buddy() for 2645 /* Gaim currently calls novell_group_buddy()
2650 * for all buddies in the group, so we don't 2646 * for all buddies in the group, so we don't
2651 * need to worry about this situation. 2647 * need to worry about this situation.
2652 */ 2648 */
2653 return; 2649 return;
2654 } 2650 }
2655 2651
2656 folder = nm_find_folder(user, old_name); 2652 folder = nm_find_folder(user, old_name);
2657 2653
2658 if (folder) { 2654 if (folder) {
2659 rc = nm_send_rename_folder(user, folder, new_name, 2655 rc = nm_send_rename_folder(user, folder, group->name,
2660 _rename_folder_resp_cb, NULL); 2656 _rename_folder_resp_cb, NULL);
2661 _check_for_disconnect(user, rc); 2657 _check_for_disconnect(user, rc);
2662 } 2658 }
2663 } 2659 }
2664 } 2660 }