aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-02-23 13:48:46 +0100
committerXavi Garcia Mena <xavi.garcia.mena@canonical.com>2016-02-23 13:48:46 +0100
commite40da89a473b15b64d036cdce2e1ead59770778b (patch)
tree1de74f75836e8c7246544ad08be30fa6ba729065 /src/main.c
parent957c495207b8c53ffa9d3622c24fdff4f31cebfa (diff)
downloadayatana-indicator-sound-e40da89a473b15b64d036cdce2e1ead59770778b.tar.gz
ayatana-indicator-sound-e40da89a473b15b64d036cdce2e1ead59770778b.tar.bz2
ayatana-indicator-sound-e40da89a473b15b64d036cdce2e1ead59770778b.zip
Created new class AccountsServiceAccess to hold all accounts service operations
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c108
1 files changed, 55 insertions, 53 deletions
diff --git a/src/main.c b/src/main.c
index f4a59b2..43e330d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -27,9 +27,9 @@ static pa_glib_mainloop * pgloop = NULL;
static gboolean
sigterm_handler (gpointer data)
{
- g_debug("Got SIGTERM");
- g_main_loop_quit((GMainLoop *)data);
- return G_SOURCE_REMOVE;
+ g_debug("Got SIGTERM");
+ g_main_loop_quit((GMainLoop *)data);
+ return G_SOURCE_REMOVE;
}
static void
@@ -37,8 +37,8 @@ on_name_lost(GDBusConnection * connection,
const gchar * name,
gpointer user_data)
{
- g_warning("Name lost or unable to acquire bus: %s", name);
- g_main_loop_quit((GMainLoop *)user_data);
+ g_warning("Name lost or unable to acquire bus: %s", name);
+ g_main_loop_quit((GMainLoop *)user_data);
}
static void
@@ -46,66 +46,68 @@ on_bus_acquired(GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
- MediaPlayerList * playerlist = NULL;
- IndicatorSoundOptions * options = NULL;
- VolumeControlPulse * volume = NULL;
- AccountsServiceUser * accounts = NULL;
- VolumeWarning * warning = NULL;
-
-
- if (g_strcmp0("lightdm", g_get_user_name()) == 0) {
- playerlist = MEDIA_PLAYER_LIST(media_player_list_greeter_new());
- } else {
- playerlist = MEDIA_PLAYER_LIST(media_player_list_mpris_new());
- accounts = accounts_service_user_new();
- }
-
- pgloop = pa_glib_mainloop_new(NULL);
- options = indicator_sound_options_gsettings_new();
- volume = volume_control_pulse_new(options, pgloop);
- warning = volume_warning_pulse_new(options, pgloop);
-
- service = indicator_sound_service_new (playerlist, volume, accounts, options, warning);
-
- g_clear_object(&playerlist);
- g_clear_object(&options);
- g_clear_object(&volume);
- g_clear_object(&accounts);
- g_clear_object(&warning);
+ MediaPlayerList * playerlist = NULL;
+ IndicatorSoundOptions * options = NULL;
+ VolumeControlPulse * volume = NULL;
+ AccountsServiceUser * accounts = NULL;
+ VolumeWarning * warning = NULL;
+ AccountsServiceAccess * accounts_service_access = NULL;
+
+
+ if (g_strcmp0("lightdm", g_get_user_name()) == 0) {
+ playerlist = MEDIA_PLAYER_LIST(media_player_list_greeter_new());
+ } else {
+ playerlist = MEDIA_PLAYER_LIST(media_player_list_mpris_new());
+ accounts = accounts_service_user_new();
+ }
+
+ pgloop = pa_glib_mainloop_new(NULL);
+ options = indicator_sound_options_gsettings_new();
+ accounts_service_access = accounts_service_access_new();
+ volume = volume_control_pulse_new(options, pgloop, accounts_service_access);
+ warning = volume_warning_pulse_new(options, pgloop);
+
+ service = indicator_sound_service_new (playerlist, volume, accounts, options, warning, accounts_service_access);
+
+ g_clear_object(&playerlist);
+ g_clear_object(&options);
+ g_clear_object(&volume);
+ g_clear_object(&accounts);
+ g_clear_object(&warning);
}
int
main (int argc, char ** argv)
{
- GMainLoop * loop = NULL;
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
- setlocale (LC_ALL, "");
- bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+ GMainLoop * loop = NULL;
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ setlocale (LC_ALL, "");
+ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
- /* Build Mainloop */
- loop = g_main_loop_new(NULL, FALSE);
+ /* Build Mainloop */
+ loop = g_main_loop_new(NULL, FALSE);
- g_unix_signal_add(SIGTERM, sigterm_handler, loop);
+ g_unix_signal_add(SIGTERM, sigterm_handler, loop);
- /* Initialize libnotify */
- notify_init ("indicator-sound");
+ /* Initialize libnotify */
+ notify_init ("indicator-sound");
- g_bus_own_name(G_BUS_TYPE_SESSION,
- "com.canonical.indicator.sound",
- G_BUS_NAME_OWNER_FLAGS_NONE,
- on_bus_acquired,
- NULL, /* name acquired */
- on_name_lost,
- loop,
- NULL);
+ g_bus_own_name(G_BUS_TYPE_SESSION,
+ "com.canonical.indicator.sound",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ on_bus_acquired,
+ NULL, /* name acquired */
+ on_name_lost,
+ loop,
+ NULL);
- g_main_loop_run(loop);
+ g_main_loop_run(loop);
- g_clear_object(&service);
- g_clear_pointer(&pgloop, pa_glib_mainloop_free);
+ g_clear_object(&service);
+ g_clear_pointer(&pgloop, pa_glib_mainloop_free);
- notify_uninit();
+ notify_uninit();
- return 0;
+ return 0;
}