GSignondSignonuiData introdued, which holds all ui data.
#include <glib.h>
#include <glib-object.h>
#include <gsignond/gsignond-session-data.h>
+#include <gsignond/gsignond-signonui-data.h>
G_BEGIN_DECLS
GSignondSessionData *session_data);
void
gsignond_plugin_user_action_finished (GSignondPlugin *self,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
void
gsignond_plugin_refresh (GSignondPlugin *self,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
/* Signals */
void
gsignond_plugin_error (GSignondPlugin *self, GError *error);
void
gsignond_plugin_user_action_required (GSignondPlugin *self,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
void
gsignond_plugin_refreshed (GSignondPlugin *self,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
void
gsignond_plugin_status_changed (GSignondPlugin *self,
GSignondPluginState state,
--- /dev/null
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Contact: Amarnath Valluri<amarnath.valluri@linux.intel.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_SIGNONUI_DATA_H__
+#define __GSIGNOND_SIGNONUI_DATA_H__
+
+#include <gsignond/gsignond-dictionary.h>
+#include <gsignond/gsignond-signonui.h>
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_SIGNONUI_DATA (GSIGNOND_TYPE_DICTIONARY)
+
+#define GSIGNOND_SIGNONUI_DATA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ GSIGNOND_TYPE_SIGNONUI_DATA, \
+ GSignondSignonuiData))
+#define GSIGNOND_IS_SIGNONUI_DATA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
+ GSIGNOND_TYPE_SIGNONUI_DATA))
+
+typedef GSignondDictionary GSignondSignonuiData;
+
+#define gsignond_signonui_data_new() gsignond_dictionary_new()
+
+#define gsignond_signonui_data_new_from_variant(variantmap) gsignond_dictionary_new_from_variant(variantmap)
+
+#define gsignond_signonui_data_to_variant(data) gsignond_dictionary_to_variant (data)
+
+#define gsignond_signonui_data_ref(data) /*gsignond_dictionary_ref*/g_hash_table_ref (data)
+
+#define gsignond_signonui_data_unref(data) /*gsignond_dictionary_unref*/g_hash_table_unref (data);
+
+const gchar*
+gsignond_signonui_data_get_captcha_response (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_captcha_response (GSignondSignonuiData *data,
+ const gchar *response);
+const gchar*
+gsignond_signonui_data_get_captcha_url (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_captcha_url (GSignondSignonuiData *data,
+ const gchar *url);
+const gchar*
+gsignond_signonui_data_get_caption (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_caption (GSignondSignonuiData *data,
+ const gchar *caption);
+gboolean
+gsignond_signonui_data_get_confirm (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_confirm (GSignondSignonuiData *data,
+ gboolean confirm);
+const gchar*
+gsignond_signonui_data_get_final_url (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_final_url (GSignondSignonuiData *data,
+ const gchar *url);
+gboolean
+gsignond_signonui_data_get_forgot_password (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_forgot_password (GSignondSignonuiData *data,
+ gboolean forgot);
+const gchar*
+gsignond_signonui_data_get_forgot_password_url (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_forgot_password_url (GSignondSignonuiData *data,
+ const gchar *url);
+const gchar*
+gsignond_signonui_data_get_message (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_message (GSignondSignonuiData *data,
+ const gchar *message);
+const gchar*
+gsignond_signonui_data_get_open_url (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_open_url (GSignondSignonuiData *data,
+ const gchar *url);
+const gchar*
+gsignond_signonui_data_get_password (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_password (GSignondSignonuiData *data,
+ const gchar *password);
+GSignondSignonuiError
+gsignond_signonui_data_get_query_error (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_query_error (GSignondSignonuiData *data,
+ GSignondSignonuiError error);
+gboolean
+gsignond_signonui_data_get_query_password (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_query_password (GSignondSignonuiData *data,
+ gboolean query);
+gboolean
+gsignond_signonui_data_get_query_username (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_query_username (GSignondSignonuiData *data,
+ gboolean query);
+gboolean
+gsignond_signonui_data_get_remember_password (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_remember_password (GSignondSignonuiData *data,
+ gboolean remember);
+const gchar*
+gsignond_signonui_data_get_request_id (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_request_id (GSignondSignonuiData *data,
+ const gchar *id);
+const gchar*
+gsignond_signonui_data_get_test_reply (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_test_reply (GSignondSignonuiData *data,
+ const gchar *reply);
+const gchar*
+gsignond_signonui_data_get_title (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_title (GSignondSignonuiData *data,
+ const gchar* title);
+const gchar*
+gsignond_signonui_data_get_url_response (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_url_response (GSignondSignonuiData *data,
+ const gchar *response);
+const gchar*
+gsignond_signonui_data_get_username (GSignondSignonuiData *data);
+void
+gsignond_signonui_data_set_username (GSignondSignonuiData *data,
+ const gchar *username);
+
+G_END_DECLS
+
+#endif /* __GSIGNOND_SIGNONUI_DATA_H__ */
--- /dev/null
+#ifndef _GSIGNOND_SIGNONUI_H_
+#define _GSIGNOND_SIGNONUI_H_
+
+/**
+ * @GSignondSignonuiError:
+ * @SIGNONUI_ERROR_NONE: No errors
+ * @SIGNONUI_ERROR_GENERAL: Generic error during interaction
+ * @SIGNONUI_ERROR_NO_SIGNONUI: Cannot send request to signon-ui
+ * @SIGNONUI_ERROR_BAD_PARAMETERS:Signon-Ui cannot create dialog based on the given UiSessionData
+ * @SIGNONUI_ERROR_CANCELED: User canceled action. Plugin should not retry automatically after this
+ * @SIGNONUI_ERROR_NOT_AVAILABLE: Requested ui is not available. For example browser cannot be started
+ * @SIGNONUI_ERROR_BAD_URL: Given url was not valid
+ * @SIGNONUI_ERROR_BAD_CAPTCHA: Given captcha image was not valid
+ * @SIGNONUI_ERROR_BAD_CAPTCHA_URL: Given url for capctha loading was not valid
+ * @SIGNONUI_ERROR_REFRESH_FAILED: Refresh failed
+ * @SIGNONUI_ERROR_FORBIDDEN: Showing ui forbidden by ui policy
+ * @SIGNONUI_ERROR_FORGOT_PASSWORD: User pressed forgot password
+ */
+typedef enum {
+ SIGNONUI_ERROR_NONE = 0,
+ SIGNONUI_ERROR_GENERAL,
+ SIGNONUI_ERROR_NO_SIGNONUI,
+ SIGNONUI_ERROR_BAD_PARAMETERS,
+ SIGNONUI_ERROR_CANCELED,
+ SIGNONUI_ERROR_NOT_AVAILABLE,
+ SIGNONUI_ERROR_BAD_URL,
+ SIGNONUI_ERROR_BAD_CAPTCHA,
+ SIGNONUI_ERROR_BAD_CAPTCHA_URL,
+ SIGNONUI_ERROR_REFRESH_FAILED,
+ SIGNONUI_ERROR_FORBIDDEN,
+ SIGNONUI_ERROR_FORGOT_PASSWORD
+} GSignondSignonuiError;
+
+#endif //_GSIGNOND_SIGNONUI_H_
gsignond-plugin-interface.c \
gsignond-dictionary.c \
gsignond-session-data.c \
+ gsignond-signonui-data.c \
gsignond-plugin-loader.c \
$(BUILT_SOURCES) \
$(NULL)
signals[USER_ACTION_REQUIRED] = g_signal_new ("user-action-required",
G_TYPE_FROM_CLASS (g_class),
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE,
- 1, GSIGNOND_TYPE_SESSION_DATA);
+ 1, GSIGNOND_TYPE_SIGNONUI_DATA);
signals[REFRESHED] = g_signal_new ("refreshed", G_TYPE_FROM_CLASS (g_class),
G_SIGNAL_RUN_FIRST, 0, NULL, NULL, NULL, G_TYPE_NONE,
- 1, GSIGNOND_TYPE_SESSION_DATA);
+ 1, GSIGNOND_TYPE_SIGNONUI_DATA);
signals[STATUS_CHANGED] = g_signal_new ("status-changed",
G_TYPE_FROM_CLASS (g_class),
}
void gsignond_plugin_user_action_finished (GSignondPlugin *self,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
g_return_if_fail (GSIGNOND_IS_PLUGIN (self));
GSIGNOND_PLUGIN_GET_INTERFACE (self)->user_action_finished (self,
- session_data);
+ ui_data);
}
void gsignond_plugin_refresh (GSignondPlugin *self,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
g_return_if_fail (GSIGNOND_IS_PLUGIN (self));
- GSIGNOND_PLUGIN_GET_INTERFACE (self)->refresh (self, session_data);
+ GSIGNOND_PLUGIN_GET_INTERFACE (self)->refresh (self, ui_data);
}
void gsignond_plugin_response (GSignondPlugin *self,
}
void gsignond_plugin_user_action_required (GSignondPlugin *self,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
- g_signal_emit (self, signals[USER_ACTION_REQUIRED], 0, session_data);
+ g_signal_emit (self, signals[USER_ACTION_REQUIRED], 0, ui_data);
}
void gsignond_plugin_refreshed (GSignondPlugin *self,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
- g_signal_emit (self, signals[REFRESHED], 0, session_data);
+ g_signal_emit (self, signals[REFRESHED], 0, ui_data);
}
void gsignond_plugin_status_changed (GSignondPlugin *self, GSignondPluginState state,
--- /dev/null
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2013 Intel Corporation.
+ *
+ * Contact: Amarnath Valluri<amarnath.valluri@linux.intel.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <gsignond/gsignond-signonui-data.h>
+
+#define SIGNONUI_KEY_CAPTCHA_RESPONSE "CaptchaResponse"
+#define SIGNONUI_KEY_CAPTCHA_URL "CaptchaUrl"
+#define SIGNONUI_KEY_CAPTION "Caption"
+#define SIGNONUI_KEY_CONFIRM "Confirm"
+#define SIGNONUI_KEY_FINAL_URL "FinalUrl"
+#define SIGNONUI_KEY_FORGOT_PASSWORD "ForgotPassword"
+#define SIGNONUI_KEY_FORGOT_PASSWORD_URL "ForgotPasswordUrl"
+#define SIGNONUI_KEY_MESSAGE "Message"
+#define SIGNONUI_KEY_OPEN_URL "OpenUrl"
+#define SIGNONUI_KEY_PASSWORD "Secret"
+#define SIGNONUI_KEY_QUERY_ERROR_CODE "QueryErrorCode"
+#define SIGNONUI_KEY_QUERY_PASSWORD "QueryPassword"
+#define SIGNONUI_KEY_QUERY_USERNAME "QueryUserName"
+#define SIGNONUI_KEY_REMEMBER_PASSWORD "RememberPassword"
+#define SIGNONUI_KEY_REQUEST_ID "RequestId"
+#define SIGNONUI_KEY_TEST_REPLY_VALUES "TestReplyValues"
+#define SIGNONUI_KEY_TITLE "Title"
+#define SIGNONUI_KEY_URL_RESPONSE "UrlResponse"
+#define SIGNONUI_KEY_USERNAME "UserName"
+
+#define _GET_STRING(data,key) \
+{ \
+ GVariant* variant = gsignond_dictionary_get(data, key);\
+ return variant ? g_variant_get_string(variant, NULL) : NULL; \
+}
+
+#define _SET_STRING(data,key,value) \
+ if(value) gsignond_dictionary_set(data, key, g_variant_new_string(value))
+
+#define _GET_BOOLEAN(data,key) \
+{\
+ GVariant* variant = gsignond_dictionary_get(data, key);\
+ return variant ? g_variant_get_boolean(variant) : FALSE;\
+}
+
+#define _SET_BOOLEAN(data,key,value) \
+ gsignond_dictionary_set(data, key, g_variant_new_boolean(value))
+
+#define _GET_INT32(data, key) \
+{\
+ GVariant* variant = gsignond_dictionary_get(data, key);\
+ return variant ? g_variant_get_int32(variant) : 0; \
+}
+
+#define _SET_INT32(data,key,value)\
+ gsignond_dictionary_set(data, key, g_variant_new_int32(value));
+
+const gchar*
+gsignond_signonui_data_get_captcha_response (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_CAPTCHA_RESPONSE);
+}
+
+void
+gsignond_signonui_data_set_captcha_response (GSignondSignonuiData *data,
+ const gchar *response)
+{
+ _SET_STRING(data, SIGNONUI_KEY_CAPTCHA_RESPONSE, response);
+}
+
+const gchar*
+gsignond_signonui_data_get_captcha_url (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_CAPTCHA_URL);
+}
+
+void
+gsignond_signonui_data_set_captcha_url (GSignondSignonuiData *data,
+ const gchar *url)
+{
+ _SET_STRING(data, SIGNONUI_KEY_CAPTCHA_URL, url);
+}
+
+const gchar*
+gsignond_signonui_data_get_caption (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_CAPTION);
+}
+
+void
+gsignond_signonui_data_set_caption (GSignondSignonuiData *data,
+ const gchar *caption)
+{
+ _SET_STRING(data, SIGNONUI_KEY_CAPTION, caption);
+}
+
+gboolean
+gsignond_signonui_data_get_confirm (GSignondSignonuiData *data)
+{
+ _GET_BOOLEAN(data, SIGNONUI_KEY_CONFIRM);
+}
+
+void
+gsignond_signonui_data_set_confirm (GSignondSignonuiData *data,
+ gboolean confirm)
+{
+ _SET_BOOLEAN(data, SIGNONUI_KEY_CONFIRM, confirm);
+}
+
+const gchar*
+gsignond_signonui_data_get_final_url (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_FINAL_URL);
+}
+
+void
+gsignond_signonui_data_set_final_url (GSignondSignonuiData *data,
+ const gchar *url)
+{
+ _SET_STRING(data, SIGNONUI_KEY_FINAL_URL, url);
+}
+
+gboolean
+gsignond_signonui_data_get_forgot_password (GSignondSignonuiData *data)
+{
+ _GET_BOOLEAN(data, SIGNONUI_KEY_FORGOT_PASSWORD);
+}
+
+void
+gsignond_signonui_data_set_forgot_password (GSignondSignonuiData *data,
+ gboolean forgot)
+{
+ _SET_BOOLEAN(data, SIGNONUI_KEY_FORGOT_PASSWORD, forgot);
+}
+
+const gchar*
+gsignond_signonui_data_get_forgot_password_url (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_FORGOT_PASSWORD_URL);
+}
+
+void
+gsignond_signonui_data_set_forgot_password_url (GSignondSignonuiData *data,
+ const gchar *url)
+{
+ _SET_STRING(data, SIGNONUI_KEY_FORGOT_PASSWORD_URL, url);
+}
+
+const gchar*
+gsignond_signonui_data_get_message (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_MESSAGE);
+}
+
+void
+gsignond_signonui_data_set_message (GSignondSignonuiData *data,
+ const gchar *message)
+{
+ _SET_STRING(data, SIGNONUI_KEY_MESSAGE, message);
+}
+
+const gchar*
+gsignond_signonui_data_get_open_url (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_OPEN_URL);
+}
+
+void
+gsignond_signonui_data_set_open_url (GSignondSignonuiData *data,
+ const gchar *url)
+{
+ _SET_STRING(data, SIGNONUI_KEY_OPEN_URL, url);
+}
+
+const gchar*
+gsignond_signonui_data_get_password (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_PASSWORD);
+}
+
+void
+gsignond_signonui_data_set_password (GSignondSignonuiData *data,
+ const gchar *password)
+{
+ _SET_STRING(data, SIGNONUI_KEY_PASSWORD, password);
+}
+
+GSignondSignonuiError
+gsignond_signonui_data_get_query_error (GSignondSignonuiData *data)
+{
+ _GET_INT32(data, SIGNONUI_KEY_QUERY_ERROR_CODE);
+}
+
+void
+gsignond_signonui_data_set_query_error (GSignondSignonuiData *data,
+ GSignondSignonuiError error)
+{
+ _SET_INT32(data, SIGNONUI_KEY_QUERY_ERROR_CODE, error);
+}
+
+gboolean
+gsignond_signonui_data_get_query_password (GSignondSignonuiData *data)
+{
+ _GET_BOOLEAN(data, SIGNONUI_KEY_QUERY_PASSWORD);
+}
+
+void
+gsignond_signonui_data_set_query_password (GSignondSignonuiData *data,
+ gboolean query)
+{
+ _SET_BOOLEAN(data, SIGNONUI_KEY_QUERY_PASSWORD, query);
+}
+
+gboolean
+gsignond_signonui_data_get_query_username (GSignondSignonuiData *data)
+{
+ _GET_BOOLEAN(data, SIGNONUI_KEY_QUERY_USERNAME);
+}
+
+void
+gsignond_signonui_data_set_query_username (GSignondSignonuiData *data,
+ gboolean query)
+{
+ _SET_BOOLEAN(data, SIGNONUI_KEY_QUERY_USERNAME, query);
+}
+
+gboolean
+gsignond_signonui_data_get_remember_password (GSignondSignonuiData *data)
+{
+ _GET_BOOLEAN(data, SIGNONUI_KEY_REMEMBER_PASSWORD);
+}
+
+void
+gsignond_signonui_data_set_remember_password (GSignondSignonuiData *data,
+ gboolean remember)
+{
+ _SET_BOOLEAN(data, SIGNONUI_KEY_REMEMBER_PASSWORD, remember);
+}
+
+const gchar*
+gsignond_signonui_data_get_request_id (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_REQUEST_ID);
+}
+
+void
+gsignond_signonui_data_set_request_id (GSignondSignonuiData *data,
+ const gchar *id)
+{
+ _SET_STRING(data, SIGNONUI_KEY_REQUEST_ID, id);
+}
+
+const gchar*
+gsignond_signonui_data_get_test_reply (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_TEST_REPLY_VALUES);
+}
+
+void
+gsignond_signonui_data_set_test_reply (GSignondSignonuiData *data,
+ const gchar *reply)
+{
+ _SET_STRING(data, SIGNONUI_KEY_TEST_REPLY_VALUES, reply);
+}
+
+const gchar*
+gsignond_signonui_data_get_title (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_TITLE);
+}
+
+void
+gsignond_signonui_data_set_title (GSignondSignonuiData *data,
+ const gchar* title)
+{
+ _SET_STRING(data, SIGNONUI_KEY_TITLE, title);
+}
+
+const gchar*
+gsignond_signonui_data_get_url_response (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_URL_RESPONSE);
+}
+
+void
+gsignond_signonui_data_set_url_response (GSignondSignonuiData *data,
+ const gchar *response)
+{
+ _SET_STRING(data, SIGNONUI_KEY_URL_RESPONSE, response);
+}
+
+const gchar*
+gsignond_signonui_data_get_username (GSignondSignonuiData *data)
+{
+ _GET_STRING(data, SIGNONUI_KEY_USERNAME);
+}
+
+void
+gsignond_signonui_data_set_username (GSignondSignonuiData *data,
+ const gchar *username)
+{
+ _SET_STRING(data, SIGNONUI_KEY_USERNAME, username);
+}
+
gsignond-identity.h \
gsignond-disposable.c \
gsignond-disposable.h \
+ gsignond-signonui-proxy.c \
+ gsignond-signonui-proxy.h \
$(BUILT_SOURCES) \
$(NULL)
gsignond-dbus-auth-session-gen.h \
gsignond-dbus-identity-gen.c \
gsignond-dbus-identity-gen.h \
+ gsignond-dbus-signonui-gen.c \
+ gsignond-dbus-signonui-gen.h \
$(NULL)
DBUS_BUILT_DOCS = \
gsignond-dbus-auth-service-doc-gen-com.google.code.AccountsSSO.gSingleSignOn.AuthService.xml \
gsignond-dbus-auth-session-doc-gen-com.google.code.AccountsSSO.gSingleSignOn.AuthSession.xml \
gsignond-dbus-identity-doc-gen-com.google.code.AccountsSSO.gSingleSignOn.Identity.xml \
+ gsignond-dbus-signonui-doc-gen-org.tizen.SSO.singlesignonui.xml \
$(NULL)
DBUS_INTERFACE_PREFIX="com.google.code.AccountsSSO.gSingleSignOn."
--generate-docbook gsignond-dbus-identity-doc-gen \
$<
+gsignond-dbus-signonui-gen.c gsignond-dbus-signonui-gen.h : $(INTERFACES_DIR)/org.tizen.SSO.singlesignonui.xml
+ gdbus-codegen \
+ --interface-prefix org.tizen.SSO \
+ --c-namespace GSignondDbus \
+ --generate-c-code gsignond-dbus-signonui-gen \
+ --generate-docbook gsignond-dbus-signonui-doc-gen\
+ $<
+
lib_LTLIBRARIES = libgsignond-dbus-glue.la
libgsignond_dbus_glue_la_CPPFLAGS = \
gsignond-dbus-auth-session-adapter.h \
gsignond-dbus-identity-adapter.c \
gsignond-dbus-identity-adapter.h \
+ gsignond-dbus-signonui-adapter.c \
+ gsignond-dbus-signonui-adapter.h \
$(NULL)
dbusservicedir = $(DBUS_SERVICES_DIR)
-dbusservice_DATA = $(SERVCIES_DIR)/com.google.code.AccountsSSO.gSingleSignOn.service
+dbusservice_DATA = \
+ $(SERVCIES_DIR)/com.google.code.AccountsSSO.gSingleSignOn.service
dbusinterfacesdir = $(DBUS_INTERFACES_DIR)
dbusinterfaces_DATA = \
$(INTERFACES_DIR)/com.google.code.AccountsSSO.gSingleSignOn.AuthService.xml \
$(INTERFACES_DIR)/com.google.code.AccountsSSO.gSingleSignOn.AuthSession.xml \
- $(INTERFACES_DIR)/com.google.code.AccountsSSO.gSingleSignOn.Identity.xml
+ $(INTERFACES_DIR)/com.google.code.AccountsSSO.gSingleSignOn.Identity.xml \
+ $(INTERFACES_DIR)/org.tizen.SSO.singlesignonui.xml
EXTRA_DIST = dbusservice
--- /dev/null
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2013 Intel Corporation.
+ *
+ * Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "gsignond-dbus-signonui-adapter.h"
+#include "gsignond/gsignond-log.h"
+#include "gsignond-dbus.h"
+
+struct _GSignondDbusSignonuiAdapterPrivate
+{
+ GDBusConnection *connection;
+ GSignondDbusSinglesignonui *proxy;
+};
+
+G_DEFINE_TYPE (GSignondDbusSignonuiAdapter, gsignond_dbus_signonui_adapter, G_TYPE_OBJECT)
+
+enum {
+ SIG_REFRESH,
+ SIG_MAX
+};
+
+static guint _signals[SIG_MAX];
+
+#define GSIGNOND_DBUS_SIGNONUI_ADAPTER_GET_PRIV(obj) \
+ G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSIGNOND_TYPE_DBUS_SIGNONUI_ADAPTER, GSignondDbusSignonuiAdapterPrivate)
+
+typedef struct
+{
+ GSignondDbusSignonuiAdapter *adapter;
+ gpointer cb;
+ gpointer data;
+} _SignonuiDbusInfo;
+
+static void
+_dispose (GObject *object)
+{
+ GSignondDbusSignonuiAdapter *self = GSIGNOND_DBUS_SIGNONUI_ADAPTER (object);
+
+ if (self->priv->connection) {
+ g_object_unref (self->priv->connection);
+ self->priv->connection = NULL;
+ }
+
+ if (self->priv->proxy) {
+ g_object_unref (self->priv->proxy);
+ self->priv->proxy = NULL;
+ }
+
+ G_OBJECT_CLASS (gsignond_dbus_signonui_adapter_parent_class)->dispose (object);
+}
+
+static void
+_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (gsignond_dbus_signonui_adapter_parent_class)->finalize (object);
+}
+
+static void
+gsignond_dbus_signonui_adapter_class_init (GSignondDbusSignonuiAdapterClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof (GSignondDbusSignonuiAdapterPrivate));
+
+ object_class->dispose = _dispose;
+ object_class->finalize = _finalize;
+
+ _signals[SIG_REFRESH] = g_signal_new ("refresh",
+ GSIGNOND_TYPE_DBUS_SIGNONUI_ADAPTER,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ G_TYPE_NONE,
+ 1, G_TYPE_STRING);
+}
+
+static void
+gsignond_dbus_signonui_adapter_init (GSignondDbusSignonuiAdapter *self)
+{
+ self->priv = GSIGNOND_DBUS_SIGNONUI_ADAPTER_GET_PRIV(self);
+
+ self->priv->connection = 0;
+ self->priv->proxy = 0;
+}
+
+static void
+_on_query_dialog_ready (GObject *proxy, GAsyncResult *res, gpointer user_data)
+{
+ GError *error = NULL;
+ GVariant *out_params = NULL;
+ _SignonuiDbusInfo *info = (_SignonuiDbusInfo *)user_data;
+
+ gsignond_dbus_singlesignonui_call_query_dialog_finish (
+ GSIGNOND_DBUS_SINGLESIGNONUI (proxy), &out_params, res, &error);
+
+ if (!info) {
+ ERR ("Memory curropted");
+ return;
+ }
+
+ if (info->cb) {
+ ((GSignondDbusSignonuiQueryDialogCb)info->cb) (out_params, error, info->data);
+ g_object_unref (info->adapter);
+ g_free (info);
+ }
+ else {
+ if (error) g_error_free (error);
+ if (out_params) g_variant_unref (out_params);
+ }
+}
+
+gboolean
+gsignond_dbus_signonui_adapter_query_dialog (GSignondDbusSignonuiAdapter *adapter,
+ GVariant *params,
+ const GSignondDbusSignonuiQueryDialogCb callback,
+ gpointer user_data)
+{
+ if (!adapter || !GSIGNOND_IS_DBUS_SIGNONUI_ADAPTER (adapter)) {
+ WARN ("assert (!adapter ||!GSIGNOND_IS_DBUS_SIGNONUI_ADAPTER (adapter)) failed");
+ return FALSE;
+ }
+ _SignonuiDbusInfo *info = g_new0 (_SignonuiDbusInfo, 1);
+
+ info->adapter = g_object_ref (adapter);
+ info->cb = callback;
+ info->data = user_data;
+ gsignond_dbus_singlesignonui_call_query_dialog (adapter->priv->proxy, params, NULL,
+ _on_query_dialog_ready, (gpointer)info);
+
+ return TRUE;
+}
+
+static void
+_on_refresh_dialog_ready (GObject *proxy, GAsyncResult *res, gpointer user_data)
+{
+ GError *error = NULL;
+ _SignonuiDbusInfo *info = (_SignonuiDbusInfo *)user_data;
+
+ gsignond_dbus_singlesignonui_call_refresh_dialog_finish (
+ GSIGNOND_DBUS_SINGLESIGNONUI (proxy), res, &error);
+
+ if (!info) {
+ ERR ("Memory curropted");
+ g_error_free (error);
+ return;
+ }
+
+ if (info->cb) {
+ ((GSignondDbusSignonuiRefreshDialogCb)info->cb) (error, info->data);
+ g_object_unref (info->adapter);
+ g_free (info);
+ }
+ else if (error) g_error_free (error);
+}
+
+gboolean
+gsignond_dbus_signonui_adapter_refresh_dialog (GSignondDbusSignonuiAdapter *adapter,
+ GVariant *params,
+ const GSignondDbusSignonuiRefreshDialogCb callback,
+ gpointer user_data)
+{
+ if (!adapter || !GSIGNOND_IS_DBUS_SIGNONUI_ADAPTER (adapter)) {
+ WARN ("assert (!adapter ||!GSIGNOND_IS_DBUS_SIGNONUI_ADAPTER (adapter)) failed");
+ return FALSE;
+ }
+ _SignonuiDbusInfo *info = g_new0 (_SignonuiDbusInfo, 1);
+
+ info->adapter = g_object_ref (adapter);
+ info->cb = callback;
+ info->data = user_data;
+ gsignond_dbus_singlesignonui_call_refresh_dialog (adapter->priv->proxy, params, NULL,
+ _on_refresh_dialog_ready, (gpointer)info);
+
+ return TRUE;
+}
+
+static void
+_on_cancel_request_ready (GObject *proxy, GAsyncResult *res, gpointer user_data)
+{
+ GError *error = NULL;
+ _SignonuiDbusInfo *info = (_SignonuiDbusInfo *)user_data;
+
+ gsignond_dbus_singlesignonui_call_cancel_ui_request_finish (
+ GSIGNOND_DBUS_SINGLESIGNONUI (proxy), res, &error);
+
+ if (!info) {
+ ERR ("Memory curropted");
+ g_error_free (error);
+ return;
+ }
+
+ if (info->cb) {
+ ((GSignondDbusSignonuiCancelRequestCb)info->cb) (error, info->data);
+ g_object_unref (info->adapter);
+ g_free (info);
+ }
+ else if (error) g_error_free (error);
+}
+
+gboolean
+gsignond_dbus_signonui_adapter_cancel_request (GSignondDbusSignonuiAdapter *adapter,
+ const gchar *request_id,
+ const GSignondDbusSignonuiCancelRequestCb callback,
+ gpointer user_data)
+{
+ if (!adapter || !GSIGNOND_IS_DBUS_SIGNONUI_ADAPTER (adapter)) {
+ WARN ("assert (!adapter ||!GSIGNOND_IS_DBUS_SIGNONUI_ADAPTER (adapter)) failed");
+ return FALSE;
+ }
+ _SignonuiDbusInfo *info = g_new0 (_SignonuiDbusInfo, 1);
+
+ info->adapter = g_object_ref (adapter);
+ info->cb = callback;
+ info->data = user_data;
+ gsignond_dbus_singlesignonui_call_cancel_ui_request (adapter->priv->proxy, request_id, NULL,
+ _on_cancel_request_ready, (gpointer)info);
+
+ return TRUE;
+}
+
+static void
+_on_refresh_request (GSignondDbusSignonuiAdapter *proxy, gchar *request_id, gpointer userdata)
+{
+ GSignondDbusSignonuiAdapter *adapter = GSIGNOND_DBUS_SIGNONUI_ADAPTER (userdata);
+
+ if (!adapter) {
+ ERR ("DBus-Error: memroy curroption");
+ return;
+ }
+
+ g_signal_emit (adapter, _signals[SIG_REFRESH], 0, request_id);
+}
+
+/**
+ * gsignond_dbus_signonui_adapter_new:
+ *
+ * Creates new instance of #GSignondDbusSignonuiAdapter
+ *
+ * Retrurns: (transfer full) new instance of #GSignondDbusSignonuiAdapter
+ */
+GSignondDbusSignonuiAdapter *
+gsignond_dbus_signonui_adapter_new ()
+{
+ GError *err = NULL;
+ GSignondDbusSignonuiAdapter *adapter = GSIGNOND_DBUS_SIGNONUI_ADAPTER (
+ g_object_new (GSIGNOND_TYPE_DBUS_SIGNONUI_ADAPTER, NULL));
+
+ adapter->priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &err);
+ if (err) {
+ ERR ("Error getting session bus :%s", err->message);
+ goto fail;
+ }
+
+ adapter->priv->proxy = gsignond_dbus_singlesignonui_proxy_new_sync (adapter->priv->connection,
+ G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES,
+ SIGNONUI_SERVICE,
+ SIGNONUI_OBJECTPATH,
+ NULL,
+ &err);
+ if (err) {
+ WARN ("failed to get ui object : %s", err->message);
+ goto fail;
+ }
+
+ g_signal_connect (adapter->priv->proxy, "refresh", G_CALLBACK (_on_refresh_request), adapter);
+
+ return adapter;
+
+fail:
+ if (err) g_error_free (err);
+ g_object_unref (adapter);
+ return NULL;
+}
+
--- /dev/null
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2013 Intel Corporation.
+ *
+ * Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_SIGNONUI_ADAPTER_H_
+#define __GSIGNOND_SIGNONUI_ADAPTER_H_
+
+#include <glib.h>
+#include <gio/gio.h>
+#include "gsignond-dbus-signonui-gen.h"
+
+G_BEGIN_DECLS
+
+#define GSIGNOND_TYPE_DBUS_SIGNONUI_ADAPTER (gsignond_dbus_signonui_adapter_get_type())
+#define GSIGNOND_DBUS_SIGNONUI_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GSIGNOND_TYPE_DBUS_SIGNONUI_ADAPTER, GSignondDbusSignonuiAdapter))
+#define GSIGNOND_DBUS_SIGNONUI_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GSIGNOND_TYPE_DBUS_SIGNONUI_ADAPTER, GSignondDbusSignonuiAdapterClass))
+#define GSIGNOND_IS_DBUS_SIGNONUI_ADAPTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GSIGNOND_TYPE_DBUS_SIGNONUI_ADAPTER))
+#define GSIGNOND_IS_DBUS_SIGNONUI_ADAPTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GSIGNOND_TYPE_DBUS_SIGNONUI_ADAPTER))
+#define GSIGNOND_DBUS_SIGNONUI_ADAPTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSIGNOND_TYPE_DBUS_SIGNONUI_ADAPTER, GSignondDbusSignonuiAdapterClass))
+
+typedef struct _GSignondDbusSignonuiAdapter GSignondDbusSignonuiAdapter;
+typedef struct _GSignondDbusSignonuiAdapterClass GSignondDbusSignonuiAdapterClass;
+typedef struct _GSignondDbusSignonuiAdapterPrivate GSignondDbusSignonuiAdapterPrivate;
+
+typedef void (*GSignondDbusSignonuiQueryDialogCb)(GVariant *out_params, GError *error, gpointer user_data);
+typedef void (*GSignondDbusSignonuiRefreshDialogCb)(GError *error, gpointer user_data);
+typedef void (*GSignondDbusSignonuiCancelRequestCb)(GError *error, gpointer user_data);
+
+struct _GSignondDbusSignonuiAdapter
+{
+ GObject parent;
+
+ /* priv */
+ GSignondDbusSignonuiAdapterPrivate *priv;
+};
+
+struct _GSignondDbusSignonuiAdapterClass
+{
+ GObjectClass parent_class;
+};
+
+GType gsignond_dbus_signonui_adapter_get_type (void) G_GNUC_CONST;
+
+GSignondDbusSignonuiAdapter * gsignond_dbus_signonui_adapter_new ();
+
+gboolean
+gsignond_dbus_signonui_adapter_query_dialog (GSignondDbusSignonuiAdapter *adapter,
+ GVariant *params,
+ const GSignondDbusSignonuiQueryDialogCb callback,
+ gpointer user_data);
+
+gboolean
+gsignond_dbus_signonui_adapter_refresh_dialog (GSignondDbusSignonuiAdapter *adapter,
+ GVariant *params,
+ const GSignondDbusSignonuiRefreshDialogCb callback,
+ gpointer user_data);
+
+gboolean
+gsignond_dbus_signonui_adapter_cancel_request (GSignondDbusSignonuiAdapter *adapter,
+ const gchar *request_id,
+ const GSignondDbusSignonuiCancelRequestCb callback,
+ gpointer user_data);
+
+G_END_DECLS
+
+#endif /* __GSIGNOND_SIGNONUI_ADAPTER_H_ */
+
#define GSIGNOND_IDENTITY_INTERFACE GSIGNOND_SERVICE_PREFIX ".Identity"
#define GSIGNOND_AUTH_SESSION_INTERFACE GSIGNOND_SERVICE_PREFIX ".AuthSession"
+#define SIGNONUI_SERVICE "org.tizen.SSO"
+#define SIGNONUI_OBJECTPATH "/org/tizen/SSO/SignonUi"
+#define SIGNONUI_INTERFACE "org.tizen.SSO.singlesignonui"
+
#endif /* __GSIGNOND_DBUS_H_ */
--- /dev/null
+<node>
+ <interface name="org.tizen.SSO.singlesignonui">
+
+ <method name="queryDialog">
+ <arg direction="in" type="a{sv}" name="parameters"/>
+ <arg direction="out" type="a{sv}" name="return_value"/>
+ </method>
+
+ <method name="refreshDialog">
+ <arg direction="in" type="a{sv}" name="parameters"/>
+ </method>
+
+ <method name="cancelUiRequest">
+ <arg direction="in" type="s" name="request_id"/>
+ </method>
+
+ <!-- user selected 'refresh', regenerate captcha image/url -->
+ <signal name="refresh">
+ <arg type="s" name="request_id"/>
+ </signal>
+
+ </interface>
+</node>
+
NULL,
G_TYPE_NONE,
1,
- GSIGNOND_TYPE_SESSION_DATA);
+ GSIGNOND_TYPE_SIGNONUI_DATA);
signals[SIG_PROCESS_REFRESHED] = g_signal_new (
"process-refreshed",
NULL,
G_TYPE_NONE,
1,
- GSIGNOND_TYPE_SESSION_DATA);
+ GSIGNOND_TYPE_SIGNONUI_DATA);
signals[SIG_PROCESS_STATE_CHANGED] = g_signal_new (
"state-changed",
void
gsignond_auth_session_iface_user_action_finished (GSignondAuthSessionIface *self,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
return GSIGNOND_AUTH_SESSION_GET_INTERFACE (self)->
- user_action_finished (self, session_data);
+ user_action_finished (self, ui_data);
}
void
gsignond_auth_session_iface_refresh (GSignondAuthSessionIface *self,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
- return GSIGNOND_AUTH_SESSION_GET_INTERFACE (self)->
- refresh (self, session_data);
+ GSIGNOND_AUTH_SESSION_GET_INTERFACE (self)->
+ refresh (self, ui_data);
}
void
void
gsignond_auth_session_iface_notify_user_action_required (GSignondAuthSessionIface *self,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
- g_signal_emit (self, signals[SIG_PROCESS_USER_ACTION_REQUIRED], 0,
- session_data);
+ g_signal_emit (self, signals[SIG_PROCESS_USER_ACTION_REQUIRED], 0, ui_data);
}
void
gsignond_auth_session_iface_notify_refreshed (GSignondAuthSessionIface *self,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
- g_signal_emit (self, signals[SIG_PROCESS_REFRESHED], 0, session_data);
+ g_signal_emit (self, signals[SIG_PROCESS_REFRESHED], 0, ui_data);
}
void
#include <glib.h>
#include <glib-object.h>
#include <gsignond/gsignond-session-data.h>
+#include <gsignond/gsignond-signonui-data.h>
#include <gsignond/gsignond-access-control-manager.h>
#include <gsignond/gsignond-security-context.h>
GSignondAccessControlManager * (*get_acm) (GSignondAuthSessionIface *session);
void (*user_action_finished) (GSignondAuthSessionIface *session,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
void (*refresh) (GSignondAuthSessionIface *session,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
};
GError **error);
void
gsignond_auth_session_iface_user_action_finished (GSignondAuthSessionIface *self,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
void
gsignond_auth_session_iface_refresh (GSignondAuthSessionIface *self,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
/* handlers */
GSignondSessionData *session_data);
void
gsignond_auth_session_iface_notify_user_action_required (GSignondAuthSessionIface *self,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
void
gsignond_auth_session_iface_notify_refreshed (GSignondAuthSessionIface *self,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
void
gsignond_auth_session_iface_notify_state_changed (GSignondAuthSessionIface *self,
gint state,
void
_user_action_finished (GSignondAuthSessionIface *iface,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
GSignondAuthSession *self = GSIGNOND_AUTH_SESSION (iface);
- gsignond_plugin_proxy_user_action_finished(self->priv->proxy, session_data);
+ gsignond_plugin_proxy_user_action_finished(self->priv->proxy, ui_data);
}
void
_refresh (GSignondAuthSessionIface *iface,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
GSignondAuthSession *self = GSIGNOND_AUTH_SESSION (iface);
- gsignond_plugin_proxy_refresh(self->priv->proxy, session_data);
+ gsignond_plugin_proxy_refresh(self->priv->proxy, ui_data);
}
GSignondAccessControlManager *
GSignondAccessControlManager *acm;
GSignondDbusAuthServiceAdapter *auth_service;
GSignondPluginProxyFactory *plugin_proxy_factory;
+ GSignondSignonuiProxy *ui;
};
static void gsignond_daemon_auth_service_iface_init (gpointer g_iface,
g_list_foreach (self->priv->identities, _free_identity, NULL);
}
+ if (self->priv->ui) {
+ g_object_unref (self->priv->ui);
+ self->priv->ui = NULL;
+ }
+
G_OBJECT_CLASS (gsignond_daemon_parent_class)->dispose (object);
}
self->priv->auth_service =
gsignond_dbus_auth_service_adapter_new (
GSIGNOND_AUTH_SERVICE_IFACE (self));
+
+ self->priv->ui = gsignond_signonui_proxy_new ();
}
static void
return self->priv->config;
}
+gboolean
+gsignond_daemon_show_dialog (GSignondDaemon *self,
+ GObject *caller,
+ GSignondSignonuiData *ui_data,
+ GSignondSignonuiProxyQueryDialogCb handler,
+ GSignondSignonuiProxyRefreshCb refresh_handler,
+ gpointer userdata)
+{
+ g_return_val_if_fail (self && GSIGNOND_IS_DAEMON(self), FALSE);
+
+ return gsignond_signonui_proxy_query_dialog (self->priv->ui, caller, ui_data, handler, refresh_handler, userdata);
+}
+
+gboolean
+gsignond_daemon_refresh_dialog (GSignondDaemon *self,
+ GObject *caller,
+ GSignondSignonuiData *ui_data,
+ GSignondSignonuiProxyRefreshDialogCb handler,
+ gpointer userdata)
+{
+ g_return_val_if_fail (self && GSIGNOND_IS_DAEMON(self), FALSE);
+
+ return gsignond_signonui_proxy_refresh_dialog (self->priv->ui, caller, ui_data, handler, userdata);
+}
+
+gboolean
+gsignond_daemon_cancel_dialog (GSignondDaemon *self,
+ GObject *caller,
+ GSignondSignonuiProxyCancelRequestCb handler,
+ gpointer userdata)
+{
+ g_return_val_if_fail (self && GSIGNOND_IS_DAEMON(self), FALSE);
+
+ return gsignond_signonui_proxy_cancel_request (self->priv->ui, caller, handler, userdata);
+}
+
GSignondAccessControlManager *
gsignond_get_access_control_manager ()
{
#include <gsignond/gsignond-access-control-manager.h>
#include "gsignond-disposable.h"
#include "plugins/gsignond-plugin-proxy-factory.h"
+#include "gsignond-signonui-proxy.h"
G_BEGIN_DECLS
GSignondConfig *
gsignond_daemon_get_config (GSignondDaemon *self);
+gboolean
+gsignond_daemon_show_dialog (GSignondDaemon *self,
+ GObject *caller,
+ GSignondSignonuiData *ui_data,
+ GSignondSignonuiProxyQueryDialogCb handler,
+ GSignondSignonuiProxyRefreshCb refresh_handler,
+ gpointer userdata);
+
+gboolean
+gsignond_daemon_refresh_dialog (GSignondDaemon *self,
+ GObject *caller,
+ GSignondSignonuiData *ui_data,
+ GSignondSignonuiProxyRefreshDialogCb handler,
+ gpointer userdata);
+
+gboolean
+gsignond_daemon_cancel_dialog (GSignondDaemon *self,
+ GObject *caller,
+ GSignondSignonuiProxyCancelRequestCb handler,
+ gpointer userdata);
+
GSignondAccessControlManager *
gsignond_get_access_control_manager ();
}
static gboolean
-_dummy_verify_user (GSignondIdentityIface *self, const GVariant *params, const GSignondSecurityContext *ctx, GError **error)
+_dummy_verify_user (GSignondIdentityIface *self, GVariant *params, const GSignondSecurityContext *ctx, GError **error)
{
(void) self;
(void) params;
NULL,
NULL,
G_TYPE_NONE,
- 1,
+ 2,
+ G_TYPE_BOOLEAN,
G_TYPE_ERROR);
signals[SIG_SECRET_VERIFIED] = g_signal_new ("secret-verified",
NULL,
NULL,
G_TYPE_NONE,
- 1,
+ 2,
+ G_TYPE_BOOLEAN,
G_TYPE_ERROR);
signals[SIG_CREDENTIALS_UPDATED] = g_signal_new ("credentials-updated",
*/
gboolean
gsignond_identity_iface_verify_user (GSignondIdentityIface *self,
- const GVariant *params,
+ GVariant *params,
const GSignondSecurityContext *ctx,
GError **error)
{
/**
* gsignond_identity_iface_notify_user_verified:
* @self: instance of #GSignondIdentityIface
+ * @result: verification result
* @error: instance of #GError, error if any, that was occured in user verification process, otherwise NULL
*
* Emits "user-verified" signal
*/
void
gsignond_identity_iface_notify_user_verified (GSignondIdentityIface *self,
+ gboolean result,
const GError *error)
{
- g_signal_emit (self, signals[SIG_USER_VERIFIED], 0, error);
+ g_signal_emit (self, signals[SIG_USER_VERIFIED], 0, result, error);
}
/**
* gsignond_identity_iface_notify_secret_verified:
* @self: instance of #GSignondIdentityIface
+ * @result: verfication result
* @error: instance of #GError, error if any, that was occured in secret verification process, otherwise NULL
*
* Emits "secret-verified" signal
*/
void
gsignond_identity_iface_notify_secret_verified (GSignondIdentityIface *self,
+ gboolean result,
const GError *error)
{
- g_signal_emit (self, signals[SIG_SECRET_VERIFIED], 0, error);
+ g_signal_emit (self, signals[SIG_SECRET_VERIFIED], 0, result, error);
}
/**
*
* Returns: @TRUE on success, @FALSE otherwise
*/
- gboolean (*verify_user) (GSignondIdentityIface *identity, const GVariant *params, const GSignondSecurityContext *ctx, GError **error);
+ gboolean (*verify_user) (GSignondIdentityIface *identity, GVariant *params, const GSignondSecurityContext *ctx, GError **error);
/**
* verify_secret:
gboolean
gsignond_identity_iface_verify_user (GSignondIdentityIface *self,
- const GVariant *params,
+ GVariant *params,
const GSignondSecurityContext *ctx,
GError **error);
gsignond_identity_iface_get_acm (GSignondIdentityIface *self);
void
-gsignond_identity_iface_notify_user_verified (GSignondIdentityIface *identity,
+gsignond_identity_iface_notify_user_verified (GSignondIdentityIface *identity,
+ gboolean res,
const GError *error);
void
gsignond_identity_iface_notify_secret_verified (GSignondIdentityIface *identity,
+ gboolean res,
const GError *error);
void
* 02110-1301 USA
*/
+#include "gsignond-identity.h"
+
#include <string.h>
+#include "gsignond-daemon.h"
+#include "gsignond-identity-iface.h"
+#include "gsignond-auth-session.h"
#include "gsignond/gsignond-log.h"
#include "gsignond/gsignond-error.h"
-
-#include "gsignond-identity-iface.h"
+#include "gsignond/gsignond-config-dbus.h"
+#include "gsignond/gsignond-signonui.h"
#include "dbus/gsignond-dbus.h"
#include "dbus/gsignond-dbus-identity-adapter.h"
-#include "gsignond-identity.h"
-#include "gsignond-auth-session.h"
#include "plugins/gsignond-plugin-proxy-factory.h"
-#include "gsignond-daemon.h"
-#include "gsignond/gsignond-config-dbus.h"
enum
{
G_TYPE_NONE);
}
-static gboolean
-_request_credentials_update (GSignondIdentityIface *iface, const gchar *message, const GSignondSecurityContext *ctx, GError **error)
-{
- if (!(iface && GSIGNOND_IS_IDENTITY (iface))) {
- WARN ("assertion (iface && GSIGNOND_IS_IDENTITY(iface)) failed");
- if (error) *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_UNKNOWN, "Unknown error");
- return FALSE;
- }
-
- GSignondIdentity *identity = GSIGNOND_IDENTITY (iface);
-
- if (!(identity && identity->priv->info)) {
- WARN ("assertion (identity && identity->priv->info) failed");
- if (error) *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_IDENTITY_ERR, "Identity not found.");
- return FALSE;
- }
-
- VALIDATE_IDENTITY_READ_ACCESS (identity, ctx, FALSE);
-
- if (!gsignond_identity_info_get_store_secret (identity->priv->info)) {
- if (error) *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_CREDENTIALS_NOT_AVAILABLE, "Password can not be stored.");
- return FALSE;
- }
-
- /*
- * TODO: Call UI to request credentials
- * and when ready, emit signal "store" to save the new credentials info
- * to database(which is handled by Daemon object).
- * On success, call
- * gsignond_identity_iface_notify_credentials_updated(self, id, NULL);
- * otherwise, calls
- * gsignond_identity_iface_notify_credentials_updated(self, 0, error);
- */
-
- /*
- * emit "identity-data-updated"
- */
-
- gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (identity));
-
- return TRUE;
-}
-
static GVariant *
_get_info (GSignondIdentityIface *iface, const GSignondSecurityContext *ctx, GError **error)
{
}
static void
+_on_dialog_refreshed (GError *error, gpointer user_data)
+{
+ GSignondAuthSessionIface *session = GSIGNOND_AUTH_SESSION_IFACE (user_data);
+
+ if (error) {
+ WARN ("Error : %s", error->message);
+ g_error_free (error);
+ }
+
+ if (session) {
+ /*
+ * FIXME: whom to pass the reply ?
+ */
+ }
+}
+
+static void
+_on_refresh_dialog (GSignondAuthSessionIface *session, GSignondSignonuiData *ui_data, gpointer userdata)
+{
+ GSignondIdentity *identity = GSIGNOND_IDENTITY (userdata);
+
+ gsignond_daemon_refresh_dialog (GSIGNOND_DAEMON (identity->priv->owner), G_OBJECT (session),
+ ui_data, _on_dialog_refreshed, (gpointer)session);
+}
+
+static void
+_on_refresh_requested (GSignondSignonuiData *ui_data, gpointer user_data)
+{
+ GSignondAuthSessionIface *session = GSIGNOND_AUTH_SESSION_IFACE (user_data);
+ gsignond_auth_session_iface_refresh (session, ui_data);
+}
+
+static void
+_on_user_action_completed (GSignondSignonuiData *reply, GError *error, gpointer user_data)
+{
+ GSignondAuthSessionIface *session = GSIGNOND_AUTH_SESSION_IFACE (user_data);
+ if (error) {
+ WARN ("UI-Error: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+ if (session) {
+ gsignond_auth_session_iface_user_action_finished (session, reply);
+ }
+ else if (reply) gsignond_signonui_data_unref (reply);
+}
+
+static void
+_on_user_action_required (GSignondAuthSessionIface *session, GSignondSignonuiData *ui_data, gpointer userdata)
+{
+ GSignondIdentity *identity = GSIGNOND_IDENTITY (userdata);
+
+ gsignond_daemon_show_dialog (GSIGNOND_DAEMON (identity->priv->owner), G_OBJECT(session),
+ ui_data, _on_user_action_completed, _on_refresh_requested, session);
+}
+
+static void
_on_session_close (gpointer data, GObject *session)
{
GSignondIdentity *identity = GSIGNOND_IDENTITY (data);
if (error) *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_UNKNOWN, "Unknown error");
return NULL;
}
+ /* Handle 'ui' signanls on session */
+ g_signal_connect (session, "process-user-action-required", G_CALLBACK (_on_user_action_required), identity);
+ g_signal_connect (session, "process-refreshed", G_CALLBACK (_on_refresh_dialog), identity);
object_path = gsignond_auth_session_get_object_path (session);
return object_path;
}
+static void
+_on_query_dialog_done (GSignondSignonuiData *reply, GError *error, gpointer user_data)
+{
+ GSignondIdentity *identity = GSIGNOND_IDENTITY (user_data);
+ guint32 id = 0;
+ GError *err = NULL;
+ GSignondSignonuiError err_id = 0;
+
+ if (error) {
+ WARN ("failed to verfiy user : %s", error->message);
+ g_error_free (error);
+
+ err = gsignond_get_gerror_for_id (GSIGNOND_ERROR_IDENTITY_OPERATION_CANCELED, "Operation cancled");
+ }
+
+ err_id = gsignond_signonui_data_get_query_error (reply);
+ if (err_id != SIGNONUI_ERROR_NONE) {
+ switch (err_id) {
+ case SIGNONUI_ERROR_CANCELED:
+ err = gsignond_get_gerror_for_id (GSIGNOND_ERROR_IDENTITY_OPERATION_CANCELED,
+ "Operation cancled");
+ break;
+ default:
+ err = gsignond_get_gerror_for_id (GSIGNOND_ERROR_INTERNAL_SERVER,
+ "signon ui returned with error : %d", err_id);
+ break;
+ }
+ }
+ else {
+ const gchar *secret = gsignond_signonui_data_get_password (reply);
+
+ if (!secret) {
+ err = gsignond_get_gerror_for_id (GSIGNOND_ERROR_INTERNAL_SERVER,
+ "Server internal error occured");
+ } else if (identity->priv->info) {
+ gsignond_identity_info_set_secret (identity->priv->info, secret) ;
+
+ /* Save new secret in db */
+ g_signal_emit (identity, signals[SIG_STORE], 0, identity->priv->info, &id);
+ if (!id) err = gsignond_get_gerror_for_id (GSIGNOND_ERROR_STORE_FAILED, "Failed to store secret");
+ }
+ }
+
+ gsignond_signonui_data_unref (reply);
+
+ gsignond_identity_iface_notify_credentials_updated (GSIGNOND_IDENTITY_IFACE (identity), id, err);
+
+ if (err) g_error_free (err);
+
+ gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (identity), TRUE);
+ gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (identity));
+}
+
+static gboolean
+_request_credentials_update (GSignondIdentityIface *iface, const gchar *message, const GSignondSecurityContext *ctx, GError **error)
+{
+ if (!(iface && GSIGNOND_IS_IDENTITY (iface))) {
+ WARN ("assertion (iface && GSIGNOND_IS_IDENTITY(iface)) failed");
+ if (error) *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_UNKNOWN, "Unknown error");
+ return FALSE;
+ }
+
+ GSignondIdentity *identity = GSIGNOND_IDENTITY (iface);
+ GSignondSignonuiData *ui_data = NULL;
+
+ if (!(identity && identity->priv->info)) {
+ WARN ("assertion (identity && identity->priv->info) failed");
+ if (error) *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_IDENTITY_ERR, "Identity not found.");
+ return FALSE;
+ }
+
+ VALIDATE_IDENTITY_READ_ACCESS (identity, ctx, FALSE);
+
+ if (!gsignond_identity_info_get_store_secret (identity->priv->info)) {
+ if (error) *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_CREDENTIALS_NOT_AVAILABLE, "Password can not be stored.");
+ return FALSE;
+ }
+
+ ui_data = gsignond_signonui_data_new ();
+
+ gsignond_signonui_data_set_query_username (ui_data, TRUE);
+ gsignond_signonui_data_set_username (ui_data, gsignond_identity_info_get_username (identity->priv->info));
+ gsignond_signonui_data_set_caption (ui_data, gsignond_identity_info_get_caption (identity->priv->info));
+ gsignond_signonui_data_set_message (ui_data, message);
+
+ gsignond_daemon_show_dialog (GSIGNOND_DAEMON (identity->priv->owner), G_OBJECT(identity),
+ ui_data, _on_query_dialog_done, NULL, identity);
+
+ gsignond_signonui_data_unref (ui_data);
+
+ gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (identity), FALSE);
+
+ return TRUE;
+}
+
+static void
+_on_user_verfied (GSignondSignonuiData *reply, GError *error, gpointer user_data)
+{
+ GSignondIdentity *identity = GSIGNOND_IDENTITY (user_data);
+ gboolean res = FALSE;
+ GError *err = NULL;
+ GSignondSignonuiError err_id = 0;
+
+ if (error) {
+ WARN ("failed to verfiy user : %s", error->message);
+ g_error_free (error);
+
+ err = gsignond_get_gerror_for_id (GSIGNOND_ERROR_IDENTITY_OPERATION_CANCELED, "Operation cancled");
+ }
+
+ err_id = gsignond_signonui_data_get_query_error (reply);
+ if (err_id != SIGNONUI_ERROR_NONE) {
+ switch (err_id) {
+ case SIGNONUI_ERROR_CANCELED:
+ err = gsignond_get_gerror_for_id (GSIGNOND_ERROR_IDENTITY_OPERATION_CANCELED,
+ "Operation cancled");
+ break;
+ case SIGNONUI_ERROR_FORGOT_PASSWORD:
+ err = gsignond_get_gerror_for_id (GSIGNOND_ERROR_FORGOT_PASSWORD, "Forgot password");
+ break;
+ default:
+ err = gsignond_get_gerror_for_id (GSIGNOND_ERROR_INTERNAL_SERVER,
+ "signon ui returned error : %d", err_id);
+ break;
+ }
+ }
+ else {
+ const gchar *secret = gsignond_signonui_data_get_password (reply);
+
+ if (!secret) {
+ err = gsignond_get_gerror_for_id (GSIGNOND_ERROR_INTERNAL_SERVER,
+ "Server internal error occured");
+ } else if (identity->priv->info) {
+ res = g_strcmp0 (secret, gsignond_identity_info_get_secret
+ (identity->priv->info)) == 0;
+ }
+ }
+
+ gsignond_signonui_data_unref (reply);
+
+ gsignond_identity_iface_notify_user_verified (GSIGNOND_IDENTITY_IFACE (identity), res, err);
+
+ if (err) g_error_free (err);
+
+ gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (identity), TRUE);
+ gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (identity));
+}
+
static gboolean
-_verify_user (GSignondIdentityIface *iface, const GVariant *params, const GSignondSecurityContext *ctx, GError **error)
+_verify_user (GSignondIdentityIface *iface, GVariant *params, const GSignondSecurityContext *ctx, GError **error)
{
if (!(iface && GSIGNOND_IS_IDENTITY (iface))) {
WARN ("assertion (iface && GSIGNOND_IS_IDENTITY(iface)) == 0) failed");
}
GSignondIdentity *identity = GSIGNOND_IDENTITY (iface);
const gchar *passwd = 0;
+ GSignondSignonuiData *ui_data = NULL;
+
if (!identity->priv->info) {
WARN ("assertion (identity->priv->info) failed");
if (error) *error = gsignond_get_gerror_for_id (GSIGNOND_ERROR_IDENTITY_ERR, "Identity not found.");
return FALSE;
}
- /*
- * TODO: Call UI to request credentials
- * and when ready, emit signal "store" to save the new credentials info
- * to database(which is handled by Daemon object).
- * On success, call
- * gsignond_identity_iface_notify_credentials_updated(self, id, NULL);
- */
+ ui_data = gsignond_signonui_data_new_from_variant (params);
+ gsignond_signonui_data_set_query_password (ui_data, TRUE);
+ gsignond_signonui_data_set_username (ui_data, gsignond_identity_info_get_username (identity->priv->info));
+ gsignond_signonui_data_set_caption (ui_data, gsignond_identity_info_get_caption (identity->priv->info));
+
+ gsignond_daemon_show_dialog (GSIGNOND_DAEMON (identity->priv->owner), G_OBJECT (identity),
+ ui_data, _on_user_verfied, NULL, identity);
- gsignond_disposable_set_keep_in_use (GSIGNOND_DISPOSABLE (identity));
+ gsignond_signonui_data_unref (ui_data);
+
+ gsignond_disposable_set_auto_dispose (GSIGNOND_DISPOSABLE (identity), FALSE);
return TRUE;
}
--- /dev/null
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2013 Intel Corporation.
+ *
+ * Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include "gsignond-signonui-proxy.h"
+#include <gsignond/gsignond-log.h>
+#include <gsignond/gsignond-signonui.h>
+#include "dbus/gsignond-dbus-signonui-adapter.h"
+
+static void _process_next_request (GSignondSignonuiProxy *proxy);
+static void _on_refresh_request (GSignondSignonuiProxy *proxy,
+ gchar *request_id, gpointer userdata);
+
+typedef struct {
+ GObject *caller;
+ GSignondSignonuiData *ui_data;
+ GSignondSignonuiProxyQueryDialogCb cb;
+ GSignondSignonuiProxyRefreshCb refresh_cb;
+ gpointer userdata;
+} _UIQueryRequest;
+
+typedef struct {
+ GSignondSignonuiProxyRefreshDialogCb cb;
+ gpointer userdata;
+} _UIRefreshRequest;
+
+typedef struct {
+ GSignondSignonuiProxyCancelRequestCb cb;
+ gpointer userdata;
+} _UICancelRequest;
+
+struct _GSignondSignonuiProxyPrivate
+{
+ GSignondDbusSignonuiAdapter *signonui;
+ _UIQueryRequest *active_request; /* Active dialog */
+ GQueue *request_queue; /* request queue */
+ gboolean is_idle;
+};
+
+G_DEFINE_TYPE (GSignondSignonuiProxy, gsignond_signonui_proxy, G_TYPE_OBJECT);
+#define GSIGNOND_SIGNONUI_PROXY_GET_PRIV(obj) G_TYPE_INSTANCE_GET_PRIVATE ((obj), GSIGNOND_TYPE_SIGNONUI_PROXY, GSignondSignonuiProxyPrivate)
+
+static _UIQueryRequest *
+_ui_query_request_new (GObject *caller,
+ GSignondSignonuiData *ui_data,
+ GSignondSignonuiProxyQueryDialogCb cb,
+ GSignondSignonuiProxyRefreshCb refresh_cb,
+ gpointer userdata)
+{
+ _UIQueryRequest *req = g_new0(_UIQueryRequest, 1);
+
+ req->caller = caller;
+ req->ui_data = gsignond_signonui_data_ref (ui_data);
+ req->cb = cb;
+ req->refresh_cb = refresh_cb;
+ req->userdata = userdata;
+
+ return req;
+}
+
+static _UIRefreshRequest *
+_ui_refresh_request_new (GSignondSignonuiProxyRefreshDialogCb cb, gpointer userdata)
+{
+ _UIRefreshRequest *req = g_new0(_UIRefreshRequest, 1);
+
+ req->cb = cb;
+ req->userdata = userdata;
+
+ return req;
+}
+
+static _UICancelRequest *
+_ui_cancel_request_new (GSignondSignonuiProxyCancelRequestCb cb, gpointer userdata)
+{
+ _UICancelRequest *req = g_new0(_UICancelRequest, 1);
+
+ req->cb = cb;
+ req->userdata = userdata;
+
+ return req;
+}
+
+static void
+_ui_query_request_free (_UIQueryRequest *req)
+{
+ if (!req) return;
+ if (req->ui_data) gsignond_signonui_data_unref (req->ui_data);
+ g_free (req);
+}
+
+static void
+_dispose (GObject *object)
+{
+ GSignondSignonuiProxy *self = GSIGNOND_SIGNONUI_PROXY (object);
+
+ if (self->priv->signonui) {
+ g_object_unref (self->priv->signonui);
+ self->priv->signonui = NULL;
+ }
+
+ G_OBJECT_CLASS (gsignond_signonui_proxy_parent_class)->dispose (object);
+}
+
+static void
+_finalize (GObject *object)
+{
+ GSignondSignonuiProxy *self = GSIGNOND_SIGNONUI_PROXY (object);
+
+ if (self->priv->request_queue) {
+ g_queue_free_full (self->priv->request_queue, (GDestroyNotify)_ui_query_request_free);
+ self->priv->request_queue = NULL;
+ }
+
+ G_OBJECT_CLASS (gsignond_signonui_proxy_parent_class)->finalize (object);
+}
+
+static void
+gsignond_signonui_proxy_class_init (GSignondSignonuiProxyClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (gobject_class, sizeof (GSignondSignonuiProxyPrivate));
+
+ gobject_class->dispose = _dispose;
+ gobject_class->finalize = _finalize;
+}
+
+static void
+gsignond_signonui_proxy_init (GSignondSignonuiProxy *proxy)
+{
+ proxy->priv = GSIGNOND_SIGNONUI_PROXY_GET_PRIV (proxy);
+
+ proxy->priv->signonui = gsignond_dbus_signonui_adapter_new ();
+
+ if (proxy->priv->signonui)
+ g_signal_connect_swapped (proxy->priv->signonui, "refresh", G_CALLBACK(_on_refresh_request), proxy);
+ proxy->priv->active_request = NULL;
+ proxy->priv->request_queue = g_queue_new ();
+ proxy->priv->is_idle = TRUE;
+}
+
+static void
+_on_refresh_request (GSignondSignonuiProxy *proxy, gchar *request_id, gpointer userdata)
+{
+ _UIQueryRequest *req = proxy->priv->active_request;
+
+ if (req && !g_strcmp0 (G_OBJECT_TYPE_NAME (req->caller), request_id)) {
+ if (req->refresh_cb) req->refresh_cb(req->ui_data, req->userdata);
+ }
+ else {
+ WARN("UI-Error: unhandled refresh request");
+ }
+}
+
+static void
+_query_dialog_cb (GVariant *reply, GError *error, gpointer user_data)
+{
+ GSignondSignonuiProxy *proxy = GSIGNOND_SIGNONUI_PROXY (user_data);
+
+ _UIQueryRequest *req = proxy->priv->active_request;
+
+ if (req && req->cb)
+ req->cb (gsignond_signonui_data_new_from_variant (reply), error, req->userdata);
+ else if (error) {
+ WARN ("UI-Error: %s", error->message);
+ g_error_free (error);
+ }
+
+ _ui_query_request_free (req);
+
+ proxy->priv->active_request = NULL;
+
+ _process_next_request (proxy);
+}
+
+static void
+_process_next_request (GSignondSignonuiProxy *proxy)
+{
+ _UIQueryRequest *req = g_queue_pop_head (proxy->priv->request_queue);
+
+ if (!req) {
+ proxy->priv->is_idle = TRUE;
+ proxy->priv->active_request = NULL;
+ return;
+ }
+
+ proxy->priv->active_request = req;
+
+ /* update request id */
+ gsignond_signonui_data_set_request_id (req->ui_data, G_OBJECT_TYPE_NAME(req->caller));
+ gsignond_dbus_signonui_adapter_query_dialog (proxy->priv->signonui,
+ gsignond_signonui_data_to_variant(req->ui_data), _query_dialog_cb, proxy);
+
+ proxy->priv->is_idle = FALSE;
+}
+
+gboolean
+gsignond_signonui_proxy_query_dialog (GSignondSignonuiProxy *proxy,
+ GObject *caller,
+ GSignondSignonuiData *ui_data,
+ GSignondSignonuiProxyQueryDialogCb cb,
+ GSignondSignonuiProxyRefreshCb refresh_cb,
+ gpointer userdata)
+{
+
+ g_queue_push_tail (proxy->priv->request_queue,
+ _ui_query_request_new (caller, ui_data, cb, refresh_cb, userdata));
+
+ if (proxy->priv->is_idle) _process_next_request (proxy);
+
+ return TRUE;
+}
+
+static void
+_refresh_dialog_cb (GError *error, gpointer user_data)
+{
+ _UIRefreshRequest *req = (_UIRefreshRequest *)user_data;
+
+ if (req && req->cb){
+ req->cb(error, req->userdata);
+ } else if (error) {
+ WARN ("UI-Error : %s", error->message);
+ g_error_free (error);
+ }
+
+ g_free (req);
+}
+
+gboolean
+gsignond_signonui_proxy_refresh_dialog (GSignondSignonuiProxy *proxy,
+ GObject *caller,
+ GSignondSignonuiData *ui_data,
+ GSignondSignonuiProxyRefreshDialogCb cb,
+ gpointer userdata)
+{
+ if (proxy->priv->active_request
+ && proxy->priv->active_request->caller == caller) {
+ _UIRefreshRequest *req = _ui_refresh_request_new (cb, userdata);
+
+ /* FIXME: Is it required to set refresh id for refresh data */
+ gsignond_signonui_data_set_request_id (ui_data, G_OBJECT_TYPE_NAME(caller));
+ gsignond_dbus_signonui_adapter_refresh_dialog (proxy->priv->signonui,
+ gsignond_signonui_data_to_variant (ui_data), _refresh_dialog_cb, req);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void
+_cancel_request_cb (GError *error, gpointer user_data)
+{
+ _UICancelRequest *req = (_UICancelRequest*)user_data;
+
+ if (req && req->cb)
+ req->cb (error, req->userdata);
+ else if (error) {
+ WARN ("UI-Error : %s", error->message);
+ g_error_free (error);
+ }
+
+ g_free (req);
+}
+
+static gint
+_find_request_by_caller (gconstpointer a, gconstpointer b)
+{
+ _UIQueryRequest *req = (_UIQueryRequest *)a;
+
+ return (req && req->caller == b) ? 0 : 1;
+}
+
+gboolean
+gsignond_signonui_proxy_cancel_request (GSignondSignonuiProxy *proxy,
+ GObject *caller,
+ GSignondSignonuiProxyCancelRequestCb cb,
+ gpointer userdata)
+{
+ GList *element = NULL;
+ _UIQueryRequest *req = NULL;
+ /* if no active request to cacel */
+ if (!proxy->priv->active_request) return FALSE;
+
+ /* cancel active request */
+ if (proxy->priv->active_request->caller == caller) {
+ _UICancelRequest *req = _ui_cancel_request_new (cb, userdata);
+ gsignond_dbus_signonui_adapter_cancel_request (proxy->priv->signonui,
+ G_OBJECT_TYPE_NAME (caller), _cancel_request_cb, req);
+ return TRUE;
+ }
+
+ /* cancel pending request */
+ element = g_queue_find_custom (proxy->priv->request_queue, caller, _find_request_by_caller);
+
+ if (!element) return FALSE;
+ req = element->data;
+
+ if (req->cb) {
+ gsignond_signonui_data_ref (req->ui_data);
+ gsignond_signonui_data_set_query_error(req->ui_data, SIGNONUI_ERROR_CANCELED);
+
+ req->cb (req->ui_data, NULL, req->userdata);
+ }
+
+ if (cb) cb(NULL, userdata);
+
+ return TRUE;
+}
+
+GSignondSignonuiProxy *
+gsignond_signonui_proxy_new ()
+{
+ return g_object_new (GSIGNOND_TYPE_SIGNONUI_PROXY, NULL);
+}
--- /dev/null
+/* vi: set et sw=4 ts=4 cino=t0,(0: */
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of gsignond
+ *
+ * Copyright (C) 2013 Intel Corporation.
+ *
+ * Contact: Amarnath Valluri<amarnath.valluri@linux.intel.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef __GSIGNOND_SIGNONUI_PROXY_H__
+#define __GSIGNOND_SIGNONUI_PROXY_H__
+
+#include <glib-object.h>
+#include <gsignond/gsignond-signonui-data.h>
+
+#define GSIGNOND_TYPE_SIGNONUI_PROXY (gsignond_signonui_proxy_get_type ())
+#define GSIGNOND_SIGNONUI_PROXY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSIGNOND_TYPE_SIGNONUI_PROXY, GSignondSignonuiProxy))
+#define GSIGNOND_IS_SIGNONUI_PROXY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GSIGNOND_TYPE_SIGNONUI_PROXY))
+#define GSIGNOND_SIGNONUI_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSIGNOND_TYPE_SIGNONUI_PROXY, GSignondSignonuiProxyClass))
+#define GSIGNOND_IS_SIGNONUI_PROXY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GSIGNOND_TYPE_SIGNONUI_PROXY))
+#define GSIGNOND_SIGNONUI_PROXY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GSIGNOND_TYPE_SIGNONUI_PROXY, GSignondSignonuiProxyClass))
+
+typedef struct _GSignondSignonuiProxy GSignondSignonuiProxy;
+typedef struct _GSignondSignonuiProxyClass GSignondSignonuiProxyClass;
+typedef struct _GSignondSignonuiProxyPrivate GSignondSignonuiProxyPrivate;
+
+typedef void (*GSignondSignonuiProxyQueryDialogCb)(GSignondSignonuiData *reply, GError *error, gpointer userdata);
+typedef void (*GSignondSignonuiProxyRefreshCb)(GSignondSignonuiData *ui_data, gpointer userdata);
+typedef void (*GSignondSignonuiProxyRefreshDialogCb) (GError *error, gpointer userdata);
+typedef void (*GSignondSignonuiProxyCancelRequestCb) (GError *error, gpointer userdata);
+
+struct _GSignondSignonuiProxy
+{
+ GObject parent;
+
+ /* Private */
+ GSignondSignonuiProxyPrivate *priv;
+};
+
+struct _GSignondSignonuiProxyClass
+{
+ GObjectClass parent_class;
+};
+
+GType gsignond_signonui_proxy_get_type (void);
+
+GSignondSignonuiProxy *
+gsignond_signonui_proxy_new ();
+
+gboolean
+gsignond_signonui_proxy_query_dialog (GSignondSignonuiProxy *proxy,
+ GObject *caller,
+ GSignondSignonuiData *ui_data,
+ GSignondSignonuiProxyQueryDialogCb callback,
+ GSignondSignonuiProxyRefreshCb refresh_cb,
+ gpointer userdata);
+
+gboolean
+gsignond_signonui_proxy_refresh_dialog (GSignondSignonuiProxy *proxy,
+ GObject *caller,
+ GSignondSignonuiData *ui_data,
+ GSignondSignonuiProxyRefreshDialogCb callback,
+ gpointer userdata);
+
+gboolean
+gsignond_signonui_proxy_cancel_request (GSignondSignonuiProxy *proxy,
+ GObject *caller,
+ GSignondSignonuiProxyCancelRequestCb callback,
+ gpointer userdata);
+
+#endif //__GSIGNOND_SIGNONUI_PROXY_H__
gpointer user_data);
static void gsignond_plugin_proxy_user_action_required_callback(
GSignondPlugin* plugin,
- GSignondSessionData* ui_request,
+ GSignondSignonuiData* ui_request,
gpointer user_data);
static void gsignond_plugin_proxy_error_callback(GSignondPlugin* plugin,
GError* error,
void
gsignond_plugin_proxy_user_action_finished (GSignondPluginProxy *self,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
g_assert (GSIGNOND_IS_PLUGIN_PROXY (self));
active session", self->priv->plugin_type);
return;
}
- gsignond_plugin_user_action_finished (self->priv->plugin, session_data);
+ gsignond_plugin_user_action_finished (self->priv->plugin, ui_data);
}
void
gsignond_plugin_proxy_refresh (GSignondPluginProxy *self,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
g_assert (GSIGNOND_IS_PLUGIN_PROXY (self));
self->priv->plugin_type);
return;
}
- gsignond_plugin_refresh (self->priv->plugin, session_data);
+ gsignond_plugin_refresh (self->priv->plugin, ui_data);
}
static void
static void
gsignond_plugin_proxy_refreshed_callback (GSignondPlugin *plugin,
- GSignondSessionData *result,
+ GSignondSignonuiData *ui_result,
gpointer user_data)
{
GSignondPluginProxy *self = GSIGNOND_PLUGIN_PROXY (user_data);
in plugin proxy", priv->plugin_type);
return;
}
- gsignond_auth_session_iface_notify_refreshed (priv->active_session, result);
+ gsignond_auth_session_iface_notify_refreshed (priv->active_session, ui_result);
}
static void
gsignond_plugin_proxy_user_action_required_callback (
GSignondPlugin *plugin,
- GSignondSessionData *ui_request,
+ GSignondSignonuiData *ui_request,
gpointer user_data)
{
GSignondPluginProxy *self = GSIGNOND_PLUGIN_PROXY (user_data);
GSignondSessionData *session_data,
const gchar *mechanism);
void gsignond_plugin_proxy_user_action_finished (GSignondPluginProxy *self,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
void gsignond_plugin_proxy_refresh (GSignondPluginProxy *self,
- GSignondSessionData *session_data);
+ GSignondSignonuiData *ui_data);
#endif /* __GSIGNOND_PLUGIN_PROXY_H__ */
if (g_strcmp0 (mechanism, "mech2") == 0) {
const gchar* username =
gsignond_session_data_get_username (session_data);
- GSignondSessionData *user_action_data = gsignond_dictionary_new ();
- // FIXME: fix when the signon ui is integrated
- /*if (username == NULL)
- gsignond_session_data_set_query_username (user_action_data, TRUE);
- else*/
- gsignond_session_data_set_username (user_action_data, username);
- //gsignond_session_data_set_query_password (user_action_data, TRUE);
+ GSignondSignonuiData *user_action_data = gsignond_signonui_data_new();
+ if (username == NULL)
+ gsignond_signonui_data_set_query_username (user_action_data, TRUE);
+ else
+ gsignond_signonui_data_set_username (user_action_data, username);
+ gsignond_signonui_data_set_query_password (user_action_data, TRUE);
gsignond_plugin_user_action_required (plugin, user_action_data);
- gsignond_dictionary_unref (user_action_data);
+ gsignond_signonui_data_unref (user_action_data);
gsignond_dictionary_unref (response);
INFO ("mechanism 'mech2' responded'");
return;
static void gsignond_ssotest_plugin_refresh (
GSignondPlugin *plugin,
- GSignondSessionData *session_data)
+ GSignondSignonuiData *ui_data)
{
- gsignond_plugin_refreshed (plugin, session_data);
+ gsignond_plugin_refreshed (plugin, ui_data);
}
static void