aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/com.canonical.indicator.sound.AccountsService.xml3
-rw-r--r--debian/control3
-rw-r--r--src/accounts-service-user.vala15
-rw-r--r--tests/accounts-service-user.cc3
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,