Simplify handling of GG xfer auth queue.
[pidgin-git.git] / pidgin / pidgindebugplugininfo.c
blob777b679b64bcee9949b95b5701b201aef7067222
1 /* pidgin
3 * Pidgin is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
5 * source distribution.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #include <talkatu.h>
24 #include "internal.h"
25 #include "plugins.h"
27 #include "pidgindebugplugininfo.h"
29 struct _PidginDebugPluginInfo {
30 GtkDialog parent;
32 gpointer reserved[4];
35 struct _PidginDebugPluginInfoClass {
36 GtkDialogClass parent;
38 gpointer reserved[4];
41 /**
42 * SECTION:pidgindebugplugininfo
43 * @Title: Debug Plugin Info
44 * @Short_description: A widget that lists verbose plugin info
46 * When helping users troubleshoot issues with Pidgin we often need to know
47 * what plugins that have installed/running. This widget gives them an easy
48 * way to get that info to us.
51 typedef struct {
52 GtkTextBuffer *buffer;
53 GtkWidget *view;
54 } PidginDebugPluginInfoPrivate;
56 G_DEFINE_TYPE_WITH_PRIVATE(PidginDebugPluginInfo, pidgin_debug_plugin_info, GTK_TYPE_DIALOG)
58 /******************************************************************************
59 * Helpers
60 *****************************************************************************/
61 static gint
62 purple_debug_plugin_compare_plugin_id(gconstpointer a, gconstpointer b) {
63 return g_strcmp0(
64 gplugin_plugin_info_get_id(GPLUGIN_PLUGIN_INFO(
65 purple_plugin_get_info(PURPLE_PLUGIN((gpointer)a)))),
66 gplugin_plugin_info_get_id(GPLUGIN_PLUGIN_INFO(
67 purple_plugin_get_info(PURPLE_PLUGIN((gpointer)b)))));
70 static gchar *
71 pidgin_debug_plugin_info_build_html(void) {
72 GString *str = g_string_new(NULL);
73 GList *plugins = NULL, *l = NULL;
75 g_string_append_printf(str, "<h2>%s</h2><dl>", _("Plugin Information"));
77 plugins = g_list_sort(
78 purple_plugins_find_all(),
79 purple_debug_plugin_compare_plugin_id
82 for(l = plugins; l != NULL; l = l->next) {
83 PurplePlugin *plugin = PURPLE_PLUGIN(l->data);
84 PurplePluginInfo *info = purple_plugin_get_info(plugin);
85 PurplePluginExtraCb extra_cb;
86 gchar *name = g_markup_escape_text(
87 gplugin_plugin_info_get_name(GPLUGIN_PLUGIN_INFO(info)),
88 -1);
89 gchar *version, *license, *website, *id;
90 gchar *authors = NULL, *extra = NULL;
91 const gchar *error_message = NULL;
92 gchar **authorsv;
93 gboolean loaded;
95 g_object_get(
96 G_OBJECT(info),
97 "authors", &authorsv,
98 "version", &version,
99 "license-id", &license,
100 "website", &website,
101 "id", &id,
102 "extra-cb", &extra_cb,
103 NULL
106 if(authorsv != NULL) {
107 gchar *authorstmp = g_strjoinv(", ", (gchar **)authorsv);
108 g_strfreev(authorsv);
110 authors = g_markup_escape_text(authorstmp, -1);
111 g_free(authorstmp);
114 if(extra_cb != NULL) {
115 extra = extra_cb(plugin);
118 error_message = purple_plugin_info_get_error(info);
120 loaded = purple_plugin_is_loaded(plugin);
122 g_string_append_printf(str, "<dt>%s</dt><dd>", name);
123 g_free(name);
125 /* this is not translated as it's meant for debugging */
126 g_string_append_printf(
127 str,
128 "<b>Authors:</b> %s<br/>"
129 "<b>Version:</b> %s<br/>"
130 "<b>License:</b> %s<br/>"
131 "<b>Website:</b> %s<br/>"
132 "<b>ID:</b> %s<br/>"
133 "<b>Extra:</b> %s<br/>"
134 "<b>Errors:</b> %s</br>"
135 "<b>Loaded:</b> %s",
136 authors ? authors : "",
137 version ? version : "",
138 license ? license : "",
139 website ? website : "",
140 id ? id : "",
141 extra ? extra : "",
142 error_message ? error_message : "",
143 loaded ? "Yes" : "No"
146 g_clear_pointer(&authors, g_free);
147 g_free(version);
148 g_free(license);
149 g_free(website);
150 g_free(id);
151 g_clear_pointer(&extra, g_free);
153 g_string_append(str, "</dd>");
156 g_list_free(plugins);
158 g_string_append(str, "</dl>");
160 return g_string_free(str, FALSE);
163 /******************************************************************************
164 * GObject Stuff
165 *****************************************************************************/
166 static void
167 pidgin_debug_plugin_info_init(PidginDebugPluginInfo *debug_plugin_info) {
168 gtk_widget_init_template(GTK_WIDGET(debug_plugin_info));
171 static void
172 pidgin_debug_plugin_info_class_init(PidginDebugPluginInfoClass *klass) {
173 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
175 gtk_widget_class_set_template_from_resource(
176 widget_class,
177 "/im/pidgin/Pidgin/Debug/plugininfo.ui"
180 gtk_widget_class_bind_template_child_private(widget_class, PidginDebugPluginInfo, buffer);
181 gtk_widget_class_bind_template_child_private(widget_class, PidginDebugPluginInfo, view);
184 /******************************************************************************
185 * Public API
186 *****************************************************************************/
189 * pidgin_debug_plugin_info_new:
191 * Creates a new #PidginDebugPluginInfo that provides the user with an easy way
192 * to share information about their plugin state for debugging purposes.
194 * Returns: (transfer full): The new #PidginDebugPluginInfo instance.
196 GtkWidget *pidgin_debug_plugin_info_new(void) {
197 return GTK_WIDGET(g_object_new(
198 PIDGIN_TYPE_DEBUG_PLUGIN_INFO,
199 NULL
203 void
204 pidgin_debug_plugin_info_show(void) {
205 PidginDebugPluginInfoPrivate *priv = NULL;
206 GtkWidget *win = NULL;
207 gchar *text = NULL;
209 win = pidgin_debug_plugin_info_new();
210 priv = pidgin_debug_plugin_info_get_instance_private(PIDGIN_DEBUG_PLUGIN_INFO(win));
212 text = pidgin_debug_plugin_info_build_html();
213 talkatu_markup_set_html(TALKATU_BUFFER(priv->buffer), text, -1);
214 g_free(text);
216 gtk_widget_show_all(win);
217 gtk_window_present(GTK_WINDOW(win));