Renames the .plugin.otr.Configurator class which is stored in OtrConfigurator.java to OtrConfigurator because NetBeans chokes on it at times with compile-time resolution errors. Besides, the naming does not seem to follow our way of writing.

Also moves the fields of the modified classes at the top of the class definitions instead of having them spread all over because it also seems to be our way of writing.
cusax-fix
Lyubomir Marinov 17 years ago
parent ff808e4616
commit 2f8b4304f2

@ -17,7 +17,7 @@
*
* @author George Politis
*/
class Configurator
public class OtrConfigurator
{
/**
* Gets an XML tag friendly {@link String} from a {@link String}.
@ -36,10 +36,12 @@ private String getXmlFriendlyString(String s)
s = "p" + s;
char[] cId = new char[s.length()];
for (int i = 0; i < cId.length; i++)
{
char c = s.charAt(i);
cId[i] = (Character.isLetterOrDigit(c)) ? c : '_';
cId[i] = Character.isLetterOrDigit(c) ? c : '_';
}
return new String(cId);
@ -54,8 +56,8 @@ private String getXmlFriendlyString(String s)
*/
private String getID(String id)
{
return "net.java.sip.communicator.plugin.otr."
+ getXmlFriendlyString(id);
return
"net.java.sip.communicator.plugin.otr." + getXmlFriendlyString(id);
}
/**
@ -69,12 +71,9 @@ private String getID(String id)
*/
public byte[] getPropertyBytes(String id)
{
String value =
(String) OtrActivator.configService.getProperty(this.getID(id));
if (value == null)
return null;
String value = OtrActivator.configService.getString(getID(id));
return Base64.decode(value.getBytes());
return (value == null) ? null : Base64.decode(value.getBytes());
}
/**
@ -89,8 +88,8 @@ public byte[] getPropertyBytes(String id)
*/
public boolean getPropertyBoolean(String id, boolean defaultValue)
{
return OtrActivator.configService.getBoolean(this.getID(id),
defaultValue);
return
OtrActivator.configService.getBoolean(getID(id), defaultValue);
}
/**
@ -105,7 +104,7 @@ public void setProperty(String id, byte[] value)
{
String valueToStore = new String(Base64.encode(value));
OtrActivator.configService.setProperty(this.getID(id), valueToStore);
OtrActivator.configService.setProperty(getID(id), valueToStore);
}
/**
@ -117,7 +116,7 @@ public void setProperty(String id, byte[] value)
*/
public void setProperty(String id, Object value)
{
OtrActivator.configService.setProperty(this.getID(id), value);
OtrActivator.configService.setProperty(getID(id), value);
}
/**
@ -128,7 +127,7 @@ public void setProperty(String id, Object value)
*/
public void removeProperty(String id)
{
OtrActivator.configService.removeProperty(this.getID(id));
OtrActivator.configService.removeProperty(getID(id));
}
/**

@ -17,17 +17,24 @@
import net.java.sip.communicator.service.protocol.*;
/**
*
* @author George Politis
*
*/
public class ScOtrEngineImpl
implements ScOtrEngine
{
private final OtrConfigurator configurator = new OtrConfigurator();
private static final Map<SessionID, Contact> contactsMap =
new Hashtable<SessionID, Contact>();
private List<ScOtrEngineListener> listeners =
private final List<String> injectedMessageUIDs = new Vector<String>();
private final List<ScOtrEngineListener> listeners =
new Vector<ScOtrEngineListener>();
private final OtrEngine otrEngine
= new OtrEngineImpl(new ScOtrEngineHost());
public void addListener(ScOtrEngineListener l)
{
synchronized (listeners)
@ -45,8 +52,6 @@ public void removeListener(ScOtrEngineListener l)
}
}
private List<String> injectedMessageUIDs = new Vector<String>();
public boolean isMessageUIDInjected(String mUID)
{
return injectedMessageUIDs.contains(mUID);
@ -94,12 +99,12 @@ public void showError(SessionID sessionID, String err)
public void injectMessage(SessionID sessionID, String messageText)
{
Contact contact = getContact(sessionID);
OperationSetBasicInstantMessaging imOpSet =
(OperationSetBasicInstantMessaging) contact
.getProtocolProvider().getOperationSet(
OperationSetBasicInstantMessaging.class);
OperationSetBasicInstantMessaging imOpSet
= contact
.getProtocolProvider()
.getOperationSet(OperationSetBasicInstantMessaging.class);
Message message = imOpSet.createMessage(messageText);
injectedMessageUIDs.add(message.getMessageUID());
imOpSet.sendInstantMessage(contact, message);
}
@ -188,11 +193,6 @@ public void sessionStatusChanged(SessionID sessionID)
});
}
private OtrEngine otrEngine = new OtrEngineImpl(new ScOtrEngineHost());
private static Map<SessionID, Contact> contactsMap =
new Hashtable<SessionID, Contact>();
public static SessionID getSessionID(Contact contact)
{
SessionID sessionID =
@ -243,8 +243,6 @@ public void startSession(Contact contact)
otrEngine.startSession(getSessionID(contact));
}
private Configurator configurator = new Configurator();
public OtrPolicy getGlobalPolicy()
{
return new OtrPolicyImpl(this.configurator.getPropertyInt("POLICY",

@ -18,6 +18,8 @@
public class ScOtrKeyManagerImpl
implements ScOtrKeyManager
{
private final OtrConfigurator configurator = new OtrConfigurator();
private final List<ScOtrKeyManagerListener> listeners =
new Vector<ScOtrKeyManagerListener>();
@ -38,8 +40,6 @@ public void removeListener(ScOtrKeyManagerListener l)
}
}
private Configurator configurator = new Configurator();
public void verify(Contact contact)
{
if ((contact == null) || isVerified(contact))

Loading…
Cancel
Save