1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-06-23 21:45:30 +00:00

Added "set status" to /account

This commit is contained in:
James Booth 2013-01-30 22:45:35 +00:00
parent 603e1934a5
commit fa9826a36a
3 changed files with 26 additions and 0 deletions

View File

@ -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("");

View File

@ -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);

View File

@ -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)
{