Merge lp:~seb128/phone-app/ringtone-in-gsettings into lp:phone-app

Proposed by Sebastien Bacher
Status: Work in progress
Proposed branch: lp:~seb128/phone-app/ringtone-in-gsettings
Merge into: lp:phone-app
Diff against target: 179 lines (+68/-5)
9 files modified
CMakeLists.txt (+2/-0)
cmake/modules/UseGSettings.cmake (+23/-0)
debian/control (+2/-0)
debian/phone-app.install (+1/-0)
libphoneapp/CMakeLists.txt (+2/-1)
libphoneapp/ringtone.cpp (+3/-4)
libphoneapp/ringtone.h (+2/-0)
schemas/CMakeLists.txt (+18/-0)
schemas/com.ubuntu.touch.phone-app.gschema.xml.in (+15/-0)
To merge this branch: bzr merge lp:~seb128/phone-app/ringtone-in-gsettings
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Lars Karlitski (community) Approve
Review via email: mp+176968@code.launchpad.net

Commit message

store the ringtone and new message sounds in gsettings

Description of the change

store the ringtone and new message sounds in gsettings

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Those changes are making the sounds to use for call/messages to be read from gsettings/customizable, see https://bugs.launchpad.net/phone-app/+bug/1202253 for some details

Note that I've not been able to actual test the runtime behaviour, because I don't have a working phone with a SIM ... is there any way to simulate phone calls on a desktop? The code build and is working fine in a standalone test application.

717. By Sebastien Bacher

store the ringtone and new message sounds in gsettings

Revision history for this message
Lars Karlitski (larsu) wrote :

> +find_library(QGSETTINGS_LIB gsettings-qt)

The cmake-foo is not strong with me, but I think you should use something like find_package here to pick up the pkg-config file.

> +#include <QGSettings/QGSettings>

This should only be "#include <QGSettings>". The pkgconfig file already points to the QGSettings directory, so that should work as soon as you pull in its cflags.

schemas/com.ubuntu.touch.phone-app.gschema.xml.in:
  * the summary and description for incoming-call-sound and incoming-message-sound are the same
  * the absolute paths are a bit weird - don't we have sound themes based on xdg dirs like we do for icons?

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

use correct include

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

> The cmake-foo is not strong with me, but I think you should use something like find_package here to pick up > the pkg-config file.

Thanks ... the new gsettings-qt (which features a .pc) was not available in saucy yet when I started and I though there was no .pc to use ... fixed that in r719

> This should only be "#include <QGSettings>". The pkgconfig file already points to the QGSettings directory, so that should work as soon as you pull in its cflags.

Thanks, that was a side-effect of not having the pkgconfig, fixed in r718

> schemas/com.ubuntu.touch.phone-app.gschema.xml.in:
> * the summary and description for incoming-call-sound and incoming-message-sound are the same

Fixed that one as well

> * the absolute paths are a bit weird - don't we have sound themes based on xdg dirs like we do for icons?

I've no strong opinion, I went with the current approch since it allows to set a file anywhere on disk (e.g a music from your xdg music dir), I'm not sure if you can do that with the theme spec.

I think the spec makes sense for system effects for example, maybe not in that "custom sound" case

719. By Sebastien Bacher

use pkgconfig since gsettings-qt just got one

Revision history for this message
Lars Karlitski (larsu) wrote :

> I've no strong opinion, I went with the current approch since it allows to set
> a file anywhere on disk (e.g a music from your xdg music dir), I'm not sure if
> you can do that with the theme spec.
>
> I think the spec makes sense for system effects for example, maybe not in that
> "custom sound" case

Okay, that makes sense.

Thanks for the quick fixes. Looks good to me now.

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

Unmerged revisions

719. By Sebastien Bacher

use pkgconfig since gsettings-qt just got one

718. By Sebastien Bacher

use correct include

717. By Sebastien Bacher

store the ringtone and new message sounds in gsettings

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 2013-05-24 13:08:32 +0000
3+++ CMakeLists.txt 2013-07-25 16:20:35 +0000
4@@ -62,6 +62,7 @@
5 pkg_check_modules(GLIB REQUIRED glib-2.0)
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
10 # Check if the messaging menu has the message header
11 set(CMAKE_REQUIRED_INCLUDES ${MESSAGING_MENU_INCLUDE_DIRS})
12@@ -89,3 +90,4 @@
13 add_subdirectory(icons)
14 add_subdirectory(tests)
15 add_subdirectory(po)
16+add_subdirectory(schemas)
17
18=== added file 'cmake/modules/UseGSettings.cmake'
19--- cmake/modules/UseGSettings.cmake 1970-01-01 00:00:00 +0000
20+++ cmake/modules/UseGSettings.cmake 2013-07-25 16:20:35 +0000
21@@ -0,0 +1,23 @@
22+# GSettings.cmake, CMake macros written for Marlin, feel free to re-use them.
23+
24+macro(add_schema SCHEMA_NAME)
25+
26+ set(PKG_CONFIG_EXECUTABLE pkg-config)
27+ set(GSETTINGS_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/glib-2.0/schemas")
28+
29+ # Run the validator and error if it fails
30+ execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE _glib_compile_schemas OUTPUT_STRIP_TRAILING_WHITESPACE)
31+ execute_process (COMMAND ${_glib_compile_schemas} --dry-run --schema-file=${SCHEMA_NAME} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE)
32+
33+ if (_schemas_invalid)
34+ message (SEND_ERROR "Schema validation error: ${_schemas_invalid}")
35+ endif (_schemas_invalid)
36+
37+ # Actually install and recomple schemas
38+ message (STATUS "${GSETTINGS_DIR} is the GSettings install dir")
39+ install (FILES ${SCHEMA_NAME} DESTINATION ${GSETTINGS_DIR} OPTIONAL)
40+
41+ install (CODE "message (STATUS \"Compiling GSettings schemas\")")
42+ install (CODE "execute_process (COMMAND ${_glib_compile_schemas} ${GSETTINGS_DIR})")
43+endmacro()
44+
45
46=== modified file 'debian/control'
47--- debian/control 2013-06-27 13:27:53 +0000
48+++ debian/control 2013-07-25 16:20:35 +0000
49@@ -7,6 +7,8 @@
50 dh-translations,
51 libgl1-mesa-dev | libgl-dev,
52 libgles2-mesa-dev,
53+ libglib2.0-dev,
54+ libgsettings-qt-dev,
55 libicu-dev,
56 libmessaging-menu-dev,
57 libnotify-dev,
58
59=== modified file 'debian/phone-app.install'
60--- debian/phone-app.install 2013-05-24 13:08:32 +0000
61+++ debian/phone-app.install 2013-07-25 16:20:35 +0000
62@@ -2,6 +2,7 @@
63 etc/xdg/autostart/phone-app-approver.desktop
64 usr/share/icons/hicolor/*/apps/phone-app*.png
65 usr/share/icons/ubuntu-mono-dark/status/*/indicator-call.svg
66+usr/share/glib-2.0
67 usr/share/applications/phone-app*.desktop
68 usr/share/dbus-1/services/*PhoneApp*.service
69 usr/share/notify-osd/icons/gnome/scalable/status/notification-unknown-call.svg
70
71=== modified file 'libphoneapp/CMakeLists.txt'
72--- libphoneapp/CMakeLists.txt 2013-04-03 19:25:46 +0000
73+++ libphoneapp/CMakeLists.txt 2013-07-25 16:20:35 +0000
74@@ -21,11 +21,12 @@
75 ${TPL_QT5_INCLUDE_DIRS}
76 ${QTGLIB_INCLUDE_DIRS}
77 ${GLIB_INCLUDE_DIRS}
78+ ${GSETTINGS_INCLUDE_DIRS}
79 )
80
81
82 add_library(phoneapp STATIC ${library_SRCS} ${library_HDRS})
83-target_link_libraries(phoneapp ${TP_QT5_LIBRARIES})
84+target_link_libraries(phoneapp ${TP_QT5_LIBRARIES} ${GSETTINGS_LIBRARIES})
85
86 qt5_use_modules(phoneapp Contacts Core DBus Multimedia Qml Quick)
87
88
89=== modified file 'libphoneapp/ringtone.cpp'
90--- libphoneapp/ringtone.cpp 2013-03-11 22:22:35 +0000
91+++ libphoneapp/ringtone.cpp 2013-07-25 16:20:35 +0000
92@@ -22,12 +22,11 @@
93 #include "ringtone.h"
94 #include <QDebug>
95
96-#define SOUND_PATH "/usr/share/sounds/ubuntu/stereo/"
97 Ringtone::Ringtone(QObject *parent) :
98 QObject(parent),
99- mCallAudioPlayer(this), mCallAudioPlaylist(this), mMessageAudioPlayer(this)
100+ mCallAudioPlayer(this), mCallAudioPlaylist(this), mMessageAudioPlayer(this), mSoundSettings("com.ubuntu.touch.phone-app")
101 {
102- mCallAudioPlaylist.addMedia(QUrl::fromLocalFile(SOUND_PATH "phone-incoming-call.ogg"));
103+ mCallAudioPlaylist.addMedia(QUrl::fromLocalFile(mSoundSettings.get("incomingCallSound").toString()));
104 mCallAudioPlaylist.setPlaybackMode(QMediaPlaylist::Loop);
105 mCallAudioPlaylist.setCurrentIndex(0);
106 }
107@@ -60,7 +59,7 @@
108 return;
109 }
110
111- mMessageAudioPlayer.setMedia(QUrl::fromLocalFile(SOUND_PATH "message-new-instant.ogg"));
112+ mMessageAudioPlayer.setMedia(QUrl::fromLocalFile(mSoundSettings.get("incomingMessageSound").toString()));
113 mMessageAudioPlayer.play();
114 }
115
116
117=== modified file 'libphoneapp/ringtone.h'
118--- libphoneapp/ringtone.h 2013-03-11 22:22:35 +0000
119+++ libphoneapp/ringtone.h 2013-07-25 16:20:35 +0000
120@@ -22,6 +22,7 @@
121 #ifndef RINGTONE_H
122 #define RINGTONE_H
123
124+#include <QGSettings>
125 #include <QObject>
126 #include <QMediaPlayer>
127 #include <QMediaPlaylist>
128@@ -47,6 +48,7 @@
129 QMediaPlaylist mCallAudioPlaylist;
130
131 QMediaPlayer mMessageAudioPlayer;
132+ QGSettings mSoundSettings;
133 };
134
135 #endif // RINGTONE_H
136
137=== added directory 'schemas'
138=== added file 'schemas/CMakeLists.txt'
139--- schemas/CMakeLists.txt 1970-01-01 00:00:00 +0000
140+++ schemas/CMakeLists.txt 2013-07-25 16:20:35 +0000
141@@ -0,0 +1,18 @@
142+include (UseGSettings)
143+
144+##
145+## GSettings schema
146+##
147+
148+set (SCHEMA_NAME "com.ubuntu.touch.phone-app.gschema.xml")
149+set (SCHEMA_FILE "${CMAKE_CURRENT_BINARY_DIR}/${SCHEMA_NAME}")
150+set (SCHEMA_FILE_IN "${CMAKE_CURRENT_SOURCE_DIR}/${SCHEMA_NAME}.in")
151+
152+# generate the .xml file using intltool
153+set (ENV{LC_ALL} "C")
154+execute_process (COMMAND intltool-merge -quiet --xml-style --utf8 --no-translations "${SCHEMA_FILE_IN}" "${SCHEMA_FILE}")
155+
156+# let UseGSettings do the rest
157+add_schema (${SCHEMA_FILE})
158+
159+
160
161=== added file 'schemas/com.ubuntu.touch.phone-app.gschema.xml.in'
162--- schemas/com.ubuntu.touch.phone-app.gschema.xml.in 1970-01-01 00:00:00 +0000
163+++ schemas/com.ubuntu.touch.phone-app.gschema.xml.in 2013-07-25 16:20:35 +0000
164@@ -0,0 +1,15 @@
165+<schemalist>
166+ <schema id="com.ubuntu.touch.phone-app" path="/com/ubuntu/touch/phone-app/">
167+ <key name="incoming-call-sound" type="s">
168+ <default>"/usr/share/sounds/ubuntu/stereo/phone-incoming-call.ogg"</default>
169+ <_summary>Ringtone sound for the phone application.</_summary>
170+ <_description>This sound file is played, on incoming calls, by the phone application.</_description>
171+ </key>
172+ <key name="incoming-message-sound" type="s">
173+ <default>"/usr/share/sounds/ubuntu/stereo/message-new-instant.ogg"</default>
174+ <_summary>Incoming message sound for the phone application.</_summary>
175+ <_description>This sound file is played, on incoming messages, by the phone application.</_description>
176+ </key>
177+ </schema>
178+</schemalist>
179+

Subscribers

People subscribed via source and target branches