/soc/2013/ankitkv/gobjectification: 727f35cfde65: Added a boxed ...

Ankit Vani a at nevitus.org
Wed Jul 17 17:34:43 EDT 2013


Changeset: 727f35cfde6515d64aef4f184a55dba53c2e26bc
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-18 03:04 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/727f35cfde65

Description:

Added a boxed type for PurpleKeyring. Refactored keyring to use GType instead of PurpleValue.

diffstat:

 libpurple/keyring.c |  55 ++++++++++++++++++++++++++++++++++++----------------
 libpurple/keyring.h |   7 ++++++
 2 files changed, 45 insertions(+), 17 deletions(-)

diffs (107 lines):

diff --git a/libpurple/keyring.c b/libpurple/keyring.c
--- a/libpurple/keyring.c
+++ b/libpurple/keyring.c
@@ -1244,12 +1244,9 @@ purple_keyring_init(void)
 	 * @param keyring_id The keyring ID.
 	 * @param keyring    The keyring.
 	 */
-	purple_signal_register(purple_keyring_get_handle(),
-		"keyring-register",
-		purple_marshal_VOID__POINTER_POINTER,
-		NULL, 2,
-		purple_value_new(PURPLE_TYPE_STRING),
-		purple_value_new(PURPLE_TYPE_BOXED, "PurpleKeyring *"));
+	purple_signal_register(purple_keyring_get_handle(), "keyring-register",
+		purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2, G_TYPE_STRING,
+		PURPLE_TYPE_KEYRING);
 
 	/* void keyring_unregister(const char *keyring_id,
 	 *      PurpleKeyring * keyring);
@@ -1259,12 +1256,9 @@ purple_keyring_init(void)
 	 * @param keyring_id The keyring ID.
 	 * @param keyring    The keyring.
 	 */
-	purple_signal_register(purple_keyring_get_handle(),
-		"keyring-unregister",
-		purple_marshal_VOID__POINTER_POINTER,
-		NULL, 2,
-		purple_value_new(PURPLE_TYPE_STRING),
-		purple_value_new(PURPLE_TYPE_BOXED, "PurpleKeyring *"));
+	purple_signal_register(purple_keyring_get_handle(), "keyring-unregister",
+		purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2, G_TYPE_STRING,
+		PURPLE_TYPE_KEYRING);
 
 	/* void password_migration(PurpleAccount* account);
 	 *
@@ -1273,11 +1267,8 @@ purple_keyring_init(void)
 	 *
 	 * @param account The account.
 	 */
-	purple_signal_register(purple_keyring_get_handle(),
-		"password-migration",
-		purple_marshal_VOID__POINTER,
-		NULL, 1,
-		purple_value_new(PURPLE_TYPE_BOXED, "PurpleAccount *"));
+	purple_signal_register(purple_keyring_get_handle(), "password-migration",
+		purple_marshal_VOID__POINTER, G_TYPE_NONE, 1, PURPLE_TYPE_ACCOUNT);
 
 	touse = purple_prefs_get_string("/purple/keyring/active");
 	if (touse == NULL) {
@@ -1355,3 +1346,33 @@ purple_keyring_get_handle(void)
 
 	return &handle;
 }
+
+static PurpleKeyring *
+purple_keyring_copy(PurpleKeyring *keyring)
+{
+	PurpleKeyring *keyring_copy;
+
+	g_return_val_if_fail(keyring != NULL, NULL);
+
+	keyring_copy = purple_keyring_new();
+	*keyring_copy = *keyring;
+
+	keyring_copy->name = g_strdup(keyring->name);
+	keyring_copy->id   = g_strdup(keyring->id);
+
+	return keyring_copy;
+}
+
+GType
+purple_keyring_get_type(void)
+{
+	static GType type = 0;
+
+	if (type == 0) {
+		type = g_boxed_type_register_static("PurpleKeyring",
+				(GBoxedCopyFunc)purple_keyring_copy,
+				(GBoxedFreeFunc)purple_keyring_free);
+	}
+
+	return type;
+}
diff --git a/libpurple/keyring.h b/libpurple/keyring.h
--- a/libpurple/keyring.h
+++ b/libpurple/keyring.h
@@ -30,6 +30,8 @@
 #include "account.h"
 #include "request.h"
 
+#define PURPLE_TYPE_KEYRING  (purple_keyring_get_type())
+
 /**
  * Default keyring ID.
  */
@@ -358,6 +360,11 @@ purple_keyring_apply_settings(void *noti
 /*@{*/
 
 /**
+ * Returns the GType for the PurpleKeyring boxed structure.
+ */
+GType purple_keyring_get_type(void);
+
+/**
  * Creates a new keyring wrapper.
  */
 PurpleKeyring *



More information about the Commits mailing list