TnyDevice

TnyDevice — A type that defines a device

Synopsis




#define             TNY_TYPE_DEVICE_SIGNAL
                    TnyDevice;
                    TnyDeviceIface;
gboolean            tny_device_is_online                (TnyDevice *self);
void                tny_device_force_online             (TnyDevice *self);
void                tny_device_force_offline            (TnyDevice *self);
void                tny_device_reset                    (TnyDevice *self);

Object Hierarchy


  GInterface
   +----TnyDevice

Prerequisites

TnyDevice requires GObject.

Signals


  "connection-changed"                             : Run First

Description

A abstract type that defines a few device specific things like the online/offline status.

Details

TNY_TYPE_DEVICE_SIGNAL

#define TNY_TYPE_DEVICE_SIGNAL (tny_device_signal_get_type())


TnyDevice

typedef struct _TnyDevice TnyDevice;

A device, with online and offline state

free-function: g_object_unref


TnyDeviceIface

typedef struct {
	GTypeInterface parent;

	gboolean (*is_online) (TnyDevice *self);

	void (*force_online) (TnyDevice *self);
	void (*force_offline) (TnyDevice *self);
	void (*reset) (TnyDevice *self);

	/* Signals */
	void (*connection_changed) (TnyDevice *self, gboolean online);
} TnyDeviceIface;


tny_device_is_online ()

gboolean            tny_device_is_online                (TnyDevice *self);

Request the current state of self. In case of forced online, this function returns TRUE. In case of forced offline, this function returns FALSE. In case of online, this function returns TRUE. In case of offline, this function returns FALSE.

Example:

TnyDevice *device = ...
tny_device_force_online (device);
if (!tny_device_is_online (device))
     g_print ("Something is wrong\n");
tny_device_reset (device);

self : a TnyDevice
Returns : TRUE if online or forced online, FALSE if offline or forced offline

Since 1.0 audience: platform-developer, type-implementer


tny_device_force_online ()

void                tny_device_force_online             (TnyDevice *self);

Force online status, so that tny_device_is_online() returns TRUE, regardless of whether there is an actual network connection. The connection_changed signal will be emitted if the returned value of tny_device_is_online() changed by this function.

This can be used on platforms that cannot detect whether a network connection exists. This will usually not attempt to make a real network connection.

See also tny_device_force_offline() and tny_device_reset().

self : a TnyDevice

Since 1.0 audience: platform-developer, type-implementer


tny_device_force_offline ()

void                tny_device_force_offline            (TnyDevice *self);

Force offline status, so that tny_device_is_online() returns FALSE, regardless of whether there is an actual network connection. The connection_changed signal will be emitted if the returned value of tny_device_is_online() changed by this function.

This can be used to mark a device as offline if the connection is unusable due to some specific error, such as a failure to access a server or to use a particular port, or if the user specifically chose "offline mode". It can also be used on platforms that cannot detect whether a network connection exists. This will usually not attempt to disconnect a real network connection.

Example:

TnyDevice *device = ...
tny_device_force_offline (device);
if (tny_device_is_online (device))
     g_print ("Something is wrong\n");
tny_device_reset (device);

See also tny_device_force_online() and tny_device_reset().

self : a TnyDevice

Since 1.0 audience: platform-developer, type-implementer


tny_device_reset ()

void                tny_device_reset                    (TnyDevice *self);

Reset the status of self, unforce the status.

This reverses the effects of tny_device_force_online and tny_device_force_offline. Future changes of connection status will cause the connection_changed signal to be emitted, and tny_device_is_online will return a correct value.

The connection_changed signal will be emitted if to return a different value than before, for instance if the network connection has actually become available or unavailable while the status was forced. For example in case the forced state was offline, and after reset the actual state is online. Or in case the forced state was online, and after reset the actual state is offline.

self : a TnyDevice

Since 1.0 audience: platform-developer, type-implementer

Signal Details

The "connection-changed" signal

void                user_function                      (TnyDevice *self,
                                                        gboolean   arg1,
                                                        gpointer   user_data)      : Run First

Emitted when the connection status of a device changes. This signal will not be emitted in response to actual connection changes while the status is forced with tny_device_force_online() or tny_device_force_offline().

@: @:
self : the object on which the signal is emitted
arg1 : Whether or not the device is now online
user_data : (null-ok): user data set when the signal handler was connected.
user_data : user data set when the signal handler was connected.

Since 1.0 audience: platform-developer, type-implementer

See Also

TnyDeviceSignal