indicator-network-0.5.1+14.04.20140409.1/0000755000015301777760000000000012321337176017725 5ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/cmake/0000755000015301777760000000000012321337176021005 5ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/cmake/FindGObjectIntrospection.cmake0000644000015301777760000000376512321336644026720 0ustar pbusernogroup00000000000000# - try to find gobject-introspection # # Once done this will define # # INTROSPECTION_FOUND - system has gobject-introspection # INTROSPECTION_SCANNER - the gobject-introspection scanner, g-ir-scanner # INTROSPECTION_COMPILER - the gobject-introspection compiler, g-ir-compiler # INTROSPECTION_GENERATE - the gobject-introspection generate, g-ir-generate # INTROSPECTION_GIRDIR # INTROSPECTION_TYPELIBDIR # INTROSPECTION_CFLAGS # INTROSPECTION_LIBS # # Copyright (C) 2010, Pino Toscano, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. macro(_GIR_GET_PKGCONFIG_VAR _outvar _varname) execute_process( COMMAND ${PKG_CONFIG_EXECUTABLE} --variable=${_varname} gobject-introspection-1.0 OUTPUT_VARIABLE _result RESULT_VARIABLE _null ) if (_null) else() string(REGEX REPLACE "[\r\n]" " " _result "${_result}") string(REGEX REPLACE " +$" "" _result "${_result}") separate_arguments(_result) set(${_outvar} ${_result} CACHE INTERNAL "") endif() endmacro(_GIR_GET_PKGCONFIG_VAR) find_package(PkgConfig) if(PKG_CONFIG_FOUND) if(PACKAGE_FIND_VERSION_COUNT GREATER 0) set(_gir_version_cmp ">=${PACKAGE_FIND_VERSION}") endif() pkg_check_modules(_pc_gir gobject-introspection-1.0${_gir_version_cmp}) if(_pc_gir_FOUND) set(INTROSPECTION_FOUND TRUE) _gir_get_pkgconfig_var(INTROSPECTION_SCANNER "g_ir_scanner") _gir_get_pkgconfig_var(INTROSPECTION_COMPILER "g_ir_compiler") _gir_get_pkgconfig_var(INTROSPECTION_GENERATE "g_ir_generate") _gir_get_pkgconfig_var(INTROSPECTION_GIRDIR "girdir") _gir_get_pkgconfig_var(INTROSPECTION_TYPELIBDIR "typelibdir") set(INTROSPECTION_CFLAGS "${_pc_gir_CFLAGS}") set(INTROSPECTION_LIBS "${_pc_gir_LIBS}") endif() endif() mark_as_advanced( INTROSPECTION_SCANNER INTROSPECTION_COMPILER INTROSPECTION_GENERATE INTROSPECTION_GIRDIR INTROSPECTION_TYPELIBDIR INTROSPECTION_CFLAGS INTROSPECTION_LIBS ) indicator-network-0.5.1+14.04.20140409.1/cmake/UseVala.cmake0000644000015301777760000002067412321336644023357 0ustar pbusernogroup00000000000000# - Precompilation of Vala/Genie source files into C sources # Makes use of the parallel build ability introduced in Vala 0.11. Derived # from a similar module by Jakob Westhoff and the original GNU Make rules. # Might be a bit oversimplified. # # This module defines three functions. The first one: # # vala_init (id # [DIRECTORY dir] - Output directory (binary dir by default) # [PACKAGES package...] - Package dependencies # [OPTIONS option...] - Extra valac options # [CUSTOM_VAPIS file...]) - Custom vapi files to include in the build # [DEPENDS targets...]) - Extra dependencies for code generation # # initializes a single precompilation unit using the given arguments. # You can put files into it via the following function: # # vala_add (id source.vala # [DEPENDS source...]) - Vala/Genie source or .vapi dependencies # # Finally retrieve paths for generated C files by calling: # # vala_finish (id # [SOURCES sources_var] - Input Vala/Genie sources # [OUTPUTS outputs_var] - Output C sources # [GENERATE_HEADER id.h - Generate id.h and id_internal.h # [GENERATE_VAPI id.vapi] - Generate a vapi file # [GENERATE_SYMBOLS id.def]]) - Generate a list of public symbols # #============================================================================= # Copyright Přemysl Janouch 2011 # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY # OF SUCH DAMAGE. #============================================================================= find_package (Vala 0.18 REQUIRED) include (CMakeParseArguments) function (vala_init id) set (_multi_value PACKAGES OPTIONS CUSTOM_VAPIS DEPENDS) cmake_parse_arguments (arg "" "DIRECTORY" "${_multi_value}" ${ARGN}) if (arg_DIRECTORY) set (directory ${arg_DIRECTORY}) if (NOT IS_DIRECTORY ${directory}) file (MAKE_DIRECTORY ${directory}) endif (NOT IS_DIRECTORY ${directory}) else (arg_DIRECTORY) set (directory ${CMAKE_CURRENT_BINARY_DIR}) endif (arg_DIRECTORY) set (pkg_opts) foreach (pkg ${arg_PACKAGES}) list (APPEND pkg_opts "--pkg=${pkg}") endforeach (pkg) set (VALA_${id}_DIR "${directory}" PARENT_SCOPE) set (VALA_${id}_ARGS ${pkg_opts} ${arg_OPTIONS} ${arg_CUSTOM_VAPIS} PARENT_SCOPE) set (VALA_${id}_DEPENDS ${arg_DEPENDS} PARENT_SCOPE) set (VALA_${id}_SOURCES "" PARENT_SCOPE) set (VALA_${id}_OUTPUTS "" PARENT_SCOPE) set (VALA_${id}_FAST_VAPI_FILES "" PARENT_SCOPE) set (VALA_${id}_FAST_VAPI_ARGS "" PARENT_SCOPE) endfunction (vala_init) function (vala_add id file) cmake_parse_arguments (arg "" "" "DEPENDS" ${ARGN}) if (NOT IS_ABSOLUTE "${file}") set (file "${CMAKE_CURRENT_SOURCE_DIR}/${file}") endif (NOT IS_ABSOLUTE "${file}") get_filename_component (output_name "${file}" NAME) get_filename_component (output_base "${file}" NAME_WE) set (output_base "${VALA_${id}_DIR}/${output_base}") # XXX: It would be best to have it working without touching the vapi # but it appears this cannot be done in CMake. add_custom_command (OUTPUT "${output_base}.vapi" COMMAND ${VALA_COMPILER} "${file}" "--fast-vapi=${output_base}.vapi" COMMAND ${CMAKE_COMMAND} -E touch "${output_base}.vapi" DEPENDS "${file}" COMMENT "Generating a fast vapi for ${output_name}" VERBATIM) set (vapi_opts) set (vapi_depends) foreach (vapi ${arg_DEPENDS}) if (NOT IS_ABSOLUTE "${vapi}") set (vapi "${VALA_${id}_DIR}/${vapi}.vapi") endif (NOT IS_ABSOLUTE "${vapi}") list (APPEND vapi_opts "--use-fast-vapi=${vapi}") list (APPEND vapi_depends "${vapi}") endforeach (vapi) add_custom_command (OUTPUT "${output_base}.c" COMMAND ${VALA_COMPILER} "${file}" -C ${vapi_opts} ${VALA_${id}_ARGS} COMMAND ${CMAKE_COMMAND} -E touch "${output_base}.c" DEPENDS "${file}" ${vapi_depends} ${VALA_${id}_DEPENDS} WORKING_DIRECTORY "${VALA_${id}_DIR}" COMMENT "Precompiling ${output_name}" VERBATIM) set (VALA_${id}_SOURCES ${VALA_${id}_SOURCES} "${file}" PARENT_SCOPE) set (VALA_${id}_OUTPUTS ${VALA_${id}_OUTPUTS} "${output_base}.c" PARENT_SCOPE) set (VALA_${id}_FAST_VAPI_FILES ${VALA_${id}_FAST_VAPI_FILES} "${output_base}.vapi" PARENT_SCOPE) set (VALA_${id}_FAST_VAPI_ARGS ${VALA_${id}_FAST_VAPI_ARGS} "--use-fast-vapi=${output_base}.vapi" PARENT_SCOPE) endfunction (vala_add) function (vala_finish id) set (_one_value SOURCES OUTPUTS GENERATE_VAPI GENERATE_HEADER GENERATE_SYMBOLS) cmake_parse_arguments (arg "" "${_one_value}" "" ${ARGN}) if (arg_SOURCES) set (${arg_SOURCES} ${VALA_${id}_SOURCES} PARENT_SCOPE) endif (arg_SOURCES) if (arg_OUTPUTS) set (${arg_OUTPUTS} ${VALA_${id}_OUTPUTS} PARENT_SCOPE) endif (arg_OUTPUTS) set (outputs) set (export_args) if (arg_GENERATE_VAPI) if (NOT IS_ABSOLUTE "${arg_GENERATE_VAPI}") set (arg_GENERATE_VAPI "${VALA_${id}_DIR}/${arg_GENERATE_VAPI}") endif (NOT IS_ABSOLUTE "${arg_GENERATE_VAPI}") list (APPEND outputs "${arg_GENERATE_VAPI}") list (APPEND export_args "--internal-vapi=${arg_GENERATE_VAPI}") if (NOT arg_GENERATE_HEADER) message (FATAL_ERROR "Header generation required for vapi") endif (NOT arg_GENERATE_HEADER) endif (arg_GENERATE_VAPI) if (arg_GENERATE_SYMBOLS) if (NOT IS_ABSOLUTE "${arg_GENERATE_SYMBOLS}") set (arg_GENERATE_SYMBOLS "${VALA_${id}_DIR}/${arg_GENERATE_SYMBOLS}") endif (NOT IS_ABSOLUTE "${arg_GENERATE_SYMBOLS}") list (APPEND outputs "${arg_GENERATE_SYMBOLS}") list (APPEND export_args "--symbols=${arg_GENERATE_SYMBOLS}") if (NOT arg_GENERATE_HEADER) message (FATAL_ERROR "Header generation required for symbols") endif (NOT arg_GENERATE_HEADER) endif (arg_GENERATE_SYMBOLS) if (arg_GENERATE_HEADER) if (NOT IS_ABSOLUTE "${arg_GENERATE_HEADER}") set (arg_GENERATE_HEADER "${VALA_${id}_DIR}/${arg_GENERATE_HEADER}") endif (NOT IS_ABSOLUTE "${arg_GENERATE_HEADER}") get_filename_component (header_path "${arg_GENERATE_HEADER}" PATH) get_filename_component (header_name "${arg_GENERATE_HEADER}" NAME_WE) set (header_base "${header_path}/${header_name}") get_filename_component (header_ext "${arg_GENERATE_HEADER}" EXT) list (APPEND outputs "${header_base}${header_ext}" "${header_base}_internal${header_ext}") list (APPEND export_args "--header=${header_base}${header_ext}" "--internal-header=${header_base}_internal${header_ext}") endif (arg_GENERATE_HEADER) if (outputs) add_custom_command (OUTPUT ${outputs} COMMAND ${VALA_COMPILER} -C ${VALA_${id}_ARGS} ${export_args} ${VALA_${id}_FAST_VAPI_ARGS} DEPENDS ${VALA_${id}_FAST_VAPI_FILES} COMMENT "Generating vapi/headers/symbols" VERBATIM) endif (outputs) endfunction (vala_finish id) function (vapi_gen id) set (_one_value LIBRARY INPUT) set (_multi_value PACKAGES) cmake_parse_arguments (arg "" "${_one_value}" "${_multi_value}" ${ARGN}) set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${id}.vapi") if (arg_LIBRARY) set (OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${arg_LIBRARY}.vapi") endif (arg_LIBRARY) set("${id}_OUTPUT" ${OUTPUT} PARENT_SCOPE) set(PACKAGE_LIST) foreach(PACKAGE ${arg_PACKAGES}) list(APPEND PACKAGE_LIST "--pkg" ${PACKAGE}) endforeach() add_custom_command( OUTPUT ${OUTPUT} COMMAND ${VAPI_GEN} ${PACKAGE_LIST} --library=${arg_LIBRARY} ${arg_INPUT} DEPENDS ${arg_INPUT} VERBATIM ) add_custom_target(${id} ALL DEPENDS ${OUTPUT}) endfunction (vapi_gen id) indicator-network-0.5.1+14.04.20140409.1/cmake/Coverage.cmake0000644000015301777760000000422212321336644023541 0ustar pbusernogroup00000000000000if (CMAKE_BUILD_TYPE MATCHES coverage) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") find_program(GCOVR_EXECUTABLE gcovr HINTS ${GCOVR_ROOT} "${GCOVR_ROOT}/bin") if (NOT GCOVR_EXECUTABLE) message(STATUS "Gcovr binary was not found, can not generate XML coverage info.") else () message(STATUS "Gcovr found, can generate XML coverage info.") add_custom_target (coverage-xml WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND "${GCOVR_EXECUTABLE}" --exclude="test.*" --exclude="obj.*" -x -r "${CMAKE_SOURCE_DIR}" --object-directory=${CMAKE_BINARY_DIR} -o coverage.xml) endif() find_program(LCOV_EXECUTABLE lcov HINTS ${LCOV_ROOT} "${GCOVR_ROOT}/bin") find_program(GENHTML_EXECUTABLE genhtml HINTS ${GENHTML_ROOT}) if (NOT LCOV_EXECUTABLE) message(STATUS "Lcov binary was not found, can not generate HTML coverage info.") else () if(NOT GENHTML_EXECUTABLE) message(STATUS "Genthml binary not found, can not generate HTML coverage info.") else() message(STATUS "Lcov and genhtml found, can generate HTML coverage info.") add_custom_target (coverage-html WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND "${LCOV_EXECUTABLE}" --capture --output-file "${CMAKE_BINARY_DIR}/coverage.info" --no-checksum --directory "${CMAKE_BINARY_DIR}" COMMAND "${LCOV_EXECUTABLE}" --remove "${CMAKE_BINARY_DIR}/coverage.info" '/usr/*' --output-file "${CMAKE_BINARY_DIR}/coverage.info" COMMAND "${LCOV_EXECUTABLE}" --remove "${CMAKE_BINARY_DIR}/coverage.info" '${CMAKE_BINARY_DIR}/*' --output-file "${CMAKE_BINARY_DIR}/coverage.info" COMMAND "${LCOV_EXECUTABLE}" --remove "${CMAKE_BINARY_DIR}/coverage.info" '${CMAKE_SOURCE_DIR}/tests/*' --output-file "${CMAKE_BINARY_DIR}/coverage.info" COMMAND "${GENHTML_EXECUTABLE}" --prefix "${CMAKE_BINARY_DIR}" --output-directory coveragereport --title "Code Coverage" --legend --show-details coverage.info ) endif() endif() endif() indicator-network-0.5.1+14.04.20140409.1/cmake/FindGMock.cmake0000644000015301777760000000076612321336644023620 0ustar pbusernogroup00000000000000# Build with system gmock and embedded gtest set (GMOCK_INCLUDE_DIRS "/usr/include/gmock/include" CACHE PATH "gmock source include directory") set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory") set (GTEST_INCLUDE_DIRS "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory") add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock") set(GTEST_LIBRARIES gtest) set(GTEST_MAIN_LIBRARIES gtest_main) set(GMOCK_LIBRARIES gmock gmock_main) indicator-network-0.5.1+14.04.20140409.1/cmake/UseGObjectIntrospection.cmake0000644000015301777760000000743712321336644026574 0ustar pbusernogroup00000000000000# Copyright (C) 2010, Pino Toscano, # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. include(ListOperations) macro(_gir_list_prefix _outvar _listvar _prefix) set(${_outvar}) foreach(_item IN LISTS ${_listvar}) list(APPEND ${_outvar} ${_prefix}${_item}) endforeach() endmacro(_gir_list_prefix) macro(gir_add_introspections introspections_girs) foreach(gir IN LISTS ${introspections_girs}) set(_gir_name "${gir}") ## Transform the gir filename to something which can reference through a variable ## without automake/make complaining, eg Gtk-2.0.gir -> Gtk_2_0_gir string(REPLACE "-" "_" _gir_name "${_gir_name}") string(REPLACE "." "_" _gir_name "${_gir_name}") # Namespace and Version is either fetched from the gir filename # or the _NAMESPACE/_VERSION variable combo set(_gir_namespace "${${_gir_name}_NAMESPACE}") if (_gir_namespace STREQUAL "") string(REGEX REPLACE "([^-]+)-.*" "\\1" _gir_namespace "${gir}") endif () set(_gir_version "${${_gir_name}_VERSION}") if (_gir_version STREQUAL "") string(REGEX REPLACE ".*-([^-]+).gir" "\\1" _gir_version "${gir}") endif () # _PROGRAM is an optional variable which needs it's own --program argument set(_gir_program "${${_gir_name}_PROGRAM}") if (NOT _gir_program STREQUAL "") set(_gir_program "--program=${_gir_program}") endif () # Variables which provides a list of things _gir_list_prefix(_gir_libraries ${_gir_name}_LIBS "--library=") _gir_list_prefix(_gir_packages ${_gir_name}_PACKAGES "--pkg=") _gir_list_prefix(_gir_includes ${_gir_name}_INCLUDES "--include=") _gir_list_prefix(_gir_export_packages ${_gir_name}_EXPORT_PACKAGES "--pkg-export=") # Reuse the LIBTOOL variable from by automake if it's set set(_gir_libtool "--no-libtool") add_custom_command( COMMAND ${INTROSPECTION_SCANNER} ${INTROSPECTION_SCANNER_ARGS} --namespace=${_gir_namespace} --nsversion=${_gir_version} ${_gir_libtool} ${_gir_program} ${_gir_libraries} ${_gir_packages} ${_gir_includes} ${_gir_export_packages} ${${_gir_name}_SCANNERFLAGS} ${${_gir_name}_CFLAGS} ${${_gir_name}_FILES} --output ${CMAKE_CURRENT_BINARY_DIR}/${gir} DEPENDS ${${_gir_name}_FILES} ${${_gir_name}_LIBS} OUTPUT ${gir} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${gir} DESTINATION share/gir-1.0) string(REPLACE ".gir" ".typelib" _typelib "${gir}") add_custom_command( COMMAND ${INTROSPECTION_COMPILER} ${INTROSPECTION_COMPILER_ARGS} --includedir=. ${CMAKE_CURRENT_BINARY_DIR}/${gir} -o ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir} OUTPUT ${_typelib} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DESTINATION ${CMAKE_INSTALL_LIBDIR}/girepository-1.0) add_custom_target(gir-${gir} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir}) add_custom_target(gir-typelibs-${_typelib} ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_typelib}) endforeach() endmacro(gir_add_introspections) macro(gir_get_cflags _output) get_directory_property(_tmp_includes INCLUDE_DIRECTORIES) list_prefix(_includes _tmp_includes "-I") get_directory_property(_tmp_compile_definitions COMPILE_DEFINITIONS) list_prefix(_compile_definitions _tmp_compile_definitions "-D") set(${_output} ${_includes} ${_compile_definitions}) endmacro(gir_get_cflags) indicator-network-0.5.1+14.04.20140409.1/cmake/COPYING-CMAKE-SCRIPTS0000644000015301777760000000245712321336644024012 0ustar pbusernogroup00000000000000Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. indicator-network-0.5.1+14.04.20140409.1/cmake/FindValgrind.cmake0000644000015301777760000000161512321336644024360 0ustar pbusernogroup00000000000000 option( ENABLE_MEMCHECK_OPTION "If set to ON, enables automatic creation of memcheck targets" OFF ) find_program( VALGRIND_PROGRAM NAMES valgrind ) if(VALGRIND_PROGRAM) set(VALGRIND_PROGRAM_OPTIONS "--suppressions=${CMAKE_SOURCE_DIR}/tests/data/valgrind.suppression" "--error-exitcode=1" "--trace-children=yes" "--trace-children-skip=*/python*,python*" "--leak-check=full" "--leak-resolution=high" "--gen-suppressions=all" "--quiet" ) endif() find_package_handle_standard_args( VALGRIND DEFAULT_MSG VALGRIND_PROGRAM ) function(add_valgrind_test NAME EXECUTABLE) if(ENABLE_MEMCHECK_OPTION) add_test(${NAME} ${VALGRIND_PROGRAM} ${VALGRIND_PROGRAM_OPTIONS} "${CMAKE_CURRENT_BINARY_DIR}/${EXECUTABLE}") set_tests_properties( ${NAME} PROPERTIES ENVIRONMENT "G_SLICE=always-malloc G_DEBUG=gc-friendly" ) else() add_test(${NAME} ${EXECUTABLE}) endif() endfunction() indicator-network-0.5.1+14.04.20140409.1/cmake/FindVala.cmake0000644000015301777760000000442212321336644023474 0ustar pbusernogroup00000000000000# - Find Vala # This module looks for valac. # This module defines the following values: # VALA_FOUND # VALA_COMPILER # VALA_VERSION # VAPI_GEN # VAPI_GEN_VERSION #============================================================================= # Copyright Přemysl Janouch 2011 # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # * Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY # OF SUCH DAMAGE. #============================================================================= find_program (VALA_COMPILER "valac") if (VALA_COMPILER) execute_process (COMMAND ${VALA_COMPILER} --version OUTPUT_VARIABLE VALA_VERSION) string (REGEX MATCH "[.0-9]+" VALA_VERSION "${VALA_VERSION}") endif (VALA_COMPILER) find_program (VAPI_GEN "vapigen") if (VAPI_GEN) execute_process (COMMAND ${VAPI_GEN} --version OUTPUT_VARIABLE VAPI_GEN_VERSION) string (REGEX MATCH "[.0-9]+" VAPI_GEN_VERSION "${VAPI_GEN_VERSION}") endif (VAPI_GEN) include (FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS (Vala REQUIRED_VARS VALA_COMPILER VERSION_VAR VALA_VERSION) mark_as_advanced (VALA_COMPILER VALA_VERSION VAPI_GEN) indicator-network-0.5.1+14.04.20140409.1/cmake/UseGSettings.cmake0000644000015301777760000000365212321336644024400 0ustar pbusernogroup00000000000000# GSettings.cmake, CMake macros written for Marlin, feel free to re-use them. option (GSETTINGS_LOCALINSTALL "Install GSettings Schemas locally instead of to the GLib prefix" OFF) option (GSETTINGS_COMPILE "Compile GSettings Schemas after installation" OFF) if(GSETTINGS_LOCALINSTALL) message(STATUS "GSettings schemas will be installed locally.") endif() if(GSETTINGS_COMPILE) message(STATUS "GSettings shemas will be compiled.") endif() macro(add_schema SCHEMA_NAME) set(PKG_CONFIG_EXECUTABLE pkg-config) # Have an option to not install the schema into where GLib is if (GSETTINGS_LOCALINSTALL) SET (GSETTINGS_DIR "${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas/") else (GSETTINGS_LOCALINSTALL) execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} glib-2.0 --variable prefix OUTPUT_VARIABLE _glib_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) SET (GSETTINGS_DIR "${_glib_prefix}/share/glib-2.0/schemas/") endif (GSETTINGS_LOCALINSTALL) # Run the validator and error if it fails execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_comple_schemas OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process (COMMAND ${_glib_comple_schemas} --dry-run --schema-file=${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE) if (_schemas_invalid) message (SEND_ERROR "Schema validation error: ${_schemas_invalid}") endif (_schemas_invalid) # Actually install and recomple schemas message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}") install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME} DESTINATION ${GSETTINGS_DIR} OPTIONAL) if (GSETTINGS_COMPILE) install (CODE "message (STATUS \"Compiling GSettings schemas\")") install (CODE "execute_process (COMMAND ${_glib_comple_schemas} ${GSETTINGS_DIR})") endif () endmacro() indicator-network-0.5.1+14.04.20140409.1/secret-agent/0000755000015301777760000000000012321337176022306 5ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/secret-agent/SecretRequest.h0000644000015301777760000000331412321336644025255 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #ifndef SECRETREQUEST_H_ #define SECRETREQUEST_H_ #include #include #include #include class SecretRequest; class SecretAgent; class SecretRequest: public QObject { Q_OBJECT public: explicit SecretRequest(SecretAgent &secretAgent, const QVariantDictMap &connection, const QDBusObjectPath &connectionPath, const QString &settingName, const QStringList &hints, uint flags, const QDBusMessage &reply, QObject *parent = 0); virtual ~SecretRequest(); public Q_SLOTS: void actionInvoked(uint id, const QString &actionKey); void notificationClosed(uint id, uint reason); public: const QVariantDictMap & connection() const; const QDBusMessage & message() const; protected: unsigned int m_notificationId; SecretAgent &m_secretAgent; QVariantDictMap m_connection; QDBusObjectPath m_connectionPath; QString m_settingName; QStringList m_hints; uint m_flags; QDBusMessage m_message; PasswordMenu m_menu; }; #endif /* SECRETREQUEST_H_ */ indicator-network-0.5.1+14.04.20140409.1/secret-agent/DBusTypes.h0000644000015301777760000000206512321336644024343 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #ifndef DBUSTYPES_H_ #define DBUSTYPES_H_ #include #include typedef QMap QVariantDictMap; Q_DECLARE_METATYPE(QVariantDictMap) class DBusTypes { public: static void registerMetaTypes() { qRegisterMetaType("QVariantDictMap"); qDBusRegisterMetaType(); } }; #endif /* DBUSTYPES_H_ */ indicator-network-0.5.1+14.04.20140409.1/secret-agent/SecretAgent.h0000644000015301777760000000502612321336644024665 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #ifndef SECRETAGENT_H_ #define SECRETAGENT_H_ #include #include #include #include #include #include #include #include #include class SecretAgentAdaptor; class SecretAgent: public QObject, protected QDBusContext { Q_OBJECT public: static const QString CONNECTION_SETTING_NAME; static const QString WIRELESS_SECURITY_SETTING_NAME; static const QString CONNECTION_ID; static const QString WIRELESS_SECURITY_PSK; static const QString WIRELESS_SECURITY_WEP_KEY0; static const QString WIRELESS_SECURITY_KEY_MGMT; static const QString KEY_MGMT_WPA_NONE; static const QString KEY_MGMT_WPA_PSK; static const QString KEY_MGMT_NONE; explicit SecretAgent(const QDBusConnection &systemConnection, const QDBusConnection &sessionConnection, QObject *parent = 0); virtual ~SecretAgent(); public Q_SLOTS: QVariantDictMap GetSecrets(const QVariantDictMap &connection, const QDBusObjectPath &connectionPath, const QString &settingName, const QStringList &hints, uint flags); void FinishGetSecrets(SecretRequest &request, bool error); void CancelGetSecrets(const QDBusObjectPath &connectionPath, const QString &settingName); void DeleteSecrets(const QVariantDictMap &connection, const QDBusObjectPath &connectionPath); void SaveSecrets(const QVariantDictMap &connection, const QDBusObjectPath &connectionPath); org::freedesktop::Notifications & notifications(); protected: QScopedPointer m_adaptor; QDBusConnection m_systemConnection; QDBusConnection m_sessionConnection; org::freedesktop::NetworkManager::AgentManager m_agentManager; org::freedesktop::Notifications m_notifications; std::shared_ptr m_request; }; #endif /* SECRETAGENT_H_ */ indicator-network-0.5.1+14.04.20140409.1/secret-agent/SecretAgentInclude.h0000644000015301777760000000152512321336644026171 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #ifndef SECRETAGENTINCLUDE_H_ #define SECRETAGENTINCLUDE_H_ #include #include #endif /* SECRETAGENTINCLUDE_H_ */ indicator-network-0.5.1+14.04.20140409.1/secret-agent/PasswordMenu.h0000644000015301777760000000215012321336644025103 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #ifndef PASSWORDMENU_H_ #define PASSWORDMENU_H_ #include #include class PasswordMenuPriv; class PasswordMenu { public: PasswordMenu(); virtual ~PasswordMenu(); const QString & busName() const; const QString & password() const; const QString & actionPath() const; const QString & menuPath() const; protected: QScopedPointer p; }; #endif /* PASSWORDMENU_H_ */ indicator-network-0.5.1+14.04.20140409.1/secret-agent/gtk/0000755000015301777760000000000012321337176023073 5ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/secret-agent/Localisation.h0000644000015301777760000000157512321336644025107 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #ifndef DAEMON_LOCALISATION_H_ #define DAEMON_LOCALISATION_H_ #include inline char* _(const char *__msgid) { return gettext(__msgid); } #endif // DAEMON_LOCALISATION_H_ indicator-network-0.5.1+14.04.20140409.1/secret-agent/main.cpp0000644000015301777760000000273512321336644023744 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #include #include #include #include #include #include #include using namespace std; static void exitQt(int sig) { Q_UNUSED(sig); QCoreApplication::exit(0); } int main(int argc, char *argv[]) { QCoreApplication application(argc, argv); DBusTypes::registerMetaTypes(); setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); textdomain(GETTEXT_PACKAGE); signal(SIGINT, &exitQt); signal(SIGTERM, &exitQt); SecretAgent secretAgent(QDBusConnection::systemBus(), QDBusConnection::sessionBus()); if (argc == 2 && QString("--print-address") == argv[1]) { cout << QDBusConnection::systemBus().baseService().toStdString() << endl; } return application.exec(); } indicator-network-0.5.1+14.04.20140409.1/secret-agent/CMakeLists.txt0000644000015301777760000000231412321336644025045 0ustar pbusernogroup00000000000000 set( INDICATOR_SECRET_AGENT_SOURCES SecretAgent.cpp SecretAgentAdaptor.cpp SecretRequest.cpp PasswordMenu.cpp ) qt5_add_dbus_adaptor( INDICATOR_SECRET_AGENT_SOURCES "${DATA_DIR}/nm-secret-agent.xml" SecretAgentInclude.h SecretAgent SecretAgentAdaptor ) qt5_add_dbus_interface( INDICATOR_SECRET_AGENT_SOURCES "${DATA_DIR}/nm-agent-manager.xml" AgentManagerInterface ) set_source_files_properties( "${DATA_DIR}/org.freedesktop.Notifications.xml" PROPERTIES INCLUDE "DBusTypes.h" ) qt5_add_dbus_interface( INDICATOR_SECRET_AGENT_SOURCES "${DATA_DIR}/org.freedesktop.Notifications.xml" NotificationsInterface ) add_library( indicator-secret-agent STATIC ${INDICATOR_SECRET_AGENT_SOURCES} ) qt5_use_modules( indicator-secret-agent Core DBus ) target_link_libraries( indicator-secret-agent ${GIO_LIBRARIES} ) add_executable( indicator-secret-agent-bin main.cpp ) set_target_properties( indicator-secret-agent-bin PROPERTIES OUTPUT_NAME indicator-secret-agent ) qt5_use_modules( indicator-secret-agent-bin Core ) target_link_libraries( indicator-secret-agent-bin indicator-secret-agent ) install( TARGETS indicator-secret-agent-bin RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}" ) indicator-network-0.5.1+14.04.20140409.1/secret-agent/SecretRequest.cpp0000644000015301777760000001045012321336644025607 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #include #include #include SecretRequest::SecretRequest(SecretAgent &secretAgent, const QVariantDictMap &connection, const QDBusObjectPath &connectionPath, const QString &settingName, const QStringList &hints, uint flags, const QDBusMessage &message, QObject *parent) : QObject(parent), m_secretAgent(secretAgent), m_connection( connection), m_connectionPath(connectionPath), m_settingName( settingName), m_hints(hints), m_flags(flags), m_message( message), m_menu() { connect(&m_secretAgent.notifications(), SIGNAL(ActionInvoked(uint, const QString &)), this, SLOT(actionInvoked(uint, const QString &))); connect(&m_secretAgent.notifications(), SIGNAL(NotificationClosed(uint, uint)), this, SLOT(notificationClosed(uint, uint))); // indicate to the notification-daemon, that we want to use snap-decisions QVariantMap notificationHints; notificationHints["x-canonical-snap-decisions"] = "true"; notificationHints["x-canonical-private-button-tint"] = "true"; QVariantMap menuModelActions; menuModelActions["notifications"] = m_menu.actionPath(); QVariantMap menuModelPaths; menuModelPaths["busName"] = m_menu.busName(); menuModelPaths["menuPath"] = m_menu.menuPath(); menuModelPaths["actions"] = menuModelActions; notificationHints["x-canonical-private-menu-model"] = menuModelPaths; const QVariantMap &conn = m_connection[SecretAgent::CONNECTION_SETTING_NAME]; auto wirelessSecurity = m_connection.find(m_settingName); QString keyMgmt( wirelessSecurity->value(SecretAgent::WIRELESS_SECURITY_KEY_MGMT).toString()); QString title(_("Connect to “%1”")); QString subject; if (keyMgmt == SecretAgent::KEY_MGMT_WPA_NONE || keyMgmt == SecretAgent::KEY_MGMT_WPA_PSK) { subject = _("WPA"); } else if (keyMgmt == SecretAgent::KEY_MGMT_NONE) { subject = _("WEP"); } m_notificationId = m_secretAgent.notifications().Notify("indicator-network", 0, "wifi-full-secure", title.arg(conn[SecretAgent::CONNECTION_ID].toString()), subject, QStringList() << "connect_id" << _("Connect") << "cancel_id" << _("Cancel"), notificationHints, 0); } SecretRequest::~SecretRequest() { /* Close the notification if it's open */ if (m_notificationId != 0) { m_secretAgent.notifications().CloseNotification(m_notificationId).waitForFinished(); m_notificationId = 0; } } /* Called when the user submits a password */ void SecretRequest::actionInvoked(uint id, const QString &actionKey) { // Ignore other requests' notifications if (id != m_notificationId) { return; } m_notificationId = 0; if (actionKey != "connect_id") { m_secretAgent.FinishGetSecrets(*this, true); return; } QString key(""); key = m_menu.password(); auto wirelessSecurity = m_connection.find(m_settingName); QString keyMgmt( wirelessSecurity->value(SecretAgent::WIRELESS_SECURITY_KEY_MGMT).toString()); if (keyMgmt == SecretAgent::KEY_MGMT_WPA_NONE || keyMgmt == SecretAgent::KEY_MGMT_WPA_PSK) { wirelessSecurity->insert(SecretAgent::WIRELESS_SECURITY_PSK, key); } else if (keyMgmt == SecretAgent::KEY_MGMT_NONE) { wirelessSecurity->insert(SecretAgent::WIRELESS_SECURITY_WEP_KEY0, key); } m_secretAgent.FinishGetSecrets(*this, false); } /* Called when the user closes the dialog */ void SecretRequest::notificationClosed(uint id, uint reason) { // Ignore other requests' notifications if (id != m_notificationId) { return; } m_notificationId = 0; m_secretAgent.FinishGetSecrets(*this, true); } const QVariantDictMap & SecretRequest::connection() const { return m_connection; } const QDBusMessage & SecretRequest::message() const { return m_message; } indicator-network-0.5.1+14.04.20140409.1/secret-agent/PasswordMenu.cpp0000644000015301777760000001064212321336644025443 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #include #include #include #include static const QString PASSWORD_ACTION_PATH("/action/%1"); static const QString PASSWORD_MENU_PATH("/menu/%1"); class PasswordMenuPriv { public: PasswordMenuPriv() : m_connection(g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL)), m_exportedActionGroupId(0), m_exportedMenuModelId(0) { } ~PasswordMenuPriv() { g_object_unref(m_connection); } static void passwordChangedCallback(GAction *passwordAction, GVariant *variant, gpointer userData) { PasswordMenuPriv *self(reinterpret_cast(userData)); self->passwordChanged(variant); } void passwordChanged(GVariant *variant) { m_password = QString::fromUtf8(g_variant_get_string(variant, 0)); if (qEnvironmentVariableIsSet("SECRET_AGENT_DEBUG_PASSWORD")) { qDebug() << "Password received"; } } GDBusConnection *m_connection; QString m_busName; QString m_actionPath; QString m_menuPath; unsigned int m_exportedActionGroupId; unsigned int m_exportedMenuModelId; QString m_password; }; PasswordMenu::PasswordMenu() : p(new PasswordMenuPriv()) { int exportrev; p->m_busName = QString::fromUtf8( g_dbus_connection_get_unique_name(p->m_connection)); // menu GMenu *menu(g_menu_new()); GMenuItem *passwordItem(g_menu_item_new("", "notifications.password")); g_menu_item_set_attribute_value(passwordItem, "x-canonical-type", g_variant_new_string("com.canonical.snapdecision.textfield")); g_menu_item_set_attribute_value(passwordItem, "x-echo-mode-password", g_variant_new_boolean(true)); g_menu_append_item(menu, passwordItem); // actions GActionGroup *actions(G_ACTION_GROUP(g_simple_action_group_new())); GAction *passwordAction(G_ACTION( g_simple_action_new_stateful("password", G_VARIANT_TYPE_STRING, g_variant_new_string("")))); g_signal_connect(G_OBJECT(passwordAction), "change-state", G_CALLBACK(PasswordMenuPriv::passwordChangedCallback), reinterpret_cast(p.data())); g_action_map_add_action(G_ACTION_MAP(actions), passwordAction); /* Export the actions group. If we can't get a name, keep trying to use increasing numbers. There is possible races on fast import/exports. They're rare, but worth protecting against. */ exportrev = 0; do { exportrev++; p->m_actionPath = PASSWORD_ACTION_PATH.arg(exportrev); p->m_exportedActionGroupId = g_dbus_connection_export_action_group( p->m_connection, p->m_actionPath.toUtf8().data(), actions, NULL); } while (p->m_exportedActionGroupId == 0 && exportrev < 128); /* Export the menu. If we can't get a name, keep trying to use increasing numbers. There is possible races on fast import/exports. They're rare, but worth protecting against. */ exportrev = 0; do { exportrev++; p->m_menuPath = PASSWORD_MENU_PATH.arg(exportrev); p->m_exportedMenuModelId = g_dbus_connection_export_menu_model( p->m_connection, p->m_menuPath.toUtf8().data(), G_MENU_MODEL(menu), NULL); } while (p->m_exportedMenuModelId == 0 && exportrev < 128); /* Unref the objects as a reference is maintained by the fact that they're exported onto the bus. */ g_object_unref(menu); g_object_unref(passwordItem); g_object_unref(actions); g_object_unref(passwordAction); } PasswordMenu::~PasswordMenu() { g_dbus_connection_unexport_action_group(p->m_connection, p->m_exportedActionGroupId); g_dbus_connection_unexport_menu_model(p->m_connection, p->m_exportedMenuModelId); } const QString & PasswordMenu::busName() const { return p->m_busName; } const QString & PasswordMenu::password() const { return p->m_password; } const QString & PasswordMenu::actionPath() const { return p->m_actionPath; } const QString & PasswordMenu::menuPath() const { return p->m_menuPath; } indicator-network-0.5.1+14.04.20140409.1/secret-agent/SecretAgent.cpp0000644000015301777760000001205012321336644025213 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #include #include #include #include #include using namespace std; using namespace org::freedesktop::NetworkManager; const QString SecretAgent::CONNECTION_SETTING_NAME("connection"); const QString SecretAgent::WIRELESS_SECURITY_SETTING_NAME( "802-11-wireless-security"); const QString SecretAgent::CONNECTION_ID("id"); const QString SecretAgent::WIRELESS_SECURITY_PSK("psk"); const QString SecretAgent::WIRELESS_SECURITY_WEP_KEY0("wep-key0"); const QString SecretAgent::WIRELESS_SECURITY_KEY_MGMT("key-mgmt"); const QString SecretAgent::KEY_MGMT_WPA_NONE("wpa-none"); const QString SecretAgent::KEY_MGMT_WPA_PSK("wpa-psk"); const QString SecretAgent::KEY_MGMT_NONE("none"); SecretAgent::SecretAgent(const QDBusConnection &systemConnection, const QDBusConnection &sessionConnection, QObject *parent) : QObject(parent), m_adaptor(new SecretAgentAdaptor(this)), m_systemConnection( systemConnection), m_sessionConnection(sessionConnection), m_agentManager( NM_DBUS_SERVICE, NM_DBUS_PATH_AGENT_MANAGER, m_systemConnection), m_notifications( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", m_sessionConnection), m_request(nullptr) { if (!m_systemConnection.registerObject(NM_DBUS_PATH_SECRET_AGENT, this)) { throw logic_error( _("Unable to register user secret agent object on DBus")); } m_agentManager.Register("com.canonical.indicator.SecretAgent").waitForFinished(); } SecretAgent::~SecretAgent() { m_agentManager.Unregister().waitForFinished(); m_systemConnection.unregisterObject(NM_DBUS_PATH_SECRET_AGENT); } /** * Example call: * [Argument: a{sa{sv}} * { * "802-11-wireless" = [Argument: a{sv} { * "security" = [Variant(QString): "802-11-wireless-security"], * "ssid" = [Variant(QByteArray): {83, 119, 97, 108, 108, 111, 119, 115, 32, 66, 97, 114, 110}], * "mode" = [Variant(QString): "infrastructure"], * "mac-address" = [Variant(QByteArray): {8, 212, 43, 19, 139, 130}] * }], * "connection" = [Argument: a{sv} { * "id" = [Variant(QString): "Swallows Barn"], * "uuid" = [Variant(QString): "40fdd8b6-e119-41ae-87a3-7bfc8044f753"], * "type" = [Variant(QString): "802-11-wireless"] * }], * "ipv4" = [Argument: a{sv} { * "addresses" = [Variant: [Argument: aau {}]], * "dns" = [Variant: [Argument: au {}]], * "method" = [Variant(QString): "auto"], * "routes" = [Variant: [Argument: aau {}]] * }], * "802-11-wireless-security" = [Argument: a{sv} { * "auth-alg" = [Variant(QString): "open"], * "key-mgmt" = [Variant(QString): "wpa-psk"] * }], * "ipv6" = [Argument: a{sv} { * "addresses" = [Variant: [Argument: a(ayuay) {}]], * "dns" = [Variant: [Argument: aay {}]], * "method" = [Variant(QString): "auto"], * "routes" = [Variant: [Argument: a(ayuayu) {}]] * }] * } * ], * [ObjectPath: /org/freedesktop/NetworkManager/Settings/0], * "802-11-wireless-security", * {}, * 5 */ QVariantDictMap SecretAgent::GetSecrets(const QVariantDictMap &connection, const QDBusObjectPath &connectionPath, const QString &settingName, const QStringList &hints, uint flags) { setDelayedReply(true); if (flags == 0) { m_systemConnection.send( message().createErrorReply(QDBusError::InternalError, "No password found for this connection.")); } else { m_request.reset(new SecretRequest(*this, connection, connectionPath, settingName, hints, flags, message())); } return QVariantDictMap(); } void SecretAgent::FinishGetSecrets(SecretRequest &request, bool error) { if (error) { m_systemConnection.send( request.message().createErrorReply(QDBusError::InternalError, "No password found for this connection.")); } else { m_systemConnection.send( request.message().createReply( QVariant::fromValue(request.connection()))); } m_request.reset(); } void SecretAgent::CancelGetSecrets(const QDBusObjectPath &connectionPath, const QString &settingName) { m_request.reset(); } void SecretAgent::DeleteSecrets(const QVariantDictMap &connection, const QDBusObjectPath &connectionPath) { } void SecretAgent::SaveSecrets(const QVariantDictMap &connection, const QDBusObjectPath &connectionPath) { } org::freedesktop::Notifications & SecretAgent::notifications() { return m_notifications; } indicator-network-0.5.1+14.04.20140409.1/tests/0000755000015301777760000000000012321337176021067 5ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/tests/TestIndicatorNetworkService.cpp0000644000015301777760000000307212321336644027243 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #include #include #include #include #include #include using namespace std; using namespace testing; using namespace QtDBusTest; using namespace QtDBusMock; namespace { class TestIndicatorNetworkService: public Test { protected: TestIndicatorNetworkService() : dbusMock(dbusTestRunner) { dbusMock.registerNetworkManager(); dbusTestRunner.startServices(); DBusServicePtr indicator( new QProcessDBusService("com.canonical.indicator.network", QDBusConnection::SessionBus, NETWORK_SERVICE_BIN, QStringList())); } virtual ~TestIndicatorNetworkService() { } DBusTestRunner dbusTestRunner; DBusMock dbusMock; }; TEST_F(TestIndicatorNetworkService, Foo) { //FIXME: Port the python test } } // namespace indicator-network-0.5.1+14.04.20140409.1/tests/TestSecretAgent.cpp0000644000015301777760000002447112321336644024646 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #include #include #include #include #include #include #include #include #include using namespace std; using namespace testing; using namespace QtDBusTest; using namespace QtDBusMock; namespace { class TestSecretAgentCommon { protected: TestSecretAgentCommon() : dbusMock(dbusTestRunner) { dbusMock.registerCustomMock("org.freedesktop.Notifications", "/org/freedesktop/Notifications", OrgFreedesktopNotificationsInterface::staticInterfaceName(), QDBusConnection::SessionBus); dbusMock.registerNetworkManager(); dbusTestRunner.startServices(); QProcessEnvironment env(QProcessEnvironment::systemEnvironment()); env.insert("SECRET_AGENT_DEBUG_PASSWORD", "1"); secretAgent.setProcessEnvironment(env); secretAgent.setProcessChannelMode(QProcess::MergedChannels); secretAgent.start(SECRET_AGENT_BIN, QStringList() << "--print-address"); secretAgent.waitForStarted(); secretAgent.waitForReadyRead(); agentBus = secretAgent.readAll().trimmed(); agentInterface.reset( new OrgFreedesktopNetworkManagerSecretAgentInterface(agentBus, NM_DBUS_PATH_SECRET_AGENT, dbusTestRunner.systemConnection())); notificationsInterface.reset( new OrgFreedesktopDBusMockInterface( "org.freedesktop.Notifications", "/org/freedesktop/Notifications", dbusTestRunner.sessionConnection())); } virtual ~TestSecretAgentCommon() { secretAgent.terminate(); secretAgent.waitForFinished(); } QVariantDictMap connection(const QString &keyManagement) { QVariantMap wirelessSecurity; wirelessSecurity[SecretAgent::WIRELESS_SECURITY_KEY_MGMT] = keyManagement; QVariantMap conn; conn[SecretAgent::CONNECTION_ID] = "the ssid"; QVariantDictMap connection; connection[SecretAgent::WIRELESS_SECURITY_SETTING_NAME] = wirelessSecurity; connection[SecretAgent::CONNECTION_SETTING_NAME] = conn; return connection; } QVariantDictMap expected(const QString &keyManagement, const QString &keyName, const QString &password) { QVariantMap wirelessSecurity; wirelessSecurity[SecretAgent::WIRELESS_SECURITY_KEY_MGMT] = keyManagement; wirelessSecurity[keyName] = password; QVariantMap conn; conn[SecretAgent::CONNECTION_ID] = "the ssid"; QVariantDictMap connection; connection[SecretAgent::WIRELESS_SECURITY_SETTING_NAME] = wirelessSecurity; connection[SecretAgent::CONNECTION_SETTING_NAME] = conn; return connection; } DBusTestRunner dbusTestRunner; DBusMock dbusMock; QProcess secretAgent; QString agentBus; QScopedPointer agentInterface; QScopedPointer notificationsInterface; }; struct TestSecretAgentParams { QString keyManagement; QString passwordKey; QString password; }; class TestSecretAgentGetSecrets: public TestSecretAgentCommon, public TestWithParam { }; static void transform(QVariantMap &map); static void transform(QVariant &variant) { if (variant.canConvert()) { QDBusArgument value(variant.value()); if (value.currentType() == QDBusArgument::MapType) { QVariantMap map; value >> map; transform(map); variant = map; } } } static void transform(QVariantMap &map) { for (auto it(map.begin()); it != map.end(); ++it) { transform(*it); } } static void transform(QVariantList &list) { for (auto it(list.begin()); it != list.end(); ++it) { transform(*it); } } TEST_P(TestSecretAgentGetSecrets, ProvidesPasswordForWpaPsk) { notificationsInterface->AddMethod( OrgFreedesktopNotificationsInterface::staticInterfaceName(), "Notify", "susssasa{sv}i", "u", "ret = 1").waitForFinished(); QDBusPendingReply reply( agentInterface->GetSecrets(connection(GetParam().keyManagement), QDBusObjectPath("/connection/foo"), SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(), 5)); QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &))); notificationSpy.wait(); ASSERT_EQ(1, notificationSpy.size()); const QVariantList &call(notificationSpy.at(0)); ASSERT_EQ("Notify", call.at(0)); QVariantList args(call.at(1).toList()); transform(args); ASSERT_EQ(8, args.size()); EXPECT_EQ("indicator-network", args.at(0)); EXPECT_EQ("Connect to “the ssid”", args.at(3).toString().toStdString()); QVariantMap hints(args.at(6).toMap()); QVariantMap menuInfo(hints["x-canonical-private-menu-model"].toMap()); QString busName(menuInfo["busName"].toString()); QString menuPath(menuInfo["menuPath"].toString()); QVariantMap actions(menuInfo["actions"].toMap()); { UnityMenuModel menuModel; QSignalSpy menuSpy(&menuModel, SIGNAL(rowsInserted(const QModelIndex&, int, int))); menuModel.setBusName(busName.toUtf8()); menuModel.setMenuObjectPath(menuPath.toUtf8()); menuModel.setActions(actions); menuSpy.wait(); menuModel.changeState(0, "hard-coded-password"); // It seems like UnityMenuModel or the GLib // DBus connection needs some grace time to // finish dispatching. secretAgent.waitForReadyRead(); ASSERT_EQ("Password received", secretAgent.readAll().trimmed()); } notificationsInterface->EmitSignal( OrgFreedesktopNotificationsInterface::staticInterfaceName(), "ActionInvoked", "us", QVariantList() << 1 << "connect_id"); QVariantDictMap result(reply); EXPECT_EQ( expected(GetParam().keyManagement, GetParam().passwordKey, GetParam().password), result); } INSTANTIATE_TEST_CASE_P(WpaPsk, TestSecretAgentGetSecrets, Values(TestSecretAgentParams( { SecretAgent::KEY_MGMT_WPA_PSK, SecretAgent::WIRELESS_SECURITY_PSK, "hard-coded-password" }))); INSTANTIATE_TEST_CASE_P(WpaNone, TestSecretAgentGetSecrets, Values(TestSecretAgentParams( { SecretAgent::KEY_MGMT_WPA_NONE, SecretAgent::WIRELESS_SECURITY_PSK, "hard-coded-password" }))); INSTANTIATE_TEST_CASE_P(None, TestSecretAgentGetSecrets, Values( TestSecretAgentParams( { SecretAgent::KEY_MGMT_NONE, SecretAgent::WIRELESS_SECURITY_WEP_KEY0, "hard-coded-password" }))); class TestSecretAgent: public TestSecretAgentCommon, public Test { }; TEST_F(TestSecretAgent, GetSecretsWithNone) { QDBusPendingReply reply( agentInterface->GetSecrets( connection(SecretAgent::KEY_MGMT_WPA_PSK), QDBusObjectPath("/connection/foo"), SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(), 0)); reply.waitForFinished(); ASSERT_TRUE(reply.isError()); EXPECT_EQ(QDBusError::InternalError, reply.error().type()); EXPECT_EQ("No password found for this connection.", reply.error().message()); } /* Tests that if we request secrets and then cancel the request that we close the notification */ TEST_F(TestSecretAgent, CancelGetSecrets) { notificationsInterface->AddMethod( OrgFreedesktopNotificationsInterface::staticInterfaceName(), "Notify", "susssasa{sv}i", "u", "ret = 1").waitForFinished(); notificationsInterface->AddMethod( OrgFreedesktopNotificationsInterface::staticInterfaceName(), "CloseNotification", "u", "", "").waitForFinished(); agentInterface->GetSecrets( connection(SecretAgent::KEY_MGMT_WPA_PSK), QDBusObjectPath("/connection/foo"), SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(), 5); QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &))); notificationSpy.wait(); ASSERT_EQ(1, notificationSpy.size()); const QVariantList &call(notificationSpy.at(0)); ASSERT_EQ("Notify", call.at(0)); notificationSpy.clear(); agentInterface->CancelGetSecrets(QDBusObjectPath("/connection/foo"), SecretAgent::WIRELESS_SECURITY_SETTING_NAME); notificationSpy.wait(); ASSERT_EQ(1, notificationSpy.size()); const QVariantList &closecall(notificationSpy.at(0)); ASSERT_EQ("CloseNotification", closecall.at(0)); } /* Ensures that if we request secrets twice we close the notification for the first request */ TEST_F(TestSecretAgent, MultiSecrets) { notificationsInterface->AddMethod( OrgFreedesktopNotificationsInterface::staticInterfaceName(), "Notify", "susssasa{sv}i", "u", "ret = 1").waitForFinished(); notificationsInterface->AddMethod( OrgFreedesktopNotificationsInterface::staticInterfaceName(), "CloseNotification", "u", "", "").waitForFinished(); QSignalSpy notificationSpy(notificationsInterface.data(), SIGNAL(MethodCalled(const QString &, const QVariantList &))); agentInterface->GetSecrets( connection(SecretAgent::KEY_MGMT_WPA_PSK), QDBusObjectPath("/connection/foo"), SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(), 5); notificationSpy.wait(); ASSERT_EQ(1, notificationSpy.size()); const QVariantList &call(notificationSpy.at(0)); ASSERT_EQ("Notify", call.at(0)); notificationSpy.clear(); agentInterface->GetSecrets( connection(SecretAgent::KEY_MGMT_WPA_PSK), QDBusObjectPath("/connection/foo2"), SecretAgent::WIRELESS_SECURITY_SETTING_NAME, QStringList(), 5); notificationSpy.wait(); notificationSpy.wait(); ASSERT_EQ(2, notificationSpy.size()); const QVariantList &closecall(notificationSpy.at(1)); ASSERT_EQ("CloseNotification", closecall.at(0)); const QVariantList &newnotify(notificationSpy.at(0)); ASSERT_EQ("Notify", newnotify.at(0)); } TEST_F(TestSecretAgent, SaveSecrets) { agentInterface->SaveSecrets(QVariantDictMap(), QDBusObjectPath("/connection/foo")).waitForFinished(); } TEST_F(TestSecretAgent, DeleteSecrets) { agentInterface->DeleteSecrets(QVariantDictMap(), QDBusObjectPath("/connection/foo")).waitForFinished(); } } // namespace indicator-network-0.5.1+14.04.20140409.1/tests/data/0000755000015301777760000000000012321337176022000 5ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/tests/data/valgrind.suppression0000644000015301777760000000277512321336644026134 0ustar pbusernogroup00000000000000{ Ignore pthreads Memcheck:Leak ... fun:pthread_create@@* } { Glib memalign Memcheck:Leak ... fun:posix_memalign } { Ignore glib mainloop Memcheck:Leak ... fun:g_main_context_push_thread_default } { Ignore glib main context Memcheck:Leak ... fun:g_main_context_new } ############################### # DBus ############################### { Memcheck:Param epoll_ctl(event) fun:epoll_ctl obj:/bin/dbus-daemon ... fun:(below main) } ############################### # GObject rules ############################### { Memcheck:Leak ... fun:g_type_register_static } { Memcheck:Leak ... fun:g_type_register_fundamental } { Memcheck:Leak ... fun:type_node_fundamental_new_W } { Memcheck:Leak ... fun:type_data_make_W } { Memcheck:Leak ... fun:g_type_add_interface_static } { Memcheck:Leak ... fun:type_iface_vtable_base_init_Wm } { Memcheck:Leak ... fun:g_dbus_interface_skeleton_class_intern_init } { Memcheck:Leak ... fun:g_signal_type_cclosure_new } { Memcheck:Leak fun:calloc fun:g_malloc0 fun:g_type_class_ref } indicator-network-0.5.1+14.04.20140409.1/tests/manual0000644000015301777760000000142212321336644022265 0ustar pbusernogroup00000000000000 Test-case indicator-network/unity7-items-check
Log in to a Unity 7 user session
Go to the panel and click on the Network indicator
Ensure there are items in the menu
Test-case indicator-network/unity7-greeter-items-check
Start a system and wait for the greeter or logout of the current user session
Go to the panel and click on the Network indicator
Ensure there are items in the menu
Test-case indicator-network/unity8-items-check
Login to a user session running Unity 8
Pull down the top panel until it sticks open
Navigate through the tabs until "Network" is shown
Network is at the top of the menu
The menu is populated with items
indicator-network-0.5.1+14.04.20140409.1/tests/main.cpp0000644000015301777760000000232412321336644022517 0ustar pbusernogroup00000000000000/* * Copyright (C) 2013 Canonical, Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Author: Pete Woods */ #include #include #include #include #include using namespace QtDBusMock; int main(int argc, char **argv) { qputenv("LANG", "C.UTF-8"); unsetenv("LC_ALL"); setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); textdomain(GETTEXT_PACKAGE); QCoreApplication application(argc, argv); DBusMock::registerMetaTypes(); DBusTypes::registerMetaTypes(); ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } indicator-network-0.5.1+14.04.20140409.1/tests/CMakeLists.txt0000644000015301777760000000220012321336644023620 0ustar pbusernogroup00000000000000 set(CMAKE_AUTOMOC OFF) include(FindGMock) set(CMAKE_AUTOMOC ON) find_package("Valgrind" REQUIRED) include_directories("${CMAKE_SOURCE_DIR}/secret-agent") include_directories("${CMAKE_BINARY_DIR}/secret-agent") include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${GMOCK_INCLUDE_DIRS}) include_directories(${GTEST_INCLUDE_DIRS}) add_definitions(-DSECRET_AGENT_BIN="${CMAKE_BINARY_DIR}/secret-agent/indicator-secret-agent") add_definitions(-DNETWORK_SERVICE_BIN="${CMAKE_BINARY_DIR}/network/indicator-network-service") set( UNIT_TESTS_SRC TestIndicatorNetworkService.cpp TestSecretAgent.cpp main.cpp ) set_source_files_properties( "${DATA_DIR}/nm-secret-agent.xml" PROPERTIES INCLUDE "DBusTypes.h" ) qt5_add_dbus_interface( UNIT_TESTS_SRC "${DATA_DIR}/nm-secret-agent.xml" SecretAgentInterface ) add_executable( unit-tests ${UNIT_TESTS_SRC} ) qt5_use_modules( unit-tests Core DBus Test ) target_link_libraries( unit-tests indicator-secret-agent ${QTDBUSMOCK_LIBRARIES} ${QTDBUSTEST_LIBRARIES} ${QMENUMODEL_LIBRARIES} ${GTEST_LIBRARIES} ${GMOCK_LIBRARIES} ) add_valgrind_test( unit-tests unit-tests ) indicator-network-0.5.1+14.04.20140409.1/data/0000755000015301777760000000000012321337176020636 5ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/data/org.freedesktop.Notifications.xml0000644000015301777760000000350112321336644027267 0ustar pbusernogroup00000000000000 indicator-network-0.5.1+14.04.20140409.1/data/indicator-network.desktop.in0000644000015301777760000000027112321336655026302 0ustar pbusernogroup00000000000000[Desktop Entry] Type=Application Name=Indicator Network Exec=@NETWORK_SERVICE@ StartupNotify=false Terminal=false OnlyShowIn=Unity;GNOME; AutostartCondition=GNOME3 unless-session gnome indicator-network-0.5.1+14.04.20140409.1/data/nm-secret-agent.xml0000644000015301777760000002322212321336644024351 0ustar pbusernogroup00000000000000 Private D-Bus interface used by secret agents that store and provide secrets to NetworkManager. If an agent provides secrets to NetworkManager as part of connection creation, and the some of those secrets are "agent owned" the agent should store those secrets itself and should not expect its SaveSecrets() method to be called. SaveSecrets() will be called eg if some program other than the agent itself (like a connection editor) changes the secrets out of band. Retrieve and return stored secrets, if any, or request new secrets from the agent's user. If user interaction is allowed and the user enters new secrets, the agent is expected to save the new secrets to persistent storage (if the secret's flags include AGENT_OWNED) as NetworkManager will not send these secrets back to the same agent via a SaveSecrets() call. Nested settings maps containing the connection for which secrets are being requested. This may contain system-owned secrets if the agent has successfully authenticated to modify system network settings and the GetSecrets request flags allow user interaction. Object path of the connection for which secrets are being requested. Setting name for which secrets are being requested. Array of strings of key names in the requested setting for which NetworkManager thinks a secrets may be required, and/or well-known identifiers and data that may be useful to the client in processing the secrets request. Note that it's not always possible to determine which secret is required, so in some cases no hints may be given. The Agent should return any secrets it has, or that it thinks are required, regardless of what hints NetworkManager sends in this request. Flags which modify the behavior of the secrets request. If true, new secrets are assumed to be invalid or incorrect, and the agent should ask the user for new secrets. If false, existing secrets should be retrieved from storage and returned without interrupting the user. Nested settings maps containing secrets. Each setting MUST contain at least the 'name' field, containing the name of the setting, and one or more secrets. Flags modifying the behavior of GetSecrets request. No special behavior; by default no user interaction is allowed and requests for secrets are fulfilled from persistent storage, or if no secrets are available an error is returned. Allows the request to interact with the user, possibly prompting via UI for secrets if any are required, or if none are found in persistent storage. Explicitly prompt for new secrets from the user. This flag signals that NetworkManager thinks any existing secrets are invalid or wrong. This flag implies that interaction is allowed. Set if the request was initiated by user-requested action via the D-Bus interface, as opposed to automatically initiated by NetworkManager in response to (for example) scan results or carrier changes. Cancel a pending GetSecrets request for secrets of the given connection. Any GetSecrets request with the same 'connection_path' and 'setting_name' that are given in a CancelGetSecrets request should be canceled. Object path of the connection for which, if secrets for the given 'setting_name' are being requested, the request should be canceled. Setting name for which secrets for this connection were originally being requested. Save given secrets to backing storage. Nested settings maps containing the entire connection (including secrets), for which the agent should save the secrets to backing storage. This method will not be called when the agent itself is the process creating or updating a connection; in that case the agent is assumed to have already saved those secrets since it had them already. Object path of the connection for which the agent should save secrets to backing storage. Delete secrets from backing storage. Nested settings maps containing the connection properties (sans secrets), for which the agent should delete the secrets from backing storage. Object path of the connection for which the agent should delete secrets from backing storage. indicator-network-0.5.1+14.04.20140409.1/data/com.canonical.indicator.network0000644000015301777760000000057012321336644026731 0ustar pbusernogroup00000000000000[Indicator Service] Name=indicator-network ObjectPath=/com/canonical/indicator/network Position=60 [desktop] ObjectPath=/com/canonical/indicator/network/desktop [phone] ObjectPath=/com/canonical/indicator/network/phone [phone_wifi_settings] ObjectPath=/com/canonical/indicator/network/phone_wifi_settings [phone_greeter] ObjectPath=/com/canonical/indicator/network/phone indicator-network-0.5.1+14.04.20140409.1/data/indicator-secret-agent.conf.in0000644000015301777760000000033112321336644026441 0ustar pbusernogroup00000000000000description "Secret agent to repsond to Network Manager password requests" start on starting indicator-network stop on stopping indicator-network respawn exec @CMAKE_INSTALL_FULL_LIBEXECDIR@/indicator-secret-agent indicator-network-0.5.1+14.04.20140409.1/data/indicator-network.conf.in0000644000015301777760000000055712321336655025565 0ustar pbusernogroup00000000000000description "Indicator Network Backend" start on indicator-services-start stop on desktop-end or indicator-services-end env G_MESSAGES_DEBUG=all export G_MESSAGES_DEBUG respawn respawn limit 2 10 pre-start script # NOTE: Only used on Unity8 today, not 7 if [ "x$DESKTOP_SESSION" != "xubuntu-touch" ] ; then stop; exit 0 fi end script exec @NETWORK_SERVICE@ indicator-network-0.5.1+14.04.20140409.1/data/indicator-network.upstart.desktop.in0000644000015301777760000000022012321336655027775 0ustar pbusernogroup00000000000000[Desktop Entry] Type=Application Name=Indicator Network Exec=@NETWORK_SERVICE@ StartupNotify=false Terminal=false Hidden=true OnlyShowIn=Unity; indicator-network-0.5.1+14.04.20140409.1/data/nm-agent-manager.xml0000644000015301777760000000323212321336644024475 0ustar pbusernogroup00000000000000 Called by secret Agents to register their ability to provide and save network secrets. Identifies this agent; only one agent in each user session may use the same identifier. Identifier formatting follows the same rules as D-Bus bus names with the exception that the ':' character is not allowed. The valid set of characters is "[A-Z][a-z][0-9]_-." and the identifier is limited in length to 255 characters with a minimum of 3 characters. An example valid identifier is 'org.gnome.nm-applet' (without quotes). Called by secret Agents to notify NetworkManager that they will no longer handle requests for network secrets. Agents are automatically unregistered when they disconnect from D-Bus. indicator-network-0.5.1+14.04.20140409.1/data/CMakeLists.txt0000644000015301777760000000515312321336655023403 0ustar pbusernogroup00000000000000 ########################### # Indicator-network service ########################### set( INDICATOR_DIR "${CMAKE_INSTALL_DATADIR}/unity/indicators" CACHE FILEPATH "Indicator directory" ) install( FILES "com.canonical.indicator.network" DESTINATION "${INDICATOR_DIR}" ) ########################### # Indicator-network upstart job ########################### set( NETWORK_SERVICE "${CMAKE_INSTALL_FULL_LIBEXECDIR}/indicator-network/indicator-network-service" ) configure_file ( indicator-network.conf.in indicator-network.conf @ONLY ) install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/indicator-network.conf" DESTINATION "${CMAKE_INSTALL_DATADIR}/upstart/sessions/" ) ########################### # Secret agent upstart job ########################### configure_file ( indicator-secret-agent.conf.in indicator-secret-agent.conf @ONLY ) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/indicator-secret-agent.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/share/upstart/sessions ) ########################### # GSettings ########################### add_schema ("com.canonical.indicator.network.gschema.xml") ########################### # XDG Autostart File ########################### # where to install set (XDG_AUTOSTART_DIR "/etc/xdg/autostart") message (STATUS "${XDG_AUTOSTART_DIR} is the DBus Service File install dir") set (XDG_AUTOSTART_NAME "${CMAKE_PROJECT_NAME}.desktop") set (XDG_AUTOSTART_FILE "${CMAKE_CURRENT_BINARY_DIR}/${XDG_AUTOSTART_NAME}") set (XDG_AUTOSTART_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${XDG_AUTOSTART_NAME}.in") # build it set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") configure_file ("${XDG_AUTOSTART_FILE_IN}" "${XDG_AUTOSTART_FILE}") # install it install (FILES "${XDG_AUTOSTART_FILE}" DESTINATION "${XDG_AUTOSTART_DIR}") ########################### # Upstart XDG Autostart Override ########################### # where to install set (UPSTART_XDG_AUTOSTART_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/upstart/xdg/autostart") message (STATUS "${UPSTART_XDG_AUTOSTART_DIR} is the Upstart XDG autostart override dir") set (UPSTART_XDG_AUTOSTART_NAME "${CMAKE_PROJECT_NAME}.upstart.desktop") set (UPSTART_XDG_AUTOSTART_FILE "${CMAKE_CURRENT_BINARY_DIR}/${UPSTART_XDG_AUTOSTART_NAME}") set (UPSTART_XDG_AUTOSTART_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${UPSTART_XDG_AUTOSTART_NAME}.in") # build it set (pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}") configure_file ("${UPSTART_XDG_AUTOSTART_FILE_IN}" "${UPSTART_XDG_AUTOSTART_FILE}") # install it install (FILES "${UPSTART_XDG_AUTOSTART_FILE}" DESTINATION "${UPSTART_XDG_AUTOSTART_DIR}" RENAME "${XDG_AUTOSTART_NAME}") indicator-network-0.5.1+14.04.20140409.1/data/com.canonical.indicator.network.gschema.xml0000644000015301777760000000152112321336644031133 0ustar pbusernogroup00000000000000 true Whether we should show a dialog when a possible Wi-Fi network appears Configures the behavior for discovery of the new networks and whether they result in a dialog being shown which allows for selection of the network. true Whether to join networks we've seen before automatically. This gets set for the Wi-Fi device in Network Manager whether it autoconnects or not. indicator-network-0.5.1+14.04.20140409.1/README.widgets0000644000015301777760000000614712321336644022261 0ustar pbusernogroup00000000000000########################## DBUSMENU WIDGETS PROPERTIES ############################# unity.widgets.systemsettings.*.wifisection ==[$(label)]========$(busy)= [ AP ] [ AP ] [ ... ] Properties: "label" - string - Optional, may have label or not "type" - string = "x-canonical-system-settings" "x-canonical-children-display" - string = "inline" "x-canonical-widget-type" - string = "unity.widgets.systemsettings.tablet.wifisection" "x-canonical-busy-action" - boolean - Shows a spinner indicating activity Actions: $(x-canonical-busy-action): - boolean - Whether the item is busy or not ------------------------------------------------------------------------------------ unity.widgets.systemsettings.*.accesspoint [ *))) AP_SSID # | > ] Properties: "type" - string = "x-canonical-system-settings" "toggle-type" - string = "radio" "x-canonical-widget-type" - string = "unity.widgets.systemsettings.tablet.accesspoint" "x-canonical-wifi-ap-is-adhoc" - bool - Whether it is an adhoc network or not "x-canonical-wifi-ap-is-secure" - bool - Whether the network is open or requires password "x-canonical-wifi-ap-bssid" - string - The internal unique id for the AP "x-canonical-wifi-ap-strength-action" - string - The action string id to gather the strength from "action" - string - The action string id to check whether the AP is active Actions: $(x-canonical-wifi-ap-strength-action): - byte - Signal strength of the access point [0-100] $(action): - bool - Whether the AP is the active one or not ------------------------------------------------------------------------------------ unity.widgets.systemsettings.*.listitem [ *STATUS* connected ] Build properties: "type" - string = "x-canonical-system-settings" "x-canonical-widget-type" - string = "unity.widgets.systemsettings.tablet.listitem" Other properties: "label" - string - The title of the information (ie "Status") "x-canonical-extra-label" - string - The value of the information (ie "Connected") ----------------------------------------------------------------------------------- unity.widgets.systemsettings.*.volumecontrol [ ))) ---------*-------- ] Properties: "type" - string = "x-canonical-system-settings" "x-canonical-widget-type" - string = "unity.widget.systemsettings.tablet.volumecontrol" "action" - string = "volume" The volume value has to be taken off the GAction state "volume" - double [0.0..1.0] ----------------------------------------------------------------------------------- [ *LABEL* ( |#) ] Properties: "type" - string = "x-canonical-system-settings" "x-canonical-widget-type" - string = "unity.widgets.systemsettings.tablet.switch" "action" - string = "mute" "label" - string = The title of the information (ie "Mute") indicator-network-0.5.1+14.04.20140409.1/NEWS0000644000015301777760000000000012321336644020411 0ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/config.h.in0000644000015301777760000000163012321336644021747 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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 . * * Author: Pete Woods */ #ifndef INDICATOR_NETWORK_CONFIG_H_ #define INDICATOR_NETWORK_CONFIG_H_ #define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@" #define GNOMELOCALEDIR "@LOCALE_DIR@" #define LOCALE_DIR "@LOCALE_DIR@" #endif // INDICATOR_NETWORK_CONFIG_H_ indicator-network-0.5.1+14.04.20140409.1/INSTALL0000644000015301777760000000445612321336644020766 0ustar pbusernogroup00000000000000# # Copyright (C) 2013 Canonical Ltd # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License version 3 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # Compile-time build dependencies ------------------------------- - gettext (gettext 0.18.1.1-10ubuntu3 or later) - glib (libglib2.0, 2.35.4 or later) - cmake (cmake, 2.8.9 or later) - gcovr (gcovr, 2.4 or later) - lcov (lcov, 1.9 or later) - google test (libgtest-dev, 1.6.0 or later) - cppcheck (cppcheck) Runtime DBus dependencies ------------------------- - com.canonical.indicators.webcredentials - org.freedesktop.Accounts - org.freedesktop.Accounts.User - org.freedesktop.DisplayManager.Seat - org.freedesktop.login1.Manager - org.freedesktop.login1.Seat - org.freedesktop.login1.User - org.gnome.ScreenSaver - org.gnome.SessionManager - org.gnome.SessionManager.EndSessionDialog Building the code ----------------- The simplest case is: $ cd indicator-session-X.Y.Z $ mkdir build $ cd build $ cmake .. $ make Running the tests ----------------- $ cd indicator-session-X.Y.Z $ mkdir build $ cd build $ cmake .. $ make $ make test $ make cppcheck Generating Test Coverage Reports -------------------------------- $ cd indicator-session-X.Y.Z $ mkdir build-coverage $ cd build-coverage $ cmake -DCMAKE_BUILD_TYPE=coverage .. $ make $ make coverage-html Installation ------------ what gets installed LC_ALL=C /usr/bin/intltool-merge -x -u --no-translations com.canonical.indicator.session.gschema.xml.in com.canonical.indicator.session.gschema.xml FIXME: not tested To get files that form part of an installation, run a "make install" in the build directory. By default, this installs them in the "install" subdirectory of the build directory. If you want to install into a different directory, use $ cmake -DCMAKE_INSTALL_PREFIX=/usr/local # Or wherever... $ make release $ make install indicator-network-0.5.1+14.04.20140409.1/po/0000755000015301777760000000000012321337176020343 5ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/po/POTFILES.skip0000644000015301777760000000042112321336644022454 0ustar pbusernogroup00000000000000network/device-wifi.c network/device-base.c network/network-menu-service.c network/device-ethernet.c network/network-action-manager.c network/network-menu.c network/device-mobile.c network/ofono.c network/settings-base.c network/settings-airplane.c network/settings-wifi.c indicator-network-0.5.1+14.04.20140409.1/po/POTFILES.in0000644000015301777760000000046212321336644022121 0ustar pbusernogroup00000000000000network/device-wifi.vala network/device-base.vala network/network-menu-service.vala network/device-ethernet.vala network/network-action-manager.vala network/network-menu.vala network/device-mobile.vala network/ofono.vala network/settings-base.vala network/settings-airplane.vala network/settings-wifi.vala indicator-network-0.5.1+14.04.20140409.1/ChangeLog0000644000015301777760000000000012321336644021464 0ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/CMakeLists.txt0000644000015301777760000000511612321336644022467 0ustar pbusernogroup00000000000000project(indicator-network C CXX) cmake_minimum_required(VERSION 2.8.9) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}") set(PACKAGE ${CMAKE_PROJECT_NAME}) set(GETTEXT_PACKAGE indicator-network) set(LOCALE_DIR "${CMAKE_INSTALL_FULL_DATADIR}/locale") add_definitions( -DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}" ) find_package(PkgConfig REQUIRED) include(GNUInstallDirs) include(Coverage) include(UseVala) include(UseGSettings) # Workaround for libexecdir on debian if (EXISTS "/etc/debian_version") set(CMAKE_INSTALL_LIBEXECDIR ${CMAKE_INSTALL_LIBDIR}) set(CMAKE_INSTALL_FULL_LIBEXECDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBEXECDIR}") endif() set(DATA_DIR "${CMAKE_SOURCE_DIR}/data") set(GLIB_REQUIRED_VERSION 2.26) pkg_check_modules( GLIB REQUIRED glib-2.0>=${GLIB_REQUIRED_VERSION} gio-2.0>=${GLIB_REQUIRED_VERSION} url-dispatcher-1 ) include_directories(${GLIB_INCLUDE_DIRS}) set(NM_REQUIRED_VERSION 0.9) pkg_check_modules( NM REQUIRED libnm-glib>=${NM_REQUIRED_VERSION} libnm-util>=${NM_REQUIRED_VERSION} ) include_directories(${NM_INCLUDE_DIRS}) set(NOTIFY_REQUIRED_VERSION 0.7.5) pkg_check_modules( NOTIFY REQUIRED libnotify>=${NOTIFY_REQUIRED_VERSION} ) include_directories(${NOTIFY_INCLUDE_DIRS}) find_package(Qt5Core REQUIRED) include_directories(${Qt5Core_INCLUDE_DIRS}) find_package(Qt5DBus COMPONENTS Qt5DBusMacros REQUIRED) include_directories(${Qt5DBus_INCLUDE_DIRS}) find_package(Qt5Test REQUIRED) include_directories(${Qt5Test_INCLUDE_DIRS}) pkg_check_modules(NM REQUIRED NetworkManager REQUIRED) include_directories(${NM_INCLUDE_DIRS}) pkg_check_modules(QTDBUSTEST REQUIRED libqtdbustest-1 REQUIRED) include_directories(${QTDBUSTEST_INCLUDE_DIRS}) pkg_check_modules(QTDBUSMOCK REQUIRED libqtdbusmock-1 REQUIRED) include_directories(${QTDBUSMOCK_INCLUDE_DIRS}) pkg_check_modules(QMENUMODEL REQUIRED qmenumodel REQUIRED) include_directories(${QMENUMODEL_INCLUDE_DIRS}) pkg_check_modules(GIO REQUIRED gio-2.0>=${GLIB_REQUIRED_VERSION}) include_directories(${GIO_INCLUDE_DIRS}) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) find_package(Vala 0.22) find_package(GObjectIntrospection 0.9.12) include_directories(${CMAKE_BINARY_DIR}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") add_definitions( -Wall ) configure_file( "config.h.in" "config.h" ) add_subdirectory(data) add_subdirectory(network) add_subdirectory(secret-agent) enable_testing() add_subdirectory(tests) ADD_CUSTOM_TARGET( check ${CMAKE_CTEST_COMMAND} --force-new-ctest-process --output-on-failure ) indicator-network-0.5.1+14.04.20140409.1/MERGE-REVIEW0000644000015301777760000000141612321336644021507 0ustar pbusernogroup00000000000000 This documents the expections that the project has on what both submitters and reviewers should ensure that they've done for a merge into the project. == Submitter Responsibilities == * Ensure the project compiles and the test suite executes without error * Ensure that non-obvious code has comments explaining it * If the change works on specific profiles, please include those in the merge description. == Reviewer Responsibilities == * Did the Jenkins build compile? Pass? Run unit tests successfully? * Are there appropriate tests to cover any new functionality? * If the description says this effects the phone profile: * Run tests indicator-network/unity8* * If the description says this effects the desktop profile: * Run tests indicator-network/unity7* indicator-network-0.5.1+14.04.20140409.1/COPYING0000644000015301777760000010451412321336644020764 0ustar pbusernogroup00000000000000 GNU 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. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . indicator-network-0.5.1+14.04.20140409.1/AUTHORS0000644000015301777760000000000012321336644020762 0ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/network/0000755000015301777760000000000012321337176021416 5ustar pbusernogroup00000000000000indicator-network-0.5.1+14.04.20140409.1/network/utils.vala0000644000015301777760000000075612321336644023432 0ustar pbusernogroup00000000000000using GLib; namespace Utils { public bool variant_contains (Variant variant, string needle) { if (variant.is_of_type(VariantType.VARIANT)) return variant_contains(variant.get_variant(), needle); if (!variant.is_container()) return false; Variant item; var iter = new VariantIter(variant); for (item = iter.next_value(); item != null; item = iter.next_value()) { if (item.get_string() == needle) return true; } return false; } } indicator-network-0.5.1+14.04.20140409.1/network/action-muxer.vapi0000644000015301777760000000056412321336644024716 0ustar pbusernogroup00000000000000[CCode (cprefix = "G", lower_case_cprefix = "g_")] namespace GLibLocal { [CCode (cheader_filename = "action-muxer.h", type_id = "G_TYPE_ACTION_MUXER")] public class ActionMuxer : GLib.Object { public ActionMuxer (); public void insert (string prefix, GLib.ActionGroup group); public void remove (string prefix); public GLib.ActionGroup get (string prefix); } } indicator-network-0.5.1+14.04.20140409.1/network/settings-airplane.vala0000644000015301777760000000302712321336644025715 0ustar pbusernogroup00000000000000// vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 /* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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: * Ted Gould */ namespace Network.Settings { public class Airplane : Base { public Airplane (GLibLocal.ActionMuxer muxer) { GLib.Object( namespace: "airplane", muxer: muxer ); var enabled = new SimpleAction.stateful("enabled", null, new Variant.boolean(false)); enabled.activate.connect((value) => { try { GLib.Process.spawn_command_line_async("notify-send \"Airplane Mode does not have backend support currently. Please turn off the radios individually.\""); } catch (Error e) { warning(@"Unable to send notification: $(e.message)"); } }); actions.add_action(enabled); var item = new MenuItem(_("Flight Mode"), "indicator.airplane.enabled"); item.set_attribute("x-canonical-type", "s", "com.canonical.indicator.switch"); _menu.append_item(item); } } } indicator-network-0.5.1+14.04.20140409.1/network/config.vapi0000644000015301777760000000044112321336644023542 0ustar pbusernogroup00000000000000[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "../config.h")] namespace Config { public const string GETTEXT_PACKAGE; public const string GNOMELOCALEDIR; public const string PKGDATADIR; public const string PACKAGE_NAME; public const string PACKAGE_VERSION; } indicator-network-0.5.1+14.04.20140409.1/network/action-muxer.h0000644000015301777760000000323212321336644024201 0ustar pbusernogroup00000000000000/* * Copyright 2012 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Authors: * Lars Uebernickel * Ryan Lortie */ #ifndef __G_ACTION_MUXER_H__ #define __G_ACTION_MUXER_H__ #include #define G_TYPE_ACTION_MUXER (g_action_muxer_get_type ()) #define G_ACTION_MUXER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_ACTION_MUXER, GActionMuxer)) #define G_IS_ACTION_MUXER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_ACTION_MUXER)) typedef struct _GActionMuxer GActionMuxer; GType g_action_muxer_get_type (void) G_GNUC_CONST; GActionMuxer * g_action_muxer_new (void); void g_action_muxer_insert (GActionMuxer *muxer, const gchar *prefix, GActionGroup *group); void g_action_muxer_remove (GActionMuxer *muxer, const gchar *prefix); GActionGroup * g_action_muxer_get (GActionMuxer *muxer, const gchar *prefix); #endif indicator-network-0.5.1+14.04.20140409.1/network/util-wrapper.h0000644000015301777760000000137112321336644024223 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Authors: * Ted Gould */ gboolean util_wrapper_is_empty_ssid (GByteArray * bytes); indicator-network-0.5.1+14.04.20140409.1/network/network-menu.vala0000644000015301777760000002012412321336644024714 0ustar pbusernogroup00000000000000// vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 /* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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: * Alberto Ruiz */ using NM; namespace Network { private const string APPLICATION_ID = "com.canonical.indicator.network"; private const string PHONE_MENU_PATH = "/com/canonical/indicator/network/phone"; private const string PHONE_WIFI_SETTINGS_MENU_PATH = "/com/canonical/indicator/network/phone_wifi_settings"; private const string DESKTOP_MENU_PATH = "/com/canonical/indicator/network/desktop"; private const string ACTION_GROUP_PATH = "/com/canonical/indicator/network"; internal class ProfileMenu { public Menu root_menu = new Menu(); public MenuItem root_item; public Menu shown_menu = new Menu(); private MenuModel? pre_settings = null; private MenuModel? post_settings = null; private GLib.DBusConnection conn; private uint export_id; public ProfileMenu (GLib.DBusConnection conn, string path, bool has_root) throws GLib.Error { Menu exported_menu; if (has_root) { root_item = new MenuItem.submenu (null, shown_menu as MenuModel); root_item.set_attribute (GLib.Menu.ATTRIBUTE_ACTION, "s", "indicator.global.network-status"); root_item.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root"); root_menu.append_item (root_item); exported_menu = root_menu; } else { exported_menu = shown_menu; } export_id = conn.export_menu_model (path, exported_menu); } ~ProfileMenu () { conn.unexport_menu_model(export_id); } public void remove_device (string path) { for (int i = 0; i < (shown_menu as MenuModel).get_n_items(); i++) { var dev = (shown_menu as MenuModel).get_item_link(i, Menu.LINK_SECTION) as Device.Base; if (dev == null) { continue; } if (dev.device.get_path() == path) { shown_menu.remove(i); break; } } } public Device.Base? find_device (string path) { Device.Base? founddev = null; for (int i = 0; i < (shown_menu as MenuModel).get_n_items(); i++) { var dev = (shown_menu as MenuModel).get_item_link(i, Menu.LINK_SECTION) as Device.Base; if (dev == null) { continue; } if (dev.device.get_path() == path) { founddev = dev; break; } } return founddev; } /* Return a sorting value based on the type of networking that is in the current menu */ private uint dev2sort (Device.Base dev) { if ((dev as Device.Ethernet) != null) { return 0; } if ((dev as Device.Wifi) != null) { return 1; } if ((dev as Device.Mobile) != null) { return 2; } return 3; } /* Figures out where the device needs to go and inserts it in the proper location */ public void append_device (Device.Base device) { /* Handle the empty case right away, no reason to mess up code later on */ if (shown_menu.get_n_items() == 0) { shown_menu.append_section(null, device); return; } int i; uint insort = dev2sort(device); for (i = (pre_settings == null ? 0 : 1); i < shown_menu.get_n_items(); i++) { var imenu = shown_menu.get_item_link(i, Menu.LINK_SECTION) as Device.Base; if (imenu == null) { continue; } var isort = dev2sort(imenu); if (isort > insort) { shown_menu.insert_section(i, null, device); break; } } if (i == shown_menu.get_n_items()) { if (post_settings == null) { shown_menu.append_section(null, device); } else { shown_menu.insert_section(shown_menu.get_n_items() - 1, null, device); } } } /* A settings section to put before all the devices */ public void set_pre_settings (MenuModel settings) { if (pre_settings != null) { warning("Already have a pre-setting menus, can't have two!"); return; } pre_settings = settings; shown_menu.insert_section(0, null, settings); } /* A settings section to put after all the devices */ public void set_post_settings (MenuModel settings) { if (post_settings != null) { warning("Already have a post-setting menus, can't have two!"); return; } post_settings = settings; shown_menu.append_section(null, settings); } } public class NetworkMenu : GLib.Object { private ProfileMenu desktop; private ProfileMenu phone; private ProfileMenu phone_wifi_settings; private NM.Client client; private ActionManager am; private GLibLocal.ActionMuxer muxer = new GLibLocal.ActionMuxer(); private GLib.DBusConnection conn; public NetworkMenu () { client = new NM.Client(); am = new ActionManager (muxer, client); client.device_added.connect ((client, device) => { add_device (device); }); client.device_removed.connect ((client, device) => { remove_device (device); }); try { conn = Bus.get_sync (BusType.SESSION, null); conn.export_action_group (ACTION_GROUP_PATH, muxer as ActionGroup); desktop = new ProfileMenu(conn, DESKTOP_MENU_PATH, true); phone = new ProfileMenu(conn, PHONE_MENU_PATH, true); phone_wifi_settings = new ProfileMenu(conn, PHONE_WIFI_SETTINGS_MENU_PATH, false); Bus.own_name_on_connection(conn, APPLICATION_ID, BusNameOwnerFlags.NONE, null, ((conn, name) => { error("Unable to get D-Bus bus name"); })); } catch (GLib.IOError e) { return; } catch (GLib.Error e) { return; } /* Put an airplane mode setting at the top of the desktop and phone menus */ /* Airplane mode is disabled for Phone 1.0 as there's no backend. commenting out to be reenabled after 1.0 ships */ if (false) { var airplane = new Network.Settings.Airplane(muxer); desktop.set_pre_settings(airplane); phone.set_pre_settings(airplane); } /* Add some items at the end of the settings menu */ var wifisettings = new Network.Settings.Wifi(muxer); phone_wifi_settings.set_post_settings(wifisettings); var devices = client.get_devices (); if (devices == null) return; for (uint i = 0; i < devices.length; i++) { add_device (devices.get (i)); } } private void add_device (NM.Device device) { Device.Base? founddev = null; founddev = desktop.find_device(device.get_path()); if (founddev != null) return; founddev = phone.find_device(device.get_path()); if (founddev != null) return; debug("Adding device: " + device.get_iface()); switch (device.get_device_type ()) { case NM.DeviceType.WIFI: var wifidev = new Device.Wifi(this.client, device as NM.DeviceWifi, this.muxer, true); desktop.append_device(wifidev); phone.append_device(wifidev); var wifisettingsdev = new Device.Wifi(this.client, device as NM.DeviceWifi, this.muxer, false); phone_wifi_settings.append_device(wifisettingsdev); break; case NM.DeviceType.MODEM: var mobiledesktopdev = new Device.Mobile(this.client, device as NM.DeviceModem, this.muxer, true, conn); desktop.append_device(mobiledesktopdev); var mobilephonedev = new Device.Mobile(this.client, device as NM.DeviceModem, this.muxer, false, conn); phone.append_device(mobilephonedev); break; case NM.DeviceType.ETHERNET: var ethdev = new Device.Ethernet(this.client, device as NM.DeviceEthernet, this.muxer); desktop.append_device(ethdev); phone.append_device(ethdev); break; default: warning("Unsupported device type: " + device.get_iface()); break; } } private void remove_device (NM.Device device) { debug("Removing device: " + device.get_iface()); desktop.remove_device(device.get_path()); phone.remove_device(device.get_path()); } } } indicator-network-0.5.1+14.04.20140409.1/network/action-muxer.c0000644000015301777760000004051012321336644024174 0ustar pbusernogroup00000000000000/* * Copyright 2012 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Authors: * Lars Uebernickel * Ryan Lortie */ #include "action-muxer.h" #include /* * SECTION:gactionmuxer * @short_description: Aggregate several action groups * * #GActionMuxer is a #GActionGroup that is capable of containing other * #GActionGroup instances. * * The typical use is aggregating all of the actions applicable to a * particular context into a single action group, with namespacing. * * Consider the case of two action groups -- one containing actions * applicable to an entire application (such as 'quit') and one * containing actions applicable to a particular window in the * application (such as 'fullscreen'). * * In this case, each of these action groups could be added to a * #GActionMuxer with the prefixes "app" and "win", respectively. This * would expose the actions as "app.quit" and "win.fullscreen" on the * #GActionGroup interface presented by the #GActionMuxer. * * Activations and state change requests on the #GActionMuxer are wired * through to the underlying action group in the expected way. */ typedef GObjectClass GActionMuxerClass; struct _GActionMuxer { GObject parent; GActionGroup *global_actions; GHashTable *groups; /* prefix -> subgroup */ GHashTable *reverse; /* subgroup -> prefix */ }; static void g_action_muxer_group_init (GActionGroupInterface *iface); static void g_action_muxer_dispose (GObject *object); static void g_action_muxer_finalize (GObject *object); static void g_action_muxer_disconnect_group (GActionMuxer *muxer, GActionGroup *subgroup); static gchar ** g_action_muxer_list_actions (GActionGroup *group); static void g_action_muxer_activate_action (GActionGroup *group, const gchar *action_name, GVariant *parameter); static void g_action_muxer_change_action_state (GActionGroup *group, const gchar *action_name, GVariant *value); static gboolean g_action_muxer_query_action (GActionGroup *group, const gchar *action_name, gboolean *enabled, const GVariantType **parameter_type, const GVariantType **state_type, GVariant **state_hint, GVariant **state); static void g_action_muxer_action_added (GActionGroup *group, gchar *action_name, gpointer user_data); static void g_action_muxer_action_removed (GActionGroup *group, gchar *action_name, gpointer user_data); static void g_action_muxer_action_state_changed (GActionGroup *group, gchar *action_name, GVariant *value, gpointer user_data); static void g_action_muxer_action_enabled_changed (GActionGroup *group, gchar *action_name, gboolean enabled, gpointer user_data); G_DEFINE_TYPE_WITH_CODE (GActionMuxer, g_action_muxer, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP, g_action_muxer_group_init)); static void g_action_muxer_class_init (GObjectClass *klass) { klass->dispose = g_action_muxer_dispose; klass->finalize = g_action_muxer_finalize; } static void g_action_muxer_init (GActionMuxer *muxer) { muxer->global_actions = NULL; muxer->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); muxer->reverse = g_hash_table_new (g_direct_hash, g_direct_equal); } static void g_action_muxer_group_init (GActionGroupInterface *iface) { iface->list_actions = g_action_muxer_list_actions; iface->activate_action = g_action_muxer_activate_action; iface->change_action_state = g_action_muxer_change_action_state; iface->query_action = g_action_muxer_query_action; } static void g_action_muxer_dispose (GObject *object) { GActionMuxer *muxer = G_ACTION_MUXER (object); GHashTableIter it; GActionGroup *subgroup; if (muxer->global_actions) { g_action_muxer_disconnect_group (muxer, muxer->global_actions); g_clear_object (&muxer->global_actions); } g_hash_table_iter_init (&it, muxer->groups); while (g_hash_table_iter_next (&it, NULL, (gpointer *) &subgroup)) g_action_muxer_disconnect_group (muxer, subgroup); g_hash_table_remove_all (muxer->groups); g_hash_table_remove_all (muxer->reverse); } static void g_action_muxer_finalize (GObject *object) { GActionMuxer *muxer = G_ACTION_MUXER (object); g_hash_table_unref (muxer->groups); g_hash_table_unref (muxer->reverse); G_OBJECT_CLASS (g_action_muxer_parent_class)->finalize (object); } static GActionGroup * g_action_muxer_lookup_group (GActionMuxer *muxer, const gchar *full_name, const gchar **action_name) { const gchar *sep; GActionGroup *group; sep = strchr (full_name, '.'); if (sep) { gchar *prefix; prefix = g_strndup (full_name, sep - full_name); group = g_hash_table_lookup (muxer->groups, prefix); g_free (prefix); if (action_name) *action_name = sep + 1; } else { group = muxer->global_actions; if (action_name) *action_name = full_name; } return group; } static gchar * g_action_muxer_lookup_full_name (GActionMuxer *muxer, GActionGroup *subgroup, const gchar *action_name) { gpointer prefix; if (subgroup == muxer->global_actions) return g_strdup (action_name); if (g_hash_table_lookup_extended (muxer->reverse, subgroup, NULL, &prefix)) return g_strdup_printf ("%s.%s", (gchar *) prefix, action_name); return NULL; } static void g_action_muxer_disconnect_group (GActionMuxer *muxer, GActionGroup *subgroup) { gchar **actions; gchar **action; actions = g_action_group_list_actions (subgroup); for (action = actions; *action; action++) g_action_muxer_action_removed (subgroup, *action, muxer); g_strfreev (actions); g_signal_handlers_disconnect_by_func (subgroup, g_action_muxer_action_added, muxer); g_signal_handlers_disconnect_by_func (subgroup, g_action_muxer_action_removed, muxer); g_signal_handlers_disconnect_by_func (subgroup, g_action_muxer_action_enabled_changed, muxer); g_signal_handlers_disconnect_by_func (subgroup, g_action_muxer_action_state_changed, muxer); } static gchar ** g_action_muxer_list_actions (GActionGroup *group) { GActionMuxer *muxer = G_ACTION_MUXER (group); GHashTableIter it; GArray *all_actions; gchar *prefix; GActionGroup *subgroup; gchar **actions; gchar **a; all_actions = g_array_sized_new (TRUE, FALSE, sizeof (gchar *), 8); if (muxer->global_actions) { actions = g_action_group_list_actions (muxer->global_actions); for (a = actions; *a; a++) { gchar *name = g_strdup (*a); g_array_append_val (all_actions, name); } g_strfreev (actions); } g_hash_table_iter_init (&it, muxer->groups); while (g_hash_table_iter_next (&it, (gpointer *) &prefix, (gpointer *) &subgroup)) { actions = g_action_group_list_actions (subgroup); for (a = actions; *a; a++) { gchar *full_name = g_strdup_printf ("%s.%s", prefix, *a); g_array_append_val (all_actions, full_name); } g_strfreev (actions); } return (gchar **) g_array_free (all_actions, FALSE); } static void g_action_muxer_activate_action (GActionGroup *group, const gchar *action_name, GVariant *parameter) { GActionMuxer *muxer = G_ACTION_MUXER (group); GActionGroup *subgroup; const gchar *action; g_return_if_fail (action_name != NULL); subgroup = g_action_muxer_lookup_group (muxer, action_name, &action); if (subgroup) g_action_group_activate_action (subgroup, action, parameter); } static void g_action_muxer_change_action_state (GActionGroup *group, const gchar *action_name, GVariant *value) { GActionMuxer *muxer = G_ACTION_MUXER (group); GActionGroup *subgroup; const gchar *action; g_return_if_fail (action_name != NULL); subgroup = g_action_muxer_lookup_group (muxer, action_name, &action); if (subgroup) g_action_group_change_action_state (subgroup, action, value); } static gboolean g_action_muxer_query_action (GActionGroup *group, const gchar *action_name, gboolean *enabled, const GVariantType **parameter_type, const GVariantType **state_type, GVariant **state_hint, GVariant **state) { GActionMuxer *muxer = G_ACTION_MUXER (group); GActionGroup *subgroup; const gchar *action; g_return_val_if_fail (action_name != NULL, FALSE); subgroup = g_action_muxer_lookup_group (muxer, action_name, &action); if (!subgroup) return FALSE; return g_action_group_query_action (subgroup, action, enabled, parameter_type, state_type, state_hint, state); } static void g_action_muxer_action_added (GActionGroup *group, gchar *action_name, gpointer user_data) { GActionMuxer *muxer = user_data; gchar *full_name; full_name = g_action_muxer_lookup_full_name (muxer, group, action_name); if (full_name) { g_action_group_action_added (G_ACTION_GROUP (muxer), full_name); g_free (full_name); } } static void g_action_muxer_action_removed (GActionGroup *group, gchar *action_name, gpointer user_data) { GActionMuxer *muxer = user_data; gchar *full_name; full_name = g_action_muxer_lookup_full_name (muxer, group, action_name); if (full_name) { g_action_group_action_removed (G_ACTION_GROUP (muxer), full_name); g_free (full_name); } } static void g_action_muxer_action_state_changed (GActionGroup *group, gchar *action_name, GVariant *value, gpointer user_data) { GActionMuxer *muxer = user_data; gchar *full_name; full_name = g_action_muxer_lookup_full_name (muxer, group, action_name); if (full_name) { g_action_group_action_state_changed (G_ACTION_GROUP (muxer), full_name, value); g_free (full_name); } } static void g_action_muxer_action_enabled_changed (GActionGroup *group, gchar *action_name, gboolean enabled, gpointer user_data) { GActionMuxer *muxer = user_data; gchar *full_name; full_name = g_action_muxer_lookup_full_name (muxer, group, action_name); if (full_name) { g_action_group_action_enabled_changed (G_ACTION_GROUP (muxer), full_name, enabled); g_free (full_name); } } /* * g_action_muxer_new: * * Creates a new #GActionMuxer. */ GActionMuxer * g_action_muxer_new (void) { return g_object_new (G_TYPE_ACTION_MUXER, NULL); } /* * g_action_muxer_insert: * @muxer: a #GActionMuxer * @prefix: (allow-none): the prefix string for the action group, or NULL * @group: (allow-none): a #GActionGroup, or NULL * * Adds the actions in @group to the list of actions provided by @muxer. * @prefix is prefixed to each action name, such that for each action * x in @group, there is an equivalent action * @prefix.x in @muxer. * * For example, if @prefix is "app" and @group contains an * action called "quit", then @muxer will now contain an * action called "app.quit". * * If @prefix is NULL, the actions in @group will be added * to @muxer without prefix. * * If @group is NULL, this function has the same effect as * calling g_action_muxer_remove() with @prefix. * * There may only be one group per prefix (including the * NULL-prefix). If a group has been added with @prefix in * a previous call to this function, it will be removed. * * @prefix must not contain a dot ('.'). */ void g_action_muxer_insert (GActionMuxer *muxer, const gchar *prefix, GActionGroup *group) { gchar *prefix_copy; gchar **actions; gchar **action; g_return_if_fail (G_IS_ACTION_MUXER (muxer)); g_return_if_fail (G_IS_ACTION_GROUP (group)); g_action_muxer_remove (muxer, prefix); if (prefix) { prefix_copy = g_strdup (prefix); g_hash_table_insert (muxer->groups, prefix_copy, g_object_ref (group)); g_hash_table_insert (muxer->reverse, group, prefix_copy); } else muxer->global_actions = g_object_ref (group); actions = g_action_group_list_actions (group); for (action = actions; *action; action++) g_action_muxer_action_added (group, *action, muxer); g_strfreev (actions); g_signal_connect (group, "action-added", G_CALLBACK (g_action_muxer_action_added), muxer); g_signal_connect (group, "action-removed", G_CALLBACK (g_action_muxer_action_removed), muxer); g_signal_connect (group, "action-enabled-changed", G_CALLBACK (g_action_muxer_action_enabled_changed), muxer); g_signal_connect (group, "action-state-changed", G_CALLBACK (g_action_muxer_action_state_changed), muxer); } /* * g_action_muxer_remove: * @muxer: a #GActionMuxer * @prefix: (allow-none): the prefix of the action group to remove, or NULL * * Removes a #GActionGroup from the #GActionMuxer. */ void g_action_muxer_remove (GActionMuxer *muxer, const gchar *prefix) { GActionGroup *subgroup; g_return_if_fail (G_IS_ACTION_MUXER (muxer)); subgroup = prefix ? g_hash_table_lookup (muxer->groups, prefix) : muxer->global_actions; if (!subgroup) return; g_action_muxer_disconnect_group (muxer, subgroup); if (prefix) { g_hash_table_remove (muxer->groups, prefix); g_hash_table_remove (muxer->reverse, subgroup); } else g_clear_object (&muxer->global_actions); } /* * g_action_muxer_get: * @muxer: a #GActionMuxer * @prefix: (allow-none): the prefix of the action group to get, or NULL * * Looks for an action group and returns it if found * * Return value: (transfer none): Action group that matches @prefix */ GActionGroup * g_action_muxer_get (GActionMuxer * muxer, const gchar * prefix) { g_return_val_if_fail (G_IS_ACTION_MUXER (muxer), NULL); return prefix ? g_hash_table_lookup (muxer->groups, prefix) : muxer->global_actions; } indicator-network-0.5.1+14.04.20140409.1/network/device-wifi.vala0000644000015301777760000004051512321336644024462 0ustar pbusernogroup00000000000000// vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 /* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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: * Ted Gould */ using NM; namespace Network.Device { internal class WifiMenu { private Menu apsmenu; private MenuItem device_item; private MenuItem settings_item; public DeviceWifi device; private NM.Client client; private string action_prefix; private bool show_settings; private HashTable aps = new HashTable(str_hash, str_equal); public WifiMenu (NM.Client client, DeviceWifi device, Menu global_menu, string action_prefix, bool show_settings) { this.apsmenu = global_menu; this.device = device; this.client = client; this.action_prefix = action_prefix; this.show_settings = show_settings; device_item = create_item_for_wifi_device (); this.apsmenu.append_item(device_item); if (show_settings) { settings_item = new MenuItem(_("Wi-Fi settings…"), "indicator.global.settings::wifi"); this.apsmenu.append_item(settings_item); } device.access_point_added.connect (access_point_added_cb); device.access_point_removed.connect (access_point_removed_cb); device.notify.connect (active_access_point_changed); var aps = device.get_access_points (); if (aps == null) return; for (uint i = 0; i? dev_conns = null; bool has_connection = false; string label; if (ap == null) return; if (UtilWrapper.is_empty_ssid(ap.get_ssid ())) return; label = Utils.ssid_to_utf8(ap.get_ssid ()); if (label == null || label[0] == '\0') return; //If it is the active access point it always goes first if (ap == device.active_access_point) { var item = new MenuItem (null, null); bind_ap_item (ap, item); apsmenu.insert_item (1, item); //TODO: Remove duplicates??? return; } var conns = rs.list_connections (); if (conns.length () > 0) { dev_conns = device.filter_connections (conns); if (dev_conns.length () > 0) has_connection = ap_has_connections (ap, dev_conns); } //Remove duplicate SSID for (int i = 0; i < apsmenu.get_n_items(); i++) { string path; if (!apsmenu.get_item_attribute (i, "x-canonical-wifi-ap-dbus-path", "s", out path)) continue; var i_ap = device.get_access_point_by_path (path); if (i_ap == null) continue; //If both have the same SSID and security flags they are a duplicate if (Utils.same_ssid (i_ap.get_ssid (), ap.get_ssid (), false) && i_ap.get_flags () == ap.get_flags ()) { //The one AP with the srongest signal wins if (i_ap.get_strength () >= ap.get_strength ()) return; apsmenu.remove (i); continue; } } //Find the right spot for the AP var item = new MenuItem (null, null); bind_ap_item (ap, item); for (int i = 0; i < apsmenu.get_n_items(); i++) { string path; if (!apsmenu.get_item_attribute (i, "x-canonical-wifi-ap-dbus-path", "s", out path)) continue; var i_ap = device.get_access_point_by_path (path); if (i_ap == null) continue; //APs that have been used previously have priority if (ap_has_connections(i_ap, dev_conns)) { if (!has_connection) continue; } //APs with higher strenght have priority if (ap.get_strength () > i_ap.get_strength ()) { apsmenu.insert_item (i, item); return; } } //AP is last in the menu (avoid the settings item) if (show_settings) { apsmenu.insert_item (apsmenu.get_n_items() - 1, item); } else { apsmenu.append_item (item); } } private void set_active_ap (AccessPoint? ap) { //TODO: Set the previously active AP in the right order if (ap == null) return; for (int i = 1; i < apsmenu.get_n_items(); i++) { string path; if (!apsmenu.get_item_attribute (i, "action", "s", out path)) continue; if (path != ap.get_path ()) continue; apsmenu.remove (i); var item = new MenuItem (null, null); bind_ap_item (ap, item); apsmenu.append_item (item); } } private static bool ap_has_connections (AccessPoint ap, SList? dev_conns) { if (dev_conns.length () < 1) return false; var ap_conns = ap.filter_connections (dev_conns); return ap_conns.length () > 0; } private void remove_ap_item (AccessPoint ap) { for (int i = 1; i < apsmenu.get_n_items(); i++) { string path; if (!apsmenu.get_item_attribute (i, "x-canonical-wifi-ap-dbus-path", "s", out path)) continue; if (path == ap.get_path ()) { apsmenu.remove (i); return; } } } } internal class WifiActionManager { private SimpleActionGroup actions; private NM.Client client; public NM.RemoteSettings rs = null; public NM.DeviceWifi wifidev = null; public WifiActionManager (SimpleActionGroup actions, NM.Client client, NM.DeviceWifi dev) { this.client = client; this.actions = actions; this.wifidev = dev; this.rs = new NM.RemoteSettings (null); /* This object should be disposed by ActionManager on device removal * but we still disconnect signals if that signal is emmited before * this object was disposed */ client.device_removed.connect (remove_device); wifidev.access_point_added.connect (access_point_added_cb); wifidev.access_point_removed.connect (access_point_removed_cb); wifidev.notify["active-access-point"].connect (active_access_point_changed); wifidev.state_changed.connect (device_state_changed_cb); var aps = wifidev.get_access_points (); if (aps != null) for (int i = 0; i < aps.length; i++) insert_ap (aps.get(i)); } ~WifiActionManager () { remove_device (client, wifidev); client.device_removed.disconnect (remove_device); } private void remove_device (NM.Client client, NM.Device device) { wifidev.access_point_added.disconnect (access_point_added_cb); wifidev.access_point_removed.disconnect (access_point_removed_cb); wifidev.notify["active-access-point"].disconnect (active_access_point_changed); wifidev.state_changed.disconnect (device_state_changed_cb); } private void device_state_changed_cb (NM.Device device, uint new_state, uint old_state, uint reason) { if (new_state != DeviceState.DISCONNECTED) return; var wifidev = (NM.DeviceWifi)device; var aps = wifidev.get_access_points (); if (aps == null) return; for (uint i = 0; i < aps.length; i++) { var ap = aps.get(i); var action = actions.lookup(ap.get_path()); if (action != null) { action.change_state(new Variant.boolean (false)); } } } private void access_point_added_cb (NM.DeviceWifi device, GLib.Object ap) { insert_ap ((AccessPoint)ap); } private void access_point_removed_cb (NM.DeviceWifi device, GLib.Object ap) { remove_ap ((AccessPoint)ap); } private void active_access_point_changed (GLib.Object obj, ParamSpec pspec) { string? active_ap = null; var aps = wifidev.get_access_points (); if (aps == null) return; if (wifidev.active_access_point != null) active_ap = wifidev.active_access_point.get_path (); for (uint i = 0; i < aps.length; i++) { var ap = aps.get(i); if (ap == null) continue; if (actions.lookup (ap.get_path ()) == null) { insert_ap (ap); continue; } var action = actions.lookup(ap.get_path()); if (action == null) continue; action.change_state(new Variant.boolean (ap.get_path() == active_ap)); } } private void insert_ap (NM.AccessPoint ap) { if (ap == null) return; bool is_active = false; /* If the ap is already included we skip this callback */ if (actions.lookup (ap.get_path ()) != null) return; GLib.debug("Adding new access point: " + ap.get_bssid() + " at " + ap.get_path()); //TODO: Add actions for each AP NM connection var strength_action_id = ap.get_path () + "::strength"; ap.notify.connect (ap_strength_changed); if (wifidev.active_access_point != null) is_active = ap.get_path () == wifidev.active_access_point.get_path (); var strength = new SimpleAction.stateful (strength_action_id, null, new Variant.byte (ap.get_strength ())); var activate = new SimpleAction.stateful (ap.get_path (), null, new Variant.boolean (is_active)); activate.activate.connect (ap_activated); actions.insert (strength); actions.insert (activate); } private void remove_ap (NM.AccessPoint ap) { GLib.debug("Removing access point: " + ap.get_bssid() + " at " + ap.get_path()); //TODO: Check if AP has connection action actions.remove (ap.get_path ()); actions.remove (ap.get_path () + "::strength"); } private void ap_activated (SimpleAction ac, Variant? val) { /* If we're the selected access point, and we get clicked, then the user is trying to disconnect from that AP */ if (ac.state.get_boolean () == true && wifidev.active_access_point != null && wifidev.active_access_point.get_path () == ac.name) { wifidev.disconnect (null); return; } /* If we're the active access point, we should just stay that way */ if (wifidev.active_access_point != null && wifidev.active_access_point.get_path () == ac.name) return; var ap = wifidev.get_access_point_by_path (ac.name); if (ap == null) { warning("Unable to access access point path: " + ac.name); return; } /* First we'll go ahead and mark all the other APs as inactive in the UI, it'll take a bit for NM to disconnect and reconnect to the other one which is confusing for users. */ foreach (var action_name in actions.list_actions()) { if (action_name == ac.name) continue; if (!Variant.is_object_path(action_name)) continue; var actionap = wifidev.get_access_point_by_path(action_name); if (actionap == null) continue; var action = actions.lookup_action(action_name); action.change_state(new Variant.boolean(false)); } /* Now setup the connection and start connecting with this AP */ var conns = rs.list_connections (); if (conns == null) { add_and_activate_ap (ac.name); return; } var dev_conns = wifidev.filter_connections (conns); if (dev_conns == null) { add_and_activate_ap (ac.name); return; } var ap_conns = ap.filter_connections (dev_conns); if (ap_conns == null) { add_and_activate_ap (ac.name); return; } client.activate_connection (ap_conns.data, wifidev, ac.name, null); return; } private void add_and_activate_ap (string ap_path) { client.add_and_activate_connection (null, wifidev, ap_path, null); } private void ap_strength_changed (GLib.Object obj, ParamSpec pspec) { var prop = pspec.get_name (); if (prop == "strength") { AccessPoint ap = (AccessPoint)obj; var action_name = ap.get_path() + "::strength"; var action = actions.lookup(action_name); if (action != null) action.change_state (new Variant.byte(ap.get_strength ())); } } } public class Wifi : Base { private WifiMenu wifimenu; private WifiActionManager wifiactionmanager; private GLib.Settings settings; public Wifi (NM.Client client, NM.DeviceWifi device, GLibLocal.ActionMuxer muxer, bool show_settings) { GLib.Object( client: client, device: device, namespace: device.get_iface(), muxer: muxer ); settings = new GLib.Settings ("com.canonical.indicator.network"); settings.changed["auto-join-previous"].connect((k) => { if (client.wireless_get_enabled()) { device.set_autoconnect(settings.get_boolean("auto-join-previous")); } }); device.set_autoconnect(settings.get_boolean("auto-join-previous")); wifimenu = new WifiMenu(client, device, this._menu, "indicator." + this.namespace + ".", show_settings); wifiactionmanager = new WifiActionManager(actions, client, device); client.notify["wireless-enabled"].connect((s, p) => { var wireless_enabled = false; s.get("wireless-enabled", out wireless_enabled); enabled_action.set_state(new Variant.boolean(wireless_enabled)); }); } protected override void disable_device () { device.disconnect(null); client.wireless_set_enabled(false); } protected override void enable_device () { client.wireless_set_enabled(true); device.set_autoconnect(settings.get_boolean("auto-join-previous")); } } } indicator-network-0.5.1+14.04.20140409.1/network/settings-wifi.vala0000644000015301777760000000347412321336644025066 0ustar pbusernogroup00000000000000// vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 /* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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: * Ted Gould */ namespace Network.Settings { public class Wifi : Base { private GLib.Settings settings; public Wifi (GLibLocal.ActionMuxer muxer) { GLib.Object( namespace: "wifi-settings", muxer: muxer ); settings = new GLib.Settings ("com.canonical.indicator.network"); var joinact = settings.create_action("auto-join-previous"); actions.add_action(joinact); var promptact = settings.create_action("prompt-on-new-wifi-ap"); actions.add_action(promptact); var joinitem = new MenuItem(_("Auto-join previous networks"), "indicator.wifi-settings.auto-join-previous"); _menu.append_item(joinitem); /* Commented out for Phone V1 that doesn't have this feature */ /* var promptitem = new MenuItem(_("Prompt when not connected"), "indicator.wifi-settings.prompt-on-new-wifi-ap"); */ /* _menu.append_item(promptitem); */ /* Commented out for Phone V1 that doesn't have this feature */ /* var captionitem = new MenuItem(_("Lists available wi-fi networks, if any, when you're using cellular data."), null); */ /* _menu.append_item(captionitem); */ } } } indicator-network-0.5.1+14.04.20140409.1/network/network-action-manager.vala0000644000015301777760000004502212321336644026641 0ustar pbusernogroup00000000000000// vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 /* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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: * Alberto Ruiz */ using NM; namespace Network { public class ActionManager { /* Action Stuff */ private GLibLocal.ActionMuxer muxer; private SimpleActionGroup actions = new SimpleActionGroup(); private SimpleAction? conn_status = null; /* Network Manager Stuff */ private NM.Client client; /* Tracks the current data connection */ private NM.ActiveConnection? act_conn = null; private NM.Device? act_dev = null; private NM.AccessPoint? act_ap = null; /* Tracking a cell modem if there is one */ private NM.DeviceModem? modemdev = null; private oFono.SIMManager? simmanager = null; private oFono.NetworkRegistration? netreg = null; private bool airplane_mode = false; private bool sim_error = false; private bool sim_installed = false; private bool sim_locked = false; private bool roaming = false; private string? current_protocol = null; private int cell_strength = 0; private int last_cell_strength = 0; private HashTable watched_modems = new HashTable(str_hash, str_equal); /* State tracking stuff */ private int last_wifi_strength = 0; /* Cellular State */ public ActionManager (GLibLocal.ActionMuxer muxer, NM.Client client) { this.client = client; this.muxer = muxer; muxer.insert("global", actions); client.device_added.connect(device_added); client.device_removed.connect(device_removed); var devices = client.get_devices(); for (var i = 0; i < devices.length && modemdev == null; i++) { device_added(devices[i]); } /* Make sure this is last as it'll set the state of the icon, so everything needs to be ready */ add_network_status_action (); var settings_action = new SimpleAction("settings", VariantType.STRING); settings_action.activate.connect((value) => { URLDispatcher.send("settings:///system/" + value.get_string(), (url, success) => { if (!success) { warning(@"Unable to activate settings URL: $url"); } }); }); actions.insert(settings_action); } ~ActionManager () { muxer.remove("global"); } private void device_added (NM.Device device) { debug(@"Action Manager Device Added: $(device.get_iface())"); NM.DeviceModem? modemmaybe = device as NM.DeviceModem; /* If it's not a modem, we can move on */ if (modemmaybe == null) { return; } /* We're only going to deal with oFono modems for now */ if ((modemmaybe.get_current_capabilities() & NM.DeviceModemCapabilities.OFONO) == 0) { debug(@"Modem $(device.get_iface()) doesn't have an OFONO capability"); debug("Not erroring for now"); /* return; TODO: Galaxy Nexus doesn't do this, so for testing we need to ignore it. */ } /* Check to see if the modem supports voice */ try { oFono.Modem? ofono_modem = watched_modems.lookup(modemmaybe.get_iface()); if (ofono_modem == null) { ofono_modem = Bus.get_proxy_sync (BusType.SYSTEM, "org.ofono", modemmaybe.get_iface(), DBusProxyFlags.DO_NOT_AUTO_START); ofono_modem.property_changed.connect((prop, value) => { if (prop == "Interfaces") { device_added(modemmaybe); } }); watched_modems.insert(modemmaybe.get_iface(), ofono_modem); } var modem_properties = ofono_modem.get_properties(); var interfaces = modem_properties.lookup("Interfaces"); if (interfaces == null) { debug(@"Modem '$(modemmaybe.get_iface())' doesn't have voice support, no interfaces"); return; } if (!Utils.variant_contains(interfaces, "org.ofono.VoiceCallManager")) { debug(@"Modem '$(modemmaybe.get_iface())' doesn't have voice support only: $(interfaces.print(false))"); return; } if (!Utils.variant_contains(interfaces, "org.ofono.SimManager")) { debug(@"Modem '$(modemmaybe.get_iface())' doesn't have SIM management support only: $(interfaces.print(false))"); return; } if (!Utils.variant_contains(interfaces, "org.ofono.NetworkRegistration")) { debug(@"Modem '$(modemmaybe.get_iface())' doesn't have Network Registration support only: $(interfaces.print(false))"); return; } } catch (Error e) { warning(@"Unable to get oFono modem properties for '$(modemmaybe.get_iface())': $(e.message)"); return; } debug("Got a modem"); modemdev = modemmaybe; try { /* Initialize the SIM Manager */ simmanager = Bus.get_proxy_sync (BusType.SYSTEM, "org.ofono", modemmaybe.get_iface(), DBusProxyFlags.DO_NOT_AUTO_START); simmanager.property_changed.connect(simmanager_property); var simprops = simmanager.get_properties(); simprops.foreach((k, v) => { simmanager_property(k, v); }); /* Initialize the Network Registration */ netreg = Bus.get_proxy_sync (BusType.SYSTEM, "org.ofono", modemmaybe.get_iface(), DBusProxyFlags.DO_NOT_AUTO_START); netreg.property_changed.connect(netreg_property); var netregprops = netreg.get_properties(); netregprops.foreach((k, v) => { netreg_property(k, v); }); } catch (Error e) { warning(@"Unable to get oFono information from $(modemdev.get_iface()): $(e.message)"); simmanager = null; netreg = null; modemdev = null; } return; } private void device_removed (NM.Device device) { bool changed = false; /* Remove the proxy if we have one, ignore the error if not */ watched_modems.remove(device.get_iface()); /* The voice modem got killed, bugger */ if (device.get_iface() == modemdev.get_iface()) { changed = true; /* Clear the old modemdevice */ modemdev = null; simmanager = null; netreg = null; current_protocol = null; /* Look through the current devices to see if we can find a new modem */ var devices = client.get_devices(); for (var i = 0; i < devices.length && modemdev == null; i++) { device_added(devices[i]); } } /* Oh, they went for the data! Jerks! This is a civil rights violation! */ if (device.get_iface() == act_dev.get_iface()) { active_connections_changed(null, null); /* NOTE: Note setting changed because ^ does it already */ } if (changed && conn_status != null) conn_status.set_state(build_state()); return; } /* Properties from the SIM manager allow us to know the state of the SIM that we've got installed. */ private void simmanager_property (string prop, Variant value) { bool changed = false; switch (prop) { case "Present": { var old = sim_installed; sim_installed = value.get_boolean(); changed = (old != sim_installed); debug(@"SIM Installed: $(sim_installed)"); break; } case "PinRequired": { var old = sim_locked; sim_locked = (value.get_string() != "none"); changed = (old != sim_locked); debug(@"SIM Lock: $(sim_locked)"); break; } } if (changed && conn_status != null) conn_status.set_state(build_state()); return; } /* Properties from the Network Registration which gives us the strength and how we're connecting to it. */ private void netreg_property (string prop, Variant value) { bool changed = false; switch (prop) { case "Technology": { var old = current_protocol; current_protocol = ofono_tech_to_icon_name(value.get_string()); changed = (old != current_protocol); debug(@"Current Protocol: $(current_protocol)"); break; } case "Strength": { var old = cell_strength; cell_strength = value.get_byte(); strength_icon(ref last_cell_strength, cell_strength); changed = (old != cell_strength); /* debug(@"Cell Strength: $(cell_strength)"); */ break; } case "Status": { var old = roaming; roaming = (value.get_string() == "roaming"); changed = (old != roaming); debug(@"Roaming Status: $(roaming)"); break; } } if (changed && conn_status != null) conn_status.set_state(build_state()); return; } private string? ofono_tech_to_icon_name (string tech) { switch (tech) { case "gsm": return "pre-edge"; case "edge": return "edge"; case "umts": return "3g"; case "hspa": return "hspa"; /* TODO: oFono can't tell us about hspa+ yet case "hspa+": return "hspa-plus"; */ case "lte": return "lte"; } warning(@"Technology type $tech that we don't understand. Calling it 'pre-edge'"); return "pre-edge"; } private Variant? icon_serialize (string icon_name) { try { var icon = GLib.Icon.new_for_string(icon_name); return icon.serialize(); } catch (Error e) { warning("Unable to serialize icon '$icon_name' error: $(e.message)"); return null; } } private Variant build_state () { var params = new HashTable(str_hash, str_equal); bool multiicon = false; var icons = new Array(); /* If we have cellular data to report or if we need to show the captured connection information, we need more than one icon. */ if (modemdev != null) { if (airplane_mode) { var icon = icon_serialize("airplane-mode"); if (icon != null) { icons.append_val(icon); multiicon = true; } } else if (!sim_installed) { params.insert("pre-label", new Variant.string(_("No SIM"))); } else if (sim_error) { params.insert("pre-label", new Variant.string(_("SIM Error"))); } else { if (cell_strength == 0) { /* Note, looking to the cell strength here, as it's unmodified or parsed for consistency. We want to know things are really dead. */ params.insert("pre-label", new Variant.string(_("No Signal"))); } else { string icon_name = "gsm-3g-none"; switch (last_cell_strength) { case 100: icon_name = "gsm-3g-full"; break; case 75: icon_name = "gsm-3g-high"; break; case 50: icon_name = "gsm-3g-medium"; break; case 25: icon_name = "gsm-3g-low"; break; } var icon = icon_serialize(icon_name); if (icon != null) { icons.append_val(icon); multiicon = true; } } } } /* Look for the first icon if we need it */ if (roaming) { var icon = icon_serialize("network-cellular-roaming"); if (icon != null) { icons.append_val(icon); multiicon = true; } } string data_icon; string a11ydesc; data_icon_name(out data_icon, out a11ydesc); /* We're doing icon always right now so we have a fallback before everyone supports multi-icon. We shouldn't set both in the future. */ var icon = icon_serialize(data_icon); if (icon != null) { params.insert("icon", icon); if (multiicon) icons.append_val(icon); } params.insert("title", new Variant.string(_("Network"))); params.insert("accessibility-desc", new Variant.string(a11ydesc)); params.insert("visible", new Variant.boolean(true)); /* Turn the icons array into a variant in the param list */ if (multiicon && icons.length > 0) { VariantBuilder builder = new VariantBuilder(VariantType.ARRAY); for (int i = 0; i < icons.length; i++) { builder.add_value(icons.index(i)); } params.insert("icons", builder.end()); } /* Convert to a Variant dictionary */ VariantBuilder final = new VariantBuilder(VariantType.DICTIONARY); params.foreach((key, value) => { final.add("{sv}", key, value); }); return final.end(); } private void data_icon_name (out string icon_name, out string a11ydesc) { if (act_dev == null) { icon_name = "nm-no-connection"; a11ydesc = "Network (none)"; return; } switch (act_dev.get_device_type ()) { case NM.DeviceType.WIFI: { uint8 strength = 0; bool secure = false; if (act_ap != null) { strength = act_ap.strength; secure = ((act_ap.get_flags() & NM.80211ApFlags.PRIVACY) != 0); } if (secure) { a11ydesc = _("Network (wireless, %d%%, secure)").printf(strength); } else { a11ydesc = _("Network (wireless, %d%%)").printf(strength); } strength_icon(ref last_wifi_strength, strength); if (secure) { icon_name = "nm-signal-%d-secure".printf(last_wifi_strength); } else { icon_name = "nm-signal-%d".printf(last_wifi_strength); } break; } case NM.DeviceType.ETHERNET: icon_name = "network-wired"; a11ydesc = _("Network (wired)"); break; case NM.DeviceType.MODEM: if (current_protocol != null) { icon_name = "network-cellular-" + current_protocol; a11ydesc = _("Network (cellular, %s)").printf(current_protocol); } else { icon_name = "network-cellular-pre-edge"; a11ydesc = _("Network (cellular)"); } break; default: icon_name = "nm-no-connection"; a11ydesc = _("Network (none)"); break; } return; } private static void strength_icon (ref int last_strength, int strength) { if (strength > 70 || (last_strength == 100 && strength > 65)) { last_strength = 100; } else if (strength > 50 || (last_strength == 75 && strength > 45)) { last_strength = 75; } else if (strength > 30 || (last_strength == 50 && strength > 25)) { last_strength = 50; } else if (strength > 10 || (last_strength == 25 && strength > 5)) { last_strength = 25; } else { last_strength = 0; } } private void add_network_status_action () { /* This is the action that represents the global status of the network. * * - The first guint32 is for the device type of the main connection as per * NetworkManager.h's NMDeviceType. * - The second one represents the connection state as per NMActiveConnectionState. * - The third one is for the extended status. In the case of Wifi it represents * signal strength. */ conn_status = new SimpleAction.stateful ("network-status", null, build_state()); actions.insert (conn_status); client.notify["active-connections"].connect (active_connections_changed); active_connections_changed(null, null); } private void active_access_point_changed (GLib.Object? client, ParamSpec? ps) { if (act_ap != null) { act_ap.notify["strength"].disconnect (active_connection_strength_changed); act_ap = null; } act_ap = (act_dev as NM.DeviceWifi).get_active_access_point(); if (act_ap != null) { act_ap.notify["strength"].connect (active_connection_strength_changed); } } private void active_connection_strength_changed (GLib.Object? client, ParamSpec? ps) { conn_status.set_state(build_state()); } private void active_connections_changed (GLib.Object? client, ParamSpec? ps) { /* Remove previous active connection */ if (act_conn != null) { act_conn.notify["state"].disconnect (active_connections_changed); act_conn.notify["default"].disconnect (active_connections_changed); act_conn.notify["default6"].disconnect (active_connections_changed); if (act_dev != null) { switch (act_dev.get_device_type ()) { case NM.DeviceType.WIFI: var dev = act_dev as NM.DeviceWifi; dev.notify["active-access-point"].disconnect (active_access_point_changed); if (act_ap != null) { act_ap.notify["strength"].disconnect (active_connection_strength_changed); act_ap = null; } break; default: break; } act_dev = null; } act_conn = null; } act_conn = get_active_connection (); if (act_conn != null) { act_dev = get_device_from_connection (act_conn); } /* If the connection doesn't have a device yet, let's not switch to looking at it */ if (act_dev == null) { act_conn = null; } /* If we have a device, we have a connection, let's make this our active connection */ if (act_dev != null) { act_conn.notify["state"].connect (active_connections_changed); act_conn.notify["default"].connect (active_connections_changed); act_conn.notify["default6"].connect (active_connections_changed); debug(@"Active connection changed to: $(act_dev.get_iface())"); if (act_dev.get_device_type() == NM.DeviceType.WIFI) { act_dev.notify["active-access-point"].connect (active_access_point_changed); active_access_point_changed(null, null); } } conn_status.set_state(build_state()); } /* This function guesses the default connection in case * multiple ones are connected */ private NM.ActiveConnection? get_active_connection () { ActiveConnection? def6 = null; /* The default IPv4 connection has precedence */ var conns = client.get_active_connections (); if (conns == null) return null; for (uint i = 0; i < conns.length; i++) { var conn = conns.get(i); if (conn.default) return conn; if (conn.default6) def6 = conn; } /* Then the default IPv6 connection otherwise the first in the list */ if (def6 != null) return def6; /*TODO: Do we show an active connetion if no default route is present? */ else if (conns.length > 0) return conns.get(0); /* If the list is empty we return null */ return null; } private NM.Device? get_device_from_connection (NM.ActiveConnection conn) { var devices = conn.get_devices (); if (devices == null) return null; /* The list length should always == 1 */ if (devices.length == 1) return devices.get (0); warning ("Connection has a list of devices length different than 0"); return null; } } /* Common utils */ private static bool device_is_busy (NM.Device device) { switch (device.get_state ()) { case NM.DeviceState.ACTIVATED: case NM.DeviceState.UNKNOWN: case NM.DeviceState.UNMANAGED: case NM.DeviceState.UNAVAILABLE: case NM.DeviceState.DISCONNECTED: return false; default: return true; } } } indicator-network-0.5.1+14.04.20140409.1/network/util-wrapper.c0000644000015301777760000000162112321336644024214 0ustar pbusernogroup00000000000000/* * Copyright 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * * Authors: * Ted Gould */ #include #include gboolean util_wrapper_is_empty_ssid (GByteArray * bytes) { if (bytes == NULL) return TRUE; return nm_utils_is_empty_ssid(bytes->data, bytes->len); } indicator-network-0.5.1+14.04.20140409.1/network/mobile-sim-manager.vala0000644000015301777760000004436512321336644025743 0ustar pbusernogroup00000000000000// vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 /* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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: * Nick Dedekind retries = new HashTable(str_hash, str_equal); private List notifications = new List (); // Sim Unlocking private string _required_pin = "none"; private string last_required_pin = ""; private string puk_code = ""; private string old_pin = ""; private string new_pin = ""; private int export_id = 0; private const string APPLICATION_ID = "com.canonical.indicator.network"; private const string SIM_UNLOCK_MENU_PATH = "/com/canonical/indicator/network/unlocksim"; private const string SIM_UNLOCK_ACTION_PATH = "/com/canonical/indicator/network/unlocksim"; private const string OFONO_ERROR_FAILED = "org.ofono.Error.Failed"; struct CurrentNotification { public int id; public Notification? notification; public uint unlock_menu_export_id; public uint unlock_actions_export_id; public Menu? unlock_menu; public SimpleActionGroup? unlock_actions; public CurrentNotification() { this.id = 0; this.notification = null; this.unlock_menu_export_id = 0; this.unlock_actions_export_id = 0; this.unlock_menu = null; this.unlock_actions = null; } } private string required_pin { get { return _required_pin; } set { if (_required_pin != value) { _required_pin = value; notify_property("pin-required"); } } } delegate void PinCancelCallback (); delegate void PinEnteredCallback (string pin); public MobileSimManager (NM.Client client, DeviceModem device, GLib.DBusConnection conn, string namespace) { this.client = client; this.device = device; this.conn = conn; this.namespace = namespace; create_ofono_sim_manager(); } public bool send_unlock_notification () { if (pin_required == false) { clear_stored_data(); return false; } if (send_unlock (required_pin == "puk" ? _("Please enter SIM PUK") : _("Please enter SIM PIN"), required_pin, required_pin == "puk" ? 8 : 4, pin_unlock_entered)) { debug(@"SIM Unlock: $required_pin"); last_required_pin = required_pin; pin_unlocking = true; debug(@"PIN LOCKING: $pin_unlocking"); return true; } else { debug(@"SIM unlock notification request failed"); clear_stored_data(); return false; } } public bool send_change_pin_notification() { if (send_unlock(_("Please enter SIM PIN"), "pin", 4, pin_change_old_entered)) { debug(@"SIM change. Sent old pin request"); return true; } else { debug(@"SIM change. Old pin notification failed"); return false; } } private bool send_unlock(string title, string? retry_type, int pin_length, PinEnteredCallback? pin_entered_callback) { string body = ""; if (retry_type != null) { uchar pin_retries = 0; if (retries.lookup_extended(retry_type, null, out pin_retries)) { if (pin_retries > 1) { body = _(@"$(pin_retries) attempts remaining"); } else if (pin_retries == 1) { body = _(@"$(pin_retries) attempt remaining"); } else { debug(@"No pin retries remaining"); send_fail_notification(_("No retries remaining")); return false; } } } // set the export hints string exported_action_path = @"$(SIM_UNLOCK_ACTION_PATH)$(export_id)"; string exported_menu_path = @"$(SIM_UNLOCK_MENU_PATH)$(export_id)"; export_id++; VariantBuilder menu_model_actions = new VariantBuilder (new VariantType ("a{sv}") ); menu_model_actions.add ("{sv}", "notifications", new Variant.string (exported_action_path)); VariantBuilder menu_model_paths = new VariantBuilder (new VariantType ("a{sv}") ); menu_model_paths.add ("{sv}", "busName", new Variant.string (APPLICATION_ID)); menu_model_paths.add ("{sv}", "menuPath", new Variant.string (exported_menu_path)); menu_model_paths.add ("{sv}", "actions", menu_model_actions.end ()); // create the menu var menu = new Menu (); var pin_unlock = new MenuItem ("", "notifications." + namespace + ".simunlock"); pin_unlock.set_attribute ("x-canonical-type", "s", "com.canonical.snapdecision.pinlock"); pin_unlock.set_attribute ("x-canonical-pin-length", "i", pin_length); menu.append_item (pin_unlock); // create the actions var actions = new SimpleActionGroup(); var unlockpin_item = new SimpleAction.stateful(namespace + ".simunlock", VariantType.BOOLEAN, new Variant.string("")); unlockpin_item.activate.connect ((ac, value) => { if (value.get_boolean() == false) { unlock_cancelled(); } }); if (pin_entered_callback != null) { unlockpin_item.change_state.connect ((ac, value) => { pin_entered_callback(value.get_string()); }); } actions.insert (unlockpin_item); // export the menu uint menu_export_id = 0; try { menu_export_id = conn.export_menu_model(exported_menu_path, menu); } catch (Error e) { warning(@"Unable to export sim unlock menu model for '$(device.get_iface())': $(e.message)"); clear_stored_data(); return false; } // export the actions uint actions_export_id = 0; try { actions_export_id = conn.export_action_group(exported_action_path, actions as ActionGroup); } catch (Error e) { warning(@"Unable to export sim unlock actions group for '$(device.get_iface())': $(e.message)"); if (menu_export_id != 0) { conn.unexport_menu_model(menu_export_id); } clear_stored_data(); return false; } // create and show the notification var notification = new Notification(title, body, ""); notification.set_hint_string ("x-canonical-snap-decisions", "true"); notification.set_hint ("x-canonical-private-menu-model", menu_model_paths.end ()); CurrentNotification new_notification = CurrentNotification() { notification = notification, unlock_menu_export_id = menu_export_id, unlock_actions_export_id = actions_export_id, unlock_menu = menu, unlock_actions = actions }; try { new_notification.notification.closed.connect (notification_closed); new_notification.notification.show (); notifications.append(new_notification); } catch (Error e) { warning(@"Unable to create sim unlock unlock notification for '$(device.get_iface())': $(e.message)"); clear_notification(new_notification); clear_stored_data(); return false; } return true; } private void send_fail_notification (string title) { try { var notification = new Notification(title, "", ""); notification.closed.connect (notification_closed); notification.show (); } catch (Error e) { warning(@"Unable to create sim unlock unlock notification for '$(device.get_iface())': $(e.message)"); return; } } private void create_ofono_sim_manager() { try { if (ofono_modem == null) { ofono_modem = Bus.get_proxy_sync (BusType.SYSTEM, "org.ofono", device.get_iface(), DBusProxyFlags.DO_NOT_AUTO_START); ofono_modem.property_changed.connect((prop, value) => { if (prop == "Interfaces") { create_ofono_sim_manager(); } }); } var modem_properties = ofono_modem.get_properties(); var interfaces = modem_properties.lookup("Interfaces"); if (interfaces == null) { debug(@"Modem '$(device.get_iface())' doesn't have voice support, no interfaces"); return; } if (!Utils.variant_contains(interfaces, "org.ofono.SimManager")) { debug(@"Modem '$(device.get_iface())' doesn't have SIM management support only: $(interfaces.print(false))"); return; } } catch (Error e) { warning(@"Unable to get oFono modem properties for '$(device.get_iface())': $(e.message)"); return; } try { /* Initialize the SIM Manager */ simmanager = Bus.get_proxy_sync (BusType.SYSTEM, "org.ofono", device.get_iface(), DBusProxyFlags.DO_NOT_AUTO_START); simmanager.property_changed.connect(simmanager_property); var simprops = simmanager.get_properties(); simprops.foreach((k, v) => { simmanager_property(k, v); }); } catch (Error e) { warning(@"Unable to get oFono information from $(device.get_iface()): $(e.message)"); simmanager = null; } return; } /* Properties from the SIM manager allow us to know the state of the SIM that we've got installed. */ private void simmanager_property (string prop, Variant value) { switch (prop) { case "Present": { sim_installed = value.get_boolean(); break; } case "PinRequired": { required_pin = value.get_string(); break; } case "Retries": { if (value.get_type_string() == "a{sy}") { for (int i = 0; i < value.n_children(); i++) { string? key = null; uchar tries = 0; value.get_child(i, "{sy}", &key, &tries); retries[key] = tries; } } break; } } } private void pin_unlock_entered (string pin) { if (required_pin == last_required_pin) { bool retry = false; if (required_pin == "puk") { // if it's a puk, we need to reset the pin. close_all_notifications(true); if (send_unlock(_("Enter new PIN code"), null, 4, pin_reset_new_entered)) { debug("SIM pin request. Sent new pin request"); puk_code = pin; } else { warning("SIM pin request. New pin notification failed"); } } else if (!enter_pin(required_pin, pin, out retry)) { warning("SIM pin request. Failed. retry=$(retry)"); close_all_notifications(true); if (retry) { send_unlock_notification(); } else { send_fail_notification("An unexpected error occurred."); } } else { debug("SIM pin request. Done"); close_all_notifications(true); } } else { warning(@"Required pin type changed. old=$(last_required_pin), new=$(required_pin)"); close_all_notifications(true); } } private void pin_reset_new_entered (string pin) { close_all_notifications(false); if (send_unlock(_("Please confirm PIN code"), null, 4, pin_reset_confirm_entered)) { debug("SIM reset pin request. Sent confirm pin request"); new_pin = pin; } else { warning("SIM reset pin request. Confirm pin notification failed"); clear_stored_data(); } } private void pin_reset_confirm_entered (string pin) { if (new_pin == pin) { if (reset_pin("puk", puk_code, pin)) { debug("SIM reset pin request. Done."); close_all_notifications(true); } else { warning("SIM reset request. Failed."); close_all_notifications(true); send_fail_notification("Failed to reset pin."); } } else { warning("SIM reset request. Pin codes did not match"); close_all_notifications(true); send_fail_notification(_("Pin codes did not match")); } } private void pin_change_old_entered (string pin) { close_all_notifications(true); if (send_unlock(_("Please enter new SIM PIN"), "pin", 4, pin_change_new_entered)) { debug("SIM change pin request. Sent new pin request"); old_pin = pin; } else { warning("SIM change pin request. New pin notification failed"); clear_stored_data(); } } private void pin_change_new_entered (string pin) { close_all_notifications(false); if (send_unlock(_("Please confirm PIN code"), null, 4, pin_change_confirm_entered)) { debug("SIM change pin request. Sent confirm pin request"); new_pin = pin; } else { warning("SIM change pin request. Confirm pin notification failed"); clear_stored_data(); } } private void pin_change_confirm_entered (string pin) { if (new_pin == pin) { if (change_pin("pin", old_pin, new_pin)) { debug("SIM change pin request. Done."); close_all_notifications(true); } else { warning("SIM change pin request. Failed."); close_all_notifications(true); send_fail_notification("Failed to change pin."); } } else { close_all_notifications(true); send_fail_notification(_("Pin codes did not match")); } } private bool enter_pin(string type, string pin, out bool retry) { retry = false; try { if (simmanager != null) { debug(@"SimManager: Entering $(type) pin"); simmanager.enter_pin(type, pin); return true; } } catch (DBusError e) { warning(@"Failed to enter $(type) pin for '$(device.get_iface())': $(e.message)"); } catch (IOError e) { warning(@"Failed to enter $(type) pin for '$(device.get_iface())': $(e.message)"); if (check_ofono_error(e, OFONO_ERROR_FAILED)) { retry = true; } } return false; } private bool reset_pin(string type, string puk, string pin) { try { if (simmanager != null) { debug(@"SimManager: Resetting"); simmanager.reset_pin(type, puk, pin); return true; } } catch (DBusError e) { warning(@"Failed to reset pin for '$(device.get_iface())': $(e.message)"); } catch (IOError e) { warning(@"Failed to reset pin for '$(device.get_iface())': $(e.message)"); } return false; } private bool change_pin(string type, string old_pin, string new_pin) { try { if (simmanager != null) { debug(@"SimManager: Changing $type pin"); simmanager.change_pin(type, old_pin, new_pin); return true; } } catch (DBusError e) { warning(@"Failed to change pin for '$(device.get_iface())': $(e.message)"); } catch (IOError e) { warning(@"Failed to change pin for '$(device.get_iface())': $(e.message)"); } return false; } private void unlock_cancelled() { debug(@"SIM notification cancelled"); close_all_notifications(true); } private void close_all_notifications(bool reset_data) { unowned List? element = notifications.first (); while (element != null) { CurrentNotification? entry = element.data; if (entry != null) { try { if (entry.unlock_menu_export_id != 0) { conn.unexport_menu_model(entry.unlock_menu_export_id); } if (entry.unlock_actions_export_id != 0) { conn.unexport_action_group(entry.unlock_actions_export_id); } debug(@"closing notification $(entry.notification.id)"); entry.notification.close(); } catch (Error e) { warning("Failed to close notification for '$(device.get_iface())': $(e.message)"); } } element = notifications.next; } if (reset_data) { clear_stored_data(); } } private void clear_stored_data() { new_pin = ""; old_pin = ""; puk_code = ""; } private void clear_notification (CurrentNotification? notification) { if (notification.unlock_menu_export_id != 0) { conn.unexport_menu_model(notification.unlock_menu_export_id); } if (notification.unlock_actions_export_id != 0) { conn.unexport_action_group(notification.unlock_actions_export_id); } } private void notification_closed (Notification? notification) { unowned List? element = notifications.first (); while (element != null) { unowned CurrentNotification? entry = element.data; if (entry != null && notification.id == entry.notification.id) { debug(@"notification_closed $(notification.id)"); clear_notification(entry); notifications.delete_link(element); break; } element = notifications.next; } if (notifications.length () == 0) { pin_unlocking = false; } } private bool check_ofono_error(Error e, string value) { return DBusError.get_remote_error(e) == value; } } } indicator-network-0.5.1+14.04.20140409.1/network/CMakeLists.txt0000644000015301777760000000574412321336644024167 0ustar pbusernogroup00000000000000 add_definitions( -w ) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) ########################### # libnetwork ########################### vala_init(libnetwork PACKAGES libnm-glib libnotify CUSTOM_VAPIS "${CMAKE_CURRENT_SOURCE_DIR}/action-muxer.vapi" "${CMAKE_CURRENT_SOURCE_DIR}/url-dispatcher.vapi" "${CMAKE_CURRENT_SOURCE_DIR}/util-wrapper.vapi" ) vala_add(libnetwork ofono.vala ) vala_add(libnetwork utils.vala ) vala_add(libnetwork network-action-manager.vala DEPENDS ofono utils ) vala_add(libnetwork network-menu.vala DEPENDS device-base device-ethernet device-mobile device-wifi settings-base settings-wifi settings-airplane network-action-manager mobile-sim-manager ) vala_add(libnetwork mobile-sim-manager.vala DEPENDS ofono utils ) vala_add(libnetwork device-base.vala ) vala_add(libnetwork device-ethernet.vala DEPENDS device-base ) vala_add(libnetwork device-mobile.vala DEPENDS device-base mobile-sim-manager ) vala_add(libnetwork device-wifi.vala DEPENDS device-base ) vala_add(libnetwork settings-base.vala ) vala_add(libnetwork settings-airplane.vala DEPENDS settings-base ) vala_add(libnetwork settings-wifi.vala DEPENDS settings-base ) vala_finish(libnetwork SOURCES LIBNETWORK_VALA_SOURCES OUTPUTS LIBNETWORK_VALA_C GENERATE_HEADER libnetwork.h GENERATE_VAPI libnetwork.vapi GENERATE_SYMBOLS libnetwork.def ) set_source_files_properties( ${LIBNETWORK_VALA_SOURCES} PROPERTIES HEADER_FILE_ONLY TRUE ) set( LIBNETWORK_SOURCES ${LIBNETWORK_VALA_SOURCES} ${LIBNETWORK_VALA_C} action-muxer.c util-wrapper.c ) add_library( network STATIC ${LIBNETWORK_SOURCES} ) target_link_libraries( network ${GLIB_LIBRARIES} ${NM_LIBRARIES} ${NOTIFY_LIBRARIES} ) ########################### # network service ########################### vala_init(network-service PACKAGES libnm-glib libnotify libnetwork DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libnetwork.vapi" CUSTOM_VAPIS "${CMAKE_CURRENT_SOURCE_DIR}/config.vapi" "${CMAKE_CURRENT_SOURCE_DIR}/action-muxer.vapi" "${CMAKE_CURRENT_SOURCE_DIR}/util-wrapper.vapi" OPTIONS --vapidir=. ) vala_add(network-service network-menu-service.vala ) vala_finish(network-service SOURCES NETWORK_SERVICE_VALA_SOURCES OUTPUTS NETWORK_SERVICE_VALA_C ) set_source_files_properties( ${NETWORK_SERVICE_VALA_SOURCES} PROPERTIES HEADER_FILE_ONLY TRUE ) set( NETWORK_SERVICE_SOURCES ${NETWORK_SERVICE_VALA_SOURCES} ${NETWORK_SERVICE_VALA_C} ) add_executable( indicator-network-service ${NETWORK_SERVICE_SOURCES} ) target_link_libraries( indicator-network-service network ) ########################### # Installation ########################### install( TARGETS indicator-network-service RUNTIME DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/indicator-network/" ) indicator-network-0.5.1+14.04.20140409.1/network/device-base.vala0000644000015301777760000001572712321336644024445 0ustar pbusernogroup00000000000000// vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 /* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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: * Ted Gould */ namespace Network.Device { public class Base : MenuModel { NM.Client _client; NM.Device _device; string _namespace; GLibLocal.ActionMuxer _muxer; protected Menu _menu = new Menu(); protected GLib.SimpleActionGroup actions = new GLib.SimpleActionGroup(); protected GLib.SimpleAction enabled_action = new SimpleAction.stateful("device-enabled", null, new Variant.boolean(false)); protected GLib.SimpleAction busy_action = new SimpleAction.stateful("device-busy", null, new Variant.boolean(false)); private NM.ActiveConnection? active_connection = null; private ulong active_connection_notify = 0; /***************************** * Properties *****************************/ public NM.Device device { construct { _device = value; return; } get { return _device; } } public NM.Client client { construct { _client = value; return; } get { return _client; } } public string namespace { construct { _namespace = value; return; } get { return _namespace; } } public GLibLocal.ActionMuxer muxer { construct { _muxer = value; return; } get { return _muxer; } } /***************************** * Functions *****************************/ construct { _menu.items_changed.connect(menu_items_changed); actions.insert(enabled_action); actions.insert(busy_action); _muxer.insert(_namespace, actions); enabled_action.activate.connect((param) => { if (enabled_action.state.get_boolean()) { disable_device(); } else { enable_device(); } }); device.state_changed.connect (device_state_changed); device.notify.connect((pspec) => { if (pspec.name == "active-connection") { active_connection_changed(); } }); active_connection_changed(); } ~Base () { muxer.remove(namespace); } protected virtual void enable_device () { warning("Subclass doesn't have a way to enable the device"); return; } protected virtual void disable_device () { device.disconnect(null); return; } private void device_state_changed (NM.Device dev, uint old_state, uint new_state, uint reason) { switch (new_state) { case NM.DeviceState.PREPARE: case NM.DeviceState.CONFIG: case NM.DeviceState.NEED_AUTH: case NM.DeviceState.IP_CONFIG: case NM.DeviceState.IP_CHECK: case NM.DeviceState.SECONDARIES: debug("Marking '" + dev.get_iface() + "' as Activating"); busy_action.set_state(new Variant.boolean(true)); enabled_action.set_state(new Variant.boolean(true)); break; case NM.DeviceState.ACTIVATED: debug("Marking '" + dev.get_iface() + "' as Active"); busy_action.set_state(new Variant.boolean(false)); enabled_action.set_state(new Variant.boolean(true)); break; case NM.DeviceState.DEACTIVATING: debug("Marking '" + dev.get_iface() + "' as Deactivating"); busy_action.set_state(new Variant.boolean(true)); enabled_action.set_state(new Variant.boolean(false)); break; default: debug("Marking '" + dev.get_iface() + "' as Disabled"); busy_action.set_state(new Variant.boolean(false)); enabled_action.set_state(new Variant.boolean(false)); break; } } private void active_connection_changed () { if (active_connection != null) { active_connection.disconnect(active_connection_notify); } active_connection = this.device.get_active_connection(); if (active_connection != null) { active_connection_notify = active_connection.notify.connect((pspec) => { if (pspec.name == "state") { active_connection_state_changed(active_connection.state); } }); active_connection_state_changed(active_connection.state); } } private void active_connection_state_changed (uint new_state) { switch (new_state) { case NM.ActiveConnectionState.ACTIVATING: debug("Marking '" + device.get_iface() + "' as Activating"); busy_action.set_state(new Variant.boolean(true)); enabled_action.set_state(new Variant.boolean(true)); break; case NM.ActiveConnectionState.ACTIVATED: debug("Marking '" + device.get_iface() + "' as Active"); busy_action.set_state(new Variant.boolean(false)); enabled_action.set_state(new Variant.boolean(true)); break; case NM.ActiveConnectionState.DEACTIVATING: debug("Marking '" + device.get_iface() + "' as Deactivating"); busy_action.set_state(new Variant.boolean(true)); enabled_action.set_state(new Variant.boolean(false)); break; default: debug("Marking '" + device.get_iface() + "' as Disabled"); busy_action.set_state(new Variant.boolean(false)); enabled_action.set_state(new Variant.boolean(false)); break; } } void menu_items_changed (int position, int removed, int added) { (this as MenuModel).items_changed(position, removed, added); } /*********************************** * Passing on functions to our menu ***********************************/ public override GLib.Variant get_item_attribute_value (int item_index, string attribute, GLib.VariantType? expected_type) { return (_menu as MenuModel).get_item_attribute_value(item_index, attribute, expected_type); } public override void get_item_attributes (int item_index, [CCode (type = "GHashTable**")] out GLib.HashTable? attributes) { (_menu as MenuModel).get_item_attributes(item_index, out attributes); } public override GLib.MenuModel get_item_link (int item_index, string link) { return (_menu as MenuModel).get_item_link(item_index, link); } public override void get_item_links (int item_index, [CCode (type = "GHashTable**")] out GLib.HashTable? links) { (_menu as MenuModel).get_item_links(item_index, out links); } public override int get_n_items () { return (_menu as MenuModel).get_n_items(); } public override bool is_mutable () { return (_menu as MenuModel).is_mutable(); } public override GLib.MenuAttributeIter iterate_item_attributes (int item_index) { return (_menu as MenuModel).iterate_item_attributes(item_index); } public override GLib.MenuLinkIter iterate_item_links (int item_index) { return (_menu as MenuModel).iterate_item_links(item_index); } } } // namespace indicator-network-0.5.1+14.04.20140409.1/network/device-mobile.vala0000644000015301777760000001200112321336644024760 0ustar pbusernogroup00000000000000// vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 /* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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: * Ted Gould */ using NM; namespace Network.Device { internal class MobileMenu { private NM.Client client; private NM.DeviceModem device; private Menu apsmenu; private string action_prefix; private MobileSimManager mobilesimmanager; private MenuItem device_item; private MenuItem settings_item; private MenuItem? unlock_sim_item = null; public MobileMenu (NM.Client client, DeviceModem device, Menu global_menu, string action_prefix, bool show_enable, MobileSimManager mobilesimmanager) { this.client = client; this.device = device; this.apsmenu = global_menu; this.action_prefix = action_prefix; this.mobilesimmanager = mobilesimmanager; if (show_enable) { device_item = create_item_for_mobile_device(); this.apsmenu.append_item(device_item); } settings_item = new MenuItem(_("Cellular settings…"), "indicator.global.settings::cellular"); this.apsmenu.append_item(settings_item); update_sim_lock_menu(mobilesimmanager.pin_required); mobilesimmanager.notify["pin-required"].connect((s, value) => { update_sim_lock_menu(mobilesimmanager.pin_required); }); } ~MobileMenu () { } private MenuItem create_item_for_mobile_device () { var device_item = new MenuItem(_("Cellular"), action_prefix + ".device-enabled"); device_item.set_attribute ("x-canonical-type" , "s", "com.canonical.indicator.switch"); return device_item; } private void update_sim_lock_menu(bool pin_required) { string action_name = action_prefix + "unlock"; debug(@"sim lock updated $(pin_required) - action $action_name"); for (int i = 0; i < apsmenu.get_n_items(); i++) { string name; if (!apsmenu.get_item_attribute (i, "action", "s", out name)) continue; debug(@"update_sim_lock_menu action $name"); if (name == action_name) { if (!pin_required) { apsmenu.remove (i); } return; } } if (pin_required) { unlock_sim_item = new MenuItem(_("Unlock SIM…"), action_name); apsmenu.insert_item (0, unlock_sim_item); } else { unlock_sim_item = null; } } } internal class MobileActionManager { private SimpleActionGroup actions; private NM.Client client; private NM.DeviceModem device; private MobileSimManager mobilesimmanager; private SimpleAction unlock_action; public MobileActionManager (SimpleActionGroup actions, NM.Client client, NM.DeviceModem device, MobileSimManager mobilesimmanager) { this.actions = actions; this.client = client; this.device = device; this.mobilesimmanager = mobilesimmanager; unlock_action = new SimpleAction("unlock", null); unlock_action.activate.connect((ac,ps) => { if (mobilesimmanager.pin_unlocking) { debug(@"SIM unlock already in progress"); return; } mobilesimmanager.send_unlock_notification(); }); actions.insert(unlock_action); unlock_action.set_enabled(mobilesimmanager.pin_required && !mobilesimmanager.pin_unlocking); mobilesimmanager.notify["pin-required"].connect((s, value) => { unlock_action.set_enabled(mobilesimmanager.pin_required && !mobilesimmanager.pin_unlocking); }); mobilesimmanager.notify["pin-unlocking"].connect((s, value) => { unlock_action.set_enabled(mobilesimmanager.pin_required && !mobilesimmanager.pin_unlocking); }); } } public class Mobile : Base { private MobileMenu mobilemenu; private MobileActionManager mobileactionmanager; private MobileSimManager mobilesimmanager; public Mobile (NM.Client client, NM.DeviceModem device, GLibLocal.ActionMuxer muxer, bool show_enable, GLib.DBusConnection conn) { GLib.Object( client: client, device: device, namespace: device.get_iface(), muxer: muxer ); mobilesimmanager = new MobileSimManager(client, device, conn, this.namespace); mobilemenu = new MobileMenu(client, device, this._menu, "indicator." + this.namespace + ".", show_enable, mobilesimmanager); mobileactionmanager = new MobileActionManager(actions, client, device, mobilesimmanager); } protected override void disable_device () { device.disconnect(null); client.wwan_set_enabled(false); } protected override void enable_device () { client.wwan_set_enabled(true); device.set_autoconnect(true); } } } indicator-network-0.5.1+14.04.20140409.1/network/network-menu-service.vala0000644000015301777760000000246412321336644026361 0ustar pbusernogroup00000000000000// vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 /* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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: * Alberto Ruiz */ using Config; using Notify; public static int main (string[] args) { // set up i18n Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8"); Intl.setlocale (LocaleCategory.ALL, ""); Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.GNOMELOCALEDIR); Intl.textdomain (Config.GETTEXT_PACKAGE); var mainloop = new MainLoop(); GLib.Unix.signal_add(GLib.ProcessSignal.TERM, () => { debug("Recieved SIGTERM"); mainloop.quit(); return false; }); Notify.init("indicator-network"); var menu = new Network.NetworkMenu (); mainloop.run (); return 0; } indicator-network-0.5.1+14.04.20140409.1/network/settings-base.vala0000644000015301777760000000564412321336644025043 0ustar pbusernogroup00000000000000// vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 /* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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: * Ted Gould */ namespace Network.Settings { public class Base : MenuModel { protected Menu _menu = new Menu(); protected string _namespace = "no-namespace-here"; protected GLib.SimpleActionGroup actions = new GLib.SimpleActionGroup(); private GLibLocal.ActionMuxer _muxer; public string namespace { construct { _namespace = value; return; } get { return _namespace; } } public GLibLocal.ActionMuxer muxer { construct { _muxer = value; return; } get { return _muxer; } } construct { _menu.items_changed.connect(menu_items_changed); _muxer.insert(_namespace, actions); } ~Base () { _muxer.remove(_namespace); } void menu_items_changed (int position, int removed, int added) { (this as MenuModel).items_changed(position, removed, added); } /*********************************** * Passing on functions to our menu ***********************************/ public override GLib.Variant get_item_attribute_value (int item_index, string attribute, GLib.VariantType? expected_type) { return (_menu as MenuModel).get_item_attribute_value(item_index, attribute, expected_type); } public override void get_item_attributes (int item_index, [CCode (type = "GHashTable**")] out GLib.HashTable? attributes) { (_menu as MenuModel).get_item_attributes(item_index, out attributes); } public override GLib.MenuModel get_item_link (int item_index, string link) { return (_menu as MenuModel).get_item_link(item_index, link); } public override void get_item_links (int item_index, [CCode (type = "GHashTable**")] out GLib.HashTable? links) { (_menu as MenuModel).get_item_links(item_index, out links); } public override int get_n_items () { return (_menu as MenuModel).get_n_items(); } public override bool is_mutable () { return (_menu as MenuModel).is_mutable(); } public override GLib.MenuAttributeIter iterate_item_attributes (int item_index) { return (_menu as MenuModel).iterate_item_attributes(item_index); } public override GLib.MenuLinkIter iterate_item_links (int item_index) { return (_menu as MenuModel).iterate_item_links(item_index); } } } indicator-network-0.5.1+14.04.20140409.1/network/ofono.vala0000644000015301777760000000354012321336644023404 0ustar pbusernogroup00000000000000 using GLib; namespace oFono { [DBus (name = "org.ofono.Modem") ] public interface Modem : GLib.Object { [DBus (name = "SetProperty")] public abstract void set_property (string property, GLib.Variant value) throws IOError; [DBus (name = "GetProperties")] public abstract GLib.HashTable get_properties () throws IOError; [DBus (name = "PropertyChanged")] public signal void property_changed (string property, GLib.Variant value); } [DBus (name = "org.ofono.NetworkRegistration") ] public interface NetworkRegistration : GLib.Object { [DBus (name = "GetProperties")] public abstract GLib.HashTable get_properties () throws IOError; [DBus (name = "PropertyChanged")] public signal void property_changed (string property, GLib.Variant value); } [DBus (name = "org.ofono.SimManager") ] public interface SIMManager : GLib.Object { [DBus (name = "SetProperty")] public abstract void set_property (string property, GLib.Variant value) throws IOError; [DBus (name = "GetProperties")] public abstract GLib.HashTable get_properties () throws IOError; [DBus (name = "PropertyChanged")] public signal void property_changed (string property, GLib.Variant value); [DBus (name = "ChangePin")] public abstract void change_pin(string type, string old_pin, string new_pin) throws DBusError, IOError; [DBus (name = "EnterPin")] public abstract void enter_pin(string type, string pin) throws DBusError, IOError; [DBus (name = "ResetPin")] public abstract void reset_pin(string type, string puk, string new_pin) throws DBusError, IOError; [DBus (name = "LockPin")] public abstract void lock_pin(string type, string pin) throws DBusError, IOError; [DBus (name = "UnlockPin")] public abstract void unlock_pin(string type, string pin) throws DBusError, IOError; } } indicator-network-0.5.1+14.04.20140409.1/network/device-ethernet.vala0000644000015301777760000000347312321336644025344 0ustar pbusernogroup00000000000000// vim: tabstop=4 noexpandtab shiftwidth=4 softtabstop=4 /* * Copyright 2013 Canonical Ltd. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * 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: * Ted Gould */ using NM; namespace Network.Device { public class Ethernet : Base { private GLib.MenuItem enabled_item; public Ethernet (NM.Client client, NM.DeviceEthernet device, GLibLocal.ActionMuxer muxer) { GLib.Object( client: client, device: device, namespace: device.get_iface(), muxer: muxer ); enabled_item = new MenuItem(_("Wired"), "indicator." + device.get_iface() + ".device-enabled"); enabled_item.set_attribute ("x-canonical-type" , "s", "com.canonical.indicator.switch"); _menu.append_item(enabled_item); /* TODO: Need busy action */ } ~Ethernet () { muxer.remove(namespace); } protected override void enable_device () { var conn = new NM.Connection(); var swired = new NM.SettingWired(); conn.add_setting(swired); var sconn = new NM.SettingConnection(); sconn.id = "Auto Ethernet"; sconn.type = NM.SettingWired.SETTING_NAME; sconn.autoconnect = true; sconn.uuid = NM.Utils.uuid_generate(); conn.add_setting(sconn); client.add_and_activate_connection(conn, this.device, "/", null); } } } indicator-network-0.5.1+14.04.20140409.1/network/util-wrapper.vapi0000644000015301777760000000030312321336644024725 0ustar pbusernogroup00000000000000[CCode (cprefix = "UtilWrapper", lower_case_cprefix = "util_wrapper_")] namespace UtilWrapper { [CCode (cheader_filename = "util-wrapper.h")] public bool is_empty_ssid (GLib.ByteArray ssid); } indicator-network-0.5.1+14.04.20140409.1/network/url-dispatcher.vapi0000644000015301777760000000030012321336644025215 0ustar pbusernogroup00000000000000namespace URLDispatcher { public delegate void UrlSendCallback (string url, bool success); [CCode (cname = "url_dispatch_send")] public void send (string url, UrlSendCallback? callback); } indicator-network-0.5.1+14.04.20140409.1/README0000644000015301777760000000126612321336644020611 0ustar pbusernogroup00000000000000System Settings Server/Client ============================= Both Server and Client applications are using cmake as default build tool. This file will guide you to compile these applications. 1. SERVER ========= The Server application is the application which make available the menu structure over dbus. 3. COMPILING ============ ./autogen.sh make 3. EXAMPLES =========== To test the current implementation you should run the server and client application simultaneously. To do that follow the steps below: In the build directory(/build): ./exportmenu/exportmenu examples/test.xml & Then from the chewie-client package run: ./client/examples/run-client-app.sh indicator-network-0.5.1+14.04.20140409.1/COPYING.LGPL0000644000015301777760000001674512321336644021531 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. .