Update wrt-plugins-common_0.3.53
[framework/web/wrt-plugins-common.git] / src / modules / tizen / DEPRACATED / Geolocation / Geolocation.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /*
17  * @author      Wojciech Bielawski (w.bielawski@samsung.com)
18  * @version     0.1
19  * @brief
20  */
21
22 #ifndef WRTDEVICEAPIS_PLATFORM_GEOLOCATION_H_
23 #define WRTDEVICEAPIS_PLATFORM_GEOLOCATION_H_
24
25 #include <map>
26 #include <API/Geolocation/IGeolocation.h>
27 #include <API/Geolocation/GeolocationFactory.h>
28 #include <API/Geolocation/EventPositionChanged.h>
29 #include <dpl/shared_ptr.h>
30 #include <dpl/noncopyable.h>
31 #include <location/location.h>
32 #include <platform/commons/Emitters.h>
33
34 namespace WrtPlugins {
35 namespace Platform {
36 namespace Geolocation {
37 class Geolocation : public Api::Geolocation::IGeolocation
38 {
39     LocationObject *m_location;
40     gulong m_signalId;
41     Api::Geolocation::IGeolocation::ApiLocationMethod m_currentLocationMethod;
42
43     friend class WrtPlugins::Api::Geolocation::GeolocationFactory;
44
45   public:
46     virtual ~Geolocation();
47
48     /**
49      * @See: IGelocation::getCurrentPosition
50      */
51     virtual void getCurrentPosition(
52             const Api::Geolocation::EventGetCurrentPositionPtr& event);
53
54     /**
55      * @See: IGelocation::watchPosition
56      */
57     virtual long watchPosition(
58             const Api::Geolocation::EventPositionChangedEmitterPtr& emitter,
59             long timeout,
60             long maximumAge,
61             bool highAccuracy);
62
63     /**
64      * @See: IGelocation::clearWatch
65      */
66     virtual void clearWatch(
67             Api::Geolocation::EventPositionChangedEmitter::IdType id);
68
69     /**
70      * @See: IGelocation::changeLocationMethod
71      */
72     virtual void changeLocationMethod(ApiLocationMethod method);
73
74     /**
75      * Method to run from platform's callback function
76      */
77     void positionHasChanged(LocationObject *obj,
78             guint type,
79             gpointer data,
80             gpointer accuracy);
81
82   protected:
83     Geolocation();
84     virtual void OnRequestReceived(
85             const Api::Geolocation::EventGetCurrentPositionPtr& event);
86
87   private:
88     typedef Emitters<Api::Geolocation::EventPositionChangedEmitter>
89     PositionChangedEmitters;
90
91     void initialize();
92     void start();
93     void stop();
94     void restart();
95     LocationMethod convertMethodToPlatform(ApiLocationMethod method) const;
96
97     PositionChangedEmitters m_positionEmitters;
98     DPL::Mutex m_initializationMutex;
99     bool m_initialized;
100 };
101 }
102 }
103 }
104
105 #endif /* WRTDEVICEAPIS_PLATFORM_GEOLOCATION_H_ */