diff --git a/src/client/pv-context.c b/src/client/pv-context.c index 91c1eace3..a30bfc8b5 100644 --- a/src/client/pv-context.c +++ b/src/client/pv-context.c @@ -321,7 +321,6 @@ on_client_connected (GObject *source_object, g_variant_get (ret, "(o)", &priv->client_path); g_print ("got client %s\n", priv->client_path); g_variant_unref (ret); - } static void diff --git a/src/client/pv-source.c b/src/client/pv-source.c index e6f0177ff..5025b8d6c 100644 --- a/src/client/pv-source.c +++ b/src/client/pv-source.c @@ -138,6 +138,8 @@ handle_create_source_output (PvSource1 *interface, const gchar *object_path; output = pv_source_create_source_output (source, arg_properties, priv->object_path); + if (output == NULL) + goto no_output; object_path = pv_source_output_get_object_path (output); @@ -145,6 +147,14 @@ handle_create_source_output (PvSource1 *interface, invocation, object_path); return TRUE; + + /* ERRORS */ +no_output: + { + g_dbus_method_invocation_return_dbus_error (invocation, + "org.pulsevideo.Error", "Can't create output"); + return TRUE; + } } static gboolean diff --git a/src/client/pv-stream.c b/src/client/pv-stream.c index c465a131d..90bd15852 100644 --- a/src/client/pv-stream.c +++ b/src/client/pv-stream.c @@ -340,8 +340,12 @@ on_source_output_proxy (GObject *source_object, { PvStream *stream = user_data; PvStreamPrivate *priv = stream->priv; + PvContext *context = priv->context; GError *error = NULL; + priv->source_output = pv_subscribe_get_proxy_finish (context->priv->subscribe, + res, + &error); if (priv->source_output == NULL) goto source_output_failed; @@ -384,13 +388,13 @@ on_source_output_created (GObject *source_object, g_print ("got source-output %s\n", priv->source_output_path); g_variant_unref (ret); - priv->source_output = pv_subscribe_get_proxy (context->priv->subscribe, - PV_DBUS_SERVICE, - priv->source_output_path, - "org.pulsevideo.SourceOutput1", - NULL, - on_source_ouput_proxy, - stream); + pv_subscribe_get_proxy (context->priv->subscribe, + PV_DBUS_SERVICE, + priv->source_output_path, + "org.pulsevideo.SourceOutput1", + NULL, + on_source_output_proxy, + stream); return; diff --git a/src/client/pv-subscribe.c b/src/client/pv-subscribe.c index e28d64616..c79ecaaf7 100644 --- a/src/client/pv-subscribe.c +++ b/src/client/pv-subscribe.c @@ -115,9 +115,9 @@ on_proxy_properties_changed (GDBusProxy *proxy, GStrv invalidated_properties, gpointer user_data) { - ProxyData *data = user_data; + PvObjectData *data = user_data; - notify_event (subscribe, data->proxy, PV_SUBSCRIPTION_EVENT_CHANGE); + notify_event (data->subscribe, data, PV_SUBSCRIPTION_EVENT_CHANGE); } static void @@ -125,12 +125,14 @@ on_proxy_created (GObject *source_object, GAsyncResult *res, gpointer user_data) { - ProxyData *data = user_data; + PvObjectData *data = user_data; PvSubscribe *subscribe = data->subscribe; PvSubscribePrivate *priv = subscribe->priv; GError *error = NULL; GList *walk; + data->pending = FALSE; + data->proxy = g_dbus_proxy_new_finish (res, &error); if (data->proxy == NULL) { priv->objects = g_list_remove (priv->objects, data); @@ -166,13 +168,14 @@ add_interface (PvSubscribe *subscribe, GVariant *properties) { PvSubscribePrivate *priv = subscribe->priv; - ProxyData *data; + PvObjectData *data; - data = g_new0 (ProxyData, 1); + data = g_new0 (PvObjectData, 1); data->subscribe = subscribe; data->sender_name = g_strdup (priv->service); data->object_path = g_strdup (object_path); data->interface_name = g_strdup (interface_name); + data->pending = TRUE; priv->objects = g_list_prepend (priv->objects, data); priv->pending_proxies++; @@ -647,8 +650,6 @@ compare_data (PvObjectData *data, const gchar *name, void pv_subscribe_get_proxy (PvSubscribe *subscribe, - GDBusProxyFlags flags, - GDBusInterfaceInfo *info, const gchar *name, const gchar *object_path, const gchar *interface_name, @@ -657,10 +658,9 @@ pv_subscribe_get_proxy (PvSubscribe *subscribe, gpointer user_data) { PvSubscribePrivate *priv; - GDBusProxy *res = NULL; GList *walk; - g_return_val_if_fail (PV_IS_SUBSCRIBE (subscribe), NULL); + g_return_if_fail (PV_IS_SUBSCRIBE (subscribe)); priv = subscribe->priv; for (walk = priv->objects; walk; walk = g_list_next (walk)) { @@ -675,7 +675,6 @@ pv_subscribe_get_proxy (PvSubscribe *subscribe, user_data); if (data->pending) { - g_task_set_task_data (task, data, NULL); data->tasks = g_list_prepend (data->tasks, task); } else if (data->proxy) { g_task_return_pointer (task, g_object_ref (data->proxy), g_object_unref); @@ -687,3 +686,11 @@ pv_subscribe_get_proxy (PvSubscribe *subscribe, } } +GDBusProxy * +pv_subscribe_get_proxy_finish (PvSubscribe *subscribe, + GAsyncResult *res, + GError **error) +{ + return g_task_propagate_pointer (G_TASK (res), error); +} + diff --git a/src/client/pv-subscribe.h b/src/client/pv-subscribe.h index 8fd29475f..5443304c4 100644 --- a/src/client/pv-subscribe.h +++ b/src/client/pv-subscribe.h @@ -87,13 +87,17 @@ PvSubscribe * pv_subscribe_new (void); PvSubscriptionState pv_subscribe_get_state (PvSubscribe *subscribe); GError * pv_subscribe_get_error (PvSubscribe *subscribe); -GDBusProxy * pv_subscribe_get_proxy (PvSubscribe *subscribe, +void pv_subscribe_get_proxy (PvSubscribe *subscribe, const gchar *name, const gchar *object_path, const gchar *interface_name, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); +GDBusProxy * pv_subscribe_get_proxy_finish (PvSubscribe *subscribe, + GAsyncResult *res, + GError **error); + G_END_DECLS diff --git a/src/server/pv-daemon.c b/src/server/pv-daemon.c index 763d56c84..e856c7556 100644 --- a/src/server/pv-daemon.c +++ b/src/server/pv-daemon.c @@ -80,9 +80,12 @@ client_name_appeared_handler (GDBusConnection *connection, gpointer user_data) { SenderData *data = user_data; + PvDaemonPrivate *priv = data->daemon->priv; g_print ("client name appeared def: %p\n", g_main_context_get_thread_default ()); + g_hash_table_insert (priv->senders, data->sender, data); + if (!g_strcmp0 (name, g_dbus_connection_get_unique_name (connection))) return; @@ -112,7 +115,6 @@ data_free (SenderData *data) g_free (data); } - static SenderData * sender_data_new (PvDaemon *daemon, const gchar *sender) { @@ -134,7 +136,6 @@ sender_data_new (PvDaemon *daemon, const gchar *sender) data, (GDestroyNotify) data_free); - g_hash_table_insert (priv->senders, data->sender, data); return data; } @@ -395,7 +396,7 @@ pv_daemon_init (PvDaemon * daemon) PvDaemonPrivate *priv = daemon->priv = PV_DAEMON_GET_PRIVATE (daemon); priv->server_manager = g_dbus_object_manager_server_new (PV_DBUS_OBJECT_PREFIX); - priv->senders = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); + priv->senders = g_hash_table_new (g_str_hash, g_str_equal); priv->subscribe = pv_subscribe_new (); g_signal_connect (priv->subscribe,