Merge lp:~thomas-voss/location-service/add_controller_and_service_configuration into lp:location-service/trunk

Proposed by Thomas Voß
Status: Superseded
Proposed branch: lp:~thomas-voss/location-service/add_controller_and_service_configuration
Merge into: lp:location-service/trunk
Diff against target: 13375 lines (+7432/-3163)
119 files modified
CMakeLists.txt (+6/-3)
debian/changelog (+6/-0)
debian/control (+13/-1)
debian/rules (+2/-2)
debian/ubuntu-location-service-bin.install (+1/-1)
debian/ubuntu-location-service-tests.install (+1/-0)
doc/Doxyfile.in (+20/-20)
examples/CMakeLists.txt (+0/-6)
examples/service/CMakeLists.txt (+5/-3)
examples/service/client.cpp (+21/-22)
examples/service/service.cpp (+9/-11)
include/CMakeLists.txt (+3/-3)
include/location_service/com/ubuntu/location/channel.h (+0/-41)
include/location_service/com/ubuntu/location/clock.h (+26/-0)
include/location_service/com/ubuntu/location/codec.h (+278/-319)
include/location_service/com/ubuntu/location/connectivity/bounded_integer.h (+184/-0)
include/location_service/com/ubuntu/location/connectivity/manager.h (+93/-0)
include/location_service/com/ubuntu/location/connectivity/radio_cell.h (+400/-0)
include/location_service/com/ubuntu/location/connectivity/wireless_network.h (+71/-0)
include/location_service/com/ubuntu/location/criteria.h (+33/-23)
include/location_service/com/ubuntu/location/default_provider_selection_policy.h (+6/-6)
include/location_service/com/ubuntu/location/engine.h (+105/-9)
include/location_service/com/ubuntu/location/heading.h (+3/-74)
include/location_service/com/ubuntu/location/optional.h (+35/-0)
include/location_service/com/ubuntu/location/position.h (+23/-45)
include/location_service/com/ubuntu/location/provider.h (+185/-82)
include/location_service/com/ubuntu/location/provider_enumerator.h (+49/-0)
include/location_service/com/ubuntu/location/provider_factory.h (+3/-3)
include/location_service/com/ubuntu/location/provider_selection.h (+62/-0)
include/location_service/com/ubuntu/location/provider_selection_policy.h (+9/-37)
include/location_service/com/ubuntu/location/providers/geoclue/geoclue.h (+28/-31)
include/location_service/com/ubuntu/location/providers/geoclue/provider.h (+4/-7)
include/location_service/com/ubuntu/location/providers/skyhook/provider.h (+2/-2)
include/location_service/com/ubuntu/location/proxy_provider.h (+2/-6)
include/location_service/com/ubuntu/location/satellite_based_positioning_state.h (+40/-0)
include/location_service/com/ubuntu/location/service/configuration.h (+4/-4)
include/location_service/com/ubuntu/location/service/default_configuration.h (+1/-1)
include/location_service/com/ubuntu/location/service/default_permission_manager.h (+1/-1)
include/location_service/com/ubuntu/location/service/implementation.h (+5/-5)
include/location_service/com/ubuntu/location/service/interface.h (+140/-16)
include/location_service/com/ubuntu/location/service/permission_manager.h (+22/-6)
include/location_service/com/ubuntu/location/service/session/implementation.h (+4/-7)
include/location_service/com/ubuntu/location/service/session/interface.h (+78/-223)
include/location_service/com/ubuntu/location/service/session/skeleton.h (+21/-19)
include/location_service/com/ubuntu/location/service/session/stub.h (+13/-14)
include/location_service/com/ubuntu/location/service/skeleton.h (+10/-5)
include/location_service/com/ubuntu/location/service/stub.h (+8/-4)
include/location_service/com/ubuntu/location/space_vehicle.h (+121/-0)
include/location_service/com/ubuntu/location/units/units.h (+6/-0)
include/location_service/com/ubuntu/location/update.h (+34/-5)
include/location_service/com/ubuntu/location/velocity.h (+3/-74)
include/location_service/com/ubuntu/location/wgs84/altitude.h (+2/-2)
include/location_service/com/ubuntu/location/wgs84/coordinate.h (+5/-3)
include/location_service/com/ubuntu/location/wgs84/latitude.h (+2/-2)
include/location_service/com/ubuntu/location/wgs84/longitude.h (+2/-2)
include/location_service/com/ubuntu/location/wifi_and_cell_reporting_state.h (+36/-0)
src/location_service/com/ubuntu/location/CMakeLists.txt (+50/-7)
src/location_service/com/ubuntu/location/connectivity/nm.h (+255/-0)
src/location_service/com/ubuntu/location/connectivity/ofono.h (+338/-0)
src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp (+338/-0)
src/location_service/com/ubuntu/location/criteria.cpp (+99/-0)
src/location_service/com/ubuntu/location/default_permission_manager.cpp (+1/-1)
src/location_service/com/ubuntu/location/default_provider_selection_policy.cpp (+15/-19)
src/location_service/com/ubuntu/location/engine.cpp (+77/-8)
src/location_service/com/ubuntu/location/init_and_shutdown.cpp (+6/-6)
src/location_service/com/ubuntu/location/position.cpp (+43/-76)
src/location_service/com/ubuntu/location/provider.cpp (+66/-103)
src/location_service/com/ubuntu/location/provider_factory.cpp (+2/-2)
src/location_service/com/ubuntu/location/providers/config.cpp (+5/-5)
src/location_service/com/ubuntu/location/providers/geoclue/CMakeLists.txt (+1/-1)
src/location_service/com/ubuntu/location/providers/geoclue/provider.cpp (+37/-39)
src/location_service/com/ubuntu/location/providers/gps/CMakeLists.txt (+9/-2)
src/location_service/com/ubuntu/location/providers/gps/hardware_abstraction_layer.cpp (+604/-0)
src/location_service/com/ubuntu/location/providers/gps/hardware_abstraction_layer.h (+322/-0)
src/location_service/com/ubuntu/location/providers/gps/provider.cpp (+52/-173)
src/location_service/com/ubuntu/location/providers/gps/provider.h (+19/-16)
src/location_service/com/ubuntu/location/providers/skyhook/provider.cpp (+3/-3)
src/location_service/com/ubuntu/location/proxy_provider.cpp (+28/-22)
src/location_service/com/ubuntu/location/service/daemon.cpp (+390/-0)
src/location_service/com/ubuntu/location/service/daemon.h (+79/-0)
src/location_service/com/ubuntu/location/service/daemon_cli_main.cpp (+24/-0)
src/location_service/com/ubuntu/location/service/daemon_main.cpp (+24/-0)
src/location_service/com/ubuntu/location/service/default_configuration.cpp (+8/-4)
src/location_service/com/ubuntu/location/service/default_permission_manager.cpp (+1/-1)
src/location_service/com/ubuntu/location/service/implementation.cpp (+88/-27)
src/location_service/com/ubuntu/location/service/main.cpp (+0/-150)
src/location_service/com/ubuntu/location/service/program_options.h (+27/-1)
src/location_service/com/ubuntu/location/service/session/implementation.cpp (+68/-39)
src/location_service/com/ubuntu/location/service/session/interface.cpp (+10/-37)
src/location_service/com/ubuntu/location/service/session/interface_p.h (+228/-0)
src/location_service/com/ubuntu/location/service/session/skeleton.cpp (+125/-106)
src/location_service/com/ubuntu/location/service/session/stub.cpp (+87/-31)
src/location_service/com/ubuntu/location/service/skeleton.cpp (+106/-178)
src/location_service/com/ubuntu/location/service/stub.cpp (+48/-11)
src/location_service/com/ubuntu/location/set_name_for_thread.cpp (+24/-0)
src/location_service/com/ubuntu/location/set_name_for_thread.h (+34/-0)
tests/CMakeLists.txt (+59/-254)
tests/acceptance_tests.cpp (+318/-78)
tests/accuracy_test.cpp (+0/-35)
tests/accuracy_tests.cpp (+0/-52)
tests/connectivity_manager_test.cpp (+42/-0)
tests/controller_test.cpp (+85/-143)
tests/criteria_test.cpp (+50/-0)
tests/cross_process_sync.h (+0/-63)
tests/daemon_and_cli_tests.cpp (+174/-0)
tests/default_permission_manager_test.cpp (+3/-1)
tests/engine_test.cpp (+96/-29)
tests/fork_and_run.h (+0/-61)
tests/geoclue_provider_test.cpp (+1/-1)
tests/gps_provider_test.cpp (+420/-4)
tests/heading_test.cpp (+1/-1)
tests/position_test.cpp (+39/-67)
tests/provider_factory_test.cpp (+1/-1)
tests/provider_selection_policy_test.cpp (+51/-22)
tests/provider_test.cpp (+93/-64)
tests/session_test.cpp (+2/-2)
tests/test_main.cpp (+5/-8)
tests/velocity_test.cpp (+0/-54)
tests/wgs84_test.cpp (+5/-5)
To merge this branch: bzr merge lp:~thomas-voss/location-service/add_controller_and_service_configuration
Reviewer Review Type Date Requested Status
Francis Ginther Approve
PS Jenkins bot continuous-integration Needs Fixing
Timo Jyrinki Approve
Review via email: mp+199105@code.launchpad.net

This proposal has been superseded by a proposal from 2014-02-03.

Commit message

* Added tests for daemon and cli.
* Unified daemon and cli header and implementation files.
* Add a command-line interface to the service.
* Split up provider selection policy to rely on an interface ProviderEnumerator to ease in testing.
* Trimmed down on types.
* Removed connectivity API draft to prepare for simpler approach.
* Refactored includes.
* Added a configuration option to handle cell and wifi ID reporting.
* Add a mock for a connectivity API exposed to providers and reporters.
* Add units for connectivity api.
* Refactor cell class into namespace radio.

Description of the change

* Added tests for daemon and cli.
* Unified daemon and cli header and implementation files.
* Add a command-line interface to the service.
* Split up provider selection policy to rely on an interface ProviderEnumerator to ease in testing.
* Trimmed down on types.
* Removed connectivity API draft to prepare for simpler approach.
* Refactored includes.
* Added a configuration option to handle cell and wifi ID reporting.
* Add a mock for a connectivity API exposed to providers and reporters.
* Add units for connectivity api.
* Refactor cell class into namespace radio.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Ok after properties-cpp gets approved from trusty NEW queue: https://launchpad.net/ubuntu/trusty/+queue?queue_state=0&queue_text=

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

Job configuration regressed, reapproving now that it is fixed.

review: Approve
88. By Thomas Voß

Merge prerequisite branch.

89. By Thomas Voß

Rename visible_radio_cells to connected_radio_cells.
Add function to trigger a scan for visible wifis.
Add missing attributes in WirelessNetwork.

90. By Thomas Voß

Split out connectivity API for provider-integration purposes.
Make sure that the invalid value for a bounded integer range is available.

91. By Thomas Voß

[ Thomas Voß ]
* Patch version bump reflecting the toolchain switch.
* No change rebuild against boost1.55.
[ thomas-voss ]
* Re-enable onSessionDied().
[ Łukasz 'sil2100' Zemczak ]
* Bump the build-dependency on dbus-cpp due to the ABI change
[ thomas-voss ]
* Backport dummy provider and accompanying tests.
[ thomas-voss ]
* Force compilation against gcc 4.7.
[ thomas-voss ]
* * Fix a race when a session is created while another one ends. *
  Ensure a sensible minimum interval between consecutive location
  updates in the GPS provider. (LP: #1240878)
* Adjust to changes in new dbus-cpp version.

92. By Thomas Voß

Add pkgconfig setup for connectivity API.
Adjust acceptance tests to rely on private bus connection without dbus-test-runner.

93. By Thomas Voß

Add missing pkgconfig file.

94. By Thomas Voß

Adjust radio cell information to reflect information and values available from Android.
Add missing build dependency on process-cpp.

95. By Thomas Voß

Add documentation for BoundedInteger::from_percent.

96. By Thomas Voß

Add more documentation to RadioCell.h.

97. By Thomas Voß

Adjust debian installation setup to account for pkgconfig files now correctly being installed to arch-specific subdirs.

98. By Thomas Voß

Fix installation of pkgconfig-file for connectivity API.

99. By Thomas Voß

Extract ssid and mode from NetworkManager.
Make sure that a missing ofono instance is handled gracefully.

100. By Thomas Voß

Remove dbus-test runner setups as dbus-cpp provides its own fixture now.
Add documentation for space vehicle.
Adjust LTE radio cell to carry an attribute TAC instead of LAC.
Add test-cases for location::connectivity::RadioCell.

101. By Thomas Voß

Add standalone example for using the connectivity API.

102. By Thomas Voß

Add standalone examples to debian package.

103. By Thomas Voß

Remove primary scrambling code from UMTS details.
Make wireless network properties observable.

104. By Thomas Voß

Fix test-case.

105. By Thomas Voß

Add a reporter sending off harvested location data to the mozilla location service.
Add test-cases for the reporter.
Adjust debian/copyright to include mongoose.

106. By Thomas Voß

Add build-dep on jsoncpp.
Make elements based on net-cpp optional for now.
Default to a NullReporter for harvesting.

107. By Thomas Voß

Requesting network scans is now async.

108. By Thomas Voß

Remove obsolete header from service implementation.

109. By Thomas Voß

Conditionally include sources for ichnaea reporter.

110. By Thomas Voß

Fix missing link directive for boost program-options.

111. By Thomas Voß

Add diagnostic message for boost libraries.

112. By Thomas Voß

Fix diagnostic message.

113. By Thomas Voß

Remove obsolete dependency on boost threads.

114. By Thomas Voß

Add test case for repeatedly querying visible cells.

115. By Thomas Voß

Refactor property handling for ofono NetworkRegistration interface.

116. By Thomas Voß

Ensure that NetworkRegistration properties are always up to date.

117. By Thomas Voß

Add test cases for GPS provider construction.

118. By Thomas Voß

Replace std::cout with proper logging.

119. By Thomas Voß

Replace std::cerr with LOG(ERROR) in connectivity manager implementation.
Wire up to properties changed signal for Ofono's NetworkRegistration interface.

120. By Thomas Voß

Rename signal to account for ofono conventions.

121. By Thomas Voß

Adjust argument type for signal PropertyChanged.

122. By Thomas Voß

Log property changes on network registration.

123. By Thomas Voß

Add signals for wifi's being added and removed to connectivity::Manager.

124. By Thomas Voß

Refactor connectivity API for visible wireless networks.

125. By Thomas Voß

Adjust standalone connectivity example.

126. By Thomas Voß

Refactor location::connectivity::RadioCell to prepare for fine-grained update propagation.

127. By Thomas Voß

Refactor implementation and consolidate ofono -> connectivity translation in one place.

128. By Thomas Voß

First cut at exposing modem properties for tracking network registrations.

129. By Thomas Voß

Wire up to a modem's PropertyChanged signal.

130. By Thomas Voß

Further glue for wiring up interface changes on a modem.

131. By Thomas Voß

Wire up to property changes on network registrations.

132. By Thomas Voß

Add threading stress-tests to standalone example.

133. By Thomas Voß

Add missing include <thread> in standalone example.
Keep threads running until cancelled in standalone example.

134. By Thomas Voß

Remove noisy std::cout's in query threads.

135. By Thomas Voß

Wire up cell added/removed signals.

136. By Thomas Voß

Factor out WirelessNetwork and RadioCell implementations into their own header files.

137. By Thomas Voß

Clean up Ofono/NM-based connectivity::Manager implementation.

138. By Thomas Voß

Factor out Ofono/NetworkManager-based implementation into header and impl. file.

139. By Thomas Voß

Split out property updates for wifi's.

140. By Thomas Voß

Wire up network registration property updates.

141. By Thomas Voß

Make the gps provider more verbose when reporting satellite visibility.

142. By Thomas Voß

Replace unguarded .at access to maps with guarded .find().
Add verbose logging line to gps hal for tracking satellite visibility updates.

143. By Thomas Voß

Add missing typename.

144. By Thomas Voß

Add more debugging output to the gps provider.

145. By Thomas Voß

More logging output.

146. By Thomas Voß

Add a missing include for logging in the location engine.

147. By Thomas Voß

Temporarily disable space vehicle reporting.

148. By Thomas Voß

Comment out test case.<

149. By Thomas Voß

Disable test cases instead of commenting them out.

150. By Thomas Voß

Remove overly-verbose logs for satellite visibility reporting.

151. By Thomas Voß

Enable AGPS support in the GPS HAL.

152. By Thomas Voß

Make sure to switch assistance mode on in the chipset driver.

153. By Thomas Voß

Notify network connectivity to GPS chipset.

154. By Thomas Voß

Make sure to announce open data connection on agps status update.

155. By Thomas Voß

Add pretty printing for SuplAssistant::Status.

156. By Thomas Voß

Add logging for agps status updates in the hardware abstraction layer.

157. By Thomas Voß

Add missing include <iosfwd>.

158. By Thomas Voß

Make operator<< inline friend to circumvent icl for gcc on arm.

159. By Thomas Voß

Entirely remove stream out operator to fix ice for gcc.

160. By Thomas Voß

Switch to mobile station based positioning.

161. By Thomas Voß

Format IP triplet as ints.

162. By Thomas Voß

Add first cut at handling agps status updates.

163. By Thomas Voß

Switch to "internet" apn for access to supl servers.

164. By Thomas Voß

Remove unneccessary apn reporting.

165. By Thomas Voß

Reenable reference location injection.

166. By Thomas Voß

Set apn for gps chipset.

167. By Thomas Voß

mobile_station_based is the default for assisted GPS.
Relax requirements on time to first fix.

168. By Thomas Voß

Make sure to reinitialize all agps flags after dropping adding data in trial setup.

169. By Thomas Voß

Ensure to set supl server when data connection is requested.

170. By Thomas Voß

Inject reference location.

171. By Thomas Voß

Make sure to report APN to gps chipset.

172. By Thomas Voß

Add accuracy for reference location.

173. By Thomas Voß

Clean up supl test case.

174. By Thomas Voß

Correct apn name.

175. By Thomas Voß

Allow for reference position injection into gps hal test cases.

176. By Thomas Voß

Make sure that we always set a supl server and port.

177. By Thomas Voß

Just a test.

178. By Thomas Voß

Adding last_seen property to WirelessNetwork.
Adding signal indicating end of wifi scan.

179. By Thomas Voß

Print last seen timestamp.

180. By Thomas Voß

Make sure that technology changes are wired up correctly.

181. By Thomas Voß

Print more verbose cell information on changes.

182. By Thomas Voß

Adjust APN for testing purposes.

183. By Thomas Voß

Inject ref position on nmea update.

184. By Thomas Voß

First cut at support for GPS XTRA data.

185. By Thomas Voß

Make sure that the xtra downloader is initialized.

186. By Thomas Voß

Make the supl benchmark inject reference position on a thread while positioning is active.

187. By Thomas Voß

Put the injector thread to sleep for a second.

188. By Thomas Voß

Fix reporting of agps status enum.
Correctly extract last seen timestamp for property updates.

189. By Thomas Voß

Report last seen as raw timestamps.

190. By Thomas Voß

Subscribe to last seen updates in standalone connectivity example.
Adjust formatting of enumerated wifis in standalone connectivity example.

191. By Thomas Voß

network-manager models last seen updates as strength updates, account for that.

192. By Thomas Voß

Refactor the android-specific implementation of the HardwareAbstractionLayer interface.

193. By Thomas Voß

Remove unneeded implementation file.

194. By Thomas Voß

Refactor the harvester to make it usable for reporting in test cases.

195. By Thomas Voß

Make the harvester more chatty in logs if verbose logging is enabled.

196. By Thomas Voß

Make reporting to ichnaea from gps provider test cases opt-in.

197. By Thomas Voß

Make sure that missing last_seen property is not fatal.

198. By Thomas Voß

Shrink the directory name for installed tests.

199. By Thomas Voß

[ Ubuntu daily release ]
* New rebuild forced
[ Ricardo Mendoza ]
* Platform API V2 rebuild

200. By Thomas Voß

Make reference position more readable.

201. By Thomas Voß

Refactor setup to make daemon and cli testable.
Add nickname property to ichnaea reporter.

202. By Thomas Voß

Address build warning for ichnaea reporter test.
Add net-cpp as build-dependency.

203. By Thomas Voß

Fix type in debian/control.

204. By Thomas Voß

Adjust install directories.

205. By Thomas Voß

Refactor and clean up gps provider test case.

206. By Thomas Voß

Refactored command line parsing to take a factory functor for creating connections to the bus (used in testing).

207. By Thomas Voß

Add an end-to-end acceptance test exercising the service with hundreds of clients randomly dying away.
Adjust implementation to correctly disconnect from core::Signal's by levering RAII as provided by core::ScopedConnection.

208. By Thomas Voß

Factor out GPS Xtra Downloader implementations and add tests around them.

209. By Thomas Voß

Disable gps xtra downloader test against external URL as the test fails in CI.

210. By Thomas Voß

Refactor skeletons for service and session, getting rid of the pimpl-pattern.
Introduce a dedicated outgoing dbus connection for integrating with other services.
Factor out testing webserver into its own class and adjust test cases.

211. By Thomas Voß

Factor out wap-headers for GPS Xtra Data Downloader.
Add checks for header in GpsXtraDownloader test cases.

212. By Thomas Voß

Remove UNRELEASED changelog artifact.

213. By Thomas Voß

Make sure that the testing web server is up before executing client requests.

214. By Thomas Voß

Send reply via the same dbus connection.

215. By Thomas Voß

Factor out resolution of client credentials and object path creation into interfaces.

216. By Thomas Voß

Make sure that session counter is incremented on access.

217. By Thomas Voß

Bump so name to account for api change.

218. By Thomas Voß

Make sure to install the versioned include directory.

219. By Thomas Voß

Bump major version.

220. By Thomas Voß

Add dependency on library package.

221. By Thomas Voß

Make sure that the dummy provider thread is correctly joined when stopped.

222. By Thomas Voß

Make sure that the daemon logs to /var/log/ubuntu-location-service.
Make sure that the CLI logs to stderr.
Make sure that the client library logs to stderr.

223. By Thomas Voß

Remove build dependency on json-cpp and net-cpp.

224. By Thomas Voß

Adjust expected type for LastSeen timestamps on wifis.

225. By Thomas Voß

Comment out header for GpsXtraDownloader.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2013-10-14 06:11:15 +0000
+++ CMakeLists.txt 2014-02-03 13:52:45 +0000
@@ -25,7 +25,8 @@
25find_package(GFlags)25find_package(GFlags)
26pkg_check_modules(DBUS dbus-1 REQUIRED)26pkg_check_modules(DBUS dbus-1 REQUIRED)
27pkg_check_modules(DBUS_CPP dbus-cpp REQUIRED)27pkg_check_modules(DBUS_CPP dbus-cpp REQUIRED)
2828pkg_check_modules(PROCESS_CPP process-cpp REQUIRED)
29pkg_check_modules(PROPERTIES_CPP properties-cpp REQUIRED)
29#####################################################################30#####################################################################
30# Enable code coverage calculation with gcov/gcovr/lcov31# Enable code coverage calculation with gcov/gcovr/lcov
31# Usage:32# Usage:
@@ -43,13 +44,15 @@
4344
44option (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS "Disable errors when local typedefs are unused" ON)45option (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS "Disable errors when local typedefs are unused" ON)
45if (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)46if (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)
46 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs")47 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs")
47endif (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)48endif (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)
4849
49include_directories(50include_directories(
50 ${Boost_INCLUDE_DIRS}51 ${Boost_INCLUDE_DIRS}
51 ${DBUS_INCLUDE_DIRS}52 ${DBUS_INCLUDE_DIRS}
52 ${DBUS_CPP_INCLUDE_DIRS}/dbus53 ${DBUS_CPP_INCLUDE_DIRS}
54 ${PROPERTIES_CPP_INCLUDE_DIRS}
55 ${PROCESS_CPP_INCLUDE_DIRS}
53 ${GLog_INCLUDE_DIR}56 ${GLog_INCLUDE_DIR}
54 ${GFlags_INCLUDE_DIR}57 ${GFlags_INCLUDE_DIR}
55 include/location_service58 include/location_service
5659
=== modified file 'debian/changelog'
--- debian/changelog 2013-10-22 17:24:31 +0000
+++ debian/changelog 2014-02-03 13:52:45 +0000
@@ -1,3 +1,9 @@
1location-service (0.0.2+13.10.20131016.1-0ubuntu3) UNRELEASED; urgency=medium
2
3 * Version bump
4
5 -- Thomas Voß <thomas.voss@canonical.com> Mon, 13 Jan 2014 16:18:15 +0100
6
1location-service (0.0.2+13.10.20131016.1-0ubuntu2) trusty; urgency=low7location-service (0.0.2+13.10.20131016.1-0ubuntu2) trusty; urgency=low
28
3 * No change rebuild for Boost 1.54 transition.9 * No change rebuild for Boost 1.54 transition.
410
=== modified file 'debian/control'
--- debian/control 2013-10-22 17:24:31 +0000
+++ debian/control 2014-02-03 13:52:45 +0000
@@ -7,7 +7,7 @@
7XSBC-Original-Maintainer: Thomas Voß <thomas.voss@canonical.com>7XSBC-Original-Maintainer: Thomas Voß <thomas.voss@canonical.com>
8Build-Depends: cmake,8Build-Depends: cmake,
9 curl,9 curl,
10 dbus-cpp-dev,10 libdbus-cpp-dev,
11 dbus-test-runner,11 dbus-test-runner,
12 debhelper (>= 9),12 debhelper (>= 9),
13 doxygen,13 doxygen,
@@ -19,11 +19,14 @@
19 libboost-program-options-dev,19 libboost-program-options-dev,
20 libboost-system-dev,20 libboost-system-dev,
21 libdbus-1-dev,21 libdbus-1-dev,
22 libdbus-cpp-dev,
22 libgoogle-glog-dev,23 libgoogle-glog-dev,
23 libgtest-dev,24 libgtest-dev,
24 libiw-dev,25 libiw-dev,
25 libplatform-hardware-api-headers,26 libplatform-hardware-api-headers,
26 libplatform-hardware-api1-dev,27 libplatform-hardware-api1-dev,
28 libprocess-cpp-dev,
29 libproperties-cpp-dev,
27Standards-Version: 3.9.430Standards-Version: 3.9.4
28Homepage: http://launchpad.net/location-service31Homepage: http://launchpad.net/location-service
29# If you aren't a member of ~phablet-team but need to upload packaging changes,32# If you aren't a member of ~phablet-team but need to upload packaging changes,
@@ -57,6 +60,15 @@
57 Contains header files required to develop clients talking to the ubuntu60 Contains header files required to develop clients talking to the ubuntu
58 location service.61 location service.
5962
63Package: ubuntu-location-service-tests
64Architecture: any
65Depends: ${misc:Depends},
66 ${shlibs:Depends},
67Description: location service aggregating position/velocity/heading
68 updates and exporting them over dbus.
69 .
70 Contains all test executables
71
60Package: ubuntu-location-service-bin72Package: ubuntu-location-service-bin
61Architecture: any73Architecture: any
62Depends: ${misc:Depends},74Depends: ${misc:Depends},
6375
=== modified file 'debian/rules'
--- debian/rules 2013-08-19 21:48:28 +0000
+++ debian/rules 2014-02-03 13:52:45 +0000
@@ -11,8 +11,8 @@
1111
12DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)12DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
1313
14export C=gcc-4.714# export C=gcc-4.7
15export CXX=g++-4.715# export CXX=g++-4.7
1616
17export DPKG_GENSYMBOLS_CHECK_LEVEL=417export DPKG_GENSYMBOLS_CHECK_LEVEL=4
1818
1919
=== modified file 'debian/ubuntu-location-service-bin.install'
--- debian/ubuntu-location-service-bin.install 2013-10-08 14:48:43 +0000
+++ debian/ubuntu-location-service-bin.install 2014-02-03 13:52:45 +0000
@@ -1,4 +1,4 @@
1etc/dbus-1/system.d/1etc/dbus-1/system.d/
2etc/init/*2etc/init/*
3usr/bin/ubuntu-location-serviced3usr/bin/ubuntu-location-serviced
44usr/bin/ubuntu-location-serviced-cli
55
=== added file 'debian/ubuntu-location-service-tests.install'
--- debian/ubuntu-location-service-tests.install 1970-01-01 00:00:00 +0000
+++ debian/ubuntu-location-service-tests.install 2014-02-03 13:52:45 +0000
@@ -0,0 +1,1 @@
1usr/bin/ubuntu-location-service-tests/*
02
=== modified file 'doc/Doxyfile.in'
--- doc/Doxyfile.in 2013-08-31 06:23:08 +0000
+++ doc/Doxyfile.in 2014-02-03 13:52:45 +0000
@@ -32,13 +32,13 @@
32# This could be handy for archiving the generated documentation or32# This could be handy for archiving the generated documentation or
33# if some version control system is used.33# if some version control system is used.
3434
35PROJECT_NUMBER = @UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@.@UBUNTU_LOCATION_SERVICE_VERSION_MINOR@.@UBUNTU_LOCATION_SERVICE_VERSION_PATCH@35PROJECT_NUMBER = @LOCATION_SERVICE_VERSION_MAJOR@.@LOCATION_SERVICE_VERSION_MINOR@.@LOCATION_SERVICE_VERSION_PATCH@
3636
37# Using the PROJECT_BRIEF tag one can provide an optional one line description37# Using the PROJECT_BRIEF tag one can provide an optional one line description
38# for a project that appears at the top of each page and should give viewer38# for a project that appears at the top of each page and should give viewer
39# a quick idea about the purpose of the project. Keep the description short.39# a quick idea about the purpose of the project. Keep the description short.
4040
41PROJECT_BRIEF =41PROJECT_BRIEF = "An aggregating location service providing positioning and geocoding capabilities to applications."
4242
43# With the PROJECT_LOGO tag one can specify an logo or icon that is43# With the PROJECT_LOGO tag one can specify an logo or icon that is
44# included in the documentation. The maximum height of the logo should not44# included in the documentation. The maximum height of the logo should not
@@ -266,7 +266,7 @@
266# func(std::string) {}). This also makes the inheritance and collaboration266# func(std::string) {}). This also makes the inheritance and collaboration
267# diagrams that involve STL classes more complete and accurate.267# diagrams that involve STL classes more complete and accurate.
268268
269BUILTIN_STL_SUPPORT = NO269BUILTIN_STL_SUPPORT = YES
270270
271# If you use Microsoft's C++/CLI language, you should set this option to YES to271# If you use Microsoft's C++/CLI language, you should set this option to YES to
272# enable parsing support.272# enable parsing support.
@@ -365,7 +365,7 @@
365# Private class members and static file members will be hidden unless365# Private class members and static file members will be hidden unless
366# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES366# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
367367
368EXTRACT_ALL = NO368EXTRACT_ALL = YES
369369
370# If the EXTRACT_PRIVATE tag is set to YES all private members of a class370# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
371# will be included in the documentation.371# will be included in the documentation.
@@ -380,7 +380,7 @@
380# If the EXTRACT_STATIC tag is set to YES all static members of a file380# If the EXTRACT_STATIC tag is set to YES all static members of a file
381# will be included in the documentation.381# will be included in the documentation.
382382
383EXTRACT_STATIC = NO383EXTRACT_STATIC = YES
384384
385# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)385# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
386# defined locally in source files will be included in the documentation.386# defined locally in source files will be included in the documentation.
@@ -423,7 +423,7 @@
423# If set to NO (the default) these declarations will be included in the423# If set to NO (the default) these declarations will be included in the
424# documentation.424# documentation.
425425
426HIDE_FRIEND_COMPOUNDS = NO426HIDE_FRIEND_COMPOUNDS = YES
427427
428# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any428# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
429# documentation blocks found inside the body of a function.429# documentation blocks found inside the body of a function.
@@ -668,7 +668,7 @@
668# directories like "/usr/src/myproject". Separate the files or directories668# directories like "/usr/src/myproject". Separate the files or directories
669# with spaces.669# with spaces.
670670
671INPUT = @CMAKE_CURRENT_SOURCE_DIR@/../include671INPUT = @CMAKE_CURRENT_SOURCE_DIR@ @CMAKE_CURRENT_SOURCE_DIR@/../include
672672
673# This tag can be used to specify the character encoding of the source files673# This tag can be used to specify the character encoding of the source files
674# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is674# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
@@ -728,7 +728,7 @@
728# directories that contain example code fragments that are included (see728# directories that contain example code fragments that are included (see
729# the \include command).729# the \include command).
730730
731EXAMPLE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/../examples731EXAMPLE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/../tests
732732
733# If the value of the EXAMPLE_PATH tag contains directories, you can use the733# If the value of the EXAMPLE_PATH tag contains directories, you can use the
734# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp734# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
@@ -791,7 +791,7 @@
791# This can be useful if you have a project on for instance GitHub and want reuse791# This can be useful if you have a project on for instance GitHub and want reuse
792# the introduction page also for the doxygen output.792# the introduction page also for the doxygen output.
793793
794USE_MDFILE_AS_MAINPAGE =794USE_MDFILE_AS_MAINPAGE = @CMAKE_SOURCE_DIR@/README.md
795795
796#---------------------------------------------------------------------------796#---------------------------------------------------------------------------
797# configuration options related to source browsing797# configuration options related to source browsing
@@ -807,7 +807,7 @@
807# Setting the INLINE_SOURCES tag to YES will include the body807# Setting the INLINE_SOURCES tag to YES will include the body
808# of functions and classes directly in the documentation.808# of functions and classes directly in the documentation.
809809
810INLINE_SOURCES = YES810INLINE_SOURCES = NO
811811
812# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct812# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
813# doxygen to hide any special comment blocks from generated source code813# doxygen to hide any special comment blocks from generated source code
@@ -929,7 +929,7 @@
929# robust against future updates. Doxygen will copy the style sheet file to929# robust against future updates. Doxygen will copy the style sheet file to
930# the output directory.930# the output directory.
931931
932HTML_EXTRA_STYLESHEET =932HTML_EXTRA_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/extra.css
933933
934# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or934# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
935# other source files which should be copied to the HTML output directory. Note935# other source files which should be copied to the HTML output directory. Note
@@ -975,7 +975,7 @@
975# documentation will contain sections that can be hidden and shown after the975# documentation will contain sections that can be hidden and shown after the
976# page has loaded.976# page has loaded.
977977
978HTML_DYNAMIC_SECTIONS = NO978HTML_DYNAMIC_SECTIONS = YES
979979
980# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of980# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of
981# entries shown in the various tree structured indices initially; the user981# entries shown in the various tree structured indices initially; the user
@@ -1145,7 +1145,7 @@
1145# navigation tree you can set this option to NO if you already set1145# navigation tree you can set this option to NO if you already set
1146# GENERATE_TREEVIEW to YES.1146# GENERATE_TREEVIEW to YES.
11471147
1148DISABLE_INDEX = NO1148DISABLE_INDEX = YES
11491149
1150# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index1150# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
1151# structure should be generated to display hierarchical information.1151# structure should be generated to display hierarchical information.
@@ -1157,7 +1157,7 @@
1157# Since the tree basically has the same information as the tab index you1157# Since the tree basically has the same information as the tab index you
1158# could consider to set DISABLE_INDEX to NO when enabling this option.1158# could consider to set DISABLE_INDEX to NO when enabling this option.
11591159
1160GENERATE_TREEVIEW = NO1160GENERATE_TREEVIEW = YES
11611161
1162# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values1162# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values
1163# (range [0,1..20]) that doxygen will group on one line in the generated HTML1163# (range [0,1..20]) that doxygen will group on one line in the generated HTML
@@ -1234,7 +1234,7 @@
1234# typically be disabled. For large projects the javascript based search engine1234# typically be disabled. For large projects the javascript based search engine
1235# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.1235# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
12361236
1237SEARCHENGINE = NO 1237SEARCHENGINE = NO
12381238
1239# When the SERVER_BASED_SEARCH tag is enabled the search engine will be1239# When the SERVER_BASED_SEARCH tag is enabled the search engine will be
1240# implemented using a web server instead of a web client using Javascript.1240# implemented using a web server instead of a web client using Javascript.
@@ -1293,7 +1293,7 @@
1293# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will1293# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
1294# generate Latex output.1294# generate Latex output.
12951295
1296GENERATE_LATEX = NO1296GENERATE_LATEX = YES
12971297
1298# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.1298# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
1299# If a relative path is entered the value of OUTPUT_DIRECTORY will be1299# If a relative path is entered the value of OUTPUT_DIRECTORY will be
@@ -1319,7 +1319,7 @@
1319# LaTeX documents. This may be useful for small projects and may help to1319# LaTeX documents. This may be useful for small projects and may help to
1320# save some trees in general.1320# save some trees in general.
13211321
1322COMPACT_LATEX = NO1322COMPACT_LATEX = YES
13231323
1324# The PAPER_TYPE tag can be used to set the paper type that is used1324# The PAPER_TYPE tag can be used to set the paper type that is used
1325# by the printer. Possible values are: a4, letter, legal and1325# by the printer. Possible values are: a4, letter, legal and
@@ -1377,7 +1377,7 @@
1377# Note that which sources are shown also depends on other settings1377# Note that which sources are shown also depends on other settings
1378# such as SOURCE_BROWSER.1378# such as SOURCE_BROWSER.
13791379
1380LATEX_SOURCE_CODE = NO1380LATEX_SOURCE_CODE = NO
13811381
1382# The LATEX_BIB_STYLE tag can be used to specify the style to use for the1382# The LATEX_BIB_STYLE tag can be used to specify the style to use for the
1383# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See1383# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See
@@ -1434,7 +1434,7 @@
1434# If the GENERATE_MAN tag is set to YES (the default) Doxygen will1434# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
1435# generate man pages1435# generate man pages
14361436
1437GENERATE_MAN = NO1437GENERATE_MAN = YES
14381438
1439# The MAN_OUTPUT tag is used to specify where the man pages will be put.1439# The MAN_OUTPUT tag is used to specify where the man pages will be put.
1440# If a relative path is entered the value of OUTPUT_DIRECTORY will be1440# If a relative path is entered the value of OUTPUT_DIRECTORY will be
@@ -1684,7 +1684,7 @@
1684# explicitly to a value larger than 0 to get control over the balance1684# explicitly to a value larger than 0 to get control over the balance
1685# between CPU load and processing speed.1685# between CPU load and processing speed.
16861686
1687DOT_NUM_THREADS = 01687DOT_NUM_THREADS = 1
16881688
1689# By default doxygen will use the Helvetica font for all dot files that1689# By default doxygen will use the Helvetica font for all dot files that
1690# doxygen generates. When you want a differently looking font you can specify1690# doxygen generates. When you want a differently looking font you can specify
16911691
=== modified file 'examples/CMakeLists.txt'
--- examples/CMakeLists.txt 2013-05-28 14:20:45 +0000
+++ examples/CMakeLists.txt 2014-02-03 13:52:45 +0000
@@ -1,7 +1,1 @@
1add_subdirectory(service)1add_subdirectory(service)
2
3
4
5
6
7
82
=== modified file 'examples/service/CMakeLists.txt'
--- examples/service/CMakeLists.txt 2013-08-29 09:21:07 +0000
+++ examples/service/CMakeLists.txt 2014-02-03 13:52:45 +0000
@@ -2,12 +2,12 @@
2find_package(Boost COMPONENTS system)2find_package(Boost COMPONENTS system)
3find_package(Threads)3find_package(Threads)
44
5pkg_check_modules(DBUS dbus-1)5pkg_check_modules(DBUS dbus-1 REQUIRED)
6pkg_check_modules(DBUS_CPP dbus-cpp)6pkg_check_modules(DBUS_CPP dbus-cpp REQUIRED)
7include_directories(7include_directories(
8 ${Boost_INCLUDE_DIRS}8 ${Boost_INCLUDE_DIRS}
9 ${DBUS_INCLUDE_DIRS}9 ${DBUS_INCLUDE_DIRS}
10 ${DBUS_CPP_INCLUDE_DIRS}/dbus10 ${DBUS_CPP_INCLUDE_DIRS}
1111
12)12)
1313
@@ -33,6 +33,7 @@
33 ${CMAKE_THREAD_LIBS_INIT}33 ${CMAKE_THREAD_LIBS_INIT}
34 ${Boost_LIBRARIES}34 ${Boost_LIBRARIES}
35 ${DBUS_LIBRARIES}35 ${DBUS_LIBRARIES}
36 ${DBUS_CPP_LDFLAGS}
36)37)
3738
38target_link_libraries(39target_link_libraries(
@@ -43,6 +44,7 @@
43 ${CMAKE_THREAD_LIBS_INIT}44 ${CMAKE_THREAD_LIBS_INIT}
44 ${Boost_LIBRARIES}45 ${Boost_LIBRARIES}
45 ${DBUS_LIBRARIES}46 ${DBUS_LIBRARIES}
47 ${DBUS_CPP_LDFLAGS}
46)48)
4749
48add_custom_command(50add_custom_command(
4951
=== modified file 'examples/service/client.cpp'
--- examples/service/client.cpp 2013-05-28 14:41:06 +0000
+++ examples/service/client.cpp 2014-02-03 13:52:45 +0000
@@ -17,16 +17,17 @@
17 */17 */
18#include "program_options.h"18#include "program_options.h"
1919
20#include "com/ubuntu/location/service/stub.h"20#include <com/ubuntu/location/service/stub.h>
2121
22#include <org/freedesktop/dbus/resolver.h>22#include <core/dbus/resolver.h>
23#include <org/freedesktop/dbus/asio/executor.h>23#include <core/dbus/asio/executor.h>
2424
25#include <thread>25#include <thread>
2626
27namespace cul = com::ubuntu::location;27namespace cul = com::ubuntu::location;
28namespace culs = com::ubuntu::location::service;28namespace culs = com::ubuntu::location::service;
29namespace dbus = org::freedesktop::dbus;29namespace culss = com::ubuntu::location::service::session;
30namespace dbus = core::dbus;
3031
31int main(int argc, char** argv)32int main(int argc, char** argv)
32{33{
@@ -53,36 +54,34 @@
53 {"system", dbus::WellKnownBus::system},54 {"system", dbus::WellKnownBus::system},
54 };55 };
5556
56 org::freedesktop::dbus::Bus::Ptr bus57 dbus::Bus::Ptr bus
57 {58 {
58 new org::freedesktop::dbus::Bus{lut.at(options.value_for_key<std::string>("bus"))}59 new dbus::Bus{lut.at(options.value_for_key<std::string>("bus"))}
59 };60 };
60 bus->install_executor(61 bus->install_executor(dbus::asio::make_executor(bus));
61 org::freedesktop::dbus::Executor::Ptr(
62 new org::freedesktop::dbus::asio::Executor{bus}));
63 std::thread t{[bus](){bus->run();}};62 std::thread t{[bus](){bus->run();}};
64 63
65 auto location_service = 64 auto location_service =
66 org::freedesktop::dbus::resolve_service_on_bus<culs::Interface, culs::Stub>(bus);65 dbus::resolve_service_on_bus<culs::Interface, culs::Stub>(bus);
67 66
68 auto s1 = location_service->create_session_for_criteria(com::ubuntu::location::Criteria{});67 auto s1 = location_service->create_session_for_criteria(cul::Criteria{});
69 68
70 s1->install_position_updates_handler(69 s1->updates().position.changed().connect(
71 [&](const com::ubuntu::location::Update<com::ubuntu::location::Position>& new_position) {70 [&](const cul::Update<cul::Position>& new_position) {
72 std::cout << "On position updated: " << new_position << std::endl;71 std::cout << "On position updated: " << new_position << std::endl;
73 });72 });
74 s1->install_velocity_updates_handler(73 s1->updates().velocity.changed().connect(
75 [&](const com::ubuntu::location::Update<com::ubuntu::location::Velocity>& new_velocity) {74 [&](const cul::Update<cul::Velocity>& new_velocity) {
76 std::cout << "On velocity_changed " << new_velocity << std::endl;75 std::cout << "On velocity_changed " << new_velocity << std::endl;
77 });76 });
78 s1->install_heading_updates_handler(77 s1->updates().heading.changed().connect(
79 [&](const com::ubuntu::location::Update<com::ubuntu::location::Heading>& new_heading) {78 [&](const cul::Update<cul::Heading>& new_heading) {
80 std::cout << "On heading changed: " << new_heading << std::endl;79 std::cout << "On heading changed: " << new_heading << std::endl;
81 });80 });
82 81
83 s1->start_position_updates();82 s1->updates().position_status = culss::Interface::Updates::Status::enabled;
84 s1->start_velocity_updates();83 s1->updates().heading_status = culss::Interface::Updates::Status::enabled;
85 s1->start_heading_updates();84 s1->updates().velocity_status = culss::Interface::Updates::Status::enabled;
86 85
87 if (t.joinable())86 if (t.joinable())
88 t.join();87 t.join();
8988
=== modified file 'examples/service/service.cpp'
--- examples/service/service.cpp 2013-05-29 06:04:02 +0000
+++ examples/service/service.cpp 2014-02-03 13:52:45 +0000
@@ -17,19 +17,19 @@
17 */17 */
18#include "program_options.h"18#include "program_options.h"
1919
20#include "com/ubuntu/location/provider_factory.h"20#include <com/ubuntu/location/provider_factory.h>
2121
22#include "com/ubuntu/location/service/default_configuration.h"22#include <com/ubuntu/location/service/default_configuration.h>
23#include "com/ubuntu/location/service/implementation.h"23#include <com/ubuntu/location/service/implementation.h>
2424
25#include <org/freedesktop/dbus/announcer.h>25#include <core/dbus/announcer.h>
26#include <org/freedesktop/dbus/asio/executor.h>26#include <core/dbus/asio/executor.h>
2727
28#include <thread>28#include <thread>
2929
30namespace cul = com::ubuntu::location;30namespace cul = com::ubuntu::location;
31namespace culs = com::ubuntu::location::service;31namespace culs = com::ubuntu::location::service;
32namespace dbus = org::freedesktop::dbus;32namespace dbus = core::dbus;
3333
34int main(int argc, char** argv)34int main(int argc, char** argv)
35{35{
@@ -124,9 +124,7 @@
124 new dbus::Bus{lut.at(options.value_for_key<std::string>("bus"))}124 new dbus::Bus{lut.at(options.value_for_key<std::string>("bus"))}
125 };125 };
126126
127 bus->install_executor(127 bus->install_executor(dbus::asio::make_executor(bus));
128 dbus::Executor::Ptr(
129 new dbus::asio::Executor{bus}));
130128
131 culs::DefaultConfiguration config;129 culs::DefaultConfiguration config;
132 130
133131
=== modified file 'include/CMakeLists.txt'
--- include/CMakeLists.txt 2013-05-28 14:20:45 +0000
+++ include/CMakeLists.txt 2014-02-03 13:52:45 +0000
@@ -1,4 +1,4 @@
1install(1install(
2 DIRECTORY location_service/com
3 DESTINATION include/ubuntu-location-service-${UBUNTU_LOCATION_SERVICE_VERSION_MAJOR}
4)
5\ No newline at end of file2\ No newline at end of file
3 DIRECTORY location_service/com
4 DESTINATION include/ubuntu-location-service-${UBUNTU_LOCATION_SERVICE_VERSION_MAJOR}
5)
66
=== removed file 'include/location_service/com/ubuntu/location/channel.h'
--- include/location_service/com/ubuntu/location/channel.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/channel.h 1970-01-01 00:00:00 +0000
@@ -1,41 +0,0 @@
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_CHANNEL_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CHANNEL_H_
20
21#include <boost/signals2.hpp>
22
23#include <memory>
24#include <set>
25
26namespace com
27{
28namespace ubuntu
29{
30namespace location
31{
32template<typename T>
33using Channel = boost::signals2::signal<void(const T&)>;
34
35typedef boost::signals2::scoped_connection ScopedChannelConnection;
36typedef boost::signals2::connection ChannelConnection;
37}
38}
39}
40
41#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CHANNEL_H_
420
=== modified file 'include/location_service/com/ubuntu/location/clock.h'
--- include/location_service/com/ubuntu/location/clock.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/clock.h 2014-02-03 13:52:45 +0000
@@ -26,15 +26,41 @@
26{26{
27namespace location27namespace location
28{28{
29/**
30 * @brief Defines the timebase of the location service.
31 */
29struct Clock32struct Clock
30{33{
34 /** @brief The underlying clock we are assuming for all time-stamping purposes. */
35 typedef std::chrono::high_resolution_clock Type;
36
37 /**
38 * @brief Duration type of the location service clock.
39 */
31 typedef std::chrono::high_resolution_clock::duration Duration;40 typedef std::chrono::high_resolution_clock::duration Duration;
41
42 /**
43 * @brief Timestamp type of the location service clock.
44 */
32 typedef std::chrono::high_resolution_clock::time_point Timestamp;45 typedef std::chrono::high_resolution_clock::time_point Timestamp;
3346
47 /**
48 * @brief Samples a timestamp from the clock.
49 * @return The current time.
50 */
34 static inline Timestamp now()51 static inline Timestamp now()
35 {52 {
36 return std::chrono::high_resolution_clock::now();53 return std::chrono::high_resolution_clock::now();
37 }54 }
55
56 /**
57 * @brief Samples a timestamp from the clock.
58 * @return The minimum point in time representable by this clock.
59 */
60 static inline Timestamp beginning_of_time()
61 {
62 return std::chrono::high_resolution_clock::time_point::min();
63 }
38};64};
39}65}
40}66}
4167
=== modified file 'include/location_service/com/ubuntu/location/codec.h'
--- include/location_service/com/ubuntu/location/codec.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/codec.h 2014-02-03 13:52:45 +0000
@@ -18,22 +18,20 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_
2020
21#include "com/ubuntu/location/accuracy.h"21#include <com/ubuntu/location/criteria.h>
22#include "com/ubuntu/location/criteria.h"22#include <com/ubuntu/location/heading.h>
23#include "com/ubuntu/location/heading.h"23#include <com/ubuntu/location/position.h>
24#include "com/ubuntu/location/position.h"24#include <com/ubuntu/location/space_vehicle.h>
25#include "com/ubuntu/location/update.h"25#include <com/ubuntu/location/update.h>
26#include "com/ubuntu/location/velocity.h"26#include <com/ubuntu/location/velocity.h>
27#include "com/ubuntu/location/units/units.h"27#include <com/ubuntu/location/units/units.h>
28#include "com/ubuntu/location/wgs84/altitude.h"28#include <com/ubuntu/location/wgs84/altitude.h>
29#include "com/ubuntu/location/wgs84/latitude.h"29#include <com/ubuntu/location/wgs84/latitude.h>
30#include "com/ubuntu/location/wgs84/longitude.h"30#include <com/ubuntu/location/wgs84/longitude.h>
3131
32#include <org/freedesktop/dbus/codec.h>32#include <core/dbus/codec.h>
3333
34namespace org34namespace core
35{
36namespace freedesktop
37{35{
38namespace dbus36namespace dbus
39{37{
@@ -46,6 +44,7 @@
46 {44 {
47 return ArgumentType::floating_point;45 return ArgumentType::floating_point;
48 }46 }
47
49 constexpr static bool is_basic_type()48 constexpr static bool is_basic_type()
50 {49 {
51 return true;50 return true;
@@ -64,319 +63,283 @@
64}63}
6564
66template<typename T>65template<typename T>
66struct Codec<com::ubuntu::location::Optional<T>>
67{
68 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Optional<T>& in)
69 {
70 bool has_value{in};
71 Codec<bool>::encode_argument(writer, has_value);
72 if (has_value)
73 Codec<typename com::ubuntu::location::Optional<T>::value_type>::encode_argument(writer, *in);
74 }
75
76 static void decode_argument(Message::Reader& reader, com::ubuntu::location::Optional<T>& in)
77 {
78 bool has_value{false};
79 Codec<bool>::decode_argument(reader, has_value);
80 if (has_value)
81 {
82 typename com::ubuntu::location::Optional<T>::value_type value;
83 Codec<typename com::ubuntu::location::Optional<T>::value_type>::decode_argument(reader, value);
84 in = value;
85 } else
86 {
87 in.reset();
88 }
89 }
90};
91
92template<typename T>
67struct Codec<com::ubuntu::location::units::Quantity<T>>93struct Codec<com::ubuntu::location::units::Quantity<T>>
68{94{
69 static void encode_argument(DBusMessageIter* out, const com::ubuntu::location::units::Quantity<T>& in)95 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::units::Quantity<T>& in)
70 {96 {
71 Codec<typename com::ubuntu::location::units::Quantity<T>::value_type>::encode_argument(out, in.value());97 Codec<typename com::ubuntu::location::units::Quantity<T>::value_type>::encode_argument(writer, in.value());
72 }98 }
7399
74 static void decode_argument(DBusMessageIter* out, com::ubuntu::location::units::Quantity<T>& in)100 static void decode_argument(Message::Reader& reader, com::ubuntu::location::units::Quantity<T>& in)
75 {101 {
76 typename com::ubuntu::location::units::Quantity<T>::value_type value;102 typename com::ubuntu::location::units::Quantity<T>::value_type value;
77 Codec<typename com::ubuntu::location::units::Quantity<T>::value_type>::decode_argument(out, value);103 Codec<typename com::ubuntu::location::units::Quantity<T>::value_type>::decode_argument(reader, value);
78 in = com::ubuntu::location::units::Quantity<T>::from_value(value);104 in = com::ubuntu::location::units::Quantity<T>::from_value(value);
79 dbus_message_iter_next(out);105 }
80 } 106};
81};
82
83namespace helper
84{
85template<typename T, typename U>
86struct TypeMapper<com::ubuntu::location::wgs84::Coordinate<T,U>>
87{
88 constexpr static ArgumentType type_value()
89 {
90 return ArgumentType::structure;
91 }
92 constexpr static bool is_basic_type()
93 {
94 return false;
95 }
96 constexpr static bool requires_signature()
97 {
98 return true;
99 }
100
101 static std::string signature()
102 {
103 static const std::string s =
104 DBUS_STRUCT_BEGIN_CHAR_AS_STRING +
105 TypeMapper<com::ubuntu::location::units::Quantity<U>>::signature() +
106 DBUS_STRUCT_END_CHAR_AS_STRING;
107 return s;
108 }
109};
110}
111107
112template<typename T, typename U>108template<typename T, typename U>
113struct Codec<com::ubuntu::location::wgs84::Coordinate<T,U>>109struct Codec<com::ubuntu::location::wgs84::Coordinate<T,U>>
114{110{
115 static void encode_argument(DBusMessageIter* out, const com::ubuntu::location::wgs84::Coordinate<T, U>& in)111 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::wgs84::Coordinate<T, U>& in)
116 {112 {
117 Codec<com::ubuntu::location::units::Quantity<U>>::encode_argument(out, in.value);113 Codec<com::ubuntu::location::units::Quantity<U>>::encode_argument(writer, in.value);
118 }114 }
119115
120 static void decode_argument(DBusMessageIter* out, com::ubuntu::location::wgs84::Coordinate<T, U>& in)116 static void decode_argument(Message::Reader& reader, com::ubuntu::location::wgs84::Coordinate<T, U>& in)
121 {117 {
122 Codec<com::ubuntu::location::units::Quantity<U>>::decode_argument(out, in.value);118 Codec<com::ubuntu::location::units::Quantity<U>>::decode_argument(reader, in.value);
123 } 119 }
124};120};
125
126namespace helper
127{
128template<>
129struct TypeMapper<com::ubuntu::location::Position>
130{
131 constexpr static ArgumentType type_value()
132 {
133 return ArgumentType::structure;
134 }
135 constexpr static bool is_basic_type()
136 {
137 return false;
138 }
139 constexpr static bool requires_signature()
140 {
141 return true;
142 }
143
144 static std::string signature()
145 {
146 static const std::string s =
147 TypeMapper<uint64_t>::signature() +
148 TypeMapper<com::ubuntu::location::wgs84::Latitude>::signature() +
149 TypeMapper<com::ubuntu::location::wgs84::Longitude>::signature() +
150 TypeMapper<com::ubuntu::location::wgs84::Altitude>::signature();
151 return s;
152 }
153};
154}
155121
156template<>122template<>
157struct Codec<com::ubuntu::location::Position>123struct Codec<com::ubuntu::location::Position>
158{124{
159 static void encode_argument(DBusMessageIter* out, const com::ubuntu::location::Position& in)125 typedef com::ubuntu::location::Position::Accuracy::Horizontal HorizontalAccuracy;
160 {126 typedef com::ubuntu::location::Position::Accuracy::Vertical VerticalAccuracy;
161 Codec<uint64_t>::encode_argument(out, in.flags().to_ulong());127
162 if (in.has_latitude())128 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Position& in)
163 Codec<com::ubuntu::location::wgs84::Latitude>::encode_argument(out, in.latitude());129 {
164 if (in.has_longitude())130 Codec<com::ubuntu::location::wgs84::Latitude>::encode_argument(writer, in.latitude);
165 Codec<com::ubuntu::location::wgs84::Longitude>::encode_argument(out, in.longitude());131 Codec<com::ubuntu::location::wgs84::Longitude>::encode_argument(writer, in.longitude);
166 if (in.has_altitude())132 Codec<com::ubuntu::location::Optional<com::ubuntu::location::wgs84::Altitude>>::encode_argument(writer, in.altitude);
167 Codec<com::ubuntu::location::wgs84::Altitude>::encode_argument(out, in.altitude());133
168 }134 Codec<com::ubuntu::location::Optional<HorizontalAccuracy>>::encode_argument(writer, in.accuracy.horizontal);
169135 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::encode_argument(writer, in.accuracy.vertical);
170 static void decode_argument(DBusMessageIter* out, com::ubuntu::location::Position& in)136 }
171 {137
172 com::ubuntu::location::wgs84::Latitude lat;138 static void decode_argument(Message::Reader& reader, com::ubuntu::location::Position& in)
173 com::ubuntu::location::wgs84::Longitude lon;139 {
174 com::ubuntu::location::wgs84::Altitude alt;140 Codec<com::ubuntu::location::wgs84::Latitude>::decode_argument(reader, in.latitude);
175 uint64_t flags_on_wire;141 Codec<com::ubuntu::location::wgs84::Longitude>::decode_argument(reader, in.longitude);
176 Codec<uint64_t>::decode_argument(out, flags_on_wire);142 Codec<com::ubuntu::location::Optional<com::ubuntu::location::wgs84::Altitude>>::decode_argument(reader, in.altitude);
177 dbus_message_iter_next(out);143
178144 Codec<com::ubuntu::location::Optional<HorizontalAccuracy>>::decode_argument(reader, in.accuracy.horizontal);
179 com::ubuntu::location::Position::Flags flags{flags_on_wire};145 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::decode_argument(reader, in.accuracy.vertical);
180 if (flags.test(com::ubuntu::location::Position::latitude_flag))146 }
181 {147};
182 Codec<com::ubuntu::location::wgs84::Latitude>::decode_argument(out, lat);148
183 in.latitude(lat);149
184 }150namespace helper
185 if (flags.test(com::ubuntu::location::Position::latitude_flag))151{
186 {152template<>
187 Codec<com::ubuntu::location::wgs84::Longitude>::decode_argument(out, lon);153struct TypeMapper<com::ubuntu::location::SpaceVehicle::Key>
188 in.longitude(lon);154{
189 }155 constexpr static ArgumentType type_value()
190 if (flags.test(com::ubuntu::location::Position::altitude_flag))156 {
191 { 157 return ArgumentType::structure;
192 Codec<com::ubuntu::location::wgs84::Altitude>::decode_argument(out, alt);158 }
193 in.altitude(alt);159 constexpr static bool is_basic_type()
194 }160 {
195 }161 return false;
196};162 }
197163 constexpr static bool requires_signature()
198namespace helper164 {
199{165 return true;
200template<>166 }
201struct TypeMapper<com::ubuntu::location::Velocity>167
202{168 static std::string signature()
203 constexpr static ArgumentType type_value()169 {
204 {170 static const std::string s =
205 return ArgumentType::structure;171 helper::TypeMapper<std::uint32_t>::signature() +
206 }172 helper::TypeMapper<std::uint32_t>::signature();
207 constexpr static bool is_basic_type()173 return s;
208 {174 }
209 return false;175};
210 }176template<>
211 constexpr static bool requires_signature()177struct TypeMapper<com::ubuntu::location::SpaceVehicle>
212 {178{
213 return true;179 constexpr static ArgumentType type_value()
214 }180 {
215181 return ArgumentType::structure;
216 static std::string signature()182 }
217 {183 constexpr static bool is_basic_type()
218 static const std::string s =184 {
219 DBUS_STRUCT_BEGIN_CHAR_AS_STRING +185 return false;
220 TypeMapper<typename com::ubuntu::location::Velocity::Quantity>::signature() +186 }
221 DBUS_STRUCT_END_CHAR_AS_STRING;187 constexpr static bool requires_signature()
222 return s;188 {
223 }189 return true;
224};190 }
225}191
226192 inline static std::string signature()
227template<>193 {
228struct Codec<com::ubuntu::location::Velocity>194 std::string s =
229{195 DBUS_STRUCT_BEGIN_CHAR_AS_STRING +
230 static void encode_argument(DBusMessageIter* out, const com::ubuntu::location::Velocity& in)196 helper::TypeMapper<com::ubuntu::location::SpaceVehicle::Key>::signature() +
231 {197 helper::TypeMapper<float>::signature() +
232 Codec<typename com::ubuntu::location::Velocity::Quantity>::encode_argument(out, in.value);198 helper::TypeMapper<bool>::signature() +
233 }199 helper::TypeMapper<bool>::signature() +
234200 helper::TypeMapper<bool>::signature() +
235 static void decode_argument(DBusMessageIter* out, com::ubuntu::location::Velocity& in)201 helper::TypeMapper<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +
236 {202 helper::TypeMapper<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +
237 Codec<typename com::ubuntu::location::Velocity::Quantity>::decode_argument(out, in.value);203 DBUS_STRUCT_END_CHAR_AS_STRING;
238 }204 return s;
239};205 }
240206};
241namespace helper207}
242{208
243template<>209template<>
244struct TypeMapper<com::ubuntu::location::Heading>210struct Codec<com::ubuntu::location::SpaceVehicle::Key>
245{211{
246 constexpr static ArgumentType type_value()212 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::SpaceVehicle::Key& in)
247 {213 {
248 return ArgumentType::structure;214 writer.push_uint32(static_cast<std::uint32_t>(in.type));
249 }215 writer.push_uint32(in.id);
250 constexpr static bool is_basic_type()216 }
251 {217
252 return false;218 static void decode_argument(Message::Reader& reader, com::ubuntu::location::SpaceVehicle::Key& in)
253 }219 {
254 constexpr static bool requires_signature()220 in.type = static_cast<com::ubuntu::location::SpaceVehicle::Type>(reader.pop_uint32());
255 {221 in.id = reader.pop_uint32();
256 return true;222 }
257 }223};
258224
259 static std::string signature()225template<>
260 {226struct Codec<com::ubuntu::location::SpaceVehicle>
261 static const std::string s =227{
262 DBUS_STRUCT_BEGIN_CHAR_AS_STRING +228 inline static void encode_argument(Message::Writer& writer, const com::ubuntu::location::SpaceVehicle& in)
263 TypeMapper<typename com::ubuntu::location::Heading::Quantity>::signature() +229 {
264 DBUS_STRUCT_END_CHAR_AS_STRING;230 auto sub = writer.open_structure();
265 return s;231
266 }232 Codec<com::ubuntu::location::SpaceVehicle::Key>::encode_argument(sub, in.key);
267};233 sub.push_floating_point(in.snr);
268}234 sub.push_boolean(in.has_almanac_data);
269235 sub.push_boolean(in.has_ephimeris_data);
270template<>236 sub.push_boolean(in.used_in_fix);
271struct Codec<com::ubuntu::location::Heading>237 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::encode_argument(sub, in.azimuth);
272{238 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::encode_argument(sub, in.elevation);
273 static void encode_argument(DBusMessageIter* out, const com::ubuntu::location::Heading& in)239
274 {240 writer.close_structure(std::move(sub));
275 Codec<typename com::ubuntu::location::Heading::Quantity>::encode_argument(out, in.value);241 }
276 }242
277243 inline static void decode_argument(Message::Reader& reader, com::ubuntu::location::SpaceVehicle& in)
278 static void decode_argument(DBusMessageIter* out, com::ubuntu::location::Heading& in)244 {
279 {245 auto sub = reader.pop_structure();
280 Codec<typename com::ubuntu::location::Heading::Quantity>::decode_argument(out, in.value);246
281 }247 Codec<com::ubuntu::location::SpaceVehicle::Key>::decode_argument(sub, in.key);
282};248 in.snr = sub.pop_floating_point();
283249 in.has_almanac_data = sub.pop_boolean();
284namespace helper250 in.has_ephimeris_data = sub.pop_boolean();
285{251 in.used_in_fix = sub.pop_boolean();
286template<typename T>252 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::decode_argument(sub, in.azimuth);
287struct TypeMapper<com::ubuntu::location::Accuracy<T>>253 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::decode_argument(sub, in.elevation);
288{254 }
289 constexpr static ArgumentType type_value()255};
290 {256
291 return ArgumentType::structure;257namespace helper
292 }258{
293 constexpr static bool is_basic_type()259template<>
294 {260struct TypeMapper<std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>>
295 return false;261{
296 }262 constexpr static ArgumentType type_value()
297 constexpr static bool requires_signature()263 {
298 {264 return ArgumentType::array;
299 return true;265 }
300 }266 constexpr static bool is_basic_type()
301267 {
302 static std::string signature()268 return false;
303 {269 }
304 static const std::string s =270 constexpr static bool requires_signature()
305 DBUS_STRUCT_BEGIN_CHAR_AS_STRING +271 {
306 TypeMapper<T>::signature() +272 return true;
307 DBUS_STRUCT_END_CHAR_AS_STRING;273 }
308 return s;274
309 }275 static std::string signature()
310};276 {
311}277 static const std::string s = DBUS_TYPE_ARRAY_AS_STRING + TypeMapper<com::ubuntu::location::SpaceVehicle>::signature();
312278 return s;
313template<typename T>279 }
314struct Codec<com::ubuntu::location::Accuracy<T>>280};
315{281}
316 static void encode_argument(DBusMessageIter* out, const com::ubuntu::location::Accuracy<T>& in)282template<>
317 {283struct Codec<std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>>
318 Codec<T>::encode_argument(out, in.value);284{
319 }285 inline static void encode_argument(Message::Writer& writer, const std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>& arg)
320286 {
321 static void decode_argument(DBusMessageIter* out, com::ubuntu::location::Accuracy<T>& in)287 types::Signature signature(helper::TypeMapper<com::ubuntu::location::SpaceVehicle>::signature());
322 {288 auto sub = writer.open_array(signature);
323 Codec<T>::decode_argument(out, in.value);289
324 } 290 for(const auto& element : arg)
325};291 {
326292 Codec<com::ubuntu::location::SpaceVehicle>::encode_argument(sub, element.second);
327namespace helper293 }
328{294
329template<>295 writer.close_array(std::move(sub));
330struct TypeMapper<com::ubuntu::location::Criteria>296 }
331{297
332 constexpr static ArgumentType type_value()298 inline static void decode_argument(Message::Reader& reader, std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>& out)
333 {299 {
334 return ArgumentType::structure;300 auto sub = reader.pop_array();
335 }301 while (sub.type() != ArgumentType::invalid)
336 constexpr static bool is_basic_type()302 {
337 {303 com::ubuntu::location::SpaceVehicle sv;
338 return false;304 Codec<com::ubuntu::location::SpaceVehicle>::decode_argument(sub, sv);
339 }305 out.insert(std::make_pair(sv.key, sv));
340 constexpr static bool requires_signature()306 }
341 {307 }
342 return true;308};
343 }
344
345 static std::string signature()
346 {
347 static const std::string s =
348 DBUS_STRUCT_BEGIN_CHAR_AS_STRING +
349 helper::TypeMapper<com::ubuntu::location::Accuracy<com::ubuntu::location::wgs84::Latitude>>::signature() +
350 helper::TypeMapper<com::ubuntu::location::Accuracy<com::ubuntu::location::wgs84::Longitude>>::signature() +
351 helper::TypeMapper<com::ubuntu::location::Accuracy<com::ubuntu::location::wgs84::Altitude>>::signature() +
352 helper::TypeMapper<com::ubuntu::location::Accuracy<com::ubuntu::location::Velocity>>::signature() +
353 helper::TypeMapper<com::ubuntu::location::Accuracy<com::ubuntu::location::Heading>>::signature() +
354 DBUS_STRUCT_END_CHAR_AS_STRING;
355 return s;
356 }
357};
358}
359309
360template<>310template<>
361struct Codec<com::ubuntu::location::Criteria>311struct Codec<com::ubuntu::location::Criteria>
362{312{
363 static void encode_argument(DBusMessageIter* out, const com::ubuntu::location::Criteria& in)313 typedef com::ubuntu::location::units::Quantity<com::ubuntu::location::units::Length> HorizontalAccuracy;
364 {314 typedef com::ubuntu::location::units::Quantity<com::ubuntu::location::units::Length> VerticalAccuracy;
365 Codec<com::ubuntu::location::Accuracy<com::ubuntu::location::wgs84::Latitude>>::encode_argument(out, in.latitude_accuracy);315 typedef com::ubuntu::location::units::Quantity<com::ubuntu::location::units::Velocity> VelocityAccuracy;
366 Codec<com::ubuntu::location::Accuracy<com::ubuntu::location::wgs84::Longitude>>::encode_argument(out, in.longitude_accuracy);316 typedef com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle> HeadingAccuracy;
367 Codec<com::ubuntu::location::Accuracy<com::ubuntu::location::wgs84::Altitude>>::encode_argument(out, in.altitude_accuracy);317
368 Codec<com::ubuntu::location::Accuracy<com::ubuntu::location::Velocity>>::encode_argument(out, in.velocity_accuracy);318 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Criteria& in)
369 Codec<com::ubuntu::location::Accuracy<com::ubuntu::location::Heading>>::encode_argument(out, in.heading_accuracy);319 {
370 }320 Codec<bool>::encode_argument(writer, in.requires.position);
371321 Codec<bool>::encode_argument(writer, in.requires.altitude);
372 static void decode_argument(DBusMessageIter* out, com::ubuntu::location::Criteria& in)322 Codec<bool>::encode_argument(writer, in.requires.heading);
373 {323 Codec<bool>::encode_argument(writer, in.requires.velocity);
374 Codec<com::ubuntu::location::Accuracy<com::ubuntu::location::wgs84::Latitude>>::decode_argument(out, in.latitude_accuracy);324
375 Codec<com::ubuntu::location::Accuracy<com::ubuntu::location::wgs84::Longitude>>::decode_argument(out, in.longitude_accuracy);325 Codec<HorizontalAccuracy>::encode_argument(writer, in.accuracy.horizontal);
376 Codec<com::ubuntu::location::Accuracy<com::ubuntu::location::wgs84::Altitude>>::decode_argument(out, in.altitude_accuracy);326 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::encode_argument(writer, in.accuracy.vertical);
377 Codec<com::ubuntu::location::Accuracy<com::ubuntu::location::Velocity>>::decode_argument(out, in.velocity_accuracy);327 Codec<com::ubuntu::location::Optional<VelocityAccuracy>>::encode_argument(writer, in.accuracy.velocity);
378 Codec<com::ubuntu::location::Accuracy<com::ubuntu::location::Heading>>::decode_argument(out, in.heading_accuracy);328 Codec<com::ubuntu::location::Optional<HeadingAccuracy>>::encode_argument(writer, in.accuracy.heading);
379 } 329 }
330
331 static void decode_argument(Message::Reader& reader, com::ubuntu::location::Criteria& in)
332 {
333 Codec<bool>::decode_argument(reader, in.requires.position);
334 Codec<bool>::decode_argument(reader, in.requires.altitude);
335 Codec<bool>::decode_argument(reader, in.requires.heading);
336 Codec<bool>::decode_argument(reader, in.requires.velocity);
337
338 Codec<HorizontalAccuracy>::decode_argument(reader, in.accuracy.horizontal);
339 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::decode_argument(reader, in.accuracy.vertical);
340 Codec<com::ubuntu::location::Optional<VelocityAccuracy>>::decode_argument(reader, in.accuracy.velocity);
341 Codec<com::ubuntu::location::Optional<HeadingAccuracy>>::decode_argument(reader, in.accuracy.heading);
342 }
380};343};
381namespace helper344namespace helper
382{345{
@@ -409,23 +372,19 @@
409template<typename T>372template<typename T>
410struct Codec<com::ubuntu::location::Update<T>>373struct Codec<com::ubuntu::location::Update<T>>
411{374{
412 static void encode_argument(DBusMessageIter* out, const com::ubuntu::location::Update<T>& in)375 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Update<T>& in)
413 {376 {
414 Codec<T>::encode_argument(out, in.value);377 Codec<T>::encode_argument(writer, in.value);
415 Codec<int64_t>::encode_argument(out, in.when.time_since_epoch().count());378 Codec<int64_t>::encode_argument(writer, in.when.time_since_epoch().count());
416 }379 }
417380
418 static void decode_argument(DBusMessageIter* out, com::ubuntu::location::Update<T>& in)381 static void decode_argument(Message::Reader& reader, com::ubuntu::location::Update<T>& in)
419 {382 {
420 Codec<T>::decode_argument(out, in.value);383 Codec<T>::decode_argument(reader, in.value);
421 int64_t value;384 in.when = com::ubuntu::location::Clock::Timestamp(com::ubuntu::location::Clock::Duration(reader.pop_int64()));
422 Codec<int64_t>::decode_argument(out, value);
423 dbus_message_iter_next(out);
424 in.when = com::ubuntu::location::Clock::Timestamp(com::ubuntu::location::Clock::Duration(value));
425 } 385 }
426};386};
427}387}
428}388}
429}
430389
431#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_390#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_
432391
=== added directory 'include/location_service/com/ubuntu/location/connectivity'
=== added file 'include/location_service/com/ubuntu/location/connectivity/bounded_integer.h'
--- include/location_service/com/ubuntu/location/connectivity/bounded_integer.h 1970-01-01 00:00:00 +0000
+++ include/location_service/com/ubuntu/location/connectivity/bounded_integer.h 2014-02-03 13:52:45 +0000
@@ -0,0 +1,184 @@
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_CONNECTIVITY_BOUNDED_INTEGER_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_BOUNDED_INTEGER_H_
20
21#include <iostream>
22#include <stdexcept>
23
24namespace com
25{
26namespace ubuntu
27{
28namespace location
29{
30namespace connectivity
31{
32/**
33 * @brief A helper class to handle bounded integer values, with an optional domain
34 * for tagging domain-specific types.
35 */
36template<int min, int max, int domain = 0>
37class BoundedInteger
38{
39public:
40 static_assert(min < max, "min >= max");
41
42 /**
43 * @brief Access the minimum value of the integer.
44 */
45 inline static int minimum()
46 {
47 return min;
48 }
49
50 /**
51 * @brief Access the maximum value of the integer.
52 */
53 inline static int maximum()
54 {
55 return max;
56 }
57
58 /**
59 * @brief Returns max - min.
60 */
61 inline static int range()
62 {
63 return max - min;
64 }
65
66 /**
67 * @brief Constructs an invalid instance.
68 */
69 BoundedInteger() : value(min-1)
70 {
71 }
72
73 /**
74 * @brief Constructs an instance from a raw value
75 * @param value The raw value.
76 * @throw std::runtime_error if value is not in [min, max].
77 */
78 explicit BoundedInteger(int value) : value(value)
79 {
80 if (value < min || value > max)
81 throw std::runtime_error(
82 std::to_string(value) + " is not in " + "[" +
83 std::to_string(min) + ", " + std::to_string(max) + "]");
84 }
85
86 /**
87 * @brief Copy c'tor.
88 * @param rhs The instance to copy from.
89 */
90 BoundedInteger(const BoundedInteger<min, max, domain>& rhs) : value(rhs.value)
91 {
92 }
93
94 /**
95 * @brief Assignment operator.
96 * @param rhs The instance to assign from.
97 * @return A mutable reference to this instance.
98 */
99 BoundedInteger<min, max, domain>& operator=(const BoundedInteger<min, max, domain>& rhs)
100 {
101 value = rhs.value;
102 return *this;
103 }
104
105 /**
106 * @brief Equality comparison operator.
107 * @param rhs The instance to compare to.
108 * @return true iff both instances' value are equal.
109 */
110 bool operator==(const BoundedInteger<min, max, domain>& rhs) const
111 {
112 return value == rhs.value;
113 }
114
115 /**
116 * @brief Implicit casting operator to a raw integer value.
117 * @return The raw integer value.
118 */
119 inline operator int() const
120 {
121 return get();
122 }
123
124 /**
125 * @brief is_valid checks whether the contained value is in [min, max].
126 * @return true iff the contained integer value is in [min, max].
127 */
128 inline bool is_valid() const
129 {
130 return min <= value && value <= max;
131 }
132
133 /**
134 * @brief Returns the raw integer value contained in this instance.
135 * @throw std::runtime_error if is_valid() returns false.
136 */
137 inline int get() const
138 {
139 if (!is_valid())
140 throw std::runtime_error("BoundedInteger::get: Contained value is not valid.");
141
142 return value;
143 }
144
145 /**
146 * @brief Assigns a new raw integer value
147 * @param new_value The new value.
148 * @throw std::runtime_error if new_value is not in [min, max].
149 */
150 inline void set(int new_value)
151 {
152 if (new_value < min || new_value > max)
153 throw std::runtime_error(
154 std::to_string(new_value) + " is not in " + "[" +
155 std::to_string(min) + ", " + std::to_string(max) + "]");
156
157 value = new_value;
158 }
159
160 /**
161 * @brief operator << pretty prints an instance of BoundedInteger.
162 * @param out The stream to print to.
163 * @param bi The instance to print.
164 * @return The stream that has been printed to.
165 */
166 inline friend std::ostream& operator<<(std::ostream& out, const BoundedInteger<min, max, domain>& bi)
167 {
168 out << bi.value;
169
170 if (!bi.is_valid())
171 out << " -> invalid";
172
173 return out;
174 }
175
176private:
177 int value;
178};
179}
180}
181}
182}
183
184#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_BOUNDED_INTEGER_H_
0185
=== added file 'include/location_service/com/ubuntu/location/connectivity/manager.h'
--- include/location_service/com/ubuntu/location/connectivity/manager.h 1970-01-01 00:00:00 +0000
+++ include/location_service/com/ubuntu/location/connectivity/manager.h 2014-02-03 13:52:45 +0000
@@ -0,0 +1,93 @@
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_CONNECTIVITY_MANAGER_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_MANAGER_H_
20
21#include <com/ubuntu/location/connectivity/radio_cell.h>
22#include <com/ubuntu/location/connectivity/wireless_network.h>
23
24#include <core/property.h>
25
26#include <string>
27#include <vector>
28
29namespace com
30{
31namespace ubuntu
32{
33namespace location
34{
35namespace connectivity
36{
37/**
38 * @brief The Manager class encapsulates access to network/radio information
39 */
40class Manager
41{
42public:
43 struct Errors
44 {
45 Errors() = delete;
46 /**
47 * @brief The ConnectivityManagementNotSupported struct is thrown if underlying
48 * platform does not provide support for connectivity mgmt.
49 */
50 struct ConnectivityManagementNotSupported : public std::runtime_error
51 {
52 ConnectivityManagementNotSupported()
53 : std::runtime_error(
54 "Underlying platform does not provide support for connectivity mgmt.")
55 {
56 }
57 };
58 };
59
60 Manager(const Manager& rhs) = delete;
61 virtual ~Manager() = default;
62
63 Manager& operator=(const Manager& rhs) = delete;
64 bool operator==(const Manager& rhs) const = delete;
65
66 /**
67 * @brief All wireless networks visible to the device.
68 * @return A getable/observable property carrying the visible wireless networks.
69 */
70 virtual const core::Property<std::vector<WirelessNetwork>>& visible_wireless_networks() = 0;
71
72 /**
73 * @brief All radio cells visible to the device.
74 * @return A getable/observable property carrying the visible radio cells.
75 */
76 virtual const core::Property<std::vector<RadioCell>>& visible_radio_cells() = 0;
77
78protected:
79 Manager() = default;
80};
81
82/**
83 * @brief Provides access to a platform-specific implementation/instance of a connectivity manager.
84 * @throw Manager::Errors::ConnectivityManagementNotSupported.
85 * @return An instance of a connectivity manager.
86 */
87const std::shared_ptr<Manager>& platform_default_manager();
88}
89}
90}
91}
92
93#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_MANAGER_H_
094
=== added file 'include/location_service/com/ubuntu/location/connectivity/radio_cell.h'
--- include/location_service/com/ubuntu/location/connectivity/radio_cell.h 1970-01-01 00:00:00 +0000
+++ include/location_service/com/ubuntu/location/connectivity/radio_cell.h 2014-02-03 13:52:45 +0000
@@ -0,0 +1,400 @@
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_CONNECTIVITY_RADIO_CELL_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_RADIO_CELL_H_
20
21#include <com/ubuntu/location/connectivity/bounded_integer.h>
22
23namespace com
24{
25namespace ubuntu
26{
27namespace location
28{
29namespace connectivity
30{
31class RadioCell
32{
33public:
34 enum class Type
35 {
36 unknown,
37 gsm,
38 umts,
39 cdma,
40 lte
41 };
42
43 enum class Domain
44 {
45 mcc,
46 mnc,
47 lac,
48 id,
49 pid,
50 rss,
51 asu,
52 ta
53 };
54
55 template<int min, int max>
56 using MobileCountryCode = BoundedInteger<min, max, static_cast<int>(Domain::mcc)>;
57 template<int min, int max>
58 using MobileNetworkCode = BoundedInteger<min, max, static_cast<int>(Domain::mnc)>;
59 template<int min, int max>
60 using LocationAreaCode = BoundedInteger<min, max, static_cast<int>(Domain::lac)>;
61 template<int min, int max>
62 using CellId = BoundedInteger<min, max, static_cast<int>(Domain::id)>;
63 template<int min, int max>
64 using PhysicalId = BoundedInteger<min, max, static_cast<int>(Domain::pid)>;
65 template<int min, int max>
66 using ReceivedSignalStrength = BoundedInteger<min, max, static_cast<int>(Domain::rss)>;
67 template<int min, int max>
68 using ArbitraryStrengthUnit = BoundedInteger<min, max, static_cast<int>(Domain::asu)>;
69 template<int min, int max>
70 using TimingAdvance = BoundedInteger<min, max, static_cast<int>(Domain::ta)>;
71
72 struct Gsm
73 {
74 typedef MobileCountryCode<0,999> MCC;
75 typedef MobileNetworkCode<0,999> MNC;
76 typedef LocationAreaCode<0,65535> LAC;
77 typedef CellId<0,65535> ID;
78 typedef ReceivedSignalStrength<-113,-51> RSS;
79 typedef ArbitraryStrengthUnit<0,31> ASU;
80 typedef TimingAdvance<0,63> TA;
81
82 bool operator==(const Gsm& rhs) const
83 {
84 return mobile_country_code == rhs.mobile_country_code &&
85 mobile_network_code == rhs.mobile_network_code &&
86 location_area_code == rhs.location_area_code &&
87 id == rhs.id &&
88 received_signal_strength == rhs.received_signal_strength &&
89 arbitrary_strength_unit == rhs.arbitrary_strength_unit &&
90 timing_advance == rhs.timing_advance;
91 }
92
93 inline friend std::ostream& operator<<(std::ostream& out, const Gsm& gsm)
94 {
95 out << "("
96 << "mcc: " << gsm.mobile_country_code << ", "
97 << "mnc: " << gsm.mobile_network_code << ", "
98 << "lac: " << gsm.location_area_code << ", "
99 << "id: " << gsm.id << ", "
100 << "rss: " << gsm.received_signal_strength << ", "
101 << "asu: " << gsm.arbitrary_strength_unit << ", "
102 << "ta: " << gsm.timing_advance << ")";
103
104 return out;
105 }
106
107 MCC mobile_country_code;
108 MNC mobile_network_code;
109 LAC location_area_code;
110 ID id;
111 RSS received_signal_strength;
112 ASU arbitrary_strength_unit;
113 TA timing_advance;
114 };
115
116 struct Umts
117 {
118 typedef MobileCountryCode<0,999> MCC;
119 typedef MobileNetworkCode<0,999> MNC;
120 typedef LocationAreaCode<0,65535> LAC;
121 typedef CellId<0,268435455> ID;
122 typedef ReceivedSignalStrength<-121,-25> RSS;
123 typedef ArbitraryStrengthUnit<-5,91> ASU;
124
125 bool operator==(const Umts& rhs) const
126 {
127 return mobile_country_code == rhs.mobile_country_code &&
128 mobile_network_code == rhs.mobile_network_code &&
129 location_area_code == rhs.location_area_code &&
130 id == rhs.id &&
131 received_signal_strength == rhs.received_signal_strength &&
132 arbitrary_strength_unit == rhs.arbitrary_strength_unit;
133 }
134
135 inline friend std::ostream& operator<<(std::ostream& out, const Umts& umts)
136 {
137 out << "("
138 << "mcc: " << umts.mobile_country_code << ", "
139 << "mnc: " << umts.mobile_network_code << ", "
140 << "lac: " << umts.location_area_code << ", "
141 << "id: " << umts.id << ", "
142 << "rss: " << umts.received_signal_strength << ", "
143 << "asu: " << umts.arbitrary_strength_unit << ")";
144
145 return out;
146 }
147 MCC mobile_country_code;
148 MNC mobile_network_code;
149 LAC location_area_code;
150 ID id;
151 RSS received_signal_strength;
152 ASU arbitrary_strength_unit;
153 };
154
155 struct Cdma
156 {
157 typedef MobileCountryCode<0,999> MCC;
158 typedef MobileNetworkCode<0,32767> MNC;
159 typedef LocationAreaCode<0,65535> LAC;
160 typedef CellId<0,65535> ID;
161 typedef ReceivedSignalStrength<-100,-75> RSS;
162 typedef ArbitraryStrengthUnit<1,16> ASU;
163
164 bool operator==(const Cdma& rhs) const
165 {
166 return mobile_country_code == rhs.mobile_country_code &&
167 mobile_network_code == rhs.mobile_network_code &&
168 location_area_code == rhs.location_area_code &&
169 id == rhs.id &&
170 received_signal_strength == rhs.received_signal_strength &&
171 arbitrary_strength_unit == rhs.arbitrary_strength_unit;
172 }
173
174 inline friend std::ostream& operator<<(std::ostream& out, const Cdma& cdma)
175 {
176 out << "("
177 << "mcc: " << cdma.mobile_country_code << ", "
178 << "mnc: " << cdma.mobile_network_code << ", "
179 << "lac: " << cdma.location_area_code << ", "
180 << "id: " << cdma.id << ", "
181 << "rss: " << cdma.received_signal_strength << ", "
182 << "asu: " << cdma.arbitrary_strength_unit << ")";
183
184 return out;
185 }
186
187 MCC mobile_country_code;
188 MNC mobile_network_code;
189 LAC location_area_code;
190 ID id;
191 RSS received_signal_strength;
192 ASU arbitrary_strength_unit;
193 };
194
195 struct Lte
196 {
197 typedef MobileCountryCode<0,999> MCC;
198 typedef MobileNetworkCode<0,32767> MNC;
199 typedef LocationAreaCode<0,65535> LAC;
200 typedef CellId<0,268435455> ID;
201 typedef PhysicalId<0,503> PID;
202 typedef ReceivedSignalStrength<-137,-45> RSS;
203 typedef ArbitraryStrengthUnit<0,95> ASU;
204 typedef TimingAdvance<0,63> TA;
205
206 bool operator==(const Lte& rhs) const
207 {
208 return mobile_country_code == rhs.mobile_country_code &&
209 mobile_network_code == rhs.mobile_network_code &&
210 location_area_code == rhs.location_area_code &&
211 id == rhs.id &&
212 physical_id == rhs.physical_id &&
213 received_signal_strength == rhs.received_signal_strength &&
214 arbitrary_strength_unit == rhs.arbitrary_strength_unit &&
215 timing_advance == rhs.timing_advance;
216 }
217
218 inline friend std::ostream& operator<<(std::ostream& out, const Lte& lte)
219 {
220 out << "("
221 << "mcc: " << lte.mobile_country_code << ", "
222 << "mnc: " << lte.mobile_network_code << ", "
223 << "lac: " << lte.location_area_code << ", "
224 << "id: " << lte.id << ", "
225 << "id: " << lte.physical_id << ", "
226 << "rss: " << lte.received_signal_strength << ", "
227 << "asu: " << lte.arbitrary_strength_unit << ", "
228 << "ta: " << lte.timing_advance << ")";
229
230 return out;
231 }
232
233 MCC mobile_country_code;
234 MNC mobile_network_code;
235 LAC location_area_code;
236 ID id;
237 PID physical_id;
238 RSS received_signal_strength;
239 ASU arbitrary_strength_unit;
240 TA timing_advance;
241 };
242
243 RadioCell() : radio_type(Type::gsm), detail{Gsm()}
244 {
245 }
246
247 explicit RadioCell(const Gsm& gsm)
248 : radio_type(Type::gsm), detail{gsm}
249 {
250 }
251
252 explicit RadioCell(const Umts& umts)
253 : radio_type(Type::umts), detail{umts}
254 {
255 }
256
257 explicit RadioCell(const Cdma& cdma)
258 : radio_type(Type::cdma), detail{cdma}
259 {
260 }
261
262 explicit RadioCell(const Lte& lte)
263 : radio_type(Type::lte), detail{lte}
264 {
265 }
266
267 RadioCell(const RadioCell& rhs) : radio_type(rhs.radio_type)
268 {
269 switch(radio_type)
270 {
271 case Type::gsm: detail.gsm = rhs.detail.gsm; break;
272 case Type::cdma: detail.cdma = rhs.detail.cdma; break;
273 case Type::umts: detail.umts = rhs.detail.umts; break;
274 case Type::lte: detail.lte = rhs.detail.lte; break;
275 case Type::unknown: break;
276 }
277 }
278
279 RadioCell& operator=(const RadioCell& rhs)
280 {
281 radio_type = rhs.radio_type;
282 switch(radio_type)
283 {
284 case Type::gsm: detail.gsm = rhs.detail.gsm; break;
285 case Type::cdma: detail.cdma = rhs.detail.cdma; break;
286 case Type::umts: detail.umts = rhs.detail.umts; break;
287 case Type::lte: detail.lte = rhs.detail.lte; break;
288 case Type::unknown: break;
289 }
290
291 return *this;
292 }
293
294 bool operator==(const RadioCell& rhs) const
295 {
296 if (radio_type != rhs.radio_type)
297 return false;
298
299 switch(radio_type)
300 {
301 case Type::gsm: return detail.gsm == rhs.detail.gsm;
302 case Type::cdma: return detail.cdma == rhs.detail.cdma;
303 case Type::umts: return detail.umts == rhs.detail.umts;
304 case Type::lte: return detail.lte == rhs.detail.lte;
305 default: return true;
306 }
307
308 return false;
309 }
310
311 Type type() const
312 {
313 return radio_type;
314 }
315
316 const Gsm& gsm() const
317 {
318 if (radio_type != Type::gsm)
319 throw std::runtime_error("Bad access to unset network type.");
320
321 return detail.gsm;
322 }
323
324 const Umts& umts() const
325 {
326 if (radio_type != Type::umts)
327 throw std::runtime_error("Bad access to unset network type.");
328
329 return detail.umts;
330 }
331
332 const Cdma& cdma() const
333 {
334 if (radio_type != Type::cdma)
335 throw std::runtime_error("Bad access to unset network type.");
336
337 return detail.cdma;
338 }
339
340 const Lte& lte() const
341 {
342 if (radio_type != Type::lte)
343 throw std::runtime_error("Bad access to unset network type.");
344
345 return detail.lte;
346 }
347
348 inline friend std::ostream& operator<<(std::ostream& out, const RadioCell& cell)
349 {
350 switch (cell.radio_type)
351 {
352 case RadioCell::Type::gsm: out << cell.detail.gsm; break;
353 case RadioCell::Type::cdma: out << cell.detail.cdma; break;
354 case RadioCell::Type::umts: out << cell.detail.umts; break;
355 case RadioCell::Type::lte: out << cell.detail.lte; break;
356 case RadioCell::Type::unknown: break;
357 }
358
359 return out;
360 }
361
362private:
363 Type radio_type;
364
365 struct None {};
366 union Detail
367 {
368 inline Detail() : none(None{})
369 {
370 }
371
372 inline explicit Detail(const Gsm& gsm) : gsm(gsm)
373 {
374 }
375
376 inline explicit Detail(const Umts& umts) : umts(umts)
377 {
378 }
379
380 inline explicit Detail(const Cdma& cdma) : cdma(cdma)
381 {
382 }
383
384 inline explicit Detail(const Lte& lte) : lte(lte)
385 {
386 }
387 None none;
388 Gsm gsm;
389 Umts umts;
390 Cdma cdma;
391 Lte lte;
392 } detail;
393};
394}
395}
396}
397}
398
399#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_RADIO_CELL_H_
400
0401
=== added file 'include/location_service/com/ubuntu/location/connectivity/wireless_network.h'
--- include/location_service/com/ubuntu/location/connectivity/wireless_network.h 1970-01-01 00:00:00 +0000
+++ include/location_service/com/ubuntu/location/connectivity/wireless_network.h 2014-02-03 13:52:45 +0000
@@ -0,0 +1,71 @@
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_CONNECTIVITY_WIRELESS_NETWORK_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_WIRELESS_NETWORK_H_
20
21#include <com/ubuntu/location/connectivity/bounded_integer.h>
22
23#include <string>
24
25namespace com
26{
27namespace ubuntu
28{
29namespace location
30{
31namespace connectivity
32{
33struct WirelessNetwork
34{
35 enum class Domain
36 {
37 frequency,
38 channel
39 };
40
41 typedef BoundedInteger<2412, 5825, static_cast<int>(Domain::frequency)> Frequency;
42 typedef BoundedInteger<1, 165, static_cast<int>(Domain::channel)> Channel;
43
44 bool operator==(const WirelessNetwork& rhs) const
45 {
46 return bssid == rhs.bssid &&
47 frequency == rhs.frequency &&
48 channel == rhs.channel &&
49 snr == rhs.snr;
50 }
51
52 friend std::ostream& operator<<(std::ostream& out, const WirelessNetwork& wifi)
53 {
54 return out << "("
55 << "bssid: " << wifi.bssid << ", "
56 << "frequency: " << wifi.frequency << ", "
57 << "channel: " << wifi.channel << ", "
58 << "snr: " << wifi.snr << ")";
59 }
60
61 std::string bssid; ///< The BSSID of the network.
62 Frequency frequency; ///< Frequency of the network/AP.
63 Channel channel; ///< Channel of the network/AP.
64 float snr; ///< Signal-noise ratio of the specific network.
65};
66}
67}
68}
69}
70
71#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_WIRELESS_NETWORK_H_
072
=== modified file 'include/location_service/com/ubuntu/location/criteria.h'
--- include/location_service/com/ubuntu/location/criteria.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/criteria.h 2014-02-03 13:52:45 +0000
@@ -18,16 +18,8 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CRITERIA_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CRITERIA_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CRITERIA_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CRITERIA_H_
2020
21#include "com/ubuntu/location/accuracy.h"21#include <com/ubuntu/location/optional.h>
22#include "com/ubuntu/location/heading.h"22#include <com/ubuntu/location/units/units.h>
23#include "com/ubuntu/location/velocity.h"
24#include "com/ubuntu/location/wgs84/altitude.h"
25#include "com/ubuntu/location/wgs84/latitude.h"
26#include "com/ubuntu/location/wgs84/longitude.h"
27
28#include <limits>
29#include <ostream>
30#include <stdexcept>
3123
32namespace com24namespace com
33{25{
@@ -35,22 +27,40 @@
35{27{
36namespace location28namespace location
37{29{
30/**
31 * @brief Summarizes criteria of a client session with respect to functionality
32 * and accuracy for position, velocity and heading measurements.
33 */
38struct Criteria34struct Criteria
39{35{
40 Criteria() : latitude_accuracy(),36 /**
41 longitude_accuracy(),37 * @brief satisfies checks whether this instance also satisfies another criteria instance.
42 altitude_accuracy(),38 * @param rhs The other criteria instance
43 velocity_accuracy(),39 * @return true iff this instance also satisfies the other instance, else false.
44 heading_accuracy()40 */
45 {41 bool satisfies(const Criteria& rhs) const;
46 }42
47 43 struct Requires
48 Accuracy<wgs84::Latitude> latitude_accuracy;44 {
49 Accuracy<wgs84::Longitude> longitude_accuracy;45 bool position = true; ///< The client needs position measurements.
50 Accuracy<wgs84::Altitude> altitude_accuracy;46 bool altitude = false; ///< The client needs altitude measurements.
51 Accuracy<Velocity> velocity_accuracy;47 bool velocity = false; ///< The client needs velocity measurments.
52 Accuracy<Heading> heading_accuracy;48 bool heading = false; ///< The client needs heading measurements.
49 } requires = Requires{};
50
51 struct Accuracy
52 {
53 units::Quantity<units::Length> horizontal = 3000 * units::Meters; ///< The client requires measurements of at least this horizontal accuracy.
54 Optional<units::Quantity<units::Length>> vertical; ///< The client requires measurements of at least this vertical accuracy.
55 Optional<units::Quantity<units::Velocity>> velocity; ///< The client requires measurements of at least this velocity accuracy.
56 Optional<units::Quantity<units::PlaneAngle>> heading; ///< The client requires measurements of at least this heading accuracy.
57 } accuracy = Accuracy{};
53};58};
59
60/**
61 * @brief operator + merges lhs and rhs such that satisfying the new criteria satisfies lhs and rhs.
62 */
63Criteria operator+(const Criteria& lhs, const Criteria& rhs);
54}64}
55}65}
56}66}
5767
=== modified file 'include/location_service/com/ubuntu/location/default_provider_selection_policy.h'
--- include/location_service/com/ubuntu/location/default_provider_selection_policy.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/default_provider_selection_policy.h 2014-02-03 13:52:45 +0000
@@ -18,7 +18,7 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_DEFAULT_PROVIDER_SELECTION_POLICY_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_DEFAULT_PROVIDER_SELECTION_POLICY_H_
19#define LOCATION_SERVICE_COM_UBUNTU_DEFAULT_PROVIDER_SELECTION_POLICY_H_19#define LOCATION_SERVICE_COM_UBUNTU_DEFAULT_PROVIDER_SELECTION_POLICY_H_
2020
21#include "com/ubuntu/location/provider_selection_policy.h"21#include <com/ubuntu/location/provider_selection_policy.h>
2222
23namespace com23namespace com
24{24{
@@ -32,21 +32,21 @@
32 DefaultProviderSelectionPolicy();32 DefaultProviderSelectionPolicy();
33 ~DefaultProviderSelectionPolicy() noexcept;33 ~DefaultProviderSelectionPolicy() noexcept;
34 34
35 ProviderSelection determine_provider_selection_from_set_for_criteria(35 ProviderSelection determine_provider_selection_for_criteria(
36 const Criteria& criteria,36 const Criteria& criteria,
37 const std::set<Provider::Ptr>& providers);37 const ProviderEnumerator& enumerator);
3838
39 Provider::Ptr determine_position_updates_provider(39 Provider::Ptr determine_position_updates_provider(
40 const Criteria& criteria,40 const Criteria& criteria,
41 const std::set<Provider::Ptr>& providers);41 const ProviderEnumerator& enumerator);
4242
43 Provider::Ptr determine_heading_updates_provider(43 Provider::Ptr determine_heading_updates_provider(
44 const Criteria& criteria,44 const Criteria& criteria,
45 const std::set<Provider::Ptr>& providers);45 const ProviderEnumerator& enumerator);
4646
47 Provider::Ptr determine_velocity_updates_provider(47 Provider::Ptr determine_velocity_updates_provider(
48 const Criteria& criteria,48 const Criteria& criteria,
49 const std::set<Provider::Ptr>& providers);49 const ProviderEnumerator& enumerator);
50};50};
51}51}
52}52}
5353
=== modified file 'include/location_service/com/ubuntu/location/engine.h'
--- include/location_service/com/ubuntu/location/engine.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/engine.h 2014-02-03 13:52:45 +0000
@@ -18,10 +18,16 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_ENGINE_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_ENGINE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_ENGINE_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_ENGINE_H_
2020
21#include "com/ubuntu/location/criteria.h"21#include <com/ubuntu/location/provider.h>
22#include "com/ubuntu/location/provider.h"22#include <com/ubuntu/location/provider_enumerator.h>
23#include "com/ubuntu/location/provider_selection_policy.h"23#include <com/ubuntu/location/provider_selection.h>
2424#include <com/ubuntu/location/satellite_based_positioning_state.h>
25#include <com/ubuntu/location/space_vehicle.h>
26#include <com/ubuntu/location/wifi_and_cell_reporting_state.h>
27
28#include <core/property.h>
29
30#include <mutex>
25#include <set>31#include <set>
2632
27namespace com33namespace com
@@ -30,26 +36,116 @@
30{36{
31namespace location37namespace location
32{38{
33class Engine39struct Criteria;
40class ProviderSelectionPolicy;
41/**
42 * @brief The Engine class encapsulates a positioning engine, relying on a set
43 * of providers and reporters to acquire and publish location information.
44 */
45class Engine : public ProviderEnumerator
34{46{
35public:47public:
36 typedef std::shared_ptr<Engine> Ptr;48 typedef std::shared_ptr<Engine> Ptr;
3749
38 Engine(const std::set<Provider::Ptr>& initial_providers,50 /**
39 const ProviderSelectionPolicy::Ptr& provider_selection_policy);51 * @brief The State enum models the current state of the engine
52 */
53 enum class Status
54 {
55 off, ///< The engine is currently offline.
56 on, ///< The engine and providers are powered on but not navigating.
57 active ///< The engine and providers are powered on and navigating.
58 };
59
60 /**
61 * @brief The Configuration struct summarizes the state of the engine.
62 */
63 struct Configuration
64 {
65 /** Setable/getable/observable property for the satellite based positioning state. */
66 core::Property<SatelliteBasedPositioningState> satellite_based_positioning_state
67 {
68 SatelliteBasedPositioningState::on
69 };
70 /** Setable/getable/observable property for the satellite based positioning state. */
71 core::Property<WifiAndCellIdReportingState> wifi_and_cell_id_reporting_state
72 {
73 WifiAndCellIdReportingState::off
74 };
75 /** Setable/getable/observable property for the overall engine state. */
76 core::Property<Engine::Status> engine_state
77 {
78 Engine::Status::on
79 };
80 };
81
82 struct Updates
83 {
84 /** The current best known reference location */
85 core::Property<Update<Position>> reference_location{};
86 /** The current best known velocity estimate. */
87 core::Property<Update<Velocity>> reference_velocity{};
88 /** The current best known heading estimate. */
89 core::Property<Update<Heading>> reference_heading{};
90 /** The current set of visible SpaceVehicles. */
91 core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>> visible_space_vehicles{};
92 };
93
94 Engine(const std::shared_ptr<ProviderSelectionPolicy>& provider_selection_policy);
40 Engine(const Engine&) = delete;95 Engine(const Engine&) = delete;
41 Engine& operator=(const Engine&) = delete;96 Engine& operator=(const Engine&) = delete;
42 virtual ~Engine() = default;97 virtual ~Engine() = default;
4398
99 /**
100 * @brief Calculates a set of providers that satisfies the given criteria.
101 * @param [in] criteria The criteria to be satisfied by the returned provider selection.
102 * @return A provider selection that satisfies the given criteria.
103 */
44 virtual ProviderSelection determine_provider_selection_for_criteria(const Criteria& criteria);104 virtual ProviderSelection determine_provider_selection_for_criteria(const Criteria& criteria);
45105
106 /**
107 * @brief Checks if the engine knows about a specific provider.
108 * @return True iff the engine knows about the provider.
109 */
46 virtual bool has_provider(const Provider::Ptr& provider) noexcept;110 virtual bool has_provider(const Provider::Ptr& provider) noexcept;
111
112 /**
113 * @brief Makes a provider known to the engine.
114 * @param provider The new provider.
115 */
47 virtual void add_provider(const Provider::Ptr& provider);116 virtual void add_provider(const Provider::Ptr& provider);
117
118 /**
119 * @brief Removes a provider from the engine.
120 * @param provider The provider to be removed.
121 */
48 virtual void remove_provider(const Provider::Ptr& provider) noexcept;122 virtual void remove_provider(const Provider::Ptr& provider) noexcept;
49123
124 /**
125 * @brief Iterates all known providers and invokes the provided enumerator for each of them.
126 * @param enumerator The functor to be invoked for each provider.
127 */
128 virtual void for_each_provider(const std::function<void(const Provider::Ptr&)>& enumerator) const noexcept;
129
130 /** The engine's configuration. */
131 Configuration configuration;
132
133 /** All updates distributed via the engine. */
134 Updates updates;
135
50private:136private:
51 std::set<Provider::Ptr> providers;137 struct ProviderConnections
52 ProviderSelectionPolicy::Ptr provider_selection_policy;138 {
139 core::ScopedConnection reference_location_updates;
140 core::ScopedConnection reference_velocity_updates;
141 core::ScopedConnection reference_heading_updates;
142 core::ScopedConnection wifi_and_cell_id_reporting_state_updates;
143 core::ScopedConnection space_vehicle_visibility_updates;
144 };
145
146 mutable std::mutex guard;
147 std::map<Provider::Ptr, ProviderConnections> providers;
148 std::shared_ptr<ProviderSelectionPolicy> provider_selection_policy;
53};149};
54}150}
55}151}
56152
=== modified file 'include/location_service/com/ubuntu/location/heading.h'
--- include/location_service/com/ubuntu/location/heading.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/heading.h 2014-02-03 13:52:45 +0000
@@ -18,12 +18,7 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_
2020
21#include "com/ubuntu/location/accuracy.h"21#include <com/ubuntu/location/units/units.h>
22#include "com/ubuntu/location/units/units.h"
23
24#include <limits>
25#include <ostream>
26#include <stdexcept>
2722
28namespace com23namespace com
29{24{
@@ -31,74 +26,8 @@
31{26{
32namespace location27namespace location
33{28{
34struct Heading29/** Heading is measured in ° deviation from true north. */
35{30typedef units::Quantity<units::PlaneAngle> Heading;
36 typedef units::PlaneAngle Unit;
37 typedef units::Quantity<Unit> Quantity;
38
39 static const Quantity& min()
40 {
41 static const auto instance = Heading::Quantity::from_value(0.);
42 return instance;
43 }
44 static const Quantity& max()
45 {
46 static const auto instance = Heading::Quantity::from_value(360.);
47 return instance;
48 }
49
50 Heading(const Quantity& value = Quantity()) : value(value)
51 {
52 if (value < min())
53 throw std::out_of_range("");
54 if (value > max())
55 throw std::out_of_range("");
56 }
57
58 bool operator==(const Heading& rhs) const
59 {
60 return value == rhs.value;
61 }
62
63 bool operator!=(const Heading& rhs) const
64 {
65 return value != rhs.value;
66 }
67
68 Quantity value;
69};
70
71inline std::ostream& operator<<(std::ostream& out, const Heading& heading)
72{
73 out << "Heading(" << heading.value << ")";
74 return out;
75}
76
77template<>
78struct AccuracyTraits<Heading>
79{
80 static AccuracyLevel classify(const Heading& h)
81 {
82 static const auto half = 0.5 * Heading::max();
83 if(h.value > half)
84 return AccuracyLevel::worst;
85
86 if(h.value < half)
87 return AccuracyLevel::best;
88
89 return AccuracyLevel::worst;
90 }
91
92 static Accuracy<Heading> best()
93 {
94 return Accuracy<Heading>{Heading{Heading::min()}};
95 }
96
97 static Accuracy<Heading> worst()
98 {
99 return Accuracy<Heading>{Heading{Heading::max()}};
100 }
101};
102}31}
103}32}
104}33}
10534
=== added file 'include/location_service/com/ubuntu/location/optional.h'
--- include/location_service/com/ubuntu/location/optional.h 1970-01-01 00:00:00 +0000
+++ include/location_service/com/ubuntu/location/optional.h 2014-02-03 13:52:45 +0000
@@ -0,0 +1,35 @@
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_OPTIONAL_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_OPTIONAL_H_
20
21#include <boost/optional.hpp>
22
23namespace com
24{
25namespace ubuntu
26{
27namespace location
28{
29template<typename T>
30using Optional = boost::optional<T>;
31}
32}
33}
34
35#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_OPTIONAL_H_
036
=== modified file 'include/location_service/com/ubuntu/location/position.h'
--- include/location_service/com/ubuntu/location/position.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/position.h 2014-02-03 13:52:45 +0000
@@ -18,9 +18,11 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_POSITION_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_POSITION_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_POSITION_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_POSITION_H_
2020
21#include "com/ubuntu/location/wgs84/altitude.h"21#include <com/ubuntu/location/wgs84/altitude.h>
22#include "com/ubuntu/location/wgs84/latitude.h"22#include <com/ubuntu/location/wgs84/latitude.h>
23#include "com/ubuntu/location/wgs84/longitude.h"23#include <com/ubuntu/location/wgs84/longitude.h>
24
25#include <com/ubuntu/location/optional.h>
2426
25#include <bitset>27#include <bitset>
26#include <ostream>28#include <ostream>
@@ -31,54 +33,30 @@
31{33{
32namespace location34namespace location
33{35{
34class Position36/**
37 * @brief The Position struct models a position in the wgs84 coordinate system.
38 */
39struct Position
35{40{
36 public:41 Position() = default;
37 enum Flag42 Position(const wgs84::Latitude&, const wgs84::Longitude&);
38 {43 Position(const wgs84::Latitude&, const wgs84::Longitude&, const wgs84::Altitude&);
39 latitude_flag = 0,
40 longitude_flag = 1,
41 altitude_flag = 2
42 };
43
44 typedef std::bitset<3> Flags;
45
46 Position();
47 Position(
48 const wgs84::Latitude& latitude,
49 const wgs84::Longitude& longitude);
50 Position(
51 const wgs84::Latitude& latitude,
52 const wgs84::Longitude& longitude,
53 const wgs84::Altitude& altitude);
5444
55 bool operator==(const Position& rhs) const;45 bool operator==(const Position& rhs) const;
56 bool operator!=(const Position& rhs) const;46 bool operator!=(const Position& rhs) const;
5747
58 const Flags& flags() const;48 wgs84::Latitude latitude = wgs84::Latitude{};
5949 wgs84::Longitude longitude = wgs84::Longitude{};
60 bool has_latitude() const;50 Optional<wgs84::Altitude> altitude = Optional<wgs84::Altitude>{};
61 Position& latitude(const wgs84::Latitude& lat);51
62 const wgs84::Latitude& latitude() const;52 struct Accuracy
63
64 bool has_longitude() const;
65 Position& longitude(const wgs84::Longitude& lon);
66 const wgs84::Longitude& longitude() const;
67
68 bool has_altitude() const;
69 Position& altitude(const wgs84::Altitude& alt);
70 const wgs84::Altitude& altitude() const;
71
72 private:
73 template<typename> friend struct Codec;
74
75 struct
76 {53 {
77 Flags flags;54 typedef units::Quantity<units::Length> Horizontal;
78 wgs84::Latitude latitude;55 typedef units::Quantity<units::Length> Vertical;
79 wgs84::Longitude longitude;56
80 wgs84::Altitude altitude;57 Optional<Horizontal> horizontal = Horizontal{};
81 } fields;58 Optional<Vertical> vertical = Optional<Vertical>{};
59 } accuracy = Accuracy{};
82};60};
8361
84std::ostream& operator<<(std::ostream& out, const Position& position);62std::ostream& operator<<(std::ostream& out, const Position& position);
8563
=== modified file 'include/location_service/com/ubuntu/location/provider.h'
--- include/location_service/com/ubuntu/location/provider.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/provider.h 2014-02-03 13:52:45 +0000
@@ -18,12 +18,16 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_H_
2020
21#include "com/ubuntu/location/channel.h"21#include <com/ubuntu/location/criteria.h>
22#include "com/ubuntu/location/criteria.h"22#include <com/ubuntu/location/heading.h>
23#include "com/ubuntu/location/heading.h"23#include <com/ubuntu/location/position.h>
24#include "com/ubuntu/location/position.h"24#include <com/ubuntu/location/space_vehicle.h>
25#include "com/ubuntu/location/update.h"25#include <com/ubuntu/location/update.h>
26#include "com/ubuntu/location/velocity.h"26#include <com/ubuntu/location/velocity.h>
27#include <com/ubuntu/location/wifi_and_cell_reporting_state.h>
28
29#include <core/property.h>
30#include <core/signal.h>
2731
28#include <atomic>32#include <atomic>
29#include <bitset>33#include <bitset>
@@ -35,97 +39,125 @@
35{39{
36namespace location40namespace location
37{41{
42/**
43 * @brief The Provider class is the abstract base of all positioning providers.
44 */
38class Provider45class Provider
39{46{
40public:47public:
41 typedef std::shared_ptr<Provider> Ptr;48 typedef std::shared_ptr<Provider> Ptr;
4249
43 enum class Feature : std::size_t50 /**
44 {51 * @brief Enumerates the known features that can be supported by providers.
45 position,52 */
46 velocity,53 enum class Features : std::size_t
47 heading54 {
48 };55 none = 0, ///< The provider does not support any feature.
4956 position = 1 << 0, ///< The provider features position updates.
50 typedef std::bitset<3> FeatureFlags;57 velocity = 1 << 1, ///< The provider features velocity updates.
5158 heading = 1 << 2 ///< The provider features heading updates.
52 enum class Requirement : std::size_t59 };
53 {60
54 satellites,61 /**
55 cell_network,62 * @brief Enumerates the requirements of a provider implementation.
56 data_network,63 */
57 monetary_spending64 enum class Requirements : std::size_t
58 };65 {
5966 none = 0, ///< The provider does not require anything.
60 typedef std::bitset<4> RequirementFlags;67 satellites = 1 << 0, ///< The provider requires satellites to be visible.
6168 cell_network = 1 << 1, ///< The provider requires a cell-network to work correctly.
69 data_network = 1 << 2, ///< The provider requires a data-network to work correctly.
70 monetary_spending = 1 << 3 ///< Using the provider results in monetary cost.
71 };
72
73 /**
74 * @brief Facade for controlling the state of position/heading/velocity updates.
75 *
76 * Multiple observers can request state changes for updates. This class ensures
77 * that the specific updates are started and stopped if at least one observer
78 * requests them and stopped when the last observer issues a stop request.
79 */
62 class Controller80 class Controller
63 {81 {
64 public:82 public:
65 typedef std::shared_ptr<Controller> Ptr;83 typedef std::shared_ptr<Controller> Ptr;
6684
67 template<typename T>
68 class Cache
69 {
70 public:
71 Cache() : d{ T{}, false }
72 {
73 }
74 const T& value() const { return d.value; }
75 void update(const T& new_value) { d.value = new_value; d.is_valid = true; }
76 bool is_valid() const { return d.is_valid; }
77 void invalidate() { d.is_valid = false; }
78
79 private:
80 struct
81 {
82 T value;
83 bool is_valid;
84 } d;
85 };
86
87 virtual ~Controller() = default;85 virtual ~Controller() = default;
88 Controller(const Controller&) = delete;86 Controller(const Controller&) = delete;
89 Controller& operator=(const Controller&) = delete;87 Controller& operator=(const Controller&) = delete;
9088
89 /**
90 * @brief Request to start position updates if not already running.
91 */
91 virtual void start_position_updates();92 virtual void start_position_updates();
93
94 /**
95 * @brief Request to stop position updates. Only stops the provider when the last observer calls this function.
96 */
92 virtual void stop_position_updates();97 virtual void stop_position_updates();
98
99 /**
100 * @brief Checks if position updates are currently running.
101 * @return true iff position updates are currently running.
102 */
93 bool are_position_updates_running() const;103 bool are_position_updates_running() const;
94104
105 /**
106 * @brief Request to start heading updates if not already running.
107 */
95 virtual void start_heading_updates();108 virtual void start_heading_updates();
109
110 /**
111 * @brief Request to stop heading updates. Only stops the provider when the last observer calls this function.
112 */
96 virtual void stop_heading_updates();113 virtual void stop_heading_updates();
114
115 /**
116 * @brief Checks if position updates are currently running.
117 * @return true iff position updates are currently running.
118 */
97 bool are_heading_updates_running() const;119 bool are_heading_updates_running() const;
98120
121 /**
122 * @brief Request to start velocity updates if not already running.
123 */
99 virtual void start_velocity_updates();124 virtual void start_velocity_updates();
125
126 /**
127 * @brief Request to stop velocity updates. Only stops the provider when the last observer calls this function.
128 */
100 virtual void stop_velocity_updates();129 virtual void stop_velocity_updates();
130
131 /**
132 * @brief Checks if velocity updates are currently running.
133 * @return true iff velocity updates are currently running.
134 */
101 bool are_velocity_updates_running() const;135 bool are_velocity_updates_running() const;
102136
103 const Cache<Update<Position>>& cached_position_update() const;
104 const Cache<Update<Heading>>& cached_heading_update() const;
105 const Cache<Update<Velocity>>& cached_velocity_update() const;
106
107 protected:137 protected:
108 friend class Provider;138 friend class Provider;
109 explicit Controller(Provider& instance);139 explicit Controller(Provider& instance);
110140
111 private:141 private:
112 void on_position_updated(const Update<Position>& position);
113 void on_velocity_updated(const Update<Velocity>& velocity);
114 void on_heading_updated(const Update<Heading>& heading);
115
116 Provider& instance;142 Provider& instance;
117 std::atomic<int> position_updates_counter;143 std::atomic<int> position_updates_counter;
118 std::atomic<int> heading_updates_counter;144 std::atomic<int> heading_updates_counter;
119 std::atomic<int> velocity_updates_counter;145 std::atomic<int> velocity_updates_counter;
120 ScopedChannelConnection position_update_connection;146 };
121 ScopedChannelConnection velocity_update_connection;147
122 ScopedChannelConnection heading_update_connection;148 /**
123 struct149 * @brief Wraps all updates that can be delivered by a provider.
124 {150 */
125 Cache<Update<Position>> position;151 struct Updates
126 Cache<Update<Velocity>> velocity;152 {
127 Cache<Update<Heading>> heading; 153 /** Position updates. */
128 } cached;154 core::Signal<Update<Position>> position;
155 /** Heading updates. */
156 core::Signal<Update<Heading>> heading;
157 /** Velocity updates. */
158 core::Signal<Update<Velocity>> velocity;
159 /** Space vehicle visibility updates. */
160 core::Signal<Update<std::set<SpaceVehicle>>> svs;
129 };161 };
130162
131 virtual ~Provider() = default;163 virtual ~Provider() = default;
@@ -133,43 +165,114 @@
133 Provider(const Provider&) = delete;165 Provider(const Provider&) = delete;
134 Provider& operator=(const Provider&) = delete;166 Provider& operator=(const Provider&) = delete;
135167
168 /**
169 * @brief Provides non-mutable access to this provider's updates.
170 * @return A non-mutable reference to the updates.
171 */
172 virtual const Updates& updates() const;
173
174 /**
175 * @brief Access to the controller facade of this provider instance.
176 */
136 virtual const Controller::Ptr& state_controller() const;177 virtual const Controller::Ptr& state_controller() const;
137178
138 virtual ChannelConnection subscribe_to_position_updates(std::function<void(const Update<Position>&)> f);179 /**
139 virtual ChannelConnection subscribe_to_heading_updates(std::function<void(const Update<Heading>&)> f);180 * @brief Checks if the provider supports a specific feature.
140 virtual ChannelConnection subscribe_to_velocity_updates(std::function<void(const Update<Velocity>&)> f);181 * @param f Feature to test for
141182 * @return true iff the provider supports the feature.
142 virtual bool supports(const Feature& f) const;183 */
143 virtual bool requires(const Requirement& r) const;184 virtual bool supports(const Features& f) const;
144185
145 virtual bool matches_criteria(const Criteria&);186 /**
146 187 * @brief Checks if the provider has got a specific requirement.
188 * @param r Requirement to test for.
189 * @return true iff the provider has the specific requirement.
190 */
191 virtual bool requires(const Requirements& r) const;
192
193 /**
194 * @brief Checks if a provider satisfies a set of accuracy criteria.
195 * @param [in] criteria The criteria to check.
196 * @return true iff the provider satisfies the given criteria.
197 */
198 virtual bool matches_criteria(const Criteria& criteria);
199
200 /**
201 * @brief Called by the engine whenever the wifi and cell ID reporting state changes.
202 * @param state The new state.
203 */
204 virtual void on_wifi_and_cell_reporting_state_changed(WifiAndCellIdReportingState state);
205
206 /**
207 * @brief Called by the engine whenever the reference location changed.
208 * @param position The new reference location.
209 */
210 virtual void on_reference_location_updated(const Update<Position>& position);
211
212 /**
213 * @brief Called by the engine whenever the reference velocity changed.
214 * @param velocity The new reference velocity.
215 */
216 virtual void on_reference_velocity_updated(const Update<Velocity>& velocity);
217
218 /**
219 * @brief Called by the engine whenever the reference heading changed.
220 * @param heading The new reference heading.
221 */
222 virtual void on_reference_heading_updated(const Update<Heading>& heading);
223
147protected:224protected:
148 explicit Provider(225 explicit Provider(
149 const FeatureFlags& feature_flags = FeatureFlags(),226 const Features& features = Features::none,
150 const RequirementFlags& requirement_flags = RequirementFlags());227 const Requirements& requirements = Requirements::none);
151228
152 void deliver_position_updates(const Update<Position>& update);229 virtual Updates& mutable_updates();
153 void deliver_heading_updates(const Update<Heading>& update);
154 void deliver_velocity_updates(const Update<Velocity>& update);
155 230
231 /**
232 * @brief Implementation-specific, empty by default.
233 */
156 virtual void start_position_updates();234 virtual void start_position_updates();
235
236 /**
237 * @brief Implementation-specific, empty by default.
238 */
157 virtual void stop_position_updates();239 virtual void stop_position_updates();
158240
241 /**
242 * @brief Implementation-specific, empty by default.
243 */
159 virtual void start_heading_updates();244 virtual void start_heading_updates();
245
246 /**
247 * @brief Implementation-specific, empty by default.
248 */
160 virtual void stop_heading_updates();249 virtual void stop_heading_updates();
161250
251 /**
252 * @brief Implementation-specific, empty by default.
253 */
162 virtual void start_velocity_updates();254 virtual void start_velocity_updates();
255
256 /**
257 * @brief Implementation-specific, empty by default.
258 */
163 virtual void stop_velocity_updates();259 virtual void stop_velocity_updates();
164260
165private:261private:
166 FeatureFlags feature_flags;262 struct
167 RequirementFlags requirement_flags;263 {
168 Channel<Update<Position>> position_updates_channel;264 Features features = Features::none;
169 Channel<Update<Heading>> heading_updates_channel;265 Requirements requirements = Requirements::none;
170 Channel<Update<Velocity>> velocity_updates_channel;266 Updates updates;
171 Controller::Ptr controller;267 Controller::Ptr controller = Controller::Ptr{};
268 } d;
172};269};
270
271Provider::Features operator|(Provider::Features lhs, Provider::Features rhs);
272Provider::Features operator&(Provider::Features lhs, Provider::Features rhs);
273
274Provider::Requirements operator|(Provider::Requirements lhs, Provider::Requirements rhs);
275Provider::Requirements operator&(Provider::Requirements lhs, Provider::Requirements rhs);
173}276}
174}277}
175}278}
176279
=== added file 'include/location_service/com/ubuntu/location/provider_enumerator.h'
--- include/location_service/com/ubuntu/location/provider_enumerator.h 1970-01-01 00:00:00 +0000
+++ include/location_service/com/ubuntu/location/provider_enumerator.h 2014-02-03 13:52:45 +0000
@@ -0,0 +1,49 @@
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_PROVIDER_ENUMERATOR_H_
19#define LOCATION_SERVICE_COM_UBUNTU_PROVIDER_ENUMERATOR_H_
20
21#include <functional>
22#include <memory>
23
24namespace com
25{
26namespace ubuntu
27{
28namespace location
29{
30class Provider;
31class ProviderEnumerator
32{
33public:
34 ProviderEnumerator(const ProviderEnumerator&) = delete;
35 virtual ~ProviderEnumerator() = default;
36
37 ProviderEnumerator& operator=(const ProviderEnumerator&) = delete;
38 bool operator==(const ProviderEnumerator&) const = delete;
39
40 virtual void for_each_provider(const std::function<void(const std::shared_ptr<Provider>&)>&) const = 0;
41
42protected:
43 ProviderEnumerator() = default;
44};
45}
46}
47}
48
49#endif // LOCATION_SERVICE_COM_UBUNTU_PROVIDER_ENUMERATOR_H_
050
=== modified file 'include/location_service/com/ubuntu/location/provider_factory.h'
--- include/location_service/com/ubuntu/location/provider_factory.h 2013-05-29 06:04:02 +0000
+++ include/location_service/com/ubuntu/location/provider_factory.h 2014-02-03 13:52:45 +0000
@@ -18,8 +18,8 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_
2020
21#include "com/ubuntu/location/configuration.h"21#include <com/ubuntu/location/configuration.h>
22#include "com/ubuntu/location/provider.h"22#include <com/ubuntu/location/provider.h>
2323
24#include <functional>24#include <functional>
25#include <map>25#include <map>
@@ -57,7 +57,7 @@
57 ProviderFactory& operator=(const ProviderFactory&) = delete;57 ProviderFactory& operator=(const ProviderFactory&) = delete;
5858
59 std::mutex guard;59 std::mutex guard;
60 std::map<std::string, Factory> factory_store; 60 std::map<std::string, Factory> factory_store;
61};61};
62}62}
63}63}
6464
=== added file 'include/location_service/com/ubuntu/location/provider_selection.h'
--- include/location_service/com/ubuntu/location/provider_selection.h 1970-01-01 00:00:00 +0000
+++ include/location_service/com/ubuntu/location/provider_selection.h 2014-02-03 13:52:45 +0000
@@ -0,0 +1,62 @@
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_PROVIDER_SELECTION_H_
19#define LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_H_
20
21#include <com/ubuntu/location/provider.h>
22
23#include <memory>
24
25namespace com
26{
27namespace ubuntu
28{
29namespace location
30{
31struct ProviderSelection
32{
33 inline Provider::Features to_feature_flags() const
34 {
35 Provider::Features flags = Provider::Features::none;
36
37 if (position_updates_provider)
38 flags = flags | Provider::Features::position;
39 if (heading_updates_provider)
40 flags = flags | Provider::Features::heading;
41 if(velocity_updates_provider)
42 flags = flags | Provider::Features::velocity;
43
44 return flags;
45 }
46
47 std::shared_ptr<Provider> position_updates_provider;
48 std::shared_ptr<Provider> heading_updates_provider;
49 std::shared_ptr<Provider> velocity_updates_provider;
50};
51
52inline bool operator==(const ProviderSelection& lhs, const ProviderSelection& rhs)
53{
54 return lhs.position_updates_provider == rhs.position_updates_provider &&
55 lhs.heading_updates_provider == rhs.heading_updates_provider &&
56 lhs.velocity_updates_provider == rhs.velocity_updates_provider;
57}
58}
59}
60}
61
62#endif // LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_H_
063
=== modified file 'include/location_service/com/ubuntu/location/provider_selection_policy.h'
--- include/location_service/com/ubuntu/location/provider_selection_policy.h 2013-06-10 11:10:00 +0000
+++ include/location_service/com/ubuntu/location/provider_selection_policy.h 2014-02-03 13:52:45 +0000
@@ -18,7 +18,8 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_POLICY_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_POLICY_H_
19#define LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_POLICY_H_19#define LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_POLICY_H_
2020
21#include "com/ubuntu/location/provider.h"21#include <com/ubuntu/location/provider_enumerator.h>
22#include <com/ubuntu/location/provider_selection.h>
2223
23#include <memory>24#include <memory>
2425
@@ -29,52 +30,23 @@
29namespace location30namespace location
30{31{
31struct Criteria;32struct Criteria;
3233class Engine;
33struct ProviderSelection
34{
35 ProviderSelection(const Provider::Ptr position = Provider::Ptr{},
36 const Provider::Ptr heading = Provider::Ptr{},
37 const Provider::Ptr velocity = Provider::Ptr{}) : position_updates_provider(position),
38 heading_updates_provider(heading),
39 velocity_updates_provider(velocity)
40 {
41 }
42
43 Provider::FeatureFlags to_feature_flags() const
44 {
45 Provider::FeatureFlags flags;
46 flags.set(static_cast<std::size_t>(Provider::Feature::position), static_cast<bool>(position_updates_provider));
47 flags.set(static_cast<std::size_t>(Provider::Feature::heading), static_cast<bool>(heading_updates_provider));
48 flags.set(static_cast<std::size_t>(Provider::Feature::velocity), static_cast<bool>(velocity_updates_provider));
49
50 return flags;
51 }
52
53 Provider::Ptr position_updates_provider;
54 Provider::Ptr heading_updates_provider;
55 Provider::Ptr velocity_updates_provider;
56};
57
58inline bool operator==(const ProviderSelection& lhs, const ProviderSelection& rhs)
59{
60 return lhs.position_updates_provider == rhs.position_updates_provider &&
61 lhs.heading_updates_provider == rhs.heading_updates_provider &&
62 lhs.velocity_updates_provider == rhs.velocity_updates_provider;
63}
6434
65class ProviderSelectionPolicy35class ProviderSelectionPolicy
66{36{
67public:37public:
68 typedef std::shared_ptr<ProviderSelectionPolicy> Ptr;38 typedef std::shared_ptr<ProviderSelectionPolicy> Ptr;
6939
40 ProviderSelectionPolicy(const ProviderSelectionPolicy&) = delete;
41 ProviderSelectionPolicy& operator=(const ProviderSelectionPolicy&) = delete;
70 virtual ~ProviderSelectionPolicy() = default;42 virtual ~ProviderSelectionPolicy() = default;
7143
72 virtual ProviderSelection determine_provider_selection_from_set_for_criteria(const Criteria& criteria, const std::set<Provider::Ptr>& providers) = 0;44 virtual ProviderSelection determine_provider_selection_for_criteria(
45 const Criteria& criteria,
46 const ProviderEnumerator& enumerator) = 0;
47
73protected:48protected:
74 ProviderSelectionPolicy() = default;49 ProviderSelectionPolicy() = default;
75private:
76 ProviderSelectionPolicy(const ProviderSelectionPolicy&) = delete;
77 ProviderSelectionPolicy& operator=(const ProviderSelectionPolicy&) = delete;
78};50};
79}51}
80}52}
8153
=== modified file 'include/location_service/com/ubuntu/location/providers/geoclue/geoclue.h'
--- include/location_service/com/ubuntu/location/providers/geoclue/geoclue.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/providers/geoclue/geoclue.h 2014-02-03 13:52:45 +0000
@@ -18,14 +18,14 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_
2020
21#include "org/freedesktop/dbus/service.h"21#include <core/dbus/service.h>
22#include "org/freedesktop/dbus/traits/service.h"22#include <core/dbus/traits/service.h>
23#include "org/freedesktop/dbus/types/struct.h"23#include <core/dbus/types/struct.h>
24#include "org/freedesktop/dbus/types/stl/tuple.h"24#include <core/dbus/types/stl/tuple.h>
2525
26#include <string>26#include <string>
2727
28namespace dbus = org::freedesktop::dbus;28namespace dbus = core::dbus;
2929
30namespace org30namespace org
31{31{
@@ -43,13 +43,13 @@
4343
44 friend std::ostream& operator<<(std::ostream& out, const Status& status)44 friend std::ostream& operator<<(std::ostream& out, const Status& status)
45 {45 {
46 static std::map<Status, std::string> lut = 46 static std::map<Status, std::string> lut =
47 {47 {
48 {Status::error, "error"},48 {Status::error, "error"},
49 {Status::unavailable, "unavailable"},49 {Status::unavailable, "unavailable"},
50 {Status::acquiring, "acquiring"},50 {Status::acquiring, "acquiring"},
51 {Status::available, "available"}51 {Status::available, "available"}
52 };52 };
5353
54 return out << lut[status];54 return out << lut[status];
55 }55 }
@@ -59,7 +59,7 @@
59 inline static std::string name()59 inline static std::string name()
60 {60 {
61 return "GetProviderInfo";61 return "GetProviderInfo";
62 } 62 }
63 typedef Geoclue Interface;63 typedef Geoclue Interface;
64 typedef std::tuple<std::string, std::string> ResultType;64 typedef std::tuple<std::string, std::string> ResultType;
65 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }65 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
@@ -70,7 +70,7 @@
70 inline static std::string name()70 inline static std::string name()
71 {71 {
72 return "GetStatus";72 return "GetStatus";
73 } 73 }
74 typedef Geoclue Interface;74 typedef Geoclue Interface;
75 typedef int32_t ResultType;75 typedef int32_t ResultType;
76 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }76 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
@@ -81,7 +81,7 @@
81 inline static std::string name()81 inline static std::string name()
82 {82 {
83 return "AddReference";83 return "AddReference";
84 } 84 }
85 typedef Geoclue Interface;85 typedef Geoclue Interface;
86 typedef void ResultType;86 typedef void ResultType;
87 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }87 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
@@ -92,7 +92,7 @@
92 inline static std::string name()92 inline static std::string name()
93 {93 {
94 return "RemoveReference";94 return "RemoveReference";
95 } 95 }
96 typedef Geoclue Interface;96 typedef Geoclue Interface;
97 typedef void ResultType;97 typedef void ResultType;
98 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }98 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
@@ -105,7 +105,7 @@
105 inline static std::string name()105 inline static std::string name()
106 {106 {
107 return "GetAddress";107 return "GetAddress";
108 } 108 }
109 typedef Address Interface;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;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}; }111 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
@@ -127,24 +127,24 @@
127127
128 struct Position128 struct Position
129 {129 {
130 struct Field130 struct Field
131 {131 {
132 Field() = delete;132 Field() = delete;
133133
134 static const int none = 0;134 static const int none = 0;
135 static const int latitude = 1;135 static const int latitude = 1;
136 static const int longitude = 2;136 static const int longitude = 2;
137 static const int altitude = 3;137 static const int altitude = 3;
138 };138 };
139139
140 typedef std::bitset<4> FieldFlags;140 typedef std::bitset<4> FieldFlags;
141141
142 struct GetPosition142 struct GetPosition
143 {143 {
144 inline static std::string name()144 inline static std::string name()
145 {145 {
146 return "GetPosition";146 return "GetPosition";
147 } 147 }
148 typedef Position Interface;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;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}; }150 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
@@ -166,24 +166,24 @@
166166
167 struct Velocity167 struct Velocity
168 {168 {
169 struct Field169 struct Field
170 {170 {
171 Field() = delete;171 Field() = delete;
172172
173 static const int none = 0;173 static const int none = 0;
174 static const int speed = 1;174 static const int speed = 1;
175 static const int direction = 2;175 static const int direction = 2;
176 static const int climb = 3;176 static const int climb = 3;
177 };177 };
178178
179 typedef std::bitset<4> FieldFlags;179 typedef std::bitset<4> FieldFlags;
180180
181 struct GetVelocity181 struct GetVelocity
182 {182 {
183 inline static std::string name()183 inline static std::string name()
184 {184 {
185 return "GetVelocity";185 return "GetVelocity";
186 } 186 }
187 typedef Velocity Interface;187 typedef Velocity Interface;
188 typedef std::tuple<int32_t, int32_t, double, double, double> ResultType;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}; }189 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
@@ -205,9 +205,7 @@
205}205}
206}206}
207207
208namespace org208namespace core
209{
210namespace freedesktop
211{209{
212namespace dbus210namespace dbus
213{211{
@@ -255,6 +253,5 @@
255}253}
256}254}
257}255}
258}
259256
260#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_257#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_
261258
=== modified file 'include/location_service/com/ubuntu/location/providers/geoclue/provider.h'
--- include/location_service/com/ubuntu/location/providers/geoclue/provider.h 2013-05-29 06:04:02 +0000
+++ include/location_service/com/ubuntu/location/providers/geoclue/provider.h 2014-02-03 13:52:45 +0000
@@ -18,8 +18,8 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_PROVIDER_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_PROVIDER_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_PROVIDER_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_PROVIDER_H_
2020
21#include "com/ubuntu/location/provider.h"21#include <com/ubuntu/location/provider.h>
22#include "com/ubuntu/location/provider_factory.h"22#include <com/ubuntu/location/provider_factory.h>
2323
24namespace com24namespace com
25{25{
@@ -36,9 +36,6 @@
36 public:36 public:
37 static Provider::Ptr create_instance(const ProviderFactory::Configuration&);37 static Provider::Ptr create_instance(const ProviderFactory::Configuration&);
3838
39 static const Provider::FeatureFlags& default_feature_flags();
40 static const Provider::RequirementFlags& default_requirement_flags();
41
42 struct Configuration39 struct Configuration
43 {40 {
44 static std::string key_name() { return "name"; }41 static std::string key_name() { return "name"; }
@@ -46,8 +43,8 @@
46 std::string name;43 std::string name;
47 std::string path;44 std::string path;
4845
49 Provider::FeatureFlags features;46 Provider::Features features = Provider::Features::none;
50 Provider::RequirementFlags requirements;47 Provider::Requirements requirements = Provider::Requirements::none;
51 };48 };
5249
53 Provider(const Configuration& config);50 Provider(const Configuration& config);
5451
=== removed directory 'include/location_service/com/ubuntu/location/providers/gps'
=== modified file 'include/location_service/com/ubuntu/location/providers/skyhook/provider.h'
--- include/location_service/com/ubuntu/location/providers/skyhook/provider.h 2013-05-29 06:04:02 +0000
+++ include/location_service/com/ubuntu/location/providers/skyhook/provider.h 2014-02-03 13:52:45 +0000
@@ -18,8 +18,8 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_SKYHOOK_PROVIDER_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_SKYHOOK_PROVIDER_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_SKYHOOK_PROVIDER_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_SKYHOOK_PROVIDER_H_
2020
21#include "com/ubuntu/location/provider.h"21#include <com/ubuntu/location/provider.h>
22#include "com/ubuntu/location/provider_factory.h"22#include <com/ubuntu/location/provider_factory.h>
2323
24#include <memory>24#include <memory>
2525
2626
=== modified file 'include/location_service/com/ubuntu/location/proxy_provider.h'
--- include/location_service/com/ubuntu/location/proxy_provider.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/proxy_provider.h 2014-02-03 13:52:45 +0000
@@ -18,8 +18,8 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROXY_PROVIDER_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROXY_PROVIDER_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROXY_PROVIDER_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROXY_PROVIDER_H_
2020
21#include "com/ubuntu/location/provider.h"21#include <com/ubuntu/location/provider.h>
22#include "com/ubuntu/location/provider_selection_policy.h"22#include <com/ubuntu/location/provider_selection_policy.h>
2323
24#include <bitset>24#include <bitset>
25#include <memory>25#include <memory>
@@ -38,10 +38,6 @@
38 ProxyProvider(const ProviderSelection& selection);38 ProxyProvider(const ProviderSelection& selection);
39 ~ProxyProvider() noexcept;39 ~ProxyProvider() noexcept;
4040
41 ChannelConnection subscribe_to_position_updates(std::function<void(const Update<Position>&)> f);
42 ChannelConnection subscribe_to_heading_updates(std::function<void(const Update<Heading>&)> f);
43 ChannelConnection subscribe_to_velocity_updates(std::function<void(const Update<Velocity>&)> f);
44
45 virtual void start_position_updates();41 virtual void start_position_updates();
46 virtual void stop_position_updates();42 virtual void stop_position_updates();
4743
4844
=== added file 'include/location_service/com/ubuntu/location/satellite_based_positioning_state.h'
--- include/location_service/com/ubuntu/location/satellite_based_positioning_state.h 1970-01-01 00:00:00 +0000
+++ include/location_service/com/ubuntu/location/satellite_based_positioning_state.h 2014-02-03 13:52:45 +0000
@@ -0,0 +1,40 @@
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_SATELLITE_BASED_POSITIONING_STATE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SATELLITE_BASED_POSITIONING_STATE_H_
20
21namespace com
22{
23namespace ubuntu
24{
25namespace location
26{
27/**
28 * @brief The SatelliteBasedPositioningState enum describes whether satellite
29 * assisted positioning is enabled or disabled.
30 */
31enum class SatelliteBasedPositioningState
32{
33 on, ///< Satellite assisted positioning is on.
34 off ///< Satellite assisted positioning is off.
35};
36}
37}
38}
39
40#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SATELLITE_BASED_POSITIONING_STATE_H_
041
=== modified file 'include/location_service/com/ubuntu/location/service/configuration.h'
--- include/location_service/com/ubuntu/location/service/configuration.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/service/configuration.h 2014-02-03 13:52:45 +0000
@@ -18,11 +18,11 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_CONFIGURATION_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_CONFIGURATION_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_CONFIGURATION_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_CONFIGURATION_H_
2020
21#include "com/ubuntu/location/service/permission_manager.h"21#include <com/ubuntu/location/service/permission_manager.h>
2222
23#include "com/ubuntu/location/engine.h"23#include <com/ubuntu/location/engine.h>
24#include "com/ubuntu/location/provider.h"24#include <com/ubuntu/location/provider.h>
25#include "com/ubuntu/location/provider_selection_policy.h"25#include <com/ubuntu/location/provider_selection_policy.h>
2626
27#include <set>27#include <set>
2828
2929
=== modified file 'include/location_service/com/ubuntu/location/service/default_configuration.h'
--- include/location_service/com/ubuntu/location/service/default_configuration.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/service/default_configuration.h 2014-02-03 13:52:45 +0000
@@ -18,7 +18,7 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_CONFIGURATION_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_CONFIGURATION_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_CONFIGURATION_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_CONFIGURATION_H_
2020
21#include "com/ubuntu/location/service/configuration.h"21#include <com/ubuntu/location/service/configuration.h>
2222
23#include <set>23#include <set>
2424
2525
=== modified file 'include/location_service/com/ubuntu/location/service/default_permission_manager.h'
--- include/location_service/com/ubuntu/location/service/default_permission_manager.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/service/default_permission_manager.h 2014-02-03 13:52:45 +0000
@@ -18,7 +18,7 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_PERMISSION_MANAGER_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_PERMISSION_MANAGER_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_PERMISSION_MANAGER_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_PERMISSION_MANAGER_H_
2020
21#include "com/ubuntu/location/service/permission_manager.h"21#include <com/ubuntu/location/service/permission_manager.h>
2222
23#include <sys/types.h>23#include <sys/types.h>
24#include <unistd.h>24#include <unistd.h>
2525
=== modified file 'include/location_service/com/ubuntu/location/service/implementation.h'
--- include/location_service/com/ubuntu/location/service/implementation.h 2013-06-10 11:10:00 +0000
+++ include/location_service/com/ubuntu/location/service/implementation.h 2014-02-03 13:52:45 +0000
@@ -18,12 +18,12 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_H_
2020
21#include "com/ubuntu/location/engine.h"21#include <com/ubuntu/location/engine.h>
22#include "com/ubuntu/location/service/skeleton.h"22#include <com/ubuntu/location/service/skeleton.h>
2323
24#include <memory>24#include <memory>
2525
26namespace dbus = org::freedesktop::dbus;26namespace dbus = core::dbus;
2727
28namespace com28namespace com
29{29{
@@ -39,14 +39,14 @@
39 typedef std::shared_ptr<Implementation> Ptr;39 typedef std::shared_ptr<Implementation> Ptr;
4040
41 Implementation(41 Implementation(
42 const org::freedesktop::dbus::Bus::Ptr& bus,42 const core::dbus::Bus::Ptr& bus,
43 const Engine::Ptr& engine,43 const Engine::Ptr& engine,
44 const PermissionManager::Ptr& permission_manager);44 const PermissionManager::Ptr& permission_manager);
45 Implementation(const Implementation&) = delete;45 Implementation(const Implementation&) = delete;
46 virtual ~Implementation() noexcept;46 virtual ~Implementation() noexcept;
47 Implementation& operator=(const Implementation&) = delete;47 Implementation& operator=(const Implementation&) = delete;
4848
49 virtual session::Interface::Ptr create_session_for_criteria(const Criteria& criteria);49 session::Interface::Ptr create_session_for_criteria(const Criteria& criteria);
5050
51 private:51 private:
52 struct Private;52 struct Private;
5353
=== modified file 'include/location_service/com/ubuntu/location/service/interface.h'
--- include/location_service/com/ubuntu/location/service/interface.h 2013-06-10 11:10:00 +0000
+++ include/location_service/com/ubuntu/location/service/interface.h 2014-02-03 13:52:45 +0000
@@ -18,16 +18,18 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_
2020
21#include "com/ubuntu/location/service/session/interface.h"21#include <com/ubuntu/location/service/session/interface.h>
2222
23#include <org/freedesktop/dbus/service.h>23#include <com/ubuntu/location/space_vehicle.h>
24#include <org/freedesktop/dbus/traits/service.h>24
25#include <org/freedesktop/dbus/types/object_path.h>25#include <core/dbus/service.h>
26#include <core/dbus/traits/service.h>
27#include <core/dbus/types/object_path.h>
2628
27#include <chrono>29#include <chrono>
28#include <functional>30#include <functional>
2931
30namespace dbus = org::freedesktop::dbus;32namespace dbus = core::dbus;
3133
32namespace com34namespace com
33{35{
@@ -35,18 +37,31 @@
35{37{
36namespace location38namespace location
37{39{
38
39struct Criteria;40struct Criteria;
40
41namespace service41namespace service
42{42{
43/**
44 * @brief The Interface class models the primary interface to the location service.
45 */
43class Interface46class Interface
44{47{
45 protected:48 protected:
46 struct Errors49 struct Errors
47 {50 {
48 struct InsufficientPermissions { inline static std::string name() { return "com.ubuntu.location.Service.Error.InsufficientPermissions"; } };51 struct InsufficientPermissions
49 struct CreatingSession { inline static std::string name() { return "com.ubuntu.location.Service.Error.CreatingSession"; } };52 {
53 inline static std::string name()
54 {
55 return "com.ubuntu.location.Service.Error.InsufficientPermissions";
56 }
57 };
58 struct CreatingSession
59 {
60 inline static std::string name()
61 {
62 return "com.ubuntu.location.Service.Error.CreatingSession";
63 }
64 };
50 };65 };
5166
52 struct CreateSessionForCriteria67 struct CreateSessionForCriteria
@@ -64,7 +79,82 @@
6479
65 typedef dbus::types::ObjectPath ResultType;80 typedef dbus::types::ObjectPath ResultType;
6681
67 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }82 inline static const std::chrono::milliseconds default_timeout()
83 {
84 return std::chrono::seconds{1};
85 }
86 };
87
88 struct Properties
89 {
90 struct DoesSatelliteBasedPositioning
91 {
92 inline static const std::string& name()
93 {
94 static const std::string s
95 {
96 "DoesSatelliteBasedPositioning"
97 };
98 return s;
99 }
100
101 typedef com::ubuntu::location::service::Interface Interface;
102 typedef bool ValueType;
103 static const bool readable = true;
104 static const bool writable = true;
105 };
106
107 struct DoesReportCellAndWifiIds
108 {
109 inline static const std::string& name()
110 {
111 static const std::string s
112 {
113 "DoesReportCellAndWifiIds"
114 };
115 return s;
116 }
117
118 typedef com::ubuntu::location::service::Interface Interface;
119 typedef bool ValueType;
120 static const bool readable = true;
121 static const bool writable = true;
122 };
123
124 struct IsOnline
125 {
126 inline static const std::string& name()
127 {
128 static const std::string s
129 {
130 "IsOnline"
131 };
132 return s;
133 }
134
135 typedef com::ubuntu::location::service::Interface Interface;
136 typedef bool ValueType;
137 static const bool readable = true;
138 static const bool writable = true;
139 };
140
141 struct VisibleSpaceVehicles
142 {
143 inline static const std::string& name()
144 {
145 static const std::string s
146 {
147 "VisibleSpaceVehicles"
148 };
149 return s;
150 }
151
152 typedef com::ubuntu::location::service::Interface Interface;
153 typedef std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle> ValueType;
154
155 static const bool readable = true;
156 static const bool writable = false;
157 };
68 };158 };
69159
70 Interface() = default;160 Interface() = default;
@@ -72,6 +162,9 @@
72 public:162 public:
73 typedef std::shared_ptr<Interface> Ptr;163 typedef std::shared_ptr<Interface> Ptr;
74164
165 /**
166 * @brief Queries the path that this object is known under.
167 */
75 inline static const std::string& path()168 inline static const std::string& path()
76 {169 {
77 static const std::string s{"/com/ubuntu/location/Service"};170 static const std::string s{"/com/ubuntu/location/Service"};
@@ -82,6 +175,40 @@
82 Interface& operator=(const Interface&) = delete;175 Interface& operator=(const Interface&) = delete;
83 virtual ~Interface() = default;176 virtual ~Interface() = default;
84177
178 /**
179 * @brief Whether the service uses satellite-based positioning.
180 * @return A setable/getable/observable property.
181 */
182 virtual core::Property<bool>& does_satellite_based_positioning() = 0;
183
184 /**
185 * @brief Whether the overall service and its positioning engine is online or not.
186 * @return A setable/getable/observable property.
187 */
188 virtual core::Property<bool>& is_online() = 0;
189
190 /**
191 * @brief Whether the engine and its providers/reporters do call home to
192 * report reference locations together with wifi and cell ids.
193 *
194 * We consider this feature privacy sensitive and it defaults to false. The
195 * user has to explicitly opt-in into this feature.
196 *
197 * @return A setable/getable/observable property.
198 */
199 virtual core::Property<bool>& does_report_cell_and_wifi_ids() = 0;
200
201 /**
202 * @brief All space vehicles currently visible.
203 */
204 virtual core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>>& visible_space_vehicles() = 0;
205
206 /**
207 * @brief Starts a new session for the given criteria
208 * @throw std::runtime_error in case of errors.
209 * @param criteria The client's requirements in terms of accuraccy and functionality
210 * @return A session instance.
211 */
85 virtual session::Interface::Ptr create_session_for_criteria(const Criteria& criteria) = 0;212 virtual session::Interface::Ptr create_session_for_criteria(const Criteria& criteria) = 0;
86};213};
87}214}
@@ -89,9 +216,7 @@
89}216}
90}217}
91218
92namespace org219namespace core
93{
94namespace freedesktop
95{220{
96namespace dbus221namespace dbus
97{222{
@@ -112,8 +237,7 @@
112}237}
113}238}
114}239}
115}
116240
117#include "com/ubuntu/location/codec.h"241#include <com/ubuntu/location/codec.h>
118242
119#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_243#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_
120244
=== modified file 'include/location_service/com/ubuntu/location/service/permission_manager.h'
--- include/location_service/com/ubuntu/location/service/permission_manager.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/service/permission_manager.h 2014-02-03 13:52:45 +0000
@@ -18,10 +18,7 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PERMISSION_MANAGER_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PERMISSION_MANAGER_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PERMISSION_MANAGER_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PERMISSION_MANAGER_H_
2020
21#include "com/ubuntu/location/channel.h"21#include <memory>
22#include "com/ubuntu/location/provider_selection_policy.h"
23
24#include <functional>
2522
26namespace com23namespace com
27{24{
@@ -29,29 +26,48 @@
29{26{
30namespace location27namespace location
31{28{
29struct Criteria;
32namespace service30namespace service
33{31{
32/**
33 * @brief Credentials of a remote session.
34 */
34struct Credentials35struct Credentials
35{36{
37 /** The process id of the remote peer. */
36 pid_t pid;38 pid_t pid;
39 /** The user id the remote peer runs under. */
37 uid_t uid;40 uid_t uid;
38};41};
3942
43/**
44 * @brief The PermissionManager class is an interface to check whether an application is allowed to access the location services.
45 */
40class PermissionManager46class PermissionManager
41{47{
42public:48public:
49 /** Manager pointer type. */
43 typedef std::shared_ptr<PermissionManager> Ptr;50 typedef std::shared_ptr<PermissionManager> Ptr;
4451
52 /**
53 * @brief The Result enum summarizes the results of a query for permissions.
54 */
45 enum class Result55 enum class Result
46 {56 {
47 granted,57 granted, ///< The app is allowed to access the location service.
48 rejected58 rejected ///< The app is not allowed to access the location service.
49 };59 };
5060
51 virtual ~PermissionManager() = default;61 virtual ~PermissionManager() = default;
52 PermissionManager(const PermissionManager&) = delete;62 PermissionManager(const PermissionManager&) = delete;
53 PermissionManager& operator=(const PermissionManager&) = delete;63 PermissionManager& operator=(const PermissionManager&) = delete;
5464
65 /**
66 * @brief Checks whether the app with the given credentials is allowed to access the service for the given criteria.
67 * @param criteria The requirements of the remote peer.
68 * @param credentials The credentials identifying the remote peer.
69 * @return Result::granted if the remote peer is allowed to access the location service, Result::rejected otherwise.
70 */
55 virtual Result check_permission_for_credentials(71 virtual Result check_permission_for_credentials(
56 const Criteria& criteria,72 const Criteria& criteria,
57 const Credentials& credentials) = 0;73 const Credentials& credentials) = 0;
5874
=== modified file 'include/location_service/com/ubuntu/location/service/session/implementation.h'
--- include/location_service/com/ubuntu/location/service/session/implementation.h 2013-06-10 11:10:00 +0000
+++ include/location_service/com/ubuntu/location/service/session/implementation.h 2014-02-03 13:52:45 +0000
@@ -18,9 +18,9 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_
2020
21#include "com/ubuntu/location/service/session/skeleton.h"21#include <com/ubuntu/location/service/session/skeleton.h>
2222
23#include "com/ubuntu/location/provider.h"23#include <com/ubuntu/location/provider.h>
2424
25#include <memory>25#include <memory>
2626
@@ -34,13 +34,10 @@
34{34{
35namespace session35namespace session
36{36{
37class Implementation : public Skeleton37class Implementation : public Interface
38{38{
39 public:39 public:
40 Implementation(40 Implementation(const Provider::Ptr& provider);
41 const org::freedesktop::dbus::Bus::Ptr& bus,
42 const org::freedesktop::dbus::types::ObjectPath& session_path,
43 const Provider::Ptr& provider);
44 Implementation(const Implementation&) = delete;41 Implementation(const Implementation&) = delete;
45 virtual ~Implementation() noexcept;42 virtual ~Implementation() noexcept;
46 Implementation& operator=(const Implementation&) = delete;43 Implementation& operator=(const Implementation&) = delete;
4744
=== modified file 'include/location_service/com/ubuntu/location/service/session/interface.h'
--- include/location_service/com/ubuntu/location/service/session/interface.h 2013-06-10 11:10:00 +0000
+++ include/location_service/com/ubuntu/location/service/session/interface.h 2014-02-03 13:52:45 +0000
@@ -18,16 +18,13 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_
2020
21#include "com/ubuntu/location/channel.h"21#include <com/ubuntu/location/heading.h>
22#include "com/ubuntu/location/heading.h"22#include <com/ubuntu/location/position.h>
23#include "com/ubuntu/location/position.h"23#include <com/ubuntu/location/provider.h>
24#include "com/ubuntu/location/provider.h"24#include <com/ubuntu/location/update.h>
25#include "com/ubuntu/location/update.h"25#include <com/ubuntu/location/velocity.h>
26#include "com/ubuntu/location/velocity.h"
2726
28#include <org/freedesktop/dbus/codec.h>27#include <core/property.h>
29#include <org/freedesktop/dbus/traits/service.h>
30#include <org/freedesktop/dbus/types/object_path.h>
3128
32namespace com29namespace com
33{30{
@@ -39,175 +36,70 @@
39{36{
40namespace session37namespace session
41{38{
39/**
40 * @brief Models a session with the location service.
41 */
42class Interface42class Interface
43{43{
44public:44public:
45 struct UpdatePosition45 struct UpdatePosition;
46 {46 struct UpdateVelocity;
47 typedef com::ubuntu::location::service::session::Interface Interface;47 struct UpdateHeading;
4848
49 inline static const std::string& name()49 struct StartPositionUpdates;
50 {50 struct StopPositionUpdates;
51 static const std::string s51
52 {52 struct StartVelocityUpdates;
53 "UpdatePosition"53 struct StopVelocityUpdates;
54 };54
55 return s;55 struct StartHeadingUpdates;
56 }56 struct StopHeadingUpdates;
57
58 typedef void ResultType;
59
60 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
61 };
62
63 struct UpdateVelocity
64 {
65 typedef com::ubuntu::location::service::session::Interface Interface;
66
67 inline static const std::string& name()
68 {
69 static const std::string s
70 {
71 "UpdateVelocity"
72 };
73 return s;
74 }
75
76 typedef void ResultType;
77
78 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
79 };
80
81 struct UpdateHeading
82 {
83 typedef com::ubuntu::location::service::session::Interface Interface;
84
85 inline static const std::string& name()
86 {
87 static const std::string s
88 {
89 "UpdateHeading"
90 };
91 return s;
92 }
93
94 typedef void ResultType;
95
96 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
97 };
98
99 struct StartPositionUpdates
100 {
101 typedef com::ubuntu::location::service::session::Interface Interface;
102
103 inline static const std::string& name()
104 {
105 static const std::string s
106 {
107 "StartPositionUpdates"
108 };
109 return s;
110 }
111
112 typedef void ResultType;
113
114 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
115 };
116
117 struct StopPositionUpdates
118 {
119 typedef com::ubuntu::location::service::session::Interface Interface;
120
121 inline static const std::string& name()
122 {
123 static const std::string s
124 {
125 "StopPositionUpdates"
126 };
127 return s;
128 }
129
130 typedef void ResultType;
131
132 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
133 };
134
135 struct StartVelocityUpdates
136 {
137 typedef com::ubuntu::location::service::session::Interface Interface;
138
139 inline static const std::string& name()
140 {
141 static const std::string s
142 {
143 "StartVelocityUpdates"
144 };
145 return s;
146 }
147
148 typedef void ResultType;
149
150 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
151 };
152
153 struct StopVelocityUpdates
154 {
155 typedef com::ubuntu::location::service::session::Interface Interface;
156
157 inline static const std::string& name()
158 {
159 static const std::string s
160 {
161 "StopVelocityUpdates"
162 };
163 return s;
164 }
165
166 typedef void ResultType;
167
168 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
169 };
170
171 struct StartHeadingUpdates
172 {
173 typedef com::ubuntu::location::service::session::Interface Interface;
174
175 inline static const std::string& name()
176 {
177 static const std::string s
178 {
179 "StartHeadingUpdates"
180 };
181 return s;
182 }
183
184 typedef void ResultType;
185
186 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
187 };
188
189 struct StopHeadingUpdates
190 {
191 typedef com::ubuntu::location::service::session::Interface Interface;
192
193 inline static const std::string& name()
194 {
195 static const std::string s
196 {
197 "StopHeadingUpdates"
198 };
199 return s;
200 }
201
202 typedef void ResultType;
203
204 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
205 };
20657
207 struct Errors58 struct Errors
208 {59 {
209 struct ErrorParsingUpdate { inline static std::string name() { return "com.ubuntu.location.Service.Session.ErrorParsingUpdate"; } };60 struct ErrorParsingUpdate;
210 struct ErrorStartingUpdate { inline static std::string name() { return "com.ubuntu.location.Service.Session.ErrorStartingUpdate"; } };61 struct ErrorStartingUpdate;
62 };
63 /**
64 * @brief Encapsulates updates provided for this session, and the ability to enable/disable updates.
65 */
66 struct Updates
67 {
68 /**
69 * @brief The Status enum models the possible states of updates.
70 */
71 enum class Status
72 {
73 enabled, ///< Updates are enabled and delivered to this session.
74 disabled ///< Updates are disabled and not delivered to this session.
75 };
76
77 /**
78 * @brief Updates for position measurements.
79 */
80 core::Property<Update<Position>> position{};
81 /**
82 * @brief Status of position updates, mutable.
83 */
84 core::Property<Status> position_status{Status::disabled};
85
86 /**
87 * @brief Updates for the heading measurements.
88 */
89 core::Property<Update<Heading>> heading{};
90 /**
91 * @brief Status of position updates, mutable.
92 */
93 core::Property<Status> heading_status{Status::disabled};
94
95 /**
96 * @brief Updates for velocity measurements.
97 */
98 core::Property<Update<Velocity>> velocity{};
99 /**
100 * @brief Status of velocity updates, mutable.
101 */
102 core::Property<Status> velocity_status{Status::disabled};
211 };103 };
212104
213 typedef std::shared_ptr<Interface> Ptr;105 typedef std::shared_ptr<Interface> Ptr;
@@ -216,60 +108,23 @@
216 virtual ~Interface() noexcept;108 virtual ~Interface() noexcept;
217 Interface& operator=(const Interface&) = delete;109 Interface& operator=(const Interface&) = delete;
218110
219 virtual const org::freedesktop::dbus::types::ObjectPath& path() const = 0;111 /**
220112 * @brief Provides access to the updates delivered for this session.
221 ChannelConnection install_position_updates_handler(std::function<void(const Update<Position>&)> handler);113 * @return A mutable reference to updates.
222 ChannelConnection install_velocity_updates_handler(std::function<void(const Update<Velocity>&)> handler);114 */
223 ChannelConnection install_heading_updates_handler(std::function<void(const Update<Heading>&)> handler);115 virtual Updates& updates();
224116
225 virtual void start_position_updates() = 0;117protected:
226 virtual void stop_position_updates() noexcept = 0;
227 virtual void start_velocity_updates() = 0;
228 virtual void stop_velocity_updates() noexcept = 0;
229 virtual void start_heading_updates() = 0;
230 virtual void stop_heading_updates() noexcept = 0;
231
232protected:
233 Interface();118 Interface();
234119
235 Channel<Update<Position>>& access_position_updates_channel();
236 Channel<Update<Heading>>& access_heading_updates_channel();
237 Channel<Update<Velocity>>& access_velocity_updates_channel();
238
239private:120private:
240 struct Private;121 struct Private;
241 std::unique_ptr<Private> d;122 std::shared_ptr<Private> d;
242};123};
243}124}
244}125}
245}126}
246}127}
247}128}
248namespace org
249{
250namespace freedesktop
251{
252namespace dbus
253{
254namespace traits
255{
256template<>
257struct Service<com::ubuntu::location::service::session::Interface>
258{
259 static const std::string& interface_name()
260 {
261 static const std::string s
262 {
263 "com.ubuntu.location.Service.Session"
264 };
265 return s;
266 }
267};
268}
269}
270}
271}
272
273#include "com/ubuntu/location/codec.h"
274129
275#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_130#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_
276131
=== modified file 'include/location_service/com/ubuntu/location/service/session/skeleton.h'
--- include/location_service/com/ubuntu/location/service/session/skeleton.h 2013-06-10 11:10:00 +0000
+++ include/location_service/com/ubuntu/location/service/session/skeleton.h 2014-02-03 13:52:45 +0000
@@ -18,19 +18,19 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_SKELETON_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_SKELETON_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_SKELETON_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_SKELETON_H_
2020
21#include "com/ubuntu/location/service/session/interface.h"21#include <com/ubuntu/location/service/session/interface.h>
2222
23#include "com/ubuntu/location/channel.h"23#include <com/ubuntu/location/heading.h>
24#include "com/ubuntu/location/heading.h"24#include <com/ubuntu/location/position.h>
25#include "com/ubuntu/location/position.h"25#include <com/ubuntu/location/provider.h>
26#include "com/ubuntu/location/provider.h"26#include <com/ubuntu/location/update.h>
27#include "com/ubuntu/location/update.h"27#include <com/ubuntu/location/velocity.h>
28#include "com/ubuntu/location/velocity.h"28
2929#include <core/dbus/message.h>
30#include <org/freedesktop/dbus/message.h>30#include <core/dbus/object.h>
31#include <org/freedesktop/dbus/skeleton.h>31#include <core/dbus/skeleton.h>
3232
33#include <functional>33#include <memory>
3434
35namespace com35namespace com
36{36{
@@ -42,21 +42,23 @@
42{42{
43namespace session43namespace session
44{44{
45class Skeleton : public org::freedesktop::dbus::Skeleton<Interface>45class Skeleton : public core::dbus::Skeleton<Interface>
46{46{
47 public:47 public:
48 Skeleton(48 Skeleton(const Interface::Ptr& instance,
49 const org::freedesktop::dbus::Bus::Ptr& bus,49 const core::dbus::Bus::Ptr& bus,
50 const org::freedesktop::dbus::types::ObjectPath& session_path);50 const core::dbus::Service::Ptr& service,
51 const core::dbus::Object::Ptr& session,
52 const core::dbus::types::ObjectPath& session_path);
51 Skeleton(const Skeleton&) = delete;53 Skeleton(const Skeleton&) = delete;
52 virtual ~Skeleton() noexcept;54 virtual ~Skeleton() noexcept;
53 Skeleton& operator=(const Skeleton&) = delete;55 Skeleton& operator=(const Skeleton&) = delete;
5456
55 virtual const org::freedesktop::dbus::types::ObjectPath& path() const;57 virtual const core::dbus::types::ObjectPath& path() const;
5658
57 private:59 private:
58 struct Private;60 struct Private;
59 std::unique_ptr<Private> d;61 std::shared_ptr<Private> d;
60};62};
61}63}
62}64}
6365
=== modified file 'include/location_service/com/ubuntu/location/service/session/stub.h'
--- include/location_service/com/ubuntu/location/service/session/stub.h 2013-06-10 11:10:00 +0000
+++ include/location_service/com/ubuntu/location/service/session/stub.h 2014-02-03 13:52:45 +0000
@@ -18,16 +18,15 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_STUB_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_STUB_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SESSION_SESSION_STUB_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SESSION_SESSION_STUB_H_
2020
21#include "com/ubuntu/location/service/session/interface.h"21#include <com/ubuntu/location/service/session/interface.h>
2222
23#include "com/ubuntu/location/channel.h"23#include <com/ubuntu/location/heading.h>
24#include "com/ubuntu/location/heading.h"24#include <com/ubuntu/location/position.h>
25#include "com/ubuntu/location/position.h"25#include <com/ubuntu/location/provider.h>
26#include "com/ubuntu/location/provider.h"26#include <com/ubuntu/location/update.h>
27#include "com/ubuntu/location/update.h"27#include <com/ubuntu/location/velocity.h>
28#include "com/ubuntu/location/velocity.h"28
2929#include <core/dbus/stub.h>
30#include <org/freedesktop/dbus/stub.h>
3130
32#include <memory>31#include <memory>
3332
@@ -41,17 +40,17 @@
41{40{
42namespace session41namespace session
43{42{
44class Stub : public org::freedesktop::dbus::Stub<Interface>43class Stub : public core::dbus::Stub<Interface>
45{44{
46 public:45 public:
47 Stub(46 Stub(
48 const org::freedesktop::dbus::Bus::Ptr& bus,47 const core::dbus::Bus::Ptr& bus,
49 const org::freedesktop::dbus::types::ObjectPath& session_path);48 const core::dbus::types::ObjectPath& session_path);
50 Stub(const Stub&) = delete;49 Stub(const Stub&) = delete;
51 virtual ~Stub() noexcept;50 virtual ~Stub() noexcept;
52 Stub& operator=(const Stub&) = delete;51 Stub& operator=(const Stub&) = delete;
5352
54 virtual const org::freedesktop::dbus::types::ObjectPath& path() const;53 virtual const core::dbus::types::ObjectPath& path() const;
5554
56 virtual void start_position_updates();55 virtual void start_position_updates();
57 virtual void stop_position_updates() noexcept;56 virtual void stop_position_updates() noexcept;
5857
=== modified file 'include/location_service/com/ubuntu/location/service/skeleton.h'
--- include/location_service/com/ubuntu/location/service/skeleton.h 2013-06-10 11:10:00 +0000
+++ include/location_service/com/ubuntu/location/service/skeleton.h 2014-02-03 13:52:45 +0000
@@ -18,11 +18,11 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SKELETON_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SKELETON_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SKELETON_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SKELETON_H_
2020
21#include "com/ubuntu/location/service/interface.h"21#include <com/ubuntu/location/service/interface.h>
22#include "com/ubuntu/location/service/permission_manager.h"22#include <com/ubuntu/location/service/permission_manager.h>
23#include "com/ubuntu/location/service/session/interface.h"23#include <com/ubuntu/location/service/session/interface.h>
2424
25#include <org/freedesktop/dbus/skeleton.h>25#include <core/dbus/skeleton.h>
2626
27namespace com27namespace com
28{28{
@@ -32,7 +32,7 @@
32{32{
33namespace service33namespace service
34{34{
35class Skeleton : public org::freedesktop::dbus::Skeleton<com::ubuntu::location::service::Interface>,35class Skeleton : public core::dbus::Skeleton<com::ubuntu::location::service::Interface>,
36 public std::enable_shared_from_this<Skeleton>36 public std::enable_shared_from_this<Skeleton>
37{37{
38 public:38 public:
@@ -43,6 +43,11 @@
43 Skeleton& operator=(const Skeleton&) = delete;43 Skeleton& operator=(const Skeleton&) = delete;
44 ~Skeleton() noexcept;44 ~Skeleton() noexcept;
4545
46 core::Property<bool>& does_satellite_based_positioning();
47 core::Property<bool>& does_report_cell_and_wifi_ids();
48 core::Property<bool>& is_online();
49 core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>>& visible_space_vehicles();
50
46 private:51 private:
47 struct Private;52 struct Private;
48 std::shared_ptr<Private> d;53 std::shared_ptr<Private> d;
4954
=== modified file 'include/location_service/com/ubuntu/location/service/stub.h'
--- include/location_service/com/ubuntu/location/service/stub.h 2013-06-10 11:10:00 +0000
+++ include/location_service/com/ubuntu/location/service/stub.h 2014-02-03 13:52:45 +0000
@@ -18,10 +18,10 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_STUB_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_STUB_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_STUB_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_STUB_H_
2020
21#include "com/ubuntu/location/service/interface.h"21#include <com/ubuntu/location/service/interface.h>
22#include "com/ubuntu/location/service/session/interface.h"22#include <com/ubuntu/location/service/session/interface.h>
2323
24#include <org/freedesktop/dbus/stub.h>24#include <core/dbus/stub.h>
2525
26namespace com26namespace com
27{27{
@@ -31,7 +31,7 @@
31{31{
32namespace service32namespace service
33{33{
34class Stub : public org::freedesktop::dbus::Stub<Interface>34class Stub : public core::dbus::Stub<Interface>
35{35{
36 public:36 public:
37 Stub(const dbus::Bus::Ptr& connection);37 Stub(const dbus::Bus::Ptr& connection);
@@ -40,6 +40,10 @@
40 ~Stub() noexcept;40 ~Stub() noexcept;
4141
42 session::Interface::Ptr create_session_for_criteria(const Criteria& criteria);42 session::Interface::Ptr create_session_for_criteria(const Criteria& criteria);
43 core::Property<bool>& does_satellite_based_positioning();
44 core::Property<bool>& does_report_cell_and_wifi_ids();
45 core::Property<bool>& is_online();
46 core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>>& visible_space_vehicles();
4347
44 private:48 private:
45 struct Private;49 struct Private;
4650
=== added file 'include/location_service/com/ubuntu/location/space_vehicle.h'
--- include/location_service/com/ubuntu/location/space_vehicle.h 1970-01-01 00:00:00 +0000
+++ include/location_service/com/ubuntu/location/space_vehicle.h 2014-02-03 13:52:45 +0000
@@ -0,0 +1,121 @@
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_SPACE_VEHICLE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SPACE_VEHICLE_H_
20
21#include <com/ubuntu/location/units/units.h>
22
23#include <iostream>
24#include <map>
25
26namespace com
27{
28namespace ubuntu
29{
30namespace location
31{
32/** @brief A space-vehicle as visible to providers. */
33struct SpaceVehicle
34{
35 /** @brief Numeric Id of an individual SpaceVehicle. */
36 typedef std::uint32_t Id;
37
38 enum class Type
39 {
40 unknown, ///< Unknown (and thus invalid) type.
41 beidou, ///< People's Republic of China's regional system, currently limited to Asia and the West Pacific
42 galileo, ///< A global system being developed by the European Union and other partner countries, planned to be operational by 2014 (and fully deployed by 2019).
43 glonass, ///< Russia's global navigation system. Fully operational worldwide.
44 gps, ///< Fully operational worldwide.
45 compass, ///< People's Republic of China's global system, planned to be operational by 2020.
46 irnss, ///< India's regional navigation system, planned to be operational by 2014, covering India and Northern Indian Ocean.
47 qzss ///< Japanese regional system covering Asia and Oceania.
48 };
49
50 struct Key
51 {
52 Type type = Type::unknown; ///< The positioning system this vehicle belongs to.
53 Id id = 0; ///< Unique id of the space vehicle.
54
55 inline bool operator==(const SpaceVehicle::Key& rhs) const
56 {
57 return type == rhs.type && id == rhs.id;
58 }
59
60 inline bool operator<(const SpaceVehicle::Key& rhs) const
61 {
62 if (type != rhs.type)
63 return type < rhs.type;
64
65 return id < rhs.id;
66 }
67 };
68
69 inline bool operator==(const SpaceVehicle& rhs) const
70 {
71 return key == rhs.key &&
72 has_almanac_data == rhs.has_almanac_data &&
73 has_ephimeris_data == rhs.has_ephimeris_data &&
74 used_in_fix == rhs.used_in_fix &&
75 units::roughly_equals(azimuth, rhs.azimuth) &&
76 units::roughly_equals(elevation, rhs.elevation);
77 }
78
79 inline bool operator<(const SpaceVehicle& rhs) const
80 {
81 return key < rhs.key;
82 }
83
84 Key key; ///< Unique key identifying an instance.
85 float snr = -std::numeric_limits<float>::max(); ///< Signal to noise ratio;
86 bool has_almanac_data = false; ///< Almanac data available for this vehicle.
87 bool has_ephimeris_data = false; ///< Ephimeris data is available for this vehicle.
88 bool used_in_fix = false; ///< This vehicle has been used to obtain a fix.
89 units::Quantity<units::PlaneAngle> azimuth; ///< Azimuth of SV.
90 units::Quantity<units::PlaneAngle> elevation; ///< Elevation of SV.
91};
92
93inline std::ostream& operator<<(std::ostream& out, const SpaceVehicle& sv)
94{
95 static const std::map<SpaceVehicle::Type, std::string> lut =
96 {
97 {SpaceVehicle::Type::unknown, "unknown"},
98 {SpaceVehicle::Type::beidou, "beidou"},
99 {SpaceVehicle::Type::galileo, "galileo"},
100 {SpaceVehicle::Type::glonass, "glonass"},
101 {SpaceVehicle::Type::gps, "gps"},
102 {SpaceVehicle::Type::compass, "compass"},
103 {SpaceVehicle::Type::irnss, "irnss"},
104 {SpaceVehicle::Type::qzss, "qzss" }
105 };
106 return out << "("
107 << "type: " << lut.at(sv.key.type) << ", "
108 << "prn: " << sv.key.id << ", "
109 << "snr: " << sv.snr << ", "
110 << "has_almanac_data: " << sv.has_almanac_data << ", "
111 << "has_ephimeris_data: " << sv.has_ephimeris_data << ", "
112 << "used_in_fix: " << sv.used_in_fix << ", "
113 << "azimuth: " << sv.azimuth << ", "
114 << "elevation: " << sv.elevation
115 << ")";
116}
117}
118}
119}
120
121#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SPACE_VEHICLE_H_
0122
=== modified file 'include/location_service/com/ubuntu/location/units/units.h'
--- include/location_service/com/ubuntu/location/units/units.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/units/units.h 2014-02-03 13:52:45 +0000
@@ -57,6 +57,12 @@
57using boost::units::sin;57using boost::units::sin;
58using boost::units::cos;58using boost::units::cos;
59using boost::units::atan2;59using boost::units::atan2;
60
61template<typename Unit>
62inline bool roughly_equals(const Quantity<Unit>& lhs, const Quantity<Unit>& rhs)
63{
64 return std::fabs(lhs.value()-rhs.value()) <= std::numeric_limits<double>::epsilon();
65}
60}66}
61}67}
62}68}
6369
=== modified file 'include/location_service/com/ubuntu/location/update.h'
--- include/location_service/com/ubuntu/location/update.h 2013-05-29 06:04:02 +0000
+++ include/location_service/com/ubuntu/location/update.h 2014-02-03 13:52:45 +0000
@@ -18,7 +18,7 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_
2020
21#include "com/ubuntu/location/clock.h"21#include <com/ubuntu/location/clock.h>
2222
23#include <ostream>23#include <ostream>
2424
@@ -28,27 +28,56 @@
28{28{
29namespace location29namespace location
30{30{
31/**
32 * @brief Templated class that wraps a value and timestamp.
33 * @tparam T The contained value.
34 */
31template<typename T>35template<typename T>
32struct Update36struct Update
33{37{
34 Update(const T& value = T{}, const Clock::Timestamp& when = Clock::Timestamp{}) : value{value}, when{when}38 /**
39 * @brief Constructs a valid update with the given value and timestamp.
40 * @param [in] value The value delivered with this update.
41 * @param [in] when The timestamp when the value was measured.
42 */
43 inline Update(const T& value = T{},
44 const Clock::Timestamp& when = Clock::now())
45 : value{value}, when{when}
35 {46 {
36 }47 }
3748
38 bool operator==(const Update<T>& rhs) const49 /**
50 * @brief operator == checks if two updates are equal.
51 * @param [in] rhs The update to check against.
52 * @return true iff this instance equals rhs.
53 */
54 inline bool operator==(const Update<T>& rhs) const
39 {55 {
40 return value == rhs.value && when == rhs.when;56 return value == rhs.value && when == rhs.when;
41 }57 }
4258
43 bool operator!=(const Update<T>& rhs) const59 /**
60 * @brief operator != checks if two updates are unequal.
61 * @param [in] rhs The update to check against.
62 * @return true iff this instance does not equal rhs.
63 */
64 inline bool operator!=(const Update<T>& rhs) const
44 {65 {
45 return !(value == rhs.value && when == rhs.when);66 return !(value == rhs.value && when == rhs.when);
46 }67 }
4768
69 /** The value delivered with this update. */
48 T value;70 T value;
49 Clock::Timestamp when;71
72 /** Time when the updated value was measured. */
73 Clock::Timestamp when = Clock::beginning_of_time();
50};74};
5175
76/**
77 * @brief Pretty-prints the update to the provided output stream.
78 * @param out The stream to write to.
79 * @param update The value to be printed.
80 */
52template<typename T>81template<typename T>
53inline std::ostream& operator<<(std::ostream& out, const Update<T>& update)82inline std::ostream& operator<<(std::ostream& out, const Update<T>& update)
54{83{
5584
=== modified file 'include/location_service/com/ubuntu/location/velocity.h'
--- include/location_service/com/ubuntu/location/velocity.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/velocity.h 2014-02-03 13:52:45 +0000
@@ -18,12 +18,7 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_
2020
21#include "com/ubuntu/location/accuracy.h"21#include <com/ubuntu/location/units/units.h>
22#include "com/ubuntu/location/units/units.h"
23
24#include <limits>
25#include <ostream>
26#include <stdexcept>
2722
28namespace com23namespace com
29{24{
@@ -31,74 +26,8 @@
31{26{
32namespace location27namespace location
33{28{
34struct Velocity29/** Velocity is measured in m/s. */
35{30typedef units::Quantity<units::Velocity> Velocity;
36 typedef units::Velocity Unit;
37 typedef units::Quantity<Unit> Quantity;
38
39 static inline const Quantity& min()
40 {
41 static const Quantity instance = Quantity::from_value(0.);
42 return instance;
43 }
44
45 static inline const Quantity max()
46 {
47 static const Quantity instance = Quantity::from_value(std::numeric_limits<double>::max());
48 return instance;
49 }
50
51 Velocity(const Quantity& value = Quantity()) : value(value)
52 {
53 if (value < Velocity::min())
54 throw std::out_of_range("");
55 if (value > Velocity::max())
56 throw std::out_of_range("");
57 }
58
59 inline bool operator==(const Velocity& rhs) const
60 {
61 return value == rhs.value;
62 }
63
64 inline bool operator!=(const Velocity& rhs) const
65 {
66 return value != rhs.value;
67 }
68
69 Quantity value;
70};
71
72inline std::ostream& operator<<(std::ostream& out, const Velocity& velocity)
73{
74 out << "Velocity(" << velocity.value << ")";
75 return out;
76}
77
78template<>
79struct AccuracyTraits<Velocity>
80{
81 static AccuracyLevel classify(const Velocity& h)
82 {
83 if (h.value > (1.f * units::MetersPerSecond))
84 return AccuracyLevel::worst;
85
86 if (h.value <= (1.f * units::MetersPerSecond))
87 return AccuracyLevel::best;
88
89 return AccuracyLevel::worst;
90 }
91
92 static Accuracy<Velocity> best()
93 {
94 return Accuracy<Velocity>{Velocity{Velocity::min()}};
95 }
96
97 static Accuracy<Velocity> worst()
98 {
99 return Accuracy<Velocity>{Velocity{2*units::MetersPerSecond}};
100 }
101};
102}31}
103}32}
104}33}
10534
=== modified file 'include/location_service/com/ubuntu/location/wgs84/altitude.h'
--- include/location_service/com/ubuntu/location/wgs84/altitude.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/wgs84/altitude.h 2014-02-03 13:52:45 +0000
@@ -18,8 +18,8 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_ALTITUDE_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_ALTITUDE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_ALTITUDE_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_ALTITUDE_H_
2020
21#include "com/ubuntu/location/units/units.h"21#include <com/ubuntu/location/units/units.h>
22#include "com/ubuntu/location/wgs84/coordinate.h"22#include <com/ubuntu/location/wgs84/coordinate.h>
2323
24namespace com24namespace com
25{25{
2626
=== modified file 'include/location_service/com/ubuntu/location/wgs84/coordinate.h'
--- include/location_service/com/ubuntu/location/wgs84/coordinate.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/wgs84/coordinate.h 2014-02-03 13:52:45 +0000
@@ -18,7 +18,7 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_COORDINATE_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_COORDINATE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_COORDINATE_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_COORDINATE_H_
2020
21#include "com/ubuntu/location/units/units.h"21#include <com/ubuntu/location/units/units.h>
2222
23#include <ostream>23#include <ostream>
2424
@@ -39,12 +39,14 @@
39};39};
4040
41template<typename Tag, typename UnitType>41template<typename Tag, typename UnitType>
42struct Coordinate42class Coordinate
43{43{
44public:
44 typedef UnitType Unit;45 typedef UnitType Unit;
45 typedef units::Quantity<Unit> Quantity;46 typedef units::Quantity<Unit> Quantity;
4647
47 explicit Coordinate(const Quantity& value = Quantity()) : value(value)48 explicit Coordinate(const Quantity& value = Quantity())
49 : value(value)
48 {50 {
49 CoordinateTraits<Coordinate<Tag,UnitType>>::check_and_throw_if_invalid(value);51 CoordinateTraits<Coordinate<Tag,UnitType>>::check_and_throw_if_invalid(value);
50 }52 }
5153
=== modified file 'include/location_service/com/ubuntu/location/wgs84/latitude.h'
--- include/location_service/com/ubuntu/location/wgs84/latitude.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/wgs84/latitude.h 2014-02-03 13:52:45 +0000
@@ -18,8 +18,8 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_
2020
21#include "com/ubuntu/location/units/units.h"21#include <com/ubuntu/location/units/units.h>
22#include "com/ubuntu/location/wgs84/coordinate.h"22#include <com/ubuntu/location/wgs84/coordinate.h>
2323
24#include <stdexcept>24#include <stdexcept>
2525
2626
=== modified file 'include/location_service/com/ubuntu/location/wgs84/longitude.h'
--- include/location_service/com/ubuntu/location/wgs84/longitude.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/wgs84/longitude.h 2014-02-03 13:52:45 +0000
@@ -18,8 +18,8 @@
18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LONGITUDE_H_18#ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LONGITUDE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LONGITUDE_H_19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LONGITUDE_H_
2020
21#include "com/ubuntu/location/units/units.h"21#include <com/ubuntu/location/units/units.h>
22#include "com/ubuntu/location/wgs84/coordinate.h"22#include <com/ubuntu/location/wgs84/coordinate.h>
2323
24#include <stdexcept>24#include <stdexcept>
2525
2626
=== added file 'include/location_service/com/ubuntu/location/wifi_and_cell_reporting_state.h'
--- include/location_service/com/ubuntu/location/wifi_and_cell_reporting_state.h 1970-01-01 00:00:00 +0000
+++ include/location_service/com/ubuntu/location/wifi_and_cell_reporting_state.h 2014-02-03 13:52:45 +0000
@@ -0,0 +1,36 @@
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_WIFI_AND_CELL_REPORTING_STATE_H_
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WIFI_AND_CELL_REPORTING_STATE_H_
20
21namespace com
22{
23namespace ubuntu
24{
25namespace location
26{
27enum class WifiAndCellIdReportingState
28{
29 on, ///< Wifi and Cell Ids might be reported to online location services.
30 off ///< Wifi and Cell Ids are _not_ reported. This is the default value.
31};
32}
33}
34}
35
36#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WIFI_AND_CELL_REPORTING_STATE_H_
037
=== modified file 'src/location_service/com/ubuntu/location/CMakeLists.txt'
--- src/location_service/com/ubuntu/location/CMakeLists.txt 2013-10-08 14:48:43 +0000
+++ src/location_service/com/ubuntu/location/CMakeLists.txt 2014-02-03 13:52:45 +0000
@@ -5,12 +5,16 @@
55
6 default_provider_selection_policy.cpp6 default_provider_selection_policy.cpp
7 7
8 criteria.cpp
8 engine.cpp9 engine.cpp
9 init_and_shutdown.cpp10 init_and_shutdown.cpp
10 position.cpp11 position.cpp
11 provider.cpp12 provider.cpp
12 provider_factory.cpp13 provider_factory.cpp
13 proxy_provider.cpp14 proxy_provider.cpp
15 set_name_for_thread.cpp
16
17 connectivity/ofono_nm_connectivity_manager.cpp
1418
15 service/default_configuration.cpp19 service/default_configuration.cpp
16 service/default_permission_manager.cpp20 service/default_permission_manager.cpp
@@ -43,6 +47,7 @@
4347
44 ${Boost_LIBRARIES}48 ${Boost_LIBRARIES}
45 ${DBUS_LIBRARIES}49 ${DBUS_LIBRARIES}
50 ${DBUS_CPP_LDFLAGS}
46 ${GLog_LIBRARY}51 ${GLog_LIBRARY}
47 ${GFlags_LIBRARY}52 ${GFlags_LIBRARY}
48)53)
@@ -52,21 +57,54 @@
52 DESTINATION ${CMAKE_INSTALL_LIBDIR}57 DESTINATION ${CMAKE_INSTALL_LIBDIR}
53)58)
5459
60add_library(
61 ubuntu-location-service-daemon
62
63 service/daemon
64)
65
55add_executable(66add_executable(
56 ubuntu-location-serviced67 ubuntu-location-serviced
5768
58 service/main.cpp69 service/daemon_main.cpp
70)
71
72add_executable(
73 ubuntu-location-serviced-cli
74
75 service/daemon_cli_main.cpp
59)76)
6077
61target_link_libraries(78target_link_libraries(
62 ubuntu-location-serviced79 ubuntu-location-service-daemon
6380
64 ubuntu-location-service81 ubuntu-location-service
6582)
66 ${ENABLED_PROVIDER_TARGETS}83
6784target_link_libraries(
68 ${Boost_LIBRARIES}85 ubuntu-location-serviced
69 ${DBUS_LIBRARIES}86
87 ubuntu-location-service-daemon
88
89 ${ENABLED_PROVIDER_TARGETS}
90
91 ${Boost_LIBRARIES}
92 ${DBUS_LIBRARIES}
93 ${DBUS_CPP_LIBRARIES}
94 ${GLog_LIBRARY}
95 ${GFlags_LIBRARY}
96)
97
98target_link_libraries(
99 ubuntu-location-serviced-cli
100
101 ubuntu-location-service-daemon
102
103 ${ENABLED_PROVIDER_TARGETS}
104
105 ${Boost_LIBRARIES}
106 ${DBUS_LIBRARIES}
107 ${DBUS_CPP_LIBRARIES}
70 ${GLog_LIBRARY}108 ${GLog_LIBRARY}
71 ${GFlags_LIBRARY}109 ${GFlags_LIBRARY}
72)110)
@@ -76,3 +114,8 @@
76 DESTINATION ${CMAKE_INSTALL_BINDIR}114 DESTINATION ${CMAKE_INSTALL_BINDIR}
77)115)
78116
117install(
118 TARGETS ubuntu-location-serviced-cli
119 DESTINATION ${CMAKE_INSTALL_BINDIR}
120)
121
79122
=== added directory 'src/location_service/com/ubuntu/location/connectivity'
=== added file 'src/location_service/com/ubuntu/location/connectivity/nm.h'
--- src/location_service/com/ubuntu/location/connectivity/nm.h 1970-01-01 00:00:00 +0000
+++ src/location_service/com/ubuntu/location/connectivity/nm.h 2014-02-03 13:52:45 +0000
@@ -0,0 +1,255 @@
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_CONNECTIVITY_NM_H
19#define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_NM_H
20
21#include <core/dbus/bus.h>
22#include <core/dbus/object.h>
23#include <core/dbus/property.h>
24#include <core/dbus/service.h>
25#include <core/dbus/types/object_path.h>
26#include <core/dbus/types/struct.h>
27#include <core/dbus/types/stl/map.h>
28#include <core/dbus/types/stl/string.h>
29#include <core/dbus/types/stl/tuple.h>
30#include <core/dbus/types/stl/vector.h>
31
32namespace org
33{
34namespace freedesktop
35{
36struct NetworkManager
37{
38 struct AccessPoint
39 {
40 static const std::string& name()
41 {
42 static const std::string s{"org.freedesktop.NetworkManager.AccessPoint"};
43 return s;
44 }
45
46 struct Frequency
47 {
48 static const std::string& name()
49 {
50 static const std::string s{"Frequency"};
51 return s;
52 }
53
54 typedef AccessPoint Interface;
55 typedef std::uint32_t ValueType;
56 static const bool readable = true;
57 static const bool writable = false;
58 };
59
60 struct HwAddress
61 {
62 static const std::string& name()
63 {
64 static const std::string s{"HwAddress"};
65 return s;
66 }
67
68 typedef AccessPoint Interface;
69 typedef std::string ValueType;
70 static const bool readable = true;
71 static const bool writable = false;
72 };
73
74 struct Strength
75 {
76 static const std::string& name()
77 {
78 static const std::string s{"Strength"};
79 return s;
80 }
81
82 typedef AccessPoint Interface;
83 typedef std::int8_t ValueType;
84 static const bool readable = true;
85 static const bool writable = false;
86 };
87
88 AccessPoint(const std::shared_ptr<core::dbus::Object>& object)
89 : frequency(object->get_property<Frequency>()),
90 hw_address(object->get_property<HwAddress>()),
91 strength(object->get_property<Strength>())
92 {
93 }
94
95 std::shared_ptr<core::dbus::Property<Frequency>> frequency;
96 std::shared_ptr<core::dbus::Property<HwAddress>> hw_address;
97 std::shared_ptr<core::dbus::Property<Strength>> strength;
98 };
99
100 struct Device
101 {
102 static const std::string& name()
103 {
104 static const std::string s{"org.freedesktop.NetworkManager.Device"};
105 return s;
106 }
107
108 enum class Type
109 {
110 unknown = 0,
111 ethernet = 1,
112 wifi = 2,
113 unused_1 = 3,
114 unused_2 = 4,
115 bluetooth = 5,
116 olpc_mesh = 6,
117 wimax = 7,
118 modem = 8,
119 infiniband = 9,
120 bond = 10,
121 vlan = 11,
122 adsl = 12,
123 bridge = 13
124 };
125
126 struct Wireless
127 {
128 static const std::string& name()
129 {
130 static const std::string s{"org.freedesktop.NetworkManager.Device.Wireless"};
131 return s;
132 }
133
134 struct GetAccessPoints
135 {
136 static const std::string& name()
137 {
138 static const std::string s{"GetAccessPoints"};
139 return s;
140 }
141
142 typedef Wireless Interface;
143
144 static std::chrono::milliseconds default_timeout()
145 {
146 return std::chrono::seconds{1};
147 }
148 };
149 };
150
151 struct DeviceType
152 {
153 static const std::string& name()
154 {
155 static const std::string s{"DeviceType"};
156 return s;
157 }
158
159 typedef Device Interface;
160 typedef std::uint32_t ValueType;
161 static const bool readable = true;
162 static const bool writable = false;
163 };
164
165 Device(const std::shared_ptr<core::dbus::Service>& service,
166 const std::shared_ptr<core::dbus::Object>& object)
167 : service(service),
168 object(object),
169 device_type(object->get_property<DeviceType>())
170 {
171 }
172
173 Type type() const
174 {
175 return static_cast<Type>(device_type->get());
176 }
177
178 std::vector<AccessPoint> get_access_points() const
179 {
180 typedef std::vector<core::dbus::types::ObjectPath> ResultType;
181 auto result = object->invoke_method_synchronously<Wireless::GetAccessPoints, ResultType>();
182
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches