mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-31 12:36:21 +00:00
Merge branch 'master' into type_out
This commit is contained in:
@@ -72,6 +72,8 @@ notify=true
|
|||||||
.br
|
.br
|
||||||
chlog=true
|
chlog=true
|
||||||
.br
|
.br
|
||||||
|
history=true
|
||||||
|
.br
|
||||||
typing=true
|
typing=true
|
||||||
.br
|
.br
|
||||||
remind=15
|
remind=15
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ static gboolean _log_roll_needed(struct dated_chat_log *dated_log);
|
|||||||
static struct dated_chat_log *_create_log(char *other, const char * const login);
|
static struct dated_chat_log *_create_log(char *other, const char * const login);
|
||||||
static void _free_chat_log(struct dated_chat_log *dated_log);
|
static void _free_chat_log(struct dated_chat_log *dated_log);
|
||||||
static gboolean _key_equals(void *key1, void *key2);
|
static gboolean _key_equals(void *key1, void *key2);
|
||||||
static char * _get_log_filename(char *other, const char * const login,
|
static char * _get_log_filename(const char * const other, const char * const login,
|
||||||
GDateTime *dt);
|
GDateTime *dt, gboolean create);
|
||||||
|
|
||||||
void
|
void
|
||||||
chat_log_init(void)
|
chat_log_init(void)
|
||||||
@@ -94,7 +94,7 @@ chat_log_chat(const gchar * const login, gchar *other,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GSList *
|
GSList *
|
||||||
chat_log_get_previous(const gchar * const login, gchar *recipient,
|
chat_log_get_previous(const gchar * const login, const gchar * const recipient,
|
||||||
GSList *history)
|
GSList *history)
|
||||||
{
|
{
|
||||||
GTimeZone *tz = g_time_zone_new_local();
|
GTimeZone *tz = g_time_zone_new_local();
|
||||||
@@ -110,7 +110,7 @@ chat_log_get_previous(const gchar * const login, gchar *recipient,
|
|||||||
|
|
||||||
// get data from all logs from the day the session was started to today
|
// get data from all logs from the day the session was started to today
|
||||||
while (g_date_time_get_day_of_year(log_date) <= g_date_time_get_day_of_year(now)) {
|
while (g_date_time_get_day_of_year(log_date) <= g_date_time_get_day_of_year(now)) {
|
||||||
char *filename = _get_log_filename(recipient, login, log_date);
|
char *filename = _get_log_filename(recipient, login, log_date, FALSE);
|
||||||
|
|
||||||
FILE *logp = fopen(filename, "r");
|
FILE *logp = fopen(filename, "r");
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
@@ -162,7 +162,7 @@ static struct dated_chat_log *
|
|||||||
_create_log(char *other, const char * const login)
|
_create_log(char *other, const char * const login)
|
||||||
{
|
{
|
||||||
GDateTime *now = g_date_time_new_now_local();
|
GDateTime *now = g_date_time_new_now_local();
|
||||||
char *filename = _get_log_filename(other, login, now);
|
char *filename = _get_log_filename(other, login, now, TRUE);
|
||||||
|
|
||||||
struct dated_chat_log *new_log = malloc(sizeof(struct dated_chat_log));
|
struct dated_chat_log *new_log = malloc(sizeof(struct dated_chat_log));
|
||||||
new_log->filename = strdup(filename);
|
new_log->filename = strdup(filename);
|
||||||
@@ -213,20 +213,27 @@ gboolean _key_equals(void *key1, void *key2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
_get_log_filename(char *other, const char * const login, GDateTime *dt)
|
_get_log_filename(const char * const other, const char * const login,
|
||||||
|
GDateTime *dt, gboolean create)
|
||||||
{
|
{
|
||||||
GString *log_file = g_string_new(getenv("HOME"));
|
GString *log_file = g_string_new(getenv("HOME"));
|
||||||
g_string_append(log_file, "/.profanity/log");
|
g_string_append(log_file, "/.profanity/log");
|
||||||
create_dir(log_file->str);
|
if (create) {
|
||||||
|
create_dir(log_file->str);
|
||||||
|
}
|
||||||
|
|
||||||
gchar *login_dir = str_replace(login, "@", "_at_");
|
gchar *login_dir = str_replace(login, "@", "_at_");
|
||||||
g_string_append_printf(log_file, "/%s", login_dir);
|
g_string_append_printf(log_file, "/%s", login_dir);
|
||||||
create_dir(log_file->str);
|
if (create) {
|
||||||
|
create_dir(log_file->str);
|
||||||
|
}
|
||||||
free(login_dir);
|
free(login_dir);
|
||||||
|
|
||||||
gchar *other_file = str_replace(other, "@", "_at_");
|
gchar *other_file = str_replace(other, "@", "_at_");
|
||||||
g_string_append_printf(log_file, "/%s", other_file);
|
g_string_append_printf(log_file, "/%s", other_file);
|
||||||
create_dir(log_file->str);
|
if (create) {
|
||||||
|
create_dir(log_file->str);
|
||||||
|
}
|
||||||
free(other_file);
|
free(other_file);
|
||||||
|
|
||||||
gchar *date = g_date_time_format(dt, "/%Y_%m_%d.log");
|
gchar *date = g_date_time_format(dt, "/%Y_%m_%d.log");
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ void chat_log_init(void);
|
|||||||
void chat_log_chat(const gchar * const login, gchar *other,
|
void chat_log_chat(const gchar * const login, gchar *other,
|
||||||
const gchar * const msg, chat_log_direction_t direction);
|
const gchar * const msg, chat_log_direction_t direction);
|
||||||
void chat_log_close(void);
|
void chat_log_close(void);
|
||||||
GSList * chat_log_get_previous(const gchar * const login, gchar *recipient,
|
GSList * chat_log_get_previous(const gchar * const login,
|
||||||
GSList *history);
|
const gchar * const recipient, GSList *history);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ static gboolean _cmd_set_typing(const char * const inp, struct cmd_help_t help);
|
|||||||
static gboolean _cmd_set_flash(const char * const inp, struct cmd_help_t help);
|
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_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_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_remind(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_set_remind(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_away(const char * const inp, struct cmd_help_t help);
|
||||||
static gboolean _cmd_online(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_online(const char * const inp, struct cmd_help_t help);
|
||||||
@@ -275,6 +276,18 @@ static struct cmd_t setting_commands[] =
|
|||||||
"to myfriend@chatserv.com, the following chat log will be created:",
|
"to myfriend@chatserv.com, the following chat log will be created:",
|
||||||
"",
|
"",
|
||||||
" ~/.profanity/log/someuser_at_chatserv.com/myfriend_at_chatserv.com",
|
" ~/.profanity/log/someuser_at_chatserv.com/myfriend_at_chatserv.com",
|
||||||
|
NULL } } },
|
||||||
|
|
||||||
|
{ "/history",
|
||||||
|
_cmd_set_history,
|
||||||
|
{ "/history on|off", "Enable/disable chat history.",
|
||||||
|
{ "/history on|off",
|
||||||
|
"-------------",
|
||||||
|
"Switch chat history on or off, requires chlog to be enabled.",
|
||||||
|
"When history is enabled, previous messages are shown in chat windows.",
|
||||||
|
"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.",
|
||||||
NULL } } }
|
NULL } } }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -768,6 +781,13 @@ _cmd_set_chlog(const char * const inp, struct cmd_help_t help)
|
|||||||
"Chat logging", prefs_set_chlog);
|
"Chat logging", prefs_set_chlog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_cmd_set_history(const char * const inp, struct cmd_help_t help)
|
||||||
|
{
|
||||||
|
return _cmd_set_boolean_preference(inp, help, "/history",
|
||||||
|
"Chat history", prefs_set_history);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cmd_set_remind(const char * const inp, struct cmd_help_t help)
|
_cmd_set_remind(const char * const inp, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -269,6 +269,19 @@ prefs_set_chlog(gboolean value)
|
|||||||
_save_prefs();
|
_save_prefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
prefs_get_history(void)
|
||||||
|
{
|
||||||
|
return g_key_file_get_boolean(prefs, "ui", "history", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
prefs_set_history(gboolean value)
|
||||||
|
{
|
||||||
|
g_key_file_set_boolean(prefs, "ui", "history", value);
|
||||||
|
_save_prefs();
|
||||||
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
prefs_get_remind(void)
|
prefs_get_remind(void)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ gboolean prefs_get_flash(void);
|
|||||||
void prefs_set_flash(gboolean value);
|
void prefs_set_flash(gboolean value);
|
||||||
gboolean prefs_get_chlog(void);
|
gboolean prefs_get_chlog(void);
|
||||||
void prefs_set_chlog(gboolean value);
|
void prefs_set_chlog(gboolean value);
|
||||||
|
gboolean prefs_get_history(void);
|
||||||
|
void prefs_set_history(gboolean value);
|
||||||
gboolean prefs_get_showsplash(void);
|
gboolean prefs_get_showsplash(void);
|
||||||
void prefs_set_showsplash(gboolean value);
|
void prefs_set_showsplash(gboolean value);
|
||||||
gint prefs_get_remind(void);
|
gint prefs_get_remind(void);
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ win_show_incomming_msg(const char * const from, const char * const message)
|
|||||||
flash();
|
flash();
|
||||||
|
|
||||||
_wins[win_index].unread++;
|
_wins[win_index].unread++;
|
||||||
if (prefs_get_chlog()) {
|
if (prefs_get_chlog() && prefs_get_history()) {
|
||||||
if (!_wins[win_index].history_shown) {
|
if (!_wins[win_index].history_shown) {
|
||||||
GSList *history = NULL;
|
GSList *history = NULL;
|
||||||
history = chat_log_get_previous(jabber_get_jid(), short_from, history);
|
history = chat_log_get_previous(jabber_get_jid(), short_from, history);
|
||||||
@@ -389,7 +389,7 @@ win_show_outgoing_msg(const char * const from, const char * const to,
|
|||||||
win_index = _new_prof_win(to);
|
win_index = _new_prof_win(to);
|
||||||
win = _wins[win_index].win;
|
win = _wins[win_index].win;
|
||||||
|
|
||||||
if (prefs_get_chlog()) {
|
if (prefs_get_chlog() && prefs_get_history()) {
|
||||||
if (!_wins[win_index].history_shown) {
|
if (!_wins[win_index].history_shown) {
|
||||||
GSList *history = NULL;
|
GSList *history = NULL;
|
||||||
history = chat_log_get_previous(jabber_get_jid(), to, history);
|
history = chat_log_get_previous(jabber_get_jid(), to, history);
|
||||||
@@ -531,6 +531,11 @@ cons_prefs(void)
|
|||||||
else
|
else
|
||||||
cons_show("Chat logging : OFF");
|
cons_show("Chat logging : OFF");
|
||||||
|
|
||||||
|
if (prefs_get_history())
|
||||||
|
cons_show("Chat history : ON");
|
||||||
|
else
|
||||||
|
cons_show("Chat history : OFF");
|
||||||
|
|
||||||
gint remind_period = prefs_get_remind();
|
gint remind_period = prefs_get_remind();
|
||||||
if (remind_period == 0) {
|
if (remind_period == 0) {
|
||||||
cons_show("Message reminder period : OFF");
|
cons_show("Message reminder period : OFF");
|
||||||
|
|||||||
Reference in New Issue
Block a user