/soc/2013/ankitkv/gobjectification: 09228ea79272: Added GBoxed t...
Ankit Vani
a at nevitus.org
Tue Jul 16 10:54:02 EDT 2013
Changeset: 09228ea79272101f6b5935b0afe16903a3e65e78
Author: Ankit Vani <a at nevitus.org>
Date: 2013-07-16 20:23 +0530
Branch: soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/09228ea79272
Description:
Added GBoxed to certificate, certificate pool, xfer, log
diffstat:
libpurple/certificate.c | 41 +++++++++++++++++++++++++++++++++++++++++
libpurple/certificate.h | 18 ++++++++++++++++++
libpurple/ft.c | 27 +++++++++++++++++++++++++++
libpurple/ft.h | 9 +++++++++
libpurple/log.c | 27 +++++++++++++++++++++++++++
libpurple/log.h | 8 ++++++++
6 files changed, 130 insertions(+), 0 deletions(-)
diffs (227 lines):
diff --git a/libpurple/certificate.c b/libpurple/certificate.c
--- a/libpurple/certificate.c
+++ b/libpurple/certificate.c
@@ -511,6 +511,20 @@ purple_certificate_get_display_string(Pu
return str;
}
+GType
+purple_certificate_get_type(void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ type = g_boxed_type_register_static("PurpleCertificate",
+ (GBoxedCopyFunc)purple_certificate_copy,
+ (GBoxedFreeFunc)purple_certificate_destroy);
+ }
+
+ return type;
+}
+
gchar *
purple_certificate_pool_mkpath(PurpleCertificatePool *pool, const gchar *id)
{
@@ -650,6 +664,33 @@ purple_certificate_pool_destroy_idlist(G
g_list_free(idlist);
}
+static PurpleCertificatePool *
+purple_certificate_pool_copy(PurpleCertificatePool *certificate_pool)
+{
+ PurpleCertificatePool *certificate_pool_copy;
+
+ g_return_val_if_fail(certificate_pool != NULL, NULL);
+
+ certificate_pool_copy = g_new(PurpleCertificatePool, 1);
+ *certificate_pool_copy = *certificate_pool;
+
+ return certificate_pool_copy;
+}
+
+GType
+purple_certificate_pool_get_type(void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ type = g_boxed_type_register_static("PurpleCertificatePool",
+ (GBoxedCopyFunc)purple_certificate_pool_copy,
+ (GBoxedFreeFunc)g_free);
+ }
+
+ return type;
+}
+
/****************************************************************************/
/* Builtin Verifiers, Pools, etc. */
diff --git a/libpurple/certificate.h b/libpurple/certificate.h
--- a/libpurple/certificate.h
+++ b/libpurple/certificate.h
@@ -81,8 +81,12 @@ typedef enum
PURPLE_CERTIFICATE_LAST = 0x80000,
} PurpleCertificateVerificationStatus;
+#define PURPLE_TYPE_CERTIFICATE (purple_certificate_get_type())
typedef struct _PurpleCertificate PurpleCertificate;
+
+#define PURPLE_TYPE_CERTIFICATE_POOL (purple_certificate_pool_get_type())
typedef struct _PurpleCertificatePool PurpleCertificatePool;
+
typedef struct _PurpleCertificateScheme PurpleCertificateScheme;
typedef struct _PurpleCertificateVerifier PurpleCertificateVerifier;
typedef struct _PurpleCertificateVerificationRequest PurpleCertificateVerificationRequest;
@@ -456,6 +460,11 @@ purple_certificate_verify_complete(Purpl
/*@{*/
/**
+ * Returns the GType for the PurpleCertificate boxed structure.
+ */
+GType purple_certificate_get_type(void);
+
+/**
* Makes a duplicate of a certificate
*
* @param crt Instance to duplicate
@@ -643,6 +652,15 @@ purple_certificate_get_display_string(Pu
/** @name Certificate Pool Functions */
/*****************************************************************************/
/*@{*/
+
+/**
+ * Returns the GType for the PurpleCertificatePool boxed structure.
+ * TODO Boxing of PurpleCertificatePool is a temporary solution to having a
+ * GType for certificate pools. This should rather be a GObject instead of
+ * a GBoxed.
+ */
+GType purple_certificate_pool_get_type(void);
+
/**
* Helper function for generating file paths in ~/.purple/certificates for
* CertificatePools that use them.
diff --git a/libpurple/ft.c b/libpurple/ft.c
--- a/libpurple/ft.c
+++ b/libpurple/ft.c
@@ -1762,6 +1762,33 @@ gpointer purple_xfer_get_ui_data(const P
return xfer->ui_data;
}
+static PurpleXfer *
+purple_xfer_copy(PurpleXfer *xfer)
+{
+ PurpleXfer *xfer_copy;
+
+ g_return_val_if_fail(xfer != NULL, NULL);
+
+ xfer_copy = g_new(PurpleXfer, 1);
+ *xfer_copy = *xfer;
+
+ return xfer_copy;
+}
+
+GType
+purple_xfer_get_type(void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ type = g_boxed_type_register_static("PurpleXfer",
+ (GBoxedCopyFunc)purple_xfer_copy,
+ (GBoxedFreeFunc)g_free);
+ }
+
+ return type;
+}
+
/**************************************************************************
* File Transfer Subsystem API
diff --git a/libpurple/ft.h b/libpurple/ft.h
--- a/libpurple/ft.h
+++ b/libpurple/ft.h
@@ -27,6 +27,8 @@
#ifndef _PURPLE_FT_H_
#define _PURPLE_FT_H_
+#define PURPLE_TYPE_XFER (purple_xfer_get_type())
+
/**************************************************************************/
/** Data Structures */
/**************************************************************************/
@@ -192,6 +194,13 @@ G_BEGIN_DECLS
/*@{*/
/**
+ * Returns the GType for the PurpleXfer boxed structure.
+ * TODO Boxing of PurpleXfer is a temporary solution to having a GType for
+ * file transfers. This should rather be a GObject instead of a GBoxed.
+ */
+GType purple_plugin_get_type(void);
+
+/**
* Creates a new file transfer handle.
* This is called by prpls.
* The handle starts with a ref count of 1, and this reference
diff --git a/libpurple/log.c b/libpurple/log.c
--- a/libpurple/log.c
+++ b/libpurple/log.c
@@ -745,6 +745,33 @@ purple_log_uninit(void)
g_hash_table_destroy(logsize_users_decayed);
}
+static PurpleLog *
+purple_log_copy(PurpleLog *log)
+{
+ PurpleLog *log_copy;
+
+ g_return_val_if_fail(log != NULL, NULL);
+
+ log_copy = g_new(PurpleLog, 1);
+ *log_copy = *log;
+
+ return log_copy;
+}
+
+GType
+purple_log_get_type(void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ type = g_boxed_type_register_static("PurpleLog",
+ (GBoxedCopyFunc)purple_log_copy,
+ (GBoxedFreeFunc)g_free);
+ }
+
+ return type;
+}
+
/****************************************************************************
* LOGGERS ******************************************************************
****************************************************************************/
diff --git a/libpurple/log.h b/libpurple/log.h
--- a/libpurple/log.h
+++ b/libpurple/log.h
@@ -29,6 +29,7 @@
#include <stdio.h>
+#define PURPLE_TYPE_LOG (purple_log_get_type())
/********************************************************
* DATA STRUCTURES **************************************
@@ -189,6 +190,13 @@ G_BEGIN_DECLS
/*@{*/
/**
+ * Returns the GType for the PurpleLog boxed structure.
+ * TODO Boxing of PurpleLog is a temporary solution to having a GType for
+ * logs. This should rather be a GObject instead of a GBoxed.
+ */
+GType purple_log_get_type(void);
+
+/**
* Creates a new log
*
* @param type The type of log this is.
More information about the Commits
mailing list