ref: remove unnecessary dbus permission

This commit is contained in:
noise 2026-02-28 19:12:09 +03:00
parent 20f9c44a6e
commit a7bb564c79
3 changed files with 7 additions and 22 deletions

View File

@ -8,8 +8,7 @@
"--share=ipc", "--share=ipc",
"--socket=fallback-x11", "--socket=fallback-x11",
"--socket=wayland", "--socket=wayland",
"--talk-name=org.kde.StatusNotifierWatcher", "--talk-name=org.kde.StatusNotifierWatcher"
"--own-name=org.kde.StatusNotifierItem-2-1"
], ],
"modules": [ "modules": [
{ {

View File

@ -266,16 +266,6 @@ static const GDBusInterfaceVTable sni_vtable = {
.set_property = NULL, .set_property = NULL,
}; };
static void on_sni_bus_name_acquired(GDBusConnection *connection,
const gchar *name,
G_GNUC_UNUSED gpointer user_data) {
g_dbus_connection_call(
connection, "org.kde.StatusNotifierWatcher", "/StatusNotifierWatcher",
"org.kde.StatusNotifierWatcher", "RegisterStatusNotifierItem",
g_variant_new("(s)", name), NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL,
NULL);
}
static void update_tray_icon(MoeMojiApplication *self) { static void update_tray_icon(MoeMojiApplication *self) {
AdwStyleManager *sm = adw_style_manager_get_default(); AdwStyleManager *sm = adw_style_manager_get_default();
gboolean dark = adw_style_manager_get_dark(sm); gboolean dark = adw_style_manager_get_dark(sm);
@ -334,11 +324,12 @@ static void setup_sni(MoeMojiApplication *self) {
g_warning("dbusmenu register: %s", error->message); g_warning("dbusmenu register: %s", error->message);
g_error_free(error); g_error_free(error);
} }
g_autofree gchar *bus_name = const gchar *unique_name = g_dbus_connection_get_unique_name(self->dbus_conn);
g_strdup_printf("org.kde.StatusNotifierItem-%d-1", getpid()); g_dbus_connection_call(
self->sni_bus_name_id = g_bus_own_name_on_connection( self->dbus_conn, "org.kde.StatusNotifierWatcher", "/StatusNotifierWatcher",
self->dbus_conn, bus_name, G_BUS_NAME_OWNER_FLAGS_NONE, "org.kde.StatusNotifierWatcher", "RegisterStatusNotifierItem",
on_sni_bus_name_acquired, NULL, NULL, NULL); g_variant_new("(s)", unique_name), NULL, G_DBUS_CALL_FLAGS_NONE, -1,
NULL, NULL, NULL);
} }
static void on_shortcuts_activated(GDBusProxy *proxy, const gchar *sender_name, static void on_shortcuts_activated(GDBusProxy *proxy, const gchar *sender_name,
@ -561,10 +552,6 @@ static void moemoji_application_dispose(GObject *object) {
self->menu_registration_id); self->menu_registration_id);
self->menu_registration_id = 0; self->menu_registration_id = 0;
} }
if (self->sni_bus_name_id > 0) {
g_bus_unown_name(self->sni_bus_name_id);
self->sni_bus_name_id = 0;
}
g_clear_object(&self->shortcuts_proxy); g_clear_object(&self->shortcuts_proxy);
g_clear_pointer(&self->shortcuts_session_path, g_free); g_clear_pointer(&self->shortcuts_session_path, g_free);
g_clear_pointer(&self->icon_theme_path, g_free); g_clear_pointer(&self->icon_theme_path, g_free);

View File

@ -11,7 +11,6 @@ struct _MoeMojiApplication {
gboolean shortcuts_bound; gboolean shortcuts_bound;
GDBusConnection *dbus_conn; GDBusConnection *dbus_conn;
guint sni_registration_id; guint sni_registration_id;
guint sni_bus_name_id;
guint menu_registration_id; guint menu_registration_id;
gchar *icon_theme_path; gchar *icon_theme_path;
const gchar *tray_icon_name; const gchar *tray_icon_name;