comparison libpurple/protocols/novell/novell.c @ 32767:2ec94166be43

On the way to hiding the PurpleConnection struct. * Added purple_connection_get_flags() and purple_connection_set_flags() * Use purple_connection_ accessor functions.
author andrew.victor@mxit.com
date Tue, 18 Oct 2011 18:47:48 +0000
parents f75041cb3fec
children
comparison
equal deleted inserted replaced
32766:ea2b621fd3ba 32767:2ec94166be43
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,
1402 return; 1402 return;
1403 1403
1404 /* Set the Purple privacy setting */ 1404 /* Set the Purple privacy setting */
1405 if (user->default_deny) { 1405 if (user->default_deny) {
1406 if (user->allow_list == NULL) { 1406 if (user->allow_list == NULL) {
1407 purple_account_set_privacy_type(gc->account, PURPLE_PRIVACY_DENY_ALL); 1407 purple_account_set_privacy_type(purple_connection_get_account(gc), PURPLE_PRIVACY_DENY_ALL);
1408 } else { 1408 } else {
1409 purple_account_set_privacy_type(gc->account, PURPLE_PRIVACY_ALLOW_USERS); 1409 purple_account_set_privacy_type(purple_connection_get_account(gc), PURPLE_PRIVACY_ALLOW_USERS);
1410 } 1410 }
1411 } else { 1411 } else {
1412 if (user->deny_list == NULL) { 1412 if (user->deny_list == NULL) {
1413 purple_account_set_privacy_type(gc->account, PURPLE_PRIVACY_ALLOW_ALL); 1413 purple_account_set_privacy_type(purple_connection_get_account(gc), PURPLE_PRIVACY_ALLOW_ALL);
1414 } else { 1414 } else {
1415 purple_account_set_privacy_type(gc->account, PURPLE_PRIVACY_DENY_USERS); 1415 purple_account_set_privacy_type(purple_connection_get_account(gc), PURPLE_PRIVACY_DENY_USERS);
1416 } 1416 }
1417 } 1417 }
1418 1418
1419 /* Add stuff */ 1419 /* Add stuff */
1420 for (node = user->allow_list; node; node = node->next) { 1420 for (node = user->allow_list; node; node = node->next) {
1422 if (user_record) 1422 if (user_record)
1423 name = nm_user_record_get_display_id(user_record); 1423 name = nm_user_record_get_display_id(user_record);
1424 else 1424 else
1425 name =(char *)node->data; 1425 name =(char *)node->data;
1426 1426
1427 if (!g_slist_find_custom(gc->account->permit, 1427 if (!g_slist_find_custom(purple_connection_get_account(gc)->permit,
1428 name, (GCompareFunc)purple_utf8_strcasecmp)) { 1428 name, (GCompareFunc)purple_utf8_strcasecmp)) {
1429 purple_privacy_permit_add(gc->account, name , TRUE); 1429 purple_privacy_permit_add(purple_connection_get_account(gc), name , TRUE);
1430 } 1430 }
1431 } 1431 }
1432 1432
1433 for (node = user->deny_list; node; node = node->next) { 1433 for (node = user->deny_list; node; node = node->next) {
1434 user_record = nm_find_user_record(user, (char *)node->data); 1434 user_record = nm_find_user_record(user, (char *)node->data);
1435 if (user_record) 1435 if (user_record)
1436 name = nm_user_record_get_display_id(user_record); 1436 name = nm_user_record_get_display_id(user_record);
1437 else 1437 else
1438 name =(char *)node->data; 1438 name =(char *)node->data;
1439 1439
1440 if (!g_slist_find_custom(gc->account->deny, 1440 if (!g_slist_find_custom(purple_connection_get_account(gc)->deny,
1441 name, (GCompareFunc)purple_utf8_strcasecmp)) { 1441 name, (GCompareFunc)purple_utf8_strcasecmp)) {
1442 purple_privacy_deny_add(gc->account, name, TRUE); 1442 purple_privacy_deny_add(purple_connection_get_account(gc), name, TRUE);
1443 } 1443 }
1444 } 1444 }
1445 1445
1446 1446
1447 /* Remove stuff */ 1447 /* Remove stuff */
1448 for (node = gc->account->permit; node; node = node->next) { 1448 for (node = purple_connection_get_account(gc)->permit; node; node = node->next) {
1449 dn = nm_lookup_dn(user, (char *)node->data); 1449 dn = nm_lookup_dn(user, (char *)node->data);
1450 if (dn != NULL && 1450 if (dn != NULL &&
1451 !g_slist_find_custom(user->allow_list, 1451 !g_slist_find_custom(user->allow_list,
1452 dn, (GCompareFunc)purple_utf8_strcasecmp)) { 1452 dn, (GCompareFunc)purple_utf8_strcasecmp)) {
1453 rem_list = g_slist_append(rem_list, node->data); 1453 rem_list = g_slist_append(rem_list, node->data);
1454 } 1454 }
1455 } 1455 }
1456 1456
1457 if (rem_list) { 1457 if (rem_list) {
1458 for (node = rem_list; node; node = node->next) { 1458 for (node = rem_list; node; node = node->next) {
1459 purple_privacy_permit_remove(gc->account, (char *)node->data, TRUE); 1459 purple_privacy_permit_remove(purple_connection_get_account(gc), (char *)node->data, TRUE);
1460 } 1460 }
1461 g_slist_free(rem_list); 1461 g_slist_free(rem_list);
1462 rem_list = NULL; 1462 rem_list = NULL;
1463 } 1463 }
1464 1464
1465 for (node = gc->account->deny; node; node = node->next) { 1465 for (node = purple_connection_get_account(gc)->deny; node; node = node->next) {
1466 dn = nm_lookup_dn(user, (char *)node->data); 1466 dn = nm_lookup_dn(user, (char *)node->data);
1467 if (dn != NULL && 1467 if (dn != NULL &&
1468 !g_slist_find_custom(user->deny_list, 1468 !g_slist_find_custom(user->deny_list,
1469 dn, (GCompareFunc)purple_utf8_strcasecmp)) { 1469 dn, (GCompareFunc)purple_utf8_strcasecmp)) {
1470 rem_list = g_slist_append(rem_list, node->data); 1470 rem_list = g_slist_append(rem_list, node->data);
1471 } 1471 }
1472 } 1472 }
1473 1473
1474 if (rem_list) { 1474 if (rem_list) {
1475 for (node = rem_list; node; node = node->next) { 1475 for (node = rem_list; node; node = node->next) {
1476 purple_privacy_deny_remove(gc->account, (char *)node->data, TRUE); 1476 purple_privacy_deny_remove(purple_connection_get_account(gc), (char *)node->data, TRUE);
1477 } 1477 }
1478 g_slist_free(rem_list); 1478 g_slist_free(rem_list);
1479 } 1479 }
1480 } 1480 }
1481 1481
3089 return; 3089 return;
3090 3090
3091 /* Remove first -- we will add it back in when we get 3091 /* Remove first -- we will add it back in when we get
3092 * the okay from the server 3092 * the okay from the server
3093 */ 3093 */
3094 purple_privacy_permit_remove(gc->account, who, TRUE); 3094 purple_privacy_permit_remove(purple_connection_get_account(gc), who, TRUE);
3095 3095
3096 if (nm_user_is_privacy_locked(user)) { 3096 if (nm_user_is_privacy_locked(user)) {
3097 _show_privacy_locked_error(gc, user); 3097 _show_privacy_locked_error(gc, user);
3098 _sync_privacy_lists(user); 3098 _sync_privacy_lists(user);
3099 return; 3099 return;
3133 return; 3133 return;
3134 3134
3135 /* Remove first -- we will add it back in when we get 3135 /* Remove first -- we will add it back in when we get
3136 * the okay from the server 3136 * the okay from the server
3137 */ 3137 */
3138 purple_privacy_deny_remove(gc->account, who, TRUE); 3138 purple_privacy_deny_remove(purple_connection_get_account(gc), who, TRUE);
3139 3139
3140 if (nm_user_is_privacy_locked(user)) { 3140 if (nm_user_is_privacy_locked(user)) {
3141 _show_privacy_locked_error(gc, user); 3141 _show_privacy_locked_error(gc, user);
3142 _sync_privacy_lists(user); 3142 _sync_privacy_lists(user);
3143 return; 3143 return;
3251 _show_privacy_locked_error(gc, user); 3251 _show_privacy_locked_error(gc, user);
3252 _sync_privacy_lists(user); 3252 _sync_privacy_lists(user);
3253 return; 3253 return;
3254 } 3254 }
3255 3255
3256 switch (purple_account_get_privacy_type(gc->account)) { 3256 switch (purple_account_get_privacy_type(purple_connection_get_account(gc))) {
3257 3257
3258 case PURPLE_PRIVACY_ALLOW_ALL: 3258 case PURPLE_PRIVACY_ALLOW_ALL:
3259 rc = nm_send_set_privacy_default(user, FALSE, 3259 rc = nm_send_set_privacy_default(user, FALSE,
3260 _set_privacy_default_resp_cb, NULL); 3260 _set_privacy_default_resp_cb, NULL);
3261 _check_for_disconnect(user, rc); 3261 _check_for_disconnect(user, rc);
3307 for (node = user->allow_list; node; node = node->next) { 3307 for (node = user->allow_list; node; node = node->next) {
3308 user_record = nm_find_user_record(user, (char *)node->data); 3308 user_record = nm_find_user_record(user, (char *)node->data);
3309 if (user_record) { 3309 if (user_record) {
3310 name = nm_user_record_get_display_id(user_record); 3310 name = nm_user_record_get_display_id(user_record);
3311 3311
3312 if (!g_slist_find_custom(gc->account->permit, 3312 if (!g_slist_find_custom(purple_connection_get_account(gc)->permit,
3313 name, (GCompareFunc)purple_utf8_strcasecmp)) { 3313 name, (GCompareFunc)purple_utf8_strcasecmp)) {
3314 purple_privacy_permit_add(gc->account, name , TRUE); 3314 purple_privacy_permit_add(purple_connection_get_account(gc), name , TRUE);
3315 } 3315 }
3316 } 3316 }
3317 } 3317 }
3318 3318
3319 for (node = gc->account->permit; node; node = node->next) { 3319 for (node = purple_connection_get_account(gc)->permit; node; node = node->next) {
3320 name = NULL; 3320 name = NULL;
3321 dn = nm_lookup_dn(user, (char *)node->data); 3321 dn = nm_lookup_dn(user, (char *)node->data);
3322 if (dn) { 3322 if (dn) {
3323 user_record = nm_find_user_record(user, dn); 3323 user_record = nm_find_user_record(user, dn);
3324 name = nm_user_record_get_display_id(user_record); 3324 name = nm_user_record_get_display_id(user_record);
3328 rc = nm_send_create_privacy_item(user, dn, TRUE, 3328 rc = nm_send_create_privacy_item(user, dn, TRUE,
3329 _create_privacy_item_deny_resp_cb, 3329 _create_privacy_item_deny_resp_cb,
3330 g_strdup(dn)); 3330 g_strdup(dn));
3331 } 3331 }
3332 } else { 3332 } else {
3333 purple_privacy_permit_remove(gc->account, (char *)node->data, TRUE); 3333 purple_privacy_permit_remove(purple_connection_get_account(gc), (char *)node->data, TRUE);
3334 } 3334 }
3335 } 3335 }
3336 } 3336 }
3337 break; 3337 break;
3338 3338
3349 for (node = user->deny_list; node; node = node->next) { 3349 for (node = user->deny_list; node; node = node->next) {
3350 user_record = nm_find_user_record(user, (char *)node->data); 3350 user_record = nm_find_user_record(user, (char *)node->data);
3351 if (user_record) { 3351 if (user_record) {
3352 name = nm_user_record_get_display_id(user_record); 3352 name = nm_user_record_get_display_id(user_record);
3353 3353
3354 if (!g_slist_find_custom(gc->account->deny, 3354 if (!g_slist_find_custom(purple_connection_get_account(gc)->deny,
3355 name, (GCompareFunc)purple_utf8_strcasecmp)) { 3355 name, (GCompareFunc)purple_utf8_strcasecmp)) {
3356 purple_privacy_deny_add(gc->account, name , TRUE); 3356 purple_privacy_deny_add(purple_connection_get_account(gc), name , TRUE);
3357 } 3357 }
3358 } 3358 }
3359 } 3359 }
3360 3360
3361 for (node = gc->account->deny; node; node = node->next) { 3361 for (node = purple_connection_get_account(gc)->deny; node; node = node->next) {
3362 3362
3363 name = NULL; 3363 name = NULL;
3364 dn = nm_lookup_dn(user, (char *)node->data); 3364 dn = nm_lookup_dn(user, (char *)node->data);
3365 if (dn) { 3365 if (dn) {
3366 user_record = nm_find_user_record(user, dn); 3366 user_record = nm_find_user_record(user, dn);
3371 rc = nm_send_create_privacy_item(user, dn, FALSE, 3371 rc = nm_send_create_privacy_item(user, dn, FALSE,
3372 _create_privacy_item_deny_resp_cb, 3372 _create_privacy_item_deny_resp_cb,
3373 g_strdup(name)); 3373 g_strdup(name));
3374 } 3374 }
3375 } else { 3375 } else {
3376 purple_privacy_deny_remove(gc->account, (char *)node->data, TRUE); 3376 purple_privacy_deny_remove(purple_connection_get_account(gc), (char *)node->data, TRUE);
3377 } 3377 }
3378 } 3378 }
3379 3379
3380 } 3380 }
3381 break; 3381 break;