Skip to content

Commit 2daa4af

Browse files
yetistlukefromdc
authored andcommitted
[gsm-autostart-app] Migrate from dbus-glib to gdbus
1 parent 90346cd commit 2daa4af

File tree

1 file changed

+46
-45
lines changed

1 file changed

+46
-45
lines changed

mate-session/gsm-autostart-app.c

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ typedef struct {
7676
GPid pid;
7777
guint child_watch_id;
7878

79-
DBusGProxy *proxy;
80-
DBusGProxyCall *proxy_call;
79+
GDBusConnection *connection;
80+
GDBusProxy *proxy;
8181
} GsmAutostartAppPrivate;
8282

8383
enum {
@@ -630,16 +630,16 @@ gsm_autostart_app_dispose (GObject *object)
630630
priv->child_watch_id = 0;
631631
}
632632

633-
if (priv->proxy_call != NULL) {
634-
dbus_g_proxy_cancel_call (priv->proxy, priv->proxy_call);
635-
priv->proxy_call = NULL;
636-
}
637-
638633
if (priv->proxy != NULL) {
639634
g_object_unref (priv->proxy);
640635
priv->proxy = NULL;
641636
}
642637

638+
if (priv->connection != NULL) {
639+
g_object_unref (priv->connection);
640+
priv->connection = NULL;
641+
}
642+
643643
if (priv->condition_monitor) {
644644
g_file_monitor_cancel (priv->condition_monitor);
645645
}
@@ -905,29 +905,37 @@ autostart_app_start_spawn (GsmAutostartApp *app,
905905
}
906906

907907
static void
908-
start_notify (DBusGProxy *proxy,
909-
DBusGProxyCall *call,
910-
GsmAutostartApp *app)
908+
start_notify (GObject *source_object,
909+
GAsyncResult *res,
910+
gpointer data)
911911
{
912-
gboolean res;
913-
GError *error;
912+
GsmAutostartApp *app;
914913
GsmAutostartAppPrivate *priv;
914+
GError *error;
915+
GVariant *variant;
915916

917+
app = data;
916918
priv = gsm_autostart_app_get_instance_private (app);
917919

918920
error = NULL;
919-
res = dbus_g_proxy_end_call (proxy,
920-
call,
921-
&error,
922-
G_TYPE_INVALID);
923-
priv->proxy_call = NULL;
921+
if (priv->proxy == NULL)
922+
return;
924923

925-
if (! res) {
924+
variant = g_dbus_proxy_call_finish (priv->proxy, res, &error);
925+
if (variant == NULL) {
926926
g_warning ("GsmAutostartApp: Error starting application: %s", error->message);
927927
g_error_free (error);
928+
return;
928929
} else {
929930
g_debug ("GsmAutostartApp: Started application %s", priv->desktop_id);
931+
g_variant_unref (variant);
930932
}
933+
934+
g_object_unref (priv->proxy);
935+
priv->proxy = NULL;
936+
937+
g_object_unref (priv->connection);
938+
priv->connection = NULL;
931939
}
932940

933941
static gboolean
@@ -937,15 +945,14 @@ autostart_app_start_activate (GsmAutostartApp *app,
937945
const char *name;
938946
char *path;
939947
char *arguments;
940-
DBusGConnection *bus;
941948
GError *local_error;
942949
GsmAutostartAppPrivate *priv;
943950

944951
priv = gsm_autostart_app_get_instance_private (app);
945952

946953
local_error = NULL;
947-
bus = dbus_g_bus_get (DBUS_BUS_SESSION, &local_error);
948-
if (bus == NULL) {
954+
priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &local_error);
955+
if (priv->connection == NULL) {
949956
if (local_error != NULL) {
950957
g_warning ("error getting session bus: %s", local_error->message);
951958
}
@@ -968,34 +975,28 @@ autostart_app_start_activate (GsmAutostartApp *app,
968975
GSM_AUTOSTART_APP_DBUS_ARGS_KEY,
969976
NULL);
970977

971-
priv->proxy = dbus_g_proxy_new_for_name (bus,
972-
name,
973-
path,
974-
GSM_SESSION_CLIENT_DBUS_INTERFACE);
978+
local_error = NULL;
979+
priv->proxy = g_dbus_proxy_new_sync (priv->connection,
980+
G_DBUS_PROXY_FLAGS_NONE,
981+
NULL,
982+
name,
983+
path,
984+
GSM_SESSION_CLIENT_DBUS_INTERFACE,
985+
NULL,
986+
&local_error);
975987
if (priv->proxy == NULL) {
976-
g_set_error (error,
977-
GSM_APP_ERROR,
978-
GSM_APP_ERROR_START,
979-
"Unable to start application: unable to create proxy for client");
988+
g_propagate_error (error, local_error);
980989
return FALSE;
981990
}
982991

983-
priv->proxy_call = dbus_g_proxy_begin_call (priv->proxy,
984-
"Start",
985-
(DBusGProxyCallNotify)start_notify,
986-
app,
987-
NULL,
988-
G_TYPE_STRING, arguments,
989-
G_TYPE_INVALID);
990-
if (priv->proxy_call == NULL) {
991-
g_object_unref (priv->proxy);
992-
priv->proxy = NULL;
993-
g_set_error (error,
994-
GSM_APP_ERROR,
995-
GSM_APP_ERROR_START,
996-
"Unable to start application: unable to call Start on client");
997-
return FALSE;
998-
}
992+
g_dbus_proxy_call (priv->proxy,
993+
"Start",
994+
g_variant_new ("(s)", arguments),
995+
G_DBUS_CALL_FLAGS_NONE,
996+
-1,
997+
NULL,
998+
(GAsyncReadyCallback) start_notify,
999+
app);
9991000

10001001
return TRUE;
10011002
}

0 commit comments

Comments
 (0)