From 68889679914543a40a0fa6c48fb0db6cffbb4597 Mon Sep 17 00:00:00 2001 From: Sehong Na Date: Sat, 31 May 2014 12:57:09 +0900 Subject: [PATCH] Initialize Tizen 2.3 --- .project | 86 ++ CMakeLists.txt | 90 ++ LICENSE.APLv2 | 202 ++++ LICENSE.Flora | 206 ++++ NOTICE | 8 + inc/FUix.h | 51 + inc/FUixSensor.h | 63 ++ inc/FUixSensorAccelerationSensorData.h | 131 +++ inc/FUixSensorDeviceOrientationSensorData.h | 134 +++ inc/FUixSensorGravitySensorData.h | 132 +++ inc/FUixSensorGyroSensorData.h | 132 +++ inc/FUixSensorIMotionEventListener.h | 117 +++ inc/FUixSensorISensorEventListener.h | 136 +++ inc/FUixSensorLightSensorData.h | 116 ++ inc/FUixSensorMagneticSensorData.h | 130 +++ inc/FUixSensorMotion.h | 171 +++ inc/FUixSensorMotionCommon.h | 89 ++ inc/FUixSensorProximitySensorData.h | 128 +++ inc/FUixSensorSensorData.h | 114 ++ inc/FUixSensorSensorManager.h | 754 +++++++++++++ inc/FUixSensorSensorTypes.h | 141 +++ inc/FUixSensorTiltSensorData.h | 132 +++ inc/FUixSensorUserAccelerationSensorData.h | 130 +++ osp-uix.manifest | 5 + osp-uix.pc.in | 14 + packaging/osp-uix.spec | 96 ++ src/FUixSensorAccelerationSensorData.cpp | 168 +++ src/FUixSensorDeviceOrientationSensorData.cpp | 143 +++ src/FUixSensorGravitySensorData.cpp | 143 +++ src/FUixSensorGyroSensorData.cpp | 143 +++ src/FUixSensorLightSensorData.cpp | 124 +++ src/FUixSensorMagneticSensorData.cpp | 167 +++ src/FUixSensorMotion.cpp | 96 ++ src/FUixSensorProximitySensorData.cpp | 151 +++ src/FUixSensorSensorData.cpp | 68 ++ src/FUixSensorSensorManager.cpp | 348 ++++++ src/FUixSensorTiltSensorData.cpp | 169 +++ src/FUixSensorUserAccelerationSensorData.cpp | 144 +++ src/FUixSensor_ISensorCore.cpp | 1107 ++++++++++++++++++++ src/FUixSensor_ISensorCore.h | 64 ++ src/FUixSensor_ISensorCoreEventReceiver.h | 64 ++ src/FUixSensor_MotionImpl.cpp | 339 ++++++ src/FUixSensor_SensorCoreEventTypes.h | 135 +++ src/FUixSensor_SensorEventDeliverer.cpp | 417 ++++++++ src/FUixSensor_SensorEventDeliverer.h | 93 ++ src/FUixSensor_SensorManagerImpl.cpp | 668 ++++++++++++ src/FUixSensor_SensorUtil.cpp | 134 +++ src/FUixSensor_SensorUtil.h | 63 ++ ...FUixSensor_SpecifiedSensorDataEventDelivererT.h | 60 ++ src/inc/FUixSensor_MotionImpl.h | 131 +++ src/inc/FUixSensor_SensorManagerImpl.h | 95 ++ 51 files changed, 8742 insertions(+) create mode 100644 .project create mode 100755 CMakeLists.txt create mode 100755 LICENSE.APLv2 create mode 100644 LICENSE.Flora create mode 100755 NOTICE create mode 100755 inc/FUix.h create mode 100755 inc/FUixSensor.h create mode 100644 inc/FUixSensorAccelerationSensorData.h create mode 100644 inc/FUixSensorDeviceOrientationSensorData.h create mode 100644 inc/FUixSensorGravitySensorData.h create mode 100644 inc/FUixSensorGyroSensorData.h create mode 100644 inc/FUixSensorIMotionEventListener.h create mode 100644 inc/FUixSensorISensorEventListener.h create mode 100644 inc/FUixSensorLightSensorData.h create mode 100644 inc/FUixSensorMagneticSensorData.h create mode 100644 inc/FUixSensorMotion.h create mode 100644 inc/FUixSensorMotionCommon.h create mode 100644 inc/FUixSensorProximitySensorData.h create mode 100644 inc/FUixSensorSensorData.h create mode 100644 inc/FUixSensorSensorManager.h create mode 100644 inc/FUixSensorSensorTypes.h create mode 100644 inc/FUixSensorTiltSensorData.h create mode 100644 inc/FUixSensorUserAccelerationSensorData.h create mode 100644 osp-uix.manifest create mode 100755 osp-uix.pc.in create mode 100644 packaging/osp-uix.spec create mode 100644 src/FUixSensorAccelerationSensorData.cpp create mode 100644 src/FUixSensorDeviceOrientationSensorData.cpp create mode 100644 src/FUixSensorGravitySensorData.cpp create mode 100644 src/FUixSensorGyroSensorData.cpp create mode 100644 src/FUixSensorLightSensorData.cpp create mode 100644 src/FUixSensorMagneticSensorData.cpp create mode 100644 src/FUixSensorMotion.cpp create mode 100644 src/FUixSensorProximitySensorData.cpp create mode 100644 src/FUixSensorSensorData.cpp create mode 100644 src/FUixSensorSensorManager.cpp create mode 100644 src/FUixSensorTiltSensorData.cpp create mode 100644 src/FUixSensorUserAccelerationSensorData.cpp create mode 100644 src/FUixSensor_ISensorCore.cpp create mode 100644 src/FUixSensor_ISensorCore.h create mode 100644 src/FUixSensor_ISensorCoreEventReceiver.h create mode 100644 src/FUixSensor_MotionImpl.cpp create mode 100644 src/FUixSensor_SensorCoreEventTypes.h create mode 100644 src/FUixSensor_SensorEventDeliverer.cpp create mode 100644 src/FUixSensor_SensorEventDeliverer.h create mode 100644 src/FUixSensor_SensorManagerImpl.cpp create mode 100644 src/FUixSensor_SensorUtil.cpp create mode 100644 src/FUixSensor_SensorUtil.h create mode 100644 src/FUixSensor_SpecifiedSensorDataEventDelivererT.h create mode 100644 src/inc/FUixSensor_MotionImpl.h create mode 100644 src/inc/FUixSensor_SensorManagerImpl.h diff --git a/.project b/.project new file mode 100644 index 0000000..cbf7b05 --- /dev/null +++ b/.project @@ -0,0 +1,86 @@ + + + rsa-osp-uix + + + git_slp + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + make + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + false + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + org.tizen.nativecpp.apichecker.core.builder + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + org.tizen.nativecpp.apichecker.core.tizenCppNature + + diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100755 index 0000000..06f695f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,90 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) + +SET (this_target osp-uix) + +SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/cmake_build_tmp/output) + +INCLUDE_DIRECTORIES( + inc + src + src/inc + /usr/include/sensor + /usr/include/system + /usr/include/osp + /usr/include/osp/app + /usr/include/osp/base + ) + +SET (${this_target}_SOURCE_FILES + src/FUixSensorMotion.cpp + src/FUixSensor_MotionImpl.cpp + src/FUixSensorSensorData.cpp + src/FUixSensorAccelerationSensorData.cpp + src/FUixSensorMagneticSensorData.cpp + src/FUixSensorProximitySensorData.cpp + src/FUixSensorTiltSensorData.cpp + src/FUixSensorGyroSensorData.cpp + src/FUixSensorLightSensorData.cpp + src/FUixSensorGravitySensorData.cpp + src/FUixSensorUserAccelerationSensorData.cpp + src/FUixSensorDeviceOrientationSensorData.cpp + src/FUixSensorSensorManager.cpp + src/FUixSensor_ISensorCore.cpp + src/FUixSensor_SensorUtil.cpp + src/FUixSensor_SensorEventDeliverer.cpp + src/FUixSensor_SensorManagerImpl.cpp + ) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall" ) + +## 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}") + +## Create Library +ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES}) + +## SET DEPENDENCY FLAGS +ADD_DEPENDENCIES(${this_target} osp-appfw) + +## SET LINKER FLAGS +SET(CMAKE_SHARED_LINKER_FLAGS -Wl,--no-undefined) + +TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" ) +TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-sensor" ) + +SET_TARGET_PROPERTIES(${this_target} + PROPERTIES + VERSION ${FULLVER} + SOVERSION ${MAJORVER} + CLEAN_DIRECT_OUTPUT 1 + ) + +ADD_CUSTOM_COMMAND(TARGET ${this_target} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} + COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${FULLVER} ${LIBRARY_OUTPUT_PATH}/debug/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX}.${MAJORVER} + COMMAND ${CMAKE_STRIP} --strip-unneeded ${LIBRARY_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}${this_target}${CMAKE_SHARED_LIBRARY_SUFFIX} + COMMENT "strip ${this_target}" + ) + +INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/ DESTINATION lib/osp + FILES_MATCHING PATTERN "*.so*" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ) +INSTALL(DIRECTORY ${LIBRARY_OUTPUT_PATH}/debug/ DESTINATION lib/osp/debug + FILES_MATCHING PATTERN "*.so*" + PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ + GROUP_EXECUTE GROUP_READ + WORLD_EXECUTE WORLD_READ) + +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/inc/ DESTINATION include/osp FILES_MATCHING PATTERN "*.h") +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/inc/ DESTINATION include/osp/uix FILES_MATCHING PATTERN "*.h") + +# pkgconfig file +CONFIGURE_FILE(${this_target}.pc.in ${CMAKE_SOURCE_DIR}/${this_target}.pc @ONLY) +INSTALL(FILES ${CMAKE_SOURCE_DIR}/${this_target}.pc DESTINATION lib/pkgconfig) diff --git a/LICENSE.APLv2 b/LICENSE.APLv2 new file mode 100755 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/LICENSE.Flora b/LICENSE.Flora new file mode 100644 index 0000000..571fe79 --- /dev/null +++ b/LICENSE.Flora @@ -0,0 +1,206 @@ +Flora License + +Version 1.1, April, 2013 + +http://floralicense.org/license/ + +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. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Tizen Compliance Specification +and passes the Tizen Compliance Tests as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +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 +solely as incorporated into a Tizen Certified Platform, 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 solely +as incorporated into a Tizen Certified Platform 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 pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. 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 + 4. 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 + and your own copyright statement or terms and conditions do not conflict + the conditions stated in the License including section 3. + +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 Flora License to your work + +To apply the Flora 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 Flora License, Version 1.1 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://floralicense.org/license/ + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/NOTICE b/NOTICE new file mode 100755 index 0000000..3a382ef --- /dev/null +++ b/NOTICE @@ -0,0 +1,8 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Apache License, Version 2. +Please, see the LICENSE.APLv2 file for Apache License terms and conditions. + +Several source codes may have its original copyright owner and/or +be licensed under other than Apache License, Version 2, say, Flora License, Version 1.1. +Please, see copyright and license comments section in the header of each file, +and the LICENSE.Flora for Flora License, Version 1.1 terms and conditions. \ No newline at end of file diff --git a/inc/FUix.h b/inc/FUix.h new file mode 100755 index 0000000..8946cea --- /dev/null +++ b/inc/FUix.h @@ -0,0 +1,51 @@ +// +// 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 FUix.h +* @brief This is the header file for the %Uix namespace. +* +* This header file contains the declarations and descriptions of the %Uix namespace. +*/ + +#ifndef _FUIX_H_ +#define _FUIX_H_ + +#include +#include +#include + +/** + * @namespace Tizen::Uix + * @brief This namespace contains %Ui extension classes and %Tizen interfaces. + * @since 2.0 + * + * @remarks @b Header @b %file: @b \#include @b @n + * + * The %Uix namespace contains classes and interfaces for UI extension services, which cover unconventional user interface + * features not included in the basic UI namespace, such as vision based recognition, device sensor input and motion + * detection, as well as speech recognition and synthesis. + * @n + * For more information on the %Uix namespace features, see Uix Guide. + * + */ +namespace Tizen { namespace Uix +{ + +} } // Tizen::Uix + +#endif // _FUIX_H_ diff --git a/inc/FUixSensor.h b/inc/FUixSensor.h new file mode 100755 index 0000000..e522131 --- /dev/null +++ b/inc/FUixSensor.h @@ -0,0 +1,63 @@ +// +// 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 FUixSensor.h +* @brief This is the header file for the %Sensor namespace. +* +* This header file contains the declarations and descriptions of the %Sensor namespace. +*/ + +#ifndef _FUIX_SENSOR_H_ +#define _FUIX_SENSOR_H_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/** + * @namespace Tizen::Uix::Sensor + * @brief This namespace contains %Sensor classes and %Tizen interfaces. + * @since 2.0 + * + * @remarks @b Header @b %file: @b \#include @b @n + * @b Library: @b osp-uix + * + * The %Sensor namespace contains classes and interfaces for %Sensor services, user control sensor and access data of each sensor. + * + * + * The following diagram illustrates the relationships between the classes belonging to the %Sensor namespace. + * @image html uix_sensor_namespace_classdiagram.png + + */ +namespace Tizen { namespace Uix { namespace Sensor +{ + +} } } // Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_H_ diff --git a/inc/FUixSensorAccelerationSensorData.h b/inc/FUixSensorAccelerationSensorData.h new file mode 100644 index 0000000..75986d1 --- /dev/null +++ b/inc/FUixSensorAccelerationSensorData.h @@ -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. +// + +/** + * @file FUixSensorAccelerationSensorData.h + * @brief This is the header file for the %AccelerationSensorData class. + * + * This header file contains the declarations of the %AccelerationSensorData class. + */ + +#ifndef _FUIX_SENSOR_ACCELERATION_SENSOR_DATA_H_ +#define _FUIX_SENSOR_ACCELERATION_SENSOR_DATA_H_ + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +/** + * @class AccelerationSensorData + * @brief This class stores acceleration sensor data, including a time stamp. + * + * @since 2.0 + * + * The %AccelerationSensorData class stores acceleration sensor data, including a time stamp. + * + * For more information on the class features, see Sensor Manager. + */ +class _OSP_EXPORT_ AccelerationSensorData + : public Tizen::Uix::Sensor::SensorData +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + AccelerationSensorData(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~AccelerationSensorData(void); + + /** + * Copying of objects using this copy constructor is allowed. + * + * @since 2.1 + * + * @param[in] rhs An instance of %AccelerationSensorData to copy + */ + AccelerationSensorData(const AccelerationSensorData& rhs); + + /** + * Compares the equality of values between two %AccelerationSensorData objects by overriding the Tizen::Base::Object::Equals() method. + * + * @since 2.1 + * + * @return @c true if all the fields in the objects are equal, @n + * else @c false + * @param[in] rhs The Tizen::Base::Object with which the comparison is done + * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method. + * + * @since 2.1 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Copying of objects using this copy assignment operator is allowed. + * + * @since 2.1 + * + * @return A reference to this instance + * @param[in] rhs An instance of %AccelerationSensorData to copy + */ + AccelerationSensorData& operator =(const AccelerationSensorData& rhs); + + +private: + virtual result GetValue(SensorDataKey dataKey, long& value) const; + virtual result GetValue(SensorDataKey dataKey, float& value) const; + virtual result GetValue(SensorDataKey dataKey, bool& value) const; + +public: + /** + * The x-axis value of the acceleration sensor data + * + * @since 2.0 + */ + float x; + + /** + * The y-axis value of the acceleration sensor data + * + * @since 2.0 + */ + float y; + + /** + * The z-axis value of the acceleration sensor data + * + * @since 2.0 + */ + float z; +}; // AccelerationSensorData +} } } // Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_ACCELERATION_SENSOR_DATA_H_ diff --git a/inc/FUixSensorDeviceOrientationSensorData.h b/inc/FUixSensorDeviceOrientationSensorData.h new file mode 100644 index 0000000..34b7df6 --- /dev/null +++ b/inc/FUixSensorDeviceOrientationSensorData.h @@ -0,0 +1,134 @@ +// +// 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 FUixSensorDeviceOrientationSensorData.h + * @brief This is the header file for the %DeviceOrientationSensorData class. + * + * This header file contains the declarations of the %DeviceOrientationSensorData class. + */ + +#ifndef _FUIX_SENSOR_DEVICE_ORIENTATION_SENSOR_DATA_H_ +#define _FUIX_SENSOR_DEVICE_ORIENTATION_SENSOR_DATA_H_ + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +/** + * @class DeviceOrientationSensorData + * @brief This class stores device-orientation sensor data, including a time stamp. + * + * @since 2.1 + * + * The %DeviceOrientationSensorData class stores device-orientation sensor data, including a time stamp. + * + * For more information on the class features, see Sensor Manager. + */ +class _OSP_EXPORT_ DeviceOrientationSensorData + : public Tizen::Uix::Sensor::SensorData +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.1 + */ + DeviceOrientationSensorData(void); + + /** + * This is the destructor for this class. + * + * @since 2.1 + */ + virtual ~DeviceOrientationSensorData(void); + + /** + * Copying of objects using this copy constructor is allowed. + * + * @since 2.1 + * + * @param[in] rhs An instance of %DeviceOrientationSensorData to copy + */ + DeviceOrientationSensorData(const DeviceOrientationSensorData& rhs); + + /** + * Compares the equality of values between two %DeviceOrientationSensorData objects by overriding the Tizen::Base::Object::Equals() method. + * + * @since 2.1 + * + * @return @c true if all the fields in the objects are equal, @n + * else @c false + * @param[in] rhs The Tizen::Base::Object with which the comparison is done + * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method. + * + * @since 2.1 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Copying of objects using this copy assignment operator is allowed. + * + * @since 2.1 + * + * @return A reference to this instance + * @param[in] rhs An instance of %DeviceOrientationSensorData to copy + */ + DeviceOrientationSensorData& operator =(const DeviceOrientationSensorData& rhs); + + + +private: + virtual result GetValue(SensorDataKey dataKey, long& value) const; + virtual result GetValue(SensorDataKey dataKey, float& value) const; + virtual result GetValue(SensorDataKey dataKey, bool& value) const; + +public: + /** + * The yaw value of the device-orientation sensor data + * + * @since 2.1 + */ + float yaw; + + /** + * The roll value of the device-orientation sensor data + * + * @since 2.1 + */ + float roll; + + /** + * The pitch value of the device-orientation sensor data + * + * @since 2.1 + */ + float pitch; + + +}; // DeviceOrientationSensorData +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_DEVICE_ORIENTATION_SENSOR_DATA_H_ diff --git a/inc/FUixSensorGravitySensorData.h b/inc/FUixSensorGravitySensorData.h new file mode 100644 index 0000000..7491b3d --- /dev/null +++ b/inc/FUixSensorGravitySensorData.h @@ -0,0 +1,132 @@ +// +// 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 FUixSensorGravitySensorData.h + * @brief This is the header file for the %GravitySensorData class. + * + * This header file contains the declarations of the %GravitySensorData class. + */ + +#ifndef _FUIX_SENSOR_GRAVITY_SENSOR_DATA_H_ +#define _FUIX_SENSOR_GRAVITY_SENSOR_DATA_H_ + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +/** + * @class GravitySensorData + * @brief This class stores gravity sensor data, including a time stamp. + * + * @since 2.1 + * + * The %GravitySensorData class stores gravity sensor data, including a time stamp. + * + * For more information on the class features, see Sensor Manager. + */ +class _OSP_EXPORT_ GravitySensorData + : public Tizen::Uix::Sensor::SensorData +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.1 + */ + GravitySensorData(void); + + /** + * This is the destructor for this class. + * + * @since 2.1 + */ + virtual ~GravitySensorData(void); + + /** + * Copying of objects using this copy constructor is allowed. + * + * @since 2.1 + * + * @param[in] rhs An instance of %GravitySensorData to copy + */ + GravitySensorData(const GravitySensorData& rhs); + + /** + * Compares the equality of values between two %GravitySensorData objects by overriding the Tizen::Base::Object::Equals() method. + * + * @since 2.1 + * + * @return @c true if all the fields in the objects are equal, @n + * else @c false + * @param[in] rhs The Tizen::Base::Object with which the comparison is done + * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method. + * + * @since 2.1 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Copying of objects using this copy assignment operator is allowed. + * + * @since 2.1 + * + * @return A reference to this instance + * @param[in] rhs An instance of %GravitySensorData to copy + */ + GravitySensorData& operator =(const GravitySensorData& rhs); + + + +private: + virtual result GetValue(SensorDataKey dataKey, long& value) const; + virtual result GetValue(SensorDataKey dataKey, float& value) const; + virtual result GetValue(SensorDataKey dataKey, bool& value) const; + +public: + /** + * The x-axis value of the gravity sensor data + * + * @since 2.1 + */ + float x; + + /** + * The y-axis value of the gravity sensor data + * + * @since 2.1 + */ + float y; + + /** + * The z-axis value of the gravity sensor data + * + * @since 2.1 + */ + float z; +}; // GravitySensorData +} } } // Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_GRAVITY_SENSOR_DATA_H_ diff --git a/inc/FUixSensorGyroSensorData.h b/inc/FUixSensorGyroSensorData.h new file mode 100644 index 0000000..7375c99 --- /dev/null +++ b/inc/FUixSensorGyroSensorData.h @@ -0,0 +1,132 @@ +// +// 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 FUixSensorGyroSensorData.h + * @brief This is the header file for the %GyroSensorData class. + * + * This header file contains the declarations of the %GyroSensorData class. + */ + +#ifndef _FUIX_SENSOR_GYRO_SENSOR_DATA_H_ +#define _FUIX_SENSOR_GYRO_SENSOR_DATA_H_ + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +/** + * @class GyroSensorData + * @brief This class stores gyro sensor data, including a time stamp. + * + * @since 2.0 + * + * The %GyroSensorData class stores gyro sensor data, including a time stamp. + * + * For more information on the class features, see Sensor Manager. + */ +class _OSP_EXPORT_ GyroSensorData + : public Tizen::Uix::Sensor::SensorData +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + GyroSensorData(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~GyroSensorData(void); + + /** + * Copying of objects using this copy constructor is allowed. + * + * @since 2.1 + * + * @param[in] rhs An instance of %GyroSensorData to copy + */ + GyroSensorData(const GyroSensorData& rhs); + + /** + * Compares the equality of values between two %GyroSensorData objects by overriding the Tizen::Base::Object::Equals() method. + * + * @since 2.1 + * + * @return @c true if all the fields in the objects are equal, @n + * else @c false + * @param[in] rhs The Tizen::Base::Object with which the comparison is done + * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method. + * + * @since 2.1 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Copying of objects using this copy assignment operator is allowed. + * + * @since 2.1 + * + * @return A reference to this instance + * @param[in] rhs An instance of %GyroSensorData to copy + */ + GyroSensorData& operator =(const GyroSensorData& rhs); + + + +private: + virtual result GetValue(SensorDataKey dataKey, long& value) const; + virtual result GetValue(SensorDataKey dataKey, float& value) const; + virtual result GetValue(SensorDataKey dataKey, bool& value) const; + +public: + /** + * The x-axis value of the gyro sensor data + * + * @since 2.0 + */ + float x; + + /** + * The y-axis value of the gyro sensor data + * + * @since 2.0 + */ + float y; + + /** + * The z-axis value of the gyro sensor data + * + * @since 2.0 + */ + float z; +}; // GyroSensorData +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_GYRO_SENSOR_DATA_H_ diff --git a/inc/FUixSensorIMotionEventListener.h b/inc/FUixSensorIMotionEventListener.h new file mode 100644 index 0000000..b9b0087 --- /dev/null +++ b/inc/FUixSensorIMotionEventListener.h @@ -0,0 +1,117 @@ +// +// 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 FUixSensorIMotionEventListener.h + * @brief This is the header file for the %IMotionEventListener interface. + * + * This header file contains the declarations of the %IMotionEventListener interface. + */ + +#ifndef _FUIX_SENSOR_IMOTION_EVENT_LISTENER_H_ +#define _FUIX_SENSOR_IMOTION_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ + +/** + * @interface IMotionEventListener + * @brief This interface is an event listener for the motion sensing events. + * + * @since 2.0 + * + * @remarks @b Header @b %file: @b \#include @b @n + * @b Library : @b osp-uix + * + * The %IMotionEventListener interface is a listener interface for the motion sensing events. + * @n + * For more information on the class features, see Device Motions. + */ + +class _OSP_EXPORT_ IMotionEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~IMotionEventListener(void){} + +public: + /** + * Called when the snap event is detected. @n + * When a snap event occurs, and if its type is registered by an application, then the event is triggered. + * + * @since 2.0 + * + * @param[in] snapType The type of the snap + */ + virtual void OnSnapDetected(MotionSnapType snapType) = 0; + + /** + * Called when the double-tap event is detected. @n + * When a double-tap event occurs, and if its type is registered by an application, then the event is triggered. + * + * @since 2.0 + * + * @see Tizen::Uix::Sensor::MotionType + */ + virtual void OnDoubleTapDetected(void) = 0; + + /** + * Called when the shake event is detected. @n + * When a shake event occurs, and if its type is registered by an application, then the event is triggered. + * + * @since 2.0 + * + * @param[in] motionState The type of the event state + */ + virtual void OnShakeDetected(MotionState motionState) = 0; + + /** + * Called when the move-to-ear event is detected. @n + * When a move-to-ear event occurs, and if its type is registered by an application, then the event is triggered. + * + * @since 2.1 + * + * @see Tizen::Uix::Sensor::MotionType + */ + virtual void OnMoveToEarDetected(void) {} + +protected: + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + virtual void IMotionEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + virtual void IMotionEventListener_Reserved2(void) {} +}; // IMotionEventListener + +} } } // Tizen::Uix::Sensor + +#endif //_FUIX_SENSOR_IMOTION_EVENT_LISTENER_H_ diff --git a/inc/FUixSensorISensorEventListener.h b/inc/FUixSensorISensorEventListener.h new file mode 100644 index 0000000..6b50e3f --- /dev/null +++ b/inc/FUixSensorISensorEventListener.h @@ -0,0 +1,136 @@ +// +// 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 FUixSensorISensorEventListener.h + * @brief This is the header file for the %ISensorEventListener interface. + * + * This header file contains the declarations of the %ISensorEventListener interface. + */ + +#ifndef _FUIX_SENSOR_ISENSOR_EVENT_LISTENER_H_ +#define _FUIX_SENSOR_ISENSOR_EVENT_LISTENER_H_ + +#include +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ + +/** + * @interface ISensorEventListener + * @brief This interface is an event listener used to receive sensor data asynchronously. + * + * @since 2.0 + * + * The %ISensorEventListener interface is an event listener used to receive sensor data asynchronously. + * It provides methods that are invoked when the sensor data is received from the device. + * + * For more information on the class features, see Sensor Manager. + */ +class _OSP_EXPORT_ ISensorEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +// Lifecycle +public: + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ISensorEventListener(void){} + +// Operation +public: + /** + * Called when the sensor data is sensed after every sensor interval or when the sensor data is changed from the previous interval. + * + * @since 2.0 + * + * @param[in] sensorType The sensor type + * @param[in] sensorData The array of sensor data + * @param[in] r The error code + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_DATA The sensor data is invalid. + * @remarks Calling of the application methods (including UI) must be handled in the main application thread, that is outside the sensor event handler %OnDataReceived(). + * @see Tizen::Uix::Sensor::AccelerationDataKey + * @see Tizen::Uix::Sensor::MagneticDataKey + * @see Tizen::Uix::Sensor::ProximityDataKey + * @see Tizen::Uix::Sensor::TiltDataKey + * + * The following example demonstrates how to use the %OnDataReceived() method. + * + * @code + * // Sample code for SensorSample.h + * #include + * #include + * + * class SensorSample : + * public Tizen::Ui::Controls::Form, + * public Tizen::Uix::Sensor::ISensorEventListener + * { + * public: + * virtual result OnDraw(); + * void OnDataReceived(SensorType sensorType, SensorData& sensorData , result r); + * //... + * } + * + * // Sample code for SensorSample.cpp + * #include "SensorSample.h" + * + * using namespace Tizen::Uix::Sensor; + * + * void + * SensorSample::OnDataReceived(SensorType sensorType, SensorData& sensorData , result r) + * { + * // ... + * } + * + * result + * SensorSample::OnDraw() + * { + * // ... + * } + * @endcode + */ + virtual void OnDataReceived(SensorType sensorType, SensorData& sensorData, result r) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + virtual void ISensorEventListener_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + virtual void ISensorEventListener_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + virtual void ISensorEventListener_Reserved3(void) {} + +}; // ISensorEventListener + +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_ISENSOR_EVENT_LISTENER_H_ diff --git a/inc/FUixSensorLightSensorData.h b/inc/FUixSensorLightSensorData.h new file mode 100644 index 0000000..f8276ab --- /dev/null +++ b/inc/FUixSensorLightSensorData.h @@ -0,0 +1,116 @@ +// +// 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 FUixSensorLightSensorData.h + * @brief This is the header file for the %LightSensorData class. + * + * This header file contains the declarations of the %LightSensorData class. + */ + +#ifndef _FUIX_SENSOR_LIGHT_SENSOR_DATA_H_ +#define _FUIX_SENSOR_LIGHT_SENSOR_DATA_H_ + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +/** + * @class LightSensorData + * @brief This class stores light sensor data, including a time stamp. + * + * @since 2.0 + * + * The %LightSensorData class stores light sensor data, including a time stamp. + * + * For more information on the class features, see Sensor Manager. + */ +class _OSP_EXPORT_ LightSensorData + : public Tizen::Uix::Sensor::SensorData +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + LightSensorData(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~LightSensorData(void); + + /** + * Copying of objects using this copy constructor is allowed. + * + * @since 2.1 + * + * @param[in] rhs An instance of %LightSensorData to copy + */ + LightSensorData(const LightSensorData& rhs); + + /** + * Compares the equality of values between two %LightSensorData objects by overriding the Tizen::Base::Object::Equals() method. + * + * @since 2.1 + * + * @return @c true if all the fields in the objects are equal, @n + * else @c false + * @param[in] rhs The Tizen::Base::Object with which the comparison is done + * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method. + * + * @since 2.1 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Copying of objects using this copy assignment operator is allowed. + * + * @since 2.1 + * + * @return A reference to this instance + * @param[in] rhs An instance of %LightSensorData to copy + */ + LightSensorData& operator =(const LightSensorData& rhs); + +private: + virtual result GetValue(SensorDataKey dataKey, long& value) const; + virtual result GetValue(SensorDataKey dataKey, float& value) const; + virtual result GetValue(SensorDataKey dataKey, bool& value) const; + +public: + /** + * The level value of the light sensor data + * + * @since 2.0 + */ + float level; +}; // LightSensorData +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_LIGHT_SENSOR_DATA_H_ diff --git a/inc/FUixSensorMagneticSensorData.h b/inc/FUixSensorMagneticSensorData.h new file mode 100644 index 0000000..db2f262 --- /dev/null +++ b/inc/FUixSensorMagneticSensorData.h @@ -0,0 +1,130 @@ +// +// 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 FUixSensorMagneticSensorData.h + * @brief This is the header file for the %MagneticSensorData class. + * + * This header file contains the declarations of the %MagneticSensorData class. + */ + +#ifndef _FUIX_SENSOR_MAGNETIC_SENSOR_DATA_H_ +#define _FUIX_SENSOR_MAGNETIC_SENSOR_DATA_H_ + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +/** + * @class MagneticSensorData + * @brief This class stores magnetic sensor data, including a time stamp. + * + * @since 2.0 + * + * The %MagneticSensorData class stores magnetic sensor data, including a time stamp. + * + * For more information on the class features, see Sensor Manager. + */ +class _OSP_EXPORT_ MagneticSensorData + : public Tizen::Uix::Sensor::SensorData +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + MagneticSensorData(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~MagneticSensorData(void); + + /** + * Copying of objects using this copy constructor is allowed. + * + * @since 2.1 + * + * @param[in] rhs An instance of %MagneticSensorData to copy + */ + MagneticSensorData(const MagneticSensorData& rhs); + + /** + * Compares the equality of values between two %MagneticSensorData objects by overriding the Tizen::Base::Object::Equals() method. + * + * @since 2.1 + * + * @return @c true if all the fields in the objects are equal, @n + * else @c false + * @param[in] rhs The Tizen::Base::Object with which the comparison is done + * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method. + * + * @since 2.1 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Copying of objects using this copy assignment operator is allowed. + * + * @since 2.1 + * + * @return A reference to this instance + * @param[in] rhs An instance of %MagneticSensorData to copy + */ + MagneticSensorData& operator =(const MagneticSensorData& rhs); + +private: + virtual result GetValue(SensorDataKey dataKey, long& value) const; + virtual result GetValue(SensorDataKey dataKey, float& value) const; + virtual result GetValue(SensorDataKey dataKey, bool& value) const; + +public: + /** + * The x-axis value of the magnetic sensor data + * + * @since 2.0 + */ + float x; + + /** + * The y-axis value of the magnetic sensor data + * + * @since 2.0 + */ + float y; + + /** + * The z-axis value of the magnetic sensor data + * + * @since 2.0 + */ + float z; +}; // MagneticSensorData +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_MAGNETIC_SENSOR_DATA_H_ diff --git a/inc/FUixSensorMotion.h b/inc/FUixSensorMotion.h new file mode 100644 index 0000000..ebd4b5d --- /dev/null +++ b/inc/FUixSensorMotion.h @@ -0,0 +1,171 @@ +// +// 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 FUixSensorMotion.h + * @brief This is the header file for the %Motion class. + * + * This header file contains the declarations of the %Motion class. + */ + +#ifndef _FUIX_SENSOR_MOTION_H_ +#define _FUIX_SENSOR_MOTION_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ + +class _MotionImpl; + +/** + * @class Motion + * @brief This class is used to probe the state or receive an event about the conceptual states of the device's movement. + * + * @since 2.0 + * + * The %Motion class allows an application to know about the movement of the device. The information is given in 2 ways: + * the application probes the state or the application registers a listener and receives an event when a movement is observed. + * + * For more information on the class features, see Device Motions. + * + * The following example demonstrates how to use the %Motion class to register a motion event listener and receive motion events. + * + * @code + * class MotionExample : public Tizen::Uix::IMotionEventListener + * { + * public: + * result Initialize(); + * + * // IMotionEventListener + * void OnDoubleTapDetected(void); + * void OnShakeDetected(Tizen::Uix::Sensor::MotionState motionState); + * void OnSnapDetected(Tizen::Uix::Sensor::MotionSnapType snapType); + * + * private: + * Tizen::Uix::Sensor::Motion* pMotion; + * }; + * + * result MotionExample::Initialize(void) + * { + * pMotion = new Motion(); + * pMotion->Construct(*this); + * pMotion->SetEnabled(MOTION_TYPE_DOUBLETAP | MOTION_TYPE_SHAKE); + * + * return E_SUCCESS; + * } + * + * void + * MotionExample::OnDoubleTapDetected(void) + * { + * // .... + * } + * + * void + * MotionExample::OnShakeDetected(MotionState motionState) + * { + * // .... + * } + * + * void + * MotionExample::OnSnapDetected(MotionSnapType snapType) + * { + * // In this example, since Snap is not enabled, this listener will not be called. + * } + * @endcode + */ + +class _OSP_EXPORT_ Motion + : public Tizen::Base::Object +{ +// Lifecycle +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + Motion(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~Motion(void); + +//Operation +public: + /** + * Initializes this instance of %Motion with the specified @c listener. + * + * @since 2.0 + * + * @return An error code + * @param[in] listener An instance of IMotionEventListener + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_MAX_EXCEEDED The application has reached the maximum number of motion instances. + * @exception E_UNSUPPORTED_OPERATION The motion detection is not supported. + */ + result Construct(IMotionEventListener& listener); + + /** + * Sets the motion event type. @n + * If the %SetEnabled() method is not called, then by default all the motion event types are captured by the listener. + * If the motion events are not to be captured, this method can be called with @c type set to @c MOTION_TYPE_NONE. + * + * @since 2.0 + * + * @param[in] type The type of motions that are captured by a listener @n + * Multiple motion types of type Tizen::Uix::Sensor::MotionType can be combined using the logical OR operator. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_STATE This instance has not been constructed as yet. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + void SetEnabled(unsigned long type); + + /** + * Checks whether the specified @c type is supported. @n + * @c MOTION_TYPE_NONE and @c MOTION_TYPE_ALL are unsupported types, and @c false is returned for these types. + * + * @since 2.0 + * + * @return @c true if the specified motion type is supported, @n + * else @c false + * @param[in] type The type of the motion to query + */ + bool IsSupported(MotionType type) const; + +private: + Motion(const Motion& value); + Motion& operator =(const Motion& value); + +private: + _MotionImpl* __pMotionImpl; + friend class _MotionImpl; + +}; // Motion + +} } } // Tizen::Uix::Sensor + +#endif //_FUIX_SENSOR_MOTION_H_ diff --git a/inc/FUixSensorMotionCommon.h b/inc/FUixSensorMotionCommon.h new file mode 100644 index 0000000..5eb1f11 --- /dev/null +++ b/inc/FUixSensorMotionCommon.h @@ -0,0 +1,89 @@ +// +// 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 FUixSensorMotionCommon.h + * @brief This is the header file for the declarations of the enumerations of the %Sensor namespace. + * + * This header file contains the declarations of the enumerations of the Sensor namespace. + */ + +#ifndef _FUIX_SENSOR_MOTION_COMMON_H_ +#define _FUIX_SENSOR_MOTION_COMMON_H_ + +namespace Tizen { namespace Uix { namespace Sensor +{ + +/** + * @enum MotionType + * + * Defines the types of motions provided. + * + * @since 2.0 + * + * @see Motion::SetEnabled() + */ +enum MotionType +{ + MOTION_TYPE_NONE = 0x0000, /**< The motion type: None */ + MOTION_TYPE_SNAP = 0x0001, /**< The motion type: Snap */ + MOTION_TYPE_SHAKE = 0x0002, /**< The motion type: Shake */ + MOTION_TYPE_DOUBLETAP = 0x0004, /**< The motion type: Tap */ + MOTION_TYPE_MOVE_TO_EAR = 0x0008, /**< The motion type: Move to ear @b Since: @b 2.1 */ + MOTION_TYPE_ALL = 0xFFFF, /**< The motion type: All */ +}; + +/** + * @enum MotionState + * + * Defines the state of motions. @n + * Some events can only be found in a subset of the states described below. + * + * @since 2.0 + * + * @see IMotionEventListener::OnShakeDetected() + */ +enum MotionState +{ + MOTION_STARTED, /**< The specified motion has just started */ + MOTION_INPROGRESS, /**< The specified motion is happening */ + MOTION_ENDED, /**< The specified motion has just ended */ + MOTION_CANCELLED, /**< The specified motion has just cancelled */ +}; + +/** + * @enum MotionSnapType + * + * Defines the types of snap provided. + * + * @since 2.0 + * + * @see IMotionEventListener::OnSnapDetected() + */ +enum MotionSnapType +{ + MOTION_SNAP_X_POSITIVE, /**< Snaps to positive X */ + MOTION_SNAP_X_NEGATIVE, /**< Snaps to negative X */ + MOTION_SNAP_Y_POSITIVE, /**< Snaps to positive Y */ + MOTION_SNAP_Y_NEGATIVE, /**< Snaps to negative Y */ + MOTION_SNAP_Z_POSITIVE, /**< Snaps to positive Z */ + MOTION_SNAP_Z_NEGATIVE, /**< Snaps to negative Z */ +}; + +} } } // Tizen::Uix::Sensor + +#endif //_FUIX_SENSOR_MOTION_COMMON_H_ diff --git a/inc/FUixSensorProximitySensorData.h b/inc/FUixSensorProximitySensorData.h new file mode 100644 index 0000000..925a8f3 --- /dev/null +++ b/inc/FUixSensorProximitySensorData.h @@ -0,0 +1,128 @@ +// +// 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 FUixSensorProximitySensorData.h + * @brief This is the header file for the %ProximitySensorData class. + * + * This header file contains the declarations of the %ProximitySensorData class. + */ + +#ifndef _FUIX_SENSOR_PROXIMITY_SENSOR_DATA_H_ +#define _FUIX_SENSOR_PROXIMITY_SENSOR_DATA_H_ + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +/** + * @class ProximitySensorData + * @brief This class stores proximity sensor data, including a time stamp. + * + * @since 2.0 + * + * The %ProximitySensorData class stores proximity sensor data, including a time stamp. + * + * For more information on the class features, see Sensor Manager. + */ +class _OSP_EXPORT_ ProximitySensorData + : public Tizen::Uix::Sensor::SensorData +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + ProximitySensorData(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~ProximitySensorData(void); + + /** + * Checks whether the object is detected. + * + * @since 2.0 + * + * @return @c true if the object is detected, @n + * else @c false + */ + bool IsObjectDetected(void) const; + + /** + * Copying of objects using this copy constructor is allowed. + * + * @since 2.1 + * + * @param[in] rhs An instance of %ProximitySensorData to copy + */ + ProximitySensorData(const ProximitySensorData& rhs); + + /** + * Compares the equality of values between two %ProximitySensorData objects by overriding the Tizen::Base::Object::Equals() method. + * + * @since 2.1 + * + * @return @c true if all the fields in the objects are equal, @n + * else @c false + * @param[in] rhs The Tizen::Base::Object with which the comparison is done + * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method. + * + * @since 2.1 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Copying of objects using this copy assignment operator is allowed. + * + * @since 2.1 + * + * @return A reference to this instance + * @param[in] rhs An instance of %ProximitySensorData to copy + */ + ProximitySensorData& operator =(const ProximitySensorData& rhs); + +private: + virtual result GetValue(SensorDataKey dataKey, long& value) const; + virtual result GetValue(SensorDataKey dataKey, float& value) const; + virtual result GetValue(SensorDataKey dataKey, bool& value) const; + +public: + /** + * The distance value of the proximity sensor data + * @brief [Deprecated] + * @deprecated This member variable is deprecated because most proximity sensors do not provide distance value reliably. + * Instead of using this variable, use the IsObjectDetected(void) method. + * @since 2.0 + */ + float distance; +}; // ProximitySensorData +} } }// Tizen::Uix:Sensor + +#endif // _FUIX_SENSOR_PROXIMITY_SENSOR_DATA_H_ diff --git a/inc/FUixSensorSensorData.h b/inc/FUixSensorSensorData.h new file mode 100644 index 0000000..e9b2502 --- /dev/null +++ b/inc/FUixSensorSensorData.h @@ -0,0 +1,114 @@ +// +// 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 FUixSensorSensorData.h + * @brief This is the header file for the %SensorData class. + * + * This header file contains the declarations of the %SensorData class. + */ + +#ifndef _FUIX_SENSOR_SENSOR_DATA_H_ +#define _FUIX_SENSOR_SENSOR_DATA_H_ + +#include +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ + +/** + * @class SensorData + * @brief This class stores sensor data, including a time stamp. + * + * @since 2.0 + * + * The %SensorData class stores sensor data, including a time stamp. + * + * For more information on the class features, see Sensor Manager. + */ +class _OSP_EXPORT_ SensorData + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + SensorData(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~SensorData(void); + + /** + * Gets the sensor data with a @c long value as the key input. + * + * @since 2.0 + * + * @return An error code + * @param[in] dataKey The key to access the sensor data + * @param[out] value The @c long value that represents the sensor data requested by the user + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The data matching the specified key and data type cannot be found. + */ + virtual result GetValue(SensorDataKey dataKey, long& value) const; + + /** + * Gets the sensor data with a @c float value as the key input. + * + * @since 2.0 + * + * @return An error code + * @param[in] dataKey The key to access the sensor data + * @param[out] value The @c float value that represents the sensor data requested by the user + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The data matching the specified key and data type cannot be found. + */ + virtual result GetValue(SensorDataKey dataKey, float& value) const; + + /** + * Gets the sensor data with a @c bool value as the key input. + * + * @since 2.0 + * + * @return An error code + * @param[in] dataKey The key to access the sensor data + * @param[out] value The @c bool value that represents the sensor data requested by the user + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The data matching the specified key and data type cannot be found. + */ + virtual result GetValue(SensorDataKey dataKey, bool& value) const; + +public: + /** + * The time stamp of the sensor data. + * + * @since 2.0 + */ + long long timestamp; + +}; // SensorData + +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_SENSOR_DATA_H_ diff --git a/inc/FUixSensorSensorManager.h b/inc/FUixSensorSensorManager.h new file mode 100644 index 0000000..7cc2309 --- /dev/null +++ b/inc/FUixSensorSensorManager.h @@ -0,0 +1,754 @@ +// +// 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 FUixSensorSensorManager.h + * @brief This is the header file for the %SensorManager class. + * + * This header file contains the declarations of the %SensorManager class. + */ + +#ifndef _FUIX_SENSOR_SENSOR_MANAGER_H_ +#define _FUIX_SENSOR_SENSOR_MANAGER_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Base +{ +class String; +} } // Tizen::Base + +namespace Tizen { namespace Uix { namespace Sensor +{ + +/** + * @class SensorManager + * @brief This class is used to receive sensor data from the device. + * + * @since 2.0 + * + * The %SensorManager class is used to receive and manage sensor data from the device, including adding or removing the sensor + * listeners, checking sensor availability, setting intervals, and getting the maximum or minimum intervals. + * + * For more information on the class features, see Sensor Manager. + * + * The following examples demonstrate how to use the %SensorManager class with the acceleration sensor. + * + * @code + * //Sample code for SensorSample.h + * #include + * + * using namespace Tizen::Uix::Sensor; + * + * class SensorSample : public ISensorEventListener + * { + * public: + * SensorSample(void); + * virtual ~SensorSample(void); + * bool CreateSensor(void); + * + * virtual void OnDataReceived(SensorType sensorType, SensorData& sensorData, result r); + * + * private: + * SensorManager __sensorManager; + * }; + * + * //Sample code for SensorSample.cpp + * #include "SensorSample.h" + * + * SensorSample::SensorSample(void) + * { + * // Initializes the sensor manager + * __sensorManager.Construct(); + * } + * + * SensorSample::~SensorSample(void) + * { + * // Finalizes the sensor manager + * } + * + * void SensorSample::OnDataReceived(SensorType sensorType, SensorData& sensorData, result r) + * { + * // Adds your code. + * // Refers to API Reference to ISensorEventListener::OnDataReceived(). + * // Application APIs should not be called inside this event handler. + * // Overrides OnDataReceived() for just receiving the sensor data and copying it to the main application context. + * + * } + * + * bool SensorSample::CreateSensor(void) + * { + * result r = E_SUCCESS; + * + * if (__sensorManager.IsAvailable(SENSOR_TYPE_ACCELERATION)) + * { + * r = __sensorManager.AddSensorListener(*this, SENSOR_TYPE_ACCELERATION, 50, true); + * if (IsFailed(r)) + * { + * return false; + * } + * } + * else + * { + * AppLogException("Acceleration sensor is not available."); + * return false; + * } + * + * return true; + * } + * @endcode + */ +class _OSP_EXPORT_ SensorManager + : public Tizen::Base::Object +{ + +// Lifecycle +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + * + * @remarks After creating an instance of this class, the Construct() method + * must be called explicitly to initialize this instance. + */ + SensorManager(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + * + * @remarks All the listeners are removed + * and the internally allocated memory block is deleted when the instance is destroyed. + */ + virtual ~SensorManager(void); + + +// Operation +public: + /** + * Initializes this instance of %SensorManager. @n + * It includes initializing the sub-component of the sensor manager. + * + * @since 2.0 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result Construct(void); + + /** + * Adds a sensor listener when the sensor powers up for the first time. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerAddSensorListenerPage "here". + * @endif + * @return An error code + * @param[in] listener The listener to add + * @param[in] sensorType The sensor type + * @param[in] interval The interval (in milliseconds) at which the sensor data is received + * @param[in] dataChanged Set to @c true if the sensor data is received only when the sensor data is changed, @n + * else @c false if the sensor data is received at every interval + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_INVALID_ARG Either of the following conditions has occurred: + * - The specified @c interval is neither greater than the maximum interval nor less than the minimum interval. + * - The sensor type is invalid. + * @exception E_OPERATION_FAILED The operation has failed to add the sensor listener. + * @exception E_USER_ALREADY_REGISTERED The specified @c listener is already registered for the specified @c sensorType. + * @exception E_UNSUPPORTED_OPERATION The target device does not support the specific sensor. + */ + + result AddSensorListener(ISensorEventListener& listener, SensorType sensorType, long interval, bool dataChanged); + + /** + * @if OSPCOMPAT + * @page CompSensorManagerAddSensorListenerPage Compatibility for AddSensorListener() + * @section CompSensorManagerAddSensorListenerIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerAddSensorListenerSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Removes a sensor listener from all sensor types. @n + * Sensor powers down when every listener added to the type of sensor is removed. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerRemoveSensorListenerPage "here". + * @endif + * @return An error code + * @param[in] listener The listener to remove + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The specified @c listener is not found in the listener list. + * @exception E_OPERATION_FAILED The operation has failed to remove sensor listeners. + * @exception E_UNSUPPORTED_OPERATION The target device does not support the specific sensor. + */ + + result RemoveSensorListener(ISensorEventListener& listener); + + /** + * @if OSPCOMPAT + * @page CompSensorManagerRemoveSensorListenerPage Compatibility for RemoveSensorListener() + * @section CompSensorManagerRemoveSensorListenerIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerRemoveSensorListenerSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + + /** + * Removes a sensor listener from the sensor type. @n + * Sensor powers down when every listener added to the type of sensor is removed. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerRemoveSensorListenerPage "here". + * @endif + * @return An error code + * @param[in] listener The listener to remove + * @param[in] sensorType The sensor type + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND Either of the following conditions has occurred: + * - The specified @c listener is not found in the listener list. + * - The specified @c sensorType is invalid. + * @exception E_OPERATION_FAILED The operation has failed to remove the sensor listener. + * @exception E_UNSUPPORTED_OPERATION The target device does not support the specific sensor. + */ + result RemoveSensorListener(ISensorEventListener& listener, SensorType sensorType); + + /** + * @if OSPCOMPAT + * @page CompSensorManagerRemoveSensorListenerPage Compatibility for RemoveSensorListener () + * @section CompSensorManagerRemoveSensorListenerIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerRemoveSensorListenerSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * @cond OSPDEPREC + * Sets the interval of a sensor. + * @if OSPCOMPAT + * @brief [Deprecated] [Compatibility] + * @endif + * @deprecated This method is deprecated because it changes only the first listener's interval; the other listeners do not have an option to change their intervals. + * To resolve this, a new method has been added. Instead of using this method, use the SetInterval(ISensorEventListener& listener, SensorType sensorType, long interval) method. + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerSetIntervalPage "here". + * @endif + * @return An error code + * @param[in] sensorType The sensor type + * @param[in] interval The interval (in milliseconds) at which the sensor data is received + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either of the following conditions has occurred: + * - The specified @c interval is neither greater than the maximum interval nor less than the minimum interval. + * - The specified @c sensorType is invalid. + * @exception E_OPERATION_FAILED The operation has failed to set the interval of the sensor. + * @exception E_UNSUPPORTED_OPERATION The target device does not support the specific sensor. + * @see SensorManager::GetMaxInterval() for getting the maximum intervals + * @see SensorManager::GetMinInterval() for getting the minimum intervals + * @endcond + */ + + result SetInterval(SensorType sensorType, long interval); + + /** + * @if OSPCOMPAT + * @page CompSensorManagerSetIntervalPage Compatibility for SetInterval () + * @section CompSensorManagerSetIntervalIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerSetIntervalSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Sets the interval of a sensor using the specified @c listener. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerSetIntervalPage "here". + * @endif + * @return An error code + * @param[in] listener The added listener + * @param[in] sensorType The sensor type + * @param[in] interval The interval (in milliseconds) at which the sensor data is received + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG Either of the following conditions has occurred: + * - The specified @c interval is neither greater than the maximum interval nor less than the minimum interval. + * - The listener is not registered for this type of sensor. + * - The specified @c sensorType is invalid. + * @exception E_OPERATION_FAILED The operation has failed to set the interval of the sensor. + * @exception E_UNSUPPORTED_OPERATION The target device does not support the specific sensor. + * @see SensorManager::GetMaxInterval() for getting the maximum intervals + * @see SensorManager::GetMinInterval() for getting the minimum intervals + */ + result SetInterval(ISensorEventListener& listener, SensorType sensorType, long interval); + + /** + * @if OSPCOMPAT + * @page CompSensorManagerSetIntervalPage Compatibility for SetInterval () + * @section CompSensorManagerSetIntervalIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerSetIntervalSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Checks whether a sensor type is available on the device. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerIsAvailablePage "here". + * @endif + * @return @c true if the sensor type is available, @n + * else @c false + * @param[in] sensorType The sensor type + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The sensor type is invalid. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + bool IsAvailable(SensorType sensorType) const; + + /** + * @if OSPCOMPAT + * @page CompSensorManagerIsAvailablePage Compatibility for IsAvailable () + * @section CompSensorManagerIsAvailableIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerIsAvailableSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Gets the minimum interval of the sensor type. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerGetMinIntervalPage "here". + * @endif + * @return An error code + * @param[in] sensorType The sensor type + * @param[out] interval The minimum interval in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The sensor type is invalid. + * @exception E_OPERATION_FAILED The operation has failed to get interval of the sensor. + * @exception E_UNSUPPORTED_OPERATION The target device does not support the specific sensor. + */ + result GetMinInterval(SensorType sensorType, long& interval) const; + + /** + * @if OSPCOMPAT + * @page CompSensorManagerGetMinIntervalPage Compatibility for GetMinInterval() + * @section CompSensorManagerGetMinIntervalIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerGetMinIntervalSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Gets the maximum interval of the sensor type. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerGetMaxIntervalPage "here". + * @endif + * @return An error code + * @param[in] sensorType The sensor type + * @param[out] interval The maximum interval in milliseconds + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The sensor type is invalid. + * @exception E_OPERATION_FAILED The operation has failed to get interval of the sensor. + * @exception E_UNSUPPORTED_OPERATION The target device does not support the specific sensor. + */ + result GetMaxInterval(SensorType sensorType, long& interval) const; + + /** + * @if OSPCOMPAT + * @page CompSensorManagerGetMaxIntervalPage Compatibility for GetMaxInterval() + * @section CompSensorManagerGetMaxIntervalIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerGetMaxIntervalSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Gets a brief description on this sensor. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerGetDescriptionPage "here". + * @endif + * @return An error code + * @param[in] sensorType The sensor type + * @param[out] description The sensor description + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The sensor type is invalid. + * @exception E_OPERATION_FAILED The operation has failed to get the description of the sensor. + * @exception E_UNSUPPORTED_OPERATION The target device does not support the specific sensor. + */ + result GetDescription(SensorType sensorType, Tizen::Base::String& description) const; + + /** + * @if OSPCOMPAT + * @page CompSensorManagerGetDescriptionPage Compatibility for GetDescription() + * @section CompSensorManagerGetDescriptionIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerGetDescriptionSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Gets the sensor's vendor information. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerGetVendorPage "here". + * @endif + * @return An error code + * @param[in] sensorType The sensor type + * @param[out] vendor The vendor information + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The sensor type is invalid. + * @exception E_OPERATION_FAILED The operation has failed to get the vendor information of the sensor. + * @exception E_UNSUPPORTED_OPERATION The target device does not support the specific sensor. + */ + result GetVendor(SensorType sensorType, Tizen::Base::String& vendor) const; + + /** + * @if OSPCOMPAT + * @page CompSensorManagerGetVendorPage Compatibility for GetVendor() + * @section CompSensorManagerGetVendorIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerGetVendorSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Gets the sensor's model ID. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerGetModelIdPage "here". + * @endif + * @return An error code + * @param[in] sensorType The sensor type + * @param[out] modelId The model ID of the sensor hardware + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The sensor type is invalid. + * @exception E_OPERATION_FAILED The operation has failed to get the model ID of the sensor. + * @exception E_UNSUPPORTED_OPERATION The target device does not support the specific sensor. + */ + result GetModelId(SensorType sensorType, Tizen::Base::String& modelId) const; + + /** + * @if OSPCOMPAT + * @page CompSensorManagerGetModelIdPage Compatibility for GetModelId() + * @section CompSensorManagerGetModelIdIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerGetModelIdSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Gets the measurement range of the sensor. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerGetMeasurementRangePage "here". + * @endif + * @return An error code + * @param[in] sensorType The sensor type + * @param[out] min The minimum value of the measurement range + * @param[out] max The maximum value of the measurement range + * @param[out] resolution The resolution of the sensor measurement, that is, Measurement/bit @n + * This is a device specific characteristic. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The sensor type is invalid. + * @exception E_OPERATION_FAILED The operation has failed. + * @exception E_UNSUPPORTED_OPERATION The target device does not support the specific sensor. + */ + result GetMeasurementRange(SensorType sensorType, float& min, float& max, float& resolution) const; + + /** + * @if OSPCOMPAT + * @page CompSensorManagerGetMeasurementRangePage Compatibility for GetMeasurementRange() + * @section CompSensorManagerGetMeasurementRangeIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor. + * + * @section CompSensorManagerGetMeasurementRangeSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Checks whether the wake up feature is supported for the specified sensor type. @n + * The return value can vary depending on a specific device model. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerIsWakeupSupportedPage "here". + * @endif + * @return @c true if the sensor type supports the wake up feature while the device is in the sleep mode, @n + * else @c false if the wake up feature is not supported by the sensor or the instance is not initialized properly + * @param[in] sensorType The sensor type + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The sensor type is invalid. + * @exception E_OPERATION_FAILED The operation has failed. + * @exception E_UNSUPPORTED_OPERATION Either of the following conditions has occurred: + * - The target device does not support the specific sensor. + * - The target device does not support the wake-up feature originally or based on the specific sensor. + * @remarks + * - The specific error code can be accessed using the GetLastResult() method. + * - This method cannot be tested on the Emulator. It always returns @c true on the Emulator. + */ + bool IsWakeupSupported(SensorType sensorType) const; + + /** + * @if OSPCOMPAT + * @page CompSensorManagerIsWakeupSupportedPage Compatibility for IsWakeupSupported() + * @section CompSensorManagerIsWakeupSupportedIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor or @n + * the target device does not support the wake-up feature originally or based on the specific sensor. + * + * @section CompSensorManagerIsWakeupSupportedSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Sets the application-wise wake up feature as enabled or disabled for the specified sensor type. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerSetWakeupEnabledPage "here". + * @endif + * @feature %http://tizen.org/feature/sensor.accelerometer.wakeup + * @return An error code + * @param[in] sensorType The sensor type + * @param[in] enable Set to @c true to enable the wake up feature, @n + * else @c false to disable the wake up feature + * @exception E_SUCCESS The method is successful. + * @exception E_OPERATION_FAILED The method has failed to set the wake up option. + * @exception E_INVALID_STATE There is no sensor listener registered for this type. + * @exception E_INVALID_ARG The sensor type is invalid. + * @exception E_OPERATION_FAILED The operation has failed. + * @exception E_UNSUPPORTED_OPERATION Either of the following conditions has occurred: + * - The target device does not support the specific sensor. + * - The target device does not support the wake-up feature originally or based on the specific sensor. + * @remarks + * - The wake up feature is automatically disabled by the system as soon as the calling application is terminated. + * - This method cannot be tested on the Emulator. It always returns @c E_SUCCESS on the Emulator. + * - Before calling this method, check whether the feature is supported by Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&). + */ + result SetWakeupEnabled(SensorType sensorType, bool enable); + + /** + * @if OSPCOMPAT + * @page CompSensorManagerSetWakeupEnabledPage Compatibility for SetWakeupEnabled() + * @section CompSensorManagerSetWakeupEnabledIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor or @n + * the target device does not support the wake-up feature originally or based on the specific sensor. + * + * @section CompSensorManagerSetWakeupEnabledSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + + /** + * Checks whether the wake up feature is enabled for the specified sensor type. + * @if OSPCOMPAT + * @brief [Compatibility] + * @endif + * @since 2.0 + * + * @if OSPCOMPAT + * @compatibility This method has compatibility issues with OSP compatible applications. @n + * For more information, see @ref CompSensorManagerIsWakeupEnabledPage "here". + * @endif + * @feature %http://tizen.org/feature/sensor.accelerometer.wakeup + * @return @c true if the wakeup feature is enabled for the specified sensor type for the calling application, @n + * else @c false + * @param[in] sensorType The sensor type + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The sensor type is invalid. + * @exception E_OPERATION_FAILED The operation has failed. + * @exception E_UNSUPPORTED_OPERATION Either of the following conditions has occurred: + * - The target device does not support the specific sensor. + * - The target device does not support the wake-up feature originally or based on the specific sensor. + * @remarks + * - The specific error code can be accessed using the GetLastResult() method. + * - This method cannot be tested on the Emulator. It always returns @c true on the Emulator. + * - Before calling this method, check whether the feature is supported by Tizen::System::SystemInfo::GetValue(const Tizen::Base::String&, bool&). + */ + bool IsWakeupEnabled(SensorType sensorType) const; + + /** + * @if OSPCOMPAT + * @page CompSensorManagerIsWakeupEnabledPage Compatibility for IsWakeupEnabled() + * @section CompSensorManagerIsWakeupEnabledIssueSection Issues + * Implementing this method in OSP compatible applications has the following issues: @n + * -# The method returns @c E_DEVICE_UNAVAILABLE if the target device does not support the specific sensor or @n + * the target device does not support the wake-up feature originally or based on the specific sensor. + * + * @section CompSensorManagerIsWakeupEnabledSolutionSection Resolutions + * This issue has been resolved in Tizen. @n + * -# The method returns @c E_UNSUPPORTED_OPERATION if the target device does not support the specific sensor. + * -# @c E_DEVICE_UNAVAILABLE exception is removed. + * @endif + */ + +private: + /** + * This is the copy constructor for %SensorManager class. + * + * @since 2.0 + */ + SensorManager(const SensorManager& sensorManager); + + /** + * Assigns the value of the specified %SensorManager object to the current instance. + * + * @since 2.0 + */ + SensorManager& operator =(const SensorManager& sensorManager); + +private: + class _SensorManagerImpl* __pSensorManagerImpl; + friend class _SensorManagerImpl; + +}; // SensorManager + +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_SENSOR_MANAGER_H_ diff --git a/inc/FUixSensorSensorTypes.h b/inc/FUixSensorSensorTypes.h new file mode 100644 index 0000000..fb1b425 --- /dev/null +++ b/inc/FUixSensorSensorTypes.h @@ -0,0 +1,141 @@ +// +// 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 FUixSensorSensorTypes.h + * @brief This is the header file for the common data types used by the %SensorData and %SensorManager classes. + * + * This header file contains the declarations of the common data types and constants used by the SensorData and SensorManager classes. + */ + +#ifndef _FUIX_SENSOR_SENSOR_TYPES_H_ +#define _FUIX_SENSOR_SENSOR_TYPES_H_ + +namespace Tizen { namespace Uix { namespace Sensor +{ + +/** +* @enum SensorType +* +* Defines the sensor type. +* +* @since 2.0 +*/ +enum SensorType +{ + SENSOR_TYPE_ACCELERATION = 0, /**< The acceleration sensor type */ + SENSOR_TYPE_MAGNETIC, /**< The magnetic sensor type */ + SENSOR_TYPE_PROXIMITY, /**< The proximity sensor type */ + SENSOR_TYPE_TILT, /**< The tilt sensor type */ + SENSOR_TYPE_GYRO, /**< The gyro sensor type */ + SENSOR_TYPE_LIGHT, /**< The light sensor type */ + SENSOR_TYPE_GRAVITY, /**< The gravity sensor type @b Since: @b 2.1 */ + SENSOR_TYPE_USER_ACCELERATION, /**< The user-acceleration sensor type @b Since: @b 2.1 */ + SENSOR_TYPE_DEVICE_ORIENTATION, /**< The device-orientation sensor type @b Since: @b 2.1 */ + SENSOR_TYPE_MAX, // This enum value is for internal use only. + // Using this enum value can cause behavioral, + // security-related, and consistency-related + // issues in the application. + SENSOR_TYPE_NONE = -1, // This enum value is for internal use only. + // Using this enum value can cause behavioral, + // security-related, and consistency-related + // issues in the application. +}; + +/** +* @enum SensorDataKey +* +* Defines the default key types for the SensorData class. +* +* @since 2.0 +* +* @remarks Use the actual key type, such as Tizen::Uix::Sensor::AccelerationDataKey, Tizen::Uix::Sensor::MagneticDataKey, Tizen::Uix::Sensor::ProximityDataKey, or Tizen::Uix::Sensor::TiltDataKey with type casting. For example, use Tizen::Uix::Sensor::SensorData::GetValue(static_cast(ACCELERATION_DATA_KEY_X), value) to get the acceleration value on the x-axis. +*/ +enum SensorDataKey +{ + SENSOR_DATA_KEY_0 = 0, + SENSOR_DATA_KEY_1, + SENSOR_DATA_KEY_2, + SENSOR_DATA_KEY_3, + SENSOR_DATA_KEY_4 +}; + +/** +* @enum AccelerationDataKey +* +* Defines the keys to access the acceleration sensor data. +* +* @since 2.0 +*/ +enum AccelerationDataKey +{ + ACCELERATION_DATA_KEY_TIMESTAMP = 256, /**< The key to the timestamp of the acceleration sensor data */ + ACCELERATION_DATA_KEY_X, /**< The key to the x-axis of the acceleration sensor data */ + ACCELERATION_DATA_KEY_Y, /**< The key to the y-axis of the acceleration sensor data */ + ACCELERATION_DATA_KEY_Z, /**< The key to the z-axis of the acceleration sensor data */ + ACCELERATION_DATA_KEY_COUNT = 4 /**< The number of indices for the acceleration sensor data */ +}; + +/** +* @enum MagneticDataKey +* +* Defines the keys to access the magnetic sensor data. +* +* @since 2.0 +*/ +enum MagneticDataKey +{ + MAGNETIC_DATA_KEY_TIMESTAMP = 266, /**< The key to the timestamp of the magnetic sensor data */ + MAGNETIC_DATA_KEY_X, /**< The key to the x-axis of the magnetic sensor data */ + MAGNETIC_DATA_KEY_Y, /**< The key to the y-axis of the magnetic sensor data */ + MAGNETIC_DATA_KEY_Z, /**< The key to the z-axis of the magnetic sensor data */ + MAGNETIC_DATA_KEY_COUNT = 4 /**< The number of indices to access the magnetic sensor data */ +}; + +/** +* @enum ProximityDataKey +* +* Defines the keys to access the proximity sensor data. +* +* @since 2.0 +*/ +enum ProximityDataKey +{ + PROXIMITY_DATA_KEY_TIMESTAMP = 276, /**< The key to the timestamp of the proximity sensor data */ + PROXIMITY_DATA_KEY_ONOFF, /**< The key to on/off the proximity sensor data */ + PROXIMITY_DATA_KEY_COUNT = 2 /**< The number of indices to access the proximity sensor data */ +}; + +/** +* @enum TiltDataKey +* +* Defines the keys to access the tilt sensor data. +* +* @since 2.0 +*/ +enum TiltDataKey +{ + TILT_DATA_KEY_TIMESTAMP = 286, /**< The key to the timestamp of the tilt sensor data */ + TILT_DATA_KEY_AZIMUTH, /**< The key to the azimuth of the tilt sensor data */ + TILT_DATA_KEY_PITCH, /**< The key to the pitch of the tilt sensor data */ + TILT_DATA_KEY_ROLL, /**< The key to the roll of the tilt sensor data */ + TILT_DATA_KEY_COUNT = 4 /**< The number of indices to access the tilt sensor data */ +}; + +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_SENSOR_TYPES_H_ diff --git a/inc/FUixSensorTiltSensorData.h b/inc/FUixSensorTiltSensorData.h new file mode 100644 index 0000000..cb1b4be --- /dev/null +++ b/inc/FUixSensorTiltSensorData.h @@ -0,0 +1,132 @@ +// +// 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 FUixSensorTiltSensorData.h + * @brief This is the header file for the %TiltSensorData class. + * + * This header file contains the declarations of the %TiltSensorData class. + */ + +#ifndef _FUIX_SENSOR_TILT_SENSOR_DATA_H_ +#define _FUIX_SENSOR_TILT_SENSOR_DATA_H_ + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +/** + * @class TiltSensorData + * @brief This class stores tilt sensor data, including a time stamp. + * + * @since 2.0 + * + * The %TiltSensorData class stores tilt sensor data, including a time stamp. + * + * For more information on the class features, see Sensor Manager. + */ +class _OSP_EXPORT_ TiltSensorData + : public Tizen::Uix::Sensor::SensorData +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + TiltSensorData(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~TiltSensorData(void); + + /** + * Copying of objects using this copy constructor is allowed. + * + * @since 2.1 + * + * @param[in] rhs An instance of %TiltSensorData to copy + */ + TiltSensorData(const TiltSensorData& rhs); + + /** + * Compares the equality of values between two %TiltSensorData objects by overriding the Tizen::Base::Object::Equals() method. + * + * @since 2.1 + * + * @return @c true if all the fields in the objects are equal, @n + * else @c false + * @param[in] rhs The Tizen::Base::Object with which the comparison is done + * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method. + * + * @since 2.1 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Copying of objects using this copy assignment operator is allowed. + * + * @since 2.1 + * + * @return A reference to this instance + * @param[in] rhs An instance of %TiltSensorData to copy + */ + TiltSensorData& operator =(const TiltSensorData& rhs); + + + +private: + virtual result GetValue(SensorDataKey dataKey, long& value) const; + virtual result GetValue(SensorDataKey dataKey, float& value) const; + virtual result GetValue(SensorDataKey dataKey, bool& value) const; + +public: + /** + * The roll value of the tilt sensor data + * + * @since 2.0 + */ + float roll; + + /** + * The pitch value of the tilt sensor data + * + * @since 2.0 + */ + float pitch; + + /** + * The azimuth value of the tilt sensor data + * + * @since 2.0 + */ + float azimuth; +}; // TiltSensorData +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_TILT_SENSOR_DATA_H_ diff --git a/inc/FUixSensorUserAccelerationSensorData.h b/inc/FUixSensorUserAccelerationSensorData.h new file mode 100644 index 0000000..d876190 --- /dev/null +++ b/inc/FUixSensorUserAccelerationSensorData.h @@ -0,0 +1,130 @@ +// +// 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 FUixSensorUserAccelerationSensorData.h + * @brief This is the header file for the %UserAccelerationSensorData class. + * + * This header file contains the declarations of the %UserAccelerationSensorData class. + */ + +#ifndef _FUIX_SENSOR_USER_ACCELERATION_SENSOR_DATA_H_ +#define _FUIX_SENSOR_USER_ACCELERATION_SENSOR_DATA_H_ + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +/** + * @class UserAccelerationSensorData + * @brief This class stores user-acceleration sensor data, including a time stamp. + * + * @since 2.1 + * + * The %UserAccelerationSensorData class stores user-acceleration sensor data, including a time stamp. + * @n + * For more information on the class features, see Sensor Manager. + */ +class _OSP_EXPORT_ UserAccelerationSensorData + : public Tizen::Uix::Sensor::SensorData +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.1 + */ + UserAccelerationSensorData(void); + + /** + * This is the destructor for this class. + * + * @since 2.1 + */ + virtual ~UserAccelerationSensorData(void); + + /** + * Copying of objects using this copy constructor is allowed. + * + * @since 2.1 + * + * @param[in] rhs An instance of %UserAccelerationSensorData to copy + */ + UserAccelerationSensorData(const UserAccelerationSensorData& rhs); + + /** + * Compares the equality of values between two %UserAccelerationSensorData objects by overriding the Tizen::Base::Object::Equals() method. + * + * @since 2.1 + * + * @return @c true if all the fields in the objects are equal, @n + * else @c false + * @param[in] rhs The Tizen::Base::Object with which the comparison is done + * @remarks An instance of Tizen::Graphics::Bitmap is not taken into account in the comparisons. + */ + virtual bool Equals(const Tizen::Base::Object& rhs) const; + + /** + * Gets the hash value of the current instance by overriding the Tizen::Base::Object::GetHashCode() method. + * + * @since 2.1 + * + * @return The hash value of the current instance + */ + virtual int GetHashCode(void) const; + + /** + * Copying of objects using this copy assignment operator is allowed. + * + * @since 2.1 + * + * @return A reference to this instance + * @param[in] rhs An instance of %UserAccelerationSensorData to copy + */ + UserAccelerationSensorData& operator =(const UserAccelerationSensorData& rhs); + +private: + virtual result GetValue(SensorDataKey dataKey, long& value) const; + virtual result GetValue(SensorDataKey dataKey, float& value) const; + virtual result GetValue(SensorDataKey dataKey, bool& value) const; + +public: + /** + * The x-axis value of the user-acceleration sensor data + * + * @since 2.1 + */ + float x; + + /** + * The y-axis value of the user-acceleration sensor data + * + * @since 2.1 + */ + float y; + + /** + * The z-axis value of the user-acceleration sensor data + * + * @since 2.1 + */ + float z; +}; // UserAccelerationSensorData +} } } // Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_USER_ACCELERATION_SENSOR_DATA_H_ diff --git a/osp-uix.manifest b/osp-uix.manifest new file mode 100644 index 0000000..ae3e6f7 --- /dev/null +++ b/osp-uix.manifest @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/osp-uix.pc.in b/osp-uix.pc.in new file mode 100755 index 0000000..eb6c3b7 --- /dev/null +++ b/osp-uix.pc.in @@ -0,0 +1,14 @@ +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=/usr/lib/osp +includedir=/usr/include/osp + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} + diff --git a/packaging/osp-uix.spec b/packaging/osp-uix.spec new file mode 100644 index 0000000..d75d4a2 --- /dev/null +++ b/packaging/osp-uix.spec @@ -0,0 +1,96 @@ +%define debug_package %{nil} +%define __strip /bin/true + +Name: osp-uix +Summary: osp uix library +Version: 1.2.2.0 +Release: 2 +Group: System/Libraries +License: Apache-2.0, Flora-1.1 +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(sensor) +BuildRequires: pkgconfig(capi-system-sensor) +BuildRequires: pkgconfig(osp-appfw) +BuildRequires: osp-appfw-internal-devel + +# runtime requires +Requires: osp-appfw + +%description +osp uix library + +%package devel +Summary: osp uix library (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description devel +osp uix library (DEV) + +%package internal-devel +Summary: osp uix library (Internal) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description internal-devel +osp uix library (Internal-DEV) + +%package debug +Summary: osp uix library (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description debug +osp uix library (DEV) + +%prep +%setup -q + +%build +%if 0%{?tizen_build_binary_release_type_eng} +CXXFLAGS="$CXXFLAGS -D_SECURE_LOG" +%endif +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +%ifarch %{ix86} +%if 0%{?simulator} +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ -D_OSP_EMUL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%else +CXXFLAGS="$CXXFLAGS -D_OSP_DEBUG_ -D_OSP_X86_ " cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%endif +%else +%if 0%{?tizen_build_binary_release_type_eng} +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_SECURE_LOG -D_OSP_ARMEL_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%else +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_" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +%endif +%endif + +# 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} +cat %{_builddir}/%{name}-%{version}/LICENSE.Flora >> %{buildroot}/usr/share/license/%{name} +%make_install + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files +%manifest osp-uix.manifest +/usr/share/license/%{name} +%{_libdir}/osp/*.so* + +%files devel +%{_includedir}/osp/*.h +%{_libdir}/pkgconfig/osp-uix.pc + +%files internal-devel +%{_includedir}/osp/uix/*.h + +%files debug +%{_libdir}/osp/debug/*.so* diff --git a/src/FUixSensorAccelerationSensorData.cpp b/src/FUixSensorAccelerationSensorData.cpp new file mode 100644 index 0000000..685f02a --- /dev/null +++ b/src/FUixSensorAccelerationSensorData.cpp @@ -0,0 +1,168 @@ +// +// 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 FUixSensorAccelerationSensorData.cpp + * @brief This is the implementation file for the %AccelerationSensorData class. + * + * This files contains implementation of the %AccelerationSensorData class. + */ + +// Includes +#include +#include +#include +#include +#include +#include "FUixSensor_SensorUtil.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found."; +} // Anonymous + +AccelerationSensorData::AccelerationSensorData(void) + : x(0.0F) + , y(0.0F) + , z(0.0F) +{ + +} + +AccelerationSensorData::~AccelerationSensorData(void) +{ + +} + +AccelerationSensorData::AccelerationSensorData(const AccelerationSensorData& rhs) + :x(rhs.x) + ,y(rhs.y) + ,z(rhs.z) +{ + +} + +AccelerationSensorData& +AccelerationSensorData::operator =(const AccelerationSensorData& rhs) +{ + // check for self-assignment + if (this != &rhs) + { + timestamp = rhs.timestamp; + x = rhs.x; + y = rhs.y; + z = rhs.z; + } + + return *this; +} + +int +AccelerationSensorData::GetHashCode(void) const +{ + int hash = 0; + + hash += LongLong::GetHashCode(this->timestamp); + hash += Float::GetHashCode(this->x); + hash += Float::GetHashCode(this->y); + hash += Float::GetHashCode(this->z); + + return hash; +} + +bool +AccelerationSensorData::Equals(const Object& rhs) const +{ + const AccelerationSensorData* pRhs = dynamic_cast (&rhs); + if (pRhs == null) + { + return false; + } + + if (this->timestamp != pRhs->timestamp) + { + return false; + } + + if (this->x != pRhs->x) + { + return false; + } + + if (this->y != pRhs->y) + { + return false; + } + + if (this->z != pRhs->z) + { + return false; + } + + + return true; +} + +result +AccelerationSensorData::GetValue(SensorDataKey dataKey, long& value) const +{ + switch (static_cast(dataKey)) + { + case ACCELERATION_DATA_KEY_TIMESTAMP: + value = _SensorUtil::CutTimestamp(timestamp); + break; + default: + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; + } + + return E_SUCCESS; +} + +result +AccelerationSensorData::GetValue(SensorDataKey dataKey, float& value) const +{ + switch (static_cast(dataKey)) + { + case ACCELERATION_DATA_KEY_X: + value = x; + break; + case ACCELERATION_DATA_KEY_Y: + value = y; + break; + case ACCELERATION_DATA_KEY_Z: + value = z; + break; + default: + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; + } + + return E_SUCCESS; +} + +result +AccelerationSensorData::GetValue(SensorDataKey dataKey, bool& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensorDeviceOrientationSensorData.cpp b/src/FUixSensorDeviceOrientationSensorData.cpp new file mode 100644 index 0000000..86c3b49 --- /dev/null +++ b/src/FUixSensorDeviceOrientationSensorData.cpp @@ -0,0 +1,143 @@ +// +// 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 FUixSensorDeviceOrientationSensorData.cpp + * @brief This is the implementation file for the %DeviceOrientationSensorData class. + * + * This files contains implementation of the %TiltSensorData class. + */ + +// Includes +#include +#include +#include +#include + +#include +#include "FUixSensor_SensorUtil.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found."; +} // Anonymous + +DeviceOrientationSensorData::DeviceOrientationSensorData(void) + : yaw(0.0F) + , roll(0.0F) + , pitch(0.0F) +{ + +} + +DeviceOrientationSensorData::~DeviceOrientationSensorData(void) +{ + +} + +DeviceOrientationSensorData::DeviceOrientationSensorData(const DeviceOrientationSensorData& rhs) + :yaw(rhs.yaw) + ,roll(rhs.roll) + ,pitch(rhs.pitch) +{ + +} + +DeviceOrientationSensorData& +DeviceOrientationSensorData::operator =(const DeviceOrientationSensorData& rhs) +{ + // check for self-assignment + if (this != &rhs) + { + timestamp = rhs.timestamp; + yaw = rhs.yaw; + roll = rhs.roll; + pitch = rhs.pitch; + } + + return *this; +} + +int +DeviceOrientationSensorData::GetHashCode(void) const +{ + int hash = 0; + + hash += LongLong::GetHashCode(this->timestamp); + hash += Float::GetHashCode(this->yaw); + hash += Float::GetHashCode(this->roll); + hash += Float::GetHashCode(this->pitch); + + return hash; +} + +bool +DeviceOrientationSensorData::Equals(const Object& rhs) const +{ + const DeviceOrientationSensorData* pRhs = dynamic_cast (&rhs); + if (pRhs == null) + { + return false; + } + + if (this->timestamp != pRhs->timestamp) + { + return false; + } + + if (this->roll != pRhs->roll) + { + return false; + } + + if (this->roll != pRhs->roll) + { + return false; + } + + if (this->pitch != pRhs->pitch) + { + return false; + } + return true; +} + +result +DeviceOrientationSensorData::GetValue(SensorDataKey dataKey, long& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +DeviceOrientationSensorData::GetValue(SensorDataKey dataKey, float& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +DeviceOrientationSensorData::GetValue(SensorDataKey dataKey, bool& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensorGravitySensorData.cpp b/src/FUixSensorGravitySensorData.cpp new file mode 100644 index 0000000..9f8286e --- /dev/null +++ b/src/FUixSensorGravitySensorData.cpp @@ -0,0 +1,143 @@ +// +// 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 FUixSensorGravitySensorData.cpp + * @brief This is the implementation file for the %GravitySensorData class. + * + * This files contains implementation of the %GravitySensorData class. + */ + +// Includes +#include +#include +#include +#include + +#include +#include "FUixSensor_SensorUtil.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found."; +} // Anonymous + +GravitySensorData::GravitySensorData(void) + : x(0.0F) + , y(0.0F) + , z(0.0F) +{ + +} + +GravitySensorData::~GravitySensorData(void) +{ + +} + +GravitySensorData::GravitySensorData(const GravitySensorData& rhs) + :x(rhs.x) + ,y(rhs.y) + ,z(rhs.z) +{ + +} + +GravitySensorData& +GravitySensorData::operator =(const GravitySensorData& rhs) +{ + // check for self-assignment + if (this != &rhs) + { + timestamp = rhs.timestamp; + x = rhs.x; + y = rhs.y; + z = rhs.z; + } + + return *this; +} + +int +GravitySensorData::GetHashCode(void) const +{ + int hash = 0; + + hash += LongLong::GetHashCode(this->timestamp); + hash += Float::GetHashCode(this->x); + hash += Float::GetHashCode(this->y); + hash += Float::GetHashCode(this->z); + + return hash; +} + +bool +GravitySensorData::Equals(const Object& rhs) const +{ + const GravitySensorData* pRhs = dynamic_cast (&rhs); + if (pRhs == null) + { + return false; + } + + if (this->timestamp != pRhs->timestamp) + { + return false; + } + + if (this->x != pRhs->x) + { + return false; + } + + if (this->y != pRhs->y) + { + return false; + } + + if (this->z != pRhs->z) + { + return false; + } + return true; +} + +result +GravitySensorData::GetValue(SensorDataKey dataKey, long& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +GravitySensorData::GetValue(SensorDataKey dataKey, float& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +GravitySensorData::GetValue(SensorDataKey dataKey, bool& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} +} } } // Tizen::Uix::Sensor diff --git a/src/FUixSensorGyroSensorData.cpp b/src/FUixSensorGyroSensorData.cpp new file mode 100644 index 0000000..75c46c0 --- /dev/null +++ b/src/FUixSensorGyroSensorData.cpp @@ -0,0 +1,143 @@ +// +// 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 FUixSensorGyroSensorData.cpp + * @brief This is the implementation file for the %GyroSensorData class. + * + * This files contains implementation of the %GyroSensorData class. + */ + +// Includes +#include +#include +#include +#include + +#include + +using namespace Tizen::Base; + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found."; +} // Anonymous + +GyroSensorData::GyroSensorData(void) + : x(0.0F) + , y(0.0F) + , z(0.0F) +{ + +} + +GyroSensorData::~GyroSensorData(void) +{ + +} + +GyroSensorData::GyroSensorData(const GyroSensorData& rhs) + :x(rhs.x) + ,y(rhs.y) + ,z(rhs.z) +{ + +} + +GyroSensorData& +GyroSensorData::operator =(const GyroSensorData& rhs) +{ + // check for self-assignment + if (this != &rhs) + { + timestamp = rhs.timestamp; + x = rhs.x; + y = rhs.y; + z = rhs.z; + } + + return *this; +} + +int +GyroSensorData::GetHashCode(void) const +{ + int hash = 0; + + hash += LongLong::GetHashCode(this->timestamp); + hash += Float::GetHashCode(this->x); + hash += Float::GetHashCode(this->y); + hash += Float::GetHashCode(this->z); + + return hash; +} + +bool +GyroSensorData::Equals(const Object& rhs) const +{ + const GyroSensorData* pRhs = dynamic_cast (&rhs); + if (pRhs == null) + { + return false; + } + + if (this->timestamp != pRhs->timestamp) + { + return false; + } + + if (this->x != pRhs->x) + { + return false; + } + + if (this->y != pRhs->y) + { + return false; + } + + if (this->z != pRhs->z) + { + return false; + } + + return true; +} + +result +GyroSensorData::GetValue(SensorDataKey dataKey, long& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +GyroSensorData::GetValue(SensorDataKey dataKey, float& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +GyroSensorData::GetValue(SensorDataKey dataKey, bool& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensorLightSensorData.cpp b/src/FUixSensorLightSensorData.cpp new file mode 100644 index 0000000..8ad4426 --- /dev/null +++ b/src/FUixSensorLightSensorData.cpp @@ -0,0 +1,124 @@ +// +// 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 FUixSensorLightSensorData.cpp + * @brief This is the implementation file for the %LightSensorData class. + * + * This files contains implementation of the %LightSensorData class. + */ + +// Includes +#include +#include +#include +#include + +#include + +using namespace Tizen::Base; + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found."; +} // Anonymous + +LightSensorData::LightSensorData(void) + : level(0.0F) +{ + +} + +LightSensorData::~LightSensorData(void) +{ + +} + +LightSensorData::LightSensorData(const LightSensorData& rhs) + :level(rhs.level) +{ + +} + +LightSensorData& +LightSensorData::operator =(const LightSensorData& rhs) +{ + // check for self-assignment + if (this != &rhs) + { + timestamp = rhs.timestamp; + level = rhs.level; + } + + return *this; +} + +int +LightSensorData::GetHashCode(void) const +{ + int hash = 0; + + hash += LongLong::GetHashCode(this->timestamp); + hash += Float::GetHashCode(this->level); + + return hash; +} + +bool +LightSensorData::Equals(const Object& rhs) const +{ + const LightSensorData* pRhs = dynamic_cast (&rhs); + if (pRhs == null) + { + return false; + } + + if (this->timestamp != pRhs->timestamp) + { + return false; + } + + if (this->level != pRhs->level) + { + return false; + } + + return true; +} +result +LightSensorData::GetValue(SensorDataKey dataKey, long& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +LightSensorData::GetValue(SensorDataKey dataKey, float& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +LightSensorData::GetValue(SensorDataKey dataKey, bool& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensorMagneticSensorData.cpp b/src/FUixSensorMagneticSensorData.cpp new file mode 100644 index 0000000..a7ca4ac --- /dev/null +++ b/src/FUixSensorMagneticSensorData.cpp @@ -0,0 +1,167 @@ +// +// 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 FUixSensorMagneticSensorData.cpp + * @brief This is the implementation file for the %MagneticSensorData class. + * + * This files contains implementation of the %MagneticSensorData class. + */ + +// Includes +#include +#include +#include +#include +#include +#include "FUixSensor_SensorUtil.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found."; +} // Anonymous + +MagneticSensorData::MagneticSensorData(void) + : x(0.0F) + , y(0.0F) + , z(0.0F) +{ + +} + +MagneticSensorData::~MagneticSensorData(void) +{ + +} + +MagneticSensorData::MagneticSensorData(const MagneticSensorData& rhs) + :x(rhs.x) + ,y(rhs.y) + ,z(rhs.z) +{ + +} + +MagneticSensorData& +MagneticSensorData::operator =(const MagneticSensorData& rhs) +{ + // check for self-assignment + if (this != &rhs) + { + timestamp = rhs.timestamp; + x = rhs.x; + y = rhs.y; + z = rhs.z; + } + + return *this; +} + +int +MagneticSensorData::GetHashCode(void) const +{ + int hash = 0; + + hash += LongLong::GetHashCode(this->timestamp); + hash += Float::GetHashCode(this->x); + hash += Float::GetHashCode(this->y); + hash += Float::GetHashCode(this->z); + + return hash; +} + +bool +MagneticSensorData::Equals(const Object& rhs) const +{ + const MagneticSensorData* pRhs = dynamic_cast (&rhs); + if (pRhs == null) + { + return false; + } + + if (this->timestamp != pRhs->timestamp) + { + return false; + } + + if (this->x != pRhs->x) + { + return false; + } + + if (this->y != pRhs->y) + { + return false; + } + + if (this->z != pRhs->z) + { + return false; + } + + + return true; +} +result +MagneticSensorData::GetValue(SensorDataKey dataKey, long& value) const +{ + switch (static_cast(dataKey)) + { + case MAGNETIC_DATA_KEY_TIMESTAMP: + value = _SensorUtil::CutTimestamp(timestamp); + break; + default: + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; + } + + return E_SUCCESS; +} + +result +MagneticSensorData::GetValue(SensorDataKey dataKey, float& value) const +{ + switch (static_cast(dataKey)) + { + case MAGNETIC_DATA_KEY_X: + value = x; + break; + case MAGNETIC_DATA_KEY_Y: + value = y; + break; + case MAGNETIC_DATA_KEY_Z: + value = z; + break; + default: + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; + } + + return E_SUCCESS; +} + +result +MagneticSensorData::GetValue(SensorDataKey dataKey, bool& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensorMotion.cpp b/src/FUixSensorMotion.cpp new file mode 100644 index 0000000..63a1761 --- /dev/null +++ b/src/FUixSensorMotion.cpp @@ -0,0 +1,96 @@ +// +// 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 +#include +#include + +using namespace Tizen::Base; + +namespace Tizen { namespace Uix { namespace Sensor +{ + +Motion::Motion(void) + : __pMotionImpl(null) +{ + +} + +Motion::~Motion(void) +{ + if (__pMotionImpl != null) + { + __pMotionImpl->SetEnabled(MOTION_TYPE_NONE); + + delete __pMotionImpl; + __pMotionImpl = null; + } +} + +result +Motion::Construct(IMotionEventListener& listener) +{ + result r = E_SUCCESS; + ClearLastResult(); + SysAssertf(__pMotionImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."); + __pMotionImpl = new (std::nothrow) _MotionImpl; + SysTryReturn(NID_UIX, __pMotionImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + r = __pMotionImpl->Construct(listener); + switch (r) + { + case E_UNSUPPORTED_OPERATION: + SysLogException(NID_UIX, r, "[%s] The motion detection feature is not supported", GetErrorMessage(r)); + break; + + case E_INVALID_STATE: + SysLogException(NID_UIX, r, "[%s] This instance is in an invalid state.", GetErrorMessage(r)); + break; + + default: + break; + } + return r; +} + +void +Motion::SetEnabled(unsigned long type) +{ + result r = E_SUCCESS; + ClearLastResult(); + + SysAssert(__pMotionImpl != null); + + SysTryReturnVoidResult(NID_UIX, __pMotionImpl->IsMotionTypeValid(type), E_INVALID_ARG, "[E_INVALID_ARG] The given type is invalid combination."); + + __pMotionImpl->SetEnabled(type); + r = GetLastResult(); + SysTryReturnVoidResult(NID_UIX, r == E_SUCCESS, r, "[%s] This instance has not been constructed as yet.", GetErrorMessage(r)); +} + +bool +Motion::IsSupported(MotionType type) const +{ + ClearLastResult(); + + SysAssert(__pMotionImpl != null); + + return __pMotionImpl->IsSupported(type); +} + +} } } // Tizen::Uix::Sensor diff --git a/src/FUixSensorProximitySensorData.cpp b/src/FUixSensorProximitySensorData.cpp new file mode 100644 index 0000000..d91d5cd --- /dev/null +++ b/src/FUixSensorProximitySensorData.cpp @@ -0,0 +1,151 @@ +// +// 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 FUixSensorProximitySensorData.cpp + * @brief This is the implementation file for the %ProximitySensorData class. + * + * This files contains implementation of the %ProximitySensorData class. + */ + +// Includes +#include +#include +#include +#include + +#include +#include "FUixSensor_SensorUtil.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found."; +} // Anonymous + +ProximitySensorData::ProximitySensorData(void) + : distance(0.0F) +{ + +} + +ProximitySensorData::~ProximitySensorData(void) +{ + +} + + +ProximitySensorData::ProximitySensorData(const ProximitySensorData& rhs) + :distance(rhs.distance) +{ + +} + +ProximitySensorData& +ProximitySensorData::operator =(const ProximitySensorData& rhs) +{ + // check for self-assignment + if (this != &rhs) + { + timestamp = rhs.timestamp; + distance = rhs.distance; + } + + return *this; +} + +int +ProximitySensorData::GetHashCode(void) const +{ + int hash = 0; + + hash += LongLong::GetHashCode(this->timestamp); + hash += Float::GetHashCode(this->distance); + + return hash; +} + +bool +ProximitySensorData::Equals(const Object& rhs) const +{ + const ProximitySensorData* pRhs = dynamic_cast (&rhs); + if (pRhs == null) + { + return false; + } + + if (this->timestamp != pRhs->timestamp) + { + return false; + } + + if (this->distance != pRhs->distance) + { + return false; + } + + return true; +} + +result +ProximitySensorData::GetValue(SensorDataKey dataKey, long& value) const +{ + switch (static_cast(dataKey)) + { + case PROXIMITY_DATA_KEY_TIMESTAMP: + value = _SensorUtil::CutTimestamp(timestamp); + break; + default: + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; + } + + return E_SUCCESS; +} + +result +ProximitySensorData::GetValue(SensorDataKey dataKey, float& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +ProximitySensorData::GetValue(SensorDataKey dataKey, bool& value) const +{ + switch (static_cast(dataKey)) + { + case PROXIMITY_DATA_KEY_ONOFF: + value = _SensorUtil::IsObjectDetected(distance); + break; + default: + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; + } + + return E_SUCCESS; +} + +bool +ProximitySensorData::IsObjectDetected(void) const +{ + return _SensorUtil::IsObjectDetected(distance); +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensorSensorData.cpp b/src/FUixSensorSensorData.cpp new file mode 100644 index 0000000..616844c --- /dev/null +++ b/src/FUixSensorSensorData.cpp @@ -0,0 +1,68 @@ +// +// 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 FUixSensorSensorData.cpp + * @brief This is the implementation file for the %SensorData class. + * + * This files contains implementation of the %SensorData class. + */ + +// Includes +#include +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found."; +} // Anonymous + +SensorData::SensorData(void) + : timestamp(0LL) +{ + +} + +SensorData::~SensorData(void) +{ + +} + +result +SensorData::GetValue(SensorDataKey dataKey, long& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +SensorData::GetValue(SensorDataKey dataKey, float& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +SensorData::GetValue(SensorDataKey dataKey, bool& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensorSensorManager.cpp b/src/FUixSensorSensorManager.cpp new file mode 100644 index 0000000..013bae1 --- /dev/null +++ b/src/FUixSensorSensorManager.cpp @@ -0,0 +1,348 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.1 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUixSensorSensorManager.cpp + * @brief This is the implementation file for the %SensorManager class. + * + * This files contains implementation of the %SensorManager class. + */ + +#include +#include + +#include +#include + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static wchar_t W_MSG_ALREADY_CONSTRUCTED[] = L"Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class."; +static wchar_t W_MSG_NOT_YET_CONSTRUCTED[] = L"Not yet constructed! Construct() should be called before use."; +static wchar_t W_MSG_INVALID_SENSOR_TYPE[] = L"The specified type of sensor is not valid."; +static wchar_t W_MSG_UNSUPPORTED_OPERATION[] = L"The target device does not support the specified sensor."; +static wchar_t W_MSG_OPERATION_FAILED[] = L"The operation has failed."; +static wchar_t W_MSG_INVALID_INTERVAL[] = L"An interval must be greater than the maximum interval or less than the minimum interval."; +static wchar_t W_MSG_USER_ALREADY_REGISTERED[] = L"The specified listener is already registered for the specified sensor type."; +static wchar_t W_MSG_NOT_REGISTERED_LISETNER[] = L"The specified listener is not registered for the specified sensor type."; +static wchar_t W_MSG_NO_LISTENER_REGISTERED[] = L"There is no sensor listener registered for this type."; +static wchar_t W_MSG_DEVICE_UNAVAILABLE[] = L"The specified type of sensor is not available."; +} // Anonymous + +// SensorManager life-cycle -------------------------------------------------------------------------------------------------- // +SensorManager::SensorManager(void) + : __pSensorManagerImpl(null) +{ + +} + +SensorManager::~SensorManager(void) +{ + if (__pSensorManagerImpl != null) + { + delete __pSensorManagerImpl; + } +} + +result +SensorManager::Construct(void) +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl == null, "%ls", W_MSG_ALREADY_CONSTRUCTED); + + std::unique_ptr<_SensorManagerImpl> pSensorManagerImpl(new (std::nothrow) _SensorManagerImpl()); + SysTryReturnResult(NID_UIX, pSensorManagerImpl != null, E_OUT_OF_MEMORY, "Allocating new _SensorManagerImpl failed."); + + result r = pSensorManagerImpl->Construct(); + SysTryReturnResult(NID_UIX, !IsFailed(r), r, "Propagating."); + + __pSensorManagerImpl = pSensorManagerImpl.release(); + + return E_SUCCESS; +} + +// Getting sensor information ------------------------------------------------------------------------------------------------ // +bool +SensorManager::IsAvailable(SensorType sensorType) const +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + bool isAvailable = __pSensorManagerImpl->IsAvailable(sensorType); + result r = GetLastResult(); + + SysTryReturn(NID_UIX, r != E_INVALID_ARG, false, r, "[%s] %ls", GetErrorMessage(r), W_MSG_INVALID_SENSOR_TYPE); + SysTryReturn(NID_UIX, r != E_OPERATION_FAILED, false, r, "[%s] %ls", GetErrorMessage(r), W_MSG_OPERATION_FAILED); + SysTryReturn(NID_UIX, r != E_UNSUPPORTED_OPERATION, false, r, "[%s] %ls", GetErrorMessage(r), W_MSG_UNSUPPORTED_OPERATION); + SysTryReturn(NID_UIX, r != E_DEVICE_UNAVAILABLE, false, r, "[%s] %ls", GetErrorMessage(r), W_MSG_DEVICE_UNAVAILABLE); + + return isAvailable; +} + +result +SensorManager::GetDescription(SensorType sensorType, Tizen::Base::String& description) const +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + result r = __pSensorManagerImpl->GetDescription(sensorType, description); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls", W_MSG_INVALID_SENSOR_TYPE); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return E_SUCCESS; +} + +result +SensorManager::GetVendor(SensorType sensorType, Tizen::Base::String& vendor) const +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + result r = __pSensorManagerImpl->GetVendor(sensorType, vendor); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls", W_MSG_INVALID_SENSOR_TYPE); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return E_SUCCESS; +} + +result +SensorManager::GetModelId(SensorType sensorType, Tizen::Base::String& modelId) const +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + result r = __pSensorManagerImpl->GetModelId(sensorType, modelId); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls", W_MSG_INVALID_SENSOR_TYPE); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return E_SUCCESS; +} + +result +SensorManager::GetMeasurementRange(SensorType sensorType, float& min, float& max, float& resolution) const +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + result r = __pSensorManagerImpl->GetMeasurementRange(sensorType, min, max, resolution); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls", W_MSG_INVALID_SENSOR_TYPE); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return E_SUCCESS; +} + +result +SensorManager::GetMinInterval(SensorType sensorType, long& interval) const +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + long dummyInterval = 0L; + result r = __pSensorManagerImpl->GetIntervalRange(sensorType, interval, dummyInterval); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls", W_MSG_INVALID_SENSOR_TYPE); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return E_SUCCESS; +} + +result +SensorManager::GetMaxInterval(SensorType sensorType, long& interval) const +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + long dummyInterval = 0L; + result r = __pSensorManagerImpl->GetIntervalRange(sensorType, dummyInterval, interval); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls", W_MSG_INVALID_SENSOR_TYPE); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return E_SUCCESS; +} + + + +// Sensor event listener management ------------------------------------------------------------------------------------------ // +result +SensorManager::AddSensorListener(ISensorEventListener& listener, SensorType sensorType, long interval, bool dataChanged) +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + result r = __pSensorManagerImpl->AddSensorEventListener(listener, sensorType, interval, dataChanged); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls or %ls", W_MSG_INVALID_SENSOR_TYPE, W_MSG_INVALID_INTERVAL); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_USER_ALREADY_REGISTERED, r, "%ls", W_MSG_USER_ALREADY_REGISTERED); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return E_SUCCESS; +} + +result +SensorManager::RemoveSensorListener(ISensorEventListener& listener) +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + result r = __pSensorManagerImpl->RemoveSensorEventListener(listener); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls", W_MSG_NOT_REGISTERED_LISETNER); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + return E_SUCCESS; +} + +result +SensorManager::RemoveSensorListener(ISensorEventListener& listener, SensorType sensorType) +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + result r = __pSensorManagerImpl->RemoveSensorEventListener(listener, sensorType); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls or %ls", W_MSG_INVALID_SENSOR_TYPE, W_MSG_NOT_REGISTERED_LISETNER); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return E_SUCCESS; +} + +result +SensorManager::SetInterval(SensorType sensorType, long interval) +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + result r = __pSensorManagerImpl->SetInterval(sensorType, interval); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls or %ls", W_MSG_INVALID_SENSOR_TYPE, W_MSG_NOT_REGISTERED_LISETNER); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return E_SUCCESS; +} + +result +SensorManager::SetInterval(ISensorEventListener& listener, SensorType sensorType, long interval) +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + result r = __pSensorManagerImpl->SetInterval(listener, sensorType, interval); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls or %ls", W_MSG_INVALID_SENSOR_TYPE, W_MSG_NOT_REGISTERED_LISETNER); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return E_SUCCESS; +} + +// Sensor wake up management ------------------------------------------------------------------------------------------------- // +bool +SensorManager::IsWakeupSupported(SensorType sensorType) const +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + bool isWakeupSupported = __pSensorManagerImpl->IsWakeupSupported(sensorType); + result r = GetLastResult(); + + SysTryReturn(NID_UIX, r != E_INVALID_ARG, false, r, "[%s] %ls", GetErrorMessage(r), W_MSG_INVALID_SENSOR_TYPE); + SysTryReturn(NID_UIX, r != E_OPERATION_FAILED, false, r, "[%s] %ls", GetErrorMessage(r), W_MSG_OPERATION_FAILED); + SysTryReturn(NID_UIX, r != E_UNSUPPORTED_OPERATION, false, r, "[%s] %ls", GetErrorMessage(r), W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return isWakeupSupported; +} + +result +SensorManager::SetWakeupEnabled(SensorType sensorType, bool enable) +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + result r = __pSensorManagerImpl->SetWakeupEnabled(sensorType, enable); + + SysTryReturnResult(NID_UIX, r != E_INVALID_ARG, r, "%ls or %ls", W_MSG_INVALID_SENSOR_TYPE, W_MSG_NOT_REGISTERED_LISETNER); + SysTryReturnResult(NID_UIX, r != E_OPERATION_FAILED, r, "%ls", W_MSG_OPERATION_FAILED); + SysTryReturnResult(NID_UIX, r != E_UNSUPPORTED_OPERATION, r, "%ls", W_MSG_UNSUPPORTED_OPERATION); + SysTryReturnResult(NID_UIX, r != E_INVALID_STATE, r, "%ls", W_MSG_NO_LISTENER_REGISTERED); + SysTryReturnResult(NID_UIX, r != E_DEVICE_UNAVAILABLE, r, "%ls", W_MSG_DEVICE_UNAVAILABLE); + + return E_SUCCESS; +} + +bool +SensorManager::IsWakeupEnabled(SensorType sensorType) const +{ + ClearLastResult(); + + SysAssertf(__pSensorManagerImpl != null, "%ls", W_MSG_NOT_YET_CONSTRUCTED); + + bool isWakeupSupported = __pSensorManagerImpl->IsWakeupEnabled(sensorType); + result r = GetLastResult(); + + SysTryReturn(NID_UIX, r != E_INVALID_ARG, false, r, "[%s] %ls", GetErrorMessage(r), W_MSG_INVALID_SENSOR_TYPE); + SysTryReturn(NID_UIX, r != E_OPERATION_FAILED, false, r, "[%s] %ls", GetErrorMessage(r), W_MSG_OPERATION_FAILED); + SysTryReturn(NID_UIX, r != E_UNSUPPORTED_OPERATION, false, r, "[%s] %ls", GetErrorMessage(r), W_MSG_UNSUPPORTED_OPERATION); + SysTryReturn(NID_UIX, r != E_DEVICE_UNAVAILABLE, false, r, "[%s] %ls", GetErrorMessage(r), W_MSG_DEVICE_UNAVAILABLE); + + return isWakeupSupported; +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensorTiltSensorData.cpp b/src/FUixSensorTiltSensorData.cpp new file mode 100644 index 0000000..c99828d --- /dev/null +++ b/src/FUixSensorTiltSensorData.cpp @@ -0,0 +1,169 @@ +// +// 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 FUixSensorTiltSensorData.cpp + * @brief This is the implementation file for the %TiltSensorData class. + * + * This files contains implementation of the %TiltSensorData class. + */ + +// Includes +#include +#include +#include +#include + +#include +#include "FUixSensor_SensorUtil.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found."; +} // Anonymous + +TiltSensorData::TiltSensorData(void) + : roll(0.0F) + , pitch(0.0F) + , azimuth(0.0F) +{ + +} + +TiltSensorData::~TiltSensorData(void) +{ + +} + +TiltSensorData::TiltSensorData(const TiltSensorData& rhs) + :azimuth(rhs.azimuth) + ,roll(rhs.roll) + ,pitch(rhs.pitch) +{ + +} + +TiltSensorData& +TiltSensorData::operator =(const TiltSensorData& rhs) +{ + // check for self-assignment + if (this != &rhs) + { + timestamp = rhs.timestamp; + azimuth = rhs.azimuth; + roll = rhs.roll; + pitch = rhs.pitch; + } + + return *this; +} + +int +TiltSensorData::GetHashCode(void) const +{ + int hash = 0; + + hash += LongLong::GetHashCode(this->timestamp); + hash += Float::GetHashCode(this->azimuth); + hash += Float::GetHashCode(this->roll); + hash += Float::GetHashCode(this->pitch); + + return hash; +} + +bool +TiltSensorData::Equals(const Object& rhs) const +{ + const TiltSensorData* pRhs = dynamic_cast (&rhs); + if (pRhs == null) + { + return false; + } + + if (this->timestamp != pRhs->timestamp) + { + return false; + } + + if (this->azimuth != pRhs->azimuth) + { + return false; + } + + if (this->roll != pRhs->roll) + { + return false; + } + + if (this->pitch != pRhs->pitch) + { + return false; + } + + + return true; +} + +result +TiltSensorData::GetValue(SensorDataKey dataKey, long& value) const +{ + switch (static_cast(dataKey)) + { + case TILT_DATA_KEY_TIMESTAMP: + value = _SensorUtil::CutTimestamp(timestamp); + break; + default: + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; + } + + return E_SUCCESS; +} + +result +TiltSensorData::GetValue(SensorDataKey dataKey, float& value) const +{ + switch (static_cast(dataKey)) + { + case TILT_DATA_KEY_ROLL: + value = roll; + break; + case TILT_DATA_KEY_PITCH: + value = pitch; + break; + case TILT_DATA_KEY_AZIMUTH: + value = azimuth; + break; + default: + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; + } + + return E_SUCCESS; +} + +result +TiltSensorData::GetValue(SensorDataKey dataKey, bool& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensorUserAccelerationSensorData.cpp b/src/FUixSensorUserAccelerationSensorData.cpp new file mode 100644 index 0000000..8139a4c --- /dev/null +++ b/src/FUixSensorUserAccelerationSensorData.cpp @@ -0,0 +1,144 @@ +// +// 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 FUixSensorUserAccelerationSensorData.cpp + * @brief This is the implementation file for the %UserAccelerationSensorData class. + * + * This files contains implementation of the %GravitySensorData class. + */ + +// Includes +#include +#include +#include +#include + +#include +#include "FUixSensor_SensorUtil.h" + +using namespace Tizen::Base; + + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static const wchar_t W_MSG_INVALID_SENSOR_DATA_KEY[] = L"A data matching the specified key and data type cannot be found."; +} // Anonymous + +UserAccelerationSensorData::UserAccelerationSensorData(void) + : x(0.0F) + , y(0.0F) + , z(0.0F) +{ + +} + +UserAccelerationSensorData::~UserAccelerationSensorData(void) +{ + +} + +UserAccelerationSensorData::UserAccelerationSensorData(const UserAccelerationSensorData& rhs) + :x(rhs.x) + ,y(rhs.y) + ,z(rhs.z) +{ + +} + +UserAccelerationSensorData& +UserAccelerationSensorData::operator =(const UserAccelerationSensorData& rhs) +{ + // check for self-assignment + if (this != &rhs) + { + timestamp = rhs.timestamp; + x = rhs.x; + y = rhs.y; + z = rhs.z; + } + + return *this; +} + +int +UserAccelerationSensorData::GetHashCode(void) const +{ + int hash = 0; + + hash += LongLong::GetHashCode(this->timestamp); + hash += Float::GetHashCode(this->x); + hash += Float::GetHashCode(this->y); + hash += Float::GetHashCode(this->z); + + return hash; +} + +bool +UserAccelerationSensorData::Equals(const Object& rhs) const +{ + const UserAccelerationSensorData* pRhs = dynamic_cast (&rhs); + if (pRhs == null) + { + return false; + } + + if (this->timestamp != pRhs->timestamp) + { + return false; + } + + if (this->x != pRhs->x) + { + return false; + } + + if (this->y != pRhs->y) + { + return false; + } + + if (this->z != pRhs->z) + { + return false; + } + return true; +} + +result +UserAccelerationSensorData::GetValue(SensorDataKey dataKey, long& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +UserAccelerationSensorData::GetValue(SensorDataKey dataKey, float& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} + +result +UserAccelerationSensorData::GetValue(SensorDataKey dataKey, bool& value) const +{ + SysLogException(NID_UIX, E_INVALID_ARG, "[%s] %ls", GetErrorMessage(E_INVALID_ARG), W_MSG_INVALID_SENSOR_DATA_KEY); + return E_INVALID_ARG; +} +} } } // Tizen::Uix::Sensor diff --git a/src/FUixSensor_ISensorCore.cpp b/src/FUixSensor_ISensorCore.cpp new file mode 100644 index 0000000..4eb5c02 --- /dev/null +++ b/src/FUixSensor_ISensorCore.cpp @@ -0,0 +1,1107 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.1 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUixSensor_ISensorCore.cpp + * @brief This is the implementation file for the %_ISensorCore interface class. + * + * This files contains implementation of the %_ISensorCore interface class. + */ + +// Includes +#include + +#include +#include +#include +#include "FUixSensor_ISensorCore.h" +#include "FUixSensor_ISensorCoreEventReceiver.h" +#include "FUixSensor_SensorUtil.h" + +using Tizen::App::_AppInfo; + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +// Internal variables -------------------------------------------------------------------------------------------------------- // +static const sensor_type_e SENSOR_UNKNOWN = static_cast(-1); +static const wchar_t W_MSG_EMUL_VENDOR[] = L"Emul_Vendor"; +static const wchar_t W_MSG_EMUL_MODEL_ID_TILT[] = L"Emul_ModelId_Tilt"; +static const wchar_t W_MSG_NOT_SUPPORTED[] = L"Not supported"; +static const long SENSOR_MIN_INTERVALS[] = { + 20L, // SENSOR_TYPE_ACCELERATION + 20L, // SENSOR_TYPE_MAGNETIC + 100L, // SENSOR_TYPE_PROXIMITY + 20L, // SENSOR_TYPE_TILT + 20L, // SENSOR_TYPE_GYRO + 100L, // SENSOR_TYPE_LIGHT + 20L, // SENSOR_TYPE_GRAVITY + 20L, // SENSOR_TYPE_USER_ACCELERATION + 20L, // SENSOR_TYPE_DEVICE_ORIENTATION +}; +static const long SENSOR_MAX_INTERVALS[] = { + 100L, // SENSOR_TYPE_ACCELERATION + 100L, // SENSOR_TYPE_MAGNETIC + 5000L, // SENSOR_TYPE_PROXIMITY + 1000L, // SENSOR_TYPE_TILT + 100L, // SENSOR_TYPE_GYRO + 5000L, // SENSOR_TYPE_LIGHT + 100L, // SENSOR_TYPE_GRAVITY + 100L, // SENSOR_TYPE_USER_ACCELERATION + 100L, // SENSOR_TYPE_DEVICE_ORIENTATION +}; +static const float MIN_VALUE_TILT = 0.0F; +static const float MAX_VALUE_TILT = 360.0F; +static const float RESOLUTION_VALUE_TILT = 0.0F; + +// Internal utility methods -------------------------------------------------------------------------------------------------- // +inline bool +IsSuccess(int sensorResult) +{ + return sensorResult == SENSOR_ERROR_NONE; +} + +sensor_type_e +ConvertToSensorTypeEFromSensorType(SensorType sensorType) +{ + switch (sensorType) + { + case SENSOR_TYPE_ACCELERATION: + return SENSOR_ACCELEROMETER; + case SENSOR_TYPE_MAGNETIC: + return SENSOR_MAGNETIC; + case SENSOR_TYPE_PROXIMITY: + return SENSOR_PROXIMITY; + case SENSOR_TYPE_TILT: + return SENSOR_ORIENTATION; + case SENSOR_TYPE_GYRO: + return SENSOR_GYROSCOPE; + case SENSOR_TYPE_LIGHT: + return SENSOR_LIGHT; + case SENSOR_TYPE_GRAVITY: + return SENSOR_GRAVITY; + case SENSOR_TYPE_USER_ACCELERATION: + return SENSOR_LINEAR_ACCELERATION; + case SENSOR_TYPE_DEVICE_ORIENTATION: + return SENSOR_DEVICE_ORIENTATION; + default: + SysAssertf(false, "ConvertToSensorTypeEFromSensorType() > Invalid SensorType [sensorType:%d]", sensorType); + SetLastResult(E_INVALID_ARG); + return SENSOR_UNKNOWN; + } +} + +int +GetStaticIntervalRange(SensorType sensorType, int& min, int& max) +{ + min = SENSOR_MIN_INTERVALS[sensorType]; + max = SENSOR_MAX_INTERVALS[sensorType]; + + return SENSOR_ERROR_NONE; +} + +sensor_type_e +GetSensorTypeEFromSensorCoreEventType(_SensorCoreEventType eventType) +{ + switch (eventType) + { + case _SENSOR_CORE_EVENT_TYPE_ACCELERATION_DATA: + // fall through + case _SENSOR_CORE_EVENT_TYPE_ACCELERATION_SENSOR_WAKEUP: + return SENSOR_ACCELEROMETER; + case _SENSOR_CORE_EVENT_TYPE_MAGNETIC_FIELD_DATA: + return SENSOR_MAGNETIC; + case _SENSOR_CORE_EVENT_TYPE_TILT_DATA: + return SENSOR_ORIENTATION; + case _SENSOR_CORE_EVENT_TYPE_PROXIMITY_DISTANCE_DATA: + return SENSOR_PROXIMITY; + case _SENSOR_CORE_EVENT_TYPE_ROTATION_RATE_DATA: + return SENSOR_GYROSCOPE; + case _SENSOR_CORE_EVENT_TYPE_LIGHT_LEVEL_DATA: + return SENSOR_LIGHT; + case _SENSOR_CORE_EVENT_TYPE_GRAVITY_DATA: + return SENSOR_GRAVITY; + case _SENSOR_CORE_EVENT_TYPE_USER_ACCELERATION_DATA: + return SENSOR_LINEAR_ACCELERATION; + case _SENSOR_CORE_EVENT_TYPE_DEVICE_ORIENTATION_DATA: + return SENSOR_DEVICE_ORIENTATION; + default: + SysAssertf(false, "GetSensorTypeEFromSensorCoreEventType() > Invalid _SensorCoreEventType [eventType:%d]", eventType); + SetLastResult(E_INVALID_ARG); + return SENSOR_UNKNOWN; + } +} + +inline int +IsStaticObjectDetected(float distance, bool& isObjectDetected) +{ + isObjectDetected = (distance <= 4.0F); + return SENSOR_ERROR_NONE; +} + +inline bool +IsAccuracyValid(sensor_data_accuracy_e accuracy) +{ + return accuracy >= SENSOR_DATA_ACCURACY_NORMAL; +} + +inline long long +CorrectTimestamp(long long timestamp) +{ + return timestamp * MICROSECOND_TO_MILLISECOND; +} + +// Internal callback methods ------------------------------------------------------------------------------------------------- // +void +OnAccelerationDataEventReceived(unsigned long long timestamp, sensor_data_accuracy_e accuracy, + float x, float y, float z, void* pUserData) +{ + _ISensorCoreEventReceiver& receiver= *static_cast<_ISensorCoreEventReceiver*>(pUserData); + _SensorCoreEvent& eventBuffer = receiver.GetSensorCoreEventBuffer(); + + eventBuffer.isEventValid = IsAccuracyValid(accuracy); + eventBuffer.eventType = _SENSOR_CORE_EVENT_TYPE_ACCELERATION_DATA; + eventBuffer.eventTimestamp = CorrectTimestamp(timestamp); + eventBuffer.eventKind.accelerationData.x = x * METER_PER_SECOND_SQUARE_TO_G; + eventBuffer.eventKind.accelerationData.y = y * METER_PER_SECOND_SQUARE_TO_G; + eventBuffer.eventKind.accelerationData.z = z * METER_PER_SECOND_SQUARE_TO_G; + receiver.OnSensorCoreEventReceived(eventBuffer); +} + +void +OnMagneticFieldDataEventReceived(unsigned long long timestamp, sensor_data_accuracy_e accuracy, + float x, float y, float z, void* pUserData) +{ + _ISensorCoreEventReceiver& receiver= *static_cast<_ISensorCoreEventReceiver*>(pUserData); + _SensorCoreEvent& eventBuffer = receiver.GetSensorCoreEventBuffer(); + eventBuffer.isEventValid = IsAccuracyValid(accuracy); + eventBuffer.eventType = _SENSOR_CORE_EVENT_TYPE_MAGNETIC_FIELD_DATA; + eventBuffer.eventTimestamp = CorrectTimestamp(timestamp); + eventBuffer.eventKind.magneticFieldData.x = x; + eventBuffer.eventKind.magneticFieldData.y = y; + eventBuffer.eventKind.magneticFieldData.z = z; + receiver.OnSensorCoreEventReceived(eventBuffer); +} + +void +OnProximityDistanceDataEventReceived(unsigned long long timestamp, float distance, void* pUserData) +{ + _ISensorCoreEventReceiver& receiver= *static_cast<_ISensorCoreEventReceiver*>(pUserData); + _SensorCoreEvent& eventBuffer = receiver.GetSensorCoreEventBuffer(); + eventBuffer.isEventValid = true; + eventBuffer.eventType = _SENSOR_CORE_EVENT_TYPE_PROXIMITY_DISTANCE_DATA; + eventBuffer.eventTimestamp = CorrectTimestamp(timestamp); + eventBuffer.eventKind.proximityDistanceData.distance = distance; + receiver.OnSensorCoreEventReceived(eventBuffer); +} + +void +OnTiltMagneticAzimuthDataEventReceived(unsigned long long timestamp, sensor_data_accuracy_e accuracy, + float azimuth, float pitch, float roll, void* pUserData) +{ + _ISensorCoreEventReceiver& receiver= *static_cast<_ISensorCoreEventReceiver*>(pUserData); + _SensorCoreEvent& eventBuffer = receiver.GetSensorCoreEventBuffer(); + eventBuffer.isEventValid = eventBuffer.isEventValid && IsAccuracyValid(accuracy); + eventBuffer.eventType = _SENSOR_CORE_EVENT_TYPE_TILT_DATA; + eventBuffer.eventTimestamp = CorrectTimestamp(timestamp); + eventBuffer.eventKind.tiltData.azimuth = azimuth; + eventBuffer.eventKind.tiltData.roll = roll; + eventBuffer.eventKind.tiltData.pitch = pitch; + receiver.OnSensorCoreEventReceived(eventBuffer); +} + +void +OnRotationRateDataEventReceived(unsigned long long timestamp, sensor_data_accuracy_e accuracy, + float x, float y, float z, void* pUserData) +{ + _ISensorCoreEventReceiver& receiver= *static_cast<_ISensorCoreEventReceiver*>(pUserData); + _SensorCoreEvent& eventBuffer = receiver.GetSensorCoreEventBuffer(); + eventBuffer.isEventValid = IsAccuracyValid(accuracy); + eventBuffer.eventType = _SENSOR_CORE_EVENT_TYPE_ROTATION_RATE_DATA; + eventBuffer.eventTimestamp = CorrectTimestamp(timestamp); + eventBuffer.eventKind.rotationRateData.x = x; + eventBuffer.eventKind.rotationRateData.y = y; + eventBuffer.eventKind.rotationRateData.z = z; + receiver.OnSensorCoreEventReceived(eventBuffer); +} + +void +OnLightLevelDataEventReceived(unsigned long long timestamp, float lux, void* pUserData) +{ + _ISensorCoreEventReceiver& receiver= *static_cast<_ISensorCoreEventReceiver*>(pUserData); + _SensorCoreEvent& eventBuffer = receiver.GetSensorCoreEventBuffer(); + eventBuffer.isEventValid = true; + eventBuffer.eventType = _SENSOR_CORE_EVENT_TYPE_LIGHT_LEVEL_DATA; + eventBuffer.eventTimestamp = CorrectTimestamp(timestamp); + eventBuffer.eventKind.lightLevelData.level = lux; + receiver.OnSensorCoreEventReceived(eventBuffer); +} + +void +OnAccelerationSensorWakeupEventReceived(void *pUserData) +{ + SysLog(NID_UIX, " OnAccelerationSensorWakeupEventReceived Device wake up by Acceleration sensor."); +} + +void +OnGravityDataEventReceived(unsigned long long timestamp, sensor_data_accuracy_e accuracy,float x, float y, float z, void* pUserData) +{ + _ISensorCoreEventReceiver& receiver= *static_cast<_ISensorCoreEventReceiver*>(pUserData); + _SensorCoreEvent& eventBuffer = receiver.GetSensorCoreEventBuffer(); + + SysLog(NID_UIX, "taehwan.son OnGravityDataEventReceived."); + eventBuffer.isEventValid = IsAccuracyValid(accuracy); + eventBuffer.eventType = _SENSOR_CORE_EVENT_TYPE_GRAVITY_DATA; + eventBuffer.eventTimestamp = CorrectTimestamp(timestamp); + eventBuffer.eventKind.gravityData.x = x; + eventBuffer.eventKind.gravityData.y = y; + eventBuffer.eventKind.gravityData.z = z; + receiver.OnSensorCoreEventReceived(eventBuffer); + +} + +void +OnUserAccelerationDataEventReceived(unsigned long long timestamp, sensor_data_accuracy_e accuracy,float x, float y, float z, void* pUserData) +{ + _ISensorCoreEventReceiver& receiver= *static_cast<_ISensorCoreEventReceiver*>(pUserData); + _SensorCoreEvent& eventBuffer = receiver.GetSensorCoreEventBuffer(); + + SysLog(NID_UIX, "OnUserAccelerationDataEventReceived."); + eventBuffer.isEventValid = IsAccuracyValid(accuracy); + eventBuffer.eventType = _SENSOR_CORE_EVENT_TYPE_USER_ACCELERATION_DATA; + eventBuffer.eventTimestamp = CorrectTimestamp(timestamp); + eventBuffer.eventKind.userAccelerationData.x = x * METER_PER_SECOND_SQUARE_TO_G; + eventBuffer.eventKind.userAccelerationData.y = y * METER_PER_SECOND_SQUARE_TO_G; + eventBuffer.eventKind.userAccelerationData.z = z * METER_PER_SECOND_SQUARE_TO_G; + receiver.OnSensorCoreEventReceived(eventBuffer); +} + +void +OnDeviceOrientationDataEventReceived(unsigned long long timestamp, sensor_data_accuracy_e accuracy,float yaw, float pitch, float roll, void* pUserData) +{ + _ISensorCoreEventReceiver& receiver= *static_cast<_ISensorCoreEventReceiver*>(pUserData); + _SensorCoreEvent& eventBuffer = receiver.GetSensorCoreEventBuffer(); + + SysLog(NID_UIX, "OnDeviceOrientationDataEventReceived."); + eventBuffer.isEventValid = IsAccuracyValid(accuracy); + eventBuffer.eventType = _SENSOR_CORE_EVENT_TYPE_DEVICE_ORIENTATION_DATA; + eventBuffer.eventTimestamp = CorrectTimestamp(timestamp); + eventBuffer.eventKind.deviceOrientationData.yaw = yaw; + eventBuffer.eventKind.deviceOrientationData.pitch = pitch; + eventBuffer.eventKind.deviceOrientationData.roll = roll; + receiver.OnSensorCoreEventReceived(eventBuffer); +} + +// Internal management methods ----------------------------------------------------------------------------------------------- // +result +ConnectToSensorCore(sensor_h& sensorHandle) +{ + sensor_h tempHandle = null; + int sensorResult = sensor_create(&tempHandle); + if (!IsSuccess(sensorResult)) + { + // SENSOR_ERROR_OUT_OF_MEMORY + SysAssertf(false, "ConnectToSensorCore() > sensor_create() failed. [handle:%p, result:%d]", tempHandle, sensorResult); + SetLastResult(E_OUT_OF_MEMORY); + return E_OUT_OF_MEMORY; + } + + sensorHandle = tempHandle; + + return E_SUCCESS; +} + +result +DisconnectFromSensorCore(sensor_h& sensorHandle) +{ + int sensorResult = sensor_destroy(sensorHandle); + if (!IsSuccess(sensorResult)) + { + // PARADOX + if(_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "DisconnectFromSensorCore() > sensor_destroy() failed. [handle:%p, result:%d]", sensorHandle, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + else + { + SysAssertf(false, "DisconnectFromSensorCore() > sensor_destroy() failed. [handle:%p, result:%d]", sensorHandle, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return E_OPERATION_FAILED; + } + } + + sensorHandle = null; + + return E_SUCCESS; +} + +result +PrepareSensorCoreEventSensing(sensor_h sensorHandle, _SensorCoreEventType eventType, long interval, void* pUserData) +{ + int sensorResult = SENSOR_ERROR_NONE; + switch (eventType) + { + case _SENSOR_CORE_EVENT_TYPE_ACCELERATION_DATA: + { + sensorResult = sensor_accelerometer_set_cb(sensorHandle, interval, OnAccelerationDataEventReceived, pUserData); + break; + } + case _SENSOR_CORE_EVENT_TYPE_MAGNETIC_FIELD_DATA: + { + sensorResult = sensor_magnetic_set_cb(sensorHandle, interval, OnMagneticFieldDataEventReceived, pUserData); + break; + } + case _SENSOR_CORE_EVENT_TYPE_PROXIMITY_DISTANCE_DATA: + { + sensorResult = sensor_proximity_set_cb(sensorHandle, interval, OnProximityDistanceDataEventReceived, pUserData); + break; + } + case _SENSOR_CORE_EVENT_TYPE_TILT_DATA: + { + sensorResult = sensor_orientation_set_cb(sensorHandle, interval, OnTiltMagneticAzimuthDataEventReceived, pUserData); + break; + } + case _SENSOR_CORE_EVENT_TYPE_ROTATION_RATE_DATA: + { + sensorResult = sensor_gyroscope_set_cb(sensorHandle, interval, OnRotationRateDataEventReceived, pUserData); + break; + } + case _SENSOR_CORE_EVENT_TYPE_LIGHT_LEVEL_DATA: + { + sensorResult = sensor_light_set_cb(sensorHandle, interval, OnLightLevelDataEventReceived, pUserData); + break; + } + case _SENSOR_CORE_EVENT_TYPE_ACCELERATION_SENSOR_WAKEUP: + { + sensorResult = sensor_awake_set_cb(sensorHandle, SENSOR_ACCELEROMETER, OnAccelerationSensorWakeupEventReceived, pUserData); + break; + } + case _SENSOR_CORE_EVENT_TYPE_GRAVITY_DATA: + { + sensorResult = sensor_gravity_set_cb(sensorHandle, interval, OnGravityDataEventReceived, pUserData); + break; + } + case _SENSOR_CORE_EVENT_TYPE_USER_ACCELERATION_DATA: + { + sensorResult = sensor_linear_acceleration_set_cb(sensorHandle, interval, OnUserAccelerationDataEventReceived, pUserData); + break; + } + case _SENSOR_CORE_EVENT_TYPE_DEVICE_ORIENTATION_DATA: + { + sensorResult = sensor_device_orientation_set_cb(sensorHandle, interval, OnDeviceOrientationDataEventReceived, pUserData); + break; + } + default: + { + // PARADOX + SysAssertf(false, "PrepareSensorCoreEventSensing() > [%s] PARADOX [eventType:%d]", GetErrorMessage(E_INVALID_ARG), eventType); + SetLastResult(E_INVALID_ARG); + return E_INVALID_ARG; + } + } + + if (!IsSuccess(sensorResult)) + { + // SENSOR_ERROR_IO_ERROR or SENSOR_ERROR_OPERATION_FAILED + if(_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "PrepareSensorCoreEventSensing() > sensor_xxx_set_cb() failed. [handle:%p, eventType:%d, interval:%ld, result:%d]", sensorHandle, eventType, interval, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + else + { + SysAssertf(false, "PrepareSensorCoreEventSensing() > sensor_xxx_set_cb() failed. [handle:%p, eventType:%d, interval:%ld, result:%d]", sensorHandle, eventType, interval, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return E_OPERATION_FAILED; + } + + } + + return E_SUCCESS; +} + +result +UnprepareSensorCoreEventSensing(sensor_h sensorHandle, _SensorCoreEventType eventType) +{ + int sensorResult = SENSOR_ERROR_NONE; + switch (eventType) + { + case _SENSOR_CORE_EVENT_TYPE_ACCELERATION_DATA: + { + sensorResult = sensor_accelerometer_unset_cb(sensorHandle); + break; + } + case _SENSOR_CORE_EVENT_TYPE_MAGNETIC_FIELD_DATA: + { + sensorResult = sensor_magnetic_unset_cb(sensorHandle); + break; + } + case _SENSOR_CORE_EVENT_TYPE_PROXIMITY_DISTANCE_DATA: + { + sensorResult = sensor_proximity_unset_cb(sensorHandle); + break; + } + case _SENSOR_CORE_EVENT_TYPE_TILT_DATA: + { + sensorResult = sensor_orientation_unset_cb(sensorHandle); + break; + } + case _SENSOR_CORE_EVENT_TYPE_ROTATION_RATE_DATA: + { + sensorResult = sensor_gyroscope_unset_cb(sensorHandle); + break; + } + case _SENSOR_CORE_EVENT_TYPE_LIGHT_LEVEL_DATA: + { + sensorResult = sensor_light_unset_cb(sensorHandle); + break; + } + case _SENSOR_CORE_EVENT_TYPE_ACCELERATION_SENSOR_WAKEUP: + { + sensorResult = sensor_awake_unset_cb(sensorHandle, SENSOR_ACCELEROMETER); + break; + } + case _SENSOR_CORE_EVENT_TYPE_GRAVITY_DATA: + { + sensorResult = sensor_gravity_unset_cb(sensorHandle); + break; + } + case _SENSOR_CORE_EVENT_TYPE_USER_ACCELERATION_DATA: + { + sensorResult = sensor_linear_acceleration_unset_cb(sensorHandle); + break; + } + case _SENSOR_CORE_EVENT_TYPE_DEVICE_ORIENTATION_DATA: + { + sensorResult = sensor_device_orientation_unset_cb(sensorHandle); + break; + } + default: + { + // PARADOX + SysAssertf(false, "UnprepareSensorCoreEventSensing() > [%s] PARADOX [eventType:%d]", GetErrorMessage(E_INVALID_ARG), eventType); + SetLastResult(E_INVALID_ARG); + return E_INVALID_ARG; + } + } + + if (!IsSuccess(sensorResult)) + { + // SENSOR_ERROR_IO_ERROR or SENSOR_ERROR_OPERATION_FAILED + if(_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "UnprepareSensorCoreEventSensing() > sensor_xxx_unset_cb() failed. [handle:%p, eventType:%d, result:%d]", sensorHandle, eventType, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + else + { + SysAssertf(false, "UnprepareSensorCoreEventSensing() > sensor_xxx_unset_cb() failed. [handle:%p, eventType:%d, result:%d]", sensorHandle, eventType, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return E_OPERATION_FAILED; + } + + + } + + return E_SUCCESS; +} + +result +StartSensorType(sensor_h sensorHandle, sensor_type_e sensorTypeE) +{ + int sensorResult = sensor_start(sensorHandle, sensorTypeE); + if (!IsSuccess(sensorResult)) + { + // SENSOR_ERROR_IO_ERROR or SENSOR_ERROR_OPERATION_FAILED + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "StartSensorCoreEventSensing() > sensor_start() failed. [handle:%p, sensorTypeE:%d, result:%d]", sensorHandle, sensorTypeE, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + else + { + SysAssertf(false, "StartSensorCoreEventSensing() > sensor_start() failed. [handle:%p, sensorTypeE:%d, result:%d]", sensorHandle, sensorTypeE, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return E_OPERATION_FAILED; + } + } + + sensorResult = sensor_set_always_on(sensorHandle, sensorTypeE); + if (!IsSuccess(sensorResult)) + { + // SENSOR_ERROR_IO_ERROR + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "StartSensorCoreEventSensing() > sensor_set_always_on() failed. [handle:%p, sensorTypeE:%d, result:%d]", sensorHandle, sensorTypeE, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + else + { + SysAssertf(false, "StartSensorCoreEventSensing() > sensor_set_always_on() failed. [handle:%p, sensorTypeE:%d, result:%d]", sensorHandle, sensorTypeE, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return E_OPERATION_FAILED; + } + } + return E_SUCCESS; +} + +result +StartSensorCoreEventSensing(sensor_h sensorHandle, _SensorCoreEventType eventType) +{ + sensor_type_e sensorTypeE = GetSensorTypeEFromSensorCoreEventType(eventType); + StartSensorType(sensorHandle,sensorTypeE); + return E_SUCCESS; +} + +result +StopSensorType(sensor_h sensorHandle, sensor_type_e sensorTypeE) +{ + int sensorResult = sensor_stop(sensorHandle,sensorTypeE ); + if (!IsSuccess(sensorResult)) + { + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + // SENSOR_ERROR_IO_ERROR + SysAssertf(false, "StartSensorCoreEventSensing() > sensor_stop() failed. [handle:%p, sensorTypeE:%d, result:%d]", sensorHandle, sensorTypeE, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + else + { + SysAssertf(false, "StartSensorCoreEventSensing() > sensor_stop() failed. [handle:%p, sensorTypeE:%d, result:%d]", sensorHandle, sensorTypeE, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return E_OPERATION_FAILED; + } + + } + return E_SUCCESS; +} + +result +StopSensorCoreEventSensing(sensor_h sensorHandle, _SensorCoreEventType eventType) +{ + + sensor_type_e sensorTypeE = GetSensorTypeEFromSensorCoreEventType(eventType); + StopSensorType(sensorHandle,sensorTypeE); + return E_SUCCESS; +} + +result +ResetSensorCoreDataEventSensingInterval(sensor_h sensorHandle, _SensorCoreEventType eventType, long interval) +{ + int sensorResult = SENSOR_ERROR_NONE; + switch (eventType) + { + case _SENSOR_CORE_EVENT_TYPE_ACCELERATION_DATA: + { + sensorResult = sensor_accelerometer_set_interval(sensorHandle, interval); + break; + } + case _SENSOR_CORE_EVENT_TYPE_MAGNETIC_FIELD_DATA: + { + sensorResult = sensor_magnetic_set_interval(sensorHandle, interval); + break; + } + case _SENSOR_CORE_EVENT_TYPE_PROXIMITY_DISTANCE_DATA: + { + sensorResult = sensor_proximity_set_interval(sensorHandle, interval); + break; + } + case _SENSOR_CORE_EVENT_TYPE_TILT_DATA: + { + sensorResult = sensor_orientation_set_interval(sensorHandle, interval); + break; + } + case _SENSOR_CORE_EVENT_TYPE_ROTATION_RATE_DATA: + { + sensorResult = sensor_gyroscope_set_interval(sensorHandle, interval); + break; + } + case _SENSOR_CORE_EVENT_TYPE_LIGHT_LEVEL_DATA: + { + sensorResult = sensor_light_set_interval(sensorHandle, interval); + break; + } + case _SENSOR_CORE_EVENT_TYPE_GRAVITY_DATA: + { + sensorResult = sensor_gravity_set_interval(sensorHandle, interval); + break; + } + case _SENSOR_CORE_EVENT_TYPE_USER_ACCELERATION_DATA: + { + sensorResult = sensor_gravity_set_interval(sensorHandle, interval); + break; + } + case _SENSOR_CORE_EVENT_TYPE_DEVICE_ORIENTATION_DATA: + { + sensorResult = sensor_gravity_set_interval(sensorHandle, interval); + break; + } + default: + { + // PARADOX + SysAssertf(false, "ResetSensorCoreDataEventSensingInterval() > [%s] PARADOX [eventType:%d]", GetErrorMessage(E_INVALID_ARG), eventType); + SetLastResult(E_INVALID_ARG); + return E_INVALID_ARG; + } + } + + if (!IsSuccess(sensorResult)) + { + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "ResetSensorCoreDataEventSensingInterval() > sensor_xxx_set_interval() failed. [handle:%p, eventType:%d, result:%d]", sensorHandle, eventType, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + else + { + SysAssertf(false, "ResetSensorCoreDataEventSensingInterval() > sensor_xxx_set_interval() failed. [handle:%p, eventType:%d, result:%d]", sensorHandle, eventType, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return E_OPERATION_FAILED; + } + // SENSOR_ERROR_IO_ERROR or SENSOR_ERROR_OPERATION_FAILED + + } + + return E_SUCCESS; +} +} // Anonymous + +// Getting sensor information ------------------------------------------------------------------------------------------------ // +bool +_ISensorCore::IsSupported(SensorType sensorType) +{ + sensor_type_e sensorTypeE = ConvertToSensorTypeEFromSensorType(sensorType); + + bool isSupported = false; + int sensorResult = sensor_is_supported(sensorTypeE, &isSupported); + if (!IsSuccess(sensorResult)) + { + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "IsSupported() > sensor_is_supported() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return false; + } + else + { + SysAssertf(false, "IsSupported() > sensor_get_spec() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return false; + } + } + + return isSupported; +} + +result +_ISensorCore::GetDescription(SensorType sensorType, Tizen::Base::String& description) +{ + description = L"In preparation..."; + return E_SUCCESS; +} + +result +_ISensorCore::GetVendor(SensorType sensorType, Tizen::Base::String& vendor) +{ + switch (sensorType) + { + case SENSOR_TYPE_TILT: + { +#if _OSP_EMUL_ + vendor = W_MSG_EMUL_VENDOR; +#else + vendor = W_MSG_NOT_SUPPORTED; +#endif + break; + } + default: + { + sensor_type_e sensorTypeE = ConvertToSensorTypeEFromSensorType(sensorType); + + char* pTempStrVendor = null; + char* pDummyStrModelId = null; + float dummyMax = 0.0F; + float dummyMin = 0.0F; + float dummyResolution = 0.0F; + int sensorResult = sensor_get_spec(sensorTypeE, &pTempStrVendor, &pDummyStrModelId, &dummyMax, &dummyMin, &dummyResolution); + if (!IsSuccess(sensorResult)) + { + // PARADOX + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "GetVendor() > sensor_get_spec() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + else + { + SysAssertf(false, "GetVendor() > sensor_get_spec() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return E_OPERATION_FAILED; + } + + } + + vendor = pTempStrVendor; + + free(pTempStrVendor); + free(pDummyStrModelId); + + break; + } + } + + return E_SUCCESS; +} + +result +_ISensorCore::GetModelId(SensorType sensorType, Tizen::Base::String& modelId) +{ + switch (sensorType) + { + case SENSOR_TYPE_TILT: + { +#if _OSP_EMUL_ + modelId = W_MSG_EMUL_MODEL_ID_TILT; +#else + modelId = W_MSG_NOT_SUPPORTED; +#endif + break; + } + default: + { + sensor_type_e sensorTypeE = ConvertToSensorTypeEFromSensorType(sensorType); + + char* pDummyStrVendor = null; + char* pTempStrModelId = null; + float dummyMax = 0.0F; + float dummyMin = 0.0F; + float dummyResolution = 0.0F; + int sensorResult = sensor_get_spec(sensorTypeE, &pDummyStrVendor, &pTempStrModelId, &dummyMax, &dummyMin, &dummyResolution); + if (!IsSuccess(sensorResult)) + { + // PARADOX + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "GetModelId() > sensor_get_spec() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + else + { + SysAssertf(false, "GetModelId() > sensor_get_spec() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return E_OPERATION_FAILED; + } + + + + } + + modelId = pTempStrModelId; + + free(pDummyStrVendor); + free(pTempStrModelId); + + break; + } + } + + return E_SUCCESS; +} + +result +_ISensorCore::GetMeasurementRange(SensorType sensorType, float& min, float& max, float& resolution) +{ + switch (sensorType) + { + case SENSOR_TYPE_TILT: + { + min = MIN_VALUE_TILT; + max = MAX_VALUE_TILT; + resolution = RESOLUTION_VALUE_TILT; + break; + } + default: + { + sensor_type_e sensorTypeE = ConvertToSensorTypeEFromSensorType(sensorType); + + char* pDummyStrVendor = null; + char* pDummyStrModelId = null; + float tempMax = 0.0F; + float tempMin = 0.0F; + float tempResolution = 0.0F; + int sensorResult = sensor_get_spec(sensorTypeE, &pDummyStrVendor, &pDummyStrModelId, &tempMax, &tempMin, &tempResolution); + if (!IsSuccess(sensorResult)) + { + // PARADOX + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "GetMeasurementRange() > sensor_get_spec() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + else + { + SysAssertf(false, "GetMeasurementRange() > sensor_get_spec() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return E_OPERATION_FAILED; + } + + } + + free(pDummyStrVendor); + free(pDummyStrModelId); + + switch (sensorTypeE) + { + case SENSOR_ACCELEROMETER: + min = tempMin * METER_PER_SECOND_SQUARE_TO_G; + max = tempMax * METER_PER_SECOND_SQUARE_TO_G; + resolution = tempResolution * METER_PER_SECOND_SQUARE_TO_G; + break; + case SENSOR_GYROSCOPE: + min = tempMin * DEGREE_TO_RADIAN; + max = tempMax * DEGREE_TO_RADIAN; + resolution = tempResolution * DEGREE_TO_RADIAN; + break; + default: + min = tempMin; + max = tempMax; + resolution = tempResolution; + break; + } + break; + } + } + + return E_SUCCESS; +} + +result +_ISensorCore::GetIntervalRange(SensorType sensorType, long& min, long& max) +{ + sensor_type_e sensorTypeE = ConvertToSensorTypeEFromSensorType(sensorType); + + int tempMin = 0; + int tempMax = 0; +// int sensorResult = sensor_get_delay_boundary(sensorTypeE, &tempMin, &tempMax); // not implemented yet + int sensorResult = GetStaticIntervalRange(sensorType, tempMin, tempMax); + if (!IsSuccess(sensorResult)) + { + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "GetIntervalRange() > sensor_get_delay_boundary() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + else + { + SysAssertf(false, "GetIntervalRange() > sensor_get_delay_boundary() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_OPERATION_FAILED); + return E_OPERATION_FAILED; + } + // SENSOR_ERROR_IO_ERROR + + } + + min = tempMin; + max = tempMax; + + return E_SUCCESS; +} + +bool +_ISensorCore::IsWakeupSupported(SensorType sensorType) +{ + sensor_type_e sensorTypeE = ConvertToSensorTypeEFromSensorType(sensorType); + + bool isWakeupSupported = false; + int sensorResult = sensor_awake_is_supported(sensorTypeE, &isWakeupSupported); + if (!IsSuccess(sensorResult)) + { + // SENSOR_ERROR_IO_ERROR + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "IsWakeupSupported() > sensor_get_delay_boundary() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_DEVICE_UNAVAILABLE); + return false; + } + else + { + SysAssertf(false, "IsWakeupSupported() > sensor_get_delay_boundary() failed. [sensorTypeE:%d, result:%d]", sensorTypeE, sensorResult); + SetLastResult(E_UNSUPPORTED_OPERATION); + return false; + } + } + + return isWakeupSupported; +} + +bool +_ISensorCore::IsObjectDetected(float distance) +{ + bool isObjectDetected = false; +// int sensorResult = sensor_util_is_near(distance, &isNear); + int sensorResult = IsStaticObjectDetected(distance, isObjectDetected); + if (!IsSuccess(sensorResult)) + { + // PARADOX + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysAssertf(false, "IsObjectDetected() > sensor_util_is_near() failed. [distance:%f, result:%d]", distance, sensorResult); + return false; + } + else + { + SysAssertf(false, "IsObjectDetected() > sensor_util_is_near() failed. [distance:%f, result:%d]", distance, sensorResult); + return false; + } + } + + return isObjectDetected; +} + +// Sensor event listener management ------------------------------------------------------------------------------------------ // +result +_ISensorCore::AddSensorCoreEventReceiver(_ISensorCoreEventReceiver& receiver) +{ + // Connect + sensor_h sensorHandle = null; + result r = ConnectToSensorCore(sensorHandle); + if (IsFailed(r)) + { + return r; + } + + // Prepare + receiver.SetSensorCoreEventReceiverState(_ISensorCoreEventReceiver::SENSOR_CORE_EVENT_RECEIVER_STATE_CONNECTED); + _SensorCoreEventType eventType = receiver.GetSensorCoreEventType(); + long interval = receiver.GetSensorCoreDataEventInterval(); + void* pUserData = &receiver; + r = PrepareSensorCoreEventSensing(sensorHandle, eventType, interval, pUserData); + if (IsFailed(r)) + { + DisconnectFromSensorCore(sensorHandle); + receiver.SetSensorCoreEventReceiverState(_ISensorCoreEventReceiver::SENSOR_CORE_EVENT_RECEIVER_STATE_NONE); + return r; + } + + // Start + receiver.SetSensorCoreEventReceiverState(_ISensorCoreEventReceiver::SENSOR_CORE_EVENT_RECEIVER_STATE_PREPARED); + receiver.SetSensorCoreEventHandle(sensorHandle); + r = StartSensorCoreEventSensing(sensorHandle, eventType); + if (IsFailed(r)) + { + receiver.SetSensorCoreEventHandle(null); + UnprepareSensorCoreEventSensing(sensorHandle, eventType); + DisconnectFromSensorCore(sensorHandle); + receiver.SetSensorCoreEventReceiverState(_ISensorCoreEventReceiver::SENSOR_CORE_EVENT_RECEIVER_STATE_NONE); + return r; + } + + receiver.SetSensorCoreEventReceiverState(_ISensorCoreEventReceiver::SENSOR_CORE_EVENT_RECEIVER_STATE_STARTED); + + return E_SUCCESS; +} + +result +_ISensorCore::RemoveSensorCoreEventReceiver(_ISensorCoreEventReceiver& receiver) +{ + sensor_h sensorHandle = static_cast(receiver.GetSensorCoreEventHandle()); + _SensorCoreEventType eventType = receiver.GetSensorCoreEventType(); + result r = E_SUCCESS; + + // Stop + if (receiver.GetSensorCoreEventReceiverState() == _ISensorCoreEventReceiver::SENSOR_CORE_EVENT_RECEIVER_STATE_STARTED) + { + r = StopSensorCoreEventSensing(sensorHandle, eventType); + if (IsFailed(r)) + { + return r; + } + + receiver.SetSensorCoreEventReceiverState(_ISensorCoreEventReceiver::SENSOR_CORE_EVENT_RECEIVER_STATE_PREPARED); + } + + // Unprepare + if (receiver.GetSensorCoreEventReceiverState() == _ISensorCoreEventReceiver::SENSOR_CORE_EVENT_RECEIVER_STATE_PREPARED) + { + r = UnprepareSensorCoreEventSensing(sensorHandle, eventType); + if (IsFailed(r)) + { + return r; + } + + receiver.SetSensorCoreEventReceiverState(_ISensorCoreEventReceiver::SENSOR_CORE_EVENT_RECEIVER_STATE_CONNECTED); + } + + // Disconnect + if (receiver.GetSensorCoreEventReceiverState() == _ISensorCoreEventReceiver::SENSOR_CORE_EVENT_RECEIVER_STATE_CONNECTED) + { + r = DisconnectFromSensorCore(sensorHandle); + if (IsFailed(r)) + { + return r; + } + + receiver.SetSensorCoreEventReceiverState(_ISensorCoreEventReceiver::SENSOR_CORE_EVENT_RECEIVER_STATE_NONE); + receiver.SetSensorCoreEventHandle(null); + } + + return E_SUCCESS; +} + +result +_ISensorCore::ResetSensorCoreEventReceivingInterval(_ISensorCoreEventReceiver& receiver) +{ + sensor_h sensorHandle = static_cast(receiver.GetSensorCoreEventHandle()); + _SensorCoreEventType eventType = receiver.GetSensorCoreEventType(); + long interval = receiver.GetSensorCoreDataEventInterval(); + + result r = ResetSensorCoreDataEventSensingInterval(sensorHandle, eventType, interval); + if (IsFailed(r)) + { + return r; + } + + return E_SUCCESS; +} + +// Sensor wake up management ------------------------------------------------------------------------------------------------- // +result +_ISensorCore::SetWakeupEnabled(SensorType sensorType, bool enable) +{ + +#if _OSP_EMUL_ + return E_SUCCESS; +#else + // not implemented yet + return E_DEVICE_UNAVAILABLE; +#endif +} + +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensor_ISensorCore.h b/src/FUixSensor_ISensorCore.h new file mode 100644 index 0000000..0886e50 --- /dev/null +++ b/src/FUixSensor_ISensorCore.h @@ -0,0 +1,64 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.1 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUixSensor_ISensorCore.h + * @brief This is the header file for the %_ISensorCore interface class. + * + * This header file contains the declarations of the %_ISensorCore interface class. + */ + +#ifndef _FUIX_SENSOR_INTERNAL_ISENSOR_CORE_H_ +#define _FUIX_SENSOR_INTERNAL_ISENSOR_CORE_H_ + +#include +#include + +namespace Tizen { namespace Base +{ +class String; +} } // Tizen::Base + +namespace Tizen { namespace Uix { namespace Sensor +{ +class _ISensorCoreEventReceiver; + +class _ISensorCore +{ +public: + static bool IsSupported(Tizen::Uix::Sensor::SensorType sensorType); + static result GetDescription(Tizen::Uix::Sensor::SensorType sensorType, Tizen::Base::String& description); + static result GetVendor(Tizen::Uix::Sensor::SensorType sensorType, Tizen::Base::String& vendor); + static result GetModelId(Tizen::Uix::Sensor::SensorType sensorType, Tizen::Base::String& modelId); + static result GetMeasurementRange(Tizen::Uix::Sensor::SensorType sensorType, float& min, float& max, float& resolution); + static result GetIntervalRange(Tizen::Uix::Sensor::SensorType sensorType, long& min, long& max); + static bool IsWakeupSupported(Tizen::Uix::Sensor::SensorType sensorType); + static bool IsObjectDetected(float distance); + + static result AddSensorCoreEventReceiver(Tizen::Uix::Sensor::_ISensorCoreEventReceiver& receiver); + static result RemoveSensorCoreEventReceiver(Tizen::Uix::Sensor::_ISensorCoreEventReceiver& receiver); + static result ResetSensorCoreEventReceivingInterval(Tizen::Uix::Sensor::_ISensorCoreEventReceiver& receiver); + + static result SetWakeupEnabled(Tizen::Uix::Sensor::SensorType sensorType, bool enable); + +private: + _ISensorCore(void); + ~_ISensorCore(void); +}; // _ISensorCore +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_INTERNAL_ISENSOR_CORE_H_ diff --git a/src/FUixSensor_ISensorCoreEventReceiver.h b/src/FUixSensor_ISensorCoreEventReceiver.h new file mode 100644 index 0000000..401f294 --- /dev/null +++ b/src/FUixSensor_ISensorCoreEventReceiver.h @@ -0,0 +1,64 @@ +// +// 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 FUixSensor_ISensorCoreEventReceiver.h + * @brief This is the header file for the %_ISensorCoreEventReceiver interface class. + * + * This header file contains the declarations of the %_ISensorCoreEventReceiver interface class. + */ + +#ifndef _FUIX_SENSOR_INTERNAL_ISENSOR_CORE_EVENT_RECEIVER_H_ +#define _FUIX_SENSOR_INTERNAL_ISENSOR_CORE_EVENT_RECEIVER_H_ + +#include +#include "FUixSensor_SensorCoreEventTypes.h" + +namespace Tizen { namespace Uix { namespace Sensor +{ +class _ISensorCoreEventReceiver +{ +public: + virtual ~_ISensorCoreEventReceiver(void){} + + virtual Tizen::Uix::Sensor::_SensorCoreEvent& GetSensorCoreEventBuffer(void) = 0; + virtual void OnSensorCoreEventReceived(Tizen::Uix::Sensor::_SensorCoreEvent& event) = 0; + +protected: + enum SensorCoreEventReceiverState + { + SENSOR_CORE_EVENT_RECEIVER_STATE_NONE = 0, + SENSOR_CORE_EVENT_RECEIVER_STATE_CONNECTED, + SENSOR_CORE_EVENT_RECEIVER_STATE_PREPARED, + SENSOR_CORE_EVENT_RECEIVER_STATE_STARTED + }; + +private: + virtual Tizen::Uix::Sensor::_SensorCoreEventType GetSensorCoreEventType(void) const = 0; + virtual long GetSensorCoreDataEventInterval(void) const = 0; + + virtual void SetSensorCoreEventHandle(Tizen::Uix::Sensor::_SensorCoreEventHandle sensorCoreEventHandle) = 0; + virtual Tizen::Uix::Sensor::_SensorCoreEventHandle GetSensorCoreEventHandle(void) const = 0; + + virtual void SetSensorCoreEventReceiverState(Tizen::Uix::Sensor::_ISensorCoreEventReceiver::SensorCoreEventReceiverState state) = 0; + virtual Tizen::Uix::Sensor::_ISensorCoreEventReceiver::SensorCoreEventReceiverState GetSensorCoreEventReceiverState(void) const = 0; + + friend class _ISensorCore; +}; // _ISensorCoreEventReceiver +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_INTERNAL_ISENSOR_CORE_EVENT_RECEIVER_H_ diff --git a/src/FUixSensor_MotionImpl.cpp b/src/FUixSensor_MotionImpl.cpp new file mode 100644 index 0000000..365d39b --- /dev/null +++ b/src/FUixSensor_MotionImpl.cpp @@ -0,0 +1,339 @@ +// +// 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 +#include +#include + +using namespace Tizen::Base; + +namespace Tizen { namespace Uix { namespace Sensor +{ + + + +void +_MotionImpl:: __MotionSnapEventReceiver(unsigned long long timeStamp, sensor_motion_snap_e snap, void *pData) +{ + IMotionEventListener* pMotionEventListener = (IMotionEventListener*) pData; + + SysLog(NID_UIX, "Detected SNAP event(%d)\n", snap); + + switch (snap) + { + case SENSOR_MOTION_SNAP_X_POSITIVE: + pMotionEventListener->OnSnapDetected(MOTION_SNAP_X_POSITIVE); + break; + + case SENSOR_MOTION_SNAP_X_NEGATIVE: + pMotionEventListener->OnSnapDetected(MOTION_SNAP_X_NEGATIVE); + break; + + case SENSOR_MOTION_SNAP_Y_NEGATIVE: + pMotionEventListener->OnSnapDetected(MOTION_SNAP_Y_NEGATIVE); + break; + + case SENSOR_MOTION_SNAP_Y_POSITIVE: + pMotionEventListener->OnSnapDetected(MOTION_SNAP_Y_POSITIVE); + break; + + case SENSOR_MOTION_SNAP_Z_POSITIVE: + pMotionEventListener->OnSnapDetected(MOTION_SNAP_Z_POSITIVE); + break; + + case SENSOR_MOTION_SNAP_Z_NEGATIVE: + pMotionEventListener->OnSnapDetected(MOTION_SNAP_Z_NEGATIVE); + break; + } +} +void +_MotionImpl::__MotionShakeEventReceiver(unsigned long long timeStamp, sensor_motion_shake_e shake, void *pData) +{ + IMotionEventListener* pMotionEventListener = (IMotionEventListener*) pData; + + SysLog(NID_UIX, "Detected SHAKE event(%d)\n", shake); + switch (shake) + { + case SENSOR_MOTION_SHAKE_DETECTED: + pMotionEventListener->OnShakeDetected(MOTION_STARTED); + break; + + case SENSOR_MOTION_SHAKE_CONTINUING: + pMotionEventListener->OnShakeDetected(MOTION_INPROGRESS); + break; + + case SENSOR_MOTION_SHAKE_FINISHED: + pMotionEventListener->OnShakeDetected(MOTION_ENDED); + break; + } + +} +void +_MotionImpl::__MotionDoubleTapEventReceiver(unsigned long long timeStamp, void *pData) +{ + IMotionEventListener* pMotionEventListener = (IMotionEventListener*) pData; + + SysLog(NID_UIX, "Detected DOUBLETAP event \n"); + + pMotionEventListener->OnDoubleTapDetected(); + +} +void +_MotionImpl::__MotionDirectCallEventReceiver(unsigned long long timeStamp, void *pData) +{ + IMotionEventListener* pMotionEventListener = (IMotionEventListener*) pData; + + SysLog(NID_UIX, "Detected MOVETOEAR event \n"); + + pMotionEventListener->OnMoveToEarDetected(); +} + +_MotionImpl::_MotionImpl(void) + : __pIMotionEventListener(null) + , __handle(null) + , __motionType(MOTION_TYPE_NONE) +{ +} + +_MotionImpl::~_MotionImpl(void) +{ + int sensorResult = SENSOR_ERROR_NONE; + + if (__motionType & MOTION_TYPE_SNAP) + { + sensorResult = sensor_stop(__handle, SENSOR_MOTION_SNAP); + SysTryReturnVoidResult(NID_UIX, sensorResult != SENSOR_ERROR_NONE, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The motion detection feature is not supported"); + } + if (__motionType & MOTION_TYPE_SHAKE) + { + sensorResult = sensor_stop(__handle, SENSOR_MOTION_SHAKE); + SysTryReturnVoidResult(NID_UIX, sensorResult != SENSOR_ERROR_NONE, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The motion detection feature is not supported"); + } + if (__motionType & MOTION_TYPE_MOVE_TO_EAR) + { + sensorResult = sensor_stop(__handle, SENSOR_MOTION_DIRECTCALL); + SysTryReturnVoidResult(NID_UIX, sensorResult != SENSOR_ERROR_NONE, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The motion detection feature is not supported"); + } + if (__motionType & MOTION_TYPE_DOUBLETAP) + { + sensorResult = sensor_stop(__handle, SENSOR_MOTION_DOUBLETAP); + SysTryReturnVoidResult(NID_UIX, sensorResult != SENSOR_ERROR_NONE, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The motion detection feature is not supported"); + } + + sensorResult = sensor_destroy(__handle); + SysTryReturnVoidResult(NID_UIX, sensorResult != SENSOR_ERROR_NONE, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The motion detection feature is not supported"); + + __handle = null; +} + +result +_MotionImpl::Construct(IMotionEventListener& listener) +{ + result r = E_SUCCESS; + + int sensorResult = SENSOR_ERROR_NONE; + + sensorResult = sensor_create(&__handle); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The motion detection feature instance is not created"); + + sensorResult = sensor_start(__handle, SENSOR_MOTION_SNAP); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_NOT_SUPPORTED, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The motion detection feature is not supported"); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_IO_ERROR, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Sensor couldn't start"); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_OPERATION_FAILED, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Sensor couldn't start"); + sensor_set_always_on(__handle, SENSOR_MOTION_SNAP); + + sensorResult = sensor_start(__handle, SENSOR_MOTION_SHAKE); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_NOT_SUPPORTED, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The motion detection feature is not supported"); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_IO_ERROR, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Sensor couldn't start"); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_OPERATION_FAILED, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Sensor couldn't start"); + sensor_set_always_on(__handle, SENSOR_MOTION_SHAKE); + + sensorResult = sensor_start(__handle, SENSOR_MOTION_DOUBLETAP); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_NOT_SUPPORTED, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The motion detection feature is not supported"); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_IO_ERROR, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Sensor couldn't start"); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_OPERATION_FAILED, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Sensor couldn't start"); + sensor_set_always_on(__handle, SENSOR_MOTION_DOUBLETAP); + + sensorResult = sensor_start(__handle, SENSOR_MOTION_DIRECTCALL); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_NOT_SUPPORTED, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] The motion detection feature is not supported"); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_IO_ERROR, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Sensor couldn't start"); + SysTryReturn(NID_UIX, sensorResult != SENSOR_ERROR_OPERATION_FAILED, E_INVALID_STATE, E_INVALID_STATE, "[E_INVALID_STATE] Sensor couldn't start"); + sensor_set_always_on(__handle, SENSOR_MOTION_DIRECTCALL); + + __pIMotionEventListener = &listener; + return r; +} + +void +_MotionImpl::SetEnabled(unsigned long type) +{ + int ret = 0; + + SysLog(NID_UIX, "type(%d) / __motionType(%d)", (int)type, (int)__motionType); + + SetLastResult(E_INVALID_STATE); + + if (type & MOTION_TYPE_SNAP) + { + if (__motionType & MOTION_TYPE_SNAP) + { + SysLog(NID_UIX, "MOTION_TYPE_SNAP is already registered."); + } + else + { + ret = sensor_motion_snap_set_cb(__handle, __MotionSnapEventReceiver, (void*) __pIMotionEventListener); + SysTryReturnVoidResult(NID_UIX, ret == SENSOR_ERROR_NONE, E_INVALID_STATE, "[E_INVALID_STATE] Failed to register motion snap event."); + } + } + else + { + if (__motionType & MOTION_TYPE_SNAP) + { + ret = sensor_motion_snap_unset_cb(__handle); + SysTryReturnVoidResult(NID_UIX, ret == SENSOR_ERROR_NONE, E_INVALID_STATE, "[E_INVALID_STATE] Failed to unregister motion snap event."); + } + } + + if (type & MOTION_TYPE_SHAKE) + { + if (__motionType & MOTION_TYPE_SHAKE) + { + SysLog(NID_UIX, "MOTION_TYPE_SHAKE is already registered."); + } + else + { + ret = sensor_motion_shake_set_cb(__handle, __MotionShakeEventReceiver, (void*) __pIMotionEventListener); + SysTryReturnVoidResult(NID_UIX, ret == SENSOR_ERROR_NONE, E_INVALID_STATE, "[E_INVALID_STATE] Failed to register motion shake event."); + } + } + else + { + if (__motionType & MOTION_TYPE_SHAKE) + { + ret = sensor_motion_shake_unset_cb(__handle); + SysTryReturnVoidResult(NID_UIX, ret == SENSOR_ERROR_NONE, E_INVALID_STATE, "[E_INVALID_STATE] Failed to unregister motion shake event."); + } + } + + if (type & MOTION_TYPE_DOUBLETAP) + { + if (__motionType & MOTION_TYPE_DOUBLETAP) + { + SysLog(NID_UIX, "MOTION_TYPE_DOUBLETAP is already registered."); + } + else + { + ret = sensor_motion_doubletap_set_cb(__handle, __MotionDoubleTapEventReceiver, (void*) __pIMotionEventListener); + SysTryReturnVoidResult(NID_UIX, ret == SENSOR_ERROR_NONE, E_INVALID_STATE, "[E_INVALID_STATE] Failed to register motion double tap event."); + } + } + else + { + if (__motionType & MOTION_TYPE_DOUBLETAP) + { + ret = sensor_motion_doubletap_unset_cb(__handle); + SysTryReturnVoidResult(NID_UIX, ret == SENSOR_ERROR_NONE, E_INVALID_STATE, "[E_INVALID_STATE] Failed to unregister motion double tap event."); + } + } + + if (type & MOTION_TYPE_MOVE_TO_EAR) + { + if (__motionType & MOTION_TYPE_MOVE_TO_EAR) + { + SysLog(NID_UIX, "MOTION_TYPE_MOVE_TO_EAR is already registered."); + } + else + { + ret = sensor_motion_directcall_set_cb(__handle, __MotionDirectCallEventReceiver, (void*) __pIMotionEventListener); + SysTryReturnVoidResult(NID_UIX, ret == SENSOR_ERROR_NONE, E_INVALID_STATE, "[E_INVALID_STATE] Failed to register motion direct call event."); + } + } + else + { + if (__motionType & MOTION_TYPE_MOVE_TO_EAR) + { + ret = sensor_motion_directcall_unset_cb(__handle); + SysTryReturnVoidResult(NID_UIX, ret == SENSOR_ERROR_NONE, E_INVALID_STATE, "[E_INVALID_STATE] Failed to unregister motion direct call event."); + } + } + + __motionType = type; + + SetLastResult(E_SUCCESS); +} + +bool +_MotionImpl::IsSupported(MotionType type) const +{ + bool isSupported = false; + + switch (type) + { + case MOTION_TYPE_SNAP: + // fall through + case MOTION_TYPE_SHAKE: + // fall through + case MOTION_TYPE_DOUBLETAP: + // fall through + case MOTION_TYPE_MOVE_TO_EAR: + + isSupported = true; + break; + + default: + isSupported = false; + break; + } + + SetLastResult(E_SUCCESS); + + return isSupported; +} + +bool +_MotionImpl::IsMotionTypeValid(unsigned long type) +{ + if (type > MOTION_TYPE_NONE && type <= (MOTION_TYPE_SNAP | MOTION_TYPE_SHAKE | MOTION_TYPE_DOUBLETAP | MOTION_TYPE_MOVE_TO_EAR)) + { + return true; + } + else if (type == MOTION_TYPE_NONE || type == MOTION_TYPE_ALL) + { + return true; + } + else + { + return false; + } +} + +_MotionImpl* +_MotionImpl::GetInstance(Motion& motion) +{ + return motion.__pMotionImpl; +} + +const _MotionImpl* +_MotionImpl::GetInstance(const Motion& motion) +{ + return motion.__pMotionImpl; +} + +} } } // Tizen::Uix::Sensor diff --git a/src/FUixSensor_SensorCoreEventTypes.h b/src/FUixSensor_SensorCoreEventTypes.h new file mode 100644 index 0000000..c6d2705 --- /dev/null +++ b/src/FUixSensor_SensorCoreEventTypes.h @@ -0,0 +1,135 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.1 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUixSensor_SensorCoreEventTypes.h + * @brief This is the header file for the common data types and constants used by the _SensorEventDeliverer and the _ISensorCore. + * + * This header file contains the declarations of the common data types and constants used by _SensorEventDeliverer and the _ISensorCore. + */ + +#ifndef _FUIX_SENSOR_INTERNAL_SENSOR_CORE_EVENT_TYPES_H_ +#define _FUIX_SENSOR_INTERNAL_SENSOR_CORE_EVENT_TYPES_H_ + +namespace Tizen { namespace Uix { namespace Sensor +{ +typedef void* _SensorCoreEventHandle; + +enum _SensorCoreEventType +{ + _SENSOR_CORE_EVENT_TYPE_ACCELERATION_DATA = 0, + _SENSOR_CORE_EVENT_TYPE_MAGNETIC_FIELD_DATA, + _SENSOR_CORE_EVENT_TYPE_PROXIMITY_DISTANCE_DATA, + _SENSOR_CORE_EVENT_TYPE_TILT_DATA, + _SENSOR_CORE_EVENT_TYPE_ROTATION_RATE_DATA, + _SENSOR_CORE_EVENT_TYPE_LIGHT_LEVEL_DATA, + _SENSOR_CORE_EVENT_TYPE_ACCELERATION_SENSOR_WAKEUP, + _SENSOR_CORE_EVENT_TYPE_GRAVITY_DATA, + _SENSOR_CORE_EVENT_TYPE_USER_ACCELERATION_DATA, + _SENSOR_CORE_EVENT_TYPE_DEVICE_ORIENTATION_DATA, + _SENSOR_CORE_EVENT_TYPE_MAX, + _SENSOR_CORE_EVENT_TYPE_NONE = -1, +}; + +struct _SensorCoreEventValue +{ + float value; +}; + +struct _SensorCoreEventAxisOf3Dimension +{ + float x; + float y; + float z; +}; + +struct _SensorCoreEventRotationAxisOf3Dimension +{ + float roll; + float pitch; + float yaw; +}; + +struct _SensorCoreEventAzimuth +{ + float azimuth; +}; + +struct _SensorCoreEventDistance +{ + float distance; +}; + +struct _SensorCoreEventTiltAxisOf3Dimension +{ + float roll; + float pitch; + float azimuth; +}; + +struct _SensorCoreEventDeviceOrientationAxisOf3Dimension +{ + float yaw; + float roll; + float pitch; +}; + + +struct _SensorCoreEventLevel +{ + float level; +}; + +union _SensorCoreEventKind +{ + _SensorCoreEventValue invalidValueData; + _SensorCoreEventAxisOf3Dimension accelerationData; + _SensorCoreEventAxisOf3Dimension magneticFieldData; + _SensorCoreEventDistance proximityDistanceData; + _SensorCoreEventTiltAxisOf3Dimension tiltData; + _SensorCoreEventAxisOf3Dimension rotationRateData; + _SensorCoreEventLevel lightLevelData; + _SensorCoreEventAxisOf3Dimension gravityData; + _SensorCoreEventAxisOf3Dimension userAccelerationData; + _SensorCoreEventDeviceOrientationAxisOf3Dimension deviceOrientationData; +}; + +struct _SensorCoreEvent +{ + bool isEventValid; + _SensorCoreEventType eventType; + long long eventTimestamp; + _SensorCoreEventKind eventKind; +}; + +static const _SensorCoreEventHandle INVALID_SENSOR_CORE_EVENT_HANDLE = 0; + +static const long long INVALID_SENSOR_CORE_EVENT_TIMESTAMP = 0LL; + +static const long INVALID_SENSOR_CORE_EVENT_INTERVAL = 0L; + +static const float INVALID_SENSOR_CORE_EVENT_VALUE = -9999.9999F; + +static const _SensorCoreEvent INVALID_SENSOR_CORE_EVENT = { + false, + _SENSOR_CORE_EVENT_TYPE_NONE, + INVALID_SENSOR_CORE_EVENT_TIMESTAMP, + { { INVALID_SENSOR_CORE_EVENT_VALUE } } +}; +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_INTERNAL_SENSOR_CORE_EVENT_TYPES_H_ diff --git a/src/FUixSensor_SensorEventDeliverer.cpp b/src/FUixSensor_SensorEventDeliverer.cpp new file mode 100644 index 0000000..21d8e17 --- /dev/null +++ b/src/FUixSensor_SensorEventDeliverer.cpp @@ -0,0 +1,417 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.1 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUixSensor_SensorEventDeliverer.cpp + * @brief This is the implementation file for the %_SensorEventDeliverer class. + * + * This files contains implementation of the %_SensorEventDeliverer class. + */ + +// Includes +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "FUixSensor_SensorEventDeliverer.h" +#include "FUixSensor_ISensorCore.h" +#include "FUixSensor_SensorCoreEventTypes.h" +#include "FUixSensor_SensorUtil.h" + +namespace Tizen { namespace Uix { namespace Sensor +{ +_SensorEventDeliverer::_SensorEventDeliverer(void) + : __eventType(_SensorEventDeliverer::SENSOR_EVENT_TYPE_NONE) + , __pListener(null) + , __sensorType(SENSOR_TYPE_NONE) + , __interval(INVALID_SENSOR_CORE_EVENT_INTERVAL) + , __dataChanged(false) + , __sensorCoreEventHandle(INVALID_SENSOR_CORE_EVENT_HANDLE) + , __state(SENSOR_CORE_EVENT_RECEIVER_STATE_NONE) + , __currentSensorCoreEvent(INVALID_SENSOR_CORE_EVENT) + , __beforeSensorCoreEvent(INVALID_SENSOR_CORE_EVENT) +{ + +} + +_SensorEventDeliverer::~_SensorEventDeliverer(void) +{ + if (GetSensorCoreEventReceiverState() != SENSOR_CORE_EVENT_RECEIVER_STATE_NONE) + { + Stop(); + } +} + +void +_SensorEventDeliverer::SetDataEventInfo(Tizen::Uix::Sensor::ISensorEventListener& listener, Tizen::Uix::Sensor::SensorType sensorType, long interval, bool dataChanged) +{ + __eventType = _SensorEventDeliverer::SENSOR_EVENT_TYPE_DATA; + __pListener = &listener; + __sensorType = sensorType; + __interval = interval; + __dataChanged = dataChanged; +} + +void +_SensorEventDeliverer::SetWakeupEventInfo(Tizen::Uix::Sensor::ISensorEventListener& listener, Tizen::Uix::Sensor::SensorType sensorType) +{ + __eventType = _SensorEventDeliverer::SENSOR_EVENT_TYPE_WAKE_UP; + __pListener = &listener; + __sensorType = sensorType; +} + +bool +_SensorEventDeliverer::IsListenerEquals(ISensorEventListener& listener) const +{ + return __pListener == &listener; +} + +result +_SensorEventDeliverer::Start(void) +{ + return _ISensorCore::AddSensorCoreEventReceiver(*this); +} + +result +_SensorEventDeliverer::Stop(void) +{ + return _ISensorCore::RemoveSensorCoreEventReceiver(*this); +} + +result +_SensorEventDeliverer::ResetInterval(long interval) +{ + if (!IsEquals(__interval, interval)) + { + __interval = interval; + // TODO: Use it +// return _ISensorCore::ResetSensorCoreEventReceivingInterval(*this); + + // Temporary implementation + result r = _ISensorCore::RemoveSensorCoreEventReceiver(*this); + if (IsFailed(r)) + { + return r; + } + return _ISensorCore::AddSensorCoreEventReceiver(*this); + } + + return E_SUCCESS; +} + +Tizen::Uix::Sensor::SensorData& +_SensorEventDeliverer::GetSensorDataBuffer(void) +{ + static SensorData sensorData; + return sensorData; +} + +namespace +{ +_SensorCoreEventType +ConvertToSensorCoreDataEventTypeFromSensorType(SensorType sensorType) +{ + switch (sensorType) + { + case SENSOR_TYPE_ACCELERATION: + return _SENSOR_CORE_EVENT_TYPE_ACCELERATION_DATA; + case SENSOR_TYPE_MAGNETIC: + return _SENSOR_CORE_EVENT_TYPE_MAGNETIC_FIELD_DATA; + case SENSOR_TYPE_PROXIMITY: + return _SENSOR_CORE_EVENT_TYPE_PROXIMITY_DISTANCE_DATA; + case SENSOR_TYPE_TILT: + return _SENSOR_CORE_EVENT_TYPE_TILT_DATA; + case SENSOR_TYPE_GYRO: + return _SENSOR_CORE_EVENT_TYPE_ROTATION_RATE_DATA; + case SENSOR_TYPE_LIGHT: + return _SENSOR_CORE_EVENT_TYPE_LIGHT_LEVEL_DATA; + case SENSOR_TYPE_GRAVITY: + return _SENSOR_CORE_EVENT_TYPE_GRAVITY_DATA; + case SENSOR_TYPE_USER_ACCELERATION: + return _SENSOR_CORE_EVENT_TYPE_USER_ACCELERATION_DATA; + case SENSOR_TYPE_DEVICE_ORIENTATION: + return _SENSOR_CORE_EVENT_TYPE_DEVICE_ORIENTATION_DATA; + default: + SysAssertf(false, "ConvertToSensorCoreEventTypeFromSensorType() > Invalid SensorType [sensorType:%d]", sensorType); + return _SENSOR_CORE_EVENT_TYPE_NONE; + } +} + +_SensorCoreEventType +ConvertToSensorCoreWakeupEventTypeFromSensorType(SensorType sensorType) +{ + switch (sensorType) + { + case SENSOR_TYPE_ACCELERATION: + return _SENSOR_CORE_EVENT_TYPE_ACCELERATION_SENSOR_WAKEUP; + default: + SysAssertf(false, "ConvertToSensorCoreEventTypeFromSensorType() > Invalid SensorType [sensorType:%d]", sensorType); + return _SENSOR_CORE_EVENT_TYPE_NONE; + } +} + +bool +IsSensorCoreEventChanged(_SensorCoreEventType eventType, _SensorCoreEvent& before, _SensorCoreEvent& after) +{ + switch (eventType) + { + case _SENSOR_CORE_EVENT_TYPE_ACCELERATION_DATA: + { + if (IsEquals(before.eventKind.accelerationData.x, after.eventKind.accelerationData.x) && + IsEquals(before.eventKind.accelerationData.y, after.eventKind.accelerationData.y) && + IsEquals(before.eventKind.accelerationData.z, after.eventKind.accelerationData.z)) + { + return false; + } + break; + } + case _SENSOR_CORE_EVENT_TYPE_MAGNETIC_FIELD_DATA: + { + if (IsEquals(before.eventKind.magneticFieldData.x, after.eventKind.magneticFieldData.x) && + IsEquals(before.eventKind.magneticFieldData.y, after.eventKind.magneticFieldData.y) && + IsEquals(before.eventKind.magneticFieldData.z, after.eventKind.magneticFieldData.z)) + { + return false; + } + break; + } + case _SENSOR_CORE_EVENT_TYPE_PROXIMITY_DISTANCE_DATA: + { + if (IsEquals(before.eventKind.proximityDistanceData.distance, after.eventKind.proximityDistanceData.distance)) + { + return false; + } + break; + } + case _SENSOR_CORE_EVENT_TYPE_TILT_DATA: + { + if (IsEquals(before.eventKind.tiltData.roll, after.eventKind.tiltData.roll) && + IsEquals(before.eventKind.tiltData.pitch, after.eventKind.tiltData.pitch) && + IsEquals(before.eventKind.tiltData.azimuth, after.eventKind.tiltData.azimuth)) + { + return false; + } + break; + } + case _SENSOR_CORE_EVENT_TYPE_ROTATION_RATE_DATA: + { + if (IsEquals(before.eventKind.rotationRateData.x, after.eventKind.rotationRateData.x) && + IsEquals(before.eventKind.rotationRateData.y, after.eventKind.rotationRateData.y) && + IsEquals(before.eventKind.rotationRateData.z, after.eventKind.rotationRateData.z)) + { + return false; + } + break; + } + case _SENSOR_CORE_EVENT_TYPE_LIGHT_LEVEL_DATA: + { + if (IsEquals(before.eventKind.lightLevelData.level, after.eventKind.lightLevelData.level)) + { + return false; + } + break; + } + case _SENSOR_CORE_EVENT_TYPE_GRAVITY_DATA: + { + if (IsEquals(before.eventKind.gravityData.x, after.eventKind.gravityData.x) && + IsEquals(before.eventKind.gravityData.y, after.eventKind.gravityData.y) && + IsEquals(before.eventKind.gravityData.z, after.eventKind.gravityData.z)) + { + return false; + } + break; + } + case _SENSOR_CORE_EVENT_TYPE_USER_ACCELERATION_DATA: + { + if (IsEquals(before.eventKind.userAccelerationData.x, after.eventKind.userAccelerationData.x) && + IsEquals(before.eventKind.userAccelerationData.y, after.eventKind.userAccelerationData.y) && + IsEquals(before.eventKind.userAccelerationData.z, after.eventKind.userAccelerationData.z)) + { + return false; + } + break; + } + case _SENSOR_CORE_EVENT_TYPE_DEVICE_ORIENTATION_DATA: + { + if (IsEquals(before.eventKind.deviceOrientationData.yaw, after.eventKind.deviceOrientationData.yaw) && + IsEquals(before.eventKind.deviceOrientationData.roll, after.eventKind.deviceOrientationData.roll) && + IsEquals(before.eventKind.deviceOrientationData.pitch, after.eventKind.deviceOrientationData.pitch)) + { + return false; + } + break; + } + default: + { + SysAssertf(false, "IsSensorCoreEventChanged() > Invalid _SensorCoreEventType [eventType:%d]", eventType); + return false; + } + } + + return true; +} +} // Anonymous + +_SensorCoreEventType +_SensorEventDeliverer::GetSensorCoreEventType(void) const +{ + if (__eventType == _SensorEventDeliverer::SENSOR_EVENT_TYPE_WAKE_UP) + { + return ConvertToSensorCoreWakeupEventTypeFromSensorType(__sensorType); + } + else + { + return ConvertToSensorCoreDataEventTypeFromSensorType(__sensorType); + } +} + +long +_SensorEventDeliverer::GetSensorCoreDataEventInterval(void) const +{ + return __interval; +} + +void +_SensorEventDeliverer::SetSensorCoreEventHandle(_SensorCoreEventHandle sensorCoreEventHandle) +{ + __sensorCoreEventHandle = sensorCoreEventHandle; +} + +_SensorCoreEventHandle +_SensorEventDeliverer::GetSensorCoreEventHandle(void) const +{ + return __sensorCoreEventHandle; +} + +void +_SensorEventDeliverer::SetSensorCoreEventReceiverState(SensorCoreEventReceiverState state) +{ + __state = state; +} + +_ISensorCoreEventReceiver::SensorCoreEventReceiverState +_SensorEventDeliverer::GetSensorCoreEventReceiverState(void) const +{ + return __state; +} + +_SensorCoreEvent& +_SensorEventDeliverer::GetSensorCoreEventBuffer(void) +{ + return __currentSensorCoreEvent; +} + +void +_SensorEventDeliverer::OnSensorCoreEventReceived(_SensorCoreEvent& event) +{ + _SensorCoreEventType eventType = event.eventType; + if (__dataChanged) + { + if (!IsSensorCoreEventChanged(eventType, __beforeSensorCoreEvent, event)) + { + __beforeSensorCoreEvent = event; + return; + } + + __beforeSensorCoreEvent = event; + } + + SensorData& sensorDataBuffer = GetSensorDataBuffer(); + sensorDataBuffer.timestamp = event.eventTimestamp; + + switch (eventType) + { + case _SENSOR_CORE_EVENT_TYPE_ACCELERATION_DATA: + { + static_cast(sensorDataBuffer).x = event.eventKind.accelerationData.x; + static_cast(sensorDataBuffer).y = event.eventKind.accelerationData.y; + static_cast(sensorDataBuffer).z = event.eventKind.accelerationData.z; + break; + } + case _SENSOR_CORE_EVENT_TYPE_MAGNETIC_FIELD_DATA: + { + static_cast(sensorDataBuffer).x = event.eventKind.magneticFieldData.x; + static_cast(sensorDataBuffer).y = event.eventKind.magneticFieldData.y; + static_cast(sensorDataBuffer).z = event.eventKind.magneticFieldData.z; + break; + } + case _SENSOR_CORE_EVENT_TYPE_PROXIMITY_DISTANCE_DATA: + { + static_cast(sensorDataBuffer).distance = event.eventKind.proximityDistanceData.distance; + break; + } + case _SENSOR_CORE_EVENT_TYPE_TILT_DATA: + { + static_cast(sensorDataBuffer).roll = event.eventKind.tiltData.roll; + static_cast(sensorDataBuffer).pitch = event.eventKind.tiltData.pitch; + static_cast(sensorDataBuffer).azimuth = event.eventKind.tiltData.azimuth; + break; + } + case _SENSOR_CORE_EVENT_TYPE_ROTATION_RATE_DATA: + { + static_cast(sensorDataBuffer).x = event.eventKind.rotationRateData.x; + static_cast(sensorDataBuffer).y = event.eventKind.rotationRateData.y; + static_cast(sensorDataBuffer).z = event.eventKind.rotationRateData.z; + break; + } + case _SENSOR_CORE_EVENT_TYPE_LIGHT_LEVEL_DATA: + { + static_cast(sensorDataBuffer).level = event.eventKind.lightLevelData.level; + break; + } + case _SENSOR_CORE_EVENT_TYPE_GRAVITY_DATA: + { + static_cast(sensorDataBuffer).x = event.eventKind.gravityData.x; + static_cast(sensorDataBuffer).y = event.eventKind.gravityData.y; + static_cast(sensorDataBuffer).z = event.eventKind.gravityData.z; + break; + } + case _SENSOR_CORE_EVENT_TYPE_USER_ACCELERATION_DATA: + { + static_cast(sensorDataBuffer).x = event.eventKind.userAccelerationData.x; + static_cast(sensorDataBuffer).y = event.eventKind.userAccelerationData.y; + static_cast(sensorDataBuffer).z = event.eventKind.userAccelerationData.z; + break; + } + case _SENSOR_CORE_EVENT_TYPE_DEVICE_ORIENTATION_DATA: + { + static_cast(sensorDataBuffer).yaw = event.eventKind.deviceOrientationData.yaw; + static_cast(sensorDataBuffer).roll = event.eventKind.deviceOrientationData.roll; + static_cast(sensorDataBuffer).pitch = event.eventKind.deviceOrientationData.pitch; + break; + } + default: + { + SysAssertf(false, "OnSensorCoreEventReceived() > Invalid _SensorCoreEventType [eventType:%d]", eventType); + return; + } + } + + __pListener->OnDataReceived(__sensorType, sensorDataBuffer, event.isEventValid ? E_SUCCESS : E_INVALID_ARG); +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensor_SensorEventDeliverer.h b/src/FUixSensor_SensorEventDeliverer.h new file mode 100644 index 0000000..02f050a --- /dev/null +++ b/src/FUixSensor_SensorEventDeliverer.h @@ -0,0 +1,93 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.1 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUixSensor_SensorEventDeliverer.h + * @brief This is the header file for the %_SensorEventDeliverer class. + * + * This header file contains the declarations of the %_SensorEventDeliverer class. + */ + +#ifndef _FUIX_SENSOR_INTERNAL_SENSOR_EVENT_DELIVERER_H_ +#define _FUIX_SENSOR_INTERNAL_SENSOR_EVENT_DELIVERER_H_ + +#include +#include +#include +#include "FUixSensor_ISensorCoreEventReceiver.h" + +namespace Tizen { namespace Uix { namespace Sensor +{ +class SensorData; +class ISensorEventListener; + +class _SensorEventDeliverer + : public Tizen::Base::Object + , private Tizen::Uix::Sensor::_ISensorCoreEventReceiver +{ +public: + _SensorEventDeliverer(void); + virtual ~_SensorEventDeliverer(void); + + void SetDataEventInfo(Tizen::Uix::Sensor::ISensorEventListener& listener, Tizen::Uix::Sensor::SensorType sensorType, long interval, bool dataChanged); + void SetWakeupEventInfo(Tizen::Uix::Sensor::ISensorEventListener& listener, Tizen::Uix::Sensor::SensorType sensorType); + bool IsListenerEquals(Tizen::Uix::Sensor::ISensorEventListener& listener) const; + + result Start(void); + result Stop(void); + + result ResetInterval(long interval); + + virtual Tizen::Uix::Sensor::SensorData& GetSensorDataBuffer(void); + + // _ISensorCoreEventReceiver + virtual Tizen::Uix::Sensor::_SensorCoreEvent& GetSensorCoreEventBuffer(void); + virtual void OnSensorCoreEventReceived(Tizen::Uix::Sensor::_SensorCoreEvent& event); + +private: + // _ISensorCoreEventReceiver + virtual Tizen::Uix::Sensor::_SensorCoreEventType GetSensorCoreEventType(void) const; + virtual long GetSensorCoreDataEventInterval(void) const; + virtual void SetSensorCoreEventHandle(Tizen::Uix::Sensor::_SensorCoreEventHandle sensorCoreEventHandle); + virtual Tizen::Uix::Sensor::_SensorCoreEventHandle GetSensorCoreEventHandle(void) const; + virtual void SetSensorCoreEventReceiverState(Tizen::Uix::Sensor::_ISensorCoreEventReceiver::SensorCoreEventReceiverState state); + virtual Tizen::Uix::Sensor::_ISensorCoreEventReceiver::SensorCoreEventReceiverState GetSensorCoreEventReceiverState(void) const; + +private: + enum SensorEventType + { + SENSOR_EVENT_TYPE_DATA = 0, + SENSOR_EVENT_TYPE_WAKE_UP, + SENSOR_EVENT_TYPE_NONE = -1 + }; + + SensorEventType __eventType; + Tizen::Uix::Sensor::ISensorEventListener* __pListener; + Tizen::Uix::Sensor::SensorType __sensorType; + long __interval; + bool __dataChanged; + + Tizen::Uix::Sensor::_SensorCoreEventHandle __sensorCoreEventHandle; + Tizen::Uix::Sensor::_ISensorCoreEventReceiver::SensorCoreEventReceiverState __state; + Tizen::Uix::Sensor::_SensorCoreEvent __currentSensorCoreEvent; + Tizen::Uix::Sensor::_SensorCoreEvent __beforeSensorCoreEvent; + + friend class _ISensorCore; +}; // _SensorEventDeliverer +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_INTERNAL_SENSOR_EVENT_DELIVERER_H_ diff --git a/src/FUixSensor_SensorManagerImpl.cpp b/src/FUixSensor_SensorManagerImpl.cpp new file mode 100644 index 0000000..fe20325 --- /dev/null +++ b/src/FUixSensor_SensorManagerImpl.cpp @@ -0,0 +1,668 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.1 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUixSensor_SensorManagerImpl.cpp + * @brief This is the implementation file for the %_SensorManagerImpl class. + * + * This files contains implementation of the %_SensorManagerImpl class. + */ + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "FUixSensor_SensorUtil.h" +#include "FUixSensor_ISensorCore.h" +#include "FUixSensor_SpecifiedSensorDataEventDelivererT.h" + +using Tizen::App::_AppInfo; + +namespace Tizen { namespace Uix { namespace Sensor +{ +namespace +{ +static const int INDEX_NONE = -1; +static const int INDEX_FIRST = 0; +static ISensorEventListener& INVALID_LISTENER = *static_cast(0); + +_SensorEventDeliverer* +CreateSensorDataDelivererN(SensorType sensorType) +{ + switch (sensorType) + { + case SENSOR_TYPE_ACCELERATION: + return new (std::nothrow) _SpecifiedSensorDataEventDelivererT(); + case SENSOR_TYPE_MAGNETIC: + return new (std::nothrow) _SpecifiedSensorDataEventDelivererT(); + case SENSOR_TYPE_PROXIMITY: + return new (std::nothrow) _SpecifiedSensorDataEventDelivererT(); + case SENSOR_TYPE_TILT: + return new (std::nothrow) _SpecifiedSensorDataEventDelivererT(); + case SENSOR_TYPE_GYRO: + return new (std::nothrow) _SpecifiedSensorDataEventDelivererT(); + case SENSOR_TYPE_LIGHT: + return new (std::nothrow) _SpecifiedSensorDataEventDelivererT(); + case SENSOR_TYPE_GRAVITY: + return new (std::nothrow) _SpecifiedSensorDataEventDelivererT(); + case SENSOR_TYPE_USER_ACCELERATION: + return new (std::nothrow) _SpecifiedSensorDataEventDelivererT(); + case SENSOR_TYPE_DEVICE_ORIENTATION: + return new (std::nothrow) _SpecifiedSensorDataEventDelivererT(); + default: + SysAssertf(false, "CreateSensorDataDelivererN() > Invalid SensorType [sensorType:%d]", sensorType); + return null; + } +} +} // Anonymous + +// _SensorManagerImpl life-cycle ---------------------------------------------------------------------------------------------- // +_SensorManagerImpl::_SensorManagerImpl(void) + : __pDelivererListHashMap(null) +{ + +} + +_SensorManagerImpl::~_SensorManagerImpl(void) +{ + Destruct(); +} + +result +_SensorManagerImpl::Construct(void) +{ + std::unique_ptr<_SensorEventDelivererListHashMap> pHashMap(new (std::nothrow) _SensorEventDelivererListHashMap()); + SysTryReturn(NID_UIX, pHashMap != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Allocating new _SensorEventDelivererListHashMap failed."); + + result r = pHashMap->Construct(); + SysTryReturn(NID_UIX, !IsFailed(r), r, r, "Constructing _SensorEventDelivererListHashMap failed."); // E_OUT_OF_MEMORY + + __pDelivererListHashMap = pHashMap.release(); + + return E_SUCCESS; +} + +void +_SensorManagerImpl::Destruct(void) +{ + if (__pDelivererListHashMap != null) + { + std::unique_ptr<_ISensorEventDelivererListHashMapEnumerator> pHashMapEnumeratorN(__pDelivererListHashMap->GetMapEnumeratorN()); + if (pHashMapEnumeratorN != null) + { + _SensorEventDelivererList* pDelivererList = null; + while (pHashMapEnumeratorN->MoveNext() == E_SUCCESS) + { + pHashMapEnumeratorN->GetValue(pDelivererList); + + pDelivererList->RemoveAll(true); + + delete pDelivererList; + } + } + else + { + _SensorEventDelivererList* pDelivererList = null; + for (int i = SENSOR_TYPE_NONE+1; i < SENSOR_TYPE_MAX; i++) + { + if (IsFailed(__pDelivererListHashMap->GetValue(static_cast(i), pDelivererList))) + { + continue; + } + + pDelivererList->RemoveAll(true); + + delete pDelivererList; + } + } + + __pDelivererListHashMap->RemoveAll(); + delete __pDelivererListHashMap; + } +} + +// Getting sensor information ------------------------------------------------------------------------------------------------- // +bool +_SensorManagerImpl::IsAvailable(SensorType sensorType) const +{ + result r = _SensorUtil::CheckSensorTypeValidation(sensorType); + if (IsFailed(r)) + { + return false; + } + + return true; +} + +result +_SensorManagerImpl::GetDescription(SensorType sensorType, Tizen::Base::String& description) const +{ + result r = _SensorUtil::CheckSensorTypeValidation(sensorType); + if (IsFailed(r)) + { + return r; + } + + return _ISensorCore::GetDescription(sensorType, description); +} + +result +_SensorManagerImpl::GetVendor(SensorType sensorType, Tizen::Base::String& vendor) const +{ + result r = _SensorUtil::CheckSensorTypeValidation(sensorType); + if (IsFailed(r)) + { + return r; + } + + return _ISensorCore::GetVendor(sensorType, vendor); +} + +result +_SensorManagerImpl::GetModelId(SensorType sensorType, Tizen::Base::String& modelId) const +{ + result r = _SensorUtil::CheckSensorTypeValidation(sensorType); + if (IsFailed(r)) + { + return r; + } + + return _ISensorCore::GetModelId(sensorType, modelId); +} + +result +_SensorManagerImpl::GetMeasurementRange(SensorType sensorType, float& min, float& max, float& resolution) const +{ + result r = _SensorUtil::CheckSensorTypeValidation(sensorType); + if (IsFailed(r)) + { + return r; + } + + return _ISensorCore::GetMeasurementRange(sensorType, min, max, resolution); +} + +result +_SensorManagerImpl::GetIntervalRange(SensorType sensorType, long& min, long& max) const +{ + result r = _SensorUtil::CheckSensorTypeValidation(sensorType); + if (IsFailed(r)) + { + return r; + } + + return _ISensorCore::GetIntervalRange(sensorType, min, max); +} + + +// Sensor event listener management ------------------------------------------------------------------------------------------- // +result +_SensorManagerImpl::AddSensorEventListener(ISensorEventListener& listener, SensorType sensorType, long interval, bool dataChanged) +{ + result r = _SensorUtil::CheckSensorTypeValidation(sensorType); + if (IsFailed(r)) + { + return r; + } + + r = _SensorUtil::CheckIntervalValidation(sensorType, interval); + if (IsFailed(r)) + { + return r; + } + + if (IsSensorTypeRegistered(sensorType)) + { + _SensorEventDelivererList* pDelivererList = null; + __pDelivererListHashMap->GetValue(sensorType, pDelivererList); + + int tempIndex = INDEX_NONE; + SysTryReturn(NID_UIX, !IsListenerRegistered(*pDelivererList, listener, tempIndex), E_USER_ALREADY_REGISTERED, E_USER_ALREADY_REGISTERED, "Invalid ISensorEventListener [sensorType:%d, listener:%p]", sensorType, &listener); + + std::unique_ptr<_SensorEventDeliverer> pDeliverer(CreateSensorDataDelivererN(sensorType)); + SysTryReturn(NID_UIX, pDeliverer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Allocating new _SensorEventDeliverer failed."); + + pDeliverer->SetDataEventInfo(listener, sensorType, interval, dataChanged); + + r = pDeliverer->Start(); + SysTryReturn(NID_UIX, !IsFailed(r), r, r, "Starting _SensorEventDeliverer failed."); // E_OUT_OF_MEMORY or E_DEVICE_UNAVAILABLE + + r = pDelivererList->Add(*(pDeliverer.get())); + if (IsFailed(r)) + { + // E_OUT_OF_MEMORY + SysLogException(NID_UIX, r, "Adding _SensorEventDeliverer failed."); + pDeliverer->Stop(); + return r; + } + + pDeliverer.release(); + } + else + { + std::unique_ptr<_SensorEventDelivererList> pDelivererList(new (std::nothrow) _SensorEventDelivererList()); + SysTryReturn(NID_UIX, pDelivererList != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Allocating new _SensorEventDelivererList failed."); + + r = pDelivererList->Construct(sensorType); + SysTryReturn(NID_UIX, !IsFailed(r), r, r, "Constructing _SensorEventDelivererList failed."); + + std::unique_ptr<_SensorEventDeliverer> pDeliverer(CreateSensorDataDelivererN(sensorType)); + SysTryReturn(NID_UIX, pDeliverer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Allocating new _SensorEventDeliverer failed."); + + r = pDelivererList->Add(*(pDeliverer.get())); + SysTryReturn(NID_UIX, !IsFailed(r), r, r, "Adding _SensorEventDeliverer failed."); // E_OUT_OF_MEMORY + + pDeliverer->SetDataEventInfo(listener, sensorType, interval, dataChanged); + + r = pDeliverer->Start(); + SysTryReturn(NID_UIX, !IsFailed(r), r, r, "Starting _SensorEventDeliverer failed."); // E_OUT_OF_MEMORY or E_DEVICE_UNAVAILABLE + + r = __pDelivererListHashMap->Add(sensorType, pDelivererList.get()); + if (IsFailed(r)) + { + // E_OUT_OF_MEMORY + SysLogException(NID_UIX, r, "Adding _SensorEventDelivererList failed."); + pDeliverer->Stop(); + return r; + } + + pDeliverer.release(); + pDelivererList.release(); + } + + return E_SUCCESS; +} + +result +_SensorManagerImpl::RemoveSensorEventListener(ISensorEventListener& listener) +{ + result r = RemoveSensorEventListenerFromDelivererListHashMap(*__pDelivererListHashMap, listener); + if (IsFailed(r)) + { + return r; + } + + return E_SUCCESS; +} + +result +_SensorManagerImpl::RemoveSensorEventListener(ISensorEventListener& listener, SensorType sensorType) +{ + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysTryReturn(NID_UIX, _SensorUtil::IsSensorTypeValid(sensorType), E_INVALID_ARG, E_INVALID_ARG, "Invalid SensorType [sensorType:%d]", sensorType); + } + else + { + result r = _SensorUtil::CheckSensorTypeValidation(sensorType); + if (IsFailed(r)) + { + return r; + } + } + + SysTryReturn(NID_UIX, IsSensorTypeRegistered(sensorType), E_INVALID_ARG, E_INVALID_ARG, "Not registered SensorType [sensorType:%d]", sensorType); + + _SensorEventDelivererList* pDelivererList = null; + __pDelivererListHashMap->GetValue(sensorType, pDelivererList); + result r = RemoveSensorEventListenerFromDelivererList(*pDelivererList, listener); + if (IsFailed(r)) + { + return r; + } + + return E_SUCCESS; +} + +result +_SensorManagerImpl::SetInterval(SensorType sensorType, long interval) +{ + // NOTE: This API was deprecated. + // It can change sensing interval for registered first listener only. + result r = _SensorUtil::CheckSensorTypeValidation(sensorType); + if (IsFailed(r)) + { + return r; + } + + r = _SensorUtil::CheckIntervalValidation(sensorType, interval); + if (IsFailed(r)) + { + return r; + } + + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + SysTryReturn(NID_UIX, IsSensorTypeRegistered(sensorType), E_DEVICE_UNAVAILABLE, E_DEVICE_UNAVAILABLE, "Not registered SensorType [sensorType:%d]", sensorType); + } + else + { + SysTryReturn(NID_UIX, IsSensorTypeRegistered(sensorType), E_INVALID_ARG, E_INVALID_ARG, "Not registered SensorType [sensorType:%d]", sensorType); + } + + _SensorEventDelivererList* pDelivererList = null; + __pDelivererListHashMap->GetValue(sensorType, pDelivererList); + + SysTryReturn(NID_UIX, pDelivererList->GetCount() > 0, E_INVALID_ARG, E_INVALID_ARG, "Listener not registered yet [sensorType:%d]", sensorType); + + _SensorEventDeliverer* pDeliverer = static_cast<_SensorEventDeliverer*>(pDelivererList->GetAt(INDEX_FIRST)); + r = pDeliverer->ResetInterval(interval); + if (IsFailed(r)) + { + return r; + } + + return E_SUCCESS; +} + +result +_SensorManagerImpl::SetInterval(ISensorEventListener& listener, SensorType sensorType, long interval) +{ + result r = _SensorUtil::CheckSensorTypeValidation(sensorType); + if (IsFailed(r)) + { + return r; + } + + r = _SensorUtil::CheckIntervalValidation(sensorType, interval); + if (IsFailed(r)) + { + return r; + } + + SysTryReturn(NID_UIX, IsSensorTypeRegistered(sensorType), E_INVALID_ARG, E_INVALID_ARG, "Not registered SensorType [sensorType:%d]", sensorType); + + _SensorEventDelivererList* pDelivererList = null; + __pDelivererListHashMap->GetValue(sensorType, pDelivererList); + + int index = INDEX_NONE; + SysTryReturn(NID_UIX, IsListenerRegistered(*pDelivererList, listener, index), E_INVALID_ARG, E_INVALID_ARG, "Invalid ISensorEventListener [sensorType:%d, listener:%p]", sensorType, &listener); + + _SensorEventDeliverer* pDeliverer = static_cast<_SensorEventDeliverer*>(pDelivererList->GetAt(index)); + r = pDeliverer->ResetInterval(interval); + if (IsFailed(r)) + { + return r; + } + + return E_SUCCESS; +} + +// Sensor wake up management -------------------------------------------------------------------------------------------------- // +bool +_SensorManagerImpl::IsWakeupSupported(SensorType sensorType) const +{ + + result r = _SensorUtil::CheckSensorTypeValidation(sensorType); + if (IsFailed(r)) + { + return r; + } +#if defined(_OSP_EMUL_) + return true; +#else + return _ISensorCore::IsWakeupSupported(sensorType); +#endif +} + +result +_SensorManagerImpl::SetWakeupEnabled(SensorType sensorType, bool enable) +{ + + bool isWakeupSupported = IsWakeupSupported(sensorType); + result r = GetLastResult(); + if (IsFailed(r)) + { + return r; + } +#if defined(_OSP_EMUL_) + return E_SUCCESS; +#else + SysTryReturn(NID_UIX, isWakeupSupported, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "Unsupported SensorType for wake up [sensorType:%d]", sensorType); + SysTryReturn(NID_UIX, IsSensorTypeRegistered(sensorType), E_INVALID_STATE, E_INVALID_STATE, "Not registered SensorType [sensorType:%d]", sensorType); + + _SensorEventDelivererList* pDelivererList = null; + __pDelivererListHashMap->GetValue(sensorType, pDelivererList); + SysTryReturn(NID_UIX, pDelivererList->GetCount() > 0, E_INVALID_STATE, E_INVALID_STATE, "Listener not registered [sensorType:%d]", sensorType); + + int tempIndex = INDEX_NONE; + bool isWakeupEnabled = IsListenerRegistered(*pDelivererList, INVALID_LISTENER, tempIndex); + if ((enable && isWakeupEnabled) || (!enable && !isWakeupEnabled)) + { + return E_SUCCESS; + } + + if (enable) + { + std::unique_ptr<_SensorEventDeliverer> pDeliverer(new (std::nothrow) _SensorEventDeliverer()); + SysTryReturn(NID_UIX, pDeliverer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "Allocating new Deliverer failed."); + + pDeliverer->SetWakeupEventInfo(INVALID_LISTENER, sensorType); + + r = pDeliverer->Start(); + SysTryReturn(NID_UIX, !IsFailed(r), r, r, "Starting Deliverer failed."); // E_OUT_OF_MEMORY or E_DEVICE_UNAVAILABLE + + r = pDelivererList->Add(*(pDeliverer.get())); + if (IsFailed(r)) + { + // E_OUT_OF_MEMORY + SysLogException(NID_UIX, r, "Adding Deliverer failed."); + pDeliverer->Stop(); + return r; + } + + pDeliverer.release(); + } + else + { + _SensorEventDeliverer* pDeliverer = static_cast<_SensorEventDeliverer*>(pDelivererList->GetAt(tempIndex)); + result r = pDeliverer->Stop(); + if (IsFailed(r)) + { + return r; + } + + pDelivererList->RemoveAt(tempIndex, true); + } + + return E_SUCCESS; +#endif +} + +bool +_SensorManagerImpl::IsWakeupEnabled(SensorType sensorType) const +{ + + bool isWakeupSupported = IsWakeupSupported(sensorType); + result r = GetLastResult(); + if (IsFailed(r)) + { + return r; + } +#if defined(_OSP_EMUL_) + return true; +#else + SysTryReturn(NID_UIX, isWakeupSupported, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "Unsupported SensorType for wake up [sensorType:%d]", sensorType); + + if (!IsSensorTypeRegistered(sensorType)) + { + return false; + } + + _SensorEventDelivererList* pDelivererList = null; + __pDelivererListHashMap->GetValue(sensorType, pDelivererList); + + int dummyIndex = INDEX_NONE; + return IsListenerRegistered(*pDelivererList, INVALID_LISTENER, dummyIndex); +#endif +} + +// Management helpers --------------------------------------------------------------------------------------------------------- // +bool +_SensorManagerImpl::IsSensorTypeRegistered(SensorType sensorType) const +{ + bool isContains = false; + __pDelivererListHashMap->ContainsKey(sensorType, isContains); + return isContains; +} + +bool +_SensorManagerImpl::IsListenerRegistered(_SensorEventDelivererList& delivererList, ISensorEventListener& listener, int& index) const +{ + int delivererCount = delivererList.GetCount(); + + _SensorEventDeliverer* pDeliverer = null; + for (int i = 0; i < delivererCount; i++) + { + pDeliverer = static_cast<_SensorEventDeliverer*>(delivererList.GetAt(i)); + + if (pDeliverer->IsListenerEquals(listener)) + { + index = i; + return true; + } + } + + return false; +} + +result +_SensorManagerImpl::RemoveSensorEventListenerFromDelivererListHashMap(_SensorEventDelivererListHashMap& delivererListHashMap, ISensorEventListener& listener) +{ + bool isRemoved = false; + std::unique_ptr<_ISensorEventDelivererListHashMapEnumerator> pHashMapEnumeratorN(delivererListHashMap.GetMapEnumeratorN()); + if (pHashMapEnumeratorN != null) + { + _SensorEventDelivererList* pDelivererList = null; + result r = E_SUCCESS; + while (pHashMapEnumeratorN->MoveNext() == E_SUCCESS) + { + pHashMapEnumeratorN->GetValue(pDelivererList); + + r = RemoveSensorEventListenerFromDelivererList(*pDelivererList, listener); + if (r == E_INVALID_ARG) + { + continue; + } + else if (r == E_DEVICE_UNAVAILABLE) + { + return r; + } + else + { + isRemoved = true; + } + } + } + else + { + _SensorEventDelivererList* pDelivererList = null; + result r = E_SUCCESS; + for (int i = SENSOR_TYPE_NONE+1; i < SENSOR_TYPE_MAX; i++) + { + if (IsFailed(delivererListHashMap.GetValue(static_cast(i), pDelivererList))) + { + continue; + } + + r = RemoveSensorEventListenerFromDelivererList(*pDelivererList, listener); + if (r == E_INVALID_ARG) + { + continue; + } + else if (r == E_DEVICE_UNAVAILABLE) + { + return r; + } + else + { + isRemoved = true; + } + } + } + + if (!isRemoved) + { + SetLastResult(E_INVALID_ARG); + return E_INVALID_ARG; + } + + return E_SUCCESS; +} + +result +_SensorManagerImpl::RemoveSensorEventListenerFromDelivererList(_SensorEventDelivererList& delivererList, ISensorEventListener& listener) +{ + int index = INDEX_NONE; + if (!IsListenerRegistered(delivererList, listener, index)) + { + SetLastResult(E_INVALID_ARG); + return E_INVALID_ARG; + } + + _SensorEventDeliverer* pDeliverer = static_cast<_SensorEventDeliverer*>(delivererList.GetAt(index)); + result r = pDeliverer->Stop(); + if (IsFailed(r)) + { + return r; + } + + r = delivererList.RemoveAt(index, true); + if (IsFailed(r)) + { + return r; + } + + if (delivererList.GetCount() == 1 && IsListenerRegistered(delivererList, INVALID_LISTENER, index)) + { + delivererList.RemoveAt(index, true); + } + + return E_SUCCESS; +} + +// Getting implementation instance -------------------------------------------------------------------------------------------- // +_SensorManagerImpl* +_SensorManagerImpl::GetInstance(SensorManager& sensorManager) +{ + return sensorManager.__pSensorManagerImpl; +} + +const _SensorManagerImpl* +_SensorManagerImpl::GetInstance(const SensorManager& sensorManager) +{ + return sensorManager.__pSensorManagerImpl; +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensor_SensorUtil.cpp b/src/FUixSensor_SensorUtil.cpp new file mode 100644 index 0000000..11812e9 --- /dev/null +++ b/src/FUixSensor_SensorUtil.cpp @@ -0,0 +1,134 @@ +// +// 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 FUixSensor_SensorUtil.cpp + * @brief This is the implementation file for the %_SensorUtil class. + * + * This files contains implementation of the %_SensorUtil class. + */ + +// Includes +#include + +#include + +#include "FUixSensor_SensorUtil.h" +#include "FUixSensor_ISensorCore.h" + +using Tizen::App::_AppInfo; + +namespace Tizen { namespace Uix { namespace Sensor +{ +bool +_SensorUtil::IsSensorTypeValid(SensorType sensorType) +{ + return (sensorType > SENSOR_TYPE_NONE) && (sensorType < SENSOR_TYPE_MAX); +} + +result +_SensorUtil::CheckSensorTypeValidation(SensorType sensorType) +{ + if (_AppInfo::GetApiVersion() == Tizen::Base::_API_VERSION_2_0 && _AppInfo::IsOspCompat()) + { + if (!IsSensorTypeValid(sensorType)) + { + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + + if (!_ISensorCore::IsSupported(sensorType)) + { + SetLastResult(E_DEVICE_UNAVAILABLE); + return E_DEVICE_UNAVAILABLE; + } + } + else + { + SysTryReturn(NID_UIX, IsSensorTypeValid(sensorType), E_INVALID_ARG, E_INVALID_ARG, "Invalid SensorType [sensorType:%d]", sensorType); + + bool isSupported = _ISensorCore::IsSupported(sensorType); + result r = GetLastResult(); + + SysTryReturn(NID_UIX, !IsFailed(r), E_OPERATION_FAILED, E_OPERATION_FAILED, "The operation has failed [sensorType:%d]", sensorType); + SysTryReturn(NID_UIX, isSupported, E_UNSUPPORTED_OPERATION, E_UNSUPPORTED_OPERATION, "Unsupported SensorType [sensorType:%d]", sensorType); + } + + return E_SUCCESS; +} + +result +_SensorUtil::CheckIntervalValidation(SensorType sensorType, long interval) +{ + long min = 0L; + long max = 0L; + result r = _ISensorCore::GetIntervalRange(sensorType, min, max); + if (IsFailed(r)) + { + return r; + } + + SysTryReturn(NID_UIX, (min <= interval) && (max >= interval), E_INVALID_ARG, E_INVALID_ARG, "Invalid interval [sensorType:%d, min:%ld, max:%ld, interval:%ld]", sensorType, min, max, interval); + + return E_SUCCESS; +} + +double +_SensorUtil::Atan2(double y, double x) +{ + // reference: http://en.wikipedia.org/wiki/Atan2#Other_implementations.2Fcode_for_atan2 + if (x > 0.0) + { + return Tizen::Base::Utility::Math::Atan(y / x); + } + + if ((y >= 0.0) && (x < 0.0)) + { + return Tizen::Base::Utility::Math::Atan(y / x) + PI; + } + + if ((y < 0.0) && (x < 0.0)) + { + return Tizen::Base::Utility::Math::Atan(y / x) - PI; + } + + if ((y > 0.0) && IsEquals(x, 0.0)) + { + return PI / 2; + } + + if ((y < 0.0) && IsEquals(x, 0.0)) + { + return -PI / 2; + } + + // Undefined case + return 0.0; +} + +long +_SensorUtil::CutTimestamp(long long timestamp) +{ + return (static_cast(timestamp) << BIT_FOR_TIMESTAMP_CUTTING) >> BIT_FOR_TIMESTAMP_CUTTING; +} + +bool +_SensorUtil::IsObjectDetected(float distance) +{ + return _ISensorCore::IsObjectDetected(distance); +} +} } }// Tizen::Uix::Sensor diff --git a/src/FUixSensor_SensorUtil.h b/src/FUixSensor_SensorUtil.h new file mode 100644 index 0000000..7f7950d --- /dev/null +++ b/src/FUixSensor_SensorUtil.h @@ -0,0 +1,63 @@ +// +// 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 FUixSensor_SensorUtil.h + * @brief This is the header file for the %_SensorUtil class. + * + * This header file contains the constants and the declarations of the %_SensorUtil class. + */ + +#ifndef _FUIX_SENSOR_INTERNAL_SENSOR_UTIL_H_ +#define _FUIX_SENSOR_INTERNAL_SENSOR_UTIL_H_ + +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ +static const double GRAVITATIONAL_ACCELERATION = 9.80665f; // m/s^2 +static const double PI = Tizen::Base::Utility::Math::GetPi(); // PI = 3.1415926535897932... +static const double MICROSECOND_TO_MILLISECOND = 0.001; +static const double METER_PER_SECOND_SQUARE_TO_G = 1.0 / GRAVITATIONAL_ACCELERATION; +static const double DEGREE_TO_RADIAN = (PI / 180.0); +static const double RADIAN_TO_DEGREE = (180.0 / PI); +static const int BIT_FOR_TIMESTAMP_CUTTING = 33; + +template inline bool +IsEquals(Numeric a, Numeric b) +{ + return !(a > b) && !(a < b); +} + +class _SensorUtil +{ +public: + static bool IsSensorTypeValid(SensorType sensorType); + static result CheckSensorTypeValidation(SensorType sensorType); + static result CheckIntervalValidation(SensorType sensorType, long interval); + static double Atan2(double y, double x); + static long CutTimestamp(long long timestamp); + static bool IsObjectDetected(float distance); + +private: + _SensorUtil(void); + ~_SensorUtil(void); +}; // _SensorUtil +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_INTERNAL_SENSOR_UTIL_H_ diff --git a/src/FUixSensor_SpecifiedSensorDataEventDelivererT.h b/src/FUixSensor_SpecifiedSensorDataEventDelivererT.h new file mode 100644 index 0000000..2fe713b --- /dev/null +++ b/src/FUixSensor_SpecifiedSensorDataEventDelivererT.h @@ -0,0 +1,60 @@ +// +// 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 FUixSensor_SpecifiedSensorDataEventDelivererT.h + * @brief This is the header file for the %_SpecifiedSensorDataEventDelivererT class. + * + * This header file contains the declarations of the %_SpecifiedSensorDataEventDelivererT class. + */ + +#ifndef _FUIX_SENSOR_INTERNAL_SPECIFIED_SENSOR_DATA_EVENT_DELIVERER_T_H_ +#define _FUIX_SENSOR_INTERNAL_SPECIFIED_SENSOR_DATA_EVENT_DELIVERER_T_H_ + +#include "FUixSensor_SensorEventDeliverer.h" + +namespace Tizen { namespace Uix { namespace Sensor +{ +class SensorData; + +template +class _SpecifiedSensorDataEventDelivererT + : public Tizen::Uix::Sensor::_SensorEventDeliverer +{ +public: + _SpecifiedSensorDataEventDelivererT(void) + : __sensorData() + { + + } + + virtual ~_SpecifiedSensorDataEventDelivererT(void) + { + + } + + virtual SensorData& GetSensorDataBuffer(void) + { + return __sensorData; + } + +private: + XxxSensorData __sensorData; +}; // _SpecifiedSensorDataEventDeliverer +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_INTERNAL_SPECIFIED_SENSOR_DATA_EVENT_DELIVERER_T_H_ diff --git a/src/inc/FUixSensor_MotionImpl.h b/src/inc/FUixSensor_MotionImpl.h new file mode 100644 index 0000000..1bf78c2 --- /dev/null +++ b/src/inc/FUixSensor_MotionImpl.h @@ -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. +// + +#ifndef _FUIX_SENSOR_INTERNAL_MOTION_IMPL_H_ +#define _FUIX_SENSOR_INTERNAL_MOTION_IMPL_H_ + +#include + +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Uix { namespace Sensor +{ + +class Motion; + +class _OSP_EXPORT_ _MotionImpl + : public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.0 + */ + _MotionImpl(void); + + /** + * This is the destructor for this class. + * + * @since 2.0 + */ + virtual ~_MotionImpl(void); + +public: + /** + * Initializes this instance of Motion with the associated listener. + * + * @since 2.0 + * @return An error code + * @param[in] listener An instance of IMotionEventListener + * @exception E_SUCCESS The method was successful. + * @exception E_OUT_OF_MEMORY Insufficient memory. + * @exception E_INVALID_STATE This instance is in an invalid state. + * @exception E_MAX_EXCEEDED Reached the limitation for the maximum number of Motion instances. + * @exception E_UNSUPPORTED_OPERATION %Motion detection is not supported. + */ + result Construct(IMotionEventListener& listener); + + /** + * Sets which type of motion event is enabled and listened to. + * By default, if this method is not called, all motion types will be listened to. + * If you do not want to listen to any type of motion event, you can call this method with type value as MOTION_TYPE_NONE. + * + * @since 2.0 + * @param[in] type The type of motions to listen for @n + * Multiple types can be combined using the OR operator of Tizen::Uix::MotionType. + * @exception E_SUCCESS The method was successful. + * @exception E_INVALID_STATE This instance has not been constructed yet. + * @exception E_INVALID_ARG A specified input parameter is invalid. @b Since: @b 2.0 + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see Tizen::Uix::Sensor::MotionType + */ + void SetEnabled(unsigned long type); + + /** + * Checks if the specified motion type is supported. + * MOTION_TYPE_NONE and MOTION_TYPE_ALL are invalid, and @c false will be returned for these types. + * + * @since 2.0 + * @return @c true if the specified motion type is supported @n + * @c false, otherwise + * @param[in] type The type of motion to query + * @see Tizen::Uix::Sensor::MotionType + */ + bool IsSupported(MotionType type) const; + + /** + * Checks if the specified motion type is valid. + * + * @since 2.0 + * @return @c true if the specified motion type is valid @n + * @c false, otherwise + * @param[in] type The type of motion to query + * Multiple motion types of type Tizen::Uix::MotionType can be combined using the logical OR operator. + * @see Tizen::Uix::Sensor::MotionType + */ + static bool IsMotionTypeValid(unsigned long type); + + static _MotionImpl* GetInstance(Motion& motion); + static const _MotionImpl* GetInstance(const Motion& motion); + +protected: + +private: + _MotionImpl(const _MotionImpl& value); + _MotionImpl& operator =(const _MotionImpl& value); + + static void __MotionSnapEventReceiver(unsigned long long timeStamp, sensor_motion_snap_e snap, void *pData); + static void __MotionShakeEventReceiver(unsigned long long timeStamp, sensor_motion_shake_e shake, void *pData); + static void __MotionDoubleTapEventReceiver(unsigned long long timeStamp, void *pData); + static void __MotionDirectCallEventReceiver(unsigned long long timeStamp, void *pData); + +private: + IMotionEventListener* __pIMotionEventListener; + sensor_handle_s *__handle; + unsigned long __motionType; + +}; // _MotionImpl + +} } } //Tizen::Uix::Sensor + +#endif //_FUIX_SENSOR_INTERNAL_MOTION_IMPL_H_ diff --git a/src/inc/FUixSensor_SensorManagerImpl.h b/src/inc/FUixSensor_SensorManagerImpl.h new file mode 100644 index 0000000..7062db7 --- /dev/null +++ b/src/inc/FUixSensor_SensorManagerImpl.h @@ -0,0 +1,95 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.1 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://floralicense.org/license/ +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an AS IS BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +/** + * @file FUixSensor_SensorManagerImpl.h + * @brief This is the header file for the %_SensorManagerImpl class. + * + * This header file contains the declarations of the %_SensorManagerImpl class. + */ + +#ifndef _FUIX_SENSOR_INTERNAL_SENSOR_MANAGER_IMPL_H_ +#define _FUIX_SENSOR_INTERNAL_SENSOR_MANAGER_IMPL_H_ + +#include +#include +#include + +namespace Tizen { namespace Base +{ +class String; +namespace Collection +{ +template class HashMapT; +template class IMapEnumeratorT; +} // Collection +} } // Tizen::Base + +namespace Tizen { namespace Uix { namespace Sensor +{ +class SensorManager; +class ISensorEventListener; + +class _OSP_EXPORT_ _SensorManagerImpl +{ +public: + _SensorManagerImpl(void); + ~_SensorManagerImpl(void); + + result Construct(void); + + bool IsAvailable(Tizen::Uix::Sensor::SensorType sensorType) const; + result GetDescription(Tizen::Uix::Sensor::SensorType sensorType, Tizen::Base::String& description) const; + result GetVendor(Tizen::Uix::Sensor::SensorType sensorType, Tizen::Base::String& vendor) const; + result GetModelId(Tizen::Uix::Sensor::SensorType sensorType, Tizen::Base::String& modelId) const; + result GetMeasurementRange(Tizen::Uix::Sensor::SensorType sensorType, float& min, float& max, float& resolution) const; + result GetIntervalRange(Tizen::Uix::Sensor::SensorType sensorType, long& min, long& max) const; + bool IsWakeupSupported(Tizen::Uix::Sensor::SensorType sensorType) const; + + result AddSensorEventListener(Tizen::Uix::Sensor::ISensorEventListener& listener, Tizen::Uix::Sensor::SensorType sensorType, long interval, bool dataChanged); + result RemoveSensorEventListener(Tizen::Uix::Sensor::ISensorEventListener& listener); + result RemoveSensorEventListener(Tizen::Uix::Sensor::ISensorEventListener& listener, Tizen::Uix::Sensor::SensorType sensorType); + result SetInterval(Tizen::Uix::Sensor::SensorType sensorType, long interval); + result SetInterval(Tizen::Uix::Sensor::ISensorEventListener& listener, Tizen::Uix::Sensor::SensorType sensorType, long interval); + + result SetWakeupEnabled(Tizen::Uix::Sensor::SensorType sensorType, bool enable); + bool IsWakeupEnabled(Tizen::Uix::Sensor::SensorType sensorType) const; + + static _SensorManagerImpl* GetInstance(SensorManager& sensorManager); + static const _SensorManagerImpl* GetInstance(const SensorManager& sensorManager); + +private: + typedef Tizen::Base::Collection::ArrayList _SensorEventDelivererList; + typedef Tizen::Base::Collection::HashMapT _SensorEventDelivererListHashMap; + typedef Tizen::Base::Collection::IMapEnumeratorT _ISensorEventDelivererListHashMapEnumerator; + + _SensorManagerImpl(const _SensorManagerImpl& sensorManagerImpl); + _SensorManagerImpl& operator =(const _SensorManagerImpl& sensorManagerImpl); + + void Destruct(void); + + bool IsSensorTypeRegistered(Tizen::Uix::Sensor::SensorType sensorType) const; + bool IsListenerRegistered(_SensorEventDelivererList& delivererList, Tizen::Uix::Sensor::ISensorEventListener& listener, int& index) const; + result RemoveSensorEventListenerFromDelivererListHashMap(_SensorEventDelivererListHashMap& delivererListHashMap, Tizen::Uix::Sensor::ISensorEventListener& listener); + result RemoveSensorEventListenerFromDelivererList(_SensorEventDelivererList& delivererList, Tizen::Uix::Sensor::ISensorEventListener& listener); + +private: + _SensorEventDelivererListHashMap* __pDelivererListHashMap; +}; // _SensorManagerImpl +} } }// Tizen::Uix::Sensor + +#endif // _FUIX_SENSOR_INTERNAL_SENSOR_MANAGER_IMPL_H_ -- 2.7.4