From f0e16f79e6b5d16c767d2c5ba3fb198400ce8b79 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Mon, 27 Apr 2026 00:24:58 +0300 Subject: [PATCH] SPARK-2401: meet plugin: should ask before installing the Electron --- .../spark/plugin/ofmeet/SparkMeetPlugin.java | 61 ++++++++----------- .../resources/i18n/sparkmeet_i18n.properties | 2 +- .../i18n/sparkmeet_i18n_fr.properties | 1 + .../i18n/sparkmeet_i18n_ru.properties | 1 + .../i18n/sparkmeet_i18n_uk.properties | 1 + 5 files changed, 29 insertions(+), 37 deletions(-) diff --git a/plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/SparkMeetPlugin.java b/plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/SparkMeetPlugin.java index 1bdf57b4e..d566b0775 100644 --- a/plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/SparkMeetPlugin.java +++ b/plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/SparkMeetPlugin.java @@ -45,6 +45,8 @@ import org.jxmpp.jid.DomainBareJid; import org.jxmpp.jid.EntityJid; import org.jxmpp.jid.parts.*; +import static javax.swing.JOptionPane.YES_OPTION; + public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageListener { public Properties props = new Properties(); @@ -60,7 +62,7 @@ public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageL /** Key: BareJid for groups or chats, EntityJid for 1-1 chats */ private final Map decorators = new HashMap<>(); private String electronExePath = null; - private String electronHomePath = null; + private File electronHomePath = null; private XProcess electronThread = null; private JPanel inviteAlert; @@ -68,7 +70,7 @@ public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageL public void initialize() { ProviderManager.addIQProvider("query", QueryRequest.NAMESPACE, new QueryRequest.Provider()); - checkNatives(); + getElectronPath(); ChatManager chatManager = SparkManager.getChatManager(); @@ -187,6 +189,11 @@ public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageL { Log.error("shutdown ", e); } + electronHomePath = null; + electronExePath = null; + url = null; + //TODO remove buttons + decorators.clear(); } @Override @@ -282,8 +289,15 @@ public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageL public void openURL(String newUrl) { + if (!electronHomePath.exists()) { + if (JOptionPane.showConfirmDialog(SparkManager.getMainWindow(), SparkMeetResource.getString("install.electron")) != YES_OPTION) { + return; + } + checkNatives(); + } + try { - electronThread = Spawn.startProcess(electronExePath + " --ignore-certificate-errors " + newUrl, new File(electronHomePath), new ProcessListener() { + electronThread = Spawn.startProcess(electronExePath + " --ignore-certificate-errors " + newUrl, electronHomePath, new ProcessListener() { @Override public void onOutputLine(final String line) { @@ -343,23 +357,11 @@ public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageL private void checkNatives() { - Log.debug("checkNatives"); - - new Thread() - { - @Override public void run() - { + Log.debug("Install Electron"); try { - String nativeLibsJarPath = Spark.getSparkUserHome() + File.separator + "plugins" + File.separator + "meet" + File.separator + "lib"; - File nativeLibFolder = new File(nativeLibsJarPath, "native"); - - electronHomePath = nativeLibsJarPath + File.separator + "native"; - electronExePath = electronHomePath + File.separator + "electron"; - - if(!nativeLibFolder.exists()) - { - nativeLibFolder.mkdir(); + //noinspection ResultOfMethodCallIgnored + electronHomePath.mkdirs(); String jarFileSuffix = null; @@ -417,30 +419,17 @@ public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageL zipIn.close(); Log.debug("Native lib folder created and natives extracted"); - } - else { - Log.debug("Native lib folder already exist."); - } - - - String libPath = nativeLibFolder.getCanonicalPath(); - - if (!System.getProperty("java.library.path").contains(libPath)) - { - String newLibPath = libPath + File.pathSeparator + System.getProperty("java.library.path"); - System.setProperty("java.library.path", newLibPath); - - // this will reload the new setting - Log.warning("Unable to modify 'java.library.path' dynamically. Please ensure the library path includes: " + libPath); - } } catch (Exception e) { Log.error(e.getMessage(), e); } - } + } - }.start(); + private void getElectronPath() { + String nativeLibsJarPath = Spark.getSparkUserHome() + File.separator + "plugins" + File.separator + "meet" + File.separator + "lib"; + electronHomePath = new File(nativeLibsJarPath, "native"); + electronExePath = new File(electronHomePath, "electron").getAbsolutePath(); } private void extractFile(ZipInputStream zipIn, String filePath) throws IOException diff --git a/plugins/meet/src/main/resources/i18n/sparkmeet_i18n.properties b/plugins/meet/src/main/resources/i18n/sparkmeet_i18n.properties index 3f2a14327..487a2bd94 100644 --- a/plugins/meet/src/main/resources/i18n/sparkmeet_i18n.properties +++ b/plugins/meet/src/main/resources/i18n/sparkmeet_i18n.properties @@ -2,4 +2,4 @@ name=Online Meetings preference.title=Online Meetings Settings preference.url=Online Meetings Base URL - +install.electron=To open the meeting web address we need to download Electron browser. Continue? diff --git a/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_fr.properties b/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_fr.properties index fcb0fd335..7a83b1d0d 100644 --- a/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_fr.properties +++ b/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_fr.properties @@ -2,3 +2,4 @@ name = Pade Meetings preference.url = URL Jitsi Meet preference.title = Paramètres Pade Meetings +install.electron=Pour ouvrir l'adresse Web de la réunion, nous devons télécharger le navigateur Electron. Continuer? diff --git a/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_ru.properties b/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_ru.properties index 5f9b40af4..839d28b71 100644 --- a/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_ru.properties +++ b/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_ru.properties @@ -2,3 +2,4 @@ name=Онлайн встречи preference.url=Базовый URL-адрес для онлайн встреч preference.title=Настройки онлайн встреч +install.electron=Чтобы открыть адрес встречи, нам нужно скачать обозреватель Electron. Продолжать? diff --git a/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_uk.properties b/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_uk.properties index bcc2d61b3..62f3331f1 100644 --- a/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_uk.properties +++ b/plugins/meet/src/main/resources/i18n/sparkmeet_i18n_uk.properties @@ -2,3 +2,4 @@ name=Онлайн зустрічі preference.url=Базова URL-адреса для онлайн зустрічей preference.title=Налаштування онлайн зустрічей +install.electron=Щоб відкрити веб-адресу зустрічі, нам потрібно скачати обозрівач Electron. Продовжити?