Mercurial > pidgin.yaz
comparison libpurple/account.c @ 32711:385ee739940c
The intention is to make PurpleAccount a private structure in account.c, so merge
PurpleAccountPrivate into PurpleAccount.
author | andrew.victor@mxit.com |
---|---|
date | Sat, 01 Oct 2011 21:54:15 +0000 |
parents | cd2254bf8fa9 |
children | a34977b4d858 |
comparison
equal
deleted
inserted
replaced
32710:839116243947 | 32711:385ee739940c |
---|---|
39 #include "signals.h" | 39 #include "signals.h" |
40 #include "status.h" | 40 #include "status.h" |
41 #include "util.h" | 41 #include "util.h" |
42 #include "xmlnode.h" | 42 #include "xmlnode.h" |
43 | 43 |
44 typedef struct | |
45 { | |
46 PurpleConnectionErrorInfo *current_error; | |
47 } PurpleAccountPrivate; | |
48 | |
49 #define PURPLE_ACCOUNT_GET_PRIVATE(account) \ | |
50 ((PurpleAccountPrivate *) (account->priv)) | |
51 | |
52 /* TODO: Should use PurpleValue instead of this? What about "ui"? */ | 44 /* TODO: Should use PurpleValue instead of this? What about "ui"? */ |
53 typedef struct | 45 typedef struct |
54 { | 46 { |
55 PurplePrefType type; | 47 PurplePrefType type; |
56 | 48 |
359 } | 351 } |
360 | 352 |
361 static xmlnode * | 353 static xmlnode * |
362 account_to_xmlnode(PurpleAccount *account) | 354 account_to_xmlnode(PurpleAccount *account) |
363 { | 355 { |
364 PurpleAccountPrivate *priv = PURPLE_ACCOUNT_GET_PRIVATE(account); | |
365 | |
366 xmlnode *node, *child; | 356 xmlnode *node, *child; |
367 const char *tmp; | 357 const char *tmp; |
368 PurplePresence *presence; | 358 PurplePresence *presence; |
369 PurpleProxyInfo *proxy_info; | 359 PurpleProxyInfo *proxy_info; |
370 | 360 |
417 { | 407 { |
418 child = proxy_settings_to_xmlnode(proxy_info); | 408 child = proxy_settings_to_xmlnode(proxy_info); |
419 xmlnode_insert_child(node, child); | 409 xmlnode_insert_child(node, child); |
420 } | 410 } |
421 | 411 |
422 child = current_error_to_xmlnode(priv->current_error); | 412 child = current_error_to_xmlnode(account->current_error); |
423 xmlnode_insert_child(node, child); | 413 xmlnode_insert_child(node, child); |
424 | 414 |
425 return node; | 415 return node; |
426 } | 416 } |
427 | 417 |
994 | 984 |
995 PurpleAccount * | 985 PurpleAccount * |
996 purple_account_new(const char *username, const char *protocol_id) | 986 purple_account_new(const char *username, const char *protocol_id) |
997 { | 987 { |
998 PurpleAccount *account = NULL; | 988 PurpleAccount *account = NULL; |
999 PurpleAccountPrivate *priv = NULL; | |
1000 PurplePlugin *prpl = NULL; | 989 PurplePlugin *prpl = NULL; |
1001 PurplePluginProtocolInfo *prpl_info = NULL; | 990 PurplePluginProtocolInfo *prpl_info = NULL; |
1002 PurpleStatusType *status_type; | 991 PurpleStatusType *status_type; |
1003 | 992 |
1004 g_return_val_if_fail(username != NULL, NULL); | 993 g_return_val_if_fail(username != NULL, NULL); |
1009 if (account != NULL) | 998 if (account != NULL) |
1010 return account; | 999 return account; |
1011 | 1000 |
1012 account = g_new0(PurpleAccount, 1); | 1001 account = g_new0(PurpleAccount, 1); |
1013 PURPLE_DBUS_REGISTER_POINTER(account, PurpleAccount); | 1002 PURPLE_DBUS_REGISTER_POINTER(account, PurpleAccount); |
1014 priv = g_new0(PurpleAccountPrivate, 1); | |
1015 account->priv = priv; | |
1016 | 1003 |
1017 purple_account_set_username(account, username); | 1004 purple_account_set_username(account, username); |
1018 | 1005 |
1019 purple_account_set_protocol_id(account, protocol_id); | 1006 purple_account_set_protocol_id(account, protocol_id); |
1020 | 1007 |
1053 } | 1040 } |
1054 | 1041 |
1055 void | 1042 void |
1056 purple_account_destroy(PurpleAccount *account) | 1043 purple_account_destroy(PurpleAccount *account) |
1057 { | 1044 { |
1058 PurpleAccountPrivate *priv = NULL; | |
1059 GList *l; | 1045 GList *l; |
1060 | 1046 |
1061 g_return_if_fail(account != NULL); | 1047 g_return_if_fail(account != NULL); |
1062 | 1048 |
1063 purple_debug_info("account", "Destroying account %p\n", account); | 1049 purple_debug_info("account", "Destroying account %p\n", account); |
1100 while (account->permit) { | 1086 while (account->permit) { |
1101 g_free(account->permit->data); | 1087 g_free(account->permit->data); |
1102 account->permit = g_slist_delete_link(account->permit, account->permit); | 1088 account->permit = g_slist_delete_link(account->permit, account->permit); |
1103 } | 1089 } |
1104 | 1090 |
1105 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); | 1091 PURPLE_DBUS_UNREGISTER_POINTER(account->current_error); |
1106 PURPLE_DBUS_UNREGISTER_POINTER(priv->current_error); | 1092 if (account->current_error) { |
1107 if (priv->current_error) { | 1093 g_free(account->current_error->description); |
1108 g_free(priv->current_error->description); | 1094 g_free(account->current_error); |
1109 g_free(priv->current_error); | 1095 } |
1110 } | |
1111 g_free(priv); | |
1112 | 1096 |
1113 PURPLE_DBUS_UNREGISTER_POINTER(account); | 1097 PURPLE_DBUS_UNREGISTER_POINTER(account); |
1114 g_free(account); | 1098 g_free(account); |
1115 } | 1099 } |
1116 | 1100 |
2707 } | 2691 } |
2708 | 2692 |
2709 static void | 2693 static void |
2710 set_current_error(PurpleAccount *account, PurpleConnectionErrorInfo *new_err) | 2694 set_current_error(PurpleAccount *account, PurpleConnectionErrorInfo *new_err) |
2711 { | 2695 { |
2712 PurpleAccountPrivate *priv; | |
2713 PurpleConnectionErrorInfo *old_err; | 2696 PurpleConnectionErrorInfo *old_err; |
2714 | 2697 |
2715 g_return_if_fail(account != NULL); | 2698 g_return_if_fail(account != NULL); |
2716 | 2699 |
2717 priv = PURPLE_ACCOUNT_GET_PRIVATE(account); | 2700 old_err = account->current_error; |
2718 old_err = priv->current_error; | |
2719 | 2701 |
2720 if(new_err == old_err) | 2702 if(new_err == old_err) |
2721 return; | 2703 return; |
2722 | 2704 |
2723 priv->current_error = new_err; | 2705 account->current_error = new_err; |
2724 | 2706 |
2725 purple_signal_emit(purple_accounts_get_handle(), | 2707 purple_signal_emit(purple_accounts_get_handle(), |
2726 "account-error-changed", | 2708 "account-error-changed", |
2727 account, old_err, new_err); | 2709 account, old_err, new_err); |
2728 schedule_accounts_save(); | 2710 schedule_accounts_save(); |
2760 } | 2742 } |
2761 | 2743 |
2762 const PurpleConnectionErrorInfo * | 2744 const PurpleConnectionErrorInfo * |
2763 purple_account_get_current_error(PurpleAccount *account) | 2745 purple_account_get_current_error(PurpleAccount *account) |
2764 { | 2746 { |
2765 PurpleAccountPrivate *priv = PURPLE_ACCOUNT_GET_PRIVATE(account); | 2747 return account->current_error; |
2766 return priv->current_error; | |
2767 } | 2748 } |
2768 | 2749 |
2769 void | 2750 void |
2770 purple_account_clear_current_error(PurpleAccount *account) | 2751 purple_account_clear_current_error(PurpleAccount *account) |
2771 { | 2752 { |