Minor code cleanup of recent commits.

cusax-fix
Lyubomir Marinov 17 years ago
parent 386d4d2157
commit 02563fe173

@ -15,7 +15,7 @@
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 ZrtpPanel() {
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);

@ -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() {
}

@ -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 JingleMediaSession createMediaSession(
/**
* 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 @@ private void setupPayloads() {
}
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())

@ -67,7 +67,7 @@ public AccountID installAccount( String userIDStr,
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 void modifyAccount( ProtocolProviderService protocolProvider,
// 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 void modifyAccount( ProtocolProviderService protocolProvider,
@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);
}

@ -93,7 +93,6 @@ public InitialAccountRegistrationFrame()
mainAccountsPanel.setOpaque(false);
accountsPanel.setOpaque(false);
buttonPanel.setOpaque(false);
messageArea.setOpaque(false);
messageAreaPanel.setOpaque(false);
SigninActionListener actionListener = new SigninActionListener();

@ -548,7 +548,7 @@ public AccountID loadAccount(Map<String, String> accountProperties)
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 @@ protected boolean removeStoredAccount(BundleContext bundleContext,
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 @@ protected boolean removeStoredAccount(BundleContext bundleContext,
= 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 @@ protected String findAccountPrefix(BundleContext bundleContext,
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:

Loading…
Cancel
Save