diff options
Diffstat (limited to 'src/net/java/sip/communicator/impl')
18 files changed, 265 insertions, 419 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); |