diff options
Diffstat (limited to 'src/net/java/sip')
34 files changed, 469 insertions, 608 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationPanel.java b/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationPanel.java index 165bde9..df5d3b2 100644 --- a/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/account/AccountsConfigurationPanel.java @@ -99,8 +99,8 @@ public class AccountsConfigurationPanel for (AccountID accountID : providerFactory.getRegisteredAccounts())
{
boolean isHidden =
- (accountID.getAccountProperties().get(
- ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null);
+ (accountID
+ .getAccountProperty(ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null);
if (isHidden)
continue;
@@ -251,8 +251,8 @@ public class AccountsConfigurationPanel this.add(accountLabel, constraints);
String passwordRequiredProperty =
- (String) protocolProvider.getAccountID().getAccountProperties()
- .get(ProtocolProviderFactory.NO_PASSWORD_REQUIRED);
+ protocolProvider.getAccountID().getAccountPropertyString(
+ ProtocolProviderFactory.NO_PASSWORD_REQUIRED);
boolean isPasswordRequired = true;
if (passwordRequiredProperty != null
@@ -265,9 +265,8 @@ public class AccountsConfigurationPanel if (isPasswordRequired)
{
String password =
- (String) protocolProvider.getAccountID()
- .getAccountProperties().get(
- ProtocolProviderFactory.PASSWORD);
+ protocolProvider.getAccountID().getAccountPropertyString(
+ ProtocolProviderFactory.PASSWORD);
passwordField.setText(password);
constraints.gridx = 1;
diff --git a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java index 589db84..985d23c 100644 --- a/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java +++ b/src/net/java/sip/communicator/impl/gui/main/chat/ChatPanel.java @@ -743,17 +743,11 @@ public class ChatPanel private boolean isGreyHistoryStyleDisabled( ProtocolProviderService protocolProvider) { - boolean isProtocolHidden = false; + boolean isProtocolHidden = + protocolProvider.getAccountID().getAccountPropertyBoolean( + ProtocolProviderFactory.IS_PROTOCOL_HIDDEN, false); boolean isGreyHistoryDisabled = false; - Object hiddenProperty - = protocolProvider.getAccountID().getAccountProperties() - .get(ProtocolProviderFactory.IS_PROTOCOL_HIDDEN); - - if (hiddenProperty != null) - isProtocolHidden - = new Boolean((String)hiddenProperty).booleanValue(); - String greyHistoryProperty = GuiActivator.getResources() .getSettingsString("impl.gui.GREY_HISTORY_ENABLED"); diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java index 9c04b07..c18f8b3 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/GroupRightButtonMenu.java @@ -81,8 +81,8 @@ public class GroupRightButtonMenu = (ProtocolProviderService)providers.next(); boolean isHidden = - pps.getAccountID().getAccountProperties(). - get(ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; + pps.getAccountID().getAccountProperty( + ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; if(isHidden) continue; diff --git a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java index 3995cb6..c2d3711 100644 --- a/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java +++ b/src/net/java/sip/communicator/impl/gui/main/contactlist/addcontact/AddContactWizard.java @@ -59,8 +59,9 @@ public class AddContactWizard { ProtocolProviderService p = (ProtocolProviderService)iter.next(); - boolean isHidden = p.getAccountID().getAccountProperties(). - get(ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; + boolean isHidden = + p.getAccountID().getAccountProperty( + ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; if(!isHidden) pps.add(p); diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java b/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java index 068839f..9e0741a 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/GlobalStatusSelectorBox.java @@ -141,10 +141,9 @@ public class GlobalStatusSelectorBox = (OperationSetPersistentPresence) protocolProvider .getOperationSet(OperationSetPresence.class); - boolean isHidden = - protocolProvider.getAccountID(). - getAccountProperties().get( - ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; + boolean isHidden = + protocolProvider.getAccountID().getAccountProperty( + ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; if (isHidden) return; @@ -158,8 +157,7 @@ public class GlobalStatusSelectorBox } else { - statusSelectorMenu - = new SimpleStatusMenu(mainFrame, protocolProvider); + statusSelectorMenu = new SimpleStatusMenu(protocolProvider); } this.add(statusSelectorMenu); @@ -501,10 +499,9 @@ public class GlobalStatusSelectorBox // We do not show hidden protocols in our status bar, so we do not // care about their status here. - isProtocolHidden = - protocolProvider.getAccountID(). - getAccountProperties().get( - ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; + isProtocolHidden = + protocolProvider.getAccountID().getAccountProperty( + ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; if (isProtocolHidden) continue; diff --git a/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java b/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java index 5a465e7..65b9f80 100644 --- a/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java +++ b/src/net/java/sip/communicator/impl/gui/main/presence/SimpleStatusMenu.java @@ -13,84 +13,63 @@ import javax.swing.*; import net.java.sip.communicator.impl.gui.*; import net.java.sip.communicator.impl.gui.customcontrols.*; -import net.java.sip.communicator.impl.gui.main.*; import net.java.sip.communicator.impl.gui.utils.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.util.*; /** - * The <tt>SimpleStatusSelectorBox</tt> is a <tt>SIPCommMenu</tt> that - * contains two statuses ONLINE and OFFLINE. It's used to represent the status - * of a protocol provider which doesn't support presence operation set. - * + * The <tt>SimpleStatusSelectorBox</tt> is a <tt>SIPCommMenu</tt> that contains + * two statuses ONLINE and OFFLINE. It's used to represent the status of a + * protocol provider which doesn't support presence operation set. + * * @author Yana Stamcheva + * @author Lubomir Marinov */ public class SimpleStatusMenu extends StatusSelectorMenu implements ActionListener { - private Logger logger = Logger.getLogger( - SimpleStatusMenu.class.getName()); - - private MainFrame mainFrame; - - private ProtocolProviderService protocolProvider; + private final Logger logger = Logger.getLogger(SimpleStatusMenu.class); - private ImageIcon onlineIcon; + private final ProtocolProviderService protocolProvider; - private ImageIcon offlineIcon; + private final ImageIcon onlineIcon; - private JMenuItem onlineItem = new JMenuItem( - GuiActivator.getResources().getI18NString("service.gui.ONLINE"), - onlineIcon); + private final ImageIcon offlineIcon; - private JMenuItem offlineItem = new JMenuItem( - GuiActivator.getResources().getI18NString("service.gui.OFFLINE"), - offlineIcon); + private final JMenuItem onlineItem; - private JLabel titleLabel; + private final JMenuItem offlineItem; /** - * Creates an instance of <tt>SimpleStatusSelectorBox</tt>. - * - * @param mainFrame The main application window. + * Creates an instance of <tt>SimpleStatusMenu</tt>. + * * @param protocolProvider The protocol provider. - * @param accountIndex If we have more than one account for a protocol, - * each account has an index. */ - public SimpleStatusMenu(MainFrame mainFrame, - ProtocolProviderService protocolProvider) + public SimpleStatusMenu(ProtocolProviderService protocolProvider) { - super(protocolProvider.getAccountID().getDisplayName(), - new ImageIcon(protocolProvider - .getProtocolIcon().getIcon(ProtocolIcon.ICON_SIZE_16x16))); - - this.mainFrame = mainFrame; - this.protocolProvider = protocolProvider; - - this.onlineIcon = new ImageIcon( - ImageLoader.getBytesInImage(protocolProvider.getProtocolIcon() - .getIcon(ProtocolIcon.ICON_SIZE_16x16))); - - this.offlineIcon = new ImageIcon( - LightGrayFilter.createDisabledImage( - ImageLoader.getBytesInImage(protocolProvider.getProtocolIcon() - .getIcon(ProtocolIcon.ICON_SIZE_16x16)))); + this(protocolProvider, + protocolProvider.getAccountID().getDisplayName(), new ImageIcon( + protocolProvider.getProtocolIcon().getIcon( + ProtocolIcon.ICON_SIZE_16x16))); + } - String tooltip = "<html><b>" - + protocolProvider.getAccountID().getDisplayName() - + "</b><br>Offline</html>"; + private SimpleStatusMenu(ProtocolProviderService protocolProvider, + String displayName, ImageIcon onlineIcon) + { + super(displayName, onlineIcon); - this.setToolTipText(tooltip); + this.protocolProvider = protocolProvider; - onlineItem.setName(Constants.ONLINE_STATUS); - offlineItem.setName(Constants.OFFLINE_STATUS); + this.onlineIcon = onlineIcon; + this.offlineIcon = + new ImageIcon(LightGrayFilter.createDisabledImage(onlineIcon + .getImage())); - onlineItem.addActionListener(this); - offlineItem.addActionListener(this); + this.setToolTipText("<html><b>" + displayName + + "</b><br>Offline</html>"); - titleLabel = new JLabel(protocolProvider - .getAccountID().getDisplayName()); + JLabel titleLabel = new JLabel(displayName); titleLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); titleLabel.setFont(Constants.FONT.deriveFont(Font.BOLD)); @@ -98,44 +77,62 @@ public class SimpleStatusMenu this.add(titleLabel); this.addSeparator(); - this.add(onlineItem); - this.add(offlineItem); + onlineItem = + createMenuItem("service.gui.ONLINE", onlineIcon, + Constants.ONLINE_STATUS); + offlineItem = + createMenuItem("service.gui.OFFLINE", offlineIcon, + Constants.OFFLINE_STATUS); + } -// setSelected(offlineItem, offlineIcon); + private JMenuItem createMenuItem(String textKey, Icon icon, String name) + { + JMenuItem menuItem = + new JMenuItem(GuiActivator.getResources().getI18NString(textKey), + icon); + + menuItem.setName(Constants.ONLINE_STATUS); + menuItem.addActionListener(this); + this.add(menuItem); + return menuItem; } /** - * Handles the <tt>ActionEvent</tt> triggered when one of the items - * in the list is selected. + * Handles the <tt>ActionEvent</tt> triggered when one of the items in the + * list is selected. */ public void actionPerformed(ActionEvent e) { JMenuItem menuItem = (JMenuItem) e.getSource(); String itemName = menuItem.getName(); - if(itemName.equals(Constants.ONLINE_STATUS)) + if (itemName.equals(Constants.ONLINE_STATUS)) { - if(!protocolProvider.isRegistered()) { - GuiActivator.getUIService().getLoginManager() - .login(protocolProvider); + if (!protocolProvider.isRegistered()) + { + GuiActivator.getUIService().getLoginManager().login( + protocolProvider); } } else { - if( !protocolProvider.getRegistrationState() - .equals(RegistrationState.UNREGISTERED) - && !protocolProvider.getRegistrationState() - .equals(RegistrationState.UNREGISTERING)) + RegistrationState registrationState = + protocolProvider.getRegistrationState(); + + if (!registrationState.equals(RegistrationState.UNREGISTERED) + && !registrationState.equals(RegistrationState.UNREGISTERING)) { - try { + try + { GuiActivator.getUIService().getLoginManager() .setManuallyDisconnected(true); protocolProvider.unregister(); } - catch (OperationFailedException e1) { + catch (OperationFailedException e1) + { logger.error("Unable to unregister the protocol provider: " - + protocolProvider - + " due to the following exception: " + e1); + + protocolProvider + + " due to the following exception: " + e1); } } } @@ -152,25 +149,22 @@ public class SimpleStatusMenu tooltip = tooltip.substring(0, tooltip.lastIndexOf("<br>")); - SelectedObject selectedObject; - if(protocolProvider.isRegistered()) + if (protocolProvider.isRegistered()) { - selectedObject = new SelectedObject(onlineIcon, onlineItem); - - setSelected(selectedObject); + setSelected(new SelectedObject(onlineIcon, onlineItem)); + // TODO Technically, we're not closing the html element. this.setToolTipText(tooltip.concat("<br>" + onlineItem.getText())); } else { - selectedObject = new SelectedObject(offlineIcon, offlineItem); - - setSelected(selectedObject); + setSelected(new SelectedObject(offlineIcon, offlineItem)); this.setToolTipText(tooltip.concat("<br>" + offlineItem.getText())); } } public void updateStatus(Object status) - {} + { + } } diff --git a/src/net/java/sip/communicator/impl/protocol/AccountManagerImpl.java b/src/net/java/sip/communicator/impl/protocol/AccountManagerImpl.java index 51315d4..707c0fb 100644 --- a/src/net/java/sip/communicator/impl/protocol/AccountManagerImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/AccountManagerImpl.java @@ -538,12 +538,10 @@ public class AccountManagerImpl }
// store the rest of the properties
- Map accountProperties = accountID.getAccountProperties();
+ Map<?, ?> accountProperties = accountID.getAccountProperties();
- for (Iterator entryIter = accountProperties.entrySet().iterator();
- entryIter.hasNext();)
+ for (Map.Entry entry : accountProperties.entrySet())
{
- Map.Entry entry = (Map.Entry) entryIter.next();
String property = (String) entry.getKey();
String value = (String) entry.getValue();
diff --git a/src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java b/src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java index 39f44fc..92f53e0 100644 --- a/src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java +++ b/src/net/java/sip/communicator/impl/protocol/dict/DictAccountID.java @@ -35,27 +35,25 @@ public class DictAccountID */ public String getHost() { - return (String) this.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_ADDRESS); + return getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS); } - + /** * Returns the dict server port * @return the dict server port */ public int getPort() { - return Integer.parseInt((String) this.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_PORT)); + return Integer + .parseInt(getAccountPropertyString(ProtocolProviderFactory.SERVER_PORT)); } - + /** * Returns the selected strategy * @return the selected strategy */ public String getStrategy() { - return (String) this.getAccountProperties() - .get(ProtocolProviderFactory.STRATEGY); + return getAccountPropertyString(ProtocolProviderFactory.STRATEGY); } } diff --git a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java index 77de1a9..df4bb2c 100644 --- a/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/icq/ProtocolProviderServiceIcqImpl.java @@ -311,12 +311,12 @@ public class ProtocolProviderServiceIcqImpl new Screenname(getAccountID().getUserID())); String proxyAddress = - (String)getAccountID().getAccountProperties().get( + getAccountID().getAccountPropertyString( ProtocolProviderFactory.PROXY_ADDRESS); if(proxyAddress != null && proxyAddress.length() > 0) { String proxyPortStr = - (String)getAccountID().getAccountProperties().get( + getAccountID().getAccountPropertyString( ProtocolProviderFactory.PROXY_PORT); int proxyPort; try @@ -330,7 +330,7 @@ public class ProtocolProviderServiceIcqImpl } String proxyType = - (String)getAccountID().getAccountProperties().get( + getAccountID().getAccountPropertyString( ProtocolProviderFactory.PROXY_TYPE); if(proxyType == null) @@ -338,10 +338,10 @@ public class ProtocolProviderServiceIcqImpl OperationFailedException.INVALID_ACCOUNT_PROPERTIES); String proxyUsername = - (String)getAccountID().getAccountProperties().get( + getAccountID().getAccountPropertyString( ProtocolProviderFactory.PROXY_USERNAME); String proxyPassword = - (String)getAccountID().getAccountProperties().get( + getAccountID().getAccountPropertyString( ProtocolProviderFactory.PROXY_PASSWORD); if(proxyType.equals("http")) diff --git a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java index 22bccff..4fea981 100644 --- a/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/irc/ProtocolProviderServiceIrcImpl.java @@ -152,14 +152,16 @@ public class ProtocolProviderServiceIrcImpl public void register(SecurityAuthority authority) throws OperationFailedException { - Map accountProperties = getAccountID().getAccountProperties(); - - String serverAddress = (String) accountProperties - .get(ProtocolProviderFactory.SERVER_ADDRESS); - - String serverPort = (String) accountProperties - .get(ProtocolProviderFactory.SERVER_PORT); - + AccountID accountID = getAccountID(); + + String serverAddress = + accountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS); + + String serverPort = + accountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_PORT); + if(serverPort == null || serverPort.equals("")) { serverPort = "6667"; @@ -169,25 +171,13 @@ public class ProtocolProviderServiceIrcImpl String serverPassword = IrcActivator. getProtocolProviderFactory().loadPassword(getAccountID()); - boolean autoNickChange = true; - - boolean passwordRequired = true; - - if(accountProperties - .get(ProtocolProviderFactory.AUTO_CHANGE_USER_NAME) != null) - { - autoNickChange = new Boolean((String)accountProperties - .get(ProtocolProviderFactory.AUTO_CHANGE_USER_NAME)) - .booleanValue(); - } - - if(accountProperties - .get(ProtocolProviderFactory.NO_PASSWORD_REQUIRED) != null) - { - passwordRequired = new Boolean((String) accountProperties - .get(ProtocolProviderFactory.NO_PASSWORD_REQUIRED)) - .booleanValue(); - } + boolean autoNickChange = + accountID.getAccountPropertyBoolean( + ProtocolProviderFactory.AUTO_CHANGE_USER_NAME, true); + + boolean passwordRequired = + accountID.getAccountPropertyBoolean( + ProtocolProviderFactory.NO_PASSWORD_REQUIRED, true); //if we don't - retrieve it from the user through the security authority if (serverPassword == null && passwordRequired) diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java index d7459cc..d173127 100644 --- a/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/jabber/ProtocolProviderServiceJabberImpl.java @@ -292,17 +292,17 @@ public class ProtocolProviderServiceJabberImpl String serviceName = StringUtils.parseServer(getAccountID().getUserID()); - String serverAddress = (String)getAccountID(). - getAccountProperties().get( - ProtocolProviderFactory.SERVER_ADDRESS); + String serverAddress = + getAccountID().getAccountPropertyString( + ProtocolProviderFactory.SERVER_ADDRESS); - String serverPort = (String)getAccountID(). - getAccountProperties().get( - ProtocolProviderFactory.SERVER_PORT); + String serverPort = + getAccountID().getAccountPropertyString( + ProtocolProviderFactory.SERVER_PORT); - String accountResource = (String)getAccountID(). - getAccountProperties().get( - ProtocolProviderFactory.RESOURCE); + String accountResource = + getAccountID().getAccountPropertyString( + ProtocolProviderFactory.RESOURCE); // check to see is there SRV records for this server domain try @@ -467,8 +467,8 @@ public class ProtocolProviderServiceJabberImpl this.accountID = accountID; String protocolIconPath = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROTOCOL_ICON_PATH); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROTOCOL_ICON_PATH); if (protocolIconPath == null) { protocolIconPath = "resources/images/protocol/jabber"; @@ -482,12 +482,12 @@ public class ProtocolProviderServiceJabberImpl //this feature is mandatory to be compliant with Service Discovery supportedFeatures.add("http://jabber.org/protocol/disco#info"); + String keepAliveStrValue = + accountID.getAccountPropertyString("SEND_KEEP_ALIVE"); - String keepAliveStrValue = (String)accountID.getAccountProperties(). - get("SEND_KEEP_ALIVE"); - - String resourcePriority = (String)accountID.getAccountProperties(). - get(ProtocolProviderFactory.RESOURCE_PRIORITY); + String resourcePriority = + accountID + .getAccountPropertyString(ProtocolProviderFactory.RESOURCE_PRIORITY); //initialize the presence operationset OperationSetPersistentPresenceJabberImpl persistentPresence = @@ -495,8 +495,8 @@ public class ProtocolProviderServiceJabberImpl if(resourcePriority != null) { - persistentPresence.setResourcePriority( - new Integer(resourcePriority).intValue()); + persistentPresence.setResourcePriority(Integer + .parseInt(resourcePriority)); // TODO : is this resource priority related to xep-0168 // (Resource Application Priority) ? // see http://www.xmpp.org/extensions/xep-0168.html @@ -521,10 +521,9 @@ public class ProtocolProviderServiceJabberImpl OperationSetBasicInstantMessagingJabberImpl basicInstantMessaging = new OperationSetBasicInstantMessagingJabberImpl(this); - if(keepAliveStrValue != null) - basicInstantMessaging. - setKeepAliveEnabled( - new Boolean(keepAliveStrValue).booleanValue()); + if (keepAliveStrValue != null) + basicInstantMessaging.setKeepAliveEnabled(Boolean + .parseBoolean(keepAliveStrValue)); supportedOperationSets.put( OperationSetBasicInstantMessaging.class.getName(), diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ClientCapabilities.java b/src/net/java/sip/communicator/impl/protocol/sip/ClientCapabilities.java index f9b7b1c..ff734e9 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ClientCapabilities.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ClientCapabilities.java @@ -437,44 +437,30 @@ public class ClientCapabilities } } else if (evt.getNewState().equals(RegistrationState.REGISTERED)) { - String keepAliveMethod = (String)provider.getAccountID(). - getAccountProperties(). - get(ProtocolProviderServiceSipImpl.KEEP_ALIVE_METHOD); + String keepAliveMethod = + provider.getAccountID().getAccountPropertyString( + ProtocolProviderServiceSipImpl.KEEP_ALIVE_METHOD); logger.trace("Keep alive method " + keepAliveMethod); if(keepAliveMethod == null || !keepAliveMethod.equalsIgnoreCase("options")) return; - String keepAliveIntStr = (String)provider.getAccountID(). - getAccountProperties(). - get(ProtocolProviderServiceSipImpl.KEEP_ALIVE_INTERVAL); + int keepAliveInterval = + provider.getAccountID().getAccountPropertyInt( + ProtocolProviderServiceSipImpl.KEEP_ALIVE_INTERVAL, -1); - logger.trace("Keep alive inerval is " + keepAliveIntStr); - if(keepAliveIntStr != null) + logger.trace("Keep alive inerval is " + keepAliveInterval); + if (keepAliveInterval > 0 + && !provider.getRegistrarConnection().isRegistrarless()) { - int keepAliveInterval = -1; - try - { - keepAliveInterval = Integer.valueOf(keepAliveIntStr) - .intValue(); - } - catch (Exception ex) - { - logger.error("Wrong value for keep-alive interval"); - } + if (keepAliveTimer == null) + keepAliveTimer = new Timer(); - if(keepAliveInterval > 0 - && !provider.getRegistrarConnection().isRegistrarless()) - { - if(keepAliveTimer == null) - keepAliveTimer = new Timer(); - - logger.debug("Scheduling OPTIONS keep alives"); + logger.debug("Scheduling OPTIONS keep alives"); - keepAliveTimer.schedule( - new KeepAliveTask(), 0, keepAliveInterval * 1000); - } + keepAliveTimer.schedule(new KeepAliveTask(), 0, + keepAliveInterval * 1000); } } } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicInstantMessagingSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicInstantMessagingSipImpl.java index 3760867..dee7196 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicInstantMessagingSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/OperationSetBasicInstantMessagingSipImpl.java @@ -62,7 +62,7 @@ public class OperationSetBasicInstantMessagingSipImpl /** * It can be implemented in some servers. */ - private boolean offlineMessageSupported = false; + private final boolean offlineMessageSupported; /** * Gives access to presence states for the Sip protocol. @@ -83,12 +83,9 @@ public class OperationSetBasicInstantMessagingSipImpl provider.addRegistrationStateChangeListener(new RegistrationStateListener()); - Object isOffMsgsSupported = provider.getAccountID(). - getAccountProperties().get("OFFLINE_MSG_SUPPORTED"); - - if(isOffMsgsSupported != null && - Boolean.valueOf((String)isOffMsgsSupported).booleanValue()) - offlineMessageSupported = true; + offlineMessageSupported = + provider.getAccountID().getAccountPropertyBoolean( + "OFFLINE_MSG_SUPPORTED", false); sipProvider.registerMethodProcessor(Request.MESSAGE, new BasicInstantMessagingMethodProcessor()); diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java index 4661c5b..1873fe1 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java @@ -367,8 +367,9 @@ public class ProtocolProviderServiceSipImpl this.accountID = accountID; - String protocolIconPath = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.PROTOCOL_ICON_PATH); + String protocolIconPath = + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROTOCOL_ICON_PATH); if (protocolIconPath == null) protocolIconPath = "resources/images/protocol/sip"; @@ -412,53 +413,19 @@ public class ProtocolProviderServiceSipImpl sipStackSharing = new SipStackSharing(); // get the presence options - String enablePresenceObj = (String) accountID - .getAccountProperties().get( - ProtocolProviderFactory.IS_PRESENCE_ENABLED); - - boolean enablePresence = true; - if (enablePresenceObj != null) { - enablePresence = Boolean.valueOf(enablePresenceObj) - .booleanValue(); - } - - String forceP2PObj = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.FORCE_P2P_MODE); + boolean enablePresence = + accountID.getAccountPropertyBoolean( + ProtocolProviderFactory.IS_PRESENCE_ENABLED, true); - boolean forceP2P = true; - if (forceP2PObj != null) { - forceP2P = Boolean.valueOf(forceP2PObj).booleanValue(); - } + boolean forceP2P = accountID.getAccountPropertyBoolean(ProtocolProviderFactory.FORCE_P2P_MODE, true); - int pollingValue = 30; - try { - String pollingString = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.POLLING_PERIOD); - if (pollingString != null) { - pollingValue = Integer.parseInt(pollingString); - } else { - logger.warn("no polling value found, using default value" - + " (" + pollingValue + ")"); - } - } catch (NumberFormatException e) { - logger.error("wrong polling value stored", e); - } + int pollingValue = + accountID.getAccountPropertyInt( + ProtocolProviderFactory.POLLING_PERIOD, 30); - int subscriptionExpiration = 3600; - try { - String subscriptionString = (String) accountID - .getAccountProperties().get(ProtocolProviderFactory - .SUBSCRIPTION_EXPIRATION); - if (subscriptionString != null) { - subscriptionExpiration = Integer.parseInt( - subscriptionString); - } else { - logger.warn("no expiration value found, using default value" - + " (" + subscriptionExpiration + ")"); - } - } catch (NumberFormatException e) { - logger.error("wrong expiration value stored", e); - } + int subscriptionExpiration = + accountID.getAccountPropertyInt( + ProtocolProviderFactory.SUBSCRIPTION_EXPIRATION, 3600); //create SIP factories. headerFactory = new HeaderFactoryImpl(); @@ -523,8 +490,9 @@ public class ProtocolProviderServiceSipImpl new ClientCapabilities(this); //initialize our display name - ourDisplayName = (String)accountID.getAccountProperties() - .get(ProtocolProviderFactory.DISPLAY_NAME); + ourDisplayName = + accountID + .getAccountPropertyString(ProtocolProviderFactory.DISPLAY_NAME); if(ourDisplayName == null || ourDisplayName.trim().length() == 0) @@ -1259,15 +1227,17 @@ public class ProtocolProviderServiceSipImpl throws IllegalArgumentException { //First init the registrar address - String registrarAddressStr = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_ADDRESS); + String registrarAddressStr = + accountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS); //if there is no registrar address, parse the user_id and extract it //from the domain part of the SIP URI. if (registrarAddressStr == null) { - String userID = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.USER_ID); + String userID = + accountID + .getAccountPropertyString(ProtocolProviderFactory.USER_ID); int index = userID.indexOf("@"); if ( index > -1 ) registrarAddressStr = userID.substring( index+1); @@ -1292,8 +1262,9 @@ public class ProtocolProviderServiceSipImpl try { // first check for srv records exists - String registrarTransport = (String)accountID.getAccountProperties() - .get(ProtocolProviderFactory.PREFERRED_TRANSPORT); + String registrarTransport = + accountID + .getAccountPropertyString(ProtocolProviderFactory.PREFERRED_TRANSPORT); if(registrarTransport == null) registrarTransport = getDefaultTransport(); @@ -1310,7 +1281,7 @@ public class ProtocolProviderServiceSipImpl // address. And this is needed because in the case we don't have // network while loading the application we still want to have our // accounts loaded. - accountID.putProperty( + accountID.putAccountProperty( ProtocolProviderFactory.SERVER_ADDRESS_VALIDATED, Boolean.toString(true)); @@ -1321,26 +1292,23 @@ public class ProtocolProviderServiceSipImpl + " appears to be an either invalid or inaccessible address: " , ex); - String serverValidatedString - = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_ADDRESS_VALIDATED); - - boolean isServerValidated = false; - if (serverValidatedString != null) - isServerValidated = new Boolean(serverValidatedString) - .booleanValue(); + boolean isServerValidated = + accountID.getAccountPropertyBoolean( + ProtocolProviderFactory.SERVER_ADDRESS_VALIDATED, false); - // We should check here if the server address was already validated. - // When we load stored accounts we want to prevent checking again the - // server address. This is needed because in the case we don't have - // network while loading the application we still want to have our - // accounts loaded. - if (serverValidatedString == null || !isServerValidated) + /* + * We should check here if the server address was already validated. + * When we load stored accounts we want to prevent checking again + * the server address. This is needed because in the case we don't + * have network while loading the application we still want to have + * our accounts loaded. + */ + if (!isServerValidated) { throw new IllegalArgumentException( registrarAddressStr - + " appears to be an either invalid or inaccessible address: " - + ex.getMessage()); + + " appears to be an either invalid or inaccessible address: " + + ex.getMessage()); } } @@ -1360,35 +1328,21 @@ public class ProtocolProviderServiceSipImpl return; } - //check if user has overridden the registrar port. - String registrarPortStr = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_PORT); - - if(registrarPortStr != null && registrarPortStr.length() > 0) + // check if user has overridden the registrar port. + registrarPort = + accountID.getAccountPropertyInt( + ProtocolProviderFactory.SERVER_PORT, registrarPort); + if (registrarPort > NetworkUtils.MAX_PORT_NUMBER) { - try - { - registrarPort = Integer.parseInt(registrarPortStr); - } - catch (NumberFormatException ex) - { - logger.error( - registrarPortStr - + " is not a valid port value. Expected an integer" - , ex); - } - - if ( registrarPort > NetworkUtils.MAX_PORT_NUMBER) - { - throw new IllegalArgumentException(registrarPort - + " is larger than " + NetworkUtils.MAX_PORT_NUMBER - + " and does not therefore represent a valid port nubmer."); - } + throw new IllegalArgumentException(registrarPort + + " is larger than " + NetworkUtils.MAX_PORT_NUMBER + + " and does not therefore represent a valid port nubmer."); } //registrar transport - String registrarTransport = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.PREFERRED_TRANSPORT); + String registrarTransport = + accountID + .getAccountPropertyString(ProtocolProviderFactory.PREFERRED_TRANSPORT); if(registrarTransport != null && registrarTransport.length() > 0) { @@ -1407,25 +1361,10 @@ public class ProtocolProviderServiceSipImpl } //init expiration timeout - int expires = SipRegistrarConnection.DEFAULT_REGISTRATION_EXPIRATION; - - String expiresStr = SipActivator.getConfigurationService().getString( - REGISTRATION_EXPIRATION); - - if(expiresStr != null && expiresStr.length() > 0) - { - try - { - expires = Integer.parseInt(expiresStr); - } - catch (NumberFormatException ex) - { - logger.error( - expiresStr - + " is not a valid expires value. Expexted an integer" - , ex); - } - } + int expires = + SipActivator.getConfigurationService().getInt( + REGISTRATION_EXPIRATION, + SipRegistrarConnection.DEFAULT_REGISTRATION_EXPIRATION); //Initialize our connection with the registrar try @@ -1437,14 +1376,9 @@ public class ProtocolProviderServiceSipImpl , expires , this); - //determine whether we should be using route headers or not - String useRouteString = (String) accountID.getAccountProperties() - .get(REGISTERS_USE_ROUTE); - - boolean useRoute = false; - - if (useRouteString != null) - useRoute = new Boolean(useRouteString).booleanValue(); + // determine whether we should be using route headers or not + boolean useRoute = + accountID.getAccountPropertyBoolean(REGISTERS_USE_ROUTE, false); this.sipRegistrarConnection.setRouteHeaderEnabled(useRoute); } @@ -1473,8 +1407,9 @@ public class ProtocolProviderServiceSipImpl throws IllegalArgumentException { //registrar transport - String registrarTransport = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.PREFERRED_TRANSPORT); + String registrarTransport = + accountID + .getAccountPropertyString(ProtocolProviderFactory.PREFERRED_TRANSPORT); if(registrarTransport != null && registrarTransport.length() > 0) { @@ -1611,8 +1546,9 @@ public class ProtocolProviderServiceSipImpl private void initOutboundProxy(SipAccountID accountID) { //First init the proxy address - String proxyAddressStr = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.PROXY_ADDRESS); + String proxyAddressStr = + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_ADDRESS); if(proxyAddressStr == null || proxyAddressStr.trim().length() == 0) return; @@ -1625,8 +1561,9 @@ public class ProtocolProviderServiceSipImpl try { // first check for srv records exists - String proxyTransport = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.PREFERRED_TRANSPORT); + String proxyTransport = + accountID + .getAccountPropertyString(ProtocolProviderFactory.PREFERRED_TRANSPORT); if(proxyTransport == null) proxyTransport = getDefaultTransport(); @@ -1647,7 +1584,7 @@ public class ProtocolProviderServiceSipImpl // address. this is needed because in the case we don't have // network while loading the application we still want to have // our accounts loaded. - accountID.putProperty( + accountID.putAccountProperty( ProtocolProviderFactory.PROXY_ADDRESS_VALIDATED, Boolean.toString(true)); } @@ -1657,21 +1594,16 @@ public class ProtocolProviderServiceSipImpl + " appears to be an either invalid or inaccessible address" , ex); - String proxyValidatedString = (String) accountID - .getAccountProperties().get( - ProtocolProviderFactory.PROXY_ADDRESS_VALIDATED); - - boolean isProxyValidated = false; - if (proxyValidatedString != null) - isProxyValidated - = new Boolean(proxyValidatedString).booleanValue(); + boolean isProxyValidated = + accountID.getAccountPropertyBoolean( + ProtocolProviderFactory.PROXY_ADDRESS_VALIDATED, false); // We should check here if the proxy address was already validated. // When we load stored accounts we want to prevent checking again the // proxy address. This is needed because in the case we don't have // network while loading the application we still want to have our // accounts loaded. - if (proxyValidatedString == null || !isProxyValidated) + if (!isProxyValidated) { throw new IllegalArgumentException( proxyAddressStr @@ -1689,36 +1621,20 @@ public class ProtocolProviderServiceSipImpl } //check if user has overridden proxy port. - String proxyPortStr = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.PROXY_PORT); - - if (proxyPortStr != null && proxyPortStr.length() > 0) + proxyPort = + accountID.getAccountPropertyInt(ProtocolProviderFactory.PROXY_PORT, + proxyPort); + if (proxyPort > NetworkUtils.MAX_PORT_NUMBER) { - try - { - proxyPort = Integer.parseInt(proxyPortStr); - } - catch (NumberFormatException ex) - { - logger.error( - proxyPortStr - + " is not a valid port value. Expected an integer" - , ex); - } - - if (proxyPort > NetworkUtils.MAX_PORT_NUMBER) - { - throw new IllegalArgumentException(proxyPort - + " is larger than " + - NetworkUtils.MAX_PORT_NUMBER - + - " and does not therefore represent a valid port nubmer."); - } + throw new IllegalArgumentException(proxyPort + " is larger than " + + NetworkUtils.MAX_PORT_NUMBER + + " and does not therefore represent a valid port nubmer."); } //proxy transport - String proxyTransport = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.PREFERRED_TRANSPORT); + String proxyTransport = + accountID + .getAccountPropertyString(ProtocolProviderFactory.PREFERRED_TRANSPORT); if (proxyTransport != null && proxyTransport.length() > 0) { diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java b/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java index 2c55a4d..4202d48 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipAccountID.java @@ -66,17 +66,6 @@ public class SipAccountID } /** - * Adds a property to the map of properties for this account identifier. - * - * @param key the key of the property - * @param value the property value - */ - public void putProperty(Object key, Object value) - { - accountProperties.put(key, value); - } - - /** * The reason we need to override this method here comes from the fact * that the user id that is standardly returned by the parent method * is not sufficient for the user to distinguish this account from other @@ -90,8 +79,8 @@ public class SipAccountID { String returnValue = getUserID(); - String protocolName = (String)getAccountProperties() - .get(ProtocolProviderFactory.PROTOCOL); + String protocolName = + getAccountPropertyString(ProtocolProviderFactory.PROTOCOL); String service = getService(); if (service == null || service.trim().length() == 0) diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java b/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java index 2f13fcc..2bce2ca 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java @@ -99,7 +99,7 @@ public class SipRegistrarConnection /** * Default value for keep-alive method - register */ - private static final String KEEP_ALIVE_INTERVAL_DEFAULT_VALUE = "25"; + private static final int KEEP_ALIVE_INTERVAL_DEFAULT_VALUE = 25; /** * Specifies whether or not we should be using a route header in register @@ -517,33 +517,20 @@ public class SipRegistrarConnection // If KEEP_ALIVE_METHOD is null we default send registers on // interval of 25 seconds String keepAliveMethod = - (String)sipProvider.getAccountID().getAccountProperties(). - get(KEEP_ALIVE_METHOD); + sipProvider.getAccountID().getAccountPropertyString( + KEEP_ALIVE_METHOD); if((keepAliveMethod != null && keepAliveMethod.equalsIgnoreCase("register")) || keepAliveMethod == null ) { - String keepAliveInterval = - (String)sipProvider.getAccountID().getAccountProperties(). - get(KEEP_ALIVE_INTERVAL); + int registrationInterval = + sipProvider.getAccountID().getAccountPropertyInt( + KEEP_ALIVE_INTERVAL, KEEP_ALIVE_INTERVAL_DEFAULT_VALUE); - if(keepAliveInterval == null) - keepAliveInterval = KEEP_ALIVE_INTERVAL_DEFAULT_VALUE; - - try - { - int registrationInterval = - Integer.valueOf(keepAliveInterval).intValue(); - - if(registrationInterval < grantedExpiration) - { - scheduleTime = registrationInterval; - } - } - catch (Exception ex) + if (registrationInterval < grantedExpiration) { - logger.error("Wrong value for KEEP_ALIVE_INTERVAL"); + scheduleTime = registrationInterval; } } @@ -1293,8 +1280,9 @@ public class SipRegistrarConnection return null; //create our own address. - String ourUserID = (String)sipProvider.getAccountID() - .getAccountProperties().get(ProtocolProviderFactory.USER_ID); + String ourUserID = + sipProvider.getAccountID().getAccountPropertyString( + ProtocolProviderFactory.USER_ID); String sipUriHost = null; if( ourUserID.indexOf("@") != -1 diff --git a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java index 3230cfc..981b64f 100644 --- a/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/ssh/ProtocolProviderServiceSSHImpl.java @@ -375,14 +375,14 @@ public class ProtocolProviderServiceSSHImpl // creating a new JSch Stack identifier for contact JSch jsch = new JSch(); - String knownHosts = (String)accountID - .getAccountProperties().get("KNOWN_HOSTS_FILE"); - + String knownHosts = + accountID.getAccountPropertyString("KNOWN_HOSTS_FILE"); + if(!knownHosts.equals("Optional")) jsch.setKnownHosts(knownHosts); - - String identitiyKey = (String)accountID - .getAccountProperties().get("IDENTITY_FILE"); + + String identitiyKey = + accountID.getAccountPropertyString("IDENTITY_FILE"); String userName = sshContact.getUserName(); diff --git a/src/net/java/sip/communicator/impl/systray/jdic/StatusSubMenu.java b/src/net/java/sip/communicator/impl/systray/jdic/StatusSubMenu.java index 1d5a96f..5b178c0 100644 --- a/src/net/java/sip/communicator/impl/systray/jdic/StatusSubMenu.java +++ b/src/net/java/sip/communicator/impl/systray/jdic/StatusSubMenu.java @@ -184,9 +184,9 @@ public class StatusSubMenu = (ProtocolProviderService) SystrayActivator.bundleContext .getService(protocolProviderRefs[i]); - boolean isHidden = - provider.getAccountID().getAccountProperties(). - get(ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; + boolean isHidden = + provider.getAccountID().getAccountProperty( + ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; if(!isHidden) this.addAccount(provider); diff --git a/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoForm.java b/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoForm.java index 3ef44b4..8b0bee9 100644 --- a/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoForm.java +++ b/src/net/java/sip/communicator/plugin/accountinfo/AccountInfoForm.java @@ -71,9 +71,9 @@ public class AccountInfoForm {
accountID = (AccountID) accountsList.get(i);
- boolean isHidden =
- accountID.getAccountProperties()
- .get(ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null;
+ boolean isHidden =
+ accountID
+ .getAccountProperty(ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null;
if(!isHidden)
hasRegisteredAccounts = true;
diff --git a/src/net/java/sip/communicator/plugin/aimaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/aimaccregwizz/FirstWizardPage.java index 8df2f43..0e6a239 100644 --- a/src/net/java/sip/communicator/plugin/aimaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/aimaccregwizz/FirstWizardPage.java @@ -392,8 +392,8 @@ public class FirstWizardPage { AccountID accountID = protocolProvider.getAccountID(); String password = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PASSWORD); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PASSWORD); this.uinField.setEnabled(false); this.uinField.setText(accountID.getUserID()); @@ -406,24 +406,24 @@ public class FirstWizardPage } String proxyAddress = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_ADDRESS); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_ADDRESS); String proxyPort = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_PORT); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_PORT); String proxyType = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_TYPE); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_TYPE); String proxyUsername = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_USERNAME); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_USERNAME); String proxyPassword = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_PASSWORD); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_PASSWORD); if (proxyAddress != null || proxyPort != null || proxyType != null || proxyUsername != null diff --git a/src/net/java/sip/communicator/plugin/dictaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/dictaccregwizz/FirstWizardPage.java index 4c65b41..02a5489 100644 --- a/src/net/java/sip/communicator/plugin/dictaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/dictaccregwizz/FirstWizardPage.java @@ -313,11 +313,14 @@ public class FirstWizardPage boolean isModified = false; if (this.initAccountID instanceof AccountID) - { // We check if there is modifications to the server - String accHost = (String) this.initAccountID.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_ADDRESS); - int accPort = Integer.parseInt((String) this.initAccountID.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_PORT)); + { // We check if there is modifications to the server + String accHost = + this.initAccountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS); + int accPort = + Integer + .parseInt(this.initAccountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_PORT)); if (accHost != host || accPort != port) { @@ -470,12 +473,15 @@ public class FirstWizardPage public void loadAccount(ProtocolProviderService protocolProvider) { AccountID accountID = protocolProvider.getAccountID(); - String host = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_ADDRESS); - String port = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_PORT); - String strategy = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.STRATEGY); + String host = + accountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS); + String port = + accountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_PORT); + String strategy = + accountID + .getAccountPropertyString(ProtocolProviderFactory.STRATEGY); this.initAccountID = accountID; @@ -530,22 +536,23 @@ public class FirstWizardPage ProtocolProviderFactory factory = DictAccRegWizzActivator.getDictProtocolProviderFactory(); - ArrayList registeredAccounts = factory.getRegisteredAccounts(); - String accHost; int accPort; - for (int i = 0; i < registeredAccounts.size(); i++) + for (AccountID accountID : factory.getRegisteredAccounts()) { - AccountID accountID = (AccountID) registeredAccounts.get(i); - accHost = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_ADDRESS); + accHost = + accountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS); if (host.equalsIgnoreCase(accHost)) { - // We check the port, only if there is an account with the same host - accPort = Integer.parseInt((String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_PORT)); + // We check the port, only if there is an account with the same + // host + accPort = + Integer + .parseInt(accountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_PORT)); if (port == accPort) { diff --git a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/FirstWizardPage.java index 51c249e..6fdecd4 100644 --- a/src/net/java/sip/communicator/plugin/gibberishaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/gibberishaccregwizz/FirstWizardPage.java @@ -280,8 +280,9 @@ public class FirstWizardPage public void loadAccount(ProtocolProviderService protocolProvider) { AccountID accountID = protocolProvider.getAccountID(); - String password = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.PASSWORD); + String password = + accountID + .getAccountPropertyString(ProtocolProviderFactory.PASSWORD); this.userIDField.setEnabled(false); this.userIDField.setText(accountID.getUserID()); diff --git a/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java index 9cb54de..8492540 100644 --- a/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/icqaccregwizz/FirstWizardPage.java @@ -393,8 +393,8 @@ public class FirstWizardPage { AccountID accountID = protocolProvider.getAccountID(); String password = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PASSWORD); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PASSWORD); this.uinField.setText(accountID.getUserID()); @@ -408,24 +408,24 @@ public class FirstWizardPage } String proxyAddress = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_ADDRESS); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_ADDRESS); String proxyPort = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_PORT); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_PORT); String proxyType = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_TYPE); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_TYPE); String proxyUsername = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_USERNAME); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_USERNAME); String proxyPassword = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_PASSWORD); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_PASSWORD); if (proxyAddress != null || proxyPort != null || proxyType != null || proxyUsername != null diff --git a/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java index 5374020..65bcabe 100644 --- a/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/ircaccregwizz/FirstWizardPage.java @@ -6,8 +6,6 @@ */ package net.java.sip.communicator.plugin.ircaccregwizz; -import java.util.*; - import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -371,20 +369,25 @@ public class FirstWizardPage { AccountID accountID = protocolProvider.getAccountID(); - String password = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.PASSWORD); + String password = + accountID + .getAccountPropertyString(ProtocolProviderFactory.PASSWORD); - String server = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_ADDRESS); + String server = + accountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS); - String port = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.SERVER_PORT); + String port = + accountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_PORT); - String autoNickChange = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.AUTO_CHANGE_USER_NAME); + String autoNickChange = + accountID + .getAccountPropertyString(ProtocolProviderFactory.AUTO_CHANGE_USER_NAME); - String noPasswordRequired = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactory.NO_PASSWORD_REQUIRED); + String noPasswordRequired = + accountID + .getAccountPropertyString(ProtocolProviderFactory.NO_PASSWORD_REQUIRED); this.nickField.setEnabled(false); this.nickField.setText(accountID.getUserID()); @@ -433,16 +436,10 @@ public class FirstWizardPage ProtocolProviderFactory factory = IrcAccRegWizzActivator.getIrcProtocolProviderFactory(); - ArrayList registeredAccounts = factory.getRegisteredAccounts(); - - for (int i = 0; i < registeredAccounts.size(); i++) + for (AccountID accountID : factory.getRegisteredAccounts()) { - AccountID accountID = (AccountID) registeredAccounts.get(i); - if (userID.equalsIgnoreCase(accountID.getUserID())) - { return true; - } } return false; } diff --git a/src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java index b53e50c..e81805d 100644 --- a/src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/msnaccregwizz/FirstWizardPage.java @@ -6,7 +6,6 @@ package net.java.sip.communicator.plugin.msnaccregwizz; import java.awt.*; -import java.util.*; import javax.swing.*; import javax.swing.event.*; @@ -272,8 +271,8 @@ public class FirstWizardPage { AccountID accountID = protocolProvider.getAccountID(); String password = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PASSWORD); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PASSWORD); this.uinField.setText(accountID.getUserID()); @@ -289,12 +288,8 @@ public class FirstWizardPage ProtocolProviderFactory factory = MsnAccRegWizzActivator.getMsnProtocolProviderFactory(); - ArrayList registeredAccounts = factory.getRegisteredAccounts(); - - for (int i = 0; i < registeredAccounts.size(); i++) + for (AccountID accountID : factory.getRegisteredAccounts()) { - AccountID accountID = (AccountID) registeredAccounts.get(i); - if (accountName.equalsIgnoreCase(accountID.getUserID())) return true; } diff --git a/src/net/java/sip/communicator/plugin/pluginmanager/PluginTableModel.java b/src/net/java/sip/communicator/plugin/pluginmanager/PluginTableModel.java index a3e989e..b1092b2 100644 --- a/src/net/java/sip/communicator/plugin/pluginmanager/PluginTableModel.java +++ b/src/net/java/sip/communicator/plugin/pluginmanager/PluginTableModel.java @@ -4,10 +4,10 @@ * Distributable under LGPL license. * See terms of license at gnu.org. */ - package net.java.sip.communicator.plugin.pluginmanager; import java.util.*; + import javax.swing.table.*; import org.osgi.framework.*; @@ -103,10 +103,8 @@ public class PluginTableModel extends AbstractTableModel Object sysBundleProp = bundle.getHeaders().get("System-Bundle"); - if(sysBundleProp == null || !sysBundleProp.equals("yes")) - return true; - else - return false; + return (sysBundleProp == null || !sysBundleProp + .equals("yes")); } } } @@ -213,5 +211,4 @@ public class PluginTableModel extends AbstractTableModel this.bundles = this.bundleContext.getBundles(); Arrays.sort(this.bundles, bundleComparator); } - } diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java index 22a96ad..a5ace3b 100644 --- a/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java +++ b/src/net/java/sip/communicator/plugin/simpleaccreg/SimpleAccountRegistrationActivator.java @@ -89,8 +89,8 @@ public class SimpleAccountRegistrationActivator { AccountID accountID = registeredAccountIter.next(); boolean isHidden = - accountID.getAccountProperties().get( - ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; + accountID + .getAccountProperty(ProtocolProviderFactory.IS_PROTOCOL_HIDDEN) != null; if (!isHidden) { diff --git a/src/net/java/sip/communicator/plugin/sipaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/sipaccregwizz/FirstWizardPage.java index 3835cf7..b69a003 100644 --- a/src/net/java/sip/communicator/plugin/sipaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/sipaccregwizz/FirstWizardPage.java @@ -532,56 +532,54 @@ public class FirstWizardPage { AccountID accountID = protocolProvider.getAccountID(); String password = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PASSWORD); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PASSWORD); String serverAddress = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.SERVER_ADDRESS); + accountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_ADDRESS); String serverPort = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.SERVER_PORT); + accountID + .getAccountPropertyString(ProtocolProviderFactory.SERVER_PORT); String proxyAddress = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_ADDRESS); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_ADDRESS); String proxyPort = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PROXY_PORT); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PROXY_PORT); String preferredTransport = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PREFERRED_TRANSPORT); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PREFERRED_TRANSPORT); - boolean enablePresence = new Boolean( - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.IS_PRESENCE_ENABLED)).booleanValue(); + boolean enablePresence = + accountID.getAccountPropertyBoolean( + ProtocolProviderFactory.IS_PRESENCE_ENABLED, false); - boolean forceP2P = new Boolean( - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.FORCE_P2P_MODE)).booleanValue(); - - boolean enabledDefaultEncryption = new Boolean( - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.DEFAULT_ENCRYPTION)).booleanValue(); + boolean forceP2P = + accountID.getAccountPropertyBoolean( + ProtocolProviderFactory.FORCE_P2P_MODE, false); + + boolean enabledDefaultEncryption = + accountID.getAccountPropertyBoolean( + ProtocolProviderFactory.DEFAULT_ENCRYPTION, false); String pollingPeriod = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.POLLING_PERIOD); + accountID + .getAccountPropertyString(ProtocolProviderFactory.POLLING_PERIOD); String subscriptionPeriod = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.SUBSCRIPTION_EXPIRATION); + accountID + .getAccountPropertyString(ProtocolProviderFactory.SUBSCRIPTION_EXPIRATION); - String keepAliveMethod - = (String) accountID.getAccountProperties() - .get("KEEP_ALIVE_METHOD"); + String keepAliveMethod = + accountID.getAccountPropertyString("KEEP_ALIVE_METHOD"); - String keepAliveInterval - = (String) accountID.getAccountProperties() - .get("KEEP_ALIVE_INTERVAL"); + String keepAliveInterval = + accountID.getAccountPropertyString("KEEP_ALIVE_INTERVAL"); uinField.setEnabled(false); this.uinField.setText((serverAddress == null) ? accountID.getUserID() @@ -655,21 +653,6 @@ public class FirstWizardPage } } - /** - * Disables Next Button if Port field value is incorrect - */ - private void setNextButtonAccordingToPort() - { - try - { - wizard.getWizardContainer().setNextFinishButtonEnabled(true); - } - catch (NumberFormatException ex) - { - wizard.getWizardContainer().setNextFinishButtonEnabled(false); - } - } - public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED diff --git a/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java index 82cc6ba..5b3dbc9 100644 --- a/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/sshaccregwizz/FirstWizardPage.java @@ -31,7 +31,8 @@ import net.java.sip.communicator.util.swing.*; * @author Shobhit Jindal */ public class FirstWizardPage - extends TransparentPanel implements WizardPage, DocumentListener + extends TransparentPanel + implements WizardPage, DocumentListener { public static final String FIRST_PAGE_IDENTIFIER = "FirstPageIdentifier"; @@ -260,11 +261,13 @@ public class FirstWizardPage AccountID accountID = protocolProvider.getAccountID(); - String identityFile = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactorySSH.IDENTITY_FILE); + String identityFile = + accountID + .getAccountPropertyString(ProtocolProviderFactorySSH.IDENTITY_FILE); - String knownHostsFile = (String) accountID.getAccountProperties() - .get(ProtocolProviderFactorySSH.KNOWN_HOSTS_FILE); + String knownHostsFile = + accountID + .getAccountPropertyString(ProtocolProviderFactorySSH.KNOWN_HOSTS_FILE); this.accountIDField.setText(accountID.getUserID()); diff --git a/src/net/java/sip/communicator/plugin/yahooaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/yahooaccregwizz/FirstWizardPage.java index a973db8..569c573 100644 --- a/src/net/java/sip/communicator/plugin/yahooaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/yahooaccregwizz/FirstWizardPage.java @@ -269,8 +269,8 @@ public class FirstWizardPage { AccountID accountID = protocolProvider.getAccountID(); String password = - (String) accountID.getAccountProperties().get( - ProtocolProviderFactory.PASSWORD); + accountID + .getAccountPropertyString(ProtocolProviderFactory.PASSWORD); this.uinField.setEnabled(false); this.uinField.setText(accountID.getUserID()); @@ -287,12 +287,8 @@ public class FirstWizardPage ProtocolProviderFactory factory = YahooAccRegWizzActivator.getYahooProtocolProviderFactory(); - ArrayList registeredAccounts = factory.getRegisteredAccounts(); - - for (int i = 0; i < registeredAccounts.size(); i++) + for (AccountID accountID : factory.getRegisteredAccounts()) { - AccountID accountID = (AccountID) registeredAccounts.get(i); - if (accountName.equalsIgnoreCase(accountID.getUserID())) return true; } diff --git a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/FirstWizardPage.java b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/FirstWizardPage.java index a68c329..78dfcd0 100644 --- a/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/FirstWizardPage.java +++ b/src/net/java/sip/communicator/plugin/zeroconfaccregwizz/FirstWizardPage.java @@ -6,9 +6,8 @@ */ package net.java.sip.communicator.plugin.zeroconfaccregwizz; -import java.util.*; - import java.awt.*; + import javax.swing.*; import javax.swing.event.*; @@ -339,16 +338,14 @@ public class FirstWizardPage this.userIDField.setEnabled(false); this.userIDField.setText(accountID.getUserID()); - this.firstField.setText((String)accountID.getAccountProperties() - .get("first")); - this.lastField.setText((String)accountID.getAccountProperties() - .get("last")); - this.mailField.setText((String)accountID.getAccountProperties() - .get("mail")); - Boolean remember = (Boolean)accountID.getAccountProperties() - .get("rememberContacts"); - if (remember.booleanValue()) this.rememberContacts.setSelected(true); - + this.firstField.setText(accountID.getAccountPropertyString("first")); + this.lastField.setText(accountID.getAccountPropertyString("last")); + this.mailField.setText(accountID.getAccountPropertyString("mail")); + + Boolean remember = + (Boolean) accountID.getAccountProperty("rememberContacts"); + if (remember.booleanValue()) + this.rememberContacts.setSelected(true); } /** @@ -364,16 +361,10 @@ public class FirstWizardPage ProtocolProviderFactory factory = ZeroconfAccRegWizzActivator.getZeroconfProtocolProviderFactory(); - ArrayList registeredAccounts = factory.getRegisteredAccounts(); - - for (int i = 0; i < registeredAccounts.size(); i++) + for (AccountID accountID : factory.getRegisteredAccounts()) { - AccountID accountID = (AccountID) registeredAccounts.get(i); - if (userID.equalsIgnoreCase(accountID.getUserID())) - { return true; - } } return false; } diff --git a/src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java b/src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java index 1898ac0..76dcff6 100644 --- a/src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java +++ b/src/net/java/sip/communicator/service/protocol/AbstractProtocolProviderService.java @@ -121,8 +121,9 @@ public abstract class AbstractProtocolProviderService */ public String getProtocolDisplayName() { - String displayName = (String) getAccountID().getAccountProperties() - .get(ProtocolProviderFactory.PROTOCOL); + String displayName = + getAccountID().getAccountPropertyString( + ProtocolProviderFactory.PROTOCOL); return (displayName == null) ? getProtocolName() : displayName; } diff --git a/src/net/java/sip/communicator/service/protocol/AccountID.java b/src/net/java/sip/communicator/service/protocol/AccountID.java index b88d207..b5097fc 100644 --- a/src/net/java/sip/communicator/service/protocol/AccountID.java +++ b/src/net/java/sip/communicator/service/protocol/AccountID.java @@ -8,6 +8,8 @@ package net.java.sip.communicator.service.protocol; import java.util.*; +import net.java.sip.communicator.util.*; + /** * The AccountID is an account identifier that, uniquely represents a specific * user account over a specific protocol. The class needs to be extended by @@ -18,19 +20,21 @@ import java.util.*; * <p> * Every instance of the <tt>ProtocolProviderService</tt>, created through the * ProtocolProviderFactory is assigned an AccountID instance, that uniquely - * represents it and whose string representation (obtainted through the + * represents it and whose string representation (obtained through the * getAccountUID() method) can be used for identification of persistently stored * account details. * <p> * Account id's are guaranteed to be different for different accounts and in the * same time are bound to be equal for multiple installations of the same * account. - * * @author Emil Ivov + * @author Lubomir Marinov */ public abstract class AccountID { + private static final Logger logger = Logger.getLogger(AccountID.class); + /** * Allows a specific set of account properties to override a given default * protocol name (e.g. account registration wizards which want to present a @@ -106,7 +110,6 @@ public abstract class AccountID String protocolName, String serviceName) { - super(); /* * Allow account registration wizards to override the default protocol @@ -144,8 +147,8 @@ public abstract class AccountID public String getDisplayName() { String returnValue = getUserID(); - String protocolName = (String)getAccountProperties() - .get(ProtocolProviderFactory.PROTOCOL); + String protocolName = + getAccountPropertyString(ProtocolProviderFactory.PROTOCOL); if (protocolName != null && protocolName.trim().length() > 0) returnValue += " (" + protocolName + ")"; @@ -154,8 +157,8 @@ public abstract class AccountID } /** - * Returns a String uniquely idnetifying this account, guaranteed to remain - * the same accross multiple installations of the same account and to always + * Returns a String uniquely identifying this account, guaranteed to remain + * the same across multiple installations of the same account and to always * be unique for differing accounts. * @return String */ @@ -166,15 +169,63 @@ public abstract class AccountID /** * Returns a Map containing protocol and implementation account - * initialization propeties. + * initialization properties. * @return a Map containing protocol and implementation account - * initialization propeties. + * initialization properties. */ public Map getAccountProperties() { return new Hashtable(accountProperties); } + public Object getAccountProperty(Object key) + { + return accountProperties.get(key); + } + + public boolean getAccountPropertyBoolean(Object key, boolean defaultValue) + { + String value = getAccountPropertyString(key); + return (value == null) ? defaultValue : Boolean.parseBoolean(value); + } + + public int getAccountPropertyInt(Object key, int defaultValue) + { + String stringValue = getAccountPropertyString(key); + int intValue = defaultValue; + + if (stringValue != null) + { + try + { + intValue = Integer.parseInt(stringValue); + } + catch (NumberFormatException ex) + { + logger.error("Failed to parse account property " + key + + " value " + stringValue + " as an integer", ex); + } + } + return intValue; + } + + public String getAccountPropertyString(Object key) + { + Object value = getAccountProperty(key); + return (value == null) ? null : value.toString(); + } + + /** + * Adds a property to the map of properties for this account identifier. + * + * @param key the key of the property + * @param value the property value + */ + public void putAccountProperty(Object key, Object value) + { + accountProperties.put(key, value); + } + /** * Returns a hash code value for the object. This method is * supported for the benefit of hashtables such as those provided by @@ -239,7 +290,7 @@ public abstract class AccountID /** * Returns a string that could be directly used (or easily converted to) an - * address that other users of the procotol can use to communicate with us. + * address that other users of the protocol can use to communicate with us. * By default this string is set to userid@servicename. Protocol * implementors should override it if they'd need it to respect a different * syntax. @@ -250,10 +301,9 @@ public abstract class AccountID */ public String getAccountAddress() { - if (getUserID().indexOf('@') > 0) - return getUserID(); - else - return getUserID() + "@" + getService(); + String userID = getUserID(); + return (userID.indexOf('@') > 0) ? userID + : (userID + "@" + getService()); } /** diff --git a/src/net/java/sip/communicator/service/protocol/Call.java b/src/net/java/sip/communicator/service/protocol/Call.java index 7e1e27f..466b358 100644 --- a/src/net/java/sip/communicator/service/protocol/Call.java +++ b/src/net/java/sip/communicator/service/protocol/Call.java @@ -54,7 +54,7 @@ public abstract class Call * related with the sourceProvider the associated CallSession will start * encrypted by default (where applicable) */ - private boolean defaultEncryption; + private final boolean defaultEncryption; /** * Creates a new Call instance. @@ -69,16 +69,10 @@ public abstract class Call this.protocolProvider = sourceProvider; AccountID accountID = sourceProvider.getAccountID(); - - String defaultEncryptionObj = (String) accountID - .getAccountProperties().get( - ProtocolProviderFactory.DEFAULT_ENCRYPTION); - - defaultEncryption = false; - if (defaultEncryptionObj != null) { - defaultEncryption = Boolean.valueOf(defaultEncryptionObj) - .booleanValue(); - } + + defaultEncryption = + accountID.getAccountPropertyBoolean( + ProtocolProviderFactory.DEFAULT_ENCRYPTION, false); } /** |