Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 1 commit
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on May 16, 2012
@antonioarlo antonioarlo backend: added a filter before sending the response to D-Bus
Added a filter that removes the 'mv' GVariants from the tuples, in order to remove the error about the 'mv' values sent to the D-Bus.
This is a fix of a previous patch, ordering better the code.

Signed-off-by: Antonio Arias <antonio.arias@gmail.com>
3cf4a06
Showing with 57 additions and 1 deletion.
  1. +57 −1 backend/gt-feed-server.c
View
58 backend/gt-feed-server.c
@@ -134,6 +134,62 @@ gt_feed_server_new(const gchar *apikey)
return g_object_new(GT_TYPE_FEED_SERVER, "api-key", apikey);
}
+static GVariant*
+filter_search_result(GVariant *content)
+{
+ GVariant *data = NULL;
+ GVariantBuilder *builder = NULL;
+ GVariant *newArray = NULL;
+ GVariantBuilder *builder2 = NULL;
+ GVariant *emptyString = g_variant_new("s", "");
+
+ GVariant *array = NULL;
+ GVariantIter *arrayIter = NULL;
+ GVariant *array2 = NULL;
+ GVariantIter *array2Iter = NULL;
+ GVariant *key = NULL;
+ GVariant *value = NULL;
+
+ if (!content)
+ return NULL;
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("av"));
+
+ g_variant_get(content, "av", &arrayIter);
+ while (g_variant_iter_loop (arrayIter, "v", &array2))
+ {
+ builder2 = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+
+ g_variant_get(array2, "a{sv}", &array2Iter);
+
+ while (g_variant_iter_loop (array2Iter, "{sv}", &key, &value))
+ {
+ if (!g_variant_is_of_type(value, G_VARIANT_TYPE_MAYBE))
+ {
+ g_variant_builder_add(builder2, "{sv}", key, value);
+ }
+ else
+ {
+ g_variant_builder_add(builder2, "{sv}", key, emptyString);
+ }
+ }
+ g_variant_iter_free(array2Iter);
+
+ newArray = g_variant_new("a{sv}", builder2);
+ g_variant_builder_add(builder, "v", newArray);
+ g_variant_builder_unref(builder2);
+
+ }
+ g_variant_iter_free(arrayIter);
+
+ data = g_variant_new("av", builder);
+ g_variant_builder_unref(builder);
+
+ g_variant_unref(content);
+
+ return data;
+}
+
static void
cb(GObject *source,
GAsyncResult *res,
@@ -144,7 +200,7 @@ cb(GObject *source,
GtFeed *feed = GT_FEED(source);
GDBusMethodInvocation *invocation = data;
- content = gt_feed_search_finish(feed, res, &error);
+ content = filter_search_result(gt_feed_search_finish(feed, res, &error));
if (error) {
g_dbus_method_invocation_take_error(invocation, error);
return;

No commit comments for this range

Something went wrong with that request. Please try again.