diff options
author | Dmitry Podgorny <pasis.ua@gmail.com> | 2012-11-13 12:51:28 +0200 |
---|---|---|
committer | Dmitry Podgorny <pasis.ua@gmail.com> | 2012-11-13 12:51:28 +0200 |
commit | a114fe88b80010dd3c4f29319bd67e7daa533cb1 (patch) | |
tree | a5b69aa358b4e43b6ae90ed44277a9ff5a0efdd0 /src/command.c | |
parent | b14aab4adedfe0c2d252af692ffddffe03d54e65 (diff) | |
download | profani-tty-a114fe88b80010dd3c4f29319bd67e7daa533cb1.tar.gz |
introduce priority support
add new command /priority <int> improve jabber_update_presence() use jabber_update_presence() for sending initial presence save priority and status string to jabber_conn structure
Diffstat (limited to 'src/command.c')
-rw-r--r-- | src/command.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/command.c b/src/command.c index a723f6f8..bf7ae5be 100644 --- a/src/command.c +++ b/src/command.c @@ -95,6 +95,7 @@ static gboolean _cmd_join(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_log(const char * const inp, struct cmd_help_t help); +static gboolean _cmd_set_priority(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_showsplash(const char * const inp, struct cmd_help_t help); @@ -423,6 +424,16 @@ static struct cmd_t setting_commands[] = "", "Config file section : [log]", "Config file value : maxsize=bytes", + NULL } } }, + + { "/priority", + _cmd_set_priority, + { "/priority <value>", "Set priority for connection.", + { "/priority <value>", + "--------------------", + "value : Number between -128 and 127. Default value is 0.", + "", + "Config file section : [jabber]", NULL } } } }; @@ -1405,6 +1416,31 @@ _cmd_set_log(const char * const inp, struct cmd_help_t help) } static gboolean +_cmd_set_priority(const char * const inp, struct cmd_help_t help) +{ + char *value; + char inp_cpy[strlen(inp) + 1]; + int intval; + + strcpy(inp_cpy, inp); + strtok(inp_cpy, " "); + value = strtok(NULL, " "); + if (value == NULL) { + cons_show("Usage: %s", help.usage); + } else { + char *status = jabber_get_status(); + intval = atoi(value); + prefs_set_priority(intval); + // update presence with new priority + jabber_update_presence(jabber_get_presence(), status); + if (status != NULL) + free(status); + cons_show("Priority set to %d.", intval); + } + return TRUE; +} + +static gboolean _cmd_vercheck(const char * const inp, struct cmd_help_t help) { if (strcmp(inp, "/vercheck") == 0) { |