diff --git a/src/command.c b/src/command.c index 2f94b575..ffd73086 100644 --- a/src/command.c +++ b/src/command.c @@ -1157,6 +1157,14 @@ _cmd_account(gchar **args, struct cmd_help_t help) accounts_set_resource(account_name, value); cons_show("Updated resource for account %s: %s", account_name, value); cons_show(""); + } else if (strcmp(property, "status") == 0) { + if (!presence_valid_string(value)) { + cons_show("Invalud status: %s", value); + } else { + accounts_set_login_presence(account_name, value); + cons_show("Updated login status for account %s: %s", account_name, value); + } + cons_show(""); } else { cons_show("Invalid property: %s", property); cons_show(""); diff --git a/src/xmpp.h b/src/xmpp.h index 08cccaab..ffe0aae8 100644 --- a/src/xmpp.h +++ b/src/xmpp.h @@ -178,6 +178,7 @@ void iq_roster_request(void); // presence functions void presence_add_handlers(void); void presence_init(void); +gboolean presence_valid_string(const char * const str); void presence_subscription(const char * const jid, const jabber_subscr_t action); GList* presence_get_subscription_requests(void); void presence_free_sub_requests(void); diff --git a/src/xmpp_presence.c b/src/xmpp_presence.c index 125e1400..f2918812 100644 --- a/src/xmpp_presence.c +++ b/src/xmpp_presence.c @@ -56,6 +56,23 @@ presence_add_handlers(void) HANDLE(NULL, NULL, _presence_handler); } +gboolean +presence_valid_string(const char * const str) +{ + if (str == NULL) { + return FALSE; + } else if ((strcmp(str, "online") == 0) || + (strcmp(str, "chat") == 0) || + (strcmp(str, "away") == 0) || + (strcmp(str, "xa") == 0) || + (strcmp(str, "dnd") == 0)) { + return TRUE; + } else { + return FALSE; + } +} + + void presence_subscription(const char * const jid, const jabber_subscr_t action) {