/soc/2013/ankitkv/gobjectification: 2aee8634c912: ciphers: Use G...

Ankit Vani a at nevitus.org
Sat Nov 16 17:54:33 EST 2013


Changeset: 2aee8634c9122be3fb66fe6ee71f5bc9be91edeb
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-11-17 04:06 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/2aee8634c912

Description:

ciphers: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called

diffstat:

 libpurple/ciphers/aescipher.c    |  17 +++++++++--------
 libpurple/ciphers/des3cipher.c   |  10 ++++++----
 libpurple/ciphers/descipher.c    |   2 +-
 libpurple/ciphers/hmaccipher.c   |   3 ++-
 libpurple/ciphers/pbkdf2cipher.c |  13 ++++++++-----
 libpurple/ciphers/rc4cipher.c    |   8 +++++---
 6 files changed, 31 insertions(+), 22 deletions(-)

diffs (157 lines):

diff --git a/libpurple/ciphers/aescipher.c b/libpurple/ciphers/aescipher.c
--- a/libpurple/ciphers/aescipher.c
+++ b/libpurple/ciphers/aescipher.c
@@ -505,11 +505,12 @@ purple_aes_cipher_set_batch_mode(PurpleC
 {
 	PurpleAESCipherPrivate *priv = PURPLE_AES_CIPHER_GET_PRIVATE(cipher);
 
-	if (mode == PURPLE_CIPHER_BATCH_MODE_CBC)
-		return;
+	if (mode != PURPLE_CIPHER_BATCH_MODE_CBC) {
+		purple_debug_error("cipher-aes", "unsupported batch mode\n");
+		priv->failure = TRUE;
+	}
 
-	purple_debug_error("cipher-aes", "unsupported batch mode\n");
-	priv->failure = TRUE;
+	g_object_notify(G_OBJECT(cipher), "batch-mode");
 }
 
 static PurpleCipherBatchMode
@@ -590,17 +591,17 @@ purple_aes_cipher_class_init(PurpleAESCi
 	cipher_class->get_batch_mode = purple_aes_cipher_get_batch_mode;
 	cipher_class->get_block_size = purple_aes_cipher_get_block_size;
 
-	pspec = g_param_spec_enum("batch_mode", "batch_mode", "batch_mode",
+	pspec = g_param_spec_enum("batch-mode", "batch-mode", "batch-mode",
 							  PURPLE_TYPE_CIPHER_BATCH_MODE, 0,
-							  G_PARAM_READWRITE);
+							  G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_BATCH_MODE, pspec);
 
 	pspec = g_param_spec_string("iv", "iv", "iv", NULL,
-								G_PARAM_WRITABLE);
+								G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_IV, pspec);
 
 	pspec = g_param_spec_string("key", "key", "key", NULL,
-								G_PARAM_WRITABLE);
+								G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_KEY, pspec);
 
 	g_type_class_add_private(klass, sizeof(PurpleAESCipherPrivate));
diff --git a/libpurple/ciphers/des3cipher.c b/libpurple/ciphers/des3cipher.c
--- a/libpurple/ciphers/des3cipher.c
+++ b/libpurple/ciphers/des3cipher.c
@@ -352,6 +352,8 @@ purple_des3_cipher_set_batch_mode(Purple
 	PurpleDES3CipherPrivate *priv = PURPLE_DES3_CIPHER_GET_PRIVATE(des3_cipher);
 
 	priv->mode = mode;
+
+	g_object_notify(G_OBJECT(cipher), "batch-mode");
 }
 
 static PurpleCipherBatchMode
@@ -456,17 +458,17 @@ purple_des3_cipher_class_init(PurpleDES3
 	cipher_class->get_batch_mode = purple_des3_cipher_get_batch_mode;
 	cipher_class->get_key_size = purple_des3_cipher_get_key_size;
 
-	pspec = g_param_spec_enum("batch_mode", "batch_mode", "batch_mode",
+	pspec = g_param_spec_enum("batch-mode", "batch-mode", "batch-mode",
 							  PURPLE_TYPE_CIPHER_BATCH_MODE, 0,
-							  G_PARAM_READWRITE);
+							  G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_BATCH_MODE, pspec);
 
 	pspec = g_param_spec_string("iv", "iv", "iv", NULL,
-								G_PARAM_WRITABLE);
+								G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_IV, pspec);
 
 	pspec = g_param_spec_string("key", "key", "key", NULL,
-								G_PARAM_WRITABLE);
+								G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_KEY, pspec);
 
 	g_type_class_add_private(klass, sizeof(PurpleDES3CipherPrivate));
diff --git a/libpurple/ciphers/descipher.c b/libpurple/ciphers/descipher.c
--- a/libpurple/ciphers/descipher.c
+++ b/libpurple/ciphers/descipher.c
@@ -534,7 +534,7 @@ purple_des_cipher_class_init(PurpleDESCi
 	cipher_class->get_key_size = purple_des_cipher_get_key_size;
 
 	pspec = g_param_spec_string("key", "key", "key", NULL,
-								G_PARAM_WRITABLE);
+								G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_KEY, pspec);
 
 	g_type_class_add_private(klass, sizeof(PurpleDESCipherPrivate));
diff --git a/libpurple/ciphers/hmaccipher.c b/libpurple/ciphers/hmaccipher.c
--- a/libpurple/ciphers/hmaccipher.c
+++ b/libpurple/ciphers/hmaccipher.c
@@ -280,7 +280,8 @@ purple_hmac_cipher_class_init(PurpleHMAC
 	cipher_class->get_block_size = purple_hmac_cipher_get_block_size;
 
 	pspec = g_param_spec_object("hash", "hash", "hash", PURPLE_TYPE_HASH,
-								G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+								G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+								G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_HASH, pspec);
 }
 
diff --git a/libpurple/ciphers/pbkdf2cipher.c b/libpurple/ciphers/pbkdf2cipher.c
--- a/libpurple/ciphers/pbkdf2cipher.c
+++ b/libpurple/ciphers/pbkdf2cipher.c
@@ -337,15 +337,18 @@ purple_pbkdf2_cipher_class_init(PurplePB
 	cipher_class->set_key = purple_pbkdf2_cipher_set_key;
 
 	pspec = g_param_spec_object("hash", "hash", "hash", PURPLE_TYPE_HASH,
-								G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+								G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY |
+								G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_HASH, pspec);
 
-	pspec = g_param_spec_uint("iter_count", "iter_count", "iter_count", 0,
-								G_MAXUINT, 0, G_PARAM_READWRITE);
+	pspec = g_param_spec_uint("iter-count", "iter-count", "iter-count", 0,
+								G_MAXUINT, 0, G_PARAM_READWRITE |
+								G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_ITER_COUNT, pspec);
 
-	pspec = g_param_spec_uint("out_len", "out_len", "out_len", 0,
-								G_MAXUINT, 0, G_PARAM_READWRITE);
+	pspec = g_param_spec_uint("out-len", "out-len", "out-len", 0,
+								G_MAXUINT, 0, G_PARAM_READWRITE |
+								G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_OUT_LEN, pspec);
 
 	g_type_class_add_private(klass, sizeof(PurplePBKDF2CipherPrivate));
diff --git a/libpurple/ciphers/rc4cipher.c b/libpurple/ciphers/rc4cipher.c
--- a/libpurple/ciphers/rc4cipher.c
+++ b/libpurple/ciphers/rc4cipher.c
@@ -180,13 +180,13 @@ purple_rc4_cipher_class_init(PurpleRC4Ci
 	cipher_class->encrypt = purple_rc4_cipher_encrypt;
 	cipher_class->set_key = purple_rc4_cipher_set_key;
 
-	pspec = g_param_spec_int("key_len", "key_len", "key_len",
+	pspec = g_param_spec_int("key-len", "key-len", "key-len",
 							 G_MININT, G_MAXINT, 0,
-							 G_PARAM_READWRITE);
+							 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_KEY_LEN, pspec);
 
 	pspec = g_param_spec_string("key", "key", "key", NULL,
-								G_PARAM_WRITABLE);
+								G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS);
 	g_object_class_install_property(obj_class, PROP_KEY, pspec);
 
 	g_type_class_add_private(klass, sizeof(PurpleRC4CipherPrivate));
@@ -241,6 +241,8 @@ purple_rc4_cipher_set_key_len(PurpleRC4C
 
 	priv = PURPLE_RC4_CIPHER_GET_PRIVATE(rc4_cipher);
 	priv->key_len = key_len;
+
+	g_object_notify(G_OBJECT(rc4_cipher), "key-len");
 }
 
 gint



More information about the Commits mailing list