gobjectification: d753b137: Add GCipher (sub class of Cipher) and su...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sun Jul 19 01:05:50 EDT 2009


-----------------------------------------------------------------
Revision: d753b1370ced3be3f01903bf333b67e5bb592299
Ancestor: b56679931786ba0a6aaaaa42b76c93bd101f5bec
Author: darkrain42 at pidgin.im
Date: 2009-07-19T05:01:20
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/d753b1370ced3be3f01903bf333b67e5bb592299

Added files:
        libpurple/gcipher.c libpurple/gcipher.h
Modified files:
        libpurple/Makefile.am libpurple/cipher.c
        libpurple/md5cipher.c libpurple/sha1cipher.c
        libpurple/sha1cipher.h

ChangeLog: 

Add GCipher (sub class of Cipher) and sub-class (on glib >2.16) md5 and sha1

-------------- next part --------------
============================================================
--- libpurple/gcipher.c	d448bded96749a55c3d2c152db7819629fa0f156
+++ libpurple/gcipher.c	d448bded96749a55c3d2c152db7819629fa0f156
@@ -0,0 +1,220 @@
+/*
+ * purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+#include "internal.h"
+
+#if GLIB_CHECK_VERSION(2,16,0)
+#include "gcipher.h"
+
+
+/*******************************************************************************
+ * Structs
+ ******************************************************************************/
+struct _PurpleGCipherPriv {
+	GChecksum *checksum;
+	GChecksumType type;
+};
+
+/******************************************************************************
+ * Enums
+ *****************************************************************************/
+enum {
+	PROP_ZERO,
+	PROP_GCHECKSUM_TYPE,
+	PROP_LAST,
+};
+
+/******************************************************************************
+ * Globals
+ *****************************************************************************/
+static GObjectClass *parent_class = NULL;
+
+/******************************************************************************
+ * Object Stuff
+ *****************************************************************************/
+static void
+purple_gcipher_reset(PurpleCipher *cipher)
+{
+	PurpleGCipher *gcipher = PURPLE_GCIPHER(cipher);
+	GChecksum *checksum = gcipher->priv->checksum;
+
+#if GLIB_CHECK_VERSION(2,18,0)
+	g_checksum_reset(checksum);
+#else
+	g_checksum_free(checksum);
+	checksum = gcipher->priv->checksum =
+		g_checksum_new(purple_gcipher_get_type(gcipher));
+#endif
+}
+
+static void
+purple_gcipher_append(PurpleCipher *cipher, const guchar *data, size_t len)
+{
+	PurpleGCipher *gcipher = PURPLE_GCIPHER(cipher);
+	GChecksum *checksum = gcipher->priv->checksum;
+
+	while (len >= G_MAXSSIZE) {
+		g_checksum_update(checksum, data, G_MAXSSIZE);
+		len -= G_MAXSSIZE;
+		data += G_MAXSSIZE;
+	}
+
+	if (len)
+		g_checksum_update(checksum, data, len);
+}
+
+static gboolean
+purple_gcipher_digest(PurpleCipher *cipher, size_t in_len,
+						guchar digest[16], size_t *out_len)
+{
+	PurpleGCipher *gcipher = PURPLE_GCIPHER(cipher);
+	GChecksum *checksum = gcipher->priv->checksum;
+
+	const gssize required_length = g_checksum_type_get_length(gcipher->priv->type);
+
+	g_return_val_if_fail(in_len >= required_length, FALSE);
+	g_return_val_if_fail(checksum != NULL, FALSE);
+
+	g_checksum_get_digest(checksum, digest, &in_len);
+
+	purple_gcipher_reset(cipher);
+
+	if (out_len)
+		*out_len = in_len;
+
+	return TRUE;
+}
+
+
+/******************************************************************************
+ * Object Stuff
+ *****************************************************************************/
+static void
+purple_gcipher_set_property(GObject *obj, guint param_id,
+                            const GValue *value, GParamSpec *pspec)
+{
+	PurpleGCipher *gcipher = PURPLE_GCIPHER(obj);
+	PurpleGCipherPriv *priv = gcipher->priv;
+
+	switch(param_id) {
+		case PROP_GCHECKSUM_TYPE:
+			priv->type = g_value_get_int(value);
+			break;
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+			break;
+	}
+}
+
+static void
+purple_gcipher_get_property(GObject *obj, guint param_id, GValue *value,
+                            GParamSpec *pspec)
+{
+	PurpleGCipher *gcipher = PURPLE_GCIPHER(obj);
+
+	switch(param_id) {
+		case PROP_GCHECKSUM_TYPE:
+			g_value_set_int(value, purple_gcipher_get_type(gcipher));
+		default:
+			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+			break;
+	}
+}
+
+static void
+purple_gcipher_finalize(GObject *obj)
+{
+	PurpleGCipher *gcipher = PURPLE_GCIPHER(obj);
+
+	g_checksum_free(gcipher->priv->checksum);
+	g_free(gcipher->priv);
+}
+
+static void
+purple_gcipher_class_init(PurpleGCipherClass *klass)
+{
+	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+	PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass);
+	GParamSpec *pspec = NULL;
+
+	parent_class = g_type_class_peek_parent(klass);
+
+	obj_class->set_property = purple_gcipher_set_property;
+	obj_class->get_property = purple_gcipher_get_property;
+	obj_class->finalize = purple_gcipher_finalize;
+
+	cipher_class->reset = purple_gcipher_reset;
+	cipher_class->append = purple_gcipher_append;
+	cipher_class->digest = purple_gcipher_digest;
+
+	pspec = g_param_spec_int("checksum_type", _("Checksum Type"),
+			_("The GChecksumType for this cipher"),
+			0, G_MAXINT, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+	g_object_class_install_property(obj_class, PROP_GCHECKSUM_TYPE, pspec);
+}
+
+static void
+purple_gcipher_init(PurpleCipher *cipher)
+{
+	PurpleGCipher *gcipher = PURPLE_GCIPHER(cipher);
+
+	gcipher->priv = g_new0(PurpleGCipherPriv, 1);
+}
+
+
+/******************************************************************************
+ * PurpleCipher API
+ *****************************************************************************/
+GType
+purple_gcipher_get_gtype(void) {
+	static GType type = 0;
+
+	if(type == 0) {
+		static const GTypeInfo info = {
+			sizeof(PurpleGCipherClass),
+			NULL,
+			NULL,
+			(GClassInitFunc)purple_gcipher_class_init,
+			NULL,
+			NULL,
+			sizeof(PurpleGCipher),
+			0,
+			(GInstanceInitFunc)purple_gcipher_init,
+			NULL
+		};
+
+		type = g_type_register_static(G_TYPE_OBJECT,
+									  "PurpleGCipher",
+									  &info, G_TYPE_FLAG_ABSTRACT);
+	}
+
+	return type;
+}
+
+GChecksumType
+purple_gcipher_get_type(PurpleGCipher *cipher)
+{
+	g_return_val_if_fail(PURPLE_IS_GCIPHER(cipher), -1);
+
+	return cipher->priv->type;
+}
+
+#endif /* GLIB_CHECK_VERSION(2,16,0) */
============================================================
--- libpurple/gcipher.h	8dc5cd1b100b099c7c378dc15cf42e3375e836ca
+++ libpurple/gcipher.h	8dc5cd1b100b099c7c378dc15cf42e3375e836ca
@@ -0,0 +1,84 @@
+/**
+ * @file gcipher.h Purple Cipher API
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
+ */
+#ifndef PURPLE_GCIPHER_H
+#define PURPLE_GCIPHER_H
+
+#include <cipher.h>
+#include <glib.h>
+#if GLIB_CHECK_VERSION(2,16,0)
+
+/*******************************************************************************
+ * New Cipher Header
+ ******************************************************************************/
+#include <glib-object.h>
+
+#define PURPLE_TYPE_GCIPHER				(purple_gcipher_get_gtype())
+#define PURPLE_GCIPHER(obj)				(G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_GCIPHER, PurpleGCipher))
+#define PURPLE_GCIPHER_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_GCIPHER, PurpleGCipherClass))
+#define PURPLE_IS_GCIPHER(obj)			(G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_GCIPHER))
+#define PURPLE_IS_GCIPHER_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_GCIPHER))
+#define PURPLE_GCIPHER_GET_CLASS(obj)	(G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_GCIPHER, PurpleGCipherClass))
+
+typedef struct _PurpleGCipher		PurpleGCipher;
+typedef struct _PurpleGCipherPriv	PurpleGCipherPriv;
+typedef struct _PurpleGCipherClass	PurpleGCipherClass;
+
+struct _PurpleGCipher {
+	GObject gparent;
+
+	PurpleGCipherPriv *priv;
+
+	void (*_purple_reserved1)(void);
+	void (*_purple_reserved2)(void);
+	void (*_purple_reserved3)(void);
+	void (*_purple_reserved4)(void);
+};
+
+struct _PurpleGCipherClass {
+	GObjectClass gparent;
+
+	void (*_purple_reserved1)(void);
+	void (*_purple_reserved2)(void);
+	void (*_purple_reserved3)(void);
+	void (*_purple_reserved4)(void);
+};
+
+G_BEGIN_DECLS
+
+GType purple_gcipher_get_gtype(void);
+
+/**
+ * Gets the type of a cipher
+ *
+ * @param cipher  The cipher
+ * @returns The type of the cipher
+ */
+GChecksumType purple_gcipher_get_type(PurpleGCipher *cipher);
+
+G_END_DECLS
+
+#endif /* GLIB_CHECK_VERSION */
+#endif /* PURPLE_GCIPHER_H */
============================================================
--- libpurple/Makefile.am	367caad71a4e78cf4353b5380bdf17d055df9a55
+++ libpurple/Makefile.am	16fec19c2a9748241192d041f25646d8e67760fb
@@ -57,6 +57,7 @@ purple_coresources = \
 	desktopitem.c \
 	eventloop.c \
 	ft.c \
+	gcipher.c \
 	group.c \
 	hmaccipher.c \
 	idle.c \
@@ -130,6 +131,7 @@ purple_coreheaders = \
 	eventloop.h \
 	ft.h \
 	gaim-compat.h \
+	gcipher.h \
 	hmaccipher.h \
 	idle.h \
 	imgstore.h \
============================================================
--- libpurple/cipher.c	3916a5ac75b37ed428a986845ff4f52e388bf85a
+++ libpurple/cipher.c	6831530ce7ef83b5b4fcaea91772dfdee0f24e61
@@ -22,87 +22,6 @@
 #include "internal.h"
 #include "cipher.h"
 
-#if GLIB_CHECK_VERSION(2,16,0)
-static void
-purple_g_checksum_init(PurpleCipherContext *context, GChecksumType type)
-{
-	GChecksum *checksum;
-
-	checksum = g_checksum_new(type);
-	purple_cipher_context_set_data(context, checksum);
-}
-
-static void
-purple_g_checksum_reset(PurpleCipherContext *context, GChecksumType type)
-{
-	GChecksum *checksum;
-
-	checksum = purple_cipher_context_get_data(context);
-	g_return_if_fail(checksum != NULL);
-
-#if GLIB_CHECK_VERSION(2,18,0)
-	g_checksum_reset(checksum);
-#else
-	g_checksum_free(checksum);
-	checksum = g_checksum_new(type);
-	purple_cipher_context_set_data(context, checksum);
-#endif
-}
-
-static void
-purple_g_checksum_uninit(PurpleCipherContext *context)
-{
-	GChecksum *checksum;
-
-	checksum = purple_cipher_context_get_data(context);
-	g_return_if_fail(checksum != NULL);
-
-	g_checksum_free(checksum);
-}
-
-static void
-purple_g_checksum_append(PurpleCipherContext *context, const guchar *data,
-                         gsize len)
-{
-	GChecksum *checksum;
-
-	checksum = purple_cipher_context_get_data(context);
-	g_return_if_fail(checksum != NULL);
-
-	while (len >= G_MAXSSIZE) {
-		g_checksum_update(checksum, data, G_MAXSSIZE);
-		len -= G_MAXSSIZE;
-		data += G_MAXSSIZE;
-	}
-
-	if (len)
-		g_checksum_update(checksum, data, len);
-}
-
-static gboolean
-purple_g_checksum_digest(PurpleCipherContext *context, GChecksumType type,
-                         gsize len, guchar *digest, gsize *out_len)
-{
-	GChecksum *checksum;
-	const gssize required_length = g_checksum_type_get_length(type);
-
-	checksum = purple_cipher_context_get_data(context);
-
-	g_return_val_if_fail(len >= required_length, FALSE);
-	g_return_val_if_fail(checksum != NULL, FALSE);
-
-	g_checksum_get_digest(checksum, digest, &len);
-
-	purple_cipher_context_reset(context, NULL);
-
-	if (out_len)
-		*out_len = len;
-
-	return TRUE;
-}
-#endif
-
-
 /*******************************************************************************
  * Structs
  ******************************************************************************/
============================================================
--- libpurple/md5cipher.c	6c95b87d9f68d325966b5d818ba098cbfb65a060
+++ libpurple/md5cipher.c	2fdd62595b5749051a0b78d7a92cc084f20f32ce
@@ -3,6 +3,7 @@
  * Copyright (C) 2001-2003  Christophe Devine <c.devine at cr0.net>
  */
 #include "md5cipher.h"
+#include "gcipher.h"
 
 #include <string.h>
 
@@ -11,12 +12,13 @@
 /******************************************************************************
  * Structs
  *****************************************************************************/
+#if !GLIB_CHECK_VERSION(2,16,0)
 struct _PurpleMD5CipherPriv {
 	guint32 total[2];
 	guint32 state[4];
 	guchar buffer[64];
 };
-
+#endif
 /******************************************************************************
  * Globals
  *****************************************************************************/
@@ -42,6 +44,7 @@ static GObjectClass *parent_class = NULL
 /******************************************************************************
  * Cipher Stuff
  *****************************************************************************/
+#if !GLIB_CHECK_VERSION(2,16,0)
 static void
 purple_md5_cipher_reset(PurpleCipher *cipher) {
 	PurpleMD5Cipher *md5_cipher = PURPLE_MD5_CIPHER(cipher);
@@ -252,6 +255,7 @@ purple_md5_cipher_digest(PurpleCipher *c
 
 	return TRUE;
 }
+#endif /* !GLIB_CHECK_VERSION(2,16,0) */
 
 static size_t
 purple_md5_cipher_get_block_size(PurpleCipher *cipher)
@@ -262,6 +266,7 @@ purple_md5_cipher_get_block_size(PurpleC
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
+#if !GLIB_CHECK_VERSION(2,16,0)
 static void
 purple_md5_cipher_finalize(GObject *obj) {
 	PurpleCipher *cipher = PURPLE_CIPHER(obj);
@@ -272,29 +277,36 @@ purple_md5_cipher_finalize(GObject *obj)
 
 	g_free(md5_cipher->priv);
 }
+#endif /* GLIB_CHECK_VERSION(2,16,0) */
 
 static void
 purple_md5_cipher_class_init(PurpleMD5CipherClass *klass) {
+#if !GLIB_CHECK_VERSION(2,16,0)
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+#endif
 	PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass);
 
 	parent_class = g_type_class_peek_parent(klass);
 
+#if !GLIB_CHECK_VERSION(2,16,0)
 	obj_class->finalize = purple_md5_cipher_finalize;
 
 	cipher_class->reset = purple_md5_cipher_reset;
 	cipher_class->append = purple_md5_cipher_append;
 	cipher_class->digest = purple_md5_cipher_digest;
+#endif
 	cipher_class->get_block_size = purple_md5_cipher_get_block_size;
 }
 
 static void
 purple_md5_cipher_init(PurpleCipher *cipher) {
+#if !GLIB_CHECK_VERSION(2,16,0)
 	PurpleMD5Cipher *md5_cipher = PURPLE_MD5_CIPHER(cipher);
 
 	md5_cipher->priv = g_new0(PurpleMD5CipherPriv, 1);
 
 	purple_md5_cipher_reset(cipher);
+#endif
 }
 
 /******************************************************************************
@@ -318,7 +330,11 @@ purple_md5_cipher_get_gtype(void) {
 			NULL,
 		};
 
+#if GLIB_CHECK_VERSION(2,16,0)
+		type = g_type_register_static(PURPLE_TYPE_GCIPHER,
+#else
 		type = g_type_register_static(PURPLE_TYPE_CIPHER,
+#endif
 									  "PurpleMD5Cipher",
 									  &info, 0);
 	}
@@ -328,5 +344,11 @@ purple_md5_cipher_new(void) {
 
 PurpleCipher *
 purple_md5_cipher_new(void) {
-	return g_object_new(PURPLE_TYPE_MD5_CIPHER, NULL);
+#if GLIB_CHECK_VERSION(2,16,0)
+	return g_object_new(PURPLE_TYPE_MD5_CIPHER,
+		"checksum_type", G_CHECKSUM_MD5,
+		NULL);
+#else
+	return g_object_new(PURPLE_TYPE_MD5_CIPHER);
+#endif
 }
============================================================
--- libpurple/sha1cipher.c	7bb6002e4e408173e0f32384aa34debbbc96d505
+++ libpurple/sha1cipher.c	27b247ee9373ec2a2644e4b5f3403950ac4c5514
@@ -1,6 +1,7 @@
 /*
  */
 #include "sha1cipher.h"
+#include "gcipher.h"
 
 #include <string.h>
 
@@ -9,9 +10,11 @@
 #define SHA1_BLOCK_WORDS		16
 #define SHA1_HASH_WORDS		4
 
+
 /******************************************************************************
  * Structs
  *****************************************************************************/
+#if !GLIB_CHECK_VERSION(2,16,0)
 struct _PurpleSHA1CipherPriv {
 	guint32 H[5];
 	guint32 W[80];
@@ -21,15 +24,12 @@ struct _PurpleSHA1CipherPriv {
 	guint32 sizeHi;
 	guint32 sizeLo;
 };
-
+#endif
 /******************************************************************************
  * Enums
  *****************************************************************************/
 enum {
 	PROP_ZERO,
-	PROP_SIZE_HI,
-	PROP_SIZE_LO,
-	PROP_LEN_W,
 	PROP_LAST,
 };
 
@@ -46,6 +46,8 @@ static GObjectClass *parent_class = NULL
 /******************************************************************************
  * Cipher Stuff
  *****************************************************************************/
+
+#if !GLIB_CHECK_VERSION(2,16,0)
 static void
 purple_sha1_cipher_reset(PurpleCipher *cipher) {
 	PurpleSHA1Cipher *sha1_cipher = PURPLE_SHA1_CIPHER(cipher);
@@ -188,6 +190,7 @@ purple_sha1_cipher_digest(PurpleCipher *
 
 	return TRUE;
 }
+#endif /* !GLIB_CHECK_VERSION */
 
 static size_t
 purple_sha1_cipher_get_block_size(PurpleCipher *cipher)
@@ -198,57 +201,8 @@ purple_sha1_cipher_get_block_size(Purple
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
+#if !GLIB_CHECK_VERSION(2,16,0)
 static void
-purple_sha1_cipher_set_property(GObject *obj, guint param_id,
-								const GValue *value, GParamSpec *pspec)
-{
-	PurpleSHA1Cipher *sha1_cipher = PURPLE_SHA1_CIPHER(obj);
-
-	switch(param_id) {
-		case PROP_SIZE_HI:
-			purple_sha1_cipher_set_size_hi(sha1_cipher,
-										   g_value_get_int(value));
-			break;
-		case PROP_SIZE_LO:
-			purple_sha1_cipher_set_size_lo(sha1_cipher,
-										   g_value_get_int(value));
-			break;
-		case PROP_LEN_W:
-			purple_sha1_cipher_set_len_w(sha1_cipher,
-										 g_value_get_int(value));
-			break;
-		default:
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-			break;
-	}
-}
-
-static void
-purple_sha1_cipher_get_property(GObject *obj, guint param_id, GValue *value,
-								GParamSpec *pspec)
-{
-	PurpleSHA1Cipher *sha1_cipher = PURPLE_SHA1_CIPHER(obj);
-
-	switch(param_id) {
-		case PROP_SIZE_HI:
-			g_value_set_int(value,
-							purple_sha1_cipher_get_size_hi(sha1_cipher));
-			break;
-		case PROP_SIZE_LO:
-			g_value_set_int(value,
-							purple_sha1_cipher_get_size_lo(sha1_cipher));
-			break;
-		case PROP_LEN_W:
-			g_value_set_int(value,
-							purple_sha1_cipher_get_len_w(sha1_cipher));
-			break;
-		default:
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-			break;
-	}
-}
-
-static void
 purple_sha1_cipher_finalize(GObject *obj) {
 	PurpleCipher *cipher = PURPLE_CIPHER(obj);
 	PurpleSHA1Cipher *sha1_cipher = PURPLE_SHA1_CIPHER(obj);
@@ -258,47 +212,36 @@ purple_sha1_cipher_finalize(GObject *obj
 
 	g_free(sha1_cipher->priv);
 }
+#endif /* !GLIB_CHECK_VERSION(2,16,0) */
 
 static void
 purple_sha1_cipher_class_init(PurpleSHA1CipherClass *klass) {
+#if !GLIB_CHECK_VERSION(2,16,0)
 	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+#endif
 	PurpleCipherClass *cipher_class = PURPLE_CIPHER_CLASS(klass);
-	GParamSpec *pspec = NULL;
 
 	parent_class = g_type_class_peek_parent(klass);
 
-	obj_class->set_property = purple_sha1_cipher_set_property;
-	obj_class->get_property = purple_sha1_cipher_get_property;
+#if !GLIB_CHECK_VERSION(2,16,0)
 	obj_class->finalize = purple_sha1_cipher_finalize;
 
 	cipher_class->reset = purple_sha1_cipher_reset;
 	cipher_class->append = purple_sha1_cipher_append;
 	cipher_class->digest = purple_sha1_cipher_digest;
+#endif
 	cipher_class->get_block_size = purple_sha1_cipher_get_block_size;
-
-	pspec = g_param_spec_int("sizeHi", "sizeHi", "sizeHi",
-							 G_MININT, G_MAXINT, 0,
-							 G_PARAM_READWRITE);
-	g_object_class_install_property(obj_class, PROP_SIZE_HI, pspec);
-
-	pspec = g_param_spec_int("sizeLo", "sizeLo", "sizeLo",
-							 G_MININT, G_MAXINT, 0,
-							 G_PARAM_READWRITE);
-	g_object_class_install_property(obj_class, PROP_SIZE_LO, pspec);
-
-	pspec = g_param_spec_int("lenW", "lenW", "lenW",
-							 G_MININT, G_MAXINT, 0,
-							 G_PARAM_READWRITE);
-	g_object_class_install_property(obj_class, PROP_LEN_W, pspec);
 }
 
 static void
 purple_sha1_cipher_init(PurpleCipher *cipher) {
+#if !GLIB_CHECK_VERSION(2,16,0)
 	PurpleSHA1Cipher *sha1_cipher = PURPLE_SHA1_CIPHER(cipher);
 
 	sha1_cipher->priv = g_new0(PurpleSHA1CipherPriv, 1);
 
 	purple_sha1_cipher_reset(cipher);
+#endif
 }
 
 /******************************************************************************
@@ -322,7 +265,11 @@ purple_sha1_cipher_get_gtype(void) {
 			NULL,
 		};
 
+#if GLIB_CHECK_VERSION(2,16,0)
+		type = g_type_register_static(PURPLE_TYPE_GCIPHER,
+#else
 		type = g_type_register_static(PURPLE_TYPE_CIPHER,
+#endif
 									  "PurpleSHA1Cipher",
 									  &info, 0);
 	}
@@ -332,58 +279,12 @@ purple_sha1_cipher_new(void) {
 
 PurpleCipher *
 purple_sha1_cipher_new(void) {
+#if GLIB_CHECK_VERSION(2,16,0)
+	return g_object_new(PURPLE_TYPE_SHA1_CIPHER,
+			"checksum_type", G_CHECKSUM_SHA1,
+			NULL);
+#else
 	return g_object_new(PURPLE_TYPE_SHA1_CIPHER, NULL);
+#endif
 }
 
-gint32
-purple_sha1_cipher_get_size_hi(PurpleSHA1Cipher *sha1_cipher) {
-	g_return_val_if_fail(PURPLE_IS_SHA1_CIPHER(sha1_cipher), 0);
-
-	return sha1_cipher->priv->sizeHi;
-}
-
-void
-purple_sha1_cipher_set_size_hi(PurpleSHA1Cipher *sha1_cipher,
-								 gint32 size_high)
-{
-	g_return_if_fail(PURPLE_IS_SHA1_CIPHER(sha1_cipher));
-
-	sha1_cipher->priv->sizeHi = size_high;
-
-	g_object_notify(G_OBJECT(sha1_cipher), "sizeHi");
-}
-
-gint32
-purple_sha1_cipher_get_size_lo(PurpleSHA1Cipher *sha1_cipher) {
-	g_return_val_if_fail(PURPLE_IS_SHA1_CIPHER(sha1_cipher), 0);
-
-	return sha1_cipher->priv->sizeLo;
-}
-
-void
-purple_sha1_cipher_set_size_lo(PurpleSHA1Cipher *sha1_cipher,
-								gint32 size_low)
-{
-	g_return_if_fail(PURPLE_IS_SHA1_CIPHER(sha1_cipher));
-
-	sha1_cipher->priv->sizeLo = size_low;
-
-	g_object_notify(G_OBJECT(sha1_cipher), "sizeLo");
-}
-
-gint32
-purple_sha1_cipher_get_len_w(PurpleSHA1Cipher *sha1_cipher) {
-	g_return_val_if_fail(PURPLE_IS_SHA1_CIPHER(sha1_cipher), 0);
-
-	return sha1_cipher->priv->lenW;
-}
-
-void
-purple_sha1_cipher_set_len_w(PurpleSHA1Cipher *sha1_cipher, gint32 lenw) {
-	g_return_if_fail(PURPLE_IS_SHA1_CIPHER(sha1_cipher));
-
-	sha1_cipher->priv->lenW = lenw;
-
-	g_object_notify(G_OBJECT(sha1_cipher), "lenW");
-}
-
============================================================
--- libpurple/sha1cipher.h	9ec3a14cd17fbcb2c795268d4a486a2c64c0a98d
+++ libpurple/sha1cipher.h	9a7de695e33970a405f497e8f2792b1ab60b640c
@@ -64,13 +64,6 @@ PurpleCipher *purple_sha1_cipher_new(voi
 
 PurpleCipher *purple_sha1_cipher_new(void);
 
-gint32 purple_sha1_cipher_get_size_hi(PurpleSHA1Cipher *sha1_cipher);
-void purple_sha1_cipher_set_size_hi(PurpleSHA1Cipher *sha1_cipher, gint32 size_high);
-gint32 purple_sha1_cipher_get_size_lo(PurpleSHA1Cipher *sha1_cipher);
-void purple_sha1_cipher_set_size_lo(PurpleSHA1Cipher *sha1_cipher, gint32 size_low);
-gint32 purple_sha1_cipher_get_len_w(PurpleSHA1Cipher *sha1_cipher);
-void purple_sha1_cipher_set_len_w(PurpleSHA1Cipher *sha1_cipher, gint32 lenw);
-
 G_END_DECLS
 
 #endif /* PURPLE_SHA1_CIPHER_H */


More information about the Commits mailing list