comparison libpurple/protocols/novell/novell.c @ 32672:3828a61c44da

A boring and large patch so I can merge heads.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 23 Dec 2011 08:21:58 +0000
parents 99ca503ea087
children
comparison
equal deleted inserted replaced
32671:0e69949b3e61 32672:3828a61c44da
129 case NMERR_CREDENTIALS_MISSING: 129 case NMERR_CREDENTIALS_MISSING:
130 case NMERR_PASSWORD_INVALID: 130 case NMERR_PASSWORD_INVALID:
131 /* Don't attempt to auto-reconnect if our 131 /* Don't attempt to auto-reconnect if our
132 * password was invalid. 132 * password was invalid.
133 */ 133 */
134 if (!purple_account_get_remember_password(gc->account)) 134 if (!purple_account_get_remember_password(purple_connection_get_account(gc)))
135 purple_account_set_password(gc->account, NULL); 135 purple_account_set_password(purple_connection_get_account(gc), NULL);
136 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED; 136 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
137 break; 137 break;
138 default: 138 default:
139 /* FIXME: There are other reasons login could fail */ 139 /* FIXME: There are other reasons login could fail */
140 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; 140 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
739 739
740 if (ret_code == NM_OK) { 740 if (ret_code == NM_OK) {
741 741
742 if (allowed) { 742 if (allowed) {
743 743
744 if (!g_slist_find_custom(gc->account->permit, 744 if (!g_slist_find_custom(purple_connection_get_account(gc)->permit,
745 display_id, (GCompareFunc)purple_utf8_strcasecmp)) { 745 display_id, (GCompareFunc)purple_utf8_strcasecmp)) {
746 purple_privacy_permit_add(gc->account, display_id, TRUE); 746 purple_privacy_permit_add(purple_connection_get_account(gc), display_id, TRUE);
747 } 747 }
748 748
749 } else { 749 } else {
750 750
751 if (!g_slist_find_custom(gc->account->permit, 751 if (!g_slist_find_custom(purple_connection_get_account(gc)->permit,
752 display_id, (GCompareFunc)purple_utf8_strcasecmp)) { 752 display_id, (GCompareFunc)purple_utf8_strcasecmp)) {
753 purple_privacy_deny_add(gc->account, display_id, TRUE); 753 purple_privacy_deny_add(purple_connection_get_account(gc), display_id, TRUE);
754 } 754 }
755 } 755 }
756 756
757 } else { 757 } else {
758 758
787 if (user_record) 787 if (user_record)
788 display_id = nm_user_record_get_display_id(user_record); 788 display_id = nm_user_record_get_display_id(user_record);
789 789
790 if (display_id) { 790 if (display_id) {
791 791
792 if (!g_slist_find_custom(gc->account->deny, 792 if (!g_slist_find_custom(purple_connection_get_account(gc)->deny,
793 display_id, (GCompareFunc)purple_utf8_strcasecmp)) { 793 display_id, (GCompareFunc)purple_utf8_strcasecmp)) {
794 794
795 purple_privacy_deny_add(gc->account, display_id, TRUE); 795 purple_privacy_deny_add(purple_connection_get_account(gc), display_id, TRUE);
796 } 796 }
797 797
798 } else { 798 } else {
799 rc = nm_send_get_details(user, who, 799 rc = nm_send_get_details(user, who,
800 _get_details_resp_add_privacy_item, 800 _get_details_resp_add_privacy_item,
838 if (user_record) 838 if (user_record)
839 display_id = nm_user_record_get_display_id(user_record); 839 display_id = nm_user_record_get_display_id(user_record);
840 840
841 if (display_id) { 841 if (display_id) {
842 842
843 if (!g_slist_find_custom(gc->account->permit, 843 if (!g_slist_find_custom(purple_connection_get_account(gc)->permit,
844 display_id, 844 display_id,
845 (GCompareFunc)purple_utf8_strcasecmp)) { 845 (GCompareFunc)purple_utf8_strcasecmp)) {
846 846
847 purple_privacy_permit_add(gc->account, display_id, TRUE); 847 purple_privacy_permit_add(purple_connection_get_account(gc), display_id, TRUE);
848 } 848 }
849 849
850 } else { 850 } else {
851 rc = nm_send_get_details(user, who, 851 rc = nm_send_get_details(user, who,
852 _get_details_resp_add_privacy_item, 852 _get_details_resp_add_privacy_item,
1175 const char *status_id; 1175 const char *status_id;
1176 const char *text = NULL; 1176 const char *text = NULL;
1177 const char *dn; 1177 const char *dn;
1178 const char *name; 1178 const char *name;
1179 int idle = 0; 1179 int idle = 0;
1180 gboolean loggedin = TRUE;
1181 1180
1182 account = purple_buddy_get_account(buddy); 1181 account = purple_buddy_get_account(buddy);
1183 name = purple_buddy_get_name(buddy); 1182 name = purple_buddy_get_name(buddy);
1184 1183
1185 switch (novellstatus) { 1184 switch (novellstatus) {
1192 case NM_STATUS_BUSY: 1191 case NM_STATUS_BUSY:
1193 status_id = NOVELL_STATUS_TYPE_BUSY; 1192 status_id = NOVELL_STATUS_TYPE_BUSY;
1194 break; 1193 break;
1195 case NM_STATUS_OFFLINE: 1194 case NM_STATUS_OFFLINE:
1196 status_id = NOVELL_STATUS_TYPE_OFFLINE; 1195 status_id = NOVELL_STATUS_TYPE_OFFLINE;
1197 loggedin = FALSE;
1198 break; 1196 break;
1199 case NM_STATUS_AWAY_IDLE: 1197 case NM_STATUS_AWAY_IDLE:
1200 status_id = NOVELL_STATUS_TYPE_AWAY; 1198 status_id = NOVELL_STATUS_TYPE_AWAY;
1201 idle = gmt; 1199 idle = gmt;
1202 break; 1200 break;
1203 default: 1201 default:
1204 status_id = NOVELL_STATUS_TYPE_OFFLINE; 1202 status_id = NOVELL_STATUS_TYPE_OFFLINE;
1205 loggedin = FALSE;
1206 break; 1203 break;
1207 } 1204 }
1208 1205
1209 /* Get status text for the user */ 1206 /* Get status text for the user */
1210 dn = nm_lookup_dn(user, name); 1207 dn = nm_lookup_dn(user, name);
1402 return; 1399 return;
1403 1400
1404 /* Set the Purple privacy setting */ 1401 /* Set the Purple privacy setting */
1405 if (user->default_deny) { 1402 if (user->default_deny) {
1406 if (user->allow_list == NULL) { 1403 if (user->allow_list == NULL) {
1407 gc->account->perm_deny = PURPLE_PRIVACY_DENY_ALL; 1404 purple_account_set_privacy_type(purple_connection_get_account(gc), PURPLE_PRIVACY_DENY_ALL);
1408 } else { 1405 } else {
1409 gc->account->perm_deny = PURPLE_PRIVACY_ALLOW_USERS; 1406 purple_account_set_privacy_type(purple_connection_get_account(gc), PURPLE_PRIVACY_ALLOW_USERS);
1410 } 1407 }
1411 } else { 1408 } else {
1412 if (user->deny_list == NULL) { 1409 if (user->deny_list == NULL) {
1413 gc->account->perm_deny = PURPLE_PRIVACY_ALLOW_ALL; 1410 purple_account_set_privacy_type(purple_connection_get_account(gc), PURPLE_PRIVACY_ALLOW_ALL);
1414 } else { 1411 } else {
1415 gc->account->perm_deny = PURPLE_PRIVACY_DENY_USERS; 1412 purple_account_set_privacy_type(purple_connection_get_account(gc), PURPLE_PRIVACY_DENY_USERS);
1416 } 1413 }
1417 } 1414 }
1418 1415
1419 /* Add stuff */ 1416 /* Add stuff */
1420 for (node = user->allow_list; node; node = node->next) { 1417 for (node = user->allow_list; node; node = node->next) {
1422 if (user_record) 1419 if (user_record)
1423 name = nm_user_record_get_display_id(user_record); 1420 name = nm_user_record_get_display_id(user_record);
1424 else 1421 else
1425 name =(char *)node->data; 1422 name =(char *)node->data;
1426 1423
1427 if (!g_slist_find_custom(gc->account->permit, 1424 if (!g_slist_find_custom(purple_connection_get_account(gc)->permit,
1428 name, (GCompareFunc)purple_utf8_strcasecmp)) { 1425 name, (GCompareFunc)purple_utf8_strcasecmp)) {
1429 purple_privacy_permit_add(gc->account, name , TRUE); 1426 purple_privacy_permit_add(purple_connection_get_account(gc), name , TRUE);
1430 } 1427 }
1431 } 1428 }
1432 1429
1433 for (node = user->deny_list; node; node = node->next) { 1430 for (node = user->deny_list; node; node = node->next) {
1434 user_record = nm_find_user_record(user, (char *)node->data); 1431 user_record = nm_find_user_record(user, (char *)node->data);
1435 if (user_record) 1432 if (user_record)
1436 name = nm_user_record_get_display_id(user_record); 1433 name = nm_user_record_get_display_id(user_record);
1437 else 1434 else
1438 name =(char *)node->data; 1435 name =(char *)node->data;
1439 1436
1440 if (!g_slist_find_custom(gc->account->deny, 1437 if (!g_slist_find_custom(purple_connection_get_account(gc)->deny,
1441 name, (GCompareFunc)purple_utf8_strcasecmp)) { 1438 name, (GCompareFunc)purple_utf8_strcasecmp)) {
1442 purple_privacy_deny_add(gc->account, name, TRUE); 1439 purple_privacy_deny_add(purple_connection_get_account(gc), name, TRUE);
1443 } 1440 }
1444 } 1441 }
1445 1442
1446 1443
1447 /* Remove stuff */ 1444 /* Remove stuff */
1448 for (node = gc->account->permit; node; node = node->next) { 1445 for (node = purple_connection_get_account(gc)->permit; node; node = node->next) {
1449 dn = nm_lookup_dn(user, (char *)node->data); 1446 dn = nm_lookup_dn(user, (char *)node->data);
1450 if (dn != NULL && 1447 if (dn != NULL &&
1451 !g_slist_find_custom(user->allow_list, 1448 !g_slist_find_custom(user->allow_list,
1452 dn, (GCompareFunc)purple_utf8_strcasecmp)) { 1449 dn, (GCompareFunc)purple_utf8_strcasecmp)) {
1453 rem_list = g_slist_append(rem_list, node->data); 1450 rem_list = g_slist_append(rem_list, node->data);
1454 } 1451 }
1455 } 1452 }
1456 1453
1457 if (rem_list) { 1454 if (rem_list) {
1458 for (node = rem_list; node; node = node->next) { 1455 for (node = rem_list; node; node = node->next) {
1459 purple_privacy_permit_remove(gc->account, (char *)node->data, TRUE); 1456 purple_privacy_permit_remove(purple_connection_get_account(gc), (char *)node->data, TRUE);
1460 } 1457 }
1461 g_slist_free(rem_list); 1458 g_slist_free(rem_list);
1462 rem_list = NULL; 1459 rem_list = NULL;
1463 } 1460 }
1464 1461
1465 for (node = gc->account->deny; node; node = node->next) { 1462 for (node = purple_connection_get_account(gc)->deny; node; node = node->next) {
1466 dn = nm_lookup_dn(user, (char *)node->data); 1463 dn = nm_lookup_dn(user, (char *)node->data);
1467 if (dn != NULL && 1464 if (dn != NULL &&
1468 !g_slist_find_custom(user->deny_list, 1465 !g_slist_find_custom(user->deny_list,
1469 dn, (GCompareFunc)purple_utf8_strcasecmp)) { 1466 dn, (GCompareFunc)purple_utf8_strcasecmp)) {
1470 rem_list = g_slist_append(rem_list, node->data); 1467 rem_list = g_slist_append(rem_list, node->data);
1471 } 1468 }
1472 } 1469 }
1473 1470
1474 if (rem_list) { 1471 if (rem_list) {
1475 for (node = rem_list; node; node = node->next) { 1472 for (node = rem_list; node; node = node->next) {
1476 purple_privacy_deny_remove(gc->account, (char *)node->data, TRUE); 1473 purple_privacy_deny_remove(purple_connection_get_account(gc), (char *)node->data, TRUE);
1477 } 1474 }
1478 g_slist_free(rem_list); 1475 g_slist_free(rem_list);
1479 } 1476 }
1480 } 1477 }
1481 1478
1627 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 1624 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
1628 1625
1629 buddy = (PurpleBuddy *) node; 1626 buddy = (PurpleBuddy *) node;
1630 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); 1627 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
1631 1628
1632 user = gc->proto_data; 1629 user = purple_connection_get_protocol_data(gc);
1633 if (user == NULL) 1630 if (user == NULL)
1634 return; 1631 return;
1635 1632
1636 /* We should already have a userrecord for the buddy */ 1633 /* We should already have a userrecord for the buddy */
1637 user_record = nm_find_user_record(user, purple_buddy_get_name(buddy)); 1634 user_record = nm_find_user_record(user, purple_buddy_get_name(buddy));
1683 { 1680 {
1684 PurpleConnection *gc; 1681 PurpleConnection *gc;
1685 NMUser *user; 1682 NMUser *user;
1686 1683
1687 gc = data; 1684 gc = data;
1688 user = gc->proto_data; 1685 user = purple_connection_get_protocol_data(gc);
1689 user->conn->ssl_conn->data = NULL; 1686 user->conn->ssl_conn->data = NULL;
1690 1687
1691 purple_connection_ssl_error (gc, error); 1688 purple_connection_ssl_error (gc, error);
1692 } 1689 }
1693 1690
1700 NMERR_T rc; 1697 NMERR_T rc;
1701 1698
1702 if (gc == NULL) 1699 if (gc == NULL)
1703 return; 1700 return;
1704 1701
1705 user = gc->proto_data; 1702 user = purple_connection_get_protocol_data(gc);
1706 if (user == NULL) 1703 if (user == NULL)
1707 return; 1704 return;
1708 1705
1709 rc = nm_process_new_data(user); 1706 rc = nm_process_new_data(user);
1710 if (rc != NM_OK) { 1707 if (rc != NM_OK) {
1734 char *ua = NULL; 1731 char *ua = NULL;
1735 1732
1736 if (gc == NULL || gsc == NULL) 1733 if (gc == NULL || gsc == NULL)
1737 return; 1734 return;
1738 1735
1739 user = gc->proto_data; 1736 user = purple_connection_get_protocol_data(gc);
1740 if ((user == NULL) || (conn = user->conn) == NULL) 1737 if ((user == NULL) || (conn = user->conn) == NULL)
1741 return; 1738 return;
1742 1739
1743 purple_connection_update_progress(gc, _("Authenticating..."), 1740 purple_connection_update_progress(gc, _("Authenticating..."),
1744 2, NOVELL_CONNECT_STEPS); 1741 2, NOVELL_CONNECT_STEPS);
2204 name = purple_account_get_username(account); 2201 name = purple_account_get_username(account);
2205 2202
2206 user = nm_initialize_user(name, server, port, account, _event_callback); 2203 user = nm_initialize_user(name, server, port, account, _event_callback);
2207 if (user && user->conn) { 2204 if (user && user->conn) {
2208 /* save user */ 2205 /* save user */
2209 gc->proto_data = user; 2206 purple_connection_set_protocol_data(gc, user);
2210 2207
2211 /* connect to the server */ 2208 /* connect to the server */
2212 purple_connection_update_progress(gc, _("Connecting"), 2209 purple_connection_update_progress(gc, _("Connecting"),
2213 1, NOVELL_CONNECT_STEPS); 2210 1, NOVELL_CONNECT_STEPS);
2214 2211
2236 NMConn *conn; 2233 NMConn *conn;
2237 2234
2238 if (gc == NULL) 2235 if (gc == NULL)
2239 return; 2236 return;
2240 2237
2241 user = gc->proto_data; 2238 user = purple_connection_get_protocol_data(gc);
2242 if (user) { 2239 if (user) {
2243 conn = user->conn; 2240 conn = user->conn;
2244 if (conn && conn->ssl_conn) { 2241 if (conn && conn->ssl_conn) {
2245 purple_ssl_close(user->conn->ssl_conn->data); 2242 purple_ssl_close(user->conn->ssl_conn->data);
2246 } 2243 }
2247 nm_deinitialize_user(user); 2244 nm_deinitialize_user(user);
2248 } 2245 }
2249 gc->proto_data = NULL; 2246 purple_connection_set_protocol_data(gc, NULL);
2250 } 2247 }
2251 2248
2252 static int 2249 static int
2253 novell_send_im(PurpleConnection * gc, const char *name, 2250 novell_send_im(PurpleConnection * gc, const char *name,
2254 const char *message_body, PurpleMessageFlags flags) 2251 const char *message_body, PurpleMessageFlags flags)
2264 2261
2265 if (gc == NULL || name == NULL || 2262 if (gc == NULL || name == NULL ||
2266 message_body == NULL || *message_body == '\0') 2263 message_body == NULL || *message_body == '\0')
2267 return 0; 2264 return 0;
2268 2265
2269 user = gc->proto_data; 2266 user = purple_connection_get_protocol_data(gc);
2270 if (user == NULL) 2267 if (user == NULL)
2271 return 0; 2268 return 0;
2272 2269
2273 /* Create a new message */ 2270 /* Create a new message */
2274 plain = purple_unescape_html(message_body); 2271 plain = purple_unescape_html(message_body);
2350 NMERR_T rc = NM_OK; 2347 NMERR_T rc = NM_OK;
2351 2348
2352 if (gc == NULL || name == NULL) 2349 if (gc == NULL || name == NULL)
2353 return 0; 2350 return 0;
2354 2351
2355 user = gc->proto_data; 2352 user = purple_connection_get_protocol_data(gc);
2356 if (user == NULL) 2353 if (user == NULL)
2357 return 0; 2354 return 0;
2358 2355
2359 /* Need to get the DN for the buddy so we can look up the convo */ 2356 /* Need to get the DN for the buddy so we can look up the convo */
2360 dn = nm_lookup_dn(user, name); 2357 dn = nm_lookup_dn(user, name);
2384 NMERR_T rc = NM_OK; 2381 NMERR_T rc = NM_OK;
2385 2382
2386 if (gc == NULL || who == NULL) 2383 if (gc == NULL || who == NULL)
2387 return; 2384 return;
2388 2385
2389 user = gc->proto_data; 2386 user = purple_connection_get_protocol_data(gc);
2390 if (user && (dn = nm_lookup_dn(user, who))) { 2387 if (user && (dn = nm_lookup_dn(user, who))) {
2391 conf = nm_find_conversation(user, dn); 2388 conf = nm_find_conversation(user, dn);
2392 if (conf) { 2389 if (conf) {
2393 rc = nm_send_leave_conference(user, conf, NULL, NULL); 2390 rc = nm_send_leave_conference(user, conf, NULL, NULL);
2394 _check_for_disconnect(user, rc); 2391 _check_for_disconnect(user, rc);
2406 NMERR_T rc = NM_OK; 2403 NMERR_T rc = NM_OK;
2407 2404
2408 if (gc == NULL) 2405 if (gc == NULL)
2409 return; 2406 return;
2410 2407
2411 user = gc->proto_data; 2408 user = purple_connection_get_protocol_data(gc);
2412 if (user == NULL) 2409 if (user == NULL)
2413 return; 2410 return;
2414 2411
2415 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) { 2412 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) {
2416 conference = cnode->data; 2413 conference = cnode->data;
2438 NMUserRecord *user_record = NULL; 2435 NMUserRecord *user_record = NULL;
2439 2436
2440 if (gc == NULL) 2437 if (gc == NULL)
2441 return; 2438 return;
2442 2439
2443 user = gc->proto_data; 2440 user = purple_connection_get_protocol_data(gc);
2444 if (user == NULL) 2441 if (user == NULL)
2445 return; 2442 return;
2446 2443
2447 user_record = nm_find_user_record(user, who); 2444 user_record = nm_find_user_record(user, who);
2448 if (user_record == NULL) { 2445 if (user_record == NULL) {
2477 char *str, *plain; 2474 char *str, *plain;
2478 2475
2479 if (gc == NULL || text == NULL) 2476 if (gc == NULL || text == NULL)
2480 return -1; 2477 return -1;
2481 2478
2482 user = gc->proto_data; 2479 user = purple_connection_get_protocol_data(gc);
2483 if (user == NULL) 2480 if (user == NULL)
2484 return -1; 2481 return -1;
2485 2482
2486 plain = purple_unescape_html(text); 2483 plain = purple_unescape_html(text);
2487 message = nm_create_message(plain); 2484 message = nm_create_message(plain);
2543 2540
2544 return -1; 2541 return -1;
2545 } 2542 }
2546 2543
2547 static void 2544 static void
2548 novell_add_buddy(PurpleConnection * gc, PurpleBuddy *buddy, PurpleGroup * group) 2545 novell_add_buddy(PurpleConnection * gc, PurpleBuddy *buddy, PurpleGroup * group, const char *message)
2549 { 2546 {
2550 NMFolder *folder = NULL; 2547 NMFolder *folder = NULL;
2551 NMContact *contact; 2548 NMContact *contact;
2552 NMUser *user; 2549 NMUser *user;
2553 NMERR_T rc = NM_OK; 2550 NMERR_T rc = NM_OK;
2617 NMERR_T rc = NM_OK; 2614 NMERR_T rc = NM_OK;
2618 2615
2619 if (gc == NULL || buddy == NULL || group == NULL) 2616 if (gc == NULL || buddy == NULL || group == NULL)
2620 return; 2617 return;
2621 2618
2622 user = (NMUser *) gc->proto_data; 2619 user = purple_connection_get_protocol_data(gc);
2623 if (user && (dn = nm_lookup_dn(user, purple_buddy_get_name(buddy)))) { 2620 if (user && (dn = nm_lookup_dn(user, purple_buddy_get_name(buddy)))) {
2624 gname = purple_group_get_name(group); 2621 gname = purple_group_get_name(group);
2625 if (strcmp(gname, NM_ROOT_FOLDER_NAME) == 0) { 2622 if (strcmp(gname, NM_ROOT_FOLDER_NAME) == 0) {
2626 gname = ""; 2623 gname = "";
2627 } 2624 }
2649 NMERR_T rc = NM_OK; 2646 NMERR_T rc = NM_OK;
2650 2647
2651 if (gc == NULL || group == NULL) 2648 if (gc == NULL || group == NULL)
2652 return; 2649 return;
2653 2650
2654 user = (NMUser *) gc->proto_data; 2651 user = purple_connection_get_protocol_data(gc);
2655 if (user) { 2652 if (user) {
2656 NMFolder *folder = nm_find_folder(user, purple_group_get_name(group)); 2653 NMFolder *folder = nm_find_folder(user, purple_group_get_name(group));
2657 2654
2658 if (folder) { 2655 if (folder) {
2659 rc = nm_send_remove_folder(user, folder, 2656 rc = nm_send_remove_folder(user, folder,
2674 NMERR_T rc = NM_OK; 2671 NMERR_T rc = NM_OK;
2675 2672
2676 if (gc == NULL || name == NULL || alias == NULL) 2673 if (gc == NULL || name == NULL || alias == NULL)
2677 return; 2674 return;
2678 2675
2679 user = (NMUser *) gc->proto_data; 2676 user = purple_connection_get_protocol_data(gc);
2680 if (user && (dn = nm_lookup_dn(user, name))) { 2677 if (user && (dn = nm_lookup_dn(user, name))) {
2681 2678
2682 /* Alias all of instances of the contact */ 2679 /* Alias all of instances of the contact */
2683 contacts = nm_find_contacts(user, dn); 2680 contacts = nm_find_contacts(user, dn);
2684 for (cnode = contacts; cnode != NULL; cnode = cnode->next) { 2681 for (cnode = contacts; cnode != NULL; cnode = cnode->next) {
2733 2730
2734 if (gc == NULL || name == NULL || 2731 if (gc == NULL || name == NULL ||
2735 old_group_name == NULL || new_group_name == NULL) 2732 old_group_name == NULL || new_group_name == NULL)
2736 return; 2733 return;
2737 2734
2738 user = (NMUser *) gc->proto_data; 2735 user = purple_connection_get_protocol_data(gc);
2739 if (user && (dn = nm_lookup_dn(user, name))) { 2736 if (user && (dn = nm_lookup_dn(user, name))) {
2740 2737
2741 /* Find the old folder */ 2738 /* Find the old folder */
2742 if (strcmp(old_group_name, NM_ROOT_FOLDER_NAME) == 0) { 2739 if (strcmp(old_group_name, NM_ROOT_FOLDER_NAME) == 0) {
2743 old_folder = nm_get_root_folder(user); 2740 old_folder = nm_get_root_folder(user);
2791 2788
2792 if (gc == NULL || old_name == NULL || group == NULL || moved_buddies == NULL) { 2789 if (gc == NULL || old_name == NULL || group == NULL || moved_buddies == NULL) {
2793 return; 2790 return;
2794 } 2791 }
2795 2792
2796 user = gc->proto_data; 2793 user = purple_connection_get_protocol_data(gc);
2797 if (user) { 2794 if (user) {
2798 const char *gname = purple_group_get_name(group); 2795 const char *gname = purple_group_get_name(group);
2799 /* Does new folder exist already? */ 2796 /* Does new folder exist already? */
2800 if (nm_find_folder(user, gname)) { 2797 if (nm_find_folder(user, gname)) {
2801 /* purple_blist_rename_group() adds the buddies 2798 /* purple_blist_rename_group() adds the buddies
2837 2834
2838 if (buddy == NULL) 2835 if (buddy == NULL)
2839 return; 2836 return;
2840 2837
2841 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); 2838 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
2842 if (gc == NULL || (user = gc->proto_data) == NULL) 2839 if (gc == NULL || (user = purple_connection_get_protocol_data(gc)) == NULL)
2843 return; 2840 return;
2844 2841
2845 if (PURPLE_BUDDY_IS_ONLINE(buddy)) { 2842 if (PURPLE_BUDDY_IS_ONLINE(buddy)) {
2846 user_record = nm_find_user_record(user, purple_buddy_get_name(buddy)); 2843 user_record = nm_find_user_record(user, purple_buddy_get_name(buddy));
2847 if (user_record) { 2844 if (user_record) {
2889 PurpleStatus *status = NULL; 2886 PurpleStatus *status = NULL;
2890 2887
2891 if (gc == NULL) 2888 if (gc == NULL)
2892 return; 2889 return;
2893 2890
2894 user = gc->proto_data; 2891 user = purple_connection_get_protocol_data(gc);
2895 if (user == NULL) 2892 if (user == NULL)
2896 return; 2893 return;
2897 2894
2898 status = purple_account_get_active_status(purple_connection_get_account(gc)); 2895 status = purple_account_get_active_status(purple_connection_get_account(gc));
2899 id = purple_status_get_id(status); 2896 id = purple_status_get_id(status);
2918 NMERR_T rc; 2915 NMERR_T rc;
2919 2916
2920 if (gc == NULL || name == NULL) 2917 if (gc == NULL || name == NULL)
2921 return; 2918 return;
2922 2919
2923 user = (NMUser *) gc->proto_data; 2920 user = purple_connection_get_protocol_data(gc);
2924 if (user) { 2921 if (user) {
2925 2922
2926 user_record = nm_find_user_record(user, name); 2923 user_record = nm_find_user_record(user, name);
2927 if (user_record) { 2924 if (user_record) {
2928 _show_info(gc, user_record, g_strdup(name)); 2925 _show_info(gc, user_record, g_strdup(name));
2947 2944
2948 account = buddy ? purple_buddy_get_account(buddy) : NULL; 2945 account = buddy ? purple_buddy_get_account(buddy) : NULL;
2949 if (buddy && account) { 2946 if (buddy && account) {
2950 PurpleConnection *gc = purple_account_get_connection(account); 2947 PurpleConnection *gc = purple_account_get_connection(account);
2951 2948
2952 if (gc && gc->proto_data) { 2949 if (gc) {
2953 NMUser *user = gc->proto_data; 2950 NMUser *user = purple_connection_get_protocol_data(gc);
2954 2951
2955 dn = nm_lookup_dn(user, purple_buddy_get_name(buddy)); 2952 if (user) {
2956 if (dn) { 2953 dn = nm_lookup_dn(user, purple_buddy_get_name(buddy));
2957 NMUserRecord *user_record = nm_find_user_record(user, dn); 2954 if (dn) {
2958 2955 NMUserRecord *user_record = nm_find_user_record(user, dn);
2959 if (user_record) { 2956
2960 text = nm_user_record_get_status_text(user_record); 2957 if (user_record) {
2961 if (text) 2958 text = nm_user_record_get_status_text(user_record);
2962 return g_strdup(text); 2959 if (text)
2960 return g_strdup(text);
2961 }
2963 } 2962 }
2964 } 2963 }
2965 } 2964 }
2966 } 2965 }
2967 2966
3033 3032
3034 if (!connected) 3033 if (!connected)
3035 return; 3034 return;
3036 3035
3037 gc = purple_account_get_connection(account); 3036 gc = purple_account_get_connection(account);
3038 user = gc->proto_data; 3037 user = purple_connection_get_protocol_data(gc);
3039 if (user == NULL) 3038 if (user == NULL)
3040 return; 3039 return;
3041 3040
3042 if (primitive == PURPLE_STATUS_AVAILABLE) { 3041 if (primitive == PURPLE_STATUS_AVAILABLE) {
3043 novellstatus = NM_STATUS_AVAILABLE; 3042 novellstatus = NM_STATUS_AVAILABLE;
3080 const char *name = who; 3079 const char *name = who;
3081 3080
3082 if (gc == NULL || who == NULL) 3081 if (gc == NULL || who == NULL)
3083 return; 3082 return;
3084 3083
3085 user = gc->proto_data; 3084 user = purple_connection_get_protocol_data(gc);
3086 if (user == NULL) 3085 if (user == NULL)
3087 return; 3086 return;
3088 3087
3089 /* Remove first -- we will add it back in when we get 3088 /* Remove first -- we will add it back in when we get
3090 * the okay from the server 3089 * the okay from the server
3091 */ 3090 */
3092 purple_privacy_permit_remove(gc->account, who, TRUE); 3091 purple_privacy_permit_remove(purple_connection_get_account(gc), who, TRUE);
3093 3092
3094 if (nm_user_is_privacy_locked(user)) { 3093 if (nm_user_is_privacy_locked(user)) {
3095 _show_privacy_locked_error(gc, user); 3094 _show_privacy_locked_error(gc, user);
3096 _sync_privacy_lists(user); 3095 _sync_privacy_lists(user);
3097 return; 3096 return;
3124 const char *name = who; 3123 const char *name = who;
3125 3124
3126 if (gc == NULL || who == NULL) 3125 if (gc == NULL || who == NULL)
3127 return; 3126 return;
3128 3127
3129 user = gc->proto_data; 3128 user = purple_connection_get_protocol_data(gc);
3130 if (user == NULL) 3129 if (user == NULL)
3131 return; 3130 return;
3132 3131
3133 /* Remove first -- we will add it back in when we get 3132 /* Remove first -- we will add it back in when we get
3134 * the okay from the server 3133 * the okay from the server
3135 */ 3134 */
3136 purple_privacy_deny_remove(gc->account, who, TRUE); 3135 purple_privacy_deny_remove(purple_connection_get_account(gc), who, TRUE);
3137 3136
3138 if (nm_user_is_privacy_locked(user)) { 3137 if (nm_user_is_privacy_locked(user)) {
3139 _show_privacy_locked_error(gc, user); 3138 _show_privacy_locked_error(gc, user);
3140 _sync_privacy_lists(user); 3139 _sync_privacy_lists(user);
3141 return; 3140 return;
3168 const char *dn = NULL; 3167 const char *dn = NULL;
3169 3168
3170 if (gc == NULL || who == NULL) 3169 if (gc == NULL || who == NULL)
3171 return; 3170 return;
3172 3171
3173 user = gc->proto_data; 3172 user = purple_connection_get_protocol_data(gc);
3174 if (user == NULL) 3173 if (user == NULL)
3175 return; 3174 return;
3176 3175
3177 if (nm_user_is_privacy_locked(user)) { 3176 if (nm_user_is_privacy_locked(user)) {
3178 _show_privacy_locked_error(gc, user); 3177 _show_privacy_locked_error(gc, user);
3198 const char *dn = NULL; 3197 const char *dn = NULL;
3199 3198
3200 if (gc == NULL || who == NULL) 3199 if (gc == NULL || who == NULL)
3201 return; 3200 return;
3202 3201
3203 user = gc->proto_data; 3202 user = purple_connection_get_protocol_data(gc);
3204 if (user == NULL) 3203 if (user == NULL)
3205 return; 3204 return;
3206 3205
3207 if (nm_user_is_privacy_locked(user)) { 3206 if (nm_user_is_privacy_locked(user)) {
3208 _show_privacy_locked_error(gc, user); 3207 _show_privacy_locked_error(gc, user);
3233 NMFolder *folder = NULL; 3232 NMFolder *folder = NULL;
3234 3233
3235 if (gc == NULL) 3234 if (gc == NULL)
3236 return; 3235 return;
3237 3236
3238 user = gc->proto_data; 3237 user = purple_connection_get_protocol_data(gc);
3239 if (user == NULL) 3238 if (user == NULL)
3240 return; 3239 return;
3241 3240
3242 if (user->privacy_synched == FALSE) { 3241 if (user->privacy_synched == FALSE) {
3243 _sync_privacy_lists(user); 3242 _sync_privacy_lists(user);
3249 _show_privacy_locked_error(gc, user); 3248 _show_privacy_locked_error(gc, user);
3250 _sync_privacy_lists(user); 3249 _sync_privacy_lists(user);
3251 return; 3250 return;
3252 } 3251 }
3253 3252
3254 switch (gc->account->perm_deny) { 3253 switch (purple_account_get_privacy_type(purple_connection_get_account(gc))) {
3255 3254
3256 case PURPLE_PRIVACY_ALLOW_ALL: 3255 case PURPLE_PRIVACY_ALLOW_ALL:
3257 rc = nm_send_set_privacy_default(user, FALSE, 3256 rc = nm_send_set_privacy_default(user, FALSE,
3258 _set_privacy_default_resp_cb, NULL); 3257 _set_privacy_default_resp_cb, NULL);
3259 _check_for_disconnect(user, rc); 3258 _check_for_disconnect(user, rc);
3305 for (node = user->allow_list; node; node = node->next) { 3304 for (node = user->allow_list; node; node = node->next) {
3306 user_record = nm_find_user_record(user, (char *)node->data); 3305 user_record = nm_find_user_record(user, (char *)node->data);
3307 if (user_record) { 3306 if (user_record) {
3308 name = nm_user_record_get_display_id(user_record); 3307 name = nm_user_record_get_display_id(user_record);
3309 3308
3310 if (!g_slist_find_custom(gc->account->permit, 3309 if (!g_slist_find_custom(purple_connection_get_account(gc)->permit,
3311 name, (GCompareFunc)purple_utf8_strcasecmp)) { 3310 name, (GCompareFunc)purple_utf8_strcasecmp)) {
3312 purple_privacy_permit_add(gc->account, name , TRUE); 3311 purple_privacy_permit_add(purple_connection_get_account(gc), name , TRUE);
3313 } 3312 }
3314 } 3313 }
3315 } 3314 }
3316 3315
3317 for (node = gc->account->permit; node; node = node->next) { 3316 for (node = purple_connection_get_account(gc)->permit; node; node = node->next) {
3318 name = NULL; 3317 name = NULL;
3319 dn = nm_lookup_dn(user, (char *)node->data); 3318 dn = nm_lookup_dn(user, (char *)node->data);
3320 if (dn) { 3319 if (dn) {
3321 user_record = nm_find_user_record(user, dn); 3320 user_record = nm_find_user_record(user, dn);
3322 name = nm_user_record_get_display_id(user_record); 3321 name = nm_user_record_get_display_id(user_record);
3326 rc = nm_send_create_privacy_item(user, dn, TRUE, 3325 rc = nm_send_create_privacy_item(user, dn, TRUE,
3327 _create_privacy_item_deny_resp_cb, 3326 _create_privacy_item_deny_resp_cb,
3328 g_strdup(dn)); 3327 g_strdup(dn));
3329 } 3328 }
3330 } else { 3329 } else {
3331 purple_privacy_permit_remove(gc->account, (char *)node->data, TRUE); 3330 purple_privacy_permit_remove(purple_connection_get_account(gc), (char *)node->data, TRUE);
3332 } 3331 }
3333 } 3332 }
3334 } 3333 }
3335 break; 3334 break;
3336 3335
3347 for (node = user->deny_list; node; node = node->next) { 3346 for (node = user->deny_list; node; node = node->next) {
3348 user_record = nm_find_user_record(user, (char *)node->data); 3347 user_record = nm_find_user_record(user, (char *)node->data);
3349 if (user_record) { 3348 if (user_record) {
3350 name = nm_user_record_get_display_id(user_record); 3349 name = nm_user_record_get_display_id(user_record);
3351 3350
3352 if (!g_slist_find_custom(gc->account->deny, 3351 if (!g_slist_find_custom(purple_connection_get_account(gc)->deny,
3353 name, (GCompareFunc)purple_utf8_strcasecmp)) { 3352 name, (GCompareFunc)purple_utf8_strcasecmp)) {
3354 purple_privacy_deny_add(gc->account, name , TRUE); 3353 purple_privacy_deny_add(purple_connection_get_account(gc), name , TRUE);
3355 } 3354 }
3356 } 3355 }
3357 } 3356 }
3358 3357
3359 for (node = gc->account->deny; node; node = node->next) { 3358 for (node = purple_connection_get_account(gc)->deny; node; node = node->next) {
3360 3359
3361 name = NULL; 3360 name = NULL;
3362 dn = nm_lookup_dn(user, (char *)node->data); 3361 dn = nm_lookup_dn(user, (char *)node->data);
3363 if (dn) { 3362 if (dn) {
3364 user_record = nm_find_user_record(user, dn); 3363 user_record = nm_find_user_record(user, dn);
3369 rc = nm_send_create_privacy_item(user, dn, FALSE, 3368 rc = nm_send_create_privacy_item(user, dn, FALSE,
3370 _create_privacy_item_deny_resp_cb, 3369 _create_privacy_item_deny_resp_cb,
3371 g_strdup(name)); 3370 g_strdup(name));
3372 } 3371 }
3373 } else { 3372 } else {
3374 purple_privacy_deny_remove(gc->account, (char *)node->data, TRUE); 3373 purple_privacy_deny_remove(purple_connection_get_account(gc), (char *)node->data, TRUE);
3375 } 3374 }
3376 } 3375 }
3377 3376
3378 } 3377 }
3379 break; 3378 break;
3461 NMERR_T rc = NM_OK; 3460 NMERR_T rc = NM_OK;
3462 3461
3463 if (gc == NULL) 3462 if (gc == NULL)
3464 return; 3463 return;
3465 3464
3466 user = gc->proto_data; 3465 user = purple_connection_get_protocol_data(gc);
3467 if (user == NULL) 3466 if (user == NULL)
3468 return; 3467 return;
3469 3468
3470 rc = nm_send_keepalive(user, NULL, NULL); 3469 rc = nm_send_keepalive(user, NULL, NULL);
3471 _check_for_disconnect(user, rc); 3470 _check_for_disconnect(user, rc);
3472 } 3471 }
3473 3472
3474 static PurplePluginProtocolInfo prpl_info = { 3473 static PurplePluginProtocolInfo prpl_info = {
3474 sizeof(PurplePluginProtocolInfo), /* struct_size */
3475 0, 3475 0,
3476 NULL, /* user_splits */ 3476 NULL, /* user_splits */
3477 NULL, /* protocol_options */ 3477 NULL, /* protocol_options */
3478 NO_BUDDY_ICONS, /* icon_spec */ 3478 NO_BUDDY_ICONS, /* icon_spec */
3479 novell_list_icon, /* list_icon */ 3479 novell_list_icon, /* list_icon */
3510 NULL, /* chat_whisper */ 3510 NULL, /* chat_whisper */
3511 novell_chat_send, /* chat_send */ 3511 novell_chat_send, /* chat_send */
3512 novell_keepalive, /* keepalive */ 3512 novell_keepalive, /* keepalive */
3513 NULL, /* register_user */ 3513 NULL, /* register_user */
3514 NULL, /* get_cb_info */ 3514 NULL, /* get_cb_info */
3515 NULL, /* get_cb_away */
3516 novell_alias_buddy, /* alias_buddy */ 3515 novell_alias_buddy, /* alias_buddy */
3517 novell_group_buddy, /* group_buddy */ 3516 novell_group_buddy, /* group_buddy */
3518 novell_rename_group, /* rename_group */ 3517 novell_rename_group, /* rename_group */
3519 NULL, /* buddy_free */ 3518 NULL, /* buddy_free */
3520 novell_convo_closed, /* convo_closed */ 3519 novell_convo_closed, /* convo_closed */
3535 NULL, /* send_raw */ 3534 NULL, /* send_raw */
3536 NULL, /* roomlist_room_serialize */ 3535 NULL, /* roomlist_room_serialize */
3537 NULL, /* unregister_user */ 3536 NULL, /* unregister_user */
3538 NULL, /* send_attention */ 3537 NULL, /* send_attention */
3539 NULL, /* get_attention_types */ 3538 NULL, /* get_attention_types */
3540 sizeof(PurplePluginProtocolInfo), /* struct_size */
3541 NULL, /* get_account_text_table */ 3539 NULL, /* get_account_text_table */
3542 NULL, /* initiate_media */ 3540 NULL, /* initiate_media */
3543 NULL, /* get_media_caps */ 3541 NULL, /* get_media_caps */
3544 NULL, /* get_moods */ 3542 NULL, /* get_moods */
3545 NULL, /* set_public_alias */ 3543 NULL, /* set_public_alias */
3546 NULL, /* get_public_alias */ 3544 NULL /* get_public_alias */
3547 NULL, /* add_buddy_with_invite */
3548 NULL /* add_buddies_with_invite */
3549 }; 3545 };
3550 3546
3551 static PurplePluginInfo info = { 3547 static PurplePluginInfo info = {
3552 PURPLE_PLUGIN_MAGIC, 3548 PURPLE_PLUGIN_MAGIC,
3553 PURPLE_MAJOR_VERSION, 3549 PURPLE_MAJOR_VERSION,