about summary refs log tree commit diff stats
path: root/src/command.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-10-28 20:52:30 +0000
committerJames Booth <boothj5@gmail.com>2012-10-28 20:52:30 +0000
commitd13794bf60747323c434ee8b25523bc12c2f540d (patch)
tree423e8d52865f00f0d3f6b236505868e2d21bc4ac /src/command.c
parent4b6002ae6347dd2fab655104163f6234a80a0c57 (diff)
downloadprofani-tty-d13794bf60747323c434ee8b25523bc12c2f540d.tar.gz
Load roster before sending presence
Diffstat (limited to 'src/command.c')
-rw-r--r--src/command.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/command.c b/src/command.c
index c9110e4b..f8c5b1e9 100644
--- a/src/command.c
+++ b/src/command.c
@@ -718,8 +718,9 @@ _cmd_sub(const char * const inp, struct cmd_help_t help)
         char *user, *lower;
         user = strndup(inp+5, strlen(inp)-5);
         lower = g_utf8_strdown(user, -1);
-    
+
         jabber_subscribe(lower);
+        cons_show("Sent subscription request to %s.", user);
 
         result = TRUE;
     }
@@ -824,16 +825,16 @@ _cmd_who(const char * const inp, struct cmd_help_t help)
 
         // get show
         strtok(inp_cpy, " ");
-        char *show = strtok(NULL, " ");
+        char *presence = strtok(NULL, " ");
 
         // bad arg
-        if ((show != NULL)
-                && (strcmp(show, "online") != 0)
-                && (strcmp(show, "offline") != 0)
-                && (strcmp(show, "away") != 0)
-                && (strcmp(show, "chat") != 0)
-                && (strcmp(show, "xa") != 0)
-                && (strcmp(show, "dnd") != 0)) {
+        if ((presence != NULL)
+                && (strcmp(presence, "online") != 0)
+                && (strcmp(presence, "offline") != 0)
+                && (strcmp(presence, "away") != 0)
+                && (strcmp(presence, "chat") != 0)
+                && (strcmp(presence, "xa") != 0)
+                && (strcmp(presence, "dnd") != 0)) {
             cons_show("Usage: %s", help.usage);
 
         // valid arg
@@ -841,23 +842,23 @@ _cmd_who(const char * const inp, struct cmd_help_t help)
             GSList *list = get_contact_list();
 
             // no arg, show all contacts
-            if (show == NULL) {
+            if (presence == NULL) {
                 cons_show("All contacts:");
                 cons_show_contacts(list);
 
             // online, show all status that indicate online
-            } else if (strcmp("online", show) == 0) {
-                cons_show("Contacts (%s):", show);
+            } else if (strcmp("online", presence) == 0) {
+                cons_show("Contacts (%s):", presence);
                 GSList *filtered = NULL;
 
                 while (list != NULL) {
                     PContact contact = list->data;
-                    const char * const contact_show = (p_contact_show(contact));
-                    if ((strcmp(contact_show, "online") == 0)
-                            || (strcmp(contact_show, "away") == 0)
-                            || (strcmp(contact_show, "dnd") == 0)
-                            || (strcmp(contact_show, "xa") == 0)
-                            || (strcmp(contact_show, "chat") == 0)) {
+                    const char * const contact_presence = (p_contact_presence(contact));
+                    if ((strcmp(contact_presence, "online") == 0)
+                            || (strcmp(contact_presence, "away") == 0)
+                            || (strcmp(contact_presence, "dnd") == 0)
+                            || (strcmp(contact_presence, "xa") == 0)
+                            || (strcmp(contact_presence, "chat") == 0)) {
                         filtered = g_slist_append(filtered, contact);
                     }
                     list = g_slist_next(list);
@@ -867,12 +868,12 @@ _cmd_who(const char * const inp, struct cmd_help_t help)
 
             // show specific status
             } else {
-                cons_show("Contacts (%s):", show);
+                cons_show("Contacts (%s):", presence);
                 GSList *filtered = NULL;
 
                 while (list != NULL) {
                     PContact contact = list->data;
-                    if (strcmp(p_contact_show(contact), show) == 0) {
+                    if (strcmp(p_contact_presence(contact), presence) == 0) {
                         filtered = g_slist_append(filtered, contact);
                     }
                     list = g_slist_next(list);