blob: 47c77b630f2175f2c9d79e57dbf88c7ab48b9cd0 (
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
|
package net.java.sip.communicator.plugin.otr;
import java.awt.*;
import java.util.*;
import javax.swing.table.*;
import net.java.sip.communicator.service.contactlist.*;
import net.java.sip.communicator.service.protocol.*;
import org.osgi.framework.*;
/**
* A special {@link Panel} for fingerprints display.
*
* @author George Politis
* @author Yana Stamcheva
*/
public class KnownFingerprintsTableModel
extends AbstractTableModel
{
public static final int CONTACTNAME_INDEX = 0;
public static final int VERIFIED_INDEX = 1;
public static final int FINGERPRINT_INDEX = 2;
public final java.util.List<Contact> allContacts = new Vector<Contact>();
public KnownFingerprintsTableModel()
{
// Get the protocolproviders
ServiceReference[] protocolProviderRefs = null;
try
{
protocolProviderRefs =
OtrActivator.bundleContext
.getServiceReferences(
ProtocolProviderService.class.getName(), null);
}
catch (InvalidSyntaxException ex)
{
return;
}
if (protocolProviderRefs == null
|| protocolProviderRefs.length < 1)
return;
// Get the metacontactlist service.
ServiceReference ref =
OtrActivator.bundleContext
.getServiceReference(MetaContactListService.class
.getName());
MetaContactListService service
= (MetaContactListService) OtrActivator
.bundleContext.getService(ref);
// Populate contacts.
for (int i = 0; i < protocolProviderRefs.length; i++)
{
ProtocolProviderService provider
= (ProtocolProviderService) OtrActivator
.bundleContext
.getService(protocolProviderRefs[i]);
Iterator<MetaContact> metaContacts =
service.findAllMetaContactsForProvider(provider);
while (metaContacts.hasNext())
{
MetaContact metaContact = metaContacts.next();
Iterator<Contact> contacts = metaContact.getContacts();
while (contacts.hasNext())
{
allContacts.add(contacts.next());
}
}
}
}
/**
* Implements AbstractTableModel#getColumnName(int).
*/
public String getColumnName(int column)
{
switch (column)
{
case CONTACTNAME_INDEX:
return OtrActivator.resourceService
.getI18NString(
"plugin.otr.configform.COLUMN_NAME_CONTACT");
case VERIFIED_INDEX:
return OtrActivator.resourceService
.getI18NString(
"plugin.otr.configform.COLUMN_NAME_VERIFIED_STATUS");
case FINGERPRINT_INDEX:
return OtrActivator.resourceService
.getI18NString(
"plugin.otr.configform.FINGERPRINT");
default:
return null;
}
}
/**
* Implements AbstractTableModel#getValueAt(int,int).
*/
public Object getValueAt(int row, int column)
{
if (row < 0)
return null;
Contact contact = allContacts.get(row);
switch (column)
{
case CONTACTNAME_INDEX:
return contact.getDisplayName();
case VERIFIED_INDEX:
// TODO: Maybe use a CheckBoxColumn?
return (OtrActivator.scOtrKeyManager
.isVerified(contact))
? OtrActivator.resourceService.getI18NString(
"plugin.otr.configform.COLUMN_VALUE_VERIFIED_TRUE")
: OtrActivator.resourceService.getI18NString(
"plugin.otr.configform.COLUMN_VALUE_VERIFIED_FALSE");
case FINGERPRINT_INDEX:
return OtrActivator.scOtrKeyManager
.getRemoteFingerprint(contact);
default:
return null;
}
}
/**
* Implements AbstractTableModel#getRowCount().
*/
public int getRowCount()
{
return allContacts.size();
}
/**
* Implements AbstractTableModel#getColumnCount().
*/
public int getColumnCount()
{
return 3;
}
}
|