aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/native/mac/libAEGetURLEventHandlerAgent.jnilibbin0 -> 22224 bytes
-rw-r--r--resources/install/ant-build-config.properties6
-rw-r--r--resources/install/build.xml55
-rwxr-xr-xresources/install/generic/installer-generic.xml6
-rwxr-xr-xresources/install/linux/installer-linux.xml6
-rwxr-xr-xresources/install/windows/installer-windows.xml6
-rw-r--r--src/native/macosx/launcharghandler/AEGetURLEventHandler.h32
-rw-r--r--src/native/macosx/launcharghandler/AEGetURLEventHandlerAgent.m173
-rw-r--r--src/native/macosx/launcharghandler/Makefile20
-rw-r--r--src/net/java/sip/communicator/util/launchutils/AEGetURLEventHandler.java62
-rw-r--r--src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java7
11 files changed, 336 insertions, 37 deletions
diff --git a/lib/native/mac/libAEGetURLEventHandlerAgent.jnilib b/lib/native/mac/libAEGetURLEventHandlerAgent.jnilib
new file mode 100755
index 0000000..9e878e1
--- /dev/null
+++ b/lib/native/mac/libAEGetURLEventHandlerAgent.jnilib
Binary files differ
diff --git a/resources/install/ant-build-config.properties b/resources/install/ant-build-config.properties
index 1d1e73f..5163cd5 100644
--- a/resources/install/ant-build-config.properties
+++ b/resources/install/ant-build-config.properties
@@ -2,6 +2,6 @@ application.name=SIP Communicator
application.web=http://sip-communicator.org/
application.email=sc@sip-communicator.org
package.name=sip-communicator
-installer.welcome.developedby=This software is developed by: SIP Communicator <sc@sip-communicator.org>
-installer.welcome.url=The homepage is at: http://sip-communicator.org/
-installer.welcome.poweredby=
+installer.welcome.wtext1=This software is developed by: SIP Communicator <sc@sip-communicator.org>
+installer.welcome.wtext2=The homepage is at: http://sip-communicator.org/
+installer.welcome.wtext3=
diff --git a/resources/install/build.xml b/resources/install/build.xml
index 6beac25..28d27d0 100644
--- a/resources/install/build.xml
+++ b/resources/install/build.xml
@@ -121,6 +121,10 @@
<filter token="APP_EMAIL" value="${application.email}" />
<filter token="APP_WEB" value="${application.web}" />
<filter token="DEST_DIR" value="${release}" />
+ <filter token="WelcomeText1" value="${installer.welcome.wtext1}" />
+ <filter token="WelcomeText2" value="${installer.welcome.wtext2}" />
+ <filter token="WelcomeText3" value="${installer.welcome.wtext3}" />
+
<copy
tofile="${generic.app.dir}/tmp-installer-generic.xml"
file="${inst.resrc}/generic/installer-generic.xml"
@@ -174,6 +178,9 @@
<filter token="APP_EMAIL" value="${application.email}" />
<filter token="APP_WEB" value="${application.web}" />
<filter token="DEST_DIR" value="${release}" />
+ <filter token="WelcomeText1" value="${installer.welcome.wtext1}" />
+ <filter token="WelcomeText2" value="${installer.welcome.wtext2}" />
+ <filter token="WelcomeText3" value="${installer.welcome.wtext3}" />
<copy todir="${linux.app.dir}/tmp" filtering="yes" >
<fileset dir="${inst.resrc}/linux">
@@ -255,9 +262,9 @@
<filter token="APP_EMAIL" value="${application.email}" />
<filter token="APP_WEB" value="${application.web}" />
<filter token="DEST_DIR" value="${release}" />
- <filter token="DEVELOPED_BY" value="${installer.welcome.developedby}" />
- <filter token="LINK" value="${installer.welcome.url}" />
- <filter token="POWERED_BY" value="${installer.welcome.poweredby}" />
+ <filter token="WelcomeText1" value="${installer.welcome.wtext1}" />
+ <filter token="WelcomeText2" value="${installer.welcome.wtext2}" />
+ <filter token="WelcomeText3" value="${installer.welcome.wtext3}" />
<copy
tofile="${windows.app.dir}/tmp-windows_shortcut_specification.xml"
@@ -407,7 +414,8 @@
bundleid="org.sip-communicator"
stubfile="${macosx.stubfile}"
extraclasspath="/System/Library/Java"
- workingdirectory="$APP_PACKAGE/Contents/Resources/Java">
+ workingdirectory="$APP_PACKAGE/Contents/Resources/Java"
+ vmoptions="-agentlib:AEGetURLEventHandlerAgent">
<javaproperty name="apple.laf.useScreenMenuBar" value="true"/>
<javaproperty name="apple.awt.brushMetalRounded" value="true"/>
@@ -446,6 +454,24 @@
files="versionupdate.properties"/>
</jarbundler>
<mkdir dir="${macosx.app.dir}/${application.name}.app/Contents/Resources/Java/log"/>
+
+ <!-- Add the url types in the Info.plist file -->
+ <replace file="${macosx.app.dir}/${application.name}.app/Contents/Info.plist">
+ <replacetoken><![CDATA[<key>CFBundleName</key>]]></replacetoken>
+ <replacevalue><![CDATA[<key>CFBundleURLTypes</key>
+ <array>
+ <dict>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>sip</string>
+ <string>feed</string>
+ </array>
+ </dict>
+ </array>
+ <key>CFBundleName</key>]]></replacevalue>
+ </replace>
+ <symlink resource="lib/native/mac/libAEGetURLEventHandlerAgent.jnilib" link="${macosx.app.dir}/${application.name}.app/Contents/Resources/Java/libAEGetURLEventHandlerAgent.jnilib"/>
+
</target>
<!-- Create a MacOSX application package with Sparkle support.
@@ -512,27 +538,6 @@
value="http://download.sip-communicator.org/nightly/macosx/${package.name}-${sip-communicator.version}.dmg"/>
</propertyfile>
- <!-- Copy the urlhandler application to destination dir-->
- <copy todir="${macosx.app.dir}/${application.name}.app/Contents/Resources/URLHandler.app">
- <fileset dir="${macosx.resrc.dir}/URLHandler.app"/>
- </copy>
- <!-- copy and icon as it uses our application icon -->
- <copy todir="${macosx.app.dir}/${application.name}.app/Contents/Resources/URLHandler.app/Contents/Resources">
- <fileset file="resources/images/logo/sc_logo_128x128.icns"/>
- </copy>
- <!-- move our application plist template -->
- <move file="${macosx.app.dir}/${application.name}.app/Contents/Resources/URLHandler.app/Contents/Info.plist.tmpl"
- tofile="${macosx.app.dir}/${application.name}.app/Contents/Resources/URLHandler.app/Contents/Info.plist"/>
- <!-- change name of the urlhandler application-->
- <replace
- file="${macosx.app.dir}/${application.name}.app/Contents/Resources/URLHandler.app/Contents/Info.plist"
- value="${application.name}">
- <replacefilter
- token="APP_NAME"/>
- </replace>
- <!-- make sure that launcher is executable -->
- <chmod file="${macosx.app.dir}/${application.name}.app/Contents/Resources/URLHandler.app/Contents/MacOS/URLHandler" perm="+x"/>
-
<property name="macosx.dmg.name"
value="${package.name}-${sip-communicator.version}.dmg"/>
<property name="macosx.dmg.tmpname"
diff --git a/resources/install/generic/installer-generic.xml b/resources/install/generic/installer-generic.xml
index e5f1530..5d173dc 100755
--- a/resources/install/generic/installer-generic.xml
+++ b/resources/install/generic/installer-generic.xml
@@ -13,9 +13,9 @@
<variable name="app-version" value="@VERSION@"/>
<variable name="released-on" value="@BUILDDATE@"/>
- <variable name="HelloPanel2.WelcomeText1" value="@DEVELOPED_BY@"/>
- <variable name="HelloPanel2.WelcomeText2" value="@LINK@"/>
- <variable name="HelloPanel2.PoweredByText" value="@POWERED_BY@"/>
+ <variable name="HelloPanel2.WelcomeText1" value="@WelcomeText1@"/>
+ <variable name="HelloPanel2.WelcomeText2" value="@WelcomeText2@"/>
+ <variable name="HelloPanel2.PoweredByText" value="@WelcomeText3@"/>
</variables>
diff --git a/resources/install/linux/installer-linux.xml b/resources/install/linux/installer-linux.xml
index 1a3df36..cc28fdd 100755
--- a/resources/install/linux/installer-linux.xml
+++ b/resources/install/linux/installer-linux.xml
@@ -13,9 +13,9 @@
<variable name="app-version" value="@VERSION@"/>
<variable name="released-on" value="@BUILDDATE@"/>
- <variable name="HelloPanel2.WelcomeText1" value="@DEVELOPED_BY@"/>
- <variable name="HelloPanel2.WelcomeText2" value="@LINK@"/>
- <variable name="HelloPanel2.PoweredByText" value="@POWERED_BY@"/>
+ <variable name="HelloPanel2.WelcomeText1" value="@WelcomeText1@"/>
+ <variable name="HelloPanel2.WelcomeText2" value="@WelcomeText2@"/>
+ <variable name="HelloPanel2.PoweredByText" value="@WelcomeText3@"/>
</variables>
diff --git a/resources/install/windows/installer-windows.xml b/resources/install/windows/installer-windows.xml
index f26a32f..b91c309 100755
--- a/resources/install/windows/installer-windows.xml
+++ b/resources/install/windows/installer-windows.xml
@@ -13,9 +13,9 @@
<variable name="app-version" value="@VERSION@"/>
<variable name="released-on" value="@BUILDDATE@"/>
- <variable name="HelloPanel2.WelcomeText1" value="@DEVELOPED_BY@"/>
- <variable name="HelloPanel2.WelcomeText2" value="@LINK@"/>
- <variable name="HelloPanel2.PoweredByText" value="@POWERED_BY@"/>
+ <variable name="HelloPanel2.WelcomeText1" value="@WelcomeText1@"/>
+ <variable name="HelloPanel2.WelcomeText2" value="@WelcomeText2@"/>
+ <variable name="HelloPanel2.PoweredByText" value="@WelcomeText3@"/>
</variables>
<guiprefs height="600" resizable="yes" width="800"/>
diff --git a/src/native/macosx/launcharghandler/AEGetURLEventHandler.h b/src/native/macosx/launcharghandler/AEGetURLEventHandler.h
new file mode 100644
index 0000000..c17c1d8
--- /dev/null
+++ b/src/native/macosx/launcharghandler/AEGetURLEventHandler.h
@@ -0,0 +1,32 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+#include <jni.h>
+/* Header for class net_java_sip_communicator_util_launchutils_AEGetURLEventHandler */
+
+#ifndef _Included_net_java_sip_communicator_util_launchutils_AEGetURLEventHandler
+#define _Included_net_java_sip_communicator_util_launchutils_AEGetURLEventHandler
+#ifdef __cplusplus
+extern "C" {
+#endif
+/*
+ * Class: net_java_sip_communicator_util_launchutils_AEGetURLEventHandler
+ * Method: setAEGetURLListener
+ * Signature: (Lnet/java/sip/communicator/util/launchutils/AEGetURLEventHandler/IAEGetURLListener;)V
+ */
+JNIEXPORT void JNICALL Java_net_java_sip_communicator_util_launchutils_AEGetURLEventHandler_setAEGetURLListener
+ (JNIEnv *, jclass, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
+/* Header for class net_java_sip_communicator_util_launchutils_AEGetURLEventHandler_IAEGetURLListener */
+
+#ifndef _Included_net_java_sip_communicator_util_launchutils_AEGetURLEventHandler_IAEGetURLListener
+#define _Included_net_java_sip_communicator_util_launchutils_AEGetURLEventHandler_IAEGetURLListener
+#ifdef __cplusplus
+extern "C" {
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/native/macosx/launcharghandler/AEGetURLEventHandlerAgent.m b/src/native/macosx/launcharghandler/AEGetURLEventHandlerAgent.m
new file mode 100644
index 0000000..029f489
--- /dev/null
+++ b/src/native/macosx/launcharghandler/AEGetURLEventHandlerAgent.m
@@ -0,0 +1,173 @@
+#include "AEGetURLEventHandler.h"
+
+#include <jvmti.h>
+#include <stdlib.h>
+#import <Foundation/Foundation.h>
+
+@interface AEGetURLEventHandler : NSObject
+{
+ jobject _listener;
+ char *_url;
+ JavaVM *_vm;
+}
+
++ (AEGetURLEventHandler *)sharedAEGetURLEventHandler;
+
+- (void)handleAEGetURLEvent:(NSAppleEventDescriptor *)event
+ withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
+- (void)setAEGetURLListener:(jobject)listener jniEnv:(JNIEnv *)jniEnv;
+- (void)setURL:(char *)url;
+- (void)setVM:(JavaVM *)vm;
+- (void)tryFireAEGetURLEvent;
+@end
+
+static AEGetURLEventHandler *g_sharedAEGetURLEventHandler = NULL;
+
+@implementation AEGetURLEventHandler
++ (AEGetURLEventHandler *)sharedAEGetURLEventHandler {
+ if (!g_sharedAEGetURLEventHandler) {
+ g_sharedAEGetURLEventHandler = [[AEGetURLEventHandler alloc] init];
+ }
+ return g_sharedAEGetURLEventHandler;
+}
+
+- (void)dealloc {
+ [self setURL:NULL];
+ [self setAEGetURLListener:NULL jniEnv:NULL];
+
+ [super dealloc];
+}
+
+- (void)handleAEGetURLEvent:(NSAppleEventDescriptor *)event
+ withReplyEvent:(NSAppleEventDescriptor *)replyEvent {
+ NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];
+ NSString *str;
+
+ str = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
+ if (str) {
+ const NSStringEncoding encoding = NSNonLossyASCIIStringEncoding;
+ NSUInteger length;
+ char *chars;
+
+ length = [str lengthOfBytesUsingEncoding:encoding];
+ if (length) {
+ length++; // Account for the NULL termination byte.
+ chars = (char *) malloc (length * sizeof (char));
+ if (chars
+ && (YES == [str getCString:chars maxLength:length encoding:encoding])) {
+ [[AEGetURLEventHandler sharedAEGetURLEventHandler]
+ setURL:chars];
+ } else {
+ free (chars);
+ }
+ }
+ }
+
+ [autoreleasePool release];
+}
+
+- (AEGetURLEventHandler *)init {
+ self = [super init];
+ if (self) {
+ _listener = NULL;
+ _url = NULL;
+ _vm = NULL;
+ }
+ return self;
+}
+
+- (void)setAEGetURLListener:(jobject)listener jniEnv:(JNIEnv *)jniEnv {
+ if (!jniEnv
+ && (!_vm || (JNI_OK != (*_vm)->GetEnv (_vm, (void **) &jniEnv, JNI_VERSION_1_2)))) {
+ return; // TODO Don't swallow the failure.
+ }
+
+ if (_listener) {
+ (*jniEnv)->DeleteGlobalRef (jniEnv, _listener);
+ _listener = NULL;
+ }
+ if (listener) {
+ _listener = (*jniEnv)->NewGlobalRef (jniEnv, listener);
+
+ [self tryFireAEGetURLEvent];
+ }
+}
+
+- (void)setURL:(char *)url {
+ if (_url != url) {
+ if (_url) {
+ free (_url);
+ }
+
+ _url = url;
+
+ [self tryFireAEGetURLEvent];
+ }
+}
+
+- (void)setVM:(JavaVM *)vm {
+ _vm = vm;
+}
+
+- (void)tryFireAEGetURLEvent {
+ JNIEnv *jniEnv;
+
+ if (_vm
+ && _listener
+ && _url
+ && (JNI_OK == (*_vm)->GetEnv (_vm, (void **) &jniEnv, JNI_VERSION_1_2))) {
+ jclass clazz = (*jniEnv)->GetObjectClass (jniEnv, _listener);
+ jmethodID methodID =
+ (*jniEnv)->GetMethodID (
+ jniEnv, clazz, "handleAEGetURLEvent", "(Ljava/lang/String;)V");
+
+ if (methodID) {
+ jstring url = (*jniEnv)->NewStringUTF (jniEnv, _url);
+
+ if (url) {
+ (*jniEnv)->CallVoidMethod (jniEnv, _listener, methodID, url);
+
+ /*
+ * The URL should not be reported again after it has been
+ * handled.
+ */
+ [self setURL:NULL];
+ }
+ }
+ }
+}
+@end
+
+JNIEXPORT jint JNICALL
+Agent_OnLoad (JavaVM *vm, char *options, void *reserved) {
+ NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];
+ AEGetURLEventHandler *aeGetURLEventHandler
+ = [AEGetURLEventHandler sharedAEGetURLEventHandler];
+
+ [aeGetURLEventHandler setVM:vm];
+
+ [[NSAppleEventManager sharedAppleEventManager]
+ setEventHandler:aeGetURLEventHandler
+ andSelector:@selector(handleAEGetURLEvent:withReplyEvent:)
+ forEventClass:kInternetEventClass
+ andEventID:kAEGetURL];
+
+ [autoreleasePool release];
+
+ /*
+ * Non-zero will terminate the VM and we don't want that even if we fail to
+ * install the event handler.
+ */
+ return 0;
+}
+
+JNIEXPORT void JNICALL
+Java_net_java_sip_communicator_util_launchutils_AEGetURLEventHandler_setAEGetURLListener
+ (JNIEnv *jniEnv, jclass clazz, jobject listener) {
+ NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];
+
+ [[AEGetURLEventHandler sharedAEGetURLEventHandler]
+ setAEGetURLListener:listener jniEnv:jniEnv];
+
+ [autoreleasePool release];
+}
diff --git a/src/native/macosx/launcharghandler/Makefile b/src/native/macosx/launcharghandler/Makefile
new file mode 100644
index 0000000..86c1e8c
--- /dev/null
+++ b/src/native/macosx/launcharghandler/Makefile
@@ -0,0 +1,20 @@
+# Author: Damian Minkov
+# javah -classpath ../../../../classes/ -o AEGetURLEventHandler.h net.java.sip.communicator.util.launchutils.AEGetURLEventHandler
+
+CC=gcc
+TARGET=libAEGetURLEventHandlerAgent.jnilib
+JNI_INCLUDE_PATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Headers/
+CFLAGS=-I$(JNI_INCLUDE_PATH)
+LIBS=-framework Foundation
+OBJS=AEGetURLEventHandlerAgent.o
+
+all:$(TARGET)
+
+clean:
+ rm -rf $(TARGET) $(OBJS) *~
+
+install:$(TARGET)
+ cp $(TARGET) ../../../../lib/native/mac/
+
+libAEGetURLEventHandlerAgent.jnilib:$(OBJS)
+ $(CC) -dynamiclib -o $(TARGET) $(LIBS) $(CFLAGS) $<
diff --git a/src/net/java/sip/communicator/util/launchutils/AEGetURLEventHandler.java b/src/net/java/sip/communicator/util/launchutils/AEGetURLEventHandler.java
new file mode 100644
index 0000000..503f47c
--- /dev/null
+++ b/src/net/java/sip/communicator/util/launchutils/AEGetURLEventHandler.java
@@ -0,0 +1,62 @@
+/*
+ * SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+
+package net.java.sip.communicator.util.launchutils;
+
+/**
+ * Registers as listener for Apple Event GURL.
+ * And will handle any url comming from the os by passing it to LaunchArgHandler.
+ *
+ * @author Lubomir Marinov
+ * @author Damian Minkov
+ */
+public class AEGetURLEventHandler
+{
+ private LaunchArgHandler launchArgHandler;
+
+ /**
+ * The interface for the used callback.
+ */
+ public interface IAEGetURLListener
+ {
+ void handleAEGetURLEvent (String url);
+ }
+
+ AEGetURLEventHandler(LaunchArgHandler launchArgHandler)
+ {
+ this.launchArgHandler = launchArgHandler;
+
+ setAEGetURLListener (new IAEGetURLListener ()
+ {
+ public void handleAEGetURLEvent (final String url)
+ {
+ new Thread()
+ {
+ public void run()
+ {
+ AEGetURLEventHandler.this.launchArgHandler.
+ handleArgs(new String[]{url});
+ }
+ }.start();
+ }
+ });
+ }
+
+ /**
+ * Sets the (global) listener for kAEGetURL AppleScript events.
+ * <p>
+ * The listener should be prepared to handle any pending events before this
+ * method returns because such events may have already been sent by the
+ * operating system (e.g. when the application wasn't running and was
+ * started in order to handle such an event).
+ * </p>
+ *
+ * @param listener the {@link IAEGetURLListener} to be set as the (global)
+ * listener for kAEGetURL AppleScript events
+ */
+ private static native void setAEGetURLListener (IAEGetURLListener listener);
+}
diff --git a/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java b/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java
index 8cecc3c..372220b 100644
--- a/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java
+++ b/src/net/java/sip/communicator/util/launchutils/LaunchArgHandler.java
@@ -132,6 +132,13 @@ public class LaunchArgHandler
{
versionProperties.load(
getClass().getResourceAsStream(VERSION_PROPERTIES));
+
+ // start url handler for mac os.
+ String osName = System.getProperty("os.name");
+ if (osName.startsWith("Mac"))
+ {
+ new AEGetURLEventHandler(this);
+ }
}
catch(IOException exc)
{