blob: 02e4b0a39f6d33a18cf47eb27d32f5f4123a2540 (
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
|
/*
* 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.plugin.accountinfo;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.swing.*;
import org.osgi.framework.*;
/**
* A GUI plug-in for SIP Communicator that will allow users to set cross
* protocol account information.
*
* @author Adam Goldstein
*/
public class AccountInfoPanel
extends TransparentPanel
{
/**
* The right side of the AccountInfo frame that contains protocol specific
* account details.
*/
private AccountDetailsPanel detailsPanel;
private final Map<ProtocolProviderService, AccountDetailsPanel> accountsTable =
new Hashtable<ProtocolProviderService, AccountDetailsPanel>();
/**
* Constructs a frame with an AccuontInfoAccountPanel to display all
* registered accounts on the left, and an information interface,
* AccountDetailsPanel, on the right.
*
* @param metaContact
*/
public AccountInfoPanel()
{
super(new BorderLayout());
JTabbedPane accountsTabbedPane = new SIPCommTabbedPane(false, false);
for (ProtocolProviderFactory providerFactory : AccountInfoActivator
.getProtocolProviderFactories().values())
{
ArrayList<AccountID> accountsList =
providerFactory.getRegisteredAccounts();
ServiceReference serRef;
ProtocolProviderService protocolProvider;
for (AccountID accountID : accountsList)
{
serRef = providerFactory.getProviderForAccount(accountID);
protocolProvider = (ProtocolProviderService) AccountInfoActivator
.bundleContext.getService(serRef);
detailsPanel = new AccountDetailsPanel(protocolProvider);
accountsTable.put(protocolProvider, detailsPanel);
protocolProvider.addRegistrationStateChangeListener(
new RegistrationStateChangeListenerImpl());
accountsTabbedPane.addTab(
accountID.getUserID(), detailsPanel);
}
}
this.add(accountsTabbedPane, BorderLayout.CENTER);
}
private class RegistrationStateChangeListenerImpl
implements RegistrationStateChangeListener
{
public void registrationStateChanged(RegistrationStateChangeEvent evt)
{
ProtocolProviderService protocolProvider = evt.getProvider();
if (protocolProvider.getOperationSet(
OperationSetServerStoredAccountInfo.class) != null
&& evt.getNewState() == RegistrationState.REGISTERED)
{
if (accountsTable.containsKey(protocolProvider))
{
AccountDetailsPanel detailsPanel
= accountsTable.get(protocolProvider);
if(!detailsPanel.isDataLoaded())
detailsPanel.loadDetails();
}
}
}
}
}
|