summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXiaotian Wu <[email protected]>2025-04-10 20:37:04 +0800
committerXiaotian Wu <[email protected]>2025-04-10 20:37:04 +0800
commit972aecd7d46c1f549485c86bdc0744d70dc77e68 (patch)
tree38441659c4077423f27aa58205c858b79c602cd3
parent54248174640de5c6079f7f85d3a44ea3923d3445 (diff)
downloadmate-session-manager-pr-gdbus-app.tar.bz2
mate-session-manager-pr-gdbus-app.tar.xz
gsm-app: migrate to gdbuspr-gdbus-app
-rw-r--r--mate-session/Makefile.am22
-rw-r--r--mate-session/gsm-app.c127
-rw-r--r--mate-session/gsm-app.h11
3 files changed, 91 insertions, 69 deletions
diff --git a/mate-session/Makefile.am b/mate-session/Makefile.am
index 448ee76..9ad7b46 100644
--- a/mate-session/Makefile.am
+++ b/mate-session/Makefile.am
@@ -23,8 +23,6 @@ mate_session_SOURCES = \
gsm-xsmp-client.c \
gsm-dbus-client.h \
gsm-dbus-client.c \
- gsm-marshal.h \
- gsm-marshal.c \
gsm-consolekit.c \
gsm-consolekit.h \
gsm-systemd.c \
@@ -55,7 +53,8 @@ mate_session_SOURCES = \
gsm-session-save.c \
gsm-session-save.h \
gsm-xsmp-server.c \
- gsm-xsmp-server.h
+ gsm-xsmp-server.h \
+ $(BUILT_SOURCES)
mate_session_CPPFLAGS = \
$(AM_CPPFLAGS) \
@@ -97,6 +96,15 @@ test_inhibit_LDADD = $(MATE_SESSION_LIBS)
test_client_dbus_SOURCES = test-client-dbus.c
test_client_dbus_LDADD = $(MATE_SESSION_LIBS)
+org.gnome.SessionManager.App.h: org.gnome.SessionManager.App.xml Makefile.am
+ $(AM_V_GEN) gdbus-codegen --interface-prefix org.gnome.SessionManager.App. \
+ --generate-c-code org.gnome.SessionManager.App \
+ --c-namespace Gsm \
+ --annotate "org.gnome.SessionManager.App" "org.gtk.GDBus.C.Name" ExportedApp \
+ $(srcdir)/org.gnome.SessionManager.App.xml
+org.gnome.SessionManager.App.c: org.gnome.SessionManager.App.h
+ @: # generated as a side-effect
+
gsm-marshal.c: gsm-marshal.list
$(AM_V_GEN)echo "#include \"gsm-marshal.h\"" > $@ && \
$(GLIB_GENMARSHAL) $< --prefix=gsm_marshal --body >> $@
@@ -110,9 +118,6 @@ gsm-manager-glue.h: org.gnome.SessionManager.xml Makefile.am
gsm-client-glue.h: org.gnome.SessionManager.Client.xml Makefile.am
$(AM_V_GEN)dbus-binding-tool --prefix=gsm_client --mode=glib-server --output=gsm-client-glue.h $(srcdir)/org.gnome.SessionManager.Client.xml
-gsm-app-glue.h: org.gnome.SessionManager.App.xml Makefile.am
- $(AM_V_GEN)dbus-binding-tool --prefix=gsm_app --mode=glib-server --output=gsm-app-glue.h $(srcdir)/org.gnome.SessionManager.App.xml
-
gsm-inhibitor-glue.h: org.gnome.SessionManager.Inhibitor.xml Makefile.am
$(AM_V_GEN)dbus-binding-tool --prefix=gsm_inhibitor --mode=glib-server --output=gsm-inhibitor-glue.h $(srcdir)/org.gnome.SessionManager.Inhibitor.xml
@@ -122,11 +127,12 @@ gsm-presence-glue.h: org.gnome.SessionManager.Presence.xml Makefile.am
BUILT_SOURCES = \
gsm-marshal.c \
gsm-marshal.h \
+ org.gnome.SessionManager.App.h \
+ org.gnome.SessionManager.App.c \
gsm-manager-glue.h \
gsm-presence-glue.h \
gsm-inhibitor-glue.h \
- gsm-client-glue.h \
- gsm-app-glue.h
+ gsm-client-glue.h
EXTRA_DIST = \
README \
diff --git a/mate-session/gsm-app.c b/mate-session/gsm-app.c
index 6d7a058..2edde33 100644
--- a/mate-session/gsm-app.c
+++ b/mate-session/gsm-app.c
@@ -28,14 +28,15 @@
#include <string.h>
#include "gsm-app.h"
-#include "gsm-app-glue.h"
+#include "org.gnome.SessionManager.App.h"
typedef struct {
char *id;
char *app_id;
int phase;
char *startup_id;
- DBusGConnection *connection;
+ GDBusConnection *connection;
+ GsmExportedApp *skeleton;
} GsmAppPrivate;
enum {
@@ -71,6 +72,46 @@ gsm_app_error_quark (void)
}
+static gboolean
+gsm_app_get_app_id (GsmExportedApp *skeleton,
+ GDBusMethodInvocation *invocation,
+ GsmApp *app)
+{
+ const gchar *id;
+
+ id = GSM_APP_GET_CLASS (app)->impl_get_app_id (app);
+ gsm_exported_app_complete_get_app_id (skeleton, invocation, id);
+
+ return TRUE;
+}
+
+static gboolean
+gsm_app_get_startup_id (GsmExportedApp *skeleton,
+ GDBusMethodInvocation *invocation,
+ GsmApp *app)
+{
+ const gchar *id;
+ GsmAppPrivate *priv;
+
+ priv = gsm_app_get_instance_private (app);
+ id = g_strdup (priv->startup_id);
+ gsm_exported_app_complete_get_startup_id (skeleton, invocation, id);
+
+ return TRUE;
+}
+
+static gboolean
+gsm_app_get_phase (GsmExportedApp *skeleton,
+ GDBusMethodInvocation *invocation,
+ GsmApp *app)
+{
+ GsmAppPrivate *priv;
+
+ priv = gsm_app_get_instance_private (app);
+ gsm_exported_app_complete_get_phase (skeleton, invocation, priv->phase);
+ return TRUE;
+}
+
static guint32
get_next_app_serial (void)
{
@@ -90,20 +131,36 @@ register_app (GsmApp *app)
{
GError *error;
GsmAppPrivate *priv;
+ GsmExportedApp *skeleton;
error = NULL;
priv = gsm_app_get_instance_private (app);
- priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- if (priv->connection == NULL) {
- if (error != NULL) {
- g_critical ("error getting session bus: %s", error->message);
- g_error_free (error);
- }
+ priv->connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
+ if (error != NULL) {
+ g_critical ("error getting session bus: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ skeleton = gsm_exported_app_skeleton_new ();
+ priv->skeleton = skeleton;
+ g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (skeleton),
+ priv->connection, priv->id,
+ &error);
+
+ if (error != NULL) {
+ g_critical ("error registering app on session bus: %s", error->message);
+ g_error_free (error);
return FALSE;
}
- dbus_g_connection_register_g_object (priv->connection, priv->id, G_OBJECT (app));
+ g_signal_connect (skeleton, "handle-get-app-id",
+ G_CALLBACK (gsm_app_get_app_id), app);
+ g_signal_connect (skeleton, "handle-get-phase",
+ G_CALLBACK (gsm_app_get_phase), app);
+ g_signal_connect (skeleton, "handle-get-startup-id",
+ G_CALLBACK (gsm_app_get_startup_id), app);
return TRUE;
}
@@ -134,7 +191,7 @@ gsm_app_constructor (GType type,
}
static void
-gsm_app_init (GsmApp *app)
+gsm_app_init (GsmApp G_GNUC_UNUSED *app)
{
}
@@ -185,7 +242,7 @@ static void
gsm_app_set_property (GObject *object,
guint prop_id,
const GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec G_GNUC_UNUSED)
{
GsmApp *app = GSM_APP (object);
@@ -208,7 +265,7 @@ static void
gsm_app_get_property (GObject *object,
guint prop_id,
GValue *value,
- GParamSpec *pspec)
+ GParamSpec *pspec G_GNUC_UNUSED)
{
GsmAppPrivate *priv;
GsmApp *app = GSM_APP (object);
@@ -244,6 +301,14 @@ gsm_app_dispose (GObject *object)
g_free (priv->id);
priv->id = NULL;
+ if (priv->skeleton != NULL) {
+ g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (priv->skeleton),
+ priv->connection);
+ g_clear_object (&priv->skeleton);
+ }
+
+ g_clear_object (&priv->connection);
+
G_OBJECT_CLASS (gsm_app_parent_class)->dispose (object);
}
@@ -316,8 +381,6 @@ gsm_app_class_init (GsmAppClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE,
0);
-
- dbus_g_object_type_install_info (GSM_TYPE_APP, &dbus_glib_gsm_app_object_info);
}
const char *
@@ -501,39 +564,3 @@ gsm_app_died (GsmApp *app)
g_signal_emit (app, signals[DIED], 0);
}
-
-gboolean
-gsm_app_get_app_id (GsmApp *app,
- char **id,
- GError **error)
-{
- g_return_val_if_fail (GSM_IS_APP (app), FALSE);
- *id = g_strdup (GSM_APP_GET_CLASS (app)->impl_get_app_id (app));
- return TRUE;
-}
-
-gboolean
-gsm_app_get_startup_id (GsmApp *app,
- char **id,
- GError **error)
-{
- GsmAppPrivate *priv;
- g_return_val_if_fail (GSM_IS_APP (app), FALSE);
-
- priv = gsm_app_get_instance_private (app);
- *id = g_strdup (priv->startup_id);
- return TRUE;
-}
-
-gboolean
-gsm_app_get_phase (GsmApp *app,
- guint *phase,
- GError **error)
-{
- GsmAppPrivate *priv;
- g_return_val_if_fail (GSM_IS_APP (app), FALSE);
-
- priv = gsm_app_get_instance_private (app);
- *phase = priv->phase;
- return TRUE;
-}
diff --git a/mate-session/gsm-app.h b/mate-session/gsm-app.h
index 96a06d1..8c2424a 100644
--- a/mate-session/gsm-app.h
+++ b/mate-session/gsm-app.h
@@ -104,17 +104,6 @@ gboolean gsm_app_has_autostart_condition (GsmApp *app,
void gsm_app_registered (GsmApp *app);
int gsm_app_peek_autostart_delay (GsmApp *app);
-/* exported to bus */
-gboolean gsm_app_get_app_id (GsmApp *app,
- char **id,
- GError **error);
-gboolean gsm_app_get_startup_id (GsmApp *app,
- char **id,
- GError **error);
-gboolean gsm_app_get_phase (GsmApp *app,
- guint *phase,
- GError **error);
-
G_END_DECLS
#endif /* __GSM_APP_H__ */