blob: 8b0bee933490abcd5d47f0198f10eca887f418d9 (
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
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
|
/*
* 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.gui.*;
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 AccountInfoForm
extends TransparentPanel
implements ConfigurationForm
{
/**
* The right side of the AccountInfo frame that contains protocol specific
* account details.
*/
private AccountDetailsPanel detailsPanel;
private JTabbedPane accountsTabbedPane = new SIPCommTabbedPane(false, false);
private Hashtable<ProtocolProviderService, AccountDetailsPanel>
accountsTable = new Hashtable();
/**
* 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 AccountInfoForm()
{
super(new BorderLayout());
Set set = AccountInfoActivator.getProtocolProviderFactories().entrySet();
Iterator iter = set.iterator();
boolean hasRegisteredAccounts = false;
while (iter.hasNext())
{
Map.Entry entry = (Map.Entry) iter.next();
ProtocolProviderFactory providerFactory
= (ProtocolProviderFactory) entry.getValue();
ArrayList accountsList = providerFactory.getRegisteredAccounts();
AccountID accountID;
ServiceReference serRef;
ProtocolProviderService protocolProvider;
for (int i = 0; i < accountsList.size(); i++)
{
accountID = (AccountID) accountsList.get(i);
boolean isHidden =
accountID
.getAccountProperty(ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null;
if(!isHidden)
hasRegisteredAccounts = true;
serRef = providerFactory.getProviderForAccount(accountID);
protocolProvider = (ProtocolProviderService) AccountInfoActivator
.bundleContext.getService(serRef);
detailsPanel = new AccountDetailsPanel(protocolProvider);
accountsTable.put(protocolProvider, detailsPanel);
protocolProvider.addRegistrationStateChangeListener(
new RegistrationStateChangeListenerImpl());
this.accountsTabbedPane.addTab(
accountID.getUserID(), detailsPanel);
}
}
this.add(accountsTabbedPane, BorderLayout.CENTER);
}
/**
* Returns the title of this configuration form.
*
* @return the icon of this configuration form.
*/
public String getTitle()
{
return Resources.getString("plugin.accountinfo.TITLE");
}
/**
* Returns the icon of this configuration form.
*
* @return the icon of this configuration form.
*/
public byte[] getIcon()
{
return Resources.getImageInBytes("plugin.accountinfo.PLUGIN_ICON");
}
/**
* Returns the form of this configuration form.
*
* @return the form of this configuration form.
*/
public Object getForm()
{
return this;
}
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();
}
}
}
}
public int getIndex()
{
return -1;
}
}
|