location-service-0.0.2+14.04.20140307/0000755000015201777760000000000012306337604017360 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/include/0000755000015201777760000000000012306337604021003 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/include/location_service/0000755000015201777760000000000012306337604024333 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/0000755000015201777760000000000012306337604025111 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/0000755000015201777760000000000012306337604026433 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/0000755000015201777760000000000012306337604030243 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/provider_factory.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/provider_factory.0000644000015201777760000000363612306337245033636 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_ #include "com/ubuntu/location/configuration.h" #include "com/ubuntu/location/provider.h" #include #include #include #include #include namespace com { namespace ubuntu { namespace location { class Provider; class ProviderFactory { public: typedef com::ubuntu::location::Configuration Configuration; typedef std::function Factory; static ProviderFactory& instance(); void add_factory_for_name(const std::string& name, const Factory& factory); Provider::Ptr create_provider_for_name_with_config(const std::string& name, const Configuration& config); void enumerate(const std::function& enumerator); private: ProviderFactory() = default; ~ProviderFactory() = default; ProviderFactory(const ProviderFactory&) = delete; ProviderFactory& operator=(const ProviderFactory&) = delete; std::mutex guard; std::map factory_store; }; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_FACTORY_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/criteria.h0000644000015201777760000000331212306337245032216 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CRITERIA_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CRITERIA_H_ #include "com/ubuntu/location/accuracy.h" #include "com/ubuntu/location/heading.h" #include "com/ubuntu/location/velocity.h" #include "com/ubuntu/location/wgs84/altitude.h" #include "com/ubuntu/location/wgs84/latitude.h" #include "com/ubuntu/location/wgs84/longitude.h" #include #include #include namespace com { namespace ubuntu { namespace location { struct Criteria { Criteria() : latitude_accuracy(), longitude_accuracy(), altitude_accuracy(), velocity_accuracy(), heading_accuracy() { } Accuracy latitude_accuracy; Accuracy longitude_accuracy; Accuracy altitude_accuracy; Accuracy velocity_accuracy; Accuracy heading_accuracy; }; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CRITERIA_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/update.h0000644000015201777760000000317112306337245031701 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_ #include "com/ubuntu/location/clock.h" #include namespace com { namespace ubuntu { namespace location { template struct Update { Update(const T& value = T{}, const Clock::Timestamp& when = Clock::Timestamp{}) : value{value}, when{when} { } bool operator==(const Update& rhs) const { return value == rhs.value && when == rhs.when; } bool operator!=(const Update& rhs) const { return !(value == rhs.value && when == rhs.when); } T value; Clock::Timestamp when; }; template inline std::ostream& operator<<(std::ostream& out, const Update& update) { out << "Update(" << update.value << ", " << update.when.time_since_epoch().count() << ")"; return out; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_UPDATE_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/position.h0000644000015201777760000000464512306337245032272 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_POSITION_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_POSITION_H_ #include "com/ubuntu/location/wgs84/altitude.h" #include "com/ubuntu/location/wgs84/latitude.h" #include "com/ubuntu/location/wgs84/longitude.h" #include #include namespace com { namespace ubuntu { namespace location { class Position { public: enum Flag { latitude_flag = 0, longitude_flag = 1, altitude_flag = 2 }; typedef std::bitset<3> Flags; Position(); Position( const wgs84::Latitude& latitude, const wgs84::Longitude& longitude); Position( const wgs84::Latitude& latitude, const wgs84::Longitude& longitude, const wgs84::Altitude& altitude); bool operator==(const Position& rhs) const; bool operator!=(const Position& rhs) const; const Flags& flags() const; bool has_latitude() const; Position& latitude(const wgs84::Latitude& lat); const wgs84::Latitude& latitude() const; bool has_longitude() const; Position& longitude(const wgs84::Longitude& lon); const wgs84::Longitude& longitude() const; bool has_altitude() const; Position& altitude(const wgs84::Altitude& alt); const wgs84::Altitude& altitude() const; private: template friend struct Codec; struct { Flags flags; wgs84::Latitude latitude; wgs84::Longitude longitude; wgs84::Altitude altitude; } fields; }; std::ostream& operator<<(std::ostream& out, const Position& position); units::Quantity haversine_distance(const Position& p1, const Position& p2); } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_POSITION_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/proxy_provider.h0000644000015201777760000000371712306337245033520 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROXY_PROVIDER_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROXY_PROVIDER_H_ #include "com/ubuntu/location/provider.h" #include "com/ubuntu/location/provider_selection_policy.h" #include #include namespace com { namespace ubuntu { namespace location { class ProxyProvider : public Provider { public: typedef std::shared_ptr Ptr; ProxyProvider(const ProviderSelection& selection); ~ProxyProvider() noexcept; ChannelConnection subscribe_to_position_updates(std::function&)> f); ChannelConnection subscribe_to_heading_updates(std::function&)> f); ChannelConnection subscribe_to_velocity_updates(std::function&)> f); virtual void start_position_updates(); virtual void stop_position_updates(); virtual void start_velocity_updates(); virtual void stop_velocity_updates(); virtual void start_heading_updates(); virtual void stop_heading_updates(); private: Provider::Ptr position_updates_provider; Provider::Ptr heading_updates_provider; Provider::Ptr velocity_updates_provider; }; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROXY_PROVIDER_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/0000755000015201777760000000000012306337604031703 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016300000000000011215 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/default_configuration.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/default_c0000644000015201777760000000331112306337245033553 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_CONFIGURATION_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_CONFIGURATION_H_ #include "com/ubuntu/location/service/configuration.h" #include namespace com { namespace ubuntu { namespace location { namespace service { class DefaultConfiguration { public: DefaultConfiguration(); DefaultConfiguration(const DefaultConfiguration&) = delete; DefaultConfiguration& operator=(const DefaultConfiguration&) = delete; ~DefaultConfiguration() noexcept; virtual Engine::Ptr the_engine( const std::set& provider_set, const ProviderSelectionPolicy::Ptr& provider_selection_policy); ProviderSelectionPolicy::Ptr the_provider_selection_policy(); std::set the_provider_set( const Provider::Ptr& seed = Provider::Ptr {}); PermissionManager::Ptr the_permission_manager(); }; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_CONFIGURATION_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/session/0000755000015201777760000000000012306337604033366 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015700000000000011220 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/session/interface.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/session/i0000644000015201777760000001663412306337270033552 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_ #include "com/ubuntu/location/channel.h" #include "com/ubuntu/location/heading.h" #include "com/ubuntu/location/position.h" #include "com/ubuntu/location/provider.h" #include "com/ubuntu/location/update.h" #include "com/ubuntu/location/velocity.h" #include #include #include namespace com { namespace ubuntu { namespace location { namespace service { namespace session { class Interface { public: struct UpdatePosition { typedef com::ubuntu::location::service::session::Interface Interface; inline static const std::string& name() { static const std::string s { "UpdatePosition" }; return s; } typedef void ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::milliseconds{250}; } }; struct UpdateVelocity { typedef com::ubuntu::location::service::session::Interface Interface; inline static const std::string& name() { static const std::string s { "UpdateVelocity" }; return s; } typedef void ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::milliseconds{250}; } }; struct UpdateHeading { typedef com::ubuntu::location::service::session::Interface Interface; inline static const std::string& name() { static const std::string s { "UpdateHeading" }; return s; } typedef void ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::milliseconds{250}; } }; struct StartPositionUpdates { typedef com::ubuntu::location::service::session::Interface Interface; inline static const std::string& name() { static const std::string s { "StartPositionUpdates" }; return s; } typedef void ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct StopPositionUpdates { typedef com::ubuntu::location::service::session::Interface Interface; inline static const std::string& name() { static const std::string s { "StopPositionUpdates" }; return s; } typedef void ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct StartVelocityUpdates { typedef com::ubuntu::location::service::session::Interface Interface; inline static const std::string& name() { static const std::string s { "StartVelocityUpdates" }; return s; } typedef void ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct StopVelocityUpdates { typedef com::ubuntu::location::service::session::Interface Interface; inline static const std::string& name() { static const std::string s { "StopVelocityUpdates" }; return s; } typedef void ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct StartHeadingUpdates { typedef com::ubuntu::location::service::session::Interface Interface; inline static const std::string& name() { static const std::string s { "StartHeadingUpdates" }; return s; } typedef void ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct StopHeadingUpdates { typedef com::ubuntu::location::service::session::Interface Interface; inline static const std::string& name() { static const std::string s { "StopHeadingUpdates" }; return s; } typedef void ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct Errors { struct ErrorParsingUpdate { inline static std::string name() { return "com.ubuntu.location.Service.Session.ErrorParsingUpdate"; } }; struct ErrorStartingUpdate { inline static std::string name() { return "com.ubuntu.location.Service.Session.ErrorStartingUpdate"; } }; struct ErrorStoppingUpdate { inline static std::string name() { return "com.ubuntu.location.Service.Session.ErrorStoppingUpdate"; } }; }; typedef std::shared_ptr Ptr; Interface(const Interface&) = delete; virtual ~Interface() noexcept; Interface& operator=(const Interface&) = delete; virtual const core::dbus::types::ObjectPath& path() const = 0; ChannelConnection install_position_updates_handler(std::function&)> handler); ChannelConnection install_velocity_updates_handler(std::function&)> handler); ChannelConnection install_heading_updates_handler(std::function&)> handler); virtual void start_position_updates() = 0; virtual void stop_position_updates() noexcept = 0; virtual void start_velocity_updates() = 0; virtual void stop_velocity_updates() noexcept = 0; virtual void start_heading_updates() = 0; virtual void stop_heading_updates() noexcept = 0; protected: Interface(); Channel>& access_position_updates_channel(); Channel>& access_heading_updates_channel(); Channel>& access_velocity_updates_channel(); private: struct Private; std::unique_ptr d; }; } } } } } namespace core { namespace dbus { namespace traits { template<> struct Service { static const std::string& interface_name() { static const std::string s { "com.ubuntu.location.Service.Session" }; return s; } }; } } } #include "com/ubuntu/location/codec.h" #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_INTERFACE_H_ ././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/session/skeleton.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/session/s0000644000015201777760000000352512306337245033561 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_SKELETON_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_SKELETON_H_ #include "com/ubuntu/location/service/session/interface.h" #include "com/ubuntu/location/channel.h" #include "com/ubuntu/location/heading.h" #include "com/ubuntu/location/position.h" #include "com/ubuntu/location/provider.h" #include "com/ubuntu/location/update.h" #include "com/ubuntu/location/velocity.h" #include #include #include namespace com { namespace ubuntu { namespace location { namespace service { namespace session { class Skeleton : public core::dbus::Skeleton { public: Skeleton( const core::dbus::Bus::Ptr& bus, const core::dbus::types::ObjectPath& session_path); Skeleton(const Skeleton&) = delete; virtual ~Skeleton() noexcept; Skeleton& operator=(const Skeleton&) = delete; virtual const core::dbus::types::ObjectPath& path() const; private: struct Private; std::unique_ptr d; }; } } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_SKELETON_H_ ././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/session/stub.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/session/s0000644000015201777760000000403412306337245033555 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_STUB_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SESSION_SESSION_STUB_H_ #include "com/ubuntu/location/service/session/interface.h" #include "com/ubuntu/location/channel.h" #include "com/ubuntu/location/heading.h" #include "com/ubuntu/location/position.h" #include "com/ubuntu/location/provider.h" #include "com/ubuntu/location/update.h" #include "com/ubuntu/location/velocity.h" #include #include namespace com { namespace ubuntu { namespace location { namespace service { namespace session { class Stub : public core::dbus::Stub { public: Stub( const core::dbus::Bus::Ptr& bus, const core::dbus::types::ObjectPath& session_path); Stub(const Stub&) = delete; virtual ~Stub() noexcept; Stub& operator=(const Stub&) = delete; virtual const core::dbus::types::ObjectPath& path() const; virtual void start_position_updates(); virtual void stop_position_updates() noexcept; virtual void start_velocity_updates(); virtual void stop_velocity_updates() noexcept; virtual void start_heading_updates(); virtual void stop_heading_updates() noexcept; private: struct Private; std::unique_ptr d; }; } } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_STUB_H_ ././@LongLink0000000000000000000000000000016400000000000011216 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/session/implementation.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/session/i0000644000015201777760000000355112306337245033546 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_ #include "com/ubuntu/location/service/session/skeleton.h" #include "com/ubuntu/location/provider.h" #include namespace com { namespace ubuntu { namespace location { namespace service { namespace session { class Implementation : public Skeleton { public: Implementation( const core::dbus::Bus::Ptr& bus, const core::dbus::types::ObjectPath& session_path, const Provider::Ptr& provider); Implementation(const Implementation&) = delete; virtual ~Implementation() noexcept; Implementation& operator=(const Implementation&) = delete; virtual void start_position_updates(); virtual void stop_position_updates() noexcept; virtual void start_velocity_updates(); virtual void stop_velocity_updates() noexcept; virtual void start_heading_updates(); virtual void stop_heading_updates() noexcept; private: struct Private; std::unique_ptr d; }; } } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SESSION_IMPLEMENTATION_H_ ././@LongLink0000000000000000000000000000017000000000000011213 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/default_permission_manager.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/default_p0000644000015201777760000000275412306337245033602 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_PERMISSION_MANAGER_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_PERMISSION_MANAGER_H_ #include "com/ubuntu/location/service/permission_manager.h" #include #include namespace com { namespace ubuntu { namespace location { namespace service { class DefaultPermissionManager : public PermissionManager { public: typedef std::shared_ptr Ptr; DefaultPermissionManager(); ~DefaultPermissionManager() noexcept; Result check_permission_for_credentials( const Criteria&, const Credentials& credentials); private: pid_t pid; uid_t uid; }; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_DEFAULT_PERMISSION_MANAGER_H_ ././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/permission_manager.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/permissio0000644000015201777760000000326712306337245033651 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PERMISSION_MANAGER_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PERMISSION_MANAGER_H_ #include "com/ubuntu/location/channel.h" #include "com/ubuntu/location/provider_selection_policy.h" #include namespace com { namespace ubuntu { namespace location { namespace service { struct Credentials { pid_t pid; uid_t uid; }; class PermissionManager { public: typedef std::shared_ptr Ptr; enum class Result { granted, rejected }; virtual ~PermissionManager() = default; PermissionManager(const PermissionManager&) = delete; PermissionManager& operator=(const PermissionManager&) = delete; virtual Result check_permission_for_credentials( const Criteria& criteria, const Credentials& credentials) = 0; protected: PermissionManager() = default; }; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_PERMISSION_MANAGER_H_ ././@LongLink0000000000000000000000000000015300000000000011214 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/configuration.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/configura0000644000015201777760000000344412306337245033611 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_CONFIGURATION_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_CONFIGURATION_H_ #include "com/ubuntu/location/service/permission_manager.h" #include "com/ubuntu/location/engine.h" #include "com/ubuntu/location/provider.h" #include "com/ubuntu/location/provider_selection_policy.h" #include namespace com { namespace ubuntu { namespace location { namespace service { class Configuration { public: virtual ~Configuration() = default; Configuration(const Configuration&) = delete; Configuration& operator=(const Configuration&) = delete; virtual Engine::Ptr the_engine( const std::set& provider_set, const ProviderSelectionPolicy::Ptr& provider_selection_policy) = 0; virtual ProviderSelectionPolicy::Ptr the_provider_selection_policy() = 0; virtual std::set the_provider_set() = 0; virtual PermissionManager::Ptr the_permission_manager() = 0; protected: Configuration() = default; }; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_CONFIGURATION_H_ ././@LongLink0000000000000000000000000000014700000000000011217 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/interface.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/interface0000644000015201777760000000551512306337245033575 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_ #include "com/ubuntu/location/service/session/interface.h" #include #include #include #include #include namespace dbus = core::dbus; namespace com { namespace ubuntu { namespace location { struct Criteria; namespace service { class Interface { protected: struct Errors { struct InsufficientPermissions { inline static std::string name() { return "com.ubuntu.location.Service.Error.InsufficientPermissions"; } }; struct CreatingSession { inline static std::string name() { return "com.ubuntu.location.Service.Error.CreatingSession"; } }; }; struct CreateSessionForCriteria { typedef com::ubuntu::location::service::Interface Interface; inline static const std::string& name() { static const std::string s { "CreateSessionForCriteria" }; return s; } typedef dbus::types::ObjectPath ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; Interface() = default; public: typedef std::shared_ptr Ptr; inline static const std::string& path() { static const std::string s{"/com/ubuntu/location/Service"}; return s; } Interface(const Interface&) = delete; Interface& operator=(const Interface&) = delete; virtual ~Interface() = default; virtual session::Interface::Ptr create_session_for_criteria(const Criteria& criteria) = 0; }; } } } } namespace core { namespace dbus { namespace traits { template<> struct Service { static const std::string& interface_name() { static const std::string s { "com.ubuntu.location.Service" }; return s; } }; } } } #include "com/ubuntu/location/codec.h" #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_ ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/skeleton.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/skeleton.0000644000015201777760000000323512306337245033534 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SKELETON_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SKELETON_H_ #include "com/ubuntu/location/service/interface.h" #include "com/ubuntu/location/service/permission_manager.h" #include "com/ubuntu/location/service/session/interface.h" #include namespace com { namespace ubuntu { namespace location { namespace service { class Skeleton : public core::dbus::Skeleton, public std::enable_shared_from_this { public: typedef std::shared_ptr Ptr; Skeleton(const dbus::Bus::Ptr& connection, const PermissionManager::Ptr& permission_manager); Skeleton(const Skeleton&) = delete; Skeleton& operator=(const Skeleton&) = delete; ~Skeleton() noexcept; private: struct Private; std::shared_ptr d; }; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_SKELETON_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/stub.h0000644000015201777760000000270312306337245033034 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_STUB_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_STUB_H_ #include "com/ubuntu/location/service/interface.h" #include "com/ubuntu/location/service/session/interface.h" #include namespace com { namespace ubuntu { namespace location { namespace service { class Stub : public core::dbus::Stub { public: Stub(const dbus::Bus::Ptr& connection); Stub(const Stub&) = delete; Stub& operator=(const Stub&) = delete; ~Stub() noexcept; session::Interface::Ptr create_session_for_criteria(const Criteria& criteria); private: struct Private; std::unique_ptr d; }; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_STUB_H_ ././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/implementation.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/service/implement0000644000015201777760000000327312306337245033626 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_H_ #include "com/ubuntu/location/engine.h" #include "com/ubuntu/location/service/skeleton.h" #include namespace dbus = core::dbus; namespace com { namespace ubuntu { namespace location { namespace service { class Implementation : public Skeleton { public: typedef std::shared_ptr Ptr; Implementation( const core::dbus::Bus::Ptr& bus, const Engine::Ptr& engine, const PermissionManager::Ptr& permission_manager); Implementation(const Implementation&) = delete; virtual ~Implementation() noexcept; Implementation& operator=(const Implementation&) = delete; virtual session::Interface::Ptr create_session_for_criteria(const Criteria& criteria); private: struct Private; std::unique_ptr d; }; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_IMPLEMENTATION_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/logging.h0000644000015201777760000000162012306337245032042 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_LOGGING_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_LOGGING_H_ #include #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_LOGGING_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/units/0000755000015201777760000000000012306337604031405 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/units/units.h0000644000015201777760000000355512306337245032731 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_UNITS_UNITS_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_UNITS_UNITS_H_ #include #include #include #include #include #include #include namespace com { namespace ubuntu { namespace location { namespace units { typedef boost::units::degree::plane_angle PlaneAngle; static const PlaneAngle Degree; static const PlaneAngle Degrees; typedef boost::units::gradian::plane_angle Gradians; typedef boost::units::si::length Length; static const Length Meter; static const Length Meters; using boost::units::si::kilo; typedef boost::units::si::velocity Velocity; static const Velocity MeterPerSecond; static const Velocity MetersPerSecond; template using Quantity = boost::units::quantity; typedef boost::units::si::dimensionless Dimensionless; using boost::units::sin; using boost::units::cos; using boost::units::atan2; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_UNITS_UNITS_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/engine.h0000644000015201777760000000346112306337245031666 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_ENGINE_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_ENGINE_H_ #include "com/ubuntu/location/criteria.h" #include "com/ubuntu/location/provider.h" #include "com/ubuntu/location/provider_selection_policy.h" #include namespace com { namespace ubuntu { namespace location { class Engine { public: typedef std::shared_ptr Ptr; Engine(const std::set& initial_providers, const ProviderSelectionPolicy::Ptr& provider_selection_policy); Engine(const Engine&) = delete; Engine& operator=(const Engine&) = delete; virtual ~Engine() = default; virtual ProviderSelection determine_provider_selection_for_criteria(const Criteria& criteria); virtual bool has_provider(const Provider::Ptr& provider) noexcept; virtual void add_provider(const Provider::Ptr& provider); virtual void remove_provider(const Provider::Ptr& provider) noexcept; private: std::set providers; ProviderSelectionPolicy::Ptr provider_selection_policy; }; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_ENGINE_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/configuration.h0000644000015201777760000000204212306337245033262 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONFIGURATION_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONFIGURATION_H_ #include namespace com { namespace ubuntu { namespace location { typedef boost::property_tree::ptree Configuration; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONFIGURATION_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/velocity.h0000644000015201777760000000522312306337245032255 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_ #include "com/ubuntu/location/accuracy.h" #include "com/ubuntu/location/units/units.h" #include #include #include namespace com { namespace ubuntu { namespace location { struct Velocity { typedef units::Velocity Unit; typedef units::Quantity Quantity; static inline const Quantity& min() { static const Quantity instance = Quantity::from_value(0.); return instance; } static inline const Quantity max() { static const Quantity instance = Quantity::from_value(std::numeric_limits::max()); return instance; } Velocity(const Quantity& value = Quantity()) : value(value) { if (value < Velocity::min()) throw std::out_of_range(""); if (value > Velocity::max()) throw std::out_of_range(""); } inline bool operator==(const Velocity& rhs) const { return value == rhs.value; } inline bool operator!=(const Velocity& rhs) const { return value != rhs.value; } Quantity value; }; inline std::ostream& operator<<(std::ostream& out, const Velocity& velocity) { out << "Velocity(" << velocity.value << ")"; return out; } template<> struct AccuracyTraits { static AccuracyLevel classify(const Velocity& h) { if (h.value > (1.f * units::MetersPerSecond)) return AccuracyLevel::worst; if (h.value <= (1.f * units::MetersPerSecond)) return AccuracyLevel::best; return AccuracyLevel::worst; } static Accuracy best() { return Accuracy{Velocity{Velocity::min()}}; } static Accuracy worst() { return Accuracy{Velocity{2*units::MetersPerSecond}}; } }; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_VELOCITY_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/clock.h0000644000015201777760000000230412306337245031507 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CLOCK_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CLOCK_H_ #include namespace com { namespace ubuntu { namespace location { struct Clock { typedef std::chrono::high_resolution_clock::duration Duration; typedef std::chrono::high_resolution_clock::time_point Timestamp; static inline Timestamp now() { return std::chrono::high_resolution_clock::now(); } }; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CLOCK_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/wgs84/0000755000015201777760000000000012306337604031217 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/wgs84/altitude.h0000644000015201777760000000243612306337245033211 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_ALTITUDE_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_ALTITUDE_H_ #include "com/ubuntu/location/units/units.h" #include "com/ubuntu/location/wgs84/coordinate.h" namespace com { namespace ubuntu { namespace location { namespace wgs84 { namespace tag { struct Altitude; } typedef Coordinate Altitude; template<> struct CoordinateTraits { static void check_and_throw_if_invalid(const typename Altitude::Quantity&) {} }; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_ALTITUDE_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/wgs84/longitude.h0000644000015201777760000000326712306337245033373 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LONGITUDE_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LONGITUDE_H_ #include "com/ubuntu/location/units/units.h" #include "com/ubuntu/location/wgs84/coordinate.h" #include namespace com { namespace ubuntu { namespace location { namespace wgs84 { namespace tag { struct Longitude; } typedef Coordinate Longitude; template<> struct CoordinateTraits { static double min() { return -180; }; static double max() { return 180; }; static void check_and_throw_if_invalid(const typename Longitude::Quantity& coordinate) { if (coordinate.value() < min()) throw std::out_of_range(u8"Longitude(coordinate.value() < min())"); if (coordinate.value() > max()) throw std::out_of_range(u8"Longitude(coordinate.value() > max())"); } }; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_ ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/wgs84/coordinate.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/wgs84/coordinate.0000644000015201777760000000411512306337245033351 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_COORDINATE_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_COORDINATE_H_ #include "com/ubuntu/location/units/units.h" #include namespace com { namespace ubuntu { namespace location { namespace wgs84 { template struct CoordinateTraits { static void check_and_throw_if_invalid(const typename Coordinate::Quantity& coordinate) { } }; template struct Coordinate { typedef UnitType Unit; typedef units::Quantity Quantity; explicit Coordinate(const Quantity& value = Quantity()) : value(value) { CoordinateTraits>::check_and_throw_if_invalid(value); } bool operator==(const Coordinate& rhs) const { return value == rhs.value; } bool operator!=(const Coordinate& rhs) const { return value != rhs.value; } Quantity value; }; template Coordinate operator-(const Coordinate& lhs, const Coordinate& rhs) { return Coordinate {rhs.value - lhs.value}; } template std::ostream& operator<<(std::ostream& out, const Coordinate& coord) { out << "Coordinate(" << coord.value << ")"; return out; } } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_COORDINATE_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/wgs84/latitude.h0000644000015201777760000000325412306337245033210 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_ #include "com/ubuntu/location/units/units.h" #include "com/ubuntu/location/wgs84/coordinate.h" #include namespace com { namespace ubuntu { namespace location { namespace wgs84 { namespace tag { struct Latitude; } typedef Coordinate Latitude; template<> struct CoordinateTraits { static double min() { return -90; }; static double max() { return 90; }; static void check_and_throw_if_invalid(const typename Latitude::Quantity& coordinate) { if (coordinate.value() < min()) throw std::out_of_range(u8"Latitude(coordinate.value() < min())"); if (coordinate.value() > max()) throw std::out_of_range(u8"Latitude(coordinate.value() > max())"); } }; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_WGS84_LATITUDE_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/channel.h0000644000015201777760000000227612306337245032034 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CHANNEL_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CHANNEL_H_ #include #include #include namespace com { namespace ubuntu { namespace location { template using Channel = boost::signals2::signal; typedef boost::signals2::scoped_connection ScopedChannelConnection; typedef boost::signals2::connection ChannelConnection; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CHANNEL_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/codec.h0000644000015201777760000003232512306337245031477 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_ #include "com/ubuntu/location/accuracy.h" #include "com/ubuntu/location/criteria.h" #include "com/ubuntu/location/heading.h" #include "com/ubuntu/location/position.h" #include "com/ubuntu/location/update.h" #include "com/ubuntu/location/velocity.h" #include "com/ubuntu/location/units/units.h" #include "com/ubuntu/location/wgs84/altitude.h" #include "com/ubuntu/location/wgs84/latitude.h" #include "com/ubuntu/location/wgs84/longitude.h" #include namespace core { namespace dbus { namespace helper { template struct TypeMapper> { constexpr static ArgumentType type_value() { return ArgumentType::floating_point; } constexpr static bool is_basic_type() { return true; } constexpr static bool requires_signature() { return false; } static std::string signature() { static const std::string s = TypeMapper::signature(); return s; } }; } template struct Codec> { static void encode_argument(core::dbus::Message::Writer& out, const com::ubuntu::location::units::Quantity& in) { Codec::value_type>::encode_argument(out, in.value()); } static void decode_argument(core::dbus::Message::Reader& out, com::ubuntu::location::units::Quantity& in) { typename com::ubuntu::location::units::Quantity::value_type value; Codec::value_type>::decode_argument(out, value); in = com::ubuntu::location::units::Quantity::from_value(value); } }; namespace helper { template struct TypeMapper> { constexpr static ArgumentType type_value() { return ArgumentType::structure; } constexpr static bool is_basic_type() { return false; } constexpr static bool requires_signature() { return true; } static std::string signature() { static const std::string s = DBUS_STRUCT_BEGIN_CHAR_AS_STRING + TypeMapper>::signature() + DBUS_STRUCT_END_CHAR_AS_STRING; return s; } }; } template struct Codec> { static void encode_argument(core::dbus::Message::Writer& out, const com::ubuntu::location::wgs84::Coordinate& in) { Codec>::encode_argument(out, in.value); } static void decode_argument(core::dbus::Message::Reader& out, com::ubuntu::location::wgs84::Coordinate& in) { Codec>::decode_argument(out, in.value); } }; namespace helper { template<> struct TypeMapper { constexpr static ArgumentType type_value() { return ArgumentType::structure; } constexpr static bool is_basic_type() { return false; } constexpr static bool requires_signature() { return true; } static std::string signature() { static const std::string s = TypeMapper::signature() + TypeMapper::signature() + TypeMapper::signature() + TypeMapper::signature(); return s; } }; } template<> struct Codec { static void encode_argument(core::dbus::Message::Writer& out, const com::ubuntu::location::Position& in) { Codec::encode_argument(out, in.flags().to_ulong()); if (in.has_latitude()) Codec::encode_argument(out, in.latitude()); if (in.has_longitude()) Codec::encode_argument(out, in.longitude()); if (in.has_altitude()) Codec::encode_argument(out, in.altitude()); } static void decode_argument(core::dbus::Message::Reader& out, com::ubuntu::location::Position& in) { com::ubuntu::location::wgs84::Latitude lat; com::ubuntu::location::wgs84::Longitude lon; com::ubuntu::location::wgs84::Altitude alt; uint64_t flags_on_wire; Codec::decode_argument(out, flags_on_wire); com::ubuntu::location::Position::Flags flags{flags_on_wire}; if (flags.test(com::ubuntu::location::Position::latitude_flag)) { Codec::decode_argument(out, lat); in.latitude(lat); } if (flags.test(com::ubuntu::location::Position::latitude_flag)) { Codec::decode_argument(out, lon); in.longitude(lon); } if (flags.test(com::ubuntu::location::Position::altitude_flag)) { Codec::decode_argument(out, alt); in.altitude(alt); } } }; namespace helper { template<> struct TypeMapper { constexpr static ArgumentType type_value() { return ArgumentType::structure; } constexpr static bool is_basic_type() { return false; } constexpr static bool requires_signature() { return true; } static std::string signature() { static const std::string s = DBUS_STRUCT_BEGIN_CHAR_AS_STRING + TypeMapper::signature() + DBUS_STRUCT_END_CHAR_AS_STRING; return s; } }; } template<> struct Codec { static void encode_argument(core::dbus::Message::Writer& out, const com::ubuntu::location::Velocity& in) { Codec::encode_argument(out, in.value); } static void decode_argument(core::dbus::Message::Reader& out, com::ubuntu::location::Velocity& in) { Codec::decode_argument(out, in.value); } }; namespace helper { template<> struct TypeMapper { constexpr static ArgumentType type_value() { return ArgumentType::structure; } constexpr static bool is_basic_type() { return false; } constexpr static bool requires_signature() { return true; } static std::string signature() { static const std::string s = DBUS_STRUCT_BEGIN_CHAR_AS_STRING + TypeMapper::signature() + DBUS_STRUCT_END_CHAR_AS_STRING; return s; } }; } template<> struct Codec { static void encode_argument(core::dbus::Message::Writer& out, const com::ubuntu::location::Heading& in) { Codec::encode_argument(out, in.value); } static void decode_argument(core::dbus::Message::Reader& out, com::ubuntu::location::Heading& in) { Codec::decode_argument(out, in.value); } }; namespace helper { template struct TypeMapper> { constexpr static ArgumentType type_value() { return ArgumentType::structure; } constexpr static bool is_basic_type() { return false; } constexpr static bool requires_signature() { return true; } static std::string signature() { static const std::string s = DBUS_STRUCT_BEGIN_CHAR_AS_STRING + TypeMapper::signature() + DBUS_STRUCT_END_CHAR_AS_STRING; return s; } }; } template struct Codec> { static void encode_argument(core::dbus::Message::Writer& out, const com::ubuntu::location::Accuracy& in) { Codec::encode_argument(out, in.value); } static void decode_argument(core::dbus::Message::Reader& out, com::ubuntu::location::Accuracy& in) { Codec::decode_argument(out, in.value); } }; namespace helper { template<> struct TypeMapper { constexpr static ArgumentType type_value() { return ArgumentType::structure; } constexpr static bool is_basic_type() { return false; } constexpr static bool requires_signature() { return true; } static std::string signature() { static const std::string s = DBUS_STRUCT_BEGIN_CHAR_AS_STRING + helper::TypeMapper>::signature() + helper::TypeMapper>::signature() + helper::TypeMapper>::signature() + helper::TypeMapper>::signature() + helper::TypeMapper>::signature() + DBUS_STRUCT_END_CHAR_AS_STRING; return s; } }; } template<> struct Codec { static void encode_argument(core::dbus::Message::Writer& out, const com::ubuntu::location::Criteria& in) { Codec>::encode_argument(out, in.latitude_accuracy); Codec>::encode_argument(out, in.longitude_accuracy); Codec>::encode_argument(out, in.altitude_accuracy); Codec>::encode_argument(out, in.velocity_accuracy); Codec>::encode_argument(out, in.heading_accuracy); } static void decode_argument(core::dbus::Message::Reader& out, com::ubuntu::location::Criteria& in) { Codec>::decode_argument(out, in.latitude_accuracy); Codec>::decode_argument(out, in.longitude_accuracy); Codec>::decode_argument(out, in.altitude_accuracy); Codec>::decode_argument(out, in.velocity_accuracy); Codec>::decode_argument(out, in.heading_accuracy); } }; namespace helper { template struct TypeMapper> { constexpr static ArgumentType type_value() { return ArgumentType::structure; } constexpr static bool is_basic_type() { return false; } constexpr static bool requires_signature() { return true; } static std::string signature() { static const std::string s = helper::TypeMapper::signature() + helper::TypeMapper::signature(); return s; } }; } template struct Codec> { static void encode_argument(core::dbus::Message::Writer& out, const com::ubuntu::location::Update& in) { Codec::encode_argument(out, in.value); Codec::encode_argument(out, in.when.time_since_epoch().count()); } static void decode_argument(core::dbus::Message::Reader& out, com::ubuntu::location::Update& in) { Codec::decode_argument(out, in.value); int64_t value; Codec::decode_argument(out, value); in.when = com::ubuntu::location::Clock::Timestamp(com::ubuntu::location::Clock::Duration(value)); } }; } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CODEC_H_ ././@LongLink0000000000000000000000000000014700000000000011217 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/init_and_shutdown.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/init_and_shutdown0000644000015201777760000000216412306337245033712 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_INIT_AND_SHUTDOWN_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_INIT_AND_SHUTDOWN_H_ namespace com { namespace ubuntu { namespace location { /** \brief Initializes the library. */ void init(int* argc, char*** argv); /** \brief Shuts down the library and frees all acquired resources. */ void shutdown(); } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_INIT_AND_SHUTDOWN_H_location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/accuracy.h0000644000015201777760000000342612306337245032214 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_ACCURACY_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_ACCURACY_H_ #include namespace com { namespace ubuntu { namespace location { enum class AccuracyLevel { country, region, locality, postalcode, street, detailed, best = detailed, worst = country }; template struct AccuracyTraits { static AccuracyLevel classify(const T& instance); static T best(); static T worst(); }; template struct Accuracy { typedef typename T::Unit Unit; typedef typename T::Quantity Quantity; static Accuracy best() { return AccuracyTraits::best(); } static Accuracy worst() { return AccuracyTraits::worst(); } AccuracyLevel classify() const { return AccuracyTraits::classify(value); } T value; }; template inline std::ostream& operator<<(std::ostream& out, const Accuracy& update) { out << "Accuracy(" << update.value << ")"; return out; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_ACCURACY_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/provider.h0000644000015201777760000001264012306337245032252 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_H_ #include "com/ubuntu/location/channel.h" #include "com/ubuntu/location/criteria.h" #include "com/ubuntu/location/heading.h" #include "com/ubuntu/location/position.h" #include "com/ubuntu/location/update.h" #include "com/ubuntu/location/velocity.h" #include #include #include namespace com { namespace ubuntu { namespace location { class Provider { public: typedef std::shared_ptr Ptr; enum class Feature : std::size_t { position, velocity, heading }; typedef std::bitset<3> FeatureFlags; enum class Requirement : std::size_t { satellites, cell_network, data_network, monetary_spending }; typedef std::bitset<4> RequirementFlags; class Controller { public: typedef std::shared_ptr Ptr; template class Cache { public: Cache() : d{ T{}, false } { } const T& value() const { return d.value; } void update(const T& new_value) { d.value = new_value; d.is_valid = true; } bool is_valid() const { return d.is_valid; } void invalidate() { d.is_valid = false; } private: struct { T value; bool is_valid; } d; }; virtual ~Controller() = default; Controller(const Controller&) = delete; Controller& operator=(const Controller&) = delete; virtual void start_position_updates(); virtual void stop_position_updates(); bool are_position_updates_running() const; virtual void start_heading_updates(); virtual void stop_heading_updates(); bool are_heading_updates_running() const; virtual void start_velocity_updates(); virtual void stop_velocity_updates(); bool are_velocity_updates_running() const; const Cache>& cached_position_update() const; const Cache>& cached_heading_update() const; const Cache>& cached_velocity_update() const; protected: friend class Provider; explicit Controller(Provider& instance); private: void on_position_updated(const Update& position); void on_velocity_updated(const Update& velocity); void on_heading_updated(const Update& heading); Provider& instance; std::atomic position_updates_counter; std::atomic heading_updates_counter; std::atomic velocity_updates_counter; ScopedChannelConnection position_update_connection; ScopedChannelConnection velocity_update_connection; ScopedChannelConnection heading_update_connection; struct { Cache> position; Cache> velocity; Cache> heading; } cached; }; virtual ~Provider() = default; Provider(const Provider&) = delete; Provider& operator=(const Provider&) = delete; virtual const Controller::Ptr& state_controller() const; virtual ChannelConnection subscribe_to_position_updates(std::function&)> f); virtual ChannelConnection subscribe_to_heading_updates(std::function&)> f); virtual ChannelConnection subscribe_to_velocity_updates(std::function&)> f); virtual bool supports(const Feature& f) const; virtual bool requires(const Requirement& r) const; virtual bool matches_criteria(const Criteria&); protected: explicit Provider( const FeatureFlags& feature_flags = FeatureFlags(), const RequirementFlags& requirement_flags = RequirementFlags()); void deliver_position_updates(const Update& update); void deliver_heading_updates(const Update& update); void deliver_velocity_updates(const Update& update); virtual void start_position_updates(); virtual void stop_position_updates(); virtual void start_heading_updates(); virtual void stop_heading_updates(); virtual void start_velocity_updates(); virtual void stop_velocity_updates(); private: FeatureFlags feature_flags; RequirementFlags requirement_flags; Channel> position_updates_channel; Channel> heading_updates_channel; Channel> velocity_updates_channel; Controller::Ptr controller; }; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDER_H_ ././@LongLink0000000000000000000000000000015700000000000011220 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/provider_selection_policy.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/provider_selectio0000644000015201777760000000564712306337245033724 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_POLICY_H_ #define LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_POLICY_H_ #include "com/ubuntu/location/provider.h" #include namespace com { namespace ubuntu { namespace location { struct Criteria; struct ProviderSelection { ProviderSelection(const Provider::Ptr position = Provider::Ptr{}, const Provider::Ptr heading = Provider::Ptr{}, const Provider::Ptr velocity = Provider::Ptr{}) : position_updates_provider(position), heading_updates_provider(heading), velocity_updates_provider(velocity) { } Provider::FeatureFlags to_feature_flags() const { Provider::FeatureFlags flags; flags.set(static_cast(Provider::Feature::position), static_cast(position_updates_provider)); flags.set(static_cast(Provider::Feature::heading), static_cast(heading_updates_provider)); flags.set(static_cast(Provider::Feature::velocity), static_cast(velocity_updates_provider)); return flags; } Provider::Ptr position_updates_provider; Provider::Ptr heading_updates_provider; Provider::Ptr velocity_updates_provider; }; inline bool operator==(const ProviderSelection& lhs, const ProviderSelection& rhs) { return lhs.position_updates_provider == rhs.position_updates_provider && lhs.heading_updates_provider == rhs.heading_updates_provider && lhs.velocity_updates_provider == rhs.velocity_updates_provider; } class ProviderSelectionPolicy { public: typedef std::shared_ptr Ptr; virtual ~ProviderSelectionPolicy() = default; virtual ProviderSelection determine_provider_selection_from_set_for_criteria(const Criteria& criteria, const std::set& providers) = 0; protected: ProviderSelectionPolicy() = default; private: ProviderSelectionPolicy(const ProviderSelectionPolicy&) = delete; ProviderSelectionPolicy& operator=(const ProviderSelectionPolicy&) = delete; }; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_PROVIDER_SELECTION_POLICY_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/heading.h0000644000015201777760000000505312306337245032017 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_ #include "com/ubuntu/location/accuracy.h" #include "com/ubuntu/location/units/units.h" #include #include #include namespace com { namespace ubuntu { namespace location { struct Heading { typedef units::PlaneAngle Unit; typedef units::Quantity Quantity; static const Quantity& min() { static const auto instance = Heading::Quantity::from_value(0.); return instance; } static const Quantity& max() { static const auto instance = Heading::Quantity::from_value(360.); return instance; } Heading(const Quantity& value = Quantity()) : value(value) { if (value < min()) throw std::out_of_range(""); if (value > max()) throw std::out_of_range(""); } bool operator==(const Heading& rhs) const { return value == rhs.value; } bool operator!=(const Heading& rhs) const { return value != rhs.value; } Quantity value; }; inline std::ostream& operator<<(std::ostream& out, const Heading& heading) { out << "Heading(" << heading.value << ")"; return out; } template<> struct AccuracyTraits { static AccuracyLevel classify(const Heading& h) { static const auto half = 0.5 * Heading::max(); if(h.value > half) return AccuracyLevel::worst; if(h.value < half) return AccuracyLevel::best; return AccuracyLevel::worst; } static Accuracy best() { return Accuracy{Heading{Heading::min()}}; } static Accuracy worst() { return Accuracy{Heading{Heading::max()}}; } }; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_HEADING_H_ ././@LongLink0000000000000000000000000000016700000000000011221 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/default_provider_selection_policy.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/default_provider_0000644000015201777760000000342512306337245033670 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_DEFAULT_PROVIDER_SELECTION_POLICY_H_ #define LOCATION_SERVICE_COM_UBUNTU_DEFAULT_PROVIDER_SELECTION_POLICY_H_ #include "com/ubuntu/location/provider_selection_policy.h" namespace com { namespace ubuntu { namespace location { class DefaultProviderSelectionPolicy : public ProviderSelectionPolicy { public: DefaultProviderSelectionPolicy(); ~DefaultProviderSelectionPolicy() noexcept; ProviderSelection determine_provider_selection_from_set_for_criteria( const Criteria& criteria, const std::set& providers); Provider::Ptr determine_position_updates_provider( const Criteria& criteria, const std::set& providers); Provider::Ptr determine_heading_updates_provider( const Criteria& criteria, const std::set& providers); Provider::Ptr determine_velocity_updates_provider( const Criteria& criteria, const std::set& providers); }; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_DEFAULT_PROVIDER_SELECTION_POLICY_H_ location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/0000755000015201777760000000000012306337604032260 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/gps/0000755000015201777760000000000012306337604033051 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/gps/provider.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/gps/pro0000644000015201777760000000365712306337245033610 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GPS_PROVIDER_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GPS_PROVIDER_H_ #include "com/ubuntu/location/provider.h" #include "com/ubuntu/location/provider_factory.h" namespace com { namespace ubuntu { namespace location { namespace providers { namespace gps { class Provider : public com::ubuntu::location::Provider { public: static std::string class_name(); static Provider::Ptr create_instance(const ProviderFactory::Configuration&); static const Provider::FeatureFlags& default_feature_flags(); static const Provider::RequirementFlags& default_requirement_flags(); Provider(); Provider(const Provider&) = delete; Provider& operator=(const Provider&) = delete; ~Provider() noexcept; virtual bool matches_criteria(const Criteria&); virtual void start_position_updates(); virtual void stop_position_updates(); virtual void start_velocity_updates(); virtual void stop_velocity_updates(); virtual void start_heading_updates(); virtual void stop_heading_updates(); private: struct Private; std::unique_ptr d; }; } } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GPS_PROVIDER_H_ ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/geoclue/location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/geoclue0000755000015201777760000000000012306337604033624 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015700000000000011220 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/geoclue/geoclue.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/geoclue0000644000015201777760000001573012306337245033635 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_ #include "core/dbus/service.h" #include "core/dbus/traits/service.h" #include "core/dbus/types/struct.h" #include "core/dbus/types/stl/tuple.h" #include namespace dbus = core::dbus; namespace org { namespace freedesktop { struct Geoclue { enum class Status : int { error, unavailable, acquiring, available }; friend std::ostream& operator<<(std::ostream& out, const Status& status) { static std::map lut = { {Status::error, "error"}, {Status::unavailable, "unavailable"}, {Status::acquiring, "acquiring"}, {Status::available, "available"} }; return out << lut[status]; } struct GetProviderInfo { inline static std::string name() { return "GetProviderInfo"; } typedef Geoclue Interface; typedef std::tuple ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct GetStatus { inline static std::string name() { return "GetStatus"; } typedef Geoclue Interface; typedef int32_t ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct AddReference { inline static std::string name() { return "AddReference"; } typedef Geoclue Interface; typedef void ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct RemoveReference { inline static std::string name() { return "RemoveReference"; } typedef Geoclue Interface; typedef void ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct Address { struct GetAddress { inline static std::string name() { return "GetAddress"; } typedef Address Interface; typedef std::tuple, dbus::types::Struct>> ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct Signals { struct AddressChanged { inline static std::string name() { return "PositionChanged"; }; typedef Address Interface; typedef std::tuple, dbus::types::Struct>> ArgumentType; }; }; }; struct Position { struct Field { Field() = delete; static const int none = 0; static const int latitude = 1; static const int longitude = 2; static const int altitude = 3; }; typedef std::bitset<4> FieldFlags; struct GetPosition { inline static std::string name() { return "GetPosition"; } typedef Position Interface; typedef std::tuple>> ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct Signals { struct PositionChanged { inline static std::string name() { return "PositionChanged"; }; typedef Position Interface; typedef std::tuple>> ArgumentType; }; }; }; struct Velocity { struct Field { Field() = delete; static const int none = 0; static const int speed = 1; static const int direction = 2; static const int climb = 3; }; typedef std::bitset<4> FieldFlags; struct GetVelocity { inline static std::string name() { return "GetVelocity"; } typedef Velocity Interface; typedef std::tuple ResultType; inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct Signals { struct VelocityChanged { inline static std::string name() { return "VelocityChanged"; }; typedef Velocity Interface; typedef std::tuple ArgumentType; }; }; }; }; } } namespace core { namespace dbus { namespace traits { template<> struct Service { inline static const std::string& interface_name() { static const std::string s{"org.freedesktop.Geoclue"}; return s; } }; template<> struct Service { inline static const std::string& interface_name() { static const std::string s{"org.freedesktop.Geoclue.Address"}; return s; } }; template<> struct Service { inline static const std::string& interface_name() { static const std::string s{"org.freedesktop.Geoclue.Position"}; return s; } }; template<> struct Service { inline static const std::string& interface_name() { static const std::string s{"org.freedesktop.Geoclue.Velocity"}; return s; } }; } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_GEOCLUE_H_ ././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/geoclue/provider.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/geoclue0000644000015201777760000000417612306337245033637 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_PROVIDER_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_PROVIDER_H_ #include "com/ubuntu/location/provider.h" #include "com/ubuntu/location/provider_factory.h" namespace com { namespace ubuntu { namespace location { namespace providers { namespace geoclue { class Provider : public com::ubuntu::location::Provider { public: static Provider::Ptr create_instance(const ProviderFactory::Configuration&); static const Provider::FeatureFlags& default_feature_flags(); static const Provider::RequirementFlags& default_requirement_flags(); struct Configuration { static std::string key_name() { return "name"; } static std::string key_path() { return "path"; } std::string name; std::string path; Provider::FeatureFlags features; Provider::RequirementFlags requirements; }; Provider(const Configuration& config); ~Provider() noexcept; virtual bool matches_criteria(const Criteria&); virtual void start_position_updates(); virtual void stop_position_updates(); virtual void start_velocity_updates(); virtual void stop_velocity_updates(); virtual void start_heading_updates(); virtual void stop_heading_updates(); private: struct Private; std::unique_ptr d; }; } } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_GEOCLUE_PROVIDER_H_ ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/skyhook/location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/skyhook0000755000015201777760000000000012306337604033670 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000location-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/skyhook/provider.hlocation-service-0.0.2+14.04.20140307/include/location_service/com/ubuntu/location/providers/skyhook0000644000015201777760000000442412306337245033677 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_SKYHOOK_PROVIDER_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_SKYHOOK_PROVIDER_H_ #include "com/ubuntu/location/provider.h" #include "com/ubuntu/location/provider_factory.h" #include namespace com { namespace ubuntu { namespace location { namespace providers { namespace skyhook { class Provider : public com::ubuntu::location::Provider { public: static Provider::Ptr create_instance(const ProviderFactory::Configuration& config); static const Provider::FeatureFlags& default_feature_flags(); static const Provider::RequirementFlags& default_requirement_flags(); struct Configuration { static std::string key_username() { return "username"; } static std::string key_realm() { return "realm"; } static std::string key_period() { return "period"; } std::string user_name; std::string realm; std::chrono::milliseconds period; }; Provider(const Configuration& config); Provider(const Provider&) = delete; Provider& operator=(const Provider&) = delete; ~Provider() noexcept; virtual bool matches_criteria(const Criteria&); virtual void start_position_updates(); virtual void stop_position_updates(); virtual void start_velocity_updates(); virtual void stop_velocity_updates(); virtual void start_heading_updates(); virtual void stop_heading_updates(); private: struct Private; std::unique_ptr d; }; } } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_SKYHOOK_PROVIDER_H_ location-service-0.0.2+14.04.20140307/include/CMakeLists.txt0000644000015201777760000000020012306337245023534 0ustar pbusernogroup00000000000000install( DIRECTORY location_service/com DESTINATION include/ubuntu-location-service-${UBUNTU_LOCATION_SERVICE_VERSION_MAJOR} )location-service-0.0.2+14.04.20140307/cmake/0000755000015201777760000000000012306337604020440 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/cmake/Findgcovr.cmake0000644000015201777760000000170212306337245023364 0ustar pbusernogroup00000000000000# - Find gcovr scrip # Will define: # # GCOVR_EXECUTABLE - the gcovr script # # Uses: # # GCOVR_ROOT - root to search for the script # # Copyright (C) 2011 by Johannes Wienke # # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General # Public License as published by the Free Software Foundation; # either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # INCLUDE(FindPackageHandleStandardArgs) FIND_PROGRAM(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin") FIND_PACKAGE_HANDLE_STANDARD_ARGS(gcovr DEFAULT_MSG GCOVR_EXECUTABLE) # only visible in advanced view MARK_AS_ADVANCED(GCOVR_EXECUTABLE) location-service-0.0.2+14.04.20140307/cmake/ParseArguments.cmake0000644000015201777760000000340612306337245024406 0ustar pbusernogroup00000000000000# Parse arguments passed to a function into several lists separated by # upper-case identifiers and options that do not have an associated list e.g.: # # SET(arguments # hello OPTION3 world # LIST3 foo bar # OPTION2 # LIST1 fuz baz # ) # PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments}) # # results in 7 distinct variables: # * ARG_DEFAULT_ARGS: hello;world # * ARG_LIST1: fuz;baz # * ARG_LIST2: # * ARG_LIST3: foo;bar # * ARG_OPTION1: FALSE # * ARG_OPTION2: TRUE # * ARG_OPTION3: TRUE # # taken from http://www.cmake.org/Wiki/CMakeMacroParseArguments MACRO(PARSE_ARGUMENTS prefix arg_names option_names) SET(DEFAULT_ARGS) FOREACH(arg_name ${arg_names}) SET(${prefix}_${arg_name}) ENDFOREACH(arg_name) FOREACH(option ${option_names}) SET(${prefix}_${option} FALSE) ENDFOREACH(option) SET(current_arg_name DEFAULT_ARGS) SET(current_arg_list) FOREACH(arg ${ARGN}) SET(larg_names ${arg_names}) LIST(FIND larg_names "${arg}" is_arg_name) IF (is_arg_name GREATER -1) SET(${prefix}_${current_arg_name} ${current_arg_list}) SET(current_arg_name ${arg}) SET(current_arg_list) ELSE (is_arg_name GREATER -1) SET(loption_names ${option_names}) LIST(FIND loption_names "${arg}" is_option) IF (is_option GREATER -1) SET(${prefix}_${arg} TRUE) ELSE (is_option GREATER -1) SET(current_arg_list ${current_arg_list} ${arg}) ENDIF (is_option GREATER -1) ENDIF (is_arg_name GREATER -1) ENDFOREACH(arg) SET(${prefix}_${current_arg_name} ${current_arg_list}) ENDMACRO(PARSE_ARGUMENTS) location-service-0.0.2+14.04.20140307/cmake/FindLcov.cmake0000644000015201777760000000172012306337245023147 0ustar pbusernogroup00000000000000# - Find lcov # Will define: # # LCOV_EXECUTABLE - the lcov binary # GENHTML_EXECUTABLE - the genhtml executable # # Copyright (C) 2010 by Johannes Wienke # # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General # Public License as published by the Free Software Foundation; # either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # INCLUDE(FindPackageHandleStandardArgs) FIND_PROGRAM(LCOV_EXECUTABLE lcov) FIND_PROGRAM(GENHTML_EXECUTABLE genhtml) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lcov DEFAULT_MSG LCOV_EXECUTABLE GENHTML_EXECUTABLE) # only visible in advanced view MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE) location-service-0.0.2+14.04.20140307/cmake/FindGLog.cmake0000644000015201777760000000061412306337245023075 0ustar pbusernogroup00000000000000if (GLog_INCLUDE_DIR) # Already in cache, be silent set(GLog_FIND_QUIETLY TRUE) endif () find_path(GLog_INCLUDE_DIR glog/logging.h) find_library(GLog_LIBRARY libglog.so HINTS /usr/lib/arm-linux-gnueabihf/) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GLog DEFAULT_MSG GLog_LIBRARY GLog_INCLUDE_DIR) mark_as_advanced(GLog_LIBRARY GLog_INCLUDE_DIR) location-service-0.0.2+14.04.20140307/cmake/PrePush.cmake0000644000015201777760000000677512306337245023050 0ustar pbusernogroup00000000000000####################################################################### # A convenience target that carries out the following steps: # - Apply astyle to all source files of interest. # - Build & test in a chroot, comparable setup to CI/Autolanding # and ppa builders. Will fail if new files have not been added. # - Build & test for android. # # NOTE: This target is very sensitive to the availability of all # all required dependencies. For that, we prefer to fail the # target if deps are missing to make the problem very visible. # # TODO: # - Wire up the style-check target once we have reached a state # where trunk actually passes the style check. ####################################################################### add_custom_target( pre-push WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) ####################################################################### # Add target for running astyle with the correct options # ####################################################################### find_program(ASTYLE_EXECUTABLE astyle) if (ASTYLE_EXECUTABLE) add_custom_target( astyle ${ASTYLE_EXECUTABLE} --style=allman -s4 --indent=spaces=4 --pad-header --align-pointer=type --recursive ${CMAKE_SOURCE_DIR}/include/*.h COMMAND ${ASTYLE_EXECUTABLE} --recursive --style=allman -s4 --indent=spaces=4 --pad-header --align-pointer=type ${CMAKE_SOURCE_DIR}/tests/*.cpp VERBATIM ) endif (ASTYLE_EXECUTABLE) ####################################################################### # Add target for creating a source tarball with bzr export # ####################################################################### add_custom_target( pre-push-source-tarball COMMAND rm -rf pre-push-build-area COMMAND mkdir pre-push-build-area COMMAND bzr export --root pre-push pre-push-build-area/${PROJECT_NAME}_${DBUS_CPP_VERSION_MAJOR}.${DBUS_CPP_VERSION_MAJOR}.${DBUS_CPP_VERSION_MAJOR}.orig.tar.bz2 ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Preparing source tarball for pre-push build & test" ) ####################################################################### # Add target for extracting source tarball for pdebuild # ####################################################################### add_custom_target( extract-pre-push-tarball COMMAND tar -xf {PROJECT_NAME}_${DBUS_CPP_VERSION_MAJOR}.${DBUS_CPP_VERSION_MAJOR}.${DBUS_CPP_VERSION_MAJOR}.orig.tar.bz2 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/pre-push-build-area VERBATIM ) ####################################################################### # Builds & tests the last committed revision of the current branch # ####################################################################### find_program(PDEBUILD_EXECUTABLE pdebuild) if(NOT PDEBUILD_EXECUTABLE) message(STATUS "pdebuild NOT found, pre-push is going to FAIL") endif() add_custom_target( pdebuild COMMAND ${PDEBUILD_EXECUTABLE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/pre-push-build-area/pre-push COMMENT "Building & testing in chroot'd environment" VERBATIM ) ####################################################################### # pdebuild: make tarball -> extract to build area -> pdebuild # # android-build: invoke cross-compile script # ####################################################################### add_dependencies(extract-pre-push-tarball pre-push-source-tarball) add_dependencies(pdebuild extract-pre-push-tarball) add_dependencies(pre-push pdebuild android-build) location-service-0.0.2+14.04.20140307/cmake/FindGFlags.cmake0000644000015201777760000000064112306337245023410 0ustar pbusernogroup00000000000000if (GFlags_INCLUDE_DIR) # Already in cache, be silent set(GFlags_FIND_QUIETLY TRUE) endif () find_path(GFlags_INCLUDE_DIR gflags/gflags.h) find_library(GFlags_LIBRARY libgflags.so HINTS /usr/lib/arm-linux-gnueabihf/) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GFlags DEFAULT_MSG GFlags_LIBRARY GFlags_INCLUDE_DIR) mark_as_advanced(GFlags_LIBRARY GFlags_INCLUDE_DIR) location-service-0.0.2+14.04.20140307/cmake/EnableCoverageReport.cmake0000644000015201777760000001537512306337245025514 0ustar pbusernogroup00000000000000# - Creates a special coverage build type and target on GCC. # # Defines a function ENABLE_COVERAGE_REPORT which generates the coverage target # for selected targets. Optional arguments to this function are used to filter # unwanted results using globbing expressions. Moreover targets with tests for # the source code can be specified to trigger regenerating the report if the # test has changed # # ENABLE_COVERAGE_REPORT(TARGETS target... [FILTER filter...] [TESTS test targets...]) # # To generate a coverage report first build the project with # CMAKE_BUILD_TYPE=coverage, then call make test and afterwards make coverage. # # The coverage report is based on gcov. Depending on the availability of lcov # a HTML report will be generated and/or an XML report of gcovr is found. # The generated coverage target executes all found solutions. Special targets # exist to create e.g. only the xml report: coverage-xml. # # Copyright (C) 2010 by Johannes Wienke # # This program is free software; you can redistribute it # and/or modify it under the terms of the GNU General # Public License as published by the Free Software Foundation; # either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # INCLUDE(ParseArguments) FIND_PACKAGE(Lcov) FIND_PACKAGE(gcovr) FUNCTION(ENABLE_COVERAGE_REPORT) # argument parsing PARSE_ARGUMENTS(ARG "FILTER;TARGETS;TESTS" "" ${ARGN}) SET(COVERAGE_RAW_FILE "${CMAKE_BINARY_DIR}/coverage.raw.info") SET(COVERAGE_FILTERED_FILE "${CMAKE_BINARY_DIR}/coverage.info") SET(COVERAGE_REPORT_DIR "${CMAKE_BINARY_DIR}/coveragereport") SET(COVERAGE_XML_FILE "${CMAKE_BINARY_DIR}/coverage.xml") SET(COVERAGE_XML_COMMAND_FILE "${CMAKE_BINARY_DIR}/coverage-xml.cmake") # decide if there is any tool to create coverage data SET(TOOL_FOUND FALSE) IF(LCOV_FOUND OR GCOVR_FOUND) SET(TOOL_FOUND TRUE) ENDIF() IF(NOT TOOL_FOUND) MESSAGE(STATUS "Cannot enable coverage targets because neither lcov nor gcovr are found.") ENDIF() STRING(TOLOWER "${CMAKE_BUILD_TYPE}" COVERAGE_BUILD_TYPE) IF(CMAKE_COMPILER_IS_GNUCXX AND TOOL_FOUND AND "${COVERAGE_BUILD_TYPE}" MATCHES "coverage") MESSAGE(STATUS "Coverage support enabled for targets: ${ARG_TARGETS}") # create coverage build type SET(CMAKE_CXX_FLAGS_COVERAGE ${CMAKE_CXX_FLAGS_DEBUG} PARENT_SCOPE) SET(CMAKE_C_FLAGS_COVERAGE ${CMAKE_C_FLAGS_DEBUG} PARENT_SCOPE) SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} coverage PARENT_SCOPE) # instrument targets SET_TARGET_PROPERTIES(${ARG_TARGETS} PROPERTIES COMPILE_FLAGS --coverage LINK_FLAGS --coverage) # html report IF (LCOV_FOUND) MESSAGE(STATUS "Enabling HTML coverage report") # set up coverage target ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_RAW_FILE} COMMAND ${LCOV_EXECUTABLE} -c -d ${CMAKE_BINARY_DIR} -o ${COVERAGE_RAW_FILE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMENT "Collecting coverage data" DEPENDS ${ARG_TARGETS} ${ARG_TESTS} VERBATIM) # filter unwanted stuff LIST(LENGTH ARG_FILTER FILTER_LENGTH) IF(${FILTER_LENGTH} GREATER 0) SET(FILTER COMMAND ${LCOV_EXECUTABLE}) FOREACH(F ${ARG_FILTER}) SET(FILTER ${FILTER} -r ${COVERAGE_FILTERED_FILE} ${F}) ENDFOREACH() SET(FILTER ${FILTER} -o ${COVERAGE_FILTERED_FILE}) ELSE() SET(FILTER "") ENDIF() ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_FILTERED_FILE} COMMAND ${LCOV_EXECUTABLE} -e ${COVERAGE_RAW_FILE} "${CMAKE_SOURCE_DIR}*" -o ${COVERAGE_FILTERED_FILE} ${FILTER} DEPENDS ${COVERAGE_RAW_FILE} COMMENT "Filtering recorded coverage data for project-relevant entries" VERBATIM) ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_REPORT_DIR} COMMAND ${CMAKE_COMMAND} -E make_directory ${COVERAGE_REPORT_DIR} COMMAND ${GENHTML_EXECUTABLE} --legend --show-details -t "${PROJECT_NAME} test coverage" -o ${COVERAGE_REPORT_DIR} ${COVERAGE_FILTERED_FILE} DEPENDS ${COVERAGE_FILTERED_FILE} COMMENT "Generating HTML coverage report in ${COVERAGE_REPORT_DIR}" VERBATIM) ADD_CUSTOM_TARGET(coverage-html DEPENDS ${COVERAGE_REPORT_DIR}) ENDIF() # xml coverage report IF(GCOVR_FOUND) MESSAGE(STATUS "Enabling XML coverage report") # gcovr cannot write directly to a file so the execution needs to # be wrapped in a cmake file that generates the file output FILE(WRITE ${COVERAGE_XML_COMMAND_FILE} "SET(ENV{LANG} en)\n") FILE(APPEND ${COVERAGE_XML_COMMAND_FILE} "EXECUTE_PROCESS(COMMAND \"${GCOVR_EXECUTABLE}\" --exclude=tests.* --exclude=obj-.* --exclude=cmake.* -x -r \"${CMAKE_SOURCE_DIR}\" OUTPUT_FILE \"${COVERAGE_XML_FILE}\" WORKING_DIRECTORY \"${CMAKE_BINARY_DIR}\")\n") ADD_CUSTOM_COMMAND(OUTPUT ${COVERAGE_XML_FILE} COMMAND ${CMAKE_COMMAND} ARGS -P ${COVERAGE_XML_COMMAND_FILE} COMMENT "Generating coverage XML report" VERBATIM) ADD_CUSTOM_TARGET(coverage-xml DEPENDS ${COVERAGE_XML_FILE}) ENDIF() # provide a global coverage target executing both steps if available SET(GLOBAL_DEPENDS "") IF(LCOV_FOUND) LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_REPORT_DIR}) ENDIF() IF(GCOVR_FOUND) LIST(APPEND GLOBAL_DEPENDS ${COVERAGE_XML_FILE}) ENDIF() IF(LCOV_FOUND OR GCOVR_FOUND) ADD_CUSTOM_TARGET(coverage DEPENDS ${GLOBAL_DEPENDS}) ENDIF() ENDIF() ENDFUNCTION() location-service-0.0.2+14.04.20140307/tests/0000755000015201777760000000000012306337604020522 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/tests/default_permission_manager_test.cpp0000644000015201777760000000302012306337245027647 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/service/default_permission_manager.h" #include TEST(DefaultPermissionManager, for_now_only_local_sessions_are_accepted) { //com::ubuntu::location::Credentials invalid_credentials{0, 0}; com::ubuntu::location::service::Credentials valid_credentials{getpid(), getuid()}; com::ubuntu::location::service::DefaultPermissionManager pm; /*EXPECT_EQ(com::ubuntu::location::DefaultPermissionManager::Result::rejected, pm.check_permission_for_credentials(com::ubuntu::location::Criteria {}, invalid_credentials));*/ EXPECT_EQ(com::ubuntu::location::service::PermissionManager::Result::granted, pm.check_permission_for_credentials(com::ubuntu::location::Criteria {}, valid_credentials)); } location-service-0.0.2+14.04.20140307/tests/acceptance_tests.cpp0000644000015201777760000002267712306337270024553 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "cross_process_sync.h" #include "fork_and_run.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace { core::dbus::Bus::Ptr the_session_bus() { core::dbus::Bus::Ptr bus{ new core::dbus::Bus{core::dbus::WellKnownBus::session}}; return bus; } class DummyProvider : public com::ubuntu::location::Provider { public: DummyProvider() { } ~DummyProvider() noexcept { } void inject_update(const com::ubuntu::location::Update& update) { deliver_position_updates(update); } void inject_update(const com::ubuntu::location::Update& update) { deliver_velocity_updates(update); } void inject_update(const com::ubuntu::location::Update& update) { deliver_heading_updates(update); } bool matches_criteria(const com::ubuntu::location::Criteria& /*criteria*/) { return true; } }; struct AlwaysGrantingPermissionManager : public com::ubuntu::location::service::PermissionManager { PermissionManager::Result check_permission_for_credentials(const com::ubuntu::location::Criteria&, const com::ubuntu::location::service::Credentials&) { return PermissionManager::Result::granted; } }; auto timestamp = com::ubuntu::location::Clock::now(); com::ubuntu::location::Update reference_position_update { { com::ubuntu::location::wgs84::Latitude{9. * com::ubuntu::location::units::Degrees}, com::ubuntu::location::wgs84::Longitude{53. * com::ubuntu::location::units::Degrees}, com::ubuntu::location::wgs84::Altitude{-2. * com::ubuntu::location::units::Meters} }, timestamp }; com::ubuntu::location::Update reference_velocity_update { {5. * com::ubuntu::location::units::MetersPerSecond}, timestamp }; com::ubuntu::location::Update reference_heading_update { {120. * com::ubuntu::location::units::Degrees}, timestamp }; } TEST(LocationServiceStandalone, SessionsReceiveUpdatesViaDBus) { test::CrossProcessSync sync_start; test::CrossProcessSync sync_session_created; auto server = [&sync_start, &sync_session_created]() { SCOPED_TRACE("Server"); auto bus = the_session_bus(); bus->install_executor(core::dbus::asio::make_executor(bus)); auto dummy = new DummyProvider(); com::ubuntu::location::Provider::Ptr helper(dummy); com::ubuntu::location::service::DefaultConfiguration config; com::ubuntu::location::service::Implementation service(bus, config.the_engine(config.the_provider_set(helper), config.the_provider_selection_policy()), config.the_permission_manager()); sync_start.signal_ready(); std::thread t{[bus](){bus->run();}}; sync_session_created.wait_for_signal_ready(); dummy->inject_update(reference_position_update); dummy->inject_update(reference_velocity_update); dummy->inject_update(reference_heading_update); if (t.joinable()) t.join(); }; auto client = [&sync_start, &sync_session_created]() { SCOPED_TRACE("Client"); sync_start.wait_for_signal_ready(); auto bus = the_session_bus(); bus->install_executor(core::dbus::asio::make_executor(bus)); std::thread t{[bus](){bus->run();}}; auto location_service = core::dbus::resolve_service_on_bus< com::ubuntu::location::service::Interface, com::ubuntu::location::service::Stub>(bus); std::cout << "Here" << std::endl; auto s1 = location_service->create_session_for_criteria(com::ubuntu::location::Criteria{}); com::ubuntu::location::Update position; s1->install_position_updates_handler( [&](const com::ubuntu::location::Update& new_position) { std::cout << "On position updated: " << new_position << std::endl; position = new_position; }); com::ubuntu::location::Update velocity; s1->install_velocity_updates_handler( [&](const com::ubuntu::location::Update& new_velocity) { std::cout << "On velocity_changed " << new_velocity << std::endl; velocity = new_velocity; }); com::ubuntu::location::Update heading; s1->install_heading_updates_handler( [&](const com::ubuntu::location::Update& new_heading) { std::cout << "On heading changed: " << new_heading << std::endl; heading = new_heading; bus->stop(); }); s1->start_position_updates(); s1->start_velocity_updates(); s1->start_heading_updates(); sync_session_created.signal_ready(); if (t.joinable()) t.join(); EXPECT_EQ(reference_position_update, position); EXPECT_EQ(reference_velocity_update, velocity); EXPECT_EQ(reference_heading_update, heading); }; EXPECT_NO_FATAL_FAILURE(test::fork_and_run(server, client)); } TEST(LocationServiceStandalone, AClientTimingOutDoesNotHarmTheService) { test::CrossProcessSync sync_start; test::CrossProcessSync sync_session_created; auto server = [&sync_start, &sync_session_created]() { SCOPED_TRACE("Server"); auto bus = the_session_bus(); bus->install_executor(core::dbus::asio::make_executor(bus)); auto dummy = new DummyProvider(); com::ubuntu::location::Provider::Ptr helper(dummy); com::ubuntu::location::service::DefaultConfiguration config; com::ubuntu::location::service::Implementation service(bus, config.the_engine(config.the_provider_set(helper), config.the_provider_selection_policy()), config.the_permission_manager()); sync_start.signal_ready(); std::thread t{[bus](){bus->run();}}; sync_session_created.wait_for_signal_ready(); for (unsigned int i = 0; i < 1000; i++) dummy->inject_update(reference_position_update); if (t.joinable()) t.join(); }; auto client = [&sync_start, &sync_session_created]() { SCOPED_TRACE("Client"); sync_start.wait_for_signal_ready(); auto bus = the_session_bus(); bus->install_executor(core::dbus::asio::make_executor(bus)); std::thread t{[bus](){bus->run();}}; auto location_service = core::dbus::resolve_service_on_bus< com::ubuntu::location::service::Interface, com::ubuntu::location::service::Stub>(bus); auto s1 = location_service->create_session_for_criteria(com::ubuntu::location::Criteria{}); static timespec two_seconds{ 2, 0 }; com::ubuntu::location::Update position; s1->install_position_updates_handler( [&](const com::ubuntu::location::Update& new_position) { std::cout << "On position updated: " << new_position << std::endl; ::nanosleep(&two_seconds, nullptr); bus->stop(); }); s1->start_position_updates(); s1->start_velocity_updates(); s1->start_heading_updates(); sync_session_created.signal_ready(); if (t.joinable()) t.join(); }; EXPECT_NO_FATAL_FAILURE(test::fork_and_run(server, client)); } location-service-0.0.2+14.04.20140307/tests/session_test.cpp0000644000015201777760000001015612306337245023754 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/provider.h" #include "com/ubuntu/location/session.h" #include #include namespace { struct MockProvider : public com::ubuntu::location::Provider { MOCK_METHOD1(subscribe_to_position_updates, com::ubuntu::location::ChannelConnection(std::function&)>)); MOCK_METHOD1(subscribe_to_heading_updates, com::ubuntu::location::ChannelConnection(std::function&)>)); MOCK_METHOD1(subscribe_to_velocity_updates, com::ubuntu::location::ChannelConnection(std::function&)>)); }; } TEST(LocationSession, constructing_with_a_null_provider_throws) { EXPECT_ANY_THROW(com::ubuntu::location::Session session(com::ubuntu::location::Provider::Ptr {})); } TEST(LocationSession, changing_provider_association_of_session_results_in_connections_to_new_provider) { using namespace ::testing; NiceMock mock_provider1; ON_CALL(mock_provider1, subscribe_to_position_updates(_)) .WillByDefault(Return(com::ubuntu::location::ChannelConnection())); ON_CALL(mock_provider1, subscribe_to_heading_updates(_)) .WillByDefault(Return(com::ubuntu::location::ChannelConnection())); ON_CALL(mock_provider1, subscribe_to_velocity_updates(_)) .WillByDefault(Return(com::ubuntu::location::ChannelConnection())); NiceMock mock_provider2; EXPECT_CALL(mock_provider2, subscribe_to_position_updates(_)) .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection())); EXPECT_CALL(mock_provider2, subscribe_to_heading_updates(_)) .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection())); EXPECT_CALL(mock_provider2, subscribe_to_velocity_updates(_)) .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection())); com::ubuntu::location::Session session(com::ubuntu::location::Provider::Ptr {&mock_provider1, [](com::ubuntu::location::Provider*) {}}); session.change_provider_assocation_to(com::ubuntu::location::Provider::Ptr {&mock_provider2, [](com::ubuntu::location::Provider*) {}}); } TEST(LocationSession, installing_updates_handlers_connects_them_to_the_provider_associated_to_the_session) { using namespace ::testing; NiceMock mock_provider; EXPECT_CALL(mock_provider, subscribe_to_position_updates(_)) .Times(1) .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection())); EXPECT_CALL(mock_provider, subscribe_to_heading_updates(_)) .Times(1) .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection())); EXPECT_CALL(mock_provider, subscribe_to_velocity_updates(_)) .Times(1) .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection())); com::ubuntu::location::Session session(com::ubuntu::location::Provider::Ptr {&mock_provider, [](com::ubuntu::location::Provider*) {}}); session.install_position_updates_handler([](const com::ubuntu::location::Update&) { }); session.install_heading_updates_handler([](const com::ubuntu::location::Update&) { }); session.install_velocity_updates_handler([](const com::ubuntu::location::Update&) { }); } location-service-0.0.2+14.04.20140307/tests/provider_test.cpp0000644000015201777760000002271112306337245024123 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/provider.h" #include #include namespace cul = com::ubuntu::location; namespace { class DummyProvider : public com::ubuntu::location::Provider { public: DummyProvider(com::ubuntu::location::Provider::FeatureFlags feature_flags = com::ubuntu::location::Provider::FeatureFlags {}, com::ubuntu::location::Provider::RequirementFlags requirement_flags = com::ubuntu::location::Provider::RequirementFlags {}) : com::ubuntu::location::Provider(feature_flags, requirement_flags) { } void inject_update(const com::ubuntu::location::Update& update) { deliver_position_updates(update); } void inject_update(const com::ubuntu::location::Update& update) { deliver_velocity_updates(update); } void inject_update(const com::ubuntu::location::Update& update) { deliver_heading_updates(update); } }; } TEST(Provider, requirement_flags_passed_at_construction_are_correctly_stored) { com::ubuntu::location::Provider::FeatureFlags feature_flags; com::ubuntu::location::Provider::RequirementFlags requirement_flags; requirement_flags.set(); DummyProvider provider(feature_flags, requirement_flags); EXPECT_TRUE(provider.requires(com::ubuntu::location::Provider::Requirement::satellites)); EXPECT_TRUE(provider.requires(com::ubuntu::location::Provider::Requirement::cell_network)); EXPECT_TRUE(provider.requires(com::ubuntu::location::Provider::Requirement::data_network)); EXPECT_TRUE(provider.requires(com::ubuntu::location::Provider::Requirement::monetary_spending)); } TEST(Provider, feature_flags_passed_at_construction_are_correctly_stored) { com::ubuntu::location::Provider::FeatureFlags flags; flags.set(); DummyProvider provider(flags); EXPECT_TRUE(provider.supports(com::ubuntu::location::Provider::Feature::position)); EXPECT_TRUE(provider.supports(com::ubuntu::location::Provider::Feature::velocity)); EXPECT_TRUE(provider.supports(com::ubuntu::location::Provider::Feature::heading)); } TEST(Provider, delivering_a_message_invokes_subscribers) { DummyProvider dp; bool position_update_triggered {false}; bool heading_update_triggered {false}; bool velocity_update_triggered {false}; dp.subscribe_to_position_updates([&](const com::ubuntu::location::Update&) { position_update_triggered = true; }); dp.subscribe_to_heading_updates([&](const com::ubuntu::location::Update&) { heading_update_triggered = true; }); dp.subscribe_to_velocity_updates([&](const com::ubuntu::location::Update&) { velocity_update_triggered = true; }); dp.inject_update(com::ubuntu::location::Update()); dp.inject_update(com::ubuntu::location::Update()); dp.inject_update(com::ubuntu::location::Update()); EXPECT_TRUE(position_update_triggered); EXPECT_TRUE(heading_update_triggered); EXPECT_TRUE(velocity_update_triggered); } namespace { struct MockProvider : public com::ubuntu::location::Provider { MockProvider() { } MOCK_METHOD1(subscribe_to_position_updates, cul::ChannelConnection (std::function&)>)); MOCK_METHOD1(subscribe_to_heading_updates, cul::ChannelConnection (std::function&)>)); MOCK_METHOD1(subscribe_to_velocity_updates, cul::ChannelConnection (std::function&)> f)); MOCK_METHOD0(start_position_updates, void()); MOCK_METHOD0(stop_position_updates, void()); MOCK_METHOD0(start_heading_updates, void()); MOCK_METHOD0(stop_heading_updates, void()); MOCK_METHOD0(start_velocity_updates, void()); MOCK_METHOD0(stop_velocity_updates, void()); }; } TEST(Provider, starting_and_stopping_multiple_times_results_in_exactly_one_call_to_start_and_stop_on_provider) { using namespace ::testing; NiceMock provider; EXPECT_CALL(provider, start_position_updates()).Times(Exactly(1)); EXPECT_CALL(provider, stop_position_updates()).Times(Exactly(1)); EXPECT_CALL(provider, start_heading_updates()).Times(Exactly(1)); EXPECT_CALL(provider, stop_heading_updates()).Times(Exactly(1)); EXPECT_CALL(provider, start_velocity_updates()).Times(Exactly(1)); EXPECT_CALL(provider, stop_velocity_updates()).Times(Exactly(1)); provider.state_controller()->start_position_updates(); provider.state_controller()->start_position_updates(); EXPECT_TRUE(provider.state_controller()->are_position_updates_running()); provider.state_controller()->stop_position_updates(); provider.state_controller()->stop_position_updates(); EXPECT_FALSE(provider.state_controller()->are_position_updates_running()); provider.state_controller()->start_heading_updates(); provider.state_controller()->start_heading_updates(); EXPECT_TRUE(provider.state_controller()->are_heading_updates_running()); provider.state_controller()->stop_heading_updates(); provider.state_controller()->stop_heading_updates(); EXPECT_FALSE(provider.state_controller()->are_heading_updates_running()); provider.state_controller()->start_velocity_updates(); provider.state_controller()->start_velocity_updates(); EXPECT_TRUE(provider.state_controller()->are_velocity_updates_running()); provider.state_controller()->stop_velocity_updates(); provider.state_controller()->stop_velocity_updates(); EXPECT_FALSE(provider.state_controller()->are_velocity_updates_running()); } #include "com/ubuntu/location/proxy_provider.h" TEST(ProxyProvider, start_and_stop_does_not_throw_for_null_providers) { cul::ProviderSelection selection; cul::ProxyProvider pp{selection}; EXPECT_NO_THROW(pp.start_position_updates()); EXPECT_NO_THROW(pp.stop_position_updates()); EXPECT_NO_THROW(pp.start_heading_updates()); EXPECT_NO_THROW(pp.stop_heading_updates()); EXPECT_NO_THROW(pp.start_velocity_updates()); EXPECT_NO_THROW(pp.stop_velocity_updates()); } TEST(ProxyProvider, setting_up_signal_connections_does_not_throw_for_null_providers) { cul::ProviderSelection selection; cul::ProxyProvider pp{selection}; EXPECT_NO_THROW(pp.subscribe_to_position_updates([](const cul::Update&){})); EXPECT_NO_THROW(pp.subscribe_to_heading_updates([](const cul::Update&){})); EXPECT_NO_THROW(pp.subscribe_to_velocity_updates([](const cul::Update&){})); } TEST(ProxyProvider, start_and_stop_of_updates_propagates_to_correct_providers) { using namespace ::testing; NiceMock mp1, mp2, mp3; EXPECT_CALL(mp1, start_position_updates()).Times(Exactly(1)); EXPECT_CALL(mp1, stop_position_updates()).Times(Exactly(1)); EXPECT_CALL(mp2, start_heading_updates()).Times(Exactly(1)); EXPECT_CALL(mp2, stop_heading_updates()).Times(Exactly(1)); EXPECT_CALL(mp3, start_velocity_updates()).Times(Exactly(1)); EXPECT_CALL(mp3, stop_velocity_updates()).Times(Exactly(1)); cul::Provider::Ptr p1{std::addressof(mp1), [](cul::Provider*){}}; cul::Provider::Ptr p2{std::addressof(mp2), [](cul::Provider*){}}; cul::Provider::Ptr p3{std::addressof(mp3), [](cul::Provider*){}}; cul::ProviderSelection selection{p1, p2, p3}; cul::ProxyProvider pp{selection}; pp.start_position_updates(); pp.stop_position_updates(); pp.start_heading_updates(); pp.stop_heading_updates(); pp.start_velocity_updates(); pp.stop_velocity_updates(); } TEST(ProxyProvider, update_signals_are_routed_from_correct_providers) { using namespace ::testing; NiceMock mp1, mp2, mp3; EXPECT_CALL(mp1, subscribe_to_position_updates(_)).Times(Exactly(1)).WillRepeatedly(Return(cul::ChannelConnection{})); EXPECT_CALL(mp2, subscribe_to_heading_updates(_)).Times(Exactly(1)).WillRepeatedly(Return(cul::ChannelConnection{})); EXPECT_CALL(mp3, subscribe_to_velocity_updates(_)).Times(Exactly(1)).WillRepeatedly(Return(cul::ChannelConnection{})); cul::Provider::Ptr p1{std::addressof(mp1), [](cul::Provider*){}}; cul::Provider::Ptr p2{std::addressof(mp2), [](cul::Provider*){}}; cul::Provider::Ptr p3{std::addressof(mp3), [](cul::Provider*){}}; cul::ProviderSelection selection{p1, p2, p3}; cul::ProxyProvider pp{selection}; mp1.subscribe_to_position_updates([](const cul::Update&){}); mp2.subscribe_to_heading_updates([](const cul::Update&){}); mp3.subscribe_to_velocity_updates([](const cul::Update&){}); } location-service-0.0.2+14.04.20140307/tests/provider_selection_policy_test.cpp0000644000015201777760000000632512306337245027552 0ustar pbusernogroup00000000000000#include "com/ubuntu/location/provider_selection_policy.h" #include #include namespace cul = com::ubuntu::location; namespace { class DummyProvider : public com::ubuntu::location::Provider { public: DummyProvider(com::ubuntu::location::Provider::FeatureFlags feature_flags = com::ubuntu::location::Provider::FeatureFlags {}, com::ubuntu::location::Provider::RequirementFlags requirement_flags = com::ubuntu::location::Provider::RequirementFlags {}) : com::ubuntu::location::Provider(feature_flags, requirement_flags) { } MOCK_METHOD1(matches_criteria, bool(const cul::Criteria&)); }; } TEST(ProviderSelection, feature_flags_calculation_works_correctly) { cul::Provider::Ptr provider{new DummyProvider{}}; cul::ProviderSelection selection{provider, provider, provider}; EXPECT_EQ(cul::Provider::FeatureFlags{"111"}, selection.to_feature_flags()); } #include "com/ubuntu/location/default_provider_selection_policy.h" TEST(DefaultProviderSelectionPolicy, if_no_provider_matches_criteria_null_is_returned) { using namespace testing; cul::DefaultProviderSelectionPolicy policy; NiceMock provider1, provider2; ON_CALL(provider1, matches_criteria(_)).WillByDefault(Return(false)); ON_CALL(provider2, matches_criteria(_)).WillByDefault(Return(false)); std::set providers; providers.insert(cul::Provider::Ptr{&provider1, [](cul::Provider*){}}); providers.insert(cul::Provider::Ptr{&provider2, [](cul::Provider*){}}); EXPECT_EQ(cul::Provider::Ptr{}, policy.determine_position_updates_provider(cul::Criteria{}, providers)); EXPECT_EQ(cul::Provider::Ptr{}, policy.determine_heading_updates_provider(cul::Criteria{}, providers)); EXPECT_EQ(cul::Provider::Ptr{}, policy.determine_velocity_updates_provider(cul::Criteria{}, providers)); EXPECT_EQ(cul::ProviderSelection{}, policy.determine_provider_selection_from_set_for_criteria(cul::Criteria{}, providers)); } TEST(DefaultProviderSelectionPolicy, an_already_running_provider_is_preferred) { using namespace testing; cul::DefaultProviderSelectionPolicy policy; NiceMock provider1, provider2; ON_CALL(provider1, matches_criteria(_)).WillByDefault(Return(true)); ON_CALL(provider2, matches_criteria(_)).WillByDefault(Return(true)); provider1.state_controller()->start_position_updates(); provider1.state_controller()->start_heading_updates(); provider1.state_controller()->start_velocity_updates(); cul::Provider::Ptr p1{&provider1, [](cul::Provider*){}}; cul::Provider::Ptr p2{&provider2, [](cul::Provider*){}}; std::set providers{{p1, p2}}; EXPECT_EQ(p1, policy.determine_position_updates_provider(cul::Criteria{}, providers)); EXPECT_EQ(p1, policy.determine_heading_updates_provider(cul::Criteria{}, providers)); EXPECT_EQ(p1, policy.determine_velocity_updates_provider(cul::Criteria{}, providers)); EXPECT_EQ(cul::ProviderSelection(p1, p1, p1), policy.determine_provider_selection_from_set_for_criteria(cul::Criteria{}, providers)); } location-service-0.0.2+14.04.20140307/tests/velocity_test.cpp0000644000015201777760000000443612306337245024133 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/velocity.h" #include TEST(Velocity, constructing_a_velocity_with_invalid_value_throws) { std::default_random_engine rng; std::uniform_real_distribution dist( -std::numeric_limits::max(), com::ubuntu::location::Velocity::min().value() - std::numeric_limits::min()); double d = dist(rng); EXPECT_ANY_THROW(com::ubuntu::location::Velocity v {d*com::ubuntu::location::units::MetersPerSecond};); dist = std::uniform_real_distribution( com::ubuntu::location::Velocity::max().value() + std::numeric_limits::min(), std::numeric_limits::max()); d = dist(rng); EXPECT_NO_THROW(com::ubuntu::location::Velocity v {d*com::ubuntu::location::units::MetersPerSecond};); } TEST(Velocity, constructing_a_velocity_with_a_valid_value_does_not_throw) { std::default_random_engine rng; std::uniform_real_distribution dist(com::ubuntu::location::Velocity::min().value(), com::ubuntu::location::Velocity::max().value()); EXPECT_NO_THROW(com::ubuntu::location::Velocity v {dist(rng)*com::ubuntu::location::units::MetersPerSecond};); } TEST(Velocity, a_velocity_contains_value_passed_at_construction) { std::default_random_engine rng; std::uniform_real_distribution dist(com::ubuntu::location::Velocity::min().value(), com::ubuntu::location::Velocity::max().value()); double d = dist(rng); com::ubuntu::location::Velocity v {d* com::ubuntu::location::units::MetersPerSecond}; EXPECT_DOUBLE_EQ(d, v.value.value()); } location-service-0.0.2+14.04.20140307/tests/geoclue_provider_test.cpp0000644000015201777760000000323012306337245025621 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/providers/geoclue_provider.h" #include #include TEST(GeoclueProvider, accessing_ubuntu_geo_ip_works) { const std::string name{"org.freedesktop.Geoclue.Providers.UbuntuGeoIP"}; const std::string path{"/core/Geoclue/Providers/UbuntuGeoIP"}; com::ubuntu::location::geoclue::Provider::Configuration config { name, path, com::ubuntu::location::geoclue::Provider::default_feature_flags(), com::ubuntu::location::geoclue::Provider::default_requirement_flags(), }; com::ubuntu::location::geoclue::Provider provider(config); EXPECT_NO_THROW(provider.start_position_updates()); EXPECT_NO_THROW(provider.stop_position_updates()); EXPECT_NO_THROW(provider.start_velocity_updates()); EXPECT_NO_THROW(provider.stop_velocity_updates()); EXPECT_NO_THROW(provider.start_heading_updates()); EXPECT_NO_THROW(provider.stop_heading_updates()); } location-service-0.0.2+14.04.20140307/tests/CMakeLists.txt0000644000015201777760000001412612306337270023265 0ustar pbusernogroup00000000000000find_package(Threads) option( LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER "Rely on dbus test runner to start a private session for testing purposes" ON ) if (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER) find_program(DBUS_TEST_RUNNER_EXECUTABLE dbus-test-runner) message(STATUS "Executing test suite under dbus-test-runner") endif (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER) # Build with system gmock and embedded gtest set (GMOCK_INCLUDE_DIR "/usr/include/gmock/include" CACHE PATH "gmock source include directory") set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory") set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory") add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock") include_directories ( ${CMAKE_SOURCE_DIR}/src/location_service ${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR} ) add_executable( acceptance_tests acceptance_tests.cpp test_main.cpp ) add_executable( accuracy_tests accuracy_tests.cpp test_main.cpp ) add_executable( controller_test controller_test.cpp test_main.cpp ) add_executable( default_permission_manager_test default_permission_manager_test.cpp test_main.cpp ) add_executable( dummy_provider_tests dummy_provider_tests.cpp test_main.cpp ) add_executable( engine_test engine_test.cpp test_main.cpp ) add_executable( position_test position_test.cpp test_main.cpp ) add_executable( provider_selection_policy_test provider_selection_policy_test.cpp test_main.cpp ) add_executable( heading_test heading_test.cpp test_main.cpp ) add_executable( velocity_test velocity_test.cpp test_main.cpp ) add_executable( wgs84_test wgs84_test.cpp test_main.cpp ) add_executable( provider_test provider_test.cpp test_main.cpp ) add_executable( provider_factory_test provider_factory_test.cpp test_main.cpp ) target_link_libraries( default_permission_manager_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gtest ) target_link_libraries( dummy_provider_tests ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gtest ) target_link_libraries( engine_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gmock gtest ) target_link_libraries( position_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gtest ) target_link_libraries( provider_selection_policy_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gmock gtest ) target_link_libraries( heading_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gtest ) target_link_libraries( velocity_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gtest ) target_link_libraries( wgs84_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gtest ) target_link_libraries( provider_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gmock gtest ) target_link_libraries( provider_factory_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gmock gtest ) target_link_libraries( acceptance_tests ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gtest ) target_link_libraries( accuracy_tests ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gtest ) target_link_libraries( controller_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gmock gtest ) if (LOCATION_SERVICE_ENABLE_GPS_PROVIDERS) add_executable(gps_provider_test gps_provider_test.cpp) target_link_libraries( gps_provider_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} ubuntu_application_api gtest gtest_main ) add_test(gps_provider_test gps_provider_test) endif(LOCATION_SERVICE_ENABLE_GPS_PROVIDERS) if (LOCATION_SERVICE_ENABLE_GEOCLUE_PROVIDERS) add_executable(geoclue_provider_test geoclue_provider_test.cpp) target_link_libraries( geoclue_provider_test ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} gtest gtest_main ) if (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER) add_test(geoclue_provider_test ${DBUS_TEST_RUNNER_EXECUTABLE} --task=${CMAKE_CURRENT_BINARY_DIR}/geoclue_provider_test) else (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER) add_test(geoclue_provider_test ${CMAKE_CURRENT_BINARY_DIR}/geoclue_provider_test) endif (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER) endif (LOCATION_SERVICE_ENABLE_GEOCLUE_PROVIDERS) if (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER) add_test(acceptance_tests ${DBUS_TEST_RUNNER_EXECUTABLE} --task=${CMAKE_CURRENT_BINARY_DIR}/acceptance_tests) else (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER) add_test(acceptance_tests ${CMAKE_CURRENT_BINARY_DIR}/acceptance_tests) endif (LOCATION_SERVICE_ENABLE_DBUS_TEST_RUNNER) add_test(provider_test provider_test) add_test(accuracy_tests accuracy_tests) add_test(controller_test controller_test) add_test(default_permission_manager_test default_permission_manager_test) add_test(engine_test engine_test) add_test(position_test position_test) add_test(provider_factory_test provider_factory_test) add_test(provider_selection_policy_test provider_selection_policy_test) add_test(heading_test heading_test) add_test(velocity_test velocity_test) add_test(wgs84_test wgs84_test) add_test(dummy_provider_tests dummy_provider_tests) location-service-0.0.2+14.04.20140307/tests/provider_factory_test.cpp0000644000015201777760000000373312306337245025655 0ustar pbusernogroup00000000000000#include "com/ubuntu/location/provider_factory.h" #include #include #include namespace cul = com::ubuntu::location; namespace { struct Factory { MOCK_METHOD1(create, cul::Provider::Ptr(const cul::ProviderFactory::Configuration&)); }; } TEST(ProviderFactory, adding_a_factory_works) { const std::string provider_name{"ATotallyDummyProviderFactory"}; Factory factory; auto factory_function = std::bind(&Factory::create, std::ref(factory), std::placeholders::_1); cul::ProviderFactory::instance().add_factory_for_name(provider_name, factory_function); bool found = false; cul::ProviderFactory::instance().enumerate([&found, &provider_name](const std::string& name, const cul::ProviderFactory::Factory&) { if (!found) found = (provider_name == name); }); EXPECT_TRUE(found); } TEST(ProviderFactory, creating_for_known_name_invokes_factory_function) { using namespace ::testing; const std::string provider_name{"ATotallyDummyProviderFactory"}; Factory factory; ON_CALL(factory, create(_)).WillByDefault(Return(cul::Provider::Ptr{})); EXPECT_CALL(factory, create(_)).Times(Exactly(1)); auto factory_function = std::bind(&Factory::create, std::ref(factory), std::placeholders::_1); cul::ProviderFactory::instance().add_factory_for_name(provider_name, factory_function); cul::ProviderFactory::instance().create_provider_for_name_with_config(provider_name, cul::ProviderFactory::Configuration{}); } TEST(ProviderFactory, attempt_to_create_for_unknown_name_returns_null_ptr) { EXPECT_EQ(cul::Provider::Ptr{}, cul::ProviderFactory::instance().create_provider_for_name_with_config( "AnUnknownProvider", cul::ProviderFactory::Configuration{})); } location-service-0.0.2+14.04.20140307/tests/engine_test.cpp0000644000015201777760000000727012306337245023541 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/engine.h" #include "com/ubuntu/location/provider.h" #include "com/ubuntu/location/provider_selection_policy.h" #include #include namespace { struct DummyProvider : public com::ubuntu::location::Provider { }; struct NullProviderSelectionPolicy : public com::ubuntu::location::ProviderSelectionPolicy { com::ubuntu::location::ProviderSelection determine_provider_selection_from_set_for_criteria(const com::ubuntu::location::Criteria&, const std::set&) { return com::ubuntu::location::ProviderSelection { com::ubuntu::location::Provider::Ptr{}, com::ubuntu::location::Provider::Ptr{}, com::ubuntu::location::Provider::Ptr{}}; } }; } TEST(Engine, adding_and_removing_providers_inserts_and_erases_from_underlying_collection) { com::ubuntu::location::Engine engine {std::set{}, std::make_shared()}; auto provider1 = std::make_shared(); auto provider2 = std::make_shared(); engine.add_provider(provider1); EXPECT_TRUE(engine.has_provider(provider1)); engine.add_provider(provider2); EXPECT_TRUE(engine.has_provider(provider2)); engine.remove_provider(provider1); EXPECT_FALSE(engine.has_provider(provider1)); engine.remove_provider(provider2); EXPECT_FALSE(engine.has_provider(provider2)); } TEST(Engine, adding_a_null_provider_throws) { com::ubuntu::location::Engine engine {std::set{}, std::make_shared()}; EXPECT_ANY_THROW(engine.add_provider(com::ubuntu::location::Provider::Ptr {});); } namespace { struct MockProviderSelectionPolicy : public com::ubuntu::location::ProviderSelectionPolicy { ~MockProviderSelectionPolicy() noexcept { } MOCK_METHOD2(determine_provider_selection_from_set_for_criteria, com::ubuntu::location::ProviderSelection(const com::ubuntu::location::Criteria&, const std::set&)); }; } TEST(Engine, provider_selection_policy_is_invoked_when_matching_providers_to_criteria) { using namespace ::testing; MockProviderSelectionPolicy policy; com::ubuntu::location::Engine engine { std::set{}, com::ubuntu::location::ProviderSelectionPolicy::Ptr{&policy, [](com::ubuntu::location::ProviderSelectionPolicy*) {}} }; EXPECT_CALL(policy, determine_provider_selection_from_set_for_criteria(_,_)) .Times(1) .WillOnce(Return(com::ubuntu::location::ProviderSelection { com::ubuntu::location::Provider::Ptr{}, com::ubuntu::location::Provider::Ptr{}, com::ubuntu::location::Provider::Ptr{}})); auto selection = engine.determine_provider_selection_for_criteria(com::ubuntu::location::Criteria {}); } location-service-0.0.2+14.04.20140307/tests/accuracy_tests.cpp0000644000015201777760000000412712306337245024247 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/accuracy.h" #include "com/ubuntu/location/heading.h" #include "com/ubuntu/location/velocity.h" #include "com/ubuntu/location/wgs84/altitude.h" #include "com/ubuntu/location/wgs84/latitude.h" #include "com/ubuntu/location/wgs84/longitude.h" #include namespace cul = com::ubuntu::location; TEST(HeadingAccuracy, classification_of_min_and_max_values_works_correctly) { cul::Accuracy acc_max{cul::Heading{cul::Heading::max()}}; EXPECT_EQ(cul::AccuracyLevel::worst, acc_max.classify()); cul::Accuracy acc_min{cul::Heading{cul::Heading::min()}}; EXPECT_EQ(cul::AccuracyLevel::best, acc_min.classify()); EXPECT_EQ(cul::AccuracyLevel::best, cul::Accuracy::best().classify()); EXPECT_EQ(cul::AccuracyLevel::worst, cul::Accuracy::worst().classify()); } TEST(VelocityAccuracy, classification_of_min_and_max_values_works_correctly) { cul::Accuracy acc_max{cul::Velocity{cul::Velocity::max()}}; EXPECT_EQ(cul::AccuracyLevel::worst, acc_max.classify()); cul::Accuracy acc_min{cul::Velocity{cul::Velocity::min()}}; EXPECT_EQ(cul::AccuracyLevel::best, acc_min.classify()); EXPECT_EQ(cul::AccuracyLevel::best, cul::Accuracy::best().classify()); EXPECT_EQ(cul::AccuracyLevel::worst, cul::Accuracy::worst().classify()); } location-service-0.0.2+14.04.20140307/tests/dummy_provider_tests.cpp0000644000015201777760000000510012306337245025512 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include #include #include #include #include namespace location = com::ubuntu::location; TEST(DummyProvider, ConstructionWithConfigurationWorks) { const double lat = 51.; const double lon = 7.; location::Configuration config; config.put(location::providers::dummy::Configuration::key_update_period(), 1000); config.put(location::providers::dummy::Configuration::key_reference_position_lat(), lat); config.put(location::providers::dummy::Configuration::key_reference_position_lon(), lon); auto instance = location::providers::dummy::Provider::create_instance(config); EXPECT_NE(std::shared_ptr(), instance); } TEST(DummyProvider, ConstructionWithConfigurationWorksAndDeliversCorrectUpdates) { std::mutex guard; std::condition_variable wait_condition; const double lat = 51.; const double lon = 7.; location::Position reference_position { location::wgs84::Latitude{lat * location::units::Degrees}, location::wgs84::Longitude{lon * location::units::Degrees} }; location::providers::dummy::Configuration config; config.reference_position = reference_position; config.update_period = std::chrono::milliseconds{500}; location::providers::dummy::Provider provider(config); provider.start_position_updates(); location::Position position; provider.subscribe_to_position_updates([&position, &wait_condition](const location::Update& update) { position = update.value; wait_condition.notify_all(); }); std::unique_lock ul(guard); wait_condition.wait_for(ul, std::chrono::seconds{1}); EXPECT_EQ(reference_position, position); provider.stop_position_updates(); } location-service-0.0.2+14.04.20140307/tests/fork_and_run.h0000644000015201777760000000261312306337245023345 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef FORK_AND_RUN_H_ #define FORK_AND_RUN_H_ #include #include #include #include #include #include namespace test { bool is_child(pid_t pid) { return pid == 0; } int fork_and_run(std::function child, std::function parent) { auto pid = fork(); if (pid < 0) { throw std::runtime_error(std::string("Could not fork child: ") + std::strerror(errno)); } if (is_child(pid)) { child(); return EXIT_SUCCESS; } else { parent(); kill(pid, SIGKILL); return EXIT_SUCCESS; } return EXIT_FAILURE; } } #endif // FORK_AND_RUN_H_ location-service-0.0.2+14.04.20140307/tests/test_main.cpp0000644000015201777760000000061612306337245023215 0ustar pbusernogroup00000000000000#include "com/ubuntu/location/init_and_shutdown.h" #include #include int main(int argc, char** argv) { // Initialize the location library ::com::ubuntu::location::init(&argc, &argv); ::std::atexit(com::ubuntu::location::shutdown); // This allows the user to override the flag on the command line. ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }location-service-0.0.2+14.04.20140307/tests/heading_test.cpp0000644000015201777760000000351312306337245023667 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/heading.h" #include TEST(Heading, constructing_a_heading_with_invalid_value_throws) { EXPECT_ANY_THROW(com::ubuntu::location::Heading h {-std::numeric_limits::min()*com::ubuntu::location::units::Degrees};); EXPECT_ANY_THROW(com::ubuntu::location::Heading h {361.*com::ubuntu::location::units::Degrees};); } TEST(Heading, constructing_a_heading_with_a_valid_value_does_not_throw) { std::default_random_engine rng; std::uniform_real_distribution dist(com::ubuntu::location::Heading::min().value(), com::ubuntu::location::Heading::max().value()); EXPECT_NO_THROW(com::ubuntu::location::Heading h {dist(rng)*com::ubuntu::location::units::Degrees};); } TEST(Heading, a_heading_contains_value_passed_at_construction) { std::default_random_engine rng; std::uniform_real_distribution dist(com::ubuntu::location::Heading::min().value(), com::ubuntu::location::Heading::max().value()); double d = dist(rng); com::ubuntu::location::Heading h {d* com::ubuntu::location::units::Degrees}; EXPECT_DOUBLE_EQ(d, h.value.value()); } location-service-0.0.2+14.04.20140307/tests/accuracy_test.cpp0000644000015201777760000000253712306337245024067 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/accuracy.h" #include "com/ubuntu/location/heading.h" #include "com/ubuntu/location/velocity.h" #include "com/ubuntu/location/wgs84/altitude.h" #include "com/ubuntu/location/wgs84/latitude.h" #include "com/ubuntu/location/wgs84/longitude.h" namespace cul = com::ubuntu::location; TEST(HeadingAccuracy, classification_of_min_and_max_values_works_correctly) { cul::Accuracy acc_max{cul::Heading{cul::Heading::max()}}; EXPECT_EQ(cul::AccuracyLevel::worst = acc.classify()); cul::Accuracy acc_min{cul::Heading{cul::Heading::min()}}; EXPECT_EQ(cul::AccuracyLevel::best = acc.classify()); } location-service-0.0.2+14.04.20140307/tests/position_test.cpp0000644000015201777760000000710412306337245024134 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/position.h" #include TEST(Position, AllFieldsAreInvalidForDefaultConstructor) { com::ubuntu::location::Position p; EXPECT_FALSE(p.has_latitude()); EXPECT_FALSE(p.has_longitude()); EXPECT_FALSE(p.has_altitude()); EXPECT_EQ(0, p.flags().to_ulong()); } TEST(Position, InitWithLatLonGivesValidFieldsForLatLon) { com::ubuntu::location::Position p{com::ubuntu::location::wgs84::Latitude{}, com::ubuntu::location::wgs84::Longitude{}}; EXPECT_TRUE(p.has_latitude()); EXPECT_TRUE(p.has_longitude()); EXPECT_FALSE(p.has_altitude()); EXPECT_EQ(3, p.flags().to_ulong()); } TEST(Position, InitWithLatLonAltGivesValidFieldsForLatLonAlt) { com::ubuntu::location::Position p{ com::ubuntu::location::wgs84::Latitude{}, com::ubuntu::location::wgs84::Longitude{}, com::ubuntu::location::wgs84::Altitude{}}; EXPECT_TRUE(p.has_latitude()); EXPECT_TRUE(p.has_longitude()); EXPECT_TRUE(p.has_altitude()); EXPECT_EQ(7, p.flags().to_ulong()); } TEST(Position, MutatorsAdjustFieldFlags) { com::ubuntu::location::Position p; EXPECT_FALSE(p.has_latitude()); EXPECT_FALSE(p.has_longitude()); EXPECT_FALSE(p.has_altitude()); p.latitude(com::ubuntu::location::wgs84::Latitude{}); EXPECT_TRUE(p.has_latitude()); EXPECT_FALSE(p.has_longitude()); EXPECT_FALSE(p.has_altitude()); p.longitude(com::ubuntu::location::wgs84::Longitude{}); EXPECT_TRUE(p.has_latitude()); EXPECT_TRUE(p.has_longitude()); EXPECT_FALSE(p.has_altitude()); p.altitude(com::ubuntu::location::wgs84::Altitude{}); EXPECT_TRUE(p.has_latitude()); EXPECT_TRUE(p.has_longitude()); EXPECT_TRUE(p.has_altitude()); } #include "com/ubuntu/location/codec.h" #include "core/dbus/message.h" #include "core/dbus/message_streaming_operators.h" TEST(Position, EncodingAndDecodingGivesSameResults) { auto msg = core::dbus::Message::make_method_call( "org.freedesktop.DBus", core::dbus::types::ObjectPath("/core/DBus"), "org.freedesktop.DBus", "ListNames"); { com::ubuntu::location::Position p{ com::ubuntu::location::wgs84::Latitude{9. * com::ubuntu::location::units::Degrees}, com::ubuntu::location::wgs84::Longitude{53. * com::ubuntu::location::units::Degrees}, com::ubuntu::location::wgs84::Altitude{-2. * com::ubuntu::location::units::Meters}}; msg->writer() << p; } { com::ubuntu::location::Position p; msg->reader() >> p; com::ubuntu::location::Position p_ref{ com::ubuntu::location::wgs84::Latitude{9. * com::ubuntu::location::units::Degrees}, com::ubuntu::location::wgs84::Longitude{53. * com::ubuntu::location::units::Degrees}, com::ubuntu::location::wgs84::Altitude{-2. * com::ubuntu::location::units::Meters}}; EXPECT_EQ(p_ref, p); } } location-service-0.0.2+14.04.20140307/tests/wgs84_test.cpp0000644000015201777760000001473012306337245023247 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/wgs84/coordinate.h" #include "com/ubuntu/location/wgs84/altitude.h" #include "com/ubuntu/location/wgs84/latitude.h" #include "com/ubuntu/location/wgs84/longitude.h" #include "com/ubuntu/location/position.h" #include TEST(Latitude, constructing_a_latitude_with_invalid_value_throws) { static const double min_value = com::ubuntu::location::wgs84::CoordinateTraits::min(); static const double max_value = com::ubuntu::location::wgs84::CoordinateTraits::max(); std::default_random_engine rng; std::uniform_real_distribution dist1( -std::numeric_limits::max(), min_value - std::numeric_limits::min()); std::uniform_real_distribution dist2( max_value + std::numeric_limits::min(), std::numeric_limits::max()); double dl = dist1(rng); double du = dist2(rng); EXPECT_ANY_THROW(com::ubuntu::location::wgs84::Latitude l {dl*com::ubuntu::location::units::Degrees};); EXPECT_ANY_THROW(com::ubuntu::location::wgs84::Latitude l {du*com::ubuntu::location::units::Degrees};); } TEST(Latitude, constructing_a_latitude_with_a_valid_value_does_not_throw) { const double min_value = com::ubuntu::location::wgs84::CoordinateTraits::min(); const double max_value = com::ubuntu::location::wgs84::CoordinateTraits::max(); std::default_random_engine rng; std::uniform_real_distribution dist(min_value,max_value); EXPECT_NO_THROW(com::ubuntu::location::wgs84::Latitude l {dist(rng)*com::ubuntu::location::units::Degrees};); } TEST(Latitude, a_latitude_contains_value_passed_at_construction) { const double min_value = com::ubuntu::location::wgs84::CoordinateTraits::min(); const double max_value = com::ubuntu::location::wgs84::CoordinateTraits::max(); std::default_random_engine rng; std::uniform_real_distribution dist(min_value,max_value); double d = dist(rng); com::ubuntu::location::wgs84::Latitude l {d* com::ubuntu::location::units::Degrees}; EXPECT_EQ(d * com::ubuntu::location::units::Degrees, l.value); } TEST(Longitude, constructing_a_longitude_with_invalid_value_throws) { static const double min_value = com::ubuntu::location::wgs84::CoordinateTraits::min(); static const double max_value = com::ubuntu::location::wgs84::CoordinateTraits::max(); std::default_random_engine rng; std::uniform_real_distribution dist1( -std::numeric_limits::max(), min_value - std::numeric_limits::min()); std::uniform_real_distribution dist2( max_value + std::numeric_limits::min(), std::numeric_limits::max()); double dl = dist1(rng); double du = dist2(rng); EXPECT_ANY_THROW(com::ubuntu::location::wgs84::Longitude l {dl*com::ubuntu::location::units::Degrees};); EXPECT_ANY_THROW(com::ubuntu::location::wgs84::Longitude l {du*com::ubuntu::location::units::Degrees};); } TEST(Longitude, constructing_a_longitude_with_a_valid_value_does_not_throw) { const double min_value = com::ubuntu::location::wgs84::CoordinateTraits::min(); const double max_value = com::ubuntu::location::wgs84::CoordinateTraits::max(); std::default_random_engine rng; std::uniform_real_distribution dist(min_value,max_value); EXPECT_NO_THROW(com::ubuntu::location::wgs84::Longitude l {dist(rng)*com::ubuntu::location::units::Degrees};); } TEST(Longitude, a_longitude_contains_value_passed_at_construction) { const double min_value = com::ubuntu::location::wgs84::CoordinateTraits::min(); const double max_value = com::ubuntu::location::wgs84::CoordinateTraits::max(); std::default_random_engine rng; std::uniform_real_distribution dist(min_value,max_value); double d = dist(rng); com::ubuntu::location::wgs84::Longitude l {d* com::ubuntu::location::units::Degrees}; EXPECT_EQ(d * com::ubuntu::location::units::Degrees, l.value); } TEST(Altitude, an_altitude_contains_value_passed_at_construction) { const double min_value = -std::numeric_limits::max(); const double max_value = std::numeric_limits::max(); std::default_random_engine rng; std::uniform_real_distribution dist(min_value,max_value); double d = dist(rng); com::ubuntu::location::wgs84::Altitude a {d* com::ubuntu::location::units::Meters}; EXPECT_EQ(d * com::ubuntu::location::units::Meters, a.value); } TEST(HaversineDistance, calculating_the_haverstine_distance_yields_correct_values) { com::ubuntu::location::wgs84::Latitude lat1 {47.621800*com::ubuntu::location::units::Degrees}; com::ubuntu::location::wgs84::Longitude lon1 {-122.350326*com::ubuntu::location::units::Degrees}; com::ubuntu::location::wgs84::Latitude lat2 {47.041917*com::ubuntu::location::units::Degrees}; com::ubuntu::location::wgs84::Longitude lon2 {-122.893766*com::ubuntu::location::units::Degrees}; com::ubuntu::location::Position seattle {lat1, lon1}; com::ubuntu::location::Position olympia {lat2, lon2}; com::ubuntu::location::units::Quantity expected_distance { 76.386615799548693 * com::ubuntu::location::units::kilo* com::ubuntu::location::units::Meters }; EXPECT_NEAR(expected_distance.value(), com::ubuntu::location::haversine_distance(seattle, olympia).value(), 1E-3); } location-service-0.0.2+14.04.20140307/tests/controller_test.cpp0000644000015201777760000001656112306337245024462 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/provider.h" #include #include namespace cul = com::ubuntu::location; namespace { struct MockProvider : public cul::Provider { MockProvider() = default; MOCK_METHOD0(start_position_updates, void()); MOCK_METHOD0(stop_position_updates, void()); MOCK_METHOD0(start_heading_updates, void()); MOCK_METHOD0(stop_heading_updates, void()); MOCK_METHOD0(start_velocity_updates, void()); MOCK_METHOD0(stop_velocity_updates, void()); void inject_update(const cul::Update& update) { deliver_position_updates(update); } void inject_update(const cul::Update& update) { deliver_velocity_updates(update); } void inject_update(const cul::Update& update) { deliver_heading_updates(update); } }; auto timestamp = com::ubuntu::location::Clock::now(); com::ubuntu::location::Update reference_position_update { { com::ubuntu::location::wgs84::Latitude{9. * com::ubuntu::location::units::Degrees}, com::ubuntu::location::wgs84::Longitude{53. * com::ubuntu::location::units::Degrees}, com::ubuntu::location::wgs84::Altitude{-2. * com::ubuntu::location::units::Meters} }, timestamp }; com::ubuntu::location::Update reference_velocity_update { {5. * com::ubuntu::location::units::MetersPerSecond}, timestamp }; com::ubuntu::location::Update reference_heading_update { {120. * com::ubuntu::location::units::Degrees}, timestamp }; } TEST(CachedUpdates, a_default_constructed_cached_value_is_invalid) { cul::Provider::Controller::Cache cached_value; EXPECT_FALSE(cached_value.is_valid()); } TEST(CachedUpdates, updating_with_value_results_in_valid_cached_value) { cul::Provider::Controller::Cache cached_value; cached_value.update(42); EXPECT_TRUE(cached_value.is_valid()); EXPECT_EQ(42, cached_value.value()); } TEST(CachedUpdates, invalidating_a_cached_value_results_in_cache_being_invalid) { cul::Provider::Controller::Cache cached_value; cached_value.update(42); EXPECT_TRUE(cached_value.is_valid()); cached_value.invalidate(); EXPECT_FALSE(cached_value.is_valid()); } TEST(Controller, controller_starts_and_stops_updates_on_provider) { using namespace ::testing; MockProvider provider; EXPECT_CALL(provider, start_position_updates()).Times(Exactly(1)); EXPECT_CALL(provider, start_velocity_updates()).Times(Exactly(1)); EXPECT_CALL(provider, start_heading_updates()).Times(Exactly(1)); EXPECT_CALL(provider, stop_position_updates()).Times(Exactly(1)); EXPECT_CALL(provider, stop_velocity_updates()).Times(Exactly(1)); EXPECT_CALL(provider, stop_heading_updates()).Times(Exactly(1)); auto controller = provider.state_controller(); controller->start_position_updates(); controller->start_velocity_updates(); controller->start_heading_updates(); EXPECT_TRUE(controller->are_position_updates_running()); EXPECT_TRUE(controller->are_velocity_updates_running()); EXPECT_TRUE(controller->are_heading_updates_running()); controller->stop_position_updates(); controller->stop_velocity_updates(); controller->stop_heading_updates(); EXPECT_FALSE(controller->are_position_updates_running()); EXPECT_FALSE(controller->are_velocity_updates_running()); EXPECT_FALSE(controller->are_heading_updates_running()); } TEST(Controller, controller_starts_and_stops_updates_on_provider_only_once) { using namespace ::testing; MockProvider provider; EXPECT_CALL(provider, start_position_updates()).Times(Exactly(1)); EXPECT_CALL(provider, start_velocity_updates()).Times(Exactly(1)); EXPECT_CALL(provider, start_heading_updates()).Times(Exactly(1)); EXPECT_CALL(provider, stop_position_updates()).Times(Exactly(1)); EXPECT_CALL(provider, stop_velocity_updates()).Times(Exactly(1)); EXPECT_CALL(provider, stop_heading_updates()).Times(Exactly(1)); auto controller = provider.state_controller(); controller->start_position_updates(); controller->start_velocity_updates(); controller->start_heading_updates(); EXPECT_TRUE(controller->are_position_updates_running()); EXPECT_TRUE(controller->are_velocity_updates_running()); EXPECT_TRUE(controller->are_heading_updates_running()); controller->start_position_updates(); controller->start_velocity_updates(); controller->start_heading_updates(); EXPECT_TRUE(controller->are_position_updates_running()); EXPECT_TRUE(controller->are_velocity_updates_running()); EXPECT_TRUE(controller->are_heading_updates_running()); controller->stop_position_updates(); controller->stop_velocity_updates(); controller->stop_heading_updates(); EXPECT_TRUE(controller->are_position_updates_running()); EXPECT_TRUE(controller->are_velocity_updates_running()); EXPECT_TRUE(controller->are_heading_updates_running()); controller->stop_position_updates(); controller->stop_velocity_updates(); controller->stop_heading_updates(); EXPECT_FALSE(controller->are_position_updates_running()); EXPECT_FALSE(controller->are_velocity_updates_running()); EXPECT_FALSE(controller->are_heading_updates_running()); } TEST(Controller, controller_remembers_cached_updates) { using namespace ::testing; MockProvider provider; auto controller = provider.state_controller(); EXPECT_FALSE(controller->cached_position_update().is_valid()); EXPECT_FALSE(controller->cached_velocity_update().is_valid()); EXPECT_FALSE(controller->cached_heading_update().is_valid()); provider.inject_update(reference_position_update); EXPECT_TRUE(controller->cached_position_update().is_valid()); EXPECT_EQ(reference_position_update, controller->cached_position_update().value()); EXPECT_FALSE(controller->cached_velocity_update().is_valid()); EXPECT_FALSE(controller->cached_heading_update().is_valid()); provider.inject_update(reference_velocity_update); EXPECT_TRUE(controller->cached_position_update().is_valid()); EXPECT_EQ(reference_position_update, controller->cached_position_update().value()); EXPECT_TRUE(controller->cached_velocity_update().is_valid()); EXPECT_EQ(reference_velocity_update, controller->cached_velocity_update().value()); EXPECT_FALSE(controller->cached_heading_update().is_valid()); provider.inject_update(reference_heading_update); EXPECT_TRUE(controller->cached_position_update().is_valid()); EXPECT_EQ(reference_position_update, controller->cached_position_update().value()); EXPECT_TRUE(controller->cached_velocity_update().is_valid()); EXPECT_EQ(reference_velocity_update, controller->cached_velocity_update().value()); EXPECT_TRUE(controller->cached_heading_update().is_valid()); EXPECT_EQ(reference_heading_update, controller->cached_heading_update().value()); } location-service-0.0.2+14.04.20140307/tests/gps_provider_test.cpp0000644000015201777760000000236612306337245025000 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/providers/gps.h" #include #include TEST(GeoclueProvider, accessing_starting_and_stopping_gps_provider_works) { com::ubuntu::location::GpsProvider provider; EXPECT_NO_THROW(provider.start_position_updates()); EXPECT_NO_THROW(provider.stop_position_updates()); EXPECT_NO_THROW(provider.start_velocity_updates()); EXPECT_NO_THROW(provider.stop_velocity_updates()); EXPECT_NO_THROW(provider.start_heading_updates()); EXPECT_NO_THROW(provider.stop_heading_updates()); } location-service-0.0.2+14.04.20140307/tests/cross_process_sync.h0000644000015201777760000000310712306337245024620 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef CROSS_PROCESS_SYNC_H_ #define CROSS_PROCESS_SYNC_H_ #include #include #include namespace test { struct CrossProcessSync { static const int read_fd = 0; static const int write_fd = 1; CrossProcessSync() { if (pipe(fds) < 0) throw std::runtime_error(strerror(errno)); } ~CrossProcessSync() noexcept { ::close(fds[0]); ::close(fds[1]); } void signal_ready() { int value = 42; if (!write(fds[write_fd], std::addressof(value), sizeof(value))) throw std::runtime_error(::strerror(errno)); } void wait_for_signal_ready() const { int value; if (!read(fds[read_fd], std::addressof(value), sizeof(value))) throw std::runtime_error(::strerror(errno)); } int fds[2]; }; } #endif // CROSS_PROCESS_SYNC_H_ location-service-0.0.2+14.04.20140307/CMakeLists.txt0000644000015201777760000000476012306337245022130 0ustar pbusernogroup00000000000000cmake_minimum_required(VERSION 2.8) project(ubuntu-location-service) set(UBUNTU_LOCATION_SERVICE_VERSION_MAJOR 0) set(UBUNTU_LOCATION_SERVICE_VERSION_MINOR 0) set(UBUNTU_LOCATION_SERVICE_VERSION_PATCH 2) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wextra -fPIC -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -fno-strict-aliasing -pedantic -Wextra -fPIC -pthread") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) include(cmake/EnableCoverageReport.cmake) include(cmake/FindGFlags.cmake) include(cmake/FindGLog.cmake) include(cmake/PrePush.cmake) include(CTest) include(GNUInstallDirs) find_package(PkgConfig) find_package(Boost 1.49 COMPONENTS system program_options) find_package(GLog) find_package(GFlags) pkg_check_modules(DBUS dbus-1 REQUIRED) pkg_check_modules(DBUS_CPP dbus-cpp REQUIRED) ##################################################################### # Enable code coverage calculation with gcov/gcovr/lcov # Usage: # * Switch build type to coverage (use ccmake or cmake-gui) # * Invoke make, make test, make coverage # * Find html report in subdir coveragereport # * Find xml report feasible for jenkins in coverage.xml ##################################################################### IF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE]) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage -fprofile-arcs" ) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs" ) SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" ) SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" ) ENDIF(CMAKE_BUILD_TYPE MATCHES [cC][oO][vV][eE][rR][aA][gG][eE]) option (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS "Disable errors when local typedefs are unused" ON) if (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS) SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=unused-local-typedefs") endif (DISABLE_ERROR_ON_LOCAL_TYPEDEFS_WARNINGS) include_directories( ${Boost_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS} ${DBUS_CPP_INCLUDE_DIRS}/dbus ${GLog_INCLUDE_DIR} ${GFlags_INCLUDE_DIR} include/location_service ) add_subdirectory(data) add_subdirectory(doc) add_subdirectory(examples) add_subdirectory(include) add_subdirectory(src) add_subdirectory(tests) # There's no nice way to format this. Thanks CMake. add_test(LGPL-required /bin/sh -c "! grep -rl 'GNU General' ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/include" ) enable_coverage_report(service) location-service-0.0.2+14.04.20140307/doc/0000755000015201777760000000000012306337604020125 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/doc/Doxyfile.in0000644000015201777760000023433212306337245022250 0ustar pbusernogroup00000000000000# Doxyfile 1.8.3.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or sequence of words) that should # identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. PROJECT_NAME = @CMAKE_PROJECT_NAME@ # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = @UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@.@UBUNTU_LOCATION_SERVICE_VERSION_MINOR@.@UBUNTU_LOCATION_SERVICE_VERSION_PATCH@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer # a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify an logo or icon that is # included in the documentation. The maximum height of the logo should not # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. Note that you specify absolute paths here, but also # relative paths, which will be relative from the directory where doxygen is # started. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding # "class=itcl::class" will allow you to use the command class in the # itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, # and language is one of the parsers supported by doxygen: IDL, Java, # Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, # C++. For instance to make doxygen treat .inc files as Fortran files (default # is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note # that for custom extensions you also need to set FILE_PATTERNS otherwise the # files are not read by doxygen. EXTENSION_MAPPING = # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all # comments according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you # can mix doxygen, HTML, and XML commands with Markdown formatting. # Disable only in case of backward compatibilities issues. MARKDOWN_SUPPORT = YES # When enabled doxygen tries to link words that correspond to documented classes, # or namespaces to their corresponding documentation. Such a link can be # prevented in individual cases by by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES (the # default) will make doxygen replace the get and set methods by a property in # the documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and # unions are shown inside the group in which they are included (e.g. using # @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and # unions with only public data fields will be shown inline in the documentation # of the scope in which they are defined (i.e. file, namespace, or group # documentation), provided this scope is documented. If set to NO (the default), # structs, classes, and unions are shown on a separate page (for HTML and Man # pages) or section (for LaTeX and RTF). INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. SYMBOL_CACHE_SIZE = 0 # Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be # set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given # their name and scope. Since this can be an expensive process and often the # same symbol appear multiple times in the code, doxygen keeps a cache of # pre-resolved symbols. If the cache is too small doxygen will become slower. # If the cache is too large, memory is wasted. The cache size is given by this # formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal # scope will be included in the documentation. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to # do proper type resolution of all parameters of a function it will reject a # match between the prototype and the implementation of a member function even # if there is only one candidate or it is obvious which candidate to choose # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if section-label ... \endif # and \cond section-label ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files # containing the references data. This must be a list of .bib files. The # .bib extension is automatically appended if omitted. Using this command # requires the bibtex tool to be installed. See also # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this # feature you need bibtex and perl available in the search path. Do not use # file names with spaces, bibtex cannot handle them. CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = @CMAKE_CURRENT_SOURCE_DIR@/../include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/../examples # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = YES # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) # and it is also possible to disable source filtering for a specific pattern # using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. FILTER_SOURCE_PATTERNS = # If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page (index.html). # This can be useful if you have a project on for instance GitHub and want reuse # the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = YES # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C, C++ and Fortran comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. Note that when using a custom header you are responsible # for the proper inclusion of any scripts and style sheets that doxygen # needs, which is dependent on the configuration options used. # It is advised to generate a default header using "doxygen -w html # header.html footer.html stylesheet.css YourConfigFile" and then modify # that header. Note that the header is subject to change so you typically # have to redo this when upgrading to a newer version of doxygen or when # changing the value of configuration settings such as GENERATE_TREEVIEW! HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If left blank doxygen will # generate a default style sheet. Note that it is recommended to use # HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this # tag will in the future become obsolete. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify an additional # user-defined cascading style sheet that is included after the standard # style sheets created by doxygen. Using this option one can overrule # certain style aspects. This is preferred over using HTML_STYLESHEET # since it does not replace the standard style sheet and is therefor more # robust against future updates. Doxygen will copy the style sheet file to # the output directory. HTML_EXTRA_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the style sheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of # entries shown in the various tree structured indices initially; the user # can expand and collapse entries dynamically later on. Doxygen will expand # the tree to such a level that at most the specified number of entries are # visible (unless a fully collapsed tree already exceeds this amount). # So setting the number of entries 1 will produce a full collapsed tree by # default. 0 is a special value representing an infinite number of entries # and will result in a full expanded tree by default. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely # identify the documentation publisher. This should be a reverse domain-name # style string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) # at top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. Since the tabs have the same information as the # navigation tree you can set this option to NO if you already set # GENERATE_TREEVIEW to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. # Since the tree basically has the same information as the tab index you # could consider to set DISABLE_INDEX to NO when enabling this option. GENERATE_TREEVIEW = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values # (range [0,1..20]) that doxygen will group on one line in the generated HTML # documentation. Note that a value of 0 will completely suppress the enum # values from appearing in the overview section. ENUM_VALUES_PER_LINE = 1 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and # SVG. The default value is HTML-CSS, which is slower, but has the best # compatibility. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to # the MathJax Content Delivery Network so you can quickly see the result without # installing MathJax. # However, it is strongly recommended to install a local # copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension # names that should be enabled during MathJax rendering. MATHJAX_EXTENSIONS = # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = NO # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a web server instead of a web client using Javascript. # There are two flavours of web server based search depending on the # EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for # searching and an index file used by the script. When EXTERNAL_SEARCH is # enabled the indexing and searching needs to be provided by external tools. # See the manual for details. SERVER_BASED_SEARCH = NO # When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP # script for searching. Instead the search results are written to an XML file # which needs to be processed by an external indexer. Doxygen will invoke an # external search engine pointed to by the SEARCHENGINE_URL option to obtain # the search results. Doxygen ships with an example indexer (doxyindexer) and # search engine (doxysearch.cgi) which are based on the open source search engine # library Xapian. See the manual for configuration details. EXTERNAL_SEARCH = NO # The SEARCHENGINE_URL should point to a search engine hosted by a web server # which will returned the search results when EXTERNAL_SEARCH is enabled. # Doxygen ships with an example search engine (doxysearch) which is based on # the open source search engine library Xapian. See the manual for configuration # details. SEARCHENGINE_URL = # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed # search data is written to a file for indexing by an external tool. With the # SEARCHDATA_FILE tag the name of this file can be specified. SEARCHDATA_FILE = searchdata.xml # When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the # EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is # useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple # projects and redirect the results back to the right project. EXTERNAL_SEARCH_ID = # The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen # projects other than the one defined by this configuration file, but that are # all added to the same external search index. Each project needs to have a # unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id # of to a relative location where the documentation can be found. # The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for # the generated latex document. The footer should contain everything after # the last chapter. If it is left blank doxygen will generate a # standard footer. Notice: only use this tag if you know what you are doing! LATEX_FOOTER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See # http://en.wikipedia.org/wiki/BibTeX for more info. LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load style sheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition that # overrules the definition found in the source code. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all references to function-like macros # that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. For each # tag file the location of the external documentation should be added. The # format of a tag file without this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths # or URLs. Note that each tag file must have a unique name (where the name does # NOT include the path). If a tag file is not located in the directory in which # doxygen is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = NO # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 1 # By default doxygen will use the Helvetica font for all dot files that # doxygen generates. When you want a differently looking font you can specify # the font name using DOT_FONTNAME. You need to make sure dot is able to find # the font, which can be done by putting it in a standard location or by setting # the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the # directory containing the font. DOT_FONTNAME = Helvetica # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the Helvetica font. # If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to # set the path where dot can find it. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = YES # If the UML_LOOK tag is enabled, the fields and methods are shown inside # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more # managable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = YES # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are svg, png, jpg, or gif. # If left blank png will be used. If you choose svg you need to set # HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = png # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to # enable generation of interactive SVG images that allow zooming and panning. # Note that this requires a modern browser other than Internet Explorer. # Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you # need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible. Older versions of IE do not have SVG support. INTERACTIVE_SVG = YES # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = YES # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = YES # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES location-service-0.0.2+14.04.20140307/doc/CMakeLists.txt0000644000015201777760000000217312306337245022671 0ustar pbusernogroup00000000000000# Copyright © 2013 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Authored by: Thomas Voss find_package(Doxygen) if(DOXYGEN_FOUND) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) add_custom_target(doc ALL ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation with Doxygen" VERBATIM) install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION share/LocationService/doc) endif(DOXYGEN_FOUND) location-service-0.0.2+14.04.20140307/COPYING.GPL0000644000015201777760000004325412306337245021045 0ustar pbusernogroup00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. location-service-0.0.2+14.04.20140307/COPYING.LGPL0000644000015201777760000001674312306337245021164 0ustar pbusernogroup00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. location-service-0.0.2+14.04.20140307/examples/0000755000015201777760000000000012306337604021176 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/examples/service/0000755000015201777760000000000012306337604022636 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/examples/service/service.md0000644000015201777760000000602612306337245024625 0ustar pbusernogroup00000000000000ubuntu-location-service(2) -- A location service aggregating position/velocity/heading updates and exporting them over dbus. ============================================================================================================================ ## SYNOPSIS `ubuntu-location-service` `--bus` `--provider` [`--provider` ] [provider specific options] ## DESCRIPTION A location service aggregating position/velocity/heading updates and exporting them over dbus. ## OPTIONS These options control which bus the service is exposed upon and which providers are instantiated: * `--bus`=: Specify the bus that the service should be exposed upon, valid values are "session" or "system". * `--provider`=: Specify the provider that should be instantiated and configured for this service instance. Valid values are: geoclue::Provider, gps::Provider and skyhook::Provider. These options control the behavior of the geoclue provider: * `--geoclue::Provider::name`=: The name of the provider on the bus. * `--geoclue::Provider::path`=: The object path of the provider on the bus. These options control the behavior of the Skyhook provider: * `--skyhook::Provider::username`=: Username for authenicating with the Skyhook service. * `--skyhook::Provider::realm`=: Realm for authenticating with the Skyhook service. * `--skyhook::Provider::period`=: Delay between updates in [ms]. These options control the logging behavior of the service: * `--logtostderr`=: Log messages to stderr instead of logfiles, defaults to false. * `--stderrthreshold`=: Copy log messages at or above this level to stderr in addition to logfiles. The numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively. Defa * `--minloglevel`=: Log messages at or above this level. Again, the numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively. * `--log_dir`=: If specified, logfiles are written into this directory instead of the default logging directory. * `--v`=: Show all VLOG(m) messages for m less or equal the value of this flag. ## EXAMPLES Starting the service with a gps and a skyhook provider, exposing it on the system bus: $ /usr/bin/ubuntu-location-service/examples/service --bus system --provider gps::Provider --provider skyhook::Provider --skyhook::Provider::username=ut_testing --skyhook::Provider::realm=ut_testing.com A slightly more verbose instance: $ /usr/bin/ubuntu-location-service/examples/service --logtostderr=true --v=5 --bus system --provider gps::Provider --provider skyhook::Provider --skyhook::Provider::username=ut_testing --skyhook::Provider::realm=ut_testing.com ## COPYRIGHT Ubuntu Location Service is Copyright (C) 2012 Canonical Ltd. location-service-0.0.2+14.04.20140307/examples/service/CMakeLists.txt0000644000015201777760000000247212306337245025404 0ustar pbusernogroup00000000000000find_package(PkgConfig) find_package(Boost COMPONENTS system) find_package(Threads) pkg_check_modules(DBUS dbus-1) pkg_check_modules(DBUS_CPP dbus-cpp) include_directories( ${Boost_INCLUDE_DIRS} ${DBUS_INCLUDE_DIRS} ${DBUS_CPP_INCLUDE_DIRS}/dbus ) link_directories( /tmp/wpsapi-4.7.6_05-linux-x86_64/lib ) add_executable( client client.cpp ) add_executable( service service.cpp ) target_link_libraries( client ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} ${DBUS_CPP_LDFLAGS} ) target_link_libraries( service ubuntu-location-service ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} ${DBUS_CPP_LDFLAGS} ) add_custom_command( OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ubuntu-location-service.1" COMMAND ronn --roff --pipe --organization=ubuntu ${CMAKE_CURRENT_SOURCE_DIR}/service.1.ronn > ${CMAKE_CURRENT_BINARY_DIR}/ubuntu-location-service.1 ) add_custom_target( ubuntu-location-service-man-page DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/ubuntu-location-service.1" ) install( TARGETS service client DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/examples/ ) install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/ubuntu-location-service.1 DESTINATION share/doc/${CMAKE_PROJECT_NAME}/man ) location-service-0.0.2+14.04.20140307/examples/service/service.cpp0000644000015201777760000001157212306337245025011 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "program_options.h" #include "com/ubuntu/location/provider_factory.h" #include "com/ubuntu/location/service/default_configuration.h" #include "com/ubuntu/location/service/implementation.h" #include #include #include namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; namespace dbus = core::dbus; int main(int argc, char** argv) { cul::ProgramOptions options; options.add("help", "Produces this help message"); options.add( "bus", "The well-known bus to announce the service upon", std::string{"session"}); options.add_composed>( "provider", "The providers that should be added to the engine"); if (!options.parse_from_command_line_args(argc, argv)) return EXIT_FAILURE; if (options.value_count_for_key("help") > 0) { options.print_help(std::cout); return EXIT_SUCCESS; } if (options.value_count_for_key("provider") == 0) { std::cout << "A set of providers need to be specified. The following providers are known:" << std::endl; cul::ProviderFactory::instance().enumerate( [](const std::string& name, const cul::ProviderFactory::Factory&) { std::cout << "\t" << name << std::endl; }); return EXIT_FAILURE; } auto selected_providers = options.value_for_key>("provider"); std::map config_lut; std::set instantiated_providers; for (const std::string& provider : selected_providers) { std::cout << "Instantiating and configuring: " << provider << std::endl; options.enumerate_unrecognized_options( [&config_lut, provider](const std::string& s) { std::stringstream in(s); std::string key, value; std::getline(in, key, '='); std::getline(in, value, '='); std::size_t pos = key.find(provider); if (pos == std::string::npos) return; static const std::string option_marker{"--"}; static const std::string scope_separator{"::"}; key = key.erase(key.find_first_of(option_marker), option_marker.size()); key = key.erase(key.find_first_of(provider), provider.size()); key = key.erase(key.find_first_of(scope_separator), scope_separator.size()); std::cout << "\t" << key << " -> " << value << std::endl; config_lut[provider].put(key, value); }); try { auto p = cul::ProviderFactory::instance().create_provider_for_name_with_config( provider, config_lut[provider]); if (p) instantiated_providers.insert(p); else throw std::runtime_error("Problem instantiating provider"); } catch(const std::runtime_error& e) { std::cerr << "Exception instantiating provider: " << e.what() << " ... Aborting now." << std::endl; return EXIT_FAILURE; } } static const std::map lut = { {"session", dbus::WellKnownBus::session}, {"system", dbus::WellKnownBus::system}, }; dbus::Bus::Ptr bus { new dbus::Bus{lut.at(options.value_for_key("bus"))} }; bus->install_executor(dbus::asio::make_executor(bus)); culs::DefaultConfiguration config; auto location_service = dbus::announce_service_on_bus< culs::Interface, culs::Implementation >( bus, config.the_engine( instantiated_providers, config.the_provider_selection_policy()), config.the_permission_manager()); std::thread t{[bus](){bus->run();}}; if (t.joinable()) t.join(); return EXIT_SUCCESS; } location-service-0.0.2+14.04.20140307/examples/service/program_options.h0000644000015201777760000000642412306337245026240 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include #include #include #include #include namespace com { namespace ubuntu { namespace location { struct ProgramOptions { ProgramOptions(bool do_allow_unregistered = true) : allow_unregistered(do_allow_unregistered) { } ProgramOptions& add(const char* name, const char* desc) { od.add_options() (name, desc); return *this; } template ProgramOptions& add(const char* name, const char* desc) { od.add_options() (name, boost::program_options::value(), desc); return *this; } template ProgramOptions& add(const char* name, const char* desc, const T& default_value) { od.add_options() (name, boost::program_options::value()->default_value(default_value), desc); return *this; } template ProgramOptions& add_composed(const char* name, const char* desc) { od.add_options()( name, boost::program_options::value()->composing(), desc); return *this; } bool parse_from_command_line_args(int argc, char** argv) { try { auto parser = boost::program_options::command_line_parser( argc, argv).options(od); auto parsed = allow_unregistered ? parser.allow_unregistered().run() : parser.run(); unrecognized = boost::program_options::collect_unrecognized( parsed.options, boost::program_options::exclude_positional); boost::program_options::store(parsed, vm); } catch(const std::runtime_error& e) { std::cerr << e.what() << std::endl; return false; } return true; } template T value_for_key(const std::string& key) { return vm[key].as(); } std::size_t value_count_for_key(const std::string& key) { return vm.count(key); } void enumerate_unrecognized_options(const std::function& enumerator) { for (const std::string& s : unrecognized) enumerator(s); } void print_help(std::ostream& out) { out << od; } bool allow_unregistered; boost::program_options::options_description od; boost::program_options::variables_map vm; std::vector unrecognized; }; } } } location-service-0.0.2+14.04.20140307/examples/service/service.1.ronn0000644000015201777760000000610712306337245025340 0ustar pbusernogroup00000000000000ubuntu-location-service(1) -- A location service aggregating position/velocity/heading updates and exporting them over dbus. ============================================================================================================================ ## SYNOPSIS `ubuntu-location-service` `--bus` `--provider` [`--provider` ] [provider specific options] [logging options] ## DESCRIPTION A location service aggregating position/velocity/heading updates and exporting them over dbus. ## OPTIONS These options control which bus the service is exposed upon and which providers are instantiated: * `--bus`=: Specify the bus that the service should be exposed upon, valid values are "session" or "system". * `--provider`=: Specify the provider that should be instantiated and configured for this service instance. Valid values are: geoclue::Provider, gps::Provider and skyhook::Provider. These options control the behavior of the geoclue provider: * `--geoclue::Provider::name`=: The name of the provider on the bus. * `--geoclue::Provider::path`=: The object path of the provider on the bus. These options control the behavior of the Skyhook provider: * `--skyhook::Provider::username`=: Username for authenicating with the Skyhook service. * `--skyhook::Provider::realm`=: Realm for authenticating with the Skyhook service. * `--skyhook::Provider::period`=: Delay between updates in [ms]. These options control the logging behavior of the service: * `--logtostderr`=: Log messages to stderr instead of logfiles, defaults to false. * `--stderrthreshold`=: Copy log messages at or above this level to stderr in addition to logfiles. The numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively. Defa * `--minloglevel`=: Log messages at or above this level. Again, the numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively. * `--log_dir`=: If specified, logfiles are written into this directory instead of the default logging directory. * `--v`=: Show all VLOG(m) messages for m less or equal the value of this flag. ## EXAMPLES Starting the service with a gps and a skyhook provider, exposing it on the system bus: $ /usr/bin/ubuntu-location-service/examples/service --bus system --provider gps::Provider --provider skyhook::Provider --skyhook::Provider::username=a_registered_user_name --skyhook::Provider::realm=a_registered_realm A slightly more verbose instance: $ /usr/bin/ubuntu-location-service/examples/service --bus system --provider gps::Provider --provider skyhook::Provider --skyhook::Provider::username=a_registered_user_name --skyhook::Provider::realm=a_registered_realm --logtostderr=true --v=5 ## COPYRIGHT Ubuntu Location Service is Copyright (C) 2013 Canonical Ltd. location-service-0.0.2+14.04.20140307/examples/service/client.cpp0000644000015201777760000000564112306337245024627 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "program_options.h" #include "com/ubuntu/location/service/stub.h" #include #include #include namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; namespace dbus = core::dbus; int main(int argc, char** argv) { cul::ProgramOptions options; options.add("help", "Produces this help message"); options.add( "bus", "The well-known bus to connect to the service upon", std::string{"session"}); if (!options.parse_from_command_line_args(argc, argv)) return EXIT_FAILURE; if (options.value_count_for_key("help") > 0) { options.print_help(std::cout); return EXIT_SUCCESS; } static const std::map lut = { {"session", dbus::WellKnownBus::session}, {"system", dbus::WellKnownBus::system}, }; core::dbus::Bus::Ptr bus { new core::dbus::Bus{lut.at(options.value_for_key("bus"))} }; bus->install_executor(core::dbus::asio::make_executor(bus)); std::thread t{[bus](){bus->run();}}; auto location_service = core::dbus::resolve_service_on_bus(bus); auto s1 = location_service->create_session_for_criteria(com::ubuntu::location::Criteria{}); s1->install_position_updates_handler( [&](const com::ubuntu::location::Update& new_position) { std::cout << "On position updated: " << new_position << std::endl; }); s1->install_velocity_updates_handler( [&](const com::ubuntu::location::Update& new_velocity) { std::cout << "On velocity_changed " << new_velocity << std::endl; }); s1->install_heading_updates_handler( [&](const com::ubuntu::location::Update& new_heading) { std::cout << "On heading changed: " << new_heading << std::endl; }); s1->start_position_updates(); s1->start_velocity_updates(); s1->start_heading_updates(); if (t.joinable()) t.join(); return EXIT_SUCCESS; } location-service-0.0.2+14.04.20140307/examples/service/ubuntu-location-service.10000644000015201777760000000634512306337245027517 0ustar pbusernogroup00000000000000.\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . .TH "UBUNTU\-LOCATION\-SERVICE" "2" "May 2013" "ubuntu" "" . .SH "NAME" \fBubuntu\-location\-service\fR \- A location service aggregating position/velocity/heading updates and exporting them over dbus\. . .SH "SYNOPSIS" \fBubuntu\-location\-service\fR \fB\-\-bus\fR \fIwell known bus name\fR \fB\-\-provider\fR \fIprovider\fR [\fB\-\-provider\fR \fIprovider\fR] [provider specific options] . .SH "DESCRIPTION" A location service aggregating position/velocity/heading updates and exporting them over dbus\. . .SH "OPTIONS" These options control which bus the service is exposed upon and which providers are instantiated: . .TP \fB\-\-bus\fR=\fIbus\fR Specify the bus that the service should be exposed upon, valid values are "session" or "system"\. . .TP \fB\-\-provider\fR=\fIprovider\fR Specify the provider that should be instantiated and configured for this service instance\. Valid values are: geoclue::Provider, gps::Provider and skyhook::Provider\. . .P These options control the behavior of the geoclue provider: . .TP \fB\-\-geoclue::Provider::name\fR=\fIname\fR The name of the provider on the bus\. . .TP \fB\-\-geoclue::Provider::path\fR=\fIpath\fR The object path of the provider on the bus\. . .P These options control the behavior of the Skyhook provider: . .TP \fB\-\-skyhook::Provider::username\fR=\fIusername\fR Username for authenicating with the Skyhook service\. . .TP \fB\-\-skyhook::Provider::realm\fR=\fIrealm\fR Realm for authenticating with the Skyhook service\. . .TP \fB\-\-skyhook::Provider::period\fR=\fIperiod\fR Delay between updates in [ms]\. . .P These options control the logging behavior of the service: . .TP \fB\-\-logtostderr\fR= Log messages to stderr instead of logfiles, defaults to false\. . .TP \fB\-\-stderrthreshold\fR= Copy log messages at or above this level to stderr in addition to logfiles\. The numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively\. Defa . .TP \fB\-\-minloglevel\fR= Log messages at or above this level\. Again, the numbers of severity levels INFO, WARNING, ERROR, and FATAL are 0, 1, 2, and 3, respectively\. . .TP \fB\-\-log_dir\fR= If specified, logfiles are written into this directory instead of the default logging directory\. . .TP \fB\-\-v\fR= Show all VLOG(m) messages for m less or equal the value of this flag\. . .SH "EXAMPLES" Starting the service with a gps and a skyhook provider, exposing it on the system bus: . .IP "" 4 . .nf $ /usr/bin/ubuntu\-location\-service/examples/service \-\-bus system \-\-provider gps::Provider \-\-provider skyhook::Provider \-\-skyhook::Provider::username=ut_testing \-\-skyhook::Provider::realm=ut_testing\.com . .fi . .IP "" 0 . .P A slightly more verbose instance: . .IP "" 4 . .nf $ /usr/bin/ubuntu\-location\-service/examples/service \-\-logtostderr=true \-\-v=5 \-\-bus system \-\-provider gps::Provider \-\-provider skyhook::Provider \-\-skyhook::Provider::username=ut_testing \-\-skyhook::Provider::realm=ut_testing\.com . .fi . .IP "" 0 . .SH "COPYRIGHT" Ubuntu Location Service is Copyright (C) 2012 Canonical Ltd\. location-service-0.0.2+14.04.20140307/examples/CMakeLists.txt0000644000015201777760000000004012306337245023731 0ustar pbusernogroup00000000000000add_subdirectory(service) location-service-0.0.2+14.04.20140307/src/0000755000015201777760000000000012306337604020147 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/src/location_service/0000755000015201777760000000000012306337604023477 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/src/location_service/CMakeLists.txt0000644000015201777760000000002512306337245026235 0ustar pbusernogroup00000000000000add_subdirectory(com)location-service-0.0.2+14.04.20140307/src/location_service/com/0000755000015201777760000000000012306337604024255 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/0000755000015201777760000000000012306337604025577 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/CMakeLists.txt0000644000015201777760000000003212306337245030333 0ustar pbusernogroup00000000000000add_subdirectory(location)location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/0000755000015201777760000000000012306337604027407 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016500000000000011217 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/default_provider_selection_policy.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/default_provider_sele0000644000015201777760000001016112306337245033700 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/default_provider_selection_policy.h" namespace cul = com::ubuntu::location; cul::DefaultProviderSelectionPolicy::DefaultProviderSelectionPolicy() { } cul::DefaultProviderSelectionPolicy::~DefaultProviderSelectionPolicy() noexcept { } cul::ProviderSelection cul::DefaultProviderSelectionPolicy::determine_provider_selection_from_set_for_criteria( const cul::Criteria& criteria, const std::set& providers) { ProviderSelection selection { determine_position_updates_provider(criteria, providers), determine_heading_updates_provider(criteria, providers), determine_velocity_updates_provider(criteria, providers), }; return selection; } cul::Provider::Ptr cul::DefaultProviderSelectionPolicy::determine_position_updates_provider( const cul::Criteria& criteria, const std::set& providers) { auto less = [](const Provider::Ptr& lhs, const Provider::Ptr& rhs) { return lhs->state_controller()->are_position_updates_running() && !rhs->state_controller()->are_position_updates_running(); }; std::set< Provider::Ptr, std::function> matching_providers(less); std::for_each( providers.begin(), providers.end(), [&](const Provider::Ptr& provider) { if (provider->matches_criteria(criteria)) matching_providers.insert(provider); }); return matching_providers.empty() ? Provider::Ptr {} : *matching_providers.begin(); } cul::Provider::Ptr cul::DefaultProviderSelectionPolicy::determine_heading_updates_provider( const cul::Criteria& criteria, const std::set& providers) { auto less = [](const Provider::Ptr& lhs, const Provider::Ptr& rhs) { return lhs->state_controller()->are_heading_updates_running() && !rhs->state_controller()->are_heading_updates_running(); }; std::set< Provider::Ptr, std::function> matching_providers(less); std::for_each( providers.begin(), providers.end(), [&](const Provider::Ptr& provider) { if (provider->matches_criteria(criteria)) matching_providers.insert(provider); }); return matching_providers.empty() ? Provider::Ptr {} : *matching_providers.begin(); } cul::Provider::Ptr cul::DefaultProviderSelectionPolicy::determine_velocity_updates_provider( const cul::Criteria& criteria, const std::set& providers) { auto less = [](const Provider::Ptr& lhs, const Provider::Ptr& rhs) { return lhs->state_controller()->are_velocity_updates_running() && !rhs->state_controller()->are_velocity_updates_running(); }; std::set< Provider::Ptr, std::function> matching_providers(less); std::for_each( providers.begin(), providers.end(), [&](const Provider::Ptr& provider) { if (provider->matches_criteria(criteria)) matching_providers.insert(provider); }); return matching_providers.empty() ? Provider::Ptr {} : *matching_providers.begin(); } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/init_and_shutdown.cpp0000644000015201777760000000121012306337245033626 0ustar pbusernogroup00000000000000#include "com/ubuntu/location/init_and_shutdown.h" #include "com/ubuntu/location/logging.h" #include namespace cul = com::ubuntu::location; namespace { struct LoggingInitializer { LoggingInitializer() { google::InitGoogleLogging("com.ubuntu.location"); } ~LoggingInitializer() { google::ShutdownGoogleLogging(); } }; static LoggingInitializer logging_initializer; } void cul::init(int* argc, char*** argv) { static const bool remove_parsed_flags = true; google::ParseCommandLineFlags(argc, argv, remove_parsed_flags); } void cul::shutdown() { google::ShutDownCommandLineFlags(); }././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/default_permission_manager.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/default_permission_ma0000644000015201777760000000246212306337245033710 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/default_permission_manager.h" namespace cul = com::ubuntu::location; cul::DefaultPermissionManager::DefaultPermissionManager() : pid(getpid()), uid(getuid()) { } cul::DefaultPermissionManager::~DefaultPermissionManager() noexcept { } cul::PermissionManager::Result cul::DefaultPermissionManager::check_permission_for_credentials( const cul::Criteria&, const cul::Credentials& credentials) { if (credentials.pid != pid || credentials.uid != uid) return Result::granted; // FIXME(tvoss): This should return rejected. return Result::granted; } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/0000755000015201777760000000000012306337604031047 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016100000000000011213 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/default_configuration.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/default_confi0000644000015201777760000000354412306337245033603 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/service/default_configuration.h" #include "com/ubuntu/location/service/default_permission_manager.h" #include "com/ubuntu/location/default_provider_selection_policy.h" namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; culs::DefaultConfiguration::DefaultConfiguration() { } culs::DefaultConfiguration::~DefaultConfiguration() noexcept { } cul::Engine::Ptr culs::DefaultConfiguration::the_engine( const std::set& provider_set, const cul::ProviderSelectionPolicy::Ptr& provider_selection_policy) { return Engine::Ptr {new Engine{provider_set, provider_selection_policy}}; } cul::ProviderSelectionPolicy::Ptr culs::DefaultConfiguration::the_provider_selection_policy() { return ProviderSelectionPolicy::Ptr(new DefaultProviderSelectionPolicy()); } std::set culs::DefaultConfiguration::the_provider_set( const cul::Provider::Ptr& seed) { return std::set{seed}; } culs::PermissionManager::Ptr culs::DefaultConfiguration::the_permission_manager() { return DefaultPermissionManager::Ptr(new DefaultPermissionManager()); } ././@LongLink0000000000000000000000000000016600000000000011220 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/default_permission_manager.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/default_permi0000644000015201777760000000255012306337245033615 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/service/default_permission_manager.h" namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; culs::DefaultPermissionManager::DefaultPermissionManager() : pid(getpid()), uid(getuid()) { } culs::DefaultPermissionManager::~DefaultPermissionManager() noexcept { } culs::PermissionManager::Result culs::DefaultPermissionManager::check_permission_for_credentials( const cul::Criteria&, const culs::Credentials& credentials) { if (credentials.pid != pid || credentials.uid != uid) return Result::granted; // FIXME(tvoss): This should return rejected. return Result::granted; } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/session/0000755000015201777760000000000012306337604032532 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016200000000000011214 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/session/implementation.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/session/imple0000644000015201777760000000527712306337245033577 0ustar pbusernogroup00000000000000#include "com/ubuntu/location/service/session/implementation.h" #include #include namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; namespace culss = com::ubuntu::location::service::session; namespace dbus = core::dbus; struct culss::Implementation::Private { Private(const Provider::Ptr& provider) : provider(provider) { } Provider::Ptr provider; ScopedChannelConnection position_updates_connection; ScopedChannelConnection velocity_updates_connection; ScopedChannelConnection heading_updates_connection; }; culss::Implementation::Implementation( const dbus::Bus::Ptr& bus, const dbus::types::ObjectPath& session_path, const cul::Provider::Ptr& provider) : Skeleton(bus, session_path), d(new Private{provider}) { if (!provider) throw std::runtime_error("Cannot create implementation for null provider."); d->position_updates_connection = provider->subscribe_to_position_updates([this](const Update& update) { access_position_updates_channel()(update); }); d->heading_updates_connection = provider->subscribe_to_heading_updates([this](const Update& update) { access_heading_updates_channel()(update); }); d->velocity_updates_connection = provider->subscribe_to_velocity_updates([this](const Update& update) { access_velocity_updates_channel()(update); }); } culss::Implementation::~Implementation() noexcept { } void culss::Implementation::start_position_updates() { d->provider->state_controller()->start_position_updates(); } void culss::Implementation::stop_position_updates() noexcept { d->provider->state_controller()->stop_position_updates(); } void culss::Implementation::start_velocity_updates() { d->provider->state_controller()->start_velocity_updates(); } void culss::Implementation::stop_velocity_updates() noexcept { d->provider->state_controller()->stop_velocity_updates(); } void culss::Implementation::start_heading_updates() { d->provider->state_controller()->start_heading_updates(); } void culss::Implementation::stop_heading_updates() noexcept { d->provider->state_controller()->stop_heading_updates(); } ././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/session/skeleton.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/session/skele0000644000015201777760000001517012306337270033563 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/service/session/skeleton.h" #include #include #include #include namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; namespace culss = com::ubuntu::location::service::session; namespace dbus = core::dbus; struct culss::Skeleton::Private { void handle_start_position_updates(const core::dbus::Message::Ptr& msg); void handle_stop_position_updates(const core::dbus::Message::Ptr& msg); void handle_start_velocity_updates(const core::dbus::Message::Ptr& msg); void handle_stop_velocity_updates(const core::dbus::Message::Ptr& msg); void handle_start_heading_updates(const core::dbus::Message::Ptr& msg); void handle_stop_heading_updates(const core::dbus::Message::Ptr& msg); Skeleton* parent; dbus::Bus::Ptr bus; dbus::types::ObjectPath session_path; dbus::Object::Ptr object; }; culss::Skeleton::Skeleton( const dbus::Bus::Ptr& bus, const dbus::types::ObjectPath& session_path) : dbus::Skeleton{bus}, d(new Private { this, bus, session_path, access_service()->add_object_for_path(session_path) }) { d->object->install_method_handler( std::bind(&Skeleton::Private::handle_start_position_updates, std::ref(d), std::placeholders::_1)); d->object->install_method_handler( std::bind(&Skeleton::Private::handle_stop_position_updates, std::ref(d), std::placeholders::_1)); d->object->install_method_handler( std::bind(&Skeleton::Private::handle_start_velocity_updates, std::ref(d), std::placeholders::_1)); d->object->install_method_handler( std::bind(&Skeleton::Private::handle_stop_velocity_updates, std::ref(d), std::placeholders::_1)); d->object->install_method_handler( std::bind(&Skeleton::Private::handle_start_heading_updates, std::ref(d), std::placeholders::_1)); d->object->install_method_handler( std::bind(&Skeleton::Private::handle_stop_heading_updates, std::ref(d), std::placeholders::_1)); } culss::Skeleton::~Skeleton() noexcept { d->object->uninstall_method_handler(); d->object->uninstall_method_handler(); d->object->uninstall_method_handler(); d->object->uninstall_method_handler(); d->object->uninstall_method_handler(); d->object->uninstall_method_handler(); } const dbus::types::ObjectPath& culss::Skeleton::path() const { return d->session_path; } void culss::Skeleton::Private::handle_start_position_updates(const core::dbus::Message::Ptr& msg) { try { parent->start_position_updates(); auto reply = dbus::Message::make_method_return(msg); bus->send(reply); } catch(const std::runtime_error& e) { auto error = core::dbus::Message::make_error( msg, Interface::Errors::ErrorStartingUpdate::name(), e.what()); bus->send(error); } } void culss::Skeleton::Private::handle_stop_position_updates(const core::dbus::Message::Ptr& msg) { try { parent->stop_position_updates(); auto reply = core::dbus::Message::make_method_return(msg); bus->send(reply); } catch(const std::runtime_error& e) { auto error = core::dbus::Message::make_error( msg, Interface::Errors::ErrorStoppingUpdate::name(), e.what()); bus->send(error); } } void culss::Skeleton::Private::handle_start_velocity_updates(const core::dbus::Message::Ptr& msg) { try { parent->start_velocity_updates(); auto reply = core::dbus::Message::make_method_return(msg); bus->send(reply); } catch(const std::runtime_error& e) { auto error = core::dbus::Message::make_error(msg, Interface::Errors::ErrorStartingUpdate::name(), e.what()); bus->send(error); } } void culss::Skeleton::Private::handle_stop_velocity_updates(const core::dbus::Message::Ptr& msg) { try { parent->stop_velocity_updates(); auto reply = core::dbus::Message::make_method_return(msg); bus->send(reply); } catch(const std::runtime_error& e) { auto error = core::dbus::Message::make_error( msg, Interface::Errors::ErrorStoppingUpdate::name(), e.what()); bus->send(error); } } void culss::Skeleton::Private::handle_start_heading_updates(const core::dbus::Message::Ptr& msg) { try { parent->start_heading_updates(); auto reply = core::dbus::Message::make_method_return(msg); bus->send(reply); } catch(const std::runtime_error& e) { auto error = core::dbus::Message::make_error(msg, Interface::Errors::ErrorStartingUpdate::name(), e.what()); bus->send(error); } } void culss::Skeleton::Private::handle_stop_heading_updates(const core::dbus::Message::Ptr& msg) { try { parent->stop_heading_updates(); auto reply = core::dbus::Message::make_method_return(msg); bus->send(reply); } catch(const std::runtime_error& e) { auto error = core::dbus::Message::make_error( msg, Interface::Errors::ErrorStoppingUpdate::name(), e.what()); bus->send(error); } } ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/session/interface.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/session/inter0000644000015201777760000000462212306337245033603 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/service/session/interface.h" #include #include #include #include namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; namespace culss = com::ubuntu::location::service::session; namespace dbus = core::dbus; struct culss::Interface::Private { cul::Channel> position_updates_channel; cul::Channel> heading_updates_channel; cul::Channel> velocity_updates_channel; }; culss::Interface::Interface() : d{new Private{}} { } culss::Interface::~Interface() noexcept { } cul::ChannelConnection culss::Interface::install_position_updates_handler(std::function&)> handler) { return d->position_updates_channel.connect(handler); } cul::ChannelConnection culss::Interface::install_velocity_updates_handler(std::function&)> handler) { return d->velocity_updates_channel.connect(handler); } cul::ChannelConnection culss::Interface::install_heading_updates_handler(std::function&)> handler) { return d->heading_updates_channel.connect(handler); } cul::Channel>& culss::Interface::access_position_updates_channel() { return d->position_updates_channel; } cul::Channel>& culss::Interface::access_heading_updates_channel() { return d->heading_updates_channel; } cul::Channel>& culss::Interface::access_velocity_updates_channel() { return d->velocity_updates_channel; } ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/session/stub.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/session/stub.0000644000015201777760000001251012306337270033506 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/service/session/stub.h" #include "com/ubuntu/location/logging.h" #include #include namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; namespace culss = com::ubuntu::location::service::session; namespace dbus = core::dbus; struct culss::Stub::Private { void update_heading(const core::dbus::Message::Ptr& msg); void update_position(const core::dbus::Message::Ptr& msg); void update_velocity(const core::dbus::Message::Ptr& msg); Stub* parent; dbus::types::ObjectPath session_path; dbus::Object::Ptr object; }; culss::Stub::Stub(const dbus::Bus::Ptr& bus, const dbus::types::ObjectPath& session_path) : dbus::Stub(bus), d(new Private{this, session_path, access_service()->add_object_for_path(session_path)}) { d->object->install_method_handler( std::bind(&Stub::Private::update_position, std::ref(d), std::placeholders::_1)); d->object->install_method_handler( std::bind(&Stub::Private::update_heading, std::ref(d), std::placeholders::_1)); d->object->install_method_handler( std::bind(&Stub::Private::update_velocity, std::ref(d), std::placeholders::_1)); } culss::Stub::~Stub() noexcept {} const dbus::types::ObjectPath& culss::Stub::path() const { return d->session_path; } void culss::Stub::start_position_updates() { auto result = d->object->transact_method(); if (result.is_error()) throw std::runtime_error(result.error().print()); } void culss::Stub::stop_position_updates() noexcept { try { auto result = d->object->transact_method(); if (result.is_error()) LOG(WARNING) << result.error(); } catch(const std::runtime_error& e) { LOG(WARNING) << e.what(); } } void culss::Stub::start_velocity_updates() { auto result = d->object->transact_method(); if (result.is_error()) throw std::runtime_error(result.error().print()); } void culss::Stub::stop_velocity_updates() noexcept { try { auto result = d->object->transact_method(); if (result.is_error()) LOG(WARNING) << result.error(); } catch(const std::runtime_error& e) { LOG(WARNING) << e.what(); } } void culss::Stub::start_heading_updates() { auto result = d->object->transact_method(); if (result.is_error()) throw std::runtime_error(result.error().print()); } void culss::Stub::stop_heading_updates() noexcept { try { auto result = d->object->transact_method(); if (result.is_error()) LOG(WARNING) << result.error(); } catch(const std::runtime_error& e) { LOG(WARNING) << e.what(); } } void culss::Stub::Private::update_heading(const core::dbus::Message::Ptr& incoming) { try { Update update; incoming->reader() >> update; parent->access_heading_updates_channel()(update); parent->access_bus()->send(dbus::Message::make_method_return(incoming)); } catch(const std::runtime_error& e) { parent->access_bus()->send(dbus::Message::make_error(incoming, Interface::Errors::ErrorParsingUpdate::name(), e.what())); } } void culss::Stub::Private::update_position(const core::dbus::Message::Ptr& incoming) { try { Update update; incoming->reader() >> update; parent->access_position_updates_channel()(update); parent->access_bus()->send(dbus::Message::make_method_return(incoming)); } catch(const std::runtime_error& e) { parent->access_bus()->send(dbus::Message::make_error(incoming, Interface::Errors::ErrorParsingUpdate::name(), e.what())); } } void culss::Stub::Private::update_velocity(const core::dbus::Message::Ptr& incoming) { try { Update update; incoming->reader() >> update; parent->access_velocity_updates_channel()(update); parent->access_bus()->send(dbus::Message::make_method_return(incoming)); } catch(const std::runtime_error& e) { parent->access_bus()->send(dbus::Message::make_error(incoming, Interface::Errors::ErrorParsingUpdate::name(), e.what())); } } ././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/implementation.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/implementatio0000644000015201777760000000376112306337245033651 0ustar pbusernogroup00000000000000#include "com/ubuntu/location/service/implementation.h" #include "com/ubuntu/location/service/session/implementation.h" #include "com/ubuntu/location/criteria.h" #include "com/ubuntu/location/engine.h" #include "com/ubuntu/location/proxy_provider.h" #include #include #include #include #include #include #include namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; namespace dbus = core::dbus; struct culs::Implementation::Private { dbus::types::ObjectPath make_session_path() { static std::size_t counter{0}; std::stringstream ss; ss << "/sessions/" << counter; counter++; return dbus::types::ObjectPath{ss.str()}; } dbus::Bus::Ptr bus; cul::Engine::Ptr engine; culs::PermissionManager::Ptr permission_manager; }; culs::Implementation::Implementation( const dbus::Bus::Ptr& bus, const cul::Engine::Ptr& engine, const culs::PermissionManager::Ptr& permission_manager) : Skeleton(bus, permission_manager), d{new Private{bus, engine, permission_manager}} { if (!bus) throw std::runtime_error("Cannot create service for null bus."); if (!engine) throw std::runtime_error("Cannot create service for null engine."); if (!permission_manager) throw std::runtime_error("Cannot create service for null permission manager."); } culs::Implementation::~Implementation() noexcept { } culs::session::Interface::Ptr culs::Implementation::create_session_for_criteria(const cul::Criteria& criteria) { auto provider_selection = d->engine->determine_provider_selection_for_criteria(criteria); auto proxy_provider = ProxyProvider::Ptr { new ProxyProvider{provider_selection} }; return session::Interface::Ptr{new session::Implementation(d->bus, d->make_session_path(), proxy_provider)}; } ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/program_options.hlocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/program_optio0000644000015201777760000000642412306337245033662 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include #include #include #include #include namespace com { namespace ubuntu { namespace location { struct ProgramOptions { ProgramOptions(bool do_allow_unregistered = true) : allow_unregistered(do_allow_unregistered) { } ProgramOptions& add(const char* name, const char* desc) { od.add_options() (name, desc); return *this; } template ProgramOptions& add(const char* name, const char* desc) { od.add_options() (name, boost::program_options::value(), desc); return *this; } template ProgramOptions& add(const char* name, const char* desc, const T& default_value) { od.add_options() (name, boost::program_options::value()->default_value(default_value), desc); return *this; } template ProgramOptions& add_composed(const char* name, const char* desc) { od.add_options()( name, boost::program_options::value()->composing(), desc); return *this; } bool parse_from_command_line_args(int argc, char** argv) { try { auto parser = boost::program_options::command_line_parser( argc, argv).options(od); auto parsed = allow_unregistered ? parser.allow_unregistered().run() : parser.run(); unrecognized = boost::program_options::collect_unrecognized( parsed.options, boost::program_options::exclude_positional); boost::program_options::store(parsed, vm); } catch(const std::runtime_error& e) { std::cerr << e.what() << std::endl; return false; } return true; } template T value_for_key(const std::string& key) { return vm[key].as(); } std::size_t value_count_for_key(const std::string& key) { return vm.count(key); } void enumerate_unrecognized_options(const std::function& enumerator) { for (const std::string& s : unrecognized) enumerator(s); } void print_help(std::ostream& out) { out << od; } bool allow_unregistered; boost::program_options::options_description od; boost::program_options::variables_map vm; std::vector unrecognized; }; } } } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/main.cpp0000644000015201777760000001157212306337245032506 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "program_options.h" #include "com/ubuntu/location/provider_factory.h" #include "com/ubuntu/location/service/default_configuration.h" #include "com/ubuntu/location/service/implementation.h" #include #include #include namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; namespace dbus = core::dbus; int main(int argc, char** argv) { cul::ProgramOptions options; options.add("help", "Produces this help message"); options.add( "bus", "The well-known bus to announce the service upon", std::string{"session"}); options.add_composed>( "provider", "The providers that should be added to the engine"); if (!options.parse_from_command_line_args(argc, argv)) return EXIT_FAILURE; if (options.value_count_for_key("help") > 0) { options.print_help(std::cout); return EXIT_SUCCESS; } if (options.value_count_for_key("provider") == 0) { std::cout << "A set of providers need to be specified. The following providers are known:" << std::endl; cul::ProviderFactory::instance().enumerate( [](const std::string& name, const cul::ProviderFactory::Factory&) { std::cout << "\t" << name << std::endl; }); return EXIT_FAILURE; } auto selected_providers = options.value_for_key>("provider"); std::map config_lut; std::set instantiated_providers; for (const std::string& provider : selected_providers) { std::cout << "Instantiating and configuring: " << provider << std::endl; options.enumerate_unrecognized_options( [&config_lut, provider](const std::string& s) { std::stringstream in(s); std::string key, value; std::getline(in, key, '='); std::getline(in, value, '='); std::size_t pos = key.find(provider); if (pos == std::string::npos) return; static const std::string option_marker{"--"}; static const std::string scope_separator{"::"}; key = key.erase(key.find_first_of(option_marker), option_marker.size()); key = key.erase(key.find_first_of(provider), provider.size()); key = key.erase(key.find_first_of(scope_separator), scope_separator.size()); std::cout << "\t" << key << " -> " << value << std::endl; config_lut[provider].put(key, value); }); try { auto p = cul::ProviderFactory::instance().create_provider_for_name_with_config( provider, config_lut[provider]); if (p) instantiated_providers.insert(p); else throw std::runtime_error("Problem instantiating provider"); } catch(const std::runtime_error& e) { std::cerr << "Exception instantiating provider: " << e.what() << " ... Aborting now." << std::endl; return EXIT_FAILURE; } } static const std::map lut = { {"session", dbus::WellKnownBus::session}, {"system", dbus::WellKnownBus::system}, }; dbus::Bus::Ptr bus { new dbus::Bus{lut.at(options.value_for_key("bus"))} }; bus->install_executor(dbus::asio::make_executor(bus)); culs::DefaultConfiguration config; auto location_service = dbus::announce_service_on_bus< culs::Interface, culs::Implementation >( bus, config.the_engine( instantiated_providers, config.the_provider_selection_policy()), config.the_permission_manager()); std::thread t{[bus](){bus->run();}}; if (t.joinable()) t.join(); return EXIT_SUCCESS; } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/skeleton.cpp0000644000015201777760000001757412306337270033414 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/service/skeleton.h" #include "com/ubuntu/location/logging.h" #include #include #include #include namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; namespace culss = com::ubuntu::location::service::session; namespace dbus = core::dbus; namespace { template struct SessionStore { typedef std::shared_ptr Ptr; SessionStore() = default; SessionStore(const SessionStore&) = delete; SessionStore& operator=(const SessionStore&) = delete; virtual ~SessionStore() = default; virtual void remove_session(const std::shared_ptr& session) = 0; }; struct SessionWrapper : public std::enable_shared_from_this { typedef std::shared_ptr Ptr; SessionWrapper(const SessionStore::Ptr& session_store, const culss::Interface::Ptr& session, core::dbus::Service::Ptr service, core::dbus::Object::Ptr object) : session_store(session_store), session{session}, remote(service, object) { session->install_position_updates_handler(std::bind(&SessionWrapper::on_position_update, this, std::placeholders::_1)); session->install_velocity_updates_handler(std::bind(&SessionWrapper::on_velocity_update, this, std::placeholders::_1)); session->install_heading_updates_handler(std::bind(&SessionWrapper::on_heading_update, this, std::placeholders::_1)); } const core::dbus::types::ObjectPath& path() const { return session->path(); } void on_session_died() noexcept { std::cout << __PRETTY_FUNCTION__ << std::endl; VLOG(1) << "Session died, removing from store and stopping all updates."; auto thiz = shared_from_this(); try { session_store->remove_session(thiz); session->stop_position_updates(); session->stop_heading_updates(); session->stop_velocity_updates(); } catch(const std::runtime_error& e) { LOG(ERROR) << "Error while stopping updates for died session: " << e.what(); } } void on_position_update(const cul::Update& position) { try { auto result = remote.session->transact_method(position); if (result.is_error()) { LOG(ERROR) << result.error().print(); on_session_died(); } } catch(const std::runtime_error& e) { // We consider the session to be dead once we hit an exception here. // We thus remove it from the central and end its lifetime. on_session_died(); } } void on_velocity_update(const cul::Update& velocity) { try { auto result = remote.session->transact_method(velocity); if (result.is_error()) { LOG(ERROR) << result.error().print(); on_session_died(); } } catch(const std::runtime_error& e) { // We consider the session to be dead once we hit an exception here. // We thus remove it from the central and end its lifetime. on_session_died(); } } void on_heading_update(const cul::Update& heading) { try { auto result = remote.session->transact_method(heading); if (result.is_error()) { LOG(ERROR) << result.error().print(); on_session_died(); } } catch(const std::runtime_error& e) { // We consider the session to be dead once we hit an exception here. // We thus remove it from the central and end its lifetime. on_session_died(); } } SessionStore::Ptr session_store; culs::session::Interface::Ptr session; struct Remote { explicit Remote(const dbus::Service::Ptr& service, const dbus::Object::Ptr& session) : service(service), session(session) { } dbus::Service::Ptr service; dbus::Object::Ptr session; } remote; }; } struct culs::Skeleton::Private : public SessionStore, std::enable_shared_from_this { Private(Skeleton* parent, const dbus::Bus::Ptr& connection, const culs::PermissionManager::Ptr& permission_manager) : parent(parent), permission_manager(permission_manager), daemon(connection), object(parent->access_service()->add_object_for_path(culs::Interface::path())) { object->install_method_handler( std::bind(&culs::Skeleton::Private::handle_create_session_for_criteria, this, std::placeholders::_1)); } ~Private() noexcept {} void handle_create_session_for_criteria(const core::dbus::Message::Ptr& in); void remove_session(const std::shared_ptr& session); Skeleton* parent; PermissionManager::Ptr permission_manager; dbus::DBus daemon; dbus::Object::Ptr object; std::mutex guard; std::map> session_store; }; culs::Skeleton::Skeleton(const dbus::Bus::Ptr& connection, const culs::PermissionManager::Ptr& permission_manager) : dbus::Skeleton(connection), d{new Private{this, connection, permission_manager}} { } culs::Skeleton::~Skeleton() noexcept { } void culs::Skeleton::Private::handle_create_session_for_criteria(const core::dbus::Message::Ptr& in) { auto sender = in->sender(); try { Criteria criteria; in->reader() >> criteria; Credentials credentials { static_cast(daemon.get_connection_unix_process_id(sender)), static_cast(daemon.get_connection_unix_user(sender)) }; if (PermissionManager::Result::rejected == permission_manager->check_permission_for_credentials(criteria, credentials)) throw std::runtime_error("Client lacks permissions to access the service with the given criteria"); auto session = parent->create_session_for_criteria(criteria); auto service = dbus::Service::use_service(parent->access_bus(), in->sender()); auto object = service->object_for_path(session->path()); { std::lock_guard lg(guard); auto wrapper = SessionWrapper::Ptr{new SessionWrapper{shared_from_this(), session, service, object}}; bool inserted = false; std::tie(std::ignore, inserted) = session_store.insert(std::make_pair(session->path(), wrapper)); auto reply = dbus::Message::make_method_return(in); reply->writer() << session->path(); parent->access_bus()->send(reply); if (!inserted) throw std::runtime_error("Could not insert duplicate session into store."); } } catch(const std::runtime_error& e) { parent->access_bus()->send( dbus::Message::make_error( in, culs::Interface::Errors::CreatingSession::name(), e.what())); LOG(ERROR) << "Error creating session: " << e.what(); } } void culs::Skeleton::Private::remove_session(const SessionWrapper::Ptr& session) { std::lock_guard lg(guard); session_store.erase(session->path()); VLOG(1) << "# of session in session store: " << session_store.size() << std::endl; } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/service/stub.cpp0000644000015201777760000000334212306337270032531 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/service/stub.h" #include "com/ubuntu/location/service/session/stub.h" #include "com/ubuntu/location/logging.h" namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::service; namespace culss = com::ubuntu::location::service::session; namespace dbus = core::dbus; struct culs::Stub::Private { core::dbus::Bus::Ptr bus; core::dbus::Object::Ptr object; }; culs::Stub::Stub(const dbus::Bus::Ptr& connection) : dbus::Stub(connection), d(new Private{connection, access_service()->object_for_path(culs::Interface::path())}) { } culs::Stub::~Stub() noexcept { } culss::Interface::Ptr culs::Stub::create_session_for_criteria(const cul::Criteria& criteria) { auto op = d->object->transact_method< culs::Interface::CreateSessionForCriteria, culs::Interface::CreateSessionForCriteria::ResultType >(criteria); if (op.is_error()) throw std::runtime_error(op.error().print()); return culss::Interface::Ptr(new culss::Stub{d->bus, op.value()}); } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/CMakeLists.txt0000644000015201777760000000265712306337245032162 0ustar pbusernogroup00000000000000add_subdirectory(providers) add_library( ubuntu-location-service SHARED default_provider_selection_policy.cpp engine.cpp init_and_shutdown.cpp position.cpp provider.cpp provider_factory.cpp proxy_provider.cpp service/default_configuration.cpp service/default_permission_manager.cpp service/implementation.cpp service/skeleton.cpp service/stub.cpp service/session/implementation.cpp service/session/interface.cpp service/session/skeleton.cpp service/session/stub.cpp providers/config.cpp ) set_target_properties( ubuntu-location-service PROPERTIES VERSION ${UBUNTU_LOCATION_SERVICE_VERSION_MAJOR}.${UBUNTU_LOCATION_SERVICE_VERSION_MINOR}.${UBUNTU_LOCATION_SERVICE_VERSION_PATCH} SOVERSION ${UBUNTU_LOCATION_SERVICE_VERSION_MAJOR} ) add_definitions(${ENABLED_PROVIDER_TARGETS_DEFINITIONS}) target_link_libraries( ubuntu-location-service ${ENABLED_PROVIDER_TARGETS} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} ${DBUS_CPP_LDFLAGS} ${GLog_LIBRARY} ${GFlags_LIBRARY} ) install( TARGETS ubuntu-location-service DESTINATION ${CMAKE_INSTALL_LIBDIR} ) add_executable( ubuntu-location-serviced service/main.cpp ) target_link_libraries( ubuntu-location-serviced ubuntu-location-service ${ENABLED_PROVIDER_TARGETS} ${Boost_LIBRARIES} ${DBUS_LIBRARIES} ${GLog_LIBRARY} ${GFlags_LIBRARY} ) install( TARGETS ubuntu-location-serviced DESTINATION ${CMAKE_INSTALL_BINDIR} ) location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/proxy_provider.cpp0000644000015201777760000000600112306337245033204 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/proxy_provider.h" #include #include namespace cul = com::ubuntu::location; cul::ProxyProvider::ProxyProvider(const cul::ProviderSelection& selection) : Provider(selection.to_feature_flags()), position_updates_provider(selection.position_updates_provider), heading_updates_provider(selection.heading_updates_provider), velocity_updates_provider(selection.velocity_updates_provider) { } cul::ProxyProvider::~ProxyProvider() noexcept { } cul::ChannelConnection cul::ProxyProvider::subscribe_to_position_updates(std::function&)> f) { if (position_updates_provider) return position_updates_provider->subscribe_to_position_updates(f); return ChannelConnection {}; } cul::ChannelConnection cul::ProxyProvider::subscribe_to_heading_updates(std::function&)> f) { if (heading_updates_provider) return heading_updates_provider->subscribe_to_heading_updates(f); return ChannelConnection {}; } cul::ChannelConnection cul::ProxyProvider::subscribe_to_velocity_updates(std::function&)> f) { if (velocity_updates_provider) return velocity_updates_provider->subscribe_to_velocity_updates(f); return ChannelConnection {}; } void cul::ProxyProvider::start_position_updates() { if (position_updates_provider) position_updates_provider->state_controller()->start_position_updates(); } void cul::ProxyProvider::stop_position_updates() { if (position_updates_provider) position_updates_provider->state_controller()->stop_position_updates(); } void cul::ProxyProvider::start_velocity_updates() { if (velocity_updates_provider) velocity_updates_provider->state_controller()->start_velocity_updates(); } void cul::ProxyProvider::stop_velocity_updates() { if (velocity_updates_provider) velocity_updates_provider->state_controller()->stop_velocity_updates(); } void cul::ProxyProvider::start_heading_updates() { if (heading_updates_provider) heading_updates_provider->state_controller()->start_heading_updates(); } void cul::ProxyProvider::stop_heading_updates() { if (heading_updates_provider) heading_updates_provider->state_controller()->stop_heading_updates(); } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/provider_factory.cpp0000644000015201777760000000376412306337245033507 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/provider_factory.h" #include "com/ubuntu/location/provider.h" #include #include #include #include namespace cul = com::ubuntu::location; cul::ProviderFactory& cul::ProviderFactory::instance() { static cul::ProviderFactory pf; return pf; } void cul::ProviderFactory::add_factory_for_name( const std::string& name, const cul::ProviderFactory::Factory& factory) { std::lock_guard lg(guard); factory_store[name] = factory; } cul::Provider::Ptr cul::ProviderFactory::create_provider_for_name_with_config( const std::string& name, const cul::ProviderFactory::Configuration& config) { std::lock_guard lg(guard); if (factory_store.count(name) == 0) return Provider::Ptr{}; return cul::Provider::Ptr{factory_store.at(name)(config)}; } void cul::ProviderFactory::enumerate( const std::function& enumerator) { std::lock_guard lg(guard); std::for_each( factory_store.begin(), factory_store.end(), [enumerator](const std::map::value_type& value) { enumerator(value.first, value.second); }); } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/position.cpp0000644000015201777760000000717312306337245031770 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/position.h" #include #include namespace cul = com::ubuntu::location; cul::Position::Position() : fields{Flags("000"), wgs84::Latitude{}, wgs84::Longitude{}, wgs84::Altitude{}} { } cul::Position::Position( const cul::wgs84::Latitude& latitude, const cul::wgs84::Longitude& longitude) : fields{Flags("011"), latitude, longitude, wgs84::Altitude{}} { } cul::Position::Position( const cul::wgs84::Latitude& latitude, const cul::wgs84::Longitude& longitude, const cul::wgs84::Altitude& altitude) : fields{Flags{"111"}, latitude, longitude, altitude} { } bool cul::Position::operator==(const cul::Position& rhs) const { return fields.latitude == rhs.fields.latitude && fields.longitude == rhs.fields.longitude && fields.altitude == rhs.fields.altitude; } bool cul::Position::operator!=(const cul::Position& rhs) const { return !(fields.latitude == rhs.fields.latitude && fields.longitude == rhs.fields.longitude && fields.altitude == rhs.fields.altitude); } const cul::Position::Flags& cul::Position::flags() const { return fields.flags; } bool cul::Position::has_latitude() const { return fields.flags.test(latitude_flag); } cul::Position& cul::Position::latitude(const cul::wgs84::Latitude& lat) { fields.flags.set(latitude_flag); fields.latitude = lat; return *this; } const cul::wgs84::Latitude& cul::Position::latitude() const { return fields.latitude; } bool cul::Position::has_longitude() const { return fields.flags.test(longitude_flag); } cul::Position& cul::Position::longitude(const cul::wgs84::Longitude& lon) { fields.flags.set(longitude_flag); fields.longitude = lon; return *this; } const cul::wgs84::Longitude& cul::Position::longitude() const { return fields.longitude; } bool cul::Position::has_altitude() const { return fields.flags.test(altitude_flag); } cul::Position& cul::Position::altitude(const cul::wgs84::Altitude& alt) { fields.flags.set(altitude_flag); fields.altitude = alt; return *this; } const cul::wgs84::Altitude& cul::Position::altitude() const { return fields.altitude; } std::ostream& cul::operator<<(std::ostream& out, const cul::Position& position) { out << "Position(" << position.latitude() << ", " << position.longitude() << ", " << position.altitude() << ")"; return out; } cul::units::Quantity cul::haversine_distance(const cul::Position& p1, const cul::Position& p2) { static const units::Quantity radius_of_earth {6371 * units::kilo* units::Meters}; auto dLat = p2.latitude() - p1.latitude(); auto dLon = p2.longitude() - p1.longitude(); auto a = std::pow(units::sin(dLat.value/2.), 2) + std::pow(units::sin(dLon.value/2.), 2) * units::cos(p1.latitude().value) * units::cos(p2.latitude().value); auto c = 2. * std::atan2(std::sqrt(a), std::sqrt(1.-a)); return radius_of_earth * c; } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/provider.cpp0000644000015201777760000001351712306337245031755 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/provider.h" #include #include #include namespace cul = com::ubuntu::location; void cul::Provider::Controller::start_position_updates() { if (++position_updates_counter == 1) { instance.start_position_updates(); } } void cul::Provider::Controller::stop_position_updates() { if (--position_updates_counter == 0) { instance.stop_position_updates(); } } bool cul::Provider::Controller::are_position_updates_running() const { return position_updates_counter > 0; } void cul::Provider::Controller::start_heading_updates() { if (++heading_updates_counter == 1) { instance.start_heading_updates(); } } void cul::Provider::Controller::stop_heading_updates() { if (--heading_updates_counter == 0) { instance.stop_heading_updates(); } } bool cul::Provider::Controller::are_heading_updates_running() const { return heading_updates_counter > 0; } void cul::Provider::Controller::start_velocity_updates() { if (++velocity_updates_counter == 1) { instance.start_velocity_updates(); } } void cul::Provider::Controller::stop_velocity_updates() { if (--velocity_updates_counter == 0) { instance.stop_velocity_updates(); } } bool cul::Provider::Controller::are_velocity_updates_running() const { return velocity_updates_counter > 0; } const cul::Provider::Controller::Cache>& cul::Provider::Controller::cached_position_update() const { return cached.position; } const cul::Provider::Controller::Cache>& cul::Provider::Controller::cached_heading_update() const { return cached.heading; } const cul::Provider::Controller::Cache>& cul::Provider::Controller::cached_velocity_update() const { return cached.velocity; } cul::Provider::Controller::Controller(cul::Provider& instance) : instance(instance), position_updates_counter(0), heading_updates_counter(0), velocity_updates_counter(0), cached { Cache>{}, Cache>{}, Cache>{} } { position_update_connection = instance.subscribe_to_position_updates( std::bind(&Controller::on_position_updated, this, std::placeholders::_1)); velocity_update_connection = instance.subscribe_to_velocity_updates( std::bind(&Controller::on_velocity_updated, this, std::placeholders::_1)); heading_update_connection = instance.subscribe_to_heading_updates( std::bind(&Controller::on_heading_updated, this, std::placeholders::_1)); } void cul::Provider::Controller::on_position_updated(const cul::Update& position) { cached.position.update(position); } void cul::Provider::Controller::on_velocity_updated(const cul::Update& velocity) { cached.velocity.update(velocity); } void cul::Provider::Controller::on_heading_updated(const cul::Update& heading) { cached.heading.update(heading); } const cul::Provider::Controller::Ptr& cul::Provider::state_controller() const { return controller; } cul::ChannelConnection cul::Provider::subscribe_to_position_updates(std::function&)> f) { return position_updates_channel.connect(f); } cul::ChannelConnection cul::Provider::subscribe_to_heading_updates(std::function&)> f) { return heading_updates_channel.connect(f); } cul::ChannelConnection cul::Provider::subscribe_to_velocity_updates(std::function&)> f) { return velocity_updates_channel.connect(f); } bool cul::Provider::supports(const cul::Provider::Feature& f) const { return feature_flags.test(static_cast(f)); } bool cul::Provider::requires(const cul::Provider::Requirement& r) const { return requirement_flags.test(static_cast(r)); } bool cul::Provider::matches_criteria(const cul::Criteria&) { return false; } cul::Provider::Provider( const cul::Provider::FeatureFlags& feature_flags, const cul::Provider::RequirementFlags& requirement_flags) : feature_flags(feature_flags), requirement_flags(requirement_flags), controller(new Controller(*this)) { } void cul::Provider::deliver_position_updates(const cul::Update& update) { position_updates_channel(update); } void cul::Provider::deliver_heading_updates(const cul::Update& update) { heading_updates_channel(update); } void cul::Provider::deliver_velocity_updates(const cul::Update& update) { velocity_updates_channel(update); } void cul::Provider::start_position_updates() {} void cul::Provider::stop_position_updates() {} void cul::Provider::start_heading_updates() {} void cul::Provider::stop_heading_updates() {} void cul::Provider::start_velocity_updates() {} void cul::Provider::stop_velocity_updates() {} location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/0000755000015201777760000000000012306337604031424 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/config.cpp0000644000015201777760000000430312306337245033376 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include #include #include "dummy/provider.h" #include namespace cul = com::ubuntu::location; namespace { struct FactoryInjector { FactoryInjector(const std::string& name, const std::function& f) { com::ubuntu::location::ProviderFactory::instance().add_factory_for_name(name, f); } }; } static FactoryInjector dummy_injector { "dummy::Provider", com::ubuntu::location::providers::dummy::Provider::create_instance }; #if defined(COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_GEOCLUE) #include static FactoryInjector geoclue_injector { "geoclue::Provider", com::ubuntu::location::providers::geoclue::Provider::create_instance }; #endif // COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_GEOCLUE #if defined(COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_GPS) #include static FactoryInjector gps_injector { "gps::Provider", com::ubuntu::location::providers::gps::Provider::create_instance }; #endif // COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_GPS #if defined(COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_SKYHOOK) #include static FactoryInjector skyhook_injector { "skyhook::Provider", com::ubuntu::location::providers::skyhook::Provider::create_instance }; #endif // COM_UBUNTU_LOCATION_SERVICE_PROVIDERS_SKYHOOK location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/gps/0000755000015201777760000000000012306337604032215 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/gps/CMakeLists.txtlocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/gps/CMakeLi0000644000015201777760000000142512306337245033410 0ustar pbusernogroup00000000000000option( LOCATION_SERVICE_ENABLE_GPS_PROVIDER "Enable location providers relying on the Android HAL to connect to GPS HW" ON ) if (LOCATION_SERVICE_ENABLE_GPS_PROVIDER) find_file( UBUNTU_HARDWARE_GPS_H gps.h NAMES ubuntu/hardware/gps.h ) if (UBUNTU_HARDWARE_GPS_H) message(STATUS "Enabling GPS location provider") add_library(gps provider.cpp) target_link_libraries(gps ubuntu_platform_hardware_api.so) set( ENABLED_PROVIDER_TARGETS ${ENABLED_PROVIDER_TARGETS} gps PARENT_SCOPE) set( ENABLED_PROVIDER_TARGETS_DEFINITIONS -DCOM_UBUNTU_LOCATION_SERVICE_PROVIDERS_GPS ${ENABLED_PROVIDER_TARGETS_DEFINITIONS} PARENT_SCOPE ) endif (UBUNTU_HARDWARE_GPS_H) endif (LOCATION_SERVICE_ENABLE_GPS_PROVIDER)././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/gps/provider.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/gps/provide0000644000015201777760000001603312306337245033614 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/providers/gps/provider.h" #include "com/ubuntu/location/logging.h" #include namespace cul = com::ubuntu::location; namespace culg = com::ubuntu::location::providers::gps; namespace { static const std::map status_lut = { {U_HARDWARE_GPS_STATUS_NONE, "U_HARDWARE_GPS_STATUS_NONE"}, {U_HARDWARE_GPS_STATUS_SESSION_BEGIN, "U_HARDWARE_GPS_STATUS_SESSION_BEGIN"}, {U_HARDWARE_GPS_STATUS_SESSION_END, "U_HARDWARE_GPS_STATUS_SESSION_END"}, {U_HARDWARE_GPS_STATUS_ENGINE_ON, "U_HARDWARE_GPS_STATUS_ENGINE_ON"}, {U_HARDWARE_GPS_STATUS_ENGINE_OFF, "U_HARDWARE_GPS_STATUS_ENGINE_OFF"} }; } struct culg::Provider::Private { static void on_location_update(UHardwareGpsLocation* location, void* context) { auto thiz = static_cast(context); if (location->flags & U_HARDWARE_GPS_LOCATION_HAS_LAT_LONG) { VLOG(1) << "location->flags & U_HARDWARE_GPS_LOCATION_HAS_LAT_LONG"; cul::Position pos; pos.latitude(cul::wgs84::Latitude{location->latitude * cul::units::Degrees}); pos.longitude(cul::wgs84::Longitude{location->longitude * cul::units::Degrees}); if(location->flags & U_HARDWARE_GPS_LOCATION_HAS_ALTITUDE) pos.altitude(cul::wgs84::Altitude{location->altitude * cul::units::Meters}); thiz->deliver_position_updates(cul::Update{pos, cul::Clock::now()}); } if (location->flags & U_HARDWARE_GPS_LOCATION_HAS_SPEED) { VLOG(1) << "location->flags & U_HARDWARE_GPS_LOCATION_HAS_SPEED"; cul::Velocity v{location->speed * cul::units::MetersPerSecond}; thiz->deliver_velocity_updates(cul::Update{v, cul::Clock::now()}); } if (location->flags & U_HARDWARE_GPS_LOCATION_HAS_BEARING) { VLOG(1) << "location->flags & U_HARDWARE_GPS_LOCATION_HAS_BEARING"; cul::Heading h{location->bearing * cul::units::Degrees}; thiz->deliver_heading_updates(cul::Update{h, cul::Clock::now()}); } } static void on_status_update(uint16_t status, void* /*context*/) { SYSLOG(INFO) << "Status = " << status_lut.at(status); } static void on_sv_status_update(UHardwareGpsSvStatus* sv_info, void* /*context*/) { SYSLOG_EVERY_N(INFO, 20) << "SV status update: [#svs: " << sv_info->num_svs << "]"; } static void on_nmea_update(int64_t /*timestamp*/, const char* /*nmea*/, int /*length*/, void* /*context*/) { } static void on_set_capabilities(uint32_t capabilities, void* /*context*/) { VLOG(1) << __PRETTY_FUNCTION__ << ": " << capabilities; } static void on_request_utc_time(void* /*context*/) { VLOG(1) << __PRETTY_FUNCTION__; } static void on_agps_status_update(UHardwareGpsAGpsStatus* /*status*/, void* /*context*/) { VLOG(1) << __PRETTY_FUNCTION__; } static void on_gps_ni_notification(UHardwareGpsNiNotification* /*notification*/, void* /*context*/) { VLOG(1) << __PRETTY_FUNCTION__; } static void on_agps_ril_request_set_id(uint32_t /*flags*/, void* /*context*/) { VLOG(1) << __PRETTY_FUNCTION__; } static void on_agps_ril_request_ref_lock(uint32_t /*flags*/, void* /*context*/) { VLOG(1) << __PRETTY_FUNCTION__; } static void on_gps_xtra_download_request(void*) { VLOG(1) << __PRETTY_FUNCTION__; } void start() { u_hardware_gps_start(gps_handle); } void stop() { u_hardware_gps_stop(gps_handle); } UHardwareGpsParams gps_params; UHardwareGps gps_handle; }; std::string culg::Provider::class_name() { return "gps::Provider"; } cul::Provider::Ptr culg::Provider::create_instance(const cul::ProviderFactory::Configuration&) { return cul::Provider::Ptr{new culg::Provider{}}; } const cul::Provider::FeatureFlags& culg::Provider::default_feature_flags() { static const cul::Provider::FeatureFlags flags{"001"}; return flags; } const cul::Provider::RequirementFlags& culg::Provider::default_requirement_flags() { static const cul::Provider::RequirementFlags flags{"1010"}; return flags; } culg::Provider::Provider() : cul::Provider( culg::Provider::default_feature_flags(), culg::Provider::default_requirement_flags()), d(new Private()) { d->gps_params.location_cb = culg::Provider::Private::on_location_update; d->gps_params.status_cb = culg::Provider::Private::on_status_update; d->gps_params.sv_status_cb = culg::Provider::Private::on_sv_status_update; d->gps_params.nmea_cb = culg::Provider::Private::on_nmea_update; d->gps_params.set_capabilities_cb = culg::Provider::Private::on_set_capabilities; d->gps_params.request_utc_time_cb = culg::Provider::Private::on_request_utc_time; d->gps_params.xtra_download_request_cb = culg::Provider::Private::on_gps_xtra_download_request; d->gps_params.agps_status_cb = culg::Provider::Private::on_agps_status_update; d->gps_params.gps_ni_notify_cb = culg::Provider::Private::on_gps_ni_notification; d->gps_params.request_setid_cb = culg::Provider::Private::on_agps_ril_request_set_id; d->gps_params.request_refloc_cb = culg::Provider::Private::on_agps_ril_request_ref_lock; d->gps_params.context = this; d->gps_handle = u_hardware_gps_new(std::addressof(d->gps_params)); static const std::chrono::milliseconds minimum_interval{500}; static const uint32_t preferred_accuracy{0}; static const uint32_t preferred_time_to_first_fix{0}; u_hardware_gps_set_position_mode( d->gps_handle, U_HARDWARE_GPS_POSITION_MODE_MS_BASED, U_HARDWARE_GPS_POSITION_RECURRENCE_PERIODIC, minimum_interval.count(), preferred_accuracy, preferred_time_to_first_fix ); } culg::Provider::~Provider() noexcept { d->stop(); u_hardware_gps_delete(d->gps_handle); } bool culg::Provider::matches_criteria(const cul::Criteria&) { return true; } void culg::Provider::start_position_updates() { d->start(); } void culg::Provider::stop_position_updates() { d->stop(); } void culg::Provider::start_velocity_updates() { d->start(); } void culg::Provider::stop_velocity_updates() { d->stop(); } void culg::Provider::start_heading_updates() { d->start(); } void culg::Provider::stop_heading_updates() { d->stop(); } ././@LongLink0000000000000000000000000000015000000000000011211 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/CMakeLists.txtlocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/CMakeLists.0000644000015201777760000000043212306337245033424 0ustar pbusernogroup00000000000000add_subdirectory(dummy) add_subdirectory(geoclue) add_subdirectory(gps) add_subdirectory(skyhook) set( ENABLED_PROVIDER_TARGETS ${ENABLED_PROVIDER_TARGETS} PARENT_SCOPE ) set( ENABLED_PROVIDER_TARGETS_DEFINITIONS ${ENABLED_PROVIDER_TARGETS_DEFINITIONS} PARENT_SCOPE ) location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/geoclue/0000755000015201777760000000000012306337604033047 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/geoclue/CMakeLists.txtlocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/geoclue/CMa0000644000015201777760000000113112306337245033427 0ustar pbusernogroup00000000000000option( LOCATION_SERVICE_ENABLE_GEOCLUE_PROVIDER "Enable location provider connecting to existing geoclue providers" ON ) if (LOCATION_SERVICE_ENABLE_GEOCLUE_PROVIDER) message(STATUS "Enabling support for Geoclue location providers") add_library(geoclue provider.cpp) set( ENABLED_PROVIDER_TARGETS ${ENABLED_PROVIDER_TARGETS} geoclue PARENT_SCOPE ) set( ENABLED_PROVIDER_TARGETS_DEFINITIONS -DCOM_UBUNTU_LOCATION_SERVICE_PROVIDERS_GEOCLUE ${ENABLED_PROVIDER_TARGETS_DEFINITIONS} PARENT_SCOPE ) endif (LOCATION_SERVICE_ENABLE_GEOCLUE_PROVIDER)././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/geoclue/provider.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/geoclue/pro0000644000015201777760000001743312306337245033603 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/providers/geoclue/provider.h" #include "com/ubuntu/location/providers/geoclue/geoclue.h" #include "core/dbus/object.h" #include "core/dbus/signal.h" #include namespace cul = com::ubuntu::location; namespace culpg = com::ubuntu::location::providers::geoclue; namespace dbus = core::dbus; namespace { dbus::Bus::Ptr the_session_bus() { static dbus::Bus::Ptr session_bus = std::make_shared(dbus::WellKnownBus::session); return session_bus; } } struct culpg::Provider::Private { Private(const culpg::Provider::Configuration& config) : bus(the_session_bus()), service(dbus::Service::use_service(bus, config.name)), object(service->object_for_path(config.path)), signal_position_changed(object->get_signal()), signal_velocity_changed(object->get_signal()) { } void start() { if (!worker.joinable()) worker = std::move(std::thread{std::bind(&dbus::Bus::run, bus)}); } void stop() { bus->stop(); if (worker.joinable()) worker.join(); } dbus::Bus::Ptr bus; dbus::Service::Ptr service; dbus::Object::Ptr object; dbus::Signal< org::freedesktop::Geoclue::Position::Signals::PositionChanged, org::freedesktop::Geoclue::Position::Signals::PositionChanged::ArgumentType >::Ptr signal_position_changed; dbus::Signal< org::freedesktop::Geoclue::Velocity::Signals::VelocityChanged, org::freedesktop::Geoclue::Velocity::Signals::VelocityChanged::ArgumentType >::Ptr signal_velocity_changed; typedef typename dbus::Signal< org::freedesktop::Geoclue::Position::Signals::PositionChanged, org::freedesktop::Geoclue::Position::Signals::PositionChanged::ArgumentType >::SubscriptionToken SignalPositionChangedSubscription; typedef typename dbus::Signal< org::freedesktop::Geoclue::Velocity::Signals::VelocityChanged, org::freedesktop::Geoclue::Velocity::Signals::VelocityChanged::ArgumentType >::SubscriptionToken SignalVelocityChangedSubscription; SignalPositionChangedSubscription position_updates_connection; SignalVelocityChangedSubscription velocity_updates_connection; std::thread worker; }; cul::Provider::Ptr culpg::Provider::create_instance(const cul::ProviderFactory::Configuration& config) { culpg::Provider::Configuration pConfig; pConfig.name = config.count(Configuration::key_name()) > 0 ? config.get(Configuration::key_name()) : throw std::runtime_error("Missing bus-name"); pConfig.path = config.count(Configuration::key_path()) > 0 ? config.get(Configuration::key_path()) : throw std::runtime_error("Missing bus-path"); return cul::Provider::Ptr{new culpg::Provider{pConfig}}; } const cul::Provider::FeatureFlags& culpg::Provider::default_feature_flags() { static const cul::Provider::FeatureFlags flags{"001"}; return flags; } const cul::Provider::RequirementFlags& culpg::Provider::default_requirement_flags() { static const cul::Provider::RequirementFlags flags{"1010"}; return flags; } culpg::Provider::Provider(const culpg::Provider::Configuration& config) : com::ubuntu::location::Provider(config.features, config.requirements), d(new Private(config)) { d->position_updates_connection = d->signal_position_changed->connect( [this](const org::freedesktop::Geoclue::Position::Signals::PositionChanged::ArgumentType& arg) { org::freedesktop::Geoclue::Position::FieldFlags flags{static_cast(std::get<0>(arg))}; cul::Update update { { flags.test(org::freedesktop::Geoclue::Position::Field::latitude) ? cul::wgs84::Latitude{std::get<2>(arg)* cul::units::Degrees} : cul::wgs84::Latitude{}, flags.test(org::freedesktop::Geoclue::Position::Field::longitude) ? cul::wgs84::Longitude{std::get<3>(arg)* cul::units::Degrees} : cul::wgs84::Longitude{}, flags.test(org::freedesktop::Geoclue::Position::Field::altitude) ? cul::wgs84::Altitude{std::get<4>(arg)* cul::units::Meters} : cul::wgs84::Altitude{} }, cul::Clock::now() }; this->deliver_position_updates(update); }); d->velocity_updates_connection = d->signal_velocity_changed->connect( [this](const org::freedesktop::Geoclue::Velocity::Signals::VelocityChanged::ArgumentType& arg) { org::freedesktop::Geoclue::Velocity::FieldFlags flags{static_cast(std::get<0>(arg))}; if (flags.none()) return; if (flags.test(org::freedesktop::Geoclue::Velocity::Field::speed)) { cul::Update update { std::get<2>(arg) * cul::units::MetersPerSecond, cul::Clock::now() }; this->deliver_velocity_updates(update); } if (flags.test(org::freedesktop::Geoclue::Velocity::Field::direction)) { cul::Update update { std::get<3>(arg) * cul::units::Degrees, cul::Clock::now() }; this->deliver_heading_updates(update); } }); auto info = d->object->invoke_method_synchronously< org::freedesktop::Geoclue::GetProviderInfo, org::freedesktop::Geoclue::GetProviderInfo::ResultType>(); auto status = d->object->invoke_method_synchronously< org::freedesktop::Geoclue::GetStatus, org::freedesktop::Geoclue::GetStatus::ResultType>(); std::cout << "GeoclueProvider: [" << std::get<0>(info.value()) << ", " << std::get<1>(info.value()) << "," << static_cast(status.value()) << "]" <stop(); } bool culpg::Provider::matches_criteria(const cul::Criteria&) { return true; } void culpg::Provider::start_position_updates() { d->start(); } void culpg::Provider::stop_position_updates() { d->stop(); } void culpg::Provider::start_velocity_updates() { d->start(); } void culpg::Provider::stop_velocity_updates() { d->stop(); } void culpg::Provider::start_heading_updates() { d->start(); } void culpg::Provider::stop_heading_updates() { d->stop(); } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/skyhook/0000755000015201777760000000000012306337604033113 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000016000000000000011212 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/skyhook/CMakeLists.txtlocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/skyhook/CMa0000644000015201777760000000165412306337245033505 0ustar pbusernogroup00000000000000option( LOCATION_SERVICE_ENABLE_SKYHOOK_PROVIDER "Enable location provider relying on the Skyhook SDK" ON ) if (LOCATION_SERVICE_ENABLE_SKYHOOK_PROVIDER) pkg_check_modules(WPSAPI wpsapi) if (WPSAPI_FOUND) message(STATUS "Enabling support for Skyhook location providers") add_definitions(-DCOM_UBUNTU_LOCATION_SERVICE_PROVIDERS_SKYHOOK) include_directories(${WPSAPI_INCLUDE_DIRS}) link_directories(${WPSAPI_LIBRARY_DIRS}) add_library(skyhook provider.cpp) target_link_libraries( skyhook ${WPSAPI_LIBRARIES} iw ) set( ENABLED_PROVIDER_TARGETS skyhook ${ENABLED_PROVIDER_TARGETS} PARENT_SCOPE ) set( ENABLED_PROVIDER_TARGETS_DEFINITIONS -DCOM_UBUNTU_LOCATION_SERVICE_PROVIDERS_SKYHOOK ${ENABLED_PROVIDER_TARGETS_DEFINITIONS} PARENT_SCOPE ) endif (WPSAPI_FOUND) endif (LOCATION_SERVICE_ENABLE_SKYHOOK_PROVIDER) ././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/skyhook/provider.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/skyhook/pro0000644000015201777760000001541512306337245033645 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/providers/skyhook/provider.h" #include "com/ubuntu/location/logging.h" #include "com/ubuntu/location/provider_factory.h" #pragma GCC diagnostic push #pragma GCC diagnostic warning "-Wignored-qualifiers" #include #pragma GCC diagnostic pop #include #include namespace cul = com::ubuntu::location; namespace culs = com::ubuntu::location::providers::skyhook; namespace { static const std::map return_code_lut = { {WPS_OK, "WPS_OK"}, {WPS_ERROR_SCANNER_NOT_FOUND, "WPS_ERROR_SCANNER_NOT_FOUND"}, {WPS_ERROR_WIFI_NOT_AVAILABLE, "WPS_ERROR_WIFI_NOT_AVAILABLE"}, {WPS_ERROR_NO_WIFI_IN_RANGE, "WPS_ERROR_NO_WIFI_IN_RANGE"}, {WPS_ERROR_UNAUTHORIZED, "WPS_ERROR_UNAUTHORIZED"}, {WPS_ERROR_SERVER_UNAVAILABLE, "WPS_ERROR_SERVER_UNAVAILABLE"}, {WPS_ERROR_LOCATION_CANNOT_BE_DETERMINED, "WPS_ERROR_LOCATION_CANNOT_BE_DETERMINED"}, {WPS_ERROR_PROXY_UNAUTHORIZED, "WPS_ERROR_PROXY_UNAUTHORIZED"}, {WPS_ERROR_FILE_IO, "WPS_ERROR_FILE_IO"}, {WPS_ERROR_INVALID_FILE_FORMAT, "WPS_ERROR_INVALID_FILE_FORMAT"}, {WPS_ERROR_TIMEOUT, "WPS_ERROR_TIMEOUT"}, {WPS_NOT_APPLICABLE, "WPS_NOT_APPLICABLE"}, {WPS_GEOFENCE_ERROR, "WPS_GEOFENCE_ERROR"}, {WPS_ERROR_NOT_TUNED, "WPS_ERROR_NOT_TUNED"}, {WPS_NOMEM, "WPS_NOMEM"}, {WPS_ERROR, "WPS_ERROR"} }; } struct culs::Provider::Private { enum class State { stopped, started, stop_requested }; static WPS_Continuation periodic_callback( void* context, WPS_ReturnCode code, const WPS_Location* location, const void*); Private( const culs::Provider::Configuration& config, culs::Provider* parent) : parent(parent), config(config), state(State::stopped) { } void start() { if (state != State::stopped) return; if (worker.joinable()) worker.join(); static const unsigned infinite_iterations = 0; authentication.username = config.user_name.c_str(); authentication.realm = config.realm.c_str(); worker = std::move(std::thread([&]() { int rc = WPS_periodic_location( &authentication, WPS_NO_STREET_ADDRESS_LOOKUP, config.period.count(), infinite_iterations, culs::Provider::Private::periodic_callback, this); if (rc != WPS_OK) LOG(ERROR) << return_code_lut.at(rc); })); state = State::started; } void request_stop() { state = State::stop_requested; } culs::Provider* parent; Configuration config; State state; WPS_SimpleAuthentication authentication; std::thread worker; }; WPS_Continuation culs::Provider::Private::periodic_callback(void* context, WPS_ReturnCode code, const WPS_Location* location, const void*) { if (code != WPS_OK) { LOG(WARNING) << return_code_lut.at(code); if (code == WPS_ERROR_WIFI_NOT_AVAILABLE) return WPS_STOP; return WPS_CONTINUE; } auto thiz = static_cast(context); if (thiz->state == culs::Provider::Private::State::stop_requested) { LOG(INFO) << "Stop requested"; thiz->state = culs::Provider::Private::State::stopped; return WPS_STOP; } cul::Position pos; pos.latitude(cul::wgs84::Latitude{location->latitude * cul::units::Degrees}) .longitude(cul::wgs84::Longitude{location->longitude * cul::units::Degrees}); if (location->altitude >= 0.f) pos.altitude(cul::wgs84::Altitude{location->altitude * cul::units::Meters}); LOG(INFO) << pos; thiz->parent->deliver_position_updates(cul::Update{pos, cul::Clock::now()}); if (location->speed >= 0.f) { cul::Velocity v{location->speed * cul::units::MetersPerSecond}; LOG(INFO) << v; thiz->parent->deliver_velocity_updates(cul::Update{v, cul::Clock::now()}); } if (location->bearing >= 0.f) { cul::Heading h{location->bearing * cul::units::Degrees}; LOG(INFO) << h; thiz->parent->deliver_heading_updates(cul::Update{h, cul::Clock::now()}); } return WPS_CONTINUE; } cul::Provider::Ptr culs::Provider::create_instance(const cul::ProviderFactory::Configuration& config) { culs::Provider::Configuration configuration { config.get(Configuration::key_username(), ""), config.get(Configuration::key_realm(), ""), std::chrono::milliseconds{config.get(Configuration::key_period(), 500)} }; return cul::Provider::Ptr{new culs::Provider{configuration}}; } const cul::Provider::FeatureFlags& culs::Provider::default_feature_flags() { static const cul::Provider::FeatureFlags flags{"001"}; return flags; } const cul::Provider::RequirementFlags& culs::Provider::default_requirement_flags() { static const cul::Provider::RequirementFlags flags{"1010"}; return flags; } culs::Provider::Provider(const culs::Provider::Configuration& config) : com::ubuntu::location::Provider(culs::Provider::default_feature_flags(), culs::Provider::default_requirement_flags()), d(new Private(config, this)) { } culs::Provider::~Provider() noexcept { d->request_stop(); } bool culs::Provider::matches_criteria(const cul::Criteria&) { return true; } void culs::Provider::start_position_updates() { d->start(); } void culs::Provider::stop_position_updates() { d->request_stop(); } void culs::Provider::start_velocity_updates() { d->start(); } void culs::Provider::stop_velocity_updates() { d->request_stop(); } void culs::Provider::start_heading_updates() { d->start(); } void culs::Provider::stop_heading_updates() { d->request_stop(); } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/dummy/0000755000015201777760000000000012306337604032557 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015600000000000011217 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/dummy/CMakeLists.txtlocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/dummy/CMake0000644000015201777760000000021212306337245033456 0ustar pbusernogroup00000000000000add_library( dummy provider.h provider.cpp) set( ENABLED_PROVIDER_TARGETS ${ENABLED_PROVIDER_TARGETS} dummy PARENT_SCOPE) ././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/dummy/provider.hlocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/dummy/provi0000644000015201777760000000444612306337245033652 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_DUMMY_PROVIDER_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_DUMMY_PROVIDER_H_ #include #include namespace com { namespace ubuntu { namespace location { namespace providers { namespace dummy { struct Configuration { inline static const char* key_update_period() { return "dummy::UpdatePeriodInMs"; } inline static const char* key_reference_position_lat() { return "ReferenceLocationLat"; } inline static const char* key_reference_position_lon() { return "ReferenceLocationLon"; } std::chrono::milliseconds update_period{500}; Position reference_position { wgs84::Latitude{9. * units::Degrees}, wgs84::Longitude{53. * units::Degrees}, wgs84::Altitude{-2. * units::Meters} }; }; class Provider : public com::ubuntu::location::Provider { public: // For integration with the Provider factory. static std::string class_name(); static Provider::Ptr create_instance(const ProviderFactory::Configuration&); Provider(const Configuration& config = Configuration{}); Provider(const Provider&) = delete; Provider& operator=(const Provider&) = delete; ~Provider() noexcept; // From Provider bool matches_criteria(const Criteria&); void start_position_updates(); void stop_position_updates(); private: struct Private; std::unique_ptr d; }; } } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_PROVIDERS_DUMMY_PROVIDER_H_ ././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/dummy/provider.cpplocation-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/providers/dummy/provi0000644000015201777760000000723312306337245033647 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "provider.h" #include #include namespace location = com::ubuntu::location; namespace dummy = com::ubuntu::location::providers::dummy; struct dummy::Provider::Private { enum class State { started, stopping, stopped }; Private(const dummy::Configuration& configuration) : configuration(configuration), state(State::stopped) { } dummy::Configuration configuration; std::atomic state; bool stop_requested; std::thread worker{}; }; std::string dummy::Provider::class_name() { return "dummy::Provider"; } location::Provider::Ptr dummy::Provider::create_instance(const location::ProviderFactory::Configuration& config) { dummy::Configuration provider_config; provider_config.update_period = std::chrono::milliseconds { config.get(dummy::Configuration::key_update_period(), 500) }; provider_config.reference_position.latitude(wgs84::Latitude { config.get(dummy::Configuration::key_reference_position_lat(), 51.) * units::Degrees }); provider_config.reference_position.longitude(wgs84::Longitude { config.get(dummy::Configuration::key_reference_position_lon(), 7.) * units::Degrees }); return location::Provider::Ptr{new dummy::Provider{provider_config}}; } namespace { location::Provider::FeatureFlags features{"111"}; location::Provider::RequirementFlags requirements{"0000"}; } dummy::Provider::Provider(const dummy::Configuration& config) : location::Provider(features, requirements), d(new Private{config}) { } dummy::Provider::~Provider() noexcept { stop_position_updates(); } bool dummy::Provider::matches_criteria(const location::Criteria&) { return true; } void dummy::Provider::start_position_updates() { if (d->state.load() != Private::State::stopped) return; d->stop_requested = false; d->worker = std::move(std::thread([this]() { d->state.store(Private::State::started); VLOG(1) << "dummy::Provider::start_position_updates: started"; location::Update update { d->configuration.reference_position, location::Clock::now() }; timespec ts {0, d->configuration.update_period.count() * 1000 * 1000}; while (!d->stop_requested) { update.when = location::Clock::now(); deliver_position_updates(update); ::nanosleep(&ts, nullptr); } })); d->state.store(Private::State::stopped); VLOG(1) << "dummy::Provider::start_position_updates: stopped"; } void dummy::Provider::stop_position_updates() { if (d->state.load() != Private::State::started) return; d->state.store(Private::State::stopping); VLOG(1) << "dummy::Provider::stop_position_updates: stopping"; if (d->worker.joinable()) { d->stop_requested = true; d->worker.join(); } } location-service-0.0.2+14.04.20140307/src/location_service/com/ubuntu/location/engine.cpp0000644000015201777760000000351212306337245031362 0ustar pbusernogroup00000000000000/* * Copyright © 2012-2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #include "com/ubuntu/location/engine.h" #include namespace cul = com::ubuntu::location; cul::Engine::Engine(const std::set& initial_providers, const cul::ProviderSelectionPolicy::Ptr& provider_selection_policy) : providers(initial_providers), provider_selection_policy(provider_selection_policy) { if (!provider_selection_policy) std::runtime_error("Cannot construct an engine given a null ProviderSelectionPolicy"); } cul::ProviderSelection cul::Engine::determine_provider_selection_for_criteria(const cul::Criteria& criteria) { return provider_selection_policy->determine_provider_selection_from_set_for_criteria(criteria, providers); } bool cul::Engine::has_provider(const cul::Provider::Ptr& provider) noexcept { return providers.count(provider) > 0; } void cul::Engine::add_provider(const cul::Provider::Ptr& provider) { if (!provider) throw std::runtime_error("Cannot add null provider"); providers.insert(provider); } void cul::Engine::remove_provider(const cul::Provider::Ptr& provider) noexcept { providers.erase(provider); } location-service-0.0.2+14.04.20140307/src/location_service/com/CMakeLists.txt0000644000015201777760000000003012306337245027007 0ustar pbusernogroup00000000000000add_subdirectory(ubuntu)location-service-0.0.2+14.04.20140307/src/CMakeLists.txt0000644000015201777760000000004212306337245022704 0ustar pbusernogroup00000000000000add_subdirectory(location_service)location-service-0.0.2+14.04.20140307/data/0000755000015201777760000000000012306337604020271 5ustar pbusernogroup00000000000000location-service-0.0.2+14.04.20140307/data/ubuntu-location-service.pc.in0000644000015201777760000000102112306337245026003 0ustar pbusernogroup00000000000000prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${exec_prefix}/include Name: @CMAKE_PROJECT_NAME@ Description: A location service aggregating position/velocity/heading updates and exporting them over dbus. Version: @UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@.@UBUNTU_LOCATION_SERVICE_VERSION_MINOR@.@UBUNTU_LOCATION_SERVICE_VERSION_PATCH@ Libs: -L${libdir} -lubuntu-location-service Cflags: -I${includedir}/ubuntu-location-service-@UBUNTU_LOCATION_SERVICE_VERSION_MAJOR@ Requires: dbus-cpplocation-service-0.0.2+14.04.20140307/data/CMakeLists.txt0000644000015201777760000000223612306337245023035 0ustar pbusernogroup00000000000000# Copyright © 2013 Canonical Ltd. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Authored by: Thomas Voss configure_file( ubuntu-location-service.pc.in ubuntu-location-service.pc @ONLY ) configure_file( ubuntu-location-service.conf.in ubuntu-location-service.conf @ONLY ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/ubuntu-location-service.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig ) install( FILES ${CMAKE_CURRENT_SOURCE_DIR}/com.ubuntu.location.Service.conf DESTINATION /etc/dbus-1/system.d/ ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/ubuntu-location-service.conf DESTINATION /etc/init/ ) location-service-0.0.2+14.04.20140307/data/com.ubuntu.location.Service.conf0000644000015201777760000000174712306337245026457 0ustar pbusernogroup00000000000000 location-service-0.0.2+14.04.20140307/data/ubuntu-location-service.conf.in0000644000015201777760000000021612306337245026333 0ustar pbusernogroup00000000000000description "Location Services" start on started dbus respawn exec /usr/bin/ubuntu-location-serviced --bus system --provider gps::Provider