comparison libpurple/account.c @ 20152:0cb113dfb096

Disable the account when the user cancels entering the password so the account isn't stuck in a weird unconnected state. Fixes #1791
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 18 Sep 2007 03:11:19 +0000
parents 6bf32c9e15a7
children 8e3ef71c4362 591267f6f1d5 2002a6a32b0c f387e8c671a4
comparison
equal deleted inserted replaced
20151:48374dc14adc 20152:0cb113dfb096
915 915
916 void 916 void
917 purple_account_set_register_callback(PurpleAccount *account, PurpleAccountRegistrationCb cb, void *user_data) 917 purple_account_set_register_callback(PurpleAccount *account, PurpleAccountRegistrationCb cb, void *user_data)
918 { 918 {
919 g_return_if_fail(account != NULL); 919 g_return_if_fail(account != NULL);
920 920
921 account->registration_cb = cb; 921 account->registration_cb = cb;
922 account->registration_cb_user_data = user_data; 922 account->registration_cb_user_data = user_data;
923 } 923 }
924 924
925 void 925 void
935 935
936 void 936 void
937 purple_account_unregister(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data) 937 purple_account_unregister(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data)
938 { 938 {
939 g_return_if_fail(account != NULL); 939 g_return_if_fail(account != NULL);
940 940
941 purple_debug_info("account", "Unregistering account %s\n", 941 purple_debug_info("account", "Unregistering account %s\n",
942 purple_account_get_username(account)); 942 purple_account_get_username(account));
943 943
944 purple_connection_new_unregister(account, purple_account_get_password(account), cb, user_data); 944 purple_connection_new_unregister(account, purple_account_get_password(account), cb, user_data);
945 } 945 }
946 946
947 static void 947 static void
948 request_password_ok_cb(PurpleAccount *account, PurpleRequestFields *fields) 948 request_password_ok_cb(PurpleAccount *account, PurpleRequestFields *fields)
958 purple_notify_error(account, NULL, _("Password is required to sign on."), NULL); 958 purple_notify_error(account, NULL, _("Password is required to sign on."), NULL);
959 return; 959 return;
960 } 960 }
961 961
962 if(remember) 962 if(remember)
963 purple_account_set_remember_password(account, TRUE); 963 purple_account_set_remember_password(account, TRUE);
964 964
965 purple_account_set_password(account, entry); 965 purple_account_set_password(account, entry);
966 966
967 purple_connection_new(account, FALSE, entry); 967 purple_connection_new(account, FALSE, entry);
968 } 968 }
969
970 static void
971 request_password_cancel_cb(PurpleAccount *account, PurpleRequestFields *fields)
972 {
973 /* Disable the account as the user has canceled connecting */
974 purple_account_set_enabled(account, purple_core_get_ui(), FALSE);
975 }
976
969 977
970 void 978 void
971 purple_account_request_password(PurpleAccount *account, GCallback ok_cb, 979 purple_account_request_password(PurpleAccount *account, GCallback ok_cb,
972 GCallback cancel_cb, void *user_data) 980 GCallback cancel_cb, void *user_data)
973 { 981 {
1038 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl); 1046 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
1039 password = purple_account_get_password(account); 1047 password = purple_account_get_password(account);
1040 if ((password == NULL) && 1048 if ((password == NULL) &&
1041 !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && 1049 !(prpl_info->options & OPT_PROTO_NO_PASSWORD) &&
1042 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) 1050 !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL))
1043 purple_account_request_password(account, G_CALLBACK(request_password_ok_cb), NULL, account); 1051 purple_account_request_password(account, G_CALLBACK(request_password_ok_cb), G_CALLBACK(request_password_cancel_cb), account);
1044 else 1052 else
1045 purple_connection_new(account, FALSE, password); 1053 purple_connection_new(account, FALSE, password);
1046 } 1054 }
1047 1055
1048 void 1056 void
1109 ops->close_account_request(info->ui_handle); 1117 ops->close_account_request(info->ui_handle);
1110 1118
1111 g_free(info); 1119 g_free(info);
1112 } 1120 }
1113 1121
1114 void 1122 void
1115 purple_account_request_close_with_account(PurpleAccount *account) 1123 purple_account_request_close_with_account(PurpleAccount *account)
1116 { 1124 {
1117 GList *l, *l_next; 1125 GList *l, *l_next;
1118 1126
1119 g_return_if_fail(account != NULL); 1127 g_return_if_fail(account != NULL);
1120 1128
1121 for (l = handles; l != NULL; l = l_next) { 1129 for (l = handles; l != NULL; l = l_next) {
1122 PurpleAccountRequestInfo *info = l->data; 1130 PurpleAccountRequestInfo *info = l->data;
1123 1131
1124 l_next = l->next; 1132 l_next = l->next;
1125 1133
1126 if (info->account == account) { 1134 if (info->account == account) {
1127 handles = g_list_remove(handles, info); 1135 handles = g_list_remove(handles, info);
1128 purple_account_request_close_info(info); 1136 purple_account_request_close_info(info);
1129 } 1137 }
1130 } 1138 }
1131 } 1139 }
1132 1140
1133 void 1141 void
1134 purple_account_request_close(void *ui_handle) 1142 purple_account_request_close(void *ui_handle)
1135 { 1143 {
1136 GList *l, *l_next; 1144 GList *l, *l_next;
1137 1145
1138 g_return_if_fail(ui_handle != NULL); 1146 g_return_if_fail(ui_handle != NULL);
1139 1147
1140 for (l = handles; l != NULL; l = l_next) { 1148 for (l = handles; l != NULL; l = l_next) {
1141 PurpleAccountRequestInfo *info = l->data; 1149 PurpleAccountRequestInfo *info = l->data;
1142 1150
1143 l_next = l->next; 1151 l_next = l->next;
1144 1152
1145 if (info->ui_handle == ui_handle) { 1153 if (info->ui_handle == ui_handle) {
1146 handles = g_list_remove(handles, info); 1154 handles = g_list_remove(handles, info);
1147 purple_account_request_close_info(info); 1155 purple_account_request_close_info(info);
1148 } 1156 }
1149 } 1157 }
1170 on_list, auth_cb, deny_cb, user_data); 1178 on_list, auth_cb, deny_cb, user_data);
1171 1179
1172 handles = g_list_append(handles, info); 1180 handles = g_list_append(handles, info);
1173 return info->ui_handle; 1181 return info->ui_handle;
1174 } 1182 }
1175 1183
1176 return NULL; 1184 return NULL;
1177 } 1185 }
1178 1186
1179 static void 1187 static void
1180 change_password_cb(PurpleAccount *account, PurpleRequestFields *fields) 1188 change_password_cb(PurpleAccount *account, PurpleRequestFields *fields)
2441 purple_signal_register(handle, "account-alias-changed", 2449 purple_signal_register(handle, "account-alias-changed",
2442 purple_marshal_VOID__POINTER_POINTER, NULL, 2, 2450 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
2443 purple_value_new(PURPLE_TYPE_SUBTYPE, 2451 purple_value_new(PURPLE_TYPE_SUBTYPE,
2444 PURPLE_SUBTYPE_ACCOUNT), 2452 PURPLE_SUBTYPE_ACCOUNT),
2445 purple_value_new(PURPLE_TYPE_STRING)); 2453 purple_value_new(PURPLE_TYPE_STRING));
2446 2454
2447 load_accounts(); 2455 load_accounts();
2448 2456
2449 } 2457 }
2450 2458
2451 void 2459 void