diff mcabber/src/xmpp_helper.c @ 1607:14690e624e9d

Add modules
author Myhailo Danylenko <isbear@ukrpost.net>
date Sun, 11 Oct 2009 16:01:52 +0200
parents 351427ef0b4b
children
line wrap: on
line diff
--- a/mcabber/src/xmpp_helper.c	Sun Oct 11 16:01:31 2009 +0200
+++ b/mcabber/src/xmpp_helper.c	Sun Oct 11 16:01:52 2009 +0200
@@ -30,6 +30,7 @@
 #include "utils.h"
 #include "caps.h"
 #include "logprint.h"
+#include "config.h"
 
 time_t iqlast; // last message/status change time
 
@@ -74,6 +75,37 @@
 };
 
 
+#ifdef MODULES_ENABLE
+static GSList *xmpp_additional_features = NULL;
+static char *ver, *ver_notavail;
+
+void xmpp_add_feature (const char *xmlns)
+{
+  if (xmlns) {
+    ver = NULL;
+    ver_notavail = NULL;
+    xmpp_additional_features = g_slist_append(xmpp_additional_features,
+                                              g_strdup (xmlns));
+  }
+}
+
+void xmpp_del_feature (const char *xmlns)
+{
+  GSList *feature = xmpp_additional_features;
+  while (feature) {
+    if (!strcmp(feature->data, xmlns)) {
+      ver = NULL;
+      ver_notavail = NULL;
+      g_free (feature->data);
+      xmpp_additional_features = g_slist_delete_link(xmpp_additional_features,
+                                                     feature);
+      return;
+    }
+    feature = g_slist_next (feature);
+  }
+}
+#endif
+
 const gchar* lm_message_node_get_child_value(LmMessageNode *node,
                                              const gchar *child)
 {
@@ -180,7 +212,9 @@
 // number) so that it doesn't conflict with the official client.
 const char *entity_version(enum imstatus status)
 {
+#ifndef MODULES_ENABLE
   static char *ver, *ver_notavail;
+#endif
 
   if (ver && (status != notavail))
     return ver;
@@ -204,6 +238,15 @@
       (!settings_opt_get_int("iq_last_disable_when_notavail") ||
        status != notavail))
    caps_add_feature("", NS_LAST);
+#ifdef MODULES_ENABLE
+  {
+    GSList *el = xmpp_additional_features;
+    while (el) {
+      caps_add_feature("", el->data);
+      el = g_slist_next (el);
+    }
+  }
+#endif
 
   if (status == notavail) {
     ver_notavail = caps_generate();