deviceprovider: add device provider

Add device provider
Clean up states
Make generic object id instead of exposing GDBusProxy
Add more introspection API
This commit is contained in:
Wim Taymans 2015-07-08 17:40:37 +02:00
parent cbeee04809
commit 7159ea8408
14 changed files with 811 additions and 41 deletions

View file

@ -555,6 +555,19 @@ pinos_context_connect (PinosContext *context,
return TRUE;
}
static void
finish_client_disconnect (PinosContext *context)
{
PinosContextPrivate *priv = context->priv;
g_clear_object (&priv->client);
g_clear_object (&priv->daemon);
g_bus_unwatch_name(priv->id);
priv->id = 0;
context_set_state (context, PINOS_CONTEXT_STATE_UNCONNECTED);
}
static void
on_client_disconnected (GObject *source_object,
GAsyncResult *res,
@ -575,12 +588,7 @@ on_client_disconnected (GObject *source_object,
}
g_variant_unref (ret);
g_clear_object (&priv->client);
g_clear_object (&priv->daemon);
g_bus_unwatch_name(priv->id);
priv->id = 0;
context_set_state (context, PINOS_CONTEXT_STATE_UNCONNECTED);
finish_client_disconnect (context);
g_object_unref (context);
}
@ -617,7 +625,11 @@ pinos_context_disconnect (PinosContext *context)
g_return_val_if_fail (PINOS_IS_CONTEXT (context), FALSE);
priv = context->priv;
g_return_val_if_fail (priv->client != NULL, FALSE);
if (priv->client == NULL) {
finish_client_disconnect (context);
return TRUE;
}
g_main_context_invoke (priv->context,
(GSourceFunc) do_disconnect,

View file

@ -67,11 +67,11 @@ typedef enum {
* The state of a #PinosContext
*/
typedef enum {
PINOS_CONTEXT_STATE_ERROR = -1,
PINOS_CONTEXT_STATE_UNCONNECTED = 0,
PINOS_CONTEXT_STATE_CONNECTING = 1,
PINOS_CONTEXT_STATE_REGISTERING = 2,
PINOS_CONTEXT_STATE_READY = 3,
PINOS_CONTEXT_STATE_ERROR = 4
} PinosContextState;
/**

View file

@ -33,7 +33,8 @@
* @cancelable: a #GCancellable
* @user_data: user data passed to @cb
*
* Call @cb for each source.
* Call @cb for each source. @cb will be called with NULL when there
* are no more sources to list.
*/
void
pinos_context_list_source_info (PinosContext *context,
@ -49,9 +50,32 @@ pinos_context_list_source_info (PinosContext *context,
GDBusProxy *proxy = walk->data;
PinosSourceInfo info;
info.id = proxy;
info.name = "gst";
cb (context, &info, user_data);
}
cb (context, NULL, user_data);
}
/**
* pinos_context_get_source_info:
* @context: a connected #PinosContext
* @id: a source id
* @flags: extra #PinosSourceInfoFlags
* @cb: a #PinosSourceInfoCallback
* @cancelable: a #GCancellable
* @user_data: user data passed to @cb
*
* Call @cb for each source. @cb will be called with NULL when there
* are no more sources to list.
*/
void
pinos_context_get_source_info_by_id (PinosContext *context,
gpointer id,
PinosSourceInfoFlags flags,
PinosSourceInfoCallback cb,
GCancellable *cancellable,
gpointer user_data)
{
}

View file

@ -50,6 +50,7 @@ typedef enum {
/**
* PinosSourceInfo:
* @id: generic id of the source
* @name: the name of the source
* @properties: the properties of the source
* @state: the current state of the source
@ -58,6 +59,7 @@ typedef enum {
* The source information
*/
typedef struct {
gpointer id;
const char *name;
GVariant *properties;
PinosSourceState state;
@ -78,11 +80,17 @@ typedef enum {
typedef gboolean (*PinosSourceInfoCallback) (PinosContext *c, const PinosSourceInfo *info, gpointer userdata);
void pinos_context_list_source_info (PinosContext *context,
PinosSourceInfoFlags flags,
PinosSourceInfoCallback cb,
GCancellable *cancellable,
gpointer user_data);
void pinos_context_list_source_info (PinosContext *context,
PinosSourceInfoFlags flags,
PinosSourceInfoCallback cb,
GCancellable *cancellable,
gpointer user_data);
void pinos_context_get_source_info_by_id (PinosContext *context,
gpointer id,
PinosSourceInfoFlags flags,
PinosSourceInfoCallback cb,
GCancellable *cancellable,
gpointer user_data);
G_END_DECLS

View file

@ -41,12 +41,12 @@ typedef struct _PinosStreamClass PinosStreamClass;
typedef struct _PinosStreamPrivate PinosStreamPrivate;
typedef enum {
PINOS_STREAM_STATE_ERROR = -1,
PINOS_STREAM_STATE_UNCONNECTED = 0,
PINOS_STREAM_STATE_CONNECTING = 1,
PINOS_STREAM_STATE_READY = 2,
PINOS_STREAM_STATE_STARTING = 3,
PINOS_STREAM_STATE_STREAMING = 4,
PINOS_STREAM_STATE_ERROR = 5
PINOS_STREAM_STATE_STREAMING = 4
} PinosStreamState;

View file

@ -643,7 +643,7 @@ pinos_subscribe_class_init (PinosSubscribeClass * klass)
3,
PINOS_TYPE_SUBSCRIPTION_EVENT,
PINOS_TYPE_SUBSCRIPTION_FLAGS,
G_TYPE_DBUS_PROXY);
G_TYPE_POINTER);
}
static void

View file

@ -87,16 +87,16 @@ PinosSubscribe * pinos_subscribe_new (void);
PinosSubscriptionState pinos_subscribe_get_state (PinosSubscribe *subscribe);
GError * pinos_subscribe_get_error (PinosSubscribe *subscribe);
void pinos_subscribe_get_proxy (PinosSubscribe *subscribe,
const gchar *name,
const gchar *object_path,
const gchar *interface_name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDBusProxy * pinos_subscribe_get_proxy_finish (PinosSubscribe *subscribe,
GAsyncResult *res,
GError **error);
void pinos_subscribe_get_proxy (PinosSubscribe *subscribe,
const gchar *name,
const gchar *object_path,
const gchar *interface_name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
GDBusProxy * pinos_subscribe_get_proxy_finish (PinosSubscribe *subscribe,
GAsyncResult *res,
GError **error);