From 8cfed9f5c6d958e2775ebeebf10a9dfec55e8071 Mon Sep 17 00:00:00 2001
From: Ingo Bauersachs
Date: Mon, 3 Feb 2014 23:33:16 +0100
Subject: [PATCH] Webstart-launcher (with HUGE hacks)
---
.gitignore | 1 +
build.xml | 2 +-
.../launcher/SIPCommunicatorJWS.java | 140 +++++++++
web-start/WebStartBuild.properties.sample | 9 +
web-start/WebStartBuild.xml | 292 ++++++++++++++++++
web-start/ant-ext/FelixConfigSelector.java | 92 ++++++
web-start/ant-ext/GenerateFelixConfigs.java | 161 ++++++++++
web-start/ant-ext/PutJarsToJnlp.java | 76 +++++
web-start/client.jnlp_template | 102 ++++++
web-start/index.html | 21 ++
10 files changed, 895 insertions(+), 1 deletion(-)
create mode 100644 src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java
create mode 100644 web-start/WebStartBuild.properties.sample
create mode 100644 web-start/WebStartBuild.xml
create mode 100644 web-start/ant-ext/FelixConfigSelector.java
create mode 100644 web-start/ant-ext/GenerateFelixConfigs.java
create mode 100644 web-start/ant-ext/PutJarsToJnlp.java
create mode 100644 web-start/client.jnlp_template
create mode 100644 web-start/index.html
diff --git a/.gitignore b/.gitignore
index e1a535379..35c645123 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ sip-communicator.utest.bin
release
lib/accounts.properties
.DS_Store
+web-start/WebStartBuild.properties
diff --git a/build.xml b/build.xml
index a8d0fb6db..85b9ee74f 100644
--- a/build.xml
+++ b/build.xml
@@ -1463,7 +1463,7 @@ javax.swing.event, javax.swing.border"/>
-
diff --git a/src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java b/src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java
new file mode 100644
index 000000000..51c02c43d
--- /dev/null
+++ b/src/net/java/sip/communicator/launcher/SIPCommunicatorJWS.java
@@ -0,0 +1,140 @@
+/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package net.java.sip.communicator.launcher;
+
+import java.io.*;
+import java.lang.reflect.*;
+import java.net.*;
+import java.util.*;
+import java.util.jar.*;
+import java.util.logging.*;
+
+import net.java.sip.communicator.util.FileHandler;
+import net.java.sip.communicator.util.*;
+
+public class SIPCommunicatorJWS
+{
+ public static void main(String[] args) throws Exception
+ {
+ // allow access to everything
+ System.setSecurityManager(null);
+
+ // prepare the logger
+ // needed by the FileHandler-Logger
+ SIPCommunicator.setScHomeDir(System.getProperty("os.name"));
+ LogManager.getLogManager()
+ .readConfiguration(
+ SIPCommunicatorJWS.class
+ .getResourceAsStream("/logging.properties"));
+
+ for (Handler h : LogManager.getLogManager().getLogger("").getHandlers())
+ LogManager.getLogManager().getLogger("").removeHandler(h);
+ LogManager.getLogManager().getLogger("").addHandler(new FileHandler());
+ LogManager.getLogManager().getLogger("")
+ .addHandler(new ConsoleHandler());
+ for (Handler h : LogManager.getLogManager().getLogger("").getHandlers())
+ h.setFormatter(new ScLogFormatter());
+
+ // be evil :-)
+ // find the path of the nativelibs under webstart (findLibrary is
+ // protected and therefore at least documented api)
+ Method findLibrary =
+ SIPCommunicatorJWS.class.getClassLoader().getClass()
+ .getDeclaredMethod("findLibrary", String.class);
+ findLibrary.setAccessible(true);
+ File path =
+ new File((String) findLibrary.invoke(
+ SIPCommunicatorJWS.class.getClassLoader(), "hid"))
+ .getParentFile();
+ System.setProperty(
+ "java.library.path",
+ System.getProperty("java.library.path") + File.pathSeparator
+ + path.getAbsolutePath());
+
+ // reset sys_paths to re-read usr_paths (runtime-dependent and therefore
+ // very very ugly :()
+ Field sys_paths = ClassLoader.class.getDeclaredField("sys_paths");
+ sys_paths.setAccessible(true);
+ sys_paths.set(null, null);
+
+ // prepare the felix-config with the absolute paths
+ Properties pIn = new Properties();
+ Properties pOut = new Properties();
+ pIn.load(SIPCommunicatorJWS.class.getResourceAsStream(System
+ .getProperty("felix.config.properties")));
+
+ String baseServerUrl =
+ System.getProperty("net.java.sip.communicator.SC_JWS_BASEDIR");
+ ClassLoader cl = SIPCommunicatorJWS.class.getClassLoader();
+ Method getJarFile =
+ cl.getClass().getDeclaredMethod("getJarFile", URL.class);
+ getJarFile.setAccessible(true);
+ for (Map.Entry
+
+In case Jitsi starts with errors please delete the 'jitsi-jws'
+folder in your home directory and try again. If this does not solve the problem contact us.
+