diff --git a/gui/build.gradle b/gui/build.gradle index b3aa4a6d..d9295590 100644 --- a/gui/build.gradle +++ b/gui/build.gradle @@ -115,6 +115,10 @@ dependencies { implementation "net.java.dev.jna:jna:5.10.0" implementation 'net.java.dev.jna:jna-platform:5.10.0' + implementation 'com.github.hypfvieh:dbus-java-parent:4.1.0' + implementation 'com.github.hypfvieh:dbus-java-transport-jnr-unixsocket:4.1.0' + implementation 'com.github.hypfvieh:dbus-java-transport-tcp:4.1.0' + // runtime "org.slf4j:slf4j-simple:${slf4jVersion}" runtimeOnly group: 'org.slf4j', name: 'slf4j-jdk14', version: "${slf4jVersion}" diff --git a/gui/src/main/groovy/com/muwire/gui/ChatNotificator.groovy b/gui/src/main/groovy/com/muwire/gui/ChatNotificator.groovy index 5b9a2a8b..31b9ec0f 100644 --- a/gui/src/main/groovy/com/muwire/gui/ChatNotificator.groovy +++ b/gui/src/main/groovy/com/muwire/gui/ChatNotificator.groovy @@ -1,5 +1,8 @@ package com.muwire.gui +import com.muwire.gui.linux.NotifyService +import net.i2p.util.SystemVersion + import java.awt.Image import java.awt.Taskbar import java.awt.Taskbar.Feature @@ -41,9 +44,11 @@ class ChatNotificator { } void notifyMention() { - if (trayIcon == null) - return - trayIcon.displayMessage(trans("NEW_CHAT_MENTION"), trans("NEW_CHAT_MENTION"), TrayIcon.MessageType.INFO) + String translated = trans("NEW_CHAT_MENTION") + if (!SystemVersion.isWindows() && !SystemVersion.isMac()) + NotifyService.notify(translated) + if (trayIcon != null) + trayIcon.displayMessage(translated, translated, TrayIcon.MessageType.INFO) } void serverTabChanged(JTabbedPane source) { diff --git a/gui/src/main/groovy/com/muwire/gui/linux/NotifyService.groovy b/gui/src/main/groovy/com/muwire/gui/linux/NotifyService.groovy new file mode 100644 index 00000000..eff69b33 --- /dev/null +++ b/gui/src/main/groovy/com/muwire/gui/linux/NotifyService.groovy @@ -0,0 +1,21 @@ +package com.muwire.gui.linux + +import org.freedesktop.Notifications +import org.freedesktop.dbus.connections.impl.DBusConnection +import org.freedesktop.dbus.connections.impl.DBusConnectionBuilder +import org.freedesktop.dbus.interfaces.DBusInterface + +class NotifyService { + + private static final String BUS_NAME = "org.freedesktop.Notifications" + private static final String BUS_PATH = "/org/freedesktop/Notifications" + private static final DBusConnection CONNECTION + + static { + CONNECTION = DBusConnectionBuilder.forSessionBus().build() + } + + static void notify(String text) { + Notifications notifications = CONNECTION.getRemoteObject(BUS_NAME, BUS_PATH, Notifications.class) + } +} diff --git a/gui/src/main/java/org/freedesktop/GetServerInformationTuple.java b/gui/src/main/java/org/freedesktop/GetServerInformationTuple.java new file mode 100644 index 00000000..563fa24c --- /dev/null +++ b/gui/src/main/java/org/freedesktop/GetServerInformationTuple.java @@ -0,0 +1,56 @@ +package org.freedesktop; + +import org.freedesktop.dbus.Tuple; +import org.freedesktop.dbus.annotations.Position; + +/** + * Auto-generated class. + */ +public class GetServerInformationTuple extends Tuple { + @Position(0) + private String arg_0; + @Position(1) + private String arg_1; + @Position(2) + private String arg_2; + @Position(3) + private String arg_3; + + public GetServerInformationTuple(String arg_0, String arg_1, String arg_2, String arg_3) { + this.arg_0 = arg_0; + this.arg_1 = arg_1; + this.arg_2 = arg_2; + this.arg_3 = arg_3; + } + + public void setArg_0(String arg) { + arg_0 = arg; + } + + public String getArg_0() { + return arg_0; + } + public void setArg_1(String arg) { + arg_1 = arg; + } + + public String getArg_1() { + return arg_1; + } + public void setArg_2(String arg) { + arg_2 = arg; + } + + public String getArg_2() { + return arg_2; + } + public void setArg_3(String arg) { + arg_3 = arg; + } + + public String getArg_3() { + return arg_3; + } + + +} \ No newline at end of file diff --git a/gui/src/main/java/org/freedesktop/Notifications.java b/gui/src/main/java/org/freedesktop/Notifications.java new file mode 100644 index 00000000..49d96a8e --- /dev/null +++ b/gui/src/main/java/org/freedesktop/Notifications.java @@ -0,0 +1,68 @@ +package org.freedesktop; + +import java.util.List; +import java.util.Map; +import org.freedesktop.dbus.exceptions.DBusException; +import org.freedesktop.dbus.interfaces.DBusInterface; +import org.freedesktop.dbus.messages.DBusSignal; +import org.freedesktop.dbus.types.UInt32; +import org.freedesktop.dbus.types.Variant; + +/** + * Auto-generated class. + */ +public interface Notifications extends DBusInterface { + + + public UInt32 Notify(String arg_0, UInt32 arg_1, String arg_2, String arg_3, String arg_4, List arg_5, Map> arg_6, int arg_7); + public void CloseNotification(UInt32 arg_0); + public List GetCapabilities(); + public GetServerInformationTuple GetServerInformation(); + + + public static class NotificationClosed extends DBusSignal { + + private final UInt32 arg_0; + private final UInt32 arg_1; + + public NotificationClosed(String _path, UInt32 _arg_0, UInt32 _arg_1) throws DBusException { + super(_path, _arg_0, _arg_1); + this.arg_0 = _arg_0; + this.arg_1 = _arg_1; + } + + + public UInt32 getArg_0() { + return arg_0; + } + + public UInt32 getArg_1() { + return arg_1; + } + + + } + + public static class ActionInvoked extends DBusSignal { + + private final UInt32 arg_0; + private final String arg_1; + + public ActionInvoked(String _path, UInt32 _arg_0, String _arg_1) throws DBusException { + super(_path, _arg_0, _arg_1); + this.arg_0 = _arg_0; + this.arg_1 = _arg_1; + } + + + public UInt32 getArg_0() { + return arg_0; + } + + public String getArg_1() { + return arg_1; + } + + + } +} \ No newline at end of file