/soc/2013/ankitkv/gobjectification: 45b72366ddde: Added get_name...

Ankit Vani a at nevitus.org
Fri Jun 14 12:52:04 EDT 2013


Changeset: 45b72366dddebbd0f01621c17402b3766dbe236a
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-06-14 22:21 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/45b72366ddde

Description:

Added get_name method to all PurpleCiphers

diffstat:

 libpurple/ciphers/aes.c    |   7 +++++++
 libpurple/ciphers/des.c    |  13 +++++++------
 libpurple/ciphers/des3.c   |   7 +++++++
 libpurple/ciphers/hmac.c   |   7 +++++++
 libpurple/ciphers/md4.c    |   7 +++++++
 libpurple/ciphers/md5.c    |   7 +++++++
 libpurple/ciphers/pbkdf2.c |   7 +++++++
 libpurple/ciphers/rc4.c    |   7 +++++++
 libpurple/ciphers/sha1.c   |   7 +++++++
 libpurple/ciphers/sha256.c |   7 +++++++
 10 files changed, 70 insertions(+), 6 deletions(-)

diffs (260 lines):

diff --git a/libpurple/ciphers/aes.c b/libpurple/ciphers/aes.c
--- a/libpurple/ciphers/aes.c
+++ b/libpurple/ciphers/aes.c
@@ -529,6 +529,12 @@ purple_aes_cipher_get_block_size(PurpleC
 	return PURPLE_AES_BLOCK_SIZE;
 }
 
+static const gchar*
+purple_aes_cipher_get_name(PurpleCipher *cipher)
+{
+	return "aes";
+}
+
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
@@ -594,6 +600,7 @@ purple_aes_cipher_class_init(PurpleAESCi
 	cipher_class->set_batch_mode = purple_aes_cipher_set_batch_mode;
 	cipher_class->get_batch_mode = purple_aes_cipher_get_batch_mode;
 	cipher_class->get_block_size = purple_aes_cipher_get_block_size;
+	cipher_class->get_name = purple_aes_cipher_get_name;
 
 	pspec = g_param_spec_enum("batch_mode", "batch_mode", "batch_mode",
 							  PURPLE_TYPE_CIPHER_BATCH_MODE, 0,
diff --git a/libpurple/ciphers/des.c b/libpurple/ciphers/des.c
--- a/libpurple/ciphers/des.c
+++ b/libpurple/ciphers/des.c
@@ -486,6 +486,12 @@ purple_des_cipher_decrypt(PurpleCipher *
 	return out_len;
 }
 
+static const gchar*
+purple_des_cipher_get_name(PurpleCipher *cipher)
+{
+	return "des";
+}
+
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
@@ -528,6 +534,7 @@ purple_des_cipher_class_init(PurpleDESCi
 	cipher_class->decrypt = purple_des_cipher_decrypt;
 	cipher_class->set_key = purple_des_cipher_set_key;
 	cipher_class->get_key_size = purple_des_cipher_get_key_size;
+	cipher_class->get_name = purple_des_cipher_get_name;
 
 	pspec = g_param_spec_string("key", "key", "key", NULL,
 								G_PARAM_WRITABLE);
@@ -536,11 +543,6 @@ purple_des_cipher_class_init(PurpleDESCi
 	g_type_class_add_private(klass, sizeof(PurpleDESCipherPrivate));
 }
 
-static void
-purple_des_cipher_init(PurpleCipher *cipher)
-{
-}
-
 /******************************************************************************
  * API
  *****************************************************************************/
@@ -553,7 +555,6 @@ purple_des_cipher_get_type(void) {
 			.class_size = sizeof(PurpleDESCipherClass),
 			.class_init = (GClassInitFunc)purple_des_cipher_class_init,
 			.instance_size = sizeof(PurpleDESCipher),
-			.instance_init = (GInstanceInitFunc)purple_des_cipher_init,
 		};
 
 		type = g_type_register_static(PURPLE_TYPE_CIPHER,
diff --git a/libpurple/ciphers/des3.c b/libpurple/ciphers/des3.c
--- a/libpurple/ciphers/des3.c
+++ b/libpurple/ciphers/des3.c
@@ -375,6 +375,12 @@ purple_des3_cipher_set_iv(PurpleCipher *
 	g_object_notify(G_OBJECT(des3_cipher), "iv");
 }
 
+static const gchar*
+purple_des3_cipher_get_name(PurpleCipher *cipher)
+{
+	return "des3";
+}
+
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
@@ -456,6 +462,7 @@ purple_des3_cipher_class_init(PurpleDES3
 	cipher_class->set_batch_mode = purple_des3_cipher_set_batch_mode;
 	cipher_class->get_batch_mode = purple_des3_cipher_get_batch_mode;
 	cipher_class->get_key_size = purple_des3_cipher_get_key_size;
+	cipher_class->get_name = purple_des3_cipher_get_name;
 
 	pspec = g_param_spec_enum("batch_mode", "batch_mode", "batch_mode",
 							  PURPLE_TYPE_CIPHER_BATCH_MODE, 0,
diff --git a/libpurple/ciphers/hmac.c b/libpurple/ciphers/hmac.c
--- a/libpurple/ciphers/hmac.c
+++ b/libpurple/ciphers/hmac.c
@@ -214,6 +214,12 @@ purple_hmac_cipher_get_block_size(Purple
 	return purple_hmac_cipher_get_block_size(priv->hash);
 }
 
+static const gchar*
+purple_hmac_cipher_get_name(PurpleCipher *cipher)
+{
+	return "hmac";
+}
+
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
@@ -284,6 +290,7 @@ purple_hmac_cipher_class_init(PurpleHMAC
 	cipher_class->get_digest_size = purple_hmac_cipher_get_digest_size;
 	cipher_class->set_key = purple_hmac_cipher_set_key;
 	cipher_class->get_block_size = purple_hmac_cipher_get_block_size;
+	cipher_class->get_name = purple_hmac_cipher_get_name;
 
 	pspec = g_param_spec_object("hash", "hash", "hash", PURPLE_TYPE_CIPHER,
 								G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
diff --git a/libpurple/ciphers/md4.c b/libpurple/ciphers/md4.c
--- a/libpurple/ciphers/md4.c
+++ b/libpurple/ciphers/md4.c
@@ -256,6 +256,12 @@ purple_md4_cipher_get_block_size(PurpleC
 	return 64;
 }
 
+static const gchar*
+purple_md4_cipher_get_name(PurpleCipher *cipher)
+{
+	return "md4";
+}
+
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
@@ -273,6 +279,7 @@ purple_md4_cipher_class_init(PurpleMD4Ci
 	cipher_class->digest = purple_md4_cipher_digest;
 	cipher_class->get_digest_size = purple_md4_cipher_get_digest_size;
 	cipher_class->get_block_size = purple_md4_cipher_get_block_size;
+	cipher_class->get_name = purple_md4_cipher_get_name;
 }
 
 /******************************************************************************
diff --git a/libpurple/ciphers/md5.c b/libpurple/ciphers/md5.c
--- a/libpurple/ciphers/md5.c
+++ b/libpurple/ciphers/md5.c
@@ -107,6 +107,12 @@ purple_md5_cipher_get_digest_size(Purple
 	return g_checksum_type_get_length(G_CHECKSUM_MD5);
 }
 
+static const gchar*
+purple_md5_cipher_get_name(PurpleCipher *cipher)
+{
+	return "md5";
+}
+
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
@@ -138,6 +144,7 @@ purple_md5_cipher_class_init(PurpleMD5Ci
 	cipher_class->digest = purple_md5_cipher_digest;
 	cipher_class->get_digest_size = purple_md5_cipher_get_digest_size;
 	cipher_class->get_block_size = purple_md5_cipher_get_block_size;
+	cipher_class->get_name = purple_md5_cipher_get_name;
 
 	g_type_class_add_private(klass, sizeof(PurpleMD5CipherPrivate));
 }
diff --git a/libpurple/ciphers/pbkdf2.c b/libpurple/ciphers/pbkdf2.c
--- a/libpurple/ciphers/pbkdf2.c
+++ b/libpurple/ciphers/pbkdf2.c
@@ -254,6 +254,12 @@ purple_pbkdf2_cipher_digest(PurpleCipher
 	return TRUE;
 }
 
+static const gchar*
+purple_pbkdf2_cipher_get_name(PurpleCipher *cipher)
+{
+	return "pbkdf2";
+}
+
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
@@ -333,6 +339,7 @@ purple_pbkdf2_cipher_class_init(PurplePB
 	cipher_class->get_digest_size = purple_pbkdf2_cipher_get_digest_size;
 	cipher_class->set_salt = purple_pbkdf2_cipher_set_salt;
 	cipher_class->set_key = purple_pbkdf2_cipher_set_key;
+	cipher_class->get_name = purple_pbkdf2_cipher_get_name;
 
 	pspec = g_param_spec_object("hash", "hash", "hash", PURPLE_TYPE_CIPHER,
 								G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
diff --git a/libpurple/ciphers/rc4.c b/libpurple/ciphers/rc4.c
--- a/libpurple/ciphers/rc4.c
+++ b/libpurple/ciphers/rc4.c
@@ -134,6 +134,12 @@ purple_rc4_cipher_encrypt(PurpleCipher *
 	return in_len;
 }
 
+static const gchar*
+purple_rc4_cipher_get_name(PurpleCipher *cipher)
+{
+	return "rc4";
+}
+
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
@@ -192,6 +198,7 @@ purple_rc4_cipher_class_init(PurpleRC4Ci
 	cipher_class->encrypt = purple_rc4_cipher_encrypt;
 	cipher_class->set_key = purple_rc4_cipher_set_key;
 	cipher_class->get_key_size = purple_rc4_cipher_get_key_size;
+	cipher_class->get_name = purple_rc4_cipher_get_name;
 
 	pspec = g_param_spec_int("key_len", "key_len", "key_len",
 							 G_MININT, G_MAXINT, 0,
diff --git a/libpurple/ciphers/sha1.c b/libpurple/ciphers/sha1.c
--- a/libpurple/ciphers/sha1.c
+++ b/libpurple/ciphers/sha1.c
@@ -107,6 +107,12 @@ purple_sha1_cipher_get_digest_size(Purpl
 	return g_checksum_type_get_length(G_CHECKSUM_SHA1);
 }
 
+static const gchar*
+purple_sha1_cipher_get_name(PurpleCipher *cipher)
+{
+	return "sha1";
+}
+
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
@@ -138,6 +144,7 @@ purple_sha1_cipher_class_init(PurpleSHA1
 	cipher_class->digest = purple_sha1_cipher_digest;
 	cipher_class->get_digest_size = purple_sha1_cipher_get_digest_size;
 	cipher_class->get_block_size = purple_sha1_cipher_get_block_size;
+	cipher_class->get_name = purple_sha1_cipher_get_name;
 
 	g_type_class_add_private(klass, sizeof(PurpleSHA1CipherPrivate));
 }
diff --git a/libpurple/ciphers/sha256.c b/libpurple/ciphers/sha256.c
--- a/libpurple/ciphers/sha256.c
+++ b/libpurple/ciphers/sha256.c
@@ -107,6 +107,12 @@ purple_sha256_cipher_get_digest_size(Pur
 	return g_checksum_type_get_length(G_CHECKSUM_SHA256);
 }
 
+static const gchar*
+purple_sha256_cipher_get_name(PurpleCipher *cipher)
+{
+	return "sha256";
+}
+
 /******************************************************************************
  * Object Stuff
  *****************************************************************************/
@@ -138,6 +144,7 @@ purple_sha256_cipher_class_init(PurpleSH
 	cipher_class->digest = purple_sha256_cipher_digest;
 	cipher_class->get_digest_size = purple_sha256_cipher_get_digest_size;
 	cipher_class->get_block_size = purple_sha256_cipher_get_block_size;
+	cipher_class->get_name = purple_sha256_cipher_get_name;
 
 	g_type_class_add_private(klass, sizeof(PurpleSHA256CipherPrivate));
 }



More information about the Commits mailing list