/**
* secret_service_new:
+ * @service_gtype: the GType of the new secret service
* @service_bus_name: (allow-none): the D-Bus service name of the secret service
* @flags: flags for which service functionality to ensure is initialized
* @cancellable: optional cancellation object
*
* This function is rarely used, see secret_service_get() instead.
*
+ * The @service_gtype argument should be set to %SECRET_TYPE_SERVICE or a the type
+ * of a derived class.
+ *
* If @flags contains any flags of which parts of the secret service to
* ensure are initialized, then those will be initialized before returning.
*
* This method will return immediately and complete asynchronously.
*/
void
-secret_service_new (const gchar *service_bus_name,
+secret_service_new (GType service_gtype,
+ const gchar *service_bus_name,
SecretServiceFlags flags,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+ g_return_if_fail (g_type_is_a (service_gtype, SECRET_TYPE_SERVICE));
if (service_bus_name == NULL)
service_bus_name = default_bus_name;
- g_async_initable_new_async (SECRET_TYPE_SERVICE, G_PRIORITY_DEFAULT,
+ g_async_initable_new_async (service_gtype, G_PRIORITY_DEFAULT,
cancellable, callback, user_data,
"g-flags", G_DBUS_PROXY_FLAGS_NONE,
"g-interface-info", _secret_gen_service_interface_info (),
/**
* secret_service_new_sync:
+ * @service_gtype: the GType of the new secret service
* @service_bus_name: (allow-none): the D-Bus service name of the secret service
* @flags: flags for which service functionality to ensure is initialized
* @cancellable: optional cancellation object
*
* This function is rarely used, see secret_service_get_sync() instead.
*
+ * The @service_gtype argument should be set to %SECRET_TYPE_SERVICE or a the
+ * type of a derived class.
+ *
* If @flags contains any flags of which parts of the secret service to
* ensure are initialized, then those will be initialized before returning.
*
* should be released with g_object_unref().
*/
SecretService *
-secret_service_new_sync (const gchar *service_bus_name,
+secret_service_new_sync (GType service_gtype,
+ const gchar *service_bus_name,
SecretServiceFlags flags,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
+ g_return_val_if_fail (g_type_is_a (service_gtype, SECRET_TYPE_SERVICE), NULL);
if (service_bus_name == NULL)
service_bus_name = default_bus_name;
- return g_initable_new (SECRET_TYPE_SERVICE, cancellable, error,
+ return g_initable_new (service_gtype, cancellable, error,
"g-flags", G_DBUS_PROXY_FLAGS_NONE,
"g-interface-info", _secret_gen_service_interface_info (),
"g-name", service_bus_name,
/* Both these sohuld point to different things */
- service1 = secret_service_new_sync (NULL, SECRET_SERVICE_NONE, NULL, &error);
+ service1 = secret_service_new_sync (SECRET_TYPE_SERVICE, NULL,
+ SECRET_SERVICE_NONE, NULL, &error);
g_assert_no_error (error);
- service2 = secret_service_new_sync (NULL, SECRET_SERVICE_NONE, NULL, &error);
+ service2 = secret_service_new_sync (SECRET_TYPE_SERVICE, NULL,
+ SECRET_SERVICE_NONE, NULL, &error);
g_assert_no_error (error);
g_assert (SECRET_IS_SERVICE (service1));
/* Both these sohuld point to different things */
- secret_service_new (NULL, SECRET_SERVICE_NONE, NULL, on_complete_get_result, &result);
+ secret_service_new (SECRET_TYPE_SERVICE, NULL, SECRET_SERVICE_NONE,
+ NULL, on_complete_get_result, &result);
g_assert (result == NULL);
egg_test_wait ();
service1 = secret_service_new_finish (result, &error);
g_assert_no_error (error);
g_clear_object (&result);
- secret_service_new (NULL, SECRET_SERVICE_NONE, NULL, on_complete_get_result, &result);
+ secret_service_new (SECRET_TYPE_SERVICE, NULL, SECRET_SERVICE_NONE, NULL,
+ on_complete_get_result, &result);
g_assert (result == NULL);
egg_test_wait ();
service2 = secret_service_new_finish (result, &error);
const gchar *path;
GList *collections;
- service = secret_service_new_sync (NULL, SECRET_SERVICE_NONE, NULL, &error);
+ service = secret_service_new_sync (SECRET_TYPE_SERVICE, NULL, SECRET_SERVICE_NONE,
+ NULL, &error);
g_assert_no_error (error);
g_assert (SECRET_IS_SERVICE (service));
g_object_unref (service);
egg_assert_not_object (service);
- service = secret_service_new_sync (NULL, SECRET_SERVICE_LOAD_COLLECTIONS, NULL, &error);
+ service = secret_service_new_sync (SECRET_TYPE_SERVICE, NULL,
+ SECRET_SERVICE_LOAD_COLLECTIONS, NULL, &error);
g_assert_no_error (error);
g_assert (SECRET_IS_SERVICE (service));
g_object_unref (service);
egg_assert_not_object (service);
- service = secret_service_new_sync (NULL, SECRET_SERVICE_OPEN_SESSION, NULL, &error);
+ service = secret_service_new_sync (SECRET_TYPE_SERVICE, NULL,
+ SECRET_SERVICE_OPEN_SESSION, NULL, &error);
g_assert_no_error (error);
g_assert (SECRET_IS_SERVICE (service));
const gchar *path;
GList *collections;
- secret_service_new (NULL, SECRET_SERVICE_LOAD_COLLECTIONS | SECRET_SERVICE_OPEN_SESSION, NULL, on_complete_get_result, &result);
+ secret_service_new (SECRET_TYPE_SERVICE, NULL,
+ SECRET_SERVICE_LOAD_COLLECTIONS | SECRET_SERVICE_OPEN_SESSION, NULL, on_complete_get_result, &result);
g_assert (result == NULL);
egg_test_wait ();
/* Now get a session with just collections */
- secret_service_new (NULL, SECRET_SERVICE_LOAD_COLLECTIONS, NULL, on_complete_get_result, &result);
+ secret_service_new (SECRET_TYPE_SERVICE, NULL, SECRET_SERVICE_LOAD_COLLECTIONS,
+ NULL, on_complete_get_result, &result);
g_assert (result == NULL);
egg_test_wait ();
gboolean ret;
/* Passing true, ensures session is established */
- service = secret_service_new_sync (NULL, SECRET_SERVICE_NONE, NULL, &error);
+ service = secret_service_new_sync (SECRET_TYPE_SERVICE, NULL,
+ SECRET_SERVICE_NONE, NULL, &error);
g_assert_no_error (error);
g_assert (service != NULL);
gboolean ret;
/* Passing true, ensures session is established */
- service = secret_service_new_sync (NULL, SECRET_SERVICE_NONE, NULL, &error);
+ service = secret_service_new_sync (SECRET_TYPE_SERVICE, NULL,
+ SECRET_SERVICE_NONE, NULL, &error);
g_assert_no_error (error);
g_assert (service != NULL);