]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-plist.c
Be more compatible with Facebook emoticon codes
[empathy.git] / libempathy-gtk / empathy-plist.c
index d7e18448cd6c6f0b9f0b7c8649d0a9019a13e6c6..e1113a073f91d69fa4aec1d71587b4ca5091d251 100644 (file)
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this code; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "config.h"
+#include "empathy-plist.h"
 
 #include <string.h>
-#include <libxml/parser.h>
 #include <libxml/tree.h>
-#include <telepathy-glib/util.h>
-#include <telepathy-glib/dbus.h>
-
-#include "empathy-plist.h"
+#include <telepathy-glib/telepathy-glib.h>
 
 static GValue *empathy_plist_parse_node (xmlNode *a_node);
 
@@ -68,7 +65,7 @@ empathy_plist_parse_real (xmlNode *a_node)
 {
        char *str_val;
        char *end_ptr;
-       gfloat double_val;
+       gdouble double_val;
 
        str_val = (char *) xmlNodeGetContent (a_node);
        double_val = g_ascii_strtod (str_val, &end_ptr);
@@ -78,7 +75,8 @@ empathy_plist_parse_real (xmlNode *a_node)
        }
        xmlFree (str_val);
 
-       return tp_g_value_slice_new_double (double_val);}
+       return tp_g_value_slice_new_double (double_val);
+}
 
 static GValue *
 empathy_plist_parse_boolean (xmlNode *a_node)
@@ -93,7 +91,7 @@ empathy_plist_parse_boolean (xmlNode *a_node)
                return NULL;
        }
 
-       return tp_g_value_slice_new_int (bool_val);
+       return tp_g_value_slice_new_boolean (bool_val);
 }
 
 static GValue *
@@ -123,7 +121,7 @@ empathy_plist_parse_one_dict_entry (xmlNode *a_node, GHashTable *dict)
        GValue *value;
 
        while (cur_node &&
-              (xmlStrcmp(cur_node->name, (xmlChar *) "key") != 0)) {
+              (xmlStrcmp (cur_node->name, (xmlChar *) "key") != 0)) {
                cur_node = cur_node->next;
        }
        if (!cur_node) {
@@ -168,34 +166,6 @@ empathy_plist_parse_dict (xmlNode *a_node)
        return tp_g_value_slice_new_take_boxed (G_TYPE_HASH_TABLE, dict);
 }
 
-static GValue *
-empathy_plist_parse_array (xmlNode *a_node)
-{
-       xmlNode *cur_node = a_node->children;
-       GValueArray *array;
-
-       array = g_value_array_new (4);
-
-       while (cur_node) {
-               GValue *cur_value;
-
-               cur_value = empathy_plist_parse_node (cur_node);
-               if (cur_value) {
-                       g_value_array_append (array, cur_value);
-                       tp_g_value_slice_free (cur_value);
-               }
-
-               /* When an array contains an element enclosed in "unknown" tags (ie
-                * non-type ones), we silently skip them since early
-                * SysInfoExtended files used to have <key> values enclosed within
-                * <array> tags.
-                */
-               cur_node = cur_node->next;
-       }
-
-       return tp_g_value_slice_new_take_boxed (G_TYPE_VALUE_ARRAY, array);
-}
-
 typedef GValue *(*ParseCallback) (xmlNode *);
 
 struct Parser {
@@ -210,7 +180,6 @@ static const struct Parser parsers[] = { {"integer", empathy_plist_parse_integer
                                         {"false",   empathy_plist_parse_boolean},
                                         {"data",    empathy_plist_parse_data},
                                         {"dict",    empathy_plist_parse_dict},
-                                        {"array",   empathy_plist_parse_array},
                                         {NULL,   NULL} };
 
 static ParseCallback
@@ -292,8 +261,7 @@ empathy_plist_parse_from_file (const char *filename)
 
        parsed_doc = empathy_plist_parse (root_element);
 
-       xmlFreeDoc(doc);
-       xmlCleanupParser();
+       xmlFreeDoc (doc);
 
        return parsed_doc;
 }
@@ -327,8 +295,7 @@ empathy_plist_parse_from_memory (const char *data, gsize len)
 
        parsed_doc = empathy_plist_parse (root_element);
 
-       xmlFreeDoc(doc);
-       xmlCleanupParser();
+       xmlFreeDoc (doc);
 
        return parsed_doc;
 }