2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 #include <FBaseErrors.h>
20 #include <FUixSensorMotion.h>
21 #include <FBaseSysLog.h>
22 #include <FUixSensor_MotionImpl.h>
24 using namespace Tizen::Base;
26 namespace Tizen { namespace Uix { namespace Sensor
37 if (__pMotionImpl != null)
39 __pMotionImpl->SetEnabled(MOTION_TYPE_NONE);
47 Motion::Construct(IMotionEventListener& listener)
51 SysAssertf(__pMotionImpl == null, "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
52 __pMotionImpl = new (std::nothrow) _MotionImpl;
53 SysTryReturn(NID_UIX, __pMotionImpl != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
54 r = __pMotionImpl->Construct(listener);
57 case E_UNSUPPORTED_OPERATION:
58 SysLogException(NID_UIX, r, "[%s] The motion detection feature is not supported", GetErrorMessage(r));
62 SysLogException(NID_UIX, r, "[%s] This instance is in an invalid state.", GetErrorMessage(r));
72 Motion::SetEnabled(unsigned long type)
77 SysAssert(__pMotionImpl != null);
79 SysTryReturnVoidResult(NID_UIX, __pMotionImpl->IsMotionTypeValid(type), E_INVALID_ARG, "[E_INVALID_ARG] The given type is invalid combination.");
81 __pMotionImpl->SetEnabled(type);
83 SysTryReturnVoidResult(NID_UIX, r == E_SUCCESS, r, "[%s] This instance has not been constructed as yet.", GetErrorMessage(r));
87 Motion::IsSupported(MotionType type) const
91 SysAssert(__pMotionImpl != null);
93 return __pMotionImpl->IsSupported(type);
96 } } } // Tizen::Uix::Sensor