Merge lp:~dobey/indicator-sound/initial-cpp into lp:indicator-sound

Proposed by dobey
Status: Approved
Approved by: dobey
Approved revision: 554
Proposed branch: lp:~dobey/indicator-sound/initial-cpp
Merge into: lp:indicator-sound
Prerequisite: lp:~dobey/indicator-sound/drop-greeeter
Diff against target: 152 lines (+46/-50)
2 files modified
src/CMakeLists.txt (+1/-1)
src/main.cpp (+45/-49)
To merge this branch: bzr merge lp:~dobey/indicator-sound/initial-cpp
Reviewer Review Type Date Requested Status
unity-api-1-bot continuous-integration Approve
Charles Kerr (community) Approve
Review via email: mp+320974@code.launchpad.net

Commit message

Move the core mainloop code to C++.

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

It's a start. :)

On a side note, you might want to disable the tests that we know will be failing (PA?) so that we can benefit from Jenkins checking things as the port from vala to C++ progresses.

review: Approve
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:554
https://jenkins.canonical.com/unity-api-1/job/lp-indicator-sound-ci/25/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1895
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1902
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1684
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1684/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1684
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1684/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1684
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1684/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1684
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1684/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1684
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1684/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1684
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1684/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-indicator-sound-ci/25/rebuild

review: Approve (continuous-integration)

Unmerged revisions

554. By dobey

More use of glib memory helpers.

553. By dobey

Move some of mainloop code to C++.

552. By dobey

Strip out the complicated non-working greeter support.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2017-03-24 18:01:58 +0000
+++ src/CMakeLists.txt 2017-03-24 18:01:58 +0000
@@ -235,7 +235,7 @@
235235
236add_executable(236add_executable(
237 indicator-sound-service-bin237 indicator-sound-service-bin
238 main.c238 main.cpp
239)239)
240240
241set_target_properties(241set_target_properties(
242242
=== renamed file 'src/main.c' => 'src/main.cpp'
--- src/main.c 2017-03-24 18:01:58 +0000
+++ src/main.cpp 2017-03-24 18:01:58 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2015 Canonical Ltd.2 * Copyright © 2015-2017 Canonical Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -14,23 +14,23 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17#include "indicator-sound-service.h"
18#include "config.h"
19
17#include <glib.h>20#include <glib.h>
21#include <glib-unix.h>
22#include <libintl.h>
18#include <locale.h>23#include <locale.h>
19#include <libnotify/notify.h>24#include <libnotify/notify.h>
2025
21#include "indicator-sound-service.h"26#include <memory>
22#include "config.h"27#include <unity/util/GObjectMemory.h>
2328#include <unity/util/GlibMemory.h>
24static IndicatorSoundService * service = NULL;29
25static pa_glib_mainloop * pgloop = NULL;30using namespace unity::util;
2631
27static gboolean32static std::shared_ptr<IndicatorSoundService> service;
28sigterm_handler (gpointer data)33static std::shared_ptr<pa_glib_mainloop> pgloop;
29{
30 g_debug("Got SIGTERM");
31 g_main_loop_quit((GMainLoop *)data);
32 return G_SOURCE_REMOVE;
33}
3434
35static void35static void
36on_name_lost(GDBusConnection * connection,36on_name_lost(GDBusConnection * connection,
@@ -46,61 +46,57 @@
46 const gchar *name,46 const gchar *name,
47 gpointer user_data)47 gpointer user_data)
48{48{
49 MediaPlayerList * playerlist = NULL;49 pgloop = share_gobject(pa_glib_mainloop_new(nullptr));
50 IndicatorSoundOptions * options = NULL;50
51 VolumeControlPulse * volume = NULL;51 auto playerlist = unique_gobject(media_player_list_mpris_new());
52 AccountsServiceUser * accounts = NULL;52 auto accounts = unique_gobject(accounts_service_user_new());
53 VolumeWarning * warning = NULL;53 auto options = unique_gobject(indicator_sound_options_gsettings_new());
54 AccountsServiceAccess * accounts_service_access = NULL;54 auto accounts_service_access = unique_gobject(accounts_service_access_new());
5555 auto volume = unique_gobject(volume_control_pulse_new(INDICATOR_SOUND_OPTIONS(options.get()),
5656 pgloop.get(),
57 playerlist = MEDIA_PLAYER_LIST(media_player_list_mpris_new());57 accounts_service_access.get()));
58 accounts = accounts_service_user_new();58 auto warning = unique_gobject(volume_warning_pulse_new(INDICATOR_SOUND_OPTIONS(options.get()),
5959 pgloop.get()));
60 pgloop = pa_glib_mainloop_new(NULL);60
61 options = indicator_sound_options_gsettings_new();61 service = share_gobject(indicator_sound_service_new(MEDIA_PLAYER_LIST(playerlist.get()),
62 accounts_service_access = accounts_service_access_new();62 VOLUME_CONTROL(volume.get()),
63 volume = volume_control_pulse_new(options, pgloop, accounts_service_access);63 accounts.get(),
64 warning = volume_warning_pulse_new(options, pgloop);64 INDICATOR_SOUND_OPTIONS(options.get()),
6565 VOLUME_WARNING(warning.get()),
66 service = indicator_sound_service_new (playerlist, volume, accounts, options, warning, accounts_service_access);66 accounts_service_access.get()));
67
68 g_clear_object(&playerlist);
69 g_clear_object(&options);
70 g_clear_object(&volume);
71 g_clear_object(&accounts);
72 g_clear_object(&warning);
73}67}
7468
75int69int
76main (int argc, char ** argv)70main (int argc, char ** argv)
77{71{
78 GMainLoop * loop = NULL;
79 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");72 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
80 setlocale (LC_ALL, "");73 setlocale (LC_ALL, "");
81 bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);74 bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
8275
83 /* Build Mainloop */76 /* Build Mainloop */
84 loop = g_main_loop_new(NULL, FALSE);77 auto loop = unique_glib(g_main_loop_new(nullptr, false));
8578
86 g_unix_signal_add(SIGTERM, sigterm_handler, loop);79 g_unix_signal_add(SIGTERM,
80 [](gpointer data) {
81 g_main_loop_quit(static_cast<GMainLoop*>(data));
82 return G_SOURCE_REMOVE;
83 },
84 loop.get());
8785
88 /* Initialize libnotify */86 /* Initialize libnotify */
89 notify_init ("indicator-sound");87 notify_init ("indicator-sound");
9088
89 // TODO: Move bus ownership out of main() once vala is gone
91 g_bus_own_name(G_BUS_TYPE_SESSION,90 g_bus_own_name(G_BUS_TYPE_SESSION,
92 "com.canonical.indicator.sound",91 "com.canonical.indicator.sound",
93 G_BUS_NAME_OWNER_FLAGS_NONE,92 G_BUS_NAME_OWNER_FLAGS_NONE,
94 on_bus_acquired,93 on_bus_acquired,
95 NULL, /* name acquired */94 nullptr, /* name acquired */
96 on_name_lost,95 on_name_lost,
97 loop,96 loop.get(),
98 NULL);97 nullptr);
9998
100 g_main_loop_run(loop);99 g_main_loop_run(loop.get());
101
102 g_clear_object(&service);
103 g_clear_pointer(&pgloop, pa_glib_mainloop_free);
104100
105 notify_uninit();101 notify_uninit();
106102

Subscribers

People subscribed via source and target branches