soc.2009.telepathy: d3f70f6f: Documented telepathy_account.*

sttwister at gmail.com sttwister at gmail.com
Mon Dec 21 14:40:43 EST 2009


-----------------------------------------------------------------
Revision: d3f70f6fd290265e3ba003d186d6b9d078ed7514
Ancestor: 6d77f7ea496aeedb05bc5490d96a218d3190bd9b
Author: sttwister at gmail.com
Date: 2009-12-21T19:35:59
Branch: im.pidgin.soc.2009.telepathy
URL: http://d.pidgin.im/viewmtn/revision/info/d3f70f6fd290265e3ba003d186d6b9d078ed7514

Modified files:
        libpurple/protocols/telepathy/telepathy_account.c
        libpurple/protocols/telepathy/telepathy_account.h

ChangeLog: 

Documented telepathy_account.*

-------------- next part --------------
============================================================
--- libpurple/protocols/telepathy/telepathy_account.c	cb385950096d4858ecf220fee3de843924f69140
+++ libpurple/protocols/telepathy/telepathy_account.c	b666bea137d7bfe0ca0c6bc1ff67f8a1566a5af9
@@ -38,7 +38,7 @@ account_properties_changed (PrplTpAccoun
 void
 account_properties_changed (PrplTpAccount *account_data,
                             GHashTable *properties,
-			    gboolean first_time)
+                            gboolean first_time)
 {
 	GHashTableIter iter;
 	gpointer key, val;
@@ -47,6 +47,7 @@ account_properties_changed (PrplTpAccoun
 
 	purple_debug_info("telepathy", "account_properties_changed!\n");
 
+	/* Iterate over all properties */
 	g_hash_table_iter_init (&iter, properties);
 	while (g_hash_table_iter_next (&iter, &key, &val)) 
 	{
@@ -56,6 +57,9 @@ account_properties_changed (PrplTpAccoun
 		{
 			gchar *connection_object = g_value_get_boxed(value);
 
+			/* We have received a new connection object, we should create a new
+			 * connection proxy.
+			 */
 			if (g_strcmp0(connection_object, "/") != 0)
 				got_connection_object(connection_object, account_data);
 		}
@@ -101,11 +105,19 @@ update_parameters_cb (TpAccount *proxy,
 	purple_debug_info("telepathy", "UpdateParameters succeeded!\n");
 }
 
+/**
+ * Return Telepathy parameters from a PurpleAccount.
+ *
+ * @param account    The account to get paramaters from.
+ * @param params     An array of Telepathy parameters to extract from account.
+ * @param out_Params An output hash table mapping paramater names to values.
+ * @param out_Unset  An output array containing unset paramaters.
+ */
 static void
 build_parameters_from_purple_account (PurpleAccount *account,
                                       TpConnectionManagerParam *params,
-				      GHashTable **out_Params,
-				      GPtrArray **out_Unset)
+                                      GHashTable **out_Params,
+                                      GPtrArray **out_Unset)
 {
 	GHashTable *params_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
 			NULL, (GDestroyNotify) tp_g_value_slice_free);
@@ -130,7 +142,7 @@ build_parameters_from_purple_account (Pu
 			tp_asv_set_string(params_hash, "password", account->password);
 
 		/* Account and password are handled in particular */
-		if (g_strcmp0(name, "account") != 0 && g_strcmp0(name, "password"))
+		if (g_strcmp0(name, "account") != 0 && g_strcmp0(name, "password") != 0)
 		{
 			/* Check the type of the parameter and update the hash table,
 			 * or add it to the unset array if it's default
@@ -192,6 +204,12 @@ build_parameters_from_purple_account (Pu
 	*out_Unset = unset;
 }
 
+/**
+ * Save account parameters to the account manager.
+ *
+ * @param account_data The account whose parameters to save.
+ * @param params       An array of parameters to save.
+ */
 static void
 save_account_parameters (PrplTpAccount *account_data,
                          TpConnectionManagerParam *params)
@@ -217,6 +235,12 @@ save_account_parameters (PrplTpAccount *
 	g_hash_table_destroy(params_hash);
 }
 
+/**
+ * Sets an account's paramaters (from Telepathy to libpurple).
+ *
+ * @param account    The account to update.
+ * @param paramaters A hashtable mapping paramater names to values.
+ */
 static void
 set_account_parameters (PurpleAccount *account,
                         GHashTable *parameters)
@@ -273,6 +297,15 @@ set_account_parameters (PurpleAccount *a
 	}
 }
                         
+/**
+ * Callback for getting all DBus properties for an account.
+ *
+ * @param proxy          The object owning the properties (must be a TpAccount).
+ * @param out_Properties A hashtable mapping property names to values.
+ * @param error          Points to a GError in case of failure, NULL otherwise.
+ * @param user_data      Points to a PrplTpAccount struct associated with the
+ *                       account.
+ */
 static void
 get_account_properties_cb (TpProxy *proxy,
                            GHashTable *out_Properties,
@@ -376,6 +409,11 @@ get_account_properties_cb (TpProxy *prox
 		purple_account_connect(account);
 }
 
+/**
+ * Callback for the AccountModified libpurple signal.
+ *
+ * @param account The account that was modified.
+ */
 static void
 purple_account_modified_cb (PurpleAccount *account,
                             gpointer user_data)
@@ -402,7 +440,7 @@ purple_account_modified_cb (PurpleAccoun
 
 	if (plugin == NULL)
 	{
-		purple_debug_info("telepathy", "There's no plugin for modifiying PurpleAccount\n");
+		purple_debug_warning("telepathy", "There's no plugin for modifiying PurpleAccount\n");
 		return;
 	}
 
@@ -412,6 +450,11 @@ purple_account_modified_cb (PurpleAccoun
 	save_account_parameters(account_data, data->protocol->params);
 }
 
+/**
+ * Callback for the AccountDestroying libpurple signal.
+ *
+ * @param account The account that will be destroyed.
+ */
 static void
 purple_account_destroying_cb (PurpleAccount *account,
                               gpointer user_data)
@@ -435,6 +478,12 @@ purple_account_destroying_cb (PurpleAcco
 	}
 }
 
+/**
+ * Callback for the AccountRemoved DBus method.
+ *
+ * @param proxy     The accounts' proxy object.
+ * @param user_data Points to a PrplTpAccount struct associated with the removed account.
+ */
 static void
 account_removed_cb (TpAccount *proxy,
                     gpointer user_data,
@@ -451,6 +500,13 @@ account_removed_cb (TpAccount *proxy,
 		purple_accounts_remove(account_data->account);
 }
 
+/**
+ * Callback for getting all DBus properties for an account.
+ *
+ * @param out_Properties A hash table mapping property names to values.
+ * @param error          Points to a GError in case of failure, NULL otherwise.
+ * @param user_data      Points to a PrplTpAccount struct associated with the account.
+ */
 static void
 account_get_all_cb (TpProxy *proxy,
                     GHashTable *out_Properties,
@@ -475,6 +531,13 @@ account_get_all_cb (TpProxy *proxy,
 
 }
 
+/**
+ * Callback for the PropertyChanged DBus signal for an account.
+ *
+ * @param proxy          The proxy object for the account.
+ * @param arg_Properties A hash table mapping property names to values.
+ * @param user_data      A PrplTpAccount struct associated with the account.
+ */
 static void
 account_property_changed_cb (TpAccount *proxy,
                              GHashTable *arg_Properties,
@@ -503,6 +566,14 @@ account_property_changed_cb (TpAccount *
 	account_properties_changed(account_data, arg_Properties, FALSE);
 }
 
+/**
+ * Callback for the CreateAccount DBus method.
+ *
+ * @param proxy       The account manager proxy object.
+ * @param out_Account The resulting account's object path.
+ * @param error       Points to a GError in case of failure, NULL otherwise.
+ * @param user_data   Points to a PrplTpAccount struct associated with the account.
+ */
 static void
 create_account_cb (TpAccountManager *proxy,
                    const gchar *out_Account,
@@ -536,6 +607,7 @@ create_account_cb (TpAccountManager *pro
 		return;
 	}
 
+	/* Create a proxy object for the new account */
 	tp_account = tp_account_new(daemon, out_Account, &err);
 
 	if (err != NULL)
@@ -557,11 +629,13 @@ create_account_cb (TpAccountManager *pro
 		return;
 	}
 
+	/* Update the account data with the new DBus data */
 	account_data->obj_Path = g_strdup((gchar *)out_Account);
 	account_data->tp_account = tp_account;
 
 	purple_debug_info("telepathy", "Caching account %s\n", out_Account);
 
+	/* Save the account in the global hash table */
 	g_hash_table_insert(accounts_Hash_Table, g_strdup(out_Account), account_data);
 
 	tp_cli_account_connect_to_account_property_changed(tp_account,
@@ -576,12 +650,18 @@ create_account_cb (TpAccountManager *pro
 		return;
 	}
 
+	/* Get all properties for the account in order to sync with libpurple */
 	tp_cli_dbus_properties_call_get_all(tp_account, -1, 
 			TP_IFACE_ACCOUNT,
 			account_get_all_cb, account_data,
 			NULL, NULL);
 }
 
+/**
+ * Callback for the AccountAdded libpurple signal.
+ *
+ * @param account The account that was added.
+ */
 static void
 purple_account_added_cb (PurpleAccount *account,
                          gpointer user_data)
@@ -650,6 +730,9 @@ purple_account_added_cb (PurpleAccount *
 
 }
 
+/**
+ * Callback for the RemoveAccount DBus method.
+ */
 static void
 remove_account_cb (TpAccount *proxy,
                    const GError *error,
@@ -665,6 +748,11 @@ remove_account_cb (TpAccount *proxy,
 	purple_debug_info("telepathy", "Remove succeeded!\n");
 }
 
+/**
+ * Callback for the AccountRemoved libpurple signal.
+ *
+ * @param account The account that was removed.
+ */
 static void
 purple_account_removed_cb (PurpleAccount *account,
                            gpointer user_data)
============================================================
--- libpurple/protocols/telepathy/telepathy_account.h	00f9f1af053564a1cd436a732ca811beaae0832a
+++ libpurple/protocols/telepathy/telepathy_account.h	32e97a91d3513bcbadd49429b8322a01ddcbf799
@@ -45,11 +45,22 @@ typedef struct
 
 } PrplTpAccount;
 
+/**
+ * Updates the properties for an account.
+ *
+ * @param account_data The account to update.
+ * @param properties   A hash table containing new/changed properties.
+ * @param first_time   TRUE if it's the first time the account's property
+ *                     change (for example right after connecting).
+ */
 void
 account_properties_changed (PrplTpAccount *account_data,
                             GHashTable *properties,
                             gboolean first_time);
 
+/**
+ * Callback for the UpdateParamters DBus call.
+ */
 void
 update_parameters_cb (TpAccount *proxy,
                       const gchar **out_Reconnect_Required,
@@ -57,6 +68,14 @@ update_parameters_cb (TpAccount *proxy,
                       gpointer user_data,
                       GObject *weak_object);
 
+/**
+ * Callback for getting "ValidAccounts" property from the account manager.
+ *
+ * @param proxy     The proxy object owning the property (account manager).
+ * @param out_Value Contains an array of strings represening accounts.
+ * @param error     Points to a GError in case of failure, NULL otherwise.
+ * @param user_data Not used.
+ */
 void
 get_valid_accounts_cb (TpProxy *proxy,
                        const GValue *out_Value,


More information about the Commits mailing list