Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/caps.c @ 30687:7fb775b4465b
jabber: Move (and harden) a function to xdata.c
Oops, I guess the const change on xmlnode_get_attrib wasn't
necessary since I had to cast away the constness so I could use
xmlnode_get_next_twin. Oh well.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sat, 10 Jul 2010 00:59:19 +0000 |
parents | 067ad74c7523 |
children | 116ca888e77d |
comparison
equal
deleted
inserted
replaced
30686:77cd42f08ba1 | 30687:7fb775b4465b |
---|---|
27 #include "caps.h" | 27 #include "caps.h" |
28 #include "cipher.h" | 28 #include "cipher.h" |
29 #include "iq.h" | 29 #include "iq.h" |
30 #include "presence.h" | 30 #include "presence.h" |
31 #include "util.h" | 31 #include "util.h" |
32 #include "xdata.h" | |
32 | 33 |
33 #define JABBER_CAPS_FILENAME "xmpp-caps.xml" | 34 #define JABBER_CAPS_FILENAME "xmpp-caps.xml" |
34 | 35 |
35 typedef struct _JabberDataFormField { | 36 typedef struct _JabberDataFormField { |
36 gchar *var; | 37 gchar *var; |
730 } else { | 731 } else { |
731 return cat_cmp; | 732 return cat_cmp; |
732 } | 733 } |
733 } | 734 } |
734 | 735 |
735 static gchar *jabber_caps_get_formtype(const xmlnode *x) { | |
736 xmlnode *formtypefield; | |
737 formtypefield = xmlnode_get_child(x, "field"); | |
738 while (formtypefield && strcmp(xmlnode_get_attrib(formtypefield, "var"), "FORM_TYPE")) formtypefield = xmlnode_get_next_twin(formtypefield); | |
739 formtypefield = xmlnode_get_child(formtypefield, "value"); | |
740 return xmlnode_get_data(formtypefield);; | |
741 } | |
742 | |
743 static gint | 736 static gint |
744 jabber_xdata_compare(gconstpointer a, gconstpointer b) | 737 jabber_xdata_compare(gconstpointer a, gconstpointer b) |
745 { | 738 { |
746 const xmlnode *aformtypefield = a; | 739 const xmlnode *aformtypefield = a; |
747 const xmlnode *bformtypefield = b; | 740 const xmlnode *bformtypefield = b; |
748 char *aformtype; | 741 char *aformtype; |
749 char *bformtype; | 742 char *bformtype; |
750 int result; | 743 int result; |
751 | 744 |
752 aformtype = jabber_caps_get_formtype(aformtypefield); | 745 aformtype = jabber_x_data_get_formtype(aformtypefield); |
753 bformtype = jabber_caps_get_formtype(bformtypefield); | 746 bformtype = jabber_x_data_get_formtype(bformtypefield); |
754 | 747 |
755 result = strcmp(aformtype, bformtype); | 748 result = strcmp(aformtype, bformtype); |
756 g_free(aformtype); | 749 g_free(aformtype); |
757 g_free(bformtype); | 750 g_free(bformtype); |
758 return result; | 751 return result; |
900 } | 893 } |
901 | 894 |
902 /* concat x-data forms to the verification string */ | 895 /* concat x-data forms to the verification string */ |
903 for(node = info->forms; node; node = node->next) { | 896 for(node = info->forms; node; node = node->next) { |
904 xmlnode *data = (xmlnode *)node->data; | 897 xmlnode *data = (xmlnode *)node->data; |
905 gchar *formtype = jabber_caps_get_formtype(data); | 898 gchar *formtype = jabber_x_data_get_formtype(data); |
906 GList *fields = jabber_caps_xdata_get_fields(data); | 899 GList *fields = jabber_caps_xdata_get_fields(data); |
907 | 900 |
908 /* append FORM_TYPE's field value to the verification string */ | 901 /* append FORM_TYPE's field value to the verification string */ |
909 append_escaped_string(context, formtype); | 902 append_escaped_string(context, formtype); |
910 g_free(formtype); | 903 g_free(formtype); |