indicator-sound-12.10.2+14.04.20140401/0000755000015301777760000000000012316645302017352 5ustar pbusernogroup00000000000000indicator-sound-12.10.2+14.04.20140401/cmake/0000755000015301777760000000000012316645302020432 5ustar pbusernogroup00000000000000indicator-sound-12.10.2+14.04.20140401/cmake/FindGObjectIntrospection.cmake0000644000015301777760000000376512316644622026352 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-sound-12.10.2+14.04.20140401/cmake/UseVala.cmake0000644000015301777760000002067412316644622023011 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.20 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-sound-12.10.2+14.04.20140401/cmake/Coverage.cmake0000644000015301777760000000422212316644622023173 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-sound-12.10.2+14.04.20140401/cmake/UseGObjectIntrospection.cmake0000644000015301777760000000743712316644622026226 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-sound-12.10.2+14.04.20140401/cmake/COPYING-CMAKE-SCRIPTS0000644000015301777760000000245712316644622023444 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-sound-12.10.2+14.04.20140401/cmake/FindVala.cmake0000644000015301777760000000442212316644622023126 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-sound-12.10.2+14.04.20140401/cmake/UseGSettings.cmake0000644000015301777760000000365212316644622024032 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-sound-12.10.2+14.04.20140401/tests/0000755000015301777760000000000012316645302020514 5ustar pbusernogroup00000000000000indicator-sound-12.10.2+14.04.20140401/tests/greeter-list.cc0000644000015301777760000000323312316644657023446 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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 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 extern "C" { #include "indicator-sound-service.h" #include "vala-mocks.h" } class GreeterListTest : public ::testing::Test { protected: GTestDBus * bus = nullptr; virtual void SetUp() { bus = g_test_dbus_new(G_TEST_DBUS_NONE); g_test_dbus_up(bus); } virtual void TearDown() { g_test_dbus_down(bus); g_clear_object(&bus); } }; TEST_F(GreeterListTest, BasicObject) { MediaPlayerListGreeter * list = media_player_list_greeter_new(); ASSERT_NE(nullptr, list); g_clear_object(&list); return; } TEST_F(GreeterListTest, BasicIterator) { MediaPlayerListGreeter * list = media_player_list_greeter_new(); ASSERT_NE(nullptr, list); MediaPlayerListGreeterIterator * iter = media_player_list_greeter_iterator_new(list); ASSERT_NE(nullptr, iter); MediaPlayer * player = media_player_list_iterator_next_value (MEDIA_PLAYER_LIST_ITERATOR(iter)); ASSERT_EQ(nullptr, player); g_clear_object(&iter); g_clear_object(&list); return; } indicator-sound-12.10.2+14.04.20140401/tests/accounts-service-mock.h0000644000015301777760000000737112316644622025105 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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 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 class AccountsServiceMock { DbusTestDbusMock * mock = nullptr; DbusTestDbusMockObject * soundobj = nullptr; DbusTestDbusMockObject * userobj = nullptr; public: AccountsServiceMock () { mock = dbus_test_dbus_mock_new("org.freedesktop.Accounts"); DbusTestDbusMockObject * baseobj = dbus_test_dbus_mock_get_object(mock, "/org/freedesktop/Accounts", "org.freedesktop.Accounts", NULL); dbus_test_dbus_mock_object_add_method(mock, baseobj, "CacheUser", G_VARIANT_TYPE_STRING, G_VARIANT_TYPE_OBJECT_PATH, "ret = dbus.ObjectPath('/user')\n", NULL); dbus_test_dbus_mock_object_add_method(mock, baseobj, "FindUserById", G_VARIANT_TYPE_INT64, G_VARIANT_TYPE_OBJECT_PATH, "ret = dbus.ObjectPath('/user')\n", NULL); dbus_test_dbus_mock_object_add_method(mock, baseobj, "FindUserByName", G_VARIANT_TYPE_STRING, G_VARIANT_TYPE_OBJECT_PATH, "ret = dbus.ObjectPath('/user')\n", NULL); dbus_test_dbus_mock_object_add_method(mock, baseobj, "ListCachedUsers", NULL, G_VARIANT_TYPE_OBJECT_PATH_ARRAY, "ret = [ dbus.ObjectPath('/user') ]\n", NULL); dbus_test_dbus_mock_object_add_method(mock, baseobj, "UncacheUser", G_VARIANT_TYPE_STRING, NULL, "", NULL); userobj = dbus_test_dbus_mock_get_object(mock, "/user", "org.freedesktop.Accounts.User", NULL); dbus_test_dbus_mock_object_add_property(mock, userobj, "UserName", G_VARIANT_TYPE_STRING, g_variant_new_string(g_get_user_name()), NULL); soundobj = dbus_test_dbus_mock_get_object(mock, "/user", "com.canonical.indicator.sound.AccountsService", NULL); dbus_test_dbus_mock_object_add_property(mock, soundobj, "Timestamp", G_VARIANT_TYPE_UINT64, g_variant_new_uint64(0), NULL); dbus_test_dbus_mock_object_add_property(mock, soundobj, "PlayerName", G_VARIANT_TYPE_STRING, g_variant_new_string(""), NULL); dbus_test_dbus_mock_object_add_property(mock, soundobj, "PlayerIcon", G_VARIANT_TYPE_VARIANT, g_variant_new_variant(g_variant_new_string("")), NULL); dbus_test_dbus_mock_object_add_property(mock, soundobj, "Running", G_VARIANT_TYPE_BOOLEAN, g_variant_new_boolean(FALSE), NULL); dbus_test_dbus_mock_object_add_property(mock, soundobj, "State", G_VARIANT_TYPE_STRING, g_variant_new_string(""), NULL); dbus_test_dbus_mock_object_add_property(mock, soundobj, "Title", G_VARIANT_TYPE_STRING, g_variant_new_string(""), NULL); dbus_test_dbus_mock_object_add_property(mock, soundobj, "Artist", G_VARIANT_TYPE_STRING, g_variant_new_string(""), NULL); dbus_test_dbus_mock_object_add_property(mock, soundobj, "Album", G_VARIANT_TYPE_STRING, g_variant_new_string(""), NULL); dbus_test_dbus_mock_object_add_property(mock, soundobj, "ArtUrl", G_VARIANT_TYPE_STRING, g_variant_new_string(""), NULL); } ~AccountsServiceMock () { g_debug("Destroying the Accounts Service Mock"); g_clear_object(&mock); } operator DbusTestTask* () { return DBUS_TEST_TASK(mock); } operator DbusTestDbusMock* () { return mock; } DbusTestDbusMockObject * get_sound () { return soundobj; } }; indicator-sound-12.10.2+14.04.20140401/tests/sound-menu.cc0000644000015301777760000000702012316644622023120 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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 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 extern "C" { #include "indicator-sound-service.h" #include "vala-mocks.h" } class SoundMenuTest : public ::testing::Test { protected: GTestDBus * bus = nullptr; virtual void SetUp() { bus = g_test_dbus_new(G_TEST_DBUS_NONE); g_test_dbus_up(bus); } virtual void TearDown() { g_test_dbus_down(bus); g_clear_object(&bus); } void verify_item_attribute (GMenuModel * mm, guint index, const gchar * name, GVariant * value) { g_variant_ref_sink(value); gchar * variantstr = g_variant_print(value, TRUE); g_debug("Expecting item %d to have a '%s' attribute: %s", index, name, variantstr); const GVariantType * type = g_variant_get_type(value); GVariant * itemval = g_menu_model_get_item_attribute_value(mm, index, name, type); ASSERT_NE(nullptr, itemval); EXPECT_TRUE(g_variant_equal(itemval, value)); g_variant_unref(value); } }; TEST_F(SoundMenuTest, BasicObject) { SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE); ASSERT_NE(nullptr, menu); g_clear_object(&menu); return; } TEST_F(SoundMenuTest, AddRemovePlayer) { SoundMenu * menu = sound_menu_new (nullptr, SOUND_MENU_DISPLAY_FLAGS_NONE); MediaPlayerTrack * track = media_player_track_new("Artist", "Title", "Album", "http://art.url"); MediaPlayerMock * media = MEDIA_PLAYER_MOCK( g_object_new(TYPE_MEDIA_PLAYER_MOCK, "mock-id", "player-id", "mock-name", "Test Player", "mock-state", "Playing", "mock-is-running", TRUE, "mock-can-raise", FALSE, "mock-current-track", track, NULL) ); g_clear_object(&track); sound_menu_add_player(menu, MEDIA_PLAYER(media)); ASSERT_NE(nullptr, menu->menu); EXPECT_EQ(2, g_menu_model_get_n_items(G_MENU_MODEL(menu->menu))); GMenuModel * section = g_menu_model_get_item_link(G_MENU_MODEL(menu->menu), 1, G_MENU_LINK_SECTION); ASSERT_NE(nullptr, section); EXPECT_EQ(2, g_menu_model_get_n_items(section)); /* No playlists, so two items */ /* Player display */ verify_item_attribute(section, 0, "action", g_variant_new_string("indicator.player-id")); verify_item_attribute(section, 0, "x-canonical-type", g_variant_new_string("com.canonical.unity.media-player")); /* Player control */ verify_item_attribute(section, 1, "x-canonical-type", g_variant_new_string("com.canonical.unity.playback-item")); verify_item_attribute(section, 1, "x-canonical-play-action", g_variant_new_string("indicator.play.player-id")); verify_item_attribute(section, 1, "x-canonical-next-action", g_variant_new_string("indicator.next.player-id")); verify_item_attribute(section, 1, "x-canonical-previous-action", g_variant_new_string("indicator.previous.player-id")); g_clear_object(§ion); sound_menu_remove_player(menu, MEDIA_PLAYER(media)); EXPECT_EQ(1, g_menu_model_get_n_items(G_MENU_MODEL(menu->menu))); g_clear_object(&media); g_clear_object(&menu); return; } indicator-sound-12.10.2+14.04.20140401/tests/media-player-mock.vala0000644000015301777760000000457012316644622024673 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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 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 */ public class MediaPlayerMock: MediaPlayer { /* Superclass variables */ public override string id { get { return mock_id; } } public override string name { get { return mock_name; } } public override string state { get { return mock_state; } set { this.mock_state = value; }} public override Icon? icon { get { return mock_icon; } } public override string dbus_name { get { return mock_dbus_name; } } public override bool is_running { get { return mock_is_running; } } public override bool can_raise { get { return mock_can_raise; } } public override MediaPlayer.Track? current_track { get { return mock_current_track; } set { this.mock_current_track = value; } } /* Mock values */ public string mock_id { get; set; } public string mock_name { get; set; } public string mock_state { get; set; } public Icon? mock_icon { get; set; } public string mock_dbus_name { get; set; } public bool mock_is_running { get; set; } public bool mock_can_raise { get; set; } public MediaPlayer.Track? mock_current_track { get; set; } /* Virtual functions */ public override void activate () { debug("Mock activate"); } public override void play_pause () { debug("Mock play_pause"); } public override void next () { debug("Mock next"); } public override void previous () { debug("Mock previous"); } public override uint get_n_playlists() { debug("Mock get_n_playlists"); return 0; } public override string get_playlist_id (int index) { debug("Mock get_playlist_id"); return ""; } public override string get_playlist_name (int index) { debug("Mock get_playlist_name"); return ""; } public override void activate_playlist_by_name (string playlist) { debug("Mock activate_playlist_by_name"); } } indicator-sound-12.10.2+14.04.20140401/tests/accounts-service-user.cc0000644000015301777760000001350112316644622025260 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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 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 #include #include #include "accounts-service-mock.h" extern "C" { #include "indicator-sound-service.h" #include "vala-mocks.h" } class AccountsServiceUserTest : public ::testing::Test { protected: DbusTestService * service = NULL; DbusTestDbusMock * mock = NULL; GDBusConnection * session = NULL; GDBusConnection * system = NULL; GDBusProxy * proxy = NULL; virtual void SetUp() { service = dbus_test_service_new(NULL); AccountsServiceMock service_mock; dbus_test_service_add_task(service, (DbusTestTask*)service_mock); dbus_test_service_start_tasks(service); g_setenv("DBUS_SYSTEM_BUS_ADDRESS", g_getenv("DBUS_SESSION_BUS_ADDRESS"), TRUE); session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); ASSERT_NE(nullptr, session); g_dbus_connection_set_exit_on_close(session, FALSE); g_object_add_weak_pointer(G_OBJECT(session), (gpointer *)&session); system = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL); ASSERT_NE(nullptr, system); g_dbus_connection_set_exit_on_close(system, FALSE); g_object_add_weak_pointer(G_OBJECT(system), (gpointer *)&system); proxy = g_dbus_proxy_new_sync(session, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.Accounts", "/user", "org.freedesktop.DBus.Properties", NULL, NULL); ASSERT_NE(nullptr, proxy); } virtual void TearDown() { g_clear_object(&proxy); g_clear_object(&mock); g_clear_object(&service); g_object_unref(session); g_object_unref(system); #if 0 /* Accounts Service keeps a bunch of references around so we have to split the tests and can't check this :-( */ unsigned int cleartry = 0; while ((session != NULL || system != NULL) && cleartry < 100) { loop(100); cleartry++; } ASSERT_EQ(nullptr, session); ASSERT_EQ(nullptr, system); #endif } static gboolean timeout_cb (gpointer user_data) { GMainLoop * loop = static_cast(user_data); g_main_loop_quit(loop); return G_SOURCE_REMOVE; } void loop (unsigned int ms) { GMainLoop * loop = g_main_loop_new(NULL, FALSE); g_timeout_add(ms, timeout_cb, loop); g_main_loop_run(loop); g_main_loop_unref(loop); } static int unref_idle (gpointer user_data) { g_variant_unref(static_cast(user_data)); return G_SOURCE_REMOVE; } const gchar * get_property_string (const gchar * name) { GVariant * propval = g_dbus_proxy_call_sync(proxy, "Get", g_variant_new("(ss)", "com.canonical.indicator.sound.AccountsService", name), G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL ); if (propval == nullptr) { return nullptr; } /* NOTE: This is a bit of a hack, basically if main gets called the returned string becomes invalid. But it makes the test much easier to read :-/ */ g_idle_add(unref_idle, propval); const gchar * ret = NULL; GVariant * child = g_variant_get_child_value(propval, 0); GVariant * vstr = g_variant_get_variant(child); ret = g_variant_get_string(vstr, NULL); g_variant_unref(vstr); g_variant_unref(child); return ret; } }; TEST_F(AccountsServiceUserTest, BasicObject) { AccountsServiceUser * srv = accounts_service_user_new(); loop(50); g_object_unref(srv); } TEST_F(AccountsServiceUserTest, SetMediaPlayer) { MediaPlayerTrack * track = media_player_track_new("Artist", "Title", "Album", "http://art.url"); MediaPlayerMock * media = MEDIA_PLAYER_MOCK( g_object_new(TYPE_MEDIA_PLAYER_MOCK, "mock-id", "player-id", "mock-name", "Test Player", "mock-state", "Playing", "mock-is-running", TRUE, "mock-can-raise", FALSE, "mock-current-track", track, NULL) ); g_clear_object(&track); AccountsServiceUser * srv = accounts_service_user_new(); accounts_service_user_set_player(srv, MEDIA_PLAYER(media)); loop(500); /* Verify the values are on the other side of the bus */ EXPECT_STREQ("Test Player", get_property_string("PlayerName")); EXPECT_STREQ("Playing", get_property_string("State")); EXPECT_STREQ("Title", get_property_string("Title")); EXPECT_STREQ("Artist", get_property_string("Artist")); EXPECT_STREQ("Album", get_property_string("Album")); EXPECT_STREQ("http://art.url", get_property_string("ArtUrl")); /* Check changing the track info */ track = media_player_track_new("Artist-ish", "Title-like", "Psuedo Album", "http://fake.art.url"); media_player_mock_set_mock_current_track(media, track); g_clear_object(&track); accounts_service_user_set_player(srv, MEDIA_PLAYER(media)); loop(500); EXPECT_STREQ("Test Player", get_property_string("PlayerName")); EXPECT_STREQ("Playing", get_property_string("State")); EXPECT_STREQ("Title-like", get_property_string("Title")); EXPECT_STREQ("Artist-ish", get_property_string("Artist")); EXPECT_STREQ("Psuedo Album", get_property_string("Album")); EXPECT_STREQ("http://fake.art.url", get_property_string("ArtUrl")); /* Check to ensure the state can be updated */ media_player_set_state(MEDIA_PLAYER(media), "Paused"); accounts_service_user_set_player(srv, MEDIA_PLAYER(media)); loop(500); EXPECT_STREQ("Paused", get_property_string("State")); g_object_unref(media); g_object_unref(srv); } indicator-sound-12.10.2+14.04.20140401/tests/media-player-user.cc0000644000015301777760000001661712316644635024373 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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 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 #include #include "accounts-service-mock.h" extern "C" { #include "indicator-sound-service.h" } class MediaPlayerUserTest : public ::testing::Test { protected: DbusTestService * service = NULL; AccountsServiceMock service_mock; GDBusConnection * session = NULL; GDBusConnection * system = NULL; GDBusProxy * proxy = NULL; virtual void SetUp() { service = dbus_test_service_new(NULL); dbus_test_service_add_task(service, (DbusTestTask*)service_mock); dbus_test_service_start_tasks(service); g_setenv("DBUS_SYSTEM_BUS_ADDRESS", g_getenv("DBUS_SESSION_BUS_ADDRESS"), TRUE); session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); ASSERT_NE(nullptr, session); g_dbus_connection_set_exit_on_close(session, FALSE); g_object_add_weak_pointer(G_OBJECT(session), (gpointer *)&session); system = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL); ASSERT_NE(nullptr, system); g_dbus_connection_set_exit_on_close(system, FALSE); g_object_add_weak_pointer(G_OBJECT(system), (gpointer *)&system); proxy = g_dbus_proxy_new_sync(session, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.Accounts", "/user", "org.freedesktop.DBus.Properties", NULL, NULL); ASSERT_NE(nullptr, proxy); } virtual void TearDown() { g_clear_object(&proxy); g_clear_object(&service); g_object_unref(session); g_object_unref(system); #if 0 /* Accounts Service keeps a bunch of references around so we have to split the tests and can't check this :-( */ unsigned int cleartry = 0; while ((session != NULL || system != NULL) && cleartry < 100) { loop(100); cleartry++; } ASSERT_EQ(nullptr, session); ASSERT_EQ(nullptr, system); #endif } static gboolean timeout_cb (gpointer user_data) { GMainLoop * loop = static_cast(user_data); g_main_loop_quit(loop); return G_SOURCE_REMOVE; } void loop (unsigned int ms) { GMainLoop * loop = g_main_loop_new(NULL, FALSE); g_timeout_add(ms, timeout_cb, loop); g_main_loop_run(loop); g_main_loop_unref(loop); } void set_property (const gchar * name, GVariant * value) { dbus_test_dbus_mock_object_update_property((DbusTestDbusMock *)service_mock, service_mock.get_sound(), name, value, NULL); } }; TEST_F(MediaPlayerUserTest, BasicObject) { MediaPlayerUser * player = media_player_user_new("user"); ASSERT_NE(nullptr, player); /* Protected, but no useful data */ EXPECT_FALSE(media_player_get_is_running(MEDIA_PLAYER(player))); EXPECT_TRUE(media_player_get_can_raise(MEDIA_PLAYER(player))); EXPECT_STREQ("user", media_player_get_id(MEDIA_PLAYER(player))); EXPECT_STREQ("", media_player_get_name(MEDIA_PLAYER(player))); EXPECT_STREQ("", media_player_get_state(MEDIA_PLAYER(player))); EXPECT_EQ(nullptr, media_player_get_icon(MEDIA_PLAYER(player))); EXPECT_EQ(nullptr, media_player_get_current_track(MEDIA_PLAYER(player))); /* Get the proxy -- but no good data */ loop(100); /* Ensure even with the proxy we don't have anything */ EXPECT_FALSE(media_player_get_is_running(MEDIA_PLAYER(player))); EXPECT_TRUE(media_player_get_can_raise(MEDIA_PLAYER(player))); EXPECT_STREQ("user", media_player_get_id(MEDIA_PLAYER(player))); EXPECT_STREQ("", media_player_get_name(MEDIA_PLAYER(player))); EXPECT_STREQ("", media_player_get_state(MEDIA_PLAYER(player))); EXPECT_EQ(nullptr, media_player_get_icon(MEDIA_PLAYER(player))); EXPECT_EQ(nullptr, media_player_get_current_track(MEDIA_PLAYER(player))); g_clear_object(&player); } TEST_F(MediaPlayerUserTest, DataSet) { /* Put data into Acts */ set_property("Timestamp", g_variant_new_uint64(g_get_monotonic_time())); set_property("PlayerName", g_variant_new_string("The Player Formerly Known as Prince")); GIcon * in_icon = g_themed_icon_new_with_default_fallbacks("foo-bar-fallback"); set_property("PlayerIcon", g_variant_new_variant(g_icon_serialize(in_icon))); set_property("State", g_variant_new_string("Chillin'")); set_property("Title", g_variant_new_string("Dictator")); set_property("Artist", g_variant_new_string("Bansky")); set_property("Album", g_variant_new_string("Vinyl is dead")); set_property("ArtUrl", g_variant_new_string("http://art.url")); /* Build our media player */ MediaPlayerUser * player = media_player_user_new("user"); ASSERT_NE(nullptr, player); /* Get the proxy -- and it's precious precious data -- oh, my, precious! */ loop(100); /* Ensure even with the proxy we don't have anything */ EXPECT_TRUE(media_player_get_is_running(MEDIA_PLAYER(player))); EXPECT_TRUE(media_player_get_can_raise(MEDIA_PLAYER(player))); EXPECT_STREQ("user", media_player_get_id(MEDIA_PLAYER(player))); EXPECT_STREQ("The Player Formerly Known as Prince", media_player_get_name(MEDIA_PLAYER(player))); EXPECT_STREQ("Chillin'", media_player_get_state(MEDIA_PLAYER(player))); GIcon * out_icon = media_player_get_icon(MEDIA_PLAYER(player)); EXPECT_NE(nullptr, out_icon); EXPECT_TRUE(g_icon_equal(in_icon, out_icon)); // NOTE: No reference in 'out_icon' returned MediaPlayerTrack * track = media_player_get_current_track(MEDIA_PLAYER(player)); EXPECT_NE(nullptr, track); EXPECT_STREQ("Dictator", media_player_track_get_title(track)); EXPECT_STREQ("Bansky", media_player_track_get_artist(track)); EXPECT_STREQ("Vinyl is dead", media_player_track_get_album(track)); EXPECT_STREQ("http://art.url", media_player_track_get_art_url(track)); // NOTE: No reference in 'track' returned g_clear_object(&in_icon); g_clear_object(&player); } TEST_F(MediaPlayerUserTest, TimeoutTest) { /* Put data into Acts -- but 15 minutes ago */ set_property("Timestamp", g_variant_new_uint64(g_get_monotonic_time() - 15 * 60 * 1000 * 1000)); set_property("PlayerName", g_variant_new_string("The Player Formerly Known as Prince")); GIcon * in_icon = g_themed_icon_new_with_default_fallbacks("foo-bar-fallback"); set_property("PlayerIcon", g_variant_new_variant(g_icon_serialize(in_icon))); set_property("State", g_variant_new_string("Chillin'")); set_property("Title", g_variant_new_string("Dictator")); set_property("Artist", g_variant_new_string("Bansky")); set_property("Album", g_variant_new_string("Vinyl is dead")); set_property("ArtUrl", g_variant_new_string("http://art.url")); /* Build our media player */ MediaPlayerUser * player = media_player_user_new("user"); ASSERT_NE(nullptr, player); /* Get the proxy -- and the old data, so old, like forever */ loop(100); /* Ensure that we show up as not running */ EXPECT_FALSE(media_player_get_is_running(MEDIA_PLAYER(player))); /* Update to make running */ set_property("Timestamp", g_variant_new_uint64(g_get_monotonic_time())); loop(100); EXPECT_TRUE(media_player_get_is_running(MEDIA_PLAYER(player))); g_clear_object(&in_icon); g_clear_object(&player); } indicator-sound-12.10.2+14.04.20140401/tests/manual0000644000015301777760000000140412316644622021717 0ustar pbusernogroup00000000000000 Test-case indicator-sound/unity7-items-check
Log in to a Unity 7 user session
Go to the panel and click on the Sound indicator
Ensure there are items in the menu
Test-case indicator-sound/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 Sound indicator
Ensure there are items in the menu
Test-case indicator-sound/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 "Sound" is shown
Sound is at the top of the menu
The menu is populated with items
indicator-sound-12.10.2+14.04.20140401/tests/CMakeLists.txt0000644000015301777760000001003412316644657023266 0ustar pbusernogroup00000000000000 ########################### # Google Test ########################### include_directories(${GTEST_INCLUDE_DIR}) add_library (gtest STATIC ${GTEST_SOURCE_DIR}/gtest-all.cc ${GTEST_SOURCE_DIR}/gtest_main.cc) target_link_libraries(gtest ${GTEST_LIBS}) ########################### # Vala Mocks ########################### set(VALA_MOCKS_HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/vala-mocks.h") set(VALA_MOCKS_SYMBOLS_PATH "${CMAKE_CURRENT_BINARY_DIR}/vala-mocks.def") vala_init(vala-mocks DEPENDS indicator-sound-service-lib PACKAGES config gio-2.0 gio-unix-2.0 libxml-2.0 libpulse libpulse-mainloop-glib libnotify accounts-service indicator-sound-service OPTIONS --ccode --thread --vapidir=${CMAKE_BINARY_DIR}/src/ --vapidir=${CMAKE_SOURCE_DIR}/vapi/ --vapidir=. ) vala_add(vala-mocks media-player-mock.vala ) vala_finish(vala-mocks SOURCES vala_mocks_VALA_SOURCES OUTPUTS vala_mocks_VALA_C GENERATE_HEADER ${VALA_MOCKS_HEADER_PATH} GENERATE_SYMBOLS ${VALA_MOCKS_SYMBOLS_PATH} ) set_source_files_properties( ${vala_mocks_VALA_SOURCES} PROPERTIES HEADER_FILE_ONLY TRUE ) set( VALA_MOCKS_SOURCES ${vala_mocks_VALA_SOURCES} ${vala_mocks_VALA_C} ${VALA_MOCKS_SYMBOLS_PATH} ) add_definitions( -Wno-unused-but-set-variable ) add_library( vala-mocks-lib STATIC ${VALA_MOCKS_SOURCES} ) target_link_libraries( vala-mocks-lib indicator-sound-service-lib ) include_directories(${CMAKE_CURRENT_BINARY_DIR}) ########################### # Name Watch Test ########################### include_directories(${CMAKE_SOURCE_DIR}/src) add_executable (name-watch-test name-watch-test.cc ${CMAKE_SOURCE_DIR}/src/bus-watch-namespace.c) target_link_libraries (name-watch-test gtest ${SOUNDSERVICE_LIBRARIES}) add_test(name-watch-test name-watch-test) ########################### # Accounts Service User ########################### include_directories(${CMAKE_SOURCE_DIR}/src) add_executable (accounts-service-user-test accounts-service-user.cc) target_link_libraries ( accounts-service-user-test indicator-sound-service-lib vala-mocks-lib gtest ${SOUNDSERVICE_LIBRARIES} ${TEST_LIBRARIES} ) # Split tests to work around libaccountservice sucking add_test(accounts-service-user-test-basic accounts-service-user-test --gtest_filter=AccountsServiceUserTest.BasicObject ) add_test(accounts-service-user-test-player accounts-service-user-test --gtest_filter=AccountsServiceUserTest.SetMediaPlayer ) ########################### # Sound Menu ########################### include_directories(${CMAKE_SOURCE_DIR}/src) add_executable (sound-menu-test sound-menu.cc) target_link_libraries ( sound-menu-test indicator-sound-service-lib vala-mocks-lib gtest ${SOUNDSERVICE_LIBRARIES} ${TEST_LIBRARIES} ) add_test(sound-menu-test sound-menu-test) ########################### # Accounts Service User ########################### include_directories(${CMAKE_SOURCE_DIR}/src) add_executable (media-player-user-test media-player-user.cc) target_link_libraries ( media-player-user-test indicator-sound-service-lib vala-mocks-lib gtest ${SOUNDSERVICE_LIBRARIES} ${TEST_LIBRARIES} ) # Split tests to work around libaccountservice sucking add_test(media-player-user-test-basic media-player-user-test --gtest_filter=MediaPlayerUserTest.BasicObject ) add_test(media-player-user-test-dataset media-player-user-test --gtest_filter=MediaPlayerUserTest.DataSet ) add_test(media-player-user-test-timeout media-player-user-test --gtest_filter=MediaPlayerUserTest.TimeoutTest ) ########################### # Greeter List ########################### include_directories(${CMAKE_SOURCE_DIR}/src) add_executable (greeter-list-test greeter-list.cc) target_link_libraries ( greeter-list-test indicator-sound-service-lib vala-mocks-lib gtest ${SOUNDSERVICE_LIBRARIES} ${TEST_LIBRARIES} ) # Split tests to work around libaccountservice sucking add_test(greeter-list-test-basic greeter-list-test --gtest_filter=GreeterListTest.BasicObject ) add_test(greeter-list-test-iterator greeter-list-test --gtest_filter=GreeterListTest.BasicIterator ) indicator-sound-12.10.2+14.04.20140401/tests/name-watch-test.cc0000644000015301777760000001132112316644622024026 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 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 extern "C" { #include "bus-watch-namespace.h" } class NameWatchTest : public ::testing::Test { private: GTestDBus * testbus = NULL; protected: virtual void SetUp() { testbus = g_test_dbus_new(G_TEST_DBUS_NONE); g_test_dbus_up(testbus); } virtual void TearDown() { g_test_dbus_down(testbus); g_clear_object(&testbus); } static gboolean timeout_cb (gpointer user_data) { GMainLoop * loop = static_cast(user_data); g_main_loop_quit(loop); return G_SOURCE_REMOVE; } void loop (unsigned int ms) { GMainLoop * loop = g_main_loop_new(NULL, FALSE); g_timeout_add(ms, timeout_cb, loop); g_main_loop_run(loop); g_main_loop_unref(loop); } }; typedef struct { guint appeared; guint vanished; } callback_count_t; static void appeared_simple_cb (GDBusConnection * bus, const gchar * name, const gchar * owner, gpointer user_data) { callback_count_t * callback_count = static_cast(user_data); callback_count->appeared++; } static void vanished_simple_cb (GDBusConnection * bus, const gchar * name, gpointer user_data) { callback_count_t * callback_count = static_cast(user_data); callback_count->vanished++; } TEST_F(NameWatchTest, BaseWatch) { callback_count_t callback_count = {0}; guint ns_watch = bus_watch_namespace(G_BUS_TYPE_SESSION, "com.foo", appeared_simple_cb, vanished_simple_cb, &callback_count, NULL); guint name1 = g_bus_own_name(G_BUS_TYPE_SESSION, "com.foo.bar", G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL, NULL); guint name2 = g_bus_own_name(G_BUS_TYPE_SESSION, "com.foo.bar_too", G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL, NULL); loop(100); ASSERT_EQ(callback_count.appeared, 2); g_bus_unown_name(name1); g_bus_unown_name(name2); loop(100); ASSERT_EQ(callback_count.vanished, 2); bus_unwatch_namespace(ns_watch); } TEST_F(NameWatchTest, NonMatches) { callback_count_t callback_count = {0}; guint ns_watch = bus_watch_namespace(G_BUS_TYPE_SESSION, "com.foo", appeared_simple_cb, vanished_simple_cb, &callback_count, NULL); guint name1 = g_bus_own_name(G_BUS_TYPE_SESSION, "com.foobar.bar", G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL, NULL); guint name2 = g_bus_own_name(G_BUS_TYPE_SESSION, "com.bar.com.foo", G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL, NULL); loop(100); ASSERT_EQ(callback_count.appeared, 0); g_bus_unown_name(name1); g_bus_unown_name(name2); loop(100); ASSERT_EQ(callback_count.vanished, 0); bus_unwatch_namespace(ns_watch); } TEST_F(NameWatchTest, StartupNames) { guint name1 = g_bus_own_name(G_BUS_TYPE_SESSION, "com.foo.bar", G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, NULL, NULL); loop(100); callback_count_t callback_count = {0}; guint ns_watch = bus_watch_namespace(G_BUS_TYPE_SESSION, "com.foo", appeared_simple_cb, vanished_simple_cb, &callback_count, NULL); loop(100); ASSERT_EQ(callback_count.appeared, 1); g_bus_unown_name(name1); loop(100); ASSERT_EQ(callback_count.vanished, 1); bus_unwatch_namespace(ns_watch); } indicator-sound-12.10.2+14.04.20140401/data/0000755000015301777760000000000012316645302020263 5ustar pbusernogroup00000000000000indicator-sound-12.10.2+14.04.20140401/data/com.canonical.indicator.sound.AccountsService.xml0000644000015301777760000000356212316644622031724 0ustar pbusernogroup00000000000000 indicator-sound-12.10.2+14.04.20140401/data/50-com.canonical.indicator.sound.AccountsService.pkla0000644000015301777760000000030412316644622032264 0ustar pbusernogroup00000000000000[Allow LightDM to set Unity AccountsService fields] Identity=unix-user:lightdm Action=com.canonical.indicator.sound.AccountsService.ModifyAnyUser ResultActive=yes ResultInactive=yes ResultAny=yes indicator-sound-12.10.2+14.04.20140401/data/com.canonical.indicator.sound.AccountsService.policy0000644000015301777760000000206412316644622032417 0ustar pbusernogroup00000000000000 Set properties of own user Authentication is required to set one's own indicator sound properties. yes yes yes Set properties of any user Authentication is required to set another user's indicator sound properties. no no no indicator-sound-12.10.2+14.04.20140401/data/indicator-sound.desktop.in0000644000015301777760000000040112316644622025364 0ustar pbusernogroup00000000000000[Desktop Entry] Type=Application Name=Indicator Sound Exec=@CMAKE_INSTALL_FULL_LIBEXECDIR@/indicator-sound/indicator-sound-service OnlyShowIn=Unity;XFCE;GNOME; NoDisplay=true StartupNotify=false Terminal=false AutostartCondition=GNOME3 unless-session gnome indicator-sound-12.10.2+14.04.20140401/data/indicator-sound.conf.in0000644000015301777760000000034112316644622024643 0ustar pbusernogroup00000000000000description "Indicator Sound Service" start on indicator-services-start stop on desktop-end or indicator-services-end respawn respawn limit 2 10 exec @CMAKE_INSTALL_FULL_LIBEXECDIR@/indicator-sound/indicator-sound-service indicator-sound-12.10.2+14.04.20140401/data/com.canonical.indicator.sound.gschema.xml0000644000015301777760000000555512316644622030237 0ustar pbusernogroup00000000000000 A list of applications blacklisted from the sound menu [] Each media player which abides by the MPRIS2 spec will automatically appear in the menu. This array should contain the desktop file names (minus .desktop suffix) of applications which do not want to be included in the sound menu. A list of applications which at some point have registered with the sound menu [] Each media player which abides by the MPRIS2 spec will automatically appear in the menu. This array should contain the desktop file names (minus .desktop suffix) of applications which have at some point appeared in the menU. This allows the menu remember and display offlined applications. A list of applications that will have player controls visible all the time [ 'rhythmbox' ] A list of applications that will have player controls visible all the time false Initial setting for global mute (mute all) on the menu On start up volume should not be muted. true Initial setting for showing notify-osd notification on scroll volume-change When using the mouse scroll-wheel over the indicator-sound icon, the volume changes. Enabling this setting, every scroll volume-change a notify-osd bubble with the updated volume value will be shown (if supported by your notification daemon). true Whether or not to show the sound indicator in the menu bar. Whether or not to show the sound indicator in the menu bar. true Whether or not to export the currently playing song to the greeter. If enabled the sound indicator will export the current player and song to the greeter so that it can be shown if the user is selected and the sound menu is shown. indicator-sound-12.10.2+14.04.20140401/data/CMakeLists.txt0000644000015301777760000000503512316644622023032 0ustar pbusernogroup00000000000000 include(UseGSettings) ########################### # Indicator service ########################### set( INDICATOR_DIR "${CMAKE_INSTALL_DATADIR}/unity/indicators" CACHE FILEPATH "Indicator directory" ) install( FILES "com.canonical.indicator.sound" DESTINATION "${INDICATOR_DIR}" ) ########################### # Upstart Job ########################### set( INDICATOR_SOUND_CONF "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound.conf" ) configure_file( "indicator-sound.conf.in" ${INDICATOR_SOUND_CONF} @ONLY ) install( FILES "${INDICATOR_SOUND_CONF}" DESTINATION "${CMAKE_INSTALL_DATADIR}/upstart/sessions/" ) ########################### # XDG Autostart ########################### set( INDICATOR_SOUND_XDG_AUTOSTART "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound.desktop" ) configure_file( "indicator-sound.desktop.in" ${INDICATOR_SOUND_XDG_AUTOSTART} @ONLY ) install( FILES "${INDICATOR_SOUND_XDG_AUTOSTART}" DESTINATION "/etc/xdg/autostart" ) ########################### # Upstart XDG Autostart Override ########################### set( INDICATOR_SOUND_UPSTART_XDG_AUTOSTART "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound.upstart.desktop" ) configure_file( "indicator-sound.upstart.desktop.in" ${INDICATOR_SOUND_UPSTART_XDG_AUTOSTART} @ONLY ) install( FILES "${INDICATOR_SOUND_UPSTART_XDG_AUTOSTART}" DESTINATION "${CMAKE_INSTALL_DATADIR}/upstart/xdg/autostart" RENAME "indicator-sound.desktop" ) ########################### # GSettings ########################### add_schema ("com.canonical.indicator.sound.gschema.xml") ########################### # Accounts Service ########################### set(POLKIT_LIB_DIR "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/polkit-1") set(POLKIT_DATA_DIR "${CMAKE_INSTALL_PREFIX}/share/polkit-1") set(DBUS_IFACE_DIR "${CMAKE_INSTALL_PREFIX}/share/dbus-1/interfaces") set(ACCOUNTS_IFACE_DIR "${CMAKE_INSTALL_PREFIX}/share/accountsservice/interfaces") install(FILES com.canonical.indicator.sound.AccountsService.xml DESTINATION "${DBUS_IFACE_DIR}" ) # Create accountsservice symlink for above dbus interface install(CODE " execute_process(COMMAND mkdir -p \"\$ENV{DESTDIR}${ACCOUNTS_IFACE_DIR}\") execute_process(COMMAND ln -sf ../../dbus-1/interfaces/com.canonical.indicator.sound.AccountsService.xml \"\$ENV{DESTDIR}${ACCOUNTS_IFACE_DIR}\") ") install(FILES com.canonical.indicator.sound.AccountsService.policy DESTINATION "${POLKIT_DATA_DIR}/actions" ) install(FILES 50-com.canonical.indicator.sound.AccountsService.pkla DESTINATION "${POLKIT_LIB_DIR}/localauthority/10-vendor.d" ) indicator-sound-12.10.2+14.04.20140401/data/indicator-sound.upstart.desktop.in0000644000015301777760000000033012316644622027066 0ustar pbusernogroup00000000000000[Desktop Entry] Type=Application Name=Indicator Sound Exec=@CMAKE_INSTALL_FULL_LIBEXECDIR@/indicator-sound/indicator-sound-service OnlyShowIn=Unity;XFCE; NoDisplay=true StartupNotify=false Terminal=false Hidden=true indicator-sound-12.10.2+14.04.20140401/data/com.canonical.indicator.sound0000644000015301777760000000100212316644622026011 0ustar pbusernogroup00000000000000[Indicator Service] Name=indicator-sound ObjectPath=/com/canonical/indicator/sound Position=30 [desktop] ObjectPath=/com/canonical/indicator/sound/desktop [phone] ObjectPath=/com/canonical/indicator/sound/phone [desktop_greeter] ObjectPath=/com/canonical/indicator/sound/desktop_greeter [desktop_lockscreen] ObjectPath=/com/canonical/indicator/sound/desktop_greeter [ubiquity] ObjectPath=/com/canonical/indicator/sound/desktop_greeter [phone_greeter] ObjectPath=/com/canonical/indicator/sound/phone_greeter indicator-sound-12.10.2+14.04.20140401/NEWS0000644000015301777760000000050512316644622020055 0ustar pbusernogroup0000000000000012.10.1 - Don't include in library code - Remove GTK+ 2 build rules from configure.ac 12.10.0 - Allow setting preferred media players through a settings key. (LP #1014955) - Fix sound indicator not working after Amarok close. (LP #992262) - Explicit handling of Ardour - Fix deprecated GTK+ API calls indicator-sound-12.10.2+14.04.20140401/config.h.in0000644000015301777760000000154612316644622021407 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 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 INDICATOR_SOUND_CONFIG_H_ #define INDICATOR_SOUND_CONFIG_H_ #define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@" #define GNOMELOCALEDIR "@GNOMELOCALEDIR@" #endif // INDICATOR_SOUND_CONFIG_H_ indicator-sound-12.10.2+14.04.20140401/po/0000755000015301777760000000000012316645302017770 5ustar pbusernogroup00000000000000indicator-sound-12.10.2+14.04.20140401/po/POTFILES.in0000644000015301777760000000006712316644622021554 0ustar pbusernogroup00000000000000[encoding: UTF-8] src/service.vala src/sound-menu.vala indicator-sound-12.10.2+14.04.20140401/ChangeLog0000644000015301777760000000000012316644622021116 0ustar pbusernogroup00000000000000indicator-sound-12.10.2+14.04.20140401/vapi/0000755000015301777760000000000012316645302020311 5ustar pbusernogroup00000000000000indicator-sound-12.10.2+14.04.20140401/vapi/bus-watcher.vapi0000644000015301777760000000205512316644622023424 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 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 */ namespace BusWatcher { [CCode (cheader_filename = "bus-watch-namespace.h", cname = "bus_watch_namespace")] public static uint watch_namespace (GLib.BusType bus_type, string name_space, [CCode (delegate_target_pos = 4.9)] owned GLib.BusNameAppearedCallback? name_appeared, [CCode (delegate_target_pos = 4.9)] owned GLib.BusNameVanishedCallback? name_vanished); } indicator-sound-12.10.2+14.04.20140401/vapi/config.vapi0000644000015301777760000000044112316644622022442 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-sound-12.10.2+14.04.20140401/vapi/url-dispatcher.vapi0000644000015301777760000000043412316644622024125 0ustar pbusernogroup00000000000000[CCode (cprefix="", lower_case_cprefix="", cheader_filename="liburl-dispatcher-1/url-dispatcher.h")] namespace UrlDispatch { public delegate void DispatchCallback (); [CCode (cname = "url_dispatch_send")] public static void send (string url, DispatchCallback? func = null); } indicator-sound-12.10.2+14.04.20140401/CMakeLists.txt0000644000015301777760000000370512316644622022123 0ustar pbusernogroup00000000000000project(indicator-sound 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-sound) set(GNOMELOCALEDIR "${CMAKE_INSTALL_FULL_DATADIR}/locale") add_definitions( -DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}" ) find_package(PkgConfig REQUIRED) include(GNUInstallDirs) include(Coverage) include(UseVala) # 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(SOURCE_DIR "${CMAKE_SOURCE_DIR}/src") set(SOURCE_BINARY_DIR "${CMAKE_BINARY_DIR}/src") set(PULSE_AUDIO_REQUIRED_VERSION 0.9.19) set(GIO_2_0_REQUIRED_VERSION 2.25.13) set(URL_DISPATCHER_1_REQUIRED_VERSION 1) pkg_check_modules( PULSEAUDIO REQUIRED libpulse-mainloop-glib>=${PULSE_AUDIO_REQUIRED_VERSION} gio-unix-2.0>=${GIO_2_0_REQUIRED_VERSION} url-dispatcher-1>=${URL_DISPATCHER_1_REQUIRED_VERSION} ) include_directories(${PULSEAUDIO_INCLUDE_DIRS}) pkg_check_modules( SOUNDSERVICE REQUIRED gee-1.0 gio-2.0>=${GIO_2_0_REQUIRED_VERSION} gio-unix-2.0 gthread-2.0 libxml-2.0 libnotify accountsservice ) include_directories(${SOUNDSERVICE_INCLUDE_DIRS}) pkg_check_modules( TEST REQUIRED dbustest-1 ) include_directories(${TEST_INCLUDE_DIRS}) find_package(Vala 0.20) find_package(GObjectIntrospection 0.9.12) include_directories(${SOURCE_DIR}) include_directories(${SOURCE_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" "${CMAKE_CURRENT_BINARY_DIR}/config.h" ) add_subdirectory(data) add_subdirectory(src) enable_testing() set (GTEST_SOURCE_DIR /usr/src/gtest/src) set (GTEST_INCLUDE_DIR ${GTEST_SOURCE_DIR}/..) set (GTEST_LIBS -lpthread) add_subdirectory(tests) indicator-sound-12.10.2+14.04.20140401/MERGE-REVIEW0000644000015301777760000000141212316644622021135 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-sound/unity8* * If the description says this effects the desktop profile: * Run tests indicator-sound/unity7* indicator-sound-12.10.2+14.04.20140401/COPYING0000644000015301777760000010437412316644622020422 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-sound-12.10.2+14.04.20140401/src/0000755000015301777760000000000012316645302020141 5ustar pbusernogroup00000000000000indicator-sound-12.10.2+14.04.20140401/src/bus-watch-namespace.c0000644000015301777760000002505112316644622024143 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 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: Lars Uebernickel */ #include #include #include "bus-watch-namespace.h" typedef struct { guint id; gchar *name_space; GBusNameAppearedCallback appeared_handler; GBusNameVanishedCallback vanished_handler; gpointer user_data; GDestroyNotify user_data_destroy; GDBusConnection *connection; GCancellable *cancellable; GHashTable *names; guint subscription_id; } NamespaceWatcher; typedef struct { NamespaceWatcher *watcher; gchar *name; } GetNameOwnerData; static guint namespace_watcher_next_id; static GHashTable *namespace_watcher_watchers; static void namespace_watcher_stop (gpointer data) { NamespaceWatcher *watcher = data; g_cancellable_cancel (watcher->cancellable); g_object_unref (watcher->cancellable); if (watcher->subscription_id) g_dbus_connection_signal_unsubscribe (watcher->connection, watcher->subscription_id); if (watcher->vanished_handler) { GHashTableIter it; const gchar *name; g_hash_table_iter_init (&it, watcher->names); while (g_hash_table_iter_next (&it, (gpointer *) &name, NULL)) watcher->vanished_handler (watcher->connection, name, watcher->user_data); } if (watcher->user_data_destroy) watcher->user_data_destroy (watcher->user_data); if (watcher->connection) { g_signal_handlers_disconnect_by_func (watcher->connection, namespace_watcher_stop, watcher); g_object_unref (watcher->connection); } g_hash_table_unref (watcher->names); g_hash_table_remove (namespace_watcher_watchers, GUINT_TO_POINTER (watcher->id)); if (g_hash_table_size (namespace_watcher_watchers) == 0) g_clear_pointer (&namespace_watcher_watchers, g_hash_table_destroy); g_free (watcher->name_space); g_free (watcher); } static void namespace_watcher_name_appeared (NamespaceWatcher *watcher, const gchar *name, const gchar *owner) { /* There's a race between NameOwnerChanged signals arriving and the * ListNames/GetNameOwner sequence returning, so this function might * be called more than once for the same name. To ensure that * appeared_handler is only called once for each name, it is only * called when inserting the name into watcher->names (each name is * only inserted once there). */ if (g_hash_table_contains (watcher->names, name)) return; g_hash_table_add (watcher->names, g_strdup (name)); if (watcher->appeared_handler) watcher->appeared_handler (watcher->connection, name, owner, watcher->user_data); } static void namespace_watcher_name_vanished (NamespaceWatcher *watcher, const gchar *name) { if (g_hash_table_remove (watcher->names, name) && watcher->vanished_handler) watcher->vanished_handler (watcher->connection, name, watcher->user_data); } static gboolean dbus_name_has_namespace (const gchar *name, const gchar *name_space) { gint len_name; gint len_namespace; len_name = strlen (name); len_namespace = strlen (name_space); if (len_name < len_namespace) return FALSE; if (memcmp (name_space, name, len_namespace) != 0) return FALSE; return len_namespace == len_name || name[len_namespace] == '.'; } static void name_owner_changed (GDBusConnection *connection, const gchar *sender_name, const gchar *object_path, const gchar *interface_name, const gchar *signal_name, GVariant *parameters, gpointer user_data) { NamespaceWatcher *watcher = user_data; const gchar *name; const gchar *old_owner; const gchar *new_owner; g_variant_get (parameters, "(&s&s&s)", &name, &old_owner, &new_owner); if (old_owner[0] != '\0') namespace_watcher_name_vanished (watcher, name); if (new_owner[0] != '\0') namespace_watcher_name_appeared (watcher, name, new_owner); } static void got_name_owner (GObject *object, GAsyncResult *result, gpointer user_data) { GetNameOwnerData *data = user_data; GError *error = NULL; GVariant *reply; const gchar *owner; reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (object), result, &error); if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_error_free (error); goto out; } if (reply == NULL) { if (!g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_OWNER)) g_warning ("bus_watch_namespace: error calling org.freedesktop.DBus.GetNameOwner: %s", error->message); g_error_free (error); goto out; } g_variant_get (reply, "(&s)", &owner); namespace_watcher_name_appeared (data->watcher, data->name, owner); g_variant_unref (reply); out: g_free (data->name); g_slice_free (GetNameOwnerData, data); } static void names_listed (GObject *object, GAsyncResult *result, gpointer user_data) { NamespaceWatcher *watcher; GError *error = NULL; GVariant *reply; GVariantIter *iter; const gchar *name; reply = g_dbus_connection_call_finish (G_DBUS_CONNECTION (object), result, &error); if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_error_free (error); return; } watcher = user_data; if (reply == NULL) { g_warning ("bus_watch_namespace: error calling org.freedesktop.DBus.ListNames: %s", error->message); g_error_free (error); return; } g_variant_get (reply, "(as)", &iter); while (g_variant_iter_next (iter, "&s", &name)) { if (dbus_name_has_namespace (name, watcher->name_space)) { GetNameOwnerData *data = g_slice_new (GetNameOwnerData); data->watcher = watcher; data->name = g_strdup (name); g_dbus_connection_call (watcher->connection, "org.freedesktop.DBus", "/", "org.freedesktop.DBus", "GetNameOwner", g_variant_new ("(s)", name), G_VARIANT_TYPE ("(s)"), G_DBUS_CALL_FLAGS_NONE, -1, watcher->cancellable, got_name_owner, data); } } g_variant_iter_free (iter); g_variant_unref (reply); } static void connection_closed (GDBusConnection *connection, gboolean remote_peer_vanished, GError *error, gpointer user_data) { NamespaceWatcher *watcher = user_data; namespace_watcher_stop (watcher); } static void got_bus (GObject *object, GAsyncResult *result, gpointer user_data) { GDBusConnection *connection; NamespaceWatcher *watcher; GError *error = NULL; connection = g_bus_get_finish (result, &error); if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) { g_error_free (error); return; } watcher = user_data; if (connection == NULL) { namespace_watcher_stop (watcher); return; } watcher->connection = connection; g_signal_connect (watcher->connection, "closed", G_CALLBACK (connection_closed), watcher); watcher->subscription_id = g_dbus_connection_signal_subscribe (watcher->connection, "org.freedesktop.DBus", "org.freedesktop.DBus", "NameOwnerChanged", "/org/freedesktop/DBus", watcher->name_space, G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE, name_owner_changed, watcher, NULL); g_dbus_connection_call (watcher->connection, "org.freedesktop.DBus", "/", "org.freedesktop.DBus", "ListNames", NULL, G_VARIANT_TYPE ("(as)"), G_DBUS_CALL_FLAGS_NONE, -1, watcher->cancellable, names_listed, watcher); } guint bus_watch_namespace (GBusType bus_type, const gchar *name_space, GBusNameAppearedCallback appeared_handler, GBusNameVanishedCallback vanished_handler, gpointer user_data, GDestroyNotify user_data_destroy) { NamespaceWatcher *watcher; /* same rules for interfaces and well-known names */ g_return_val_if_fail (name_space != NULL && g_dbus_is_interface_name (name_space), 0); g_return_val_if_fail (appeared_handler || vanished_handler, 0); watcher = g_new0 (NamespaceWatcher, 1); watcher->id = namespace_watcher_next_id++; watcher->name_space = g_strdup (name_space); watcher->appeared_handler = appeared_handler; watcher->vanished_handler = vanished_handler; watcher->user_data = user_data; watcher->user_data_destroy = user_data_destroy; watcher->cancellable = g_cancellable_new (); watcher->names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); if (namespace_watcher_watchers == NULL) namespace_watcher_watchers = g_hash_table_new (g_direct_hash, g_direct_equal); g_hash_table_insert (namespace_watcher_watchers, GUINT_TO_POINTER (watcher->id), watcher); g_bus_get (bus_type, watcher->cancellable, got_bus, watcher); return watcher->id; } void bus_unwatch_namespace (guint id) { /* namespace_watcher_stop() might have already removed the watcher * with @id in the case of a connection error. Thus, this function * doesn't warn when @id is absent from the hash table. */ if (namespace_watcher_watchers) { NamespaceWatcher *watcher; watcher = g_hash_table_lookup (namespace_watcher_watchers, GUINT_TO_POINTER (id)); if (watcher) { /* make sure vanished() is not called as a result of this function */ g_hash_table_remove_all (watcher->names); namespace_watcher_stop (watcher); } } } indicator-sound-12.10.2+14.04.20140401/src/volume-control.vala0000644000015301777760000003307212316644622024004 0ustar pbusernogroup00000000000000/* * -*- Mode:Vala; indent-tabs-mode:t; tab-width:4; encoding:utf8 -*- * 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 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: * Alberto Ruiz */ using PulseAudio; [CCode(cname="pa_cvolume_set", cheader_filename = "pulse/volume.h")] extern unowned PulseAudio.CVolume? vol_set (PulseAudio.CVolume? cv, uint channels, PulseAudio.Volume v); [DBus (name="com.canonical.UnityGreeter.List")] interface GreeterListInterface : Object { public abstract async string get_active_entry () throws IOError; public signal void entry_selected (string entry_name); } public class VolumeControl : Object { /* this is static to ensure it being freed after @context (loop does not have ref counting) */ private static PulseAudio.GLibMainLoop loop; private uint _reconnect_timer = 0; private PulseAudio.Context context; private bool _mute = true; private bool _is_playing = false; private double _volume = 0.0; private double _mic_volume = 0.0; private DBusProxy _user_proxy; private GreeterListInterface _greeter_proxy; private Cancellable _mute_cancellable; private Cancellable _volume_cancellable; public signal void volume_changed (double v); public signal void mic_volume_changed (double v); /** true when connected to the pulse server */ public bool ready { get; set; } /** true when a microphone is active **/ public bool active_mic { get; private set; default = false; } public VolumeControl () { if (loop == null) loop = new PulseAudio.GLibMainLoop (); _mute_cancellable = new Cancellable (); _volume_cancellable = new Cancellable (); setup_accountsservice.begin (); this.reconnect_to_pulse (); } ~VolumeControl () { if (_reconnect_timer != 0) { Source.remove (_reconnect_timer); _reconnect_timer = 0; } } /* PulseAudio logic*/ private void context_events_cb (Context c, Context.SubscriptionEventType t, uint32 index) { switch (t & Context.SubscriptionEventType.FACILITY_MASK) { case Context.SubscriptionEventType.SINK: update_sink (); break; case Context.SubscriptionEventType.SOURCE: update_source (); break; case Context.SubscriptionEventType.SOURCE_OUTPUT: switch (t & Context.SubscriptionEventType.TYPE_MASK) { case Context.SubscriptionEventType.NEW: c.get_source_output_info (index, source_output_info_cb); break; case Context.SubscriptionEventType.REMOVE: this.active_mic = false; break; } break; } } private void sink_info_cb_for_props (Context c, SinkInfo? i, int eol) { if (i == null) return; if (_mute != (bool)i.mute) { _mute = (bool)i.mute; this.notify_property ("mute"); } var playing = (i.state == PulseAudio.SinkState.RUNNING); if (_is_playing != playing) { _is_playing = playing; this.notify_property ("is-playing"); } if (_volume != volume_to_double (i.volume.values[0])) { _volume = volume_to_double (i.volume.values[0]); volume_changed (_volume); } } private void source_info_cb (Context c, SourceInfo? i, int eol) { if (i == null) return; if (_mic_volume != volume_to_double (i.volume.values[0])) { _mic_volume = volume_to_double (i.volume.values[0]); mic_volume_changed (_mic_volume); } } private void server_info_cb_for_props (Context c, ServerInfo? i) { if (i == null) return; context.get_sink_info_by_name (i.default_sink_name, sink_info_cb_for_props); } private void update_sink () { context.get_server_info (server_info_cb_for_props); } private void update_source_get_server_info_cb (PulseAudio.Context c, PulseAudio.ServerInfo? i) { if (i != null) context.get_source_info_by_name (i.default_source_name, source_info_cb); } private void update_source () { context.get_server_info (update_source_get_server_info_cb); } private void source_output_info_cb (Context c, SourceOutputInfo? i, int eol) { if (i == null) return; var role = i.proplist.gets (PulseAudio.Proplist.PROP_MEDIA_ROLE); if (role == "phone" || role == "production") this.active_mic = true; } private void context_state_callback (Context c) { switch (c.get_state ()) { case Context.State.READY: c.subscribe (PulseAudio.Context.SubscriptionMask.SINK | PulseAudio.Context.SubscriptionMask.SOURCE | PulseAudio.Context.SubscriptionMask.SOURCE_OUTPUT); c.set_subscribe_callback (context_events_cb); update_sink (); update_source (); this.ready = true; break; case Context.State.FAILED: case Context.State.TERMINATED: if (_reconnect_timer == 0) _reconnect_timer = Timeout.add_seconds (2, reconnect_timeout); break; default: this.ready = false; break; } } bool reconnect_timeout () { _reconnect_timer = 0; reconnect_to_pulse (); return false; // G_SOURCE_REMOVE } void reconnect_to_pulse () { if (this.ready) { this.context.disconnect (); this.context = null; this.ready = false; } var props = new Proplist (); props.sets (Proplist.PROP_APPLICATION_NAME, "Ubuntu Audio Settings"); props.sets (Proplist.PROP_APPLICATION_ID, "com.canonical.settings.sound"); props.sets (Proplist.PROP_APPLICATION_ICON_NAME, "multimedia-volume-control"); props.sets (Proplist.PROP_APPLICATION_VERSION, "0.1"); this.context = new PulseAudio.Context (loop.get_api(), null, props); this.context.set_state_callback (context_state_callback); if (context.connect(null, Context.Flags.NOFAIL, null) < 0) warning( "pa_context_connect() failed: %s\n", PulseAudio.strerror(context.errno())); } void sink_info_list_callback_set_mute (PulseAudio.Context context, PulseAudio.SinkInfo? sink, int eol) { if (sink != null) context.set_sink_mute_by_index (sink.index, true, null); } void sink_info_list_callback_unset_mute (PulseAudio.Context context, PulseAudio.SinkInfo? sink, int eol) { if (sink != null) context.set_sink_mute_by_index (sink.index, false, null); } /* Mute operations */ bool set_mute_internal (bool mute) { return_val_if_fail (context.get_state () == Context.State.READY, false); if (_mute != mute) { if (mute) context.get_sink_info_list (sink_info_list_callback_set_mute); else context.get_sink_info_list (sink_info_list_callback_unset_mute); return true; } else { return false; } } public void set_mute (bool mute) { if (set_mute_internal (mute)) sync_mute_to_accountsservice.begin (mute); } public void toggle_mute () { this.set_mute (!this._mute); } public bool mute { get { return this._mute; } } public bool is_playing { get { return this._is_playing; } } /* Volume operations */ private static PulseAudio.Volume double_to_volume (double vol) { double tmp = (double)(PulseAudio.Volume.NORM - PulseAudio.Volume.MUTED) * vol; return (PulseAudio.Volume)tmp + PulseAudio.Volume.MUTED; } private static double volume_to_double (PulseAudio.Volume vol) { double tmp = (double)(vol - PulseAudio.Volume.MUTED); return tmp / (double)(PulseAudio.Volume.NORM - PulseAudio.Volume.MUTED); } private void set_volume_success_cb (Context c, int success) { if ((bool)success) volume_changed (_volume); } private void sink_info_set_volume_cb (Context c, SinkInfo? i, int eol) { if (i == null) return; unowned CVolume cvol = vol_set (i.volume, 1, double_to_volume (_volume)); c.set_sink_volume_by_index (i.index, cvol, set_volume_success_cb); } private void server_info_cb_for_set_volume (Context c, ServerInfo? i) { if (i == null) { warning ("Could not get PulseAudio server info"); return; } context.get_sink_info_by_name (i.default_sink_name, sink_info_set_volume_cb); } bool set_volume_internal (double volume) { return_val_if_fail (context.get_state () == Context.State.READY, false); if (_volume != volume) { _volume = volume; context.get_server_info (server_info_cb_for_set_volume); return true; } else { return false; } } public void set_volume (double volume) { if (set_volume_internal (volume)) sync_volume_to_accountsservice.begin (volume); } void set_mic_volume_success_cb (Context c, int success) { if ((bool)success) mic_volume_changed (_mic_volume); } void set_mic_volume_get_server_info_cb (PulseAudio.Context c, PulseAudio.ServerInfo? i) { if (i != null) { unowned CVolume cvol = CVolume (); cvol = vol_set (cvol, 1, double_to_volume (_mic_volume)); c.set_source_volume_by_name (i.default_source_name, cvol, set_mic_volume_success_cb); } } public void set_mic_volume (double volume) { return_if_fail (context.get_state () == Context.State.READY); _mic_volume = volume; context.get_server_info (set_mic_volume_get_server_info_cb); } public double get_volume () { return _volume; } public double get_mic_volume () { return _mic_volume; } /* AccountsService operations */ private void accountsservice_props_changed_cb (DBusProxy proxy, Variant changed_properties, string[] invalidated_properties) { Variant volume_variant = changed_properties.lookup_value ("Volume", new VariantType ("d")); if (volume_variant != null) { var volume = volume_variant.get_double (); if (volume >= 0) set_volume_internal (volume); } Variant mute_variant = changed_properties.lookup_value ("Muted", new VariantType ("b")); if (mute_variant != null) { var mute = mute_variant.get_boolean (); set_mute_internal (mute); } } private async void setup_user_proxy (string? username_in = null) { var username = username_in; _user_proxy = null; // Look up currently selected greeter user, if asked if (username == null) { try { username = yield _greeter_proxy.get_active_entry (); if (username == "" || username == null) return; } catch (GLib.Error e) { warning ("unable to find Accounts path for user %s: %s", username, e.message); return; } } // Get master AccountsService object DBusProxy accounts_proxy; try { accounts_proxy = yield DBusProxy.create_for_bus (BusType.SYSTEM, DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS, null, "org.freedesktop.Accounts", "/org/freedesktop/Accounts", "org.freedesktop.Accounts"); } catch (GLib.Error e) { warning ("unable to get greeter proxy: %s", e.message); return; } // Find user's AccountsService object try { var user_path_variant = yield accounts_proxy.call ("FindUserByName", new Variant ("(s)", username), DBusCallFlags.NONE, -1); string user_path; user_path_variant.get ("(o)", out user_path); _user_proxy = yield DBusProxy.create_for_bus (BusType.SYSTEM, DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, "org.freedesktop.Accounts", user_path, "com.ubuntu.AccountsService.Sound"); } catch (GLib.Error e) { warning ("unable to find Accounts path for user %s: %s", username, e.message); return; } // Get current values and listen for changes _user_proxy.g_properties_changed.connect (accountsservice_props_changed_cb); var props_variant = yield _user_proxy.get_connection ().call (_user_proxy.get_name (), _user_proxy.get_object_path (), "org.freedesktop.DBus.Properties", "GetAll", new Variant ("(s)", _user_proxy.get_interface_name ()), null, DBusCallFlags.NONE, -1); Variant props; props_variant.get ("(@a{sv})", out props); accountsservice_props_changed_cb(_user_proxy, props, null); } private void greeter_user_changed (string username) { setup_user_proxy.begin (username); } private async void setup_accountsservice () { if (Environment.get_variable ("XDG_SESSION_CLASS") == "greeter") { try { _greeter_proxy = yield Bus.get_proxy (BusType.SESSION, "com.canonical.UnityGreeter", "/list"); } catch (GLib.Error e) { warning ("unable to get greeter proxy: %s", e.message); return; } _greeter_proxy.entry_selected.connect (greeter_user_changed); yield setup_user_proxy (); } else { // We are in a user session. We just need our own proxy var username = Environment.get_variable ("USER"); if (username != "" && username != null) { yield setup_user_proxy (username); } } } private async void sync_mute_to_accountsservice (bool mute) { if (_user_proxy == null) return; _mute_cancellable.cancel (); _mute_cancellable.reset (); try { yield _user_proxy.get_connection ().call (_user_proxy.get_name (), _user_proxy.get_object_path (), "org.freedesktop.DBus.Properties", "Set", new Variant ("(ssv)", _user_proxy.get_interface_name (), "Muted", new Variant ("b", mute)), null, DBusCallFlags.NONE, -1, _mute_cancellable); } catch (GLib.Error e) { warning ("unable to sync mute to AccountsService: %s", e.message); } } private async void sync_volume_to_accountsservice (double volume) { if (_user_proxy == null) return; _volume_cancellable.cancel (); _volume_cancellable.reset (); try { yield _user_proxy.get_connection ().call (_user_proxy.get_name (), _user_proxy.get_object_path (), "org.freedesktop.DBus.Properties", "Set", new Variant ("(ssv)", _user_proxy.get_interface_name (), "Volume", new Variant ("d", volume)), null, DBusCallFlags.NONE, -1, _volume_cancellable); } catch (GLib.Error e) { warning ("unable to sync volume to AccountsService: %s", e.message); } } } indicator-sound-12.10.2+14.04.20140401/src/media-player-user.vala0000644000015301777760000001667412316644622024355 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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 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 */ public class MediaPlayerUser : MediaPlayer { Act.UserManager accounts_manager = Act.UserManager.get_default(); string username; Act.User? actuser = null; AccountsServiceSoundSettings? proxy = null; GreeterBroadcast? greeter = null; HashTable properties_queued = new HashTable(str_hash, str_equal); uint properties_timeout = 0; /* Grab the user from the Accounts service and, when it is loaded then set up a proxy to its sound settings */ public MediaPlayerUser(string user) { username = user; actuser = accounts_manager.get_user(user); actuser.notify["is-loaded"].connect(() => { debug("User loaded"); this.proxy = null; Bus.get_proxy.begin ( BusType.SYSTEM, "org.freedesktop.Accounts", actuser.get_object_path(), DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, new_proxy); }); Bus.get_proxy.begin ( BusType.SYSTEM, "com.canonical.Unity.Greeter.Broadcast", "/com/canonical/Unity/Greeter/Broadcast", DBusProxyFlags.NONE, null, greeter_proxy_new); } ~MediaPlayerUser () { if (properties_timeout != 0) { Source.remove(properties_timeout); properties_timeout = 0; } } /* Ensure that we've collected all the changes so that we only signal once for variables like 'track' */ bool properties_idle () { properties_timeout = 0; properties_queued.@foreach((key, value) => { debug("Notifying '%s' changed", key); this.notify_property(key); }); properties_queued.remove_all(); /* Remove source */ return false; } /* Turns the DBus names into the object properties */ void queue_property_notification (string dbus_property_name) { if (properties_timeout == 0) { properties_timeout = Idle.add(properties_idle); } switch (dbus_property_name) { case "Timestamp": properties_queued.insert("name", true); properties_queued.insert("icon", true); properties_queued.insert("state", true); properties_queued.insert("current-track", true); properties_queued.insert("is-running", true); break; case "PlayerName": properties_queued.insert("name", true); break; case "PlayerIcon": properties_queued.insert("icon", true); break; case "State": properties_queued.insert("state", true); break; case "Title": case "Artist": case "Album": case "ArtUrl": properties_queued.insert("current-track", true); break; } } void new_proxy (GLib.Object? obj, AsyncResult res) { try { this.proxy = Bus.get_proxy.end (res); var gproxy = this.proxy as DBusProxy; gproxy.g_properties_changed.connect ((proxy, changed, invalidated) => { string key = ""; Variant value; VariantIter iter = new VariantIter(changed); while (iter.next("{sv}", &key, &value)) { queue_property_notification(key); } foreach (var invalid in invalidated) { queue_property_notification(invalid); } }); debug("Notifying player is ready for user: %s", this.username); this.notify_property("is-running"); } catch (Error e) { this.proxy = null; warning("Unable to get proxy to user '%s' sound settings: %s", username, e.message); } } bool proxy_is_valid () { if (this.proxy == null) { return false; } /* More than 10 minutes old */ if (this.proxy.timestamp < GLib.get_monotonic_time() - 10 * 60 * 1000 * 1000) { return false; } return true; } public override string id { get { return username; } } /* These values come from the proxy */ string name_cache; public override string name { get { if (proxy_is_valid()) { name_cache = this.proxy.player_name; debug("Player Name: %s", name_cache); return name_cache; } else { return ""; } } } string state_cache; public override string state { get { if (proxy_is_valid()) { state_cache = this.proxy.state; debug("State: %s", state_cache); return state_cache; } else { return ""; } } set { } } Icon icon_cache; public override Icon? icon { get { if (proxy_is_valid()) { icon_cache = Icon.deserialize(this.proxy.player_icon); return icon_cache; } else { return null; } } } /* Placeholder */ public override string dbus_name { get { return ""; } } /* If it's shown externally it's running */ public override bool is_running { get { return proxy_is_valid(); } } /* A bit weird. Not sure how we should handle this. */ public override bool can_raise { get { return true; } } /* Fill out the track based on the values in the proxy */ MediaPlayer.Track track_cache; public override MediaPlayer.Track? current_track { get { if (proxy_is_valid()) { track_cache = new MediaPlayer.Track( this.proxy.artist, this.proxy.title, this.proxy.album, this.proxy.art_url ); return track_cache; } else { return null; } } set { } } void greeter_proxy_new (GLib.Object? obj, AsyncResult res) { try { this.greeter = Bus.get_proxy.end (res); } catch (Error e) { this.greeter = null; warning("Unable to get greeter proxy: %s", e.message); } } /* Control functions through unity-greeter-session-broadcast */ public override void activate () { /* TODO: */ } public override void play_pause () { debug("Play Pause for user: %s", this.username); if (this.greeter != null) { this.greeter.RequestSoundPlayPause.begin(this.username, (obj, res) => { try { (obj as GreeterBroadcast).RequestSoundPlayPause.end(res); } catch (Error e) { warning("Unable to send play pause: %s", e.message); } }); } else { warning("No unity-greeter-session-broadcast to send play-pause"); } } public override void next () { debug("Next for user: %s", this.username); if (this.greeter != null) { this.greeter.RequestSoundNext.begin(this.username, (obj, res) => { try { (obj as GreeterBroadcast).RequestSoundNext.end(res); } catch (Error e) { warning("Unable to send next: %s", e.message); } }); } else { warning("No unity-greeter-session-broadcast to send next"); } } public override void previous () { debug("Previous for user: %s", this.username); if (this.greeter != null) { this.greeter.RequestSoundPrev.begin(this.username, (obj, res) => { try { (obj as GreeterBroadcast).RequestSoundPrev.end(res); } catch (Error e) { warning("Unable to send previous: %s", e.message); } }); } else { warning("No unity-greeter-session-broadcast to send previous"); } } /* Play list functions are all null as we don't support the playlist feature on the greeter */ public override uint get_n_playlists() { return 0; } public override string get_playlist_id (int index) { return ""; } public override string get_playlist_name (int index) { return ""; } public override void activate_playlist_by_name (string playlist) { } } indicator-sound-12.10.2+14.04.20140401/src/service.vala0000644000015301777760000004055012316644711022455 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 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 */ public class IndicatorSound.Service: Object { public Service (MediaPlayerList playerlist) { this.settings = new Settings ("com.canonical.indicator.sound"); this.sharedsettings = new Settings ("com.ubuntu.sound"); this.settings.bind ("visible", this, "visible", SettingsBindFlags.GET); this.notify["visible"].connect ( () => this.update_root_icon () ); this.volume_control = new VolumeControl (); this.players = playerlist; this.players.player_added.connect (this.player_added); this.players.player_removed.connect (this.player_removed); this.actions = new SimpleActionGroup (); this.actions.add_action_entries (action_entries, this); this.actions.add_action (this.create_mute_action ()); this.actions.add_action (this.create_volume_action ()); this.actions.add_action (this.create_mic_volume_action ()); this.menus = new HashTable (str_hash, str_equal); this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS)); this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE)); this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); this.menus.@foreach ( (profile, menu) => { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); }); /* Setup handling for the greeter-export setting */ this.settings.changed["greeter-export"].connect( () => this.build_accountsservice() ); build_accountsservice(); this.sync_preferred_players (); this.settings.changed["interested-media-players"].connect ( () => { this.sync_preferred_players (); }); if (settings.get_boolean ("show-notify-osd-on-scroll")) { List caps = Notify.get_server_caps (); if (caps.find_custom ("x-canonical-private-synchronous", strcmp) != null) { this.notification = new Notify.Notification ("indicator-sound", "", ""); this.notification.set_hint_string ("x-canonical-private-synchronous", "indicator-sound"); } } sharedsettings.bind ("allow-amplified-volume", this, "allow-amplified-volume", SettingsBindFlags.GET); } ~Service() { if (this.sound_was_blocked_timeout_id > 0) { Source.remove (this.sound_was_blocked_timeout_id); this.sound_was_blocked_timeout_id = 0; } } void build_accountsservice () { clear_acts_player(); this.accounts_service = null; /* If we're not exporting, don't build anything */ if (!this.settings.get_boolean("greeter-export")) { debug("Accounts service export disabled due to user setting"); return; } /* If we're on the greeter, don't export */ if (GLib.Environment.get_user_name() == "lightdm") { debug("Accounts service export disabled due to being used on the greeter"); return; } this.accounts_service = new AccountsServiceUser(); this.eventually_update_player_actions(); } void clear_acts_player () { /* NOTE: This is a bit of a hack to ensure that accounts service doesn't continue to export the player by keeping a ref in the timer */ if (this.accounts_service != null) this.accounts_service.player = null; } public int run () { if (this.loop != null) { warning ("service is already running"); return 1; } Bus.own_name (BusType.SESSION, "com.canonical.indicator.sound", BusNameOwnerFlags.NONE, this.bus_acquired, null, this.name_lost); this.loop = new MainLoop (null, false); GLib.Unix.signal_add(GLib.ProcessSignal.TERM, () => { debug("SIGTERM recieved, stopping our mainloop"); this.loop.quit(); return false; }); this.loop.run (); clear_acts_player(); return 0; } public bool visible { get; set; } public bool allow_amplified_volume { get { return this.max_volume > 1.0; } set { if (value) { /* from pulse/volume.h: #define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0)) */ this.max_volume = (double)PulseAudio.Volume.sw_from_dB(11.0) / PulseAudio.Volume.NORM; } else { this.max_volume = 1.0; } /* Normalize volume, because the volume action's state is [0.0, 1.0], see create_volume_action() */ this.actions.change_action_state ("volume", this.volume_control.get_volume () / this.max_volume); } } const ActionEntry[] action_entries = { { "root", null, null, "@a{sv} {}", null }, { "scroll", activate_scroll_action, "i", null, null }, { "desktop-settings", activate_desktop_settings, null, null, null }, { "phone-settings", activate_phone_settings, null, null, null }, }; MainLoop loop; SimpleActionGroup actions; HashTable menus; Settings settings; Settings sharedsettings; VolumeControl volume_control; MediaPlayerList players; uint player_action_update_id; bool mute_blocks_sound; uint sound_was_blocked_timeout_id; Notify.Notification notification; bool syncing_preferred_players = false; AccountsServiceUser? accounts_service = null; /* Maximum volume as a scaling factor between the volume action's state and the value in * this.volume_control. See create_volume_action(). */ double max_volume = 1.0; const double volume_step_percentage = 0.06; void activate_scroll_action (SimpleAction action, Variant? param) { int delta = param.get_int32(); /* positive for up, negative for down */ double v = this.volume_control.get_volume () + volume_step_percentage * delta; this.volume_control.set_volume (v.clamp (0.0, this.max_volume)); if (this.notification != null) { string icon; if (v <= 0.0) icon = "notification-audio-volume-off"; else if (v <= 0.3) icon = "notification-audio-volume-low"; else if (v <= 0.7) icon = "notification-audio-volume-medium"; else icon = "notification-audio-volume-high"; this.notification.update ("indicator-sound", "", icon); this.notification.set_hint_int32 ("value", ((int32) (100 * v / this.max_volume)).clamp (-1, 101)); try { this.notification.show (); } catch (Error e) { warning ("unable to show notification: %s", e.message); } } } void activate_desktop_settings (SimpleAction action, Variant? param) { var env = Environment.get_variable ("DESKTOP_SESSION"); string cmd; if (env == "xubuntu" || env == "ubuntustudio") cmd = "pavucontrol"; else { if (Environment.get_variable ("XDG_CURRENT_DESKTOP") == "Unity" && Environment.find_program_in_path ("unity-control-center") != null) cmd = "unity-control-center sound"; else cmd = "gnome-control-center sound"; } try { Process.spawn_command_line_async (cmd); } catch (Error e) { warning ("unable to launch sound settings: %s", e.message); } } void activate_phone_settings (SimpleAction action, Variant? param) { UrlDispatch.send ("settings:///system/sound"); } /* Returns a serialized version of @icon_name suited for the panel */ static Variant serialize_themed_icon (string icon_name) { var icon = new ThemedIcon.with_default_fallbacks (icon_name); return icon.serialize (); } void update_root_icon () { double volume = this.volume_control.get_volume (); string icon; if (this.volume_control.mute) icon = this.mute_blocks_sound ? "audio-volume-muted-blocking-panel" : "audio-volume-muted-panel"; else if (volume <= 0.0) icon = "audio-volume-low-zero-panel"; else if (volume <= 0.3) icon = "audio-volume-low-panel"; else if (volume <= 0.7) icon = "audio-volume-medium-panel"; else icon = "audio-volume-high-panel"; string accessible_name; if (this.volume_control.mute) { accessible_name = _("Volume (muted)"); } else { int volume_int = (int)(volume * 100); accessible_name = "%s (%d%%)".printf (_("Volume"), volume_int); } var root_action = actions.lookup_action ("root") as SimpleAction; var builder = new VariantBuilder (new VariantType ("a{sv}")); builder.add ("{sv}", "title", new Variant.string (_("Sound"))); builder.add ("{sv}", "accessible-desc", new Variant.string (accessible_name)); builder.add ("{sv}", "icon", serialize_themed_icon (icon)); builder.add ("{sv}", "visible", new Variant.boolean (this.visible)); root_action.set_state (builder.end()); } Action create_mute_action () { var mute_action = new SimpleAction.stateful ("mute", null, new Variant.boolean (this.volume_control.mute)); mute_action.activate.connect ( (action, param) => { action.change_state (new Variant.boolean (!action.get_state ().get_boolean ())); }); mute_action.change_state.connect ( (action, val) => { volume_control.set_mute (val.get_boolean ()); }); this.volume_control.notify["mute"].connect ( () => { mute_action.set_state (new Variant.boolean (this.volume_control.mute)); this.update_root_icon (); }); this.volume_control.notify["is-playing"].connect( () => { if (!this.volume_control.mute) { this.mute_blocks_sound = false; return; } if (this.volume_control.is_playing) { this.mute_blocks_sound = true; } else if (this.mute_blocks_sound) { /* Continue to show the blocking icon five seconds after a player has tried to play something */ if (this.sound_was_blocked_timeout_id > 0) Source.remove (this.sound_was_blocked_timeout_id); this.sound_was_blocked_timeout_id = Timeout.add_seconds (5, () => { this.mute_blocks_sound = false; this.sound_was_blocked_timeout_id = 0; this.update_root_icon (); return false; }); } this.update_root_icon (); }); return mute_action; } void volume_changed (double volume) { var volume_action = this.actions.lookup_action ("volume") as SimpleAction; /* Normalize volume, because the volume action's state is [0.0, 1.0], see create_volume_action() */ volume_action.set_state (new Variant.double (volume / this.max_volume)); this.update_root_icon (); } Action create_volume_action () { /* The action's state is between be in [0.0, 1.0] instead of [0.0, * max_volume], so that we don't need to update the slider menu item * every time allow-amplified-volume is changed. Convert between the * two here, so that we always pass the full range into * volume_control.set_volume(). */ double volume = this.volume_control.get_volume () / this.max_volume; var volume_action = new SimpleAction.stateful ("volume", VariantType.INT32, new Variant.double (volume)); volume_action.change_state.connect ( (action, val) => { double v = val.get_double () * this.max_volume; volume_control.set_volume (v.clamp (0.0, this.max_volume)); }); /* activating this action changes the volume by the amount given in the parameter */ volume_action.activate.connect ( (action, param) => { int delta = param.get_int32 (); double v = volume_control.get_volume () + volume_step_percentage * delta; volume_control.set_volume (v.clamp (0.0, this.max_volume)); }); this.volume_control.volume_changed.connect (volume_changed); this.volume_control.bind_property ("ready", volume_action, "enabled", BindingFlags.SYNC_CREATE); return volume_action; } Action create_mic_volume_action () { var volume_action = new SimpleAction.stateful ("mic-volume", null, new Variant.double (this.volume_control.get_mic_volume ())); volume_action.change_state.connect ( (action, val) => { volume_control.set_mic_volume (val.get_double ()); }); this.volume_control.mic_volume_changed.connect ( (volume) => { volume_action.set_state (new Variant.double (volume)); }); this.volume_control.bind_property ("ready", volume_action, "enabled", BindingFlags.SYNC_CREATE); return volume_action; } void bus_acquired (DBusConnection connection, string name) { try { connection.export_action_group ("/com/canonical/indicator/sound", this.actions); } catch (Error e) { critical ("%s", e.message); } this.menus.@foreach ( (profile, menu) => menu.export (connection, @"/com/canonical/indicator/sound/$profile")); } void name_lost (DBusConnection connection, string name) { this.loop.quit (); } Variant action_state_for_player (MediaPlayer player) { var builder = new VariantBuilder (new VariantType ("a{sv}")); builder.add ("{sv}", "running", new Variant ("b", player.is_running)); builder.add ("{sv}", "state", new Variant ("s", player.state)); if (player.current_track != null) { builder.add ("{sv}", "title", new Variant ("s", player.current_track.title)); builder.add ("{sv}", "artist", new Variant ("s", player.current_track.artist)); builder.add ("{sv}", "album", new Variant ("s", player.current_track.album)); builder.add ("{sv}", "art-url", new Variant ("s", player.current_track.art_url)); } return builder.end (); } bool update_player_actions () { bool clear_accounts_player = true; foreach (var player in this.players) { SimpleAction? action = this.actions.lookup_action (player.id) as SimpleAction; if (action != null) { action.set_state (this.action_state_for_player (player)); action.set_enabled (player.can_raise); } /* If we're playing then put that data in accounts service */ if (player.is_running && accounts_service != null) { accounts_service.player = player; clear_accounts_player = false; } } if (clear_accounts_player) clear_acts_player(); this.player_action_update_id = 0; return false; } void eventually_update_player_actions () { if (player_action_update_id == 0) this.player_action_update_id = Idle.add (this.update_player_actions); } void sync_preferred_players () { this.syncing_preferred_players = true; this.players.sync (settings.get_strv ("interested-media-players")); this.syncing_preferred_players = false; } void update_preferred_players () { /* only write the key if we're not getting this call because we're syncing from the key right now */ if (!this.syncing_preferred_players) { var builder = new VariantBuilder (VariantType.STRING_ARRAY); foreach (var player in this.players) builder.add ("s", player.id); this.settings.set_value ("interested-media-players", builder.end ()); } } void player_added (MediaPlayer player) { this.menus.@foreach ( (profile, menu) => menu.add_player (player)); SimpleAction action = new SimpleAction.stateful (player.id, null, this.action_state_for_player (player)); action.set_enabled (player.can_raise); action.activate.connect ( () => { player.activate (); }); this.actions.add_action (action); var play_action = new SimpleAction.stateful ("play." + player.id, null, player.state); play_action.activate.connect ( () => player.play_pause () ); this.actions.add_action (play_action); player.notify["state"].connect ( (object, pspec) => { play_action.set_state (player.state); }); var next_action = new SimpleAction ("next." + player.id, null); next_action.activate.connect ( () => player.next () ); this.actions.add_action (next_action); var prev_action = new SimpleAction ("previous." + player.id, null); prev_action.activate.connect ( () => player.previous () ); this.actions.add_action (prev_action); var playlist_action = new SimpleAction ("play-playlist." + player.id, VariantType.STRING); playlist_action.activate.connect ( (parameter) => player.activate_playlist_by_name (parameter.get_string ()) ); this.actions.add_action (playlist_action); player.notify.connect (this.eventually_update_player_actions); this.update_preferred_players (); } void player_removed (MediaPlayer player) { this.actions.remove_action (player.id); this.actions.remove_action ("play." + player.id); this.actions.remove_action ("next." + player.id); this.actions.remove_action ("previous." + player.id); this.actions.remove_action ("play-playlist." + player.id); player.notify.disconnect (this.eventually_update_player_actions); this.menus.@foreach ( (profile, menu) => menu.remove_player (player)); this.update_preferred_players (); } } indicator-sound-12.10.2+14.04.20140401/src/sound-menu.vala0000644000015301777760000001752612316644622023117 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 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 */ public class SoundMenu: Object { public enum DisplayFlags { NONE = 0, SHOW_MUTE = 1, HIDE_INACTIVE_PLAYERS = 2, HIDE_PLAYERS = 4 } public SoundMenu (string? settings_action, DisplayFlags flags) { /* A sound menu always has at least two sections: the volume section (this.volume_section) * at the start of the menu, and the settings section at the end. Between those two, * it has a dynamic amount of player sections, one for each registered player. */ this.volume_section = new Menu (); if ((flags & DisplayFlags.SHOW_MUTE) != 0) volume_section.append (_("Mute"), "indicator.mute"); volume_section.append_item (this.create_slider_menu_item ("indicator.volume(0)", 0.0, 1.0, 0.01, "audio-volume-low-zero-panel", "audio-volume-high-panel")); this.menu = new Menu (); this.menu.append_section (null, volume_section); if (settings_action != null) { settings_shown = true; this.menu.append (_("Sound Settings…"), settings_action); } var root_item = new MenuItem (null, "indicator.root"); root_item.set_attribute ("x-canonical-type", "s", "com.canonical.indicator.root"); root_item.set_attribute ("x-canonical-scroll-action", "s", "indicator.scroll"); root_item.set_attribute ("x-canonical-secondary-action", "s", "indicator.mute"); root_item.set_submenu (this.menu); this.root = new Menu (); root.append_item (root_item); this.hide_players = (flags & DisplayFlags.HIDE_PLAYERS) != 0; this.hide_inactive = (flags & DisplayFlags.HIDE_INACTIVE_PLAYERS) != 0; this.notify_handlers = new HashTable (direct_hash, direct_equal); } public void export (DBusConnection connection, string object_path) { try { connection.export_menu_model (object_path, this.root); } catch (Error e) { critical ("%s", e.message); } } public bool show_mic_volume { get { return this.mic_volume_shown; } set { if (value && !this.mic_volume_shown) { var slider = this.create_slider_menu_item ("indicator.mic-volume", 0.0, 1.0, 0.01, "audio-input-microphone-low-zero-panel", "audio-input-microphone-high-panel"); volume_section.append_item (slider); this.mic_volume_shown = true; } else if (!value && this.mic_volume_shown) { this.volume_section.remove (this.volume_section.get_n_items () -1); this.mic_volume_shown = false; } } } public void add_player (MediaPlayer player) { if (this.notify_handlers.contains (player)) return; if (player.is_running || !this.hide_inactive) this.insert_player_section (player); this.update_playlists (player); var handler_id = player.notify["is-running"].connect ( () => { if (player.is_running) if (this.find_player_section(player) == -1) this.insert_player_section (player); else if (this.hide_inactive) this.remove_player_section (player); this.update_playlists (player); }); this.notify_handlers.insert (player, handler_id); player.playlists_changed.connect (this.update_playlists); } public void remove_player (MediaPlayer player) { this.remove_player_section (player); var id = this.notify_handlers.lookup(player); if (id != 0) { player.disconnect(id); } player.playlists_changed.disconnect (this.update_playlists); /* this'll drop our ref to it */ this.notify_handlers.remove (player); } public Menu root; public Menu menu; Menu volume_section; bool mic_volume_shown; bool settings_shown = false; bool hide_inactive; bool hide_players = false; HashTable notify_handlers; /* returns the position in this.menu of the section that's associated with @player */ int find_player_section (MediaPlayer player) { debug("Looking for player: %s", player.id); string action_name = @"indicator.$(player.id)"; int n = this.menu.get_n_items (); for (int i = 0; i < n; i++) { var section = this.menu.get_item_link (i, Menu.LINK_SECTION); if (section == null) continue; string action; section.get_item_attribute (0, "action", "s", out action); if (action == action_name) return i; } debug("Unable to find section for player: %s", player.id); return -1; } void insert_player_section (MediaPlayer player) { if (this.hide_players) return; var section = new Menu (); Icon icon; debug("Adding section for player: %s (%s)", player.id, player.is_running ? "running" : "not running"); icon = player.icon; if (icon == null) icon = new ThemedIcon.with_default_fallbacks ("application-default-icon"); var player_item = new MenuItem (player.name, "indicator." + player.id); player_item.set_attribute ("x-canonical-type", "s", "com.canonical.unity.media-player"); if (icon != null) player_item.set_attribute_value ("icon", icon.serialize ()); section.append_item (player_item); var playback_item = new MenuItem (null, null); playback_item.set_attribute ("x-canonical-type", "s", "com.canonical.unity.playback-item"); playback_item.set_attribute ("x-canonical-play-action", "s", "indicator.play." + player.id); playback_item.set_attribute ("x-canonical-next-action", "s", "indicator.next." + player.id); playback_item.set_attribute ("x-canonical-previous-action", "s", "indicator.previous." + player.id); section.append_item (playback_item); /* Add new players to the end of the player sections, just before the settings */ if (settings_shown) { this.menu.insert_section (this.menu.get_n_items () -1, null, section); } else { this.menu.append_section (null, section); } } void remove_player_section (MediaPlayer player) { if (this.hide_players) return; int index = this.find_player_section (player); if (index >= 0) this.menu.remove (index); } void update_playlists (MediaPlayer player) { int index = find_player_section (player); if (index < 0) return; var player_section = this.menu.get_item_link (index, Menu.LINK_SECTION) as Menu; /* if a section has three items, the playlists menu is in it */ if (player_section.get_n_items () == 3) player_section.remove (2); if (!player.is_running) return; var count = player.get_n_playlists (); if (count == 0) return; var playlists_section = new Menu (); for (int i = 0; i < count; i++) { var playlist_id = player.get_playlist_id (i); playlists_section.append (player.get_playlist_name (i), @"indicator.play-playlist.$(player.id)::$playlist_id"); } var submenu = new Menu (); submenu.append_section (null, playlists_section); player_section.append_submenu (_("Choose Playlist"), submenu); } MenuItem create_slider_menu_item (string action, double min, double max, double step, string min_icon_name, string max_icon_name) { var min_icon = new ThemedIcon.with_default_fallbacks (min_icon_name); var max_icon = new ThemedIcon.with_default_fallbacks (max_icon_name); var slider = new MenuItem (null, action); slider.set_attribute ("x-canonical-type", "s", "com.canonical.unity.slider"); slider.set_attribute_value ("min-icon", min_icon.serialize ()); slider.set_attribute_value ("max-icon", max_icon.serialize ()); slider.set_attribute ("min-value", "d", min); slider.set_attribute ("max-value", "d", max); slider.set_attribute ("step", "d", step); return slider; } } indicator-sound-12.10.2+14.04.20140401/src/Makefile.am.THIS0000644000015301777760000000173712316644622022757 0ustar pbusernogroup00000000000000pkglibexec_PROGRAMS = indicator-sound-service indicator_sound_service_SOURCES = \ service.vala \ main.vala \ volume-control.vala \ media-player.vala \ media-player-list.vala \ mpris2-interfaces.vala \ freedesktop-interfaces.vala \ sound-menu.vala \ bus-watch-namespace.c \ bus-watch-namespace.h indicator_sound_service_VALAFLAGS = \ --ccode \ --vapidir=$(top_srcdir)/vapi/ \ --vapidir=./ \ --thread \ --pkg config \ --pkg gio-2.0 \ --pkg gio-unix-2.0 \ --pkg libxml-2.0 \ --pkg libpulse \ --pkg libpulse-mainloop-glib \ --pkg bus-watcher \ --target-glib=2.36 # -w to disable warnings for vala-generated code indicator_sound_service_CFLAGS = $(PULSEAUDIO_CFLAGS) \ $(SOUNDSERVICE_CFLAGS) \ $(GCONF_CFLAGS) \ $(COVERAGE_CFLAGS) \ -DLIBEXECDIR=\"$(libexecdir)\" \ -w \ -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" indicator_sound_service_LDADD = $(PULSEAUDIO_LIBS) $(SOUNDSERVICE_LIBS) $(GCONF_LIBS) indicator_sound_service_LDFLAGS = $(COVERAGE_LDFLAGS) indicator-sound-12.10.2+14.04.20140401/src/media-player-list-greeter.vala0000644000015301777760000000657312316644730026002 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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 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 */ [DBus (name="com.canonical.UnityGreeter.List")] public interface UnityGreeterList : Object { public abstract async string get_active_entry () throws IOError; public signal void entry_selected (string entry_name); } public class MediaPlayerListGreeter : MediaPlayerList { string? selected_user = null; UnityGreeterList? proxy = null; HashTable players = new HashTable(str_hash, str_equal); public MediaPlayerListGreeter () { Bus.get_proxy.begin ( BusType.SESSION, "com.canonical.UnityGreeter", "/list", DBusProxyFlags.NONE, null, new_proxy); } void new_proxy (GLib.Object? obj, AsyncResult res) { try { this.proxy = Bus.get_proxy.end(res); this.proxy.entry_selected.connect(active_user_changed); this.proxy.get_active_entry.begin ((obj, res) => { try { var value = (obj as UnityGreeterList).get_active_entry.end(res); active_user_changed(value); } catch (Error e) { warning("Unable to get active entry: %s", e.message); } }); } catch (Error e) { this.proxy = null; warning("Unable to create proxy to the greeter: %s", e.message); } } void active_user_changed (string active_user) { /* No change, move along */ if (selected_user == active_user) { return; } debug(@"Active user changed to: $active_user"); var old_user = selected_user; /* Protect against a null user */ if (active_user != "" && active_user[0] != '*') { selected_user = active_user; } else { debug(@"Blocking active user change for '$active_user'"); selected_user = null; } if (selected_user != null && !players.contains(selected_user)) { players.insert(selected_user, new MediaPlayerUser(selected_user)); } if (old_user != null) { var old_player = players.lookup(old_user); debug("Removing player for user: %s", old_user); player_removed(old_player); } if (selected_user != null) { var new_player = players.lookup(selected_user); if (new_player != null) { debug("Adding player for user: %s", selected_user); player_added(new_player); } } } /* We need to have an iterator for the interface, but eh, we can only ever have one player for the current user */ public class Iterator : MediaPlayerList.Iterator { int i = 0; MediaPlayerListGreeter list; public Iterator (MediaPlayerListGreeter in_list) { list = in_list; } public override MediaPlayer? next_value () { MediaPlayer? retval = null; if (i == 0 && list.selected_user != null) { retval = list.players.lookup(list.selected_user); } i++; return retval; } } public override MediaPlayerList.Iterator iterator() { return new Iterator(this) as MediaPlayerList.Iterator; } } indicator-sound-12.10.2+14.04.20140401/src/greeter-broadcast.vala0000644000015301777760000000276212316644622024416 0ustar pbusernogroup00000000000000/* * Copyright 2014 © 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 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 */ [DBus (name = "com.canonical.Unity.Greeter.Broadcast")] public interface GreeterBroadcast : Object { // methods // unused public abstract async void RequestApplicationStart(string name, string appid) throws IOError; // unused public abstract async void RequestHomeShown(string name) throws IOError; public abstract async void RequestSoundPlayPause(string name) throws IOError; public abstract async void RequestSoundNext(string name) throws IOError; public abstract async void RequestSoundPrev(string name) throws IOError; // signals // unused public signal void StartApplication(string username, string appid); // unused public signal void ShowHome(string username); public signal void SoundPlayPause(string username); public signal void SoundNext(string username); public signal void SoundPrev(string username); } indicator-sound-12.10.2+14.04.20140401/src/freedesktop-interfaces.vala0000644000015301777760000000316612316644622025454 0ustar pbusernogroup00000000000000/* Copyright 2010 Canonical Ltd. Authors: Conor Curran 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 . */ [DBus (name = "org.freedesktop.DBus")] public interface FreeDesktopObject: Object { public abstract async string[] list_names() throws IOError; public abstract signal void name_owner_changed ( string name, string old_owner, string new_owner ); } [DBus (name = "org.freedesktop.DBus.Introspectable")] public interface FreeDesktopIntrospectable: Object { public abstract string Introspect() throws IOError; } [DBus (name = "org.freedesktop.DBus.Properties")] public interface FreeDesktopProperties : Object{ public signal void PropertiesChanged (string source, HashTable changed_properties, string[] invalid ); } public errordomain XmlError { FILE_NOT_FOUND, XML_DOCUMENT_EMPTY } const string FREEDESKTOP_SERVICE = "org.freedesktop.DBus"; const string FREEDESKTOP_OBJECT = "/org/freedesktop/DBus"; indicator-sound-12.10.2+14.04.20140401/src/main.c0000644000015301777760000000164712316644622021245 0ustar pbusernogroup00000000000000/* main.c generated by valac 0.22.1, the Vala compiler * generated from main.vala, do not modify */ #include #include #include #include "indicator-sound-service.h" #include "config.h" int main (int argc, char ** argv) { gint result = 0; IndicatorSoundService* service = NULL; bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); /* Initialize libnotify */ notify_init ("indicator-sound"); MediaPlayerList * playerlist = NULL; if (g_strcmp0("lightdm", g_get_user_name()) == 0) { playerlist = MEDIA_PLAYER_LIST(media_player_list_greeter_new()); } else { playerlist = MEDIA_PLAYER_LIST(media_player_list_mpris_new()); } service = indicator_sound_service_new (playerlist); result = indicator_sound_service_run (service); g_object_unref(playerlist); g_object_unref(service); return result; } indicator-sound-12.10.2+14.04.20140401/src/accounts-service-user.vala0000644000015301777760000001140112316644622025240 0ustar pbusernogroup00000000000000/* * Copyright 2014 © 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 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 */ public class AccountsServiceUser : Object { Act.UserManager accounts_manager = Act.UserManager.get_default(); Act.User? user = null; AccountsServiceSoundSettings? proxy = null; uint timer = 0; MediaPlayer? _player = null; GreeterBroadcast? greeter = null; public MediaPlayer? player { set { this._player = value; debug("New player: %s", this._player != null ? this._player.name : "Cleared"); /* No proxy, no settings to set */ if (this.proxy == null) { debug("Nothing written to Accounts Service, waiting on proxy"); return; } /* Always reset the timer */ if (this.timer != 0) { GLib.Source.remove(this.timer); this.timer = 0; } if (this._player == null) { debug("Clearing player data in accounts service"); /* Clear it */ this.proxy.player_name = ""; this.proxy.timestamp = 0; this.proxy.title = ""; this.proxy.artist = ""; this.proxy.album = ""; this.proxy.art_url = ""; var icon = new ThemedIcon.with_default_fallbacks ("application-default-icon"); this.proxy.player_icon = icon.serialize(); } else { this.proxy.timestamp = GLib.get_monotonic_time(); this.proxy.player_name = this._player.name; if (this._player.icon == null) { var icon = new ThemedIcon.with_default_fallbacks ("application-default-icon"); this.proxy.player_icon = icon.serialize(); } else { this.proxy.player_icon = this._player.icon.serialize(); } this.proxy.running = this._player.is_running; this.proxy.state = this._player.state; if (this._player.current_track != null) { this.proxy.title = this._player.current_track.title; this.proxy.artist = this._player.current_track.artist; this.proxy.album = this._player.current_track.album; this.proxy.art_url = this._player.current_track.art_url; } else { this.proxy.title = ""; this.proxy.artist = ""; this.proxy.album = ""; this.proxy.art_url = ""; } this.timer = GLib.Timeout.add_seconds(5 * 60, () => { debug("Writing timestamp"); this.proxy.timestamp = GLib.get_monotonic_time(); return true; }); } } get { return this._player; } } public AccountsServiceUser () { user = accounts_manager.get_user(GLib.Environment.get_user_name()); user.notify["is-loaded"].connect(() => user_loaded_changed()); user_loaded_changed(); Bus.get_proxy.begin ( BusType.SYSTEM, "com.canonical.Unity.Greeter.Broadcast", "/com/canonical/Unity/Greeter/Broadcast", DBusProxyFlags.NONE, null, greeter_proxy_new); } void user_loaded_changed () { debug("User loaded changed"); this.proxy = null; if (this.user.is_loaded) { Bus.get_proxy.begin ( BusType.SYSTEM, "org.freedesktop.Accounts", user.get_object_path(), DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, new_proxy); } } ~AccountsServiceUser () { debug("Account Service Object Finalizing"); this.player = null; if (this.timer != 0) { GLib.Source.remove(this.timer); this.timer = 0; } } void new_proxy (GLib.Object? obj, AsyncResult res) { try { this.proxy = Bus.get_proxy.end (res); this.player = _player; } catch (Error e) { this.proxy = null; warning("Unable to get proxy to user sound settings: %s", e.message); } } void greeter_proxy_new (GLib.Object? obj, AsyncResult res) { try { this.greeter = Bus.get_proxy.end (res); this.greeter.SoundPlayPause.connect((username) => { if (username != GLib.Environment.get_user_name()) return; if (this._player == null) return; this._player.play_pause(); }); this.greeter.SoundNext.connect((username) => { if (username != GLib.Environment.get_user_name()) return; if (this._player == null) return; this._player.next(); }); this.greeter.SoundPrev.connect((username) => { if (username != GLib.Environment.get_user_name()) return; if (this._player == null) return; this._player.previous(); }); } catch (Error e) { this.greeter = null; warning("Unable to get greeter proxy: %s", e.message); } } } indicator-sound-12.10.2+14.04.20140401/src/media-player-list-mpris.vala0000644000015301777760000001013512316644622025464 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 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 */ /** * MediaPlayerList is a list of media players that should appear in the sound menu. Its main responsibility is * to listen for MPRIS players on the bus and attach them to the corresponding %Player objects. */ public class MediaPlayerListMpris : MediaPlayerList { public MediaPlayerListMpris () { this._players = new HashTable (str_hash, str_equal); BusWatcher.watch_namespace (BusType.SESSION, "org.mpris.MediaPlayer2", this.player_appeared, this.player_disappeared); } /* only valid while the list is not changed */ public class Iterator : MediaPlayerList.Iterator { HashTableIter iter; public Iterator (MediaPlayerListMpris list) { this.iter = HashTableIter (list._players); } public override MediaPlayer? next_value () { MediaPlayerMpris? player; if (this.iter.next (null, out player)) return player as MediaPlayer; else return null; } } public override MediaPlayerList.Iterator iterator () { return new Iterator (this) as MediaPlayerList.Iterator; } /** * Adds the player associated with @desktop_id. Does nothing if such a player already exists. */ MediaPlayerMpris? insert (string desktop_id) { debug("Inserting player: %s", desktop_id); var id = desktop_id.has_suffix (".desktop") ? desktop_id : desktop_id + ".desktop"; MediaPlayerMpris? player = this._players.lookup (id); if (player == null) { var appinfo = new DesktopAppInfo (id); if (appinfo == null) { warning ("unable to find application '%s'", id); return null; } player = new MediaPlayerMpris (appinfo); this._players.insert (player.id, player); this.player_added (player); } return player; } /** * Removes the player associated with @desktop_id, unless it is currently running. */ void remove (string desktop_id) { MediaPlayer? player = this._players.lookup (desktop_id); if (player != null && !player.is_running) { this._players.remove (desktop_id); this.player_removed (player); } } /** * Synchronizes the player list with @desktop_ids. After this call, this list will only contain the players * in @desktop_ids. Players that were running but are not in @desktop_ids will remain in the list. */ public override void sync (string[] desktop_ids) { /* hash desktop_ids for faster lookup */ var hash = new HashTable (str_hash, str_equal); foreach (var id in desktop_ids) hash.add (id); /* remove players that are not desktop_ids */ foreach (var id in this._players.get_keys ()) { if (!hash.contains (id)) this.remove (id); } /* insert all players (insert() takes care of not adding a player twice */ foreach (var id in desktop_ids) this.insert (id); } HashTable _players; void player_appeared (DBusConnection connection, string name, string owner) { try { MprisRoot mpris2_root = Bus.get_proxy_sync (BusType.SESSION, name, MPRIS_MEDIA_PLAYER_PATH); var player = this.insert (mpris2_root.DesktopEntry); if (player != null) player.attach (mpris2_root, name); } catch (Error e) { warning ("unable to create mpris proxy for '%s': %s", name, e.message); } } void player_disappeared (DBusConnection connection, string dbus_name) { MediaPlayerMpris? player = this._players.find ( (name, player) => { return player.dbus_name == dbus_name; }); if (player != null) player.detach (); } } indicator-sound-12.10.2+14.04.20140401/src/mpris2-interfaces.vala0000644000015301777760000000555312316644622024357 0ustar pbusernogroup00000000000000/* Copyright 2010 Canonical Ltd. Authors: Conor Curran 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 . */ const string MPRIS_PREFIX = "org.mpris.MediaPlayer2."; const string MPRIS_MEDIA_PLAYER_PATH = "/org/mpris/MediaPlayer2"; [DBus (name = "org.mpris.MediaPlayer2")] public interface MprisRoot : Object { // properties public abstract bool HasTracklist{owned get; set;} public abstract bool CanQuit{owned get; set;} public abstract bool CanRaise{owned get; set;} public abstract string Identity{owned get; set;} public abstract string DesktopEntry{owned get; set;} // methods public abstract async void Quit() throws IOError; public abstract async void Raise() throws IOError; } [DBus (name = "org.mpris.MediaPlayer2.Player")] public interface MprisPlayer : Object { // properties public abstract HashTable Metadata{owned get; set;} public abstract int32 Position{owned get; set;} public abstract string PlaybackStatus{owned get; set;} // methods public abstract async void PlayPause() throws IOError; public abstract async void Next() throws IOError; public abstract async void Previous() throws IOError; public abstract async void Seek(int64 offset) throws IOError; // signals public signal void Seeked(int64 new_position); } // Playlist container public struct PlaylistDetails{ public ObjectPath? path; public string? name; public string? icon_path; } // Active playlist property container public struct ActivePlaylistContainer{ public bool valid; public PlaylistDetails? details; } [DBus (name = "org.mpris.MediaPlayer2.Playlists")] public interface MprisPlaylists : Object { //properties public abstract string[] Orderings{owned get; set;} public abstract uint32 PlaylistCount{owned get; set;} public abstract ActivePlaylistContainer? ActivePlaylist {owned get; set;} //methods public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError; public abstract async PlaylistDetails[]? GetPlaylists ( uint32 index, uint32 max_count, string order, bool reverse_order ) throws IOError; //signals public signal void PlaylistChanged (PlaylistDetails details); } indicator-sound-12.10.2+14.04.20140401/src/media-player.vala0000644000015301777760000000422612316644622023367 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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 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 */ public abstract class MediaPlayer : Object { public virtual string id { get { not_implemented(); return ""; } } public virtual string name { get { not_implemented(); return ""; } } public virtual string state { get { not_implemented(); return ""; } set { }} public virtual Icon? icon { get { not_implemented(); return null; } } public virtual string dbus_name { get { not_implemented(); return ""; } } public virtual bool is_running { get { not_implemented(); return false; } } public virtual bool can_raise { get { not_implemented(); return false; } } public class Track : Object { public string artist { get; construct; } public string title { get; construct; } public string album { get; construct; } public string art_url { get; construct; } public Track (string artist, string title, string album, string art_url) { Object (artist: artist, title: title, album: album, art_url: art_url); } } public virtual Track? current_track { get { not_implemented(); return null; } set { not_implemented(); } } public signal void playlists_changed (); public abstract void activate (); public abstract void play_pause (); public abstract void next (); public abstract void previous (); public abstract uint get_n_playlists(); public abstract string get_playlist_id (int index); public abstract string get_playlist_name (int index); public abstract void activate_playlist_by_name (string playlist); private void not_implemented () { warning("Property not implemented"); } } indicator-sound-12.10.2+14.04.20140401/src/CMakeLists.txt0000644000015301777760000000662712316644622022720 0ustar pbusernogroup00000000000000 ########################### # Vala Generation ########################### set(HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound-service.h") set(SYMBOLS_PATH "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound-service.def") set(VAPI_PATH "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound-service.vapi") vapi_gen(accounts-service LIBRARY accounts-service PACKAGES gio-2.0 INPUT /usr/share/gir-1.0/AccountsService-1.0.gir ) vala_init(indicator-sound-service DEPENDS accounts-service PACKAGES config gio-2.0 gio-unix-2.0 libxml-2.0 libpulse libpulse-mainloop-glib libnotify accounts-service OPTIONS --ccode --thread --vapidir=${CMAKE_SOURCE_DIR}/vapi/ --vapidir=. --pkg=url-dispatcher --pkg=bus-watcher ) vala_add(indicator-sound-service service.vala DEPENDS sound-menu volume-control media-player media-player-list mpris2-interfaces accounts-service-user ) vala_add(indicator-sound-service volume-control.vala ) vala_add(indicator-sound-service media-player.vala ) vala_add(indicator-sound-service media-player-mpris.vala DEPENDS media-player mpris2-interfaces ) vala_add(indicator-sound-service media-player-user.vala DEPENDS media-player accounts-service-sound-settings greeter-broadcast ) vala_add(indicator-sound-service media-player-list.vala DEPENDS media-player ) vala_add(indicator-sound-service media-player-list-mpris.vala DEPENDS media-player-list media-player media-player-mpris mpris2-interfaces ) vala_add(indicator-sound-service media-player-list-greeter.vala DEPENDS media-player-list media-player-user media-player ) vala_add(indicator-sound-service mpris2-interfaces.vala ) vala_add(indicator-sound-service freedesktop-interfaces.vala ) vala_add(indicator-sound-service sound-menu.vala DEPENDS media-player ) vala_add(indicator-sound-service accounts-service-user.vala DEPENDS media-player mpris2-interfaces accounts-service-sound-settings greeter-broadcast ) vala_add(indicator-sound-service accounts-service-sound-settings.vala ) vala_add(indicator-sound-service greeter-broadcast.vala ) vala_finish(indicator-sound-service SOURCES project_VALA_SOURCES OUTPUTS project_VALA_C GENERATE_HEADER ${HEADER_PATH} GENERATE_SYMBOLS ${SYMBOLS_PATH} GENERATE_VAPI ${VAPI_PATH} ) set_source_files_properties( ${project_VALA_SOURCES} PROPERTIES HEADER_FILE_ONLY TRUE ) set( INDICATOR_SOUND_SOURCES ${project_VALA_SOURCES} ${project_VALA_C} bus-watch-namespace.c ${SYMBOLS_PATH} ) ########################### # Lib ########################### add_definitions( -w ) add_library( indicator-sound-service-lib STATIC ${INDICATOR_SOUND_SOURCES} ) target_link_libraries( indicator-sound-service-lib ${PULSEAUDIO_LIBRARIES} ${SOUNDSERVICE_LIBRARIES} ) ########################### # Executable ########################### include_directories(${CMAKE_BINARY_DIR}) add_executable( indicator-sound-service-bin main.c ) set_target_properties( indicator-sound-service-bin PROPERTIES OUTPUT_NAME "indicator-sound-service" ) target_link_libraries( indicator-sound-service-bin indicator-sound-service-lib ) ########################### # Installation ########################### install( TARGETS indicator-sound-service-bin RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/indicator-sound/ ) indicator-sound-12.10.2+14.04.20140401/src/bus-watch-namespace.h0000644000015301777760000000246512316644622024154 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 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: Lars Uebernickel */ #ifndef __BUS_WATCH_NAMESPACE_H__ #define __BUS_WATCH_NAMESPACE_H__ #include guint bus_watch_namespace (GBusType bus_type, const gchar *name_space, GBusNameAppearedCallback appeared_handler, GBusNameVanishedCallback vanished_handler, gpointer user_data, GDestroyNotify user_data_destroy); void bus_unwatch_namespace (guint id); #endif indicator-sound-12.10.2+14.04.20140401/src/media-player-list.vala0000644000015301777760000000202012316644622024326 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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 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 */ public class MediaPlayerList { public class Iterator { public virtual MediaPlayer? next_value() { return null; } } public virtual Iterator iterator () { return new Iterator(); } public virtual void sync (string[] ids) { return; } public signal void player_added (MediaPlayer player); public signal void player_removed (MediaPlayer player); } indicator-sound-12.10.2+14.04.20140401/src/media-player-mpris.vala0000644000015301777760000002040012316644622024507 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 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 */ /** * MediaPlayerMpris represents an MRPIS-capable media player. */ public class MediaPlayerMpris: MediaPlayer { public MediaPlayerMpris (DesktopAppInfo appinfo) { this.appinfo = appinfo; } /** Desktop id of the player */ public override string id { get { return this.appinfo.get_id (); } } /** Display name of the player */ public override string name { get { return this.appinfo.get_name (); } } /** Application icon of the player */ public override Icon? icon { get { return this.appinfo.get_icon (); } } /** * True if an instance of the player is currently running. * * See also: attach(), detach() */ public override bool is_running { get { return this.proxy != null; } } /** Name of the player on the bus, if an instance is currently running */ public override string dbus_name { get { return this._dbus_name; } } public override string state { get; private set; default = "Paused"; } public override MediaPlayer.Track? current_track { get; set; } public override bool can_raise { get { return this.root != null ? this.root.CanRaise : true; } } /** * Attach this object to a process of the associated media player. The player must own @dbus_name and * implement the org.mpris.MediaPlayer2.Player interface. * * Only one player can be attached at any given time. Use detach() to detach a player. * * This method does not block. If it is successful, "is-running" will be set to %TRUE. */ public void attach (MprisRoot root, string dbus_name) { return_if_fail (this._dbus_name == null && this.proxy == null); this.root = root; this.notify_property ("can-raise"); this._dbus_name = dbus_name; Bus.get_proxy.begin (BusType.SESSION, dbus_name, "/org/mpris/MediaPlayer2", DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, got_proxy); Bus.get_proxy.begin (BusType.SESSION, dbus_name, "/org/mpris/MediaPlayer2", DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, got_playlists_proxy); } /** * Detach this object from a process running the associated media player. * * See also: attach() */ public void detach () { this.root = null; this.proxy = null; this._dbus_name = null; this.notify_property ("is-running"); this.notify_property ("can-raise"); this.state = "Paused"; this.current_track = null; } /** * Activate the associated media player. * * Note: this will _not_ call attach(), because it doesn't know on which dbus-name the player will appear. * Use attach() to attach this object to a running instance of the player. */ public override void activate () { try { if (this.proxy == null) { this.appinfo.launch (null, null); this.state = "Launching"; } else if (this.root != null && this.root.CanRaise) { this.root.Raise (); } } catch (Error e) { warning ("unable to activate %s: %s", appinfo.get_name (), e.message); } } /** * Toggles playing status. */ public override void play_pause () { if (this.proxy != null) { this.proxy.PlayPause.begin (); } else if (this.state != "Launching") { this.play_when_attached = true; this.activate (); } } /** * Skips to the next track. */ public override void next () { if (this.proxy != null) this.proxy.Next.begin (); } /** * Skips to the previous track. */ public override void previous () { if (this.proxy != null) this.proxy.Previous.begin (); } public override uint get_n_playlists () { return this.playlists != null ? this.playlists.length : 0; } public override string get_playlist_id (int index) { return_val_if_fail (index < this.playlists.length, ""); return this.playlists[index].path; } public override string get_playlist_name (int index) { return_val_if_fail (index < this.playlists.length, ""); return this.playlists[index].name; } public override void activate_playlist_by_name (string name) { if (this.playlists_proxy != null) this.playlists_proxy.ActivatePlaylist.begin (new ObjectPath (name)); } DesktopAppInfo appinfo; MprisPlayer? proxy; MprisPlaylists ?playlists_proxy; string _dbus_name; bool play_when_attached = false; MprisRoot root; PlaylistDetails[] playlists = null; void got_proxy (Object? obj, AsyncResult res) { try { this.proxy = Bus.get_proxy.end (res); /* Connecting to GDBusProxy's "g-properties-changed" signal here, because vala's dbus objects don't * emit notify signals */ var gproxy = this.proxy as DBusProxy; gproxy.g_properties_changed.connect (this.proxy_properties_changed); this.notify_property ("is-running"); this.state = this.proxy.PlaybackStatus; this.update_current_track (gproxy.get_cached_property ("Metadata")); if (this.play_when_attached) { /* wait a little before calling PlayPause, some players need some time to set themselves up */ Timeout.add (1000, () => { proxy.PlayPause.begin (); return false; } ); this.play_when_attached = false; } } catch (Error e) { this._dbus_name = null; warning ("unable to attach to media player: %s", e.message); } } void fetch_playlists () { /* The proxy is created even when the interface is not supported. GDBusProxy will return 0 for the PlaylistCount property in that case. */ if (this.playlists_proxy != null && this.playlists_proxy.PlaylistCount > 0) { this.playlists_proxy.GetPlaylists.begin (0, 100, "Alphabetical", false, (obj, res) => { try { this.playlists = playlists_proxy.GetPlaylists.end (res); this.playlists_changed (); } catch (Error e) { warning ("could not fetch playlists: %s", e.message); this.playlists = null; } }); } else { this.playlists = null; this.playlists_changed (); } } void got_playlists_proxy (Object? obj, AsyncResult res) { try { this.playlists_proxy = Bus.get_proxy.end (res); var gproxy = this.proxy as DBusProxy; gproxy.g_properties_changed.connect (this.playlists_proxy_properties_changed); } catch (Error e) { warning ("unable to create mpris plalists proxy: %s", e.message); return; } Timeout.add (500, () => { this.fetch_playlists (); return false; } ); } /* some players (e.g. Spotify) don't follow the spec closely and pass single strings in metadata fields * where an array of string is expected */ static string sanitize_metadata_value (Variant? v) { if (v == null) return ""; else if (v.is_of_type (VariantType.STRING)) return v.get_string (); else if (v.is_of_type (VariantType.STRING_ARRAY)) return string.joinv (",", v.get_strv ()); warn_if_reached (); return ""; } void proxy_properties_changed (DBusProxy proxy, Variant changed_properties, string[] invalidated_properties) { if (changed_properties.lookup ("PlaybackStatus", "s", null)) { this.state = this.proxy.PlaybackStatus; } var metadata = changed_properties.lookup_value ("Metadata", new VariantType ("a{sv}")); if (metadata != null) this.update_current_track (metadata); } void playlists_proxy_properties_changed (DBusProxy proxy, Variant changed_properties, string[] invalidated_properties) { if (changed_properties.lookup ("PlaylistCount", "u", null)) this.fetch_playlists (); } void update_current_track (Variant metadata) { if (metadata != null) { this.current_track = new Track ( sanitize_metadata_value (metadata.lookup_value ("xesam:artist", null)), sanitize_metadata_value (metadata.lookup_value ("xesam:title", null)), sanitize_metadata_value (metadata.lookup_value ("xesam:album", null)), sanitize_metadata_value (metadata.lookup_value ("mpris:artUrl", null)) ); } else { this.current_track = null; } } } indicator-sound-12.10.2+14.04.20140401/src/voip-input-menu-item.h0000644000015301777760000000540412316644622024331 0ustar pbusernogroup00000000000000/* Copyright 2011 Canonical Ltd. Authors: Conor Curran 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 . */ #ifndef __VOIP_INPUT_MENU_ITEM_H__ #define __VOIP_INPUT_MENU_ITEM_H__ #include #include #include #include "device.h" G_BEGIN_DECLS #define VOIP_INPUT_MENU_ITEM_TYPE (voip_input_menu_item_get_type ()) #define VOIP_INPUT_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), VOIP_INPUT_MENU_ITEM_TYPE, VoipInputMenuItem)) #define VOIP_INPUT_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), VOIP_INPUT_MENU_ITEM_TYPE, VoipInputMenuItemClass)) #define IS_VOIP_INPUT_MENU_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), VOIP_INPUT_MENU_ITEM_TYPE)) #define IS_VOIP_INPUT_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), VOIP_INPUT_MENU_ITEM_TYPE)) #define VOIP_INPUT_MENU_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), VOIP_INPUT_MENU_ITEM_TYPE, VoipInputMenuItemClass)) typedef struct _VoipInputMenuItem VoipInputMenuItem; typedef struct _VoipInputMenuItemClass VoipInputMenuItemClass; struct _VoipInputMenuItemClass { DbusmenuMenuitemClass parent_class; }; struct _VoipInputMenuItem { DbusmenuMenuitem parent; }; GType voip_input_menu_item_get_type (void); void voip_input_menu_item_update (VoipInputMenuItem* item, const pa_source_info* source); void voip_input_menu_item_enable (VoipInputMenuItem* item, gboolean active); gboolean voip_input_menu_item_is_interested (VoipInputMenuItem* item, gint source_output_index, gint client_index); gboolean voip_input_menu_item_is_active (VoipInputMenuItem* item); gboolean voip_input_menu_item_is_populated (VoipInputMenuItem* item); // TODO rename get source index gint voip_input_menu_item_get_index (VoipInputMenuItem* item); gint voip_input_menu_item_get_source_output_index (VoipInputMenuItem* item); void voip_input_menu_item_deactivate_source (VoipInputMenuItem* item, gboolean visible); void voip_input_menu_item_deactivate_voip_client (VoipInputMenuItem* item); VoipInputMenuItem* voip_input_menu_item_new (Device* sink); G_END_DECLS #endif indicator-sound-12.10.2+14.04.20140401/src/accounts-service-sound-settings.vala0000644000015301777760000000237112316644622027256 0ustar pbusernogroup00000000000000/* * Copyright 2014 © 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 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 */ [DBus (name = "com.canonical.indicator.sound.AccountsService")] public interface AccountsServiceSoundSettings : Object { // properties public abstract uint64 timestamp {owned get; set;} public abstract string player_name {owned get; set;} public abstract Variant player_icon {owned get; set;} public abstract bool running {owned get; set;} public abstract string state {owned get; set;} public abstract string title {owned get; set;} public abstract string artist {owned get; set;} public abstract string album {owned get; set;} public abstract string art_url {owned get; set;} } indicator-sound-12.10.2+14.04.20140401/AUTHORS0000644000015301777760000000015612316644622020430 0ustar pbusernogroup00000000000000Charles Kerr Ted Gould Cody Russell indicator-sound-12.10.2+14.04.20140401/README0000644000015301777760000000000012316644622020224 0ustar pbusernogroup00000000000000