ubuntu-location-service  0.0.2
geoclue.h
1 /*
2  * Copyright © 2012-2013 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_
20 
21 #include "org/freedesktop/dbus/service.h"
22 #include "org/freedesktop/dbus/traits/service.h"
23 #include "org/freedesktop/dbus/types/struct.h"
24 #include "org/freedesktop/dbus/types/stl/tuple.h"
25 
26 #include <string>
27 
28 namespace dbus = org::freedesktop::dbus;
29 
30 namespace org
31 {
32 namespace freedesktop
33 {
34 struct Geoclue
35 {
36  enum class Status : int
37  {
38  error,
39  unavailable,
40  acquiring,
41  available
42  };
43 
44  friend std::ostream& operator<<(std::ostream& out, const Status& status)
45  {
46  static std::map<Status, std::string> lut =
47  {
48  {Status::error, "error"},
49  {Status::unavailable, "unavailable"},
50  {Status::acquiring, "acquiring"},
51  {Status::available, "available"}
52  };
53 
54  return out << lut[status];
55  }
56 
58  {
59  inline static std::string name()
60  {
61  return "GetProviderInfo";
62  }
63  typedef Geoclue Interface;
64  typedef std::tuple<std::string, std::string> ResultType;
65  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
66  };
67 
68  struct GetStatus
69  {
70  inline static std::string name()
71  {
72  return "GetStatus";
73  }
74  typedef Geoclue Interface;
75  typedef int32_t ResultType;
76  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
77  };
78 
79  struct AddReference
80  {
81  inline static std::string name()
82  {
83  return "AddReference";
84  }
85  typedef Geoclue Interface;
86  typedef void ResultType;
87  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
88  };
89 
91  {
92  inline static std::string name()
93  {
94  return "RemoveReference";
95  }
96  typedef Geoclue Interface;
97  typedef void ResultType;
98  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
99  };
100 
101  struct Address
102  {
103  struct GetAddress
104  {
105  inline static std::string name()
106  {
107  return "GetAddress";
108  }
109  typedef Address Interface;
110  typedef std::tuple<int32_t, std::map<std::string, std::string>, dbus::types::Struct<std::tuple<int32_t, double, double>>> ResultType;
111  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
112  };
113 
114  struct Signals
115  {
117  {
118  inline static std::string name()
119  {
120  return "PositionChanged";
121  };
122  typedef Address Interface;
123  typedef std::tuple<int32_t, std::map<std::string, std::string>, dbus::types::Struct<std::tuple<int32_t, double, double>>> ArgumentType;
124  };
125  };
126  };
127 
128  struct Position
129  {
130  struct Field
131  {
132  Field() = delete;
133 
134  static const int none = 0;
135  static const int latitude = 1;
136  static const int longitude = 2;
137  static const int altitude = 3;
138  };
139 
140  typedef std::bitset<4> FieldFlags;
141 
142  struct GetPosition
143  {
144  inline static std::string name()
145  {
146  return "GetPosition";
147  }
148  typedef Position Interface;
149  typedef std::tuple<int32_t, int32_t, double, double, double, dbus::types::Struct<std::tuple<int32_t, double, double>>> ResultType;
150  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
151  };
152 
153  struct Signals
154  {
156  {
157  inline static std::string name()
158  {
159  return "PositionChanged";
160  };
161  typedef Position Interface;
162  typedef std::tuple<int32_t, int32_t, double, double, double, dbus::types::Struct<std::tuple<int32_t, double, double>>> ArgumentType;
163  };
164  };
165  };
166 
167  struct Velocity
168  {
169  struct Field
170  {
171  Field() = delete;
172 
173  static const int none = 0;
174  static const int speed = 1;
175  static const int direction = 2;
176  static const int climb = 3;
177  };
178 
179  typedef std::bitset<4> FieldFlags;
180 
181  struct GetVelocity
182  {
183  inline static std::string name()
184  {
185  return "GetVelocity";
186  }
187  typedef Velocity Interface;
188  typedef std::tuple<int32_t, int32_t, double, double, double> ResultType;
189  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
190  };
191  struct Signals
192  {
194  {
195  inline static std::string name()
196  {
197  return "VelocityChanged";
198  };
199  typedef Velocity Interface;
200  typedef std::tuple<int32_t, int32_t, double, double, double> ArgumentType;
201  };
202  };
203  };
204 };
205 }
206 }
207 
208 namespace org
209 {
210 namespace freedesktop
211 {
212 namespace dbus
213 {
214 namespace traits
215 {
216 template<>
217 struct Service<org::freedesktop::Geoclue>
218 {
219  inline static const std::string& interface_name()
220  {
221  static const std::string s{"org.freedesktop.Geoclue"};
222  return s;
223  }
224 };
225 
226 template<>
227 struct Service<org::freedesktop::Geoclue::Address>
228 {
229  inline static const std::string& interface_name()
230  {
231  static const std::string s{"org.freedesktop.Geoclue.Address"};
232  return s;
233  }
234 };
235 
236 template<>
237 struct Service<org::freedesktop::Geoclue::Position>
238 {
239  inline static const std::string& interface_name()
240  {
241  static const std::string s{"org.freedesktop.Geoclue.Position"};
242  return s;
243  }
244 };
245 
246 template<>
247 struct Service<org::freedesktop::Geoclue::Velocity>
248 {
249  inline static const std::string& interface_name()
250  {
251  static const std::string s{"org.freedesktop.Geoclue.Velocity"};
252  return s;
253  }
254 };
255 }
256 }
257 }
258 }
259 
260 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_