From: Lukasz Stanislawski Date: Tue, 19 Apr 2016 11:25:07 +0000 (+0200) Subject: Lockscreen refactor X-Git-Tag: accepted/tizen/common/20160420.141000^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=c9b3b3367e701aa82fd27dc876ad883f2308c71a;p=apps%2Fcore%2Fpreloaded%2Flockscreen.git Lockscreen refactor This commit compleatly reimplements current lockscreen application. The reason to perform such task were: * many features of lockscreen were stubs or half-implemented features * source directory layout should match SDK requirements. * no application architecture was used New version is using modified version of MVC model. Commit additionally implements minicontroller handling and contextual events. Change-Id: I2888e286afdee84c68b82d01995332bd05f8e7e9 --- 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..7cacafc --- /dev/null +++ b/Build/basedef.mk @@ -0,0 +1,14 @@ +# Add inputs and outputs from these tool invocations to the build variables + +C_DEPS += + +SYSROOT := $(SBI_SYSROOT) + +ROOTSTRAP_INCS := $(addprefix -I $(SYSROOT)/,$(PLATFORM_INCS_EX)) +EFL_INCS := + +RS_LIBRARIES := $(addprefix -l,$(RS_LIBRARIES_EX)) + +PLATFORM_INCS := $(ROOTSTRAP_INCS) $(EFL_INCS) \ + -I"$(SDK_PATH)/library" + diff --git a/Build/flags.mk b/Build/flags.mk new file mode 100644 index 0000000..0ee8efb --- /dev/null +++ b/Build/flags.mk @@ -0,0 +1,16 @@ + +DEBUG_OP = -g3 +CPP_DEBUG_OP = + +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/makefile b/Build/makefile new file mode 100644 index 0000000..4e2d6c5 --- /dev/null +++ b/Build/makefile @@ -0,0 +1,275 @@ +BUILD_SCRIPT_VERSION := 1.0.7 + +all : app_build + +clean : app_clean + +version : make_version + + +BSLASH := \\# +BSLASH2SLASH = $(subst $(BSLASH),/,$(1)) +REMOVE_TAIL = $(patsubst %/,%,$(1)) + +PROJ_ROOT := $(call BSLASH2SLASH,$(PROJPATH)) + +-include $(PROJ_ROOT)/project_def.prop +-include basedef.mk +-include tooldef.mk +-include flags.mk +-include prepost.mk + +APPTYPE := $(type) + +OBJ_OUTPUT := $(call BSLASH2SLASH,$(OUTPUT_DIR)/objs) + +OS_NAME = $(shell $(UNAME)) + +#LOWER_APPNAME := $(shell echo translit($(APPNAME),[A-Z],[a-z])|$(M4)) +LOWER_APPNAME := $(shell echo $(APPNAME)|$(TR) [A-Z] [a-z]) + +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 + +FIND_FILES = $(shell $(FIND) $(PROJ_ROOT)/$(dir $(1)) -type f -name $(notdir $(1)) -printf '$(dir $(1))%P ') + +NORMAL_SRCS := $(filter-out %*.c %*.cpp,$(USER_SRCS)) +WIDLCARD_SRCS := $(filter %*.c %*.cpp,$(USER_SRCS)) +ALL_SRCS := $(NORMAL_SRCS) $(foreach var,$(WIDLCARD_SRCS),$(call FIND_FILES,$(var))) + +C_SRCS := $(filter %.c,$(ALL_SRCS)) +CPP_SRCS := $(filter %.cpp,$(ALL_SRCS)) + +USER_EDCS := $(subst $(BSLASH),/,$(USER_EDCS)) +NORMAL_EDCS := $(filter-out %*.edc,$(USER_EDCS)) +WIDLCARD_EDCS := $(filter %*.edc,$(USER_EDCS)) +EDCS := $(NORMAL_EDCS) $(foreach var,$(WIDLCARD_EDCS),$(call FIND_FILES,$(var))) + +NORMAL_POS := $(filter-out %*.po,$(USER_POS)) +WIDLCARD_POS := $(filter %*.po,$(USER_POS)) +POS := $(NORMAL_POS) $(foreach var,$(WIDLCARD_POS),$(call FIND_FILES,$(var))) + +LIBPATHS := $(addprefix -L$(PROJ_ROOT)/,$(USER_LIB_DIRS)) \ + $(addprefix -L,$(USER_LIB_DIRS_ABS)) +LIBS += $(addprefix -l,$(USER_LIBS)) +UOBJS := $(addprefix $(PROJ_ROOT)/,$(USER_OBJS)) \ + $(USER_OBJS_ABS) + +M_OPT = -MMD -MP -MF"$(@:%.o=%.d)" + +FUNC_C2O = $(patsubst %.c,$(OBJ_OUTPUT)/%.o,$(1)) +FUNC_CPP2O = $(patsubst %.cpp,$(OBJ_OUTPUT)/%.o,$(1)) +FUNC_EDC2EDJ = $(patsubst %.edc,$(OUTPUT_DIR)/%.edj,$(1)) +FUNC_PO2MO = $(patsubst %.po,$(OUTPUT_DIR)/res/locale/%/LC_MESSAGES/$(LOWER_APPNAME).mo,$(notdir $(1))) + + +C_OBJS := $(call FUNC_C2O,$(C_SRCS)) +CPP_OBJS := $(call FUNC_CPP2O,$(CPP_SRCS)) +OBJS := $(C_OBJS) $(CPP_OBJS) +EDJ_FILES := $(call FUNC_EDC2EDJ,$(EDCS)) +MO_FILES := $(call FUNC_PO2MO,$(POS)) +DEPS := $(OBJS:.o=.d) + + +ifneq ($(strip $(DEPS)),) +-include $(DEPS) +endif + +ifeq ($(strip $(APPTYPE)),app) +$(APPFILE) : $(OBJS) $(UOBJS) + @echo ' Building target: $@' + @echo ' Invoking: C/C++ Linker' + @$(MKDIR) $(MKDIR_OP) $(subst $(BSLASH),/,$(@D)) + $(CXX) -o "$(APPFILE)" $(OBJS) $(UOBJS) $(LIBPATHS) -Xlinker --as-needed $(LIBS) $(LINK_FLAGS) $(TC_LINKER_MISC) $(RS_LINKER_MISC) -pie -lpthread -Xlinker -rpath="/home/developer/sdk_tools/lib" --sysroot="$(SYSROOT)" -Xlinker --version-script="$(PROJ_PATH)/.exportMap" -L"$(SBI_SYSROOT)/usr/lib" $(RS_LIBRARIES) -Xlinker -rpath="/opt/usr/apps/$(APPID)/lib" -Werror-implicit-function-declaration + @echo ' Finished building target: $@' +endif +ifeq ($(strip $(APPTYPE)),staticLib) +$(APPFILE) : $(OBJS) $(UOBJS) + @echo ' Building target: $@' + @echo ' Invoking: Archive utility' + @$(MKDIR) $(MKDIR_OP) $(subst $(BSLASH),/,$(@D)) + $(AR) -r "$(APPFILE)" $(OBJS) $(UOBJS) $(AR_FLAGS) + @echo ' Finished building target: $@' +endif +ifeq ($(strip $(APPTYPE)),sharedLib) +$(APPFILE) : $(OBJS) $(UOBJS) + @echo ' Building target: $@' + @echo ' Invoking: C/C++ Linker' + @$(MKDIR) $(MKDIR_OP) $(subst $(BSLASH),/,$(@D)) + $(CXX) -o "$(APPFILE)" $(OBJS) $(UOBJS) $(LIBPATHS) -Xlinker --as-needed $(LIBS) $(LINK_FLAGS) $(TC_LINKER_MISC) $(RS_LINKER_MISC) -shared -lpthread --sysroot="$(SYSROOT)" -L"$(SYSROOT)/usr/lib" $(RS_LIBRARIES) + @echo ' Finished building target: $@' +endif + + +ifneq ($(strip $(C_SRCS)),) +CDEFS += $(addprefix -D,$(USER_DEFS)) +CDEFS += $(addprefix -U,$(USER_UNDEFS)) + +INCS := $(addprefix -I$(PROJ_ROOT)/,$(USER_INC_DIRS)) \ + $(addprefix -I,$(USER_INC_DIRS_ABS)) \ + $(addprefix -include$(PROJ_ROOT)/,$(USER_INC_FILES)) \ + $(addprefix -include,$(USER_INC_FILES_ABS)) + +$(C_OBJS) : $(OBJ_OUTPUT)/%.o : $(PROJ_ROOT)/%.c $(PLATFORM_INCS_FILE) + @echo ' Building file: $<' + @echo ' Invoking: C Compiler' + @$(MKDIR) $(MKDIR_OP) $(subst $(BSLASH),/,$(@D)) +ifeq ($(strip $(APPTYPE)),sharedLib) + $(CC) -c $< -o $@ $(CDEFS) $(INCS) -I"pch" $(COMPILE_FLAGS) $(TC_COMPILER_MISC) $(RS_COMPILER_MISC) -fPIC --sysroot="$(SYSROOT)" -Werror-implicit-function-declaration $(M_OPT) @$(PLATFORM_INCS_FILE) +else + $(CC) -c $< -o $@ $(CDEFS) $(INCS) -I"pch" $(COMPILE_FLAGS) $(TC_COMPILER_MISC) $(RS_COMPILER_MISC) -fPIE --sysroot="$(SYSROOT)" -Werror-implicit-function-declaration $(M_OPT) @$(PLATFORM_INCS_FILE) +endif + @echo ' Finished building: $<' +endif + +ifneq ($(strip $(CPP_SRCS)),) +CPPDEFS += $(addprefix -D,$(USER_CPP_DEFS)) +CPPDEFS += $(addprefix -U,$(USER_CPP_UNDEFS)) + +CPP_INCS := $(addprefix -I$(PROJ_ROOT)/,$(USER_CPP_INC_DIRS)) \ + $(addprefix -I,$(USER_CPP_INC_DIRS_ABS)) \ + $(addprefix -include$(PROJ_ROOT)/,$(USER_CPP_INC_FILES)) \ + $(addprefix -include,$(USER_CPP_INC_FILES_ABS)) + +$(CPP_OBJS) : $(OBJ_OUTPUT)/%.o : $(PROJ_ROOT)/%.cpp $(PLATFORM_INCS_FILE) + @echo ' Building file: $<' + @echo ' Invoking: C++ Compiler' + @$(MKDIR) $(MKDIR_OP) $(subst $(BSLASH),/,$(@D)) +ifeq ($(strip $(APPTYPE)),sharedLib) + $(CXX) -c $< -o $@ $(CPPDEFS) $(CPP_INCS) -I"pch" $(CPP_COMPILE_FLAGS) $(TC_COMPILER_MISC) $(RS_COMPILER_MISC) -fPIC --sysroot="$(SYSROOT)" -Werror-implicit-function-declaration $(M_OPT) @$(PLATFORM_INCS_FILE) +else + $(CXX) -c $< -o $@ $(CPPDEFS) $(CPP_INCS) -I"pch" $(CPP_COMPILE_FLAGS) $(TC_COMPILER_MISC) $(RS_COMPILER_MISC) -fPIE --sysroot="$(SYSROOT)" -Werror-implicit-function-declaration $(M_OPT) @$(PLATFORM_INCS_FILE) +endif + @echo ' Finished building: $<' +endif + + +$(OBJ_OUTPUT) : + @echo ' Building directory: $@' + @$(MKDIR) $(MKDIR_OP) $(OBJ_OUTPUT) + +preproc : $(OBJ_OUTPUT) +ifneq ($(strip $(PREBUILD_COMMAND)),) +ifneq ($(strip $(PREBUILD_DESC)),) + @echo $(PREBUILD_DESC) +endif + @echo $(shell $(PREBUILD_COMMAND)) +endif + + +postproc : +ifneq ($(strip $(POSTBUILD_COMMAND)),) +ifneq ($(strip $(POSTBUILD_DESC)),) + @echo $(POSTBUILD_DESC) +endif + @echo $(shell $(POSTBUILD_COMMAND)) +endif + +ifneq ($(strip $(PLATFORM_INCS)),) +$(PLATFORM_INCS_FILE) : $(OBJ_OUTPUT) + @echo ' Building inc file: $@' +ifneq ($(findstring Linux,$(OS_NAME)),) + @echo $(PLATFORM_INCS) > $@ +else +ifneq ($(findstring 3.82,$(MAKE_VERSION)),) + $(file > $@,$(PLATFORM_INCS)) +else + @echo $(PLATFORM_INCS) > $@ +endif +endif +endif + +ALL_EDJ_FILES := + +define EDJ_PROC +ALL_EDCS := $$(subst $(BSLASH),/,$$($(2))) +NORMAL_EDCS := $$(filter-out %*.edc,$$(ALL_EDCS)) +WIDLCARD_EDCS := $$(filter %*.edc,$$(ALL_EDCS)) +EDCS := $$(NORMAL_EDCS) $$(foreach var_edc,$$(WIDLCARD_EDCS),$$(call FIND_FILES,$$(var_edc))) + +ifneq ($$(strip $$(EDCS)),) +EDJ_FILES := $$(call FUNC_EDC2EDJ,$$(EDCS)) + +ALL_EDJ_FILES += $$(EDJ_FILES) + +EDC_$(1)_COMPILER_FLAGS := -id "$$(SDK_TOOLPATH)/enventor/share/enventor/images" +EDC_$(1)_COMPILER_FLAGS += -sd "$$(SDK_TOOLPATH)/enventor/share/enventor/sounds" +EDC_$(1)_COMPILER_FLAGS += -fd "$$(SDK_TOOLPATH)/enventor/share/enventor/fonts" + +ifneq ($$(strip $(3)),) +EDC_$(1)_COMPILER_FLAGS += $$(addprefix -id $$(PROJ_PATH)/,$$($(3))) +endif +ifneq ($$(strip $(4)),) +EDC_$(1)_COMPILER_FLAGS += $$(addprefix -id ,$$($(4))) +endif +ifneq ($$(strip $(5)),) +EDC_$(1)_COMPILER_FLAGS += $$(addprefix -sd $$(PROJ_PATH)/,$$($(5))) +endif +ifneq ($$(strip $(6)),) +EDC_$(1)_COMPILER_FLAGS += $$(addprefix -sd ,$$($(6))) +endif +ifneq ($$(strip $(7)),) +EDC_$(1)_COMPILER_FLAGS += $$(addprefix -fd $$(PROJ_PATH)/,$$($(7))) +endif +ifneq ($$(strip $(8)),) +EDC_$(1)_COMPILER_FLAGS += $$(addprefix -fd ,$$($(8))) +endif + +$$(EDJ_FILES) : $$(OUTPUT_DIR)/%.edj : $$(PROJ_ROOT)/%.edc + @echo ' Building file: $$<' + @echo ' Invoking: EDC Resource Compiler' + @$$(MKDIR) $$(MKDIR_OP) $$(subst $$(BSLASH),/,$$(@D)) + $$(EDJE_CC) $$(EDC_$(1)_COMPILER_FLAGS) $$(CDEFS) "$$<" "$$@" + @echo ' Finished building: $$<' +endif +endef + +# Global EDCs +ifneq ($(strip $(USER_EDCS)),) +$(eval $(call EDJ_PROC,,USER_EDCS,USER_EDCS_IMAGE_DIRS,USER_EDCS_IMAGE_DIRS_ABS,USER_EDCS_SOUND_DIRS,USER_EDCS_SOUND_DIRS_ABS,USER_EDCS_FONT_DIRS,USER_EDCS_FONT_DIRS_ABS)) +endif + +# Individual EDCs +ifneq ($(strip $(USER_EXT_EDC_KEYS)),) +$(foreach var,$(USER_EXT_EDC_KEYS),$(eval $(call EDJ_PROC,$(var),USER_EXT_$(var)_EDCS,USER_EXT_$(var)_EDCS_IMAGE_DIRS,USER_EXT_$(var)_EDCS_IMAGE_DIRS_ABS,USER_EXT_$(var)_EDCS_SOUND_DIRS,USER_EXT_$(var)_EDCS_SOUND_DIRS_ABS,USER_EXT_$(var)_EDCS_FONT_DIRS,USER_EXT_$(var)_EDCS_FONT_DIRS_ABS))) +endif + + +ifneq ($(strip $(POS)),) +define MO_RULE +$(call FUNC_PO2MO,$(1)) : $(PROJ_ROOT)/$(1) + @echo ' Building file: $$<' + @echo ' Invoking: msgfmt String Formatter' + @$$(MKDIR) $$(MKDIR_OP) $$(subst $$(BSLASH),/,$$(@D)) + $$(MSGFMT) -o $$@ $$< + @echo ' Finished building: $$<' +endef + +$(foreach var,$(POS),$(eval $(call MO_RULE,$(var)))) +endif + + +secondary-outputs : $(ALL_EDJ_FILES) $(MO_FILES) + +-include appendix.mk + + +app_build : preproc $(APPFILE) secondary-outputs postproc + +app_clean : + rm -f "$(APPFILE)" + rm -rf "$(OUTPUT_DIR)" + +make_version : + @echo $(BUILD_SCRIPT_VERSION) diff --git a/Build/prepost.mk b/Build/prepost.mk new file mode 100644 index 0000000..6bb5e2f --- /dev/null +++ b/Build/prepost.mk @@ -0,0 +1,6 @@ + +# Add pre/post build process +PREBUILD_DESC = +PREBUILD_COMMAND = +POSTBUILD_DESC = +POSTBUILD_COMMAND = diff --git a/Build/tooldef.mk b/Build/tooldef.mk new file mode 100644 index 0000000..4244fb3 --- /dev/null +++ b/Build/tooldef.mk @@ -0,0 +1,61 @@ +# Add inputs and outputs from these tool invocations to the build variables + +ifeq ($(strip $(BUILD_CONFIG)),) +BUILD_CONFIG = Debug +endif + +ifeq ($(strip $(OUTPUT_DIR)),) +OUTPUT_DIR := $(PROJPATH)/$(BUILD_CONFIG) +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 $(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 + diff --git a/CMake/CMakeLists.txt b/CMake/CMakeLists.txt new file mode 100644 index 0000000..c64c82b --- /dev/null +++ b/CMake/CMakeLists.txt @@ -0,0 +1,81 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(lockscreen C) + +SET(INSTALL_EXEC_PREFIX "${INSTALL_PREFIX}/bin") +SET(INSTALL_RESDIR "${INSTALL_PREFIX}/res") +SET(INSTALL_IMAGEDIR "${INSTALL_RESDIR}/images") +SET(EDJEDIR "${INSTALL_RESDIR}/edje") +SET(LOCALEDIR "${INSTALL_RESDIR}/locale") +SET(CMAKE_VERBOSE_MAKEFILE 0) + +SET(PROJECT_ROOT_DIR "${CMAKE_SOURCE_DIR}/..") +SET(PROJECT_RESOURCES_DIR "${PROJECT_ROOT_DIR}/res") +SET(PROJECT_EDC_DIR "${PROJECT_RESOURCES_DIR}/edje") +SET(PROJECT_IMAGES_DIR "${PROJECT_RESOURCES_DIR}/images") +SET(PROJECT_PO_DIR "${PROJECT_RESOURCES_DIR}/po") + +INCLUDE(FindPkgConfig) +pkg_check_modules(MENU_PKGS REQUIRED + dlog + bundle + elementary + capi-system-info + capi-system-runtime-info + capi-system-system-settings + capi-system-device + capi-appfw-application + capi-appfw-app-manager + notification + minicontrol-viewer + feedback + tzsh-lockscreen-service + capi-base-utils-i18n + capi-telephony +) + +FOREACH (flag ${MENU_PKGS_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Winline -g -fno-builtin-malloc -fPIE") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") + +INCLUDE_DIRECTORIES(${PROJECT_ROOT_DIR}/inc) + +ADD_EXECUTABLE(${PROJECT_NAME} + ${PROJECT_ROOT_DIR}/src/battery_ctrl.c + ${PROJECT_ROOT_DIR}/src/camera_ctrl.c + ${PROJECT_ROOT_DIR}/src/camera_view.c + ${PROJECT_ROOT_DIR}/src/lockscreen.c + ${PROJECT_ROOT_DIR}/src/util.c + ${PROJECT_ROOT_DIR}/src/window.c + ${PROJECT_ROOT_DIR}/src/background.c + ${PROJECT_ROOT_DIR}/src/battery.c + ${PROJECT_ROOT_DIR}/src/events.c + ${PROJECT_ROOT_DIR}/src/events_view.c + ${PROJECT_ROOT_DIR}/src/events_ctrl.c + ${PROJECT_ROOT_DIR}/src/minicontrollers.c + ${PROJECT_ROOT_DIR}/src/sim.c + ${PROJECT_ROOT_DIR}/src/camera.c + ${PROJECT_ROOT_DIR}/src/main_view.c + ${PROJECT_ROOT_DIR}/src/main_ctrl.c + ${PROJECT_ROOT_DIR}/src/display.c + ${PROJECT_ROOT_DIR}/src/time_format.c + ${PROJECT_ROOT_DIR}/src/util_time.c + ${PROJECT_ROOT_DIR}/src/time_format_ctrl.c + ${PROJECT_ROOT_DIR}/src/sim_ctrl.c +) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} -lm) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${MENU_PKGS_LDFLAGS}) + +# Install +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${INSTALL_EXEC_PREFIX}) + +INSTALL(FILES ${PROJECT_ROOT_DIR}/tizen-manifest.xml DESTINATION ${SYS_PACKAGES_DIR} RENAME org.tizen.lockscreen.xml) +INSTALL(DIRECTORY DESTINATION ${PREFIX}/data) +INSTALL(FILES ${PROJECT_ROOT_DIR}/shared/res/lockscreen.png DESTINATION ${SYS_ICONS_DIR}) + +# End of a file +ADD_SUBDIRECTORY(res) diff --git a/CMake/res/CMakeLists.txt b/CMake/res/CMakeLists.txt new file mode 100644 index 0000000..b8b6e43 --- /dev/null +++ b/CMake/res/CMakeLists.txt @@ -0,0 +1,4 @@ +ADD_SUBDIRECTORY(edje) +ADD_SUBDIRECTORY(po) +ADD_SUBDIRECTORY(images) + diff --git a/CMake/res/edje/CMakeLists.txt b/CMake/res/edje/CMakeLists.txt new file mode 100644 index 0000000..01d8d29 --- /dev/null +++ b/CMake/res/edje/CMakeLists.txt @@ -0,0 +1,15 @@ +ADD_CUSTOM_TARGET(lockscreen.edj + COMMAND edje_cc -id ${PROJECT_EDC_DIR}/images + ${PROJECT_EDC_DIR}/lockscreen.edc lockscreen.edj + DEPENDS ${PROJECT_EDC_DIR}/lockscreen.edc +) +ADD_DEPENDENCIES(${PROJECT_NAME} lockscreen.edj) +INSTALL(FILES lockscreen.edj DESTINATION ${EDJEDIR}) + +ADD_CUSTOM_TARGET(index.edj + COMMAND edje_cc -id ${PROJECT_EDC_DIR}/images + ${PROJECT_EDC_DIR}/index.edc index.edj + DEPENDS ${PROJECT_EDC_DIR}/index.edc +) +ADD_DEPENDENCIES(${PROJECT_NAME} index.edj) +INSTALL(FILES index.edj DESTINATION ${EDJEDIR}) diff --git a/CMake/res/images/CMakeLists.txt b/CMake/res/images/CMakeLists.txt new file mode 100644 index 0000000..5737cc5 --- /dev/null +++ b/CMake/res/images/CMakeLists.txt @@ -0,0 +1,4 @@ +INSTALL(FILES ${PROJECT_IMAGES_DIR}/Notification_ic_message.png DESTINATION ${INSTALL_IMAGEDIR}) +INSTALL(FILES ${PROJECT_IMAGES_DIR}/Notification_ic_missedcall.png DESTINATION ${INSTALL_IMAGEDIR}) +INSTALL(FILES ${PROJECT_IMAGES_DIR}/Default.jpg DESTINATION ${INSTALL_IMAGEDIR}) + diff --git a/po/CMakeLists.txt b/CMake/res/po/CMakeLists.txt old mode 100644 new mode 100755 similarity index 59% rename from po/CMakeLists.txt rename to CMake/res/po/CMakeLists.txt index 2d1db70..1ac0fc9 --- a/po/CMakeLists.txt +++ b/CMake/res/po/CMakeLists.txt @@ -1,12 +1,16 @@ # for i18n -SET(POFILES ar.po az.po bg.po ca.po cs.po da.po de.po el_GR.po en.po en_PH.po en_US.po es_ES.po es_US.po et.po eu.po fi.po fr.po fr_CA.po ga.po gl.po hi.po hr.po hu.po hy.po is.po it_IT.po ja_JP.po ka.po kk.po ko_KR.po lt.po lv.po mk.po nb.po nl.po pl.po pt_BR.po pt_PT.po ro.po ru_RU.po sk.po sl.po sr.po sv.po tr_TR.po uk.po uz.po zh_CN.po zh_HK.po zh_TW.po) - +SET(POFILES ar.po az.po bg.po ca.po cs.po da.po de.po el_GR.po en_PH.po en.po en_US.po + es_ES.po es_US.po et.po eu.po fi.po fr_CA.po fr.po ga.po gl.po hi.po hr.po + hu.po hy.po is.po it_IT.po ja_JP.po ka.po kk.po ko_KR.po lt.po lv.po mk.po + nb.po nl.po pl.po pt_BR.po pt_PT.po ro.po ru_RU.po sk.po sl.po sr.po sv.po + tr_TR.po uk.po uz.po zh_CN.po zh_HK.po zh_TW.po) SET(MSGFMT "/usr/bin/msgfmt") +MESSAGE(STATUS "po files ---") FOREACH(pofile ${POFILES}) - SET(pofile ${CMAKE_CURRENT_SOURCE_DIR}/${pofile}) - MESSAGE("PO: ${pofile}") + SET(pofile ${PROJECT_PO_DIR}/${pofile}) + MESSAGE(STATUS " ${pofile}") GET_FILENAME_COMPONENT(absPofile ${pofile} ABSOLUTE) GET_FILENAME_COMPONENT(lang ${absPofile} NAME_WE) SET(moFile ${CMAKE_CURRENT_BINARY_DIR}/${lang}.mo) @@ -19,5 +23,4 @@ FOREACH(pofile ${POFILES}) SET(moFiles ${moFiles} ${moFile}) ENDFOREACH(pofile) -MESSAGE(".mo files: ${moFiles}") ADD_CUSTOM_TARGET(po ALL DEPENDS ${moFiles}) diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100755 index da7adec..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,97 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(lockscreen) -# FIND ALL SOURCE IN A SOURCE DIRECTORY -AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src SRCS) -AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/daemon SRCS) - -#INCLUDE FILE -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) -SET(PACKAGE "${PROJECT_NAME}") -SET(RESOURCE_DIR "${CMAKE_SOURCE_DIR}/res") -SET(EDJDIR "${RESOURCE_DIR}/edje/${PACKAGE}") -SET(LOCALEDIR "/usr/apps/org.tizen.lockscreen/res/locale") - -INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs REQUIRED - bundle - appcore-efl - evas - edje - elementary - ecore - eina - capi-system-sensor - capi-system-info - capi-system-runtime-info - capi-system-system-settings - capi-system-device - capi-appfw-application - capi-appfw-preference - capi-appfw-app-manager - capi-ui-efl-util - aul - ail - notification - minicontrol-viewer - minicontrol-monitor - ui-gadget-1 - feedback - msg-service - tapi - efl-extension - key-manager - accounts-svc - dbus-1 - dbus-glib-1 - deviced - tzsh-lockscreen-service -) - -IF(X11_SUPPORT) -pkg_check_modules(pkgs REQUIRED - ecore-x - utilX - ) -ENDIF(X11_SUPPORT) - -IF(WAYLAND_SUPPORT) -pkg_check_modules(pkgs REQUIRED - ecore-wayland - ) -ENDIF(WAYLAND_SUPPORT) - -ADD_DEFINITIONS("-DPROJECT=\"${PROJECT_NAME}\"") - -FOREACH(flag ${pkgs_CFLAGS}) - SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") -ENDFOREACH(flag) - -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fPIE") -SET(CMAKE_C_FLAGS_PROFILING "-O0 -g -pg -fPIE") -SET(CMAKE_CXX_FLAGS_PROFILING "-O0 -std=c++0x -g -pg -fPIE") -SET(CMAKE_C_FLAGS_DEBUG "-O0 -g -fPIE") -SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -std=c++0x -g -fPIE") -SET(CMAKE_C_FLAGS_RELEASE "-O2 -g -fPIE") -SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -std=c++0x -g -fPIE") -SET(CMAKE_C_FLAGS_CCOV "-O2 -g --coverage -fPIE") -SET(CMAKE_CXX_FLAGS_CCOV "-O2 -std=c++0x -g --coverage -fPIE") - -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") - -ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) - -TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS}) - -# Install -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) - -#Install images -INSTALL(DIRECTORY data/images/ DESTINATION res/images) - -# Install Manifest File -INSTALL(FILES org.tizen.lockscreen.xml DESTINATION /usr/share/packages) - -# End of a file -ADD_SUBDIRECTORY(data) -ADD_SUBDIRECTORY(po) diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt deleted file mode 100755 index 26fdf5e..0000000 --- a/data/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -ADD_CUSTOM_TARGET(lockscreen.edj - COMMAND edje_cc -id ${CMAKE_CURRENT_SOURCE_DIR}/edje/images - ${CMAKE_SOURCE_DIR}/data/edje/lockscreen.edc ${CMAKE_BINARY_DIR}/data/edje/lockscreen.edj - DEPENDS ${CMAKE_SOURCE_DIR}/data/edje/lockscreen.edc -) -ADD_DEPENDENCIES(${PROJECT_NAME} lockscreen.edj) -INSTALL(FILES edje/lockscreen.edj DESTINATION res/edje) - diff --git a/data/edje/camera.edc b/data/edje/camera.edc deleted file mode 100644 index 2266cd9..0000000 --- a/data/edje/camera.edc +++ /dev/null @@ -1,288 +0,0 @@ -/* - * Copyright (c) 2009-2014 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. - */ - -group { - name: "camera-layout"; - images { - image: "lock_circle_line_camera_drag.png" COMP; - image: "lock_circle_line_camera.png" COMP; - image: "quick_shot_bg.png" COMP; - image: "quick_shot_icon.png" COMP; - } - parts { - part { - name: "bg"; - type: SPACER; - scale: 1; - description { - state: "default" 0.0; - fixed: 1 1; - min: CAMERA_LAYOUT_SIZE CAMERA_LAYOUT_SIZE; - max: CAMERA_LAYOUT_SIZE CAMERA_LAYOUT_SIZE; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 1.0 1.0; } - } - } - part { - name: "img.camera.circle.line"; - type: IMAGE; - scale: 1; - description { - state: "default" 0.0; - fixed: 1 1; - rel1 { relative: 0.5 0.5; to: "bg"; } - rel2 { relative: 0.5 0.5; to: "bg"; } - min: CAMERA_ICON_SIZE CAMERA_ICON_SIZE; - max: CAMERA_ICON_SIZE CAMERA_ICON_SIZE; - image.normal: "lock_circle_line_camera.png"; - visible: 0; - } - description { - state: "release" 0.0; - inherit: "default" 0.0; - min: CAMERA_ICON_SIZE CAMERA_ICON_SIZE; - max: CAMERA_ICON_SIZE CAMERA_ICON_SIZE; - visible: 0; - } - description { - state: "press" 0.0; - inherit: "default" 0.0;; - min: CAMERA_LAYOUT_SIZE CAMERA_LAYOUT_SIZE; - max: CAMERA_LAYOUT_SIZE CAMERA_LAYOUT_SIZE; - visible: 1; - } - } - part { - name: "img.camera.circle.drag"; - type: IMAGE; - description { - state: "default" 0.0; - fixed: 1 1; - align: 0.5 0.5; - rel1 { relative: 0.5 0.5; to: "bg"; } - rel2 { relative: 0.5 0.5; to: "bg"; } - min: 1 1; - max: 1 1; - image.normal: "lock_circle_line_camera_drag.png"; - visible: 0; - } - description { - state: "release" 0.0; - inherit: "default" 0.0; - min: 1 1; - max: 1 1; - visible: 0; - } - description { - state: "press" 0.0; - inherit: "default" 0.0;; - visible: 1; - } - } - part { - name: "img.camera.bg"; - type: IMAGE; - scale: 1; - description { - state: "default" 0.0; - min: CAMERA_ICON_SIZE CAMERA_ICON_SIZE; - max: CAMERA_ICON_SIZE CAMERA_ICON_SIZE; - fixed: 1 1; - rel1 { relative: 0.5 0.5; to: "bg"; } - rel2 { relative: 0.5 0.5; to: "bg"; } - image.normal: "quick_shot_bg.png"; - color_class: "AO001"; - } - description { - state: "release" 0.0; - inherit: "default" 0.0; - color_class: "AO001"; - } - description { - state: "press" 0.0; - inherit: "default" 0.0;; - color_class: "AO001P"; - } - } - part { - name: "img.camera.icon"; - type: IMAGE; - scale: 1; - repeat_events: 1; - description { - state: "default" 0.0; - min: CAMERA_ICON_SIZE CAMERA_ICON_SIZE; - max: CAMERA_ICON_SIZE CAMERA_ICON_SIZE; - fixed: 1 1; - rel1 { relative: 0.5 0.5; to: "img.camera.bg"; } - rel2 { relative: 0.5 0.5; to: "img.camera.bg"; } - image.normal: "quick_shot_icon.png"; - map { - on: 1; - rotation { - center: "bg"; - x: 0.0; - y: 0.0; - z: 0.0; - } - } - } - } - } - programs { - script{ - public use_custom; - public g_mouse_down; - public g_full_state; - public g_angle; - public g_angle_new; - public g_angle_old; - public g_angle_busy; - public g_anim_fill_enable; - public g_filler_expanded; - } - program { - name: "init,layout"; - signal: "load"; - source: ""; - script { - set_int(g_mouse_down, 0); - set_int(g_angle, 0); - set_int(g_angle_new, 0); - set_int(g_angle_busy, 0); - set_int(g_anim_fill_enable, 0); - set_int(g_full_state, 0); - set_int(g_filler_expanded, 0); - set_int(use_custom, 0); - } - } - program { - name: "rotation,end"; - script { - new angle_old; - new angle_new; - - angle_old = get_int(g_angle); - angle_new = get_int(g_angle_new); - - if (angle_old != angle_new) { - set_int(g_angle_busy, 1); - } else { - set_int(g_angle_busy, 0); - } - } - } - program { - signal: "mouse,down,1"; - source: "img.camera.bg"; - action: SIGNAL_EMIT "camera,icon,mouse,down" "img.camera.bg"; - script { - set_int(g_mouse_down, 1); - } - } - program { - name: "camera,icon,press"; - signal: "camera,icon,press"; - source: "img.camera.bg"; - action: STATE_SET "press" 0.0; - target: "img.camera.bg"; - target: "img.camera.circle.drag"; - after: "camera,circle,start"; - } - program { - name: "camera,circle,start"; - source: "img.camera.circle.line"; - action: STATE_SET "press" 0.0; - target: "img.camera.circle.line"; - transition: SIN_FAC 0.5 1.7; - } - program { - signal: "mouse,up,1"; - source: "img.camera.bg"; - action: SIGNAL_EMIT "camera,icon,mouse,up" "img.camera.bg"; - script { - set_int(g_mouse_down, 0); - } - - } - program { - name: "camera,icon,release"; - signal: "camera,icon,release"; - source: "img.camera.bg"; - action: STATE_SET "release" 0.0; - target: "img.camera.bg"; - after: "camera,circle,end"; - } - program { - name: "camera,circle,end"; - source: "img.camera.circle.line"; - action: STATE_SET "release" 0.0; - target: "img.camera.circle.line"; - target: "img.camera.circle.drag"; - transition: SIN_FAC 0.5 1.7; - } - program { - signal: "mouse,move"; - source: "img.camera.icon"; - script { - new x; - new y; - get_mouse(x, y); - - if (get_int(g_mouse_down) == 0) { - return ; - } - - new x_icon; - new y_icon; - new w_icon; - new h_icon; - get_geometry(PART:"img.camera.icon", x_icon, y_icon, w_icon, h_icon); - - new x_max; - new y_max; - new w_max; - new h_max; - get_geometry(PART:"bg", x_max, y_max, w_max, h_max); - - new Float:d_x; - new Float:d_y; - d_x = abs((x_icon + (w_icon / 2) - x) * 2); - d_y = abs((y_icon + (h_icon / 2) - y) * 2); - - new min = round(sqrt((d_x * d_x) + (d_y * d_y))); - - min = (min > w_max) ? w_max : min; - min = (min < w_icon) ? w_icon : min; - - custom_state(PART:"img.camera.circle.drag", "press", 0.0); - set_state_val(PART:"img.camera.circle.drag", STATE_MIN, min, min); - set_state_val(PART:"img.camera.circle.drag", STATE_MAX, min, min); - set_state(PART:"img.camera.circle.drag", "custom", 0.0); - - if (min >= w_max) { - if (get_int(g_full_state) == 0) { - stop_programs_on(PART:"img.camera.circle.line"); - } - set_int(g_full_state, 1); - } else { - set_int(g_full_state, 0); - } - set_int(g_filler_expanded, 1); - } - } - } -} diff --git a/data/edje/contextual_event.edc b/data/edje/contextual_event.edc deleted file mode 100644 index 0afbd38..0000000 --- a/data/edje/contextual_event.edc +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright (c) 2009-2014 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. - */ - -group { - styles { - style { - name: "time_style_contextual"; - base: "style=far_shadow,bottom shadow_color=#00000033 font=SamsungNeoNum-3T:style=Regular color=#FFFFFF font_size=32 align=center wrap=none"; - } - style { - name: "close_style"; - base: "font=Tizen:style=Regular color=#FFFFFF font_size=32 wrap=none align=center"; - } - } - images { - image: "event_close_bg.#.png" COMP; - image: "miss_noti_bg.#.png" COMP; - } - name: "contextual-event"; - parts { - part { - name: "bg"; - type: SPACER; - description { - state: "default" 0.0; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 1.0 1.0; } - } - } - part { - name: "img.event.area.bg"; - type: IMAGE; - description { - state: "default" 0.0; - align: 0.0 0.0; - rel1 { relative: CONTEXTUAL_INFO_PADDING_LEFT/WIN_WIDTH CONTEXTUAL_INFO_DATE_HEIGHT/CONTEXTUAL_INFO_HEIGHT; to: "bg"; } - rel2 { relative: (WIN_WIDTH - CONTEXTUAL_INFO_PADDING_RIGHT)/WIN_WIDTH CONTEXTUAL_INFO_EVENT_AREA_HEIGHT/CONTEXTUAL_INFO_HEIGHT; to: "bg"; } - image { - normal: "miss_noti_bg.#.png"; - } - color_class: "AO002"; - } - } - part { - name: "rect.time.date.info"; - type: SPACER; - description { - state: "default" 0.0; - align: 0.0 0.0; - rel1 { relative: 0.0 0.0; to: "bg"; } - rel2 { relative: 1.0 CONTEXTUAL_INFO_DATE_HEIGHT/CONTEXTUAL_INFO_HEIGHT; to: "bg"; } - } - } - part { - name: "txt.date"; - type: TEXTBLOCK; - scale: 1; - description { - state: "default" 0.0; - align: 0.0 0.0; - rel1 { relative: 0.0 0.0; to_x: "bg"; to_y: "rect.time.date.info"; offset: 0 10; } - rel2 { relative: 1.0 0.0; to_x: "bg"; to_y: "rect.time.date.info"; offset: 0 10;} - text { - style: "time_style_contextual"; - align: 0.5 0.5; - min: 1 1; - ellipsis: -1; - text: "12:45 PM Wed, 3 August"; - } - } - } - part { - name: "rect.close.btn"; - type: SPACER; - description { - state: "default" 0.0; - align: 0.0 0.0; - rel1 { relative: CONTEXTUAL_INFO_PADDING_LEFT/WIN_WIDTH CONTEXTUAL_INFO_DATE_HEIGHT/CONTEXTUAL_INFO_HEIGHT; to: "bg"; } - rel2 { relative: (WIN_WIDTH - CONTEXTUAL_INFO_PADDING_RIGHT)/WIN_WIDTH (CONTEXTUAL_INFO_DATE_HEIGHT + 13 + CONTEXTUAL_INFO_CLOSE_BTN_HEIGHT + 13)/CONTEXTUAL_INFO_HEIGHT; to: "bg"; } - } - } - part { - name: "txt.close"; - type: TEXTBLOCK; - scale: 1; - repeat_events: 1; - description { - state: "default" 0.0; - align: 1.0 0.5; - rel1 { relative: 1.0 0.5; to: "rect.close.btn"; offset: -32 0; } - rel2 { relative: 1.0 0.5; to: "rect.close.btn"; offset: -32 0; } - text { - style: "close_style"; - min: 1 1; - ellipsis: -1; - align: 0.5 0.5; - text: "CLOSE"; - } - } - } - part { - name: "btn.close"; - type: IMAGE; - description { - state: "default" 0.0; - align: 1.0 0.0; - rel1 { to: "txt.close"; offset: -10 0; } - rel2 { to: "txt.close"; offset: 10 0; } - image { - normal: "event_close_bg.#.png"; - } - color_class: "AO005"; - } - description { - state: "press" 0.0; - inherit: "default" 0.0; - color: 50 50 50 50; - } - } - part { - name: "sw.scroller"; - type: SWALLOW; - scale: 1; - description { - state: "default" 0.0; - fixed: 1 1; - align: 0.0 0.0; - rel1 { relative: CONTEXTUAL_INFO_PADDING_LEFT/WIN_WIDTH 1.0; to_x: "bg"; to_y: "rect.close.btn"; } - rel2 { relative: (WIN_WIDTH - CONTEXTUAL_INFO_PADDING_RIGHT)/WIN_WIDTH 1.0; to_x: "bg"; to_y: "img.event.area.bg"; } - } - } - part { - name: "rect.index"; - type: SPACER; - description { - state: "default" 0.0; - align: 0.0 0.0; - rel1 { relative: 0.0 CONTEXTUAL_INFO_EVENT_AREA_HEIGHT/CONTEXTUAL_INFO_HEIGHT; to: "bg"; } - rel2 { relative: 1.0 (CONTEXTUAL_INFO_EVENT_AREA_HEIGHT + 10 + CONTEXTUAL_INFO_PAGE_INDICATOR_HEIGHT)/CONTEXTUAL_INFO_HEIGHT; to: "bg"; } - } - } - part { - name: "sw.index"; - type: SWALLOW; - description { - state: "default" 0.0; - align: 0.5 0.5; - rel1 { relative: 0.0 0.0; to: "rect.index"; } - rel2 { relative: 1.0 1.0; to: "rect.index"; } - visible: 1; - } - description { - state: "hide" 0.0; - inherit: "default" 0.0; - visible: 0; - } - } - } - programs { - program { - name: "btn,close,press"; - signal: "mouse,down,1"; - source: "btn.close"; - action: STATE_SET "press" 0.0; - target: "btn.close"; - } - program { - name: "btn,close,release"; - signal: "mouse,up,1"; - source: "btn.close"; - action: STATE_SET "default" 0.0; - target: "btn.close"; - } - program { - name: "btn,close,clicked"; - signal: "mouse,clicked,1"; - source: "btn.close"; - action: SIGNAL_EMIT "btn,close,clicked" "btn.close"; - } - program { - name: "hide,index"; - signal: "hide,index"; - source: "sw.index"; - action: STATE_SET "hide" 0.0; - target: "sw.index"; - } - program { - name: "show,index"; - signal: "show,index"; - source: "sw.index"; - action: STATE_SET "default" 0.0; - target: "sw.index"; - } - } -} - -group { - name: "missed-event-page"; - parts { - part { - name: "bg"; - type: SWALLOW; - description { - state: "default" 0.0; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 1.0 1.0; } - } - } - part { - name: "sw.content.top"; - type: SWALLOW; - description { - state: "default" 0.0; - align: 0.0 0.0; - rel1 { relative: 0.0 0.0; to: "bg"; } - rel2 { relative: 1.0 MISSED_EVT_ITEM_HEIGHT/CONTEXTUAL_INFO_PAGE_HEIGHT; to: "bg"; } - } - } - part { - name: "rect.separator"; - type: RECT; - description { - state: "default" 0.0; - min: 1 1; - fixed: 1 1; - align: 0.0 0.0; - rel1 { relative: CONTEXTUAL_INFO_PADDING_LEFT/WIN_WIDTH 1.0; to_x: "bg"; to_y: "sw.content.top"; } - rel2 { relative: (WIN_WIDTH - CONTEXTUAL_INFO_PADDING_RIGHT)/WIN_WIDTH 1.0; to_x: "bg"; to_y: "sw.content.top"; } - color_class: "AO002L1"; - } - } - part { - name: "sw.content.bottom"; - type: SWALLOW; - description { - state: "default" 0.0; - align: 0.0 0.0; - rel1 { relative: 0.0 MISSED_EVT_ITEM_HEIGHT/CONTEXTUAL_INFO_PAGE_HEIGHT; to: "bg"; } - rel2 { relative: 1.0 (MISSED_EVT_ITEM_HEIGHT*2)/CONTEXTUAL_INFO_PAGE_HEIGHT; to: "bg"; } - } - } - } -} - -group { - name: "music-page"; - parts { - part { - name: "bg"; - type: SWALLOW; - description { - state: "default" 0.0; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 1.0 1.0; } - } - } - part { - name: "sw.content"; - type: SWALLOW; - description { - state: "default" 0.0; - align: 0.0 0.0; - rel1 { relative: 0.0 0.0; to: "bg"; } - rel2 { relative: 1.0 1.0; to: "bg"; } - } - } - } -} diff --git a/data/edje/images/enter_pin_dot.png b/data/edje/images/enter_pin_dot.png deleted file mode 100644 index 467db33..0000000 Binary files a/data/edje/images/enter_pin_dot.png and /dev/null differ diff --git a/data/edje/images/lock_circle_line_camera.png b/data/edje/images/lock_circle_line_camera.png deleted file mode 100644 index 9330235..0000000 Binary files a/data/edje/images/lock_circle_line_camera.png and /dev/null differ diff --git a/data/edje/images/lock_circle_line_camera_drag.png b/data/edje/images/lock_circle_line_camera_drag.png deleted file mode 100644 index 0971827..0000000 Binary files a/data/edje/images/lock_circle_line_camera_drag.png and /dev/null differ diff --git a/data/edje/images/ls_back_02_nor.png b/data/edje/images/ls_back_02_nor.png deleted file mode 100644 index 7a8f607..0000000 Binary files a/data/edje/images/ls_back_02_nor.png and /dev/null differ diff --git a/data/edje/images/ls_back_02_press.png b/data/edje/images/ls_back_02_press.png deleted file mode 100644 index 7426dfc..0000000 Binary files a/data/edje/images/ls_back_02_press.png and /dev/null differ diff --git a/data/edje/images/ls_icon_call.png b/data/edje/images/ls_icon_call.png deleted file mode 100644 index 18bf92a..0000000 Binary files a/data/edje/images/ls_icon_call.png and /dev/null differ diff --git a/data/edje/images/ls_password_underline.#.png b/data/edje/images/ls_password_underline.#.png deleted file mode 100644 index 9b6944b..0000000 Binary files a/data/edje/images/ls_password_underline.#.png and /dev/null differ diff --git a/data/edje/images/ls_pin_dot.png b/data/edje/images/ls_pin_dot.png deleted file mode 100644 index c01ca7c..0000000 Binary files a/data/edje/images/ls_pin_dot.png and /dev/null differ diff --git a/data/edje/images/miss_noti_bg.#.png b/data/edje/images/miss_noti_bg.#.png deleted file mode 100644 index fe970b5..0000000 Binary files a/data/edje/images/miss_noti_bg.#.png and /dev/null differ diff --git a/data/edje/images/quick_button_icon_bg.png b/data/edje/images/quick_button_icon_bg.png deleted file mode 100755 index 392389c..0000000 Binary files a/data/edje/images/quick_button_icon_bg.png and /dev/null differ diff --git a/data/edje/images/quick_shot.png b/data/edje/images/quick_shot.png deleted file mode 100755 index d2957c1..0000000 Binary files a/data/edje/images/quick_shot.png and /dev/null differ diff --git a/data/edje/images/quick_shot_bg.png b/data/edje/images/quick_shot_bg.png deleted file mode 100644 index 19cc91c..0000000 Binary files a/data/edje/images/quick_shot_bg.png and /dev/null differ diff --git a/data/edje/images/quick_shot_icon.png b/data/edje/images/quick_shot_icon.png deleted file mode 100644 index 4221723..0000000 Binary files a/data/edje/images/quick_shot_icon.png and /dev/null differ diff --git a/data/edje/images/quick_shot_press.png b/data/edje/images/quick_shot_press.png deleted file mode 100644 index 9046ca1..0000000 Binary files a/data/edje/images/quick_shot_press.png and /dev/null differ diff --git a/data/edje/index.edc b/data/edje/index.edc deleted file mode 100644 index 5096eba..0000000 --- a/data/edje/index.edc +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright (c) 2009-2014 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. - */ - -#define INDEX_PAGECONTROL_IND_INC 35 35 -#define INDEX_PAGECONTROL_IND_MIN_INC 35 35 -#define INDEX_PAGECONTROL_FONT_COLOR_INC 255 255 255 -#define INDEX_PAGECONTROL_FONT_SIZE_INC 18 - -collections { - base_scale: 1.7; - group { - name: "elm/index/base/vertical/lockscreen/index"; - alias: "elm/index/base/horizontal/lockscreen/index"; - parts { - part { - name: "clip"; - type: RECT; - mouse_events: 0; - description { - state: "default" 0.0; - visible: 0; - color: 255 255 255 0; - } - description { - state: "active" 0.0; - visible: 1; - color: 255 255 255 255; - } - } - part { - name: "elm.swallow.index.0"; - type: SWALLOW; - mouse_events: 0; - clip_to: "clip"; - description { - state: "default" 0.0; - align: 0.5 0.5; - rel1.relative: 0 0; - rel2.relative: 1 1; - } - } - part { - name: "elm.swallow.event.0"; - type: SWALLOW; - mouse_events: 0; - repeat_events: 0; - description { - state: "default" 0.0; - align: 0.5 0.5; - } - } - } - programs { - program { - name: "active"; - signal: "elm,state,active"; - source: "elm"; - action: STATE_SET "active" 0.0; - transition: DECELERATE 0.5; - target: "clip"; - } - program { - name: "inactive"; - signal: "elm,state,inactive"; - source: "elm"; - action: STATE_SET "default" 0.0; - transition: DECELERATE 0.5; - target: "clip"; - } - } - } - - group { - name: "elm/index/item/vertical/lockscreen/index"; - alias: "elm/index/item_odd/vertical/lockscreen/index"; - alias: "elm/index/item/horizontal/lockscreen/index"; - alias: "elm/index/item_odd/horizontal/lockscreen/index"; - images { - image: "page indicator.png" COMP; - image: "page indicator_focus.png" COMP; - } - parts { - part { - name:"bg"; - type: RECT; - scale: 1; - description { - state: "default" 0.0; - min: INDEX_PAGECONTROL_IND_INC; - max: INDEX_PAGECONTROL_IND_INC; - visible: 0; - align: 0.5 0.5; - } - } - part { - name: "indicator1"; - type: IMAGE; - mouse_events: 0; - scale: 1; - description { - state: "default" 0.0; - align: 0.5 0.5; - fixed: 1 1; - rel1.to: "bg"; - rel2.to: "bg"; - min: INDEX_PAGECONTROL_IND_MIN_INC; - max: INDEX_PAGECONTROL_IND_MIN_INC; - image.normal: "page indicator.png"; - } - description { - state: "active" 0.0; - inherit: "default" 0.0; - visible: 0; - } - } - part { - name: "indicator2"; - type: IMAGE; - mouse_events: 0; - scale: 1; - description { - state: "default" 0.0; - align: 0.5 0.5; - fixed: 1 1; - min: INDEX_PAGECONTROL_IND_MIN_INC; - max: INDEX_PAGECONTROL_IND_MIN_INC; - image.normal: "page indicator_focus.png"; - visible: 0; - } - description { - state: "active" 0.0; - inherit: "default" 0.0; - min: INDEX_PAGECONTROL_IND_INC; - max: INDEX_PAGECONTROL_IND_INC; - visible: 1; - } - } - part { - name: "elm.text"; - type: TEXT; - mouse_events: 0; - description { - state: "default" 0.0; - fixed: 1 1; - color: INDEX_PAGECONTROL_FONT_COLOR_INC 0; - align: 0.5 0.5; - text { - font: "TIZEN:style=Bold"; - size: INDEX_PAGECONTROL_FONT_SIZE_INC; - min: 0 1; - //FIXME:values should be 0.5 0.5 when fonts are aligned correctly. - align: 0.53 0.56; - } - rel1 { to: "indicator2"; } - rel2 { to: "indicator2"; } - } - description { - state: "active" 0.0; - inherit: "default" 0.0; - color: INDEX_PAGECONTROL_FONT_COLOR_INC 255; - } - } - } - programs { - program { - name: "active"; - signal: "elm,state,active"; - source: "elm"; - action: STATE_SET "active" 0.0; - target: "indicator1"; - target: "indicator2"; - target: "elm.text"; - transition: LINEAR 0.2; - } - program { - name: "inactive"; - signal: "elm,state,inactive"; - source: "elm"; - action: STATE_SET "default" 0.0; - target: "indicator1"; - target: "indicator2"; - target: "elm.text"; - transition: LINEAR 0.2; - } - } - } -} diff --git a/data/images/ls_noti_ic_call.png b/data/images/ls_noti_ic_call.png deleted file mode 100644 index 40b1b02..0000000 Binary files a/data/images/ls_noti_ic_call.png and /dev/null differ diff --git a/data/images/ls_noti_ic_msg.png b/data/images/ls_noti_ic_msg.png deleted file mode 100644 index 7b8bda6..0000000 Binary files a/data/images/ls_noti_ic_msg.png and /dev/null differ diff --git a/inc/background.h b/inc/background.h new file mode 100644 index 0000000..d5d91b0 --- /dev/null +++ b/inc/background.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016 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 _LOCKSCREEN_BACKGROUND_H_ +#define _LOCKSCREEN_BACKGROUND_H_ + +/** + * @brief Event fired when lockscreen background changes. + * @note register via ecore_event_handler_add + * @note can be triggered after lockscreen_background_init + */ +extern int LOCKSCREEN_EVENT_BACKGROUND_CHANGED; + +/** + * @brief Initializes background notification changes. + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_background_init(void); + +/** + * @brief Sets background file that will be display be lockscreen. + * If @path parameter is NULL the default background will be used. + * + * @note can fire LOCKSCREEN_EVENT_BACKGROUND_CHANGED event + * @return: 0 on success, other value on failure. + */ +int lockscreen_background_file_set(const char *path); + +/** + * @brief Deinitialize background notification changes. + */ +void lockscreen_background_shutdown(void); + +/** + * @brief Get current background file path. + */ +const char *lockscreen_background_file_get(void); + +#endif + diff --git a/inc/battery.h b/inc/battery.h new file mode 100644 index 0000000..5c79054 --- /dev/null +++ b/inc/battery.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016 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 _LOCKSCREEN_BATTERY_H_ +#define _LOCKSCREEN_BATTERY_H_ + +#include + +/** + * @brief Event fired when battery status changes. + * @note register via ecore_event_handler_add + * @note can be triggered after lockscreen_battery_init + */ +extern int LOCKSCREEN_EVENT_BATTERY_CHANGED; + +/** + * @brief Initializes battery notification changes. + * @return: 0 on success, other value on failure. + */ +int lockscreen_battery_init(void); + +/** + * @brief Deinitialize battery notification changes. + */ +void lockscreen_battery_shutdown(void); + +/** + * @brief true is battery is charging. + */ +bool lockscreen_battery_is_charging(void); + +/** + * @brief true is battery charger is connected. + */ +bool lockscreen_battery_is_connected(void); + +/** + * @brief Returns battery level state 0 - 100 + */ +int lockscreen_battery_level_get(void); + +#endif diff --git a/include/battery.h b/inc/battery_ctrl.h similarity index 60% rename from include/battery.h rename to inc/battery_ctrl.h index 80632e4..40dc142 100644 --- a/include/battery.h +++ b/inc/battery_ctrl.h @@ -14,17 +14,24 @@ * limitations under the License. */ -#ifndef __BATTERY_H__ -#define __BATTERY_H__ +#ifndef _LOCKSCREEN_BATTERY_CTRL_H_ +#define _LOCKSCREEN_BATTERY_CTRL_H_ -bool lock_battery_is_charging_get(void); -bool lock_battery_is_connected_get(void); +#include -lock_error_e lock_battery_update(void); -lock_error_e lock_battery_show(void); -lock_error_e lock_battery_hide(void); +/** + * @brief Initializes battery controller. + * + * Battery controller manages battery information + * presentation on @main_view object. + * + * @return: 0 on success, other value on failure. + */ +int lock_battery_ctrl_init(Evas_Object *main_view); -lock_error_e lock_battery_init(void); -void lock_battery_fini(void); +/** + * @brief Deinitializes battery controller. + */ +void lock_battery_ctrl_fini(void); #endif diff --git a/inc/camera.h b/inc/camera.h new file mode 100644 index 0000000..f141615 --- /dev/null +++ b/inc/camera.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016 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 _LOCKSCREEN_CAMERA_H_ +#define _LOCKSCREEN_CAMERA_H_ + +#include + +/** + * @brief Event fired when lockscreen camera shortcut required status + * changes. + * + * @see lockscreen_camera_is_on + */ +extern int LOCKSCREEN_EVENT_CAMERA_STATUS_CHANGED; + +/** + * @brief Initializes camera module + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_camera_init(void); + +/** + * @brief Activates system-default camera application. + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_camera_activate(); + +/** + * @brief Shutdowns camera module + */ +void lockscreen_camera_shutdown(void); + +/** + * @brief Returns true if camera shortcut icon should be displayed + * on lockscreen, false otherwise. + */ +bool lockscreen_camera_is_on(void); + +#endif + diff --git a/include/lock_time.h b/inc/camera_ctrl.h similarity index 56% rename from include/lock_time.h rename to inc/camera_ctrl.h index 27b6412..9f66615 100644 --- a/include/lock_time.h +++ b/inc/camera_ctrl.h @@ -14,17 +14,25 @@ * limitations under the License. */ -#ifndef __LOCK_TIME_H__ -#define __LOCK_TIME_H__ +#ifndef _LOCKSCREEN_CAMERA_CTRL_H_ +#define _LOCKSCREEN_CAMERA_CTRL_H_ -lock_error_e lock_time_update(void); -void lock_time_timer_enable_set(int is_enable); +#include -char *lock_time_formatted_noti_time_get(time_t ts); +/** + * @brief Initializes camera controller. + * + * Camera controller module is responsible for displaying camera icon on + * @main_view and launching camera application when requested by user. + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_camera_ctrl_init(Evas_Object *main_view); -void lock_time_resume(void); -void lock_time_pause(void); -void lock_time_init(void); -void lock_time_fini(void); +/** + * @brief Deinitializes camera controller. + */ +void lockscreen_camera_ctrl_fini(void); #endif + diff --git a/inc/camera_view.h b/inc/camera_view.h new file mode 100644 index 0000000..f153041 --- /dev/null +++ b/inc/camera_view.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016 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 _LOCKSCREEN_CAMERA_VIEW_H_ +#define _LOCKSCREEN_CAMERA_VIEW_H_ + +#include + +/** + * @brief Smart signal emitted when camera icon is being selected. + */ +#define SIGNAL_CAMERA_SELECTED "camera,icon,selected" + +/** + * @brief Creates camera view + * + * @note parent should be Elementary widget. + */ +Evas_Object *lockscreen_camera_view_create(Evas_Object *parent); + +#endif diff --git a/inc/display.h b/inc/display.h new file mode 100644 index 0000000..4f03df2 --- /dev/null +++ b/inc/display.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016 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 _LOCKSCREEN_DISPLAY_H_ +#define _LOCKSCREEN_DISPLAY_H_ + +#include + +/** + * @brief Event fired when device display truns off or on. + */ +extern int LOCKSCREEN_EVENT_DISPLAY_STATUS_CHANGED; + +/** + * @brief Initializes display notifications. + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_display_init(void); + +/** + * @brief Deinitialize display notifications. + */ +void lockscreen_display_shutdown(void); + +/** + * @brief + * Freeze auto disabling device screen after predefined number of seconds. + * + * @note if device display in already in "off" state this function has no effect. + */ +void lockscreen_display_timer_freeze(void); + +/** + * @brief + * Resumes auto disabling device screen after predefined number of seconds. + * + * @note if device display in already in "off" state this function has no effect. + * @note if lockscreen_data_model_display_timer_freeze function was not called + * beforehead, this function resets time estimated to turn off display. + */ +void lockscreen_display_timer_renew(void); + +/** + * @brief Gets current display status. + * Returns true if display is turned on, false otherwise. + */ +bool lockscreen_display_is_off(void); + +#endif diff --git a/inc/events.h b/inc/events.h new file mode 100644 index 0000000..71f459a --- /dev/null +++ b/inc/events.h @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2016 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 _LOCKSCREEN_EVENTS_H_ +#define _LOCKSCREEN_EVENTS_H_ + +#include +#include + +typedef enum { + LOCKSCREEN_EVENT_TYPE_NOTIFICATION = (1 << 0), + LOCKSCREEN_EVENT_TYPE_MINICONTROLLER = (1 << 1) +} lockscreen_event_type_e; + +/** + * @brief Event fired when lockscreen's events change. + */ +extern int LOCKSCREEN_EVENT_EVENTS_CHANGED; + +/** + * @brief lockscreen event handle + */ +typedef struct lockscreen_event lockscreen_event_t; + +/** + * @brief Initialize event support + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_events_init(void); + +/** + * @brief Denitialize event support. + */ +void lockscreen_events_shutdown(void); + +/** + * @brief Gets main event icon + */ +const char *lockscreen_event_icon_get(const lockscreen_event_t *event); + +/** + * @brief Get secondary event icon + */ +const char *lockscreen_event_sub_icon_get(const lockscreen_event_t *event); + +/** + * @brief Get event title + */ +const char *lockscreen_event_title_get(const lockscreen_event_t *event); + +/** + * @brief Get event textual content. + */ +const char *lockscreen_event_content_get(const lockscreen_event_t *event); + +/** + * @brief Gets time when event was posted. + */ +time_t lockscreen_event_time_get(const lockscreen_event_t *event); + +/** + * @brief Result of launch true if launch has successed, false otherwise + */ +typedef void (*Launch_Result_Cb)(bool result); + +/** + * @brief Launch application which posted the event + */ +bool lockscreen_event_launch(lockscreen_event_t *event, Launch_Result_Cb cb); + +/** + * @brief Get event type. + */ +lockscreen_event_type_e lockscreen_event_type_get(const lockscreen_event_t *event); + +/** + * @brief Gets list of all displayed events. + * + * @note list elements are only until LOCKSCREEN_EVENT_NOTIFICATIONS_CHANGED is fired. + * @note should be free with eina_list_free + */ +Eina_List *lockscreen_events_get(void); + +/** + * @brief Inticates if any events for lockscreen are currently posted. + */ +bool lockscreen_events_exists(void); + +/** + * @brief Creates minicontroller for given event. + */ +Evas_Object *lockscreen_event_minicontroller_create(lockscreen_event_t *event, Evas_Object *parent); + +/** + * @brief Clears event + */ +void lockscreen_event_remove(lockscreen_event_t *event); + +/** + * @brief Clears all events + */ +void lockscreen_events_remove_all(void); + +#endif diff --git a/include/default_lock.h b/inc/events_ctrl.h similarity index 52% rename from include/default_lock.h rename to inc/events_ctrl.h index 8a71e6f..fdcb4aa 100644 --- a/include/default_lock.h +++ b/inc/events_ctrl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2016 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. @@ -14,21 +14,24 @@ * limitations under the License. */ -#ifndef __DEFAULT_LOCK_H__ -#define __DEFAULT_LOCK_H__ +#ifndef _LOCKSCREEN_EVENTS_CTRL_H_ +#define _LOCKSCREEN_EVENTS_CTRL_H_ -typedef enum { - LOCK_EXIT_STATE_NORMAL = 0, - LOCK_EXIT_STATE_EXIT = 1, - LOCK_EXIT_STATE_CAMERA = 2, - LOCK_EXIT_STATE_MAX, -} lock_exit_state_e; +#include -Evas_Object *lock_default_conformant_get(void); -Evas_Object *lock_default_lock_layout_get(void); -Evas_Object *lock_default_swipe_layout_get(void); +/** + * @brief Initialize events controller. + * + * Events controller module is responsible for displaying notification and + * minicontrollers on @main_view + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_events_ctrl_init(Evas_Object *main_view); -lock_error_e lock_default_lock_init(void); -void lock_default_lock_fini(void); +/** + * @brief Deinitialize events controller. + */ +void lockscreen_events_ctrl_shutdown(); #endif diff --git a/inc/events_view.h b/inc/events_view.h new file mode 100644 index 0000000..6c37c4d --- /dev/null +++ b/inc/events_view.h @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016 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 _LOCKSCREEN_EVENTS_VIEW_H_ +#define _LOCKSCREEN_EVENTS_VIEW_H_ + +#include + +#define NOTI_ITEM_STYLE "noti" +#define NOTI_ITEM_TEXT "elm.text" +#define NOTI_ITEM_TEXT_SUB "elm.text.sub" +#define NOTI_ITEM_TEXT_TIME "elm.text.time" +#define NOTI_ITEM_ICON "elm.swallow.icon" +#define NOTI_ITEM_ICON_SUB "elm.swallow.sub.icon" + +#define WIDGET_ITEM_STYLE "one_icon" +#define WIDGET_ITEM_CONTENT "elm.swallow.icon" + +/** + * @brief Smart signal emitted when close button is clicked. + */ +#define SIGNAL_CLOSE_BUTTON_CLICKED "btn,close,clicked" + +/** + * @brief Creates camera view object. + * @note parent should be elementary widget. + */ +Evas_Object *lockscreen_events_view_create(Evas_Object *parent); + +/** + * @brief Gets internall genlist object + * @note should not be del manually + */ +Evas_Object *lockscreen_events_genlist_get(Evas_Object *events_view); + +#endif + diff --git a/include/sim_state.h b/inc/lockscreen.h similarity index 67% rename from include/sim_state.h rename to inc/lockscreen.h index 217e948..dc69654 100644 --- a/include/sim_state.h +++ b/inc/lockscreen.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2016 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. @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef __SIM_STATE_H__ -#define __SIM_STATE_H__ +#ifndef _LOCKSCREEN_H_ +#define _LOCKSCREEN_H_ -lock_error_e lock_sim_state_init(void); -void lock_sim_state_resume(void); -void lock_sim_state_deinit(void); -void lock_sim_state_language_change(void); +#define EDJE_DIR "edje/" +#define IMAGE_DIR "images/" + +#define LOCK_EDJE_FILE EDJE_DIR"lockscreen.edj" #endif diff --git a/inc/log.h b/inc/log.h new file mode 100644 index 0000000..614eb6d --- /dev/null +++ b/inc/log.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2009-2014 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 __LOG_H__ +#define __LOG_H__ + +#include +#include + +#ifdef LOG_TAG + #undef LOG_TAG +#endif + +#define LOG_TAG "LOCKSCREEN" + +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) + +#if !defined(DBG) +#define DBG(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, "%s: %s[%d]\t " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg) +#endif + +#if !defined(WRN) +#define WRN(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, "%s: %s[%d]\t " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg) +#endif + +#if !defined(ERR) +#define ERR(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, "%s: %s[%d]\t " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg) +#endif + +#if !defined(INF) +#define INF(fmt, arg...) dlog_print(DLOG_INFO, LOG_TAG, "%s: %s[%d]\t " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg) +#endif + +#if !defined(FATAL) +#define FAT(fmt, arg...) dlog_print(DLOG_FATAL, LOG_TAG, "%s: %s[%d]\t " #fmt "\n", __FILENAME__, __func__, __LINE__, ##arg); +#endif + +#undef _ +#define _(str) i18n_get_text(str) + +#endif diff --git a/include/page_indicator.h b/inc/main_ctrl.h similarity index 56% rename from include/page_indicator.h rename to inc/main_ctrl.h index cea14cc..217aeaf 100644 --- a/include/page_indicator.h +++ b/inc/main_ctrl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2016 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. @@ -14,15 +14,22 @@ * limitations under the License. */ -#ifndef __PAGE_INDICATOR_H__ -#define __PAGE_INDICATOR_H__ +#ifndef _LOCKSCREEN_MAIN_CTRL_H_ +#define _LOCKSCREEN_MAIN_CTRL_H_ -Evas_Object *lock_page_indicator_index_get(void); - -void lock_page_indicator_bring_in_page(int current_page); -void lock_page_indicator_update(void); +/** + * @brief Initializes main controller. + * + * Application's root controller. Manages all other controllers. + * Creates main_view. + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_main_ctrl_init(); -Evas_Object *lock_page_indicator_create(void); -void lock_page_indicator_del(void); +/** + * @brief Shutdown main controller. + */ +void lockscreen_main_ctrl_shutdown(); #endif diff --git a/inc/main_view.h b/inc/main_view.h new file mode 100644 index 0000000..9286fcf --- /dev/null +++ b/inc/main_view.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2016 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 _LOCKSCREEN_MAIN_VIEW_H_ +#define _LOCKSCREEN_MAIN_VIEW_H_ + +#include +#include + +typedef enum { + LOCKSCREEN_BACKGROUND_TYPE_DEFAULT, + LOCKSCREEN_BACKGROUND_TYPE_ALBUM_ART, +} lockscreen_main_view_background_type; + +/** + * @brief Smart signal emitted when swipe gesture gesture has been performed. + */ +#define SIGNAL_SWIPE_GESTURE_FINISHED "swipe,gesture,finished" + +/** + * @brief Smart signal emitted unlock animation finished. + */ +#define SIGNAL_UNLOCK_ANIMATION_FINISHED "unlock,anim,finished" + +/** + * @brief Accessible via lockscreen_main_view_part_content_get/set/unset + */ +#define PART_CAMERA "sw.camera" + +/** + * @brief Accessible via lockscreen_main_view_part_content_get/set/unset + */ +#define PART_EVENTS "sw.contextual_event" + +/** + * @brief Creates main view object + */ +Evas_Object *lockscreen_main_view_create(Evas_Object *parent); + +/** + * @brief Set sub view of main view object + */ +void lockscreen_main_view_part_content_set(Evas_Object *view, const char *part, Evas_Object *content); + +/** + * @brief Get sub view of main view object + */ +Evas_Object *lockscreen_main_view_part_content_get(Evas_Object *view, const char *part); + +/** + * @brief Unsets sub view of main view object + */ +Evas_Object *lockscreen_main_view_part_content_unset(Evas_Object *view, const char *part); + +/** + * @brief Set main view background image + */ +bool lockscreen_main_view_background_set(Evas_Object *view, lockscreen_main_view_background_type type, const char *file); + +/** + * @brief Sets battery status displayed text + */ +void lockscreen_main_view_battery_status_text_set(Evas_Object *view, const char *battery); + +/** + * @brief Plays unlock animation and runs @animation_end_cb on end. + * @note animation_end_cb will be called only once. + */ +void lockscreen_main_view_unlock(Evas_Object *obj); + +/** + * @brief Sets main view time information + * + * @note time information will be displayed in format suitable for given locale, + * timezone and 24h format option. + */ +void lockscreen_main_view_time_set(Evas_Object *view, const char *locale, const char *timezone, bool use24hformat, time_t time); + +/** + * @brief Sets sim status textual information. + */ +void lockscreen_main_view_sim_status_text_set(Evas_Object *view, const char *text); + +#endif diff --git a/inc/minicontrollers.h b/inc/minicontrollers.h new file mode 100644 index 0000000..7920a74 --- /dev/null +++ b/inc/minicontrollers.h @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016 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 _LOCKSCREEN_MINICONTROLLERS_H_ +#define _LOCKSCREEN_MINICONTROLLERS_H_ + +#include + +/** + * @brief Event fired when minicontroller changes. + */ +extern int LOCKSCREEN_EVENT_MINICONTROLLERS_CHANGED; + +/** + * @brief Initialize minicontroller support + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_minicontrollers_init(void); + +/** + * @brief Deinitialize minicontroller support. + */ +void lockscreen_minicontrollers_shutdown(void); + +/** + * @brief Creates minicontroller for name and parent + */ +Evas_Object *lockscreen_minicontrollers_minicontroller_create(const char *name, Evas_Object *parent); + +/** + * @brief Gets all minicontroller names targeted for lockscreen + * + * @note list should be free with eina_list_free + * @note data contains const char * + * @note list data should not be free + */ +Eina_List *lockscreen_minicontrollers_list_get(void); + +/** + * @brief Stops minicontroller of given name. + */ +bool lockscreen_minicontrollers_minicontroller_stop(const char *name); + +#endif + diff --git a/inc/sim.h b/inc/sim.h new file mode 100644 index 0000000..f042055 --- /dev/null +++ b/inc/sim.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016 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 _LOCKSCREEN_SIM_H_ +#define _LOCKSCREEN_SIM_H_ + +/** + * @brief Event fired when sim information changes + */ +extern int LOCKSCREEN_EVENT_SIM_STATUS_CHANGED; + +/** + * @brief Initializes sim information changes + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_sim_init(); + +typedef enum { + LOCKSCREEN_PRIMARY_SIM = 0, + LOCKSCREEN_SECONDARY_SIM, + LOCKSCREEN_SIM_MAX, +} lockscreen_sim_num_e; + +/** + * @brief Shutdowns sim information changes. + */ +void lockscreen_sim_shutdown(void); + +/** + * @brief Get current PLMN information for given sim + */ +const char *lockscreen_sim_get_plmn(lockscreen_sim_num_e num); + +#endif diff --git a/include/background_view.h b/inc/sim_ctrl.h similarity index 53% rename from include/background_view.h rename to inc/sim_ctrl.h index fe68ba6..75c3321 100644 --- a/include/background_view.h +++ b/inc/sim_ctrl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2016 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. @@ -14,19 +14,24 @@ * limitations under the License. */ -#ifndef __BACKGROUND_VIEW_H__ -#define __BACKGROUND_VIEW_H__ +#ifndef _LOCKSCREEN_SIM_CTRL_H_ +#define _LOCKSCREEN_SIM_CTRL_H_ -typedef enum { - LOCK_BG_DEFAULT = 0, - LOCK_BG_ALBUM_ART = 1, - LOCK_BG_MAX, -} lock_bg_type_e; +#include -Evas_Object *lock_background_view_bg_get(void); +/** + * @brief Intializes sim controller + * + * Sim controller is resposible for updating main_view information when sim PLMN + * information changes. + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_sim_ctrl_init(Evas_Object *main_view); -lock_error_e lock_background_view_image_set(lock_bg_type_e type, char *file); -Evas_Object *lock_background_view_bg_create(Evas_Object *win); -void lock_background_view_bg_del(void); +/** + * @brief Shutdonws sim controller + */ +void lockscreen_sim_ctrl_shutdown(); #endif diff --git a/inc/time_format.h b/inc/time_format.h new file mode 100644 index 0000000..5a2c685 --- /dev/null +++ b/inc/time_format.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016 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 _LOCKSCREEN_TIME_FORMAT_H_ +#define _LOCKSCREEN_TIME_FORMAT_H_ + +#include + +/** + * @brief Event fired when locale/timezone/24h fromat information changes + */ +extern int LOCKSCREEN_EVENT_TIME_FORMAT_CHANGED; + +/** + * @brief Initializes time format information events. + */ +int lockscreen_time_format_init(void); + +/** + * @brief Shutdowns time format information + */ +void lockscreen_time_format_shutdown(void); + +/** + * @brief Get system default locale + */ +const char *lockscreen_time_format_locale_get(void); + +/** + * @brief Get system default timezone + */ +const char *lockscreen_time_format_timezone_get(void); + +/** + * @brief Get 24-h format option + * @note return true is system is using 24-h time date format, false otherwise. + */ +bool lockscreen_time_format_use_24h(void); + +#endif diff --git a/include/camera.h b/inc/time_format_ctrl.h similarity index 50% rename from include/camera.h rename to inc/time_format_ctrl.h index 085d454..0da08fd 100644 --- a/include/camera.h +++ b/inc/time_format_ctrl.h @@ -14,24 +14,31 @@ * limitations under the License. */ -#ifndef __CAMERA_H__ -#define __CAMERA_H__ +#ifndef _LOCKSCREEN_TIME_FORMAT_CTRL_H_ +#define _LOCKSCREEN_TIME_FORMAT_CTRL_H_ -#define APP_NAME_CAMERA "org.tizen.camera-app" +#include -typedef enum { - CAMERA_VIEW_DRAGGING_START = 1, - CAMERA_VIEW_DRAGGING_STOP = 2, - CAMERA_VIEW_ROTATE = 3, - CAMERA_VIEW_MAX, -} camera_view_type_e; +/** + * @brief Initializes time format controller + * + * time format controller manages time updates na @main_view object + * and apply proper time formating when system default settings changes. + * + * @return: 0 on success, other value on failure. + */ +int lockscreen_time_format_ctrl_init(Evas_Object *main_view); -Evas_Object *lock_camera_layout_get(void); +/** + * @brief Shutdowns time format controller. + */ +void lockscreen_time_format_ctrl_shutdown(void); -lock_error_e lock_camera_above_win_state_send(Eina_Bool state); -void lock_camera_app_launch(void); -lock_error_e lock_camera_view_action(camera_view_type_e action, int angle); -Evas_Object *lock_camera_layout_create(Evas_Object *parent); -void lock_camera_layout_destroy(void); +/** + * @brief Forces controller to refrest time information on view + */ +void lockscreen_time_format_ctrl_time_update(void); #endif + + diff --git a/inc/util.h b/inc/util.h new file mode 100644 index 0000000..3b4dc2e --- /dev/null +++ b/inc/util.h @@ -0,0 +1,77 @@ +/* * Copyright 2016 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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 _LOCKSCREEN_UTIL_H_ +#define _LOCKSCREEN_UTIL_H_ + +#include + +/* + * @brief Application sub-directories type. + */ +enum app_subdir { + APP_DIR_DATA, + APP_DIR_CACHE, + APP_DIR_RESOURCE, + APP_DIR_SHARED_DATA, + APP_DIR_SHARED_RESOURCE, + APP_DIR_SHARED_TRUSTED, + APP_DIR_EXTERNAL_DATA, + APP_DIR_EXTERNAL_CACHE, + APP_DIR_EXTERNAL_SHARED_DATA, +}; + +/** + * @brief Returns absolute path to resource file located in applications directory. + * + * @param subdir type of subdirectory + * @param relative path of resource from starting from "data" dir. + * eg. for DATA_DIR subdir and relative "database.db" => "/home/owner/apps/org.tizen.lockscreen/data/database.db" + * @return absolute path string. + */ +const char *util_get_file_path(enum app_subdir dir, const char *relative); + +/** + * @brief Convinience macros + */ +/** + * @brief Convinience macros + */ +#define util_get_data_file_path(x) util_get_file_path(APP_DIR_DATA, (x)) +#define util_get_cache_file_path(x) util_get_file_path(APP_DIR_CACHE, (x)) +#define util_get_res_file_path(x) util_get_file_path(APP_DIR_RESOURCE, (x)) +#define util_get_shared_data_file_path(x) util_get_file_path(APP_DIR_SHARED_DATA, (x)) +#define util_get_shared_res_file_path(x) util_get_file_path(APP_DIR_SHARED_RESOURCE, (x)) +#define util_get_trusted_file_path(x) util_get_file_path(APP_DIR_SHARED_TRUSTED, (x)) +#define util_get_external_data_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_DATA, (x)) +#define util_get_external_cache_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_CACHE, (x)) +#define util_get_external_shared_data_file_path(x) util_get_file_path(APP_DIR_EXTERNAL_SHARED_DATA, (x)) + +/** + * @brief utility macro to enumerate + */ +#define SIZE(x) sizeof(x)/sizeof(x[0]) + +/** + * @brief Get default lockscreen elementary theme extension. + */ +const Elm_Theme *util_lockscreen_theme_get(void); + +/** + * @brief Plays default tap signal + */ +void util_feedback_tap_play(void); + +#endif /* __HOME_SCREEN_UTIL_H__ */ diff --git a/inc/util_time.h b/inc/util_time.h new file mode 100644 index 0000000..56dd8af --- /dev/null +++ b/inc/util_time.h @@ -0,0 +1,24 @@ +/* + * Copyright 2016 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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 __LOCK_SCREEN_UTIL_TIME_H__ +#define __LOCK_SCREEN_UTIL_TIME_H__ + +bool util_time_formatted_date_get(time_t time, const char *locale, const char *timezone, const char *skeleton, char **str_date); + +bool util_time_formatted_time_get(time_t time, const char *locale, const char *timezone, bool use24hformat, char **str_time, char **str_meridiem); + +#endif diff --git a/include/window.h b/inc/window.h similarity index 57% rename from include/window.h rename to inc/window.h index 60d02c3..1c8a09d 100644 --- a/include/window.h +++ b/inc/window.h @@ -14,14 +14,32 @@ * limitations under the License. */ -#ifndef __WINDOW_H__ -#define __WINDOW_H__ +#ifndef _LOCKSCREEN_WINDOW_H_ +#define _LOCKSCREEN_WINDOW_H_ + +#include + +/** + * @brief Smart signal emitted when users start touching window. + */ +#define SIGNAL_TOUCH_STARTED "win,touch,started" + +/** + * @brief Smart signal emitted when users ended touching window. + */ +#define SIGNAL_TOUCH_ENDED "win,touch,ended" -Evas_Object *lock_window_win_get(void); int lock_window_width_get(void); int lock_window_height_get(void); -Evas_Object *lock_window_create(int type); -void lock_window_destroy(void); +/** + * @brief Creates default lockscreen fullscreen window + */ +Evas_Object *lockscreen_window_create(void); + +/** + * @brief Sets lockscreen content view + */ +void lockscreen_window_content_set(Evas_Object *content); #endif diff --git a/include/contextual_event.h b/include/contextual_event.h deleted file mode 100644 index 3ba0d2a..0000000 --- a/include/contextual_event.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 __CONTEXTUAL_EVENT_H__ -#define __CONTEXTUAL_EVENT_H__ - -#include - -#include "music_player.h" -#include "missed_event.h" - -#define LOCK_CONTEXTUAL_PAGE_TYPE_KEY "__contextual_page_type__" - -typedef enum { - LOCK_CONTEXTUAL_TYPE_NONE = 0, - LOCK_CONTEXTUAL_TYPE_MISSED_EVENT = 1, - LOCK_CONTEXTUAL_TYPE_MUSIC = 2, - LOCK_CONTEXTUAL_TYPE_MAX, -} contextual_type_e; - -Evas_Object *lock_contextual_event_layout_get(void); -Evas_Object *lock_contextual_event_scroller_get(void); -Evas_Object *lock_contextual_event_scroller_box_get(void); -Eina_Bool lock_contextual_event_layout_visible_get(void); - -int lock_contextual_event_page_count_get(void); -int lock_contextual_event_current_page_get(void); -Evas_Object *lock_contextual_event_page_get(contextual_type_e type); -Evas_Object *lock_contextual_event_page_create(Evas_Object *parent, contextual_type_e type); - -lock_error_e lock_contextual_event_music_add(music_state_e state, const char *name, int width, int height); -void lock_contextual_event_music_del(void); - -Evas_Object *lock_contextual_event_missed_event_item_find(missed_event_type_e type); -lock_error_e lock_contextual_event_missed_event_item_add(Evas_Object *item, missed_event_type_e type); -void lock_contextual_event_missed_event_item_del(missed_event_type_e type); -void lock_contextual_event_missed_event_del(void); - -Evas_Object *lock_contextual_event_layout_create(Evas_Object *parent); -lock_error_e lock_contextual_event_layout_del(void); - -#endif diff --git a/include/dbus.h b/include/dbus.h deleted file mode 100644 index 8ee4631..0000000 --- a/include/dbus.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 __DBUS_H__ -#define __DBUS_H__ - -typedef enum { - DBUS_EVENT_LCD_ON = 0, - DBUS_EVENT_LCD_OFF, - DBUS_EVENT_ANGLE_CHANGED, - DBUS_EVENT_MAX, -} dbus_event_type_e; - -/* DBUS interfaces and signals */ -#define DBUS_COORD_INTEFACE "org.tizen.system.coord" -#define DBUS_ROTATION_PATH "/Org/Tizen/System/Coord/Rotation" -#define DBUS_ROTATION_INTERFACE DBUS_COORD_INTEFACE".rotation" -#define DBUS_ROTATION_MEMBER_CHANGED "Changed" -#define DBUS_ROTATION_METHOD_DEGREE "Degree" - -#define DBUS_LOW_BATTERY_PATH "/Org/Tizen/System/Popup/Lowbat" -#define DBUS_LOW_BATTERY_INTERFACE "org.tizen.system.popup.Lowbat" -#define DBUS_LOW_BATTERY_MEMBER_EXTREME_LEVEL "Extreme" - -#define DBUS_DEVICED_BUS_NAME "org.tizen.system.deviced" -#define DBUS_DEVICED_PATH "/Org/Tizen/System/DeviceD" -#define DBUS_DEVICED_INTERFACE DBUS_DEVICED_BUS_NAME - -/* deviced::display */ -#define DBUS_DEVICED_DISPLAY_PATH DBUS_DEVICED_PATH"/Display" -#define DBUS_DEVICED_DISPLAY_INTERFACE DBUS_DEVICED_INTERFACE".display" -#define DBUS_DEVICED_DISPLAY_MEMBER_LCD_ON "LCDOn" -#define DBUS_DEVICED_DISPLAY_MEMBER_LCD_OFF "LCDOff" -#define DBUS_DEVICED_DISPLAY_MEMBER_LCD_ON_BY_POWERKEY "LCDOnByPowerkey" -#define DBUS_DEVICED_DISPLAY_METHOD_LCD_OFF "PowerKeyLCDOff" -#define DBUS_DEVICED_DISPLAY_METHOD_CHANGE_STATE "changestate" -#define DBUS_DEVICED_DISPLAY_METHOD_CUSTOM_LCD_ON "CustomLCDOn" -#define DBUS_DEVICED_DISPLAY_COMMAND_LCD_ON "lcdon" - -int lock_dbus_register_cb(int type, void (*result_cb)(void *, void *), void *result_data); -void lock_dbus_unregister_cb(int type, void (*result_cb)(void *, void *)); - -void lock_dbus_init(void *data); -void lock_dbus_fini(void *data); - -#endif diff --git a/include/lockscreen.h b/include/lockscreen.h deleted file mode 100755 index dc40d20..0000000 --- a/include/lockscreen.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 __LOCKSCREEN_H__ -#define __LOCKSCREEN_H__ - -#include -#include -#include - -#define EDJE_DIR "/usr/apps/org.tizen.lockscreen/res/edje/" -#define IMAGE_DIR "/usr/apps/org.tizen.lockscreen/res/images/" - -#define LOCK_EDJE_FILE EDJE_DIR"lockscreen.edj" - -#define LOCK_DEFAULT_BG_PATH "/usr/apps/org.tizen.lockscreen/res/images/Default.jpg" - -#define _EDJ(x) elm_layout_edje_get(x) -#define _X(x) ELM_SCALE_SIZE(x) - -#define _NOT_LOCALIZED(str) (str) - -#define BUF_SIZE_64 64 -#define BUF_SIZE_512 512 -#define BUF_SIZE_1024 1024 - -typedef enum { - LOCK_TYPE_NONE = 0, - LOCK_TYPE_SWIPE, - LOCK_TYPE_MOTION, - LOCK_TYPE_FINGERPRINT, - LOCK_TYPE_FACE_AND_VOICE, - LOCK_TYPE_SIMPLE_PASSWORD, - LOCK_TYPE_PASSWORD, - LOCK_TYPE_AUTO_LOCK, - LOCK_TYPE_OTHER, - LOCK_TYPE_MAX -} lock_type_e; - -typedef enum { - LOCK_ERROR_OK = 0, - LOCK_ERROR_FAIL = -1, - LOCK_ERROR_INVALID_PARAMETER = -2, - LOCK_ERROR_NO_DATA = -3, - LOCK_ERROR_MAX, -} lock_error_e; - -void lockscreen_exit(void); -int lockscreen_setting_lock_type_get(void); -Ecore_Timer *lockscreen_lcd_off_timer_get(void); - -void lockscreen_lcd_off_timer_set(void); -void lockscreen_lcd_off_timer_reset(void); -void lockscreen_lcd_off_timer_unset(void); -void lockscreen_lcd_off_count_raise(void); -void lockscreen_lcd_off_count_reset(void); - -void lockscreen_feedback_tap_play(void); - - -#endif diff --git a/include/log.h b/include/log.h deleted file mode 100755 index 6dcdfb8..0000000 --- a/include/log.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 __LOG_H__ -#define __LOG_H__ - -#include -#include - -#ifdef LOG_TAG - #undef LOG_TAG -#endif - -#define LOG_TAG "LOCKSCREEN" -#define ENABLE_LOG_SYSTEM - -#ifdef ENABLE_LOG_SYSTEM - #define _E(fmt, arg...) LOGE("[%s:%d:E] "fmt, __func__, __LINE__, ##arg) - #define _D(fmt, arg...) LOGD("[%s:%d:D] "fmt, __func__, __LINE__, ##arg) - #define _W(fmt, arg...) LOGW("[%s:%d:W] "fmt, __func__, __LINE__, ##arg) - #define _I(fmt, arg...) LOGI("[%s:%d:I] "fmt, __func__, __LINE__, ##arg) - #define _SECURE_E(fmt, arg...) SECURE_LOGE("["LOG_TAG"%s:%d:E] : %s "fmt, __FILE__, __LINE__, __func__, ##arg) - #define _SECURE_D(fmt, arg...) SECURE_LOGD("["LOG_TAG"%s:%d:D] : %s "fmt, __FILE__, __LINE__, __func__, ##arg) - #define _SECURE_W(fmt, arg...) SECURE_LOGW("["LOG_TAG"%s:%d:W] : %s "fmt, __FILE__, __LINE__, __func__, ##arg) - #define _SECURE_I(fmt, arg...) SECURE_LOGI("["LOG_TAG"%s:%d:I] : %s "fmt, __FILE__, __LINE__, __func__, ##arg) -#else - #define _E(fmt, arg...) - #define _D(fmt, arg...) - #define _W(fmt, arg...) - #define _I(fmt, arg...) - #define _SECURE_E(fmt, arg...) - #define _SECURE_D(fmt, arg...) - #define _SECURE_W(fmt, arg...) - #define _SECURE_I(fmt, arg...) -#endif - -#undef _ -#define _(str) i18n_get_text(str) - -#define retv_if(expr, val) do { \ - if(expr) { \ - _E("(%s) -> %s() return", #expr, __FUNCTION__); \ - return (val); \ - } \ -} while (0) - -#define retm_if(expr, fmt, arg...) do { \ - if(expr) { \ - _E(fmt, ##arg); \ - _E("(%s) -> %s() return", #expr, __FUNCTION__); \ - return; \ - } \ -} while (0) - -#define ret_if(expr) do { \ - if(expr) { \ - _E("(%s) -> %s() return", #expr, __FUNCTION__); \ - return; \ - } \ -} while (0) - -#define goto_if(expr, val) do { \ - if(expr) { \ - _E("(%s) -> goto", #expr); \ - goto val; \ - } \ -} while (0) - -#define break_if(expr) { \ - if(expr) { \ - _E("(%s) -> break", #expr); \ - break; \ - } \ -} - -#define continue_if(expr) { \ - if(expr) { \ - _E("(%s) -> continue", #expr); \ - continue; \ - } \ -} - -#endif diff --git a/include/missed_event.h b/include/missed_event.h deleted file mode 100644 index 538efd1..0000000 --- a/include/missed_event.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 __MISSED_EVENT_H__ -#define __MISSED_EVENT_H__ - -#define LOCK_CONTEXTUAL_MISSED_EVENT_TYPE_KEY "__missed_event_type__" -#define LOCK_CONTEXTUAL_MISSED_EVENT_IS_SELECTED_KEY "__missed_event_is_selected_type__" -#define LOCK_CONTEXTUAL_MISSED_EVENT_BUNDLE_KEY "__missed_event_bundle__" - -#define APP_NAME_CALL "org.tizen.phone" -#define APP_NAME_CONTACTS "org.tizen.contacts" -#define APP_NAME_MSG "org.tizen.message" - -#define ICON_PATH_MISSED_EVENT_MSG "/usr/apps/org.tizen.quickpanel/shared/res/noti_icons/Contact/noti_contact_default.png" -#define ICON_PATH_MISSED_EVENT_CALL ICON_PATH_MISSED_EVENT_MSG - -typedef enum { - LOCK_MISSED_EVENT_TYPE_NONE = 0, - LOCK_MISSED_EVENT_TYPE_CALL = 1, - LOCK_MISSED_EVENT_TYPE_MSG = 2, - LOCK_MISSED_EVENT_TYPE_MAX, -} missed_event_type_e; - -Evas_Object *lock_missed_event_selected_item_get(void); - -void lock_missed_event_item_launch(void); -void lock_missed_event_item_disabled_set(Eina_Bool disabled); -void lock_missed_event_item_selected_unset(void); -void lock_missed_event_item_destroy(Evas_Object *item); - -lock_error_e lock_missed_event_noti_cb_register(void); -void lock_missed_event_noti_cb_unregister(void); - -#endif diff --git a/include/music_player.h b/include/music_player.h deleted file mode 100644 index 7e95fba..0000000 --- a/include/music_player.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 __MUSIC_PLAYER_H__ -#define __MUSIC_PLAYER_H__ - -#define MUSIC_PLAYER_NAME "[music-minicontrol.LOCKSCREEN]" -#define SOUND_PLAYER_NAME "[sound-minicontrol.LOCKSCREEN]" -#define MUSIC_PLAYER "org.tizen.music-player" -#define SOUND_PLAYER "org.tizen.sound-player" -#define LOCK_MUSIC_PLAYER_MINICONTROL_NAME_KEY "__minicontrol_name__" - -typedef enum { - MUSIC_STATE_NO_MUSIC = 0, - MUSIC_STATE_MUSIC_PLAYER_ON = 1, - MUSIC_STATE_SOUND_PLAYER_ON = 2, - MUSIC_STATE_MAX, -} music_state_e; - -typedef enum { - READ_FILE_ERROR_NONE = 0, - READ_FILE_ERROR_EOF = 1, - READ_FILE_ERROR_ERROR = 2, - READ_FILE_MAX, -} read_file_error_e; - -music_state_e lock_music_player_state_get(void); -Evas_Object *lock_music_player_minicontroller_get(void); - -void lock_music_player_bg_set(Evas_Object *bg, music_state_e music_state); -void lock_music_player_bg_unset(void); -void lock_music_player_minicontroller_hide_event_send(void); -Evas_Object *lock_music_player_minicontroller_create(music_state_e state, Evas_Object *layout, const char *name); -void lock_music_player_minicontroller_destroy(void); - -#endif diff --git a/include/property.h b/include/property.h deleted file mode 100644 index 4dd4ae1..0000000 --- a/include/property.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 __PROPERTY_H__ -#define __PROPERTY_H__ - -#include -#include -#include - -#include - -#include - -typedef enum { - PROPERTY_TYPE_SYSTEM_SETTINGS = 0, - PROPERTY_TYPE_SYSTEM_INFO = 1, - PROPERTY_TYPE_RUNTIME_INFO = 2, - PROPERTY_TYPE_PREFERENCE = 3, - PROPERTY_TYPE_VCONFKEY = 4, - PROPERTY_TYPE_MAX, -} property_type_e; - -bool lock_property_sound_lock_get(void); -bool lock_property_sound_touch_get(void); -bool lock_property_rotation_enabled_get(void); - -lock_error_e lock_property_get_string(property_type_e type, void *key, char **str); -lock_error_e lock_property_get_bool(property_type_e type, void *key, void *val); -lock_error_e lock_property_get_int(property_type_e type, void *key, int *val); - -void lock_property_register(void *data); -void lock_property_unregister(void); - -#endif diff --git a/org.tizen.lockscreen.xml b/org.tizen.lockscreen.xml deleted file mode 100755 index b81d378..0000000 --- a/org.tizen.lockscreen.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - geunsun Lee - lockscreen - - - - - - - - - - - - - - - - - - - - - - - http://tizen.org/privilege/telephony.admin - http://tizen.org/privilege/telephony - http://tizen.org/privilege/window.priority.set - - diff --git a/packaging/org.tizen.lockscreen.spec b/packaging/org.tizen.lockscreen.spec old mode 100755 new mode 100644 index 247214f..d4cfc1f --- a/packaging/org.tizen.lockscreen.spec +++ b/packaging/org.tizen.lockscreen.spec @@ -1,10 +1,6 @@ -%bcond_with wayland - -%define AppInstallPath /usr/apps/org.tizen.lockscreen -%define Exec lockscreen - Name: org.tizen.lockscreen Summary: Lockscreen app +Group: Applications/Core Applications Version: 0.0.1 Release: 1 License: Apache-2.0 @@ -18,46 +14,26 @@ ExcludeArch: %{arm} %ix86 x86_64 ExcludeArch: %{arm} %ix86 x86_64 %endif -BuildRequires: pkgconfig(appcore-efl) -BuildRequires: pkgconfig(ecore) -BuildRequires: pkgconfig(eina) -BuildRequires: pkgconfig(evas) +BuildRequires: cmake +BuildRequires: edje-tools +BuildRequires: gettext-tools +BuildRequires: hash-signer BuildRequires: pkgconfig(bundle) -BuildRequires: pkgconfig(capi-system-sensor) BuildRequires: pkgconfig(capi-system-info) -BuildRequires: pkgconfig(capi-system-runtime-info) -BuildRequires: pkgconfig(capi-system-system-settings) +BuildRequires: pkgconfig(capi-system-runtime-info) BuildRequires: pkgconfig(capi-system-device) +BuildRequires: pkgconfig(capi-system-system-settings) BuildRequires: pkgconfig(capi-appfw-application) -BuildRequires: pkgconfig(capi-appfw-preference) -BuildRequires: pkgconfig(capi-appfw-app-manager) -BuildRequires: pkgconfig(capi-ui-efl-util) -BuildRequires: pkgconfig(deviced) -BuildRequires: pkgconfig(edje) -BuildRequires: pkgconfig(aul) -BuildRequires: pkgconfig(ail) +BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(dbus-1) -BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(notification) BuildRequires: pkgconfig(minicontrol-viewer) -BuildRequires: pkgconfig(minicontrol-monitor) -BuildRequires: pkgconfig(ui-gadget-1) BuildRequires: pkgconfig(feedback) -BuildRequires: pkgconfig(msg-service) -BuildRequires: pkgconfig(tapi) -BuildRequires: pkgconfig(efl-extension) -BuildRequires: pkgconfig(key-manager) -BuildRequires: pkgconfig(accounts-svc) BuildRequires: pkgconfig(tzsh-lockscreen-service) -BuildRequires: cmake -BuildRequires: edje-tools -BuildRequires: gettext-tools -#BuildRequires: model-build-features - -BuildRequires: pkgconfig(ecore-wayland) +BuildRequires: pkgconfig(libtzplatform-config) +BuildRequires: pkgconfig(capi-base-utils-i18n) +BuildRequires: pkgconfig(capi-telephony) %description Lockscreen application for Tizen. @@ -66,6 +42,14 @@ Lockscreen application for Tizen. %setup -q %build + +%define _pkg_dir %{TZ_SYS_RO_APP}/%{name} +%define _pkg_shared_dir %{_pkg_dir}/shared +%define _pkg_data_dir %{_pkg_dir}/data +%define _sys_icons_dir %{_pkg_shared_dir}/res +%define _sys_packages_dir %{TZ_SYS_RO_PACKAGES} +%define _sys_license_dir %{TZ_SYS_SHARE}/license + %if 0%{?tizen_build_binary_release_type_eng} export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE" export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE" @@ -82,32 +66,40 @@ export CXXFLAGS="$CXXFLAGS -DTIZEN_BUILD_EMULATOR" export FFLAGS="$FFLAGS -DTIZEN_BUILD_EMULATOR" %endif -%if %{with wayland} -export WAYLAND_SUPPORT=On -export X11_SUPPORT=Off -%else -export WAYLAND_SUPPORT=Off -export X11_SUPPORT=On -%endif -cmake . -DCMAKE_INSTALL_PREFIX="%{AppInstallPath}" -DCMAKE_TARGET="%{Exec}" -DCMAKE_PACKAGE="%{name}" -DWAYLAND_SUPPORT=${WAYLAND_SUPPORT} -DX11_SUPPORT=${X11_SUPPORT} +cd CMake +cmake . -DINSTALL_PREFIX=%{_pkg_dir} \ + -DSYS_ICONS_DIR=%{_sys_icons_dir} \ + -DSYS_PACKAGES_DIR=%{_sys_packages_dir} make %{?jobs:-j%jobs} +cd - %install -rm -rf %{buildroot} +cd CMake %make_install +cd - + +%define tizen_sign 1 +%define tizen_sign_base %{_pkg_dir} +%define tizen_sign_level public +%define tizen_author_sign 1 +%define tizen_dist_sign 1 +%find_lang lockscreen %post /sbin/ldconfig %postun -p /sbin/ldconfig -%files +%files -f lockscreen.lang %manifest org.tizen.lockscreen.manifest %defattr(-,root,root,-) -%{AppInstallPath}/bin/lockscreen -%{AppInstallPath}/res/images/*.png -%{AppInstallPath}/res/images/*.jpg -%{AppInstallPath}/res/edje/*.edj -%{AppInstallPath}/res/locale/*/LC_MESSAGES/* -/usr/share/packages/org.tizen.lockscreen.xml +%{_pkg_dir}/bin/lockscreen +%{_pkg_dir}/res/images/*.png +%{_pkg_dir}/res/images/*.jpg +%{_pkg_dir}/res/edje/*.edj +%{_pkg_dir}/res/locale/*/LC_MESSAGES/* +%{_sys_packages_dir}/org.tizen.lockscreen.xml +%{_sys_icons_dir}/lockscreen.png +%{_pkg_dir}/author-signature.xml +%{_pkg_dir}/signature1.xml diff --git a/project_def.prop b/project_def.prop new file mode 100644 index 0000000..43c99f7 --- /dev/null +++ b/project_def.prop @@ -0,0 +1,73 @@ + +# Project Name +APPNAME = lockscreen + +# Project Type +type = app + +# Project Profile +profile = mobile-3.0 + +# C Sources +USER_SRCS = src/background.c src/battery.c src/battery_ctrl.c src/camera.c src/camera_ctrl.c src/display.c src/lockscreen.c src/main_ctrl.c src/main_view.c src/minicontrollers.c src/events.c src/sim.c src/sim_ctrl.c src/time_format.c src/time_format_ctrl.c src/util.c src/util_time.c src/window.c + +# EDC Sources +USER_EDCS = + +# PO Sources +USER_POS = res/po/hu.po res/po/ar.po res/po/hi.po res/po/en.po res/po/da.po res/po/sv.po res/po/sk.po res/po/fr.po res/po/fr_CA.po res/po/ja_JP.po res/po/bg.po res/po/nb.po res/po/lt.po res/po/zh_TW.po res/po/uk.po res/po/sr.po res/po/cs.po res/po/ro.po res/po/zh_HK.po res/po/sl.po res/po/ka.po res/po/fi.po res/po/en_PH.po res/po/et.po res/po/zh_CN.po res/po/es_US.po res/po/kk.po res/po/eu.po res/po/el_GR.po res/po/pt_BR.po res/po/lv.po res/po/hy.po res/po/gl.po res/po/ga.po res/po/de.po res/po/it_IT.po res/po/ru_RU.po res/po/tr_TR.po res/po/pt_PT.po res/po/pl.po res/po/hr.po res/po/az.po res/po/en_US.po res/po/uz.po res/po/nl.po res/po/ca.po res/po/ko_KR.po res/po/is.po res/po/es_ES.po res/po/mk.po + +# User Defines +USER_DEFS = +USER_CPP_DEFS = + +# User Undefines +USER_UNDEFS = +USER_CPP_UNDEFS = + +# User Libraries +USER_LIBS = + +# User Objects +USER_OBJS = +USER_OBJS_ABS = + +# User Includes +## C Compiler +USER_INC_DIRS = inc +USER_INC_DIRS_ABS = +USER_INC_FILES = +USER_INC_FILES_ABS = +## C++ Compiler +USER_CPP_INC_DIRS = +USER_CPP_INC_DIRS_ABS = +USER_CPP_INC_FILES = +USER_CPP_INC_FILES_ABS = + +# User Library Path +USER_LIB_DIRS = +USER_LIB_DIRS_ABS = + +# EDC Resource Path +USER_EDCS_IMAGE_DIRS = res/edje/images +USER_EDCS_IMAGE_DIRS_ABS = +USER_EDCS_SOUND_DIRS = edje/sounds +USER_EDCS_SOUND_DIRS_ABS = +USER_EDCS_FONT_DIRS = edje/fonts +USER_EDCS_FONT_DIRS_ABS = + +# EDC Flags +USER_EXT_EDC_KEYS = EDC0 + +USER_EXT_EDC0_EDCS = res/edje/lockscreen.edc res/edje/index.edc +USER_EXT_EDC0_EDCS_IMAGE_DIRS = res/edje/images +USER_EXT_EDC0_EDCS_IMAGE_DIRS_ABS = +USER_EXT_EDC0_EDCS_SOUND_DIRS = edje/sounds +USER_EXT_EDC0_EDCS_SOUND_DIRS_ABS = +USER_EXT_EDC0_EDCS_FONT_DIRS = edje/fonts +USER_EXT_EDC0_EDCS_FONT_DIRS_ABS = + +# Resource Filter +USER_RES_INCLUDE = +USER_RES_EXCLUDE = + diff --git a/res/edje/camera.edc b/res/edje/camera.edc new file mode 100644 index 0000000..dc7b9f4 --- /dev/null +++ b/res/edje/camera.edc @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2009-2014 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. + */ + +group { + name: "camera-layout"; + images { + image: "quick_shot.png" COMP; + image: "quick_shot_press.png" COMP; + image: "lock_circle_line_camera.png" COMP; + image: "lock_circle_line_camera_drag.png" COMP; + } + parts { + part { + name: "camera.circle"; + type: IMAGE; + scale: 1; + description { + state: "default" 0.0; + min: 500 500; + visible: 0; + image.normal: "lock_circle_line_camera.png"; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + } + description { + inherit: "default"; + state: "pressed" 1.0; + visible: 1; + } + } + part { + name: "camera.circle.fill"; + type: IMAGE; + scale: 1; + description { + state: "default" 0.0; + min: 500 500; + visible: 0; + image.normal: "lock_circle_line_camera_drag.png"; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + fixed: 1 1; + } + description { + inherit: "default"; + state: "pressed" 1.0; + visible: 1; + } + } + part { + name: "img.camera"; + type: IMAGE; + scale: 1; + description { + state: "default" 0.0; + max: 124 124; + fixed: 1 1; + align: 1.0 1.0; + rel1 { relative: 0.0 0.0; to: "camera.circle.fill"; } + rel2 { relative: 462/500 462/500; to: "camera.circle.fill"; } + image.normal: "quick_shot.png"; + visible: 1; + } + description { + state: "pressed" 1.0; + inherit: "default" 0.0;; + image.normal: "quick_shot_press.png"; + } + } + } + programs { + program { + signal: "mouse,down,1"; + source: "img.camera"; + action: STATE_SET "pressed" 1.0; + target: "camera.circle.fill"; + target: "camera.circle"; + target: "img.camera"; + } + program { + signal: "mouse,up,1"; + source: "img.camera"; + action: STATE_SET "default" 0.0; + target: "camera.circle.fill"; + target: "camera.circle"; + target: "img.camera"; + } + program { + signal: "mouse,up,1"; + source: "img.camera"; + script { + /* get parts coords */ + new x,y,w,h,ix,iy,iw,ih; + get_geometry(PART:"img.camera", ix, iy, iw, ih); + get_geometry(PART:"camera.circle.fill", x, y, w, h); + + /* calculate elipsis center */ + new xc = x + ix + iw / 2; + new yc = y + iy + ih / 2; + + /* calculate elipsis radious */ + new radx = xc - x; + new rady = yc - y; + + /* get mouse coords */ + new mx, my; + get_mouse(mx, my); + + /* check if mouse is inside elipsis */ + new Float:d = float((mx-xc)*(mx-xc))/float(radx*radx) + float((my-yc)*(my-yc))/float(rady*rady); + + /* Emit signal if mouse inside elipsis */ + if (d <= 1.0) + { + emit("camera,icon,clicked", "camera-layout"); + } + } + } + } +} diff --git a/data/edje/color_classes.edc b/res/edje/color_classes.edc similarity index 78% rename from data/edje/color_classes.edc rename to res/edje/color_classes.edc index 056a332..53090b7 100644 --- a/data/edje/color_classes.edc +++ b/res/edje/color_classes.edc @@ -43,24 +43,4 @@ color_classes { name: "ATO007"; color: 255 255 255 255; } - color_class { - name: "AO001"; - color: 100 100 100 100; - } - color_class { - name: "AO001P"; - color: 50 50 50 200; - } - color_class { - name: "AO002"; - color: 150 150 150 150; - } - color_class { - name: "AO005"; - color: 100 100 100 100; - } - color_class { - name: "AO002L1"; - color: 200 200 200 100; - } } diff --git a/res/edje/contextual_event.edc b/res/edje/contextual_event.edc new file mode 100644 index 0000000..6c988b5 --- /dev/null +++ b/res/edje/contextual_event.edc @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2009-2014 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. + */ + +group { + styles { + style { + name: "close_style"; + base: "font=Tizen:style=Regular color=#FFFFFF font_size=30 wrap=none align=center"; + } + } + images { + image: "event_close_bg.#.png" COMP; + } + name: "contextual-event"; + parts { + part { + name: "bg"; + type: SPACER; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + } + } + part { + name: "rect.event.area.bg"; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 50; + align: 0.0 0.0; + rel1 { relative: 0.0 0.0; } + rel2 { relative: 1.0 1.0; } + } + } + part { + name: "txt.close"; + type: TEXTBLOCK; + repeat_events: 1; + description { + state: "default" 0.0; + align: 1.0 0.0; + rel1 { relative: 1.0 0.0; to_x: "bg"; to_y: "rect.event.area.bg"; offset: -20 6; } + rel2 { relative: 1.0 0.0; to_x: "bg"; to_y: "rect.event.area.bg"; offset: -20 6; } + text { + style: "close_style"; + min: 1 1; + ellipsis: -1; + align: 0.5 0.5; + text: "CLOSE"; + } + } + } + part { + name: "btn.close"; + type: IMAGE; + description { + state: "default" 0.0; + align: 1.0 0.0; + color: 100 100 100 100; + rel1 { to: "txt.close"; offset: -10 0; } + rel2 { to: "txt.close"; offset: 10 0; } + image { + normal: "event_close_bg.#.png"; + } + } + description { + state: "press" 0.0; + inherit: "default" 0.0; + color: 50 50 50 50; + } + } + part { + name: "sw.genlist"; + type: SWALLOW; + description { + state: "default" 0.0; + align: 0.0 0.0; + rel1 { relative: 0.0 1.0; to_x: "bg"; to_y: "btn.close"; offset: 0 6; } + } + } + part { + name: "rect.index"; + type: SPACER; + description { + state: "default" 0.0; + align: 0.0 0.0; + rel1 { relative: 0.0 (CONTEXTUAL_INFO_DATE_HEIGHT+CONTEXTUAL_INFO_EVENT_AREA_HEIGHT)/CONTEXTUAL_INFO_HEIGHT; to: "bg"; } + rel2 { relative: 1.0 (CONTEXTUAL_INFO_DATE_HEIGHT+CONTEXTUAL_INFO_EVENT_AREA_HEIGHT+CONTEXTUAL_INFO_PAGE_INDICATOR_HEIGHT)/CONTEXTUAL_INFO_HEIGHT; to: "bg"; } + } + } + part { + name: "sw.index"; + type: SWALLOW; + description { + state: "default" 0.0; + align: 0.5 0.5; + fixed: 1 1; + rel1 { relative: 0.5 0.5; to: "rect.index"; } + rel2 { relative: 0.5 0.5; to: "rect.index"; } + visible: 1; + } + description { + state: "hide" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + } + programs { + program { + name: "btn,close,press"; + signal: "mouse,down,1"; + source: "btn.close"; + action: STATE_SET "press" 0.0; + target: "btn.close"; + } + program { + name: "btn,close,release"; + signal: "mouse,up,1"; + source: "btn.close"; + action: STATE_SET "default" 0.0; + target: "btn.close"; + } + program { + name: "btn,close,clicked"; + signal: "mouse,clicked,1"; + source: "btn.close"; + action: SIGNAL_EMIT "btn,close,clicked" "contextual-event"; + } + program { + name: "hide,index"; + signal: "hide,index"; + source: "sw.index"; + action: STATE_SET "hide" 0.0; + target: "sw.index"; + } + program { + name: "show,index"; + signal: "show,index"; + source: "sw.index"; + action: STATE_SET "default" 0.0; + target: "sw.index"; + } + } +} diff --git a/data/edje/images/event_close_bg.#.png b/res/edje/images/event_close_bg.#.png similarity index 100% rename from data/edje/images/event_close_bg.#.png rename to res/edje/images/event_close_bg.#.png diff --git a/data/edje/images/event_list_bg.#.png b/res/edje/images/event_list_bg.#.png similarity index 100% rename from data/edje/images/event_list_bg.#.png rename to res/edje/images/event_list_bg.#.png diff --git a/data/edje/images/event_list_divider.#.png b/res/edje/images/event_list_divider.#.png similarity index 100% rename from data/edje/images/event_list_divider.#.png rename to res/edje/images/event_list_divider.#.png diff --git a/res/edje/images/lock_circle_line_camera.png b/res/edje/images/lock_circle_line_camera.png new file mode 100644 index 0000000..ea6de88 Binary files /dev/null and b/res/edje/images/lock_circle_line_camera.png differ diff --git a/res/edje/images/lock_circle_line_camera_drag.png b/res/edje/images/lock_circle_line_camera_drag.png new file mode 100644 index 0000000..0cd9580 Binary files /dev/null and b/res/edje/images/lock_circle_line_camera_drag.png differ diff --git a/data/edje/images/page indicator.png b/res/edje/images/page indicator.png similarity index 100% rename from data/edje/images/page indicator.png rename to res/edje/images/page indicator.png diff --git a/data/edje/images/page indicator_focus.png b/res/edje/images/page indicator_focus.png similarity index 100% rename from data/edje/images/page indicator_focus.png rename to res/edje/images/page indicator_focus.png diff --git a/res/edje/images/quick_shot.png b/res/edje/images/quick_shot.png new file mode 100755 index 0000000..4f3e0c1 Binary files /dev/null and b/res/edje/images/quick_shot.png differ diff --git a/res/edje/images/quick_shot_press.png b/res/edje/images/quick_shot_press.png new file mode 100644 index 0000000..2033942 Binary files /dev/null and b/res/edje/images/quick_shot_press.png differ diff --git a/res/edje/index.edc b/res/edje/index.edc new file mode 100644 index 0000000..baed6f5 --- /dev/null +++ b/res/edje/index.edc @@ -0,0 +1,382 @@ +/* + * Copyright (c) 2009-2014 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. + */ + +#define INDEX_PAGECONTROL_IND_INC 35 35 +#define INDEX_PAGECONTROL_IND_MIN_INC 35 35 +#define INDEX_PAGECONTROL_FONT_COLOR_INC 255 255 255 +#define INDEX_PAGECONTROL_FONT_SIZE_INC 18 + +collections { + base_scale: 2.6; + group { + name: "elm/index/base/vertical/lockscreen/index"; + alias: "elm/index/base/horizontal/lockscreen/index"; + parts { + part { + name: "clip"; + type: RECT; + mouse_events: 0; + description { + state: "default" 0.0; + visible: 0; + color: 255 255 255 0; + } + description { + state: "active" 0.0; + visible: 1; + color: 255 255 255 255; + } + } + part { + name: "elm.swallow.index.0"; + type: SWALLOW; + mouse_events: 0; + clip_to: "clip"; + description { + state: "default" 0.0; + align: 0.5 0.5; + rel1.relative: 0 0; + rel2.relative: 1 1; + } + } + part { + name: "elm.swallow.event.0"; + type: SWALLOW; + mouse_events: 0; + repeat_events: 0; + description { + state: "default" 0.0; + align: 0.5 0.5; + } + } + } + programs { + program { + name: "active"; + signal: "elm,state,active"; + source: "elm"; + action: STATE_SET "active" 0.0; + transition: DECELERATE 0.5; + target: "clip"; + } + program { + name: "inactive"; + signal: "elm,state,inactive"; + source: "elm"; + action: STATE_SET "default" 0.0; + transition: DECELERATE 0.5; + target: "clip"; + } + } + } + + group { + name: "elm/index/item/vertical/lockscreen/index"; + alias: "elm/index/item_odd/vertical/lockscreen/index"; + alias: "elm/index/item/horizontal/lockscreen/index"; + alias: "elm/index/item_odd/horizontal/lockscreen/index"; + images { + image: "page indicator.png" COMP; + image: "page indicator_focus.png" COMP; + } + parts { + part { + name:"bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: INDEX_PAGECONTROL_IND_INC; + max: INDEX_PAGECONTROL_IND_INC; + visible: 0; + align: 0.5 0.5; + } + } + part { + name: "indicator1"; + type: IMAGE; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + fixed: 1 1; + rel1.to: "bg"; + rel2.to: "bg"; + min: INDEX_PAGECONTROL_IND_MIN_INC; + max: INDEX_PAGECONTROL_IND_MIN_INC; + image.normal: "page indicator.png"; + } + description { + state: "active" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + part { + name: "indicator2"; + type: IMAGE; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + align: 0.5 0.5; + fixed: 1 1; + min: INDEX_PAGECONTROL_IND_MIN_INC; + max: INDEX_PAGECONTROL_IND_MIN_INC; + image.normal: "page indicator_focus.png"; + visible: 0; + } + description { + state: "active" 0.0; + inherit: "default" 0.0; + min: INDEX_PAGECONTROL_IND_INC; + max: INDEX_PAGECONTROL_IND_INC; + visible: 1; + } + } + part { + name: "elm.text"; + type: TEXT; + mouse_events: 0; + description { + state: "default" 0.0; + fixed: 1 1; + color: INDEX_PAGECONTROL_FONT_COLOR_INC 0; + align: 0.5 0.5; + text { + font: "TIZEN:style=Bold"; + size: INDEX_PAGECONTROL_FONT_SIZE_INC; + min: 0 1; + //FIXME:values should be 0.5 0.5 when fonts are aligned correctly. + align: 0.53 0.56; + } + rel1 { to: "indicator2"; } + rel2 { to: "indicator2"; } + } + description { + state: "active" 0.0; + inherit: "default" 0.0; + color: INDEX_PAGECONTROL_FONT_COLOR_INC 255; + } + } + } + programs { + program { + name: "active"; + signal: "elm,state,active"; + source: "elm"; + action: STATE_SET "active" 0.0; + target: "indicator1"; + target: "indicator2"; + target: "elm.text"; + transition: LINEAR 0.2; + } + program { + name: "inactive"; + signal: "elm,state,inactive"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "indicator1"; + target: "indicator2"; + target: "elm.text"; + transition: LINEAR 0.2; + } + } + } + /* Elementary theme to overwrite */ + group { name: "elm/genlist/item/noti/default"; + styles { + style { + name: "variable_style"; + base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO009 font_size=24 text_class=ATO009 align=right ellipsis=1.0"; + } + style { + name: "title_style"; + base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO039 font_size=30 text_class=ATO039 ellipsis=1.0"; + } + style { + name: "content_style"; + base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO010 font_size=24 text_class=ATO010 ellipsis=1.0"; + } + style { + name: "time_style"; + base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO010 font_size=24 text_class=ATO010 align=right"; + } + style { + name: "selected_style"; + base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO039 font_size=30 text_class=ATO039 wrap=mixed"; + } + } + data.item: "texts" "elm.text elm.text.sub elm.text.time"; + data.item: "contents" "elm.swallow.icon elm.swallow.sub.icon"; + + parts { + // base spacer for item min height + spacer { "base"; scale; + desc { "default"; + min: 0 130; + } + } + rect { "bg"; scale; + desc { "default"; + visible: 0; + color: 0 0 0 10; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + } + desc { "pressed"; inherit: "default"; + visible: 1; + } + } + spacer { "padding.left"; scale; + desc { state: "default"; + fixed: 1 0; + min: 26 0; + max: 26 -1; + align: 0.0 0.5; + rel1.relative: 0.0 0.0; + rel2.relative: 0.0 1.0; + } + } + spacer { "padding.right"; scale; + desc { state: "default"; + fixed: 1 0; + min: 26 0; + max: 26 -1; + align: 1.0 0.5; + rel1.relative: 1.0 0.0; + rel2.relative: 1.0 1.0; + } + } + spacer { "padding.top"; scale; + desc { state: "default"; + fixed: 0 1; + min: 0 16; + max: -1 16; + align: 0.5 0.0; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 0.0; + } + } + spacer { "padding.bottom"; scale; + desc { state: "default"; + fixed: 0 1; + min: 0 16; + max: -1 16; + align: 0.5 0.0; + rel1.relative: 0.0 1.0; + rel2.relative: 1.0 1.0; + } + } + swallow { "elm.swallow.icon"; scale; + desc { state: "default"; + fixed: 1 0; + align: 0.0 0.5; + min: 98 98; + max: 98 98; + rel1 { to_x: "padding.left"; to_y: "padding.top"; relative: 1.0 1.0; } + rel2 { to_x: "padding.left"; to_y: "padding.bottom"; relative: 1.0 0.0; } + } + } + swallow { "elm.swallow.sub.icon"; scale; + desc { state: "default"; + fixed: 1 0; + align: 0.0 0.0; + min: 45 45; + max: 45 45; + rel1 { to: "elm.swallow.icon"; relative: 60/98 60/98; } + rel2 { to: "elm.swallow.icon"; relative: 104/98 104/98; } + } + } + spacer { "padding.icon.text"; scale; + desc { state: "default"; + fixed: 0 1; + min: 16 0; + max: 16 -1; + align: 0 0.5; + rel1 { relative: 1.0 1.0; to_x: "elm.swallow.icon"; to_y: "padding.top"; } + rel2 { relative: 1.0 1.0; to_x: "elm.swallow.icon"; } + } + } + // sub text line + textblock { "elm.text"; scale; + desc { "default"; + fixed: 1 1; + min: 0 54; + max: -1 54; + align: 0.0 0.0; + rel1 { to_x: "padding.icon.text"; to_y: "padding.top"; relative: 1.0 1.0; } + //rel2 { to_x: "elm.padding.A.D"; to_y: "elm.padding.bottom"; relative: 0.0 0.0; } + text.style: "title_style"; + text.min: 1 1; + text.max: 0 1; + text.ellipsis: -1; + } + } + textblock { "elm.text.sub"; scale; + desc { "default"; + fixed: 1 1; + min: 0 43; + max: -1 43; + align: 0.0 0.0; + rel1 { to: "elm.text"; relative: 0.0 1.0; } + //rel2 { to_x: "elm.padding.A.D"; to_y: "elm.padding.bottom"; relative: 0.0 0.0; } + text.style: "content_style"; + text.min: 1 1; + text.max: 0 1; + text.ellipsis: -1; + } + } + spacer { "padding.text.date"; scale; + desc { state: "default"; + fixed: 0 1; + min: 32 0; + max: 32 -1; + align: 1.0 0.5; + rel1 { relative: 1.0 1.0; to_x: "elm.swallow.icon"; to_y: "padding.top"; } + rel2 { relative: 1.0 1.0; to_x: "elm.swallow.icon"; } + } + } + textblock { "elm.text.time"; scale; + desc { "default"; + fixed: 1 1; + min: 0 54; + max: -1 54; + align: 0.0 0.0; + rel1 { to_x: "padding.text.date"; to_y: "padding.top"; relative: 1.0 1.0; } + rel2 { to_x: "padding.right"; to_y: "padding.top"; relative: 0.0 1.0; } + text.style: "time_style"; + text.min: 1 1; + text.max: 0 1; + text.ellipsis: -1; + } + } + } + program { name: "pressed"; + signal: "elm,state,selected"; + source: "elm"; + action: STATE_SET "pressed" 0.0; + target: "bg"; + } + program { name: "unpressed"; + signal: "elm,state,unselected"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "bg"; + } + } +} diff --git a/data/edje/lockscreen.edc b/res/edje/lockscreen.edc similarity index 60% rename from data/edje/lockscreen.edc rename to res/edje/lockscreen.edc index 41a5453..5af66fa 100755 --- a/data/edje/lockscreen.edc +++ b/res/edje/lockscreen.edc @@ -17,42 +17,35 @@ #define WIN_WIDTH 720 #define WIN_HEIGHT 1280 -#define INDICATOR_HEIGHT 52 +#define INDICATOR_HEIGHT 38 #define SWIPE_LOCK_PADDING_TOP 10 -#define SWIPE_LOCK_PADDING_BOTTOM 38 -#define SWIPE_LOCK_PADDING_LEFT 38 -#define SWIPE_LOCK_PADDING_RIGHT 38 +#define SWIPE_LOCK_PADDING_BOTTOM 32 +#define SWIPE_LOCK_PADDING_LEFT 24 +#define SWIPE_LOCK_PADDING_RIGHT 24 #define SWIPE_LOCK_EFFECT_HEIGHT 130 +#define SWIPE_LOCK_BOUNCE_EFFECT_OFFSET 12 -#define CONTEXTUAL_INFO_PADDING_LEFT 11 -#define CONTEXTUAL_INFO_PADDING_RIGHT CONTEXTUAL_INFO_PADDING_LEFT -#define CONTEXTUAL_INFO_DATE_HEIGHT 69 -#define CONTEXTUAL_INFO_CLOSE_BTN_HEIGHT 47 -#define CONTEXTUAL_INFO_PAGE_HEIGHT (130*2)//MISSED_EVT_ITEM_HEIGHT*2 +#define CONTEXTUAL_INFO_HEIGHT 314 +#define CONTEXTUAL_INFO_DATE_HEIGHT 44 +#define CONTEXTUAL_INFO_CLOSE_BTN_HEIGHT 41 +#define CONTEXTUAL_INFO_PAGE_HEIGHT 181 #define CONTEXTUAL_INFO_PAGE_INDICATOR_HEIGHT 48 -//#define CONTEXTUAL_INFO_EVENT_AREA_HEIGHT (CONTEXTUAL_INFO_DATE_HEIGHT+13+CONTEXTUAL_INFO_CLOSE_BTN_HEIGHT+13+CONTEXTUAL_INFO_PAGE_HEIGHT) -#define CONTEXTUAL_INFO_EVENT_AREA_HEIGHT 402 -//#define CONTEXTUAL_INFO_HEIGHT (CONTEXTUAL_INFO_EVENT_AREA_HEIGHT+10+CONTEXTUAL_INFO_PAGE_INDICATOR_HEIGHT) -#define CONTEXTUAL_INFO_HEIGHT 512 -#define MISSED_EVT_ITEM_WIDTH 698 -#define MISSED_EVT_ITEM_HEIGHT 130 -#define MISSED_EVT_ITEM_PADDING_LEFT 26 -#define MISSED_EVT_ITEM_PADDING_RIGHT MISSED_EVT_ITEM_PADDING_LEFT -#define MISSED_EVT_ITEM_PADDING_TOP 16 -#define MISSED_EVT_ITEM_PADDING_BOTTOM MISSED_EVT_ITEM_PADDING_TOP -#define MISSED_EVT_ITEM_TEXT_TOP_HEIGHT 54 -#define MISSED_EVT_ITEM_TEXT_BOTTOM_HEIGHT 43 +#define CONTEXTUAL_INFO_EVENT_AREA_HEIGHT (CONTEXTUAL_INFO_PAGE_HEIGHT+CONTEXTUAL_INFO_CLOSE_BTN_HEIGHT) -#define MISSED_EVT_SEPARATOR_WIDTH (WIN_WIDTH-CONTEXTUAL_INFO_PADDING_LEFT-CONTEXTUAL_INFO_PADDING_RIGHT) +#define MISSED_EVT_ITEM_HEIGHT 90 +#define MISSED_EVT_ITEM_PADDING_LEFT 15 +#define MISSED_EVT_ITEM_PADDING_RIGHT 15 +#define MISSED_EVT_ITEM_PADDING_TOP 8 +#define MISSED_EVT_ITEM_PADDING_BOTTOM 8 + +#define MISSED_EVT_SEPARATOR_WIDTH (540-20) #define MISSED_EVT_SEPARATOR_HEIGHT 1 -#define MISSED_EVT_ICON_LAYOUT_SIZE 105 -#define MISSED_EVT_ICON_IMG_SIZE 98 -#define MISSED_EVT_ICON_SUB_SIZE 45 +#define MISSED_EVT_ICON_SIZE 55 -#define CAMERA_LAYOUT_SIZE 802 -#define CAMERA_ICON_SIZE 124 +#define CAMERA_LAYOUT_SIZE 280 +#define CAMERA_ICON_SIZE 110 collections { base_scale: 2.6; @@ -76,7 +69,7 @@ collections { } } part { - name: "vi_clipper"; + name: "bg_clipper"; type: RECT; description { state: "default" 0.0; @@ -90,7 +83,7 @@ collections { part { name: "sw.bg"; type: SWALLOW; - clip_to: "vi_clipper"; + clip_to: "bg_clipper"; description { state: "default" 0.0; fixed: 1 1; @@ -99,7 +92,6 @@ collections { part { name: "music_dim"; type: RECT; - clip_to: "vi_clipper"; description { state: "default" 0.0; rel1 { relative: 0.0 0.0; to : "sw.bg";} @@ -133,32 +125,32 @@ collections { } programs { program { - name: "vi_effect"; - signal: "vi_effect"; - source: "vi_clipper"; + name: "bg,hide"; + signal: "bg,hide"; + source: "lockscreen"; action: STATE_SET "effect" 0.0; - target: "vi_clipper"; + target: "bg_clipper"; transition: SIN_FAC 0.5 1.7; } program { - name: "vi_effect_stop"; - signal: "vi_effect_stop"; - source: "vi_clipper"; + name: "bg,show"; + signal: "bg,show"; + source: "lockscreen"; action: STATE_SET "default" 0.0; - target: "vi_clipper"; + target: "bg_clipper"; transition: SIN_FAC 0.5 1.7; } program { name: "music_on"; signal: "music_on"; - source: "bg"; + source: "lockscreen"; action: STATE_SET "music_on" 0.0; target: "music_dim"; } program { name: "music_off"; signal: "music_off"; - source: "bg"; + source: "lockscreen"; action: STATE_SET "default" 0.0; target: "music_dim"; } diff --git a/data/edje/missed_event_item.edc b/res/edje/missed_event_item.edc similarity index 58% rename from data/edje/missed_event_item.edc rename to res/edje/missed_event_item.edc index 2863fda..b48c6b7 100644 --- a/data/edje/missed_event_item.edc +++ b/res/edje/missed_event_item.edc @@ -14,38 +14,44 @@ * limitations under the License. */ +#define ITEM_TITLE_HEIGHT 27 + group { styles { style { + name: "variable_style"; + base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO009 font_size=24 text_class=ATO009 align=right ellipsis=1.0"; + } + style { name: "title_style"; - base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO014 font_size=40 text_class=ATO014 ellipsis=1.0"; + base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO039 font_size=30 text_class=ATO039 ellipsis=1.0"; } style { name: "content_style"; - base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO015 font_size=32 text_class=ATO015 ellipsis=1.0"; + base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO010 font_size=24 text_class=ATO010 ellipsis=1.0"; } style { name: "time_style"; - base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO016 font_size=32 text_class=ATO016 align=right"; - } - style { - name: "variable_style"; - base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO016 font_size=32 text_class=ATO016 align=right ellipsis=1.0"; + base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO010 font_size=24 text_class=ATO010 align=right"; } style { name: "selected_style"; - base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO039 font_size=40 text_class=ATO039 wrap=mixed"; + base: "font=Tizen:style=Regular color=#FFFFFFFF color_class=ATO039 font_size=30 text_class=ATO039 wrap=mixed"; } } + images { + image: "event_list_bg.#.png" COMP; + } name: "missed-event-item"; parts { part { name: "bg"; - type: SPACER; + type: RECT; mouse_events: 1; repeat_events: 1; description { state: "default" 0.0; + color: 0 0 0 0; } } part { @@ -54,20 +60,19 @@ group { description { state: "default" 0.0; align: 0.0 0.0; - rel1 { relative: MISSED_EVT_ITEM_PADDING_LEFT/MISSED_EVT_ITEM_WIDTH MISSED_EVT_ITEM_PADDING_TOP/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } - rel2 { relative: (MISSED_EVT_ITEM_PADDING_LEFT + MISSED_EVT_ICON_LAYOUT_SIZE)/MISSED_EVT_ITEM_WIDTH (MISSED_EVT_ITEM_PADDING_TOP + MISSED_EVT_ICON_LAYOUT_SIZE)/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } + rel1 { relative: 12/WIN_WIDTH 17/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } + rel2 { relative: (12+MISSED_EVT_ICON_SIZE)/WIN_WIDTH (17+MISSED_EVT_ICON_SIZE)/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } } } part { name: "txt.title"; type: TEXTBLOCK; - scale: 1; description { state: "default" 0.0; fixed: 1 1; align: 0.0 0.5; - rel1 { relative: (MISSED_EVT_ITEM_PADDING_LEFT + MISSED_EVT_ICON_LAYOUT_SIZE + 25)/MISSED_EVT_ITEM_WIDTH MISSED_EVT_ITEM_PADDING_TOP/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } - rel2 { relative: 0.0 (MISSED_EVT_ITEM_PADDING_TOP + MISSED_EVT_ITEM_TEXT_TOP_HEIGHT)/MISSED_EVT_ITEM_HEIGHT; to_x: "txt.time"; to_y: "bg"; offset: -32 0; } + rel1 { relative: (12+MISSED_EVT_ICON_SIZE+12)/WIN_WIDTH 8/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } + rel2 { relative: 0.0 (8+41)/MISSED_EVT_ITEM_HEIGHT; to_x: "txt.time"; to_y: "bg"; offset: -14 0; } text { style: "title_style"; min: 0 1; @@ -89,15 +94,14 @@ group { part { name: "txt.content"; type: TEXTBLOCK; - scale: 1; mouse_events: 1; repeat_events: 1; description { state: "default" 0.0; fixed: 1 1; align: 0.0 0.5; - rel1 { relative: (MISSED_EVT_ITEM_PADDING_LEFT + MISSED_EVT_ICON_LAYOUT_SIZE + 25)/MISSED_EVT_ITEM_WIDTH (MISSED_EVT_ITEM_PADDING_TOP + MISSED_EVT_ITEM_TEXT_TOP_HEIGHT)/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } - rel2 { relative: 0.0 (MISSED_EVT_ITEM_PADDING_TOP + MISSED_EVT_ITEM_TEXT_TOP_HEIGHT + MISSED_EVT_ITEM_TEXT_BOTTOM_HEIGHT)/MISSED_EVT_ITEM_HEIGHT; to_x: "txt.time"; to_y: "bg"; offset: -32 0; } + rel1 { relative: (12+MISSED_EVT_ICON_SIZE+12)/WIN_WIDTH (8+41)/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } + rel2 { relative: 0.0 (8+41+33)/MISSED_EVT_ITEM_HEIGHT; to_x: "txt.time"; to_y: "bg"; offset: -14 0; } text { style: "content_style"; text: ""; @@ -119,7 +123,6 @@ group { part { name: "txt.selected.message"; type: TEXTBLOCK; - scale: 1; description { state: "default" 0.0; fixed: 1 1; @@ -142,15 +145,14 @@ group { part { name: "txt.variable"; type: TEXTBLOCK; - scale: 1; mouse_events: 1; repeat_events: 1; description { state: "default" 0.0; fixed: 1 1; align: 1.0 0.0; - rel1 { relative: 0.0 MISSED_EVT_ITEM_PADDING_TOP/MISSED_EVT_ITEM_HEIGHT; to_x: "txt.time"; to_y: "bg"; } - rel2 { relative: 1.0 (MISSED_EVT_ITEM_PADDING_TOP + MISSED_EVT_ITEM_TEXT_TOP_HEIGHT)/MISSED_EVT_ITEM_HEIGHT; to_x: "txt.time"; to_y: "bg"; } + rel1 { relative: 0.0 8/MISSED_EVT_ITEM_HEIGHT; to_x: "txt.time"; to_y: "bg"; } + rel2 { relative: 1.0 (8+41)/MISSED_EVT_ITEM_HEIGHT; to_x: "txt.time"; to_y: "bg"; } text { style: "variable_style"; min: 0 1; @@ -176,15 +178,14 @@ group { part { name: "txt.time"; type: TEXTBLOCK; - scale: 1; mouse_events: 1; repeat_events: 1; description { state: "default" 0.0; fixed: 1 1; align: 1.0 0.0; - rel1 { relative: (MISSED_EVT_ITEM_WIDTH - MISSED_EVT_ITEM_PADDING_RIGHT)/MISSED_EVT_ITEM_WIDTH (MISSED_EVT_ITEM_PADDING_TOP + MISSED_EVT_ITEM_TEXT_TOP_HEIGHT)/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } - rel2 { relative: (MISSED_EVT_ITEM_WIDTH - MISSED_EVT_ITEM_PADDING_RIGHT)/MISSED_EVT_ITEM_WIDTH (MISSED_EVT_ITEM_PADDING_TOP + MISSED_EVT_ITEM_TEXT_TOP_HEIGHT + MISSED_EVT_ITEM_TEXT_BOTTOM_HEIGHT)/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } + rel1 { relative: (WIN_WIDTH-14)/WIN_WIDTH (8+41)/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } + rel2 { relative: (WIN_WIDTH-14)/WIN_WIDTH (8+41+33)/MISSED_EVT_ITEM_HEIGHT; to: "bg"; } text { style: "time_style"; min: 1 1; @@ -267,70 +268,3 @@ group { } } } - -group { - name: "missed-event-item-icon"; - images { - image: "quick_button_icon_bg.png" COMP; - } - parts { - part { - name: "bg"; - type: SPACER; - scale: 1; - description { - state: "default" 0.0; - fixed: 1 1; - min: MISSED_EVT_ICON_LAYOUT_SIZE MISSED_EVT_ICON_LAYOUT_SIZE; - max: MISSED_EVT_ICON_LAYOUT_SIZE MISSED_EVT_ICON_LAYOUT_SIZE; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 1.0 1.0; } - } - } - part { - name: "clipper"; - type: IMAGE; - scale: 1; - precise_is_inside: 1; - description { - state: "default" 0.0; - fixed : 1 1; - align: 0 0; - min: MISSED_EVT_ICON_IMG_SIZE MISSED_EVT_ICON_IMG_SIZE; - max: MISSED_EVT_ICON_IMG_SIZE MISSED_EVT_ICON_IMG_SIZE; - rel1 { relative: 0.0 0.0; } - rel2 { relative: 0.0 0.0; } - image.normal: "quick_button_icon_bg.png"; - } - } - part { - name: "sw.icon"; - type: SWALLOW; - scale: 1; - clip_to: "clipper"; - description { - state: "default" 0.0; - fixed: 1 1; - align: 0.5 0.5; - min: MISSED_EVT_ICON_IMG_SIZE MISSED_EVT_ICON_IMG_SIZE; - max: MISSED_EVT_ICON_IMG_SIZE MISSED_EVT_ICON_IMG_SIZE; - rel1 { to: "clipper"; } - rel2 { to: "clipper"; } - } - } - part { - name: "sw.icon.sub"; - type: SWALLOW; - scale: 1; - description { - state: "default" 0.0; - fixed: 1 1; - align: 1 1; - min: MISSED_EVT_ICON_SUB_SIZE MISSED_EVT_ICON_SUB_SIZE; - max: MISSED_EVT_ICON_SUB_SIZE MISSED_EVT_ICON_SUB_SIZE; - rel1 { relative: 1.0 1.0; } - rel2 { relative: 1.0 1.0; } - } - } - } -} diff --git a/data/edje/swipe_lock.edc b/res/edje/swipe_lock.edc similarity index 60% rename from data/edje/swipe_lock.edc rename to res/edje/swipe_lock.edc index f4cae1d..6c9d77c 100644 --- a/data/edje/swipe_lock.edc +++ b/res/edje/swipe_lock.edc @@ -18,13 +18,17 @@ group { styles { style { name: "time_style_default"; - base: "style=far_shadow,bottom shadow_color=#00000033 font=SNum-3T:style=Light color=#FFFFFF font_size=136 wrap=none text_class=tizen"; - tag: "small_font" "+ font_size=35 font=SNum-3T:style=Light"; + base: "style=far_shadow,bottom shadow_color=#00000033 font=SamsungNeoNum-3T:style=Regular color=#FFFFFF font_size=106 wrap=none"; + tag: "small_font" "+ font_size=40 font=SamsungNeoNum-3T:style=Light"; } style { - name: "date_and_battery_style_default"; - base: "style=far_shadow,bottom shadow_color=#00000033 font=Tizen:style=Regular font_size=35 color=#FFFFFF wrap=none align=left text_class=tizen"; - tag: "small_font" "+ font_size=35"; + name: "date_style_default"; + base: "style=far_shadow,bottom shadow_color=#00000033 font=Tizen:style=Regular font_size=44 color=#FFFFFF wrap=none align=left text_class=ATO003"; + tag: "small_font" "+ font_size=32"; + } + style { + name: "time_style_contextual"; + base: "style=far_shadow,bottom shadow_color=#00000033 font=SamsungNeoNum-3T:style=Regular color=#FFFFFF font_size=34 align=center wrap=none"; } } name: "swipe-lock"; @@ -45,7 +49,7 @@ group { } description { state: "effect" 0.0; - color: 255 255 255 0; + color: 255 255 255 20; } } part { @@ -70,8 +74,8 @@ group { description { state: "effect_start" 0.0; inherit: "default" 0.0; - rel1 { offset: 0 -6; } - rel2 { offset: 0 -6; } + rel1 { relative: 0.0 (INDICATOR_HEIGHT-SWIPE_LOCK_BOUNCE_EFFECT_OFFSET)/WIN_HEIGHT; to: "bg"; } + rel2 { relative: 1.0 (INDICATOR_HEIGHT+SWIPE_LOCK_PADDING_TOP-SWIPE_LOCK_BOUNCE_EFFECT_OFFSET)/WIN_HEIGHT; to: "bg"; } } description { state: "effect" 0.0; @@ -92,8 +96,8 @@ group { description { state: "effect_start" 0.0; inherit: "default" 0.0; - rel1 { offset: 0 6; } - rel2 { offset: 0 6; } + rel1 { relative: 0.0 (WIN_HEIGHT-SWIPE_LOCK_PADDING_BOTTOM+SWIPE_LOCK_BOUNCE_EFFECT_OFFSET)/WIN_HEIGHT; to: "bg"; } + rel2 { relative: 1.0 (WIN_HEIGHT+SWIPE_LOCK_BOUNCE_EFFECT_OFFSET)/WIN_HEIGHT; to: "bg"; } } description { state: "effect" 0.0; @@ -123,33 +127,34 @@ group { } } part { - name: "sw.contextual_event"; - type: SWALLOW; - clip_to: "vi_clipper"; + name: "txt.timedate"; + type: TEXTBLOCK; description { state: "default" 0.0; - align: 0 0; - rel1 { relative: 0.0 INDICATOR_HEIGHT/WIN_HEIGHT; to: "bg"; } - rel2 { relative: 1.0 (INDICATOR_HEIGHT+CONTEXTUAL_INFO_HEIGHT)/WIN_HEIGHT; to: "bg"; } - } - description { - state: "effect_start" 0.0; - inherit: "default" 0.0; - rel1 { offset: 0 -6; } - rel2 { offset: 0 -6; } + align: 0.5 0.5; + visible: 0; + fixed: 0 0; + rel1 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "padding.top"; offset: 0 45; } + rel2 { relative: 0.0 1.0; to_x: "padding.right"; to_y: "padding.top"; } + text { + style: "time_style_contextual"; + align: 0.5 0.5; + min: 1 1; + ellipsis: -1; + text: "12:45 PM Wed, 3 August"; + } } description { - state: "effect" 0.0; inherit: "default" 0.0; - rel1 { offset: 0 -SWIPE_LOCK_EFFECT_HEIGHT; } - rel2 { offset: 0 -SWIPE_LOCK_EFFECT_HEIGHT; } + state: "contextual_event" 0.0; + visible: 1; } } part { name: "txt.time"; type: TEXTBLOCK; - scale: 1; clip_to: "vi_clipper"; + scale: 1; description { state: "default" 0.0; align: 0 0; @@ -164,12 +169,17 @@ group { text: "12:45 PM"; } } + description { + inherit: "default" 0.0; + state: "contextual_event" 0.0; + visible: 0; + } } part { name: "txt.date"; type: TEXTBLOCK; - scale: 1; clip_to: "vi_clipper"; + scale: 1; description { state: "default" 0.0; align: 0 0; @@ -177,46 +187,85 @@ group { rel1 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "txt.time"; offset: 0 -13; } rel2 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "txt.time"; offset: 0 -13; } text { - style: "date_and_battery_style_default"; + style: "date_style_default"; align: 0.5 0.5; min: 1 1; ellipsis: -1; text: "Wed 1 December"; } } + description { + inherit: "default" 0.0; + state: "contextual_event" 0.0; + visible: 0; + } + } + part { + name: "padding.txt.battery"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + min: WIN_WIDTH 62; + max: WIN_WIDTH 62; + fixed: 1 1; + align: 0 0; + rel1 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "txt.date"; } + rel2 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "txt.date"; } + } } part { name: "txt.battery"; - type: TEXTBLOCK; + type: TEXT; scale: 1; clip_to: "vi_clipper"; description { state: "default" 0.0; - align: 0 0; + min: 314 40; + max: 314 40; fixed: 1 1; + align: 0 0; visible: 1; - rel1 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "txt.date"; offset: 0 115; } - rel2 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "txt.date"; offset: 0 115; } + rel1 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "padding.txt.battery"; } + rel2 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "padding.txt.battery"; } text { - style: "date_and_battery_style_default"; align: 0.0 0.5; min: 1 1; ellipsis: -1; text: "Charging: 50%"; + size: 34; } } description { state: "contextual_event" 0.0; inherit: "default" 0.0; align: 0 0; - rel1 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "sw.contextual_event"; offset: 0 17; } - rel2 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "sw.contextual_event"; offset: 0 17; } + rel1 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "sw.contextual_event"; offset: 0 5; } + rel2 { relative: 1.0 1.0; to_x: "padding.left"; to_y: "sw.contextual_event"; offset: 0 5; } } description { - state: "hide" 0.0; + state: "default_hidden" 0.0; inherit: "default" 0.0; visible: 0; } + description { + state: "contextual_event_hidden" 0.0; + inherit: "contextual_event" 0.0; + visible: 0; + } + } + part { + name: "padding.txt.plmn"; + type: SPACER; + description { + state: "default" 0.0; + min: WIN_WIDTH 14; + max: WIN_WIDTH 14; + fixed: 1 1; + align: 0 1; + rel1 { relative: 1.0 0.0; to_x: "padding.left"; to_y: "padding.bottom"; } + rel2 { relative: 1.0 0.0; to_x: "padding.left"; to_y: "padding.bottom"; } + } } part { name: "txt.plmn"; @@ -225,11 +274,13 @@ group { clip_to: "vi_clipper"; description { state: "default" 0.0; + min: 314 40; + max: 314 40; fixed: 1 1; align: 0 1; visible: 1; - rel1 { relative: 1.0 0.0; to_x: "padding.left"; to_y: "padding.bottom"; offset: 0 -41; } - rel2 { relative: 1.0 0.0; to_x: "padding.left"; to_y: "padding.bottom"; offset: 0 -41; } + rel1 { relative: 1.0 0.0; to_x: "padding.left"; to_y: "padding.txt.plmn"; } + rel2 { relative: 1.0 0.0; to_x: "padding.left"; to_y: "padding.txt.plmn"; } } description { state: "hide" 0.0; @@ -238,16 +289,54 @@ group { } } part { + name: "event"; + type: RECT; + repeat_events: 1; + description { + state: "default" 0.0; + color: 0 0 0 0; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 1.0; + } + description { + state: "blocked" 1.0; + inherit : "default"; + } + } + part { + name: "sw.contextual_event"; + type: SWALLOW; + clip_to: "vi_clipper"; + description { + state: "default" 0.0; + align: 0 0; + rel1 { relative: 0.5 1.0; to_x: "padding.left"; to_y: "txt.timedate"; offset: 0 15; } + rel2 { relative: 0.5 (INDICATOR_HEIGHT+CONTEXTUAL_INFO_HEIGHT)/WIN_HEIGHT; to_x: "padding.right"; to_y: "bg"; } + } + description { + state: "effect_start" 0.0; + inherit: "default" 0.0; + rel1 { offset: 0 -6; } + rel2 { offset: 0 -6; } + } + description { + state: "effect" 0.0; + inherit: "default" 0.0; + rel1 { offset: 0 -SWIPE_LOCK_EFFECT_HEIGHT; } + rel2 { offset: 0 -SWIPE_LOCK_EFFECT_HEIGHT; } + } + } + part { name: "sw.camera"; type: SWALLOW; scale: 1; clip_to: "vi_clipper"; description { state: "default" 0.0; - align: 0.5 0.5; + max: 500 500; + align: 1 1; fixed: 1 1; - rel1 { relative: 220/WIN_WIDTH (WIN_HEIGHT-500)/WIN_HEIGHT; to: "bg"; } - rel2 { relative: (220+CAMERA_LAYOUT_SIZE)/WIN_WIDTH (WIN_HEIGHT-500+CAMERA_LAYOUT_SIZE)/WIN_HEIGHT; to: "bg"; } + rel2 { to: "padding.bottom"; }; } } } @@ -277,68 +366,104 @@ group { target: "padding.bottom"; } program { - name: "vi_effect"; - signal: "vi_effect"; - source: "padding.top"; + name: "unlock,anim,start"; + signal: "unlock,anim,start"; + source: "lockscreen"; + action: STATE_SET "blocked" 1.0; + target: "event"; + after: "vi_effect_anim"; + } + program { + name: "vi_effect_anim"; action: STATE_SET "effect" 0.0; target: "padding.top"; target: "sw.contextual_event"; target: "padding.bottom"; target: "vi_clipper"; - transition: SIN_FAC 0.5 1.7; + transition: DECEL 0.5; after: "vi_effect_end"; } program { name: "vi_effect_end"; signal: "vi_effect_end"; source: "vi_clipper"; - action: SIGNAL_EMIT "vi_effect_end" "vi_clipper"; - } - program { - name: "vi_effect_stop"; - signal: "vi_effect_stop"; - source: "padding.top"; - action: STATE_SET "default" 0.0; - target: "padding.top"; - target: "sw.contextual_event"; - target: "padding.bottom"; - target: "vi_clipper"; - transition: BOUNCE 0.6 2.5 3.0; + action: SIGNAL_EMIT "unlock,anim,end" "swipe-layout"; } + /* Handle battery status updates program { name: "hide,txt,battery"; signal: "hide,txt,battery"; - source: "txt.battery"; - action: STATE_SET "hide" 0.0; + source: "lockscreen"; + filter: "txt.battery" "default"; + action: STATE_SET "default_hidden" 0.0; target: "txt.battery"; } program { name: "show,txt,battery"; signal: "show,txt,battery"; - source: "txt.battery"; + source: "lockscreen"; + filter: "txt.battery" "default_hidden"; action: STATE_SET "default" 0.0; target: "txt.battery"; } + /* Handle contextual layout transformation */ program { - name: "show,txt,battery,contextual,event"; - signal: "show,txt,battery,contextual,event"; - source: "txt.battery"; + name: "contextual,events,show"; + signal: "contextual,events,show"; + source: "lockscreen"; action: STATE_SET "contextual_event" 0.0; target: "txt.battery"; + target: "txt.time"; + target: "txt.date"; + target: "txt.timedate"; + } + program { + name: "contextual,events,hide"; + signal: "contextual,events,hide"; + source: "lockscreen"; + action: STATE_SET "default" 0.0; + target: "txt.battery"; + target: "txt.time"; + target: "txt.date"; + target: "txt.timedate"; } program { name: "hide,txt,plmn"; signal: "hide,txt,plmn"; - source: "txt.plmn"; + source: "lockscreen"; action: STATE_SET "hide" 0.0; target: "txt.plmn"; } program { name: "show,txt,plmn"; signal: "show,txt,plmn"; - source: "txt.plmn"; + source: "lockscreen"; action: STATE_SET "default" 0.0; target: "txt.plmn"; } + program { + name: "bounce,start"; + signal: "mouse,down,1"; + source: "event"; + filter: "event" "default"; + action: STATE_SET "effect_start" 0.0; + target: "padding.top"; + target: "sw.contextual_event"; + target: "padding.bottom"; + target: "vi_clipper"; + transition: DECEL 0.2; + } + program { + name: "bounce,end"; + signal: "mouse,up,1"; + source: "event"; + filter: "event" "default"; + action: STATE_SET "default" 0.0; + target: "padding.top"; + target: "sw.contextual_event"; + target: "padding.bottom"; + target: "vi_clipper"; + transition: BOUNCE 0.6 2.5 3.0; + } } } diff --git a/data/images/Default.jpg b/res/images/Default.jpg similarity index 100% rename from data/images/Default.jpg rename to res/images/Default.jpg diff --git a/data/images/Notification_ic_message.png b/res/images/Notification_ic_message.png similarity index 100% rename from data/images/Notification_ic_message.png rename to res/images/Notification_ic_message.png diff --git a/data/images/Notification_ic_missedcall.png b/res/images/Notification_ic_missedcall.png similarity index 100% rename from data/images/Notification_ic_missedcall.png rename to res/images/Notification_ic_missedcall.png diff --git a/po/ar.po b/res/po/ar.po similarity index 100% rename from po/ar.po rename to res/po/ar.po diff --git a/po/az.po b/res/po/az.po similarity index 100% rename from po/az.po rename to res/po/az.po diff --git a/po/bg.po b/res/po/bg.po similarity index 100% rename from po/bg.po rename to res/po/bg.po diff --git a/po/ca.po b/res/po/ca.po similarity index 100% rename from po/ca.po rename to res/po/ca.po diff --git a/po/cs.po b/res/po/cs.po similarity index 100% rename from po/cs.po rename to res/po/cs.po diff --git a/po/da.po b/res/po/da.po similarity index 100% rename from po/da.po rename to res/po/da.po diff --git a/po/de.po b/res/po/de.po similarity index 100% rename from po/de.po rename to res/po/de.po diff --git a/po/el_GR.po b/res/po/el_GR.po similarity index 100% rename from po/el_GR.po rename to res/po/el_GR.po diff --git a/po/en.po b/res/po/en.po similarity index 100% rename from po/en.po rename to res/po/en.po diff --git a/po/en_PH.po b/res/po/en_PH.po similarity index 100% rename from po/en_PH.po rename to res/po/en_PH.po diff --git a/po/en_US.po b/res/po/en_US.po similarity index 100% rename from po/en_US.po rename to res/po/en_US.po diff --git a/po/es_ES.po b/res/po/es_ES.po similarity index 100% rename from po/es_ES.po rename to res/po/es_ES.po diff --git a/po/es_US.po b/res/po/es_US.po similarity index 100% rename from po/es_US.po rename to res/po/es_US.po diff --git a/po/et.po b/res/po/et.po similarity index 100% rename from po/et.po rename to res/po/et.po diff --git a/po/eu.po b/res/po/eu.po similarity index 100% rename from po/eu.po rename to res/po/eu.po diff --git a/po/fi.po b/res/po/fi.po similarity index 100% rename from po/fi.po rename to res/po/fi.po diff --git a/po/fr.po b/res/po/fr.po similarity index 100% rename from po/fr.po rename to res/po/fr.po diff --git a/po/fr_CA.po b/res/po/fr_CA.po similarity index 100% rename from po/fr_CA.po rename to res/po/fr_CA.po diff --git a/po/ga.po b/res/po/ga.po similarity index 100% rename from po/ga.po rename to res/po/ga.po diff --git a/po/gl.po b/res/po/gl.po similarity index 100% rename from po/gl.po rename to res/po/gl.po diff --git a/po/hi.po b/res/po/hi.po similarity index 100% rename from po/hi.po rename to res/po/hi.po diff --git a/po/hr.po b/res/po/hr.po similarity index 100% rename from po/hr.po rename to res/po/hr.po diff --git a/po/hu.po b/res/po/hu.po similarity index 100% rename from po/hu.po rename to res/po/hu.po diff --git a/po/hy.po b/res/po/hy.po similarity index 100% rename from po/hy.po rename to res/po/hy.po diff --git a/po/is.po b/res/po/is.po similarity index 100% rename from po/is.po rename to res/po/is.po diff --git a/po/it_IT.po b/res/po/it_IT.po similarity index 100% rename from po/it_IT.po rename to res/po/it_IT.po diff --git a/po/ja_JP.po b/res/po/ja_JP.po similarity index 100% rename from po/ja_JP.po rename to res/po/ja_JP.po diff --git a/po/ka.po b/res/po/ka.po similarity index 100% rename from po/ka.po rename to res/po/ka.po diff --git a/po/kk.po b/res/po/kk.po similarity index 100% rename from po/kk.po rename to res/po/kk.po diff --git a/po/ko_KR.po b/res/po/ko_KR.po similarity index 100% rename from po/ko_KR.po rename to res/po/ko_KR.po diff --git a/po/lt.po b/res/po/lt.po similarity index 100% rename from po/lt.po rename to res/po/lt.po diff --git a/po/lv.po b/res/po/lv.po similarity index 100% rename from po/lv.po rename to res/po/lv.po diff --git a/po/mk.po b/res/po/mk.po similarity index 100% rename from po/mk.po rename to res/po/mk.po diff --git a/po/nb.po b/res/po/nb.po similarity index 100% rename from po/nb.po rename to res/po/nb.po diff --git a/po/nl.po b/res/po/nl.po similarity index 100% rename from po/nl.po rename to res/po/nl.po diff --git a/po/pl.po b/res/po/pl.po similarity index 100% rename from po/pl.po rename to res/po/pl.po diff --git a/po/pt_BR.po b/res/po/pt_BR.po similarity index 100% rename from po/pt_BR.po rename to res/po/pt_BR.po diff --git a/po/pt_PT.po b/res/po/pt_PT.po similarity index 100% rename from po/pt_PT.po rename to res/po/pt_PT.po diff --git a/po/ro.po b/res/po/ro.po similarity index 100% rename from po/ro.po rename to res/po/ro.po diff --git a/po/ru_RU.po b/res/po/ru_RU.po similarity index 100% rename from po/ru_RU.po rename to res/po/ru_RU.po diff --git a/po/sk.po b/res/po/sk.po similarity index 100% rename from po/sk.po rename to res/po/sk.po diff --git a/po/sl.po b/res/po/sl.po similarity index 100% rename from po/sl.po rename to res/po/sl.po diff --git a/po/sr.po b/res/po/sr.po similarity index 100% rename from po/sr.po rename to res/po/sr.po diff --git a/po/sv.po b/res/po/sv.po similarity index 100% rename from po/sv.po rename to res/po/sv.po diff --git a/po/tr_TR.po b/res/po/tr_TR.po similarity index 100% rename from po/tr_TR.po rename to res/po/tr_TR.po diff --git a/po/uk.po b/res/po/uk.po similarity index 100% rename from po/uk.po rename to res/po/uk.po diff --git a/po/uz.po b/res/po/uz.po similarity index 100% rename from po/uz.po rename to res/po/uz.po diff --git a/po/zh_CN.po b/res/po/zh_CN.po similarity index 100% rename from po/zh_CN.po rename to res/po/zh_CN.po diff --git a/po/zh_HK.po b/res/po/zh_HK.po similarity index 100% rename from po/zh_HK.po rename to res/po/zh_HK.po diff --git a/po/zh_TW.po b/res/po/zh_TW.po similarity index 100% rename from po/zh_TW.po rename to res/po/zh_TW.po diff --git a/shared/res/lockscreen.png b/shared/res/lockscreen.png new file mode 100644 index 0000000..9765b1b Binary files /dev/null and b/shared/res/lockscreen.png differ diff --git a/src/background.c b/src/background.c new file mode 100644 index 0000000..e1a1e0e --- /dev/null +++ b/src/background.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2016 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 "lockscreen.h" +#include "log.h" +#include "background.h" +#include "util.h" + +#include +#include +#include + +#define DEFAULT_BG IMAGE_DIR"Default.jpg" + +static char *background_file; +static int init_count; +int LOCKSCREEN_EVENT_BACKGROUND_CHANGED; + +int lockscreen_background_init(void) +{ + char *bg; + + if (!init_count) { + LOCKSCREEN_EVENT_BACKGROUND_CHANGED = ecore_event_type_new(); + int ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &bg); + if (ret != SYSTEM_SETTINGS_ERROR_NONE) { + ERR("system_settings_set_value_string failed: %s", get_error_message(ret)); + init_count = 0; + return -1; + } + if (lockscreen_background_file_set(bg)) + lockscreen_background_file_set(NULL); + free(bg); + } + init_count++; + return 0; +} + +int lockscreen_background_file_set(const char *path) +{ + if (!path) { + return lockscreen_background_file_set(util_get_res_file_path(DEFAULT_BG)); + } + + if (background_file && !strcmp(background_file, path)) { + return 0; + } + + if (!ecore_file_can_read(path)) { + ERR("Cannot access/read background file: %s", path); + return -1; + } + + free(background_file); + background_file = strdup(path); + + ecore_event_add(LOCKSCREEN_EVENT_BACKGROUND_CHANGED, NULL, NULL, NULL); + return 0; +} + +void lockscreen_background_shutdown(void) +{ + if (init_count) { + init_count--; + free(background_file); + background_file = NULL; + } +} + +const char *lockscreen_background_file_get(void) +{ + return background_file; +} diff --git a/src/background_view.c b/src/background_view.c deleted file mode 100644 index 41ca5a6..0000000 --- a/src/background_view.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 "lockscreen.h" -#include "log.h" -#include "background_view.h" -#include "window.h" -#include "property.h" -#include "default_lock.h" - -#define EDJE_SIGNAL_SOURCE "bg" -#define EDJE_SIGNAL_EMIT_MUSIC_ON "music_on" -#define EDJE_SIGNAL_EMIT_MUSIC_OFF "music_off" - -static struct _s_info { - Evas_Object *bg; -} s_info = { - .bg = NULL, -}; - -Evas_Object *lock_background_view_bg_get(void) -{ - return s_info.bg; -} - -lock_error_e lock_background_view_image_set(lock_bg_type_e type, char *file) -{ - Evas_Object *lock_layout = NULL; - const char *old_filename = NULL; - const char *emission; - - char *lock_bg = NULL; - - retv_if(!s_info.bg, LOCK_ERROR_INVALID_PARAMETER); - - elm_bg_file_get(s_info.bg, &old_filename, NULL); - if (!old_filename) { - old_filename = LOCK_DEFAULT_BG_PATH; - } - _D("old file name : %s", old_filename); - - switch(type) { - case LOCK_BG_DEFAULT: - if (LOCK_ERROR_OK != lock_property_get_string(PROPERTY_TYPE_SYSTEM_SETTINGS, (void *)SYSTEM_SETTINGS_KEY_WALLPAPER_LOCK_SCREEN, &lock_bg)) { - _E("Failed to get lockscreen BG"); - goto ERROR; - } - goto_if(!lock_bg, ERROR); - - _D("lock_bg : %s", lock_bg); - - if (!elm_bg_file_set(s_info.bg, lock_bg, NULL)) { - _E("Failed to set a BG image : %s", lock_bg); - free(lock_bg); - goto ERROR; - } - - emission = EDJE_SIGNAL_EMIT_MUSIC_OFF; - - free(lock_bg); - break; - case LOCK_BG_ALBUM_ART: - if (!file) { - _E("Failed to set a BG image"); - return LOCK_ERROR_INVALID_PARAMETER; - } - - if (!elm_bg_file_set(s_info.bg, file, NULL)) { - _E("Failed to set album art BG : %s", file); - goto ERROR; - } - - emission = EDJE_SIGNAL_EMIT_MUSIC_ON; - break; - default: - _E("Failed to set background image : type error(%d)", type); - goto ERROR; - } - - lock_layout = lock_default_lock_layout_get(); - if (lock_layout) { - elm_layout_signal_emit(lock_layout, emission, EDJE_SIGNAL_SOURCE); - } - - return LOCK_ERROR_OK; - -ERROR: - if (!elm_bg_file_set(s_info.bg, old_filename, NULL)) { - _E("Failed to set old BG file : %s. Retry to set default BG.", old_filename); - if (!elm_bg_file_set(s_info.bg, LOCK_DEFAULT_BG_PATH, NULL)) { - _E("Failed to set default BG : %s.", LOCK_DEFAULT_BG_PATH); - return LOCK_ERROR_FAIL; - } - } - - return LOCK_ERROR_OK; -} - -Evas_Object *lock_background_view_bg_create(Evas_Object *win) -{ - int win_w = lock_window_width_get(); - int win_h = lock_window_height_get(); - _D("win size : %dx%d", win_w, win_h); - - retv_if(!win, NULL); - - Evas_Object *bg = elm_bg_add(win); - retv_if(!bg , NULL); - - elm_bg_option_set(bg, ELM_BG_OPTION_SCALE); - - evas_object_size_hint_min_set(bg, win_w, win_h); - elm_win_resize_object_add(win, bg); - evas_object_show(bg); - - s_info.bg = bg; - - if (LOCK_ERROR_OK != lock_background_view_image_set(LOCK_BG_DEFAULT, NULL)) { - _E("Failed to set a BG image"); - } - - return bg; -} - -void lock_background_view_bg_del(void) -{ - if (s_info.bg) { - evas_object_del(s_info.bg); - s_info.bg = NULL; - } -} diff --git a/src/battery.c b/src/battery.c index 2105d42..21e371a 100644 --- a/src/battery.c +++ b/src/battery.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2016 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. @@ -14,282 +14,125 @@ * limitations under the License. */ -#include -#include - -#include "lockscreen.h" #include "log.h" #include "battery.h" -#include "property.h" -#include "default_lock.h" -static struct _s_info { - bool is_connected; - bool is_charging; -} s_info = { - .is_connected = false, - .is_charging = false, -}; +#include +#include +#include -bool lock_battery_is_charging_get(void) -{ - return s_info.is_charging; -} +#include -bool lock_battery_is_connected_get(void) -{ - return s_info.is_connected; -} +static bool is_connected, is_charging; +static int level, init_count; +int LOCKSCREEN_EVENT_BATTERY_CHANGED; -static char *_replaceString(char *strInput, const char *strTarget, const char *strChange) +int _battery_status_update() { - char* strResult; - char* strTemp; - int i = 0; - int nCount = 0; - int nTargetLength = strlen(strTarget); - - if (nTargetLength < 1) { - _E("there is no target to chnage"); - return NULL; - } + bool model_changed = false; - int nChangeLength = strlen(strChange); + int percent, ret; + bool charging, connected; - if (nChangeLength != nTargetLength) { - for (i = 0; strInput[i] != '\0';) { - if (memcmp(&strInput[i], strTarget, nTargetLength) == 0) { - nCount++; //consider same string exist - i += nTargetLength; - } else { - i++; - } - } - } else { - i = strlen(strInput); + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_CHARGER_CONNECTED, &connected); + if (ret != RUNTIME_INFO_ERROR_NONE) { + ERR("runtime_info_get_value_bool failed: %s", get_error_message(ret)); + return -1; } - - strResult = (char *) malloc(i + 1 + nCount * (nChangeLength - nTargetLength)); - - if (!strResult) { - _E("fail malloc!!"); - return NULL; + if (is_connected != connected) { + is_connected = connected; + model_changed = true; } + ret = device_battery_is_charging(&charging); + if (ret != DEVICE_ERROR_NONE) { + ERR("device_battery_is_charging failed: %s", get_error_message(ret)); + return -1; + } + if (is_charging != charging) { + is_charging = charging; + model_changed = true; + } - strTemp = strResult; - while (*strInput) { - if (memcmp(strInput, strTarget, nTargetLength) == 0) { - memcpy(strTemp, strChange, nChangeLength); - strTemp += nChangeLength; //move changed length - strInput += nTargetLength; // move target length - } else { - *strTemp++ = *strInput++; // original str cpy - } + ret = device_battery_get_percent(&percent); + if (ret != DEVICE_ERROR_NONE) { + ERR("device_battery_get_percent failed: %s", get_error_message(ret)); + return -1; + } + if (level != percent) { + level = percent; + model_changed = true; } - *strTemp = '\0'; + if (model_changed) + ecore_event_add(LOCKSCREEN_EVENT_BATTERY_CHANGED, NULL, NULL, NULL); - return strResult; + return 0; } -lock_error_e lock_battery_update(void) +static void _battery_changed_cb(device_callback_e type, void *value, void *user_data) { - Evas_Object *swipe_layout = NULL; - - bool status = false; - int capacity = 0; - device_battery_level_e battery_level = 0; - bool charger = false; - int ret = 0; - - swipe_layout = lock_default_swipe_layout_get(); - retv_if(!swipe_layout, LOCK_ERROR_FAIL); - - ret = lock_property_get_bool(PROPERTY_TYPE_RUNTIME_INFO, (void *)RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, &status); - if (ret != LOCK_ERROR_OK) { - _E("Failed to get runtime info : RUNTIME_INFO_KEY_BATTERY_IS_CHARGING"); - elm_object_part_text_set(swipe_layout, "txt.battery", ""); - return LOCK_ERROR_FAIL; - } else { - elm_object_signal_emit(swipe_layout, "show,txt,battery", "txt.battery"); - - if (status == true) { - ret = device_battery_get_percent(&capacity); - if (ret != DEVICE_ERROR_NONE) { - _E("Failed to get battery percent(%d)", ret); - } - - ret = device_battery_get_level_status(&battery_level); - if (ret != DEVICE_ERROR_NONE) { - _E("Failed to get battery level status(%d)", ret); - } - - if (capacity == 100) { - _D("Fully charged"); - elm_object_part_text_set(swipe_layout, "txt.battery", _("IDS_SM_POP_FULLY_CHARGED")); - } else { - char buff[64]; - char *newString = NULL; - newString = _replaceString(_("IDS_LCKSCN_BODY_CHARGING_C_PDP"), "%d%", "%d%%"); - - if (newString != NULL) { - snprintf(buff, sizeof(buff), newString , capacity); - free(newString) ; - } else { - snprintf(buff, sizeof(buff), _("IDS_LCKSCN_BODY_CHARGING_C_PDP") , capacity); - } - - elm_object_part_text_set(swipe_layout, "txt.battery", buff); - } - } else { - elm_object_part_text_set(swipe_layout, "txt.battery", ""); - - ret = lock_property_get_bool(PROPERTY_TYPE_RUNTIME_INFO, (void *)RUNTIME_INFO_KEY_CHARGER_CONNECTED , &charger); - if (ret != LOCK_ERROR_OK) { - _E("Failed to get runtime info : RUNTIME_INFO_KEY_CHARGER_CONNECTED"); - } else { - ret = device_battery_get_percent(&capacity); - if (ret != DEVICE_ERROR_NONE) { - _E("Failed to get battery percent(%d)", ret); - } - - ret = device_battery_get_level_status(&battery_level); - if (ret != DEVICE_ERROR_NONE) { - _E("Failed to get battery level status(%d)", ret); - } - - if (capacity == 100 && charger == true) { - elm_object_part_text_set(swipe_layout, "txt.battery", _("IDS_SM_POP_FULLY_CHARGED")); - } else { - elm_object_part_text_set(swipe_layout, "txt.battery", ""); - } - } - } - } - - return LOCK_ERROR_OK; + if (type == DEVICE_CALLBACK_BATTERY_LEVEL || type == DEVICE_CALLBACK_BATTERY_CAPACITY) + _battery_status_update(); } -static void _battery_changed_cb(device_callback_e type, void *value, void *user_data) +static void _battery_charger_changed_cb(runtime_info_key_e key, void *data) { - _D("%s", __func__); - - if (LOCK_ERROR_OK != lock_battery_update()) { - _E("Failed to update battery information"); - } + if (key == RUNTIME_INFO_KEY_CHARGER_CONNECTED) + _battery_status_update(); } -lock_error_e lock_battery_show(void) +int lockscreen_battery_init() { - Evas_Object *swipe_layout = NULL; - - int ret = 0; - - swipe_layout = lock_default_swipe_layout_get(); - retv_if(!swipe_layout, LOCK_ERROR_FAIL); + if (!init_count) { + LOCKSCREEN_EVENT_BATTERY_CHANGED = ecore_event_type_new(); + int ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED, _battery_charger_changed_cb, NULL); + if (ret != RUNTIME_INFO_ERROR_NONE) { + ERR("runtime_info_set_changed_cb failed: %s", get_error_message(ret)); + return -1; + } - elm_object_signal_emit(swipe_layout, "show,txt,battery", "txt.battery"); + ret = device_add_callback(DEVICE_CALLBACK_BATTERY_CAPACITY, _battery_changed_cb, NULL); + if (ret != DEVICE_ERROR_NONE) { + ERR("device_add_callback failed: %s", get_error_message(ret)); + runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED); + return -1; + } - ret = device_add_callback(DEVICE_CALLBACK_BATTERY_CAPACITY, _battery_changed_cb, NULL); - if (ret != DEVICE_ERROR_NONE) { - _E("Failed to add device callback : DEVICE_CALLBACK_BATTERY_CAPACITY(%d)", ret); - } + ret = device_add_callback(DEVICE_CALLBACK_BATTERY_CHARGING, _battery_changed_cb, NULL); + if (ret != DEVICE_ERROR_NONE) { + ERR("device_add_callback failed: %s", get_error_message(ret)); + device_remove_callback(DEVICE_CALLBACK_BATTERY_CAPACITY, _battery_changed_cb); + runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED); + return -1; + } - ret = device_add_callback(DEVICE_CALLBACK_BATTERY_LEVEL, _battery_changed_cb, NULL); - if (ret != DEVICE_ERROR_NONE) { - _E("Failed to add device callback : DEVICE_CALLBACK_BATTERY_LEVEL(%d)", ret); + _battery_status_update(); } - - return LOCK_ERROR_OK; + init_count++; + return 0; } -lock_error_e lock_battery_hide(void) +void lockscreen_battery_shutdown(void) { - Evas_Object *swipe_layout = NULL; - - int ret = 0; - - swipe_layout = lock_default_swipe_layout_get(); - retv_if(!swipe_layout, LOCK_ERROR_FAIL); - - elm_object_signal_emit(swipe_layout, "hide,txt,battery", "txt.battery"); - - ret = device_remove_callback(DEVICE_CALLBACK_BATTERY_CAPACITY, _battery_changed_cb); - if (ret != DEVICE_ERROR_NONE) { - _E("Failed to remove device callback : DEVICE_CALLBCK_BATTERY_CAPACITY(%d)", ret); + if (init_count) { + init_count--; + if (!init_count) + runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED); } - - ret = device_remove_callback(DEVICE_CALLBACK_BATTERY_LEVEL, _battery_changed_cb); - if (ret != DEVICE_ERROR_NONE) { - _E("Failed to remove device callback : DEVICE_CALLBCK_BATTERY_LEVEL(%d)", ret); - } - - return LOCK_ERROR_OK; } -static void _battery_charger_changed_cb(runtime_info_key_e key, void *data) +bool lockscreen_battery_is_charging(void) { - _D("%s", __func__); - - int ret = 0; - bool is_connected = 0; - - ret = lock_property_get_bool(PROPERTY_TYPE_RUNTIME_INFO, (void *)RUNTIME_INFO_KEY_CHARGER_CONNECTED , &is_connected); - if (ret != LOCK_ERROR_OK) { - _E("Failed to get runtime info : RUNTIME_INFO_KEY_CHARGER_CONNECTED"); - } - - _D("charger connected : %d", is_connected); - s_info.is_connected = is_connected; - - if (is_connected) { - _D("show battery information"); - if (LOCK_ERROR_OK != lock_battery_show()) { - _E("Failed to show battery infomation"); - } - - if (LOCK_ERROR_OK != lock_battery_update()) { - _E("Failed to update battery information"); - } - } else { - _D("hide battery inforamtion"); - if (LOCK_ERROR_OK != lock_battery_hide()) { - _E("Failed to hide battery information"); - } - } + return is_charging; } -lock_error_e lock_battery_init(void) +bool lockscreen_battery_is_connected(void) { - int ret = 0; - - ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED, _battery_charger_changed_cb, NULL); - if (ret != RUNTIME_INFO_ERROR_NONE) { - _E("Failed to set changed cb : RUNTIME_INFO_KEY_CHANGER_CONNECTED(%d)", ret); - } - - ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, _battery_charger_changed_cb, NULL); - if (ret != RUNTIME_INFO_ERROR_NONE) { - _E("Failed to set changed cb : RUNTIME_INFO_KEY_BATTERY_IS_CHARGING(%d)", ret); - } - - _battery_charger_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED, NULL); - - return LOCK_ERROR_OK; + return is_connected; } -void lock_battery_fini(void) +int lockscreen_battery_level_get(void) { - int ret = 0; - - ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_CHARGER_CONNECTED); - if (ret != RUNTIME_INFO_ERROR_NONE) { - _E("Failed to set changed cb : RUNTIME_INFO_KEY_CHANGER_CONNECTED(%d)", ret); - } - - ret = runtime_info_unset_changed_cb(RUNTIME_INFO_KEY_BATTERY_IS_CHARGING); - if (ret != RUNTIME_INFO_ERROR_NONE) { - _E("Failed to set changed cb : RUNTIME_INFO_KEY_BATTERY_IS_CHARGING(%d)", ret); - } + return level; } diff --git a/src/battery_ctrl.c b/src/battery_ctrl.c new file mode 100644 index 0000000..2208712 --- /dev/null +++ b/src/battery_ctrl.c @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2009-2014 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 "lockscreen.h" +#include "log.h" +#include "battery_ctrl.h" +#include "battery.h" +#include "main_view.h" + +#include + +static Ecore_Event_Handler *handler; +static Evas_Object *main_view; + + +// FIXME why this is needed? +static char *_replaceString(char *strInput, const char *strTarget, const char *strChange) +{ + char* strResult; char* strTemp; + int i = 0; + int nCount = 0; + int nTargetLength = strlen(strTarget); + + if (nTargetLength < 1) { + ERR("there is no target to chnage"); + return NULL; + } + + int nChangeLength = strlen(strChange); + + if (nChangeLength != nTargetLength) { + for (i = 0; strInput[i] != '\0';) { + if (memcmp(&strInput[i], strTarget, nTargetLength) == 0) { + nCount++; //consider same string exist + i += nTargetLength; + } else { + i++; + } + } + } else { + i = strlen(strInput); + } + + strResult = (char *) malloc(i + 1 + nCount * (nChangeLength - nTargetLength)); + + if (!strResult) { + ERR("fail malloc!!"); + return NULL; + } + + strTemp = strResult; + while (*strInput) { + if (memcmp(strInput, strTarget, nTargetLength) == 0) { + memcpy(strTemp, strChange, nChangeLength); + strTemp += nChangeLength; //move changed length + strInput += nTargetLength; // move target length + } else { + *strTemp++ = *strInput++; // original str cpy + } + } + + *strTemp = '\0'; + + return strResult; +} + +static char *_text_from_percentage(int capacity) +{ + char buff[64]; + char *newString = NULL; + newString = _replaceString(_("IDS_LCKSCN_BODY_CHARGING_C_PDP"), "%d%", "%d%%"); + + if (newString != NULL) { + snprintf(buff, sizeof(buff), newString , capacity); + free(newString) ; + } else { + snprintf(buff, sizeof(buff), _("IDS_LCKSCN_BODY_CHARGING_C_PDP") , capacity); + } + return strdup(buff); +} + +static int _battery_update(void) +{ + if (lockscreen_battery_is_charging()) { + if (lockscreen_battery_level_get() == 100) { + lockscreen_main_view_battery_status_text_set(main_view, _("IDS_SM_POP_FULLY_CHARGED")); + } else { + char *buff = _text_from_percentage(lockscreen_battery_level_get()); + lockscreen_main_view_battery_status_text_set(main_view, buff); + free(buff); + } + } else { + if (lockscreen_battery_level_get() == 100 && lockscreen_battery_is_connected()) { + lockscreen_main_view_battery_status_text_set(main_view, _("IDS_SM_POP_FULLY_CHARGED")); + } else { + lockscreen_main_view_battery_status_text_set(main_view, NULL); + } + } + return 0; +} + +static Eina_Bool _data_battery_update(void *data, int event, void *event_info) +{ + _battery_update(); + return EINA_TRUE; +} + +int lock_battery_ctrl_init(Evas_Object *view) +{ + if (lockscreen_battery_init()) { + FAT("lockscreen_battery_init failed. Battery related information will not be available"); + return 1; + } + handler = ecore_event_handler_add(LOCKSCREEN_EVENT_BATTERY_CHANGED, _data_battery_update, NULL); + if (!handler) + FAT("ecore_event_handler_add failed on LOCKSCREEN_DATA_MODEL_EVENT_BATTERY_CHANGED event"); + main_view = view; + _battery_update(); + return 0; +} + +void lock_battery_ctrl_fini(void) +{ + ecore_event_handler_del(handler); +} diff --git a/src/camera.c b/src/camera.c new file mode 100644 index 0000000..3e99406 --- /dev/null +++ b/src/camera.c @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2016 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 "camera.h" +#include "log.h" + +#include +#include +#define KEY_DISPLAY_OVER_LOCKSCREEN "http://tizen.org/lock/window/above" + +static bool camera_enabled; +static int init_count; + +int LOCKSCREEN_EVENT_CAMERA_STATUS_CHANGED; + +static void _app_control_reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) +{ + switch (result) { + case APP_CONTROL_RESULT_APP_STARTED: + case APP_CONTROL_RESULT_SUCCEEDED: + DBG("Camera application launch succcessed."); + break; + case APP_CONTROL_RESULT_FAILED: + case APP_CONTROL_RESULT_CANCELED: + DBG("Camera application launch failed."); + break; + } +} + +int lockscreen_camera_activate() +{ + app_control_h app_ctr; + + int err = app_control_create(&app_ctr); + if (err != APP_CONTROL_ERROR_NONE) { + ERR("app_control_create failed: %s", get_error_message(err)); + return 1; + } + + err = app_control_set_launch_mode(app_ctr, APP_CONTROL_LAUNCH_MODE_GROUP); + if (err != APP_CONTROL_ERROR_NONE) { + ERR("app_control_set_launch_mode failed: %s", get_error_message(err)); + app_control_destroy(app_ctr); + return 1; + } + + /* Send a hint to camera-app to display itself over lockscreen */ + err = app_control_add_extra_data(app_ctr, KEY_DISPLAY_OVER_LOCKSCREEN, "on"); + if (err != APP_CONTROL_ERROR_NONE) { + ERR("app_control_add_extra_data failed: %s", get_error_message(err)); + app_control_destroy(app_ctr); + return 1; + } + + /* Send a hint to camera-app to display itself in secure mode*/ + err = app_control_add_extra_data(app_ctr, "secure_mode", "true"); + if (err != APP_CONTROL_ERROR_NONE) { + ERR("app_control_add_extra_data failed: %s", get_error_message(err)); + app_control_destroy(app_ctr); + return 1; + } + + err = app_control_set_app_id(app_ctr, "org.tizen.camera-app"); + if (err != APP_CONTROL_ERROR_NONE) { + ERR("app_control_set_app_id failed: %s", get_error_message(err)); + app_control_destroy(app_ctr); + return 1; + } + + err = app_control_send_launch_request(app_ctr, _app_control_reply_cb, NULL); + if (err != APP_CONTROL_ERROR_NONE) { + ERR("app_control_send_launch_request failed: %s", get_error_message(err)); + app_control_destroy(app_ctr); + return 1; + } + + DBG("Launch request send for %s", APP_CONTROL_OPERATION_CREATE_CONTENT); + app_control_destroy(app_ctr); + + return 0; +} + +int lockscreen_camera_init(void) +{ + if (!init_count) { + //FIXME load this from settings + camera_enabled = true; + LOCKSCREEN_EVENT_CAMERA_STATUS_CHANGED = ecore_event_type_new(); + } + + init_count++; + return 0; +} + +void lockscreen_camera_shutdown(void) +{ + if (init_count) { + init_count--; + } +} + +bool lockscreen_camera_is_on(void) +{ + return camera_enabled; +} diff --git a/src/camera_ctrl.c b/src/camera_ctrl.c new file mode 100644 index 0000000..a697808 --- /dev/null +++ b/src/camera_ctrl.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016 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 "log.h" +#include "camera_ctrl.h" +#include "camera.h" +#include "camera_view.h" +#include "main_view.h" + +static Ecore_Event_Handler *handler; +static Evas_Object *main_view; + +static void _camera_clicked(void *data, Evas_Object *obj, void *event) +{ + lockscreen_camera_activate(); +} + +static void _camera_view_update() +{ + Evas_Object *cam_view; + + if (lockscreen_camera_is_on()) { + cam_view = lockscreen_camera_view_create(main_view); + evas_object_smart_callback_add(cam_view, SIGNAL_CAMERA_SELECTED, _camera_clicked, NULL); + lockscreen_main_view_part_content_set(main_view, PART_CAMERA, cam_view); + } + else { + cam_view = lockscreen_main_view_part_content_unset(main_view, PART_CAMERA); + evas_object_del(cam_view); + } +} + +static Eina_Bool _cam_status_changed(void *data, int event, void *event_info) +{ + _camera_view_update(); + return EINA_TRUE; +} + +int lockscreen_camera_ctrl_init(Evas_Object *view) +{ + if (lockscreen_camera_init()) { + ERR("lockscreen_camera_init failed"); + return 1; + } + + handler = ecore_event_handler_add(LOCKSCREEN_EVENT_CAMERA_STATUS_CHANGED, _cam_status_changed, NULL); + if (!handler) + FAT("ecore_event_handler_add failed on LOCKSCREEN_EVENT_BATTERY_CHANGED event"); + main_view = view; + _camera_view_update(); + + return 0; +} + +void lockscreen_camera_ctrl_fini(void) +{ + Evas_Object *cam_view = lockscreen_main_view_part_content_get(main_view, PART_CAMERA); + if (cam_view) evas_object_smart_callback_del(cam_view, SIGNAL_CAMERA_SELECTED, _camera_clicked); + ecore_event_handler_del(handler); + lockscreen_camera_shutdown(); +} diff --git a/src/camera_view.c b/src/camera_view.c new file mode 100644 index 0000000..cad48b3 --- /dev/null +++ b/src/camera_view.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2016 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 "camera_view.h" +#include "util.h" +#include "log.h" +#include "lockscreen.h" +#include "util_time.h" + +#include + +static void _camera_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + evas_object_smart_callback_call(data, SIGNAL_CAMERA_SELECTED, NULL); +} + +Evas_Object *lockscreen_camera_view_create(Evas_Object *parent) +{ + Evas_Object *cam_ly = elm_layout_add(parent); + if (!elm_layout_file_set(cam_ly, util_get_res_file_path(LOCK_EDJE_FILE), "camera-layout")) { + FAT("elm_layout_file_set failed"); + return false; + } + elm_object_signal_callback_add(cam_ly, "camera,icon,clicked", "camera-layout", _camera_clicked, cam_ly); + + evas_object_show(cam_ly); + return cam_ly; +} diff --git a/src/dbus.c b/src/dbus.c deleted file mode 100644 index 1a0dd95..0000000 --- a/src/dbus.c +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 "lockscreen.h" -#include "log.h" -#include "dbus.h" -#include "property.h" -#include "lock_time.h" -#include "default_lock.h" - -static struct _s_info { - DBusConnection *connection; - Eina_List *cbs_list[DBUS_EVENT_MAX]; - int is_rotate_signal_added; -} s_info = { - .connection = NULL, - .cbs_list = { NULL, }, - .is_rotate_signal_added = 0, -}; - -typedef struct { - void (*result_cb)(void *, void *); - void *result_data; -} dbus_cb_s; - -static void _execute_cbs(int type, void *event_info) -{ - dbus_cb_s *cb = NULL; - - Eina_List *list = eina_list_clone(s_info.cbs_list[type]); - EINA_LIST_FREE(list, cb) { - continue_if(!cb); - continue_if(!cb->result_cb); - - cb->result_cb(cb->result_data, event_info); - } -} - -static void _cbs_fini(void) -{ - int i = 0; - - const Eina_List *l = NULL; - const Eina_List *n = NULL; - dbus_cb_s *cb = NULL; - - for (i = 0; i < DBUS_EVENT_MAX; i++) { - EINA_LIST_FOREACH_SAFE(s_info.cbs_list[i], l, n, cb) { - free(cb); - } - } -} - -static DBusConnection *_dbus_connection_get(void) -{ - if (!s_info.connection) { - DBusError derror; - DBusConnection *connection = NULL; - - dbus_error_init(&derror); - connection = dbus_bus_get_private(DBUS_BUS_SYSTEM, &derror); - if (!connection) { - _E("Failed to get dbus connection : %s", derror.message); - dbus_error_free(&derror); - return NULL; - } - dbus_connection_setup_with_g_main(connection, NULL); - dbus_error_free(&derror); - - s_info.connection = connection; - } - - return s_info.connection; -} - -static DBusHandlerResult _dbus_message_recv_cb(DBusConnection *connection, DBusMessage *message, void *data) -{ - if (dbus_message_is_signal(message, DBUS_DEVICED_DISPLAY_INTERFACE, DBUS_DEVICED_DISPLAY_MEMBER_LCD_ON)) { - _I("LCD on"); - int ret = 0; - DBusError derror; - const char *state = NULL; - dbus_error_init(&derror); - ret = dbus_message_get_args(message, &derror, DBUS_TYPE_STRING, &state, DBUS_TYPE_INVALID); - if (!ret) { - _E("Failed to get reply (%s:%s)", derror.name, derror.message); - } - _execute_cbs(DBUS_EVENT_LCD_ON, (void*)state); - dbus_error_free(&derror); - } else if (dbus_message_is_signal(message, DBUS_DEVICED_DISPLAY_INTERFACE, DBUS_DEVICED_DISPLAY_MEMBER_LCD_OFF)) { - _I("LCD off"); - int ret = 0; - DBusError derror; - const char *state = NULL; - dbus_error_init(&derror); - ret = dbus_message_get_args(message, &derror, DBUS_TYPE_STRING, &state, DBUS_TYPE_INVALID); - if (!ret) { - _E("Failed to get reply (%s:%s)", derror.name, derror.message); - } - _execute_cbs(DBUS_EVENT_LCD_OFF, (void*)state); - dbus_error_free(&derror); - } else if (dbus_message_is_signal(message, DBUS_ROTATION_INTERFACE, DBUS_ROTATION_MEMBER_CHANGED)) { - int ret = 0; - DBusError derror; - int state = 0; - dbus_error_init(&derror); - ret = dbus_message_get_args(message, &derror, DBUS_TYPE_INT32, &state, DBUS_TYPE_INVALID); - if (!ret) { - _E("Failed to get reply (%s:%s)", derror.name, derror.message); - } - - int angle = (state - 1) * 90; - angle = (angle < 0) ? 0 : angle; - - _I("rotation changed : %d", angle); - _execute_cbs(DBUS_EVENT_ANGLE_CHANGED, (void*)angle); - dbus_error_free(&derror); - } - - return DBUS_HANDLER_RESULT_HANDLED; -} - -static lock_error_e _dbus_sig_attach(char *path, char *interface, char *member) -{ - DBusError derror; - DBusConnection *connection = NULL; - - retv_if(!path, LOCK_ERROR_INVALID_PARAMETER); - retv_if(!interface, LOCK_ERROR_INVALID_PARAMETER); - retv_if(!member, LOCK_ERROR_INVALID_PARAMETER); - - /* DBUS */ - connection = _dbus_connection_get(); - if (!connection) { - _E("Failed to get DBUS connection"); - return LOCK_ERROR_FAIL; - } - - dbus_error_init(&derror); - - /* Set the DBus rule for the wakeup gesture signal */ - char rules[512] = { 0, }; - snprintf(rules, sizeof(rules) - 1, "path='%s',type='signal',interface='%s', member='%s'", path, interface, member); - dbus_bus_add_match(connection, rules, &derror); - if (dbus_error_is_set(&derror)) { - _E("D-BUS rule adding error: %s", derror.message); - dbus_error_free(&derror); - return LOCK_ERROR_FAIL; - } - - /* Set the callback function */ - if (dbus_connection_add_filter(connection, _dbus_message_recv_cb, NULL, NULL) == FALSE) { - _E("Failed to add dbus filter : %s", derror.message); - dbus_error_free(&derror); - return LOCK_ERROR_FAIL; - } - - dbus_error_free(&derror); - - return LOCK_ERROR_OK; -} - -static lock_error_e _dbus_sig_dettach(const char *path, const char *interface, const char *member) -{ - DBusError err; - DBusConnection *connection = NULL; - - int ret = LOCK_ERROR_OK; - - retv_if(!path, LOCK_ERROR_INVALID_PARAMETER); - retv_if(!interface, LOCK_ERROR_INVALID_PARAMETER); - retv_if(!member, LOCK_ERROR_INVALID_PARAMETER); - - connection = _dbus_connection_get(); - if (!connection) { - _E("failed to get DBUS connection"); - return LOCK_ERROR_FAIL; - } - - dbus_error_init(&err); - dbus_connection_remove_filter(connection, _dbus_message_recv_cb, NULL); - - char rules[512] = { 0, }; - - snprintf(rules, sizeof(rules), "path='%s',type='signal',interface='%s',member='%s'", path, interface, member); - dbus_bus_remove_match(connection, rules, &err); - if (dbus_error_is_set(&err)) { - _E("Failed to dbus_bus_remove_match : %s", err.message); - ret = LOCK_ERROR_FAIL; - } - - dbus_error_free(&err); - - return ret; -} - -int lock_dbus_register_cb(int type, void (*result_cb)(void *, void *), void *result_data) -{ - retv_if(!result_cb, LOCK_ERROR_FAIL); - - dbus_cb_s *cb = calloc(1, sizeof(dbus_cb_s)); - retv_if(!cb, LOCK_ERROR_FAIL); - - cb->result_cb = result_cb; - cb->result_data = result_data; - - s_info.cbs_list[type] = eina_list_prepend(s_info.cbs_list[type], cb); - retv_if(!s_info.cbs_list[type], LOCK_ERROR_FAIL); - - return LOCK_ERROR_OK; -} - -void lock_dbus_unregister_cb(int type, void (*result_cb)(void *, void *)) -{ - const Eina_List *l; - const Eina_List *n; - dbus_cb_s *cb; - EINA_LIST_FOREACH_SAFE(s_info.cbs_list[type], l, n, cb) { - continue_if(!cb); - if (result_cb != cb->result_cb) continue; - s_info.cbs_list[type] = eina_list_remove(s_info.cbs_list[type], cb); - free(cb); - return; - } -} - -static void _lcd_on_cb(void *user_data, void *event_info) -{ - _I("Dbus LCD on"); - - lock_time_resume(); - - lockscreen_lcd_off_timer_set(); -} - -static void _lcd_off_cb(void *user_data, void *event_info) -{ - _I("Dbus LCD off"); - - lock_time_pause(); - - lockscreen_lcd_off_timer_unset(); - lockscreen_lcd_off_count_reset(); -} - -void lock_dbus_init(void *data) -{ - if (_dbus_sig_attach(DBUS_DEVICED_DISPLAY_PATH, - DBUS_DEVICED_DISPLAY_INTERFACE, - DBUS_DEVICED_DISPLAY_MEMBER_LCD_ON) != LOCK_ERROR_OK) { - _E("Failed to attach LCD on signal filter"); - } - - if (_dbus_sig_attach(DBUS_DEVICED_DISPLAY_PATH, - DBUS_DEVICED_DISPLAY_INTERFACE, - DBUS_DEVICED_DISPLAY_MEMBER_LCD_OFF) != LOCK_ERROR_OK) { - _E("Failed to attach LCD off signal filter"); - } - - if (lock_property_rotation_enabled_get()) { - if (_dbus_sig_attach(DBUS_ROTATION_PATH, - DBUS_ROTATION_INTERFACE, - DBUS_ROTATION_MEMBER_CHANGED) != LOCK_ERROR_OK) { - _E("Failed to attach rotation signal filter"); - } - } - - if (lock_dbus_register_cb(DBUS_EVENT_LCD_ON, _lcd_on_cb, NULL) != LOCK_ERROR_OK) { - _E("Failed to register lcd status changed cb"); - } - - if (lock_dbus_register_cb(DBUS_EVENT_LCD_OFF, _lcd_off_cb, NULL) != LOCK_ERROR_OK) { - _E("Failed to register lcd status changed cb"); - } -} - -void lock_dbus_fini(void *data) -{ - _dbus_sig_dettach(DBUS_DEVICED_DISPLAY_PATH, - DBUS_DEVICED_DISPLAY_INTERFACE, - DBUS_DEVICED_DISPLAY_MEMBER_LCD_ON); - - _dbus_sig_dettach(DBUS_DEVICED_DISPLAY_PATH, - DBUS_DEVICED_DISPLAY_INTERFACE, - DBUS_DEVICED_DISPLAY_MEMBER_LCD_OFF); - - if (lock_property_rotation_enabled_get()) { - _dbus_sig_dettach(DBUS_ROTATION_PATH, - DBUS_ROTATION_INTERFACE, - DBUS_ROTATION_MEMBER_CHANGED); - } - - if (s_info.connection != NULL) { - dbus_connection_close(s_info.connection); - dbus_connection_unref(s_info.connection); - s_info.connection = NULL; - - _D("DBUS connection is closed"); - } - - _cbs_fini(); - - lock_dbus_unregister_cb(DBUS_EVENT_LCD_ON, _lcd_on_cb); - lock_dbus_unregister_cb(DBUS_EVENT_LCD_OFF, _lcd_off_cb); -} diff --git a/src/default_lock.c b/src/default_lock.c deleted file mode 100644 index 51f9605..0000000 --- a/src/default_lock.c +++ /dev/null @@ -1,431 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 "lockscreen.h" -#include "log.h" -#include "default_lock.h" -#include "property.h" -#include "window.h" -#include "background_view.h" -#include "battery.h" -#include "lock_time.h" -#include "sim_state.h" - -#define INDICATOR_HEIGHT 38 -#define UNLOCK_DISTANCE 140 - -#define MINICONTROL_BUNDLE_KEY_WIDTH "width" -#define MINICONTROL_BUNDLE_KEY_HEIGHT "height" - -static struct _s_info { - Evas_Object *conformant; - Evas_Object *layout; - Evas_Object *swipe_layout; - - Ecore_Event_Handler *mouse_down_handler; - Ecore_Event_Handler *mouse_move_handler; - Ecore_Event_Handler *mouse_up_handler; - - Eina_Bool is_mouse_down; - - int lcd_off_count; - - int clicked_x; - int clicked_y; - - lock_exit_state_e exit_state; -} s_info = { - .conformant = NULL, - .layout= NULL, - .swipe_layout = NULL, - - .mouse_down_handler = NULL, - .mouse_move_handler = NULL, - .mouse_up_handler = NULL, - - .is_mouse_down = EINA_FALSE, - .clicked_x = 0, - .clicked_y = 0, - - .exit_state = LOCK_EXIT_STATE_NORMAL, -}; - -Evas_Object *lock_default_conformant_get(void) -{ - return s_info.conformant; -} - -Evas_Object *lock_default_lock_layout_get(void) -{ - return s_info.layout; -} - -Evas_Object *lock_default_swipe_layout_get(void) -{ - return s_info.swipe_layout; -} - -void _default_lock_hw_back_cb(void *data, Evas_Object *obj, void *event_info) -{ - _I("%s", __func__); -} - -static Eina_Bool _default_lock_mouse_down_cb(void *data, int type, void *event) -{ - _D("%s", __func__); - - Ecore_Event_Mouse_Button *m = event; - - int touch_upper_y = 0; - - retv_if(!m, ECORE_CALLBACK_CANCEL); - retv_if(!s_info.swipe_layout, ECORE_CALLBACK_CANCEL); - - /* (Up to 3 times, 30 seconds) is extended by 10 seconds Control panel area when tap */ - lockscreen_lcd_off_count_raise(); - - s_info.clicked_x = m->root.x; - s_info.clicked_y = m->root.y; - _D("clicked x(%d), y(%d)", s_info.clicked_x, s_info.clicked_y); - - touch_upper_y = INDICATOR_HEIGHT; - _D("touch upper y : %d", touch_upper_y); - - if (m->root.y <= touch_upper_y) { - _D("ignore touch event(%d > %d)", m->root.y, touch_upper_y); - s_info.is_mouse_down = EINA_FALSE; - } else { - elm_object_signal_emit(s_info.swipe_layout, "vi_effect_start", "padding.top"); - s_info.is_mouse_down = EINA_TRUE; - } - - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool _default_lock_mouse_move_cb(void *data, int type, void *event) -{ - Ecore_Event_Mouse_Move *m = event; - retv_if(!m, ECORE_CALLBACK_CANCEL); - retv_if(m->multi.device != 0, ECORE_CALLBACK_CANCEL); - - int const dx = m->x - s_info.clicked_x; - int const dy = s_info.clicked_y - m->y; - int scaled_unlock_distance = _X(UNLOCK_DISTANCE); - int distance = sqrt(dx*dx + dy*dy) + _X(20); - - if (distance >= scaled_unlock_distance) { - s_info.exit_state = LOCK_EXIT_STATE_EXIT; - } else { - s_info.exit_state = LOCK_EXIT_STATE_NORMAL; - } - - return ECORE_CALLBACK_DONE; -} - -static Eina_Bool _default_lock_mouse_up_cb(void *data, int type, void *event) -{ - _D("%s", __func__); - - Ecore_Event_Mouse_Button *m = event; - - retv_if(!m, ECORE_CALLBACK_CANCEL); - retv_if(m->multi.device != 0, ECORE_CALLBACK_CANCEL); - retv_if(!s_info.layout, ECORE_CALLBACK_CANCEL); - retv_if(!s_info.swipe_layout, ECORE_CALLBACK_CANCEL); - - - if (s_info.is_mouse_down == EINA_FALSE) { - _I("ignore touch event"); - return ECORE_CALLBACK_CANCEL; - } - - s_info.is_mouse_down = EINA_FALSE; - - switch(s_info.exit_state) { - case LOCK_EXIT_STATE_NORMAL : - _D("cancel unlock"); - break; - case LOCK_EXIT_STATE_EXIT : - _D("exit lockscreen"); - - elm_object_signal_emit(s_info.swipe_layout, "vi_effect", "padding.top"); - elm_object_signal_emit(s_info.layout, "vi_effect", "vi_clipper"); - return ECORE_CALLBACK_CANCEL; - default : - _E("type error : %d", s_info.exit_state); - break; - } - - s_info.exit_state = LOCK_EXIT_STATE_NORMAL; - - elm_object_signal_emit(s_info.swipe_layout, "vi_effect_stop", "padding.top"); - elm_object_signal_emit(s_info.layout, "vi_effect_stop", "vi_clipper"); - elm_object_signal_emit(s_info.swipe_layout, "show,txt,plmn", "txt.plmn"); - - return ECORE_CALLBACK_PASS_ON; -} - -static void _vi_effect_end_cb(void *data, Evas_Object *obj, const char *emission, const char *source) -{ - _D("%s", __func__); - - ui_app_exit(); -} - -static lock_error_e _unlock_panel_create(void) -{ - retv_if(!s_info.swipe_layout, LOCK_ERROR_FAIL); - - s_info.mouse_down_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _default_lock_mouse_down_cb, NULL); - if (!s_info.mouse_down_handler) { - _E("Failed to add mouse down handler"); - } - - s_info.mouse_move_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, _default_lock_mouse_move_cb, NULL); - if (!s_info.mouse_move_handler) { - _E("Failed to add mouse move handler"); - } - - s_info.mouse_up_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, _default_lock_mouse_up_cb, NULL); - if (!s_info.mouse_up_handler) { - _E("Failed to add mouse up handler"); - } - - elm_object_signal_callback_add(s_info.swipe_layout, "vi_effect_end", "vi_clipper", _vi_effect_end_cb, NULL); - - return LOCK_ERROR_OK; -} - -static Evas_Object *_swipe_layout_create(Evas_Object *parent) -{ - Evas_Object *swipe_layout = NULL; - - retv_if(!parent, NULL); - - swipe_layout = elm_layout_add(parent); - retv_if(!swipe_layout, NULL); - - if (!elm_layout_file_set(swipe_layout, LOCK_EDJE_FILE, "swipe-lock")) { - _E("Failed to set edje file for swipe lock"); - goto ERROR; - } - - evas_object_size_hint_weight_set(swipe_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(swipe_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - - evas_object_show(swipe_layout); - s_info.swipe_layout = swipe_layout; - - /* initialize time & date information */ - lock_time_init(); - - /* initialize battery information */ - if (LOCK_ERROR_OK != lock_battery_init()) { - _E("Failed to initialize battery information"); - } - - /* initialize PLMN-SPN information */ - if (LOCK_ERROR_OK != lock_sim_state_init()) { - _E("Failed to initialize sim state"); - } - - return swipe_layout; - -ERROR: - _E("Failed to create swipe layout"); - - if(swipe_layout) { - evas_object_del(swipe_layout); - swipe_layout = NULL; - } - - return NULL; -} - -static Evas_Object *_layout_create(void) -{ - Evas_Object *layout = NULL; - Evas_Object *swipe_layout = NULL; - Evas_Object *win = NULL; - - win = lock_window_win_get(); - retv_if(!win, NULL); - - layout = elm_layout_add(win); - retv_if(!layout, NULL); - - evas_object_show(layout); - - if (!elm_layout_file_set(layout, LOCK_EDJE_FILE, "lockscreen")) { - _E("Failed to set edje file"); - goto ERROR; - } - - evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); - - swipe_layout = _swipe_layout_create(layout); - if (!swipe_layout) { - _E("Failed to create swipe layout"); - goto ERROR; - } - - elm_object_part_content_set(layout, "sw.swipe_layout", swipe_layout); - if (!elm_object_part_content_get(layout, "sw.swipe_layout")) { - _E("Failed to set swipe layout"); - goto ERROR; - } - - elm_win_resize_object_add(win, layout); - - return layout; - -ERROR: - _E("Failed to create layout"); - - if (layout) { - evas_object_del(layout); - layout = NULL; - } - - if (swipe_layout) { - evas_object_del(swipe_layout); - swipe_layout = NULL; - } - - return NULL; -} - -static Evas_Object *_comformant_create(void) -{ - Evas_Object *conformant = NULL; - Evas_Object *win = NULL; - - win = lock_window_win_get(); - retv_if(!win, NULL); - - conformant = elm_conformant_add(win); - retv_if(!conformant, NULL); - - evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(win, conformant); - - elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW); - elm_object_signal_emit(conformant, "elm,state,indicator,overlap", "elm"); - - evas_object_show(conformant); - - return conformant; -} - -lock_error_e lock_default_lock_init(void) -{ - Evas_Object *conformant = NULL; - Evas_Object *layout = NULL; - Evas_Object *bg = NULL; - - int ret = 0; - - layout = _layout_create(); - goto_if(!layout, ERROR); - - s_info.layout = layout; - - conformant = _comformant_create(); - goto_if(!conformant, ERROR); - s_info.conformant = conformant; - - eext_object_event_callback_add(layout, EEXT_CALLBACK_BACK, _default_lock_hw_back_cb, NULL); - - bg = lock_background_view_bg_get(); - if (!bg) { - _E("Failed to get BG"); - } else { - elm_object_part_content_set(layout, "sw.bg", bg); - } - - ret = _unlock_panel_create(); - goto_if(LOCK_ERROR_OK != ret, ERROR); - - return LOCK_ERROR_OK; - -ERROR: - _E("Failed to initialize default lock"); - - if (conformant) { - evas_object_del(conformant); - conformant = NULL; - } - - if (layout) { - evas_object_del(layout); - layout = NULL; - } - - return LOCK_ERROR_FAIL; -} - -void lock_default_lock_fini(void) -{ - /* delete network status */ - lock_sim_state_deinit(); - - /* delete batteyr information */ - lock_battery_fini(); - - /* delete data&time information */ - lock_time_fini(); - - /* delete wallpaper */ - lock_background_view_bg_del(); - - if (s_info.mouse_down_handler) { - ecore_event_handler_del(s_info.mouse_down_handler); - s_info.mouse_down_handler = NULL; - } - - if (s_info.mouse_move_handler) { - ecore_event_handler_del(s_info.mouse_move_handler); - s_info.mouse_move_handler = NULL; - } - - if (s_info.mouse_up_handler) { - ecore_event_handler_del(s_info.mouse_up_handler); - s_info.mouse_up_handler = NULL; - } - - if (s_info.swipe_layout) { - evas_object_del(s_info.swipe_layout); - s_info.swipe_layout = NULL; - } - - if (s_info.conformant) { - evas_object_del(s_info.conformant); - s_info.conformant = NULL; - } - - if (s_info.layout) { - eext_object_event_callback_del(s_info.layout, EEXT_CALLBACK_BACK, _default_lock_hw_back_cb); - evas_object_del(s_info.layout); - s_info.layout = NULL; - } -} diff --git a/src/display.c b/src/display.c new file mode 100644 index 0000000..fcc13c3 --- /dev/null +++ b/src/display.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2016 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 "display.h" +#include "log.h" + +#define LOCK_LCD_OFF_TIMEOUT_TIME 10 + +static Ecore_Timer *lcd_off_timer; +int LOCKSCREEN_EVENT_DISPLAY_STATUS_CHANGED; +static int init_count; +static int display_off; + +static Eina_Bool _time_elapsed(void *data) +{ + int ret = device_display_change_state(DISPLAY_STATE_SCREEN_OFF); + if (ret != DEVICE_ERROR_NONE) { + ERR("device_display_change_state failed: %s", get_error_message(ret)); + } + + lcd_off_timer = NULL; + return ECORE_CALLBACK_CANCEL; +} + +static void _timer_reset(void) +{ + if (lcd_off_timer) { + ecore_timer_reset(lcd_off_timer); + } else { + lcd_off_timer = ecore_timer_add(LOCK_LCD_OFF_TIMEOUT_TIME, _time_elapsed, NULL); + } +} + +static void _display_status_changed(device_callback_e type, void *value, void *user_data) +{ + if (type != DEVICE_CALLBACK_DISPLAY_STATE) + return; + + display_state_e state = (display_state_e)value; + + switch (state) { + case DISPLAY_STATE_NORMAL: + case DISPLAY_STATE_SCREEN_DIM: + INF("Display on"); + _timer_reset(); + display_off = false; + break; + case DISPLAY_STATE_SCREEN_OFF: + INF("Display off"); + display_off = true; + break; + } + + ecore_event_add(LOCKSCREEN_EVENT_DISPLAY_STATUS_CHANGED, NULL, NULL, NULL); +} + +int lockscreen_display_init(void) +{ + display_state_e state; + + if (!init_count) { + LOCKSCREEN_EVENT_DISPLAY_STATUS_CHANGED = ecore_event_type_new(); + int ret = device_add_callback(DEVICE_CALLBACK_DISPLAY_STATE, _display_status_changed, NULL); + if (ret != DEVICE_ERROR_NONE) { + ERR("device_add_callback failed: %s", get_error_message(ret)); + return 1; + } + ret = device_display_get_state(&state); + if (ret != DEVICE_ERROR_NONE) { + ERR("device_display_get_state failed: %s", get_error_message(ret)); + device_remove_callback(DEVICE_CALLBACK_DISPLAY_STATE, _display_status_changed); + return 1; + } + + switch (state) { + case DISPLAY_STATE_NORMAL: + case DISPLAY_STATE_SCREEN_DIM: + display_off = false; + break; + case DISPLAY_STATE_SCREEN_OFF: + display_off = true; + break; + } + + _timer_reset(); + } + + init_count++; + return 0; +} + +void lockscreen_display_shutdown(void) +{ + if (init_count) { + init_count--; + + if (!init_count) { + if (lcd_off_timer) ecore_timer_del(lcd_off_timer); + device_remove_callback(DEVICE_CALLBACK_DISPLAY_STATE, _display_status_changed); + } + } +} + +void lockscreen_display_timer_freeze(void) +{ + if (lcd_off_timer) { + ecore_timer_freeze(lcd_off_timer); + } +} + +void lockscreen_display_timer_renew(void) +{ + if (lcd_off_timer) { + ecore_timer_thaw(lcd_off_timer); + ecore_timer_reset(lcd_off_timer); + } +} + +bool lockscreen_display_is_off(void) +{ + return display_off; +} diff --git a/src/events.c b/src/events.c new file mode 100644 index 0000000..ce1ccab --- /dev/null +++ b/src/events.c @@ -0,0 +1,425 @@ +/* + * Copyright (c) 2016 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 "log.h" +#include "lockscreen.h" +#include "events.h" +#include "minicontrollers.h" + +static Eina_List *notifications; +static Eina_List *minicontrollers; +static int init_count; +int LOCKSCREEN_EVENT_EVENTS_CHANGED; +static Ecore_Event_Handler *handler; +static bool freeze_event; + +struct lockscreen_event { + lockscreen_event_type_e type; + union { + char *icon_path; + char *minicontroller_name; + }; + char *icon_sub_path; + char *title; + char *content; + bundle *service_handle; + time_t time; + char *package; + notification_h noti; +}; + +static bool _notification_accept(notification_h noti) +{ + int app_list = 0; + int ret = notification_get_display_applist(noti, &app_list); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_get_display_applist failed: %s", get_error_message(ret)); + return false; + } + return app_list & NOTIFICATION_DISPLAY_APP_LOCK; +} + +static void _lockscreen_event_destroy(lockscreen_event_t *event) +{ + if (event->title) free(event->title); + if (event->content) free(event->content); + if (event->icon_path) free(event->icon_path); + if (event->icon_sub_path) free(event->icon_sub_path); + if (event->package) free(event->package); + if (event->service_handle) bundle_free(event->service_handle); + if (event->noti) notification_free(event->noti); + + free(event); +} + +static lockscreen_event_t *_lockscreen_event_minicontroller_create(const char *mini_name) +{ + lockscreen_event_t *event = calloc(1, sizeof(lockscreen_event_t)); + if (!event) return NULL; + + event->type = LOCKSCREEN_EVENT_TYPE_MINICONTROLLER; + event->minicontroller_name = mini_name ? strdup(mini_name) : NULL; + + return event; +} + +static lockscreen_event_t *_lockscreen_event_notification_create(notification_h noti) +{ + int ret; + char *val; + lockscreen_event_t *event = calloc(1, sizeof(lockscreen_event_t)); + if (!event) return NULL; + + event->type = LOCKSCREEN_EVENT_TYPE_NOTIFICATION; + + ret = notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &val); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_get_text failed: %s", get_error_message(ret)); + _lockscreen_event_destroy(event); + return NULL; + } + if (val) event->title = strdup(val); + + ret = notification_get_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, &val); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_get_text failed: %s", get_error_message(ret)); + _lockscreen_event_destroy(event); + return NULL; + } + if (val) event->content = strdup(val); + + ret = notification_get_pkgname(noti, &val); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_get_pkgname failed: %s", get_error_message(ret)); + _lockscreen_event_destroy(event); + return NULL; + } + if (val) event->package = strdup(val); + + ret = notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, &val); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_get_image failed: %s", get_error_message(ret)); + _lockscreen_event_destroy(event); + return NULL; + } + if (val) event->icon_path = strdup(val); + + ret = notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_SUB, &val); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_get_image failed: %s", get_error_message(ret)); + _lockscreen_event_destroy(event); + return NULL; + } + if (val) event->icon_sub_path = strdup(val); + + ret = notification_get_time(noti, &event->time); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_get_time failed: %s", get_error_message(ret)); + _lockscreen_event_destroy(event); + return NULL; + } + + ret = notification_get_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &event->service_handle); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_get_execute_option failed: %s", get_error_message(ret)); + _lockscreen_event_destroy(event); + return NULL; + } + + if (event->service_handle) { + event->service_handle = bundle_dup(event->service_handle); + } + + ret = notification_clone(noti, &event->noti); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_clone failed: %s", get_error_message(ret)); + _lockscreen_event_destroy(event); + return NULL; + } + + DBG("Title: %s", event->title); + DBG("Content: %s", event->content); + DBG("Package: %s", event->package); + DBG("Icon: %s", event->icon_path); + DBG("SubIcon: %s", event->icon_sub_path); + + return event; +} + +static int _load_notifications() +{ + notification_list_h noti_list; + notification_list_h noti_list_head = NULL; + notification_h noti = NULL; + + int ret = notification_get_list(NOTIFICATION_TYPE_NOTI, -1, ¬i_list_head); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_get_list failed: %s", get_error_message(ret)); + return 1; + } + + noti_list = noti_list_head; + while (noti_list) { + noti = notification_list_get_data(noti_list); + if (_notification_accept(noti)) { + lockscreen_event_t *me = _lockscreen_event_notification_create(noti); + notifications = eina_list_append(notifications, me); + } + noti_list = notification_list_get_next(noti_list); + } + + ecore_event_add(LOCKSCREEN_EVENT_EVENTS_CHANGED, NULL, NULL, NULL); + + notification_free_list(noti_list_head); + return 0; +} + +static void _unload_notifications() +{ + lockscreen_event_t *event; + + if (!notifications) + return; + + EINA_LIST_FREE(notifications, event) + _lockscreen_event_destroy(event); + + notifications = NULL; + ecore_event_add(LOCKSCREEN_EVENT_EVENTS_CHANGED, NULL, NULL, NULL); +} + +static void _noti_changed_cb(void *data, notification_type_e type, notification_op *op_list, int num_op) +{ + _unload_notifications(); + _load_notifications(); +} + +static void _unload_minicontrollers(void) +{ + lockscreen_event_t *event; + EINA_LIST_FREE(minicontrollers, event) + _lockscreen_event_destroy(event); + minicontrollers = NULL; + ecore_event_add(LOCKSCREEN_EVENT_EVENTS_CHANGED, NULL, NULL, NULL); +} + +static void _load_minicontrollers(void) +{ + Eina_List *mini = lockscreen_minicontrollers_list_get(); + const char *name; + EINA_LIST_FREE(mini, name) { + lockscreen_event_t *event = _lockscreen_event_minicontroller_create(name); + minicontrollers = eina_list_append(minicontrollers, event); + } + ecore_event_add(LOCKSCREEN_EVENT_EVENTS_CHANGED, NULL, NULL, NULL); +} + +static Eina_Bool _lockscreen_events_minicontroller_changed(void *data, int event, void *event_info) +{ + _unload_minicontrollers(); + _load_minicontrollers(); + return EINA_TRUE; +} + +int lockscreen_events_init(void) +{ + if (!init_count) { + LOCKSCREEN_EVENT_EVENTS_CHANGED = ecore_event_type_new(); + if (lockscreen_minicontrollers_init()) { + ERR("lockscreen_minicontrollers_init failed"); + return 1; + } + int ret = notification_register_detailed_changed_cb(_noti_changed_cb, NULL); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_register_detailed_changed_cb failed: %d", get_error_message(ret)); + return 1; + } + handler = ecore_event_handler_add(LOCKSCREEN_EVENT_MINICONTROLLERS_CHANGED, _lockscreen_events_minicontroller_changed, NULL); + if (_load_notifications()) { + ERR("load_notifications failed"); + return 1; + } + } + init_count++; + return 0; +} + +void lockscreen_events_shutdown(void) +{ + if (init_count) { + init_count--; + if (!init_count) { + int ret = notification_unregister_detailed_changed_cb(_noti_changed_cb, NULL); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_unregister_detailed_changed_cb failed: %s", get_error_message(ret)); + } + _unload_notifications(); + _unload_minicontrollers(); + ecore_event_handler_del(handler); + } + } +} + +static void _app_control_reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) +{ + bool ret = false; + Launch_Result_Cb cb = user_data; + + switch (result) { + case APP_CONTROL_RESULT_APP_STARTED: + case APP_CONTROL_RESULT_SUCCEEDED: + ret = true; + break; + case APP_CONTROL_RESULT_FAILED: + case APP_CONTROL_RESULT_CANCELED: + ret = false; + break; + } + if (cb) cb(ret); +} + +bool lockscreen_event_launch(lockscreen_event_t *event, Launch_Result_Cb cb) +{ + app_control_h service = NULL; + + if (event->type != LOCKSCREEN_EVENT_TYPE_NOTIFICATION) + return false; + + int ret = app_control_create(&service); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("app_control_create failed: %s", get_error_message(ret)); + return false; + } + + ret = app_control_import_from_bundle(service, event->service_handle); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("app_control_import_from_bundle: %s", get_error_message(ret)); + app_control_destroy(service); + return false; + } + + INF("Launching event for package: %s", event->package); + + ret = app_control_send_launch_request(service, _app_control_reply_cb, cb); + if (ret != APP_CONTROL_ERROR_NONE) { + ERR("app_control_send_launch_request failed: %s", get_error_message(ret)); + app_control_destroy(service); + return false; + } + + app_control_destroy(service); + + return true; +} + +Eina_List *lockscreen_events_get(void) +{ + return eina_list_merge(eina_list_clone(notifications), eina_list_clone(minicontrollers));; +} + +bool lockscreen_events_exists(void) +{ + return notifications || minicontrollers ? EINA_TRUE : EINA_FALSE; +} + +const char *lockscreen_event_title_get(const lockscreen_event_t *event) +{ + return event->title; +} + +const char *lockscreen_event_content_get(const lockscreen_event_t *event) +{ + return event->content; +} + +time_t lockscreen_event_time_get(const lockscreen_event_t *event) +{ + return event->time; +} + +const char *lockscreen_event_icon_get(const lockscreen_event_t *event) +{ + return event->icon_path; +} + +const char *lockscreen_event_sub_icon_get(const lockscreen_event_t *event) +{ + return event->icon_sub_path; +} + +lockscreen_event_type_e lockscreen_event_type_get(const lockscreen_event_t *event) +{ + return event->type; +} + +Evas_Object *lockscreen_event_minicontroller_create(lockscreen_event_t *event, Evas_Object *parent) +{ + if (event->type != LOCKSCREEN_EVENT_TYPE_MINICONTROLLER) + return NULL; + return lockscreen_minicontrollers_minicontroller_create(event->minicontroller_name, parent); +} + +static void _lockscreen_event_notification_delete(notification_h noti) +{ + int ret = notification_delete(noti); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("notification_delete failed: %s", get_error_message(ret)); + } +} + +static void _lockscreen_event_minicontroller_delete(const char *name) +{ + lockscreen_minicontrollers_minicontroller_stop(name); +} + +void lockscreen_event_remove(lockscreen_event_t *event) +{ + switch (event->type) { + case LOCKSCREEN_EVENT_TYPE_NOTIFICATION: + _lockscreen_event_notification_delete(event->noti); + notifications = eina_list_remove(notifications, event); + break; + case LOCKSCREEN_EVENT_TYPE_MINICONTROLLER: + _lockscreen_event_minicontroller_delete(event->minicontroller_name); + minicontrollers = eina_list_remove(minicontrollers, event); + break; + } + _lockscreen_event_destroy(event); + if (!freeze_event) + ecore_event_add(LOCKSCREEN_EVENT_EVENTS_CHANGED, NULL, NULL, NULL); +} + +void lockscreen_events_remove_all(void) +{ + lockscreen_event_t *event; + freeze_event = true; + + EINA_LIST_FREE(notifications, event) { + lockscreen_event_remove(event); + } + EINA_LIST_FREE(minicontrollers, event) { + lockscreen_event_remove(event); + } + notifications = minicontrollers = NULL; + freeze_event = false; + ecore_event_add(LOCKSCREEN_EVENT_EVENTS_CHANGED, NULL, NULL, NULL); +} diff --git a/src/events_ctrl.c b/src/events_ctrl.c new file mode 100644 index 0000000..04a65a1 --- /dev/null +++ b/src/events_ctrl.c @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2016 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 "log.h" +#include "events_ctrl.h" +#include "events_view.h" +#include "main_view.h" +#include "events.h" +#include "time_format.h" +#include "util_time.h" + +#include +#include +#include + +static Ecore_Event_Handler *events_handler; +static Evas_Object *main_view; + +static Evas_Object *_lockscreen_events_view_ctrl_genlist_noti_content_get(void *data, Evas_Object *obj, const char *part); +static char *_lockscreen_events_view_ctrl_genlist_noti_text_get(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_lockscreen_events_view_ctrl_genlist_widget_content_get(void *data, Evas_Object *obj, const char *part); + +static Elm_Genlist_Item_Class noti_itc = { + .item_style = NOTI_ITEM_STYLE, + .func.content_get = _lockscreen_events_view_ctrl_genlist_noti_content_get, + .func.text_get = _lockscreen_events_view_ctrl_genlist_noti_text_get, +}; + +static Elm_Genlist_Item_Class widget_itc = { + .item_style = WIDGET_ITEM_STYLE, + .func.content_get = _lockscreen_events_view_ctrl_genlist_widget_content_get, +}; + +static Evas_Object *_lockscreen_events_view_ctrl_genlist_noti_content_get(void *data, Evas_Object *obj, const char *part) +{ + Evas_Object *ret = NULL; + lockscreen_event_t *event = data; + + if (!strcmp(part, NOTI_ITEM_ICON)) { + ret = elm_icon_add(obj); + elm_image_file_set(ret, lockscreen_event_icon_get(event), NULL); + } + else if (!strcmp(part, NOTI_ITEM_ICON_SUB)) { + ret = elm_icon_add(obj); + elm_image_file_set(ret, lockscreen_event_sub_icon_get(event), NULL); + } + return ret; +} + +static char *_lockscreen_events_view_ctrl_genlist_noti_text_time_get(time_t time) +{ + const char *locale = lockscreen_time_format_locale_get(); + const char *timezone = lockscreen_time_format_timezone_get(); + bool use24hformat = lockscreen_time_format_use_24h(); + char *str_time, *str_meridiem; + char time_buf[PATH_MAX] = {0,}; + + if (!util_time_formatted_time_get(time, locale, timezone, use24hformat, &str_time, &str_meridiem)) { + ERR("util_time_formatted_time_get failed"); + return NULL; + } + + if (use24hformat) { + snprintf(time_buf, sizeof(time_buf), "%s", str_time); + } else { + snprintf(time_buf, sizeof(time_buf), "%s %s", str_time, str_meridiem); + } + + free(str_time); + free(str_meridiem); + return strdup(time_buf); +} + +static char *_lockscreen_events_view_ctrl_genlist_noti_text_get(void *data, Evas_Object *obj, const char *part) +{ + lockscreen_event_t *event = data; + const char *val = NULL; + + if (!strcmp(part, NOTI_ITEM_TEXT)) { + val = lockscreen_event_title_get(event); + } + else if (!strcmp(part, NOTI_ITEM_TEXT_SUB)) { + val = lockscreen_event_content_get(event); + } + else if (!strcmp(part, NOTI_ITEM_TEXT_TIME)) { + val = _lockscreen_events_view_ctrl_genlist_noti_text_time_get(lockscreen_event_time_get(event)); + return (char*)val; + } + return val ? strdup(val) : NULL; +} + +static Evas_Object *_lockscreen_events_view_ctrl_genlist_widget_content_get(void *data, Evas_Object *obj, const char *part) +{ + lockscreen_event_t *event = data; + + if (!strcmp(part, WIDGET_ITEM_CONTENT)) { + return lockscreen_event_minicontroller_create(event, obj); + } + return NULL; +} + +static void _lockscreen_events_view_close_all_button_clicked(void *data, Evas_Object *obj, void *event_info) +{ + lockscreen_events_remove_all(); +} + +static void _lockscreen_events_ctrl_view_show() +{ + Evas_Object *events_view = lockscreen_main_view_part_content_get(main_view, PART_EVENTS); + if (!events_view) { + events_view = lockscreen_events_view_create(main_view); + evas_object_smart_callback_add(events_view, SIGNAL_CLOSE_BUTTON_CLICKED, _lockscreen_events_view_close_all_button_clicked, NULL); + lockscreen_main_view_part_content_set(main_view, PART_EVENTS, events_view); + } +} + +static void _lockscreen_events_ctrl_view_hide() +{ + Evas_Object *events_view = lockscreen_main_view_part_content_unset(main_view, PART_EVENTS); + if (events_view) { + evas_object_del(events_view); + } +} + +static int _lockscreen_events_ctrl_sort(const void *data1, const void *data2) +{ + const lockscreen_event_t *event1 = data1; + const lockscreen_event_t *event2 = data2; + + lockscreen_event_type_e type1 = lockscreen_event_type_get(event1); + lockscreen_event_type_e type2 = lockscreen_event_type_get(event2); + + if (type1 != type2) + return type1 > type2 ? -1 : 1; + + time_t time1 = lockscreen_event_time_get(event1); + time_t time2 = lockscreen_event_time_get(event2); + + return time1 > time2 ? -1 : 1; +} + +static void _lockscreen_events_ctrl_main_view_unlocked(void *data, Evas_Object *obj, void *event_info) +{ + ui_app_exit(); +} + +static void _lockscreen_events_ctrl_launch_result(bool result) +{ + if (result) { + evas_object_smart_callback_add(main_view, SIGNAL_UNLOCK_ANIMATION_FINISHED, _lockscreen_events_ctrl_main_view_unlocked, NULL); + lockscreen_main_view_unlock(main_view); + } else { + INF("Failed to launch application"); + } +} + +static void _lockscreen_events_ctrl_item_selected(void *data, Evas_Object *obj, void *info) +{ + lockscreen_event_t *event = data; + lockscreen_event_launch(event, _lockscreen_events_ctrl_launch_result); +} + +static void _lockscreen_events_ctrl_events_load() +{ + lockscreen_event_t *event; + + Evas_Object *genlist = lockscreen_events_genlist_get(lockscreen_main_view_part_content_get(main_view, PART_EVENTS)); + if (!genlist) { + FAT("lockscreen_events_genlist_get failed"); + return; + } + + Eina_List *events = lockscreen_events_get(); + events = eina_list_sort(events, -1, _lockscreen_events_ctrl_sort); + EINA_LIST_FREE(events, event) { + lockscreen_event_type_e type = lockscreen_event_type_get(event); + + switch (type) { + case LOCKSCREEN_EVENT_TYPE_NOTIFICATION: + elm_genlist_item_append(genlist, ¬i_itc, event, NULL, ELM_GENLIST_ITEM_NONE, _lockscreen_events_ctrl_item_selected, event); + break; + case LOCKSCREEN_EVENT_TYPE_MINICONTROLLER: + elm_genlist_item_append(genlist, &widget_itc, event, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); + } + } +} + +static void _lockscreen_events_ctrl_events_unload() +{ + Evas_Object *genlist = lockscreen_events_genlist_get(lockscreen_main_view_part_content_get(main_view, PART_EVENTS)); + elm_genlist_clear(genlist); +} + +static Eina_Bool _lockscreen_events_ctrl_events_changed(void *data, int event, void *event_info) +{ + /* Improve load/unload in the future */ + _lockscreen_events_ctrl_events_unload(); + + if (lockscreen_events_exists()) { + _lockscreen_events_ctrl_view_show(); + _lockscreen_events_ctrl_events_load(); + } + else { + _lockscreen_events_ctrl_view_hide(); + } + + return EINA_TRUE; +} + +int lockscreen_events_ctrl_init(Evas_Object *mv) +{ + if (lockscreen_events_init()) { + FAT("lockscreen_events_init failed."); + return 1; + } + + if (lockscreen_time_format_init()) { + FAT("lockscreen_time_format_init failed."); + lockscreen_events_shutdown(); + } + + main_view = mv; + + events_handler = ecore_event_handler_add(LOCKSCREEN_EVENT_EVENTS_CHANGED, _lockscreen_events_ctrl_events_changed, NULL); + + if (lockscreen_events_exists()) { + _lockscreen_events_ctrl_view_show(); + } + else + _lockscreen_events_ctrl_view_hide(); + + return 0; +} + +void lockscreen_events_ctrl_shutdown() +{ + ecore_event_handler_del(events_handler); + lockscreen_events_shutdown(); + lockscreen_time_format_shutdown(); +} diff --git a/src/events_view.c b/src/events_view.c new file mode 100644 index 0000000..872b23b --- /dev/null +++ b/src/events_view.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016 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 "events_view.h" +#include "util.h" +#include "log.h" +#include "lockscreen.h" +#include "util_time.h" + +#include + +static void _lockscreen_events_view_close_all_clicked(void *date, Evas_Object *obj, const char *emission, const char *source) +{ + evas_object_smart_callback_call(obj, SIGNAL_CLOSE_BUTTON_CLICKED, NULL); +} + +Evas_Object *lockscreen_events_view_create(Evas_Object *parent) +{ + Evas_Object *layout = elm_layout_add(parent); + if (!elm_layout_file_set(layout, util_get_res_file_path(LOCK_EDJE_FILE), "contextual-event")) { + FAT("elm_layout_file_set failed for contextual-event"); + evas_object_del(layout); + return NULL; + } + evas_object_show(layout); + + Evas_Object *genlist = elm_genlist_add(layout); + elm_genlist_mode_set(genlist, ELM_LIST_EXPAND); + elm_scroller_bounce_set(genlist, EINA_TRUE, EINA_FALSE); + elm_scroller_policy_set(genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_object_tree_focus_allow_set(genlist, EINA_TRUE); + evas_object_show(genlist); + + /* Defined in elm-theme-tizen.edj */ + elm_layout_theme_set(genlist, "scroller", "base", "effect"); + elm_object_part_content_set(layout, "sw.genlist", genlist); + + /* Load theme extension */ + util_lockscreen_theme_get(); + + /* Register close button clicked callback */ + elm_object_signal_callback_add(layout, "btn,close,clicked", "contextual-event", _lockscreen_events_view_close_all_clicked, NULL); + + return layout; +} + +Evas_Object *lockscreen_events_genlist_get(Evas_Object *events_view) +{ + return elm_object_part_content_get(events_view, "sw.genlist"); +} diff --git a/src/lock_time.c b/src/lock_time.c deleted file mode 100644 index 926aa38..0000000 --- a/src/lock_time.c +++ /dev/null @@ -1,678 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 "lockscreen.h" -#include "log.h" -#include "lock_time.h" -#include "property.h" -#include "default_lock.h" - -#define TIME_LOCALE_FILE "/opt/etc/localtime" -#define TIME_ZONEINFO_PATH "/usr/share/zoneinfo/" -#define TIME_ZONEINFO_PATH_LEN (strlen(TIME_ZONEINFO_PATH)) - -static struct _s_info { - int is_initialized; - Ecore_Timer *timer; - int is_timer_enabled; - UDateFormat *formatter_date; - UDateFormat *formatter_time; - UDateFormat *formatter_ampm; - UDateTimePatternGenerator *generator; - int timeformat; - char *timeregion_format; - char *timezone_id; - Eina_Bool is_pre_meridiem; - int is_roaming; - - int need_sync; -} s_info = { - .is_initialized = 0, - .timer = NULL, - .is_timer_enabled = 0, - .formatter_date = NULL, - .formatter_time = NULL, - .formatter_ampm = NULL, - .generator = NULL, - .timeformat = APPCORE_TIME_FORMAT_24, - .timeregion_format = NULL, - .timezone_id = NULL, - .is_pre_meridiem = EINA_FALSE, - .is_roaming = -1, - - .need_sync = 0, -}; - -static void _timer_add(void); - -static UDateFormat *__util_time_ampm_formatter_get(void *data, const char *timezone_id) -{ - UErrorCode status = U_ZERO_ERROR; - - UChar u_best_pattern[64] = {0,}; - UDateFormat *formatter = NULL; - - u_uastrcpy(u_best_pattern, "a"); - - UChar u_timezone_id[64] = {0,}; - if (!timezone_id) { - u_uastrncpy(u_timezone_id, s_info.timezone_id, sizeof(u_timezone_id)); - formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, s_info.timeregion_format, u_timezone_id, -1, - u_best_pattern, -1, &status); - } else { - u_uastrncpy(u_timezone_id, timezone_id, sizeof(u_timezone_id)); - formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, s_info.timeregion_format, u_timezone_id, -1, - u_best_pattern, -1, &status); - } - if (U_FAILURE(status)) { - _E("udat_open() failed"); - return NULL; - } - - char a_best_pattern[64] = {0,}; - u_austrcpy(a_best_pattern, u_best_pattern); - - return formatter; -} - -static UDateFormat *__util_time_time_formatter_get(void *data, int time_format, const char *timezone_id) -{ - char buf[64] = {0,}; - UErrorCode status = U_ZERO_ERROR; - UChar u_pattern[64] = {0,}; - UChar u_best_pattern[64] = {0,}; - int32_t u_best_pattern_capacity; - char a_best_pattern[64] = {0,}; - - UDateFormat *formatter = NULL; - - retv_if(!s_info.generator, NULL); - - if (time_format == APPCORE_TIME_FORMAT_24) { - snprintf(buf, sizeof(buf)-1, "%s", "HH:mm"); - } else { - /* set time format 12 */ - snprintf(buf, sizeof(buf)-1, "%s", "h:mm"); - } - - if (!u_uastrncpy(u_pattern, buf, sizeof(u_pattern))) { - _E("u_uastrncpy() is failed."); - return NULL; - } - - u_best_pattern_capacity = - (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0])); - - udatpg_getBestPattern(s_info.generator, u_pattern, u_strlen(u_pattern), - u_best_pattern, u_best_pattern_capacity, &status); - if (U_FAILURE(status)) { - _E("udatpg_getBestPattern() failed"); - return NULL; - } - - u_austrcpy(a_best_pattern, u_best_pattern); - - if (a_best_pattern[0] == 'a') { - s_info.is_pre_meridiem = EINA_TRUE; - } else { - s_info.is_pre_meridiem = EINA_FALSE; - } - - char *saveptr; - char *a_best_pattern_fixed = strtok_r(a_best_pattern, "a", &saveptr); - a_best_pattern_fixed = strtok_r(a_best_pattern_fixed, " ", &saveptr); - if (a_best_pattern_fixed) { - u_uastrcpy(u_best_pattern, a_best_pattern_fixed); - } - - UChar u_timezone_id[64] = {0,}; - if (!timezone_id) { - u_uastrncpy(u_timezone_id, s_info.timezone_id, sizeof(u_timezone_id)); - formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, s_info.timeregion_format, u_timezone_id, -1, - u_best_pattern, -1, &status); - } else { - u_uastrncpy(u_timezone_id, timezone_id, sizeof(u_timezone_id)); - formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, s_info.timeregion_format, u_timezone_id, -1, - u_best_pattern, -1, &status); - } - if (U_FAILURE(status)) { - _E("udat_open() failed"); - return NULL; - } - - return formatter; -} - -static UDateFormat *__util_time_date_formatter_get(void *data, const char *timezone_id, const char *skeleton) -{ - UErrorCode status = U_ZERO_ERROR; - - UChar u_skeleton[64] = {0,}; - int skeleton_len = 0; - - UChar u_best_pattern[64] = {0,}; - int32_t u_best_pattern_capacity; - UDateFormat *formatter = NULL; - - retv_if(!s_info.generator, NULL); - - u_uastrncpy(u_skeleton, skeleton, strlen(skeleton)); - skeleton_len = u_strlen(u_skeleton); - - u_best_pattern_capacity = - (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0])); - - udatpg_getBestPattern(s_info.generator, u_skeleton, skeleton_len, - u_best_pattern, u_best_pattern_capacity, &status); - if (U_FAILURE(status)) { - _E("udatpg_getBestPattern() failed"); - return NULL; - } - - UChar u_timezone_id[64] = {0,}; - if (!timezone_id) { - u_uastrncpy(u_timezone_id, s_info.timezone_id, sizeof(u_timezone_id)); - formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, s_info.timeregion_format, u_timezone_id, -1, - u_best_pattern, -1, &status); - } else { - u_uastrncpy(u_timezone_id, timezone_id, sizeof(u_timezone_id)); - formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, s_info.timeregion_format, u_timezone_id, -1, - u_best_pattern, -1, &status); - } - if (U_FAILURE(status)) { - _E("udat_open() failed"); - return NULL; - } - - char a_best_pattern[64] = {0,}; - u_austrcpy(a_best_pattern, u_best_pattern); - - return formatter; -} - -static int __util_time_formatted_time_get(UDateFormat *formatter, time_t tt, char *buf, int buf_len) -{ - retv_if (!formatter, -1); - - UDate u_time = (UDate)tt * 1000; - UChar u_formatted_str[64] = {0,}; - int32_t u_formatted_str_capacity; - UErrorCode status = U_ZERO_ERROR; - - u_formatted_str_capacity = (int32_t)(sizeof(u_formatted_str) / sizeof((u_formatted_str)[0])); - - (void)udat_format(formatter, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &status); - if (U_FAILURE(status)) { - _E("udat_format() failed"); - return -1; - } - - u_austrncpy(buf, u_formatted_str, buf_len-1); - _D("time(%d) formatted(%s)", tt, buf); - - return (int)u_strlen(u_formatted_str); -} - -static void _util_time_get(int is_current_time, time_t tt_a, char *timezone, char *skeleton, char **str_date, char **str_time, char **str_meridiem) -{ - time_t tt; - struct tm st; - char buf_date[512] = {0,}; - char buf_time[512] = {0,}; - char buf_ampm[512] = {0,}; - - if (is_current_time == 1) { - tt = time(NULL); - } else { - tt = tt_a; - } - localtime_r(&tt, &st); - - UDateFormat *formatter_date = NULL; - UDateFormat *formatter_time = NULL; - UDateFormat *formatter_ampm = NULL; - - if (timezone != NULL) { - if (!skeleton) { - formatter_date = __util_time_date_formatter_get(NULL, timezone, "MMMMEd"); - } else { - formatter_date = __util_time_date_formatter_get(NULL, timezone, skeleton); - } - formatter_time = __util_time_time_formatter_get(NULL, s_info.timeformat, timezone); - if (s_info.timeformat == APPCORE_TIME_FORMAT_12) { - formatter_ampm = __util_time_ampm_formatter_get(NULL, timezone); - } - } else { - if (!skeleton) { - formatter_date = s_info.formatter_date; - } else { - formatter_date = __util_time_date_formatter_get(NULL, timezone, skeleton); - } - formatter_time = s_info.formatter_time; - formatter_ampm = s_info.formatter_ampm; - } - - if (!s_info.formatter_time) { - s_info.formatter_time = __util_time_time_formatter_get(NULL, s_info.timeformat, NULL); - } - - __util_time_formatted_time_get(formatter_date, tt, buf_date, sizeof(buf_date)); - - /* time */ - if (s_info.timeformat == APPCORE_TIME_FORMAT_24) { - __util_time_formatted_time_get(formatter_time, tt, buf_time, sizeof(buf_time)-1); - } else { - __util_time_formatted_time_get(formatter_time, tt, buf_time, sizeof(buf_time)-1); - int ampm_len = __util_time_formatted_time_get(formatter_ampm, tt, buf_ampm, sizeof(buf_ampm)-1); - if (ampm_len > 4) { - if (st.tm_hour >= 0 && st.tm_hour < 12) { - snprintf(buf_ampm, sizeof(buf_ampm)-1, "AM"); - } else { - snprintf(buf_ampm, sizeof(buf_ampm)-1, "PM"); - } - } - } - - if (str_date != NULL) { - *str_date = strdup(buf_date); - } - - if (str_time != NULL) { - *str_time = strdup(buf_time); - } - - if (str_meridiem != NULL) { - *str_meridiem = strdup(buf_ampm); - } - - if (timezone != NULL) { - if (formatter_date != NULL) udat_close(formatter_date); - if (formatter_time != NULL) udat_close(formatter_time); - if (formatter_ampm != NULL) udat_close(formatter_ampm); - } -} - -static char *_get_locale(void) -{ - return strdup("en_US.UTF-8"); -} - -static int _is_korea_locale() -{ - int ret = 0; - char *locale = _get_locale(); - if (locale) { - if (strstr(locale,"ko_KR")) { - ret = 1; - } - free(locale); - } - - return ret; -} - -lock_error_e lock_time_update(void) -{ - Evas_Object *swipe_layout = NULL; - - struct tm st; - time_t tt = time(NULL); - localtime_r(&tt, &st); - - char *str_date = NULL; - char *str_time = NULL; - char *str_meridiem = NULL; - char time_buf[PATH_MAX] = {0,}; - char date_buf[PATH_MAX] = {0,}; - - swipe_layout = lock_default_swipe_layout_get(); - retv_if(!swipe_layout, LOCK_ERROR_FAIL); - - _util_time_get(1, 0, NULL, "MMMMEd", &str_date, &str_time, &str_meridiem); - if (s_info.timeformat == APPCORE_TIME_FORMAT_12) { - if (_is_korea_locale()) { - snprintf(time_buf, sizeof(time_buf), "<%s>%s %s", "small_font", str_meridiem, str_time); - } else { - snprintf(time_buf, sizeof(time_buf), "%s<%s> %s", str_time, "small_font", str_meridiem); - } - } else { - if (_is_korea_locale()) { - snprintf(time_buf, sizeof(time_buf), "%s", str_time); - } else { - snprintf(time_buf, sizeof(time_buf), "%s", str_time); - } - } - - snprintf(date_buf, sizeof(time_buf), "<%s>%s", "small_font", str_date); - - elm_object_part_text_set(swipe_layout, "txt.time", time_buf); - elm_object_part_text_set(swipe_layout, "txt.date", str_date); - - free(str_date); - free(str_time); - free(str_meridiem); - - return LOCK_ERROR_OK; -} - -static UDateTimePatternGenerator *__util_time_generator_get(void *data) -{ - UErrorCode status = U_ZERO_ERROR; - UDateTimePatternGenerator *generator = NULL; - - retv_if(!s_info.timeregion_format, NULL); - - generator = udatpg_open(s_info.timeregion_format, &status); - if (U_FAILURE(status)) { - _E("udatpg_open() failed"); - generator = NULL; - return NULL; - } - return generator; -} - -static void _util_time_formatters_create(void *data) -{ - if (!s_info.generator) { - s_info.generator = __util_time_generator_get(NULL); - } - - if (!s_info.formatter_date) { - s_info.formatter_date = __util_time_date_formatter_get(NULL, NULL, "MMMMEd"); - } - - if (s_info.timeformat == APPCORE_TIME_FORMAT_12) { - if (!s_info.formatter_ampm) { - s_info.formatter_ampm = __util_time_ampm_formatter_get(NULL, NULL); - } - } - - if (!s_info.formatter_time) { - s_info.formatter_time = __util_time_time_formatter_get(NULL, s_info.timeformat, NULL); - } -} - -static char *_util_time_timezone_id_get(void) -{ - char tz[1024] = {0,}; - char *timezone = NULL; - - memcpy(tz, "Asia/Seoul",strlen("Asia/Seoul")); - timezone = strdup(tz); - - _D("timezone is %s ", timezone); - return timezone; -} - -static char *_util_time_regionformat_get(void) -{ - return strdup("en_US"); -} - -static void _formatter_create(void) -{ - bool timeformat_24_bool = false; - - timeformat_24_bool = true; - - if (timeformat_24_bool) { - _D("TIMEFORMAT : 24"); - s_info.timeformat = APPCORE_TIME_FORMAT_24; - } else { - _D("TIMEFORMAT : 12"); - s_info.timeformat = APPCORE_TIME_FORMAT_12; - } - - if (!s_info.timeregion_format) { - s_info.timeregion_format = _util_time_regionformat_get(); - } - - if (!s_info.timezone_id) { - s_info.timezone_id = _util_time_timezone_id_get(); - } - - _util_time_formatters_create(NULL); - - s_info.is_initialized = 1; - _D("%d %s %s", s_info.timeformat, s_info.timeregion_format, s_info.timezone_id); -} - -static void _util_time_formatters_destroy(void) -{ - if (s_info.generator) { - udat_close(s_info.generator); - s_info.generator = NULL; - } - if (s_info.formatter_date) { - udat_close(s_info.formatter_date); - s_info.formatter_date = NULL; - } - if (s_info.formatter_time) { - udat_close(s_info.formatter_time); - s_info.formatter_time = NULL; - } - if (s_info.formatter_ampm) { - udat_close(s_info.formatter_ampm); - s_info.formatter_ampm = NULL; - } -} - -static void _formatter_destroy(void) -{ - if (s_info.timeregion_format) { - free(s_info.timeregion_format); - s_info.timeregion_format = NULL; - } - if (s_info.timezone_id) { - free(s_info.timezone_id); - s_info.timezone_id = NULL; - } - - _util_time_formatters_destroy(); - - s_info.is_initialized = 0; -} - -static void _util_time_vconf_changed_cb(keynode_t *key, void *data) -{ - int index = (int)data; - - _formatter_destroy(); - _formatter_create(); - - if (index == 1) { - s_info.need_sync = 1; - } -} - -static void _time_event_attach(void) -{ - int ret = 0; - - /* register vconf cbs */ - ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM, _util_time_vconf_changed_cb, (void*)3); - ret_if(ret != 0); - ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_TIMEZONE_INT, _util_time_vconf_changed_cb, (void*)4); - ret_if(ret != 0); -} - -static void _time_event_deattach(void) -{ - int ret = 0; - - /* unregister vconf cbs */ - ret = vconf_ignore_key_changed(VCONFKEY_TELEPHONY_SVC_ROAM, _util_time_vconf_changed_cb); - ret_if(ret != 0); - ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_TIMEZONE_INT, _util_time_vconf_changed_cb); - ret_if(ret != 0); -} - -static Eina_Bool _timer_cb(void *data) -{ - s_info.timer = NULL; - - if (LOCK_ERROR_OK != lock_time_update()) { - _E("Failed to update time & date"); - } - - if (s_info.is_timer_enabled == 1) { - _timer_add(); - } - return ECORE_CALLBACK_CANCEL; -} - -static void _timer_add(void) -{ - time_t tt; - struct tm st; - - tt = time(NULL); - localtime_r(&tt, &st); - - s_info.timer = ecore_timer_add(60 - st.tm_sec, _timer_cb, NULL); -} - -static void _timer_del(void) -{ - if (s_info.timer != NULL) { - ecore_timer_del(s_info.timer); - s_info.timer = NULL; - } -} - -void lock_time_timer_enable_set(int is_enable) -{ - _timer_del(); - s_info.is_timer_enabled = is_enable; - - if (is_enable == 1) { - _timer_add(); - } -} - -static void _util_time_reset_view(void) -{ - Evas_Object *swipe_layout = lock_default_swipe_layout_get(); - ret_if(!swipe_layout); - - elm_object_part_text_set(swipe_layout, "txt.time", ""); - elm_object_part_text_set(swipe_layout, "txt.date", ""); -} - -char *lock_time_formatted_noti_time_get(time_t ts) -{ - char *time_str = NULL; - char *curr_date = NULL; - char *noti_date = NULL; - - _util_time_get(0, time(NULL), NULL, UDAT_YEAR_NUM_MONTH_DAY, &curr_date, NULL, NULL); - _util_time_get(0, ts, NULL, UDAT_YEAR_NUM_MONTH_DAY, ¬i_date, NULL, NULL); - - if (curr_date != NULL && noti_date != NULL) { - if (strcmp(curr_date, noti_date)) { - char *date = NULL; - _util_time_get(0, ts, NULL, UDAT_ABBR_MONTH_DAY, &date, NULL, NULL); - free(curr_date); - free(noti_date); - return date; - } - } - - if (s_info.timeformat == APPCORE_TIME_FORMAT_24) { - _util_time_get(0, ts, NULL, UDAT_HOUR_MINUTE , NULL, &time_str, NULL); - if (time_str) { - return time_str; - } - } else { - struct tm st; - localtime_r(&ts, &st); - _util_time_get(0, ts, NULL, UDAT_HOUR_MINUTE , NULL, &time_str, NULL); - - char buf_ampm[512] = {0,}; - int ampm_len = __util_time_formatted_time_get(s_info.formatter_ampm, ts, buf_ampm, sizeof(buf_ampm) - 1); - if (ampm_len > 4) { - if (st.tm_hour >= 0 && st.tm_hour < 12) { - snprintf(buf_ampm, sizeof(buf_ampm)-1, "AM"); - } else { - snprintf(buf_ampm, sizeof(buf_ampm)-1, "PM"); - } - } - - char time[PATH_MAX]; - - if (_is_korea_locale()) { - snprintf(time, sizeof(time), "%s %s", buf_ampm, time_str); - } else { - snprintf(time, sizeof(time), "%s %s", time_str, buf_ampm); - } - - free(time_str); - - return strdup(time); - } - - return NULL; -} - -void lock_time_resume(void) -{ - if (s_info.need_sync == 1) { - _formatter_destroy(); - _formatter_create(); - s_info.need_sync = 0; - } - - if (LOCK_ERROR_OK != lock_time_update()) { - _E("Failed to update time & date"); - } - - lock_time_timer_enable_set(1); -} - -void lock_time_pause(void) -{ - _util_time_reset_view(); - lock_time_timer_enable_set(0); -} - -void lock_time_init(void) -{ - _formatter_create(); - _time_event_attach(); - - if (LOCK_ERROR_OK != lock_time_update()) { - _E("Failed to update time & date"); - } - - lock_time_timer_enable_set(1); -} - -void lock_time_fini(void) -{ - _formatter_destroy(); - _time_event_deattach(); - - lock_time_timer_enable_set(0); -} diff --git a/src/lockscreen.c b/src/lockscreen.c old mode 100755 new mode 100644 index e8c54d9..9c3b23d --- a/src/lockscreen.c +++ b/src/lockscreen.c @@ -20,258 +20,37 @@ #include #include #include -#include #include -#include -#include -#include -#include #include "lockscreen.h" #include "log.h" -#include "property.h" -#include "window.h" -#include "background_view.h" -#include "default_lock.h" -#include "dbus.h" - -#define LOCK_CONTROL_TYPE_KEY "lock_type" -#define LOCK_CONTROL_TYPE_VALUE_RECOVERY "recovery_lock" -#define LOCK_CONTROL_KEY "lock_op" -#define LOCK_CONTROL_VALUE_START_READY "start_ready" - -#define LOCK_LCD_OFF_TIMEOUT_TIME 10 - -static struct _s_info { - Elm_Theme *theme; - Ecore_Timer *lcd_off_timer; - int lock_type; - int lcd_off_count; - -} s_info = { - .theme = NULL, - .lcd_off_timer = NULL, - .lock_type = 0, - .lcd_off_count = 0, -}; - -Elm_Theme *lockscreen_theme_get(void) -{ - return s_info.theme; -} - -int lockscreen_setting_lock_type_get(void) -{ - return s_info.lock_type; -} - -Ecore_Timer *lockscreen_lcd_off_timer_get(void) -{ - return s_info.lcd_off_timer; -} - -int lockscreen_lcd_off_count_get(void) -{ - return s_info.lcd_off_count; -} - -void lockscreen_feedback_tap_play(void) -{ - if (!lock_property_sound_touch_get()) { - return; - } - - feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TAP); -} - -static Eina_Bool _lcd_off_timer_cb(void *data) -{ - int ret = 0; - - ret = display_change_state(LCD_OFF); - if (ret != 0) { - _E("Failed to change LCD state : LCD_OFF(%d)", ret); - } else { - _I("lcd off : %dsec", LOCK_LCD_OFF_TIMEOUT_TIME); - } - - return ECORE_CALLBACK_CANCEL; -} - -void lockscreen_lcd_off_timer_set(void) -{ - if (s_info.lcd_off_timer) { - ecore_timer_del(s_info.lcd_off_timer); - s_info.lcd_off_timer = NULL; - } - - s_info.lcd_off_timer = ecore_timer_add(LOCK_LCD_OFF_TIMEOUT_TIME, _lcd_off_timer_cb, NULL); -} - -void lockscreen_lcd_off_timer_reset(void) -{ - if (s_info.lcd_off_timer) { - ecore_timer_reset(s_info.lcd_off_timer); - } -} - -void lockscreen_lcd_off_timer_unset(void) -{ - if (s_info.lcd_off_timer) { - ecore_timer_del(s_info.lcd_off_timer); - s_info.lcd_off_timer = NULL; - _I("unset lcd off timer"); - } -} - -void lockscreen_lcd_off_count_raise(void) -{ - if (s_info.lcd_off_count < 3) { - _D("count for lcd off timer : %d", s_info.lcd_off_count); - lockscreen_lcd_off_timer_reset(); - s_info.lcd_off_count++; - } -} - -void lockscreen_lcd_off_count_reset(void) -{ - _D("lcd off count reset : %d -> 0", s_info.lcd_off_count); - s_info.lcd_off_count = 0; -} - -static void _init_theme(void) -{ - s_info.theme = elm_theme_new(); - elm_theme_ref_set(s_info.theme, NULL); - elm_theme_extension_add(s_info.theme, EDJE_DIR"index.edj"); -} - -static void _fini_theme(void) -{ - elm_theme_extension_del(s_info.theme, EDJE_DIR"index.edj"); - elm_theme_free(s_info.theme); - s_info.theme = NULL; -} +#include "main_ctrl.h" static Eina_Bool _lock_idler_cb(void *data) { - _init_theme(); - - if (LOCK_ERROR_OK != lock_default_lock_init()) { - _E("Failed to initialize default lockscreen"); - return ECORE_CALLBACK_CANCEL; - } - - /* register callback func. : key sound, touch sound, rotation */ - lock_property_register(NULL); - - /* initialize dbus */ - lock_dbus_init(NULL); - - feedback_initialize(); - - lockscreen_lcd_off_timer_set(); - -#if 0 - /* set rotation changed cb */ - if (elm_win_wm_rotation_supported_get(win)) { - int rots[4] = { 0, }; - elm_win_wm_rotation_available_rotations_set(win, rots, 0); - } -#endif + lockscreen_main_ctrl_init(); return ECORE_CALLBACK_CANCEL; } -static void _back_key_cb(void *data, Evas_Object *obj, void *event_info) -{ - _D("%s", __func__); - - lockscreen_feedback_tap_play(); -} - bool _create_app(void *data) { - _D("%s", __func__); - + DBG("Lockscreen launch request."); elm_config_accel_preference_set("opengl"); + DBG("base scale : %f", elm_app_base_scale_get()); + DBG("edje scale : %f", edje_scale_get()); - Evas_Object *win = NULL; - Evas_Object *bg = NULL; - int locktype = 0; - int ret = 0; - - _D("base scale : %f", elm_app_base_scale_get()); - - /* Get lockscreen type */ - ret = lock_property_get_int(PROPERTY_TYPE_VCONFKEY, VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &locktype); - if (ret != LOCK_ERROR_OK) { - _E("Failed to get lockscreen type. Set default lockscreen."); - locktype = SETTING_SCREEN_LOCK_TYPE_SWIPE; - } - _D("lockscreen type : %d", locktype); - s_info.lock_type = locktype; - - /* Create lockscreen window */ - win = lock_window_create(locktype); - retv_if(!win, false); - - /* Create lockscreen BG */ - bg = lock_background_view_bg_create(win); - if (!bg) { - _E("Failed to create BG"); - } - - evas_object_show(win); - + /* Quickfix: run real creation in idler since running device/display API here + * causes SIGSEGV */ ecore_idler_add(_lock_idler_cb, NULL); - eext_object_event_callback_add(win, EEXT_CALLBACK_BACK, _back_key_cb, NULL); - return true; } -static void _app_control(app_control_h control, void *data) -{ - char *control_val = NULL; - - app_control_get_extra_data(control, LOCK_CONTROL_TYPE_KEY, &control_val); - _I("control value : %s", control_val); - - if (control_val) { - free(control_val); - control_val = NULL; - } -} - void _terminate_app(void *data) { - _D("%s", __func__); - - lock_default_lock_fini(); - - lock_property_unregister(); - feedback_deinitialize(); - lock_dbus_fini(NULL); - lock_window_destroy(); - - _fini_theme(); -} - -void _pause_app(void *user_data) -{ - _D("%s", __func__); -} - -void _resume_app(void *user_data) -{ - _D("%s", __func__); -} - -static void _language_changed(void *data) -{ - _D("%s", __func__); + DBG("Lockscreen terminated request."); } int main(int argc, char *argv[]) @@ -279,23 +58,13 @@ int main(int argc, char *argv[]) int ret = 0; ui_app_lifecycle_callback_s lifecycle_callback = {0,}; - app_event_handler_h handlers[5] = {NULL, }; lifecycle_callback.create = _create_app; lifecycle_callback.terminate = _terminate_app; - lifecycle_callback.pause = _pause_app; - lifecycle_callback.resume = _resume_app; - lifecycle_callback.app_control = _app_control; - - ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, NULL); - ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, NULL); - ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, NULL); - ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, (void *)_language_changed, NULL); - ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, NULL); ret = ui_app_main(argc, argv, &lifecycle_callback, NULL); if (ret != APP_ERROR_NONE) { - _E("app_main() is failed. err = %d", ret); + ERR("ui_app_main failed: %s", get_error_message(ret)); } return ret; diff --git a/src/main_ctrl.c b/src/main_ctrl.c new file mode 100644 index 0000000..1a188f1 --- /dev/null +++ b/src/main_ctrl.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2016 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 "log.h" +#include "main_ctrl.h" +#include "main_view.h" +#include "window.h" +#include "battery_ctrl.h" +#include "background.h" +#include "camera_ctrl.h" +#include "time_format_ctrl.h" +#include "util.h" +#include "sim_ctrl.h" +#include "display.h" +#include "events_ctrl.h" + +#include +#include + +static Evas_Object *win; +static Evas_Object *view; + +static void _view_unlocked(void *data, Evas_Object *obj, void *event) +{ + ui_app_exit(); +} + +static void _swipe_finished(void *data, Evas_Object *obj, void *event) +{ + /* When swipe finished play unlock animation and exit */ + evas_object_smart_callback_add(obj, SIGNAL_UNLOCK_ANIMATION_FINISHED, _view_unlocked, NULL); + lockscreen_main_view_unlock(obj); +} + +static Eina_Bool _lockscreen_main_ctrl_win_event_cb(void *data, Evas_Object *obj, Evas_Object *source, Evas_Callback_Type type, void *event_info) +{ + if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_TRUE; + Evas_Event_Key_Down *ev = event_info; + + if (!strcmp(ev->key, "XF86PowerOff") || !strcmp(ev->key, "XF86Menu")) { + lockscreen_time_format_ctrl_time_update(); + } + else if (!strcmp(ev->key, "XF86Back")) { + util_feedback_tap_play(); + } + + return EINA_TRUE; +} + +static void _lockcscreen_main_ctrl_win_touch_start_cb(void *data, Evas_Object *obj, void *event_info) +{ + lockscreen_display_timer_freeze(); +} + +static void _lockcscreen_main_ctrl_win_touch_end_cb(void *data, Evas_Object *obj, void *event_info) +{ + lockscreen_display_timer_renew(); +} + +int lockscreen_main_ctrl_init(void) +{ + win = lockscreen_window_create(); + if (!win) + FAT("elm_win_add failed."); + + view = lockscreen_main_view_create(win); + if (!view) + FAT("lockscreen_main_view_create failed."); + + if (lockscreen_background_init()) { + FAT("lockscreen_background_init failed. Background changes will not be available"); + } else { + if (!lockscreen_main_view_background_set(view, LOCKSCREEN_BACKGROUND_TYPE_DEFAULT, lockscreen_background_file_get())) + FAT("lockscreen_main_view_background_image_set failed"); + } + + if (lockscreen_display_init()) { + FAT("lockscreen_display_init failed. Display on/off changes will not be available."); + } else { + evas_object_smart_callback_add(win, SIGNAL_TOUCH_STARTED, _lockcscreen_main_ctrl_win_touch_start_cb, NULL); + evas_object_smart_callback_add(win, SIGNAL_TOUCH_ENDED, _lockcscreen_main_ctrl_win_touch_end_cb, NULL); + } + + lockscreen_window_content_set(view); + evas_object_smart_callback_add(view, SIGNAL_SWIPE_GESTURE_FINISHED, _swipe_finished, NULL); + elm_object_event_callback_add(win, _lockscreen_main_ctrl_win_event_cb, NULL); + + // init subcontrollers + if (lock_battery_ctrl_init(view)) + FAT("lock_battery_ctrl_init failed. Battery information will not be available"); + + if (lockscreen_camera_ctrl_init(view)) + FAT("lockscreen_camera_ctrl_init failed. Camera quickshot will not be available"); + + if (lockscreen_time_format_ctrl_init(view)) + FAT("lockscreen_time_format_ctrl_init failed. Time format changes will not be available"); + + if (lockscreen_sim_ctrl_init(view)) + FAT("lockscreen_sim_ctrl_init failed. Sim PLMN updates will not be available"); + + if (lockscreen_events_ctrl_init(view)) + FAT("lockscreen_events_ctrl_init failed. Lockscreen events will not be displayed"); + + return 0; +} + +void lockscreen_main_ctrl_shutdown(void) +{ + lockscreen_background_shutdown(); + evas_object_del(win); +} diff --git a/src/main_view.c b/src/main_view.c new file mode 100644 index 0000000..24a6faa --- /dev/null +++ b/src/main_view.c @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2016 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 "main_view.h" +#include "util.h" +#include "log.h" +#include "lockscreen.h" +#include "util_time.h" + +#include + +#define EMG_BUTTON_WIDTH 322 +#define PLMN_LABEL_STYLE_START "" +#define PLMN_LABEL_STYLE_END "" + +static Evas_Object *_swipe_layout_create(Evas_Object *parent) +{ + Evas_Object *swipe_layout = NULL; + if (!parent) return NULL; + + swipe_layout = elm_layout_add(parent); + + if (!elm_layout_file_set(swipe_layout, util_get_res_file_path(LOCK_EDJE_FILE), "swipe-lock")) { + ERR("elm_layout_file_set failed."); + evas_object_del(swipe_layout); + return NULL; + } + + evas_object_size_hint_weight_set(swipe_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(swipe_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + evas_object_show(swipe_layout); + + return swipe_layout; +} + +void lockscreen_main_view_part_content_set(Evas_Object *view, const char *part, Evas_Object *content) +{ + Evas_Object *swipe_layout = elm_object_part_content_get(view, "sw.swipe_layout"); + if (!swipe_layout) { + FAT("No sw.swipe_layout part"); + return; + } + if (!strcmp(PART_EVENTS, part)) { + elm_object_signal_emit(swipe_layout, "contextual,events,show", "lockscreen"); + } + elm_object_part_content_set(swipe_layout, part, content); +} + +Evas_Object *lockscreen_main_view_part_content_unset(Evas_Object *view, const char *part) +{ + Evas_Object *swipe_layout = elm_object_part_content_get(view, "sw.swipe_layout"); + if (!swipe_layout) { + FAT("No sw.swipe_layout part"); + return false; + } + if (!strcmp(PART_EVENTS, part)) { + elm_object_signal_emit(swipe_layout, "contextual,events,hide", "lockscreen"); + } + return elm_object_part_content_unset(swipe_layout, part); +} + +Evas_Object *lockscreen_main_view_part_content_get(Evas_Object *view, const char *part) +{ + Evas_Object *swipe_layout = elm_object_part_content_get(view, "sw.swipe_layout"); + if (!swipe_layout) { + FAT("No sw.swipe_layout part"); + return false; + } + return elm_object_part_content_get(swipe_layout, part); +} + +static Evas_Event_Flags _swipe_state_end(void *data, void *event_info) +{ + evas_object_smart_callback_call(data, SIGNAL_SWIPE_GESTURE_FINISHED, NULL); + return EVAS_EVENT_FLAG_NONE; +} + +Evas_Object *lockscreen_main_view_create(Evas_Object *win) +{ + Evas_Object *layout = elm_layout_add(win); + if (!elm_layout_file_set(layout, util_get_res_file_path(LOCK_EDJE_FILE), "lockscreen")) { + FAT("Failed to set edje file for main view."); + return NULL; + } + + evas_object_show(layout); + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + + Evas_Object *swipe_layout = _swipe_layout_create(layout); + if (!swipe_layout) { + evas_object_del(layout); + return NULL; + } + elm_object_part_content_set(layout, "sw.swipe_layout", swipe_layout); + + Evas_Object *bg = elm_bg_add(layout); + elm_bg_option_set(bg, ELM_BG_OPTION_SCALE); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_part_content_set(layout, "sw.bg", bg); + + Evas_Object *gesture_layer = elm_gesture_layer_add(layout); + elm_gesture_layer_hold_events_set(gesture_layer, EINA_TRUE); + elm_gesture_layer_attach(gesture_layer, layout); + elm_gesture_layer_attach(gesture_layer, swipe_layout); + elm_gesture_layer_attach(gesture_layer, bg); + elm_gesture_layer_cb_set(gesture_layer, ELM_GESTURE_N_FLICKS, ELM_GESTURE_STATE_END, _swipe_state_end, layout); + evas_object_show(gesture_layer); + + return layout; +} + +bool lockscreen_main_view_background_set(Evas_Object *view, lockscreen_main_view_background_type type, const char *file) +{ + Evas_Object *bg = elm_object_part_content_get(view, "sw.bg"); + if (!bg) { + FAT("No sw.bg part"); + return false; + } + + if (!elm_bg_file_set(bg, file, NULL)) { + ERR("elm_bg_file_set failed: %s", file); + return false; + } + + switch (type) { + case LOCKSCREEN_BACKGROUND_TYPE_DEFAULT: + elm_object_signal_emit(view, "music_off", "lockscreen"); + break; + case LOCKSCREEN_BACKGROUND_TYPE_ALBUM_ART: + elm_object_signal_emit(view, "music_on", "lockscreen"); + break; + } + + return true; +} + +void lockscreen_main_view_battery_status_text_set(Evas_Object *view, const char *battery) +{ + Evas_Object *swipe_layout = elm_object_part_content_get(view, "sw.swipe_layout"); + if (!swipe_layout) { + FAT("No sw.swipe_layout part"); + return; + } + if (battery) { + elm_object_part_text_set(swipe_layout, "txt.battery", battery); + elm_object_signal_emit(swipe_layout, "show,txt,battery", "lockscreen"); + } else { + elm_object_signal_emit(swipe_layout, "hide,txt,battery", "lockscreen"); + elm_object_part_text_set(swipe_layout, "txt.battery", ""); + } +} + +void lockscreen_main_view_sim_status_text_set(Evas_Object *view, const char *text) +{ + Evas_Object *swipe_layout = elm_object_part_content_get(view, "sw.swipe_layout"); + if (!swipe_layout) { + FAT("No sw.swipe_layout part"); + return; + } + Evas_Object *label = NULL; + char buf[512] = { 0, }; + char *markup_text = NULL; + Evas_Object *tb = NULL; + Evas_Coord tb_w = 0; + + if (!text) { + elm_object_signal_emit(swipe_layout, "hide,txt,plmn", "lockscreen"); + return; + } + + label = elm_label_add(swipe_layout); + elm_object_scale_set(label, edje_scale_get() * 0.6); + markup_text = elm_entry_utf8_to_markup(text); + snprintf(buf, sizeof(buf), "%s%s%s", PLMN_LABEL_STYLE_START, markup_text, PLMN_LABEL_STYLE_END); + free(markup_text); + + elm_object_style_set(label, "slide_short"); + elm_label_wrap_width_set(label, 100); + elm_label_ellipsis_set(label, EINA_TRUE); + elm_label_slide_duration_set(label, 2); + elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_NONE); + + Evas_Object *label_edje = elm_layout_edje_get(label); + tb = (Evas_Object *)edje_object_part_object_get(label_edje, "elm.text"); + if (!tb) { + FAT("elm.text part not found in edje"); + } + + evas_object_textblock_size_native_get(tb, &tb_w, NULL); + + if ((tb_w > 0) && (tb_w > ELM_SCALE_SIZE(EMG_BUTTON_WIDTH))) { + elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_AUTO); + } + + elm_label_slide_go(label); + elm_object_text_set(label, buf); + + elm_object_part_content_set(swipe_layout, "txt.plmn", label); + elm_object_signal_emit(swipe_layout, "show,txt,plmn", "lockscreen"); + evas_object_show(label); +} + +static void _layout_unlocked(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + Evas_Object *swipe_layout = elm_object_part_content_get(data, "sw.swipe_layout"); + if (!swipe_layout) { + FAT("No sw.swipe_layout part"); + return; + } + evas_object_smart_callback_call(data, SIGNAL_UNLOCK_ANIMATION_FINISHED, NULL); + elm_object_signal_callback_del(swipe_layout, "unlock,anim,end", "swipe-layout", _layout_unlocked); +} + +void lockscreen_main_view_unlock(Evas_Object *view) +{ + Evas_Object *swipe_layout = elm_object_part_content_get(view, "sw.swipe_layout"); + if (!swipe_layout) { + FAT("No sw.swipe_layout part"); + return; + } + elm_object_signal_callback_add(swipe_layout, "unlock,anim,end", "swipe-layout", _layout_unlocked, view); + elm_object_signal_emit(swipe_layout, "unlock,anim,start", "lockscreen"); + elm_object_signal_emit(view, "bg,hide", "lockscreen"); +} + +static int _is_korea_locale(const char *locale) +{ + int ret = 0; + if (locale) { + if (strstr(locale,"ko_KR")) { + ret = 1; + } + } + return ret; +} + +void lockscreen_main_view_time_set(Evas_Object *view, const char *locale, const char *timezone, bool use24hformat, time_t time) +{ + Evas_Object *swipe_layout = elm_object_part_content_get(view, "sw.swipe_layout"); + if (!swipe_layout) { + FAT("No sw.swipe_layout part"); + return; + } + char buf[PATH_MAX] = {0,}; + char *str_date, *str_time, *str_meridiem; + + if (!util_time_formatted_time_get(time, locale, timezone, use24hformat, &str_time, &str_meridiem)) { + ERR("util_time_formatted_time_get failed"); + return; + } + if (!util_time_formatted_date_get(time, locale, timezone, "MMMMEd", &str_date)) { + ERR("util_time_formatted_date_get failed"); + free(str_time); + free(str_meridiem); + return; + } + + if (use24hformat) { + snprintf(buf, sizeof(buf), "%s", str_time); + } else { + if (_is_korea_locale(locale)) { + snprintf(buf, sizeof(buf), "<%s>%s %s", "small_font", str_meridiem, str_time); + } else { + snprintf(buf, sizeof(buf), "%s<%s> %s", str_time, "small_font", str_meridiem); + } + } + elm_object_part_text_set(swipe_layout, "txt.time", buf); + + snprintf(buf, sizeof(buf), "<%s>%s", "small_font", str_date); + elm_object_part_text_set(swipe_layout, "txt.date", buf); + + snprintf(buf, sizeof(buf), "%s %s", str_time, str_date); + elm_object_part_text_set(swipe_layout, "txt.timedate", buf); + + free(str_date); + free(str_time); + free(str_meridiem); +} diff --git a/src/minicontrollers.c b/src/minicontrollers.c new file mode 100644 index 0000000..8731698 --- /dev/null +++ b/src/minicontrollers.c @@ -0,0 +1,189 @@ +/* + * Copyright (c) 2016 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 "log.h" +#include "minicontrollers.h" + +typedef struct { + const char *name; + int width, height; +} minicontroller_info_t; + +static Eina_List *active_minicontroller; +int LOCKSCREEN_EVENT_MINICONTROLLERS_CHANGED, init_count; + +static int _lockscreen_minicontroller_search(const void *data1, const void *data2); + +static minicontroller_info_t *_minicontroller_create(const char *name, int w, int h) +{ + minicontroller_info_t *ret = calloc(1, sizeof(minicontroller_info_t)); + + ret->name = eina_stringshare_add(name); + ret->width = w; + ret->height = h; + + return ret; +} + +static void _minicontroller_destroy(minicontroller_info_t *info) +{ + eina_stringshare_del(info->name); + free(info); +} + +static void _minicontroller_start_handle(const char *name, int w, int h) +{ + /** FIXME Since minicontroller API do not allow to filter minicontrollers + * targeted for lockscreen we just asume that interesting minicontrollers + * has proper suffix in its name */ + if (name && strstr(name, "LOCKSCREEN")) { + minicontroller_info_t *info = eina_list_search_unsorted(active_minicontroller, _lockscreen_minicontroller_search, name); + if (name) { + info = _minicontroller_create(name, w, h); + active_minicontroller = eina_list_append(active_minicontroller, info); + ecore_event_add(LOCKSCREEN_EVENT_MINICONTROLLERS_CHANGED, NULL, NULL, NULL); + } + } +} + +static void _minicontroller_stop_handle(const char *name) +{ + if (name) { + minicontroller_info_t *info = eina_list_search_unsorted(active_minicontroller, _lockscreen_minicontroller_search, name); + if (info) { + active_minicontroller = eina_list_remove(active_minicontroller, info); + _minicontroller_destroy(info); + ecore_event_add(LOCKSCREEN_EVENT_MINICONTROLLERS_CHANGED, NULL, NULL, NULL); + } + } +} + +static void _minicontroller_geometry_from_bundle_get(bundle *event_arg, int *width, int *height) +{ + int *val; + size_t val_size; + if (!event_arg) + return; + int ret = bundle_get_byte(event_arg, "width", (void**)&val, &val_size); + if (ret == BUNDLE_ERROR_NONE) { + if (width) *width = *val; + } + ret = bundle_get_byte(event_arg, "height", (void**)&val, &val_size); + if (ret == BUNDLE_ERROR_NONE) { + if (height) *height = *val; + } +} + +static void _minicontroler_event(minicontrol_event_e event, const char *minicontrol_name, bundle *event_arg, void *data) +{ + int w = 0, h = 0; + if (!minicontrol_name) + return; + + DBG("Available minicontroller: %s", minicontrol_name); + + switch (event) { + case MINICONTROL_EVENT_START: + _minicontroller_geometry_from_bundle_get(event_arg, &w, &h); + _minicontroller_start_handle(minicontrol_name, w, h); + break; + case MINICONTROL_EVENT_STOP: + _minicontroller_stop_handle(minicontrol_name); + break; + default: + DBG("Unahandled minicontroller event: %d for %s", event, minicontrol_name); + break; + } +} + +int lockscreen_minicontrollers_init(void) +{ + if (!init_count) { + LOCKSCREEN_EVENT_MINICONTROLLERS_CHANGED = ecore_event_type_new(); + int ret = minicontrol_viewer_set_event_cb(_minicontroler_event, NULL); + if (ret != MINICONTROL_ERROR_NONE) { + ERR("minicontrol_viewer_set_event_cb failed: %s", get_error_message(ret)); + return 1; + } + } + init_count++; + return 0; +} + +void lockscreen_minicontrollers_shutdown(void) +{ + minicontroller_info_t *info; + if (init_count) { + init_count--; + if (!init_count) { + int ret = minicontrol_viewer_unset_event_cb(); + if (ret != MINICONTROL_ERROR_NONE) { + ERR("minicontrol_viewer_unset_event_cb failed: %s", get_error_message(ret)); + } + EINA_LIST_FREE(active_minicontroller, info) { + _minicontroller_destroy(info); + } + active_minicontroller = NULL; + } + } +} + +static int _lockscreen_minicontroller_search(const void *data1, const void *data2) +{ + const minicontroller_info_t *info = data1; + const char *name = data2; + return strcmp(name, info->name); +} + +Evas_Object *lockscreen_minicontrollers_minicontroller_create(const char *name, Evas_Object *parent) +{ + minicontroller_info_t *info = eina_list_search_unsorted(active_minicontroller, _lockscreen_minicontroller_search, name); + + if (!info) { + ERR("Invalid minicontroller name: %s", name); + return NULL; + } + + Evas_Object *ret = minicontrol_viewer_add(parent, info->name); + evas_object_size_hint_min_set(ret, info->width, info->height); + evas_object_show(ret); + return ret; +} + +Eina_List *lockscreen_minicontrollers_list_get(void) +{ + Eina_List *ret = NULL, *l; + minicontroller_info_t *info; + + EINA_LIST_FOREACH(active_minicontroller, l, info) { + ret = eina_list_append(ret, info->name); + } + return ret; +} + +bool lockscreen_minicontrollers_minicontroller_stop(const char *name) +{ + int ret = minicontrol_viewer_send_event(name, MINICONTROL_VIEWER_EVENT_HIDE, NULL); + if (ret != MINICONTROL_ERROR_NONE) { + ERR("minicontrol_viewer_send_event failed: %s", get_error_message(ret)); + return false; + } + return true; +} diff --git a/src/property.c b/src/property.c deleted file mode 100644 index 8df1a77..0000000 --- a/src/property.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 "lockscreen.h" -#include "log.h" -#include "property.h" -#include "default_lock.h" - -static struct _s_info { - bool is_sound_lock; - bool is_sound_touch; - bool is_rotation_enabled; -} s_info = { - .is_sound_lock = false, - .is_sound_touch = false, - .is_rotation_enabled = false, -}; - -bool lock_property_sound_lock_get(void) -{ - return s_info.is_sound_lock; -} - -bool lock_property_sound_touch_get(void) -{ - return s_info.is_sound_touch; -} - -bool lock_property_rotation_enabled_get(void) -{ - return s_info.is_rotation_enabled; -} - -lock_error_e lock_property_get_string(property_type_e type, void *key, char **str) -{ - int ret = 0; - - switch(type) { - case PROPERTY_TYPE_SYSTEM_SETTINGS : - ret = system_settings_get_value_string((int)key, &(*str)); - if (SYSTEM_SETTINGS_ERROR_NONE != ret) { - ret = -1; - } - _D("SYSTEM SETTINGS : key(%d), val(%s)", (int)key, *str); - break; - case PROPERTY_TYPE_SYSTEM_INFO : - ret = system_info_get_platform_string((char *)key, &(*str)); - if (SYSTEM_INFO_ERROR_NONE != ret) { - ret = -1; - } - break; - _D("SYSTEM INFO : key(%s), val(%s)", (char *)key, *str); - case PROPERTY_TYPE_RUNTIME_INFO : - ret = runtime_info_get_value_string((int)key, &(*str)); - if (RUNTIME_INFO_ERROR_NONE != ret) { - ret = -1; - } - _D("RUNTIME INFO : key(%d), val(%s)", (int)key, *str); - break; - case PROPERTY_TYPE_VCONFKEY : - *str = vconf_get_str((char *)key); - if (!(*str)) { - ret = -1; - } - _D("vconfkey : key(%s), val(%s)", (char *)key, *str); - break; - default : - _E("Failed to get property. type error(%d)", type); - return LOCK_ERROR_FAIL; - } - - if (ret == -1) { - _E("Failed to get property : type(%d), ret(%d)", type, ret); - return LOCK_ERROR_FAIL; - } - - return LOCK_ERROR_OK; -} - -lock_error_e lock_property_get_bool(property_type_e type, void *key, void *val) -{ - int ret = 0; - - switch(type) { - case PROPERTY_TYPE_SYSTEM_SETTINGS : - ret = system_settings_get_value_bool((int)key, val); - if (SYSTEM_SETTINGS_ERROR_NONE != ret) { - ret = -1; - } - _D("SYSTEM SETTINGS : key(%d), val(%d)", (int)key, *((bool *)val)); - break; - case PROPERTY_TYPE_SYSTEM_INFO : - ret = system_info_get_platform_bool((char *)key, val); - if (SYSTEM_INFO_ERROR_NONE != ret) { - ret = -1; - } - _D("SYSTEM INFO : key(%s), val(%d)", (char *)key, *((bool *)val)); - break; - case PROPERTY_TYPE_RUNTIME_INFO : - ret = runtime_info_get_value_bool((int)key, val); - if (RUNTIME_INFO_ERROR_NONE != ret) { - ret = -1; - } - _D("RUNTIME INFO : key(%d), val(%d)", (int)key, *((bool *)val)); - break; - case PROPERTY_TYPE_VCONFKEY : - ret = vconf_get_bool((char *)key, val); - if (ret < 0) { - ret = -1; - } - _D("vconfkey : key(%s), val(%d)", (char *)key, *((int *)val)); - break; - default : - _E("Failed to get property. type error(%d)", type); - return LOCK_ERROR_FAIL; - } - - if (ret == -1) { - _E("Failed to get property : type(%d), ret(%d)", type, ret); - return LOCK_ERROR_FAIL; - } - - return LOCK_ERROR_OK; -} - -lock_error_e lock_property_get_int(property_type_e type, void *key, int *val) -{ - int ret = 0; - - switch(type) { - case PROPERTY_TYPE_SYSTEM_SETTINGS : - ret = system_settings_get_value_int((int)key, val); - if (SYSTEM_SETTINGS_ERROR_NONE != ret) { - ret = -1; - } - _D("SYSTEM SETTINGS : key(%d), val(%d)", (int)key, *val); - break; - case PROPERTY_TYPE_SYSTEM_INFO : - ret = system_info_get_platform_int((char *)key, val); - if (SYSTEM_INFO_ERROR_NONE != ret) { - ret = -1; - } - _D("SYSTEM INFO : key(%s), val(%d)", (char *)key, *val); - break; - case PROPERTY_TYPE_RUNTIME_INFO : - ret = runtime_info_get_value_int((int)key, &(*val)); - if (RUNTIME_INFO_ERROR_NONE != ret) { - ret = -1; - } - _D("RUNTIME INFO : key(%d), val(%d)", (int)key, *val); - break; - case PROPERTY_TYPE_VCONFKEY : - ret = vconf_get_int((char *)key, &(*val)); - if (ret < 0) { - ret = -1; - } - _D("vconfkey : key(%s), val(%d)", (char *)key, *val); - break; - default : - _E("Failed to get property. type error(%d)", type); - return LOCK_ERROR_FAIL; - } - - if (ret == -1) { - _E("Failed to get property : type(%d), ret(%d)", type, ret); - return LOCK_ERROR_FAIL; - } - - return LOCK_ERROR_OK; -} - -void lock_property_register(void *data) -{ - bool val = false; - - s_info.is_sound_lock = val; - s_info.is_sound_touch = val; - s_info.is_rotation_enabled = val; - - _D("sound_lock(%d), sound_touch(%d), rotation(%d)", s_info.is_sound_lock, s_info.is_sound_touch, s_info.is_rotation_enabled); -} - -void lock_property_unregister(void) -{ - _D("unregister property cb"); -} diff --git a/src/sim.c b/src/sim.c new file mode 100644 index 0000000..2c59eab --- /dev/null +++ b/src/sim.c @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2016 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 "log.h" +#include "util.h" +#include "sim.h" + +#include +#include + +static telephony_handle_list_s handle_list; +static char *sim_plmn[LOCKSCREEN_SIM_MAX]; +static int init_count; +int LOCKSCREEN_EVENT_SIM_STATUS_CHANGED; + +static const telephony_noti_e notis[] = { + TELEPHONY_NOTI_SIM_STATUS, + TELEPHONY_NOTI_NETWORK_NETWORK_NAME, + TELEPHONY_NOTI_NETWORK_SERVICE_STATE, +}; + +static char *_sim_plmn_get(telephony_h handle) +{ + char *network_name; + + int ret = telephony_network_get_network_name(handle, &network_name); + if (ret != TELEPHONY_ERROR_NONE) { + ERR("telephony_network_get_network_name failed: %s", get_error_message(ret)); + return NULL; + } + + return network_name; +} + +static char *_sim_spn_get(telephony_h handle) +{ + char *spn_name; + + int ret = telephony_sim_get_spn(handle, &spn_name); + if (ret != TELEPHONY_ERROR_NONE) { + ERR("telephony_sim_get_spn failed: %s", get_error_message(ret)); + return NULL; + } + return spn_name; +} + +static char *_sim_state_text_for_sim_get(telephony_h handle) +{ + int ret; + telephony_network_service_state_e service_state; + telephony_network_name_option_e name_option; + + char *plmn = NULL; + char *spn = NULL; + char buf[1024] = { 0, }; + + /* get service state */ + ret = telephony_network_get_service_state(handle, &service_state); + if (ret != TELEPHONY_ERROR_NONE) { + ERR("telephony_network_get_service_state failed: %s", get_error_message(ret)); + return NULL; + } + + switch (service_state) { + case TELEPHONY_NETWORK_SERVICE_STATE_IN_SERVICE: + /* get network name option */ + ret = telephony_network_get_network_name_option(handle, &name_option); + if (ret != TELEPHONY_ERROR_NONE) { + ERR("telephony_network_get_network_name_option failed: %s", get_error_message(ret)); + return NULL; + } + + switch (name_option) { + case TELEPHONY_NETWORK_NAME_OPTION_SPN: + spn = _sim_spn_get(handle); + if (spn != NULL && spn[0] != 0) { + INF("PLMN/SPN - Sim %p using SPN: %s", handle, spn); + snprintf(buf, sizeof(buf), "%s", spn); + } + break; + case TELEPHONY_NETWORK_NAME_OPTION_NETWORK: + plmn = _sim_plmn_get(handle); + if (plmn != NULL && plmn[0] != 0) { + INF("PLMN/SPN - Sim %p using PLMN: %s", handle, plmn); + snprintf(buf, sizeof(buf), "%s", plmn); + } + break; + case TELEPHONY_NETWORK_NAME_OPTION_ANY: + spn = _sim_spn_get(handle); + plmn = _sim_plmn_get(handle); + if (spn != NULL && spn[0] != 0 && plmn != NULL && plmn[0] != 0) { + INF("PLMN/SPN - Sim %p using SPN: %s, PLMN: %s", handle, spn, plmn); + snprintf(buf, sizeof(buf), "%s - %s", plmn, spn); + } else if (spn != NULL && spn[0] != 0) { + INF("PLMN/SPN - Sim %p using SPN: %s", handle, spn); + snprintf(buf, sizeof(buf), "%s", spn); + } else if (plmn != NULL && plmn[0] != 0) { + INF("PLMN/SPN - Sim %p using PLMN: %s", handle, plmn); + snprintf(buf, sizeof(buf), "%s", plmn); + } + break; + default: + ERR("Invalid name option[%d]", name_option); + plmn = _sim_plmn_get(handle); + if (plmn != NULL && plmn[0] != 0) { + INF("PLMN/SPN - Sim %p using PLMN: %s", handle, plmn); + snprintf(buf, sizeof(buf), "%s", plmn); + } + break; + } + break; + case TELEPHONY_NETWORK_SERVICE_STATE_OUT_OF_SERVICE: + snprintf(buf, sizeof(buf), "%s", _("IDS_COM_BODY_NO_SERVICE")); + break; + case TELEPHONY_NETWORK_SERVICE_STATE_EMERGENCY_ONLY: + snprintf(buf, sizeof(buf), "%s", _("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY")); + break; + default: + snprintf(buf, sizeof(buf), "%s", _("IDS_COM_BODY_NO_SERVICE")); + break; + } + + return strdup(buf); +} + +static void _update_sim_info(bool emit) +{ + int i; + telephony_sim_state_e state; + + for (i = 0; (i < handle_list.count) && (i < LOCKSCREEN_SIM_MAX); i++) + { + char *out = NULL; + + int ret = telephony_sim_get_state(handle_list.handle[i], &state); + if (ret != TELEPHONY_ERROR_NONE) + continue; + + if (state == TELEPHONY_SIM_STATE_UNAVAILABLE) + out = NULL; + else { + out = _sim_state_text_for_sim_get(handle_list.handle[i]); + } + + free(sim_plmn[i]); + sim_plmn[i] = out; + } + + if (emit) ecore_event_add(LOCKSCREEN_EVENT_SIM_STATUS_CHANGED, NULL, NULL, NULL); +} + +static void _on_telephony_state_changed_cb(telephony_state_e state, void *user_data) +{ + _update_sim_info(true); +} + +static void _on_sim_info_changed_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data) +{ + _update_sim_info(true); +} + +int lockscreen_sim_init(void) +{ + int i; + if (!init_count) { + LOCKSCREEN_EVENT_SIM_STATUS_CHANGED = ecore_event_type_new(); + int ret = telephony_init(&handle_list); + if (ret != TELEPHONY_ERROR_NONE) + { + ERR("telephony_init failed: %s", get_error_message(ret)); + return -1; + } + + ret = telephony_set_state_changed_cb(_on_telephony_state_changed_cb, NULL); + if (ret != TELEPHONY_ERROR_NONE) { + telephony_deinit(&handle_list); + ERR("telephony_set_state_changed_cb failed: %s", get_error_message(ret)); + return -1; + } + + for (i = 0; (i < handle_list.count) && (i < LOCKSCREEN_SIM_MAX); i++) + { + int j; + for (j = 0; j < SIZE(notis); j++) + { + ret = telephony_set_noti_cb(handle_list.handle[i], notis[j], _on_sim_info_changed_cb, NULL); + if (ret != TELEPHONY_ERROR_NONE) { + ERR("telephony_set_noti_cb failed: %s", get_error_message(ret)); + } + } + } + + _update_sim_info(false); + } + init_count++; + return 0; +} + +void lockscreen_sim_shutdown(void) +{ + if (init_count) { + init_count--; + if (!init_count) { + int i; + for (i = 0; i < LOCKSCREEN_SIM_MAX; i++) { + free(sim_plmn[i]); + sim_plmn[i] = NULL; + } + telephony_deinit(&handle_list); + telephony_unset_state_changed_cb(_on_telephony_state_changed_cb); + } + } +} + +const char *lockscreen_sim_get_plmn(lockscreen_sim_num_e num) +{ + return sim_plmn[num]; +} diff --git a/src/sim_ctrl.c b/src/sim_ctrl.c new file mode 100644 index 0000000..2ad6cda --- /dev/null +++ b/src/sim_ctrl.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2009-2014 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 "log.h" +#include "main_view.h" +#include "sim.h" + +static Ecore_Event_Handler *handler; +static Evas_Object *main_view; + +static void _sim_state_view_update() +{ + const char *sim1, *sim2; + char buf[128] = {0,}; + + sim1 = lockscreen_sim_get_plmn(LOCKSCREEN_PRIMARY_SIM); + sim2 = lockscreen_sim_get_plmn(LOCKSCREEN_SECONDARY_SIM); + + if (sim1 && sim2) { + snprintf(buf, sizeof(buf), "%s / %s", sim1, sim2); + } else if (sim1) { + snprintf(buf, sizeof(buf), "%s", sim1); + } else if (sim2) { + snprintf(buf, sizeof(buf), "%s", sim2); + } + + lockscreen_main_view_sim_status_text_set(main_view, buf); +} + +static Eina_Bool _sim_status_changed(void *data, int type, void *event_info) +{ + _sim_state_view_update(); + return EINA_TRUE; +} + +int lockscreen_sim_ctrl_init(Evas_Object *view) +{ + if (lockscreen_sim_init()) { + ERR("lockscreen_sim_init failed"); + return 1; + } + + handler = ecore_event_handler_add(LOCKSCREEN_EVENT_SIM_STATUS_CHANGED, _sim_status_changed, NULL); + main_view = view; + _sim_state_view_update(); + return 0; +} + +void lockscreen_sim_ctrl_shutdown() +{ + ecore_event_handler_del(handler); + lockscreen_sim_shutdown(); +} diff --git a/src/sim_state.c b/src/sim_state.c deleted file mode 100644 index cea07b0..0000000 --- a/src/sim_state.c +++ /dev/null @@ -1,686 +0,0 @@ -/* - * Copyright (c) 2009-2014 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 - -#if TIZEN_BUILD_TARGET -//#include -#endif - -#include "lockscreen.h" -#include "log.h" -#include "sim_state.h" -#include "property.h" -#include "default_lock.h" - -#define NO_SIM_LEN 8 -#define PLMN_LENGTH 6 -#define PLMN_SPN_LENGTH 32 -#define EMG_BUTTON_WIDTH 322 - -#define TAPI_HANDLE_MAX 2 - -#define PLMN_LABEL_STYLE_START "" -#define PLMN_LABEL_STYLE_END "" - -static struct _s_info { - TapiHandle *handle[TAPI_HANDLE_MAX+1]; - Eina_Bool sim_card_ready[2]; - - Evas_Object *layout; - Evas_Object *operator_name; - - int call_state; // 0:none, 1:call -} s_info = { - .handle[0] = NULL, - .handle[1] = NULL, - .handle[2] = NULL, - .sim_card_ready[0] = EINA_FALSE, - .sim_card_ready[1] = EINA_FALSE, - .layout = NULL, - .operator_name = NULL, - .call_state = 0, -}; - -static void _sim_callback_register(void); -static void _sim_callback_unregister(void); - -static void _operator_name_slide_mode_set(Evas_Object *label) -{ - Evas_Object *label_edje = NULL; - Evas_Object *tb = NULL; - Evas_Coord tb_w = 0; - - ret_if(!label); - - elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_NONE); - - label_edje = elm_layout_edje_get(label); - ret_if(!label_edje); - - tb = (Evas_Object*)edje_object_part_object_get(label_edje, "elm.text"); - ret_if(!tb); - - evas_object_textblock_size_native_get(tb, &tb_w, NULL); - - if ((tb_w > 0) && (tb_w > _X(EMG_BUTTON_WIDTH))) { - elm_label_slide_mode_set(label, ELM_LABEL_SLIDE_MODE_AUTO); - } - - elm_label_slide_go(label); -} - -static void _operator_sliding_label_create(Evas_Object *layout, char *text) -{ - Evas_Object *label = NULL; - char buf[512] = { 0, }; - char *markup_text = NULL; - - label = elm_label_add(layout); - ret_if(!label); - - markup_text = elm_entry_utf8_to_markup(text); - snprintf(buf, sizeof(buf), "%s%s%s", PLMN_LABEL_STYLE_START, markup_text, PLMN_LABEL_STYLE_END); - free(markup_text); - - elm_object_style_set(label, "slide_short"); - elm_label_wrap_width_set(label, 100); - elm_label_ellipsis_set(label, EINA_TRUE); - elm_label_slide_duration_set(label, 2); - _operator_name_slide_mode_set(label); - - elm_object_text_set(label, buf); - - elm_object_part_content_set(layout, "txt.plmn", label); - evas_object_show(label); - - s_info.operator_name = label; -} - -static int _sim_controller_get_call_state(void) -{ - int value = 0; - int ret = 0; - - ret = lock_property_get_int(PROPERTY_TYPE_VCONFKEY, VCONFKEY_CALL_STATE, &value); - retv_if(ret != LOCK_ERROR_OK, 0); - - if (value == VCONFKEY_CALL_OFF) { - _E("Call is OFF"); - return 0; - } - - _D("Call status[%d]", value); - - return 1; -} - -static void _sim_controller_call_state_changed_cb(keynode_t *key, void *data) -{ - int call_state = _sim_controller_get_call_state(); - - if (s_info.call_state != call_state) { - _D("Call state changed[%d]", call_state); - s_info.call_state = call_state; - } -} - -static char *_sim_plmn_get(TapiHandle *handle) -{ - int ret = 0; - char *network_name = NULL; - - /* Reading Network (PLMN) name - ‘string’ type Property */ - ret = tel_get_property_string(handle, TAPI_PROP_NETWORK_NETWORK_NAME, &network_name); - if (ret == TAPI_API_SUCCESS) { - /* ‘network_name’ contains valid Network name based on Display condition */ - return network_name; - } else { - _E("Sim = %p PLMN = ERROR[%d]", handle, ret); - /* get property failed */ - } - - return NULL; -} - -static char *_sim_spn_get(TapiHandle *handle) -{ - int ret = 0; - char *spn_name = NULL; - - /* Reading SPN name - ‘string’ type Property */ - ret = tel_get_property_string(handle, TAPI_PROP_NETWORK_SPN_NAME, &spn_name); - if (ret == TAPI_API_SUCCESS) { - /* ‘spn_name’ contains valid Service provider name */ - return spn_name; - } else { - _E("Sim = %p SPN = ERROR[%d]", handle, ret); - /* get property failed */ - return NULL; - } -} - -static char *_plmn_spn_network_get(int handle_num, TapiHandle *handle) -{ - int ret = TAPI_API_SUCCESS; - int service_type = TAPI_NETWORK_SERVICE_TYPE_UNKNOWN; - int name_option = TAPI_NETWORK_DISP_INVALID; - char *plmn = NULL; - char *spn = NULL; - char buf[1024] = { 0, }; - - // get service type - ret = tel_get_property_int(handle, TAPI_PROP_NETWORK_SERVICE_TYPE, &service_type); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to get service type[%d]", ret); - } - - if (service_type >= TAPI_NETWORK_SERVICE_TYPE_2G) { - // get network name option - ret = tel_get_property_int(handle, TAPI_PROP_NETWORK_NAME_OPTION, &name_option); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to get name option[%d]", ret); - } - - switch (name_option) { - case TAPI_NETWORK_DISP_SPN: - spn = _sim_spn_get(handle); - if (spn != NULL && spn[0] != 0) { - _I("PLMN/SPN - Sim %p using SPN: %s", handle, spn); - snprintf(buf, sizeof(buf), "%s", spn); - } - break; - case TAPI_NETWORK_DISP_PLMN: - plmn = _sim_plmn_get(handle); - if (plmn != NULL && plmn[0] != 0) { - _I("PLMN/SPN - Sim %p using PLMN: %s", handle, plmn); - snprintf(buf, sizeof(buf), "%s", plmn); - } - break; - case TAPI_NETWORK_DISP_SPN_PLMN: - spn = _sim_spn_get(handle); - plmn = _sim_plmn_get(handle); - if (spn != NULL && spn[0] != 0 && plmn != NULL && plmn[0] != 0) { - _I("PLMN/SPN - Sim %p using SPN: %s, PLMN: %s", handle, spn, plmn); - snprintf(buf, sizeof(buf), "%s - %s", plmn, spn); - } else if (spn != NULL && spn[0] != 0) { - _I("PLMN/SPN - Sim %p using SPN: %s", handle, spn); - snprintf(buf, sizeof(buf), "%s", spn); - } else if (plmn != NULL && plmn[0] != 0) { - _I("PLMN/SPN - Sim %p using PLMN: %s", handle, plmn); - snprintf(buf, sizeof(buf), "%s", plmn); - } - break; - default: - _E("Invalid name option[%d]", name_option); - plmn = _sim_plmn_get(handle); - if (plmn != NULL && plmn[0] != 0) { - _I("PLMN/SPN - Sim %p using PLMN: %s", handle, plmn); - snprintf(buf, sizeof(buf), "%s", plmn); - } - break; - } - } else { - switch (service_type) { - case TAPI_NETWORK_SERVICE_TYPE_NO_SERVICE: - snprintf(buf, sizeof(buf), "%s", _("IDS_COM_BODY_NO_SERVICE")); - break; - case TAPI_NETWORK_SERVICE_TYPE_EMERGENCY: - snprintf(buf, sizeof(buf), "%s", _("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY")); - break; - case TAPI_NETWORK_SERVICE_TYPE_SEARCH: - snprintf(buf, sizeof(buf), "%s", _("IDS_COM_BODY_SEARCHING")); - break; - default: - _E("invalid service type[%d]", service_type); - plmn = _sim_plmn_get(handle); - if (plmn != NULL && plmn[0] != 0) { - _I("PLMN/SPN - Sim %p using PLMN: %s", handle, plmn); - snprintf(buf, sizeof(buf), "%s", plmn); - } - break; - } - } - - _D("handle[%d][%p] service_type[%d], name_option[%d] >> [%s]", handle_num, handle, service_type, name_option, buf); - - if (strlen(buf) == 0) { - _E("Empty string"); - snprintf(buf, sizeof(buf), "%s", _("IDS_COM_BODY_NO_SERVICE")); - } else if (strncasecmp(buf, "No Service", strlen("No Service")) == 0) { - _E("USING SPECIAL NETWORK NAME: %s in handle: %d", _("IDS_COM_BODY_NO_SERVICE"), handle_num); - return strdup(_("IDS_COM_BODY_NO_SERVICE")); - } else if (strncasecmp(buf, "EMERGENCY", strlen("EMERGENCY")) == 0) { - _E("USING SPECIAL NETWORK NAME: %s in handle: %d", _("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY"), handle_num); - return strdup(_("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY")); - } else if (strncasecmp(buf, "Searching", strlen("Searching")) == 0) { - _E("USING SPECIAL NETWORK NAME: %s in handle: %d", _("IDS_COM_BODY_SEARCHING"), handle_num); - return strdup(_("IDS_COM_BODY_SEARCHING")); - } else if (strncasecmp(buf, "SIM _Eor", strlen("SIM Error")) == 0) { - _E("USING SPECIAL NETWORK NAME: %s in handle: %d", _("IDS_IDLE_BODY_INVALID_SIM_CARD"), handle_num); - return strdup(_("IDS_IDLE_BODY_INVALID_SIM_CARD")); - } else if (strncasecmp(buf, "NO SIM", strlen("NO SIM")) == 0) { - _E("USING SPECIAL NETWORK NAME: %s in handle: %d", _("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY"), handle_num); - return strdup(_("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY")); - } - - return strdup(buf); -} - -static void _sim_status_print(TelSimCardStatus_t sim_status, int card_changed) -{ - switch(sim_status) { - case TAPI_SIM_STATUS_CARD_ERROR: - _I("Sim card status: TAPI_SIM_STATUS_CARD__EOR"); - break; - case TAPI_SIM_STATUS_CARD_NOT_PRESENT: - _I("Sim card status: TAPI_SIM_STATUS_CARD_NOT_PRESENT"); - break; - case TAPI_SIM_STATUS_SIM_INITIALIZING: - _I("Sim card status: TAPI_SIM_STATUS_SIM_INITIALIZING"); - break; - case TAPI_SIM_STATUS_SIM_INIT_COMPLETED: - _I("Sim card status: TAPI_SIM_STATUS_SIM_INIT_COMPLETED"); - break; - case TAPI_SIM_STATUS_SIM_PIN_REQUIRED: - _I("Sim card status: TAPI_SIM_STATUS_SIM_PIN_REQUIRED"); - break; - case TAPI_SIM_STATUS_SIM_PUK_REQUIRED: - _I("Sim card status: TAPI_SIM_STATUS_SIM_PUK_REQUIRED"); - break; - case TAPI_SIM_STATUS_CARD_BLOCKED: - _I("Sim card status: TAPI_SIM_STATUS_CARD_BLOCKED"); - break; - case TAPI_SIM_STATUS_SIM_NCK_REQUIRED: - _I("Sim card status: TAPI_SIM_STATUS_SIM_NCK_REQUIRED"); - break; - case TAPI_SIM_STATUS_SIM_NSCK_REQUIRED: - _I("Sim card status: TAPI_SIM_STATUS_SIM_NSCK_REQUIRED"); - break; - case TAPI_SIM_STATUS_SIM_SPCK_REQUIRED: - _I("Sim card status: TAPI_SIM_STATUS_SIM_SPCK_REQUIRED"); - break; - case TAPI_SIM_STATUS_SIM_CCK_REQUIRED: - _I("Sim card status: TAPI_SIM_STATUS_SIM_CCK_REQUIRED"); - break; - case TAPI_SIM_STATUS_CARD_REMOVED: - _I("Sim card status: TAPI_SIM_STATUS_CARD_REMOVED"); - break; - case TAPI_SIM_STATUS_SIM_LOCK_REQUIRED: - _I("Sim card status: TAPI_SIM_STATUS_SIM_LOCK_REQUIRED"); - break; - case TAPI_SIM_STATUS_CARD_CRASHED: - _I("Sim card status: TAPI_SIM_STATUS_CARD_CRASHED"); - break; - case TAPI_SIM_STATUS_CARD_POWEROFF: - _I("Sim card status: TAPI_SIM_STATUS_CARD_POWEROFF"); - break; - case TAPI_SIM_STATUS_UNKNOWN: - _I("Sim card status: TAPI_SIM_STATUS_UNKNOWN"); - break; - } - - _I("Sim_card_changed: %d", card_changed); -} - -static void _sim_status_get(void) -{ - int i = 0; - int ret = 0; - TelSimCardStatus_t sim_status; - int card_changed = 0; - - for (i = 0; i < TAPI_HANDLE_MAX + 1; ++i) { - if (s_info.handle[i]) { - ret = tel_get_sim_init_info (s_info.handle[i], &sim_status, &card_changed); - if (ret == 0) { - _sim_status_print(sim_status, card_changed); - - if (sim_status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED || sim_status == TAPI_SIM_STATUS_SIM_PIN_REQUIRED) { - if (i < TAPI_HANDLE_MAX) { - s_info.sim_card_ready[i] = EINA_TRUE; - } - } else { - _E("SIM[%d] is not completed initialization [%d]", i, sim_status); - } - } else { - _E("Could not get sim[%d] status[%d]", i, ret); - } - } - } -} - -static void _sim_state_text_set(Eina_Bool flight_mode) -{ - Evas_Object *swipe_layout = lock_default_swipe_layout_get(); - ret_if(!swipe_layout); - - if (flight_mode) { - /* if flight mode, No service */ - _operator_sliding_label_create(swipe_layout, _("IDS_COM_BODY_NO_SERVICE")); - } else if (s_info.sim_card_ready[0] && s_info.sim_card_ready[1]) { - _operator_sliding_label_create(swipe_layout, ""); - } else if (s_info.sim_card_ready[0]) { - char *plmn_spn1 = _plmn_spn_network_get(0, s_info.handle[0]); - _operator_sliding_label_create(swipe_layout, plmn_spn1); - free(plmn_spn1); - } else if (s_info.sim_card_ready[1]) { - char *plmn_spn1 = _plmn_spn_network_get(1, s_info.handle[1]); - _operator_sliding_label_create(swipe_layout, plmn_spn1); - free(plmn_spn1); - } else { - _operator_sliding_label_create(swipe_layout, _("IDS_IDLE_MBODY_EMERGENCY_CALLS_ONLY")); - } -} - -static void _view_init(void) -{ - int flight_mode_state = EINA_FALSE; - int ret = 0; - - ret = lock_property_get_bool(PROPERTY_TYPE_VCONFKEY, VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode_state); - if (ret != LOCK_ERROR_OK) { - _E("Could not get 'VCONFKEY_TELEPHONY_FLIGHT_MODE' value"); - } - - _sim_state_text_set(flight_mode_state); -} - -static void _tel_init(void) -{ - char **cp_list = NULL; - unsigned int modem_num = 0; - - /* Get CP name list – cp_list */ - cp_list = tel_get_cp_name_list(); - ret_if(!cp_list); - - while (cp_list[modem_num]) { - /* Initialize TAPI handle */ - s_info.handle[modem_num] = tel_init(cp_list[modem_num]); - - if (cp_list[modem_num]) { - _E("s_info.handle[%d] = %s; ptr = %p", modem_num, cp_list[modem_num], s_info.handle[modem_num]); - } - - /* Move to next CP Name in cp_list */ - modem_num++; - } - - s_info.handle[modem_num] = NULL; - - /* free cp_list */ - free(cp_list); -} - -static void _tel_deinit(void) -{ - int i = 0; - while (s_info.handle[i]) { - /* De-initialize TAPI handle */ - tel_deinit(s_info.handle[i]); - s_info.handle[i] = NULL; - - /* Move to next handle */ - i++; - } -} - -static void _tel_ready_cb(keynode_t *key, void *data) -{ - Eina_Bool status = EINA_FALSE; - - status = vconf_keynode_get_bool(key); - _D("tel status[%d]", status); - - if (status) { /* Telephony State - READY */ - _tel_init(); - _sim_callback_register(); - _sim_status_get(); - - _view_init(); - } else { /* Telephony State – NOT READY */ - /* De-initialization is optional here (ONLY if required) */ - _tel_deinit(); - s_info.sim_card_ready[0] = EINA_FALSE; - s_info.sim_card_ready[1] = EINA_FALSE; - - _sim_callback_unregister(); - } -} - -static void _tel_flight_mode_cb(keynode_t *key, void *data) -{ - Eina_Bool flight_mode_state = EINA_FALSE; - - flight_mode_state = vconf_keynode_get_bool(key); - _sim_state_text_set(flight_mode_state); -} - -static void _on_sim_card_status_changed_cb(TapiHandle *handle, const char *noti_id, void *data, void *user_data) -{ - int handle_num = (int)user_data; - int *sim_status = data; - - _E("SIM[%p][%d] status[%d], [%d][%d]", handle, handle_num, *sim_status, s_info.sim_card_ready[0], s_info.sim_card_ready[1]); - - if (*sim_status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED || *sim_status == TAPI_SIM_STATUS_SIM_PIN_REQUIRED) { - s_info.sim_card_ready[handle_num] = EINA_TRUE; - } else { - s_info.sim_card_ready[handle_num] = EINA_FALSE; - } - - _view_init(); -} - -static void _on_plmn_spn_changed_cb(TapiHandle *handle, const char *noti_id, void *data, void *user_data) -{ - int flight_mode_state = EINA_FALSE; - int ret = 0; - - ret_if(!handle); - - ret = lock_property_get_bool(PROPERTY_TYPE_VCONFKEY, VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode_state); - if (ret != LOCK_ERROR_OK) { - _E("Could not get the 'VCONFKEY_TELEPHONY_FLIGHT_MODE' value"); - } - - _sim_state_text_set(flight_mode_state); -} - -static void _sim_callback_register(void) -{ - int i = 0; - int ret = 0; - - for (i = 0; i < TAPI_HANDLE_MAX; ++i) { - if (s_info.handle[i]) { - ret = tel_register_noti_event(s_info.handle[i], TAPI_NOTI_SIM_STATUS, _on_sim_card_status_changed_cb, (void*)i); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to register '_on_sim_card_status_changed_cb' callback to handle[%d][%d]", i, ret); - } else { - _E("SIM card status changed event registered"); - } - - ret = tel_register_noti_event(s_info.handle[i], TAPI_PROP_NETWORK_SPN_NAME, _on_plmn_spn_changed_cb, (void*)i); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to register '_on_plmn_spn_changed_cb' callback to handle[%d][%d]", i, ret); - } - - ret = tel_register_noti_event(s_info.handle[i], TAPI_PROP_NETWORK_NETWORK_NAME, _on_plmn_spn_changed_cb, (void*)i); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to register '_on_plmn_spn_changed_cb' callback to handle: %i", i); - } - - ret = tel_register_noti_event(s_info.handle[i], TAPI_PROP_NETWORK_SERVICE_TYPE, _on_plmn_spn_changed_cb, (void*) i); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to register network service type[%d][%d]", ret, i); - } - - ret = tel_register_noti_event(s_info.handle[i], TAPI_PROP_NETWORK_NAME_OPTION, _on_plmn_spn_changed_cb, (void*) i); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to register network name option[%d][%d]", ret, i); - } - } else { - _E("No handle [%d]", i); - } - } -} - -static void _sim_callback_unregister(void) -{ - int i = 0; - int ret = 0; - for (i = 0; i < TAPI_HANDLE_MAX; ++i) { - if (s_info.handle[i]) { - ret = tel_deregister_noti_event(s_info.handle[i], TAPI_NOTI_SIM_STATUS); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to dereregister TAPI_NOTI_SIM_STATUS callback from handle: %i", i); - } else { - _D("SIM status changed event deregistered"); - } - - ret = tel_deregister_noti_event(s_info.handle[i], TAPI_PROP_NETWORK_NETWORK_NAME); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to dereregister TAPI_PROP_NETWORK_PLMN callback from handle: %i", i); - } - - ret = tel_deregister_noti_event(s_info.handle[i], TAPI_PROP_NETWORK_SPN_NAME); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to dereregister TAPI_PROP_NETWORK_SPN_NAME callback from handle: %i", i); - } - - ret = tel_deregister_noti_event(s_info.handle[i], TAPI_PROP_NETWORK_SERVICE_TYPE); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to deregister network service type[%d][%d]", ret, i); - } - - ret = tel_deregister_noti_event(s_info.handle[i], TAPI_PROP_NETWORK_NAME_OPTION); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to deregister network name option[%d][%d]", ret, i); - } - - if (i == 0) { - ret = tel_deregister_noti_event(s_info.handle[i], TAPI_NOTI_CALL_PREFERRED_VOICE_SUBSCRIPTION); - if (ret != TAPI_API_SUCCESS) { - _E("Failed to dereregister callback to handle: %d", i); - } - } - } - } -} - - -lock_error_e lock_sim_state_init(void) -{ - int state = EINA_FALSE; - int ret = 0; - /* Check if Telephony state - READY */ - ret = lock_property_get_bool(PROPERTY_TYPE_VCONFKEY, VCONFKEY_TELEPHONY_READY, &state); - - _D("Telephony Ready : %d", state); - - if (ret == LOCK_ERROR_OK && state == EINA_TRUE) { - /* Telephony State - READY */ - /* Initialize TAPI handles */ - - _tel_init(); - _sim_callback_register(); - _sim_status_get(); - - _view_init(); - } else { - /* Telephony State – NOT READY, register for change in state */ - _D("Telephony state: [NOT Ready]"); - } - - /* Register for Telephony state change */ - ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_READY, _tel_ready_cb, NULL); - if (ret != 0) { - _E("Failed to register VCONFKEY_TELEPHONY_READY key changed callback"); - } - - ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, _tel_flight_mode_cb, NULL); - if (ret != 0) { - _E("Failed to register VCONFKEY_TELEPHONY_FLIGHT_MODE key changed callback"); - } - - ret = vconf_notify_key_changed(VCONFKEY_CALL_STATE, _sim_controller_call_state_changed_cb, NULL); - if (ret != 0) { - _E("Failed to notify call state[%d]", ret); - } - - return LOCK_ERROR_OK; -} - -void lock_sim_state_resume(void) -{ - int state = FALSE; - int ret = 0; - int i = 0; - TelSimCardStatus_t sim_status; - int card_changed = 0; - - ret = lock_property_get_bool(PROPERTY_TYPE_VCONFKEY, VCONFKEY_TELEPHONY_READY, &state); - if (ret != LOCK_ERROR_OK || state == FALSE) { - _E("Failed to get telephony state[%d][%d]", state, ret); - return; - } - - for (i = 0; i < TAPI_HANDLE_MAX; ++i) { - if (s_info.handle[i]) { - ret = tel_get_sim_init_info(s_info.handle[i], &sim_status, &card_changed); - _D("SIM[%d] info[%d][%d][%d]", i, ret, sim_status, card_changed); - if (sim_status == TAPI_SIM_STATUS_SIM_INIT_COMPLETED || sim_status == TAPI_SIM_STATUS_SIM_PIN_REQUIRED) { - if (s_info.sim_card_ready[i] != EINA_TRUE) { - _E("SIM[%d] is init completed but local value is not ture", i); - } - } - } else { - _E("No handle[%d]", i); - } - } -} - -void lock_sim_state_deinit(void) -{ - _D("De-initialization"); - _tel_deinit(); - s_info.sim_card_ready[0] = EINA_FALSE; - s_info.sim_card_ready[1] = EINA_FALSE; - - _sim_callback_unregister(); -} - -void lock_sim_state_language_change(void) -{ - _on_plmn_spn_changed_cb(s_info.handle[0], "SELF", NULL, (void*) 0); - _on_plmn_spn_changed_cb(s_info.handle[1], "SELF", NULL, (void*) 1); - - if (s_info.handle[0] == NULL && s_info.handle[1] == NULL) { - int flight_mode = EINA_FALSE; - int ret = lock_property_get_bool(PROPERTY_TYPE_VCONFKEY, VCONFKEY_TELEPHONY_FLIGHT_MODE, &flight_mode); - if (ret != 0) { - _E("Failed to get flight mode[%d]", ret); - } - - _sim_state_text_set(flight_mode); - } -} diff --git a/src/time_format.c b/src/time_format.c new file mode 100644 index 0000000..269946f --- /dev/null +++ b/src/time_format.c @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2016 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 "time_format.h" +#include "log.h" +#include +#include +#include + +static bool use24hformat; +static char *locale, *tz_timezone; +static int init_count; +int LOCKSCREEN_EVENT_TIME_FORMAT_CHANGED; + +static void _time_changed(system_settings_key_e key, void *user_data) +{ + int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + + switch (key) { + case SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR: + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &use24hformat); + break; + case SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE: + free(tz_timezone); + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, &tz_timezone); + break; + case SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE: + free(locale); + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale); + break; + case SYSTEM_SETTINGS_KEY_TIME_CHANGED: + ret = SYSTEM_SETTINGS_ERROR_NONE; + break; + default: + ERR("Unhandled system_setting event: %d", key); + break; + } + + if (ret == SYSTEM_SETTINGS_ERROR_NONE) { + ecore_event_add(LOCKSCREEN_EVENT_TIME_FORMAT_CHANGED, NULL, NULL, NULL); + } +} + +int lockscreen_time_format_init(void) +{ + if (!init_count) { + LOCKSCREEN_EVENT_TIME_FORMAT_CHANGED = ecore_event_type_new(); + int ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, _time_changed, NULL); + if (ret != SYSTEM_SETTINGS_ERROR_NONE) { + ERR("system_settings_set_changed_cb failed: %s", get_error_message(ret)); + return 1; + } +#if 0 + ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, _time_changed, NULL); + if (ret != SYSTEM_SETTINGS_ERROR_NONE) { + ERR("system_settings_set_changed_cb failed: %s", get_error_message(ret)); + return 1; + } +#endif + ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED, _time_changed, NULL); + if (ret != SYSTEM_SETTINGS_ERROR_NONE) { + ERR("system_settings_set_changed_cb failed: %s", get_error_message(ret)); + return 1; + } + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR, &use24hformat); + + if (ret != SYSTEM_SETTINGS_ERROR_NONE) { + ERR("system_settings_get_value_bool failed: %s", get_error_message(ret)); + return 1; + } + + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale); + if (ret != SYSTEM_SETTINGS_ERROR_NONE) { + ERR("system_settings_get_value_string failed: %s", get_error_message(ret)); + return 1; + } + + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE, &tz_timezone); + if (ret != SYSTEM_SETTINGS_ERROR_NONE) { + free(locale); + ERR("system_settings_get_value_string failed: %s", get_error_message(ret)); + return 1; + } + } + + init_count++; + return 0; +} + +void lockscreen_time_format_shutdown(void) +{ + if (init_count) { + init_count--; + if (!init_count) { + free(locale); + free(tz_timezone); + system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEFORMAT_24HOUR); + system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_TIMEZONE); + system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE); + system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_TIME_CHANGED); + locale = tz_timezone = NULL; + } + } +} + +const char *lockscreen_time_format_locale_get(void) +{ + return locale; +} + +const char *lockscreen_time_format_timezone_get(void) +{ + return tz_timezone; +} + +bool lockscreen_time_format_use_24h(void) +{ + return use24hformat; +} diff --git a/src/time_format_ctrl.c b/src/time_format_ctrl.c new file mode 100644 index 0000000..f3451b0 --- /dev/null +++ b/src/time_format_ctrl.c @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2016 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 "log.h" +#include "time_format.h" +#include "display.h" +#include "main_view.h" + +#include +#include + +static Ecore_Event_Handler *handler, *display_handler; +static Ecore_Timer *update_timer; +static Evas_Object *main_view; + +static void _time_update(void) +{ + lockscreen_main_view_time_set(main_view, lockscreen_time_format_locale_get(), + lockscreen_time_format_timezone_get(), lockscreen_time_format_use_24h(), time(NULL)); +} + +static Eina_Bool _timer_cb(void *data) +{ + _time_update(); + ecore_timer_interval_set(update_timer, 60.0); + return ECORE_CALLBACK_RENEW; +} + +static void _time_spawn_align(void) +{ + time_t tt; + struct tm st; + + tt = time(NULL); + localtime_r(&tt, &st); + + ecore_timer_interval_set(update_timer, 60 - st.tm_sec); +} + +static Eina_Bool _time_changed(void *data, int event, void *event_info) +{ + _time_update(); + _time_spawn_align(); + return EINA_TRUE; +} + +static Eina_Bool _display_status_changed(void *data, int event, void *event_info) +{ + if (lockscreen_display_is_off()) { + if (update_timer) ecore_timer_freeze(update_timer); + } + else { + _time_update(); + _time_spawn_align(); + } + return EINA_TRUE; +} + +int lockscreen_time_format_ctrl_init(Evas_Object *view) +{ + if (lockscreen_display_init()) { + FAT("lockscreen_display_init failed"); + return 1; + } + + if (lockscreen_time_format_init()) { + lockscreen_display_shutdown(); + FAT("lockscreen_time_format_init failed"); + return 1; + } + + handler = ecore_event_handler_add(LOCKSCREEN_EVENT_TIME_FORMAT_CHANGED, _time_changed, NULL); + if (!handler) + FAT("ecore_event_handler_add failed on LOCKSCREEN_DATA_MODEL_EVENT_TIME_FORMAT_CHANGED event"); + display_handler = ecore_event_handler_add(LOCKSCREEN_EVENT_DISPLAY_STATUS_CHANGED, _display_status_changed, NULL); + if (!display_handler) + FAT("ecore_event_handler_add failed on LOCKSCREEN_DATA_MODEL_EVENT_LCD_STATUS_CHANGED event"); + main_view = view; + update_timer = ecore_timer_add(60.0, _timer_cb, NULL); + _time_update(); + _time_spawn_align(); + + return 0; +} + +void lockscreen_time_ctrl_shutdown(void) +{ + ecore_timer_del(update_timer); + ecore_event_handler_del(handler); + ecore_event_handler_del(display_handler); + lockscreen_display_shutdown(); + lockscreen_time_format_shutdown(); +} + +void lockscreen_time_format_ctrl_time_update(void) +{ + _time_update(); +} + diff --git a/src/util.c b/src/util.c new file mode 100644 index 0000000..a8f4cc9 --- /dev/null +++ b/src/util.c @@ -0,0 +1,94 @@ +/* + * Copyright 2016 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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 "log.h" +#include "util.h" +#include "lockscreen.h" + +const char *util_get_file_path(enum app_subdir dir, const char *relative) +{ + static char buf[PATH_MAX]; + char *prefix; + + switch (dir) { + case APP_DIR_DATA: + prefix = app_get_data_path(); + break; + case APP_DIR_CACHE: + prefix = app_get_cache_path(); + break; + case APP_DIR_RESOURCE: + prefix = app_get_resource_path(); + break; + case APP_DIR_SHARED_DATA: + prefix = app_get_shared_data_path(); + break; + case APP_DIR_SHARED_RESOURCE: + prefix = app_get_shared_resource_path(); + break; + case APP_DIR_SHARED_TRUSTED: + prefix = app_get_shared_trusted_path(); + break; + case APP_DIR_EXTERNAL_DATA: + prefix = app_get_external_data_path(); + break; + case APP_DIR_EXTERNAL_CACHE: + prefix = app_get_external_cache_path(); + break; + case APP_DIR_EXTERNAL_SHARED_DATA: + prefix = app_get_external_shared_data_path(); + break; + default: + FAT("Not handled directory type."); + return NULL; + } + size_t res = eina_file_path_join(buf, sizeof(buf), prefix, relative); + free(prefix); + if (res > sizeof(buf)) { + ERR("Path exceeded PATH_MAX"); + return NULL; + } + + return &buf[0]; +} + +const Elm_Theme *util_lockscreen_theme_get(void) +{ + static Elm_Theme *theme; + if (!theme) + { + theme = elm_theme_new(); + elm_theme_ref_set(theme, NULL); + elm_theme_overlay_add(NULL, util_get_res_file_path(EDJE_DIR"index.edj")); + } + return theme; +} + +void util_feedback_tap_play(void) +{ + static int init; + if (!init) { + int ret = feedback_initialize(); + if (ret != FEEDBACK_ERROR_NONE) { + FAT("feedback_initialize failed."); + } + init = 1; + } + feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TAP); +} diff --git a/src/util_time.c b/src/util_time.c new file mode 100644 index 0000000..de62c69 --- /dev/null +++ b/src/util_time.c @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2016 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 "util_time.h" +#include "log.h" + +static i18n_udatepg_h _util_time_generator_get(const char *timezone_id) +{ + static i18n_udatepg_h generator; + static char *tz; + + if (tz && !strcmp(tz, timezone_id)) { + return generator; + } + + if (generator) { + i18n_udatepg_destroy(generator); + generator = NULL; + } + + int ret = i18n_udatepg_create(timezone_id, &generator); + if (ret != I18N_ERROR_NONE) { + ERR("i18n_udatepg_create failed: %s", get_error_message(ret)); + return NULL; + } + free(tz); + tz = strdup(timezone_id); + return generator; +} + +static i18n_udate_format_h __util_time_date_formatter_get(const char *locale, const char *timezone_id, const char *skeleton) +{ + int status; + i18n_uchar u_skeleton[64] = {0,}; + int32_t skeleton_len = 0, pattern_len; + + i18n_uchar u_best_pattern[64] = {0,}; + int32_t u_best_pattern_capacity; + i18n_udate_format_h formatter = NULL; + + const i18n_udatepg_h generator = _util_time_generator_get(timezone_id); + if (!generator) { + ERR("_util_time_generator_get failed"); + return NULL; + } + + i18n_ustring_copy_ua_n(u_skeleton, skeleton, strlen(skeleton)); + skeleton_len = i18n_ustring_get_length(u_skeleton); + + u_best_pattern_capacity = + (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0])); + + status = i18n_udatepg_get_best_pattern(generator, u_skeleton, skeleton_len, + u_best_pattern, u_best_pattern_capacity, &pattern_len); + if (status != I18N_ERROR_NONE) { + ERR("i18n_udatepg_get_best_pattern failed: %s", get_error_message(status)); + return NULL; + } + + i18n_uchar u_timezone_id[64] = {0,}; + i18n_ustring_copy_ua_n(u_timezone_id, timezone_id, sizeof(u_timezone_id)); + status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, locale, u_timezone_id, -1, + u_best_pattern, -1, &formatter); + if (status != I18N_ERROR_NONE) { + ERR("i18n_udate_create() failed"); + return NULL; + } + + return formatter; +} + +static i18n_udate_format_h __util_time_time_formatter_get(bool use24hformat, const char *locale, const char *timezone_id) +{ + char buf[64] = {0,}; + int status; + i18n_uchar u_pattern[64] = {0,}; + i18n_uchar u_best_pattern[64] = {0,}; + int32_t u_best_pattern_capacity, u_best_pattern_len; + char a_best_pattern[128] = {0,}; + + i18n_udate_format_h formatter = NULL; + + const i18n_udatepg_h generator = _util_time_generator_get(timezone_id); + if (!generator) { + ERR("_util_time_generator_get failed"); + return NULL; + } + + if (use24hformat) { + snprintf(buf, sizeof(buf)-1, "%s", "HH:mm"); + } else { + /* set time format 12 */ + snprintf(buf, sizeof(buf)-1, "%s", "h:mm"); + } + + i18n_ustring_copy_ua_n(u_pattern, buf, sizeof(u_pattern)); + + u_best_pattern_capacity = + (int32_t) (sizeof(u_best_pattern) / sizeof((u_best_pattern)[0])); + + status = i18n_udatepg_get_best_pattern(generator, u_pattern, sizeof(u_pattern), + u_best_pattern, u_best_pattern_capacity, &u_best_pattern_len); + if (status != I18N_ERROR_NONE) { + ERR("i18n_udatepg_get_best_pattern() failed: %s", get_error_message(status)); + return NULL; + } + + i18n_ustring_copy_au(a_best_pattern, u_best_pattern); + + char *a_best_pattern_fixed = strtok(a_best_pattern, "a"); + a_best_pattern_fixed = strtok(a_best_pattern_fixed, " "); + if (a_best_pattern_fixed) { + i18n_ustring_copy_ua(u_best_pattern, a_best_pattern_fixed); + } + + i18n_uchar u_timezone_id[64] = {0,}; + i18n_ustring_copy_ua_n(u_timezone_id, timezone_id, sizeof(u_timezone_id)); + + status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, locale, u_timezone_id, -1, + u_best_pattern, -1, &formatter); + if (status != I18N_ERROR_NONE) { + ERR("i18n_udate_create() failed"); + return NULL; + } + + return formatter; +} + +static i18n_udate_format_h __util_time_ampm_formatter_get(const char *locale, const char *timezone_id) +{ + int status; + + i18n_uchar u_best_pattern[64] = {0,}; + i18n_udate_format_h formatter = NULL; + + i18n_ustring_copy_ua(u_best_pattern, "a"); + + i18n_uchar u_timezone_id[64] = {0,}; + i18n_ustring_copy_ua_n(u_timezone_id, timezone_id, sizeof(u_timezone_id)); + + status = i18n_udate_create(I18N_UDATE_PATTERN, I18N_UDATE_PATTERN, locale, u_timezone_id, -1, + u_best_pattern, -1, &formatter); + + if (status != I18N_ERROR_NONE) { + ERR("i18n_udate_create() failed"); + return NULL; + } + + return formatter; +} + +static int __util_time_formatted_time_get(i18n_udate_format_h formatter, time_t tt, char *buf, int buf_len) +{ + if (!formatter) return -1; + + i18n_udate u_time = (i18n_udate)tt * 1000; + i18n_uchar u_formatted_str[64] = {0,}; + int32_t u_formatted_str_capacity, buf_needed; + int status; + + u_formatted_str_capacity = (int32_t)(sizeof(u_formatted_str) / sizeof((u_formatted_str)[0])); + + status = i18n_udate_format_date(formatter, u_time, u_formatted_str, u_formatted_str_capacity, NULL, &buf_needed); + if (status != I18N_ERROR_NONE) { + ERR("i18n_udate_format_date() failed"); + return -1; + } + + i18n_ustring_copy_au_n(buf,u_formatted_str, buf_len - 1); + DBG("time(%d) formatted(%s)", tt, buf); + + return (int)i18n_ustring_get_length(u_formatted_str); +} + +bool util_time_formatted_time_get(time_t time, const char *locale, const char *timezone, bool use24hformat, char **str_time, char **str_meridiem) +{ + struct tm st; + char buf_time[512] = {0,}; + char buf_ampm[512] = {0,}; + localtime_r(&time, &st); + + i18n_udate_format_h timef, ampmf; + + timef = __util_time_time_formatter_get(use24hformat, locale, timezone); + __util_time_formatted_time_get(timef, time, buf_time, sizeof(buf_time)-1); + + if (!use24hformat) { + ampmf = __util_time_ampm_formatter_get(locale, timezone); + int ampm_len = __util_time_formatted_time_get(ampmf, time, buf_ampm, sizeof(buf_ampm)-1); + if (ampm_len > 4) { + if (st.tm_hour >= 0 && st.tm_hour < 12) { + snprintf(buf_ampm, sizeof(buf_ampm)-1, "AM"); + } else { + snprintf(buf_ampm, sizeof(buf_ampm)-1, "PM"); + } + } + } + + if (str_time) *str_time = strdup(buf_time); + if (str_meridiem) *str_meridiem = strdup(buf_ampm); + + return true; +} + +bool util_time_formatted_date_get(time_t time, const char *locale, const char *timezone, const char *skeleton, char **str_date) +{ + struct tm st; + char buf_date[512] = {0,}; + localtime_r(&time, &st); + i18n_udate_format_h datef; + + datef = __util_time_date_formatter_get(locale, timezone, skeleton ? skeleton : "MMMMEd"); + + __util_time_formatted_time_get(datef, time, buf_date, sizeof(buf_date)); + if (str_date != NULL) { + *str_date = strdup(buf_date); + return true; + } + return false; +} diff --git a/src/window.c b/src/window.c index ce7cf9a..c0bd2bd 100644 --- a/src/window.c +++ b/src/window.c @@ -14,125 +14,92 @@ * limitations under the License. */ -#include -#include #include -#include -#include +#include -#include "lockscreen.h" -#include "log.h" #include "window.h" -#include "tzsh_lockscreen_service.h" +#include "log.h" -#define STR_ATOM_PANEL_SCROLLABLE_STATE "_E_MOVE_PANEL_SCROLLABLE_STATE" -static struct _s_info { +static struct { Evas_Object *win; + Evas_Object *conformant; +} view; - tzsh_h tzsh; - tzsh_lockscreen_service_h lockscreen_service; - - int win_w; - int win_h; -} s_info = { - .win = NULL, - - .tzsh = NULL, - .lockscreen_service = NULL, - - .win_w = 0, - .win_h = 0, -}; - -Evas_Object *lock_window_win_get(void) +static void _lockscreen_window_event_rect_mouse_down_cb(void *data, Evas *e, Evas_Object *src, void *event_info) { - return s_info.win; + evas_object_smart_callback_call(data, SIGNAL_TOUCH_STARTED, NULL); } -int lock_window_width_get(void) +static void _lockscreen_window_event_rect_mouse_up_cb(void *data, Evas *e, Evas_Object *src, void *event_info) { - return s_info.win_w; + evas_object_smart_callback_call(data, SIGNAL_TOUCH_ENDED, NULL); } -int lock_window_height_get(void) +static void _lockscreen_window_event_rect_geometry_changed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) { - return s_info.win_h; + int x, y, w, h; + evas_object_geometry_get(obj, &x, &y, &w, &h); + evas_object_geometry_set(data, x, y, w, h); } -static lock_error_e _tzsh_set(Evas_Object *win) +Evas_Object *lockscreen_window_create(void) { tzsh_h tzsh = NULL; tzsh_lockscreen_service_h lockscreen_service = NULL; - tzsh_window tz_win; + Evas_Object *win = elm_win_add(NULL, "LOCKSCREEN", ELM_WIN_NOTIFICATION); + if (!win) return NULL; - retv_if(!win, LOCK_ERROR_INVALID_PARAMETER); + elm_win_alpha_set(win, EINA_TRUE); + elm_win_title_set(win, "LOCKSCREEN"); + elm_win_borderless_set(win, EINA_TRUE); + elm_win_autodel_set(win, EINA_TRUE); + elm_win_role_set(win, "notification-normal"); + elm_win_fullscreen_set(win, EINA_TRUE); + elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW); tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL); - retv_if(!tzsh, LOCK_ERROR_FAIL); - s_info.tzsh = tzsh; - - tz_win = elm_win_window_id_get(win); - if (!tz_win) { - tzsh_destroy(tzsh); - return LOCK_ERROR_FAIL; + if (!tzsh) { + ERR("tzsh_create failed"); + evas_object_del(win); + return NULL; } - lockscreen_service = tzsh_lockscreen_service_create(tzsh, tz_win); + lockscreen_service = tzsh_lockscreen_service_create(tzsh, elm_win_window_id_get(win)); if (!lockscreen_service) { + ERR("tzsh_lockscreen_service_create failed"); tzsh_destroy(tzsh); - return LOCK_ERROR_FAIL; + evas_object_del(win); + return NULL; } - s_info.lockscreen_service = lockscreen_service; - return LOCK_ERROR_OK; -} + Evas_Object *conformant = elm_conformant_add(win); + evas_object_size_hint_weight_set(conformant, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(conformant, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_win_resize_object_add(win, conformant); -static void _tzsh_unset(void) -{ - if (s_info.lockscreen_service) { - tzsh_lockscreen_service_destroy(s_info.lockscreen_service); - s_info.lockscreen_service = NULL; - } + elm_object_signal_emit(conformant, "elm,state,indicator,overlap", "elm"); - if (s_info.tzsh) { - tzsh_destroy(s_info.tzsh); - s_info.tzsh = NULL; - } -} + Evas_Object *event_rect = evas_object_rectangle_add(evas_object_evas_get(win)); + evas_object_color_set(event_rect, 0, 0, 0, 0); + evas_object_layer_set(event_rect, EVAS_LAYER_MAX); + evas_object_repeat_events_set(event_rect, EINA_TRUE); + evas_object_event_callback_add(event_rect, EVAS_CALLBACK_MOUSE_DOWN, _lockscreen_window_event_rect_mouse_down_cb, win); + evas_object_event_callback_add(event_rect, EVAS_CALLBACK_MOUSE_UP, _lockscreen_window_event_rect_mouse_up_cb, win); + evas_object_show(event_rect); -Evas_Object *lock_window_create(int type) -{ - int x = 0, y = 0, w = 0, h = 0; + evas_object_event_callback_add(win, EVAS_CALLBACK_RESIZE, _lockscreen_window_event_rect_geometry_changed_cb, event_rect); + evas_object_event_callback_add(win, EVAS_CALLBACK_MOVE, _lockscreen_window_event_rect_geometry_changed_cb, event_rect); + evas_object_show(win); + evas_object_show(conformant); - Evas_Object *win = elm_win_add(NULL, "LOCKSCREEN", ELM_WIN_NOTIFICATION); - retv_if(!win, NULL); - - elm_win_alpha_set(win, EINA_TRUE); - elm_win_title_set(win, "LOCKSCREEN"); - elm_win_borderless_set(win, EINA_TRUE); - elm_win_autodel_set(win, EINA_TRUE); - efl_util_set_notification_window_level(win, EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM); - - elm_win_screen_size_get(win, &x, &y, &w, &h); - - s_info.win = win; - s_info.win_w = w; - s_info.win_h = h; - - if (LOCK_ERROR_OK != _tzsh_set(win)) { - _E("Failed to set tzsh"); - } + view.win = win; + view.conformant = conformant; return win; } -void lock_window_destroy(void) +void lockscreen_window_content_set(Evas_Object *content) { - _tzsh_unset(); - - if (s_info.win) { - evas_object_del(s_info.win); - s_info.win = NULL; - } + elm_object_part_content_set(view.conformant, NULL, content); } diff --git a/tizen-manifest.xml b/tizen-manifest.xml new file mode 100644 index 0000000..f5989b6 --- /dev/null +++ b/tizen-manifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + lockscreen.png + + + + http://tizen.org/privilege/telephony + http://tizen.org/privilege/appmanager.launch + http://tizen.org/privilege/display + http://tizen.org/privilege/notification + http://tizen.org/privilege/haptic + +