aboutsummaryrefslogtreecommitdiff
path: root/src/notifier.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-01-04 09:38:01 -0600
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-28 10:17:14 +0200
commit1182c7fb79942c14f2a713063182778e6af94cd1 (patch)
tree8868f158ed71d8e97e79220a42c590fa6a44666d /src/notifier.c
parent5d038638f58765ec3859797704c5d0e1c0fa7903 (diff)
downloadayatana-indicator-power-1182c7fb79942c14f2a713063182778e6af94cd1.tar.gz
ayatana-indicator-power-1182c7fb79942c14f2a713063182778e6af94cd1.tar.bz2
ayatana-indicator-power-1182c7fb79942c14f2a713063182778e6af94cd1.zip
add build-dep to accountsservice-ubuntu-schemas instead of bundling com.ubuntu.touch.AccountsService.Sound.xml into our source tree
Diffstat (limited to 'src/notifier.c')
-rw-r--r--src/notifier.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/notifier.c b/src/notifier.c
index ad7efb0..487f889 100644
--- a/src/notifier.c
+++ b/src/notifier.c
@@ -18,7 +18,11 @@
*/
#include "datafiles.h"
+
+#ifdef HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS
#include "dbus-accounts-sound.h"
+#endif
+
#include "dbus-battery.h"
#include "dbus-shared.h"
#include "notifier.h"
@@ -89,7 +93,9 @@ typedef struct
IndicatorPowerSoundPlayer * sound_player;
GCancellable * cancellable;
+ #ifdef HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS
DbusAccountsServiceSound * accounts_service_sound_proxy;
+ #endif
}
IndicatorPowerNotifierPrivate;
@@ -147,16 +153,18 @@ get_battery_power_level (IndicatorPowerDevice * battery)
**** Sounds
***/
+#ifdef HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS
static void
on_sound_proxy_ready (GObject * source_object G_GNUC_UNUSED,
GAsyncResult * res,
gpointer gself)
{
GError * error;
- DbusAccountsServiceSound * proxy;
-
error = NULL;
+
+ DbusAccountsServiceSound * proxy;
proxy = dbus_accounts_service_sound_proxy_new_for_bus_finish (res, &error);
+
if (error != NULL)
{
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
@@ -172,6 +180,7 @@ on_sound_proxy_ready (GObject * source_object G_GNUC_UNUSED,
}
}
+
static gboolean
silent_mode (IndicatorPowerNotifier * self)
{
@@ -180,6 +189,7 @@ silent_mode (IndicatorPowerNotifier * self)
return (p->accounts_service_sound_proxy != NULL)
&& (dbus_accounts_service_sound_get_silent_mode(p->accounts_service_sound_proxy));
}
+#endif
static void
play_low_battery_sound (IndicatorPowerNotifier * self)
@@ -191,9 +201,11 @@ play_low_battery_sound (IndicatorPowerNotifier * self)
/* can't play? */
g_return_if_fail (p->sound_player != NULL);
+ #ifdef HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS
/* won't play? */
if (silent_mode(self))
return;
+ #endif
filename = datafile_find(DATAFILE_TYPE_SOUND, key);
if (filename != NULL)
@@ -459,7 +471,10 @@ my_dispose (GObject * o)
notification_clear (self);
indicator_power_notifier_set_battery (self, NULL);
g_clear_object (&p->dbus_battery);
+
+ #ifdef HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS
g_clear_object (&p->accounts_service_sound_proxy);
+ #endif
G_OBJECT_CLASS (indicator_power_notifier_parent_class)->dispose (o);
}
@@ -467,7 +482,7 @@ my_dispose (GObject * o)
static void
my_finalize (GObject * o G_GNUC_UNUSED)
{
- /* FIXME: This is an awkward place to put this.
+ /* FIXME: This is an awkward place to put this.
Ordinarily something like this would go in main(), but we need libnotify
to clean itself up before shutting down the bus in the unit tests as well. */
if (!--instance_count)
@@ -494,6 +509,7 @@ indicator_power_notifier_init (IndicatorPowerNotifier * self)
if (!instance_count++ && !notify_init("ayatana-indicator-power-service"))
g_critical("Unable to initialize libnotify! Notifications might not be shown.");
+ #ifdef HAS_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS
gchar* object_path = g_strdup_printf("/org/freedesktop/Accounts/User%lu", (gulong)getuid());
dbus_accounts_service_sound_proxy_new_for_bus(
G_BUS_TYPE_SYSTEM,
@@ -504,6 +520,7 @@ indicator_power_notifier_init (IndicatorPowerNotifier * self)
on_sound_proxy_ready,
self);
g_clear_pointer(&object_path, g_free);
+ #endif
}
static void