connectivity-api-0.0.1+14.04.20140312/0000755000015201777760000000000012307723764017401 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/include/0000755000015201777760000000000012307723764021024 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/include/com/0000755000015201777760000000000012307723764021602 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/0000755000015201777760000000000012307723764023124 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/0000755000015201777760000000000012307723764025642 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/0000755000015201777760000000000012307723764030031 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/link.h0000644000015201777760000000603212307723555031136 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef COM_UBUNTU_CONNECTIVITY_NETWORKING_LINK #define COM_UBUNTU_CONNECTIVITY_NETWORKING_LINK #include namespace com { namespace ubuntu { namespace connectivity { namespace networking { #ifndef CONNECTIVITY_CPP_EXPORT #define CONNECTIVITY_CPP_EXPORT __attribute ((visibility ("default"))) #endif class CONNECTIVITY_CPP_EXPORT Link { public: typedef std::shared_ptr Ptr; Link(const Link&) = delete; virtual ~Link() = default; Link& operator=(const Link&) = delete; bool operator==(const Link&) const = delete; /// @private enum class Type { wifi, wired, wwan, service }; /// @private enum class Status { disabled, offline, connecting, // link is in process of becoming online connected, // the link is up, but not fully configured yet // happens with wifi for example when captive portal // login is required online }; /** * @brief Characteristics of the link. * \see Manager::characteristics */ enum Characteristics : std::uint32_t { /** No special characteristics. */ empty = 0, /** * The link has monetary costs, * No data should be transfered before getting confirmation from the user. */ has_monetary_costs = 1 << 0, /** * The link has limited volume. * No large files should be transfered before getting a confirmation from the user. */ is_volume_limited = 1 << 1, /** * The link has limited bandwith. * Large transfer should be postponed until high bandwith link becomes available. */ is_bandwidth_limited = 1 << 2 }; /// @private virtual void enable() = 0; /// @private virtual void disable() = 0; /// @private virtual Type type() const = 0; /// @private virtual const core::Property& characteristics() = 0; /// @private virtual const core::Property& status() = 0; /// @private typedef unsigned int Id; /// @private virtual Id id() const = 0; /// @private virtual std::string name() const = 0; protected: /// @private Link() = default; }; } } } } #endif connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/manager.h0000644000015201777760000000777212307723555031627 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef COM_UBUNTU_CONNECTIVITY_NETWORKING_MANAGER #define COM_UBUNTU_CONNECTIVITY_NETWORKING_MANAGER #include #include #include #include #include namespace com { namespace ubuntu { namespace connectivity { namespace networking { #ifndef CONNECTIVITY_CPP_EXPORT #define CONNECTIVITY_CPP_EXPORT __attribute ((visibility ("default"))) #endif /** * @brief networking manager * * This is the top-level manager class for accessing networking information. * * A new instance of this class can only be created using the static Manager::createInstance(). * * For system networking status, see Manager::status. * For connection characteristics, see Manager::characteristics. * * Examples: * - \ref networking-status "Getting the networking status." */ class CONNECTIVITY_CPP_EXPORT Manager { public: Manager &operator=(const Manager&) = delete; virtual ~Manager() = default; Manager(const Manager&) = delete; /** * @brief Creates a new instance of a networking Manager. * * \snippet example_networking_status.cpp create manager * * Applications should call this function just once. * If application needs to share the instance internally the std::unique_ptr * can be transformed into a std::shared_ptr: * @code * std::shared_ptr mgr{std::move(Manager::createInstance())}; * @endcode * * @note This call may block. * * @return std::unique_ptr to new instance of a networking manager. */ static std::unique_ptr createInstance(); /// @private enum class FlightModeStatus { on, off }; /** * @brief enum class for networking status * * Networking status may be accessed through the Manager::status property. */ enum class NetworkingStatus { /** No Internet connection available. */ offline, /** System is actively establising a connection. */ connecting, /** System is connected to the Internet. */ online }; /// @private virtual void enableFlightMode() = 0; /// @private virtual void disableFlightMode() = 0; /// @private virtual const core::Property& flightMode() = 0; /// @private virtual const core::Property>& links() = 0; /// @private virtual const core::Property>& services() = 0; /** * status of the overall system networking * * \snippet example_networking_status.cpp subscribe networking status changes */ virtual const core::Property &status() = 0; /** * characteristics of the overall system networking * * the value is a bitfield and the individial bits are defined * in Link::Characteristics. * * \snippet example_networking_status.cpp subscribe characteristics changes */ virtual const core::Property& characteristics() = 0; protected: /** * @brief The default constructor is protected. * * To create an instance of the networking manager call Manager::createInstance(). * */ Manager(); }; } } } } #endif connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/service/0000755000015201777760000000000012307723764031471 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/service/vpn/0000755000015201777760000000000012307723764032274 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000014700000000000011217 Lustar 00000000000000connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/service/vpn/service.hconnectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/service/vpn/service0000644000015201777760000000247212307723555033662 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef COM_UBUNTU_CONNECTIVITY_NETWORKING_SERVICE_VPN_SERVICE #define COM_UBUNTU_CONNECTIVITY_NETWORKING_SERVICE_VPN_SERVICE #include namespace com { namespace ubuntu { namespace connectivity { namespace networking { namespace service { namespace vpn { /// @private class Service : public com::ubuntu::connectivity::networking::Service { public: typedef std::shared_ptr Ptr; virtual ~Service() = default; virtual const core::Property> &establishedOver() = 0; protected: Service() = default; }; } } } } } } #endif connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/service/tor/0000755000015201777760000000000012307723764032275 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000014700000000000011217 Lustar 00000000000000connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/service/tor/service.hconnectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/service/tor/service0000644000015201777760000000242512307723555033661 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef COM_UBUNTU_CONNECTIVITY_NETWORKING_SERVICE_TOR_SERVICE #define COM_UBUNTU_CONNECTIVITY_NETWORKING_SERVICE_TOR_SERVICE #include namespace com { namespace ubuntu { namespace connectivity { namespace networking { namespace service { namespace tor { /// @private class Service : public com::ubuntu::connectivity::networking::Service { public: typedef std::shared_ptr Ptr; virtual ~Service() = default; virtual const core::Property> &establishedOver() = 0; }; } } } } } } #endif connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/service/tethering/0000755000015201777760000000000012307723764033462 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/service/tethering/service.hconnectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/service/tethering/s0000644000015201777760000000276612307723555033660 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef COM_UBUNTU_CONNECTIVITY_NETWORKING_SERVICE_TETHERING_SERVICE #define COM_UBUNTU_CONNECTIVITY_NETWORKING_SERVICE_TETHERING_SERVICE #include namespace com { namespace ubuntu { namespace connectivity { namespace networking { namespace service { namespace tethering { /// @private class Service : public com::ubuntu::connectivity::networking::Service { public: typedef std::shared_ptr Ptr; virtual ~Service() = default; /* * Which link is shared to the client devices. */ const Property> &shared() = 0; /* * Which link is used to serve the clients. */ const Property> &sharedOver() = 0; protected: Service() = default; }; } } } } } } #endif connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/wwan/0000755000015201777760000000000012307723764031005 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/wwan/link.h0000644000015201777760000000271112307723555032112 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef COM_UBUNTU_CONNECTIVITY_NETWORKING_WWAN_DEVICE #define COM_UBUNTU_CONNECTIVITY_NETWORKING_WWAN_DEVICE #include #include #include namespace com { namespace ubuntu { namespace connectivity { namespace networking { namespace wwan { #ifndef CONNECTIVITY_CPP_EXPORT #define CONNECTIVITY_CPP_EXPORT __attribute ((visibility ("default"))) #endif class CONNECTIVITY_CPP_EXPORT Link : public com::ubuntu::connectivity::networking::Link { public: typedef std::shared_ptr Ptr; enum class Type { GSM, CDMA, BLUETOOTH_DUN, BLUETOOTH_PAN }; virtual ~Link() {} virtual State state() const = 0; virtual Type wwanType() const = 0; }; } } } } #endif connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/wifi/0000755000015201777760000000000012307723764030767 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/wifi/link.h0000644000015201777760000000326612307723555032102 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef COM_UBUNTU_CONNECTIVITY_NETWORKING_WIFI_LINK #define COM_UBUNTU_CONNECTIVITY_NETWORKING_WIFI_LINK #include #include #include #include namespace com { namespace ubuntu { namespace connectivity { namespace networking { namespace wifi { #ifndef CONNECTIVITY_CPP_EXPORT #define CONNECTIVITY_CPP_EXPORT __attribute ((visibility ("default"))) #endif /// @private class CONNECTIVITY_CPP_EXPORT Link : public com::ubuntu::connectivity::networking::Link { public: typedef std::shared_ptr Ptr; typedef unsigned int Id; Link() = default; Link(const Link&) = delete; virtual ~Link() = default; virtual const core::Property>& accessPoints() = 0; virtual void connect_to(AccessPoint::Ptr accessPoint) = 0; virtual const core::Property& activeAccessPoint() = 0; }; } } } } } #endif connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/wifi/access-point.h0000644000015201777760000000274012307723555033531 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef COM_UBUNTU_CONNECTIVITY_NETWORKING_WIFI_ACCESS_POINT #define COM_UBUNTU_CONNECTIVITY_NETWORKING_WIFI_ACCESS_POINT #include #include namespace com { namespace ubuntu { namespace connectivity { namespace networking { namespace wifi { #ifndef CONNECTIVITY_CPP_EXPORT #define CONNECTIVITY_CPP_EXPORT __attribute ((visibility ("default"))) #endif /// @private class CONNECTIVITY_CPP_EXPORT AccessPoint { public: typedef std::shared_ptr Ptr; virtual ~AccessPoint() = default; /* from 0.00 to 100.00, * -1 not available */ virtual const core::Property& strength() = 0; virtual std::string ssid() = 0; virtual bool secured() = 0; virtual bool adhoc() = 0; }; } } } } } #endif connectivity-api-0.0.1+14.04.20140312/include/com/ubuntu/connectivity/networking/service.h0000644000015201777760000000375512307723555031652 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef COM_UBUNTU_CONNECTIVITY_NETWORKING_SERVICE #define COM_UBUNTU_CONNECTIVITY_NETWORKING_SERVICE #include #include namespace com { namespace ubuntu { namespace connectivity { namespace networking { #ifndef CONNECTIVITY_CPP_EXPORT #define CONNECTIVITY_CPP_EXPORT __attribute ((visibility ("default"))) #endif /// @private class CONNECTIVITY_CPP_EXPORT Service { public: typedef std::shared_ptr Ptr; enum class Type { vpn, tethering, tor }; virtual Type type() const = 0; enum class Status { stopped, starting, running }; virtual const core::Property& status() = 0; // which other Service this service requires to be active // before it can be activated virtual std::shared_ptr requires() = 0; // possible link this service provides. // check with: // if (service->link()) { // // we have a link coming from the service // do_something_with(link); // } virtual Link::Ptr link() = 0; virtual void start() = 0; virtual void stop() = 0; typedef unsigned int Id; virtual Id id() const = 0; virtual core::Property& name() = 0; }; } } } } #endif connectivity-api-0.0.1+14.04.20140312/cmake/0000755000015201777760000000000012307723764020461 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/cmake/modules/0000755000015201777760000000000012307723764022131 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/cmake/modules/Findgcovr.cmake0000644000015201777760000000170212307723555025052 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) connectivity-api-0.0.1+14.04.20140312/cmake/modules/ParseArguments.cmake0000644000015201777760000000340612307723555026074 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) connectivity-api-0.0.1+14.04.20140312/cmake/modules/FindGtest.cmake0000644000015201777760000000337212307723555025025 0ustar pbusernogroup00000000000000include(ExternalProject) include(FindPackageHandleStandardArgs) #gtest set(GTEST_INSTALL_DIR /usr/src/gmock/gtest/include) find_path(GTEST_INCLUDE_DIR gtest/gtest.h HINTS ${GTEST_INSTALL_DIR}) #gmock find_path(GMOCK_INSTALL_DIR gmock/CMakeLists.txt HINTS /usr/src) if(${GMOCK_INSTALL_DIR} STREQUAL "GMOCK_INSTALL_DIR-NOTFOUND") message(FATAL_ERROR "google-mock package not found") endif() set(GMOCK_INSTALL_DIR ${GMOCK_INSTALL_DIR}/gmock) find_path(GMOCK_INCLUDE_DIR gmock/gmock.h) set(GMOCK_PREFIX gmock) set(GMOCK_BINARY_DIR ${CMAKE_BINARY_DIR}/${GMOCK_PREFIX}/libs) set(GTEST_BINARY_DIR ${GMOCK_BINARY_DIR}/gtest) set(GTEST_CMAKE_ARGS "") if (${MIR_IS_CROSS_COMPILING}) set(GTEST_CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_MODULE_PATH}/LinuxCrossCompile.cmake) endif() ExternalProject_Add( GMock #where to build in source tree PREFIX ${GMOCK_PREFIX} #where the source is external to the project SOURCE_DIR ${GMOCK_INSTALL_DIR} #forward the compilers to the subproject so cross-arch builds work CMAKE_ARGS ${GTEST_CMAKE_ARGS} BINARY_DIR ${GMOCK_BINARY_DIR} #we don't need to install, so skip INSTALL_COMMAND "" ) set(GMOCK_LIBRARY ${GMOCK_BINARY_DIR}/libgmock.a) set(GMOCK_MAIN_LIBRARY ${GMOCK_BINARY_DIR}/libgmock_main.a) set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY}) set(GTEST_LIBRARY ${GTEST_BINARY_DIR}/libgtest.a) set(GTEST_MAIN_LIBRARY ${GTEST_BINARY_DIR}/libgtest_main.a) set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARY} ${GTEST_MAIN_LIBRARY}) set(GTEST_ALL_LIBRARIES ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES}) find_package_handle_standard_args(GTest DEFAULT_MSG GMOCK_INCLUDE_DIR GTEST_INCLUDE_DIR) connectivity-api-0.0.1+14.04.20140312/cmake/modules/FindLcov.cmake0000644000015201777760000000172012307723555024635 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) connectivity-api-0.0.1+14.04.20140312/cmake/modules/EnableCoverageReport.cmake0000644000015201777760000001537512307723555027202 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() connectivity-api-0.0.1+14.04.20140312/tests/0000755000015201777760000000000012307723764020543 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/tests/CMakeLists.txt0000644000015201777760000000574112307723555023310 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 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 . # # Authors: # Antti Kaijanmäki set (OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Don't treat warnings as errors in 3rd_party/{gmock,cucumber-cpp} string (REPLACE " -Werror " " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}) set (CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS}) if (NOT DEFINED GTEST_ROOT) set(GTEST_ROOT /usr/src/gtest) endif() set(GTEST_SRC_DIR "${GTEST_ROOT}/src") set(GTEST_INCLUDE_DIR ${GTEST_ROOT}) add_library(gtest STATIC ${GTEST_SRC_DIR}/gtest-all.cc ${GTEST_SRC_DIR}/gtest_main.cc ) set_target_properties(gtest PROPERTIES INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIR}) target_link_libraries(gtest ${CMAKE_THREAD_LIBS_INIT}) include_directories(${GTEST_INCLUDE_DIRS}) add_definitions(-DCORE_DBUS_ENABLE_GOOGLE_TEST_FIXTURE) pkg_check_modules(PROCESS_CPP process-cpp) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/test_data.h.in ${CMAKE_CURRENT_BINARY_DIR}/test_data.h @ONLY ) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) add_executable ( test_networking_status test_networking_status.cpp ) add_executable ( test_flight_mode test_flight_mode.cpp ) add_executable ( test_wifi_link test_wifi_link.cpp ) add_executable ( test_wifi_connect test_wifi_connect.cpp ) add_executable ( test_wifi_link_enable_disable test_wifi_link_enable_disable.cpp ) target_link_libraries( test_networking_status connectivity-cpp gtest ${PROCESS_CPP_LIBRARIES} ) target_link_libraries( test_flight_mode connectivity-cpp gtest ${PROCESS_CPP_LIBRARIES} ) target_link_libraries( test_wifi_link connectivity-cpp gtest ${PROCESS_CPP_LIBRARIES} ) target_link_libraries( test_wifi_connect connectivity-cpp gtest ${PROCESS_CPP_LIBRARIES} ) target_link_libraries( test_wifi_link_enable_disable connectivity-cpp gtest ${PROCESS_CPP_LIBRARIES} ) add_test(test_networking_status ${CMAKE_CURRENT_BINARY_DIR}/test_networking_status) add_test(test_flight_mode ${CMAKE_CURRENT_BINARY_DIR}/test_flight_mode) add_test(test_wifi_link ${CMAKE_CURRENT_BINARY_DIR}/test_wifi_link) add_test(test_wifi_connect ${CMAKE_CURRENT_BINARY_DIR}/test_wifi_connect) add_test(test_wifi_connect.cpp test_wifi_link_enable_disable ${CMAKE_CURRENT_BINARY_DIR}/test_wifi_connect.cpp test_wifi_link_enable_disable) connectivity-api-0.0.1+14.04.20140312/tests/test_service.h0000644000015201777760000000532612307723555023417 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 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 TEST_SERVICE_H_ #define TEST_SERVICE_H_ namespace test { struct Service { struct Method { typedef Service Interface; inline static const std::string& name() { static const std::string s { "Method" }; return s; } inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct Signals { struct Dummy { inline static std::string name() { return "Dummy"; }; typedef Service Interface; typedef int64_t ArgumentType; }; }; struct Properties { struct Dummy { inline static std::string name() { return "Dummy"; }; typedef Service Interface; typedef double ValueType; static const bool readable = true; static const bool writable = true; }; }; struct Interfaces { struct Foo { static const std::string& name() { static const std::string s{"this.is.unlikely.to.exist.Service.Foo"}; return s; } struct Signals { struct Dummy { inline static std::string name() { return "Dummy"; } typedef Foo Interface; typedef int64_t ArgumentType; }; }; }; }; }; } #include namespace core { namespace dbus { namespace traits { template<> struct Service { inline static const std::string& interface_name() { static const std::string s { "this.is.unlikely.to.exist.Service" }; return s; } }; } } } #endif // TEST_SERVICE_H_ connectivity-api-0.0.1+14.04.20140312/tests/test_networking_status.cpp0000644000015201777760000001642712307723555026110 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 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: Antti Kaijanmäki */ #include #include #include #include #include #include #include #include #include #include "sig_term_catcher.h" #include "test_data.h" #include "test_service.h" #include #include #include #include #include #include #include namespace fdo = org::freedesktop; namespace NM = fdo::NetworkManager; #include namespace cuc = com::ubuntu::connectivity; namespace dbus = core::dbus; namespace { struct Service : public core::dbus::testing::Fixture {}; auto session_bus_config_file = core::dbus::testing::Fixture::default_session_bus_config_file() = core::testing::session_bus_configuration_file(); auto system_bus_config_file = core::dbus::testing::Fixture::default_system_bus_config_file() = core::testing::system_bus_configuration_file(); } TEST_F(Service, networkingStatus) { core::testing::CrossProcessSync services_ready; core::testing::CrossProcessSync client_ready; core::testing::CrossProcessSync update_networking_status; auto service = [&, this]() { core::testing::SigTermCatcher sc; auto bus = system_bus(); bus->install_executor(core::dbus::asio::make_executor(bus)); auto nm_service = NM::Service::Mock(bus); auto nm_root = nm_service.nm; nm_root->object->install_method_handler([bus, nm_root](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); reply->writer() << std::vector(); bus->send(reply); }); nm_root->state->set(NM_STATE_UNKNOWN); auto urfkill_service = fdo::URfkill::Service::Mock(bus); auto urfkill_root = urfkill_service.urfkill; urfkill_root->object->install_method_handler([bus](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); reply->writer() << std::vector(); bus->send(reply); }); std::thread t{[bus](){ bus->run(); }}; services_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); EXPECT_EQ(1, client_ready.wait_for_signal_ready_for(std::chrono::milliseconds{2000})); NM::Interface::NetworkManager::Signal::PropertiesChanged::ArgumentType properties; properties["State"] = dbus::types::Variant::encode(NM_STATE_UNKNOWN); nm_root->properties_changed->emit(properties); properties["State"] = dbus::types::Variant::encode(NM_STATE_ASLEEP); nm_root->properties_changed->emit(properties); properties["State"] = dbus::types::Variant::encode(NM_STATE_DISCONNECTED); nm_root->properties_changed->emit(properties); properties["State"] = dbus::types::Variant::encode(NM_STATE_CONNECTING); nm_root->properties_changed->emit(properties); properties["State"] = dbus::types::Variant::encode(NM_STATE_CONNECTED_LOCAL); nm_root->properties_changed->emit(properties); properties["State"] = dbus::types::Variant::encode(NM_STATE_CONNECTED_SITE); nm_root->properties_changed->emit(properties); properties["State"] = dbus::types::Variant::encode(NM_STATE_CONNECTED_GLOBAL); nm_root->properties_changed->emit(properties); properties["State"] = dbus::types::Variant::encode(NM_STATE_DISCONNECTING); nm_root->properties_changed->emit(properties); properties["State"] = dbus::types::Variant::encode(NM_STATE_DISCONNECTED); nm_root->properties_changed->emit(properties); properties["State"] = dbus::types::Variant::encode(NM_STATE_CONNECTING); nm_root->properties_changed->emit(properties); properties["State"] = dbus::types::Variant::encode(NM_STATE_CONNECTED_GLOBAL); nm_root->properties_changed->emit(properties); // status change update_networking_status.try_signal_ready_for(std::chrono::milliseconds{2000}); sc.wait_for_signal_for(std::chrono::seconds{10}); bus->stop(); if (t.joinable()) t.join(); return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; auto client = [&, this]() { EXPECT_EQ(1, services_ready.wait_for_signal_ready_for(std::chrono::milliseconds{2000})); std::unique_ptr mgr; mgr = cuc::networking::Manager::createInstance(); EXPECT_EQ(mgr->status().get(), cuc::networking::Manager::NetworkingStatus::offline); std::vector states; mgr->status().changed().connect([&states](cuc::networking::Manager::NetworkingStatus status) { states.push_back(status); }); client_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); EXPECT_EQ(1, update_networking_status.wait_for_signal_ready_for(std::chrono::milliseconds{2000})); sleep(1); EXPECT_EQ(states.size(), 5); EXPECT_EQ(states.at(0), cuc::networking::Manager::NetworkingStatus::connecting); EXPECT_EQ(states.at(1), cuc::networking::Manager::NetworkingStatus::online); EXPECT_EQ(states.at(2), cuc::networking::Manager::NetworkingStatus::offline); EXPECT_EQ(states.at(3), cuc::networking::Manager::NetworkingStatus::connecting); EXPECT_EQ(states.at(4), cuc::networking::Manager::NetworkingStatus::online); delete mgr.release(); return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); } connectivity-api-0.0.1+14.04.20140312/tests/test_wifi_connect.cpp0000644000015201777760000002752312307723555024764 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 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: Antti Kaijanmäki */ #include #include #include #include #include #include #include #include #include #include "sig_term_catcher.h" #include "test_data.h" #include "test_service.h" #include #include #include #include #include #include #include namespace fdo = org::freedesktop; namespace NM = fdo::NetworkManager; #include #include #include namespace cuc = com::ubuntu::connectivity; namespace dbus = core::dbus; namespace { struct Service : public core::dbus::testing::Fixture {}; auto session_bus_config_file = core::dbus::testing::Fixture::default_session_bus_config_file() = core::testing::session_bus_configuration_file(); auto system_bus_config_file = core::dbus::testing::Fixture::default_system_bus_config_file() = core::testing::system_bus_configuration_file(); } TEST_F(Service, wifiLink) { core::testing::CrossProcessSync services_ready; core::testing::CrossProcessSync client_ready; core::testing::CrossProcessSync stage1; core::testing::CrossProcessSync stage2; auto service = [&, this]() { core::testing::SigTermCatcher sc; auto bus = system_bus(); bus->install_executor(core::dbus::asio::make_executor(bus)); auto service = NM::Service::Mock(bus); auto nm_root = service.nm; auto wifi_dev = NM::Interface::Device(nm_root->service, nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/Devices/0"))); auto ap1 = NM::Interface::AccessPoint(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/1"))); auto ap2 = NM::Interface::AccessPoint(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/2"))); auto wrong_settings = NM::Interface::Connection(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/Settings/1"))); auto correct_settings = NM::Interface::Connection(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/Settings/2"))); wrong_settings.object->install_method_handler([&](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); std::map> conf; std::map wireless_conf; wireless_conf["ssid"] = dbus::types::Variant::encode>({0x64, 0x65, 0x66}); // def conf["802-11-wireless"] = wireless_conf; reply->writer() << conf; bus->send(reply); }); correct_settings.object->install_method_handler([&](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); std::map> conf; std::map wireless_conf; wireless_conf["ssid"] = dbus::types::Variant::encode>({0x61, 0x62, 0x63}); // abc conf["802-11-wireless"] = wireless_conf; reply->writer() << conf; bus->send(reply); }); nm_root->object->install_method_handler([bus, &wifi_dev](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); std::vector devices; devices.push_back(wifi_dev.object->path()); reply->writer() << devices; bus->send(reply); }); NM::Interface::Device::Property::AvailableConnections::ValueType available_connections; available_connections.push_back(wrong_settings.object->path()); available_connections.push_back(correct_settings.object->path()); wifi_dev.available_connections->set(available_connections); nm_root->object->install_method_handler([&](const dbus::Message::Ptr& msg) { std::cout << "Server: Active Connection" << std::endl; auto reader = msg->reader(); dbus::types::ObjectPath connection = reader.pop_object_path(); dbus::types::ObjectPath device = reader.pop_object_path(); dbus::types::ObjectPath specific_object = reader.pop_object_path(); EXPECT_EQ(connection, correct_settings.object->path()); EXPECT_EQ(device, wifi_dev.object->path()); EXPECT_EQ(specific_object, ap1.object->path()); auto reply = dbus::Message::make_method_return(msg); reply->writer() << dbus::types::ObjectPath("/"); /// @todo return an actual ActiveConnection at some point. bus->send(reply); }); nm_root->object->install_method_handler([&](const dbus::Message::Ptr& msg) { std::cout << "Server: Add and Active Connection" << std::endl; auto reader = msg->reader(); std::map> connection; reader >> connection; dbus::types::ObjectPath device = reader.pop_object_path(); dbus::types::ObjectPath specific_object = reader.pop_object_path(); EXPECT_TRUE(connection.find("802-11-wireless") != connection.end()); auto wificonf = connection["802-11-wireless"]; EXPECT_TRUE(wificonf.find("ssid") != wificonf.end()); EXPECT_EQ(wificonf["ssid"].as>(), ap2.ssid->get()); EXPECT_EQ(device, wifi_dev.object->path()); EXPECT_EQ(specific_object, ap2.object->path()); auto reply = dbus::Message::make_method_return(msg); auto ret = std::make_tuple(dbus::types::ObjectPath("/"), dbus::types::ObjectPath("/")); reply->writer() << ret; /// @todo return actual Settings and ActiveConnection at some point. bus->send(reply); }); nm_root->state->set(NM_STATE_DISCONNECTED); wifi_dev.device_type->set(NM_DEVICE_TYPE_WIFI); std::vector aps; wifi_dev.object->install_method_handler([bus, &aps](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); reply->writer() << aps; bus->send(reply); }); auto ap_added = wifi_dev.object->get_signal(); auto ap_removed = wifi_dev.object->get_signal(); ap1.flags->set(NM_802_11_AP_FLAGS_PRIVACY); ap1.mode->set(NM_802_11_MODE_INFRA); ap1.ssid->set({0x61, 0x62, 0x63}); // abc ap1.strength->set(90); auto ap1_pc = ap1.properties_changed; ap2.flags->set(NM_802_11_AP_FLAGS_NONE); ap2.mode->set(NM_802_11_MODE_ADHOC); ap2.ssid->set({0x31, 0x32, 0x33}); // 123 ap2.strength->set(60); auto ap2_pc = ap2.properties_changed; auto urfkill_service = fdo::URfkill::Service::Mock(bus); auto urfkill_root = urfkill_service.urfkill; urfkill_root->object->install_method_handler([bus](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); reply->writer() << std::vector(); bus->send(reply); }); std::thread t{[bus](){ bus->run(); }}; aps.push_back(ap1.object->path()); aps.push_back(ap2.object->path()); services_ready.try_signal_ready_for(std::chrono::milliseconds{5000}); EXPECT_EQ(1, client_ready.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); stage1.try_signal_ready_for(std::chrono::milliseconds{5000}); sleep(1); stage2.try_signal_ready_for(std::chrono::milliseconds{5000}); sc.wait_for_signal_for(std::chrono::seconds{60}); bus->stop(); if (t.joinable()) t.join(); return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; auto client = [&, this]() { EXPECT_EQ(1, services_ready.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); std::unique_ptr mgr; mgr = cuc::networking::Manager::createInstance(); auto links = mgr->links(); EXPECT_EQ(links->size(), 1); EXPECT_EQ((*links->begin())->type(), cuc::networking::Link::Type::wifi); auto wifilink = std::dynamic_pointer_cast(*links->begin()); EXPECT_TRUE(wifilink.get() != nullptr); auto aps = wifilink->accessPoints().get(); EXPECT_EQ(aps.size(), 2); std::shared_ptr ap_abc; std::shared_ptr ap_123; for (auto ap : aps) { if (ap->ssid() == "abc") ap_abc = ap; if (ap->ssid() == "123") ap_123 = ap; } EXPECT_TRUE(ap_abc.get() != nullptr); EXPECT_TRUE(ap_123.get() != nullptr); client_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); wifilink->connect_to(ap_abc); sleep(1); EXPECT_EQ(1, stage1.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); wifilink->connect_to(ap_123); sleep(1); delete mgr.release(); return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); } connectivity-api-0.0.1+14.04.20140312/tests/sig_term_catcher.h0000644000015201777760000000402712307723555024217 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 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 CORE_TESTING_SIG_TERM_CATCHER_H_ #define CORE_TESTING_SIG_TERM_CATCHER_H_ #include #include #include #include #include namespace core { namespace testing { struct SigTermCatcher { inline SigTermCatcher() { sigemptyset(&signal_mask); if (-1 == sigaddset(&signal_mask, SIGTERM)) throw std::system_error(errno, std::system_category()); if (-1 == sigprocmask(SIG_BLOCK, &signal_mask, NULL)) throw std::system_error(errno, std::system_category()); if (-1 == (signal_fd = signalfd(-1, &signal_mask, 0))) throw std::system_error(errno, std::system_category()); } inline ~SigTermCatcher() { ::close(signal_fd); } inline void wait_for_signal_for(const std::chrono::milliseconds& ms) { pollfd fd; fd.fd = signal_fd; fd.events = POLLIN; if (poll(&fd, 1, ms.count()) > 0) { signalfd_siginfo siginfo; if (-1 == ::read(signal_fd, &siginfo, sizeof(siginfo))) throw std::system_error(errno, std::system_category()); } else { throw std::system_error(errno, std::system_category()); } } sigset_t signal_mask; int signal_fd = -1; }; } } #endif // CORE_TESTING_SIG_TERM_CATCHER_H_ connectivity-api-0.0.1+14.04.20140312/tests/test_flight_mode.cpp0000644000015201777760000001472712307723555024600 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 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: Antti Kaijanmäki */ #include #include #include #include #include #include #include #include #include #include "sig_term_catcher.h" #include "test_data.h" #include "test_service.h" #include #include #include #include #include #include #include namespace fdo = org::freedesktop; namespace NM = fdo::NetworkManager; #include namespace cuc = com::ubuntu::connectivity; namespace dbus = core::dbus; namespace { struct Service : public core::dbus::testing::Fixture {}; auto session_bus_config_file = core::dbus::testing::Fixture::default_session_bus_config_file() = core::testing::session_bus_configuration_file(); auto system_bus_config_file = core::dbus::testing::Fixture::default_system_bus_config_file() = core::testing::system_bus_configuration_file(); } TEST_F(Service, flightMode) { core::testing::CrossProcessSync services_ready; core::testing::CrossProcessSync failing_invokations; core::testing::CrossProcessSync client_ready; auto service = [&, this]() { core::testing::SigTermCatcher sc; auto bus = system_bus(); bus->install_executor(core::dbus::asio::make_executor(bus)); auto nm_service = NM::Service::Mock(bus); auto nm_root = nm_service.nm; nm_root->object->install_method_handler([bus, nm_root](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); reply->writer() << std::vector(); bus->send(reply); }); nm_root->state->set(0); auto urfkill_service = fdo::URfkill::Service::Mock(bus); auto urfkill_root = urfkill_service.urfkill; auto rfkill_device = fdo::URfkill::Interface::Device(urfkill_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/URfkill/devices/0"))); // as we only have one device and it's not blocked the initial state should be off rfkill_device.hard->set(false); rfkill_device.soft->set(false); urfkill_root->object->install_method_handler([bus](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); std::vector devices; devices.push_back(dbus::types::ObjectPath("/org/freedesktop/URfkill/devices/0")); reply->writer() << devices; bus->send(reply); }); bool fail = true; urfkill_root->object->install_method_handler([bus, &fail](const dbus::Message::Ptr& msg) { auto reader = msg->reader(); // not used for now. //std::uint32_t type = reader.pop_uint32(); //bool block = reader.pop_boolean(); auto reply = dbus::Message::make_method_return(msg); reply->writer() << !fail; bus->send(reply); }); std::thread t{[bus](){ bus->run(); }}; services_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); EXPECT_EQ(1, failing_invokations.wait_for_signal_ready_for(std::chrono::milliseconds{2000})); fail = false; EXPECT_EQ(1, client_ready.wait_for_signal_ready_for(std::chrono::milliseconds{2000})); sc.wait_for_signal_for(std::chrono::seconds{10}); bus->stop(); if (t.joinable()) t.join(); return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; auto client = [&, this]() { EXPECT_EQ(1, services_ready.wait_for_signal_ready_for(std::chrono::milliseconds{2000})); std::unique_ptr mgr; mgr = cuc::networking::Manager::createInstance(); std::vector statuses; try { EXPECT_EQ(mgr->flightMode().get(), cuc::networking::Manager::FlightModeStatus::off); mgr->flightMode().changed().connect([&statuses](cuc::networking::Manager::FlightModeStatus status) { statuses.push_back(status); }); mgr->enableFlightMode(); mgr->disableFlightMode(); failing_invokations.try_signal_ready_for(std::chrono::milliseconds{2000}); mgr->enableFlightMode(); mgr->disableFlightMode(); } catch (std::runtime_error e) { std::cout << "exception: " << e.what() << std::endl; } client_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); EXPECT_EQ(statuses.size(), 2); EXPECT_EQ(statuses.at(0), cuc::networking::Manager::FlightModeStatus::on); EXPECT_EQ(statuses.at(1), cuc::networking::Manager::FlightModeStatus::off); delete mgr.release(); return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); } connectivity-api-0.0.1+14.04.20140312/tests/test_data.h.in0000644000015201777760000000506312307723555023273 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 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 TEST_DATA_H_ #define TEST_DATA_H_ namespace core { namespace testing { const char* session_bus_configuration_file() { return "@CMAKE_SOURCE_DIR@/data/session.conf"; } const char* system_bus_configuration_file() { return "@CMAKE_SOURCE_DIR@/data/system.conf"; } namespace com { namespace canonical { const char* user_metrics_introspection_file() { return "@CMAKE_CURRENT_SOURCE_DIR@/data/com.canonical.UserMetrics.xml"; } const char* url_dispatcher_introspection_file() { return "@CMAKE_CURRENT_SOURCE_DIR@/data/com.canonical.URLDispatcher.xml"; } } } namespace org { namespace freedesktop { namespace modem_manager { namespace modem { constexpr const char* cdma_introspection_file() { return "@CMAKE_CURRENT_SOURCE_DIR@/data/org.freedesktop.ModemManager.Modem.Cdma.xml"; } constexpr const char* firmware_introspection_file() { return "@CMAKE_CURRENT_SOURCE_DIR@/data/org.freedesktop.ModemManager.Modem.Firmware.xml"; } namespace gsm { constexpr const char* card_introspection_file() { return "@CMAKE_CURRENT_SOURCE_DIR@/data/org.freedesktop.ModemManager.Modem.Gsm.Card.xml"; } constexpr const char* contact_introspection_file() { return "@CMAKE_CURRENT_SOURCE_DIR@/data/org.freedesktop.ModemManager.Modem.Gsm.Contacts.xml"; } constexpr const char* hso_introspection_file() { return "@CMAKE_CURRENT_SOURCE_DIR@/data/org.freedesktop.ModemManager.Modem.Gsm.Hso.xml"; } constexpr const char* network_introspection_file() { return "@CMAKE_CURRENT_SOURCE_DIR@/data/org.freedesktop.ModemManager.Modem.Gsm.Network.xml"; } constexpr const char* sms_introspection_file() { return "@CMAKE_CURRENT_SOURCE_DIR@/data/org.freedesktop.ModemManager.Modem.Gsm.SMS.xml"; } constexpr const char* ussd_introspection_file() { return "@CMAKE_CURRENT_SOURCE_DIR@/data/org.freedesktop.ModemManager.Modem.Gsm.Ussd.xml"; } } } } } } } } #endif // TEST_DATA_H_ connectivity-api-0.0.1+14.04.20140312/tests/test_wifi_link_enable_disable.cpp0000644000015201777760000002140412307723555027251 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 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: Antti Kaijanmäki */ #include #include #include #include #include #include #include #include #include #include "sig_term_catcher.h" #include "test_data.h" #include "test_service.h" #include #include #include #include #include #include #include namespace fdo = org::freedesktop; namespace NM = fdo::NetworkManager; #include #include #include namespace cuc = com::ubuntu::connectivity; namespace dbus = core::dbus; namespace { struct Service : public core::dbus::testing::Fixture {}; auto session_bus_config_file = core::dbus::testing::Fixture::default_session_bus_config_file() = core::testing::session_bus_configuration_file(); auto system_bus_config_file = core::dbus::testing::Fixture::default_system_bus_config_file() = core::testing::system_bus_configuration_file(); } TEST_F(Service, wifiLink) { core::testing::CrossProcessSync services_ready; core::testing::CrossProcessSync client_ready; core::testing::CrossProcessSync stage1; core::testing::CrossProcessSync stage2; auto service = [&, this]() { core::testing::SigTermCatcher sc; auto bus = system_bus(); bus->install_executor(core::dbus::asio::make_executor(bus)); auto service = NM::Service::Mock(bus); auto nm_root = service.nm; auto wifi_dev = NM::Interface::Device(nm_root->service, nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/Devices/0"))); nm_root->object->install_method_handler([bus, &wifi_dev](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); std::vector devices; devices.push_back(wifi_dev.object->path()); reply->writer() << devices; bus->send(reply); }); nm_root->state->set(NM_STATE_CONNECTED_GLOBAL); wifi_dev.device_type->set(NM_DEVICE_TYPE_WIFI); wifi_dev.state->set(NM_DEVICE_STATE_ACTIVATED); wifi_dev.object->install_method_handler([&](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); reply->writer() << std::vector(); bus->send(reply); }); bool wireless_enabled = true; nm_root->wireless_enabled->set(wireless_enabled); nm_root->wireless_enabled->changed().connect([&](bool value) { wireless_enabled = value; if (wireless_enabled) { wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_UNAVAILABLE, NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE)); wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE)); wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_REASON_NONE)); wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE)); wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE)); wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_REASON_NONE)); wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE)); wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_SECONDARIES, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE)); wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_SECONDARIES, NM_DEVICE_STATE_REASON_NONE)); } else { wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_UNAVAILABLE, NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_REASON_NONE)); } }); auto urfkill_service = fdo::URfkill::Service::Mock(bus); auto urfkill_root = urfkill_service.urfkill; urfkill_root->object->install_method_handler([bus](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); reply->writer() << std::vector(); bus->send(reply); }); std::thread t{[bus](){ bus->run(); }}; services_ready.try_signal_ready_for(std::chrono::milliseconds{5000}); EXPECT_EQ(1, client_ready.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); stage1.try_signal_ready_for(std::chrono::milliseconds{5000}); sleep(1); EXPECT_FALSE(wireless_enabled); stage2.try_signal_ready_for(std::chrono::milliseconds{5000}); sleep(1); EXPECT_TRUE(wireless_enabled); sc.wait_for_signal_for(std::chrono::seconds{60}); bus->stop(); if (t.joinable()) t.join(); return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; auto client = [&, this]() { EXPECT_EQ(1, services_ready.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); std::unique_ptr mgr; mgr = cuc::networking::Manager::createInstance(); auto links = mgr->links(); EXPECT_EQ(links->size(), 1); EXPECT_EQ((*links->begin())->type(), cuc::networking::Link::Type::wifi); auto wifilink = std::dynamic_pointer_cast(*links->begin()); EXPECT_TRUE(wifilink.get() != nullptr); client_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); wifilink->disable(); sleep(1); EXPECT_EQ(1, stage1.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); EXPECT_EQ(wifilink->status().get(), cuc::networking::Link::Status::disabled); std::vector link_states; wifilink->status().changed().connect([&](cuc::networking::Link::Status value) { link_states.push_back(value); }); wifilink->enable(); sleep(1); EXPECT_EQ(1, stage2.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); EXPECT_EQ(wifilink->status().get(), cuc::networking::Link::Status::online); EXPECT_EQ(link_states.size(), 4); EXPECT_EQ(link_states[0], cuc::networking::Link::Status::offline); EXPECT_EQ(link_states[1], cuc::networking::Link::Status::connecting); EXPECT_EQ(link_states[2], cuc::networking::Link::Status::connected); EXPECT_EQ(link_states[3], cuc::networking::Link::Status::online); delete mgr.release(); return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); } connectivity-api-0.0.1+14.04.20140312/tests/test_wifi_link.cpp0000644000015201777760000003600012307723555024256 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 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: Antti Kaijanmäki */ #include #include #include #include #include #include #include #include #include #include "sig_term_catcher.h" #include "test_data.h" #include "test_service.h" #include #include #include #include #include #include #include namespace fdo = org::freedesktop; namespace NM = fdo::NetworkManager; #include #include #include namespace cuc = com::ubuntu::connectivity; namespace dbus = core::dbus; namespace { struct Service : public core::dbus::testing::Fixture {}; auto session_bus_config_file = core::dbus::testing::Fixture::default_session_bus_config_file() = core::testing::session_bus_configuration_file(); auto system_bus_config_file = core::dbus::testing::Fixture::default_system_bus_config_file() = core::testing::system_bus_configuration_file(); } TEST_F(Service, wifiLink) { core::testing::CrossProcessSync services_ready; core::testing::CrossProcessSync client_ready; core::testing::CrossProcessSync stage1; core::testing::CrossProcessSync stage2; core::testing::CrossProcessSync stage3; auto service = [&, this]() { core::testing::SigTermCatcher sc; auto bus = system_bus(); bus->install_executor(core::dbus::asio::make_executor(bus)); auto service = NM::Service::Mock(bus); auto nm_root = service.nm; auto wifi_dev = NM::Interface::Device(nm_root->service, nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/Devices/0"))); auto ap1 = NM::Interface::AccessPoint(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/1"))); auto ap2 = NM::Interface::AccessPoint(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/2"))); nm_root->object->install_method_handler([bus, &wifi_dev](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); std::vector devices; devices.push_back(wifi_dev.object->path()); reply->writer() << devices; bus->send(reply); }); nm_root->state->set(NM_STATE_CONNECTED_GLOBAL); wifi_dev.device_type->set(NM_DEVICE_TYPE_WIFI); std::vector aps; wifi_dev.object->install_method_handler([bus, &aps](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); reply->writer() << aps; bus->send(reply); }); auto ap_added = wifi_dev.object->get_signal(); auto ap_removed = wifi_dev.object->get_signal(); ap1.flags->set(NM_802_11_AP_FLAGS_PRIVACY); ap1.mode->set(NM_802_11_MODE_INFRA); ap1.ssid->set({0x61, 0x62, 0x63}); // abc ap1.strength->set(90); auto ap1_pc = ap1.properties_changed; ap2.flags->set(NM_802_11_AP_FLAGS_NONE); ap2.mode->set(NM_802_11_MODE_ADHOC); ap2.ssid->set({0x31, 0x32, 0x33}); // 123 ap2.strength->set(60); auto ap2_pc = ap2.properties_changed; auto urfkill_service = fdo::URfkill::Service::Mock(bus); auto urfkill_root = urfkill_service.urfkill; urfkill_root->object->install_method_handler([bus](const dbus::Message::Ptr& msg) { auto reply = dbus::Message::make_method_return(msg); reply->writer() << std::vector(); bus->send(reply); }); std::thread t{[bus](){ bus->run(); }}; // add just one AP initially aps.push_back(ap1.object->path()); services_ready.try_signal_ready_for(std::chrono::milliseconds{5000}); EXPECT_EQ(1, client_ready.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); NM::Interface::AccessPoint::Signal::PropertiesChanged::ArgumentType properties; properties["Strength"] = dbus::types::Variant::encode(0); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(1); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(2); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(3); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(4); ap1_pc->emit(properties); stage1.try_signal_ready_for(std::chrono::milliseconds{5000}); // add second ap aps.push_back(ap2.object->path()); ap_added->emit(ap2.object->path()); sleep(1); properties["Strength"] = dbus::types::Variant::encode(5); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(6); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(7); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(8); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(9); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(100); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(99); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(98); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(97); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(96); ap2_pc->emit(properties); ap2_pc->emit(properties); stage2.try_signal_ready_for(std::chrono::milliseconds{5000}); // remove the first ap aps.clear(); aps.push_back(ap2.object->path()); ap_removed->emit(ap1.object->path()); sleep(1); properties["Strength"] = dbus::types::Variant::encode(95); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(94); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(93); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(92); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(91); ap2_pc->emit(properties); stage3.try_signal_ready_for(std::chrono::milliseconds{5000}); // add the first ap back aps.push_back(ap1.object->path()); ap_added->emit(ap1.object->path()); sleep(1); properties["Strength"] = dbus::types::Variant::encode(10); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(11); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(12); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(13); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(14); ap1_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(90); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(89); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(88); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(87); ap2_pc->emit(properties); properties["Strength"] = dbus::types::Variant::encode(86); ap2_pc->emit(properties); sc.wait_for_signal_for(std::chrono::seconds{60}); bus->stop(); if (t.joinable()) t.join(); return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; auto client = [&, this]() { EXPECT_EQ(1, services_ready.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); std::unique_ptr mgr; mgr = cuc::networking::Manager::createInstance(); auto links = mgr->links(); EXPECT_EQ(links->size(), 1); EXPECT_EQ((*links->begin())->type(), cuc::networking::Link::Type::wifi); auto wifilink = std::dynamic_pointer_cast(*links->begin()); EXPECT_TRUE(wifilink.get() != nullptr); std::vector values_abc; std::vector values_123; std::map, core::ScopedConnection> connections; auto ap_connect = [&](std::shared_ptr ap) { if (ap->ssid() == "abc") { EXPECT_TRUE(ap->secured()); EXPECT_FALSE(ap->adhoc()); auto con = ap->strength().changed().connect([&values_abc](double value){ values_abc.push_back(value); }); connections.insert(std::make_pair(ap, core::ScopedConnection(con))); } else if (ap->ssid() == "123") { EXPECT_FALSE(ap->secured()); EXPECT_TRUE(ap->adhoc()); auto con = ap->strength().changed().connect([&values_123](double value){ values_123.push_back(value); }); connections.insert(std::make_pair(ap, core::ScopedConnection(con))); } }; auto aps = wifilink->accessPoints().get(); EXPECT_EQ(aps.size(), 1); for (auto ap : aps) { ap_connect(ap); } aps.clear(); wifilink->accessPoints().changed().connect([&](std::set> aps) { connections.clear(); for (auto ap: aps) ap_connect(ap); }); client_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); sleep(1); EXPECT_EQ(values_abc.size(), 5); EXPECT_EQ(values_123.size(), 0); EXPECT_FLOAT_EQ(values_abc[0], 0); EXPECT_FLOAT_EQ(values_abc[1], 1); EXPECT_FLOAT_EQ(values_abc[2], 2); EXPECT_FLOAT_EQ(values_abc[3], 3); EXPECT_FLOAT_EQ(values_abc[4], 4); values_abc.clear(); values_123.clear(); EXPECT_EQ(1, stage1.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); sleep(1); EXPECT_EQ(values_abc.size(), 5); EXPECT_EQ(values_123.size(), 5); EXPECT_FLOAT_EQ(values_abc[0], 5); EXPECT_FLOAT_EQ(values_abc[1], 6); EXPECT_FLOAT_EQ(values_abc[2], 7); EXPECT_FLOAT_EQ(values_abc[3], 8); EXPECT_FLOAT_EQ(values_abc[4], 9); EXPECT_FLOAT_EQ(values_123[0], 100); EXPECT_FLOAT_EQ(values_123[1], 99); EXPECT_FLOAT_EQ(values_123[2], 98); EXPECT_FLOAT_EQ(values_123[3], 97); EXPECT_FLOAT_EQ(values_123[4], 96); values_abc.clear(); values_123.clear(); EXPECT_EQ(1, stage2.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); sleep(1); EXPECT_EQ(values_abc.size(), 0); EXPECT_EQ(values_123.size(), 5); EXPECT_FLOAT_EQ(values_123[0], 95); EXPECT_FLOAT_EQ(values_123[1], 94); EXPECT_FLOAT_EQ(values_123[2], 93); EXPECT_FLOAT_EQ(values_123[3], 92); EXPECT_FLOAT_EQ(values_123[4], 91); values_abc.clear(); values_123.clear(); EXPECT_EQ(1, stage3.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); sleep(1); EXPECT_EQ(values_abc.size(), 5); EXPECT_EQ(values_123.size(), 5); EXPECT_FLOAT_EQ(values_abc[0], 10); EXPECT_FLOAT_EQ(values_abc[1], 11); EXPECT_FLOAT_EQ(values_abc[2], 12); EXPECT_FLOAT_EQ(values_abc[3], 13); EXPECT_FLOAT_EQ(values_abc[4], 14); EXPECT_FLOAT_EQ(values_123[0], 90); EXPECT_FLOAT_EQ(values_123[1], 89); EXPECT_FLOAT_EQ(values_123[2], 88); EXPECT_FLOAT_EQ(values_123[3], 87); EXPECT_FLOAT_EQ(values_123[4], 86); delete mgr.release(); return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); } connectivity-api-0.0.1+14.04.20140312/CMakeLists.txt0000644000015201777760000001021312307723555022134 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 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 . # # Authors: # Antti Kaijanmäki cmake_minimum_required(VERSION 2.8) project(connectivity-cpp) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) include(EnableCoverageReport) include(GNUInstallDirs) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wextra -fPIC -fvisibility=hidden -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -pedantic -Wextra -fPIC -pthread") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") ##################################################################### # 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]) set(CONNECTIVITY_CPP_VERSION_MAJOR 0) set(CONNECTIVITY_CPP_VERSION_MINOR 0) set(CONNECTIVITY_CPP_VERSION_PATCH 1) include(CTest) find_package(PkgConfig REQUIRED) include_directories(include) include_directories(dbus-cpp) pkg_check_modules( PROPERTIESCPP REQUIRED properties-cpp ) include_directories(${PROPERTIESCPP_INCLUDE_DIRS}) pkg_check_modules( DBUSCPP REQUIRED dbus-cpp ) include_directories(${DBUSCPP_INCLUDE_DIRS}) pkg_check_modules( NETWORKMANAGER REQUIRED NetworkManager ) include_directories(${NETWORKMANAGER_NCLUDE_DIRS}) # list these here to have them visible in Qt Creator set(CONNECTIVITY_INTERFACES include/com/ubuntu/connectivity/networking/link.h include/com/ubuntu/connectivity/networking/manager.h include/com/ubuntu/connectivity/networking/service.h include/com/ubuntu/connectivity/networking/service/tethering/service.h include/com/ubuntu/connectivity/networking/service/tor/service.h include/com/ubuntu/connectivity/networking/service/vpn/service.h include/com/ubuntu/connectivity/networking/wifi/access-point.h include/com/ubuntu/connectivity/networking/wifi/link.h include/com/ubuntu/connectivity/networking/wwan/link.h ) add_custom_target(QtCreatorHeaderHack SOURCES ${CONNECTIVITY_INTERFACES}) # list these here to have them visible in Qt Creator set(DBUS_INTERFACES dbus-cpp/services/nm.h dbus-cpp/services/ofono.h dbus-cpp/services/urfkill.h ) add_custom_target(QtCreatorHeaderHack2 SOURCES ${DBUS_INTERFACES}) add_subdirectory(data) add_subdirectory(doc) add_subdirectory(examples) add_subdirectory(tests) add_subdirectory(src) install( DIRECTORY include/ DESTINATION include/connectivity-cpp-${CONNECTIVITY_CPP_VERSION_MAJOR} ) enable_coverage_report(TARGETS connectivity-cpp FILTER ${CMAKE_SOURCE_DIR}/tests/* ${CMAKE_BINARY_DIR}/*) message(STATUS "Remember, you need to compile this with GCC 4.7 or there will be bugs.") message(STATUS "Package builds to this automatically. To do it manually do this:") message(STATUS "CC=gcc-4.7 CXX=g++-4.7 cmake ") connectivity-api-0.0.1+14.04.20140312/doc/0000755000015201777760000000000012307723764020146 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/doc/pages/0000755000015201777760000000000012307723764021245 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/doc/pages/using.dox0000644000015201777760000000077112307723555023111 0ustar pbusernogroup00000000000000/*! \page using-cpp Using the C++ API Install the development headers: \code{.txt} sudo apt-get install libconnectivity-cpp-dev \endcode Enable c++11 and use pkg-config to get the necessary compilation flags: \code{.txt} $ g++ myapp.cpp -std=c++11 `pkg-config --cflags --libs connectivity-cpp` -o myapp \endcode The headers can then be included as: \code{.cpp} // includes the com::ubuntu::networking::connectivity::Manager class #include \endcode */ connectivity-api-0.0.1+14.04.20140312/doc/pages/mainpage.dox0000644000015201777760000000136712307723555023547 0ustar pbusernogroup00000000000000/*! \mainpage Ubuntu Connectivity API \tableofcontents \section sec_introduction Introduction Ubuntu API offers a way to access the connectivity related information of the system. \subsection sec_thread_safety Note on thread safety The API implementation uses a worker thread. The property changes may be dispatched from this thread and thus the user of this API must make sure to handle necessary threading issues. \section sec_general General Topics - \ref using-cpp "Using this C++ API" - \ref networking-status "Getting the networking status." \section sec_bug_reports Reporting Bugs If you find any problems with the or this documentation, please file a bug in Connectivity API [Launchpad page](https://bugs.launchpad.net/connectivity-api). */ connectivity-api-0.0.1+14.04.20140312/doc/pages/networking-status.dox0000644000015201777760000000210712307723555025467 0ustar pbusernogroup00000000000000/*! \page networking-status Networking Status Applications needing to access the overall system networking status can access the top level com::ubuntu::connectivity::networking::Manager class. The class has properties for the networking status and connection characteristics of the system networking. \section Setup Manager is accessed by including the appropriate header: \snippet example_networking_status.cpp include and then creating an instance of the manager: \snippet example_networking_status.cpp create manager \section sec_networking_status Networking Status The status of the system networking can be accessed through the Manager::status property: \snippet example_networking_status.cpp subscribe networking status changes \section sec_characteristics Networking Characteristics The characteristics can be accessed through the Manager::characteristics property as a bitfield: \snippet example_networking_status.cpp subscribe characteristics changes --- The complete example (found in examples/example_networking_status.cpp): \include example_networking_status.cpp */ connectivity-api-0.0.1+14.04.20140312/doc/Doxyfile.in0000644000015201777760000023442212307723555022266 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 = @CONNECTIVITY_CPP_VERSION_MAJOR@.@CONNECTIVITY_CPP_VERSION_MINOR@.@CONNECTIVITY_CPP_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 = No # 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 = @CMAKE_SOURCE_DIR@/include # 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 = YES # 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 = YES # 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 = YES # 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 = YES # 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 = YES # 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_SOURCE_DIR@/include @CMAKE_CURRENT_SOURCE_DIR@ # 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_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 = NO # 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 = @CMAKE_CURRENT_SOURCE_DIR@/extra.css # 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 = YES # 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 = YES # 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 = YES # 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 = YES # 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 = YES # 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 = 0 # 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 connectivity-api-0.0.1+14.04.20140312/doc/CMakeLists.txt0000644000015201777760000000322012307723555022701 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 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 . # # Authors: # Antti Kaijanmäki option( CONNECTIVITY_CPP_ENABLE_DOC_GENERATION "Generate package documentation with doxygen" ON ) if (CONNECTIVITY_CPP_ENABLE_DOC_GENERATION) 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 ${CMAKE_INSTALL_DOCDIR}) install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/xml DESTINATION ${CMAKE_INSTALL_DOCDIR}) endif (DOXYGEN_FOUND) endif (CONNECTIVITY_CPP_ENABLE_DOC_GENERATION) # list these here to have them visible in Qt Creator set(DOC_PAGES pages/mainpage.dox pages/using.dox pages/networking-status.dox ) add_custom_target(QtCreatorDocsHack SOURCES ${DOC_PAGES}) connectivity-api-0.0.1+14.04.20140312/examples/0000755000015201777760000000000012307723764021217 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/examples/example_airplane_mode.cpp0000644000015201777760000000377712307723555026251 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 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 . * * Authors: * Antti Kaijanmäki */ #include #include #include #include namespace cuc = com::ubuntu::connectivity; int main(int, char *[]) { auto mgr = cuc::networking::Manager::createInstance(); if (mgr->flightMode().get() == cuc::networking::Manager::FlightModeStatus::off) std::cout << "Initial Flight Mode: Off" << std::endl; else std::cout << "Initial Flight Mode: On" << std::endl; mgr->flightMode().changed().connect( [](cuc::networking::Manager::FlightModeStatus status) { switch (status) { case cuc::networking::Manager::FlightModeStatus::on: std::cout << "Flight Mode is On" << std::endl; break; case cuc::networking::Manager::FlightModeStatus::off: std::cout << "Flight Mode Off" << std::endl; break; } }); mgr->enableFlightMode(); // enable wifi devices while in flightmode for (auto link : mgr->links().get()) { if (link->type() == cuc::networking::Link::Type::wifi) { link->enable(); } } mgr->disableFlightMode(); sigset_t signal_set; sigemptyset(&signal_set); sigaddset(&signal_set, SIGINT); int signal; sigwait(&signal_set, &signal); return 0; } connectivity-api-0.0.1+14.04.20140312/examples/CMakeLists.txt0000644000015201777760000000260612307723555023761 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 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 . # # Authors: # Antti Kaijanmäki add_executable( example_airplane_mode example_airplane_mode.cpp ) target_link_libraries(example_airplane_mode connectivity-cpp) add_executable( example_available_links example_available_links.cpp ) target_link_libraries(example_available_links connectivity-cpp) add_executable( example_connect_to_wifi_network example_connect_to_wifi_network.cpp ) target_link_libraries(example_connect_to_wifi_network connectivity-cpp) add_executable( example_networking_status example_networking_status.cpp ) target_link_libraries(example_networking_status connectivity-cpp) add_executable( example_tor_over_vpn example_tor_over_vpn.cpp ) target_link_libraries(example_tor_over_vpn connectivity-cpp) connectivity-api-0.0.1+14.04.20140312/examples/example_networking_status.cpp0000644000015201777760000000553312307723555027234 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 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 . * * Authors: * Antti Kaijanmäki */ #include #include #include //! [include] #include namespace networking = com::ubuntu::connectivity::networking; //! [include] int main(int, char *[]) { //! [create manager] auto mgr = networking::Manager::createInstance(); //! [create manager] // Subscribe to system networking changes //! [subscribe networking status changes] mgr->status().changed().connect( [](networking::Manager::NetworkingStatus status) { switch(status) { case networking::Manager::NetworkingStatus::offline: { std::cout << "System networking status changed to: offline" << std::endl; break; } case networking::Manager::NetworkingStatus::connecting: { std::cout << "System networking status changed to: connecting" << std::endl; break; } case networking::Manager::NetworkingStatus::online: { std::cout << "System networking status changed to: online" << std::endl; break; } } }); //! [subscribe networking status changes] // Subscribe to characteristics changes //! [subscribe characteristics changes] mgr->characteristics().changed().connect( [](std::uint32_t characteristics) { std::cout << "System networking characteristics changed:" << std::endl; if ((characteristics & networking::Link::Characteristics::has_monetary_costs) != 0) { std::cout << " - has monetary costs" << std::endl; } if ((characteristics & networking::Link::Characteristics::is_bandwidth_limited) != 0) { std::cout << " - is bandwith limited" << std::endl; } if ((characteristics & networking::Link::Characteristics::is_volume_limited) != 0) { std::cout << " - is volume_limited" << std::endl; } }); //! [subscribe characteristics changes] sigset_t signal_set; sigemptyset(&signal_set); sigaddset(&signal_set, SIGINT); int signal; sigwait(&signal_set, &signal); return 0; } connectivity-api-0.0.1+14.04.20140312/examples/example_connect_to_wifi_network.cpp0000644000015201777760000000353612307723555030365 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 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 . * * Authors: * Antti Kaijanmäki */ #include #include #include #include namespace cuc = com::ubuntu::connectivity; int main(int, char *[]) { auto mgr = cuc::networking::Manager::createInstance(); // Store the first network over a wireless link with snr > 80% std::shared_ptr wireless_network; for (auto link : mgr->links().get()) { if (link->type() != cuc::networking::Link::Type::wifi) continue; auto wifilink = std::dynamic_pointer_cast(link); for (auto ap : wifilink->accessPoints().get()) { if (ap->strength().get() > 80.0) { wireless_network = ap; break; } } if (wireless_network) { std::cout << "Connecting to " << wireless_network->ssid() << std::endl; wifilink->connect_to(wireless_network); break; } } if (!wireless_network) { std::cout << "Could not find suitable network." << std::endl; } return 0; } connectivity-api-0.0.1+14.04.20140312/examples/example_available_links.cpp0000644000015201777760000000423012307723555026553 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 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 . * * Authors: * Antti Kaijanmäki */ #include #include #include #include namespace cuc = com::ubuntu::connectivity; int main(int, char *[]) { auto mgr = cuc::networking::Manager::createInstance(); for (auto link : mgr->links().get()) { switch (link->type()) { case(cuc::networking::Link::Type::wifi): { std::cout << "Wi-Fi link: " << std::endl; auto wifilink = std::dynamic_pointer_cast(link); std::cout << " Available Wi-Fi access points:" << std::endl; for (auto ap : wifilink->accessPoints().get()) { std::cout << " " << ap->ssid() << ", secured: " << (ap->secured() ? "yes" : "no") << ", strength: " << ap->strength().get() << ", adhoc: " << (ap->adhoc() ? "yes" : "no") << std::endl; } break; } case(cuc::networking::Link::Type::wired): { std::cout << "Wired link" << std::endl; break; } case(cuc::networking::Link::Type::wwan): { std::cout << "WWan link" << std::endl; break; } case(cuc::networking::Link::Type::service): { std::cout << "Service link" << std::endl; break; } } } return 0; } connectivity-api-0.0.1+14.04.20140312/examples/example_tor_over_vpn.cpp0000644000015201777760000000610412307723555026157 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 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 . * * Authors: * Antti Kaijanmäki */ #include #include #include #include #include #include namespace cuc = com::ubuntu::connectivity; int main(int, char *[]) { auto mgr = cuc::networking::Manager::createInstance(); // this example assumes that there is only one VPN link configured // and the Tor service is configured to require that VPN link std::shared_ptr vpn; std::shared_ptr tor; for (auto service : mgr->services().get()) { if (service->type() == cuc::networking::Service::Type::tor) { tor = std::dynamic_pointer_cast(service); continue; } if (service->type() == cuc::networking::Service::Type::vpn) { vpn = std::dynamic_pointer_cast(service); continue; } } try { if (!vpn || !tor) throw std::logic_error("not configured properly"); // just do some verifying. // VPN and Tor are configured using private APIs. if (tor->requires() == vpn) std::cout << "tor requires vpn: check." << std::endl; else throw std::logic_error("not configured properly"); if (tor->establishedOver() == vpn->link()) std::cout << "tor uses the vpn link: check." << std::endl; tor->status().changed().connect( [](cuc::networking::Service::Status status) { switch(status) { case cuc::networking::Service::Status::stopped: { std::cout << "Tor stopped" << std::endl; } case cuc::networking::Service::Status::starting: { std::cout << "Tor starting" << std::endl; } case cuc::networking::Service::Status::running: { std::cout << "Tor running" << std::endl; } } }); // now, just start tor. // this will also bring up VPN service and the specific VPN link tor->start(); } catch (std::exception &e) { std::cerr << e.what() << std::endl; return -1; } return 0; } connectivity-api-0.0.1+14.04.20140312/src/0000755000015201777760000000000012307723764020170 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/src/manager.cpp0000644000015201777760000000203312307723555022302 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 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 . * * Authors: * Antti Kaijanmäki */ #include "platform/nmofono/manager.h" #include using namespace com::ubuntu::connectivity::networking; Manager::Manager() { } std::unique_ptr Manager::createInstance() { std::unique_ptr mgr; mgr.reset(new platform::nmofono::Manager); return mgr; } connectivity-api-0.0.1+14.04.20140312/src/CMakeLists.txt0000644000015201777760000000222712307723555022731 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 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 . # # Authors: # Antti Kaijanmäki add_library(connectivity-cpp SHARED manager.cpp ) set_target_properties(connectivity-cpp PROPERTIES VERSION ${CONNECTIVITY_CPP_VERSION_MAJOR}.${CONNECTIVITY_CPP_VERSION_MINOR}.${CONNECTIVITY_CPP_VERSION_PATCH} SOVERSION ${CONNECTIVITY_CPP_VERSION_MAJOR} OUTPUT_NAME "connectivity-cpp" ) target_link_libraries(connectivity-cpp platform_nmofono) add_subdirectory(platform/nmofono) install( TARGETS connectivity-cpp LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) connectivity-api-0.0.1+14.04.20140312/src/platform/0000755000015201777760000000000012307723764022014 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/0000755000015201777760000000000012307723764023467 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/manager.h0000644000015201777760000000475712307723555025265 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef PLATFORM_NMOFONO_MANAGER #define PLATFORM_NMOFONO_MANAGER #include #include #include namespace platform { namespace nmofono { class Manager; class Network; } } class platform::nmofono::Manager : public com::ubuntu::connectivity::networking::Manager { std::shared_ptr nm; std::shared_ptr urfkill; void updateNetworkingStatus(std::uint32_t); struct State { State(); ~State(); std::shared_ptr m_bus; std::thread worker; }; std::unique_ptr m_state; public: Manager(); // Public API void enableFlightMode(); void disableFlightMode(); const core::Property& flightMode(); const core::Property>>& links(); const core::Property>>&services(); const core::Property & status(); const core::Property& characteristics(); // private API core::Property m_flightMode; core::Property>> m_links; core::Property>> m_services; core::Property m_status; core::Property m_characteristics; }; #endif connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/bounded_integer.h0000644000015201777760000001125212307723555026774 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_CONNECTIVITY_BOUNDED_INTEGER_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_BOUNDED_INTEGER_H_ #include #include namespace com { namespace ubuntu { namespace location { namespace connectivity { /** * @brief A helper class to handle bounded integer values, with an optional domain * for tagging domain-specific types. */ template class BoundedInteger { public: static_assert(min < max, "min >= max"); /** * @brief Access the minimum value of the integer. */ inline static int minimum() { return min; } /** * @brief Access the maximum value of the integer. */ inline static int maximum() { return max; } /** * @brief Returns max - min. */ inline static int range() { return max - min; } /** * @brief Constructs an invalid instance. */ BoundedInteger() : value(min-1) { } /** * @brief Constructs an instance from a raw value * @param value The raw value. * @throw std::runtime_error if value is not in [min, max]. */ explicit BoundedInteger(int value) : value(value) { if (value < min || value > max) throw std::runtime_error( std::to_string(value) + " is not in " + "[" + std::to_string(min) + ", " + std::to_string(max) + "]"); } /** * @brief Copy c'tor. * @param rhs The instance to copy from. */ BoundedInteger(const BoundedInteger& rhs) : value(rhs.value) { } /** * @brief Assignment operator. * @param rhs The instance to assign from. * @return A mutable reference to this instance. */ BoundedInteger& operator=(const BoundedInteger& rhs) { value = rhs.value; return *this; } /** * @brief Equality comparison operator. * @param rhs The instance to compare to. * @return true iff both instances' value are equal. */ bool operator==(const BoundedInteger& rhs) const { return value == rhs.value; } /** * @brief Implicit casting operator to a raw integer value. * @return The raw integer value. */ inline operator int() const { return get(); } /** * @brief is_valid checks whether the contained value is in [min, max]. * @return true iff the contained integer value is in [min, max]. */ inline bool is_valid() const { return min <= value && value <= max; } /** * @brief Returns the raw integer value contained in this instance. * @throw std::runtime_error if is_valid() returns false. */ inline int get() const { if (!is_valid()) throw std::runtime_error("BoundedInteger::get: Contained value is not valid."); return value; } /** * @brief Assigns a new raw integer value * @param new_value The new value. * @throw std::runtime_error if new_value is not in [min, max]. */ inline void set(int new_value) { if (new_value < min || new_value > max) throw std::runtime_error( std::to_string(new_value) + " is not in " + "[" + std::to_string(min) + ", " + std::to_string(max) + "]"); value = new_value; } /** * @brief operator << pretty prints an instance of BoundedInteger. * @param out The stream to print to. * @param bi The instance to print. * @return The stream that has been printed to. */ inline friend std::ostream& operator<<(std::ostream& out, const BoundedInteger& bi) { out << bi.value; if (!bi.is_valid()) out << " -> invalid"; return out; } private: int value; }; } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_BOUNDED_INTEGER_H_ connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/manager.cpp0000644000015201777760000001512012307723555025602 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 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 . * * Authors: * Antti Kaijanmäki */ #include "manager.h" #include "wifi/link.h" #include "set_name_for_thread.h" #include using namespace platform::nmofono; namespace networking = com::ubuntu::connectivity::networking; namespace dbus = core::dbus; namespace fdo = org::freedesktop; namespace NM = fdo::NetworkManager; Manager::State::State() { try { m_bus = std::make_shared(dbus::WellKnownBus::system); } catch(std::runtime_error e) { std::cerr << "Failed to connect to the bus: " << e.what() << std::endl; throw; } auto executor = dbus::asio::make_executor(m_bus); m_bus->install_executor(executor); worker = std::move(std::thread([this]() { m_bus->run(); })); com::ubuntu::location::set_name_for_thread( worker, "OfonoNmConnectivityManagerWorkerThread"); } Manager::State::~State() { if (worker.joinable()) { m_bus->stop(); worker.join(); } } void Manager::updateNetworkingStatus(std::uint32_t status) { switch(status) { case NM_STATE_UNKNOWN: case NM_STATE_ASLEEP: case NM_STATE_DISCONNECTED: case NM_STATE_DISCONNECTING: { m_status.set(networking::Manager::NetworkingStatus::offline); break; } case NM_STATE_CONNECTING: { m_status.set(networking::Manager::NetworkingStatus::connecting); break; } case NM_STATE_CONNECTED_LOCAL: case NM_STATE_CONNECTED_SITE: case NM_STATE_CONNECTED_GLOBAL: { m_status.set(networking::Manager::NetworkingStatus::online); break; } } } Manager::Manager() { try { m_state.reset(new State); } catch (...) { throw; } auto nm_service = std::make_shared(m_state->m_bus); nm = nm_service->nm; auto urfkill_service = std::make_shared(m_state->m_bus); urfkill = urfkill_service->urfkill; /// @todo add a watcher for the service /// @todo exceptions /// @todo offload the initialization to a thread or something /// @todo those Id() thingies nm->device_added->connect([this](const dbus::types::ObjectPath &path){ std::cout << "Device Added:" << path.as_string() << std::endl; auto links = m_links.get(); for (auto dev : links) { if (std::dynamic_pointer_cast(dev)->m_dev.object->path() == path) { // already in the list return; } } NM::Interface::Device dev(nm->service, nm->service->object_for_path(path)); if (dev.type() == NM::Interface::Device::Type::wifi) { links.insert(std::make_shared(dev,*nm.get())); m_links.set(links); } }); nm->device_removed->connect([this](const dbus::types::ObjectPath &path){ std::cout << "Device Removed:" << path.as_string() << std::endl; auto links = m_links.get(); for (auto dev : links) { if (std::dynamic_pointer_cast(dev)->m_dev.object->path() == path) { links.erase(dev); break; } } m_links.set(links); }); std::set > links; for(auto dev : nm->get_devices()) { switch (dev.type()) { case NM::Interface::Device::Type::wifi: { std::shared_ptr link; link.reset(new wifi::Link(dev, *nm.get())); links.insert(link); break; } default: ; } } m_links.set(links); updateNetworkingStatus(nm->state->get()); nm->properties_changed->connect([this](NM::Interface::NetworkManager::Signal::PropertiesChanged::ArgumentType map) { for (auto entry : map) { const std::string &key = entry.first; if (key == "ActiveConnections") { } else if (key == "PrimaryConnection") { } else if (key == "State") { updateNetworkingStatus(entry.second.as()); } } }); // if even one of the rfkill devices is not blocked we set flightmode OFF // once we get the flightmode backend we can do partial flight mode m_flightMode.set(networking::Manager::FlightModeStatus::on); for (auto path : urfkill->enumerate_devices()) { fdo::URfkill::Interface::Device dev(urfkill->service->object_for_path(path)); if (!dev.soft->get() && !dev.hard->get()) { m_flightMode.set(networking::Manager::FlightModeStatus::off); break; } } /// @todo set by the default connections. m_characteristics.set(networking::Link::Characteristics::empty); } void Manager::enableFlightMode() { if (urfkill->block(0/*all*/, true)) m_flightMode.set(networking::Manager::FlightModeStatus::on); else m_flightMode.set(networking::Manager::FlightModeStatus::off); } void Manager::disableFlightMode() { if (urfkill->block(0/*all*/, false)) m_flightMode.set(networking::Manager::FlightModeStatus::off); else m_flightMode.set(networking::Manager::FlightModeStatus::on); } const core::Property& Manager::flightMode() { // - connect to each individual URfkill.Killswitch interface // - make this property to reflect their combined state /// @todo implement flightmode status properly when URfkill gets the flightmode API return m_flightMode; } const core::Property > >& Manager::links() { return m_links; } const core::Property>>& Manager::services() { return m_services; } const core::Property & Manager::status() { return m_status; } const core::Property& Manager::characteristics() { return m_characteristics; } connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/service/0000755000015201777760000000000012307723764025127 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/CMakeLists.txt0000644000015201777760000000207012307723555026224 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 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 . # # Authors: # Antti Kaijanmäki set(NMOFONO_PLATFORM_SOURCES manager.cpp manager.h service.cpp service.h wifi/access-point.h wifi/link.h wifi/link.cpp #ofono_nm_connectivity_manager.cpp set_name_for_thread.cpp set_name_for_thread.h ) add_library(platform_nmofono STATIC ${NMOFONO_PLATFORM_SOURCES}) target_link_libraries( platform_nmofono ${DBUSCPP_LIBRARIES} ) connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/service.cpp0000644000015201777760000000132212307723555025627 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 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 . * * Authors: * Antti Kaijanmäki */ connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/ofono_nm_connectivity_manager.cpp0000644000015201777760000002775412307723555032312 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 "nm.h" #include "ofono.h" #include #include #include #include #include #include #include #include #include #include #include #include "set_name_for_thread.h" #include #include "manager_ref.h" namespace connectivity = com::ubuntu::location::connectivity; namespace dbus = core::dbus; namespace { template struct DispatchedProperty : public core::Property { typedef std::function Getter; DispatchedProperty(const Getter& getter = Getter()) : getter(getter) { } const T& get() const { if (getter) { return core::Property::mutable_get() = getter(); } return core::Property::get(); } Getter getter; }; struct State { ~State(); std::thread worker; } state; const std::shared_ptr& system_bus() { static std::once_flag once; static const std::shared_ptr instance { new dbus::Bus(dbus::WellKnownBus::system) }; std::call_once(once,[] { auto executor = dbus::asio::make_executor(instance); instance->install_executor(executor); state.worker = std::move(std::thread([]() { instance->run(); })); com::ubuntu::location::set_name_for_thread( state.worker, "OfonoNmConnectivityManagerWorkerThread"); }); return instance; } State::~State() { if (worker.joinable()) { system_bus()->stop(); worker.join(); } } } namespace { struct OfonoNmConnectivityManager : public connectivity::Manager { OfonoNmConnectivityManager() { d.visible_wireless_networks.getter = [this]() { auto devices = d.network_manager.get_devices(); std::vector wifis; for(const auto& device : devices) { if (device.type() == org::freedesktop::NetworkManager::Device::Type::wifi) { auto aps = device.get_access_points(); for(auto const& ap : aps) { connectivity::WirelessNetwork wifi; wifi.bssid = ap.hw_address->get(); wifi.frequency.set(ap.frequency->get()); wifi.snr = ap.strength->get() / 127.; wifis.push_back(wifi); } } } return std::vector(wifis); }; d.visible_radio_cells.getter = [this]() { std::vector cells; d.modem_manager.for_each_modem([&cells](const org::Ofono::Manager::Modem& modem) { static const std::map type_lut = { { org::Ofono::Manager::Modem::NetworkRegistration::Technology::gsm(), connectivity::RadioCell::Type::gsm }, { org::Ofono::Manager::Modem::NetworkRegistration::Technology::lte(), connectivity::RadioCell::Type::lte }, { org::Ofono::Manager::Modem::NetworkRegistration::Technology::umts(), connectivity::RadioCell::Type::umts }, { org::Ofono::Manager::Modem::NetworkRegistration::Technology::edge(), connectivity::RadioCell::Type::unknown }, { org::Ofono::Manager::Modem::NetworkRegistration::Technology::hspa(), connectivity::RadioCell::Type::unknown }, {std::string(), connectivity::RadioCell::Type::unknown} }; auto radio_type = type_lut.at( modem.network_registration.get< org::Ofono::Manager::Modem::NetworkRegistration::Technology >()); auto lac = modem.network_registration.get< org::Ofono::Manager::Modem::NetworkRegistration::LocationAreaCode >(); auto cell_id = modem.network_registration.get< org::Ofono::Manager::Modem::NetworkRegistration::CellId >(0); auto strength = modem.network_registration.get< org::Ofono::Manager::Modem::NetworkRegistration::Strength >(0); std::stringstream ssmcc { modem.network_registration.get< org::Ofono::Manager::Modem::NetworkRegistration::MobileCountryCode >() }; int mcc{0}; ssmcc >> mcc; std::stringstream ssmnc { modem.network_registration.get< org::Ofono::Manager::Modem::NetworkRegistration::MobileNetworkCode >() }; int mnc{0}; ssmnc >> mnc; switch(radio_type) { case connectivity::RadioCell::Type::gsm: { connectivity::RadioCell::Gsm gsm { connectivity::RadioCell::Gsm::MCC{mcc}, connectivity::RadioCell::Gsm::MNC{mnc}, connectivity::RadioCell::Gsm::LAC{lac}, connectivity::RadioCell::Gsm::ID{cell_id}, connectivity::RadioCell::Gsm::RSS { connectivity::RadioCell::Gsm::RSS::minimum() + strength/127. * connectivity::RadioCell::Gsm::RSS::range() }, connectivity::RadioCell::Gsm::ASU { 0.5 * (strength/127. * connectivity::RadioCell::Gsm::RSS::range()) }, connectivity::RadioCell::Gsm::TA{0} }; cells.emplace_back(gsm); break; } case connectivity::RadioCell::Type::lte: { connectivity::RadioCell::Lte lte { connectivity::RadioCell::Lte::MCC{mcc}, connectivity::RadioCell::Lte::MNC{mnc}, connectivity::RadioCell::Lte::LAC{lac}, connectivity::RadioCell::Lte::ID{cell_id}, connectivity::RadioCell::Lte::PID{0}, connectivity::RadioCell::Lte::RSS { connectivity::RadioCell::Lte::RSS::minimum() + strength/127. * connectivity::RadioCell::Lte::RSS::range() }, connectivity::RadioCell::Lte::ASU { 140 + connectivity::RadioCell::Lte::RSS::minimum() + strength/127. * connectivity::RadioCell::Lte::RSS::range() }, connectivity::RadioCell::Lte::TA{0} }; cells.emplace_back(lte); break; } case connectivity::RadioCell::Type::umts: { connectivity::RadioCell::Umts umts { connectivity::RadioCell::Umts::MCC{mcc}, connectivity::RadioCell::Umts::MNC{mnc}, connectivity::RadioCell::Umts::LAC{lac}, connectivity::RadioCell::Umts::ID{cell_id}, connectivity::RadioCell::Umts::RSS { connectivity::RadioCell::Umts::RSS::minimum() + strength/127. * connectivity::RadioCell::Umts::RSS::range() }, connectivity::RadioCell::Umts::ASU { 116 + connectivity::RadioCell::Umts::RSS::minimum() + strength/127. * connectivity::RadioCell::Umts::RSS::range() } }; cells.emplace_back(umts); break; } case connectivity::RadioCell::Type::cdma: { connectivity::RadioCell::Cdma cdma { connectivity::RadioCell::Cdma::MCC{mcc}, connectivity::RadioCell::Cdma::MNC{mnc}, connectivity::RadioCell::Cdma::LAC{lac}, connectivity::RadioCell::Cdma::ID{cell_id}, connectivity::RadioCell::Cdma::RSS { connectivity::RadioCell::Cdma::RSS::minimum() + strength/127. * connectivity::RadioCell::Cdma::RSS::range() }, connectivity::RadioCell::Cdma::ASU { // TODO(tvoss): // RSSI [dBm] >= -75: ASU = 16, // RSSI [dBm] >= -82: ASU = 8, // RSSI [dBm] >= -90: ASU = 4, // RSSI [dBm] >= -95: ASU = 2, // RSSI [dBm] >= -100: ASU = 1. } }; cells.emplace_back(cdma); break; } default: break; // By default, we do not add a cell. } }); return cells; }; } const core::Property>& visible_wireless_networks() { return d.visible_wireless_networks; } const core::Property>& visible_radio_cells() { return d.visible_radio_cells; } struct Private { Private() : network_manager(system_bus()), modem_manager(system_bus()) { } org::freedesktop::NetworkManager network_manager; org::Ofono::Manager modem_manager; DispatchedProperty> visible_wireless_networks; DispatchedProperty> visible_radio_cells; } d; }; } const std::shared_ptr& connectivity::platform_default_manager() { static const std::shared_ptr instance{new OfonoNmConnectivityManager{}}; return instance; } connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/set_name_for_thread.h0000644000015201777760000000204312307723555027625 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_SET_NAME_FOR_THREAD_H #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SET_NAME_FOR_THREAD_H #include namespace com { namespace ubuntu { namespace location { void set_name_for_thread(std::thread& t, const char* name); } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SET_NAME_FOR_THREAD_H connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/wifi/0000755000015201777760000000000012307723764024425 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/wifi/link.h0000644000015201777760000000527212307723555025537 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef PLATFORM_TEST_WIFI_LINK #define PLATFORM_TEST_WIFI_LINK #include #include namespace platform { namespace nmofono { namespace wifi { class Link; } } } class platform::nmofono::wifi::Link : public com::ubuntu::connectivity::networking::wifi::Link { public: Link(org::freedesktop::NetworkManager::Interface::Device dev, org::freedesktop::NetworkManager::Interface::NetworkManager nm); ~Link(); // public API void enable(); void disable(); Type type() const; const core::Property& characteristics(); const core::Property& status(); Id id() const; std::string name() const; const core::Property>>& accessPoints(); void connect_to(std::shared_ptr accessPoint); const core::Property>& activeAccessPoint(); // private API void updateDeviceState(std::uint32_t new_state); void updateActiveConnection(const core::dbus::types::ObjectPath &path); void setFlightMode(bool value); core::Property m_characteristics; core::Property m_status; core::Property>> m_accessPoints; core::Property> m_activeAccessPoint; org::freedesktop::NetworkManager::Interface::Device m_dev; org::freedesktop::NetworkManager::Interface::Device::Wireless m_wireless; org::freedesktop::NetworkManager::Interface::NetworkManager m_nm; bool m_disabled; bool m_flightMode; std::uint32_t m_lastState; std::string m_name; std::shared_ptr m_activeConnection; }; #endif connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/wifi/link.cpp0000644000015201777760000002366012307723555026073 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 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 . * * Authors: * Antti Kaijanmäki */ #include "link.h" #include "access-point.h" using namespace platform::nmofono::wifi; namespace networking = com::ubuntu::connectivity::networking; namespace dbus = core::dbus; namespace fdo = org::freedesktop; namespace NM = fdo::NetworkManager; using core::Property; Link::Link(NM::Interface::Device dev, NM::Interface::NetworkManager nm) : m_dev(dev), m_wireless(dev.object), m_nm(nm), m_flightMode(false) { m_characteristics.set(Link::Characteristics::empty); m_status.set(Status::disabled); m_name = m_dev.device_interface->get(); std::set> list; for (auto access_point : dev.get_access_points()) { list.insert(std::make_shared(access_point)); } m_accessPoints.set(list); updateDeviceState(m_dev.state->get()); m_dev.state_changed->connect([this](NM::Interface::Device::Signal::StateChanged::ArgumentType args) { // StateChanged ( u: new_state, u: old_state, u: reason ) std::uint32_t new_state = std::get<0>(args); // std::uint32_t old_state = std::get<1>(args); // std::uint32_t reason = std::get<2>(args); updateDeviceState(new_state); }); m_wireless.access_point_added->connect([this](const dbus::types::ObjectPath &path) { for (auto ap : m_accessPoints.get()) { if (std::dynamic_pointer_cast(ap)->m_ap.object->path() == path) { // already in the list return; } } auto list = m_accessPoints.get(); NM::Interface::AccessPoint ap(m_nm.service->object_for_path(path)); list.insert(std::make_shared(ap)); m_accessPoints.set(list); }); m_wireless.access_point_removed->connect([this](const dbus::types::ObjectPath &path) { auto list = m_accessPoints.get(); for (auto ap : list) { if (std::dynamic_pointer_cast(ap)->m_ap.object->path() == path) { list.erase(ap); m_accessPoints.set(list); return; } } }); } Link::~Link() {} void Link::enable() { std::cout << "Link::enable()" << std::endl; /// @todo see comment in disable() m_flightMode = false; m_nm.wireless_enabled->set(true); #if 0 /** @todo: * NetworkManager 0.9.9 allows doing this below and letting NM to figure out the best connection: * * m_nm.activate_connection(dbus::types::ObjectPath("/"), * m_dev.object->path(), * core::dbus::typ es::ObjectPath("/")); * * for now we get somewhat similar result by toggling the Autoconnect property, * but this breaks the possible setting we will have for autoconnecting later. */ m_dev.autoconnect->set(true); m_disabled = false; #endif } void Link::disable() { std::cout << "Link::disable()" << std::endl; /// @todo for now just disable wireless completely. /// this only works properly when there is one wifi adapter on the system m_flightMode = true; /// @todo remove this hack once NM properly detects external rfkill m_nm.wireless_enabled->set(false); #if 0 /** @todo remove this after NM 0.9.9 is available. check comment in enable() */ m_dev.autoconnect->set(false); m_dev.disconnect(); m_disabled = true; #endif } networking::Link::Type Link::type() const { return Type::wifi; } const Property& Link::characteristics() { return m_characteristics; } const Property& Link::status() { return m_status; } networking::Link::Id Link::id() const { return 0; } std::string Link::name() const { return m_name; } const Property > >& Link::accessPoints() { return m_accessPoints; } void Link::connect_to(std::shared_ptr accessPoint) { std::shared_ptr ap = std::dynamic_pointer_cast(accessPoint); NM::Interface::Connection *found = nullptr; auto connections = m_dev.get_available_connections(); for (auto &con : connections) { for (auto map : con.get_settings()) { if (map.first == "802-11-wireless") { for (auto conf : map.second) { if (conf.first == "ssid") { std::vector value; value = conf.second.as>(); if (value == ap->m_ap.ssid->get()) { found = &con; break; } } } } } } /// @todo check the timestamps as there might be multiple ones that are suitable. /// @todo oh, and check more parameters than just the ssid core::dbus::types::ObjectPath ac; if (found) { ac = m_nm.activate_connection(found->object->path(), m_dev.object->path(), ap->m_ap.object->path()); } else { std::map > conf; /// @todo getting the ssid multiple times over dbus is stupid. std::map wireless_conf; wireless_conf["ssid"] = dbus::types::Variant::encode>(ap->m_ap.ssid->get()); conf["802-11-wireless"] = wireless_conf; auto ret = m_nm.add_and_activate_connection(conf, m_dev.object->path(), ap->m_ap.object->path()); ac = std::get<1>(ret); } updateActiveConnection(ac); } const Property >& Link::activeAccessPoint() { return m_activeAccessPoint; } void Link::updateDeviceState(std::uint32_t new_state) { m_lastState = new_state; switch (new_state){ case NM_DEVICE_STATE_UNKNOWN: case NM_DEVICE_STATE_UNMANAGED: case NM_DEVICE_STATE_UNAVAILABLE: case NM_DEVICE_STATE_DISCONNECTED: case NM_DEVICE_STATE_DEACTIVATING: case NM_DEVICE_STATE_FAILED: { /// @todo need to find a way to actually disable individual devices in NM /// this is just a work-around as NM does not detect external rfkill if (m_flightMode) m_status.set(Status::disabled); else m_status.set(Status::offline); updateActiveConnection(core::dbus::types::ObjectPath("/")); break; } case NM_DEVICE_STATE_PREPARE: case NM_DEVICE_STATE_CONFIG: case NM_DEVICE_STATE_NEED_AUTH: case NM_DEVICE_STATE_IP_CONFIG: case NM_DEVICE_STATE_IP_CHECK: { m_status.set(Status::connecting); auto path = m_dev.active_connection->get(); // for some reason the path is not always set on these // states. Let's not clear the active connection as obviously // we have one. if (path != core::dbus::types::ObjectPath("/")) updateActiveConnection(path); break; } case NM_DEVICE_STATE_SECONDARIES: { m_status.set(Status::connected); updateActiveConnection(m_dev.active_connection->get()); break; } case NM_DEVICE_STATE_ACTIVATED: { m_status.set(Status::online); updateActiveConnection(m_dev.active_connection->get()); break; }} } /// '/' path means invalid. void Link::updateActiveConnection(const core::dbus::types::ObjectPath &path) { // clear the one we have. if (path == core::dbus::types::ObjectPath("/")) { m_activeAccessPoint.set(com::ubuntu::connectivity::networking::wifi::AccessPoint::Ptr()); m_activeConnection.reset(); return; } // already up-to-date if (m_activeConnection && m_activeConnection->object->path() == path) return; try { m_activeConnection = std::make_shared( m_dev.service->object_for_path(path)); auto state = m_activeConnection->get_state(); switch (state) { case NM::Interface::ActiveConnection::State::unknown: case NM::Interface::ActiveConnection::State::activating: case NM::Interface::ActiveConnection::State::activated: case NM::Interface::ActiveConnection::State::deactivating: case NM::Interface::ActiveConnection::State::deactivated: ; // for Wi-Fi devices specific_object is the AccessPoint object. auto ap_path = m_activeConnection->specific_object->get(); for (auto ap : m_accessPoints.get()) { auto nm_ap = std::dynamic_pointer_cast(ap); if (nm_ap->m_ap.object->path() == ap_path) { m_activeAccessPoint.set(ap); break; } } } } catch (std::exception &e) { std::cerr << "failed to get active connection:" << std::endl << "\tpath: " << path.as_string() << std::endl << "\t" << e.what() << std::endl; } } void Link::setFlightMode(bool value) { m_flightMode = value; updateDeviceState(m_lastState); } connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/wifi/access-point.h0000644000015201777760000000560112307723555027166 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef PLATFORM_NMOFONO_WIFI_ACCESS_POINT #define PLATFORM_NMOFONO_WIFI_ACCESS_POINT #include #include #include namespace platform { namespace nmofono { namespace wifi { class AccessPoint; } } } class platform::nmofono::wifi::AccessPoint : public com::ubuntu::connectivity::networking::wifi::AccessPoint { public: AccessPoint(org::freedesktop::NetworkManager::Interface::AccessPoint ap) : m_ap(ap) { m_secured = m_ap.flags->get() == NM_802_11_AP_FLAGS_PRIVACY; /// @todo check for the other modes also.. m_adhoc = m_ap.mode->get() != NM_802_11_MODE_INFRA; std::string ssid; for (auto c : m_ap.ssid->get()) { if (isprint(c)) { ssid += (char)c; } else { // contains unprintable characters /// @todo do something more elegant ssid += u8"�"; } } m_ssid = ssid; m_strength.set(m_ap.strength->get()); m_ap.properties_changed->connect([this](org::freedesktop::NetworkManager::Interface::AccessPoint::Signal::PropertiesChanged::ArgumentType map){ for (auto entry : map) { if (entry.first == "Strength") { m_strength.set(entry.second.as()); } } }); } const core::Property& strength() { return m_strength; } // time when last connected to this access point // for APs that have never been connected the // lastConnected->time_since_epoch().count() is 0 const core::Property& lastConnected() { return m_lastConnected; } std::string ssid() { return m_ssid; } bool secured() { return m_secured; } bool adhoc() { return m_adhoc; } core::Property m_strength; core::Property m_lastConnected; std::string m_ssid; bool m_secured; bool m_adhoc; org::freedesktop::NetworkManager::Interface::AccessPoint m_ap; }; #endif connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/set_name_for_thread.cpp0000644000015201777760000000156312307723555030166 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 "set_name_for_thread.h" void com::ubuntu::location::set_name_for_thread(std::thread& t, const char* name) { pthread_setname_np(t.native_handle(), name); } connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/service.h0000644000015201777760000000234212307723555025277 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 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 . * * Authors: * Antti Kaijanmäki */ #ifndef PLATFORM_NMOFONO_SERVICE #define PLATFORM_NMOFONO_SERVICE #include namespace platform { namespace nmofono { class Service; } } class platform::nmofono::Service : public com::ubuntu::connectivity::networking::Service { public: Type type() const; const Property& status(); std::shared_ptr requires(); std::shared_ptr link(); void start(); void stop(); Id id() const; Property& name(); }; #endif connectivity-api-0.0.1+14.04.20140312/src/platform/nmofono/manager_ref.h0000644000015201777760000003535712307723555026121 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_CONNECTIVITY_MANAGER_H_ #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_MANAGER_H_ #include "bounded_integer.h" #include #include #include namespace com { namespace ubuntu { namespace location { namespace connectivity { class RadioCell { public: enum class Type { unknown, gsm, umts, cdma, lte }; enum class Domain { mcc, mnc, lac, id, pid, rss, asu, ta }; template using MobileCountryCode = BoundedInteger(Domain::mcc)>; template using MobileNetworkCode = BoundedInteger(Domain::mnc)>; template using LocationAreaCode = BoundedInteger(Domain::lac)>; template using CellId = BoundedInteger(Domain::id)>; template using PhysicalId = BoundedInteger(Domain::pid)>; template using ReceivedSignalStrength = BoundedInteger(Domain::rss)>; template using ArbitraryStrengthUnit = BoundedInteger(Domain::asu)>; template using TimingAdvance = BoundedInteger(Domain::ta)>; struct Gsm { typedef MobileCountryCode<0,999> MCC; typedef MobileNetworkCode<0,999> MNC; typedef LocationAreaCode<0,65535> LAC; typedef CellId<0,65535> ID; typedef ReceivedSignalStrength<-113,-51> RSS; typedef ArbitraryStrengthUnit<0,31> ASU; typedef TimingAdvance<0,63> TA; bool operator==(const Gsm& rhs) const { return mobile_country_code == rhs.mobile_country_code && mobile_network_code == rhs.mobile_network_code && location_area_code == rhs.location_area_code && id == rhs.id && received_signal_strength == rhs.received_signal_strength && arbitrary_strength_unit == rhs.arbitrary_strength_unit && timing_advance == rhs.timing_advance; } inline friend std::ostream& operator<<(std::ostream& out, const Gsm& gsm) { out << "(" << "mcc: " << gsm.mobile_country_code << ", " << "mnc: " << gsm.mobile_network_code << ", " << "lac: " << gsm.location_area_code << ", " << "id: " << gsm.id << ", " << "rss: " << gsm.received_signal_strength << ", " << "asu: " << gsm.arbitrary_strength_unit << ", " << "ta: " << gsm.timing_advance << ")"; return out; } MCC mobile_country_code; MNC mobile_network_code; LAC location_area_code; ID id; RSS received_signal_strength; ASU arbitrary_strength_unit; TA timing_advance; }; struct Umts { typedef MobileCountryCode<0,999> MCC; typedef MobileNetworkCode<0,999> MNC; typedef LocationAreaCode<0,65535> LAC; typedef CellId<0,268435455> ID; typedef ReceivedSignalStrength<-121,-25> RSS; typedef ArbitraryStrengthUnit<-5,91> ASU; bool operator==(const Umts& rhs) const { return mobile_country_code == rhs.mobile_country_code && mobile_network_code == rhs.mobile_network_code && location_area_code == rhs.location_area_code && id == rhs.id && received_signal_strength == rhs.received_signal_strength && arbitrary_strength_unit == rhs.arbitrary_strength_unit; } inline friend std::ostream& operator<<(std::ostream& out, const Umts& umts) { out << "(" << "mcc: " << umts.mobile_country_code << ", " << "mnc: " << umts.mobile_network_code << ", " << "lac: " << umts.location_area_code << ", " << "id: " << umts.id << ", " << "rss: " << umts.received_signal_strength << ", " << "asu: " << umts.arbitrary_strength_unit << ")"; return out; } MCC mobile_country_code; MNC mobile_network_code; LAC location_area_code; ID id; RSS received_signal_strength; ASU arbitrary_strength_unit; }; struct Cdma { typedef MobileCountryCode<0,999> MCC; typedef MobileNetworkCode<0,32767> MNC; typedef LocationAreaCode<0,65535> LAC; typedef CellId<0,65535> ID; typedef ReceivedSignalStrength<-100,-75> RSS; typedef ArbitraryStrengthUnit<1,16> ASU; bool operator==(const Cdma& rhs) const { return mobile_country_code == rhs.mobile_country_code && mobile_network_code == rhs.mobile_network_code && location_area_code == rhs.location_area_code && id == rhs.id && received_signal_strength == rhs.received_signal_strength && arbitrary_strength_unit == rhs.arbitrary_strength_unit; } inline friend std::ostream& operator<<(std::ostream& out, const Cdma& cdma) { out << "(" << "mcc: " << cdma.mobile_country_code << ", " << "mnc: " << cdma.mobile_network_code << ", " << "lac: " << cdma.location_area_code << ", " << "id: " << cdma.id << ", " << "rss: " << cdma.received_signal_strength << ", " << "asu: " << cdma.arbitrary_strength_unit << ")"; return out; } MCC mobile_country_code; MNC mobile_network_code; LAC location_area_code; ID id; RSS received_signal_strength; ASU arbitrary_strength_unit; }; struct Lte { typedef MobileCountryCode<0,999> MCC; typedef MobileNetworkCode<0,32767> MNC; typedef LocationAreaCode<0,65535> LAC; typedef CellId<0,268435455> ID; typedef PhysicalId<0,503> PID; typedef ReceivedSignalStrength<-137,-45> RSS; typedef ArbitraryStrengthUnit<0,95> ASU; typedef TimingAdvance<0,63> TA; bool operator==(const Lte& rhs) const { return mobile_country_code == rhs.mobile_country_code && mobile_network_code == rhs.mobile_network_code && location_area_code == rhs.location_area_code && id == rhs.id && physical_id == rhs.physical_id && received_signal_strength == rhs.received_signal_strength && arbitrary_strength_unit == rhs.arbitrary_strength_unit && timing_advance == rhs.timing_advance; } inline friend std::ostream& operator<<(std::ostream& out, const Lte& lte) { out << "(" << "mcc: " << lte.mobile_country_code << ", " << "mnc: " << lte.mobile_network_code << ", " << "lac: " << lte.location_area_code << ", " << "id: " << lte.id << ", " << "id: " << lte.physical_id << ", " << "rss: " << lte.received_signal_strength << ", " << "asu: " << lte.arbitrary_strength_unit << ", " << "ta: " << lte.timing_advance << ")"; return out; } MCC mobile_country_code; MNC mobile_network_code; LAC location_area_code; ID id; PID physical_id; RSS received_signal_strength; ASU arbitrary_strength_unit; TA timing_advance; }; RadioCell() : radio_type(Type::gsm), detail{Gsm()} { } explicit RadioCell(const Gsm& gsm) : radio_type(Type::gsm), detail{gsm} { } explicit RadioCell(const Umts& umts) : radio_type(Type::umts), detail{umts} { } explicit RadioCell(const Cdma& cdma) : radio_type(Type::cdma), detail{cdma} { } explicit RadioCell(const Lte& lte) : radio_type(Type::lte), detail{lte} { } RadioCell(const RadioCell& rhs) : radio_type(rhs.radio_type) { switch(radio_type) { case Type::gsm: detail.gsm = rhs.detail.gsm; break; case Type::cdma: detail.cdma = rhs.detail.cdma; break; case Type::umts: detail.umts = rhs.detail.umts; break; case Type::lte: detail.lte = rhs.detail.lte; break; case Type::unknown: break; } } RadioCell& operator=(const RadioCell& rhs) { radio_type = rhs.radio_type; switch(radio_type) { case Type::gsm: detail.gsm = rhs.detail.gsm; break; case Type::cdma: detail.cdma = rhs.detail.cdma; break; case Type::umts: detail.umts = rhs.detail.umts; break; case Type::lte: detail.lte = rhs.detail.lte; break; case Type::unknown: break; } return *this; } bool operator==(const RadioCell& rhs) const { if (radio_type != rhs.radio_type) return false; switch(radio_type) { case Type::gsm: return detail.gsm == rhs.detail.gsm; case Type::cdma: return detail.cdma == rhs.detail.cdma; case Type::umts: return detail.umts == rhs.detail.umts; case Type::lte: return detail.lte == rhs.detail.lte; default: return true; } return false; } Type type() const { return radio_type; } const Gsm& gsm() const { if (radio_type != Type::gsm) throw std::runtime_error("Bad access to unset network type."); return detail.gsm; } const Umts& umts() const { if (radio_type != Type::umts) throw std::runtime_error("Bad access to unset network type."); return detail.umts; } const Cdma& cdma() const { if (radio_type != Type::cdma) throw std::runtime_error("Bad access to unset network type."); return detail.cdma; } const Lte& lte() const { if (radio_type != Type::lte) throw std::runtime_error("Bad access to unset network type."); return detail.lte; } inline friend std::ostream& operator<<(std::ostream& out, const RadioCell& cell) { switch (cell.radio_type) { case RadioCell::Type::gsm: out << cell.detail.gsm; break; case RadioCell::Type::cdma: out << cell.detail.cdma; break; case RadioCell::Type::umts: out << cell.detail.umts; break; case RadioCell::Type::lte: out << cell.detail.lte; break; } return out; } private: Type radio_type; struct None {}; union Detail { inline Detail() : none(None{}) { } inline explicit Detail(const Gsm& gsm) : gsm(gsm) { } inline explicit Detail(const Umts& umts) : umts(umts) { } inline explicit Detail(const Cdma& cdma) : cdma(cdma) { } inline explicit Detail(const Lte& lte) : lte(lte) { } None none; Gsm gsm; Umts umts; Cdma cdma; Lte lte; } detail; }; struct WirelessNetwork { enum class Domain { frequency, channel }; typedef BoundedInteger<2412, 5825, static_cast(Domain::frequency)> Frequency; typedef BoundedInteger<1, 165, static_cast(Domain::channel)> Channel; bool operator==(const WirelessNetwork& rhs) const { return bssid == rhs.bssid && frequency == rhs.frequency && channel == rhs.channel && snr == rhs.snr; } friend std::ostream& operator<<(std::ostream& out, const WirelessNetwork& wifi) { return out << "(" << "bssid: " << wifi.bssid << ", " << "frequency: " << wifi.frequency << ", " << "channel: " << wifi.channel << ", " << "snr: " << wifi.snr << ")"; } std::string bssid; ///< The BSSID of the network. Frequency frequency; ///< Frequency of the network/AP. Channel channel; ///< Channel of the network/AP. float snr; ///< Signal-noise ratio of the specific network. }; /** * @brief The Manager class encapsulates access to network/radio information */ class Manager { public: struct Errors { Errors() = delete; /** * @brief The ConnectivityManagementNotSupported struct is thrown if underlying * platform does not provide support for connectivity mgmt. */ struct ConnectivityManagementNotSupported : public std::runtime_error { ConnectivityManagementNotSupported() : std::runtime_error( "Underlying platform does not provide support for connectivity mgmt.") { } }; }; Manager(const Manager& rhs) = delete; virtual ~Manager() = default; Manager& operator=(const Manager& rhs) = delete; bool operator==(const Manager& rhs) const = delete; /** * @brief All wireless networks visible to the device. * @return A getable/observable property carrying the visible wireless networks. */ virtual const core::Property>& visible_wireless_networks() = 0; /** * @brief All radio cells visible to the device. * @return A getable/observable property carrying the visible radio cells. */ virtual const core::Property>& visible_radio_cells() = 0; protected: Manager() = default; }; /** * @brief Provides access to a platform-specific implementation/instance of a connectivity manager. * @throw Manager::Errors::ConnectivityManagementNotSupported. * @return An instance of a connectivity manager. */ const std::shared_ptr& platform_default_manager(); } } } } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_MANAGER_H_ connectivity-api-0.0.1+14.04.20140312/data/0000755000015201777760000000000012307723764020312 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/data/session.conf0000644000015201777760000000315512307723555022646 0ustar pbusernogroup00000000000000 session unix:tmpdir=/tmp 60000 1000000000 1000000000 1000000000 120000 240000 100000 10000 100000 10000 50000 50000 50000 300000 connectivity-api-0.0.1+14.04.20140312/data/CMakeLists.txt0000644000015201777760000000153712307723555023056 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 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 . # # Authors: # Antti Kaijanmäki configure_file( connectivity-cpp.pc.in connectivity-cpp.pc @ONLY ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/connectivity-cpp.pc DESTINATION lib/pkgconfig ) connectivity-api-0.0.1+14.04.20140312/data/system.conf0000644000015201777760000000123212307723555022501 0ustar pbusernogroup00000000000000 system unix:tmpdir=/tmp connectivity-api-0.0.1+14.04.20140312/data/connectivity-cpp.pc.in0000644000015201777760000000061112307723555024535 0ustar pbusernogroup00000000000000prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${exec_prefix}/include Name: @CMAKE_PROJECT_NAME@ Description: Version: @CONNECTIVITY_CPP_VERSION_MAJOR@.@CONNECTIVITY_CPP_VERSION_MINOR@.@CONNECTIVITY_CPP_VERSION_PATCH@ Cflags: -I${includedir}/connectivity-cpp-@CONNECTIVITY_CPP_VERSION_MAJOR@ Libs: -L${libdir} -lconnectivity-cpp Requires: dbus-cpp connectivity-api-0.0.1+14.04.20140312/COPYING0000644000015201777760000001674312307723555020445 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. connectivity-api-0.0.1+14.04.20140312/dbus-cpp/0000755000015201777760000000000012307723764021116 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/dbus-cpp/services/0000755000015201777760000000000012307723764022741 5ustar pbusernogroup00000000000000connectivity-api-0.0.1+14.04.20140312/dbus-cpp/services/urfkill.h0000644000015201777760000001447212307723555024570 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: Antti Kaijanmäki */ #ifndef PLATFORM_MANAGER_NMOFONO_URFKILL_H #define PLATFORM_MANAGER_NMOFONO_URFKILL_H #include #include #include #include #include #include #include #include #include #include #include namespace org { namespace freedesktop { namespace URfkill { struct Interface { struct URfkill { static const std::string& name() { static const std::string s{"org.freedesktop.URfkill"}; return s; } struct Method { struct Block { static const std::string& name() { static const std::string s{"Block"}; return s; } typedef URfkill Interface; static std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct EnumerateDevices { static const std::string& name() { static const std::string s{"EnumerateDevices"}; return s; } typedef URfkill Interface; typedef std::vector ResultType; static std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; }; bool block(std::uint32_t type, bool block) { auto result = object->invoke_method_synchronously< Method::Block, bool>(type, block); if (result.is_error()) throw std::runtime_error(result.error().print()); return result.value(); } Method::EnumerateDevices::ResultType enumerate_devices() { auto result = object->invoke_method_synchronously< Method::EnumerateDevices, Method::EnumerateDevices::ResultType>(); if (result.is_error()) throw std::runtime_error(result.error().print()); return result.value(); } URfkill(std::shared_ptr &service, std::shared_ptr &object) : service(service), object(object) { } std::shared_ptr service; std::shared_ptr object; }; struct Device { static const std::string& name() { static const std::string s{"org.freedesktop.URfkill.Device"}; return s; } struct Property { struct Hard { static const std::string& name() { static const std::string s{"hard"}; return s; } typedef Device Interface; typedef bool ValueType; static const bool readable = true; static const bool writable = false; }; struct Soft { static const std::string& name() { static const std::string s{"soft"}; return s; } typedef Device Interface; typedef bool ValueType; static const bool readable = true; static const bool writable = false; }; }; Device(const std::shared_ptr& object) : object(object), hard(object->get_property()), soft(object->get_property()) {} std::shared_ptr object; std::shared_ptr> hard; std::shared_ptr> soft; }; }; struct Service { std::shared_ptr urfkill; Service(const core::dbus::Bus::Ptr& bus) { auto service = core::dbus::Service::use_service(bus); auto object = service->object_for_path(core::dbus::types::ObjectPath("/org/freedesktop/URfkill")); urfkill = std::make_shared(service, object); } struct Mock { std::shared_ptr urfkill; Mock(const core::dbus::Bus::Ptr& bus) { auto service = core::dbus::Service::add_service(bus); auto object = service->add_object_for_path(core::dbus::types::ObjectPath("/org/freedesktop/URfkill")); urfkill = std::make_shared(service, object); } }; }; } } } #endif // PLATFORM_MANAGER_NMOFONO_URFKILL_H connectivity-api-0.0.1+14.04.20140312/dbus-cpp/services/nm.h0000644000015201777760000010762512307723555023535 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: Antti Kaijanmäki */ #ifndef PLATFORM_MANAGER_NMOFONO_NM_H #define PLATFORM_MANAGER_NMOFONO_NM_H #include #include #include #include #include #include #include #include #include #include #include #include namespace org { namespace freedesktop { namespace NetworkManager { struct Interface { struct AccessPoint { static const std::string& name() { static const std::string s{NM_DBUS_INTERFACE_ACCESS_POINT}; return s; } struct Property { struct Frequency { static const std::string& name() { static const std::string s{"Frequency"}; return s; } typedef AccessPoint Interface; typedef std::uint32_t ValueType; static const bool readable = true; static const bool writable = false; }; struct Flags { static const std::string& name() { static const std::string s{"Flags"}; return s; } typedef AccessPoint Interface; typedef std::uint32_t ValueType; static const bool readable = true; static const bool writable = false; }; struct Mode { static const std::string& name() { static const std::string s{"Mode"}; return s; } typedef AccessPoint Interface; typedef std::uint32_t ValueType; static const bool readable = true; static const bool writable = false; }; struct Ssid { static const std::string& name() { static const std::string s{"Ssid"}; return s; } typedef AccessPoint Interface; /// @todo bug tvoss.. D-Bus BYTE(y) should be unsigned typedef std::vector ValueType; static const bool readable = true; static const bool writable = false; }; struct HwAddress { static const std::string& name() { static const std::string s{"HwAddress"}; return s; } typedef AccessPoint Interface; typedef std::string ValueType; static const bool readable = true; static const bool writable = false; }; struct Strength { static const std::string& name() { static const std::string s{"Strength"}; return s; } typedef AccessPoint Interface; typedef std::int8_t ValueType; static const bool readable = true; static const bool writable = false; }; }; struct Signal { struct PropertiesChanged { static const std::string& name() { static const std::string s{"PropertiesChanged"}; return s; } typedef AccessPoint Interface; typedef std::map ArgumentType; }; }; AccessPoint(const std::shared_ptr& object) : object(object), frequency(object->get_property()), hw_address(object->get_property()), strength(object->get_property()), flags(object->get_property()), mode(object->get_property()), ssid(object->get_property()), properties_changed(object->get_signal()) {} std::shared_ptr object; std::shared_ptr> frequency; std::shared_ptr> hw_address; std::shared_ptr> strength; std::shared_ptr> flags; std::shared_ptr> mode; std::shared_ptr> ssid; std::shared_ptr> properties_changed; }; // Interface::AccessPoint struct ActiveConnection { static const std::string& name() { static const std::string s{NM_DBUS_INTERFACE_ACTIVE_CONNECTION}; return s; } struct Property { struct Connection { static const std::string& name() { static const std::string s{"Connection"}; return s; } typedef ActiveConnection Interface; typedef core::dbus::types::ObjectPath ValueType; static const bool readable = true; static const bool writable = false; }; struct SpecificObject { static const std::string& name() { static const std::string s{"SpecificObject"}; return s; } typedef ActiveConnection Interface; typedef core::dbus::types::ObjectPath ValueType; static const bool readable = true; static const bool writable = false; }; struct Uuid { static const std::string& name() { static const std::string s{"Uuid"}; return s; } typedef ActiveConnection Interface; typedef std::string ValueType; static const bool readable = true; static const bool writable = false; }; struct Devices { static const std::string& name() { static const std::string s{"Devices"}; return s; } typedef ActiveConnection Interface; typedef std::vector ValueType; static const bool readable = true; static const bool writable = false; }; struct State { static const std::string& name() { static const std::string s{"State"}; return s; } typedef ActiveConnection Interface; typedef std::uint32_t ValueType; static const bool readable = true; static const bool writable = false; }; struct Default { static const std::string& name() { static const std::string s{"Default"}; return s; } typedef ActiveConnection Interface; typedef bool ValueType; static const bool readable = true; static const bool writable = false; }; struct Default6 { static const std::string& name() { static const std::string s{"Default6"}; return s; } typedef ActiveConnection Interface; typedef bool ValueType; static const bool readable = true; static const bool writable = false; }; struct Vpn { static const std::string& name() { static const std::string s{"Vpn"}; return s; } typedef ActiveConnection Interface; typedef bool ValueType; static const bool readable = true; static const bool writable = false; }; struct Master { static const std::string& name() { static const std::string s{"Master"}; return s; } typedef ActiveConnection Interface; typedef bool ValueType; static const bool readable = true; static const bool writable = false; }; }; // struct Property struct Signal { struct PropertiesChanged { static const std::string& name() { static const std::string s{"PropertiesChanged"}; return s; } typedef ActiveConnection Interface; typedef std::map ArgumentType; }; }; enum class State { unknown = NM_ACTIVE_CONNECTION_STATE_UNKNOWN, activating = NM_ACTIVE_CONNECTION_STATE_ACTIVATING, activated = NM_ACTIVE_CONNECTION_STATE_ACTIVATED, deactivating = NM_ACTIVE_CONNECTION_STATE_DEACTIVATING, deactivated = NM_ACTIVE_CONNECTION_STATE_DEACTIVATED }; ActiveConnection(const std::shared_ptr& object) : object(object), connection(object->get_property()), specific_object(object->get_property()), uuid(object->get_property()), devices(object->get_property()), state(object->get_property()), default_ipv4(object->get_property()), default_ipv6(object->get_property()), vpn(object->get_property()), master(object->get_property()), properties_changed(object->get_signal()) { token = properties_changed->connect([this](const Signal::PropertiesChanged::ArgumentType &map){ for (auto entry: map) { if (entry.first == "State") { #if 0 std::uint32_t new_value = entry.second.as(); state->update([&new_value](std::uint32_t ¤t_value){ if (new_value == current_value) return false; current_value = new_value; return true; }); #endif continue; } else { std::cout << "Unexpected Connection.Active update: " << entry.first << std::endl; } } }); } ~ActiveConnection() { /// @todo fix dbus-cpp... //properties_changed->disconnect(token); } State get_state() { return static_cast(state->get()); } std::shared_ptr object; std::shared_ptr> connection; std::shared_ptr> specific_object; std::shared_ptr> uuid; std::shared_ptr> devices; std::shared_ptr> state; std::shared_ptr> default_ipv4; std::shared_ptr> default_ipv6; std::shared_ptr> vpn; std::shared_ptr> master; private: std::shared_ptr> properties_changed; core::dbus::Signal::SubscriptionToken token; }; // Interface::ActiveConnection struct Connection { std::shared_ptr object; Connection(const std::shared_ptr& object) : object(object) {} static const std::string& name() { static const std::string s{NM_DBUS_IFACE_SETTINGS_CONNECTION}; return s; } struct Method { struct GetSettings { static const std::string& name() { static const std::string s{"GetSettings"}; return s; } typedef Connection Interface; typedef std::map> ResultType; static std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; }; Method::GetSettings::ResultType get_settings() { auto result = object->invoke_method_synchronously(); if (result.is_error()) throw std::runtime_error(result.error().print()); return result.value(); } }; // Interface::Connection struct Device { static const std::string& name() { static const std::string s{NM_DBUS_INTERFACE_DEVICE}; return s; } enum class Type { unknown = NM_DEVICE_TYPE_UNKNOWN, ethernet = NM_DEVICE_TYPE_ETHERNET, wifi = NM_DEVICE_TYPE_WIFI, unused_1 = NM_DEVICE_TYPE_UNUSED1, unused_2 = NM_DEVICE_TYPE_UNUSED2, bluetooth = NM_DEVICE_TYPE_BT, olpc_mesh = NM_DEVICE_TYPE_OLPC_MESH, wimax = NM_DEVICE_TYPE_WIMAX, modem = NM_DEVICE_TYPE_MODEM, infiniband = NM_DEVICE_TYPE_INFINIBAND, bond = NM_DEVICE_TYPE_BOND, vlan = NM_DEVICE_TYPE_VLAN, adsl = NM_DEVICE_TYPE_ADSL, bridge = NM_DEVICE_TYPE_BRIDGE }; struct Wireless { static const std::string& name() { static const std::string s{NM_DBUS_INTERFACE_DEVICE_WIRELESS}; return s; } struct Method { struct GetAccessPoints { static const std::string& name() { static const std::string s{"GetAccessPoints"}; return s; } typedef Wireless Interface; typedef std::vector ResultType; static std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; }; struct Signal { struct AccessPointAdded { static const std::string& name() { static const std::string s{"AccessPointAdded"}; return s; } typedef Wireless Interface; typedef core::dbus::types::ObjectPath ArgumentType; }; struct AccessPointRemoved { static const std::string& name() { static const std::string s{"AccessPointRemoved"}; return s; } typedef Wireless Interface; typedef core::dbus::types::ObjectPath ArgumentType; }; }; Wireless(std::shared_ptr &base) : access_point_added(base->get_signal()), access_point_removed(base->get_signal()) {} std::shared_ptr> access_point_added; std::shared_ptr> access_point_removed; }; // Interface::Device::Wireless struct Property { struct DeviceType { static const std::string& name() { static const std::string s{"DeviceType"}; return s; } typedef Device Interface; typedef std::uint32_t ValueType; static const bool readable = true; static const bool writable = false; }; struct DeviceInterface { static const std::string& name() { static const std::string s{"Interface"}; return s; } typedef Device Interface; typedef std::string ValueType; static const bool readable = true; static const bool writable = false; }; struct Autoconnect { static const std::string& name() { static const std::string s{"Autoconnect"}; return s; } typedef Device Interface; typedef bool ValueType; static const bool readable = true; static const bool writable = true; }; struct State { static const std::string &name() { static const std::string s{"State"}; return s; } typedef Device Interface; typedef std::uint32_t ValueType; static const bool readable = true; static const bool writable = false; }; struct AvailableConnections { static const std::string &name() { static const std::string s{"AvailableConnections"}; return s; } typedef Device Interface; typedef std::vector ValueType; static const bool readable = true; static const bool writable = false; }; struct ActiveConnection { static const std::string &name() { static const std::string s{"ActiveConnection"}; return s; } typedef Device Interface; typedef core::dbus::types::ObjectPath ValueType; static const bool readable = true; static const bool writable = false; }; }; std::vector get_available_connections() { std::vector list; for (auto c: available_connections->get()) { list.push_back(Connection(service->object_for_path(c))); } return list; } struct Method { struct Disconnect { static const std::string& name() { static const std::string s{"Disconnect"}; return s; } typedef Device Interface; typedef void ResultType; static std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; }; void disconnect() { auto result = object->invoke_method_synchronously< Device::Method::Disconnect, Device::Method::Disconnect::ResultType>(); if (result.is_error()) throw std::runtime_error(result.error().print()); } struct Signal { struct StateChanged { static const std::string& name() { static const std::string s{"StateChanged"}; return s; } typedef Device Interface; typedef std::tuple ArgumentType; }; }; Type type() const { return static_cast(device_type->get()); } std::string interface() const { return device_interface->get(); } std::vector get_access_points() const { auto result = object->invoke_method_synchronously(); if (result.is_error()) throw std::runtime_error(result.error().print()); std::vector aps; for (const auto& path : result.value()) { aps.push_back(AccessPoint(service->object_for_path(path))); } return aps; } Device(const std::shared_ptr& service, const std::shared_ptr& object) : service(service), object(object), device_type(object->get_property()), autoconnect(object->get_property()), device_interface(object->get_property()), state(object->get_property()), state_changed(object->get_signal()), available_connections(object->get_property()), active_connection(object->get_property()) {} std::shared_ptr service; std::shared_ptr object; std::shared_ptr> device_type; std::shared_ptr> autoconnect; std::shared_ptr> device_interface; std::shared_ptr> state; std::shared_ptr> state_changed; std::shared_ptr> available_connections; std::shared_ptr> active_connection; }; // Interface::Device struct NetworkManager { static const std::string& name() { static const std::string s{NM_DBUS_INTERFACE}; return s; } struct Method { struct ActivateConnection { static const std::string& name() { static const std::string s{"ActivateConnection"}; return s; } typedef NetworkManager Interface; typedef core::dbus::types::ObjectPath ResultType; static std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct AddAndActivateConnection { static const std::string& name() { static const std::string s{"AddAndActivateConnection"}; return s; } typedef NetworkManager Interface; typedef std::tuple ResultType; static std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct GetDevices { static const std::string& name() { static const std::string s{"GetDevices"}; return s; } typedef NetworkManager Interface; typedef std::vector ResultType; static std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; }; struct Property { struct WirelessEnabled { static const std::string &name() { static const std::string s{"WirelessEnabled"}; return s; } typedef NetworkManager Interface; typedef bool ValueType; static const bool readable = true; static const bool writable = true; }; struct State { static const std::string &name() { static const std::string s{"State"}; return s; } typedef NetworkManager Interface; typedef std::uint32_t ValueType; static const bool readable = true; static const bool writable = false; }; struct PrimaryConnection { static const std::string &name() { static const std::string s{"PrimaryConnection"}; return s; } typedef NetworkManager Interface; typedef core::dbus::types::ObjectPath ValueType; static const bool readable = true; static const bool writable = false; }; }; struct Signal { struct PropertiesChanged { static const std::string& name() { static const std::string s{"PropertiesChanged"}; return s; } typedef NetworkManager Interface; typedef std::map ArgumentType; }; struct DeviceAdded { static const std::string& name() { static const std::string s{"DeviceAdded"}; return s; } typedef NetworkManager Interface; typedef core::dbus::types::ObjectPath ArgumentType; }; struct DeviceRemoved { static const std::string& name() { static const std::string s{"DeviceRemoved"}; return s; } typedef NetworkManager Interface; typedef core::dbus::types::ObjectPath ArgumentType; }; }; Method::ActivateConnection::ResultType activate_connection(const core::dbus::types::ObjectPath &connection, const core::dbus::types::ObjectPath &device, const core::dbus::types::ObjectPath &specific_object) { auto result = object->invoke_method_synchronously< Method::ActivateConnection, Method::ActivateConnection::ResultType> (connection, device, specific_object); if (result.is_error()) throw std::runtime_error(result.error().print()); return result.value(); } Method::AddAndActivateConnection::ResultType add_and_activate_connection(std::map> &connection, const core::dbus::types::ObjectPath &device, const core::dbus::types::ObjectPath &specific_object) { auto result = object->invoke_method_synchronously< Method::AddAndActivateConnection, Method::AddAndActivateConnection::ResultType> (connection, device, specific_object); if (result.is_error()) throw std::runtime_error(result.error().print()); /// @todo return the settings (std::get<0>) object at some point return result.value(); } std::vector get_devices() { auto result = object->invoke_method_synchronously< Method::GetDevices, Method::GetDevices::ResultType>(); if (result.is_error()) throw std::runtime_error(result.error().print()); std::vector devices; for (const auto& path : result.value()) { devices.emplace_back( Device( service, service->object_for_path(path))); } return devices; } NetworkManager(std::shared_ptr &service, std::shared_ptr &object) : service(service), object(object), wireless_enabled(object->get_property()), state(object->get_property()), properties_changed(object->get_signal()), primary_connection(object->get_property()), device_added(object->get_signal()), device_removed(object->get_signal()) { } std::shared_ptr service; std::shared_ptr object; std::shared_ptr> wireless_enabled; std::shared_ptr> state; std::shared_ptr> properties_changed; std::shared_ptr> primary_connection; std::shared_ptr> device_added; std::shared_ptr> device_removed; }; // Interface::NetworkManager }; struct Service { std::shared_ptr nm; Service(const core::dbus::Bus::Ptr& bus) { auto service = core::dbus::Service::use_service(bus); auto object = service->object_for_path(core::dbus::types::ObjectPath(NM_DBUS_PATH)); nm = std::make_shared(service, object); } struct Mock { std::shared_ptr nm; Mock(const core::dbus::Bus::Ptr& bus) { auto service = core::dbus::Service::add_service(bus); auto object = service->add_object_for_path(core::dbus::types::ObjectPath(NM_DBUS_PATH)); nm = std::make_shared(service, object); } }; }; } } } #endif // PLATFORM_MANAGER_NMOFONO_NM_H connectivity-api-0.0.1+14.04.20140312/dbus-cpp/services/ofono.h0000644000015201777760000002530412307723555024234 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_CONNECTIVITY_OFONO_H #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_OFONO_H #include #include #include #include #include #include #include #include #include #include namespace org { struct Ofono { static const std::string& name() { static const std::string s{"org.ofono"}; return s; } struct Manager { static const std::string& name() { static const std::string s{"org.ofono.Manager"}; return s; } struct GetModems { static const std::string& name() { static const std::string s{"GetModems"}; return s; } typedef Manager Interface; typedef std::vector< core::dbus::types::Struct< core::dbus::types::ObjectPath > > ResultType; static std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct ModemAdded { static const std::string& name() { static const std::string s{"ModemAdded"}; return s; } typedef Manager Interface; typedef std::tuple> ArgumentType; }; struct ModemRemoved { static const std::string& name() { static const std::string s{"ModemRemoved"}; return s; } typedef Manager Interface; typedef core::dbus::types::ObjectPath ArgumentType; }; struct Modem { struct NetworkRegistration { static const std::string& name() { static const std::string s{"org.ofono.NetworkRegistration"}; return s; } struct GetProperties { static const std::string& name() { static const std::string s{"GetProperties"}; return s; } typedef NetworkRegistration Interface; typedef std::map> ValueType; static std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; } }; struct Mode { static const char* unregistered() { return "unregistered"; } static const char* registered() { return "registered"; } static const char* searching() { return "searching"; } static const char* denied() { return "denied"; } static const char* unknown() { return "unknown"; } static const char* roaming() { return "roaming"; } static const std::string& name() { static const std::string s{"Mode"}; return s; } typedef NetworkRegistration Interface; typedef std::string ValueType; static const bool readable = true; static const bool writable = false; }; struct LocationAreaCode { static const std::string& name() { static const std::string s{"LocationAreaCode"}; return s; } typedef NetworkRegistration Interface; typedef std::uint16_t ValueType; static const bool readable = true; static const bool writable = false; }; struct CellId { static const std::string& name() { static const std::string s{"CellId"}; return s; } typedef NetworkRegistration Interface; typedef std::uint32_t ValueType; static const bool readable = true; static const bool writable = false; }; struct MobileCountryCode { static const std::string& name() { static const std::string s{"MobileCountryCode"}; return s; } typedef NetworkRegistration Interface; typedef std::string ValueType; static const bool readable = true; static const bool writable = false; }; struct MobileNetworkCode { static const std::string& name() { static const std::string s{"MobileNetworkCode"}; return s; } typedef NetworkRegistration Interface; typedef std::string ValueType; static const bool readable = true; static const bool writable = false; }; struct Technology { static const char* gsm() { return "gsm"; } static const char* edge() { return "edge"; } static const char* umts() { return "umts"; } static const char* hspa() { return "hspa"; } static const char* lte() { return "lte"; } static const std::string& name() { static const std::string s{"Technology"}; return s; } typedef NetworkRegistration Interface; typedef std::string ValueType; static const bool readable = true; static const bool writable = false; }; struct Strength { static const std::string& name() { static const std::string s{"Strength"}; return s; } typedef NetworkRegistration Interface; typedef std::int8_t ValueType; static const bool readable = true; static const bool writable = false; }; NetworkRegistration(const std::shared_ptr& object) : object(object), properties{} { auto result = object->invoke_method_synchronously(); if (result.is_error()) throw std::runtime_error(result.error().print()); properties = result.value(); } template typename Property::ValueType get( const typename Property::ValueType& default_value = typename Property::ValueType{}) const { try { core::dbus::types::Any value = properties.at(Property::name()).get(); typename Property::ValueType result; value.reader() >> result; return result; } catch(...) { } return default_value; } std::shared_ptr object; GetProperties::ValueType properties; }; Modem(const std::shared_ptr& service, const std::shared_ptr& object) : service(service), object(object), network_registration{object} { } std::shared_ptr service; std::shared_ptr object; NetworkRegistration network_registration; }; Manager(const core::dbus::Bus::Ptr& bus) : service(core::dbus::Service::use_service(bus)), object(service->object_for_path(core::dbus::types::ObjectPath("/"))), modem_added(object->get_signal()), modem_removed(object->get_signal()) { auto result = object->invoke_method_synchronously(); if (result.is_error()) throw std::runtime_error(result.error().print()); for (const auto& element : result.value()) { modems.insert( std::make_pair( element.value, Modem { service, service->object_for_path(element.value) })); } modem_added->connect([this](const ModemAdded::ArgumentType& arg) { std::lock_guard lg(guard); modems.insert( std::make_pair( std::get<0>(arg), Modem{ service, service->object_for_path(std::get<0>(arg)) })); }); modem_removed->connect([this](const ModemRemoved::ArgumentType& arg) { std::lock_guard lg(guard); modems.erase(arg); }); } void for_each_modem(const std::function& functor) const { std::lock_guard lg(guard); for (const auto& modem : modems) { functor(modem.second); } } std::shared_ptr service; std::shared_ptr object; std::shared_ptr> modem_added; std::shared_ptr> modem_removed; mutable std::mutex guard; std::map modems; }; }; } #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_CONNECTIVITY_OFONO_H