diff options
author | Alexandr Miloslavskiy | 2019-04-29 08:51:24 -0400 |
---|---|---|
committer | Alexandr Miloslavskiy | 2019-04-29 09:36:38 -0400 |
commit | 3df6d246caeee99b4e0ecb27509b3124c910972d (patch) | |
tree | 1ed3a06b56f4d428b7ad24d86b4e64d32aa5fce2 | |
parent | ce086f1979c87fa169cb52c5a62b29c2595878f0 (diff) | |
download | eclipse.platform.swt-3df6d246caeee99b4e0ecb27509b3124c910972d.tar.gz eclipse.platform.swt-3df6d246caeee99b4e0ecb27509b3124c910972d.tar.xz eclipse.platform.swt-3df6d246caeee99b4e0ecb27509b3124c910972d.zip |
Bug 531634 - [GTK] Linux: Handle logoff / shutdown events from session manager
Do not show errors if session manager is not supported.
Change-Id: I55e93786596791e8e8593e393c32867d56e5aae9
Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java index cecfac30ac..14ae1825f0 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/internal/SessionManagerDBus.java @@ -244,10 +244,9 @@ public class SessionManagerDBus { /** * Creates a connection to the session manager. * - * Saves result to member variable when successful. - * @return Error string in case of error, null if successful. + * @return Pointer to dbus proxy, 0 if failed. */ - private String connectSessionManager(String dbusName, String objectPath, String interfaceName) { + private long connectSessionManager(String dbusName, String objectPath, String interfaceName) { int sessionManagerFlags = OS.G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START | OS.G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | @@ -265,47 +264,55 @@ public class SessionManagerDBus { error); // Proxy is usually created even for non-existent service names. - if (proxy == 0) return extractFreeGError(error[0]); + // Errors are not really expected here. + if (proxy == 0) { + String errorText = extractFreeGError(error[0]); + System.err.format( + "SWT SessionManagerDBus: Failed to connect to %s: %s%n", + dbusName, + errorText); + + return 0; + } - // Is the service actually present? + // Proxy was created, but is the service actually present? + // This is what fails if service is not supported. long owner = OS.g_dbus_proxy_get_name_owner(proxy); if (owner == 0) { + // It's expected that not every Linux will support it. + // Do not print errors, because there's nothing wrong. OS.g_object_unref(proxy); - return "Service not present"; + return 0; } OS.g_free(owner); // Success - sessionManagerProxy = proxy; - return null; + return proxy; } private boolean connectSessionManager() { - String errorGnome = connectSessionManager( + long proxyGnome = connectSessionManager( "org.gnome.SessionManager", //$NON-NLS-1$ "/org/gnome/SessionManager", //$NON-NLS-1$ "org.gnome.SessionManager"); //$NON-NLS-1$ - if (errorGnome == null) { + if (proxyGnome != 0) { + sessionManagerProxy = proxyGnome; isGnome = true; return true; } - String errorXCFE = connectSessionManager( + long proxyXFCE = connectSessionManager( "org.xfce.SessionManager", //$NON-NLS-1$ "/org/xfce/SessionManager", //$NON-NLS-1$ "org.xfce.Session.Manager"); //$NON-NLS-1$ - if (errorXCFE == null) { + if (proxyXFCE != 0) { + sessionManagerProxy = proxyXFCE; isGnome = false; return true; } - System.err.format( - "SWT SessionManagerDBus: Failed to connect to SessionManager (gnome: %s, xcfe: %s)%n", - errorGnome, - errorXCFE); - return false; } |