summaryrefslogtreecommitdiff
path: root/gcr/gcr-mock-prompter.c
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2012-09-21 10:23:23 +0200
committerStef Walter <stefw@gnome.org>2012-10-22 15:58:55 +0200
commitd042d43ae1f44c37334fd620ad1e5625f06aa88f (patch)
tree8be293e916dbd1b90f325d112df626adcf006354 /gcr/gcr-mock-prompter.c
parent930654b4bc985b733640ece9017133cb8c220b7b (diff)
downloadgcr-d042d43ae1f44c37334fd620ad1e5625f06aa88f.tar.gz
gcr: Implement prompt-close in GcrSystemPrompt and GcrSystemPrompter
* Properly relay the prompt-close signal from GcrSystemPrompter back to GcrSystemPrompt by firing the PromptDone callback method on the caller's DBus interface. * Make sure GcrSystemPrompt emits prompt-close appropriately for all the various paths that can close the prompt. * Add testing of the above, and changes in the mock prompter for this. https://bugzilla.gnome.org/show_bug.cgi?id=678611
Diffstat (limited to 'gcr/gcr-mock-prompter.c')
-rw-r--r--gcr/gcr-mock-prompter.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/gcr/gcr-mock-prompter.c b/gcr/gcr-mock-prompter.c
index 1ef31e0..564ed2d 100644
--- a/gcr/gcr-mock-prompter.c
+++ b/gcr/gcr-mock-prompter.c
@@ -88,6 +88,7 @@ struct _GcrMockPromptClass {
};
typedef struct {
+ gboolean close;
gboolean proceed;
gchar *password;
GList *properties;
@@ -403,6 +404,17 @@ on_timeout_complete (gpointer data)
return FALSE;
}
+static gboolean
+on_timeout_complete_and_close (gpointer data)
+{
+ GSimpleAsyncResult *res = data;
+ GcrPrompt *prompt = GCR_PROMPT (g_async_result_get_source_object (data));
+ g_simple_async_result_complete (res);
+ gcr_prompt_close (prompt);
+ g_object_unref (prompt);
+ return FALSE;
+}
+
static void
gcr_mock_prompt_confirm_async (GcrPrompt *prompt,
GCancellable *cancellable,
@@ -428,6 +440,10 @@ gcr_mock_prompt_confirm_async (GcrPrompt *prompt,
g_critical ("password prompt requested, but not expected");
g_simple_async_result_set_op_res_gboolean (res, FALSE);
+ } else if (response->close) {
+ complete_func = on_timeout_complete_and_close;
+ g_simple_async_result_set_op_res_gboolean (res, FALSE);
+
} else if (response->password) {
g_critical ("confirmation prompt requested, but password prompt expected");
g_simple_async_result_set_op_res_gboolean (res, FALSE);
@@ -504,6 +520,10 @@ gcr_mock_prompt_password_async (GcrPrompt *prompt,
g_critical ("password prompt requested, but not expected");
g_simple_async_result_set_op_res_gpointer (res, NULL, NULL);
+ } else if (response->close) {
+ g_simple_async_result_set_op_res_gpointer (res, NULL, NULL);
+ complete_func = on_timeout_complete_and_close;
+
} else if (!response->password) {
g_critical ("password prompt requested, but confirmation prompt expected");
g_simple_async_result_set_op_res_gpointer (res, NULL, NULL);
@@ -798,6 +818,30 @@ gcr_mock_prompter_expect_password_cancel (void)
}
/**
+ * gcr_mock_prompter_expect_close:
+ *
+ * Queue an expected response on the mock prompter.
+ *
+ * Expects any prompt, and closes the prompt when it gets it.
+ */
+void
+gcr_mock_prompter_expect_close (void)
+{
+ MockResponse *response;
+
+ g_assert (running != NULL);
+
+ g_mutex_lock (running->mutex);
+
+ response = g_new0 (MockResponse, 1);
+ response->close = TRUE;
+
+ g_queue_push_tail (&running->responses, response);
+
+ g_mutex_unlock (running->mutex);
+}
+
+/**
* gcr_mock_prompter_is_expecting:
*
* Check if the mock prompter is expecting a response. This will be %TRUE