mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 04:42:14 +00:00
dbus-session: Make some properties part of the interface
The pointer to the manager, the peer name and the ID are things that are always metadata related to a session, so make them properties on the interface instead of duplicating them. The implementations still need to keep track of them, but their existance is shared. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2713>
This commit is contained in:
parent
5731268087
commit
849766652a
@ -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);
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
@ -25,6 +25,15 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#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 */
|
||||
|
@ -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 *
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user