Package: gmpc-plugins / 11.8.16-6

awn-Port-from-deprecated-dbus-glib-to-GDBus.patch Patch series | download
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
From: Simon McVittie <smcv@debian.org>
Date: Tue, 18 Aug 2020 16:16:11 +0100
Subject: awn: Port from deprecated dbus-glib to GDBus

Also, don't leak the GError if a D-Bus call fails.

Bug-Debian: https://bugs.debian.org/955896
---
 gmpc-awn/configure.ac |   2 +-
 gmpc-awn/src/plugin.c | 103 +++++++++++++++++++++++++++-----------------------
 2 files changed, 56 insertions(+), 49 deletions(-)

diff --git a/gmpc-awn/configure.ac b/gmpc-awn/configure.ac
index 1fb34d9..eb6a705 100644
--- a/gmpc-awn/configure.ac
+++ b/gmpc-awn/configure.ac
@@ -41,7 +41,7 @@ AC_PROG_LIBTOOL
 PKG_CHECK_MODULES([gmpcawn],
 [
     gmpc >= 0.15.4.96
-    dbus-glib-1
+    gio-2.0   >= 2.32
 ])
 
 AC_SUBST(gmpcawn_LIBS)
diff --git a/gmpc-awn/src/plugin.c b/gmpc-awn/src/plugin.c
index 2b06e54..a5c5b4d 100644
--- a/gmpc-awn/src/plugin.c
+++ b/gmpc-awn/src/plugin.c
@@ -25,12 +25,17 @@
 #include <string.h>
 #include <glib.h>
 #include <glib/gi18n-lib.h>
+#include <gio/gio.h>
 #include <gdk/gdkx.h>
 #include <gmpc/plugin.h>
 #include <gmpc/metadata.h>
 #include <gmpc/misc.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-bindings.h>
+
+#define AWN_BUS_NAME "com.google.code.Awn"
+#define AWN_OBJECT_PATH "/com/google/code/Awn"
+#define AWN_INTERFACE "com.google.code.Awn"
+
+static GDBusConnection *session_bus = NULL;
 
 static void awn_update_cover(GmpcMetaWatcher *gmv, mpd_Song *song, MetaDataType type, MetaDataResult ret, MetaData *met); 
 static int awn_get_enabled(void)
@@ -61,9 +66,6 @@ static XID get_main_window_xid() {
 
 static void setAwnIcon(const char *filename) {
     XID xid;
-    DBusGConnection *connection;
-    DBusGProxy *proxy;
-    GError *error;	
 
     xid = get_main_window_xid();
 
@@ -71,27 +73,27 @@ static void setAwnIcon(const char *filename) {
         return;
     }
 
-    error = NULL;
-    connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
-
-    if (connection != NULL)
+    if (session_bus != NULL)
     {
-        proxy = dbus_g_proxy_new_for_name(
-                connection,
-                "com.google.code.Awn",
-                "/com/google/code/Awn",
-                "com.google.code.Awn");
-        error = NULL;
-        dbus_g_proxy_call(proxy, "SetTaskIconByXid", &error, G_TYPE_INT64,
-                (gint64)xid, G_TYPE_STRING, filename, G_TYPE_INVALID);
+        g_dbus_connection_call (session_bus,
+                                AWN_BUS_NAME,
+                                AWN_OBJECT_PATH,
+                                AWN_INTERFACE,
+                                "SetTaskIconByXid",
+                                g_variant_new ("(xs)",
+                                               (gint64) xid,
+                                               filename),
+                                NULL,
+                                G_DBUS_CALL_FLAGS_NONE,
+                                -1,
+                                NULL,
+                                NULL,
+                                NULL);
     }
 }
 
 static void unsetAwnIcon() {
     XID xid;
-    DBusGConnection *connection;
-    DBusGProxy *proxy;
-    GError *error;	
 
     xid = get_main_window_xid();
 
@@ -99,26 +101,26 @@ static void unsetAwnIcon() {
         return;
     }
 
-    error = NULL;
-    connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
-
-    if (connection != NULL)
+    if (session_bus != NULL)
     {
-        proxy = dbus_g_proxy_new_for_name(
-                connection,
-                "com.google.code.Awn",
-                "/com/google/code/Awn",
-                "com.google.code.Awn");
-        error = NULL;
-        dbus_g_proxy_call(proxy, "UnsetTaskIconByXid", &error,
-                G_TYPE_INT64, (gint64)xid, G_TYPE_INVALID);
+        g_dbus_connection_call (session_bus,
+                                AWN_BUS_NAME,
+                                AWN_OBJECT_PATH,
+                                AWN_INTERFACE,
+                                "UnsetTaskIconByXid",
+                                g_variant_new ("(x)",
+                                               (gint64) xid),
+                                NULL,
+                                G_DBUS_CALL_FLAGS_NONE,
+                                -1,
+                                NULL,
+                                NULL,
+                                NULL);
     }
 }
+
 static void setAwnProgress(int progress) {
     XID xid;
-    DBusGConnection *connection;
-    DBusGProxy *proxy;
-    GError *error;	
 
     xid = get_main_window_xid();
 
@@ -126,27 +128,31 @@ static void setAwnProgress(int progress) {
         return;
     }
 
-    error = NULL;
-    connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
-
-    if (connection != NULL)
+    if (session_bus != NULL)
     {
-        proxy = dbus_g_proxy_new_for_name(
-                connection,
-                "com.google.code.Awn",
-                "/com/google/code/Awn",
-                "com.google.code.Awn");
-        error = NULL;
-        dbus_g_proxy_call(proxy, "SetProgressByXid", &error,G_TYPE_INT64, (gint64)xid,
-                G_TYPE_INT, progress, G_TYPE_INVALID);
+        g_dbus_connection_call (session_bus,
+                                AWN_BUS_NAME,
+                                AWN_OBJECT_PATH,
+                                AWN_INTERFACE,
+                                "SetProgressByXid",
+                                g_variant_new ("(xi)",
+                                               (gint64) xid,
+                                               progress),
+                                NULL,
+                                G_DBUS_CALL_FLAGS_NONE,
+                                -1,
+                                NULL,
+                                NULL,
+                                NULL);
     }
 }
+
 /**
  * Destroy the plugin
  */
 static void awn_plugin_destroy(void)
 {
-
+    g_clear_object (&session_bus);
 }
 
 
@@ -155,6 +161,7 @@ static void awn_plugin_init(void)
     bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
     bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
     g_signal_connect(G_OBJECT(gmw), "data-changed", G_CALLBACK(awn_update_cover), NULL);
+    session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
 }
 
 static void awn_update_cover(GmpcMetaWatcher *gmv, mpd_Song *song, MetaDataType type, MetaDataResult ret, MetaData *met)