/**
* secret_prompt_run:
* @self: a prompt
- * @window_id: XWindow id for parent window to be transient for
+ * @window_id: (allow-none): string form of XWindow id for parent window to be transient for
* @cancellable: optional cancellation object
* @return_type: the variant type of the prompt result
* @error: location to place an error on failure
* action the prompt is completing, and is defined in the Secret Service DBus
* API specification.
*
- * If @window_id is non-zero then it is used as an XWindow id. The Secret
- * Service can make its prompt transient for the window with this id. In some
- * Secret Service implementations this is not possible, so the behavior
- * depending on this should degrade gracefully.
+ * If @window_id is non-null then it is used as an XWindow id on Linux. The API
+ * expects this id to be converted to a string using the <literal>%d</literal>
+ * printf format. The Secret Service can make its prompt transient for the window
+ * with this id. In some Secret Service implementations this is not possible, so
+ * the behavior depending on this should degrade gracefully.
*
* This runs the dialog in a recursive mainloop. When run from a user interface
* thread, this means the user interface will remain responsive. Care should be
*/
GVariant *
secret_prompt_run (SecretPrompt *self,
- gulong window_id,
+ const gchar *window_id,
GCancellable *cancellable,
const GVariantType *return_type,
GError **error)
/**
* secret_prompt_perform_sync:
* @self: a prompt
- * @window_id: XWindow id for parent window to be transient for
+ * @window_id: (allow-none): string form of XWindow id for parent window to be transient for
* @cancellable: optional cancellation object
* @return_type: the variant type of the prompt result
* @error: location to place an error on failure
* action the prompt is completing, and is defined in the Secret Service DBus
* API specification.
*
- * If @window_id is non-zero then it is used as an XWindow id. The Secret
- * Service can make its prompt transient for the window with this id. In some
- * Secret Service implementations this is not possible, so the behavior
- * depending on this should degrade gracefully.
+ * If @window_id is non-null then it is used as an XWindow id on Linux. The API
+ * expects this id to be converted to a string using the <literal>%d</literal>
+ * printf format. The Secret Service can make its prompt transient for the window
+ * with this id. In some Secret Service implementations this is not possible,
+ * so the behavior depending on this should degrade gracefully.
*
* This method may block indefinitely and should not be used in user interface
* threads.
*/
GVariant *
secret_prompt_perform_sync (SecretPrompt *self,
- gulong window_id,
+ const gchar *window_id,
GCancellable *cancellable,
const GVariantType *return_type,
GError **error)
/**
* secret_prompt_perform:
* @self: a prompt
- * @window_id: XWindow id for parent window to be transient for
+ * @window_id: (allow-none): string form of XWindow id for parent window to be transient for
* @return_type: the variant type of the prompt result
* @cancellable: optional cancellation object
* @callback: called when the operation completes
* Runs a prompt and performs the prompting. Returns %TRUE if the prompt
* was completed and not dismissed.
*
- * If @window_id is non-zero then it is used as an XWindow id. The Secret
- * Service can make its prompt transient for the window with this id. In some
- * Secret Service implementations this is not possible, so the behavior
- * depending on this should degrade gracefully.
+ * If @window_id is non-null then it is used as an XWindow id on Linux. The API
+ * expects this id to be converted to a string using the <literal>%d</literal>
+ * printf format. The Secret Service can make its prompt transient for the window
+ * with this id. In some Secret Service implementations this is not possible, so
+ * the behavior depending on this should degrade gracefully.
*
* This method will return immediately and complete asynchronously.
*/
void
secret_prompt_perform (SecretPrompt *self,
- gulong window_id,
+ const gchar *window_id,
const GVariantType *return_type,
GCancellable *cancellable,
GAsyncReadyCallback callback,
const gchar *object_path;
gboolean prompted;
GDBusProxy *proxy;
- gchar *window;
g_return_if_fail (SECRET_IS_PROMPT (self));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
closure->return_type = return_type ? g_variant_type_copy (return_type) : NULL;
g_simple_async_result_set_op_res_gpointer (res, closure, perform_closure_free);
- if (window_id == 0)
- window = g_strdup ("");
- else
- window = g_strdup_printf ("%lu", window_id);
+ if (window_id == NULL)
+ window_id = "";
owner_name = g_dbus_proxy_get_name_owner (proxy);
object_path = g_dbus_proxy_get_object_path (proxy);
res, NULL);
}
- g_dbus_proxy_call (proxy, "Prompt", g_variant_new ("(s)", window),
+ g_dbus_proxy_call (proxy, "Prompt", g_variant_new ("(s)", window_id),
G_DBUS_CALL_FLAGS_NO_AUTO_START, -1,
closure->call_cancellable, on_prompt_prompted, g_object_ref (res));
- g_free (window);
g_object_unref (res);
}
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/simple");
- retval = secret_prompt_perform_sync (prompt, 0, NULL, NULL, &error);
+ retval = secret_prompt_perform_sync (prompt, NULL, NULL, NULL, &error);
g_assert_no_error (error);
g_assert (retval != NULL);
g_variant_unref (retval);
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/error");
g_object_add_weak_pointer (G_OBJECT (prompt), (gpointer *)&prompt);
- retval = secret_prompt_perform_sync (prompt, 0, NULL, NULL, &error);
+ retval = secret_prompt_perform_sync (prompt, NULL, NULL, NULL, &error);
g_assert_error (error, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED);
g_assert (retval == NULL);
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/vanish");
g_object_add_weak_pointer (G_OBJECT (prompt), (gpointer *)&prompt);
- retval = secret_prompt_perform_sync (prompt, 0, NULL, NULL, &error);
+ retval = secret_prompt_perform_sync (prompt, NULL, NULL, NULL, &error);
g_assert_no_error (error);
g_assert (retval == NULL);
prompt = _secret_prompt_instance (test->service, "/org/freedesktop/secrets/prompts/window");
g_object_add_weak_pointer (G_OBJECT (prompt), (gpointer *)&prompt);
- retval = secret_prompt_perform_sync (prompt, 555, NULL, G_VARIANT_TYPE_STRING, &error);
+ retval = secret_prompt_perform_sync (prompt, "555", NULL, G_VARIANT_TYPE_STRING, &error);
g_assert_no_error (error);
g_assert (retval != NULL);
g_assert_cmpstr (g_variant_get_string (retval, NULL), ==, "555");