Skip to content

Commit

Permalink
Remove all files when disabling extension
Browse files Browse the repository at this point in the history
If the extension is uninstalled, the DBus file and others
remain in the system. This can cause problems to other programs
that interact with GSConnect.

This patch fixes this issue by removing all the files when the
extension is disabled, and recreating them when it is enabled.

Fix GSConnect#1269
  • Loading branch information
rastersoft committed Mar 6, 2022
1 parent af72ded commit 3bf8d4d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,6 @@ var serviceIndicator = null;


function init() {
// If installed as a user extension, this will install the Desktop entry,
// DBus and systemd service files necessary for DBus activation and
// GNotifications. Since there's no uninit()/uninstall() hook for extensions
// and they're only used *by* GSConnect, they should be okay to leave.
Utils.installService();

// These modify the notification source for GSConnect's GNotifications and
// need to be active even when the extension is disabled (eg. lock screen).
// Since they *only* affect notifications from GSConnect, it should be okay
Expand All @@ -443,6 +437,10 @@ function init() {


function enable() {
// If installed as a user extension, this will install the Desktop entry,
// DBus and systemd service files necessary for DBus activation and
// GNotifications.
Utils.installService(true);
serviceIndicator = new ServiceIndicator();
Notification.patchGtkNotificationSources();
}
Expand All @@ -452,4 +450,5 @@ function disable() {
serviceIndicator.destroy();
serviceIndicator = null;
Notification.unpatchGtkNotificationSources();
Utils.installService(false);
}
2 changes: 1 addition & 1 deletion src/prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Extension = imports.misc.extensionUtils.getCurrentExtension();
const Utils = Extension.imports.shell.utils;

function init() {
Utils.installService();
Utils.installService(true);
}

function buildPrefsWidget() {
Expand Down
4 changes: 2 additions & 2 deletions src/shell/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function _installResource(dirname, basename, relativePath) {
/**
* Install the files necessary for the GSConnect service to run.
*/
function installService() {
function installService(enabling) {
const confDir = GLib.get_user_config_dir();
const dataDir = GLib.get_user_data_dir();
const homeDir = GLib.get_home_dir();
Expand Down Expand Up @@ -171,7 +171,7 @@ function installService() {

// If running as a user extension, ensure the DBus service, desktop entry,
// file manager scripts, and WebExtension manifests are installed.
if (Config.IS_USER) {
if (Config.IS_USER && enabling) {
// DBus Service
if (!_installResource(dbusDir, dbusFile, `${dbusFile}.in`))
throw Error('GSConnect: Failed to install DBus Service');
Expand Down

0 comments on commit 3bf8d4d

Please sign in to comment.