diff options
author | Ted Gould <ted@gould.cx> | 2014-02-21 13:05:14 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2014-02-21 13:05:14 -0600 |
commit | acce82e25c48da98b5e298a70aa119b3f9e8a1f9 (patch) | |
tree | feb3589509fc2864038078f8525e9ee29e0c7151 | |
parent | 0b76536b27f57db75a101e8ce7e3f75b7cddf57c (diff) | |
parent | bc01d6ceef3dbc5119a0ac7b2fba1583f62c3d48 (diff) | |
download | ayatana-indicator-sound-acce82e25c48da98b5e298a70aa119b3f9e8a1f9.tar.gz ayatana-indicator-sound-acce82e25c48da98b5e298a70aa119b3f9e8a1f9.tar.bz2 ayatana-indicator-sound-acce82e25c48da98b5e298a70aa119b3f9e8a1f9.zip |
Grabbing the timestamp
-rw-r--r-- | data/com.canonical.indicator.sound.AccountsService.xml | 3 | ||||
-rw-r--r-- | debian/control | 3 | ||||
-rw-r--r-- | src/accounts-service-user.vala | 15 | ||||
-rw-r--r-- | tests/accounts-service-user.cc | 3 |
4 files changed, 24 insertions, 0 deletions
diff --git a/data/com.canonical.indicator.sound.AccountsService.xml b/data/com.canonical.indicator.sound.AccountsService.xml index 1651a43..fb7e96f 100644 --- a/data/com.canonical.indicator.sound.AccountsService.xml +++ b/data/com.canonical.indicator.sound.AccountsService.xml @@ -12,6 +12,9 @@ <annotation name="org.freedesktop.Accounts.Authentication.ChangeAny" value="com.canonical.indicator.sound.AccountsService.ModifyAnyUser"/> + <property name="Timestamp" type="t" access="readwrite"> + <annotation name="org.freedesktop.Accounts.DefaultValue" value="0"/> + </property> <property name="PlayerName" type="s" access="readwrite"> <annotation name="org.freedesktop.Accounts.DefaultValue" value=""/> </property> diff --git a/debian/control b/debian/control index 06acb09..84d3727 100644 --- a/debian/control +++ b/debian/control @@ -8,11 +8,13 @@ Build-Depends: debhelper (>= 9.0), dbus, dbus-test-runner, dh-translations, + gir1.2-accountsservice-1.0, gnome-common, autotools-dev, valac (>= 0.20), libaccountsservice-dev, libdbustest1-dev, + libgirepository1.0-dev, libglib2.0-dev (>= 2.22.3), libgtest-dev, liburl-dispatcher1-dev, @@ -21,6 +23,7 @@ Build-Depends: debhelper (>= 9.0), libnotify-dev, libgee-dev, libxml2-dev, + python3-dbusmock, Standards-Version: 3.9.4 Homepage: https://launchpad.net/indicator-sound # If you aren't a member of ~indicator-applet-developers but need to upload diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala index 19ca774..47189a5 100644 --- a/src/accounts-service-user.vala +++ b/src/accounts-service-user.vala @@ -20,6 +20,7 @@ [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;} @@ -34,6 +35,7 @@ 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; public MediaPlayer? player { @@ -44,10 +46,18 @@ public class AccountsServiceUser : Object { if (this.proxy == null) return; + /* Always reset the timer */ + if (this.timer != 0) { + GLib.Source.remove(this.timer); + this.timer = 0; + } + if (this._player == null) { /* Clear it */ this.proxy.player_name = ""; + this.proxy.timestamp = 0; } 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"); @@ -70,6 +80,11 @@ public class AccountsServiceUser : Object { this.proxy.album = ""; this.proxy.art_url = ""; } + + this.timer = GLib.Timeout.add_seconds(5 * 60, () => { + this.proxy.timestamp = GLib.get_monotonic_time(); + return true; + }); } } get { diff --git a/tests/accounts-service-user.cc b/tests/accounts-service-user.cc index 65806e3..a52b3a0 100644 --- a/tests/accounts-service-user.cc +++ b/tests/accounts-service-user.cc @@ -68,6 +68,9 @@ class AccountsServiceUserTest : public ::testing::Test DbusTestDbusMockObject * soundobj = dbus_test_dbus_mock_get_object(mock, "/user", "com.canonical.indicator.sound.AccountsService", NULL); dbus_test_dbus_mock_object_add_property(mock, soundobj, + "Timeout", 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, |