+++ /dev/null
- /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <tizen.h>
-#include <stdlib.h>
-#include <service_app.h>
-#include <dlog.h>
-#include <glib.h>
-#include <rpc-port.h>
-#include <app_manager.h>
-
-#include "autofill_stub.h"
-#include "autofill_service_proxy.h"
-#include "autofill_manager_stub.h"
-#include "autofill_config.h"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "AUTOFILL_DAEMON"
-
-
-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;
-} autofill_client_s;
-
-static GList *__client_list = NULL;
-
-static autofill_client_s *
-get_autofill_client(const char *app_id, int context_id)
-{
- GList *iter;
- autofill_client_s *client;
-
- iter = __client_list;
- while (iter) {
- client = iter->data;
-
- iter = g_list_next(iter);
-
- if (!client) {
- LOGW("Warning: value is NULL");
- continue;
- }
-
- 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, 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)
-{
- LOGD("");
- autofill_client_s *handle;
-
- handle = calloc(1, sizeof(autofill_client_s));
- if (!handle) {
- LOGE("Out of memory");
- return NULL;
- }
-
- handle->app_id = strdup(app_id);
- if (!handle->app_id) {
- LOGE("Out of memory");
- free(handle);
- 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");
- free(handle->app_id);
- free(handle);
- return NULL;
- }
-
- rpc_port_AutofillAppPort_autofill_fill_response_received_cb_clone(fill_response_received_cb, &handle->fill_response_received_cb);
-
- if (!handle->fill_response_received_cb) {
- LOGE("Out of memory");
- free(handle->app_id);
- rpc_port_AutofillAppPort_autofill_auth_info_received_cb_destroy(handle->auth_info_cb);
- free(handle);
- return NULL;
- }
-
- return handle;
-}
-
-static void __destroy_client(gpointer data)
-{
- LOGD("");
- autofill_client_s *handle = data;
-
- if (!handle)
- return;
-
- if (handle->auth_info_cb) {
- rpc_port_AutofillAppPort_autofill_auth_info_received_cb_destroy(handle->auth_info_cb);
- handle->auth_info_cb = NULL;
- }
-
- if (handle->fill_response_received_cb) {
- rpc_port_AutofillAppPort_autofill_fill_response_received_cb_destroy(handle->fill_response_received_cb);
- handle->fill_response_received_cb = NULL;
- }
-
- if (handle->app_id) {
- free(handle->app_id);
- handle->app_id = NULL;
- }
-
- free(handle);
-}
-
-static void __remove_client(rpc_port_stub_AutofillAppPort_context_h context)
-{
- autofill_client_s *client = NULL;
- rpc_port_stub_AutofillAppPort_context_get_tag(context, (void *)&client);
- if (!client)
- return;
-
- rpc_port_stub_AutofillAppPort_context_set_tag(context, NULL);
-
- LOGI("name(%s)", client->app_id);
-
- __client_list = g_list_remove(__client_list, client);
- __destroy_client(client);
-}
-
-static void __message_create(rpc_port_stub_AutofillAppPort_context_h context,
- void *user_data)
-{
- LOGD("");
- char *sender = NULL;
-
- rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender);
- if (!sender)
- return;
-
- LOGD("sender(%s)", sender);
- free(sender);
-}
-
-static void __message_terminate(rpc_port_stub_AutofillAppPort_context_h context,
- void *user_data)
-{
- LOGD("");
- char *sender = NULL;
-
- rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender);
- if (!sender)
- return;
-
- LOGD("[__RPC_PORT__] sender(%s)", sender);
- free(sender);
-
- __remove_client(context);
-}
-
-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;
- autofill_client_s *client = NULL;
-
- rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender);
- if (!sender)
- return -1;
-
- LOGD("sender(%s)", sender);
-
- client = __create_client(sender, context_id, auth_info_cb, fill_response_received_cb);
- free(sender);
-
- if (!client)
- return -1;
-
- __client_list = g_list_append(__client_list, client);
-
- rpc_port_stub_AutofillAppPort_context_set_tag(context, client);
-
- return 0;
-}
-
-static void __message_unregister(rpc_port_stub_AutofillAppPort_context_h context, int context_id, void *user_data)
-{
- __remove_client(context);
-}
-
-static void __manager_create(rpc_port_stub_AutofillManagerPort_context_h context,
- void *user_data)
-{
- LOGD("");
-}
-
-static void __manager_terminate(rpc_port_stub_AutofillManagerPort_context_h context,
- void *user_data)
-{
- LOGD("");
-}
-
-bool __view_info_item_cb(rpc_port_autofill_item_h items, void *user_data)
-{
- char *id = NULL;
- char *label = NULL;
- char *value = NULL;
- int autofill_hint;
- bool sensitive_data;
-
- rpc_port_autofill_svc_view_info_h svi = (rpc_port_autofill_svc_view_info_h)user_data;
-
- rpc_port_autofill_svc_item_h svc_item;
-
- rpc_port_autofill_svc_item_create(&svc_item);
-
- rpc_port_autofill_item_get_id(items, &id);
- rpc_port_autofill_svc_item_set_id(svc_item, id);
- if (id) {
- LOGD("id : %s", id);
- free(id);
- }
-
- rpc_port_autofill_item_get_label(items, &label);
- rpc_port_autofill_svc_item_set_label(svc_item, label);
- if (label) {
- LOGD("label : %s", label);
- free(label);
- }
-
- rpc_port_autofill_item_get_value(items, &value);
- rpc_port_autofill_svc_item_set_value(svc_item, value);
- if (value) {
- LOGD("value : %s", value);
- free(value);
- }
-
- rpc_port_autofill_item_get_autofill_hint(items, &autofill_hint);
- rpc_port_autofill_svc_item_set_autofill_hint(svc_item, autofill_hint);
- LOGD("autofill hint : %d", autofill_hint);
-
- rpc_port_autofill_item_get_is_sensitive_data(items, &sensitive_data);
- rpc_port_autofill_svc_item_set_is_sensitive_data(svc_item, sensitive_data);
- LOGD("sensitive data : %d", sensitive_data);
-
- rpc_port_autofill_svc_view_info_add_items(svi, svc_item);
-
- rpc_port_autofill_svc_item_destroy(svc_item);
-
- return true;
-}
-
-bool __save_item_cb(rpc_port_autofill_save_item_h items, void *user_data)
-{
- char *id = NULL;
- char *label = NULL;
- char *value = NULL;
- int autofill_hint;
- bool sensitive_data;
-
- rpc_port_autofill_svc_save_view_info_h svi = (rpc_port_autofill_svc_save_view_info_h)user_data;
-
- rpc_port_autofill_svc_save_item_h svc_save_item;
-
- rpc_port_autofill_svc_save_item_create(&svc_save_item);
-
- rpc_port_autofill_save_item_get_id(items, &id);
- rpc_port_autofill_svc_save_item_set_id(svc_save_item, id);
- if (id) {
- LOGD("id : %s", id);
- free(id);
- }
-
- rpc_port_autofill_save_item_get_label(items, &label);
- rpc_port_autofill_svc_save_item_set_label(svc_save_item, label);
- if (label) {
- LOGD("label : %s", label);
- free(label);
- }
-
- rpc_port_autofill_save_item_get_value(items, &value);
- rpc_port_autofill_svc_save_item_set_value(svc_save_item, value);
- if (value) {
- LOGD("value : %s", value);
- free(value);
- }
-
- rpc_port_autofill_save_item_get_autofill_hint(items, &autofill_hint);
- rpc_port_autofill_svc_save_item_set_autofill_hint(svc_save_item, autofill_hint);
- LOGD("autofill hint : %d", autofill_hint);
-
- rpc_port_autofill_save_item_get_is_sensitive_data(items, &sensitive_data);
- rpc_port_autofill_svc_save_item_set_is_sensitive_data(svc_save_item, sensitive_data);
- LOGD("sensitive data : %d", sensitive_data);
-
- rpc_port_autofill_svc_save_view_info_add_items(svi, svc_save_item);
-
- rpc_port_autofill_svc_save_item_destroy(svc_save_item);
-
- return true;
-}
-
-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 (!svc_rpc_h) {
- LOGW("Not initialized");
- return 0;
- }
-
- rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender);
- char *view_id = NULL;
-
- rpc_port_autofill_view_info_get_view_id(vi, &view_id);
- LOGD("app id : %s, view id : %s", sender, view_id);
-
- rpc_port_stub_AutofillAppPort_context_get_tag(context, (void *)&sender_client);
-
- /* create view info */
- rpc_port_autofill_svc_view_info_h svi;
- rpc_port_autofill_svc_view_info_create(&svi);
- rpc_port_autofill_svc_view_info_set_app_id(svi, sender);
- rpc_port_autofill_svc_view_info_set_view_id(svi, view_id);
-
- rpc_port_autofill_view_info_foreach_items(vi, __view_info_item_cb, svi);
-
- rpc_port_proxy_AutofillSvcPort_invoke_request_auth_info(svc_rpc_h, context_id, svi);
-
- if (sender) {
- free(sender);
- }
-
- if (view_id) {
- free(view_id);
- }
-
- rpc_port_autofill_svc_view_info_destroy(svi);
-
- return 0;
-}
-
-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 (!svc_rpc_h) {
- LOGW("Not initialized");
- return 0;
- }
-
- 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, 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_svc_view_info_set_app_id(svi, sender);
- rpc_port_autofill_svc_view_info_set_view_id(svi, view_id);
-
- rpc_port_autofill_view_info_foreach_items(vi, __view_info_item_cb, svi);
-
- rpc_port_proxy_AutofillSvcPort_invoke_send_fill_request(svc_rpc_h, context_id, svi);
-
- if (sender)
- free(sender);
-
- if (view_id)
- free(view_id);
-
- rpc_port_autofill_svc_view_info_destroy(svi);
-
- return 0;
-}
-
-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 (!svc_rpc_h) {
- LOGW("Not initialized");
- return 0;
- }
-
- rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender);
- if (sender) {
- LOGD("sender(%s)", sender);
- free(sender);
- }
-
- char *view_id = NULL;
- rpc_port_autofill_save_view_info_get_view_id(vi, &view_id);
- if (view_id) {
- LOGD("view id : %s", view_id);
- }
-
- rpc_port_autofill_svc_save_view_info_h svi;
- rpc_port_autofill_svc_save_view_info_create(&svi);
- rpc_port_autofill_svc_save_view_info_set_view_id(svi, view_id);
-
- 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(svc_rpc_h, context_id, svi);
-
- if (view_id)
- free(view_id);
-
- rpc_port_autofill_svc_save_view_info_destroy(svi);
-
- return 0;
-}
-
-bool fill_response_item_cb(rpc_port_autofill_svc_response_item_h response_items, void *user_data)
-{
- rpc_port_autofill_response_group_h res_group = (rpc_port_autofill_response_group_h)user_data;
-
- char *id = NULL;
- char *presentation_text = NULL;
- char *value = NULL;
-
- rpc_port_autofill_response_item_h res_item;
-
- rpc_port_autofill_response_item_create(&res_item);
-
- rpc_port_autofill_svc_response_item_get_id(response_items, &id);
- rpc_port_autofill_response_item_set_id(res_item, id);
-
- rpc_port_autofill_svc_response_item_get_presentation_text(response_items, &presentation_text);
- rpc_port_autofill_response_item_set_presentation_text(res_item, presentation_text);
-
- rpc_port_autofill_svc_response_item_get_value(response_items, &value);
- rpc_port_autofill_response_item_set_value(res_item, value);
-
- LOGD("id : %s, presentation text : %s, value : %s", id, presentation_text, value);
-
- rpc_port_autofill_response_group_add_response_items(res_group, res_item);
-
- if (id)
- free(id);
-
- if (presentation_text)
- free(presentation_text);
-
- if (value)
- free(value);
-
- rpc_port_autofill_response_item_destroy(res_item);
-
- return true;
-}
-
-bool fill_response_group_cb(rpc_port_autofill_svc_response_group_h response_groups, void *user_data)
-{
- rpc_port_autofill_fill_response_h fr_h = (rpc_port_autofill_fill_response_h)user_data;
-
- rpc_port_autofill_response_group_h res_group;
- rpc_port_autofill_response_group_create(&res_group);
-
- rpc_port_autofill_svc_response_group_foreach_response_items(response_groups, fill_response_item_cb, res_group);
-
- rpc_port_autofill_fill_response_add_response_groups(fr_h, res_group);
-
- rpc_port_autofill_response_group_destroy(res_group);
-
- return true;
-}
-
-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;
- char *app_id = NULL;
-
- rpc_port_autofill_svc_fill_response_get_app_id(response_h, &app_id);
- rpc_port_autofill_svc_fill_response_get_view_id(response_h, &view_id);
- LOGD("app id : %s, view id : %s", app_id, view_id);
-
- /* create autofill response */
- rpc_port_autofill_fill_response_h fill_response_h;
- rpc_port_autofill_fill_response_create(&fill_response_h);
- rpc_port_autofill_fill_response_set_view_id(fill_response_h, view_id);
-
- 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, context_id);
- if (sender_client)
- rpc_port_AutofillAppPort_autofill_fill_response_received_cb_invoke(sender_client->fill_response_received_cb, fill_response_h);
-
- rpc_port_autofill_fill_response_destroy(fill_response_h);
-
- if (app_id)
- free(app_id);
-
- if (view_id)
- free(view_id);
-}
-
-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;
- char *service_name = NULL;
- char *service_logo_image_path = NULL;
- char *service_message = NULL;
- char *app_id = NULL;
- char *view_id = NULL;
-
- rpc_port_autofill_svc_auth_info_get_app_id(svc_auth_info_h, &app_id);
- rpc_port_autofill_svc_auth_info_get_view_id(svc_auth_info_h, &view_id);
- rpc_port_autofill_svc_auth_info_get_exist_autofill_data(svc_auth_info_h, &exist_autofill_data);
- rpc_port_autofill_svc_auth_info_get_need_authentication(svc_auth_info_h, &need_authentication);
- rpc_port_autofill_svc_auth_info_get_service_name(svc_auth_info_h, &service_name);
- rpc_port_autofill_svc_auth_info_get_service_logo_image_path(svc_auth_info_h, &service_logo_image_path);
- rpc_port_autofill_svc_auth_info_get_service_message(svc_auth_info_h, &service_message);
-
- LOGD("app id : %s, service name : %s, message : %s, logo path : %s", app_id, service_name, service_message, service_logo_image_path);
-
- /* transfer auth info */
- rpc_port_autofill_auth_info_h auth_info_h;
- rpc_port_autofill_auth_info_create(&auth_info_h);
- rpc_port_autofill_auth_info_set_view_id(auth_info_h, view_id);
- rpc_port_autofill_auth_info_set_exist_autofill_data(auth_info_h, exist_autofill_data);
- rpc_port_autofill_auth_info_set_need_authentication(auth_info_h, need_authentication);
- rpc_port_autofill_auth_info_set_service_name(auth_info_h, service_name);
- 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, context_id);
- if (sender_client)
- rpc_port_AutofillAppPort_autofill_auth_info_received_cb_invoke(sender_client->auth_info_cb, auth_info_h);
-
- rpc_port_autofill_auth_info_destroy(auth_info_h);
-
- if (app_id)
- free(app_id);
-
- if (view_id)
- free(view_id);
-
- if (service_name)
- free(service_name);
-
- if (service_logo_image_path)
- free(service_logo_image_path);
-
- if (service_message)
- free(service_message);
-}
-
-static void __on_connected(rpc_port_proxy_AutofillSvcPort_h h, void *user_data)
-{
- LOGI("[__RPC_PORT__] connected");
-
- rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_received_cb_h = rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_create(__fill_response_recv_cb, false, NULL);
- rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb_h = rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_create(__auth_info_recv_cb, false, NULL);
-
- int r = rpc_port_proxy_AutofillSvcPort_invoke_Register(h, auth_info_cb_h, fill_response_received_cb_h);
- if (r != 0)
- LOGD("Failed to invoke Register");
-}
-
-//LCOV_EXCL_START
-static void __on_disconnected(rpc_port_proxy_AutofillSvcPort_h h, void *user_data)
-{
- LOGD("disconnected");
-
- svc_rpc_h = NULL;
-}
-
-static void __on_rejected(rpc_port_proxy_AutofillSvcPort_h h, void *user_data)
-{
- LOGD("rejected");
-}
-//LCOV_EXCL_STOP
-
-static bool __manager_set_autofill_service_cb(rpc_port_stub_AutofillManagerPort_context_h context, const char *app_id, void *user_data)
-{
- LOGD("app id : %s", app_id);
-
- if (app_id)
- autofill_config_set_autofill_service_app_id(app_id);
-
- if (svc_rpc_h) {
- LOGD("send terminate");
- // terminate service
- rpc_port_proxy_AutofillSvcPort_invoke_request_terminate(svc_rpc_h);
-
- int ret = rpc_port_proxy_AutofillSvcPort_destroy(svc_rpc_h);
- LOGD("ret : %d", ret);
- }
-
- svc_rpc_h = NULL;
-
- connect_service();
-
- return true;
-}
-
-static char * __manager_get_autofill_service_cb(rpc_port_stub_AutofillManagerPort_context_h context, void *user_data)
-{
- if (!svc_rpc_h) {
- LOGW("Not initialized");
- return false;
- }
-
- char *app_id;
- autofill_config_get_autofill_service_app_id(&app_id);
-
- LOGD("app id : %s", app_id);
-
- return app_id;
-}
-
-bool add_autofill_service_cb(app_info_h app_info, void *user_data)
-{
- char *app_id = NULL;
- rpc_port_list_string_h service_info_list = (rpc_port_list_string_h)user_data;
-
- int ret = app_info_get_app_id(app_info, &app_id);
- if (ret != APP_MANAGER_ERROR_NONE) {
- LOGW("app_info_get_app_id failed (%d)", ret);
- return true;
- }
-
- LOGD("Find autofill service : %s", app_id);
-
- rpc_port_list_string_add_list_strings(service_info_list, app_id);
-
- if (app_id) {
- free(app_id);
- }
-
- return true;
-}
-
-static bool __manager_get_autofill_service_list_cb(rpc_port_stub_AutofillManagerPort_context_h context, rpc_port_list_string_h *service_info_list, void *user_data)
-{
- int ret;
- app_info_metadata_filter_h handle = NULL;
-
- // Get the Autofill service list
- ret = app_info_metadata_filter_create(&handle);
- if (ret != APP_MANAGER_ERROR_NONE) {
- LOGW("app_info_metadata_filter_create failed (%d)", ret);
- app_info_metadata_filter_destroy(handle);
- return false;
- }
-
- ret = app_info_metadata_filter_add(handle, "autofill-service", "true");
- if (ret != APP_MANAGER_ERROR_NONE) {
- LOGW("app_info_metadata_filter_add failed (%d)", ret);
- app_info_metadata_filter_destroy(handle);
- return false;
- }
-
- rpc_port_list_string_h app_id_list_h;
- rpc_port_list_string_create(&app_id_list_h);
-
- ret = app_info_metadata_filter_foreach(handle, add_autofill_service_cb, app_id_list_h);
- if (ret != APP_MANAGER_ERROR_NONE) {
- LOGW("app_info_metadata_filter_foreach failed (%d)", ret);
- }
-
- *service_info_list = app_id_list_h;
-
- app_info_metadata_filter_destroy(handle);
-
- return true;
-}
-
-static int connect_service()
-{
- int ret;
- size_t service_id_len;
-
- rpc_port_proxy_AutofillSvcPort_callback_s rpc_callback = {
- .connected = __on_connected,
- .disconnected = __on_disconnected,
- .rejected = __on_rejected
- };
-
- if (svc_rpc_h) {
- LOGI("already connected\n");
- return RPC_PORT_ERROR_NONE;
- }
-
- char *active_autofill_service_id = NULL;
- autofill_config_get_autofill_service_app_id(&active_autofill_service_id);
- LOGD("autofill service : '%s'", active_autofill_service_id);
-
- if (!active_autofill_service_id) {
- active_autofill_service_id = strdup(AUTOFILL_SERVICE_APP_ID);
- }
-
- if (active_autofill_service_id) {
- autofill_config_set_autofill_service_app_id(active_autofill_service_id);
- 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, &svc_rpc_h);
- }
- free(active_autofill_service_id);
-
- if (service_id_len == 0) {
- LOGD("No Autofill service to connect");
- return false;
- }
-
- if (ret != RPC_PORT_ERROR_NONE) {
- LOGW("Failed to create rpc port. err = %d", ret);
- return false;
- }
- }
-
- 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 ret;
-}
-
-bool service_app_create(void *data)
-{
- // Todo: add your code here.
- LOGD("");
-
- int ret;
- // register app port
- rpc_port_stub_AutofillAppPort_callback_s callback = {
- __message_create,
- __message_terminate,
- __message_register,
- __message_unregister,
- __auth_info_request_cb,
- __autofill_fill_request_cb,
- __commit_cb,
- };
-
- ret = rpc_port_stub_AutofillAppPort_register(&callback, NULL);
- if (ret != 0)
- LOGI("Failed to register app port");
- else
- LOGI("Succeeded to register app port");
-
- // register manager port
- rpc_port_stub_AutofillManagerPort_callback_s manager_callback = {
- __manager_create,
- __manager_terminate,
- __manager_set_autofill_service_cb,
- __manager_get_autofill_service_cb,
- __manager_get_autofill_service_list_cb,
- };
-
- ret = rpc_port_stub_AutofillManagerPort_register(&manager_callback, NULL);
- if (ret != 0)
- LOGI("Failed to register manager port");
- else
- LOGI("Succeeded to register manager port");
-
- connect_service();
-
- return true;
-}
-
-void service_app_terminate(void *data)
-{
- // Todo: add your code here.
- LOGD("");
-
- if (__client_list) {
- g_list_free_full(__client_list, __destroy_client);
- __client_list = NULL;
- }
-
- rpc_port_stub_AutofillAppPort_unregister();
-
- return;
-}
-
-void service_app_control(app_control_h app_control, void *data)
-{
- // Todo: add your code here.
- return;
-}
-
-static void
-service_app_lang_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LANGUAGE_CHANGED*/
- return;
-}
-
-static void
-service_app_region_changed(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_REGION_FORMAT_CHANGED*/
-}
-
-static void
-service_app_low_battery(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_BATTERY*/
-}
-
-static void
-service_app_low_memory(app_event_info_h event_info, void *user_data)
-{
- /*APP_EVENT_LOW_MEMORY*/
-}
-
-/**
- * Entry point for this application.
- */
-int main(int argc, char *argv[])
-{
- LOGI("BEGIN");
-
- char ad[50] = {0,};
- service_app_lifecycle_callback_s event_callback;
- app_event_handler_h handlers[5] = {NULL, };
-
- event_callback.create = service_app_create;
- event_callback.terminate = service_app_terminate;
- event_callback.app_control = service_app_control;
-
- service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
- service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
-
- return service_app_main(argc, argv, &event_callback, ad);
-}