Mercurial > pidgin.yaz
comparison libpurple/account.c @ 21229:0b67d509a305
merge of '1bcf84e26d11f259b3c5ec663e3fecc2f01aed33'
and 'ce13b5ca4994abbd4934b3bc568c8b115335c426'
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 14 Oct 2007 02:41:00 +0000 |
parents | 285bb637a2b7 8e3ef71c4362 |
children | b9680933c2c6 |
comparison
equal
deleted
inserted
replaced
21098:7e200a629109 | 21229:0b67d509a305 |
---|---|
61 typedef struct | 61 typedef struct |
62 { | 62 { |
63 PurpleAccountRequestType type; | 63 PurpleAccountRequestType type; |
64 PurpleAccount *account; | 64 PurpleAccount *account; |
65 void *ui_handle; | 65 void *ui_handle; |
66 | 66 char *user; |
67 gpointer userdata; | |
68 PurpleAccountRequestAuthorizationCb auth_cb; | |
69 PurpleAccountRequestAuthorizationCb deny_cb; | |
67 } PurpleAccountRequestInfo; | 70 } PurpleAccountRequestInfo; |
68 | 71 |
69 static PurpleAccountUiOps *account_ui_ops = NULL; | 72 static PurpleAccountUiOps *account_ui_ops = NULL; |
70 | 73 |
71 static GList *accounts = NULL; | 74 static GList *accounts = NULL; |
1155 purple_account_request_close_info(info); | 1158 purple_account_request_close_info(info); |
1156 } | 1159 } |
1157 } | 1160 } |
1158 } | 1161 } |
1159 | 1162 |
1163 static void | |
1164 request_auth_cb(void *data) | |
1165 { | |
1166 PurpleAccountRequestInfo *info = data; | |
1167 info->auth_cb(info->userdata); | |
1168 purple_signal_emit(purple_accounts_get_handle(), | |
1169 "account-authorization-granted", info->account, info->user); | |
1170 g_free(info->user); | |
1171 g_free(info); | |
1172 } | |
1173 | |
1174 static void | |
1175 request_deny_cb(void *data) | |
1176 { | |
1177 PurpleAccountRequestInfo *info = data; | |
1178 info->deny_cb(info->userdata); | |
1179 purple_signal_emit(purple_accounts_get_handle(), | |
1180 "account-authorization-denied", info->account, info->user); | |
1181 g_free(info->user); | |
1182 g_free(info); | |
1183 } | |
1184 | |
1160 void * | 1185 void * |
1161 purple_account_request_authorization(PurpleAccount *account, const char *remote_user, | 1186 purple_account_request_authorization(PurpleAccount *account, const char *remote_user, |
1162 const char *id, const char *alias, const char *message, gboolean on_list, | 1187 const char *id, const char *alias, const char *message, gboolean on_list, |
1163 PurpleAccountRequestAuthorizationCb auth_cb, PurpleAccountRequestAuthorizationCb deny_cb, void *user_data) | 1188 PurpleAccountRequestAuthorizationCb auth_cb, PurpleAccountRequestAuthorizationCb deny_cb, void *user_data) |
1164 { | 1189 { |
1165 PurpleAccountUiOps *ui_ops; | 1190 PurpleAccountUiOps *ui_ops; |
1166 PurpleAccountRequestInfo *info; | 1191 PurpleAccountRequestInfo *info; |
1192 int plugin_return; | |
1167 | 1193 |
1168 g_return_val_if_fail(account != NULL, NULL); | 1194 g_return_val_if_fail(account != NULL, NULL); |
1169 g_return_val_if_fail(remote_user != NULL, NULL); | 1195 g_return_val_if_fail(remote_user != NULL, NULL); |
1170 | 1196 |
1171 ui_ops = purple_accounts_get_ui_ops(); | 1197 ui_ops = purple_accounts_get_ui_ops(); |
1198 | |
1199 plugin_return = GPOINTER_TO_INT( | |
1200 purple_signal_emit_return_1(purple_accounts_get_handle(), | |
1201 "account-authorization-requested", account, remote_user)); | |
1202 | |
1203 if (plugin_return > 0) { | |
1204 auth_cb(user_data); | |
1205 return NULL; | |
1206 } else if (plugin_return < 0) { | |
1207 deny_cb(user_data); | |
1208 return NULL; | |
1209 } | |
1172 | 1210 |
1173 if (ui_ops != NULL && ui_ops->request_authorize != NULL) { | 1211 if (ui_ops != NULL && ui_ops->request_authorize != NULL) { |
1174 info = g_new0(PurpleAccountRequestInfo, 1); | 1212 info = g_new0(PurpleAccountRequestInfo, 1); |
1175 info->type = PURPLE_ACCOUNT_REQUEST_AUTHORIZATION; | 1213 info->type = PURPLE_ACCOUNT_REQUEST_AUTHORIZATION; |
1176 info->account = account; | 1214 info->account = account; |
1215 info->auth_cb = auth_cb; | |
1216 info->deny_cb = deny_cb; | |
1217 info->userdata = user_data; | |
1218 info->user = g_strdup(remote_user); | |
1177 info->ui_handle = ui_ops->request_authorize(account, remote_user, id, alias, message, | 1219 info->ui_handle = ui_ops->request_authorize(account, remote_user, id, alias, message, |
1178 on_list, auth_cb, deny_cb, user_data); | 1220 on_list, request_auth_cb, request_deny_cb, info); |
1179 | 1221 |
1180 handles = g_list_append(handles, info); | 1222 handles = g_list_append(handles, info); |
1181 return info->ui_handle; | 1223 return info->ui_handle; |
1182 } | 1224 } |
1183 | 1225 |
2450 purple_marshal_VOID__POINTER_POINTER, NULL, 2, | 2492 purple_marshal_VOID__POINTER_POINTER, NULL, 2, |
2451 purple_value_new(PURPLE_TYPE_SUBTYPE, | 2493 purple_value_new(PURPLE_TYPE_SUBTYPE, |
2452 PURPLE_SUBTYPE_ACCOUNT), | 2494 PURPLE_SUBTYPE_ACCOUNT), |
2453 purple_value_new(PURPLE_TYPE_STRING)); | 2495 purple_value_new(PURPLE_TYPE_STRING)); |
2454 | 2496 |
2497 purple_signal_register(handle, "account-authorization-requested", | |
2498 purple_marshal_INT__POINTER_POINTER, | |
2499 purple_value_new(PURPLE_TYPE_INT), 2, | |
2500 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
2501 PURPLE_SUBTYPE_ACCOUNT), | |
2502 purple_value_new(PURPLE_TYPE_STRING)); | |
2503 | |
2504 purple_signal_register(handle, "account-authorization-denied", | |
2505 purple_marshal_VOID__POINTER_POINTER, NULL, 2, | |
2506 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
2507 PURPLE_SUBTYPE_ACCOUNT), | |
2508 purple_value_new(PURPLE_TYPE_STRING)); | |
2509 | |
2510 purple_signal_register(handle, "account-authorization-granted", | |
2511 purple_marshal_VOID__POINTER_POINTER, NULL, 2, | |
2512 purple_value_new(PURPLE_TYPE_SUBTYPE, | |
2513 PURPLE_SUBTYPE_ACCOUNT), | |
2514 purple_value_new(PURPLE_TYPE_STRING)); | |
2515 | |
2455 load_accounts(); | 2516 load_accounts(); |
2456 | 2517 |
2457 } | 2518 } |
2458 | 2519 |
2459 void | 2520 void |