1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

Added chlog preference for chat logging

This commit is contained in:
James Booth 2012-07-22 23:07:34 +01:00
parent a3efcb7e05
commit 6b697054b6
5 changed files with 47 additions and 13 deletions

View File

@ -48,6 +48,7 @@ static gboolean _cmd_set_beep(const char * const inp);
static gboolean _cmd_set_notify(const char * const inp);
static gboolean _cmd_set_flash(const char * const inp);
static gboolean _cmd_set_showsplash(const char * const inp);
static gboolean _cmd_set_chlog(const char * const inp);
static gboolean _cmd_away(const char * const inp);
static gboolean _cmd_online(const char * const inp);
static gboolean _cmd_dnd(const char * const inp);
@ -80,11 +81,12 @@ static struct cmd_t commands[] = {
{ "/quit", _cmd_quit },
{ "/ros", _cmd_ros },
{ "/showsplash", _cmd_set_showsplash },
{ "/chlog", _cmd_set_chlog },
{ "/who", _cmd_who },
{ "/xa", _cmd_xa },
};
static const int num_cmds = 16;
static const int num_cmds = 17;
gboolean process_input(char *inp)
{
@ -331,6 +333,21 @@ static gboolean _cmd_set_showsplash(const char * const inp)
return TRUE;
}
static gboolean _cmd_set_chlog(const char * const inp)
{
if (strcmp(inp, "/chlog on") == 0) {
cons_show("Chat logging enabled.");
prefs_set_chlog(TRUE);
} else if (strcmp(inp, "/chlog off") == 0) {
cons_show("Chat logging disabled.");
prefs_set_chlog(FALSE);
} else {
cons_show("Usage: /chlog <on/off>");
}
return TRUE;
}
static gboolean _cmd_away(const char * const inp)
{
_update_presence(PRESENCE_AWAY, "away", inp);

View File

@ -166,10 +166,11 @@ void jabber_send(const char * const msg, const char * const recipient)
free(coded_msg);
free(coded_msg2);
free(coded_msg3);
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
chat_log_chat(jid, (char *)recipient, msg, OUT);
if (prefs_get_chlog()) {
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
chat_log_chat(jid, (char *)recipient, msg, OUT);
}
}
void jabber_roster_request(void)
@ -255,13 +256,14 @@ static int _jabber_message_handler(xmpp_conn_t * const conn,
win_show_incomming_msg(from, message);
win_page_off();
char from_cpy[strlen(from) + 1];
strcpy(from_cpy, from);
char *short_from = strtok(from_cpy, "/");
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
chat_log_chat(jid, short_from, message, IN);
if (prefs_get_chlog()) {
char from_cpy[strlen(from) + 1];
strcpy(from_cpy, from);
char *short_from = strtok(from_cpy, "/");
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
chat_log_chat(jid, short_from, message, IN);
}
return 1;
}

View File

@ -195,6 +195,17 @@ void prefs_set_flash(gboolean value)
_save_prefs();
}
gboolean prefs_get_chlog(void)
{
return g_key_file_get_boolean(prefs, "ui", "chlog", NULL);
}
void prefs_set_chlog(gboolean value)
{
g_key_file_set_boolean(prefs, "ui", "chlog", value);
_save_prefs();
}
void prefs_add_login(const char *jid)
{
gsize njids;

View File

@ -36,10 +36,13 @@ gboolean prefs_get_notify(void);
void prefs_set_notify(gboolean value);
gboolean prefs_get_flash(void);
void prefs_set_flash(gboolean value);
void prefs_add_login(const char *jid);
gboolean prefs_get_chlog(void);
void prefs_set_chlog(gboolean value);
gboolean prefs_get_showsplash(void);
void prefs_set_showsplash(gboolean value);
void prefs_add_login(const char *jid);
NCURSES_COLOR_T prefs_get_bkgnd();
NCURSES_COLOR_T prefs_get_text();
NCURSES_COLOR_T prefs_get_online();

View File

@ -352,6 +352,7 @@ void cons_help(void)
cons_show("/notify <on/off> : Enable/disable desktop notifications");
cons_show("/flash <on/off> : Enable/disable screen flash notification");
cons_show("/showsplash <on/off> : Enable/disable splash logo on startup");
cons_show("/chlog <on/off> : Enable/disable chat logging");
cons_show("");
cons_show("Status changes (msg is optional):");
cons_show("");