caesarcipher: Remove in preparation of removing PurpleCipher

Thu, 29 Sep 2016 20:05:55 -0500

author
Mike Ruprecht <cmaiku@gmail.com>
date
Thu, 29 Sep 2016 20:05:55 -0500
changeset 38410
da125623534f
parent 38409
751fa9e1fc8e
child 38411
b7f2d7c563fb

caesarcipher: Remove in preparation of removing PurpleCipher

libpurple/plugins/Makefile.am file | annotate | diff | comparison | revisions
libpurple/plugins/caesarcipher.c file | annotate | diff | comparison | revisions
libpurple/plugins/caesarcipher.h file | annotate | diff | comparison | revisions
libpurple/plugins/caesarcipher_consumer.c file | annotate | diff | comparison | revisions
--- a/libpurple/plugins/Makefile.am	Fri Jun 16 16:00:15 2017 -0500
+++ b/libpurple/plugins/Makefile.am	Thu Sep 29 20:05:55 2016 -0500
@@ -11,8 +11,6 @@
 
 autoaccept_la_LDFLAGS         = -module @PLUGIN_LDFLAGS@
 buddynote_la_LDFLAGS          = -module @PLUGIN_LDFLAGS@
-caesarcipher_la_LDFLAGS          = -module @PLUGIN_LDFLAGS@
-caesarcipher_consumer_la_LDFLAGS = -module @PLUGIN_LDFLAGS@
 codeinline_la_LDFLAGS         = -module @PLUGIN_LDFLAGS@
 debug_example_la_LDFLAGS      = -module @PLUGIN_LDFLAGS@
 helloworld_la_LDFLAGS         = -module @PLUGIN_LDFLAGS@
@@ -44,8 +42,6 @@
 	statenotify.la
 
 noinst_LTLIBRARIES = \
-	caesarcipher.la \
-	caesarcipher_consumer.la \
 	codeinline.la \
 	debug_example.la \
 	helloworld.la \
@@ -58,8 +54,6 @@
 
 autoaccept_la_SOURCES       = autoaccept.c
 buddynote_la_SOURCES        = buddynote.c
-caesarcipher_la_SOURCES     = caesarcipher.c caesarcipher.h
-caesarcipher_consumer_la_SOURCES = caesarcipher_consumer.c
 codeinline_la_SOURCES		= codeinline.c
 debug_example_la_SOURCES = debug_example.c
 helloworld_la_SOURCES       = helloworld.c
@@ -77,8 +71,6 @@
 
 autoaccept_la_LIBADD         = @PURPLE_LIBS@
 buddynote_la_LIBADD          = @PURPLE_LIBS@
-caesarcipher_la_LIBADD          = @PURPLE_LIBS@
-caesarcipher_consumer_la_LIBADD = @PURPLE_LIBS@
 codeinline_la_LIBADD         = @PURPLE_LIBS@
 idle_la_LIBADD               = @PURPLE_LIBS@
 joinpart_la_LIBADD           = @PURPLE_LIBS@
--- a/libpurple/plugins/caesarcipher.c	Fri Jun 16 16:00:15 2017 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-/*
- * An example plugin that demonstrates exporting of a cipher object
- * type to be used in another plugin.
- *
- * This plugin only provides the CaesarCipher type. See caesarcipher_consumer
- * plugin for its use.
- *
- * Copyright (C) 2013, Ankit Vani <a@nevitus.org>
- *
- * 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.
- */
-
-/* When writing a third-party plugin, do not include libpurple's internal.h
- * included below. This file is for internal libpurple use only. We're including
- * it here for our own convenience. */
-#include "internal.h"
-
-/* This file defines PURPLE_PLUGINS and includes all the libpurple headers */
-#include <purple.h>
-
-#include "caesarcipher.h"
-
-#define CAESAR_CIPHER_GET_PRIVATE(obj) \
-	(G_TYPE_INSTANCE_GET_PRIVATE((obj), CAESAR_TYPE_CIPHER, CaesarCipherPrivate))
-
-typedef struct {
-	gint8 offset;
-} CaesarCipherPrivate;
-
-enum {
-	PROP_NONE,
-	PROP_OFFSET,
-	PROP_LAST,
-};
-
-/******************************************************************************
- * Cipher stuff
- *****************************************************************************/
-static void
-caesar_shift(const guchar input[], size_t in_len, guchar output[], gint8 offset)
-{
-	size_t i;
-
-	for (i = 0; i < in_len; ++i) {
-		if (input[i] >= 'a' && input[i] <= 'z')
-			output[i] = (((input[i] - 'a') + offset + 26) % 26) + 'a';
-		else if (input[i] >= 'A' && input[i] <= 'Z')
-			output[i] = (((input[i] - 'A') + offset + 26) % 26) + 'A';
-		else
-			output[i] = input[i];
-	}
-
-	output[i] = '\0';
-}
-
-static void
-caesar_cipher_set_offset(PurpleCipher *cipher, gint8 offset)
-{
-	CaesarCipherPrivate *priv = CAESAR_CIPHER_GET_PRIVATE(cipher);
-
-	priv->offset = offset % 26;
-}
-
-static ssize_t
-caesar_cipher_encrypt(PurpleCipher *cipher, const guchar input[], size_t in_len,
-		guchar output[], size_t out_size)
-{
-	CaesarCipherPrivate *priv = CAESAR_CIPHER_GET_PRIVATE(cipher);
-
-	g_return_val_if_fail(out_size > in_len, -1);
-
-	caesar_shift(input, in_len, output, priv->offset);
-
-	return in_len;
-}
-
-static ssize_t
-caesar_cipher_decrypt(PurpleCipher *cipher, const guchar input[], size_t in_len,
-		guchar output[], size_t out_size)
-{
-	CaesarCipherPrivate *priv = CAESAR_CIPHER_GET_PRIVATE(cipher);
-
-	g_return_val_if_fail(out_size > in_len, -1);
-
-	caesar_shift(input, in_len, output, -priv->offset);
-
-	return in_len;
-}
-
-static void
-caesar_cipher_set_key(PurpleCipher *cipher, const guchar *key, size_t len)
-{
-	caesar_cipher_set_offset(cipher, len);
-}
-
-/******************************************************************************
- * Object stuff
- *****************************************************************************/
-static void
-caesar_cipher_set_property(GObject *obj, guint param_id, const GValue *value,
-		GParamSpec *pspec)
-{
-	PurpleCipher *cipher = PURPLE_CIPHER(obj);
-
-	switch(param_id) {
-		case PROP_OFFSET:
-			caesar_cipher_set_offset(cipher, g_value_get_schar(value));
-			break;
-		default:
-			G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
-			break;
-	}
-}
-
-/* initialize the cipher object. used in PURPLE_DEFINE_TYPE. */
-static void
-caesar_cipher_init(CaesarCipher *cipher)
-{
-	/* classic caesar cipher uses a shift of 3 */
-	CAESAR_CIPHER_GET_PRIVATE(cipher)->offset = 3;
-}
-
-/* initialize the cipher class. used in PURPLE_DEFINE_TYPE. */
-static void
-caesar_cipher_class_init(PurpleCipherClass *klass)
-{
-	GObjectClass *obj_class = G_OBJECT_CLASS(klass);
-
-	obj_class->set_property = caesar_cipher_set_property;
-	g_type_class_add_private(obj_class, sizeof(CaesarCipherPrivate));
-
-	klass->encrypt  = caesar_cipher_encrypt;
-	klass->decrypt  = caesar_cipher_decrypt;
-	klass->set_key  = caesar_cipher_set_key;
-
-	g_object_class_install_property(obj_class, PROP_OFFSET,
-		g_param_spec_char("offset", "offset",
-			"The offset by which to shift alphabets",
-			-25, 25, 3,
-			G_PARAM_WRITABLE)
-	);
-}
-
-/*
- * define the CaesarCipher type. this function defines
- * caesar_cipher_get_type() and caesar_cipher_register_type().
- */
-PURPLE_DEFINE_TYPE(CaesarCipher, caesar_cipher, PURPLE_TYPE_CIPHER);
-
-G_MODULE_EXPORT PurpleCipher *
-caesar_cipher_new(void)
-{
-	return g_object_new(CAESAR_TYPE_CIPHER, NULL);
-}
-
-/******************************************************************************
- * Plugin stuff
- *****************************************************************************/
-static PurplePluginInfo *
-plugin_query(GError **error)
-{
-	const gchar * const authors[] = {
-		"Ankit Vani <a@nevitus.org>",
-		NULL
-	};
-
-	return purple_plugin_info_new(
-		"id",           "core-caesarcipher",
-		"name",         N_("Caesar Cipher Provider Example"),
-		"version",      DISPLAY_VERSION,
-		"category",     N_("Example"),
-		"summary",      N_("An example plugin that demonstrates exporting of a "
-		                   "cipher type."),
-		"description",  N_("An example plugin that demonstrates exporting of "
-		                   "a cipher object type to be used in another "
-		                   "plugin."),
-		"authors",      authors,
-		"website",      PURPLE_WEBSITE,
-		"abi-version",  PURPLE_ABI_VERSION,
-		NULL
-	);
-}
-
-static gboolean
-plugin_load(PurplePlugin *plugin, GError **error)
-{
-	/* register the CaesarCipher type in the type system */
-	caesar_cipher_register_type(plugin);
-
-	return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin, GError **error)
-{
-	return TRUE;
-}
-
-PURPLE_PLUGIN_INIT(caesarcipher, plugin_query, plugin_load, plugin_unload);
--- a/libpurple/plugins/caesarcipher.h	Fri Jun 16 16:00:15 2017 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,67 +0,0 @@
-/*
- * An example plugin that demonstrates exporting of a cipher object
- * type to be used in another plugin.
- *
- * Copyright (C) 2013, Ankit Vani <a@nevitus.org>
- *
- * 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 _CAESAR_CIPHER_H_
-#define _CAESAR_CIPHER_H_
-
-#include "cipher.h"
-
-#define CAESAR_TYPE_CIPHER             (caesar_cipher_get_type())
-#define CAESAR_CIPHER(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj), CAESAR_TYPE_CIPHER, CaesarCipher))
-#define CAESAR_CIPHER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass), CAESAR_TYPE_CIPHER, CaesarCipherClass))
-#define CAESAR_IS_CIPHER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj), CAESAR_TYPE_CIPHER))
-#define CAESAR_IS_CIPHER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass), CAESAR_TYPE_CIPHER))
-#define CAESAR_CIPHER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj), CAESAR_TYPE_CIPHER, CaesarCipherClass))
-
-typedef struct _CaesarCipher CaesarCipher;
-typedef struct _CaesarCipherClass CaesarCipherClass;
-
-/*
- * A caesar cipher object.
- *
- * The Caesar cipher is one of the simplest and most widely known encryption
- * techniques. It is a type of substitution cipher in which each letter in the
- * plaintext is replaced by a letter some fixed number of positions down the
- * alphabet.
- */
-struct _CaesarCipher
-{
-	PurpleCipher gparent;
-};
-
-/* The base class for all CaesarCipher's. */
-struct _CaesarCipherClass
-{
-	PurpleCipherClass gparent;
-};
-
-/*
- * Returns the GType for the CaesarCipher object.
- */
-G_MODULE_EXPORT GType caesar_cipher_get_type(void);
-
-/*
- * Creates a new CaesarCipher instance and returns it.
- */
-G_MODULE_EXPORT PurpleCipher *caesar_cipher_new(void);
-
-#endif /* _CAESAR_CIPHER_H_ */
--- a/libpurple/plugins/caesarcipher_consumer.c	Fri Jun 16 16:00:15 2017 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-/*
- * An example plugin that demonstrates usage of a cipher object type
- * registered in another plugin.
- *
- * This plugin requires the caesarcipher plugin to be loaded to use the
- * CaesarCipher type.
- *
- * Copyright (C) 2013, Ankit Vani <a@nevitus.org>
- *
- * 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.
- */
-
-/* When writing a third-party plugin, do not include libpurple's internal.h
- * included below. This file is for internal libpurple use only. We're including
- * it here for our own convenience. */
-#include "internal.h"
-
-/* This file defines PURPLE_PLUGINS and includes all the libpurple headers */
-#include <purple.h>
-
-#include "caesarcipher.h"
-
-static void
-debug_cipher(PurpleCipher *cipher, const gchar *input)
-{
-	gchar ciphertext[512], plaintext[512];
-
-	purple_debug_info("caesarcipher_consumer", "Encrypting...");
-
-	purple_debug_info("caesarcipher_consumer", "INPUT:  %s\n", input);
-	purple_cipher_encrypt(cipher, (const guchar *)input, strlen(input),
-			(guchar *)ciphertext, 512);
-	purple_debug_info("caesarcipher_consumer", "OUTPUT: %s\n", ciphertext);
-
-	purple_debug_info("caesarcipher_consumer", "Decrypting...");
-
-	purple_debug_info("caesarcipher_consumer", "INPUT:  %s\n", ciphertext);
-	purple_cipher_decrypt(cipher, (const guchar *)ciphertext,
-			strlen(ciphertext), (guchar *)plaintext, 512);
-	purple_debug_info("caesarcipher_consumer", "OUTPUT: %s\n", plaintext);
-}
-
-static PurplePluginInfo *
-plugin_query(GError **error)
-{
-	const gchar * const authors[] = {
-		"Ankit Vani <a@nevitus.org>",
-		NULL
-	};
-
-	/* we need to ensure the object provider is loaded for its type to be
-	 * registered in the type system. */
-	const gchar * const dependencies[] = {
-		"core-caesarcipher",
-		NULL
-	};
-
-	return purple_plugin_info_new(
-		"id",            "core-caesarcipher_consumer",
-		"name",          N_("Caesar Cipher Consumer Example"),
-		"version",       DISPLAY_VERSION,
-		"category",      N_("Example"),
-		"summary",       N_("An example plugin that demonstrates usage of a "
-		                    "loaded cipher type."),
-		"description",   N_("An example plugin that demonstrates usage of "
-		                    "a cipher object type registered in another "
-		                    "plugin."),
-		"authors",       authors,
-		"website",       PURPLE_WEBSITE,
-		"abi-version",   PURPLE_ABI_VERSION,
-		"dependencies",  dependencies,
-
-		NULL
-	);
-}
-
-static gboolean
-plugin_load(PurplePlugin *plugin, GError **error)
-{
-	PurpleCipher *cipher = caesar_cipher_new();
-	purple_debug_info("caesarcipher_consumer", "Created caesar cipher "
-	                                           "object.\n");
-
-	debug_cipher(cipher, "Input string for cipher!");
-
-	purple_cipher_set_key(cipher, NULL, 13);
-	purple_debug_info("caesarcipher_consumer", "Offset set to 13.\n");
-
-	debug_cipher(cipher, "An0ther input 4 cipher..");
-
-	g_object_unref(cipher);
-	purple_debug_info("caesarcipher_consumer", "Destroyed caesar cipher "
-	                                           "object.\n");
-
-	return TRUE;
-}
-
-static gboolean
-plugin_unload(PurplePlugin *plugin, GError **error)
-{
-	return TRUE;
-}
-
-PURPLE_PLUGIN_INIT(caesarcipher_consumer, plugin_query, plugin_load, plugin_unload);

mercurial