gobjectification: 4f9fa2e2: Hide some more stuff from PurpleAccount....
sadrul at pidgin.im
sadrul at pidgin.im
Thu Jun 26 20:06:20 EDT 2008
-----------------------------------------------------------------
Revision: 4f9fa2e22c476f9ee1e4f94f8c3a76a7e8d16f75
Ancestor: e266be2d36e08b1c15f3e134cdb0803b8cfb38db
Author: sadrul at pidgin.im
Date: 2008-06-26T23:48:58
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/4f9fa2e22c476f9ee1e4f94f8c3a76a7e8d16f75
Modified files:
libpurple/account.c libpurple/account.h
libpurple/protocols/gg/gg.c libpurple/protocols/irc/cmds.c
libpurple/protocols/jabber/jabber.c
libpurple/protocols/msn/notification.c
libpurple/protocols/myspace/myspace.c
libpurple/protocols/oscar/flap_connection.c
libpurple/protocols/oscar/oscar.c
libpurple/protocols/yahoo/yahoo.c
libpurple/protocols/yahoo/yahoo_aliases.c
libpurple/protocols/yahoo/yahoo_picture.c
libpurple/protocols/yahoo/yahoo_profile.c
libpurple/savedstatuses.c pidgin/gtkblist.c pidgin/gtkconv.c
pidgin/plugins/xmppconsole.c
ChangeLog:
Hide some more stuff from PurpleAccount. The stuff related to privacy are
the only ones left to be hidden, and I am not sure simply providing
accessor functions is enough for those.
A couple of questions:
* We now have a 'disconnecting' variable for a PurpleAccount. Can't we
use a connection-flag instead? (that's what we use to determine if an
account is connected/connecting/disconnected)
* It looks like we can remove registration_cb/registration_cb_user_data
from PurpleAccount, and replace that with a corresponding signal.
For example, we can have a "registered" signal (with "success"/
"failure" details, perhaps). Any objections to this change?
-------------- next part --------------
============================================================
--- libpurple/account.c 39db1423ca6bee3479f5c8408da7769af8ca951e
+++ libpurple/account.c 975c531db2d2353fadae74ff298ac260567e9d39
@@ -56,14 +56,28 @@ struct _PurpleAccountPrivate
char *protocol_id; /**< The ID of the protocol. */
+ PurpleConnection *gc; /**< The connection handle. */
+ gboolean disconnecting; /**< The account is currently disconnecting */
+
+ PurpleProxyInfo *proxy_info; /**< Proxy information. This will be set */
+ /* to NULL when the account inherits */
+ /* proxy settings from global prefs. */
+
PurpleConnectionErrorInfo *current_error;
gboolean check_mail;
gboolean enabled;
PurplePlugin *prpl;
+
+ GHashTable *settings; /**< Protocol-specific settings. */
+ GHashTable *ui_settings; /**< UI-specific settings. */
+
+ PurplePresence *presence; /**< Presence. */
+ PurpleLog *system_log; /**< The system log */
+ GList *status_types; /**< Status types. */
};
#define PURPLE_ACCOUNT_GET_PRIVATE(account) \
- ((PurpleAccountPrivate *) (account->priv))
+ (G_TYPE_INSTANCE_GET_PRIVATE((account), PURPLE_TYPE_ACCOUNT, PurpleAccountPrivate))
/* TODO: Should use PurpleValue instead of this? What about "ui"? */
typedef struct
@@ -452,10 +466,12 @@ purple_account_set_property(GObject *obj
purple_account_set_connection(account,
PURPLE_CONNECTION(g_value_get_object(value)));
break;
- case PROP_PRPL:
+ case PROP_PRPL: {
#warning use _object when the prpls are GObjects
- account->priv->prpl = g_value_get_pointer(value);
- account->priv->protocol_id = g_strdup(purple_plugin_get_id(account->priv->prpl));
+ PurpleAccountPrivate *priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ priv->prpl = g_value_get_pointer(value);
+ priv->protocol_id = g_strdup(purple_plugin_get_id(priv->prpl));
+ }
break;
case PROP_USER_INFO:
purple_account_set_user_info(account, g_value_get_string(value));
@@ -530,14 +546,13 @@ static void purple_account_init(GTypeIns
static void purple_account_init(GTypeInstance *instance, gpointer klass)
{
PurpleAccount *account = PURPLE_ACCOUNT(instance);
+ PurpleAccountPrivate *priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
- account->priv = g_new0(PurpleAccountPrivate, 1);
-
- account->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
+ priv->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, delete_setting);
- account->ui_settings = g_hash_table_new_full(g_str_hash, g_str_equal,
+ priv->ui_settings = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, (GDestroyNotify)g_hash_table_destroy);
- account->system_log = NULL;
+ priv->system_log = NULL;
account->perm_deny = PURPLE_PRIVACY_ALLOW_ALL;
}
@@ -570,26 +585,25 @@ purple_account_finalize(GObject *object)
priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
- g_free(account->priv->username);
- g_free(account->priv->alias);
- g_free(account->priv->password);
- g_free(account->priv->user_info);
- g_free(account->priv->buddy_icon_path);
- g_free(account->priv->protocol_id);
+ g_free(priv->username);
+ g_free(priv->alias);
+ g_free(priv->password);
+ g_free(priv->user_info);
+ g_free(priv->buddy_icon_path);
+ g_free(priv->protocol_id);
- g_hash_table_destroy(account->settings);
- g_hash_table_destroy(account->ui_settings);
+ g_hash_table_destroy(priv->settings);
+ g_hash_table_destroy(priv->ui_settings);
purple_account_set_status_types(account, NULL);
- purple_presence_destroy(account->presence);
+ purple_presence_destroy(priv->presence);
- if(account->system_log)
- purple_log_free(account->system_log);
+ if (priv->system_log)
+ purple_log_free(priv->system_log);
PURPLE_DBUS_UNREGISTER_POINTER(priv->current_error);
g_free(priv->current_error);
- g_free(priv);
PURPLE_DBUS_UNREGISTER_POINTER(account);
parent_class->finalize(object);
@@ -689,6 +703,8 @@ static void purple_account_class_init(Pu
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
#warning TODO: Setup more signals
+
+ g_type_class_add_private(klass, sizeof(PurpleAccountPrivate));
}
GType purple_account_get_gtype(void)
@@ -724,6 +740,7 @@ purple_account_new(const char *username,
PurplePlugin *prpl = NULL;
PurplePluginProtocolInfo *prpl_info = NULL;
PurpleStatusType *status_type;
+ PurpleAccountPrivate *priv;
g_return_val_if_fail(username != NULL, NULL);
g_return_val_if_fail(protocol_id != NULL, NULL);
@@ -740,6 +757,7 @@ purple_account_new(const char *username,
PROP_USERNAME_S, username,
PROP_PRPL_S, prpl,
NULL);
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
PURPLE_DBUS_REGISTER_POINTER(account, PurpleAccount);
@@ -747,15 +765,15 @@ purple_account_new(const char *username,
if (prpl_info != NULL && prpl_info->status_types != NULL)
purple_account_set_status_types(account, prpl_info->status_types(account));
- account->presence = purple_presence_new_for_account(account);
+ priv->presence = purple_presence_new_for_account(account);
status_type = purple_account_get_status_type_with_primitive(account, PURPLE_STATUS_AVAILABLE);
if (status_type != NULL) {
- purple_presence_set_status_active(account->presence,
+ purple_presence_set_status_active(priv->presence,
purple_status_type_get_id(status_type),
TRUE);
} else {
- purple_presence_set_status_active(account->presence,
+ purple_presence_set_status_active(priv->presence,
"offline",
TRUE);
}
@@ -770,6 +788,7 @@ purple_account_destroy(PurpleAccount *ac
g_object_unref(G_OBJECT(account));
}
+#if 0
void
purple_account_set_register_callback(PurpleAccount *account, PurpleAccountRegistrationCb cb, void *user_data)
{
@@ -778,6 +797,7 @@ purple_account_set_register_callback(Pur
account->registration_cb = cb;
account->registration_cb_user_data = user_data;
}
+#endif
void
purple_account_register(PurpleAccount *account)
@@ -913,18 +933,21 @@ purple_account_disconnect(PurpleAccount
void
purple_account_disconnect(PurpleAccount *account)
{
+ PurpleAccountPrivate *priv;
+
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
g_return_if_fail(!purple_account_is_disconnected(account));
purple_debug_info("account", "Disconnecting account %p\n", account);
- account->disconnecting = TRUE;
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ priv->disconnecting = TRUE;
purple_account_set_connection(account, NULL);
if (!purple_account_get_remember_password(account))
purple_account_set_password(account, NULL);
- account->disconnecting = FALSE;
+ priv->disconnecting = FALSE;
}
void
@@ -1322,16 +1345,19 @@ purple_account_set_connection(PurpleAcco
purple_account_set_connection(PurpleAccount *account, PurpleConnection *gc)
{
PurpleConnection *old;
+ PurpleAccountPrivate *priv;
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
g_return_if_fail(gc == NULL || PURPLE_IS_CONNECTION(gc));
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+
#warning Connect and disconnect to 'signed-on' and 'connection-error' on gc and set/clear current_error.
- if (account->gc == gc)
+ if (priv->gc == gc)
return;
- old = account->gc;
- account->gc = gc;
+ old = priv->gc;
+ priv->gc = gc;
if (old)
g_object_unref(old);
g_object_notify(G_OBJECT(account), PROP_CONNECTION_S);
@@ -1370,6 +1396,7 @@ purple_account_set_enabled(PurpleAccount
{
PurpleConnection *gc;
gboolean was_enabled = FALSE;
+ PurpleAccountPrivate *priv;
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
@@ -1377,7 +1404,8 @@ purple_account_set_enabled(PurpleAccount
if (was_enabled == value)
return;
- PURPLE_ACCOUNT_GET_PRIVATE(account)->enabled = value;
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ priv->enabled = value;
g_object_notify(G_OBJECT(account), PROP_ENABLED_S);
g_signal_emit(G_OBJECT(account), signals[SIG_ENABLE_CHANGED],
@@ -1394,7 +1422,7 @@ purple_account_set_enabled(PurpleAccount
return;
#endif
- if (value && purple_presence_is_online(account->presence))
+ if (value && purple_presence_is_online(priv->presence))
purple_account_connect(account);
else if (!value && !purple_account_is_disconnected(account))
purple_account_disconnect(account);
@@ -1403,12 +1431,15 @@ purple_account_set_proxy_info(PurpleAcco
void
purple_account_set_proxy_info(PurpleAccount *account, PurpleProxyInfo *info)
{
+ PurpleAccountPrivate *priv;
+
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
- if (account->proxy_info != NULL)
- purple_proxy_info_destroy(account->proxy_info);
+ if (priv->proxy_info != NULL)
+ purple_proxy_info_destroy(priv->proxy_info);
- account->proxy_info = info;
+ priv->proxy_info = info;
schedule_accounts_save();
}
@@ -1416,17 +1447,20 @@ purple_account_set_status_types(PurpleAc
void
purple_account_set_status_types(PurpleAccount *account, GList *status_types)
{
+ PurpleAccountPrivate *priv;
+
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
/* Out with the old... */
- if (account->status_types != NULL)
+ if (priv->status_types != NULL)
{
- g_list_foreach(account->status_types, (GFunc)purple_status_type_destroy, NULL);
- g_list_free(account->status_types);
+ g_list_foreach(priv->status_types, (GFunc)purple_status_type_destroy, NULL);
+ g_list_free(priv->status_types);
}
/* In with the new... */
- account->status_types = status_types;
+ priv->status_types = status_types;
}
void
@@ -1482,11 +1516,12 @@ purple_account_clear_settings(PurpleAcco
void
purple_account_clear_settings(PurpleAccount *account)
{
+ PurpleAccountPrivate *priv;
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
- g_hash_table_destroy(account->settings);
-
- account->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ g_hash_table_destroy(priv->settings);
+ priv->settings = g_hash_table_new_full(g_str_hash, g_str_equal,
g_free, delete_setting);
}
@@ -1497,8 +1532,9 @@ account_setting_value_changed(PurpleAcco
va_list args;
PurpleAccountSetting *setting;
gboolean changed = TRUE;
+ PurpleAccountPrivate *priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
- setting = g_hash_table_lookup(account->settings, name);
+ setting = g_hash_table_lookup(priv->settings, name);
if (!setting)
return TRUE; /* This is a new setting */
@@ -1527,6 +1563,7 @@ purple_account_set_int(PurpleAccount *ac
void
purple_account_set_int(PurpleAccount *account, const char *name, int value)
{
+ PurpleAccountPrivate *priv;
PurpleAccountSetting *setting;
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
@@ -1536,11 +1573,11 @@ purple_account_set_int(PurpleAccount *ac
return;
setting = g_new0(PurpleAccountSetting, 1);
-
setting->type = PURPLE_PREF_INT;
setting->value.integer = value;
- g_hash_table_insert(account->settings, g_strdup(name), setting);
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ g_hash_table_insert(priv->settings, g_strdup(name), setting);
g_signal_emit(G_OBJECT(account), signals[SIG_SETTINGS_CHANGED],
g_quark_from_string(name));
}
@@ -1549,6 +1586,7 @@ purple_account_set_string(PurpleAccount
purple_account_set_string(PurpleAccount *account, const char *name,
const char *value)
{
+ PurpleAccountPrivate *priv;
PurpleAccountSetting *setting;
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
@@ -1558,11 +1596,11 @@ purple_account_set_string(PurpleAccount
return;
setting = g_new0(PurpleAccountSetting, 1);
-
setting->type = PURPLE_PREF_STRING;
setting->value.string = g_strdup(value);
- g_hash_table_insert(account->settings, g_strdup(name), setting);
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ g_hash_table_insert(priv->settings, g_strdup(name), setting);
g_signal_emit(G_OBJECT(account), signals[SIG_SETTINGS_CHANGED],
g_quark_from_string(name));
@@ -1571,6 +1609,7 @@ purple_account_set_bool(PurpleAccount *a
void
purple_account_set_bool(PurpleAccount *account, const char *name, gboolean value)
{
+ PurpleAccountPrivate *priv;
PurpleAccountSetting *setting;
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
@@ -1580,11 +1619,11 @@ purple_account_set_bool(PurpleAccount *a
return;
setting = g_new0(PurpleAccountSetting, 1);
-
setting->type = PURPLE_PREF_BOOLEAN;
setting->value.boolean = value;
- g_hash_table_insert(account->settings, g_strdup(name), setting);
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ g_hash_table_insert(priv->settings, g_strdup(name), setting);
g_signal_emit(G_OBJECT(account), signals[SIG_SETTINGS_CHANGED],
g_quark_from_string(name));
@@ -1593,14 +1632,16 @@ get_ui_settings_table(PurpleAccount *acc
static GHashTable *
get_ui_settings_table(PurpleAccount *account, const char *ui)
{
+ PurpleAccountPrivate *priv;
GHashTable *table;
- table = g_hash_table_lookup(account->ui_settings, ui);
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ table = g_hash_table_lookup(priv->ui_settings, ui);
if (table == NULL) {
table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
delete_setting);
- g_hash_table_insert(account->ui_settings, g_strdup(ui), table);
+ g_hash_table_insert(priv->ui_settings, g_strdup(ui), table);
}
return table;
@@ -1770,6 +1811,12 @@ gboolean
}
gboolean
+purple_account_is_disconnecting(const PurpleAccount *account)
+{
+ return (PURPLE_ACCOUNT_GET_PRIVATE(account)->disconnecting);
+}
+
+gboolean
purple_account_is_disconnected(const PurpleAccount *account)
{
return (purple_account_get_state(account) == PURPLE_CONNECTION_STATE_DISCONNECTED);
@@ -1840,7 +1887,7 @@ purple_account_get_connection(const Purp
{
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
- return account->gc;
+ return PURPLE_ACCOUNT_GET_PRIVATE(account)->gc;
}
gboolean
@@ -1872,7 +1919,7 @@ purple_account_get_proxy_info(const Purp
{
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
- return account->proxy_info;
+ return PURPLE_ACCOUNT_GET_PRIVATE(account)->proxy_info;
}
PurpleStatus *
@@ -1880,7 +1927,7 @@ purple_account_get_active_status(const P
{
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
- return purple_presence_get_active_status(account->presence);
+ return purple_presence_get_active_status(PURPLE_ACCOUNT_GET_PRIVATE(account)->presence);
}
PurpleStatus *
@@ -1889,7 +1936,7 @@ purple_account_get_status(const PurpleAc
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
g_return_val_if_fail(status_id != NULL, NULL);
- return purple_presence_get_status(account->presence, status_id);
+ return purple_presence_get_status(PURPLE_ACCOUNT_GET_PRIVATE(account)->presence, status_id);
}
PurpleStatusType *
@@ -1934,7 +1981,7 @@ purple_account_get_presence(const Purple
{
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
- return account->presence;
+ return PURPLE_ACCOUNT_GET_PRIVATE(account)->presence;
}
gboolean
@@ -1944,7 +1991,8 @@ purple_account_is_status_active(const Pu
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), FALSE);
g_return_val_if_fail(status_id != NULL, FALSE);
- return purple_presence_is_status_active(account->presence, status_id);
+ return purple_presence_is_status_active(PURPLE_ACCOUNT_GET_PRIVATE(account)->presence,
+ status_id);
}
GList *
@@ -1952,19 +2000,21 @@ purple_account_get_status_types(const Pu
{
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
- return account->status_types;
+ return PURPLE_ACCOUNT_GET_PRIVATE(account)->status_types;
}
int
purple_account_get_int(const PurpleAccount *account, const char *name,
int default_value)
{
+ PurpleAccountPrivate *priv;
PurpleAccountSetting *setting;
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), default_value);
g_return_val_if_fail(name != NULL, default_value);
- setting = g_hash_table_lookup(account->settings, name);
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ setting = g_hash_table_lookup(priv->settings, name);
if (setting == NULL)
return default_value;
@@ -1978,12 +2028,14 @@ purple_account_get_string(const PurpleAc
purple_account_get_string(const PurpleAccount *account, const char *name,
const char *default_value)
{
+ PurpleAccountPrivate *priv;
PurpleAccountSetting *setting;
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), default_value);
g_return_val_if_fail(name != NULL, default_value);
- setting = g_hash_table_lookup(account->settings, name);
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ setting = g_hash_table_lookup(priv->settings, name);
if (setting == NULL)
return default_value;
@@ -1997,12 +2049,14 @@ purple_account_get_bool(const PurpleAcco
purple_account_get_bool(const PurpleAccount *account, const char *name,
gboolean default_value)
{
+ PurpleAccountPrivate *priv;
PurpleAccountSetting *setting;
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), default_value);
g_return_val_if_fail(name != NULL, default_value);
- setting = g_hash_table_lookup(account->settings, name);
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ setting = g_hash_table_lookup(priv->settings, name);
if (setting == NULL)
return default_value;
@@ -2016,6 +2070,7 @@ purple_account_get_ui_int(const PurpleAc
purple_account_get_ui_int(const PurpleAccount *account, const char *ui,
const char *name, int default_value)
{
+ PurpleAccountPrivate *priv;
PurpleAccountSetting *setting;
GHashTable *table;
@@ -2023,7 +2078,8 @@ purple_account_get_ui_int(const PurpleAc
g_return_val_if_fail(ui != NULL, default_value);
g_return_val_if_fail(name != NULL, default_value);
- if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL)
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ if ((table = g_hash_table_lookup(priv->ui_settings, ui)) == NULL)
return default_value;
if ((setting = g_hash_table_lookup(table, name)) == NULL)
@@ -2038,6 +2094,7 @@ purple_account_get_ui_string(const Purpl
purple_account_get_ui_string(const PurpleAccount *account, const char *ui,
const char *name, const char *default_value)
{
+ PurpleAccountPrivate *priv;
PurpleAccountSetting *setting;
GHashTable *table;
@@ -2045,7 +2102,8 @@ purple_account_get_ui_string(const Purpl
g_return_val_if_fail(ui != NULL, default_value);
g_return_val_if_fail(name != NULL, default_value);
- if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL)
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ if ((table = g_hash_table_lookup(priv->ui_settings, ui)) == NULL)
return default_value;
if ((setting = g_hash_table_lookup(table, name)) == NULL)
@@ -2060,6 +2118,7 @@ purple_account_get_ui_bool(const PurpleA
purple_account_get_ui_bool(const PurpleAccount *account, const char *ui,
const char *name, gboolean default_value)
{
+ PurpleAccountPrivate *priv;
PurpleAccountSetting *setting;
GHashTable *table;
@@ -2067,7 +2126,8 @@ purple_account_get_ui_bool(const PurpleA
g_return_val_if_fail(ui != NULL, default_value);
g_return_val_if_fail(name != NULL, default_value);
- if ((table = g_hash_table_lookup(account->ui_settings, ui)) == NULL)
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ if ((table = g_hash_table_lookup(priv->ui_settings, ui)) == NULL)
return default_value;
if ((setting = g_hash_table_lookup(table, name)) == NULL)
@@ -2081,31 +2141,35 @@ purple_account_get_log(PurpleAccount *ac
PurpleLog *
purple_account_get_log(PurpleAccount *account, gboolean create)
{
+ PurpleAccountPrivate *priv;
g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
- if(!account->system_log && create){
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ if(!priv->system_log && create){
PurplePresence *presence;
int login_time;
presence = purple_account_get_presence(account);
login_time = purple_presence_get_login_time(presence);
- account->system_log = purple_log_new(PURPLE_LOG_SYSTEM,
+ priv->system_log = purple_log_new(PURPLE_LOG_SYSTEM,
purple_account_get_username(account), account, NULL,
(login_time != 0) ? login_time : time(NULL), NULL);
}
- return account->system_log;
+ return priv->system_log;
}
void
purple_account_destroy_log(PurpleAccount *account)
{
+ PurpleAccountPrivate *priv;
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
- if(account->system_log){
- purple_log_free(account->system_log);
- account->system_log = NULL;
+ priv = PURPLE_ACCOUNT_GET_PRIVATE(account);
+ if(priv->system_log){
+ purple_log_free(priv->system_log);
+ priv->system_log = NULL;
}
}
@@ -2391,15 +2455,15 @@ xmlnode * purple_account_to_xmlnode(Purp
child = xmlnode_new_child(node, "check-mail");
xmlnode_insert_data(child, purple_account_get_check_mail(account) ? "1" : "0", -1);
- if (g_hash_table_size(account->settings) > 0)
+ if (g_hash_table_size(priv->settings) > 0)
{
child = xmlnode_new_child(node, "settings");
- g_hash_table_foreach(account->settings, setting_to_xmlnode, child);
+ g_hash_table_foreach(priv->settings, setting_to_xmlnode, child);
}
- if (g_hash_table_size(account->ui_settings) > 0)
+ if (g_hash_table_size(priv->ui_settings) > 0)
{
- g_hash_table_foreach(account->ui_settings, ui_setting_to_xmlnode, node);
+ g_hash_table_foreach(priv->ui_settings, ui_setting_to_xmlnode, node);
}
if ((proxy_info = purple_account_get_proxy_info(account)) != NULL)
@@ -2573,7 +2637,7 @@ purple_accounts_restore_current_statuses
{
account = (PurpleAccount *)l->data;
if (purple_account_get_enabled(account) &&
- (purple_presence_is_online(account->presence)))
+ (purple_presence_is_online(PURPLE_ACCOUNT_GET_PRIVATE(account)->presence)))
{
purple_account_connect(account);
}
============================================================
--- libpurple/account.h 750313c104c561763790d46cdfae899ab9e44540
+++ libpurple/account.h 69b50214d950785b3066fef3de9c1773dd05f4db
@@ -126,28 +126,15 @@ struct _PurpleAccount
PurpleAccountPrivate *priv;
- PurpleConnection *gc; /**< The connection handle. */
- gboolean disconnecting; /**< The account is currently disconnecting */
-
- GHashTable *settings; /**< Protocol-specific settings. */
- GHashTable *ui_settings; /**< UI-specific settings. */
-
- PurpleProxyInfo *proxy_info; /**< Proxy information. This will be set */
- /* to NULL when the account inherits */
- /* proxy settings from global prefs. */
-
GSList *permit; /**< Permit list. */
GSList *deny; /**< Deny list. */
int perm_deny; /**< The permit/deny setting. */
- GList *status_types; /**< Status types. */
-
- PurplePresence *presence; /**< Presence. */
- PurpleLog *system_log; /**< The system log */
-
- void *ui_data; /**< The UI can put data here. */
+#if 0
+ /* XXX: Someone needs to explain (again?) why these are necessary */
PurpleAccountRegistrationCb registration_cb;
void *registration_cb_user_data;
+#endif
};
struct _PurpleAccountClass
@@ -189,6 +176,7 @@ void purple_account_connect(PurpleAccoun
*/
void purple_account_connect(PurpleAccount *account);
+#if 0
/**
* Sets the callback for successful registration.
*
@@ -197,6 +185,7 @@ void purple_account_set_register_callbac
* @param user_data The user data passed to the callback
*/
void purple_account_set_register_callback(PurpleAccount *account, PurpleAccountRegistrationCb cb, void *user_data);
+#endif
/**
* Registers an account.
@@ -537,6 +526,15 @@ gboolean purple_account_is_disconnected(
gboolean purple_account_is_disconnected(const PurpleAccount *account);
/**
+ * Returns whether or not the account is disconnecting.
+ *
+ * @param account The account.
+ *
+ * @return @c TRUE if disconnecting, or @c FALSE otherwise.
+ */
+gboolean purple_account_is_disconnecting(const PurpleAccount *account);
+
+/**
* Returns the account's username.
*
* @param account The account.
============================================================
--- libpurple/protocols/gg/gg.c ff952f3ecce09a43f8ee33ef4e6f3253f227f60e
+++ libpurple/protocols/gg/gg.c 382cc6f3088d55b420f63710cb33da1b97636fd0
@@ -412,8 +412,11 @@ static void ggp_callback_register_accoun
purple_notify_info(NULL, _("New Gadu-Gadu Account Registered"),
_("Registration completed successfully!"), NULL);
+#if 0
if(account->registration_cb)
(account->registration_cb)(account, TRUE, account->registration_cb_user_data);
+#endif
+
/* TODO: the currently open Accounts Window will not be updated withthe
* new username and etc, we need to somehow have it refresh at this
* point
@@ -423,8 +426,10 @@ exit_err:
purple_connection_destroy(gc);
exit_err:
+#if 0
if(account->registration_cb)
(account->registration_cb)(account, FALSE, account->registration_cb_user_data);
+#endif
gg_register_free(h);
g_free(email);
============================================================
--- libpurple/protocols/irc/cmds.c 5a474ed951b98282d4d7564fc984cba00c852681
+++ libpurple/protocols/irc/cmds.c 2a4a22c655ed080af4962eb44e4bc98f6af5c5b5
@@ -399,7 +399,7 @@ int irc_cmd_quit(struct irc_conn *irc, c
irc->quitting = TRUE;
- if (!irc->account->disconnecting)
+ if (!purple_account_is_disconnecting(irc->account))
purple_account_set_status(irc->account, "offline", TRUE, NULL);
}
============================================================
--- libpurple/protocols/jabber/jabber.c 77adee1e58f1428b6cf27d2a07cbcdbfc15b7dba
+++ libpurple/protocols/jabber/jabber.c e1883229fa6f25b9edc67309382c36faf657a627
@@ -705,12 +705,13 @@ jabber_registration_result_cb(JabberStre
if(!strcmp(type, "result")) {
if(js->registration) {
- buf = g_strdup_printf(_("Registration of %s@%s successful"),
- js->user->node, js->user->domain);
+ buf = g_strdup_printf(_("Registration of %s@%s successful"),
+ js->user->node, js->user->domain);
+#if 0
if(account->registration_cb)
(account->registration_cb)(account, TRUE, account->registration_cb_user_data);
- }
- else
+#endif
+ } else
buf = g_strdup_printf(_("Registration to %s successful"),
to);
purple_notify_info(NULL, _("Registration Successful"),
@@ -725,8 +726,10 @@ jabber_registration_result_cb(JabberStre
purple_notify_error(NULL, _("Registration Failed"),
_("Registration Failed"), msg);
g_free(msg);
+#if 0
if(account->registration_cb)
(account->registration_cb)(account, FALSE, account->registration_cb_user_data);
+#endif
}
g_free(to);
if(js->registration)
@@ -863,8 +866,10 @@ jabber_register_cancel_cb(JabberRegister
{
PurpleAccount *account = purple_connection_get_account(cbdata->js->gc);
if(account && cbdata->js->registration) {
+#if 0
if(account->registration_cb)
(account->registration_cb)(account, FALSE, account->registration_cb_user_data);
+#endif
jabber_connection_schedule_close(cbdata->js);
}
g_free(cbdata->who);
@@ -921,8 +926,10 @@ void jabber_register_parse(JabberStream
if(js->registration) {
purple_notify_error(NULL, _("Already Registered"),
_("Already Registered"), NULL);
+#if 0
if(account->registration_cb)
(account->registration_cb)(account, FALSE, account->registration_cb_user_data);
+#endif
jabber_connection_schedule_close(js);
return;
}
@@ -946,8 +953,10 @@ void jabber_register_parse(JabberStream
#if 0
js->gc->wants_to_die = TRUE;
#endif
+#if 0
if(account->registration_cb) /* succeeded, but we have no login info */
(account->registration_cb)(account, TRUE, account->registration_cb_user_data);
+#endif
jabber_connection_schedule_close(js);
}
return;
============================================================
--- libpurple/protocols/msn/notification.c 5b6776bf119055b3f2f4ec99319c6276ebbc047e
+++ libpurple/protocols/msn/notification.c bf213257b25ee48f3b5b1787383908d3e4a873a0
@@ -454,7 +454,7 @@ ubm_cmd_post(MsnCmdProc *cmdproc, MsnCom
msn_message_show_readable(msg, "Notification", TRUE);
#endif
- gc = cmdproc->session->account->gc;
+ gc = purple_account_get_connection(cmdproc->session->account);
passport = msg->remote_user;
content_type = msn_message_get_content_type(msg);
@@ -658,6 +658,7 @@ msn_notification_dump_contact(MsnSession
int payload_len;
int adl_count = 0;
const char *display_name;
+ PurpleConnection *conn;
adl_node = xmlnode_new("ml");
adl_node->child = NULL;
@@ -701,7 +702,8 @@ msn_notification_dump_contact(MsnSession
xmlnode_free(adl_node);
}
- display_name = purple_connection_get_display_name(session->account->gc);
+ conn = purple_account_get_connection(session->account);
+ display_name = purple_connection_get_display_name(conn);
if (display_name
&& strcmp(display_name,
purple_account_get_username(session->account))) {
@@ -1796,7 +1798,7 @@ initial_email_msg(MsnCmdProc *cmdproc, M
const char *unread;
session = cmdproc->session;
- gc = session->account->gc;
+ gc = purple_account_get_connection(session->account);
if (strcmp(msg->remote_user, "Hotmail"))
/* This isn't an official message. */
@@ -1850,7 +1852,7 @@ initial_mdata_msg(MsnCmdProc *cmdproc, M
const char *mdata, *unread;
session = cmdproc->session;
- gc = session->account->gc;
+ gc = purple_account_get_connection(session->account);
if (strcmp(msg->remote_user, "Hotmail"))
/* This isn't an official message. */
@@ -1929,7 +1931,7 @@ email_msg(MsnCmdProc *cmdproc, MsnMessag
char *from, *subject, *tmp;
session = cmdproc->session;
- gc = session->account->gc;
+ gc = purple_account_get_connection(session->account);
if (strcmp(msg->remote_user, "Hotmail"))
/* This isn't an official message. */
@@ -2014,7 +2016,8 @@ system_msg(MsnCmdProc *cmdproc, MsnMessa
}
if (*buf != '\0')
- purple_notify_info(cmdproc->session->account->gc, NULL, buf, NULL);
+ purple_notify_info(purple_account_get_connection(cmdproc->session->account),
+ NULL, buf, NULL);
}
g_hash_table_destroy(table);
============================================================
--- libpurple/protocols/myspace/myspace.c 07189cfeb9e695b4bc2ad5fa00bcd1b873a9747a
+++ libpurple/protocols/myspace/myspace.c 8c1d6bb12deae61195fd8188566883f40d68079c
@@ -2397,7 +2397,7 @@ const char *msim_normalize(const PurpleA
const char *username;
/* If the account does not exist, we can't look up the user. */
- if (!account || !account->gc)
+ if (!account || !purple_account_get_connection(account))
return str;
id = atol(str);
============================================================
--- libpurple/protocols/oscar/flap_connection.c 5d1940c20e230caffcec7bb7446dcec8ecb4e4bd
+++ libpurple/protocols/oscar/flap_connection.c a96381c660796e6e28ec426a976e4c4f8a662ac7
@@ -380,7 +380,7 @@ flap_connection_destroy_cb(gpointer data
* TODO: If we don't have a SNAC_FAMILY_LOCATE connection then
* we should try to request one instead of disconnecting.
*/
- if (!account->disconnecting && ((od->oscar_connections == NULL)
+ if (!purple_account_is_disconnecting(account) && ((od->oscar_connections == NULL)
|| (!flap_connection_getbytype(od, SNAC_FAMILY_LOCATE))))
{
/* No more FLAP connections! Sign off this PurpleConnection! */
============================================================
--- libpurple/protocols/oscar/oscar.c ea254eaf571534dfe4289b0fa00737db2432d227
+++ libpurple/protocols/oscar/oscar.c 038f8996d84d5eb966f8c1495631c52feeb0f69c
@@ -4900,10 +4900,12 @@ static int purple_ssi_parselist(OscarDat
va_list ap;
guint16 fmtver, numitems;
guint32 timestamp;
+ PurplePresence *presence;
gc = od->gc;
od = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
account = purple_connection_get_account(gc);
+ presence = purple_account_get_presence(account);
va_start(ap, fr);
fmtver = (guint16)va_arg(ap, int);
@@ -5145,7 +5147,7 @@ static int purple_ssi_parselist(OscarDat
"ssi: changing permdeny from %d to %hhu\n", account->perm_deny, permdeny);
account->perm_deny = permdeny;
if (od->icq && account->perm_deny == PURPLE_PRIVACY_ALLOW_USERS) {
- purple_presence_set_status_active(account->presence, OSCAR_STATUS_ID_INVISIBLE, TRUE);
+ purple_presence_set_status_active(presence, OSCAR_STATUS_ID_INVISIBLE, TRUE);
}
}
}
@@ -5713,7 +5715,7 @@ void oscar_tooltip_text(PurpleBuddy *b,
if (!PURPLE_BUDDY_IS_ONLINE(b))
return;
- gc = b->account->gc;
+ gc = purple_account_get_connection(b->account);
od = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
userinfo = aim_locate_finduserinfo(od, b->name);
============================================================
--- libpurple/protocols/yahoo/yahoo.c 84f20faed0e94014c547972f5438acdb65d72e8d
+++ libpurple/protocols/yahoo/yahoo.c 762739910de1f26321a0a24ba59128d33bec0b05
@@ -3532,9 +3532,11 @@ static void yahoo_show_inbox(PurplePlugi
"Content-Length: 0\r\n\r\n",
yd->cookie_t, yd->cookie_y);
gboolean use_whole_url = FALSE;
+ PurpleAccount *account = purple_connection_get_account(gc);
+ PurpleProxyInfo *proxy_info = purple_account_get_proxy_info(account);
/* use whole URL if using HTTP Proxy */
- if ((purple_connection_get_account(gc)->proxy_info) && (purple_connection_get_account(gc)->proxy_info->type == PURPLE_PROXY_HTTP))
+ if (proxy_info && proxy_info->type == PURPLE_PROXY_HTTP)
use_whole_url = TRUE;
url_data = purple_util_fetch_url_request(base_url, use_whole_url,
============================================================
--- libpurple/protocols/yahoo/yahoo_aliases.c 9c6eb565553fd3442315195387ccf651ac087ad0
+++ libpurple/protocols/yahoo/yahoo_aliases.c d6f14b90cd5fac8dbbd60f2f8c2baed29e4c8958
@@ -155,14 +155,16 @@ yahoo_fetch_aliases(PurpleConnection *gc
gchar *request, *webpage, *webaddress;
PurpleUtilFetchUrlData *url_data;
PurpleAccount *account;
+ PurpleProxyInfo *proxy_info;
gboolean use_whole_url = FALSE;
account = purple_connection_get_account(gc);
+ proxy_info = purple_account_get_proxy_info(account);
/* use whole URL if using HTTP Proxy */
- if ((account->proxy_info)
- && (account->proxy_info->type == PURPLE_PROXY_HTTP))
+ if ((proxy_info)
+ && (proxy_info->type == PURPLE_PROXY_HTTP))
use_whole_url = TRUE;
/* Using callback_data so I have access to gc in the callback function */
@@ -272,15 +274,17 @@ yahoo_update_alias(PurpleConnection *gc,
gboolean use_whole_url = FALSE;
YahooFriend *f;
PurpleAccount *account;
+ PurpleProxyInfo *proxy_info;
g_return_if_fail(who != NULL);
g_return_if_fail(gc != NULL);
account = purple_connection_get_account(gc);
+ proxy_info = purple_account_get_proxy_info(account);
/* use whole URL if using HTTP Proxy */
- if ((account->proxy_info)
- && (account->proxy_info->type == PURPLE_PROXY_HTTP))
+ if ((proxy_info)
+ && (proxy_info->type == PURPLE_PROXY_HTTP))
use_whole_url = TRUE;
if (alias == NULL)
============================================================
--- libpurple/protocols/yahoo/yahoo_picture.c 4c754b42b01ec8ffbe6f07afbea258e7a8ec64dc
+++ libpurple/protocols/yahoo/yahoo_picture.c a8b345db1d5cea93665e4e08854769c5d1b09e5a
@@ -117,9 +117,11 @@ void yahoo_process_picture(PurpleConnect
PurpleBuddy *b = purple_find_buddy(purple_connection_get_account(gc), who);
const char *locksum = NULL;
gboolean use_whole_url = FALSE;
+ PurpleAccount *account = purple_connection_get_account(gc);
+ PurpleProxyInfo *proxy_info = purple_account_get_proxy_info(account);
/* use whole URL if using HTTP Proxy */
- if ((purple_connection_get_account(gc)->proxy_info) && (purple_connection_get_account(gc)->proxy_info->type == PURPLE_PROXY_HTTP))
+ if (proxy_info && proxy_info->type == PURPLE_PROXY_HTTP)
use_whole_url = TRUE;
/* FIXME: Cleanup this strtol() stuff if possible. */
@@ -458,9 +460,11 @@ static void yahoo_buddy_icon_upload_conn
PurpleAccount *account;
struct yahoo_data *yd;
gboolean use_whole_url = FALSE;
+ PurpleProxyInfo *proxy_info;
account = purple_connection_get_account(gc);
yd = purple_object_get_protocol_data(PURPLE_OBJECT(gc));
+ proxy_info = purple_account_get_proxy_info(account);
/* Buddy icon connect is now complete; clear the PurpleProxyConnectData */
yd->buddy_icon_connect_data = NULL;
@@ -471,8 +475,7 @@ static void yahoo_buddy_icon_upload_conn
return;
}
/* use whole URL if using HTTP Proxy */
- if ((account->proxy_info)
- && (account->proxy_info->type == PURPLE_PROXY_HTTP))
+ if (proxy_info && proxy_info->type == PURPLE_PROXY_HTTP)
use_whole_url = TRUE;
pkt = yahoo_packet_new(YAHOO_SERVICE_PICTURE_UPLOAD, YAHOO_STATUS_AVAILABLE, yd->session_id);
============================================================
--- libpurple/protocols/yahoo/yahoo_profile.c 57223f178af72f25b22307d847c7f73ac4e2f61d
+++ libpurple/protocols/yahoo/yahoo_profile.c 18223106ee3448a7477fd7f064a9e916127bc102
@@ -934,10 +934,11 @@ static void yahoo_got_info(PurpleUtilFet
if (photo_url_text) {
PurpleUtilFetchUrlData *url_data;
gboolean use_whole_url = FALSE;
+ PurpleAccount *account = purple_connection_get_account(info_data->gc);
+ PurpleProxyInfo *proxy_info = purple_account_get_proxy_info(account);
/* use whole URL if using HTTP Proxy */
- if ((purple_connection_get_account(info_data->gc)->proxy_info) &&
- (purple_connection_get_account(info_data->gc)->proxy_info->type == PURPLE_PROXY_HTTP))
+ if (proxy_info && proxy_info->type == PURPLE_PROXY_HTTP)
use_whole_url = TRUE;
/* User-uploaded photos use a different server that requires the Host
============================================================
--- libpurple/savedstatuses.c 5f842ca17975257f3af208f4125d43cb00d34d52
+++ libpurple/savedstatuses.c 3c119529afb54fc41360563834bfb47c6e96a676
@@ -404,7 +404,7 @@ parse_substatus(xmlnode *substatus)
if ((node != NULL) && ((data = xmlnode_get_data(node)) != NULL))
{
ret->type = purple_status_type_find_with_id(
- ret->account->status_types, data);
+ purple_account_get_status_types(ret->account), data);
g_free(data);
}
============================================================
--- pidgin/gtkblist.c 660acf2c183d95d4708cdd88fc446b5a42c9df9c
+++ pidgin/gtkblist.c cfc8ef8ef90e875a8c6b94ae74335eab16f243e3
@@ -1706,7 +1706,7 @@ create_buddy_menu(PurpleBlistNode *node,
if(buddy == b)
continue;
- if(!buddy->account->gc)
+ if(!purple_account_get_connection(buddy->account))
continue;
if(!show_offline && !PURPLE_BUDDY_IS_ONLINE(buddy))
continue;
@@ -1837,7 +1837,7 @@ static gboolean gtk_blist_button_press_c
prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
if (prpl && prpl_info->get_info)
- pidgin_retrieve_user_info(b->account->gc, b->name);
+ pidgin_retrieve_user_info(purple_account_get_connection(b->account), b->name);
handled = TRUE;
}
============================================================
--- pidgin/gtkconv.c 37b83877fa8e23c46912d39af55012df878c5a9d
+++ pidgin/gtkconv.c 837235a34b9dd7005d2da85f38ff3317f8f4eeef
@@ -1756,8 +1756,8 @@ create_chat_menu(PurpleConversation *con
if (buddy != NULL)
{
if (purple_account_is_connected(conv->account))
- pidgin_append_blist_node_proto_menu(menu, conv->account->gc,
- (PurpleBlistNode *)buddy);
+ pidgin_append_blist_node_proto_menu(menu, purple_account_get_connection(conv->account),
+ (PurpleBlistNode *)buddy);
pidgin_append_blist_node_extended_menu(menu, (PurpleBlistNode *)buddy);
gtk_widget_show_all(menu);
}
@@ -3232,7 +3232,8 @@ populate_menu_with_options(GtkWidget *me
}
} else if (node) {
if (purple_account_is_connected(conv->account))
- pidgin_append_blist_node_proto_menu(menu, conv->account->gc, node);
+ pidgin_append_blist_node_proto_menu(menu,
+ purple_account_get_connection(conv->account), node);
pidgin_append_blist_node_extended_menu(menu, node);
}
============================================================
--- pidgin/plugins/xmppconsole.c 3c1364a21e5e4b54af49090bc6de75236e418a74
+++ pidgin/plugins/xmppconsole.c fdff9039551d6b07b82b9ea6216ed09a12e13567
@@ -713,16 +713,18 @@ dropdown_changed_cb(GtkComboBox *widget,
dropdown_changed_cb(GtkComboBox *widget, gpointer nul)
{
PurpleAccount *account;
+ PurpleConnection *conn;
if (!console)
return;
account = purple_accounts_find(gtk_combo_box_get_active_text(GTK_COMBO_BOX(console->dropdown)),
"prpl-jabber");
- if (!account || !account->gc)
+ conn = account ? purple_account_get_connection(account) : NULL;
+ if (!account || !conn)
return;
- console->gc = account->gc;
+ console->gc = conn;
gtk_imhtml_clear(GTK_IMHTML(console->imhtml));
}
More information about the Commits
mailing list