From: Jihoon Kim Date: Tue, 28 Aug 2018 09:17:18 +0000 (+0900) Subject: initial X-Git-Tag: accepted/tizen/unified/20181106.070517~21 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F22%2F191522%2F2;p=platform%2Fcore%2Fuifw%2Fautofill.git initial Change-Id: I930e1264e99a98a52585253afcdda1e40de3d93a Signed-off-by: Jihoon Kim --- diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..0d7c70c --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Jihoon Kim diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..1d17f5e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,45 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(autofill) + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(EXEC_PREFIX "${PREFIX}") +SET(INCLUDEDIR "${PREFIX}/include") +SET(VERSION 0.2.44) + +FIND_PROGRAM(UNAME NAMES uname) +EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") + +#ADD_DEFINITIONS("-DTTS_LIBDIR=\"${LIBDIR}\"") +ADD_DEFINITIONS("-Werror") + +## Include common directory ## +INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/common") + +## Dependent packages ## +INCLUDE(FindPkgConfig) + +## API ## +#ADD_SUBDIRECTORY(include) + +## Autofill common library ## +ADD_SUBDIRECTORY(common) + +## Client library ## +ADD_SUBDIRECTORY(client) + +## Service library ## +ADD_SUBDIRECTORY(service_lib) + +## Server daemon ## +ADD_SUBDIRECTORY(server) + +## Autofill Service ## +ADD_SUBDIRECTORY(service) + +## Config ## +#INSTALL(FILES ${CMAKE_SOURCE_DIR}/autofill-config.xml DESTINATION ${TZ_SYS_RO_SHARE}/voice/autofill/1.0) + +#INSTALL(FILES ${CMAKE_SOURCE_DIR}/autofill-server.conf DESTINATION /etc/dbus-1/session.d) + +## Sample application ## +ADD_SUBDIRECTORY(test) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7726e77 --- /dev/null +++ b/LICENSE @@ -0,0 +1,204 @@ +Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt new file mode 100644 index 0000000..c275b2b --- /dev/null +++ b/client/CMakeLists.txt @@ -0,0 +1,137 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET(project_prefix "capi") +SET(prefix "/usr") +SET(version "0.0.1") +SET(maintainer "Jihoon Kim ") +SET(description "Autofill APIs") +SET(service "ui") +SET(submodule "autofill") +SET(dependents "dlog eina capi-appfw-application glib-2.0 rpc-port") +SET(LIBDIR ${LIB_INSTALL_DIR}) + +SET(Services + "application" + "base" + "content" + "location" + "media" + "messaging" + "network" + "social" + "telephony" + "system" + "ui" + ) + +#FILE(STRINGS config.cfg configs REGEX "^ *[^#]") +FOREACH(lines ${configs}) +# MESSAGE(${lines}) + IF(${lines} MATCHES "([^=]*)=['\"](.*)['\"]") + SET(key ${CMAKE_MATCH_1}) + SET(value ${CMAKE_MATCH_2}) +# MESSAGE("${key} -> ${value}") + SET(${key} "${value}") + ENDIF() +ENDFOREACH(lines ${configs}) + +LIST(FIND Services ${service} sfind) + +IF( ${sfind} EQUAL -1 ) + MESSAGE(FATAL_ERROR "Service must be one of ") + FOREACH( s IN ${Services} ) + MESSAGE(FATAL_ERROR "[${s}]") + ENDFOREACH( s IN ${Services} ) +ENDIF( ${sfind} EQUAL -1 ) + +SET(fw_name "${project_prefix}-${service}-${submodule}") + +PROJECT(${fw_name} C) + +SET(CMAKE_INSTALL_PREFIX ${prefix}) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(VERSION ${version}) + +SET(INC_DIR ../include) +INCLUDE_DIRECTORIES(${INC_DIR}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_name} REQUIRED ${dependents}) +FOREACH(flag ${${fw_name}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -fpermissive") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") + +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DTIZEN_DEBUG") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") + +aux_source_directory(. SOURCES) +ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) + +TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS} capi-ui-autofill-common) + +SET_TARGET_PROPERTIES(${fw_name} + PROPERTIES + VERSION ${FULLVER} + SOVERSION ${MAJORVER} + CLEAN_DIRECT_OUTPUT 1 +) + +INSTALL(TARGETS ${fw_name} DESTINATION ${LIBDIR}) +INSTALL( + DIRECTORY ${INC_DIR}/ DESTINATION include + FILES_MATCHING + PATTERN "*_private.h" EXCLUDE + PATTERN "${INC_DIR}/*.h" + ) + +SET(PC_NAME ${fw_name}) +SET(PC_REQUIRED ${dependents}) +SET(PC_LDFLAGS -l${fw_name}) + +CONFIGURE_FILE( + capi-ui-autofill.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc + @ONLY +) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIBDIR}/pkgconfig) + +IF(UNIX) + +ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) +ADD_CUSTOM_COMMAND( + DEPENDS clean + COMMENT "distribution clean" + COMMAND find + ARGS . + -not -name config.cmake -and \( + -name tester.c -or + -name Testing -or + -name CMakeFiles -or + -name cmake.depends -or + -name cmake.check_depends -or + -name CMakeCache.txt -or + -name cmake.check_cache -or + -name *.cmake -or + -name Makefile -or + -name core -or + -name core.* -or + -name gmon.out -or + -name install_manifest.txt -or + -name *.pc -or + -name *~ \) + | grep -v TC | xargs rm -rf + TARGET distclean + VERBATIM +) + +ENDIF(UNIX) diff --git a/client/autofill.c b/client/autofill.c new file mode 100644 index 0000000..48ced6d --- /dev/null +++ b/client/autofill.c @@ -0,0 +1,242 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include "autofill_private.h" +#include "autofill_proxy.h" + +#define AUTOFILL_DAEMON_APP_ID "org.tizen.autofill-daemon" + +#ifdef LOG_TAG +#undef LOG_TAG +#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_Cb g_autofill_fill_response_cb; +extern void *g_autofill_fill_response_data; + +extern Autofill_Auth_Info_Cb g_autofill_auth_info_cb; +extern void *g_autofill_auth_info_data; + +static bool fill_response_item_cb(rpc_port_autofill_response_item_h response_items, void *user_data) +{ + char *id = NULL; + char *presentation_text = NULL; + char *value = NULL; + autofill_fill_response_h fill_response = (autofill_fill_response_h)user_data; + + if (!fill_response) + return true; + + rpc_port_autofill_response_item_get_id(response_items, &id); + rpc_port_autofill_response_item_get_presentation_text(response_items, &presentation_text); + rpc_port_autofill_response_item_get_value(response_items, &value); + + LOGD("id : %s, presentation text : %s, value : %s", id, presentation_text, value); + + autofill_fill_response_item_h ritem; + + autofill_fill_response_item_create(&ritem); + autofill_fill_response_item_set_id(ritem, id); + autofill_fill_response_item_set_presentation_text(ritem, presentation_text); + autofill_fill_response_item_set_value(ritem, value); + + autofill_fill_response_add_item(fill_response, ritem); + + if (id) + free(id); + + if (presentation_text) + free(presentation_text); + + if (value) + free(value); + + return true; +} + +static void __fill_response_recv_cb(void *user_data, rpc_port_autofill_fill_response_h response_h) +{ + char *view_id = NULL; + + autofill_fill_response_h rh; + autofill_fill_response_create(&rh); + + rpc_port_autofill_fill_response_get_view_id(response_h, &view_id); + + autofill_fill_response_set_view_id(rh, view_id); + + LOGD("view id : %s", view_id); + free(view_id); + + rpc_port_autofill_fill_response_foreach_response_items(response_h, fill_response_item_cb, rh); + + if (g_autofill_fill_response_cb) + g_autofill_fill_response_cb(rh, g_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); + + bool exist_autofill_data; + bool need_authentication; + char *service_name = NULL; + char *service_logo_image_path = NULL; + char *service_message = NULL; + + rpc_port_autofill_auth_info_get_exist_autofill_data(auth_info_h, &exist_autofill_data); + rpc_port_autofill_auth_info_get_need_authentication(auth_info_h, &need_authentication); + rpc_port_autofill_auth_info_get_service_name(auth_info_h, &service_name); + rpc_port_autofill_auth_info_get_service_logo_image_path(auth_info_h, &service_logo_image_path); + rpc_port_autofill_auth_info_get_service_message(auth_info_h, &service_message); + + LOGD("service name : %s", service_name); + + autofill_auth_info_set_exist_autofill_data(ah, exist_autofill_data); + autofill_auth_info_set_need_authentication(ah, need_authentication); + 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); + + if (service_name) + free(service_name); + + if (service_logo_image_path) + free(service_logo_image_path); + + if (service_message) + free(service_message); + + if (g_autofill_auth_info_cb) + g_autofill_auth_info_cb(ah, g_autofill_fill_response_data); + + autofill_auth_info_destroy(ah); +} + +static void __on_connected(rpc_port_proxy_AutofillAppPort_h h, void *user_data) +{ + LOGI("[__RPC_PORT__] connected"); + rpc_port_AutofillAppPort_autofill_fill_response_cb_h fill_response_cb = rpc_port_AutofillAppPort_autofill_fill_response_cb_create(__fill_response_recv_cb, false, NULL); + rpc_port_AutofillAppPort_autofill_auth_info_cb_h auth_info_cb = rpc_port_AutofillAppPort_autofill_auth_info_cb_create(__auth_info_recv_cb, false, NULL); + + int r = rpc_port_proxy_AutofillAppPort_invoke_Register(h, auth_info_cb, fill_response_cb); + if (r != 0) + LOGD("Failed to invoke Register"); + + if (connection_callback) + connection_callback(AUTOFILL_CONNECTION_STATUS_CONNECTED, connection_userdata); +} + +//LCOV_EXCL_START +static void __on_disconnected(rpc_port_proxy_AutofillAppPort_h h, void *user_data) +{ + LOGD("disconnected"); + + if (connection_callback) + connection_callback(AUTOFILL_CONNECTION_STATUS_DISCONNECTED, connection_userdata); + + 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); +} +//LCOV_EXCL_STOP + +EXPORT_API int autofill_initialize(autofill_connection_status_changed_cb callback, void *user_data) +{ + LOGD("autofill initialize"); + + int ret; + + rpc_port_proxy_AutofillAppPort_callback_s rpc_callback = { + .connected = __on_connected, + .disconnected = __on_disconnected, + .rejected = __on_rejected + }; + + if (!callback) { + LOGW("parameter is NULL\n"); + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + if (rpc_h) { + LOGI("already connected\n"); + return AUTOFILL_ERROR_NONE; + } + + connection_callback = callback; + connection_userdata = user_data; + + ret = rpc_port_proxy_AutofillAppPort_create(AUTOFILL_DAEMON_APP_ID, &rpc_callback, NULL, &rpc_h); + if (ret != RPC_PORT_ERROR_NONE) { + LOGW("Failed to create rpc port. err = %d", ret); + return AUTOFILL_ERROR_OUT_OF_MEMORY; + } + + ret = rpc_port_proxy_AutofillAppPort_connect(rpc_h); + switch (ret) { + case RPC_PORT_ERROR_NONE: + ret = AUTOFILL_ERROR_NONE; + break; + case RPC_PORT_ERROR_IO_ERROR: + break; + case RPC_PORT_ERROR_PERMISSION_DENIED: + ret = AUTOFILL_ERROR_PERMISSION_DENIED; + break; + default: + ret = AUTOFILL_ERROR_IO_ERROR; + break; + } + + if (ret != AUTOFILL_ERROR_NONE) { + LOGW("Failed to connect rpc port. err = %d", ret); + return ret; + } + + return ret; +} + +EXPORT_API int autofill_deinitialize() +{ + LOGD("autofill deinitialize"); + + if (rpc_h) { + rpc_port_proxy_AutofillAppPort_destroy(rpc_h); + rpc_h = NULL; + } + + return AUTOFILL_ERROR_NONE; +} diff --git a/client/autofill_auth.c b/client/autofill_auth.c new file mode 100644 index 0000000..fa54479 --- /dev/null +++ b/client/autofill_auth.c @@ -0,0 +1,112 @@ +/* + * 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 +#include +#include +#include +#include +#include "autofill_private.h" +#include "autofill_proxy.h" +#include + +extern rpc_port_proxy_AutofillAppPort_h rpc_h; + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILL" + +Autofill_Auth_Info_Cb g_autofill_auth_info_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) +{ + LOGD("app id : %s, view id : %s", vi->app_id, vi->view_id); + + rpc_port_autofill_view_info_h vih; + char *id; + char *label; + autofill_hint_e autofill_hint; + bool sensitive_data; + + if (!vi) { + LOGW("parameter is NULL"); + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + rpc_port_autofill_view_info_create(&vih); + rpc_port_autofill_view_info_set_view_id(vih, vi->view_id); + + Eina_List *l; + autofill_item_h it; + EINA_LIST_FOREACH(vi->autofill_item_list, l, it) + { + autofill_item_get_id(it, &id); + autofill_item_get_label(it, &label); + autofill_item_get_autofill_hint(it, &autofill_hint); + autofill_item_get_sensitive_data(it, &sensitive_data); + + LOGD("it : %p, id : %s, label : %s, hint : %d, sensitive : %d", it, id, label, autofill_hint, sensitive_data); + + rpc_port_autofill_item_h aih; + rpc_port_autofill_item_create(&aih); + rpc_port_autofill_item_set_id(aih, id); + rpc_port_autofill_item_set_label(aih, label); + rpc_port_autofill_item_set_autofill_hint(aih, (int)autofill_hint); + rpc_port_autofill_item_set_is_sensitive_data(aih, sensitive_data); + rpc_port_autofill_view_info_add_items(vih, aih); + + if (id) { + free(id); + id = NULL; + } + + if (label) { + free(label); + label = NULL; + } + + rpc_port_autofill_item_destroy(aih); + } + + LOGD("rpc_h : %p", rpc_h); + + if (rpc_h) { + rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(rpc_h, vih); + } + + rpc_port_autofill_view_info_destroy(vih); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_set_callback(Autofill_Auth_Info_Cb autofill_auth_info_cb, void *data) +{ + g_autofill_auth_info_cb = autofill_auth_info_cb; + g_autofill_auth_info_data = data; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_unset_callback() +{ + g_autofill_auth_info_cb = NULL; + g_autofill_auth_info_data = NULL; + + return AUTOFILL_ERROR_NONE; +} diff --git a/client/autofill_client_private.h b/client/autofill_client_private.h new file mode 100644 index 0000000..561be79 --- /dev/null +++ b/client/autofill_client_private.h @@ -0,0 +1,26 @@ +/* + * 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. + */ + +#ifndef __TIZEN_UIX_AUTOFILL_CLIENT_PRIVATE_H__ +#define __TIZEN_UIX_AUTOFILL_CLIENT_PRIVATE_H__ + +#include +#include "autofill_proxy.h" +#include "autofill.h" + +rpc_port_proxy_AutofillAppPort_h rpc_h = NULL; + +#endif /* __TIZEN_UIX_AUTOFILL_CLIENT_PRIVATE_H__ */ diff --git a/client/autofill_fill_request.c b/client/autofill_fill_request.c new file mode 100644 index 0000000..964b548 --- /dev/null +++ b/client/autofill_fill_request.c @@ -0,0 +1,109 @@ +/* + * 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 +#include +#include +#include +#include +//#include +#include +#include "autofill_private.h" +#include "autofill_proxy.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILL" + +extern rpc_port_proxy_AutofillAppPort_h rpc_h; + +Autofill_Fill_Response_Cb g_autofill_fill_response_cb = NULL; +void *g_autofill_fill_response_data = NULL; + +EXPORT_API int autofill_fill_request(autofill_view_info_h vi) +{ + rpc_port_autofill_view_info_h vih; + char *id; + char *label; + autofill_hint_e autofill_hint; + bool sensitive_data; + + if (!vi) { + LOGW("parameter is NULL"); + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + Eina_List *l; + autofill_item_h it; + + rpc_port_autofill_view_info_create(&vih); + rpc_port_autofill_view_info_set_view_id(vih, vi->view_id); + + EINA_LIST_FOREACH(vi->autofill_item_list, l, it) + { + autofill_item_get_id(it, &id); + autofill_item_get_label(it, &label); + autofill_item_get_autofill_hint(it, &autofill_hint); + autofill_item_get_sensitive_data(it, &sensitive_data); + + LOGD("it : %p, id : %s, label : %s, hint : %d, sensitive : %d", it, id, label, autofill_hint, sensitive_data); + + rpc_port_autofill_item_h aih; + rpc_port_autofill_item_create(&aih); + rpc_port_autofill_item_set_id(aih, id); + rpc_port_autofill_item_set_label(aih, label); + rpc_port_autofill_item_set_autofill_hint(aih, (int)autofill_hint); + rpc_port_autofill_item_set_is_sensitive_data(aih, sensitive_data); + rpc_port_autofill_view_info_add_items(vih, aih); + + if (id) { + free(id); + id = NULL; + } + + if (label) { + free(label); + label = NULL; + } + + rpc_port_autofill_item_destroy(aih); + } + + LOGD("app id : %s, view id : %s", vi->app_id, vi->view_id); + + rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(rpc_h, vih); + + rpc_port_autofill_view_info_destroy(vih); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_fill_response_set_callback(Autofill_Fill_Response_Cb autofill_response_cb, void *data) +{ + g_autofill_fill_response_cb = autofill_response_cb; + g_autofill_fill_response_data = data; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_fill_response_unset_callback() +{ + g_autofill_fill_response_cb = NULL; + g_autofill_fill_response_data = NULL; + + return AUTOFILL_ERROR_NONE; +} diff --git a/client/autofill_proxy.c b/client/autofill_proxy.c new file mode 100644 index 0000000..f6a6f53 --- /dev/null +++ b/client/autofill_proxy.c @@ -0,0 +1,2639 @@ +/* + * Generated by tidlc 1.3.1. + * + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "autofill_proxy.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "RPC_PORT_PROXY" + +#ifdef _E +#undef _E +#endif + +#ifdef _W +#undef _W +#endif + +#ifdef _I +#undef _I +#endif + +#ifdef _D +#undef _D +#endif + +#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +typedef void (*proxy_delegate)(GList **list, rpc_port_parcel_h parcel, int seq_id, int id); + +struct autofill_item_s { + rpc_port_parcelable_t parcelable; + char *id; + char *label; + char *value; + int autofill_hint; + bool is_sensitive_data; +}; + +static void __autofill_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->id ? h->id : ""); + rpc_port_parcel_write_string(parcel, h->label ? h->label : ""); + rpc_port_parcel_write_string(parcel, h->value ? h->value : ""); + rpc_port_parcel_write_int32(parcel, h->autofill_hint); + rpc_port_parcel_write_bool(parcel, h->is_sensitive_data); +} + +static void __autofill_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->id); + rpc_port_parcel_read_string(parcel, &h->label); + rpc_port_parcel_read_string(parcel, &h->value); + rpc_port_parcel_read_int32(parcel, &h->autofill_hint); + rpc_port_parcel_read_bool(parcel, &h->is_sensitive_data); +} + +int rpc_port_autofill_item_create(rpc_port_autofill_item_h *h) +{ + struct autofill_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_item_to; + handle->parcelable.from = __autofill_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_item_destroy(rpc_port_autofill_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) + free(h->id); + + if (h->label) + free(h->label); + + if (h->value) + free(h->value); + + free(h); + + return 0; +} + +int rpc_port_autofill_item_clone(rpc_port_autofill_item_h h, rpc_port_autofill_item_h *clone) +{ + rpc_port_autofill_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_item_create(&handle); + if (!handle) { + _E("Failed to create autofill_item handle"); + return -1; + } + + if (h->id) { + handle->id = strdup(h->id); + if (!handle->id) { + _E("Failed to duplicate h->id"); + rpc_port_autofill_item_destroy(handle); + return -1; + } + } + + if (h->label) { + handle->label = strdup(h->label); + if (!handle->label) { + _E("Failed to duplicate h->label"); + rpc_port_autofill_item_destroy(handle); + return -1; + } + } + + if (h->value) { + handle->value = strdup(h->value); + if (!handle->value) { + _E("Failed to duplicate h->value"); + rpc_port_autofill_item_destroy(handle); + return -1; + } + } + + handle->autofill_hint = h->autofill_hint; + handle->is_sensitive_data = h->is_sensitive_data; + *clone = handle; + + return 0; +} + +int rpc_port_autofill_item_set_id(rpc_port_autofill_item_h h, const char *id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) { + free(h->id); + h->id = NULL; + } + + h->id = strdup(id); + if (!h->id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_set_label(rpc_port_autofill_item_h h, const char *label) +{ + if (!h || !label) { + _E("Invalid parameter"); + return -1; + } + + if (h->label) { + free(h->label); + h->label = NULL; + } + + h->label = strdup(label); + if (!h->label) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_set_value(rpc_port_autofill_item_h h, const char *value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (h->value) { + free(h->value); + h->value = NULL; + } + + h->value = strdup(value); + if (!h->value) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_set_autofill_hint(rpc_port_autofill_item_h h, int autofill_hint) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->autofill_hint = autofill_hint; + return 0; +} + +int rpc_port_autofill_item_set_is_sensitive_data(rpc_port_autofill_item_h h, bool is_sensitive_data) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->is_sensitive_data = is_sensitive_data; + return 0; +} + +int rpc_port_autofill_item_get_id(rpc_port_autofill_item_h h, char **id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->id) { + _E("Invalid parameter: h->id is NULL"); + return -1; + } + + *id = strdup(h->id); + if (*id == NULL) { + _E("Failed to duplicate id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_get_label(rpc_port_autofill_item_h h, char **label) +{ + if (!h || !label) { + _E("Invalid parameter"); + return -1; + } + + if (!h->label) { + _E("Invalid parameter: h->label is NULL"); + return -1; + } + + *label = strdup(h->label); + if (*label == NULL) { + _E("Failed to duplicate label"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_get_value(rpc_port_autofill_item_h h, char **value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (!h->value) { + _E("Invalid parameter: h->value is NULL"); + return -1; + } + + *value = strdup(h->value); + if (*value == NULL) { + _E("Failed to duplicate value"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_get_autofill_hint(rpc_port_autofill_item_h h, int *autofill_hint) +{ + if (!h || !autofill_hint) { + _E("Invalid parameter"); + return -1; + } + + *autofill_hint = h->autofill_hint; + return 0; +} + +int rpc_port_autofill_item_get_is_sensitive_data(rpc_port_autofill_item_h h, bool *is_sensitive_data) +{ + if (!h || !is_sensitive_data) { + _E("Invalid parameter"); + return -1; + } + + *is_sensitive_data = h->is_sensitive_data; + return 0; +} + +struct autofill_view_info_s { + rpc_port_parcelable_t parcelable; + char *view_id; + GList *items; +}; + +static void __autofill_view_info_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_view_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->view_id ? h->view_id : ""); + rpc_port_parcel_write_array_count(parcel, g_list_length(h->items)); + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __autofill_view_info_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_view_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->view_id); + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_item_h value = NULL; + + rpc_port_autofill_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->items = g_list_append(h->items, value); + } + } while (0); +} + +int rpc_port_autofill_view_info_create(rpc_port_autofill_view_info_h *h) +{ + struct autofill_view_info_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_view_info_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_view_info_to; + handle->parcelable.from = __autofill_view_info_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_view_info_destroy(rpc_port_autofill_view_info_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) + free(h->view_id); + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + if (value) + rpc_port_autofill_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_autofill_view_info_clone(rpc_port_autofill_view_info_h h, rpc_port_autofill_view_info_h *clone) +{ + rpc_port_autofill_view_info_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_view_info_create(&handle); + if (!handle) { + _E("Failed to create autofill_view_info handle"); + return -1; + } + + if (h->view_id) { + handle->view_id = strdup(h->view_id); + if (!handle->view_id) { + _E("Failed to duplicate h->view_id"); + rpc_port_autofill_view_info_destroy(handle); + return -1; + } + } + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_item_h new_value; + rpc_port_autofill_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_autofill_view_info_destroy(handle); + return -1; + } + + rpc_port_autofill_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_view_info_destroy(handle); + return -1; + } + + handle->items = g_list_append(handle->items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_view_info_set_view_id(rpc_port_autofill_view_info_h h, const char *view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) { + free(h->view_id); + h->view_id = NULL; + } + + h->view_id = strdup(view_id); + if (!h->view_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_view_info_add_items(rpc_port_autofill_view_info_h h, rpc_port_autofill_item_h items) +{ + if (!h || !items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_item_h value = NULL; + + rpc_port_autofill_item_clone(items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->items = g_list_append(h->items, value); + } while (0); + + return 0; +} + +int rpc_port_autofill_view_info_get_view_id(rpc_port_autofill_view_info_h h, char **view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->view_id) { + _E("Invalid parameter: h->view_id is NULL"); + return -1; + } + + *view_id = strdup(h->view_id); + if (*view_id == NULL) { + _E("Failed to duplicate view_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_view_info_foreach_items(rpc_port_autofill_view_info_h h, + bool (*callback)(rpc_port_autofill_item_h items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_autofill_view_info_remove_items(rpc_port_autofill_view_info_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_item_h value = iter->data; + h->items = g_list_remove_link(h->items, iter); + rpc_port_autofill_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_view_info_get_items_length(rpc_port_autofill_view_info_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->items); + + return 0; +} + +struct autofill_auth_info_s { + rpc_port_parcelable_t parcelable; + bool exist_autofill_data; + bool need_authentication; + char *service_name; + char *service_logo_image_path; + char *service_message; +}; + +static void __autofill_auth_info_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_auth_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_bool(parcel, h->exist_autofill_data); + rpc_port_parcel_write_bool(parcel, h->need_authentication); + rpc_port_parcel_write_string(parcel, h->service_name ? h->service_name : ""); + rpc_port_parcel_write_string(parcel, h->service_logo_image_path ? h->service_logo_image_path : ""); + rpc_port_parcel_write_string(parcel, h->service_message ? h->service_message : ""); +} + +static void __autofill_auth_info_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_auth_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_bool(parcel, &h->exist_autofill_data); + rpc_port_parcel_read_bool(parcel, &h->need_authentication); + rpc_port_parcel_read_string(parcel, &h->service_name); + rpc_port_parcel_read_string(parcel, &h->service_logo_image_path); + rpc_port_parcel_read_string(parcel, &h->service_message); +} + +int rpc_port_autofill_auth_info_create(rpc_port_autofill_auth_info_h *h) +{ + struct autofill_auth_info_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_auth_info_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_auth_info_to; + handle->parcelable.from = __autofill_auth_info_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_auth_info_destroy(rpc_port_autofill_auth_info_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_name) + free(h->service_name); + + if (h->service_logo_image_path) + free(h->service_logo_image_path); + + if (h->service_message) + free(h->service_message); + + free(h); + + return 0; +} + +int rpc_port_autofill_auth_info_clone(rpc_port_autofill_auth_info_h h, rpc_port_autofill_auth_info_h *clone) +{ + rpc_port_autofill_auth_info_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_auth_info_create(&handle); + if (!handle) { + _E("Failed to create autofill_auth_info handle"); + return -1; + } + + handle->exist_autofill_data = h->exist_autofill_data; + handle->need_authentication = h->need_authentication; + if (h->service_name) { + handle->service_name = strdup(h->service_name); + if (!handle->service_name) { + _E("Failed to duplicate h->service_name"); + rpc_port_autofill_auth_info_destroy(handle); + return -1; + } + } + + if (h->service_logo_image_path) { + handle->service_logo_image_path = strdup(h->service_logo_image_path); + if (!handle->service_logo_image_path) { + _E("Failed to duplicate h->service_logo_image_path"); + rpc_port_autofill_auth_info_destroy(handle); + return -1; + } + } + + if (h->service_message) { + handle->service_message = strdup(h->service_message); + if (!handle->service_message) { + _E("Failed to duplicate h->service_message"); + rpc_port_autofill_auth_info_destroy(handle); + return -1; + } + } + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_auth_info_set_exist_autofill_data(rpc_port_autofill_auth_info_h h, bool exist_autofill_data) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->exist_autofill_data = exist_autofill_data; + return 0; +} + +int rpc_port_autofill_auth_info_set_need_authentication(rpc_port_autofill_auth_info_h h, bool need_authentication) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->need_authentication = need_authentication; + return 0; +} + +int rpc_port_autofill_auth_info_set_service_name(rpc_port_autofill_auth_info_h h, const char *service_name) +{ + if (!h || !service_name) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_name) { + free(h->service_name); + h->service_name = NULL; + } + + h->service_name = strdup(service_name); + if (!h->service_name) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_auth_info_set_service_logo_image_path(rpc_port_autofill_auth_info_h h, const char *service_logo_image_path) +{ + if (!h || !service_logo_image_path) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_logo_image_path) { + free(h->service_logo_image_path); + h->service_logo_image_path = NULL; + } + + h->service_logo_image_path = strdup(service_logo_image_path); + if (!h->service_logo_image_path) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_auth_info_set_service_message(rpc_port_autofill_auth_info_h h, const char *service_message) +{ + if (!h || !service_message) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_message) { + free(h->service_message); + h->service_message = NULL; + } + + h->service_message = strdup(service_message); + if (!h->service_message) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_auth_info_get_exist_autofill_data(rpc_port_autofill_auth_info_h h, bool *exist_autofill_data) +{ + if (!h || !exist_autofill_data) { + _E("Invalid parameter"); + return -1; + } + + *exist_autofill_data = h->exist_autofill_data; + return 0; +} + +int rpc_port_autofill_auth_info_get_need_authentication(rpc_port_autofill_auth_info_h h, bool *need_authentication) +{ + if (!h || !need_authentication) { + _E("Invalid parameter"); + return -1; + } + + *need_authentication = h->need_authentication; + return 0; +} + +int rpc_port_autofill_auth_info_get_service_name(rpc_port_autofill_auth_info_h h, char **service_name) +{ + if (!h || !service_name) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_name) { + _E("Invalid parameter: h->service_name is NULL"); + return -1; + } + + *service_name = strdup(h->service_name); + if (*service_name == NULL) { + _E("Failed to duplicate service_name"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_auth_info_get_service_logo_image_path(rpc_port_autofill_auth_info_h h, char **service_logo_image_path) +{ + if (!h || !service_logo_image_path) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_logo_image_path) { + _E("Invalid parameter: h->service_logo_image_path is NULL"); + return -1; + } + + *service_logo_image_path = strdup(h->service_logo_image_path); + if (*service_logo_image_path == NULL) { + _E("Failed to duplicate service_logo_image_path"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_auth_info_get_service_message(rpc_port_autofill_auth_info_h h, char **service_message) +{ + if (!h || !service_message) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_message) { + _E("Invalid parameter: h->service_message is NULL"); + return -1; + } + + *service_message = strdup(h->service_message); + if (*service_message == NULL) { + _E("Failed to duplicate service_message"); + return -1; + } + + return 0; +} + +struct autofill_response_item_s { + rpc_port_parcelable_t parcelable; + char *id; + char *presentation_text; + char *value; +}; + +static void __autofill_response_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->id ? h->id : ""); + rpc_port_parcel_write_string(parcel, h->presentation_text ? h->presentation_text : ""); + rpc_port_parcel_write_string(parcel, h->value ? h->value : ""); +} + +static void __autofill_response_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->id); + rpc_port_parcel_read_string(parcel, &h->presentation_text); + rpc_port_parcel_read_string(parcel, &h->value); +} + +int rpc_port_autofill_response_item_create(rpc_port_autofill_response_item_h *h) +{ + struct autofill_response_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_response_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_response_item_to; + handle->parcelable.from = __autofill_response_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_response_item_destroy(rpc_port_autofill_response_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) + free(h->id); + + if (h->presentation_text) + free(h->presentation_text); + + if (h->value) + free(h->value); + + free(h); + + return 0; +} + +int rpc_port_autofill_response_item_clone(rpc_port_autofill_response_item_h h, rpc_port_autofill_response_item_h *clone) +{ + rpc_port_autofill_response_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_response_item_create(&handle); + if (!handle) { + _E("Failed to create autofill_response_item handle"); + return -1; + } + + if (h->id) { + handle->id = strdup(h->id); + if (!handle->id) { + _E("Failed to duplicate h->id"); + rpc_port_autofill_response_item_destroy(handle); + return -1; + } + } + + if (h->presentation_text) { + handle->presentation_text = strdup(h->presentation_text); + if (!handle->presentation_text) { + _E("Failed to duplicate h->presentation_text"); + rpc_port_autofill_response_item_destroy(handle); + return -1; + } + } + + if (h->value) { + handle->value = strdup(h->value); + if (!handle->value) { + _E("Failed to duplicate h->value"); + rpc_port_autofill_response_item_destroy(handle); + return -1; + } + } + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_response_item_set_id(rpc_port_autofill_response_item_h h, const char *id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) { + free(h->id); + h->id = NULL; + } + + h->id = strdup(id); + if (!h->id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_response_item_set_presentation_text(rpc_port_autofill_response_item_h h, const char *presentation_text) +{ + if (!h || !presentation_text) { + _E("Invalid parameter"); + return -1; + } + + if (h->presentation_text) { + free(h->presentation_text); + h->presentation_text = NULL; + } + + h->presentation_text = strdup(presentation_text); + if (!h->presentation_text) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_response_item_set_value(rpc_port_autofill_response_item_h h, const char *value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (h->value) { + free(h->value); + h->value = NULL; + } + + h->value = strdup(value); + if (!h->value) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_response_item_get_id(rpc_port_autofill_response_item_h h, char **id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->id) { + _E("Invalid parameter: h->id is NULL"); + return -1; + } + + *id = strdup(h->id); + if (*id == NULL) { + _E("Failed to duplicate id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_response_item_get_presentation_text(rpc_port_autofill_response_item_h h, char **presentation_text) +{ + if (!h || !presentation_text) { + _E("Invalid parameter"); + return -1; + } + + if (!h->presentation_text) { + _E("Invalid parameter: h->presentation_text is NULL"); + return -1; + } + + *presentation_text = strdup(h->presentation_text); + if (*presentation_text == NULL) { + _E("Failed to duplicate presentation_text"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_response_item_get_value(rpc_port_autofill_response_item_h h, char **value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (!h->value) { + _E("Invalid parameter: h->value is NULL"); + return -1; + } + + *value = strdup(h->value); + if (*value == NULL) { + _E("Failed to duplicate value"); + return -1; + } + + return 0; +} + +struct autofill_fill_response_s { + rpc_port_parcelable_t parcelable; + char *view_id; + GList *response_items; +}; + +static void __autofill_fill_response_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_fill_response_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->view_id ? h->view_id : ""); + rpc_port_parcel_write_array_count(parcel, g_list_length(h->response_items)); + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __autofill_fill_response_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_fill_response_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->view_id); + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_response_item_h value = NULL; + + rpc_port_autofill_response_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->response_items = g_list_append(h->response_items, value); + } + } while (0); +} + +int rpc_port_autofill_fill_response_create(rpc_port_autofill_fill_response_h *h) +{ + struct autofill_fill_response_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_fill_response_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_fill_response_to; + handle->parcelable.from = __autofill_fill_response_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_fill_response_destroy(rpc_port_autofill_fill_response_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) + free(h->view_id); + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + if (value) + rpc_port_autofill_response_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->response_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_autofill_fill_response_clone(rpc_port_autofill_fill_response_h h, rpc_port_autofill_fill_response_h *clone) +{ + rpc_port_autofill_fill_response_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_fill_response_create(&handle); + if (!handle) { + _E("Failed to create autofill_fill_response handle"); + return -1; + } + + if (h->view_id) { + handle->view_id = strdup(h->view_id); + if (!handle->view_id) { + _E("Failed to duplicate h->view_id"); + rpc_port_autofill_fill_response_destroy(handle); + return -1; + } + } + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_response_item_h new_value; + rpc_port_autofill_response_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_autofill_fill_response_destroy(handle); + return -1; + } + + rpc_port_autofill_response_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_fill_response_destroy(handle); + return -1; + } + + handle->response_items = g_list_append(handle->response_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_fill_response_set_view_id(rpc_port_autofill_fill_response_h h, const char *view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) { + free(h->view_id); + h->view_id = NULL; + } + + h->view_id = strdup(view_id); + if (!h->view_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_fill_response_add_response_items(rpc_port_autofill_fill_response_h h, rpc_port_autofill_response_item_h response_items) +{ + if (!h || !response_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_response_item_h value = NULL; + + rpc_port_autofill_response_item_clone(response_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->response_items = g_list_append(h->response_items, value); + } while (0); + + return 0; +} + +int rpc_port_autofill_fill_response_get_view_id(rpc_port_autofill_fill_response_h h, char **view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->view_id) { + _E("Invalid parameter: h->view_id is NULL"); + return -1; + } + + *view_id = strdup(h->view_id); + if (*view_id == NULL) { + _E("Failed to duplicate view_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_fill_response_foreach_response_items(rpc_port_autofill_fill_response_h h, + bool (*callback)(rpc_port_autofill_response_item_h response_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_autofill_fill_response_remove_response_items(rpc_port_autofill_fill_response_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->response_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_response_item_h value = iter->data; + h->response_items = g_list_remove_link(h->response_items, iter); + rpc_port_autofill_response_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_fill_response_get_response_items_length(rpc_port_autofill_fill_response_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->response_items); + + return 0; +} + +struct list_autofill_item_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_items; +}; + +static void __list_autofill_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_items)); + do { + GList *iter; + + iter = h->list_autofill_items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __list_autofill_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_item_h value = NULL; + + rpc_port_autofill_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_items = g_list_append(h->list_autofill_items, value); + } + } while (0); +} + +int rpc_port_list_autofill_item_create(rpc_port_list_autofill_item_h *h) +{ + struct list_autofill_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_item_to; + handle->parcelable.from = __list_autofill_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_item_destroy(rpc_port_list_autofill_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + if (value) + rpc_port_autofill_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_item_clone(rpc_port_list_autofill_item_h h, rpc_port_list_autofill_item_h *clone) +{ + rpc_port_list_autofill_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_item_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_item handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_items; + while (iter) { + rpc_port_autofill_item_h new_value; + rpc_port_autofill_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_item_destroy(handle); + return -1; + } + + rpc_port_autofill_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_item_destroy(handle); + return -1; + } + + handle->list_autofill_items = g_list_append(handle->list_autofill_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_item_add_list_autofill_items(rpc_port_list_autofill_item_h h, rpc_port_autofill_item_h list_autofill_items) +{ + if (!h || !list_autofill_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_item_h value = NULL; + + rpc_port_autofill_item_clone(list_autofill_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_items = g_list_append(h->list_autofill_items, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_item_foreach_list_autofill_items(rpc_port_list_autofill_item_h h, + bool (*callback)(rpc_port_autofill_item_h list_autofill_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_list_autofill_item_remove_list_autofill_items(rpc_port_list_autofill_item_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_item_h value = iter->data; + h->list_autofill_items = g_list_remove_link(h->list_autofill_items, iter); + rpc_port_autofill_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_item_get_list_autofill_items_length(rpc_port_list_autofill_item_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_items); + + return 0; +} + +struct list_autofill_response_item_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_response_items; +}; + +static void __list_autofill_response_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_response_items)); + do { + GList *iter; + + iter = h->list_autofill_response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __list_autofill_response_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_response_item_h value = NULL; + + rpc_port_autofill_response_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_response_items = g_list_append(h->list_autofill_response_items, value); + } + } while (0); +} + +int rpc_port_list_autofill_response_item_create(rpc_port_list_autofill_response_item_h *h) +{ + struct list_autofill_response_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_response_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_response_item_to; + handle->parcelable.from = __list_autofill_response_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_response_item_destroy(rpc_port_list_autofill_response_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + if (value) + rpc_port_autofill_response_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_response_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_response_item_clone(rpc_port_list_autofill_response_item_h h, rpc_port_list_autofill_response_item_h *clone) +{ + rpc_port_list_autofill_response_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_response_item_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_response_item handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_response_items; + while (iter) { + rpc_port_autofill_response_item_h new_value; + rpc_port_autofill_response_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_response_item_destroy(handle); + return -1; + } + + rpc_port_autofill_response_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_response_item_destroy(handle); + return -1; + } + + handle->list_autofill_response_items = g_list_append(handle->list_autofill_response_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_response_item_add_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, rpc_port_autofill_response_item_h list_autofill_response_items) +{ + if (!h || !list_autofill_response_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_response_item_h value = NULL; + + rpc_port_autofill_response_item_clone(list_autofill_response_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_response_items = g_list_append(h->list_autofill_response_items, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_response_item_foreach_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, + bool (*callback)(rpc_port_autofill_response_item_h list_autofill_response_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_list_autofill_response_item_remove_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_response_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_response_item_h value = iter->data; + h->list_autofill_response_items = g_list_remove_link(h->list_autofill_response_items, iter); + rpc_port_autofill_response_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_response_item_get_list_autofill_response_items_length(rpc_port_list_autofill_response_item_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_response_items); + + return 0; +} + +enum AutofillAppPort_method_e { + AutofillAppPort_METHOD_Result, + AutofillAppPort_METHOD_Callback, + AutofillAppPort_METHOD_Register, + AutofillAppPort_METHOD_Unregister, + AutofillAppPort_METHOD_request_auth_info, + AutofillAppPort_METHOD_send_fill_request, +}; + +enum AutofillAppPort_delegate_e { + AutofillAppPort_DELEGATE_autofill_auth_info_cb = 1, + AutofillAppPort_DELEGATE_autofill_fill_response_cb = 2, +}; + +struct AutofillAppPort_s { + char *stub_appid; + rpc_port_proxy_h proxy; + rpc_port_h port; + rpc_port_h callback_port; + rpc_port_proxy_AutofillAppPort_callback_s callback; + void *user_data; + GList *delegates; + GRecMutex mutex; +}; + +struct AutofillAppPort_autofill_auth_info_cb_s { + rpc_port_parcelable_t parcelable; + int id; + int seq_id; + AutofillAppPort_autofill_auth_info_cb callback; + bool once; + void *user_data; +}; + +static void __AutofillAppPort_autofill_auth_info_cb_to(rpc_port_parcel_h parcel, void *data) +{ + struct AutofillAppPort_autofill_auth_info_cb_s *handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, handle->id); + rpc_port_parcel_write_int32(parcel, handle->seq_id); + rpc_port_parcel_write_bool(parcel, handle->once); +} + +static void __AutofillAppPort_autofill_auth_info_cb_from(rpc_port_parcel_h parcel, void *data) +{ + struct AutofillAppPort_autofill_auth_info_cb_s *handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_int32(parcel, &handle->id); + rpc_port_parcel_read_int32(parcel, &handle->seq_id); + rpc_port_parcel_read_bool(parcel, &handle->once); +} + +rpc_port_AutofillAppPort_autofill_auth_info_cb_h rpc_port_AutofillAppPort_autofill_auth_info_cb_create(AutofillAppPort_autofill_auth_info_cb callback, bool once, void *user_data) +{ + struct AutofillAppPort_autofill_auth_info_cb_s *handle; + static int seq_num; + + handle = calloc(1, sizeof(struct AutofillAppPort_autofill_auth_info_cb_s)); + if (!handle) { + _E("Out of memory"); + return NULL; + } + + handle->parcelable.to = __AutofillAppPort_autofill_auth_info_cb_to; + handle->parcelable.from= __AutofillAppPort_autofill_auth_info_cb_from; + handle->id = AutofillAppPort_DELEGATE_autofill_auth_info_cb; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + handle->callback = callback; + handle->once = once; + handle->user_data = user_data; + + return handle; +} + +int rpc_port_proxy_AutofillAppPort_autofill_auth_info_cb_destroy(rpc_port_AutofillAppPort_autofill_auth_info_cb_h delegate) +{ + if (!delegate) { + _E("Invalid parameter"); + return -1; + } + + free(delegate); + + return 0; +} + +int rpc_port_proxy_AutofillAppPort_autofill_auth_info_cb_dispose(rpc_port_proxy_AutofillAppPort_h proxy, rpc_port_AutofillAppPort_autofill_auth_info_cb_h delegate) +{ + struct AutofillAppPort_autofill_auth_info_cb_s *handle; + GList *iter; + + if (!proxy || !delegate) { + _E("Invalid handle %p %p", proxy, delegate); + return -1; + } + + iter = proxy->delegates; + while (iter) { + handle = (struct AutofillAppPort_autofill_auth_info_cb_s *)iter->data; + if (handle == delegate) { + proxy->delegates = g_list_remove_link(proxy->delegates, iter); + free(handle); + g_list_free(iter); + return 0; + } + iter = g_list_next(iter); + } + + return -1; +} + +static void __AutofillAppPort_delegate_autofill_auth_info_cb(GList **list, rpc_port_parcel_h parcel, int seq_id, int id) +{ + rpc_port_autofill_auth_info_h auth_info; + + rpc_port_autofill_auth_info_create(&auth_info); + rpc_port_parcel_read(parcel, &auth_info->parcelable, auth_info); + + do { + struct AutofillAppPort_autofill_auth_info_cb_s *handle; + GList *iter; + + iter = *list; + while (iter) { + handle = (struct AutofillAppPort_autofill_auth_info_cb_s *)iter->data; + if (handle->seq_id == seq_id && handle->id == id) { + handle->callback(handle->user_data, auth_info); + + if (handle->once) { + *list = g_list_remove_link(*list, iter); + free(handle); + g_list_free(iter); + } + break; + } + iter = g_list_next(iter); + } + } while (0); + rpc_port_autofill_auth_info_destroy(auth_info); +} + +struct AutofillAppPort_autofill_fill_response_cb_s { + rpc_port_parcelable_t parcelable; + int id; + int seq_id; + AutofillAppPort_autofill_fill_response_cb callback; + bool once; + void *user_data; +}; + +static void __AutofillAppPort_autofill_fill_response_cb_to(rpc_port_parcel_h parcel, void *data) +{ + struct AutofillAppPort_autofill_fill_response_cb_s *handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, handle->id); + rpc_port_parcel_write_int32(parcel, handle->seq_id); + rpc_port_parcel_write_bool(parcel, handle->once); +} + +static void __AutofillAppPort_autofill_fill_response_cb_from(rpc_port_parcel_h parcel, void *data) +{ + struct AutofillAppPort_autofill_fill_response_cb_s *handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_int32(parcel, &handle->id); + rpc_port_parcel_read_int32(parcel, &handle->seq_id); + rpc_port_parcel_read_bool(parcel, &handle->once); +} + +rpc_port_AutofillAppPort_autofill_fill_response_cb_h rpc_port_AutofillAppPort_autofill_fill_response_cb_create(AutofillAppPort_autofill_fill_response_cb callback, bool once, void *user_data) +{ + struct AutofillAppPort_autofill_fill_response_cb_s *handle; + static int seq_num; + + handle = calloc(1, sizeof(struct AutofillAppPort_autofill_fill_response_cb_s)); + if (!handle) { + _E("Out of memory"); + return NULL; + } + + handle->parcelable.to = __AutofillAppPort_autofill_fill_response_cb_to; + handle->parcelable.from= __AutofillAppPort_autofill_fill_response_cb_from; + handle->id = AutofillAppPort_DELEGATE_autofill_fill_response_cb; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + handle->callback = callback; + handle->once = once; + handle->user_data = user_data; + + return handle; +} + +int rpc_port_proxy_AutofillAppPort_autofill_fill_response_cb_destroy(rpc_port_AutofillAppPort_autofill_fill_response_cb_h delegate) +{ + if (!delegate) { + _E("Invalid parameter"); + return -1; + } + + free(delegate); + + return 0; +} + +int rpc_port_proxy_AutofillAppPort_autofill_fill_response_cb_dispose(rpc_port_proxy_AutofillAppPort_h proxy, rpc_port_AutofillAppPort_autofill_fill_response_cb_h delegate) +{ + struct AutofillAppPort_autofill_fill_response_cb_s *handle; + GList *iter; + + if (!proxy || !delegate) { + _E("Invalid handle %p %p", proxy, delegate); + return -1; + } + + iter = proxy->delegates; + while (iter) { + handle = (struct AutofillAppPort_autofill_fill_response_cb_s *)iter->data; + if (handle == delegate) { + proxy->delegates = g_list_remove_link(proxy->delegates, iter); + free(handle); + g_list_free(iter); + return 0; + } + iter = g_list_next(iter); + } + + return -1; +} + +static void __AutofillAppPort_delegate_autofill_fill_response_cb(GList **list, rpc_port_parcel_h parcel, int seq_id, int id) +{ + rpc_port_autofill_fill_response_h response; + + rpc_port_autofill_fill_response_create(&response); + rpc_port_parcel_read(parcel, &response->parcelable, response); + + do { + struct AutofillAppPort_autofill_fill_response_cb_s *handle; + GList *iter; + + iter = *list; + while (iter) { + handle = (struct AutofillAppPort_autofill_fill_response_cb_s *)iter->data; + if (handle->seq_id == seq_id && handle->id == id) { + handle->callback(handle->user_data, response); + + if (handle->once) { + *list = g_list_remove_link(*list, iter); + free(handle); + g_list_free(iter); + } + break; + } + iter = g_list_next(iter); + } + } while (0); + rpc_port_autofill_fill_response_destroy(response); +} + +static proxy_delegate __AutofillAppPort_delegate_table[] = { + [AutofillAppPort_DELEGATE_autofill_auth_info_cb] = __AutofillAppPort_delegate_autofill_auth_info_cb, + [AutofillAppPort_DELEGATE_autofill_fill_response_cb] = __AutofillAppPort_delegate_autofill_fill_response_cb, +}; + +static void __AutofillAppPort_process_received_event(GList **list, rpc_port_parcel_h parcel) +{ + int id; + int seq_id; + bool once; + + rpc_port_parcel_read_int32(parcel, &id); + rpc_port_parcel_read_int32(parcel, &seq_id); + rpc_port_parcel_read_bool(parcel, &once); + + if (id > 0 && id < (sizeof(__AutofillAppPort_delegate_table) / sizeof(__AutofillAppPort_delegate_table[0]))) { + if (__AutofillAppPort_delegate_table[id]) + __AutofillAppPort_delegate_table[id](list, parcel, seq_id, id); + } else { + _W("Unknown id(%d)", id); + } +} + +static rpc_port_parcel_h __AutofillAppPort_consume_command(rpc_port_proxy_AutofillAppPort_h h) +{ + rpc_port_parcel_h parcel = NULL; + int cmd = -1; + + do { + rpc_port_parcel_create_from_port(&parcel, h->port); + if (!parcel) + break; + + rpc_port_parcel_read_int32(parcel, &cmd); + if (cmd == AutofillAppPort_METHOD_Result) + return parcel; + + rpc_port_parcel_destroy(parcel); + parcel = NULL; + } while (true); + + return NULL; +} + +static void __AutofillAppPort_on_connected(const char *endpoint, const char *port_name, rpc_port_h port, void *data) +{ + rpc_port_proxy_AutofillAppPort_h handle = data; + + handle->port = port; + rpc_port_proxy_get_port(handle->proxy, RPC_PORT_PORT_CALLBACK, &handle->callback_port); + if (handle->callback.connected) + handle->callback.connected(handle, handle->user_data); + _I("[__RPC_PORT__] endpoint(%s), port_name(%s)", endpoint, port_name); +} + +static void __AutofillAppPort_on_disconnected(const char *endpoint, const char *port_name, void *data) +{ + rpc_port_proxy_AutofillAppPort_h handle = data; + + handle->port = NULL; + if (handle->callback.disconnected) + handle->callback.disconnected(handle, handle->user_data); + _I("[__RPC_PORT__] endpoint(%s), port_name(%s)", endpoint, port_name); +} + +static void __AutofillAppPort_on_rejected(const char *endpoint, const char *port_name, void *data) +{ + rpc_port_proxy_AutofillAppPort_h handle = data; + + handle->port = NULL; + if (handle->callback.rejected) + handle->callback.rejected(handle, handle->user_data); + _I("[__RPC_PORT__] endpoint(%s), port_name(%s)", endpoint, port_name); +} + +static void __AutofillAppPort_on_received(const char *endpoint, const char *port_name, void *data) +{ + rpc_port_proxy_AutofillAppPort_h handle = data; + rpc_port_parcel_h parcel_received; + int cmd = -1; + + rpc_port_parcel_create_from_port(&parcel_received, handle->callback_port); + rpc_port_parcel_read_int32(parcel_received, &cmd); + if (cmd != AutofillAppPort_METHOD_Callback) { + _E("Invalid protocol"); + rpc_port_parcel_destroy(parcel_received); + return; + } + + __AutofillAppPort_process_received_event(&handle->delegates, parcel_received); + rpc_port_parcel_destroy(parcel_received); + _I("[__RPC_PORT__] endpoint(%s), port_name(%s)", endpoint, port_name); +} + +int rpc_port_proxy_AutofillAppPort_invoke_Register(rpc_port_proxy_AutofillAppPort_h h, rpc_port_AutofillAppPort_autofill_auth_info_cb_h auth_info_cb, rpc_port_AutofillAppPort_autofill_fill_response_cb_h fill_response_cb) +{ + rpc_port_parcel_h parcel; + int r; + int ret = -1; + + if (!h || !auth_info_cb || !fill_response_cb) { + _E("Invalid parameter"); + return ret; + } + + if (!h->port) { + _E("Not connected"); + return ret; + } + + rpc_port_parcel_create(&parcel); + rpc_port_parcel_write_int32(parcel, AutofillAppPort_METHOD_Register); + + do { + struct AutofillAppPort_autofill_auth_info_cb_s *handle = auth_info_cb; + + rpc_port_parcel_write(parcel, &handle->parcelable, handle); + h->delegates = g_list_append(h->delegates, handle); + } while (0); + + do { + struct AutofillAppPort_autofill_fill_response_cb_s *handle = fill_response_cb; + + rpc_port_parcel_write(parcel, &handle->parcelable, handle); + h->delegates = g_list_append(h->delegates, handle); + } while (0); + + r = rpc_port_parcel_send(parcel, h->port); + if (r != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. result(%d)", r); + r = RPC_PORT_ERROR_IO_ERROR; + } + + rpc_port_parcel_destroy(parcel); + + g_rec_mutex_lock(&h->mutex); + do { + rpc_port_parcel_h parcel_received; + + parcel_received = __AutofillAppPort_consume_command(h); + if (!parcel_received) { + _E("Invalid protocol"); + break; + } + + rpc_port_parcel_read_int32(parcel_received, &ret); + + rpc_port_parcel_destroy(parcel_received); + } while (0); + g_rec_mutex_unlock(&h->mutex); + set_last_result(r); + + return ret; +} + +void rpc_port_proxy_AutofillAppPort_invoke_Unregister(rpc_port_proxy_AutofillAppPort_h h) +{ + rpc_port_parcel_h parcel; + int r; + + if (!h) { + _E("Invalid parameter"); + return; + } + + if (!h->port) { + _E("Not connected"); + return; + } + + rpc_port_parcel_create(&parcel); + rpc_port_parcel_write_int32(parcel, AutofillAppPort_METHOD_Unregister); + + r = rpc_port_parcel_send(parcel, h->port); + if (r != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. result(%d)", r); + r = RPC_PORT_ERROR_IO_ERROR; + } + + rpc_port_parcel_destroy(parcel); + set_last_result(r); +} + +void rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi) +{ + rpc_port_parcel_h parcel; + int r; + + if (!h || !vi) { + _E("Invalid parameter"); + return; + } + + if (!h->port) { + _E("Not connected"); + return; + } + + rpc_port_parcel_create(&parcel); + rpc_port_parcel_write_int32(parcel, AutofillAppPort_METHOD_request_auth_info); + rpc_port_parcel_write(parcel, &vi->parcelable, vi); + + r = rpc_port_parcel_send(parcel, h->port); + if (r != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. result(%d)", r); + r = RPC_PORT_ERROR_IO_ERROR; + } + + rpc_port_parcel_destroy(parcel); + set_last_result(r); +} + +void rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi) +{ + rpc_port_parcel_h parcel; + int r; + + if (!h || !vi) { + _E("Invalid parameter"); + return; + } + + if (!h->port) { + _E("Not connected"); + return; + } + + rpc_port_parcel_create(&parcel); + rpc_port_parcel_write_int32(parcel, AutofillAppPort_METHOD_send_fill_request); + rpc_port_parcel_write(parcel, &vi->parcelable, vi); + + r = rpc_port_parcel_send(parcel, h->port); + if (r != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. result(%d)", r); + r = RPC_PORT_ERROR_IO_ERROR; + } + + rpc_port_parcel_destroy(parcel); + set_last_result(r); +} + +static struct AutofillAppPort_s *__create_AutofillAppPort(const char *stub_appid, rpc_port_proxy_AutofillAppPort_callback_s *callback, void *user_data) +{ + struct AutofillAppPort_s *handle; + + handle = calloc(1, sizeof(struct AutofillAppPort_s)); + if (!handle) { + _E("Out of memory"); + return NULL; + } + + handle->stub_appid = strdup(stub_appid); + if (!handle->stub_appid) { + _E("Out of memory"); + free(handle); + return NULL; + } + + rpc_port_proxy_create(&handle->proxy); + if (!handle->proxy) { + _E("Failed to create proxy"); + free(handle->stub_appid); + free(handle); + return NULL; + } + + g_rec_mutex_init(&handle->mutex); + + handle->callback = *callback; + handle->user_data = user_data; + + return handle; +} + +static void __destroy_AutofillAppPort(struct AutofillAppPort_s *h) +{ + if (!h) + return; + + g_rec_mutex_clear(&h->mutex); + + if (h->delegates) + g_list_free_full(h->delegates, free); + + if (h->proxy) + rpc_port_proxy_destroy(h->proxy); + + if (h->stub_appid) + free(h->stub_appid); + + free(h); +} + +int rpc_port_proxy_AutofillAppPort_create(const char *stub_appid, rpc_port_proxy_AutofillAppPort_callback_s *callback, void *user_data, rpc_port_proxy_AutofillAppPort_h *h) +{ + struct AutofillAppPort_s *handle; + int r; + + if (!stub_appid || !callback || !h) { + _E("Invalid parameter"); + return -1; + } + + handle = __create_AutofillAppPort(stub_appid, callback, user_data); + if (!handle) + return -1; + + r = rpc_port_proxy_add_connected_event_cb(handle->proxy, __AutofillAppPort_on_connected, handle); + if (r != 0) { + _E("Failed to add connected event cb. err = %d", r); + __destroy_AutofillAppPort(handle); + return r; + } + + r = rpc_port_proxy_add_disconnected_event_cb(handle->proxy, __AutofillAppPort_on_disconnected, handle); + if (r != 0) { + _E("Failed to add disconnected event cb. err = %d", r); + __destroy_AutofillAppPort(handle); + return r; + } + + r = rpc_port_proxy_add_rejected_event_cb(handle->proxy, __AutofillAppPort_on_rejected, handle); + if (r != 0) { + _E("Failed to add rejected event cb. err = %d", r); + __destroy_AutofillAppPort(handle); + return r; + } + + r = rpc_port_proxy_add_received_event_cb(handle->proxy, __AutofillAppPort_on_received, handle); + if (r != 0) { + _E("Failed to add received event cb. err = %d", r); + __destroy_AutofillAppPort(handle); + return r; + } + + *h = handle; + + return 0; +} + +int rpc_port_proxy_AutofillAppPort_connect(rpc_port_proxy_AutofillAppPort_h h) +{ + int r; + + if (!h || !h->proxy) { + _E("Invalid parameter"); + return -1; + } + + r = rpc_port_proxy_connect(h->proxy, h->stub_appid, "AutofillAppPort"); + if (r != 0) { + _E("Failed to connect AutofillAppPort(%s)", h->stub_appid); + return r; + } + + return 0; +} + +int rpc_port_proxy_AutofillAppPort_destroy(rpc_port_proxy_AutofillAppPort_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + __destroy_AutofillAppPort(h); + return 0; +} diff --git a/client/autofill_proxy.h b/client/autofill_proxy.h new file mode 100644 index 0000000..c32a2f7 --- /dev/null +++ b/client/autofill_proxy.h @@ -0,0 +1,226 @@ +/* + * Generated by tidlc 1.3.1. + * + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct autofill_item_s *rpc_port_autofill_item_h; + +int rpc_port_autofill_item_create(rpc_port_autofill_item_h *h); + +int rpc_port_autofill_item_destroy(rpc_port_autofill_item_h h); + +int rpc_port_autofill_item_clone(rpc_port_autofill_item_h h, rpc_port_autofill_item_h *clone); + +int rpc_port_autofill_item_set_id(rpc_port_autofill_item_h h, const char *id); + +int rpc_port_autofill_item_set_label(rpc_port_autofill_item_h h, const char *label); + +int rpc_port_autofill_item_set_value(rpc_port_autofill_item_h h, const char *value); + +int rpc_port_autofill_item_set_autofill_hint(rpc_port_autofill_item_h h, int autofill_hint); + +int rpc_port_autofill_item_set_is_sensitive_data(rpc_port_autofill_item_h h, bool is_sensitive_data); + +int rpc_port_autofill_item_get_id(rpc_port_autofill_item_h h, char **id); + +int rpc_port_autofill_item_get_label(rpc_port_autofill_item_h h, char **label); + +int rpc_port_autofill_item_get_value(rpc_port_autofill_item_h h, char **value); + +int rpc_port_autofill_item_get_autofill_hint(rpc_port_autofill_item_h h, int *autofill_hint); + +int rpc_port_autofill_item_get_is_sensitive_data(rpc_port_autofill_item_h h, bool *is_sensitive_data); + +typedef struct autofill_view_info_s *rpc_port_autofill_view_info_h; + +int rpc_port_autofill_view_info_create(rpc_port_autofill_view_info_h *h); + +int rpc_port_autofill_view_info_destroy(rpc_port_autofill_view_info_h h); + +int rpc_port_autofill_view_info_clone(rpc_port_autofill_view_info_h h, rpc_port_autofill_view_info_h *clone); + +int rpc_port_autofill_view_info_set_view_id(rpc_port_autofill_view_info_h h, const char *view_id); + +int rpc_port_autofill_view_info_add_items(rpc_port_autofill_view_info_h h, rpc_port_autofill_item_h items); + +int rpc_port_autofill_view_info_get_view_id(rpc_port_autofill_view_info_h h, char **view_id); + +int rpc_port_autofill_view_info_foreach_items(rpc_port_autofill_view_info_h h, + bool (*callback)(rpc_port_autofill_item_h items, void *user_data), void *user_data); + +int rpc_port_autofill_view_info_remove_items(rpc_port_autofill_view_info_h h, unsigned int nth); + +int rpc_port_autofill_view_info_get_items_length(rpc_port_autofill_view_info_h h, unsigned int *length); + +typedef struct autofill_auth_info_s *rpc_port_autofill_auth_info_h; + +int rpc_port_autofill_auth_info_create(rpc_port_autofill_auth_info_h *h); + +int rpc_port_autofill_auth_info_destroy(rpc_port_autofill_auth_info_h h); + +int rpc_port_autofill_auth_info_clone(rpc_port_autofill_auth_info_h h, rpc_port_autofill_auth_info_h *clone); + +int rpc_port_autofill_auth_info_set_exist_autofill_data(rpc_port_autofill_auth_info_h h, bool exist_autofill_data); + +int rpc_port_autofill_auth_info_set_need_authentication(rpc_port_autofill_auth_info_h h, bool need_authentication); + +int rpc_port_autofill_auth_info_set_service_name(rpc_port_autofill_auth_info_h h, const char *service_name); + +int rpc_port_autofill_auth_info_set_service_logo_image_path(rpc_port_autofill_auth_info_h h, const char *service_logo_image_path); + +int rpc_port_autofill_auth_info_set_service_message(rpc_port_autofill_auth_info_h h, const char *service_message); + +int rpc_port_autofill_auth_info_get_exist_autofill_data(rpc_port_autofill_auth_info_h h, bool *exist_autofill_data); + +int rpc_port_autofill_auth_info_get_need_authentication(rpc_port_autofill_auth_info_h h, bool *need_authentication); + +int rpc_port_autofill_auth_info_get_service_name(rpc_port_autofill_auth_info_h h, char **service_name); + +int rpc_port_autofill_auth_info_get_service_logo_image_path(rpc_port_autofill_auth_info_h h, char **service_logo_image_path); + +int rpc_port_autofill_auth_info_get_service_message(rpc_port_autofill_auth_info_h h, char **service_message); + +typedef struct autofill_response_item_s *rpc_port_autofill_response_item_h; + +int rpc_port_autofill_response_item_create(rpc_port_autofill_response_item_h *h); + +int rpc_port_autofill_response_item_destroy(rpc_port_autofill_response_item_h h); + +int rpc_port_autofill_response_item_clone(rpc_port_autofill_response_item_h h, rpc_port_autofill_response_item_h *clone); + +int rpc_port_autofill_response_item_set_id(rpc_port_autofill_response_item_h h, const char *id); + +int rpc_port_autofill_response_item_set_presentation_text(rpc_port_autofill_response_item_h h, const char *presentation_text); + +int rpc_port_autofill_response_item_set_value(rpc_port_autofill_response_item_h h, const char *value); + +int rpc_port_autofill_response_item_get_id(rpc_port_autofill_response_item_h h, char **id); + +int rpc_port_autofill_response_item_get_presentation_text(rpc_port_autofill_response_item_h h, char **presentation_text); + +int rpc_port_autofill_response_item_get_value(rpc_port_autofill_response_item_h h, char **value); + +typedef struct autofill_fill_response_s *rpc_port_autofill_fill_response_h; + +int rpc_port_autofill_fill_response_create(rpc_port_autofill_fill_response_h *h); + +int rpc_port_autofill_fill_response_destroy(rpc_port_autofill_fill_response_h h); + +int rpc_port_autofill_fill_response_clone(rpc_port_autofill_fill_response_h h, rpc_port_autofill_fill_response_h *clone); + +int rpc_port_autofill_fill_response_set_view_id(rpc_port_autofill_fill_response_h h, const char *view_id); + +int rpc_port_autofill_fill_response_add_response_items(rpc_port_autofill_fill_response_h h, rpc_port_autofill_response_item_h response_items); + +int rpc_port_autofill_fill_response_get_view_id(rpc_port_autofill_fill_response_h h, char **view_id); + +int rpc_port_autofill_fill_response_foreach_response_items(rpc_port_autofill_fill_response_h h, + bool (*callback)(rpc_port_autofill_response_item_h response_items, void *user_data), void *user_data); + +int rpc_port_autofill_fill_response_remove_response_items(rpc_port_autofill_fill_response_h h, unsigned int nth); + +int rpc_port_autofill_fill_response_get_response_items_length(rpc_port_autofill_fill_response_h h, unsigned int *length); + +typedef struct list_autofill_item_s *rpc_port_list_autofill_item_h; + +int rpc_port_list_autofill_item_create(rpc_port_list_autofill_item_h *h); + +int rpc_port_list_autofill_item_destroy(rpc_port_list_autofill_item_h h); + +int rpc_port_list_autofill_item_clone(rpc_port_list_autofill_item_h h, rpc_port_list_autofill_item_h *clone); + +int rpc_port_list_autofill_item_add_list_autofill_items(rpc_port_list_autofill_item_h h, rpc_port_autofill_item_h list_autofill_items); + +int rpc_port_list_autofill_item_foreach_list_autofill_items(rpc_port_list_autofill_item_h h, + bool (*callback)(rpc_port_autofill_item_h list_autofill_items, void *user_data), void *user_data); + +int rpc_port_list_autofill_item_remove_list_autofill_items(rpc_port_list_autofill_item_h h, unsigned int nth); + +int rpc_port_list_autofill_item_get_list_autofill_items_length(rpc_port_list_autofill_item_h h, unsigned int *length); + +typedef struct list_autofill_response_item_s *rpc_port_list_autofill_response_item_h; + +int rpc_port_list_autofill_response_item_create(rpc_port_list_autofill_response_item_h *h); + +int rpc_port_list_autofill_response_item_destroy(rpc_port_list_autofill_response_item_h h); + +int rpc_port_list_autofill_response_item_clone(rpc_port_list_autofill_response_item_h h, rpc_port_list_autofill_response_item_h *clone); + +int rpc_port_list_autofill_response_item_add_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, rpc_port_autofill_response_item_h list_autofill_response_items); + +int rpc_port_list_autofill_response_item_foreach_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, + bool (*callback)(rpc_port_autofill_response_item_h list_autofill_response_items, void *user_data), void *user_data); + +int rpc_port_list_autofill_response_item_remove_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, unsigned int nth); + +int rpc_port_list_autofill_response_item_get_list_autofill_response_items_length(rpc_port_list_autofill_response_item_h h, unsigned int *length); + +typedef struct AutofillAppPort_s *rpc_port_proxy_AutofillAppPort_h; + +typedef struct { + void (*connected)(rpc_port_proxy_AutofillAppPort_h h, void *user_data); + void (*disconnected)(rpc_port_proxy_AutofillAppPort_h h, void *user_data); + void (*rejected)(rpc_port_proxy_AutofillAppPort_h h, void *user_data); +} rpc_port_proxy_AutofillAppPort_callback_s; + +typedef struct AutofillAppPort_autofill_auth_info_cb_s *rpc_port_AutofillAppPort_autofill_auth_info_cb_h; + +typedef void (*AutofillAppPort_autofill_auth_info_cb)(void *user_data, rpc_port_autofill_auth_info_h auth_info); + +rpc_port_AutofillAppPort_autofill_auth_info_cb_h rpc_port_AutofillAppPort_autofill_auth_info_cb_create(AutofillAppPort_autofill_auth_info_cb callback, bool once, void *user_data); + +int rpc_port_AutofillAppPort_autofill_auth_info_cb_destroy(rpc_port_AutofillAppPort_autofill_auth_info_cb_h delegate); + +int rpc_port_proxy_AutofillAppPort_autofill_auth_info_cb_dispose(rpc_port_proxy_AutofillAppPort_h proxy, rpc_port_AutofillAppPort_autofill_auth_info_cb_h delegate); + +typedef struct AutofillAppPort_autofill_fill_response_cb_s *rpc_port_AutofillAppPort_autofill_fill_response_cb_h; + +typedef void (*AutofillAppPort_autofill_fill_response_cb)(void *user_data, rpc_port_autofill_fill_response_h response); + +rpc_port_AutofillAppPort_autofill_fill_response_cb_h rpc_port_AutofillAppPort_autofill_fill_response_cb_create(AutofillAppPort_autofill_fill_response_cb callback, bool once, void *user_data); + +int rpc_port_AutofillAppPort_autofill_fill_response_cb_destroy(rpc_port_AutofillAppPort_autofill_fill_response_cb_h delegate); + +int rpc_port_proxy_AutofillAppPort_autofill_fill_response_cb_dispose(rpc_port_proxy_AutofillAppPort_h proxy, rpc_port_AutofillAppPort_autofill_fill_response_cb_h delegate); + +int rpc_port_proxy_AutofillAppPort_create(const char *stub_appid, + rpc_port_proxy_AutofillAppPort_callback_s *callback, void *user_data, + rpc_port_proxy_AutofillAppPort_h *h); + +int rpc_port_proxy_AutofillAppPort_connect(rpc_port_proxy_AutofillAppPort_h h); + +int rpc_port_proxy_AutofillAppPort_destroy(rpc_port_proxy_AutofillAppPort_h h); + +int rpc_port_proxy_AutofillAppPort_invoke_Register(rpc_port_proxy_AutofillAppPort_h h, rpc_port_AutofillAppPort_autofill_auth_info_cb_h auth_info_cb, rpc_port_AutofillAppPort_autofill_fill_response_cb_h fill_response_cb); + +void rpc_port_proxy_AutofillAppPort_invoke_Unregister(rpc_port_proxy_AutofillAppPort_h h); + +void rpc_port_proxy_AutofillAppPort_invoke_request_auth_info(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi); + +void rpc_port_proxy_AutofillAppPort_invoke_send_fill_request(rpc_port_proxy_AutofillAppPort_h h, rpc_port_autofill_view_info_h vi); + +#ifdef __cplusplus +} +#endif diff --git a/client/capi-ui-autofill.manifest b/client/capi-ui-autofill.manifest new file mode 100644 index 0000000..dfdc35c --- /dev/null +++ b/client/capi-ui-autofill.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/client/capi-ui-autofill.pc.in b/client/capi-ui-autofill.pc.in new file mode 100644 index 0000000..7740411 --- /dev/null +++ b/client/capi-ui-autofill.pc.in @@ -0,0 +1,14 @@ +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=@LIBDIR@ +includedir=/usr/include + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} + diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt new file mode 100644 index 0000000..6e33fb6 --- /dev/null +++ b/common/CMakeLists.txt @@ -0,0 +1,106 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET(project_prefix "capi") +SET(prefix "/usr") +SET(version "0.0.1") +SET(maintainer "Jihoon Kim ") +SET(description "Autofill Common APIs") +SET(service "ui") +SET(submodule "autofill-common") +SET(dependents "dlog eina capi-appfw-application glib-2.0 rpc-port") +SET(LIBDIR ${LIB_INSTALL_DIR}) + +SET(Services + "application" + "base" + "content" + "location" + "media" + "messaging" + "network" + "social" + "telephony" + "system" + "ui" + ) + +#FILE(STRINGS config.cfg configs REGEX "^ *[^#]") +FOREACH(lines ${configs}) +# MESSAGE(${lines}) + IF(${lines} MATCHES "([^=]*)=['\"](.*)['\"]") + SET(key ${CMAKE_MATCH_1}) + SET(value ${CMAKE_MATCH_2}) +# MESSAGE("${key} -> ${value}") + SET(${key} "${value}") + ENDIF() +ENDFOREACH(lines ${configs}) + +LIST(FIND Services ${service} sfind) + +IF( ${sfind} EQUAL -1 ) + MESSAGE(FATAL_ERROR "Service must be one of ") + FOREACH( s IN ${Services} ) + MESSAGE(FATAL_ERROR "[${s}]") + ENDFOREACH( s IN ${Services} ) +ENDIF( ${sfind} EQUAL -1 ) + +SET(fw_name "${project_prefix}-${service}-${submodule}") + +PROJECT(${fw_name} C) + +SET(CMAKE_INSTALL_PREFIX ${prefix}) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(VERSION ${version}) + +SET(INC_DIR ../include) +INCLUDE_DIRECTORIES(${INC_DIR}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_name} REQUIRED ${dependents}) +FOREACH(flag ${${fw_name}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -fpermissive") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") + +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DTIZEN_DEBUG") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") + +aux_source_directory(. SOURCES) +ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) + +TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) + +SET_TARGET_PROPERTIES(${fw_name} + PROPERTIES + VERSION ${FULLVER} + SOVERSION ${MAJORVER} + CLEAN_DIRECT_OUTPUT 1 +) + +INSTALL(TARGETS ${fw_name} DESTINATION ${LIBDIR}) +INSTALL( + DIRECTORY ${INC_DIR}/ DESTINATION include + FILES_MATCHING + PATTERN "*_private.h" EXCLUDE + PATTERN "${INC_DIR}/*.h" + ) + +SET(PC_NAME ${fw_name}) +SET(PC_REQUIRED ${dependents}) +SET(PC_LDFLAGS -l${fw_name}) + +CONFIGURE_FILE( + capi-ui-autofill-common.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc + @ONLY +) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIBDIR}/pkgconfig) diff --git a/common/autofill_auth_info.c b/common/autofill_auth_info.c new file mode 100644 index 0000000..66cb1ce --- /dev/null +++ b/common/autofill_auth_info.c @@ -0,0 +1,208 @@ +/* + * 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 +#include +#include +#include +#include +#include + +#include "autofill_private.h" +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILL" + +struct autofill_auth_info_s { + char *app_id; + bool exist_autofill_data; // autofill data 보유 여부 + bool need_authentication; // 인증 필요 여부 + + char *service_name; // 서비스 이름 (ex> Samsung Pass) + char *service_logo_image_path; // 서비스 로고 이미지 경로 (ex> /home/owner/…/appid/shared/samsung_pass_logo.png) + char *service_message; // 표기 메시지 (ex> samsung pass로 로그인) +}; + +EXPORT_API int autofill_auth_info_create(autofill_auth_info_h *vi) +{ + if (!vi) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + struct autofill_auth_info_s *vs = (autofill_auth_info_h)calloc(1, sizeof(struct autofill_auth_info_s)); + if (!vs) + return AUTOFILL_ERROR_OUT_OF_MEMORY; + + *vi = (autofill_auth_info_h)vs; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_destroy(autofill_auth_info_h vi) +{ + if (!vi) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (vi->app_id) + free(vi->app_id); + + if (vi->service_name) + free(vi->service_name); + + if (vi->service_message) + free(vi->service_message); + + if (vi->service_logo_image_path) + free(vi->service_logo_image_path); + + free(vi); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_set_exist_autofill_data(autofill_auth_info_h vi, bool exist_autofill_data) +{ + if (!vi) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + vi->exist_autofill_data = exist_autofill_data; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_get_exist_autofill_data(autofill_auth_info_h vi, bool *exist_autofill_data) +{ + if (!vi || !exist_autofill_data) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + *exist_autofill_data = vi->exist_autofill_data; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_set_need_authentication(autofill_auth_info_h vi, bool need_authentication) +{ + if (!vi) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + vi->need_authentication = need_authentication; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_get_need_authentication(autofill_auth_info_h vi, bool *need_authentication) +{ + if (!vi || !need_authentication) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + *need_authentication = vi->need_authentication; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_set_service_name(autofill_auth_info_h vi, const char *service_name) +{ + if (!vi || !service_name) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (vi->service_name) + free(vi->service_name); + + vi->service_name = strdup(service_name); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_get_service_name(autofill_auth_info_h vi, char **service_name) +{ + if (!vi || !service_name) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + *service_name = strdup(vi->service_name); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_set_service_message(autofill_auth_info_h vi, const char *service_message) +{ + if (!vi || !service_message) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (vi->service_message) + free(vi->service_message); + + vi->service_message = strdup(service_message); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_get_service_message(autofill_auth_info_h vi, char **service_message) +{ + if (!vi || !service_message) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + *service_message = strdup(vi->service_message); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_set_service_logo_image_path(autofill_auth_info_h vi, const char *service_logo_image_path) +{ + if (!vi || !service_logo_image_path) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (vi->service_logo_image_path) + free(vi->service_logo_image_path); + + vi->service_logo_image_path = strdup(service_logo_image_path); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_get_service_logo_image_path(autofill_auth_info_h vi, char **service_logo_image_path) +{ + if (!vi || !service_logo_image_path) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + *service_logo_image_path = strdup(vi->service_logo_image_path); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_set_app_id(autofill_auth_info_h vi, const char *app_id) +{ + if (!vi || !app_id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (vi->app_id) + free(vi->app_id); + + vi->app_id = strdup(app_id); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_auth_info_get_app_id(autofill_auth_info_h vi, char **app_id) +{ + if (!vi) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + *app_id = strdup(vi->app_id); + + return AUTOFILL_ERROR_NONE; +} diff --git a/common/autofill_fill_response.c b/common/autofill_fill_response.c new file mode 100644 index 0000000..67e5bf5 --- /dev/null +++ b/common/autofill_fill_response.c @@ -0,0 +1,154 @@ +/* + * 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 +#include +#include +#include +#include +#include "autofill_private.h" +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILL" + +EXPORT_API int autofill_fill_response_create(autofill_fill_response_h *h) +{ + LOGD("autofill fill response item create"); + + if (!h) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + autofill_fill_response_h ri = (autofill_fill_response_h)calloc(1, sizeof(struct autofill_fill_response_s)); + if (!ri) + return AUTOFILL_ERROR_OUT_OF_MEMORY; + + *h = (autofill_fill_response_h)ri; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_fill_response_destroy(autofill_fill_response_h h) +{ + if (!h) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (h->view_id) + free(h->view_id); + + // Release memory autofill fill response item list + autofill_fill_response_item_h it_h; + EINA_LIST_FREE(h->autofill_fill_response_item_list, it_h) + autofill_fill_response_item_destroy(it_h); + + free(h); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_fill_response_set_app_id(autofill_fill_response_h h, const char *app_id) +{ + if (!h || !app_id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (h->app_id) { + free(h->app_id); + } + + h->app_id = strdup(app_id); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_fill_response_get_app_id(autofill_fill_response_h h, char **app_id) +{ + if (!h || !app_id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (!h->app_id) + return AUTOFILL_ERROR_OPERATION_FAILED; + + *app_id = strdup(h->app_id); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_fill_response_set_view_id(autofill_fill_response_h h, const char *view_id) +{ + if (!h || !view_id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (h->view_id) { + free(h->view_id); + } + + h->view_id = strdup(view_id); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_fill_response_get_view_id(autofill_fill_response_h h, char **view_id) +{ + if (!h || !view_id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (!h->view_id) + return AUTOFILL_ERROR_OPERATION_FAILED; + + *view_id = strdup(h->view_id); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_fill_response_add_item(autofill_fill_response_h h, autofill_fill_response_item_h it) +{ + if (!h || !it) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + LOGD("autofill fill response item : %p", it); + + autofill_fill_response_item_h clone; + autofill_fill_response_item_clone(it, &clone); + if (!clone) { + LOGW("Out of memory"); + return AUTOFILL_ERROR_OUT_OF_MEMORY; + } + + h->autofill_fill_response_item_list = eina_list_append(h->autofill_fill_response_item_list, clone); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_fill_response_foreach_items(autofill_fill_response_h h, + bool (*callback)(autofill_fill_response_item_h item, void *user_data), void *user_data) +{ + if (!h || !callback) { + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + Eina_List *l; + autofill_fill_response_item_h it; + EINA_LIST_FOREACH(h->autofill_fill_response_item_list, l, it) + { + bool ret = callback(it, user_data); + if (!ret) + break; + } + + return 0; +} diff --git a/common/autofill_fill_response_item.c b/common/autofill_fill_response_item.c new file mode 100644 index 0000000..54982e0 --- /dev/null +++ b/common/autofill_fill_response_item.c @@ -0,0 +1,205 @@ +/* + * 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 +#include +#include +#include +#include +#include "autofill_private.h" +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILL" + +struct autofill_response_item_s { + char *id; + char *presentation_text; // context popup 표기용 (ex> ‘ID A’s password) + char *value; // autofill value +}; + +// autofill fill response item 생성 +EXPORT_API int autofill_fill_response_item_create(autofill_fill_response_item_h *it) +{ + LOGD("autofill fill response item create"); + + if (!it) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + autofill_fill_response_item_h ri = (autofill_fill_response_item_h)calloc(1, sizeof(struct autofill_response_item_s)); + if (!ri) + return AUTOFILL_ERROR_OUT_OF_MEMORY; + + *it = (autofill_fill_response_item_h)ri; + + return AUTOFILL_ERROR_NONE; +} + +// autofill fill response item 삭제 +EXPORT_API int autofill_fill_response_item_destroy(autofill_fill_response_item_h it) +{ + if (!it) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (it->id) + free(it->id); + + if (it->value) + free(it->value); + + if (it->presentation_text) + free(it->presentation_text); + + free(it); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_fill_response_item_clone(autofill_fill_response_item_h h, autofill_fill_response_item_h *clone) +{ + autofill_fill_response_item_h handle; + + if (!h || !clone) { + LOGW("Invalid parameter"); + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + autofill_fill_response_item_create(&handle); + if (!handle) { + LOGW("Failed to create autofill_item handle"); + return AUTOFILL_ERROR_OPERATION_FAILED; + } + + if (h->id) { + handle->id = strdup(h->id); + if (!handle->id) { + LOGW("Failed to duplicate h->id"); + autofill_fill_response_item_destroy(handle); + return AUTOFILL_ERROR_OUT_OF_MEMORY; + } + } + + if (h->presentation_text) { + handle->presentation_text = strdup(h->presentation_text); + if (!handle->presentation_text) { + LOGW("Failed to duplicate h->presentation_text"); + autofill_fill_response_item_destroy(handle); + return AUTOFILL_ERROR_OUT_OF_MEMORY; + } + } + + if (h->value) { + handle->value = strdup(h->value); + if (!handle->value) { + LOGW("Failed to duplicate h->value"); + autofill_fill_response_item_destroy(handle); + return AUTOFILL_ERROR_OUT_OF_MEMORY; + } + } + + *clone = handle; + + return AUTOFILL_ERROR_NONE; +} + +// Set autofill ID +EXPORT_API int autofill_fill_response_item_set_id(autofill_fill_response_item_h it, const char *id) +{ + if (!it || !id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (it->id) { + free(it->id); + } + + it->id = strdup(id); + + return AUTOFILL_ERROR_NONE; +} + +// Get autofill ID +EXPORT_API int autofill_fill_response_item_get_id(autofill_fill_response_item_h it, char **id) +{ + if (!it || !id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (!it->id) + return AUTOFILL_ERROR_OPERATION_FAILED; + + *id = strdup(it->id); + + return AUTOFILL_ERROR_NONE; +} + +// Set autofill value +EXPORT_API int autofill_fill_response_item_set_value(autofill_fill_response_item_h it, const char *value) +{ + if (!it || !value) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (it->value) { + free(it->value); + } + + it->value = strdup(value); + + return AUTOFILL_ERROR_NONE; +} + +// Get autofill value +EXPORT_API int autofill_fill_response_item_get_value(autofill_fill_response_item_h it, char **value) +{ + if (!it || !value) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (!it->value) + return AUTOFILL_ERROR_OPERATION_FAILED; + + *value = strdup(it->value); + + return AUTOFILL_ERROR_NONE; +} + +// Set presentation text +EXPORT_API int autofill_fill_response_item_set_presentation_text(autofill_fill_response_item_h it, const char *presentation_text) +{ + if (!it || !presentation_text) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (it->presentation_text) { + free(it->presentation_text); + } + + it->presentation_text = strdup(presentation_text); + + return AUTOFILL_ERROR_NONE; +} + +// Get presentation text +EXPORT_API int autofill_fill_response_item_get_presentation_text(autofill_fill_response_item_h it, char ** presentation_text) +{ + if (!it || !presentation_text) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (!it->presentation_text) + return AUTOFILL_ERROR_OPERATION_FAILED; + + *presentation_text = strdup(it->presentation_text); + + return AUTOFILL_ERROR_NONE; +} diff --git a/common/autofill_item.c b/common/autofill_item.c new file mode 100644 index 0000000..f271d6d --- /dev/null +++ b/common/autofill_item.c @@ -0,0 +1,252 @@ +/* + * 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 +#include +#include +#include +#include +#include "autofill_private.h" +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILL" + +struct autofill_item_s { + char *id; + char *label; + char *value; + autofill_hint_e autofill_hint; + bool is_sensitive_data; +}; + +EXPORT_API int autofill_item_create(autofill_item_h *it) +{ + if (!it) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + struct autofill_item_s *ai = (autofill_item_h)calloc(1, sizeof(struct autofill_item_s)); + if (!ai) + return AUTOFILL_ERROR_OUT_OF_MEMORY; + + ai->is_sensitive_data = false; + + *it = (autofill_item_h)ai; + + return AUTOFILL_ERROR_NONE; +} + +// Destroy autofill info list item +EXPORT_API int autofill_item_destroy(autofill_item_h it) +{ + if (!it) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (it->id) + free(it->id); + + if (it->label) + free(it->label); + + if (it->value) + free(it->value); + + free(it); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_item_clone(autofill_item_h h, autofill_item_h *clone) +{ + autofill_item_h handle; + + if (!h || !clone) { + LOGW("Invalid parameter"); + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + autofill_item_create(&handle); + if (!handle) { + LOGW("Failed to create autofill_item handle"); + return AUTOFILL_ERROR_OPERATION_FAILED; + } + + if (h->id) { + handle->id = strdup(h->id); + if (!handle->id) { + LOGW("Failed to duplicate h->id"); + autofill_item_destroy(handle); + return AUTOFILL_ERROR_OUT_OF_MEMORY; + } + } + + if (h->label) { + handle->label = strdup(h->label); + if (!handle->label) { + LOGW("Failed to duplicate h->label"); + autofill_item_destroy(handle); + return AUTOFILL_ERROR_OUT_OF_MEMORY; + } + } + + if (h->value) { + handle->value = strdup(h->value); + if (!handle->value) { + LOGW("Failed to duplicate h->value"); + autofill_item_destroy(handle); + return AUTOFILL_ERROR_OUT_OF_MEMORY; + } + } + + handle->autofill_hint = h->autofill_hint; + handle->is_sensitive_data = h->is_sensitive_data; + + *clone = handle; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_item_set_autofill_hint(autofill_item_h it, autofill_hint_e hints) +{ + if (!it) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + it->autofill_hint = hints; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_item_get_autofill_hint(autofill_item_h it, autofill_hint_e *hints) +{ + if (!it || !hints) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + *hints = it->autofill_hint; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_item_set_id(autofill_item_h it, const char *id) +{ + if (!it || !id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (it->id) { + free(it->id); + } + + it->id = strdup(id); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_item_get_id(autofill_item_h it, char **id) +{ + if (!it || !id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (!it->id) { + return AUTOFILL_ERROR_OPERATION_FAILED; + } + + *id = strdup(it->id); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_item_set_label(autofill_item_h it, const char *label) +{ + if (!it || !label) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (it->label) { + free(it->label); + } + + it->label = strdup(label); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_item_get_label(autofill_item_h it, char **label) +{ + if (!it || !label) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (!it->label) { + return AUTOFILL_ERROR_OPERATION_FAILED; + } + + *label = strdup(it->label); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_item_set_sensitive_data(autofill_item_h it, bool sensitive) +{ + if (!it) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + it->is_sensitive_data = sensitive; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_item_get_sensitive_data(autofill_item_h it, bool *sensitive) +{ + if (!it || !sensitive) { + LOGW("AUTOFILL_ERROR_INVALID_PARAMETER"); + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + *sensitive = it->is_sensitive_data; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_item_set_value(autofill_item_h it, const char *value) +{ + if (!it || !value) { + LOGW("AUTOFILL_ERROR_INVALID_PARAMETER"); + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + if (it->value) { + free(it->value); + } + + it->value = strdup(value); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_item_get_value(autofill_item_h it, char **value) +{ + if (!it || !value) { + LOGW("AUTOFILL_ERROR_INVALID_PARAMETER"); + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + if (!it->value) { + return AUTOFILL_ERROR_OPERATION_FAILED; + } + + *value = strdup(it->value); + + return AUTOFILL_ERROR_NONE; +} diff --git a/common/autofill_view_info.c b/common/autofill_view_info.c new file mode 100644 index 0000000..6ce95f1 --- /dev/null +++ b/common/autofill_view_info.c @@ -0,0 +1,155 @@ +/* + * 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 +#include +#include +#include +#include +#include +//#include + +#include "autofill_private.h" +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILL" + +EXPORT_API int autofill_view_info_create(autofill_view_info_h *vi) +{ + if (!vi) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + struct autofill_view_info_s *vs = (struct autofill_view_info_s *)calloc(1, sizeof(struct autofill_view_info_s)); + if (!vs) + return AUTOFILL_ERROR_OUT_OF_MEMORY; + + *vi = (autofill_view_info_h)vs; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_view_info_destroy(autofill_view_info_h vi) +{ + if (!vi) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (vi->app_id) + free(vi->app_id); + + if (vi->view_id) + free(vi->view_id); + + // release memory autofill item list + autofill_item_h it_h; + EINA_LIST_FREE(vi->autofill_item_list, it_h) + autofill_item_destroy(it_h); + + free(vi); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_view_info_set_app_id(autofill_view_info_h vi, const char *app_id) +{ + if (!vi || !app_id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (vi->app_id) + free(vi->app_id); + + vi->app_id = strdup(app_id); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_view_info_get_app_id(autofill_view_info_h vi, char **app_id) +{ + if (!vi || !app_id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (!vi->app_id) + return AUTOFILL_ERROR_OPERATION_FAILED; + + *app_id = strdup(vi->app_id); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_view_info_set_view_id(autofill_view_info_h vi, const char *view_id) +{ + if (!vi || !view_id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (vi->view_id) + free(vi->view_id); + + vi->view_id = strdup(view_id); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_view_info_get_view_id(autofill_view_info_h vi, char **view_id) +{ + if (!vi || !view_id) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + if (!vi->view_id) + return AUTOFILL_ERROR_OPERATION_FAILED; + + *view_id = strdup(vi->view_id); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_view_info_add_item(const autofill_view_info_h vi, autofill_item_h it) +{ + if (!vi || !it) + return AUTOFILL_ERROR_INVALID_PARAMETER; + + autofill_item_h clone = NULL; + + autofill_item_clone(it, &clone); + if (!clone) { + LOGW("Out of memory"); + return AUTOFILL_ERROR_OUT_OF_MEMORY; + } + + vi->autofill_item_list = eina_list_append(vi->autofill_item_list, clone); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_view_info_foreach_items(autofill_view_info_h h, + bool (*callback)(autofill_item_h item, void *user_data), void *user_data) +{ + if (!h || !callback) { + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + Eina_List *l; + autofill_item_h it; + EINA_LIST_FOREACH(h->autofill_item_list, l, it) + { + bool ret = callback(it, user_data); + if (!ret) + break; + } + + return 0; +} diff --git a/common/capi-ui-autofill-common.manifest b/common/capi-ui-autofill-common.manifest new file mode 100644 index 0000000..dfdc35c --- /dev/null +++ b/common/capi-ui-autofill-common.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/common/capi-ui-autofill-common.pc.in b/common/capi-ui-autofill-common.pc.in new file mode 100644 index 0000000..7740411 --- /dev/null +++ b/common/capi-ui-autofill-common.pc.in @@ -0,0 +1,14 @@ +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=@LIBDIR@ +includedir=/usr/include + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} + diff --git a/doc/autofill_doc.h b/doc/autofill_doc.h new file mode 100644 index 0000000..3315b40 --- /dev/null +++ b/doc/autofill_doc.h @@ -0,0 +1,37 @@ +/* + * 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. + */ + +#ifndef __TIZEN_UIX_AUTOFILL_DOC_H__ +#define __TIZEN_UIX_AUTOFILL_DOC_H__ + + +/** + * @ingroup CAPI_UIX_FRAMEWORK + * @defgroup CAPI_UIX_AUTOFILL_MODULE Input Method + * @brief The @ref CAPI_UIX_AUTOFILL_MODULE API provides the functions for starting IME application lifecycle, + * methods to interact with current UI state of IME, and getting attributes/events. + * @section CAPI_UIX_AUTOFILL_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_UIX_AUTOFILL_MODULE_OVERVIEW Overview + * Input method editor (IME) is an input panel that lets users provide input and the platform receive the text data entered. + * Custom keyboards can be built according to the application's necessity by these API sets. + * Tizen provides a framework to create such input method editors. Such extra input methods can be selected from Settings. + */ + + +#endif /* __TIZEN_UIX_AUTOFILL_DOC_H__ */ + diff --git a/include/autofill.h b/include/autofill.h new file mode 100644 index 0000000..dcd4c11 --- /dev/null +++ b/include/autofill.h @@ -0,0 +1,170 @@ +/* + * 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. + */ + +#ifndef __TIZEN_UIX_AUTOFILL_H__ +#define __TIZEN_UIX_AUTOFILL_H__ + +/** + * @file autofill.h + * @brief This file contains autofill APIs and related enumeration. + */ + +#include +#include +#include "autofill_enum.h" +#include "autofill_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_UIX_AUTOFILL_MODULE + * @{ + */ + +/** + * @brief Enumeration of connection status. + * @since_tizen 5.5 + */ +typedef enum { + AUTOFILL_CONNECTION_STATUS_CONNECTED = 0, /**< Connected */ + AUTOFILL_CONNECTION_STATUS_DISCONNECTED, /**< Disconnected */ + AUTOFILL_CONNECTION_STATUS_REJECTED, /**< Rejected */ +} autofill_connection_status_e; + +/** +* @brief Called when the connection status is changed. +* @since_tizen 5.5 +* @param[in] status The connection status +* @param[in] user_data The user data passed from the callback function +* @see autofill_initialize() +* @see autofill_deinitialize() +*/ +typedef void(*autofill_connection_status_changed_cb)(autofill_connection_status_e status, void* user_data); + +typedef void (*Autofill_Fill_Response_Cb)(autofill_fill_response_h fill_response, void *data); + +typedef void (*Autofill_Auth_Info_Cb)(autofill_auth_info_h auth_info, void *data); + +// initialize / deinitialize +/** + * @brief Autofill initialize + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_initialize(autofill_connection_status_changed_cb callback, void *user_data); + +/** + * @brief Autofill deinitialize + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_deinitialize(); + +// auth +/** + * @brief Request of authentication information + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_request(autofill_view_info_h vi); + +/** + * @brief Register the callback to receive the authentication information + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_set_callback(Autofill_Auth_Info_Cb autofill_auth_info_cb, void *data); + +/** + * @brief Unregister the callback to receive the authentication information + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_unset_callback(); + +/** + * @brief Send fill request to fill out each input form + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_request(autofill_view_info_h vi); + +// fill response +/** + * @brief Register the callback to receive autofill fill response + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_set_callback(Autofill_Fill_Response_Cb autofill_response_cb, void *data); + +/** + * @brief Register the callback to receive autofill fill response + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_unset_callback(); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_UIX_AUTOFILL_H__ */ diff --git a/include/autofill_common.h b/include/autofill_common.h new file mode 100644 index 0000000..024e5ad --- /dev/null +++ b/include/autofill_common.h @@ -0,0 +1,678 @@ +/* + * 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. + */ + +#ifndef __TIZEN_UIX_AUTOFILL_COMMON_H__ +#define __TIZEN_UIX_AUTOFILL_COMMON_H__ + +/** + * @file autofill_common.h + * @brief This file contains autofill APIs and related enumeration. + */ + +#include +#include +#include "autofill_enum.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_UIX_AUTOFILL_COMMON_MODULE + * @{ + */ + +/** + * @brief Enumeration for autofill function error + * + * @since_tizen 5.5 + */ +typedef enum { + AUTOFILL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + AUTOFILL_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O Error */ + AUTOFILL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + AUTOFILL_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + AUTOFILL_ERROR_NO_CALLBACK_FUNCTION = TIZEN_ERROR_IME | 0x0001, /**< Necessary callback function is not set */ + AUTOFILL_ERROR_NOT_RUNNING = TIZEN_ERROR_IME | 0x0002, /**< IME main loop isn't started yet */ + AUTOFILL_ERROR_OPERATION_FAILED = TIZEN_ERROR_IME | 0x0003, /**< Operation failed */ + AUTOFILL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< out of memory */ +} autofill_error_e; + +typedef struct autofill_item_s *autofill_item_h; +typedef struct autofill_auth_info_s *autofill_auth_info_h; +typedef struct autofill_view_info_s *autofill_view_info_h; +typedef struct autofill_fill_response_s *autofill_fill_response_h; +typedef struct autofill_response_item_s *autofill_fill_response_item_h; + +/** + * @brief Create autofill item + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_create(autofill_item_h *it); + +/** + * @brief Destroy autofill item + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_destroy(autofill_item_h it); + +/** + * @brief Clone autofill item + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_clone(autofill_item_h h, autofill_item_h *clone); + +/** + * @brief Set autofill hint (id (username), name, password, phone, credit card number, organization, so on) + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_set_autofill_hint(autofill_item_h it, autofill_hint_e hints); + +/** + * @brief Get autofill hint + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_get_autofill_hint(autofill_item_h it, autofill_hint_e *hints); + +/** + * @brief Set autofill ID + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_set_id(autofill_item_h it, const char *id); + +/** + * @brief Set autofill ID + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_get_id(autofill_item_h it, char **id); + +/** + * @brief Set autofill Label + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_set_label(autofill_item_h it, const char *label); + +/** + * @brief Get autofill Label + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_get_label(autofill_item_h it, char **label); + +/** + * @brief Set sensitive data + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_set_sensitive_data(autofill_item_h it, bool sensitive); + +/** + * @brief Get sensitive data + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_get_sensitive_data(autofill_item_h it, bool *sensitive); + +/** + * @brief Set autofill value + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_set_value(autofill_item_h it, const char *value); + +/** + * @brief Get autofill value + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_item_get_value(autofill_item_h it, char **value); + +// auth info + +/** + * @brief Create autofill auth info + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_create(autofill_auth_info_h *vi); // + +/** + * @brief Destroy autofill view info + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_destroy(autofill_auth_info_h vi); + +/** + * @brief Set app id + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_set_app_id(autofill_auth_info_h vi, const char *app_id); // + +/** + * @brief Get app id + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_get_app_id(autofill_auth_info_h vi, char **app_id); + +/** + * @brief Set exist autofill data + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_set_exist_autofill_data(autofill_auth_info_h vi, bool exist_autofill_data); + +/** + * @brief Get exist autofill data + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_get_exist_autofill_data(autofill_auth_info_h vi, bool *exist_autofill_data); + +/** + * @brief Set need authentication + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_set_need_authentication(autofill_auth_info_h vi, bool need_authentication); + +/** + * @brief Get need authentication + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_get_need_authentication(autofill_auth_info_h vi, bool *need_authentication); + +/** + * @brief Set service name + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_set_service_name(autofill_auth_info_h vi, const char *service_name); + +/** + * @brief Get service name + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_get_service_name(autofill_auth_info_h vi, char **service_name); + +/** + * @brief Set service message + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_set_service_message(autofill_auth_info_h vi, const char *service_message); + +/** + * @brief Get service message + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_get_service_message(autofill_auth_info_h vi, char **service_message); + +/** + * @brief Set service logo image path + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_set_service_logo_image_path(autofill_auth_info_h vi, const char *service_logo_image_path); + +/** + * @brief Get service logo image path + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_auth_info_get_service_logo_image_path(autofill_auth_info_h vi, char **service_logo_image_path); + +// view info +/** + * @brief Create autofill view info + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_view_info_create(autofill_view_info_h *vi); + +/** + * @brief Destroy autofill view info + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_view_info_destroy(autofill_view_info_h vi); + +/** + * @brief Set app id + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_view_info_set_app_id(autofill_view_info_h vi, const char *app_id); + +/** + * @brief Get app id + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_view_info_get_app_id(const autofill_view_info_h vi, char **app_id); + +/** + * @brief Set view id + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_view_info_set_view_id(autofill_view_info_h vi, const char *view_id); + +/** + * @brief Get view id + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_view_info_get_view_id(autofill_view_info_h vi, char **view_id); + +/** + * @brief Add autofill item + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_view_info_add_item(const autofill_view_info_h vi, autofill_item_h it); + +int autofill_view_info_foreach_items(autofill_view_info_h h, bool (*callback)(autofill_item_h item, void *user_data), void *user_data); + +// fill response +// 각 입력 필드별 autofill fill response item +/** + * @brief Add autofill fill response item + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_create(autofill_fill_response_h *h); + +/** + * @brief Remove autofill fill response item + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_destroy(autofill_fill_response_h h); + +/** + * @brief Set app ID + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_set_app_id(autofill_fill_response_h h, const char *app_id); + +/** + * @brief Get app ID + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_get_app_id(autofill_fill_response_h h, char **app_id); + +/** + * @brief Set view ID + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_set_view_id(autofill_fill_response_h h, const char *view_id); + +/** + * @brief Get view ID + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_get_view_id(autofill_fill_response_h h, char **view_id); + +/** + * @brief Add autofill item + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_add_item(autofill_fill_response_h h, autofill_fill_response_item_h it); + +// fill response item +/** + * @brief Create autofill response item + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_item_create(autofill_fill_response_item_h *it); // + +/** + * @brief Destroy autofill fill response item + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_item_destroy(autofill_fill_response_item_h it); + +/** + * @brief Clone autofill fill response item + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_item_clone(autofill_fill_response_item_h h, autofill_fill_response_item_h *clone); + +/** + * @brief Set autofill ID + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_item_set_id(autofill_fill_response_item_h it, const char *id); + +/** + * @brief Get autofill ID + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_item_get_id(autofill_fill_response_item_h it, char **id); + +/** + * @brief Set autofill value + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_item_set_value(autofill_fill_response_item_h it, const char *value); + +/** + * @brief Get autofill value + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_item_get_value(autofill_fill_response_item_h it, char **value); + +/** + * @brief Set presentation text + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_item_set_presentation_text(autofill_fill_response_item_h it, const char *presentation_text); + +/** + * @brief Get presentation text + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_fill_response_item_get_presentation_text(autofill_fill_response_item_h it, char ** presentation_text); + +int autofill_fill_response_foreach_items(autofill_fill_response_h h, bool (*callback)(autofill_fill_response_item_h item, void *user_data), void *user_data); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_UIX_AUTOFILL_COMMON_H__ */ diff --git a/include/autofill_enum.h b/include/autofill_enum.h new file mode 100644 index 0000000..c80d98a --- /dev/null +++ b/include/autofill_enum.h @@ -0,0 +1,19 @@ +#ifndef __TIZEN_UIX_AUTOFILL_ENUM_H__ +#define __TIZEN_UIX_AUTOFILL_ENUM_H__ + +typedef enum +{ + AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE, /**< Autofill hint for a credit card expiration date */ + AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY, /**< Autofill hint for a credit card expiration day */ + AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH, /**< Autofill hint for a credit card expiration month */ + AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR, /**< Autofill hint for a credit card expiration year */ + AUTOFILL_HINT_CREDIT_CARD_NUMBER, /**< Autofill hint for a credit card number */ + AUTOFILL_HINT_EMAIL_ADDRESS, /**< Autofill hint for an email address */ + AUTOFILL_HINT_NAME, /**< Autofill hint for a user's real name */ + AUTOFILL_HINT_PHONE, /**< Autofill hint for a phone number */ + AUTOFILL_HINT_POSTAL_ADDRESS, /**< Autofill hint for a postal address */ + AUTOFILL_HINT_POSTAL_CODE, /**< Autofill hint for a postal code */ + AUTOFILL_HINT_ID /**< Autofill hint for a user's ID */ +} autofill_hint_e; + +#endif diff --git a/include/autofill_private.h b/include/autofill_private.h new file mode 100644 index 0000000..47f1ac0 --- /dev/null +++ b/include/autofill_private.h @@ -0,0 +1,41 @@ +/* + * 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. + */ + +#ifndef __TIZEN_UIX_AUTOFILL_PRIVATE_H__ +#define __TIZEN_UIX_AUTOFILL_PRIVATE_H__ + +#include +#include "autofill_enum.h" + +struct autofill_view_info_s { + char *app_id; // app ID + char *view_id; // view unique ID or web page URL (URL started with http:// or https://) + Eina_List *autofill_item_list; // autofill_item_h list +}; + +struct autofill_save_view_info_s { + char *app_id; // app ID + char *view_id; // view unique ID or web page URL (URL started with http:// or https://) + Eina_List *autofill_save_item_list; // autofill_save_item_h list +}; + +struct autofill_fill_response_s { + char *app_id; // app ID + char *view_id; // view unique ID + Eina_List *autofill_fill_response_item_list; // autofill_fill_response_item_h list +}; + +#endif /* __TIZEN_UIX_AUTOFILL_PRIVATE_H__ */ diff --git a/include/autofill_service.h b/include/autofill_service.h new file mode 100644 index 0000000..42e1322 --- /dev/null +++ b/include/autofill_service.h @@ -0,0 +1,141 @@ +/* + * 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. + */ + +#ifndef __TIZEN_UIX_AUTOFILL_SERVICE_H__ +#define __TIZEN_UIX_AUTOFILL_SERVICE_H__ + +/** + * @file autofill_service.h + * @brief This file contains autofill APIs and related enumeration. + */ + +#include +#include +#include "autofill_enum.h" +#include "autofill_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_UIX_AUTOFILL_SERVICE_MODULE + * @{ + */ + +//typedef autofill_client_s *autofill_client_h; + +/** +* @brief Called when the connection status is changed. +* @since_tizen 5.5 +* @param[in] status The connection status +* @param[in] user_data The user data passed from the callback function +* @see autofill_initialize() +* @see autofill_deinitialize() +*/ +//typedef void(*autofill_service_connection_status_changed_cb)(autofill_service_connection_status_e status, void* user_data); + +typedef void (*autofill_service_auth_info_request_cb)(autofill_view_info_h vi, void *user_data); + +typedef void (*autofill_service_fill_request_cb)(autofill_view_info_h vi, void *user_data); + +// initialize / deinitialize +/** + * @brief Initialize autofill service library + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_service_initialize(); + +/** + * @brief Deinitialize autofill service library + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_service_deinitialize(); + +// auth +/** + * @brief Register the callback to receive the request of authentication information + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_service_set_auth_info_request_cb(autofill_service_auth_info_request_cb callback, void *user_data); + +/** + * @brief Send the authentication information + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_service_send_auth_info(autofill_auth_info_h h); + +// fill request +/** + * @brief Register the callback to receive the fill request + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_service_set_fill_request_cb(autofill_service_fill_request_cb callback, void *user_data); + +/** + * @brief Send the fill response + * + * @since_tizen 5.5 + * + * @privlevel public + * + * @return 0 on success, otherwise a negative error value + * @retval #AUTOFILL_ERROR_NONE No error + */ +int autofill_service_send_fill_response(autofill_fill_response_h h); + +// save request +//int autofill_service_set_save_request_cb(); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __TIZEN_UIX_AUTOFILL_SERVICE_H__ */ diff --git a/packaging/capi-ui-autofill.spec b/packaging/capi-ui-autofill.spec new file mode 100644 index 0000000..abdcacf --- /dev/null +++ b/packaging/capi-ui-autofill.spec @@ -0,0 +1,176 @@ +Name: capi-ui-autofill +Summary: Autofill Library +Version: 0.1.0 +Release: 1 +Group: Graphics & UI Framework/Input +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(capi-appfw-service-application) +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(evas) +BuildRequires: pkgconfig(eina) +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(ecore-imf) +BuildRequires: pkgconfig(ecore-imf-evas) +BuildRequires: pkgconfig(ecore-evas) +BuildRequires: pkgconfig(rpc-port) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(efl-extension) +BuildRequires: pkgconfig(elementary) +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description +Autofill Library + + +%package devel +Summary: Autofill Library (Development) +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +Autofill Library (Development) + +%package -n capi-ui-autofill-common +Summary: Autofill Common Library +Group: Graphics & UI Framework/Input +Requires: %{name} = %{version}-%{release} + +%description -n capi-ui-autofill-common +Autofill Common Library + +%package -n capi-ui-autofill-common-devel +Summary: Autofill Common Library (Development) +Group: Graphics & UI Framework/Input +Requires: %{name} = %{version}-%{release} + +%description -n capi-ui-autofill-common-devel +Autofill Common Library (Development) + + +%package -n capi-ui-autofill-service +Summary: Autofill Service Library +Group: Graphics & UI Framework/Input +Requires: %{name} = %{version}-%{release} + +%description -n capi-ui-autofill-service +Autofill Service Library + + +%package -n capi-ui-autofill-service-devel +Summary: Autofill Service Library (Development) +Group: Graphics & UI Framework/Input +Requires: %{name} = %{version}-%{release} + +%description -n capi-ui-autofill-service-devel +Autofill Service Library (Development) + + +%package -n org.tizen.autofill-test +Summary: Autofill Test application +Group: Graphics & UI Framework/Input +Requires: %{name} = %{version}-%{release} + +%description -n org.tizen.autofill-test +Autofill Test application + + +%package -n org.tizen.autofill-daemon +Summary: Autofill Daemon application +Group: Graphics & UI Framework/Input +Requires: %{name} = %{version}-%{release} + +%description -n org.tizen.autofill-daemon +Autofill Daemon application + + +%package -n org.tizen.autofill-service +Summary: Autofill Service application +Group: Graphics & UI Framework/Input +Requires: %{name} = %{version}-%{release} + +%description -n org.tizen.autofill-service +Autofill Service application + +%prep +%setup -q + + +%build + +export CFLAGS+=" -DTIZEN_DEBUG_ENABLE -fvisibility=hidden -Werror" +export CXXFLAGS+=" -DTIZEN_DEBUG_ENABLE -fvisibility=hidden -Werror" +export FFLAGS+=" -DTIZEN_DEBUG_ENABLE -fvisibility=hidden" + +rm -rf CMakeFiles +rm -rf CMakeCache.txt +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DLIB_INSTALL_DIR:PATH=%{_libdir} \ + -DTZ_SYS_RO_APP=%TZ_SYS_RO_APP -DTZ_SYS_RO_PACKAGES=%TZ_SYS_RO_PACKAGES + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post +/sbin/ldconfig + +%post -n org.tizen.autofill-test +mkdir -p %{TZ_SYS_RO_APP}/org.tizen.autofill-test + +%post -n org.tizen.autofill-daemon +mkdir -p %{TZ_SYS_RO_APP}/org.tizen.autofill-daemon + +%postun -p /sbin/ldconfig + + +%files +%manifest client/capi-ui-autofill.manifest +%{_libdir}/libcapi-ui-autofill.so.* +%license LICENSE + +%files -n capi-ui-autofill-common +%manifest common/capi-ui-autofill-common.manifest +%{_libdir}/libcapi-ui-autofill-common.so.* +%license LICENSE + +%files -n capi-ui-autofill-common-devel +%{_includedir}/autofill_common*.h +%{_libdir}/pkgconfig/*.pc +%{_libdir}/libcapi-ui-autofill-common.so + +%files devel +%{_includedir}/autofill*.h +%{_libdir}/pkgconfig/*.pc +%{_libdir}/libcapi-ui-autofill.so + +%files -n capi-ui-autofill-service +%manifest service_lib/capi-ui-autofill-service.manifest +%{_libdir}/libcapi-ui-autofill-service.so.* +%license LICENSE + +%files -n capi-ui-autofill-service-devel +%{_includedir}/autofill_service*.h +%{_libdir}/pkgconfig/*.pc +%{_libdir}/libcapi-ui-autofill-service.so + +%files -n org.tizen.autofill-test +%manifest test/org.tizen.autofill-test.manifest +%{TZ_SYS_RO_PACKAGES}/org.tizen.autofill-test.xml +%{TZ_SYS_RO_APP}/org.tizen.autofill-test/* + +%files -n org.tizen.autofill-daemon +%manifest server/org.tizen.autofill-daemon.manifest +%{TZ_SYS_RO_PACKAGES}/org.tizen.autofill-daemon.xml +%{TZ_SYS_RO_APP}/org.tizen.autofill-daemon/* + +%files -n org.tizen.autofill-service +%manifest service/org.tizen.autofill-service.manifest +%{TZ_SYS_RO_PACKAGES}/org.tizen.autofill-service.xml +%{TZ_SYS_RO_APP}/org.tizen.autofill-service/* diff --git a/prebuild.sh b/prebuild.sh new file mode 100755 index 0000000..3771c0f --- /dev/null +++ b/prebuild.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -x +tidlc -p -l C -i tidl/autofill.tidl -o autofill_proxy +mv autofill_proxy.h ./client/ +mv autofill_proxy.c ./client/ + +tidlc -s -l C -i tidl/autofill.tidl -o autofill_stub +mv autofill_stub.h ./server/ +mv autofill_stub.c ./server/ + +tidlc -p -l C -i tidl/autofill_service.tidl -o autofill_service_proxy +mv autofill_service_proxy.h ./server/ +mv autofill_service_proxy.c ./server/ + +tidlc -s -l C -i tidl/autofill_service.tidl -o autofill_service_stub +mv autofill_service_stub.h ./service_lib/ +mv autofill_service_stub.c ./service_lib/ diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt new file mode 100644 index 0000000..78e70c8 --- /dev/null +++ b/server/CMakeLists.txt @@ -0,0 +1,42 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(autofill-daemon C) + +SET(SRCS + main.c + autofill_stub.c + autofill_service_proxy.c +) + +pkg_check_modules(pkgs_daemon REQUIRED + capi-base-common + dlog + ecore + eina + capi-appfw-service-application + rpc-port + glib-2.0 +) + +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include) + +FOREACH(flag ${pkgs_daemon_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +FIND_PROGRAM(UNAME NAMES uname) +EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") + MESSAGE("add -DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_daemon_LDFLAGS}) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${TZ_SYS_RO_APP}/org.tizen.${PROJECT_NAME}/bin/) +INSTALL(FILES ${CMAKE_BINARY_DIR}/server/org.tizen.${PROJECT_NAME}.xml DESTINATION ${TZ_SYS_RO_PACKAGES}) +#INSTALL(FILES ${CMAKE_BINARY_DIR}/daemon/autofill-daemon.manifest DESTINATION ${TZ_SYS_RO_PACKAGES}) diff --git a/server/autofill_service_proxy.c b/server/autofill_service_proxy.c new file mode 100644 index 0000000..7d7a6fa --- /dev/null +++ b/server/autofill_service_proxy.c @@ -0,0 +1,2810 @@ +/* + * Generated by tidlc 1.3.1. + * + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "autofill_service_proxy.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "RPC_PORT_PROXY" + +#ifdef _E +#undef _E +#endif + +#ifdef _W +#undef _W +#endif + +#ifdef _I +#undef _I +#endif + +#ifdef _D +#undef _D +#endif + +#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +typedef void (*proxy_delegate)(GList **list, rpc_port_parcel_h parcel, int seq_id, int id); + +struct autofill_svc_item_s { + rpc_port_parcelable_t parcelable; + char *id; + char *label; + char *value; + int autofill_hint; + bool is_sensitive_data; +}; + +static void __autofill_svc_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->id ? h->id : ""); + rpc_port_parcel_write_string(parcel, h->label ? h->label : ""); + rpc_port_parcel_write_string(parcel, h->value ? h->value : ""); + rpc_port_parcel_write_int32(parcel, h->autofill_hint); + rpc_port_parcel_write_bool(parcel, h->is_sensitive_data); +} + +static void __autofill_svc_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->id); + rpc_port_parcel_read_string(parcel, &h->label); + rpc_port_parcel_read_string(parcel, &h->value); + rpc_port_parcel_read_int32(parcel, &h->autofill_hint); + rpc_port_parcel_read_bool(parcel, &h->is_sensitive_data); +} + +int rpc_port_autofill_svc_item_create(rpc_port_autofill_svc_item_h *h) +{ + struct autofill_svc_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_item_to; + handle->parcelable.from = __autofill_svc_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_item_destroy(rpc_port_autofill_svc_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) + free(h->id); + + if (h->label) + free(h->label); + + if (h->value) + free(h->value); + + free(h); + + return 0; +} + +int rpc_port_autofill_svc_item_clone(rpc_port_autofill_svc_item_h h, rpc_port_autofill_svc_item_h *clone) +{ + rpc_port_autofill_svc_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_item_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_item handle"); + return -1; + } + + if (h->id) { + handle->id = strdup(h->id); + if (!handle->id) { + _E("Failed to duplicate h->id"); + rpc_port_autofill_svc_item_destroy(handle); + return -1; + } + } + + if (h->label) { + handle->label = strdup(h->label); + if (!handle->label) { + _E("Failed to duplicate h->label"); + rpc_port_autofill_svc_item_destroy(handle); + return -1; + } + } + + if (h->value) { + handle->value = strdup(h->value); + if (!handle->value) { + _E("Failed to duplicate h->value"); + rpc_port_autofill_svc_item_destroy(handle); + return -1; + } + } + + handle->autofill_hint = h->autofill_hint; + handle->is_sensitive_data = h->is_sensitive_data; + *clone = handle; + + return 0; +} + +int rpc_port_autofill_svc_item_set_id(rpc_port_autofill_svc_item_h h, const char *id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) { + free(h->id); + h->id = NULL; + } + + h->id = strdup(id); + if (!h->id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_set_label(rpc_port_autofill_svc_item_h h, const char *label) +{ + if (!h || !label) { + _E("Invalid parameter"); + return -1; + } + + if (h->label) { + free(h->label); + h->label = NULL; + } + + h->label = strdup(label); + if (!h->label) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_set_value(rpc_port_autofill_svc_item_h h, const char *value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (h->value) { + free(h->value); + h->value = NULL; + } + + h->value = strdup(value); + if (!h->value) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_set_autofill_hint(rpc_port_autofill_svc_item_h h, int autofill_hint) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->autofill_hint = autofill_hint; + return 0; +} + +int rpc_port_autofill_svc_item_set_is_sensitive_data(rpc_port_autofill_svc_item_h h, bool is_sensitive_data) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->is_sensitive_data = is_sensitive_data; + return 0; +} + +int rpc_port_autofill_svc_item_get_id(rpc_port_autofill_svc_item_h h, char **id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->id) { + _E("Invalid parameter: h->id is NULL"); + return -1; + } + + *id = strdup(h->id); + if (*id == NULL) { + _E("Failed to duplicate id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_get_label(rpc_port_autofill_svc_item_h h, char **label) +{ + if (!h || !label) { + _E("Invalid parameter"); + return -1; + } + + if (!h->label) { + _E("Invalid parameter: h->label is NULL"); + return -1; + } + + *label = strdup(h->label); + if (*label == NULL) { + _E("Failed to duplicate label"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_get_value(rpc_port_autofill_svc_item_h h, char **value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (!h->value) { + _E("Invalid parameter: h->value is NULL"); + return -1; + } + + *value = strdup(h->value); + if (*value == NULL) { + _E("Failed to duplicate value"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_get_autofill_hint(rpc_port_autofill_svc_item_h h, int *autofill_hint) +{ + if (!h || !autofill_hint) { + _E("Invalid parameter"); + return -1; + } + + *autofill_hint = h->autofill_hint; + return 0; +} + +int rpc_port_autofill_svc_item_get_is_sensitive_data(rpc_port_autofill_svc_item_h h, bool *is_sensitive_data) +{ + if (!h || !is_sensitive_data) { + _E("Invalid parameter"); + return -1; + } + + *is_sensitive_data = h->is_sensitive_data; + return 0; +} + +struct autofill_svc_view_info_s { + rpc_port_parcelable_t parcelable; + char *app_id; + char *view_id; + GList *items; +}; + +static void __autofill_svc_view_info_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_view_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->app_id ? h->app_id : ""); + rpc_port_parcel_write_string(parcel, h->view_id ? h->view_id : ""); + rpc_port_parcel_write_array_count(parcel, g_list_length(h->items)); + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __autofill_svc_view_info_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_view_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->app_id); + rpc_port_parcel_read_string(parcel, &h->view_id); + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_svc_item_h value = NULL; + + rpc_port_autofill_svc_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->items = g_list_append(h->items, value); + } + } while (0); +} + +int rpc_port_autofill_svc_view_info_create(rpc_port_autofill_svc_view_info_h *h) +{ + struct autofill_svc_view_info_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_view_info_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_view_info_to; + handle->parcelable.from = __autofill_svc_view_info_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_view_info_destroy(rpc_port_autofill_svc_view_info_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) + free(h->app_id); + + if (h->view_id) + free(h->view_id); + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + if (value) + rpc_port_autofill_svc_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_autofill_svc_view_info_clone(rpc_port_autofill_svc_view_info_h h, rpc_port_autofill_svc_view_info_h *clone) +{ + rpc_port_autofill_svc_view_info_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_view_info_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_view_info handle"); + return -1; + } + + if (h->app_id) { + handle->app_id = strdup(h->app_id); + if (!handle->app_id) { + _E("Failed to duplicate h->app_id"); + rpc_port_autofill_svc_view_info_destroy(handle); + return -1; + } + } + + if (h->view_id) { + handle->view_id = strdup(h->view_id); + if (!handle->view_id) { + _E("Failed to duplicate h->view_id"); + rpc_port_autofill_svc_view_info_destroy(handle); + return -1; + } + } + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_svc_item_h new_value; + rpc_port_autofill_svc_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_autofill_svc_view_info_destroy(handle); + return -1; + } + + rpc_port_autofill_svc_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_svc_view_info_destroy(handle); + return -1; + } + + handle->items = g_list_append(handle->items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_svc_view_info_set_app_id(rpc_port_autofill_svc_view_info_h h, const char *app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) { + free(h->app_id); + h->app_id = NULL; + } + + h->app_id = strdup(app_id); + if (!h->app_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_view_info_set_view_id(rpc_port_autofill_svc_view_info_h h, const char *view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) { + free(h->view_id); + h->view_id = NULL; + } + + h->view_id = strdup(view_id); + if (!h->view_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_view_info_add_items(rpc_port_autofill_svc_view_info_h h, rpc_port_autofill_svc_item_h items) +{ + if (!h || !items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_item_h value = NULL; + + rpc_port_autofill_svc_item_clone(items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->items = g_list_append(h->items, value); + } while (0); + + return 0; +} + +int rpc_port_autofill_svc_view_info_get_app_id(rpc_port_autofill_svc_view_info_h h, char **app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->app_id) { + _E("Invalid parameter: h->app_id is NULL"); + return -1; + } + + *app_id = strdup(h->app_id); + if (*app_id == NULL) { + _E("Failed to duplicate app_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_view_info_get_view_id(rpc_port_autofill_svc_view_info_h h, char **view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->view_id) { + _E("Invalid parameter: h->view_id is NULL"); + return -1; + } + + *view_id = strdup(h->view_id); + if (*view_id == NULL) { + _E("Failed to duplicate view_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_view_info_foreach_items(rpc_port_autofill_svc_view_info_h h, + bool (*callback)(rpc_port_autofill_svc_item_h items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_autofill_svc_view_info_remove_items(rpc_port_autofill_svc_view_info_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_svc_item_h value = iter->data; + h->items = g_list_remove_link(h->items, iter); + rpc_port_autofill_svc_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_svc_view_info_get_items_length(rpc_port_autofill_svc_view_info_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->items); + + return 0; +} + +struct autofill_svc_auth_info_s { + rpc_port_parcelable_t parcelable; + char *app_id; + bool exist_autofill_data; + bool need_authentication; + char *service_name; + char *service_logo_image_path; + char *service_message; +}; + +static void __autofill_svc_auth_info_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_auth_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->app_id ? h->app_id : ""); + rpc_port_parcel_write_bool(parcel, h->exist_autofill_data); + rpc_port_parcel_write_bool(parcel, h->need_authentication); + rpc_port_parcel_write_string(parcel, h->service_name ? h->service_name : ""); + rpc_port_parcel_write_string(parcel, h->service_logo_image_path ? h->service_logo_image_path : ""); + rpc_port_parcel_write_string(parcel, h->service_message ? h->service_message : ""); +} + +static void __autofill_svc_auth_info_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_auth_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->app_id); + rpc_port_parcel_read_bool(parcel, &h->exist_autofill_data); + rpc_port_parcel_read_bool(parcel, &h->need_authentication); + rpc_port_parcel_read_string(parcel, &h->service_name); + rpc_port_parcel_read_string(parcel, &h->service_logo_image_path); + rpc_port_parcel_read_string(parcel, &h->service_message); +} + +int rpc_port_autofill_svc_auth_info_create(rpc_port_autofill_svc_auth_info_h *h) +{ + struct autofill_svc_auth_info_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_auth_info_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_auth_info_to; + handle->parcelable.from = __autofill_svc_auth_info_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_auth_info_destroy(rpc_port_autofill_svc_auth_info_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) + free(h->app_id); + + if (h->service_name) + free(h->service_name); + + if (h->service_logo_image_path) + free(h->service_logo_image_path); + + if (h->service_message) + free(h->service_message); + + free(h); + + return 0; +} + +int rpc_port_autofill_svc_auth_info_clone(rpc_port_autofill_svc_auth_info_h h, rpc_port_autofill_svc_auth_info_h *clone) +{ + rpc_port_autofill_svc_auth_info_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_auth_info_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_auth_info handle"); + return -1; + } + + if (h->app_id) { + handle->app_id = strdup(h->app_id); + if (!handle->app_id) { + _E("Failed to duplicate h->app_id"); + rpc_port_autofill_svc_auth_info_destroy(handle); + return -1; + } + } + + handle->exist_autofill_data = h->exist_autofill_data; + handle->need_authentication = h->need_authentication; + if (h->service_name) { + handle->service_name = strdup(h->service_name); + if (!handle->service_name) { + _E("Failed to duplicate h->service_name"); + rpc_port_autofill_svc_auth_info_destroy(handle); + return -1; + } + } + + if (h->service_logo_image_path) { + handle->service_logo_image_path = strdup(h->service_logo_image_path); + if (!handle->service_logo_image_path) { + _E("Failed to duplicate h->service_logo_image_path"); + rpc_port_autofill_svc_auth_info_destroy(handle); + return -1; + } + } + + if (h->service_message) { + handle->service_message = strdup(h->service_message); + if (!handle->service_message) { + _E("Failed to duplicate h->service_message"); + rpc_port_autofill_svc_auth_info_destroy(handle); + return -1; + } + } + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_app_id(rpc_port_autofill_svc_auth_info_h h, const char *app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) { + free(h->app_id); + h->app_id = NULL; + } + + h->app_id = strdup(app_id); + if (!h->app_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_exist_autofill_data(rpc_port_autofill_svc_auth_info_h h, bool exist_autofill_data) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->exist_autofill_data = exist_autofill_data; + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_need_authentication(rpc_port_autofill_svc_auth_info_h h, bool need_authentication) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->need_authentication = need_authentication; + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_service_name(rpc_port_autofill_svc_auth_info_h h, const char *service_name) +{ + if (!h || !service_name) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_name) { + free(h->service_name); + h->service_name = NULL; + } + + h->service_name = strdup(service_name); + if (!h->service_name) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_service_logo_image_path(rpc_port_autofill_svc_auth_info_h h, const char *service_logo_image_path) +{ + if (!h || !service_logo_image_path) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_logo_image_path) { + free(h->service_logo_image_path); + h->service_logo_image_path = NULL; + } + + h->service_logo_image_path = strdup(service_logo_image_path); + if (!h->service_logo_image_path) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_service_message(rpc_port_autofill_svc_auth_info_h h, const char *service_message) +{ + if (!h || !service_message) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_message) { + free(h->service_message); + h->service_message = NULL; + } + + h->service_message = strdup(service_message); + if (!h->service_message) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_app_id(rpc_port_autofill_svc_auth_info_h h, char **app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->app_id) { + _E("Invalid parameter: h->app_id is NULL"); + return -1; + } + + *app_id = strdup(h->app_id); + if (*app_id == NULL) { + _E("Failed to duplicate app_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_exist_autofill_data(rpc_port_autofill_svc_auth_info_h h, bool *exist_autofill_data) +{ + if (!h || !exist_autofill_data) { + _E("Invalid parameter"); + return -1; + } + + *exist_autofill_data = h->exist_autofill_data; + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_need_authentication(rpc_port_autofill_svc_auth_info_h h, bool *need_authentication) +{ + if (!h || !need_authentication) { + _E("Invalid parameter"); + return -1; + } + + *need_authentication = h->need_authentication; + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_service_name(rpc_port_autofill_svc_auth_info_h h, char **service_name) +{ + if (!h || !service_name) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_name) { + _E("Invalid parameter: h->service_name is NULL"); + return -1; + } + + *service_name = strdup(h->service_name); + if (*service_name == NULL) { + _E("Failed to duplicate service_name"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_service_logo_image_path(rpc_port_autofill_svc_auth_info_h h, char **service_logo_image_path) +{ + if (!h || !service_logo_image_path) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_logo_image_path) { + _E("Invalid parameter: h->service_logo_image_path is NULL"); + return -1; + } + + *service_logo_image_path = strdup(h->service_logo_image_path); + if (*service_logo_image_path == NULL) { + _E("Failed to duplicate service_logo_image_path"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_service_message(rpc_port_autofill_svc_auth_info_h h, char **service_message) +{ + if (!h || !service_message) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_message) { + _E("Invalid parameter: h->service_message is NULL"); + return -1; + } + + *service_message = strdup(h->service_message); + if (*service_message == NULL) { + _E("Failed to duplicate service_message"); + return -1; + } + + return 0; +} + +struct autofill_svc_response_item_s { + rpc_port_parcelable_t parcelable; + char *id; + char *presentation_text; + char *value; +}; + +static void __autofill_svc_response_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->id ? h->id : ""); + rpc_port_parcel_write_string(parcel, h->presentation_text ? h->presentation_text : ""); + rpc_port_parcel_write_string(parcel, h->value ? h->value : ""); +} + +static void __autofill_svc_response_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->id); + rpc_port_parcel_read_string(parcel, &h->presentation_text); + rpc_port_parcel_read_string(parcel, &h->value); +} + +int rpc_port_autofill_svc_response_item_create(rpc_port_autofill_svc_response_item_h *h) +{ + struct autofill_svc_response_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_response_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_response_item_to; + handle->parcelable.from = __autofill_svc_response_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_response_item_destroy(rpc_port_autofill_svc_response_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) + free(h->id); + + if (h->presentation_text) + free(h->presentation_text); + + if (h->value) + free(h->value); + + free(h); + + return 0; +} + +int rpc_port_autofill_svc_response_item_clone(rpc_port_autofill_svc_response_item_h h, rpc_port_autofill_svc_response_item_h *clone) +{ + rpc_port_autofill_svc_response_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_response_item_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_response_item handle"); + return -1; + } + + if (h->id) { + handle->id = strdup(h->id); + if (!handle->id) { + _E("Failed to duplicate h->id"); + rpc_port_autofill_svc_response_item_destroy(handle); + return -1; + } + } + + if (h->presentation_text) { + handle->presentation_text = strdup(h->presentation_text); + if (!handle->presentation_text) { + _E("Failed to duplicate h->presentation_text"); + rpc_port_autofill_svc_response_item_destroy(handle); + return -1; + } + } + + if (h->value) { + handle->value = strdup(h->value); + if (!handle->value) { + _E("Failed to duplicate h->value"); + rpc_port_autofill_svc_response_item_destroy(handle); + return -1; + } + } + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_svc_response_item_set_id(rpc_port_autofill_svc_response_item_h h, const char *id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) { + free(h->id); + h->id = NULL; + } + + h->id = strdup(id); + if (!h->id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_response_item_set_presentation_text(rpc_port_autofill_svc_response_item_h h, const char *presentation_text) +{ + if (!h || !presentation_text) { + _E("Invalid parameter"); + return -1; + } + + if (h->presentation_text) { + free(h->presentation_text); + h->presentation_text = NULL; + } + + h->presentation_text = strdup(presentation_text); + if (!h->presentation_text) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_response_item_set_value(rpc_port_autofill_svc_response_item_h h, const char *value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (h->value) { + free(h->value); + h->value = NULL; + } + + h->value = strdup(value); + if (!h->value) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_response_item_get_id(rpc_port_autofill_svc_response_item_h h, char **id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->id) { + _E("Invalid parameter: h->id is NULL"); + return -1; + } + + *id = strdup(h->id); + if (*id == NULL) { + _E("Failed to duplicate id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_response_item_get_presentation_text(rpc_port_autofill_svc_response_item_h h, char **presentation_text) +{ + if (!h || !presentation_text) { + _E("Invalid parameter"); + return -1; + } + + if (!h->presentation_text) { + _E("Invalid parameter: h->presentation_text is NULL"); + return -1; + } + + *presentation_text = strdup(h->presentation_text); + if (*presentation_text == NULL) { + _E("Failed to duplicate presentation_text"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_response_item_get_value(rpc_port_autofill_svc_response_item_h h, char **value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (!h->value) { + _E("Invalid parameter: h->value is NULL"); + return -1; + } + + *value = strdup(h->value); + if (*value == NULL) { + _E("Failed to duplicate value"); + return -1; + } + + return 0; +} + +struct autofill_svc_fill_response_s { + rpc_port_parcelable_t parcelable; + char *app_id; + char *view_id; + GList *response_items; +}; + +static void __autofill_svc_fill_response_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_fill_response_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->app_id ? h->app_id : ""); + rpc_port_parcel_write_string(parcel, h->view_id ? h->view_id : ""); + rpc_port_parcel_write_array_count(parcel, g_list_length(h->response_items)); + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __autofill_svc_fill_response_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_fill_response_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->app_id); + rpc_port_parcel_read_string(parcel, &h->view_id); + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_svc_response_item_h value = NULL; + + rpc_port_autofill_svc_response_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->response_items = g_list_append(h->response_items, value); + } + } while (0); +} + +int rpc_port_autofill_svc_fill_response_create(rpc_port_autofill_svc_fill_response_h *h) +{ + struct autofill_svc_fill_response_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_fill_response_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_fill_response_to; + handle->parcelable.from = __autofill_svc_fill_response_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_fill_response_destroy(rpc_port_autofill_svc_fill_response_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) + free(h->app_id); + + if (h->view_id) + free(h->view_id); + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + if (value) + rpc_port_autofill_svc_response_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->response_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_autofill_svc_fill_response_clone(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_fill_response_h *clone) +{ + rpc_port_autofill_svc_fill_response_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_fill_response_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_fill_response handle"); + return -1; + } + + if (h->app_id) { + handle->app_id = strdup(h->app_id); + if (!handle->app_id) { + _E("Failed to duplicate h->app_id"); + rpc_port_autofill_svc_fill_response_destroy(handle); + return -1; + } + } + + if (h->view_id) { + handle->view_id = strdup(h->view_id); + if (!handle->view_id) { + _E("Failed to duplicate h->view_id"); + rpc_port_autofill_svc_fill_response_destroy(handle); + return -1; + } + } + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h new_value; + rpc_port_autofill_svc_response_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_autofill_svc_fill_response_destroy(handle); + return -1; + } + + rpc_port_autofill_svc_response_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_svc_fill_response_destroy(handle); + return -1; + } + + handle->response_items = g_list_append(handle->response_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_svc_fill_response_set_app_id(rpc_port_autofill_svc_fill_response_h h, const char *app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) { + free(h->app_id); + h->app_id = NULL; + } + + h->app_id = strdup(app_id); + if (!h->app_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_fill_response_set_view_id(rpc_port_autofill_svc_fill_response_h h, const char *view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) { + free(h->view_id); + h->view_id = NULL; + } + + h->view_id = strdup(view_id); + if (!h->view_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_fill_response_add_response_items(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_response_item_h response_items) +{ + if (!h || !response_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_response_item_h value = NULL; + + rpc_port_autofill_svc_response_item_clone(response_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->response_items = g_list_append(h->response_items, value); + } while (0); + + return 0; +} + +int rpc_port_autofill_svc_fill_response_get_app_id(rpc_port_autofill_svc_fill_response_h h, char **app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->app_id) { + _E("Invalid parameter: h->app_id is NULL"); + return -1; + } + + *app_id = strdup(h->app_id); + if (*app_id == NULL) { + _E("Failed to duplicate app_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_fill_response_get_view_id(rpc_port_autofill_svc_fill_response_h h, char **view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->view_id) { + _E("Invalid parameter: h->view_id is NULL"); + return -1; + } + + *view_id = strdup(h->view_id); + if (*view_id == NULL) { + _E("Failed to duplicate view_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_fill_response_foreach_response_items(rpc_port_autofill_svc_fill_response_h h, + bool (*callback)(rpc_port_autofill_svc_response_item_h response_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_autofill_svc_fill_response_remove_response_items(rpc_port_autofill_svc_fill_response_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->response_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_svc_response_item_h value = iter->data; + h->response_items = g_list_remove_link(h->response_items, iter); + rpc_port_autofill_svc_response_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_svc_fill_response_get_response_items_length(rpc_port_autofill_svc_fill_response_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->response_items); + + return 0; +} + +struct list_autofill_svc_item_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_svc_items; +}; + +static void __list_autofill_svc_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_svc_items)); + do { + GList *iter; + + iter = h->list_autofill_svc_items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __list_autofill_svc_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_svc_item_h value = NULL; + + rpc_port_autofill_svc_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_svc_items = g_list_append(h->list_autofill_svc_items, value); + } + } while (0); +} + +int rpc_port_list_autofill_svc_item_create(rpc_port_list_autofill_svc_item_h *h) +{ + struct list_autofill_svc_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_svc_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_svc_item_to; + handle->parcelable.from = __list_autofill_svc_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_item_destroy(rpc_port_list_autofill_svc_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + if (value) + rpc_port_autofill_svc_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_svc_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_svc_item_clone(rpc_port_list_autofill_svc_item_h h, rpc_port_list_autofill_svc_item_h *clone) +{ + rpc_port_list_autofill_svc_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_svc_item_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_svc_item handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_items; + while (iter) { + rpc_port_autofill_svc_item_h new_value; + rpc_port_autofill_svc_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_svc_item_destroy(handle); + return -1; + } + + rpc_port_autofill_svc_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_svc_item_destroy(handle); + return -1; + } + + handle->list_autofill_svc_items = g_list_append(handle->list_autofill_svc_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_item_add_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, rpc_port_autofill_svc_item_h list_autofill_svc_items) +{ + if (!h || !list_autofill_svc_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_item_h value = NULL; + + rpc_port_autofill_svc_item_clone(list_autofill_svc_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_svc_items = g_list_append(h->list_autofill_svc_items, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_svc_item_foreach_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, + bool (*callback)(rpc_port_autofill_svc_item_h list_autofill_svc_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_list_autofill_svc_item_remove_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_svc_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_svc_item_h value = iter->data; + h->list_autofill_svc_items = g_list_remove_link(h->list_autofill_svc_items, iter); + rpc_port_autofill_svc_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_svc_item_get_list_autofill_svc_items_length(rpc_port_list_autofill_svc_item_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_svc_items); + + return 0; +} + +struct list_autofill_svc_response_item_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_svc_response_items; +}; + +static void __list_autofill_svc_response_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_svc_response_items)); + do { + GList *iter; + + iter = h->list_autofill_svc_response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __list_autofill_svc_response_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_svc_response_item_h value = NULL; + + rpc_port_autofill_svc_response_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_svc_response_items = g_list_append(h->list_autofill_svc_response_items, value); + } + } while (0); +} + +int rpc_port_list_autofill_svc_response_item_create(rpc_port_list_autofill_svc_response_item_h *h) +{ + struct list_autofill_svc_response_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_svc_response_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_svc_response_item_to; + handle->parcelable.from = __list_autofill_svc_response_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_destroy(rpc_port_list_autofill_svc_response_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + if (value) + rpc_port_autofill_svc_response_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_svc_response_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_clone(rpc_port_list_autofill_svc_response_item_h h, rpc_port_list_autofill_svc_response_item_h *clone) +{ + rpc_port_list_autofill_svc_response_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_svc_response_item_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_svc_response_item handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h new_value; + rpc_port_autofill_svc_response_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_svc_response_item_destroy(handle); + return -1; + } + + rpc_port_autofill_svc_response_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_svc_response_item_destroy(handle); + return -1; + } + + handle->list_autofill_svc_response_items = g_list_append(handle->list_autofill_svc_response_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_add_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, rpc_port_autofill_svc_response_item_h list_autofill_svc_response_items) +{ + if (!h || !list_autofill_svc_response_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_response_item_h value = NULL; + + rpc_port_autofill_svc_response_item_clone(list_autofill_svc_response_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_svc_response_items = g_list_append(h->list_autofill_svc_response_items, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_foreach_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, + bool (*callback)(rpc_port_autofill_svc_response_item_h list_autofill_svc_response_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_remove_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_svc_response_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_svc_response_item_h value = iter->data; + h->list_autofill_svc_response_items = g_list_remove_link(h->list_autofill_svc_response_items, iter); + rpc_port_autofill_svc_response_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_get_list_autofill_svc_response_items_length(rpc_port_list_autofill_svc_response_item_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_svc_response_items); + + return 0; +} + +enum AutofillSvcPort_method_e { + AutofillSvcPort_METHOD_Result, + AutofillSvcPort_METHOD_Callback, + AutofillSvcPort_METHOD_Register, + AutofillSvcPort_METHOD_Unregister, + AutofillSvcPort_METHOD_request_auth_info, + AutofillSvcPort_METHOD_send_fill_request, +}; + +enum AutofillSvcPort_delegate_e { + AutofillSvcPort_DELEGATE_autofill_svc_auth_info_cb = 1, + AutofillSvcPort_DELEGATE_autofill_svc_fill_response_cb = 2, +}; + +struct AutofillSvcPort_s { + char *stub_appid; + rpc_port_proxy_h proxy; + rpc_port_h port; + rpc_port_h callback_port; + rpc_port_proxy_AutofillSvcPort_callback_s callback; + void *user_data; + GList *delegates; + GRecMutex mutex; +}; + +struct AutofillSvcPort_autofill_svc_auth_info_cb_s { + rpc_port_parcelable_t parcelable; + int id; + int seq_id; + AutofillSvcPort_autofill_svc_auth_info_cb callback; + bool once; + void *user_data; +}; + +static void __AutofillSvcPort_autofill_svc_auth_info_cb_to(rpc_port_parcel_h parcel, void *data) +{ + struct AutofillSvcPort_autofill_svc_auth_info_cb_s *handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, handle->id); + rpc_port_parcel_write_int32(parcel, handle->seq_id); + rpc_port_parcel_write_bool(parcel, handle->once); +} + +static void __AutofillSvcPort_autofill_svc_auth_info_cb_from(rpc_port_parcel_h parcel, void *data) +{ + struct AutofillSvcPort_autofill_svc_auth_info_cb_s *handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_int32(parcel, &handle->id); + rpc_port_parcel_read_int32(parcel, &handle->seq_id); + rpc_port_parcel_read_bool(parcel, &handle->once); +} + +rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_create(AutofillSvcPort_autofill_svc_auth_info_cb callback, bool once, void *user_data) +{ + struct AutofillSvcPort_autofill_svc_auth_info_cb_s *handle; + static int seq_num; + + handle = calloc(1, sizeof(struct AutofillSvcPort_autofill_svc_auth_info_cb_s)); + if (!handle) { + _E("Out of memory"); + return NULL; + } + + handle->parcelable.to = __AutofillSvcPort_autofill_svc_auth_info_cb_to; + handle->parcelable.from= __AutofillSvcPort_autofill_svc_auth_info_cb_from; + handle->id = AutofillSvcPort_DELEGATE_autofill_svc_auth_info_cb; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + handle->callback = callback; + handle->once = once; + handle->user_data = user_data; + + return handle; +} + +int rpc_port_proxy_AutofillSvcPort_autofill_svc_auth_info_cb_destroy(rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h delegate) +{ + if (!delegate) { + _E("Invalid parameter"); + return -1; + } + + free(delegate); + + return 0; +} + +int rpc_port_proxy_AutofillSvcPort_autofill_svc_auth_info_cb_dispose(rpc_port_proxy_AutofillSvcPort_h proxy, rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h delegate) +{ + struct AutofillSvcPort_autofill_svc_auth_info_cb_s *handle; + GList *iter; + + if (!proxy || !delegate) { + _E("Invalid handle %p %p", proxy, delegate); + return -1; + } + + iter = proxy->delegates; + while (iter) { + handle = (struct AutofillSvcPort_autofill_svc_auth_info_cb_s *)iter->data; + if (handle == delegate) { + proxy->delegates = g_list_remove_link(proxy->delegates, iter); + free(handle); + g_list_free(iter); + return 0; + } + iter = g_list_next(iter); + } + + return -1; +} + +static void __AutofillSvcPort_delegate_autofill_svc_auth_info_cb(GList **list, rpc_port_parcel_h parcel, int seq_id, int id) +{ + rpc_port_autofill_svc_auth_info_h auth_info; + + rpc_port_autofill_svc_auth_info_create(&auth_info); + rpc_port_parcel_read(parcel, &auth_info->parcelable, auth_info); + + do { + struct AutofillSvcPort_autofill_svc_auth_info_cb_s *handle; + GList *iter; + + iter = *list; + while (iter) { + handle = (struct AutofillSvcPort_autofill_svc_auth_info_cb_s *)iter->data; + if (handle->seq_id == seq_id && handle->id == id) { + handle->callback(handle->user_data, auth_info); + + if (handle->once) { + *list = g_list_remove_link(*list, iter); + free(handle); + g_list_free(iter); + } + break; + } + iter = g_list_next(iter); + } + } while (0); + rpc_port_autofill_svc_auth_info_destroy(auth_info); +} + +struct AutofillSvcPort_autofill_svc_fill_response_cb_s { + rpc_port_parcelable_t parcelable; + int id; + int seq_id; + AutofillSvcPort_autofill_svc_fill_response_cb callback; + bool once; + void *user_data; +}; + +static void __AutofillSvcPort_autofill_svc_fill_response_cb_to(rpc_port_parcel_h parcel, void *data) +{ + struct AutofillSvcPort_autofill_svc_fill_response_cb_s *handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, handle->id); + rpc_port_parcel_write_int32(parcel, handle->seq_id); + rpc_port_parcel_write_bool(parcel, handle->once); +} + +static void __AutofillSvcPort_autofill_svc_fill_response_cb_from(rpc_port_parcel_h parcel, void *data) +{ + struct AutofillSvcPort_autofill_svc_fill_response_cb_s *handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_int32(parcel, &handle->id); + rpc_port_parcel_read_int32(parcel, &handle->seq_id); + rpc_port_parcel_read_bool(parcel, &handle->once); +} + +rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_create(AutofillSvcPort_autofill_svc_fill_response_cb callback, bool once, void *user_data) +{ + struct AutofillSvcPort_autofill_svc_fill_response_cb_s *handle; + static int seq_num; + + handle = calloc(1, sizeof(struct AutofillSvcPort_autofill_svc_fill_response_cb_s)); + if (!handle) { + _E("Out of memory"); + return NULL; + } + + handle->parcelable.to = __AutofillSvcPort_autofill_svc_fill_response_cb_to; + handle->parcelable.from= __AutofillSvcPort_autofill_svc_fill_response_cb_from; + handle->id = AutofillSvcPort_DELEGATE_autofill_svc_fill_response_cb; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + handle->callback = callback; + handle->once = once; + handle->user_data = user_data; + + return handle; +} + +int rpc_port_proxy_AutofillSvcPort_autofill_svc_fill_response_cb_destroy(rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h delegate) +{ + if (!delegate) { + _E("Invalid parameter"); + return -1; + } + + free(delegate); + + return 0; +} + +int rpc_port_proxy_AutofillSvcPort_autofill_svc_fill_response_cb_dispose(rpc_port_proxy_AutofillSvcPort_h proxy, rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h delegate) +{ + struct AutofillSvcPort_autofill_svc_fill_response_cb_s *handle; + GList *iter; + + if (!proxy || !delegate) { + _E("Invalid handle %p %p", proxy, delegate); + return -1; + } + + iter = proxy->delegates; + while (iter) { + handle = (struct AutofillSvcPort_autofill_svc_fill_response_cb_s *)iter->data; + if (handle == delegate) { + proxy->delegates = g_list_remove_link(proxy->delegates, iter); + free(handle); + g_list_free(iter); + return 0; + } + iter = g_list_next(iter); + } + + return -1; +} + +static void __AutofillSvcPort_delegate_autofill_svc_fill_response_cb(GList **list, rpc_port_parcel_h parcel, int seq_id, int id) +{ + rpc_port_autofill_svc_fill_response_h response; + + rpc_port_autofill_svc_fill_response_create(&response); + rpc_port_parcel_read(parcel, &response->parcelable, response); + + do { + struct AutofillSvcPort_autofill_svc_fill_response_cb_s *handle; + GList *iter; + + iter = *list; + while (iter) { + handle = (struct AutofillSvcPort_autofill_svc_fill_response_cb_s *)iter->data; + if (handle->seq_id == seq_id && handle->id == id) { + handle->callback(handle->user_data, response); + + if (handle->once) { + *list = g_list_remove_link(*list, iter); + free(handle); + g_list_free(iter); + } + break; + } + iter = g_list_next(iter); + } + } while (0); + rpc_port_autofill_svc_fill_response_destroy(response); +} + +static proxy_delegate __AutofillSvcPort_delegate_table[] = { + [AutofillSvcPort_DELEGATE_autofill_svc_auth_info_cb] = __AutofillSvcPort_delegate_autofill_svc_auth_info_cb, + [AutofillSvcPort_DELEGATE_autofill_svc_fill_response_cb] = __AutofillSvcPort_delegate_autofill_svc_fill_response_cb, +}; + +static void __AutofillSvcPort_process_received_event(GList **list, rpc_port_parcel_h parcel) +{ + int id; + int seq_id; + bool once; + + rpc_port_parcel_read_int32(parcel, &id); + rpc_port_parcel_read_int32(parcel, &seq_id); + rpc_port_parcel_read_bool(parcel, &once); + + if (id > 0 && id < (sizeof(__AutofillSvcPort_delegate_table) / sizeof(__AutofillSvcPort_delegate_table[0]))) { + if (__AutofillSvcPort_delegate_table[id]) + __AutofillSvcPort_delegate_table[id](list, parcel, seq_id, id); + } else { + _W("Unknown id(%d)", id); + } +} + +static rpc_port_parcel_h __AutofillSvcPort_consume_command(rpc_port_proxy_AutofillSvcPort_h h) +{ + rpc_port_parcel_h parcel = NULL; + int cmd = -1; + + do { + rpc_port_parcel_create_from_port(&parcel, h->port); + if (!parcel) + break; + + rpc_port_parcel_read_int32(parcel, &cmd); + if (cmd == AutofillSvcPort_METHOD_Result) + return parcel; + + rpc_port_parcel_destroy(parcel); + parcel = NULL; + } while (true); + + return NULL; +} + +static void __AutofillSvcPort_on_connected(const char *endpoint, const char *port_name, rpc_port_h port, void *data) +{ + rpc_port_proxy_AutofillSvcPort_h handle = data; + + handle->port = port; + rpc_port_proxy_get_port(handle->proxy, RPC_PORT_PORT_CALLBACK, &handle->callback_port); + if (handle->callback.connected) + handle->callback.connected(handle, handle->user_data); + _I("[__RPC_PORT__] endpoint(%s), port_name(%s)", endpoint, port_name); +} + +static void __AutofillSvcPort_on_disconnected(const char *endpoint, const char *port_name, void *data) +{ + rpc_port_proxy_AutofillSvcPort_h handle = data; + + handle->port = NULL; + if (handle->callback.disconnected) + handle->callback.disconnected(handle, handle->user_data); + _I("[__RPC_PORT__] endpoint(%s), port_name(%s)", endpoint, port_name); +} + +static void __AutofillSvcPort_on_rejected(const char *endpoint, const char *port_name, void *data) +{ + rpc_port_proxy_AutofillSvcPort_h handle = data; + + handle->port = NULL; + if (handle->callback.rejected) + handle->callback.rejected(handle, handle->user_data); + _I("[__RPC_PORT__] endpoint(%s), port_name(%s)", endpoint, port_name); +} + +static void __AutofillSvcPort_on_received(const char *endpoint, const char *port_name, void *data) +{ + rpc_port_proxy_AutofillSvcPort_h handle = data; + rpc_port_parcel_h parcel_received; + int cmd = -1; + + rpc_port_parcel_create_from_port(&parcel_received, handle->callback_port); + rpc_port_parcel_read_int32(parcel_received, &cmd); + if (cmd != AutofillSvcPort_METHOD_Callback) { + _E("Invalid protocol"); + rpc_port_parcel_destroy(parcel_received); + return; + } + + __AutofillSvcPort_process_received_event(&handle->delegates, parcel_received); + rpc_port_parcel_destroy(parcel_received); + _I("[__RPC_PORT__] endpoint(%s), port_name(%s)", endpoint, port_name); +} + +int rpc_port_proxy_AutofillSvcPort_invoke_Register(rpc_port_proxy_AutofillSvcPort_h h, rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb, rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_cb) +{ + rpc_port_parcel_h parcel; + int r; + int ret = -1; + + if (!h || !auth_info_cb || !fill_response_cb) { + _E("Invalid parameter"); + return ret; + } + + if (!h->port) { + _E("Not connected"); + return ret; + } + + rpc_port_parcel_create(&parcel); + rpc_port_parcel_write_int32(parcel, AutofillSvcPort_METHOD_Register); + + do { + struct AutofillSvcPort_autofill_svc_auth_info_cb_s *handle = auth_info_cb; + + rpc_port_parcel_write(parcel, &handle->parcelable, handle); + h->delegates = g_list_append(h->delegates, handle); + } while (0); + + do { + struct AutofillSvcPort_autofill_svc_fill_response_cb_s *handle = fill_response_cb; + + rpc_port_parcel_write(parcel, &handle->parcelable, handle); + h->delegates = g_list_append(h->delegates, handle); + } while (0); + + r = rpc_port_parcel_send(parcel, h->port); + if (r != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. result(%d)", r); + r = RPC_PORT_ERROR_IO_ERROR; + } + + rpc_port_parcel_destroy(parcel); + + g_rec_mutex_lock(&h->mutex); + do { + rpc_port_parcel_h parcel_received; + + parcel_received = __AutofillSvcPort_consume_command(h); + if (!parcel_received) { + _E("Invalid protocol"); + break; + } + + rpc_port_parcel_read_int32(parcel_received, &ret); + + rpc_port_parcel_destroy(parcel_received); + } while (0); + g_rec_mutex_unlock(&h->mutex); + set_last_result(r); + + return ret; +} + +void rpc_port_proxy_AutofillSvcPort_invoke_Unregister(rpc_port_proxy_AutofillSvcPort_h h) +{ + rpc_port_parcel_h parcel; + int r; + + if (!h) { + _E("Invalid parameter"); + return; + } + + if (!h->port) { + _E("Not connected"); + return; + } + + rpc_port_parcel_create(&parcel); + rpc_port_parcel_write_int32(parcel, AutofillSvcPort_METHOD_Unregister); + + r = rpc_port_parcel_send(parcel, h->port); + if (r != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. result(%d)", r); + r = RPC_PORT_ERROR_IO_ERROR; + } + + rpc_port_parcel_destroy(parcel); + set_last_result(r); +} + +void rpc_port_proxy_AutofillSvcPort_invoke_request_auth_info(rpc_port_proxy_AutofillSvcPort_h h, rpc_port_autofill_svc_view_info_h vi) +{ + rpc_port_parcel_h parcel; + int r; + + if (!h || !vi) { + _E("Invalid parameter"); + return; + } + + if (!h->port) { + _E("Not connected"); + return; + } + + rpc_port_parcel_create(&parcel); + rpc_port_parcel_write_int32(parcel, AutofillSvcPort_METHOD_request_auth_info); + rpc_port_parcel_write(parcel, &vi->parcelable, vi); + + r = rpc_port_parcel_send(parcel, h->port); + if (r != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. result(%d)", r); + r = RPC_PORT_ERROR_IO_ERROR; + } + + rpc_port_parcel_destroy(parcel); + set_last_result(r); +} + +void rpc_port_proxy_AutofillSvcPort_invoke_send_fill_request(rpc_port_proxy_AutofillSvcPort_h h, rpc_port_autofill_svc_view_info_h vi) +{ + rpc_port_parcel_h parcel; + int r; + + if (!h || !vi) { + _E("Invalid parameter"); + return; + } + + if (!h->port) { + _E("Not connected"); + return; + } + + rpc_port_parcel_create(&parcel); + rpc_port_parcel_write_int32(parcel, AutofillSvcPort_METHOD_send_fill_request); + rpc_port_parcel_write(parcel, &vi->parcelable, vi); + + r = rpc_port_parcel_send(parcel, h->port); + if (r != RPC_PORT_ERROR_NONE) { + _E("Failed to send parcel. result(%d)", r); + r = RPC_PORT_ERROR_IO_ERROR; + } + + rpc_port_parcel_destroy(parcel); + set_last_result(r); +} + +static struct AutofillSvcPort_s *__create_AutofillSvcPort(const char *stub_appid, rpc_port_proxy_AutofillSvcPort_callback_s *callback, void *user_data) +{ + struct AutofillSvcPort_s *handle; + + handle = calloc(1, sizeof(struct AutofillSvcPort_s)); + if (!handle) { + _E("Out of memory"); + return NULL; + } + + handle->stub_appid = strdup(stub_appid); + if (!handle->stub_appid) { + _E("Out of memory"); + free(handle); + return NULL; + } + + rpc_port_proxy_create(&handle->proxy); + if (!handle->proxy) { + _E("Failed to create proxy"); + free(handle->stub_appid); + free(handle); + return NULL; + } + + g_rec_mutex_init(&handle->mutex); + + handle->callback = *callback; + handle->user_data = user_data; + + return handle; +} + +static void __destroy_AutofillSvcPort(struct AutofillSvcPort_s *h) +{ + if (!h) + return; + + g_rec_mutex_clear(&h->mutex); + + if (h->delegates) + g_list_free_full(h->delegates, free); + + if (h->proxy) + rpc_port_proxy_destroy(h->proxy); + + if (h->stub_appid) + free(h->stub_appid); + + free(h); +} + +int rpc_port_proxy_AutofillSvcPort_create(const char *stub_appid, rpc_port_proxy_AutofillSvcPort_callback_s *callback, void *user_data, rpc_port_proxy_AutofillSvcPort_h *h) +{ + struct AutofillSvcPort_s *handle; + int r; + + if (!stub_appid || !callback || !h) { + _E("Invalid parameter"); + return -1; + } + + handle = __create_AutofillSvcPort(stub_appid, callback, user_data); + if (!handle) + return -1; + + r = rpc_port_proxy_add_connected_event_cb(handle->proxy, __AutofillSvcPort_on_connected, handle); + if (r != 0) { + _E("Failed to add connected event cb. err = %d", r); + __destroy_AutofillSvcPort(handle); + return r; + } + + r = rpc_port_proxy_add_disconnected_event_cb(handle->proxy, __AutofillSvcPort_on_disconnected, handle); + if (r != 0) { + _E("Failed to add disconnected event cb. err = %d", r); + __destroy_AutofillSvcPort(handle); + return r; + } + + r = rpc_port_proxy_add_rejected_event_cb(handle->proxy, __AutofillSvcPort_on_rejected, handle); + if (r != 0) { + _E("Failed to add rejected event cb. err = %d", r); + __destroy_AutofillSvcPort(handle); + return r; + } + + r = rpc_port_proxy_add_received_event_cb(handle->proxy, __AutofillSvcPort_on_received, handle); + if (r != 0) { + _E("Failed to add received event cb. err = %d", r); + __destroy_AutofillSvcPort(handle); + return r; + } + + *h = handle; + + return 0; +} + +int rpc_port_proxy_AutofillSvcPort_connect(rpc_port_proxy_AutofillSvcPort_h h) +{ + int r; + + if (!h || !h->proxy) { + _E("Invalid parameter"); + return -1; + } + + r = rpc_port_proxy_connect(h->proxy, h->stub_appid, "AutofillSvcPort"); + if (r != 0) { + _E("Failed to connect AutofillSvcPort(%s)", h->stub_appid); + return r; + } + + return 0; +} + +int rpc_port_proxy_AutofillSvcPort_destroy(rpc_port_proxy_AutofillSvcPort_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + __destroy_AutofillSvcPort(h); + return 0; +} diff --git a/server/autofill_service_proxy.h b/server/autofill_service_proxy.h new file mode 100644 index 0000000..451899e --- /dev/null +++ b/server/autofill_service_proxy.h @@ -0,0 +1,238 @@ +/* + * Generated by tidlc 1.3.1. + * + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct autofill_svc_item_s *rpc_port_autofill_svc_item_h; + +int rpc_port_autofill_svc_item_create(rpc_port_autofill_svc_item_h *h); + +int rpc_port_autofill_svc_item_destroy(rpc_port_autofill_svc_item_h h); + +int rpc_port_autofill_svc_item_clone(rpc_port_autofill_svc_item_h h, rpc_port_autofill_svc_item_h *clone); + +int rpc_port_autofill_svc_item_set_id(rpc_port_autofill_svc_item_h h, const char *id); + +int rpc_port_autofill_svc_item_set_label(rpc_port_autofill_svc_item_h h, const char *label); + +int rpc_port_autofill_svc_item_set_value(rpc_port_autofill_svc_item_h h, const char *value); + +int rpc_port_autofill_svc_item_set_autofill_hint(rpc_port_autofill_svc_item_h h, int autofill_hint); + +int rpc_port_autofill_svc_item_set_is_sensitive_data(rpc_port_autofill_svc_item_h h, bool is_sensitive_data); + +int rpc_port_autofill_svc_item_get_id(rpc_port_autofill_svc_item_h h, char **id); + +int rpc_port_autofill_svc_item_get_label(rpc_port_autofill_svc_item_h h, char **label); + +int rpc_port_autofill_svc_item_get_value(rpc_port_autofill_svc_item_h h, char **value); + +int rpc_port_autofill_svc_item_get_autofill_hint(rpc_port_autofill_svc_item_h h, int *autofill_hint); + +int rpc_port_autofill_svc_item_get_is_sensitive_data(rpc_port_autofill_svc_item_h h, bool *is_sensitive_data); + +typedef struct autofill_svc_view_info_s *rpc_port_autofill_svc_view_info_h; + +int rpc_port_autofill_svc_view_info_create(rpc_port_autofill_svc_view_info_h *h); + +int rpc_port_autofill_svc_view_info_destroy(rpc_port_autofill_svc_view_info_h h); + +int rpc_port_autofill_svc_view_info_clone(rpc_port_autofill_svc_view_info_h h, rpc_port_autofill_svc_view_info_h *clone); + +int rpc_port_autofill_svc_view_info_set_app_id(rpc_port_autofill_svc_view_info_h h, const char *app_id); + +int rpc_port_autofill_svc_view_info_set_view_id(rpc_port_autofill_svc_view_info_h h, const char *view_id); + +int rpc_port_autofill_svc_view_info_add_items(rpc_port_autofill_svc_view_info_h h, rpc_port_autofill_svc_item_h items); + +int rpc_port_autofill_svc_view_info_get_app_id(rpc_port_autofill_svc_view_info_h h, char **app_id); + +int rpc_port_autofill_svc_view_info_get_view_id(rpc_port_autofill_svc_view_info_h h, char **view_id); + +int rpc_port_autofill_svc_view_info_foreach_items(rpc_port_autofill_svc_view_info_h h, + bool (*callback)(rpc_port_autofill_svc_item_h items, void *user_data), void *user_data); + +int rpc_port_autofill_svc_view_info_remove_items(rpc_port_autofill_svc_view_info_h h, unsigned int nth); + +int rpc_port_autofill_svc_view_info_get_items_length(rpc_port_autofill_svc_view_info_h h, unsigned int *length); + +typedef struct autofill_svc_auth_info_s *rpc_port_autofill_svc_auth_info_h; + +int rpc_port_autofill_svc_auth_info_create(rpc_port_autofill_svc_auth_info_h *h); + +int rpc_port_autofill_svc_auth_info_destroy(rpc_port_autofill_svc_auth_info_h h); + +int rpc_port_autofill_svc_auth_info_clone(rpc_port_autofill_svc_auth_info_h h, rpc_port_autofill_svc_auth_info_h *clone); + +int rpc_port_autofill_svc_auth_info_set_app_id(rpc_port_autofill_svc_auth_info_h h, const char *app_id); + +int rpc_port_autofill_svc_auth_info_set_exist_autofill_data(rpc_port_autofill_svc_auth_info_h h, bool exist_autofill_data); + +int rpc_port_autofill_svc_auth_info_set_need_authentication(rpc_port_autofill_svc_auth_info_h h, bool need_authentication); + +int rpc_port_autofill_svc_auth_info_set_service_name(rpc_port_autofill_svc_auth_info_h h, const char *service_name); + +int rpc_port_autofill_svc_auth_info_set_service_logo_image_path(rpc_port_autofill_svc_auth_info_h h, const char *service_logo_image_path); + +int rpc_port_autofill_svc_auth_info_set_service_message(rpc_port_autofill_svc_auth_info_h h, const char *service_message); + +int rpc_port_autofill_svc_auth_info_get_app_id(rpc_port_autofill_svc_auth_info_h h, char **app_id); + +int rpc_port_autofill_svc_auth_info_get_exist_autofill_data(rpc_port_autofill_svc_auth_info_h h, bool *exist_autofill_data); + +int rpc_port_autofill_svc_auth_info_get_need_authentication(rpc_port_autofill_svc_auth_info_h h, bool *need_authentication); + +int rpc_port_autofill_svc_auth_info_get_service_name(rpc_port_autofill_svc_auth_info_h h, char **service_name); + +int rpc_port_autofill_svc_auth_info_get_service_logo_image_path(rpc_port_autofill_svc_auth_info_h h, char **service_logo_image_path); + +int rpc_port_autofill_svc_auth_info_get_service_message(rpc_port_autofill_svc_auth_info_h h, char **service_message); + +typedef struct autofill_svc_response_item_s *rpc_port_autofill_svc_response_item_h; + +int rpc_port_autofill_svc_response_item_create(rpc_port_autofill_svc_response_item_h *h); + +int rpc_port_autofill_svc_response_item_destroy(rpc_port_autofill_svc_response_item_h h); + +int rpc_port_autofill_svc_response_item_clone(rpc_port_autofill_svc_response_item_h h, rpc_port_autofill_svc_response_item_h *clone); + +int rpc_port_autofill_svc_response_item_set_id(rpc_port_autofill_svc_response_item_h h, const char *id); + +int rpc_port_autofill_svc_response_item_set_presentation_text(rpc_port_autofill_svc_response_item_h h, const char *presentation_text); + +int rpc_port_autofill_svc_response_item_set_value(rpc_port_autofill_svc_response_item_h h, const char *value); + +int rpc_port_autofill_svc_response_item_get_id(rpc_port_autofill_svc_response_item_h h, char **id); + +int rpc_port_autofill_svc_response_item_get_presentation_text(rpc_port_autofill_svc_response_item_h h, char **presentation_text); + +int rpc_port_autofill_svc_response_item_get_value(rpc_port_autofill_svc_response_item_h h, char **value); + +typedef struct autofill_svc_fill_response_s *rpc_port_autofill_svc_fill_response_h; + +int rpc_port_autofill_svc_fill_response_create(rpc_port_autofill_svc_fill_response_h *h); + +int rpc_port_autofill_svc_fill_response_destroy(rpc_port_autofill_svc_fill_response_h h); + +int rpc_port_autofill_svc_fill_response_clone(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_fill_response_h *clone); + +int rpc_port_autofill_svc_fill_response_set_app_id(rpc_port_autofill_svc_fill_response_h h, const char *app_id); + +int rpc_port_autofill_svc_fill_response_set_view_id(rpc_port_autofill_svc_fill_response_h h, const char *view_id); + +int rpc_port_autofill_svc_fill_response_add_response_items(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_response_item_h response_items); + +int rpc_port_autofill_svc_fill_response_get_app_id(rpc_port_autofill_svc_fill_response_h h, char **app_id); + +int rpc_port_autofill_svc_fill_response_get_view_id(rpc_port_autofill_svc_fill_response_h h, char **view_id); + +int rpc_port_autofill_svc_fill_response_foreach_response_items(rpc_port_autofill_svc_fill_response_h h, + bool (*callback)(rpc_port_autofill_svc_response_item_h response_items, void *user_data), void *user_data); + +int rpc_port_autofill_svc_fill_response_remove_response_items(rpc_port_autofill_svc_fill_response_h h, unsigned int nth); + +int rpc_port_autofill_svc_fill_response_get_response_items_length(rpc_port_autofill_svc_fill_response_h h, unsigned int *length); + +typedef struct list_autofill_svc_item_s *rpc_port_list_autofill_svc_item_h; + +int rpc_port_list_autofill_svc_item_create(rpc_port_list_autofill_svc_item_h *h); + +int rpc_port_list_autofill_svc_item_destroy(rpc_port_list_autofill_svc_item_h h); + +int rpc_port_list_autofill_svc_item_clone(rpc_port_list_autofill_svc_item_h h, rpc_port_list_autofill_svc_item_h *clone); + +int rpc_port_list_autofill_svc_item_add_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, rpc_port_autofill_svc_item_h list_autofill_svc_items); + +int rpc_port_list_autofill_svc_item_foreach_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, + bool (*callback)(rpc_port_autofill_svc_item_h list_autofill_svc_items, void *user_data), void *user_data); + +int rpc_port_list_autofill_svc_item_remove_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, unsigned int nth); + +int rpc_port_list_autofill_svc_item_get_list_autofill_svc_items_length(rpc_port_list_autofill_svc_item_h h, unsigned int *length); + +typedef struct list_autofill_svc_response_item_s *rpc_port_list_autofill_svc_response_item_h; + +int rpc_port_list_autofill_svc_response_item_create(rpc_port_list_autofill_svc_response_item_h *h); + +int rpc_port_list_autofill_svc_response_item_destroy(rpc_port_list_autofill_svc_response_item_h h); + +int rpc_port_list_autofill_svc_response_item_clone(rpc_port_list_autofill_svc_response_item_h h, rpc_port_list_autofill_svc_response_item_h *clone); + +int rpc_port_list_autofill_svc_response_item_add_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, rpc_port_autofill_svc_response_item_h list_autofill_svc_response_items); + +int rpc_port_list_autofill_svc_response_item_foreach_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, + bool (*callback)(rpc_port_autofill_svc_response_item_h list_autofill_svc_response_items, void *user_data), void *user_data); + +int rpc_port_list_autofill_svc_response_item_remove_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, unsigned int nth); + +int rpc_port_list_autofill_svc_response_item_get_list_autofill_svc_response_items_length(rpc_port_list_autofill_svc_response_item_h h, unsigned int *length); + +typedef struct AutofillSvcPort_s *rpc_port_proxy_AutofillSvcPort_h; + +typedef struct { + void (*connected)(rpc_port_proxy_AutofillSvcPort_h h, void *user_data); + void (*disconnected)(rpc_port_proxy_AutofillSvcPort_h h, void *user_data); + void (*rejected)(rpc_port_proxy_AutofillSvcPort_h h, void *user_data); +} rpc_port_proxy_AutofillSvcPort_callback_s; + +typedef struct AutofillSvcPort_autofill_svc_auth_info_cb_s *rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h; + +typedef void (*AutofillSvcPort_autofill_svc_auth_info_cb)(void *user_data, rpc_port_autofill_svc_auth_info_h auth_info); + +rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_create(AutofillSvcPort_autofill_svc_auth_info_cb callback, bool once, void *user_data); + +int rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_destroy(rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h delegate); + +int rpc_port_proxy_AutofillSvcPort_autofill_svc_auth_info_cb_dispose(rpc_port_proxy_AutofillSvcPort_h proxy, rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h delegate); + +typedef struct AutofillSvcPort_autofill_svc_fill_response_cb_s *rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h; + +typedef void (*AutofillSvcPort_autofill_svc_fill_response_cb)(void *user_data, rpc_port_autofill_svc_fill_response_h response); + +rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_create(AutofillSvcPort_autofill_svc_fill_response_cb callback, bool once, void *user_data); + +int rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_destroy(rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h delegate); + +int rpc_port_proxy_AutofillSvcPort_autofill_svc_fill_response_cb_dispose(rpc_port_proxy_AutofillSvcPort_h proxy, rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h delegate); + +int rpc_port_proxy_AutofillSvcPort_create(const char *stub_appid, + rpc_port_proxy_AutofillSvcPort_callback_s *callback, void *user_data, + rpc_port_proxy_AutofillSvcPort_h *h); + +int rpc_port_proxy_AutofillSvcPort_connect(rpc_port_proxy_AutofillSvcPort_h h); + +int rpc_port_proxy_AutofillSvcPort_destroy(rpc_port_proxy_AutofillSvcPort_h h); + +int rpc_port_proxy_AutofillSvcPort_invoke_Register(rpc_port_proxy_AutofillSvcPort_h h, rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb, rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_cb); + +void rpc_port_proxy_AutofillSvcPort_invoke_Unregister(rpc_port_proxy_AutofillSvcPort_h h); + +void rpc_port_proxy_AutofillSvcPort_invoke_request_auth_info(rpc_port_proxy_AutofillSvcPort_h h, rpc_port_autofill_svc_view_info_h vi); + +void rpc_port_proxy_AutofillSvcPort_invoke_send_fill_request(rpc_port_proxy_AutofillSvcPort_h h, rpc_port_autofill_svc_view_info_h vi); + +#ifdef __cplusplus +} +#endif diff --git a/server/autofill_stub.c b/server/autofill_stub.c new file mode 100644 index 0000000..792804c --- /dev/null +++ b/server/autofill_stub.c @@ -0,0 +1,2706 @@ +/* + * Generated by tidlc 1.3.1. + * + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "autofill_stub.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "RPC_PORT_STUB" + +#ifdef _E +#undef _E +#endif + +#ifdef _W +#undef _W +#endif + +#ifdef _I +#undef _I +#endif + +#ifdef _D +#undef _D +#endif + +#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +typedef int (*stub_method)(rpc_port_h, rpc_port_parcel_h, void *data); + +struct autofill_item_s { + rpc_port_parcelable_t parcelable; + char *id; + char *label; + char *value; + int autofill_hint; + bool is_sensitive_data; +}; + +static void __autofill_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->id ? h->id : ""); + rpc_port_parcel_write_string(parcel, h->label ? h->label : ""); + rpc_port_parcel_write_string(parcel, h->value ? h->value : ""); + rpc_port_parcel_write_int32(parcel, h->autofill_hint); + rpc_port_parcel_write_bool(parcel, h->is_sensitive_data); +} + +static void __autofill_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->id); + rpc_port_parcel_read_string(parcel, &h->label); + rpc_port_parcel_read_string(parcel, &h->value); + rpc_port_parcel_read_int32(parcel, &h->autofill_hint); + rpc_port_parcel_read_bool(parcel, &h->is_sensitive_data); +} + +int rpc_port_autofill_item_create(rpc_port_autofill_item_h *h) +{ + struct autofill_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_item_to; + handle->parcelable.from = __autofill_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_item_destroy(rpc_port_autofill_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) + free(h->id); + + if (h->label) + free(h->label); + + if (h->value) + free(h->value); + + free(h); + + return 0; +} + +int rpc_port_autofill_item_clone(rpc_port_autofill_item_h h, rpc_port_autofill_item_h *clone) +{ + rpc_port_autofill_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_item_create(&handle); + if (!handle) { + _E("Failed to create autofill_item handle"); + return -1; + } + + if (h->id) { + handle->id = strdup(h->id); + if (!handle->id) { + _E("Failed to duplicate h->id"); + rpc_port_autofill_item_destroy(handle); + return -1; + } + } + + if (h->label) { + handle->label = strdup(h->label); + if (!handle->label) { + _E("Failed to duplicate h->label"); + rpc_port_autofill_item_destroy(handle); + return -1; + } + } + + if (h->value) { + handle->value = strdup(h->value); + if (!handle->value) { + _E("Failed to duplicate h->value"); + rpc_port_autofill_item_destroy(handle); + return -1; + } + } + + handle->autofill_hint = h->autofill_hint; + handle->is_sensitive_data = h->is_sensitive_data; + *clone = handle; + + return 0; +} + +int rpc_port_autofill_item_set_id(rpc_port_autofill_item_h h, const char *id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) { + free(h->id); + h->id = NULL; + } + + h->id = strdup(id); + if (!h->id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_set_label(rpc_port_autofill_item_h h, const char *label) +{ + if (!h || !label) { + _E("Invalid parameter"); + return -1; + } + + if (h->label) { + free(h->label); + h->label = NULL; + } + + h->label = strdup(label); + if (!h->label) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_set_value(rpc_port_autofill_item_h h, const char *value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (h->value) { + free(h->value); + h->value = NULL; + } + + h->value = strdup(value); + if (!h->value) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_set_autofill_hint(rpc_port_autofill_item_h h, int autofill_hint) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->autofill_hint = autofill_hint; + return 0; +} + +int rpc_port_autofill_item_set_is_sensitive_data(rpc_port_autofill_item_h h, bool is_sensitive_data) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->is_sensitive_data = is_sensitive_data; + return 0; +} + +int rpc_port_autofill_item_get_id(rpc_port_autofill_item_h h, char **id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->id) { + _E("Invalid parameter: h->id is NULL"); + return -1; + } + + *id = strdup(h->id); + if (*id == NULL) { + _E("Failed to duplicate id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_get_label(rpc_port_autofill_item_h h, char **label) +{ + if (!h || !label) { + _E("Invalid parameter"); + return -1; + } + + if (!h->label) { + _E("Invalid parameter: h->label is NULL"); + return -1; + } + + *label = strdup(h->label); + if (*label == NULL) { + _E("Failed to duplicate label"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_get_value(rpc_port_autofill_item_h h, char **value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (!h->value) { + _E("Invalid parameter: h->value is NULL"); + return -1; + } + + *value = strdup(h->value); + if (*value == NULL) { + _E("Failed to duplicate value"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_item_get_autofill_hint(rpc_port_autofill_item_h h, int *autofill_hint) +{ + if (!h || !autofill_hint) { + _E("Invalid parameter"); + return -1; + } + + *autofill_hint = h->autofill_hint; + return 0; +} + +int rpc_port_autofill_item_get_is_sensitive_data(rpc_port_autofill_item_h h, bool *is_sensitive_data) +{ + if (!h || !is_sensitive_data) { + _E("Invalid parameter"); + return -1; + } + + *is_sensitive_data = h->is_sensitive_data; + return 0; +} + +struct autofill_view_info_s { + rpc_port_parcelable_t parcelable; + char *view_id; + GList *items; +}; + +static void __autofill_view_info_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_view_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->view_id ? h->view_id : ""); + rpc_port_parcel_write_array_count(parcel, g_list_length(h->items)); + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __autofill_view_info_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_view_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->view_id); + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_item_h value = NULL; + + rpc_port_autofill_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->items = g_list_append(h->items, value); + } + } while (0); +} + +int rpc_port_autofill_view_info_create(rpc_port_autofill_view_info_h *h) +{ + struct autofill_view_info_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_view_info_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_view_info_to; + handle->parcelable.from = __autofill_view_info_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_view_info_destroy(rpc_port_autofill_view_info_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) + free(h->view_id); + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + if (value) + rpc_port_autofill_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_autofill_view_info_clone(rpc_port_autofill_view_info_h h, rpc_port_autofill_view_info_h *clone) +{ + rpc_port_autofill_view_info_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_view_info_create(&handle); + if (!handle) { + _E("Failed to create autofill_view_info handle"); + return -1; + } + + if (h->view_id) { + handle->view_id = strdup(h->view_id); + if (!handle->view_id) { + _E("Failed to duplicate h->view_id"); + rpc_port_autofill_view_info_destroy(handle); + return -1; + } + } + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_item_h new_value; + rpc_port_autofill_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_autofill_view_info_destroy(handle); + return -1; + } + + rpc_port_autofill_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_view_info_destroy(handle); + return -1; + } + + handle->items = g_list_append(handle->items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_view_info_set_view_id(rpc_port_autofill_view_info_h h, const char *view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) { + free(h->view_id); + h->view_id = NULL; + } + + h->view_id = strdup(view_id); + if (!h->view_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_view_info_add_items(rpc_port_autofill_view_info_h h, rpc_port_autofill_item_h items) +{ + if (!h || !items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_item_h value = NULL; + + rpc_port_autofill_item_clone(items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->items = g_list_append(h->items, value); + } while (0); + + return 0; +} + +int rpc_port_autofill_view_info_get_view_id(rpc_port_autofill_view_info_h h, char **view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->view_id) { + _E("Invalid parameter: h->view_id is NULL"); + return -1; + } + + *view_id = strdup(h->view_id); + if (*view_id == NULL) { + _E("Failed to duplicate view_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_view_info_foreach_items(rpc_port_autofill_view_info_h h, + bool (*callback)(rpc_port_autofill_item_h items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_autofill_view_info_remove_items(rpc_port_autofill_view_info_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_item_h value = iter->data; + h->items = g_list_remove_link(h->items, iter); + rpc_port_autofill_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_view_info_get_items_length(rpc_port_autofill_view_info_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->items); + + return 0; +} + +struct autofill_auth_info_s { + rpc_port_parcelable_t parcelable; + bool exist_autofill_data; + bool need_authentication; + char *service_name; + char *service_logo_image_path; + char *service_message; +}; + +static void __autofill_auth_info_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_auth_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_bool(parcel, h->exist_autofill_data); + rpc_port_parcel_write_bool(parcel, h->need_authentication); + rpc_port_parcel_write_string(parcel, h->service_name ? h->service_name : ""); + rpc_port_parcel_write_string(parcel, h->service_logo_image_path ? h->service_logo_image_path : ""); + rpc_port_parcel_write_string(parcel, h->service_message ? h->service_message : ""); +} + +static void __autofill_auth_info_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_auth_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_bool(parcel, &h->exist_autofill_data); + rpc_port_parcel_read_bool(parcel, &h->need_authentication); + rpc_port_parcel_read_string(parcel, &h->service_name); + rpc_port_parcel_read_string(parcel, &h->service_logo_image_path); + rpc_port_parcel_read_string(parcel, &h->service_message); +} + +int rpc_port_autofill_auth_info_create(rpc_port_autofill_auth_info_h *h) +{ + struct autofill_auth_info_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_auth_info_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_auth_info_to; + handle->parcelable.from = __autofill_auth_info_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_auth_info_destroy(rpc_port_autofill_auth_info_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_name) + free(h->service_name); + + if (h->service_logo_image_path) + free(h->service_logo_image_path); + + if (h->service_message) + free(h->service_message); + + free(h); + + return 0; +} + +int rpc_port_autofill_auth_info_clone(rpc_port_autofill_auth_info_h h, rpc_port_autofill_auth_info_h *clone) +{ + rpc_port_autofill_auth_info_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_auth_info_create(&handle); + if (!handle) { + _E("Failed to create autofill_auth_info handle"); + return -1; + } + + handle->exist_autofill_data = h->exist_autofill_data; + handle->need_authentication = h->need_authentication; + if (h->service_name) { + handle->service_name = strdup(h->service_name); + if (!handle->service_name) { + _E("Failed to duplicate h->service_name"); + rpc_port_autofill_auth_info_destroy(handle); + return -1; + } + } + + if (h->service_logo_image_path) { + handle->service_logo_image_path = strdup(h->service_logo_image_path); + if (!handle->service_logo_image_path) { + _E("Failed to duplicate h->service_logo_image_path"); + rpc_port_autofill_auth_info_destroy(handle); + return -1; + } + } + + if (h->service_message) { + handle->service_message = strdup(h->service_message); + if (!handle->service_message) { + _E("Failed to duplicate h->service_message"); + rpc_port_autofill_auth_info_destroy(handle); + return -1; + } + } + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_auth_info_set_exist_autofill_data(rpc_port_autofill_auth_info_h h, bool exist_autofill_data) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->exist_autofill_data = exist_autofill_data; + return 0; +} + +int rpc_port_autofill_auth_info_set_need_authentication(rpc_port_autofill_auth_info_h h, bool need_authentication) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->need_authentication = need_authentication; + return 0; +} + +int rpc_port_autofill_auth_info_set_service_name(rpc_port_autofill_auth_info_h h, const char *service_name) +{ + if (!h || !service_name) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_name) { + free(h->service_name); + h->service_name = NULL; + } + + h->service_name = strdup(service_name); + if (!h->service_name) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_auth_info_set_service_logo_image_path(rpc_port_autofill_auth_info_h h, const char *service_logo_image_path) +{ + if (!h || !service_logo_image_path) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_logo_image_path) { + free(h->service_logo_image_path); + h->service_logo_image_path = NULL; + } + + h->service_logo_image_path = strdup(service_logo_image_path); + if (!h->service_logo_image_path) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_auth_info_set_service_message(rpc_port_autofill_auth_info_h h, const char *service_message) +{ + if (!h || !service_message) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_message) { + free(h->service_message); + h->service_message = NULL; + } + + h->service_message = strdup(service_message); + if (!h->service_message) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_auth_info_get_exist_autofill_data(rpc_port_autofill_auth_info_h h, bool *exist_autofill_data) +{ + if (!h || !exist_autofill_data) { + _E("Invalid parameter"); + return -1; + } + + *exist_autofill_data = h->exist_autofill_data; + return 0; +} + +int rpc_port_autofill_auth_info_get_need_authentication(rpc_port_autofill_auth_info_h h, bool *need_authentication) +{ + if (!h || !need_authentication) { + _E("Invalid parameter"); + return -1; + } + + *need_authentication = h->need_authentication; + return 0; +} + +int rpc_port_autofill_auth_info_get_service_name(rpc_port_autofill_auth_info_h h, char **service_name) +{ + if (!h || !service_name) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_name) { + _E("Invalid parameter: h->service_name is NULL"); + return -1; + } + + *service_name = strdup(h->service_name); + if (*service_name == NULL) { + _E("Failed to duplicate service_name"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_auth_info_get_service_logo_image_path(rpc_port_autofill_auth_info_h h, char **service_logo_image_path) +{ + if (!h || !service_logo_image_path) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_logo_image_path) { + _E("Invalid parameter: h->service_logo_image_path is NULL"); + return -1; + } + + *service_logo_image_path = strdup(h->service_logo_image_path); + if (*service_logo_image_path == NULL) { + _E("Failed to duplicate service_logo_image_path"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_auth_info_get_service_message(rpc_port_autofill_auth_info_h h, char **service_message) +{ + if (!h || !service_message) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_message) { + _E("Invalid parameter: h->service_message is NULL"); + return -1; + } + + *service_message = strdup(h->service_message); + if (*service_message == NULL) { + _E("Failed to duplicate service_message"); + return -1; + } + + return 0; +} + +struct autofill_response_item_s { + rpc_port_parcelable_t parcelable; + char *id; + char *presentation_text; + char *value; +}; + +static void __autofill_response_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->id ? h->id : ""); + rpc_port_parcel_write_string(parcel, h->presentation_text ? h->presentation_text : ""); + rpc_port_parcel_write_string(parcel, h->value ? h->value : ""); +} + +static void __autofill_response_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->id); + rpc_port_parcel_read_string(parcel, &h->presentation_text); + rpc_port_parcel_read_string(parcel, &h->value); +} + +int rpc_port_autofill_response_item_create(rpc_port_autofill_response_item_h *h) +{ + struct autofill_response_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_response_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_response_item_to; + handle->parcelable.from = __autofill_response_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_response_item_destroy(rpc_port_autofill_response_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) + free(h->id); + + if (h->presentation_text) + free(h->presentation_text); + + if (h->value) + free(h->value); + + free(h); + + return 0; +} + +int rpc_port_autofill_response_item_clone(rpc_port_autofill_response_item_h h, rpc_port_autofill_response_item_h *clone) +{ + rpc_port_autofill_response_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_response_item_create(&handle); + if (!handle) { + _E("Failed to create autofill_response_item handle"); + return -1; + } + + if (h->id) { + handle->id = strdup(h->id); + if (!handle->id) { + _E("Failed to duplicate h->id"); + rpc_port_autofill_response_item_destroy(handle); + return -1; + } + } + + if (h->presentation_text) { + handle->presentation_text = strdup(h->presentation_text); + if (!handle->presentation_text) { + _E("Failed to duplicate h->presentation_text"); + rpc_port_autofill_response_item_destroy(handle); + return -1; + } + } + + if (h->value) { + handle->value = strdup(h->value); + if (!handle->value) { + _E("Failed to duplicate h->value"); + rpc_port_autofill_response_item_destroy(handle); + return -1; + } + } + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_response_item_set_id(rpc_port_autofill_response_item_h h, const char *id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) { + free(h->id); + h->id = NULL; + } + + h->id = strdup(id); + if (!h->id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_response_item_set_presentation_text(rpc_port_autofill_response_item_h h, const char *presentation_text) +{ + if (!h || !presentation_text) { + _E("Invalid parameter"); + return -1; + } + + if (h->presentation_text) { + free(h->presentation_text); + h->presentation_text = NULL; + } + + h->presentation_text = strdup(presentation_text); + if (!h->presentation_text) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_response_item_set_value(rpc_port_autofill_response_item_h h, const char *value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (h->value) { + free(h->value); + h->value = NULL; + } + + h->value = strdup(value); + if (!h->value) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_response_item_get_id(rpc_port_autofill_response_item_h h, char **id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->id) { + _E("Invalid parameter: h->id is NULL"); + return -1; + } + + *id = strdup(h->id); + if (*id == NULL) { + _E("Failed to duplicate id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_response_item_get_presentation_text(rpc_port_autofill_response_item_h h, char **presentation_text) +{ + if (!h || !presentation_text) { + _E("Invalid parameter"); + return -1; + } + + if (!h->presentation_text) { + _E("Invalid parameter: h->presentation_text is NULL"); + return -1; + } + + *presentation_text = strdup(h->presentation_text); + if (*presentation_text == NULL) { + _E("Failed to duplicate presentation_text"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_response_item_get_value(rpc_port_autofill_response_item_h h, char **value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (!h->value) { + _E("Invalid parameter: h->value is NULL"); + return -1; + } + + *value = strdup(h->value); + if (*value == NULL) { + _E("Failed to duplicate value"); + return -1; + } + + return 0; +} + +struct autofill_fill_response_s { + rpc_port_parcelable_t parcelable; + char *view_id; + GList *response_items; +}; + +static void __autofill_fill_response_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_fill_response_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->view_id ? h->view_id : ""); + rpc_port_parcel_write_array_count(parcel, g_list_length(h->response_items)); + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __autofill_fill_response_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_fill_response_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->view_id); + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_response_item_h value = NULL; + + rpc_port_autofill_response_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->response_items = g_list_append(h->response_items, value); + } + } while (0); +} + +int rpc_port_autofill_fill_response_create(rpc_port_autofill_fill_response_h *h) +{ + struct autofill_fill_response_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_fill_response_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_fill_response_to; + handle->parcelable.from = __autofill_fill_response_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_fill_response_destroy(rpc_port_autofill_fill_response_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) + free(h->view_id); + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + if (value) + rpc_port_autofill_response_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->response_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_autofill_fill_response_clone(rpc_port_autofill_fill_response_h h, rpc_port_autofill_fill_response_h *clone) +{ + rpc_port_autofill_fill_response_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_fill_response_create(&handle); + if (!handle) { + _E("Failed to create autofill_fill_response handle"); + return -1; + } + + if (h->view_id) { + handle->view_id = strdup(h->view_id); + if (!handle->view_id) { + _E("Failed to duplicate h->view_id"); + rpc_port_autofill_fill_response_destroy(handle); + return -1; + } + } + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_response_item_h new_value; + rpc_port_autofill_response_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_autofill_fill_response_destroy(handle); + return -1; + } + + rpc_port_autofill_response_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_fill_response_destroy(handle); + return -1; + } + + handle->response_items = g_list_append(handle->response_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_fill_response_set_view_id(rpc_port_autofill_fill_response_h h, const char *view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) { + free(h->view_id); + h->view_id = NULL; + } + + h->view_id = strdup(view_id); + if (!h->view_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_fill_response_add_response_items(rpc_port_autofill_fill_response_h h, rpc_port_autofill_response_item_h response_items) +{ + if (!h || !response_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_response_item_h value = NULL; + + rpc_port_autofill_response_item_clone(response_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->response_items = g_list_append(h->response_items, value); + } while (0); + + return 0; +} + +int rpc_port_autofill_fill_response_get_view_id(rpc_port_autofill_fill_response_h h, char **view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->view_id) { + _E("Invalid parameter: h->view_id is NULL"); + return -1; + } + + *view_id = strdup(h->view_id); + if (*view_id == NULL) { + _E("Failed to duplicate view_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_fill_response_foreach_response_items(rpc_port_autofill_fill_response_h h, + bool (*callback)(rpc_port_autofill_response_item_h response_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_autofill_fill_response_remove_response_items(rpc_port_autofill_fill_response_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->response_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_response_item_h value = iter->data; + h->response_items = g_list_remove_link(h->response_items, iter); + rpc_port_autofill_response_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_fill_response_get_response_items_length(rpc_port_autofill_fill_response_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->response_items); + + return 0; +} + +struct list_autofill_item_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_items; +}; + +static void __list_autofill_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_items)); + do { + GList *iter; + + iter = h->list_autofill_items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __list_autofill_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_item_h value = NULL; + + rpc_port_autofill_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_items = g_list_append(h->list_autofill_items, value); + } + } while (0); +} + +int rpc_port_list_autofill_item_create(rpc_port_list_autofill_item_h *h) +{ + struct list_autofill_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_item_to; + handle->parcelable.from = __list_autofill_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_item_destroy(rpc_port_list_autofill_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + if (value) + rpc_port_autofill_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_item_clone(rpc_port_list_autofill_item_h h, rpc_port_list_autofill_item_h *clone) +{ + rpc_port_list_autofill_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_item_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_item handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_items; + while (iter) { + rpc_port_autofill_item_h new_value; + rpc_port_autofill_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_item_destroy(handle); + return -1; + } + + rpc_port_autofill_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_item_destroy(handle); + return -1; + } + + handle->list_autofill_items = g_list_append(handle->list_autofill_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_item_add_list_autofill_items(rpc_port_list_autofill_item_h h, rpc_port_autofill_item_h list_autofill_items) +{ + if (!h || !list_autofill_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_item_h value = NULL; + + rpc_port_autofill_item_clone(list_autofill_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_items = g_list_append(h->list_autofill_items, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_item_foreach_list_autofill_items(rpc_port_list_autofill_item_h h, + bool (*callback)(rpc_port_autofill_item_h list_autofill_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_items; + while (iter) { + rpc_port_autofill_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_list_autofill_item_remove_list_autofill_items(rpc_port_list_autofill_item_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_item_h value = iter->data; + h->list_autofill_items = g_list_remove_link(h->list_autofill_items, iter); + rpc_port_autofill_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_item_get_list_autofill_items_length(rpc_port_list_autofill_item_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_items); + + return 0; +} + +struct list_autofill_response_item_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_response_items; +}; + +static void __list_autofill_response_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_response_items)); + do { + GList *iter; + + iter = h->list_autofill_response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __list_autofill_response_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_response_item_h value = NULL; + + rpc_port_autofill_response_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_response_items = g_list_append(h->list_autofill_response_items, value); + } + } while (0); +} + +int rpc_port_list_autofill_response_item_create(rpc_port_list_autofill_response_item_h *h) +{ + struct list_autofill_response_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_response_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_response_item_to; + handle->parcelable.from = __list_autofill_response_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_response_item_destroy(rpc_port_list_autofill_response_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + if (value) + rpc_port_autofill_response_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_response_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_response_item_clone(rpc_port_list_autofill_response_item_h h, rpc_port_list_autofill_response_item_h *clone) +{ + rpc_port_list_autofill_response_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_response_item_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_response_item handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_response_items; + while (iter) { + rpc_port_autofill_response_item_h new_value; + rpc_port_autofill_response_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_response_item_destroy(handle); + return -1; + } + + rpc_port_autofill_response_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_response_item_destroy(handle); + return -1; + } + + handle->list_autofill_response_items = g_list_append(handle->list_autofill_response_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_response_item_add_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, rpc_port_autofill_response_item_h list_autofill_response_items) +{ + if (!h || !list_autofill_response_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_response_item_h value = NULL; + + rpc_port_autofill_response_item_clone(list_autofill_response_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_response_items = g_list_append(h->list_autofill_response_items, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_response_item_foreach_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, + bool (*callback)(rpc_port_autofill_response_item_h list_autofill_response_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_response_items; + while (iter) { + rpc_port_autofill_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_list_autofill_response_item_remove_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_response_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_response_item_h value = iter->data; + h->list_autofill_response_items = g_list_remove_link(h->list_autofill_response_items, iter); + rpc_port_autofill_response_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_response_item_get_list_autofill_response_items_length(rpc_port_list_autofill_response_item_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_response_items); + + return 0; +} + +enum AutofillAppPort_method_e { + AutofillAppPort_METHOD_Result, + AutofillAppPort_METHOD_Callback, + AutofillAppPort_METHOD_Register, + AutofillAppPort_METHOD_Unregister, + AutofillAppPort_METHOD_request_auth_info, + AutofillAppPort_METHOD_send_fill_request, +}; + +enum AutofillAppPort_delegate_e { + AutofillAppPort_DELEGATE_autofill_auth_info_cb = 1, + AutofillAppPort_DELEGATE_autofill_fill_response_cb = 2, +}; + +static rpc_port_stub_h __AutofillAppPort_stub; +static rpc_port_stub_AutofillAppPort_callback_s __AutofillAppPort_callback; +static void *__AutofillAppPort_user_data; +static GList *__AutofillAppPort_contexts; + +struct AutofillAppPort_context_s { + char *sender; + char *instance; + rpc_port_h port; + void *tag; + rpc_port_stub_AutofillAppPort_callback_s callback; + void *user_data; +}; + +static struct AutofillAppPort_context_s *__create_AutofillAppPort_context(const char *sender, const char *instance) +{ + struct AutofillAppPort_context_s *handle; + + handle = calloc(1, sizeof(struct AutofillAppPort_context_s)); + if (!handle) { + _E("Out of memory"); + return NULL; + } + + handle->sender = strdup(sender); + if (!handle->sender) { + _E("Out of memory"); + free(handle); + return NULL; + } + + handle->instance = strdup(instance); + if (!handle->instance) { + _E("Out of memory"); + free(handle->sender); + free(handle); + return NULL; + } + + handle->callback = __AutofillAppPort_callback; + handle->user_data = __AutofillAppPort_user_data; + + return handle; +} + +static void __destroy_AutofillAppPort_context(gpointer data) +{ + struct AutofillAppPort_context_s *handle = data; + + if (!handle) { + _E("Critical error!"); + return; + } + + free(handle->instance); + free(handle->sender); + free(handle); +} + +static struct AutofillAppPort_context_s *__find_AutofillAppPort_context(const char *instance) +{ + struct AutofillAppPort_context_s *handle; + GList *iter; + + iter = __AutofillAppPort_contexts; + while (iter) { + handle = (struct AutofillAppPort_context_s *)iter->data; + if (!strcmp(handle->instance, instance)) + return handle; + iter = g_list_next(iter); + } + + return NULL; +} + +int rpc_port_stub_AutofillAppPort_context_set_tag(rpc_port_stub_AutofillAppPort_context_h ctx, void *tag) +{ + if (!ctx) { + _E("Invalid parameter"); + return -1; + } + + ctx->tag = tag; + + return 0; +} + +int rpc_port_stub_AutofillAppPort_context_get_tag(rpc_port_stub_AutofillAppPort_context_h ctx, void **tag) +{ + if (!ctx || !tag) { + _E("Invalid parameter"); + return -1; + } + + *tag = ctx->tag; + + return 0; +} + +int rpc_port_stub_AutofillAppPort_context_get_sender(rpc_port_stub_AutofillAppPort_context_h ctx, char **sender) +{ + if (!ctx || !sender) { + _E("Invalid parameter"); + return -1; + } + + *sender = strdup(ctx->sender); + if (*sender == NULL) { + _E("Out of memory"); + return -1; + } + + return 0; +} + +struct AutofillAppPort_autofill_auth_info_cb_s { + rpc_port_parcelable_t parcelable; + rpc_port_h port; + int id; + int seq_id; + bool once; + bool valid; +}; + +static void __AutofillAppPort_autofill_auth_info_cb_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillAppPort_autofill_auth_info_cb_h handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, handle->id); + rpc_port_parcel_write_int32(parcel, handle->seq_id); + rpc_port_parcel_write_bool(parcel, handle->once); +} + +static void __AutofillAppPort_autofill_auth_info_cb_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillAppPort_autofill_auth_info_cb_h handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_int32(parcel, &handle->id); + rpc_port_parcel_read_int32(parcel, &handle->seq_id); + rpc_port_parcel_read_bool(parcel, &handle->once); +} + +int rpc_port_AutofillAppPort_autofill_auth_info_cb_create(rpc_port_AutofillAppPort_autofill_auth_info_cb_h *h) +{ + struct AutofillAppPort_autofill_auth_info_cb_s *handle; + static int seq_num; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillAppPort_autofill_auth_info_cb_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __AutofillAppPort_autofill_auth_info_cb_to; + handle->parcelable.from = __AutofillAppPort_autofill_auth_info_cb_from; + handle->id = AutofillAppPort_DELEGATE_autofill_auth_info_cb; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + handle->once = false; + handle->valid = true; + + *h = handle; + + return 0; +} + +int rpc_port_AutofillAppPort_autofill_auth_info_cb_destroy(rpc_port_AutofillAppPort_autofill_auth_info_cb_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + free(h); + + return 0; +} + +int rpc_port_AutofillAppPort_autofill_auth_info_cb_clone(rpc_port_AutofillAppPort_autofill_auth_info_cb_h h, rpc_port_AutofillAppPort_autofill_auth_info_cb_h *clone) +{ + rpc_port_AutofillAppPort_autofill_auth_info_cb_h handle; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillAppPort_autofill_auth_info_cb_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable = h->parcelable; + handle->port = h->port; + handle->id = h->id; + handle->seq_id = h->seq_id; + handle->once = h->once; + handle->valid = h->valid; + + *clone = handle; + + return 0; +} + +int rpc_port_AutofillAppPort_autofill_auth_info_cb_invoke(rpc_port_AutofillAppPort_autofill_auth_info_cb_h h, rpc_port_autofill_auth_info_h auth_info) +{ + rpc_port_parcel_h parcel = NULL; + + if (!h || !h->port) { + _E("Invalid parameter"); + return -1; + } + + if (h->once && !h->valid) { + _E("Invalid callback"); + return -1; + } + + rpc_port_parcel_create(&parcel); + if (!parcel) { + _E("Failed to create parcel"); + return -1; + } + + rpc_port_parcel_write_int32(parcel, AutofillAppPort_METHOD_Callback); + rpc_port_parcel_write(parcel, &h->parcelable, h); + rpc_port_parcel_write(parcel, &auth_info->parcelable, auth_info); + + rpc_port_parcel_send(parcel, h->port); + rpc_port_parcel_destroy(parcel); + h->valid = false; + + return 0; +} + +int rpc_port_AutofillAppPort_autofill_auth_info_cb_set_port(rpc_port_AutofillAppPort_autofill_auth_info_cb_h h, rpc_port_h port) +{ + if (!h || !port) { + _E("Invalid parameter"); + return -1; + } + + h->port = port; + + return 0; +} + +struct AutofillAppPort_autofill_fill_response_cb_s { + rpc_port_parcelable_t parcelable; + rpc_port_h port; + int id; + int seq_id; + bool once; + bool valid; +}; + +static void __AutofillAppPort_autofill_fill_response_cb_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillAppPort_autofill_fill_response_cb_h handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, handle->id); + rpc_port_parcel_write_int32(parcel, handle->seq_id); + rpc_port_parcel_write_bool(parcel, handle->once); +} + +static void __AutofillAppPort_autofill_fill_response_cb_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillAppPort_autofill_fill_response_cb_h handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_int32(parcel, &handle->id); + rpc_port_parcel_read_int32(parcel, &handle->seq_id); + rpc_port_parcel_read_bool(parcel, &handle->once); +} + +int rpc_port_AutofillAppPort_autofill_fill_response_cb_create(rpc_port_AutofillAppPort_autofill_fill_response_cb_h *h) +{ + struct AutofillAppPort_autofill_fill_response_cb_s *handle; + static int seq_num; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillAppPort_autofill_fill_response_cb_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __AutofillAppPort_autofill_fill_response_cb_to; + handle->parcelable.from = __AutofillAppPort_autofill_fill_response_cb_from; + handle->id = AutofillAppPort_DELEGATE_autofill_fill_response_cb; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + handle->once = false; + handle->valid = true; + + *h = handle; + + return 0; +} + +int rpc_port_AutofillAppPort_autofill_fill_response_cb_destroy(rpc_port_AutofillAppPort_autofill_fill_response_cb_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + free(h); + + return 0; +} + +int rpc_port_AutofillAppPort_autofill_fill_response_cb_clone(rpc_port_AutofillAppPort_autofill_fill_response_cb_h h, rpc_port_AutofillAppPort_autofill_fill_response_cb_h *clone) +{ + rpc_port_AutofillAppPort_autofill_fill_response_cb_h handle; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillAppPort_autofill_fill_response_cb_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable = h->parcelable; + handle->port = h->port; + handle->id = h->id; + handle->seq_id = h->seq_id; + handle->once = h->once; + handle->valid = h->valid; + + *clone = handle; + + return 0; +} + +int rpc_port_AutofillAppPort_autofill_fill_response_cb_invoke(rpc_port_AutofillAppPort_autofill_fill_response_cb_h h, rpc_port_autofill_fill_response_h response) +{ + rpc_port_parcel_h parcel = NULL; + + if (!h || !h->port) { + _E("Invalid parameter"); + return -1; + } + + if (h->once && !h->valid) { + _E("Invalid callback"); + return -1; + } + + rpc_port_parcel_create(&parcel); + if (!parcel) { + _E("Failed to create parcel"); + return -1; + } + + rpc_port_parcel_write_int32(parcel, AutofillAppPort_METHOD_Callback); + rpc_port_parcel_write(parcel, &h->parcelable, h); + rpc_port_parcel_write(parcel, &response->parcelable, response); + + rpc_port_parcel_send(parcel, h->port); + rpc_port_parcel_destroy(parcel); + h->valid = false; + + return 0; +} + +int rpc_port_AutofillAppPort_autofill_fill_response_cb_set_port(rpc_port_AutofillAppPort_autofill_fill_response_cb_h h, rpc_port_h port) +{ + if (!h || !port) { + _E("Invalid parameter"); + return -1; + } + + h->port = port; + + return 0; +} + +static int __AutofillAppPort_method_Register(rpc_port_h port, rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_AutofillAppPort_context_h context = data; + rpc_port_h callback_port; + int r; + + r = rpc_port_stub_get_port(__AutofillAppPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); + if (r != 0) { + _E("Failed to get callback port"); + return -1; + } + + rpc_port_AutofillAppPort_autofill_auth_info_cb_h auth_info_cb = NULL; + rpc_port_AutofillAppPort_autofill_fill_response_cb_h fill_response_cb = NULL; + + rpc_port_AutofillAppPort_autofill_auth_info_cb_create(&auth_info_cb); + + if (!auth_info_cb) { + _E("Failed to create handle"); + return -1; + } + + rpc_port_AutofillAppPort_autofill_auth_info_cb_set_port(auth_info_cb, callback_port); + rpc_port_parcel_read(parcel, &auth_info_cb->parcelable, auth_info_cb); + rpc_port_AutofillAppPort_autofill_fill_response_cb_create(&fill_response_cb); + + if (!fill_response_cb) { + _E("Failed to create handle"); + return -1; + } + + rpc_port_AutofillAppPort_autofill_fill_response_cb_set_port(fill_response_cb, callback_port); + rpc_port_parcel_read(parcel, &fill_response_cb->parcelable, fill_response_cb); + + int ret = context->callback.Register(context, auth_info_cb, fill_response_cb, context->user_data); + do { + rpc_port_parcel_h result; + + rpc_port_parcel_create(&result); + rpc_port_parcel_write_int32(result, AutofillAppPort_METHOD_Result); + rpc_port_parcel_write_int32(result, ret); + rpc_port_parcel_send(result, port); + rpc_port_parcel_destroy(result); + } while (0); + + rpc_port_AutofillAppPort_autofill_auth_info_cb_destroy(auth_info_cb); + rpc_port_AutofillAppPort_autofill_fill_response_cb_destroy(fill_response_cb); + return 0; +} + +static int __AutofillAppPort_method_Unregister(rpc_port_h port, rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_AutofillAppPort_context_h context = data; + rpc_port_h callback_port; + int r; + + r = rpc_port_stub_get_port(__AutofillAppPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); + if (r != 0) { + _E("Failed to get callback port"); + return -1; + } + + context->callback.Unregister(context, context->user_data); + + return 0; +} + +static int __AutofillAppPort_method_request_auth_info(rpc_port_h port, rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_AutofillAppPort_context_h context = data; + rpc_port_h callback_port; + int r; + + r = rpc_port_stub_get_port(__AutofillAppPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); + if (r != 0) { + _E("Failed to get callback port"); + return -1; + } + + rpc_port_autofill_view_info_h vi = NULL; + + rpc_port_autofill_view_info_create(&vi); + rpc_port_parcel_read(parcel, &vi->parcelable, vi); + + context->callback.request_auth_info(context, vi, context->user_data); + + rpc_port_autofill_view_info_destroy(vi); + return 0; +} + +static int __AutofillAppPort_method_send_fill_request(rpc_port_h port, rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_AutofillAppPort_context_h context = data; + rpc_port_h callback_port; + int r; + + r = rpc_port_stub_get_port(__AutofillAppPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); + if (r != 0) { + _E("Failed to get callback port"); + return -1; + } + + rpc_port_autofill_view_info_h vi = NULL; + + rpc_port_autofill_view_info_create(&vi); + rpc_port_parcel_read(parcel, &vi->parcelable, vi); + + context->callback.send_fill_request(context, vi, context->user_data); + + rpc_port_autofill_view_info_destroy(vi); + return 0; +} + +static stub_method __AutofillAppPort_method_table[] = { + [AutofillAppPort_METHOD_Register] = __AutofillAppPort_method_Register, + [AutofillAppPort_METHOD_Unregister] = __AutofillAppPort_method_Unregister, + [AutofillAppPort_METHOD_request_auth_info] = __AutofillAppPort_method_request_auth_info, + [AutofillAppPort_METHOD_send_fill_request] = __AutofillAppPort_method_send_fill_request, +}; + +static void __AutofillAppPort_on_connected(const char *sender, const char *instance, void *data) +{ + rpc_port_stub_AutofillAppPort_context_h context; + + _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); + context = __create_AutofillAppPort_context(sender, instance); + if (!context) + return; + + if (context->callback.create) + context->callback.create(context, context->user_data); + __AutofillAppPort_contexts = g_list_append(__AutofillAppPort_contexts, context); +} + +static void __AutofillAppPort_on_disconnected(const char *sender, const char *instance, void *data) +{ + rpc_port_stub_AutofillAppPort_context_h context; + + _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); + context = __find_AutofillAppPort_context(instance); + if (!context) + return; + + if (context->callback.terminate) + context->callback.terminate(context, context->user_data); + __AutofillAppPort_contexts = g_list_remove(__AutofillAppPort_contexts, context); + __destroy_AutofillAppPort_context(context); +} + +static int __AutofillAppPort_on_received(const char *sender, const char *instance, rpc_port_h port, void *data) +{ + rpc_port_stub_AutofillAppPort_context_h context; + rpc_port_parcel_h parcel; + int cmd = -1; + int r; + + _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); + context = __find_AutofillAppPort_context(instance); + if (!context) { + _E("Failed to find AutofillAppPort context(%s)", instance); + return -1; + } + + context->port = port; + r = rpc_port_parcel_create_from_port(&parcel, port); + if (r != 0) { + _E("Failed to create parcel from port"); + return r; + } + + rpc_port_parcel_read_int32(parcel, &cmd); + if (cmd > 1 && cmd < (sizeof(__AutofillAppPort_method_table) / sizeof(__AutofillAppPort_method_table[0]))) { + if (__AutofillAppPort_method_table[cmd]) + r = __AutofillAppPort_method_table[cmd](port, parcel, context); + } else { + _E("Unknown Command(%d)", cmd); + r = -1; + } + + rpc_port_parcel_destroy(parcel); + + return r; +} + +static int __AutofillAppPort_add_privileges(void) +{ + + return 0; +} + +int rpc_port_stub_AutofillAppPort_register(rpc_port_stub_AutofillAppPort_callback_s *callback, void *user_data) +{ + int r; + + if (__AutofillAppPort_stub) { + _W("Already exists"); + return -1; + } + + if (!callback) { + _E("Invalid parameter"); + return -1; + } + + __AutofillAppPort_callback = *callback; + __AutofillAppPort_user_data = user_data; + r = rpc_port_stub_create(&__AutofillAppPort_stub, "AutofillAppPort"); + if (r != 0) { + _E("Failed to create stub handle"); + return r; + } + + r = rpc_port_stub_add_received_event_cb(__AutofillAppPort_stub, __AutofillAppPort_on_received, NULL); + if (r != 0) { + _E("Failed to add received event callback"); + rpc_port_stub_destroy(__AutofillAppPort_stub); + __AutofillAppPort_stub = NULL; + return r; + } + + r = rpc_port_stub_add_connected_event_cb(__AutofillAppPort_stub, __AutofillAppPort_on_connected, NULL); + if (r != 0) { + _E("Failed to add connected event callback"); + rpc_port_stub_destroy(__AutofillAppPort_stub); + __AutofillAppPort_stub = NULL; + return r; + } + + r = rpc_port_stub_add_disconnected_event_cb(__AutofillAppPort_stub, __AutofillAppPort_on_disconnected, NULL); + if (r != 0) { + _E("Failed to add disconnected event callback"); + rpc_port_stub_destroy(__AutofillAppPort_stub); + __AutofillAppPort_stub = NULL; + return r; + } + + r = __AutofillAppPort_add_privileges(); + if (r != 0) { + _E("Failed to add privileges"); + rpc_port_stub_destroy(__AutofillAppPort_stub); + __AutofillAppPort_stub = NULL; + return r; + } + + r = rpc_port_stub_listen(__AutofillAppPort_stub); + if (r != 0) { + _E("Failed to listen stub"); + rpc_port_stub_destroy(__AutofillAppPort_stub); + __AutofillAppPort_stub = NULL; + return r; + } + + return 0; +} + +int rpc_port_stub_AutofillAppPort_unregister(void) +{ + int r; + + if (!__AutofillAppPort_stub) + return -1; + + if (__AutofillAppPort_contexts) { + g_list_free_full(__AutofillAppPort_contexts, __destroy_AutofillAppPort_context); + __AutofillAppPort_contexts = NULL; + } + + r = rpc_port_stub_destroy(__AutofillAppPort_stub); + __AutofillAppPort_stub = NULL; + + return r; +} + +int rpc_port_stub_AutofillAppPort_get_client_number(unsigned int *n) +{ + if (!n) { + _E("Invalid parameter"); + return -1; + } + + if (!__AutofillAppPort_stub) { + _E("AutofillAppPort Stub is not ready"); + return -1; + } + + *n = g_list_length(__AutofillAppPort_contexts); + + return 0; +} diff --git a/server/autofill_stub.h b/server/autofill_stub.h new file mode 100644 index 0000000..d5cc5c4 --- /dev/null +++ b/server/autofill_stub.h @@ -0,0 +1,222 @@ +/* + * Generated by tidlc 1.3.1. + * + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct autofill_item_s *rpc_port_autofill_item_h; + +int rpc_port_autofill_item_create(rpc_port_autofill_item_h *h); + +int rpc_port_autofill_item_destroy(rpc_port_autofill_item_h h); + +int rpc_port_autofill_item_clone(rpc_port_autofill_item_h h, rpc_port_autofill_item_h *clone); + +int rpc_port_autofill_item_set_id(rpc_port_autofill_item_h h, const char *id); + +int rpc_port_autofill_item_set_label(rpc_port_autofill_item_h h, const char *label); + +int rpc_port_autofill_item_set_value(rpc_port_autofill_item_h h, const char *value); + +int rpc_port_autofill_item_set_autofill_hint(rpc_port_autofill_item_h h, int autofill_hint); + +int rpc_port_autofill_item_set_is_sensitive_data(rpc_port_autofill_item_h h, bool is_sensitive_data); + +int rpc_port_autofill_item_get_id(rpc_port_autofill_item_h h, char **id); + +int rpc_port_autofill_item_get_label(rpc_port_autofill_item_h h, char **label); + +int rpc_port_autofill_item_get_value(rpc_port_autofill_item_h h, char **value); + +int rpc_port_autofill_item_get_autofill_hint(rpc_port_autofill_item_h h, int *autofill_hint); + +int rpc_port_autofill_item_get_is_sensitive_data(rpc_port_autofill_item_h h, bool *is_sensitive_data); + +typedef struct autofill_view_info_s *rpc_port_autofill_view_info_h; + +int rpc_port_autofill_view_info_create(rpc_port_autofill_view_info_h *h); + +int rpc_port_autofill_view_info_destroy(rpc_port_autofill_view_info_h h); + +int rpc_port_autofill_view_info_clone(rpc_port_autofill_view_info_h h, rpc_port_autofill_view_info_h *clone); + +int rpc_port_autofill_view_info_set_view_id(rpc_port_autofill_view_info_h h, const char *view_id); + +int rpc_port_autofill_view_info_add_items(rpc_port_autofill_view_info_h h, rpc_port_autofill_item_h items); + +int rpc_port_autofill_view_info_get_view_id(rpc_port_autofill_view_info_h h, char **view_id); + +int rpc_port_autofill_view_info_foreach_items(rpc_port_autofill_view_info_h h, + bool (*callback)(rpc_port_autofill_item_h items, void *user_data), void *user_data); + +int rpc_port_autofill_view_info_remove_items(rpc_port_autofill_view_info_h h, unsigned int nth); + +int rpc_port_autofill_view_info_get_items_length(rpc_port_autofill_view_info_h h, unsigned int *length); + +typedef struct autofill_auth_info_s *rpc_port_autofill_auth_info_h; + +int rpc_port_autofill_auth_info_create(rpc_port_autofill_auth_info_h *h); + +int rpc_port_autofill_auth_info_destroy(rpc_port_autofill_auth_info_h h); + +int rpc_port_autofill_auth_info_clone(rpc_port_autofill_auth_info_h h, rpc_port_autofill_auth_info_h *clone); + +int rpc_port_autofill_auth_info_set_exist_autofill_data(rpc_port_autofill_auth_info_h h, bool exist_autofill_data); + +int rpc_port_autofill_auth_info_set_need_authentication(rpc_port_autofill_auth_info_h h, bool need_authentication); + +int rpc_port_autofill_auth_info_set_service_name(rpc_port_autofill_auth_info_h h, const char *service_name); + +int rpc_port_autofill_auth_info_set_service_logo_image_path(rpc_port_autofill_auth_info_h h, const char *service_logo_image_path); + +int rpc_port_autofill_auth_info_set_service_message(rpc_port_autofill_auth_info_h h, const char *service_message); + +int rpc_port_autofill_auth_info_get_exist_autofill_data(rpc_port_autofill_auth_info_h h, bool *exist_autofill_data); + +int rpc_port_autofill_auth_info_get_need_authentication(rpc_port_autofill_auth_info_h h, bool *need_authentication); + +int rpc_port_autofill_auth_info_get_service_name(rpc_port_autofill_auth_info_h h, char **service_name); + +int rpc_port_autofill_auth_info_get_service_logo_image_path(rpc_port_autofill_auth_info_h h, char **service_logo_image_path); + +int rpc_port_autofill_auth_info_get_service_message(rpc_port_autofill_auth_info_h h, char **service_message); + +typedef struct autofill_response_item_s *rpc_port_autofill_response_item_h; + +int rpc_port_autofill_response_item_create(rpc_port_autofill_response_item_h *h); + +int rpc_port_autofill_response_item_destroy(rpc_port_autofill_response_item_h h); + +int rpc_port_autofill_response_item_clone(rpc_port_autofill_response_item_h h, rpc_port_autofill_response_item_h *clone); + +int rpc_port_autofill_response_item_set_id(rpc_port_autofill_response_item_h h, const char *id); + +int rpc_port_autofill_response_item_set_presentation_text(rpc_port_autofill_response_item_h h, const char *presentation_text); + +int rpc_port_autofill_response_item_set_value(rpc_port_autofill_response_item_h h, const char *value); + +int rpc_port_autofill_response_item_get_id(rpc_port_autofill_response_item_h h, char **id); + +int rpc_port_autofill_response_item_get_presentation_text(rpc_port_autofill_response_item_h h, char **presentation_text); + +int rpc_port_autofill_response_item_get_value(rpc_port_autofill_response_item_h h, char **value); + +typedef struct autofill_fill_response_s *rpc_port_autofill_fill_response_h; + +int rpc_port_autofill_fill_response_create(rpc_port_autofill_fill_response_h *h); + +int rpc_port_autofill_fill_response_destroy(rpc_port_autofill_fill_response_h h); + +int rpc_port_autofill_fill_response_clone(rpc_port_autofill_fill_response_h h, rpc_port_autofill_fill_response_h *clone); + +int rpc_port_autofill_fill_response_set_view_id(rpc_port_autofill_fill_response_h h, const char *view_id); + +int rpc_port_autofill_fill_response_add_response_items(rpc_port_autofill_fill_response_h h, rpc_port_autofill_response_item_h response_items); + +int rpc_port_autofill_fill_response_get_view_id(rpc_port_autofill_fill_response_h h, char **view_id); + +int rpc_port_autofill_fill_response_foreach_response_items(rpc_port_autofill_fill_response_h h, + bool (*callback)(rpc_port_autofill_response_item_h response_items, void *user_data), void *user_data); + +int rpc_port_autofill_fill_response_remove_response_items(rpc_port_autofill_fill_response_h h, unsigned int nth); + +int rpc_port_autofill_fill_response_get_response_items_length(rpc_port_autofill_fill_response_h h, unsigned int *length); + +typedef struct list_autofill_item_s *rpc_port_list_autofill_item_h; + +int rpc_port_list_autofill_item_create(rpc_port_list_autofill_item_h *h); + +int rpc_port_list_autofill_item_destroy(rpc_port_list_autofill_item_h h); + +int rpc_port_list_autofill_item_clone(rpc_port_list_autofill_item_h h, rpc_port_list_autofill_item_h *clone); + +int rpc_port_list_autofill_item_add_list_autofill_items(rpc_port_list_autofill_item_h h, rpc_port_autofill_item_h list_autofill_items); + +int rpc_port_list_autofill_item_foreach_list_autofill_items(rpc_port_list_autofill_item_h h, + bool (*callback)(rpc_port_autofill_item_h list_autofill_items, void *user_data), void *user_data); + +int rpc_port_list_autofill_item_remove_list_autofill_items(rpc_port_list_autofill_item_h h, unsigned int nth); + +int rpc_port_list_autofill_item_get_list_autofill_items_length(rpc_port_list_autofill_item_h h, unsigned int *length); + +typedef struct list_autofill_response_item_s *rpc_port_list_autofill_response_item_h; + +int rpc_port_list_autofill_response_item_create(rpc_port_list_autofill_response_item_h *h); + +int rpc_port_list_autofill_response_item_destroy(rpc_port_list_autofill_response_item_h h); + +int rpc_port_list_autofill_response_item_clone(rpc_port_list_autofill_response_item_h h, rpc_port_list_autofill_response_item_h *clone); + +int rpc_port_list_autofill_response_item_add_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, rpc_port_autofill_response_item_h list_autofill_response_items); + +int rpc_port_list_autofill_response_item_foreach_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, + bool (*callback)(rpc_port_autofill_response_item_h list_autofill_response_items, void *user_data), void *user_data); + +int rpc_port_list_autofill_response_item_remove_list_autofill_response_items(rpc_port_list_autofill_response_item_h h, unsigned int nth); + +int rpc_port_list_autofill_response_item_get_list_autofill_response_items_length(rpc_port_list_autofill_response_item_h h, unsigned int *length); + +typedef struct AutofillAppPort_context_s* rpc_port_stub_AutofillAppPort_context_h; + +int rpc_port_stub_AutofillAppPort_context_set_tag(rpc_port_stub_AutofillAppPort_context_h ctx, void *tag); + +int rpc_port_stub_AutofillAppPort_context_get_tag(rpc_port_stub_AutofillAppPort_context_h ctx, void **tag); + +int rpc_port_stub_AutofillAppPort_context_get_sender(rpc_port_stub_AutofillAppPort_context_h ctx, char **sender); + +typedef struct AutofillAppPort_autofill_auth_info_cb_s *rpc_port_AutofillAppPort_autofill_auth_info_cb_h; + +int rpc_port_AutofillAppPort_autofill_auth_info_cb_destroy(rpc_port_AutofillAppPort_autofill_auth_info_cb_h h); + +int rpc_port_AutofillAppPort_autofill_auth_info_cb_clone(rpc_port_AutofillAppPort_autofill_auth_info_cb_h h, rpc_port_AutofillAppPort_autofill_auth_info_cb_h *clone); + +int rpc_port_AutofillAppPort_autofill_auth_info_cb_invoke(rpc_port_AutofillAppPort_autofill_auth_info_cb_h h, rpc_port_autofill_auth_info_h auth_info); + +typedef struct AutofillAppPort_autofill_fill_response_cb_s *rpc_port_AutofillAppPort_autofill_fill_response_cb_h; + +int rpc_port_AutofillAppPort_autofill_fill_response_cb_destroy(rpc_port_AutofillAppPort_autofill_fill_response_cb_h h); + +int rpc_port_AutofillAppPort_autofill_fill_response_cb_clone(rpc_port_AutofillAppPort_autofill_fill_response_cb_h h, rpc_port_AutofillAppPort_autofill_fill_response_cb_h *clone); + +int rpc_port_AutofillAppPort_autofill_fill_response_cb_invoke(rpc_port_AutofillAppPort_autofill_fill_response_cb_h h, rpc_port_autofill_fill_response_h response); + +typedef struct { + void (*create)(rpc_port_stub_AutofillAppPort_context_h context, void *user_data); + void (*terminate)(rpc_port_stub_AutofillAppPort_context_h context, void *user_data); + + int (*Register)(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_AutofillAppPort_autofill_auth_info_cb_h auth_info_cb, rpc_port_AutofillAppPort_autofill_fill_response_cb_h fill_response_cb, void *user_data); + void (*Unregister)(rpc_port_stub_AutofillAppPort_context_h context, void *user_data); + void (*request_auth_info)(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data); + void (*send_fill_request)(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data); +} rpc_port_stub_AutofillAppPort_callback_s; + +int rpc_port_stub_AutofillAppPort_register(rpc_port_stub_AutofillAppPort_callback_s *callback, void *user_data); + +int rpc_port_stub_AutofillAppPort_unregister(void); + +int rpc_port_stub_AutofillAppPort_get_client_number(unsigned int *n); + +#ifdef __cplusplus +} +#endif diff --git a/server/main.c b/server/main.c new file mode 100644 index 0000000..e131a50 --- /dev/null +++ b/server/main.c @@ -0,0 +1,575 @@ + /* + * 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 +#include +#include +#include +#include +#include + +#include "autofill_stub.h" +#include "autofill_service_proxy.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILL_DAEMON" + +#define AUTOFILL_SERVICE_APP_ID "org.tizen.autofill-service" + +static rpc_port_proxy_AutofillSvcPort_h rpc_h = NULL; + +typedef struct { + char *app_id; + + rpc_port_AutofillAppPort_autofill_auth_info_cb_h auth_info_cb; + rpc_port_AutofillAppPort_autofill_fill_response_cb_h fill_response_cb; +} autofill_client_s; + +static GList *__client_list = NULL; + +static autofill_client_s * +get_autofill_client(const char *app_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 (strcmp(client->app_id, app_id) == 0) { + return client; + } + } + + return NULL; +} + +static autofill_client_s *__create_client(const char *app_id, + rpc_port_AutofillAppPort_autofill_auth_info_cb_h auth_info_cb, + rpc_port_AutofillAppPort_autofill_fill_response_cb_h fill_response_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; + } + + rpc_port_AutofillAppPort_autofill_auth_info_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_cb_clone(fill_response_cb, &handle->fill_response_cb); + + if (!handle->fill_response_cb) { + LOGE("Out of memory"); + free(handle->app_id); + rpc_port_AutofillAppPort_autofill_auth_info_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_cb_destroy(handle->auth_info_cb); + + if (handle->fill_response_cb) + rpc_port_AutofillAppPort_autofill_fill_response_cb_destroy(handle->fill_response_cb); + + if (handle->app_id) + free(handle->app_id); + + free(handle); +} + +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("[__RPC_PORT__] 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); +} + +static int __message_register(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_AutofillAppPort_autofill_auth_info_cb_h auth_info_cb, rpc_port_AutofillAppPort_autofill_fill_response_cb_h fill_response_cb, void *user_data) +{ + LOGD(""); + char *sender = NULL; + + rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender); + if (!sender) + return -1; + + LOGD("sender(%s)", sender); + + autofill_client_s *client; + client = __create_client(sender, auth_info_cb, fill_response_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, void *user_data) +{ + autofill_client_s *client = NULL; + rpc_port_stub_AutofillAppPort_context_get_tag(context, (void *)&client); + if (client == NULL) + 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); +} + +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; +} + +static void __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data) +{ + char *sender = NULL; + autofill_client_s *sender_client; + + 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(rpc_h, svi); + + if (sender) { + free(sender); + } + + if (view_id) { + free(view_id); + } + + rpc_port_autofill_svc_view_info_destroy(svi); + +} + +static void __autofill_fill_request_cb(rpc_port_stub_AutofillAppPort_context_h context, rpc_port_autofill_view_info_h vi, void *user_data) +{ + char *sender = NULL; + char *view_id = NULL; + + 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); + + 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(rpc_h, svi); + + if (sender) + free(sender); + + if (view_id) + free(view_id); + + rpc_port_autofill_svc_view_info_destroy(svi); +} + +bool fill_response_item_cb(rpc_port_autofill_svc_response_item_h response_items, void *user_data) +{ + //autofill_fill_response_s *fill_response = (autofill_fill_response_s *)user_data; + + rpc_port_autofill_fill_response_h svi = (rpc_port_autofill_fill_response_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_fill_response_add_response_items(svi, 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; +} + +static void __fill_response_recv_cb(void *user_data, 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_items(response_h, fill_response_item_cb, fill_response_h); + + autofill_client_s *sender_client = get_autofill_client(app_id); + if (sender_client) + rpc_port_AutofillAppPort_autofill_fill_response_cb_invoke(sender_client->fill_response_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, 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; + + rpc_port_autofill_svc_auth_info_get_app_id(svc_auth_info_h, &app_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_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); + if (sender_client) + rpc_port_AutofillAppPort_autofill_auth_info_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 (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_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_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"); + + rpc_h = NULL; +} + +static void __on_rejected(rpc_port_proxy_AutofillSvcPort_h h, void *user_data) +{ + LOGD("rejected"); +} +//LCOV_EXCL_STOP + +static int connect_service() +{ + int ret; + + rpc_port_proxy_AutofillSvcPort_callback_s rpc_callback = { + .connected = __on_connected, + .disconnected = __on_disconnected, + .rejected = __on_rejected + }; + + if (rpc_h) { + LOGI("already connected\n"); + return RPC_PORT_ERROR_NONE; + } + + ret = rpc_port_proxy_AutofillSvcPort_create(AUTOFILL_SERVICE_APP_ID, &rpc_callback, NULL, &rpc_h); + if (ret != RPC_PORT_ERROR_NONE) { + LOGW("Failed to create rpc port. err = %d", ret); + return false; + } + + ret = rpc_port_proxy_AutofillSvcPort_connect(rpc_h); + + return ret; + +} + +bool service_app_create(void *data) +{ + // Todo: add your code here. + LOGD(""); + + int ret; + rpc_port_stub_AutofillAppPort_callback_s callback = { + __message_create, + __message_terminate, + __message_register, + __message_unregister, + __auth_info_request_cb, + __autofill_fill_request_cb + }; + + ret = rpc_port_stub_AutofillAppPort_register(&callback, NULL); + if (ret != 0) + LOGI("Failed to register message"); + else + LOGI("Succeeded to register message"); + + rpc_port_stub_AutofillAppPort_register(&callback, NULL); + + 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); + } + + 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); +} diff --git a/server/org.tizen.autofill-daemon.manifest b/server/org.tizen.autofill-daemon.manifest new file mode 100644 index 0000000..017d22d --- /dev/null +++ b/server/org.tizen.autofill-daemon.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/server/org.tizen.autofill-daemon.xml b/server/org.tizen.autofill-daemon.xml new file mode 100644 index 0000000..fd959f2 --- /dev/null +++ b/server/org.tizen.autofill-daemon.xml @@ -0,0 +1,14 @@ + + + + Jihoon Kim + autofill-daemon + + + + + + http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/datasharing + + diff --git a/service/CMakeLists.txt b/service/CMakeLists.txt new file mode 100644 index 0000000..ed867d1 --- /dev/null +++ b/service/CMakeLists.txt @@ -0,0 +1,41 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(autofill-service C) + +SET(SRCS + service_main.c +# autofill_stub.c +) + +pkg_check_modules(pkgs_service REQUIRED + capi-base-common + dlog + ecore + eina + capi-appfw-service-application + rpc-port + glib-2.0 +) + +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include) + +FOREACH(flag ${pkgs_service_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +FIND_PROGRAM(UNAME NAMES uname) +EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") + MESSAGE("add -DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_service_LDFLAGS} capi-ui-autofill-service) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${TZ_SYS_RO_APP}/org.tizen.${PROJECT_NAME}/bin/) +INSTALL(FILES ${CMAKE_BINARY_DIR}/service/org.tizen.${PROJECT_NAME}.xml DESTINATION ${TZ_SYS_RO_PACKAGES}) +#INSTALL(FILES ${CMAKE_BINARY_DIR}/service/autofill-service.manifest DESTINATION ${TZ_SYS_RO_PACKAGES}) diff --git a/service/org.tizen.autofill-service.manifest b/service/org.tizen.autofill-service.manifest new file mode 100644 index 0000000..017d22d --- /dev/null +++ b/service/org.tizen.autofill-service.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/service/org.tizen.autofill-service.xml b/service/org.tizen.autofill-service.xml new file mode 100644 index 0000000..70aba8b --- /dev/null +++ b/service/org.tizen.autofill-service.xml @@ -0,0 +1,14 @@ + + + + Jihoon Kim + autofill-service + + + + + + http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/datasharing + + diff --git a/service/service_main.c b/service/service_main.c new file mode 100644 index 0000000..038cae2 --- /dev/null +++ b/service/service_main.c @@ -0,0 +1,221 @@ + /* + * 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 +#include +#include +#include +#include +#include "autofill_service.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILL_SERVICE_TEST" + +static bool __view_info_item_cb(autofill_item_h items, void *user_data) +{ + char *id = NULL; + char *label = NULL; + char *value = NULL; + autofill_hint_e autofill_hint; + bool sensitive_data; + + autofill_item_get_id(items, &id); + if (id) { + LOGD("id : %s", id); + free(id); + } + + autofill_item_get_label(items, &label); + if (label) { + LOGD("label : %s", label); + free(label); + } + + autofill_item_get_value(items, &value); + if (value) { + LOGD("value : %s", value); + free(value); + } + + autofill_item_get_autofill_hint(items, &autofill_hint); + LOGD("autofill hint : %d", autofill_hint); + + autofill_item_get_sensitive_data(items, &sensitive_data); + LOGD("sensitive data : %d", sensitive_data); + + return true; +} + +static void _auth_info_request_cb(autofill_view_info_h vi, void *user_data) +{ + LOGD(""); + + char *view_id = NULL; + char *app_id = NULL; + + autofill_view_info_get_app_id(vi, &app_id); + autofill_view_info_get_view_id(vi, &view_id); + LOGD("app_id : %s, view id : %s", app_id, view_id); + + autofill_view_info_foreach_items(vi, __view_info_item_cb, NULL); + + if (view_id) + free(view_id); + + autofill_auth_info_h auth_info; + autofill_auth_info_create(&auth_info); + autofill_auth_info_set_app_id(auth_info, app_id); + + if (app_id) + free(app_id); + + autofill_auth_info_set_exist_autofill_data(auth_info, true); + autofill_auth_info_set_need_authentication(auth_info, false); + autofill_auth_info_set_service_name(auth_info, "Samsung Pass444"); + autofill_auth_info_set_service_message(auth_info, "Login with Samsung Pass333"); + autofill_auth_info_set_service_logo_image_path(auth_info, "/usr/apps/com.samsung.samsungpass/shared/samsung_pass.png"); + + LOGD("send auth info"); + autofill_service_send_auth_info(auth_info); + + autofill_auth_info_destroy(auth_info); +} + +static void _fill_request_cb(autofill_view_info_h vi, void *user_data) +{ + char *app_id = NULL; + char *view_id = NULL; + + autofill_view_info_get_app_id(vi, &app_id); + autofill_view_info_get_view_id(vi, &view_id); + LOGD("app id : %s, view id : %s", app_id, view_id); + + autofill_fill_response_h fill_response; + autofill_fill_response_create(&fill_response); + autofill_fill_response_set_app_id(fill_response, app_id); + autofill_fill_response_set_view_id(fill_response, view_id); + + if (app_id) + free(app_id); + + if (view_id) + free(view_id); + + autofill_fill_response_item_h ritem_h[2]; + + /* item 1 */ + autofill_fill_response_item_create(&ritem_h[0]); + autofill_fill_response_item_set_id(ritem_h[0], "id"); + autofill_fill_response_item_set_presentation_text(ritem_h[0], "Input ID"); + autofill_fill_response_item_set_value(ritem_h[0], "tester"); + + autofill_fill_response_add_item(fill_response, ritem_h[0]); + + /* item 2 */ + autofill_fill_response_item_create(&ritem_h[1]); + autofill_fill_response_item_set_id(ritem_h[1], "password"); + autofill_fill_response_item_set_presentation_text(ritem_h[1], "Input Password"); + autofill_fill_response_item_set_value(ritem_h[1], "testerpw"); + + autofill_fill_response_add_item(fill_response, ritem_h[1]); + + autofill_service_send_fill_response(fill_response); + + autofill_fill_response_item_destroy(ritem_h[0]); + autofill_fill_response_item_destroy(ritem_h[1]); + + autofill_fill_response_destroy(fill_response); +} + +bool service_app_create(void *data) +{ + // Todo: add your code here. + LOGD(""); + + autofill_service_initialize(); + + autofill_service_set_auth_info_request_cb(_auth_info_request_cb, NULL); + autofill_service_set_fill_request_cb(_fill_request_cb, NULL); + + return true; +} + +void service_app_terminate(void *data) +{ + // Todo: add your code here. + LOGD(""); + + autofill_service_deinitialize(); + + 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); +} + diff --git a/service_lib/CMakeLists.txt b/service_lib/CMakeLists.txt new file mode 100644 index 0000000..11604da --- /dev/null +++ b/service_lib/CMakeLists.txt @@ -0,0 +1,106 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET(project_prefix "capi") +SET(prefix "/usr") +SET(version "0.0.1") +SET(maintainer "Jihoon Kim ") +SET(description "Autofill Service APIs") +SET(service "ui") +SET(submodule "autofill-service") +SET(dependents "dlog eina capi-appfw-application glib-2.0 rpc-port") +SET(LIBDIR ${LIB_INSTALL_DIR}) + +SET(Services + "application" + "base" + "content" + "location" + "media" + "messaging" + "network" + "social" + "telephony" + "system" + "ui" + ) + +#FILE(STRINGS config.cfg configs REGEX "^ *[^#]") +FOREACH(lines ${configs}) +# MESSAGE(${lines}) + IF(${lines} MATCHES "([^=]*)=['\"](.*)['\"]") + SET(key ${CMAKE_MATCH_1}) + SET(value ${CMAKE_MATCH_2}) +# MESSAGE("${key} -> ${value}") + SET(${key} "${value}") + ENDIF() +ENDFOREACH(lines ${configs}) + +LIST(FIND Services ${service} sfind) + +IF( ${sfind} EQUAL -1 ) + MESSAGE(FATAL_ERROR "Service must be one of ") + FOREACH( s IN ${Services} ) + MESSAGE(FATAL_ERROR "[${s}]") + ENDFOREACH( s IN ${Services} ) +ENDIF( ${sfind} EQUAL -1 ) + +SET(fw_name "${project_prefix}-${service}-${submodule}") + +PROJECT(${fw_name} C) + +SET(CMAKE_INSTALL_PREFIX ${prefix}) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(VERSION ${version}) + +SET(INC_DIR ../include .) +INCLUDE_DIRECTORIES(${INC_DIR}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_name} REQUIRED ${dependents}) +FOREACH(flag ${${fw_name}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -fpermissive") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") + +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DTIZEN_DEBUG") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") + +aux_source_directory(. SOURCES) +ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) + +TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS} capi-ui-autofill-common) + +SET_TARGET_PROPERTIES(${fw_name} + PROPERTIES + VERSION ${FULLVER} + SOVERSION ${MAJORVER} + CLEAN_DIRECT_OUTPUT 1 +) + +INSTALL(TARGETS ${fw_name} DESTINATION ${LIBDIR}) +INSTALL( + DIRECTORY ${INC_DIR}/ DESTINATION include + FILES_MATCHING + PATTERN "*_private.h" EXCLUDE + PATTERN "${INC_DIR}/*.h" + ) + +SET(PC_NAME ${fw_name}) +SET(PC_REQUIRED ${dependents}) +SET(PC_LDFLAGS -l${fw_name}) + +CONFIGURE_FILE( + capi-ui-autofill-service.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc + @ONLY +) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIBDIR}/pkgconfig) diff --git a/service_lib/autofill_service.c b/service_lib/autofill_service.c new file mode 100644 index 0000000..3d9e8de --- /dev/null +++ b/service_lib/autofill_service.c @@ -0,0 +1,473 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include + +#include "autofill_service.h" +#include "autofill_private.h" +#include "autofill_service_stub.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILL_SERVICE" + +static autofill_service_fill_request_cb g_autofill_service_fill_request_cb; +static void *g_autofill_service_fill_request_data = NULL; + +static autofill_service_auth_info_request_cb g_autofill_service_auth_info_request_cb; +static void *g_autofill_service_auth_info_request_data = NULL; + +rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h g_auth_info_cb; +rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h g_fill_response_cb; + +typedef struct { + char *app_id; + + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb; + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_cb; +} autofill_svc_s; + +static GList *__client_list = NULL; + +bool __autofill_item_cb(rpc_port_autofill_svc_item_h items, void *user_data) +{ + char *id = NULL; + char *label = NULL; + char *value = NULL; + int autofill_hint; + bool sensitive_data; + + autofill_view_info_h vi = (autofill_view_info_h)user_data; + + autofill_item_h ai; + autofill_item_create(&ai); + + rpc_port_autofill_svc_item_get_id(items, &id); + autofill_item_set_id(ai, id); + if (id) { + LOGD("id : %s", id); + free(id); + } + + rpc_port_autofill_svc_item_get_label(items, &label); + autofill_item_set_label(ai, label); + if (label) { + LOGD("label : %s", label); + free(label); + } + + rpc_port_autofill_svc_item_get_value(items, &value); + autofill_item_set_value(ai, value); + if (value) { + LOGD("value : %s", value); + free(value); + } + + rpc_port_autofill_svc_item_get_autofill_hint(items, &autofill_hint); + autofill_item_set_autofill_hint(ai, autofill_hint); + LOGD("autofill hint : %d", autofill_hint); + + rpc_port_autofill_svc_item_get_is_sensitive_data(items, &sensitive_data); + autofill_item_set_sensitive_data(ai, sensitive_data); + LOGD("sensitive data : %d", sensitive_data); + + autofill_view_info_add_item(vi, ai); + + autofill_item_destroy(ai); + + 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) +{ + char *sender = NULL; + + rpc_port_stub_AutofillSvcPort_context_get_sender(context, &sender); + if (sender) { + LOGD("sender(%s)", sender); + free(sender); + } + + char *app_id = NULL; + char *view_id = NULL; + rpc_port_autofill_svc_view_info_get_app_id(vi, &app_id); + rpc_port_autofill_svc_view_info_get_view_id(vi, &view_id); + LOGD("app id : %s, view id : %s", app_id, view_id); + + autofill_view_info_h view_info; + autofill_view_info_create(&view_info); + autofill_view_info_set_app_id(view_info, app_id); + autofill_view_info_set_view_id(view_info, view_id); + + rpc_port_autofill_svc_view_info_foreach_items(vi, __autofill_item_cb, view_info); + + if (g_autofill_service_auth_info_request_cb) + g_autofill_service_auth_info_request_cb(view_info, g_autofill_service_auth_info_request_data); + + autofill_view_info_destroy(view_info); + + if (view_id) + free(view_id); + + if (app_id) + 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) +{ + char *app_id = NULL; + char *view_id = NULL; + + rpc_port_autofill_svc_view_info_get_app_id(vi, &app_id); + rpc_port_autofill_svc_view_info_get_view_id(vi, &view_id); + + LOGD("app id ; %s, view id : %s", app_id, view_id); + + autofill_view_info_h view_info; + autofill_view_info_create(&view_info); + autofill_view_info_set_app_id(view_info, app_id); + autofill_view_info_set_view_id(view_info, view_id); + + rpc_port_autofill_svc_view_info_foreach_items(vi, __autofill_item_cb, view_info); + + if (g_autofill_service_fill_request_cb) + g_autofill_service_fill_request_cb(view_info, g_autofill_service_auth_info_request_data); + + autofill_view_info_destroy(view_info); + + if (app_id) + free(app_id); + + if (view_id) + free(view_id); +} + +static autofill_svc_s *__create_client(const char *app_id, + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb, + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_cb) +{ + LOGD(""); + autofill_svc_s *handle; + + handle = calloc(1, sizeof(autofill_svc_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; + } + + rpc_port_AutofillSvcPort_autofill_svc_auth_info_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_AutofillSvcPort_autofill_svc_fill_response_cb_clone(fill_response_cb, &handle->fill_response_cb); + + if (!handle->fill_response_cb) { + LOGE("Out of memory"); + free(handle->app_id); + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_destroy(handle->auth_info_cb); + free(handle); + return NULL; + } + + return handle; +} + +static void __destroy_client(gpointer data) +{ + LOGD(""); + autofill_svc_s *handle = data; + + if (!handle) + return; + + if (handle->auth_info_cb) + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_destroy(handle->auth_info_cb); + + if (handle->fill_response_cb) + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_destroy(handle->fill_response_cb); + + if (handle->app_id) + free(handle->app_id); + + free(handle); +} + +static void __message_create(rpc_port_stub_AutofillSvcPort_context_h context, + void *user_data) +{ + LOGD(""); + char *sender = NULL; + + rpc_port_stub_AutofillSvcPort_context_get_sender(context, &sender); + if (!sender) + return; + + LOGD("sender(%s)", sender); + free(sender); +} + +static void __message_terminate(rpc_port_stub_AutofillSvcPort_context_h context, + void *user_data) +{ + LOGD(""); + char *sender = NULL; + + rpc_port_stub_AutofillSvcPort_context_get_sender(context, &sender); + if (!sender) + return; + + LOGD("sender(%s)", sender); + free(sender); +} + +static int __message_register(rpc_port_stub_AutofillSvcPort_context_h context, rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb, rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_cb, void *user_data) +{ + LOGD(""); + char *sender = NULL; + + rpc_port_stub_AutofillSvcPort_context_get_sender(context, &sender); + if (!sender) + return -1; + + LOGD("sender(%s)", sender); + + autofill_svc_s *client; + client = __create_client(sender, auth_info_cb, fill_response_cb); + free(sender); + + if (!client) + return -1; + + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_clone(auth_info_cb, &g_auth_info_cb); + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_clone(fill_response_cb, &g_fill_response_cb); + + LOGD("auth info : %p, fill response : %p", g_auth_info_cb, g_fill_response_cb); + + __client_list = g_list_append(__client_list, client); + + rpc_port_stub_AutofillSvcPort_context_set_tag(context, client); + + return 0; +} + +static void __message_unregister(rpc_port_stub_AutofillSvcPort_context_h context, void *user_data) +{ + autofill_svc_s *client = NULL; + rpc_port_stub_AutofillSvcPort_context_get_tag(context, (void *)&client); + if (client == NULL) + return; + + rpc_port_stub_AutofillSvcPort_context_set_tag(context, NULL); + LOGI("name(%s)", client->app_id); + + __client_list = g_list_remove(__client_list, client); + __destroy_client(client); +} + +EXPORT_API int autofill_service_initialize() +{ + LOGD("autofill service initialize"); + + int ret; + + rpc_port_stub_AutofillSvcPort_callback_s callback = { + __message_create, + __message_terminate, + __message_register, + __message_unregister, + __auth_info_request_cb, + __autofill_fill_request_cb, + }; + + ret = rpc_port_stub_AutofillSvcPort_register(&callback, NULL); + if (ret != 0) + LOGI("Failed to register message"); + else + LOGI("Succeeded to register message"); + + return ret; +} + +EXPORT_API int autofill_service_deinitialize() +{ + LOGD("autofill service deinitialize"); + + if (__client_list) { + g_list_free_full(__client_list, __destroy_client); + } + + rpc_port_stub_AutofillSvcPort_unregister(); + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_service_set_auth_info_request_cb(autofill_service_auth_info_request_cb callback, void *user_data) +{ + g_autofill_service_auth_info_request_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) +{ + bool exist_autofill_data; + bool need_authentication; + char *app_id = NULL; + char *service_name = NULL; + char *service_logo_image_path = NULL; + char *service_message = NULL; + + if (!h) { + LOGW("parameter is NULL"); + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + autofill_auth_info_get_app_id(h, &app_id); + autofill_auth_info_get_exist_autofill_data(h, &exist_autofill_data); + autofill_auth_info_get_need_authentication(h, &need_authentication); + autofill_auth_info_get_service_name(h, &service_name); + autofill_auth_info_get_service_message(h, &service_message); + autofill_auth_info_get_service_logo_image_path(h, &service_logo_image_path); + + LOGD("app_id : %s", app_id); + + /* create auth info */ + rpc_port_autofill_svc_auth_info_h auth_info_h; + rpc_port_autofill_svc_auth_info_create(&auth_info_h); + rpc_port_autofill_svc_auth_info_set_app_id(auth_info_h, app_id); + rpc_port_autofill_svc_auth_info_set_exist_autofill_data(auth_info_h, exist_autofill_data); + rpc_port_autofill_svc_auth_info_set_need_authentication(auth_info_h, need_authentication); + rpc_port_autofill_svc_auth_info_set_service_name(auth_info_h, service_name); + 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); + + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_invoke(g_auth_info_cb, auth_info_h); + + if (app_id) + free(app_id); + + if (service_name) + free(service_name); + + if (service_logo_image_path) + free(service_logo_image_path); + + if (service_message) + free(service_message); + + rpc_port_autofill_svc_auth_info_destroy(auth_info_h); + + return AUTOFILL_ERROR_NONE; +} + +// fill request +EXPORT_API int autofill_service_set_fill_request_cb(autofill_service_fill_request_cb callback, void *user_data) +{ + g_autofill_service_fill_request_cb = callback; + g_autofill_service_fill_request_data = user_data; + + return AUTOFILL_ERROR_NONE; +} + +EXPORT_API int autofill_service_send_fill_response(autofill_fill_response_h h) +{ + /* create autofill response */ + rpc_port_autofill_svc_fill_response_h fill_response_h; + char *id = NULL; + char *value = NULL; + char *presentation_text = NULL; + + Eina_List *l; + autofill_fill_response_item_h it; + + if (!h) { + LOGW("parameter is NULL"); + return AUTOFILL_ERROR_INVALID_PARAMETER; + } + + rpc_port_autofill_svc_fill_response_create(&fill_response_h); + + if (h->app_id) + rpc_port_autofill_svc_fill_response_set_app_id(fill_response_h, h->app_id); + + if (h->view_id) + rpc_port_autofill_svc_fill_response_set_view_id(fill_response_h, h->view_id); + + rpc_port_autofill_svc_response_item_h ritem_h; + + int i = 0, count = 0; + EINA_LIST_FOREACH(h->autofill_fill_response_item_list, l, it) + { + autofill_fill_response_item_get_id(it, &id); + autofill_fill_response_item_get_value(it, &value); + autofill_fill_response_item_get_presentation_text(it, &presentation_text); + + LOGD("it : %p, id : %s, value : %s, presentation text : %s", it, id, value, presentation_text); + + rpc_port_autofill_svc_response_item_create(&ritem_h); + rpc_port_autofill_svc_response_item_set_id(ritem_h, id); + rpc_port_autofill_svc_response_item_set_presentation_text(ritem_h, presentation_text); + rpc_port_autofill_svc_response_item_set_value(ritem_h, value); + + rpc_port_autofill_svc_fill_response_add_response_items(fill_response_h, ritem_h); + + if (id) { + free(id); + id = NULL; + } + + if (value) { + free(value); + value = NULL; + } + + if (presentation_text) { + free(presentation_text); + presentation_text= NULL; + } + + rpc_port_autofill_svc_response_item_destroy(ritem_h); + + count++; + i++; + } + + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_invoke(g_fill_response_cb, fill_response_h); + + rpc_port_autofill_svc_fill_response_destroy(fill_response_h); + + return AUTOFILL_ERROR_NONE; +} diff --git a/service_lib/autofill_service_stub.c b/service_lib/autofill_service_stub.c new file mode 100644 index 0000000..17c108f --- /dev/null +++ b/service_lib/autofill_service_stub.c @@ -0,0 +1,2877 @@ +/* + * Generated by tidlc 1.3.1. + * + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "autofill_service_stub.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "RPC_PORT_STUB" + +#ifdef _E +#undef _E +#endif + +#ifdef _W +#undef _W +#endif + +#ifdef _I +#undef _I +#endif + +#ifdef _D +#undef _D +#endif + +#define _E(fmt, ...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _W(fmt, ...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _I(fmt, ...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define _D(fmt, ...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s(%d) > "fmt, basename(__FILE__), __FUNCTION__, __LINE__, ##__VA_ARGS__) + +typedef int (*stub_method)(rpc_port_h, rpc_port_parcel_h, void *data); + +struct autofill_svc_item_s { + rpc_port_parcelable_t parcelable; + char *id; + char *label; + char *value; + int autofill_hint; + bool is_sensitive_data; +}; + +static void __autofill_svc_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->id ? h->id : ""); + rpc_port_parcel_write_string(parcel, h->label ? h->label : ""); + rpc_port_parcel_write_string(parcel, h->value ? h->value : ""); + rpc_port_parcel_write_int32(parcel, h->autofill_hint); + rpc_port_parcel_write_bool(parcel, h->is_sensitive_data); +} + +static void __autofill_svc_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->id); + rpc_port_parcel_read_string(parcel, &h->label); + rpc_port_parcel_read_string(parcel, &h->value); + rpc_port_parcel_read_int32(parcel, &h->autofill_hint); + rpc_port_parcel_read_bool(parcel, &h->is_sensitive_data); +} + +int rpc_port_autofill_svc_item_create(rpc_port_autofill_svc_item_h *h) +{ + struct autofill_svc_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_item_to; + handle->parcelable.from = __autofill_svc_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_item_destroy(rpc_port_autofill_svc_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) + free(h->id); + + if (h->label) + free(h->label); + + if (h->value) + free(h->value); + + free(h); + + return 0; +} + +int rpc_port_autofill_svc_item_clone(rpc_port_autofill_svc_item_h h, rpc_port_autofill_svc_item_h *clone) +{ + rpc_port_autofill_svc_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_item_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_item handle"); + return -1; + } + + if (h->id) { + handle->id = strdup(h->id); + if (!handle->id) { + _E("Failed to duplicate h->id"); + rpc_port_autofill_svc_item_destroy(handle); + return -1; + } + } + + if (h->label) { + handle->label = strdup(h->label); + if (!handle->label) { + _E("Failed to duplicate h->label"); + rpc_port_autofill_svc_item_destroy(handle); + return -1; + } + } + + if (h->value) { + handle->value = strdup(h->value); + if (!handle->value) { + _E("Failed to duplicate h->value"); + rpc_port_autofill_svc_item_destroy(handle); + return -1; + } + } + + handle->autofill_hint = h->autofill_hint; + handle->is_sensitive_data = h->is_sensitive_data; + *clone = handle; + + return 0; +} + +int rpc_port_autofill_svc_item_set_id(rpc_port_autofill_svc_item_h h, const char *id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) { + free(h->id); + h->id = NULL; + } + + h->id = strdup(id); + if (!h->id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_set_label(rpc_port_autofill_svc_item_h h, const char *label) +{ + if (!h || !label) { + _E("Invalid parameter"); + return -1; + } + + if (h->label) { + free(h->label); + h->label = NULL; + } + + h->label = strdup(label); + if (!h->label) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_set_value(rpc_port_autofill_svc_item_h h, const char *value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (h->value) { + free(h->value); + h->value = NULL; + } + + h->value = strdup(value); + if (!h->value) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_set_autofill_hint(rpc_port_autofill_svc_item_h h, int autofill_hint) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->autofill_hint = autofill_hint; + return 0; +} + +int rpc_port_autofill_svc_item_set_is_sensitive_data(rpc_port_autofill_svc_item_h h, bool is_sensitive_data) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->is_sensitive_data = is_sensitive_data; + return 0; +} + +int rpc_port_autofill_svc_item_get_id(rpc_port_autofill_svc_item_h h, char **id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->id) { + _E("Invalid parameter: h->id is NULL"); + return -1; + } + + *id = strdup(h->id); + if (*id == NULL) { + _E("Failed to duplicate id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_get_label(rpc_port_autofill_svc_item_h h, char **label) +{ + if (!h || !label) { + _E("Invalid parameter"); + return -1; + } + + if (!h->label) { + _E("Invalid parameter: h->label is NULL"); + return -1; + } + + *label = strdup(h->label); + if (*label == NULL) { + _E("Failed to duplicate label"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_get_value(rpc_port_autofill_svc_item_h h, char **value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (!h->value) { + _E("Invalid parameter: h->value is NULL"); + return -1; + } + + *value = strdup(h->value); + if (*value == NULL) { + _E("Failed to duplicate value"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_item_get_autofill_hint(rpc_port_autofill_svc_item_h h, int *autofill_hint) +{ + if (!h || !autofill_hint) { + _E("Invalid parameter"); + return -1; + } + + *autofill_hint = h->autofill_hint; + return 0; +} + +int rpc_port_autofill_svc_item_get_is_sensitive_data(rpc_port_autofill_svc_item_h h, bool *is_sensitive_data) +{ + if (!h || !is_sensitive_data) { + _E("Invalid parameter"); + return -1; + } + + *is_sensitive_data = h->is_sensitive_data; + return 0; +} + +struct autofill_svc_view_info_s { + rpc_port_parcelable_t parcelable; + char *app_id; + char *view_id; + GList *items; +}; + +static void __autofill_svc_view_info_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_view_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->app_id ? h->app_id : ""); + rpc_port_parcel_write_string(parcel, h->view_id ? h->view_id : ""); + rpc_port_parcel_write_array_count(parcel, g_list_length(h->items)); + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __autofill_svc_view_info_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_view_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->app_id); + rpc_port_parcel_read_string(parcel, &h->view_id); + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_svc_item_h value = NULL; + + rpc_port_autofill_svc_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->items = g_list_append(h->items, value); + } + } while (0); +} + +int rpc_port_autofill_svc_view_info_create(rpc_port_autofill_svc_view_info_h *h) +{ + struct autofill_svc_view_info_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_view_info_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_view_info_to; + handle->parcelable.from = __autofill_svc_view_info_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_view_info_destroy(rpc_port_autofill_svc_view_info_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) + free(h->app_id); + + if (h->view_id) + free(h->view_id); + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + if (value) + rpc_port_autofill_svc_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_autofill_svc_view_info_clone(rpc_port_autofill_svc_view_info_h h, rpc_port_autofill_svc_view_info_h *clone) +{ + rpc_port_autofill_svc_view_info_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_view_info_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_view_info handle"); + return -1; + } + + if (h->app_id) { + handle->app_id = strdup(h->app_id); + if (!handle->app_id) { + _E("Failed to duplicate h->app_id"); + rpc_port_autofill_svc_view_info_destroy(handle); + return -1; + } + } + + if (h->view_id) { + handle->view_id = strdup(h->view_id); + if (!handle->view_id) { + _E("Failed to duplicate h->view_id"); + rpc_port_autofill_svc_view_info_destroy(handle); + return -1; + } + } + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_svc_item_h new_value; + rpc_port_autofill_svc_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_autofill_svc_view_info_destroy(handle); + return -1; + } + + rpc_port_autofill_svc_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_svc_view_info_destroy(handle); + return -1; + } + + handle->items = g_list_append(handle->items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_svc_view_info_set_app_id(rpc_port_autofill_svc_view_info_h h, const char *app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) { + free(h->app_id); + h->app_id = NULL; + } + + h->app_id = strdup(app_id); + if (!h->app_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_view_info_set_view_id(rpc_port_autofill_svc_view_info_h h, const char *view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) { + free(h->view_id); + h->view_id = NULL; + } + + h->view_id = strdup(view_id); + if (!h->view_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_view_info_add_items(rpc_port_autofill_svc_view_info_h h, rpc_port_autofill_svc_item_h items) +{ + if (!h || !items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_item_h value = NULL; + + rpc_port_autofill_svc_item_clone(items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->items = g_list_append(h->items, value); + } while (0); + + return 0; +} + +int rpc_port_autofill_svc_view_info_get_app_id(rpc_port_autofill_svc_view_info_h h, char **app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->app_id) { + _E("Invalid parameter: h->app_id is NULL"); + return -1; + } + + *app_id = strdup(h->app_id); + if (*app_id == NULL) { + _E("Failed to duplicate app_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_view_info_get_view_id(rpc_port_autofill_svc_view_info_h h, char **view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->view_id) { + _E("Invalid parameter: h->view_id is NULL"); + return -1; + } + + *view_id = strdup(h->view_id); + if (*view_id == NULL) { + _E("Failed to duplicate view_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_view_info_foreach_items(rpc_port_autofill_svc_view_info_h h, + bool (*callback)(rpc_port_autofill_svc_item_h items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_autofill_svc_view_info_remove_items(rpc_port_autofill_svc_view_info_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_svc_item_h value = iter->data; + h->items = g_list_remove_link(h->items, iter); + rpc_port_autofill_svc_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_svc_view_info_get_items_length(rpc_port_autofill_svc_view_info_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->items); + + return 0; +} + +struct autofill_svc_auth_info_s { + rpc_port_parcelable_t parcelable; + char *app_id; + bool exist_autofill_data; + bool need_authentication; + char *service_name; + char *service_logo_image_path; + char *service_message; +}; + +static void __autofill_svc_auth_info_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_auth_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->app_id ? h->app_id : ""); + rpc_port_parcel_write_bool(parcel, h->exist_autofill_data); + rpc_port_parcel_write_bool(parcel, h->need_authentication); + rpc_port_parcel_write_string(parcel, h->service_name ? h->service_name : ""); + rpc_port_parcel_write_string(parcel, h->service_logo_image_path ? h->service_logo_image_path : ""); + rpc_port_parcel_write_string(parcel, h->service_message ? h->service_message : ""); +} + +static void __autofill_svc_auth_info_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_auth_info_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->app_id); + rpc_port_parcel_read_bool(parcel, &h->exist_autofill_data); + rpc_port_parcel_read_bool(parcel, &h->need_authentication); + rpc_port_parcel_read_string(parcel, &h->service_name); + rpc_port_parcel_read_string(parcel, &h->service_logo_image_path); + rpc_port_parcel_read_string(parcel, &h->service_message); +} + +int rpc_port_autofill_svc_auth_info_create(rpc_port_autofill_svc_auth_info_h *h) +{ + struct autofill_svc_auth_info_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_auth_info_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_auth_info_to; + handle->parcelable.from = __autofill_svc_auth_info_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_auth_info_destroy(rpc_port_autofill_svc_auth_info_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) + free(h->app_id); + + if (h->service_name) + free(h->service_name); + + if (h->service_logo_image_path) + free(h->service_logo_image_path); + + if (h->service_message) + free(h->service_message); + + free(h); + + return 0; +} + +int rpc_port_autofill_svc_auth_info_clone(rpc_port_autofill_svc_auth_info_h h, rpc_port_autofill_svc_auth_info_h *clone) +{ + rpc_port_autofill_svc_auth_info_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_auth_info_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_auth_info handle"); + return -1; + } + + if (h->app_id) { + handle->app_id = strdup(h->app_id); + if (!handle->app_id) { + _E("Failed to duplicate h->app_id"); + rpc_port_autofill_svc_auth_info_destroy(handle); + return -1; + } + } + + handle->exist_autofill_data = h->exist_autofill_data; + handle->need_authentication = h->need_authentication; + if (h->service_name) { + handle->service_name = strdup(h->service_name); + if (!handle->service_name) { + _E("Failed to duplicate h->service_name"); + rpc_port_autofill_svc_auth_info_destroy(handle); + return -1; + } + } + + if (h->service_logo_image_path) { + handle->service_logo_image_path = strdup(h->service_logo_image_path); + if (!handle->service_logo_image_path) { + _E("Failed to duplicate h->service_logo_image_path"); + rpc_port_autofill_svc_auth_info_destroy(handle); + return -1; + } + } + + if (h->service_message) { + handle->service_message = strdup(h->service_message); + if (!handle->service_message) { + _E("Failed to duplicate h->service_message"); + rpc_port_autofill_svc_auth_info_destroy(handle); + return -1; + } + } + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_app_id(rpc_port_autofill_svc_auth_info_h h, const char *app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) { + free(h->app_id); + h->app_id = NULL; + } + + h->app_id = strdup(app_id); + if (!h->app_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_exist_autofill_data(rpc_port_autofill_svc_auth_info_h h, bool exist_autofill_data) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->exist_autofill_data = exist_autofill_data; + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_need_authentication(rpc_port_autofill_svc_auth_info_h h, bool need_authentication) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->need_authentication = need_authentication; + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_service_name(rpc_port_autofill_svc_auth_info_h h, const char *service_name) +{ + if (!h || !service_name) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_name) { + free(h->service_name); + h->service_name = NULL; + } + + h->service_name = strdup(service_name); + if (!h->service_name) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_service_logo_image_path(rpc_port_autofill_svc_auth_info_h h, const char *service_logo_image_path) +{ + if (!h || !service_logo_image_path) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_logo_image_path) { + free(h->service_logo_image_path); + h->service_logo_image_path = NULL; + } + + h->service_logo_image_path = strdup(service_logo_image_path); + if (!h->service_logo_image_path) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_set_service_message(rpc_port_autofill_svc_auth_info_h h, const char *service_message) +{ + if (!h || !service_message) { + _E("Invalid parameter"); + return -1; + } + + if (h->service_message) { + free(h->service_message); + h->service_message = NULL; + } + + h->service_message = strdup(service_message); + if (!h->service_message) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_app_id(rpc_port_autofill_svc_auth_info_h h, char **app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->app_id) { + _E("Invalid parameter: h->app_id is NULL"); + return -1; + } + + *app_id = strdup(h->app_id); + if (*app_id == NULL) { + _E("Failed to duplicate app_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_exist_autofill_data(rpc_port_autofill_svc_auth_info_h h, bool *exist_autofill_data) +{ + if (!h || !exist_autofill_data) { + _E("Invalid parameter"); + return -1; + } + + *exist_autofill_data = h->exist_autofill_data; + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_need_authentication(rpc_port_autofill_svc_auth_info_h h, bool *need_authentication) +{ + if (!h || !need_authentication) { + _E("Invalid parameter"); + return -1; + } + + *need_authentication = h->need_authentication; + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_service_name(rpc_port_autofill_svc_auth_info_h h, char **service_name) +{ + if (!h || !service_name) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_name) { + _E("Invalid parameter: h->service_name is NULL"); + return -1; + } + + *service_name = strdup(h->service_name); + if (*service_name == NULL) { + _E("Failed to duplicate service_name"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_service_logo_image_path(rpc_port_autofill_svc_auth_info_h h, char **service_logo_image_path) +{ + if (!h || !service_logo_image_path) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_logo_image_path) { + _E("Invalid parameter: h->service_logo_image_path is NULL"); + return -1; + } + + *service_logo_image_path = strdup(h->service_logo_image_path); + if (*service_logo_image_path == NULL) { + _E("Failed to duplicate service_logo_image_path"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_auth_info_get_service_message(rpc_port_autofill_svc_auth_info_h h, char **service_message) +{ + if (!h || !service_message) { + _E("Invalid parameter"); + return -1; + } + + if (!h->service_message) { + _E("Invalid parameter: h->service_message is NULL"); + return -1; + } + + *service_message = strdup(h->service_message); + if (*service_message == NULL) { + _E("Failed to duplicate service_message"); + return -1; + } + + return 0; +} + +struct autofill_svc_response_item_s { + rpc_port_parcelable_t parcelable; + char *id; + char *presentation_text; + char *value; +}; + +static void __autofill_svc_response_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->id ? h->id : ""); + rpc_port_parcel_write_string(parcel, h->presentation_text ? h->presentation_text : ""); + rpc_port_parcel_write_string(parcel, h->value ? h->value : ""); +} + +static void __autofill_svc_response_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->id); + rpc_port_parcel_read_string(parcel, &h->presentation_text); + rpc_port_parcel_read_string(parcel, &h->value); +} + +int rpc_port_autofill_svc_response_item_create(rpc_port_autofill_svc_response_item_h *h) +{ + struct autofill_svc_response_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_response_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_response_item_to; + handle->parcelable.from = __autofill_svc_response_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_response_item_destroy(rpc_port_autofill_svc_response_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) + free(h->id); + + if (h->presentation_text) + free(h->presentation_text); + + if (h->value) + free(h->value); + + free(h); + + return 0; +} + +int rpc_port_autofill_svc_response_item_clone(rpc_port_autofill_svc_response_item_h h, rpc_port_autofill_svc_response_item_h *clone) +{ + rpc_port_autofill_svc_response_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_response_item_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_response_item handle"); + return -1; + } + + if (h->id) { + handle->id = strdup(h->id); + if (!handle->id) { + _E("Failed to duplicate h->id"); + rpc_port_autofill_svc_response_item_destroy(handle); + return -1; + } + } + + if (h->presentation_text) { + handle->presentation_text = strdup(h->presentation_text); + if (!handle->presentation_text) { + _E("Failed to duplicate h->presentation_text"); + rpc_port_autofill_svc_response_item_destroy(handle); + return -1; + } + } + + if (h->value) { + handle->value = strdup(h->value); + if (!handle->value) { + _E("Failed to duplicate h->value"); + rpc_port_autofill_svc_response_item_destroy(handle); + return -1; + } + } + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_svc_response_item_set_id(rpc_port_autofill_svc_response_item_h h, const char *id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (h->id) { + free(h->id); + h->id = NULL; + } + + h->id = strdup(id); + if (!h->id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_response_item_set_presentation_text(rpc_port_autofill_svc_response_item_h h, const char *presentation_text) +{ + if (!h || !presentation_text) { + _E("Invalid parameter"); + return -1; + } + + if (h->presentation_text) { + free(h->presentation_text); + h->presentation_text = NULL; + } + + h->presentation_text = strdup(presentation_text); + if (!h->presentation_text) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_response_item_set_value(rpc_port_autofill_svc_response_item_h h, const char *value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (h->value) { + free(h->value); + h->value = NULL; + } + + h->value = strdup(value); + if (!h->value) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_response_item_get_id(rpc_port_autofill_svc_response_item_h h, char **id) +{ + if (!h || !id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->id) { + _E("Invalid parameter: h->id is NULL"); + return -1; + } + + *id = strdup(h->id); + if (*id == NULL) { + _E("Failed to duplicate id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_response_item_get_presentation_text(rpc_port_autofill_svc_response_item_h h, char **presentation_text) +{ + if (!h || !presentation_text) { + _E("Invalid parameter"); + return -1; + } + + if (!h->presentation_text) { + _E("Invalid parameter: h->presentation_text is NULL"); + return -1; + } + + *presentation_text = strdup(h->presentation_text); + if (*presentation_text == NULL) { + _E("Failed to duplicate presentation_text"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_response_item_get_value(rpc_port_autofill_svc_response_item_h h, char **value) +{ + if (!h || !value) { + _E("Invalid parameter"); + return -1; + } + + if (!h->value) { + _E("Invalid parameter: h->value is NULL"); + return -1; + } + + *value = strdup(h->value); + if (*value == NULL) { + _E("Failed to duplicate value"); + return -1; + } + + return 0; +} + +struct autofill_svc_fill_response_s { + rpc_port_parcelable_t parcelable; + char *app_id; + char *view_id; + GList *response_items; +}; + +static void __autofill_svc_fill_response_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_fill_response_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_string(parcel, h->app_id ? h->app_id : ""); + rpc_port_parcel_write_string(parcel, h->view_id ? h->view_id : ""); + rpc_port_parcel_write_array_count(parcel, g_list_length(h->response_items)); + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __autofill_svc_fill_response_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_fill_response_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_string(parcel, &h->app_id); + rpc_port_parcel_read_string(parcel, &h->view_id); + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_svc_response_item_h value = NULL; + + rpc_port_autofill_svc_response_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->response_items = g_list_append(h->response_items, value); + } + } while (0); +} + +int rpc_port_autofill_svc_fill_response_create(rpc_port_autofill_svc_fill_response_h *h) +{ + struct autofill_svc_fill_response_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_fill_response_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_fill_response_to; + handle->parcelable.from = __autofill_svc_fill_response_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_fill_response_destroy(rpc_port_autofill_svc_fill_response_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) + free(h->app_id); + + if (h->view_id) + free(h->view_id); + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + if (value) + rpc_port_autofill_svc_response_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->response_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_autofill_svc_fill_response_clone(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_fill_response_h *clone) +{ + rpc_port_autofill_svc_fill_response_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_fill_response_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_fill_response handle"); + return -1; + } + + if (h->app_id) { + handle->app_id = strdup(h->app_id); + if (!handle->app_id) { + _E("Failed to duplicate h->app_id"); + rpc_port_autofill_svc_fill_response_destroy(handle); + return -1; + } + } + + if (h->view_id) { + handle->view_id = strdup(h->view_id); + if (!handle->view_id) { + _E("Failed to duplicate h->view_id"); + rpc_port_autofill_svc_fill_response_destroy(handle); + return -1; + } + } + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h new_value; + rpc_port_autofill_svc_response_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_autofill_svc_fill_response_destroy(handle); + return -1; + } + + rpc_port_autofill_svc_response_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_svc_fill_response_destroy(handle); + return -1; + } + + handle->response_items = g_list_append(handle->response_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_autofill_svc_fill_response_set_app_id(rpc_port_autofill_svc_fill_response_h h, const char *app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->app_id) { + free(h->app_id); + h->app_id = NULL; + } + + h->app_id = strdup(app_id); + if (!h->app_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_fill_response_set_view_id(rpc_port_autofill_svc_fill_response_h h, const char *view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (h->view_id) { + free(h->view_id); + h->view_id = NULL; + } + + h->view_id = strdup(view_id); + if (!h->view_id) { + _E("Failed to duplicate data"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_fill_response_add_response_items(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_response_item_h response_items) +{ + if (!h || !response_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_response_item_h value = NULL; + + rpc_port_autofill_svc_response_item_clone(response_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->response_items = g_list_append(h->response_items, value); + } while (0); + + return 0; +} + +int rpc_port_autofill_svc_fill_response_get_app_id(rpc_port_autofill_svc_fill_response_h h, char **app_id) +{ + if (!h || !app_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->app_id) { + _E("Invalid parameter: h->app_id is NULL"); + return -1; + } + + *app_id = strdup(h->app_id); + if (*app_id == NULL) { + _E("Failed to duplicate app_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_fill_response_get_view_id(rpc_port_autofill_svc_fill_response_h h, char **view_id) +{ + if (!h || !view_id) { + _E("Invalid parameter"); + return -1; + } + + if (!h->view_id) { + _E("Invalid parameter: h->view_id is NULL"); + return -1; + } + + *view_id = strdup(h->view_id); + if (*view_id == NULL) { + _E("Failed to duplicate view_id"); + return -1; + } + + return 0; +} + +int rpc_port_autofill_svc_fill_response_foreach_response_items(rpc_port_autofill_svc_fill_response_h h, + bool (*callback)(rpc_port_autofill_svc_response_item_h response_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_autofill_svc_fill_response_remove_response_items(rpc_port_autofill_svc_fill_response_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->response_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_svc_response_item_h value = iter->data; + h->response_items = g_list_remove_link(h->response_items, iter); + rpc_port_autofill_svc_response_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_svc_fill_response_get_response_items_length(rpc_port_autofill_svc_fill_response_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->response_items); + + return 0; +} + +struct list_autofill_svc_item_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_svc_items; +}; + +static void __list_autofill_svc_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_svc_items)); + do { + GList *iter; + + iter = h->list_autofill_svc_items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __list_autofill_svc_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_svc_item_h value = NULL; + + rpc_port_autofill_svc_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_svc_items = g_list_append(h->list_autofill_svc_items, value); + } + } while (0); +} + +int rpc_port_list_autofill_svc_item_create(rpc_port_list_autofill_svc_item_h *h) +{ + struct list_autofill_svc_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_svc_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_svc_item_to; + handle->parcelable.from = __list_autofill_svc_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_item_destroy(rpc_port_list_autofill_svc_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + if (value) + rpc_port_autofill_svc_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_svc_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_svc_item_clone(rpc_port_list_autofill_svc_item_h h, rpc_port_list_autofill_svc_item_h *clone) +{ + rpc_port_list_autofill_svc_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_svc_item_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_svc_item handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_items; + while (iter) { + rpc_port_autofill_svc_item_h new_value; + rpc_port_autofill_svc_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_svc_item_destroy(handle); + return -1; + } + + rpc_port_autofill_svc_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_svc_item_destroy(handle); + return -1; + } + + handle->list_autofill_svc_items = g_list_append(handle->list_autofill_svc_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_item_add_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, rpc_port_autofill_svc_item_h list_autofill_svc_items) +{ + if (!h || !list_autofill_svc_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_item_h value = NULL; + + rpc_port_autofill_svc_item_clone(list_autofill_svc_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_svc_items = g_list_append(h->list_autofill_svc_items, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_svc_item_foreach_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, + bool (*callback)(rpc_port_autofill_svc_item_h list_autofill_svc_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_items; + while (iter) { + rpc_port_autofill_svc_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_list_autofill_svc_item_remove_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_svc_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_svc_item_h value = iter->data; + h->list_autofill_svc_items = g_list_remove_link(h->list_autofill_svc_items, iter); + rpc_port_autofill_svc_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_svc_item_get_list_autofill_svc_items_length(rpc_port_list_autofill_svc_item_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_svc_items); + + return 0; +} + +struct list_autofill_svc_response_item_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_svc_response_items; +}; + +static void __list_autofill_svc_response_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_svc_response_items)); + do { + GList *iter; + + iter = h->list_autofill_svc_response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write(parcel, &value->parcelable, value); + } + } while (0); +} + +static void __list_autofill_svc_response_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_response_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + do { + int len = 0; + + rpc_port_parcel_read_array_count(parcel, &len); + for (int i = 0; i < len; i++) { + rpc_port_autofill_svc_response_item_h value = NULL; + + rpc_port_autofill_svc_response_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_svc_response_items = g_list_append(h->list_autofill_svc_response_items, value); + } + } while (0); +} + +int rpc_port_list_autofill_svc_response_item_create(rpc_port_list_autofill_svc_response_item_h *h) +{ + struct list_autofill_svc_response_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_svc_response_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_svc_response_item_to; + handle->parcelable.from = __list_autofill_svc_response_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_destroy(rpc_port_list_autofill_svc_response_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + if (value) + rpc_port_autofill_svc_response_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_svc_response_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_clone(rpc_port_list_autofill_svc_response_item_h h, rpc_port_list_autofill_svc_response_item_h *clone) +{ + rpc_port_list_autofill_svc_response_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_svc_response_item_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_svc_response_item handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h new_value; + rpc_port_autofill_svc_response_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_svc_response_item_destroy(handle); + return -1; + } + + rpc_port_autofill_svc_response_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_svc_response_item_destroy(handle); + return -1; + } + + handle->list_autofill_svc_response_items = g_list_append(handle->list_autofill_svc_response_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_add_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, rpc_port_autofill_svc_response_item_h list_autofill_svc_response_items) +{ + if (!h || !list_autofill_svc_response_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_response_item_h value = NULL; + + rpc_port_autofill_svc_response_item_clone(list_autofill_svc_response_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_svc_response_items = g_list_append(h->list_autofill_svc_response_items, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_foreach_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, + bool (*callback)(rpc_port_autofill_svc_response_item_h list_autofill_svc_response_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_response_items; + while (iter) { + rpc_port_autofill_svc_response_item_h value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + + bool ret = callback(value, user_data); + if (!ret) + break; + } + } while (0); + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_remove_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_svc_response_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_svc_response_item_h value = iter->data; + h->list_autofill_svc_response_items = g_list_remove_link(h->list_autofill_svc_response_items, iter); + rpc_port_autofill_svc_response_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_svc_response_item_get_list_autofill_svc_response_items_length(rpc_port_list_autofill_svc_response_item_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_svc_response_items); + + return 0; +} + +enum AutofillSvcPort_method_e { + AutofillSvcPort_METHOD_Result, + AutofillSvcPort_METHOD_Callback, + AutofillSvcPort_METHOD_Register, + AutofillSvcPort_METHOD_Unregister, + AutofillSvcPort_METHOD_request_auth_info, + AutofillSvcPort_METHOD_send_fill_request, +}; + +enum AutofillSvcPort_delegate_e { + AutofillSvcPort_DELEGATE_autofill_svc_auth_info_cb = 1, + AutofillSvcPort_DELEGATE_autofill_svc_fill_response_cb = 2, +}; + +static rpc_port_stub_h __AutofillSvcPort_stub; +static rpc_port_stub_AutofillSvcPort_callback_s __AutofillSvcPort_callback; +static void *__AutofillSvcPort_user_data; +static GList *__AutofillSvcPort_contexts; + +struct AutofillSvcPort_context_s { + char *sender; + char *instance; + rpc_port_h port; + void *tag; + rpc_port_stub_AutofillSvcPort_callback_s callback; + void *user_data; +}; + +static struct AutofillSvcPort_context_s *__create_AutofillSvcPort_context(const char *sender, const char *instance) +{ + struct AutofillSvcPort_context_s *handle; + + handle = calloc(1, sizeof(struct AutofillSvcPort_context_s)); + if (!handle) { + _E("Out of memory"); + return NULL; + } + + handle->sender = strdup(sender); + if (!handle->sender) { + _E("Out of memory"); + free(handle); + return NULL; + } + + handle->instance = strdup(instance); + if (!handle->instance) { + _E("Out of memory"); + free(handle->sender); + free(handle); + return NULL; + } + + handle->callback = __AutofillSvcPort_callback; + handle->user_data = __AutofillSvcPort_user_data; + + return handle; +} + +static void __destroy_AutofillSvcPort_context(gpointer data) +{ + struct AutofillSvcPort_context_s *handle = data; + + if (!handle) { + _E("Critical error!"); + return; + } + + free(handle->instance); + free(handle->sender); + free(handle); +} + +static struct AutofillSvcPort_context_s *__find_AutofillSvcPort_context(const char *instance) +{ + struct AutofillSvcPort_context_s *handle; + GList *iter; + + iter = __AutofillSvcPort_contexts; + while (iter) { + handle = (struct AutofillSvcPort_context_s *)iter->data; + if (!strcmp(handle->instance, instance)) + return handle; + iter = g_list_next(iter); + } + + return NULL; +} + +int rpc_port_stub_AutofillSvcPort_context_set_tag(rpc_port_stub_AutofillSvcPort_context_h ctx, void *tag) +{ + if (!ctx) { + _E("Invalid parameter"); + return -1; + } + + ctx->tag = tag; + + return 0; +} + +int rpc_port_stub_AutofillSvcPort_context_get_tag(rpc_port_stub_AutofillSvcPort_context_h ctx, void **tag) +{ + if (!ctx || !tag) { + _E("Invalid parameter"); + return -1; + } + + *tag = ctx->tag; + + return 0; +} + +int rpc_port_stub_AutofillSvcPort_context_get_sender(rpc_port_stub_AutofillSvcPort_context_h ctx, char **sender) +{ + if (!ctx || !sender) { + _E("Invalid parameter"); + return -1; + } + + *sender = strdup(ctx->sender); + if (*sender == NULL) { + _E("Out of memory"); + return -1; + } + + return 0; +} + +struct AutofillSvcPort_autofill_svc_auth_info_cb_s { + rpc_port_parcelable_t parcelable; + rpc_port_h port; + int id; + int seq_id; + bool once; + bool valid; +}; + +static void __AutofillSvcPort_autofill_svc_auth_info_cb_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, handle->id); + rpc_port_parcel_write_int32(parcel, handle->seq_id); + rpc_port_parcel_write_bool(parcel, handle->once); +} + +static void __AutofillSvcPort_autofill_svc_auth_info_cb_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_int32(parcel, &handle->id); + rpc_port_parcel_read_int32(parcel, &handle->seq_id); + rpc_port_parcel_read_bool(parcel, &handle->once); +} + +int rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_create(rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h *h) +{ + struct AutofillSvcPort_autofill_svc_auth_info_cb_s *handle; + static int seq_num; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillSvcPort_autofill_svc_auth_info_cb_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __AutofillSvcPort_autofill_svc_auth_info_cb_to; + handle->parcelable.from = __AutofillSvcPort_autofill_svc_auth_info_cb_from; + handle->id = AutofillSvcPort_DELEGATE_autofill_svc_auth_info_cb; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + handle->once = false; + handle->valid = true; + + *h = handle; + + return 0; +} + +int rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_destroy(rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + free(h); + + return 0; +} + +int rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_clone(rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h h, rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h *clone) +{ + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h handle; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillSvcPort_autofill_svc_auth_info_cb_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable = h->parcelable; + handle->port = h->port; + handle->id = h->id; + handle->seq_id = h->seq_id; + handle->once = h->once; + handle->valid = h->valid; + + *clone = handle; + + return 0; +} + +int rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_invoke(rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h h, rpc_port_autofill_svc_auth_info_h auth_info) +{ + rpc_port_parcel_h parcel = NULL; + + if (!h || !h->port) { + _E("Invalid parameter"); + return -1; + } + + if (h->once && !h->valid) { + _E("Invalid callback"); + return -1; + } + + rpc_port_parcel_create(&parcel); + if (!parcel) { + _E("Failed to create parcel"); + return -1; + } + + rpc_port_parcel_write_int32(parcel, AutofillSvcPort_METHOD_Callback); + rpc_port_parcel_write(parcel, &h->parcelable, h); + rpc_port_parcel_write(parcel, &auth_info->parcelable, auth_info); + + rpc_port_parcel_send(parcel, h->port); + rpc_port_parcel_destroy(parcel); + h->valid = false; + + return 0; +} + +int rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_set_port(rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h h, rpc_port_h port) +{ + if (!h || !port) { + _E("Invalid parameter"); + return -1; + } + + h->port = port; + + return 0; +} + +struct AutofillSvcPort_autofill_svc_fill_response_cb_s { + rpc_port_parcelable_t parcelable; + rpc_port_h port; + int id; + int seq_id; + bool once; + bool valid; +}; + +static void __AutofillSvcPort_autofill_svc_fill_response_cb_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_int32(parcel, handle->id); + rpc_port_parcel_write_int32(parcel, handle->seq_id); + rpc_port_parcel_write_bool(parcel, handle->once); +} + +static void __AutofillSvcPort_autofill_svc_fill_response_cb_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h handle = data; + + if (!handle) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_read_int32(parcel, &handle->id); + rpc_port_parcel_read_int32(parcel, &handle->seq_id); + rpc_port_parcel_read_bool(parcel, &handle->once); +} + +int rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_create(rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h *h) +{ + struct AutofillSvcPort_autofill_svc_fill_response_cb_s *handle; + static int seq_num; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillSvcPort_autofill_svc_fill_response_cb_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __AutofillSvcPort_autofill_svc_fill_response_cb_to; + handle->parcelable.from = __AutofillSvcPort_autofill_svc_fill_response_cb_from; + handle->id = AutofillSvcPort_DELEGATE_autofill_svc_fill_response_cb; + handle->seq_id = g_atomic_int_add(&seq_num, 1) + 1; + handle->once = false; + handle->valid = true; + + *h = handle; + + return 0; +} + +int rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_destroy(rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + free(h); + + return 0; +} + +int rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_clone(rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h h, rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h *clone) +{ + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h handle; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillSvcPort_autofill_svc_fill_response_cb_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable = h->parcelable; + handle->port = h->port; + handle->id = h->id; + handle->seq_id = h->seq_id; + handle->once = h->once; + handle->valid = h->valid; + + *clone = handle; + + return 0; +} + +int rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_invoke(rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h h, rpc_port_autofill_svc_fill_response_h response) +{ + rpc_port_parcel_h parcel = NULL; + + if (!h || !h->port) { + _E("Invalid parameter"); + return -1; + } + + if (h->once && !h->valid) { + _E("Invalid callback"); + return -1; + } + + rpc_port_parcel_create(&parcel); + if (!parcel) { + _E("Failed to create parcel"); + return -1; + } + + rpc_port_parcel_write_int32(parcel, AutofillSvcPort_METHOD_Callback); + rpc_port_parcel_write(parcel, &h->parcelable, h); + rpc_port_parcel_write(parcel, &response->parcelable, response); + + rpc_port_parcel_send(parcel, h->port); + rpc_port_parcel_destroy(parcel); + h->valid = false; + + return 0; +} + +int rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_set_port(rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h h, rpc_port_h port) +{ + if (!h || !port) { + _E("Invalid parameter"); + return -1; + } + + h->port = port; + + return 0; +} + +static int __AutofillSvcPort_method_Register(rpc_port_h port, rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_AutofillSvcPort_context_h context = data; + rpc_port_h callback_port; + int r; + + r = rpc_port_stub_get_port(__AutofillSvcPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); + if (r != 0) { + _E("Failed to get callback port"); + return -1; + } + + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb = NULL; + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_cb = NULL; + + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_create(&auth_info_cb); + + if (!auth_info_cb) { + _E("Failed to create handle"); + return -1; + } + + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_set_port(auth_info_cb, callback_port); + rpc_port_parcel_read(parcel, &auth_info_cb->parcelable, auth_info_cb); + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_create(&fill_response_cb); + + if (!fill_response_cb) { + _E("Failed to create handle"); + return -1; + } + + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_set_port(fill_response_cb, callback_port); + rpc_port_parcel_read(parcel, &fill_response_cb->parcelable, fill_response_cb); + + int ret = context->callback.Register(context, auth_info_cb, fill_response_cb, context->user_data); + do { + rpc_port_parcel_h result; + + rpc_port_parcel_create(&result); + rpc_port_parcel_write_int32(result, AutofillSvcPort_METHOD_Result); + rpc_port_parcel_write_int32(result, ret); + rpc_port_parcel_send(result, port); + rpc_port_parcel_destroy(result); + } while (0); + + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_destroy(auth_info_cb); + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_destroy(fill_response_cb); + return 0; +} + +static int __AutofillSvcPort_method_Unregister(rpc_port_h port, rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_AutofillSvcPort_context_h context = data; + rpc_port_h callback_port; + int r; + + r = rpc_port_stub_get_port(__AutofillSvcPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); + if (r != 0) { + _E("Failed to get callback port"); + return -1; + } + + context->callback.Unregister(context, context->user_data); + + return 0; +} + +static int __AutofillSvcPort_method_request_auth_info(rpc_port_h port, rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_AutofillSvcPort_context_h context = data; + rpc_port_h callback_port; + int r; + + r = rpc_port_stub_get_port(__AutofillSvcPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); + if (r != 0) { + _E("Failed to get callback port"); + return -1; + } + + rpc_port_autofill_svc_view_info_h vi = NULL; + + rpc_port_autofill_svc_view_info_create(&vi); + rpc_port_parcel_read(parcel, &vi->parcelable, vi); + + context->callback.request_auth_info(context, vi, context->user_data); + + rpc_port_autofill_svc_view_info_destroy(vi); + return 0; +} + +static int __AutofillSvcPort_method_send_fill_request(rpc_port_h port, rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_AutofillSvcPort_context_h context = data; + rpc_port_h callback_port; + int r; + + r = rpc_port_stub_get_port(__AutofillSvcPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); + if (r != 0) { + _E("Failed to get callback port"); + return -1; + } + + rpc_port_autofill_svc_view_info_h vi = NULL; + + rpc_port_autofill_svc_view_info_create(&vi); + rpc_port_parcel_read(parcel, &vi->parcelable, vi); + + context->callback.send_fill_request(context, vi, context->user_data); + + rpc_port_autofill_svc_view_info_destroy(vi); + return 0; +} + +static stub_method __AutofillSvcPort_method_table[] = { + [AutofillSvcPort_METHOD_Register] = __AutofillSvcPort_method_Register, + [AutofillSvcPort_METHOD_Unregister] = __AutofillSvcPort_method_Unregister, + [AutofillSvcPort_METHOD_request_auth_info] = __AutofillSvcPort_method_request_auth_info, + [AutofillSvcPort_METHOD_send_fill_request] = __AutofillSvcPort_method_send_fill_request, +}; + +static void __AutofillSvcPort_on_connected(const char *sender, const char *instance, void *data) +{ + rpc_port_stub_AutofillSvcPort_context_h context; + + _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); + context = __create_AutofillSvcPort_context(sender, instance); + if (!context) + return; + + if (context->callback.create) + context->callback.create(context, context->user_data); + __AutofillSvcPort_contexts = g_list_append(__AutofillSvcPort_contexts, context); +} + +static void __AutofillSvcPort_on_disconnected(const char *sender, const char *instance, void *data) +{ + rpc_port_stub_AutofillSvcPort_context_h context; + + _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); + context = __find_AutofillSvcPort_context(instance); + if (!context) + return; + + if (context->callback.terminate) + context->callback.terminate(context, context->user_data); + __AutofillSvcPort_contexts = g_list_remove(__AutofillSvcPort_contexts, context); + __destroy_AutofillSvcPort_context(context); +} + +static int __AutofillSvcPort_on_received(const char *sender, const char *instance, rpc_port_h port, void *data) +{ + rpc_port_stub_AutofillSvcPort_context_h context; + rpc_port_parcel_h parcel; + int cmd = -1; + int r; + + _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); + context = __find_AutofillSvcPort_context(instance); + if (!context) { + _E("Failed to find AutofillSvcPort context(%s)", instance); + return -1; + } + + context->port = port; + r = rpc_port_parcel_create_from_port(&parcel, port); + if (r != 0) { + _E("Failed to create parcel from port"); + return r; + } + + rpc_port_parcel_read_int32(parcel, &cmd); + if (cmd > 1 && cmd < (sizeof(__AutofillSvcPort_method_table) / sizeof(__AutofillSvcPort_method_table[0]))) { + if (__AutofillSvcPort_method_table[cmd]) + r = __AutofillSvcPort_method_table[cmd](port, parcel, context); + } else { + _E("Unknown Command(%d)", cmd); + r = -1; + } + + rpc_port_parcel_destroy(parcel); + + return r; +} + +static int __AutofillSvcPort_add_privileges(void) +{ + + return 0; +} + +int rpc_port_stub_AutofillSvcPort_register(rpc_port_stub_AutofillSvcPort_callback_s *callback, void *user_data) +{ + int r; + + if (__AutofillSvcPort_stub) { + _W("Already exists"); + return -1; + } + + if (!callback) { + _E("Invalid parameter"); + return -1; + } + + __AutofillSvcPort_callback = *callback; + __AutofillSvcPort_user_data = user_data; + r = rpc_port_stub_create(&__AutofillSvcPort_stub, "AutofillSvcPort"); + if (r != 0) { + _E("Failed to create stub handle"); + return r; + } + + r = rpc_port_stub_add_received_event_cb(__AutofillSvcPort_stub, __AutofillSvcPort_on_received, NULL); + if (r != 0) { + _E("Failed to add received event callback"); + rpc_port_stub_destroy(__AutofillSvcPort_stub); + __AutofillSvcPort_stub = NULL; + return r; + } + + r = rpc_port_stub_add_connected_event_cb(__AutofillSvcPort_stub, __AutofillSvcPort_on_connected, NULL); + if (r != 0) { + _E("Failed to add connected event callback"); + rpc_port_stub_destroy(__AutofillSvcPort_stub); + __AutofillSvcPort_stub = NULL; + return r; + } + + r = rpc_port_stub_add_disconnected_event_cb(__AutofillSvcPort_stub, __AutofillSvcPort_on_disconnected, NULL); + if (r != 0) { + _E("Failed to add disconnected event callback"); + rpc_port_stub_destroy(__AutofillSvcPort_stub); + __AutofillSvcPort_stub = NULL; + return r; + } + + r = __AutofillSvcPort_add_privileges(); + if (r != 0) { + _E("Failed to add privileges"); + rpc_port_stub_destroy(__AutofillSvcPort_stub); + __AutofillSvcPort_stub = NULL; + return r; + } + + r = rpc_port_stub_listen(__AutofillSvcPort_stub); + if (r != 0) { + _E("Failed to listen stub"); + rpc_port_stub_destroy(__AutofillSvcPort_stub); + __AutofillSvcPort_stub = NULL; + return r; + } + + return 0; +} + +int rpc_port_stub_AutofillSvcPort_unregister(void) +{ + int r; + + if (!__AutofillSvcPort_stub) + return -1; + + if (__AutofillSvcPort_contexts) { + g_list_free_full(__AutofillSvcPort_contexts, __destroy_AutofillSvcPort_context); + __AutofillSvcPort_contexts = NULL; + } + + r = rpc_port_stub_destroy(__AutofillSvcPort_stub); + __AutofillSvcPort_stub = NULL; + + return r; +} + +int rpc_port_stub_AutofillSvcPort_get_client_number(unsigned int *n) +{ + if (!n) { + _E("Invalid parameter"); + return -1; + } + + if (!__AutofillSvcPort_stub) { + _E("AutofillSvcPort Stub is not ready"); + return -1; + } + + *n = g_list_length(__AutofillSvcPort_contexts); + + return 0; +} diff --git a/service_lib/autofill_service_stub.h b/service_lib/autofill_service_stub.h new file mode 100644 index 0000000..0c921ba --- /dev/null +++ b/service_lib/autofill_service_stub.h @@ -0,0 +1,234 @@ +/* + * Generated by tidlc 1.3.1. + * + * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * + * 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. + */ + +#pragma once + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct autofill_svc_item_s *rpc_port_autofill_svc_item_h; + +int rpc_port_autofill_svc_item_create(rpc_port_autofill_svc_item_h *h); + +int rpc_port_autofill_svc_item_destroy(rpc_port_autofill_svc_item_h h); + +int rpc_port_autofill_svc_item_clone(rpc_port_autofill_svc_item_h h, rpc_port_autofill_svc_item_h *clone); + +int rpc_port_autofill_svc_item_set_id(rpc_port_autofill_svc_item_h h, const char *id); + +int rpc_port_autofill_svc_item_set_label(rpc_port_autofill_svc_item_h h, const char *label); + +int rpc_port_autofill_svc_item_set_value(rpc_port_autofill_svc_item_h h, const char *value); + +int rpc_port_autofill_svc_item_set_autofill_hint(rpc_port_autofill_svc_item_h h, int autofill_hint); + +int rpc_port_autofill_svc_item_set_is_sensitive_data(rpc_port_autofill_svc_item_h h, bool is_sensitive_data); + +int rpc_port_autofill_svc_item_get_id(rpc_port_autofill_svc_item_h h, char **id); + +int rpc_port_autofill_svc_item_get_label(rpc_port_autofill_svc_item_h h, char **label); + +int rpc_port_autofill_svc_item_get_value(rpc_port_autofill_svc_item_h h, char **value); + +int rpc_port_autofill_svc_item_get_autofill_hint(rpc_port_autofill_svc_item_h h, int *autofill_hint); + +int rpc_port_autofill_svc_item_get_is_sensitive_data(rpc_port_autofill_svc_item_h h, bool *is_sensitive_data); + +typedef struct autofill_svc_view_info_s *rpc_port_autofill_svc_view_info_h; + +int rpc_port_autofill_svc_view_info_create(rpc_port_autofill_svc_view_info_h *h); + +int rpc_port_autofill_svc_view_info_destroy(rpc_port_autofill_svc_view_info_h h); + +int rpc_port_autofill_svc_view_info_clone(rpc_port_autofill_svc_view_info_h h, rpc_port_autofill_svc_view_info_h *clone); + +int rpc_port_autofill_svc_view_info_set_app_id(rpc_port_autofill_svc_view_info_h h, const char *app_id); + +int rpc_port_autofill_svc_view_info_set_view_id(rpc_port_autofill_svc_view_info_h h, const char *view_id); + +int rpc_port_autofill_svc_view_info_add_items(rpc_port_autofill_svc_view_info_h h, rpc_port_autofill_svc_item_h items); + +int rpc_port_autofill_svc_view_info_get_app_id(rpc_port_autofill_svc_view_info_h h, char **app_id); + +int rpc_port_autofill_svc_view_info_get_view_id(rpc_port_autofill_svc_view_info_h h, char **view_id); + +int rpc_port_autofill_svc_view_info_foreach_items(rpc_port_autofill_svc_view_info_h h, + bool (*callback)(rpc_port_autofill_svc_item_h items, void *user_data), void *user_data); + +int rpc_port_autofill_svc_view_info_remove_items(rpc_port_autofill_svc_view_info_h h, unsigned int nth); + +int rpc_port_autofill_svc_view_info_get_items_length(rpc_port_autofill_svc_view_info_h h, unsigned int *length); + +typedef struct autofill_svc_auth_info_s *rpc_port_autofill_svc_auth_info_h; + +int rpc_port_autofill_svc_auth_info_create(rpc_port_autofill_svc_auth_info_h *h); + +int rpc_port_autofill_svc_auth_info_destroy(rpc_port_autofill_svc_auth_info_h h); + +int rpc_port_autofill_svc_auth_info_clone(rpc_port_autofill_svc_auth_info_h h, rpc_port_autofill_svc_auth_info_h *clone); + +int rpc_port_autofill_svc_auth_info_set_app_id(rpc_port_autofill_svc_auth_info_h h, const char *app_id); + +int rpc_port_autofill_svc_auth_info_set_exist_autofill_data(rpc_port_autofill_svc_auth_info_h h, bool exist_autofill_data); + +int rpc_port_autofill_svc_auth_info_set_need_authentication(rpc_port_autofill_svc_auth_info_h h, bool need_authentication); + +int rpc_port_autofill_svc_auth_info_set_service_name(rpc_port_autofill_svc_auth_info_h h, const char *service_name); + +int rpc_port_autofill_svc_auth_info_set_service_logo_image_path(rpc_port_autofill_svc_auth_info_h h, const char *service_logo_image_path); + +int rpc_port_autofill_svc_auth_info_set_service_message(rpc_port_autofill_svc_auth_info_h h, const char *service_message); + +int rpc_port_autofill_svc_auth_info_get_app_id(rpc_port_autofill_svc_auth_info_h h, char **app_id); + +int rpc_port_autofill_svc_auth_info_get_exist_autofill_data(rpc_port_autofill_svc_auth_info_h h, bool *exist_autofill_data); + +int rpc_port_autofill_svc_auth_info_get_need_authentication(rpc_port_autofill_svc_auth_info_h h, bool *need_authentication); + +int rpc_port_autofill_svc_auth_info_get_service_name(rpc_port_autofill_svc_auth_info_h h, char **service_name); + +int rpc_port_autofill_svc_auth_info_get_service_logo_image_path(rpc_port_autofill_svc_auth_info_h h, char **service_logo_image_path); + +int rpc_port_autofill_svc_auth_info_get_service_message(rpc_port_autofill_svc_auth_info_h h, char **service_message); + +typedef struct autofill_svc_response_item_s *rpc_port_autofill_svc_response_item_h; + +int rpc_port_autofill_svc_response_item_create(rpc_port_autofill_svc_response_item_h *h); + +int rpc_port_autofill_svc_response_item_destroy(rpc_port_autofill_svc_response_item_h h); + +int rpc_port_autofill_svc_response_item_clone(rpc_port_autofill_svc_response_item_h h, rpc_port_autofill_svc_response_item_h *clone); + +int rpc_port_autofill_svc_response_item_set_id(rpc_port_autofill_svc_response_item_h h, const char *id); + +int rpc_port_autofill_svc_response_item_set_presentation_text(rpc_port_autofill_svc_response_item_h h, const char *presentation_text); + +int rpc_port_autofill_svc_response_item_set_value(rpc_port_autofill_svc_response_item_h h, const char *value); + +int rpc_port_autofill_svc_response_item_get_id(rpc_port_autofill_svc_response_item_h h, char **id); + +int rpc_port_autofill_svc_response_item_get_presentation_text(rpc_port_autofill_svc_response_item_h h, char **presentation_text); + +int rpc_port_autofill_svc_response_item_get_value(rpc_port_autofill_svc_response_item_h h, char **value); + +typedef struct autofill_svc_fill_response_s *rpc_port_autofill_svc_fill_response_h; + +int rpc_port_autofill_svc_fill_response_create(rpc_port_autofill_svc_fill_response_h *h); + +int rpc_port_autofill_svc_fill_response_destroy(rpc_port_autofill_svc_fill_response_h h); + +int rpc_port_autofill_svc_fill_response_clone(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_fill_response_h *clone); + +int rpc_port_autofill_svc_fill_response_set_app_id(rpc_port_autofill_svc_fill_response_h h, const char *app_id); + +int rpc_port_autofill_svc_fill_response_set_view_id(rpc_port_autofill_svc_fill_response_h h, const char *view_id); + +int rpc_port_autofill_svc_fill_response_add_response_items(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_response_item_h response_items); + +int rpc_port_autofill_svc_fill_response_get_app_id(rpc_port_autofill_svc_fill_response_h h, char **app_id); + +int rpc_port_autofill_svc_fill_response_get_view_id(rpc_port_autofill_svc_fill_response_h h, char **view_id); + +int rpc_port_autofill_svc_fill_response_foreach_response_items(rpc_port_autofill_svc_fill_response_h h, + bool (*callback)(rpc_port_autofill_svc_response_item_h response_items, void *user_data), void *user_data); + +int rpc_port_autofill_svc_fill_response_remove_response_items(rpc_port_autofill_svc_fill_response_h h, unsigned int nth); + +int rpc_port_autofill_svc_fill_response_get_response_items_length(rpc_port_autofill_svc_fill_response_h h, unsigned int *length); + +typedef struct list_autofill_svc_item_s *rpc_port_list_autofill_svc_item_h; + +int rpc_port_list_autofill_svc_item_create(rpc_port_list_autofill_svc_item_h *h); + +int rpc_port_list_autofill_svc_item_destroy(rpc_port_list_autofill_svc_item_h h); + +int rpc_port_list_autofill_svc_item_clone(rpc_port_list_autofill_svc_item_h h, rpc_port_list_autofill_svc_item_h *clone); + +int rpc_port_list_autofill_svc_item_add_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, rpc_port_autofill_svc_item_h list_autofill_svc_items); + +int rpc_port_list_autofill_svc_item_foreach_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, + bool (*callback)(rpc_port_autofill_svc_item_h list_autofill_svc_items, void *user_data), void *user_data); + +int rpc_port_list_autofill_svc_item_remove_list_autofill_svc_items(rpc_port_list_autofill_svc_item_h h, unsigned int nth); + +int rpc_port_list_autofill_svc_item_get_list_autofill_svc_items_length(rpc_port_list_autofill_svc_item_h h, unsigned int *length); + +typedef struct list_autofill_svc_response_item_s *rpc_port_list_autofill_svc_response_item_h; + +int rpc_port_list_autofill_svc_response_item_create(rpc_port_list_autofill_svc_response_item_h *h); + +int rpc_port_list_autofill_svc_response_item_destroy(rpc_port_list_autofill_svc_response_item_h h); + +int rpc_port_list_autofill_svc_response_item_clone(rpc_port_list_autofill_svc_response_item_h h, rpc_port_list_autofill_svc_response_item_h *clone); + +int rpc_port_list_autofill_svc_response_item_add_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, rpc_port_autofill_svc_response_item_h list_autofill_svc_response_items); + +int rpc_port_list_autofill_svc_response_item_foreach_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, + bool (*callback)(rpc_port_autofill_svc_response_item_h list_autofill_svc_response_items, void *user_data), void *user_data); + +int rpc_port_list_autofill_svc_response_item_remove_list_autofill_svc_response_items(rpc_port_list_autofill_svc_response_item_h h, unsigned int nth); + +int rpc_port_list_autofill_svc_response_item_get_list_autofill_svc_response_items_length(rpc_port_list_autofill_svc_response_item_h h, unsigned int *length); + +typedef struct AutofillSvcPort_context_s* rpc_port_stub_AutofillSvcPort_context_h; + +int rpc_port_stub_AutofillSvcPort_context_set_tag(rpc_port_stub_AutofillSvcPort_context_h ctx, void *tag); + +int rpc_port_stub_AutofillSvcPort_context_get_tag(rpc_port_stub_AutofillSvcPort_context_h ctx, void **tag); + +int rpc_port_stub_AutofillSvcPort_context_get_sender(rpc_port_stub_AutofillSvcPort_context_h ctx, char **sender); + +typedef struct AutofillSvcPort_autofill_svc_auth_info_cb_s *rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h; + +int rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_destroy(rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h h); + +int rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_clone(rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h h, rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h *clone); + +int rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_invoke(rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h h, rpc_port_autofill_svc_auth_info_h auth_info); + +typedef struct AutofillSvcPort_autofill_svc_fill_response_cb_s *rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h; + +int rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_destroy(rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h h); + +int rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_clone(rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h h, rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h *clone); + +int rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_invoke(rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h h, rpc_port_autofill_svc_fill_response_h response); + +typedef struct { + void (*create)(rpc_port_stub_AutofillSvcPort_context_h context, void *user_data); + void (*terminate)(rpc_port_stub_AutofillSvcPort_context_h context, void *user_data); + + int (*Register)(rpc_port_stub_AutofillSvcPort_context_h context, rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb, rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_cb, void *user_data); + void (*Unregister)(rpc_port_stub_AutofillSvcPort_context_h context, void *user_data); + void (*request_auth_info)(rpc_port_stub_AutofillSvcPort_context_h context, rpc_port_autofill_svc_view_info_h vi, void *user_data); + void (*send_fill_request)(rpc_port_stub_AutofillSvcPort_context_h context, rpc_port_autofill_svc_view_info_h vi, void *user_data); +} rpc_port_stub_AutofillSvcPort_callback_s; + +int rpc_port_stub_AutofillSvcPort_register(rpc_port_stub_AutofillSvcPort_callback_s *callback, void *user_data); + +int rpc_port_stub_AutofillSvcPort_unregister(void); + +int rpc_port_stub_AutofillSvcPort_get_client_number(unsigned int *n); + +#ifdef __cplusplus +} +#endif diff --git a/service_lib/capi-ui-autofill-service.manifest b/service_lib/capi-ui-autofill-service.manifest new file mode 100644 index 0000000..dfdc35c --- /dev/null +++ b/service_lib/capi-ui-autofill-service.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/service_lib/capi-ui-autofill-service.pc.in b/service_lib/capi-ui-autofill-service.pc.in new file mode 100644 index 0000000..7740411 --- /dev/null +++ b/service_lib/capi-ui-autofill-service.pc.in @@ -0,0 +1,14 @@ +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=@LIBDIR@ +includedir=/usr/include + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..63da7e6 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,46 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(autofill-test C) + +SET(SRCS + ecore_imf_example.c +) + +pkg_check_modules(pkgs_test REQUIRED + capi-base-common + dlog + ecore + ecore-evas + evas + eina + ecore-imf + ecore-imf-evas + capi-appfw-application + efl-extension + elementary +) + +INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include) + +FOREACH(flag ${pkgs_test_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_DEFINITIONS("-DEXPORTED=__attribute__((visibility(\"default\")))") + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +FIND_PROGRAM(UNAME NAMES uname) +EXEC_PROGRAM("${UNAME}" ARGS "-m" OUTPUT_VARIABLE "ARCH") +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") + MESSAGE("add -DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_test_LDFLAGS} capi-ui-autofill) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${TZ_SYS_RO_APP}/org.tizen.${PROJECT_NAME}/bin) +INSTALL(FILES ${CMAKE_BINARY_DIR}/test/org.tizen.autofill-test.xml DESTINATION ${TZ_SYS_RO_PACKAGES}) +#INSTALL(FILES ${CMAKE_BINARY_DIR}/test/autofill-test.manifest DESTINATION ${TZ_SYS_RO_PACKAGES}) diff --git a/test/ecore_imf_example.c b/test/ecore_imf_example.c new file mode 100644 index 0000000..56f876c --- /dev/null +++ b/test/ecore_imf_example.c @@ -0,0 +1,860 @@ +/** + * Ecore example illustrating how to use ecore imf. + * + * @verbatim + * gcc -o ecore_imf_example ecore_imf_example.c `pkg-config --cflags --libs ecore evas eina ecore-evas ecore-imf ecore-imf-evas` + * @endverbatim + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define WIDTH 720 +#define HEIGHT 1280 + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILL_TEST" + +typedef struct _Entry Entry; + +struct _Entry +{ + Evas_Object *rect; + Evas_Object *txt_obj; + Evas_Textblock_Style *txt_style; + Evas_Textblock_Cursor *cursor; + Evas_Textblock_Cursor *preedit_start; + Evas_Textblock_Cursor *preedit_end; + Ecore_IMF_Context *imf_context; + autofill_item_h ai_h; + Eina_Bool have_preedit : 1; +}; + +static Entry en1, en2; + +static autofill_view_info_h autofill_view_info = NULL; + +static void _imf_cursor_info_set(Entry *en); + +static void +_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info) +{ + Entry *en = data; + Evas_Event_Mouse_Down *ev = event_info; + if (!en) return; + + if (en->imf_context) + { + Ecore_IMF_Event_Mouse_Down ecore_ev; + ecore_imf_evas_event_mouse_down_wrap(ev, &ecore_ev); + if (ecore_imf_context_filter_event(en->imf_context, + ECORE_IMF_EVENT_MOUSE_DOWN, + (Ecore_IMF_Event *)&ecore_ev)) + return; + + // ecore_imf_context_reset should be called before calculating new cursor position + ecore_imf_context_reset(en->imf_context); + } + + // calculate new cursor position +} + +static void +_mouse_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info) +{ + Entry *en = data; + Evas_Event_Mouse_Up *ev = event_info; + if (!en) return; + + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) + { + _imf_cursor_info_set(en); + return; + } + + if (en->imf_context) + { + Ecore_IMF_Event_Mouse_Up ecore_ev; + ecore_imf_evas_event_mouse_up_wrap(ev, &ecore_ev); + if (ecore_imf_context_filter_event(en->imf_context, + ECORE_IMF_EVENT_MOUSE_UP, + (Ecore_IMF_Event *)&ecore_ev)) + return; + } + + if (en->rect) + { + if (evas_object_focus_get(en->rect)) + { + // notify cursor information + _imf_cursor_info_set(en); + } + else + evas_object_focus_set(en->rect, EINA_TRUE); + } +} + +static bool _fill_response_item_cb(autofill_fill_response_item_h item, void *user_data) +{ + char *id = NULL; + char *value = NULL; + char *presentation_text = NULL; + + char *id1 = NULL, *id2 = NULL; + + autofill_item_get_id(en1.ai_h, &id1); + autofill_item_get_id(en2.ai_h, &id2); + + autofill_fill_response_item_get_id(item, &id); + autofill_fill_response_item_get_presentation_text(item, &presentation_text); + autofill_fill_response_item_get_value(item, &value); + + LOGD("id : %s, value : %s, presentation text : %s", id, value, presentation_text); + + if (id1 && strcmp(id, id1) == 0) { + //ecore_imf_context_event_callback_call(en1.imf_context, ECORE_IMF_CALLBACK_AUTOFILL_DATA_SET, response_item->value); + //LOGD("autofill id : %s, value : %s", response_item->id, response_item->value); + evas_object_textblock_text_markup_prepend(en1.cursor, value); + //return; + } + + if (id2 && strcmp(id, id2) == 0) { + //ecore_imf_context_event_callback_call(en1.imf_context, ECORE_IMF_CALLBACK_AUTOFILL_DATA_SET, response_item->value); + //LOGD("autofill id : %s, value : %s", response_item->id, response_item->value); + evas_object_textblock_text_markup_prepend(en2.cursor, value); + //return; + } + + if (id) { + free(id); + } + + if (value) { + free(value); + } + + if (presentation_text) { + free(presentation_text); + } + + return true; +} + +static void +_autofill_fill_response_cb(autofill_fill_response_h fill_response, void *data) +{ + if (!fill_response) + return; + +#if 0 + if (eina_list_count(fill_response->autofill_fill_response_item_list) == 1) + { + response_item = (autofill_fill_response_item_h)eina_list_data_get(fill_response->autofill_fill_response_item_list); + + if (id1 && strcmp(response_item->id, id1) == 0) { + //ecore_imf_context_event_callback_call(en1.imf_context, ECORE_IMF_CALLBACK_AUTOFILL_DATA_SET, response_item->value); + LOGD("autofill id : %s, value : %s", response_item->id, response_item->value); + evas_object_textblock_text_markup_prepend(en1.cursor, response_item->value); + return; + } + + if (id2 && strcmp(response_item->id, id2) == 0) { + //ecore_imf_context_event_callback_call(en1.imf_context, ECORE_IMF_CALLBACK_AUTOFILL_DATA_SET, response_item->value); + LOGD("autofill id : %s, value : %s", response_item->id, response_item->value); + evas_object_textblock_text_markup_prepend(en2.cursor, response_item->value); + return; + } + + return; + } +#endif + + autofill_fill_response_foreach_items(fill_response, _fill_response_item_cb, NULL); +} + +static void +_autofill_auth_info_cb(autofill_auth_info_h auth_info, void *data) +{ + bool exist_autofill_data; + bool need_authentication; + char *service_name = NULL; + char *service_message = NULL; + char *service_logo_image_path = NULL; + + autofill_auth_info_get_exist_autofill_data(auth_info, &exist_autofill_data); + autofill_auth_info_get_need_authentication(auth_info, &need_authentication); + + autofill_auth_info_get_service_name(auth_info, &service_name); + autofill_auth_info_get_service_message(auth_info, &service_message); + autofill_auth_info_get_service_logo_image_path(auth_info, &service_logo_image_path); + + LOGD("exist : %d, need_auth : %d, service name : %s, logo path : %s, message : '%s'", exist_autofill_data, need_authentication, service_name, service_logo_image_path, service_message); + + if (service_message) + free(service_message); + + if (service_name) + free(service_name); + + if (service_logo_image_path) + free(service_logo_image_path); + + if (!exist_autofill_data) + return; + + if (need_authentication) + { + // FILL ME : show service info popup + return; + } + + LOGD("Send fill request"); + + autofill_fill_response_set_callback(_autofill_fill_response_cb, NULL); + autofill_fill_request(autofill_view_info); +} + +static void +_request_autofill_auth_info() +{ + autofill_auth_info_set_callback(_autofill_auth_info_cb, NULL); + autofill_auth_info_request(autofill_view_info); +} + +static void +_entry_focus_in_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Entry *en = data; + if (!en) return; + + if (en->imf_context) + ecore_imf_context_focus_in(en->imf_context); + + // notify the cursor information + _imf_cursor_info_set(en); + + _request_autofill_auth_info(); +} + +static void +_entry_focus_out_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info EINA_UNUSED) +{ + Entry *en = data; + if (!en) return; + + if (en->imf_context) + { + // ecore_imf_context_reset should be called for flushing the preedit string in focus-out event handler + ecore_imf_context_reset(en->imf_context); + ecore_imf_context_focus_out(en->imf_context); + } +} + +static void +_canvas_focus_in_cb(void *data EINA_UNUSED, Evas *e, void *event_info EINA_UNUSED) +{ + Entry *en; + Evas_Object *obj = evas_focus_get(e); + if (!obj) return; + + en = evas_object_data_get(obj, "Entry"); + if (en) + _entry_focus_in_cb(en, NULL, NULL, NULL); +} + +static void +_canvas_focus_out_cb(void *data EINA_UNUSED, Evas *e, void *event_info EINA_UNUSED) +{ + Entry *en; + Evas_Object *obj = evas_focus_get(e); + if (!obj) return; + + en = evas_object_data_get(obj, "Entry"); + if (en) + _entry_focus_out_cb(en, NULL, NULL, NULL); +} + +static void +_imf_cursor_info_set(Entry *en) +{ + Evas_Coord x, y, w, h; + Evas_Coord cx, cy, cw, ch; // cursor geometry + int cursor_pos; // cursor position in chars (Not bytes) + Evas_BiDi_Direction dir; + + if (!en) return; + + // get cursor geometry + if (en->txt_obj) + evas_object_geometry_get(en->txt_obj, &x, &y, &w, &h); + + if (en->cursor && en->imf_context) + { + evas_textblock_cursor_geometry_get(en->cursor, &cx, &cy, &cw, &ch, &dir, EVAS_TEXTBLOCK_CURSOR_BEFORE); + + // get cursor position + cursor_pos = evas_textblock_cursor_pos_get(en->cursor); + + ecore_imf_context_cursor_position_set(en->imf_context, cursor_pos); + ecore_imf_context_cursor_location_set(en->imf_context, x + cx, y + cy, cw, ch); + ecore_imf_context_bidi_direction_set(en->imf_context, (Ecore_IMF_BiDi_Direction)dir); + } +} + +static void +_preedit_del(Entry *en) +{ + if (!en || !en->have_preedit) return; + if (!en->preedit_start || !en->preedit_end) return; + if (!evas_textblock_cursor_compare(en->preedit_start, en->preedit_end)) return; + + // delete the preedit characters + evas_textblock_cursor_range_delete(en->preedit_start, en->preedit_end); +} + +static void +_preedit_clear(Entry *en) +{ + if (en->preedit_start) + { + evas_textblock_cursor_free(en->preedit_start); + en->preedit_start = NULL; + } + + if (en->preedit_end) + { + evas_textblock_cursor_free(en->preedit_end); + en->preedit_end = NULL; + } + + en->have_preedit = EINA_FALSE; +} + +static Eina_Bool +_ecore_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, char **text, int *cursor_pos) +{ + // This callback will be called when the Input Method Context module requests the surrounding context. + Entry *en = data; + const char *str; + + if (!en) return EINA_FALSE; + + str = evas_object_textblock_text_markup_get(en->txt_obj); + + if (text) + *text = str ? strdup(str) : strdup(""); + + // get the current position of cursor + if (cursor_pos && en->cursor) + *cursor_pos = evas_textblock_cursor_pos_get(en->cursor); + + return EINA_TRUE; +} + +static void +_ecore_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info) +{ + // called when the input method needs to delete all or part of the context surrounding the cursor + Entry *en = data; + Ecore_IMF_Event_Delete_Surrounding *ev = event_info; + Evas_Textblock_Cursor *del_start, *del_end; + int cursor_pos; + + if ((!en) || (!ev) || (!en->cursor)) return; + + // get the current cursor position + cursor_pos = evas_textblock_cursor_pos_get(en->cursor); + + // start cursor position to be deleted + del_start = evas_object_textblock_cursor_new(en->txt_obj); + evas_textblock_cursor_pos_set(del_start, cursor_pos + ev->offset); + + // end cursor position to be deleted + del_end = evas_object_textblock_cursor_new(en->txt_obj); + evas_textblock_cursor_pos_set(del_end, cursor_pos + ev->offset + ev->n_chars); + + // implement function to delete character(s) from 'cursor_pos+ev->offset' cursor position to 'cursor_pos + ev->offset + ev->n_chars' + evas_textblock_cursor_range_delete(del_start, del_end); + + evas_textblock_cursor_free(del_start); + evas_textblock_cursor_free(del_end); +} + +static void +_ecore_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info) +{ + Entry *en = data; + char *commit_str = (char *)event_info; + if (!en) return; + + // delete preedit string + _preedit_del(en); + _preedit_clear(en); + + printf("commit string : %s\n", commit_str); + + // insert the commit string in the editor + if (en->cursor && commit_str) + evas_object_textblock_text_markup_prepend(en->cursor, commit_str); + + // notify the cursor information + _imf_cursor_info_set(en); + + return; +} + +static void +_ecore_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx, void *event_info EINA_UNUSED) +{ + // example how to get preedit string + Entry *en = data; + char *preedit_string; + int cursor_pos; + Eina_List *attrs = NULL; + Eina_List *l; + Ecore_IMF_Preedit_Attr *attr; + Ecore_IMF_Context *imf_context = ctx; + int preedit_start_pos, preedit_end_pos; + int i; + Eina_Bool preedit_end_state = EINA_FALSE; + + if (!en || !en->cursor) return; + + // get preedit string and attributes + ecore_imf_context_preedit_string_with_attributes_get(imf_context, &preedit_string, &attrs, &cursor_pos); + printf("preedit string : %s\n", preedit_string); + + if (!strcmp(preedit_string, "")) + preedit_end_state = EINA_TRUE; + + // delete preedit + _preedit_del(en); + + preedit_start_pos = evas_textblock_cursor_pos_get(en->cursor); + + // insert preedit character(s) + if (strlen(preedit_string) > 0) + { + if (attrs) + { + EINA_LIST_FOREACH(attrs, l, attr) + { + if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB1) // style type + { + // apply appropriate style such as underline + } + else if (attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB2 || attr->preedit_type == ECORE_IMF_PREEDIT_TYPE_SUB3) + { + // apply appropriate style such as underline + } + } + + // insert code to display preedit string in your editor + evas_object_textblock_text_markup_prepend(en->cursor, preedit_string); + } + } + + if (!preedit_end_state) + { + // set preedit start cursor + if (!en->preedit_start) + en->preedit_start = evas_object_textblock_cursor_new(en->txt_obj); + evas_textblock_cursor_copy(en->cursor, en->preedit_start); + + // set preedit end cursor + if (!en->preedit_end) + en->preedit_end = evas_object_textblock_cursor_new(en->txt_obj); + evas_textblock_cursor_copy(en->cursor, en->preedit_end); + + preedit_end_pos = evas_textblock_cursor_pos_get(en->cursor); + + for (i = 0; i < (preedit_end_pos - preedit_start_pos); i++) + { + evas_textblock_cursor_char_prev(en->preedit_start); + } + + en->have_preedit = EINA_TRUE; + + // set cursor position + evas_textblock_cursor_pos_set(en->cursor, preedit_start_pos + cursor_pos); + } + + // notify the cursor information + _imf_cursor_info_set(en); + + EINA_LIST_FREE(attrs, attr) { + if (attr) + free(attr); + } + + free(preedit_string); +} + +static void +_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info) +{ + Entry *en = data; + Evas_Event_Key_Down *ev = event_info; + Eina_Bool control, alt, shift; + if ((!en) || (!ev->key) || (!en->cursor)) return; + + if (en->imf_context) + { + Ecore_IMF_Event_Key_Down ecore_ev; + ecore_imf_evas_event_key_down_wrap(ev, &ecore_ev); + if (ecore_imf_context_filter_event(en->imf_context, + ECORE_IMF_EVENT_KEY_DOWN, + (Ecore_IMF_Event *)&ecore_ev)) + return; + } + + control = evas_key_modifier_is_set(ev->modifiers, "Control"); + alt = evas_key_modifier_is_set(ev->modifiers, "Alt"); + shift = evas_key_modifier_is_set(ev->modifiers, "Shift"); + (void)alt; + (void)shift; + + if (!strcmp(ev->key, "BackSpace")) + { + if (evas_textblock_cursor_char_prev(en->cursor)) + { + evas_textblock_cursor_char_delete(en->cursor); + // notify the cursor information + _imf_cursor_info_set(en); + } + return; + } + else if (!strcmp(ev->key, "Delete") || + (!strcmp(ev->key, "KP_Delete") && !ev->string)) + { + // FILLME + } + else if ((control) && (!strcmp(ev->key, "v"))) + { + // ctrl + v + // FILLME + } + else if ((control) && (!strcmp(ev->key, "a"))) + { + // ctrl + a + // FILLME + } + else if ((control) && (!strcmp(ev->key, "A"))) + { + // ctrl + A + // FILLME + } + else if ((control) && ((!strcmp(ev->key, "c") || (!strcmp(ev->key, "Insert"))))) + { + // ctrl + c + // FILLME + } + else if ((control) && ((!strcmp(ev->key, "x") || (!strcmp(ev->key, "m"))))) + { + // ctrl + x + // FILLME + } + else if ((control) && (!strcmp(ev->key, "z"))) + { + // ctrl + z (undo) + // FILLME + } + else if ((control) && (!strcmp(ev->key, "y"))) + { + // ctrl + y (redo) + // FILLME + } + else if ((!strcmp(ev->key, "Return")) || (!strcmp(ev->key, "KP_Enter"))) + { + // FILLME + } + else + { + if (ev->string) + { + printf("key down string : %s\n", ev->string); + evas_object_textblock_text_markup_prepend(en->cursor, ev->string); + } + } + + // notify the cursor information + _imf_cursor_info_set(en); +} + +static void +_key_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info) +{ + Entry *en = data; + Evas_Event_Key_Up *ev = event_info; + + if (!en) return; + + if (en->imf_context) + { + Ecore_IMF_Event_Key_Up ecore_ev; + + ecore_imf_evas_event_key_up_wrap(ev, &ecore_ev); + if (ecore_imf_context_filter_event(en->imf_context, + ECORE_IMF_EVENT_KEY_UP, + (Ecore_IMF_Event *)&ecore_ev)) + return; + } +} + +static void +create_input_field(Evas *evas, Entry *en, const char *id, const char *label, bool sensitive, autofill_hint_e autofill_hint, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) +{ + if (!en) return; + + en->have_preedit = EINA_FALSE; + en->preedit_start = NULL; + en->preedit_end = NULL; + + // create the background for text input field + en->rect = evas_object_rectangle_add(evas); + evas_object_color_set(en->rect, 150, 150, 150, 255); // gray color + evas_object_move(en->rect, x, y); + evas_object_resize(en->rect, w, h); + evas_object_show(en->rect); + evas_object_data_set(en->rect, "Entry", en); + + // create text object for displaying text + en->txt_obj = evas_object_textblock_add(evas); + evas_object_color_set(en->txt_obj, 0, 0, 0, 255); + evas_object_pass_events_set(en->txt_obj, EINA_TRUE); + evas_object_move(en->txt_obj, x, y); + evas_object_resize(en->txt_obj, w, h); + evas_object_show(en->txt_obj); + + // set style on textblock + static const char *style_buf = + "DEFAULT='font=Sans font_size=30 color=#000 text_class=entry'" + "newline='br'" + "b='+ font=Sans:style=bold'"; + en->txt_style = evas_textblock_style_new(); + evas_textblock_style_set(en->txt_style, style_buf); + evas_object_textblock_style_set(en->txt_obj, en->txt_style); + + // create cursor + en->cursor = evas_object_textblock_cursor_new(en->txt_obj); + + // create input context + const char *default_id = ecore_imf_context_default_id_get(); + if (!default_id) + { + fprintf(stderr, "Can't create ecore_imf_context\n"); + return; + } + + autofill_item_create(&en->ai_h); + autofill_item_set_autofill_hint(en->ai_h, autofill_hint); + autofill_item_set_id(en->ai_h, id); + autofill_item_set_label(en->ai_h, label); + autofill_item_set_sensitive_data(en->ai_h, sensitive); + + en->imf_context = ecore_imf_context_add(default_id); + ecore_imf_context_client_canvas_set(en->imf_context, evas); + + // register key event handler + evas_object_event_callback_add(en->rect, EVAS_CALLBACK_KEY_DOWN, _key_down_cb, en); + evas_object_event_callback_add(en->rect, EVAS_CALLBACK_KEY_UP, _key_up_cb, en); + + // register mouse event handler + evas_object_event_callback_add(en->rect, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down_cb, en); + evas_object_event_callback_add(en->rect, EVAS_CALLBACK_MOUSE_UP, _mouse_up_cb, en); + + // register focus event handler + evas_object_event_callback_add(en->rect, EVAS_CALLBACK_FOCUS_IN, _entry_focus_in_cb, en); + evas_object_event_callback_add(en->rect, EVAS_CALLBACK_FOCUS_OUT, _entry_focus_out_cb, en); + + // register retrieve surrounding callback + ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context, _ecore_imf_retrieve_surrounding_cb, en); + + // register commit event callback + ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _ecore_imf_event_commit_cb, en); + + // register preedit changed event handler + ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _ecore_imf_event_preedit_changed_cb, en); + + // register surrounding delete event callback + ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _ecore_imf_event_delete_surrounding_cb, en); +} + +static void +delete_input_field(Entry *en) +{ + if (!en) return; + + autofill_item_destroy(en->ai_h); + + if (en->rect) + { + evas_object_del(en->rect); + en->rect = NULL; + } + + if (en->cursor) + { + evas_textblock_cursor_free(en->cursor); + en->cursor = NULL; + } + + if (en->preedit_start) + { + evas_textblock_cursor_free(en->preedit_start); + en->preedit_start = NULL; + } + + if (en->preedit_end) + { + evas_textblock_cursor_free(en->preedit_end); + en->preedit_end = NULL; + } + + if (en->txt_obj) + { + evas_object_del(en->txt_obj); + en->txt_obj = NULL; + } + + if (en->txt_style) + { + evas_textblock_style_free(en->txt_style); + en->txt_style = NULL; + } + + if (en->imf_context) + { + ecore_imf_context_del(en->imf_context); + en->imf_context = NULL; + } +} + +static void connection_status_changed_cb(autofill_connection_status_e status, void *user_data) +{ + switch (status) { + case AUTOFILL_CONNECTION_STATUS_CONNECTED: + LOGD("connected"); + break; + case AUTOFILL_CONNECTION_STATUS_DISCONNECTED: + LOGD("disconnected"); + break; + case AUTOFILL_CONNECTION_STATUS_REJECTED: + LOGD("rejected"); + break; + default: + break; + } +} + +static void __back_cb(void *data, Evas_Object *obj, void *event_info) +{ + LOGD(""); + ecore_main_loop_quit(); +} + +EXPORTED int +main(void) +{ + Ecore_Evas *ee; + Evas *evas; + + if (!ecore_evas_init()) + { + fprintf(stderr, "failed to call ecore_evas_init()\n"); + return EXIT_FAILURE; + } + + ecore_imf_init(); + + autofill_initialize(connection_status_changed_cb, NULL); + + // create a new window, with size=WIDTHxHEIGHT and default engine + ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL); + + if (!ee) + { + fprintf(stderr, "failed to call ecore_evas_new\n"); + return EXIT_FAILURE; + } + + ecore_evas_show(ee); + + // get the canvas off just-created window + evas = ecore_evas_get(ee); + if (!evas) + { + fprintf(stderr, "failed to call ecore_evas_get\n"); + return EXIT_FAILURE; + } + + // create input field rectangle + Evas_Object *bg = evas_object_rectangle_add(evas); + evas_object_move(bg, 0, 0); + evas_object_resize(bg, WIDTH, HEIGHT); + evas_object_color_set(bg, 255, 255, 255, 255); + evas_object_show(bg); + + eext_object_event_callback_add(bg, EEXT_CALLBACK_BACK, __back_cb, NULL); + + // register canvas focus in/out event handler + evas_event_callback_add(evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb, NULL); + evas_event_callback_add(evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _canvas_focus_out_cb, NULL); + + memset(&en1, 0, sizeof(en1)); + memset(&en2, 0, sizeof(en2)); + + // create input field 1 + create_input_field(evas, &en1, "id", "ID", false, AUTOFILL_HINT_ID, 40, 60, 400, 80); + + // create input field 2 + create_input_field(evas, &en2, "password", "Password", true, AUTOFILL_HINT_EMAIL_ADDRESS, 40, 180, 400, 80); + + char *app_id; + app_get_id(&app_id); + + // create autofill view info + autofill_view_info_create(&autofill_view_info); + autofill_view_info_set_app_id(autofill_view_info, app_id); + autofill_view_info_set_view_id(autofill_view_info, "login"); + autofill_view_info_add_item(autofill_view_info, en1.ai_h); + autofill_view_info_add_item(autofill_view_info, en2.ai_h); + + if (app_id) + free(app_id); + + // give focus to input field 1 + evas_object_focus_set(en1.rect, EINA_TRUE); + + ecore_main_loop_begin(); // begin mainloop + + delete_input_field(&en1); // delete input field 1 + delete_input_field(&en2); // delete input field 2 + + if (autofill_view_info) { + autofill_view_info_destroy(autofill_view_info); + autofill_view_info = NULL; + } + + evas_event_callback_del_full(evas, EVAS_CALLBACK_CANVAS_FOCUS_IN, _canvas_focus_in_cb, NULL); + evas_event_callback_del_full(evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT, _canvas_focus_out_cb, NULL); + + ecore_evas_free(ee); + + autofill_deinitialize(); + + ecore_imf_shutdown(); + ecore_evas_shutdown(); + + return 0; +} diff --git a/test/org.tizen.autofill-test.manifest b/test/org.tizen.autofill-test.manifest new file mode 100644 index 0000000..017d22d --- /dev/null +++ b/test/org.tizen.autofill-test.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/test/org.tizen.autofill-test.xml b/test/org.tizen.autofill-test.xml new file mode 100644 index 0000000..b14c751 --- /dev/null +++ b/test/org.tizen.autofill-test.xml @@ -0,0 +1,14 @@ + + + + Jihoon Kim + autofill-test + + + + + + http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/datasharing + + diff --git a/tidl/autofill.tidl b/tidl/autofill.tidl new file mode 100644 index 0000000..f35e84b --- /dev/null +++ b/tidl/autofill.tidl @@ -0,0 +1,42 @@ +struct autofill_item { + string id; + string label; + string value; + int autofill_hint; + bool is_sensitive_data; +} + +struct autofill_view_info { + string view_id; + list items; +} + +struct autofill_auth_info { + bool exist_autofill_data; + bool need_authentication; + + string service_name; + string service_logo_image_path; + string service_message; +} + +struct autofill_response_item { + string id; + string presentation_text; + string value; +} + +struct autofill_fill_response { + string view_id; + list response_items; +} + +interface AutofillAppPort { + void autofill_auth_info_cb(autofill_auth_info auth_info) delegate; + void autofill_fill_response_cb(autofill_fill_response response) delegate; + int Register(autofill_auth_info_cb auth_info_cb, autofill_fill_response_cb fill_response_cb); + void Unregister() async; + + void request_auth_info(autofill_view_info vi) async; + void send_fill_request(autofill_view_info vi) async; +} diff --git a/tidl/autofill_service.tidl b/tidl/autofill_service.tidl new file mode 100644 index 0000000..cc8967d --- /dev/null +++ b/tidl/autofill_service.tidl @@ -0,0 +1,45 @@ +struct autofill_svc_item { + string id; + string label; + string value; + int autofill_hint; + bool is_sensitive_data; +} + +struct autofill_svc_view_info { + string app_id; + string view_id; + list items; +} + +struct autofill_svc_auth_info { + string app_id; + bool exist_autofill_data; + bool need_authentication; + + string service_name; + string service_logo_image_path; + string service_message; +} + +struct autofill_svc_response_item { + string id; + string presentation_text; + string value; +} + +struct autofill_svc_fill_response { + string app_id; + string view_id; + list response_items; +} + +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; + 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; +}