diff --git a/src/backends/meta-dbus-session-manager.c b/src/backends/meta-dbus-session-manager.c index 13d3bc317..1fd0b7777 100644 --- a/src/backends/meta-dbus-session-manager.c +++ b/src/backends/meta-dbus-session-manager.c @@ -288,7 +288,7 @@ on_session_closed (MetaDbusSession *session, { MetaDbusSessionManagerPrivate *priv = meta_dbus_session_manager_get_instance_private (session_manager); - const char *session_id; + g_autofree char *session_id = NULL; session_id = meta_dbus_session_get_id (session); g_hash_table_remove (priv->sessions, session_id); diff --git a/src/backends/meta-dbus-session-watcher.c b/src/backends/meta-dbus-session-watcher.c index 79f07560c..df074ce35 100644 --- a/src/backends/meta-dbus-session-watcher.c +++ b/src/backends/meta-dbus-session-watcher.c @@ -26,6 +26,8 @@ #include +#include "backends/meta-dbus-session-manager.h" + enum { SESSION_SIGNAL_SESSION_CLOSED, @@ -186,9 +188,52 @@ meta_dbus_session_notify_closed (MetaDbusSession *session) g_signal_emit (session, session_signals[SESSION_SIGNAL_SESSION_CLOSED], 0); } +void +meta_dbus_session_install_properties (GObjectClass *object_class, + unsigned int first_prop) +{ + g_object_class_override_property (object_class, + first_prop + META_DBUS_SESSION_PROP_SESSION_MANAGER, + "session-manager"); + g_object_class_override_property (object_class, + first_prop + META_DBUS_SESSION_PROP_PEER_NAME, + "peer-name"); + g_object_class_override_property (object_class, + first_prop + META_DBUS_SESSION_PROP_ID, + "id"); +} + static void meta_dbus_session_default_init (MetaDbusSessionInterface *iface) { + g_object_interface_install_property ( + iface, + g_param_spec_object ("session-manager", + "session manager", + "D-Bus session manager", + META_TYPE_DBUS_SESSION_MANAGER, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + g_object_interface_install_property ( + iface, + g_param_spec_string ("peer-name", + "peer name", + "D-Bus peer name", + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + g_object_interface_install_property ( + iface, + g_param_spec_string ("id", + "session id", + "Unique ID of the session", + NULL, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + session_signals[SESSION_SIGNAL_SESSION_CLOSED] = g_signal_new ("session-closed", G_TYPE_FROM_INTERFACE (iface), @@ -232,8 +277,32 @@ meta_dbus_session_close (MetaDbusSession *session) META_DBUS_SESSION_GET_IFACE (session)->close (session); } -const char * +MetaDbusSessionManager * +meta_dbus_session_manager (MetaDbusSessionManager *session) +{ + MetaDbusSessionManager *manager; + + g_object_get (session, "session-manager", &manager, NULL); + + return manager; +} + +char * +meta_dbus_session_get_peer_name (MetaDbusSession *session) +{ + char *peer_name; + + g_object_get (session, "peer-name", &peer_name, NULL); + + return peer_name; +} + +char * meta_dbus_session_get_id (MetaDbusSession *session) { - return META_DBUS_SESSION_GET_IFACE (session)->get_id (session); + char *id; + + g_object_get (session, "id", &id, NULL); + + return id; } diff --git a/src/backends/meta-dbus-session-watcher.h b/src/backends/meta-dbus-session-watcher.h index 98aee63e4..ae99edba8 100644 --- a/src/backends/meta-dbus-session-watcher.h +++ b/src/backends/meta-dbus-session-watcher.h @@ -25,6 +25,15 @@ #include +#include "backends/meta-backend-types.h" + +enum +{ + META_DBUS_SESSION_PROP_SESSION_MANAGER, + META_DBUS_SESSION_PROP_PEER_NAME, + META_DBUS_SESSION_PROP_ID, +}; + #define META_TYPE_DBUS_SESSION (meta_dbus_session_get_type ()) G_DECLARE_INTERFACE (MetaDbusSession, meta_dbus_session, META, DBUS_SESSION, @@ -35,7 +44,6 @@ struct _MetaDbusSessionInterface GTypeInterface parent_iface; void (* close) (MetaDbusSession *session); - const char * (* get_id) (MetaDbusSession *session); }; #define META_TYPE_DBUS_SESSION_WATCHER (meta_dbus_session_watcher_get_type ()) @@ -48,10 +56,17 @@ void meta_dbus_session_watcher_watch_session (MetaDbusSessionWatcher *session_wa const char *client_dbus_name, MetaDbusSession *session); +void meta_dbus_session_install_properties (GObjectClass *object_class, + unsigned int first_prop); + void meta_dbus_session_notify_closed (MetaDbusSession *session); void meta_dbus_session_close (MetaDbusSession *session); -const char * meta_dbus_session_get_id (MetaDbusSession *session); +MetaDbusSessionManager * meta_dbus_session_manager (MetaDbusSessionManager *session); + +char * meta_dbus_session_get_peer_name (MetaDbusSession *session); + +char * meta_dbus_session_get_id (MetaDbusSession *session); #endif /* META_DBUS_SESSION_WATCHER_H */ diff --git a/src/backends/meta-remote-desktop-session.c b/src/backends/meta-remote-desktop-session.c index 7cbc66c2b..5e044b1f5 100644 --- a/src/backends/meta-remote-desktop-session.c +++ b/src/backends/meta-remote-desktop-session.c @@ -54,15 +54,9 @@ enum { PROP_0, - PROP_SESSION_MANAGER, - PROP_PEER_NAME, - PROP_ID, - N_PROPS }; -static GParamSpec *obj_props[N_PROPS]; - typedef enum _MetaRemoteDesktopNotifyAxisFlags { META_REMOTE_DESKTOP_NOTIFY_AXIS_FLAGS_NONE = 0, @@ -265,14 +259,6 @@ meta_remote_desktop_session_close (MetaDbusSession *dbus_session) g_object_unref (session); } -static const char * -meta_remote_desktop_session_get_id (MetaDbusSession *dbus_session) -{ - MetaRemoteDesktopSession *session = META_REMOTE_DESKTOP_SESSION (dbus_session); - - return session->session_id; -} - char * meta_remote_desktop_session_get_object_path (MetaRemoteDesktopSession *session) { @@ -1706,7 +1692,6 @@ static void meta_dbus_session_init_iface (MetaDbusSessionInterface *iface) { iface->close = meta_remote_desktop_session_close; - iface->get_id = meta_remote_desktop_session_get_id; } static void @@ -1741,13 +1726,13 @@ meta_remote_desktop_session_set_property (GObject *object, switch (prop_id) { - case PROP_SESSION_MANAGER: + case N_PROPS + META_DBUS_SESSION_PROP_SESSION_MANAGER: session->session_manager = g_value_get_object (value); break; - case PROP_PEER_NAME: + case N_PROPS + META_DBUS_SESSION_PROP_PEER_NAME: session->peer_name = g_value_dup_string (value); break; - case PROP_ID: + case N_PROPS + META_DBUS_SESSION_PROP_ID: session->session_id = g_value_dup_string (value); break; default: @@ -1766,13 +1751,13 @@ meta_remote_desktop_session_get_property (GObject *object, switch (prop_id) { - case PROP_SESSION_MANAGER: + case N_PROPS + META_DBUS_SESSION_PROP_SESSION_MANAGER: g_value_set_object (value, session->session_manager); break; - case PROP_PEER_NAME: + case N_PROPS + META_DBUS_SESSION_PROP_PEER_NAME: g_value_set_string (value, session->peer_name); break; - case PROP_ID: + case N_PROPS + META_DBUS_SESSION_PROP_ID: g_value_set_string (value, session->session_id); break; default: @@ -1803,31 +1788,7 @@ meta_remote_desktop_session_class_init (MetaRemoteDesktopSessionClass *klass) object_class->set_property = meta_remote_desktop_session_set_property; object_class->get_property = meta_remote_desktop_session_get_property; - obj_props[PROP_SESSION_MANAGER] = - g_param_spec_object ("session-manager", - "session manager", - "D-Bus session manager", - META_TYPE_DBUS_SESSION_MANAGER, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_props[PROP_PEER_NAME] = - g_param_spec_string ("peer-name", - "peer name", - "D-Bus peer name", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_props[PROP_ID] = - g_param_spec_string ("id", - "session id", - "Unique ID of the session", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - g_object_class_install_properties (object_class, N_PROPS, obj_props); + meta_dbus_session_install_properties (object_class, N_PROPS); } static MetaRemoteDesktopSessionHandle * diff --git a/src/backends/meta-screen-cast-session.c b/src/backends/meta-screen-cast-session.c index a001e5fca..a0258bd39 100644 --- a/src/backends/meta-screen-cast-session.c +++ b/src/backends/meta-screen-cast-session.c @@ -43,9 +43,6 @@ enum { PROP_0, - PROP_SESSION_MANAGER, - PROP_PEER_NAME, - PROP_ID, PROP_SESSION_TYPE, N_PROPS @@ -186,14 +183,6 @@ meta_screen_cast_session_close (MetaDbusSession *dbus_session) g_object_unref (session); } -static const char * -meta_screen_cast_session_get_id (MetaDbusSession *dbus_session) -{ - MetaScreenCastSession *session = META_SCREEN_CAST_SESSION (dbus_session); - - return session->session_id; -} - MetaScreenCastStream * meta_screen_cast_session_get_stream (MetaScreenCastSession *session, const char *path) @@ -777,7 +766,6 @@ static void meta_dbus_session_init_iface (MetaDbusSessionInterface *iface) { iface->close = meta_screen_cast_session_close; - iface->get_id = meta_screen_cast_session_get_id; } static void @@ -803,18 +791,19 @@ meta_screen_cast_session_set_property (GObject *object, switch (prop_id) { - case PROP_SESSION_MANAGER: - session->session_manager = g_value_get_object (value); - break; - case PROP_PEER_NAME: - session->peer_name = g_value_dup_string (value); - break; - case PROP_ID: - session->session_id = g_value_dup_string (value); - break; case PROP_SESSION_TYPE: session->session_type = g_value_get_enum (value); break; + + case N_PROPS + META_DBUS_SESSION_PROP_SESSION_MANAGER: + session->session_manager = g_value_get_object (value); + break; + case N_PROPS + META_DBUS_SESSION_PROP_PEER_NAME: + session->peer_name = g_value_dup_string (value); + break; + case N_PROPS + META_DBUS_SESSION_PROP_ID: + session->session_id = g_value_dup_string (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -831,18 +820,19 @@ meta_screen_cast_session_get_property (GObject *object, switch (prop_id) { - case PROP_SESSION_MANAGER: - g_value_set_object (value, session->session_manager); - break; - case PROP_PEER_NAME: - g_value_set_string (value, session->peer_name); - break; - case PROP_ID: - g_value_set_string (value, session->session_id); - break; case PROP_SESSION_TYPE: g_value_set_enum (value, session->session_type); break; + + case N_PROPS + META_DBUS_SESSION_PROP_SESSION_MANAGER: + g_value_set_object (value, session->session_manager); + break; + case N_PROPS + META_DBUS_SESSION_PROP_PEER_NAME: + g_value_set_string (value, session->peer_name); + break; + case N_PROPS + META_DBUS_SESSION_PROP_ID: + g_value_set_string (value, session->session_id); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -863,30 +853,6 @@ meta_screen_cast_session_class_init (MetaScreenCastSessionClass *klass) object_class->set_property = meta_screen_cast_session_set_property; object_class->get_property = meta_screen_cast_session_get_property; - obj_props[PROP_SESSION_MANAGER] = - g_param_spec_object ("session-manager", - "session manager", - "D-Bus session manager", - META_TYPE_DBUS_SESSION_MANAGER, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_props[PROP_PEER_NAME] = - g_param_spec_string ("peer-name", - "peer name", - "D-Bus peer name", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); - obj_props[PROP_ID] = - g_param_spec_string ("id", - "session id", - "Unique ID of the session", - NULL, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS); obj_props[PROP_SESSION_TYPE] = g_param_spec_enum ("session-type", "session type", @@ -897,6 +863,7 @@ meta_screen_cast_session_class_init (MetaScreenCastSessionClass *klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_properties (object_class, N_PROPS, obj_props); + meta_dbus_session_install_properties (object_class, N_PROPS); } static gboolean