Merged in rw_grim/pidgin (pull request #301)

Tue, 26 Dec 2017 05:28:40 +0000

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 26 Dec 2017 05:28:40 +0000
changeset 38815
bc7b43e17b3a
parent 38808
42859bc2eb8f (diff)
parent 38814
e06f252d2edf (current diff)
child 38817
6ac0c00dd6ad

Merged in rw_grim/pidgin (pull request #301)

Remove #if 0's from libpurple

Approved-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>

--- a/doc/reference/libpurple/libpurple-docs.xml	Thu Dec 14 21:27:42 2017 -0600
+++ b/doc/reference/libpurple/libpurple-docs.xml	Tue Dec 26 05:28:40 2017 +0000
@@ -58,6 +58,7 @@
       <xi:include href="xml/nat-pmp.xml" />
       <xi:include href="xml/network.xml" />
       <xi:include href="xml/notify.xml" />
+      <xi:include href="xml/options.xml" />
       <xi:include href="xml/plugins.xml" />
       <xi:include href="xml/prefs.xml" />
       <xi:include href="xml/pluginpref.xml" />
--- a/finch/gntblist.c	Thu Dec 14 21:27:42 2017 -0600
+++ b/finch/gntblist.c	Tue Dec 26 05:28:40 2017 +0000
@@ -127,10 +127,6 @@
 static void add_chat(PurpleChat *chat, FinchBlist *ggblist);
 static void add_node(PurpleBlistNode *node, FinchBlist *ggblist);
 static void node_update(PurpleBuddyList *list, PurpleBlistNode *node);
-#if 0
-static gboolean is_contact_online(PurpleContact *contact);
-static gboolean is_group_online(PurpleGroup *group);
-#endif
 static void draw_tooltip(FinchBlist *ggblist);
 static void tooltip_for_buddy(PurpleBuddy *buddy, GString *str, gboolean full);
 static gboolean remove_typing_cb(gpointer null);
@@ -385,27 +381,6 @@
 		fnode = purple_blist_node_get_ui_data(node);
 		if (fnode && fnode->signed_timer)
 			flag |= GNT_TEXT_FLAG_BLINK;
-	} else if (PURPLE_IS_GROUP(node)) {
-		/* If the node is collapsed, then check to see if any of the priority buddies of
-		 * any of the contacts within this group recently signed on/off, and set the blink
-		 * flag appropriately. */
-		/* XXX: Refs #5444 */
-		/* XXX: there's no way I can ask if the node is expanded or not? *sigh*
-		 * API addition would be necessary */
-#if 0
-		if (!gnt_tree_get_expanded(GNT_TREE(ggblist->tree), node)) {
-			for (node = purple_blist_node_get_first_child(node); node;
-					node = purple_blist_node_get_sibling_next(node)) {
-				PurpleBlistNode *pnode;
-				pnode = purple_contact_get_priority_buddy((PurpleContact*)node);
-				fnode = purple_blist_node_get_ui_data(node);
-				if (fnode && fnode->signed_timer) {
-					flag |= GNT_TEXT_FLAG_BLINK;
-					break;
-				}
-			}
-		}
-#endif
 	}
 
 	return flag;
@@ -418,37 +393,6 @@
 	gnt_tree_set_row_color(GNT_TREE(ggblist->tree), node, get_display_color(node));
 }
 
-#if 0
-static gboolean
-is_contact_online(PurpleContact *contact)
-{
-	PurpleBlistNode *node;
-	for (node = purple_blist_node_get_first_child(((PurpleBlistNode*)contact)); node;
-			node = purple_blist_node_get_sibling_next(node)) {
-		FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
-		if (PURPLE_BUDDY_IS_ONLINE((PurpleBuddy*)node) ||
-				(fnode && fnode->signed_timer))
-			return TRUE;
-	}
-	return FALSE;
-}
-
-static gboolean
-is_group_online(PurpleGroup *group)
-{
-	PurpleBlistNode *node;
-	for (node = purple_blist_node_get_first_child(((PurpleBlistNode*)group)); node;
-			node = purple_blist_node_get_sibling_next(node)) {
-		if (PURPLE_IS_CHAT(node) &&
-				purple_account_is_connected(((PurpleChat *)node)->account))
-			return TRUE;
-		else if (is_contact_online((PurpleContact*)node))
-			return TRUE;
-	}
-	return FALSE;
-}
-#endif
-
 static void
 new_node(PurpleBlistNode *node)
 {
@@ -999,20 +943,6 @@
 		blist_update_row_flags((PurpleBlistNode*)contact);
 }
 
-#if 0
-static void
-buddy_signed_on(PurpleBuddy *buddy, FinchBlist *ggblist)
-{
-	add_node((PurpleBlistNode*)buddy, ggblist);
-}
-
-static void
-buddy_signed_off(PurpleBuddy *buddy, FinchBlist *ggblist)
-{
-	node_remove(purple_blist_get_buddy_list(), (PurpleBlistNode*)buddy);
-}
-#endif
-
 PurpleBlistUiOps *finch_blist_get_ui_ops()
 {
 	return &blist_ui_ops;
@@ -3127,17 +3057,6 @@
 	purple_signal_connect(purple_blist_get_handle(), "buddy-signed-off", finch_blist_get_handle(),
 				PURPLE_CALLBACK(buddy_signed_on_off), ggblist);
 
-#if 0
-	/* These I plan to use to indicate unread-messages etc. */
-	purple_signal_connect(purple_conversations_get_handle(), "received-im-msg", finch_blist_get_handle(),
-				PURPLE_CALLBACK(received_im_msg), list);
-	purple_signal_connect(purple_conversations_get_handle(), "sent-im-msg", finch_blist_get_handle(),
-				PURPLE_CALLBACK(sent_im_msg), NULL);
-
-	purple_signal_connect(purple_conversations_get_handle(), "received-chat-msg", finch_blist_get_handle(),
-				PURPLE_CALLBACK(received_chat_msg), list);
-#endif
-
 	g_signal_connect(G_OBJECT(ggblist->tree), "selection_changed", G_CALLBACK(selection_changed), ggblist);
 	g_signal_connect(G_OBJECT(ggblist->tree), "key_pressed", G_CALLBACK(key_pressed), ggblist);
 	g_signal_connect(G_OBJECT(ggblist->tree), "context-menu", G_CALLBACK(context_menu), ggblist);
--- a/finch/gntplugin.c	Thu Dec 14 21:27:42 2017 -0600
+++ b/finch/gntplugin.c	Tue Dec 26 05:28:40 2017 +0000
@@ -446,95 +446,6 @@
 	}
 }
 
-#if 0
-static void
-install_selected_file_cb(gpointer handle, const char *filename)
-{
-	/* Try to init the selected file.
-	 * If it succeeds, try to make a copy of the file in $USERDIR/plugins/.
-	 * If the copy succeeds, unload and destroy the plugin in the original
-	 *  location and init+load the new one.
-	 * Select the plugin in the plugin list.
-	 */
-	char *path;
-	PurplePlugin *plugin;
-
-	g_return_if_fail(plugins.window);
-
-	plugin = purple_plugin_probe(filename);
-	if (!plugin) {
-		purple_notify_error(handle, _("Error loading plugin"),
-				_("The selected file is not a valid plugin."),
-				_("Please open the debug window and try again to see the exact error message."), NULL);
-		return;
-	}
-	if (g_list_find(gnt_tree_get_rows(GNT_TREE(plugins.tree)), plugin)) {
-		purple_plugin_load(plugin);
-		gnt_tree_set_choice(GNT_TREE(plugins.tree), plugin, purple_plugin_is_loaded(plugin));
-		gnt_tree_set_selected(GNT_TREE(plugins.tree), plugin);
-		return;
-	}
-
-	path = g_build_filename(purple_user_dir(), "plugins", NULL);
-	if (purple_build_dir(path, S_IRUSR | S_IWUSR | S_IXUSR) == 0) {
-		char *content = NULL;
-		gsize length = 0;
-
-		if (g_file_get_contents(filename, &content, &length, NULL)) {
-			char *file = g_path_get_basename(filename);
-			g_free(path);
-			path = g_build_filename(purple_user_dir(), "plugins", file, NULL);
-			if (purple_util_write_data_to_file_absolute(path, content, length)) {
-				purple_plugin_destroy(plugin);
-				plugin = purple_plugin_probe(path);
-				if (!plugin) {
-					purple_debug_warning("gntplugin", "This is really strange. %s can be loaded, but %s can't!\n",
-							filename, path);
-					g_unlink(path);
-					plugin = purple_plugin_probe(filename);
-				}
-			} else {
-			}
-		}
-		g_free(content);
-	}
-	g_free(path);
-
-	purple_plugin_load(plugin);
-
-	if (plugin->info->type == PURPLE_PLUGIN_LOADER) {
-		GList *cur;
-		for (cur = PURPLE_PLUGIN_LOADER_INFO(plugin)->exts; cur != NULL;
-				cur = cur->next)
-			purple_plugins_probe(cur->data);
-		return;
-	}
-
-	if (plugin->info->type != PURPLE_PLUGIN_STANDARD ||
-			(plugin->info->flags & PURPLE_PLUGIN_FLAG_INVISIBLE) ||
-			plugin->error)
-		return;
-
-	gnt_tree_add_choice(GNT_TREE(plugins.tree), plugin,
-			gnt_tree_create_row(GNT_TREE(plugins.tree), plugin->info->name), NULL, NULL);
-	gnt_tree_set_choice(GNT_TREE(plugins.tree), plugin, purple_plugin_is_loaded(plugin));
-	gnt_tree_set_row_flags(GNT_TREE(plugins.tree), plugin, GNT_TEXT_FLAG_BOLD);
-	gnt_tree_set_selected(GNT_TREE(plugins.tree), plugin);
-}
-
-static void
-install_plugin_cb(GntWidget *w, gpointer null)
-{
-	static int handle;
-
-	purple_request_close_with_handle(&handle);
-	purple_request_file(&handle, _("Select plugin to install"), NULL,
-			FALSE, G_CALLBACK(install_selected_file_cb), NULL,
-			NULL, &handle);
-	g_signal_connect_swapped(G_OBJECT(w), "destroy", G_CALLBACK(purple_request_close_with_handle), &handle);
-}
-#endif
-
 void finch_plugins_show_all(void)
 {
 	GntWidget *window, *tree, *box, *aboot, *button;
@@ -603,13 +514,6 @@
 	box = gnt_hbox_new(FALSE);
 	gnt_box_add_widget(GNT_BOX(window), box);
 
-#if 0
-	button = gnt_button_new(_("Install Plugin..."));
-	gnt_box_add_widget(GNT_BOX(box), button);
-	gnt_util_set_trigger_widget(GNT_WIDGET(tree), GNT_KEY_INS, button);
-	g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(install_plugin_cb), NULL);
-#endif
-
 	button = gnt_button_new(_("Close"));
 	gnt_box_add_widget(GNT_BOX(box), button);
 	g_signal_connect_swapped(G_OBJECT(button), "activate",
--- a/finch/libfinch.c	Thu Dec 14 21:27:42 2017 -0600
+++ b/finch/libfinch.c	Tue Dec 26 05:28:40 2017 +0000
@@ -29,6 +29,7 @@
 #include "glibcompat.h"
 #include "log.h"
 #include "notify.h"
+#include "options.h"
 #include "plugins.h"
 #include "protocol.h"
 #include "pounce.h"
@@ -146,9 +147,6 @@
 		{"config", 'c', 0,
 			G_OPTION_ARG_FILENAME, &opt_config_dir_arg,
 			_("use DIR for config files"), _("DIR")},
-		{"debug", 'd', 0,
-			G_OPTION_ARG_NONE, &debug_enabled,
-			_("print debugging messages to stderr"), NULL},
 		{"nologin", 'n', 0,
 			G_OPTION_ARG_NONE, &opt_nologin,
 			_("don't automatically login"), NULL},
@@ -170,6 +168,9 @@
 	g_option_context_set_summary(context, DISPLAY_VERSION);
 	g_option_context_add_main_entries(context, option_entries, PACKAGE);
 
+	g_option_context_add_group(context, purple_get_option_group());
+	g_option_context_add_group(context, gplugin_get_option_group());
+
 #ifdef G_OS_WIN32
 	/* Handle Unicode filenames on Windows. See GOptionContext docs. */
 	args = g_win32_get_command_line();
--- a/libpurple/meson.build	Thu Dec 14 21:27:42 2017 -0600
+++ b/libpurple/meson.build	Tue Dec 26 05:28:40 2017 +0000
@@ -39,6 +39,7 @@
 	'nat-pmp.c',
 	'network.c',
 	'notify.c',
+	'options.c',
 	'plugins.c',
 	'pluginpref.c',
 	'pounce.c',
@@ -118,6 +119,7 @@
 	'nat-pmp.h',
 	'network.h',
 	'notify.h',
+	'options.h',
 	'plugins.h',
 	'pluginpref.h',
 	'pounce.h',
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/options.c	Tue Dec 26 05:28:40 2017 +0000
@@ -0,0 +1,96 @@
+/* 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"
+
+#include "options.h"
+
+#include "network.h"
+
+/******************************************************************************
+ * Callbacks
+ *****************************************************************************/
+static gboolean
+debug_cb(const gchar *option_name, const gchar *value,
+		gpointer data, GError **error)
+{
+	purple_debug_set_enabled(TRUE);
+
+	if (purple_strequal(value, "colored")) {
+		purple_debug_set_colored(TRUE);
+	}
+
+	return TRUE;
+}
+
+static gboolean
+force_online_cb(const gchar *option_name, const gchar *value,
+                gpointer data, GError **error)
+{
+	purple_network_force_online();
+
+	return TRUE;
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+
+/**
+ * purple_get_option_group:
+ *
+ * Returns a #GOptionGroup for the commandline arguments recognized by
+ * LibPurple.  You should add this option group to your #GOptionContext with
+ * g_option_context_add_group(), if you are using g_option_context_parse() to
+ * parse your commandline arguments.
+ *
+ * Return Value: (transfer full): a #GOptionGroup for the commandline arguments
+ *                                recognized by LibPurple.
+ */
+GOptionGroup *
+purple_get_option_group(void) {
+	GOptionGroup *group = NULL;
+	GOptionEntry entries[] = {
+		{
+			"debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
+			G_OPTION_ARG_CALLBACK, &debug_cb,
+			_("print debugging messages to stdout"),
+			_("[colored]")
+		}, {
+			"force-online", 'f', 0,
+			G_OPTION_ARG_NONE, &force_online_cb,
+			_("force online, regardless of network status"),
+			NULL
+		},
+	};
+
+	group = g_option_group_new(
+		"libpurple",
+		_("LibPurple options"),
+		_("Show LibPurple Options"),
+		NULL,
+		NULL
+	);
+
+	g_option_group_add_entries(group, entries);
+
+	return group;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/options.h	Tue Dec 26 05:28:40 2017 +0000
@@ -0,0 +1,42 @@
+/* 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_OPTIONS_H
+#define PURPLE_OPTIONS_H
+
+/**
+ * SECTION:options
+ * @section_id: libpurple-options
+ * @short_description: <filename>options.h</filename>
+ * @title: Options API
+ *
+ * The functions defined here are to help in handling command line options.
+ */
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+GOptionGroup *purple_get_option_group(void);
+
+G_END_DECLS
+
+#endif /* PURPLE_OPTIONS_H */
--- a/libpurple/plugins/filectl.c	Thu Dec 14 21:27:42 2017 -0600
+++ b/libpurple/plugins/filectl.c	Tue Dec 26 05:28:40 2017 +0000
@@ -86,27 +86,6 @@
 			free(arg1);
 			free(arg2);
 
-/* purple_find_conversation() is gone in 2.0.0. */
-#if 0
-		} else if (!g_ascii_strncasecmp(command, "send", 4)) {
-			PurpleConversation *conv;
-
-			arg1 = getarg(buffer, 1, 0);
-			arg2 = getarg(buffer, 2, 1);
-
-			conv = purple_find_conversation(PURPLE_CONV_TYPE_ANY, arg1);
-			if (conv != NULL)
-			{
-				/*
-				purple_conversation_write(conv, arg2, WFLAG_SEND, NULL, time(NULL), -1);
-				purple_serv_send_im(conv->gc, arg1, arg2, 0);
-				*/
-			}
-
-			free(arg1);
-			free(arg2);
-#endif
-
 		} else if (!g_ascii_strncasecmp(command, "away", 4)) {
 			arg1 = getarg(buffer, 1, 1);
 			/* serv_set_away_all(arg1); */
--- a/libpurple/plugins/log_reader.c	Thu Dec 14 21:27:42 2017 -0600
+++ b/libpurple/plugins/log_reader.c	Tue Dec 26 05:28:40 2017 +0000
@@ -2444,35 +2444,6 @@
 	if (path) {
 		/* Read talk.ini file to find the log directory. */
 		GError *error = NULL;
-
-#if 0 /* FIXME: Not tested yet. */
-		GKeyFile *key_file;
-
-		purple_debug_info("Trillian talk.ini read", "Reading %s\n", path);
-
-		error = NULL;
-		if (!g_key_file_load_from_file(key_file, path, G_KEY_FILE_NONE, GError &error)) {
-			purple_debug_error("Trillian talk.ini read",
-			                   "Error reading talk.ini\n");
-			if (error)
-				g_error_free(error);
-		} else {
-			char *logdir = g_key_file_get_string(key_file, "Logging", "Directory", &error);
-			if (error) {
-				purple_debug_error("Trillian talk.ini read",
-				                   "Error reading Directory value from Logging section\n");
-				g_error_free(error);
-			}
-
-			if (logdir) {
-				g_strchomp(logdir);
-				purple_prefs_add_string("/plugins/core/log_reader/trillian/log_directory", logdir);
-				found = TRUE;
-			}
-
-			g_key_file_free(key_file);
-		}
-#else
 		gchar *contents = NULL;
 
 		if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
@@ -2514,7 +2485,6 @@
 			g_free(contents);
 		}
 		g_free(path);
-#endif
 	} /* path */
 
 	if (!found) {
--- a/pidgin/libpidgin.c	Thu Dec 14 21:27:42 2017 -0600
+++ b/pidgin/libpidgin.c	Tue Dec 26 05:28:40 2017 +0000
@@ -33,6 +33,7 @@
 #include "log.h"
 #include "network.h"
 #include "notify.h"
+#include "options.h"
 #include "prefs.h"
 #include "protocol.h"
 #include "pounce.h"
@@ -375,25 +376,10 @@
 	purple_blist_set_visible(TRUE);
 }
 
-static gboolean debug_colored = FALSE;
-static gboolean debug_enabled = FALSE;
 static gboolean opt_login = FALSE;
 static gchar *opt_login_arg = NULL;
 
 static gboolean
-debug_opt_arg_func(const gchar *option_name, const gchar *value,
-		gpointer data, GError **error)
-{
-	debug_enabled = TRUE;
-
-	if (purple_strequal(value, "colored")) {
-		debug_colored = TRUE;
-	}
-
-	return TRUE;
-}
-
-static gboolean
 login_opt_arg_func(const gchar *option_name, const gchar *value,
 		gpointer data, GError **error)
 {
@@ -408,7 +394,6 @@
 int pidgin_start(int argc, char *argv[])
 {
 	GApplication *app;
-	gboolean opt_force_online = FALSE;
 	gboolean opt_nologin = FALSE;
 	gboolean opt_version = FALSE;
 	gboolean opt_si = TRUE;     /* Check for single instance? */
@@ -441,13 +426,6 @@
 		{"config", 'c', 0,
 			G_OPTION_ARG_FILENAME, &opt_config_dir_arg,
 			_("use DIR for config files"), _("DIR")},
-		{"debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
-			G_OPTION_ARG_CALLBACK, &debug_opt_arg_func,
-			_("print debugging messages to stdout"),
-			_("[colored]")},
-		{"force-online", 'f', 0,
-			G_OPTION_ARG_NONE, &opt_force_online,
-			_("force online, regardless of network status"), NULL},
 		{"login", 'l', G_OPTION_FLAG_OPTIONAL_ARG,
 			G_OPTION_ARG_CALLBACK, &login_opt_arg_func,
 			_("enable specified account(s) (optional argument NAME\n"
@@ -468,11 +446,8 @@
 		{NULL}
 	};
 
-	debug_colored = FALSE;
 #ifdef DEBUG
-	debug_enabled = TRUE;
-#else
-	debug_enabled = FALSE;
+	purple_debug_set_enabled(TRUE);
 #endif
 
 #ifdef ENABLE_NLS
@@ -594,6 +569,8 @@
 	g_free(summary);
 
 	g_option_context_add_main_entries(context, option_entries, PACKAGE);
+	g_option_context_add_group(context, purple_get_option_group());
+	g_option_context_add_group(context, gplugin_get_option_group());
 	g_option_context_add_group(context, gtk_get_option_group(TRUE));
 
 #ifdef G_OS_WIN32
@@ -646,11 +623,6 @@
 	 * Fire up this baby.
 	 */
 
-	if (g_getenv("PIDGIN_DEBUG_COLORED") != NULL)
-		debug_colored = TRUE;
-	purple_debug_set_enabled(debug_enabled);
-	purple_debug_set_colored(debug_colored);
-
 	app = G_APPLICATION(gtk_application_new("im.pidgin.Pidgin",
 				G_APPLICATION_NON_UNIQUE));
 
@@ -741,11 +713,6 @@
 	g_free(opt_config_dir_arg);
 	opt_config_dir_arg = NULL;
 
-	/* This needs to be before purple_blist_show() so the
-	 * statusbox gets the forced online status. */
-	if (opt_force_online)
-		purple_network_force_online();
-
 	/*
 	 * We want to show the blist early in the init process so the
 	 * user feels warm and fuzzy (not cold and prickley).
--- a/po/POTFILES.in	Thu Dec 14 21:27:42 2017 -0600
+++ b/po/POTFILES.in	Tue Dec 26 05:28:40 2017 +0000
@@ -54,6 +54,7 @@
 libpurple/mediamanager.c
 libpurple/media/backend-fs2.c
 libpurple/message.c
+libpurple/options.c
 libpurple/plugins.c
 libpurple/plugins/autoaccept.c
 libpurple/plugins/buddynote.c

mercurial