Added support for resouce binding and session establishment
[cascardo/chat.git] / features.c
index 3fd1896..a4427ce 100644 (file)
 
 #include "xmpp_internal.h"
 
-void
+static void
+session (hc_xmpp_t *xmpp, iks *f)
+{
+  iks *c;
+  xmpp->session |= SUPPORTED;
+  for (c = iks_child (f); c != NULL; c = iks_next (c))
+    {
+      if (!iks_strcmp (iks_name (c), "optional"))
+        xmpp->session |= OPTIONAL;
+      else if (!iks_strcmp (iks_name (c), "required"))
+        xmpp->session |= REQUIRED;
+    }
+}
+
+static void
+xmpp_bind (hc_xmpp_t *xmpp, iks *f)
+{
+  iks *c;
+  xmpp->bind |= SUPPORTED;
+  for (c = iks_child (f); c != NULL; c = iks_next (c))
+    {
+      if (!iks_strcmp (iks_name (c), "optional"))
+        xmpp->bind |= OPTIONAL;
+      else if (!iks_strcmp (iks_name (c), "required"))
+        xmpp->bind |= REQUIRED;
+    }
+}
+
+static void
 sasl (hc_xmpp_t *xmpp, iks *f)
 {
   iks *c;
@@ -33,7 +61,7 @@ sasl (hc_xmpp_t *xmpp, iks *f)
     }
 }
 
-void
+static void
 tls (hc_xmpp_t *xmpp, iks *f)
 {
   iks *c;
@@ -56,8 +84,14 @@ hc_xmpp_features (hc_xmpp_t *xmpp, iks *features)
       if (!iks_strcmp (iks_name (c), "starttls") &&
           !iks_strcmp (iks_find_attrib (c, "xmlns"), HC_XMPP_NS_TLS))
         tls (xmpp, c);
-      if (!iks_strcmp (iks_name (c), "mechanisms") &&
+      else if (!iks_strcmp (iks_name (c), "mechanisms") &&
           !iks_strcmp (iks_find_attrib (c, "xmlns"), HC_XMPP_NS_SASL))
         sasl (xmpp, c);
+      else if (!iks_strcmp (iks_name (c), "bind") &&
+          !iks_strcmp (iks_find_attrib (c, "xmlns"), HC_XMPP_NS_BIND))
+        xmpp_bind (xmpp, c);
+      else if (!iks_strcmp (iks_name (c), "session") &&
+          !iks_strcmp (iks_find_attrib (c, "xmlns"), HC_XMPP_NS_SESSION))
+        session (xmpp, c);
     }
 }