Send a reason when interrupted by sigint
authorStiletto <blasux@blasux.ru>
Wed, 24 Oct 2012 00:37:31 +0400
changeset 7 a49fb1ec5e2a
parent 6 0d97b0d61ed2
child 8 dfd274c668f9
Send a reason when interrupted by sigint
iswydt.vala
--- a/iswydt.vala	Wed Oct 24 00:37:04 2012 +0400
+++ b/iswydt.vala	Wed Oct 24 00:37:31 2012 +0400
@@ -127,7 +127,13 @@
             _change_state(State.DISCONNECTED, e.message);
         }
     }
-    public void close() {
+    public void close(string reason) {
+        if ((state==State.CONNECTED)&&(reason != null)) {
+            var prs = new Lm.Message(null, Lm.MessageType.PRESENCE);
+            prs.node.set_attribute("type","unavailable");
+            prs.node.add_child("status",reason);
+            cn.send(prs);
+        }
         cn.close();
     }
 }
@@ -173,7 +179,7 @@
                 if (news == Connection.State.DISCONNECTED)
                     loop.quit();
             });
-            account.close();
+            account.close("Received SIGINT");
         }
     });
     Posix.sigaction(Posix.SIGINT, action, null);