From 834c66e2ef074c7811cb87fa786abf8c6e3384e3 Mon Sep 17 00:00:00 2001 From: Sehong Na Date: Sat, 31 May 2014 12:56:25 +0900 Subject: [PATCH 1/1] Initialize Tizen 2.3 --- CMakeLists.txt | 100 + LICENSE.APLv2 | 202 ++ data/dummy | 2 + .../etc/smack/accesses.d/osp-common-service.native | 10 + global_res/opt/usr/etc/system_info_cache.ini | 0 inc/CommonService.h | 78 + manifest.xml | 27 + osp-common-service.manifest | 15 + packaging/osp-common-service.spec | 95 + src/CommonService.cpp | 131 + src/CommonServiceEntry.cpp | 61 + src/messaging/CMakeLists.txt | 35 + src/messaging/FMsg_CbsMaker.cpp | 159 ++ src/messaging/FMsg_CbsMaker.h | 67 + src/messaging/FMsg_IpcCallbackHandler.cpp | 971 +++++++ src/messaging/FMsg_IpcCallbackHandler.h | 225 ++ src/messaging/FMsg_MessagingIpcStub.cpp | 583 ++++ src/messaging/FMsg_MessagingIpcStub.h | 112 + src/messaging/FMsg_SmsService.cpp | 436 +++ src/messaging/FMsg_SmsService.h | 101 + src/messaging/FMsg_WapPushService.cpp | 361 +++ src/messaging/FMsg_WapPushService.h | 72 + src/system/CMakeLists.txt | 47 + src/system/FSys_AlarmExStub.cpp | 245 ++ src/system/FSys_AlarmExStub.h | 76 + src/system/FSys_DeviceId.cpp | 408 +++ src/system/FSys_DeviceId.h | 72 + src/system/FSys_DeviceManagerStub.cpp | 353 +++ src/system/FSys_DeviceManagerStub.h | 93 + src/system/FSys_PowerManagerStub.cpp | 270 ++ src/system/FSys_PowerManagerStub.h | 86 + src/system/FSys_RuntimeInfoStub.cpp | 312 +++ src/system/FSys_RuntimeInfoStub.h | 79 + src/system/FSys_SettingService.cpp | 552 ++++ src/system/FSys_SettingService.h | 90 + src/system/FSys_SystemInfoService.cpp | 2818 ++++++++++++++++++++ src/system/FSys_SystemInfoService.h | 70 + src/system/FSys_SystemServiceIpcEventForAsync.cpp | 58 + src/system/FSys_SystemServiceIpcEventForAsync.h | 56 + src/ui/CMakeLists.txt | 26 + src/ui/FUi_UiManagerStub.cpp | 147 + src/ui/FUi_UiManagerStub.h | 66 + 42 files changed, 9767 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 LICENSE.APLv2 create mode 100644 data/dummy create mode 100644 global_res/opt/etc/smack/accesses.d/osp-common-service.native create mode 100644 global_res/opt/usr/etc/system_info_cache.ini create mode 100644 inc/CommonService.h create mode 100644 manifest.xml create mode 100644 osp-common-service.manifest create mode 100644 packaging/osp-common-service.spec create mode 100644 src/CommonService.cpp create mode 100644 src/CommonServiceEntry.cpp create mode 100644 src/messaging/CMakeLists.txt create mode 100644 src/messaging/FMsg_CbsMaker.cpp create mode 100644 src/messaging/FMsg_CbsMaker.h create mode 100644 src/messaging/FMsg_IpcCallbackHandler.cpp create mode 100644 src/messaging/FMsg_IpcCallbackHandler.h create mode 100644 src/messaging/FMsg_MessagingIpcStub.cpp create mode 100644 src/messaging/FMsg_MessagingIpcStub.h create mode 100644 src/messaging/FMsg_SmsService.cpp create mode 100644 src/messaging/FMsg_SmsService.h create mode 100644 src/messaging/FMsg_WapPushService.cpp create mode 100644 src/messaging/FMsg_WapPushService.h create mode 100644 src/system/CMakeLists.txt create mode 100644 src/system/FSys_AlarmExStub.cpp create mode 100644 src/system/FSys_AlarmExStub.h create mode 100644 src/system/FSys_DeviceId.cpp create mode 100644 src/system/FSys_DeviceId.h create mode 100644 src/system/FSys_DeviceManagerStub.cpp create mode 100644 src/system/FSys_DeviceManagerStub.h create mode 100644 src/system/FSys_PowerManagerStub.cpp create mode 100644 src/system/FSys_PowerManagerStub.h create mode 100644 src/system/FSys_RuntimeInfoStub.cpp create mode 100644 src/system/FSys_RuntimeInfoStub.h create mode 100644 src/system/FSys_SettingService.cpp create mode 100644 src/system/FSys_SettingService.h create mode 100644 src/system/FSys_SystemInfoService.cpp create mode 100644 src/system/FSys_SystemInfoService.h create mode 100644 src/system/FSys_SystemServiceIpcEventForAsync.cpp create mode 100644 src/system/FSys_SystemServiceIpcEventForAsync.h create mode 100644 src/ui/CMakeLists.txt create mode 100644 src/ui/FUi_UiManagerStub.cpp create mode 100644 src/ui/FUi_UiManagerStub.h diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4d05255 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,100 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET (this_target osp-common-service) +SET (APPID sjjevolsjk) + +SET(CMAKE_EXECUTABLE_SUFFIX ".exe") +SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/output") + +INCLUDE_DIRECTORIES ( + inc + src/messaging + src/system + src/ui + /usr/include/osp/ui + ) + +SET (${this_target}_SOURCE_FILES + src/CommonService.cpp + src/CommonServiceEntry.cpp + ) + +INCLUDE(FindPkgConfig) +pkg_check_modules(${this_target} REQUIRED + glib-2.0 + ecore + eina + chromium + libsmack + capi-appfw-application + osp-appfw + osp-appfw-server + osp-system-server +) + +FOREACH(flag ${${this_target}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +ADD_SUBDIRECTORY(src/messaging) +ADD_SUBDIRECTORY(src/system) +ADD_SUBDIRECTORY(src/ui) + +## SET EXTRA COMPILER FLAGS +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE -Wall -pthread -g3" ) +#SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fstack-protector -Wstack-protector" ) + +## SET C COMPILER FLAGS +SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## SET CPP COMPILER FLAGS +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") +SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +SET(CMAKE_SKIP_BUILD_RPATH FALSE) +SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +SET(CMAKE_INSTALL_RPATH "/usr/lib/osp-server") +SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) + +## Create Executable +ADD_EXECUTABLE (${this_target} ${${this_target}_SOURCE_FILES}) + +## Create Shared Library +SET(STATIC_LIBS messaging_service system_service ui_service) + +SET_TARGET_PROPERTIES(${this_target} PROPERTIES LINK_INTERFACE_LIBRARIES "") + +ADD_DEPENDENCIES(${this_target} ${STATIC_LIBS}) + +MACRO(OSP_ADD_OBJS_IN_ARCHIVE archives) + SET(LINK_OBJECTS_IN_ARCHIVE) + FOREACH(archive ${ARGV}) + SET(LINK_OBJECTS_IN_ARCHIVE "${LINK_OBJECTS_IN_ARCHIVE} -l${archive}") + ENDFOREACH(archive) + SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--whole-archive ${LINK_OBJECTS_IN_ARCHIVE} -Wl,-no-whole-archive") +ENDMACRO(OSP_ADD_OBJS_IN_ARCHIVE) + +OSP_ADD_OBJS_IN_ARCHIVE(${STATIC_LIBS}) + +SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed") + +TARGET_LINK_LIBRARIES( ${this_target} ${STATIC_LIBS}) + +TARGET_LINK_LIBRARIES(${this_target} -Xlinker --no-undefined -Xlinker --as-needed -pie) +TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-uifw" ) +TARGET_LINK_LIBRARIES(${this_target} -L/usr/lib/osp -losp-messaging) +TARGET_LINK_LIBRARIES(${this_target} "-lmsg_mapi" ) +TARGET_LINK_LIBRARIES(${this_target} "-lutilX" ) +TARGET_LINK_LIBRARIES(${this_target} "-lecore_x" ) +TARGET_LINK_LIBRARIES(${this_target} "-lSLP-tapi" ) +TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-info" ) +TARGET_LINK_LIBRARIES(${this_target} "-lcapi-network-wifi" ) +TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib -lkies_alarm") +TARGET_LINK_LIBRARIES(${this_target} "-ldl") +TARGET_LINK_LIBRARIES(${this_target} ${${this_target}_LDFLAGS} ${${this_target}_LIBRARIES}) + +INSTALL(TARGETS ${this_target} DESTINATION ../usr/apps/${APPID}/bin) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/manifest.xml DESTINATION ../usr/apps/${APPID}/info) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/global_res/opt/usr/etc/system_info_cache.ini DESTINATION ../opt/usr/etc) +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/data/ DESTINATION ../usr/apps/${APPID}/data) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/global_res/opt/etc/smack/accesses.d/osp-common-service.native DESTINATION ../etc/smack/accesses.d) diff --git a/LICENSE.APLv2 b/LICENSE.APLv2 new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE.APLv2 @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/data/dummy b/data/dummy new file mode 100644 index 0000000..139597f --- /dev/null +++ b/data/dummy @@ -0,0 +1,2 @@ + + diff --git a/global_res/opt/etc/smack/accesses.d/osp-common-service.native b/global_res/opt/etc/smack/accesses.d/osp-common-service.native new file mode 100644 index 0000000..6d4cb35 --- /dev/null +++ b/global_res/opt/etc/smack/accesses.d/osp-common-service.native @@ -0,0 +1,10 @@ +root sjjevolsjk rw---- +_default_ sjjevolsjk rw---- +sjjevolsjk alarm-server::alarm rw---- +sjjevolsjk bt-service::admin -w---- +sjjevolsjk net-config rw---- +sjjevolsjk connman rw---- +sjjevolsjk location_fw::client rw---- +sjjevolsjk deviced::display rw---- +sjjevolsjk tethering::dbus-access rw---- +sjjevolsjk system::vconf_network rw---- diff --git a/global_res/opt/usr/etc/system_info_cache.ini b/global_res/opt/usr/etc/system_info_cache.ini new file mode 100644 index 0000000..e69de29 diff --git a/inc/CommonService.h b/inc/CommonService.h new file mode 100644 index 0000000..99b62ee --- /dev/null +++ b/inc/CommonService.h @@ -0,0 +1,78 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef _COMMON_SERVICE_H_ +#define _COMMON_SERVICE_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ +class _UiManagerStub; +}} // Tizen::Ui + +namespace Tizen { namespace System +{ +class _SystemInfoService; +class _SettingService; +class _RuntimeInfoStub; +class _DeviceManagerStub; +class _PowerManagerStub; +class _AlarmExStub; +}} + +namespace Tizen { namespace Messaging +{ +class _MessagingIpcStub; +}} +/** + * @class CommonService + * @brief + */ +class CommonService + : public Tizen::App::ServiceApp +{ +public: + static Tizen::App::ServiceApp* CreateInstance(void); + + CommonService(void); + virtual ~CommonService(void); + + bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry); + bool OnAppInitialized(void); + bool OnAppWillTerminate(void); + bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false); + void OnLowMemory(void); + void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel); + +private: + void InitializeServices(void); + + std::unique_ptr __pUiManagerStub; + Tizen::System::_SystemInfoService* __pSystemInfoService; + Tizen::System::_SettingService* __pSettingService; + Tizen::System::_RuntimeInfoStub* __pRuntimeInfoStub; + Tizen::System::_DeviceManagerStub* __pDeviceManagerStub; + Tizen::System::_PowerManagerStub* __pPowerManagerStub; + Tizen::System::_AlarmExStub* __pAlarmExStub; + std::unique_ptr__pMessagingIpcStub; +}; + +#endif // _COMMON_SERVICE_H_ diff --git a/manifest.xml b/manifest.xml new file mode 100644 index 0000000..001159e --- /dev/null +++ b/manifest.xml @@ -0,0 +1,27 @@ + + + sjjevolsjk + 1.0.0 + C++App + + Samsung Electronics + + + + + + 2.1 + + + + + + Native Privileged API Service + + + + + + + + diff --git a/osp-common-service.manifest b/osp-common-service.manifest new file mode 100644 index 0000000..b654211 --- /dev/null +++ b/osp-common-service.manifest @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/packaging/osp-common-service.spec b/packaging/osp-common-service.spec new file mode 100644 index 0000000..082240d --- /dev/null +++ b/packaging/osp-common-service.spec @@ -0,0 +1,95 @@ +Name: osp-common-service +Summary: osp common service +Version: 1.2.2.0 +Release: 1 +Group: System/Libraries +License: Apache License, Version 2.0 or Flora +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(osp-system-server) +BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(chromium) +BuildRequires: pkgconfig(capi-appfw-package-manager) +BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(capi-network-wifi) +BuildRequires: pkgconfig(capi-network-bluetooth) +BuildRequires: pkgconfig(capi-media-sound-manager) +BuildRequires: pkgconfig(capi-telephony-network-info) +BuildRequires: pkgconfig(tapi) +BuildRequires: pkgconfig(pkgmgr) +BuildRequires: pkgconfig(osp-appfw) +BuildRequires: pkgconfig(osp-uifw) +BuildRequires: osp-appfw-internal-devel +BuildRequires: osp-uifw-internal-devel +BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(x11) +BuildRequires: pkgconfig(utilX) +BuildRequires: pkgconfig(tapi) +BuildRequires: hash-signer +BuildRequires: pkgconfig(dbus-1) +BuildRequires: pkgconfig(dbus-glib-1) +BuildRequires: pkgconfig(email-service) +BuildRequires: pkgconfig(msg-service) +BuildRequires: pkgconfig(osp-shell) +BuildRequires: pkgconfig(osp-messaging) +BuildRequires: pkgconfig(kies_alarm) +BuildRequires: pkgconfig(alarm-service) +BuildRequires: pkgconfig(alarm-engine) +BuildRequires: osp-messaging-internal-devel +# runtime requires +Requires: chromium +Requires: osp-appfw +Requires(post): bluetooth-frwk-service + +%description +osp common service + +%prep +%setup -q + +%build +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` + +%ifarch %{ix86} + ARCH=x86 + CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_" + %if 0%{?simulator} + CXXFLAGS="$CXXFLAGS -D_OSP_EMUL_" + %endif +%else + ARCH=arm + CXXFLAGS="-O2 -g -pipe -Wall -fno-exceptions -Wformat -Wformat-security -Wl,--as-needed -fmessage-length=0 -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -D__SOFTFP__ -mthumb -Wa,-mimplicit-it=thumb -funwind-tables -D_OSP_DEBUG_ -D_OSP_ARMEL_" +%endif + +%if 0%{?tizen_build_binary_release_type_eng} + CXXFLAGS="$CXXFLAGS -D_SECURE_LOG" +%endif + +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DOBS=1 -DFULLVER=%{version} -DMAJORVER=${MAJORVER} -DARCH=${ARCH} + +# Call make instruction with smp support +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +mkdir -p %{buildroot}/usr/share/license +cp %{_builddir}/%{name}-%{version}/LICENSE.APLv2 %{buildroot}/usr/share/license/%{name} + +%make_install +%define tizen_sign 1 +%define tizen_sign_base /usr/apps/sjjevolsjk +%define tizen_sign_level public +%define tizen_author_sign 1 +%define tizen_dist_sign 1 + +%post +/bin/rm -fr /opt/apps/sjjevolsjk +/usr/etc/package-manager/backend/tpk -i /usr/apps/sjjevolsjk + +%files +/usr/apps/sjjevolsjk/* +/etc/smack/accesses.d/%{name}.native +%config(noreplace) /opt/usr/etc/system_info_cache.ini +%manifest osp-common-service.manifest +/usr/share/license/%{name} diff --git a/src/CommonService.cpp b/src/CommonService.cpp new file mode 100644 index 0000000..16969fa --- /dev/null +++ b/src/CommonService.cpp @@ -0,0 +1,131 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include +#include + +#include "CommonService.h" +#include "FUi_UiManagerStub.h" +#include "system/FSys_SystemInfoService.h" +#include "system/FSys_SettingService.h" +#include "FSys_RuntimeInfoStub.h" +#include "FSys_DeviceManagerStub.h" +#include "FSys_PowerManagerStub.h" +#include "FSys_AlarmExStub.h" +#include "FMsg_MessagingIpcStub.h" + +using namespace std; +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::System; +using namespace Tizen::Ui; + +CommonService::CommonService(void) + : __pUiManagerStub(null) + , __pSystemInfoService(null) + , __pSettingService(null) + , __pRuntimeInfoStub(null) + , __pDeviceManagerStub(null) + , __pPowerManagerStub(null) + , __pAlarmExStub(null) + , __pMessagingIpcStub(null) +{ +} + +CommonService::~CommonService(void) +{ +} + +ServiceApp* +CommonService::CreateInstance(void) +{ + return new (std::nothrow) CommonService(); +} + +bool +CommonService::OnAppInitializing(AppRegistry& appRegistry) +{ + return true; +} + +bool +CommonService::OnAppInitialized(void) +{ + InitializeServices(); + __pSystemInfoService->CachingSystemInformation(); + return true; +} + +bool +CommonService::OnAppWillTerminate(void) +{ + return true; +} + +bool +CommonService::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) +{ + return true; +} + +void +CommonService::OnLowMemory(void) +{ +} + +void +CommonService::OnBatteryLevelChanged(BatteryLevel batteryLevel) +{ +} + +void +CommonService::InitializeServices(void) +{ + result r = E_SUCCESS; + + __pSettingService = _SettingService::GetInstance(); + SysLogException(NID_SYS, E_SUCCESS, "Setting done"); + __pRuntimeInfoStub = _RuntimeInfoStub::GetInstance(); + SysLogException(NID_SYS, E_SUCCESS, "Runtime done"); + __pDeviceManagerStub = _DeviceManagerStub::GetInstance(); + SysLogException(NID_SYS, E_SUCCESS, "Device done"); + __pPowerManagerStub = _PowerManagerStub::GetInstance(); + SysLogException(NID_SYS, E_SUCCESS, "Power done"); + + unique_ptr<_UiManagerStub> pUiManagerStub(new (std::nothrow) _UiManagerStub()); + SysTryReturnVoidResult(NID_UI, pUiManagerStub, E_OUT_OF_MEMORY, "Memory is insufficient."); + + r = pUiManagerStub->Construct(); + SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "Propagating."); + + __pUiManagerStub = move(pUiManagerStub); + SysLogException(NID_SYS, E_SUCCESS, "UI done"); + + __pMessagingIpcStub.reset(new (std::nothrow) Tizen::Messaging::_MessagingIpcStub()); + SysTryReturnVoidResult(NID_MSG, __pMessagingIpcStub, E_OUT_OF_MEMORY, "Memory is insufficient."); + + r = __pMessagingIpcStub->Construct(); + SysTryReturnVoidResult(NID_MSG, r == E_SUCCESS, r, "MsgStub Failed."); + SysLogException(NID_SYS, E_SUCCESS, "Message done"); + + __pSystemInfoService = _SystemInfoService::GetInstance(); + SysLogException(NID_SYS, E_SUCCESS, "System done"); + + __pAlarmExStub = _AlarmExStub::GetInstance(); + SysLogException(NID_SYS, E_SUCCESS, "AlarmEx done"); +} + diff --git a/src/CommonServiceEntry.cpp b/src/CommonServiceEntry.cpp new file mode 100644 index 0000000..ad25ee6 --- /dev/null +++ b/src/CommonServiceEntry.cpp @@ -0,0 +1,61 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#include "CommonService.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +_EXPORT_ int OspMain(int argc, char *pArgv[]); + +/** + * The entry function of Tizen C++ application called by the operating system. + */ +int +OspMain(int argc, char *pArgv[]) +{ + result r = E_SUCCESS; + + AppLog("Application started."); + ArrayList* pArgs = new ArrayList(); + pArgs->Construct(); + for (int i = 0; i < argc; i++) + { + pArgs->Add(*(new String(pArgv[i]))); + } + + r = Tizen::App::ServiceApp::Execute(CommonService::CreateInstance, pArgs); + if (IsFailed(r)) + { + AppLogException("Application execution failed-[%s].", GetErrorMessage(r)); + r &= 0x0000FFFF; + } + + pArgs->RemoveAll(true); + delete pArgs; + AppLog("Application finished."); + + return static_cast(r); +} +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/src/messaging/CMakeLists.txt b/src/messaging/CMakeLists.txt new file mode 100644 index 0000000..f56b0d0 --- /dev/null +++ b/src/messaging/CMakeLists.txt @@ -0,0 +1,35 @@ +SET (this_target messaging_service) + +INCLUDE_DIRECTORIES( + ${SLP_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/inc + /usr/include/msg-service + /usr/include/dbus-1.0 + /usr/lib/dbus-1.0/include + /usr/include/email-service + /usr/include/osp/messaging + ./ + ) + +SET (${this_target}_SOURCE_FILES + FMsg_IpcCallbackHandler.cpp + FMsg_MessagingIpcStub.cpp + FMsg_SmsService.cpp + FMsg_WapPushService.cpp + FMsg_CbsMaker.cpp +) + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") + +## SET EXTRA COMPILER FLAGS +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC" ) + +## SET C COMPILER FLAGS +SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## SET CPP COMPILER FLAGS +SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## Create Library +ADD_LIBRARY (${this_target} STATIC ${${this_target}_SOURCE_FILES}) + diff --git a/src/messaging/FMsg_CbsMaker.cpp b/src/messaging/FMsg_CbsMaker.cpp new file mode 100644 index 0000000..acaf1d4 --- /dev/null +++ b/src/messaging/FMsg_CbsMaker.cpp @@ -0,0 +1,159 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/** + * + * @file FMsg_CbsMaker.cpp + * @brief This is the implementation file for the %_CbsMaker class. + * + * + * This file contains the implementation of the %_CbsMaker class. + * + * @endif + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "FMsg_Types.h" +#include "FMsg_CbsMaker.h" + +using namespace Tizen::Base; +using namespace Tizen::Messaging; +using namespace Tizen::Security; + +namespace Tizen { namespace Messaging +{ + +_CbsMaker::_CbsMaker(void) + : __fromId(-1) + , __toId(-1) + , __channelName(L"") + , __isChannelEnable(false) +{ +} + +_CbsMaker::_CbsMaker(const _CbsMaker& value) +{ + __fromId = value.__fromId; + __toId = value.__toId; + __channelName = value.__channelName; + __isChannelEnable = value.__isChannelEnable; +} + +_CbsMaker::~_CbsMaker(void) +{ +} + +_CbsMaker& +_CbsMaker::operator =(const _CbsMaker& rhs) +{ + if (this != &rhs) + { + __fromId = rhs.__fromId; + __toId = rhs.__toId; + __channelName = rhs.__channelName; + __isChannelEnable = rhs.__isChannelEnable; + } + + return (*this); +} + +result +_CbsMaker::Construct(int from, int to, const Tizen::Base::String& name) +{ + __fromId = from; + __toId = to; + __channelName = name; + __isChannelEnable = false; + + return E_SUCCESS; +} + +_CbsMaker* +_CbsMaker::GetCbsChannelN(int from, int to, const Tizen::Base::String& name) +{ + result r = E_SUCCESS; + _CbsMaker* pCbsChannel = null; + + pCbsChannel = new (std::nothrow) _CbsMaker(); + SysTryCatch(NID_MSG, pCbsChannel != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); + + r = pCbsChannel->Construct(from, to, name); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "failed to construct channel."); + + SetLastResult(GetLastResult()); + return pCbsChannel; + +CATCH: + SetLastResult(GetLastResult()); + + if(pCbsChannel) + { + delete pCbsChannel; + pCbsChannel = null; + } + + return null; +} + +_CbsMaker* +_CbsMaker::GetInstance(_CbsMaker& cbsChannel) +{ + return &cbsChannel; +} + +bool +_CbsMaker::IsActivated(void) const +{ + return __isChannelEnable; +} + +Tizen::Base::String +_CbsMaker::GetName(void) const +{ + return __channelName; +} + +result +_CbsMaker::GetRange(int& from, int& to) const +{ + result r = E_SUCCESS; + + from = __fromId; + to = __toId; + + return r; +} + +void +_CbsMaker::SetCbsChannelName(Tizen::Base::String channelName) +{ + __channelName = channelName; +} + +void +_CbsMaker::SetCbsChannelState(bool isChannelEnable) +{ + __isChannelEnable = isChannelEnable; +} + +} } // Tizen::Messaging diff --git a/src/messaging/FMsg_CbsMaker.h b/src/messaging/FMsg_CbsMaker.h new file mode 100644 index 0000000..caf9554 --- /dev/null +++ b/src/messaging/FMsg_CbsMaker.h @@ -0,0 +1,67 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/** + * + * @file FMsg_CbsMaker.h + * @brief This is the header file for the _CbsMaker class. + * + * + * This header file contains the declarations of the _CbsMaker class. + * + * @endif + */ + +#ifndef _FMSG_INTERNAL_CBS_MAKER_H_ +#define _FMSG_INTERNAL_CBS_MAKER_H_ + +namespace Tizen { namespace Messaging +{ + + + +class _CbsMaker + : public Tizen::Base::Object +{ +public: + + + virtual ~_CbsMaker(void); + + result GetRange(int& from, int& to) const; + Tizen::Base::String GetName(void) const; + bool IsActivated(void) const; + void SetCbsChannelName(Tizen::Base::String channelName); + void SetCbsChannelState(bool isChannelEnable); + static _CbsMaker* GetCbsChannelN(int from, int to, const Tizen::Base::String& name); + static _CbsMaker* GetInstance(_CbsMaker& cbsChannel); + +public: + + _CbsMaker(void); + _CbsMaker(const _CbsMaker& rhs); + _CbsMaker& operator =(const _CbsMaker& rhs); + result Construct(int from, int to, const Tizen::Base::String& name); + +private: + int __fromId; + int __toId; + Tizen::Base::String __channelName; + bool __isChannelEnable; +}; // _CbsMaker + +} } // Tizen::Messaging +#endif // _FMSG_INTERNAL_CBS_MAKER_H_ diff --git a/src/messaging/FMsg_IpcCallbackHandler.cpp b/src/messaging/FMsg_IpcCallbackHandler.cpp new file mode 100644 index 0000000..9f27b54 --- /dev/null +++ b/src/messaging/FMsg_IpcCallbackHandler.cpp @@ -0,0 +1,971 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/** + * @file FMsg_IpcCallbackHandler.cpp + * @brief This is the implementation file for the %_IpcCallbackHandler class. + * + * This file contains the implementation of the %_IpcCallbackHandler class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FMsg_IpcCallbackHandler.h" +#include "FMsg_SmsService.h" +#include "FMsg_Types.h" +#include "FMsg_CbsMaker.h" +#include "FMsg_MessagingIpcStub.h" +#include "FMsg_WapPushService.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; + +namespace Tizen { namespace Messaging +{ + +_IpcCallbackHandler* _IpcCallbackHandler::__pMessageCallbackHandler = 0; +bool _IpcCallbackHandler::__destroyed = false; + +_IpcCallbackHandler::_IpcCallbackHandler(void) + : __msgHandle(0) + , __cbsSettingsHandle(0) + , __pCbsChannelList(0) + , __pTempCbsChannelList(0) + , __callbackRegistered(false) + , __incomingSmsCallbackRegistered(true) + , __pWapPushClientId(null) + ,__pSmsClientId(null) + ,__pCbsEtwsClientId(null) + +{ +} + +result +_IpcCallbackHandler::Construct() +{ + result r = E_SUCCESS; + + __pTempCbsChannelList = new (std::nothrow) ArrayList(); + SysTryReturnResult(NID_MSG, __pTempCbsChannelList != null, E_OUT_OF_MEMORY, "memory allocation failed"); + r = __pTempCbsChannelList->Construct(); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to construct an ArrayList"); + std::atexit(CloseCbsSettingsHandle); + + return r; +} + +_IpcCallbackHandler::~_IpcCallbackHandler(void) +{ + + if (__msgHandle) + { + msg_close_msg_handle(&__msgHandle); + __msgHandle = 0; + } + + if (__cbsSettingsHandle) + { + msg_release_struct(&__cbsSettingsHandle); + __cbsSettingsHandle = 0; + } + + if (__pTempCbsChannelList) + { + if (__pTempCbsChannelList->GetCount() > 0) + { + __pTempCbsChannelList->RemoveAll(true); + } + delete __pTempCbsChannelList; + __pTempCbsChannelList = null; + } +} + +_IpcCallbackHandler* +_IpcCallbackHandler::GetInstance(void) +{ + SysTryReturn(NID_MSG, __destroyed == false, null, E_SYSTEM, "Instance Dead"); + + result r = E_SUCCESS; + + if (!__pMessageCallbackHandler) + { + __pMessageCallbackHandler = new (std::nothrow) _IpcCallbackHandler(); + SysTryReturn(NID_MSG, __pMessageCallbackHandler != NULL, null, E_SYSTEM, "failed to create instance"); + + if (__pMessageCallbackHandler) + { + r = __pMessageCallbackHandler->Construct(); + + if (r != E_SUCCESS) + { + delete __pMessageCallbackHandler; + __pMessageCallbackHandler = 0; + } + } + } + + return __pMessageCallbackHandler; +} + +int +_IpcCallbackHandler::OpenMessageHandle(msg_handle_t& messageHandle) +{ + int err = MSG_SUCCESS; + + if (!__msgHandle) + { + err = msg_open_msg_handle(&__msgHandle); + if ( err != MSG_SUCCESS ) + { + __msgHandle = null; + } + + } + + messageHandle = __msgHandle; + return err; +} + +int +_IpcCallbackHandler::OpenCbsSettingsHandle(msg_struct_t& cbsSettingsHandle) +{ + int err = MSG_SUCCESS; + + if (!__cbsSettingsHandle) + { + __cbsSettingsHandle = msg_create_struct(MSG_STRUCT_SETTING_CB_OPT); + if (__cbsSettingsHandle && __msgHandle) + { + err = msg_get_cb_opt(__msgHandle, __cbsSettingsHandle); + } + } + + cbsSettingsHandle = __cbsSettingsHandle; + return err; +} + +result +_IpcCallbackHandler::AddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate) +{ + result r = E_SUCCESS; + int fromId = 0; + int toId = 0; + bool channelFound = false; + SysLog(NID_MSG, "AddCbsChannel from %d to %d name %ls activate %d ",from, to, name.GetPointer(), activate); + + for (int index = 0; index < __pTempCbsChannelList->GetCount(); index++) + { + _CbsMaker* pCbsChannel = null; + pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(index)); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + + pCbsChannel->GetRange(fromId, toId); + if (from == fromId && to == toId) + { + channelFound = true; + break; // found channel to be updated. + } + + } + SysTryReturn(NID_MSG, channelFound == false, r = E_ALREADY_SET, E_ALREADY_SET, "Failed due to already cb range."); + + if (!channelFound) + { + _CbsMaker* pCbsChannel = null; + pCbsChannel = _CbsMaker::GetCbsChannelN(from, to, name); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + + if (activate) + { + _CbsMaker::GetInstance(*pCbsChannel)->SetCbsChannelState(activate); + } + r =__pTempCbsChannelList->Add(*pCbsChannel); + SysTryReturn(NID_MSG,r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to set the channel."); + + } + + r = SaveCbsSettings(); + return r; +} + +result +_IpcCallbackHandler::RemoveCbsChannel(int from, int to) +{ + result r = E_SUCCESS; + int fromId = 0; + int toId = 0; + bool channelFound = false; + _CbsMaker* pCbsChannel = NULL; + SysLog(NID_MSG, "RemoveCbsChannel from %d %d ",from, to); + + for (int index = 0; index < __pTempCbsChannelList->GetCount(); index++) + { + pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(index)); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + + pCbsChannel->GetRange(fromId, toId); + if (from == fromId && to == toId) + { + channelFound = true; // found channel to be removed. + __pTempCbsChannelList->RemoveAt(index); + index--; + delete pCbsChannel; + + } + } + + + if (!channelFound) + { + return E_OBJ_NOT_FOUND; + } + r = SaveCbsSettings(); + SysTryReturn(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to remove the channel."); + + return r; +} + +result +_IpcCallbackHandler::SearchCbsChannel(int from, int to, int& index) +{ + result r = E_SUCCESS; + int fromId = 0; + int toId = 0; + bool channelFound = false; + _CbsMaker* pCbsChannel = NULL; + SysLog(NID_MSG, "SearchCbsChannel from %d %d ",from, to); + + for (int tempIndex = 0; tempIndex < __pTempCbsChannelList->GetCount(); tempIndex++) + { + pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(tempIndex)); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + + pCbsChannel->GetRange(fromId, toId); + if (from == fromId && to == toId) + { + channelFound = true; + index = tempIndex; + break; // found channel to be searched. + } + } + + if (!channelFound) + { + return E_OBJ_NOT_FOUND; + } + + return r; +} + +result +_IpcCallbackHandler::UpdateCbsChannel(int from, int to, Tizen::Base::String name, bool activate) +{ + result r = E_SUCCESS; + int fromId = 0; + int toId = 0; + bool channelFound = false; + int index = 0; + _CbsMaker* pCbsChannel = NULL; + SysLog(NID_MSG, "UpdateCbsChannel from %d to %d name %ls activate %d ",from, to, name.GetPointer(), activate); + + for (int i = 0; i < __pTempCbsChannelList->GetCount(); i++) + { + pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(i)); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + + pCbsChannel->GetRange(fromId, toId); + if (from == fromId && to == toId) + { + channelFound = true; + index = i; + break; // found channel to be updated. + } + } + + if (!channelFound) + { + return E_OBJ_NOT_FOUND; + } + + // set cbs channel name + _CbsMaker::GetInstance(*pCbsChannel)->SetCbsChannelName(name); + + if (activate) + { + _CbsMaker::GetInstance(*pCbsChannel)->SetCbsChannelState(activate); + } + else + { + _CbsMaker::GetInstance(*pCbsChannel)->SetCbsChannelState(false); + } + //For changing to latest + __pTempCbsChannelList->RemoveAt(index); + __pTempCbsChannelList->Add(*pCbsChannel); + + r = SaveCbsSettings(); + SysTryReturn(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to save the channel."); + + return r; +} + +result +_IpcCallbackHandler::GetCbsChannel(int index, int& from, int& to, Tizen::Base::String& name, bool& activate) +{ + result r = E_SUCCESS; + _CbsMaker* pCbsChannel = NULL; + + pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(index)); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + + pCbsChannel->GetRange(from, to); + name = pCbsChannel->GetName(); + if (pCbsChannel->IsActivated()) + { + activate = true; + } + else + { + activate = false; + } + return r; +} + +result +_IpcCallbackHandler::GetCbsChannelsCount(int& count) +{ + result r = E_SUCCESS; + + if (__pTempCbsChannelList) + { + count = __pTempCbsChannelList->GetCount(); + } + + return r; +} + +result +_IpcCallbackHandler::SaveCbsSettings() +{ + int err = MSG_SUCCESS; + result r = E_SUCCESS; + int fromId = 0; + int toId = 0; + bool isChannelActive = false; + String channelName; + char* pTempChannelName = null; + + SysTryReturn(NID_MSG, __pTempCbsChannelList != null, r = E_SYSTEM, E_SYSTEM, "Failed to save the channel."); + err = msg_get_list_handle(__cbsSettingsHandle, MSG_CB_CHANNEL_LIST_STRUCT, (void **)&__pCbsChannelList); + SysTryReturn(NID_MSG, err == MSG_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel handle."); + SysLog(NID_MSG, "SaveCbsSettings Count %d, %d ",__pCbsChannelList->nCount,__pTempCbsChannelList->GetCount()); + __pCbsChannelList->nCount = __pTempCbsChannelList->GetCount(); + + // save Channel List + for (int index = 0; index < __pTempCbsChannelList->GetCount(); index++) + { + Tizen::Messaging::_CbsMaker* pCbsChannel = dynamic_cast< Tizen::Messaging::_CbsMaker* >(__pTempCbsChannelList->GetAt(index)); + SysTryReturn(NID_MSG, pCbsChannel != null, r = E_SYSTEM, E_SYSTEM, "Failed to get the channel."); + pCbsChannel->GetRange(fromId, toId); + channelName = pCbsChannel->GetName(); + if (pCbsChannel->IsActivated()) + { + isChannelActive = true; + } + + pTempChannelName = _StringConverter::CopyToCharArrayN(channelName); + SysTryReturn(NID_MSG, pTempChannelName != null, r = E_OUT_OF_MEMORY, r, "Memory allocation failed."); + + msg_set_bool_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ACTIVATE_BOOL, isChannelActive); + msg_set_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_FROM_INT, fromId); + msg_set_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_TO_INT, toId); + msg_set_str_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_NAME_STR, + pTempChannelName,CB_CHANNEL_NAME_MAX); + + if (pTempChannelName) + { + delete[] pTempChannelName; + pTempChannelName = null; + } + } + + err = msg_set_cb_opt(__msgHandle, __cbsSettingsHandle); + r = ConvertException(err); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to save the channel.[%d] ",err); + return r; +} + +result +_IpcCallbackHandler::LoadCbsSettings() +{ + int err = MSG_SUCCESS; + result r = E_SUCCESS; + _CbsMaker* pCbsChannel = NULL; + int fromId = 0; + int toId = 0; + bool isChannelActive = false; + char channelName[CB_CHANNEL_NAME_MAX + 1] = {0,}; + + if (__pTempCbsChannelList->GetCount() > 0) + { + __pTempCbsChannelList->RemoveAll(true); + } + + if (__cbsSettingsHandle) + { + // Load Channel List + err = msg_get_list_handle(__cbsSettingsHandle, MSG_CB_CHANNEL_LIST_STRUCT, (void **)&__pCbsChannelList); + r = ConvertException(err); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to open cbs Settings Handle"); + + for (int index = 0; index < __pCbsChannelList->nCount; index++) + { + msg_get_bool_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ACTIVATE_BOOL, &isChannelActive); + msg_get_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_FROM_INT, &fromId); + msg_get_int_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_ID_TO_INT, &toId); + msg_get_str_value(__pCbsChannelList->msg_struct_info[index], MSG_CB_CHANNEL_NAME_STR, + channelName,CB_CHANNEL_NAME_MAX); + if((toId >= 0) && (fromId >= 0) && (toId >= fromId) && (toId <= MAX_CBS_CHANNEL_LIMIT) && ((toId - fromId) <= MAX_CBS_CHANNEL_RANGE)) + { + pCbsChannel = _CbsMaker::GetCbsChannelN(fromId, toId, String(channelName)); + SysTryReturnResult(NID_MSG, pCbsChannel != null, E_SYSTEM, "Failed to get the channel."); + if (isChannelActive) + { + _CbsMaker::GetInstance(*pCbsChannel)->SetCbsChannelState(isChannelActive); + } + __pTempCbsChannelList->Add(*pCbsChannel); + } + else + { + SysLog(NID_MSG, "Load CBS Error: From[%d] To[%d] ",fromId, toId); + + } + } + } + + return r; + +} + +int +_IpcCallbackHandler::CloseMessageHandle() +{ + int err = MSG_SUCCESS; + + if (__msgHandle) + { + err = msg_close_msg_handle(&__msgHandle); + __msgHandle = 0; + __callbackRegistered = false; + } + + return err; +} + +void +_IpcCallbackHandler::CloseCbsSettingsHandle() +{ + + if (__pMessageCallbackHandler) + { + delete __pMessageCallbackHandler; + __pMessageCallbackHandler = null; + } + __destroyed = true; + +} + +void +_IpcCallbackHandler::SetInComingSmsCallback(bool incomingSmsCallbackRegistered) +{ + __incomingSmsCallbackRegistered = incomingSmsCallbackRegistered; +} + +void +_IpcCallbackHandler::IncomingSmsCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam) +{ + + int msgSize = 0; + msg_get_int_value(newMsg, MSG_MESSAGE_DATA_SIZE_INT, &msgSize); + char msgText[msgSize + 1]; + memset(msgText, 0, msgSize + 1); + msg_get_str_value(newMsg, MSG_MESSAGE_SMS_DATA_STR, msgText, msgSize); + String message(msgText); + + int port = -1; + msg_get_int_value(newMsg, MSG_MESSAGE_DEST_PORT_INT, &port); + + int displayTime = -1; + msg_get_int_value(newMsg, MSG_MESSAGE_DISPLAY_TIME_INT, &displayTime); + //DateTime receivedTime = _MsgUtil::ConvertTime((time_t *) &displayTime); + + char address[MAX_ADDRESS_VAL_LEN] = {0, }; + msg_struct_list_s* pAddrList = NULL; + msg_struct_t addrInfo = NULL; + msg_get_list_handle(newMsg, MSG_MESSAGE_ADDR_LIST_STRUCT, (void **)&pAddrList); + addrInfo = pAddrList->msg_struct_info[0]; + msg_get_str_value(addrInfo, MSG_ADDRESS_INFO_ADDRESS_VALUE_STR, address, MAX_ADDRESS_VAL_LEN); + String senderAddress(address); + + SysLog(NID_MSG, "hMsgHandle: [%d]", hMsgHandle); + SysLog(NID_MSG, "msg_body: [%s]", msgText); + SysLog(NID_MSG, "port: [%d]", port); + //SysLog(NID_MSG, "received time: [%s]", ctime(pReceivedTime)); + + SysTryReturnVoidResult(NID_MSG, GetInstance()->__pSmsClientId != null, E_OUT_OF_MEMORY,"failed to get client id."); + IMapEnumerator* pMapEnum = GetInstance()->__pSmsClientId->GetMapEnumeratorN(); + SysTryReturnVoidResult(NID_MSG, pMapEnum != null, E_OUT_OF_MEMORY,"MapEnum failed."); + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + Integer* pKey = null; + String* pValue = null; + String portNum; + + pKey = static_cast< Integer* > (pMapEnum->GetKey()); + pValue = static_cast< String* > (pMapEnum->GetValue()); + SysLog(NID_MSG, "pKey %d, value %ls", pKey->ToInt(), pValue->GetPointer()); + portNum.Append(port); + if (pValue->Contains(portNum)) + { + SysLog(NID_MSG, "pKey %d, value %ls", pKey->ToInt(), pValue->GetPointer()); + _SmsService::GetStubInstance()->IncomingSmsCallback(port, displayTime, message, senderAddress,pKey->ToInt()); + + } +} + + delete pMapEnum; + SysLog(NID_MSG, "End"); + + +} + +void +_IpcCallbackHandler::IncomingCbsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam) +{ + + int tempReceivedTime = 0; + DateTime receivedTime; + bool etwsNotifiation = false; + int messgeId = 0; + int serialNumber = 0; + int length = 0; + int cbsType = -1; + Tizen::Base::ByteBuffer msgSerialNumber; + + msg_get_int_value(newMsg, MSG_CB_MSG_RECV_TIME_INT, &tempReceivedTime); + receivedTime = __pMessageCallbackHandler->ConvertTime((time_t *) &tempReceivedTime); + + msg_get_int_value(newMsg, MSG_CB_MSG_MSG_ID_INT, &messgeId); + msg_get_int_value(newMsg, MSG_CB_MSG_SERIAL_NUM_INT, &serialNumber); + msg_get_int_value(newMsg, MSG_CB_MSG_TYPE_INT, &cbsType); + + msgSerialNumber.Construct(sizeof(int)); + msgSerialNumber.SetInt(0, serialNumber); + msgSerialNumber.SetPosition(0); + + if (cbsType == MSG_TYPE_SMS_ETWS_PRIMARY) + { + int etwsWarningType; + char etwsWarningInfo[MESSAGES_ETWS_WARNING_INFO_LEN]; + Tizen::Base::ByteBuffer msgSecurityInfo; + Tizen::Base::ByteBuffer etwsMsgWarningType; + msg_get_int_value(newMsg, MSG_CB_MSG_ETWS_WARNING_TYPE_INT, &etwsWarningType); + msg_get_str_value(newMsg, MSG_CB_MSG_ETWS_WARNING_SECU_INFO_STR, etwsWarningInfo, MESSAGES_ETWS_WARNING_INFO_LEN); + + String etwsSecurityInfo(etwsWarningInfo); + length = etwsSecurityInfo.GetLength(); + msgSecurityInfo.Construct(length); + msgSecurityInfo.SetArray((byte*) etwsWarningInfo, 0, length); + msgSecurityInfo.SetPosition(0); + + etwsMsgWarningType.Construct(sizeof(int)); + etwsMsgWarningType.SetInt(0, etwsWarningType); + etwsMsgWarningType.SetPosition(0); + + etwsNotifiation = true; + + SysLog(NID_MSG, "cbs etwsWarningType: [%d]", etwsWarningType); + SysLog(NID_MSG, "cbs etwsWarningInfo: [%s]", etwsWarningInfo); + + SysTryReturnVoidResult(NID_MSG, GetInstance()->__pCbsEtwsClientId != null, E_OUT_OF_MEMORY,"failed to get client id."); + for ( int i = 0; i < GetInstance()->__pCbsEtwsClientId->GetCount(); i++) + { + Integer * pId = static_cast (GetInstance()->__pCbsEtwsClientId->GetAt(i)); + _SmsService::GetStubInstance()->IncomingEtwsCallback(tempReceivedTime, msgSerialNumber, msgSecurityInfo, messgeId, etwsMsgWarningType, pId->ToInt()); + } + + + } + else + { + int dataCodingScheme = 0; + int msgSize = 0; + + msg_get_int_value(newMsg, MSG_CB_MSG_CB_TEXT_LEN_INT, &msgSize); + char msgBody[msgSize + 1]; + memset(msgBody, 0, msgSize + 1); + msg_get_str_value(newMsg, MSG_CB_MSG_CB_TEXT_STR, msgBody, msgSize + 1); + String message(msgBody); // porting char* to String + + msg_get_int_value(newMsg, MSG_CB_MSG_DCS_INT, &dataCodingScheme); + Tizen::Base::Integer dataCodingSchemeTemp(dataCodingScheme); + + //language type of cbs message + String messageLanguage(L""); + byte higherNibble = dataCodingScheme & 0xf0; + byte lowerNibble = dataCodingScheme & 0x0f; + + //check higher nibble + // if higher nibble 0000 + if (higherNibble == 0x00) + { + messageLanguage = GetCbsLanguageType(lowerNibble); + } + else if (higherNibble == 0x01) + { + // if higher nibble is 0001, get language type from framework + int len = 15; + char type[len + 1]; + memset(type, 0, len + 1); + msg_get_str_value(newMsg, MSG_CB_MSG_LANGUAGE_TYPE_STR, type, len); + messageLanguage = String(type); + } + else if (higherNibble == 0x20 && lowerNibble == 0x00) + { + // if 0010 0000 + messageLanguage = String(L"CS"); + } + else + { + // use empty string + } + + SysTryReturnVoidResult(NID_MSG, GetInstance()->__pCbsEtwsClientId != null, E_OUT_OF_MEMORY,"failed to get client id."); + for ( int i = 0; i < GetInstance()->__pCbsEtwsClientId->GetCount(); i++) + { + Integer * pId = static_cast (GetInstance()->__pCbsEtwsClientId->GetAt(i)); + _SmsService::GetStubInstance()->IncomingCbsCallback(message, msgSerialNumber, tempReceivedTime, messgeId, dataCodingScheme, messageLanguage, pId->ToInt()); + } + + SysLog(NID_MSG, "cbs msg_body: [%s]", msgBody); + SysLog(NID_MSG, "cbs dataCodingScheme: [%d]", dataCodingScheme); + SysLog(NID_MSG, "cbs languageType: [%ls]", messageLanguage.GetPointer()); + } + + SysLog(NID_MSG, "cbs msg_id: [%d]", messgeId); + SysLog(NID_MSG, "cbs serialNumber: [%d]", serialNumber); + SysLog(NID_MSG, "cbs etwsNotifiation: [%d]", etwsNotifiation); +} + +void +_IpcCallbackHandler::IncomingWapPushMessageCallback(msg_handle_t hMsgHandle, const char* pHeader, const char* pBody, int bodyLength, void* pUserParam) +{ + + String msgHeader(pHeader); + Tizen::Base::ByteBuffer msgBody; + msgBody.Construct(bodyLength); + msgBody.SetArray((byte*) pBody, 0, bodyLength); + msgBody.SetPosition(0); + + SysLog(NID_MSG, "push msg body: [%s]", pBody); + SysLog(NID_MSG, "push msg header: [%s]", pHeader); + SysLog(NID_MSG, "push body length: [%d]", bodyLength); + + SysTryReturnVoidResult(NID_MSG, _IpcCallbackHandler::GetInstance()->__pWapPushClientId != null, E_OUT_OF_MEMORY, "failed to get client id."); + IMapEnumerator* pMapEnum = _IpcCallbackHandler::GetInstance()->__pWapPushClientId->GetMapEnumeratorN(); + SysTryReturnVoidResult(NID_MSG, pMapEnum != null, E_OUT_OF_MEMORY,"MapEnum failed."); + + while (pMapEnum->MoveNext() == E_SUCCESS) + { + Integer* pKey = null; + String* pValue = null; + + pKey = static_cast< Integer* > (pMapEnum->GetKey()); + pValue = static_cast< String* > (pMapEnum->GetValue()); + + + if (msgHeader.Contains(*pValue)) + { + SysLog(NID_MSG, "pKey %d, value %ls", pKey->ToInt(), pValue->GetPointer()); + _WapPushService::GetStubInstance()->IncomingWapPushMessageCallback(msgHeader, msgBody, bodyLength, pKey->ToInt()); + } + } + + delete pMapEnum; + SysLog(NID_MSG, "End"); + +} + +Tizen::Base::String +_IpcCallbackHandler::GetCbsLanguageType(byte codingScheme) +{ + String languageType(L""); + + switch(codingScheme) + { + case 0x00: + languageType = String(L"DE"); + break; + case 0x01: + languageType = String(L"EN"); + break; + case 0x02: + languageType = String(L"IT"); + break; + case 0x03: + languageType = String(L"FR"); + break; + case 0x04: + languageType = String(L"ES"); + break; + case 0x05: + languageType = String(L"NL"); + break; + case 0x06: + languageType = String(L"SV"); + break; + case 0x07: + languageType = String(L"DA"); + break; + case 0x08: + languageType = String(L"PT"); + break; + case 0x09: + languageType = String(L"FI"); + break; + case 0x0a: + languageType = String(L"NO"); + break; + case 0x0b: + languageType = String(L"EL"); + break; + case 0x0c: + languageType = String(L"TR"); + break; + case 0x0d: + languageType = String(L"HU"); + break; + case 0x0e: + languageType = String(L"PL"); + break; + case 0x0f: + languageType = String(L""); + SysLog(NID_MSG, "Language unspecified."); + break; + default: + break; + }; + + return languageType; +} + +result +_IpcCallbackHandler::SetWapPushClientId(const Tizen::Base::String& AppId, int id) +{ + result r = E_SUCCESS; + Integer *pId = new Integer(id); + String *pApp = new String(AppId); + + if(!__pWapPushClientId) + { + __pWapPushClientId = new (std::nothrow) Tizen::Base::Collection::MultiHashMap(); + SysTryCatch(NID_MSG, __pWapPushClientId != null, ,E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] memory allocation failed."); + r = __pWapPushClientId->Construct(); + SysTryCatch(NID_MSG, r == E_SUCCESS, delete __pWapPushClientId , r, "[%s] Contruct of MultiHashMap Failed.", GetErrorMessage(r)); + } + if(!__pWapPushClientId->Contains(*pId, *pApp)) + { + r = __pWapPushClientId->Add(*pId, *pApp); + SysLog(NID_MSG, "AppId %ls, Client %d",AppId.GetPointer(), id); + return r; + } + + delete pId; + delete pApp; + return r; + +CATCH: + delete pId; + delete pApp; + return r; + +} + +result +_IpcCallbackHandler::SetSmsClientId (int port, int id) +{ + result r = E_SUCCESS; + Integer *pId = new Integer(id); + String *pPort = new String; + + pPort->Append(port); + if(!__pSmsClientId) + { + __pSmsClientId = new (std::nothrow) Tizen::Base::Collection::MultiHashMap(); + SysTryCatch(NID_MSG, __pSmsClientId != null, ,E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] memory allocation failed."); + r = __pSmsClientId->Construct(); + SysTryCatch(NID_MSG, r == E_SUCCESS, delete __pSmsClientId , r, "[%s] Contruct of MultiHashMap Failed.", GetErrorMessage(r)); + + } + if(!__pSmsClientId->Contains(*pId, *pPort)) + { + r = __pSmsClientId->Add(*pId, *pPort); + SysLog(NID_MSG, "Port %ls, Client %d",pPort->GetPointer(), id); + return r; + } + delete pId; + delete pPort; + return r; + +CATCH: + delete pId; + delete pPort; + return r; +} + + +result +_IpcCallbackHandler::SetCbsEtwsClientId ( int id) +{ + result r = E_SUCCESS; + Integer *pId = new Integer(id); + + if(!__pCbsEtwsClientId) + { + __pCbsEtwsClientId = new (std::nothrow) Tizen::Base::Collection::ArrayList(); + SysTryCatch(NID_MSG, __pCbsEtwsClientId != null, ,E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] memory allocation failed."); + r = __pCbsEtwsClientId->Construct(); + SysTryCatch(NID_MSG, r == E_SUCCESS, delete __pCbsEtwsClientId , r, "[%s] Contruct of ArrayList Failed.", GetErrorMessage(r)); + + } + if(!__pCbsEtwsClientId->Contains(*pId)) + { + r = __pCbsEtwsClientId->Add(*pId); + SysLog(NID_MSG, "Client %d",id); + return r; + } + delete pId; + return r; + +CATCH: + delete pId; + return r; + +} + +result +_IpcCallbackHandler::RemoveClientId ( int id) +{ + result r = E_SUCCESS; + Integer *pId = new Integer(id); + + if(__pWapPushClientId) + { + r = __pWapPushClientId->Remove(*pId); + SysLog(NID_MSG, "WapPush Removed :Client %d",id); + + } + if(__pSmsClientId) + { + r = __pSmsClientId->Remove(*pId); + SysLog(NID_MSG, "SMS Removed :Client %d",id); + + } + if(__pCbsEtwsClientId) + { + + if(__pCbsEtwsClientId->Contains(*pId)) + { + r = __pCbsEtwsClientId->Remove(*pId); + SysLog(NID_MSG, "CbsEtws Removed :Client %d",id); + } + + } + + delete pId; + return r; +} + + +result +_IpcCallbackHandler::ConvertException(int err) const +{ + result r = E_SUCCESS; + + switch (err) + { + case MSG_SUCCESS: + r = E_SUCCESS; + break; + + case MSG_ERR_INVALID_PARAMETER: + case MSG_ERR_INVALID_MESSAGE: + case MSG_ERR_NULL_POINTER: + case MSG_ERR_NULL_MESSAGE: + r = E_INVALID_ARG; + break; + + case MSG_ERR_MEMORY_ERROR: + r = E_OUT_OF_MEMORY; + break; + + case MSG_ERR_SERVER_NOT_READY: + case MSG_ERR_TRANSPORT_ERROR: + case MSG_ERR_COMMUNICATION_ERROR: + r = E_NETWORK_UNAVAILABLE; + break; + + case MSG_ERR_NO_SIM: + r = E_DEVICE_UNAVAILABLE; + break; + + case MSG_ERR_PLUGIN_TAPI_FAILED: + r = E_FAILURE; + break; + + default: + r = E_SYSTEM; + break; + } + + return r; +} + +Tizen::Base::DateTime +_IpcCallbackHandler::ConvertTime(time_t* pTime) +{ + DateTime dateTime; + struct tm* pTempTime = null; + + pTempTime = gmtime(pTime); + if (pTempTime) + { + dateTime.SetValue(pTempTime->tm_year + 1900, pTempTime->tm_mon + 1, pTempTime->tm_mday, pTempTime->tm_hour, pTempTime->tm_min, pTempTime->tm_sec); + } + return dateTime; +} + + +} } // Tizen::Messaging diff --git a/src/messaging/FMsg_IpcCallbackHandler.h b/src/messaging/FMsg_IpcCallbackHandler.h new file mode 100644 index 0000000..96002e9 --- /dev/null +++ b/src/messaging/FMsg_IpcCallbackHandler.h @@ -0,0 +1,225 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/** + * @file FMsg_IpcCallbackHandler.h + * @brief This is the header file for _IpcCallbackHandler class. + * + * This header file contains declaration of _IpcCallbackHandler class + */ + +#ifndef _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_ +#define _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_ + +// includes +#include +#include +#include + +namespace Tizen { namespace Messaging +{ + +/** +* @class _IpcCallbackHandler +* @brief This class provides methods to use the SMS/MMS call back Handler service +* @since 2.1 +* +* This class provides methods to use the SMS/MMS call back Handler service . @n +*/ + +// forward declaration + +class _IpcCallbackHandler + : public Tizen::Base::Object +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.1 + */ + virtual ~_IpcCallbackHandler(void); + + /** + * Initializes the Messaging Hash Map table + * + * @since 3.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG Input parameter is NULL. + * @exception E_OUT_OF_MEMORY Memory error. + */ + result Construct(void); + + // Operation +public: + /** + * Gets the instance of SmsMmsCallbackHandler class. + * + * @since 2.1 + * @return instance of SmsMmsCallbackHandler class + */ + static _IpcCallbackHandler* GetInstance(void); + + /** + * gets the Message Handle for SMS/MMS operation. + * + * @since 3.0 + * @return An error code + * @param[in] messageHandle message Handle + * @exception MSG_SUCCESS The method was successful. + * @exception MSG_ERR_NULL_POINTER Input parameter is NULL. + * @exception MSG_ERR_MEMORY_ERROR Memory error. + */ + int OpenMessageHandle(msg_handle_t& messageHandle); + + /** + * gets the Message Handle for Cbs message operation. + * + * @since 3.0 + * @return An error code + * @param[in] cbsSettingsHandle cbs message Handle + * @exception MSG_SUCCESS The method was successful. + * @exception MSG_ERR_NULL_POINTER Input parameter is NULL. + * @exception MSG_ERR_MEMORY_ERROR Memory error. + */ + int OpenCbsSettingsHandle(msg_struct_t& cbsSettingsHandle); + + // Adds a CBS channel with specified parameters. + result AddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate); + + // Removes a CBS channel with specified parameters. + result RemoveCbsChannel(int from, int to); + + // Searches a CBS channel with specified parameters and returns index of channel found. + result SearchCbsChannel(int from, int to, int& index); + + // Updates a CBS channel with specified parameters. + result UpdateCbsChannel(int from, int to, Tizen::Base::String name, bool activate); + + // Gets a CBS channel data with specified index. + result GetCbsChannel(int index, int& from, int& to, Tizen::Base::String& name, bool& activate); + + // Gets a CBS channel count. + result GetCbsChannelsCount(int& count); + + /** + * loads the Cbs channels list. + * + * @since 3.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG Input parameter is NULL. + * @exception E_OUT_OF_MEMORY Memory error. + */ + result LoadCbsSettings(); + + /** + * saves the Cbs channels list. + * + * @since 3.0 + * @return An error code + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_ARG Input parameter is NULL. + * @exception E_OUT_OF_MEMORY Memory error. + */ + result SaveCbsSettings(); + + /** + * closes the CBS Message Handle. + * + * @since 3.0 + * @return An error code + * @exception MSG_SUCCESS The method was successful. + * @exception MSG_ERR_NULL_POINTER Input parameter is NULL. + * @exception MSG_ERR_MEMORY_ERROR Memory error. + */ + static void CloseCbsSettingsHandle(void); + + /** + * closes the Message Handle for SMS/MMS operation. + * + * @since 3.0 + * @return An error code + * @exception MSG_SUCCESS The method was successful. + * @exception MSG_ERR_NULL_POINTER Input parameter is NULL. + * @exception MSG_ERR_MEMORY_ERROR Memory error. + */ + int CloseMessageHandle(void); + + + static void IncomingSmsCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam); + + /** + * Sets the __incomingSmsCallbackRegistered flag. + * + * @since 3.0 + * @param[in] incomingSmsCallbackRegistered SMS registered flag + */ + void SetInComingSmsCallback(bool incomingSmsCallbackRegistered); + + /** + * Sets the Cbs And Etws UserEvent. + * + * @since 3.0 + * @param[in] msgType message type + * @param[in] pEvent message Event + */ + + // for incoming CBS/Etws + static void IncomingCbsMessageCallback(msg_handle_t hMsgHandle, msg_struct_t newMsg, void* pUserParam); + + // for incoming Wap push + static void IncomingWapPushMessageCallback(msg_handle_t hMsgHandle, const char* pHeader, const char* pBody, int bodyLength, void* pUserParam); + + //get cb message language type + static Tizen::Base::String GetCbsLanguageType(byte codingScheme); + + result SetWapPushClientId(const Tizen::Base::String& AppId, int id); + result SetSmsClientId (int port, int id); + result SetCbsEtwsClientId ( int id); + result RemoveClientId ( int id); + Tizen::Base::DateTime ConvertTime(time_t* pTime); + + // Life cycle +private: + /** + * This is the default constructor for this class. + * + * @since 2.1 + */ + _IpcCallbackHandler(void); + + result ConvertException(int err) const; + +private: + static _IpcCallbackHandler* __pMessageCallbackHandler; + msg_handle_t __msgHandle; + msg_struct_t __cbsSettingsHandle; + msg_struct_list_s* __pCbsChannelList; + Tizen::Base::Collection::ArrayList* __pTempCbsChannelList; + bool __callbackRegistered; + bool __incomingSmsCallbackRegistered; + Tizen::Base::Collection::MultiHashMap* __pWapPushClientId; + Tizen::Base::Collection::MultiHashMap* __pSmsClientId; + Tizen::Base::Collection::ArrayList* __pCbsEtwsClientId; + static bool __destroyed; + +}; // _IpcCallbackHandler + +} } // Tizen::Messaging + +#endif // _FMSG_INTERNAL_SMS_MMS_CALLBACK_HANDLER_H_ diff --git a/src/messaging/FMsg_MessagingIpcStub.cpp b/src/messaging/FMsg_MessagingIpcStub.cpp new file mode 100644 index 0000000..ee4a895 --- /dev/null +++ b/src/messaging/FMsg_MessagingIpcStub.cpp @@ -0,0 +1,583 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FMsg_MessagingIpcStub.cpp + * @brief This is the implementation file for the %_MessagingIpcStub class. + */ +#include +#include +#include +#include +#include +#include +#include +#include "FMsg_MessagingMessageTypes.h" +#include "FMsg_MessagingIpcStub.h" +#include "FMsg_IpcCallbackHandler.h" +#include "FMsg_WapPushService.h" +#include "FMsg_SmsService.h" +#include "FMsg_CbsMaker.h" + + +using namespace Tizen::Base; +using namespace Tizen::Io; +using namespace Tizen::Messaging; +using namespace Tizen::Security; + +namespace Tizen { namespace Messaging +{ + +_MessagingIpcStub::_MessagingIpcStub(void) + :__pWapPushService(null) + ,__pSmsService(null) + ,__pIpcServer(null) + ,__pCbsList(null) +{ +} + +_MessagingIpcStub::~_MessagingIpcStub(void) +{ + + if (__pIpcServer) + { + __pIpcServer->Stop(); + delete __pIpcServer; + __pIpcServer = null; + } + + if (__pCbsList) + { + __pCbsList->RemoveAll(true); + delete __pCbsList; + __pCbsList = null; + } + +} + +result +_MessagingIpcStub::Construct(void) +{ + result r = E_SUCCESS; + + __pIpcServer = new (std::nothrow) _IpcServer; + SysTryCatch(NID_MSG, __pIpcServer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + r = __pIpcServer->Construct(MESSAGING_IPC_SERVER_NAME, *this); + SysTryCatch(NID_MSG, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, + "[%s] A system error has been occurred. Failed to construct IpcServer.", GetErrorMessage(E_SYSTEM)); + + __pWapPushService = _WapPushService::GetInstance(this); + SysTryCatch(NID_MSG, __pWapPushService != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __pSmsService = _SmsService::GetInstance(this); + SysTryCatch(NID_MSG, __pSmsService != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __pCbsList = new (std::nothrow) Tizen::Base::Collection::ArrayList; + SysTryCatch(NID_MSG, __pCbsList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, + "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + __pCbsList->Construct(); + + SysLog(NID_MSG, "_MessagingIpcStub Construct."); + + return r; + +CATCH: + if (__pIpcServer) + { + __pIpcServer->Stop(); + delete __pIpcServer; + __pIpcServer = null; + } + + if (__pCbsList) + { + delete __pCbsList; + __pCbsList = null; + } + + return r; +} + +void +_MessagingIpcStub::OnIpcServerStarted(const Tizen::Io::_IpcServer& server) +{ + SysLog(NID_MSG, "_MessagingIpcStub started."); +} + +void +_MessagingIpcStub::OnIpcServerStopped(const Tizen::Io::_IpcServer& server) +{ + SysLog(NID_MSG, "_MessagingIpcStub stopped."); +} + +void +_MessagingIpcStub::OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId) +{ + SysLog(NID_MSG, "Connected with clientId[%d].", clientId); +} + +void +_MessagingIpcStub::OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId) +{ + + _IpcCallbackHandler::GetInstance()->RemoveClientId(clientId); + SysLog(NID_MSG, "Disconnected with clientId[%d].", clientId); +} + +void +_MessagingIpcStub::OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message) +{ + IPC_BEGIN_MESSAGE_MAP(_MessagingIpcStub, message) + IPC_MESSAGE_HANDLER(MessagingMsgStart_addWapPushEventListener, OnIpcAddWapPushEventListener, &server) + //IPC_MESSAGE_HANDLER(MessagingMsgStart_removeWapPushEventListener, OnIpcRemoveWapPushEventListener, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_registerCondition, OnIpcRegisterCondition, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_unregisterCondition, OnIpcUnregisterCondition, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_openCbsHandle, OnIpcOpenMsgHandle, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_openMsgHandle, OnIpcOpenCbsHandle, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_addSmsEventListener, OnIpcAddSmsEventListener, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_addCbsEtwsEventListener, OnIpcAddCbsEtwsEventListener, &server) + + IPC_MESSAGE_HANDLER(MessagingMsgStart_setSavingToCbsBoxEnabled, OnIpcSetSavingToCbsBoxEnabled, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_isCbsEnabled, OnIpcIsCbsEnabled, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_setCbsEnabled, OnIpcSetCbsEnabled, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_addCbsChannel, OnIpcAddCbsChannel, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_removeCbsChannel, OnIpcRemoveCbsChannel, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_getCbsChannelN, OnIpcGetCbsChannelN, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_getCbsChannelListN, OnIpcGetCbsChannelListN, &server) + IPC_MESSAGE_HANDLER(MessagingMsgStart_updateCbsChannel, OnIpcUpdateCbsChannel, &server) + IPC_END_MESSAGE_MAP() +} + + +void +_MessagingIpcStub::OnIpcAddWapPushEventListener(const Tizen::Base::String& wapApplicationId, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_WAPPUSH); + + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + { + + *pResult = __pWapPushService->AddWapPushEventListener(wapApplicationId, __pIpcServer->GetClientId()); + + } + +} + +void +_MessagingIpcStub::IncomingWapPushMessageCallback(Tizen::Base::String &header, Tizen::Base::ByteBuffer &body, int bodyLength, int clientId) +{ + + SysLog(NID_MSG, "IncomingWapPushMessageCallback with clientId : %d", clientId); + IPC::Message* pMessage = new (std::nothrow) MessagingMsgStart_wapPushEventCallBack(header, body, bodyLength); + SysTryReturnVoidResult(NID_MSG, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed."); + __pIpcServer->SendResponse(clientId, *pMessage); + SysLog(NID_MSG, "IncomingWapPushMessageCallback End clientId : %d", clientId); + +} + +/* +void +_MessagingIpcStub::OnIpcRemoveWapPushEventListener(const Tizen::Base::String& wapApplicationId, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_WAPPUSH); + + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + { + + *pResult = __pWapPushService->RemoveWapPushEventListener(wapApplicationId); + + } +} +*/ +void +_MessagingIpcStub::OnIpcRegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_WAPPUSH); + + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + { + *pResult = __pWapPushService->RegisterCondition(wapApplicationId,contentType); + } + +} + +void +_MessagingIpcStub::OnIpcUnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_WAPPUSH); + + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + { + + *pResult = __pWapPushService->UnregisterCondition(wapApplicationId, contentType); + + } + + + +} + +void +_MessagingIpcStub::OnIpcOpenMsgHandle(unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + + *pResult = __pSmsService->OpenMsgHandle(); + + + +} + + +void +_MessagingIpcStub::OnIpcOpenCbsHandle(unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + + *pResult = __pSmsService->OpenCbsHandle(); + + + +} + +void +_MessagingIpcStub::OnIpcAddSmsEventListener(int port, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_SMSTRIGGER); + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + *pResult = __pSmsService->AddSmsEventListener(port, __pIpcServer->GetClientId()); + +} + +void +_MessagingIpcStub::IncomingSmsCallback(int port, int displayTime, Tizen::Base::String &message, Tizen::Base::String &senderAddress, int clientId) +{ + + SysLog(NID_MSG, "IncomingSmsCallback with clientId : %d", clientId); + IPC::Message* pMessage = new (std::nothrow) MessagingMsgStart_incomingSmsCallback(port, displayTime, message, senderAddress); + SysTryReturnVoidResult(NID_MSG, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed."); + __pIpcServer->SendResponse(clientId, *pMessage); + +} + +void +_MessagingIpcStub::OnIpcAddCbsEtwsEventListener(bool enabled, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST); + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + *pResult = __pSmsService->AddCbsEtwsEventListener(enabled, __pIpcServer->GetClientId()); + SysLog(NID_MSG, "OnIpcAddCbsEtwsEventListener : %d", *pResult); + +} + + +void +_MessagingIpcStub::IncomingEtwsCallback(int tempReceivedTime, Tizen::Base::ByteBuffer &msgSerialNumber, Tizen::Base::ByteBuffer &msgSecurityInfo, int messgeId, Tizen::Base::ByteBuffer &etwsMsgWarningType, int clientId) +{ + + SysLog(NID_MSG, "IncomingEtwsCallback with clientId : %d", clientId); + IPC::Message* pMessage = new (std::nothrow) MessagingMsgStart_incomingEtwsCallback(tempReceivedTime, msgSerialNumber, msgSecurityInfo, messgeId, etwsMsgWarningType); + SysTryReturnVoidResult(NID_MSG, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed."); + __pIpcServer->SendResponse(clientId, *pMessage); + + + +} + +void +_MessagingIpcStub::IncomingCbsCallback(Tizen::Base::String &message, Tizen::Base::ByteBuffer &msgSerialNumber, int tempReceivedTime, int messgeId, int dataCodingScheme, Tizen::Base::String &messageLanguage, int clientId) +{ + + SysLog(NID_MSG, "IncomingCbsCallback with clientId : %d", clientId); + IPC::Message* pMessage = new (std::nothrow) MessagingMsgStart_incomingCbsCallback(message, msgSerialNumber, tempReceivedTime, messgeId, dataCodingScheme, messageLanguage); + SysTryReturnVoidResult(NID_MSG, pMessage != null , E_OUT_OF_MEMORY, "Memory allocation failed."); + __pIpcServer->SendResponse(clientId, *pMessage); + + + +} + +void +_MessagingIpcStub::OnIpcSetSavingToCbsBoxEnabled(bool enable, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST); + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + { + *pResult = __pSmsService->SetSavingToCbsBoxEnabled(enable); + } + +} + + +void +_MessagingIpcStub::OnIpcIsCbsEnabled(bool *isCbsEnabled, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST); + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + { + + *isCbsEnabled = __pSmsService->IsCbsEnabled(); + *pResult = GetLastResult(); + } + +} + + +void +_MessagingIpcStub::OnIpcSetCbsEnabled(bool enable, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST); + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + { + *pResult = __pSmsService->SetCbsEnabled(enable); + } + + +} + + +void +_MessagingIpcStub::OnIpcAddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST); + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + { + *pResult = __pSmsService->AddCbsChannel(from, to, name, activate); + } + + +} + + + +void +_MessagingIpcStub::OnIpcRemoveCbsChannel(int from, int to, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST); + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + { + *pResult = __pSmsService->RemoveCbsChannel(from, to); + } + + +} + + +void +_MessagingIpcStub::OnIpcGetCbsChannelN(int from, int to, bool *isActive, Tizen::Base::String *channelName, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST); + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + { _CbsMaker *pTemp = const_cast<_CbsMaker*>(__pSmsService->GetCbsChannelN(from, to)); + + if (null != pTemp) + { + *isActive = pTemp->IsActivated(); + *channelName = pTemp->GetName(); + delete pTemp; + } + else + { + *isActive = FALSE; + *channelName =L""; + + + } + *pResult = GetLastResult(); + + } + +} + +void +_MessagingIpcStub::OnIpcGetCbsChannelListN(Tizen::Base::Collection::ArrayList *pCbsList, unsigned long* pResult) +{ + + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls, Previous Cbs Count : %d", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer(), __pCbsList->GetCount()); + + __pCbsList->RemoveAll(true); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST); + + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + { + + *pResult = __pSmsService->GetCbsChannelListN(pCbsList); + __pCbsList->AddItems(*pCbsList); + } + +} + +void +_MessagingIpcStub::OnIpcUpdateCbsChannel(int from, int to, const Tizen::Base::String &name, bool isChannelEnable, unsigned long* pResult) +{ + SysLog(NID_MSG, "Received the request of getting the msg with clientId : %d, PackageId : %ls", + __pIpcServer->GetClientId(), __pIpcServer->GetClientPackageId().GetPointer()); + String packageId = __pIpcServer->GetClientPackageId(); + *pResult = _AccessController::CheckSystemPrivilege(packageId, _PRV_CELLBROADCAST); + if (*pResult != E_SUCCESS) + { + *pResult = E_PRIVILEGE_DENIED; + SysLogException(NID_MSG, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + } + else + *pResult = _IpcCallbackHandler::GetInstance()->UpdateCbsChannel(from, to, name, isChannelEnable); + +} + + +}} + + diff --git a/src/messaging/FMsg_MessagingIpcStub.h b/src/messaging/FMsg_MessagingIpcStub.h new file mode 100644 index 0000000..59a1425 --- /dev/null +++ b/src/messaging/FMsg_MessagingIpcStub.h @@ -0,0 +1,112 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FMsg_MessagingIpcStub.h + * @brief This is the header file for the %_MessagingIpcStub class. + * + * This header file contains the declarations of the %_MessagingIpcStub class. + */ + +#ifndef _MESSAGING_IPC_STUB_H_ +#define _MESSAGING_IPC_STUB_H_ + +#include + +namespace Tizen { namespace Base { +class String; +} } + +namespace Tizen { namespace Io { +class _IpcServer; +} } + +namespace Tizen { namespace Messaging { + +class _WapPushService; +class _SmsService; +class _CbsMaker; + + +/** + * @class _MessagingIpcStub + * @brief This class represents an IPC stub for the Connectivity daemon service. + * + * @since 2.1 + * + * This class represents an IPC stub for the wap push. + */ +class _MessagingIpcStub + : public Tizen::Base::Object + , public Tizen::Io::_IIpcServerEventListener +{ +public: + _MessagingIpcStub(void); + virtual ~_MessagingIpcStub(void); + + result Construct(void); + + virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server); + virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server); + virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId); + virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId); + virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message); + void IncomingWapPushMessageCallback(Tizen::Base::String &header, Tizen::Base::ByteBuffer &body, int bodyLength, int clientId); + void IncomingSmsCallback(int port, int displayTime, Tizen::Base::String &message, Tizen::Base::String &senderAddress, int clientId); + void IncomingEtwsCallback(int tempReceivedTime, Tizen::Base::ByteBuffer &msgSerialNumber, Tizen::Base::ByteBuffer &msgSecurityInfo, int messgeId, Tizen::Base::ByteBuffer &etwsMsgWarningType, int clientId); + void IncomingCbsCallback(Tizen::Base::String &message, Tizen::Base::ByteBuffer &msgSerialNumber, int tempReceivedTime, int messgeId, int dataCodingScheme, Tizen::Base::String &messageLanguage, int clientId); + + + +private: + + void OnIpcAddWapPushEventListener(const Tizen::Base::String& wapApplicationId, unsigned long* pResult); + //void OnIpcRemoveWapPushEventListener(const Tizen::Base::String& wapApplicationId, unsigned long* pResult); + void OnIpcRegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType, unsigned long* pResult); + void OnIpcUnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType, unsigned long* pResult); + void OnIpcOpenMsgHandle(unsigned long* pResult); + void OnIpcOpenCbsHandle(unsigned long* pResult); + void OnIpcAddSmsEventListener(int port, unsigned long* pResult); + void OnIpcAddCbsEtwsEventListener(bool enabled, unsigned long* pResult); + + void OnIpcSetSavingToCbsBoxEnabled(bool enable, unsigned long* pResult); + void OnIpcIsCbsEnabled(bool *isCbsEnabled, unsigned long* pResult); + void OnIpcSetCbsEnabled(bool enable, unsigned long* pResult); + void OnIpcAddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate, unsigned long* pResult); + void OnIpcRemoveCbsChannel(int from, int to, unsigned long* pResult); + void OnIpcGetCbsChannelN(int from, int to, bool *isActive, Tizen::Base::String *channelName, unsigned long* pResult); + void OnIpcGetCbsChannelListN(Tizen::Base::Collection::ArrayList *pCbsList, unsigned long* pResult); + void OnIpcUpdateCbsChannel(int from, int to, const Tizen::Base::String &name, bool isChannelEnable, unsigned long* pResult); + + + + + _MessagingIpcStub(const _MessagingIpcStub& rhs); + _MessagingIpcStub& operator =(const _MessagingIpcStub& rhs); + +private: + _WapPushService *__pWapPushService; + _SmsService * __pSmsService; + Tizen::Io::_IpcServer* __pIpcServer; + Tizen::Base::Collection::ArrayList *__pCbsList; + friend class _WapPushService; + friend class _SmsService; + +}; +}}//Tizen::Messasing +#endif // _MESSAGING_IPC_STUB_H_ + diff --git a/src/messaging/FMsg_SmsService.cpp b/src/messaging/FMsg_SmsService.cpp new file mode 100644 index 0000000..ae27141 --- /dev/null +++ b/src/messaging/FMsg_SmsService.cpp @@ -0,0 +1,436 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/** + * @file FMsg_SmsService.cpp + * @brief This is the implementation file for the %_SmsService class. + * + * This file contains the implementation of the %_SmsService class. + */ + +// OAF headers +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FMsg_MessagingIpcStub.h" +#include "FMsg_IpcCallbackHandler.h" +#include "FMsg_SmsService.h" +#include "FMsg_CbsMaker.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Messaging; +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Messaging +{ + +_SmsService *_SmsService::__pSelf = null; + + +_SmsService::_SmsService(void) + : __isConstructed(false) + , __isCbsSaveEnabled(true) + , __pSmsTriggerEventList(null) + , __msgHandle(0) + , __cbsSettingsHandle(0) + ,__pStub(0) +{ +} + +_SmsService::~_SmsService(void) +{ + + + if (__pSmsTriggerEventList) + { + if (__pSmsTriggerEventList->GetCount() > 0) + { + __pSmsTriggerEventList->RemoveAll(true); + } + delete __pSmsTriggerEventList; + __pSmsTriggerEventList = null; + } + + if (_IpcCallbackHandler::GetInstance()) + { + _IpcCallbackHandler::GetInstance()->CloseMessageHandle(); + } + + __isConstructed = false; +} + +_SmsService* +_SmsService::GetInstance() +{ + + return _SmsService::__pSelf; + +} + + +_SmsService* +_SmsService::GetInstance(_MessagingIpcStub *pStub) +{ + if (pStub) + { + SysTryReturnResult(NID_MSG, _SmsService::__pSelf == null, null, "_SmsService already created."); + + _SmsService::__pSelf = new (std::nothrow)_SmsService(); + SysTryReturnResult(NID_MSG, _SmsService::__pSelf != null, null, "_SmsService creation failed."); + _SmsService::__pSelf->__pStub = pStub; + std::atexit(DestroyInstance); + return _SmsService::__pSelf; + + } + return _SmsService::__pSelf; + +} + + _MessagingIpcStub* + _SmsService::GetStubInstance() + { + if(_SmsService::__pSelf) + { + + return _SmsService::__pSelf->__pStub; + } + + return null; + + } + + + void + _SmsService::DestroyInstance() + { + + if(_SmsService::__pSelf) + + { + delete _SmsService::__pSelf ; + _SmsService::__pSelf = null; + + } + } + +result +_SmsService::OpenMsgHandle() +{ + result r = E_SUCCESS; + int err = MSG_SUCCESS; + __isConstructed = true; + err = _IpcCallbackHandler::GetInstance()->OpenMessageHandle(__msgHandle); + r = ConvertException(err); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to open messageHandle."); + + return r; + +} +result +_SmsService::OpenCbsHandle() +{ + + result r = E_SUCCESS; + int err = MSG_SUCCESS; + + err = _IpcCallbackHandler::GetInstance()->OpenCbsSettingsHandle(__cbsSettingsHandle); + r = ConvertException(err); + if (r == E_DEVICE_UNAVAILABLE) + { + r = E_SUCCESS; + SysLog(NID_MSG, "Sim card is not present in device"); // even no sim, return sucess so that app will launch sucess + } + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to open cbs Settings Handle"); + SysTryReturnResult(NID_MSG, __cbsSettingsHandle > 0, E_SYSTEM, "cbsSettingsHandle is invalid."); + // load cbs settings + r = _IpcCallbackHandler::GetInstance()->LoadCbsSettings(); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to load cbs message settings."); + + return r; + +} + +result +_SmsService::AddSmsEventListener(int port, int clientId) +{ + // checking conditions + + result r = E_SUCCESS; + int err = MSG_SUCCESS; + + SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance()->SetSmsClientId(port, clientId)== E_SUCCESS, , r, "[%s] failed to save client id.", GetErrorMessage(r)); + // Register SMS Trigger + err = msg_reg_sms_message_callback(__msgHandle, &_IpcCallbackHandler::IncomingSmsCallback, port, null); + SysTryCatch(NID_MSG, err == MSG_ERR_INVALID_PARAMETER || r == E_SUCCESS, , r, "[%s] Failed to register for incoming sms callback.", GetErrorMessage(r)); + + return E_SUCCESS; + +CATCH: + return r; +} + + + +result +_SmsService::AddCbsEtwsEventListener(bool enabled, int clientId) +{ + SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet."); + SysAssertf(__msgHandle > 0, "message handle is invalid."); + + result r = E_SUCCESS; + int err = MSG_SUCCESS; + + SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance()->SetCbsEtwsClientId(clientId)== E_SUCCESS, r = E_SYSTEM, r, "[%s] failed to save client id.", GetErrorMessage(r)); + + err = msg_reg_cb_message_callback(__msgHandle, &_IpcCallbackHandler::IncomingCbsMessageCallback, enabled, null); + r = ConvertException(err); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to set cbs incoming callback", GetErrorMessage(r)); + + return r; + +CATCH: + + return r; + } + + +result +_SmsService::SetSavingToCbsBoxEnabled(bool enable) +{ + SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet."); + SysAssertf(__msgHandle > 0, "message handle is invalid."); + SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null"); + + int err = MSG_SUCCESS; + + err = msg_reg_cb_message_callback(__msgHandle, &_IpcCallbackHandler::IncomingCbsMessageCallback, enable, null); + SysTryReturnResult(NID_MSG, err == MSG_SUCCESS, E_SYSTEM, "Failed to set SavingToCbsBoxEnabled option."); + + __isCbsSaveEnabled = enable; + + return E_SUCCESS; +} + +bool +_SmsService::IsCbsEnabled(void) const +{ + SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet."); + SysAssertf(__msgHandle > 0, "message handle is invalid."); + SysTryReturn(NID_MSG, __cbsSettingsHandle != NULL, false, E_SYSTEM, "Cb handle is null"); + + bool isCbsEnabled = false; + int err = MSG_SUCCESS; + + err = msg_get_bool_value(__cbsSettingsHandle, MSG_CB_RECEIVE_BOOL, &isCbsEnabled); + SysTryReturn(NID_MSG, err == MSG_SUCCESS, false, E_SYSTEM, "Failed to set SavingToCbsBoxEnabled option."); + + return isCbsEnabled; +} + +result +_SmsService::SetCbsEnabled(bool enable) +{ + SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet."); + SysAssertf(__msgHandle > 0, "message handle is invalid."); + SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null"); + + int err = MSG_SUCCESS; + result r = E_SUCCESS; + + err = msg_set_bool_value(__cbsSettingsHandle, MSG_CB_RECEIVE_BOOL, enable); + SysTryReturnResult(NID_MSG, err == MSG_SUCCESS, E_SYSTEM, "Failed to set cbs enabled."); + + r = _IpcCallbackHandler::GetInstance()->SaveCbsSettings(); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, E_SYSTEM, "Failed to save cbs settings."); + + return E_SUCCESS; +} + +result +_SmsService::AddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate) +{ + SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet."); + SysAssertf(__msgHandle > 0, "message handle is invalid."); + SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null"); + + result r = E_SUCCESS; + int count = 0; + + r = _IpcCallbackHandler::GetInstance()->GetCbsChannelsCount(count); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to get CB Channel count."); + + if (CB_CHANNEL_MAX <= count) + { + return E_ALREADY_SET; + } + + // add channel + r = _IpcCallbackHandler::GetInstance()->AddCbsChannel(from, to, name, activate); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to add a CB Channel."); + + return r; +} + +result +_SmsService::RemoveCbsChannel(int from, int to) +{ + SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet."); + SysAssertf(__msgHandle > 0, "message handle is invalid."); + SysTryReturnResult(NID_MSG, __cbsSettingsHandle != NULL, E_SYSTEM, "Cb handle is null"); + + result r = E_SUCCESS; + + // remove channel + r = _IpcCallbackHandler::GetInstance()->RemoveCbsChannel(from, to); + SysTryReturn(NID_MSG, r == E_SUCCESS, r, r, "Failed to remove a CB Channel."); + + return r; +} + +_CbsMaker* +_SmsService::GetCbsChannelN(int from, int to) const +{ + SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet."); + SysAssertf(__msgHandle > 0, "message handle is invalid."); + SysTryReturn(NID_MSG, __cbsSettingsHandle != null, null, E_SYSTEM, "Cb handle is null."); + + result r = E_SUCCESS; + int fromId = 0; + int toId = 0; + int index = 0; + bool isActive = false; + String channelName; + std::unique_ptr<_CbsMaker> pCbsChannel; + + ClearLastResult(); + + // search channel + r = _IpcCallbackHandler::GetInstance()->SearchCbsChannel(from, to, index); + SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to find the cb channel."); + + // get channel + r = _IpcCallbackHandler::GetInstance()->GetCbsChannel(index, fromId, toId, channelName, isActive); + SysTryReturn(NID_MSG, r == E_SUCCESS, null, r, "Failed to get the cb channel."); + + // creates channel + pCbsChannel.reset(_CbsMaker::GetCbsChannelN(fromId, toId, channelName)); + + if (isActive) + { + pCbsChannel->SetCbsChannelState(true); + } + + return pCbsChannel.release(); +} + +result +_SmsService::GetCbsChannelListN(Tizen::Base::Collection::ArrayList *pCbsList) +{ + SysAssertf(__isConstructed == true, "_SmsService instance is not constructed yet."); + SysAssertf(__msgHandle > 0, "message handle is invalid."); + SysTryReturn(NID_MSG, __cbsSettingsHandle != null, null, E_SYSTEM, "Cb handle is null."); + + result r = E_SUCCESS; + int cbChannelCount = 0; + int fromId = 0; + int toId = 0; + bool isActive = false; + String channelName; + std::unique_ptr<_CbsMaker> pCbsChannel; + + ClearLastResult(); + + r = _IpcCallbackHandler::GetInstance()->GetCbsChannelsCount(cbChannelCount); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to get CB Channel count."); + + for (int index = 0; index < cbChannelCount; index++) + { + // get channel + r = _IpcCallbackHandler::GetInstance()->GetCbsChannel(index, fromId, toId, channelName, isActive); + SysTryReturnResult(NID_MSG, r == E_SUCCESS, r , "Failed to get the cb channel."); + + pCbsList->Add(new String(Integer::ToString(fromId))); + pCbsList->Add(new String(Integer::ToString(toId))); + pCbsList->Add(new String(channelName)); + pCbsList->Add(new String(Integer::ToString(isActive))); + + } + + return E_SUCCESS; +} + + +result +_SmsService::ConvertException(int err) const +{ + result r = E_SUCCESS; + + switch (err) + { + case MSG_SUCCESS: + r = E_SUCCESS; + break; + + case MSG_ERR_INVALID_PARAMETER: + case MSG_ERR_INVALID_MESSAGE: + case MSG_ERR_NULL_POINTER: + case MSG_ERR_NULL_MESSAGE: + r = E_INVALID_ARG; + break; + + case MSG_ERR_MEMORY_ERROR: + r = E_OUT_OF_MEMORY; + break; + + case MSG_ERR_STORAGE_ERROR: + r = E_STORAGE_FULL; + break; + + case MSG_ERR_DB_STEP: + r = E_OBJ_NOT_FOUND; + break; + + case MSG_ERR_SERVER_NOT_READY: + case MSG_ERR_TRANSPORT_ERROR: + case MSG_ERR_COMMUNICATION_ERROR: + r = E_NETWORK_UNAVAILABLE; + break; + + case MSG_ERR_NO_SIM: + r = E_DEVICE_UNAVAILABLE; + break; + + case MSG_ERR_PLUGIN_TAPI_FAILED: + r = E_FAILURE; + break; + + default: + r = E_SYSTEM; + break; + } + + return r; +} + +} } // Tizen::Messaging diff --git a/src/messaging/FMsg_SmsService.h b/src/messaging/FMsg_SmsService.h new file mode 100644 index 0000000..328e0b1 --- /dev/null +++ b/src/messaging/FMsg_SmsService.h @@ -0,0 +1,101 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/** + * @file FMsg_SmsService.h + * @brief This is the header file for the _SmsService class. + * + * This header file contains the declarations of the _SmsService class. + */ + +#ifndef _FMSG_INTERNAL_SMS_SERVICE_H_ +#define _FMSG_INTERNAL_SMS_SERVICE_H_ + + +namespace Tizen { namespace Messaging +{ + +class _CbsMaker; +class _MessagingIpcStub; + + +/** +* @class _SmsService +* @brief This class provides methods to use the SMS messaging service. +* @since 1.0 +* +* This class provides methods to use the SMS messaging service. @n +*/ + + +class _SmsService + : public Tizen::Base::Object +{ + // Life cycle +public: + + + /** + * This is the destructor for this class. + */ + virtual ~_SmsService(void); + +private: + _SmsService(void); + _SmsService(const _SmsService& value); + _SmsService& operator =(const _SmsService& rhs); + + + // Operation +public: + + result OpenMsgHandle(); + result OpenCbsHandle(); + result AddSmsEventListener(int port, int clientId); + result AddCbsEtwsEventListener(bool enabled, int clientId); + result SetSavingToCbsBoxEnabled(bool enable); + bool IsCbsEnabled(void) const; + result SetCbsEnabled(bool enable); + result AddCbsChannel(int from, int to, const Tizen::Base::String& name, bool activate = true); + result RemoveCbsChannel(int from, int to); + _CbsMaker* GetCbsChannelN(int from, int to) const; + result GetCbsChannelListN(Tizen::Base::Collection::ArrayList *pCbsList); + +public: + + static _SmsService* GetInstance(); + static _SmsService* GetInstance(_MessagingIpcStub *pStub = null); + static _MessagingIpcStub* GetStubInstance(); + static void DestroyInstance(); + +private: + + result ConvertException(int err) const; + +private: + static _SmsService * __pSelf; + bool __isConstructed; + bool __isCbsSaveEnabled; + Tizen::Base::Collection::ArrayList* __pSmsTriggerEventList; + msg_handle_t __msgHandle; + msg_struct_t __cbsSettingsHandle; + _MessagingIpcStub *__pStub; + friend class _MessagingIpcStub; + +}; // _SmsService +} } // Tizen::Messaging + +#endif // _FMSG_INTERNAL_SMS_SERVICE_H_ diff --git a/src/messaging/FMsg_WapPushService.cpp b/src/messaging/FMsg_WapPushService.cpp new file mode 100644 index 0000000..cbdeda5 --- /dev/null +++ b/src/messaging/FMsg_WapPushService.cpp @@ -0,0 +1,361 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/** + * @file FMsg_WapPushService.cpp + * @brief This is the implementation file for the %_WapPushService class. + * + * This file contains the implementation of the %_WapPushService class. + */ + + +#include +#include +#include +#include +#include +#include +#include +#include "FMsg_WapPushService.h" +#include "FMsg_IpcCallbackHandler.h" +#include "FMsg_MessagingIpcStub.h" + +using namespace Tizen::Base; +using namespace Tizen::Messaging; +using namespace Tizen::Base::Collection; + +namespace Tizen { namespace Messaging +{ + +_WapPushService *_WapPushService::__pSelf = null; + +_WapPushService::_WapPushService(void) + : __msgHandle(0) + ,__pStub(null) + +{ +} + +_WapPushService::_WapPushService(const _WapPushService& value) +{ + __msgHandle = value.__msgHandle; + +} + +_WapPushService::~_WapPushService(void) +{ + +} + +_WapPushService* +_WapPushService::GetInstance() +{ + + return _WapPushService::__pSelf; + +} + + +_WapPushService* +_WapPushService::GetInstance(_MessagingIpcStub *pStub) +{ + if (pStub) + { + SysTryReturnResult(NID_MSG, _WapPushService::__pSelf == null, null, "_WapPushService already created."); + _WapPushService::__pSelf = new (std::nothrow)_WapPushService(); + _WapPushService::__pSelf->__pStub = pStub; + std::atexit(DestroyInstance); + return _WapPushService::__pSelf; + } + return _WapPushService::__pSelf; + +} + + _MessagingIpcStub* + _WapPushService::GetStubInstance() + { + if(_WapPushService::__pSelf) + { + + return _WapPushService::__pSelf->__pStub; + } + + return null; + + } + + + void + _WapPushService::DestroyInstance() +{ + + if(_WapPushService::__pSelf) + + { + delete _WapPushService::__pSelf ; + _WapPushService::__pSelf = null; + +} + } + + + +result +_WapPushService::AddWapPushEventListener(const Tizen::Base::String& wapApplicationId,int clientId) +{ + result r = E_SUCCESS; + int err = MSG_SUCCESS; + char* pWapAppId = null; + + ClearLastResult(); + SysLog(NID_MSG, "wapApp: %ls", wapApplicationId.GetPointer()); + + pWapAppId = _StringConverter::CopyToCharArrayN(wapApplicationId); + SysTryCatch(NID_MSG, pWapAppId != null, r = E_OUT_OF_MEMORY, r, "[%s] memory allocation failed", GetErrorMessage(r)); + SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance()->SetWapPushClientId(wapApplicationId, clientId)== E_SUCCESS, , r, "[%s] failed to save client id.", GetErrorMessage(r)); + SysTryCatch(NID_MSG, _IpcCallbackHandler::GetInstance() != null, r = E_OUT_OF_MEMORY, r, "[%s] failed to get msg handle.", GetErrorMessage(r)); + + // open message handle + err = _IpcCallbackHandler::GetInstance()->OpenMessageHandle(__msgHandle); + + r = ConvertException(err); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Open Message Handle", GetErrorMessage(r)); + + SysLog(NID_MSG, "The value of __msgHandle is [%d]", __msgHandle); + + // check value of msg handle + SysTryCatch(NID_MSG, __msgHandle > 0, r = E_SYSTEM, r, "failed to get msg handle."); + err = msg_reg_push_message_callback(__msgHandle, &_IpcCallbackHandler::IncomingWapPushMessageCallback, pWapAppId, (void*) null); + + r = ConvertException(err); + SysTryCatch(NID_MSG, err == MSG_ERR_INVALID_PARAMETER || r == E_SUCCESS, , r, "[%s] Failed to Add WapPush EventListener.", GetErrorMessage(r)); + + if (pWapAppId) + { + delete[] pWapAppId; + pWapAppId = null; + } + + return E_SUCCESS; + +CATCH: + if (pWapAppId) + { + delete[] pWapAppId; + pWapAppId = null; + } + + return r; +} + +result +_WapPushService::RegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType) +{ + result r = E_SUCCESS; + int err = MSG_SUCCESS; + char* pWapAppId = null; + char* pContentType = null; + msg_struct_t pushInfo = null; + char* pPkgName = null; + + ClearLastResult(); + + pWapAppId = _StringConverter::CopyToCharArrayN(wapApplicationId); + SysTryCatch(NID_MSG, pWapAppId != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); + + pContentType = _StringConverter::CopyToCharArrayN(contentType); + SysTryCatch(NID_MSG, pContentType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); + + err = app_get_package(&pPkgName); + SysTryCatch(NID_MSG, err == APP_ERROR_NONE && pPkgName != null, r = E_SYSTEM, r, "[%s] Failed to Open Message Handle", GetErrorMessage(r)); + + pushInfo = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO); + SysTryCatch(NID_MSG, pushInfo != null, r = E_SYSTEM, r, "[%s] Failed to create push data info", GetErrorMessage(r)); + msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, (char *)pContentType, MAX_WAPPUSH_CONTENT_TYPE_LEN); + msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_APPLICATON_ID_STR, (char *)pWapAppId, MAX_WAPPUSH_ID_LEN); + msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pPkgName, MSG_FILEPATH_LEN_MAX); + free(pPkgName); + pPkgName = null; + + err = msg_add_push_event(__msgHandle, pushInfo); + msg_release_struct(&pushInfo); + + r = ConvertException(err); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to register Condition for wap push.", GetErrorMessage(r)); + + if (pWapAppId) + { + delete[] pWapAppId; + pWapAppId = null; + } + + if (pContentType) + { + delete[] pContentType; + pContentType = null; + } + return r; + +CATCH: + if (pPkgName) + { + free(pPkgName); + pPkgName = null; + } + + if (pushInfo) + { + msg_release_struct(&pushInfo); + pushInfo = null; + } + + if (pWapAppId) + { + delete[] pWapAppId; + pWapAppId = null; + } + + if (pContentType) + { + delete[] pContentType; + pContentType = null; + } + return r; +} + +result +_WapPushService::UnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType) +{ + result r = E_SUCCESS; + int err = MSG_SUCCESS; + char* pWapAppId = null; + char* pContentType = null; + msg_struct_t pushInfo = null; + char* pPkgName = null; + + ClearLastResult(); + + pWapAppId = _StringConverter::CopyToCharArrayN(wapApplicationId); + SysTryCatch(NID_MSG, pWapAppId != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); + + pContentType = _StringConverter::CopyToCharArrayN(contentType); + SysTryCatch(NID_MSG, pContentType != null, r = E_OUT_OF_MEMORY, r, "memory allocation failed"); + + err = app_get_package(&pPkgName); + SysTryCatch(NID_MSG, err == APP_ERROR_NONE, r = E_SYSTEM, r, "[%s] Failed to Open Message Handle", GetErrorMessage(r)); + + pushInfo = msg_create_struct(MSG_STRUCT_PUSH_CONFIG_INFO); + msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_CONTENT_TYPE_STR, pContentType, MAX_WAPPUSH_CONTENT_TYPE_LEN); + msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_APPLICATON_ID_STR, pWapAppId, MAX_WAPPUSH_ID_LEN); + msg_set_str_value(pushInfo, MSG_PUSH_CONFIG_PACKAGE_NAME_STR, pPkgName, MSG_FILEPATH_LEN_MAX); + free(pPkgName); + pPkgName = null; + + err = msg_delete_push_event(__msgHandle, pushInfo); + msg_release_struct(&pushInfo); + + r = ConvertException(err); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to Unregister Condition for wap push", GetErrorMessage(r)); + + if (pWapAppId) + { + delete[] pWapAppId; + pWapAppId = null; + } + + if (pContentType) + { + delete[] pContentType; + pContentType = null; + } + return r; + +CATCH: + if (pPkgName) + { + free(pPkgName); + pPkgName = null; + } + + if (pushInfo) + { + msg_release_struct(&pushInfo); + pushInfo = null; + } + + if (pWapAppId) + { + delete[] pWapAppId; + pWapAppId = null; + } + + if (pContentType) + { + delete[] pContentType; + pContentType = null; + } + return r; +} + +result +_WapPushService::ConvertException(int err) const +{ + result r = E_SUCCESS; + + switch (err) + { + case MSG_SUCCESS: + r = E_SUCCESS; + break; + + case MSG_ERR_DB_ROW: + r = E_ALREADY_SET; + break; + + case MSG_ERR_INVALID_PARAMETER: + case MSG_ERR_INVALID_MESSAGE: + case MSG_ERR_NULL_POINTER: + case MSG_ERR_NULL_MESSAGE: + r = E_INVALID_ARG; + break; + + case MSG_ERR_MEMORY_ERROR: + r = E_OUT_OF_MEMORY; + break; + + case MSG_ERR_SERVER_NOT_READY: + case MSG_ERR_TRANSPORT_ERROR: + case MSG_ERR_COMMUNICATION_ERROR: + r = E_NETWORK_UNAVAILABLE; + break; + + case MSG_ERR_NO_SIM: + r = E_DEVICE_UNAVAILABLE; + break; + + case MSG_ERR_PLUGIN_TAPI_FAILED: + r = E_FAILURE; + break; + + default: + r = E_SYSTEM; + break; + } + + return r; +} + +} } diff --git a/src/messaging/FMsg_WapPushService.h b/src/messaging/FMsg_WapPushService.h new file mode 100644 index 0000000..4dabd0b --- /dev/null +++ b/src/messaging/FMsg_WapPushService.h @@ -0,0 +1,72 @@ +// +// Open Service Platform +// Copyright (c) 2012-2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + + +#ifndef _FMSG_INTERNAL_WAP_PUSH_SERVICE_H_ +#define _FMSG_INTERNAL_WAP_PUSH_SERVICE_H_ + +#include + +namespace Tizen { namespace Messaging +{ + +class _WapPushCallBackData +{ +public: + int clientId; + int addr; +}; + + +// forward declaration +class _MessagingIpcStub; + +class _WapPushService + : public Tizen::Base::Object +{ +private: + _WapPushService(void); + _WapPushService(const _WapPushService& value); + + +public: + + result AddWapPushEventListener(const Tizen::Base::String& wapApplicationId, int clientId); + result RegisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType); + result UnregisterCondition(const Tizen::Base::String& wapApplicationId, const Tizen::Base::String& contentType); + result ConvertException(int err) const; + + static _WapPushService* GetInstance(); + static _WapPushService* GetInstance(_MessagingIpcStub *pStub = null); + static _MessagingIpcStub* GetStubInstance(); + static void DestroyInstance(); + + virtual ~_WapPushService(void); + + + +private: + msg_handle_t __msgHandle; + _MessagingIpcStub *__pStub; + static _WapPushService *__pSelf; + friend class _MessagingIpcStub; + + +}; // _WapPushService + +} } // Tizen::Messaging +#endif // _FMSG_INTERNAL_WAP_PUSH_MANAGER_IMPL_H_ diff --git a/src/system/CMakeLists.txt b/src/system/CMakeLists.txt new file mode 100644 index 0000000..e7101d3 --- /dev/null +++ b/src/system/CMakeLists.txt @@ -0,0 +1,47 @@ +SET (this_target system_service) + +INCLUDE_DIRECTORIES( + ${SLP_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/inc + /usr/include/system + /usr/include/network + /usr/include/telephony + /usr/include/telephony-client + ./ + ) + +SET (${this_target}_SOURCE_FILES + FSys_DeviceId.cpp + FSys_SystemInfoService.cpp + FSys_SettingService.cpp + FSys_RuntimeInfoStub.cpp + FSys_DeviceManagerStub.cpp + FSys_PowerManagerStub.cpp + FSys_SystemServiceIpcEventForAsync.cpp + FSys_AlarmExStub.cpp +) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED + kies_alarm + alarm-engine + alarm-service + osp-system-server +) + +## SET EXTRA COMPILER FLAGS +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag} -fPIC" ) +ENDFOREACH(flag) + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") + +## SET C COMPILER FLAGS +SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## SET CPP COMPILER FLAGS +SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## Create Library +ADD_LIBRARY (${this_target} STATIC ${${this_target}_SOURCE_FILES}) + diff --git a/src/system/FSys_AlarmExStub.cpp b/src/system/FSys_AlarmExStub.cpp new file mode 100644 index 0000000..41b5a28 --- /dev/null +++ b/src/system/FSys_AlarmExStub.cpp @@ -0,0 +1,245 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_AlarmExStub.cpp + * @brief This is the implementation for the _AlarmExStub class. + */ +#include +#include +#include +#include +#include +#include +#include +#include +extern "C"{ +#include //It should be changed after update kies_alarm.h by SLP +} + +#include "FBase_StringConverter.h" +#include "FSys_AlarmExStub.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; +using namespace Tizen::System; +using namespace Tizen::Security; + +namespace { + static const wchar_t* ALARM_EX_SERVICE_PRIVILEGE = L"http://developer.samsung.com/tizen/privilege/smartswitch.alarminfomanager"; + static const wchar_t* ALARM_EX_SERVICE_ID = L"osp.sys.ipcserver.alarmex"; + static const wchar_t* _ALARM_EX_EXPORT_DATA = L"osp.system.command.alarmex.export.data"; + static const wchar_t* _ALARM_EX_IMPORT_DATA = L"osp.system.command.alarmex.import.data"; + static const int _ALARM_EX_COMMAND_ID = 1; + static const int _ALARM_EX_ARGUMENT_ID = 2; + static const int _ALARM_ERROR_FAILURE = -1; + static const int _ALARM_ERROR_SUCCESS = 0; + static const int _ALARM_ERROR_DATA_NOT_FOUND = 1; + static const int _ALARM_ERROR_INVALID_DATA = 2; + static const int _ALARM_ERROR_PRIVILEGE_DENIED = 3; +} + +_AlarmExStub* _AlarmExStub::__pAlarmExStub = null; + +_AlarmExStub::_AlarmExStub(void) + : __pIpcServer(null) + , __serviceId(ALARM_EX_SERVICE_ID) +{ +} + +_AlarmExStub::~_AlarmExStub(void) +{ + if (__pIpcServer) + { + __pIpcServer->Stop(); + } +} + +_AlarmExStub* +_AlarmExStub::GetInstance() +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + + if (__pAlarmExStub == null) + { + pthread_once(&onceBlock, InitSingleton); + } + return __pAlarmExStub; +} + +void +_AlarmExStub::InitSingleton(void) +{ + std::unique_ptr< _AlarmExStub > pAlarmExStub(new (std::nothrow) _AlarmExStub()); + SysTryReturn(NID_SYS, pAlarmExStub, ,E_OUT_OF_MEMORY, "It is not enough memory."); + result r = pAlarmExStub->Construct(); + SysTryReturn(NID_SYS, !IsFailed(r), , r, "[%s] It is failed to get AlarmExCommunicationStub.", GetErrorMessage(r)); + __pAlarmExStub = pAlarmExStub.release(); + atexit(DestroySingleton); +} + + +void +_AlarmExStub::DestroySingleton(void) +{ + delete __pAlarmExStub; +} + +result +_AlarmExStub::Construct(void) +{ + unique_ptr<_IpcServer> pIpcServer(new (std::nothrow) _IpcServer()); + SysTryReturnResult(NID_SYS, pIpcServer, E_OUT_OF_MEMORY, "Memory is insufficient."); + + result r = pIpcServer->Construct(String(ALARM_EX_SERVICE_ID), *this, true); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to construct."); + + r = pIpcServer->Start(); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to start."); + + __pIpcServer = move(pIpcServer); + + return E_SUCCESS; +} + + +result +_AlarmExStub::ExportToFile(const String &path) +{ + result r = E_SUCCESS; + SysLog(NID_SYS, "ExportToFile"); + int error = -1; + std::unique_ptr pSmackLable(_StringConverter::CopyToCharArrayN(__clientPackageId)); + std::unique_ptr pPath(_StringConverter::CopyToCharArrayN(path)); + error = alarm_backup(pPath.get()); + SysLog(NID_SYS, "alarm_backup returns [%d]", error); + + if (error == 0) + { + r = E_SUCCESS; + int errorCode = chown(pPath.get(), 5000, 5000); + SysTryReturnResult(NID_SYS, errorCode == 0, E_SYSTEM, "It is failed to change permission."); + SysTryReturnResult(NID_SYS, smack_setlabel(pPath.get(), pSmackLable.get(), SMACK_LABEL_ACCESS) == 0, E_SYSTEM, "[E_SYSTEM] SMACK labeling failed"); + } + else if (error == 1) + { + r = E_DATA_NOT_FOUND; + } + else + { + r = E_FAILURE; + } + + return r; +} + +result +_AlarmExStub::ImportFromFile(const String &path) +{ + result r = E_SUCCESS; + SysLog(NID_SYS, "ImportFromFile"); + int error = -1; + std::unique_ptr pPath( _StringConverter::CopyToCharArrayN(path)); + error = alarm_restore(pPath.get()); + SysLog(NID_SYS, "alarm_restore returns [%d]", error); + + if (error == 0) + { + r = E_SUCCESS; + } + else if (error == 1) + { + r = E_DATA_NOT_FOUND; + } + else + { + r = E_FAILURE; + } + return r; +} +void +_AlarmExStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message) +{ + __clientPackageId = server.GetClientPackageId(); + SysLog(NID_SYS, "client app id [%ls]", __clientPackageId.GetPointer()); + + IPC_BEGIN_MESSAGE_MAP(_AlarmExStub, message) + IPC_MESSAGE_HANDLER_EX(IoService_Request, &server, OnRequestOccured) + IPC_END_MESSAGE_MAP_EX() +} + +bool +_AlarmExStub::OnRequestOccured(const ArrayList& request, ArrayList* response) +{ + result r = E_SUCCESS; + + __command = *((String*)request.GetAt(_ALARM_EX_COMMAND_ID)); + __argument = *((String*)request.GetAt(_ALARM_EX_ARGUMENT_ID)); + + r = _AccessController::CheckPrivilege(__clientPackageId, ALARM_EX_SERVICE_PRIVILEGE); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_PRIVILEGE_DENIED , E_PRIVILEGE_DENIED, "[%s] error occurs.", GetErrorMessage(r)); + + SysLog(NID_SYS, "Request AlarmEX: [%ls] path [%ls].", __command.GetPointer(), __argument.GetPointer()); + + if (__command == _ALARM_EX_EXPORT_DATA) + { + r = ExportToFile(__argument); + } + else if(__command == _ALARM_EX_IMPORT_DATA) + { + r = ImportFromFile(__argument); + } + else + { + SysLogException(NID_SYS, E_SYSTEM, "Required Command[%ls] is not proccess on _AlarmEx.", __command.GetPointer()); + r = E_SYSTEM; + } + +CATCH: + SysLog(NID_SYS, "Alarm result [%s]", GetErrorMessage(r)); + __result = ""; + if (r == E_SUCCESS) + { + __result.Append(_ALARM_ERROR_SUCCESS); + } + else if (r == E_INVALID_DATA) + { + __result.Append(_ALARM_ERROR_INVALID_DATA); + } + else if (r == E_PRIVILEGE_DENIED) + { + __result.Append(_ALARM_ERROR_PRIVILEGE_DENIED); + } + else if (r == E_DATA_NOT_FOUND) + { + __result.Append(_ALARM_ERROR_DATA_NOT_FOUND); + } + else + { + __result.Append(_ALARM_ERROR_FAILURE); + } + + response->Add(__serviceId); + response->Add(__command); + response->Add(__result); + + ArrayList* temp = const_cast(&request); + temp->RemoveAll(true); + return true; +} diff --git a/src/system/FSys_AlarmExStub.h b/src/system/FSys_AlarmExStub.h new file mode 100644 index 0000000..dbf70d7 --- /dev/null +++ b/src/system/FSys_AlarmExStub.h @@ -0,0 +1,76 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_AlarmExStub.h + * @brief This is the header file of the _AlarmExStub class. + * + * This header file contains the declarations of the _AlarmExStub class. + */ + +#ifndef _FSYS_ALARM_EX_STUB_H_ +#define _FSYS_ALARM_EX_STUB_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace System +{ +class _OSP_EXPORT_ _AlarmExStub + : public Tizen::Base::Object + , public Tizen::Io::_IIpcServerEventListener +{ +public: + static _AlarmExStub* GetInstance(void); + virtual ~_AlarmExStub(void); + +private: + static void InitSingleton(void); + static void DestroySingleton(void); + + _AlarmExStub(void); + result Construct(void); + + result ExportToFile(const Tizen::Base::String &path); + result ImportFromFile(const Tizen::Base::String &path); + + _AlarmExStub(const _AlarmExStub& rhs); + _AlarmExStub& operator =(const _AlarmExStub& rhs); + + bool OnRequestOccured(const Tizen::Base::Collection::ArrayList& request, Tizen::Base::Collection::ArrayList* response); + + virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server) {} + virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server) {} + virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId) {} + virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId) {} + virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message); + +private: + std::unique_ptr __pIpcServer; + static _AlarmExStub* __pAlarmExStub; + Tizen::App::AppId __clientPackageId; + Tizen::Base::String __serviceId; + Tizen::Base::String __command; + Tizen::Base::String __argument; + Tizen::Base::String __result; +}; // _AlarmExStub + +}} // Tizen::System + +#endif // _FSYS_ALARM_EX_STUB_H_ diff --git a/src/system/FSys_DeviceId.cpp b/src/system/FSys_DeviceId.cpp new file mode 100644 index 0000000..a646d8f --- /dev/null +++ b/src/system/FSys_DeviceId.cpp @@ -0,0 +1,408 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_DeviceId.cpp + * @brief This is the implementation file for _DeviceId class. + */ + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include "FSys_DeviceId.h" + +using namespace Tizen::Base; +using namespace Tizen::Text; + +namespace Tizen { namespace System +{ + +const int _CRYPT_KEY_SIZE = 8; +const int _SEED_LENGTH = 15; +const char _BLUETOOTH_ADDR[] = "/csa/bluetooth/.bd_addr"; + +static const char BASE32_CHAR_SET[] = "abcdefghijklmnopqrstuvwxyz0123456789"; + +static const unsigned long long int __gCrc64Table[] = +{ + 0x0000000000000000ULL, 0x01B0000000000000ULL, 0x0360000000000000ULL, 0x02D0000000000000ULL, + 0x06C0000000000000ULL, 0x0770000000000000ULL, 0x05A0000000000000ULL, 0x0410000000000000ULL, + 0x0D80000000000000ULL, 0x0C30000000000000ULL, 0x0EE0000000000000ULL, 0x0F50000000000000ULL, + 0x0B40000000000000ULL, 0x0AF0000000000000ULL, 0x0820000000000000ULL, 0x0990000000000000ULL, + 0x1B00000000000000ULL, 0x1AB0000000000000ULL, 0x1860000000000000ULL, 0x19D0000000000000ULL, + 0x1DC0000000000000ULL, 0x1C70000000000000ULL, 0x1EA0000000000000ULL, 0x1F10000000000000ULL, + 0x1680000000000000ULL, 0x1730000000000000ULL, 0x15E0000000000000ULL, 0x1450000000000000ULL, + 0x1040000000000000ULL, 0x11F0000000000000ULL, 0x1320000000000000ULL, 0x1290000000000000ULL, + 0x3600000000000000ULL, 0x37B0000000000000ULL, 0x3560000000000000ULL, 0x34D0000000000000ULL, + 0x30C0000000000000ULL, 0x3170000000000000ULL, 0x33A0000000000000ULL, 0x3210000000000000ULL, + 0x3B80000000000000ULL, 0x3A30000000000000ULL, 0x38E0000000000000ULL, 0x3950000000000000ULL, + 0x3D40000000000000ULL, 0x3CF0000000000000ULL, 0x3E20000000000000ULL, 0x3F90000000000000ULL, + 0x2D00000000000000ULL, 0x2CB0000000000000ULL, 0x2E60000000000000ULL, 0x2FD0000000000000ULL, + 0x2BC0000000000000ULL, 0x2A70000000000000ULL, 0x28A0000000000000ULL, 0x2910000000000000ULL, + 0x2080000000000000ULL, 0x2130000000000000ULL, 0x23E0000000000000ULL, 0x2250000000000000ULL, + 0x2640000000000000ULL, 0x27F0000000000000ULL, 0x2520000000000000ULL, 0x2490000000000000ULL, + 0x6C00000000000000ULL, 0x6DB0000000000000ULL, 0x6F60000000000000ULL, 0x6ED0000000000000ULL, + 0x6AC0000000000000ULL, 0x6B70000000000000ULL, 0x69A0000000000000ULL, 0x6810000000000000ULL, + 0x6180000000000000ULL, 0x6030000000000000ULL, 0x62E0000000000000ULL, 0x6350000000000000ULL, + 0x6740000000000000ULL, 0x66F0000000000000ULL, 0x6420000000000000ULL, 0x6590000000000000ULL, + 0x7700000000000000ULL, 0x76B0000000000000ULL, 0x7460000000000000ULL, 0x75D0000000000000ULL, + 0x71C0000000000000ULL, 0x7070000000000000ULL, 0x72A0000000000000ULL, 0x7310000000000000ULL, + 0x7A80000000000000ULL, 0x7B30000000000000ULL, 0x79E0000000000000ULL, 0x7850000000000000ULL, + 0x7C40000000000000ULL, 0x7DF0000000000000ULL, 0x7F20000000000000ULL, 0x7E90000000000000ULL, + 0x5A00000000000000ULL, 0x5BB0000000000000ULL, 0x5960000000000000ULL, 0x58D0000000000000ULL, + 0x5CC0000000000000ULL, 0x5D70000000000000ULL, 0x5FA0000000000000ULL, 0x5E10000000000000ULL, + 0x5780000000000000ULL, 0x5630000000000000ULL, 0x54E0000000000000ULL, 0x5550000000000000ULL, + 0x5140000000000000ULL, 0x50F0000000000000ULL, 0x5220000000000000ULL, 0x5390000000000000ULL, + 0x4100000000000000ULL, 0x40B0000000000000ULL, 0x4260000000000000ULL, 0x43D0000000000000ULL, + 0x47C0000000000000ULL, 0x4670000000000000ULL, 0x44A0000000000000ULL, 0x4510000000000000ULL, + 0x4C80000000000000ULL, 0x4D30000000000000ULL, 0x4FE0000000000000ULL, 0x4E50000000000000ULL, + 0x4A40000000000000ULL, 0x4BF0000000000000ULL, 0x4920000000000000ULL, 0x4890000000000000ULL, + 0xD800000000000000ULL, 0xD9B0000000000000ULL, 0xDB60000000000000ULL, 0xDAD0000000000000ULL, + 0xDEC0000000000000ULL, 0xDF70000000000000ULL, 0xDDA0000000000000ULL, 0xDC10000000000000ULL, + 0xD580000000000000ULL, 0xD430000000000000ULL, 0xD6E0000000000000ULL, 0xD750000000000000ULL, + 0xD340000000000000ULL, 0xD2F0000000000000ULL, 0xD020000000000000ULL, 0xD190000000000000ULL, + 0xC300000000000000ULL, 0xC2B0000000000000ULL, 0xC060000000000000ULL, 0xC1D0000000000000ULL, + 0xC5C0000000000000ULL, 0xC470000000000000ULL, 0xC6A0000000000000ULL, 0xC710000000000000ULL, + 0xCE80000000000000ULL, 0xCF30000000000000ULL, 0xCDE0000000000000ULL, 0xCC50000000000000ULL, + 0xC840000000000000ULL, 0xC9F0000000000000ULL, 0xCB20000000000000ULL, 0xCA90000000000000ULL, + 0xEE00000000000000ULL, 0xEFB0000000000000ULL, 0xED60000000000000ULL, 0xECD0000000000000ULL, + 0xE8C0000000000000ULL, 0xE970000000000000ULL, 0xEBA0000000000000ULL, 0xEA10000000000000ULL, + 0xE380000000000000ULL, 0xE230000000000000ULL, 0xE0E0000000000000ULL, 0xE150000000000000ULL, + 0xE540000000000000ULL, 0xE4F0000000000000ULL, 0xE620000000000000ULL, 0xE790000000000000ULL, + 0xF500000000000000ULL, 0xF4B0000000000000ULL, 0xF660000000000000ULL, 0xF7D0000000000000ULL, + 0xF3C0000000000000ULL, 0xF270000000000000ULL, 0xF0A0000000000000ULL, 0xF110000000000000ULL, + 0xF880000000000000ULL, 0xF930000000000000ULL, 0xFBE0000000000000ULL, 0xFA50000000000000ULL, + 0xFE40000000000000ULL, 0xFFF0000000000000ULL, 0xFD20000000000000ULL, 0xFC90000000000000ULL, + 0xB400000000000000ULL, 0xB5B0000000000000ULL, 0xB760000000000000ULL, 0xB6D0000000000000ULL, + 0xB2C0000000000000ULL, 0xB370000000000000ULL, 0xB1A0000000000000ULL, 0xB010000000000000ULL, + 0xB980000000000000ULL, 0xB830000000000000ULL, 0xBAE0000000000000ULL, 0xBB50000000000000ULL, + 0xBF40000000000000ULL, 0xBEF0000000000000ULL, 0xBC20000000000000ULL, 0xBD90000000000000ULL, + 0xAF00000000000000ULL, 0xAEB0000000000000ULL, 0xAC60000000000000ULL, 0xADD0000000000000ULL, + 0xA9C0000000000000ULL, 0xA870000000000000ULL, 0xAAA0000000000000ULL, 0xAB10000000000000ULL, + 0xA280000000000000ULL, 0xA330000000000000ULL, 0xA1E0000000000000ULL, 0xA050000000000000ULL, + 0xA440000000000000ULL, 0xA5F0000000000000ULL, 0xA720000000000000ULL, 0xA690000000000000ULL, + 0x8200000000000000ULL, 0x83B0000000000000ULL, 0x8160000000000000ULL, 0x80D0000000000000ULL, + 0x84C0000000000000ULL, 0x8570000000000000ULL, 0x87A0000000000000ULL, 0x8610000000000000ULL, + 0x8F80000000000000ULL, 0x8E30000000000000ULL, 0x8CE0000000000000ULL, 0x8D50000000000000ULL, + 0x8940000000000000ULL, 0x88F0000000000000ULL, 0x8A20000000000000ULL, 0x8B90000000000000ULL, + 0x9900000000000000ULL, 0x98B0000000000000ULL, 0x9A60000000000000ULL, 0x9BD0000000000000ULL, + 0x9FC0000000000000ULL, 0x9E70000000000000ULL, 0x9CA0000000000000ULL, 0x9D10000000000000ULL, + 0x9480000000000000ULL, 0x9530000000000000ULL, 0x97E0000000000000ULL, 0x9650000000000000ULL, + 0x9240000000000000ULL, 0x93F0000000000000ULL, 0x9120000000000000ULL, 0x9090000000000000ULL +}; + + +String _DeviceId::__deviceId = ""; + +result +_DeviceId::GetId(Tizen::Base::String& deviceId, int type) +{ + int ret = 0; + result r = E_SUCCESS; + + if(__deviceId != "") + { + deviceId = __deviceId; + return r; + } + + char* pDeviceString = null; + + unsigned long long tempRes = 0; + + //0xCAFEBABECAFEBABE + const char keyValue[_CRYPT_KEY_SIZE] = {0xCA, 0xFE, 0xBA, 0xBE, 0xCA, 0xFE, 0xBA, 0xBE}; + + char pFirstCrypt[_SEED_LENGTH + 1] = {0,}; + ByteBuffer crc64Input; + ByteBuffer crc64Result; + ByteBuffer base32Result; + + Utf8Encoding utf8; + + if(type == 0) + { + int time_count = 0; + int status = 0; + TapiHandle* handle = null; + + while(time_count < 30) //Wait 30 second. + { + if(handle == null) + { + handle = tel_init(null); + } + + if(handle != null) + { + ret = tel_check_modem_power_status(handle, &status); + SysLog(NID_SYS, "Modem check result is %d, status is %d.", handle, status); + if(ret != TAPI_API_SUCCESS) + { + tel_deinit(handle); + SysLogException(NID_SYS, E_SYSTEM, "It is failed to get IMEI."); + return E_SYSTEM; + } + + if(status == 0) + { + break; + } + } + usleep(1000000); + time_count++; + } + + if(handle != null) + { + if(status == 0) + { + pDeviceString = tel_get_misc_me_imei_sync(handle); + tel_deinit(handle); + SysTryReturnResult(NID_SYS, pDeviceString != null, E_SYSTEM, "It is failed to get IMEI"); + } + else + { + tel_deinit(handle); + SysLogException(NID_SYS, E_SYSTEM, "Modem is not ready to get IMEI."); + return E_SYSTEM; + } + } + else + { + SysLogException(NID_SYS, E_SYSTEM, "Modem handle is not ready."); + return E_SYSTEM; + } + } + else if(type == 1) + { + char* wifiMacAddress = null; + ret = wifi_get_mac_address(&wifiMacAddress); + SysTryReturnResult(NID_SYS, ret == WIFI_ERROR_NONE && wifiMacAddress != null, E_SYSTEM, "It is failed to get Wi-Fi MAC address."); + + SysLog(NID_SYS, "Wifi Address is [%s]", wifiMacAddress); + + pDeviceString = (char*)malloc(_SEED_LENGTH); + memset(pDeviceString, 0, _SEED_LENGTH); + + char* temp = wifiMacAddress; + strcat(pDeviceString, "WIF"); + for(int i = 0; i < 6; i++) + { + strncat(pDeviceString, temp, 2); + temp+=3; + } + + free(wifiMacAddress); + } + else if(type == 2) + { + FILE* fp = null; + fp = fopen(_BLUETOOTH_ADDR, "r"); + SysTryReturnResult(NID_SYS, fp!= null, E_SYSTEM, "It is failed to get Bluetooth address."); + + char buffer[32] = {0,}; + char* temp = buffer; + int size_of_assign = 0; + + size_of_assign = fscanf(fp, "%s", temp); + if(size_of_assign < 4) + { + SysLogException(NID_SYS, E_SYSTEM, "It is failed to read file. [%d]", size_of_assign); + fclose(fp); + return E_SYSTEM; + } + temp+=4; + + size_of_assign = fscanf(fp, "%s", temp); + if(size_of_assign < 2) + { + SysLogException(NID_SYS, E_SYSTEM, "It is failed to read file. [%d]", size_of_assign); + fclose(fp); + return E_SYSTEM; + } + temp+=2; + + size_of_assign = fscanf(fp, "%s", temp); + if(size_of_assign < 6) + { + SysLogException(NID_SYS, E_SYSTEM, "It is failed to read file. [%d]", size_of_assign); + fclose(fp); + return E_SYSTEM; + } + fclose(fp); + + char* pTmp = buffer; + while (*pTmp = toupper(*pTmp)) + { + pTmp++; + } + + SysLog(NID_SYS, "Bluetooth Address is [%s]", buffer); + + pDeviceString = (char*)malloc(_SEED_LENGTH); + memset(pDeviceString, 0, _SEED_LENGTH); + + strcat(pDeviceString, "BLU"); + strcat(pDeviceString, buffer); + } + else + { + return E_SYSTEM; + } + + int nCryptKeyCount = 0; + for (int i = 0; i < _SEED_LENGTH; i++) + { + pFirstCrypt[i] = (char) (((pDeviceString)[i] ^ keyValue[nCryptKeyCount])); + nCryptKeyCount ++; + if(nCryptKeyCount == _CRYPT_KEY_SIZE) + { + nCryptKeyCount = 0; + } + } + + r = crc64Input.Construct(_SEED_LENGTH); + SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] It is failed to construct ByteBuffer", GetErrorMessage(r)); + + r = crc64Input.SetArray((byte*) pFirstCrypt, 0, _SEED_LENGTH); + SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] It is failed to set array to ByteBuffer", GetErrorMessage(r)); + crc64Input.Flip(); + + r = GenerateCrc64(crc64Input, tempRes); + SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] It is failed to generate CRC64 value", GetErrorMessage(r)); + + r = crc64Result.Construct(sizeof(tempRes)); + SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] It is failed to construct ByteBuffer", GetErrorMessage(r)); + r = crc64Result.SetArray((byte*) &tempRes, 0, sizeof(tempRes)); + SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] It is failed to set array to ByteBuffer", GetErrorMessage(r)); + crc64Result.Flip(); + + r = Base32Encode(crc64Result, base32Result); + SysTryCatch(NID_SYS, !IsFailed(r), , r, "[%s] It is failed to encode as Base64", GetErrorMessage(r)); + + r = utf8.GetString(base32Result, __deviceId); + SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] It is failed to convert ByteBuffer to String", GetErrorMessage(r)); + + deviceId = __deviceId; +CATCH: + if (pDeviceString != null) + { + free(pDeviceString); + } + + return r; +} + +result +_DeviceId::GenerateCrc64(Tizen::Base::ByteBuffer& input, unsigned long long int& value) +{ + result r = E_SUCCESS; + + byte* pPu8 = const_cast (input.GetPointer()); + unsigned long long int* pCrcTable = null; + int inputSize = input.GetRemaining(); + + value = 0ULL; + + pCrcTable = const_cast (__gCrc64Table); + + while (inputSize--) + { + value = pCrcTable[(value ^ *pPu8++) & 0xff] ^ (value >> 8); + } + + return r; +} + +result +_DeviceId::Base32Encode(Tizen::Base::ByteBuffer& input, Tizen::Base::ByteBuffer& output) +{ + result r = E_SUCCESS; + + byte* pEncodingPointer = null; + byte* pSrcPointer = null; + byte* pStorePtr = null; + int i = 0; + + const byte* pInputData = input.GetPointer(); + int inputSize = input.GetRemaining(); + + byte* pBuffer = null; + int bufferLength = 0; + + int pSrcSize = inputSize+1; + + pSrcPointer = (byte*)malloc(sizeof(byte)*pSrcSize); + SysTryReturn(NID_SYS, pSrcPointer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] It is failed to allocate memory"); + pStorePtr = pSrcPointer; + memset(pSrcPointer,0,sizeof(byte)*pSrcSize); + memcpy(pSrcPointer,pInputData,sizeof(byte)*inputSize); + + bufferLength = 8 * (inputSize / 5 + 1) + 1; + pBuffer = (byte*) calloc(1, bufferLength); + SysTryCatch(NID_SYS, pBuffer != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] It is failed to allocate memory"); + + pEncodingPointer = pBuffer; + + for (i = 0; i < inputSize; i += 5) + { + pEncodingPointer[0] = BASE32_CHAR_SET[(pSrcPointer[0] >> 3)]; + pEncodingPointer[1] = BASE32_CHAR_SET[((pSrcPointer[0] & 0x07) << 2) | ((pSrcPointer[1] & 0xc0) >> 6)]; + pEncodingPointer[2] = (i + 1 < inputSize) ? BASE32_CHAR_SET[((pSrcPointer[1] & 0x3e) >> 1)] : '\0'; + pEncodingPointer[3] = (i + 1 < inputSize) ? BASE32_CHAR_SET[((pSrcPointer[1] & 0x01) << 4) | ((pSrcPointer[2] & 0xf0) >> 4)] : '\0'; + pEncodingPointer[4] = (i + 2 < inputSize) ? BASE32_CHAR_SET[((pSrcPointer[2] & 0x0f) << 1) | ((pSrcPointer[3] & 0x80) >> 7)] : '\0'; + pEncodingPointer[5] = (i + 3 < inputSize) ? BASE32_CHAR_SET[((pSrcPointer[3] & 0x3e) >> 2)] : '\0'; + pEncodingPointer[6] = (i + 3 < inputSize) ? BASE32_CHAR_SET[((pSrcPointer[3] & 0x03) << 3) | ((pSrcPointer[4] & 0xe0) >> 5)] : '\0'; + pEncodingPointer[7] = (i + 4 < inputSize) ? BASE32_CHAR_SET[((pSrcPointer[4] & 0x1f))] : '\0'; + + pSrcPointer += 5; + pEncodingPointer += 8; + } + + r = output.Construct(bufferLength); + SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] It is failed to construct ByteBuffer."); + r = output.SetArray(pBuffer, 0, bufferLength); + SysTryCatch(NID_SYS, !IsFailed(r), r = E_SYSTEM, r, "[%s] It is failed to set array to ByteBuffer."); + output.Flip(); + +CATCH: + if (pBuffer != null) + { + free(pBuffer); + } + if (pStorePtr != null) + { + free(pStorePtr); + } + + return r; +} + +}} // Tizen::System + diff --git a/src/system/FSys_DeviceId.h b/src/system/FSys_DeviceId.h new file mode 100644 index 0000000..a6ca39c --- /dev/null +++ b/src/system/FSys_DeviceId.h @@ -0,0 +1,72 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_DeviceId.h + * @brief This is the header file for _DeviceId class. + */ + + +#ifndef _FSYS_INTERNAL_DEVICE_ID_H_ +#define _FSYS_INTERNAL_DEVICE_ID_H_ + + +#include + +namespace Tizen { namespace Base +{ +class String; +class ByteBuffer; +}} + +namespace Tizen { namespace System +{ + + +class _DeviceId +{ +public: + /** + * Gets device unique ID. + * + * @since 1.0 + * @return An error code + * @param[out] deviceId The device unique ID. + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_SYSTEM A system error has occurred. + */ + static result GetId(Tizen::Base::String& deviceId, int type = 0); + +private: + /** + * This is the default constructor for this class. + */ + _DeviceId(void); + + /** + * This is the destructor for this class. + */ + ~_DeviceId(void); + + static result GenerateCrc64(Tizen::Base::ByteBuffer& input, unsigned long long int& value); + static result Base32Encode(Tizen::Base::ByteBuffer& input, Tizen::Base::ByteBuffer& output); + static Tizen::Base::String __deviceId; +}; //_DeviceId + +}} + +#endif // _FSYS_INTERNAL_DEVICE_ID_H_ diff --git a/src/system/FSys_DeviceManagerStub.cpp b/src/system/FSys_DeviceManagerStub.cpp new file mode 100644 index 0000000..0bc8a61 --- /dev/null +++ b/src/system/FSys_DeviceManagerStub.cpp @@ -0,0 +1,353 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_DeviceManagerStub.cpp + * @brief This is the implementation for the _DeviceManagerStub class. + */ +#include + +#include +#include +#include +#include +#include "FApp_AppManagerImpl.h" +#include "FSys_DeviceManagerStub.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; +using namespace Tizen::System; +using namespace Tizen::App; + +const static wchar_t* DEVICE_MANAGER_SERVICE_ID = L"osp.sys.ipcserver.devicemanager"; +const static wchar_t* DEVIVE_MANAGER_SERVICE_MUTEX_ID = L"osp.sys.ipcserver.devicemanager"; +const static wchar_t* DEVICE_MANAGER_COMMAND_OPEN = L"osp.devicemanager.command.open"; +const static wchar_t* DEVICE_MANAGER_COMMAND_CLOSE = L"osp.devicemanager.command.close"; +const static wchar_t* DEVICE_MANAGER_COMMAND_STATUS= L"osp.devicemanager.command.status"; +const static wchar_t* DEVICE_MANAGER_COMMAND_EVENT = L"osp.devicemanager.command.event"; +const static wchar_t* DEVICE_MANAGER_BLUETOOTH = L"osp.devicemanager.bluetooth"; +const static wchar_t* DEVICE_MANAGER_REGISTRY_NAME = L"/tmp/sys.devicemanager.ini"; +const static wchar_t* DEVICE_MANAGER_REGISTRY_SECTION = L"DeviceManagerPid"; + +const static wchar_t* BLUETOOTH_A2DP_CONNECTED = L"Connected"; +const static wchar_t* BLUETOOTH_A2DP_DISCONNECTED = L"Disconnected"; + +_DeviceManagerStub* _DeviceManagerStub::__pDeviceManagerStub = null; + +_DeviceManagerStub::_DeviceManagerStub(void) + : __pIpcServer(null) + , __pDeviceManager(null) + , __pDeviceManagerServiceIpcEventForAsync(null) + , __IsInitializedDevice(false) + , __pRegistry(null) +{ + result r = E_SUCCESS; + r = __Mutex.Create(DEVIVE_MANAGER_SERVICE_MUTEX_ID); + SysTryReturn(NID_SYS, r == E_SUCCESS, , r, "It is failed to create mutex. [%s] Propaged.", GetErrorMessage(r)); +} + +_DeviceManagerStub::~_DeviceManagerStub(void) +{ + __pDeviceManager->UnregisterListner(*this); + + if (__pRegistry) + { + __pRegistry->Flush(); + delete __pRegistry; + } + + if (__pIpcServer) + { + __pIpcServer->Stop(); + } + + if (__pDeviceManagerServiceIpcEventForAsync) + { + delete __pDeviceManagerServiceIpcEventForAsync; + } + __Mutex.Release(); +} + +_DeviceManagerStub* +_DeviceManagerStub::GetInstance(void) +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + + if (__pDeviceManagerStub == null) + { + pthread_once(&onceBlock, InitSingleton); + } + return __pDeviceManagerStub; +} + +void +_DeviceManagerStub::InitSingleton(void) +{ + unique_ptr< _DeviceManagerStub > pDeviceManagerStub(new (std::nothrow) _DeviceManagerStub()); + SysTryReturn(NID_SYS, pDeviceManagerStub, ,E_OUT_OF_MEMORY, "It is not enough memory."); + + result r = pDeviceManagerStub->Construct(); + SysTryReturn(NID_SYS, !IsFailed(r), , r, "[%s] It is failed to get DeviceManagerCommunicationStub.", GetErrorMessage(r)); + __pDeviceManagerStub = pDeviceManagerStub.release(); + SysLog(NID_SYS, "It is success InitSingleton."); + atexit(DestroySingleton); +} + +void +_DeviceManagerStub::DestroySingleton(void) +{ + delete __pDeviceManagerStub; +} + + +result +_DeviceManagerStub::Construct(void) +{ + unique_ptr<_IpcServer> pIpcServer(new (std::nothrow) _IpcServer()); + SysTryReturnResult(NID_SYS, pIpcServer, E_OUT_OF_MEMORY, "Memory is insufficient."); + + result r = pIpcServer->Construct(String(DEVICE_MANAGER_SERVICE_ID), *this, true); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to construct."); + + r = pIpcServer->Start(); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to start."); + + __pDeviceManager = _DeviceManager::GetInstance(); + SysTryReturn(NID_SYS, __pDeviceManager, E_SYSTEM, E_SYSTEM,"It is failed to create DeviceManager instance."); + + __pRegistry = new (std::nothrow) Registry(); + SysTryReturn(NID_SYS, __pRegistry, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"Memory is insufficient."); + + r = __pRegistry->Construct(DEVICE_MANAGER_REGISTRY_NAME, "a+"); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to open device manager registry.[%s]", GetErrorMessage(r)); + + r = __pRegistry->AddSection(DEVICE_MANAGER_REGISTRY_SECTION); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to add device manager registry section.[%s]", GetErrorMessage(r)); + + r = __pRegistry->Flush(); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to flush device manager registry.[%s]", GetErrorMessage(r)); + + __pIpcServer = move(pIpcServer); + + _AppManagerImpl* pAppManagerImpl = Tizen::App::_AppManagerImpl::GetInstance(); + pAppManagerImpl->AddAppEventListener(*this); + + __pDeviceManager->RegisterListner(*this); + + return E_SUCCESS; +} + + + +result +_DeviceManagerStub::SendData(const int pid, Tizen::Base::Collection::ArrayList* data) +{ + __Mutex.Acquire(); + result r = E_SUCCESS; + + SysTryCatch(NID_SYS, __pIpcServer != null, r = E_SYSTEM, E_SYSTEM, "IPC server is not ready."); + SysTryCatch(NID_SYS, data != null, r = E_SYSTEM, E_SYSTEM, "There is no data."); + + if(__pDeviceManagerServiceIpcEventForAsync == null) + { + __pDeviceManagerServiceIpcEventForAsync = new (std::nothrow) _SystemServiceIpcEventForAsync(__pIpcServer.get()); + __pDeviceManagerServiceIpcEventForAsync->Construct(1048576, Tizen::Base::Runtime::THREAD_PRIORITY_MID); + __pDeviceManagerServiceIpcEventForAsync->Start(); + } + SysTryCatch(NID_SYS, __pDeviceManagerServiceIpcEventForAsync != null, r = E_SYSTEM, E_SYSTEM, "Event thread is not ready."); + + r = __pDeviceManagerServiceIpcEventForAsync->SendUserEvent((RequestId)pid, (IList*)data); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Message is failed to add on event thread."); + SysLog(NID_SYS, "It is success to send data"); +CATCH: + if(r != E_SUCCESS) + { + delete data; + } + __Mutex.Release(); + return r; +} + +void +_DeviceManagerStub::AddInterestedApp(AppId appId, int pid) +{ + result r = E_SUCCESS; + + if (__IsInitializedDevice == false) + { + r = __pDeviceManager->InitializeDevice(); + SysTryReturn(NID_SYS, r == E_SUCCESS, , E_SYSTEM, "It is failed to init device"); + __IsInitializedDevice = true; + SysLog(NID_SYS, "InitializeDevice for BT"); + } + r = __pRegistry->AddValue(DEVICE_MANAGER_REGISTRY_SECTION, (String) appId, pid); + SysLog(NID_SYS, "The result of adding pid is [%s]", GetErrorMessage(r)); + r = __pRegistry->Flush(); + SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, r, "It is failed to flush pid registry.[%s]", GetErrorMessage(r)); +} + + +void +_DeviceManagerStub::RemoveInterestedApp(AppId appId, int pid) +{ + if (__IsInitializedDevice == false) + { + return; + } + result r = __pRegistry->RemoveValue(DEVICE_MANAGER_REGISTRY_SECTION, (String) appId); + SysLog(NID_SYS, "The result of removing pid is [%s]", GetErrorMessage(r)); + r = __pRegistry->Flush(); + SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, r, "It is failed to flush pid registry.[%s]", GetErrorMessage(r)); + + IList* pInterestList = __pRegistry->GetAllEntryNamesN(DEVICE_MANAGER_REGISTRY_SECTION); + SysTryReturn(NID_SYS, pInterestList, , E_SYSTEM, "It is failed to get registry."); + + if (pInterestList->GetCount() == 0) + { + __pDeviceManager->DeinitializeDevice(); + __IsInitializedDevice = false; + SysLog(NID_SYS, "DeinitializeDevice for BT"); + } + delete pInterestList; +} + + +void +_DeviceManagerStub::OnDeviceStateChanged (DeviceType deviceType, const Tizen::Base::String &state) +{ + std::unique_ptr< Tizen::Base::Collection::IList> pInterestedPidList(__pRegistry->GetAllEntryNamesN(DEVICE_MANAGER_REGISTRY_SECTION)); + SysTryReturn(NID_SYS, pInterestedPidList, , E_SYSTEM, "It is failed to get list from registry."); + + if(pInterestedPidList->GetCount() > 0) + { + for ( int count = 0; count < pInterestedPidList->GetCount() ; count++) + { + int pid = -1; + String* pAppId = (String*)pInterestedPidList->GetAt(count); + result r = __pRegistry->GetValue(DEVICE_MANAGER_REGISTRY_SECTION, *pAppId, pid); + SysTryReturn(NID_SYS, r == E_SUCCESS, , E_SYSTEM, "It is failed to get pid [%s].", GetErrorMessage(r)); + SysLog(NID_SYS, "Device interest id [%ls] [%d]", pAppId->GetPointer(), pid); + + ArrayList* data = null; + + __serviceId = DEVICE_MANAGER_SERVICE_ID; + __command = DEVICE_MANAGER_COMMAND_EVENT; + __deviceType = DEVICE_MANAGER_BLUETOOTH; + __result = state; + + data = new (std::nothrow) ArrayList(); + data->Construct(); + data->Add(__serviceId); + data->Add(__command); + data->Add(__deviceType); + data->Add(__result); + + SendData(pid, data); + SysLog(NID_SYS, "Bluetooth headset event is sent to %d [%ls].", pid, state.GetPointer()); + } + } + else + { + SysLog(NID_SYS, "Bluetooth Headset Event is not required by any application."); + } +} + +void +_DeviceManagerStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message) +{ + __currentPkgId = server.GetClientPackageId(); + __currentPid = server.GetClientId(); + IPC_BEGIN_MESSAGE_MAP(_DeviceManagerStub, message) + IPC_MESSAGE_HANDLER_EX(IoService_Request, &server, OnRequestOccured) + IPC_END_MESSAGE_MAP_EX() +} + +bool +_DeviceManagerStub::OnRequestOccured(const ArrayList& request, ArrayList* response) +{ + int cmp = 0; + StringComparer strComparer; + + __command = *(String*)request.GetAt(1); + __deviceType = *(String*)request.GetAt(2); + + SysLog(NID_SYS, "command is %ls, device is %ls", __command.GetPointer(), __deviceType.GetPointer()); + + strComparer.Compare(__command, String(DEVICE_MANAGER_COMMAND_OPEN), cmp); + if(cmp == 0) + { + strComparer.Compare(__deviceType, String(DEVICE_MANAGER_BLUETOOTH), cmp); + if(cmp == 0) + { + SysLog(NID_SYS, "Bluetooth headset event is required"); + AddInterestedApp(__currentPkgId, __currentPid); + } + } + + strComparer.Compare(__command, String(DEVICE_MANAGER_COMMAND_CLOSE), cmp); + if(cmp == 0) + { + strComparer.Compare(__deviceType, String(DEVICE_MANAGER_BLUETOOTH), cmp); + if(cmp == 0) + { + RemoveInterestedApp(__currentPkgId, __currentPid); + } + } + strComparer.Compare(__command, String(DEVICE_MANAGER_COMMAND_STATUS), cmp); + if(cmp == 0) + { + strComparer.Compare(__deviceType, String(DEVICE_MANAGER_BLUETOOTH), cmp); + if(cmp == 0) + { + bool isBluetoothHeadSetConnected = __pDeviceManager->GetBluetoothStatus(); + SysLog(NID_SYS, "Bluetooth headset status is %d", isBluetoothHeadSetConnected); + + if(response != null) + { + __serviceId = DEVICE_MANAGER_SERVICE_ID; + __command = DEVICE_MANAGER_COMMAND_STATUS; + __deviceType = DEVICE_MANAGER_BLUETOOTH; + + if(isBluetoothHeadSetConnected == true) + { + __result = BLUETOOTH_A2DP_CONNECTED; + } + else + { + __result = BLUETOOTH_A2DP_DISCONNECTED; + } + response->Add(__serviceId); + response->Add(__command); + response->Add(__deviceType); + response->Add(__result); + } + } + } + + ArrayList* temp = const_cast(&request); + temp->RemoveAll(true); + return true; +} + + +void +_DeviceManagerStub::OnApplicationTerminated(const AppId& appId, int pid) +{ + RemoveInterestedApp(appId, pid); +} diff --git a/src/system/FSys_DeviceManagerStub.h b/src/system/FSys_DeviceManagerStub.h new file mode 100644 index 0000000..e5f4726 --- /dev/null +++ b/src/system/FSys_DeviceManagerStub.h @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_DeviceManagerStub.h + * @brief This is the header file of the _DeviceManagerStub class. + * + * This header file contains the declarations of the _DeviceManagerStub class. + */ + +#ifndef _FSYS_DEVICE_MANAGER_STUB_H_ +#define _FSYS_DEVICE_MANAGER_STUB_H_ + +#include +#include +#include +#include +#include "FApp_IAppEventListener.h" +#include "FSys_SystemServiceIpcEventForAsync.h" +#include "FSys_DeviceManager.h" + +namespace Tizen { namespace System +{ +class _OSP_EXPORT_ _DeviceManagerStub + : public Tizen::Base::Object + , public Tizen::Io::_IIpcServerEventListener + , public Tizen::System::IDeviceEventListener + , public Tizen::App::_IAppEventListener +{ +public: + static _DeviceManagerStub* GetInstance(void); + + virtual ~_DeviceManagerStub(void); + result SendData(const int pid, Tizen::Base::Collection::ArrayList* data); + virtual void OnDeviceStateChanged (DeviceType deviceType, const Tizen::Base::String &state); +private: + _DeviceManagerStub(void); + result Construct(void); + + static void InitSingleton(void); + static void DestroySingleton(void); + + _DeviceManagerStub(const _DeviceManagerStub& rhs); + _DeviceManagerStub& operator =(const _DeviceManagerStub& rhs); + + void AddInterestedApp(Tizen::App::AppId appId, int pid); + void RemoveInterestedApp(Tizen::App::AppId appId, int pid); + + bool OnRequestOccured(const Tizen::Base::Collection::ArrayList& request, Tizen::Base::Collection::ArrayList* response); + virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message); + virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, int pid); + + virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server){}; + virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server){}; + virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId){}; + virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId){}; + + virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, int pid){}; + +private: + std::unique_ptr __pIpcServer; + static _DeviceManagerStub* __pDeviceManagerStub; + _DeviceManager* __pDeviceManager; + Tizen::Base::Runtime::Mutex __Mutex; + Tizen::App::AppId __currentPkgId; + int __currentPid; + Tizen::Base::String __serviceId; + Tizen::Base::String __command; + Tizen::Base::String __deviceType; + Tizen::Base::String __result; + + _SystemServiceIpcEventForAsync* __pDeviceManagerServiceIpcEventForAsync; + bool __IsInitializedDevice; + Tizen::Io::Registry* __pRegistry; +}; // _DeviceManagerStub + +}} // Tizen::System + +#endif // _FSYS_DEVICE_MANAGER_STUB_H_ diff --git a/src/system/FSys_PowerManagerStub.cpp b/src/system/FSys_PowerManagerStub.cpp new file mode 100644 index 0000000..a08b3f9 --- /dev/null +++ b/src/system/FSys_PowerManagerStub.cpp @@ -0,0 +1,270 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_PowerManagerStub.cpp + * @brief This is the implementation for the _PowerManagerStub class. + */ +#include +#include +#include +#include +#include "FApp_AppManagerImpl.h" +#include "FSys_PowerManagerStub.h" +#include "FSys_PowerManager.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; +using namespace Tizen::System; +using namespace Tizen::App; + +namespace { + static const wchar_t* POWER_MANAGER_SERVICE_ID = L"osp.sys.ipcserver.powermanager"; + static const wchar_t* _POWER_BRIGHTNESS_CHANGE = L"osp.system.command.power.change.brightness"; + static const wchar_t* _POWER_BRIGHTNESS_RESTORE = L"osp.system.command.power.restore.brightness"; + static const int _POWER_COMMAND_ID = 1; + static const wchar_t* _POWER_OK = L"osp.system.result.ok"; + static const wchar_t* _POWER_ERROR = L"osp.system.result.error"; + static const wchar_t* _POWER_MANAGER_REGISTRY_NAME = L"/tmp/sys.powermanager.ini"; + static const wchar_t* _POWER_MANAGER_REGISTRY_BRIGHTNESS_SECTION = L"Brightness"; + static const wchar_t* _POWER_MANAGER_REGISTRY_ACTIVE_ID = L"ActiveId"; +} + +_PowerManagerStub* _PowerManagerStub::__pPowerManagerStub = null; + +_PowerManagerStub::_PowerManagerStub(void) + : __pIpcServer(null) + , __serviceId(POWER_MANAGER_SERVICE_ID) + , __pRegistry(null) +{ +} + +_PowerManagerStub::~_PowerManagerStub(void) +{ + if (__pIpcServer) + { + __pIpcServer->Stop(); + } + + if (__pRegistry) + { + __pRegistry->Flush(); + delete __pRegistry; + } +} + +_PowerManagerStub* +_PowerManagerStub::GetInstance() +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + + if (__pPowerManagerStub == null) + { + pthread_once(&onceBlock, InitSingleton); + } + return __pPowerManagerStub; +} + +void +_PowerManagerStub::InitSingleton(void) +{ + std::unique_ptr< _PowerManagerStub > pPowerManagerStub(new (std::nothrow) _PowerManagerStub()); + SysTryReturn(NID_SYS, pPowerManagerStub, ,E_OUT_OF_MEMORY, "It is not enough memory."); + result r = pPowerManagerStub->Construct(); + SysTryReturn(NID_SYS, !IsFailed(r), , r, "[%s] It is failed to get PowerManagerCommunicationStub.", GetErrorMessage(r)); + __pPowerManagerStub = pPowerManagerStub.release(); + atexit(DestroySingleton); +} + + +void +_PowerManagerStub::DestroySingleton(void) +{ + delete __pPowerManagerStub; +} + +result +_PowerManagerStub::Construct(void) +{ + unique_ptr<_IpcServer> pIpcServer(new (std::nothrow) _IpcServer()); + SysTryReturnResult(NID_SYS, pIpcServer, E_OUT_OF_MEMORY, "Memory is insufficient."); + + result r = pIpcServer->Construct(String(POWER_MANAGER_SERVICE_ID), *this, true); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to construct."); + + r = pIpcServer->Start(); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to start."); + + _AppManagerImpl* pAppManagerImpl = null; + pAppManagerImpl = _AppManagerImpl::GetInstance(); + SysTryReturn(NID_SYS, pAppManagerImpl != null, E_SYSTEM , E_SYSTEM, "It is failed to get _AppManagerImpl class."); + + r = pAppManagerImpl->AddActiveAppEventListener(*this); + SysTryReturn(NID_SYS, r == E_SUCCESS || r == E_OBJ_ALREADY_EXIST, E_SYSTEM, E_SYSTEM, "[%s] It is failed to add active app event listener",GetErrorMessage(r)); + + r = pAppManagerImpl->AddAppEventListener(*this); + SysTryReturn(NID_SYS, r == E_SUCCESS || r == E_OBJ_ALREADY_EXIST, E_SYSTEM, E_SYSTEM, "It is failed to add app event listener"); + + __pRegistry = new (std::nothrow) Registry(); + SysTryReturn(NID_SYS, __pRegistry, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,"Memory is insufficient."); + + r = __pRegistry->Construct(_POWER_MANAGER_REGISTRY_NAME, "a+"); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to open power manager registry.[%s]", GetErrorMessage(r)); + + r = __pRegistry->AddSection(_POWER_MANAGER_REGISTRY_BRIGHTNESS_SECTION); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "It is failed to add power manager registry brightness section.[%s]", GetErrorMessage(r)); + + __pIpcServer = move(pIpcServer); + + return E_SUCCESS; +} + +result +_PowerManagerStub::ChangeBrightness() +{ + result r = E_FAILURE; + int brightness = -1; + + r = __pRegistry->GetValue(_POWER_MANAGER_REGISTRY_BRIGHTNESS_SECTION, (String)__activeAppId, brightness); + if (r == E_SUCCESS) + { + r = _PowerManager::ChangeBrightness(brightness); + SysLog(NID_SYS, "change brightness %d", brightness); + } + + if (r != E_SUCCESS) + { + r = _PowerManager::ChangeBrightness(0); + SysLog(NID_SYS, "change brightness system value."); + } + + return r; +} +void +_PowerManagerStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message) +{ + __currentAppId = server.GetClientPackageId(); + IPC_BEGIN_MESSAGE_MAP(_PowerManagerStub, message) + IPC_MESSAGE_HANDLER_EX(IoService_Request, &server, OnRequestOccured) + IPC_END_MESSAGE_MAP_EX() +} + +bool +_PowerManagerStub::OnRequestOccured(const ArrayList& request, ArrayList* response) +{ + bool isSuccess = false; + result r = E_SUCCESS; + + __command = *((String*)request.GetAt(_POWER_COMMAND_ID)); + + if (__activeAppId.IsEmpty()) + { + r = __pRegistry->GetValue(_POWER_MANAGER_REGISTRY_BRIGHTNESS_SECTION, _POWER_MANAGER_REGISTRY_ACTIVE_ID, __activeAppId); + if (r == E_SUCCESS) + { + SysLog(NID_SYS, "Get the active id from registry [%ls].", __activeAppId.GetPointer()); + } + else + { + SysLog(NID_SYS, "It is failed to get the active id from registry"); + } + } + + if (__command == _POWER_BRIGHTNESS_CHANGE) + { + SysTryCatch(NID_SYS, __activeAppId == __currentAppId, r = E_SUCCESS, r, + "It is not active application[%ls]. Current Active App is [%ls].", __currentAppId.GetPointer(), __activeAppId.GetPointer()); + int brightness = 0; + String* brightnessBuffer = (String*)request.GetAt(_POWER_COMMAND_ID + 1); + Integer::Parse(*brightnessBuffer, brightness); + + __pRegistry->RemoveValue(_POWER_MANAGER_REGISTRY_BRIGHTNESS_SECTION, (String)__currentAppId); + + r = __pRegistry->AddValue(_POWER_MANAGER_REGISTRY_BRIGHTNESS_SECTION, __currentAppId, brightness); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, + "It is failed to add requested App Id(%ls) and Brightness(%d) on the managed app list.", __currentAppId.GetPointer(), brightness); + r = ChangeBrightness(); + } + else if(__command == _POWER_BRIGHTNESS_RESTORE) + { + SysLog(NID_SYS, "Request bright restore"); + __pRegistry->RemoveValue(_POWER_MANAGER_REGISTRY_BRIGHTNESS_SECTION, (String)__currentAppId); + r = ChangeBrightness(); + } + else + { + SysLogException(NID_SYS, E_SYSTEM, "Required Command[%ls] is not proccess on _PowerManager.", __command.GetPointer()); + r = E_SYSTEM; + } + + isSuccess = true; +CATCH: + if(r == E_SUCCESS) + { + __result = _POWER_OK; + } + else + { + __result = _POWER_ERROR; + } + + response->Add(__serviceId); + response->Add(__command); + response->Add(__result); + + ArrayList* temp = const_cast(&request); + temp->RemoveAll(true); + + __pRegistry->Flush(); + return isSuccess; +} + +void +_PowerManagerStub::OnApplicationTerminated(const AppId& appId, int pid) +{ + SysLog(NID_SYS, "Terminated app [%ls]", appId.GetPointer()); + String requiredAppId; + appId.SubString(0, 10, requiredAppId); + __pRegistry->RemoveValue(_POWER_MANAGER_REGISTRY_BRIGHTNESS_SECTION, (String)requiredAppId); + __pRegistry->Flush(); + ChangeBrightness(); +} + +void +_PowerManagerStub::OnActiveAppChanged(const AppId& appId) +{ + AppId smallAppId; + appId.SubString(0, 10, smallAppId); + SysLog(NID_SYS, "Active app [%ls], current [%ls] ", smallAppId.GetPointer(), __activeAppId.GetPointer()); + if(__activeAppId != smallAppId) + { + __activeAppId = smallAppId; + result r = __pRegistry->AddValue(_POWER_MANAGER_REGISTRY_BRIGHTNESS_SECTION, _POWER_MANAGER_REGISTRY_ACTIVE_ID, (String)__activeAppId); + if (r == E_KEY_ALREADY_EXIST) + { + __pRegistry->SetValue(_POWER_MANAGER_REGISTRY_BRIGHTNESS_SECTION, _POWER_MANAGER_REGISTRY_ACTIVE_ID, (String)__activeAppId); + } + __pRegistry->Flush(); + ChangeBrightness(); + } + else + { + SysLog(NID_SYS, "Current App[%ls] is already actived.", __activeAppId.GetPointer()); + } +} diff --git a/src/system/FSys_PowerManagerStub.h b/src/system/FSys_PowerManagerStub.h new file mode 100644 index 0000000..28e3494 --- /dev/null +++ b/src/system/FSys_PowerManagerStub.h @@ -0,0 +1,86 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_PowerManagerStub.h + * @brief This is the header file of the _PowerManagerStub class. + * + * This header file contains the declarations of the _PowerManagerStub class. + */ + +#ifndef _FSYS_POWER_MANAGER_STUB_H_ +#define _FSYS_POWER_MANAGER_STUB_H_ + +#include +#include +#include + +#include +#include +#include "FApp_IAppEventListener.h" + +namespace Tizen { namespace System +{ +class _OSP_EXPORT_ _PowerManagerStub + : public Tizen::Base::Object + , public Tizen::Io::_IIpcServerEventListener + , public Tizen::App::_IAppEventListener + , public Tizen::App::IActiveAppEventListener +{ +public: + static _PowerManagerStub* GetInstance(void); + virtual ~_PowerManagerStub(void); + virtual void OnActiveAppChanged(const Tizen::App::AppId& appId); + +private: + static void InitSingleton(void); + static void DestroySingleton(void); + + _PowerManagerStub(void); + result Construct(void); + + result ChangeBrightness(void); + + _PowerManagerStub(const _PowerManagerStub& rhs); + _PowerManagerStub& operator =(const _PowerManagerStub& rhs); + + bool OnRequestOccured(const Tizen::Base::Collection::ArrayList& request, Tizen::Base::Collection::ArrayList* response); + + virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server) {} + virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server) {} + virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId) {} + virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId) {} + virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message); + + virtual void OnApplicationLaunched(const Tizen::App::AppId& appId, int pid) {} + virtual void OnApplicationTerminated(const Tizen::App::AppId& appId, int pid); + +private: + std::unique_ptr __pIpcServer; + static _PowerManagerStub* __pPowerManagerStub; + Tizen::Base::Runtime::Mutex __Mutex; + Tizen::App::AppId __activeAppId; + Tizen::App::AppId __currentAppId; + Tizen::Base::String __serviceId; + Tizen::Base::String __command; + Tizen::Base::String __result; + Tizen::Io::Registry* __pRegistry; +}; // _PowerManagerStub + +}} // Tizen::System + +#endif // _FSYS_POWER_MANAGER_STUB_H_ diff --git a/src/system/FSys_RuntimeInfoStub.cpp b/src/system/FSys_RuntimeInfoStub.cpp new file mode 100644 index 0000000..096c98d --- /dev/null +++ b/src/system/FSys_RuntimeInfoStub.cpp @@ -0,0 +1,312 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_RuntimeInfoStub.cpp + * @brief This is the implementation for the _RuntimeInfoStub class. + */ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "FSys_RuntimeInfo.h" +#include "FSys_RuntimeInfoStub.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; +using namespace Tizen::System; +using namespace Tizen::App; + +namespace { + static const wchar_t* RUNTIME_INFO_STUB_MUTEX_ID = L"osp.sys.ipcserver.runtimeinfo"; + static const int _RUNTIME_GET_PARAM_TYPE = 1; + static const wchar_t* _RUNTIME_SERVICE_ID = L"osp.sys.ipcserver.runtimeinfo"; + static const wchar_t* _RUNTIME_GET_SIZE = L"osp.system.command.runtime.get.size"; + static const wchar_t* _RUNTIME_RESULT_SUCCESS = L"osp.system.result.success"; + static const wchar_t* _RUNTIME_RESULT_SYSTEM = L"osp.system.result.system"; +} + +_RuntimeInfoStub* _RuntimeInfoStub::__pRuntimeInfoStub = null; + +static pthread_mutex_t send_msg_lock; +class _DirectorySizeObject +{ +public: + _DirectorySizeObject() + : path(null) + , pid(0) + , msg_id(0) + { + } + ~_DirectorySizeObject() + { + if(path != null) + { + delete [] path; + } + } + + char* path; + int pid; + int msg_id; +}; + +_RuntimeInfoStub::_RuntimeInfoStub(void) + : __pIpcServer(null) + , __pIpcEventForAsync(null) +{ + result r = E_SUCCESS; + r = __Mutex.Create(RUNTIME_INFO_STUB_MUTEX_ID); + SysTryReturn(NID_SYS, r == E_SUCCESS, , r, "It is failed to create mutex. [%s] Propaged.", GetErrorMessage(r)); + + if(pthread_mutex_init(&send_msg_lock, null)) + { + SysLogException(NID_SYS, E_SYSTEM, "It is failed to init mutex."); + } +} + +_RuntimeInfoStub::~_RuntimeInfoStub(void) +{ + if (__pIpcServer) + { + __pIpcServer->Stop(); + } + + __Mutex.Release(); + + if(pthread_mutex_destroy(&send_msg_lock)) + { + SysLogException(NID_SYS, E_SYSTEM, "It is failed to term mutex."); + } +} + +_RuntimeInfoStub* +_RuntimeInfoStub::GetInstance(void) +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + + if (__pRuntimeInfoStub == null) + { + pthread_once(&onceBlock, InitSingleton); + } + return __pRuntimeInfoStub; +} + +void +_RuntimeInfoStub::InitSingleton(void) +{ + std::unique_ptr< _RuntimeInfoStub > pRuntimeInfoStub(new (std::nothrow) _RuntimeInfoStub()); + SysTryReturn(NID_SYS, pRuntimeInfoStub, , E_OUT_OF_MEMORY, "It is not enough memory."); + + result r = pRuntimeInfoStub->Construct(); + SysTryReturn(NID_SYS, !IsFailed(r), , r, "[%s] It is failed to get RuntimeInfoCommunicationStub.", GetErrorMessage(r)); + __pRuntimeInfoStub = pRuntimeInfoStub.release(); + atexit(DestroySingleton); +} + +void +_RuntimeInfoStub::DestroySingleton(void) +{ + delete __pRuntimeInfoStub; +} + +result +_RuntimeInfoStub::Construct(void) +{ + std::unique_ptr<_IpcServer> pIpcServer(new (std::nothrow) _IpcServer()); + SysTryReturnResult(NID_SYS, pIpcServer, E_OUT_OF_MEMORY, "Memory is insufficient."); + + result r = pIpcServer->Construct(String(_RUNTIME_SERVICE_ID), *this, true); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to construct."); + + r = pIpcServer->Start(); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to start."); + + __pIpcServer = move(pIpcServer); + return E_SUCCESS; +} + +void +_RuntimeInfoStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message) +{ + __currentPid = server.GetClientId(); + IPC_BEGIN_MESSAGE_MAP(_RuntimeInfoStub, message) + IPC_MESSAGE_HANDLER_EX(IoService_Request, &server, OnRequestOccured) + IPC_END_MESSAGE_MAP_EX() +} + +bool +_RuntimeInfoStub::OnRequestOccured(const ArrayList& request, ArrayList* response) +{ + bool isSuccess = false; + result r = E_SUCCESS; + + __serviceId = _RUNTIME_SERVICE_ID; + __command = *((String*)request.GetAt(_RUNTIME_GET_PARAM_TYPE)); + __result = L""; + + if(__command == _RUNTIME_GET_SIZE) + { + int mid = 0; + String* path = (String*)request.GetAt(_RUNTIME_GET_PARAM_TYPE+1); + String* messageId = (String*)request.GetAt(_RUNTIME_GET_PARAM_TYPE+2); + SysTryCatch(NID_SYS, path != null, r = E_SYSTEM, E_SYSTEM, "There is no path information."); + + std::unique_ptr< char > directoryPath(_StringConverter::CopyToCharArrayN(*path)); + Integer::Parse(*messageId, mid); + _DirectorySizeObject* dso = new (std::nothrow) _DirectorySizeObject(); + dso->pid = __currentPid; + dso->path = directoryPath.release(); + dso->msg_id = mid; + + pthread_t p_thread; + int thr_id = pthread_create(&p_thread, null, _RuntimeInfoStub::GetDirectorySizeAsync, dso); + if(thr_id < 0) + { + __result = _RUNTIME_RESULT_SYSTEM; + } + else + { + pthread_detach(p_thread); + __result = _RUNTIME_RESULT_SUCCESS; + } + } + else + { + __result = _RUNTIME_RESULT_SYSTEM; + } + + isSuccess = true; +CATCH: + response->Add(__serviceId); + response->Add(__command); + if (isSuccess == true) + { + response->Add(__result); + } + + ArrayList* temp = const_cast(&request); + temp->RemoveAll(true); + return isSuccess; +} + +void* +_RuntimeInfoStub::GetDirectorySizeAsync(void* data) +{ + result r= E_SUCCESS; + long long size = 0; + _RuntimeInfo* pRuntimeInfo = null; + _DirectorySizeObject* dso = null; + + pRuntimeInfo = _RuntimeInfo::GetInstance(); + SysTryCatch(NID_SYS, pRuntimeInfo != null, r = E_SYSTEM, r, "There is no _RuntimeInfo instance."); + + dso = (_DirectorySizeObject*) data; + SysTryCatch(NID_SYS, dso != null, r = E_SYSTEM, r, "There is no _DirectorySizeObject."); + + size = pRuntimeInfo->GetDirectorySize(dso->path); + +CATCH: + if(dso != null) + { + _RuntimeInfoStub::SendResponse(dso->pid, dso->msg_id, size, r); + delete dso; + } + return null; +} + +void +_RuntimeInfoStub::SendResponse(int pid, int msg_id, long long size, result rcode) +{ + result r = E_SUCCESS; + pthread_mutex_lock(&send_msg_lock); + + ArrayList* data = null; + String* pValue = null; + String* pMessageId = null; + + SysLog(NID_SYS, "It sends asynchronous result to pid [%d].", pid); + + data = new (std::nothrow) ArrayList(SingleObjectDeleter); + data->Construct(); + + pMessageId = new (std::nothrow) String(); + pMessageId->Append(msg_id); + + data->Add(new (std::nothrow) String(_RUNTIME_SERVICE_ID)); + data->Add(new (std::nothrow) String(_RUNTIME_GET_SIZE)); + data->Add(pMessageId); + + pValue = new (std::nothrow) String(); + pValue->Append(size); + data->Add(pValue); + + if(rcode == E_SUCCESS) + { + data->Add(new (std::nothrow) String(_RUNTIME_RESULT_SUCCESS)); + } + else + { + data->Add(new (std::nothrow) String(_RUNTIME_RESULT_SYSTEM)); + } + + _RuntimeInfoStub* pRuntimeInfoStub = null; + pRuntimeInfoStub = _RuntimeInfoStub::GetInstance(); + SysTryCatch(NID_SYS, pRuntimeInfoStub, E_SYSTEM, E_SYSTEM, "RuntimeInfoStub is not created."); + + pRuntimeInfoStub->SendDataAsync(pid, data); +CATCH: + pthread_mutex_unlock(&send_msg_lock); + +} + +result +_RuntimeInfoStub::SendDataAsync(const int pid, Tizen::Base::Collection::ArrayList* data) +{ + __Mutex.Acquire(); + result r = E_SUCCESS; + + SysTryCatch(NID_SYS, __pIpcServer != null, r = E_SYSTEM, E_SYSTEM, "IPC server is not ready."); + SysTryCatch(NID_SYS, data != null, r = E_SYSTEM, E_SYSTEM, "There is no data."); + + if(__pIpcEventForAsync == null) + { + __pIpcEventForAsync.reset(new (std::nothrow) _SystemServiceIpcEventForAsync(__pIpcServer.get())); + SysTryCatch(NID_SYS, __pIpcEventForAsync != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "It is not enough memory."); + __pIpcEventForAsync->Construct(1048576, Tizen::Base::Runtime::THREAD_PRIORITY_MID); + __pIpcEventForAsync->Start(); + } + + r = __pIpcEventForAsync->SendUserEvent((RequestId)pid, (IList*)data); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "Message is failed to add on event thread."); + +CATCH: + if(r != E_SUCCESS) + { + delete data; + } + __Mutex.Release(); + return r; +} diff --git a/src/system/FSys_RuntimeInfoStub.h b/src/system/FSys_RuntimeInfoStub.h new file mode 100644 index 0000000..ff2b030 --- /dev/null +++ b/src/system/FSys_RuntimeInfoStub.h @@ -0,0 +1,79 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_RuntimeInfoStub.h + * @brief This is the header file of the _RuntimeInfoStub class. + * + * This header file contains the declarations of the _RuntimeInfoStub class. + */ + +#ifndef _FSYS_RUNTIME_INFO_STUB_H_ +#define _FSYS_RUNTIME_INFO_STUB_H_ + +#include +#include +#include +#include + +#include "FSys_SystemServiceIpcEventForAsync.h" + +namespace Tizen { namespace System +{ +class _OSP_EXPORT_ _RuntimeInfoStub + : public Tizen::Base::Object + , public Tizen::Io::_IIpcServerEventListener +{ +public: + static _RuntimeInfoStub* GetInstance(void); + virtual ~_RuntimeInfoStub(void); + +private: + static void InitSingleton(void); + static void DestroySingleton(void); + + _RuntimeInfoStub(void); + result Construct(void); + + bool OnRequestOccured(const Tizen::Base::Collection::ArrayList& request, Tizen::Base::Collection::ArrayList* response); + virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message); + result SendDataAsync(const int pid, Tizen::Base::Collection::ArrayList* data); + + static void SendResponse(int pid, int msg_id, long long size, result rcode); + static void* GetDirectorySizeAsync(void* data); + + virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server) {} + virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server) {} + virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId) {} + virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId) {} + +private: + int __currentPid; + Tizen::Base::String __serviceId; + Tizen::Base::String __command; + Tizen::Base::String __result; + + std::unique_ptr< Tizen::Io::_IpcServer > __pIpcServer; + std::unique_ptr< _SystemServiceIpcEventForAsync > __pIpcEventForAsync; + + static _RuntimeInfoStub* __pRuntimeInfoStub; + Tizen::Base::Runtime::Mutex __Mutex; +}; // _RuntimeInfoStub + +}} // Tizen::System + +#endif // _FSYS_RUNTIME_INFO_STUB_H_ diff --git a/src/system/FSys_SettingService.cpp b/src/system/FSys_SettingService.cpp new file mode 100644 index 0000000..1be84e5 --- /dev/null +++ b/src/system/FSys_SettingService.cpp @@ -0,0 +1,552 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_SettingService.cpp + * @brief This is the implementation file for _SettingService class. + */ + +#include + +#include +#include +#include + +#include +#include +#include + +#include "FSys_SettingService.h" + +using namespace std; +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; +using namespace Tizen::Security; + +namespace Tizen { namespace System { + +const static wchar_t* SETTING_SERVICE_ID = L"osp.sys.ipcserver.setting_service"; + +const static wchar_t* SETTING_SERVICE_COMMAND_GET_BOOL = L"osp.sys.ipcserver.setting_service.command.get.bool"; +const static wchar_t* SETTING_SERVICE_COMMAND_GET_INT = L"osp.sys.ipcserver.setting_service.command.get.int"; +const static wchar_t* SETTING_SERVICE_COMMAND_GET_STRING = L"osp.sys.ipcserver.setting_service.command.get.string"; +const static wchar_t* SETTING_SERVICE_COMMAND_SET_BOOL = L"osp.sys.ipcserver.setting_service.command.set.bool"; +const static wchar_t* SETTING_SERVICE_COMMAND_SET_INT = L"osp.sys.ipcserver.setting_service.command.set.int"; +const static wchar_t* SETTING_SERVICE_COMMAND_SET_STRING = L"osp.sys.ipcserver.setting_service.command.set.string"; +const static wchar_t* SETTING_SERVICE_COMMAND_SET_PRIV_BOOL = L"osp.sys.ipcserver.setting_service.command.set.priv.bool"; +const static wchar_t* SETTING_SERVICE_COMMAND_SET_PRIV_STRING = L"osp.sys.ipcserver.setting_service.command.set.priv.string"; +const static wchar_t* SETTING_SERVICE_COMMAND_SET_ASYNC_BOOL = L"osp.sys.ipcserver.setting_service.command.set.async.bool"; +const static wchar_t* SETTING_SERVICE_COMMAND_SET_PRIV_ASYNC_BOOL = L"osp.sys.ipcserver.setting_service.command.set.priv.async.bool"; +const static wchar_t* SETTING_SERVICE_COMMAND_RESULT = L"osp.sys.ipcserver.setting_service.command.result"; + +const static wchar_t* SETTING_SERVICE_COMMAND_SUBSCRIBE = L"osp.sys.ipcserver.setting_service.command.subscribe"; +const static wchar_t* SETTING_SERVICE_COMMAND_UNSUBSCRIBE = L"osp.sys.ipcserver.setting_service.command.unsubscribe"; +const static wchar_t* SETTING_SERVICE_COMMAND_EVENT = L"osp.sys.ipcserver.setting_service.command.event"; + +const static wchar_t* SETTING_SERVICE_COMMAND_SUPPORTED = L"osp.sys.ipcserver.setting_service.command.supported"; + +const static wchar_t* SETTING_SERVICE_COMMAND_SUBSCRIBE_INTERNAL = L"osp.sys.ipcserver.setting_service.command.subscribe.internal"; +const static wchar_t* SETTING_SERVICE_COMMAND_UNSUBSCRIBE_INTERNAL = L"osp.sys.ipcserver.setting_service.command.unsubscribe.internal"; +const static wchar_t* SETTING_SERVICE_COMMAND_EVENT_INTERNAL = L"osp.sys.ipcserver.setting_service.command.event.internal"; + +const static int SETTING_SERVICE_IPC_MSG_COMMAND = 0; +const static int SETTING_SERVICE_IPC_MSG_KEY = 1; +const static int SETTING_SERVICE_IPC_MSG_VALUE = 2; + +const static wchar_t* _SETTINGS_KEY_FONT_SIZE = L"http://tizen.org/setting/font.size"; +const static wchar_t* _SETTINGS_KEY_FONT_TYPE = L"http://tizen.org/setting/font.type"; +const static wchar_t* _SETTINGS_KEY_LOCALE_COUNTRY = L"http://tizen.org/setting/locale.country"; +const static wchar_t* _SETTINGS_KEY_LOCALE_LANGUAGE = L"http://tizen.org/setting/locale.language"; + +_SettingService* _SettingService::__pSettingService = null; + +_SettingService::_SettingService() + : __serviceId(SETTING_SERVICE_ID) + , __pSettingInfo(null) + , __asyncList(SingleObjectDeleter) + , __eventList(SingleObjectDeleter) + , __eventListForInternal(SingleObjectDeleter) +{ +} + +_SettingService::~_SettingService() +{ + __pSettingInfo->RemoveSettingEventListener(*this); + __pSettingInfo = null; + result r = __ipcServer.Stop(); + __responseMessage.RemoveAll(true); + SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, r, "It is failed to stop IPC server."); +} + + +result +_SettingService::Construct(void) +{ + result r = E_SUCCESS; + + r = __ipcServer.Construct(__serviceId, *this, true); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to construct IPC server."); + + __pSettingInfo = _SettingInfo::GetInstance(); + SysTryCatch(NID_SYS, __pSettingInfo != null, r = E_SYSTEM, E_SYSTEM, "It is failed to get instance of _SettingInfo."); + + __pSettingInfo->AddSettingEventListener(*this); + r = __asyncList.Construct(); + SysTryCatch(NID_SYS, r == E_SUCCESS, , r, "It is failed to construct async list."); + + r = __eventList.Construct(); + SysTryCatch(NID_SYS, r == E_SUCCESS, , r, "It is failed to construct event list."); + + r = __eventListForInternal.Construct(); + SysTryCatch(NID_SYS, r == E_SUCCESS, , r, "It is failed to construct event list for internal."); + + r = __ipcServer.Start(); + SysTryCatch(NID_SYS, r == E_SUCCESS, , r, "It is failed to start IPC server."); + + r = __responseMessage.Construct(); + SysTryCatch(NID_SYS, r == E_SUCCESS, , r, "It is failed to create response message container."); + +CATCH: + if(r != E_SUCCESS) + { + if (__pSettingInfo != null) + { + __pSettingInfo->RemoveSettingEventListener(*this); + __pSettingInfo = null; + } + SysLogException(NID_SYS, r, "It is failed to construct _SettingService."); + __ipcServer.Stop(); + } + return r; +} + + +_SettingService* +_SettingService::GetInstance(void) +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + if(__pSettingService == null) + { + pthread_once(&onceBlock, InitSingleton); + } + return __pSettingService; +} + +void +_SettingService::InitSingleton(void) +{ + std::unique_ptr<_SettingService> pSettingService(new (nothrow) _SettingService()); + SysTryReturnVoidResult(NID_SYS, pSettingService != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + result r = pSettingService->Construct(); + SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, r, "It is failed to init Setting service [%s].", GetErrorMessage(r)); + __pSettingService = pSettingService.release(); + atexit(DestroySingleton); +} + +void +_SettingService::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message) +{ + __currentPkgId = server.GetClientPackageId(); + __currentPid = server.GetClientId(); + IPC_BEGIN_MESSAGE_MAP(_SettingService, message) + IPC_MESSAGE_HANDLER_EX(IoService_Request, &server, OnRequestOccured) + IPC_END_MESSAGE_MAP_EX() +} + +bool +_SettingService::OnRequestOccured(const ArrayList& request, ArrayList* response) +{ + result r = E_SUCCESS; + String* pCommand = null; + String* pKey = null; + String* pValue = null; + + SysTryCatch(NID_SYS, response != null, r = E_SYSTEM, r, "There is no response instance."); + + __responseMessage.RemoveAll(true); + pCommand = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_COMMAND); + SysTryCatch(NID_SYS, pCommand != null, r = E_SYSTEM, r, "There is no command information."); + + SysLog(NID_SYS, "Required command is [%ls].", pCommand->GetPointer()); + + if(*pCommand == SETTING_SERVICE_COMMAND_GET_INT) + { + int value = 0; + + pKey = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_KEY); + SysTryCatch(NID_SYS, pKey != null, r = E_SYSTEM, r, "There is no key information."); + r = __pSettingInfo->GetValue(*pKey, value); + pValue = new (nothrow) String(); + SysTryCatch(NID_SYS, pValue != null, r = E_SYSTEM, r, "It is failed to create pValue."); + pValue->Append(value); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_GET_BOOL) + { + bool value = false; + + pKey = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_KEY); + SysTryCatch(NID_SYS, pKey != null, r = E_SYSTEM, r, "There is no key information."); + r = __pSettingInfo->GetValue(*pKey, value); + pValue = new (nothrow) String(); + SysTryCatch(NID_SYS, pValue != null, r = E_SYSTEM, r, "It is failed to create pValue."); + pValue->Append(value); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_GET_STRING) + { + String value; + + pKey = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_KEY); + SysTryCatch(NID_SYS, pKey != null, r = E_SYSTEM, r, "There is no key information."); + r = __pSettingInfo->GetValue(*pKey, value); + pValue = new (nothrow) String(value); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_SET_INT) + { + int value = 0; + + r = _AccessController::CheckSystemPrivilege(__currentPkgId, _PRV_SETTING); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, r, "The application[%ls] does not have the privilege to call this method.", __currentPkgId.GetPointer()); + + pKey = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_KEY); + SysTryCatch(NID_SYS, pKey != null, r = E_SYSTEM, r, "There is no key information."); + pValue = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_VALUE); + Integer::Parse(*pValue, value); + r = __pSettingInfo->SetValue(*pKey, value); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_SET_BOOL) + { + bool value = false; + + r = _AccessController::CheckSystemPrivilege(__currentPkgId, _PRV_SETTING); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, r, "The application[%ls] does not have the privilege to call this method.", __currentPkgId.GetPointer()); + + pKey = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_KEY); + SysTryCatch(NID_SYS, pKey != null, r = E_SYSTEM, r, "There is no key information."); + pValue = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_VALUE); + value = Boolean::Parse(*pValue); + r = __pSettingInfo->SetValue(*pKey, value); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_SET_STRING) + { + + r = _AccessController::CheckSystemPrivilege(__currentPkgId, _PRV_SETTING); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, r, "The application[%ls] does not have the privilege to call this method.", __currentPkgId.GetPointer()); + + pKey = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_KEY); + SysTryCatch(NID_SYS, pKey != null, r = E_SYSTEM, r, "There is no key information."); + pValue = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_VALUE); + r = __pSettingInfo->SetValue(*pKey, *pValue); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_SET_PRIV_BOOL) + { + bool value = false; + + r = _AccessController::CheckSystemPrivilege(__currentPkgId, _PRV_SYSTEMSETTING_WRITE, _PRV_SETTINGMANAGER_WRITE); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, r, "The application[%ls] does not have the privilege to call this method.", __currentPkgId.GetPointer()); + + pKey = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_KEY); + SysTryCatch(NID_SYS, pKey != null, r = E_SYSTEM, r, "There is no key information."); + pValue = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_VALUE); + value = Boolean::Parse(*pValue); + r = __pSettingInfo->SetValueForPrivilegedKey(*pKey, value); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_SET_PRIV_STRING) + { + r = _AccessController::CheckSystemPrivilege(__currentPkgId, _PRV_SYSTEMSETTING_WRITE, _PRV_SETTINGMANAGER_WRITE); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, r, "The application[%ls] does not have the privilege to call this method.", __currentPkgId.GetPointer()); + + pKey = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_KEY); + SysTryCatch(NID_SYS, pKey != null, r = E_SYSTEM, r, "There is no key information."); + pValue = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_VALUE); + r = __pSettingInfo->SetValueForPrivilegedKey(*pKey, *pValue); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_SET_ASYNC_BOOL) + { + bool value = false; + + r = _AccessController::CheckSystemPrivilege(__currentPkgId, _PRV_SETTING); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, r, "The application[%ls] does not have the privilege to call this method.", __currentPkgId.GetPointer()); + + pKey = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_KEY); + SysTryCatch(NID_SYS, pKey != null, r = E_SYSTEM, r, "There is no key information."); + pValue = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_VALUE); + + SysLog(NID_SYS, "Key is %ls, Value is %ls, pid is %d.", pKey->GetPointer(), pValue->GetPointer(), __currentPid); + if(*pValue == L"true") + { + value = true; + } + else + { + value = false; + } + unique_ptr reservedKey(new (nothrow)String(*pKey)); + SysTryCatch(NID_SYS, __asyncList.ContainsKey(*(reservedKey.get())) == false, r = E_IN_PROGRESS, r, "Required key(%ls) is already under processing.", pKey->GetPointer()); + unique_ptr reservedPid(new (nothrow)Integer(__currentPid)); + + r = __asyncList.Add(reservedKey.get(), reservedPid.get()); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to add aync list."); + reservedPid.release(); + reservedKey.release(); + + r = __pSettingInfo->SetValueAsync(*pKey, value, this); + if(r != E_SUCCESS) + { + __asyncList.Remove(*pKey); + } + SysLog(NID_SYS, "Result is %s.", GetErrorMessage(r)); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_SET_PRIV_ASYNC_BOOL) + { + bool value = false; + r = _AccessController::CheckSystemPrivilege(__currentPkgId, _PRV_SYSTEMSETTING_WRITE, _PRV_SETTINGMANAGER_WRITE); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_PRIVILEGE_DENIED, r, "The application[%ls] does not have the privilege to call this method.", __currentPkgId.GetPointer()); + + pKey = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_KEY); + SysTryCatch(NID_SYS, pKey != null, r = E_SYSTEM, r, "There is no key information."); + pValue = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_VALUE); + + SysLog(NID_SYS, "Key is %ls, Value is %ls, pid is %d.", pKey->GetPointer(), pValue->GetPointer(), __currentPid); + if(*pValue == L"true") + { + value = true; + } + else + { + value = false; + } + + unique_ptr reservedKey(new (nothrow)String(*pKey)); + SysTryCatch(NID_SYS, __asyncList.ContainsKey(*(reservedKey.get())) == false, r = E_IN_PROGRESS, r, "Required key(%ls) is already under processing.", pKey->GetPointer()); + unique_ptr reservedPid(new (nothrow)Integer(__currentPid)); + + r = __asyncList.Add(reservedKey.get(), reservedPid.get()); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to add aync list."); + reservedPid.release(); + reservedKey.release(); + + r = __pSettingInfo->SetValueAsyncForPrivilegedKey(*pKey, value, this); + if(r != E_SUCCESS) + { + __asyncList.Remove(*pKey); + } + SysLog(NID_SYS, "Result is %s.", GetErrorMessage(r)); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_SUBSCRIBE) + { + unique_ptr pid(new (nothrow) Integer(__currentPid)); + + SysTryCatch(NID_SYS, __eventList.Contains(*(pid.get())) == false, r = E_OBJ_ALREADY_EXIST, r, "Required application(%ls, %d) is already subscribe event.", __currentPkgId.GetPointer(), __currentPid); + r = __eventList.Add(pid.get()); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to add application(%ls, %d) on event list", __currentPkgId.GetPointer(), __currentPid); + pid.release(); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_UNSUBSCRIBE) + { + unique_ptr pid(new (nothrow) Integer(__currentPid)); + + SysTryCatch(NID_SYS, __eventList.Contains(*(pid.get())) == true, r = E_OBJ_NOT_FOUND, r, "Required application(%ls, %d) is not subscribe event.", __currentPkgId.GetPointer(), __currentPid); + r = __eventList.Remove(*(pid.get()), true); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to remove application(%ls, %d) on event list", __currentPkgId.GetPointer(), __currentPid); + pid.release(); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_SUPPORTED) + { + bool value = false; + + pKey = (String*)request.GetAt(SETTING_SERVICE_IPC_MSG_KEY); + SysTryCatch(NID_SYS, pKey != null, r = E_SYSTEM, r, "There is no key information."); + value = __pSettingInfo->HasKey(*pKey); + SysLog(NID_SYS, "%ls is %d.", pKey->GetPointer(), value); + pValue = new (nothrow) String(); + SysTryCatch(NID_SYS, pValue != null, r = E_SYSTEM, r, "It is failed to create pValue."); + pValue->Append(value); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_SUBSCRIBE_INTERNAL) + { + unique_ptr pid(new (nothrow) Integer(__currentPid)); + + SysTryCatch(NID_SYS, __eventListForInternal.Contains(*(pid.get())) == false, r = E_OBJ_ALREADY_EXIST, r, "Required application(%ls, %d) is already subscribe event.", __currentPkgId.GetPointer(), __currentPid); + r = __eventListForInternal.Add(pid.get()); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to add application(%ls, %d) on event list", __currentPkgId.GetPointer(), __currentPid); + pid.release(); + } + else if(*pCommand == SETTING_SERVICE_COMMAND_UNSUBSCRIBE_INTERNAL) + { + unique_ptr pid(new (nothrow) Integer(__currentPid)); + + SysTryCatch(NID_SYS, __eventListForInternal.Contains(*(pid.get())) == true, r = E_OBJ_NOT_FOUND, r, "Required application(%ls, %d) is not subscribe event.", __currentPkgId.GetPointer(), __currentPid); + r = __eventListForInternal.Remove(*(pid.get()), true); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to remove application(%ls, %d) on event list", __currentPkgId.GetPointer(), __currentPid); + pid.release(); + } + else + { + return false; + } + +CATCH: + if(response != null) + { + String* pCommandCode = new (nothrow) String(*pCommand); + String* pResultCode = new (nothrow) String(GetErrorMessage(r)); + + SysLog(NID_SYS, "Command Code is %ls.", pCommandCode->GetPointer()); + SysLog(NID_SYS, "Result Code is %ls.", pResultCode->GetPointer()); + + response->Add(pCommandCode); + response->Add(pResultCode); + if(pValue != null) + { + SysLog(NID_SYS, "Value is %ls.", pValue->GetPointer()); + response->Add(pValue); + } + + __responseMessage.AddItems(*response); + } + else + { + SysLog(NID_SYS, "response is empty."); + } + + return true; +} + +void +_SettingService::OnResultReceivedForSetValueAsync(const String& key, result rCode) +{ + SysLog(NID_SYS, "Key is %ls, result is %s.", key.GetPointer(), GetErrorMessage(rCode)); + Integer* pid = (Integer*) __asyncList.GetValue(key); + ArrayList* pData = null; + result r = E_SUCCESS; + String cmdCode(SETTING_SERVICE_COMMAND_RESULT); + String keyCode; + String resultCode; + + SysTryCatch(NID_SYS, pid != null, r = E_SYSTEM, r, "Required key(%ls) is not reserved.", key.GetPointer()); + pData = new (nothrow) ArrayList; + pData->Construct(); + keyCode.Append(key); + resultCode.Append(GetErrorMessage(rCode)); + pData->Add(cmdCode); + pData->Add(keyCode); + pData->Add(resultCode); + + r = __ipcServer.SendResponse(pid->value, new (nothrow) IoService_Data(*pData)); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "It is failed to send result to %d.", pid->value); + +CATCH: + __asyncList.Remove(key, true); + + if(pData != null) + { + delete pData; + } +} + +void +_SettingService::OnSettingChanged(Tizen::Base::String& key) +{ + result r = E_SUCCESS; + IEnumerator* pEnum = null; + + if(key == _SETTINGS_KEY_FONT_SIZE || key == _SETTINGS_KEY_FONT_TYPE + || key == _SETTINGS_KEY_LOCALE_COUNTRY || key == _SETTINGS_KEY_LOCALE_LANGUAGE) + { + pEnum = __eventListForInternal.GetEnumeratorN(); + + while(pEnum->MoveNext() == E_SUCCESS) + { + Integer* pid = (Integer*) pEnum->GetCurrent(); + + ArrayList data; + data.Construct(); + String cmdCode(SETTING_SERVICE_COMMAND_EVENT_INTERNAL); + String keyCode(key); + data.Add(cmdCode); + data.Add(keyCode); + + r = __ipcServer.SendResponse(pid->value, new (nothrow) IoService_Data(data)); + SysLog(NID_SYS, "Internal setting event is delivered to %d. result is %s.", pid->value, GetErrorMessage(r)); + } + delete pEnum; + } + + pEnum = __eventList.GetEnumeratorN(); + while(pEnum->MoveNext() == E_SUCCESS) + { + Integer* pid = (Integer*) pEnum->GetCurrent(); + + ArrayList data; + data.Construct(); + String cmdCode(SETTING_SERVICE_COMMAND_EVENT); + String keyCode(key); + data.Add(cmdCode); + data.Add(keyCode); + + r = __ipcServer.SendResponse(pid->value, new (nothrow) IoService_Data(data)); + SysLog(NID_SYS, "Setting event is delivered to %d. result is %s.", pid->value, GetErrorMessage(r)); + } + + delete pEnum; +} + +void +_SettingService::OnIpcServerStarted(const _IpcServer& server) +{ +} + +void +_SettingService::OnIpcServerStopped(const _IpcServer& server) +{ +} + +void +_SettingService::OnIpcClientConnected(const _IpcServer& server, int clientId) +{ +} + +void +_SettingService::OnIpcClientDisconnected(const _IpcServer&server, int clientId) +{ +} + +void +_SettingService::OnApplicationLaunched(const AppId& appId, int pid) +{ +} + +void +_SettingService::OnApplicationTerminated(const AppId& appId, int pid) +{ + Integer reservedKey(pid); + result r = __eventList.Remove(reservedKey, true); + SysLog(NID_SYS, "Application(%d) is terminated and unsubscribe result is %s.", pid, GetErrorMessage(r)); + r = __eventListForInternal.Remove(reservedKey, true); + SysLog(NID_SYS, "unsubscribe result is %s on internal event.", GetErrorMessage(r)); +} + +void +_SettingService::DestroySingleton(void) +{ + delete __pSettingService; + __pSettingService = null; +} + +}} + diff --git a/src/system/FSys_SettingService.h b/src/system/FSys_SettingService.h new file mode 100644 index 0000000..2508017 --- /dev/null +++ b/src/system/FSys_SettingService.h @@ -0,0 +1,90 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_SettingService.h + * @brief This is the header file of the _SettingService class. + * + * This header file contains the declarations of the _SettingService class. + */ + + +#ifndef _FSYS_SETTING_SERVICE_INTERNAL_H_ +#define _FSYS_SETTING_SERVICE_INTERNAL_H_ + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +namespace Tizen { namespace System +{ + +class _SettingService + : public Tizen::Base::Object + , public Tizen::App::_IAppEventListener + , public Tizen::Io::_IIpcServerEventListener + , public Tizen::System::ISettingInfoSetValueAsyncResultListener + , public Tizen::System::ISettingEventListener +{ +private: + static void InitSingleton(void); + static void DestroySingleton(void); + +public: + _SettingService(); + ~_SettingService(); + result Construct(void); + static _SettingService* GetInstance(void); + +private: + bool OnRequestOccured(const Tizen::Base::Collection::ArrayList& request, Tizen::Base::Collection::ArrayList* response); + void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message); + void OnIpcServerStarted(const Tizen::Io::_IpcServer& server); + void OnIpcServerStopped(const Tizen::Io::_IpcServer& server); + void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId); + void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId); + + void OnApplicationLaunched(const Tizen::App::AppId& appId, int pid); + void OnApplicationTerminated(const Tizen::App::AppId& appId, int pid); + + void OnResultReceivedForSetValueAsync(const Tizen::Base::String& key, result r); + void OnSettingChanged(Tizen::Base::String& key); + +private: + static _SettingService* __pSettingService; + Tizen::Io::_IpcServer __ipcServer; + Tizen::Base::String __serviceId; + _SettingInfo* __pSettingInfo; + Tizen::Base::Collection::HashMap __asyncList; + Tizen::Base::Collection::ArrayList __eventList; + Tizen::Base::Collection::ArrayList __eventListForInternal; + Tizen::Base::Collection::ArrayList __responseMessage; + + Tizen::App::AppId __currentPkgId; + int __currentPid; +}; + +}} +#endif diff --git a/src/system/FSys_SystemInfoService.cpp b/src/system/FSys_SystemInfoService.cpp new file mode 100644 index 0000000..5a35341 --- /dev/null +++ b/src/system/FSys_SystemInfoService.cpp @@ -0,0 +1,2818 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_SystemInfoService.cpp + * @brief This is the implementation file for _SystemInfoService class. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace Tizen::App; +using namespace Tizen::App::Package; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Utility; +using namespace Tizen::Io; + +namespace Tizen { namespace System +{ +//Camera +static const wchar_t* _CAMERA = L"http://tizen.org/feature/camera"; +static const wchar_t* _CAMERA_BACK = L"http://tizen.org/feature/camera.back"; +static const wchar_t* _CAMERA_BACK_FLASH = L"http://tizen.org/feature/camera.back.flash"; +static const wchar_t* _CAMERA_FRONT = L"http://tizen.org/feature/camera.front"; +static const wchar_t* _CAMERA_FRONT_FLASH = L"http://tizen.org/feature/camera.front.flash"; +//Database +static const wchar_t* _DATABASE_ENCRYPTION = L"http://tizen.org/feature/database.encryption"; +//FM Radio +static const wchar_t* _FMRADIO = L"http://tizen.org/feature/fmradio"; +//Graphic +static const wchar_t* _GRAPHIC_ACCELERATION = L"http://tizen.org/feature/graphics.acceleration"; +//Input +static const wchar_t* _INPUT_KEYBOARD = L"http://tizen.org/feature/input.keyboard"; +static const wchar_t* _INPUT_KEYBOARD_LAYOUT = L"http://tizen.org/feature/input.keyboard.layout"; +//Location +static const wchar_t* _LOCATION = L"http://tizen.org/feature/location"; +static const wchar_t* _LOCATION_GPS = L"http://tizen.org/feature/location.gps"; +static const wchar_t* _LOCATION_WPS = L"http://tizen.org/feature/location.wps"; +//Microphone +static const wchar_t* _MICROPHONE = L"http://tizen.org/feature/microphone"; +//Multi point +static const wchar_t* _MULTIPOINTTOUCH_PINCHZOOM = L"http://tizen.org/feature/multi_point_touch.pinch_zoom"; +static const wchar_t* _MULTIPOINTTOUCH_POINTCOUNT = L"http://tizen.org/feature/multi_point_touch.point_count"; +//Network bluetooth +static const wchar_t* _NETWORK_BLUETOOTH = L"http://tizen.org/feature/network.bluetooth"; +//Network NFC +static const wchar_t* _NETWORK_NFC = L"http://tizen.org/feature/network.nfc"; +static const wchar_t* _NETWORK_NFC_RESERVED_PUSH = L"http://tizen.org/feature/network.nfc.reserved_push"; +//Network push +static const wchar_t* _NETWORK_PUSH = L"http://tizen.org/feature/network.push"; +static const wchar_t* _NETWORK_SECURE_ELEMENT = L"http://tizen.org/feature/network.secure_element"; +//Network telephony +static const wchar_t* _NETWORK_TELEPHONY = L"http://tizen.org/feature/network.telephony"; +static const wchar_t* _NETWORK_TELEPHONY_MMS = L"http://tizen.org/feature/network.telephony.mms"; +static const wchar_t* _NETWORK_TELEPHONY_SMS = L"http://tizen.org/feature/network.telephony.sms"; +static const wchar_t* _NETWORK_TELEPHONY_SMS_CBS = L"http://tizen.org/feature/network.telephony.sms.cbs"; +static const wchar_t* _NETWORK_TELEPHONY_SERVICE_CDMA = L"http://tizen.org/feature/network.telephony.service.cdma"; +static const wchar_t* _NETWORK_TELEPHONY_SERVICE_EDGE = L"http://tizen.org/feature/network.telephony.service.edge"; +static const wchar_t* _NETWORK_TELEPHONY_SERVICE_GPRS = L"http://tizen.org/feature/network.telephony.service.gprs"; +static const wchar_t* _NETWORK_TELEPHONY_SERVICE_GSM = L"http://tizen.org/feature/network.telephony.service.gsm"; +static const wchar_t* _NETWORK_TELEPHONY_SERVICE_HSDPA = L"http://tizen.org/feature/network.telephony.service.hsdpa"; +static const wchar_t* _NETWORK_TELEPHONY_SERVICE_HSPA = L"http://tizen.org/feature/network.telephony.service.hspa"; +static const wchar_t* _NETWORK_TELEPHONY_SERVICE_HSUPA = L"http://tizen.org/feature/network.telephony.service.hsupa"; +static const wchar_t* _NETWORK_TELEPHONY_SERVICE_LTE = L"http://tizen.org/feature/network.telephony.service.lte"; +static const wchar_t* _NETWORK_TELEPHONY_SERVICE_UMTS = L"http://tizen.org/feature/network.telephony.service.umts"; +//Network WIFI +static const wchar_t* _NETWORK_WIFI = L"http://tizen.org/feature/network.wifi"; +static const wchar_t* _NETWORK_WIFI_DIRECT = L"http://tizen.org/feature/network.wifi.direct"; +//Opengles +static const wchar_t* _OPENGLES = L"http://tizen.org/feature/opengles"; +static const wchar_t* _OPENGLES_TEXTUREFORMAT_3DC = L"http://tizen.org/feature/opengles.texture_format.3dc"; +static const wchar_t* _OPENGLES_TEXTUREFORMAT_ATC = L"http://tizen.org/feature/opengles.texture_format.atc"; +static const wchar_t* _OPENGLES_TEXTUREFORMAT_ETC = L"http://tizen.org/feature/opengles.texture_format.etc"; +static const wchar_t* _OPENGLES_TEXTUREFORMAT_PTC = L"http://tizen.org/feature/opengles.texture_format.ptc"; +static const wchar_t* _OPENGLES_TEXTUREFORMAT_PVRTC = L"http://tizen.org/feature/opengles.texture_format.pvrtc"; +static const wchar_t* _OPENGLES_TEXTUREFORMAT_UTC = L"http://tizen.org/feature/opengles.texture_format.utc"; +static const wchar_t* _OPENGLES_VERSION_1_1 = L"http://tizen.org/feature/opengles.version.1_1"; +static const wchar_t* _OPENGLES_VERSION_2_0 = L"http://tizen.org/feature/opengles.version.2_0"; +//Platform core CPU +static const wchar_t* _PLATFORM_CORE_CPU_ARCH_ARMV6 = L"http://tizen.org/feature/platform.core.cpu.arch.armv6"; +static const wchar_t* _PLATFORM_CORE_CPU_ARCH_ARMV7 = L"http://tizen.org/feature/platform.core.cpu.arch.armv7"; +static const wchar_t* _PLATFORM_CORE_CPU_ARCH_X86 = L"http://tizen.org/feature/platform.core.cpu.arch.x86"; +//Platform core FPU +static const wchar_t* _PLATFORM_CORE_FPU_ARCH_SSE2 = L"http://tizen.org/feature/platform.core.fpu.arch.sse2"; +static const wchar_t* _PLATFORM_CORE_FPU_ARCH_SSE3 = L"http://tizen.org/feature/platform.core.fpu.arch.sse3"; +static const wchar_t* _PLATFORM_CORE_FPU_ARCH_SSSE3 = L"http://tizen.org/feature/platform.core.fpu.arch.ssse3"; +static const wchar_t* _PLATFORM_CORE_FPU_ARCH_VFPV2 = L"http://tizen.org/feature/platform.core.fpu.arch.vfpv2"; +static const wchar_t* _PLATFORM_CORE_FPU_ARCH_VFPV3 = L"http://tizen.org/feature/platform.core.fpu.arch.vfpv3"; +//Platform Version +static const wchar_t* _PLATFORM_NATIVE_API_VERSION = L"http://tizen.org/feature/platform.native.api.version"; +static const wchar_t* _PLATFORM_NATIVE_OSP_COMPATIBLE = L"http://tizen.org/feature/platform.native.osp_compatible"; +static const wchar_t* _PLATFORM_VERSION = L"http://tizen.org/feature/platform.version"; +static const wchar_t* _PLATFORM_WEB_API_VERSION = L"http://tizen.org/feature/platform.web.api.version"; +//Screen +static const wchar_t* _SCREEN_AUTO_ROTATION = L"http://tizen.org/feature/screen.auto_rotation"; +static const wchar_t* _SCREEN_BPP = L"http://tizen.org/feature/screen.bpp"; +static const wchar_t* _SCREEN_COORDINATE_SYSTEM_SIZE_LARGE = L"http://tizen.org/feature/screen.coordinate_system.size.large"; +static const wchar_t* _SCREEN_COORDINATE_SYSTEM_SIZE_NORMAL = L"http://tizen.org/feature/screen.coordinate_system.size.normal"; +static const wchar_t* _SCREEN_DESKTOPMODE = L"http://tizen.org/feature/screen.desktop_mode"; +static const wchar_t* _SCREEN_DPI = L"http://tizen.org/feature/screen.dpi"; +static const wchar_t* _SCREEN_HEIGHT = L"http://tizen.org/feature/screen.height"; +static const wchar_t* _SCREEN_SIZE_LARGE = L"http://tizen.org/feature/screen.size.large"; +static const wchar_t* _SCREEN_SIZE_NORMAL = L"http://tizen.org/feature/screen.size.normal"; +static const wchar_t* _SCREEN_SIZE_NORMAL_240_400 = L"http://tizen.org/feature/screen.size.normal.240.400"; +static const wchar_t* _SCREEN_SIZE_NORMAL_320_480 = L"http://tizen.org/feature/screen.size.normal.320.480"; +static const wchar_t* _SCREEN_SIZE_NORMAL_480_800 = L"http://tizen.org/feature/screen.size.normal.480.800"; +static const wchar_t* _SCREEN_SIZE_NORMAL_540_960 = L"http://tizen.org/feature/screen.size.normal.540.960"; +static const wchar_t* _SCREEN_SIZE_NORMAL_600_1024 = L"http://tizen.org/feature/screen.size.normal.600.1024"; +static const wchar_t* _SCREEN_SIZE_NORMAL_720_1280 = L"http://tizen.org/feature/screen.size.normal.720.1280"; +static const wchar_t* _SCREEN_SIZE_NORMAL_1080_1920 = L"http://tizen.org/feature/screen.size.normal.1080.1920"; +static const wchar_t* _SCREEN_WIDTH = L"http://tizen.org/feature/screen.width"; +//Screen HDMI RCA +static const wchar_t* _SCREEN_OUTPUT_HDMI = L"http://tizen.org/feature/screen.output.hdmi"; +static const wchar_t* _SCREEN_OUTPUT_RCA = L"http://tizen.org/feature/screen.output.rca"; +//Shell +static const wchar_t* _SHELL_APPWIDGET = L"http://tizen.org/feature/shell.appwidget"; +//Sensor +static const wchar_t* _SENSOR_ACCELEROMETER = L"http://tizen.org/feature/sensor.accelerometer"; +static const wchar_t* _SENSOR_ACCELEROMETER_WAKEUP = L"http://tizen.org/feature/sensor.accelerometer.wakeup"; +static const wchar_t* _SENSOR_BAROMETER = L"http://tizen.org/feature/sensor.barometer"; +static const wchar_t* _SENSOR_BAROMETER_WAKEUP = L"http://tizen.org/feature/sensor.barometer.wakeup"; +static const wchar_t* _SENSOR_GYROSCOPE = L"http://tizen.org/feature/sensor.gyroscope"; +static const wchar_t* _SENSOR_GYROSCOPE_WAKEUP = L"http://tizen.org/feature/sensor.gyroscope.wakeup"; +static const wchar_t* _SENSOR_MAGNETOMETER = L"http://tizen.org/feature/sensor.magnetometer"; +static const wchar_t* _SENSOR_MAGNETOMETER_WAKEUP = L"http://tizen.org/feature/sensor.magnetometer.wakeup"; +static const wchar_t* _SENSOR_PHOTOMETER = L"http://tizen.org/feature/sensor.photometer"; +static const wchar_t* _SENSOR_PHOTOMETER_WAKEUP = L"http://tizen.org/feature/sensor.photometer.wakeup"; +static const wchar_t* _SENSOR_PROXIMITY = L"http://tizen.org/feature/sensor.proximity"; +static const wchar_t* _SENSOR_PROXIMITY_WAKEUP = L"http://tizen.org/feature/sensor.proximity.wakeup"; +static const wchar_t* _SENSOR_TILTMETER = L"http://tizen.org/feature/sensor.tiltmeter"; +static const wchar_t* _SENSOR_TILTMETER_WAKEUP = L"http://tizen.org/feature/sensor.tiltmeter.wakeup"; +//SIP VOIP +static const wchar_t* _SIP_VOIP = L"http://tizen.org/feature/sip.voip"; +//Speech Recognition +static const wchar_t* _SPEECH_RECOGNITION = L"http://tizen.org/feature/speech.recognition"; +static const wchar_t* _SPEECH_SYNTHESIS = L"http://tizen.org/feature/speech.synthesis"; +//USB +static const wchar_t* _USB_ACCESSORY = L"http://tizen.org/feature/usb.accessory"; +static const wchar_t* _USB_CLIENT = L"http://tizen.org/feature/usb.client"; +static const wchar_t* _USB_HOST = L"http://tizen.org/feature/usb.host"; +//Vision +static const wchar_t* _VISION_FACE_RECOGNITION = L"http://tizen.org/feature/vision.face_recognition"; +static const wchar_t* _VISION_IMAGE_RECOGNITION = L"http://tizen.org/feature/vision.image_recognition"; +static const wchar_t* _VISION_QRCODE_GENERATION = L"http://tizen.org/feature/vision.qrcode_generation"; +static const wchar_t* _VISION_QRCODE_RECOGNITION = L"http://tizen.org/feature/vision.qrcode_recognition"; + +static const wchar_t* _BUILD_STRING = L"http://tizen.org/system/build.string"; +//DUID +static const wchar_t* _DUID = L"http://tizen.org/system/duid"; +//Model name +static const wchar_t* _MODELNAME = L"http://tizen.org/system/model_name"; +//Platform name +static const wchar_t* _PLATFORM_NAME = L"http://tizen.org/system/platform.name"; +//Sound +static const wchar_t* _SOUND_MEDIA_VOLUME_MAX = L"http://tizen.org/system/sound.media.volume.resolution.max"; +static const wchar_t* _SOUND_NOTIFICATION_VOLUME_MAX = L"http://tizen.org/system/sound.notification.volume.resolution.max"; +static const wchar_t* _SOUND_RINGTONE_VOLUME_MAX = L"http://tizen.org/system/sound.ringtone.volume.resolution.max"; +static const wchar_t* _SOUND_SYSTEM_VOLUME_MAX = L"http://tizen.org/system/sound.system.volume.resolution.max"; + + +//Communication + +static const wchar_t* _SYSTEM_CACHING_FILE = L"/opt/usr/etc/system_info_cache.ini"; +static const wchar_t* _SYSTEM_CACHING_SECTION = L"SystemInformation"; + +static const wchar_t* _SYSTEM_CACHING_TRUE = L"true"; +static const wchar_t* _SYSTEM_CACHING_FALSE = L"false"; + +_SystemInfoService* _SystemInfoService::__pSystemInfoService = null; + +_SystemInfoService::_SystemInfoService() +{ +} + +_SystemInfoService::~_SystemInfoService() +{ +} + +_SystemInfoService* +_SystemInfoService::GetInstance(void) +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + if(__pSystemInfoService == null) + { + pthread_once(&onceBlock, InitSingleton); + } + return __pSystemInfoService; +} + +void +_SystemInfoService::InitSingleton(void) +{ + _SystemInfoService* pSystemInfoService = new (nothrow) _SystemInfoService(); + SysTryReturnVoidResult(NID_SYS, pSystemInfoService != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __pSystemInfoService = pSystemInfoService; + atexit(DestroySingleton); +} + +void +_SystemInfoService::DestroySingleton(void) +{ + delete __pSystemInfoService; + __pSystemInfoService = null; +} + +result +_SystemInfoService::CreateCacheFile(void) +{ + Registry reg; + result r = E_SUCCESS; + String systemValue; + + r = reg.Construct(_SYSTEM_CACHING_FILE, "w+"); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to create the cache file."); + + r = reg.AddSection(_SYSTEM_CACHING_SECTION); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to create section on the cache file."); + + bool bValue = false; + int nValue = 0; + String sValue; + + //For improve launch performance + nValue = 0; + this->GetValue(_SCREEN_DPI, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_DPI, nValue); + reg.Flush(); + + nValue = 0; + this->GetValue(_SCREEN_HEIGHT, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_HEIGHT, nValue); + reg.Flush(); + + nValue = 0; + this->GetValue(_SCREEN_WIDTH, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_WIDTH, nValue); + reg.Flush(); + + this->GetValue(_CAMERA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _CAMERA, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_CAMERA_BACK, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _CAMERA_BACK, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_CAMERA_BACK_FLASH, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _CAMERA_BACK_FLASH, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_CAMERA_FRONT, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _CAMERA_FRONT, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_CAMERA_FRONT_FLASH, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _CAMERA_FRONT_FLASH, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_DATABASE_ENCRYPTION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _DATABASE_ENCRYPTION, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_FMRADIO, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _FMRADIO, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_GRAPHIC_ACCELERATION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _GRAPHIC_ACCELERATION, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_INPUT_KEYBOARD, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _INPUT_KEYBOARD, systemValue); + reg.Flush(); + + sValue.Clear(); + this->GetValue(_INPUT_KEYBOARD_LAYOUT, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _INPUT_KEYBOARD_LAYOUT, sValue); + reg.Flush(); + + this->GetValue(_LOCATION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _LOCATION, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_LOCATION_GPS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _LOCATION_GPS, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_LOCATION_WPS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _LOCATION_WPS, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_MICROPHONE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _MICROPHONE, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_MULTIPOINTTOUCH_PINCHZOOM, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _MULTIPOINTTOUCH_PINCHZOOM, systemValue); + reg.Flush(); + + nValue = 0; + this->GetValue(_MULTIPOINTTOUCH_POINTCOUNT, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _MULTIPOINTTOUCH_POINTCOUNT, nValue); + reg.Flush(); + + this->GetValue(_NETWORK_BLUETOOTH, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_BLUETOOTH, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_NFC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_NFC, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_NFC_RESERVED_PUSH, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_NFC_RESERVED_PUSH, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_PUSH, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_PUSH, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_SECURE_ELEMENT, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_SECURE_ELEMENT, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_MMS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_MMS, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SMS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SMS, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SMS_CBS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SMS_CBS, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_CDMA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_CDMA, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_EDGE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_EDGE, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_GPRS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_GPRS, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_GSM, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_GSM, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_HSDPA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_HSDPA, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_HSPA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_HSPA, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_HSUPA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_HSUPA, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_LTE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_LTE, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_UMTS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_UMTS, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_WIFI, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_WIFI, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_NETWORK_WIFI_DIRECT, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_WIFI_DIRECT, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_OPENGLES, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_3DC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_3DC, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_ATC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_ATC, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_ETC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_ETC, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_PTC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_PTC, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_PVRTC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_PVRTC, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_UTC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_UTC, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_OPENGLES_VERSION_1_1, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_VERSION_1_1, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_OPENGLES_VERSION_2_0, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_VERSION_2_0, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_PLATFORM_CORE_CPU_ARCH_ARMV6, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_CPU_ARCH_ARMV6, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_PLATFORM_CORE_CPU_ARCH_ARMV7, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_CPU_ARCH_ARMV7, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_PLATFORM_CORE_CPU_ARCH_X86, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_CPU_ARCH_X86, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_PLATFORM_CORE_FPU_ARCH_SSE2, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_SSE2, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_PLATFORM_CORE_FPU_ARCH_SSE3, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_SSE3, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_PLATFORM_CORE_FPU_ARCH_SSSE3, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_SSSE3, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_PLATFORM_CORE_FPU_ARCH_VFPV2, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_VFPV2, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_PLATFORM_CORE_FPU_ARCH_VFPV3, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_VFPV3, systemValue); + reg.Flush(); + + sValue.Clear(); + this->GetValue(_PLATFORM_NATIVE_API_VERSION, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_NATIVE_API_VERSION, sValue); + reg.Flush(); + + this->GetValue(_PLATFORM_NATIVE_OSP_COMPATIBLE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_NATIVE_OSP_COMPATIBLE, systemValue); + reg.Flush(); + + sValue.Clear(); + this->GetValue(_PLATFORM_VERSION, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_VERSION, sValue); + reg.Flush(); + + this->GetValue(_PLATFORM_WEB_API_VERSION, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_WEB_API_VERSION, sValue); + reg.Flush(); + + this->GetValue(_SCREEN_AUTO_ROTATION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_AUTO_ROTATION, systemValue); + reg.Flush(); + + nValue = 0; + this->GetValue(_SCREEN_BPP, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_BPP, nValue); + reg.Flush(); + + this->GetValue(_SCREEN_COORDINATE_SYSTEM_SIZE_LARGE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_COORDINATE_SYSTEM_SIZE_LARGE, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_COORDINATE_SYSTEM_SIZE_NORMAL, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_COORDINATE_SYSTEM_SIZE_NORMAL, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_DESKTOPMODE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_DESKTOPMODE, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_LARGE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_LARGE, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_240_400, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_240_400, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_320_480, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_320_480, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_480_800, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_480_800, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_540_960, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_540_960, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_600_1024, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_600_1024, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_720_1280, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_720_1280, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_1080_1920, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_1080_1920, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_OUTPUT_HDMI, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_OUTPUT_HDMI, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_OUTPUT_RCA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_OUTPUT_RCA, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SHELL_APPWIDGET, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SHELL_APPWIDGET, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_ACCELEROMETER, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_ACCELEROMETER, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_ACCELEROMETER_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_ACCELEROMETER_WAKEUP, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_BAROMETER, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_BAROMETER, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_BAROMETER_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_BAROMETER_WAKEUP, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_GYROSCOPE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_GYROSCOPE, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_GYROSCOPE_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_GYROSCOPE_WAKEUP, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_MAGNETOMETER, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_MAGNETOMETER, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_MAGNETOMETER_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_MAGNETOMETER_WAKEUP, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_PHOTOMETER, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_PHOTOMETER, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_PHOTOMETER_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_PHOTOMETER_WAKEUP, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_PROXIMITY, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_PROXIMITY, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_PROXIMITY_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_PROXIMITY_WAKEUP, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_TILTMETER, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_TILTMETER, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SENSOR_TILTMETER_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_TILTMETER_WAKEUP, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SIP_VOIP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SIP_VOIP, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SPEECH_RECOGNITION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SPEECH_RECOGNITION, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_SPEECH_SYNTHESIS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _SPEECH_SYNTHESIS, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_USB_ACCESSORY, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _USB_ACCESSORY, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_USB_CLIENT, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _USB_CLIENT, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_USB_HOST, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _USB_HOST, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_VISION_FACE_RECOGNITION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _VISION_FACE_RECOGNITION, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_VISION_IMAGE_RECOGNITION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _VISION_IMAGE_RECOGNITION, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_VISION_QRCODE_GENERATION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _VISION_QRCODE_GENERATION, systemValue); + reg.Flush(); + + bValue = false; + this->GetValue(_VISION_QRCODE_RECOGNITION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + reg.AddValue(_SYSTEM_CACHING_SECTION, _VISION_QRCODE_RECOGNITION, systemValue); + reg.Flush(); + + sValue.Clear(); + this->GetValue(_BUILD_STRING, sValue); + reg.Flush(); + reg.AddValue(_SYSTEM_CACHING_SECTION, _BUILD_STRING, sValue); + reg.Flush(); + + sValue.Clear(); + r = this->GetValue(_DUID, sValue); + if(r != E_SUCCESS) + { + sValue.Append(L"ERROR"); + } + reg.AddValue(_SYSTEM_CACHING_SECTION, _DUID, sValue); + reg.Flush(); + + sValue.Clear(); + this->GetValue(_MODELNAME, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _MODELNAME, sValue); + reg.Flush(); + + sValue.Clear(); + this->GetValue(_PLATFORM_NAME, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_NAME, sValue); + reg.Flush(); + + nValue = 0; + this->GetValue(_SOUND_MEDIA_VOLUME_MAX, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SOUND_MEDIA_VOLUME_MAX, nValue); + reg.Flush(); + + nValue = 0; + this->GetValue(_SOUND_NOTIFICATION_VOLUME_MAX, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SOUND_NOTIFICATION_VOLUME_MAX, nValue); + reg.Flush(); + + nValue = 0; + this->GetValue(_SOUND_RINGTONE_VOLUME_MAX, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SOUND_RINGTONE_VOLUME_MAX, nValue); + reg.Flush(); + + nValue = 0; + this->GetValue(_SOUND_SYSTEM_VOLUME_MAX, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SOUND_SYSTEM_VOLUME_MAX, nValue); + reg.Flush(); + + return E_SUCCESS; +} + +result +_SystemInfoService::UpdateCacheFile(void) +{ + Registry reg; + result r = E_SUCCESS; + String systemValue; + + r = reg.Construct(_SYSTEM_CACHING_FILE, "r+"); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, r, "It is failed to create the cache file."); + + bool bValue = false; + int nValue = 0; + String sValue; + + //For improve launch performance + nValue = 0; + this->GetValue(_SCREEN_DPI, nValue); + if (reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_DPI, nValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION,_SCREEN_DPI, nValue); + } + reg.Flush(); + + nValue = 0; + this->GetValue(_SCREEN_HEIGHT, nValue); + if(reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_HEIGHT, nValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _SCREEN_HEIGHT, nValue); + } + reg.Flush(); + + nValue = 0; + this->GetValue(_SCREEN_WIDTH, nValue); + if(reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_WIDTH, nValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _SCREEN_WIDTH, nValue); + } + reg.Flush(); + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _CAMERA, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_CAMERA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _CAMERA, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _CAMERA_BACK, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_CAMERA_BACK, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _CAMERA_BACK, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _CAMERA_BACK_FLASH, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_CAMERA_BACK_FLASH, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _CAMERA_BACK_FLASH, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _CAMERA_FRONT, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_CAMERA_FRONT, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _CAMERA_FRONT, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _CAMERA_FRONT_FLASH, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_CAMERA_FRONT_FLASH, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _CAMERA_FRONT_FLASH, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _DATABASE_ENCRYPTION, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_DATABASE_ENCRYPTION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _DATABASE_ENCRYPTION, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _FMRADIO, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_FMRADIO, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _FMRADIO, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _GRAPHIC_ACCELERATION, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_GRAPHIC_ACCELERATION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _GRAPHIC_ACCELERATION, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _INPUT_KEYBOARD, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_INPUT_KEYBOARD, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _INPUT_KEYBOARD, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _INPUT_KEYBOARD_LAYOUT, sValue); + if(r != E_SUCCESS) + { + sValue.Clear(); + this->GetValue(_INPUT_KEYBOARD_LAYOUT, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _INPUT_KEYBOARD_LAYOUT, sValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _LOCATION, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_LOCATION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _LOCATION, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _LOCATION_GPS, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_LOCATION_GPS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _LOCATION_GPS, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _LOCATION_WPS, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_LOCATION_WPS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _LOCATION_WPS, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _MICROPHONE, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_MICROPHONE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _MICROPHONE, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _MULTIPOINTTOUCH_PINCHZOOM, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_MULTIPOINTTOUCH_PINCHZOOM, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _MULTIPOINTTOUCH_PINCHZOOM, systemValue); + reg.Flush(); + } + + nValue = 0; + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _MULTIPOINTTOUCH_POINTCOUNT, nValue); + if(r != E_SUCCESS) + { + nValue = 0; + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _MULTIPOINTTOUCH_POINTCOUNT, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _MULTIPOINTTOUCH_POINTCOUNT, nValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_BLUETOOTH, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_BLUETOOTH, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_BLUETOOTH, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_NFC, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_NFC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_NFC, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_NFC_RESERVED_PUSH, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_NFC_RESERVED_PUSH, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_NFC_RESERVED_PUSH, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_PUSH, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_PUSH, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_PUSH, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_SECURE_ELEMENT, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_SECURE_ELEMENT, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_SECURE_ELEMENT, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_MMS, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_MMS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_MMS, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SMS, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SMS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SMS, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SMS_CBS, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SMS_CBS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SMS_CBS, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_CDMA, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_CDMA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_CDMA, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_EDGE, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_EDGE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_EDGE, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_GPRS, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_GPRS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_GPRS, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_GSM, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_GSM, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_GSM, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_HSDPA, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_HSDPA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_HSDPA, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_HSPA, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_HSPA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_HSPA, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_HSUPA, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_HSUPA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_HSUPA, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_LTE, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_LTE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_LTE, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_UMTS, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_TELEPHONY_SERVICE_UMTS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_TELEPHONY_SERVICE_UMTS, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_WIFI, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_WIFI, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_WIFI, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _NETWORK_WIFI_DIRECT, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_NETWORK_WIFI_DIRECT, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _NETWORK_WIFI_DIRECT, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _OPENGLES, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_OPENGLES, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_3DC, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_3DC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_3DC, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_ATC, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_ATC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_ATC, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_ETC, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_ETC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_ETC, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_PTC, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_PTC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_PTC, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_PVRTC, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_PVRTC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_PVRTC, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_UTC, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_OPENGLES_TEXTUREFORMAT_UTC, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_TEXTUREFORMAT_UTC, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _OPENGLES_VERSION_1_1, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_OPENGLES_VERSION_1_1, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_VERSION_1_1, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _OPENGLES_VERSION_2_0, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_OPENGLES_VERSION_2_0, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _OPENGLES_VERSION_2_0, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_CPU_ARCH_ARMV6, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_PLATFORM_CORE_CPU_ARCH_ARMV6, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_CPU_ARCH_ARMV6, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_CPU_ARCH_ARMV7, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_PLATFORM_CORE_CPU_ARCH_ARMV7, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_CPU_ARCH_ARMV7, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_CPU_ARCH_X86, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_PLATFORM_CORE_CPU_ARCH_X86, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_CPU_ARCH_X86, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_SSE2, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_PLATFORM_CORE_FPU_ARCH_SSE2, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_SSE2, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_SSE3, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_PLATFORM_CORE_FPU_ARCH_SSE3, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_SSE3, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_SSSE3, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_PLATFORM_CORE_FPU_ARCH_SSSE3, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_SSSE3, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_VFPV2, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_PLATFORM_CORE_FPU_ARCH_VFPV2, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_VFPV2, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_VFPV3, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_PLATFORM_CORE_FPU_ARCH_VFPV3, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_CORE_FPU_ARCH_VFPV3, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_NATIVE_API_VERSION, sValue); + if(r != E_SUCCESS) + { + sValue.Clear(); + this->GetValue(_PLATFORM_NATIVE_API_VERSION, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_NATIVE_API_VERSION, sValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_NATIVE_OSP_COMPATIBLE, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_PLATFORM_NATIVE_OSP_COMPATIBLE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_NATIVE_OSP_COMPATIBLE, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_VERSION, sValue); + if(r != E_SUCCESS) + { + sValue.Clear(); + this->GetValue(_PLATFORM_VERSION, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_VERSION, sValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_WEB_API_VERSION, sValue); + if(r != E_SUCCESS) + { + sValue.Clear(); + this->GetValue(_PLATFORM_WEB_API_VERSION, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_WEB_API_VERSION, sValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SCREEN_AUTO_ROTATION, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + bValue = false; + this->GetValue(_SCREEN_AUTO_ROTATION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_AUTO_ROTATION, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SCREEN_BPP, nValue); + if(r != E_SUCCESS) + { + nValue = 0; + this->GetValue(_SCREEN_BPP, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_BPP, nValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SCREEN_COORDINATE_SYSTEM_SIZE_LARGE, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SCREEN_COORDINATE_SYSTEM_SIZE_LARGE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_COORDINATE_SYSTEM_SIZE_LARGE, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SCREEN_COORDINATE_SYSTEM_SIZE_NORMAL, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SCREEN_COORDINATE_SYSTEM_SIZE_NORMAL, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_COORDINATE_SYSTEM_SIZE_NORMAL, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SCREEN_DESKTOPMODE, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SCREEN_DESKTOPMODE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_DESKTOPMODE, systemValue); + reg.Flush(); + } + + bValue = false; + this->GetValue(_SCREEN_SIZE_LARGE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + if(reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_LARGE, systemValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_LARGE, systemValue); + } + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + if(reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL, systemValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL, systemValue); + } + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_240_400, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + if(reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_240_400, systemValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_240_400, systemValue); + } + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_320_480, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + if(reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_320_480, systemValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_320_480, systemValue); + } + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_480_800, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + if(reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_480_800, systemValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_480_800, systemValue); + } + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_540_960, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + if(reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_540_960, systemValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_540_960, systemValue); + } + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_600_1024, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + if(reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_600_1024, systemValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_600_1024, systemValue); + } + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_720_1280, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + if(reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_720_1280, systemValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_720_1280, systemValue); + } + reg.Flush(); + + bValue = false; + this->GetValue(_SCREEN_SIZE_NORMAL_1080_1920, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + if(reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_1080_1920, systemValue) == E_KEY_ALREADY_EXIST) + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _SCREEN_SIZE_NORMAL_1080_1920, systemValue); + } + reg.Flush(); + + bValue = false; + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SCREEN_OUTPUT_HDMI, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SCREEN_OUTPUT_HDMI, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_OUTPUT_HDMI, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SCREEN_OUTPUT_RCA, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SCREEN_OUTPUT_RCA, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SCREEN_OUTPUT_RCA, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SHELL_APPWIDGET, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SHELL_APPWIDGET, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SHELL_APPWIDGET, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_ACCELEROMETER, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_ACCELEROMETER, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_ACCELEROMETER, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_ACCELEROMETER_WAKEUP, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_ACCELEROMETER_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_ACCELEROMETER_WAKEUP, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_BAROMETER, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_BAROMETER, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_BAROMETER, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_BAROMETER_WAKEUP, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_BAROMETER_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_BAROMETER_WAKEUP, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_GYROSCOPE, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_GYROSCOPE, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_GYROSCOPE, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_GYROSCOPE_WAKEUP, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_GYROSCOPE_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_GYROSCOPE_WAKEUP, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_MAGNETOMETER, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_MAGNETOMETER, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_MAGNETOMETER, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_MAGNETOMETER_WAKEUP, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_MAGNETOMETER_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_MAGNETOMETER_WAKEUP, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_PHOTOMETER, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_PHOTOMETER, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_PHOTOMETER, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_PHOTOMETER_WAKEUP, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_PHOTOMETER_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_PHOTOMETER_WAKEUP, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_PROXIMITY, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_PROXIMITY, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_PROXIMITY, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_PROXIMITY_WAKEUP, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_PROXIMITY_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_PROXIMITY_WAKEUP, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_TILTMETER, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_TILTMETER, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_TILTMETER, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SENSOR_TILTMETER_WAKEUP, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SENSOR_TILTMETER_WAKEUP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SENSOR_TILTMETER_WAKEUP, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SIP_VOIP, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SIP_VOIP, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SIP_VOIP, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SPEECH_RECOGNITION, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SPEECH_RECOGNITION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SPEECH_RECOGNITION, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SPEECH_SYNTHESIS, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_SPEECH_SYNTHESIS, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _SPEECH_SYNTHESIS, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _USB_ACCESSORY, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_USB_ACCESSORY, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _USB_ACCESSORY, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _USB_CLIENT, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_USB_CLIENT, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _USB_CLIENT, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _USB_HOST, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_USB_HOST, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _USB_HOST, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _VISION_FACE_RECOGNITION, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_VISION_FACE_RECOGNITION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _VISION_FACE_RECOGNITION, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _VISION_IMAGE_RECOGNITION, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_VISION_IMAGE_RECOGNITION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _VISION_IMAGE_RECOGNITION, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _VISION_QRCODE_GENERATION, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_VISION_QRCODE_GENERATION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _VISION_QRCODE_GENERATION, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _VISION_QRCODE_RECOGNITION, systemValue); + if(r != E_SUCCESS) + { + bValue = false; + this->GetValue(_VISION_QRCODE_RECOGNITION, bValue); + if(bValue == true) + systemValue = _SYSTEM_CACHING_TRUE; + else + systemValue = _SYSTEM_CACHING_FALSE; + + reg.AddValue(_SYSTEM_CACHING_SECTION, _VISION_QRCODE_RECOGNITION, systemValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _BUILD_STRING, sValue); + if(r != E_SUCCESS) + { + sValue.Clear(); + this->GetValue(_BUILD_STRING, sValue); + reg.Flush(); + reg.AddValue(_SYSTEM_CACHING_SECTION, _BUILD_STRING, sValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _DUID, sValue); + if(r != E_SUCCESS || sValue == L"ERROR") + { + sValue.Clear(); + r = this->GetValue(_DUID, sValue); + if(r != E_SUCCESS) + { + sValue.Append(L"ERROR"); + } + r = reg.AddValue(_SYSTEM_CACHING_SECTION, _DUID, sValue); + + if (r == E_KEY_ALREADY_EXIST && sValue != L"ERROR") + { + reg.SetValue(_SYSTEM_CACHING_SECTION, _DUID, sValue); + } + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _MODELNAME, sValue); + if(r != E_SUCCESS) + { + sValue.Clear(); + this->GetValue(_MODELNAME, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _MODELNAME, sValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _PLATFORM_NAME, sValue); + if(r != E_SUCCESS) + { + sValue.Clear(); + this->GetValue(_PLATFORM_NAME, sValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _PLATFORM_NAME, sValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SOUND_MEDIA_VOLUME_MAX, nValue); + if(r != E_SUCCESS) + { + nValue = 0; + this->GetValue(_SOUND_MEDIA_VOLUME_MAX, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SOUND_MEDIA_VOLUME_MAX, nValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SOUND_NOTIFICATION_VOLUME_MAX, nValue); + if(r != E_SUCCESS) + { + nValue = 0; + this->GetValue(_SOUND_NOTIFICATION_VOLUME_MAX, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SOUND_NOTIFICATION_VOLUME_MAX, nValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SOUND_RINGTONE_VOLUME_MAX, nValue); + if(r != E_SUCCESS) + { + nValue = 0; + this->GetValue(_SOUND_RINGTONE_VOLUME_MAX, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SOUND_RINGTONE_VOLUME_MAX, nValue); + reg.Flush(); + } + + r = reg.GetValue(_SYSTEM_CACHING_SECTION, _SOUND_SYSTEM_VOLUME_MAX, nValue); + if(r != E_SUCCESS) + { + nValue = 0; + this->GetValue(_SOUND_SYSTEM_VOLUME_MAX, nValue); + reg.AddValue(_SYSTEM_CACHING_SECTION, _SOUND_SYSTEM_VOLUME_MAX, nValue); + reg.Flush(); + } + + return E_SUCCESS; +} + +result +_SystemInfoService::CachingSystemInformation(void) +{ + result r = E_SUCCESS; + + if(File::IsFileExist(_SYSTEM_CACHING_FILE) == false) + { + r = CreateCacheFile(); + } + else + { + FileAttributes attr; + r = File::GetAttributes(_SYSTEM_CACHING_FILE, attr); + SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get file attributes. [%s]", GetErrorMessage(r)); + + if(attr.GetFileSize() == 0) + { + r = CreateCacheFile(); + } + else + { + r = UpdateCacheFile(); + } + } + return r; +} + +result +_SystemInfoService::GetValue(const String& key, String& value) +{ + int ret = 0; + result r = E_SUCCESS; + char* pValue = null; + + SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer()); + if (key == _DUID) + { + bool supported = false; + SysLog(NID_SYS, "It trys to get DUID from telephony."); + this->GetValue(_NETWORK_TELEPHONY, supported); + if(supported == true) + { + r = _DeviceId::GetId(value, 0); + } + else + { + SysLog(NID_SYS, "It trys to get DUID from wifi."); + this->GetValue(_NETWORK_WIFI, supported); + if(supported == true) + { + r = _DeviceId::GetId(value, 1); + } + else + { + SysLog(NID_SYS, "It trys to get DUID from bluetooth."); + this->GetValue(_NETWORK_BLUETOOTH, supported); + if(supported == true) + { + r = _DeviceId::GetId(value, 2); + } + else + { + SysLogException(NID_SYS, E_SYSTEM, "It is failed to get telephony, wifi, bluetooth information."); + return E_SYSTEM; + } + } + } + SysTryReturnResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, "It is failed to get the key[%ls]", key.GetPointer()); + } + else if (key == _MODELNAME) + { + ret = system_info_get_value_string(SYSTEM_INFO_KEY_MODEL, &pValue); + SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE && pValue, E_SYSTEM, "It is failed to get the SYSTEM_INFO_KEY_MODEL"); + + r = StringUtil::Utf8ToString(pValue, value); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "[%s] StringUtil::Utf8ToString It is failed", GetErrorMessage(r)); + } + else if (key == _BUILD_STRING) + { + ret = system_info_get_value_string(SYSTEM_INFO_KEY_BUILD_STRING, &pValue); + SysTryReturnResult(NID_SYS, ret == SYSTEM_INFO_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] system_info_get_value_string : \"SYSTEM_INFO_KEY_TIZEN_VERSION_STRING\"It is failed"); + + r = StringUtil::Utf8ToString(pValue, value); + SysTryCatch(NID_SYS, r == E_SUCCESS, r = E_SYSTEM, r, "[%s] StringUtil::Utf8ToString It is failed", GetErrorMessage(r)); + } + else + { + String tizenKey; + key.SubString(7, tizenKey); + + ClearLastResult(); + unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tizenKey)); + r = GetLastResult(); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r)); + int ret = system_info_get_platform_string(systemKey.get(), &pValue); + + SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from the configuration file", key.GetPointer()); + + r = StringUtil::Utf8ToString(pValue, value); + free(pValue); + pValue = null; + + return r; + } + +CATCH: + if(pValue != null) + { + free(pValue); + } + + return r; + +} + +result +_SystemInfoService::GetValue(const String& key, int& value) +{ + int ret = 0; + result r = E_SUCCESS; + + SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer()); + + String tizenKey; + key.SubString(7, tizenKey); + + ClearLastResult(); + unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tizenKey)); + r = GetLastResult(); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r)); + ret = system_info_get_platform_int(systemKey.get(), &value); + + SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", key.GetPointer()); + r = E_SUCCESS; + + return r; +} + +result +_SystemInfoService::GetValue(const String& key, bool& value) +{ + int ret = 0; + result r = E_SUCCESS; + + SysLog(NID_SYS, "Request Key is %ls.", key.GetPointer()); + + if (key == _SCREEN_DESKTOPMODE) + { + value = false; + } + else if (key == _USB_CLIENT) + { + value = true; + } + else + { + String tizenKey; + key.SubString(7, tizenKey); + + ClearLastResult(); + unique_ptr< char[] > systemKey(_StringConverter::CopyToCharArrayN(tizenKey)); + r = GetLastResult(); + SysTryReturn(NID_SYS, r == E_SUCCESS, E_SYSTEM, r, "[%s] StringUtil::StringToUtf8N It is failed", GetErrorMessage(r)); + + bool supported = false; + ret = system_info_get_platform_bool(systemKey.get(), &supported); + SysTryReturnResult(NID_SYS, ret == 0, E_OBJ_NOT_FOUND, "It is failed to get system information %ls from configration file.", key.GetPointer()); + value = supported; + } + + return E_SUCCESS; +} +} } // Tizen::System diff --git a/src/system/FSys_SystemInfoService.h b/src/system/FSys_SystemInfoService.h new file mode 100644 index 0000000..f5511be --- /dev/null +++ b/src/system/FSys_SystemInfoService.h @@ -0,0 +1,70 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_SystemInfo.h + * @brief This is the header file for the _SystemInfo class. + */ + +#ifndef _FSYS_SERVICE_SYS_INFO_SERVICE_H_ +#define _FSYS_SERVICE_SYS_INFO_SERVICE_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +//#include +//#include +//#include + +namespace Tizen { namespace System +{ + +class _SystemInfoService +{ +private: + _SystemInfoService(); + ~_SystemInfoService(); + static void InitSingleton(void); + static void DestroySingleton(void); + +public: + static _SystemInfoService* GetInstance(void); + +public: + result CachingSystemInformation(void); + + result CreateCacheFile(void); + + result UpdateCacheFile(void); + + result GetValue(const Tizen::Base::String& key, Tizen::Base::String& value); + + result GetValue(const Tizen::Base::String& key, int& value); + + result GetValue(const Tizen::Base::String& key, bool& value); +private: + static _SystemInfoService* __pSystemInfoService; +}; + +} } // Tizen::System + +#endif // _FSYS_SERVICE_SYS_INFO_SERVICE_H_ diff --git a/src/system/FSys_SystemServiceIpcEventForAsync.cpp b/src/system/FSys_SystemServiceIpcEventForAsync.cpp new file mode 100644 index 0000000..63e0050 --- /dev/null +++ b/src/system/FSys_SystemServiceIpcEventForAsync.cpp @@ -0,0 +1,58 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_SystemServiceIpcEventForAsync.cpp + * @brief This is the header file for the %_SystemServiceIpcEventForAsync class. + * + * This header file contains the declarations of the %_SystemServiceIpcEventForAsync class. + */ + +#include +#include "FSys_SystemServiceIpcEventForAsync.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Io; + +namespace Tizen{ namespace System { + +_SystemServiceIpcEventForAsync::_SystemServiceIpcEventForAsync(_IpcServer *pIpcServer) +{ + __pIpcServer = pIpcServer; +} + +result +_SystemServiceIpcEventForAsync::Construct(long stackSize, ThreadPriority priority) +{ + return EventDrivenThread::Construct(stackSize, priority); +} + +void +_SystemServiceIpcEventForAsync::OnUserEventReceivedN(RequestId requestId, IList *pArgs) +{ + if(pArgs != null) + { + ArrayList* data = (ArrayList*)pArgs; + result r = __pIpcServer->SendResponse((int)requestId, new (std::nothrow) IoService_Data(*data)); + delete pArgs; + SysTryReturnVoidResult(NID_SYS, r == E_SUCCESS, E_SYSTEM, + "It is failed to send IPC message to %d. [%s]", (int)requestId, GetErrorMessage(r)); + } +} + +}} diff --git a/src/system/FSys_SystemServiceIpcEventForAsync.h b/src/system/FSys_SystemServiceIpcEventForAsync.h new file mode 100644 index 0000000..202a4b7 --- /dev/null +++ b/src/system/FSys_SystemServiceIpcEventForAsync.h @@ -0,0 +1,56 @@ +// +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FSys_SystemServiceIpcEventForAsync.h + * @brief This is the header file for the %_SystemServiceIpcEventForAsync class. + * + * This header file contains the declarations of the %_SystemServiceIpcEventForAsync class. + */ + +#ifndef _FSYS_SYSTEM_SERVICE_EVENT_FOR_ASYNC_H_ +#define _FSYS_SYSTEM_SERVICE_EVENT_FOR_ASYNC_H_ + +#include +#include +#include + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; + +namespace Tizen { namespace System { +class _OSP_EXPORT_ _SystemServiceIpcEventForAsync + : public Tizen::Base::Runtime::EventDrivenThread +{ +public: + _SystemServiceIpcEventForAsync(_IpcServer *pIpcServer); + + bool OnStart(void) + { + return true; + } + void OnStop(void) {} + result Construct(long stackSize, Tizen::Base::Runtime::ThreadPriority priority); + void OnUserEventReceivedN(RequestId requestId, IList *pArgs); +private: + _IpcServer* __pIpcServer; +}; +}} //Tizen::System + + +#endif // _FSYS_SYSTEM_SERVICE_EVENT_FOR_ASYNC_H_ + diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt new file mode 100644 index 0000000..f9530bb --- /dev/null +++ b/src/ui/CMakeLists.txt @@ -0,0 +1,26 @@ +SET (this_target ui_service) + +INCLUDE_DIRECTORIES( + ${SLP_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/inc + ./ + ) + +SET (${this_target}_SOURCE_FILES + FUi_UiManagerStub.cpp +) + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") + +## SET EXTRA COMPILER FLAGS +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIC" ) + +## SET C COMPILER FLAGS +SET(CMAKE_C_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## SET CPP COMPILER FLAGS +SET(CMAKE_CXX_FLAGS "${OSP_DEBUG_FLAGS} ${OSP_OPT_FLAGS} ${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} ${OSP_COMPILER_FLAGS}") + +## Create Library +ADD_LIBRARY (${this_target} STATIC ${${this_target}_SOURCE_FILES}) + diff --git a/src/ui/FUi_UiManagerStub.cpp b/src/ui/FUi_UiManagerStub.cpp new file mode 100644 index 0000000..2849af7 --- /dev/null +++ b/src/ui/FUi_UiManagerStub.cpp @@ -0,0 +1,147 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUi_UiManagerStub.cpp + * @brief This is the implementation for the _UiManagerStub class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_UiManagerStub.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Io; +using namespace Tizen::Security; + +namespace Tizen { namespace Ui +{ + +enum _ZOrderGroup +{ + _Z_ORDER_GROUP_HIGHEST, + _Z_ORDER_GROUP_HIGH, + _Z_ORDER_GROUP_NORMAL, +}; + +_UiManagerStub::_UiManagerStub(void) +{ +} + +_UiManagerStub::~_UiManagerStub(void) +{ + if (__pIpcServer) + { + __pIpcServer->Stop(); + } +} + +result +_UiManagerStub::Construct(void) +{ + result r = StartIpcServer(); + SysTryReturnResult(NID_UI, r == E_SUCCESS, r, "Propagating."); + + return E_SUCCESS; +} + +result +_UiManagerStub::StartIpcServer(void) +{ + unique_ptr<_IpcServer> pIpcServer(new (std::nothrow) _IpcServer()); + SysTryReturnResult(NID_UI, pIpcServer, E_OUT_OF_MEMORY, "Memory is insufficient."); + + result r = pIpcServer->Construct(L"osp.ui.ipcserver.uimanager", *this, true); + SysTryReturnResult(NID_UI, r == E_SUCCESS, r, "Propagating."); + + r = pIpcServer->Start(); + SysTryReturnResult(NID_UI, r == E_SUCCESS, r, "Propagating."); + + __pIpcServer = move(pIpcServer); + + return E_SUCCESS; +} + +bool +_UiManagerStub::OnSetZOrderGroup(unsigned int window, int windowZOrderGroup, result* pResult) +{ + *pResult = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientPackageId(), _PRV_UIMANAGER); + SysTryReturn(NID_UI, *pResult == E_SUCCESS, true, *pResult, "[%s] Propagating.", GetErrorMessage(*pResult)); + + Ecore_X_Window win = (Ecore_X_Window)window; + ecore_x_icccm_transient_for_unset(win); + SysLog(NID_UI, "[Window Order Group][Window : 0x%x] transient_for_unset", window); + + if (windowZOrderGroup == _Z_ORDER_GROUP_NORMAL) + { + ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL); + SysLog(NID_UI, "[Window Order Group][Window : 0x%x] set : ECORE_X_WINDOW_TYPE_NORMAL", window); + } + else if (windowZOrderGroup == _Z_ORDER_GROUP_HIGHEST) + { + ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NOTIFICATION); + utilx_set_system_notification_level((Display*)ecore_x_display_get(), win, UTILX_NOTIFICATION_LEVEL_HIGH); + SysLog(NID_UI, "[Window Order Group][Window : 0x%x] set : ECORE_X_WINDOW_TYPE_NOTIFICATION, UTILX_NOTIFICATION_LEVEL_HIGH", window); + } + else if (windowZOrderGroup == _Z_ORDER_GROUP_HIGH) + { + ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NOTIFICATION); + utilx_set_system_notification_level((Display*)ecore_x_display_get(), win, UTILX_NOTIFICATION_LEVEL_NORMAL); + SysLog(NID_UI, "[Window Order Group][Window : 0x%x] set : ECORE_X_WINDOW_TYPE_NOTIFICATION, UTILX_NOTIFICATION_LEVEL_NORMAL", window); + } + + return true; +} + +void +_UiManagerStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message) +{ + IPC_BEGIN_MESSAGE_MAP(_UiManagerStub, message) + IPC_MESSAGE_HANDLER_EX(UiManager_SetZOrderGroup, &server, OnSetZOrderGroup) + IPC_END_MESSAGE_MAP() +} + +void +_UiManagerStub::OnIpcServerStarted(const _IpcServer& server) +{ +} + +void +_UiManagerStub::OnIpcServerStopped(const _IpcServer& server) +{ +} + +void +_UiManagerStub::OnIpcClientConnected(const _IpcServer& server, int clientId) +{ +} + +void +_UiManagerStub::OnIpcClientDisconnected(const _IpcServer&server, int clientId) +{ +} + +}} // Tizen::Ui diff --git a/src/ui/FUi_UiManagerStub.h b/src/ui/FUi_UiManagerStub.h new file mode 100644 index 0000000..494c75d --- /dev/null +++ b/src/ui/FUi_UiManagerStub.h @@ -0,0 +1,66 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUi_UiManagerStub.h + * @brief This is the header file of the _UiManagerStub class. + * + * This header file contains the declarations of the _UiManagerStub class. + */ + +#ifndef _FUI_INTERNAL_UI_MANAGER_STUB_H_ +#define _FUI_INTERNAL_UI_MANAGER_STUB_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Ui +{ + +class _UiManagerStub + : public Tizen::Base::Object + , public Tizen::Io::_IIpcServerEventListener +{ +public: + _UiManagerStub(void); + virtual ~_UiManagerStub(void); + + result Construct(void); + + bool OnSetZOrderGroup(unsigned int window, int windowZOrderGroup, result* pResult); + +private: + _UiManagerStub(const _UiManagerStub& rhs); + _UiManagerStub& operator =(const _UiManagerStub& rhs); + + result StartIpcServer(void); + + virtual void OnIpcServerStarted(const Tizen::Io::_IpcServer& server); + virtual void OnIpcServerStopped(const Tizen::Io::_IpcServer& server); + virtual void OnIpcClientConnected(const Tizen::Io::_IpcServer& server, int clientId); + virtual void OnIpcClientDisconnected(const Tizen::Io::_IpcServer&server, int clientId); + virtual void OnIpcRequestReceived(Tizen::Io::_IpcServer& server, const IPC::Message& message); + +private: + std::unique_ptr __pIpcServer; +}; // _UiManagerStub + +}} // Tizen::Ui + +#endif // _FUI_INTERNAL_UI_MANAGER_STUB_H_ \ No newline at end of file -- 2.7.4