Fix a bug in filter_serialize () and update tests.
[mmediamanager.git] / test / clients / test-applications.c
blob7b10bd36e2c0a756128d47bf4bc9d74870099a02
1 /* test program for libmmanager */
3 #include "config.h"
4 #include "mm.h"
5 #include <glib-object.h>
6 #include <gio/gdesktopappinfo.h>
7 #include <gio/gio.h>
8 #include <glib.h>
10 static void
11 print_all (MMAttribute * attr,
12 GValue *val,
13 gpointer unused)
15 const char *string;
17 string = g_value_get_string (val);
18 g_print ("attr %s, name %s, desc %s, value %s\n", mm_attribute_get_id (attr),
19 mm_attribute_get_name (attr), mm_attribute_get_description (attr),
20 string);
23 static void
24 print_all_hits (MMHitCollection *coll)
26 MMHit *h;
27 GHashTable *table;
29 while ((h = mm_hit_collection_get_next_hit (coll)) != NULL) {
30 table = mm_hit_get_all_values (h);
31 g_hash_table_foreach (table, (GHFunc) print_all, NULL);
35 static void
36 print_all_categories (MMApplication *app)
38 GList *cats, *l;
39 MMFilter *f;
40 MMFilterParam *fp;
41 MMAttribute *a;
42 GValue *val;
44 cats = mm_application_get_categories (app);
45 f = g_object_new (MM_TYPE_FILTER, NULL);
46 a = mm_attribute_manager_lookup_attribute (mm_attribute_base_manager_get (), MM_ATTRIBUTE_BASE_URI);
47 val = mm_create_gvalue_for_attribute (a);
48 g_value_set_string (val, "file:///home/anarki/blah");
49 fp = mm_filter_param_new (a, val, MM_COMP_EQUAL);
50 mm_filter_add_filtering_param (f, fp);
51 g_object_unref (fp);
52 g_free (val);
53 for (l = cats; l; l = l->next) {
54 g_print ("category name %s\n", mm_category_get_name (l->data));
55 print_all_hits (mm_category_get_hits (l->data, f));
59 int main (int argc, char **argv)
61 MMManager *manager;
62 GList *applications, *l;
63 GDesktopAppInfo *info;
64 MMApplication *app;
66 g_type_init ();
68 manager = mm_manager_get ();
69 applications = mm_manager_get_application_list (manager);
71 for (l = applications; l; l = l->next) {
72 app = l->data;
73 info = mm_application_get_app_info (app);
74 g_print ("found application %s\n", g_app_info_get_name (G_APP_INFO (info)));
75 print_all_categories (app);
78 g_print ("end of list\n");
80 return 0;