soc.2009.telepathy: 3448d090: Store and update Account properties
sttwister at soc.pidgin.im
sttwister at soc.pidgin.im
Wed Jul 22 20:00:47 EDT 2009
-----------------------------------------------------------------
Revision: 3448d090f42db1744353a177f79f698b86e2874d
Ancestor: 069d7166a82c2c0707ac394ee3f4429db7b78dfb
Author: sttwister at soc.pidgin.im
Date: 2009-07-22T23:55:53
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/3448d090f42db1744353a177f79f698b86e2874d
Modified files:
libpurple/protocols/telepathy/telepathy_account.c
libpurple/protocols/telepathy/telepathy_account.h
ChangeLog:
Store and update Account properties
-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy_account.c 0ab26f7acd71957ad4edfbcde3d590b1d9412ec4
+++ libpurple/protocols/telepathy/telepathy_account.c 2e7e18119b7a697e152b81044a94cb71f2d10f2e
@@ -303,6 +303,9 @@ get_account_properties_cb (TpProxy *prox
purple_accounts_add(account);
+ tp_g_hash_table_update(account_data->properties, out_Properties,
+ (GBoxedCopyFunc)g_strdup, (GBoxedCopyFunc)tp_g_value_slice_dup);
+
/* Sync the parameters with PurpleAccount's parameters */
set_account_parameters(account, parameters);
}
@@ -360,6 +363,7 @@ purple_account_destroying_cb (PurpleAcco
g_free(account_data->obj_Path);
g_free(account_data->cm);
g_free(account_data->protocol);
+ g_hash_table_destroy(account_data->properties);
g_free(account_data);
}
@@ -380,6 +384,50 @@ static void
}
static void
+account_get_all_cb (TpProxy *proxy,
+ GHashTable *out_Properties,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ telepathy_account *account_data = user_data;
+
+ if (error != NULL)
+ {
+ purple_debug_error("telepathy", "GetAll error: %s\n", error->message);
+ return;
+ }
+
+ tp_g_hash_table_update(account_data->properties, out_Properties,
+ (GBoxedCopyFunc)g_strdup, (GBoxedCopyFunc)tp_g_value_slice_dup);
+
+}
+
+static void
+account_property_changed_cb (TpAccount *proxy,
+ GHashTable *arg_Properties,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ telepathy_account *account_data = user_data;
+
+ GHashTableIter iter;
+ gpointer key, value;
+
+ purple_debug_info("telepathy", "Properties changed for account %s\n",
+ purple_account_get_username(account_data->account));
+
+ g_hash_table_iter_init (&iter, arg_Properties);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ purple_debug_info("telepathy", " %s\n", (gchar *)key);
+ }
+
+ tp_g_hash_table_update(account_data->properties, arg_Properties,
+ (GBoxedCopyFunc)g_strdup, (GBoxedCopyFunc)tp_g_value_slice_dup);
+}
+
+static void
create_account_cb (TpAccountManager *proxy,
const gchar *out_Account,
const GError *error,
@@ -430,6 +478,24 @@ create_account_cb (TpAccountManager *pro
account_data->obj_Path = g_strdup((gchar *)out_Account);
account_data->tp_account = tp_account;
+
+
+ tp_cli_account_connect_to_account_property_changed(tp_account,
+ account_property_changed_cb, account_data,
+ NULL, NULL, &err);
+
+ if (err != NULL)
+ {
+ purple_debug_error("telepathy", "Error connecting to"
+ " AccountPropertyChanged: %s\n", err->message);
+ g_error_free(err);
+ err = NULL;
+ }
+
+ tp_cli_dbus_properties_call_get_all(tp_account, -1,
+ TP_IFACE_ACCOUNT,
+ account_get_all_cb, account_data,
+ NULL, NULL);
}
static void
@@ -483,6 +549,8 @@ purple_account_added_cb (PurpleAccount *
account_data->account = account;
account_data->cm = g_strdup((gchar *)tp_connection_manager_get_name(data->cm));
account_data->protocol = g_strdup(data->protocol->name);
+ account_data->properties = g_hash_table_new_full (g_str_hash, g_str_equal,
+ NULL, (GDestroyNotify) tp_g_value_slice_free);
purple_account_set_int(account, "tp_account_data", (int)account_data);
@@ -594,8 +662,22 @@ get_valid_accounts_cb (TpProxy *proxy,
account_data->tp_account = account;
account_data->obj_Path = g_strdup(obj_Path);
+ account_data->properties = g_hash_table_new_full (g_str_hash, g_str_equal,
+ NULL, (GDestroyNotify) tp_g_value_slice_free);
/* Get all properties and sync the accounts with libpurple */
+ tp_cli_account_connect_to_account_property_changed(account,
+ account_property_changed_cb, account_data,
+ NULL, NULL, &err);
+
+ if (err != NULL)
+ {
+ purple_debug_error("telepathy", "Error connecting to"
+ " AccountPropertyChanged: %s\n", err->message);
+ g_error_free(err);
+ err = NULL;
+ }
+
tp_cli_dbus_properties_call_get_all(account, -1, TP_IFACE_ACCOUNT,
get_account_properties_cb, account_data, NULL, NULL);
============================================================
--- libpurple/protocols/telepathy/telepathy_account.h a9cc8e064616b8ae66d7ce9a1391495aca0fe82a
+++ libpurple/protocols/telepathy/telepathy_account.h 410ad9d3c0ca1c18cf59c399b49afb98ec9a5da4
@@ -33,6 +33,8 @@ typedef struct
gchar *obj_Path;
gchar *cm, *protocol;
+ GHashTable *properties;
+
} telepathy_account;
void
More information about the Commits
mailing list