about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2013-01-30 22:45:35 +0000
committerJames Booth <boothj5@gmail.com>2013-01-30 22:45:35 +0000
commitfa9826a36af3aea03369f77288b1ba6b6a231484 (patch)
tree830e9b157d3e1419e7220888d9020c70819fc055
parent603e1934a553371daf807b1f5e9a0df71852f2cf (diff)
downloadprofani-tty-fa9826a36af3aea03369f77288b1ba6b6a231484.tar.gz
Added "set status" to /account
-rw-r--r--src/command.c8
-rw-r--r--src/xmpp.h1
-rw-r--r--src/xmpp_presence.c17
3 files changed, 26 insertions, 0 deletions
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)
 {