mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added chlog preference for chat logging
This commit is contained in:
parent
a3efcb7e05
commit
6b697054b6
@ -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_notify(const char * const inp);
|
||||||
static gboolean _cmd_set_flash(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_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_away(const char * const inp);
|
||||||
static gboolean _cmd_online(const char * const inp);
|
static gboolean _cmd_online(const char * const inp);
|
||||||
static gboolean _cmd_dnd(const char * const inp);
|
static gboolean _cmd_dnd(const char * const inp);
|
||||||
@ -80,11 +81,12 @@ static struct cmd_t commands[] = {
|
|||||||
{ "/quit", _cmd_quit },
|
{ "/quit", _cmd_quit },
|
||||||
{ "/ros", _cmd_ros },
|
{ "/ros", _cmd_ros },
|
||||||
{ "/showsplash", _cmd_set_showsplash },
|
{ "/showsplash", _cmd_set_showsplash },
|
||||||
|
{ "/chlog", _cmd_set_chlog },
|
||||||
{ "/who", _cmd_who },
|
{ "/who", _cmd_who },
|
||||||
{ "/xa", _cmd_xa },
|
{ "/xa", _cmd_xa },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int num_cmds = 16;
|
static const int num_cmds = 17;
|
||||||
|
|
||||||
gboolean process_input(char *inp)
|
gboolean process_input(char *inp)
|
||||||
{
|
{
|
||||||
@ -331,6 +333,21 @@ static gboolean _cmd_set_showsplash(const char * const inp)
|
|||||||
return TRUE;
|
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)
|
static gboolean _cmd_away(const char * const inp)
|
||||||
{
|
{
|
||||||
_update_presence(PRESENCE_AWAY, "away", inp);
|
_update_presence(PRESENCE_AWAY, "away", inp);
|
||||||
|
@ -167,9 +167,10 @@ void jabber_send(const char * const msg, const char * const recipient)
|
|||||||
free(coded_msg2);
|
free(coded_msg2);
|
||||||
free(coded_msg3);
|
free(coded_msg3);
|
||||||
|
|
||||||
|
if (prefs_get_chlog()) {
|
||||||
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
|
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
|
||||||
|
|
||||||
chat_log_chat(jid, (char *)recipient, msg, OUT);
|
chat_log_chat(jid, (char *)recipient, msg, OUT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void jabber_roster_request(void)
|
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_show_incomming_msg(from, message);
|
||||||
win_page_off();
|
win_page_off();
|
||||||
|
|
||||||
|
if (prefs_get_chlog()) {
|
||||||
char from_cpy[strlen(from) + 1];
|
char from_cpy[strlen(from) + 1];
|
||||||
strcpy(from_cpy, from);
|
strcpy(from_cpy, from);
|
||||||
char *short_from = strtok(from_cpy, "/");
|
char *short_from = strtok(from_cpy, "/");
|
||||||
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
|
const char *jid = xmpp_conn_get_jid(jabber_conn.conn);
|
||||||
|
|
||||||
|
|
||||||
chat_log_chat(jid, short_from, message, IN);
|
chat_log_chat(jid, short_from, message, IN);
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -195,6 +195,17 @@ void prefs_set_flash(gboolean value)
|
|||||||
_save_prefs();
|
_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)
|
void prefs_add_login(const char *jid)
|
||||||
{
|
{
|
||||||
gsize njids;
|
gsize njids;
|
||||||
|
@ -36,10 +36,13 @@ gboolean prefs_get_notify(void);
|
|||||||
void prefs_set_notify(gboolean value);
|
void prefs_set_notify(gboolean value);
|
||||||
gboolean prefs_get_flash(void);
|
gboolean prefs_get_flash(void);
|
||||||
void prefs_set_flash(gboolean value);
|
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);
|
gboolean prefs_get_showsplash(void);
|
||||||
void prefs_set_showsplash(gboolean value);
|
void prefs_set_showsplash(gboolean value);
|
||||||
|
|
||||||
|
void prefs_add_login(const char *jid);
|
||||||
|
|
||||||
NCURSES_COLOR_T prefs_get_bkgnd();
|
NCURSES_COLOR_T prefs_get_bkgnd();
|
||||||
NCURSES_COLOR_T prefs_get_text();
|
NCURSES_COLOR_T prefs_get_text();
|
||||||
NCURSES_COLOR_T prefs_get_online();
|
NCURSES_COLOR_T prefs_get_online();
|
||||||
|
@ -352,6 +352,7 @@ void cons_help(void)
|
|||||||
cons_show("/notify <on/off> : Enable/disable desktop notifications");
|
cons_show("/notify <on/off> : Enable/disable desktop notifications");
|
||||||
cons_show("/flash <on/off> : Enable/disable screen flash notification");
|
cons_show("/flash <on/off> : Enable/disable screen flash notification");
|
||||||
cons_show("/showsplash <on/off> : Enable/disable splash logo on startup");
|
cons_show("/showsplash <on/off> : Enable/disable splash logo on startup");
|
||||||
|
cons_show("/chlog <on/off> : Enable/disable chat logging");
|
||||||
cons_show("");
|
cons_show("");
|
||||||
cons_show("Status changes (msg is optional):");
|
cons_show("Status changes (msg is optional):");
|
||||||
cons_show("");
|
cons_show("");
|
||||||
|
Loading…
Reference in New Issue
Block a user