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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
/*
* 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.impl.globaldisplaydetails;
import net.java.sip.communicator.service.globaldisplaydetails.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.globalstatus.*;
import net.java.sip.communicator.util.*;
import org.jitsi.service.configuration.*;
import org.jitsi.service.resources.*;
import org.osgi.framework.*;
/**
*
* @author Yana Stamcheva
*/
public class GlobalDisplayDetailsActivator
implements BundleActivator,
ServiceListener
{
/**
* The bundle context.
*/
private static BundleContext bundleContext;
/**
* The service giving access to image and string application resources.
*/
private static ResourceManagementService resourcesService;
/**
* The service giving access to the configuration resources.
*/
private static ConfigurationService configService;
/**
* The alert UI service.
*/
private static AlertUIService alertUIService;
/**
* The UI service.
*/
private static UIService uiService;
/**
* The display details implementation.
*/
static GlobalDisplayDetailsImpl displayDetailsImpl;
/**
* Initialize and start file service
*
* @param bc the <tt>BundleContext</tt>
* @throws Exception if initializing and starting file service fails
*/
public void start(BundleContext bc)
throws Exception
{
bundleContext = bc;
displayDetailsImpl = new GlobalDisplayDetailsImpl();
bundleContext.addServiceListener(this);
bundleContext.registerService(
GlobalDisplayDetailsService.class.getName(),
displayDetailsImpl,
null);
bundleContext.registerService(
GlobalStatusService.class.getName(),
new GlobalStatusServiceImpl(),
null);
}
/**
* Stops this bundle.
*
* @param bundleContext the <tt>BundleContext</tt>
* @throws Exception if the stop operation goes wrong
*/
public void stop(BundleContext bundleContext)
throws Exception
{
}
/**
* Returns the <tt>ResourceManagementService</tt>, through which we will
* access all resources.
*
* @return the <tt>ResourceManagementService</tt>, through which we will
* access all resources.
*/
public static ResourceManagementService getResources()
{
if (resourcesService == null)
{
resourcesService
= ServiceUtils.getService(
bundleContext,
ResourceManagementService.class);
}
return resourcesService;
}
/**
* Returns the <tt>ConfigurationService</tt> obtained from the bundle
* context.
* @return the <tt>ConfigurationService</tt> obtained from the bundle
* context
*/
public static ConfigurationService getConfigurationService()
{
if(configService == null)
{
configService
= ServiceUtils.getService(
bundleContext,
ConfigurationService.class);
}
return configService;
}
/**
* Returns the <tt>AlertUIService</tt> obtained from the bundle
* context.
* @return the <tt>AlertUIService</tt> obtained from the bundle
* context
*/
public static AlertUIService getAlertUIService()
{
if(alertUIService == null)
{
alertUIService
= ServiceUtils.getService(
bundleContext,
AlertUIService.class);
}
return alertUIService;
}
/**
* Returns the <tt>UIService</tt> obtained from the bundle
* context.
* @return the <tt>UIService</tt> obtained from the bundle
* context
*/
public static UIService getUIService()
{
if(uiService == null)
{
uiService
= ServiceUtils.getService(
bundleContext,
UIService.class);
}
return uiService;
}
/**
* Implements the <tt>ServiceListener</tt> method. Verifies whether the
* passed event concerns a <tt>ProtocolProviderService</tt> and adds or
* removes a registration listener.
*
* @param event The <tt>ServiceEvent</tt> object.
*/
public void serviceChanged(ServiceEvent event)
{
ServiceReference serviceRef = event.getServiceReference();
// if the event is caused by a bundle being stopped, we don't want to
// know
if (serviceRef.getBundle().getState() == Bundle.STOPPING)
{
return;
}
Object service
= UtilActivator.bundleContext.getService(serviceRef);
// we don't care if the source service is not a protocol provider
if (!(service instanceof ProtocolProviderService))
{
return;
}
switch (event.getType())
{
case ServiceEvent.REGISTERED:
((ProtocolProviderService) service)
.addRegistrationStateChangeListener(displayDetailsImpl);
break;
case ServiceEvent.UNREGISTERING:
((ProtocolProviderService) service)
.removeRegistrationStateChangeListener(displayDetailsImpl);
break;
}
}
}
|