Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Add option to hide the "playback" message (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
Valinwolf authored and kgraefe committed Jul 31, 2019
1 parent c178efb commit a56ff23
Showing 1 changed file with 44 additions and 9 deletions.
53 changes: 44 additions & 9 deletions src/znchelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ static gboolean core_quitting = FALSE;
#define ZNC_CONV_STATE_START 0
#define ZNC_CONV_STATE_REPLAY 1
#define ZNC_CONV_STATE_DONE 2
#define PREF_PREFIX "/plugins/core/znc-helper"
#define PREF_HIDEMSG PREF_PREFIX "/hidemsg"

struct znc_conn {
gboolean server_time_enabled;
Expand Down Expand Up @@ -122,10 +124,12 @@ static void znc_write_chat(
state = GPOINTER_TO_INT(purple_conversation_get_data(conv, "znc-state"));
switch(state) {
case ZNC_CONV_STATE_START:
ui_write_chat(
conv, "***", _("Buffer Playback..."),
PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_SYSTEM, time(NULL)
);
if(!purple_prefs_get_bool(PREF_HIDEMSG)) {
ui_write_chat(
conv, "***", _("Buffer Playback..."),
PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_SYSTEM, time(NULL)
);
}
purple_conversation_set_data(conv,
"znc-state", GINT_TO_POINTER(ZNC_CONV_STATE_REPLAY)
);
Expand Down Expand Up @@ -329,10 +333,12 @@ static void parse_endofwho(PurpleConnection *gc, char **text) {
goto exit;
}

ui_write_chat(
conv, "***", _("Playback Complete."),
PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_SYSTEM, time(NULL)
);
if(!purple_prefs_get_bool(PREF_HIDEMSG)) {
ui_write_chat(
conv, "***", _("Playback Complete."),
PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_SYSTEM, time(NULL)
);
}

/* Remove all users from the chat that are in the playback but
* not present anymore. This gives the UI the chance to mark
Expand Down Expand Up @@ -540,6 +546,33 @@ static gboolean plugin_unload(PurplePlugin *plugin) {
return TRUE;
}

static PurplePluginPrefFrame *
get_plugin_pref_frame(PurplePlugin *plugin)
{
PurplePluginPrefFrame *frame;
PurplePluginPref *pref;

frame = purple_plugin_pref_frame_new();

pref = purple_plugin_pref_new_with_name_and_label(PREF_HIDEMSG,
_("Hide the playback start/end messages"));
purple_plugin_pref_frame_add(frame, pref);

return frame;
}

static PurplePluginUiInfo prefs_info = {
get_plugin_pref_frame,
0,
NULL,

/* padding */
NULL,
NULL,
NULL,
NULL
};

static PurplePluginInfo info = {
PURPLE_PLUGIN_MAGIC,
PURPLE_MAJOR_VERSION,
Expand All @@ -564,7 +597,7 @@ static PurplePluginInfo info = {

NULL, /**< ui_info */
NULL, /**< extra_info */
NULL, /**< prefs_info */
&prefs_info, /**< prefs_info */
NULL, /**< actions */
/* padding */
NULL,
Expand All @@ -591,6 +624,8 @@ static void init_plugin(PurplePlugin *plugin) {
info.name = _("ZNC Helper");
info.summary = _("Pidgin ZNC Helper parses IRC bouncer timestamps and displays them as normal timestamps.");
info.description = _("Pidgin ZNC Helper parses IRC bouncer timestamps and displays them as normal timestamps.");
purple_prefs_add_none(PREF_PREFIX);
purple_prefs_add_bool(PREF_HIDEMSG, FALSE);
}

PURPLE_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info)

0 comments on commit a56ff23

Please sign in to comment.