/** * as_content_rating_node_parse: * @content_rating: a #AsContentRating instance. * @node: a #GNode. * @ctx: a #AsNodeContext. * @error: A #GError or %NULL. * * Populates the object from a DOM node. * * Returns: %TRUE for success * * Since: 0.5.12 **/ gboolean as_content_rating_node_parse (AsContentRating *content_rating, GNode *node, AsNodeContext *ctx, GError **error) { AsContentRatingPrivate *priv = GET_PRIVATE (content_rating); GNode *c; const gchar *tmp; g_autoptr(GHashTable) captions = NULL; /* get ID */ tmp = as_node_get_attribute (node, "type"); if (tmp != NULL) as_content_rating_set_kind (content_rating, tmp); /* get keys */ for (c = node->children; c != NULL; c = c->next) { AsContentRatingKey *key; g_autoptr(AsImage) image = NULL; if (as_node_get_tag (c) != AS_TAG_CONTENT_ATTRIBUTE) continue; key = g_slice_new0 (AsContentRatingKey); as_ref_string_assign (&key->id, as_node_get_attribute (c, "id")); key->value = as_content_rating_value_from_string (as_node_get_data (c)); g_ptr_array_add (priv->keys, key); } return TRUE; }
/** * as_require_node_parse: * @require: a #AsRequire instance. * @node: a #GNode. * @ctx: a #AsNodeContext. * @error: A #GError or %NULL. * * Populates the object from a DOM node. * * Returns: %TRUE for success * * Since: 0.6.7 **/ gboolean as_require_node_parse (AsRequire *require, GNode *node, AsNodeContext *ctx, GError **error) { AsRequirePrivate *priv = GET_PRIVATE (require); const gchar *tmp; tmp = as_node_get_name (node); if (tmp != NULL) as_require_set_kind (require, as_require_kind_from_string (tmp)); tmp = as_node_get_attribute (node, "compare"); if (tmp != NULL) as_require_set_compare (require, as_require_compare_from_string (tmp)); as_ref_string_assign (&priv->version, as_node_get_attribute_as_refstr (node, "version")); as_ref_string_assign (&priv->value, as_node_get_data_as_refstr (node)); return TRUE; }
/** * as_provide_node_parse: * @provide: a #AsProvide instance. * @node: a #GNode. * @ctx: a #AsNodeContext. * @error: A #GError or %NULL. * * Populates the object from a DOM node. * * Returns: %TRUE for success * * Since: 0.1.6 **/ gboolean as_provide_node_parse (AsProvide *provide, GNode *node, AsNodeContext *ctx, GError **error) { AsProvidePrivate *priv = GET_PRIVATE (provide); const gchar *tmp; if (g_strcmp0 (as_node_get_name (node), "dbus") == 0) { tmp = as_node_get_attribute (node, "type"); if (g_strcmp0 (tmp, "system") == 0) priv->kind = AS_PROVIDE_KIND_DBUS_SYSTEM; else priv->kind = AS_PROVIDE_KIND_DBUS_SESSION; } else if (g_strcmp0 (as_node_get_name (node), "firmware") == 0) { tmp = as_node_get_attribute (node, "type"); if (g_strcmp0 (tmp, "flashed") == 0) priv->kind = AS_PROVIDE_KIND_FIRMWARE_FLASHED; else priv->kind = AS_PROVIDE_KIND_FIRMWARE_RUNTIME; } else { priv->kind = as_provide_kind_from_string (as_node_get_name (node)); } as_ref_string_assign (&priv->value, as_node_get_data_as_refstr (node)); return TRUE; }
/** * as_image_node_parse: * @image: a #AsImage instance. * @node: a #GNode. * @ctx: a #AsNodeContext. * @error: A #GError or %NULL. * * Populates the object from a DOM node. * * Returns: %TRUE for success * * Since: 0.1.0 **/ gboolean as_image_node_parse (AsImage *image, GNode *node, AsNodeContext *ctx, GError **error) { AsImagePrivate *priv = GET_PRIVATE (image); const gchar *tmp; guint size; size = as_node_get_attribute_as_uint (node, "width"); if (size != G_MAXUINT) as_image_set_width (image, size); size = as_node_get_attribute_as_uint (node, "height"); if (size != G_MAXUINT) as_image_set_height (image, size); tmp = as_node_get_attribute (node, "type"); if (tmp == NULL) as_image_set_kind (image, AS_IMAGE_KIND_SOURCE); else as_image_set_kind (image, as_image_kind_from_string (tmp)); as_ref_string_assign (&priv->url, as_node_get_data (node)); as_ref_string_assign (&priv->locale, as_node_get_attribute (node, "xml:lang")); return TRUE; }