aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdino/src/dbus/notifications.vala34
-rw-r--r--main/src/ui/application.vala16
2 files changed, 34 insertions, 16 deletions
diff --git a/libdino/src/dbus/notifications.vala b/libdino/src/dbus/notifications.vala
index 25a567df..2a9deb64 100644
--- a/libdino/src/dbus/notifications.vala
+++ b/libdino/src/dbus/notifications.vala
@@ -17,12 +17,34 @@ namespace Dino {
public abstract async void get_server_information(out string name, out string vendor, out string version, out string spec_version) throws DBusError, IOError;
}
+ // This function will always return. Sometimes Glib.Bus.get_proxy doesn't return, but this function covers that with a timeout.
+ // Returns null if the dbus notifications interface can't be obtained (if timeout or exception)
public static async DBusNotifications? get_notifications_dbus() {
- try {
- return yield Bus.get_proxy(BusType.SESSION, "org.freedesktop.Notifications", "/org/freedesktop/Notifications");
- } catch (IOError e) {
- warning("Couldn't get org.freedesktop.Notifications DBus instance: %s\n", e.message);
- }
- return null;
+ DBusNotifications? ret = null;
+ Cancellable cancellable = new Cancellable();
+
+ uint timeout_handle_id = Timeout.add_seconds(10, () => {
+ warning("Timeout waiting for org.freedesktop.Notifications DBus instance");
+ cancellable.cancel();
+ Idle.add(get_notifications_dbus.callback);
+ return false;
+ });
+
+ Bus.get_proxy.begin<DBusNotifications>(BusType.SESSION, "org.freedesktop.Notifications", "/org/freedesktop/Notifications", 0, cancellable, (_, res) => {
+ try {
+ ret = Bus.get_proxy.end(res);
+ } catch(IOError e) {
+ warning("Couldn't get org.freedesktop.Notifications DBus instance: %s", e.message);
+ }
+ if (timeout_handle_id != 0) {
+ Source.remove(timeout_handle_id);
+ Idle.add(get_notifications_dbus.callback);
+ }
+ });
+
+ yield;
+ timeout_handle_id = 0;
+
+ return ret;
}
} \ No newline at end of file
diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala
index 2463de46..605a7a75 100644
--- a/main/src/ui/application.vala
+++ b/main/src/ui/application.vala
@@ -46,16 +46,12 @@ public class Dino.Ui.Application : Adw.Application, Dino.Application {
NotificationEvents notification_events = stream_interactor.get_module(NotificationEvents.IDENTITY);
get_notifications_dbus.begin((_, res) => {
// It might take a bit to get the interface. NotificationEvents will queue any notifications in the meantime.
- try {
- DBusNotifications? dbus_notifications = get_notifications_dbus.end(res);
- if (dbus_notifications != null) {
- FreeDesktopNotifier free_desktop_notifier = new FreeDesktopNotifier(stream_interactor, dbus_notifications);
- notification_events.register_notification_provider.begin(free_desktop_notifier);
- } else {
- notification_events.register_notification_provider.begin(new GNotificationsNotifier(stream_interactor));
- }
- } catch (Error e) {
- debug("Failed accessing fdo notification server: %s", e.message);
+ DBusNotifications? dbus_notifications = get_notifications_dbus.end(res);
+ if (dbus_notifications != null) {
+ FreeDesktopNotifier free_desktop_notifier = new FreeDesktopNotifier(stream_interactor, dbus_notifications);
+ notification_events.register_notification_provider.begin(free_desktop_notifier);
+ } else {
+ notification_events.register_notification_provider.begin(new GNotificationsNotifier(stream_interactor));
}
});