changeset 1492:563ba5a861ae

Improve last ad-hoc fix
author Mikael Berthe <mikael@lilotux.net>
date Mon, 28 Apr 2008 19:34:10 +0200
parents 3d47694b4dcc
children 1ae5fb9b04ca
files mcabber/src/jab_iq.c
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/jab_iq.c	Mon Apr 28 18:54:55 2008 +0200
+++ b/mcabber/src/jab_iq.c	Mon Apr 28 19:34:10 2008 +0200
@@ -1147,6 +1147,7 @@
     sessionid = generate_session_id("set-status");
     xmlnode_put_attrib(command, "sessionid", sessionid);
     g_free(sessionid);
+    sessionid = NULL;
     xmlnode_put_attrib(command, "status", "executing");
 
     x = xmlnode_insert_tag(command, "x");
@@ -1190,9 +1191,9 @@
     xmlnode_put_attrib(y, "type", "text-multi");
     xmlnode_put_attrib(y, "var", "status-message");
     xmlnode_put_attrib(y, "label", "Message");
-  }
-  else // (if sessionid)
-  {
+  } else if (!strcmp(action, "cancel")) {
+    xmlnode_put_attrib(command, "status", "canceled");
+  } else  { // (if sessionid and not canceled)
     y = xmlnode_get_tag(x, "x?xmlns=jabber:x:data");
     if (y) {
       char *value, *message;
@@ -1206,7 +1207,6 @@
                                        message ? message : "");
         cmd_setstatus(NULL, status);
         g_free(status);
-        xmlnode_put_attrib(command, "sessionid", sessionid);
         xmlnode_put_attrib(command, "status", "completed");
         xmlnode_put_attrib(iq, "type", "result");
         xmlnode_insert_dataform_result_message(command,
@@ -1214,6 +1214,8 @@
       }
     }
   }
+  if (sessionid)
+    xmlnode_put_attrib(command, "sessionid", sessionid);
   xmlnode_put_attrib(iq, "to", xmlnode_get_attrib(xmldata, "from"));
   xmlnode_put_attrib(iq, "id", id);
   jab_send(jc, iq);
@@ -1263,6 +1265,7 @@
     sessionid = generate_session_id("leave-groupchats");
     xmlnode_put_attrib(command, "sessionid", sessionid);
     g_free(sessionid);
+    sessionid = NULL;
     xmlnode_put_attrib(command, "status", "executing");
 
     x = xmlnode_insert_tag(command, "x");
@@ -1290,9 +1293,9 @@
     xmlnode_insert_tag(field, "required");
 
     foreach_buddy(ROSTER_TYPE_ROOM, &_callback_foreach_buddy_groupchat, &field);
-  }
-  else // (if sessionid)
-  {
+  } else if (!strcmp(action, "cancel")) {
+    xmlnode_put_attrib(command, "status", "canceled");
+  } else  { // (if sessionid and not canceled)
     xmlnode form = xmlnode_get_tag(x, "x?xmlns=jabber:x:data");
     if (form) {
       xmlnode x, gc;
@@ -1306,7 +1309,7 @@
         if (to_leave) {
           GList* b = buddy_search_jid(to_leave);
           if (b)
-            cmd_room_leave(b->data, "Asked by remote command");
+            cmd_room_leave(b->data, "Requested by remote command");
         }
       }
       xmlnode_put_attrib(iq, "type", "result");
@@ -1314,6 +1317,8 @@
                                              "Groupchats have been left");
     }
   }
+  if (sessionid)
+    xmlnode_put_attrib(command, "sessionid", sessionid);
   xmlnode_put_attrib(iq, "to", xmlnode_get_attrib(xmldata, "from"));
   xmlnode_put_attrib(iq, "id", id);
   jab_send(jc, iq);
@@ -1710,6 +1715,7 @@
     ns = xmlnode_get_attrib(x, "xmlns");
     if (ns && !strcmp(ns, NS_COMMANDS)) {
       handle_iq_commands(conn, from, id, xmldata);
+      return;
     } else {
       iq_not_implemented = TRUE;
     }