/soc/2013/ankitkv/gobjectification: bb716fcd7bb0: Merged soc.201...

Ankit Vani a at nevitus.org
Thu Dec 5 14:07:47 EST 2013


Changeset: bb716fcd7bb0cd39848e78d955f8bc127ebe585a
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-12-06 00:37 +0530
Branch:	 soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/bb716fcd7bb0

Description:

Merged soc.2013.gobjectification branch

diffstat:

 libpurple/account.c        |   3 --
 libpurple/accounts.c       |   3 --
 libpurple/blistnodetypes.c |  59 +++++++++++++++++++++++++++++++++------------
 libpurple/buddylist.c      |   2 -
 libpurple/internal.h       |  27 +++++++++++++++++++++
 libpurple/presence.c       |   4 +--
 libpurple/status.c         |   4 +--
 7 files changed, 72 insertions(+), 30 deletions(-)

diffs (271 lines):

diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -138,9 +138,6 @@ static GObjectClass  *parent_class = NUL
 static GParamSpec    *properties[PROP_LAST];
 static GList         *handles = NULL;
 
-void _purple_account_set_current_error(PurpleAccount *account,
-		PurpleConnectionErrorInfo *new_err);
-
 /***************
  * Account API *
  ***************/
diff --git a/libpurple/accounts.c b/libpurple/accounts.c
--- a/libpurple/accounts.c
+++ b/libpurple/accounts.c
@@ -38,9 +38,6 @@ static GList   *accounts = NULL;
 static guint    save_timer = 0;
 static gboolean accounts_loaded = FALSE;
 
-void _purple_account_set_current_error(PurpleAccount *account,
-		PurpleConnectionErrorInfo *new_err);
-
 /*********************************************************************
  * Writing to disk                                                   *
  *********************************************************************/
diff --git a/libpurple/blistnodetypes.c b/libpurple/blistnodetypes.c
--- a/libpurple/blistnodetypes.c
+++ b/libpurple/blistnodetypes.c
@@ -64,6 +64,9 @@ struct _PurpleBuddyPrivate {
 	PurpleAccount *account;      /**< the account this buddy belongs to       */
 	PurplePresence *presence;    /**< Presense information of the buddy       */
 	PurpleMediaCaps media_caps;  /**< The media capabilities of the buddy.    */
+
+	gboolean is_constructed;     /**< Indicates if the buddy has finished
+	                                  being constructed.                      */
 };
 
 /* Buddy property enums */
@@ -98,7 +101,9 @@ enum
 
 /** Private data for a group */
 struct _PurpleGroupPrivate {
-	char *name;  /**< The name of this group. */
+	char *name;               /**< The name of this group.                    */
+	gboolean is_constructed;  /**< Indicates if the group has finished being
+	                               constructed.                               */
 };
 
 /* Group property enums */
@@ -111,10 +116,13 @@ enum
 
 /** Private data for a chat node */
 struct _PurpleChatPrivate {
-	char *alias;             /**< The display name of this chat.              */
-	PurpleAccount *account;  /**< The account this chat is attached to        */
-	GHashTable *components;  /**< the stuff the protocol needs to know to join
-	                              the chat                                    */
+	char *alias;              /**< The display name of this chat.             */
+	PurpleAccount *account;   /**< The account this chat is attached to       */
+	GHashTable *components;   /**< the stuff the protocol needs to know to
+	                               join the chat                              */
+
+	gboolean is_constructed;  /**< Indicates if the chat has finished being
+	                               constructed.                               */
 };
 
 /* Chat property enums */
@@ -142,8 +150,6 @@ purple_strings_are_different(const char 
 			((one == NULL || *one == '\0') && (two == NULL || *two == '\0')));
 }
 
-PurpleBlistNode *_purple_blist_get_last_child(PurpleBlistNode *node);
-
 /**************************************************************************/
 /* Buddy API                                                              */
 /**************************************************************************/
@@ -548,12 +554,18 @@ purple_buddy_set_property(GObject *obj, 
 
 	switch (param_id) {
 		case BUDDY_PROP_NAME:
-			g_free(priv->name);
-			priv->name = purple_utf8_strip_unprintables(g_value_get_string(value));
+			if (priv->is_constructed)
+				purple_buddy_set_name(buddy, g_value_get_string(value));
+			else
+				priv->name =
+					purple_utf8_strip_unprintables(g_value_get_string(value));
 			break;
 		case BUDDY_PROP_LOCAL_ALIAS:
-			g_free(priv->local_alias);
-			priv->local_alias = purple_utf8_strip_unprintables(g_value_get_string(value));
+			if (priv->is_constructed)
+				purple_buddy_set_local_alias(buddy, g_value_get_string(value));
+			else
+				priv->local_alias =
+					purple_utf8_strip_unprintables(g_value_get_string(value));
 			break;
 		case BUDDY_PROP_SERVER_ALIAS:
 			purple_buddy_set_server_alias(buddy, g_value_get_string(value));
@@ -630,6 +642,8 @@ purple_buddy_constructed(GObject *object
 
 	if (ops && ops->new_node)
 		ops->new_node((PurpleBlistNode *)buddy);
+
+	priv->is_constructed = TRUE;
 }
 
 /* GObject dispose function */
@@ -1222,8 +1236,11 @@ purple_chat_set_property(GObject *obj, g
 
 	switch (param_id) {
 		case CHAT_PROP_ALIAS:
-			g_free(priv->alias);
-			priv->alias = purple_utf8_strip_unprintables(g_value_get_string(value));
+			if (priv->is_constructed)
+				purple_chat_set_alias(chat, g_value_get_string(value));
+			else
+				priv->alias =
+					purple_utf8_strip_unprintables(g_value_get_string(value));
 			break;
 		case CHAT_PROP_ACCOUNT:
 			priv->account = g_value_get_object(value);
@@ -1273,12 +1290,15 @@ static void
 purple_chat_constructed(GObject *object)
 {
 	PurpleChat *chat = PURPLE_CHAT(object);
+	PurpleChatPrivate *priv = PURPLE_CHAT_GET_PRIVATE(chat);
 	PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
 
 	G_OBJECT_CLASS(blistnode_parent_class)->constructed(object);
 
 	if (ops != NULL && ops->new_node != NULL)
 		ops->new_node(PURPLE_BLIST_NODE(chat));
+
+	priv->is_constructed = TRUE;
 }
 
 /* GObject finalize function */
@@ -1573,12 +1593,16 @@ static void
 purple_group_set_property(GObject *obj, guint param_id, const GValue *value,
 		GParamSpec *pspec)
 {
-	PurpleGroupPrivate *priv = PURPLE_GROUP_GET_PRIVATE(obj);
+	PurpleGroup *group = PURPLE_GROUP(obj);
+	PurpleGroupPrivate *priv = PURPLE_GROUP_GET_PRIVATE(group);
 
 	switch (param_id) {
 		case GROUP_PROP_NAME:
-			g_free(priv->name);
-			priv->name = purple_utf8_strip_unprintables(g_value_get_string(value));
+			if (priv->is_constructed)
+				purple_group_set_name(group, g_value_get_string(value));
+			else
+				priv->name =
+					purple_utf8_strip_unprintables(g_value_get_string(value));
 			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
@@ -1615,12 +1639,15 @@ static void
 purple_group_constructed(GObject *object)
 {
 	PurpleGroup *group = PURPLE_GROUP(object);
+	PurpleGroupPrivate *priv = PURPLE_GROUP_GET_PRIVATE(group);
 	PurpleBlistUiOps *ops = purple_blist_get_ui_ops();
 
 	G_OBJECT_CLASS(counting_parent_class)->constructed(object);
 
 	if (ops && ops->new_node)
 		ops->new_node(PURPLE_BLIST_NODE(group));
+
+	priv->is_constructed = TRUE;
 }
 
 /* GObject finalize function */
diff --git a/libpurple/buddylist.c b/libpurple/buddylist.c
--- a/libpurple/buddylist.c
+++ b/libpurple/buddylist.c
@@ -64,8 +64,6 @@ static GHashTable *groups_cache = NULL;
 static guint          save_timer = 0;
 static gboolean       blist_loaded = FALSE;
 
-PurpleBlistNode *_purple_blist_get_last_child(PurpleBlistNode *node);
-
 /*********************************************************************
  * Private utility functions                                         *
  *********************************************************************/
diff --git a/libpurple/internal.h b/libpurple/internal.h
--- a/libpurple/internal.h
+++ b/libpurple/internal.h
@@ -157,6 +157,25 @@
 #include "accounts.h"
 #include "connection.h"
 
+/**
+ * Sets an error for an account.
+ *
+ * @param account  The account to set the error for.
+ * @param new_err  The #PurpleConnectionErrorInfo instance representing the
+ *                 error.
+ */
+void _purple_account_set_current_error(PurpleAccount *account,
+                                       PurpleConnectionErrorInfo *new_err);
+
+/**
+ * Returns the last child of a particular node.
+ *
+ * @param node  The node whose last child is to be retrieved.
+ *
+ * @return The last child of the node.
+ */
+PurpleBlistNode *_purple_blist_get_last_child(PurpleBlistNode *node);
+
 /* This is for the accounts code to notify the buddy icon code that
  * it's done loading.  We may want to replace this with a signal. */
 void
@@ -233,4 +252,12 @@ void _purple_connection_add_active_chat(
 void _purple_connection_remove_active_chat(PurpleConnection *gc,
                                            PurpleChatConversation *chat);
 
+/**
+ * Returns the primitive scores array from status.c.
+ *
+ * @note This function should only be called by
+ *       purple_buddy_presence_compute_score() in presence.c.
+ */
+int *_purple_statuses_get_primitive_scores(void);
+
 #endif /* _PURPLE_INTERNAL_H_ */
diff --git a/libpurple/presence.c b/libpurple/presence.c
--- a/libpurple/presence.c
+++ b/libpurple/presence.c
@@ -102,8 +102,6 @@ static GParamSpec *properties[PRES_PROP_
 static GParamSpec *ap_properties[ACPRES_PROP_LAST];
 static GParamSpec *bp_properties[BUDPRES_PROP_LAST];
 
-int *_purple_get_primitive_scores(void);
-
 /**************************************************************************
 * PurplePresence API
 **************************************************************************/
@@ -615,7 +613,7 @@ purple_buddy_presence_compute_score(cons
 	int score = 0;
 	PurplePresence *presence = PURPLE_PRESENCE(buddy_presence);
 	PurpleBuddy *b = purple_buddy_presence_get_buddy(buddy_presence);
-	int *primitive_scores = _purple_get_primitive_scores();
+	int *primitive_scores = _purple_statuses_get_primitive_scores();
 	int offline_score = purple_prefs_get_int("/purple/status/scores/offline_msg");
 	int idle_score = purple_prefs_get_int("/purple/status/scores/idle");
 
diff --git a/libpurple/status.c b/libpurple/status.c
--- a/libpurple/status.c
+++ b/libpurple/status.c
@@ -121,8 +121,6 @@ static int primitive_scores[] =
 #define SCORE_IDLE_TIME 10
 #define SCORE_OFFLINE_MESSAGE 11
 
-int *_purple_get_primitive_scores(void);
-
 /**************************************************************************
  * PurpleStatusPrimitive API
  **************************************************************************/
@@ -147,7 +145,7 @@ static struct PurpleStatusPrimitiveMap
 };
 
 int *
-_purple_get_primitive_scores(void)
+_purple_statuses_get_primitive_scores(void)
 {
 	return primitive_scores;
 }



More information about the Commits mailing list