Status selector box added only once for a protocol. Bug in re-login fixed.

cusax-fix
Yana Stamcheva 21 years ago
parent 314fae1bbe
commit 14f09e4890

@ -74,7 +74,7 @@ public class MainFrame extends JFrame {
private MetaContactListService contactList;
private ArrayList accounts = new ArrayList();
private Hashtable accounts = new Hashtable();
private Hashtable waitToBeDeliveredMsgs = new Hashtable();
@ -160,10 +160,12 @@ public void setConfigFrame(ConfigurationFrame configFrame) {
}
/**
* Returns a set of all operation sets supported by the given protocol provider.
* Returns a set of all operation sets supported by the given
* protocol provider.
*
* @param protocolProvider The protocol provider.
* @return a set of all operation sets supported by the given protocol provider.
* @return a set of all operation sets supported by the given
* protocol provider.
*/
public Map getSupportedOperationSets
(ProtocolProviderService protocolProvider) {
@ -221,7 +223,8 @@ public void setConfigFrame(ConfigurationFrame configFrame) {
//request the focus int the contact list panel, which
//permits to search in the contact list
this.tabbedPane.getContactListPanel().getContactList().requestFocus();
this.tabbedPane.getContactListPanel()
.getContactList().requestFocus();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
@ -241,14 +244,16 @@ else if(key.equals(OperationSetBasicInstantMessaging.class.getName())
= (OperationSetBasicInstantMessaging)value;
this.imOperationSets.put(protocolProvider, im);
//Add to all instant messaging operation sets the Message listener
//implemented in the ContactListPanel, which handles all received messages.
//Add to all instant messaging operation sets the Message
//listener implemented in the ContactListPanel, which handles
//all received messages.
im.addMessageListener(this.getTabbedPane().getContactListPanel());
}
else if(key.equals(OperationSetTypingNotifications.class.getName())){
OperationSetTypingNotifications tn
= (OperationSetTypingNotifications)value;
tn.addTypingNotificationsListener(this.getTabbedPane().getContactListPanel());
tn.addTypingNotificationsListener
(this.getTabbedPane().getContactListPanel());
}
}
}
@ -278,18 +283,24 @@ public void addProtocolProvider(
*
* @param account The account to be added.
*/
public void addAccount(Account account){
this.accounts.add(account);
this.getStatusPanel().activateAccount(account);
this.getStatusPanel().startConnecting(account.getProtocolName());
public void addAccount(String identifier,
ProtocolProviderService protocolProvider){
String protocolName = protocolProvider.getProtocolName();
if(!getStatusPanel().isProtocolActivated(protocolName)){
this.accounts.put(protocolProvider, identifier);
this.getStatusPanel().activateAccount(protocolProvider);
}
this.getStatusPanel()
.startConnecting(protocolName);
}
/**
* Returns the default account (for now is returning the first one).
* @return the default account (for now is returning the first one).
*/
public Account getAccount(){
return (Account)this.accounts.get(0);
public String getDefaultAccount(ProtocolProviderService protocolProvider){
return (String)this.accounts.get(protocolProvider);
}
/**
@ -306,9 +317,11 @@ public Account getAccount(){
}
/**
* Returns the basic instant messaging operation set for the given protocol provider.
* Returns the basic instant messaging operation set for the given
* protocol provider.
*
* @param protocolProvider The protocol provider for which the IM is searched.
* @param protocolProvider The protocol provider for which the IM
* is searched.
* @return OperationSetBasicInstantMessaging The basic instant messaging
* operation set for the given protocol provider.
*/

@ -18,7 +18,14 @@
import net.java.sip.communicator.impl.gui.main.utils.Constants;
import net.java.sip.communicator.impl.gui.main.utils.ImageLoader;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
/**
* The StatusPanel is the place where the user can see and change its status
* for all registered protocols.
*
* @author Yana Stamcheva
*/
public class StatusPanel extends JPanel {
private Hashtable protocolStatusCombos = new Hashtable();
@ -35,19 +42,25 @@ public StatusPanel(MainFrame mainFrame) {
Constants.CONTACTPANEL_MOVER_START_COLOR));
}
public void activateAccount(Account account) {
/**
* Creates the selector box, containing all protocol statuses, adds it to
* the StatusPanel and refreshes the panel.
*
* @param protocolProvider The protocol provider.
*/
public void activateAccount(ProtocolProviderService protocolProvider) {
Map protocolStatusMap = Constants
.getProtocolStatusIcons(account.getProtocolName());
.getProtocolStatusIcons(protocolProvider.getProtocolName());
StatusSelectorBox protocolStatusCombo
= new StatusSelectorBox(
this.mainFrame,
account,
protocolProvider,
protocolStatusMap,
(Image)protocolStatusMap.get(Constants.OFFLINE_STATUS));
this.protocolStatusCombos.put( account.getProtocolName(),
this.protocolStatusCombos.put( protocolProvider.getProtocolName(),
protocolStatusCombo);
this.add(protocolStatusCombo);
@ -55,6 +68,12 @@ public void activateAccount(Account account) {
this.getParent().validate();
}
/**
* Sets the selected status.
*
* @param protocol The protocol name.
* @param status The newly selected status.
*/
public void setSelectedStatus(String protocol, Object status){
Map protocolStatusMap = Constants
@ -69,6 +88,12 @@ public void setSelectedStatus(String protocol, Object status){
selectorBox.repaint();
}
/**
* Shows the protocol animated icon, indicating that it is in a connecting
* state.
*
* @param protocol The protocol name.
*/
public void startConnecting(String protocol){
StatusSelectorBox selectorBox
@ -80,6 +105,12 @@ public void startConnecting(String protocol){
selectorBox.repaint();
}
/**
* Removes the protocol animated icon, indicating that the connecting
* process is finished.
*
* @param protocol The protocol name.
*/
public void stopConnecting(String protocol){
StatusSelectorBox selectorBox
@ -90,13 +121,19 @@ public void stopConnecting(String protocol){
selectorBox.repaint();
}
public Hashtable getProtocolStatusCombos() {
return protocolStatusCombos;
}
public void setProtocolStatusCombos(
Hashtable protocolStatusCombos) {
this.protocolStatusCombos = protocolStatusCombos;
/**
* Checks if the given protocol has already its StatusSelectorBox in the
* StatusPanel.
*
* @param protocolName The protocol name.
* @return True if the protcol has already its StatusSelectorBox in the
* StatusPanel, False otherwise.
*/
public boolean isProtocolActivated(String protocolName){
if(protocolStatusCombos.containsKey(protocolName))
return true;
else
return false;
}
public MainFrame getMainFrame() {

@ -34,6 +34,7 @@
import net.java.sip.communicator.service.protocol.OperationFailedException;
import net.java.sip.communicator.service.protocol.OperationSetPresence;
import net.java.sip.communicator.service.protocol.PresenceStatus;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
import net.java.sip.communicator.service.protocol.icqconstants.IcqStatusEnum;
import net.java.sip.communicator.util.Logger;
@ -55,9 +56,10 @@ public class StatusSelectorBox extends JLabel
private Connecting connecting = new Connecting();
private Account account;
private ProtocolProviderService protocolProvider;
public StatusSelectorBox(MainFrame mainFrame, Account account) {
public StatusSelectorBox( MainFrame mainFrame,
ProtocolProviderService protocolProvider) {
this.setPreferredSize(new Dimension(
this.backgroundImage.getWidth(this),
@ -69,8 +71,8 @@ public StatusSelectorBox(MainFrame mainFrame, Account account) {
this.mainFrame = mainFrame;
this.account = account;
this.protocolProvider = protocolProvider;
this.popup = new AntialiasedPopupMenu();
this.popup.setInvoker(this);
@ -79,7 +81,7 @@ public StatusSelectorBox(MainFrame mainFrame, Account account) {
}
public StatusSelectorBox( MainFrame mainFrame,
Account account,
ProtocolProviderService protocolProvider,
Map itemsMap,
Image selectedItem) {
@ -94,9 +96,7 @@ public StatusSelectorBox( MainFrame mainFrame,
this.setIcon(new ImageIcon(selectedItem));
this.mainFrame = mainFrame;
this.account = account;
this.protocolProvider = protocolProvider;
this.itemsMap = itemsMap;
this.popup = new AntialiasedPopupMenu();
@ -146,8 +146,7 @@ public void actionPerformed (ActionEvent e) {
JMenuItem menuItem = (JMenuItem) e.getSource();
OperationSetPresence presence
= mainFrame.getProtocolPresence
(account.getProtocolProvider());
= mainFrame.getProtocolPresence(protocolProvider);
Iterator statusSet = presence.getSupportedStatusSet();
@ -164,21 +163,17 @@ public void actionPerformed (ActionEvent e) {
if(status.equals(IcqStatusEnum.ONLINE)){
if(account.getProtocolProvider()
.isRegistered()){
if(protocolProvider.isRegistered()){
presence
.publishPresenceStatus(status, "");
}
else{
account.getProtocolProvider()
.register(null);
protocolProvider.register(null);
}
}
else if(status.equals(IcqStatusEnum.OFFLINE)){
account.getProtocolProvider().unregister();
protocolProvider.unregister();
}
else {

@ -41,6 +41,7 @@
import net.java.sip.communicator.service.protocol.Message;
import net.java.sip.communicator.service.protocol.OperationSetTypingNotifications;
import net.java.sip.communicator.service.protocol.PresenceStatus;
import net.java.sip.communicator.service.protocol.ProtocolProviderService;
import net.java.sip.communicator.service.protocol.event.*;
/**
@ -481,9 +482,11 @@ public void messageDelivered(MessageDeliveredEvent evt) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(evt.getTimestamp());
ProtocolProviderService protocolProvider
= evt.getDestinationContact().getProtocolProvider();
chatPanel.getConversationPanel().processMessage(
this.mainFrame.getAccount().getIdentifier(),
this.mainFrame.getDefaultAccount(protocolProvider),
calendar,
ChatMessage.OUTGOING_MESSAGE,
msg.getContent());

@ -80,23 +80,17 @@ public void login( AccountManager accountManager,
Hashtable accountProperties = new Hashtable();
accountProperties.put(AccountProperties.PASSWORD, passwd);
this.accountID = accountManager.installAccount(
this.bc, user, accountProperties);
ServiceReference serRef = null;
this.accountID = accountManager.installAccount(
this.bc, user, accountProperties);
serRef = accountManager
ServiceReference serRef = accountManager
.getProviderForAccount(this.accountID);
ProtocolProviderService protocolProvider
= (ProtocolProviderService)this.bc.getService(serRef);
Account account
= new Account( user,
protocolProvider);
this.mainFrame.addAccount(account);
this.mainFrame.addAccount(user, protocolProvider);
protocolProvider.addRegistrationStateChangeListener(this);

@ -206,9 +206,7 @@ protected void paintComponent(Graphics g) {
g2.setColor(new Color(255, 255, 255, 100));
g2.fillRect(0, 0, getWidth(), getHeight());
}
}
/**

Loading…
Cancel
Save