/soc/2013/ankitkv/gobjectification: 99bcdb44c75f: Added boxed ty...

Ankit Vani a at nevitus.org
Mon Jul 15 16:19:18 EDT 2013


Changeset: 99bcdb44c75f655128130aa989b51390983ee322
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-07-16 01:45 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/99bcdb44c75f

Description:

Added boxed types for PurpleStatus and PurpleSavedStatus

diffstat:

 libpurple/plugins/perl/perl-common.c |  16 ++++++++--------
 libpurple/savedstatuses.c            |  23 +++++++++++++++++++++++
 libpurple/savedstatuses.h            |   6 ++++++
 libpurple/status.c                   |  23 +++++++++++++++++++++++
 libpurple/status.h                   |  15 +++++++++++----
 5 files changed, 71 insertions(+), 12 deletions(-)

diffs (154 lines):

diff --git a/libpurple/plugins/perl/perl-common.c b/libpurple/plugins/perl/perl-common.c
--- a/libpurple/plugins/perl/perl-common.c
+++ b/libpurple/plugins/perl/perl-common.c
@@ -427,21 +427,21 @@ purple_perl_sv_from_purple_type(const GT
 		stash = "Purple::BuddyList::Node";
 	else if (type == PURPLE_TYPE_CIPHER)
 		stash = "Purple::Cipher";
-	else if (type == PURPLE_TYPE_STATUS) /* TODO */
+	else if (type == PURPLE_TYPE_STATUS)
 		stash = "Purple::Status";
-	else if (type == PURPLE_TYPE_SAVEDSTATUS) /* TODO */
+	else if (type == PURPLE_TYPE_SAVEDSTATUS)
 		stash = "Purple::SavedStatus";
-	else if (type == PURPLE_TYPE_LOG) /* TODO */
+	else if (type == PURPLE_TYPE_LOG)
 		stash = "Purple::Log";
-	else if (type == PURPLE_TYPE_XFER) /* TODO */
+	else if (type == PURPLE_TYPE_XFER)
 		stash = "Purple::Xfer";
-	else if (type == PURPLE_TYPE_XMLNODE) /* TODO */
+	else if (type == PURPLE_TYPE_XMLNODE)
 		stash = "Purple::XMLNode";
-	else if (type == PURPLE_TYPE_USERINFO) /* TODO */
+	else if (type == PURPLE_TYPE_USERINFO)
  		stash = "Purple::NotifyUserInfo";
-	else if (type == PURPLE_TYPE_STORED_IMAGE) /* TODO */
+	else if (type == PURPLE_TYPE_STORED_IMAGE)
  		stash = "Purple::StoredImage";
-	else if (type == PURPLE_TYPE_CERTIFICATEPOOL) /* TODO */
+	else if (type == PURPLE_TYPE_CERTIFICATEPOOL)
  		stash = "Purple::Certificate::Pool";
 
 	return sv_2mortal(purple_perl_bless_object(arg, stash));
diff --git a/libpurple/savedstatuses.c b/libpurple/savedstatuses.c
--- a/libpurple/savedstatuses.c
+++ b/libpurple/savedstatuses.c
@@ -1172,6 +1172,29 @@ purple_savedstatus_activate_for_account(
 	}
 }
 
+static PurpleSavedStatus *
+purple_savedstatus_copy(PurpleSavedStatus *savedstatus)
+{
+	PurpleSavedStatus *savedstatus_copy = g_new(PurpleSavedStatus, 1);
+	*savedstatus_copy = *savedstatus;
+
+	return savedstatus_copy;
+}
+
+GType
+purple_savedstatus_get_type(void)
+{
+	static GType type = 0;
+
+	if (type == 0) {
+		type = g_boxed_type_register_static("PurpleSavedStatus",
+				(GBoxedCopyFunc)purple_savedstatus_copy,
+				(GBoxedFreeFunc)g_free);
+	}
+
+	return type;
+}
+
 void *
 purple_savedstatuses_get_handle(void)
 {
diff --git a/libpurple/savedstatuses.h b/libpurple/savedstatuses.h
--- a/libpurple/savedstatuses.h
+++ b/libpurple/savedstatuses.h
@@ -54,6 +54,7 @@
  *       something we should look into once the status box gets fleshed
  *       out more.
  */
+#define PURPLE_TYPE_SAVEDSTATUS  (purple_savedstatus_get_type())
 
 typedef struct _PurpleSavedStatus     PurpleSavedStatus;
 typedef struct _PurpleSavedStatusSub  PurpleSavedStatusSub;
@@ -68,6 +69,11 @@ G_BEGIN_DECLS
 /*@{*/
 
 /**
+ * Returns the GType for the PurpleSavedStatus boxed structure.
+ */
+GType purple_savedstatus_get_type(void);
+
+/**
  * Create a new saved status.  This will add the saved status to the
  * list of saved statuses and writes the revised list to status.xml.
  *
diff --git a/libpurple/status.c b/libpurple/status.c
--- a/libpurple/status.c
+++ b/libpurple/status.c
@@ -1054,6 +1054,29 @@ purple_status_compare(const PurpleStatus
 	return 0;
 }
 
+static PurpleStatus *
+purple_status_copy(PurpleStatus *status)
+{
+	PurpleStatus *status_copy = g_new(PurpleStatus, 1);
+	*status_copy = *status;
+
+	return status_copy;
+}
+
+GType
+purple_status_get_type(void)
+{
+	static GType type = 0;
+
+	if (type == 0) {
+		type = g_boxed_type_register_static("PurpleStatus",
+				(GBoxedCopyFunc)purple_status_copy,
+				(GBoxedFreeFunc)g_free);
+	}
+
+	return type;
+}
+
 
 /**************************************************************************
 * PurplePresence API
diff --git a/libpurple/status.h b/libpurple/status.h
--- a/libpurple/status.h
+++ b/libpurple/status.h
@@ -82,10 +82,12 @@
  * hardcoded in each PRPL and will not change often.  And because
  * they are hardcoded, they do not need to be saved to any XML file.
  */
-typedef struct _PurpleStatusType      PurpleStatusType;
-typedef struct _PurpleStatusAttr      PurpleStatusAttr;
-typedef struct _PurplePresence        PurplePresence;
-typedef struct _PurpleStatus          PurpleStatus;
+#define PURPLE_TYPE_STATUS      (purple_status_get_type())
+typedef struct _PurpleStatus    PurpleStatus;
+
+typedef struct _PurplePresence    PurplePresence;
+typedef struct _PurpleStatusType  PurpleStatusType;
+typedef struct _PurpleStatusAttr  PurpleStatusAttr;
 
 typedef struct _PurpleMood {
 	const char *mood;
@@ -442,6 +444,11 @@ GValue *purple_status_attr_get_value(con
 /*@{*/
 
 /**
+ * Returns the GType for the PurpleStatus boxed structure.
+ */
+GType purple_status_get_type(void);
+
+/**
  * Creates a new status.
  *
  * @param status_type The type of status.



More information about the Commits mailing list