Commit c40bf36f authored by Christian Kellner's avatar Christian Kellner
Browse files

device: method to get the dbus object path

parent e4a777f5
......@@ -31,6 +31,8 @@ struct _BoltDevice
{
BoltDBusDeviceSkeleton object;
char *dbus_path;
char *uid;
char *name;
char *vendor;
......@@ -62,6 +64,8 @@ bolt_device_finalize (GObject *object)
{
BoltDevice *dev = BOLT_DEVICE (object);
g_free (dev->dbus_path);
g_free (dev->uid);
g_free (dev->name);
g_free (dev->vendor);
......@@ -240,10 +244,11 @@ bolt_device_export (BoltDevice *device,
GDBusConnection *connection,
GError **error)
{
g_autofree char *path = NULL;
const char *path;
g_return_val_if_fail (BOLT_IS_DEVICE (device), FALSE);
path = g_strdup_printf ("/org/freedesktop/Bolt/devices/%s", device->uid);
g_strdelimit (path, "-", '_');
path = bolt_device_get_object_path (device);
g_debug ("Exporting device at: %s", path);
......@@ -258,3 +263,21 @@ bolt_device_unexport (BoltDevice *device)
{
g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON (device));
}
const char *
bolt_device_get_object_path (BoltDevice *device)
{
g_return_val_if_fail (BOLT_IS_DEVICE (device), FALSE);
if (device->dbus_path == NULL)
{
char *path = NULL;
path = g_strdup_printf ("/org/freedesktop/Bolt/devices/%s", device->uid);
g_strdelimit (path, "-", '_');
device->dbus_path = path;
}
return device->dbus_path;
}
......@@ -42,4 +42,6 @@ gboolean bolt_device_export (BoltDevice *device,
void bolt_device_unexport (BoltDevice *device);
const char * bolt_device_get_object_path (BoltDevice *device);
G_END_DECLS
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment