+/*
+ * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+#include "xmpp_internal.h"
+
+void
+sasl (hc_xmpp_t *xmpp, iks *f)
+{
+ iks *c;
+ xmpp->sasl |= SUPPORTED;
+ for (c = iks_child (f); c != NULL; c = iks_next (c))
+ {
+ if (!iks_strcmp (iks_name (c), "optional"))
+ xmpp->sasl |= OPTIONAL;
+ else if (!iks_strcmp (iks_name (c), "required"))
+ xmpp->sasl |= REQUIRED;
+ }
+}
+
+void
+tls (hc_xmpp_t *xmpp, iks *f)
+{
+ iks *c;
+ xmpp->tls |= SUPPORTED;
+ for (c = iks_child (f); c != NULL; c = iks_next (c))
+ {
+ if (!iks_strcmp (iks_name (c), "optional"))
+ xmpp->tls |= OPTIONAL;
+ else if (!iks_strcmp (iks_name (c), "required"))
+ xmpp->tls |= REQUIRED;
+ }
+}
+
+void
+hc_xmpp_features (hc_xmpp_t *xmpp, iks *features)
+{
+ iks *c;
+ for (c = iks_child (features); c != NULL; c = iks_next (c))
+ {
+ 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") &&
+ !iks_strcmp (iks_find_attrib (c, "xmlns"), HC_XMPP_NS_SASL))
+ sasl (xmpp, c);
+ }
+}