Merge lp:~laney/ubuntu-system-settings/as-ringtone into lp:ubuntu-system-settings

Proposed by Iain Lane
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 560
Merged at revision: 640
Proposed branch: lp:~laney/ubuntu-system-settings/as-ringtone
Merge into: lp:ubuntu-system-settings
Diff against target: 406 lines (+214/-23)
9 files modified
debian/control (+6/-0)
debian/rules (+1/-1)
debian/ubuntu-system-settings-sound-gsettings-to-accountsservice.py (+54/-0)
debian/ubuntu-system-settings.migrations (+1/-0)
plugins/sound/CMakeLists.txt (+2/-1)
plugins/sound/PageComponent.qml (+7/-4)
plugins/sound/SoundsList.qml (+26/-13)
plugins/sound/sound.cpp (+85/-3)
plugins/sound/sound.h (+32/-1)
To merge this branch: bzr merge lp:~laney/ubuntu-system-settings/as-ringtone
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Michael Terry (community) Approve
Review via email: mp+200862@code.launchpad.net

Commit message

Also store the ringtone, messages and silent mode settings in AccountsService.

Description of the change

Bug #1265528 asks for the sound settings to be stored in AS so that the greeter can get at them.

I'm not sure about silent-mode; should this be a global property? And what does that mean for AS - that it should be stored under the greeter user?

In the meantime, this is a port of what we currently have in GSettings.

Once session-migration and a GLib bug have been fixed, we'll need to add a job to do an initial migration from GSettings to AS.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
552. By Iain Lane

Add a session-migration script to move sound settings from GSettings to AS

553. By Iain Lane

Add Depends for the session-migration script

554. By Iain Lane

Add comment & rename script

555. By Iain Lane

Merge with lp:~seb128/ubuntu-system-settings/bzrignore-cmake-user

Revision history for this message
Iain Lane (laney) wrote :

Right, I've added a session-migration script. I'll need to upload a GLib cherry-pick before it works though, so wait a little please.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
556. By Iain Lane

Build-Depend on dh-migrations

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Iain Lane (laney) wrote :

The fixed glib should migrate soon.

It'd be fine to review this now, but the migration script won't work unless you have the new glib installed (that's ok, as session-migration will re-run it until it passes). So bear that in mind - probably install the new glib manually if you have to in order to test this.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks for the work, I just installed that, some issues/comments

* Sorry for not commenting about that earlier, but looking at the changes (dropping use of gsettings to monitor accountsservice) made me wonder if that's the right approch. I've commented on the bug with some details, but basically I think we should consider gsettings the canonical storage and only deal with that one, and have a service in the desktop that does the "gsettings<->accountsservice syncs".

It's likely that other elements are going to let the user change configs (e.g the phone app itself, third party code) and we don't want each of those to duplicate the sync code

* the migration script hits an error (I've the new glib installed)

ERROR:dbus.proxies:Introspect error on :1.16:/org/freedesktop/Accounts/User1000: dbus.exceptions.IntrospectionParserException: Error parsing introspect data: <class 'xml.parsers.expat.ExpatError'>: not well-formed (invalid token): line 63, column 84

Traceback (most recent call last):
  File "/usr/share/session-migration/scripts/ubuntu-system-settings-sound-gsettings-to-accountsservice.py", line 54, in <module>
    set_as_setting('com.ubuntu.touch.AccountsService.Sound', a, f(g))
  File "/usr/share/session-migration/scripts/ubuntu-system-settings-sound-gsettings-to-accountsservice.py", line 46, in set_as_setting
    dbus_interface=dbus.PROPERTIES_IFACE)
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 70, in __call__
    return self._proxy_method(*args, **keywords)
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__
    **keywords)
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking
    message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: No such interface 'org.freedesktop.DBus.Properties' on object at path /org/freedesktop/Accounts/User1000

* deleting the destructor is ok, it's not related to those changes, would be nice to have cleanups made in different commits (same for the lines wrapping/spacing changes ;-)

* I'm probably overlooking something trivial, but in

" - soundSelector.selectedIndex = Utilities.indexSelectedFile(soundFileNames, soundSettings.incomingCallSound)
 + soundSelector.selectedIndex =
 + Utilities.indexSelectedFile(soundFileNames,
 + incomingCallSound)"

you drop the "soundSettings." prefix ... where is "incomingCallSound" defined?

The code otherwise looks fine, thanks for the work there!

review: Needs Fixing
Revision history for this message
Sebastien Bacher (seb128) wrote :

The migration error is gone once accountsservice restarted, since that's a system service that doesn't happen if you logout/login. We should either restart the service from the postinst or ignore/trap the error and wait until the next reboot to have a migration working

Revision history for this message
Iain Lane (laney) wrote :

On Fri, Jan 10, 2014 at 05:35:34PM -0000, Sebastien Bacher wrote:
> The migration error is gone once accountsservice restarted, since that's a system service that doesn't happen if you logout/login. We should either restart the service from the postinst or ignore/trap the error and wait until the next reboot to have a migration working

No. It's the glib problem that I mentioned in the comments.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Revision history for this message
Sebastien Bacher (seb128) wrote :

> No. It's the glib problem that I mentioned in the comments.

I had the new glib installed before restarting my session though ... to me it looked like accountsservice didn't pick the new xml until restarted (the sounds section was not in d-feet either)

Revision history for this message
Iain Lane (laney) wrote :

On Mon, Jan 13, 2014 at 09:37:36AM -0000, Sebastien Bacher wrote:
> > No. It's the glib problem that I mentioned in the comments.
>
> I had the new glib installed before restarting my session though ... to me it looked like accountsservice didn't pick the new xml until restarted (the sounds section was not in d-feet either)

The error you pasted in your earlier review is the glib one.

I guess AS should have a way to trigger re-loading of the schemas as
new ones are only picked up when the service restarts.

Not sure it's a big issue here as the session-migration only happens on
session start anyway.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Revision history for this message
Iain Lane (laney) wrote :

Ah, I suppose that AS needs to restart with the new glib to pick up the fix.

Revision history for this message
Sebastien Bacher (seb128) wrote :

> Ah, I suppose that AS needs to restart with the new glib to pick up the fix.

right, that as well I guess (I didn't reboot after installing the new glib)

Revision history for this message
Iain Lane (laney) wrote :

I'm wondering if the schemas should instead be shipped in their own package?

I've just written the telephony-service change and it seems bad and wrong for it to depend on u-s-s for this.

We could make a new binary out of u-s-s for simplicity or create a new source (probably renaming gsettings-ubuntu-touch-schemas).

wdyt?

Revision history for this message
Iain Lane (laney) wrote :

Oh, and to reply to the rest of the review.

On Fri, Jan 10, 2014 at 05:32:26PM -0000, Sebastien Bacher wrote:
> Review: Needs Fixing
>
> Thanks for the work, I just installed that, some issues/comments
>
> * deleting the destructor is ok, it's not related to those changes, would be nice to have cleanups made in different commits (same for the lines wrapping/spacing changes ;-)

Hmm, I meant to do the deletion in a separate merge proposal, will do
that (oh for rebase -i).

Not the formatting though, that's too painful to undo.

For future reference, you want merge proposals which are solely
formatting changes?

>
> * I'm probably overlooking something trivial, but in
>
> " - soundSelector.selectedIndex = Utilities.indexSelectedFile(soundFileNames, soundSettings.incomingCallSound)
> + soundSelector.selectedIndex =
> + Utilities.indexSelectedFile(soundFileNames,
> + incomingCallSound)"
>
> you drop the "soundSettings." prefix ... where is "incomingCallSound" defined?

It's now being read from the cpp sound backend which is the AS property.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

557. By Iain Lane

Put back destructor which is an unrelated change for this set

Revision history for this message
Sebastien Bacher (seb128) wrote :

> We could make a new binary out of u-s-s for simplicity or create a new source (probably renaming gsettings-ubuntu-touch-schemas).

I would just put them in gsettings-u-t-s, but renaming is fine if you want the name to strictly match the content...

> For future reference, you want merge proposals which are solely formatting changes?

If possible, I think it's better (it makes easier to make sense of "bzr blame" and such later on). Ideally we would do a formatting fix on the current codebase and try to be strict about newly added code, to avoid having to deal with those issues later

> It's now being read from the cpp sound backend which is the AS property.

shouldn't that be "backendInfo.incomingCallSound" then?

Revision history for this message
Iain Lane (laney) wrote :

On Mon, Jan 13, 2014 at 11:44:39AM -0000, Sebastien Bacher wrote:
> > It's now being read from the cpp sound backend which is the AS property.
>
> shouldn't that be "backendInfo.incomingCallSound" then?

We're already within backendInfo at that point so you don't need to say
that.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Revision history for this message
Sebastien Bacher (seb128) wrote :

> We're already within backendInfo at that point so you don't need to say that.

Oh, indeed, that makes sense. That's going to teach me to read only the diff and not open the file to have the full context ... thanks!

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
558. By Iain Lane

Remove the AS schema from here - it's going to gsettings-ubuntu-touch-schemas

559. By Iain Lane

merge lp:~laney/ubuntu-system-settings/as-schemas-package

Revision history for this message
Iain Lane (laney) wrote :

> > We could make a new binary out of u-s-s for simplicity or create a new
> source (probably renaming gsettings-ubuntu-touch-schemas).
>
> I would just put them in gsettings-u-t-s, but renaming is fine if you want the
> name to strictly match the content...

Alright, I've done some MPs for this.

https://code.launchpad.net/~laney/gsettings-ubuntu-touch-schemas/add-sound-as-schema
https://code.launchpad.net/~laney/gsettings-ubuntu-touch-schemas/add-accountsservice-schema
https://code.launchpad.net/~laney/ubuntu-system-settings/as-schemas-package

& removed the schema from here (I also merged the third branch above into this one as they are entangled)

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Iain Lane (laney) wrote :

ping

Revision history for this message
Michael Terry (mterry) wrote :

Looks great to me, tested and it seems fine.

 * Are any changes against your component pending/needed to land the MP under review in a functional state and are those called out explicitly by the submitter?
 - No
 * Did you do exploratory testing related to the component you own with the MP changeset included?
 - No, but greeter uses similar code to interact with other settings
 * Has the submitter requested review by all the relevant teams/reviewers?
 - Yes
 * If you are the reviewer owning the component the MP is against, have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
 - N/A

review: Approve
560. By Iain Lane

Merge trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Sebastien Bacher (seb128) wrote :

Looks fine to me as well, thanks

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-02-06 15:47:27 +0000
3+++ debian/control 2014-02-24 20:53:19 +0000
4@@ -4,6 +4,7 @@
5 Maintainer: Ubuntu Desktop Team <ubuntu-desktop@lists.ubuntu.com>
6 Build-Depends: dbus-test-runner,
7 debhelper (>= 9),
8+ dh-migrations,
9 python:any (>= 2.7),
10 python-setuptools,
11 gdb:any,
12@@ -53,6 +54,11 @@
13 libsystemsettings1 (= ${binary:Version}),
14 system-image-dbus (>= 0.9),
15 ubuntu-keyboard-data (>= 0.99.trunk.phablet2+13.10.20131001),
16+# for the session-migration script
17+ python3,
18+ python3-gi,
19+ python3-dbus,
20+ gir1.2-glib-2.0
21 Recommends: ubuntu-mobile-icons,
22 ubuntu-system-settings-online-accounts,
23 ubuntu-touch-sounds,
24
25=== modified file 'debian/rules'
26--- debian/rules 2013-12-05 17:40:46 +0000
27+++ debian/rules 2014-02-24 20:53:19 +0000
28@@ -19,4 +19,4 @@
29 dh_makeshlibs -Xusr/lib/$(DEB_HOST_MULTIARCH)/ubuntu-system-settings
30
31 %:
32- dh $@ --fail-missing --with python2
33+ dh $@ --fail-missing --with python2,migrations
34
35=== added file 'debian/ubuntu-system-settings-sound-gsettings-to-accountsservice.py'
36--- debian/ubuntu-system-settings-sound-gsettings-to-accountsservice.py 1970-01-01 00:00:00 +0000
37+++ debian/ubuntu-system-settings-sound-gsettings-to-accountsservice.py 2014-02-24 20:53:19 +0000
38@@ -0,0 +1,54 @@
39+#!/usr/bin/python3
40+# -*- coding: utf-8 -*-
41+# Copyright (C) 2013 Canonical
42+#
43+# Authors:
44+# Iain Lane <iain.lane@canonical.com>
45+#
46+# This program is free software; you can redistribute it and/or modify it under
47+# the terms of the GNU General Public License as published by the Free Software
48+# Foundation; version 3.
49+#
50+# This program is distributed in the hope that it will be useful, but WITHOUTa
51+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
52+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
53+# details.
54+#
55+# You should have received a copy of the GNU General Public License along with
56+# this program; if not, write to the Free Software Foundation, Inc.,
57+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
58+
59+# Migrate ubuntu-system-settings sound panel settings from GSettings to
60+# AccountsService
61+
62+import dbus
63+import os
64+
65+from gi.repository import Gio
66+
67+system_bus = dbus.SystemBus()
68+manager_proxy = system_bus.get_object('org.freedesktop.Accounts',
69+ '/org/freedesktop/Accounts')
70+object_path = manager_proxy.FindUserById(
71+ os.getuid(), dbus_interface='org.freedesktop.Accounts')
72+user_proxy = system_bus.get_object('org.freedesktop.Accounts', object_path)
73+
74+gsettings = Gio.Settings(schema="com.ubuntu.touch.sound")
75+
76+def get_string(key):
77+ return gsettings.get_string(key)
78+
79+def get_bool(key):
80+ return gsettings.get_boolean(key)
81+
82+def set_as_setting(interface, setting, value):
83+ user_proxy.Set(interface, setting, value,
84+ dbus_interface=dbus.PROPERTIES_IFACE)
85+
86+# (gsettings key, accountsservice key, function to retrieve from gsettings)
87+keys = [('silent-mode', 'SilentMode', get_bool),
88+ ('incoming-call-sound', 'IncomingCallSound', get_string),
89+ ('incoming-message-sound', 'IncomingMessageSound', get_string)]
90+
91+for (g, a, f) in keys:
92+ set_as_setting('com.ubuntu.touch.AccountsService.Sound', a, f(g))
93
94=== added file 'debian/ubuntu-system-settings.migrations'
95--- debian/ubuntu-system-settings.migrations 1970-01-01 00:00:00 +0000
96+++ debian/ubuntu-system-settings.migrations 2014-02-24 20:53:19 +0000
97@@ -0,0 +1,1 @@
98+debian/ubuntu-system-settings-sound-gsettings-to-accountsservice.py
99
100=== modified file 'plugins/sound/CMakeLists.txt'
101--- plugins/sound/CMakeLists.txt 2013-10-22 14:44:44 +0000
102+++ plugins/sound/CMakeLists.txt 2014-02-24 20:53:19 +0000
103@@ -6,7 +6,8 @@
104
105 add_library(UbuntuSoundPanel MODULE plugin.h sound.h plugin.cpp sound.cpp
106 ${QML_SOURCES})
107-qt5_use_modules(UbuntuSoundPanel Qml Quick)
108+target_link_libraries(UbuntuSoundPanel uss-accountsservice)
109+qt5_use_modules(UbuntuSoundPanel Qml Quick DBus)
110
111 set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/Sound)
112 install(TARGETS UbuntuSoundPanel DESTINATION ${PLUG_DIR})
113
114=== modified file 'plugins/sound/PageComponent.qml'
115--- plugins/sound/PageComponent.qml 2014-01-27 11:13:58 +0000
116+++ plugins/sound/PageComponent.qml 2014-02-24 20:53:19 +0000
117@@ -23,6 +23,7 @@
118 import Ubuntu.Components 0.1
119 import Ubuntu.Components.ListItems 0.1 as ListItem
120 import SystemSettings 1.0
121+import Ubuntu.SystemSettings.Sound 1.0
122
123 import "utilities.js" as Utilities
124
125@@ -32,6 +33,8 @@
126 title: i18n.tr("Sound")
127 flickable: scrollWidget
128
129+ UbuntuSoundPanel { id: backendInfo }
130+
131 GSettings {
132 id: soundSettings
133 schema.id: "com.ubuntu.touch.sound"
134@@ -49,7 +52,7 @@
135 anchors.left: parent.left
136 anchors.right: parent.right
137
138- SilentModeWarning { visible: soundSettings.silentMode }
139+ SilentModeWarning { visible: backendInfo.silentMode }
140
141 ListItem.Standard {
142 text: i18n.tr("Phone calls:")
143@@ -58,7 +61,7 @@
144 ListItem.SingleValue {
145 text: i18n.tr("Ringtone")
146 value: Utilities.buildDisplayName(
147- soundSettings.incomingCallSound)
148+ backendInfo.incomingCallSound)
149 progression: true
150 onClicked: pageStack.push(
151 Qt.resolvedUrl("SoundsList.qml"),
152@@ -92,12 +95,12 @@
153 ListItem.SingleValue {
154 text: i18n.tr("Message received")
155 value:Utilities.buildDisplayName(
156- soundSettings.incomingMessageSound)
157+ backendInfo.incomingMessageSound)
158 progression: true
159 onClicked: pageStack.push(
160 Qt.resolvedUrl("SoundsList.qml"),
161 { title: i18n.tr("Message received"),
162- soundType: 1,
163+ soundType: 1,
164 soundsDir:
165 "/usr/share/sounds/ubuntu/notifications/" })
166 }
167
168=== modified file 'plugins/sound/SoundsList.qml'
169--- plugins/sound/SoundsList.qml 2013-11-28 18:36:25 +0000
170+++ plugins/sound/SoundsList.qml 2014-02-24 20:53:19 +0000
171@@ -24,21 +24,31 @@
172 {return soundsDir+sound})
173 soundDisplayNames = Utilities.buildSoundValues(soundFileNames)
174 if (soundType == 0)
175- soundSelector.selectedIndex = Utilities.indexSelectedFile(soundFileNames, soundSettings.incomingCallSound)
176+ soundSelector.selectedIndex =
177+ Utilities.indexSelectedFile(soundFileNames,
178+ incomingCallSound)
179 else if (soundType == 1)
180- soundSelector.selectedIndex = Utilities.indexSelectedFile(soundFileNames, soundSettings.incomingMessageSound)
181+ soundSelector.selectedIndex =
182+ Utilities.indexSelectedFile(soundFileNames,
183+ incomingMessageSound)
184+ }
185+ onIncomingCallSoundChanged: {
186+ if (soundType == 0)
187+ soundSelector.selectedIndex =
188+ Utilities.indexSelectedFile(soundFileNames,
189+ incomingCallSound)
190+ }
191+ onIncomingMessageSoundChanged: {
192+ if (soundType == 1)
193+ soundSelector.selectedIndex =
194+ Utilities.indexSelectedFile(soundFileNames,
195+ incomingMessageSound)
196 }
197 }
198
199 GSettings {
200 id: soundSettings
201 schema.id: "com.ubuntu.touch.sound"
202- onChanged: {
203- if (soundType == 0 && key == "incomingCallSound")
204- soundSelector.selectedIndex = Utilities.indexSelectedFile(soundFileNames, value)
205- if (soundType == 1 && key == "incomingMessageSound")
206- soundSelector.selectedIndex = Utilities.indexSelectedFile(soundFileNames, value)
207- }
208 }
209
210 Audio {
211@@ -50,7 +60,7 @@
212 anchors.left: parent.left
213 anchors.right: parent.right
214
215- SilentModeWarning { visible: soundSettings.silentMode }
216+ SilentModeWarning { visible: backendInfo.silentMode }
217
218 ListItem.SingleControl {
219 id: listId
220@@ -61,7 +71,7 @@
221 soundEffect.stop()
222 }
223 enabled: soundEffect.playbackState == Audio.PlayingState
224- visible: showStopButton && !soundSettings.silentMode
225+ visible: showStopButton && !backendInfo.silentMode
226 }
227 }
228
229@@ -74,12 +84,15 @@
230 expanded: true
231 model: soundDisplayNames
232 onDelegateClicked: {
233- if (soundType == 0)
234+ if (soundType == 0) {
235 soundSettings.incomingCallSound = soundFileNames[index]
236- else if (soundType == 1)
237+ backendInfo.incomingCallSound = soundFileNames[index]
238+ } else if (soundType == 1) {
239 soundSettings.incomingMessageSound = soundFileNames[index]
240+ backendInfo.incomingMessageSound = soundFileNames[index]
241+ }
242 /* Only preview the file if not in silent mode */
243- if (!soundSettings.silentMode) {
244+ if (!backendInfo.silentMode) {
245 soundEffect.source = soundFileNames[index]
246 soundEffect.play()
247 }
248
249=== modified file 'plugins/sound/sound.cpp'
250--- plugins/sound/sound.cpp 2014-01-13 11:40:54 +0000
251+++ plugins/sound/sound.cpp 2014-02-24 20:53:19 +0000
252@@ -22,15 +22,97 @@
253 #include "sound.h"
254 #include <unistd.h>
255
256+#define AS_INTERFACE "com.ubuntu.touch.AccountsService.Sound"
257+
258 Sound::Sound(QObject *parent) :
259 QObject(parent)
260 {
261-
262+ connect (&m_accountsService,
263+ SIGNAL (propertyChanged (QString, QString)),
264+ this,
265+ SLOT (slotChanged (QString, QString)));
266+
267+ connect (&m_accountsService,
268+ SIGNAL (nameOwnerChanged()),
269+ this,
270+ SLOT (slotNameOwnerChanged()));
271+}
272+
273+void Sound::slotChanged(QString interface,
274+ QString property)
275+{
276+ if (interface != AS_INTERFACE)
277+ return;
278+
279+ if (property == "SilentMode") {
280+ Q_EMIT silentModeChanged();
281+ } else if (property == "IncomingCallSound") {
282+ Q_EMIT incomingCallSoundChanged();
283+ } else if (property == "IncomingMessageSound") {
284+ Q_EMIT incomingMessageSoundChanged();
285+ }
286+}
287+
288+void Sound::slotNameOwnerChanged()
289+{
290+ // Tell QML so that it refreshes its view of the property
291+ Q_EMIT incomingCallSoundChanged();
292+ Q_EMIT incomingMessageSoundChanged();
293+ Q_EMIT silentModeChanged();
294+}
295+
296+QString Sound::getIncomingCallSound()
297+{
298+ return m_accountsService.getUserProperty(AS_INTERFACE,
299+ "IncomingCallSound").toString();
300+}
301+
302+void Sound::setIncomingCallSound(QString sound)
303+{
304+ if (sound == getIncomingCallSound())
305+ return;
306+
307+ m_accountsService.setUserProperty(AS_INTERFACE,
308+ "IncomingCallSound",
309+ QVariant::fromValue(sound));
310+ Q_EMIT(incomingCallSoundChanged());
311+}
312+
313+QString Sound::getIncomingMessageSound()
314+{
315+ return m_accountsService.getUserProperty(AS_INTERFACE,
316+ "IncomingMessageSound").toString();
317+}
318+
319+void Sound::setIncomingMessageSound(QString sound)
320+{
321+ if (sound == getIncomingMessageSound())
322+ return;
323+
324+ m_accountsService.setUserProperty(AS_INTERFACE,
325+ "IncomingMessageSound",
326+ QVariant::fromValue(sound));
327+ Q_EMIT(incomingMessageSoundChanged());
328+}
329+
330+bool Sound::getSilentMode()
331+{
332+ return m_accountsService.getUserProperty(AS_INTERFACE,
333+ "SilentMode").toBool();
334+}
335+
336+void Sound::setSilentMode(bool enabled)
337+{
338+ if (enabled == getSilentMode())
339+ return;
340+
341+ m_accountsService.setUserProperty(AS_INTERFACE,
342+ "SilentMode",
343+ QVariant::fromValue(enabled));
344+ Q_EMIT(silentModeChanged());
345 }
346
347 QStringList Sound::listSounds(const QString &dirString)
348-
349-
350 {
351 if (m_soundsList.isEmpty())
352 {
353
354=== modified file 'plugins/sound/sound.h'
355--- plugins/sound/sound.h 2014-01-13 11:40:54 +0000
356+++ plugins/sound/sound.h 2014-02-24 20:53:19 +0000
357@@ -21,6 +21,8 @@
358 #ifndef SOUND_H
359 #define SOUND_H
360
361+#include "accountsservice.h"
362+
363 #include <QObject>
364 #include <QProcess>
365
366@@ -31,10 +33,39 @@
367 public:
368 explicit Sound(QObject *parent = 0);
369 Q_INVOKABLE QStringList listSounds(const QString &dirString);
370-
371+ Q_PROPERTY (QString incomingCallSound
372+ READ getIncomingCallSound
373+ WRITE setIncomingCallSound
374+ NOTIFY incomingCallSoundChanged)
375+ Q_PROPERTY (QString incomingMessageSound
376+ READ getIncomingMessageSound
377+ WRITE setIncomingMessageSound
378+ NOTIFY incomingMessageSoundChanged)
379+ Q_PROPERTY (bool silentMode
380+ READ getSilentMode
381+ WRITE setSilentMode
382+ NOTIFY silentModeChanged)
383+
384+
385+public Q_SLOTS:
386+ void slotChanged(QString, QString);
387+ void slotNameOwnerChanged();
388+
389+Q_SIGNALS:
390+ void incomingCallSoundChanged();
391+ void incomingMessageSoundChanged();
392+ void silentModeChanged();
393
394 private:
395+ AccountsService m_accountsService;
396 QStringList m_soundsList;
397+
398+ QString getIncomingCallSound();
399+ void setIncomingCallSound(QString sound);
400+ QString getIncomingMessageSound();
401+ void setIncomingMessageSound(QString sound);
402+ bool getSilentMode();
403+ void setSilentMode(bool enabled);
404 };
405
406 #endif // SOUND_H

Subscribers

People subscribed via source and target branches