1) Updated to latest smack.

2) Fixed conference room issue.

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@6878 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2007-01-30 23:57:27 +00:00
committed by derek
parent f441736a39
commit 623dea61ec
19 changed files with 217 additions and 308 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -12,11 +12,13 @@ package org.jivesoftware;
import org.jivesoftware.resource.Res;
import org.jivesoftware.smack.AccountManager;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.packet.XMPPError;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.spark.component.TitlePanel;
import org.jivesoftware.spark.util.DummySSLSocketFactory;
import org.jivesoftware.spark.util.ModelUtil;
import org.jivesoftware.spark.util.ResourceUtils;
import org.jivesoftware.spark.util.SwingWorker;
@ -252,7 +254,7 @@ public class AccountCreationWizard extends JPanel {
private XMPPConnection getConnection() throws XMPPException {
LocalPreferences localPref = SettingsManager.getLocalPreferences();
XMPPConnection con;
XMPPConnection con = null;
// Get connection
@ -272,21 +274,34 @@ public class AccountCreationWizard extends JPanel {
boolean useSSL = localPref.isSSL();
boolean hostPortConfigured = localPref.isHostAndPortConfigured();
ConnectionConfiguration config = null;
if (useSSL) {
if (!hostPortConfigured) {
con = new XMPPConnection(serverName);
config = new ConnectionConfiguration(serverName, 5223);
config.setSocketFactory(new DummySSLSocketFactory());
}
else {
con = new XMPPConnection(localPref.getXmppHost(), port, serverName);
config = new ConnectionConfiguration(localPref.getXmppHost(), port, serverName);
config.setSocketFactory(new DummySSLSocketFactory());
}
}
else {
if (!hostPortConfigured) {
con = new XMPPConnection(serverName);
config = new ConnectionConfiguration(serverName);
}
else {
con = new XMPPConnection(localPref.getXmppHost(), port, serverName);
config = new ConnectionConfiguration(localPref.getXmppHost(), port, serverName);
}
}
if (config != null) {
config.setReconnectionAllowed(true);
boolean compressionEnabled = localPref.isCompressionEnabled();
config.setCompressionEnabled(compressionEnabled);
con = new XMPPConnection(config);
}
if (con != null) {

View File

@ -28,6 +28,7 @@ import org.jivesoftware.spark.SessionManager;
import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.Workspace;
import org.jivesoftware.spark.component.RolloverButton;
import org.jivesoftware.spark.util.DummySSLSocketFactory;
import org.jivesoftware.spark.util.Encryptor;
import org.jivesoftware.spark.util.GraphicUtils;
import org.jivesoftware.spark.util.ModelUtil;
@ -36,7 +37,6 @@ import org.jivesoftware.spark.util.SwingWorker;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.sparkimpl.plugin.layout.LayoutSettings;
import org.jivesoftware.sparkimpl.plugin.layout.LayoutSettingsManager;
import org.jivesoftware.sparkimpl.settings.SSLXMPPConnection;
import org.jivesoftware.sparkimpl.settings.local.LocalPreferences;
import org.jivesoftware.sparkimpl.settings.local.SettingsManager;
@ -578,10 +578,12 @@ public final class LoginDialog {
if (useSSL) {
if (!hostPortConfigured) {
connection = new SSLXMPPConnection(serverName);
config = new ConnectionConfiguration(serverName, 5223);
config.setSocketFactory(new DummySSLSocketFactory());
}
else {
connection = new SSLXMPPConnection(localPref.getXmppHost(), port, serverName);
config = new ConnectionConfiguration(localPref.getXmppHost(), port, serverName);
config.setSocketFactory(new DummySSLSocketFactory());
}
}
else {
@ -720,17 +722,17 @@ public final class LoginDialog {
int height = settings.getMainWindowHeight();
LocalPreferences pref = SettingsManager.getLocalPreferences();
if(pref.isDockingEnabled()) {
if (pref.isDockingEnabled()) {
JSplitPane splitPane = mainWindow.getSplitPane();
workspace.getCardPanel().setMinimumSize(null);
splitPane.setLeftComponent(workspace.getCardPanel());
SparkManager.getChatManager().getChatContainer().setMinimumSize(null);
splitPane.setRightComponent(SparkManager.getChatManager().getChatContainer());
int dividerLoc = settings.getSplitPaneDividerLocation();
if (dividerLoc != -1){
if (dividerLoc != -1) {
mainWindow.getSplitPane().setDividerLocation(dividerLoc);
}
else{
else {
mainWindow.getSplitPane().setDividerLocation(240);
}
@ -874,7 +876,7 @@ public final class LoginDialog {
// Delete settings File
settingsXML.delete();
}
}
}

View File

@ -289,7 +289,7 @@ public final class Spark {
}
public static void installBaseUIProperties() {
UIManager.put("TextField.lightforeground", Color.lightGray);
UIManager.put("TextField.lightforeground", Color.gray);
UIManager.put("TextField.foreground", Color.BLACK);
UIManager.put("TextField.caretForeground", Color.black);

View File

@ -10,8 +10,8 @@
package org.jivesoftware.spark.component;
import org.jivesoftware.spark.util.GraphicUtils;
import org.jdesktop.swingx.JXTable;
import org.jivesoftware.spark.util.GraphicUtils;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
@ -46,7 +46,7 @@ import java.util.Map;
* @version 1.0, 03/12/14
*/
public abstract class Table extends JXTable {
private Table.JiveTableModel tableModel;
/**
* Define the color of row and column selections.
@ -114,9 +114,8 @@ public abstract class Table extends JXTable {
*
* @param headers the table headers to use.
*/
protected Table(String[] headers) {
tableModel = new Table.JiveTableModel(headers, 0, false);
setModel(tableModel);
protected Table(Object[] headers) {
((DefaultTableModel)getModel()).setColumnIdentifiers(headers);
// Handle JDK 1.5 bug with preferred size on table headers.
JTableHeader header = getTableHeader();
@ -150,6 +149,16 @@ public abstract class Table extends JXTable {
});
}
public void setValueAt(Object object, int i, int i1) {
getModel().setValueAt(object, i, i1);
}
public Object getValueAt(int i, int i1) {
return getModel().getValueAt(i, i1);
}
public Component prepareRenderer(TableCellRenderer renderer,
int rowIndex, int vColIndex) {
Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
@ -177,7 +186,7 @@ public abstract class Table extends JXTable {
final Iterator iter = list.iterator();
while (iter.hasNext()) {
Object[] newRow = (Object[])iter.next();
tableModel.addRow(newRow);
((DefaultTableModel)getModel()).addRow(newRow);
}
}
@ -190,6 +199,14 @@ public abstract class Table extends JXTable {
return getRowObject(getSelectedRow());
}
public void addRow(Object[] row) {
((DefaultTableModel)getModel()).addRow(row);
}
public void removeRow(int row) {
((DefaultTableModel)getModel()).removeRow(row);
}
/**
* Returns the object[] of a row.
*
@ -205,7 +222,7 @@ public abstract class Table extends JXTable {
Object[] obj = new Object[columnCount];
for (int j = 0; j < columnCount; j++) {
Object objs = tableModel.getValueAt(selectedRow, j);
Object objs = getModel().getValueAt(selectedRow, j);
obj[j] = objs;
}
@ -218,7 +235,7 @@ public abstract class Table extends JXTable {
public void clearTable() {
int rowCount = getRowCount();
for (int i = 0; i < rowCount; i++) {
getTableModel().removeRow(0);
((DefaultTableModel)getModel()).removeRow(0);
}
}
@ -426,15 +443,6 @@ public abstract class Table extends JXTable {
}
}
/**
* Returns the table model.
*
* @return the table model.
*/
public Table.JiveTableModel getTableModel() {
return tableModel;
}
/**
* Clears all objects from map.
*/

View File

@ -334,7 +334,7 @@ public class ContactItem extends JPanel {
getNicknameLabel().setForeground((Color)UIManager.get("ContactItemOffline.color"));
RosterEntry entry = SparkManager.getConnection().getRoster().getEntry(getFullJID());
if (entry != null && (entry.getType() == RosterPacket.ItemType.NONE || entry.getType() == RosterPacket.ItemType.FROM)
if (entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
// Do not move out of group.
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, 11));
@ -363,7 +363,7 @@ public class ContactItem extends JPanel {
getNicknameLabel().setForeground((Color)UIManager.get("ContactItemOffline.color"));
RosterEntry entry = SparkManager.getConnection().getRoster().getEntry(getFullJID());
if (entry != null && (entry.getType() == RosterPacket.ItemType.NONE || entry.getType() == RosterPacket.ItemType.FROM)
if (entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
// Do not move out of group.
setIcon(SparkRes.getImageIcon(SparkRes.SMALL_QUESTION));
@ -453,7 +453,7 @@ public class ContactItem extends JPanel {
getNicknameLabel().setForeground((Color)UIManager.get("ContactItemOffline.color"));
RosterEntry entry = SparkManager.getConnection().getRoster().getEntry(getFullJID());
if (entry != null && (entry.getType() == RosterPacket.ItemType.NONE || entry.getType() == RosterPacket.ItemType.FROM)
if (entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
// Do not move out of group.
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, 11));
@ -483,7 +483,7 @@ public class ContactItem extends JPanel {
getNicknameLabel().setForeground((Color)UIManager.get("ContactItemOffline.color"));
RosterEntry entry = SparkManager.getConnection().getRoster().getEntry(getFullJID());
if (entry != null && (entry.getType() == RosterPacket.ItemType.NONE || entry.getType() == RosterPacket.ItemType.FROM)
if (entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
// Do not move out of group.
getNicknameLabel().setFont(new Font("Dialog", Font.PLAIN, 11));

View File

@ -254,7 +254,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
final String bareJID = StringUtils.parseBareAddress(presence.getFrom());
RosterEntry entry = roster.getEntry(bareJID);
boolean isPending = entry != null && (entry.getType() == RosterPacket.ItemType.NONE || entry.getType() == RosterPacket.ItemType.FROM)
boolean isPending = entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus();
// If online, check to see if they are in the offline group.
@ -417,7 +417,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
ContactItem contactItem = new ContactItem(name, entry.getUser());
contactItem.setPresence(null);
if ((entry.getType() == RosterPacket.ItemType.NONE || entry.getType() == RosterPacket.ItemType.FROM)
if ((entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
// Add to contact group.
contactGroup.addContactItem(contactItem);
@ -484,7 +484,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
newContactItem.setPresence(presence);
if (entry != null && (entry.getType() == RosterPacket.ItemType.NONE || entry.getType() == RosterPacket.ItemType.FROM)) {
if (entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)) {
// Ignore, since the new user is pending to be added.
for (RosterGroup group : entry.getGroups()) {
ContactGroup contactGroup = getContactGroup(group.getName());
@ -492,7 +492,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
contactGroup = addContactGroup(group.getName());
}
boolean isPending = entry != null && (entry.getType() == RosterPacket.ItemType.NONE || entry.getType() == RosterPacket.ItemType.FROM)
boolean isPending = entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus();
if (isPending) {
contactGroup.setVisible(true);
@ -617,7 +617,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
item.setPresence(presence);
updateUserPresence(presence);
if (entry != null && (entry.getType() == RosterPacket.ItemType.NONE || entry.getType() == RosterPacket.ItemType.FROM)
if (entry != null && (entry.getType() == RosterPacket.ItemType.none || entry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == entry.getStatus()) {
contactGroup.setVisible(true);
@ -661,7 +661,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
else {
ContactItem offlineItem = offlineGroup.getContactItemByJID(jid);
if (offlineItem != null) {
if ((rosterEntry.getType() == RosterPacket.ItemType.NONE || rosterEntry.getType() == RosterPacket.ItemType.FROM)
if ((rosterEntry.getType() == RosterPacket.ItemType.none || rosterEntry.getType() == RosterPacket.ItemType.from)
&& RosterPacket.ItemStatus.SUBSCRIPTION_PENDING == rosterEntry.getStatus()) {
// Remove from offlineItem and add to unfiledItem.
offlineGroup.removeContactItem(offlineItem);
@ -1335,7 +1335,7 @@ public final class ContactList extends JPanel implements ActionListener, Contact
Roster roster = SparkManager.getConnection().getRoster();
RosterEntry entry = roster.getEntry(item.getFullJID());
if (entry != null && entry.getType() == RosterPacket.ItemType.FROM) {
if (entry != null && entry.getType() == RosterPacket.ItemType.from) {
popup.add(subscribeAction);
}

View File

@ -15,9 +15,7 @@ import org.jivesoftware.smack.RosterEntry;
import org.jivesoftware.smack.RosterGroup;
import org.jivesoftware.smack.RosterListener;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.spark.util.GraphicUtils;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
@ -27,7 +25,6 @@ import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.util.Collection;
import java.util.Iterator;
public class NewRoster extends JPanel implements RosterListener {
@ -78,7 +75,7 @@ public class NewRoster extends JPanel implements RosterListener {
roster.addRosterListener(this);
for(RosterGroup group : roster.getGroups()){
for (RosterGroup group : roster.getGroups()) {
// Create Group node.
final RosterNode groupNode = new RosterNode(group.getName(), true);
@ -86,7 +83,7 @@ public class NewRoster extends JPanel implements RosterListener {
rootNode.add(groupNode);
}
for(RosterEntry entry : group.getEntries()){
for (RosterEntry entry : group.getEntries()) {
String nickname = entry.getName();
if (nickname == null) {
nickname = entry.getUser();
@ -105,7 +102,7 @@ public class NewRoster extends JPanel implements RosterListener {
rootNode.add(unfiledGroup);
// Add Unfiled Group
for(RosterEntry entry : roster.getUnfiledEntries()){
for (RosterEntry entry : roster.getUnfiledEntries()) {
String name = entry.getName();
if (name == null) {
name = entry.getUser();
@ -134,19 +131,4 @@ public class NewRoster extends JPanel implements RosterListener {
public void presenceChanged(String XMPPAddress) {
}
public static void main(String args[]) throws Exception {
final XMPPConnection con = new XMPPConnection("jivesoftware.com", 5222);
con.login("agent", "agent");
final JFrame frame = new JFrame();
frame.getContentPane().setLayout(new BorderLayout());
NewRoster roster = new NewRoster();
frame.getContentPane().add(roster);
frame.pack();
frame.setSize(600, 400);
GraphicUtils.centerWindowOnScreen(frame);
frame.setVisible(true);
roster.buildContactList(con);
}
}

View File

@ -157,7 +157,7 @@ public class SubscriptionDialog {
// If User is already in roster, do not show.
RosterEntry entry = roster.getEntry(jid);
if (entry != null && entry.getType() == RosterPacket.ItemType.TO) {
if (entry != null && entry.getType() == RosterPacket.ItemType.to) {
Presence response = new Presence(Presence.Type.subscribed);
response.setTo(jid);

View File

@ -283,7 +283,7 @@ public class ConferenceRoomBrowser extends JPanel implements ActionListener {
final DefaultTreeModel model = (DefaultTreeModel)serviceTree.getModel();
model.nodeStructureChanged(node);
serviceTree.expandPath(rootPath);
roomsTable.getTableModel().setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BOOKMARK_ICON)), selectedRow, 0);
roomsTable.setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BOOKMARK_ICON)), selectedRow, 0);
addBookmarkUI(false);
conferences.addBookmark(roomName, roomJID, false);
@ -294,7 +294,7 @@ public class ConferenceRoomBrowser extends JPanel implements ActionListener {
JiveTreeNode node = (JiveTreeNode)path.getLastPathComponent();
final DefaultTreeModel model = (DefaultTreeModel)serviceTree.getModel();
model.removeNodeFromParent(node);
roomsTable.getTableModel().setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BLANK_IMAGE)), selectedRow, 0);
roomsTable.setValueAt(new JLabel(SparkRes.getImageIcon(SparkRes.BLANK_IMAGE)), selectedRow, 0);
addBookmarkUI(true);
String jid = (String)node.getAssociatedObject();
@ -636,7 +636,7 @@ public class ConferenceRoomBrowser extends JPanel implements ActionListener {
}
final Object[] insertRoom = new Object[]{bookmarkedLabel, roomName, StringUtils.parseName(jid), occupants};
roomsTable.getTableModel().addRow(insertRoom);
roomsTable.addRow(insertRoom);
}
/**

View File

@ -359,7 +359,7 @@ public final class GroupChatParticipantList extends JPanel implements ChatRoomLi
int index = getIndex(nickname);
if (index != -1) {
final JLabel userLabel = new JLabel(nickname, icon, JLabel.HORIZONTAL);
participantsList.getTableModel().setValueAt(userLabel, index, 0);
participantsList.setValueAt(userLabel, index, 0);
}
}
}
@ -389,7 +389,7 @@ public final class GroupChatParticipantList extends JPanel implements ChatRoomLi
private int getIndex(String nickname) {
for (int i = 0; i < participantsList.getRowCount(); i++) {
final JLabel userLabel = (JLabel)participantsList.getTableModel().getValueAt(i, 0);
final JLabel userLabel = (JLabel)participantsList.getValueAt(i, 0);
if (userLabel.getText().equals(nickname)) {
return i;
}
@ -580,7 +580,7 @@ public final class GroupChatParticipantList extends JPanel implements ChatRoomLi
int index = getIndex(selectedUser);
if (index != -1) {
participantsList.getTableModel().removeRow(index);
participantsList.removeRow(index);
}
}
};
@ -650,7 +650,7 @@ public final class GroupChatParticipantList extends JPanel implements ChatRoomLi
JLabel label = new JLabel(user, icon, JLabel.HORIZONTAL);
participantsList.getTableModel().setValueAt(label, index, 0);
participantsList.setValueAt(label, index, 0);
}
};
@ -810,7 +810,7 @@ public final class GroupChatParticipantList extends JPanel implements ChatRoomLi
for (int i = 0; i < getRowCount(); i++) {
JLabel label = (JLabel)getValueAt(i, 0);
if (label.getText().equals(nickname)) {
getTableModel().removeRow(i);
removeRow(i);
}
}
}
@ -818,7 +818,7 @@ public final class GroupChatParticipantList extends JPanel implements ChatRoomLi
public void addUser(ImageIcon userIcon, String nickname) {
JLabel user = new JLabel(nickname, userIcon, JLabel.HORIZONTAL);
final Object[] userObject = new Object[]{user};
getTableModel().addRow(userObject);
addRow(userObject);
}
// Handle image rendering correctly

View File

@ -0,0 +1,113 @@
/**
* $Revision$
* $Date$
*
* Copyright (C) 1999-2005 Jive Software. All rights reserved.
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
package org.jivesoftware.spark.util;
import com.sun.net.ssl.SSLContext;
import com.sun.net.ssl.TrustManager;
import com.sun.net.ssl.X509TrustManager;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateExpiredException;
import java.security.cert.CertificateNotYetValidException;
import java.security.cert.X509Certificate;
/**
* An SSL socket factory that will let any certifacte past, even if it's expired or
* not singed by a root CA.
*/
public class DummySSLSocketFactory extends SSLSocketFactory {
private SSLSocketFactory factory;
public DummySSLSocketFactory() {
try {
SSLContext sslcontent = SSLContext.getInstance("TLS");
sslcontent.init(null, // KeyManager not required
new TrustManager[]{new DummyTrustManager()},
new java.security.SecureRandom());
factory = sslcontent.getSocketFactory();
}
catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
catch (KeyManagementException e) {
e.printStackTrace();
}
}
public static SocketFactory getDefault() {
return new DummySSLSocketFactory();
}
public Socket createSocket(Socket socket, String s, int i, boolean flag)
throws IOException {
return factory.createSocket(socket, s, i, flag);
}
public Socket createSocket(InetAddress inaddr, int i, InetAddress inaddr2, int j)
throws IOException {
return factory.createSocket(inaddr, i, inaddr2, j);
}
public Socket createSocket(InetAddress inaddr, int i) throws IOException {
return factory.createSocket(inaddr, i);
}
public Socket createSocket(String s, int i, InetAddress inaddr, int j) throws IOException {
return factory.createSocket(s, i, inaddr, j);
}
public Socket createSocket(String s, int i) throws IOException {
return factory.createSocket(s, i);
}
public String[] getDefaultCipherSuites() {
return factory.getSupportedCipherSuites();
}
public String[] getSupportedCipherSuites() {
return factory.getSupportedCipherSuites();
}
}
/**
* Trust manager which accepts certificates without any validation
* except date validation.
*/
class DummyTrustManager implements X509TrustManager {
public boolean isClientTrusted(X509Certificate[] cert) {
return true;
}
public boolean isServerTrusted(X509Certificate[] cert) {
try {
cert[0].checkValidity();
return true;
}
catch (CertificateExpiredException e) {
return false;
}
catch (CertificateNotYetValidException e) {
return false;
}
}
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
}

View File

@ -87,6 +87,11 @@ public class JabberVersion implements Plugin {
return;
}
ContactItem contactItem = (ContactItem)component;
if(contactItem.getPresence() == null){
return;
}
Action versionRequest = new AbstractAction() {
public void actionPerformed(ActionEvent e) {
viewClient();

View File

@ -15,8 +15,8 @@ import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.PrivateDataManager;
import org.jivesoftware.smackx.packet.PrivateData;
import org.jivesoftware.smackx.provider.PrivateDataProvider;
import org.jivesoftware.spark.util.log.Log;
import org.jivesoftware.spark.util.ModelUtil;
import org.jivesoftware.spark.util.log.Log;
import org.xmlpull.v1.XmlPullParser;
import java.util.ArrayList;
@ -83,7 +83,7 @@ public class Tasks implements PrivateData {
Task task = (Task)iter.next();
buf.append("<task>");
buf.append("<title>").append(task.getTitle()).append("</title>");
if(task.isCompleted()){
if (task.isCompleted()) {
buf.append("<completed>true</completed>");
}
buf.append("</task>");
@ -141,7 +141,7 @@ public class Tasks implements PrivateData {
}
if (eventType == XmlPullParser.START_TAG && "completed".equals(parser.getName())) {
String completed = parser.nextText();
if(ModelUtil.hasLength(completed)){
if (ModelUtil.hasLength(completed)) {
task.setCompleted(Boolean.parseBoolean(completed));
}
}
@ -187,22 +187,4 @@ public class Tasks implements PrivateData {
return tasks;
}
public static void main(String args[]) throws Exception {
XMPPConnection.DEBUG_ENABLED = true;
XMPPConnection con = new XMPPConnection("derek", 5222);
con.login("derek", "test");
Tasks tasks = getTaskList(con);
Task task = new Task();
task.setTitle("Hi");
task.setCompleted(true);
tasks.addTask(task);
saveTasks(tasks, con);
System.out.println(tasks);
}
}

View File

@ -13,7 +13,6 @@ package org.jivesoftware.sparkimpl.profile;
import org.jivesoftware.resource.Res;
import org.jivesoftware.resource.SparkRes;
import org.jivesoftware.smack.PacketInterceptor;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.filter.PacketFilter;
import org.jivesoftware.smack.filter.PacketTypeFilter;
@ -53,10 +52,7 @@ import javax.swing.JTabbedPane;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
@ -753,22 +749,4 @@ public class VCardManager {
return number;
}
public static void main(String args[]) throws Exception {
XMPPConnection con = new XMPPConnection("jivesoftware.com", 5222);
con.connect();
con.login("test", "test");
VCard vcard = new VCard();
vcard.load(con, "matt@jivesoftware.com");
String avatarHash = org.jivesoftware.spark.util.StringUtils.hash(vcard.getAvatar());
String vcardXML = vcard.toXML();
System.out.println(avatarHash);
System.out.println(vcardXML);
}
}

View File

@ -118,7 +118,7 @@ public class UserSearchResults extends JPanel {
modelList.add(modelValue);
}
resultsTable.getTableModel().addRow(modelList.toArray());
resultsTable.addRow(modelList.toArray());
}
}

View File

@ -1,176 +0,0 @@
/**
* $RCSfile$
* $Revision: 2408 $
* $Date: 2004-11-02 15:53:30 -0800 (Tue, 02 Nov 2004) $
*
* Copyright 2003-2004 Jive Software.
*
* All rights reserved. Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.sparkimpl.settings;
import com.sun.net.ssl.SSLContext;
import com.sun.net.ssl.TrustManager;
import com.sun.net.ssl.X509TrustManager;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.CertificateExpiredException;
import java.security.cert.CertificateNotYetValidException;
import java.security.cert.X509Certificate;
import javax.net.SocketFactory;
import javax.net.ssl.SSLSocketFactory;
/**
* Creates an SSL connection to a XMPP server.
*
* @author Matt Tucker
*/
public class SSLXMPPConnection extends XMPPConnection {
private static SocketFactory socketFactory = new DummySSLSocketFactory();
/**
* Creates a new SSL connection to the specified host on the default
* SSL port (5223).
*
* @param host the XMPP host.
* @throws XMPPException if an error occurs while trying to establish the connection.
* Two possible errors can occur which will be wrapped by an XMPPException --
* UnknownHostException (XMPP error code 504), and IOException (XMPP error code
* 502). The error codes and wrapped exceptions can be used to present more
* appropiate error messages to end-users.
*/
public SSLXMPPConnection(String host) throws XMPPException {
this(host, 5223);
}
/**
* Creates a new SSL connection to the specified host on the specified port.
*
* @param host the XMPP host.
* @param port the port to use for the connection (default XMPP SSL port is 5223).
* @throws XMPPException if an error occurs while trying to establish the connection.
* Two possible errors can occur which will be wrapped by an XMPPException --
* UnknownHostException (XMPP error code 504), and IOException (XMPP error code
* 502). The error codes and wrapped exceptions can be used to present more
* appropiate error messages to end-users.
*/
public SSLXMPPConnection(String host, int port) throws XMPPException {
super(host, port, null, socketFactory);
}
public SSLXMPPConnection(String host, int port, String serviceName) throws XMPPException {
super(host, port, serviceName, socketFactory);
}
public boolean isSecureConnection() {
return true;
}
/**
* An SSL socket factory that will let any certifacte past, even if it's expired or
* not singed by a root CA.
*/
private static class DummySSLSocketFactory extends SSLSocketFactory {
private SSLSocketFactory factory;
public DummySSLSocketFactory() {
try {
SSLContext sslcontent = SSLContext.getInstance("TLS");
sslcontent.init(null, // KeyManager not required
new TrustManager[]{new DummyTrustManager()},
new java.security.SecureRandom());
factory = sslcontent.getSocketFactory();
}
catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
catch (KeyManagementException e) {
e.printStackTrace();
}
}
public static SocketFactory getDefault() {
return new DummySSLSocketFactory();
}
public Socket createSocket(Socket socket, String s, int i, boolean flag)
throws IOException {
return factory.createSocket(socket, s, i, flag);
}
public Socket createSocket(InetAddress inaddr, int i, InetAddress inaddr2, int j)
throws IOException {
return factory.createSocket(inaddr, i, inaddr2, j);
}
public Socket createSocket(InetAddress inaddr, int i) throws IOException {
return factory.createSocket(inaddr, i);
}
public Socket createSocket(String s, int i, InetAddress inaddr, int j) throws IOException {
return factory.createSocket(s, i, inaddr, j);
}
public Socket createSocket(String s, int i) throws IOException {
return factory.createSocket(s, i);
}
public String[] getDefaultCipherSuites() {
return factory.getSupportedCipherSuites();
}
public String[] getSupportedCipherSuites() {
return factory.getSupportedCipherSuites();
}
}
/**
* Trust manager which accepts certificates without any validation
* except date validation.
*/
private static class DummyTrustManager implements X509TrustManager {
public boolean isClientTrusted(X509Certificate[] cert) {
return true;
}
public boolean isServerTrusted(X509Certificate[] cert) {
try {
cert[0].checkValidity();
return true;
}
catch (CertificateExpiredException e) {
return false;
}
catch (CertificateNotYetValidException e) {
return false;
}
}
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0];
}
}
}