comparison libpurple/protocols/novell/novell.c @ 31986:a13f4cad3cdd

Convert novell prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
author andrew.victor@mxit.com
date Mon, 29 Aug 2011 22:43:18 +0000
parents 99ca503ea087
children cd1d9e04c587
comparison
equal deleted inserted replaced
31985:dfe284205c32 31986:a13f4cad3cdd
1627 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node)); 1627 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
1628 1628
1629 buddy = (PurpleBuddy *) node; 1629 buddy = (PurpleBuddy *) node;
1630 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); 1630 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
1631 1631
1632 user = gc->proto_data; 1632 user = purple_connection_get_protocol_data(gc);
1633 if (user == NULL) 1633 if (user == NULL)
1634 return; 1634 return;
1635 1635
1636 /* We should already have a userrecord for the buddy */ 1636 /* We should already have a userrecord for the buddy */
1637 user_record = nm_find_user_record(user, purple_buddy_get_name(buddy)); 1637 user_record = nm_find_user_record(user, purple_buddy_get_name(buddy));
1683 { 1683 {
1684 PurpleConnection *gc; 1684 PurpleConnection *gc;
1685 NMUser *user; 1685 NMUser *user;
1686 1686
1687 gc = data; 1687 gc = data;
1688 user = gc->proto_data; 1688 user = purple_connection_get_protocol_data(gc);
1689 user->conn->ssl_conn->data = NULL; 1689 user->conn->ssl_conn->data = NULL;
1690 1690
1691 purple_connection_ssl_error (gc, error); 1691 purple_connection_ssl_error (gc, error);
1692 } 1692 }
1693 1693
1700 NMERR_T rc; 1700 NMERR_T rc;
1701 1701
1702 if (gc == NULL) 1702 if (gc == NULL)
1703 return; 1703 return;
1704 1704
1705 user = gc->proto_data; 1705 user = purple_connection_get_protocol_data(gc);
1706 if (user == NULL) 1706 if (user == NULL)
1707 return; 1707 return;
1708 1708
1709 rc = nm_process_new_data(user); 1709 rc = nm_process_new_data(user);
1710 if (rc != NM_OK) { 1710 if (rc != NM_OK) {
1734 char *ua = NULL; 1734 char *ua = NULL;
1735 1735
1736 if (gc == NULL || gsc == NULL) 1736 if (gc == NULL || gsc == NULL)
1737 return; 1737 return;
1738 1738
1739 user = gc->proto_data; 1739 user = purple_connection_get_protocol_data(gc);
1740 if ((user == NULL) || (conn = user->conn) == NULL) 1740 if ((user == NULL) || (conn = user->conn) == NULL)
1741 return; 1741 return;
1742 1742
1743 purple_connection_update_progress(gc, _("Authenticating..."), 1743 purple_connection_update_progress(gc, _("Authenticating..."),
1744 2, NOVELL_CONNECT_STEPS); 1744 2, NOVELL_CONNECT_STEPS);
2204 name = purple_account_get_username(account); 2204 name = purple_account_get_username(account);
2205 2205
2206 user = nm_initialize_user(name, server, port, account, _event_callback); 2206 user = nm_initialize_user(name, server, port, account, _event_callback);
2207 if (user && user->conn) { 2207 if (user && user->conn) {
2208 /* save user */ 2208 /* save user */
2209 gc->proto_data = user; 2209 purple_connection_set_protocol_data(gc, user);
2210 2210
2211 /* connect to the server */ 2211 /* connect to the server */
2212 purple_connection_update_progress(gc, _("Connecting"), 2212 purple_connection_update_progress(gc, _("Connecting"),
2213 1, NOVELL_CONNECT_STEPS); 2213 1, NOVELL_CONNECT_STEPS);
2214 2214
2236 NMConn *conn; 2236 NMConn *conn;
2237 2237
2238 if (gc == NULL) 2238 if (gc == NULL)
2239 return; 2239 return;
2240 2240
2241 user = gc->proto_data; 2241 user = purple_connection_get_protocol_data(gc);
2242 if (user) { 2242 if (user) {
2243 conn = user->conn; 2243 conn = user->conn;
2244 if (conn && conn->ssl_conn) { 2244 if (conn && conn->ssl_conn) {
2245 purple_ssl_close(user->conn->ssl_conn->data); 2245 purple_ssl_close(user->conn->ssl_conn->data);
2246 } 2246 }
2247 nm_deinitialize_user(user); 2247 nm_deinitialize_user(user);
2248 } 2248 }
2249 gc->proto_data = NULL; 2249 purple_connection_set_protocol_data(gc, NULL);
2250 } 2250 }
2251 2251
2252 static int 2252 static int
2253 novell_send_im(PurpleConnection * gc, const char *name, 2253 novell_send_im(PurpleConnection * gc, const char *name,
2254 const char *message_body, PurpleMessageFlags flags) 2254 const char *message_body, PurpleMessageFlags flags)
2264 2264
2265 if (gc == NULL || name == NULL || 2265 if (gc == NULL || name == NULL ||
2266 message_body == NULL || *message_body == '\0') 2266 message_body == NULL || *message_body == '\0')
2267 return 0; 2267 return 0;
2268 2268
2269 user = gc->proto_data; 2269 user = purple_connection_get_protocol_data(gc);
2270 if (user == NULL) 2270 if (user == NULL)
2271 return 0; 2271 return 0;
2272 2272
2273 /* Create a new message */ 2273 /* Create a new message */
2274 plain = purple_unescape_html(message_body); 2274 plain = purple_unescape_html(message_body);
2350 NMERR_T rc = NM_OK; 2350 NMERR_T rc = NM_OK;
2351 2351
2352 if (gc == NULL || name == NULL) 2352 if (gc == NULL || name == NULL)
2353 return 0; 2353 return 0;
2354 2354
2355 user = gc->proto_data; 2355 user = purple_connection_get_protocol_data(gc);
2356 if (user == NULL) 2356 if (user == NULL)
2357 return 0; 2357 return 0;
2358 2358
2359 /* Need to get the DN for the buddy so we can look up the convo */ 2359 /* Need to get the DN for the buddy so we can look up the convo */
2360 dn = nm_lookup_dn(user, name); 2360 dn = nm_lookup_dn(user, name);
2384 NMERR_T rc = NM_OK; 2384 NMERR_T rc = NM_OK;
2385 2385
2386 if (gc == NULL || who == NULL) 2386 if (gc == NULL || who == NULL)
2387 return; 2387 return;
2388 2388
2389 user = gc->proto_data; 2389 user = purple_connection_get_protocol_data(gc);
2390 if (user && (dn = nm_lookup_dn(user, who))) { 2390 if (user && (dn = nm_lookup_dn(user, who))) {
2391 conf = nm_find_conversation(user, dn); 2391 conf = nm_find_conversation(user, dn);
2392 if (conf) { 2392 if (conf) {
2393 rc = nm_send_leave_conference(user, conf, NULL, NULL); 2393 rc = nm_send_leave_conference(user, conf, NULL, NULL);
2394 _check_for_disconnect(user, rc); 2394 _check_for_disconnect(user, rc);
2406 NMERR_T rc = NM_OK; 2406 NMERR_T rc = NM_OK;
2407 2407
2408 if (gc == NULL) 2408 if (gc == NULL)
2409 return; 2409 return;
2410 2410
2411 user = gc->proto_data; 2411 user = purple_connection_get_protocol_data(gc);
2412 if (user == NULL) 2412 if (user == NULL)
2413 return; 2413 return;
2414 2414
2415 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) { 2415 for (cnode = user->conferences; cnode != NULL; cnode = cnode->next) {
2416 conference = cnode->data; 2416 conference = cnode->data;
2438 NMUserRecord *user_record = NULL; 2438 NMUserRecord *user_record = NULL;
2439 2439
2440 if (gc == NULL) 2440 if (gc == NULL)
2441 return; 2441 return;
2442 2442
2443 user = gc->proto_data; 2443 user = purple_connection_get_protocol_data(gc);
2444 if (user == NULL) 2444 if (user == NULL)
2445 return; 2445 return;
2446 2446
2447 user_record = nm_find_user_record(user, who); 2447 user_record = nm_find_user_record(user, who);
2448 if (user_record == NULL) { 2448 if (user_record == NULL) {
2477 char *str, *plain; 2477 char *str, *plain;
2478 2478
2479 if (gc == NULL || text == NULL) 2479 if (gc == NULL || text == NULL)
2480 return -1; 2480 return -1;
2481 2481
2482 user = gc->proto_data; 2482 user = purple_connection_get_protocol_data(gc);
2483 if (user == NULL) 2483 if (user == NULL)
2484 return -1; 2484 return -1;
2485 2485
2486 plain = purple_unescape_html(text); 2486 plain = purple_unescape_html(text);
2487 message = nm_create_message(plain); 2487 message = nm_create_message(plain);
2617 NMERR_T rc = NM_OK; 2617 NMERR_T rc = NM_OK;
2618 2618
2619 if (gc == NULL || buddy == NULL || group == NULL) 2619 if (gc == NULL || buddy == NULL || group == NULL)
2620 return; 2620 return;
2621 2621
2622 user = (NMUser *) gc->proto_data; 2622 user = purple_connection_get_protocol_data(gc);
2623 if (user && (dn = nm_lookup_dn(user, purple_buddy_get_name(buddy)))) { 2623 if (user && (dn = nm_lookup_dn(user, purple_buddy_get_name(buddy)))) {
2624 gname = purple_group_get_name(group); 2624 gname = purple_group_get_name(group);
2625 if (strcmp(gname, NM_ROOT_FOLDER_NAME) == 0) { 2625 if (strcmp(gname, NM_ROOT_FOLDER_NAME) == 0) {
2626 gname = ""; 2626 gname = "";
2627 } 2627 }
2649 NMERR_T rc = NM_OK; 2649 NMERR_T rc = NM_OK;
2650 2650
2651 if (gc == NULL || group == NULL) 2651 if (gc == NULL || group == NULL)
2652 return; 2652 return;
2653 2653
2654 user = (NMUser *) gc->proto_data; 2654 user = purple_connection_get_protocol_data(gc);
2655 if (user) { 2655 if (user) {
2656 NMFolder *folder = nm_find_folder(user, purple_group_get_name(group)); 2656 NMFolder *folder = nm_find_folder(user, purple_group_get_name(group));
2657 2657
2658 if (folder) { 2658 if (folder) {
2659 rc = nm_send_remove_folder(user, folder, 2659 rc = nm_send_remove_folder(user, folder,
2674 NMERR_T rc = NM_OK; 2674 NMERR_T rc = NM_OK;
2675 2675
2676 if (gc == NULL || name == NULL || alias == NULL) 2676 if (gc == NULL || name == NULL || alias == NULL)
2677 return; 2677 return;
2678 2678
2679 user = (NMUser *) gc->proto_data; 2679 user = purple_connection_get_protocol_data(gc);
2680 if (user && (dn = nm_lookup_dn(user, name))) { 2680 if (user && (dn = nm_lookup_dn(user, name))) {
2681 2681
2682 /* Alias all of instances of the contact */ 2682 /* Alias all of instances of the contact */
2683 contacts = nm_find_contacts(user, dn); 2683 contacts = nm_find_contacts(user, dn);
2684 for (cnode = contacts; cnode != NULL; cnode = cnode->next) { 2684 for (cnode = contacts; cnode != NULL; cnode = cnode->next) {
2733 2733
2734 if (gc == NULL || name == NULL || 2734 if (gc == NULL || name == NULL ||
2735 old_group_name == NULL || new_group_name == NULL) 2735 old_group_name == NULL || new_group_name == NULL)
2736 return; 2736 return;
2737 2737
2738 user = (NMUser *) gc->proto_data; 2738 user = purple_connection_get_protocol_data(gc);
2739 if (user && (dn = nm_lookup_dn(user, name))) { 2739 if (user && (dn = nm_lookup_dn(user, name))) {
2740 2740
2741 /* Find the old folder */ 2741 /* Find the old folder */
2742 if (strcmp(old_group_name, NM_ROOT_FOLDER_NAME) == 0) { 2742 if (strcmp(old_group_name, NM_ROOT_FOLDER_NAME) == 0) {
2743 old_folder = nm_get_root_folder(user); 2743 old_folder = nm_get_root_folder(user);
2791 2791
2792 if (gc == NULL || old_name == NULL || group == NULL || moved_buddies == NULL) { 2792 if (gc == NULL || old_name == NULL || group == NULL || moved_buddies == NULL) {
2793 return; 2793 return;
2794 } 2794 }
2795 2795
2796 user = gc->proto_data; 2796 user = purple_connection_get_protocol_data(gc);
2797 if (user) { 2797 if (user) {
2798 const char *gname = purple_group_get_name(group); 2798 const char *gname = purple_group_get_name(group);
2799 /* Does new folder exist already? */ 2799 /* Does new folder exist already? */
2800 if (nm_find_folder(user, gname)) { 2800 if (nm_find_folder(user, gname)) {
2801 /* purple_blist_rename_group() adds the buddies 2801 /* purple_blist_rename_group() adds the buddies
2837 2837
2838 if (buddy == NULL) 2838 if (buddy == NULL)
2839 return; 2839 return;
2840 2840
2841 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); 2841 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
2842 if (gc == NULL || (user = gc->proto_data) == NULL) 2842 if (gc == NULL || (user = purple_connection_get_protocol_data(gc)) == NULL)
2843 return; 2843 return;
2844 2844
2845 if (PURPLE_BUDDY_IS_ONLINE(buddy)) { 2845 if (PURPLE_BUDDY_IS_ONLINE(buddy)) {
2846 user_record = nm_find_user_record(user, purple_buddy_get_name(buddy)); 2846 user_record = nm_find_user_record(user, purple_buddy_get_name(buddy));
2847 if (user_record) { 2847 if (user_record) {
2889 PurpleStatus *status = NULL; 2889 PurpleStatus *status = NULL;
2890 2890
2891 if (gc == NULL) 2891 if (gc == NULL)
2892 return; 2892 return;
2893 2893
2894 user = gc->proto_data; 2894 user = purple_connection_get_protocol_data(gc);
2895 if (user == NULL) 2895 if (user == NULL)
2896 return; 2896 return;
2897 2897
2898 status = purple_account_get_active_status(purple_connection_get_account(gc)); 2898 status = purple_account_get_active_status(purple_connection_get_account(gc));
2899 id = purple_status_get_id(status); 2899 id = purple_status_get_id(status);
2918 NMERR_T rc; 2918 NMERR_T rc;
2919 2919
2920 if (gc == NULL || name == NULL) 2920 if (gc == NULL || name == NULL)
2921 return; 2921 return;
2922 2922
2923 user = (NMUser *) gc->proto_data; 2923 user = purple_connection_get_protocol_data(gc);
2924 if (user) { 2924 if (user) {
2925 2925
2926 user_record = nm_find_user_record(user, name); 2926 user_record = nm_find_user_record(user, name);
2927 if (user_record) { 2927 if (user_record) {
2928 _show_info(gc, user_record, g_strdup(name)); 2928 _show_info(gc, user_record, g_strdup(name));
2947 2947
2948 account = buddy ? purple_buddy_get_account(buddy) : NULL; 2948 account = buddy ? purple_buddy_get_account(buddy) : NULL;
2949 if (buddy && account) { 2949 if (buddy && account) {
2950 PurpleConnection *gc = purple_account_get_connection(account); 2950 PurpleConnection *gc = purple_account_get_connection(account);
2951 2951
2952 if (gc && gc->proto_data) { 2952 if (gc) {
2953 NMUser *user = gc->proto_data; 2953 NMUser *user = purple_connection_get_protocol_data(gc);
2954 2954
2955 dn = nm_lookup_dn(user, purple_buddy_get_name(buddy)); 2955 if (user) {
2956 if (dn) { 2956 dn = nm_lookup_dn(user, purple_buddy_get_name(buddy));
2957 NMUserRecord *user_record = nm_find_user_record(user, dn); 2957 if (dn) {
2958 2958 NMUserRecord *user_record = nm_find_user_record(user, dn);
2959 if (user_record) { 2959
2960 text = nm_user_record_get_status_text(user_record); 2960 if (user_record) {
2961 if (text) 2961 text = nm_user_record_get_status_text(user_record);
2962 return g_strdup(text); 2962 if (text)
2963 return g_strdup(text);
2964 }
2963 } 2965 }
2964 } 2966 }
2965 } 2967 }
2966 } 2968 }
2967 2969
3033 3035
3034 if (!connected) 3036 if (!connected)
3035 return; 3037 return;
3036 3038
3037 gc = purple_account_get_connection(account); 3039 gc = purple_account_get_connection(account);
3038 user = gc->proto_data; 3040 user = purple_connection_get_protocol_data(gc);
3039 if (user == NULL) 3041 if (user == NULL)
3040 return; 3042 return;
3041 3043
3042 if (primitive == PURPLE_STATUS_AVAILABLE) { 3044 if (primitive == PURPLE_STATUS_AVAILABLE) {
3043 novellstatus = NM_STATUS_AVAILABLE; 3045 novellstatus = NM_STATUS_AVAILABLE;
3080 const char *name = who; 3082 const char *name = who;
3081 3083
3082 if (gc == NULL || who == NULL) 3084 if (gc == NULL || who == NULL)
3083 return; 3085 return;
3084 3086
3085 user = gc->proto_data; 3087 user = purple_connection_get_protocol_data(gc);
3086 if (user == NULL) 3088 if (user == NULL)
3087 return; 3089 return;
3088 3090
3089 /* Remove first -- we will add it back in when we get 3091 /* Remove first -- we will add it back in when we get
3090 * the okay from the server 3092 * the okay from the server
3124 const char *name = who; 3126 const char *name = who;
3125 3127
3126 if (gc == NULL || who == NULL) 3128 if (gc == NULL || who == NULL)
3127 return; 3129 return;
3128 3130
3129 user = gc->proto_data; 3131 user = purple_connection_get_protocol_data(gc);
3130 if (user == NULL) 3132 if (user == NULL)
3131 return; 3133 return;
3132 3134
3133 /* Remove first -- we will add it back in when we get 3135 /* Remove first -- we will add it back in when we get
3134 * the okay from the server 3136 * the okay from the server
3168 const char *dn = NULL; 3170 const char *dn = NULL;
3169 3171
3170 if (gc == NULL || who == NULL) 3172 if (gc == NULL || who == NULL)
3171 return; 3173 return;
3172 3174
3173 user = gc->proto_data; 3175 user = purple_connection_get_protocol_data(gc);
3174 if (user == NULL) 3176 if (user == NULL)
3175 return; 3177 return;
3176 3178
3177 if (nm_user_is_privacy_locked(user)) { 3179 if (nm_user_is_privacy_locked(user)) {
3178 _show_privacy_locked_error(gc, user); 3180 _show_privacy_locked_error(gc, user);
3198 const char *dn = NULL; 3200 const char *dn = NULL;
3199 3201
3200 if (gc == NULL || who == NULL) 3202 if (gc == NULL || who == NULL)
3201 return; 3203 return;
3202 3204
3203 user = gc->proto_data; 3205 user = purple_connection_get_protocol_data(gc);
3204 if (user == NULL) 3206 if (user == NULL)
3205 return; 3207 return;
3206 3208
3207 if (nm_user_is_privacy_locked(user)) { 3209 if (nm_user_is_privacy_locked(user)) {
3208 _show_privacy_locked_error(gc, user); 3210 _show_privacy_locked_error(gc, user);
3233 NMFolder *folder = NULL; 3235 NMFolder *folder = NULL;
3234 3236
3235 if (gc == NULL) 3237 if (gc == NULL)
3236 return; 3238 return;
3237 3239
3238 user = gc->proto_data; 3240 user = purple_connection_get_protocol_data(gc);
3239 if (user == NULL) 3241 if (user == NULL)
3240 return; 3242 return;
3241 3243
3242 if (user->privacy_synched == FALSE) { 3244 if (user->privacy_synched == FALSE) {
3243 _sync_privacy_lists(user); 3245 _sync_privacy_lists(user);
3461 NMERR_T rc = NM_OK; 3463 NMERR_T rc = NM_OK;
3462 3464
3463 if (gc == NULL) 3465 if (gc == NULL)
3464 return; 3466 return;
3465 3467
3466 user = gc->proto_data; 3468 user = purple_connection_get_protocol_data(gc);
3467 if (user == NULL) 3469 if (user == NULL)
3468 return; 3470 return;
3469 3471
3470 rc = nm_send_keepalive(user, NULL, NULL); 3472 rc = nm_send_keepalive(user, NULL, NULL);
3471 _check_for_disconnect(user, rc); 3473 _check_for_disconnect(user, rc);