Merge lp:~laney/telephony-service/accountsservice into lp:telephony-service

Proposed by Iain Lane
Status: Merged
Merged at revision: 780
Proposed branch: lp:~laney/telephony-service/accountsservice
Merge into: lp:telephony-service
Diff against target: 295 lines (+129/-17)
7 files modified
CMakeLists.txt (+0/-1)
approver/CMakeLists.txt (+0/-2)
debian/control (+1/-2)
indicator/CMakeLists.txt (+0/-2)
libtelephonyservice/CMakeLists.txt (+1/-3)
libtelephonyservice/ringtone.cpp (+103/-5)
libtelephonyservice/ringtone.h (+24/-2)
To merge this branch: bzr merge lp:~laney/telephony-service/accountsservice
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Michael Terry Approve
Gustavo Pichorim Boiko (community) Approve
Review via email: mp+201630@code.launchpad.net

Commit message

Read the user's ringtone, message tone and silent mode settings from AccountsService instead of GSettings

Description of the change

Once https://code.launchpad.net/~laney/ubuntu-system-settings/as-ringtone/+merge/200862 is released to distro, u-s-s will set accountsservice properties for the ringtone, message tone and silent-mode.

This branch converts telephony-service to read those.

It just does it for the current user. In future, we'll need to use logind to get the active user and play that user's ringtone. That's the important part we win by switching 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)
Revision history for this message
Iain Lane (laney) wrote :

@boiko: hey, could you review this please?

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

271 + void slotChanged(QString, QVariantMap, QStringList);
272 + void slotNameOwnerChanged(QString, QString, QString);

Just to be consistent with other classes, would you mind renaming those to:
onChanged and onNameOwnerChanged ?

review: Needs Fixing
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

I tried the code from this MR together with the other required packages, and it works for the first time, but if telephony-service-approver is already running, it doesn't seem to be reading the new incoming call sound correctly.

review: Needs Fixing
765. By Iain Lane

Rename slot* to on*

766. By Iain Lane

Use invalidatedProperties instead of changedProperties to fix change notification

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

Fixed both, I think - could you try again?

If you like, you can use a command like

  sudo gdbus call -y -d org.freedesktop.Accounts -o /org/freedesktop/Accounts/User32011 -m org.freedesktop.DBus.Properties.Set com.ubuntu.touch.AccountsService.Sound IncomingCallSound "<'/usr/share/sounds/ubuntu/ringtones/Soul.ogg'>"

to update the ringtone so that you don't have to go through system-settings.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good now, and works as expected!

review: Approve
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

As this needs to be synchronized with the ubuntu-system-settings MR, feel free to top approve it once the changes are ready to land.

Revision history for this message
Bill Filler (bfiller) wrote :

@laney
Is there an MR for the u-s-s related change that is necessary? Can request a release for both together..

Revision history for this message
Bill Filler (bfiller) wrote :

nm, see it in the description

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

Just tested this, works great.

review: Approve
767. By Iain Lane

Merge trunk

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-01-07 19:53:45 +0000
3+++ CMakeLists.txt 2014-03-03 16:11:46 +0000
4@@ -61,7 +61,6 @@
5 pkg_check_modules(TP_QT5 REQUIRED TelepathyQt5)
6 pkg_check_modules(NOTIFY REQUIRED libnotify)
7 pkg_check_modules(MESSAGING_MENU REQUIRED messaging-menu)
8-pkg_check_modules(GSETTINGS REQUIRED gsettings-qt)
9 pkg_check_modules(UserMetrics REQUIRED libusermetricsinput-1)
10
11 add_definitions(-DQT_NO_KEYWORDS)
12
13=== modified file 'approver/CMakeLists.txt'
14--- approver/CMakeLists.txt 2013-12-21 23:44:41 +0000
15+++ approver/CMakeLists.txt 2014-03-03 16:11:46 +0000
16@@ -11,7 +11,6 @@
17 include_directories(
18 ${TP_QT5_INCLUDE_DIRS}
19 ${NOTIFY_INCLUDE_DIRS}
20- ${GSETTINGS_INCLUDE_DIRS}
21 ${CMAKE_SOURCE_DIR}/libtelephonyservice
22 ${CMAKE_CURRENT_BINARY_DIR}
23 )
24@@ -25,7 +24,6 @@
25 target_link_libraries(telephony-service-approver
26 ${TP_QT5_LIBRARIES}
27 ${NOTIFY_LIBRARIES}
28- ${GSETTINGS_LIBRARIES}
29 telephonyservice
30 )
31
32
33=== modified file 'debian/control'
34--- debian/control 2014-01-29 15:16:16 +0000
35+++ debian/control 2014-03-03 16:11:46 +0000
36@@ -10,7 +10,6 @@
37 gnome-keyring,
38 libgl1-mesa-dev | libgl-dev,
39 libgles2-mesa-dev,
40- libgsettings-qt-dev,
41 libicu-dev,
42 libmessaging-menu-dev,
43 libnotify-dev,
44@@ -40,7 +39,7 @@
45 Pre-Depends: dpkg (>= 1.15.6~)
46 Conflicts: phone-app
47 Replaces: phone-app
48-Depends: gsettings-ubuntu-touch-schemas (>= 0.0.1+13.10.20130730),
49+Depends: accountsservice-ubuntu-touch-schemas,
50 history-service,
51 libnotify4,
52 telepathy-mission-control-5,
53
54=== modified file 'indicator/CMakeLists.txt'
55--- indicator/CMakeLists.txt 2013-09-25 21:18:46 +0000
56+++ indicator/CMakeLists.txt 2014-03-03 16:11:46 +0000
57@@ -13,7 +13,6 @@
58 ${TP_QT5_INCLUDE_DIRS}
59 ${NOTIFY_INCLUDE_DIRS}
60 ${MESSAGING_MENU_INCLUDE_DIRS}
61- ${GSETTINGS_INCLUDE_DIRS}
62 ${CMAKE_SOURCE_DIR}/libtelephonyservice
63 ${CMAKE_CURRENT_BINARY_DIR}
64 ${UserMetrics_INCLUDE_DIRS}
65@@ -28,7 +27,6 @@
66 ${TP_QT5_LIBRARIES}
67 ${NOTIFY_LIBRARIES}
68 ${MESSAGING_MENU_LIBRARIES}
69- ${GSETTINGS_LIBRARIES}
70 ${UserMetrics_LIBRARIES}
71 telephonyservice
72 )
73
74=== modified file 'libtelephonyservice/CMakeLists.txt'
75--- libtelephonyservice/CMakeLists.txt 2014-01-20 12:57:43 +0000
76+++ libtelephonyservice/CMakeLists.txt 2014-03-03 16:11:46 +0000
77@@ -13,7 +13,6 @@
78
79 include_directories(
80 ${TP_QT5_INCLUDE_DIRS}
81- ${GSETTINGS_INCLUDE_DIRS}
82 ${NOTIFY_INCLUDE_DIRS}
83 )
84
85@@ -25,8 +24,7 @@
86 target_link_libraries(telephonyservice
87 ${TP_QT5_LIBRARIES}
88 ${UBUNTU_APP_LIB}
89- ${NOTIFY_LIBRARIES}
90- ${GSETTINGS_LIBRARIES})
91+ ${NOTIFY_LIBRARIES})
92
93 qt5_use_modules(telephonyservice Contacts Core DBus Multimedia Qml Quick)
94
95
96=== modified file 'libtelephonyservice/ringtone.cpp'
97--- libtelephonyservice/ringtone.cpp 2013-08-29 22:10:16 +0000
98+++ libtelephonyservice/ringtone.cpp 2014-03-03 16:11:46 +0000
99@@ -21,17 +21,115 @@
100
101 #include "ringtone.h"
102
103+#define AS_SERVICE "org.freedesktop.Accounts"
104+#define AS_PATH "/org/freedesktop/Accounts"
105+#define AS_IFACE "org.freedesktop.Accounts"
106+#define AS_EXTENSION_IFACE "com.ubuntu.touch.AccountsService.Sound"
107+
108 RingtoneWorker::RingtoneWorker(QObject *parent) :
109 QObject(parent), mCallAudioPlayer(this), mCallAudioPlaylist(this),
110- mMessageAudioPlayer(this), mSoundSettings("com.ubuntu.touch.sound")
111+ mMessageAudioPlayer(this),
112+ mSystemBusConnection(QDBusConnection::systemBus()),
113+ mServiceWatcher(AS_SERVICE,
114+ mSystemBusConnection,
115+ QDBusServiceWatcher::WatchForOwnerChange),
116+ mAccountsserviceIface(AS_SERVICE,
117+ AS_PATH,
118+ AS_IFACE,
119+ mSystemBusConnection)
120 {
121 mCallAudioPlaylist.setPlaybackMode(QMediaPlaylist::Loop);
122 mCallAudioPlaylist.setCurrentIndex(0);
123+
124+ connect (&mServiceWatcher,
125+ SIGNAL (serviceOwnerChanged (QString, QString, QString)),
126+ this,
127+ SLOT (onNameOwnerChanged (QString, QString, QString)));
128+
129+ if (mAccountsserviceIface.isValid()) {
130+ setUpInterface();
131+ }
132+}
133+
134+void RingtoneWorker::onNameOwnerChanged(QString name,
135+ QString oldOwner,
136+ QString newOwner)
137+{
138+ Q_UNUSED (oldOwner);
139+ Q_UNUSED (newOwner);
140+ if (name != "org.freedesktop.Accounts")
141+ return;
142+
143+ setUpInterface();
144+}
145+
146+void RingtoneWorker::onChanged(QString interface,
147+ QVariantMap changedProperties,
148+ QStringList invalidatedProperties)
149+{
150+ Q_UNUSED (interface);
151+ Q_UNUSED (changedProperties);
152+
153+ if (invalidatedProperties.contains("SilentMode"))
154+ mSilentMode = getUserProperty("SilentMode").toBool();
155+
156+ if (invalidatedProperties.contains("IncomingCallSound"))
157+ mIncomingCallSound = getUserProperty("IncomingCallSound").toString();
158+
159+ if (invalidatedProperties.contains("IncomingMessageSound"))
160+ mIncomingMessageSound = getUserProperty("IncomingMessageSound").toString();
161+}
162+
163+void RingtoneWorker::setUpInterface()
164+{
165+ /* Here we should figure out which is the active user and get that user's
166+ * AS object path. */
167+ QDBusReply<QDBusObjectPath> qObjectPath = mAccountsserviceIface.call(
168+ "FindUserById", qlonglong(getuid()));
169+
170+ if (qObjectPath.isValid()) {
171+ mObjectPath = qObjectPath.value().path();
172+ mAccountsserviceIface.connection().connect(
173+ mAccountsserviceIface.service(),
174+ mObjectPath,
175+ "org.freedesktop.DBus.Properties",
176+ "PropertiesChanged",
177+ this,
178+ SLOT(onChanged(QString, QVariantMap, QStringList)));
179+
180+ mSilentMode = getUserProperty("SilentMode").toBool();
181+ mIncomingCallSound = getUserProperty("IncomingCallSound").toString();
182+ mIncomingMessageSound = getUserProperty("IncomingMessageSound").toString();
183+ }
184+}
185+
186+QVariant RingtoneWorker::getUserProperty(const QString property)
187+{
188+ if (!mAccountsserviceIface.isValid())
189+ return QVariant();
190+
191+ QDBusInterface iface (
192+ "org.freedesktop.Accounts",
193+ mObjectPath,
194+ "org.freedesktop.DBus.Properties",
195+ mSystemBusConnection,
196+ this);
197+
198+ if (iface.isValid()) {
199+ QDBusReply<QDBusVariant> answer = iface.call(
200+ "Get",
201+ AS_EXTENSION_IFACE,
202+ property);
203+ if (answer.isValid()) {
204+ return answer.value().variant();
205+ }
206+ }
207+ return QVariant();
208 }
209
210 void RingtoneWorker::playIncomingCallSound()
211 {
212- if (mSoundSettings.get("silentMode") == true) {
213+ if (mSilentMode) {
214 return;
215 }
216
217@@ -40,7 +138,7 @@
218 }
219
220 mCallAudioPlaylist.clear();
221- mCallAudioPlaylist.addMedia(QUrl::fromLocalFile(mSoundSettings.get("incomingCallSound").toString()));
222+ mCallAudioPlaylist.addMedia(QUrl::fromLocalFile(mIncomingCallSound));
223 mCallAudioPlayer.setPlaylist(&mCallAudioPlaylist);
224 mCallAudioPlayer.play();
225 }
226@@ -52,7 +150,7 @@
227
228 void RingtoneWorker::playIncomingMessageSound()
229 {
230- if (mSoundSettings.get("silentMode") == true) {
231+ if (mSilentMode) {
232 return;
233 }
234
235@@ -60,7 +158,7 @@
236 return;
237 }
238
239- mMessageAudioPlayer.setMedia(QUrl::fromLocalFile(mSoundSettings.get("incomingMessageSound").toString()));
240+ mMessageAudioPlayer.setMedia(QUrl::fromLocalFile(mIncomingMessageSound));
241 mMessageAudioPlayer.play();
242 }
243
244
245=== modified file 'libtelephonyservice/ringtone.h'
246--- libtelephonyservice/ringtone.h 2013-08-23 01:49:53 +0000
247+++ libtelephonyservice/ringtone.h 2014-03-03 16:11:46 +0000
248@@ -24,10 +24,15 @@
249
250 #include <QObject>
251 #include <QThread>
252-#include <QGSettings>
253 #include <QMediaPlayer>
254 #include <QMediaPlaylist>
255 #include <QFile>
256+#include <QDBusReply>
257+#include <QDBusServiceWatcher>
258+#include <QtDBus/QDBusInterface>
259+#include <unistd.h>
260+#include <sys/types.h>
261+
262
263 class RingtoneWorker : public QObject
264 {
265@@ -40,12 +45,29 @@
266 void stopIncomingCallSound();
267 void playIncomingMessageSound();
268 void stopIncomingMessageSound();
269+
270+
271+private Q_SLOTS:
272+ void onChanged(QString, QVariantMap, QStringList);
273+ void onNameOwnerChanged(QString, QString, QString);
274+
275 private:
276 QMediaPlayer mCallAudioPlayer;
277 QMediaPlaylist mCallAudioPlaylist;
278
279 QMediaPlayer mMessageAudioPlayer;
280- QGSettings mSoundSettings;
281+
282+ QDBusConnection mSystemBusConnection;
283+ QDBusServiceWatcher mServiceWatcher;
284+ QDBusInterface mAccountsserviceIface;
285+ QString mObjectPath;
286+
287+ bool mSilentMode;
288+ QString mIncomingCallSound;
289+ QString mIncomingMessageSound;
290+
291+ void setUpInterface();
292+ QVariant getUserProperty(const QString property);
293 };
294
295 class Ringtone : public QObject

Subscribers

People subscribed via source and target branches

to all changes: