blob: 1bfd6b079eb8677a510ba06678e594bcb02ccefc (
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
/*
* 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.impl.argdelegation;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.util.*;
import net.java.sip.communicator.util.launchutils.*;
import org.osgi.framework.*;
//import com.apple.eawt.AppEvent.*;
import com.apple.eawt.*;
/**
* Activates the <tt>ArgDelegationService</tt> and registers a URI delegation
* peer with the util package arg manager so that we would be notified when the
* application receives uri arguments.
*
* @author Emil Ivov
*/
public class ArgDelegationActivator
implements BundleActivator
{
/**
* A reference to the bundle context that is currently in use.
*/
private static BundleContext bundleContext = null;
/**
* A reference to the delegation peer implementation that is currently
* handling uri arguments.
*/
private ArgDelegationPeerImpl delegationPeer = null;
/**
* A reference to the <tt>UIService</tt> currently in use in
* SIP Communicator.
*/
private static UIService uiService = null;
/**
* Starts the arg delegation bundle and registers the delegationPeer with
* the util package URI manager.
*
* @param bc a reference to the currently active bundle context.
* @throws Exception if starting the arg delegation bundle and registering
* the delegationPeer with the util package URI manager fails
*/
public void start(BundleContext bc) throws Exception
{
bundleContext = bc;
delegationPeer = new ArgDelegationPeerImpl(bc);
bc.addServiceListener(delegationPeer);
//register our instance of delegation peer.
LaunchArgHandler.getInstance().setDelegationPeer(delegationPeer);
if(OSUtils.IS_MAC)
{
Application application = Application.getApplication();
if(application != null)
{
// application.setOpenURIHandler(new OpenURIHandler() {
//
// public void openURI(OpenURIEvent evt)
// {
// delegationPeer.handleUri(evt.getURI().toString());
// }
// });
}
}
}
/**
* Unsets the delegation peer instance that we set when we start this
* bundle.
*
* @param bc an instance of the currently valid bundle context.
* @throws Exception if unsetting the delegation peer instance that we set
* when we start this bundle fails
*/
public void stop(BundleContext bc) throws Exception
{
uiService = null;
bc.removeServiceListener(delegationPeer);
delegationPeer = null;
LaunchArgHandler.getInstance().setDelegationPeer(null);
}
/**
* Returns a reference to an UIService implementation currently registered
* in the bundle context or null if no such implementation was found.
*
* @return a reference to an UIService implementation currently registered
* in the bundle context or null if no such implementation was found.
*/
public static UIService getUIService()
{
if(uiService == null)
uiService = ServiceUtils.getService(bundleContext, UIService.class);
return uiService;
}
}
|