// // 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 FLoc_SyncLocationRequestInfo.h * @brief This is the header file for the %_SyncLocationRequestInfo class. * * This header file contains the declarations of the %_SyncLocationRequestInfo class member variables. */ #ifndef _FLOC_INTERNAL_SYNC_LOCATION_REQUEST_INFO_H_ #define _FLOC_INTERNAL_SYNC_LOCATION_REQUEST_INFO_H_ #include #include #include #include #include #include namespace Tizen { namespace Locations { class _LocationMonitor; class _LocationManager; class _SyncLocationRequestInfo : public Tizen::Base::Object { public: _SyncLocationRequestInfo(_LocationMonitor* pLocMonitor, RequestId reqId, const Tizen::Base::DateTime& requestTime) : Tizen::Base::Object() , __oldLocTime(requestTime) , __pLocMonitor(pLocMonitor) , __pTimer(null) , __reqId(reqId) , __tickCount(0) { } ~_SyncLocationRequestInfo(void) {} _LocationMonitor* GetLocationMonitor(void) const {return __pLocMonitor;} result StartTimer(Tizen::Base::Runtime::ITimerEventListener& listener) { result r = E_SUCCESS; if (__pTimer == null) { std::unique_ptr< Tizen::Base::Runtime::Timer > pTimer(new (std::nothrow) Tizen::Base::Runtime::Timer()); SysTryReturn(NID_LOC, pTimer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); r = pTimer->Construct(listener); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to construct the timer.", GetErrorMessage(r)); __pTimer = std::move(pTimer); } const int DEFAULT_TIME_OUT = 1000; r = __pTimer->Start(DEFAULT_TIME_OUT); SysTryReturn(NID_LOC, r == E_SUCCESS, r, r, "[%s] Failed to start the timer.", GetErrorMessage(r)); __tickCount++; return E_SUCCESS; } bool Equals(const Tizen::Base::Runtime::Timer& timer) {return __pTimer->Equals(timer);} RequestId GetRequestId(void) const {return __reqId;} int GetTickCount(void) const {return __tickCount;} bool IsInTime(const Tizen::Base::DateTime& timestamp) { SysSecureLog(NID_LOC, "Previous location time is (%ls) and the current location time is (%ls)", __oldLocTime.ToString().GetPointer(), timestamp.ToString().GetPointer()); return (timestamp > __oldLocTime) ? true : false; } bool IsAccuracySatisfying(LocationAccuracy accuracy) { if (accuracy == LOC_ACCURACY_INVALID) { return false; } else { return (accuracy <= __pLocMonitor->GetAccuracy()) ? true : false; } } private: _SyncLocationRequestInfo(void); _SyncLocationRequestInfo& operator =(const _SyncLocationRequestInfo& rhs); private: Tizen::Base::DateTime __oldLocTime; _LocationMonitor* __pLocMonitor; std::unique_ptr< Tizen::Base::Runtime::Timer > __pTimer; RequestId __reqId; int __tickCount; }; //_SyncLocationRequestInfo }} //Tizen::Locations #endif // _FLOC_INTERNAL_SYNC_LOCATION_REQUEST_INFO_H_