static EvMetadataManager *ev_metadata_manager = NULL;
+/**
+ * item_free:
+ * @data: a pointer to a #Item data
+ *
+ * It does free the values on the #GHashTable where data points.
+ */
static void
item_free (gpointer data)
{
g_free (item);
}
+/**
+ * ev_metadata_manager_init:
+ *
+ * Creates an EvMetadataManager with default values.
+ *
+ * values_loaded -> %FALSE.
+ * modified -> %FALSE.
+ * timeout_id -> the id of the event source.
+ * items -> a new full empty #GHashTable.
+ */
void
ev_metadata_manager_init (void)
{
ev_metadata_manager = NULL;
}
+static void
+value_free (gpointer data)
+{
+ GValue *value = (GValue *)data;
+
+ g_value_unset (value);
+ g_free (value);
+}
+
static GValue *
parse_value (xmlChar *value, xmlChar *type)
{
item->values = g_hash_table_new_full (g_str_hash,
g_str_equal,
g_free,
- g_free);
+ value_free);
cur = cur->xmlChildrenNode;
xmlChar *key;
xmlChar *xml_value;
xmlChar *type;
- GValue *value;
+ GValue *value;
key = xmlGetProp (cur, (const xmlChar *)"key");
xml_value = xmlGetProp (cur, (const xmlChar *)"value");
if (key != NULL)
xmlFree (key);
+ if (type != NULL)
+ xmlFree (type);
if (xml_value != NULL)
xmlFree (xml_value);
}
cur = xmlDocGetRootElement (doc);
if (cur == NULL)
{
- g_message ("The metadata file '%s' is empty", METADATA_FILE);
+ g_message ("The metadata file ā%sā is empty", METADATA_FILE);
xmlFreeDoc (doc);
return FALSE;
if (xmlStrcmp (cur->name, (const xmlChar *) "metadata"))
{
- g_message ("File '%s' is of the wrong type", METADATA_FILE);
+ g_message ("File ā%sā is of the wrong type", METADATA_FILE);
xmlFreeDoc (doc);
return FALSE;
return TRUE;
}
-static void
-value_free (gpointer data)
-{
- GValue *value = (GValue *)data;
-
- g_value_unset (value);
- g_free (value);
-}
-
-
#define LAST_URI "last-used-value"
static gboolean
}
/**
- * ev_metadata_manager_set:
+ * ev_metadata_manager_get:
* @uri: Uri to set data for, if @NULL, we return default value
* @key: Key to set uri
* @value: GValue struct filled up with value
string_value = g_strdup_printf ("%d", g_value_get_int (value));
break;
case G_TYPE_DOUBLE:
- string_value = g_strdup_printf ("%f", g_value_get_double (value));
- break;
+ {
+ gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
+ g_ascii_dtostr (buf, G_ASCII_DTOSTR_BUF_SIZE, g_value_get_double (value));
+ string_value = g_strdup_printf ("%s", buf);
+ }
+ break;
case G_TYPE_BOOLEAN:
string_value = g_strdup_printf ("%d", g_value_get_boolean (value));
break;