File: session.c

package info (click to toggle)
packagekit 1.3.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,704 kB
  • sloc: ansic: 56,209; cpp: 13,919; python: 4,970; xml: 4,945; sh: 313; perl: 60; makefile: 57
file content (53 lines) | stat: -rw-r--r-- 1,267 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <gio/gio.h>

int
main (int argc, char *argv[])
{
	const gchar *packages[] = {"openoffice-clipart",
				   "openoffice-clipart-extras",
				   NULL};
	GDBusProxy *proxy = NULL;
	GError *error = NULL;
	guint32 xid = 0;
	GVariant *retval = NULL;

	/* get a session bus proxy */
	proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
					       G_DBUS_PROXY_FLAGS_NONE, NULL,
					       "org.freedesktop.PackageKit",
					       "/org/freedesktop/PackageKit",
					       "org.freedesktop.PackageKit.Modify",
					       NULL, &error);
	if (proxy == NULL) {
		g_warning ("failed: %s", error->message);
		g_error_free (error);
		goto out;
	}

	/* get the window ID, or use 0 for non-modal */
	//xid = GDK_WINDOW_XID (gtk_widget_get_window (dialog));

	/* issue the sync request */
	retval = g_dbus_proxy_call_sync (proxy,
					 "InstallPackageNames",
					 g_variant_new ("(u^a&ss)",
							xid,
							packages,
							"hide-finished"),
					 G_DBUS_CALL_FLAGS_NONE,
					 -1, /* timeout */
					 NULL, /* cancellable */
					 &error);
	if (retval == NULL) {
		g_warning ("failed: %s", error->message);
		g_error_free (error);
		goto out;
	}
out:
	if (proxy != NULL)
		g_object_unref (proxy);
	if (retval != NULL)
		g_object_unref (retval);
	return 0;
}