From 7982d7061b89e3bd3a6c8528f8d0491104998bc7 Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 31 Oct 2012 21:41:00 +0000 Subject: [PATCH] Added states preference to enable chat states --- src/command.c | 29 +++++++++++++++++++++++++++++ src/preferences.c | 13 +++++++++++++ src/preferences.h | 2 ++ src/windows.c | 5 +++++ 4 files changed, 49 insertions(+) diff --git a/src/command.c b/src/command.c index d4f1756d..475bb433 100644 --- a/src/command.c +++ b/src/command.c @@ -94,6 +94,7 @@ static gboolean _cmd_set_flash(const char * const inp, struct cmd_help_t help); static gboolean _cmd_set_showsplash(const char * const inp, struct cmd_help_t help); static gboolean _cmd_set_chlog(const char * const inp, struct cmd_help_t help); static gboolean _cmd_set_history(const char * const inp, struct cmd_help_t help); +static gboolean _cmd_set_states(const char * const inp, struct cmd_help_t help); static gboolean _cmd_vercheck(const char * const inp, struct cmd_help_t help); static gboolean _cmd_away(const char * const inp, struct cmd_help_t help); static gboolean _cmd_online(const char * const inp, struct cmd_help_t help); @@ -331,8 +332,26 @@ static struct cmd_t setting_commands[] = "to myfriend@chatserv.com, the following chat log will be created:", "", " ~/.profanity/log/someuser_at_chatserv.com/myfriend_at_chatserv.com", + "", + "Config file section : [ui]", + "Config file value : chlog=true|false", NULL } } }, + { "/states", + _cmd_set_states, + { "/states on|off", "Send chat states during a chat session.", + { "/states on|off", + "--------------", + "Sending of chat state notifications during chat sessions.", + "Enabling this will send information about your activity during a chat", + "session with somebody, such as whether you have become inactive, or", + "have close the chat window.", + "", + "Config file section : [ui]", + "Config file value : states=true|false", + NULL } } }, + + { "/history", _cmd_set_history, { "/history on|off", "Chat history in message windows.", @@ -343,6 +362,9 @@ static struct cmd_t setting_commands[] = "The last day of messages are shown, or if you have had profanity open", "for more than a day, messages will be shown from the day which", "you started profanity.", + "", + "Config file section : [ui]", + "Config file value : history=true|false", NULL } } } }; @@ -1012,6 +1034,13 @@ _cmd_set_beep(const char * const inp, struct cmd_help_t help) "Sound", prefs_set_beep); } +static gboolean +_cmd_set_states(const char * const inp, struct cmd_help_t help) +{ + return _cmd_set_boolean_preference(inp, help, "/states", + "Sending chat states", prefs_set_states); +} + static gboolean _cmd_set_notify(const char * const inp, struct cmd_help_t help) { diff --git a/src/preferences.c b/src/preferences.c index 78044fcc..b1e2f0a0 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -235,6 +235,19 @@ prefs_set_beep(gboolean value) _save_prefs(); } +gboolean +prefs_get_states(void) +{ + return g_key_file_get_boolean(prefs, "ui", "states", NULL); +} + +void +prefs_set_states(gboolean value) +{ + g_key_file_set_boolean(prefs, "ui", "states", value); + _save_prefs(); +} + gboolean prefs_get_notify_typing(void) { diff --git a/src/preferences.h b/src/preferences.h index 6ccdf461..31f352cb 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -56,6 +56,8 @@ gboolean prefs_get_vercheck(void); void prefs_set_vercheck(gboolean value); gboolean prefs_get_intype(void); void prefs_set_intype(gboolean value); +gboolean prefs_get_states(void); +void prefs_set_states(gboolean value); void prefs_set_notify_message(gboolean value); gboolean prefs_get_notify_message(void); diff --git a/src/windows.c b/src/windows.c index 0d4c0b7c..5f3fad1e 100644 --- a/src/windows.c +++ b/src/windows.c @@ -552,6 +552,11 @@ cons_prefs(void) else cons_show("Chat logging : OFF"); + if (prefs_get_states()) + cons_show("Send chat states : ON"); + else + cons_show("Send chat states : OFF"); + if (prefs_get_history()) cons_show("Chat history : ON"); else