summaryrefslogtreecommitdiff
blob: bda0feedceb724f98018ec0d976226da2ab8ac88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
https://github.com/linuxmint/cinnamon/commit/ef463cc0aaedd714f2956daab227aeda1d87897e

From ef463cc0aaedd714f2956daab227aeda1d87897e Mon Sep 17 00:00:00 2001
From: Michael Webster <miketwebster@gmail.com>
Date: Wed, 12 Jan 2022 14:50:47 -0500
Subject: [PATCH] calendar events: Check if evolution-data-server is running
 before enabling events.

None of the e-d-s libraries actually depend on evolution-data-server
(which is what provides the backend to these libraries). Also, not
everyone may want this sort of thing in the first place.

So, check if the e-d-s service we require is active before trying
to enable event support.

ref: #10597, #10567
---
 .../applets/calendar@cinnamon.org/calendar.js |  2 +-
 .../calendar@cinnamon.org/eventView.js        | 43 +++++++++++++++----
 js/misc/interfaces.js                         |  4 ++
 3 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/files/usr/share/cinnamon/applets/calendar@cinnamon.org/calendar.js b/files/usr/share/cinnamon/applets/calendar@cinnamon.org/calendar.js
index 460883c063..5078a201ed 100644
--- a/files/usr/share/cinnamon/applets/calendar@cinnamon.org/calendar.js
+++ b/files/usr/share/cinnamon/applets/calendar@cinnamon.org/calendar.js
@@ -159,7 +159,7 @@ class Calendar {
         this.desktop_settings = new Gio.Settings({ schema_id: DESKTOP_SCHEMA });
         this.desktop_settings.connect("changed::" + FIRST_WEEKDAY_KEY, Lang.bind(this, this._onSettingsChange));
 
-        this.events_enabled = true;
+        this.events_enabled = false;
         this.events_manager.connect("events-updated", this._events_updated.bind(this));
         this.events_manager.connect("events-manager-ready", this._update_events_enabled.bind(this));
         this.events_manager.connect("has-calendars-changed", this._update_events_enabled.bind(this));
diff --git a/files/usr/share/cinnamon/applets/calendar@cinnamon.org/eventView.js b/files/usr/share/cinnamon/applets/calendar@cinnamon.org/eventView.js
index 1d1035c605..2e73363fb7 100644
--- a/files/usr/share/cinnamon/applets/calendar@cinnamon.org/eventView.js
+++ b/files/usr/share/cinnamon/applets/calendar@cinnamon.org/eventView.js
@@ -17,6 +17,7 @@ const Main = imports.ui.main;
 const Util = imports.misc.util;
 const Mainloop = imports.mainloop;
 const Tweener = imports.ui.tweener;
+const Interfaces = imports.misc.interfaces;
 
 const STATUS_UNKNOWN = 0;
 const STATUS_NO_CALENDARS = 1;
@@ -302,18 +303,42 @@ class EventsManager {
 
     start_events() {
         if (this._calendar_server == null) {
-            Cinnamon.CalendarServerProxy.new_for_bus(
-                Gio.BusType.SESSION,
-                // Gio.DBusProxyFlags.NONE,
-                Gio.DBusProxyFlags.DO_NOT_AUTO_START_AT_CONSTRUCTION,
-                "org.cinnamon.CalendarServer",
-                "/org/cinnamon/CalendarServer",
-                null,
-                this._calendar_server_ready.bind(this)
-            );
+            Interfaces.getDBusAsync((proxy, error) => {
+                if (error) {
+                    this.log_dbus_error(error);
+                    return;
+                }
+
+                proxy.NameHasOwnerRemote("org.gnome.evolution.dataserver.Calendar8", (has_owner, error) => {
+                    if (error) {
+                        this.log_dbus_error(error);
+                        return;
+                    }
+
+                    if (has_owner[0]) {
+                        log("calendar@cinnamon.org: Calendar events supported.")
+
+                        Cinnamon.CalendarServerProxy.new_for_bus(
+                            Gio.BusType.SESSION,
+                            Gio.DBusProxyFlags.DO_NOT_AUTO_START_AT_CONSTRUCTION,
+                            "org.cinnamon.CalendarServer",
+                            "/org/cinnamon/CalendarServer",
+                            null,
+                            this._calendar_server_ready.bind(this)
+                        );
+                    } else {
+                        log("calendar@cinnamon.org: No calendar event support (needs evolution-data-server)")
+
+                    }
+                });
+            })
         }
     }
 
+    log_dbus_error(e) {
+        global.logError(`calendar@cinnamon.org: Could not check for calendar event support: ${e.toString()}`);
+    }
+
     _calendar_server_ready(obj, res) {
         try {
             this._calendar_server = Cinnamon.CalendarServerProxy.new_for_bus_finish(res);
diff --git a/js/misc/interfaces.js b/js/misc/interfaces.js
index 8bc6e717d4..6bdb7b78c2 100644
--- a/js/misc/interfaces.js
+++ b/js/misc/interfaces.js
@@ -13,6 +13,10 @@ const DBusIface = '\
             <arg type="s" direction="in" /> \
             <arg type="s" direction="out" /> \
         </method> \
+        <method name="NameHasOwner"> \
+            <arg type="s" direction="in" /> \
+            <arg type="b" direction="out" /> \
+        </method> \
         <method name="ListNames"> \
             <arg type="as" direction="out" /> \
         </method> \