static void mex_telepathy_channel_new_tf_channel (GObject *source, GAsyncResult *result, gpointer user_data) { MexTelepathyChannel *self = MEX_TELEPATHY_CHANNEL (user_data); MexTelepathyChannelPrivate *priv = self->priv; MEX_DEBUG ("New TfChannel"); priv->tf_channel = TF_CHANNEL (g_async_initable_new_finish ( G_ASYNC_INITABLE (source), result, NULL)); if (priv->tf_channel == NULL) { MEX_WARNING ("Failed to create channel"); return; } MEX_DEBUG ("Adding timeout"); priv->pipeline_timer = g_timeout_add_seconds (5, mex_telepathy_channel_dump_pipeline, self); g_signal_connect (priv->tf_channel, "fs-conference-added", G_CALLBACK (mex_telepathy_channel_conference_added), self); g_signal_connect (priv->tf_channel, "content-added", G_CALLBACK (mex_telepathy_channel_on_content_added), self); }
static void on_tf_channel_ready (GObject *source, GAsyncResult *result, gpointer user_data) { EmpathyCallHandler *self = EMPATHY_CALL_HANDLER (user_data); EmpathyCallHandlerPriv *priv = GET_PRIV (self); GError *error = NULL; priv->tfchannel = TF_CHANNEL (g_async_initable_new_finish ( G_ASYNC_INITABLE (source), result, NULL)); if (priv->tfchannel == NULL) { g_warning ("Failed to create Farstream channel: %s", error->message); g_error_free (error); return; } /* Set up the telepathy farstream channel */ g_signal_connect (priv->tfchannel, "closed", G_CALLBACK (on_tf_channel_closed_cb), self); g_signal_connect (priv->tfchannel, "fs-conference-added", G_CALLBACK (on_tf_channel_conference_added_cb), self); g_signal_connect (priv->tfchannel, "fs-conference-removed", G_CALLBACK (on_tf_channel_conference_removed_cb), self); g_signal_connect (priv->tfchannel, "content-added", G_CALLBACK (on_tf_channel_content_added_cb), self); g_signal_connect (priv->tfchannel, "content-removed", G_CALLBACK (on_tf_channel_content_removed_cb), self); }
static void list_build_object_ready (GDBusConnection *connection, GAsyncResult *res, ListSmsContext *ctx) { GError *error = NULL; GObject *sms; GObject *source_object; source_object = g_async_result_get_source_object (res); sms = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error); g_object_unref (source_object); if (error) { g_simple_async_result_take_error (ctx->result, error); list_sms_context_complete_and_free (ctx); return; } /* Keep the object */ ctx->sms_objects = g_list_prepend (ctx->sms_objects, sms); /* If no more smss, just end here. */ if (!ctx->sms_paths[++ctx->i]) { g_simple_async_result_set_op_res_gpointer (ctx->result, ctx->sms_objects, (GDestroyNotify)sms_object_list_free); ctx->sms_objects = NULL; list_sms_context_complete_and_free (ctx); return; } /* Keep on creating next object */ create_next_sms (ctx); }
static void on_manager_new (GObject *source, GAsyncResult *result, gpointer user_data) { GSimpleAsyncResult *async = G_SIMPLE_ASYNC_RESULT (user_data); NewClosure *closure = g_simple_async_result_get_op_res_gpointer (async); GDBusConnection *connection; GError *error = NULL; GObject *object; object = g_async_initable_new_finish (G_ASYNC_INITABLE (source), result, &error); if (error == NULL) { closure->manager = UM_REALM_MANAGER (object); connection = g_dbus_object_manager_client_get_connection (G_DBUS_OBJECT_MANAGER_CLIENT (object)); g_debug ("Connected to realmd"); um_realm_provider_proxy_new (connection, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, "org.freedesktop.realmd", "/org/freedesktop/realmd", closure->cancellable, on_provider_new, g_object_ref (async)); } else { g_simple_async_result_take_error (async, error); g_simple_async_result_complete (async); } g_object_unref (async); }
static void handle_new_bss (NMSupplicantInterface *self, const char *object_path) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); GDBusProxy *bss_proxy; g_return_if_fail (object_path != NULL); if (g_hash_table_lookup (priv->bss_proxies, object_path)) return; bss_proxy = g_object_new (G_TYPE_DBUS_PROXY, "g-bus-type", G_BUS_TYPE_SYSTEM, "g-flags", G_DBUS_PROXY_FLAGS_NONE, "g-name", WPAS_DBUS_SERVICE, "g-object-path", object_path, "g-interface-name", WPAS_DBUS_IFACE_BSS, NULL); g_hash_table_insert (priv->bss_proxies, (char *) g_dbus_proxy_get_object_path (bss_proxy), bss_proxy); g_signal_connect (bss_proxy, "g-properties-changed", G_CALLBACK (bss_props_changed_cb), self); g_async_initable_init_async (G_ASYNC_INITABLE (bss_proxy), G_PRIORITY_DEFAULT, priv->other_cancellable, (GAsyncReadyCallback) on_bss_proxy_acquired, self); }
/** * cockpit_fake_manager_new_finish: * @result: an async result * @error: location to place an error or NULL * * Complete an async init of fake manager started with * cockpit_fake_manager_new_for_bus(). * * Returns: (transfer full): the new manager or NULL */ GDBusObjectManager * cockpit_fake_manager_new_finish (GAsyncResult *result, GError **error) { GObject *source_object; GObject *object; source_object = g_async_result_get_source_object (result); object = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), result, error); g_object_unref (source_object); return object ? G_DBUS_OBJECT_MANAGER (object) : NULL; }
/** * nma_mobile_providers_database_new_finish: * @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to nma_mobile_providers_database_new(). * @error: Return location for error or %NULL. * * Returns: (transfer full) (type NMAMobileProvidersDatabase): The constructed object or %NULL if @error is set. */ NMAMobileProvidersDatabase * nma_mobile_providers_database_new_finish (GAsyncResult *res, GError **error) { GObject *initable; GObject *out; initable = g_async_result_get_source_object (res); out = g_async_initable_new_finish (G_ASYNC_INITABLE (initable), res, error); g_object_unref (initable); return out ? NMA_MOBILE_PROVIDERS_DATABASE (out) : NULL; }
GObject * hev_serial_port_new_finish(GAsyncResult *res, GError **error) { GObject *object = NULL, *source_object = NULL; g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); source_object = g_async_result_get_source_object(res); object = g_async_initable_new_finish(G_ASYNC_INITABLE(source_object), res, error); g_object_unref(source_object); return object; }
void tf_call_channel_new_async (TpChannel *channel, GAsyncReadyCallback callback, gpointer user_data) { TfCallChannel *self = g_object_new (TF_TYPE_CALL_CHANNEL, NULL); self->proxy = g_object_ref (channel); g_async_initable_init_async (G_ASYNC_INITABLE (self), 0, NULL, callback, user_data); /* Ownership passed to async call */ g_object_unref (self); }
/** * goa_client_new_finish: * @res: A #GAsyncResult. * @error: Return location for error or %NULL. * * Finishes an operation started with goa_client_new(). * * Returns: A #GoaClient or %NULL if @error is set. Free with * g_object_unref() when done with it. */ GoaClient * goa_client_new_finish (GAsyncResult *res, GError **error) { GObject *ret; GObject *source_object; source_object = g_async_result_get_source_object (res); ret = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); g_object_unref (source_object); if (ret != NULL) return GOA_CLIENT (ret); else return NULL; }
GDBusProxy * _nm_dbus_new_proxy_for_connection_finish (GAsyncResult *result, GError **error) { GObject *source; GDBusProxy *proxy; source = g_async_result_get_source_object (result); proxy = G_DBUS_PROXY (g_async_initable_new_finish (G_ASYNC_INITABLE (source), result, error)); g_object_unref (source); _nm_dbus_proxy_replace_match (proxy); return proxy; }
/** * e_gdbus_cal_factory_proxy_new_for_bus_finish: * @res: A #GAsyncResult obtained from the #GAsyncReadyCallback function passed to e_gdbus_cal_factory_proxy_new_for_bus(). * @error: Return location for error or %NULL. * * Finishes creating a #EGdbusCalFactoryProxy. * * Returns: A #EGdbusCalFactoryProxy or %NULL if @error is set. Free with g_object_unref(). */ EGdbusCalFactory *e_gdbus_cal_factory_proxy_new_for_bus_finish (GAsyncResult *res, GError **error) { GObject *object; GObject *source_object; source_object = g_async_result_get_source_object (res); g_assert (source_object != NULL); object = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); g_object_unref (source_object); if (object != NULL) return E_GDBUS_CAL_FACTORY (object); else return NULL; }
GClueClientInfo * gclue_client_info_new_finish (GAsyncResult *res, GError **error) { GObject *object; GObject *source_object; source_object = g_async_result_get_source_object (res); object = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); g_object_unref (source_object); if (object != NULL) return GCLUE_CLIENT_INFO (object); else return NULL; }
EmpathyServerTLSHandler * empathy_server_tls_handler_new_finish (GAsyncResult *result, GError **error) { GObject *object, *source_object; source_object = g_async_result_get_source_object (result); object = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), result, error); g_object_unref (source_object); if (object != NULL) return EMPATHY_SERVER_TLS_HANDLER (object); else return NULL; }
static void content_ready (GObject *object, GAsyncResult *res, gpointer user_data) { TfCallChannel *self = TF_CALL_CHANNEL (user_data); TfCallContent *content = TF_CALL_CONTENT (object); if (g_async_initable_init_finish (G_ASYNC_INITABLE (object), res, NULL)) { g_signal_emit (self, signals[SIGNAL_CONTENT_ADDED], 0, content); } else { g_ptr_array_remove_fast (self->contents, content); } g_object_unref (self); }
/** * g_async_initable_newv_async: * @object_type: a #GType supporting #GAsyncInitable. * @n_parameters: the number of parameters in @parameters * @parameters: the parameters to use to construct the object * @io_priority: the <link linkend="io-priority">I/O priority</link> * of the operation. * @cancellable: optional #GCancellable object, %NULL to ignore. * @callback: a #GAsyncReadyCallback to call when the initialization is * finished * @user_data: the data to pass to callback function * * Helper function for constructing #GAsyncInitable object. This is * similar to g_object_newv() but also initializes the object asynchronously. * * When the initialization is finished, @callback will be called. You can * then call g_async_initable_new_finish() to get the new object and check * for any errors. * * Since: 2.22 */ void g_async_initable_newv_async (GType object_type, guint n_parameters, GParameter *parameters, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GObject *obj; g_return_if_fail (G_TYPE_IS_ASYNC_INITABLE (object_type)); obj = g_object_newv (object_type, n_parameters, parameters); g_async_initable_init_async (G_ASYNC_INITABLE (obj), io_priority, cancellable, callback, user_data); }
MMBearer * mm_broadband_bearer_novatel_new_finish (GAsyncResult *res, GError **error) { GObject *bearer; GObject *source; source = g_async_result_get_source_object (res); bearer = g_async_initable_new_finish (G_ASYNC_INITABLE (source), res, error); g_object_unref (source); if (!bearer) return NULL; /* Only export valid bearers */ mm_bearer_export (MM_BEARER (bearer)); return MM_BEARER (bearer); }
MMBaseSim * mm_sim_sierra_new_finish (GAsyncResult *res, GError **error) { GObject *source; GObject *sim; source = g_async_result_get_source_object (res); sim = g_async_initable_new_finish (G_ASYNC_INITABLE (source), res, error); g_object_unref (source); if (!sim) return NULL; /* Only export valid SIMs */ mm_base_sim_export (MM_BASE_SIM (sim)); return MM_BASE_SIM (sim); }
HevIObj * hev_iobj_new_finish (GAsyncResult *res, GError **error) { GObject *object; GObject *source_object; g_debug ("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); source_object = g_async_result_get_source_object (res); g_assert (NULL != source_object); object = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, error); g_object_unref (source_object); if (NULL != object) return HEV_IOBJ (object); return NULL; }
static void initable_init_async_parent_ready (GObject *source, GAsyncResult *res, gpointer user_data) { GError *inner_error = NULL; InitAsyncContext *ctx = user_data; gchar *name = NULL; gchar *object_path = NULL; GDBusObjectManagerClientFlags flags = G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE; GDBusConnection *connection = NULL; /* Parent init ready, check it */ if (!async_initable_parent_iface->init_finish (G_ASYNC_INITABLE (source), res, &inner_error)) { g_simple_async_result_take_error (ctx->result, inner_error); g_simple_async_result_complete (ctx->result); init_async_context_free (ctx); return; } /* Get the Manager proxy created asynchronously now */ g_object_get (ctx->manager, "name", &name, "object-path", &object_path, "flags", &flags, "connection", &connection, NULL); mm_gdbus_org_freedesktop_modem_manager1_proxy_new (connection, flags, name, object_path, ctx->cancellable, initable_init_async_manager_proxy_ready, ctx); g_object_unref (connection); g_free (object_path); g_free (name); }
/** * g_async_initable_new_valist_async: * @object_type: a #GType supporting #GAsyncInitable. * @first_property_name: the name of the first property, followed by * the value, and other property value pairs, and ended by %NULL. * @var_args: The var args list generated from @first_property_name. * @io_priority: the <link linkend="io-priority">I/O priority</link> * of the operation. * @cancellable: optional #GCancellable object, %NULL to ignore. * @callback: a #GAsyncReadyCallback to call when the initialization is * finished * @user_data: the data to pass to callback function * * Helper function for constructing #GAsyncInitable object. This is * similar to g_object_new_valist() but also initializes the object * asynchronously. * * When the initialization is finished, @callback will be called. You can * then call g_async_initable_new_finish() to get the new object and check * for any errors. * * Since: 2.22 */ void g_async_initable_new_valist_async (GType object_type, const gchar *first_property_name, va_list var_args, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GObject *obj; g_return_if_fail (G_TYPE_IS_ASYNC_INITABLE (object_type)); obj = g_object_new_valist (object_type, first_property_name, var_args); g_async_initable_init_async (G_ASYNC_INITABLE (obj), io_priority, cancellable, callback, user_data); g_object_unref (obj); /* Passed ownership to async call */ }
static void new_sms_object_ready (GDBusConnection *connection, GAsyncResult *res, CreateSmsContext *ctx) { GError *error = NULL; GObject *sms; GObject *source_object; source_object = g_async_result_get_source_object (res); sms = g_async_initable_new_finish (G_ASYNC_INITABLE (source_object), res, &error); g_object_unref (source_object); if (error) g_simple_async_result_take_error (ctx->result, error); else g_simple_async_result_set_op_res_gpointer (ctx->result, sms, (GDestroyNotify)g_object_unref); create_sms_context_complete_and_free (ctx); }
static void interface_add_done (NMSupplicantInterface *self, const char *path) { NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); nm_log_dbg (LOGD_SUPPLICANT, "(%s): interface added to supplicant", priv->dev); priv->object_path = g_strdup (path); priv->iface_proxy = g_object_new (G_TYPE_DBUS_PROXY, "g-bus-type", G_BUS_TYPE_SYSTEM, "g-flags", G_DBUS_PROXY_FLAGS_NONE, "g-name", WPAS_DBUS_SERVICE, "g-object-path", priv->object_path, "g-interface-name", WPAS_DBUS_IFACE_INTERFACE, NULL); g_signal_connect (priv->iface_proxy, "g-properties-changed", G_CALLBACK (props_changed_cb), self); g_async_initable_init_async (G_ASYNC_INITABLE (priv->iface_proxy), G_PRIORITY_DEFAULT, priv->init_cancellable, (GAsyncReadyCallback) on_iface_proxy_acquired, self); }
static void on_bss_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) { NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; gs_free_error GError *error = NULL; gs_strfreev char **properties = NULL; gs_unref_variant GVariant *props = NULL; GVariantBuilder builder; char **iter; if (!g_async_initable_init_finish (G_ASYNC_INITABLE (proxy), result, &error)) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { nm_log_dbg (LOGD_SUPPLICANT, "Failed to acquire BSS proxy: (%s)", error->message); g_hash_table_remove (NM_SUPPLICANT_INTERFACE_GET_PRIVATE (user_data)->bss_proxies, g_dbus_proxy_get_object_path (proxy)); } return; } self = NM_SUPPLICANT_INTERFACE (user_data); priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); iter = properties = g_dbus_proxy_get_cached_property_names (proxy); while (iter && *iter) { GVariant *copy = g_dbus_proxy_get_cached_property (proxy, *iter); g_variant_builder_add (&builder, "{sv}", *iter++, copy); g_variant_unref (copy); } props = g_variant_builder_end (&builder); g_signal_emit (self, signals[NEW_BSS], 0, g_dbus_proxy_get_object_path (proxy), g_variant_ref_sink (props)); }
IdeFileSettings * ide_file_settings_new (IdeObject *parent, GFile *file, const gchar *language) { IdeFileSettingsPrivate *priv; GIOExtensionPoint *extension_point; IdeFileSettings *ret; GList *list; g_return_val_if_fail (G_IS_FILE (file), NULL); g_return_val_if_fail (IDE_IS_OBJECT (parent), NULL); ret = g_object_new (IDE_TYPE_FILE_SETTINGS, "file", file, "language", language, NULL); priv = ide_file_settings_get_instance_private (ret); ide_object_append (parent, IDE_OBJECT (ret)); extension_point = g_io_extension_point_lookup (IDE_FILE_SETTINGS_EXTENSION_POINT); list = g_io_extension_point_get_extensions (extension_point); /* * Don't allow our unsettled count to hit zero until we are finished. */ priv->unsettled_count++; for (; list; list = list->next) { GIOExtension *extension = list->data; g_autoptr(IdeFileSettings) child = NULL; GType gtype; gtype = g_io_extension_get_type (extension); if (!g_type_is_a (gtype, IDE_TYPE_FILE_SETTINGS)) { g_warning ("%s is not an IdeFileSettings", g_type_name (gtype)); continue; } child = g_object_new (gtype, "file", file, "language", language, NULL); ide_object_append (IDE_OBJECT (ret), IDE_OBJECT (child)); if (G_IS_INITABLE (child)) { g_autoptr(GError) error = NULL; if (!g_initable_init (G_INITABLE (child), NULL, &error)) { if (!ide_error_ignore (error)) g_warning ("%s", error->message); } } else if (G_IS_ASYNC_INITABLE (child)) { priv->unsettled_count++; g_async_initable_init_async (G_ASYNC_INITABLE (child), G_PRIORITY_DEFAULT, NULL, ide_file_settings__init_cb, g_object_ref (ret)); } _ide_file_settings_append (ret, child); } priv->unsettled_count--; return ret; }
static void on_iface_proxy_acquired (GDBusProxy *proxy, GAsyncResult *result, gpointer user_data) { NMSupplicantInterface *self; NMSupplicantInterfacePrivate *priv; gs_free_error GError *error = NULL; if (!g_async_initable_init_finish (G_ASYNC_INITABLE (proxy), result, &error)) { if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { nm_log_warn (LOGD_SUPPLICANT, "Failed to acquire wpa_supplicant interface proxy: (%s)", error->message); set_state (NM_SUPPLICANT_INTERFACE (user_data), NM_SUPPLICANT_INTERFACE_STATE_DOWN); } return; } self = NM_SUPPLICANT_INTERFACE (user_data); priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self); _nm_dbus_signal_connect (priv->iface_proxy, "ScanDone", G_VARIANT_TYPE ("(b)"), G_CALLBACK (wpas_iface_scan_done), self); _nm_dbus_signal_connect (priv->iface_proxy, "BSSAdded", G_VARIANT_TYPE ("(oa{sv})"), G_CALLBACK (wpas_iface_bss_added), self); _nm_dbus_signal_connect (priv->iface_proxy, "BSSRemoved", G_VARIANT_TYPE ("(o)"), G_CALLBACK (wpas_iface_bss_removed), self); _nm_dbus_signal_connect (priv->iface_proxy, "NetworkRequest", G_VARIANT_TYPE ("(oss)"), G_CALLBACK (wpas_iface_network_request), self); /* Scan result aging parameters */ g_dbus_proxy_call (priv->iface_proxy, "org.freedesktop.DBus.Properties.Set", g_variant_new ("(ssv)", WPAS_DBUS_IFACE_INTERFACE, "BSSExpireAge", g_variant_new_uint32 (250)), G_DBUS_CALL_FLAGS_NONE, -1, priv->init_cancellable, NULL, NULL); g_dbus_proxy_call (priv->iface_proxy, "org.freedesktop.DBus.Properties.Set", g_variant_new ("(ssv)", WPAS_DBUS_IFACE_INTERFACE, "BSSExpireCount", g_variant_new_uint32 (2)), G_DBUS_CALL_FLAGS_NONE, -1, priv->init_cancellable, NULL, NULL); /* Check whether NetworkReply and AP mode are supported */ priv->ready_count = 1; g_dbus_proxy_call (priv->iface_proxy, "NetworkReply", g_variant_new ("(oss)", "/fff", "foobar", "foobar"), G_DBUS_CALL_FLAGS_NONE, -1, priv->init_cancellable, (GAsyncReadyCallback) iface_check_netreply_cb, self); if (priv->ap_support == AP_SUPPORT_UNKNOWN) { /* If the global supplicant capabilities property is not present, we can * fall back to checking whether the ProbeRequest method is supported. If * neither of these works we have no way of determining if AP mode is * supported or not. hostap 1.0 and earlier don't support either of these. */ priv->ready_count++; g_dbus_proxy_call (priv->iface_proxy, DBUS_INTERFACE_INTROSPECTABLE ".Introspect", NULL, G_DBUS_CALL_FLAGS_NONE, -1, priv->init_cancellable, (GAsyncReadyCallback) iface_check_ap_mode_cb, self); } }