#endif
#define LOG_TAG "AUTOFILL"
-rpc_port_proxy_AutofillAppPort_h rpc_h = NULL;
-
-static autofill_connection_status_changed_cb connection_callback = NULL;
-static void *connection_userdata = NULL;
-
-extern autofill_fill_response_received_cb g_autofill_fill_response_received_cb;
-extern void *g_autofill_fill_response_data;
-
-extern autofill_auth_info_received_cb g_autofill_auth_info_received_cb;
-extern void *g_autofill_auth_info_data;
+static int _autofill_context_count = 0;
static bool fill_response_item_cb(rpc_port_autofill_response_item_h response_items, void *user_data)
{
static void __fill_response_recv_cb(void *user_data, rpc_port_autofill_fill_response_h response_h)
{
char *view_id = NULL;
+ autofill_h ah = user_data;
autofill_fill_response_h rh;
autofill_fill_response_create(&rh);
rpc_port_autofill_fill_response_foreach_response_groups(response_h, fill_response_group_cb, rh);
- if (g_autofill_fill_response_received_cb)
- g_autofill_fill_response_received_cb(rh, g_autofill_fill_response_data);
+ if (ah->autofill_fill_response_received_cb)
+ ah->autofill_fill_response_received_cb(ah, rh, ah->autofill_fill_response_data);
autofill_fill_response_destroy(rh);
}
static void __auth_info_recv_cb(void *user_data, rpc_port_autofill_auth_info_h auth_info_h)
{
- autofill_auth_info_h ah;
- autofill_auth_info_create(&ah);
+ autofill_auth_info_h aih;
+ autofill_h ah = user_data;
+
+ autofill_auth_info_create(&aih);
bool autofill_data_present = false;
bool authentication_needed = false;
LOGD("service name : %s", service_name);
- autofill_auth_info_set_view_id(ah, view_id);
- autofill_auth_info_set_autofill_data_present(ah, autofill_data_present);
- autofill_auth_info_set_authentication_needed(ah, authentication_needed);
- autofill_auth_info_set_service_name(ah, service_name);
- autofill_auth_info_set_service_logo_image_path(ah, service_logo_image_path);
- autofill_auth_info_set_service_message(ah, service_message);
+ autofill_auth_info_set_view_id(aih, view_id);
+ autofill_auth_info_set_autofill_data_present(aih, autofill_data_present);
+ autofill_auth_info_set_authentication_needed(aih, authentication_needed);
+ autofill_auth_info_set_service_name(aih, service_name);
+ autofill_auth_info_set_service_logo_image_path(aih, service_logo_image_path);
+ autofill_auth_info_set_service_message(aih, service_message);
if (view_id)
free(view_id);
if (service_message)
free(service_message);
- if (g_autofill_auth_info_received_cb)
- g_autofill_auth_info_received_cb(ah, g_autofill_fill_response_data);
+ if (ah) {
+ if (ah->autofill_auth_info_received_cb)
+ ah->autofill_auth_info_received_cb(ah, aih, ah->autofill_fill_response_data);
+ }
+ else {
+ LOGW("no user data");
+ }
- autofill_auth_info_destroy(ah);
+ autofill_auth_info_destroy(aih);
}
static void __on_connected(rpc_port_proxy_AutofillAppPort_h h, void *user_data)
{
- LOGI("[__RPC_PORT__] connected");
- rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_received_cb = rpc_port_AutofillAppPort_autofill_fill_response_received_cb_create(__fill_response_recv_cb, false, NULL);
- rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_received_cb = rpc_port_AutofillAppPort_autofill_auth_info_received_cb_create(__auth_info_recv_cb, false, NULL);
+ autofill_h ah = user_data;
+ if (!ah) {
+ LOGW("no user data");
+ return;
+ }
+
+ LOGI("connected");
+ rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_received_cb = rpc_port_AutofillAppPort_autofill_fill_response_received_cb_create(__fill_response_recv_cb, false, ah);
+ rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_received_cb = rpc_port_AutofillAppPort_autofill_auth_info_received_cb_create(__auth_info_recv_cb, false, ah);
- int r = rpc_port_proxy_AutofillAppPort_invoke_Register(h, auth_info_received_cb, fill_response_received_cb);
+ int r = rpc_port_proxy_AutofillAppPort_invoke_Register(h, ah->context_id, auth_info_received_cb, fill_response_received_cb);
if (r != 0)
LOGD("Failed to invoke Register");
- if (connection_callback)
- connection_callback(AUTOFILL_CONNECTION_STATUS_CONNECTED, connection_userdata);
+ if (ah->connection_callback)
+ ah->connection_callback(ah, AUTOFILL_CONNECTION_STATUS_CONNECTED, ah->connection_userdata);
}
//LCOV_EXCL_START
{
LOGD("disconnected");
- if (connection_callback)
- connection_callback(AUTOFILL_CONNECTION_STATUS_DISCONNECTED, connection_userdata);
+ autofill_h ah = user_data;
+ if (ah) {
+ if (ah && ah->connection_callback)
+ ah->connection_callback(ah, AUTOFILL_CONNECTION_STATUS_DISCONNECTED, ah->connection_userdata);
- rpc_h = NULL;
+ ah->rpc_h = NULL;
+ }
}
static void __on_rejected(rpc_port_proxy_AutofillAppPort_h h, void *user_data)
{
LOGD("rejected");
- if (connection_callback)
- connection_callback(AUTOFILL_CONNECTION_STATUS_REJECTED, connection_userdata);
+ autofill_h ah = user_data;
+
+ if (ah && ah->connection_callback)
+ ah->connection_callback(ah, AUTOFILL_CONNECTION_STATUS_REJECTED, ah->connection_userdata);
}
//LCOV_EXCL_STOP
-EXPORT_API int autofill_initialize(void)
+EXPORT_API int autofill_create(autofill_h *ah)
{
- LOGD("autofill initialize");
-
int ret;
- if (rpc_h) {
- LOGI("already initialized\n");
- return AUTOFILL_ERROR_NONE;
- }
+ if (!ah)
+ return AUTOFILL_ERROR_INVALID_PARAMETER;
rpc_port_proxy_AutofillAppPort_callback_s rpc_callback = {
.connected = __on_connected,
.rejected = __on_rejected
};
- ret = rpc_port_proxy_AutofillAppPort_create(AUTOFILL_DAEMON_APP_ID, &rpc_callback, NULL, &rpc_h);
+ struct autofill_s *as = (autofill_h)calloc(1, sizeof(struct autofill_s));
+ if (!as)
+ return AUTOFILL_ERROR_OUT_OF_MEMORY;
+
+ ret = rpc_port_proxy_AutofillAppPort_create(AUTOFILL_DAEMON_APP_ID, &rpc_callback, as, &as->rpc_h);
if (ret != RPC_PORT_ERROR_NONE) {
LOGW("Failed to create rpc port. err = %d", ret);
+ free(as);
return AUTOFILL_ERROR_OUT_OF_MEMORY;
}
- return ret;
+ as->context_id = _autofill_context_count++;
+ *ah = as;
+
+ return AUTOFILL_ERROR_NONE;
}
-EXPORT_API int autofill_deinitialize(void)
+EXPORT_API int autofill_destroy(autofill_h ah)
{
- LOGD("autofill deinitialize");
+ if (!ah)
+ return AUTOFILL_ERROR_INVALID_PARAMETER;
- connection_callback = NULL;
- g_autofill_fill_response_received_cb = NULL;
- g_autofill_auth_info_received_cb = NULL;
+ ah->connection_callback = NULL;
+ ah->autofill_fill_response_received_cb = NULL;
+ ah->autofill_auth_info_received_cb = NULL;
- if (rpc_h) {
- rpc_port_proxy_AutofillAppPort_destroy(rpc_h);
- rpc_h = NULL;
+ if (ah->rpc_h) {
+ rpc_port_proxy_AutofillAppPort_destroy(ah->rpc_h);
+ ah->rpc_h = NULL;
}
- else
- return AUTOFILL_ERROR_NOT_INITIALIZED;
return AUTOFILL_ERROR_NONE;
}
-EXPORT_API int autofill_connect(autofill_connection_status_changed_cb callback, void *user_data)
+EXPORT_API int autofill_connect(autofill_h ah, autofill_connection_status_changed_cb callback, void *user_data)
{
- LOGD("autofill connect");
+ LOGD("autofill connect. handle : %p", ah);
int ret;
- if (!callback) {
- LOGW("parameter is NULL\n");
+ if (!ah || !callback) {
+ LOGW("[ERROR] Invalid parameter");
return AUTOFILL_ERROR_INVALID_PARAMETER;
}
- if (!rpc_h) {
- LOGW("Not initialized\n");
- return AUTOFILL_ERROR_NOT_INITIALIZED;
+ if (!ah->rpc_h) {
+ return AUTOFILL_ERROR_OPERATION_FAILED;
}
- connection_callback = callback;
- connection_userdata = user_data;
+ ah->connection_callback = callback;
+ ah->connection_userdata = user_data;
- ret = rpc_port_proxy_AutofillAppPort_connect(rpc_h);
+ ret = rpc_port_proxy_AutofillAppPort_connect(ah->rpc_h);
if (ret != RPC_PORT_ERROR_NONE) {
LOGW("Failed to connect rpc port. err = %d", ret);
return AUTOFILL_ERROR_OPERATION_FAILED;
}
}
-EXPORT_API int autofill_commit(autofill_save_view_info_h vi)
+EXPORT_API int autofill_commit(autofill_h ah, autofill_save_view_info_h vi)
{
rpc_port_autofill_save_view_info_h vih;
char *id;
autofill_hint_e autofill_hint;
bool sensitive_data;
- if (!vi) {
- LOGW("parameter is NULL");
+ if (!ah || !vi) {
+ LOGW("[ERROR] Invalid parameter");
return AUTOFILL_ERROR_INVALID_PARAMETER;
}
- if (!rpc_h) {
- LOGW("Not initialized\n");
- return AUTOFILL_ERROR_NOT_INITIALIZED;
+ if (!ah->rpc_h) {
+ return AUTOFILL_ERROR_OPERATION_FAILED;
}
rpc_port_autofill_save_view_info_create(&vih);
LOGD("app id : %s, view id : %s", vi->app_id, vi->view_id);
- int ret = rpc_port_proxy_AutofillAppPort_invoke_commit(rpc_h, vih);
+ int ret = rpc_port_proxy_AutofillAppPort_invoke_commit(ah->rpc_h, ah->context_id, vih);
rpc_port_autofill_save_view_info_destroy(vih);
#include "autofill_private.h"
#include "autofill_proxy.h"
-extern rpc_port_proxy_AutofillAppPort_h rpc_h;
-
#ifdef LOG_TAG
#undef LOG_TAG
#endif
#define LOG_TAG "AUTOFILL"
-autofill_auth_info_received_cb g_autofill_auth_info_received_cb = NULL;
-void *g_autofill_auth_info_data = NULL;
-
// Request autofill auth info
-EXPORT_API int autofill_auth_info_request(autofill_view_info_h vi)
+EXPORT_API int autofill_auth_info_request(autofill_h ah, autofill_view_info_h vi)
{
int ret = AUTOFILL_ERROR_NONE;
rpc_port_autofill_view_info_h vih;
autofill_hint_e autofill_hint;
bool sensitive_data;
- if (!vi) {
- LOGW("parameter is NULL");
+ if (!ah || !vi) {
+ LOGW("[ERROR] Invalid parameter");
return AUTOFILL_ERROR_INVALID_PARAMETER;
}
- if (!rpc_h) {
- LOGW("Not initialized");
- return AUTOFILL_ERROR_NOT_INITIALIZED;
+ if (!ah->rpc_h) {
+ return AUTOFILL_ERROR_OPERATION_FAILED;
}
LOGD("app id : %s, view id : %s", vi->app_id, vi->view_id);
rpc_port_autofill_item_destroy(aih);
}
- LOGD("rpc_h : %p", rpc_h);
+ LOGD("rpc_h : %p, context id : %d", ah->rpc_h, ah->context_id);
- ret = rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(rpc_h, vih);
+ ret = rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(ah->rpc_h, ah->context_id, vih);
rpc_port_autofill_view_info_destroy(vih);
return AUTOFILL_ERROR_NONE;
}
-EXPORT_API int autofill_auth_info_set_received_cb(autofill_auth_info_received_cb callback, void *user_data)
+EXPORT_API int autofill_auth_info_set_received_cb(autofill_h ah, autofill_auth_info_received_cb callback, void *user_data)
{
- if (!callback) {
- LOGW("parameter is NULL");
+ if (!ah || !callback) {
+ LOGW("[ERROR] Invalid parameter");
return AUTOFILL_ERROR_INVALID_PARAMETER;
}
- g_autofill_auth_info_received_cb = callback;
- g_autofill_auth_info_data = user_data;
+ ah->autofill_auth_info_received_cb = callback;
+ ah->autofill_auth_info_data = user_data;
return AUTOFILL_ERROR_NONE;
}
-EXPORT_API int autofill_auth_info_unset_received_cb(void)
+EXPORT_API int autofill_auth_info_unset_received_cb(autofill_h ah)
{
- g_autofill_auth_info_received_cb = NULL;
- g_autofill_auth_info_data = NULL;
+ if (!ah) {
+ LOGW("[ERROR] Invalid parameter");
+ return AUTOFILL_ERROR_INVALID_PARAMETER;
+ }
+
+ ah->autofill_auth_info_received_cb = NULL;
+ ah->autofill_auth_info_data = NULL;
return AUTOFILL_ERROR_NONE;
}
#endif
#define LOG_TAG "AUTOFILL"
-extern rpc_port_proxy_AutofillAppPort_h rpc_h;
-
-autofill_fill_response_received_cb g_autofill_fill_response_received_cb = NULL;
-void *g_autofill_fill_response_data = NULL;
-
-EXPORT_API int autofill_fill_request(autofill_view_info_h vi)
+EXPORT_API int autofill_fill_request(autofill_h ah, autofill_view_info_h vi)
{
int ret = AUTOFILL_ERROR_NONE;
rpc_port_autofill_view_info_h vih;
autofill_hint_e autofill_hint;
bool sensitive_data;
- if (!vi) {
- LOGW("parameter is NULL");
+ if (!ah || !vi) {
+ LOGW("[ERROR] Invalid parameter");
return AUTOFILL_ERROR_INVALID_PARAMETER;
}
- if (!rpc_h) {
- LOGW("Not initialized");
- return AUTOFILL_ERROR_NOT_INITIALIZED;
+ if (!ah->rpc_h) {
+ return AUTOFILL_ERROR_OPERATION_FAILED;
}
Eina_List *l;
rpc_port_autofill_item_destroy(aih);
}
- LOGD("app id : %s, view id : %s", vi->app_id, vi->view_id);
+ LOGD("app id : %s, view id : %s, context id : %d", vi->app_id, vi->view_id, ah->context_id);
- ret = rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(rpc_h, vih);
+ ret = rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(ah->rpc_h, ah->context_id, vih);
rpc_port_autofill_view_info_destroy(vih);
return AUTOFILL_ERROR_NONE;
}
-EXPORT_API int autofill_fill_response_set_received_cb(autofill_fill_response_received_cb callback, void *user_data)
+EXPORT_API int autofill_fill_response_set_received_cb(autofill_h ah, autofill_fill_response_received_cb callback, void *user_data)
{
- if (!callback) {
- LOGW("parameter is NULL");
+ if (!ah || !callback) {
+ LOGW("[ERROR] Invalid parameter");
return AUTOFILL_ERROR_INVALID_PARAMETER;
}
- g_autofill_fill_response_received_cb = callback;
- g_autofill_fill_response_data = user_data;
+ ah->autofill_fill_response_received_cb = callback;
+ ah->autofill_fill_response_data = user_data;
return AUTOFILL_ERROR_NONE;
}
-EXPORT_API int autofill_fill_response_unset_received_cb(void)
+EXPORT_API int autofill_fill_response_unset_received_cb(autofill_h ah)
{
- g_autofill_fill_response_received_cb = NULL;
- g_autofill_fill_response_data = NULL;
+ if (!ah) {
+ LOGW("[ERROR] Invalid parameter");
+ return AUTOFILL_ERROR_INVALID_PARAMETER;
+ }
+
+ ah->autofill_fill_response_received_cb = NULL;
+ ah->autofill_fill_response_data = NULL;
return AUTOFILL_ERROR_NONE;
}
} autofill_connection_status_e;
/**
+ * @brief The autofill handle.
+ * @since_tizen 5.5
+ */
+typedef struct autofill_s *autofill_h;
+
+/**
* @brief Called when the connection status is changed.
* @since_tizen 5.5
+ * @remarks @a ah should not be freed and can be used only in the callback.
+ * @param[in] ah The autofill handle
* @param[in] status The connection status
* @param[in] user_data The user data passed from the callback function
* @see autofill_connect()
*/
-typedef void(*autofill_connection_status_changed_cb)(autofill_connection_status_e status, void* user_data);
+typedef void (*autofill_connection_status_changed_cb)(autofill_h ah, autofill_connection_status_e status, void* user_data);
/**
* @brief Called when receiving autofill fill response data.
* @since_tizen 5.5
+ * @remarks @a ah should not be freed and can be used only in the callback.
* @remarks @a fill_response_h should not be freed and can be used only in the callback.
+ * @param[in] ah The autofill handle
* @param[in] fill_response_h The autofill fill response handle
* @param[in] user_data The user data to be passed to the callback function
* @see autofill_fill_response_set_received_cb()
*/
-typedef void (*autofill_fill_response_received_cb)(autofill_fill_response_h fill_response_h, void *user_data);
+typedef void (*autofill_fill_response_received_cb)(autofill_h ah, autofill_fill_response_h fill_response_h, void *user_data);
/**
* @brief Called when receiving the authentication information.
* @since_tizen 5.5
+ * @remarks @a ah should not be freed and can be used only in the callback.
* @remarks @a auth_info should not be freed and can be used only in the callback.
+ * @param[in] ah The autofill handle
* @param[in] auth_info The autofill authentication information handle
* @param[in] user_data The user data passed from the callback function
* @see autofill_fill_response_set_received_cb()
*/
-typedef void (*autofill_auth_info_received_cb)(autofill_auth_info_h auth_info, void *user_data);
+typedef void (*autofill_auth_info_received_cb)(autofill_h ah, autofill_auth_info_h auth_info, void *user_data);
/**
- * @brief Initializes autofill.
+ * @brief Creates a handle for autofill.
* @since_tizen 5.5
+ * @remarks If the function succeeds, @a ah handle must be released with autofill_destroy().
+ * @param[out] ah The autofill handle
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
+ * @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #AUTOFILL_ERROR_OUT_OF_MEMORY Out of memory
+ * @see autofill_destroy()
*/
-int autofill_initialize(void);
+int autofill_create(autofill_h *ah);
/**
- * @brief Deinitializes autofill.
+ * @brief Destroys an autofill.
* @since_tizen 5.5
+ * @param[in] ah The autofill handle
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
- * @retval #AUTOFILL_ERROR_NOT_INITIALIZED Not initialized
+ * @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see autofill_create()
*/
-int autofill_deinitialize(void);
+int autofill_destroy(autofill_h ah);
/**
* @brief Connects to autofill daemon.
* @since_tizen 5.5
+ * @param[in] ah The autofill handle
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
* @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUTOFILL_ERROR_NOT_INITIALIZED Not initialized
* @retval #AUTOFILL_ERROR_OPERATION_FAILED Operation failure
*/
-int autofill_connect(autofill_connection_status_changed_cb callback, void *user_data);
+int autofill_connect(autofill_h ah, autofill_connection_status_changed_cb callback, void *user_data);
/**
* @brief Requests of authentication information.
* @since_tizen 5.5
+ * @param[in] ah The autofill handle
* @param[in] vi The autofill view info handle
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
* @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUTOFILL_ERROR_NOT_INITIALIZED Not initialized
* @retval #AUTOFILL_ERROR_OPERATION_FAILED Operation failure
*/
-int autofill_auth_info_request(autofill_view_info_h vi);
+int autofill_auth_info_request(autofill_h ah, autofill_view_info_h vi);
/**
* @brief Sets the callback to receive the authentication information.
* @since_tizen 5.5
+ * @param[in] ah The autofill handle
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
* @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see autofill_auth_info_unset_received_cb()
*/
-int autofill_auth_info_set_received_cb(autofill_auth_info_received_cb callback, void *user_data);
+int autofill_auth_info_set_received_cb(autofill_h ah, autofill_auth_info_received_cb callback, void *user_data);
/**
* @brief Unsets the callback to receive the authentication information.
* @since_tizen 5.5
+ * @param[in] ah The autofill handle
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
+ * @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see autofill_auth_info_set_received_cb()
*/
-int autofill_auth_info_unset_received_cb(void);
+int autofill_auth_info_unset_received_cb(autofill_h ah);
/**
* @brief Sends fill request to fill out each input form.
* @since_tizen 5.5
+ * @param[in] ah The autofill handle
* @param[in] vi The autofill view info handle
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
* @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUTOFILL_ERROR_NOT_INITIALIZED Not initialized
* @retval #AUTOFILL_ERROR_OPERATION_FAILED Operation failure
*/
-int autofill_fill_request(autofill_view_info_h vi);
+int autofill_fill_request(autofill_h ah, autofill_view_info_h vi);
/**
* @brief Sets the callback to receive autofill fill response.
* @since_tizen 5.5
+ * @param[in] ah The autofill handle
* @param[in] callback The callback function to register
* @param[in] user_data The user data to be passed to the callback function
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
* @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see autofill_fill_response_unset_received_cb()
*/
-int autofill_fill_response_set_received_cb(autofill_fill_response_received_cb callback, void *user_data);
+int autofill_fill_response_set_received_cb(autofill_h ah, autofill_fill_response_received_cb callback, void *user_data);
/**
* @brief Unsets the callback to receive autofill fill response.
* @since_tizen 5.5
+ * @param[in] ah The autofill handle
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
+ * @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
*/
-int autofill_fill_response_unset_received_cb(void);
+int autofill_fill_response_unset_received_cb(autofill_h ah);
/**
* @brief Sends the autofill save view info.
* @since_tizen 5.5
+ * @param[in] ah The autofill handle
* @param[in] vi The autofill save view info handle
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
* @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #AUTOFILL_ERROR_NOT_INITIALIZED Not initialized
* @retval #AUTOFILL_ERROR_OPERATION_FAILED Operation failure
*/
-int autofill_commit(autofill_save_view_info_h vi);
+int autofill_commit(autofill_h ah, autofill_save_view_info_h vi);
/**
* @}
#define __TIZEN_UIX_AUTOFILL_PRIVATE_H__
#include <Eina.h>
+#include "autofill.h"
+#include "../client/autofill_proxy.h"
+
+struct autofill_s {
+ rpc_port_proxy_AutofillAppPort_h rpc_h;
+
+ unsigned int context_id;
+
+ autofill_connection_status_changed_cb connection_callback;
+ void *connection_userdata;
+
+ autofill_fill_response_received_cb autofill_fill_response_received_cb;
+ void *autofill_fill_response_data;
+
+ autofill_auth_info_received_cb autofill_auth_info_received_cb;
+ void *autofill_auth_info_data;
+};
struct autofill_view_info_s {
char *app_id; // app ID
Eina_List *autofill_fill_response_item_list; // autofill_fill_response_item_h list
};
-#endif /* __TIZEN_UIX_AUTOFILL_PRIVATE_H__ */
+#endif /* __TIZEN_UIX_AUTOFILL_PRIVATE_H__ */
\ No newline at end of file
* @brief Called when receiving authentication information request.
* @since_tizen 5.5
* @remarks @a vi should not be freed and can be used only in the callback.
+ * @param[in] context_id The autofill context identification value of an associated autofill client handle
* @param[in] vi The autofill view info handle
* @param[in] user_data The user data passed from the callback function
* @see autofill_service_set_auth_info_requested_cb()
*/
-typedef void (*autofill_service_auth_info_requested_cb)(autofill_view_info_h vi, void *user_data);
+typedef void (*autofill_service_auth_info_requested_cb)(int context_id, autofill_view_info_h vi, void *user_data);
/**
* @brief Called when receiving fill request.
* @since_tizen 5.5
* @remarks @a vi should not be freed and can be used only in the callback.
+ * @param[in] context_id The autofill context identification value of an associated autofill client handle
* @param[in] vi The autofill view info handle
* @param[in] user_data The user data passed from the callback function
* @see autofill_service_set_auth_info_requested_cb()
*/
-typedef void (*autofill_service_fill_requested_cb)(autofill_view_info_h vi, void *user_data);
+typedef void (*autofill_service_fill_requested_cb)(int context_id, autofill_view_info_h vi, void *user_data);
/**
* @brief Called when receiving commit request.
* @since_tizen 5.5
* @remarks @a vi should not be freed and can be used only in the callback.
+ * @param[in] context_id The autofill context identification value of an associated autofill client handle
* @param[in] vi The autofill save view info handle
* @param[in] user_data The user data passed from the callback function
* @see autofill_service_set_commited_cb()
*/
-typedef void (*autofill_service_commited_cb)(autofill_save_view_info_h vi, void *user_data);
+typedef void (*autofill_service_commited_cb)(int context_id, autofill_save_view_info_h vi, void *user_data);
/**
* @brief Called when receiving terminate request.
/**
* @brief Sends the authentication information.
* @since_tizen 5.5
+ * @param[in] context_id The autofill context identification value of an associated autofill client handle
* @param[in] h The autofill authentication info handle
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
* @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
*/
-int autofill_service_send_auth_info(autofill_auth_info_h h);
+int autofill_service_send_auth_info(int context_id, autofill_auth_info_h h);
/**
* @brief Sets the callback to receive the fill request.
/**
* @brief Sends the fill response.
* @since_tizen 5.5
+ * @param[in] context_id The autofill context identification value of an associated autofill client handle
* @param[in] h The autofill fill response handle
* @return 0 on success, otherwise a negative error value
* @retval #AUTOFILL_ERROR_NONE No error
* @retval #AUTOFILL_ERROR_INVALID_PARAMETER Invalid parameter
*/
-int autofill_service_send_fill_response(autofill_fill_response_h h);
+int autofill_service_send_fill_response(int context_id, autofill_fill_response_h h);
/**
* @brief Sets the callback to receive the commit request.
#define LOG_TAG "AUTOFILL_DAEMON"
-static rpc_port_proxy_AutofillSvcPort_h rpc_h = NULL;
+static rpc_port_proxy_AutofillSvcPort_h svc_rpc_h = NULL;
static int connect_service();
typedef struct {
char *app_id;
+ int context_id;
rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_cb;
rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_received_cb;
static GList *__client_list = NULL;
static autofill_client_s *
-get_autofill_client(const char *app_id)
+get_autofill_client(const char *app_id, int context_id)
{
GList *iter;
autofill_client_s *client;
continue;
}
- if (client->app_id && strcmp(client->app_id, app_id) == 0) {
+ if ((client->context_id == context_id) &&
+ client->app_id && strcmp(client->app_id, app_id) == 0) {
return client;
}
}
return NULL;
}
-static autofill_client_s *__create_client(const char *app_id,
+static autofill_client_s *__create_client(const char *app_id, int context_id,
rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_cb,
rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_received_cb)
{
return NULL;
}
+ handle->context_id = context_id;
+
rpc_port_AutofillAppPort_autofill_auth_info_received_cb_clone(auth_info_cb, &handle->auth_info_cb);
if (!handle->auth_info_cb) {
LOGE("Out of memory");
if (!sender)
return;
- LOGD("[__RPC_PORT__] sender(%s)", sender);
+ LOGD("sender(%s)", sender);
free(sender);
}
__remove_client(context);
}
-static int __message_register(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_cb, rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_received_cb, void *user_data)
+static int __message_register(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_cb, rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_received_cb, void *user_data)
{
LOGD("");
char *sender = NULL;
LOGD("sender(%s)", sender);
- client = __create_client(sender, auth_info_cb, fill_response_received_cb);
+ client = __create_client(sender, context_id, auth_info_cb, fill_response_received_cb);
free(sender);
if (!client)
return 0;
}
-static void __message_unregister(rpc_port_stub_AutofillAppPort_context_h context, void *user_data)
+static void __message_unregister(rpc_port_stub_AutofillAppPort_context_h context, int context_id, void *user_data)
{
__remove_client(context);
}
return true;
}
-static int __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data)
+static int __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_view_info_h vi, void *user_data)
{
char *sender = NULL;
autofill_client_s *sender_client;
- if (!rpc_h) {
+ if (!svc_rpc_h) {
LOGW("Not initialized");
return -1;
}
rpc_port_autofill_view_info_foreach_items(vi, __view_info_item_cb, svi);
- rpc_port_proxy_AutofillSvcPort_invoke_request_auth_info(rpc_h, svi);
+ rpc_port_proxy_AutofillSvcPort_invoke_request_auth_info(svc_rpc_h, context_id, svi);
if (sender) {
free(sender);
return 0;
}
-static int __autofill_fill_request_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data)
+static int __autofill_fill_request_cb(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_view_info_h vi, void *user_data)
{
char *sender = NULL;
char *view_id = NULL;
- if (!rpc_h) {
+ if (!svc_rpc_h) {
LOGW("Not initialized");
return -1;
}
rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender);
rpc_port_autofill_view_info_get_view_id(vi, &view_id);
- LOGD("app id : %s, view id : %s", sender, view_id);
+ LOGD("app id : %s, view id : %s, context id : %d", sender, view_id, context_id);
rpc_port_autofill_svc_view_info_h svi;
rpc_port_autofill_svc_view_info_create(&svi);
rpc_port_autofill_view_info_foreach_items(vi, __view_info_item_cb, svi);
- rpc_port_proxy_AutofillSvcPort_invoke_send_fill_request(rpc_h, svi);
+ rpc_port_proxy_AutofillSvcPort_invoke_send_fill_request(svc_rpc_h, context_id, svi);
if (sender)
free(sender);
return 0;
}
-static int __commit_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_save_view_info_h vi, void *user_data)
+static int __commit_cb(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_save_view_info_h vi, void *user_data)
{
char *sender = NULL;
autofill_client_s *sender_client;
- if (!rpc_h) {
+ if (!svc_rpc_h) {
LOGW("Not initialized");
return -1;
}
rpc_port_stub_AutofillAppPort_context_get_tag(context, (void *)&sender_client);
rpc_port_autofill_save_view_info_foreach_items(vi, __save_item_cb, svi);
- rpc_port_proxy_AutofillSvcPort_invoke_commit(rpc_h, svi);
+ rpc_port_proxy_AutofillSvcPort_invoke_commit(svc_rpc_h, context_id, svi);
if (view_id)
free(view_id);
return true;
}
-static void __fill_response_recv_cb(void *user_data, rpc_port_autofill_svc_fill_response_h response_h)
+static void __fill_response_recv_cb(void *user_data, int context_id, rpc_port_autofill_svc_fill_response_h response_h)
{
// recv fill response from service
char *view_id = NULL;
rpc_port_autofill_svc_fill_response_foreach_response_groups(response_h, fill_response_group_cb, fill_response_h);
- autofill_client_s *sender_client = get_autofill_client(app_id);
+ autofill_client_s *sender_client = get_autofill_client(app_id, context_id);
if (sender_client)
rpc_port_AutofillAppPort_autofill_fill_response_received_cb_invoke(sender_client->fill_response_received_cb, fill_response_h);
free(view_id);
}
-static void __auth_info_recv_cb(void *user_data, rpc_port_autofill_svc_auth_info_h svc_auth_info_h)
+static void __auth_info_recv_cb(void *user_data, int context_id, rpc_port_autofill_svc_auth_info_h svc_auth_info_h)
{
bool exist_autofill_data;
bool need_authentication;
rpc_port_autofill_auth_info_set_service_message(auth_info_h, service_message);
rpc_port_autofill_auth_info_set_service_logo_image_path(auth_info_h, service_logo_image_path);
- autofill_client_s *sender_client = get_autofill_client(app_id);
+ autofill_client_s *sender_client = get_autofill_client(app_id, context_id);
if (sender_client)
rpc_port_AutofillAppPort_autofill_auth_info_received_cb_invoke(sender_client->auth_info_cb, auth_info_h);
{
LOGD("disconnected");
- rpc_h = NULL;
+ svc_rpc_h = NULL;
}
static void __on_rejected(rpc_port_proxy_AutofillSvcPort_h h, void *user_data)
if (app_id)
autofill_config_set_autofill_service_app_id(app_id);
- if (rpc_h) {
+ if (svc_rpc_h) {
LOGD("send terminate");
// terminate service
- rpc_port_proxy_AutofillSvcPort_invoke_request_terminate(rpc_h);
+ rpc_port_proxy_AutofillSvcPort_invoke_request_terminate(svc_rpc_h);
- int ret = rpc_port_proxy_AutofillSvcPort_destroy(rpc_h);
+ int ret = rpc_port_proxy_AutofillSvcPort_destroy(svc_rpc_h);
LOGD("ret : %d", ret);
}
- rpc_h = NULL;
+ svc_rpc_h = NULL;
connect_service();
static char * __manager_get_autofill_service_cb(rpc_port_stub_AutofillManagerPort_context_h context, void *user_data)
{
- if (!rpc_h) {
+ if (!svc_rpc_h) {
LOGW("Not initialized");
return false;
}
.rejected = __on_rejected
};
- if (rpc_h) {
+ if (svc_rpc_h) {
LOGI("already connected\n");
return RPC_PORT_ERROR_NONE;
}
service_id_len = strlen(active_autofill_service_id);
if (service_id_len > 0) {
- ret = rpc_port_proxy_AutofillSvcPort_create(active_autofill_service_id, &rpc_callback, NULL, &rpc_h);
+ ret = rpc_port_proxy_AutofillSvcPort_create(active_autofill_service_id, &rpc_callback, NULL, &svc_rpc_h);
}
free(active_autofill_service_id);
}
}
- ret = rpc_port_proxy_AutofillSvcPort_connect(rpc_h);
+ ret = rpc_port_proxy_AutofillSvcPort_connect(svc_rpc_h);
if (ret != RPC_PORT_ERROR_NONE) {
LOGW("Failed to connect. err = %d", ret);
return false;
return true;
}
-static void __auth_info_request_cb(rpc_port_stub_AutofillSvcPort_context_h context, rpc_port_autofill_svc_view_info_h vi, void *user_data)
+static void __auth_info_request_cb(rpc_port_stub_AutofillSvcPort_context_h context, int context_id, rpc_port_autofill_svc_view_info_h vi, void *user_data)
{
char *sender = NULL;
rpc_port_autofill_svc_view_info_foreach_items(vi, __autofill_item_cb, view_info);
if (g_autofill_service_auth_info_requested_cb)
- g_autofill_service_auth_info_requested_cb(view_info, g_autofill_service_auth_info_request_data);
+ g_autofill_service_auth_info_requested_cb(context_id, view_info, g_autofill_service_auth_info_request_data);
autofill_view_info_destroy(view_info);
free(app_id);
}
-static void __autofill_fill_request_cb(rpc_port_stub_AutofillSvcPort_context_h context, rpc_port_autofill_svc_view_info_h vi, void *user_data)
+static void __autofill_fill_request_cb(rpc_port_stub_AutofillSvcPort_context_h context, int context_id, rpc_port_autofill_svc_view_info_h vi, void *user_data)
{
char *app_id = NULL;
char *view_id = NULL;
rpc_port_autofill_svc_view_info_foreach_items(vi, __autofill_item_cb, view_info);
if (g_autofill_service_fill_requested_cb)
- g_autofill_service_fill_requested_cb(view_info, g_autofill_service_auth_info_request_data);
+ g_autofill_service_fill_requested_cb(context_id, view_info, g_autofill_service_auth_info_request_data);
autofill_view_info_destroy(view_info);
free(view_id);
}
-static void __autofill_commit_cb(rpc_port_stub_AutofillSvcPort_context_h context, rpc_port_autofill_svc_save_view_info_h vi, void *user_data)
+static void __autofill_commit_cb(rpc_port_stub_AutofillSvcPort_context_h context, int context_id, rpc_port_autofill_svc_save_view_info_h vi, void *user_data)
{
char *view_id = NULL;
rpc_port_autofill_svc_save_view_info_get_view_id(vi, &view_id);
rpc_port_autofill_svc_save_view_info_foreach_items(vi, __save_item_cb, view_info);
if (g_autofill_service_commited_cb)
- g_autofill_service_commited_cb(view_info, g_autofill_service_commit_data);
+ g_autofill_service_commited_cb(context_id, view_info, g_autofill_service_commit_data);
autofill_save_view_info_destroy(view_info);
EXPORT_API int autofill_service_set_auth_info_requested_cb(autofill_service_auth_info_requested_cb callback, void *user_data)
{
- if (!callback)
+ if (!callback) {
+ LOGW("[ERROR] Invalid parameter");
return AUTOFILL_ERROR_INVALID_PARAMETER;
+ }
g_autofill_service_auth_info_requested_cb = callback;
g_autofill_service_auth_info_request_data = user_data;
return AUTOFILL_ERROR_NONE;
}
-EXPORT_API int autofill_service_send_auth_info(autofill_auth_info_h h)
+EXPORT_API int autofill_service_send_auth_info(int context_id, autofill_auth_info_h h)
{
bool autofill_data_present = false;
bool authentication_needed = false;
int ret = AUTOFILL_ERROR_NONE;
if (!h) {
- LOGW("parameter is NULL");
+ LOGW("[ERROR] Invalid parameter");
return AUTOFILL_ERROR_INVALID_PARAMETER;
}
rpc_port_autofill_svc_auth_info_set_service_message(auth_info_h, service_message);
rpc_port_autofill_svc_auth_info_set_service_logo_image_path(auth_info_h, service_logo_image_path);
- ret = rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_invoke(g_auth_info_cb, auth_info_h);
+ ret = rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_invoke(g_auth_info_cb, context_id, auth_info_h);
if (app_id)
free(app_id);
// fill request
EXPORT_API int autofill_service_set_fill_requested_cb(autofill_service_fill_requested_cb callback, void *user_data)
{
- if (!callback)
- return AUTOFILL_ERROR_INVALID_PARAMETER;
+ if (!callback) {
+ LOGW("[ERROR] Invalid parameter");
+ return AUTOFILL_ERROR_INVALID_PARAMETER;
+ }
g_autofill_service_fill_requested_cb = callback;
g_autofill_service_fill_request_data = user_data;
return true;
}
-EXPORT_API int autofill_service_send_fill_response(autofill_fill_response_h h)
+EXPORT_API int autofill_service_send_fill_response(int context_id, autofill_fill_response_h h)
{
/* create autofill response */
rpc_port_autofill_svc_fill_response_h fill_response_h;
autofill_fill_response_group_h it;
if (!h) {
- LOGW("parameter is NULL");
+ LOGW("[ERROR] Invalid parameter");
return AUTOFILL_ERROR_INVALID_PARAMETER;
}
rpc_port_autofill_svc_response_group_destroy(res_group_h);
}
- ret = rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_invoke(g_fill_response_received_cb, fill_response_h);
+ ret = rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_invoke(g_fill_response_received_cb, context_id, fill_response_h);
rpc_port_autofill_svc_fill_response_destroy(fill_response_h);
EXPORT_API int autofill_service_set_commited_cb(autofill_service_commited_cb callback, void *user_data)
{
- if (!callback)
+ if (!callback) {
+ LOGW("[ERROR] Invalid parameter");
return AUTOFILL_ERROR_INVALID_PARAMETER;
+ }
g_autofill_service_commited_cb = callback;
g_autofill_service_commit_data = user_data;
interface AutofillAppPort {
void autofill_auth_info_received_cb(autofill_auth_info auth_info) delegate;
void autofill_fill_response_received_cb(autofill_fill_response response) delegate;
- int Register(autofill_auth_info_received_cb auth_info_cb, autofill_fill_response_received_cb fill_response_cb);
- void Unregister() async;
+ int Register(int context_id, autofill_auth_info_received_cb auth_info_cb, autofill_fill_response_received_cb fill_response_cb);
+ void Unregister(int context_id) async;
- int request_auth_info(autofill_view_info vi);
- int send_fill_request(autofill_view_info vi);
- int commit(autofill_save_view_info vi);
+ int request_auth_info(int context_id, autofill_view_info vi);
+ int send_fill_request(int context_id, autofill_view_info vi);
+ int commit(int context_id, autofill_save_view_info vi);
}
}
interface AutofillSvcPort {
- void autofill_svc_auth_info_cb(autofill_svc_auth_info auth_info) delegate;
- void autofill_svc_fill_response_cb(autofill_svc_fill_response response) delegate;
+ void autofill_svc_auth_info_cb(int context_id, autofill_svc_auth_info auth_info) delegate;
+ void autofill_svc_fill_response_cb(int context_id, autofill_svc_fill_response response) delegate;
int Register(autofill_svc_auth_info_cb auth_info_cb, autofill_svc_fill_response_cb fill_response_cb);
void Unregister() async;
- void request_auth_info(autofill_svc_view_info vi) async;
- void send_fill_request(autofill_svc_view_info vi) async;
- void commit(autofill_svc_save_view_info si) async;
+ void request_auth_info(int context_id, autofill_svc_view_info vi) async;
+ void send_fill_request(int context_id, autofill_svc_view_info vi) async;
+ void commit(int context_id, autofill_svc_save_view_info si) async;
void request_terminate() async;
}