about summary refs log tree commit diff stats
path: root/src/command/cmd_funcs.c
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2019-11-06 20:09:34 +0100
committerMichael Vetter <jubalh@iodoru.org>2019-11-06 20:09:34 +0100
commitecfa2d0c1b96c4fbd8f9312c7afc2efae08568ed (patch)
tree6db0fa1584dcb76d8041125c7b3680730abbd74b /src/command/cmd_funcs.c
parent4a0d1d21084fe446fe8c040af0b5fd4e5701d641 (diff)
downloadprofani-tty-ecfa2d0c1b96c4fbd8f9312c7afc2efae08568ed.tar.gz
Merge state commands (online, away) into status
Before we had `/online`, `/away`, `/dnd`, `/chat`, `/xa`.
These commands are no longer available.

We have `/status set online` etc now.

Before `/status` was used to get the status of a contact.
This now moved to `/status get`.

Regards https://github.com/profanity-im/profanity/issues/1116
Diffstat (limited to 'src/command/cmd_funcs.c')
-rw-r--r--src/command/cmd_funcs.c65
1 files changed, 26 insertions, 39 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index e8c99901..f665bae1 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -3228,9 +3228,31 @@ _cmd_status_show_status(char* usr)
 }
 
 gboolean
-cmd_status(ProfWin *window, const char *const command, gchar **args)
+cmd_status_set(ProfWin *window, const char *const command, gchar **args)
+{
+    char *state = args[1];
+
+    if (g_strcmp0(state, "online") == 0) {
+        _update_presence(RESOURCE_ONLINE, "online", args);
+    } else if (g_strcmp0(state, "away") == 0) {
+        _update_presence(RESOURCE_AWAY, "away", args);
+    } else if (g_strcmp0(state, "dnd") == 0) {
+        _update_presence(RESOURCE_DND, "dnd", args);
+    } else if (g_strcmp0(state, "chat") == 0) {
+        _update_presence(RESOURCE_CHAT, "chat", args);
+    } else if (g_strcmp0(state, "xa") == 0) {
+        _update_presence(RESOURCE_XA, "xa", args);
+    } else {
+        cons_bad_cmd_usage(command);
+    }
+
+    return TRUE;
+}
+
+gboolean
+cmd_status_get(ProfWin *window, const char *const command, gchar **args)
 {
-    char *usr = args[0];
+    char *usr = args[1];
 
     jabber_conn_status_t conn_status = connection_get_status();
 
@@ -6765,41 +6787,6 @@ cmd_receipts(ProfWin *window, const char *const command, gchar **args)
 }
 
 gboolean
-cmd_away(ProfWin *window, const char *const command, gchar **args)
-{
-    _update_presence(RESOURCE_AWAY, "away", args);
-    return TRUE;
-}
-
-gboolean
-cmd_online(ProfWin *window, const char *const command, gchar **args)
-{
-    _update_presence(RESOURCE_ONLINE, "online", args);
-    return TRUE;
-}
-
-gboolean
-cmd_dnd(ProfWin *window, const char *const command, gchar **args)
-{
-    _update_presence(RESOURCE_DND, "dnd", args);
-    return TRUE;
-}
-
-gboolean
-cmd_chat(ProfWin *window, const char *const command, gchar **args)
-{
-    _update_presence(RESOURCE_CHAT, "chat", args);
-    return TRUE;
-}
-
-gboolean
-cmd_xa(ProfWin *window, const char *const command, gchar **args)
-{
-    _update_presence(RESOURCE_XA, "xa", args);
-    return TRUE;
-}
-
-gboolean
 cmd_plugins_sourcepath(ProfWin *window, const char *const command, gchar **args)
 {
     if (args[1] == NULL) {
@@ -8091,8 +8078,8 @@ _update_presence(const resource_presence_t resource_presence,
 {
     char *msg = NULL;
     int num_args = g_strv_length(args);
-    if (num_args == 1) {
-        msg = args[0];
+    if (num_args == 2) {
+        msg = args[1];
     }
 
     jabber_conn_status_t conn_status = connection_get_status();