From de76813c8421fd900e0d57038d28e8be693e33be Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Tue, 28 Nov 2017 08:47:03 +0000 Subject: Fork from Ubuntus' indicator-display project. --- .bzr-builddeb/default.conf | 2 - .bzrignore | 3 - CMakeLists.txt | 5 +- data/CMakeLists.txt | 28 ++++--- data/ayatana-indicator-display.conf.in | 9 +++ data/ayatana-indicator-display.override | 1 + data/ayatana-indicator-display.service.in | 8 ++ data/com.canonical.indicator.rotation_lock | 11 --- data/indicator-display.conf.in | 9 --- data/indicator-display.override | 1 - data/indicator-display.service.in | 8 -- data/org.ayatana.display.gschema.xml | 24 ++++++ data/org.ayatana.indicator.rotation_lock | 11 +++ debian/changelog | 9 +++ debian/control | 35 ++++----- debian/copyright | 7 ++ debian/indicator-display.maintscript | 1 - debian/rules | 14 +++- po/LINGUAS | 117 +++++++++++++++++++++++++++++ po/POTFILES.in | 9 +++ po/ayatana-indicator-display.pot | 43 +++++++++++ po/indicator-display.pot | 43 ----------- src/CMakeLists.txt | 6 +- src/dbus-names.h | 7 +- src/exporter.cpp | 8 +- src/greeter.cpp | 28 +++---- src/greeter.h | 12 +-- src/main.cpp | 2 +- src/rotation-lock.cpp | 6 +- tests/unit/CMakeLists.txt | 32 +++++++- tests/unit/greeter-test.cpp | 12 +-- tests/utils/CMakeLists.txt | 1 - tests/utils/mock-greeter.py | 41 ++++++++++ tests/utils/mock-unity-greeter.py | 41 ---------- update-po.sh | 29 +++++++ update-pot.sh | 19 +++++ 36 files changed, 448 insertions(+), 194 deletions(-) delete mode 100644 .bzr-builddeb/default.conf delete mode 100644 .bzrignore create mode 100644 data/ayatana-indicator-display.conf.in create mode 100644 data/ayatana-indicator-display.override create mode 100644 data/ayatana-indicator-display.service.in delete mode 100644 data/com.canonical.indicator.rotation_lock delete mode 100644 data/indicator-display.conf.in delete mode 100644 data/indicator-display.override delete mode 100644 data/indicator-display.service.in create mode 100644 data/org.ayatana.display.gschema.xml create mode 100644 data/org.ayatana.indicator.rotation_lock delete mode 100644 debian/indicator-display.maintscript create mode 100644 po/LINGUAS create mode 100644 po/POTFILES.in create mode 100644 po/ayatana-indicator-display.pot delete mode 100644 po/indicator-display.pot create mode 100644 tests/utils/mock-greeter.py delete mode 100644 tests/utils/mock-unity-greeter.py create mode 100755 update-po.sh create mode 100755 update-pot.sh diff --git a/.bzr-builddeb/default.conf b/.bzr-builddeb/default.conf deleted file mode 100644 index 6c96a98..0000000 --- a/.bzr-builddeb/default.conf +++ /dev/null @@ -1,2 +0,0 @@ -[BUILDDEB] -split = True diff --git a/.bzrignore b/.bzrignore deleted file mode 100644 index 4f05230..0000000 --- a/.bzrignore +++ /dev/null @@ -1,3 +0,0 @@ -build/ -po/Makefile.in.in -po/POTFILES.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 27a074b..ce70069 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,10 @@ -project(indicator-display LANGUAGES C CXX) +project(ayatana-indicator-display LANGUAGES C CXX) cmake_minimum_required(VERSION 2.8.9) list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) set(PACKAGE ${CMAKE_PROJECT_NAME}) -set(GETTEXT_PACKAGE indicator-display) +set(GETTEXT_PACKAGE "ayatana-indicator-display") add_definitions( -DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}" -DGNOMELOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}" @@ -82,4 +82,3 @@ ENABLE_COVERAGE_REPORT( TESTS ${COVERAGE_TEST_TARGETS} FILTER /usr/include ${CMAKE_BINARY_DIR}/* ) - diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index d74ca48..7f10bac 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -1,3 +1,5 @@ +find_package(GSettings) + ## ## Upstart Job File ## @@ -18,14 +20,20 @@ configure_file ("${UPSTART_JOB_FILE_IN}" "${UPSTART_JOB_FILE}") install (FILES "${UPSTART_JOB_FILE}" DESTINATION "${UPSTART_JOBS_DIR}") +## +## GSettings +## + +if(NOT EXISTS /usr/share/glib-2.0/schemas/com.ubuntu.touch.system.gschema.xml) + add_schema ("org.ayatana.display.gschema.xml") +endif() + ## ## Systemd Unit File ## # where to install -# Uncomment when we drop Vivid -# pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir) -set (SYSTEMD_USER_DIR "/usr/lib/systemd/user") +pkg_get_variable(SYSTEMD_USER_DIR systemd systemduserunitdir) message (STATUS "${SYSTEMD_USER_DIR} is the systemd user unit file install dir") set (SYSTEMD_USER_NAME "${CMAKE_PROJECT_NAME}.service") @@ -51,15 +59,15 @@ install (FILES "${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_PROJECT_NAME}.override" DESTINATION "${UPSTART_SYSTEMD_OVERRIDE_DIR}") ## -## Unity Indicator File +## Ayatana Indicator File ## # where to install -set (UNITY_INDICATOR_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/unity/indicators") -message (STATUS "${UNITY_INDICATOR_DIR} is the Unity Indicator install dir") +set (AYATANA_INDICATOR_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/ayatana/indicators") +message (STATUS "${AYATANA_INDICATOR_DIR} is the Ayatana Indicator install dir") -set (UNITY_INDICATOR_NAME "com.canonical.indicator.rotation_lock") -set (UNITY_INDICATOR_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${UNITY_INDICATOR_NAME}") +set (AYATANA_INDICATOR_NAME "org.ayatana.indicator.rotation_lock") +set (AYATANA_INDICATOR_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${AYATANA_INDICATOR_NAME}") -install (FILES "${UNITY_INDICATOR_FILE}" - DESTINATION "${UNITY_INDICATOR_DIR}") +install (FILES "${AYATANA_INDICATOR_FILE}" + DESTINATION "${AYATANA_INDICATOR_DIR}") diff --git a/data/ayatana-indicator-display.conf.in b/data/ayatana-indicator-display.conf.in new file mode 100644 index 0000000..2fbabc4 --- /dev/null +++ b/data/ayatana-indicator-display.conf.in @@ -0,0 +1,9 @@ +description "Indicator Display Backend" + +start on indicator-services-start +stop on desktop-end or indicator-services-end + +respawn +respawn limit 2 10 + +exec @pkglibexecdir@/indicator-display-service diff --git a/data/ayatana-indicator-display.override b/data/ayatana-indicator-display.override new file mode 100644 index 0000000..2905494 --- /dev/null +++ b/data/ayatana-indicator-display.override @@ -0,0 +1 @@ +manual diff --git a/data/ayatana-indicator-display.service.in b/data/ayatana-indicator-display.service.in new file mode 100644 index 0000000..8245917 --- /dev/null +++ b/data/ayatana-indicator-display.service.in @@ -0,0 +1,8 @@ +[Unit] +Description=Indicator Display Backend +PartOf=graphical-session.target +After=indicators-pre.target + +[Service] +ExecStart=@pkglibexecdir@/indicator-display-service +Restart=on-failure diff --git a/data/com.canonical.indicator.rotation_lock b/data/com.canonical.indicator.rotation_lock deleted file mode 100644 index 7740db7..0000000 --- a/data/com.canonical.indicator.rotation_lock +++ /dev/null @@ -1,11 +0,0 @@ -[Indicator Service] -Name=indicator-rotation-lock -ObjectPath=/com/canonical/indicator/rotation_lock -Position=90 - -[phone] -ObjectPath=/com/canonical/indicator/rotation_lock/phone - -[phone_greeter] -ObjectPath=/com/canonical/indicator/rotation_lock/phone - diff --git a/data/indicator-display.conf.in b/data/indicator-display.conf.in deleted file mode 100644 index 2fbabc4..0000000 --- a/data/indicator-display.conf.in +++ /dev/null @@ -1,9 +0,0 @@ -description "Indicator Display Backend" - -start on indicator-services-start -stop on desktop-end or indicator-services-end - -respawn -respawn limit 2 10 - -exec @pkglibexecdir@/indicator-display-service diff --git a/data/indicator-display.override b/data/indicator-display.override deleted file mode 100644 index 2905494..0000000 --- a/data/indicator-display.override +++ /dev/null @@ -1 +0,0 @@ -manual diff --git a/data/indicator-display.service.in b/data/indicator-display.service.in deleted file mode 100644 index 8245917..0000000 --- a/data/indicator-display.service.in +++ /dev/null @@ -1,8 +0,0 @@ -[Unit] -Description=Indicator Display Backend -PartOf=graphical-session.target -After=indicators-pre.target - -[Service] -ExecStart=@pkglibexecdir@/indicator-display-service -Restart=on-failure diff --git a/data/org.ayatana.display.gschema.xml b/data/org.ayatana.display.gschema.xml new file mode 100644 index 0000000..70d6e46 --- /dev/null +++ b/data/org.ayatana.display.gschema.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + false + Lock rotation + + Lock automatic display rotation. + + + + "none" + Orientation lock + Locks orientation to a specific value. + + + diff --git a/data/org.ayatana.indicator.rotation_lock b/data/org.ayatana.indicator.rotation_lock new file mode 100644 index 0000000..7740db7 --- /dev/null +++ b/data/org.ayatana.indicator.rotation_lock @@ -0,0 +1,11 @@ +[Indicator Service] +Name=indicator-rotation-lock +ObjectPath=/com/canonical/indicator/rotation_lock +Position=90 + +[phone] +ObjectPath=/com/canonical/indicator/rotation_lock/phone + +[phone_greeter] +ObjectPath=/com/canonical/indicator/rotation_lock/phone + diff --git a/debian/changelog b/debian/changelog index 8c8e124..e75a952 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +ayatana-indicator-display (0.2-0) UNRELEASED; urgency=medium + + * Fork ayatana-indicator-datetime from Ubuntu's indicator-display. + + * Upstream-provided Debian package for ayatana-indicator-display. + See upstream ChangeLog for recent changes. + + -- Mike Gabriel Fri, 24 Nov 2017 10:04:00 +0100 + indicator-display (0.1+17.04.20170210-0ubuntu1) zesty; urgency=medium * Remove old autostart files. diff --git a/debian/control b/debian/control index 7871d0f..84930d7 100644 --- a/debian/control +++ b/debian/control @@ -1,8 +1,7 @@ -Source: indicator-display -Section: misc +Source: ayatana-indicator-display +Section: x11 Priority: optional -Maintainer: Ubuntu Developers -XSBC-Original-Maintainer: Charles Kerr +Maintainer: Mike Gabriel Build-Depends: cmake, cmake-extras (>= 0.10), dbus, @@ -12,32 +11,28 @@ Build-Depends: cmake, # for coverage reports gcovr, lcov, +# Ubuntu B-Ds, if on Ubuntu + gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140813) | hello, # for tests - qt5-default, qtbase5-dev, libqtdbusmock1-dev, libqtdbustest1-dev, cppcheck, googletest | google-mock (>= 1.6.0+svn437), - gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140813), # for packaging debhelper (>= 9), - dh-translations, # for systemd unit - systemd, -Standards-Version: 3.9.5 -Homepage: http://launchpad.net/indicator-display/ -X-Ubuntu-Use-Langpack: yes -# If you aren't a member of ~indicator-applet-developers but need to upload -# packaging changes, just go ahead. ~indicator-applet-developers will notice and -# sync up the code again. -Vcs-Bzr: https://code.launchpad.net/~indicator-applet-developers/indicator-display/trunk.14.10 + systemd [linux-any], +Standards-Version: 4.1.1 +Homepage: http://github.com/AyatanaIndicators/ayatana-indicator-display +Vcs-Git: http://github.com/AyatanaIndicators/ayatana-indicator-display +Vcs-Browser: http://github.com/AyatanaIndicators/ayatana-indicator-display -Package: indicator-display +Package: ayatana-indicator-display Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, - gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140813), - indicator-common, -Description: Collection of small indicators - Indicators too small to merit separate codebases, such as Rotation Lock + ayatana-indicator-common, +Description: Ayatana Indicator for Display configuration + This Ayatana Indicator is designed to be placed on the right side of a + panel and give the user easy control for changing their display settings. diff --git a/debian/copyright b/debian/copyright index 7809d7c..54b1359 100644 --- a/debian/copyright +++ b/debian/copyright @@ -4,6 +4,13 @@ Source: http://launchpad.net/indicator-display Files: * Copyright: 2014, Canonical Ltd. +License: GPL-3 + +Files: debian/* +Copyright: 2014, Canonical Ltd. + 2017, Mike Gabriel +License: GPL-3 + License: GPL-3 This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/debian/indicator-display.maintscript b/debian/indicator-display.maintscript deleted file mode 100644 index 6013bd1..0000000 --- a/debian/indicator-display.maintscript +++ /dev/null @@ -1 +0,0 @@ -rm_conffile /etc/xdg/autostart/indicator-display.desktop 0.1+17.04.20170210-0ubuntu1~ diff --git a/debian/rules b/debian/rules index 9bd9847..4ff937e 100755 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,17 @@ #!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +export DPKG_GENSYMBOLS_CHECK_LEVEL=4 + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/buildflags.mk %: - dh $@ --parallel --with translations + dh $@ --parallel +get-orig-source: + uscan --noconf --force-download --rename --download-current-version --destdir=.. diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 0000000..8f5caec --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1,117 @@ +af +am +an +ar +ast +az +bem +be +bg +bn +bo +br +bs +ca +ca@valencia +ce +ckb +co +crh +cs +cv +cy +da +de +el +en_AU +en_CA +en_GB +eo +es +et +eu +fa +fil +fi +fo +fr_CA +fr +frp +fy +ga +gd +gl +gu +he +hi +hr +ht +hu +hy +ia +id +is +it +ja +ka +kk +kl +km +kn +ko +ku +kw +ky +la +lb +lo +lt +lv +mg +mhr +mi +ml +mr +ms +my +nb +ne +nl +nn +oc +os +pa +pl +ps +pt_BR +pt +ro +ru +sa +sc +sd +se +shn +si +sk +sl +sq +sr +sv +sw +szl +ta +te +tg +th +ti +tr +ug +uk +ur +uz +vi +wae +zh_CN +zh_HK +zh_TW diff --git a/po/POTFILES.in b/po/POTFILES.in new file mode 100644 index 0000000..8d88dd5 --- /dev/null +++ b/po/POTFILES.in @@ -0,0 +1,9 @@ +src/adbd-client.cpp +src/exporter.cpp +src/greeter.cpp +src/indicator.cpp +src/main.cpp +src/rotation-lock.cpp +src/usb-manager.cpp +src/usb-monitor.cpp +src/usb-snap.cpp diff --git a/po/ayatana-indicator-display.pot b/po/ayatana-indicator-display.pot new file mode 100644 index 0000000..26488a3 --- /dev/null +++ b/po/ayatana-indicator-display.pot @@ -0,0 +1,43 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Canonical Ltd. +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-07 13:08-0500\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../src/rotation-lock.cpp:125 +msgid "Rotation Lock" +msgstr "" + +#: ../src/rotation-lock.cpp:136 +msgid "Rotation" +msgstr "" + +#: ../src/usb-snap.cpp:107 +#, c-format +msgid "The computer's RSA key fingerprint is: %s" +msgstr "" + +#: ../src/usb-snap.cpp:112 +msgid "Allow" +msgstr "" + +#: ../src/usb-snap.cpp:114 +msgid "Don't Allow" +msgstr "" + +#: ../src/usb-snap.cpp:126 +msgid "Allow USB Debugging?" +msgstr "" diff --git a/po/indicator-display.pot b/po/indicator-display.pot deleted file mode 100644 index 26488a3..0000000 --- a/po/indicator-display.pot +++ /dev/null @@ -1,43 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR Canonical Ltd. -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR , YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-02-07 13:08-0500\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME \n" -"Language-Team: LANGUAGE \n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: ../src/rotation-lock.cpp:125 -msgid "Rotation Lock" -msgstr "" - -#: ../src/rotation-lock.cpp:136 -msgid "Rotation" -msgstr "" - -#: ../src/usb-snap.cpp:107 -#, c-format -msgid "The computer's RSA key fingerprint is: %s" -msgstr "" - -#: ../src/usb-snap.cpp:112 -msgid "Allow" -msgstr "" - -#: ../src/usb-snap.cpp:114 -msgid "Don't Allow" -msgstr "" - -#: ../src/usb-snap.cpp:126 -msgid "Allow USB Debugging?" -msgstr "" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 060071d..eb736c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,9 @@ - add_definitions(-DG_LOG_DOMAIN="${CMAKE_PROJECT_NAME}") +if(EXISTS "/usr/share/glib-2.0/schemas/com.ubuntu.sound.gschema.xml") + add_definitions( -DHAS_UBUNTU_TOUCH_SCHEMA ) +endif() + add_compile_options( ${CXX_WARNING_ARGS} ) @@ -34,4 +37,3 @@ install( ${SERVICE_EXEC} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR} ) - diff --git a/src/dbus-names.h b/src/dbus-names.h index b31098a..aa7ef2a 100644 --- a/src/dbus-names.h +++ b/src/dbus-names.h @@ -39,11 +39,11 @@ namespace DBusNames } } - namespace UnityGreeter + namespace Greeter { - static constexpr char const * NAME = "com.canonical.UnityGreeter"; + static constexpr char const * NAME = "org.ayatana.Greeter"; static constexpr char const * PATH = "/"; - static constexpr char const * INTERFACE = "com.canonical.UnityGreeter"; + static constexpr char const * INTERFACE = "org.ayatana.Greeter"; } namespace Properties @@ -57,4 +57,3 @@ namespace DBusNames } } } - diff --git a/src/exporter.cpp b/src/exporter.cpp index 252bbdf..b415a81 100644 --- a/src/exporter.cpp +++ b/src/exporter.cpp @@ -26,7 +26,7 @@ public: explicit Impl(const std::shared_ptr& indicator): m_indicator(indicator) { - auto bus_name = g_strdup_printf("com.canonical.indicator.%s", indicator->name()); + auto bus_name = g_strdup_printf("org.ayatana.indicator.%s", indicator->name()); m_own_id = g_bus_own_name(G_BUS_TYPE_SESSION, bus_name, G_BUS_NAME_OWNER_FLAGS_NONE, @@ -94,7 +94,7 @@ private: // export the actions error = nullptr; - object_path = g_strdup_printf("/com/canonical/indicator/%s", indicator->name()); + object_path = g_strdup_printf("/org/ayatana/indicator/%s", indicator->name()); id = g_dbus_connection_export_action_group(m_bus, object_path, G_ACTION_GROUP(indicator->action_group()), @@ -151,7 +151,7 @@ private: // build the header menu auto detailed_action = g_strdup_printf("indicator.%s", action_name.c_str()); GMenuItem* header = g_menu_item_new(nullptr, detailed_action); - g_menu_item_set_attribute(header, "x-canonical-type", "s", "com.canonical.indicator.root"); + g_menu_item_set_attribute(header, "x-canonical-type", "s", "org.ayatana.indicator.root"); g_menu_item_set_submenu(header, profile->menu_model().get()); g_free(detailed_action); @@ -161,7 +161,7 @@ private: g_object_unref(header); // export the menu - auto object_path = g_strdup_printf("/com/canonical/indicator/%s/%s", + auto object_path = g_strdup_printf("/org/ayatana/indicator/%s/%s", indicator->name(), profile->name().c_str()); GError* error = nullptr; diff --git a/src/greeter.cpp b/src/greeter.cpp index 3d0f347..02eb0be 100644 --- a/src/greeter.cpp +++ b/src/greeter.cpp @@ -22,7 +22,7 @@ #include -class UnityGreeter::Impl +class Greeter::Impl { public: @@ -72,7 +72,7 @@ private: const auto watcher_id = g_bus_watch_name_on_connection( bus, - DBusNames::UnityGreeter::NAME, + DBusNames::Greeter::NAME, G_BUS_NAME_WATCHER_FLAGS_AUTO_START, on_greeter_appeared, on_greeter_vanished, @@ -81,11 +81,11 @@ private: const auto subscription_id = g_dbus_connection_signal_subscribe( bus, - DBusNames::UnityGreeter::NAME, + DBusNames::Greeter::NAME, DBusNames::Properties::INTERFACE, DBusNames::Properties::PropertiesChanged::NAME, - DBusNames::UnityGreeter::PATH, - DBusNames::UnityGreeter::INTERFACE, + DBusNames::Greeter::PATH, + DBusNames::Greeter::INTERFACE, G_DBUS_SIGNAL_FLAGS_NONE, on_properties_changed_signal, gself, @@ -114,11 +114,11 @@ private: g_dbus_connection_call( bus, - DBusNames::UnityGreeter::NAME, - DBusNames::UnityGreeter::PATH, + DBusNames::Greeter::NAME, + DBusNames::Greeter::PATH, DBusNames::Properties::INTERFACE, "Get", - g_variant_new("(ss)", DBusNames::UnityGreeter::INTERFACE, "IsActive"), + g_variant_new("(ss)", DBusNames::Greeter::INTERFACE, "IsActive"), G_VARIANT_TYPE("(v)"), G_DBUS_CALL_FLAGS_NONE, -1, @@ -171,7 +171,7 @@ private: auto self = static_cast(gself); g_return_if_fail(!g_strcmp0(sender_name, self->m_owner.c_str())); - g_return_if_fail(!g_strcmp0(object_path, DBusNames::UnityGreeter::PATH)); + g_return_if_fail(!g_strcmp0(object_path, DBusNames::Greeter::PATH)); g_return_if_fail(!g_strcmp0(interface_name, DBusNames::Properties::INTERFACE)); g_return_if_fail(!g_strcmp0(signal_name, DBusNames::Properties::PropertiesChanged::NAME)); g_return_if_fail(g_variant_is_of_type(parameters, G_VARIANT_TYPE(DBusNames::Properties::PropertiesChanged::ARGS_VARIANT_TYPE))); @@ -193,19 +193,19 @@ private: **** ***/ -Greeter::Greeter() =default; +BaseGreeter::BaseGreeter() =default; -Greeter::~Greeter() =default; +BaseGreeter::~BaseGreeter() =default; -UnityGreeter::UnityGreeter(): +Greeter::Greeter(): impl{new Impl{}} { } -UnityGreeter::~UnityGreeter() =default; +Greeter::~Greeter() =default; core::Property& -UnityGreeter::state() +Greeter::state() { return impl->state(); } diff --git a/src/greeter.h b/src/greeter.h index f3012f6..0bfe026 100644 --- a/src/greeter.h +++ b/src/greeter.h @@ -24,11 +24,11 @@ #include #include -class Greeter +class BaseGreeter { public: - Greeter(); - virtual ~Greeter(); + BaseGreeter(); + virtual ~BaseGreeter(); enum class State { UNAVAILABLE, INACTIVE, ACTIVE }; static inline const char* state_str(const State& state) { @@ -39,11 +39,11 @@ static inline const char* state_str(const State& state) { }; -class UnityGreeter: public Greeter +class Greeter: public BaseGreeter { public: - UnityGreeter(); - virtual ~UnityGreeter(); + Greeter(); + virtual ~Greeter(); core::Property& state() override; protected: diff --git a/src/main.cpp b/src/main.cpp index 52cdd58..e061871 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -63,7 +63,7 @@ main(int /*argc*/, char** /*argv*/) static constexpr char const * ADB_SOCKET_PATH {"/dev/socket/adbd"}; static constexpr char const * PUBLIC_KEYS_FILENAME {"/data/misc/adb/adb_keys"}; auto usb_monitor = std::make_shared(); - auto greeter = std::make_shared(); + auto greeter = std::make_shared(); UsbManager usb_manager {ADB_SOCKET_PATH, PUBLIC_KEYS_FILENAME, usb_monitor, greeter}; // let's go! diff --git a/src/rotation-lock.cpp b/src/rotation-lock.cpp index 88c7e1b..9af5f8e 100644 --- a/src/rotation-lock.cpp +++ b/src/rotation-lock.cpp @@ -123,7 +123,7 @@ private: menu = g_menu_new(); menu_item = g_menu_item_new(_("Rotation Lock"), "indicator.rotation-lock"); - g_menu_item_set_attribute(menu_item, "x-canonical-type", "s", "com.canonical.indicator.switch"); + g_menu_item_set_attribute(menu_item, "x-canonical-type", "s", "org.ayatana.indicator.switch"); g_menu_append_item(menu, menu_item); g_object_unref(menu_item); @@ -144,7 +144,11 @@ private: **** ***/ +#ifdef HAS_UBUNTU_TOUCH_SCHEMA static constexpr char const * m_schema_name {"com.ubuntu.touch.system"}; +#else + static constexpr char const * m_schema_name {"org.ayatana.display"}; +#endif static constexpr char const * m_rotation_lock_icon_name {"orientation-lock"}; GSettings* m_settings = nullptr; GSimpleActionGroup* m_action_group = nullptr; diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 87fab3a..fda43be 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -1,3 +1,31 @@ +########################### +# GSettings Schema +########################### + +# build the necessary schemas +set_directory_properties (PROPERTIES + ADDITIONAL_MAKE_CLEAN_FILES gschemas.compiled) +set_source_files_properties (gschemas.compiled GENERATED) + +# GSettings: +# compile the org.ayatana.display schema into a gschemas.compiled file in this directory, +# and help the tests to find that file by setting -DSCHEMA_DIR +set (XDG_DATA_DIRS "${CMAKE_CURRENT_BINARY_DIR}/gsettings-schemas") +set (SCHEMA_DIR "${XDG_DATA_DIRS}/glib-2.0/schemas") +if (EXISTS /usr/share/glib-2.0/schemas/com.ubuntu.touch.system.gschema.xml) + set (DISPLAY_SCHEMA /usr/share/glib-2.0/schemas/com.ubuntu.touch.system.gschema.xml) +else() + set (DISPLAY_SCHEMA ${CMAKE_SOURCE_DIR}/data/org.ayatana.display.gschema.xml) +endif() +add_definitions(-DSCHEMA_DIR="${SCHEMA_DIR}") +execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas + OUTPUT_VARIABLE COMPILE_SCHEMA_EXECUTABLE + OUTPUT_STRIP_TRAILING_WHITESPACE) +add_custom_command (OUTPUT gschemas.compiled + COMMAND mkdir -p ${SCHEMA_DIR} + COMMAND cp -f ${DISPLAY_SCHEMA} ${SCHEMA_DIR} + COMMAND ${COMPILE_SCHEMA_EXECUTABLE} ${SCHEMA_DIR}) + set(SERVICE_LINK_LIBRARIES ${SERVICE_LIB} ${SERVICE_DEPS_LIBRARIES} @@ -15,13 +43,13 @@ set(TEST_LINK_LIBRARIES ) add_definitions( - -DGREETER_TEMPLATE="${CMAKE_SOURCE_DIR}/tests/utils/mock-unity-greeter.py" + -DGREETER_TEMPLATE="${CMAKE_SOURCE_DIR}/tests/utils/mock-greeter.py" ) function(add_test_by_name name) set(TEST_NAME ${name}) set(COVERAGE_TEST_TARGETS ${COVERAGE_TEST_TARGETS} ${TEST_NAME} PARENT_SCOPE) - add_executable (${TEST_NAME} ${TEST_NAME}.cpp) + add_executable (${TEST_NAME} ${TEST_NAME}.cpp gschemas.compiled) add_test(${TEST_NAME} ${TEST_NAME}) set_property(TEST ${TEST_NAME} APPEND PROPERTY ENVIRONMENT ${CTEST_ENVIRONMENT}) target_link_libraries(${TEST_NAME} ${SERVICE_LINK_LIBRARIES} ${TEST_LINK_LIBRARIES} ${THREAD_LINK_LIBRARIES}) diff --git a/tests/unit/greeter-test.cpp b/tests/unit/greeter-test.cpp index bfa88e8..61880f6 100644 --- a/tests/unit/greeter-test.cpp +++ b/tests/unit/greeter-test.cpp @@ -70,7 +70,7 @@ protected: // set a watcher to look for our mock greeter to appear bool owned {}; QDBusServiceWatcher watcher( - DBusNames::UnityGreeter::NAME, + DBusNames::Greeter::NAME, m_dbus_runner->sessionConnection() ); QObject::connect( @@ -83,7 +83,7 @@ protected: QVariantMap parameters; parameters["IsActive"] = QVariant(is_active); m_dbus_mock->registerTemplate( - DBusNames::UnityGreeter::NAME, + DBusNames::Greeter::NAME, GREETER_TEMPLATE, parameters, QDBusConnection::SessionBus @@ -116,7 +116,7 @@ TEST_F(GreeterFixture, ActiveServiceStartsBeforeWatcher) start_greeter_service(is_active); - UnityGreeter greeter; + Greeter greeter; ASSERT_PROPERTY_EQ_EVENTUALLY(expected, greeter.state()); } @@ -126,7 +126,7 @@ TEST_F(GreeterFixture, WatcherStartsBeforeActiveService) constexpr bool is_active {true}; constexpr Greeter::State expected {Greeter::State::ACTIVE}; - UnityGreeter greeter; + Greeter greeter; start_greeter_service(is_active); @@ -140,7 +140,7 @@ TEST_F(GreeterFixture, InactiveServiceStartsBeforeWatcher) start_greeter_service(is_active); - UnityGreeter greeter; + Greeter greeter; ASSERT_PROPERTY_EQ_EVENTUALLY(expected, greeter.state()); } @@ -150,7 +150,7 @@ TEST_F(GreeterFixture, WatcherStartsBeforeInactiveService) constexpr bool is_active {false}; constexpr Greeter::State expected {Greeter::State::INACTIVE}; - UnityGreeter greeter; + Greeter greeter; start_greeter_service(is_active); diff --git a/tests/utils/CMakeLists.txt b/tests/utils/CMakeLists.txt index e458c82..fd82b79 100644 --- a/tests/utils/CMakeLists.txt +++ b/tests/utils/CMakeLists.txt @@ -14,4 +14,3 @@ qt5_use_modules( Core DBus ) - diff --git a/tests/utils/mock-greeter.py b/tests/utils/mock-greeter.py new file mode 100644 index 0000000..dc48a6d --- /dev/null +++ b/tests/utils/mock-greeter.py @@ -0,0 +1,41 @@ +'''desktop greeter mock template + +Very basic template that just mocks the greeter is-active flag +''' + +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; either version 3 of the License, or (at your option) any +# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text +# of the license. + +__author__ = 'Charles Kerr' +__email__ = 'charles.kerr@canonical.com' +__copyright__ = '(c) 2016 Canonical Ltd.' +__license__ = 'LGPL 3+' + +import dbus +import os + +from dbusmock import MOCK_IFACE, mockobject + +BUS_NAME = 'org.ayatana.Greeter' +MAIN_OBJ = '/' +MAIN_IFACE = 'org.ayatana.Greeter' +SYSTEM_BUS = False + + +def load(mock, parameters): + mock.AddMethods( + MAIN_IFACE, [ + ('HideGreeter', '', '', 'self.Set("org.ayatana.Greeter", "IsActive", False)'), + ('ShowGreeter', '', '', 'self.Set("org.ayatana.Greeter", "IsActive", True)') + ] + ) + mock.AddProperties( + MAIN_IFACE, + dbus.Dictionary({ + 'IsActive': parameters.get('IsActive', False), + }, signature='sv') + ) + diff --git a/tests/utils/mock-unity-greeter.py b/tests/utils/mock-unity-greeter.py deleted file mode 100644 index 70fb791..0000000 --- a/tests/utils/mock-unity-greeter.py +++ /dev/null @@ -1,41 +0,0 @@ -'''unity greeter mock template - -Very basic template that just mocks the greeter is-active flag -''' - -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation; either version 3 of the License, or (at your option) any -# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text -# of the license. - -__author__ = 'Charles Kerr' -__email__ = 'charles.kerr@canonical.com' -__copyright__ = '(c) 2016 Canonical Ltd.' -__license__ = 'LGPL 3+' - -import dbus -import os - -from dbusmock import MOCK_IFACE, mockobject - -BUS_NAME = 'com.canonical.UnityGreeter' -MAIN_OBJ = '/' -MAIN_IFACE = 'com.canonical.UnityGreeter' -SYSTEM_BUS = False - - -def load(mock, parameters): - mock.AddMethods( - MAIN_IFACE, [ - ('HideGreeter', '', '', 'self.Set("com.canonical.UnityGreeter", "IsActive", False)'), - ('ShowGreeter', '', '', 'self.Set("com.canonical.UnityGreeter", "IsActive", True)') - ] - ) - mock.AddProperties( - MAIN_IFACE, - dbus.Dictionary({ - 'IsActive': parameters.get('IsActive', False), - }, signature='sv') - ) - diff --git a/update-po.sh b/update-po.sh new file mode 100755 index 0000000..81a9dc5 --- /dev/null +++ b/update-po.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -x + +# Copyright (C) 2017 by Mike Gabriel +# +# This package 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 of the License. +# +# This package 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 + +GETTEXT_DOMAIN=$(cat CMakeLists.txt | grep 'set.*(.*GETTEXT_PACKAGE' | sed -r -e 's/.*\"([^"]+)\"\)/\1/') + +cd po/ +cat LINGUAS | while read lingua; do + if [ ! -e ${lingua}.po ]; then + msginit --input=${GETTEXT_DOMAIN}.pot --locale=${lingua} --no-translator --output-file=$lingua.po + else + intltool-update --gettext-package ${GETTEXT_DOMAIN} $(basename ${lingua}) + fi +done +cd - 1>/dev/null diff --git a/update-pot.sh b/update-pot.sh new file mode 100755 index 0000000..f4dcda8 --- /dev/null +++ b/update-pot.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Copyright (C) 2017 by Mike Gabriel +# +# This package 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 of the License. +# +# This package 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 + +GETTEXT_DOMAIN=$(cat CMakeLists.txt | grep 'set.*(.*GETTEXT_PACKAGE' | sed -r -e 's/.*\"([^"]+)\"\)/\1/') + +cd po/ && intltool-update --gettext-package ${GETTEXT_DOMAIN} --pot -- cgit v1.2.3