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

Add option to hide the "playback" message #13

Merged
merged 7 commits into from
Jul 31, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 20 additions & 9 deletions src/znchelper.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ static void znc_write_chat(
PurpleConversation *conv, const char *who, const char *message,
PurpleMessageFlags flags, time_t mtime
) {
PurpleConnection *gc = purple_conversation_get_gc(conv);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please don't mix up declarations and code and make sure to check the return values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix that right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit added to fix this

PurpleConvChat *chat;
struct znc_conn *znc;
GList *parted, *l;
Expand All @@ -122,10 +123,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_account_get_bool(gc->account, "hide_znc_playback_message", FALSE)) {
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 +332,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_account_get_bool(gc->account, "hide_znc_playback_message", FALSE)) {
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 @@ -444,6 +449,7 @@ static void core_quitting_cb() {

static gboolean plugin_load(PurplePlugin *plugin) {
PurpleAccountOption *option;
PurpleAccountOption *option2;
GList *convs;

prpl_irc = purple_find_prpl("prpl-irc");
Expand All @@ -462,7 +468,12 @@ static gboolean plugin_load(PurplePlugin *plugin) {
option = purple_account_option_bool_new(
_("Uses ZNC bouncer"), "uses_znc_bouncer", FALSE
);
option2 = purple_account_option_bool_new(
_("Hide ZNC Playback Message"), "hide_znc_playback_message", FALSE
);
irc_info->protocol_options = g_list_append(irc_info->protocol_options, option);
irc_info->protocol_options = g_list_append(irc_info->protocol_options, option2);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove newline


znc_conns = g_hash_table_new_full(NULL, NULL, NULL, g_free);

Expand Down Expand Up @@ -525,7 +536,7 @@ static gboolean plugin_unload(PurplePlugin *plugin) {
for(l = irc_info->protocol_options; l != NULL; l = l->next) {
option = (PurpleAccountOption *)l->data;
setting = purple_account_option_get_setting(option);
if(setting && g_str_equal(setting, "uses_znc_bouncer")) {
if(setting && (g_str_equal(setting, "uses_znc_bouncer") || g_str_equal(setting, "hide_znc_playback_message"))) {
irc_info->protocol_options = g_list_delete_link(
irc_info->protocol_options, l
);
Expand Down