blob: 97aeec7a3dad21f210161dbdb0009e3680772245 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
/*
* 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.util.launchutils;
/**
* Registers as listener for kAEGetURL AppleScript events.
* And will handle any url coming 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
{
/**
* Handle the URL event.
*
* @param url the URL
*/
void handleAEGetURLEvent (String url);
}
AEGetURLEventHandler(LaunchArgHandler launchArgHandler)
{
this.launchArgHandler = launchArgHandler;
try
{
setAEGetURLListener (new IAEGetURLListener ()
{
public void handleAEGetURLEvent (final String url)
{
new Thread()
{
@Override
public void run()
{
AEGetURLEventHandler.this.launchArgHandler.
handleArgs(new String[]{url});
}
}.start();
}
});
}
catch(Throwable err)
{
//we don't have logging here so dump to stderr
System.err.println(
"Warning: Failed to register our command line argument"
+ " handler. We won't be able to handle command line"
+ " arguments.");
err.printStackTrace();
}
}
/**
* 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);
}
|