src/autofill-daemon.c
src/autofill_config.c
src/autofill_request_list.c
+ src/autofill_client.c
+ src/autofill_client_list.c
src/autofill_stub.c
src/autofill_manager_stub.c
src/autofill_service_proxy.c
#include "autofill_stub.h"
#include "autofill_service_proxy.h"
#include "autofill_manager_stub.h"
+#include "autofill_client_list.h"
#include "autofill_config.h"
#include "autofill_request_item.h"
#include "autofill_request_list.h"
static rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb_h = NULL;
static rpc_port_AutofillSvcPort_autofill_svc_send_error_cb_h error_info_cb_h = NULL;
-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;
- rpc_port_AutofillAppPort_autofill_error_info_received_cb_h error_info_cb;
-} autofill_client_s;
-
-static GList *__client_list = NULL;
static Ecore_Timer *g_connect_timer = NULL;
static bool g_autofill_service_connected = false;
static bool connect_service();
static void terminate_autofill_service();
-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,
- rpc_port_AutofillAppPort_autofill_error_info_received_cb_h error_info_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;
- }
-
- rpc_port_AutofillAppPort_autofill_error_info_received_cb_clone(error_info_cb, &handle->error_info_cb);
- if (!handle->error_info_cb) {
- LOGE("Out of memory");
- free(handle->app_id);
- rpc_port_AutofillAppPort_autofill_auth_info_received_cb_destroy(handle->auth_info_cb);
- rpc_port_AutofillAppPort_autofill_fill_response_received_cb_destroy(handle->fill_response_received_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->error_info_cb) {
- rpc_port_AutofillAppPort_autofill_error_info_received_cb_destroy(handle->error_info_cb);
- handle->error_info_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;
LOGI("name(%s)", client->app_id);
- __client_list = g_list_remove(__client_list, client);
- __destroy_client(client);
+ guint client_list_size = remove_autofill_client_list(client);
+ destroy_autofill_client(client);
- if (g_list_length(__client_list) == 0) {
+ if (client_list_size == 0) {
terminate_autofill_service();
LOGI("terminate autofill daemon");
LOGD("sender(%s)", sender);
- client = __create_client(sender, context_id, auth_info_cb, fill_response_received_cb, error_info_cb);
+ client = create_autofill_client(sender, context_id, auth_info_cb, fill_response_received_cb, error_info_cb);
free(sender);
if (!client)
return -1;
- __client_list = g_list_append(__client_list, client);
+ add_autofill_client_list(client);
rpc_port_stub_AutofillAppPort_context_set_tag(context, client);
// Todo: add your code here.
LOGD("");
- if (__client_list) {
- g_list_free_full(__client_list, __destroy_client);
- __client_list = NULL;
- }
+ remove_all_client_list();
remove_all_pending_request_item_list();
--- /dev/null
+ /*
+ * Copyright (c) 2020 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 <stdio.h>
+#include <glib.h>
+#include <dlog.h>
+
+#include "autofill_daemon_dlog.h"
+#include "autofill_stub.h"
+#include "autofill_client.h"
+
+autofill_client_s *create_autofill_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,
+ rpc_port_AutofillAppPort_autofill_error_info_received_cb_h error_info_cb)
+{
+ LOGD("");
+ autofill_client_s *ac;
+
+ ac = calloc(1, sizeof(autofill_client_s));
+ if (!ac) {
+ LOGE("Out of memory");
+ return NULL;
+ }
+
+ ac->app_id = strdup(app_id);
+ if (!ac->app_id) {
+ LOGE("Out of memory");
+ free(ac);
+ return NULL;
+ }
+
+ ac->context_id = context_id;
+
+ rpc_port_AutofillAppPort_autofill_auth_info_received_cb_clone(auth_info_cb, &ac->auth_info_cb);
+ if (!ac->auth_info_cb) {
+ LOGE("Out of memory");
+ free(ac->app_id);
+ free(ac);
+ return NULL;
+ }
+
+ rpc_port_AutofillAppPort_autofill_fill_response_received_cb_clone(fill_response_received_cb, &ac->fill_response_received_cb);
+
+ if (!ac->fill_response_received_cb) {
+ LOGE("Out of memory");
+ free(ac->app_id);
+ rpc_port_AutofillAppPort_autofill_auth_info_received_cb_destroy(ac->auth_info_cb);
+ free(ac);
+ return NULL;
+ }
+
+ rpc_port_AutofillAppPort_autofill_error_info_received_cb_clone(error_info_cb, &ac->error_info_cb);
+ if (!ac->error_info_cb) {
+ LOGE("Out of memory");
+ free(ac->app_id);
+ rpc_port_AutofillAppPort_autofill_auth_info_received_cb_destroy(ac->auth_info_cb);
+ rpc_port_AutofillAppPort_autofill_fill_response_received_cb_destroy(ac->fill_response_received_cb);
+ free(ac);
+ return NULL;
+ }
+
+ return ac;
+}
+
+void destroy_autofill_client(autofill_client_s *ac)
+{
+ LOGD("");
+
+ if (!ac)
+ return;
+
+ if (ac->auth_info_cb) {
+ rpc_port_AutofillAppPort_autofill_auth_info_received_cb_destroy(ac->auth_info_cb);
+ ac->auth_info_cb = NULL;
+ }
+
+ if (ac->fill_response_received_cb) {
+ rpc_port_AutofillAppPort_autofill_fill_response_received_cb_destroy(ac->fill_response_received_cb);
+ ac->fill_response_received_cb = NULL;
+ }
+
+ if (ac->error_info_cb) {
+ rpc_port_AutofillAppPort_autofill_error_info_received_cb_destroy(ac->error_info_cb);
+ ac->error_info_cb = NULL;
+ }
+
+ if (ac->app_id) {
+ free(ac->app_id);
+ ac->app_id = NULL;
+ }
+
+ free(ac);
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 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.
+ */
+
+#ifndef __AUTOFILL_CLIENT_H__
+#define __AUTOFILL_CLIENT_H__
+
+#include "autofill_stub.h"
+
+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;
+ rpc_port_AutofillAppPort_autofill_error_info_received_cb_h error_info_cb;
+} autofill_client_s;
+
+autofill_client_s *create_autofill_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,
+ rpc_port_AutofillAppPort_autofill_error_info_received_cb_h error_info_cb);
+
+void destroy_autofill_client(autofill_client_s *ac);
+
+#endif /* __AUTOFILL_CLIENT_H__ */
--- /dev/null
+ /*
+ * Copyright (c) 2020 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 <stdio.h>
+#include <glib.h>
+#include <dlog.h>
+
+#include "autofill_daemon_dlog.h"
+#include "autofill_client.h"
+
+static GList *__client_list = NULL;
+
+guint add_autofill_client_list(autofill_client_s *ac)
+{
+ __client_list = g_list_append(__client_list, ac);
+ return g_list_length(__client_list);
+}
+
+guint remove_autofill_client_list(autofill_client_s *ac)
+{
+ __client_list = g_list_remove(__client_list, ac);
+ return g_list_length(__client_list);
+}
+
+static void destroy_each_client(gpointer data)
+{
+ destroy_autofill_client((autofill_client_s *)data);
+}
+
+void remove_all_client_list()
+{
+ if (__client_list) {
+ g_list_free_full(__client_list, destroy_each_client);
+ __client_list = NULL;
+ }
+}
+
+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;
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2020 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.
+ */
+
+#ifndef __AUTOFILL_CLIENT_LIST_H__
+#define __AUTOFILL_CLIENT_LIST_H__
+
+#include <glib.h>
+#include "autofill_stub.h"
+#include "autofill_client.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+guint add_autofill_client_list(autofill_client_s *ac);
+guint remove_autofill_client_list(autofill_client_s *ac);
+
+void remove_all_client_list();
+autofill_client_s *get_autofill_client(const char *app_id, int context_id);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __AUTOFILL_CLIENT_LIST_H__ */