DevkitClient

DevkitClient — Accessing the DeviceKit daemon

Synopsis


#include <devkit-gobject/devkit-gobject.h>

                    DevkitClient;
                    DevkitClientClass;
DevkitClient *      devkit_client_new                   (const gchar **subsystems);
gboolean            devkit_client_connect               (DevkitClient *client,
                                                         GError **error);
GList *             devkit_client_enumerate_by_subsystem
                                                        (DevkitClient *client,
                                                         const gchar **subsystems,
                                                         GError **error);
GList *             devkit_client_enumerate_by_native_path
                                                        (DevkitClient *client,
                                                         const gchar **native_paths,
                                                         GError **error);
const gchar *       devkit_client_get_daemon_version    (DevkitClient *client);

Object Hierarchy

  GObject
   +----DevkitClient

Properties

  "daemon-version"           gchar*                : Read
  "subsystems"               GStrv*                : Read / Write / Construct Only

Signals

  "device-event"                                   : Run Last

Description

This class provides an interface to the DeviceKit daemon for device enumeration and changes. To get informed about changes, connect to the "device-event" signal.

Details

DevkitClient

typedef struct _DevkitClient DevkitClient;

The DevkitClient struct is opaque and should not be accessed directly.


DevkitClientClass

typedef struct {
        GObjectClass   parent_class;

        /* signals */
        void (*device_event) (DevkitClient  *client,
                              const gchar   *action,
                              DevkitDevice  *device);
} DevkitClientClass;

Class structure for DevkitClient.

GObjectClass parent_class;

Parent class.

device_event ()

Signal class handler for the "device-event" signal.

devkit_client_new ()

DevkitClient *      devkit_client_new                   (const gchar **subsystems);

Constructs a DevkitClient object that listen for device events for devices belonging to subsystems and emits signals. You need to call devkit_client_connect() before it can be used.

subsystems :

Either NULL to listen on events on all subsystems or a NULL terminated string array of of subsystems to listen for events on.

Returns :

A new DevkitClient object.

devkit_client_connect ()

gboolean            devkit_client_connect               (DevkitClient *client,
                                                         GError **error);

Connects to the DeviceKit daemon and starts listening for events. The DeviceKit daemon will be inhibited from shutting down until client is disposed.

client :

A DevkitClient object.

error :

Return location for error.

Returns :

TRUE if the connection was made, FALSE if error is set.

devkit_client_enumerate_by_subsystem ()

GList *             devkit_client_enumerate_by_subsystem
                                                        (DevkitClient *client,
                                                         const gchar **subsystems,
                                                         GError **error);

Retrieves an ordered list of the devices belonging to subsystems from the DeviceKit daemon.

client :

A DevkitClient object.

subsystems :

Either NULL to enumerate all devices or a NULL terminated string array detailing what subsystems to get information about.

error :

Return location for error.

Returns :

NULL if error is set, otherwise a list of DevkitDevice objects. The caller should free this by using g_object_unref() on each element in the list and then g_list_free() on the list.

devkit_client_enumerate_by_native_path ()

GList *             devkit_client_enumerate_by_native_path
                                                        (DevkitClient *client,
                                                         const gchar **native_paths,
                                                         GError **error);

Retrieves an ordered list of the devices with information about the devices given in native_paths from the DeviceKit daemon.

client :

A DevkitClient object.

native_paths :

A NULL terminated string array of native paths.

error :

Return location for error.

Returns :

NULL if error is set, otherwise a list of DevkitDevice objects. The caller should free this by using g_object_unref() on each element in the list and then g_list_free() on the list.

devkit_client_get_daemon_version ()

const gchar *       devkit_client_get_daemon_version    (DevkitClient *client);

Gets the version of the running daemon.

client :

a DevkitClient

Returns :

The version of the running daemon.

Property Details

The "daemon-version" property

  "daemon-version"           gchar*                : Read

The version of the running DeviceKit daemon.

Default value: NULL


The "subsystems" property

  "subsystems"               GStrv*                : Read / Write / Construct Only

The subsystems to listen for events on from the DeviceKit daemon and generate "device-event" signals from. If NULL, events from all subsystems will be reported.

Signal Details

The "device-event" signal

void                user_function                      (DevkitClient *client,
                                                        gchar        *action,
                                                        DevkitDevice *device,
                                                        gpointer      user_data)      : Run Last

Emitted when an event is happening on a device.

client :

a DevkitClient.

action :

an OS-specific string (e.g. "add", "remove", "change") describing the event

device :

details about the DevkitDevice the event is happening on.

user_data :

user data set when the signal handler was connected.