From c3085ba6df24b696fedf781e948533a0f8fdbc19 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 7 Dec 2018 11:53:27 +0900 Subject: [PATCH 02/11] Upload initial version Change-Id: I0d7ccecb6ca5751af672bc344a34e2256a59ab5b Signed-off-by: Jihoon Kim --- .cproject | 621 +++++++++++++++++++++++++++++++++ .exportMap | 5 + .package-stamp | 1 + .project | 46 +++ .tproject | 12 + Build/appendix.mk | 1 + Build/basedef.mk | 34 ++ Build/build_c.mk | 113 ++++++ Build/build_edc.mk | 81 +++++ Build/build_po.mk | 64 ++++ Build/flags.mk | 16 + Build/funcs.mk | 50 +++ Build/makefile | 34 ++ Build/makefile.mk | 218 ++++++++++++ Build/platform.mk | 17 + Build/tooldef.mk | 70 ++++ LICENSE | 202 +++++++++++ build_def.prop | 6 + inc/autofill-daemon.h | 28 ++ project_def.prop | 58 ++++ src/autofill-daemon.c | 842 +++++++++++++++++++++++++++++++++++++++++++++ src/autofill_config.c | 106 ++++++ src/autofill_config.h | 39 +++ src/autofill_daemon_dlog.h | 81 +++++ tidl/autofill.tidl | 61 ++++ tidl/autofill_manager.tidl | 5 + tidl/autofill_service.tidl | 65 ++++ tizen-manifest.xml | 12 + 28 files changed, 2888 insertions(+) create mode 100644 .cproject create mode 100644 .exportMap create mode 100644 .package-stamp create mode 100644 .project create mode 100644 .tproject create mode 100644 Build/appendix.mk create mode 100644 Build/basedef.mk create mode 100644 Build/build_c.mk create mode 100644 Build/build_edc.mk create mode 100644 Build/build_po.mk create mode 100644 Build/flags.mk create mode 100644 Build/funcs.mk create mode 100644 Build/makefile create mode 100644 Build/makefile.mk create mode 100644 Build/platform.mk create mode 100644 Build/tooldef.mk create mode 100644 LICENSE create mode 100644 build_def.prop create mode 100644 inc/autofill-daemon.h create mode 100644 project_def.prop create mode 100644 src/autofill-daemon.c create mode 100644 src/autofill_config.c create mode 100644 src/autofill_config.h create mode 100644 src/autofill_daemon_dlog.h create mode 100644 tidl/autofill.tidl create mode 100644 tidl/autofill_manager.tidl create mode 100644 tidl/autofill_service.tidl create mode 100644 tizen-manifest.xml diff --git a/.cproject b/.cproject new file mode 100644 index 0000000..01aa971 --- /dev/null +++ b/.cproject @@ -0,0 +1,621 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.exportMap b/.exportMap new file mode 100644 index 0000000..de30516 --- /dev/null +++ b/.exportMap @@ -0,0 +1,5 @@ +{ + global: main; + _IO_*; + local: *; +}; diff --git a/.package-stamp b/.package-stamp new file mode 100644 index 0000000..40cbe59 --- /dev/null +++ b/.package-stamp @@ -0,0 +1 @@ +TPK \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..08ac931 --- /dev/null +++ b/.project @@ -0,0 +1,46 @@ + + + autofill-daemon + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + 1542586781108 + + 26 + + org.eclipse.ui.ide.multiFilter + 1.0-projectRelativePath-matches-false-false-*/.tpk + + + + 1542586781110 + + 6 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-project_def.prop + + + + diff --git a/.tproject b/.tproject new file mode 100644 index 0000000..658e81b --- /dev/null +++ b/.tproject @@ -0,0 +1,12 @@ + + + + + mobile-5.0 + + + + + + + diff --git a/Build/appendix.mk b/Build/appendix.mk new file mode 100644 index 0000000..2e06c34 --- /dev/null +++ b/Build/appendix.mk @@ -0,0 +1 @@ +# Appendix diff --git a/Build/basedef.mk b/Build/basedef.mk new file mode 100644 index 0000000..a762983 --- /dev/null +++ b/Build/basedef.mk @@ -0,0 +1,34 @@ +# Add inputs and outputs from these tool invocations to the build variables + + +OS_NAME := $(shell $(UNAME)) + + +#ifeq ($(origin BUILD_CONFIG), undefined) +BUILD_CONFIG ?= Debug +#endif + +#ifeq ($(origin ARCH), undefined) +ARCH ?= i386 +#endif + +#ifeq ($(origin PROJPATH), undefined) +PROJPATH ?= . +#endif + + +#ifeq ($(origin PROJ_PATH), undefined) +PROJ_PATH ?= $(PROJPATH) +#endif + +#ifeq ($(strip $(OUTPUT_DIR)),) +#OUTPUT_DIR ?= $(PROJ_PATH)/$(BUILD_CONFIG) +#endif + +#ifeq ($(strip $(BUILD_ARCH)),) +BUILD_ARCH ?= $(ARCH) +#endif + +#ifeq ($(strip $(ENVENTOR_PATH)),) +ENVENTOR_PATH ?= $(SDK_TOOLPATH)/enventor +#endif diff --git a/Build/build_c.mk b/Build/build_c.mk new file mode 100644 index 0000000..5fffeea --- /dev/null +++ b/Build/build_c.mk @@ -0,0 +1,113 @@ +# C/C++ build script + + +_FUNC_EXT2O = $(patsubst %.$(3),$(1)/%.o,$(2)) +_FUNC_C2O = $(call _FUNC_EXT2O,$(1),$(2),c) +_FUNC_CPP2O = $(call _FUNC_EXT2O,$(1),$(2),cpp) + + +# parameter : +# $(1) - C/C++ soruce file +# $(2) - output path +# $(3) - .ext +# $(4) - unique id +CONVERT_ESC_EXT_TO_O = $(addprefix $(2)/,$(notdir $(patsubst %.$(3),%-$(4).o,$(1)))) + +#CONVERT_ESC_C_TO_O = $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),c) +#CONVERT_ESC_CPP_TO_O = $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),cpp) + + +# parameter : +# $(1) - encoded one C/C++ soruce file +# $(2) - output path +# $(3) - ext title (C/C++) +# $(4) - ext (c/cpp) +# $(5) - compiler ($(CC)/$(CXX)) +# $(6) - build opt +# $(7) - build opt file +# output : +# $(8) - output files list +define C_BUILD_PROC_RAW +$(call CONVERT_ESC_EXT_TO_O,$(1),$(2),$(4),$(8)) : $(call DECODE_4MAKE,$(1)) $(7) + @echo ' Building file: $$<' + @echo ' Invoking: $(3) Compiler' + $$(call MAKEDIRS,$$(@D)) + $(5) -c "$$<" -o "$$@" $(6) -Wp,@$(7) + @echo ' Finished building: $$<' +$(9) += $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),$(4),$(8)) +endef + + +# parameter : +# $(1) - output paths +# $(2) - src paths +# $(3) - inc paths +# $(4) - inc files +# $(5) - Defs +# $(6) - UnDefs +# $(7) - compiler opt +# $(8) - compiler opt file +# $(9) - ext title (C/C++) +# $(10) - ext (c/cpp) +# $(11) - compiler ($(CC)/$(CXX)) +# output : +# $(12) - OBJS +# return : +# none +define C_PROC_RAW + +_OUTPUT_DIR := $$(strip $(1))# +_SRCS := $(2)# +_INCS := $(3)# +_INC_FILES := $(4)# +_DEFS := $(5)# +_UNDEFS := $(6)# + +_OPT := $(7) +_OPT_FILE := $(8) + +_EXT_TITLE := $(9) +_EXT := $(10) +_COMPILER := $(11) + +#_OUTPUT_FILES := $(12) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_SRCS)) +_ENC_SRCS := $$(filter %.$$(_EXT),$$(_ENC_SRCS)) + +ifneq ($$(strip $$(_SRCS)),) + +_NORMAL_SRCS := $$(filter-out %*.$$(_EXT),$$(_ENC_SRCS)) +_WIDLCARD_SRCS := $$(filter %*.$$(_EXT),$$(_ENC_SRCS)) + +_ALL_SRCS := $$(call DECODE_4MAKE,$$(_NORMAL_SRCS)) \ + $$(foreach var,$$(_WIDLCARD_SRCS),$$(call FIND_FILES_4MAKE,$$(call DECODE_4MAKE,$$(var)))) + +ifneq ($$(strip $$(_ALL_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_ALL_SRCS)) + +_CDEFS := $$(CDEFS) +_CDEFS += $$(addprefix -D,$$(_DEFS)) +_CDEFS += $$(addprefix -U,$$(_UNDEFS)) + +_ENC_C_INCS := $$(call ENCODE_4MAKE,$$(_INCS)) +_ENC_C_INCS := $$(addprefix -I,$$(_ENC_C_INCS)) + +_ENC_INC_FILES := $$(call ENCODE_4MAKE,$$(_INC_FILES)) +_ENC_INC_FILES += $$(addprefix -include,$$(_ENC_INC_FILES)) + +_C_INCS := $$(call DECODE_4MAKE,$$(_ENC_C_INCS) $$(_ENC_C_INC_FILES)) + +_DEFS := $$(_CDEFS) $$(_C_INCS) -I"pch" $$(_OPT) + +_UNIQUE_ID = $$(firstword $$(shell echo $$(var) | $$(CKSUM))) + +$$(foreach var,$$(_ENC_SRCS),$$(eval $$(call C_BUILD_PROC_RAW,$$(var),$$(_OUTPUT_DIR),$$(_EXT_TITLE),$$(_EXT),$$(_COMPILER),$$(_DEFS),$$(_OPT_FILE),$$(_UNIQUE_ID),$(12)))) + +endif # (_(strip _(_ALL_SRCS)),) + +endif # (_(strip _(_SRCS)),) + + +endef diff --git a/Build/build_edc.mk b/Build/build_edc.mk new file mode 100644 index 0000000..6f85fdd --- /dev/null +++ b/Build/build_edc.mk @@ -0,0 +1,81 @@ +# EDC build script + + +FUNC_EDC2EDJ = $(patsubst %.edc,$(2)/%.edj,$(1)) + +# parameter : +# $(1) - C/C++ soruce file +# $(2) - output path +CONVERT_ESC_EDC_TO_EDJ = $(call CONVERT_4MAKE_TO_OUT,$(call FUNC_EDC2EDJ,$(1),$(2))) + + +# parameter : +# $(1) - encoded one C/C++ soruce file +# $(2) - output path +# $(3) - build opt +# output : +# $(4) - output files list +define EDJ_BUILD_PROC_RAW +$(call CONVERT_ESC_EDC_TO_EDJ,$(1),$(2)) : $(call DECODE_4MAKE,$(1)) + @echo ' Building file: $$<' + @echo ' Invoking: EDC Resource Compiler' + $$(call MAKEDIRS,$$(@D)) + $$(EDJE_CC) $(3) "$$<" "$$@" + @echo ' Finished building: $$<' +$(4) += $(call CONVERT_ESC_EDC_TO_EDJ,$(1),$(2)) +endef + + +# parameter : +# $(1) - output paths +# $(2) - src paths +# $(3) - image inc paths +# $(4) - sound inc paths +# $(5) - font inc paths +# output : +# $(6) - OBJS +# return : +# none +define EDJ_PROC_RAW + +_OUTPUT_DIR := $$(strip $(1))# +_SRCS := $(2)# +_IMAGE_DIRS := $(3)# +_SOUND_DIRS := $(4)# +_FONT_DIRS := $(5)# + +ifneq ($$(strip $$(_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_SRCS)) + +_NORMAL_SRCS := $$(filter-out %*.edc,$$(_ENC_SRCS)) +_WIDLCARD_SRCS := $$(filter %*.edc,$$(_ENC_SRCS)) + +_ALL_SRCS := $$(call DECODE_4MAKE,$$(_NORMAL_SRCS)) \ + $$(foreach var,$$(_WIDLCARD_SRCS),$$(call FIND_FILES_4MAKE,$$(call DECODE_4MAKE,$$(var)))) + +ifneq ($$(strip $$(_ALL_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_ALL_SRCS)) + +_COMPILER_FLAGS := -id "$$(ENVENTOR_SHARED_RES_PATH)/images" +_COMPILER_FLAGS += -sd "$$(ENVENTOR_SHARED_RES_PATH)/sounds" +_COMPILER_FLAGS += -fd "$$(ENVENTOR_SHARED_RES_PATH)/fonts" + +ifneq ($$(strip $$(_IMAGE_DIRS)),) +_COMPILER_FLAGS += $$(addprefix -id ,$$(_IMAGE_DIRS)) +endif +ifneq ($$(strip $$(_SOUND_DIRS)),) +_COMPILER_FLAGS += $$(addprefix -sd ,$$(_SOUND_DIRS)) +endif +ifneq ($$(strip $$(_FONT_DIRS)),) +_COMPILER_FLAGS += $$(addprefix -fd ,$$(_FONT_DIRS)) +endif + +$$(foreach var,$$(_ENC_SRCS),$$(eval $$(call EDJ_BUILD_PROC_RAW,$$(var),$$(_OUTPUT_DIR),$$(_COMPILER_FLAGS),$(6)))) + +endif # (_(strip _(_ALL_SRCS)),) + +endif # (_(strip _(_SRCS)),) + +endef diff --git a/Build/build_po.mk b/Build/build_po.mk new file mode 100644 index 0000000..d88d71a --- /dev/null +++ b/Build/build_po.mk @@ -0,0 +1,64 @@ +# PO build script + + +_FUNC_PO2MO = $(patsubst %.po,$(2)/res/locale/%/LC_MESSAGES/$(3).mo,$(notdir $(1))) + + +# parameter : +# $(1) - C/C++ soruce file +# $(2) - output path +# $(3) - app name +CONVERT_ESC_PO_TO_MO = $(call CONVERT_4MAKE_TO_OUT,$(call _FUNC_PO2MO,$(1),$(2),$(3))) + + +# parameter : +# $(1) - encoded one C/C++ soruce file +# $(2) - output path +# $(3) - app name +# output : +# $(4) - output files list +define MO_BUILD_PROC_RAW +$(call CONVERT_ESC_PO_TO_MO,$(1),$(2),$(3)) : $(call DECODE_4MAKE,$(1)) + @echo ' Building file: $$<' + @echo ' Invoking: msgfmt String Formatter' + $$(call MAKEDIRS,$$(@D)) + $$(MSGFMT) -o "$$@" "$$<" + @echo ' Finished building: $$<' +$(4) += $(call CONVERT_ESC_PO_TO_MO,$(1),$(2),$(3)) +endef + + +# parameter : +# $(1) - output dir +# $(2) - src paths +# $(3) - app name +# output : +# $(4) - OBJS + +define MO_PROC_RAW + +_OUTPUT_DIR := $(1) +_SRCS := $(2) +_APPNAME := $(3) + +ifneq ($$(strip $$(_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_SRCS)) + +_NORMAL_SRCS := $$(filter-out %*.po,$$(_ENC_SRCS)) +_WIDLCARD_SRCS := $$(filter %*.po,$$(_ENC_SRCS)) + +_ALL_SRCS := $$(call DECODE_4MAKE,$$(_NORMAL_SRCS)) \ + $$(foreach var,$$(_WIDLCARD_SRCS),$$(call FIND_FILES_4MAKE,$$(call DECODE_4MAKE,$$(var)))) + +ifneq ($$(strip $$(_ALL_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_ALL_SRCS)) + +$$(foreach var,$$(_ENC_SRCS),$$(eval $$(call MO_BUILD_PROC_RAW,$$(var),$$(_OUTPUT_DIR),$$(_APPNAME),$(4)))) + +endif # (_(strip _(_ALL_SRCS)),) + +endif # (_(strip _(_SRCS)),) + +endef diff --git a/Build/flags.mk b/Build/flags.mk new file mode 100644 index 0000000..57fb49d --- /dev/null +++ b/Build/flags.mk @@ -0,0 +1,16 @@ + +DEBUG_OP = -g3 -D_DEBUG +CPP_DEBUG_OP = -D_DEBUG + +OPTIMIZATION_OP = -O0 +CPP_OPTIMIZATION_OP = + +COMPILE_FLAGS = $(DEBUG_OP) $(OPTIMIZATION_OP) -Wall -c -fmessage-length=0 + +CPP_COMPILE_FLAGS = $(CPP_DEBUG_OP) $(CPP_OPTIMIZATION_OP) + +LINK_FLAGS = + +AR_FLAGS = + +EDC_COMPILE_FLAGS = \ No newline at end of file diff --git a/Build/funcs.mk b/Build/funcs.mk new file mode 100644 index 0000000..3ba778b --- /dev/null +++ b/Build/funcs.mk @@ -0,0 +1,50 @@ + +BSLASH := \\# +NULL_CHAR := # +SPACE := \ # +COLON := :# +DOTDOT := ..# +SPACE_ESC := &sp;# +COLON_ESC := &co;# +SPACE_OUT := ~sp~# +COLON_OUT := ~co~# +DOTDOT_OUT := ~dtdt~# + +BSLASH2SLASH = $(subst $(BSLASH),/,$(1)) + +REMOVE_TAIL = $(patsubst %/,%,$(1)) + +#LOWER_CASE = $(shell echo translit($(1),[A-Z],[a-z])|$(M4)) +LOWER_CASE = $(shell echo $(1)|$(TR) [A-Z] [a-z]) + +#ifneq ($(findstring Windows,$(OS)),) +# ... +#endif + +FIND_FILES = $(shell $(FIND) $(1)/$(2) | $(SED) 's/^$(subst /,$(BSLASH)/,$(1))$(BSLASH)///') +FIND_FILES_ESC = $(shell $(FIND) $(1)/$(2) | $(SED) 's/^$(subst /,$(BSLASH)/,$(1))$(BSLASH)///' -e 's/:/$(BSLASH)&co;/g' -e 's/$(BSLASH) /$(BSLASH)&sp;/g') +FIND_FILES_4MAKE = $(shell $(FIND) $(1)/$(2) | $(SED) 's/^$(subst /,$(BSLASH)/,$(1))$(BSLASH)///') + +FIND_FILES_ABS = $(shell $(FIND) $(1)) +FIND_FILES_ABS_4MAKE = $(shell $(FIND) $(1) -e 's/$(BSLASH) /$(BSLASH)&sp;/g') +FIND_FILES_ABS_ESC = $(shell $(FIND) $(1) -e 's/:/$(BSLASH)&co;/g' -e 's/$(BSLASH) /$(BSLASH)&sp;/g') + +FIND_FILES_4MAKE = $(shell $(FIND) $(1) | $(SED) 's/ /\\\ /g') + +#ENCODE_ESC = $(shell echo $(1) | $(SED) -e 's/:/$(BSLASH)&co;/g' -e 's/$(BSLASH) /$(BSLASH)&sp;/g') +#DECODE_ESC = $(shell echo $(1) | $(SED) -e 's/$(BSLASH)&co;/:/g' -e 's/$(BSLASH)&sp;/$(BSLASH) / g') +ENCODE_ESC = $(subst $(SPACE),$(SPACE_ESC),$(subst $(COLON),$(COLON_ESC),$(1))) +DECODE_ESC = $(subst $(COLON_ESC),$(COLON),$(subst $(SPACE_ESC),$(SPACE),$(1))) +ENCODE_4MAKE = $(subst $(SPACE),$(SPACE_ESC),$(1)) +DECODE_4MAKE = $(subst $(SPACE_ESC),$(SPACE),$(1)) + +CONVERT_TO_OUT = $(subst $(DOTDOT),$(DOTDOT_OUT),$(subst $(COLON),$(COLON_OUT),$(subst $(SPACE),$(SPACE_OUT),$(1)))) +CONVERT_ESC_TO_OUT = $(subst $(DOTDOT),$(DOTDOT_OUT),$(subst $(COLON_ESC),$(COLON_OUT),$(subst $(SPACE_ESC),$(SPACE_OUT),$(1)))) +CONVERT_4MAKE_TO_OUT = $(subst $(DOTDOT),$(DOTDOT_OUT),$(subst $(COLON),$(COLON_OUT),$(subst $(SPACE_ESC),$(SPACE_OUT),$(1)))) + +PROC_NO_EXIST = $(if $(wildcard $(1)),,$(call $(2),$(1))) +define MAKEDIRS0 + @echo ' Building directory: $(1)' + @$(MKDIR) $(MKDIR_OP) $(subst $(BSLASH),/,$(1)) +endef +MAKEDIRS = $(call PROC_NO_EXIST,$(1),MAKEDIRS0) diff --git a/Build/makefile b/Build/makefile new file mode 100644 index 0000000..117b240 --- /dev/null +++ b/Build/makefile @@ -0,0 +1,34 @@ +# +# Usege : make -f /Build/makefile -C +# + +BUILD_SCRIPT_VERSION := 1.1.0 + +.PHONY : app_version app_build app_clean build_version + + +all : app_build + +clean : app_clean + +version : build_version + +#PROJ_ROOT = . +#BUILD_ROOT := $(PROJ_PATH)/Build# + +ifeq ($(MAKE_NAME),mingw32-make) +ifneq ($(SHELL),) +OPTIONS += --eval="SHELL=$(SHELL)" +endif +endif + +app_build : + @echo $(MAKE) -f "$(BUILD_ROOT)/makefile.mk" + @$(MAKE_BIN) -f "$(BUILD_ROOT)/makefile.mk" -C "$(PROJ_PATH)" $(OPTIONS) + +app_clean : + @$(MAKE) -f "$(BUILD_ROOT)/makefile.mk" -C "$(PROJ_PATH)" $(OPTIONS) clean + +build_version : + @echo makefile : $(BUILD_SCRIPT_VERSION) + @$(MAKE) -f "$(BUILD_ROOT)/makefile.mk" -C "$(PROJ_PATH)" $(OPTIONS) version diff --git a/Build/makefile.mk b/Build/makefile.mk new file mode 100644 index 0000000..ffe7594 --- /dev/null +++ b/Build/makefile.mk @@ -0,0 +1,218 @@ +# +# Usege : make -f /Build/makefile -C +# + +BUILD_SCRIPT_VERSION := 1.2.3 + +.PHONY : app_version app_clean build_version + + +all : app_build + +clean : app_clean + +version : build_version + +_BLANK :=# +_SPACE := $(_BLANK) $(_BLANK)# +_SPACE_4MAKE := \$(_SPACE)# + +NULL_CHAR :=# +SPACE := $(NULL_CHAR) $(NULL_CHAR)# + +PROJ_ROOT := . +_PROJ_ROOT_4MAKE := $(subst $(_SPACE),$(_SPACE_4MAKE),$(PROJ_ROOT))# +PROJ_ROOT=$(_PROJ_ROOT_4MAKE) +_BUILD_ROOT_4MAKE := $(subst $(_SPACE),$(_SPACE_4MAKE),$(BUILD_ROOT))# +BUILD_ROOT=$(_BUILD_ROOT_4MAKE) + +include $(BUILD_ROOT)/basedef.mk + +include $(PROJ_ROOT)/project_def.prop +-include $(PROJ_ROOT)/build_def.prop + +include $(BUILD_ROOT)/funcs.mk + +-include $(BUILD_ROOT)/tooldef.mk +-include $(BUILD_ROOT)/flags.mk +-include $(BUILD_ROOT)/platform.mk + + +APPTYPE := $(type) + +OUTPUT_DIR := $(PROJ_ROOT)/$(BUILD_CONFIG) +OBJ_OUTPUT := $(OUTPUT_DIR)/objs + +LOWER_APPNAME := $(call LOWER_CASE,$(APPNAME)) +APPID2 := $(subst $(basename $(APPID)).,,$(APPID)) + +ifeq ($(strip $(APPTYPE)),app) +APPFILE := $(OUTPUT_DIR)/$(LOWER_APPNAME) +endif +ifeq ($(strip $(APPTYPE)),staticLib) +APPFILE := $(OUTPUT_DIR)/lib$(LOWER_APPNAME).a +endif +ifeq ($(strip $(APPTYPE)),sharedLib) +APPFILE := $(OUTPUT_DIR)/lib$(LOWER_APPNAME).so +endif + +ifneq ($(strip $(PLATFORM_INCS)),) +PLATFORM_INCS_FILE := $(OBJ_OUTPUT)/platform_incs_file.inc +endif + +ifneq ($(strip $(RS_LIBRARIES)),) +RS_LIBRARIES_FILE := $(OBJ_OUTPUT)/platform_libs.file +endif + +OBJS_FILE := $(OBJ_OUTPUT)/target_objs.file + +include $(BUILD_ROOT)/build_c.mk + + +ifeq ($(strip $(APPTYPE)),app) +EXT_OP := -fPIE +endif +ifeq ($(strip $(APPTYPE)),staticLib) +EXT_OP := -fPIE +endif +ifeq ($(strip $(APPTYPE)),sharedLib) +EXT_OP := -fPIC +endif + +C_OPT := $(COMPILE_FLAGS) $(TC_COMPILER_MISC) $(RS_COMPILER_MISC) $(EXT_OP) --sysroot="$(SYSROOT)" -Werror-implicit-function-declaration $(M_OPT) $(USER_C_OPTS) +CPP_OPT := $(CPP_COMPILE_FLAGS) $(TC_COMPILER_MISC) $(RS_COMPILER_MISC) $(EXT_OP) --sysroot="$(SYSROOT)" -Werror-implicit-function-declaration $(M_OPT) $(USER_CPP_OPTS) +C_OPT_FILE := $(PLATFORM_INCS_FILE) + +OBJS := # + +# Global C/C++ +ifeq ($(strip $(USER_ROOT)),) +USER_ROOT := $(PROJ_ROOT) +endif +$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_SRCS),$(USER_INC_DIRS),$(USER_INC_FILES),$(USER_DEFS),$(USER_UNDEFS),$(C_OPT),$(C_OPT_FILE),C,c,$(CC),OBJS)) +$(foreach ext,cpp cxx cc c++ C,$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_SRCS),$(USER_INC_DIRS),$(USER_CPP_INC_FILES),$(USER_CPP_DEFS),$(USER_CPP_UNDEFS),$(CPP_OPT),$(C_OPT_FILE),C++,$(ext),$(CXX),OBJS))) + +# Individual C/C++ +ifneq ($(strip $(USER_EXT_C_KEYS)),) +$(foreach var,$(USER_EXT_C_KEYS),$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_EXT_$(var)_SRCS),$(USER_EXT_$(var)_INC_DIRS),$(USER_EXT_$(var)_INC_FILES),$(USER_EXT_$(var)_DEFS),$(USER_EXT_$(var)_UNDEFS),$(C_OPT),$(C_OPT_FILE),C,c,$(CC),OBJS))) +$(foreach ext,cpp cxx cc c++ C,$(foreach var,$(USER_EXT_C_KEYS),$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_EXT_$(var)_SRCS),$(USER_EXT_$(var)_INC_DIRS),$(USER_EXT_$(var)_CPP_INC_FILES),$(USER_EXT_$(var)_CPP_DEFS),$(USER_EXT_$(var)_CPP_UNDEFS),$(CPP_OPT),$(C_OPT_FILE),C++,$(ext),$(CXX),OBJS)))) +endif + + +ifneq ($(strip $(USER_LIB_DIRS)),) +_ENC_USER_LIB_DIRS := $(call ENCODE_4MAKE,$(USER_LIB_DIRS)) +_ENC_USER_LIB_DIRS := $(addprefix -L,$(_ENC_USER_LIB_DIRS)) +LIBPATHS := $(call DECODE_4MAKE,$(_ENC_USER_LIB_DIRS)) +endif + +LIBS += $(addprefix -l,$(USER_LIBS)) + +UOBJS += $(USER_OBJS) + +M_OPT = -MMD -MP -MF"$(@:%.o=%.d)" + +DEPS := $(OBJS:.o=.d) + +ifneq ($(strip $(DEPS)),) +-include $(PROJ_ROOT)/Build/$(DEPS) +endif + +# create platform_libs_files.lib to pass the libraries to ld +$(RS_LIBRARIES_FILE) : + @echo $(RS_LIBRARIES) > $@ + +# create objs_file.obj to pass the obj files to ld or ar +$(OBJS_FILE) : $(OBJS) + @echo $(OBJS) > $@ + +ifeq ($(strip $(APPTYPE)),app) +$(APPFILE) : $(OBJS_FILE) $(UOBJS) $(RS_LIBRARIES_FILE) + @echo ' Building target: $@' + @echo ' Invoking: C/C++ Linker' + $(call MAKEDIRS,$(@D)) + $(CXX) -o $(APPFILE) @$(OBJS_FILE) $(UOBJS) $(LIBS) $(LIBPATHS) $(LINK_FLAGS) $(TC_LINKER_MISC) $(RS_LINKER_MISC) -Xlinker --as-needed -pie -lpthread --sysroot="$(SYSROOT)" -Xlinker --version-script="$(PROJ_ROOT)/.exportMap" $(RS_LIB_PATHS) @$(RS_LIBRARIES_FILE) -Xlinker -rpath='$$ORIGIN/../lib' -Werror-implicit-function-declaration $(USER_LINK_OPTS) + @echo ' Finished building target: $@' +endif +ifeq ($(strip $(APPTYPE)),staticLib) +$(APPFILE) : $(OBJS_FILE) $(UOBJS) + @echo ' Building target: $@' + @echo ' Invoking: Archive utility' + $(call MAKEDIRS,$(@D)) + $(AR) -r $(APPFILE) @$(OBJS_FILE) $(AR_FLAGS) $(USER_LINK_OPTS) + @echo ' Finished building target: $@' +endif +ifeq ($(strip $(APPTYPE)),sharedLib) +$(APPFILE) : $(OBJS_FILE) $(UOBJS) $(RS_LIBRARIES_FILE) + @echo ' Building target: $@' + @echo ' Invoking: C/C++ Linker' + $(call MAKEDIRS,$(@D)) + $(CXX) -o $(APPFILE) @$(OBJS_FILE) $(UOBJS) $(LIBS) $(LIBPATHS) $(LINK_FLAGS) $(TC_LINKER_MISC) $(RS_LINKER_MISC) -Xlinker --as-needed -shared -lpthread --sysroot="$(SYSROOT)" $(RS_LIB_PATHS) @$(RS_LIBRARIES_FILE) $(USER_LINK_OPTS) + @echo ' Finished building target: $@' +endif + + +$(OBJ_OUTPUT) : + $(call MAKEDIRS,$@) + +$(OUTPUT_DIR) : + $(call MAKEDIRS,$@) + + +#ifneq ($(strip $(PLATFORM_INCS)),) +#$(PLATFORM_INCS_FILE) : $(OBJ_OUTPUT) +# @echo ' Building inc file: $@' +#ifneq ($(findstring Windows,$(OS)),) +#ifneq ($(findstring 3.82,$(MAKE_VERSION)),) +# $(file > $@,$(PLATFORM_INCS)) +#else +# @echo $(PLATFORM_INCS) > $@ +#endif +#else +# @echo '$(PLATFORM_INCS)' > $@ +#endif +#endif + + +include $(BUILD_ROOT)/build_edc.mk + +#ifeq ($(strip $(ENVENTOR_SHARED_RES_PATH)),) +ENVENTOR_SHARED_RES_PATH ?= $(ENVENTOR_PATH)/share/enventor +#endif + +EDJ_FILES := + +# Global EDCs +ifneq ($(strip $(USER_EDCS)),) +$(eval $(call EDJ_PROC_RAW,$(OUTPUT_DIR),$(USER_EDCS),$(USER_EDCS_IMAGE_DIRS),$(USER_EDCS_SOUND_DIRS),$(USER_EDCS_FONT_DIRS),EDJ_FILES)) +endif + +# Individual EDCs +ifneq ($(strip $(USER_EXT_EDC_KEYS)),) +$(foreach var,$(USER_EXT_EDC_KEYS),$(eval $(call EDJ_PROC_RAW,$(OUTPUT_DIR),$(USER_EXT_$(var)_EDCS),$(USER_EXT_$(var)_EDCS_IMAGE_DIRS),$(USER_EXT_$(var)_EDCS_SOUND_DIRS),$(USER_EXT_$(var)_EDCS_FONT_DIRS),EDJ_FILES))) +endif + + +include $(BUILD_ROOT)/build_po.mk + +MO_FILES := + +# Global POs +ifneq ($(strip $(USER_POS)),) +$(eval $(call MO_PROC_RAW,$(OUTPUT_DIR),$(USER_POS),$(APPID2),MO_FILES)) +endif + + +secondary-outputs : $(EDJ_FILES) $(MO_FILES) + +-include appendix.mk + +app_build : $(OUTPUT_DIR) $(APPFILE) secondary-outputs + @echo ========= done ========= + + +app_clean : + rm -f $(APPFILE) + rm -rf $(OUTPUT_DIR) + +build_version : + @echo makefile.mk : $(BUILD_SCRIPT_VERSION) \ No newline at end of file diff --git a/Build/platform.mk b/Build/platform.mk new file mode 100644 index 0000000..77c3ab0 --- /dev/null +++ b/Build/platform.mk @@ -0,0 +1,17 @@ +# Add inputs and outputs from these tool invocations to the build variables + +SYSROOT = $(SBI_SYSROOT) + +#USR_INCS := $(addprefix -I "$(SYSROOT),$(PLATFORM_INCS_EX)) +USR_INCS1 := $(addsuffix ",$(PLATFORM_INCS_EX)) +USR_INCS := $(addprefix -I "$(SYSROOT),$(USR_INCS1)) + +ifeq ($(strip $(PLATFORM_LIB_PATHS)),) +RS_LIB_PATHS := "$(SYSROOT)/usr/lib" +else +RS_LIB_PATHS := $(addprefix -L,$(PLATFORM_LIB_PATHS)) +endif + +RS_LIBRARIES := $(addprefix -l,$(RS_LIBRARIES_EX)) + +PLATFORM_INCS = $(USR_INCS) -I "$(SDK_PATH)/library" diff --git a/Build/tooldef.mk b/Build/tooldef.mk new file mode 100644 index 0000000..c62243c --- /dev/null +++ b/Build/tooldef.mk @@ -0,0 +1,70 @@ +# Add inputs and outputs from these tool invocations to the build variables + +ifneq ($(strip $(SHELL_BIN)),) +SHELL = $(SHELL_BIN) +else +SHELL = sh +endif + +ifneq ($(strip $(MKDIR_BIN)),) +MKDIR = $(MKDIR_BIN) +MKDIR_OP = -p +else +MKDIR = mkdir +MKDIR_OP = -p +endif + +ifneq ($(strip $(UNAME_BIN)),) +UNAME = $(UNAME_BIN) +else +UNAME = uname +endif + +ifneq ($(strip $(M4_BIN)),) +M4 = $(M4_BIN) +else +M4 = m4 +endif + +ifneq ($(strip $(TR_BIN)),) +TR = $(TR_BIN) +else +TR = tr +endif + +ifneq ($(strip $(FIND_BIN)),) +FIND = $(FIND_BIN) +else +FIND = find +endif + +ifneq ($(strip $(SED_BIN)),) +SED = $(SED_BIN) +else +SED = sed +endif + +ifneq ($(strip $(GREP_BIN)),) +GREP = $(GREP_BIN) +else +GREP = grep +endif + +ifneq ($(strip $(EDJE_CC_BIN)),) +EDJE_CC = $(EDJE_CC_BIN) +else +EDJE_CC = edje_cc +endif + +ifneq ($(strip $(MSGFMT_BIN)),) +MSGFMT = $(MSGFMT_BIN) +else +MSGFMT = msgfmt +endif + +ifneq ($(strip $(CKSUM_BIN)),) +CKSUM = $(CKSUM_BIN) +else +CKSUM = cksum +endif + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + 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/build_def.prop b/build_def.prop new file mode 100644 index 0000000..520f46f --- /dev/null +++ b/build_def.prop @@ -0,0 +1,6 @@ + +# Add pre/post build process +PREBUILD_DESC = +PREBUILD_COMMAND = tidlc -s -l C -i tidl/autofill.tidl -o autofill_stub; mv autofill_stub.h ./src/; mv autofill_stub.c ./src/; tidlc -p -l C -i tidl/autofill_service.tidl -o autofill_service_proxy; mv autofill_service_proxy.h ./src/; mv autofill_service_proxy.c ./src/; tidlc -s -l C -i tidl/autofill_manager.tidl -o autofill_manager_stub; mv autofill_manager_stub.h ./src/; mv autofill_manager_stub.c ./src/; +POSTBUILD_DESC = +POSTBUILD_COMMAND = diff --git a/inc/autofill-daemon.h b/inc/autofill-daemon.h new file mode 100644 index 0000000..3f761d3 --- /dev/null +++ b/inc/autofill-daemon.h @@ -0,0 +1,28 @@ +/* + * 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 __autofill-daemon_H__ +#define __autofill-daemon_H__ + +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "AUTOFILLD" + + +#endif /* __autofill-daemon_H__ */ diff --git a/project_def.prop b/project_def.prop new file mode 100644 index 0000000..2cc9827 --- /dev/null +++ b/project_def.prop @@ -0,0 +1,58 @@ + +# Project Name +APPNAME = autofilld + +# Project Type +type = app + +# Project Profile +profile = mobile-5.0 + +# C/CPP Sources +USER_SRCS = src/autofill-daemon.c src/autofill_service_proxy.c src/autofill_stub.c src/autofill_manager_stub.c src/autofill_config.c + +# EDC Sources +USER_EDCS = + +# PO Sources +USER_POS = + +# User Defines +USER_DEFS = TIZEN_DEPRECATION DEPRECATION_WARNING +USER_CPP_DEFS = + +# User Undefines +USER_UNDEFS = +USER_CPP_UNDEFS = + +# User Libraries +USER_LIBS = + +# User Objects +USER_OBJS = + +# User Includes +## C Compiler +USER_C_INC_DIRS = inc +USER_INC_FILES = +## C++ Compiler +USER_CPP_INC_DIRS = +USER_CPP_INC_FILES = + +USER_INC_DIRS = $(USER_C_INC_DIRS) $(USER_CPP_INC_DIRS) + +# User Library Path +USER_LIB_DIRS = lib + +# EDC Resource Path +USER_EDCS_IMAGE_DIRS = ${OUTPUT_DIR} +USER_EDCS_SOUND_DIRS = ${OUTPUT_DIR} +USER_EDCS_FONT_DIRS = ${OUTPUT_DIR} + +# EDC Flags +USER_EXT_EDC_KEYS = + +# Resource Filter +USER_RES_INCLUDE = +USER_RES_EXCLUDE = + diff --git a/src/autofill-daemon.c b/src/autofill-daemon.c new file mode 100644 index 0000000..3a4c9b3 --- /dev/null +++ b/src/autofill-daemon.c @@ -0,0 +1,842 @@ +/* + * 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_daemon_dlog.h" +#include "autofill_stub.h" +#include "autofill_service_proxy.h" +#include "autofill_manager_stub.h" +#include "autofill_config.h" + +static rpc_port_proxy_AutofillSvcPort_h svc_rpc_h = NULL; + +static int connect_service(); + +typedef struct { + char *app_id; + int context_id; + + rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_cb; + rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_received_cb; +} autofill_client_s; + +static GList *__client_list = NULL; + +static autofill_client_s * +get_autofill_client(const char *app_id, int context_id) +{ + GList *iter; + autofill_client_s *client; + + iter = __client_list; + while (iter) { + client = iter->data; + + iter = g_list_next(iter); + + if (!client) { + LOGW("Warning: value is NULL"); + continue; + } + + if ((client->context_id == context_id) && + client->app_id && strcmp(client->app_id, app_id) == 0) { + return client; + } + } + + return NULL; +} + +static autofill_client_s *__create_client(const char *app_id, int context_id, + rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_cb, + rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_received_cb) +{ + LOGD(""); + autofill_client_s *handle; + + handle = calloc(1, sizeof(autofill_client_s)); + if (!handle) { + LOGE("Out of memory"); + return NULL; + } + + handle->app_id = strdup(app_id); + if (!handle->app_id) { + LOGE("Out of memory"); + free(handle); + return NULL; + } + + handle->context_id = context_id; + + rpc_port_AutofillAppPort_autofill_auth_info_received_cb_clone(auth_info_cb, &handle->auth_info_cb); + if (!handle->auth_info_cb) { + LOGE("Out of memory"); + free(handle->app_id); + free(handle); + return NULL; + } + + rpc_port_AutofillAppPort_autofill_fill_response_received_cb_clone(fill_response_received_cb, &handle->fill_response_received_cb); + + if (!handle->fill_response_received_cb) { + LOGE("Out of memory"); + free(handle->app_id); + rpc_port_AutofillAppPort_autofill_auth_info_received_cb_destroy(handle->auth_info_cb); + free(handle); + return NULL; + } + + return handle; +} + +static void __destroy_client(gpointer data) +{ + LOGD(""); + autofill_client_s *handle = data; + + if (!handle) + return; + + if (handle->auth_info_cb) { + rpc_port_AutofillAppPort_autofill_auth_info_received_cb_destroy(handle->auth_info_cb); + handle->auth_info_cb = NULL; + } + + if (handle->fill_response_received_cb) { + rpc_port_AutofillAppPort_autofill_fill_response_received_cb_destroy(handle->fill_response_received_cb); + handle->fill_response_received_cb = NULL; + } + + if (handle->app_id) { + free(handle->app_id); + handle->app_id = NULL; + } + + free(handle); +} + +static void __remove_client(rpc_port_stub_AutofillAppPort_context_h context) +{ + autofill_client_s *client = NULL; + rpc_port_stub_AutofillAppPort_context_get_tag(context, (void *)&client); + if (!client) + return; + + rpc_port_stub_AutofillAppPort_context_set_tag(context, NULL); + + LOGI("name(%s)", client->app_id); + + __client_list = g_list_remove(__client_list, client); + __destroy_client(client); +} + +static void __message_create(rpc_port_stub_AutofillAppPort_context_h context, + void *user_data) +{ + LOGD(""); + char *sender = NULL; + + rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender); + if (!sender) + return; + + LOGD("sender(%s)", sender); + free(sender); +} + +static void __message_terminate(rpc_port_stub_AutofillAppPort_context_h context, + void *user_data) +{ + LOGD(""); + char *sender = NULL; + + rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender); + if (!sender) + return; + + LOGD("[__RPC_PORT__] sender(%s)", sender); + free(sender); + + __remove_client(context); +} + +static int __message_register(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_cb, rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_received_cb, void *user_data) +{ + LOGD(""); + char *sender = NULL; + autofill_client_s *client = NULL; + + rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender); + if (!sender) + return -1; + + LOGD("sender(%s)", sender); + + client = __create_client(sender, context_id, auth_info_cb, fill_response_received_cb); + free(sender); + + if (!client) + return -1; + + __client_list = g_list_append(__client_list, client); + + rpc_port_stub_AutofillAppPort_context_set_tag(context, client); + + return 0; +} + +static void __message_unregister(rpc_port_stub_AutofillAppPort_context_h context, int context_id, void *user_data) +{ + __remove_client(context); +} + +static void __manager_create(rpc_port_stub_AutofillManagerPort_context_h context, + void *user_data) +{ + LOGD(""); +} + +static void __manager_terminate(rpc_port_stub_AutofillManagerPort_context_h context, + void *user_data) +{ + LOGD(""); +} + +bool __view_info_item_cb(rpc_port_autofill_item_h items, void *user_data) +{ + char *id = NULL; + char *label = NULL; + char *value = NULL; + int autofill_hint; + bool sensitive_data; + + rpc_port_autofill_svc_view_info_h svi = (rpc_port_autofill_svc_view_info_h)user_data; + + rpc_port_autofill_svc_item_h svc_item; + + rpc_port_autofill_svc_item_create(&svc_item); + + rpc_port_autofill_item_get_id(items, &id); + rpc_port_autofill_svc_item_set_id(svc_item, id); + if (id) { + free(id); + } + + rpc_port_autofill_item_get_label(items, &label); + rpc_port_autofill_svc_item_set_label(svc_item, label); + if (label) { + free(label); + } + + rpc_port_autofill_item_get_value(items, &value); + rpc_port_autofill_svc_item_set_value(svc_item, value); + if (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); + + rpc_port_autofill_item_get_is_sensitive_data(items, &sensitive_data); + rpc_port_autofill_svc_item_set_is_sensitive_data(svc_item, sensitive_data); + + rpc_port_autofill_svc_view_info_add_items(svi, svc_item); + + rpc_port_autofill_svc_item_destroy(svc_item); + + return true; +} + +bool __save_item_cb(rpc_port_autofill_save_item_h items, void *user_data) +{ + char *id = NULL; + char *label = NULL; + char *value = NULL; + int autofill_hint; + bool sensitive_data; + + rpc_port_autofill_svc_save_view_info_h svi = (rpc_port_autofill_svc_save_view_info_h)user_data; + + rpc_port_autofill_svc_save_item_h svc_save_item; + + rpc_port_autofill_svc_save_item_create(&svc_save_item); + + rpc_port_autofill_save_item_get_id(items, &id); + rpc_port_autofill_svc_save_item_set_id(svc_save_item, id); + if (id) { + free(id); + } + + rpc_port_autofill_save_item_get_label(items, &label); + rpc_port_autofill_svc_save_item_set_label(svc_save_item, label); + if (label) { + free(label); + } + + rpc_port_autofill_save_item_get_value(items, &value); + rpc_port_autofill_svc_save_item_set_value(svc_save_item, value); + if (value) { + free(value); + } + + rpc_port_autofill_save_item_get_autofill_hint(items, &autofill_hint); + rpc_port_autofill_svc_save_item_set_autofill_hint(svc_save_item, autofill_hint); + + rpc_port_autofill_save_item_get_is_sensitive_data(items, &sensitive_data); + rpc_port_autofill_svc_save_item_set_is_sensitive_data(svc_save_item, sensitive_data); + + rpc_port_autofill_svc_save_view_info_add_items(svi, svc_save_item); + + rpc_port_autofill_svc_save_item_destroy(svc_save_item); + + return true; +} + +static int __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_view_info_h vi, void *user_data) +{ + char *sender = NULL; + autofill_client_s *sender_client; + + if (!svc_rpc_h) { + LOGW("Not initialized"); + return -1; + } + + rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender); + char *view_id = NULL; + + rpc_port_autofill_view_info_get_view_id(vi, &view_id); + LOGD("app id : %s, view id : %s", sender, view_id); + + rpc_port_stub_AutofillAppPort_context_get_tag(context, (void *)&sender_client); + + /* create view info */ + rpc_port_autofill_svc_view_info_h svi; + rpc_port_autofill_svc_view_info_create(&svi); + rpc_port_autofill_svc_view_info_set_app_id(svi, sender); + rpc_port_autofill_svc_view_info_set_view_id(svi, view_id); + + rpc_port_autofill_view_info_foreach_items(vi, __view_info_item_cb, svi); + + rpc_port_proxy_AutofillSvcPort_invoke_request_auth_info(svc_rpc_h, context_id, svi); + + if (sender) { + free(sender); + } + + if (view_id) { + free(view_id); + } + + rpc_port_autofill_svc_view_info_destroy(svi); + + return 0; +} + +static int __autofill_fill_request_cb(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_view_info_h vi, void *user_data) +{ + char *sender = NULL; + char *view_id = NULL; + + if (!svc_rpc_h) { + LOGW("Not initialized"); + return -1; + } + + rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender); + rpc_port_autofill_view_info_get_view_id(vi, &view_id); + + LOGD("app id : %s, view id : %s, context id : %d", sender, view_id, context_id); + + rpc_port_autofill_svc_view_info_h svi; + rpc_port_autofill_svc_view_info_create(&svi); + rpc_port_autofill_svc_view_info_set_app_id(svi, sender); + rpc_port_autofill_svc_view_info_set_view_id(svi, view_id); + + rpc_port_autofill_view_info_foreach_items(vi, __view_info_item_cb, svi); + + rpc_port_proxy_AutofillSvcPort_invoke_send_fill_request(svc_rpc_h, context_id, svi); + + if (sender) + free(sender); + + if (view_id) + free(view_id); + + rpc_port_autofill_svc_view_info_destroy(svi); + + return 0; +} + +static int __commit_cb(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_save_view_info_h vi, void *user_data) +{ + char *sender = NULL; + autofill_client_s *sender_client; + + if (!svc_rpc_h) { + LOGW("Not initialized"); + return -1; + } + + rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender); + if (sender) { + LOGD("sender(%s)", sender); + free(sender); + } + + char *view_id = NULL; + rpc_port_autofill_save_view_info_get_view_id(vi, &view_id); + if (view_id) { + LOGD("view id : %s", view_id); + } + + rpc_port_autofill_svc_save_view_info_h svi; + rpc_port_autofill_svc_save_view_info_create(&svi); + rpc_port_autofill_svc_save_view_info_set_view_id(svi, view_id); + + rpc_port_stub_AutofillAppPort_context_get_tag(context, (void *)&sender_client); + rpc_port_autofill_save_view_info_foreach_items(vi, __save_item_cb, svi); + + rpc_port_proxy_AutofillSvcPort_invoke_commit(svc_rpc_h, context_id, svi); + + if (view_id) + free(view_id); + + rpc_port_autofill_svc_save_view_info_destroy(svi); + + return 0; +} + +bool fill_response_item_cb(rpc_port_autofill_svc_response_item_h response_items, void *user_data) +{ + rpc_port_autofill_response_group_h res_group = (rpc_port_autofill_response_group_h)user_data; + + char *id = NULL; + char *presentation_text = NULL; + char *value = NULL; + + rpc_port_autofill_response_item_h res_item; + + rpc_port_autofill_response_item_create(&res_item); + + rpc_port_autofill_svc_response_item_get_id(response_items, &id); + rpc_port_autofill_response_item_set_id(res_item, id); + + rpc_port_autofill_svc_response_item_get_presentation_text(response_items, &presentation_text); + rpc_port_autofill_response_item_set_presentation_text(res_item, presentation_text); + + rpc_port_autofill_svc_response_item_get_value(response_items, &value); + rpc_port_autofill_response_item_set_value(res_item, value); + + rpc_port_autofill_response_group_add_response_items(res_group, res_item); + + if (id) + free(id); + + if (presentation_text) + free(presentation_text); + + if (value) + free(value); + + rpc_port_autofill_response_item_destroy(res_item); + + return true; +} + +bool fill_response_group_cb(rpc_port_autofill_svc_response_group_h response_groups, void *user_data) +{ + rpc_port_autofill_fill_response_h fr_h = (rpc_port_autofill_fill_response_h)user_data; + + rpc_port_autofill_response_group_h res_group; + rpc_port_autofill_response_group_create(&res_group); + + rpc_port_autofill_svc_response_group_foreach_response_items(response_groups, fill_response_item_cb, res_group); + + rpc_port_autofill_fill_response_add_response_groups(fr_h, res_group); + + rpc_port_autofill_response_group_destroy(res_group); + + return true; +} + +static void __fill_response_recv_cb(void *user_data, int context_id, rpc_port_autofill_svc_fill_response_h response_h) +{ + // recv fill response from service + char *view_id = NULL; + char *app_id = NULL; + + rpc_port_autofill_svc_fill_response_get_app_id(response_h, &app_id); + rpc_port_autofill_svc_fill_response_get_view_id(response_h, &view_id); + + /* create autofill response */ + rpc_port_autofill_fill_response_h fill_response_h; + rpc_port_autofill_fill_response_create(&fill_response_h); + rpc_port_autofill_fill_response_set_view_id(fill_response_h, view_id); + + rpc_port_autofill_svc_fill_response_foreach_response_groups(response_h, fill_response_group_cb, fill_response_h); + + autofill_client_s *sender_client = get_autofill_client(app_id, context_id); + if (sender_client) + rpc_port_AutofillAppPort_autofill_fill_response_received_cb_invoke(sender_client->fill_response_received_cb, fill_response_h); + + rpc_port_autofill_fill_response_destroy(fill_response_h); + + if (app_id) + free(app_id); + + if (view_id) + free(view_id); +} + +static void __auth_info_recv_cb(void *user_data, int context_id, rpc_port_autofill_svc_auth_info_h svc_auth_info_h) +{ + bool exist_autofill_data; + bool need_authentication; + char *service_name = NULL; + char *service_logo_image_path = NULL; + char *service_message = NULL; + char *app_id = NULL; + char *view_id = NULL; + + rpc_port_autofill_svc_auth_info_get_app_id(svc_auth_info_h, &app_id); + rpc_port_autofill_svc_auth_info_get_view_id(svc_auth_info_h, &view_id); + rpc_port_autofill_svc_auth_info_get_exist_autofill_data(svc_auth_info_h, &exist_autofill_data); + rpc_port_autofill_svc_auth_info_get_need_authentication(svc_auth_info_h, &need_authentication); + rpc_port_autofill_svc_auth_info_get_service_name(svc_auth_info_h, &service_name); + rpc_port_autofill_svc_auth_info_get_service_logo_image_path(svc_auth_info_h, &service_logo_image_path); + rpc_port_autofill_svc_auth_info_get_service_message(svc_auth_info_h, &service_message); + + LOGD("app id : %s, service name : %s, message : %s, logo path : %s", app_id, service_name, service_message, service_logo_image_path); + + /* transfer auth info */ + rpc_port_autofill_auth_info_h auth_info_h; + rpc_port_autofill_auth_info_create(&auth_info_h); + rpc_port_autofill_auth_info_set_view_id(auth_info_h, view_id); + rpc_port_autofill_auth_info_set_exist_autofill_data(auth_info_h, exist_autofill_data); + rpc_port_autofill_auth_info_set_need_authentication(auth_info_h, need_authentication); + rpc_port_autofill_auth_info_set_service_name(auth_info_h, service_name); + rpc_port_autofill_auth_info_set_service_message(auth_info_h, service_message); + rpc_port_autofill_auth_info_set_service_logo_image_path(auth_info_h, service_logo_image_path); + + autofill_client_s *sender_client = get_autofill_client(app_id, context_id); + if (sender_client) + rpc_port_AutofillAppPort_autofill_auth_info_received_cb_invoke(sender_client->auth_info_cb, auth_info_h); + + rpc_port_autofill_auth_info_destroy(auth_info_h); + + if (app_id) + free(app_id); + + if (view_id) + free(view_id); + + if (service_name) + free(service_name); + + if (service_logo_image_path) + free(service_logo_image_path); + + if (service_message) + free(service_message); +} + +static void __on_connected(rpc_port_proxy_AutofillSvcPort_h h, void *user_data) +{ + LOGI("[__RPC_PORT__] connected"); + + rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_h fill_response_received_cb_h = rpc_port_AutofillSvcPort_autofill_svc_fill_response_cb_create(__fill_response_recv_cb, false, NULL); + rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_h auth_info_cb_h = rpc_port_AutofillSvcPort_autofill_svc_auth_info_cb_create(__auth_info_recv_cb, false, NULL); + + int r = rpc_port_proxy_AutofillSvcPort_invoke_Register(h, auth_info_cb_h, fill_response_received_cb_h); + if (r != 0) + LOGD("Failed to invoke Register"); +} + +//LCOV_EXCL_START +static void __on_disconnected(rpc_port_proxy_AutofillSvcPort_h h, void *user_data) +{ + LOGD("disconnected"); + + svc_rpc_h = NULL; +} + +static void __on_rejected(rpc_port_proxy_AutofillSvcPort_h h, void *user_data) +{ + LOGD("rejected"); +} +//LCOV_EXCL_STOP + +static bool __manager_set_autofill_service_cb(rpc_port_stub_AutofillManagerPort_context_h context, const char *app_id, void *user_data) +{ + LOGD("app id : %s", app_id); + + if (app_id) + autofill_config_set_autofill_service_app_id(app_id); + + if (svc_rpc_h) { + LOGD("send terminate"); + // terminate service + rpc_port_proxy_AutofillSvcPort_invoke_request_terminate(svc_rpc_h); + + int ret = rpc_port_proxy_AutofillSvcPort_destroy(svc_rpc_h); + LOGD("ret : %d", ret); + } + else { + LOGW("Not initialized"); + return false; + } + svc_rpc_h = NULL; + + connect_service(); + + return true; +} + +static char * __manager_get_autofill_service_cb(rpc_port_stub_AutofillManagerPort_context_h context, void *user_data) +{ + if (!svc_rpc_h) { + LOGW("Not initialized"); + return false; + } + + char *app_id; + autofill_config_get_autofill_service_app_id(&app_id); + + LOGD("app id : %s", app_id); + + return app_id; +} + +bool add_autofill_service_cb(app_info_h app_info, void *user_data) +{ + char *app_id = NULL; + rpc_port_list_string_h service_info_list = (rpc_port_list_string_h)user_data; + + int ret = app_info_get_app_id(app_info, &app_id); + if (ret != APP_MANAGER_ERROR_NONE) { + LOGW("app_info_get_app_id failed (%d)", ret); + return true; + } + + LOGD("Find autofill service : %s", app_id); + + rpc_port_list_string_add_list_strings(service_info_list, app_id); + + if (app_id) { + free(app_id); + } + + return true; +} + +static bool __manager_get_autofill_service_list_cb(rpc_port_stub_AutofillManagerPort_context_h context, rpc_port_list_string_h *service_info_list, void *user_data) +{ + int ret; + app_info_metadata_filter_h handle = NULL; + + // Get the Autofill service list + ret = app_info_metadata_filter_create(&handle); + if (ret != APP_MANAGER_ERROR_NONE) { + LOGW("app_info_metadata_filter_create failed (%d)", ret); + app_info_metadata_filter_destroy(handle); + return false; + } + + ret = app_info_metadata_filter_add(handle, "autofill-service", "true"); + if (ret != APP_MANAGER_ERROR_NONE) { + LOGW("app_info_metadata_filter_add failed (%d)", ret); + app_info_metadata_filter_destroy(handle); + return false; + } + + rpc_port_list_string_h app_id_list_h; + rpc_port_list_string_create(&app_id_list_h); + + ret = app_info_metadata_filter_foreach(handle, add_autofill_service_cb, app_id_list_h); + if (ret != APP_MANAGER_ERROR_NONE) { + LOGW("app_info_metadata_filter_foreach failed (%d)", ret); + } + + *service_info_list = app_id_list_h; + + app_info_metadata_filter_destroy(handle); + + return true; +} + +static int connect_service() +{ + int ret; + + rpc_port_proxy_AutofillSvcPort_callback_s rpc_callback = { + .connected = __on_connected, + .disconnected = __on_disconnected, + .rejected = __on_rejected + }; + + if (svc_rpc_h) { + LOGI("already connected\n"); + return RPC_PORT_ERROR_NONE; + } + + char *active_autofill_service_id = NULL; + autofill_config_get_autofill_service_app_id(&active_autofill_service_id); + LOGD("autofill service : %s", active_autofill_service_id); + + if (!active_autofill_service_id) { + active_autofill_service_id = strdup(AUTOFILL_SERVICE_APP_ID); + } + + if (active_autofill_service_id) { + autofill_config_set_autofill_service_app_id(active_autofill_service_id); + ret = rpc_port_proxy_AutofillSvcPort_create(active_autofill_service_id, &rpc_callback, NULL, &svc_rpc_h); + free(active_autofill_service_id); + if (ret != RPC_PORT_ERROR_NONE) { + LOGW("Failed to create rpc port. err = %d", ret); + return false; + } + } + + ret = rpc_port_proxy_AutofillSvcPort_connect(svc_rpc_h); + if (ret != RPC_PORT_ERROR_NONE) { + LOGW("Failed to connect. err = %d", ret); + return false; + } + + return ret; +} + +bool service_app_create(void *data) +{ + // Todo: add your code here. + LOGD(""); + + int ret; + // register app port + rpc_port_stub_AutofillAppPort_callback_s callback = { + __message_create, + __message_terminate, + __message_register, + __message_unregister, + __auth_info_request_cb, + __autofill_fill_request_cb, + __commit_cb, + }; + + ret = rpc_port_stub_AutofillAppPort_register(&callback, NULL); + if (ret != 0) + LOGI("Failed to register app port"); + else + LOGI("Succeeded to register app port"); + + // register manager port + rpc_port_stub_AutofillManagerPort_callback_s manager_callback = { + __manager_create, + __manager_terminate, + __manager_set_autofill_service_cb, + __manager_get_autofill_service_cb, + __manager_get_autofill_service_list_cb, + }; + + ret = rpc_port_stub_AutofillManagerPort_register(&manager_callback, NULL); + if (ret != 0) + LOGI("Failed to register manager port"); + else + LOGI("Succeeded to register manager port"); + + connect_service(); + + return true; +} + +void service_app_terminate(void *data) +{ + // Todo: add your code here. + LOGD(""); + + if (__client_list) { + g_list_free_full(__client_list, __destroy_client); + __client_list = NULL; + } + + rpc_port_stub_AutofillAppPort_unregister(); + + return; +} + +void service_app_control(app_control_h app_control, void *data) +{ + // Todo: add your code here. + return; +} + +static void +service_app_lang_changed(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LANGUAGE_CHANGED*/ + return; +} + +static void +service_app_region_changed(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_REGION_FORMAT_CHANGED*/ +} + +static void +service_app_low_battery(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LOW_BATTERY*/ +} + +static void +service_app_low_memory(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LOW_MEMORY*/ +} + +/** + * Entry point for this application. + */ +int main(int argc, char *argv[]) +{ + LOGI("BEGIN"); + + char ad[50] = {0,}; + service_app_lifecycle_callback_s event_callback; + app_event_handler_h handlers[5] = {NULL, }; + + event_callback.create = service_app_create; + event_callback.terminate = service_app_terminate; + event_callback.app_control = service_app_control; + + service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad); + service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad); + service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad); + service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad); + + return service_app_main(argc, argv, &event_callback, ad); +} diff --git a/src/autofill_config.c b/src/autofill_config.c new file mode 100644 index 0000000..5430b60 --- /dev/null +++ b/src/autofill_config.c @@ -0,0 +1,106 @@ + /* + * 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_config.h" +#include "autofill_daemon_dlog.h" + +#define SETTING_ACTIVE_AUTOFILL_SERVICE "ActiveAutofillService" +#define AUTOFILL_SYSTEM_CONFIG_FILE "/etc/autofill/config" + +bool autofill_config_get_autofill_service_app_id(char **app_id) +{ + char *active_autofill_service_id = NULL; + FILE *pFile = NULL; + Eina_Strbuf *sb_key = NULL, *sb_value = NULL; + const char *key_str = NULL; + const char *value_str = NULL; + bool ret = false; + char strTemp[1024]; + + if (preference_get_string(SETTING_ACTIVE_AUTOFILL_SERVICE, &active_autofill_service_id) == PREFERENCE_ERROR_NONE) { + LOGD("preference active autofill service : %s", active_autofill_service_id); + *app_id = active_autofill_service_id; + return true; + } + + LOGD("Read from config"); + + pFile = fopen(AUTOFILL_SYSTEM_CONFIG_FILE, "r"); + if (pFile == NULL) + return false; + + while (fgets(strTemp, sizeof(strTemp), pFile) != NULL) + { + char **result_arr = eina_str_split(strTemp, "=", 0); + if (!result_arr) + continue; + + if (!result_arr[0]) { + free(result_arr); + continue; + } + + sb_key = eina_strbuf_new(); + eina_strbuf_append(sb_key, result_arr[0]); + eina_strbuf_trim(sb_key); + + key_str = eina_strbuf_string_get(sb_key); + if (key_str) { + if (strcmp(key_str, SETTING_ACTIVE_AUTOFILL_SERVICE) == 0) { + if (result_arr[1]) { + sb_value = eina_strbuf_new(); + eina_strbuf_append(sb_value, result_arr[1]); + eina_strbuf_trim(sb_value); + value_str = eina_strbuf_string_get(sb_value); + + if (app_id && value_str) { + *app_id = strdup(value_str); + ret = true; + } + + eina_strbuf_free(sb_value); + } + } + eina_strbuf_free(sb_key); + } + + /* Free the memory */ + free(result_arr[0]); + free(result_arr); + + if (ret) + break; + } /* end of while */ + + fclose(pFile); + + return ret; +} + +bool autofill_config_set_autofill_service_app_id(const char *app_id) +{ + if (preference_set_string(SETTING_ACTIVE_AUTOFILL_SERVICE, app_id) == PREFERENCE_ERROR_NONE) + return true; + + return false; +} + diff --git a/src/autofill_config.h b/src/autofill_config.h new file mode 100644 index 0000000..57eb00e --- /dev/null +++ b/src/autofill_config.h @@ -0,0 +1,39 @@ +/* + * 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 __AUTOFILL_CONFIG_H__ +#define __AUTOFILL_CONFIG_H__ + +#include + +#define AUTOFILL_SERVICE_APP_ID "org.tizen.autofill-service" + +#ifdef __cplusplus +extern "C" { +#endif + +bool autofill_config_get_autofill_service_app_id(char **app_id); +bool autofill_config_set_autofill_service_app_id(const char *app_id); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* __AUTOFILL_CONFIG_H__ */ diff --git a/src/autofill_daemon_dlog.h b/src/autofill_daemon_dlog.h new file mode 100644 index 0000000..454e14e --- /dev/null +++ b/src/autofill_daemon_dlog.h @@ -0,0 +1,81 @@ +/* + * 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 __AUTOFILL_DAEMON_DLOG_H__ +#define __AUTOFILL_DAEMON_DLOG_H__ + +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "AUTOFILL_DAEMON" + +#define COLOR_RED "\033[0;31m" +#define COLOR_GREEN "\033[0;32m" +#define COLOR_BROWN "\033[0;33m" +#define COLOR_BLUE "\033[0;34m" +#define COLOR_PURPLE "\033[0;35m" +#define COLOR_CYAN "\033[0;36m" +#define COLOR_LIGHTBLUE "\033[0;37m" +#define COLOR_END "\033[0;m" + +#define LOGI(fmt, arg...) dlog_print(DLOG_INFO, LOG_TAG, "%s (%d) %s : " fmt, __FILE__, __LINE__, __FUNCTION__, ##arg) +#define LOGD(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s (%d) %s : " fmt, __FILE__, __LINE__, __FUNCTION__, ##arg) +#define LOGW(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "%s (%d) %s : " fmt, __FILE__, __LINE__, __FUNCTION__, ##arg) +#define LOGE(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "%s (%d) %s : " fmt, __FILE__, __LINE__, __FUNCTION__, ##arg) + +#define PLOG(fmt, args...) LOGD(fmt, ##args) +#define PINFO(fmt, args...) LOGI(COLOR_PURPLE "* Info * " fmt COLOR_END, ##args) +#define PWARNING(fmt, args...) LOGW(COLOR_BLUE "* Warning * " fmt COLOR_END, ##args) +#define PERR(fmt, args...) LOGE(COLOR_RED "* Critical * " fmt COLOR_END, ##args) +#define PENTER() LOGD(COLOR_GREEN "BEGIN >>>>" COLOR_END) +#define PLEAVE() LOGD(COLOR_GREEN "END <<<<" COLOR_END) +#define SEC_LOG(fmt, args...) LOGD(fmt, ##args) +#define SEC_INFO(fmt, args...) LOGI(fmt, ##args) +#define SEC_ERR(fmt, args...) LOGE(COLOR_RED "* Critical * " fmt COLOR_END, ##args) + +#define RET_IF(expr) \ +do { \ + if (expr) \ + return; \ +} while (0) + +#define RETV_IF(expr, val) \ +do { \ + if (expr) \ + return (val); \ +} while (0) + +#define RETM_IF(expr, fmt, arg...) \ +do { \ + if (expr) { \ + PERR(fmt, ##arg); \ + return; \ + } \ +} while (0) + +#define RETVM_IF(expr, val, fmt, arg...) \ +do { \ + if (expr) { \ + PERR(fmt, ##arg); \ + return (val); \ + } \ +} while (0) + +#endif /* __AUTOFILL_DAEMON_DLOG___ */ diff --git a/tidl/autofill.tidl b/tidl/autofill.tidl new file mode 100644 index 0000000..8c3d185 --- /dev/null +++ b/tidl/autofill.tidl @@ -0,0 +1,61 @@ +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_save_item { + string id; + string label; + string value; + int autofill_hint; + bool is_sensitive_data; +} + +struct autofill_save_view_info { + string view_id; + list items; +} + +struct autofill_auth_info { + string view_id; + 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_response_group { + list response_items; +} + +struct autofill_fill_response { + string view_id; + list response_groups; +} + +interface AutofillAppPort { + void autofill_auth_info_received_cb(autofill_auth_info auth_info) delegate; + void autofill_fill_response_received_cb(autofill_fill_response response) delegate; + int Register(int context_id, autofill_auth_info_received_cb auth_info_cb, autofill_fill_response_received_cb fill_response_cb); + void Unregister(int context_id) async; + + int request_auth_info(int context_id, autofill_view_info vi); + int send_fill_request(int context_id, autofill_view_info vi); + int commit(int context_id, autofill_save_view_info vi); +} diff --git a/tidl/autofill_manager.tidl b/tidl/autofill_manager.tidl new file mode 100644 index 0000000..f1ea517 --- /dev/null +++ b/tidl/autofill_manager.tidl @@ -0,0 +1,5 @@ +interface AutofillManagerPort { + bool set_autofill_service(string app_id); + string get_autofill_service(); + bool get_autofill_service_list(out list service_info_list); +} diff --git a/tidl/autofill_service.tidl b/tidl/autofill_service.tidl new file mode 100644 index 0000000..43b9d9f --- /dev/null +++ b/tidl/autofill_service.tidl @@ -0,0 +1,65 @@ +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_save_item { + string id; + string label; + string value; + int autofill_hint; + bool is_sensitive_data; +} + +struct autofill_svc_save_view_info { + string view_id; + list items; +} + +struct autofill_svc_auth_info { + string app_id; + string view_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_response_group { + list response_items; +} + +struct autofill_svc_fill_response { + string app_id; + string view_id; + list response_groups; +} + +interface AutofillSvcPort { + void autofill_svc_auth_info_cb(int context_id, autofill_svc_auth_info auth_info) delegate; + void autofill_svc_fill_response_cb(int context_id, autofill_svc_fill_response response) delegate; + int Register(autofill_svc_auth_info_cb auth_info_cb, autofill_svc_fill_response_cb fill_response_cb); + void Unregister() async; + + void request_auth_info(int context_id, autofill_svc_view_info vi) async; + void send_fill_request(int context_id, autofill_svc_view_info vi) async; + void commit(int context_id, autofill_svc_save_view_info si) async; + void request_terminate() async; +} diff --git a/tizen-manifest.xml b/tizen-manifest.xml new file mode 100644 index 0000000..50b355e --- /dev/null +++ b/tizen-manifest.xml @@ -0,0 +1,12 @@ + + + + + + + + + http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/datasharing + + -- 2.7.4 From 4023cb1436ac572c66a1374cf5bf46249ee29c68 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 14 Dec 2018 17:01:00 +0900 Subject: [PATCH 03/11] Check autofill service app id is validity Change-Id: If6c0f1d0808d5a8a46555ab00c0da3601e74b426 Signed-off-by: Jihoon Kim --- src/autofill-daemon.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/autofill-daemon.c b/src/autofill-daemon.c index 3a4c9b3..0f267ab 100644 --- a/src/autofill-daemon.c +++ b/src/autofill-daemon.c @@ -604,10 +604,7 @@ static bool __manager_set_autofill_service_cb(rpc_port_stub_AutofillManagerPort_ int ret = rpc_port_proxy_AutofillSvcPort_destroy(svc_rpc_h); LOGD("ret : %d", ret); } - else { - LOGW("Not initialized"); - return false; - } + svc_rpc_h = NULL; connect_service(); @@ -690,6 +687,7 @@ static bool __manager_get_autofill_service_list_cb(rpc_port_stub_AutofillManager static int connect_service() { int ret; + size_t service_id_len; rpc_port_proxy_AutofillSvcPort_callback_s rpc_callback = { .connected = __on_connected, @@ -704,7 +702,7 @@ static int connect_service() char *active_autofill_service_id = NULL; autofill_config_get_autofill_service_app_id(&active_autofill_service_id); - LOGD("autofill service : %s", active_autofill_service_id); + LOGD("autofill service : '%s'", active_autofill_service_id); if (!active_autofill_service_id) { active_autofill_service_id = strdup(AUTOFILL_SERVICE_APP_ID); @@ -712,8 +710,18 @@ static int connect_service() if (active_autofill_service_id) { autofill_config_set_autofill_service_app_id(active_autofill_service_id); - ret = rpc_port_proxy_AutofillSvcPort_create(active_autofill_service_id, &rpc_callback, NULL, &svc_rpc_h); + service_id_len = strlen(active_autofill_service_id); + + if (service_id_len > 0) { + ret = rpc_port_proxy_AutofillSvcPort_create(active_autofill_service_id, &rpc_callback, NULL, &svc_rpc_h); + } free(active_autofill_service_id); + + if (service_id_len == 0) { + LOGD("No Autofill service to connect"); + return false; + } + if (ret != RPC_PORT_ERROR_NONE) { LOGW("Failed to create rpc port. err = %d", ret); return false; -- 2.7.4 From 4b9fee3d36a7ff55319af7defb15d6ec7c9cb4a5 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 14 Dec 2018 17:02:45 +0900 Subject: [PATCH 04/11] Fix TC fail issue in case of no service app Change-Id: I2da23c57163aba8a8b72cd58d341dac4d5678968 Signed-off-by: Jihoon Kim --- src/autofill-daemon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/autofill-daemon.c b/src/autofill-daemon.c index 0f267ab..1ca0dd1 100644 --- a/src/autofill-daemon.c +++ b/src/autofill-daemon.c @@ -321,7 +321,7 @@ static int __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h contex if (!svc_rpc_h) { LOGW("Not initialized"); - return -1; + return 0; } rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender); @@ -362,7 +362,7 @@ static int __autofill_fill_request_cb(rpc_port_stub_AutofillAppPort_context_h co if (!svc_rpc_h) { LOGW("Not initialized"); - return -1; + return 0; } rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender); @@ -397,7 +397,7 @@ static int __commit_cb(rpc_port_stub_AutofillAppPort_context_h context, int cont if (!svc_rpc_h) { LOGW("Not initialized"); - return -1; + return 0; } rpc_port_stub_AutofillAppPort_context_get_sender(context, &sender); -- 2.7.4 From 02bf7bf8367297aa7066856f3f4a2bcd8186d572 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 17 Dec 2018 10:36:46 +0900 Subject: [PATCH 05/11] Disable to use tidlc temporarily Change-Id: I75f838ea607e80cba49a27369803959123ebb2f5 Signed-off-by: Jihoon Kim --- build_def.prop | 2 +- src/autofill_manager_stub.c | 681 +++++++ src/autofill_manager_stub.h | 70 + src/autofill_service_proxy.c | 4261 ++++++++++++++++++++++++++++++++++++++++++ src/autofill_service_proxy.h | 346 ++++ src/autofill_stub.c | 4148 ++++++++++++++++++++++++++++++++++++++++ src/autofill_stub.h | 327 ++++ 7 files changed, 9834 insertions(+), 1 deletion(-) create mode 100644 src/autofill_manager_stub.c create mode 100644 src/autofill_manager_stub.h create mode 100644 src/autofill_service_proxy.c create mode 100644 src/autofill_service_proxy.h create mode 100644 src/autofill_stub.c create mode 100644 src/autofill_stub.h diff --git a/build_def.prop b/build_def.prop index 520f46f..6bb5e2f 100644 --- a/build_def.prop +++ b/build_def.prop @@ -1,6 +1,6 @@ # Add pre/post build process PREBUILD_DESC = -PREBUILD_COMMAND = tidlc -s -l C -i tidl/autofill.tidl -o autofill_stub; mv autofill_stub.h ./src/; mv autofill_stub.c ./src/; tidlc -p -l C -i tidl/autofill_service.tidl -o autofill_service_proxy; mv autofill_service_proxy.h ./src/; mv autofill_service_proxy.c ./src/; tidlc -s -l C -i tidl/autofill_manager.tidl -o autofill_manager_stub; mv autofill_manager_stub.h ./src/; mv autofill_manager_stub.c ./src/; +PREBUILD_COMMAND = POSTBUILD_DESC = POSTBUILD_COMMAND = diff --git a/src/autofill_manager_stub.c b/src/autofill_manager_stub.c new file mode 100644 index 0000000..a662337 --- /dev/null +++ b/src/autofill_manager_stub.c @@ -0,0 +1,681 @@ +/* + * Generated by tidlc 1.3.2. + * + * 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_manager_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 list_string_s { + rpc_port_parcelable_t parcelable; + GList *list_strings; +}; + +static void __list_string_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_string_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_strings)); + do { + GList *iter; + + iter = h->list_strings; + while (iter) { + char *value = iter->data; + + iter = g_list_next(iter); + if (!value) { + _W("Warning: value is NULL"); + continue; + } + rpc_port_parcel_write_string(parcel, value ? value : ""); + } + } while (0); +} + +static void __list_string_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_string_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++) { + char *value = NULL; + + rpc_port_parcel_read_string(parcel, &value); + h->list_strings = g_list_append(h->list_strings, value); + } + } while (0); +} + +int rpc_port_list_string_create(rpc_port_list_string_h *h) +{ + struct list_string_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_string_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_string_to; + handle->parcelable.from = __list_string_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_string_destroy(rpc_port_list_string_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_strings; + while (iter) { + char *value = iter->data; + if (value) + free(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_strings); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_string_clone(rpc_port_list_string_h h, rpc_port_list_string_h *clone) +{ + rpc_port_list_string_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_string_create(&handle); + if (!handle) { + _E("Failed to create list_string handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_strings; + while (iter) { + char *new_value; + char *value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_string_destroy(handle); + return -1; + } + + new_value = strdup(value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_string_destroy(handle); + return -1; + } + + handle->list_strings = g_list_append(handle->list_strings, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_string_add_list_strings(rpc_port_list_string_h h, const char *list_strings) +{ + if (!h || !list_strings) { + _E("Invalid parameter"); + return -1; + } + + do { + char *value = NULL; + + value = strdup(list_strings); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_strings = g_list_append(h->list_strings, value); + } while (0); + + return 0; +} + +int rpc_port_list_string_foreach_list_strings(rpc_port_list_string_h h, + bool (*callback)(const char *list_strings, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_strings; + while (iter) { + char *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_string_remove_list_strings(rpc_port_list_string_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_strings, nth); + if (iter == NULL) + return -1; + + char *value = iter->data; + h->list_strings = g_list_remove_link(h->list_strings, iter); + if (value) + free(value); + + g_list_free(iter); + + return 0; +} + +int rpc_port_list_string_get_list_strings_length(rpc_port_list_string_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_strings); + + return 0; +} + +enum AutofillManagerPort_method_e { + AutofillManagerPort_METHOD_Result, + AutofillManagerPort_METHOD_Callback, + AutofillManagerPort_METHOD_set_autofill_service, + AutofillManagerPort_METHOD_get_autofill_service, + AutofillManagerPort_METHOD_get_autofill_service_list, +}; + +static rpc_port_stub_h __AutofillManagerPort_stub; +static rpc_port_stub_AutofillManagerPort_callback_s __AutofillManagerPort_callback; +static void *__AutofillManagerPort_user_data; +static GList *__AutofillManagerPort_contexts; + +struct AutofillManagerPort_context_s { + char *sender; + char *instance; + rpc_port_h port; + void *tag; + rpc_port_stub_AutofillManagerPort_callback_s callback; + void *user_data; +}; + +static struct AutofillManagerPort_context_s *__create_AutofillManagerPort_context(const char *sender, const char *instance) +{ + struct AutofillManagerPort_context_s *handle; + + handle = calloc(1, sizeof(struct AutofillManagerPort_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 = __AutofillManagerPort_callback; + handle->user_data = __AutofillManagerPort_user_data; + + return handle; +} + +static void __destroy_AutofillManagerPort_context(gpointer data) +{ + struct AutofillManagerPort_context_s *handle = data; + + if (!handle) { + _E("Critical error!"); + return; + } + + free(handle->instance); + free(handle->sender); + free(handle); +} + +static struct AutofillManagerPort_context_s *__find_AutofillManagerPort_context(const char *instance) +{ + struct AutofillManagerPort_context_s *handle; + GList *iter; + + iter = __AutofillManagerPort_contexts; + while (iter) { + handle = (struct AutofillManagerPort_context_s *)iter->data; + if (!strcmp(handle->instance, instance)) + return handle; + iter = g_list_next(iter); + } + + return NULL; +} + +int rpc_port_stub_AutofillManagerPort_context_set_tag(rpc_port_stub_AutofillManagerPort_context_h ctx, void *tag) +{ + if (!ctx) { + _E("Invalid parameter"); + return -1; + } + + ctx->tag = tag; + + return 0; +} + +int rpc_port_stub_AutofillManagerPort_context_get_tag(rpc_port_stub_AutofillManagerPort_context_h ctx, void **tag) +{ + if (!ctx || !tag) { + _E("Invalid parameter"); + return -1; + } + + *tag = ctx->tag; + + return 0; +} + +int rpc_port_stub_AutofillManagerPort_context_get_sender(rpc_port_stub_AutofillManagerPort_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; +} + +static int __AutofillManagerPort_method_set_autofill_service(rpc_port_h port, rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_AutofillManagerPort_context_h context = data; + rpc_port_h callback_port; + int r; + + r = rpc_port_stub_get_port(__AutofillManagerPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); + if (r != 0) { + _E("Failed to get callback port"); + return -1; + } + + char *app_id; + + rpc_port_parcel_read_string(parcel, &app_id); + + bool ret = context->callback.set_autofill_service(context, app_id, context->user_data); + do { + rpc_port_parcel_h result; + + rpc_port_parcel_create(&result); + rpc_port_parcel_write_int32(result, AutofillManagerPort_METHOD_Result); + rpc_port_parcel_write_bool(result, ret); + rpc_port_parcel_send(result, port); + rpc_port_parcel_destroy(result); + } while (0); + + free(app_id); + return 0; +} + +static int __AutofillManagerPort_method_get_autofill_service(rpc_port_h port, rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_AutofillManagerPort_context_h context = data; + rpc_port_h callback_port; + int r; + + r = rpc_port_stub_get_port(__AutofillManagerPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); + if (r != 0) { + _E("Failed to get callback port"); + return -1; + } + + char *ret = context->callback.get_autofill_service(context, context->user_data); + do { + rpc_port_parcel_h result; + + rpc_port_parcel_create(&result); + rpc_port_parcel_write_int32(result, AutofillManagerPort_METHOD_Result); + rpc_port_parcel_write_string(result, ret ? ret : ""); + rpc_port_parcel_send(result, port); + rpc_port_parcel_destroy(result); + } while (0); + free(ret); + return 0; +} + +static int __AutofillManagerPort_method_get_autofill_service_list(rpc_port_h port, rpc_port_parcel_h parcel, void *data) +{ + rpc_port_stub_AutofillManagerPort_context_h context = data; + rpc_port_h callback_port; + int r; + + r = rpc_port_stub_get_port(__AutofillManagerPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); + if (r != 0) { + _E("Failed to get callback port"); + return -1; + } + + rpc_port_list_string_h service_info_list = NULL; + + bool ret = context->callback.get_autofill_service_list(context, &service_info_list, context->user_data); + do { + rpc_port_parcel_h result; + + rpc_port_parcel_create(&result); + rpc_port_parcel_write_int32(result, AutofillManagerPort_METHOD_Result); + rpc_port_parcel_write(result, &service_info_list->parcelable, service_info_list); + rpc_port_parcel_write_bool(result, ret); + rpc_port_parcel_send(result, port); + rpc_port_parcel_destroy(result); + } while (0); + + rpc_port_list_string_destroy(service_info_list); + return 0; +} + +static stub_method __AutofillManagerPort_method_table[] = { + [AutofillManagerPort_METHOD_set_autofill_service] = __AutofillManagerPort_method_set_autofill_service, + [AutofillManagerPort_METHOD_get_autofill_service] = __AutofillManagerPort_method_get_autofill_service, + [AutofillManagerPort_METHOD_get_autofill_service_list] = __AutofillManagerPort_method_get_autofill_service_list, +}; + +static void __AutofillManagerPort_on_connected(const char *sender, const char *instance, void *data) +{ + rpc_port_stub_AutofillManagerPort_context_h context; + + _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); + context = __create_AutofillManagerPort_context(sender, instance); + if (!context) + return; + + if (context->callback.create) + context->callback.create(context, context->user_data); + __AutofillManagerPort_contexts = g_list_append(__AutofillManagerPort_contexts, context); +} + +static void __AutofillManagerPort_on_disconnected(const char *sender, const char *instance, void *data) +{ + rpc_port_stub_AutofillManagerPort_context_h context; + + _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); + context = __find_AutofillManagerPort_context(instance); + if (!context) + return; + + if (context->callback.terminate) + context->callback.terminate(context, context->user_data); + __AutofillManagerPort_contexts = g_list_remove(__AutofillManagerPort_contexts, context); + __destroy_AutofillManagerPort_context(context); +} + +static int __AutofillManagerPort_on_received(const char *sender, const char *instance, rpc_port_h port, void *data) +{ + rpc_port_stub_AutofillManagerPort_context_h context; + rpc_port_parcel_h parcel; + int cmd = -1; + int r; + + _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); + context = __find_AutofillManagerPort_context(instance); + if (!context) { + _E("Failed to find AutofillManagerPort 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(__AutofillManagerPort_method_table) / sizeof(__AutofillManagerPort_method_table[0]))) { + if (__AutofillManagerPort_method_table[cmd]) + r = __AutofillManagerPort_method_table[cmd](port, parcel, context); + } else { + _E("Unknown Command(%d)", cmd); + r = -1; + } + + rpc_port_parcel_destroy(parcel); + + return r; +} + +static int __AutofillManagerPort_add_privileges(void) +{ + + return 0; +} + +int rpc_port_stub_AutofillManagerPort_register(rpc_port_stub_AutofillManagerPort_callback_s *callback, void *user_data) +{ + int r; + + if (__AutofillManagerPort_stub) { + _W("Already exists"); + return -1; + } + + if (!callback) { + _E("Invalid parameter"); + return -1; + } + + __AutofillManagerPort_callback = *callback; + __AutofillManagerPort_user_data = user_data; + r = rpc_port_stub_create(&__AutofillManagerPort_stub, "AutofillManagerPort"); + if (r != 0) { + _E("Failed to create stub handle"); + return r; + } + + r = rpc_port_stub_add_received_event_cb(__AutofillManagerPort_stub, __AutofillManagerPort_on_received, NULL); + if (r != 0) { + _E("Failed to add received event callback"); + rpc_port_stub_destroy(__AutofillManagerPort_stub); + __AutofillManagerPort_stub = NULL; + return r; + } + + r = rpc_port_stub_add_connected_event_cb(__AutofillManagerPort_stub, __AutofillManagerPort_on_connected, NULL); + if (r != 0) { + _E("Failed to add connected event callback"); + rpc_port_stub_destroy(__AutofillManagerPort_stub); + __AutofillManagerPort_stub = NULL; + return r; + } + + r = rpc_port_stub_add_disconnected_event_cb(__AutofillManagerPort_stub, __AutofillManagerPort_on_disconnected, NULL); + if (r != 0) { + _E("Failed to add disconnected event callback"); + rpc_port_stub_destroy(__AutofillManagerPort_stub); + __AutofillManagerPort_stub = NULL; + return r; + } + + r = __AutofillManagerPort_add_privileges(); + if (r != 0) { + _E("Failed to add privileges"); + rpc_port_stub_destroy(__AutofillManagerPort_stub); + __AutofillManagerPort_stub = NULL; + return r; + } + + r = rpc_port_stub_listen(__AutofillManagerPort_stub); + if (r != 0) { + _E("Failed to listen stub"); + rpc_port_stub_destroy(__AutofillManagerPort_stub); + __AutofillManagerPort_stub = NULL; + return r; + } + + return 0; +} + +int rpc_port_stub_AutofillManagerPort_unregister(void) +{ + int r; + + if (!__AutofillManagerPort_stub) + return -1; + + if (__AutofillManagerPort_contexts) { + g_list_free_full(__AutofillManagerPort_contexts, __destroy_AutofillManagerPort_context); + __AutofillManagerPort_contexts = NULL; + } + + r = rpc_port_stub_destroy(__AutofillManagerPort_stub); + __AutofillManagerPort_stub = NULL; + + return r; +} + +int rpc_port_stub_AutofillManagerPort_get_client_number(unsigned int *n) +{ + if (!n) { + _E("Invalid parameter"); + return -1; + } + + if (!__AutofillManagerPort_stub) { + _E("AutofillManagerPort Stub is not ready"); + return -1; + } + + *n = g_list_length(__AutofillManagerPort_contexts); + + return 0; +} diff --git a/src/autofill_manager_stub.h b/src/autofill_manager_stub.h new file mode 100644 index 0000000..458cb01 --- /dev/null +++ b/src/autofill_manager_stub.h @@ -0,0 +1,70 @@ +/* + * Generated by tidlc 1.3.2. + * + * 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 list_string_s *rpc_port_list_string_h; + +int rpc_port_list_string_create(rpc_port_list_string_h *h); + +int rpc_port_list_string_destroy(rpc_port_list_string_h h); + +int rpc_port_list_string_clone(rpc_port_list_string_h h, rpc_port_list_string_h *clone); + +int rpc_port_list_string_add_list_strings(rpc_port_list_string_h h, const char *list_strings); + +int rpc_port_list_string_foreach_list_strings(rpc_port_list_string_h h, + bool (*callback)(const char *list_strings, void *user_data), void *user_data); + +int rpc_port_list_string_remove_list_strings(rpc_port_list_string_h h, unsigned int nth); + +int rpc_port_list_string_get_list_strings_length(rpc_port_list_string_h h, unsigned int *length); + +typedef struct AutofillManagerPort_context_s* rpc_port_stub_AutofillManagerPort_context_h; + +int rpc_port_stub_AutofillManagerPort_context_set_tag(rpc_port_stub_AutofillManagerPort_context_h ctx, void *tag); + +int rpc_port_stub_AutofillManagerPort_context_get_tag(rpc_port_stub_AutofillManagerPort_context_h ctx, void **tag); + +int rpc_port_stub_AutofillManagerPort_context_get_sender(rpc_port_stub_AutofillManagerPort_context_h ctx, char **sender); + +typedef struct { + void (*create)(rpc_port_stub_AutofillManagerPort_context_h context, void *user_data); + void (*terminate)(rpc_port_stub_AutofillManagerPort_context_h context, void *user_data); + + bool (*set_autofill_service)(rpc_port_stub_AutofillManagerPort_context_h context, const char *app_id, void *user_data); + char *(*get_autofill_service)(rpc_port_stub_AutofillManagerPort_context_h context, void *user_data); + bool (*get_autofill_service_list)(rpc_port_stub_AutofillManagerPort_context_h context, rpc_port_list_string_h *service_info_list, void *user_data); +} rpc_port_stub_AutofillManagerPort_callback_s; + +int rpc_port_stub_AutofillManagerPort_register(rpc_port_stub_AutofillManagerPort_callback_s *callback, void *user_data); + +int rpc_port_stub_AutofillManagerPort_unregister(void); + +int rpc_port_stub_AutofillManagerPort_get_client_number(unsigned int *n); + +#ifdef __cplusplus +} +#endif diff --git a/src/autofill_service_proxy.c b/src/autofill_service_proxy.c new file mode 100644 index 0000000..18e3bb5 --- /dev/null +++ b/src/autofill_service_proxy.c @@ -0,0 +1,4261 @@ +/* + * Generated by tidlc 1.3.2. + * + * 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_save_item_s { + rpc_port_parcelable_t parcelable; + char *id; + char *label; + char *value; + int autofill_hint; + bool is_sensitive_data; +}; + +static void __autofill_svc_save_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_save_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_save_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_save_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_save_item_create(rpc_port_autofill_svc_save_item_h *h) +{ + struct autofill_svc_save_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_save_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_save_item_to; + handle->parcelable.from = __autofill_svc_save_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_save_item_destroy(rpc_port_autofill_svc_save_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_save_item_clone(rpc_port_autofill_svc_save_item_h h, rpc_port_autofill_svc_save_item_h *clone) +{ + rpc_port_autofill_svc_save_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_save_item_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_save_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_save_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_save_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_save_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_save_item_set_id(rpc_port_autofill_svc_save_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_save_item_set_label(rpc_port_autofill_svc_save_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_save_item_set_value(rpc_port_autofill_svc_save_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_save_item_set_autofill_hint(rpc_port_autofill_svc_save_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_save_item_set_is_sensitive_data(rpc_port_autofill_svc_save_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_save_item_get_id(rpc_port_autofill_svc_save_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_save_item_get_label(rpc_port_autofill_svc_save_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_save_item_get_value(rpc_port_autofill_svc_save_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_save_item_get_autofill_hint(rpc_port_autofill_svc_save_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_save_item_get_is_sensitive_data(rpc_port_autofill_svc_save_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_save_view_info_s { + rpc_port_parcelable_t parcelable; + char *view_id; + GList *items; +}; + +static void __autofill_svc_save_view_info_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_save_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_svc_save_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_save_view_info_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_save_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_svc_save_item_h value = NULL; + + rpc_port_autofill_svc_save_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_save_view_info_create(rpc_port_autofill_svc_save_view_info_h *h) +{ + struct autofill_svc_save_view_info_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_save_view_info_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_save_view_info_to; + handle->parcelable.from = __autofill_svc_save_view_info_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_save_view_info_destroy(rpc_port_autofill_svc_save_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_svc_save_item_h value = iter->data; + if (value) + rpc_port_autofill_svc_save_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_autofill_svc_save_view_info_clone(rpc_port_autofill_svc_save_view_info_h h, rpc_port_autofill_svc_save_view_info_h *clone) +{ + rpc_port_autofill_svc_save_view_info_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_save_view_info_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_save_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_svc_save_view_info_destroy(handle); + return -1; + } + } + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_svc_save_item_h new_value; + rpc_port_autofill_svc_save_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_autofill_svc_save_view_info_destroy(handle); + return -1; + } + + rpc_port_autofill_svc_save_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_svc_save_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_save_view_info_set_view_id(rpc_port_autofill_svc_save_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_save_view_info_add_items(rpc_port_autofill_svc_save_view_info_h h, rpc_port_autofill_svc_save_item_h items) +{ + if (!h || !items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_save_item_h value = NULL; + + rpc_port_autofill_svc_save_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_save_view_info_get_view_id(rpc_port_autofill_svc_save_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_save_view_info_foreach_items(rpc_port_autofill_svc_save_view_info_h h, + bool (*callback)(rpc_port_autofill_svc_save_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_save_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_save_view_info_remove_items(rpc_port_autofill_svc_save_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_save_item_h value = iter->data; + h->items = g_list_remove_link(h->items, iter); + rpc_port_autofill_svc_save_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_svc_save_view_info_get_items_length(rpc_port_autofill_svc_save_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; + char *view_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_string(parcel, h->view_id ? h->view_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_string(parcel, &h->view_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->view_id) + free(h->view_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; + } + } + + 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_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_view_id(rpc_port_autofill_svc_auth_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_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_view_id(rpc_port_autofill_svc_auth_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_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_response_group_s { + rpc_port_parcelable_t parcelable; + GList *response_items; +}; + +static void __autofill_svc_response_group_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_response_group_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + 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_response_group_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_svc_response_group_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->response_items = g_list_append(h->response_items, value); + } + } while (0); +} + +int rpc_port_autofill_svc_response_group_create(rpc_port_autofill_svc_response_group_h *h) +{ + struct autofill_svc_response_group_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_svc_response_group_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_svc_response_group_to; + handle->parcelable.from = __autofill_svc_response_group_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_svc_response_group_destroy(rpc_port_autofill_svc_response_group_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + 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_response_group_clone(rpc_port_autofill_svc_response_group_h h, rpc_port_autofill_svc_response_group_h *clone) +{ + rpc_port_autofill_svc_response_group_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_svc_response_group_create(&handle); + if (!handle) { + _E("Failed to create autofill_svc_response_group 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_response_group_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_response_group_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_response_group_add_response_items(rpc_port_autofill_svc_response_group_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_response_group_foreach_response_items(rpc_port_autofill_svc_response_group_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_response_group_remove_response_items(rpc_port_autofill_svc_response_group_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_response_group_get_response_items_length(rpc_port_autofill_svc_response_group_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->response_items); + + return 0; +} + +struct autofill_svc_fill_response_s { + rpc_port_parcelable_t parcelable; + char *app_id; + char *view_id; + GList *response_groups; +}; + +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_groups)); + do { + GList *iter; + + iter = h->response_groups; + while (iter) { + rpc_port_autofill_svc_response_group_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_group_h value = NULL; + + rpc_port_autofill_svc_response_group_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->response_groups = g_list_append(h->response_groups, 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_groups; + while (iter) { + rpc_port_autofill_svc_response_group_h value = iter->data; + if (value) + rpc_port_autofill_svc_response_group_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->response_groups); + } 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_groups; + while (iter) { + rpc_port_autofill_svc_response_group_h new_value; + rpc_port_autofill_svc_response_group_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_group_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_svc_fill_response_destroy(handle); + return -1; + } + + handle->response_groups = g_list_append(handle->response_groups, 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_groups(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_response_group_h response_groups) +{ + if (!h || !response_groups) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_response_group_h value = NULL; + + rpc_port_autofill_svc_response_group_clone(response_groups, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->response_groups = g_list_append(h->response_groups, 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_groups(rpc_port_autofill_svc_fill_response_h h, + bool (*callback)(rpc_port_autofill_svc_response_group_h response_groups, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->response_groups; + while (iter) { + rpc_port_autofill_svc_response_group_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_groups(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_groups, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_svc_response_group_h value = iter->data; + h->response_groups = g_list_remove_link(h->response_groups, iter); + rpc_port_autofill_svc_response_group_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_svc_fill_response_get_response_groups_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_groups); + + 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_group_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_svc_response_groups; +}; + +static void __list_autofill_svc_response_group_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_response_group_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_groups)); + do { + GList *iter; + + iter = h->list_autofill_svc_response_groups; + while (iter) { + rpc_port_autofill_svc_response_group_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_group_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_response_group_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_group_h value = NULL; + + rpc_port_autofill_svc_response_group_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_svc_response_groups = g_list_append(h->list_autofill_svc_response_groups, value); + } + } while (0); +} + +int rpc_port_list_autofill_svc_response_group_create(rpc_port_list_autofill_svc_response_group_h *h) +{ + struct list_autofill_svc_response_group_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_svc_response_group_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_svc_response_group_to; + handle->parcelable.from = __list_autofill_svc_response_group_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_response_group_destroy(rpc_port_list_autofill_svc_response_group_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_response_groups; + while (iter) { + rpc_port_autofill_svc_response_group_h value = iter->data; + if (value) + rpc_port_autofill_svc_response_group_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_svc_response_groups); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_svc_response_group_clone(rpc_port_list_autofill_svc_response_group_h h, rpc_port_list_autofill_svc_response_group_h *clone) +{ + rpc_port_list_autofill_svc_response_group_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_svc_response_group_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_svc_response_group handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_response_groups; + while (iter) { + rpc_port_autofill_svc_response_group_h new_value; + rpc_port_autofill_svc_response_group_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_svc_response_group_destroy(handle); + return -1; + } + + rpc_port_autofill_svc_response_group_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_svc_response_group_destroy(handle); + return -1; + } + + handle->list_autofill_svc_response_groups = g_list_append(handle->list_autofill_svc_response_groups, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_response_group_add_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, rpc_port_autofill_svc_response_group_h list_autofill_svc_response_groups) +{ + if (!h || !list_autofill_svc_response_groups) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_response_group_h value = NULL; + + rpc_port_autofill_svc_response_group_clone(list_autofill_svc_response_groups, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_svc_response_groups = g_list_append(h->list_autofill_svc_response_groups, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_svc_response_group_foreach_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, + bool (*callback)(rpc_port_autofill_svc_response_group_h list_autofill_svc_response_groups, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_response_groups; + while (iter) { + rpc_port_autofill_svc_response_group_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_group_remove_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_svc_response_groups, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_svc_response_group_h value = iter->data; + h->list_autofill_svc_response_groups = g_list_remove_link(h->list_autofill_svc_response_groups, iter); + rpc_port_autofill_svc_response_group_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_svc_response_group_get_list_autofill_svc_response_groups_length(rpc_port_list_autofill_svc_response_group_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_svc_response_groups); + + 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; +} + +struct list_autofill_svc_save_item_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_svc_save_items; +}; + +static void __list_autofill_svc_save_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_save_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_save_items)); + do { + GList *iter; + + iter = h->list_autofill_svc_save_items; + while (iter) { + rpc_port_autofill_svc_save_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_save_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_svc_save_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_save_item_h value = NULL; + + rpc_port_autofill_svc_save_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_svc_save_items = g_list_append(h->list_autofill_svc_save_items, value); + } + } while (0); +} + +int rpc_port_list_autofill_svc_save_item_create(rpc_port_list_autofill_svc_save_item_h *h) +{ + struct list_autofill_svc_save_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_svc_save_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_svc_save_item_to; + handle->parcelable.from = __list_autofill_svc_save_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_save_item_destroy(rpc_port_list_autofill_svc_save_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_save_items; + while (iter) { + rpc_port_autofill_svc_save_item_h value = iter->data; + if (value) + rpc_port_autofill_svc_save_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_svc_save_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_svc_save_item_clone(rpc_port_list_autofill_svc_save_item_h h, rpc_port_list_autofill_svc_save_item_h *clone) +{ + rpc_port_list_autofill_svc_save_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_svc_save_item_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_svc_save_item handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_save_items; + while (iter) { + rpc_port_autofill_svc_save_item_h new_value; + rpc_port_autofill_svc_save_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_svc_save_item_destroy(handle); + return -1; + } + + rpc_port_autofill_svc_save_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_svc_save_item_destroy(handle); + return -1; + } + + handle->list_autofill_svc_save_items = g_list_append(handle->list_autofill_svc_save_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_svc_save_item_add_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, rpc_port_autofill_svc_save_item_h list_autofill_svc_save_items) +{ + if (!h || !list_autofill_svc_save_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_svc_save_item_h value = NULL; + + rpc_port_autofill_svc_save_item_clone(list_autofill_svc_save_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_svc_save_items = g_list_append(h->list_autofill_svc_save_items, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_svc_save_item_foreach_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, + bool (*callback)(rpc_port_autofill_svc_save_item_h list_autofill_svc_save_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_svc_save_items; + while (iter) { + rpc_port_autofill_svc_save_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_save_item_remove_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_svc_save_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_svc_save_item_h value = iter->data; + h->list_autofill_svc_save_items = g_list_remove_link(h->list_autofill_svc_save_items, iter); + rpc_port_autofill_svc_save_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_svc_save_item_get_list_autofill_svc_save_items_length(rpc_port_list_autofill_svc_save_item_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_svc_save_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, + AutofillSvcPort_METHOD_commit, + AutofillSvcPort_METHOD_request_terminate, +}; + +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) +{ + int context_id; + rpc_port_autofill_svc_auth_info_h auth_info; + + rpc_port_parcel_read_int32(parcel, &context_id); + 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, context_id, 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) +{ + int context_id; + rpc_port_autofill_svc_fill_response_h response; + + rpc_port_parcel_read_int32(parcel, &context_id); + 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, context_id, 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 = NULL; + int cmd = -1; + + rpc_port_parcel_create_from_port(&parcel_received, handle->callback_port); + if (!parcel_received) { + _E("Failed to create parcel from port(%s)", port_name); + return; + } + + 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, int context_id, 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_int32(parcel, context_id); + 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, int context_id, 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_int32(parcel, context_id); + 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_commit(rpc_port_proxy_AutofillSvcPort_h h, int context_id, rpc_port_autofill_svc_save_view_info_h si) +{ + rpc_port_parcel_h parcel; + int r; + + if (!h || !si) { + _E("Invalid parameter"); + return; + } + + if (!h->port) { + _E("Not connected"); + return; + } + + rpc_port_parcel_create(&parcel); + rpc_port_parcel_write_int32(parcel, AutofillSvcPort_METHOD_commit); + rpc_port_parcel_write_int32(parcel, context_id); + rpc_port_parcel_write(parcel, &si->parcelable, si); + + 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_terminate(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_request_terminate); + + 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/src/autofill_service_proxy.h b/src/autofill_service_proxy.h new file mode 100644 index 0000000..8a0700b --- /dev/null +++ b/src/autofill_service_proxy.h @@ -0,0 +1,346 @@ +/* + * Generated by tidlc 1.3.2. + * + * 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_save_item_s *rpc_port_autofill_svc_save_item_h; + +int rpc_port_autofill_svc_save_item_create(rpc_port_autofill_svc_save_item_h *h); + +int rpc_port_autofill_svc_save_item_destroy(rpc_port_autofill_svc_save_item_h h); + +int rpc_port_autofill_svc_save_item_clone(rpc_port_autofill_svc_save_item_h h, rpc_port_autofill_svc_save_item_h *clone); + +int rpc_port_autofill_svc_save_item_set_id(rpc_port_autofill_svc_save_item_h h, const char *id); + +int rpc_port_autofill_svc_save_item_set_label(rpc_port_autofill_svc_save_item_h h, const char *label); + +int rpc_port_autofill_svc_save_item_set_value(rpc_port_autofill_svc_save_item_h h, const char *value); + +int rpc_port_autofill_svc_save_item_set_autofill_hint(rpc_port_autofill_svc_save_item_h h, int autofill_hint); + +int rpc_port_autofill_svc_save_item_set_is_sensitive_data(rpc_port_autofill_svc_save_item_h h, bool is_sensitive_data); + +int rpc_port_autofill_svc_save_item_get_id(rpc_port_autofill_svc_save_item_h h, char **id); + +int rpc_port_autofill_svc_save_item_get_label(rpc_port_autofill_svc_save_item_h h, char **label); + +int rpc_port_autofill_svc_save_item_get_value(rpc_port_autofill_svc_save_item_h h, char **value); + +int rpc_port_autofill_svc_save_item_get_autofill_hint(rpc_port_autofill_svc_save_item_h h, int *autofill_hint); + +int rpc_port_autofill_svc_save_item_get_is_sensitive_data(rpc_port_autofill_svc_save_item_h h, bool *is_sensitive_data); + +typedef struct autofill_svc_save_view_info_s *rpc_port_autofill_svc_save_view_info_h; + +int rpc_port_autofill_svc_save_view_info_create(rpc_port_autofill_svc_save_view_info_h *h); + +int rpc_port_autofill_svc_save_view_info_destroy(rpc_port_autofill_svc_save_view_info_h h); + +int rpc_port_autofill_svc_save_view_info_clone(rpc_port_autofill_svc_save_view_info_h h, rpc_port_autofill_svc_save_view_info_h *clone); + +int rpc_port_autofill_svc_save_view_info_set_view_id(rpc_port_autofill_svc_save_view_info_h h, const char *view_id); + +int rpc_port_autofill_svc_save_view_info_add_items(rpc_port_autofill_svc_save_view_info_h h, rpc_port_autofill_svc_save_item_h items); + +int rpc_port_autofill_svc_save_view_info_get_view_id(rpc_port_autofill_svc_save_view_info_h h, char **view_id); + +int rpc_port_autofill_svc_save_view_info_foreach_items(rpc_port_autofill_svc_save_view_info_h h, + bool (*callback)(rpc_port_autofill_svc_save_item_h items, void *user_data), void *user_data); + +int rpc_port_autofill_svc_save_view_info_remove_items(rpc_port_autofill_svc_save_view_info_h h, unsigned int nth); + +int rpc_port_autofill_svc_save_view_info_get_items_length(rpc_port_autofill_svc_save_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_view_id(rpc_port_autofill_svc_auth_info_h h, const char *view_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_view_id(rpc_port_autofill_svc_auth_info_h h, char **view_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_response_group_s *rpc_port_autofill_svc_response_group_h; + +int rpc_port_autofill_svc_response_group_create(rpc_port_autofill_svc_response_group_h *h); + +int rpc_port_autofill_svc_response_group_destroy(rpc_port_autofill_svc_response_group_h h); + +int rpc_port_autofill_svc_response_group_clone(rpc_port_autofill_svc_response_group_h h, rpc_port_autofill_svc_response_group_h *clone); + +int rpc_port_autofill_svc_response_group_add_response_items(rpc_port_autofill_svc_response_group_h h, rpc_port_autofill_svc_response_item_h response_items); + +int rpc_port_autofill_svc_response_group_foreach_response_items(rpc_port_autofill_svc_response_group_h h, + bool (*callback)(rpc_port_autofill_svc_response_item_h response_items, void *user_data), void *user_data); + +int rpc_port_autofill_svc_response_group_remove_response_items(rpc_port_autofill_svc_response_group_h h, unsigned int nth); + +int rpc_port_autofill_svc_response_group_get_response_items_length(rpc_port_autofill_svc_response_group_h h, unsigned int *length); + +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_groups(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_response_group_h response_groups); + +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_groups(rpc_port_autofill_svc_fill_response_h h, + bool (*callback)(rpc_port_autofill_svc_response_group_h response_groups, void *user_data), void *user_data); + +int rpc_port_autofill_svc_fill_response_remove_response_groups(rpc_port_autofill_svc_fill_response_h h, unsigned int nth); + +int rpc_port_autofill_svc_fill_response_get_response_groups_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_group_s *rpc_port_list_autofill_svc_response_group_h; + +int rpc_port_list_autofill_svc_response_group_create(rpc_port_list_autofill_svc_response_group_h *h); + +int rpc_port_list_autofill_svc_response_group_destroy(rpc_port_list_autofill_svc_response_group_h h); + +int rpc_port_list_autofill_svc_response_group_clone(rpc_port_list_autofill_svc_response_group_h h, rpc_port_list_autofill_svc_response_group_h *clone); + +int rpc_port_list_autofill_svc_response_group_add_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, rpc_port_autofill_svc_response_group_h list_autofill_svc_response_groups); + +int rpc_port_list_autofill_svc_response_group_foreach_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, + bool (*callback)(rpc_port_autofill_svc_response_group_h list_autofill_svc_response_groups, void *user_data), void *user_data); + +int rpc_port_list_autofill_svc_response_group_remove_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, unsigned int nth); + +int rpc_port_list_autofill_svc_response_group_get_list_autofill_svc_response_groups_length(rpc_port_list_autofill_svc_response_group_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 list_autofill_svc_save_item_s *rpc_port_list_autofill_svc_save_item_h; + +int rpc_port_list_autofill_svc_save_item_create(rpc_port_list_autofill_svc_save_item_h *h); + +int rpc_port_list_autofill_svc_save_item_destroy(rpc_port_list_autofill_svc_save_item_h h); + +int rpc_port_list_autofill_svc_save_item_clone(rpc_port_list_autofill_svc_save_item_h h, rpc_port_list_autofill_svc_save_item_h *clone); + +int rpc_port_list_autofill_svc_save_item_add_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, rpc_port_autofill_svc_save_item_h list_autofill_svc_save_items); + +int rpc_port_list_autofill_svc_save_item_foreach_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, + bool (*callback)(rpc_port_autofill_svc_save_item_h list_autofill_svc_save_items, void *user_data), void *user_data); + +int rpc_port_list_autofill_svc_save_item_remove_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, unsigned int nth); + +int rpc_port_list_autofill_svc_save_item_get_list_autofill_svc_save_items_length(rpc_port_list_autofill_svc_save_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, int context_id, 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, int context_id, 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, int context_id, rpc_port_autofill_svc_view_info_h vi); + +void rpc_port_proxy_AutofillSvcPort_invoke_send_fill_request(rpc_port_proxy_AutofillSvcPort_h h, int context_id, rpc_port_autofill_svc_view_info_h vi); + +void rpc_port_proxy_AutofillSvcPort_invoke_commit(rpc_port_proxy_AutofillSvcPort_h h, int context_id, rpc_port_autofill_svc_save_view_info_h si); + +void rpc_port_proxy_AutofillSvcPort_invoke_request_terminate(rpc_port_proxy_AutofillSvcPort_h h); + +#ifdef __cplusplus +} +#endif diff --git a/src/autofill_stub.c b/src/autofill_stub.c new file mode 100644 index 0000000..086ada2 --- /dev/null +++ b/src/autofill_stub.c @@ -0,0 +1,4148 @@ +/* + * Generated by tidlc 1.3.2. + * + * 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_save_item_s { + rpc_port_parcelable_t parcelable; + char *id; + char *label; + char *value; + int autofill_hint; + bool is_sensitive_data; +}; + +static void __autofill_save_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_save_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_save_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_save_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_save_item_create(rpc_port_autofill_save_item_h *h) +{ + struct autofill_save_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_save_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_save_item_to; + handle->parcelable.from = __autofill_save_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_save_item_destroy(rpc_port_autofill_save_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_save_item_clone(rpc_port_autofill_save_item_h h, rpc_port_autofill_save_item_h *clone) +{ + rpc_port_autofill_save_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_save_item_create(&handle); + if (!handle) { + _E("Failed to create autofill_save_item handle"); + return -1; + } + + if (h->id) { + handle->id = strdup(h->id); + if (!handle->id) { + _E("Failed to duplicate h->id"); + rpc_port_autofill_save_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_save_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_save_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_save_item_set_id(rpc_port_autofill_save_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_save_item_set_label(rpc_port_autofill_save_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_save_item_set_value(rpc_port_autofill_save_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_save_item_set_autofill_hint(rpc_port_autofill_save_item_h h, int autofill_hint) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + h->autofill_hint = autofill_hint; + return 0; +} + +int rpc_port_autofill_save_item_set_is_sensitive_data(rpc_port_autofill_save_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_save_item_get_id(rpc_port_autofill_save_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_save_item_get_label(rpc_port_autofill_save_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_save_item_get_value(rpc_port_autofill_save_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_save_item_get_autofill_hint(rpc_port_autofill_save_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_save_item_get_is_sensitive_data(rpc_port_autofill_save_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_save_view_info_s { + rpc_port_parcelable_t parcelable; + char *view_id; + GList *items; +}; + +static void __autofill_save_view_info_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_save_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_save_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_save_view_info_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_save_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_save_item_h value = NULL; + + rpc_port_autofill_save_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_save_view_info_create(rpc_port_autofill_save_view_info_h *h) +{ + struct autofill_save_view_info_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_save_view_info_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_save_view_info_to; + handle->parcelable.from = __autofill_save_view_info_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_save_view_info_destroy(rpc_port_autofill_save_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_save_item_h value = iter->data; + if (value) + rpc_port_autofill_save_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_autofill_save_view_info_clone(rpc_port_autofill_save_view_info_h h, rpc_port_autofill_save_view_info_h *clone) +{ + rpc_port_autofill_save_view_info_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_save_view_info_create(&handle); + if (!handle) { + _E("Failed to create autofill_save_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_save_view_info_destroy(handle); + return -1; + } + } + + do { + GList *iter; + + iter = h->items; + while (iter) { + rpc_port_autofill_save_item_h new_value; + rpc_port_autofill_save_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_autofill_save_view_info_destroy(handle); + return -1; + } + + rpc_port_autofill_save_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_save_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_save_view_info_set_view_id(rpc_port_autofill_save_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_save_view_info_add_items(rpc_port_autofill_save_view_info_h h, rpc_port_autofill_save_item_h items) +{ + if (!h || !items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_save_item_h value = NULL; + + rpc_port_autofill_save_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_save_view_info_get_view_id(rpc_port_autofill_save_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_save_view_info_foreach_items(rpc_port_autofill_save_view_info_h h, + bool (*callback)(rpc_port_autofill_save_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_save_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_save_view_info_remove_items(rpc_port_autofill_save_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_save_item_h value = iter->data; + h->items = g_list_remove_link(h->items, iter); + rpc_port_autofill_save_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_save_view_info_get_items_length(rpc_port_autofill_save_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; + char *view_id; + 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_string(parcel, h->view_id ? h->view_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_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_string(parcel, &h->view_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_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->view_id) + free(h->view_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_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; + } + + 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_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_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_view_id(rpc_port_autofill_auth_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_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_view_id(rpc_port_autofill_auth_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_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_response_group_s { + rpc_port_parcelable_t parcelable; + GList *response_items; +}; + +static void __autofill_response_group_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_response_group_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + 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_response_group_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_autofill_response_group_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->response_items = g_list_append(h->response_items, value); + } + } while (0); +} + +int rpc_port_autofill_response_group_create(rpc_port_autofill_response_group_h *h) +{ + struct autofill_response_group_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct autofill_response_group_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __autofill_response_group_to; + handle->parcelable.from = __autofill_response_group_from; + + *h = handle; + + return 0; +} + +int rpc_port_autofill_response_group_destroy(rpc_port_autofill_response_group_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + 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_response_group_clone(rpc_port_autofill_response_group_h h, rpc_port_autofill_response_group_h *clone) +{ + rpc_port_autofill_response_group_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_autofill_response_group_create(&handle); + if (!handle) { + _E("Failed to create autofill_response_group 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_response_group_destroy(handle); + return -1; + } + + rpc_port_autofill_response_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_response_group_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_response_group_add_response_items(rpc_port_autofill_response_group_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_response_group_foreach_response_items(rpc_port_autofill_response_group_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_response_group_remove_response_items(rpc_port_autofill_response_group_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_response_group_get_response_items_length(rpc_port_autofill_response_group_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->response_items); + + return 0; +} + +struct autofill_fill_response_s { + rpc_port_parcelable_t parcelable; + char *view_id; + GList *response_groups; +}; + +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_groups)); + do { + GList *iter; + + iter = h->response_groups; + while (iter) { + rpc_port_autofill_response_group_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_group_h value = NULL; + + rpc_port_autofill_response_group_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->response_groups = g_list_append(h->response_groups, 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_groups; + while (iter) { + rpc_port_autofill_response_group_h value = iter->data; + if (value) + rpc_port_autofill_response_group_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->response_groups); + } 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_groups; + while (iter) { + rpc_port_autofill_response_group_h new_value; + rpc_port_autofill_response_group_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_autofill_fill_response_destroy(handle); + return -1; + } + + rpc_port_autofill_response_group_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_autofill_fill_response_destroy(handle); + return -1; + } + + handle->response_groups = g_list_append(handle->response_groups, 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_groups(rpc_port_autofill_fill_response_h h, rpc_port_autofill_response_group_h response_groups) +{ + if (!h || !response_groups) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_response_group_h value = NULL; + + rpc_port_autofill_response_group_clone(response_groups, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->response_groups = g_list_append(h->response_groups, 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_groups(rpc_port_autofill_fill_response_h h, + bool (*callback)(rpc_port_autofill_response_group_h response_groups, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->response_groups; + while (iter) { + rpc_port_autofill_response_group_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_groups(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_groups, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_response_group_h value = iter->data; + h->response_groups = g_list_remove_link(h->response_groups, iter); + rpc_port_autofill_response_group_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_autofill_fill_response_get_response_groups_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_groups); + + 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_group_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_response_groups; +}; + +static void __list_autofill_response_group_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_response_group_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_response_groups)); + do { + GList *iter; + + iter = h->list_autofill_response_groups; + while (iter) { + rpc_port_autofill_response_group_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_group_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_response_group_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_group_h value = NULL; + + rpc_port_autofill_response_group_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_response_groups = g_list_append(h->list_autofill_response_groups, value); + } + } while (0); +} + +int rpc_port_list_autofill_response_group_create(rpc_port_list_autofill_response_group_h *h) +{ + struct list_autofill_response_group_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_response_group_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_response_group_to; + handle->parcelable.from = __list_autofill_response_group_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_response_group_destroy(rpc_port_list_autofill_response_group_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_response_groups; + while (iter) { + rpc_port_autofill_response_group_h value = iter->data; + if (value) + rpc_port_autofill_response_group_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_response_groups); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_response_group_clone(rpc_port_list_autofill_response_group_h h, rpc_port_list_autofill_response_group_h *clone) +{ + rpc_port_list_autofill_response_group_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_response_group_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_response_group handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_response_groups; + while (iter) { + rpc_port_autofill_response_group_h new_value; + rpc_port_autofill_response_group_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_response_group_destroy(handle); + return -1; + } + + rpc_port_autofill_response_group_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_response_group_destroy(handle); + return -1; + } + + handle->list_autofill_response_groups = g_list_append(handle->list_autofill_response_groups, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_response_group_add_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, rpc_port_autofill_response_group_h list_autofill_response_groups) +{ + if (!h || !list_autofill_response_groups) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_response_group_h value = NULL; + + rpc_port_autofill_response_group_clone(list_autofill_response_groups, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_response_groups = g_list_append(h->list_autofill_response_groups, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_response_group_foreach_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, + bool (*callback)(rpc_port_autofill_response_group_h list_autofill_response_groups, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_response_groups; + while (iter) { + rpc_port_autofill_response_group_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_group_remove_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_response_groups, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_response_group_h value = iter->data; + h->list_autofill_response_groups = g_list_remove_link(h->list_autofill_response_groups, iter); + rpc_port_autofill_response_group_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_response_group_get_list_autofill_response_groups_length(rpc_port_list_autofill_response_group_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_response_groups); + + 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; +} + +struct list_autofill_save_item_s { + rpc_port_parcelable_t parcelable; + GList *list_autofill_save_items; +}; + +static void __list_autofill_save_item_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_save_item_h h = data; + + if (!parcel || !h) { + _E("Invalid parameter"); + return; + } + + rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_save_items)); + do { + GList *iter; + + iter = h->list_autofill_save_items; + while (iter) { + rpc_port_autofill_save_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_save_item_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_list_autofill_save_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_save_item_h value = NULL; + + rpc_port_autofill_save_item_create(&value); + if (!value) { + _E("Failed to create handle"); + return; + } + + rpc_port_parcel_read(parcel, &value->parcelable, value); + h->list_autofill_save_items = g_list_append(h->list_autofill_save_items, value); + } + } while (0); +} + +int rpc_port_list_autofill_save_item_create(rpc_port_list_autofill_save_item_h *h) +{ + struct list_autofill_save_item_s *handle; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct list_autofill_save_item_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __list_autofill_save_item_to; + handle->parcelable.from = __list_autofill_save_item_from; + + *h = handle; + + return 0; +} + +int rpc_port_list_autofill_save_item_destroy(rpc_port_list_autofill_save_item_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_save_items; + while (iter) { + rpc_port_autofill_save_item_h value = iter->data; + if (value) + rpc_port_autofill_save_item_destroy(value); + + iter = g_list_next(iter); + } + g_list_free(h->list_autofill_save_items); + } while (0); + + free(h); + + return 0; +} + +int rpc_port_list_autofill_save_item_clone(rpc_port_list_autofill_save_item_h h, rpc_port_list_autofill_save_item_h *clone) +{ + rpc_port_list_autofill_save_item_h handle = NULL; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + rpc_port_list_autofill_save_item_create(&handle); + if (!handle) { + _E("Failed to create list_autofill_save_item handle"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_save_items; + while (iter) { + rpc_port_autofill_save_item_h new_value; + rpc_port_autofill_save_item_h value = iter->data; + + if (!value) { + _E("Error: value is NULL"); + rpc_port_list_autofill_save_item_destroy(handle); + return -1; + } + + rpc_port_autofill_save_item_clone(value, &new_value); + if (!new_value) { + _E("Failed to duplicate value"); + rpc_port_list_autofill_save_item_destroy(handle); + return -1; + } + + handle->list_autofill_save_items = g_list_append(handle->list_autofill_save_items, new_value); + iter = g_list_next(iter); + } + } while (0); + + *clone = handle; + + return 0; +} + +int rpc_port_list_autofill_save_item_add_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, rpc_port_autofill_save_item_h list_autofill_save_items) +{ + if (!h || !list_autofill_save_items) { + _E("Invalid parameter"); + return -1; + } + + do { + rpc_port_autofill_save_item_h value = NULL; + + rpc_port_autofill_save_item_clone(list_autofill_save_items, &value); + if (!value) { + _E("Out of memory"); + return -1; + } + + h->list_autofill_save_items = g_list_append(h->list_autofill_save_items, value); + } while (0); + + return 0; +} + +int rpc_port_list_autofill_save_item_foreach_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, + bool (*callback)(rpc_port_autofill_save_item_h list_autofill_save_items, void *user_data), void *user_data) +{ + if (!h || !callback) { + _E("Invalid parameter"); + return -1; + } + + do { + GList *iter; + + iter = h->list_autofill_save_items; + while (iter) { + rpc_port_autofill_save_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_save_item_remove_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, unsigned int nth) +{ + GList *iter; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + iter = g_list_nth(h->list_autofill_save_items, nth); + if (iter == NULL) + return -1; + + rpc_port_autofill_save_item_h value = iter->data; + h->list_autofill_save_items = g_list_remove_link(h->list_autofill_save_items, iter); + rpc_port_autofill_save_item_destroy(value); + g_list_free(iter); + + return 0; +} + +int rpc_port_list_autofill_save_item_get_list_autofill_save_items_length(rpc_port_list_autofill_save_item_h h, unsigned int *length) +{ + if (!h || !length) { + _E("Invalid parameter"); + return -1; + } + + *length = g_list_length(h->list_autofill_save_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, + AutofillAppPort_METHOD_commit, +}; + +enum AutofillAppPort_delegate_e { + AutofillAppPort_DELEGATE_autofill_auth_info_received_cb = 1, + AutofillAppPort_DELEGATE_autofill_fill_response_received_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_received_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_received_cb_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillAppPort_autofill_auth_info_received_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_received_cb_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillAppPort_autofill_auth_info_received_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_received_cb_create(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h *h) +{ + struct AutofillAppPort_autofill_auth_info_received_cb_s *handle; + static int seq_num; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillAppPort_autofill_auth_info_received_cb_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __AutofillAppPort_autofill_auth_info_received_cb_to; + handle->parcelable.from = __AutofillAppPort_autofill_auth_info_received_cb_from; + handle->id = AutofillAppPort_DELEGATE_autofill_auth_info_received_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_received_cb_destroy(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + free(h); + + return 0; +} + +int rpc_port_AutofillAppPort_autofill_auth_info_received_cb_clone(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h h, rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h *clone) +{ + rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h handle; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillAppPort_autofill_auth_info_received_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_received_cb_invoke(rpc_port_AutofillAppPort_autofill_auth_info_received_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_received_cb_set_port(rpc_port_AutofillAppPort_autofill_auth_info_received_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_received_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_received_cb_to(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillAppPort_autofill_fill_response_received_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_received_cb_from(rpc_port_parcel_h parcel, void *data) +{ + rpc_port_AutofillAppPort_autofill_fill_response_received_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_received_cb_create(rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h *h) +{ + struct AutofillAppPort_autofill_fill_response_received_cb_s *handle; + static int seq_num; + + if (!h) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillAppPort_autofill_fill_response_received_cb_s)); + if (!handle) { + _E("Out of memory"); + return -1; + } + + handle->parcelable.to = __AutofillAppPort_autofill_fill_response_received_cb_to; + handle->parcelable.from = __AutofillAppPort_autofill_fill_response_received_cb_from; + handle->id = AutofillAppPort_DELEGATE_autofill_fill_response_received_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_received_cb_destroy(rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h h) +{ + if (!h) { + _E("Invalid parameter"); + return -1; + } + + free(h); + + return 0; +} + +int rpc_port_AutofillAppPort_autofill_fill_response_received_cb_clone(rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h h, rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h *clone) +{ + rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h handle; + + if (!h || !clone) { + _E("Invalid parameter"); + return -1; + } + + handle = calloc(1, sizeof(struct AutofillAppPort_autofill_fill_response_received_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_received_cb_invoke(rpc_port_AutofillAppPort_autofill_fill_response_received_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_received_cb_set_port(rpc_port_AutofillAppPort_autofill_fill_response_received_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; + } + + int context_id; + rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_cb = NULL; + rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_cb = NULL; + + rpc_port_parcel_read_int32(parcel, &context_id); + rpc_port_AutofillAppPort_autofill_auth_info_received_cb_create(&auth_info_cb); + + if (!auth_info_cb) { + _E("Failed to create handle"); + return -1; + } + + rpc_port_AutofillAppPort_autofill_auth_info_received_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_received_cb_create(&fill_response_cb); + + if (!fill_response_cb) { + _E("Failed to create handle"); + return -1; + } + + rpc_port_AutofillAppPort_autofill_fill_response_received_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, context_id, 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_received_cb_destroy(auth_info_cb); + rpc_port_AutofillAppPort_autofill_fill_response_received_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; + } + + int context_id; + + rpc_port_parcel_read_int32(parcel, &context_id); + + context->callback.Unregister(context, context_id, 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; + } + + int context_id; + rpc_port_autofill_view_info_h vi = NULL; + + rpc_port_parcel_read_int32(parcel, &context_id); + rpc_port_autofill_view_info_create(&vi); + rpc_port_parcel_read(parcel, &vi->parcelable, vi); + + int ret = context->callback.request_auth_info(context, context_id, vi, 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_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; + } + + int context_id; + rpc_port_autofill_view_info_h vi = NULL; + + rpc_port_parcel_read_int32(parcel, &context_id); + rpc_port_autofill_view_info_create(&vi); + rpc_port_parcel_read(parcel, &vi->parcelable, vi); + + int ret = context->callback.send_fill_request(context, context_id, vi, 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_autofill_view_info_destroy(vi); + return 0; +} + +static int __AutofillAppPort_method_commit(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; + } + + int context_id; + rpc_port_autofill_save_view_info_h vi = NULL; + + rpc_port_parcel_read_int32(parcel, &context_id); + rpc_port_autofill_save_view_info_create(&vi); + rpc_port_parcel_read(parcel, &vi->parcelable, vi); + + int ret = context->callback.commit(context, context_id, vi, 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_autofill_save_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, + [AutofillAppPort_METHOD_commit] = __AutofillAppPort_method_commit, +}; + +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/src/autofill_stub.h b/src/autofill_stub.h new file mode 100644 index 0000000..9a3682c --- /dev/null +++ b/src/autofill_stub.h @@ -0,0 +1,327 @@ +/* + * Generated by tidlc 1.3.2. + * + * 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_save_item_s *rpc_port_autofill_save_item_h; + +int rpc_port_autofill_save_item_create(rpc_port_autofill_save_item_h *h); + +int rpc_port_autofill_save_item_destroy(rpc_port_autofill_save_item_h h); + +int rpc_port_autofill_save_item_clone(rpc_port_autofill_save_item_h h, rpc_port_autofill_save_item_h *clone); + +int rpc_port_autofill_save_item_set_id(rpc_port_autofill_save_item_h h, const char *id); + +int rpc_port_autofill_save_item_set_label(rpc_port_autofill_save_item_h h, const char *label); + +int rpc_port_autofill_save_item_set_value(rpc_port_autofill_save_item_h h, const char *value); + +int rpc_port_autofill_save_item_set_autofill_hint(rpc_port_autofill_save_item_h h, int autofill_hint); + +int rpc_port_autofill_save_item_set_is_sensitive_data(rpc_port_autofill_save_item_h h, bool is_sensitive_data); + +int rpc_port_autofill_save_item_get_id(rpc_port_autofill_save_item_h h, char **id); + +int rpc_port_autofill_save_item_get_label(rpc_port_autofill_save_item_h h, char **label); + +int rpc_port_autofill_save_item_get_value(rpc_port_autofill_save_item_h h, char **value); + +int rpc_port_autofill_save_item_get_autofill_hint(rpc_port_autofill_save_item_h h, int *autofill_hint); + +int rpc_port_autofill_save_item_get_is_sensitive_data(rpc_port_autofill_save_item_h h, bool *is_sensitive_data); + +typedef struct autofill_save_view_info_s *rpc_port_autofill_save_view_info_h; + +int rpc_port_autofill_save_view_info_create(rpc_port_autofill_save_view_info_h *h); + +int rpc_port_autofill_save_view_info_destroy(rpc_port_autofill_save_view_info_h h); + +int rpc_port_autofill_save_view_info_clone(rpc_port_autofill_save_view_info_h h, rpc_port_autofill_save_view_info_h *clone); + +int rpc_port_autofill_save_view_info_set_view_id(rpc_port_autofill_save_view_info_h h, const char *view_id); + +int rpc_port_autofill_save_view_info_add_items(rpc_port_autofill_save_view_info_h h, rpc_port_autofill_save_item_h items); + +int rpc_port_autofill_save_view_info_get_view_id(rpc_port_autofill_save_view_info_h h, char **view_id); + +int rpc_port_autofill_save_view_info_foreach_items(rpc_port_autofill_save_view_info_h h, + bool (*callback)(rpc_port_autofill_save_item_h items, void *user_data), void *user_data); + +int rpc_port_autofill_save_view_info_remove_items(rpc_port_autofill_save_view_info_h h, unsigned int nth); + +int rpc_port_autofill_save_view_info_get_items_length(rpc_port_autofill_save_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_view_id(rpc_port_autofill_auth_info_h h, const char *view_id); + +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_view_id(rpc_port_autofill_auth_info_h h, char **view_id); + +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_response_group_s *rpc_port_autofill_response_group_h; + +int rpc_port_autofill_response_group_create(rpc_port_autofill_response_group_h *h); + +int rpc_port_autofill_response_group_destroy(rpc_port_autofill_response_group_h h); + +int rpc_port_autofill_response_group_clone(rpc_port_autofill_response_group_h h, rpc_port_autofill_response_group_h *clone); + +int rpc_port_autofill_response_group_add_response_items(rpc_port_autofill_response_group_h h, rpc_port_autofill_response_item_h response_items); + +int rpc_port_autofill_response_group_foreach_response_items(rpc_port_autofill_response_group_h h, + bool (*callback)(rpc_port_autofill_response_item_h response_items, void *user_data), void *user_data); + +int rpc_port_autofill_response_group_remove_response_items(rpc_port_autofill_response_group_h h, unsigned int nth); + +int rpc_port_autofill_response_group_get_response_items_length(rpc_port_autofill_response_group_h h, unsigned int *length); + +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_groups(rpc_port_autofill_fill_response_h h, rpc_port_autofill_response_group_h response_groups); + +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_groups(rpc_port_autofill_fill_response_h h, + bool (*callback)(rpc_port_autofill_response_group_h response_groups, void *user_data), void *user_data); + +int rpc_port_autofill_fill_response_remove_response_groups(rpc_port_autofill_fill_response_h h, unsigned int nth); + +int rpc_port_autofill_fill_response_get_response_groups_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_group_s *rpc_port_list_autofill_response_group_h; + +int rpc_port_list_autofill_response_group_create(rpc_port_list_autofill_response_group_h *h); + +int rpc_port_list_autofill_response_group_destroy(rpc_port_list_autofill_response_group_h h); + +int rpc_port_list_autofill_response_group_clone(rpc_port_list_autofill_response_group_h h, rpc_port_list_autofill_response_group_h *clone); + +int rpc_port_list_autofill_response_group_add_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, rpc_port_autofill_response_group_h list_autofill_response_groups); + +int rpc_port_list_autofill_response_group_foreach_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, + bool (*callback)(rpc_port_autofill_response_group_h list_autofill_response_groups, void *user_data), void *user_data); + +int rpc_port_list_autofill_response_group_remove_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, unsigned int nth); + +int rpc_port_list_autofill_response_group_get_list_autofill_response_groups_length(rpc_port_list_autofill_response_group_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 list_autofill_save_item_s *rpc_port_list_autofill_save_item_h; + +int rpc_port_list_autofill_save_item_create(rpc_port_list_autofill_save_item_h *h); + +int rpc_port_list_autofill_save_item_destroy(rpc_port_list_autofill_save_item_h h); + +int rpc_port_list_autofill_save_item_clone(rpc_port_list_autofill_save_item_h h, rpc_port_list_autofill_save_item_h *clone); + +int rpc_port_list_autofill_save_item_add_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, rpc_port_autofill_save_item_h list_autofill_save_items); + +int rpc_port_list_autofill_save_item_foreach_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, + bool (*callback)(rpc_port_autofill_save_item_h list_autofill_save_items, void *user_data), void *user_data); + +int rpc_port_list_autofill_save_item_remove_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, unsigned int nth); + +int rpc_port_list_autofill_save_item_get_list_autofill_save_items_length(rpc_port_list_autofill_save_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_received_cb_s *rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h; + +int rpc_port_AutofillAppPort_autofill_auth_info_received_cb_destroy(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h h); + +int rpc_port_AutofillAppPort_autofill_auth_info_received_cb_clone(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h h, rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h *clone); + +int rpc_port_AutofillAppPort_autofill_auth_info_received_cb_invoke(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h h, rpc_port_autofill_auth_info_h auth_info); + +typedef struct AutofillAppPort_autofill_fill_response_received_cb_s *rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h; + +int rpc_port_AutofillAppPort_autofill_fill_response_received_cb_destroy(rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h h); + +int rpc_port_AutofillAppPort_autofill_fill_response_received_cb_clone(rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h h, rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h *clone); + +int rpc_port_AutofillAppPort_autofill_fill_response_received_cb_invoke(rpc_port_AutofillAppPort_autofill_fill_response_received_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, int context_id, rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_cb, rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_cb, void *user_data); + void (*Unregister)(rpc_port_stub_AutofillAppPort_context_h context, int context_id, void *user_data); + int (*request_auth_info)(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_view_info_h vi, void *user_data); + int (*send_fill_request)(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_view_info_h vi, void *user_data); + int (*commit)(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_save_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 -- 2.7.4 From b61d882c589f14c00ae31a7da4a1776fb8c7cf61 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 17 Dec 2018 14:16:07 +0900 Subject: [PATCH 06/11] Add AutofillManagerPort in bypass list Change-Id: I096d3aa1798a44f326921cd9d2ffc45f347b4829 Signed-off-by: Jihoon Kim --- tizen-manifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tizen-manifest.xml b/tizen-manifest.xml index 50b355e..9867d5b 100644 --- a/tizen-manifest.xml +++ b/tizen-manifest.xml @@ -3,7 +3,7 @@ - + http://tizen.org/privilege/appmanager.launch -- 2.7.4 From 857f01bc2eaa961108fd44a2563818148c938aaf Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 17 Dec 2018 14:16:25 +0900 Subject: [PATCH 07/11] Revert "Disable to use tidlc temporarily" This reverts commit 02bf7bf8367297aa7066856f3f4a2bcd8186d572. Change-Id: I096b2497afe7802b32f4d3f8816a0cb594e68bc0 --- build_def.prop | 2 +- src/autofill_manager_stub.c | 681 ------- src/autofill_manager_stub.h | 70 - src/autofill_service_proxy.c | 4261 ------------------------------------------ src/autofill_service_proxy.h | 346 ---- src/autofill_stub.c | 4148 ---------------------------------------- src/autofill_stub.h | 327 ---- 7 files changed, 1 insertion(+), 9834 deletions(-) delete mode 100644 src/autofill_manager_stub.c delete mode 100644 src/autofill_manager_stub.h delete mode 100644 src/autofill_service_proxy.c delete mode 100644 src/autofill_service_proxy.h delete mode 100644 src/autofill_stub.c delete mode 100644 src/autofill_stub.h diff --git a/build_def.prop b/build_def.prop index 6bb5e2f..520f46f 100644 --- a/build_def.prop +++ b/build_def.prop @@ -1,6 +1,6 @@ # Add pre/post build process PREBUILD_DESC = -PREBUILD_COMMAND = +PREBUILD_COMMAND = tidlc -s -l C -i tidl/autofill.tidl -o autofill_stub; mv autofill_stub.h ./src/; mv autofill_stub.c ./src/; tidlc -p -l C -i tidl/autofill_service.tidl -o autofill_service_proxy; mv autofill_service_proxy.h ./src/; mv autofill_service_proxy.c ./src/; tidlc -s -l C -i tidl/autofill_manager.tidl -o autofill_manager_stub; mv autofill_manager_stub.h ./src/; mv autofill_manager_stub.c ./src/; POSTBUILD_DESC = POSTBUILD_COMMAND = diff --git a/src/autofill_manager_stub.c b/src/autofill_manager_stub.c deleted file mode 100644 index a662337..0000000 --- a/src/autofill_manager_stub.c +++ /dev/null @@ -1,681 +0,0 @@ -/* - * Generated by tidlc 1.3.2. - * - * 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_manager_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 list_string_s { - rpc_port_parcelable_t parcelable; - GList *list_strings; -}; - -static void __list_string_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_list_string_h h = data; - - if (!parcel || !h) { - _E("Invalid parameter"); - return; - } - - rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_strings)); - do { - GList *iter; - - iter = h->list_strings; - while (iter) { - char *value = iter->data; - - iter = g_list_next(iter); - if (!value) { - _W("Warning: value is NULL"); - continue; - } - rpc_port_parcel_write_string(parcel, value ? value : ""); - } - } while (0); -} - -static void __list_string_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_list_string_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++) { - char *value = NULL; - - rpc_port_parcel_read_string(parcel, &value); - h->list_strings = g_list_append(h->list_strings, value); - } - } while (0); -} - -int rpc_port_list_string_create(rpc_port_list_string_h *h) -{ - struct list_string_s *handle; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct list_string_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __list_string_to; - handle->parcelable.from = __list_string_from; - - *h = handle; - - return 0; -} - -int rpc_port_list_string_destroy(rpc_port_list_string_h h) -{ - if (!h) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->list_strings; - while (iter) { - char *value = iter->data; - if (value) - free(value); - - iter = g_list_next(iter); - } - g_list_free(h->list_strings); - } while (0); - - free(h); - - return 0; -} - -int rpc_port_list_string_clone(rpc_port_list_string_h h, rpc_port_list_string_h *clone) -{ - rpc_port_list_string_h handle = NULL; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - rpc_port_list_string_create(&handle); - if (!handle) { - _E("Failed to create list_string handle"); - return -1; - } - - do { - GList *iter; - - iter = h->list_strings; - while (iter) { - char *new_value; - char *value = iter->data; - - if (!value) { - _E("Error: value is NULL"); - rpc_port_list_string_destroy(handle); - return -1; - } - - new_value = strdup(value); - if (!new_value) { - _E("Failed to duplicate value"); - rpc_port_list_string_destroy(handle); - return -1; - } - - handle->list_strings = g_list_append(handle->list_strings, new_value); - iter = g_list_next(iter); - } - } while (0); - - *clone = handle; - - return 0; -} - -int rpc_port_list_string_add_list_strings(rpc_port_list_string_h h, const char *list_strings) -{ - if (!h || !list_strings) { - _E("Invalid parameter"); - return -1; - } - - do { - char *value = NULL; - - value = strdup(list_strings); - if (!value) { - _E("Out of memory"); - return -1; - } - - h->list_strings = g_list_append(h->list_strings, value); - } while (0); - - return 0; -} - -int rpc_port_list_string_foreach_list_strings(rpc_port_list_string_h h, - bool (*callback)(const char *list_strings, void *user_data), void *user_data) -{ - if (!h || !callback) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->list_strings; - while (iter) { - char *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_string_remove_list_strings(rpc_port_list_string_h h, unsigned int nth) -{ - GList *iter; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - iter = g_list_nth(h->list_strings, nth); - if (iter == NULL) - return -1; - - char *value = iter->data; - h->list_strings = g_list_remove_link(h->list_strings, iter); - if (value) - free(value); - - g_list_free(iter); - - return 0; -} - -int rpc_port_list_string_get_list_strings_length(rpc_port_list_string_h h, unsigned int *length) -{ - if (!h || !length) { - _E("Invalid parameter"); - return -1; - } - - *length = g_list_length(h->list_strings); - - return 0; -} - -enum AutofillManagerPort_method_e { - AutofillManagerPort_METHOD_Result, - AutofillManagerPort_METHOD_Callback, - AutofillManagerPort_METHOD_set_autofill_service, - AutofillManagerPort_METHOD_get_autofill_service, - AutofillManagerPort_METHOD_get_autofill_service_list, -}; - -static rpc_port_stub_h __AutofillManagerPort_stub; -static rpc_port_stub_AutofillManagerPort_callback_s __AutofillManagerPort_callback; -static void *__AutofillManagerPort_user_data; -static GList *__AutofillManagerPort_contexts; - -struct AutofillManagerPort_context_s { - char *sender; - char *instance; - rpc_port_h port; - void *tag; - rpc_port_stub_AutofillManagerPort_callback_s callback; - void *user_data; -}; - -static struct AutofillManagerPort_context_s *__create_AutofillManagerPort_context(const char *sender, const char *instance) -{ - struct AutofillManagerPort_context_s *handle; - - handle = calloc(1, sizeof(struct AutofillManagerPort_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 = __AutofillManagerPort_callback; - handle->user_data = __AutofillManagerPort_user_data; - - return handle; -} - -static void __destroy_AutofillManagerPort_context(gpointer data) -{ - struct AutofillManagerPort_context_s *handle = data; - - if (!handle) { - _E("Critical error!"); - return; - } - - free(handle->instance); - free(handle->sender); - free(handle); -} - -static struct AutofillManagerPort_context_s *__find_AutofillManagerPort_context(const char *instance) -{ - struct AutofillManagerPort_context_s *handle; - GList *iter; - - iter = __AutofillManagerPort_contexts; - while (iter) { - handle = (struct AutofillManagerPort_context_s *)iter->data; - if (!strcmp(handle->instance, instance)) - return handle; - iter = g_list_next(iter); - } - - return NULL; -} - -int rpc_port_stub_AutofillManagerPort_context_set_tag(rpc_port_stub_AutofillManagerPort_context_h ctx, void *tag) -{ - if (!ctx) { - _E("Invalid parameter"); - return -1; - } - - ctx->tag = tag; - - return 0; -} - -int rpc_port_stub_AutofillManagerPort_context_get_tag(rpc_port_stub_AutofillManagerPort_context_h ctx, void **tag) -{ - if (!ctx || !tag) { - _E("Invalid parameter"); - return -1; - } - - *tag = ctx->tag; - - return 0; -} - -int rpc_port_stub_AutofillManagerPort_context_get_sender(rpc_port_stub_AutofillManagerPort_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; -} - -static int __AutofillManagerPort_method_set_autofill_service(rpc_port_h port, rpc_port_parcel_h parcel, void *data) -{ - rpc_port_stub_AutofillManagerPort_context_h context = data; - rpc_port_h callback_port; - int r; - - r = rpc_port_stub_get_port(__AutofillManagerPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); - if (r != 0) { - _E("Failed to get callback port"); - return -1; - } - - char *app_id; - - rpc_port_parcel_read_string(parcel, &app_id); - - bool ret = context->callback.set_autofill_service(context, app_id, context->user_data); - do { - rpc_port_parcel_h result; - - rpc_port_parcel_create(&result); - rpc_port_parcel_write_int32(result, AutofillManagerPort_METHOD_Result); - rpc_port_parcel_write_bool(result, ret); - rpc_port_parcel_send(result, port); - rpc_port_parcel_destroy(result); - } while (0); - - free(app_id); - return 0; -} - -static int __AutofillManagerPort_method_get_autofill_service(rpc_port_h port, rpc_port_parcel_h parcel, void *data) -{ - rpc_port_stub_AutofillManagerPort_context_h context = data; - rpc_port_h callback_port; - int r; - - r = rpc_port_stub_get_port(__AutofillManagerPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); - if (r != 0) { - _E("Failed to get callback port"); - return -1; - } - - char *ret = context->callback.get_autofill_service(context, context->user_data); - do { - rpc_port_parcel_h result; - - rpc_port_parcel_create(&result); - rpc_port_parcel_write_int32(result, AutofillManagerPort_METHOD_Result); - rpc_port_parcel_write_string(result, ret ? ret : ""); - rpc_port_parcel_send(result, port); - rpc_port_parcel_destroy(result); - } while (0); - free(ret); - return 0; -} - -static int __AutofillManagerPort_method_get_autofill_service_list(rpc_port_h port, rpc_port_parcel_h parcel, void *data) -{ - rpc_port_stub_AutofillManagerPort_context_h context = data; - rpc_port_h callback_port; - int r; - - r = rpc_port_stub_get_port(__AutofillManagerPort_stub, RPC_PORT_PORT_CALLBACK, context->instance, &callback_port); - if (r != 0) { - _E("Failed to get callback port"); - return -1; - } - - rpc_port_list_string_h service_info_list = NULL; - - bool ret = context->callback.get_autofill_service_list(context, &service_info_list, context->user_data); - do { - rpc_port_parcel_h result; - - rpc_port_parcel_create(&result); - rpc_port_parcel_write_int32(result, AutofillManagerPort_METHOD_Result); - rpc_port_parcel_write(result, &service_info_list->parcelable, service_info_list); - rpc_port_parcel_write_bool(result, ret); - rpc_port_parcel_send(result, port); - rpc_port_parcel_destroy(result); - } while (0); - - rpc_port_list_string_destroy(service_info_list); - return 0; -} - -static stub_method __AutofillManagerPort_method_table[] = { - [AutofillManagerPort_METHOD_set_autofill_service] = __AutofillManagerPort_method_set_autofill_service, - [AutofillManagerPort_METHOD_get_autofill_service] = __AutofillManagerPort_method_get_autofill_service, - [AutofillManagerPort_METHOD_get_autofill_service_list] = __AutofillManagerPort_method_get_autofill_service_list, -}; - -static void __AutofillManagerPort_on_connected(const char *sender, const char *instance, void *data) -{ - rpc_port_stub_AutofillManagerPort_context_h context; - - _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); - context = __create_AutofillManagerPort_context(sender, instance); - if (!context) - return; - - if (context->callback.create) - context->callback.create(context, context->user_data); - __AutofillManagerPort_contexts = g_list_append(__AutofillManagerPort_contexts, context); -} - -static void __AutofillManagerPort_on_disconnected(const char *sender, const char *instance, void *data) -{ - rpc_port_stub_AutofillManagerPort_context_h context; - - _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); - context = __find_AutofillManagerPort_context(instance); - if (!context) - return; - - if (context->callback.terminate) - context->callback.terminate(context, context->user_data); - __AutofillManagerPort_contexts = g_list_remove(__AutofillManagerPort_contexts, context); - __destroy_AutofillManagerPort_context(context); -} - -static int __AutofillManagerPort_on_received(const char *sender, const char *instance, rpc_port_h port, void *data) -{ - rpc_port_stub_AutofillManagerPort_context_h context; - rpc_port_parcel_h parcel; - int cmd = -1; - int r; - - _I("[__RPC_PORT__] sender(%s), instance(%s)", sender, instance); - context = __find_AutofillManagerPort_context(instance); - if (!context) { - _E("Failed to find AutofillManagerPort 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(__AutofillManagerPort_method_table) / sizeof(__AutofillManagerPort_method_table[0]))) { - if (__AutofillManagerPort_method_table[cmd]) - r = __AutofillManagerPort_method_table[cmd](port, parcel, context); - } else { - _E("Unknown Command(%d)", cmd); - r = -1; - } - - rpc_port_parcel_destroy(parcel); - - return r; -} - -static int __AutofillManagerPort_add_privileges(void) -{ - - return 0; -} - -int rpc_port_stub_AutofillManagerPort_register(rpc_port_stub_AutofillManagerPort_callback_s *callback, void *user_data) -{ - int r; - - if (__AutofillManagerPort_stub) { - _W("Already exists"); - return -1; - } - - if (!callback) { - _E("Invalid parameter"); - return -1; - } - - __AutofillManagerPort_callback = *callback; - __AutofillManagerPort_user_data = user_data; - r = rpc_port_stub_create(&__AutofillManagerPort_stub, "AutofillManagerPort"); - if (r != 0) { - _E("Failed to create stub handle"); - return r; - } - - r = rpc_port_stub_add_received_event_cb(__AutofillManagerPort_stub, __AutofillManagerPort_on_received, NULL); - if (r != 0) { - _E("Failed to add received event callback"); - rpc_port_stub_destroy(__AutofillManagerPort_stub); - __AutofillManagerPort_stub = NULL; - return r; - } - - r = rpc_port_stub_add_connected_event_cb(__AutofillManagerPort_stub, __AutofillManagerPort_on_connected, NULL); - if (r != 0) { - _E("Failed to add connected event callback"); - rpc_port_stub_destroy(__AutofillManagerPort_stub); - __AutofillManagerPort_stub = NULL; - return r; - } - - r = rpc_port_stub_add_disconnected_event_cb(__AutofillManagerPort_stub, __AutofillManagerPort_on_disconnected, NULL); - if (r != 0) { - _E("Failed to add disconnected event callback"); - rpc_port_stub_destroy(__AutofillManagerPort_stub); - __AutofillManagerPort_stub = NULL; - return r; - } - - r = __AutofillManagerPort_add_privileges(); - if (r != 0) { - _E("Failed to add privileges"); - rpc_port_stub_destroy(__AutofillManagerPort_stub); - __AutofillManagerPort_stub = NULL; - return r; - } - - r = rpc_port_stub_listen(__AutofillManagerPort_stub); - if (r != 0) { - _E("Failed to listen stub"); - rpc_port_stub_destroy(__AutofillManagerPort_stub); - __AutofillManagerPort_stub = NULL; - return r; - } - - return 0; -} - -int rpc_port_stub_AutofillManagerPort_unregister(void) -{ - int r; - - if (!__AutofillManagerPort_stub) - return -1; - - if (__AutofillManagerPort_contexts) { - g_list_free_full(__AutofillManagerPort_contexts, __destroy_AutofillManagerPort_context); - __AutofillManagerPort_contexts = NULL; - } - - r = rpc_port_stub_destroy(__AutofillManagerPort_stub); - __AutofillManagerPort_stub = NULL; - - return r; -} - -int rpc_port_stub_AutofillManagerPort_get_client_number(unsigned int *n) -{ - if (!n) { - _E("Invalid parameter"); - return -1; - } - - if (!__AutofillManagerPort_stub) { - _E("AutofillManagerPort Stub is not ready"); - return -1; - } - - *n = g_list_length(__AutofillManagerPort_contexts); - - return 0; -} diff --git a/src/autofill_manager_stub.h b/src/autofill_manager_stub.h deleted file mode 100644 index 458cb01..0000000 --- a/src/autofill_manager_stub.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Generated by tidlc 1.3.2. - * - * 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 list_string_s *rpc_port_list_string_h; - -int rpc_port_list_string_create(rpc_port_list_string_h *h); - -int rpc_port_list_string_destroy(rpc_port_list_string_h h); - -int rpc_port_list_string_clone(rpc_port_list_string_h h, rpc_port_list_string_h *clone); - -int rpc_port_list_string_add_list_strings(rpc_port_list_string_h h, const char *list_strings); - -int rpc_port_list_string_foreach_list_strings(rpc_port_list_string_h h, - bool (*callback)(const char *list_strings, void *user_data), void *user_data); - -int rpc_port_list_string_remove_list_strings(rpc_port_list_string_h h, unsigned int nth); - -int rpc_port_list_string_get_list_strings_length(rpc_port_list_string_h h, unsigned int *length); - -typedef struct AutofillManagerPort_context_s* rpc_port_stub_AutofillManagerPort_context_h; - -int rpc_port_stub_AutofillManagerPort_context_set_tag(rpc_port_stub_AutofillManagerPort_context_h ctx, void *tag); - -int rpc_port_stub_AutofillManagerPort_context_get_tag(rpc_port_stub_AutofillManagerPort_context_h ctx, void **tag); - -int rpc_port_stub_AutofillManagerPort_context_get_sender(rpc_port_stub_AutofillManagerPort_context_h ctx, char **sender); - -typedef struct { - void (*create)(rpc_port_stub_AutofillManagerPort_context_h context, void *user_data); - void (*terminate)(rpc_port_stub_AutofillManagerPort_context_h context, void *user_data); - - bool (*set_autofill_service)(rpc_port_stub_AutofillManagerPort_context_h context, const char *app_id, void *user_data); - char *(*get_autofill_service)(rpc_port_stub_AutofillManagerPort_context_h context, void *user_data); - bool (*get_autofill_service_list)(rpc_port_stub_AutofillManagerPort_context_h context, rpc_port_list_string_h *service_info_list, void *user_data); -} rpc_port_stub_AutofillManagerPort_callback_s; - -int rpc_port_stub_AutofillManagerPort_register(rpc_port_stub_AutofillManagerPort_callback_s *callback, void *user_data); - -int rpc_port_stub_AutofillManagerPort_unregister(void); - -int rpc_port_stub_AutofillManagerPort_get_client_number(unsigned int *n); - -#ifdef __cplusplus -} -#endif diff --git a/src/autofill_service_proxy.c b/src/autofill_service_proxy.c deleted file mode 100644 index 18e3bb5..0000000 --- a/src/autofill_service_proxy.c +++ /dev/null @@ -1,4261 +0,0 @@ -/* - * Generated by tidlc 1.3.2. - * - * 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_save_item_s { - rpc_port_parcelable_t parcelable; - char *id; - char *label; - char *value; - int autofill_hint; - bool is_sensitive_data; -}; - -static void __autofill_svc_save_item_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_svc_save_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_save_item_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_svc_save_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_save_item_create(rpc_port_autofill_svc_save_item_h *h) -{ - struct autofill_svc_save_item_s *handle; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct autofill_svc_save_item_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __autofill_svc_save_item_to; - handle->parcelable.from = __autofill_svc_save_item_from; - - *h = handle; - - return 0; -} - -int rpc_port_autofill_svc_save_item_destroy(rpc_port_autofill_svc_save_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_save_item_clone(rpc_port_autofill_svc_save_item_h h, rpc_port_autofill_svc_save_item_h *clone) -{ - rpc_port_autofill_svc_save_item_h handle = NULL; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - rpc_port_autofill_svc_save_item_create(&handle); - if (!handle) { - _E("Failed to create autofill_svc_save_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_save_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_save_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_save_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_save_item_set_id(rpc_port_autofill_svc_save_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_save_item_set_label(rpc_port_autofill_svc_save_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_save_item_set_value(rpc_port_autofill_svc_save_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_save_item_set_autofill_hint(rpc_port_autofill_svc_save_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_save_item_set_is_sensitive_data(rpc_port_autofill_svc_save_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_save_item_get_id(rpc_port_autofill_svc_save_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_save_item_get_label(rpc_port_autofill_svc_save_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_save_item_get_value(rpc_port_autofill_svc_save_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_save_item_get_autofill_hint(rpc_port_autofill_svc_save_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_save_item_get_is_sensitive_data(rpc_port_autofill_svc_save_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_save_view_info_s { - rpc_port_parcelable_t parcelable; - char *view_id; - GList *items; -}; - -static void __autofill_svc_save_view_info_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_svc_save_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_svc_save_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_save_view_info_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_svc_save_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_svc_save_item_h value = NULL; - - rpc_port_autofill_svc_save_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_save_view_info_create(rpc_port_autofill_svc_save_view_info_h *h) -{ - struct autofill_svc_save_view_info_s *handle; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct autofill_svc_save_view_info_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __autofill_svc_save_view_info_to; - handle->parcelable.from = __autofill_svc_save_view_info_from; - - *h = handle; - - return 0; -} - -int rpc_port_autofill_svc_save_view_info_destroy(rpc_port_autofill_svc_save_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_svc_save_item_h value = iter->data; - if (value) - rpc_port_autofill_svc_save_item_destroy(value); - - iter = g_list_next(iter); - } - g_list_free(h->items); - } while (0); - - free(h); - - return 0; -} - -int rpc_port_autofill_svc_save_view_info_clone(rpc_port_autofill_svc_save_view_info_h h, rpc_port_autofill_svc_save_view_info_h *clone) -{ - rpc_port_autofill_svc_save_view_info_h handle = NULL; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - rpc_port_autofill_svc_save_view_info_create(&handle); - if (!handle) { - _E("Failed to create autofill_svc_save_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_svc_save_view_info_destroy(handle); - return -1; - } - } - - do { - GList *iter; - - iter = h->items; - while (iter) { - rpc_port_autofill_svc_save_item_h new_value; - rpc_port_autofill_svc_save_item_h value = iter->data; - - if (!value) { - _E("Error: value is NULL"); - rpc_port_autofill_svc_save_view_info_destroy(handle); - return -1; - } - - rpc_port_autofill_svc_save_item_clone(value, &new_value); - if (!new_value) { - _E("Failed to duplicate value"); - rpc_port_autofill_svc_save_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_save_view_info_set_view_id(rpc_port_autofill_svc_save_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_save_view_info_add_items(rpc_port_autofill_svc_save_view_info_h h, rpc_port_autofill_svc_save_item_h items) -{ - if (!h || !items) { - _E("Invalid parameter"); - return -1; - } - - do { - rpc_port_autofill_svc_save_item_h value = NULL; - - rpc_port_autofill_svc_save_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_save_view_info_get_view_id(rpc_port_autofill_svc_save_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_save_view_info_foreach_items(rpc_port_autofill_svc_save_view_info_h h, - bool (*callback)(rpc_port_autofill_svc_save_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_save_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_save_view_info_remove_items(rpc_port_autofill_svc_save_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_save_item_h value = iter->data; - h->items = g_list_remove_link(h->items, iter); - rpc_port_autofill_svc_save_item_destroy(value); - g_list_free(iter); - - return 0; -} - -int rpc_port_autofill_svc_save_view_info_get_items_length(rpc_port_autofill_svc_save_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; - char *view_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_string(parcel, h->view_id ? h->view_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_string(parcel, &h->view_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->view_id) - free(h->view_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; - } - } - - 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_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_view_id(rpc_port_autofill_svc_auth_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_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_view_id(rpc_port_autofill_svc_auth_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_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_response_group_s { - rpc_port_parcelable_t parcelable; - GList *response_items; -}; - -static void __autofill_svc_response_group_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_svc_response_group_h h = data; - - if (!parcel || !h) { - _E("Invalid parameter"); - return; - } - - 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_response_group_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_svc_response_group_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->response_items = g_list_append(h->response_items, value); - } - } while (0); -} - -int rpc_port_autofill_svc_response_group_create(rpc_port_autofill_svc_response_group_h *h) -{ - struct autofill_svc_response_group_s *handle; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct autofill_svc_response_group_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __autofill_svc_response_group_to; - handle->parcelable.from = __autofill_svc_response_group_from; - - *h = handle; - - return 0; -} - -int rpc_port_autofill_svc_response_group_destroy(rpc_port_autofill_svc_response_group_h h) -{ - if (!h) { - _E("Invalid parameter"); - return -1; - } - - 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_response_group_clone(rpc_port_autofill_svc_response_group_h h, rpc_port_autofill_svc_response_group_h *clone) -{ - rpc_port_autofill_svc_response_group_h handle = NULL; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - rpc_port_autofill_svc_response_group_create(&handle); - if (!handle) { - _E("Failed to create autofill_svc_response_group 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_response_group_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_response_group_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_response_group_add_response_items(rpc_port_autofill_svc_response_group_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_response_group_foreach_response_items(rpc_port_autofill_svc_response_group_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_response_group_remove_response_items(rpc_port_autofill_svc_response_group_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_response_group_get_response_items_length(rpc_port_autofill_svc_response_group_h h, unsigned int *length) -{ - if (!h || !length) { - _E("Invalid parameter"); - return -1; - } - - *length = g_list_length(h->response_items); - - return 0; -} - -struct autofill_svc_fill_response_s { - rpc_port_parcelable_t parcelable; - char *app_id; - char *view_id; - GList *response_groups; -}; - -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_groups)); - do { - GList *iter; - - iter = h->response_groups; - while (iter) { - rpc_port_autofill_svc_response_group_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_group_h value = NULL; - - rpc_port_autofill_svc_response_group_create(&value); - if (!value) { - _E("Failed to create handle"); - return; - } - - rpc_port_parcel_read(parcel, &value->parcelable, value); - h->response_groups = g_list_append(h->response_groups, 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_groups; - while (iter) { - rpc_port_autofill_svc_response_group_h value = iter->data; - if (value) - rpc_port_autofill_svc_response_group_destroy(value); - - iter = g_list_next(iter); - } - g_list_free(h->response_groups); - } 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_groups; - while (iter) { - rpc_port_autofill_svc_response_group_h new_value; - rpc_port_autofill_svc_response_group_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_group_clone(value, &new_value); - if (!new_value) { - _E("Failed to duplicate value"); - rpc_port_autofill_svc_fill_response_destroy(handle); - return -1; - } - - handle->response_groups = g_list_append(handle->response_groups, 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_groups(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_response_group_h response_groups) -{ - if (!h || !response_groups) { - _E("Invalid parameter"); - return -1; - } - - do { - rpc_port_autofill_svc_response_group_h value = NULL; - - rpc_port_autofill_svc_response_group_clone(response_groups, &value); - if (!value) { - _E("Out of memory"); - return -1; - } - - h->response_groups = g_list_append(h->response_groups, 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_groups(rpc_port_autofill_svc_fill_response_h h, - bool (*callback)(rpc_port_autofill_svc_response_group_h response_groups, void *user_data), void *user_data) -{ - if (!h || !callback) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->response_groups; - while (iter) { - rpc_port_autofill_svc_response_group_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_groups(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_groups, nth); - if (iter == NULL) - return -1; - - rpc_port_autofill_svc_response_group_h value = iter->data; - h->response_groups = g_list_remove_link(h->response_groups, iter); - rpc_port_autofill_svc_response_group_destroy(value); - g_list_free(iter); - - return 0; -} - -int rpc_port_autofill_svc_fill_response_get_response_groups_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_groups); - - 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_group_s { - rpc_port_parcelable_t parcelable; - GList *list_autofill_svc_response_groups; -}; - -static void __list_autofill_svc_response_group_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_list_autofill_svc_response_group_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_groups)); - do { - GList *iter; - - iter = h->list_autofill_svc_response_groups; - while (iter) { - rpc_port_autofill_svc_response_group_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_group_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_list_autofill_svc_response_group_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_group_h value = NULL; - - rpc_port_autofill_svc_response_group_create(&value); - if (!value) { - _E("Failed to create handle"); - return; - } - - rpc_port_parcel_read(parcel, &value->parcelable, value); - h->list_autofill_svc_response_groups = g_list_append(h->list_autofill_svc_response_groups, value); - } - } while (0); -} - -int rpc_port_list_autofill_svc_response_group_create(rpc_port_list_autofill_svc_response_group_h *h) -{ - struct list_autofill_svc_response_group_s *handle; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct list_autofill_svc_response_group_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __list_autofill_svc_response_group_to; - handle->parcelable.from = __list_autofill_svc_response_group_from; - - *h = handle; - - return 0; -} - -int rpc_port_list_autofill_svc_response_group_destroy(rpc_port_list_autofill_svc_response_group_h h) -{ - if (!h) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_svc_response_groups; - while (iter) { - rpc_port_autofill_svc_response_group_h value = iter->data; - if (value) - rpc_port_autofill_svc_response_group_destroy(value); - - iter = g_list_next(iter); - } - g_list_free(h->list_autofill_svc_response_groups); - } while (0); - - free(h); - - return 0; -} - -int rpc_port_list_autofill_svc_response_group_clone(rpc_port_list_autofill_svc_response_group_h h, rpc_port_list_autofill_svc_response_group_h *clone) -{ - rpc_port_list_autofill_svc_response_group_h handle = NULL; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - rpc_port_list_autofill_svc_response_group_create(&handle); - if (!handle) { - _E("Failed to create list_autofill_svc_response_group handle"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_svc_response_groups; - while (iter) { - rpc_port_autofill_svc_response_group_h new_value; - rpc_port_autofill_svc_response_group_h value = iter->data; - - if (!value) { - _E("Error: value is NULL"); - rpc_port_list_autofill_svc_response_group_destroy(handle); - return -1; - } - - rpc_port_autofill_svc_response_group_clone(value, &new_value); - if (!new_value) { - _E("Failed to duplicate value"); - rpc_port_list_autofill_svc_response_group_destroy(handle); - return -1; - } - - handle->list_autofill_svc_response_groups = g_list_append(handle->list_autofill_svc_response_groups, new_value); - iter = g_list_next(iter); - } - } while (0); - - *clone = handle; - - return 0; -} - -int rpc_port_list_autofill_svc_response_group_add_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, rpc_port_autofill_svc_response_group_h list_autofill_svc_response_groups) -{ - if (!h || !list_autofill_svc_response_groups) { - _E("Invalid parameter"); - return -1; - } - - do { - rpc_port_autofill_svc_response_group_h value = NULL; - - rpc_port_autofill_svc_response_group_clone(list_autofill_svc_response_groups, &value); - if (!value) { - _E("Out of memory"); - return -1; - } - - h->list_autofill_svc_response_groups = g_list_append(h->list_autofill_svc_response_groups, value); - } while (0); - - return 0; -} - -int rpc_port_list_autofill_svc_response_group_foreach_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, - bool (*callback)(rpc_port_autofill_svc_response_group_h list_autofill_svc_response_groups, void *user_data), void *user_data) -{ - if (!h || !callback) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_svc_response_groups; - while (iter) { - rpc_port_autofill_svc_response_group_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_group_remove_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, unsigned int nth) -{ - GList *iter; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - iter = g_list_nth(h->list_autofill_svc_response_groups, nth); - if (iter == NULL) - return -1; - - rpc_port_autofill_svc_response_group_h value = iter->data; - h->list_autofill_svc_response_groups = g_list_remove_link(h->list_autofill_svc_response_groups, iter); - rpc_port_autofill_svc_response_group_destroy(value); - g_list_free(iter); - - return 0; -} - -int rpc_port_list_autofill_svc_response_group_get_list_autofill_svc_response_groups_length(rpc_port_list_autofill_svc_response_group_h h, unsigned int *length) -{ - if (!h || !length) { - _E("Invalid parameter"); - return -1; - } - - *length = g_list_length(h->list_autofill_svc_response_groups); - - 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; -} - -struct list_autofill_svc_save_item_s { - rpc_port_parcelable_t parcelable; - GList *list_autofill_svc_save_items; -}; - -static void __list_autofill_svc_save_item_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_list_autofill_svc_save_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_save_items)); - do { - GList *iter; - - iter = h->list_autofill_svc_save_items; - while (iter) { - rpc_port_autofill_svc_save_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_save_item_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_list_autofill_svc_save_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_save_item_h value = NULL; - - rpc_port_autofill_svc_save_item_create(&value); - if (!value) { - _E("Failed to create handle"); - return; - } - - rpc_port_parcel_read(parcel, &value->parcelable, value); - h->list_autofill_svc_save_items = g_list_append(h->list_autofill_svc_save_items, value); - } - } while (0); -} - -int rpc_port_list_autofill_svc_save_item_create(rpc_port_list_autofill_svc_save_item_h *h) -{ - struct list_autofill_svc_save_item_s *handle; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct list_autofill_svc_save_item_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __list_autofill_svc_save_item_to; - handle->parcelable.from = __list_autofill_svc_save_item_from; - - *h = handle; - - return 0; -} - -int rpc_port_list_autofill_svc_save_item_destroy(rpc_port_list_autofill_svc_save_item_h h) -{ - if (!h) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_svc_save_items; - while (iter) { - rpc_port_autofill_svc_save_item_h value = iter->data; - if (value) - rpc_port_autofill_svc_save_item_destroy(value); - - iter = g_list_next(iter); - } - g_list_free(h->list_autofill_svc_save_items); - } while (0); - - free(h); - - return 0; -} - -int rpc_port_list_autofill_svc_save_item_clone(rpc_port_list_autofill_svc_save_item_h h, rpc_port_list_autofill_svc_save_item_h *clone) -{ - rpc_port_list_autofill_svc_save_item_h handle = NULL; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - rpc_port_list_autofill_svc_save_item_create(&handle); - if (!handle) { - _E("Failed to create list_autofill_svc_save_item handle"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_svc_save_items; - while (iter) { - rpc_port_autofill_svc_save_item_h new_value; - rpc_port_autofill_svc_save_item_h value = iter->data; - - if (!value) { - _E("Error: value is NULL"); - rpc_port_list_autofill_svc_save_item_destroy(handle); - return -1; - } - - rpc_port_autofill_svc_save_item_clone(value, &new_value); - if (!new_value) { - _E("Failed to duplicate value"); - rpc_port_list_autofill_svc_save_item_destroy(handle); - return -1; - } - - handle->list_autofill_svc_save_items = g_list_append(handle->list_autofill_svc_save_items, new_value); - iter = g_list_next(iter); - } - } while (0); - - *clone = handle; - - return 0; -} - -int rpc_port_list_autofill_svc_save_item_add_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, rpc_port_autofill_svc_save_item_h list_autofill_svc_save_items) -{ - if (!h || !list_autofill_svc_save_items) { - _E("Invalid parameter"); - return -1; - } - - do { - rpc_port_autofill_svc_save_item_h value = NULL; - - rpc_port_autofill_svc_save_item_clone(list_autofill_svc_save_items, &value); - if (!value) { - _E("Out of memory"); - return -1; - } - - h->list_autofill_svc_save_items = g_list_append(h->list_autofill_svc_save_items, value); - } while (0); - - return 0; -} - -int rpc_port_list_autofill_svc_save_item_foreach_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, - bool (*callback)(rpc_port_autofill_svc_save_item_h list_autofill_svc_save_items, void *user_data), void *user_data) -{ - if (!h || !callback) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_svc_save_items; - while (iter) { - rpc_port_autofill_svc_save_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_save_item_remove_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, unsigned int nth) -{ - GList *iter; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - iter = g_list_nth(h->list_autofill_svc_save_items, nth); - if (iter == NULL) - return -1; - - rpc_port_autofill_svc_save_item_h value = iter->data; - h->list_autofill_svc_save_items = g_list_remove_link(h->list_autofill_svc_save_items, iter); - rpc_port_autofill_svc_save_item_destroy(value); - g_list_free(iter); - - return 0; -} - -int rpc_port_list_autofill_svc_save_item_get_list_autofill_svc_save_items_length(rpc_port_list_autofill_svc_save_item_h h, unsigned int *length) -{ - if (!h || !length) { - _E("Invalid parameter"); - return -1; - } - - *length = g_list_length(h->list_autofill_svc_save_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, - AutofillSvcPort_METHOD_commit, - AutofillSvcPort_METHOD_request_terminate, -}; - -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) -{ - int context_id; - rpc_port_autofill_svc_auth_info_h auth_info; - - rpc_port_parcel_read_int32(parcel, &context_id); - 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, context_id, 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) -{ - int context_id; - rpc_port_autofill_svc_fill_response_h response; - - rpc_port_parcel_read_int32(parcel, &context_id); - 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, context_id, 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 = NULL; - int cmd = -1; - - rpc_port_parcel_create_from_port(&parcel_received, handle->callback_port); - if (!parcel_received) { - _E("Failed to create parcel from port(%s)", port_name); - return; - } - - 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, int context_id, 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_int32(parcel, context_id); - 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, int context_id, 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_int32(parcel, context_id); - 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_commit(rpc_port_proxy_AutofillSvcPort_h h, int context_id, rpc_port_autofill_svc_save_view_info_h si) -{ - rpc_port_parcel_h parcel; - int r; - - if (!h || !si) { - _E("Invalid parameter"); - return; - } - - if (!h->port) { - _E("Not connected"); - return; - } - - rpc_port_parcel_create(&parcel); - rpc_port_parcel_write_int32(parcel, AutofillSvcPort_METHOD_commit); - rpc_port_parcel_write_int32(parcel, context_id); - rpc_port_parcel_write(parcel, &si->parcelable, si); - - 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_terminate(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_request_terminate); - - 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/src/autofill_service_proxy.h b/src/autofill_service_proxy.h deleted file mode 100644 index 8a0700b..0000000 --- a/src/autofill_service_proxy.h +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Generated by tidlc 1.3.2. - * - * 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_save_item_s *rpc_port_autofill_svc_save_item_h; - -int rpc_port_autofill_svc_save_item_create(rpc_port_autofill_svc_save_item_h *h); - -int rpc_port_autofill_svc_save_item_destroy(rpc_port_autofill_svc_save_item_h h); - -int rpc_port_autofill_svc_save_item_clone(rpc_port_autofill_svc_save_item_h h, rpc_port_autofill_svc_save_item_h *clone); - -int rpc_port_autofill_svc_save_item_set_id(rpc_port_autofill_svc_save_item_h h, const char *id); - -int rpc_port_autofill_svc_save_item_set_label(rpc_port_autofill_svc_save_item_h h, const char *label); - -int rpc_port_autofill_svc_save_item_set_value(rpc_port_autofill_svc_save_item_h h, const char *value); - -int rpc_port_autofill_svc_save_item_set_autofill_hint(rpc_port_autofill_svc_save_item_h h, int autofill_hint); - -int rpc_port_autofill_svc_save_item_set_is_sensitive_data(rpc_port_autofill_svc_save_item_h h, bool is_sensitive_data); - -int rpc_port_autofill_svc_save_item_get_id(rpc_port_autofill_svc_save_item_h h, char **id); - -int rpc_port_autofill_svc_save_item_get_label(rpc_port_autofill_svc_save_item_h h, char **label); - -int rpc_port_autofill_svc_save_item_get_value(rpc_port_autofill_svc_save_item_h h, char **value); - -int rpc_port_autofill_svc_save_item_get_autofill_hint(rpc_port_autofill_svc_save_item_h h, int *autofill_hint); - -int rpc_port_autofill_svc_save_item_get_is_sensitive_data(rpc_port_autofill_svc_save_item_h h, bool *is_sensitive_data); - -typedef struct autofill_svc_save_view_info_s *rpc_port_autofill_svc_save_view_info_h; - -int rpc_port_autofill_svc_save_view_info_create(rpc_port_autofill_svc_save_view_info_h *h); - -int rpc_port_autofill_svc_save_view_info_destroy(rpc_port_autofill_svc_save_view_info_h h); - -int rpc_port_autofill_svc_save_view_info_clone(rpc_port_autofill_svc_save_view_info_h h, rpc_port_autofill_svc_save_view_info_h *clone); - -int rpc_port_autofill_svc_save_view_info_set_view_id(rpc_port_autofill_svc_save_view_info_h h, const char *view_id); - -int rpc_port_autofill_svc_save_view_info_add_items(rpc_port_autofill_svc_save_view_info_h h, rpc_port_autofill_svc_save_item_h items); - -int rpc_port_autofill_svc_save_view_info_get_view_id(rpc_port_autofill_svc_save_view_info_h h, char **view_id); - -int rpc_port_autofill_svc_save_view_info_foreach_items(rpc_port_autofill_svc_save_view_info_h h, - bool (*callback)(rpc_port_autofill_svc_save_item_h items, void *user_data), void *user_data); - -int rpc_port_autofill_svc_save_view_info_remove_items(rpc_port_autofill_svc_save_view_info_h h, unsigned int nth); - -int rpc_port_autofill_svc_save_view_info_get_items_length(rpc_port_autofill_svc_save_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_view_id(rpc_port_autofill_svc_auth_info_h h, const char *view_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_view_id(rpc_port_autofill_svc_auth_info_h h, char **view_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_response_group_s *rpc_port_autofill_svc_response_group_h; - -int rpc_port_autofill_svc_response_group_create(rpc_port_autofill_svc_response_group_h *h); - -int rpc_port_autofill_svc_response_group_destroy(rpc_port_autofill_svc_response_group_h h); - -int rpc_port_autofill_svc_response_group_clone(rpc_port_autofill_svc_response_group_h h, rpc_port_autofill_svc_response_group_h *clone); - -int rpc_port_autofill_svc_response_group_add_response_items(rpc_port_autofill_svc_response_group_h h, rpc_port_autofill_svc_response_item_h response_items); - -int rpc_port_autofill_svc_response_group_foreach_response_items(rpc_port_autofill_svc_response_group_h h, - bool (*callback)(rpc_port_autofill_svc_response_item_h response_items, void *user_data), void *user_data); - -int rpc_port_autofill_svc_response_group_remove_response_items(rpc_port_autofill_svc_response_group_h h, unsigned int nth); - -int rpc_port_autofill_svc_response_group_get_response_items_length(rpc_port_autofill_svc_response_group_h h, unsigned int *length); - -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_groups(rpc_port_autofill_svc_fill_response_h h, rpc_port_autofill_svc_response_group_h response_groups); - -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_groups(rpc_port_autofill_svc_fill_response_h h, - bool (*callback)(rpc_port_autofill_svc_response_group_h response_groups, void *user_data), void *user_data); - -int rpc_port_autofill_svc_fill_response_remove_response_groups(rpc_port_autofill_svc_fill_response_h h, unsigned int nth); - -int rpc_port_autofill_svc_fill_response_get_response_groups_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_group_s *rpc_port_list_autofill_svc_response_group_h; - -int rpc_port_list_autofill_svc_response_group_create(rpc_port_list_autofill_svc_response_group_h *h); - -int rpc_port_list_autofill_svc_response_group_destroy(rpc_port_list_autofill_svc_response_group_h h); - -int rpc_port_list_autofill_svc_response_group_clone(rpc_port_list_autofill_svc_response_group_h h, rpc_port_list_autofill_svc_response_group_h *clone); - -int rpc_port_list_autofill_svc_response_group_add_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, rpc_port_autofill_svc_response_group_h list_autofill_svc_response_groups); - -int rpc_port_list_autofill_svc_response_group_foreach_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, - bool (*callback)(rpc_port_autofill_svc_response_group_h list_autofill_svc_response_groups, void *user_data), void *user_data); - -int rpc_port_list_autofill_svc_response_group_remove_list_autofill_svc_response_groups(rpc_port_list_autofill_svc_response_group_h h, unsigned int nth); - -int rpc_port_list_autofill_svc_response_group_get_list_autofill_svc_response_groups_length(rpc_port_list_autofill_svc_response_group_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 list_autofill_svc_save_item_s *rpc_port_list_autofill_svc_save_item_h; - -int rpc_port_list_autofill_svc_save_item_create(rpc_port_list_autofill_svc_save_item_h *h); - -int rpc_port_list_autofill_svc_save_item_destroy(rpc_port_list_autofill_svc_save_item_h h); - -int rpc_port_list_autofill_svc_save_item_clone(rpc_port_list_autofill_svc_save_item_h h, rpc_port_list_autofill_svc_save_item_h *clone); - -int rpc_port_list_autofill_svc_save_item_add_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, rpc_port_autofill_svc_save_item_h list_autofill_svc_save_items); - -int rpc_port_list_autofill_svc_save_item_foreach_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, - bool (*callback)(rpc_port_autofill_svc_save_item_h list_autofill_svc_save_items, void *user_data), void *user_data); - -int rpc_port_list_autofill_svc_save_item_remove_list_autofill_svc_save_items(rpc_port_list_autofill_svc_save_item_h h, unsigned int nth); - -int rpc_port_list_autofill_svc_save_item_get_list_autofill_svc_save_items_length(rpc_port_list_autofill_svc_save_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, int context_id, 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, int context_id, 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, int context_id, rpc_port_autofill_svc_view_info_h vi); - -void rpc_port_proxy_AutofillSvcPort_invoke_send_fill_request(rpc_port_proxy_AutofillSvcPort_h h, int context_id, rpc_port_autofill_svc_view_info_h vi); - -void rpc_port_proxy_AutofillSvcPort_invoke_commit(rpc_port_proxy_AutofillSvcPort_h h, int context_id, rpc_port_autofill_svc_save_view_info_h si); - -void rpc_port_proxy_AutofillSvcPort_invoke_request_terminate(rpc_port_proxy_AutofillSvcPort_h h); - -#ifdef __cplusplus -} -#endif diff --git a/src/autofill_stub.c b/src/autofill_stub.c deleted file mode 100644 index 086ada2..0000000 --- a/src/autofill_stub.c +++ /dev/null @@ -1,4148 +0,0 @@ -/* - * Generated by tidlc 1.3.2. - * - * 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_save_item_s { - rpc_port_parcelable_t parcelable; - char *id; - char *label; - char *value; - int autofill_hint; - bool is_sensitive_data; -}; - -static void __autofill_save_item_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_save_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_save_item_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_save_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_save_item_create(rpc_port_autofill_save_item_h *h) -{ - struct autofill_save_item_s *handle; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct autofill_save_item_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __autofill_save_item_to; - handle->parcelable.from = __autofill_save_item_from; - - *h = handle; - - return 0; -} - -int rpc_port_autofill_save_item_destroy(rpc_port_autofill_save_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_save_item_clone(rpc_port_autofill_save_item_h h, rpc_port_autofill_save_item_h *clone) -{ - rpc_port_autofill_save_item_h handle = NULL; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - rpc_port_autofill_save_item_create(&handle); - if (!handle) { - _E("Failed to create autofill_save_item handle"); - return -1; - } - - if (h->id) { - handle->id = strdup(h->id); - if (!handle->id) { - _E("Failed to duplicate h->id"); - rpc_port_autofill_save_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_save_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_save_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_save_item_set_id(rpc_port_autofill_save_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_save_item_set_label(rpc_port_autofill_save_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_save_item_set_value(rpc_port_autofill_save_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_save_item_set_autofill_hint(rpc_port_autofill_save_item_h h, int autofill_hint) -{ - if (!h) { - _E("Invalid parameter"); - return -1; - } - - h->autofill_hint = autofill_hint; - return 0; -} - -int rpc_port_autofill_save_item_set_is_sensitive_data(rpc_port_autofill_save_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_save_item_get_id(rpc_port_autofill_save_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_save_item_get_label(rpc_port_autofill_save_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_save_item_get_value(rpc_port_autofill_save_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_save_item_get_autofill_hint(rpc_port_autofill_save_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_save_item_get_is_sensitive_data(rpc_port_autofill_save_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_save_view_info_s { - rpc_port_parcelable_t parcelable; - char *view_id; - GList *items; -}; - -static void __autofill_save_view_info_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_save_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_save_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_save_view_info_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_save_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_save_item_h value = NULL; - - rpc_port_autofill_save_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_save_view_info_create(rpc_port_autofill_save_view_info_h *h) -{ - struct autofill_save_view_info_s *handle; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct autofill_save_view_info_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __autofill_save_view_info_to; - handle->parcelable.from = __autofill_save_view_info_from; - - *h = handle; - - return 0; -} - -int rpc_port_autofill_save_view_info_destroy(rpc_port_autofill_save_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_save_item_h value = iter->data; - if (value) - rpc_port_autofill_save_item_destroy(value); - - iter = g_list_next(iter); - } - g_list_free(h->items); - } while (0); - - free(h); - - return 0; -} - -int rpc_port_autofill_save_view_info_clone(rpc_port_autofill_save_view_info_h h, rpc_port_autofill_save_view_info_h *clone) -{ - rpc_port_autofill_save_view_info_h handle = NULL; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - rpc_port_autofill_save_view_info_create(&handle); - if (!handle) { - _E("Failed to create autofill_save_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_save_view_info_destroy(handle); - return -1; - } - } - - do { - GList *iter; - - iter = h->items; - while (iter) { - rpc_port_autofill_save_item_h new_value; - rpc_port_autofill_save_item_h value = iter->data; - - if (!value) { - _E("Error: value is NULL"); - rpc_port_autofill_save_view_info_destroy(handle); - return -1; - } - - rpc_port_autofill_save_item_clone(value, &new_value); - if (!new_value) { - _E("Failed to duplicate value"); - rpc_port_autofill_save_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_save_view_info_set_view_id(rpc_port_autofill_save_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_save_view_info_add_items(rpc_port_autofill_save_view_info_h h, rpc_port_autofill_save_item_h items) -{ - if (!h || !items) { - _E("Invalid parameter"); - return -1; - } - - do { - rpc_port_autofill_save_item_h value = NULL; - - rpc_port_autofill_save_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_save_view_info_get_view_id(rpc_port_autofill_save_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_save_view_info_foreach_items(rpc_port_autofill_save_view_info_h h, - bool (*callback)(rpc_port_autofill_save_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_save_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_save_view_info_remove_items(rpc_port_autofill_save_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_save_item_h value = iter->data; - h->items = g_list_remove_link(h->items, iter); - rpc_port_autofill_save_item_destroy(value); - g_list_free(iter); - - return 0; -} - -int rpc_port_autofill_save_view_info_get_items_length(rpc_port_autofill_save_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; - char *view_id; - 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_string(parcel, h->view_id ? h->view_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_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_string(parcel, &h->view_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_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->view_id) - free(h->view_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_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; - } - - 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_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_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_view_id(rpc_port_autofill_auth_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_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_view_id(rpc_port_autofill_auth_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_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_response_group_s { - rpc_port_parcelable_t parcelable; - GList *response_items; -}; - -static void __autofill_response_group_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_response_group_h h = data; - - if (!parcel || !h) { - _E("Invalid parameter"); - return; - } - - 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_response_group_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_autofill_response_group_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->response_items = g_list_append(h->response_items, value); - } - } while (0); -} - -int rpc_port_autofill_response_group_create(rpc_port_autofill_response_group_h *h) -{ - struct autofill_response_group_s *handle; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct autofill_response_group_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __autofill_response_group_to; - handle->parcelable.from = __autofill_response_group_from; - - *h = handle; - - return 0; -} - -int rpc_port_autofill_response_group_destroy(rpc_port_autofill_response_group_h h) -{ - if (!h) { - _E("Invalid parameter"); - return -1; - } - - 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_response_group_clone(rpc_port_autofill_response_group_h h, rpc_port_autofill_response_group_h *clone) -{ - rpc_port_autofill_response_group_h handle = NULL; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - rpc_port_autofill_response_group_create(&handle); - if (!handle) { - _E("Failed to create autofill_response_group 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_response_group_destroy(handle); - return -1; - } - - rpc_port_autofill_response_item_clone(value, &new_value); - if (!new_value) { - _E("Failed to duplicate value"); - rpc_port_autofill_response_group_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_response_group_add_response_items(rpc_port_autofill_response_group_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_response_group_foreach_response_items(rpc_port_autofill_response_group_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_response_group_remove_response_items(rpc_port_autofill_response_group_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_response_group_get_response_items_length(rpc_port_autofill_response_group_h h, unsigned int *length) -{ - if (!h || !length) { - _E("Invalid parameter"); - return -1; - } - - *length = g_list_length(h->response_items); - - return 0; -} - -struct autofill_fill_response_s { - rpc_port_parcelable_t parcelable; - char *view_id; - GList *response_groups; -}; - -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_groups)); - do { - GList *iter; - - iter = h->response_groups; - while (iter) { - rpc_port_autofill_response_group_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_group_h value = NULL; - - rpc_port_autofill_response_group_create(&value); - if (!value) { - _E("Failed to create handle"); - return; - } - - rpc_port_parcel_read(parcel, &value->parcelable, value); - h->response_groups = g_list_append(h->response_groups, 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_groups; - while (iter) { - rpc_port_autofill_response_group_h value = iter->data; - if (value) - rpc_port_autofill_response_group_destroy(value); - - iter = g_list_next(iter); - } - g_list_free(h->response_groups); - } 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_groups; - while (iter) { - rpc_port_autofill_response_group_h new_value; - rpc_port_autofill_response_group_h value = iter->data; - - if (!value) { - _E("Error: value is NULL"); - rpc_port_autofill_fill_response_destroy(handle); - return -1; - } - - rpc_port_autofill_response_group_clone(value, &new_value); - if (!new_value) { - _E("Failed to duplicate value"); - rpc_port_autofill_fill_response_destroy(handle); - return -1; - } - - handle->response_groups = g_list_append(handle->response_groups, 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_groups(rpc_port_autofill_fill_response_h h, rpc_port_autofill_response_group_h response_groups) -{ - if (!h || !response_groups) { - _E("Invalid parameter"); - return -1; - } - - do { - rpc_port_autofill_response_group_h value = NULL; - - rpc_port_autofill_response_group_clone(response_groups, &value); - if (!value) { - _E("Out of memory"); - return -1; - } - - h->response_groups = g_list_append(h->response_groups, 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_groups(rpc_port_autofill_fill_response_h h, - bool (*callback)(rpc_port_autofill_response_group_h response_groups, void *user_data), void *user_data) -{ - if (!h || !callback) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->response_groups; - while (iter) { - rpc_port_autofill_response_group_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_groups(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_groups, nth); - if (iter == NULL) - return -1; - - rpc_port_autofill_response_group_h value = iter->data; - h->response_groups = g_list_remove_link(h->response_groups, iter); - rpc_port_autofill_response_group_destroy(value); - g_list_free(iter); - - return 0; -} - -int rpc_port_autofill_fill_response_get_response_groups_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_groups); - - 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_group_s { - rpc_port_parcelable_t parcelable; - GList *list_autofill_response_groups; -}; - -static void __list_autofill_response_group_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_list_autofill_response_group_h h = data; - - if (!parcel || !h) { - _E("Invalid parameter"); - return; - } - - rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_response_groups)); - do { - GList *iter; - - iter = h->list_autofill_response_groups; - while (iter) { - rpc_port_autofill_response_group_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_group_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_list_autofill_response_group_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_group_h value = NULL; - - rpc_port_autofill_response_group_create(&value); - if (!value) { - _E("Failed to create handle"); - return; - } - - rpc_port_parcel_read(parcel, &value->parcelable, value); - h->list_autofill_response_groups = g_list_append(h->list_autofill_response_groups, value); - } - } while (0); -} - -int rpc_port_list_autofill_response_group_create(rpc_port_list_autofill_response_group_h *h) -{ - struct list_autofill_response_group_s *handle; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct list_autofill_response_group_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __list_autofill_response_group_to; - handle->parcelable.from = __list_autofill_response_group_from; - - *h = handle; - - return 0; -} - -int rpc_port_list_autofill_response_group_destroy(rpc_port_list_autofill_response_group_h h) -{ - if (!h) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_response_groups; - while (iter) { - rpc_port_autofill_response_group_h value = iter->data; - if (value) - rpc_port_autofill_response_group_destroy(value); - - iter = g_list_next(iter); - } - g_list_free(h->list_autofill_response_groups); - } while (0); - - free(h); - - return 0; -} - -int rpc_port_list_autofill_response_group_clone(rpc_port_list_autofill_response_group_h h, rpc_port_list_autofill_response_group_h *clone) -{ - rpc_port_list_autofill_response_group_h handle = NULL; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - rpc_port_list_autofill_response_group_create(&handle); - if (!handle) { - _E("Failed to create list_autofill_response_group handle"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_response_groups; - while (iter) { - rpc_port_autofill_response_group_h new_value; - rpc_port_autofill_response_group_h value = iter->data; - - if (!value) { - _E("Error: value is NULL"); - rpc_port_list_autofill_response_group_destroy(handle); - return -1; - } - - rpc_port_autofill_response_group_clone(value, &new_value); - if (!new_value) { - _E("Failed to duplicate value"); - rpc_port_list_autofill_response_group_destroy(handle); - return -1; - } - - handle->list_autofill_response_groups = g_list_append(handle->list_autofill_response_groups, new_value); - iter = g_list_next(iter); - } - } while (0); - - *clone = handle; - - return 0; -} - -int rpc_port_list_autofill_response_group_add_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, rpc_port_autofill_response_group_h list_autofill_response_groups) -{ - if (!h || !list_autofill_response_groups) { - _E("Invalid parameter"); - return -1; - } - - do { - rpc_port_autofill_response_group_h value = NULL; - - rpc_port_autofill_response_group_clone(list_autofill_response_groups, &value); - if (!value) { - _E("Out of memory"); - return -1; - } - - h->list_autofill_response_groups = g_list_append(h->list_autofill_response_groups, value); - } while (0); - - return 0; -} - -int rpc_port_list_autofill_response_group_foreach_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, - bool (*callback)(rpc_port_autofill_response_group_h list_autofill_response_groups, void *user_data), void *user_data) -{ - if (!h || !callback) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_response_groups; - while (iter) { - rpc_port_autofill_response_group_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_group_remove_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, unsigned int nth) -{ - GList *iter; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - iter = g_list_nth(h->list_autofill_response_groups, nth); - if (iter == NULL) - return -1; - - rpc_port_autofill_response_group_h value = iter->data; - h->list_autofill_response_groups = g_list_remove_link(h->list_autofill_response_groups, iter); - rpc_port_autofill_response_group_destroy(value); - g_list_free(iter); - - return 0; -} - -int rpc_port_list_autofill_response_group_get_list_autofill_response_groups_length(rpc_port_list_autofill_response_group_h h, unsigned int *length) -{ - if (!h || !length) { - _E("Invalid parameter"); - return -1; - } - - *length = g_list_length(h->list_autofill_response_groups); - - 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; -} - -struct list_autofill_save_item_s { - rpc_port_parcelable_t parcelable; - GList *list_autofill_save_items; -}; - -static void __list_autofill_save_item_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_list_autofill_save_item_h h = data; - - if (!parcel || !h) { - _E("Invalid parameter"); - return; - } - - rpc_port_parcel_write_array_count(parcel, g_list_length(h->list_autofill_save_items)); - do { - GList *iter; - - iter = h->list_autofill_save_items; - while (iter) { - rpc_port_autofill_save_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_save_item_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_list_autofill_save_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_save_item_h value = NULL; - - rpc_port_autofill_save_item_create(&value); - if (!value) { - _E("Failed to create handle"); - return; - } - - rpc_port_parcel_read(parcel, &value->parcelable, value); - h->list_autofill_save_items = g_list_append(h->list_autofill_save_items, value); - } - } while (0); -} - -int rpc_port_list_autofill_save_item_create(rpc_port_list_autofill_save_item_h *h) -{ - struct list_autofill_save_item_s *handle; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct list_autofill_save_item_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __list_autofill_save_item_to; - handle->parcelable.from = __list_autofill_save_item_from; - - *h = handle; - - return 0; -} - -int rpc_port_list_autofill_save_item_destroy(rpc_port_list_autofill_save_item_h h) -{ - if (!h) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_save_items; - while (iter) { - rpc_port_autofill_save_item_h value = iter->data; - if (value) - rpc_port_autofill_save_item_destroy(value); - - iter = g_list_next(iter); - } - g_list_free(h->list_autofill_save_items); - } while (0); - - free(h); - - return 0; -} - -int rpc_port_list_autofill_save_item_clone(rpc_port_list_autofill_save_item_h h, rpc_port_list_autofill_save_item_h *clone) -{ - rpc_port_list_autofill_save_item_h handle = NULL; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - rpc_port_list_autofill_save_item_create(&handle); - if (!handle) { - _E("Failed to create list_autofill_save_item handle"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_save_items; - while (iter) { - rpc_port_autofill_save_item_h new_value; - rpc_port_autofill_save_item_h value = iter->data; - - if (!value) { - _E("Error: value is NULL"); - rpc_port_list_autofill_save_item_destroy(handle); - return -1; - } - - rpc_port_autofill_save_item_clone(value, &new_value); - if (!new_value) { - _E("Failed to duplicate value"); - rpc_port_list_autofill_save_item_destroy(handle); - return -1; - } - - handle->list_autofill_save_items = g_list_append(handle->list_autofill_save_items, new_value); - iter = g_list_next(iter); - } - } while (0); - - *clone = handle; - - return 0; -} - -int rpc_port_list_autofill_save_item_add_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, rpc_port_autofill_save_item_h list_autofill_save_items) -{ - if (!h || !list_autofill_save_items) { - _E("Invalid parameter"); - return -1; - } - - do { - rpc_port_autofill_save_item_h value = NULL; - - rpc_port_autofill_save_item_clone(list_autofill_save_items, &value); - if (!value) { - _E("Out of memory"); - return -1; - } - - h->list_autofill_save_items = g_list_append(h->list_autofill_save_items, value); - } while (0); - - return 0; -} - -int rpc_port_list_autofill_save_item_foreach_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, - bool (*callback)(rpc_port_autofill_save_item_h list_autofill_save_items, void *user_data), void *user_data) -{ - if (!h || !callback) { - _E("Invalid parameter"); - return -1; - } - - do { - GList *iter; - - iter = h->list_autofill_save_items; - while (iter) { - rpc_port_autofill_save_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_save_item_remove_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, unsigned int nth) -{ - GList *iter; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - iter = g_list_nth(h->list_autofill_save_items, nth); - if (iter == NULL) - return -1; - - rpc_port_autofill_save_item_h value = iter->data; - h->list_autofill_save_items = g_list_remove_link(h->list_autofill_save_items, iter); - rpc_port_autofill_save_item_destroy(value); - g_list_free(iter); - - return 0; -} - -int rpc_port_list_autofill_save_item_get_list_autofill_save_items_length(rpc_port_list_autofill_save_item_h h, unsigned int *length) -{ - if (!h || !length) { - _E("Invalid parameter"); - return -1; - } - - *length = g_list_length(h->list_autofill_save_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, - AutofillAppPort_METHOD_commit, -}; - -enum AutofillAppPort_delegate_e { - AutofillAppPort_DELEGATE_autofill_auth_info_received_cb = 1, - AutofillAppPort_DELEGATE_autofill_fill_response_received_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_received_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_received_cb_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_AutofillAppPort_autofill_auth_info_received_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_received_cb_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_AutofillAppPort_autofill_auth_info_received_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_received_cb_create(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h *h) -{ - struct AutofillAppPort_autofill_auth_info_received_cb_s *handle; - static int seq_num; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct AutofillAppPort_autofill_auth_info_received_cb_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __AutofillAppPort_autofill_auth_info_received_cb_to; - handle->parcelable.from = __AutofillAppPort_autofill_auth_info_received_cb_from; - handle->id = AutofillAppPort_DELEGATE_autofill_auth_info_received_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_received_cb_destroy(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h h) -{ - if (!h) { - _E("Invalid parameter"); - return -1; - } - - free(h); - - return 0; -} - -int rpc_port_AutofillAppPort_autofill_auth_info_received_cb_clone(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h h, rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h *clone) -{ - rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h handle; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct AutofillAppPort_autofill_auth_info_received_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_received_cb_invoke(rpc_port_AutofillAppPort_autofill_auth_info_received_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_received_cb_set_port(rpc_port_AutofillAppPort_autofill_auth_info_received_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_received_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_received_cb_to(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_AutofillAppPort_autofill_fill_response_received_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_received_cb_from(rpc_port_parcel_h parcel, void *data) -{ - rpc_port_AutofillAppPort_autofill_fill_response_received_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_received_cb_create(rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h *h) -{ - struct AutofillAppPort_autofill_fill_response_received_cb_s *handle; - static int seq_num; - - if (!h) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct AutofillAppPort_autofill_fill_response_received_cb_s)); - if (!handle) { - _E("Out of memory"); - return -1; - } - - handle->parcelable.to = __AutofillAppPort_autofill_fill_response_received_cb_to; - handle->parcelable.from = __AutofillAppPort_autofill_fill_response_received_cb_from; - handle->id = AutofillAppPort_DELEGATE_autofill_fill_response_received_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_received_cb_destroy(rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h h) -{ - if (!h) { - _E("Invalid parameter"); - return -1; - } - - free(h); - - return 0; -} - -int rpc_port_AutofillAppPort_autofill_fill_response_received_cb_clone(rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h h, rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h *clone) -{ - rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h handle; - - if (!h || !clone) { - _E("Invalid parameter"); - return -1; - } - - handle = calloc(1, sizeof(struct AutofillAppPort_autofill_fill_response_received_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_received_cb_invoke(rpc_port_AutofillAppPort_autofill_fill_response_received_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_received_cb_set_port(rpc_port_AutofillAppPort_autofill_fill_response_received_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; - } - - int context_id; - rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_cb = NULL; - rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_cb = NULL; - - rpc_port_parcel_read_int32(parcel, &context_id); - rpc_port_AutofillAppPort_autofill_auth_info_received_cb_create(&auth_info_cb); - - if (!auth_info_cb) { - _E("Failed to create handle"); - return -1; - } - - rpc_port_AutofillAppPort_autofill_auth_info_received_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_received_cb_create(&fill_response_cb); - - if (!fill_response_cb) { - _E("Failed to create handle"); - return -1; - } - - rpc_port_AutofillAppPort_autofill_fill_response_received_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, context_id, 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_received_cb_destroy(auth_info_cb); - rpc_port_AutofillAppPort_autofill_fill_response_received_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; - } - - int context_id; - - rpc_port_parcel_read_int32(parcel, &context_id); - - context->callback.Unregister(context, context_id, 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; - } - - int context_id; - rpc_port_autofill_view_info_h vi = NULL; - - rpc_port_parcel_read_int32(parcel, &context_id); - rpc_port_autofill_view_info_create(&vi); - rpc_port_parcel_read(parcel, &vi->parcelable, vi); - - int ret = context->callback.request_auth_info(context, context_id, vi, 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_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; - } - - int context_id; - rpc_port_autofill_view_info_h vi = NULL; - - rpc_port_parcel_read_int32(parcel, &context_id); - rpc_port_autofill_view_info_create(&vi); - rpc_port_parcel_read(parcel, &vi->parcelable, vi); - - int ret = context->callback.send_fill_request(context, context_id, vi, 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_autofill_view_info_destroy(vi); - return 0; -} - -static int __AutofillAppPort_method_commit(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; - } - - int context_id; - rpc_port_autofill_save_view_info_h vi = NULL; - - rpc_port_parcel_read_int32(parcel, &context_id); - rpc_port_autofill_save_view_info_create(&vi); - rpc_port_parcel_read(parcel, &vi->parcelable, vi); - - int ret = context->callback.commit(context, context_id, vi, 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_autofill_save_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, - [AutofillAppPort_METHOD_commit] = __AutofillAppPort_method_commit, -}; - -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/src/autofill_stub.h b/src/autofill_stub.h deleted file mode 100644 index 9a3682c..0000000 --- a/src/autofill_stub.h +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Generated by tidlc 1.3.2. - * - * 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_save_item_s *rpc_port_autofill_save_item_h; - -int rpc_port_autofill_save_item_create(rpc_port_autofill_save_item_h *h); - -int rpc_port_autofill_save_item_destroy(rpc_port_autofill_save_item_h h); - -int rpc_port_autofill_save_item_clone(rpc_port_autofill_save_item_h h, rpc_port_autofill_save_item_h *clone); - -int rpc_port_autofill_save_item_set_id(rpc_port_autofill_save_item_h h, const char *id); - -int rpc_port_autofill_save_item_set_label(rpc_port_autofill_save_item_h h, const char *label); - -int rpc_port_autofill_save_item_set_value(rpc_port_autofill_save_item_h h, const char *value); - -int rpc_port_autofill_save_item_set_autofill_hint(rpc_port_autofill_save_item_h h, int autofill_hint); - -int rpc_port_autofill_save_item_set_is_sensitive_data(rpc_port_autofill_save_item_h h, bool is_sensitive_data); - -int rpc_port_autofill_save_item_get_id(rpc_port_autofill_save_item_h h, char **id); - -int rpc_port_autofill_save_item_get_label(rpc_port_autofill_save_item_h h, char **label); - -int rpc_port_autofill_save_item_get_value(rpc_port_autofill_save_item_h h, char **value); - -int rpc_port_autofill_save_item_get_autofill_hint(rpc_port_autofill_save_item_h h, int *autofill_hint); - -int rpc_port_autofill_save_item_get_is_sensitive_data(rpc_port_autofill_save_item_h h, bool *is_sensitive_data); - -typedef struct autofill_save_view_info_s *rpc_port_autofill_save_view_info_h; - -int rpc_port_autofill_save_view_info_create(rpc_port_autofill_save_view_info_h *h); - -int rpc_port_autofill_save_view_info_destroy(rpc_port_autofill_save_view_info_h h); - -int rpc_port_autofill_save_view_info_clone(rpc_port_autofill_save_view_info_h h, rpc_port_autofill_save_view_info_h *clone); - -int rpc_port_autofill_save_view_info_set_view_id(rpc_port_autofill_save_view_info_h h, const char *view_id); - -int rpc_port_autofill_save_view_info_add_items(rpc_port_autofill_save_view_info_h h, rpc_port_autofill_save_item_h items); - -int rpc_port_autofill_save_view_info_get_view_id(rpc_port_autofill_save_view_info_h h, char **view_id); - -int rpc_port_autofill_save_view_info_foreach_items(rpc_port_autofill_save_view_info_h h, - bool (*callback)(rpc_port_autofill_save_item_h items, void *user_data), void *user_data); - -int rpc_port_autofill_save_view_info_remove_items(rpc_port_autofill_save_view_info_h h, unsigned int nth); - -int rpc_port_autofill_save_view_info_get_items_length(rpc_port_autofill_save_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_view_id(rpc_port_autofill_auth_info_h h, const char *view_id); - -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_view_id(rpc_port_autofill_auth_info_h h, char **view_id); - -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_response_group_s *rpc_port_autofill_response_group_h; - -int rpc_port_autofill_response_group_create(rpc_port_autofill_response_group_h *h); - -int rpc_port_autofill_response_group_destroy(rpc_port_autofill_response_group_h h); - -int rpc_port_autofill_response_group_clone(rpc_port_autofill_response_group_h h, rpc_port_autofill_response_group_h *clone); - -int rpc_port_autofill_response_group_add_response_items(rpc_port_autofill_response_group_h h, rpc_port_autofill_response_item_h response_items); - -int rpc_port_autofill_response_group_foreach_response_items(rpc_port_autofill_response_group_h h, - bool (*callback)(rpc_port_autofill_response_item_h response_items, void *user_data), void *user_data); - -int rpc_port_autofill_response_group_remove_response_items(rpc_port_autofill_response_group_h h, unsigned int nth); - -int rpc_port_autofill_response_group_get_response_items_length(rpc_port_autofill_response_group_h h, unsigned int *length); - -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_groups(rpc_port_autofill_fill_response_h h, rpc_port_autofill_response_group_h response_groups); - -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_groups(rpc_port_autofill_fill_response_h h, - bool (*callback)(rpc_port_autofill_response_group_h response_groups, void *user_data), void *user_data); - -int rpc_port_autofill_fill_response_remove_response_groups(rpc_port_autofill_fill_response_h h, unsigned int nth); - -int rpc_port_autofill_fill_response_get_response_groups_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_group_s *rpc_port_list_autofill_response_group_h; - -int rpc_port_list_autofill_response_group_create(rpc_port_list_autofill_response_group_h *h); - -int rpc_port_list_autofill_response_group_destroy(rpc_port_list_autofill_response_group_h h); - -int rpc_port_list_autofill_response_group_clone(rpc_port_list_autofill_response_group_h h, rpc_port_list_autofill_response_group_h *clone); - -int rpc_port_list_autofill_response_group_add_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, rpc_port_autofill_response_group_h list_autofill_response_groups); - -int rpc_port_list_autofill_response_group_foreach_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, - bool (*callback)(rpc_port_autofill_response_group_h list_autofill_response_groups, void *user_data), void *user_data); - -int rpc_port_list_autofill_response_group_remove_list_autofill_response_groups(rpc_port_list_autofill_response_group_h h, unsigned int nth); - -int rpc_port_list_autofill_response_group_get_list_autofill_response_groups_length(rpc_port_list_autofill_response_group_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 list_autofill_save_item_s *rpc_port_list_autofill_save_item_h; - -int rpc_port_list_autofill_save_item_create(rpc_port_list_autofill_save_item_h *h); - -int rpc_port_list_autofill_save_item_destroy(rpc_port_list_autofill_save_item_h h); - -int rpc_port_list_autofill_save_item_clone(rpc_port_list_autofill_save_item_h h, rpc_port_list_autofill_save_item_h *clone); - -int rpc_port_list_autofill_save_item_add_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, rpc_port_autofill_save_item_h list_autofill_save_items); - -int rpc_port_list_autofill_save_item_foreach_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, - bool (*callback)(rpc_port_autofill_save_item_h list_autofill_save_items, void *user_data), void *user_data); - -int rpc_port_list_autofill_save_item_remove_list_autofill_save_items(rpc_port_list_autofill_save_item_h h, unsigned int nth); - -int rpc_port_list_autofill_save_item_get_list_autofill_save_items_length(rpc_port_list_autofill_save_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_received_cb_s *rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h; - -int rpc_port_AutofillAppPort_autofill_auth_info_received_cb_destroy(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h h); - -int rpc_port_AutofillAppPort_autofill_auth_info_received_cb_clone(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h h, rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h *clone); - -int rpc_port_AutofillAppPort_autofill_auth_info_received_cb_invoke(rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h h, rpc_port_autofill_auth_info_h auth_info); - -typedef struct AutofillAppPort_autofill_fill_response_received_cb_s *rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h; - -int rpc_port_AutofillAppPort_autofill_fill_response_received_cb_destroy(rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h h); - -int rpc_port_AutofillAppPort_autofill_fill_response_received_cb_clone(rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h h, rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h *clone); - -int rpc_port_AutofillAppPort_autofill_fill_response_received_cb_invoke(rpc_port_AutofillAppPort_autofill_fill_response_received_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, int context_id, rpc_port_AutofillAppPort_autofill_auth_info_received_cb_h auth_info_cb, rpc_port_AutofillAppPort_autofill_fill_response_received_cb_h fill_response_cb, void *user_data); - void (*Unregister)(rpc_port_stub_AutofillAppPort_context_h context, int context_id, void *user_data); - int (*request_auth_info)(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_view_info_h vi, void *user_data); - int (*send_fill_request)(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_view_info_h vi, void *user_data); - int (*commit)(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_save_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 -- 2.7.4 From 454fe0cc1e6723208f9e92bf97486b488ab6c20f Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 17 Dec 2018 14:32:15 +0900 Subject: [PATCH 08/11] Update package version to 1.0.1 Change-Id: Ib45c228003d0e5bd0fdf1853ea981746d747c15c Signed-off-by: Jihoon Kim --- tizen-manifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tizen-manifest.xml b/tizen-manifest.xml index 9867d5b..cd82dbb 100644 --- a/tizen-manifest.xml +++ b/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From d4e5c02a6b9ed332944bf378eab4e8be3a1be9f5 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 21 Dec 2018 11:19:31 +0900 Subject: [PATCH 09/11] Fix crash temporarily Change-Id: I24b54f5d03f23f09e1260c687d0ef4312c86c89c Signed-off-by: Jihoon Kim --- src/autofill-daemon.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/autofill-daemon.c b/src/autofill-daemon.c index 1ca0dd1..fbda668 100644 --- a/src/autofill-daemon.c +++ b/src/autofill-daemon.c @@ -350,8 +350,6 @@ static int __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h contex free(view_id); } - rpc_port_autofill_svc_view_info_destroy(svi); - return 0; } -- 2.7.4 From 6a2d3dd80ce05b877618c424823a86759ba69025 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Fri, 21 Dec 2018 11:20:21 +0900 Subject: [PATCH 10/11] Update package version to 1.0.2 Change-Id: I9a61f611d95645b6f83d74059ea3362fef21047c Signed-off-by: Jihoon Kim --- tizen-manifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tizen-manifest.xml b/tizen-manifest.xml index cd82dbb..82b91ce 100644 --- a/tizen-manifest.xml +++ b/tizen-manifest.xml @@ -1,5 +1,5 @@ - + -- 2.7.4 From 868d8409a0375647cac8e62a20355bff9e764a6c Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Mon, 24 Dec 2018 09:57:18 +0900 Subject: [PATCH 11/11] Initialize variables before using Change-Id: I93334b2efbdaf81c470f84853b82a92f63711470 Signed-off-by: Jihoon Kim --- src/autofill-daemon.c | 84 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/src/autofill-daemon.c b/src/autofill-daemon.c index fbda668..5967d6c 100644 --- a/src/autofill-daemon.c +++ b/src/autofill-daemon.c @@ -234,9 +234,12 @@ bool __view_info_item_cb(rpc_port_autofill_item_h items, void *user_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_h svc_item = NULL; - rpc_port_autofill_svc_item_create(&svc_item); + if (rpc_port_autofill_svc_item_create(&svc_item) != 0) { + LOGW("Failed to create autofill item"); + return true; + } rpc_port_autofill_item_get_id(items, &id); rpc_port_autofill_svc_item_set_id(svc_item, id); @@ -262,7 +265,9 @@ bool __view_info_item_cb(rpc_port_autofill_item_h items, void *user_data) rpc_port_autofill_item_get_is_sensitive_data(items, &sensitive_data); rpc_port_autofill_svc_item_set_is_sensitive_data(svc_item, sensitive_data); - rpc_port_autofill_svc_view_info_add_items(svi, svc_item); + if (rpc_port_autofill_svc_view_info_add_items(svi, svc_item) != 0) { + LOGW("Failed to add item"); + } rpc_port_autofill_svc_item_destroy(svc_item); @@ -279,9 +284,10 @@ bool __save_item_cb(rpc_port_autofill_save_item_h items, void *user_data) rpc_port_autofill_svc_save_view_info_h svi = (rpc_port_autofill_svc_save_view_info_h)user_data; - rpc_port_autofill_svc_save_item_h svc_save_item; + rpc_port_autofill_svc_save_item_h svc_save_item = NULL; - rpc_port_autofill_svc_save_item_create(&svc_save_item); + if (rpc_port_autofill_svc_save_item_create(&svc_save_item) != 0) + return true; rpc_port_autofill_save_item_get_id(items, &id); rpc_port_autofill_svc_save_item_set_id(svc_save_item, id); @@ -317,7 +323,6 @@ bool __save_item_cb(rpc_port_autofill_save_item_h items, void *user_data) static int __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_view_info_h vi, void *user_data) { char *sender = NULL; - autofill_client_s *sender_client; if (!svc_rpc_h) { LOGW("Not initialized"); @@ -330,11 +335,12 @@ static int __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h contex 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_h svi = NULL; + if (rpc_port_autofill_svc_view_info_create(&svi) != 0) { + goto end; + } + rpc_port_autofill_svc_view_info_set_app_id(svi, sender); rpc_port_autofill_svc_view_info_set_view_id(svi, view_id); @@ -342,6 +348,9 @@ static int __auth_info_request_cb(rpc_port_stub_AutofillAppPort_context_h contex rpc_port_proxy_AutofillSvcPort_invoke_request_auth_info(svc_rpc_h, context_id, svi); + rpc_port_autofill_svc_view_info_destroy(svi); + +end: if (sender) { free(sender); } @@ -368,8 +377,11 @@ static int __autofill_fill_request_cb(rpc_port_stub_AutofillAppPort_context_h co LOGD("app id : %s, view id : %s, context id : %d", sender, view_id, context_id); - rpc_port_autofill_svc_view_info_h svi; - rpc_port_autofill_svc_view_info_create(&svi); + rpc_port_autofill_svc_view_info_h svi = NULL; + if (rpc_port_autofill_svc_view_info_create(&svi) != 0) { + goto end; + } + rpc_port_autofill_svc_view_info_set_app_id(svi, sender); rpc_port_autofill_svc_view_info_set_view_id(svi, view_id); @@ -377,21 +389,22 @@ static int __autofill_fill_request_cb(rpc_port_stub_AutofillAppPort_context_h co rpc_port_proxy_AutofillSvcPort_invoke_send_fill_request(svc_rpc_h, context_id, svi); + rpc_port_autofill_svc_view_info_destroy(svi); + +end: if (sender) free(sender); if (view_id) free(view_id); - rpc_port_autofill_svc_view_info_destroy(svi); - return 0; } static int __commit_cb(rpc_port_stub_AutofillAppPort_context_h context, int context_id, rpc_port_autofill_save_view_info_h vi, void *user_data) { char *sender = NULL; - autofill_client_s *sender_client; + char *view_id = NULL; if (!svc_rpc_h) { LOGW("Not initialized"); @@ -404,17 +417,17 @@ static int __commit_cb(rpc_port_stub_AutofillAppPort_context_h context, int cont free(sender); } - char *view_id = NULL; + rpc_port_autofill_svc_save_view_info_h svi = NULL; + if (rpc_port_autofill_svc_save_view_info_create(&svi) != 0) { + return 0; + } + rpc_port_autofill_save_view_info_get_view_id(vi, &view_id); if (view_id) { LOGD("view id : %s", view_id); } - - rpc_port_autofill_svc_save_view_info_h svi; - rpc_port_autofill_svc_save_view_info_create(&svi); rpc_port_autofill_svc_save_view_info_set_view_id(svi, view_id); - rpc_port_stub_AutofillAppPort_context_get_tag(context, (void *)&sender_client); rpc_port_autofill_save_view_info_foreach_items(vi, __save_item_cb, svi); rpc_port_proxy_AutofillSvcPort_invoke_commit(svc_rpc_h, context_id, svi); @@ -435,9 +448,11 @@ bool fill_response_item_cb(rpc_port_autofill_svc_response_item_h response_items, char *presentation_text = NULL; char *value = NULL; - rpc_port_autofill_response_item_h res_item; + rpc_port_autofill_response_item_h res_item = NULL; - rpc_port_autofill_response_item_create(&res_item); + if (rpc_port_autofill_response_item_create(&res_item) != 0) { + return true; + } rpc_port_autofill_svc_response_item_get_id(response_items, &id); rpc_port_autofill_response_item_set_id(res_item, id); @@ -468,8 +483,9 @@ bool fill_response_group_cb(rpc_port_autofill_svc_response_group_h response_grou { rpc_port_autofill_fill_response_h fr_h = (rpc_port_autofill_fill_response_h)user_data; - rpc_port_autofill_response_group_h res_group; - rpc_port_autofill_response_group_create(&res_group); + rpc_port_autofill_response_group_h res_group = NULL; + if (rpc_port_autofill_response_group_create(&res_group) != 0) + return true; rpc_port_autofill_svc_response_group_foreach_response_items(response_groups, fill_response_item_cb, res_group); @@ -486,12 +502,14 @@ static void __fill_response_recv_cb(void *user_data, int context_id, rpc_port_au char *view_id = NULL; char *app_id = NULL; + /* create autofill response */ + rpc_port_autofill_fill_response_h fill_response_h = NULL; + if (rpc_port_autofill_fill_response_create(&fill_response_h) != 0) + return; + 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); - /* create autofill response */ - rpc_port_autofill_fill_response_h fill_response_h; - rpc_port_autofill_fill_response_create(&fill_response_h); rpc_port_autofill_fill_response_set_view_id(fill_response_h, view_id); rpc_port_autofill_svc_fill_response_foreach_response_groups(response_h, fill_response_group_cb, fill_response_h); @@ -511,8 +529,8 @@ static void __fill_response_recv_cb(void *user_data, int context_id, rpc_port_au static void __auth_info_recv_cb(void *user_data, int context_id, rpc_port_autofill_svc_auth_info_h svc_auth_info_h) { - bool exist_autofill_data; - bool need_authentication; + bool exist_autofill_data = false; + bool need_authentication = false; char *service_name = NULL; char *service_logo_image_path = NULL; char *service_message = NULL; @@ -530,7 +548,7 @@ static void __auth_info_recv_cb(void *user_data, int context_id, rpc_port_autofi 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_h auth_info_h = NULL; rpc_port_autofill_auth_info_create(&auth_info_h); rpc_port_autofill_auth_info_set_view_id(auth_info_h, view_id); rpc_port_autofill_auth_info_set_exist_autofill_data(auth_info_h, exist_autofill_data); @@ -617,7 +635,7 @@ static char * __manager_get_autofill_service_cb(rpc_port_stub_AutofillManagerPor return false; } - char *app_id; + char *app_id = NULL; autofill_config_get_autofill_service_app_id(&app_id); LOGD("app id : %s", app_id); @@ -667,7 +685,7 @@ static bool __manager_get_autofill_service_list_cb(rpc_port_stub_AutofillManager return false; } - rpc_port_list_string_h app_id_list_h; + rpc_port_list_string_h app_id_list_h = NULL; rpc_port_list_string_create(&app_id_list_h); ret = app_info_metadata_filter_foreach(handle, add_autofill_service_cb, app_id_list_h); @@ -685,7 +703,7 @@ static bool __manager_get_autofill_service_list_cb(rpc_port_stub_AutofillManager static int connect_service() { int ret; - size_t service_id_len; + size_t service_id_len = 0; rpc_port_proxy_AutofillSvcPort_callback_s rpc_callback = { .connected = __on_connected, -- 2.7.4