DevdClient

DevdClient — base class for communicating with devices

Functions

Properties

char * arch Read
char * kernel Read
char * name Read
char * system Read
guint timeout Read / Write
char * triplet Read

Signals

Types and Values

Object Hierarchy

    GObject
    ╰── DevdClient
        ╰── DevdNetworkClient

Description

The DevdClient is a base-class that is used to communicate with devices. Network based devices (or USB) subclass this to provide a common API, despite different transport mediums.

Functions

devd_client_emit_notification ()

void
devd_client_emit_notification (DevdClient *self,
                               const gchar *method,
                               GVariant *params);

devd_client_emit_service_added ()

void
devd_client_emit_service_added (DevdClient *self,
                                const gchar *service);

devd_client_get_services ()

gchar **
devd_client_get_services (DevdClient *self);

Gets the names of services currently supported by the client.

Parameters

self

a DevdClient

 

Returns

a GStrv of service names.

[transfer full]

Since: 3.28


devd_client_has_service ()

gboolean
devd_client_has_service (DevdClient *self,
                         const gchar *name);

devd_client_get_timeout ()

guint
devd_client_get_timeout (DevdClient *self);

devd_client_set_timeout ()

void
devd_client_set_timeout (DevdClient *self,
                         guint timeout);

devd_client_get_name ()

gchar *
devd_client_get_name (DevdClient *self);

Gets the name of the peer that this client is connected to.

This value is discovered when initializing a connection with the peer.

Parameters

self

a DevdClient

 

Returns

a newly allocated string or NULL.

[transfer full][nullable]

Since: 3.28


devd_client_get_arch ()

gchar *
devd_client_get_arch (DevdClient *self);

devd_client_get_arch has been deprecated since version 3.30 and should not be used in newly-written code.

Use devd_client_get_triplet() instead.

Gets the architecture of the device, such as "x86_64". Generally, this is the machine value from uname().

Parameters

self

a DevdClient

 

Returns

a string representing the architecture.

[transfer full]

Since: 3.28


devd_client_get_kernel ()

gchar *
devd_client_get_kernel (DevdClient *self);

devd_client_get_kernel has been deprecated since version 3.30 and should not be used in newly-written code.

Use devd_client_get_triplet() instead.

Gets the kernel of the device, such as "linux". This is the kernel component of the familiar "target triplet".

Parameters

self

a DevdClient

 

Returns

a string representing the kernel.

[transfer full]

Since: 3.28


devd_client_get_system ()

gchar *
devd_client_get_system (DevdClient *self);

devd_client_get_system has been deprecated since version 3.30 and should not be used in newly-written code.

Use devd_client_get_triplet() instead.

Gets the system of the device, such as "gnu". This is the system component of the familiar "target triplet".

Parameters

self

a DevdClient

 

Returns

a string representing the system.

[transfer full]

Since: 3.28


devd_client_get_triplet ()

DevdTriplet *
devd_client_get_triplet (DevdClient *self);

Gets the DevdTriplet object holding information about the architecture triplet

Parameters

self

a DevdClient

 

Returns

a DevdTriplet representing the architecture triplet.

[transfer full]

Since: 3.30


devd_client_connect_async ()

void
devd_client_connect_async (DevdClient *self,
                           GCancellable *cancellable,
                           GAsyncReadyCallback callback,
                           gpointer user_data);

Asynchronously connects to the device for which the client was created.

callback should complete the operation by calling devd_client_connect_finish().

Parameters

self

a DevdClient

 

cancellable

a GCancellable or NULL.

[nullable]

callback

a GAsyncReadyCallback, or NULL

 

user_data

closure data for callback

 

Since: 3.28


devd_client_connect_finish ()

gboolean
devd_client_connect_finish (DevdClient *self,
                            GAsyncResult *result,
                            GError **error);

Completes an asynchronous connection to the device, initiated with devd_client_connect_async().

Parameters

self

a DevdClient

 

result

a GAsyncResult provided to callback

 

error

a location for a GError or NULL

 

Returns

TRUE if successful; otherwise FALSE and error is set.

Since: 3.28


devd_client_disconnect_async ()

void
devd_client_disconnect_async (DevdClient *self,
                              GCancellable *cancellable,
                              GAsyncReadyCallback callback,
                              gpointer user_data);

devd_client_disconnect_finish ()

gboolean
devd_client_disconnect_finish (DevdClient *self,
                               GAsyncResult *result,
                               GError **error);

devd_client_call_async ()

void
devd_client_call_async (DevdClient *self,
                        const gchar *method,
                        GVariant *params,
                        GCancellable *cancellable,
                        GAsyncReadyCallback callback,
                        gpointer user_data);

Asynchronously calls an RPC on the device, if available.

Not all DevdClient implementations are guaranteed to support this interface, and therefore may fail.

Parameters

self

a DevdClient

 

method

the RPC method name

 

params

the parameters for the method.

[transfer none][nullable]

cancellable

a GCancellable or NULL.

[nullable]

callback

a callback to execute upon completion

 

user_data

closure data for callback

 

Since: 3.28


devd_client_call_finish ()

gboolean
devd_client_call_finish (DevdClient *self,
                         GAsyncResult *result,
                         GVariant **reply,
                         GError **error);

Gets the result of the RPC call.

Parameters

self

a DevdClient

 

result

a GAsyncResult provided to callback

 

reply

a location for a GVariant.

[optional][out]

error

a location for a GError, or NULL

 

Returns

TRUE if successful; otherwise FALSE and error is set. reply is set to the reply from the peer, of provided.


devd_client_list_apps_async ()

void
devd_client_list_apps_async (DevdClient *self,
                             GCancellable *cancellable,
                             GAsyncReadyCallback callback,
                             gpointer user_data);

Asynchronously requests a list of applications that are available to the peer that the DevdClient is connected to.

To complete the asynchronous request, callback must call devd_client_list_apps_finish() to obtain the result.

Parameters

self

a DevdClient

 

cancellable

a GCancellable or NULL.

[nullable]

callback

a GAsyncReadyCallback

 

user_data

closure data for callback

 

Since: 3.28


devd_client_list_apps_finish ()

GPtrArray *
devd_client_list_apps_finish (DevdClient *self,
                              GAsyncResult *result,
                              GError **error);

Completes an asynchronous request to devd_client_list_apps_async().

Parameters

self

a DevdClient

 

result

a GAsyncResult provided to callback

 

error

a location for a GError, or NULL

 

Returns

An array of DevdClientAppInfo if successful; otherwise NULL and error is set.

[transfer container][element-type Deviced.AppInfo]

Since: 3.28


devd_client_list_runtimes_async ()

void
devd_client_list_runtimes_async (DevdClient *self,
                                 GCancellable *cancellable,
                                 GAsyncReadyCallback callback,
                                 gpointer user_data);

Asynchronously requests a list of runtimes that are available to the peer that the DevdClient is connected to.

To complete the asynchronous request, callback must call devd_client_list_runtimes_finish() to obtain the result.

Parameters

self

a DevdClient

 

cancellable

a GCancellable or NULL.

[nullable]

callback

a GAsyncReadyCallback

 

user_data

closure data for callback

 

Since: 3.28


devd_client_list_runtimes_finish ()

GPtrArray *
devd_client_list_runtimes_finish (DevdClient *self,
                                  GAsyncResult *result,
                                  GError **error);

Completes an asynchronous request to devd_client_list_runtimes_async().

Parameters

self

a DevdClient

 

result

a GAsyncResult provided to callback

 

error

a location for a GError, or NULL

 

Returns

An array of DevdClientAppInfo if successful; otherwise NULL and error is set.

[transfer container][element-type Deviced.AppInfo]

Since: 3.28


devd_client_list_files_async ()

void
devd_client_list_files_async (DevdClient *self,
                              const gchar *path,
                              const gchar *attributes,
                              GCancellable *cancellable,
                              GAsyncReadyCallback callback,
                              gpointer user_data);

Lists the files in a given path on the device.

Use attributes to specify the file attributes to retrieve. These follow the same convention as g_file_enumerate_children().

Parameters

self

a DevdClient

 

path

the path on the device

 

attributes

file attributes

 

cancellable

a GCancellable, or NULL.

[nullable]

callback

a callback to execute up on completion

 

user_data

closure data for callback

 

Since: 3.28


devd_client_list_files_finish ()

GPtrArray *
devd_client_list_files_finish (DevdClient *self,
                               GAsyncResult *result,
                               GError **error);

Completes an asynchronous request to list files on the device.

Parameters

self

a DevdClient

 

result

a GAsyncResult provided to callback

 

error

a location for a GError, or NULL

 

Returns

a GPtrArray of GFileInfo retrieved from the device.

[transfer container][element-type Gio.FileInfo]

Since: 3.28


devd_client_run_app_async ()

void
devd_client_run_app_async (DevdClient *self,
                           const gchar *provider,
                           const gchar *app_id,
                           const gchar *pty,
                           GCancellable *cancellable,
                           GAsyncReadyCallback callback,
                           gpointer user_data);

Asynchronously runs an application on the connected DevdClient.

To complete the asynchronous request, callback must call devd_client_run_app_finish() to obtain the result.

Parameters

self

a DevdClient

 

provider

the app provider

 

app_id

the ID of the app to run

 

pty

a pty ID.

[nullable]

cancellable

a GCancellable or NULL.

[nullable]

callback

a GAsyncReadyCallback

 

user_data

closure data for callback

 

Since: 3.28


devd_client_run_app_finish ()

gchar *
devd_client_run_app_finish (DevdClient *self,
                            GAsyncResult *result,
                            GError **error);

Completes an asynchronous request to devd_client_run_app_async().

Parameters

self

a DevdClient

 

result

a GAsyncResult provided to callback

 

error

a location for a GError, or NULL

 

Returns

the identifier for the process, or NULL and error is set.

Since: 3.28


devd_client_syncfs_async ()

void
devd_client_syncfs_async (DevdClient *self,
                          const gchar *devices,
                          GCancellable *cancellable,
                          GAsyncReadyCallback callback,
                          gpointer user_data);

Requests that the device sync changes to the file-system to the underlying storage devices specified, or all devices if devices is NULL.

Note, currently, only syncing all file-systems is supported.

Parameters

self

a DevdClient

 

devices

a comma-separated list of devices, or NULL.

[nullable]

cancellable

a GCancellable, or NULL.

[nullable]

callback

a callback to execute upon completion

 

user_data

closure data for callback

 

Since: 3.28


devd_client_syncfs_finish ()

gboolean
devd_client_syncfs_finish (DevdClient *self,
                           GAsyncResult *result,
                           GError **error);

Completes an asynchronous request to sync file-system changes to their underlying storage devices.

Parameters

self

a DevdClient

 

result

a GAsyncResult provided to callback

 

error

a location for a GError, or NULL

 

Returns

TRUE if successful; otherwise FALSE and error is set.

Since: 3.28

Types and Values

DEVD_TYPE_CLIENT

#define DEVD_TYPE_CLIENT (devd_client_get_type())

struct DevdClientClass

struct DevdClientClass {
  GObjectClass parent_instance;

  void         (*notification)          (DevdClient             *self,
                                         const gchar            *method,
                                         GVariant               *params);
  void         (*service_added)         (DevdClient             *self,
                                         const gchar            *service);
  void         (*connect_async)         (DevdClient             *self,
                                         GCancellable           *cancellable,
                                         GAsyncReadyCallback     callback,
                                         gpointer                user_data);
  gboolean     (*connect_finish)        (DevdClient             *self,
                                         GAsyncResult           *result,
                                         GError                **error);
  void         (*disconnect_async)      (DevdClient             *self,
                                         GCancellable           *cancellable,
                                         GAsyncReadyCallback     callback,
                                         gpointer                user_data);
  gboolean     (*disconnect_finish)     (DevdClient             *self,
                                         GAsyncResult           *result,
                                         GError                **error);
  gchar       *(*get_name)              (DevdClient             *self);
  gchar       *(*get_arch)              (DevdClient             *self);
  gchar       *(*get_kernel)            (DevdClient             *self);
  gchar       *(*get_system)            (DevdClient             *self);
  DevdTriplet *(*get_triplet)           (DevdClient             *self);
  void         (*call_async)            (DevdClient             *self,
                                         const gchar            *method,
                                         GVariant               *params,
                                         GCancellable           *cancellable,
                                         GAsyncReadyCallback     callback,
                                         gpointer                user_data);
  gboolean     (*call_finish)           (DevdClient             *self,
                                         GAsyncResult           *result,
                                         GVariant              **reply,
                                         GError                **error);
  void         (*list_apps_async)       (DevdClient             *self,
                                         GCancellable           *cancellable,
                                         GAsyncReadyCallback     callback,
                                         gpointer                user_data);
  GPtrArray   *(*list_runtimes_finish)  (DevdClient             *self,
                                         GAsyncResult           *result,
                                         GError                **error);
  void         (*list_runtimes_async)   (DevdClient             *self,
                                         GCancellable           *cancellable,
                                         GAsyncReadyCallback     callback,
                                         gpointer                user_data);
  GPtrArray   *(*list_apps_finish)      (DevdClient             *self,
                                         GAsyncResult           *result,
                                         GError                **error);
  void         (*list_files_async)      (DevdClient             *self,
                                         const gchar            *path,
                                         const gchar            *attributes,
                                         GCancellable           *cancellable,
                                         GAsyncReadyCallback     callback,
                                         gpointer                user_data);
  GPtrArray   *(*list_files_finish)     (DevdClient             *self,
                                         GAsyncResult           *result,
                                         GError                **error);
  void         (*run_app_async)         (DevdClient             *self,
                                         const gchar            *provider,
                                         const gchar            *app_id,
                                         const gchar            *pty,
                                         GCancellable           *cancellable,
                                         GAsyncReadyCallback     callback,
                                         gpointer                user_data);
  gchar       *(*run_app_finish)        (DevdClient             *self,
                                         GAsyncResult           *result,
                                         GError                **error);
  void         (*syncfs_async)          (DevdClient             *self,
                                         const gchar            *devices,
                                         GCancellable           *cancellable,
                                         GAsyncReadyCallback     callback,
                                         gpointer                user_data);
  gboolean     (*syncfs_finish)         (DevdClient             *self,
                                         GAsyncResult           *result,
                                         GError                **error);
};

DevdClient

typedef struct _DevdClient DevdClient;

Property Details

The “arch” property

  “arch”                     char *

The architecture of the device, if provided.

Owner: DevdClient

Flags: Read

Default value: NULL


The “kernel” property

  “kernel”                   char *

The kernel of the device, if provided.

Owner: DevdClient

Flags: Read

Default value: NULL


The “name” property

  “name”                     char *

The name of the device, if any.

Owner: DevdClient

Flags: Read

Default value: NULL


The “system” property

  “system”                   char *

The operating system of the device, if provided.

Owner: DevdClient

Flags: Read

Default value: NULL


The “timeout” property

  “timeout”                  guint

The timeout for communication in seconds.

Owner: DevdClient

Flags: Read / Write

Default value: 0


The “triplet” property

  “triplet”                  char *

The architecture triplet, if provided.

Owner: DevdClient

Flags: Read

Default value: NULL

Signal Details

The “notification” signal

void
user_function (DevdClient *self,
               char       *method,
               GVariant   *params,
               gpointer    user_data)

The "notification" signal is emitted when a client has received a notification from the peer.

Not all clients will support this, so it's specific for communicating with some clients and services.

Parameters

self

a DevdClient

 

method

the method name

 

params

the parameters for the notification

 

user_data

user data set when the signal handler was connected.

 

Flags: Has Details

Since: 3.28


The “service-added” signal

void
user_function (DevdClient *self,
               char       *service,
               gpointer    user_data)

The "service-added" signal is emitted when a new service is advertised by the client. This can happen when the device has enabled a new feature while you're connected.

If integrating with third-party libraries, this can be used to advertise that additional services are enabled on the connection.

Parameters

self

a DevdClient

 

service

the name of the service

 

user_data

user data set when the signal handler was connected.

 

Flags: Run Last

Since: 3.28