/soc/2013/ankitkv/gobjectification: 5eed877cb061: Moved ui_data ...

Ankit Vani a at nevitus.org
Sun Jun 30 06:24:11 EDT 2013


Changeset: 5eed877cb061b0dd188c5b29f4245fcf96e78ed3
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-30 15:53 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/5eed877cb061

Description:

Moved ui_data to the object structure, and added back [gs]et_ui_data() methods

diffstat:

 libpurple/account.c                           |  16 ++++++++++++++++
 libpurple/account.h                           |  24 ++++++++++++++++++++++++
 libpurple/conversation.c                      |  15 ++++-----------
 libpurple/conversation.h                      |   5 +++++
 libpurple/conversationtypes.c                 |  15 ++++-----------
 libpurple/conversationtypes.h                 |   5 +++++
 libpurple/plugins/perl/common/Conversation.xs |   5 -----
 7 files changed, 58 insertions(+), 27 deletions(-)

diffs (203 lines):

diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -2157,6 +2157,22 @@ purple_account_get_ui_bool(const PurpleA
 	return g_value_get_boolean(&setting->value);
 }
 
+gpointer
+purple_account_get_ui_data(const PurpleAccount *account)
+{
+	g_return_val_if_fail(account != NULL, NULL);
+
+	return account->ui_data;
+}
+
+void
+purple_account_set_ui_data(PurpleAccount *account, gpointer ui_data)
+{
+	g_return_if_fail(account != NULL);
+
+	account->ui_data = ui_data;
+}
+
 PurpleLog *
 purple_account_get_log(PurpleAccount *account, gboolean create)
 {
diff --git a/libpurple/account.h b/libpurple/account.h
--- a/libpurple/account.h
+++ b/libpurple/account.h
@@ -97,6 +97,11 @@ struct _PurpleAccount
 	/*< private >*/
 	GObject gparent;
 
+	/** The UI data associated with this account. This is a convenience
+	 *  field provided to the UIs -- it is not used by the libpurple core.
+	 */
+	gpointer ui_data;
+
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
 	void (*_purple_reserved3)(void);
@@ -572,6 +577,25 @@ void purple_account_set_ui_bool(PurpleAc
 							  const char *name, gboolean value);
 
 /**
+ * Set the UI data associated with this account.
+ *
+ * @param account The account.
+ * @param ui_data A pointer to associate with this object.
+ */
+void purple_account_set_ui_data(PurpleAccount *account, gpointer ui_data);
+
+/**
+ * Returns the UI data associated with this account.
+ *
+ * @param account The account.
+ *
+ * @return The UI data associated with this account.  This is a
+ *         convenience field provided to the UIs--it is not
+ *         used by the libuprple core.
+ */
+gpointer purple_account_get_ui_data(const PurpleAccount *account);
+
+/**
  * Returns whether or not the account is connected.
  *
  * @param account The account.
diff --git a/libpurple/conversation.c b/libpurple/conversation.c
--- a/libpurple/conversation.c
+++ b/libpurple/conversation.c
@@ -57,7 +57,6 @@ struct _PurpleConversationPrivate
 	GList *logs;                      /**< This conversation's logs          */
 
 	PurpleConversationUiOps *ui_ops;  /**< UI-specific operations.           */
-	void *ui_data;                    /**< UI-specific data.                 */
 
 	PurpleConnectionFlags features;   /**< The supported features            */
 	GList *message_history;           /**< Message history, as a GList of
@@ -309,7 +308,6 @@ purple_conversation_set_ui_ops(PurpleCon
 	if (priv->ui_ops != NULL && priv->ui_ops->destroy_conversation != NULL)
 		priv->ui_ops->destroy_conversation(conv);
 
-	priv->ui_data = NULL;
 	priv->ui_ops = ops;
 }
 
@@ -863,20 +861,16 @@ purple_conversation_message_get_type(voi
 
 void purple_conversation_set_ui_data(PurpleConversation *conv, gpointer ui_data)
 {
-	PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
+	g_return_if_fail(conv != NULL);
 
-	g_return_if_fail(priv != NULL);
-
-	priv->ui_data = ui_data;
+	conv->ui_data = ui_data;
 }
 
 gpointer purple_conversation_get_ui_data(const PurpleConversation *conv)
 {
-	PurpleConversationPrivate *priv = PURPLE_CONVERSATION_GET_PRIVATE(conv);
+	g_return_val_if_fail(conv != NULL, NULL);
 
-	g_return_val_if_fail(priv != NULL, NULL);
-
-	return priv->ui_data;
+	return conv->ui_data;
 }
 
 gboolean
@@ -1013,7 +1007,6 @@ purple_conversation_finalize(GObject *ob
 
 	if (ops != NULL && ops->destroy_conversation != NULL)
 		ops->destroy_conversation(conv);
-	priv->ui_data = NULL;
 
 	parent_class->finalize(object);
 }
diff --git a/libpurple/conversation.h b/libpurple/conversation.h
--- a/libpurple/conversation.h
+++ b/libpurple/conversation.h
@@ -119,6 +119,11 @@ struct _PurpleConversation
 	/*< private >*/
 	GObject gparent;
 
+	/** The UI data associated with this conversation. This is a convenience
+	 *  field provided to the UIs -- it is not used by the libpurple core.
+	 */
+	gpointer ui_data;
+
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
 	void (*_purple_reserved3)(void);
diff --git a/libpurple/conversationtypes.c b/libpurple/conversationtypes.c
--- a/libpurple/conversationtypes.c
+++ b/libpurple/conversationtypes.c
@@ -111,7 +111,6 @@ struct _PurpleChatUserPrivate
 	PurpleChatUserFlags flags;     /**< A bitwise OR of flags for this
 	                                    participant, such as whether they
 	                                    are a channel operator.               */
-	gpointer ui_data;              /**< UI can put whatever it wants here.    */
 };
 
 /* Chat User Property enums */
@@ -1752,23 +1751,17 @@ purple_chat_user_get_flags(const PurpleC
 void
 purple_chat_user_set_ui_data(PurpleChatUser *cb, gpointer ui_data)
 {
-	PurpleChatUserPrivate *priv;
-	priv = PURPLE_CHAT_USER_GET_PRIVATE(cb);
+	g_return_if_fail(cb != NULL);
 
-	g_return_if_fail(priv != NULL);
-
-	priv->ui_data = ui_data;
+	cb->ui_data = ui_data;
 }
 
 gpointer
 purple_chat_user_get_ui_data(const PurpleChatUser *cb)
 {
-	PurpleChatUserPrivate *priv;
-	priv = PURPLE_CHAT_USER_GET_PRIVATE(cb);
+	g_return_val_if_fail(cb != NULL, NULL);
 
-	g_return_val_if_fail(priv != NULL, NULL);
-
-	return priv->ui_data;
+	return cb->ui_data;
 }
 
 void
diff --git a/libpurple/conversationtypes.h b/libpurple/conversationtypes.h
--- a/libpurple/conversationtypes.h
+++ b/libpurple/conversationtypes.h
@@ -155,6 +155,11 @@ struct _PurpleChatUser
 	/*< private >*/
 	GObject gparent;
 
+	/** The UI data associated with this chat user. This is a convenience
+	 *  field provided to the UIs -- it is not used by the libpurple core.
+	 */
+	gpointer ui_data;
+
 	void (*_purple_reserved1)(void);
 	void (*_purple_reserved2)(void);
 	void (*_purple_reserved3)(void);
diff --git a/libpurple/plugins/perl/common/Conversation.xs b/libpurple/plugins/perl/common/Conversation.xs
--- a/libpurple/plugins/perl/common/Conversation.xs
+++ b/libpurple/plugins/perl/common/Conversation.xs
@@ -188,11 +188,6 @@ gboolean
 purple_conversation_is_logging(conv)
 	Purple::Conversation conv
 
-gpointer
-purple_conversation_get_data(conv, key)
-	Purple::Conversation conv
-	const char * key
-
 Purple::ConnectionFlags
 purple_conversation_get_features(conv)
 	Purple::Conversation conv



More information about the Commits mailing list