pidgin/pidgin

Remove entire PurpleDebugUiInterface and implementations

2021-10-19, Elliott Sales de Andrade
02abf3170610
Parents 409319dde54e
Children 85ddac53ef14
Remove entire PurpleDebugUiInterface and implementations

The `purple_debug*` functions are routed through GLib's logging interface, and the UIs capture logs from there, so there's no need for this interface any more.

Testing Done:
Opened Debug Window and saw logs appearing there.

Reviewed at https://reviews.imfreedom.org/r/1074/
--- a/ChangeLog.API Tue Oct 19 00:40:28 2021 -0500
+++ b/ChangeLog.API Tue Oct 19 00:41:44 2021 -0500
@@ -389,6 +389,7 @@
* Removed the general Purple DBus interface
* purple_date_format_long, use g_date_time_format instead.
* purple_date_format_short, use g_date_time_format instead.
+ * PurpleDebugUiOps
* purple_dnsquery_a_account
* purple_event_loop_{get|set}_ui_ops. Manually drive the GLib
event loop yourself. See GLib Main Event Loop docs.
--- a/finch/gntdebug.c Tue Oct 19 00:40:28 2021 -0500
+++ b/finch/gntdebug.c Tue Oct 19 00:41:44 2021 -0500
@@ -44,12 +44,6 @@
/* Other members, including private data. */
};
-static void finch_debug_ui_interface_init(PurpleDebugUiInterface *iface);
-
-G_DEFINE_TYPE_WITH_CODE(FinchDebugUi, finch_debug_ui, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE(PURPLE_TYPE_DEBUG_UI,
- finch_debug_ui_interface_init));
-
static gboolean
handle_fprintf_stderr_cb(GIOChannel *source, GIOCondition cond, gpointer null)
{
@@ -103,72 +97,6 @@
gboolean paused;
} debug;
-static gboolean
-match_string(const char *category, const char *args)
-{
- const char *str = gnt_entry_get_text(GNT_ENTRY(debug.search));
- if (!str || !*str)
- return TRUE;
- if (g_strrstr(category, str) != NULL)
- return TRUE;
- if (g_strrstr(args, str) != NULL)
- return TRUE;
- return FALSE;
-}
-
-static void
-finch_debug_print(PurpleDebugUi *self,
- PurpleDebugLevel level, const char *category,
- const char *args)
-{
- if (debug.window && !debug.paused && match_string(category, args))
- {
- int pos = gnt_text_view_get_lines_below(GNT_TEXT_VIEW(debug.tview));
- GntTextFormatFlags flag = GNT_TEXT_FLAG_NORMAL;
- const char *mdate;
- time_t mtime = time(NULL);
- mdate = purple_utf8_strftime("%H:%M:%S ", localtime(&mtime));
- gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview),
- mdate, flag);
-
- gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview),
- category, GNT_TEXT_FLAG_BOLD);
- gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview),
- ": ", GNT_TEXT_FLAG_BOLD);
-
- switch (level)
- {
- case PURPLE_DEBUG_WARNING:
- flag |= GNT_TEXT_FLAG_UNDERLINE;
- /* fall through */
- case PURPLE_DEBUG_ERROR:
- case PURPLE_DEBUG_FATAL:
- flag |= GNT_TEXT_FLAG_BOLD;
- break;
- default:
- break;
- }
-
- gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), args, flag);
- gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(debug.tview), "\n", GNT_TEXT_FLAG_NORMAL);
- if (pos <= 1)
- gnt_text_view_scroll(GNT_TEXT_VIEW(debug.tview), 0);
- }
-}
-
-static gboolean
-finch_debug_is_enabled(PurpleDebugUi *self, PurpleDebugLevel level, const char *category)
-{
- return debug.window && !debug.paused;
-}
-
-static void
-finch_debug_ui_interface_init(PurpleDebugUiInterface *iface)
-{
- iface->print = finch_debug_print;
- iface->is_enabled = finch_debug_is_enabled;
-}
-
static void
reset_debug_win(GntWidget *w, gpointer null)
{
@@ -396,22 +324,6 @@
return FALSE;
}
-static void
-finch_debug_ui_class_init(FinchDebugUiClass *klass)
-{
-}
-
-static void
-finch_debug_ui_init(FinchDebugUi *self)
-{
-}
-
-FinchDebugUi *
-finch_debug_ui_new(void)
-{
- return g_object_new(FINCH_TYPE_DEBUG_UI, NULL);
-}
-
void
finch_debug_init_handler(void)
{
--- a/finch/gntdebug.h Tue Oct 19 00:40:28 2021 -0500
+++ b/finch/gntdebug.h Tue Oct 19 00:41:44 2021 -0500
@@ -42,16 +42,6 @@
* GNT Debug API
**********************************************************************/
-#define FINCH_TYPE_DEBUG_UI (finch_debug_ui_get_type())
-G_DECLARE_FINAL_TYPE(FinchDebugUi, finch_debug_ui, FINCH, DEBUG_UI, GObject)
-
-/**
- * finch_debug_ui_new:
- *
- * Perform necessary initializations.
- */
-FinchDebugUi *finch_debug_ui_new(void);
-
/**
* finch_debug_init_handler:
*
--- a/finch/libfinch.c Tue Oct 19 00:40:28 2021 -0500
+++ b/finch/libfinch.c Tue Oct 19 00:41:44 2021 -0500
@@ -39,13 +39,6 @@
#include "config.h"
#include "package_revision.h"
-static void
-debug_init(void)
-{
- FinchDebugUi *ui = finch_debug_ui_new();
- purple_debug_set_ui(PURPLE_DEBUG_UI(ui));
-}
-
static PurpleUiInfo *
finch_ui_get_info(void) {
return purple_ui_info_new(_("Finch"), VERSION, "https://pidgin.im",
@@ -61,7 +54,6 @@
static PurpleCoreUiOps core_ops =
{
finch_prefs_init,
- debug_init,
finch_ui_init,
finch_quit,
finch_ui_get_info,
--- a/libpurple/core.c Tue Oct 19 00:40:28 2021 -0500
+++ b/libpurple/core.c Tue Oct 19 00:41:44 2021 -0500
@@ -134,13 +134,10 @@
purple_debug_init();
- if (ops != NULL)
- {
- if (ops->ui_prefs_init != NULL)
+ if (ops != NULL) {
+ if (ops->ui_prefs_init != NULL) {
ops->ui_prefs_init();
-
- if (ops->debug_ui_init != NULL)
- ops->debug_ui_init();
+ }
}
purple_cmds_init();
--- a/libpurple/core.h Tue Oct 19 00:40:28 2021 -0500
+++ b/libpurple/core.h Tue Oct 19 00:41:44 2021 -0500
@@ -48,11 +48,6 @@
* @ui_prefs_init: Called just after the preferences subsystem is initialized;
* the UI could use this callback to add some preferences it
* needs to be in place when other subsystems are initialized.
- * @debug_ui_init: Called just after the debug subsystem is initialized, but
- * before just about every other component's initialization. The
- * UI should use this hook to call purple_debug_set_ui() so
- * that debugging information for other components can be logged
- * during their initialization.
* @ui_init: Called after all of libpurple has been initialized. The UI
* should use this hook to set all other necessary
* <link linkend="chapter-ui-ops"><literal>UiOps structures</literal></link>.
@@ -67,7 +62,6 @@
struct _PurpleCoreUiOps
{
void (*ui_prefs_init)(void);
- void (*debug_ui_init)(void);
void (*ui_init)(void);
void (*quit)(void);
--- a/libpurple/debug.c Tue Oct 19 00:40:28 2021 -0500
+++ b/libpurple/debug.c Tue Oct 19 00:41:44 2021 -0500
@@ -23,8 +23,6 @@
#include "debug.h"
#include "prefs.h"
-static PurpleDebugUi *debug_ui = NULL;
-
/*
* This determines whether debug info should be written to the
* console or not.
@@ -165,11 +163,6 @@
return debug_enabled;
}
-void
-purple_debug_set_ui(PurpleDebugUi *ui) {
- g_set_object(&debug_ui, ui);
-}
-
gboolean
purple_debug_is_verbose() {
return debug_verbose;
@@ -195,11 +188,6 @@
debug_colored = colored;
}
-PurpleDebugUi *
-purple_debug_get_ui(void) {
- return debug_ui;
-}
-
void
purple_debug_init(void) {
/* Read environment variables once per init */
--- a/libpurple/debug.h Tue Oct 19 00:40:28 2021 -0500
+++ b/libpurple/debug.h Tue Oct 19 00:41:44 2021 -0500
@@ -218,32 +218,6 @@
void purple_debug_set_colored(gboolean colored);
/******************************************************************************
- * UI Registration Functions
- *****************************************************************************/
-
-/**
- * purple_debug_set_ui:
- * @ui: The UI operations structure.
- *
- * Sets the UI operations structure to be used when outputting debug
- * information.
- *
- * Since: 3.0.0
- */
-void purple_debug_set_ui(PurpleDebugUi *ui);
-
-/**
- * purple_debug_get_ui:
- *
- * Get the #PurpleDebugUi instance used for outputting debug information.
- *
- * Returns: (transfer none): The #PurpleDebugUi instance in use.
- *
- * Since: 3.0.0
- */
-PurpleDebugUi *purple_debug_get_ui(void);
-
-/******************************************************************************
* Debug Subsystem
*****************************************************************************/
--- a/pidgin/libpidgin.c Tue Oct 19 00:40:28 2021 -0500
+++ b/pidgin/libpidgin.c Tue Oct 19 00:41:44 2021 -0500
@@ -183,13 +183,6 @@
purple_ui_add_protocol_theme_paths(protocol);
}
-static void
-debug_init(void)
-{
- PidginDebugUi *ui = pidgin_debug_ui_new();
- purple_debug_set_ui(PURPLE_DEBUG_UI(ui));
-}
-
static gboolean
pidgin_history_init(GError **error) {
PurpleHistoryManager *manager = NULL;
@@ -289,7 +282,6 @@
pidgin_quit(void)
{
/* Uninit */
- PurpleDebugUi *ui;
/* Be sure to close all windows that are not attached to anything
* (e.g., the debug window), or they may access things after they are
@@ -304,9 +296,6 @@
pidgin_accounts_uninit();
pidgin_xfers_uninit();
pidgin_debug_window_hide();
- ui = purple_debug_get_ui();
- purple_debug_set_ui(NULL);
- g_object_unref(ui);
pidgin_debug_uninit();
/* and end it all... */
@@ -322,7 +311,6 @@
static PurpleCoreUiOps core_ops =
{
pidgin_prefs_init,
- debug_init,
pidgin_ui_init,
pidgin_quit,
pidgin_ui_get_info,
--- a/pidgin/pidgindebug.c Tue Oct 19 00:40:28 2021 -0500
+++ b/pidgin/pidgindebug.c Tue Oct 19 00:41:44 2021 -0500
@@ -72,19 +72,6 @@
static PidginDebugWindow *debug_win = NULL;
static guint debug_enabled_timer = 0;
-struct _PidginDebugUi
-{
- GObject parent;
-
- /* Other members, including private data. */
- guint debug_enabled_timer;
-};
-
-static void pidgin_debug_ui_interface_init(PurpleDebugUiInterface *iface);
-
-G_DEFINE_TYPE_WITH_CODE(PidginDebugUi, pidgin_debug_ui, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE(PURPLE_TYPE_DEBUG_UI,
- pidgin_debug_ui_interface_init));
G_DEFINE_TYPE(PidginDebugWindow, pidgin_debug_window, GTK_TYPE_WINDOW);
static gint
@@ -811,11 +798,6 @@
return G_LOG_WRITER_HANDLED;
}
-static void
-pidgin_debug_ui_init(PidginDebugUi *self)
-{
-}
-
void
pidgin_debug_window_show(void)
{
@@ -838,121 +820,6 @@
}
}
-static void
-pidgin_debug_print(PurpleDebugUi *self,
- PurpleDebugLevel level, const char *category,
- const char *arg_s)
-{
- GtkTextTag *level_tag;
- const char *mdate;
- time_t mtime;
- GtkTextIter end;
- gboolean scroll;
-
- if (debug_win == NULL)
- return;
- if (!purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled"))
- return;
-
- scroll = view_near_bottom(debug_win);
- gtk_text_buffer_get_end_iter(debug_win->buffer, &end);
- gtk_text_buffer_move_mark(debug_win->buffer, debug_win->start_mark,
- &end);
-
- level_tag = debug_win->tags.level[level];
-
- mtime = time(NULL);
- mdate = purple_utf8_strftime("(%H:%M:%S) ", localtime(&mtime));
- gtk_text_buffer_insert_with_tags(
- debug_win->buffer,
- &end,
- mdate,
- -1,
- level_tag,
- debug_win->paused ? debug_win->tags.paused : NULL,
- NULL);
-
- if (category && *category) {
- gtk_text_buffer_insert_with_tags(
- debug_win->buffer,
- &end,
- category,
- -1,
- level_tag,
- debug_win->tags.category,
- debug_win->paused ? debug_win->tags.paused : NULL,
- NULL);
- gtk_text_buffer_insert_with_tags(
- debug_win->buffer,
- &end,
- ": ",
- 2,
- level_tag,
- debug_win->tags.category,
- debug_win->paused ? debug_win->tags.paused : NULL,
- NULL);
- }
-
- gtk_text_buffer_insert_with_tags(
- debug_win->buffer,
- &end,
- arg_s,
- -1,
- level_tag,
- debug_win->paused ? debug_win->tags.paused : NULL,
- NULL);
- gtk_text_buffer_insert_with_tags(
- debug_win->buffer,
- &end,
- "\n",
- 1,
- level_tag,
- debug_win->paused ? debug_win->tags.paused : NULL,
- NULL);
-
- if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/filter") && debug_win->regex) {
- /* Filter out any new messages. */
- GtkTextIter start;
-
- gtk_text_buffer_get_iter_at_mark(debug_win->buffer, &start,
- debug_win->start_mark);
- gtk_text_buffer_get_iter_at_mark(debug_win->buffer, &end,
- debug_win->end_mark);
-
- do_regex(debug_win, &start, &end);
- }
-
- if (scroll) {
- gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(debug_win->textview),
- debug_win->end_mark, 0, TRUE, 0, 1);
- }
-}
-
-static gboolean
-pidgin_debug_is_enabled(PurpleDebugUi *self, PurpleDebugLevel level, const char *category)
-{
- return (debug_win != NULL &&
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/enabled"));
-}
-
-static void
-pidgin_debug_ui_interface_init(PurpleDebugUiInterface *iface)
-{
- iface->print = pidgin_debug_print;
- iface->is_enabled = pidgin_debug_is_enabled;
-}
-
-static void
-pidgin_debug_ui_class_init(PidginDebugUiClass *klass)
-{
-}
-
-PidginDebugUi *
-pidgin_debug_ui_new(void)
-{
- return g_object_new(PIDGIN_TYPE_DEBUG_UI, NULL);
-}
-
void
pidgin_debug_init_handler(void)
{
--- a/pidgin/pidgindebug.h Tue Oct 19 00:40:28 2021 -0500
+++ b/pidgin/pidgindebug.h Tue Oct 19 00:41:44 2021 -0500
@@ -36,9 +36,7 @@
G_BEGIN_DECLS
-#define PIDGIN_TYPE_DEBUG_UI (pidgin_debug_ui_get_type())
#define PIDGIN_TYPE_DEBUG_WINDOW (pidgin_debug_window_get_type())
-G_DECLARE_FINAL_TYPE(PidginDebugUi, pidgin_debug_ui, PIDGIN, DEBUG_UI, GObject)
G_DECLARE_FINAL_TYPE(PidginDebugWindow, pidgin_debug_window, PIDGIN, DEBUG_WINDOW, GtkWindow)
/**
@@ -72,13 +70,6 @@
void pidgin_debug_uninit(void);
/**
- * pidgin_debug_ui_new:
- *
- * Initializes the GTK debug system.
- */
-PidginDebugUi *pidgin_debug_ui_new(void);
-
-/**
* pidgin_debug_get_handle:
*
* Get the handle for the GTK debug system.