Merge lp:~mandel/location-service/add-auto-formatting into lp:location-service/trunk

Proposed by Manuel de la Peña
Status: Approved
Approved by: Thomas Voß
Approved revision: 191
Proposed branch: lp:~mandel/location-service/add-auto-formatting
Merge into: lp:location-service/trunk
Diff against target: 30592 lines (+11828/-10771)
162 files modified
CMakeLists.txt (+35/-0)
_clang-format (+48/-0)
astyle-config (+44/-0)
include/location_service/com/ubuntu/location/accuracy.h (+17/-12)
include/location_service/com/ubuntu/location/clock.h (+1/-1)
include/location_service/com/ubuntu/location/codec.h (+54/-44)
include/location_service/com/ubuntu/location/configuration.h (+1/-1)
include/location_service/com/ubuntu/location/connectivity/bounded_integer.h (+15/-15)
include/location_service/com/ubuntu/location/connectivity/manager.h (+2/-4)
include/location_service/com/ubuntu/location/connectivity/radio_cell.h (+54/-117)
include/location_service/com/ubuntu/location/connectivity/wireless_network.h (+9/-15)
include/location_service/com/ubuntu/location/criteria.h (+13/-9)
include/location_service/com/ubuntu/location/default_provider_selection_policy.h (+10/-17)
include/location_service/com/ubuntu/location/heading.h (+1/-1)
include/location_service/com/ubuntu/location/init_and_shutdown.h (+1/-1)
include/location_service/com/ubuntu/location/logging.h (+1/-2)
include/location_service/com/ubuntu/location/optional.h (+2/-2)
include/location_service/com/ubuntu/location/position.h (+10/-3)
include/location_service/com/ubuntu/location/provider.h (+14/-16)
include/location_service/com/ubuntu/location/provider_enumerator.h (+1/-1)
include/location_service/com/ubuntu/location/provider_factory.h (+7/-5)
include/location_service/com/ubuntu/location/provider_selection.h (+10/-4)
include/location_service/com/ubuntu/location/provider_selection_policy.h (+3/-4)
include/location_service/com/ubuntu/location/providers/geoclue/geoclue.h (+55/-23)
include/location_service/com/ubuntu/location/providers/geoclue/provider.h (+11/-5)
include/location_service/com/ubuntu/location/providers/remote/interface.h (+45/-70)
include/location_service/com/ubuntu/location/providers/remote/skeleton.h (+7/-3)
include/location_service/com/ubuntu/location/providers/remote/stub.h (+7/-3)
include/location_service/com/ubuntu/location/providers/skyhook/provider.h (+16/-7)
include/location_service/com/ubuntu/location/proxy_provider.h (+2/-2)
include/location_service/com/ubuntu/location/satellite_based_positioning_state.h (+3/-3)
include/location_service/com/ubuntu/location/service/configuration.h (+4/-5)
include/location_service/com/ubuntu/location/service/default_permission_manager.h (+6/-8)
include/location_service/com/ubuntu/location/service/interface.h (+10/-28)
include/location_service/com/ubuntu/location/service/permission_manager.h (+5/-7)
include/location_service/com/ubuntu/location/service/session/implementation.h (+3/-3)
include/location_service/com/ubuntu/location/service/session/interface.h (+4/-4)
include/location_service/com/ubuntu/location/service/session/skeleton.h (+1/-1)
include/location_service/com/ubuntu/location/service/session/stub.h (+4/-6)
include/location_service/com/ubuntu/location/service/skeleton.h (+15/-17)
include/location_service/com/ubuntu/location/service/stub.h (+4/-4)
include/location_service/com/ubuntu/location/space_vehicle.h (+35/-38)
include/location_service/com/ubuntu/location/units/units.h (+10/-11)
include/location_service/com/ubuntu/location/update.h (+10/-11)
include/location_service/com/ubuntu/location/velocity.h (+1/-1)
include/location_service/com/ubuntu/location/wgs84/altitude.h (+5/-3)
include/location_service/com/ubuntu/location/wgs84/coordinate.h (+11/-11)
include/location_service/com/ubuntu/location/wgs84/latitude.h (+6/-2)
include/location_service/com/ubuntu/location/wgs84/longitude.h (+6/-2)
include/location_service/com/ubuntu/location/wifi_and_cell_reporting_state.h (+3/-3)
src/location_service/com/ubuntu/location/boost_ptree_settings.cpp (+3/-2)
src/location_service/com/ubuntu/location/boost_ptree_settings.h (+1/-1)
src/location_service/com/ubuntu/location/connectivity/cached_radio_cell.cpp (+334/-350)
src/location_service/com/ubuntu/location/connectivity/cached_radio_cell.h (+9/-10)
src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp (+73/-96)
src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h (+3/-4)
src/location_service/com/ubuntu/location/connectivity/dummy_connectivity_manager.h (+9/-5)
src/location_service/com/ubuntu/location/connectivity/manager.cpp (+58/-19)
src/location_service/com/ubuntu/location/connectivity/nm.h (+66/-68)
src/location_service/com/ubuntu/location/connectivity/ofono.h (+522/-600)
src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.cpp (+390/-348)
src/location_service/com/ubuntu/location/connectivity/ofono_nm_connectivity_manager.h (+54/-39)
src/location_service/com/ubuntu/location/connectivity/radio_cell.cpp (+31/-26)
src/location_service/com/ubuntu/location/connectivity/wireless_network.cpp (+10/-5)
src/location_service/com/ubuntu/location/criteria.cpp (+24/-6)
src/location_service/com/ubuntu/location/default_permission_manager.cpp (+6/-5)
src/location_service/com/ubuntu/location/default_provider_selection_policy.cpp (+56/-72)
src/location_service/com/ubuntu/location/engine.cpp (+156/-145)
src/location_service/com/ubuntu/location/engine.h (+24/-48)
src/location_service/com/ubuntu/location/non_selecting_provider_selection_policy.cpp (+50/-33)
src/location_service/com/ubuntu/location/non_selecting_provider_selection_policy.h (+1/-1)
src/location_service/com/ubuntu/location/position.cpp (+27/-22)
src/location_service/com/ubuntu/location/provider.cpp (+43/-15)
src/location_service/com/ubuntu/location/provider_factory.cpp (+8/-15)
src/location_service/com/ubuntu/location/providers/config.cpp (+14/-29)
src/location_service/com/ubuntu/location/providers/dummy/provider.cpp (+54/-68)
src/location_service/com/ubuntu/location/providers/dummy/provider.h (+16/-58)
src/location_service/com/ubuntu/location/providers/geoclue/provider.cpp (+77/-90)
src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.cpp (+153/-168)
src/location_service/com/ubuntu/location/providers/gps/android_hardware_abstraction_layer.h (+25/-22)
src/location_service/com/ubuntu/location/providers/gps/hardware_abstraction_layer.h (+3/-3)
src/location_service/com/ubuntu/location/providers/gps/net_cpp_gps_xtra_downloader.h (+26/-11)
src/location_service/com/ubuntu/location/providers/gps/null_gps_xtra_downloader.h (+19/-3)
src/location_service/com/ubuntu/location/providers/gps/provider.cpp (+16/-17)
src/location_service/com/ubuntu/location/providers/gps/provider.h (+6/-5)
src/location_service/com/ubuntu/location/providers/remote/provider.cpp (+378/-319)
src/location_service/com/ubuntu/location/providers/remote/provider.h (+1/-1)
src/location_service/com/ubuntu/location/providers/remote/skeleton.cpp (+2/-1)
src/location_service/com/ubuntu/location/providers/skyhook/provider.cpp (+43/-45)
src/location_service/com/ubuntu/location/proxy_provider.cpp (+16/-21)
src/location_service/com/ubuntu/location/satellite_based_positioning_state.cpp (+19/-19)
src/location_service/com/ubuntu/location/service/daemon.cpp (+210/-215)
src/location_service/com/ubuntu/location/service/daemon.h (+9/-21)
src/location_service/com/ubuntu/location/service/daemon_cli_main.cpp (+4/-2)
src/location_service/com/ubuntu/location/service/daemon_main.cpp (+4/-2)
src/location_service/com/ubuntu/location/service/dbus_connection_factory.h (+2/-5)
src/location_service/com/ubuntu/location/service/default_configuration.cpp (+3/-3)
src/location_service/com/ubuntu/location/service/default_configuration.h (+5/-6)
src/location_service/com/ubuntu/location/service/default_permission_manager.cpp (+6/-5)
src/location_service/com/ubuntu/location/service/demultiplexing_reporter.cpp (+12/-8)
src/location_service/com/ubuntu/location/service/demultiplexing_reporter.h (+13/-3)
src/location_service/com/ubuntu/location/service/harvester.cpp (+20/-12)
src/location_service/com/ubuntu/location/service/harvester.h (+1/-2)
src/location_service/com/ubuntu/location/service/ichnaea_reporter.cpp (+149/-118)
src/location_service/com/ubuntu/location/service/ichnaea_reporter.h (+23/-28)
src/location_service/com/ubuntu/location/service/implementation.cpp (+69/-90)
src/location_service/com/ubuntu/location/service/implementation.h (+2/-2)
src/location_service/com/ubuntu/location/service/program_options.h (+51/-50)
src/location_service/com/ubuntu/location/service/provider_daemon.cpp (+49/-60)
src/location_service/com/ubuntu/location/service/provider_daemon.h (+1/-1)
src/location_service/com/ubuntu/location/service/provider_daemon_main.cpp (+2/-4)
src/location_service/com/ubuntu/location/service/runtime_tests.cpp (+43/-36)
src/location_service/com/ubuntu/location/service/runtime_tests.h (+1/-1)
src/location_service/com/ubuntu/location/service/session/implementation.cpp (+50/-55)
src/location_service/com/ubuntu/location/service/session/interface.cpp (+2/-1)
src/location_service/com/ubuntu/location/service/session/interface_p.h (+48/-51)
src/location_service/com/ubuntu/location/service/session/skeleton.cpp (+91/-85)
src/location_service/com/ubuntu/location/service/session/stub.cpp (+96/-85)
src/location_service/com/ubuntu/location/service/skeleton.cpp (+83/-127)
src/location_service/com/ubuntu/location/service/stub.cpp (+19/-17)
src/location_service/com/ubuntu/location/service/trust_store_permission_manager.cpp (+42/-52)
src/location_service/com/ubuntu/location/service/trust_store_permission_manager.h (+3/-4)
src/location_service/com/ubuntu/location/set_name_for_thread.h (+1/-1)
src/location_service/com/ubuntu/location/settings.cpp (+2/-0)
src/location_service/com/ubuntu/location/settings.h (+24/-13)
src/location_service/com/ubuntu/location/wifi_and_cell_reporting_state.cpp (+19/-19)
tests/acceptance_tests.cpp (+272/-309)
tests/connectivity_manager_test.cpp (+133/-114)
tests/controller_test.cpp (+11/-21)
tests/daemon_and_cli_tests.cpp (+48/-71)
tests/default_permission_manager_test.cpp (+2/-3)
tests/demultiplexing_reporter_test.cpp (+6/-10)
tests/did_finish_successfully.h (+5/-1)
tests/dummy_provider_tests.cpp (+11/-16)
tests/engine_test.cpp (+50/-67)
tests/espoo_provider_test.cpp (+143/-137)
tests/geoclue_provider_test.cpp (+2/-3)
tests/gps_provider_test.cpp (+139/-188)
tests/harvester_test.cpp (+9/-25)
tests/heading_test.cpp (+7/-6)
tests/ichnaea_reporter_test.cpp (+41/-83)
tests/mock_connectivity_manager.h (+15/-16)
tests/mock_event_consumer.h (+17/-17)
tests/mock_network_manager.h (+81/-77)
tests/mock_ofono.h (+82/-51)
tests/mock_provider.h (+11/-6)
tests/mock_reporter.h (+4/-5)
tests/mongoose.c (+5311/-4272)
tests/mongoose.h (+105/-96)
tests/null_provider_selection_policy.h (+6/-11)
tests/position_test.cpp (+11/-19)
tests/provider_factory_test.cpp (+13/-11)
tests/provider_selection_policy_test.cpp (+51/-59)
tests/provider_test.cpp (+66/-45)
tests/remote_provider_test.cpp (+199/-214)
tests/remote_providerd_test.cpp (+120/-116)
tests/session_test.cpp (+37/-25)
tests/trust_store_permission_manager_test.cpp (+47/-53)
tests/web_server.h (+21/-19)
tests/wgs84_test.cpp (+57/-51)
tools/CMakeLists.txt (+1/-0)
tools/formatcode.in (+67/-0)
To merge this branch: bzr merge lp:~mandel/location-service/add-auto-formatting
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) code, wait a bit more to land. Disapprove
Thomas Voß (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+257240@code.launchpad.net

Commit message

Add the autoformatting used in the diff projects from the team.

Description of the change

Add the autoformatting used in the diff projects from the team.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
185. By Manuel de la Peña

Run the autoformatting code.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
186. By Manuel de la Peña

Reverted the format changes and added the missing _clang_format file.

187. By Manuel de la Peña

Add missin astyle file.

188. By Manuel de la Peña

Performed style rule.

189. By Manuel de la Peña

Revert style changes.

190. By Manuel de la Peña

Merged with trunk.

191. By Manuel de la Peña

Ran format job.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Thomas Voß (thomas-voss) wrote :

LGTM.

review: Approve
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

I'd like to put this landing on hold until we sort out the remaining critical issues with location-service (and make it reliable).

Landing a big cosmetic change creates a huge pain later on when tracing back changes and bisecting problems, for really no benefit. While I understand it's good to have a code style pattern, at this point I feel it could end up creating more problems for us.

We can land this once we're more comfortable with the codebase.

review: Disapprove (code, wait a bit more to land.)

Unmerged revisions

191. By Manuel de la Peña

Ran format job.

190. By Manuel de la Peña

Merged with trunk.

189. By Manuel de la Peña

Revert style changes.

188. By Manuel de la Peña

Performed style rule.

187. By Manuel de la Peña

Add missin astyle file.

186. By Manuel de la Peña

Reverted the format changes and added the missing _clang_format file.

185. By Manuel de la Peña

Run the autoformatting code.

184. By Manuel de la Peña

Add auto-formatting shared between diff projects from the team.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-09-18 23:06:08 +0000
+++ CMakeLists.txt 2015-04-23 17:23:49 +0000
@@ -54,6 +54,41 @@
54 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs")54 SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs")
55endif (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)55endif (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS)
5656
57
58#
59# Code style fixer. We put the code through astyle first because it makes some fixes that
60# clang-format won't do (such as "char *p" -> "char* p"). But astyle messes up other things
61# (particularly lambdas and assembly-style comments), which clang-format does right.
62# So, we run clang-format after running astyle, which undoes the damage done by astyle
63# without reverting desirable astyle fixes.
64#
65
66find_program(ASTYLE_COMMAND NAMES astyle)
67if (NOT ASTYLE_COMMAND)
68 message(WARNING "Cannot find astyle: formatcode target will not be available")
69else()
70 # astyle 2.03 creates DOS line endings, so we need to fix its output
71 find_program(DOS2UNIX_COMMAND NAMES dos2unix)
72 if (NOT DOS2UNIX_COMMAND)
73 message(WARNING "Cannot find dos2unix: formatcode target will not be available")
74 else()
75 find_program(CLANG_FORMAT_COMMAND NAMES clang-format-3.6 clang-format-3.5)
76 if (NOT CLANG_FORMAT_COMMAND)
77 message(WARNING "Cannot find clang-format >= clang-format-3.5: formatcode target will not be available")
78 endif()
79 endif()
80endif()
81
82if (ASTYLE_COMMAND AND DOS2UNIX_COMMAND AND CLANG_FORMAT_COMMAND)
83 add_subdirectory(tools)
84 add_custom_target(
85 format
86 ${CMAKE_BINARY_DIR}/tools/formatcode ${CMAKE_SOURCE_DIR}/src ${ASTYLE_COMMAND} ${CLANG_FORMAT_COMMAND}
87 COMMAND ${CMAKE_BINARY_DIR}/tools/formatcode ${CMAKE_SOURCE_DIR}/include ${ASTYLE_COMMAND} ${CLANG_FORMAT_COMMAND}
88 COMMAND ${CMAKE_BINARY_DIR}/tools/formatcode ${CMAKE_SOURCE_DIR}/tests ${ASTYLE_COMMAND} ${CLANG_FORMAT_COMMAND}
89 )
90endif()
91
57include_directories(92include_directories(
58 ${Boost_INCLUDE_DIRS}93 ${Boost_INCLUDE_DIRS}
59 ${DBUS_INCLUDE_DIRS}94 ${DBUS_INCLUDE_DIRS}
6095
=== added file '_clang-format'
--- _clang-format 1970-01-01 00:00:00 +0000
+++ _clang-format 2015-04-23 17:23:49 +0000
@@ -0,0 +1,48 @@
1---
2AccessModifierOffset: -4
3AlignEscapedNewlinesLeft: true
4AlignTrailingComments: true
5AllowAllParametersOfDeclarationOnNextLine: true
6AllowShortFunctionsOnASingleLine: false
7AllowShortIfStatementsOnASingleLine: false
8AllowShortLoopsOnASingleLine: false
9AlwaysBreakBeforeMultilineStrings: true
10AlwaysBreakTemplateDeclarations: true
11BinPackParameters: false
12BreakBeforeBinaryOperators: false
13BreakBeforeBraces: Allman
14BreakBeforeTernaryOperators: false
15BreakConstructorInitializersBeforeComma: true
16ColumnLimit: 120
17ConstructorInitializerAllOnOneLineOrOnePerLine: false
18ConstructorInitializerIndentWidth: 4
19ContinuationIndentWidth: 4
20Cpp11BracedListStyle: true
21DerivePointerBinding: true
22ExperimentalAutoDetectBinPacking: false
23IndentCaseLabels: true
24IndentFunctionDeclarationAfterType: true
25IndentWidth: 4
26Language: Cpp
27MaxEmptyLinesToKeep: 1
28NamespaceIndentation: None
29ObjCSpaceBeforeProtocolList: false
30PenaltyBreakBeforeFirstCallParameter: 1
31PenaltyBreakComment: 100
32PenaltyBreakFirstLessLess: 120
33PenaltyBreakString: 1000
34PenaltyExcessCharacter: 1000000
35PenaltyReturnTypeOnItsOwnLine: 200
36PointerBindsToType: true
37SpaceBeforeAssignmentOperators: true
38SpaceBeforeParens: ControlStatements
39SpaceInEmptyParentheses: false
40SpacesBeforeTrailingComments: 2
41SpacesInAngles: false
42SpacesInCStyleCastParentheses: false
43SpacesInParentheses: false
44Standard: Cpp11
45TabWidth: 8
46UseTab: Never
47...
48
049
=== added file 'astyle-config'
--- astyle-config 1970-01-01 00:00:00 +0000
+++ astyle-config 2015-04-23 17:23:49 +0000
@@ -0,0 +1,44 @@
1# Options for formatting code with astyle.
2#
3# This helps to make code match the style guide.
4#
5# Use like this:
6#
7# astyle --options=astyle-config mfile.h myfile.cpp
8#
9# Occasionally, astyle does something silly (particularly with lambdas), so it's
10# still necessary to scan the changes for things that are wrong.
11# But, for most files, it does a good job.
12#
13# Please consider using this before checking code in for review. Code reviews shouldn't
14# have to deal with layout issues, they are just a distraction. It's better to be able
15# to focus on semantics in a code review, with style issues out of the way.
16
17--formatted
18--style=allman
19--min-conditional-indent=2
20--indent-switches
21--max-instatement-indent=120
22--pad-header
23--align-pointer=type
24--align-reference=type
25--add-brackets
26--convert-tabs
27--close-templates
28--max-code-length=120
29
30# --pad-oper
31#
32# Commented out for now. It changes
33#
34# for (int i=0; i<10; ++i)
35# to
36# for (int i = 0; i < 10; ++i)
37#
38# Unfortunately, it also messes with rvalue references:
39#
40# ResourcePtr& operator=(ResourcePtr&& r);
41#
42# becomes:
43#
44# ResourcePtr& operator=(ResourcePtr && r);
045
=== modified file 'include/location_service/com/ubuntu/location/accuracy.h'
--- include/location_service/com/ubuntu/location/accuracy.h 2013-05-28 14:41:06 +0000
+++ include/location_service/com/ubuntu/location/accuracy.h 2015-04-23 17:23:49 +0000
@@ -34,12 +34,12 @@
34 postalcode,34 postalcode,
35 street,35 street,
36 detailed,36 detailed,
37 37
38 best = detailed,38 best = detailed,
39 worst = country39 worst = country
40};40};
4141
42template<typename T>42template <typename T>
43struct AccuracyTraits43struct AccuracyTraits
44{44{
45 static AccuracyLevel classify(const T& instance);45 static AccuracyLevel classify(const T& instance);
@@ -47,14 +47,20 @@
47 static T worst();47 static T worst();
48};48};
4949
50template<typename T>50template <typename T>
51struct Accuracy51struct Accuracy
52{52{
53 typedef typename T::Unit Unit;53 typedef typename T::Unit Unit;
54 typedef typename T::Quantity Quantity;54 typedef typename T::Quantity Quantity;
5555
56 static Accuracy<T> best() { return AccuracyTraits<T>::best(); }56 static Accuracy<T> best()
57 static Accuracy<T> worst() { return AccuracyTraits<T>::worst(); }57 {
58 return AccuracyTraits<T>::best();
59 }
60 static Accuracy<T> worst()
61 {
62 return AccuracyTraits<T>::worst();
63 }
5864
59 AccuracyLevel classify() const65 AccuracyLevel classify() const
60 {66 {
@@ -64,15 +70,14 @@
64 T value;70 T value;
65};71};
6672
67template<typename T>73template <typename T>
68inline std::ostream& operator<<(std::ostream& out, const Accuracy<T>& update)74inline std::ostream& operator<<(std::ostream& out, const Accuracy<T>& update)
69{75{
70 out << "Accuracy(" << update.value << ")";76 out << "Accuracy(" << update.value << ")";
71 return out;77 return out;
72}78}
7379}
74}80}
75}81}
76}82
7783#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_ACCURACY_H_
78#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_ACCURACY_H_
7984
=== modified file 'include/location_service/com/ubuntu/location/clock.h'
--- include/location_service/com/ubuntu/location/clock.h 2013-12-16 12:37:07 +0000
+++ include/location_service/com/ubuntu/location/clock.h 2015-04-23 17:23:49 +0000
@@ -66,4 +66,4 @@
66}66}
67}67}
6868
69#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CLOCK_H_69#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CLOCK_H_
7070
=== modified file 'include/location_service/com/ubuntu/location/codec.h'
--- include/location_service/com/ubuntu/location/codec.h 2014-09-12 15:04:21 +0000
+++ include/location_service/com/ubuntu/location/codec.h 2015-04-23 17:23:49 +0000
@@ -38,7 +38,7 @@
38{38{
39namespace helper39namespace helper
40{40{
41template<typename T>41template <typename T>
42struct TypeMapper<com::ubuntu::location::units::Quantity<T>>42struct TypeMapper<com::ubuntu::location::units::Quantity<T>>
43{43{
44 constexpr static ArgumentType type_value()44 constexpr static ArgumentType type_value()
@@ -63,7 +63,7 @@
63};63};
64}64}
6565
66template<typename T>66template <typename T>
67struct Codec<com::ubuntu::location::Optional<T>>67struct Codec<com::ubuntu::location::Optional<T>>
68{68{
69 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Optional<T>& in)69 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Optional<T>& in)
@@ -71,7 +71,9 @@
71 bool has_value{in};71 bool has_value{in};
72 Codec<bool>::encode_argument(writer, has_value);72 Codec<bool>::encode_argument(writer, has_value);
73 if (has_value)73 if (has_value)
74 {
74 Codec<typename com::ubuntu::location::Optional<T>::value_type>::encode_argument(writer, *in);75 Codec<typename com::ubuntu::location::Optional<T>::value_type>::encode_argument(writer, *in);
76 }
75 }77 }
7678
77 static void decode_argument(Message::Reader& reader, com::ubuntu::location::Optional<T>& in)79 static void decode_argument(Message::Reader& reader, com::ubuntu::location::Optional<T>& in)
@@ -83,14 +85,15 @@
83 typename com::ubuntu::location::Optional<T>::value_type value;85 typename com::ubuntu::location::Optional<T>::value_type value;
84 Codec<typename com::ubuntu::location::Optional<T>::value_type>::decode_argument(reader, value);86 Codec<typename com::ubuntu::location::Optional<T>::value_type>::decode_argument(reader, value);
85 in = value;87 in = value;
86 } else88 }
89 else
87 {90 {
88 in.reset();91 in.reset();
89 }92 }
90 }93 }
91};94};
9295
93template<typename T>96template <typename T>
94struct Codec<com::ubuntu::location::units::Quantity<T>>97struct Codec<com::ubuntu::location::units::Quantity<T>>
95{98{
96 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::units::Quantity<T>& in)99 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::units::Quantity<T>& in)
@@ -106,8 +109,8 @@
106 }109 }
107};110};
108111
109template<typename T, typename U>112template <typename T, typename U>
110struct Codec<com::ubuntu::location::wgs84::Coordinate<T,U>>113struct Codec<com::ubuntu::location::wgs84::Coordinate<T, U>>
111{114{
112 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::wgs84::Coordinate<T, U>& in)115 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::wgs84::Coordinate<T, U>& in)
113 {116 {
@@ -120,7 +123,7 @@
120 }123 }
121};124};
122125
123template<>126template <>
124struct Codec<com::ubuntu::location::Position>127struct Codec<com::ubuntu::location::Position>
125{128{
126 typedef com::ubuntu::location::Position::Accuracy::Horizontal HorizontalAccuracy;129 typedef com::ubuntu::location::Position::Accuracy::Horizontal HorizontalAccuracy;
@@ -130,7 +133,8 @@
130 {133 {
131 Codec<com::ubuntu::location::wgs84::Latitude>::encode_argument(writer, in.latitude);134 Codec<com::ubuntu::location::wgs84::Latitude>::encode_argument(writer, in.latitude);
132 Codec<com::ubuntu::location::wgs84::Longitude>::encode_argument(writer, in.longitude);135 Codec<com::ubuntu::location::wgs84::Longitude>::encode_argument(writer, in.longitude);
133 Codec<com::ubuntu::location::Optional<com::ubuntu::location::wgs84::Altitude>>::encode_argument(writer, in.altitude);136 Codec<com::ubuntu::location::Optional<com::ubuntu::location::wgs84::Altitude>>::encode_argument(writer,
137 in.altitude);
134138
135 Codec<com::ubuntu::location::Optional<HorizontalAccuracy>>::encode_argument(writer, in.accuracy.horizontal);139 Codec<com::ubuntu::location::Optional<HorizontalAccuracy>>::encode_argument(writer, in.accuracy.horizontal);
136 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::encode_argument(writer, in.accuracy.vertical);140 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::encode_argument(writer, in.accuracy.vertical);
@@ -140,17 +144,17 @@
140 {144 {
141 Codec<com::ubuntu::location::wgs84::Latitude>::decode_argument(reader, in.latitude);145 Codec<com::ubuntu::location::wgs84::Latitude>::decode_argument(reader, in.latitude);
142 Codec<com::ubuntu::location::wgs84::Longitude>::decode_argument(reader, in.longitude);146 Codec<com::ubuntu::location::wgs84::Longitude>::decode_argument(reader, in.longitude);
143 Codec<com::ubuntu::location::Optional<com::ubuntu::location::wgs84::Altitude>>::decode_argument(reader, in.altitude);147 Codec<com::ubuntu::location::Optional<com::ubuntu::location::wgs84::Altitude>>::decode_argument(reader,
148 in.altitude);
144149
145 Codec<com::ubuntu::location::Optional<HorizontalAccuracy>>::decode_argument(reader, in.accuracy.horizontal);150 Codec<com::ubuntu::location::Optional<HorizontalAccuracy>>::decode_argument(reader, in.accuracy.horizontal);
146 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::decode_argument(reader, in.accuracy.vertical);151 Codec<com::ubuntu::location::Optional<VerticalAccuracy>>::decode_argument(reader, in.accuracy.vertical);
147 }152 }
148};153};
149154
150
151namespace helper155namespace helper
152{156{
153template<>157template <>
154struct TypeMapper<com::ubuntu::location::SpaceVehicle::Key>158struct TypeMapper<com::ubuntu::location::SpaceVehicle::Key>
155{159{
156 constexpr static ArgumentType type_value()160 constexpr static ArgumentType type_value()
@@ -169,12 +173,11 @@
169 static std::string signature()173 static std::string signature()
170 {174 {
171 static const std::string s =175 static const std::string s =
172 helper::TypeMapper<std::uint32_t>::signature() +176 helper::TypeMapper<std::uint32_t>::signature() + helper::TypeMapper<std::uint32_t>::signature();
173 helper::TypeMapper<std::uint32_t>::signature();
174 return s;177 return s;
175 }178 }
176};179};
177template<>180template <>
178struct TypeMapper<com::ubuntu::location::SpaceVehicle>181struct TypeMapper<com::ubuntu::location::SpaceVehicle>
179{182{
180 constexpr static ArgumentType type_value()183 constexpr static ArgumentType type_value()
@@ -194,20 +197,20 @@
194 {197 {
195 std::string s =198 std::string s =
196 DBUS_STRUCT_BEGIN_CHAR_AS_STRING +199 DBUS_STRUCT_BEGIN_CHAR_AS_STRING +
197 helper::TypeMapper<com::ubuntu::location::SpaceVehicle::Key>::signature() +200 helper::TypeMapper<com::ubuntu::location::SpaceVehicle::Key>::signature() +
198 helper::TypeMapper<float>::signature() +201 helper::TypeMapper<float>::signature() + helper::TypeMapper<bool>::signature() +
199 helper::TypeMapper<bool>::signature() +202 helper::TypeMapper<bool>::signature() + helper::TypeMapper<bool>::signature() +
200 helper::TypeMapper<bool>::signature() +203 helper::TypeMapper<
201 helper::TypeMapper<bool>::signature() +204 com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +
202 helper::TypeMapper<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +205 helper::TypeMapper<
203 helper::TypeMapper<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +206 com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::signature() +
204 DBUS_STRUCT_END_CHAR_AS_STRING;207 DBUS_STRUCT_END_CHAR_AS_STRING;
205 return s;208 return s;
206 }209 }
207};210};
208}211}
209212
210template<>213template <>
211struct Codec<com::ubuntu::location::SpaceVehicle::Key>214struct Codec<com::ubuntu::location::SpaceVehicle::Key>
212{215{
213 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::SpaceVehicle::Key& in)216 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::SpaceVehicle::Key& in)
@@ -223,7 +226,7 @@
223 }226 }
224};227};
225228
226template<>229template <>
227struct Codec<com::ubuntu::location::SpaceVehicle>230struct Codec<com::ubuntu::location::SpaceVehicle>
228{231{
229 inline static void encode_argument(Message::Writer& writer, const com::ubuntu::location::SpaceVehicle& in)232 inline static void encode_argument(Message::Writer& writer, const com::ubuntu::location::SpaceVehicle& in)
@@ -235,8 +238,10 @@
235 sub.push_boolean(in.has_almanac_data);238 sub.push_boolean(in.has_almanac_data);
236 sub.push_boolean(in.has_ephimeris_data);239 sub.push_boolean(in.has_ephimeris_data);
237 sub.push_boolean(in.used_in_fix);240 sub.push_boolean(in.used_in_fix);
238 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::encode_argument(sub, in.azimuth);241 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::encode_argument(
239 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::encode_argument(sub, in.elevation);242 sub, in.azimuth);
243 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::encode_argument(
244 sub, in.elevation);
240245
241 writer.close_structure(std::move(sub));246 writer.close_structure(std::move(sub));
242 }247 }
@@ -250,14 +255,16 @@
250 in.has_almanac_data = sub.pop_boolean();255 in.has_almanac_data = sub.pop_boolean();
251 in.has_ephimeris_data = sub.pop_boolean();256 in.has_ephimeris_data = sub.pop_boolean();
252 in.used_in_fix = sub.pop_boolean();257 in.used_in_fix = sub.pop_boolean();
253 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::decode_argument(sub, in.azimuth);258 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::decode_argument(
254 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::decode_argument(sub, in.elevation);259 sub, in.azimuth);
260 Codec<com::ubuntu::location::units::Quantity<com::ubuntu::location::units::PlaneAngle>>::decode_argument(
261 sub, in.elevation);
255 }262 }
256};263};
257264
258namespace helper265namespace helper
259{266{
260template<>267template <>
261struct TypeMapper<std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>>268struct TypeMapper<std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>>
262{269{
263 constexpr static ArgumentType type_value()270 constexpr static ArgumentType type_value()
@@ -275,20 +282,23 @@
275282
276 static std::string signature()283 static std::string signature()
277 {284 {
278 static const std::string s = DBUS_TYPE_ARRAY_AS_STRING + TypeMapper<com::ubuntu::location::SpaceVehicle>::signature();285 static const std::string s =
286 DBUS_TYPE_ARRAY_AS_STRING + TypeMapper<com::ubuntu::location::SpaceVehicle>::signature();
279 return s;287 return s;
280 }288 }
281};289};
282}290}
283template<>291template <>
284struct Codec<std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>>292struct Codec<std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>>
285{293{
286 inline static void encode_argument(Message::Writer& writer, const std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>& arg)294 inline static void encode_argument(
295 Message::Writer& writer,
296 const std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>& arg)
287 {297 {
288 types::Signature signature(helper::TypeMapper<com::ubuntu::location::SpaceVehicle>::signature());298 types::Signature signature(helper::TypeMapper<com::ubuntu::location::SpaceVehicle>::signature());
289 auto sub = writer.open_array(signature);299 auto sub = writer.open_array(signature);
290300
291 for(const auto& element : arg)301 for (const auto& element : arg)
292 {302 {
293 Codec<com::ubuntu::location::SpaceVehicle>::encode_argument(sub, element.second);303 Codec<com::ubuntu::location::SpaceVehicle>::encode_argument(sub, element.second);
294 }304 }
@@ -296,7 +306,9 @@
296 writer.close_array(std::move(sub));306 writer.close_array(std::move(sub));
297 }307 }
298308
299 inline static void decode_argument(Message::Reader& reader, std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>& out)309 inline static void decode_argument(
310 Message::Reader& reader,
311 std::map<com::ubuntu::location::SpaceVehicle::Key, com::ubuntu::location::SpaceVehicle>& out)
300 {312 {
301 auto sub = reader.pop_array();313 auto sub = reader.pop_array();
302 while (sub.type() != ArgumentType::invalid)314 while (sub.type() != ArgumentType::invalid)
@@ -308,7 +320,7 @@
308 }320 }
309};321};
310322
311template<>323template <>
312struct Codec<com::ubuntu::location::Criteria>324struct Codec<com::ubuntu::location::Criteria>
313{325{
314 typedef com::ubuntu::location::units::Quantity<com::ubuntu::location::units::Length> HorizontalAccuracy;326 typedef com::ubuntu::location::units::Quantity<com::ubuntu::location::units::Length> HorizontalAccuracy;
@@ -343,7 +355,7 @@
343 }355 }
344};356};
345357
346template<>358template <>
347struct Codec<com::ubuntu::location::Provider::Features>359struct Codec<com::ubuntu::location::Provider::Features>
348{360{
349 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Provider::Features& in)361 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Provider::Features& in)
@@ -357,7 +369,7 @@
357 }369 }
358};370};
359371
360template<>372template <>
361struct Codec<com::ubuntu::location::Provider::Requirements>373struct Codec<com::ubuntu::location::Provider::Requirements>
362{374{
363 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Provider::Requirements& in)375 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Provider::Requirements& in)
@@ -371,7 +383,7 @@
371 }383 }
372};384};
373385
374template<>386template <>
375struct Codec<com::ubuntu::location::WifiAndCellIdReportingState>387struct Codec<com::ubuntu::location::WifiAndCellIdReportingState>
376{388{
377 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::WifiAndCellIdReportingState& in)389 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::WifiAndCellIdReportingState& in)
@@ -387,7 +399,7 @@
387399
388namespace helper400namespace helper
389{401{
390template<typename T>402template <typename T>
391struct TypeMapper<com::ubuntu::location::Update<T>>403struct TypeMapper<com::ubuntu::location::Update<T>>
392{404{
393 constexpr static ArgumentType type_value()405 constexpr static ArgumentType type_value()
@@ -405,15 +417,13 @@
405417
406 static std::string signature()418 static std::string signature()
407 {419 {
408 static const std::string s =420 static const std::string s = helper::TypeMapper<T>::signature() + helper::TypeMapper<uint64_t>::signature();
409 helper::TypeMapper<T>::signature() +
410 helper::TypeMapper<uint64_t>::signature();
411 return s;421 return s;
412 }422 }
413};423};
414}424}
415425
416template<typename T>426template <typename T>
417struct Codec<com::ubuntu::location::Update<T>>427struct Codec<com::ubuntu::location::Update<T>>
418{428{
419 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Update<T>& in)429 static void encode_argument(Message::Writer& writer, const com::ubuntu::location::Update<T>& in)
@@ -426,9 +436,9 @@
426 {436 {
427 Codec<T>::decode_argument(reader, in.value);437 Codec<T>::decode_argument(reader, in.value);
428 in.when = com::ubuntu::location::Clock::Timestamp(com::ubuntu::location::Clock::Duration(reader.pop_int64()));438 in.when = com::ubuntu::location::Clock::Timestamp(com::ubuntu::location::Clock::Duration(reader.pop_int64()));
429 } 439 }
430};440};
431}441}
432}442}
433443
434#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_444#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_
435445
=== modified file 'include/location_service/com/ubuntu/location/configuration.h'
--- include/location_service/com/ubuntu/location/configuration.h 2013-05-29 06:04:02 +0000
+++ include/location_service/com/ubuntu/location/configuration.h 2015-04-23 17:23:49 +0000
@@ -31,4 +31,4 @@
31}31}
32}32}
3333
34#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONFIGURATION_H_
35\ No newline at end of file34\ No newline at end of file
35#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONFIGURATION_H_
36\ No newline at end of file36\ No newline at end of file
3737
=== modified file 'include/location_service/com/ubuntu/location/connectivity/bounded_integer.h'
--- include/location_service/com/ubuntu/location/connectivity/bounded_integer.h 2014-06-10 11:53:01 +0000
+++ include/location_service/com/ubuntu/location/connectivity/bounded_integer.h 2015-04-23 17:23:49 +0000
@@ -33,7 +33,7 @@
33 * @brief A helper class to handle bounded integer values, with an optional domain33 * @brief A helper class to handle bounded integer values, with an optional domain
34 * for tagging domain-specific types.34 * for tagging domain-specific types.
35 */35 */
36template<typename Tag, int min, int max, int inv = min-1>36template <typename Tag, int min, int max, int inv = min - 1>
37class BoundedInteger37class BoundedInteger
38{38{
39public:39public:
@@ -79,16 +79,14 @@
79 // Capping to [0,1]79 // Capping to [0,1]
80 percent = std::min<float>(1., std::max<float>(0., percent));80 percent = std::min<float>(1., std::max<float>(0., percent));
8181
82 return BoundedInteger<Tag, min, max, inv>82 return BoundedInteger<Tag, min, max, inv>{static_cast<int>(minimum() + percent * range())};
83 {
84 static_cast<int>(minimum() + percent * range())
85 };
86 }83 }
8784
88 /**85 /**
89 * @brief Constructs an invalid instance.86 * @brief Constructs an invalid instance.
90 */87 */
91 inline BoundedInteger() : value(min-1)88 inline BoundedInteger()
89 : value(min - 1)
92 {90 {
93 }91 }
9492
@@ -97,19 +95,20 @@
97 * @param value The raw value.95 * @param value The raw value.
98 * @throw std::runtime_error if value is not in [min, max].96 * @throw std::runtime_error if value is not in [min, max].
99 */97 */
100 inline explicit BoundedInteger(int value) : value(value)98 inline explicit BoundedInteger(int value)
99 : value(value)
101 {100 {
102 if (value < min || value > max)101 if (value < min || value > max)
103 throw std::runtime_error(102 throw std::runtime_error(std::to_string(value) + " is not in " + "[" + std::to_string(min) + ", " +
104 std::to_string(value) + " is not in " + "[" +103 std::to_string(max) + "]");
105 std::to_string(min) + ", " + std::to_string(max) + "]");
106 }104 }
107105
108 /**106 /**
109 * @brief Copy c'tor.107 * @brief Copy c'tor.
110 * @param rhs The instance to copy from.108 * @param rhs The instance to copy from.
111 */109 */
112 inline BoundedInteger(const BoundedInteger<Tag, min, max, inv>& rhs) : value(rhs.value)110 inline BoundedInteger(const BoundedInteger<Tag, min, max, inv>& rhs)
111 : value(rhs.value)
113 {112 {
114 }113 }
115114
@@ -169,9 +168,8 @@
169 inline void set(int new_value)168 inline void set(int new_value)
170 {169 {
171 if (new_value < min || new_value > max)170 if (new_value < min || new_value > max)
172 throw std::runtime_error(171 throw std::runtime_error(std::to_string(new_value) + " is not in " + "[" + std::to_string(min) + ", " +
173 std::to_string(new_value) + " is not in " + "[" +172 std::to_string(max) + "]");
174 std::to_string(min) + ", " + std::to_string(max) + "]");
175173
176 value = new_value;174 value = new_value;
177 }175 }
@@ -193,7 +191,9 @@
193 out << bi.value;191 out << bi.value;
194192
195 if (!bi.is_valid())193 if (!bi.is_valid())
194 {
196 out << " -> invalid";195 out << " -> invalid";
196 }
197197
198 return out;198 return out;
199 }199 }
@@ -206,4 +206,4 @@
206}206}
207}207}
208208
209#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_BOUNDED_INTEGER_H_209#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_BOUNDED_INTEGER_H_
210210
=== modified file 'include/location_service/com/ubuntu/location/connectivity/manager.h'
--- include/location_service/com/ubuntu/location/connectivity/manager.h 2014-07-10 16:44:26 +0000
+++ include/location_service/com/ubuntu/location/connectivity/manager.h 2015-04-23 17:23:49 +0000
@@ -106,8 +106,7 @@
106 struct ConnectivityManagementNotSupported : public std::runtime_error106 struct ConnectivityManagementNotSupported : public std::runtime_error
107 {107 {
108 ConnectivityManagementNotSupported()108 ConnectivityManagementNotSupported()
109 : std::runtime_error(109 : std::runtime_error("Underlying platform does not provide support for connectivity mgmt.")
110 "Underlying platform does not provide support for connectivity mgmt.")
111 {110 {
112 }111 }
113 };112 };
@@ -154,7 +153,6 @@
154 */153 */
155 virtual const core::Property<bool>& is_wwan_hardware_enabled() const = 0;154 virtual const core::Property<bool>& is_wwan_hardware_enabled() const = 0;
156155
157
158 /**156 /**
159 * @brief Returns a getable/observable property that describes the characteristics157 * @brief Returns a getable/observable property that describes the characteristics
160 * of the active network connection.158 * of the active network connection.
@@ -230,4 +228,4 @@
230}228}
231}229}
232230
233#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_MANAGER_H_231#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_MANAGER_H_
234232
=== modified file 'include/location_service/com/ubuntu/location/connectivity/radio_cell.h'
--- include/location_service/com/ubuntu/location/connectivity/radio_cell.h 2014-06-10 11:53:01 +0000
+++ include/location_service/com/ubuntu/location/connectivity/radio_cell.h 2015-04-23 17:23:49 +0000
@@ -50,35 +50,53 @@
50 };50 };
5151
52 /** @cond */52 /** @cond */
53 struct Mcc {};53 struct Mcc
54 struct Mnc {};54 {
55 struct Lac {};55 };
56 struct Id {};56 struct Mnc
57 struct Psc {};57 {
58 struct Pid {};58 };
59 struct Rss {};59 struct Lac
60 struct Asu {};60 {
61 struct Ta {};61 };
62 struct Id
63 {
64 };
65 struct Psc
66 {
67 };
68 struct Pid
69 {
70 };
71 struct Rss
72 {
73 };
74 struct Asu
75 {
76 };
77 struct Ta
78 {
79 };
6280
63 template<int min, int max, int invalid = min-1>81 template <int min, int max, int invalid = min - 1>
64 using MobileCountryCode = BoundedInteger<Mcc, min, max, invalid>;82 using MobileCountryCode = BoundedInteger<Mcc, min, max, invalid>;
65 template<int min, int max, int invalid = min-1>83 template <int min, int max, int invalid = min - 1>
66 using MobileNetworkCode = BoundedInteger<Mnc, min, max, invalid>;84 using MobileNetworkCode = BoundedInteger<Mnc, min, max, invalid>;
67 template<int min, int max, int invalid = min-1>85 template <int min, int max, int invalid = min - 1>
68 using LocationAreaCode = BoundedInteger<Lac, min, max, invalid>;86 using LocationAreaCode = BoundedInteger<Lac, min, max, invalid>;
69 template<int min, int max, int invalid = min-1>87 template <int min, int max, int invalid = min - 1>
70 using TrackingAreaCode = BoundedInteger<Lac, min, max, invalid>;88 using TrackingAreaCode = BoundedInteger<Lac, min, max, invalid>;
71 template<int min, int max, int invalid = min-1>89 template <int min, int max, int invalid = min - 1>
72 using CellId = BoundedInteger<Id, min, max, invalid>;90 using CellId = BoundedInteger<Id, min, max, invalid>;
73 template<int min, int max, int invalid = min-1>91 template <int min, int max, int invalid = min - 1>
74 using PrimaryScramblingCode = BoundedInteger<Psc, min, max, invalid>;92 using PrimaryScramblingCode = BoundedInteger<Psc, min, max, invalid>;
75 template<int min, int max, int invalid = min-1>93 template <int min, int max, int invalid = min - 1>
76 using PhysicalId = BoundedInteger<Pid, min, max, invalid>;94 using PhysicalId = BoundedInteger<Pid, min, max, invalid>;
77 template<int min, int max, int invalid = min-1>95 template <int min, int max, int invalid = min - 1>
78 using ReceivedSignalStrength = BoundedInteger<Rss, min, max, invalid>;96 using ReceivedSignalStrength = BoundedInteger<Rss, min, max, invalid>;
79 template<int min, int max, int invalid = min-1>97 template <int min, int max, int invalid = min - 1>
80 using ArbitraryStrengthUnit = BoundedInteger<Asu, min, max, invalid>;98 using ArbitraryStrengthUnit = BoundedInteger<Asu, min, max, invalid>;
81 template<int min, int max, int invalid = min-1>99 template <int min, int max, int invalid = min - 1>
82 using TimingAdvance = BoundedInteger<Ta, min, max, invalid>;100 using TimingAdvance = BoundedInteger<Ta, min, max, invalid>;
83 /** @endcond */101 /** @endcond */
84102
@@ -86,41 +104,16 @@
86 struct Gsm104 struct Gsm
87 {105 {
88 /** 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */106 /** 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
89 typedef MobileCountryCode107 typedef MobileCountryCode<0, 999, std::numeric_limits<int>::max()> MCC;
90 <
91 0,
92 999,
93 std::numeric_limits<int>::max()
94 > MCC;
95 /** 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */108 /** 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
96 typedef MobileNetworkCode109 typedef MobileNetworkCode<0, 999, std::numeric_limits<int>::max()> MNC;
97 <
98 0,
99 999,
100 std::numeric_limits<int>::max()
101 > MNC;
102 /** 16-bit Location Area Code, 0..65535, INT_MAX if unknown */110 /** 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
103 typedef LocationAreaCode111 typedef LocationAreaCode<0, 65535, std::numeric_limits<int>::max()> LAC;
104 <
105 0,
106 65535,
107 std::numeric_limits<int>::max()
108 > LAC;
109 /** 16-bit GSM Cell Identity described in TS 27.007, 0..65535, INT_MAX if unknown */112 /** 16-bit GSM Cell Identity described in TS 27.007, 0..65535, INT_MAX if unknown */
110 typedef CellId113 typedef CellId<0, 65535, std::numeric_limits<int>::max()> ID;
111 <
112 0,
113 65535,
114 std::numeric_limits<int>::max()
115 > ID;
116114
117 /** Valid values are (0-31, 99) as defined in TS 27.007 8.5 */115 /** Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
118 typedef ArbitraryStrengthUnit116 typedef ArbitraryStrengthUnit<0, 31, 99> SignalStrength;
119 <
120 0,
121 31,
122 99
123 > SignalStrength;
124117
125 MCC mobile_country_code;118 MCC mobile_country_code;
126 MNC mobile_network_code;119 MNC mobile_network_code;
@@ -133,40 +126,15 @@
133 struct Umts126 struct Umts
134 {127 {
135 /** 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */128 /** 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
136 typedef MobileCountryCode129 typedef MobileCountryCode<0, 999, std::numeric_limits<int>::max()> MCC;
137 <
138 0,
139 999,
140 std::numeric_limits<int>::max()
141 > MCC;
142 /** 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */130 /** 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
143 typedef MobileNetworkCode131 typedef MobileNetworkCode<0, 999, std::numeric_limits<int>::max()> MNC;
144 <
145 0,
146 999,
147 std::numeric_limits<int>::max()
148 > MNC;
149 /** 16-bit Location Area Code, 0..65535, INT_MAX if unknown */132 /** 16-bit Location Area Code, 0..65535, INT_MAX if unknown */
150 typedef LocationAreaCode133 typedef LocationAreaCode<0, 65535, std::numeric_limits<int>::max()> LAC;
151 <
152 0,
153 65535,
154 std::numeric_limits<int>::max()
155 > LAC;
156 /** 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */134 /** 28-bit UMTS Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */
157 typedef CellId135 typedef CellId<0, 268435455, std::numeric_limits<int>::max()> ID;
158 <
159 0,
160 268435455,
161 std::numeric_limits<int>::max()
162 > ID;
163 /** Valid values are (0-31, 99) as defined in TS 27.007 8.5 */136 /** Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
164 typedef ArbitraryStrengthUnit137 typedef ArbitraryStrengthUnit<0, 31, 99> SignalStrength;
165 <
166 0,
167 31,
168 99
169 > SignalStrength;
170138
171 MCC mobile_country_code;139 MCC mobile_country_code;
172 MNC mobile_network_code;140 MNC mobile_network_code;
@@ -179,47 +147,17 @@
179 struct Lte147 struct Lte
180 {148 {
181 /** 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */149 /** 3-digit Mobile Country Code, 0..999, INT_MAX if unknown */
182 typedef MobileCountryCode150 typedef MobileCountryCode<0, 999, std::numeric_limits<int>::max()> MCC;
183 <
184 0,
185 999,
186 std::numeric_limits<int>::max()
187 > MCC;
188 /** 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */151 /** 2 or 3-digit Mobile Network Code, 0..999, INT_MAX if unknown */
189 typedef MobileNetworkCode152 typedef MobileNetworkCode<0, 999, std::numeric_limits<int>::max()> MNC;
190 <
191 0,
192 999,
193 std::numeric_limits<int>::max()
194 > MNC;
195 /** 16-bit Tracking Area Code, 0..65535, INT_MAX if unknown */153 /** 16-bit Tracking Area Code, 0..65535, INT_MAX if unknown */
196 typedef TrackingAreaCode154 typedef TrackingAreaCode<0, 65535, std::numeric_limits<int>::max()> TAC;
197 <
198 0,
199 65535,
200 std::numeric_limits<int>::max()
201 > TAC;
202 /** 28-bit Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */155 /** 28-bit Cell Identity described in TS 25.331, 0..268435455, INT_MAX if unknown */
203 typedef CellId156 typedef CellId<0, 268435455, std::numeric_limits<int>::max()> ID;
204 <
205 0,
206 268435455,
207 std::numeric_limits<int>::max()
208 > ID;
209 /** Physical cell id, 0..503, INT_MAX if unknown */157 /** Physical cell id, 0..503, INT_MAX if unknown */
210 typedef PhysicalId158 typedef PhysicalId<0, 503, std::numeric_limits<int>::max()> PID;
211 <
212 0,
213 503,
214 std::numeric_limits<int>::max()
215 > PID;
216 /** Valid values are (0-31, 99) as defined in TS 27.007 8.5 */159 /** Valid values are (0-31, 99) as defined in TS 27.007 8.5 */
217 typedef ArbitraryStrengthUnit160 typedef ArbitraryStrengthUnit<0, 31, 99> SignalStrength;
218 <
219 0,
220 31,
221 99
222 > SignalStrength;
223161
224 MCC mobile_country_code;162 MCC mobile_country_code;
225 MNC mobile_network_code;163 MNC mobile_network_code;
@@ -279,5 +217,4 @@
279}217}
280}218}
281219
282#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_RADIO_CELL_H_220#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_RADIO_CELL_H_
283
284221
=== modified file 'include/location_service/com/ubuntu/location/connectivity/wireless_network.h'
--- include/location_service/com/ubuntu/location/connectivity/wireless_network.h 2014-06-10 09:08:10 +0000
+++ include/location_service/com/ubuntu/location/connectivity/wireless_network.h 2015-04-23 17:23:49 +0000
@@ -52,27 +52,21 @@
52 struct Tag52 struct Tag
53 {53 {
54 /** @brief Tags a frequency measurement for a wireless network. */54 /** @brief Tags a frequency measurement for a wireless network. */
55 struct Frequency {};55 struct Frequency
56 {
57 };
56 /** @brief Tags the signal strength of a wireless network. */58 /** @brief Tags the signal strength of a wireless network. */
57 struct SignalStrength {};59 struct SignalStrength
60 {
61 };
58 };62 };
59 /** @endcond */63 /** @endcond */
6064
61 /** Frequency that an individual AP operates on. */65 /** Frequency that an individual AP operates on. */
62 typedef BoundedInteger66 typedef BoundedInteger<Tag::Frequency, 2412, 5825> Frequency;
63 <
64 Tag::Frequency,
65 2412,
66 5825
67 > Frequency;
6867
69 /** Strength of signal for an individual AP. */68 /** Strength of signal for an individual AP. */
70 typedef BoundedInteger69 typedef BoundedInteger<Tag::SignalStrength, 0, 100> SignalStrength;
71 <
72 Tag::SignalStrength,
73 0,
74 100
75 > SignalStrength;
7670
77 /** @cond */71 /** @cond */
78 WirelessNetwork() = default;72 WirelessNetwork() = default;
@@ -114,4 +108,4 @@
114}108}
115}109}
116110
117#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_WIRELESS_NETWORK_H_111#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_WIRELESS_NETWORK_H_
118112
=== modified file 'include/location_service/com/ubuntu/location/criteria.h'
--- include/location_service/com/ubuntu/location/criteria.h 2014-01-12 18:03:12 +0000
+++ include/location_service/com/ubuntu/location/criteria.h 2015-04-23 17:23:49 +0000
@@ -42,18 +42,22 @@
4242
43 struct Requires43 struct Requires
44 {44 {
45 bool position = true; ///< The client needs position measurements.45 bool position = true; ///< The client needs position measurements.
46 bool altitude = false; ///< The client needs altitude measurements.46 bool altitude = false; ///< The client needs altitude measurements.
47 bool velocity = false; ///< The client needs velocity measurments.47 bool velocity = false; ///< The client needs velocity measurments.
48 bool heading = false; ///< The client needs heading measurements.48 bool heading = false; ///< The client needs heading measurements.
49 } requires = Requires{};49 } requires = Requires{};
5050
51 struct Accuracy51 struct Accuracy
52 {52 {
53 units::Quantity<units::Length> horizontal = 3000 * units::Meters; ///< The client requires measurements of at least this horizontal accuracy.53 units::Quantity<units::Length> horizontal =
54 Optional<units::Quantity<units::Length>> vertical; ///< The client requires measurements of at least this vertical accuracy.54 3000 * units::Meters; ///< The client requires measurements of at least this horizontal accuracy.
55 Optional<units::Quantity<units::Velocity>> velocity; ///< The client requires measurements of at least this velocity accuracy.55 Optional<units::Quantity<units::Length>> vertical; ///< The client requires measurements of at least this
56 Optional<units::Quantity<units::PlaneAngle>> heading; ///< The client requires measurements of at least this heading accuracy.56 ///vertical accuracy.
57 Optional<units::Quantity<units::Velocity>> velocity; ///< The client requires measurements of at least this
58 ///velocity accuracy.
59 Optional<units::Quantity<units::PlaneAngle>> heading; ///< The client requires measurements of at least this
60 ///heading accuracy.
57 } accuracy = Accuracy{};61 } accuracy = Accuracy{};
58};62};
5963
@@ -65,4 +69,4 @@
65}69}
66}70}
6771
68#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CRITERIA_H_72#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CRITERIA_H_
6973
=== 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-12-14 09:10:29 +0000
+++ include/location_service/com/ubuntu/location/default_provider_selection_policy.h 2015-04-23 17:23:49 +0000
@@ -31,25 +31,18 @@
31public:31public:
32 DefaultProviderSelectionPolicy();32 DefaultProviderSelectionPolicy();
33 ~DefaultProviderSelectionPolicy() noexcept;33 ~DefaultProviderSelectionPolicy() noexcept;
34 34
35 ProviderSelection determine_provider_selection_for_criteria(35 ProviderSelection determine_provider_selection_for_criteria(const Criteria& criteria,
36 const Criteria& criteria,36 const ProviderEnumerator& enumerator);
37 const ProviderEnumerator& enumerator);37
3838 Provider::Ptr determine_position_updates_provider(const Criteria& criteria, const ProviderEnumerator& enumerator);
39 Provider::Ptr determine_position_updates_provider(39
40 const Criteria& criteria,40 Provider::Ptr determine_heading_updates_provider(const Criteria& criteria, const ProviderEnumerator& enumerator);
41 const ProviderEnumerator& enumerator);41
4242 Provider::Ptr determine_velocity_updates_provider(const Criteria& criteria, const ProviderEnumerator& enumerator);
43 Provider::Ptr determine_heading_updates_provider(
44 const Criteria& criteria,
45 const ProviderEnumerator& enumerator);
46
47 Provider::Ptr determine_velocity_updates_provider(
48 const Criteria& criteria,
49 const ProviderEnumerator& enumerator);
50};43};
51}44}
52}45}
53}46}
5447
55#endif // LOCATION_SERVICE_COM_UBUNTU_DEFAULT_PROVIDER_SELECTION_POLICY_H_48#endif // LOCATION_SERVICE_COM_UBUNTU_DEFAULT_PROVIDER_SELECTION_POLICY_H_
5649
=== modified file 'include/location_service/com/ubuntu/location/heading.h'
--- include/location_service/com/ubuntu/location/heading.h 2013-12-12 14:36:32 +0000
+++ include/location_service/com/ubuntu/location/heading.h 2015-04-23 17:23:49 +0000
@@ -32,4 +32,4 @@
32}32}
33}33}
3434
35#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_35#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_
3636
=== modified file 'include/location_service/com/ubuntu/location/init_and_shutdown.h'
--- include/location_service/com/ubuntu/location/init_and_shutdown.h 2013-05-29 09:21:16 +0000
+++ include/location_service/com/ubuntu/location/init_and_shutdown.h 2015-04-23 17:23:49 +0000
@@ -33,4 +33,4 @@
33}33}
34}34}
3535
36#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_INIT_AND_SHUTDOWN_H_
37\ No newline at end of file36\ No newline at end of file
37#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_INIT_AND_SHUTDOWN_H_
38\ No newline at end of file38\ No newline at end of file
3939
=== modified file 'include/location_service/com/ubuntu/location/logging.h'
--- include/location_service/com/ubuntu/location/logging.h 2014-06-20 07:40:34 +0000
+++ include/location_service/com/ubuntu/location/logging.h 2015-04-23 17:23:49 +0000
@@ -21,5 +21,4 @@
21#include <glog/logging.h>21#include <glog/logging.h>
22#include <glog/vlog_is_on.h>22#include <glog/vlog_is_on.h>
2323
24#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_LOGGING_H_24#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_LOGGING_H_
25
2625
=== modified file 'include/location_service/com/ubuntu/location/optional.h'
--- include/location_service/com/ubuntu/location/optional.h 2013-12-12 14:36:32 +0000
+++ include/location_service/com/ubuntu/location/optional.h 2015-04-23 17:23:49 +0000
@@ -26,10 +26,10 @@
26{26{
27namespace location27namespace location
28{28{
29template<typename T>29template <typename T>
30using Optional = boost::optional<T>;30using Optional = boost::optional<T>;
31}31}
32}32}
33}33}
3434
35#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_OPTIONAL_H_35#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_OPTIONAL_H_
3636
=== modified file 'include/location_service/com/ubuntu/location/position.h'
--- include/location_service/com/ubuntu/location/position.h 2014-06-17 08:06:08 +0000
+++ include/location_service/com/ubuntu/location/position.h 2015-04-23 17:23:49 +0000
@@ -50,8 +50,15 @@
50 Position() = default;50 Position() = default;
51 Position(const wgs84::Latitude&, const wgs84::Longitude&);51 Position(const wgs84::Latitude&, const wgs84::Longitude&);
52 Position(const wgs84::Latitude&, const wgs84::Longitude&, const wgs84::Altitude&);52 Position(const wgs84::Latitude&, const wgs84::Longitude&, const wgs84::Altitude&);
53 Position(const wgs84::Latitude&, const wgs84::Longitude&, const wgs84::Altitude&, const units::Quantity<units::Length>& hor_acc);53 Position(const wgs84::Latitude&,
54 Position(const wgs84::Latitude&, const wgs84::Longitude&, const wgs84::Altitude&, const units::Quantity<units::Length>& hor_acc, const units::Quantity<units::Length>& ver_acc);54 const wgs84::Longitude&,
55 const wgs84::Altitude&,
56 const units::Quantity<units::Length>& hor_acc);
57 Position(const wgs84::Latitude&,
58 const wgs84::Longitude&,
59 const wgs84::Altitude&,
60 const units::Quantity<units::Length>& hor_acc,
61 const units::Quantity<units::Length>& ver_acc);
5562
56 bool operator==(const Position& rhs) const;63 bool operator==(const Position& rhs) const;
57 bool operator!=(const Position& rhs) const;64 bool operator!=(const Position& rhs) const;
@@ -68,4 +75,4 @@
68}75}
69}76}
70}77}
71#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_POSITION_H_78#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_POSITION_H_
7279
=== modified file 'include/location_service/com/ubuntu/location/provider.h'
--- include/location_service/com/ubuntu/location/provider.h 2015-01-21 20:13:28 +0000
+++ include/location_service/com/ubuntu/location/provider.h 2015-04-23 17:23:49 +0000
@@ -52,22 +52,22 @@
52 */52 */
53 enum class Features : std::size_t53 enum class Features : std::size_t
54 {54 {
55 none = 0, ///< The provider does not support any feature.55 none = 0, ///< The provider does not support any feature.
56 position = 1 << 0, ///< The provider features position updates.56 position = 1 << 0, ///< The provider features position updates.
57 velocity = 1 << 1, ///< The provider features velocity updates.57 velocity = 1 << 1, ///< The provider features velocity updates.
58 heading = 1 << 2 ///< The provider features heading updates.58 heading = 1 << 2 ///< The provider features heading updates.
59 }; 59 };
6060
61 /**61 /**
62 * @brief Enumerates the requirements of a provider implementation.62 * @brief Enumerates the requirements of a provider implementation.
63 */63 */
64 enum class Requirements : std::size_t64 enum class Requirements : std::size_t
65 {65 {
66 none = 0, ///< The provider does not require anything.66 none = 0, ///< The provider does not require anything.
67 satellites = 1 << 0, ///< The provider requires satellites to be visible.67 satellites = 1 << 0, ///< The provider requires satellites to be visible.
68 cell_network = 1 << 1, ///< The provider requires a cell-network to work correctly.68 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.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.70 monetary_spending = 1 << 3 ///< Using the provider results in monetary cost.
71 };71 };
7272
73 /**73 /**
@@ -80,11 +80,11 @@
80 class Controller80 class Controller
81 {81 {
82 public:82 public:
83 typedef std::shared_ptr<Controller> Ptr; 83 typedef std::shared_ptr<Controller> Ptr;
8484
85 virtual ~Controller() = default;85 virtual ~Controller() = default;
86 Controller(const Controller&) = delete;86 Controller(const Controller&) = delete;
87 Controller& operator=(const Controller&) = delete; 87 Controller& operator=(const Controller&) = delete;
8888
89 /**89 /**
90 * @brief disable switches the provider to a disabled state, such that subsequent90 * @brief disable switches the provider to a disabled state, such that subsequent
@@ -234,9 +234,7 @@
234 virtual void on_reference_heading_updated(const Update<Heading>& heading);234 virtual void on_reference_heading_updated(const Update<Heading>& heading);
235235
236protected:236protected:
237 explicit Provider(237 explicit Provider(const Features& features = Features::none, const Requirements& requirements = Requirements::none);
238 const Features& features = Features::none,
239 const Requirements& requirements = Requirements::none);
240238
241 virtual Updates& mutable_updates();239 virtual Updates& mutable_updates();
242240
@@ -289,4 +287,4 @@
289}287}
290}288}
291289
292#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_H_290#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_H_
293291
=== modified file 'include/location_service/com/ubuntu/location/provider_enumerator.h'
--- include/location_service/com/ubuntu/location/provider_enumerator.h 2013-12-14 09:10:29 +0000
+++ include/location_service/com/ubuntu/location/provider_enumerator.h 2015-04-23 17:23:49 +0000
@@ -46,4 +46,4 @@
46}46}
47}47}
4848
49#endif // LOCATION_SERVICE_COM_UBUNTU_PROVIDER_ENUMERATOR_H_49#endif // LOCATION_SERVICE_COM_UBUNTU_PROVIDER_ENUMERATOR_H_
5050
=== modified file 'include/location_service/com/ubuntu/location/provider_factory.h'
--- include/location_service/com/ubuntu/location/provider_factory.h 2014-10-27 21:58:16 +0000
+++ include/location_service/com/ubuntu/location/provider_factory.h 2015-04-23 17:23:49 +0000
@@ -37,7 +37,7 @@
3737
38class ProviderFactory38class ProviderFactory
39{39{
40 public:40public:
41 typedef com::ubuntu::location::Configuration Configuration;41 typedef com::ubuntu::location::Configuration Configuration;
42 typedef std::function<Provider::Ptr(const Configuration&)> Factory;42 typedef std::function<Provider::Ptr(const Configuration&)> Factory;
4343
@@ -50,13 +50,15 @@
50 // by calling the factory and passing it the given config. Please note that the name50 // by calling the factory and passing it the given config. Please note that the name
51 // can be decorated with @ for distinguishing providers of the same type but different configs.51 // can be decorated with @ for distinguishing providers of the same type but different configs.
52 // Eg.:52 // Eg.:
53 // --provider=remote::Provider@espoo --remote::Provider@espoo::name="com.ubuntu.espoo.service.Provider" --remote::Provider@espoo::path="/com/ubuntu/espoo/service/Provider"53 // --provider=remote::Provider@espoo --remote::Provider@espoo::name="com.ubuntu.espoo.service.Provider"
54 // --provider=remote::Provider@gps --remote::Provider@gps::name="com.ubuntu.android.gps.Provider" --remote::Provider@gps::path="/com/ubuntu/android/gps/Provider"54 // --remote::Provider@espoo::path="/com/ubuntu/espoo/service/Provider"
55 // --provider=remote::Provider@gps --remote::Provider@gps::name="com.ubuntu.android.gps.Provider"
56 // --remote::Provider@gps::path="/com/ubuntu/android/gps/Provider"
55 Provider::Ptr create_provider_for_name_with_config(const std::string& name, const Configuration& config);57 Provider::Ptr create_provider_for_name_with_config(const std::string& name, const Configuration& config);
5658
57 void enumerate(const std::function<void(const std::string&, const Factory&)>& enumerator);59 void enumerate(const std::function<void(const std::string&, const Factory&)>& enumerator);
5860
59 private:61private:
60 ProviderFactory() = default;62 ProviderFactory() = default;
61 ~ProviderFactory() = default;63 ~ProviderFactory() = default;
6264
@@ -70,4 +72,4 @@
70}72}
71}73}
7274
73#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_75#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_
7476
=== modified file 'include/location_service/com/ubuntu/location/provider_selection.h'
--- include/location_service/com/ubuntu/location/provider_selection.h 2013-12-14 09:10:29 +0000
+++ include/location_service/com/ubuntu/location/provider_selection.h 2015-04-23 17:23:49 +0000
@@ -35,11 +35,17 @@
35 Provider::Features flags = Provider::Features::none;35 Provider::Features flags = Provider::Features::none;
3636
37 if (position_updates_provider)37 if (position_updates_provider)
38 {
38 flags = flags | Provider::Features::position;39 flags = flags | Provider::Features::position;
40 }
39 if (heading_updates_provider)41 if (heading_updates_provider)
42 {
40 flags = flags | Provider::Features::heading;43 flags = flags | Provider::Features::heading;
41 if(velocity_updates_provider)44 }
45 if (velocity_updates_provider)
46 {
42 flags = flags | Provider::Features::velocity;47 flags = flags | Provider::Features::velocity;
48 }
4349
44 return flags;50 return flags;
45 }51 }
@@ -52,11 +58,11 @@
52inline bool operator==(const ProviderSelection& lhs, const ProviderSelection& rhs)58inline bool operator==(const ProviderSelection& lhs, const ProviderSelection& rhs)
53{59{
54 return lhs.position_updates_provider == rhs.position_updates_provider &&60 return lhs.position_updates_provider == rhs.position_updates_provider &&
55 lhs.heading_updates_provider == rhs.heading_updates_provider &&61 lhs.heading_updates_provider == rhs.heading_updates_provider &&
56 lhs.velocity_updates_provider == rhs.velocity_updates_provider;62 lhs.velocity_updates_provider == rhs.velocity_updates_provider;
57}63}
58}64}
59}65}
60}66}
6167
62#endif // LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_H_68#endif // LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_H_
6369
=== modified file 'include/location_service/com/ubuntu/location/provider_selection_policy.h'
--- include/location_service/com/ubuntu/location/provider_selection_policy.h 2014-06-20 07:40:34 +0000
+++ include/location_service/com/ubuntu/location/provider_selection_policy.h 2015-04-23 17:23:49 +0000
@@ -43,9 +43,8 @@
43 ProviderSelectionPolicy& operator=(const ProviderSelectionPolicy&) = delete;43 ProviderSelectionPolicy& operator=(const ProviderSelectionPolicy&) = delete;
44 virtual ~ProviderSelectionPolicy() = default;44 virtual ~ProviderSelectionPolicy() = default;
4545
46 virtual ProviderSelection determine_provider_selection_for_criteria(46 virtual ProviderSelection determine_provider_selection_for_criteria(const Criteria& criteria,
47 const Criteria& criteria,47 const ProviderEnumerator& enumerator) = 0;
48 const ProviderEnumerator& enumerator) = 0;
4948
50protected:49protected:
51 ProviderSelectionPolicy() = default;50 ProviderSelectionPolicy() = default;
@@ -54,4 +53,4 @@
54}53}
55}54}
5655
57#endif // LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_POLICY_H_56#endif // LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_POLICY_H_
5857
=== modified file 'include/location_service/com/ubuntu/location/providers/geoclue/geoclue.h'
--- include/location_service/com/ubuntu/location/providers/geoclue/geoclue.h 2014-02-03 13:52:21 +0000
+++ include/location_service/com/ubuntu/location/providers/geoclue/geoclue.h 2015-04-23 17:23:49 +0000
@@ -43,13 +43,10 @@
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 = {{Status::error, "error"},
47 {47 {Status::unavailable, "unavailable"},
48 {Status::error, "error"},48 {Status::acquiring, "acquiring"},
49 {Status::unavailable, "unavailable"},49 {Status::available, "available"}};
50 {Status::acquiring, "acquiring"},
51 {Status::available, "available"}
52 };
5350
54 return out << lut[status];51 return out << lut[status];
55 }52 }
@@ -62,7 +59,10 @@
62 }59 }
63 typedef Geoclue Interface;60 typedef Geoclue Interface;
64 typedef std::tuple<std::string, std::string> ResultType;61 typedef std::tuple<std::string, std::string> ResultType;
65 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }62 inline static const std::chrono::milliseconds default_timeout()
63 {
64 return std::chrono::seconds{1};
65 }
66 };66 };
6767
68 struct GetStatus68 struct GetStatus
@@ -73,7 +73,10 @@
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()
77 {
78 return std::chrono::seconds{1};
79 }
77 };80 };
7881
79 struct AddReference82 struct AddReference
@@ -84,7 +87,10 @@
84 }87 }
85 typedef Geoclue Interface;88 typedef Geoclue Interface;
86 typedef void ResultType;89 typedef void ResultType;
87 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }90 inline static const std::chrono::milliseconds default_timeout()
91 {
92 return std::chrono::seconds{1};
93 }
88 };94 };
8995
90 struct RemoveReference96 struct RemoveReference
@@ -95,7 +101,10 @@
95 }101 }
96 typedef Geoclue Interface;102 typedef Geoclue Interface;
97 typedef void ResultType;103 typedef void ResultType;
98 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }104 inline static const std::chrono::milliseconds default_timeout()
105 {
106 return std::chrono::seconds{1};
107 }
99 };108 };
100109
101 struct Address110 struct Address
@@ -107,8 +116,13 @@
107 return "GetAddress";116 return "GetAddress";
108 }117 }
109 typedef Address Interface;118 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;119 typedef std::tuple<int32_t,
111 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }120 std::map<std::string, std::string>,
121 dbus::types::Struct<std::tuple<int32_t, double, double>>> ResultType;
122 inline static const std::chrono::milliseconds default_timeout()
123 {
124 return std::chrono::seconds{1};
125 }
112 };126 };
113127
114 struct Signals128 struct Signals
@@ -120,7 +134,9 @@
120 return "PositionChanged";134 return "PositionChanged";
121 };135 };
122 typedef Address Interface;136 typedef Address Interface;
123 typedef std::tuple<int32_t, std::map<std::string, std::string>, dbus::types::Struct<std::tuple<int32_t, double, double>>> ArgumentType;137 typedef std::tuple<int32_t,
138 std::map<std::string, std::string>,
139 dbus::types::Struct<std::tuple<int32_t, double, double>>> ArgumentType;
124 };140 };
125 };141 };
126 };142 };
@@ -146,8 +162,16 @@
146 return "GetPosition";162 return "GetPosition";
147 }163 }
148 typedef Position Interface;164 typedef Position Interface;
149 typedef std::tuple<int32_t, int32_t, double, double, double, dbus::types::Struct<std::tuple<int32_t, double, double>>> ResultType;165 typedef std::tuple<int32_t,
150 inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }166 int32_t,
167 double,
168 double,
169 double,
170 dbus::types::Struct<std::tuple<int32_t, double, double>>> ResultType;
171 inline static const std::chrono::milliseconds default_timeout()
172 {
173 return std::chrono::seconds{1};
174 }
151 };175 };
152176
153 struct Signals177 struct Signals
@@ -159,7 +183,12 @@
159 return "PositionChanged";183 return "PositionChanged";
160 };184 };
161 typedef Position Interface;185 typedef Position Interface;
162 typedef std::tuple<int32_t, int32_t, double, double, double, dbus::types::Struct<std::tuple<int32_t, double, double>>> ArgumentType;186 typedef std::tuple<int32_t,
187 int32_t,
188 double,
189 double,
190 double,
191 dbus::types::Struct<std::tuple<int32_t, double, double>>> ArgumentType;
163 };192 };
164 };193 };
165 };194 };
@@ -186,7 +215,10 @@
186 }215 }
187 typedef Velocity Interface;216 typedef Velocity Interface;
188 typedef std::tuple<int32_t, int32_t, double, double, double> ResultType;217 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}; }218 inline static const std::chrono::milliseconds default_timeout()
219 {
220 return std::chrono::seconds{1};
221 }
190 };222 };
191 struct Signals223 struct Signals
192 {224 {
@@ -211,7 +243,7 @@
211{243{
212namespace traits244namespace traits
213{245{
214template<>246template <>
215struct Service<org::freedesktop::Geoclue>247struct Service<org::freedesktop::Geoclue>
216{248{
217 inline static const std::string& interface_name()249 inline static const std::string& interface_name()
@@ -221,7 +253,7 @@
221 }253 }
222};254};
223255
224template<>256template <>
225struct Service<org::freedesktop::Geoclue::Address>257struct Service<org::freedesktop::Geoclue::Address>
226{258{
227 inline static const std::string& interface_name()259 inline static const std::string& interface_name()
@@ -231,7 +263,7 @@
231 }263 }
232};264};
233265
234template<>266template <>
235struct Service<org::freedesktop::Geoclue::Position>267struct Service<org::freedesktop::Geoclue::Position>
236{268{
237 inline static const std::string& interface_name()269 inline static const std::string& interface_name()
@@ -241,7 +273,7 @@
241 }273 }
242};274};
243275
244template<>276template <>
245struct Service<org::freedesktop::Geoclue::Velocity>277struct Service<org::freedesktop::Geoclue::Velocity>
246{278{
247 inline static const std::string& interface_name()279 inline static const std::string& interface_name()
@@ -254,4 +286,4 @@
254}286}
255}287}
256288
257#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_289#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_
258290
=== modified file 'include/location_service/com/ubuntu/location/providers/geoclue/provider.h'
--- include/location_service/com/ubuntu/location/providers/geoclue/provider.h 2013-12-10 09:42:54 +0000
+++ include/location_service/com/ubuntu/location/providers/geoclue/provider.h 2015-04-23 17:23:49 +0000
@@ -33,13 +33,19 @@
33{33{
34class Provider : public com::ubuntu::location::Provider34class Provider : public com::ubuntu::location::Provider
35{35{
36 public:36public:
37 static Provider::Ptr create_instance(const ProviderFactory::Configuration&);37 static Provider::Ptr create_instance(const ProviderFactory::Configuration&);
3838
39 struct Configuration39 struct Configuration
40 {40 {
41 static std::string key_name() { return "name"; }41 static std::string key_name()
42 static std::string key_path() { return "path"; }42 {
43 return "name";
44 }
45 static std::string key_path()
46 {
47 return "path";
48 }
43 std::string name;49 std::string name;
44 std::string path;50 std::string path;
4551
@@ -61,7 +67,7 @@
61 virtual void start_heading_updates();67 virtual void start_heading_updates();
62 virtual void stop_heading_updates();68 virtual void stop_heading_updates();
6369
64 private:70private:
65 struct Private;71 struct Private;
66 std::unique_ptr<Private> d;72 std::unique_ptr<Private> d;
67};73};
@@ -70,4 +76,4 @@
70}76}
71}77}
72}78}
73#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_PROVIDER_H_79#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_PROVIDER_H_
7480
=== modified file 'include/location_service/com/ubuntu/location/providers/remote/interface.h'
--- include/location_service/com/ubuntu/location/providers/remote/interface.h 2015-01-21 20:04:56 +0000
+++ include/location_service/com/ubuntu/location/providers/remote/interface.h 2015-04-23 17:23:49 +0000
@@ -99,26 +99,20 @@
99 // Creates a new skeleton instance and installs the interface99 // Creates a new skeleton instance and installs the interface
100 // com::ubuntu::remote::Interface on it.100 // com::ubuntu::remote::Interface on it.
101 Skeleton(const core::dbus::Object::Ptr& object)101 Skeleton(const core::dbus::Object::Ptr& object)
102 : object{object},102 : object{object}
103 properties103 , properties{object->get_property<Properties::HasPosition>(),
104 {104 object->get_property<Properties::HasVelocity>(),
105 object->get_property<Properties::HasPosition>(),105 object->get_property<Properties::HasHeading>(),
106 object->get_property<Properties::HasVelocity>(),106 object->get_property<Properties::RequiresSatellites>(),
107 object->get_property<Properties::HasHeading>(),107 object->get_property<Properties::RequiresCellNetwork>(),
108 object->get_property<Properties::RequiresSatellites>(),108 object->get_property<Properties::RequiresDataNetwork>(),
109 object->get_property<Properties::RequiresCellNetwork>(),109 object->get_property<Properties::RequiresMonetarySpending>(),
110 object->get_property<Properties::RequiresDataNetwork>(),110 object->get_property<Properties::ArePositionUpdatesRunning>(),
111 object->get_property<Properties::RequiresMonetarySpending>(),111 object->get_property<Properties::AreHeadingUpdatesRunning>(),
112 object->get_property<Properties::ArePositionUpdatesRunning>(),112 object->get_property<Properties::AreVelocityUpdatesRunning>()}
113 object->get_property<Properties::AreHeadingUpdatesRunning>(),113 , signals{object->get_signal<Signals::PositionChanged>(),
114 object->get_property<Properties::AreVelocityUpdatesRunning>()114 object->get_signal<Signals::HeadingChanged>(),
115 },115 object->get_signal<Signals::VelocityChanged>()}
116 signals
117 {
118 object->get_signal<Signals::PositionChanged>(),
119 object->get_signal<Signals::HeadingChanged>(),
120 object->get_signal<Signals::VelocityChanged>()
121 }
122 {116 {
123 }117 }
124118
@@ -141,20 +135,14 @@
141 // All known signals.135 // All known signals.
142 struct136 struct
143 {137 {
144 std::shared_ptr<core::dbus::Signal<138 std::shared_ptr<core::dbus::Signal<Signals::PositionChanged, Signals::PositionChanged::ArgumentType>>
145 Signals::PositionChanged,139 position_changed;
146 Signals::PositionChanged::ArgumentType140
147 >> position_changed;141 std::shared_ptr<core::dbus::Signal<Signals::HeadingChanged, Signals::HeadingChanged::ArgumentType>>
148142 heading_changed;
149 std::shared_ptr<core::dbus::Signal<143
150 Signals::HeadingChanged,144 std::shared_ptr<core::dbus::Signal<Signals::VelocityChanged, Signals::VelocityChanged::ArgumentType>>
151 Signals::HeadingChanged::ArgumentType145 velocity_changed;
152 >> heading_changed;
153
154 std::shared_ptr<core::dbus::Signal<
155 Signals::VelocityChanged,
156 Signals::VelocityChanged::ArgumentType
157 >> velocity_changed;
158 } signals;146 } signals;
159 };147 };
160148
@@ -163,26 +151,20 @@
163 // Creates a new skeleton instance and installs the interface151 // Creates a new skeleton instance and installs the interface
164 // com::ubuntu::remote::Interface on it.152 // com::ubuntu::remote::Interface on it.
165 Stub(const core::dbus::Object::Ptr& object)153 Stub(const core::dbus::Object::Ptr& object)
166 : object{object},154 : object{object}
167 properties155 , properties{object->get_property<Properties::HasPosition>(),
168 {156 object->get_property<Properties::HasVelocity>(),
169 object->get_property<Properties::HasPosition>(),157 object->get_property<Properties::HasHeading>(),
170 object->get_property<Properties::HasVelocity>(),158 object->get_property<Properties::RequiresSatellites>(),
171 object->get_property<Properties::HasHeading>(),159 object->get_property<Properties::RequiresCellNetwork>(),
172 object->get_property<Properties::RequiresSatellites>(),160 object->get_property<Properties::RequiresDataNetwork>(),
173 object->get_property<Properties::RequiresCellNetwork>(),161 object->get_property<Properties::RequiresMonetarySpending>(),
174 object->get_property<Properties::RequiresDataNetwork>(),162 object->get_property<Properties::ArePositionUpdatesRunning>(),
175 object->get_property<Properties::RequiresMonetarySpending>(),163 object->get_property<Properties::AreHeadingUpdatesRunning>(),
176 object->get_property<Properties::ArePositionUpdatesRunning>(),164 object->get_property<Properties::AreVelocityUpdatesRunning>()}
177 object->get_property<Properties::AreHeadingUpdatesRunning>(),165 , signals{object->get_signal<Signals::PositionChanged>(),
178 object->get_property<Properties::AreVelocityUpdatesRunning>()166 object->get_signal<Signals::HeadingChanged>(),
179 },167 object->get_signal<Signals::VelocityChanged>()}
180 signals
181 {
182 object->get_signal<Signals::PositionChanged>(),
183 object->get_signal<Signals::HeadingChanged>(),
184 object->get_signal<Signals::VelocityChanged>()
185 }
186 {168 {
187 }169 }
188170
@@ -205,27 +187,20 @@
205 // All known signals.187 // All known signals.
206 struct188 struct
207 {189 {
208 std::shared_ptr<core::dbus::Signal<190 std::shared_ptr<core::dbus::Signal<Signals::PositionChanged, Signals::PositionChanged::ArgumentType>>
209 Signals::PositionChanged,191 position_changed;
210 Signals::PositionChanged::ArgumentType192
211 >> position_changed;193 std::shared_ptr<core::dbus::Signal<Signals::HeadingChanged, Signals::HeadingChanged::ArgumentType>>
212194 heading_changed;
213 std::shared_ptr<core::dbus::Signal<195
214 Signals::HeadingChanged,196 std::shared_ptr<core::dbus::Signal<Signals::VelocityChanged, Signals::VelocityChanged::ArgumentType>>
215 Signals::HeadingChanged::ArgumentType197 velocity_changed;
216 >> heading_changed;
217
218 std::shared_ptr<core::dbus::Signal<
219 Signals::VelocityChanged,
220 Signals::VelocityChanged::ArgumentType
221 >> velocity_changed;
222 } signals;198 } signals;
223 };199 };
224
225};200};
226}201}
227}202}
228}203}
229}204}
230}205}
231#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_REMOTE_INTERFACE_H_206#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_REMOTE_INTERFACE_H_
232207
=== modified file 'include/location_service/com/ubuntu/location/providers/remote/skeleton.h'
--- include/location_service/com/ubuntu/location/providers/remote/skeleton.h 2014-09-12 13:11:42 +0000
+++ include/location_service/com/ubuntu/location/providers/remote/skeleton.h 2015-04-23 17:23:49 +0000
@@ -20,10 +20,14 @@
2020
21#include <com/ubuntu/location/provider.h>21#include <com/ubuntu/location/provider.h>
2222
23namespace core { namespace dbus {23namespace core
24{
25namespace dbus
26{
24class Bus;27class Bus;
25class Object;28class Object;
26}}29}
30}
2731
28namespace com32namespace com
29{33{
@@ -56,4 +60,4 @@
56}60}
57}61}
58}62}
59#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_REMOTE_SKELETON_H_63#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_REMOTE_SKELETON_H_
6064
=== modified file 'include/location_service/com/ubuntu/location/providers/remote/stub.h'
--- include/location_service/com/ubuntu/location/providers/remote/stub.h 2014-09-12 13:11:42 +0000
+++ include/location_service/com/ubuntu/location/providers/remote/stub.h 2015-04-23 17:23:49 +0000
@@ -20,10 +20,14 @@
2020
21#include <com/ubuntu/location/provider.h>21#include <com/ubuntu/location/provider.h>
2222
23namespace core { namespace dbus {23namespace core
24{
25namespace dbus
26{
24class Bus;27class Bus;
25class Object;28class Object;
26}}29}
30}
2731
28namespace com32namespace com
29{33{
@@ -52,4 +56,4 @@
52}56}
53}57}
54}58}
55#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_REMOTE_STUB_H_59#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_REMOTE_STUB_H_
5660
=== modified file 'include/location_service/com/ubuntu/location/providers/skyhook/provider.h'
--- include/location_service/com/ubuntu/location/providers/skyhook/provider.h 2013-12-10 09:42:54 +0000
+++ include/location_service/com/ubuntu/location/providers/skyhook/provider.h 2015-04-23 17:23:49 +0000
@@ -35,17 +35,26 @@
35{35{
36class Provider : public com::ubuntu::location::Provider36class Provider : public com::ubuntu::location::Provider
37{37{
38 public:38public:
39 static Provider::Ptr create_instance(const ProviderFactory::Configuration& config);39 static Provider::Ptr create_instance(const ProviderFactory::Configuration& config);
40 40
41 static const Provider::FeatureFlags& default_feature_flags();41 static const Provider::FeatureFlags& default_feature_flags();
42 static const Provider::RequirementFlags& default_requirement_flags();42 static const Provider::RequirementFlags& default_requirement_flags();
4343
44 struct Configuration44 struct Configuration
45 {45 {
46 static std::string key_username() { return "username"; }46 static std::string key_username()
47 static std::string key_realm() { return "realm"; }47 {
48 static std::string key_period() { return "period"; }48 return "username";
49 }
50 static std::string key_realm()
51 {
52 return "realm";
53 }
54 static std::string key_period()
55 {
56 return "period";
57 }
4958
50 std::string user_name;59 std::string user_name;
51 std::string realm;60 std::string realm;
@@ -68,7 +77,7 @@
68 virtual void start_heading_updates();77 virtual void start_heading_updates();
69 virtual void stop_heading_updates();78 virtual void stop_heading_updates();
7079
71 private:80private:
72 struct Private;81 struct Private;
73 std::unique_ptr<Private> d;82 std::unique_ptr<Private> d;
74};83};
@@ -77,4 +86,4 @@
77}86}
78}87}
79}88}
80#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_SKYHOOK_PROVIDER_H_89#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_SKYHOOK_PROVIDER_H_
8190
=== modified file 'include/location_service/com/ubuntu/location/proxy_provider.h'
--- include/location_service/com/ubuntu/location/proxy_provider.h 2014-06-20 07:40:34 +0000
+++ include/location_service/com/ubuntu/location/proxy_provider.h 2015-04-23 17:23:49 +0000
@@ -46,7 +46,7 @@
4646
47 virtual void start_heading_updates();47 virtual void start_heading_updates();
48 virtual void stop_heading_updates();48 virtual void stop_heading_updates();
49 49
50private:50private:
51 ProviderSelection providers;51 ProviderSelection providers;
5252
@@ -61,4 +61,4 @@
61}61}
62}62}
6363
64#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROXY_PROVIDER_H_64#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROXY_PROVIDER_H_
6565
=== modified file 'include/location_service/com/ubuntu/location/satellite_based_positioning_state.h'
--- include/location_service/com/ubuntu/location/satellite_based_positioning_state.h 2014-11-14 11:26:45 +0000
+++ include/location_service/com/ubuntu/location/satellite_based_positioning_state.h 2015-04-23 17:23:49 +0000
@@ -32,8 +32,8 @@
32 */32 */
33enum class SatelliteBasedPositioningState33enum class SatelliteBasedPositioningState
34{34{
35 on, ///< Satellite assisted positioning is on.35 on, ///< Satellite assisted positioning is on.
36 off ///< Satellite assisted positioning is off.36 off ///< Satellite assisted positioning is off.
37};37};
3838
39/** @brief Pretty prints the given state to the given stream. */39/** @brief Pretty prints the given state to the given stream. */
@@ -44,4 +44,4 @@
44}44}
45}45}
4646
47#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SATELLITE_BASED_POSITIONING_STATE_H_47#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SATELLITE_BASED_POSITIONING_STATE_H_
4848
=== modified file 'include/location_service/com/ubuntu/location/service/configuration.h'
--- include/location_service/com/ubuntu/location/service/configuration.h 2014-11-14 11:33:05 +0000
+++ include/location_service/com/ubuntu/location/service/configuration.h 2015-04-23 17:23:49 +0000
@@ -41,10 +41,9 @@
41 Configuration(const Configuration&) = delete;41 Configuration(const Configuration&) = delete;
42 Configuration& operator=(const Configuration&) = delete;42 Configuration& operator=(const Configuration&) = delete;
4343
44 virtual std::shared_ptr<Engine> the_engine(44 virtual std::shared_ptr<Engine> the_engine(const std::set<Provider::Ptr>& provider_set,
45 const std::set<Provider::Ptr>& provider_set,45 const ProviderSelectionPolicy::Ptr& provider_selection_policy) = 0;
46 const ProviderSelectionPolicy::Ptr& provider_selection_policy) = 0;46
47
48 virtual ProviderSelectionPolicy::Ptr the_provider_selection_policy() = 0;47 virtual ProviderSelectionPolicy::Ptr the_provider_selection_policy() = 0;
49 virtual std::set<Provider::Ptr> the_provider_set() = 0;48 virtual std::set<Provider::Ptr> the_provider_set() = 0;
50 virtual PermissionManager::Ptr the_permission_manager() = 0;49 virtual PermissionManager::Ptr the_permission_manager() = 0;
@@ -57,4 +56,4 @@
57}56}
58}57}
5958
60#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_CONFIGURATION_H_59#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_CONFIGURATION_H_
6160
=== 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-12-10 09:42:54 +0000
+++ include/location_service/com/ubuntu/location/service/default_permission_manager.h 2015-04-23 17:23:49 +0000
@@ -33,17 +33,15 @@
33{33{
34class DefaultPermissionManager : public PermissionManager34class DefaultPermissionManager : public PermissionManager
35{35{
36 public:36public:
37 typedef std::shared_ptr<DefaultPermissionManager> Ptr;37 typedef std::shared_ptr<DefaultPermissionManager> Ptr;
3838
39 DefaultPermissionManager();39 DefaultPermissionManager();
40 ~DefaultPermissionManager() noexcept;40 ~DefaultPermissionManager() noexcept;
41 41
42 Result check_permission_for_credentials(42 Result check_permission_for_credentials(const Criteria&, const Credentials& credentials);
43 const Criteria&,43
44 const Credentials& credentials);44private:
45
46 private:
47 pid_t pid;45 pid_t pid;
48 uid_t uid;46 uid_t uid;
49};47};
@@ -51,4 +49,4 @@
51}49}
52}50}
53}51}
54#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_PERMISSION_MANAGER_H_52#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_PERMISSION_MANAGER_H_
5553
=== modified file 'include/location_service/com/ubuntu/location/service/interface.h'
--- include/location_service/com/ubuntu/location/service/interface.h 2014-08-01 15:59:25 +0000
+++ include/location_service/com/ubuntu/location/service/interface.h 2015-04-23 17:23:49 +0000
@@ -45,7 +45,7 @@
45 */45 */
46class Interface46class Interface
47{47{
48 protected:48protected:
49 struct Errors49 struct Errors
50 {50 {
51 struct InsufficientPermissions51 struct InsufficientPermissions
@@ -70,10 +70,7 @@
7070
71 inline static const std::string& name()71 inline static const std::string& name()
72 {72 {
73 static const std::string s73 static const std::string s{"CreateSessionForCriteria"};
74 {
75 "CreateSessionForCriteria"
76 };
77 return s;74 return s;
78 }75 }
7976
@@ -91,10 +88,7 @@
91 {88 {
92 inline static const std::string& name()89 inline static const std::string& name()
93 {90 {
94 static const std::string s91 static const std::string s{"DoesSatelliteBasedPositioning"};
95 {
96 "DoesSatelliteBasedPositioning"
97 };
98 return s;92 return s;
99 }93 }
10094
@@ -108,10 +102,7 @@
108 {102 {
109 inline static const std::string& name()103 inline static const std::string& name()
110 {104 {
111 static const std::string s105 static const std::string s{"DoesReportCellAndWifiIds"};
112 {
113 "DoesReportCellAndWifiIds"
114 };
115 return s;106 return s;
116 }107 }
117108
@@ -125,10 +116,7 @@
125 {116 {
126 inline static const std::string& name()117 inline static const std::string& name()
127 {118 {
128 static const std::string s119 static const std::string s{"IsOnline"};
129 {
130 "IsOnline"
131 };
132 return s;120 return s;
133 }121 }
134122
@@ -142,10 +130,7 @@
142 {130 {
143 inline static const std::string& name()131 inline static const std::string& name()
144 {132 {
145 static const std::string s133 static const std::string s{"VisibleSpaceVehicles"};
146 {
147 "VisibleSpaceVehicles"
148 };
149 return s;134 return s;
150 }135 }
151136
@@ -159,7 +144,7 @@
159144
160 Interface() = default;145 Interface() = default;
161146
162 public:147public:
163 typedef std::shared_ptr<Interface> Ptr;148 typedef std::shared_ptr<Interface> Ptr;
164149
165 /**150 /**
@@ -222,15 +207,12 @@
222{207{
223namespace traits208namespace traits
224{209{
225template<>210template <>
226struct Service<com::ubuntu::location::service::Interface>211struct Service<com::ubuntu::location::service::Interface>
227{212{
228 static const std::string& interface_name()213 static const std::string& interface_name()
229 {214 {
230 static const std::string s215 static const std::string s{"com.ubuntu.location.Service"};
231 {
232 "com.ubuntu.location.Service"
233 };
234 return s;216 return s;
235 }217 }
236};218};
@@ -240,4 +222,4 @@
240222
241#include <com/ubuntu/location/codec.h>223#include <com/ubuntu/location/codec.h>
242224
243#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_225#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_
244226
=== modified file 'include/location_service/com/ubuntu/location/service/permission_manager.h'
--- include/location_service/com/ubuntu/location/service/permission_manager.h 2014-06-23 04:57:59 +0000
+++ include/location_service/com/ubuntu/location/service/permission_manager.h 2015-04-23 17:23:49 +0000
@@ -53,8 +53,8 @@
53 */53 */
54 enum class Result54 enum class Result
55 {55 {
56 granted, ///< The app is allowed to access the location service.56 granted, ///< The app is allowed to access the location service.
57 rejected ///< The app is not allowed to access the location service.57 rejected ///< The app is not allowed to access the location service.
58 };58 };
5959
60 virtual ~PermissionManager() = default;60 virtual ~PermissionManager() = default;
@@ -67,10 +67,8 @@
67 * @param credentials The credentials identifying the remote peer.67 * @param credentials The credentials identifying the remote peer.
68 * @return Result::granted if the remote peer is allowed to access the location service, Result::rejected otherwise.68 * @return Result::granted if the remote peer is allowed to access the location service, Result::rejected otherwise.
69 */69 */
70 virtual Result check_permission_for_credentials(70 virtual Result check_permission_for_credentials(const Criteria& criteria, const Credentials& credentials) = 0;
71 const Criteria& criteria,71
72 const Credentials& credentials) = 0;
73
74protected:72protected:
75 PermissionManager() = default;73 PermissionManager() = default;
76};74};
@@ -78,4 +76,4 @@
78}76}
79}77}
80}78}
81#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PERMISSION_MANAGER_H_79#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PERMISSION_MANAGER_H_
8280
=== modified file 'include/location_service/com/ubuntu/location/service/session/implementation.h'
--- include/location_service/com/ubuntu/location/service/session/implementation.h 2014-02-03 13:52:21 +0000
+++ include/location_service/com/ubuntu/location/service/session/implementation.h 2015-04-23 17:23:49 +0000
@@ -36,7 +36,7 @@
36{36{
37class Implementation : public Interface37class Implementation : public Interface
38{38{
39 public:39public:
40 Implementation(const Provider::Ptr& provider);40 Implementation(const Provider::Ptr& provider);
41 Implementation(const Implementation&) = delete;41 Implementation(const Implementation&) = delete;
42 virtual ~Implementation() noexcept;42 virtual ~Implementation() noexcept;
@@ -51,7 +51,7 @@
51 virtual void start_heading_updates();51 virtual void start_heading_updates();
52 virtual void stop_heading_updates() noexcept;52 virtual void stop_heading_updates() noexcept;
5353
54 private:54private:
55 struct Private;55 struct Private;
56 std::unique_ptr<Private> d;56 std::unique_ptr<Private> d;
57};57};
@@ -61,4 +61,4 @@
61}61}
62}62}
6363
64#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_64#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_
6565
=== modified file 'include/location_service/com/ubuntu/location/service/session/interface.h'
--- include/location_service/com/ubuntu/location/service/session/interface.h 2014-05-19 09:55:25 +0000
+++ include/location_service/com/ubuntu/location/service/session/interface.h 2015-04-23 17:23:49 +0000
@@ -70,8 +70,8 @@
70 */70 */
71 enum class Status71 enum class Status
72 {72 {
73 enabled, ///< Updates are enabled and delivered to this session.73 enabled, ///< Updates are enabled and delivered to this session.
74 disabled ///< Updates are disabled and not delivered to this session.74 disabled ///< Updates are disabled and not delivered to this session.
75 };75 };
7676
77 /**77 /**
@@ -114,7 +114,7 @@
114 */114 */
115 virtual Updates& updates();115 virtual Updates& updates();
116116
117protected: 117protected:
118 Interface();118 Interface();
119119
120private:120private:
@@ -127,4 +127,4 @@
127}127}
128}128}
129129
130#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_130#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_
131131
=== modified file 'include/location_service/com/ubuntu/location/service/session/skeleton.h'
--- include/location_service/com/ubuntu/location/service/session/skeleton.h 2014-08-01 12:51:25 +0000
+++ include/location_service/com/ubuntu/location/service/session/skeleton.h 2015-04-23 17:23:49 +0000
@@ -119,4 +119,4 @@
119}119}
120}120}
121121
122#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_SKELETON_H_122#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_SKELETON_H_
123123
=== modified file 'include/location_service/com/ubuntu/location/service/session/stub.h'
--- include/location_service/com/ubuntu/location/service/session/stub.h 2014-02-03 13:52:21 +0000
+++ include/location_service/com/ubuntu/location/service/session/stub.h 2015-04-23 17:23:49 +0000
@@ -42,10 +42,8 @@
42{42{
43class Stub : public core::dbus::Stub<Interface>43class Stub : public core::dbus::Stub<Interface>
44{44{
45 public:45public:
46 Stub(46 Stub(const core::dbus::Bus::Ptr& bus, const core::dbus::types::ObjectPath& session_path);
47 const core::dbus::Bus::Ptr& bus,
48 const core::dbus::types::ObjectPath& session_path);
49 Stub(const Stub&) = delete;47 Stub(const Stub&) = delete;
50 virtual ~Stub() noexcept;48 virtual ~Stub() noexcept;
51 Stub& operator=(const Stub&) = delete;49 Stub& operator=(const Stub&) = delete;
@@ -61,7 +59,7 @@
61 virtual void start_heading_updates();59 virtual void start_heading_updates();
62 virtual void stop_heading_updates() noexcept;60 virtual void stop_heading_updates() noexcept;
6361
64 private:62private:
65 struct Private;63 struct Private;
66 std::unique_ptr<Private> d;64 std::unique_ptr<Private> d;
67};65};
@@ -70,4 +68,4 @@
70}68}
71}69}
72}70}
73#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_STUB_H_71#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_STUB_H_
7472
=== modified file 'include/location_service/com/ubuntu/location/service/skeleton.h'
--- include/location_service/com/ubuntu/location/service/skeleton.h 2015-02-13 13:19:18 +0000
+++ include/location_service/com/ubuntu/location/service/skeleton.h 2015-04-23 17:23:49 +0000
@@ -38,9 +38,8 @@
38{38{
39namespace service39namespace service
40{40{
41class Skeleton41class Skeleton : public core::dbus::Skeleton<com::ubuntu::location::service::Interface>,
42 : public core::dbus::Skeleton<com::ubuntu::location::service::Interface>,42 public std::enable_shared_from_this<Skeleton>
43 public std::enable_shared_from_this<Skeleton>
44{43{
45public:44public:
46 typedef std::shared_ptr<Skeleton> Ptr;45 typedef std::shared_ptr<Skeleton> Ptr;
@@ -123,10 +122,9 @@
123122
124 // Tries to register the given session under the given path in the session store.123 // Tries to register the given session under the given path in the session store.
125 // Returns true iff the session has been added to the store.124 // Returns true iff the session has been added to the store.
126 bool add_to_session_store_for_path(125 bool add_to_session_store_for_path(const core::dbus::types::ObjectPath& path,
127 const core::dbus::types::ObjectPath& path,126 std::unique_ptr<core::dbus::ServiceWatcher> watcher,
128 std::unique_ptr<core::dbus::ServiceWatcher> watcher,127 const session::Interface::Ptr& session);
129 const session::Interface::Ptr& session);
130128
131 // Removes the session with the given path from the session store.129 // Removes the session with the given path from the session store.
132 void remove_from_session_store_for_path(const core::dbus::types::ObjectPath& path);130 void remove_from_session_store_for_path(const core::dbus::types::ObjectPath& path);
@@ -145,19 +143,19 @@
145 // The skeleton object representing com.ubuntu.location.service.Interface on the bus.143 // The skeleton object representing com.ubuntu.location.service.Interface on the bus.
146 core::dbus::Object::Ptr object;144 core::dbus::Object::Ptr object;
147 // We emit property changes manually.145 // We emit property changes manually.
148 core::dbus::Signal146 core::dbus::Signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged,
149 <147 core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType>::Ptr
150 core::dbus::interfaces::Properties::Signals::PropertiesChanged,148 properties_changed;
151 core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType
152 >::Ptr properties_changed;
153149
154 // DBus properties as exposed on the bus for com.ubuntu.location.service.Interface150 // DBus properties as exposed on the bus for com.ubuntu.location.service.Interface
155 struct151 struct
156 {152 {
157 std::shared_ptr< core::dbus::Property<Interface::Properties::DoesSatelliteBasedPositioning> > does_satellite_based_positioning;153 std::shared_ptr<core::dbus::Property<Interface::Properties::DoesSatelliteBasedPositioning>>
158 std::shared_ptr< core::dbus::Property<Interface::Properties::DoesReportCellAndWifiIds> > does_report_cell_and_wifi_ids;154 does_satellite_based_positioning;
159 std::shared_ptr< core::dbus::Property<Interface::Properties::IsOnline> > is_online;155 std::shared_ptr<core::dbus::Property<Interface::Properties::DoesReportCellAndWifiIds>>
160 std::shared_ptr< core::dbus::Property<Interface::Properties::VisibleSpaceVehicles> > visible_space_vehicles;156 does_report_cell_and_wifi_ids;
157 std::shared_ptr<core::dbus::Property<Interface::Properties::IsOnline>> is_online;
158 std::shared_ptr<core::dbus::Property<Interface::Properties::VisibleSpaceVehicles>> visible_space_vehicles;
161 } properties;159 } properties;
162 // We sign up to property changes here, to be able to report them to the bus160 // We sign up to property changes here, to be able to report them to the bus
163 struct161 struct
@@ -181,4 +179,4 @@
181}179}
182}180}
183}181}
184#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SKELETON_H_182#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SKELETON_H_
185183
=== modified file 'include/location_service/com/ubuntu/location/service/stub.h'
--- include/location_service/com/ubuntu/location/service/stub.h 2014-02-03 13:52:21 +0000
+++ include/location_service/com/ubuntu/location/service/stub.h 2015-04-23 17:23:49 +0000
@@ -33,7 +33,7 @@
33{33{
34class Stub : public core::dbus::Stub<Interface>34class Stub : public core::dbus::Stub<Interface>
35{35{
36 public:36public:
37 Stub(const dbus::Bus::Ptr& connection);37 Stub(const dbus::Bus::Ptr& connection);
38 Stub(const Stub&) = delete;38 Stub(const Stub&) = delete;
39 Stub& operator=(const Stub&) = delete;39 Stub& operator=(const Stub&) = delete;
@@ -42,10 +42,10 @@
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();43 core::Property<bool>& does_satellite_based_positioning();
44 core::Property<bool>& does_report_cell_and_wifi_ids();44 core::Property<bool>& does_report_cell_and_wifi_ids();
45 core::Property<bool>& is_online(); 45 core::Property<bool>& is_online();
46 core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>>& visible_space_vehicles();46 core::Property<std::map<SpaceVehicle::Key, SpaceVehicle>>& visible_space_vehicles();
4747
48 private:48private:
49 struct Private;49 struct Private;
50 std::unique_ptr<Private> d;50 std::unique_ptr<Private> d;
51};51};
@@ -53,4 +53,4 @@
53}53}
54}54}
55}55}
56#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_STUB_H_56#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_STUB_H_
5757
=== modified file 'include/location_service/com/ubuntu/location/space_vehicle.h'
--- include/location_service/com/ubuntu/location/space_vehicle.h 2014-05-20 07:26:03 +0000
+++ include/location_service/com/ubuntu/location/space_vehicle.h 2015-04-23 17:23:49 +0000
@@ -38,21 +38,23 @@
38 /** @brief Enumerates all known space-vehicle types. */38 /** @brief Enumerates all known space-vehicle types. */
39 enum class Type39 enum class Type
40 {40 {
41 unknown, ///< Unknown (and thus invalid) type.41 unknown, ///< Unknown (and thus invalid) type.
42 beidou, ///< People's Republic of China's regional system, currently limited to Asia and the West Pacific42 beidou, ///< People's Republic of China's regional system, currently limited to Asia and the West Pacific
43 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 galileo, ///< A global system being developed by the European Union and other partner countries, planned to be
44 glonass, ///< Russia's global navigation system. Fully operational worldwide.44 ///operational by 2014 (and fully deployed by 2019).
45 gps, ///< Fully operational worldwide.45 glonass, ///< Russia's global navigation system. Fully operational worldwide.
46 compass, ///< People's Republic of China's global system, planned to be operational by 2020.46 gps, ///< Fully operational worldwide.
47 irnss, ///< India's regional navigation system, planned to be operational by 2014, covering India and Northern Indian Ocean.47 compass, ///< People's Republic of China's global system, planned to be operational by 2020.
48 qzss ///< Japanese regional system covering Asia and Oceania.48 irnss, ///< India's regional navigation system, planned to be operational by 2014, covering India and Northern
49 }; 49 ///Indian Ocean.
50 qzss ///< Japanese regional system covering Asia and Oceania.
51 };
5052
51 /** @brief Uniquely identifies a space vehicle, given its type and its id. */53 /** @brief Uniquely identifies a space vehicle, given its type and its id. */
52 struct Key54 struct Key
53 {55 {
54 Type type = Type::unknown; ///< The positioning system this vehicle belongs to.56 Type type = Type::unknown; ///< The positioning system this vehicle belongs to.
55 Id id = 0; ///< Unique id of the space vehicle.57 Id id = 0; ///< Unique id of the space vehicle.
5658
57 inline bool operator==(const SpaceVehicle::Key& rhs) const59 inline bool operator==(const SpaceVehicle::Key& rhs) const
58 {60 {
@@ -62,7 +64,9 @@
62 inline bool operator<(const SpaceVehicle::Key& rhs) const64 inline bool operator<(const SpaceVehicle::Key& rhs) const
63 {65 {
64 if (type != rhs.type)66 if (type != rhs.type)
67 {
65 return type < rhs.type;68 return type < rhs.type;
69 }
6670
67 return id < rhs.id;71 return id < rhs.id;
68 }72 }
@@ -70,12 +74,9 @@
7074
71 inline bool operator==(const SpaceVehicle& rhs) const75 inline bool operator==(const SpaceVehicle& rhs) const
72 {76 {
73 return key == rhs.key &&77 return key == rhs.key && has_almanac_data == rhs.has_almanac_data &&
74 has_almanac_data == rhs.has_almanac_data &&78 has_ephimeris_data == rhs.has_ephimeris_data && used_in_fix == rhs.used_in_fix &&
75 has_ephimeris_data == rhs.has_ephimeris_data &&79 units::roughly_equals(azimuth, rhs.azimuth) && units::roughly_equals(elevation, rhs.elevation);
76 used_in_fix == rhs.used_in_fix &&
77 units::roughly_equals(azimuth, rhs.azimuth) &&
78 units::roughly_equals(elevation, rhs.elevation);
79 }80 }
8081
81 inline bool operator<(const SpaceVehicle& rhs) const82 inline bool operator<(const SpaceVehicle& rhs) const
@@ -83,28 +84,25 @@
83 return key < rhs.key;84 return key < rhs.key;
84 }85 }
8586
86 Key key; ///< Unique key identifying an instance.87 Key key; ///< Unique key identifying an instance.
87 float snr = -std::numeric_limits<float>::max(); ///< Signal to noise ratio;88 float snr = -std::numeric_limits<float>::max(); ///< Signal to noise ratio;
88 bool has_almanac_data = false; ///< Almanac data available for this vehicle.89 bool has_almanac_data = false; ///< Almanac data available for this vehicle.
89 bool has_ephimeris_data = false; ///< Ephimeris data is available for this vehicle.90 bool has_ephimeris_data = false; ///< Ephimeris data is available for this vehicle.
90 bool used_in_fix = false; ///< This vehicle has been used to obtain a fix.91 bool used_in_fix = false; ///< This vehicle has been used to obtain a fix.
91 units::Quantity<units::PlaneAngle> azimuth; ///< Azimuth of SV.92 units::Quantity<units::PlaneAngle> azimuth; ///< Azimuth of SV.
92 units::Quantity<units::PlaneAngle> elevation; ///< Elevation of SV.93 units::Quantity<units::PlaneAngle> elevation; ///< Elevation of SV.
93};94};
9495
95inline std::ostream& operator<<(std::ostream& out, const SpaceVehicle& sv)96inline std::ostream& operator<<(std::ostream& out, const SpaceVehicle& sv)
96{97{
97 static const std::map<SpaceVehicle::Type, std::string> lut =98 static const std::map<SpaceVehicle::Type, std::string> lut = {{SpaceVehicle::Type::unknown, "unknown"},
98 {99 {SpaceVehicle::Type::beidou, "beidou"},
99 {SpaceVehicle::Type::unknown, "unknown"},100 {SpaceVehicle::Type::galileo, "galileo"},
100 {SpaceVehicle::Type::beidou, "beidou"},101 {SpaceVehicle::Type::glonass, "glonass"},
101 {SpaceVehicle::Type::galileo, "galileo"},102 {SpaceVehicle::Type::gps, "gps"},
102 {SpaceVehicle::Type::glonass, "glonass"},103 {SpaceVehicle::Type::compass, "compass"},
103 {SpaceVehicle::Type::gps, "gps"},104 {SpaceVehicle::Type::irnss, "irnss"},
104 {SpaceVehicle::Type::compass, "compass"},105 {SpaceVehicle::Type::qzss, "qzss"}};
105 {SpaceVehicle::Type::irnss, "irnss"},
106 {SpaceVehicle::Type::qzss, "qzss" }
107 };
108 return out << "("106 return out << "("
109 << "type: " << lut.at(sv.key.type) << ", "107 << "type: " << lut.at(sv.key.type) << ", "
110 << "prn: " << sv.key.id << ", "108 << "prn: " << sv.key.id << ", "
@@ -113,11 +111,10 @@
113 << "has_ephimeris_data: " << sv.has_ephimeris_data << ", "111 << "has_ephimeris_data: " << sv.has_ephimeris_data << ", "
114 << "used_in_fix: " << sv.used_in_fix << ", "112 << "used_in_fix: " << sv.used_in_fix << ", "
115 << "azimuth: " << sv.azimuth << ", "113 << "azimuth: " << sv.azimuth << ", "
116 << "elevation: " << sv.elevation114 << "elevation: " << sv.elevation << ")";
117 << ")";
118}115}
119}116}
120}117}
121}118}
122119
123#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SPACE_VEHICLE_H_120#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SPACE_VEHICLE_H_
124121
=== modified file 'include/location_service/com/ubuntu/location/units/units.h'
--- include/location_service/com/ubuntu/location/units/units.h 2013-12-10 09:42:54 +0000
+++ include/location_service/com/ubuntu/location/units/units.h 2015-04-23 17:23:49 +0000
@@ -49,7 +49,7 @@
49static const Velocity MeterPerSecond;49static const Velocity MeterPerSecond;
50static const Velocity MetersPerSecond;50static const Velocity MetersPerSecond;
5151
52template<typename Unit>52template <typename Unit>
53using Quantity = boost::units::quantity<Unit, double>;53using Quantity = boost::units::quantity<Unit, double>;
5454
55typedef boost::units::si::dimensionless Dimensionless;55typedef boost::units::si::dimensionless Dimensionless;
@@ -58,15 +58,14 @@
58using boost::units::cos;58using boost::units::cos;
59using boost::units::atan2;59using boost::units::atan2;
6060
61template<typename Unit>61template <typename Unit>
62inline bool roughly_equals(const Quantity<Unit>& lhs, const Quantity<Unit>& rhs)62inline bool roughly_equals(const Quantity<Unit>& lhs, const Quantity<Unit>& rhs)
63{63{
64 return std::fabs(lhs.value()-rhs.value()) <= std::numeric_limits<double>::epsilon();64 return std::fabs(lhs.value() - rhs.value()) <= std::numeric_limits<double>::epsilon();
65}65}
66}66}
67}67}
68}68}
69}69}
7070
71#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_UNITS_UNITS_H_71#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_UNITS_UNITS_H_
72
7372
=== modified file 'include/location_service/com/ubuntu/location/update.h'
--- include/location_service/com/ubuntu/location/update.h 2013-12-10 09:42:54 +0000
+++ include/location_service/com/ubuntu/location/update.h 2015-04-23 17:23:49 +0000
@@ -32,7 +32,7 @@
32 * @brief Templated class that wraps a value and timestamp.32 * @brief Templated class that wraps a value and timestamp.
33 * @tparam T The contained value.33 * @tparam T The contained value.
34 */34 */
35template<typename T>35template <typename T>
36struct Update36struct Update
37{37{
38 /**38 /**
@@ -40,9 +40,9 @@
40 * @param [in] value The value delivered with this update.40 * @param [in] value The value delivered with this update.
41 * @param [in] when The timestamp when the value was measured.41 * @param [in] when The timestamp when the value was measured.
42 */42 */
43 inline Update(const T& value = T{},43 inline Update(const T& value = T{}, const Clock::Timestamp& when = Clock::now())
44 const Clock::Timestamp& when = Clock::now())44 : value{value}
45 : value{value}, when{when}45 , when{when}
46 {46 {
47 }47 }
4848
@@ -78,15 +78,14 @@
78 * @param out The stream to write to.78 * @param out The stream to write to.
79 * @param update The value to be printed.79 * @param update The value to be printed.
80 */80 */
81template<typename T>81template <typename T>
82inline std::ostream& operator<<(std::ostream& out, const Update<T>& update)82inline std::ostream& operator<<(std::ostream& out, const Update<T>& update)
83{83{
84 out << "Update(" << update.value << ", " << update.when.time_since_epoch().count() << ")";84 out << "Update(" << update.value << ", " << update.when.time_since_epoch().count() << ")";
85 return out;85 return out;
86}86}
8787}
88}88}
89}89}
90}90
9191#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_
92#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_
9392
=== modified file 'include/location_service/com/ubuntu/location/velocity.h'
--- include/location_service/com/ubuntu/location/velocity.h 2014-06-20 07:40:34 +0000
+++ include/location_service/com/ubuntu/location/velocity.h 2015-04-23 17:23:49 +0000
@@ -32,4 +32,4 @@
32}32}
33}33}
3434
35#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_35#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_
3636
=== modified file 'include/location_service/com/ubuntu/location/wgs84/altitude.h'
--- include/location_service/com/ubuntu/location/wgs84/altitude.h 2013-12-10 09:42:54 +0000
+++ include/location_service/com/ubuntu/location/wgs84/altitude.h 2015-04-23 17:23:49 +0000
@@ -35,13 +35,15 @@
35}35}
36typedef Coordinate<tag::Altitude, units::Length> Altitude;36typedef Coordinate<tag::Altitude, units::Length> Altitude;
3737
38template<>38template <>
39struct CoordinateTraits<Altitude>39struct CoordinateTraits<Altitude>
40{40{
41 static void check_and_throw_if_invalid(const typename Altitude::Quantity&) {}41 static void check_and_throw_if_invalid(const typename Altitude::Quantity&)
42 {
43 }
42};44};
43}45}
44}46}
45}47}
46}48}
47#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_ALTITUDE_H_49#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_ALTITUDE_H_
4850
=== modified file 'include/location_service/com/ubuntu/location/wgs84/coordinate.h'
--- include/location_service/com/ubuntu/location/wgs84/coordinate.h 2013-12-12 14:36:32 +0000
+++ include/location_service/com/ubuntu/location/wgs84/coordinate.h 2015-04-23 17:23:49 +0000
@@ -30,7 +30,7 @@
30{30{
31namespace wgs8431namespace wgs84
32{32{
33template<typename Coordinate>33template <typename Coordinate>
34struct CoordinateTraits34struct CoordinateTraits
35{35{
36 static void check_and_throw_if_invalid(const typename Coordinate::Quantity& coordinate)36 static void check_and_throw_if_invalid(const typename Coordinate::Quantity& coordinate)
@@ -38,7 +38,7 @@
38 }38 }
39};39};
4040
41template<typename Tag, typename UnitType>41template <typename Tag, typename UnitType>
42class Coordinate42class Coordinate
43{43{
44public:44public:
@@ -48,15 +48,15 @@
48 explicit Coordinate(const Quantity& value = Quantity())48 explicit Coordinate(const Quantity& value = Quantity())
49 : value(value)49 : value(value)
50 {50 {
51 CoordinateTraits<Coordinate<Tag,UnitType>>::check_and_throw_if_invalid(value);51 CoordinateTraits<Coordinate<Tag, UnitType>>::check_and_throw_if_invalid(value);
52 }52 }
5353
54 bool operator==(const Coordinate<Tag,UnitType>& rhs) const54 bool operator==(const Coordinate<Tag, UnitType>& rhs) const
55 {55 {
56 return value == rhs.value;56 return value == rhs.value;
57 }57 }
5858
59 bool operator!=(const Coordinate<Tag,UnitType>& rhs) const59 bool operator!=(const Coordinate<Tag, UnitType>& rhs) const
60 {60 {
61 return value != rhs.value;61 return value != rhs.value;
62 }62 }
@@ -64,14 +64,14 @@
64 Quantity value;64 Quantity value;
65};65};
6666
67template<typename T, typename U>67template <typename T, typename U>
68Coordinate<T,U> operator-(const Coordinate<T,U>& lhs, const Coordinate<T,U>& rhs)68Coordinate<T, U> operator-(const Coordinate<T, U>& lhs, const Coordinate<T, U>& rhs)
69{69{
70 return Coordinate<T,U> {rhs.value - lhs.value};70 return Coordinate<T, U>{rhs.value - lhs.value};
71}71}
7272
73template<typename T, typename U>73template <typename T, typename U>
74std::ostream& operator<<(std::ostream& out, const Coordinate<T,U>& coord)74std::ostream& operator<<(std::ostream& out, const Coordinate<T, U>& coord)
75{75{
76 out << "Coordinate(" << coord.value << ")";76 out << "Coordinate(" << coord.value << ")";
77 return out;77 return out;
@@ -80,4 +80,4 @@
80}80}
81}81}
82}82}
83#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_COORDINATE_H_83#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_COORDINATE_H_
8484
=== modified file 'include/location_service/com/ubuntu/location/wgs84/latitude.h'
--- include/location_service/com/ubuntu/location/wgs84/latitude.h 2013-12-10 09:42:54 +0000
+++ include/location_service/com/ubuntu/location/wgs84/latitude.h 2015-04-23 17:23:49 +0000
@@ -37,7 +37,7 @@
37}37}
38typedef Coordinate<tag::Latitude, units::PlaneAngle> Latitude;38typedef Coordinate<tag::Latitude, units::PlaneAngle> Latitude;
3939
40template<>40template <>
41struct CoordinateTraits<Latitude>41struct CoordinateTraits<Latitude>
42{42{
43 static double min()43 static double min()
@@ -52,13 +52,17 @@
52 static void check_and_throw_if_invalid(const typename Latitude::Quantity& coordinate)52 static void check_and_throw_if_invalid(const typename Latitude::Quantity& coordinate)
53 {53 {
54 if (coordinate.value() < min())54 if (coordinate.value() < min())
55 {
55 throw std::out_of_range(u8"Latitude(coordinate.value() < min())");56 throw std::out_of_range(u8"Latitude(coordinate.value() < min())");
57 }
56 if (coordinate.value() > max())58 if (coordinate.value() > max())
59 {
57 throw std::out_of_range(u8"Latitude(coordinate.value() > max())");60 throw std::out_of_range(u8"Latitude(coordinate.value() > max())");
61 }
58 }62 }
59};63};
60}64}
61}65}
62}66}
63}67}
64#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_68#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_
6569
=== modified file 'include/location_service/com/ubuntu/location/wgs84/longitude.h'
--- include/location_service/com/ubuntu/location/wgs84/longitude.h 2013-12-10 09:42:54 +0000
+++ include/location_service/com/ubuntu/location/wgs84/longitude.h 2015-04-23 17:23:49 +0000
@@ -37,7 +37,7 @@
37}37}
38typedef Coordinate<tag::Longitude, units::PlaneAngle> Longitude;38typedef Coordinate<tag::Longitude, units::PlaneAngle> Longitude;
3939
40template<>40template <>
41struct CoordinateTraits<Longitude>41struct CoordinateTraits<Longitude>
42{42{
43 static double min()43 static double min()
@@ -52,13 +52,17 @@
52 static void check_and_throw_if_invalid(const typename Longitude::Quantity& coordinate)52 static void check_and_throw_if_invalid(const typename Longitude::Quantity& coordinate)
53 {53 {
54 if (coordinate.value() < min())54 if (coordinate.value() < min())
55 {
55 throw std::out_of_range(u8"Longitude(coordinate.value() < min())");56 throw std::out_of_range(u8"Longitude(coordinate.value() < min())");
57 }
56 if (coordinate.value() > max())58 if (coordinate.value() > max())
59 {
57 throw std::out_of_range(u8"Longitude(coordinate.value() > max())");60 throw std::out_of_range(u8"Longitude(coordinate.value() > max())");
61 }
58 }62 }
59};63};
60}64}
61}65}
62}66}
63}67}
64#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_68#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_
6569
=== modified 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 2014-11-14 11:26:45 +0000
+++ include/location_service/com/ubuntu/location/wifi_and_cell_reporting_state.h 2015-04-23 17:23:49 +0000
@@ -28,8 +28,8 @@
28{28{
29enum class WifiAndCellIdReportingState29enum class WifiAndCellIdReportingState
30{30{
31 on, ///< Wifi and Cell Ids might be reported to online location services.31 on, ///< Wifi and Cell Ids might be reported to online location services.
32 off ///< Wifi and Cell Ids are _not_ reported. This is the default value.32 off ///< Wifi and Cell Ids are _not_ reported. This is the default value.
33};33};
3434
35/** @brief Pretty prints the given state to the given stream. */35/** @brief Pretty prints the given state to the given stream. */
@@ -40,4 +40,4 @@
40}40}
41}41}
4242
43#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WIFI_AND_CELL_REPORTING_STATE_H_43#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WIFI_AND_CELL_REPORTING_STATE_H_
4444
=== modified file 'src/location_service/com/ubuntu/location/boost_ptree_settings.cpp'
--- src/location_service/com/ubuntu/location/boost_ptree_settings.cpp 2015-01-14 13:41:54 +0000
+++ src/location_service/com/ubuntu/location/boost_ptree_settings.cpp 2015-04-23 17:23:49 +0000
@@ -25,7 +25,8 @@
25namespace location = com::ubuntu::location;25namespace location = com::ubuntu::location;
2626
27// Creates a new instance, reading values from the given filename.27// Creates a new instance, reading values from the given filename.
28location::BoostPtreeSettings::BoostPtreeSettings(const std::string& fn) : fn{fn}28location::BoostPtreeSettings::BoostPtreeSettings(const std::string& fn)
29 : fn{fn}
29{30{
30 try31 try
31 {32 {
@@ -52,7 +53,7 @@
5253
53// Returns true iff a value is known for the given key.54// Returns true iff a value is known for the given key.
54bool location::BoostPtreeSettings::has_value_for_key(const std::string& key) const55bool location::BoostPtreeSettings::has_value_for_key(const std::string& key) const
55{ 56{
56 return tree.count(key) > 0;57 return tree.count(key) > 0;
57}58}
5859
5960
=== modified file 'src/location_service/com/ubuntu/location/boost_ptree_settings.h'
--- src/location_service/com/ubuntu/location/boost_ptree_settings.h 2014-11-14 19:24:45 +0000
+++ src/location_service/com/ubuntu/location/boost_ptree_settings.h 2015-04-23 17:23:49 +0000
@@ -59,4 +59,4 @@
59}59}
60}60}
6161
62#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_BOOST_PTREE_SETTINGS_H_62#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_BOOST_PTREE_SETTINGS_H_
6363
=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_radio_cell.cpp'
--- src/location_service/com/ubuntu/location/connectivity/cached_radio_cell.cpp 2014-11-10 12:31:47 +0000
+++ src/location_service/com/ubuntu/location/connectivity/cached_radio_cell.cpp 2015-04-23 17:23:49 +0000
@@ -24,15 +24,14 @@
24{24{
25// We use this for debugging purposes.25// We use this for debugging purposes.
26const bool also_apply_cell_change_heuristics_to_gsm_cells =26const bool also_apply_cell_change_heuristics_to_gsm_cells =
27 core::posix::this_process::env::get(27 core::posix::this_process::env::get("COM_UBUNTU_LOCATION_CONNECTIVITY_DATA_CELL_FOR_GSM_TOO", "false") == "true";
28 "COM_UBUNTU_LOCATION_CONNECTIVITY_DATA_CELL_FOR_GSM_TOO",
29 "false") == "true";
3028
31std::int64_t timeout_in_seconds()29std::int64_t timeout_in_seconds()
32{30{
33 auto value = core::posix::this_process::env::get("COM_UBUNTU_LOCATION_CONNECTIVITY_DATA_CELL_TIMEOUT", "60");31 auto value = core::posix::this_process::env::get("COM_UBUNTU_LOCATION_CONNECTIVITY_DATA_CELL_TIMEOUT", "60");
34 std::stringstream ss(value);32 std::stringstream ss(value);
35 std::uint64_t result; ss >> result;33 std::uint64_t result;
34 ss >> result;
3635
37 return result;36 return result;
38}37}
@@ -50,65 +49,56 @@
5049
51const std::map<std::string, com::ubuntu::location::connectivity::RadioCell::Type>& detail::CachedRadioCell::type_lut()50const std::map<std::string, com::ubuntu::location::connectivity::RadioCell::Type>& detail::CachedRadioCell::type_lut()
52{51{
53 static const std::map<std::string, com::ubuntu::location::connectivity::RadioCell::Type> lut52 static const std::map<std::string, com::ubuntu::location::connectivity::RadioCell::Type> lut{
54 {53 {org::Ofono::Manager::Modem::NetworkRegistration::Technology::gsm(),
55 {54 com::ubuntu::location::connectivity::RadioCell::Type::gsm},
56 org::Ofono::Manager::Modem::NetworkRegistration::Technology::gsm(),55 {org::Ofono::Manager::Modem::NetworkRegistration::Technology::lte(),
57 com::ubuntu::location::connectivity::RadioCell::Type::gsm56 com::ubuntu::location::connectivity::RadioCell::Type::lte},
58 },57 {org::Ofono::Manager::Modem::NetworkRegistration::Technology::umts(),
59 {58 com::ubuntu::location::connectivity::RadioCell::Type::umts},
60 org::Ofono::Manager::Modem::NetworkRegistration::Technology::lte(),59 {org::Ofono::Manager::Modem::NetworkRegistration::Technology::edge(),
61 com::ubuntu::location::connectivity::RadioCell::Type::lte60 com::ubuntu::location::connectivity::RadioCell::Type::gsm},
62 },61 {org::Ofono::Manager::Modem::NetworkRegistration::Technology::hspa(),
63 {62 com::ubuntu::location::connectivity::RadioCell::Type::umts},
64 org::Ofono::Manager::Modem::NetworkRegistration::Technology::umts(),63 {std::string(), com::ubuntu::location::connectivity::RadioCell::Type::unknown}};
65 com::ubuntu::location::connectivity::RadioCell::Type::umts
66 },
67 {
68 org::Ofono::Manager::Modem::NetworkRegistration::Technology::edge(),
69 com::ubuntu::location::connectivity::RadioCell::Type::gsm
70 },
71 {
72 org::Ofono::Manager::Modem::NetworkRegistration::Technology::hspa(),
73 com::ubuntu::location::connectivity::RadioCell::Type::umts
74 },
75 {std::string(), com::ubuntu::location::connectivity::RadioCell::Type::unknown}
76 };
7764
78 return lut;65 return lut;
79}66}
8067
81detail::CachedRadioCell::CellChangeHeuristics::CellChangeHeuristics(68detail::CachedRadioCell::CellChangeHeuristics::CellChangeHeuristics(boost::asio::io_service& io_service, bool needed)
82 boost::asio::io_service& io_service,69 : needed(needed)
83 bool needed)70 , io_service(io_service)
84 : needed(needed),71 , invalidation_timer(io_service)
85 io_service(io_service),72 , valid(true)
86 invalidation_timer(io_service),
87 valid(true)
88{73{
89}74}
9075
91detail::CachedRadioCell::CachedRadioCell(const org::Ofono::Manager::Modem& modem, boost::asio::io_service& io_service)76detail::CachedRadioCell::CachedRadioCell(const org::Ofono::Manager::Modem& modem, boost::asio::io_service& io_service)
92 : RadioCell(), 77 : RadioCell()
93 cell_change_heuristics(io_service, is_running_on_problematic_modem_firmware(modem)),78 , cell_change_heuristics(io_service, is_running_on_problematic_modem_firmware(modem))
94 roaming(false),79 , roaming(false)
95 radio_type(Type::gsm),80 , radio_type(Type::gsm)
96 modem(modem),81 , modem(modem)
97 detail{}82 , detail{}
98{83{
99 auto status = query_status();84 auto status = query_status();
100 radio_type = query_technology();85 radio_type = query_technology();
10186
102 connections.network_registration_properties_changed = modem.network_registration.signals.property_changed->connect([this](const std::tuple<std::string, core::dbus::types::Variant>& tuple)87 connections.network_registration_properties_changed = modem.network_registration.signals.property_changed->connect(
103 {88 [this](const std::tuple<std::string, core::dbus::types::Variant>& tuple)
104 on_network_registration_property_changed(tuple);89 {
105 });90 on_network_registration_property_changed(tuple);
91 });
10692
107 if (not is_registered_or_roaming(status))93 if (not is_registered_or_roaming(status))
94 {
108 return;95 return;
96 }
10997
110 if (radio_type == com::ubuntu::location::connectivity::RadioCell::Type::unknown)98 if (radio_type == com::ubuntu::location::connectivity::RadioCell::Type::unknown)
99 {
111 return;100 return;
101 }
112102
113 auto lac = query_lac();103 auto lac = query_lac();
114 auto mcc = query_mcc();104 auto mcc = query_mcc();
@@ -116,53 +106,47 @@
116 auto cell_id = query_cid();106 auto cell_id = query_cid();
117 auto strength = query_strength();107 auto strength = query_strength();
118108
119 switch(radio_type)109 switch (radio_type)
120 {110 {
121 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:111 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:
122 {112 {
123 com::ubuntu::location::connectivity::RadioCell::Gsm gsm113 com::ubuntu::location::connectivity::RadioCell::Gsm gsm{
124 {114 com::ubuntu::location::connectivity::RadioCell::Gsm::MCC{mcc},
125 com::ubuntu::location::connectivity::RadioCell::Gsm::MCC{mcc},115 com::ubuntu::location::connectivity::RadioCell::Gsm::MNC{mnc},
126 com::ubuntu::location::connectivity::RadioCell::Gsm::MNC{mnc},116 com::ubuntu::location::connectivity::RadioCell::Gsm::LAC{lac},
127 com::ubuntu::location::connectivity::RadioCell::Gsm::LAC{lac},117 com::ubuntu::location::connectivity::RadioCell::Gsm::ID{cell_id},
128 com::ubuntu::location::connectivity::RadioCell::Gsm::ID{cell_id},118 com::ubuntu::location::connectivity::RadioCell::Gsm::SignalStrength::from_percent(strength / 100.f)};
129 com::ubuntu::location::connectivity::RadioCell::Gsm::SignalStrength::from_percent(strength/100.f)119 VLOG(1) << gsm;
130 };120 detail.gsm = gsm;
131 VLOG(1) << gsm;121 break;
132 detail.gsm = gsm;122 }
133 break;123 case com::ubuntu::location::connectivity::RadioCell::Type::lte:
134 }124 {
135 case com::ubuntu::location::connectivity::RadioCell::Type::lte:125 com::ubuntu::location::connectivity::RadioCell::Lte lte{
136 {126 com::ubuntu::location::connectivity::RadioCell::Lte::MCC{mcc},
137 com::ubuntu::location::connectivity::RadioCell::Lte lte127 com::ubuntu::location::connectivity::RadioCell::Lte::MNC{mnc},
138 {128 com::ubuntu::location::connectivity::RadioCell::Lte::TAC{lac},
139 com::ubuntu::location::connectivity::RadioCell::Lte::MCC{mcc},129 com::ubuntu::location::connectivity::RadioCell::Lte::ID{cell_id},
140 com::ubuntu::location::connectivity::RadioCell::Lte::MNC{mnc},130 com::ubuntu::location::connectivity::RadioCell::Lte::PID{},
141 com::ubuntu::location::connectivity::RadioCell::Lte::TAC{lac},131 com::ubuntu::location::connectivity::RadioCell::Lte::SignalStrength::from_percent(strength / 100.f)};
142 com::ubuntu::location::connectivity::RadioCell::Lte::ID{cell_id},132 VLOG(1) << lte;
143 com::ubuntu::location::connectivity::RadioCell::Lte::PID{},133 detail.lte = lte;
144 com::ubuntu::location::connectivity::RadioCell::Lte::SignalStrength::from_percent(strength/100.f)134 break;
145 };135 }
146 VLOG(1) << lte;136 case com::ubuntu::location::connectivity::RadioCell::Type::umts:
147 detail.lte = lte;137 {
148 break;138 com::ubuntu::location::connectivity::RadioCell::Umts umts{
149 }139 com::ubuntu::location::connectivity::RadioCell::Umts::MCC{mcc},
150 case com::ubuntu::location::connectivity::RadioCell::Type::umts:140 com::ubuntu::location::connectivity::RadioCell::Umts::MNC{mnc},
151 {141 com::ubuntu::location::connectivity::RadioCell::Umts::LAC{lac},
152 com::ubuntu::location::connectivity::RadioCell::Umts umts142 com::ubuntu::location::connectivity::RadioCell::Umts::ID{cell_id},
153 {143 com::ubuntu::location::connectivity::RadioCell::Umts::SignalStrength::from_percent(strength / 100.f)};
154 com::ubuntu::location::connectivity::RadioCell::Umts::MCC{mcc},144 VLOG(1) << umts;
155 com::ubuntu::location::connectivity::RadioCell::Umts::MNC{mnc},145 detail.umts = umts;
156 com::ubuntu::location::connectivity::RadioCell::Umts::LAC{lac},146 break;
157 com::ubuntu::location::connectivity::RadioCell::Umts::ID{cell_id},147 }
158 com::ubuntu::location::connectivity::RadioCell::Umts::SignalStrength::from_percent(strength/100.f)148 default:
159 };149 break;
160 VLOG(1) << umts;
161 detail.umts = umts;
162 break;
163 }
164 default:
165 break;
166 }150 }
167151
168 roaming = status == org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::roaming;152 roaming = status == org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::roaming;
@@ -172,7 +156,8 @@
172156
173detail::CachedRadioCell::~CachedRadioCell()157detail::CachedRadioCell::~CachedRadioCell()
174{158{
175 modem.network_registration.signals.property_changed->disconnect(connections.network_registration_properties_changed);159 modem.network_registration.signals.property_changed->disconnect(
160 connections.network_registration_properties_changed);
176}161}
177162
178const core::Property<bool>& detail::CachedRadioCell::is_roaming() const163const core::Property<bool>& detail::CachedRadioCell::is_roaming() const
@@ -198,7 +183,9 @@
198const com::ubuntu::location::connectivity::RadioCell::Gsm& detail::CachedRadioCell::gsm() const183const com::ubuntu::location::connectivity::RadioCell::Gsm& detail::CachedRadioCell::gsm() const
199{184{
200 if (radio_type != com::ubuntu::location::connectivity::RadioCell::Type::gsm)185 if (radio_type != com::ubuntu::location::connectivity::RadioCell::Type::gsm)
186 {
201 throw std::runtime_error("Bad access to unset network type.");187 throw std::runtime_error("Bad access to unset network type.");
188 }
202189
203 return detail.gsm;190 return detail.gsm;
204}191}
@@ -206,7 +193,9 @@
206const com::ubuntu::location::connectivity::RadioCell::Umts& detail::CachedRadioCell::umts() const193const com::ubuntu::location::connectivity::RadioCell::Umts& detail::CachedRadioCell::umts() const
207{194{
208 if (radio_type != RadioCell::Type::umts)195 if (radio_type != RadioCell::Type::umts)
196 {
209 throw std::runtime_error("Bad access to unset network type.");197 throw std::runtime_error("Bad access to unset network type.");
198 }
210199
211 return detail.umts;200 return detail.umts;
212}201}
@@ -214,14 +203,18 @@
214const com::ubuntu::location::connectivity::RadioCell::Lte& detail::CachedRadioCell::lte() const203const com::ubuntu::location::connectivity::RadioCell::Lte& detail::CachedRadioCell::lte() const
215{204{
216 if (radio_type != RadioCell::Type::lte)205 if (radio_type != RadioCell::Type::lte)
206 {
217 throw std::runtime_error("Bad access to unset network type.");207 throw std::runtime_error("Bad access to unset network type.");
208 }
218209
219 return detail.lte;210 return detail.lte;
220}211}
221212
222void detail::CachedRadioCell::on_network_registration_property_changed(const std::tuple<std::string, core::dbus::types::Variant>& tuple)213void detail::CachedRadioCell::on_network_registration_property_changed(
214 const std::tuple<std::string, core::dbus::types::Variant>& tuple)
223{215{
224 VLOG(10) << "Property changed on modem " << modem.object->path() << " for network registration: " << std::get<0>(tuple);216 VLOG(10) << "Property changed on modem " << modem.object->path()
217 << " for network registration: " << std::get<0>(tuple);
225218
226 const auto& key = std::get<0>(tuple);219 const auto& key = std::get<0>(tuple);
227 const auto& variant = std::get<1>(tuple);220 const auto& variant = std::get<1>(tuple);
@@ -232,9 +225,7 @@
232 {225 {
233 did_cell_identity_change = true;226 did_cell_identity_change = true;
234227
235 auto value = variant.as<228 auto value = variant.as<org::Ofono::Manager::Modem::NetworkRegistration::Technology::ValueType>();
236 org::Ofono::Manager::Modem::NetworkRegistration::Technology::ValueType
237 >();
238229
239 auto it = type_lut().find(value);230 auto it = type_lut().find(value);
240231
@@ -251,251 +242,254 @@
251 }242 }
252243
253 if (radio_type == it->second)244 if (radio_type == it->second)
245 {
254 return;246 return;
247 }
255248
256 switch(radio_type)249 switch (radio_type)
257 {250 {
258 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:251 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:
259 switch(it->second)252 switch (it->second)
260 {253 {
261 case com::ubuntu::location::connectivity::RadioCell::Type::umts:254 case com::ubuntu::location::connectivity::RadioCell::Type::umts:
262 detail.umts.location_area_code = detail.gsm.location_area_code;255 detail.umts.location_area_code = detail.gsm.location_area_code;
263 detail.umts.mobile_network_code = detail.gsm.mobile_network_code;256 detail.umts.mobile_network_code = detail.gsm.mobile_network_code;
264 detail.umts.mobile_country_code = detail.gsm.mobile_country_code;257 detail.umts.mobile_country_code = detail.gsm.mobile_country_code;
265 detail.umts.strength.reset();258 detail.umts.strength.reset();
266 detail.umts.id.reset();259 detail.umts.id.reset();
267 break;260 break;
268 case com::ubuntu::location::connectivity::RadioCell::Type::lte:261 case com::ubuntu::location::connectivity::RadioCell::Type::lte:
269 detail.lte.tracking_area_code = detail.gsm.location_area_code;262 detail.lte.tracking_area_code = detail.gsm.location_area_code;
270 detail.lte.mobile_network_code = detail.gsm.mobile_network_code;263 detail.lte.mobile_network_code = detail.gsm.mobile_network_code;
271 detail.lte.mobile_country_code = detail.gsm.mobile_country_code;264 detail.lte.mobile_country_code = detail.gsm.mobile_country_code;
272 detail.lte.strength.reset();265 detail.lte.strength.reset();
273 detail.lte.id.reset();266 detail.lte.id.reset();
274 break;267 break;
275 default:268 default:
276 break;269 break;
277 }270 }
278 break;271 break;
279 case com::ubuntu::location::connectivity::RadioCell::Type::umts:272 case com::ubuntu::location::connectivity::RadioCell::Type::umts:
280 switch(it->second)273 switch (it->second)
281 {274 {
282 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:275 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:
283 detail.gsm.location_area_code = detail.umts.location_area_code;276 detail.gsm.location_area_code = detail.umts.location_area_code;
284 detail.gsm.mobile_network_code = detail.umts.mobile_network_code;277 detail.gsm.mobile_network_code = detail.umts.mobile_network_code;
285 detail.gsm.mobile_country_code = detail.umts.mobile_country_code;278 detail.gsm.mobile_country_code = detail.umts.mobile_country_code;
286 detail.gsm.strength.reset();279 detail.gsm.strength.reset();
287 detail.gsm.id.reset();280 detail.gsm.id.reset();
288 break;281 break;
289 case com::ubuntu::location::connectivity::RadioCell::Type::lte:282 case com::ubuntu::location::connectivity::RadioCell::Type::lte:
290 detail.lte.tracking_area_code = detail.umts.location_area_code;283 detail.lte.tracking_area_code = detail.umts.location_area_code;
291 detail.lte.mobile_network_code = detail.umts.mobile_network_code;284 detail.lte.mobile_network_code = detail.umts.mobile_network_code;
292 detail.lte.mobile_country_code = detail.umts.mobile_country_code;285 detail.lte.mobile_country_code = detail.umts.mobile_country_code;
293 detail.lte.strength.reset();286 detail.lte.strength.reset();
294 detail.lte.id.reset();287 detail.lte.id.reset();
295 break;288 break;
296 default:289 default:
297 break;290 break;
298 }291 }
299 break;292 break;
300 case com::ubuntu::location::connectivity::RadioCell::Type::lte:293 case com::ubuntu::location::connectivity::RadioCell::Type::lte:
301 switch(it->second)294 switch (it->second)
302 {295 {
303 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:296 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:
304 detail.gsm.location_area_code = detail.lte.tracking_area_code;297 detail.gsm.location_area_code = detail.lte.tracking_area_code;
305 detail.gsm.mobile_network_code = detail.lte.mobile_network_code;298 detail.gsm.mobile_network_code = detail.lte.mobile_network_code;
306 detail.gsm.mobile_country_code = detail.lte.mobile_country_code;299 detail.gsm.mobile_country_code = detail.lte.mobile_country_code;
307 detail.gsm.strength.reset();300 detail.gsm.strength.reset();
308 detail.gsm.id.reset();301 detail.gsm.id.reset();
309 break;302 break;
310 case com::ubuntu::location::connectivity::RadioCell::Type::umts:303 case com::ubuntu::location::connectivity::RadioCell::Type::umts:
311 detail.umts.location_area_code = detail.lte.tracking_area_code;304 detail.umts.location_area_code = detail.lte.tracking_area_code;
312 detail.umts.mobile_network_code = detail.lte.mobile_network_code;305 detail.umts.mobile_network_code = detail.lte.mobile_network_code;
313 detail.umts.mobile_country_code = detail.lte.mobile_country_code;306 detail.umts.mobile_country_code = detail.lte.mobile_country_code;
314 detail.umts.strength.reset();307 detail.umts.strength.reset();
315 detail.umts.id.reset();308 detail.umts.id.reset();
316 break;309 break;
317 default:310 default:
318 break;311 break;
319 }312 }
320 default:313 default:
321 // We take the default path here, specifically for cases where314 // We take the default path here, specifically for cases where
322 // we started out with Technology::unknown.315 // we started out with Technology::unknown.
323 break;316 break;
324 };317 };
325318
326 radio_type = it->second;319 radio_type = it->second;
327320
328 if (cell_change_heuristics.valid.get())321 if (cell_change_heuristics.valid.get())
322 {
329 on_changed();323 on_changed();
324 }
330 }325 }
331326
332 if (key == org::Ofono::Manager::Modem::NetworkRegistration::CellId::name())327 if (key == org::Ofono::Manager::Modem::NetworkRegistration::CellId::name())
333 {328 {
334 did_cell_identity_change = true;329 did_cell_identity_change = true;
335330
336 auto value = variant.as<331 auto value = variant.as<org::Ofono::Manager::Modem::NetworkRegistration::CellId::ValueType>();
337 org::Ofono::Manager::Modem::NetworkRegistration::CellId::ValueType
338 >();
339332
340 switch(radio_type)333 switch (radio_type)
341 {334 {
342 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:335 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:
343 detail.gsm.id.set(value);336 detail.gsm.id.set(value);
344 VLOG(1) << detail.gsm;337 VLOG(1) << detail.gsm;
345 break;338 break;
346 case com::ubuntu::location::connectivity::RadioCell::Type::umts:339 case com::ubuntu::location::connectivity::RadioCell::Type::umts:
347 detail.umts.id.set(value);340 detail.umts.id.set(value);
348 VLOG(1) << detail.umts;341 VLOG(1) << detail.umts;
349 break;342 break;
350 case com::ubuntu::location::connectivity::RadioCell::Type::lte:343 case com::ubuntu::location::connectivity::RadioCell::Type::lte:
351 detail.lte.id.set(value);344 detail.lte.id.set(value);
352 VLOG(1) << detail.lte;345 VLOG(1) << detail.lte;
353 break;346 break;
354 default:347 default:
355 break;348 break;
356 };349 };
357350
358 if (cell_change_heuristics.valid.get())351 if (cell_change_heuristics.valid.get())
352 {
359 on_changed();353 on_changed();
354 }
360 }355 }
361356
362 if (key == org::Ofono::Manager::Modem::NetworkRegistration::LocationAreaCode::name())357 if (key == org::Ofono::Manager::Modem::NetworkRegistration::LocationAreaCode::name())
363 {358 {
364 did_cell_identity_change = true;359 did_cell_identity_change = true;
365360
366 auto value = variant.as<361 auto value = variant.as<org::Ofono::Manager::Modem::NetworkRegistration::LocationAreaCode::ValueType>();
367 org::Ofono::Manager::Modem::NetworkRegistration::LocationAreaCode::ValueType362 switch (radio_type)
368 >();
369 switch(radio_type)
370 {363 {
371 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:364 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:
372 detail.gsm.location_area_code.set(value);365 detail.gsm.location_area_code.set(value);
373 VLOG(1) << detail.gsm;366 VLOG(1) << detail.gsm;
374 break;367 break;
375 case com::ubuntu::location::connectivity::RadioCell::Type::umts:368 case com::ubuntu::location::connectivity::RadioCell::Type::umts:
376 detail.umts.location_area_code.set(value);369 detail.umts.location_area_code.set(value);
377 VLOG(1) << detail.umts;370 VLOG(1) << detail.umts;
378 break;371 break;
379 case com::ubuntu::location::connectivity::RadioCell::Type::lte:372 case com::ubuntu::location::connectivity::RadioCell::Type::lte:
380 detail.lte.tracking_area_code.set(value);373 detail.lte.tracking_area_code.set(value);
381 VLOG(1) << detail.lte;374 VLOG(1) << detail.lte;
382 break;375 break;
383 default:376 default:
384 break;377 break;
385 };378 };
386379
387 if (cell_change_heuristics.valid.get())380 if (cell_change_heuristics.valid.get())
381 {
388 on_changed();382 on_changed();
383 }
389 }384 }
390385
391 if (key == org::Ofono::Manager::Modem::NetworkRegistration::MobileCountryCode::name())386 if (key == org::Ofono::Manager::Modem::NetworkRegistration::MobileCountryCode::name())
392 {387 {
393 did_cell_identity_change = true;388 did_cell_identity_change = true;
394389
395 std::stringstream ss390 std::stringstream ss{
396 {391 variant.as<org::Ofono::Manager::Modem::NetworkRegistration::MobileCountryCode::ValueType>()};
397 variant.as<392 int value{-1};
398 org::Ofono::Manager::Modem::NetworkRegistration::MobileCountryCode::ValueType393 ss >> value;
399 >()
400 };
401 int value{-1}; ss >> value;
402394
403 switch(radio_type)395 switch (radio_type)
404 {396 {
405 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:397 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:
406 detail.gsm.mobile_country_code.set(value);398 detail.gsm.mobile_country_code.set(value);
407 VLOG(1) << detail.gsm;399 VLOG(1) << detail.gsm;
408 break;400 break;
409 case com::ubuntu::location::connectivity::RadioCell::Type::umts:401 case com::ubuntu::location::connectivity::RadioCell::Type::umts:
410 detail.umts.mobile_country_code.set(value);402 detail.umts.mobile_country_code.set(value);
411 VLOG(1) << detail.umts;403 VLOG(1) << detail.umts;
412 break;404 break;
413 case com::ubuntu::location::connectivity::RadioCell::Type::lte:405 case com::ubuntu::location::connectivity::RadioCell::Type::lte:
414 detail.lte.mobile_country_code.set(value);406 detail.lte.mobile_country_code.set(value);
415 VLOG(1) << detail.lte;407 VLOG(1) << detail.lte;
416 break;408 break;
417 default:409 default:
418 break;410 break;
419 };411 };
420412
421 if (cell_change_heuristics.valid.get())413 if (cell_change_heuristics.valid.get())
414 {
422 on_changed();415 on_changed();
416 }
423 }417 }
424418
425 if (key == org::Ofono::Manager::Modem::NetworkRegistration::MobileNetworkCode::name())419 if (key == org::Ofono::Manager::Modem::NetworkRegistration::MobileNetworkCode::name())
426 {420 {
427 did_cell_identity_change = true;421 did_cell_identity_change = true;
428422
429 std::stringstream ss423 std::stringstream ss{
430 {424 variant.as<org::Ofono::Manager::Modem::NetworkRegistration::MobileNetworkCode::ValueType>()};
431 variant.as<425 int value{-1};
432 org::Ofono::Manager::Modem::NetworkRegistration::MobileNetworkCode::ValueType426 ss >> value;
433 >()
434 };
435 int value{-1}; ss >> value;
436427
437 switch(radio_type)428 switch (radio_type)
438 {429 {
439 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:430 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:
440 detail.gsm.mobile_network_code.set(value);431 detail.gsm.mobile_network_code.set(value);
441 VLOG(1) << detail.gsm;432 VLOG(1) << detail.gsm;
442 break;433 break;
443 case com::ubuntu::location::connectivity::RadioCell::Type::umts:434 case com::ubuntu::location::connectivity::RadioCell::Type::umts:
444 detail.umts.mobile_network_code.set(value);435 detail.umts.mobile_network_code.set(value);
445 VLOG(1) << detail.umts;436 VLOG(1) << detail.umts;
446 break;437 break;
447 case com::ubuntu::location::connectivity::RadioCell::Type::lte:438 case com::ubuntu::location::connectivity::RadioCell::Type::lte:
448 detail.lte.mobile_network_code.set(value);439 detail.lte.mobile_network_code.set(value);
449 VLOG(1) << detail.lte;440 VLOG(1) << detail.lte;
450 break;441 break;
451 default:442 default:
452 break;443 break;
453 };444 };
454445
455 if (cell_change_heuristics.valid.get())446 if (cell_change_heuristics.valid.get())
447 {
456 on_changed();448 on_changed();
449 }
457 }450 }
458451
459 if (key == org::Ofono::Manager::Modem::NetworkRegistration::Strength::name())452 if (key == org::Ofono::Manager::Modem::NetworkRegistration::Strength::name())
460 {453 {
461 auto value = variant.as<454 auto value = variant.as<org::Ofono::Manager::Modem::NetworkRegistration::Strength::ValueType>();
462 org::Ofono::Manager::Modem::NetworkRegistration::Strength::ValueType
463 >();
464455
465 switch(radio_type)456 switch (radio_type)
466 {457 {
467 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:458 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:
468 detail.gsm.strength459 detail.gsm.strength =
469 = com::ubuntu::location::connectivity::RadioCell::Gsm::SignalStrength::from_percent(value/100.f);460 com::ubuntu::location::connectivity::RadioCell::Gsm::SignalStrength::from_percent(value / 100.f);
470 VLOG(1) << detail.gsm;461 VLOG(1) << detail.gsm;
471 break;462 break;
472 case com::ubuntu::location::connectivity::RadioCell::Type::umts:463 case com::ubuntu::location::connectivity::RadioCell::Type::umts:
473 detail.umts.strength464 detail.umts.strength =
474 = com::ubuntu::location::connectivity::RadioCell::Umts::SignalStrength::from_percent(value/100.f);465 com::ubuntu::location::connectivity::RadioCell::Umts::SignalStrength::from_percent(value / 100.f);
475 VLOG(1) << detail.umts;466 VLOG(1) << detail.umts;
476 break;467 break;
477 case com::ubuntu::location::connectivity::RadioCell::Type::lte:468 case com::ubuntu::location::connectivity::RadioCell::Type::lte:
478 detail.lte.strength469 detail.lte.strength =
479 = com::ubuntu::location::connectivity::RadioCell::Lte::SignalStrength::from_percent(value/100.f);470 com::ubuntu::location::connectivity::RadioCell::Lte::SignalStrength::from_percent(value / 100.f);
480 VLOG(1) << detail.lte;471 VLOG(1) << detail.lte;
481 break;472 break;
482 default:473 default:
483 break;474 break;
484 };475 };
485476
486 if (cell_change_heuristics.valid.get())477 if (cell_change_heuristics.valid.get())
478 {
487 on_changed();479 on_changed();
480 }
488 }481 }
489482
490 if (key == org::Ofono::Manager::Modem::NetworkRegistration::Status::name())483 if (key == org::Ofono::Manager::Modem::NetworkRegistration::Status::name())
491 {484 {
492 roaming =485 roaming = variant.as<org::Ofono::Manager::Modem::NetworkRegistration::Status::ValueType>() ==
493 variant.as<org::Ofono::Manager::Modem::NetworkRegistration::Status::ValueType>() ==486 org::Ofono::Manager::Modem::NetworkRegistration::Status::roaming;
494 org::Ofono::Manager::Modem::NetworkRegistration::Status::roaming;
495 }487 }
496488
497 if (did_cell_identity_change)489 if (did_cell_identity_change)
490 {
498 execute_cell_change_heuristics_if_appropriate();491 execute_cell_change_heuristics_if_appropriate();
492 }
499}493}
500494
501void detail::CachedRadioCell::execute_cell_change_heuristics_if_appropriate()495void detail::CachedRadioCell::execute_cell_change_heuristics_if_appropriate()
@@ -504,9 +498,9 @@
504 // whenever the cell identity changes, we start a timer and invalidate the498 // whenever the cell identity changes, we start a timer and invalidate the
505 // cell to account for situations where the underlying modem firmware does not499 // cell to account for situations where the underlying modem firmware does not
506 // report cell changes when on a 3G data connection.500 // report cell changes when on a 3G data connection.
507 if (cell_change_heuristics.needed && // Only carry out this step if it is actually required501 if (cell_change_heuristics.needed && // Only carry out this step if it is actually required
508 (radio_type == com::ubuntu::location::connectivity::RadioCell::Type::umts ||502 (radio_type == com::ubuntu::location::connectivity::RadioCell::Type::umts ||
509 also_apply_cell_change_heuristics_to_gsm_cells)) // and if it's a 3G cell.503 also_apply_cell_change_heuristics_to_gsm_cells)) // and if it's a 3G cell.
510 {504 {
511 static const boost::posix_time::seconds timeout{timeout_in_seconds()};505 static const boost::posix_time::seconds timeout{timeout_in_seconds()};
512506
@@ -514,10 +508,12 @@
514508
515 cell_change_heuristics.invalidation_timer.expires_from_now(timeout);509 cell_change_heuristics.invalidation_timer.expires_from_now(timeout);
516 cell_change_heuristics.invalidation_timer.async_wait([this](boost::system::error_code ec)510 cell_change_heuristics.invalidation_timer.async_wait([this](boost::system::error_code ec)
517 {511 {
518 if (not ec)512 if (not ec)
519 cell_change_heuristics.valid = false;513 {
520 });514 cell_change_heuristics.valid = false;
515 }
516 });
521517
522 cell_change_heuristics.valid = is_cell_details_valid();518 cell_change_heuristics.valid = is_cell_details_valid();
523 }519 }
@@ -526,32 +522,42 @@
526// Queries the status from the Ofono NetworkRegistration.522// Queries the status from the Ofono NetworkRegistration.
527org::Ofono::Manager::Modem::NetworkRegistration::Status::Value detail::CachedRadioCell::query_status()523org::Ofono::Manager::Modem::NetworkRegistration::Status::Value detail::CachedRadioCell::query_status()
528{524{
529 auto status =525 auto status = modem.network_registration.get<org::Ofono::Manager::Modem::NetworkRegistration::Status>();
530 modem.network_registration.get
531 <
532 org::Ofono::Manager::Modem::NetworkRegistration::Status
533 >();
534526
535 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::unregistered)527 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::unregistered)
528 {
536 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::unregistered;529 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::unregistered;
530 }
537531
538 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::registered)532 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::registered)
533 {
539 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::registered;534 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::registered;
535 }
540536
541 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::searching)537 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::searching)
538 {
542 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::searching;539 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::searching;
540 }
543541
544 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::denied)542 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::denied)
543 {
545 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::denied;544 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::denied;
545 }
546546
547 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::unknown)547 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::unknown)
548 {
548 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::unknown;549 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::unknown;
550 }
549551
550 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::unregistered)552 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::unregistered)
553 {
551 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::unregistered;554 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::unregistered;
555 }
552556
553 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::roaming)557 if (status == org::Ofono::Manager::Modem::NetworkRegistration::Status::roaming)
558 {
554 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::roaming;559 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::roaming;
560 }
555561
556 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::unknown;562 return org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::unknown;
557}563}
@@ -559,15 +565,14 @@
559// Queries the technology from the Ofono NetworkRegistration.565// Queries the technology from the Ofono NetworkRegistration.
560com::ubuntu::location::connectivity::RadioCell::Type detail::CachedRadioCell::query_technology()566com::ubuntu::location::connectivity::RadioCell::Type detail::CachedRadioCell::query_technology()
561{567{
562 auto technology =568 auto technology = modem.network_registration.get<org::Ofono::Manager::Modem::NetworkRegistration::Technology>();
563 modem.network_registration.get<
564 org::Ofono::Manager::Modem::NetworkRegistration::Technology
565 >();
566569
567 auto it = type_lut().find(technology);570 auto it = type_lut().find(technology);
568571
569 if (it == type_lut().end())572 if (it == type_lut().end())
573 {
570 return com::ubuntu::location::connectivity::RadioCell::Type::unknown;574 return com::ubuntu::location::connectivity::RadioCell::Type::unknown;
575 }
571576
572 return it->second;577 return it->second;
573}578}
@@ -575,60 +580,44 @@
575// Queries the cell id from the Ofono NetworkRegistration.580// Queries the cell id from the Ofono NetworkRegistration.
576int detail::CachedRadioCell::query_cid()581int detail::CachedRadioCell::query_cid()
577{582{
578 return modem.network_registration.get583 return modem.network_registration.get<org::Ofono::Manager::Modem::NetworkRegistration::CellId>();
579 <
580 org::Ofono::Manager::Modem::NetworkRegistration::CellId
581 >();
582}584}
583585
584// Queries the location area code from the Ofono NetworkRegistration.586// Queries the location area code from the Ofono NetworkRegistration.
585std::uint16_t detail::CachedRadioCell::query_lac()587std::uint16_t detail::CachedRadioCell::query_lac()
586{588{
587 return modem.network_registration.get589 return modem.network_registration.get<org::Ofono::Manager::Modem::NetworkRegistration::LocationAreaCode>();
588 <
589 org::Ofono::Manager::Modem::NetworkRegistration::LocationAreaCode
590 >();
591}590}
592591
593// Queries the mobile network code from the Ofono NetworkRegistration.592// Queries the mobile network code from the Ofono NetworkRegistration.
594int detail::CachedRadioCell::query_mnc()593int detail::CachedRadioCell::query_mnc()
595{594{
596 std::stringstream ssmnc595 std::stringstream ssmnc{
597 {596 modem.network_registration.get<org::Ofono::Manager::Modem::NetworkRegistration::MobileNetworkCode>()};
598 modem.network_registration.get597 int mnc{0};
599 <598 ssmnc >> mnc;
600 org::Ofono::Manager::Modem::NetworkRegistration::MobileNetworkCode
601 >()
602 };
603 int mnc{0}; ssmnc >> mnc;
604 return mnc;599 return mnc;
605}600}
606601
607// Queries the mobile country code from the Ofono NetworkRegistration.602// Queries the mobile country code from the Ofono NetworkRegistration.
608int detail::CachedRadioCell::query_mcc()603int detail::CachedRadioCell::query_mcc()
609{604{
610 std::stringstream ssmcc605 std::stringstream ssmcc{
611 {606 modem.network_registration.get<org::Ofono::Manager::Modem::NetworkRegistration::MobileCountryCode>()};
612 modem.network_registration.get607 int mcc{0};
613 <608 ssmcc >> mcc;
614 org::Ofono::Manager::Modem::NetworkRegistration::MobileCountryCode
615 >()
616 };
617 int mcc{0}; ssmcc >> mcc;
618 return mcc;609 return mcc;
619}610}
620611
621// Queries the signal strength from the Ofono NetworkRegistration.612// Queries the signal strength from the Ofono NetworkRegistration.
622std::int8_t detail::CachedRadioCell::query_strength()613std::int8_t detail::CachedRadioCell::query_strength()
623{614{
624 return modem.network_registration.get615 return modem.network_registration.get<org::Ofono::Manager::Modem::NetworkRegistration::Strength>();
625 <
626 org::Ofono::Manager::Modem::NetworkRegistration::Strength
627 >();
628}616}
629617
630// Returns true iff status is either roaming or registered.618// Returns true iff status is either roaming or registered.
631bool detail::CachedRadioCell::is_registered_or_roaming(org::Ofono::Manager::Modem::NetworkRegistration::Status::Value status)619bool detail::CachedRadioCell::is_registered_or_roaming(
620 org::Ofono::Manager::Modem::NetworkRegistration::Status::Value status)
632{621{
633 return status == org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::registered ||622 return status == org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::registered ||
634 status == org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::roaming;623 status == org::Ofono::Manager::Modem::NetworkRegistration::Status::Value::roaming;
@@ -637,16 +626,16 @@
637// Returns true iff all the parts of the cell are populated with valid values.626// Returns true iff all the parts of the cell are populated with valid values.
638bool detail::CachedRadioCell::is_cell_details_valid()627bool detail::CachedRadioCell::is_cell_details_valid()
639{628{
640 switch(radio_type)629 switch (radio_type)
641 {630 {
642 case com::ubuntu::location::connectivity::RadioCell::Type::unknown:631 case com::ubuntu::location::connectivity::RadioCell::Type::unknown:
643 return false;632 return false;
644 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:633 case com::ubuntu::location::connectivity::RadioCell::Type::gsm:
645 return is_gsm_valid();634 return is_gsm_valid();
646 case com::ubuntu::location::connectivity::RadioCell::Type::umts:635 case com::ubuntu::location::connectivity::RadioCell::Type::umts:
647 return is_umts_valid();636 return is_umts_valid();
648 case com::ubuntu::location::connectivity::RadioCell::Type::lte:637 case com::ubuntu::location::connectivity::RadioCell::Type::lte:
649 return is_lte_valid();638 return is_lte_valid();
650 }639 }
651640
652 return false;641 return false;
@@ -655,46 +644,41 @@
655// Retuns true iff the GSM cell details are valid.644// Retuns true iff the GSM cell details are valid.
656bool detail::CachedRadioCell::is_gsm_valid()645bool detail::CachedRadioCell::is_gsm_valid()
657{646{
658 return gsm().mobile_country_code.is_valid() &&647 return gsm().mobile_country_code.is_valid() && gsm().mobile_network_code.is_valid() &&
659 gsm().mobile_network_code.is_valid() &&648 gsm().location_area_code.is_valid() && gsm().id.is_valid() && gsm().strength.is_valid();
660 gsm().location_area_code.is_valid() &&
661 gsm().id.is_valid() &&
662 gsm().strength.is_valid();
663}649}
664650
665// Returns true iff the Umts cell details are valid.651// Returns true iff the Umts cell details are valid.
666bool detail::CachedRadioCell::is_umts_valid()652bool detail::CachedRadioCell::is_umts_valid()
667{653{
668 return umts().mobile_country_code.is_valid() &&654 return umts().mobile_country_code.is_valid() && umts().mobile_network_code.is_valid() &&
669 umts().mobile_network_code.is_valid() &&655 umts().location_area_code.is_valid() && umts().id.is_valid() && umts().strength.is_valid();
670 umts().location_area_code.is_valid() &&
671 umts().id.is_valid() &&
672 umts().strength.is_valid();
673}656}
674657
675// Returns true iff the Lte cell details are valid.658// Returns true iff the Lte cell details are valid.
676bool detail::CachedRadioCell::is_lte_valid()659bool detail::CachedRadioCell::is_lte_valid()
677{660{
678 return lte().mobile_country_code.is_valid() &&661 return lte().mobile_country_code.is_valid() && lte().mobile_network_code.is_valid() &&
679 lte().mobile_network_code.is_valid() &&662 lte().tracking_area_code.is_valid() && lte().id.is_valid() && lte().physical_id.is_valid() &&
680 lte().tracking_area_code.is_valid() &&
681 lte().id.is_valid() &&
682 lte().physical_id.is_valid() &&
683 lte().strength.is_valid();663 lte().strength.is_valid();
684}664}
685665
686detail::CachedRadioCell::Detail::Detail() : none(detail::CachedRadioCell::None{})666detail::CachedRadioCell::Detail::Detail()
687{667 : none(detail::CachedRadioCell::None{})
688}668{
689669}
690detail::CachedRadioCell::Detail::Detail(const com::ubuntu::location::connectivity::RadioCell::Gsm& gsm) : gsm(gsm)670
691{671detail::CachedRadioCell::Detail::Detail(const com::ubuntu::location::connectivity::RadioCell::Gsm& gsm)
692}672 : gsm(gsm)
693673{
694detail::CachedRadioCell::Detail::Detail(const com::ubuntu::location::connectivity::RadioCell::Umts& umts) : umts(umts)674}
695{675
696}676detail::CachedRadioCell::Detail::Detail(const com::ubuntu::location::connectivity::RadioCell::Umts& umts)
697677 : umts(umts)
698detail::CachedRadioCell::Detail::Detail(const com::ubuntu::location::connectivity::RadioCell::Lte& lte) : lte(lte)678{
679}
680
681detail::CachedRadioCell::Detail::Detail(const com::ubuntu::location::connectivity::RadioCell::Lte& lte)
682 : lte(lte)
699{683{
700}684}
701685
=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_radio_cell.h'
--- src/location_service/com/ubuntu/location/connectivity/cached_radio_cell.h 2014-10-13 12:38:40 +0000
+++ src/location_service/com/ubuntu/location/connectivity/cached_radio_cell.h 2015-04-23 17:23:49 +0000
@@ -72,8 +72,7 @@
72 // cell change heuristics go here.72 // cell change heuristics go here.
73 struct CellChangeHeuristics73 struct CellChangeHeuristics
74 {74 {
75 CellChangeHeuristics(boost::asio::io_service& io_service,75 CellChangeHeuristics(boost::asio::io_service& io_service, bool needed);
76 bool needed);
77 // True if the heuristic is needed76 // True if the heuristic is needed
78 const bool needed;77 const bool needed;
79 // The io_service for setting up timeouts.78 // The io_service for setting up timeouts.
@@ -86,7 +85,7 @@
86 // Property to indicate whether the current cell is85 // Property to indicate whether the current cell is
87 // still valid according to the cell change heuristics.86 // still valid according to the cell change heuristics.
88 core::Property<bool> valid;87 core::Property<bool> valid;
89 } cell_change_heuristics; 88 } cell_change_heuristics;
90 // Executes the cell change heuristics if precondition is met.89 // Executes the cell change heuristics if precondition is met.
91 void execute_cell_change_heuristics_if_appropriate();90 void execute_cell_change_heuristics_if_appropriate();
9291
@@ -123,15 +122,15 @@
123 // Encapsulates all event connections that have to be cut on destruction.122 // Encapsulates all event connections that have to be cut on destruction.
124 struct123 struct
125 {124 {
126 core::dbus::Signal125 core::dbus::Signal<org::Ofono::Manager::Modem::NetworkRegistration::PropertyChanged,
127 <126 org::Ofono::Manager::Modem::NetworkRegistration::PropertyChanged::ArgumentType>::
128 org::Ofono::Manager::Modem::NetworkRegistration::PropertyChanged,127 SubscriptionToken network_registration_properties_changed;
129 org::Ofono::Manager::Modem::NetworkRegistration::PropertyChanged::ArgumentType
130 >::SubscriptionToken network_registration_properties_changed;
131 } connections;128 } connections;
132129
133 // Marks the unset type in a variant.130 // Marks the unset type in a variant.
134 struct None {};131 struct None
132 {
133 };
135134
136 // Our custom variant handling the different known cell identity details.135 // Our custom variant handling the different known cell identity details.
137 union Detail136 union Detail
@@ -154,4 +153,4 @@
154};153};
155}154}
156155
157#endif // CACHED_RADIO_CELL_H_156#endif // CACHED_RADIO_CELL_H_
158157
=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp'
--- src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2014-08-14 20:33:37 +0000
+++ src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.cpp 2015-04-23 17:23:49 +0000
@@ -27,25 +27,23 @@
27 return std::string(ssid.begin(), ssid.end());27 return std::string(ssid.begin(), ssid.end());
28}28}
2929
30com::ubuntu::location::connectivity::WirelessNetwork::Mode30com::ubuntu::location::connectivity::WirelessNetwork::Mode wifi_mode_from_ap_mode(
31wifi_mode_from_ap_mode(org::freedesktop::NetworkManager::AccessPoint::Mode::ValueType value)31 org::freedesktop::NetworkManager::AccessPoint::Mode::ValueType value)
32{32{
33 com::ubuntu::location::connectivity::WirelessNetwork::Mode mode33 com::ubuntu::location::connectivity::WirelessNetwork::Mode mode{
34 {34 com::ubuntu::location::connectivity::WirelessNetwork::Mode::unknown};
35 com::ubuntu::location::connectivity::WirelessNetwork::Mode::unknown
36 };
3735
38 switch (value)36 switch (value)
39 {37 {
40 case org::freedesktop::NetworkManager::AccessPoint::Mode::Value::unknown:38 case org::freedesktop::NetworkManager::AccessPoint::Mode::Value::unknown:
41 mode = com::ubuntu::location::connectivity::WirelessNetwork::Mode::unknown;39 mode = com::ubuntu::location::connectivity::WirelessNetwork::Mode::unknown;
42 break;40 break;
43 case org::freedesktop::NetworkManager::AccessPoint::Mode::Value::adhoc:41 case org::freedesktop::NetworkManager::AccessPoint::Mode::Value::adhoc:
44 mode = com::ubuntu::location::connectivity::WirelessNetwork::Mode::adhoc;42 mode = com::ubuntu::location::connectivity::WirelessNetwork::Mode::adhoc;
45 break;43 break;
46 case org::freedesktop::NetworkManager::AccessPoint::Mode::Value::infra:44 case org::freedesktop::NetworkManager::AccessPoint::Mode::Value::infra:
47 mode = com::ubuntu::location::connectivity::WirelessNetwork::Mode::infrastructure;45 mode = com::ubuntu::location::connectivity::WirelessNetwork::Mode::infrastructure;
48 break;46 break;
49 }47 }
5048
51 return mode;49 return mode;
@@ -77,101 +75,76 @@
77 return frequency_;75 return frequency_;
78}76}
7977
80const core::Property<connectivity::WirelessNetwork::SignalStrength>& detail::CachedWirelessNetwork::signal_strength() const78const core::Property<connectivity::WirelessNetwork::SignalStrength>& detail::CachedWirelessNetwork::signal_strength()
79 const
81{80{
82 return signal_strength_;81 return signal_strength_;
83}82}
8483
85detail::CachedWirelessNetwork::CachedWirelessNetwork(84detail::CachedWirelessNetwork::CachedWirelessNetwork(const org::freedesktop::NetworkManager::Device& device,
86 const org::freedesktop::NetworkManager::Device& device,85 const org::freedesktop::NetworkManager::AccessPoint& ap)
87 const org::freedesktop::NetworkManager::AccessPoint& ap)86 : device_(device)
88 : device_(device),87 , access_point_(ap)
89 access_point_(ap)
90{88{
91 last_seen_ = std::chrono::system_clock::time_point89 last_seen_ =
92 {90 std::chrono::system_clock::time_point{std::chrono::system_clock::duration{access_point_.last_seen->get()}};
93 std::chrono::system_clock::duration{access_point_.last_seen->get()}
94 };
9591
96 bssid_ = access_point_.hw_address->get();92 bssid_ = access_point_.hw_address->get();
97 ssid_ = utf8_ssid_to_string(access_point_.ssid->get());93 ssid_ = utf8_ssid_to_string(access_point_.ssid->get());
98 mode_ = wifi_mode_from_ap_mode(access_point_.mode->get());94 mode_ = wifi_mode_from_ap_mode(access_point_.mode->get());
99 frequency_ = com::ubuntu::location::connectivity::WirelessNetwork::Frequency95 frequency_ = com::ubuntu::location::connectivity::WirelessNetwork::Frequency{
100 {96 static_cast<int>(access_point_.frequency->get())};
101 static_cast<int>(access_point_.frequency->get())97 signal_strength_ = com::ubuntu::location::connectivity::WirelessNetwork::SignalStrength{
102 };98 static_cast<int>(access_point_.strength->get())};
103 signal_strength_ = com::ubuntu::location::connectivity::WirelessNetwork::SignalStrength
104 {
105 static_cast<int>(access_point_.strength->get())
106 };
10799
108 // Wire up all the connections100 // Wire up all the connections
109 access_point_.properties_changed->connect([this](const std::map<std::string, core::dbus::types::Variant>& dict)101 access_point_.properties_changed->connect([this](const std::map<std::string, core::dbus::types::Variant>& dict)
110 {102 {
111 on_access_point_properties_changed(dict);103 on_access_point_properties_changed(dict);
112 });104 });
113}105}
114106
115void detail::CachedWirelessNetwork::on_access_point_properties_changed(const std::map<std::string, core::dbus::types::Variant>& dict)107void detail::CachedWirelessNetwork::on_access_point_properties_changed(
108 const std::map<std::string, core::dbus::types::Variant>& dict)
116{109{
117 // We route by string110 // We route by string
118 static const std::unordered_map<std::string, std::function<void(CachedWirelessNetwork&, const core::dbus::types::Variant&)> > lut111 static const std::unordered_map<std::string,
119 {112 std::function<void(CachedWirelessNetwork&, const core::dbus::types::Variant&)>> lut{
120 {113 {org::freedesktop::NetworkManager::AccessPoint::HwAddress::name(),
121 org::freedesktop::NetworkManager::AccessPoint::HwAddress::name(),114 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)
122 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)115 {
123 {116 thiz.bssid_ = value.as<org::freedesktop::NetworkManager::AccessPoint::HwAddress::ValueType>();
124 thiz.bssid_ = value.as<org::freedesktop::NetworkManager::AccessPoint::HwAddress::ValueType>();117 }},
125 }118 {org::freedesktop::NetworkManager::AccessPoint::Ssid::name(),
126 },119 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)
127 {120 {
128 org::freedesktop::NetworkManager::AccessPoint::Ssid::name(),121 thiz.ssid_ =
129 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)122 utf8_ssid_to_string(value.as<org::freedesktop::NetworkManager::AccessPoint::Ssid::ValueType>());
130 {123 }},
131 thiz.ssid_ = utf8_ssid_to_string(value.as<org::freedesktop::NetworkManager::AccessPoint::Ssid::ValueType>());124 {org::freedesktop::NetworkManager::AccessPoint::Strength::name(),
132 }125 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)
133 },126 {
134 {127 thiz.signal_strength_ = com::ubuntu::location::connectivity::WirelessNetwork::SignalStrength{
135 org::freedesktop::NetworkManager::AccessPoint::Strength::name(),128 value.as<org::freedesktop::NetworkManager::AccessPoint::Strength::ValueType>()};
136 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)129 }},
137 {130 {org::freedesktop::NetworkManager::AccessPoint::Frequency::name(),
138 thiz.signal_strength_ = com::ubuntu::location::connectivity::WirelessNetwork::SignalStrength131 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)
139 {132 {
140 value.as<org::freedesktop::NetworkManager::AccessPoint::Strength::ValueType>()133 thiz.frequency_ = com::ubuntu::location::connectivity::WirelessNetwork::Frequency{
141 };134 static_cast<int>(value.as<org::freedesktop::NetworkManager::AccessPoint::Frequency::ValueType>())};
142 }135 }},
143 },136 {org::freedesktop::NetworkManager::AccessPoint::Mode::name(),
144 {137 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)
145 org::freedesktop::NetworkManager::AccessPoint::Frequency::name(),138 {
146 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)139 thiz.mode_ =
147 {140 wifi_mode_from_ap_mode(value.as<org::freedesktop::NetworkManager::AccessPoint::Mode::ValueType>());
148 thiz.frequency_ = com::ubuntu::location::connectivity::WirelessNetwork::Frequency141 }},
149 {142 {org::freedesktop::NetworkManager::AccessPoint::LastSeen::name(),
150 static_cast<int>(value.as<org::freedesktop::NetworkManager::AccessPoint::Frequency::ValueType>())143 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)
151 };144 {
152 }145 thiz.last_seen_ = std::chrono::system_clock::time_point{std::chrono::system_clock::duration{
153 },146 value.as<org::freedesktop::NetworkManager::AccessPoint::LastSeen::ValueType>()}};
154 {147 }}};
155 org::freedesktop::NetworkManager::AccessPoint::Mode::name(),
156 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)
157 {
158 thiz.mode_ = wifi_mode_from_ap_mode(value.as<org::freedesktop::NetworkManager::AccessPoint::Mode::ValueType>());
159 }
160 },
161 {
162 org::freedesktop::NetworkManager::AccessPoint::LastSeen::name(),
163 [](CachedWirelessNetwork& thiz, const core::dbus::types::Variant& value)
164 {
165 thiz.last_seen_ = std::chrono::system_clock::time_point
166 {
167 std::chrono::system_clock::duration
168 {
169 value.as<org::freedesktop::NetworkManager::AccessPoint::LastSeen::ValueType>()
170 }
171 };
172 }
173 }
174 };
175148
176 for (const auto& pair : dict)149 for (const auto& pair : dict)
177 {150 {
@@ -182,8 +155,12 @@
182 // log the issue for later analysis.155 // log the issue for later analysis.
183 try156 try
184 {157 {
185 if (lut.count(pair.first) > 0) lut.at(pair.first)(*this, pair.second);158 if (lut.count(pair.first) > 0)
186 } catch (...)159 {
160 lut.at(pair.first)(*this, pair.second);
161 }
162 }
163 catch (...)
187 {164 {
188 VLOG(1) << "Exception while updating state for property change: " << pair.first;165 VLOG(1) << "Exception while updating state for property change: " << pair.first;
189 }166 }
190167
=== modified file 'src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h'
--- src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h 2014-08-14 20:25:22 +0000
+++ src/location_service/com/ubuntu/location/connectivity/cached_wireless_network.h 2015-04-23 17:23:49 +0000
@@ -37,9 +37,8 @@
37 // Constructs a new instance associated with the ap and the (remote) device37 // Constructs a new instance associated with the ap and the (remote) device
38 // it belongs to. Please note that the caching nature of the class ensures that38 // it belongs to. Please note that the caching nature of the class ensures that
39 // ap and device stubs are kept alive.39 // ap and device stubs are kept alive.
40 CachedWirelessNetwork(40 CachedWirelessNetwork(const org::freedesktop::NetworkManager::Device& device,
41 const org::freedesktop::NetworkManager::Device& device,41 const org::freedesktop::NetworkManager::AccessPoint& ap);
42 const org::freedesktop::NetworkManager::AccessPoint& ap);
4342
44 // Timestamp when the network became visible.43 // Timestamp when the network became visible.
45 const core::Property<std::chrono::system_clock::time_point>& last_seen() const override;44 const core::Property<std::chrono::system_clock::time_point>& last_seen() const override;
@@ -76,4 +75,4 @@
76};75};
77}76}
7877
79#endif // CACHED_WIRELESS_NETWORK_H_78#endif // CACHED_WIRELESS_NETWORK_H_
8079
=== modified file 'src/location_service/com/ubuntu/location/connectivity/dummy_connectivity_manager.h'
--- src/location_service/com/ubuntu/location/connectivity/dummy_connectivity_manager.h 2014-10-08 20:51:25 +0000
+++ src/location_service/com/ubuntu/location/connectivity/dummy_connectivity_manager.h 2015-04-23 17:23:49 +0000
@@ -50,7 +50,8 @@
50 return properties.is_wwan_hardware_enabled;50 return properties.is_wwan_hardware_enabled;
51 }51 }
5252
53 const core::Property<com::ubuntu::location::connectivity::Characteristics>& active_connection_characteristics() const53 const core::Property<com::ubuntu::location::connectivity::Characteristics>& active_connection_characteristics()
54 const
54 {55 {
55 return properties.active_connection_characteristics;56 return properties.active_connection_characteristics;
56 }57 }
@@ -74,7 +75,8 @@
74 return sigs.wireless_network_removed;75 return sigs.wireless_network_removed;
75 }76 }
7677
77 void enumerate_visible_wireless_networks(const std::function<void(const com::ubuntu::location::connectivity::WirelessNetwork::Ptr&)>&) const78 void enumerate_visible_wireless_networks(
79 const std::function<void(const com::ubuntu::location::connectivity::WirelessNetwork::Ptr&)>&) const
78 {80 {
79 }81 }
8082
@@ -88,7 +90,8 @@
88 return sigs.connected_cell_removed;90 return sigs.connected_cell_removed;
89 }91 }
9092
91 void enumerate_connected_radio_cells(const std::function<void(const com::ubuntu::location::connectivity::RadioCell::Ptr&)>&) const93 void enumerate_connected_radio_cells(
94 const std::function<void(const com::ubuntu::location::connectivity::RadioCell::Ptr&)>&) const
92 {95 {
93 }96 }
9497
@@ -98,7 +101,8 @@
98 core::Property<bool> is_wwan_enabled{false};101 core::Property<bool> is_wwan_enabled{false};
99 core::Property<bool> is_wifi_hardware_enabled{false};102 core::Property<bool> is_wifi_hardware_enabled{false};
100 core::Property<bool> is_wwan_hardware_enabled{false};103 core::Property<bool> is_wwan_hardware_enabled{false};
101 core::Property<com::ubuntu::location::connectivity::State> state{com::ubuntu::location::connectivity::State::unknown};104 core::Property<com::ubuntu::location::connectivity::State> state{
105 com::ubuntu::location::connectivity::State::unknown};
102 core::Property<com::ubuntu::location::connectivity::Characteristics> active_connection_characteristics{};106 core::Property<com::ubuntu::location::connectivity::Characteristics> active_connection_characteristics{};
103 } properties;107 } properties;
104108
@@ -113,4 +117,4 @@
113};117};
114}118}
115119
116#endif // DUMMY_CONNECTIVITY_MANAGER_H_120#endif // DUMMY_CONNECTIVITY_MANAGER_H_
117121
=== modified file 'src/location_service/com/ubuntu/location/connectivity/manager.cpp'
--- src/location_service/com/ubuntu/location/connectivity/manager.cpp 2014-10-02 06:59:46 +0000
+++ src/location_service/com/ubuntu/location/connectivity/manager.cpp 2015-04-23 17:23:49 +0000
@@ -24,14 +24,30 @@
24{24{
25 switch (state)25 switch (state)
26 {26 {
27 case State::unknown: out << "State::unknown"; break;27 case State::unknown:
28 case State::asleep: out << "State::asleep"; break;28 out << "State::unknown";
29 case State::disconnected: out << "State::disconnected"; break;29 break;
30 case State::disconnecting: out << "State::disconnecting"; break;30 case State::asleep:
31 case State::connecting: out << "State::connecting"; break;31 out << "State::asleep";
32 case State::connected_local: out << "State::connected_local"; break;32 break;
33 case State::connected_site: out << "State::connected_site"; break;33 case State::disconnected:
34 case State::connected_global: out << "State::connected_global"; break;34 out << "State::disconnected";
35 break;
36 case State::disconnecting:
37 out << "State::disconnecting";
38 break;
39 case State::connecting:
40 out << "State::connecting";
41 break;
42 case State::connected_local:
43 out << "State::connected_local";
44 break;
45 case State::connected_site:
46 out << "State::connected_site";
47 break;
48 case State::connected_global:
49 out << "State::connected_global";
50 break;
35 }51 }
3652
37 return out;53 return out;
@@ -53,18 +69,41 @@
5369
54 out << "[";70 out << "[";
5571
56 if ((characteristics & connectivity::Characteristics::connection_goes_via_wifi) != connectivity::Characteristics::none)72 if ((characteristics & connectivity::Characteristics::connection_goes_via_wifi) !=
57 { out << "connection_goes_via_wifi"; first = false; }73 connectivity::Characteristics::none)
58 if ((characteristics & connectivity::Characteristics::connection_goes_via_wwan) != connectivity::Characteristics::none)74 {
59 { out << (first ? "" : ", ") << "connection_goes_via_wwan"; first = false; }75 out << "connection_goes_via_wifi";
76 first = false;
77 }
78 if ((characteristics & connectivity::Characteristics::connection_goes_via_wwan) !=
79 connectivity::Characteristics::none)
80 {
81 out << (first ? "" : ", ") << "connection_goes_via_wwan";
82 first = false;
83 }
60 if ((characteristics & connectivity::Characteristics::connection_is_roaming) != connectivity::Characteristics::none)84 if ((characteristics & connectivity::Characteristics::connection_is_roaming) != connectivity::Characteristics::none)
61 { out << (first ? "" : ", ") << "connection_is_roaming"; first = false; }85 {
62 if ((characteristics & connectivity::Characteristics::connection_has_monetary_costs) != connectivity::Characteristics::none)86 out << (first ? "" : ", ") << "connection_is_roaming";
63 { out << (first ? "" : ", ") << "connection_has_monetary_costs"; first = false; }87 first = false;
64 if ((characteristics & connectivity::Characteristics::connection_is_bandwith_limited) != connectivity::Characteristics::none)88 }
65 { out << (first ? "" : ", ") << "connection_is_bandwidth_limited"; first = false; }89 if ((characteristics & connectivity::Characteristics::connection_has_monetary_costs) !=
66 if ((characteristics & connectivity::Characteristics::connection_is_volume_limited) != connectivity::Characteristics::none)90 connectivity::Characteristics::none)
67 { out << (first ? "" : ", ") << "connection_is_volume_limited"; first = false; }91 {
92 out << (first ? "" : ", ") << "connection_has_monetary_costs";
93 first = false;
94 }
95 if ((characteristics & connectivity::Characteristics::connection_is_bandwith_limited) !=
96 connectivity::Characteristics::none)
97 {
98 out << (first ? "" : ", ") << "connection_is_bandwidth_limited";
99 first = false;
100 }
101 if ((characteristics & connectivity::Characteristics::connection_is_volume_limited) !=
102 connectivity::Characteristics::none)
103 {
104 out << (first ? "" : ", ") << "connection_is_volume_limited";
105 first = false;
106 }
68107
69 out << "]";108 out << "]";
70 return out;109 return out;
71110
=== modified file 'src/location_service/com/ubuntu/location/connectivity/nm.h'
--- src/location_service/com/ubuntu/location/connectivity/nm.h 2015-02-26 10:59:22 +0000
+++ src/location_service/com/ubuntu/location/connectivity/nm.h 2015-04-23 17:23:49 +0000
@@ -151,14 +151,14 @@
151 };151 };
152152
153 AccessPoint(const std::shared_ptr<core::dbus::Object>& object)153 AccessPoint(const std::shared_ptr<core::dbus::Object>& object)
154 : object(object),154 : object(object)
155 frequency(object->get_property<Frequency>()),155 , frequency(object->get_property<Frequency>())
156 last_seen(object->get_property<LastSeen>()),156 , last_seen(object->get_property<LastSeen>())
157 mode(object->get_property<Mode>()),157 , mode(object->get_property<Mode>())
158 hw_address(object->get_property<HwAddress>()),158 , hw_address(object->get_property<HwAddress>())
159 ssid(object->get_property<Ssid>()),159 , ssid(object->get_property<Ssid>())
160 strength(object->get_property<Strength>()),160 , strength(object->get_property<Strength>())
161 properties_changed(object->get_signal<PropertiesChanged>())161 , properties_changed(object->get_signal<PropertiesChanged>())
162 {162 {
163 }163 }
164164
@@ -291,17 +291,13 @@
291 static const bool writable = false;291 static const bool writable = false;
292 };292 };
293293
294 Device(const std::shared_ptr<core::dbus::Service>& service,294 Device(const std::shared_ptr<core::dbus::Service>& service, const std::shared_ptr<core::dbus::Object>& object)
295 const std::shared_ptr<core::dbus::Object>& object)295 : service(service)
296 : service(service),296 , object(object)
297 object(object),297 , device_type(object->get_property<DeviceType>())
298 device_type(object->get_property<DeviceType>()),298 , signals{object->get_signal<Wireless::Signals::ScanDone>(),
299 signals299 object->get_signal<Wireless::Signals::AccessPointAdded>(),
300 {300 object->get_signal<Wireless::Signals::AccessPointRemoved>()}
301 object->get_signal<Wireless::Signals::ScanDone>(),
302 object->get_signal<Wireless::Signals::AccessPointAdded>(),
303 object->get_signal<Wireless::Signals::AccessPointRemoved>()
304 }
305 {301 {
306 }302 }
307303
@@ -316,10 +312,14 @@
316 auto result = object->transact_method<Wireless::GetAccessPoints, ResultType>();312 auto result = object->transact_method<Wireless::GetAccessPoints, ResultType>();
317313
318 if (result.is_error())314 if (result.is_error())
315 {
319 throw std::runtime_error(result.error().print());316 throw std::runtime_error(result.error().print());
317 }
320318
321 for (const auto& path : result.value())319 for (const auto& path : result.value())
320 {
322 f(path);321 f(path);
322 }
323 }323 }
324324
325 std::vector<AccessPoint> get_access_points() const325 std::vector<AccessPoint> get_access_points() const
@@ -328,12 +328,16 @@
328 auto result = object->invoke_method_synchronously<Wireless::GetAccessPoints, ResultType>();328 auto result = object->invoke_method_synchronously<Wireless::GetAccessPoints, ResultType>();
329329
330 if (result.is_error())330 if (result.is_error())
331 {
331 throw std::runtime_error(result.error().print());332 throw std::runtime_error(result.error().print());
333 }
332334
333 std::vector<AccessPoint> aps;335 std::vector<AccessPoint> aps;
334336
335 for (const auto& path : result.value())337 for (const auto& path : result.value())
338 {
336 aps.push_back(AccessPoint(service->object_for_path(path)));339 aps.push_back(AccessPoint(service->object_for_path(path)));
340 }
337341
338 return aps;342 return aps;
339 }343 }
@@ -350,8 +354,10 @@
350 struct354 struct
351 {355 {
352 core::dbus::Signal<Wireless::Signals::ScanDone, Wireless::Signals::ScanDone::ArgumentType>::Ptr scan_done;356 core::dbus::Signal<Wireless::Signals::ScanDone, Wireless::Signals::ScanDone::ArgumentType>::Ptr scan_done;
353 core::dbus::Signal<Wireless::Signals::AccessPointAdded, Wireless::Signals::AccessPointAdded::ArgumentType>::Ptr ap_added;357 core::dbus::Signal<Wireless::Signals::AccessPointAdded,
354 core::dbus::Signal<Wireless::Signals::AccessPointRemoved, Wireless::Signals::AccessPointRemoved::ArgumentType>::Ptr ap_removed;358 Wireless::Signals::AccessPointAdded::ArgumentType>::Ptr ap_added;
359 core::dbus::Signal<Wireless::Signals::AccessPointRemoved,
360 Wireless::Signals::AccessPointRemoved::ArgumentType>::Ptr ap_removed;
355 } signals;361 } signals;
356 };362 };
357363
@@ -382,12 +388,9 @@
382388
383 ActiveConnection(const std::shared_ptr<core::dbus::Service>& service,389 ActiveConnection(const std::shared_ptr<core::dbus::Service>& service,
384 const std::shared_ptr<core::dbus::Object>& object)390 const std::shared_ptr<core::dbus::Object>& object)
385 : service{service},391 : service{service}
386 object{object},392 , object{object}
387 properties393 , properties{object->get_property<Properties::Devices>()}
388 {
389 object->get_property<Properties::Devices>()
390 }
391 {394 {
392 }395 }
393396
@@ -396,14 +399,16 @@
396 auto device_paths = properties.devices->get();399 auto device_paths = properties.devices->get();
397400
398 for (const auto& device_path : device_paths)401 for (const auto& device_path : device_paths)
402 {
399 functor(device_path);403 functor(device_path);
404 }
400 }405 }
401406
402 std::shared_ptr<core::dbus::Service> service;407 std::shared_ptr<core::dbus::Service> service;
403 std::shared_ptr<core::dbus::Object> object;408 std::shared_ptr<core::dbus::Object> object;
404 struct409 struct
405 {410 {
406 std::shared_ptr<core::dbus::Property<Properties::Devices> > devices;411 std::shared_ptr<core::dbus::Property<Properties::Devices>> devices;
407 } properties;412 } properties;
408 };413 };
409414
@@ -603,41 +608,35 @@
603 };608 };
604609
605 NetworkManager(const core::dbus::Bus::Ptr& bus)610 NetworkManager(const core::dbus::Bus::Ptr& bus)
606 : service(core::dbus::Service::use_service<NetworkManager>(bus)),611 : service(core::dbus::Service::use_service<NetworkManager>(bus))
607 object(service->object_for_path(core::dbus::types::ObjectPath("/org/freedesktop/NetworkManager"))),612 , object(service->object_for_path(core::dbus::types::ObjectPath("/org/freedesktop/NetworkManager")))
608 properties613 , properties{object->get_property<Properties::Connectivity>(),
609 {614 object->get_property<Properties::PrimaryConnection>(),
610 object->get_property<Properties::Connectivity>(),615 object->get_property<Properties::State>(),
611 object->get_property<Properties::PrimaryConnection>(),616 object->get_property<Properties::WirelessEnabled>(),
612 object->get_property<Properties::State>(),617 object->get_property<Properties::WirelessHardwareEnabled>(),
613 object->get_property<Properties::WirelessEnabled>(),618 object->get_property<Properties::WwanEnabled>(),
614 object->get_property<Properties::WirelessHardwareEnabled>(),619 object->get_property<Properties::WwanHardwareEnabled>()}
615 object->get_property<Properties::WwanEnabled>(),620 , signals{object->get_signal<Signals::DeviceAdded>(),
616 object->get_property<Properties::WwanHardwareEnabled>()621 object->get_signal<Signals::DeviceRemoved>(),
617 },622 object->get_signal<Signals::PropertiesChanged>(),
618 signals623 object->get_signal<Signals::StateChanged>()}
619 {
620 object->get_signal<Signals::DeviceAdded>(),
621 object->get_signal<Signals::DeviceRemoved>(),
622 object->get_signal<Signals::PropertiesChanged>(),
623 object->get_signal<Signals::StateChanged>()
624 }
625 {624 {
626 }625 }
627626
628 void for_each_device(const std::function<void(const core::dbus::types::ObjectPath&)>& f)627 void for_each_device(const std::function<void(const core::dbus::types::ObjectPath&)>& f)
629 {628 {
630 auto result =629 auto result = object->transact_method<NetworkManager::GetDevices, std::vector<core::dbus::types::ObjectPath>>();
631 object->transact_method<
632 NetworkManager::GetDevices,
633 std::vector<core::dbus::types::ObjectPath>
634 >();
635630
636 if (result.is_error())631 if (result.is_error())
632 {
637 throw std::runtime_error(result.error().print());633 throw std::runtime_error(result.error().print());
634 }
638635
639 for (const auto& path : result.value())636 for (const auto& path : result.value())
637 {
640 f(path);638 f(path);
639 }
641 }640 }
642641
643 Device device_for_path(const core::dbus::types::ObjectPath& path)642 Device device_for_path(const core::dbus::types::ObjectPath& path)
@@ -648,20 +647,18 @@
648 std::vector<Device> get_devices()647 std::vector<Device> get_devices()
649 {648 {
650 auto result =649 auto result =
651 object->invoke_method_synchronously<650 object
652 NetworkManager::GetDevices,651 ->invoke_method_synchronously<NetworkManager::GetDevices, std::vector<core::dbus::types::ObjectPath>>();
653 std::vector<core::dbus::types::ObjectPath>>();
654652
655 if (result.is_error())653 if (result.is_error())
654 {
656 throw std::runtime_error(result.error().print());655 throw std::runtime_error(result.error().print());
656 }
657657
658 std::vector<Device> devices;658 std::vector<Device> devices;
659 for (const auto& path : result.value())659 for (const auto& path : result.value())
660 {660 {
661 devices.emplace_back(661 devices.emplace_back(Device(service, service->object_for_path(path)));
662 Device(
663 service,
664 service->object_for_path(path)));
665 }662 }
666663
667 return devices;664 return devices;
@@ -672,23 +669,24 @@
672669
673 struct670 struct
674 {671 {
675 std::shared_ptr<core::dbus::Property<Properties::Connectivity> > connectivity;672 std::shared_ptr<core::dbus::Property<Properties::Connectivity>> connectivity;
676 std::shared_ptr<core::dbus::Property<Properties::PrimaryConnection> > primary_connection;673 std::shared_ptr<core::dbus::Property<Properties::PrimaryConnection>> primary_connection;
677 std::shared_ptr<core::dbus::Property<Properties::State> > state;674 std::shared_ptr<core::dbus::Property<Properties::State>> state;
678 std::shared_ptr<core::dbus::Property<Properties::WirelessEnabled> > is_wifi_enabled;675 std::shared_ptr<core::dbus::Property<Properties::WirelessEnabled>> is_wifi_enabled;
679 std::shared_ptr<core::dbus::Property<Properties::WirelessHardwareEnabled> > is_wifi_hardware_enabled;676 std::shared_ptr<core::dbus::Property<Properties::WirelessHardwareEnabled>> is_wifi_hardware_enabled;
680 std::shared_ptr<core::dbus::Property<Properties::WwanEnabled> > is_wwan_enabled;677 std::shared_ptr<core::dbus::Property<Properties::WwanEnabled>> is_wwan_enabled;
681 std::shared_ptr<core::dbus::Property<Properties::WwanHardwareEnabled> > is_wwan_hardware_enabled;678 std::shared_ptr<core::dbus::Property<Properties::WwanHardwareEnabled>> is_wwan_hardware_enabled;
682 } properties;679 } properties;
683 struct680 struct
684 {681 {
685 core::dbus::Signal<Signals::DeviceAdded, Signals::DeviceAdded::ArgumentType>::Ptr device_added;682 core::dbus::Signal<Signals::DeviceAdded, Signals::DeviceAdded::ArgumentType>::Ptr device_added;
686 core::dbus::Signal<Signals::DeviceRemoved, Signals::DeviceRemoved::ArgumentType>::Ptr device_removed;683 core::dbus::Signal<Signals::DeviceRemoved, Signals::DeviceRemoved::ArgumentType>::Ptr device_removed;
687 core::dbus::Signal<Signals::PropertiesChanged, Signals::PropertiesChanged::ArgumentType>::Ptr properties_changed;684 core::dbus::Signal<Signals::PropertiesChanged, Signals::PropertiesChanged::ArgumentType>::Ptr
685 properties_changed;
688 core::dbus::Signal<Signals::StateChanged, Signals::StateChanged::ArgumentType>::Ptr state_changed;686 core::dbus::Signal<Signals::StateChanged, Signals::StateChanged::ArgumentType>::Ptr state_changed;
689 } signals;687 } signals;
690};688};
691}689}
692}690}
693691
694#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_NM_H692#endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_NM_H
695693
=== modified file 'src/location_service/com/ubuntu/location/connectivity/ofono.h'
--- src/location_service/com/ubuntu/location/connectivity/ofono.h 2015-01-06 12:35:02 +0000
+++ src/location_service/com/ubuntu/location/connectivity/ofono.h 2015-04-23 17:23:49 +0000
@@ -36,84 +36,31 @@
36{36{
37struct Ofono37struct Ofono
38{38{
39static const std::string& name()
40{
41 static const std::string s{"org.ofono"};
42 return s;
43}
44struct Manager
45{
46 typedef std::shared_ptr<Manager> Ptr;
47
48 static const std::string& name()39 static const std::string& name()
49 {40 {
50 static const std::string s{"org.ofono.Manager"};41 static const std::string s{"org.ofono"};
51 return s;42 return s;
52 }43 }
5344 struct Manager
54 struct GetModems45 {
55 {46 typedef std::shared_ptr<Manager> Ptr;
56 static const std::string& name()47
57 {48 static const std::string& name()
58 static const std::string s{"GetModems"};49 {
59 return s;50 static const std::string s{"org.ofono.Manager"};
60 }51 return s;
6152 }
62 typedef Manager Interface;53
63 typedef std::vector<54 struct GetModems
64 core::dbus::types::Struct<
65 core::dbus::types::ObjectPath
66 >
67 > ResultType;
68
69 static std::chrono::milliseconds default_timeout()
70 {
71 return std::chrono::seconds{1};
72 }
73 };
74
75 struct ModemAdded
76 {
77 static const std::string& name()
78 {
79 static const std::string s{"ModemAdded"};
80 return s;
81 }
82
83 typedef Manager Interface;
84 typedef std::tuple<core::dbus::types::ObjectPath, std::map<std::string, std::string>> ArgumentType;
85 };
86
87 struct ModemRemoved
88 {
89 static const std::string& name()
90 {
91 static const std::string s{"ModemRemoved"};
92 return s;
93 }
94
95 typedef Manager Interface;
96 typedef core::dbus::types::ObjectPath ArgumentType;
97 };
98
99 struct Modem
100 {
101 static const std::string& name()
102 {
103 static const std::string s{"org.ofono.Modem"};
104 return s;
105 }
106
107 struct GetProperties
108 {55 {
109 static const std::string& name()56 static const std::string& name()
110 {57 {
111 static const std::string s{"GetProperties"};58 static const std::string s{"GetModems"};
112 return s;59 return s;
113 }60 }
11461
115 typedef Modem Interface;62 typedef Manager Interface;
116 typedef std::map<std::string, core::dbus::types::Variant> ValueType;63 typedef std::vector<core::dbus::types::Struct<core::dbus::types::ObjectPath>> ResultType;
11764
118 static std::chrono::milliseconds default_timeout()65 static std::chrono::milliseconds default_timeout()
119 {66 {
@@ -121,287 +68,37 @@
121 }68 }
122 };69 };
12370
124 struct PropertyChanged71 struct ModemAdded
125 {72 {
126 inline static std::string name()73 static const std::string& name()
127 {74 {
128 return "PropertyChanged";75 static const std::string s{"ModemAdded"};
129 }76 return s;
13077 }
131 typedef Modem Interface;78
13279 typedef Manager Interface;
133 typedef std::tuple<std::string, core::dbus::types::Variant> ArgumentType;80 typedef std::tuple<core::dbus::types::ObjectPath, std::map<std::string, std::string>> ArgumentType;
134 };81 };
13582
136 struct Properties83 struct ModemRemoved
137 {84 {
138 struct Powered85 static const std::string& name()
139 {86 {
140 static const std::string& name()87 static const std::string s{"ModemRemoved"};
141 {88 return s;
142 static const std::string s{"Powered"};89 }
143 return s;90
144 }91 typedef Manager Interface;
14592 typedef core::dbus::types::ObjectPath ArgumentType;
146 typedef Modem Interface;93 };
147 typedef bool ValueType;94
148 static const bool readable = true;95 struct Modem
149 static const bool writable = true;96 {
150 };97 static const std::string& name()
15198 {
152 struct Online99 static const std::string s{"org.ofono.Modem"};
153 {100 return s;
154 static const std::string& name()101 }
155 {
156 static const std::string s{"Online"};
157 return s;
158 }
159
160 typedef Modem Interface;
161 typedef bool ValueType;
162 static const bool readable = true;
163 static const bool writable = true;
164 };
165
166 struct Lockdown
167 {
168 static const std::string& name()
169 {
170 static const std::string s{"Lockdown"};
171 return s;
172 }
173
174 typedef Modem Interface;
175 typedef bool ValueType;
176 static const bool readable = true;
177 static const bool writable = true;
178 };
179
180 struct Name
181 {
182 static const std::string& name()
183 {
184 static const std::string s{"Name"};
185 return s;
186 }
187
188 typedef Modem Interface;
189 typedef std::string ValueType;
190 static const bool readable = true;
191 static const bool writable = false;
192 };
193
194 struct Manufacturer
195 {
196 static const std::string& name()
197 {
198 static const std::string s{"Manufacturer"};
199 return s;
200 }
201
202 typedef Modem Interface;
203 typedef std::string ValueType;
204 static const bool readable = true;
205 static const bool writable = false;
206 };
207
208 struct Model
209 {
210 static const std::string& name()
211 {
212 static const std::string s{"Model"};
213 return s;
214 }
215
216 typedef Modem Interface;
217 typedef std::string ValueType;
218 static const bool readable = true;
219 static const bool writable = false;
220 };
221
222 struct Revision
223 {
224 static const std::string& name()
225 {
226 static const std::string s{"Revision"};
227 return s;
228 }
229
230 typedef Modem Interface;
231 typedef std::string ValueType;
232 static const bool readable = true;
233 static const bool writable = false;
234 };
235
236 struct Serial
237 {
238 static const std::string& name()
239 {
240 static const std::string s{"Serial"};
241 return s;
242 }
243
244 typedef Modem Interface;
245 typedef std::string ValueType;
246 static const bool readable = true;
247 static const bool writable = false;
248 };
249
250 struct Features
251 {
252 static constexpr const char* net{"net"};
253 static constexpr const char* rat{"rat"};
254 static constexpr const char* cbs{"cbs"};
255 static constexpr const char* sms{"sms"};
256 static constexpr const char* sim{"sim"};
257 static constexpr const char* stk{"stk"};
258 static constexpr const char* ussd{"ussd"};
259 static constexpr const char* gprs{"gprs"};
260 static constexpr const char* tty{"tty"};
261 static constexpr const char* gps{"gps"};
262
263 static const std::string& name()
264 {
265 static const std::string s{"Features"};
266 return s;
267 }
268
269 typedef Modem Interface;
270 typedef std::vector<std::string> ValueType;
271 static const bool readable = true;
272 static const bool writable = false;
273 };
274
275 struct Interfaces
276 {
277 static constexpr const char* assisted_satellite_navigation
278 {
279 "org.ofono.AssistedSatelliteNavigation"
280 };
281 static constexpr const char* audio_settings
282 {
283 "org.ofono.AudioSettings"
284 };
285 static constexpr const char* call_barring
286 {
287 "org.ofono.CallBarring"
288 };
289 static constexpr const char* call_forwarding
290 {
291 "org.ofono.CallForwarding"
292 };
293 static constexpr const char* call_meter
294 {
295 "org.ofono.CallMeter"
296 };
297 static constexpr const char* call_settings
298 {
299 "org.ofono.CallSettings"
300 };
301 static constexpr const char* call_volume
302 {
303 "org.ofono.CallVolume"
304 };
305 static constexpr const char* cell_broadcast
306 {
307 "org.ofono.CellBroadcast"
308 };
309 static constexpr const char* hands_free
310 {
311 "org.ofono.Handsfree"
312 };
313 static constexpr const char* location_reporting
314 {
315 "org.ofono.LocationReporting"
316 };
317 static constexpr const char* message_manager
318 {
319 "org.ofono.MessageManager"
320 };
321 static constexpr const char* message_waiting
322 {
323 "org.ofono.MessageWaiting"
324 };
325 static constexpr const char* network_registration
326 {
327 "org.ofono.NetworkRegistration"
328 };
329 static constexpr const char* phonebook
330 {
331 "org.ofono.Phonebook"
332 };
333 static constexpr const char* push_notification
334 {
335 "org.ofono.PushNotification"
336 };
337 static constexpr const char* radio_settings
338 {
339 "org.ofono.RadioSettings"
340 };
341 static constexpr const char* sim_manager
342 {
343 "org.ofono.SimManager"
344 };
345 static constexpr const char* smart_messaging
346 {
347 "org.ofono.SmartMessaging"
348 };
349 static constexpr const char* sim_toolkit
350 {
351 "org.ofono.SimToolkit"
352 };
353 static constexpr const char* supplementary_services
354 {
355 "org.ofono.SupplementaryServices"
356 };
357 static constexpr const char* text_telephony
358 {
359 "org.ofono.TextTelephony"
360 };
361 static constexpr const char* voice_call_manager
362 {
363 "org.ofono.VoiceCallManager"
364 };
365
366 static const std::string& name()
367 {
368 static const std::string s{"Interfaces"};
369 return s;
370 }
371
372 typedef Modem Interface;
373 typedef std::vector<std::string> ValueType;
374 static const bool readable = true;
375 static const bool writable = false;
376 };
377
378 struct Type
379 {
380 static constexpr const char* test{"test"};
381 static constexpr const char* hfp{"hfp"};
382 static constexpr const char* sap{"sap"};
383 static constexpr const char* hardware{"hardware"};
384
385 static const std::string& name()
386 {
387 static const std::string s{"Type"};
388 return s;
389 }
390
391 typedef Modem Interface;
392 typedef std::string ValueType;
393 static const bool readable = true;
394 static const bool writable = false;
395 };
396 };
397
398 struct NetworkRegistration
399 {
400 static const std::string& name()
401 {
402 static const std::string s{"org.ofono.NetworkRegistration"};
403 return s;
404 }
405102
406 struct GetProperties103 struct GetProperties
407 {104 {
@@ -411,7 +108,7 @@
411 return s;108 return s;
412 }109 }
413110
414 typedef NetworkRegistration Interface;111 typedef Modem Interface;
415 typedef std::map<std::string, core::dbus::types::Variant> ValueType;112 typedef std::map<std::string, core::dbus::types::Variant> ValueType;
416113
417 static std::chrono::milliseconds default_timeout()114 static std::chrono::milliseconds default_timeout()
@@ -427,229 +124,498 @@
427 return "PropertyChanged";124 return "PropertyChanged";
428 }125 }
429126
430 typedef NetworkRegistration Interface;127 typedef Modem Interface;
431128
432 typedef std::tuple<std::string, core::dbus::types::Variant> ArgumentType;129 typedef std::tuple<std::string, core::dbus::types::Variant> ArgumentType;
433 };130 };
434131
435 struct Status132 struct Properties
436 {133 {
437 enum class Value134 struct Powered
438 {135 {
439 unregistered,136 static const std::string& name()
440 registered,137 {
441 searching,138 static const std::string s{"Powered"};
442 denied,139 return s;
443 unknown,140 }
444 roaming141
445 };142 typedef Modem Interface;
446143 typedef bool ValueType;
447 static constexpr const char* unregistered144 static const bool readable = true;
448 {145 static const bool writable = true;
449 "unregistered"146 };
450 };147
451 static constexpr const char* registered148 struct Online
452 {149 {
453 "registered"150 static const std::string& name()
454 };151 {
455 static constexpr const char* searching152 static const std::string s{"Online"};
456 {153 return s;
457 "searching"154 }
458 };155
459 static constexpr const char* denied156 typedef Modem Interface;
460 {157 typedef bool ValueType;
461 "denied"158 static const bool readable = true;
462 };159 static const bool writable = true;
463 static constexpr const char* unknown160 };
464 {161
465 "unknown"162 struct Lockdown
466 };163 {
467 static constexpr const char* roaming164 static const std::string& name()
468 {165 {
469 "roaming"166 static const std::string s{"Lockdown"};
470 };167 return s;
471168 }
472 static const char* value_to_string(Value value)169
473 {170 typedef Modem Interface;
474 switch (value)171 typedef bool ValueType;
475 {172 static const bool readable = true;
476 case Value::unregistered: return unregistered;173 static const bool writable = true;
477 case Value::registered: return registered;174 };
478 case Value::searching: return searching;175
479 case Value::denied: return denied;176 struct Name
480 case Value::unknown: return unknown;177 {
481 case Value::roaming: return roaming;178 static const std::string& name()
482 }179 {
483180 static const std::string s{"Name"};
484 return nullptr;181 return s;
485 }182 }
486183
487 static const std::string& name()184 typedef Modem Interface;
488 {185 typedef std::string ValueType;
489 static const std::string s{"Status"};186 static const bool readable = true;
490 return s;187 static const bool writable = false;
491 }188 };
492189
493 typedef NetworkRegistration Interface;190 struct Manufacturer
494 typedef std::string ValueType;191 {
495 static const bool readable = true;192 static const std::string& name()
496 static const bool writable = false;193 {
497 };194 static const std::string s{"Manufacturer"};
498195 return s;
499 struct LocationAreaCode196 }
500 {197
501 static const std::string& name()198 typedef Modem Interface;
502 {199 typedef std::string ValueType;
503 static const std::string s{"LocationAreaCode"};200 static const bool readable = true;
504 return s;201 static const bool writable = false;
505 }202 };
506203
507 typedef NetworkRegistration Interface;204 struct Model
508 typedef std::uint16_t ValueType;205 {
509 static const bool readable = true;206 static const std::string& name()
510 static const bool writable = false;207 {
511 };208 static const std::string s{"Model"};
512209 return s;
513 struct CellId210 }
514 {211
515 static const std::string& name()212 typedef Modem Interface;
516 {213 typedef std::string ValueType;
517 static const std::string s{"CellId"};214 static const bool readable = true;
518 return s;215 static const bool writable = false;
519 }216 };
520217
521 typedef NetworkRegistration Interface;218 struct Revision
522 typedef std::uint32_t ValueType;219 {
523 static const bool readable = true;220 static const std::string& name()
524 static const bool writable = false;221 {
525 };222 static const std::string s{"Revision"};
526223 return s;
527 struct MobileCountryCode224 }
528 {225
529 static const std::string& name()226 typedef Modem Interface;
530 {227 typedef std::string ValueType;
531 static const std::string s{"MobileCountryCode"};228 static const bool readable = true;
532 return s;229 static const bool writable = false;
533 }230 };
534231
535 typedef NetworkRegistration Interface;232 struct Serial
536 typedef std::string ValueType;233 {
537 static const bool readable = true;234 static const std::string& name()
538 static const bool writable = false;235 {
539 };236 static const std::string s{"Serial"};
540237 return s;
541 struct MobileNetworkCode238 }
542 {239
543 static const std::string& name()240 typedef Modem Interface;
544 {241 typedef std::string ValueType;
545 static const std::string s{"MobileNetworkCode"};242 static const bool readable = true;
546 return s;243 static const bool writable = false;
547 }244 };
548
549 typedef NetworkRegistration Interface;
550 typedef std::string ValueType;
551 static const bool readable = true;
552 static const bool writable = false;
553 };
554
555 struct Technology
556 {
557 static const char* gsm() { return "gsm"; }
558 static const char* edge() { return "edge"; }
559 static const char* umts() { return "umts"; }
560 static const char* hspa() { return "hspa"; }
561 static const char* lte() { return "lte"; }
562
563 static const std::string& name()
564 {
565 static const std::string s{"Technology"};
566 return s;
567 }
568
569 typedef NetworkRegistration Interface;
570 typedef std::string ValueType;
571 static const bool readable = true;
572 static const bool writable = false;
573 };
574
575 struct Strength
576 {
577 static const std::string& name()
578 {
579 static const std::string s{"Strength"};
580 return s;
581 }
582
583 typedef NetworkRegistration Interface;
584 typedef std::int8_t ValueType;
585 static const bool readable = true;
586 static const bool writable = false;
587 };
588
589 NetworkRegistration(const std::shared_ptr<core::dbus::Object>& object)
590 : object(object),
591 signals
592 {
593 object->get_signal<PropertyChanged>()
594 }
595 {
596 }
597
598 // Calling this function might fail. However, we do not throw and only log
599 // the issue for later forensics.
600 bool refresh_properties() const
601 {
602 auto result = object->invoke_method_synchronously<GetProperties, GetProperties::ValueType>();
603
604 if (result.is_error())
605 {
606 LOG(WARNING) << "Could not refresh properties for org::Ofono::Modem::NetworkRegistration: " << result.error().print();
607 return false;
608 }
609
610 properties = result.value();
611 return true;
612 }
613
614 template<typename Property>
615 typename Property::ValueType get(bool refresh = true) const
616 {
617 if (refresh)
618 {
619 if (not refresh_properties())
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches