Updating to allow reconnection.

git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@5907 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Derek DeMoro
2006-11-01 21:36:13 +00:00
committed by derek
parent e2d79c3153
commit debd9aeddd
8 changed files with 67 additions and 204 deletions

View File

@ -5,13 +5,15 @@
<ROW Property="ARPCOMMENTS" Value="This installer database contains the logic and data required to install [|ProductName]." ValueLocId="*"/> <ROW Property="ARPCOMMENTS" Value="This installer database contains the logic and data required to install [|ProductName]." ValueLocId="*"/>
<ROW Property="ARPPRODUCTICON" Value="controlPanelIcon.exe"/> <ROW Property="ARPPRODUCTICON" Value="controlPanelIcon.exe"/>
<ROW Property="ARPURLINFOABOUT" Value="http://www.jivesoftware.org/spark"/> <ROW Property="ARPURLINFOABOUT" Value="http://www.jivesoftware.org/spark"/>
<ROW Property="BannerBitmap" Value="default_banner.bmp" Type="1"/> <ROW Property="BannerBitmap" Value="style2blue_banner.jpg" Type="1"/>
<ROW Property="DialogBitmap" Value="default_dialog.bmp" Type="1"/> <ROW Property="CTRLS" Value="2"/>
<ROW Property="DialogBitmap" Value="style2blue_dialog.jpg" Type="1"/>
<ROW Property="Manufacturer" Value="Jive Software" ValueLocId="*"/> <ROW Property="Manufacturer" Value="Jive Software" ValueLocId="*"/>
<ROW Property="ProductCode" Value="1033:{B68C7CBE-A77D-4CA3-9E78-2C3BF2B5A897} "/> <ROW Property="ProductCode" Value="1033:{B68C7CBE-A77D-4CA3-9E78-2C3BF2B5A897} "/>
<ROW Property="ProductLanguage" Value="1033"/> <ROW Property="ProductLanguage" Value="1033"/>
<ROW Property="ProductName" Value="Spark" ValueLocId="*"/> <ROW Property="ProductName" Value="Spark" ValueLocId="*"/>
<ROW Property="ProductVersion" Value="2.0.5"/> <ROW Property="ProductVersion" Value="2.0.5"/>
<ROW Property="RUNAPPLICATION" Value="1" Type="4"/>
<ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/> <ROW Property="SecureCustomProperties" Value="OLDPRODUCTS;AI_NEWERPRODUCTFOUND"/>
<ROW Property="UpgradeCode" Value="{FD8D7ADD-E933-4DEA-81BA-2F4C0FF8B22E}"/> <ROW Property="UpgradeCode" Value="{FD8D7ADD-E933-4DEA-81BA-2F4C0FF8B22E}"/>
</COMPONENT> </COMPONENT>
@ -128,9 +130,9 @@
<ROW Fragment="UI.aip" Path="&lt;UI.aip&gt;"/> <ROW Fragment="UI.aip" Path="&lt;UI.aip&gt;"/>
</COMPONENT> </COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.MsiBinaryComponent"> <COMPONENT cid="caphyon.advinst.msicomp.MsiBinaryComponent">
<ROW Name="default_banner.bmp" SourcePath="&lt;default-banner.bmp&gt;"/>
<ROW Name="default_dialog.bmp" SourcePath="&lt;default-dialog.bmp&gt;"/>
<ROW Name="launcher.dll" SourcePath="&lt;launcher.dll&gt;"/> <ROW Name="launcher.dll" SourcePath="&lt;launcher.dll&gt;"/>
<ROW Name="style2blue_banner.jpg" SourcePath="&lt;style2blue-banner.jpg&gt;"/>
<ROW Name="style2blue_dialog.jpg" SourcePath="&lt;style2blue-dialog.jpg&gt;"/>
</COMPONENT> </COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.MsiControlComponent"> <COMPONENT cid="caphyon.advinst.msicomp.MsiControlComponent">
<ATTRIBUTE name="FixedSizeBitmaps" value="0"/> <ATTRIBUTE name="FixedSizeBitmaps" value="0"/>
@ -150,6 +152,7 @@
</COMPONENT> </COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.MsiCustActComponent"> <COMPONENT cid="caphyon.advinst.msicomp.MsiCustActComponent">
<ROW Action="AI_DOWNGRADE" Type="19" Target="4010"/> <ROW Action="AI_DOWNGRADE" Type="19" Target="4010"/>
<ROW Action="AI_LaunchApp" Type="1" Source="launcher.dll" Target="[#Spark.exe]"/>
<ROW Action="AI_PREPARE_UPGRADE" Type="1" Source="launcher.dll" Target="PrepareUpgrade"/> <ROW Action="AI_PREPARE_UPGRADE" Type="1" Source="launcher.dll" Target="PrepareUpgrade"/>
<ROW Action="AI_RESTORE_LOCATION" Type="1" Source="launcher.dll" Target="RestoreLocation"/> <ROW Action="AI_RESTORE_LOCATION" Type="1" Source="launcher.dll" Target="RestoreLocation"/>
<ROW Action="AI_STORE_LOCATION" Type="51" Source="ARPINSTALLLOCATION" Target="[APPDIR]"/> <ROW Action="AI_STORE_LOCATION" Type="51" Source="ARPINSTALLLOCATION" Target="[APPDIR]"/>
@ -209,6 +212,7 @@
<ATTRIBUTE name="MediaSize" value="0"/> <ATTRIBUTE name="MediaSize" value="0"/>
<ATTRIBUTE name="MediaSizeUnit" value="0"/> <ATTRIBUTE name="MediaSizeUnit" value="0"/>
<ATTRIBUTE name="Package" value="1"/> <ATTRIBUTE name="Package" value="1"/>
<ATTRIBUTE name="PackageName" value="..\..\..\..\spark"/>
</COMPONENT> </COMPONENT>
<COMPONENT cid="caphyon.advinst.msicomp.MsiRegsComponent"> <COMPONENT cid="caphyon.advinst.msicomp.MsiRegsComponent">
<ROW Registry="DellSupport" Root="1" Key="Run" Name="DellSupport" Value="&quot;C:\Program Files\Dell Support\DSAgnt.exe&quot; /startup" Component_="DellSupport"/> <ROW Registry="DellSupport" Root="1" Key="Run" Name="DellSupport" Value="&quot;C:\Program Files\Dell Support\DSAgnt.exe&quot; /startup" Component_="DellSupport"/>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -590,7 +590,7 @@ public final class LoginDialog {
config = new ConnectionConfiguration(localPref.getXmppHost(), port, serverName); config = new ConnectionConfiguration(localPref.getXmppHost(), port, serverName);
} }
config.setReconnectionAllowed(false); //config.setReconnectionAllowed(false);
} }
if (config != null) { if (config != null) {

View File

@ -134,7 +134,6 @@ public final class ContactList extends JPanel implements ActionListener, Contact
private RetryPanel retryPanel; private RetryPanel retryPanel;
private RetryPanel.ReconnectListener reconnectListener;
private Workspace workspace; private Workspace workspace;
@ -1863,86 +1862,33 @@ public final class ContactList extends JPanel implements ActionListener, Contact
connectionClosedOnError(null); connectionClosedOnError(null);
} }
private void reconnect(final String message, final boolean conflict) { private void reconnect(final String message) {
// Show MainWindow // Show MainWindow
SparkManager.getMainWindow().setVisible(true); SparkManager.getMainWindow().setVisible(true);
// Flash That Window. // Flash That Window.
SparkManager.getAlertManager().flashWindowStopOnFocus(SparkManager.getMainWindow()); SparkManager.getAlertManager().flashWindowStopOnFocus(SparkManager.getMainWindow());
if (reconnectListener == null) {
reconnectListener = new RetryPanel.ReconnectListener() {
public void reconnected() {
clientReconnected();
}
public void cancelled() {
removeAllUsers();
}
};
retryPanel.addReconnectionListener(reconnectListener);
}
workspace.changeCardLayout(RETRY_PANEL); workspace.changeCardLayout(RETRY_PANEL);
retryPanel.setDisconnectReason(message); retryPanel.setDisconnectReason(message);
if (false) {
retryPanel.startTimer();
}
else {
retryPanel.showConflict();
}
}
private void removeAllUsers() {
// Show reconnect panel
workspace.changeCardLayout(RETRY_PANEL);
// Behind the scenes, move everyone to the offline group.
Iterator contactGroups = new ArrayList(getContactGroups()).iterator();
while (contactGroups.hasNext()) {
ContactGroup contactGroup = (ContactGroup)contactGroups.next();
Iterator contactItems = new ArrayList(contactGroup.getContactItems()).iterator();
while (contactItems.hasNext()) {
ContactItem item = (ContactItem)contactItems.next();
contactGroup.removeContactItem(item);
}
}
} }
public void clientReconnected() { public void clientReconnected() {
XMPPConnection con = SparkManager.getConnection(); buildContactList();
if (con.isConnected()) {
// Send Available status
final Presence presence = SparkManager.getWorkspace().getStatusBar().getPresence();
SparkManager.getSessionManager().changePresence(presence);
final Roster roster = con.getRoster();
for (RosterEntry entry : roster.getEntries()) {
updateUserPresence(roster.getPresence(entry.getUser()));
}
}
workspace.changeCardLayout(Workspace.WORKSPACE_PANE); workspace.changeCardLayout(Workspace.WORKSPACE_PANE);
} }
public void connectionClosedOnError(final Exception ex) { public void connectionClosedOnError(final Exception ex) {
String errorMessage = Res.getString("message.disconnected.error"); String errorMessage = Res.getString("message.disconnected.error");
boolean conflictError = false;
if (ex != null && ex instanceof XMPPException) { if (ex != null && ex instanceof XMPPException) {
XMPPException xmppEx = (XMPPException)ex; XMPPException xmppEx = (XMPPException)ex;
StreamError error = xmppEx.getStreamError(); StreamError error = xmppEx.getStreamError();
String reason = error.getCode(); String reason = error.getCode();
if ("conflict".equals(reason)) { if ("conflict".equals(reason)) {
errorMessage = Res.getString("message.disconnected.conflict.error"); errorMessage = Res.getString("message.disconnected.conflict.error");
conflictError = true;
} }
else { else {
errorMessage = Res.getString("message.general.error", reason); errorMessage = Res.getString("message.general.error", reason);
@ -1950,22 +1896,29 @@ public final class ContactList extends JPanel implements ActionListener, Contact
} }
final String message = errorMessage; final String message = errorMessage;
final boolean conflicted = conflictError;
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
public void run() { public void run() {
reconnect(message, conflicted); reconnect(message);
} }
}); });
} }
public void reconnectingIn(int i) { public void reconnectingIn(int i) {
if (i == 0) {
retryPanel.setReconnectText("Attempting...");
}
else {
retryPanel.setReconnectText("Reconnect...");
}
} }
public void reconectionSuccessful() { public void reconectionSuccessful() {
clientReconnected();
} }
public void reconnectionFailed(Exception exception) { public void reconnectionFailed(Exception exception) {
retryPanel.setReconnectText("Reconnect Failed");
} }

View File

@ -16,10 +16,9 @@ import org.jivesoftware.spark.SparkManager;
import org.jivesoftware.spark.component.RolloverButton; import org.jivesoftware.spark.component.RolloverButton;
import org.jivesoftware.spark.component.WrappedLabel; import org.jivesoftware.spark.component.WrappedLabel;
import org.jivesoftware.spark.util.ModelUtil; import org.jivesoftware.spark.util.ModelUtil;
import org.jivesoftware.spark.util.ResourceUtils; import org.jivesoftware.spark.util.SwingWorker;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.Timer;
import java.awt.Color; import java.awt.Color;
import java.awt.FlowLayout; import java.awt.FlowLayout;
@ -29,9 +28,6 @@ import java.awt.GridBagLayout;
import java.awt.Insets; import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/** /**
* RetryPanel is the UI/Function class to handle reconnection logic. This allows for a simple card layout to replace the current * RetryPanel is the UI/Function class to handle reconnection logic. This allows for a simple card layout to replace the current
@ -42,12 +38,6 @@ import java.util.List;
public class RetryPanel extends JPanel { public class RetryPanel extends JPanel {
private WrappedLabel descriptionLabel; private WrappedLabel descriptionLabel;
private RolloverButton retryButton; private RolloverButton retryButton;
private RolloverButton cancelButton;
private Timer timer;
private int countdown;
private List listeners = new ArrayList();
/** /**
* Construct the RetryPanel. * Construct the RetryPanel.
@ -55,35 +45,61 @@ public class RetryPanel extends JPanel {
public RetryPanel() { public RetryPanel() {
setLayout(new GridBagLayout()); setLayout(new GridBagLayout());
countdown = 45;
// Init Components // Init Components
descriptionLabel = new WrappedLabel(); descriptionLabel = new WrappedLabel();
retryButton = new RolloverButton(SparkRes.getImageIcon(SparkRes.SMALL_CHECK)); retryButton = new RolloverButton(SparkRes.getImageIcon(SparkRes.SMALL_CHECK));
cancelButton = new RolloverButton("", SparkRes.getImageIcon(SparkRes.SMALL_CHECK));
ResourceUtils.resButton(cancelButton, Res.getString("button.reconnect"));
layoutComponents(); layoutComponents();
retryButton.addActionListener(new ActionListener() { retryButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
//attemptReconnect(); attemptReconnection();
} }
}); });
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
logout();
}
});
setBackground(Color.white); setBackground(Color.white);
// Set Font // Set Font
descriptionLabel.setFont(new Font("Dialog", Font.PLAIN, 13)); descriptionLabel.setFont(new Font("Dialog", Font.PLAIN, 12));
retryButton.setText("Reconnect");
}
private void attemptReconnection() {
retryButton.setText("Attempting...");
retryButton.setEnabled(false);
SwingWorker worker = new SwingWorker() {
public Object construct() {
try {
SparkManager.getConnection().connect();
return true;
}
catch (Exception e) {
e.printStackTrace();
}
return false;
}
public void finished() {
retryButton.setEnabled(true);
if ((Boolean)get()) {
ContactList list = SparkManager.getWorkspace().getContactList();
list.clientReconnected();
}
else {
retryButton.setText("Reconnect");
}
}
};
worker.start();
} }
/** /**
@ -104,7 +120,6 @@ public class RetryPanel extends JPanel {
final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.setOpaque(false); buttonPanel.setOpaque(false);
buttonPanel.add(retryButton); buttonPanel.add(retryButton);
buttonPanel.add(cancelButton);
add(buttonPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); add(buttonPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
} }
@ -112,24 +127,12 @@ public class RetryPanel extends JPanel {
/** /**
* Starts the countdown to the next retry attempt. The retry attemp is set for every 45 seconds or what is set * Starts the countdown to the next retry attempt. The retry attemp is set for every 45 seconds or what is set
* as the default in preferences. * as the default in preferences.
*
* @param text the text to display on the reconnect button.
*/ */
protected void startTimer() { protected void setReconnectText(String text) {
retryButton.setVisible(true); retryButton.setVisible(true);
retryButton.setText(text);
ActionListener updateTime = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (countdown > 0) {
retryButton.setText("Retry in " + countdown);
countdown--;
}
else {
//attemptReconnect();
}
}
};
timer = new Timer(1000, updateTime);
timer.start();
} }
/** /**
@ -138,101 +141,4 @@ public class RetryPanel extends JPanel {
public void showConflict() { public void showConflict() {
retryButton.setVisible(false); retryButton.setVisible(false);
} }
/*
private void attemptReconnect() {
retryButton.setText("Attempting....");
timer.stop();
SwingWorker worker = new SwingWorker() {
public Object construct() {
try {
Thread.sleep(500);
}
catch (InterruptedException e) {
Log.error(e);
}
return timer;
}
public void finished() {
XMPPConnection con;
try {
con = SparkManager.getConnection().reconnect();
SparkManager.getSessionManager().setConnection(con);
SparkManager.getMessageEventManager().setConnection(con);
fireReconnection();
}
catch (XMPPException e) {
countdown = 45;
timer.start();
}
}
};
worker.start();
}
*/
/**
* Adds a <code>ReconnectListener</code>.
*
* @param listener the listener to add.
*/
public void addReconnectionListener(ReconnectListener listener) {
listeners.add(listener);
}
/**
* Removes a <code>ReconnectListener</code>.
*
* @param listener the listener to remove.
*/
public void removeReconnectionListener(ReconnectListener listener) {
listeners.remove(listener);
}
private void fireReconnection() {
final Iterator iter = ModelUtil.reverseListIterator(listeners.listIterator());
while (iter.hasNext()) {
ReconnectListener listener = (ReconnectListener)iter.next();
listener.reconnected();
}
}
private void fireCancelled() {
final Iterator iter = ModelUtil.reverseListIterator(listeners.listIterator());
while (iter.hasNext()) {
ReconnectListener listener = (ReconnectListener)iter.next();
listener.cancelled();
}
}
private void logout() {
SparkManager.getMainWindow().setVisible(false);
SparkManager.getMainWindow().logout(false);
}
/**
* Implementation of this class if you wish to be notified of reconnection or cancelling events when Spark
* loses it's connection to the server.
*/
public interface ReconnectListener {
/**
* Spark has successfully reconnected.
*/
void reconnected();
/**
* The user has decided to cancel the reconnection attempt.
*/
void cancelled();
}
} }

View File

@ -233,8 +233,8 @@ message.supply.valid.timeout = Supply a valid time out value.
message.supply.valid.port = Supply a valid port. message.supply.valid.port = Supply a valid port.
message.supply.resource = Supply a valid resource. message.supply.resource = Supply a valid resource.
message.current.status = Let others know your current status or activity. message.current.status = Let others know your current status or activity.
message.disconnected.error = Your connection was closed due to an error. message.disconnected.error = Disconnected from the server
message.disconnected.conflict.error = Your connection was closed due to the same user logging in from another location. message.disconnected.conflict.error = Disconnected from the server due to the same user logging in from another location.
message.locked.workstation = User has locked their workstation. message.locked.workstation = User has locked their workstation.
message.away.idle = Away due to idle. message.away.idle = Away due to idle.
message.default.error = An error has been detected. Please report to support@jivesoftware.com. message.default.error = An error has been detected. Please report to support@jivesoftware.com.