Split PurpleKeyValuePair out to it's own file and try to do some cleanup in the files that need to include it.

Thu, 30 Apr 2020 23:43:54 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 30 Apr 2020 23:43:54 -0500
changeset 40350
72271baf92bc
parent 40349
649f7720b294
child 40351
79cbdc5c5989

Split PurpleKeyValuePair out to it's own file and try to do some cleanup in the files that need to include it.

doc/reference/libpurple/libpurple-docs.xml file | annotate | diff | comparison | revisions
finch/gntaccount.c file | annotate | diff | comparison | revisions
finch/gntplugin.c file | annotate | diff | comparison | revisions
finch/gntrequest.c file | annotate | diff | comparison | revisions
libpurple/group.h file | annotate | diff | comparison | revisions
libpurple/media/backend-fs2.c file | annotate | diff | comparison | revisions
libpurple/media/codec.h file | annotate | diff | comparison | revisions
libpurple/meson.build file | annotate | diff | comparison | revisions
libpurple/pluginpref.c file | annotate | diff | comparison | revisions
libpurple/protocol.h file | annotate | diff | comparison | revisions
libpurple/protocols/gg/gg.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/gtalk.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/jingle/rtp.c file | annotate | diff | comparison | revisions
libpurple/protocols/jabber/xmpp.c file | annotate | diff | comparison | revisions
libpurple/protocols/silc/silc.c file | annotate | diff | comparison | revisions
libpurple/purpleaccountoption.c file | annotate | diff | comparison | revisions
libpurple/purplekeyvaluepair.c file | annotate | diff | comparison | revisions
libpurple/purplekeyvaluepair.h file | annotate | diff | comparison | revisions
libpurple/request.c file | annotate | diff | comparison | revisions
libpurple/util.c file | annotate | diff | comparison | revisions
libpurple/util.h file | annotate | diff | comparison | revisions
pidgin/gtkaccount.c file | annotate | diff | comparison | revisions
pidgin/gtkprefs.c file | annotate | diff | comparison | revisions
pidgin/gtkrequest.c file | annotate | diff | comparison | revisions
--- a/doc/reference/libpurple/libpurple-docs.xml	Thu Apr 30 20:57:31 2020 -0500
+++ b/doc/reference/libpurple/libpurple-docs.xml	Thu Apr 30 23:43:54 2020 -0500
@@ -66,6 +66,7 @@
       <xi:include href="xml/purple-gio.xml" />
       <xi:include href="xml/purpleaccountoption.xml" />
       <xi:include href="xml/purpleaccountusersplit.xml" />
+      <xi:include href="xml/purplekeyvaluepair.xml" />
       <xi:include href="xml/purpleprotocolfactory.xml" />
       <xi:include href="xml/purpleuiinfo.xml" />
       <xi:include href="xml/queuedoutputstream.xml" />
--- a/finch/gntaccount.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/finch/gntaccount.c	Thu Apr 30 23:43:54 2020 -0500
@@ -36,13 +36,7 @@
 
 #include "finch.h"
 
-#include <account.h>
-#include <connection.h>
-#include <notify.h>
-#include <plugins.h>
-#include <purpleaccountoption.h>
-#include <request.h>
-#include <savedstatuses.h>
+#include <purple.h>
 
 #include "gntaccount.h"
 #include "gntblist.h"
--- a/finch/gntplugin.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/finch/gntplugin.c	Thu Apr 30 23:43:54 2020 -0500
@@ -32,9 +32,7 @@
 
 #include "finch.h"
 
-#include "debug.h"
-#include "notify.h"
-#include "request.h"
+#include <purple.h>
 
 #include "gntplugin.h"
 #include "gntrequest.h"
--- a/finch/gntrequest.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/finch/gntrequest.c	Thu Apr 30 23:43:54 2020 -0500
@@ -35,8 +35,8 @@
 
 #include "finch.h"
 #include "gntrequest.h"
-#include "debug.h"
-#include "util.h"
+
+#include <purple.h>
 
 typedef struct
 {
--- a/libpurple/group.h	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/group.h	Thu Apr 30 23:43:54 2020 -0500
@@ -43,7 +43,6 @@
 #include "account.h"
 #include "blistnode.h"
 #include "buddyicon.h"
-#include "media.h"
 #include "presence.h"
 #include "status.h"
 
--- a/libpurple/media/backend-fs2.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/media/backend-fs2.c	Thu Apr 30 23:43:54 2020 -0500
@@ -28,6 +28,7 @@
 #include "debug.h"
 #include "network.h"
 #include "media-gst.h"
+#include <purplekeyvaluepair.h>
 
 #include <farstream/fs-conference.h>
 #include <farstream/fs-element-added-notifier.h>
--- a/libpurple/media/codec.h	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/media/codec.h	Thu Apr 30 23:43:54 2020 -0500
@@ -37,7 +37,7 @@
  */
 typedef struct _PurpleMediaCodec PurpleMediaCodec;
 
-#include "../util.h"
+#include <purplekeyvaluepair.h>
 
 #include <glib-object.h>
 
--- a/libpurple/meson.build	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/meson.build	Thu Apr 30 23:43:54 2020 -0500
@@ -48,6 +48,7 @@
 	'purple-gio.c',
 	'purpleaccountoption.c',
 	'purpleaccountusersplit.c',
+	'purplekeyvaluepair.c',
 	'purpleprotocolfactory.c',
 	'purpleuiinfo.c',
 	'queuedoutputstream.c',
@@ -125,6 +126,7 @@
 	'purple-gio.h',
 	'purpleaccountoption.h',
 	'purpleaccountusersplit.h',
+	'purplekeyvaluepair.h',
 	'purpleprotocolfactory.h',
 	'purpleuiinfo.h',
 	'queuedoutputstream.h',
--- a/libpurple/pluginpref.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/pluginpref.c	Thu Apr 30 23:43:54 2020 -0500
@@ -29,6 +29,7 @@
 #include "internal.h"
 #include "pluginpref.h"
 #include "prefs.h"
+#include "purplekeyvaluepair.h"
 
 struct _PurplePluginPrefFrame
 {
--- a/libpurple/protocol.h	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/protocol.h	Thu Apr 30 23:43:54 2020 -0500
@@ -46,7 +46,6 @@
 #include "debug.h"
 #include "xfer.h"
 #include "image.h"
-#include "media.h"
 #include "message.h"
 #include "notify.h"
 #include "plugins.h"
--- a/libpurple/protocols/gg/gg.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/protocols/gg/gg.c	Thu Apr 30 23:43:54 2020 -0500
@@ -28,17 +28,7 @@
 
 #include <internal.h>
 
-#include "action.h"
-#include "plugins.h"
-#include "version.h"
-#include "notify.h"
-#include "buddylist.h"
-#include "purpleaccountoption.h"
-#include "core.h"
-#include "debug.h"
-#include "util.h"
-#include "request.h"
-#include "xmlnode.h"
+#include <purple.h>
 
 #include "gg.h"
 #include "chat.h"
--- a/libpurple/protocols/jabber/gtalk.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/protocols/jabber/gtalk.c	Thu Apr 30 23:43:54 2020 -0500
@@ -21,10 +21,7 @@
  */
 
 #include "internal.h"
-#include "chat.h"
-#include "core.h"
-#include "plugins.h"
-#include "purpleaccountusersplit.h"
+#include <purple.h>
 
 #include "gtalk.h"
 
--- a/libpurple/protocols/jabber/jingle/rtp.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/protocols/jabber/jingle/rtp.c	Thu Apr 30 23:43:54 2020 -0500
@@ -26,16 +26,15 @@
 
 #ifdef USE_VV
 
+#include <purple.h>
+
 #include "jabber.h"
 #include "jingle.h"
 #include "google/google_p2p.h"
-#include "media.h"
-#include "mediamanager.h"
 #include "iceudp.h"
 #include "rawudp.h"
 #include "rtp.h"
 #include "session.h"
-#include "debug.h"
 
 #include <string.h>
 
--- a/libpurple/protocols/jabber/xmpp.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/protocols/jabber/xmpp.c	Thu Apr 30 23:43:54 2020 -0500
@@ -21,10 +21,7 @@
  */
 
 #include "internal.h"
-#include "chat.h"
-#include "core.h"
-#include "plugins.h"
-#include "purpleaccountusersplit.h"
+#include <purple.h>
 
 #include "xmpp.h"
 
--- a/libpurple/protocols/silc/silc.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/protocols/silc/silc.c	Thu Apr 30 23:43:54 2020 -0500
@@ -18,13 +18,13 @@
 */
 
 #include "internal.h"
-#include "plugins.h"
+#include <purple.h>
+
 PURPLE_BEGIN_IGNORE_CAST_ALIGN
 #include "silc.h"
 PURPLE_END_IGNORE_CAST_ALIGN
 #include "silcclient.h"
 #include "silcpurple.h"
-#include "version.h"
 #include "wb.h"
 #include "core.h"
 
--- a/libpurple/purpleaccountoption.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/purpleaccountoption.c	Thu Apr 30 23:43:54 2020 -0500
@@ -20,9 +20,9 @@
  */
 #include "internal.h"
 
+#include "prefs.h"
 #include "purpleaccountoption.h"
-#include "prefs.h"
-#include "util.h"
+#include "purplekeyvaluepair.h"
 
 /*
  * An option for an account.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purplekeyvaluepair.c	Thu Apr 30 23:43:54 2020 -0500
@@ -0,0 +1,65 @@
+/*
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "purplekeyvaluepair.h"
+
+G_DEFINE_BOXED_TYPE(PurpleKeyValuePair, purple_key_value_pair,
+                    purple_key_value_pair_copy, purple_key_value_pair_free);
+
+PurpleKeyValuePair *
+purple_key_value_pair_new(const gchar *key, gpointer value) {
+	return purple_key_value_pair_new_full(key, value, NULL);
+}
+
+PurpleKeyValuePair *
+purple_key_value_pair_new_full(const gchar *key, gpointer value,
+                               GDestroyNotify value_destroy_func)
+{
+	PurpleKeyValuePair *kvp;
+
+	kvp = g_new0(PurpleKeyValuePair, 1);
+	kvp->key = g_strdup(key);
+	kvp->value = value;
+	kvp->value_destroy_func = value_destroy_func;
+
+	return kvp;
+}
+
+void
+purple_key_value_pair_free(PurpleKeyValuePair *kvp) {
+	g_return_if_fail(kvp != NULL);
+
+	g_free(kvp->key);
+
+	if(kvp->value_destroy_func) {
+		kvp->value_destroy_func(kvp->value);
+	}
+
+	g_free(kvp);
+}
+
+PurpleKeyValuePair *
+purple_key_value_pair_copy(PurpleKeyValuePair *kvp) {
+	g_return_val_if_fail(kvp != NULL, NULL);
+
+	return purple_key_value_pair_new_full(kvp->key, kvp->value,
+	                                      kvp->value_destroy_func);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/purplekeyvaluepair.h	Thu Apr 30 23:43:54 2020 -0500
@@ -0,0 +1,120 @@
+/*
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PURPLE_KEY_VALUE_PAIR_H
+#define PURPLE_KEY_VALUE_PAIR_H
+
+/**
+ * SECTION:purplekeyvaluepair
+ * @section_id: libpurple-key-value-pair
+ * @short_description: <filename>purplekeyvaluepair.h</filename>
+ * @title: Key Value Pairs
+ */
+
+#define PURPLE_TYPE_KEY_VALUE_PAIR (purple_key_value_pair_get_type())
+
+/**
+ * PurpleKeyValuePair:
+ * @key: The key
+ * @value: The value
+ * @value_destroy_func: A #GDestroyNotify to free @value when
+ *                      purple_key_value_pair_free() is called.
+ *
+ * A key-value pair.
+ *
+ * This is used by, among other things, purple_gtk_combo* functions to pass in
+ * a list of key-value pairs so it can display a user-friendly value.
+ */
+typedef struct _PurpleKeyValuePair PurpleKeyValuePair;
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+struct _PurpleKeyValuePair {
+	gchar *key;
+	gpointer value;
+	GDestroyNotify value_destroy_func;
+};
+
+/**
+ * purple_key_value_pair_get_type:
+ *
+ * The standard %_GET_TYPE function for #PurpleKeyValuePair.
+ *
+ * Returns: The #GType for #PurpleKeyValuePair.
+ */
+GType purple_key_value_pair_get_type(void);
+
+/**
+ * purple_key_value_pair_new:
+ * @key: The key part of PurpleKeyValuePair
+ * @value: The value part of PurpleKeyValuePair
+ *
+ * Creates a new PurpleKeyValuePair allocating memory for @key,
+ * free value function is NULL.
+ *
+ * Returns: (transfer full): The created PurpleKeyValuePair
+ *
+ * Since: 3.0.0
+ */
+PurpleKeyValuePair *purple_key_value_pair_new(const gchar *key, gpointer value);
+
+/**
+ * purple_key_value_pair_new_full:
+ * @key: The key part of PurpleKeyValuePair
+ * @value: The value part of PurpleKeyValuePair
+ * @value_destroy_func: a function to free the memory for the @value
+ *
+ * Creates a new PurpleKeyValuePair allocating memory for @key,
+ * set free value function to @value_destroy_func.
+ *
+ * Returns: (transfer full): The created PurpleKeyValuePair
+ *
+ * Since: 3.0.0
+ */
+PurpleKeyValuePair *purple_key_value_pair_new_full(const gchar *key, gpointer value, GDestroyNotify value_destroy_func);
+
+/**
+ * purple_key_value_pair_free:
+ * @kvp: The PurpleKeyValuePair to free.
+ *
+ * Frees @kvp.
+ *
+ * Since: 3.0.0
+ */
+void purple_key_value_pair_free(PurpleKeyValuePair *kvp);
+
+/**
+ * purple_key_value_pair_copy:
+ * @kvp: The #PurpleKeyValuePair to copy.
+ *
+ * Creates a copy of @kvp.
+ *
+ * Returns: (transfer full): A new copy of @kvp.
+ */
+PurpleKeyValuePair *purple_key_value_pair_copy(PurpleKeyValuePair *kvp);
+
+G_END_DECLS
+
+#endif /* PURPLE_KEY_VALUE_PAIR_H */
+
--- a/libpurple/request.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/request.c	Thu Apr 30 23:43:54 2020 -0500
@@ -24,6 +24,7 @@
 #include "notify.h"
 #include "request.h"
 #include "debug.h"
+#include "purplekeyvaluepair.h"
 
 static PurpleRequestUiOps *request_ui_ops = NULL;
 static GList *handles = NULL;
--- a/libpurple/util.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/util.c	Thu Apr 30 23:43:54 2020 -0500
@@ -3782,43 +3782,6 @@
 	return g_string_free(string, FALSE);
 }
 
-PurpleKeyValuePair *
-purple_key_value_pair_new(const char *key, gpointer value)
-{
-	PurpleKeyValuePair *kvp;
-
-	kvp = g_new0(PurpleKeyValuePair, 1);
-	kvp->key = g_strdup(key);
-	kvp->value = value;
-	kvp->value_destroy_func = NULL;
-
-	return kvp;
-}
-
-PurpleKeyValuePair *
-purple_key_value_pair_new_full(const char *key, gpointer value, GDestroyNotify value_destroy_func)
-{
-	PurpleKeyValuePair *kvp = purple_key_value_pair_new(key, value);
-
-	kvp->value_destroy_func = value_destroy_func;
-
-	return kvp;
-}
-
-void
-purple_key_value_pair_free(PurpleKeyValuePair *kvp)
-{
-	g_return_if_fail(kvp != NULL);
-
-	g_free(kvp->key);
-
-	if (kvp->value_destroy_func) {
-		kvp->value_destroy_func(kvp->value);
-	}
-
-	g_free(kvp);
-}
-
 gchar *
 purple_uuid_random(void)
 {
--- a/libpurple/util.h	Thu Apr 30 20:57:31 2020 -0500
+++ b/libpurple/util.h	Thu Apr 30 23:43:54 2020 -0500
@@ -33,18 +33,6 @@
 
 #include <stdio.h>
 
-/**
- * PurpleKeyValuePair:
- * @key: The key
- * @value: The value
- *
- * A key-value pair.
- *
- * This is used by, among other things, purple_gtk_combo* functions to pass in a
- * list of key-value pairs so it can display a user-friendly value.
- */
-typedef struct _PurpleKeyValuePair PurpleKeyValuePair;
-
 #include "account.h"
 #include "signals.h"
 #include "xmlnode.h"
@@ -54,13 +42,6 @@
 
 typedef char *(*PurpleInfoFieldFormatCallback)(const char *field, size_t len);
 
-struct _PurpleKeyValuePair
-{
-	gchar *key;
-	void *value;
-	GDestroyNotify value_destroy_func;
-};
-
 G_BEGIN_DECLS
 
 /**
@@ -88,45 +69,6 @@
 char * purple_util_format_song_info(const char *title, const char *artist,
 		const char *album, gpointer unused);
 
-/**
- * purple_key_value_pair_new:
- * @key:  The key part of PurpleKeyValuePair
- * @value:  The value part of PurpleKeyValuePair
- *
- * Creates a new PurpleKeyValuePair allocating memory for @key,
- * free value function is NULL.
- *
- * Returns:  The created PurpleKeyValuePair
- *
- * Since: 3.0.0
- */
-PurpleKeyValuePair *purple_key_value_pair_new(const char *key, gpointer value);
-
-/**
- * purple_key_value_pair_new_full:
- * @key:  The key part of PurpleKeyValuePair
- * @value:  The value part of PurpleKeyValuePair
- * @value_destroy_func: a function to free the memory for the @value
- *
- * Creates a new PurpleKeyValuePair allocating memory for @key,
- * set free value function to @value_destroy_func.
- *
- * Returns:  The created PurpleKeyValuePair
- *
- * Since: 3.0.0
- */
-PurpleKeyValuePair *purple_key_value_pair_new_full(const char *key, gpointer value, GDestroyNotify value_destroy_func);
-
-/**
- * purple_key_value_pair_free:
- * @kvp:  The PurpleKeyValuePair to free.
- *
- * Frees @kvp.
- *
- * Since: 3.0.0
- */
-void purple_key_value_pair_free(PurpleKeyValuePair *kvp);
-
 /**************************************************************************/
 /* Utility Subsystem                                                      */
 /**************************************************************************/
--- a/pidgin/gtkaccount.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/pidgin/gtkaccount.c	Thu Apr 30 23:43:54 2020 -0500
@@ -22,18 +22,7 @@
 #include "internal.h"
 #include "pidgin.h"
 
-#include "account.h"
-#include "core.h"
-#include "debug.h"
-#include "notify.h"
-#include "plugins.h"
-#include "prefs.h"
-#include "protocol.h"
-#include "purpleaccountoption.h"
-#include "request.h"
-#include "savedstatuses.h"
-#include "signals.h"
-#include "util.h"
+#include <purple.h>
 
 #include "gtkaccount.h"
 #include "gtkblist.h"
--- a/pidgin/gtkprefs.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/pidgin/gtkprefs.c	Thu Apr 30 23:43:54 2020 -0500
@@ -24,22 +24,7 @@
 #include "internal.h"
 #include "pidgin.h"
 
-#include "debug.h"
-#include "nat-pmp.h"
-#include "notify.h"
-#include "prefs.h"
-#include "proxy.h"
-#include "protocol.h"
-#include "request.h"
-#include "savedstatuses.h"
-#include "sound.h"
-#include "sound-theme.h"
-#include "stun.h"
-#include "theme-manager.h"
-#include "upnp.h"
-#include "util.h"
-#include "network.h"
-#include "keyring.h"
+#include <purple.h>
 
 #include "gtkblist.h"
 #include "gtkconv.h"
--- a/pidgin/gtkrequest.c	Thu Apr 30 20:57:31 2020 -0500
+++ b/pidgin/gtkrequest.c	Thu Apr 30 23:43:54 2020 -0500
@@ -24,9 +24,7 @@
 #include "internal.h"
 #include "pidgin.h"
 
-#include "debug.h"
-#include "prefs.h"
-#include "util.h"
+#include <purple.h>
 
 #include "gtkrequest.h"
 #include "gtkutils.h"

mercurial