Update tests
[mmediamanager.git] / test / clients / test-applications.c
blobc205b86dbcb3cbfc55f4cfe3d4c4e2984bf11860
1 /* test program for libmmanager */
3 #include <libmmanager/mm-manager.h>
4 #include <libmmanager/mm-application.h>
5 #include <libmmanager/mm-category.h>
6 #include <libmmanager/mm-filter.h>
7 #include <libmmanager/mm-hit.h>
8 #include <libmmanager/mm-hit-collection.h>
9 #include <libmmanager/mm-attribute.h>
10 #include <glib-object.h>
11 #include <gio/gdesktopappinfo.h>
12 #include <gio/gio.h>
13 #include <glib.h>
15 static void
16 print_all (MMAttribute * attr,
17 GValue *val,
18 gpointer unused)
20 const char *string;
22 string = g_value_get_string (val);
23 g_print ("attr %s, name %s, desc %s, value %s\n", mm_attribute_get_id (attr),
24 mm_attribute_get_name (attr), mm_attribute_get_description (attr),
25 string);
28 static void
29 print_all_hits (MMHitCollection *coll)
31 MMHit *h;
32 GHashTable *table;
34 while ((h = mm_hit_collection_get_next_hit (coll)) != NULL) {
35 table = mm_hit_get_all_values (h);
36 g_hash_table_foreach (table, (GHFunc) print_all, NULL);
40 static void
41 print_all_categories (MMApplication *app)
43 GList *cats, *l;
44 MMFilter *f;
46 cats = mm_application_get_categories (app);
47 f = g_object_new (MM_TYPE_FILTER, NULL);
48 for (l = cats; l; l = l->next) {
49 g_print ("category name %s\n", mm_category_get_name (l->data));
50 print_all_hits (mm_category_get_hits (l->data, f));
54 int main (int argc, char **argv)
56 MMManager *manager;
57 GList *applications, *l;
58 GDesktopAppInfo *info;
59 MMApplication *app;
61 g_type_init ();
63 manager = mm_manager_get ();
64 applications = mm_manager_get_application_list (manager);
66 for (l = applications; l; l = l->next) {
67 app = l->data;
68 info = mm_application_get_app_info (app);
69 g_print ("found application %s\n", g_app_info_get_name (G_APP_INFO (info)));
70 print_all_categories (app);
73 g_print ("end of list\n");
75 return 0;