Merge branch 'master' into chatstates
This commit is contained in:
207
src/command.c
207
src/command.c
@@ -71,12 +71,11 @@ static gboolean _cmd_tiny(const char * const inp, struct cmd_help_t help);
|
|||||||
static gboolean _cmd_close(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_close(const char * const inp, struct cmd_help_t help);
|
||||||
static gboolean _cmd_set_beep(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_set_beep(const char * const inp, struct cmd_help_t help);
|
||||||
static gboolean _cmd_set_notify(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_set_notify(const char * const inp, struct cmd_help_t help);
|
||||||
static gboolean _cmd_set_typing(const char * const inp, struct cmd_help_t help);
|
static gboolean _cmd_set_intype(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_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_vercheck(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_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);
|
||||||
@@ -207,7 +206,7 @@ static struct cmd_t setting_commands[] =
|
|||||||
{
|
{
|
||||||
{ "/beep",
|
{ "/beep",
|
||||||
_cmd_set_beep,
|
_cmd_set_beep,
|
||||||
{ "/beep on|off", "Enable/disable sound notifications.",
|
{ "/beep on|off", "Terminal beep on new messages.",
|
||||||
{ "/beep on|off",
|
{ "/beep on|off",
|
||||||
"------------",
|
"------------",
|
||||||
"Switch the terminal bell on or off.",
|
"Switch the terminal bell on or off.",
|
||||||
@@ -221,46 +220,32 @@ static struct cmd_t setting_commands[] =
|
|||||||
|
|
||||||
{ "/notify",
|
{ "/notify",
|
||||||
_cmd_set_notify,
|
_cmd_set_notify,
|
||||||
{ "/notify on|off", "Enable/disable message notifications.",
|
{ "/notify type value", "Control various desktop noficiations.",
|
||||||
{ "/notify on|off",
|
{ "/notify type value",
|
||||||
"--------------",
|
"------------------",
|
||||||
"Switch the message notifications on or off.",
|
"Settings for various desktop notifications where type is one of:",
|
||||||
"The notification will appear for all incoming messages.",
|
"message : Notificaitons for messages.",
|
||||||
"The desktop environment must support desktop notifications.",
|
" : on|off",
|
||||||
|
"remind : Notification reminders of unread messages.",
|
||||||
|
" : where value is the reminder period in seconds,",
|
||||||
|
" : use 0 to disable.",
|
||||||
|
"typing : Notifications when contacts are typing.",
|
||||||
|
" : on|off",
|
||||||
"",
|
"",
|
||||||
"Config file section : [ui]",
|
"Example : /notify message on (enable message notifications)",
|
||||||
"Config file value : notify=true|false",
|
"Example : /notify remind 10 (remind every 10 seconds)",
|
||||||
NULL } } },
|
"Example : /notify remind 0 (switch off reminders)",
|
||||||
|
"Example : /notify typing on (enable typing notifications)",
|
||||||
{ "/typing",
|
|
||||||
_cmd_set_typing,
|
|
||||||
{ "/typing on|off", "Enable/disable typing notifications.",
|
|
||||||
{ "/typing on|off",
|
|
||||||
"--------------",
|
|
||||||
"Switch typing notifications on or off for incoming messages",
|
|
||||||
"If desktop notifications are also enabled you will receive them",
|
|
||||||
"for when users are typing a message to you.",
|
|
||||||
"",
|
"",
|
||||||
"Config file section : [ui]",
|
"Config file section : [notifications]",
|
||||||
"Config file value : typing=true|false",
|
"Config file value : message=on|off",
|
||||||
NULL } } },
|
"Config file value : typing=on|off",
|
||||||
|
|
||||||
{ "/remind",
|
|
||||||
_cmd_set_remind,
|
|
||||||
{ "/remind seconds", "Set message reminder period in seconds.",
|
|
||||||
{ "/remind seconds",
|
|
||||||
"--------------",
|
|
||||||
"Set the period for new message reminders as desktop notifications.",
|
|
||||||
"The value is in seconds, a setting of 0 will disable the feature.",
|
|
||||||
"The desktop environment must support desktop notifications.",
|
|
||||||
"",
|
|
||||||
"Config file section : [ui]",
|
|
||||||
"Config file value : remind=seconds",
|
"Config file value : remind=seconds",
|
||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
{ "/flash",
|
{ "/flash",
|
||||||
_cmd_set_flash,
|
_cmd_set_flash,
|
||||||
{ "/flash on|off", "Enable/disable screen flash notifications.",
|
{ "/flash on|off", "Terminal flash on new messages.",
|
||||||
{ "/flash on|off",
|
{ "/flash on|off",
|
||||||
"-------------",
|
"-------------",
|
||||||
"Make the terminal flash when incoming messages are recieved.",
|
"Make the terminal flash when incoming messages are recieved.",
|
||||||
@@ -272,9 +257,20 @@ static struct cmd_t setting_commands[] =
|
|||||||
"Config file value : flash=true|false",
|
"Config file value : flash=true|false",
|
||||||
NULL } } },
|
NULL } } },
|
||||||
|
|
||||||
|
{ "/intype",
|
||||||
|
_cmd_set_intype,
|
||||||
|
{ "/intype on|off", "Show when contact is typing.",
|
||||||
|
{ "/intype on|off",
|
||||||
|
"--------------",
|
||||||
|
"Show when a contact is typing in the console, and in active message window.",
|
||||||
|
"",
|
||||||
|
"Config file section : [ui]",
|
||||||
|
"Config file value : intype=true|false",
|
||||||
|
NULL } } },
|
||||||
|
|
||||||
{ "/showsplash",
|
{ "/showsplash",
|
||||||
_cmd_set_showsplash,
|
_cmd_set_showsplash,
|
||||||
{ "/showsplash on|off", "Enable/disable splash logo on startup.",
|
{ "/showsplash on|off", "Splash logo on startup.",
|
||||||
{ "/showsplash on|off",
|
{ "/showsplash on|off",
|
||||||
"------------------",
|
"------------------",
|
||||||
"Switch on or off the ascii logo on start up.",
|
"Switch on or off the ascii logo on start up.",
|
||||||
@@ -295,7 +291,7 @@ static struct cmd_t setting_commands[] =
|
|||||||
|
|
||||||
{ "/chlog",
|
{ "/chlog",
|
||||||
_cmd_set_chlog,
|
_cmd_set_chlog,
|
||||||
{ "/chlog on|off", "Enable/disable chat logging.",
|
{ "/chlog on|off", "Chat logging to file",
|
||||||
{ "/chlog on|off",
|
{ "/chlog on|off",
|
||||||
"-------------",
|
"-------------",
|
||||||
"Switch chat logging on or off.",
|
"Switch chat logging on or off.",
|
||||||
@@ -311,7 +307,7 @@ static struct cmd_t setting_commands[] =
|
|||||||
|
|
||||||
{ "/history",
|
{ "/history",
|
||||||
_cmd_set_history,
|
_cmd_set_history,
|
||||||
{ "/history on|off", "Enable/disable chat history.",
|
{ "/history on|off", "Chat history in message windows.",
|
||||||
{ "/history on|off",
|
{ "/history on|off",
|
||||||
"-------------",
|
"-------------",
|
||||||
"Switch chat history on or off, requires chlog to be enabled.",
|
"Switch chat history on or off, requires chlog to be enabled.",
|
||||||
@@ -385,6 +381,7 @@ static struct cmd_t status_commands[] =
|
|||||||
|
|
||||||
static PAutocomplete commands_ac;
|
static PAutocomplete commands_ac;
|
||||||
static PAutocomplete help_ac;
|
static PAutocomplete help_ac;
|
||||||
|
static PAutocomplete notify_ac;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialise command autocompleter and history
|
* Initialise command autocompleter and history
|
||||||
@@ -399,6 +396,10 @@ cmd_init(void)
|
|||||||
p_autocomplete_add(help_ac, strdup("status"));
|
p_autocomplete_add(help_ac, strdup("status"));
|
||||||
p_autocomplete_add(help_ac, strdup("settings"));
|
p_autocomplete_add(help_ac, strdup("settings"));
|
||||||
p_autocomplete_add(help_ac, strdup("navigation"));
|
p_autocomplete_add(help_ac, strdup("navigation"));
|
||||||
|
notify_ac = p_autocomplete_new();
|
||||||
|
p_autocomplete_add(notify_ac, strdup("message"));
|
||||||
|
p_autocomplete_add(notify_ac, strdup("typing"));
|
||||||
|
p_autocomplete_add(notify_ac, strdup("remind"));
|
||||||
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
for (i = 0; i < ARRAY_SIZE(main_commands); i++) {
|
for (i = 0; i < ARRAY_SIZE(main_commands); i++) {
|
||||||
@@ -427,6 +428,7 @@ cmd_close(void)
|
|||||||
{
|
{
|
||||||
p_autocomplete_clear(commands_ac);
|
p_autocomplete_clear(commands_ac);
|
||||||
p_autocomplete_clear(help_ac);
|
p_autocomplete_clear(help_ac);
|
||||||
|
p_autocomplete_clear(notify_ac);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command autocompletion functions
|
// Command autocompletion functions
|
||||||
@@ -443,7 +445,7 @@ cmd_reset_completer(void)
|
|||||||
p_autocomplete_reset(commands_ac);
|
p_autocomplete_reset(commands_ac);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Command help
|
// Command help autocomplete
|
||||||
char *
|
char *
|
||||||
cmd_help_complete(char *inp)
|
cmd_help_complete(char *inp)
|
||||||
{
|
{
|
||||||
@@ -456,6 +458,19 @@ cmd_help_reset_completer(void)
|
|||||||
p_autocomplete_reset(help_ac);
|
p_autocomplete_reset(help_ac);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Command notify autcomplete
|
||||||
|
char *
|
||||||
|
cmd_notify_complete(char *inp)
|
||||||
|
{
|
||||||
|
return p_autocomplete_complete(notify_ac, inp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cmd_notify_reset_completer(void)
|
||||||
|
{
|
||||||
|
p_autocomplete_reset(notify_ac);
|
||||||
|
}
|
||||||
|
|
||||||
GSList *
|
GSList *
|
||||||
cmd_get_basic_help(void)
|
cmd_get_basic_help(void)
|
||||||
{
|
{
|
||||||
@@ -847,15 +862,76 @@ _cmd_set_beep(const char * const inp, struct cmd_help_t help)
|
|||||||
static gboolean
|
static gboolean
|
||||||
_cmd_set_notify(const char * const inp, struct cmd_help_t help)
|
_cmd_set_notify(const char * const inp, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
return _cmd_set_boolean_preference(inp, help, "/notify",
|
char *kind = NULL;
|
||||||
"Desktop notifications", prefs_set_notify);
|
char *value = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
// copy input
|
||||||
_cmd_set_typing(const char * const inp, struct cmd_help_t help)
|
char inp_cpy[strlen(inp) + 1];
|
||||||
{
|
strcpy(inp_cpy, inp);
|
||||||
return _cmd_set_boolean_preference(inp, help, "/typing",
|
|
||||||
"Incoming typing notifications", prefs_set_typing);
|
// get kind
|
||||||
|
strtok(inp_cpy, " ");
|
||||||
|
kind = strtok(NULL, " ");
|
||||||
|
if ((kind != NULL) && (strlen(inp) > (8 + strlen(kind) + 1))) {
|
||||||
|
if ((strcmp(kind, "message") != 0) &&
|
||||||
|
(strcmp(kind, "typing") != 0) &&
|
||||||
|
(strcmp(kind, "remind") != 0)) {
|
||||||
|
cons_show("Usage: %s", help.usage);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
// get value
|
||||||
|
value = strndup(inp+8+strlen(kind)+1, strlen(inp)-(8+strlen(kind)+1));
|
||||||
|
|
||||||
|
if (value != NULL) {
|
||||||
|
|
||||||
|
// set message setting
|
||||||
|
if (strcmp(kind, "message") == 0) {
|
||||||
|
if (strcmp(inp, "/notify message on") == 0) {
|
||||||
|
cons_show("Message notifications enabled.");
|
||||||
|
prefs_set_notify_message(TRUE);
|
||||||
|
} else if (strcmp(inp, "/notify message off") == 0) {
|
||||||
|
cons_show("Message notifications disabled.");
|
||||||
|
prefs_set_notify_message(FALSE);
|
||||||
|
} else {
|
||||||
|
cons_show("Usage: /notify message on|off");
|
||||||
|
}
|
||||||
|
|
||||||
|
// set typing setting
|
||||||
|
} else if (strcmp(kind, "typing") == 0) {
|
||||||
|
if (strcmp(inp, "/notify typing on") == 0) {
|
||||||
|
cons_show("Typing notifications enabled.");
|
||||||
|
prefs_set_notify_typing(TRUE);
|
||||||
|
} else if (strcmp(inp, "/notify typing off") == 0) {
|
||||||
|
cons_show("Typing notifications disabled.");
|
||||||
|
prefs_set_notify_typing(FALSE);
|
||||||
|
} else {
|
||||||
|
cons_show("Usage: /notify typing on|off");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { // remind
|
||||||
|
gint period = atoi(value);
|
||||||
|
|
||||||
|
prefs_set_notify_remind(period);
|
||||||
|
if (period == 0) {
|
||||||
|
cons_show("Message reminders disabled.");
|
||||||
|
} else if (period == 1) {
|
||||||
|
cons_show("Message reminder period set to 1 second.");
|
||||||
|
} else {
|
||||||
|
cons_show("Message reminder period set to %d seconds.", period);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
} else {
|
||||||
|
cons_show("Usage: %s", help.usage);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cons_show("Usage: %s", help.usage);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -877,6 +953,13 @@ _cmd_set_flash(const char * const inp, struct cmd_help_t help)
|
|||||||
"Screen flash", prefs_set_flash);
|
"Screen flash", prefs_set_flash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
_cmd_set_intype(const char * const inp, struct cmd_help_t help)
|
||||||
|
{
|
||||||
|
return _cmd_set_boolean_preference(inp, help, "/intype",
|
||||||
|
"Show contact typing", prefs_set_intype);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cmd_set_showsplash(const char * const inp, struct cmd_help_t help)
|
_cmd_set_showsplash(const char * const inp, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
@@ -898,34 +981,6 @@ _cmd_set_history(const char * const inp, struct cmd_help_t help)
|
|||||||
"Chat history", prefs_set_history);
|
"Chat history", prefs_set_history);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
_cmd_set_remind(const char * const inp, struct cmd_help_t help)
|
|
||||||
{
|
|
||||||
if ((strncmp(inp, "/remind ", 8) != 0) || (strlen(inp) < 9)) {
|
|
||||||
cons_show("Usage: %s", help.usage);
|
|
||||||
} else {
|
|
||||||
// copy input
|
|
||||||
char inp_cpy[strlen(inp) + 1];
|
|
||||||
strcpy(inp_cpy, inp);
|
|
||||||
|
|
||||||
// get period
|
|
||||||
strtok(inp_cpy, " ");
|
|
||||||
char *period_str = strtok(NULL, " ");
|
|
||||||
gint period = atoi(period_str);
|
|
||||||
|
|
||||||
prefs_set_remind(period);
|
|
||||||
if (period == 0) {
|
|
||||||
cons_show("Message reminders disabled.");
|
|
||||||
} else if (period == 1) {
|
|
||||||
cons_show("Message reminder period set to 1 second.");
|
|
||||||
} else {
|
|
||||||
cons_show("Message reminder period set to %d seconds.", period);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_cmd_away(const char * const inp, struct cmd_help_t help)
|
_cmd_away(const char * const inp, struct cmd_help_t help)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ gboolean cmd_execute_default(const char * const inp);
|
|||||||
|
|
||||||
// command help
|
// command help
|
||||||
char * cmd_help_complete(char *inp);
|
char * cmd_help_complete(char *inp);
|
||||||
|
char * cmd_notify_complete(char *inp);
|
||||||
void cmd_help_reset_completer(void);
|
void cmd_help_reset_completer(void);
|
||||||
|
void cmd_notify_reset_completer(void);
|
||||||
GSList * cmd_get_basic_help(void);
|
GSList * cmd_get_basic_help(void);
|
||||||
GSList * cmd_get_settings_help(void);
|
GSList * cmd_get_settings_help(void);
|
||||||
GSList * cmd_get_status_help(void);
|
GSList * cmd_get_status_help(void);
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ static int _printable(const int ch);
|
|||||||
static void _replace_input(char *input, const char * const new_input, int *size);
|
static void _replace_input(char *input, const char * const new_input, int *size);
|
||||||
static void _parameter_autocomplete(char *input, int *size, char *command,
|
static void _parameter_autocomplete(char *input, int *size, char *command,
|
||||||
autocomplete_func func);
|
autocomplete_func func);
|
||||||
|
static void _notify_autocomplete(char *input, int *size);
|
||||||
|
|
||||||
void
|
void
|
||||||
create_input_window(void)
|
create_input_window(void)
|
||||||
@@ -174,6 +175,7 @@ inp_get_char(int *ch, char *input, int *size)
|
|||||||
prefs_reset_login_search();
|
prefs_reset_login_search();
|
||||||
prefs_reset_boolean_choice();
|
prefs_reset_boolean_choice();
|
||||||
cmd_help_reset_completer();
|
cmd_help_reset_completer();
|
||||||
|
cmd_notify_reset_completer();
|
||||||
cmd_reset_completer();
|
cmd_reset_completer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,9 +362,7 @@ _handle_edit(const int ch, char *input, int *size)
|
|||||||
cmd_help_complete);
|
cmd_help_complete);
|
||||||
_parameter_autocomplete(input, size, "/beep",
|
_parameter_autocomplete(input, size, "/beep",
|
||||||
prefs_autocomplete_boolean_choice);
|
prefs_autocomplete_boolean_choice);
|
||||||
_parameter_autocomplete(input, size, "/notify",
|
_parameter_autocomplete(input, size, "/intype",
|
||||||
prefs_autocomplete_boolean_choice);
|
|
||||||
_parameter_autocomplete(input, size, "/typing",
|
|
||||||
prefs_autocomplete_boolean_choice);
|
prefs_autocomplete_boolean_choice);
|
||||||
_parameter_autocomplete(input, size, "/flash",
|
_parameter_autocomplete(input, size, "/flash",
|
||||||
prefs_autocomplete_boolean_choice);
|
prefs_autocomplete_boolean_choice);
|
||||||
@@ -375,6 +375,8 @@ _handle_edit(const int ch, char *input, int *size)
|
|||||||
_parameter_autocomplete(input, size, "/vercheck",
|
_parameter_autocomplete(input, size, "/vercheck",
|
||||||
prefs_autocomplete_boolean_choice);
|
prefs_autocomplete_boolean_choice);
|
||||||
|
|
||||||
|
_notify_autocomplete(input, size);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -434,3 +436,56 @@ _parameter_autocomplete(char *input, int *size, char *command,
|
|||||||
}
|
}
|
||||||
free(command_cpy);
|
free(command_cpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_notify_autocomplete(char *input, int *size)
|
||||||
|
{
|
||||||
|
char *found = NULL;
|
||||||
|
char *auto_msg = NULL;
|
||||||
|
char inp_cpy[*size];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if ((strncmp(input, "/notify message ", 16) == 0) && (*size > 16)) {
|
||||||
|
for(i = 16; i < *size; i++) {
|
||||||
|
inp_cpy[i-16] = input[i];
|
||||||
|
}
|
||||||
|
inp_cpy[(*size) - 16] = '\0';
|
||||||
|
found = prefs_autocomplete_boolean_choice(inp_cpy);
|
||||||
|
if (found != NULL) {
|
||||||
|
auto_msg = (char *) malloc((16 + (strlen(found) + 1)) * sizeof(char));
|
||||||
|
strcpy(auto_msg, "/notify message ");
|
||||||
|
strcat(auto_msg, found);
|
||||||
|
_replace_input(input, auto_msg, size);
|
||||||
|
free(auto_msg);
|
||||||
|
free(found);
|
||||||
|
}
|
||||||
|
} else if ((strncmp(input, "/notify typing ", 15) == 0) && (*size > 15)) {
|
||||||
|
for(i = 15; i < *size; i++) {
|
||||||
|
inp_cpy[i-15] = input[i];
|
||||||
|
}
|
||||||
|
inp_cpy[(*size) - 15] = '\0';
|
||||||
|
found = prefs_autocomplete_boolean_choice(inp_cpy);
|
||||||
|
if (found != NULL) {
|
||||||
|
auto_msg = (char *) malloc((15 + (strlen(found) + 1)) * sizeof(char));
|
||||||
|
strcpy(auto_msg, "/notify typing ");
|
||||||
|
strcat(auto_msg, found);
|
||||||
|
_replace_input(input, auto_msg, size);
|
||||||
|
free(auto_msg);
|
||||||
|
free(found);
|
||||||
|
}
|
||||||
|
} else if ((strncmp(input, "/notify ", 8) == 0) && (*size > 8)) {
|
||||||
|
for(i = 8; i < *size; i++) {
|
||||||
|
inp_cpy[i-8] = input[i];
|
||||||
|
}
|
||||||
|
inp_cpy[(*size) - 8] = '\0';
|
||||||
|
found = cmd_notify_complete(inp_cpy);
|
||||||
|
if (found != NULL) {
|
||||||
|
auto_msg = (char *) malloc((8 + (strlen(found) + 1)) * sizeof(char));
|
||||||
|
strcpy(auto_msg, "/notify ");
|
||||||
|
strcat(auto_msg, found);
|
||||||
|
_replace_input(input, auto_msg, size);
|
||||||
|
free(auto_msg);
|
||||||
|
free(found);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ _message_handler(xmpp_conn_t * const conn,
|
|||||||
// if no message, check for chatstates
|
// if no message, check for chatstates
|
||||||
if (body == NULL) {
|
if (body == NULL) {
|
||||||
|
|
||||||
if (prefs_get_typing()) {
|
if (prefs_get_notify_typing() || prefs_get_intype()) {
|
||||||
if (xmpp_stanza_get_child_by_name(stanza, "active") != NULL) {
|
if (xmpp_stanza_get_child_by_name(stanza, "active") != NULL) {
|
||||||
// active
|
// active
|
||||||
} else if (xmpp_stanza_get_child_by_name(stanza, "composing") != NULL) {
|
} else if (xmpp_stanza_get_child_by_name(stanza, "composing") != NULL) {
|
||||||
|
|||||||
@@ -236,28 +236,41 @@ prefs_set_beep(gboolean value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
prefs_get_notify(void)
|
prefs_get_notify_typing(void)
|
||||||
{
|
{
|
||||||
return g_key_file_get_boolean(prefs, "ui", "notify", NULL);
|
return g_key_file_get_boolean(prefs, "notifications", "typing", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
prefs_set_notify(gboolean value)
|
prefs_set_notify_typing(gboolean value)
|
||||||
{
|
{
|
||||||
g_key_file_set_boolean(prefs, "ui", "notify", value);
|
g_key_file_set_boolean(prefs, "notifications", "typing", value);
|
||||||
_save_prefs();
|
_save_prefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
prefs_get_typing(void)
|
prefs_get_notify_message(void)
|
||||||
{
|
{
|
||||||
return g_key_file_get_boolean(prefs, "ui", "typing", NULL);
|
return g_key_file_get_boolean(prefs, "notifications", "message", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
prefs_set_typing(gboolean value)
|
prefs_set_notify_message(gboolean value)
|
||||||
{
|
{
|
||||||
g_key_file_set_boolean(prefs, "ui", "typing", value);
|
g_key_file_set_boolean(prefs, "notifications", "message", value);
|
||||||
|
_save_prefs();
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
prefs_get_notify_remind(void)
|
||||||
|
{
|
||||||
|
return g_key_file_get_integer(prefs, "notifications", "remind", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
prefs_set_notify_remind(gint value)
|
||||||
|
{
|
||||||
|
g_key_file_set_integer(prefs, "notifications", "remind", value);
|
||||||
_save_prefs();
|
_save_prefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -287,6 +300,19 @@ prefs_set_flash(gboolean value)
|
|||||||
_save_prefs();
|
_save_prefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
prefs_get_intype(void)
|
||||||
|
{
|
||||||
|
return g_key_file_get_boolean(prefs, "ui", "intype", NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
prefs_set_intype(gboolean value)
|
||||||
|
{
|
||||||
|
g_key_file_set_boolean(prefs, "ui", "intype", value);
|
||||||
|
_save_prefs();
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
prefs_get_chlog(void)
|
prefs_get_chlog(void)
|
||||||
{
|
{
|
||||||
@@ -313,19 +339,6 @@ prefs_set_history(gboolean value)
|
|||||||
_save_prefs();
|
_save_prefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
|
||||||
prefs_get_remind(void)
|
|
||||||
{
|
|
||||||
return g_key_file_get_integer(prefs, "ui", "remind", NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
prefs_set_remind(gint value)
|
|
||||||
{
|
|
||||||
g_key_file_set_integer(prefs, "ui", "remind", value);
|
|
||||||
_save_prefs();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
prefs_add_login(const char *jid)
|
prefs_add_login(const char *jid)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,10 +44,6 @@ void prefs_reset_boolean_choice(void);
|
|||||||
|
|
||||||
gboolean prefs_get_beep(void);
|
gboolean prefs_get_beep(void);
|
||||||
void prefs_set_beep(gboolean value);
|
void prefs_set_beep(gboolean value);
|
||||||
gboolean prefs_get_notify(void);
|
|
||||||
void prefs_set_notify(gboolean value);
|
|
||||||
gboolean prefs_get_typing(void);
|
|
||||||
void prefs_set_typing(gboolean value);
|
|
||||||
gboolean prefs_get_flash(void);
|
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);
|
||||||
@@ -56,10 +52,17 @@ gboolean prefs_get_history(void);
|
|||||||
void prefs_set_history(gboolean value);
|
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);
|
|
||||||
void prefs_set_remind(gint value);
|
|
||||||
gboolean prefs_get_vercheck(void);
|
gboolean prefs_get_vercheck(void);
|
||||||
void prefs_set_vercheck(gboolean value);
|
void prefs_set_vercheck(gboolean value);
|
||||||
|
gboolean prefs_get_intype(void);
|
||||||
|
void prefs_set_intype(gboolean value);
|
||||||
|
|
||||||
|
void prefs_set_notify_message(gboolean value);
|
||||||
|
gboolean prefs_get_notify_message(void);
|
||||||
|
void prefs_set_notify_typing(gboolean value);
|
||||||
|
gboolean prefs_get_notify_typing(void);
|
||||||
|
void prefs_set_notify_remind(gint period);
|
||||||
|
gint prefs_get_notify_remind(void);
|
||||||
|
|
||||||
void prefs_add_login(const char *jid);
|
void prefs_add_login(const char *jid);
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ prof_run(const int disable_tls, char *log_level)
|
|||||||
|
|
||||||
gdouble elapsed = g_timer_elapsed(timer, NULL);
|
gdouble elapsed = g_timer_elapsed(timer, NULL);
|
||||||
|
|
||||||
gint remind_period = prefs_get_remind();
|
gint remind_period = prefs_get_notify_remind();
|
||||||
|
|
||||||
// 0 means to not remind
|
// 0 means to not remind
|
||||||
if (remind_period > 0 && elapsed >= remind_period) {
|
if (remind_period > 0 && elapsed >= remind_period) {
|
||||||
|
|||||||
@@ -222,26 +222,28 @@ win_show_typing(const char * const from)
|
|||||||
|
|
||||||
int win_index = _find_prof_win_index(short_from);
|
int win_index = _find_prof_win_index(short_from);
|
||||||
|
|
||||||
// no chat window for user
|
if (prefs_get_intype()) {
|
||||||
if (win_index == NUM_WINS) {
|
// no chat window for user
|
||||||
_cons_show_typing(short_from);
|
if (win_index == NUM_WINS) {
|
||||||
|
_cons_show_typing(short_from);
|
||||||
|
|
||||||
// have chat window but not currently in it
|
// have chat window but not currently in it
|
||||||
} else if (win_index != _curr_prof_win) {
|
} else if (win_index != _curr_prof_win) {
|
||||||
_cons_show_typing(short_from);
|
_cons_show_typing(short_from);
|
||||||
dirty = TRUE;
|
dirty = TRUE;
|
||||||
|
|
||||||
// in chat window with user
|
// in chat window with user
|
||||||
} else {
|
} else {
|
||||||
title_bar_set_typing(TRUE);
|
title_bar_set_typing(TRUE);
|
||||||
title_bar_draw();
|
title_bar_draw();
|
||||||
|
|
||||||
status_bar_active(win_index);
|
status_bar_active(win_index);
|
||||||
dirty = TRUE;
|
dirty = TRUE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
if (prefs_get_notify())
|
if (prefs_get_notify_typing())
|
||||||
_win_notify_typing(short_from);
|
_win_notify_typing(short_from);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -300,7 +302,7 @@ win_show_incomming_msg(const char * const from, const char * const message)
|
|||||||
if (prefs_get_beep())
|
if (prefs_get_beep())
|
||||||
beep();
|
beep();
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
if (prefs_get_notify())
|
if (prefs_get_notify_message())
|
||||||
_win_notify_message(short_from);
|
_win_notify_message(short_from);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -509,52 +511,57 @@ cons_prefs(void)
|
|||||||
cons_show("");
|
cons_show("");
|
||||||
|
|
||||||
if (prefs_get_beep())
|
if (prefs_get_beep())
|
||||||
cons_show("Terminal beep : ON");
|
cons_show("Terminal beep : ON");
|
||||||
else
|
else
|
||||||
cons_show("Terminal beep : OFF");
|
cons_show("Terminal beep : OFF");
|
||||||
|
|
||||||
if (prefs_get_flash())
|
if (prefs_get_flash())
|
||||||
cons_show("Terminal flash : ON");
|
cons_show("Terminal flash : ON");
|
||||||
else
|
else
|
||||||
cons_show("Terminal flash : OFF");
|
cons_show("Terminal flash : OFF");
|
||||||
|
|
||||||
if (prefs_get_notify())
|
if (prefs_get_intype())
|
||||||
cons_show("Message notifications : ON");
|
cons_show("Show typing : ON");
|
||||||
else
|
else
|
||||||
cons_show("Message notifications : OFF");
|
cons_show("Show typing : OFF");
|
||||||
|
|
||||||
if (prefs_get_typing())
|
|
||||||
cons_show("Typing notifications : ON");
|
|
||||||
else
|
|
||||||
cons_show("Typing notifications : OFF");
|
|
||||||
|
|
||||||
if (prefs_get_showsplash())
|
if (prefs_get_showsplash())
|
||||||
cons_show("Splash screen : ON");
|
cons_show("Splash screen : ON");
|
||||||
else
|
else
|
||||||
cons_show("Splash screen : OFF");
|
cons_show("Splash screen : OFF");
|
||||||
|
|
||||||
if (prefs_get_chlog())
|
if (prefs_get_chlog())
|
||||||
cons_show("Chat logging : ON");
|
cons_show("Chat logging : ON");
|
||||||
else
|
else
|
||||||
cons_show("Chat logging : OFF");
|
cons_show("Chat logging : OFF");
|
||||||
|
|
||||||
if (prefs_get_history())
|
if (prefs_get_history())
|
||||||
cons_show("Chat history : ON");
|
cons_show("Chat history : ON");
|
||||||
else
|
else
|
||||||
cons_show("Chat history : OFF");
|
cons_show("Chat history : OFF");
|
||||||
|
|
||||||
if (prefs_get_vercheck())
|
if (prefs_get_vercheck())
|
||||||
cons_show("Version checking : ON");
|
cons_show("Version checking : ON");
|
||||||
else
|
else
|
||||||
cons_show("Version checking : OFF");
|
cons_show("Version checking : OFF");
|
||||||
|
|
||||||
gint remind_period = prefs_get_remind();
|
if (prefs_get_notify_message())
|
||||||
|
cons_show("Message notifications : ON");
|
||||||
|
else
|
||||||
|
cons_show("Message notifications : OFF");
|
||||||
|
|
||||||
|
if (prefs_get_notify_typing())
|
||||||
|
cons_show("Typing notifications : ON");
|
||||||
|
else
|
||||||
|
cons_show("Typing notifications : OFF");
|
||||||
|
|
||||||
|
gint remind_period = prefs_get_notify_remind();
|
||||||
if (remind_period == 0) {
|
if (remind_period == 0) {
|
||||||
cons_show("Message reminder period : OFF");
|
cons_show("Reminder notification period : OFF");
|
||||||
} else if (remind_period == 1) {
|
} else if (remind_period == 1) {
|
||||||
cons_show("Message reminder period : 1 second");
|
cons_show("Reminder notification period : 1 second");
|
||||||
} else {
|
} else {
|
||||||
cons_show("Message reminder period : %d seconds", remind_period);
|
cons_show("Reminder notification period : %d seconds", remind_period);
|
||||||
}
|
}
|
||||||
|
|
||||||
cons_show("");
|
cons_show("");
|
||||||
|
|||||||
Reference in New Issue
Block a user