From dce6722fd10abff74c71d60468885439efc6561f Mon Sep 17 00:00:00 2001 From: Dele Olajide Date: Tue, 18 Oct 2022 20:57:02 +0100 Subject: [PATCH 1/2] Add Preferences Panel in SparkMeet --- plugins/meet/pom.xml | 2 +- plugins/meet/readme.md | 2 + .../plugin/ofmeet/ChatRoomDecorator.java | 10 +- .../spark/plugin/ofmeet/SparkMeetPlugin.java | 31 +++-- .../plugin/ofmeet/SparkMeetPreference.java | 119 ++++++++++++++++++ 5 files changed, 150 insertions(+), 14 deletions(-) create mode 100644 plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/SparkMeetPreference.java diff --git a/plugins/meet/pom.xml b/plugins/meet/pom.xml index 716801d3..22a463f1 100644 --- a/plugins/meet/pom.xml +++ b/plugins/meet/pom.xml @@ -10,7 +10,7 @@ meet - 0.0.8 + 0.0.9 Pade Meetings Plugin Adds support for Pade Meetings to the Spark IM client. diff --git a/plugins/meet/readme.md b/plugins/meet/readme.md index f33f6fd6..5202094d 100644 --- a/plugins/meet/readme.md +++ b/plugins/meet/readme.md @@ -7,3 +7,5 @@ It uses Electron instead of depending on Chrome installed and configured as the It is a much better user experience than opening a Chrome browser window out of context somewhere else. Screen sharing is not yet working. All Electron runtime platforms (windows, Linux & OSX) are supported. I have only tested it at home on my windows desktop. Feeback will be appreciated from Linux and OSX users. + +![](https://user-images.githubusercontent.com/110731/196530400-a350cc2c-7f53-4148-b230-ebb7b8cc404a.png) \ No newline at end of file diff --git a/plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/ChatRoomDecorator.java b/plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/ChatRoomDecorator.java index bc295f1d..b57307a5 100644 --- a/plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/ChatRoomDecorator.java +++ b/plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/ChatRoomDecorator.java @@ -31,14 +31,14 @@ public class ChatRoomDecorator { public RolloverButton ofmeetButton; public final ChatRoom room; + public static String ICON_STRING = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAKDSURBVDhPXVM7axVBFP5m7maN5gFyJTdNEEVDUt3C/yAIKkRSidjEUsTKRyrtLSyi/gArSRfFOiBqY5UqICaRYDCvm7177+7Ozj7G70wSSJzlmzk75/WdmTMqLwq3ubKCcGQEOgjgBgKoYACq0YBrKGh+rqrh6gKqqFGVBVCUKJMexqenoba2t937qSmcu3QRmk5aN7yz4tfQGrVzkOG4ermuUBPdzT+4v7wMHYYhMg3k1JkaSJktyQyigwPsdfYRRV0keY7EWpiyRFpWMGJbVQjPDCLQSiGJe9Bxn2lI0VUYao1jcmYGDTJJow6+v3mH860xlkSGcNBOI4oPyBGgv0bKmpIiR7+wPmP7ziyuP37EWi2utK/hdZKgZwyyNEWaW29r8hJK84w0p5yRLBWWNAVRt4vVL9+w+OIlXt27i6+LHzC78BbR7i5y6gUZfRTZ0531EDlrt5VDQWS5Qd9knmJIbP1cg7HG6wViK0lFHwiDHQqms8eZTGqHDg9tdH8XG/y/PDmJG/PP8XC8hR5Pv087cfxLaEq8KEbkT8lAHpTjuIuxdhvzH5dw8+kTzDWb2NneQR3oU3aHh8hFAuQ8WSugbEjxx6fPeHbrNhbmHqDb6bA3gkM9IbapBOCtkYA7OgPeLyHBMpvD8r4HKQtN9qDXHcPbUsd7lxKopGjJR8BGRZJkiPsxqhP7/0MS0R/K9mN3dXgUY7JxNKQMqXGIOGzk04P++E382lgnQ7avZK25e4yA/0JfgggLjxN6gfhI+Srd33PDzQtoycbR4NPwmY9XGbIyl88u2CKi1VWosq5db30N4dkh35q+tRRfI7tMwImJ6MpsruZKyMussgzhxAT+AQRKd557vsR7AAAAAElFTkSuQmCC"; - public ChatRoomDecorator(final ChatRoom room, final String url, final SparkMeetPlugin plugin) + public ChatRoomDecorator(final ChatRoom room, final SparkMeetPlugin plugin) { this.room = room; try { - String imageString = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAKDSURBVDhPXVM7axVBFP5m7maN5gFyJTdNEEVDUt3C/yAIKkRSidjEUsTKRyrtLSyi/gArSRfFOiBqY5UqICaRYDCvm7177+7Ozj7G70wSSJzlmzk75/WdmTMqLwq3ubKCcGQEOgjgBgKoYACq0YBrKGh+rqrh6gKqqFGVBVCUKJMexqenoba2t937qSmcu3QRmk5aN7yz4tfQGrVzkOG4ermuUBPdzT+4v7wMHYYhMg3k1JkaSJktyQyigwPsdfYRRV0keY7EWpiyRFpWMGJbVQjPDCLQSiGJe9Bxn2lI0VUYao1jcmYGDTJJow6+v3mH860xlkSGcNBOI4oPyBGgv0bKmpIiR7+wPmP7ziyuP37EWi2utK/hdZKgZwyyNEWaW29r8hJK84w0p5yRLBWWNAVRt4vVL9+w+OIlXt27i6+LHzC78BbR7i5y6gUZfRTZ0531EDlrt5VDQWS5Qd9knmJIbP1cg7HG6wViK0lFHwiDHQqms8eZTGqHDg9tdH8XG/y/PDmJG/PP8XC8hR5Pv087cfxLaEq8KEbkT8lAHpTjuIuxdhvzH5dw8+kTzDWb2NneQR3oU3aHh8hFAuQ8WSugbEjxx6fPeHbrNhbmHqDb6bA3gkM9IbapBOCtkYA7OgPeLyHBMpvD8r4HKQtN9qDXHcPbUsd7lxKopGjJR8BGRZJkiPsxqhP7/0MS0R/K9mN3dXgUY7JxNKQMqXGIOGzk04P++E382lgnQ7avZK25e4yA/0JfgggLjxN6gfhI+Srd33PDzQtoycbR4NPwmY9XGbIyl88u2CKi1VWosq5db30N4dkh35q+tRRfI7tMwImJ6MpsruZKyMussgzhxAT+AQRKd557vsR7AAAAAElFTkSuQmCC"; - byte[] imageByte = DatatypeConverter.parseBase64Binary(imageString); + byte[] imageByte = DatatypeConverter.parseBase64Binary(ICON_STRING); ImageIcon ofmeetIcon = new ImageIcon(imageByte); ofmeetButton = new RolloverButton(SparkRes.getImageIcon("PADE_ICON")); ofmeetButton.setToolTipText(GraphicUtils.createToolTip("Pade Meetings")); @@ -51,12 +51,12 @@ public class ChatRoomDecorator if ("groupchat".equals(room.getChatType().toString())) { newRoomId = roomId + "-" + sessionID; - newUrl = url + newRoomId; + newUrl = plugin.url + newRoomId; plugin.handleClick(newUrl, room, newUrl, Message.Type.groupchat); } else { newRoomId = sessionID; - newUrl = url + newRoomId; + newUrl = plugin.url + newRoomId; plugin.handleClick(newUrl, room, newUrl, Message.Type.chat); } }); 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 ebf21141..fb8b9012 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 @@ -40,11 +40,13 @@ import org.jxmpp.jid.parts.*; public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageListener { + public Properties props = props = new Properties(); + public String url = null; + private org.jivesoftware.spark.ChatManager chatManager; - private String url = null; - - private static final File pluginsettings = new File(System.getProperty("user.home") + System.getProperty("file.separator") + "Spark" + System.getProperty("file.separator") + "ofmeet.properties"); - private final Map decorators = new HashMap<>(); + private File pluginsettings = new File(System.getProperty("user.home") + System.getProperty("file.separator") + "Spark" + System.getProperty("file.separator") + "ofmeet.properties"); + + private final Map decorators = new HashMap<>(); private String electronExePath = null; private String electronHomePath = null; private XProcess electronThread = null; @@ -54,14 +56,12 @@ public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageL { checkNatives(); - chatManager = SparkManager.getChatManager(); + chatManager = SparkManager.getChatManager(); String server = SparkManager.getSessionManager().getServerAddress().toString(); String port = "7443"; url = "https://" + server + ":" + port + "/ofmeet/"; - Properties props = new Properties(); - if (pluginsettings.exists()) { Log.warning("ofmeet-info: Properties-file does exist= " + pluginsettings.getPath()); @@ -85,8 +85,23 @@ public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageL chatManager.addChatRoomListener(this); chatManager.addGlobalMessageListener(this); + + SparkMeetPreference preference = new SparkMeetPreference(this); + SparkManager.getPreferenceManager().addPreference(preference); } + public void commit(String url) { + this.url = url; + props.setProperty("url", url); + + try { + FileOutputStream outputStream = new FileOutputStream(pluginsettings); + props.store(outputStream, "Properties"); + outputStream.close(); + } catch (Exception e) { + Log.warning("ofmeet-Error:", e); + } + } public void shutdown() { @@ -292,7 +307,7 @@ public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageL if (roomId.indexOf('/') == -1) { - decorators.put(roomId, new ChatRoomDecorator(room, url, this)); + decorators.put(roomId, new ChatRoomDecorator(room, this)); } } diff --git a/plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/SparkMeetPreference.java b/plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/SparkMeetPreference.java new file mode 100644 index 00000000..04a16e0f --- /dev/null +++ b/plugins/meet/src/main/java/org/jivesoftware/spark/plugin/ofmeet/SparkMeetPreference.java @@ -0,0 +1,119 @@ +/** + * Copyright (C) 2004-2011 Jive Software. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jivesoftware.spark.plugin.ofmeet; + +import java.util.*; +import javax.swing.*; +import java.awt.*; +import javax.swing.border.*; +import javax.xml.bind.DatatypeConverter; + +import org.jivesoftware.spark.preference.Preference; +import org.jivesoftware.spark.util.log.Log; + +public class SparkMeetPreference implements Preference { + public static final String NAMESPACE = "ofmeet"; + + private SparkMeetPlugin plugin; + private final UrlPanel panel = new UrlPanel(); + + public SparkMeetPreference(SparkMeetPlugin plugin) { + this.plugin = plugin; + } + + @Override + public void commit() { + plugin.commit(panel.getUrl()); + } + + @Override + public Object getData() { + return plugin.props; + } + + @Override + public String getErrorMessage() { + return null; + } + + @Override + public JComponent getGUI() { + panel.setUrl(plugin.props.getProperty("url")); + return panel; + } + + @Override + public Icon getIcon() { + byte[] imageByte = DatatypeConverter.parseBase64Binary(ChatRoomDecorator.ICON_STRING); + return new ImageIcon(imageByte); + } + + @Override + public String getListName() { + return "Pade Meetings"; + } + + @Override + public String getNamespace() { + return NAMESPACE; + } + + @Override + public String getTitle() { + return "Pade Meetings Settings"; + } + + @Override + public String getTooltip() { + return "Set URL for Pade Meetingst"; + } + + @Override + public boolean isDataValid() { + return true; + } + + @Override + public void load() { + + } + + @Override + public void shutdown() { + + } + + private static class UrlPanel extends JPanel { + private static final long serialVersionUID = -5992704440953686499L; + private final JTextArea txtMessage = new JTextArea(2, 0); + + UrlPanel() { + txtMessage.setBorder(UIManager.getLookAndFeelDefaults().getBorder("TextField.border")); + setLayout(new BorderLayout()); + setBorder(BorderFactory.createCompoundBorder(new TitledBorder("Jitsi Meet URL"), new EmptyBorder(2,4,4,4))); + add(txtMessage, BorderLayout.CENTER); + } + + public void setUrl(String message) { + txtMessage.setText(message); + } + + public String getUrl() { + return txtMessage.getText().trim(); + } + } + +} From 4e667de88699246c75f00fa2810fc6ef75c83a21 Mon Sep 17 00:00:00 2001 From: ilyaHlevnoy <71222850+Plyha@users.noreply.github.com> Date: Thu, 20 Oct 2022 16:14:08 +0300 Subject: [PATCH 2/2] fix path --- .../org/jivesoftware/spark/plugin/ofmeet/SparkMeetPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fb8b9012..31b3364b 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 @@ -44,7 +44,7 @@ public class SparkMeetPlugin implements Plugin, ChatRoomListener, GlobalMessageL public String url = null; private org.jivesoftware.spark.ChatManager chatManager; - private File pluginsettings = new File(System.getProperty("user.home") + System.getProperty("file.separator") + "Spark" + System.getProperty("file.separator") + "ofmeet.properties"); + private final File pluginsettings = new File( Spark.getLogDirectory().getParentFile() + System.getProperty("file.separator") + "ofmeet.properties"); private final Map decorators = new HashMap<>(); private String electronExePath = null;