Add doc files to dist and fix version number in NEWS.
[mmediamanager.git] / test / clients / test-applications.c
blobe5df4bf5fcb01c9e054eaf0ed338f13930d4625e
1 /* test program for libmmanager */
3 #include "config.h"
4 #include <libmmanager/mm.h>
5 #include <glib-object.h>
6 #include <gio/gio.h>
7 #include <glib.h>
9 static void
10 print_all (MMAttribute * attr,
11 GValue *val,
12 gpointer unused)
14 const char *string;
16 string = g_value_get_string (val);
17 g_print ("attr %s, name %s, desc %s, value %s\n", mm_attribute_get_id (attr),
18 mm_attribute_get_name (attr), mm_attribute_get_description (attr),
19 string);
22 static void
23 print_all_hits (MMHitCollection *coll)
25 MMHit *h;
26 GHashTable *table;
28 while ((h = mm_hit_collection_get_next_hit (coll)) != NULL) {
29 table = mm_hit_get_all_values (h);
30 g_hash_table_foreach (table, (GHFunc) print_all, NULL);
34 static void
35 print_all_categories (MMApplication *app)
37 GList *cats, *l;
38 MMFilter *f;
39 MMFilterParam *fp;
40 MMAttribute *a;
41 GValue *val;
42 GError *error = NULL;
44 cats = mm_application_get_categories (app, &error);
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, &error));
59 int main (int argc, char **argv)
61 MMManager *manager;
62 GList *applications, *l;
63 GAppInfo *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;