Separate the conversation commands out to their own file
Testing Done:
Ran pidgin locally verified the commands worked. Ran `ninja pidgin-doc` as well as `ninja pidgin-pot`
Reviewed at https://reviews.imfreedom.org/r/632/
--- a/doc/reference/pidgin/pidgin-docs.xml Fri Apr 30 05:03:39 2021 -0500
+++ b/doc/reference/pidgin/pidgin-docs.xml Thu May 06 21:32:40 2021 -0500
@@ -60,6 +60,7 @@
<xi:include href="xml/pidginavatar.xml" />
<xi:include href="xml/pidgincellrendererexpander.xml" />
<xi:include href="xml/pidginclosebutton.xml" />
+ <xi:include href="xml/pidgincommands.xml" /> <xi:include href="xml/pidgincontactcompletion.xml" />
<xi:include href="xml/pidgincontactlist.xml" />
<xi:include href="xml/pidginconversationwindow.xml" />
--- a/pidgin/gtkconv.c Fri Apr 30 05:03:39 2021 -0500
+++ b/pidgin/gtkconv.c Thu May 06 21:32:40 2021 -0500
@@ -287,103 +287,6 @@
-say_command_cb(PurpleConversation *conv,
- const char *cmd, char **args, char **error, void *data)
- purple_conversation_send(conv, args[0]);
- return PURPLE_CMD_RET_OK;
-me_command_cb(PurpleConversation *conv,
- const char *cmd, char **args, char **error, void *data)
- tmp = g_strdup_printf("/me %s", args[0]);
- purple_conversation_send(conv, tmp);
- return PURPLE_CMD_RET_OK;
-debug_command_cb(PurpleConversation *conv,
- const char *cmd, char **args, char **error, void *data)
- if (!g_ascii_strcasecmp(args[0], "version")) {
- tmp = g_strdup_printf("Using Pidgin v%s with libpurple v%s.",
- DISPLAY_VERSION, purple_core_get_version());
- } else if (!g_ascii_strcasecmp(args[0], "plugins")) {
- /* Show all the loaded plugins, including plugins marked internal.
- * This is intentional, since third party protocols are often sources of bugs, and some
- * plugin loaders can also be buggy.
- GString *str = g_string_new("Loaded Plugins: ");
- const GList *plugins = purple_plugins_get_loaded();
- for (; plugins; plugins = plugins->next) {
- GPluginPluginInfo *info = GPLUGIN_PLUGIN_INFO(
- purple_plugin_get_info(
- PURPLE_PLUGIN(plugins->data)));
- gplugin_plugin_info_get_name(info));
- str = g_string_append(str, ", ");
- str = g_string_append(str, "(none)");
- tmp = g_string_free(str, FALSE);
- } else if (!g_ascii_strcasecmp(args[0], "unsafe")) {
- if (purple_debug_is_unsafe()) {
- purple_debug_set_unsafe(FALSE);
- purple_conversation_write_system_message(conv,
- _("Unsafe debugging is now disabled."),
- PURPLE_MESSAGE_NO_LOG);
- purple_debug_set_unsafe(TRUE);
- purple_conversation_write_system_message(conv,
- _("Unsafe debugging is now enabled."),
- PURPLE_MESSAGE_NO_LOG);
- return PURPLE_CMD_RET_OK;
- } else if (!g_ascii_strcasecmp(args[0], "verbose")) {
- if (purple_debug_is_verbose()) {
- purple_debug_set_verbose(FALSE);
- purple_conversation_write_system_message(conv,
- _("Verbose debugging is now disabled."),
- PURPLE_MESSAGE_NO_LOG);
- purple_debug_set_verbose(TRUE);
- purple_conversation_write_system_message(conv,
- _("Verbose debugging is now enabled."),
- PURPLE_MESSAGE_NO_LOG);
- return PURPLE_CMD_RET_OK;
- purple_conversation_write_system_message(conv,
- _("Supported debug options are: plugins, version, unsafe, verbose"),
- PURPLE_MESSAGE_NO_LOG);
- return PURPLE_CMD_RET_OK;
- markup = g_markup_escape_text(tmp, -1);
- purple_conversation_send(conv, markup);
- return PURPLE_CMD_RET_OK;
static void clear_conversation_scrollback_cb(PurpleConversation *conv,
@@ -395,65 +298,6 @@
-clear_command_cb(PurpleConversation *conv,
- const char *cmd, char **args, char **error, void *data)
- purple_conversation_clear_message_history(conv);
- return PURPLE_CMD_RET_OK;
-clearall_command_cb(PurpleConversation *conv,
- const char *cmd, char **args, char **error, void *data)
- for (l = purple_conversations_get_all(); l != NULL; l = l->next)
- purple_conversation_clear_message_history(PURPLE_CONVERSATION(l->data));
- return PURPLE_CMD_RET_OK;
-help_command_cb(PurpleConversation *conv,
- const char *cmd, char **args, char **error, void *data)
- text = purple_cmd_help(conv, args[0]);
- for (l = text; l; l = l->next)
- g_string_append_printf(s, "%s\n", (char *)l->data);
- g_string_append_printf(s, "%s", (char *)l->data);
- g_string_append(s, _("No such command (in this context)."));
- s = g_string_new(_("Use \"/help <command>\" for help with a "
- "specific command.<br/>The following commands are available "
- "in this context:<br/>"));
- text = purple_cmd_list(conv);
- for (l = text; l; l = l->next)
- g_string_append_printf(s, "%s, ", (char *)l->data);
- g_string_append_printf(s, "%s.", (char *)l->data);
- purple_conversation_write_system_message(conv, s->str, PURPLE_MESSAGE_NO_LOG);
- g_string_free(s, TRUE);
- return PURPLE_CMD_RET_OK;
send_history_add(PidginConversation *gtkconv, const char *message)
@@ -5109,28 +4953,6 @@
/**********************************************************************
- **********************************************************************/
- purple_cmd_register("say", "S", PURPLE_CMD_P_DEFAULT,
- PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
- say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL);
- purple_cmd_register("me", "S", PURPLE_CMD_P_DEFAULT,
- PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
- me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL);
- purple_cmd_register("debug", "w", PURPLE_CMD_P_DEFAULT,
- PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
- debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL);
- purple_cmd_register("clear", "", PURPLE_CMD_P_DEFAULT,
- PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
- clear_command_cb, _("clear: Clears the conversation scrollback."), NULL);
- purple_cmd_register("clearall", "", PURPLE_CMD_P_DEFAULT,
- PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL,
- clearall_command_cb, _("clear: Clears all conversation scrollbacks."), NULL);
- purple_cmd_register("help", "w", PURPLE_CMD_P_DEFAULT,
- PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, NULL,
- help_command_cb, _("help <command>: Help on a specific command."), NULL);
- /**********************************************************************
**********************************************************************/
--- a/pidgin/libpidgin.c Fri Apr 30 05:03:39 2021 -0500
+++ b/pidgin/libpidgin.c Thu May 06 21:32:40 2021 -0500
@@ -54,6 +54,7 @@
#include "pidginplugininfo.h"
+#include "pidginprivate.h" @@ -189,6 +190,7 @@
pidgin_conversations_init();
+ pidgin_commands_init(); @@ -206,6 +208,7 @@
_pidgin_smiley_theme_uninit();
+ pidgin_commands_uninit(); pidgin_conversations_uninit();
--- a/pidgin/meson.build Fri Apr 30 05:03:39 2021 -0500
+++ b/pidgin/meson.build Thu May 06 21:32:40 2021 -0500
@@ -40,6 +40,7 @@
'pidgincellrendererexpander.c',
'pidgincontactcompletion.c',
'pidginconversationwindow.c',
@@ -236,7 +237,7 @@
libpidgin_inc = include_directories('.')
libpidgin = shared_library('pidgin3',
- libpidgin_SOURCES + libpidgin_built_sources + libpidgin_built_headers,
+ libpidgin_SOURCES + libpidgin_built_sources + libpidgin_built_headers + ['pidginprivate.h'], c_args : ['-DPIDGIN_COMPILATION', '-DG_LOG_DOMAIN="Pidgin"'],
include_directories : [toplevel_inc],
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidgincommands.c Thu May 06 21:32:40 2021 -0500
@@ -0,0 +1,214 @@
+ * Pidgin - Internet Messenger + * Copyright (C) Pidgin Developers <devel@pidgin.im> + * Pidgin is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * 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 <https://www.gnu.org/licenses/>. +#include <glib/gi18n-lib.h> +#include <pidginprivate.h> +/****************************************************************************** + * Command Implementations + *****************************************************************************/ +say_command_cb(PurpleConversation *conv, + const char *cmd, char **args, char **error, void *data) + purple_conversation_send(conv, args[0]); + return PURPLE_CMD_RET_OK; +me_command_cb(PurpleConversation *conv, + const char *cmd, char **args, char **error, void *data) + tmp = g_strdup_printf("/me %s", args[0]); + purple_conversation_send(conv, tmp); + return PURPLE_CMD_RET_OK; +debug_command_cb(PurpleConversation *conv, + const char *cmd, char **args, char **error, void *data) + if (!g_ascii_strcasecmp(args[0], "version")) { + tmp = g_strdup_printf("Using Pidgin v%s with libpurple v%s.", + DISPLAY_VERSION, purple_core_get_version()); + } else if (!g_ascii_strcasecmp(args[0], "plugins")) { + /* Show all the loaded plugins, including plugins marked internal. + * This is intentional, since third party protocols are often sources of bugs, and some + * plugin loaders can also be buggy. + GString *str = g_string_new("Loaded Plugins: "); + const GList *plugins = purple_plugins_get_loaded(); + for (; plugins; plugins = plugins->next) { + GPluginPluginInfo *info = GPLUGIN_PLUGIN_INFO( + purple_plugin_get_info( + PURPLE_PLUGIN(plugins->data))); + gplugin_plugin_info_get_name(info)); + str = g_string_append(str, ", "); + str = g_string_append(str, "(none)"); + tmp = g_string_free(str, FALSE); + } else if (!g_ascii_strcasecmp(args[0], "unsafe")) { + if (purple_debug_is_unsafe()) { + purple_debug_set_unsafe(FALSE); + purple_conversation_write_system_message(conv, + _("Unsafe debugging is now disabled."), + PURPLE_MESSAGE_NO_LOG); + purple_debug_set_unsafe(TRUE); + purple_conversation_write_system_message(conv, + _("Unsafe debugging is now enabled."), + PURPLE_MESSAGE_NO_LOG); + return PURPLE_CMD_RET_OK; + } else if (!g_ascii_strcasecmp(args[0], "verbose")) { + if (purple_debug_is_verbose()) { + purple_debug_set_verbose(FALSE); + purple_conversation_write_system_message(conv, + _("Verbose debugging is now disabled."), + PURPLE_MESSAGE_NO_LOG); + purple_debug_set_verbose(TRUE); + purple_conversation_write_system_message(conv, + _("Verbose debugging is now enabled."), + PURPLE_MESSAGE_NO_LOG); + return PURPLE_CMD_RET_OK; + purple_conversation_write_system_message(conv, + _("Supported debug options are: plugins, version, unsafe, verbose"), + PURPLE_MESSAGE_NO_LOG); + return PURPLE_CMD_RET_OK; + markup = g_markup_escape_text(tmp, -1); + purple_conversation_send(conv, markup); + return PURPLE_CMD_RET_OK; +clear_command_cb(PurpleConversation *conv, + const char *cmd, char **args, char **error, void *data) + purple_conversation_clear_message_history(conv); + return PURPLE_CMD_RET_OK; +clearall_command_cb(PurpleConversation *conv, + const char *cmd, char **args, char **error, void *data) + for (l = purple_conversations_get_all(); l != NULL; l = l->next) + purple_conversation_clear_message_history(PURPLE_CONVERSATION(l->data)); + return PURPLE_CMD_RET_OK; +help_command_cb(PurpleConversation *conv, + const char *cmd, char **args, char **error, void *data) + text = purple_cmd_help(conv, args[0]); + for (l = text; l; l = l->next) + g_string_append_printf(s, "%s\n", (char *)l->data); + g_string_append_printf(s, "%s", (char *)l->data); + g_string_append(s, _("No such command (in this context).")); + s = g_string_new(_("Use \"/help <command>\" for help with a " + "specific command.<br/>The following commands are available " + "in this context:<br/>")); + text = purple_cmd_list(conv); + for (l = text; l; l = l->next) + g_string_append_printf(s, "%s, ", (char *)l->data); + g_string_append_printf(s, "%s.", (char *)l->data); + purple_conversation_write_system_message(conv, s->str, PURPLE_MESSAGE_NO_LOG); + g_string_free(s, TRUE); + return PURPLE_CMD_RET_OK; +/****************************************************************************** + *****************************************************************************/ +pidgin_commands_init(void) { + purple_cmd_register("say", "S", PURPLE_CMD_P_DEFAULT, + PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, + say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); + purple_cmd_register("me", "S", PURPLE_CMD_P_DEFAULT, + PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, + me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); + purple_cmd_register("debug", "w", PURPLE_CMD_P_DEFAULT, + PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, + debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); + purple_cmd_register("clear", "", PURPLE_CMD_P_DEFAULT, + PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, + clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); + purple_cmd_register("clearall", "", PURPLE_CMD_P_DEFAULT, + PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM, NULL, + clearall_command_cb, _("clearall: Clears all conversation scrollbacks."), NULL); + purple_cmd_register("help", "w", PURPLE_CMD_P_DEFAULT, + PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, + help_command_cb, _("help <command>: Help on a specific command."), NULL); +pidgin_commands_uninit(void) { --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/pidginprivate.h Thu May 06 21:32:40 2021 -0500
@@ -0,0 +1,56 @@
+ * Pidgin - Internet Messenger + * Copyright (C) Pidgin Developers <devel@pidgin.im> + * Pidgin is the legal property of its developers, whose names are too numerous + * to list here. Please refer to the COPYRIGHT file distributed with this + * 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 <https://www.gnu.org/licenses/>. +#ifndef PIDGIN_PRIVATE_H +#define PIDGIN_PRIVATE_H + * pidgin_commands_init: + * Initializes the default conversation commands for Pidgin. + * This should only be called internally from Pidgin. +void pidgin_commands_init(void); + * pidgin_commands_uninit: + * Uninitializes the default conversation commands for Pidgin. + * This should only be called internally from Pidgin. +void pidgin_commands_uninit(void); +#endif /* PIDGIN_PRIVATE_H */ --- a/po/POTFILES.in Fri Apr 30 05:03:39 2021 -0500
+++ b/po/POTFILES.in Thu May 06 21:32:40 2021 -0500
@@ -349,6 +349,7 @@
pidgin/pidgincellrendererexpander.c
pidgin/pidginclosebutton.c
pidgin/pidgincontactcompletion.c
pidgin/pidgincontactlist.c
pidgin/pidginconversationwindow.c