aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/java/sip/communicator
diff options
context:
space:
mode:
authorLyubomir Marinov <lyubomir.marinov@jitsi.org>2008-12-10 23:31:09 +0000
committerLyubomir Marinov <lyubomir.marinov@jitsi.org>2008-12-10 23:31:09 +0000
commit02563fe173edaaa201d02385808d08cc6e7175d7 (patch)
tree961711bbcaf8f695cbb5b884ff7bceda374f21f5 /src/net/java/sip/communicator
parent386d4d2157a718ba6044360df7386338007f1a47 (diff)
downloadjitsi-02563fe173edaaa201d02385808d08cc6e7175d7.zip
jitsi-02563fe173edaaa201d02385808d08cc6e7175d7.tar.gz
jitsi-02563fe173edaaa201d02385808d08cc6e7175d7.tar.bz2
Minor code cleanup of recent commits.
Diffstat (limited to 'src/net/java/sip/communicator')
-rwxr-xr-xsrc/net/java/sip/communicator/impl/gui/main/call/ZrtpPanel.java13
-rw-r--r--src/net/java/sip/communicator/impl/gui/utils/SoundProperties.java91
-rw-r--r--src/net/java/sip/communicator/impl/protocol/jabber/mediamgr/JingleScMediaManager.java48
-rw-r--r--src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java6
-rw-r--r--src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java1
-rw-r--r--src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java20
6 files changed, 93 insertions, 86 deletions
diff --git a/src/net/java/sip/communicator/impl/gui/main/call/ZrtpPanel.java b/src/net/java/sip/communicator/impl/gui/main/call/ZrtpPanel.java
index b191d59..b9540dd 100755
--- a/src/net/java/sip/communicator/impl/gui/main/call/ZrtpPanel.java
+++ b/src/net/java/sip/communicator/impl/gui/main/call/ZrtpPanel.java
@@ -15,7 +15,7 @@ import javax.swing.*;
import net.java.sip.communicator.impl.gui.*;
import net.java.sip.communicator.impl.gui.utils.*;
import net.java.sip.communicator.service.gui.*;
-import net.java.sip.communicator.service.notification.NotificationService;
+import net.java.sip.communicator.service.notification.*;
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.util.swing.*;
@@ -48,8 +48,6 @@ public class ZrtpPanel extends TransparentPanel {
private boolean sasVerified = false;
private NotificationService notificationService = null;
-
- GridLayout simpleLayout = new GridLayout(0, 4);
public ZrtpPanel() {
iconEncrVerified = new ImageIcon(
@@ -57,15 +55,8 @@ public class ZrtpPanel extends TransparentPanel {
iconEncr = new ImageIcon(ImageLoader.getImage(ImageLoader.ENCR));
iconEncrDisabled = new ImageIcon(
ImageLoader.getImage(ImageLoader.ENCR_DISABLED));
- setLayout(simpleLayout);
-
- simpleLayout.setHgap(5);
- simpleLayout.setVgap(2);
- setLayout(simpleLayout);
-
- simpleLayout.setHgap(10);
- simpleLayout.setVgap(3);
+ setLayout(new GridLayout(0, 4, 10, 3));
secButton = new JButton("");
sasLabel = new JLabel("", JLabel.CENTER);
diff --git a/src/net/java/sip/communicator/impl/gui/utils/SoundProperties.java b/src/net/java/sip/communicator/impl/gui/utils/SoundProperties.java
index e9a6e8a..9b50ae8 100644
--- a/src/net/java/sip/communicator/impl/gui/utils/SoundProperties.java
+++ b/src/net/java/sip/communicator/impl/gui/utils/SoundProperties.java
@@ -7,70 +7,83 @@
package net.java.sip.communicator.impl.gui.utils;
import net.java.sip.communicator.impl.gui.*;
+import net.java.sip.communicator.service.resources.*;
/**
* Manages the access to the properties file containing all sounds paths.
*
* @author Yana Stamcheva
*/
-public class SoundProperties
+public final class SoundProperties
{
- public static String INCOMING_MESSAGE
- = GuiActivator.getResources().getSoundPath("INCOMING_MESSAGE");
+ public static final String INCOMING_MESSAGE;
- public static String OUTGOING_CALL
- = GuiActivator.getResources().getSoundPath("OUTGOING_CALL");
+ public static final String OUTGOING_CALL;
- public static String INCOMING_CALL
- = GuiActivator.getResources().getSoundPath("INCOMING_CALL");
+ public static final String INCOMING_CALL;
- public static String DIAL_ZERO
- = GuiActivator.getResources().getSoundPath("DIAL_ZERO");
+ public static final String DIAL_ZERO;
- public static String DIAL_ONE
- = GuiActivator.getResources().getSoundPath("DIAL_ONE");
+ public static final String DIAL_ONE;
- public static String DIAL_TWO
- = GuiActivator.getResources().getSoundPath("DIAL_TWO");
+ public static final String DIAL_TWO;
- public static String DIAL_THREE
- = GuiActivator.getResources().getSoundPath("DIAL_THREE");
+ public static final String DIAL_THREE;
- public static String DIAL_FOUR
- = GuiActivator.getResources().getSoundPath("DIAL_FOUR");
+ public static final String DIAL_FOUR;
- public static String DIAL_FIVE
- = GuiActivator.getResources().getSoundPath("DIAL_FIVE");
+ public static final String DIAL_FIVE;
- public static String DIAL_SIX
- = GuiActivator.getResources().getSoundPath("DIAL_SIX");
+ public static final String DIAL_SIX;
- public static String DIAL_SEVEN
- = GuiActivator.getResources().getSoundPath("DIAL_SEVEN");
+ public static final String DIAL_SEVEN;
- public static String DIAL_EIGHT
- = GuiActivator.getResources().getSoundPath("DIAL_EIGHT");
+ public static final String DIAL_EIGHT;
- public static String DIAL_NINE
- = GuiActivator.getResources().getSoundPath("DIAL_NINE");
+ public static final String DIAL_NINE;
- public static String DIAL_DIEZ
- = GuiActivator.getResources().getSoundPath("DIAL_DIEZ");
+ public static final String DIAL_DIEZ;
- public static String DIAL_STAR
- = GuiActivator.getResources().getSoundPath("DIAL_STAR");
+ public static final String DIAL_STAR;
- public static String BUSY
- = GuiActivator.getResources().getSoundPath("BUSY");
+ public static final String BUSY;
- public static String ZRTP_SECURE
- = GuiActivator.getResources().getSoundPath("ZRTP_SECURE");
+ public static final String ZRTP_SECURE;
- public static String ZRTP_ALERT
- = GuiActivator.getResources().getSoundPath("ZRTP_ALERT");
+ public static final String ZRTP_ALERT;
- private static final String BUNDLE_NAME
- = "net.java.sip.communicator.impl.gui.utils.sounds";
+ static
+ {
+
+ /*
+ * Call GuiActivator.getResources() once because (1) it's not a trivial
+ * getter, it caches the reference so it always checks whether the cache
+ * has already been built and (2) accessing a local variable is supposed
+ * to be faster than calling a method (even if the method is a trivial
+ * getter and it's inlined at runtime, it's still supposed to be slower
+ * because it will be accessing a field, not a local variable).
+ */
+ ResourceManagementService resources = GuiActivator.getResources();
+
+ INCOMING_MESSAGE = resources.getSoundPath("INCOMING_MESSAGE");
+ OUTGOING_CALL = resources.getSoundPath("OUTGOING_CALL");
+ INCOMING_CALL = resources.getSoundPath("INCOMING_CALL");
+ DIAL_ZERO = resources.getSoundPath("DIAL_ZERO");
+ DIAL_ONE = resources.getSoundPath("DIAL_ONE");
+ DIAL_TWO = resources.getSoundPath("DIAL_TWO");
+ DIAL_THREE = resources.getSoundPath("DIAL_THREE");
+ DIAL_FOUR = resources.getSoundPath("DIAL_FOUR");
+ DIAL_FIVE = resources.getSoundPath("DIAL_FIVE");
+ DIAL_SIX = resources.getSoundPath("DIAL_SIX");
+ DIAL_SEVEN = resources.getSoundPath("DIAL_SEVEN");
+ DIAL_EIGHT = resources.getSoundPath("DIAL_EIGHT");
+ DIAL_NINE = resources.getSoundPath("DIAL_NINE");
+ DIAL_DIEZ = resources.getSoundPath("DIAL_DIEZ");
+ DIAL_STAR = resources.getSoundPath("DIAL_STAR");
+ BUSY = resources.getSoundPath("BUSY");
+ ZRTP_SECURE = resources.getSoundPath("ZRTP_SECURE");
+ ZRTP_ALERT = resources.getSoundPath("ZRTP_ALERT");
+ }
private SoundProperties() {
}
diff --git a/src/net/java/sip/communicator/impl/protocol/jabber/mediamgr/JingleScMediaManager.java b/src/net/java/sip/communicator/impl/protocol/jabber/mediamgr/JingleScMediaManager.java
index 38d4ad8..acfc6bd 100644
--- a/src/net/java/sip/communicator/impl/protocol/jabber/mediamgr/JingleScMediaManager.java
+++ b/src/net/java/sip/communicator/impl/protocol/jabber/mediamgr/JingleScMediaManager.java
@@ -7,6 +7,7 @@
package net.java.sip.communicator.impl.protocol.jabber.mediamgr;
import java.util.*;
+
import net.java.sip.communicator.impl.protocol.jabber.*;
import net.java.sip.communicator.util.*;
@@ -63,13 +64,21 @@ public class JingleScMediaManager extends JingleMediaManager
/**
* Setup API supported Payloads
- *
- * http://tools.ietf.org/html/rfc3551#page-32 to view the
- * correspondence between PayloadType and codec
+ *
+ * http://tools.ietf.org/html/rfc3551#page-32 to view the correspondence
+ * between PayloadType and codec
*/
- private void setupPayloads() {
+ private void setupPayloads()
+ {
- String[] audioEnc = new String[0];
+ /*
+ * Initializing audioEnc to new String[0] isn't better than setting it
+ * to null upon an exception because the former causes an allocation.
+ * Besides, the exception is supposes to happen in rare/exceptional
+ * situations i.e. in most of the cases the allocation will immediately
+ * be thrown away as garbage. Checking for null is faster.
+ */
+ String[] audioEnc;
try
{
@@ -78,22 +87,29 @@ public class JingleScMediaManager extends JingleMediaManager
}
catch (Exception e)
{
+ audioEnc = null;
+
logger.warn("Cannot get Audio encodings!", e);
}
- for (int i = 0; i < audioEnc.length; i++)
+ if (audioEnc != null)
{
- int payloadType = MediaUtils.getPayloadType(
- Integer.parseInt(audioEnc[i]));
-
- if (MediaUtils.getPayloadName(payloadType) != null)
- {
- payloads.add(new PayloadType.Audio(payloadType
- , MediaUtils.getPayloadName(payloadType)));
- }
- else if (payloadType >= 0)
+ for (int i = 0; i < audioEnc.length; i++)
{
- payloads.add(new PayloadType.Audio(payloadType, audioEnc[i]));
+ int payloadType =
+ MediaUtils.getPayloadType(Integer.parseInt(audioEnc[i]));
+ String payloadName = MediaUtils.getPayloadName(payloadType);
+
+ if (payloadName != null)
+ {
+ payloads
+ .add(new PayloadType.Audio(payloadType, payloadName));
+ }
+ else if (payloadType >= 0)
+ {
+ payloads
+ .add(new PayloadType.Audio(payloadType, audioEnc[i]));
+ }
}
}
if (payloads.isEmpty())
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java
index 78022f3..754370b 100644
--- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java
+++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderFactorySipImpl.java
@@ -67,7 +67,7 @@ public class ProtocolProviderFactorySipImpl
throw new NullPointerException("The specified property map was null");
// serverAddress == null is OK because of registrarless support
- String serverAddress = (String)accountProperties.get(SERVER_ADDRESS);
+ String serverAddress = accountProperties.get(SERVER_ADDRESS);
if (!accountProperties.containsKey(PROTOCOL))
accountProperties.put(PROTOCOL, ProtocolNames.SIP);
@@ -161,7 +161,7 @@ public class ProtocolProviderFactorySipImpl
// and check for a password.
this.storeAccount(accountID);
- String userIDStr = (String) accountProperties.get(USER_ID);
+ String userIDStr = accountProperties.get(USER_ID);
Hashtable<String, String> properties = new Hashtable<String, String>();
properties.put(PROTOCOL, ProtocolNames.SIP);
@@ -205,7 +205,7 @@ public class ProtocolProviderFactorySipImpl
@Override
protected AccountID createAccountID(String userID, Map<String, String> accountProperties)
{
- String serverAddress = (String) accountProperties.get(SERVER_ADDRESS);
+ String serverAddress = accountProperties.get(SERVER_ADDRESS);
return new SipAccountID(userID, accountProperties, serverAddress);
}
diff --git a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java
index b48976f..82e8b0a 100644
--- a/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java
+++ b/src/net/java/sip/communicator/plugin/simpleaccreg/InitialAccountRegistrationFrame.java
@@ -93,7 +93,6 @@ public class InitialAccountRegistrationFrame
mainAccountsPanel.setOpaque(false);
accountsPanel.setOpaque(false);
buttonPanel.setOpaque(false);
- messageArea.setOpaque(false);
messageAreaPanel.setOpaque(false);
SigninActionListener actionListener = new SigninActionListener();
diff --git a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
index a7f6bc8..ca6c8ba 100644
--- a/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
+++ b/src/net/java/sip/communicator/service/protocol/ProtocolProviderFactory.java
@@ -548,7 +548,7 @@ public abstract class ProtocolProviderFactory
throw new NullPointerException(
"The specified property map was null");
- String userID = (String) accountProperties.get(USER_ID);
+ String userID = accountProperties.get(USER_ID);
if (userID == null)
throw new NullPointerException(
"The account properties contained no user id.");
@@ -655,13 +655,9 @@ public abstract class ProtocolProviderFactory
List<String> storedAccounts = configurationService.getPropertyNamesByPrefix(
sourcePackageName, true);
- Iterator<String> storedAccountsIter = storedAccounts.iterator();
-
//find an account with the corresponding id.
- while (storedAccountsIter.hasNext())
+ for (String accountRootPropertyName : storedAccounts)
{
- String accountRootPropertyName = (String) storedAccountsIter.next();
-
//unregister the account in the configuration service.
//all the properties must have been registered in the following
//hierarchy:
@@ -678,13 +674,9 @@ public abstract class ProtocolProviderFactory
= configurationService.getPropertyNamesByPrefix(
accountRootPropertyName, false);
- Iterator<String> propsIter = accountPropertyNames.iterator();
-
//set all account properties to null in order to remove them.
- while (propsIter.hasNext())
+ for (String propName : accountPropertyNames)
{
- String propName = (String) propsIter.next();
-
configurationService.setProperty(propName, null);
}
@@ -723,13 +715,9 @@ public abstract class ProtocolProviderFactory
List<String> storedAccounts = configurationService.getPropertyNamesByPrefix(
sourcePackageName, true);
- Iterator<String> storedAccountsIter = storedAccounts.iterator();
-
//find an account with the corresponding id.
- while (storedAccountsIter.hasNext())
+ for (String accountRootPropertyName : storedAccounts)
{
- String accountRootPropertyName = (String) storedAccountsIter.next();
-
//unregister the account in the configuration service.
//all the properties must have been registered in the following
//hierarchy: