Makes OTR configurable from provisioning and defaults settings.

cusax-fix
Yana Stamcheva 13 years ago
parent a2e939f9a1
commit 90c1de2895

@ -97,3 +97,6 @@ impl.gui.PARANOIA_UI=false
impl.gui.I_DONT_CARE_THAT_MUCH_ABOUT_SECURITY=false
net.java.sip.communicator.impl.protocol.jabber.JINGLE_NODES_SEARCH_PREFIXES=relay, jinglenodes, jn, jnodes
#Indicates if the private messaging should be mandatory by default.
net.java.sip.communicator.plugin.otr.PRIVATE_MESSAGING_MANDATORY=false

@ -36,6 +36,20 @@ public class OtrActivator
private static final String OTR_CHAT_CONFIG_DISABLED_PROP
= "net.java.sip.communicator.plugin.otr.otrchatconfig.DISABLED";
/**
* A property specifying whether private messaging should be made mandatory.
*/
public static final String OTR_MANDATORY_PROP =
"net.java.sip.communicator.plugin.otr.PRIVATE_MESSAGING_MANDATORY";
/**
* A property specifying whether private messaging should be automatically
* initiated.
*/
public static final String AUTO_INIT_OTR_PROP =
"net.java.sip.communicator.plugin.otr.AUTO_INIT_PRIVATE_MESSAGING";
/**
* The {@link BundleContext} of the {@link OtrActivator}.
*/

@ -243,8 +243,30 @@ public void loadPolicy()
cbEnable.setSelected(otrEnabled);
cbAutoInitiate.setEnabled(otrEnabled);
cbRequireOtr.setEnabled(otrEnabled);
cbAutoInitiate.setSelected(otrPolicy.getEnableAlways());
cbRequireOtr.setSelected(otrPolicy.getRequireEncryption());
String autoInitPropValue
= OtrActivator.configService.getString(
OtrActivator.AUTO_INIT_OTR_PROP);
boolean isAutoInit = otrPolicy.getEnableAlways();
if (autoInitPropValue != null)
isAutoInit = Boolean.parseBoolean(autoInitPropValue);
cbAutoInitiate.setSelected(isAutoInit);
String otrMandatoryPropValue
= OtrActivator.configService.getString(
OtrActivator.OTR_MANDATORY_PROP);
String defaultOtrPropValue
= OtrActivator.resourceService.getSettingsString(
OtrActivator.OTR_MANDATORY_PROP);
boolean isMandatory = otrPolicy.getRequireEncryption();
if (otrMandatoryPropValue != null)
isMandatory = Boolean.parseBoolean(otrMandatoryPropValue);
else if (!isMandatory && defaultOtrPropValue != null)
isMandatory = Boolean.parseBoolean(defaultOtrPropValue);
cbRequireOtr.setSelected(isMandatory);
}
private SIPCommCheckBox cbEnable;
@ -292,8 +314,13 @@ public void actionPerformed(ActionEvent e)
OtrActivator.scOtrEngine
.getGlobalPolicy();
otrPolicy.setEnableAlways(((JCheckBox) e.getSource())
.isSelected());
boolean isAutoInit
= ((JCheckBox) e.getSource()).isSelected();
otrPolicy.setEnableAlways(isAutoInit);
OtrActivator.configService.setProperty(
OtrActivator.AUTO_INIT_OTR_PROP,
Boolean.toString(isAutoInit));
OtrActivator.scOtrEngine.setGlobalPolicy(otrPolicy);
@ -313,8 +340,14 @@ public void actionPerformed(ActionEvent e)
OtrPolicy otrPolicy =
OtrActivator.scOtrEngine.getGlobalPolicy();
otrPolicy.setRequireEncryption(((JCheckBox) e.getSource())
.isSelected());
boolean isRequired
= ((JCheckBox) e.getSource()).isSelected();
otrPolicy.setRequireEncryption(isRequired);
OtrActivator.configService.setProperty(
OtrActivator.OTR_MANDATORY_PROP,
Boolean.toString(isRequired));
OtrActivator.scOtrEngine.setGlobalPolicy(otrPolicy);

@ -127,7 +127,7 @@ else if (ACTION_COMMAND_CB_ENABLE.equals(actionCommand))
{
OtrPolicy policy =
OtrActivator.scOtrEngine.getContactPolicy(contact);
boolean state = ((JCheckBoxMenuItem) e.getSource()).getState();
boolean state = ((JCheckBoxMenuItem) e.getSource()).isSelected();
policy.setEnableManual(state);
OtrActivator.scOtrEngine.setContactPolicy(contact, policy);
@ -137,9 +137,12 @@ else if (ACTION_COMMAND_CB_AUTO.equals(actionCommand))
{
OtrPolicy policy =
OtrActivator.scOtrEngine.getContactPolicy(contact);
boolean state = ((JCheckBoxMenuItem) e.getSource()).getState();
boolean state = ((JCheckBoxMenuItem) e.getSource()).isSelected();
policy.setEnableAlways(state);
OtrActivator.configService.setProperty(
OtrActivator.AUTO_INIT_OTR_PROP,
Boolean.toString(state));
OtrActivator.scOtrEngine.setContactPolicy(contact, policy);
}
@ -147,9 +150,12 @@ else if (ACTION_COMMAND_CB_REQUIRE.equals(actionCommand))
{
OtrPolicy policy =
OtrActivator.scOtrEngine.getContactPolicy(contact);
boolean state = ((JCheckBoxMenuItem) e.getSource()).getState();
boolean state = ((JCheckBoxMenuItem) e.getSource()).isSelected();
policy.setRequireEncryption(state);
OtrActivator.configService.setProperty(
OtrActivator.OTR_MANDATORY_PROP,
Boolean.toString(state));
OtrActivator.scOtrEngine.setContactPolicy(contact, policy);
}
else if (ACTION_COMMAND_CB_RESET.equals(actionCommand))
@ -274,7 +280,7 @@ private void buildMenu()
JCheckBoxMenuItem cbEnable = new JCheckBoxMenuItem();
cbEnable.setText(OtrActivator.resourceService
.getI18NString("plugin.otr.menu.CB_ENABLE"));
cbEnable.setState(policy.getEnableManual());
cbEnable.setSelected(policy.getEnableManual());
cbEnable.setActionCommand(ACTION_COMMAND_CB_ENABLE);
cbEnable.addActionListener(this);
@ -282,7 +288,16 @@ private void buildMenu()
cbAlways.setText(OtrActivator.resourceService
.getI18NString("plugin.otr.menu.CB_AUTO"));
cbAlways.setEnabled(policy.getEnableManual());
cbAlways.setState(policy.getEnableAlways());
String autoInitPropValue
= OtrActivator.configService.getString(
OtrActivator.AUTO_INIT_OTR_PROP);
boolean isAutoInit = policy.getEnableAlways();
if (autoInitPropValue != null)
isAutoInit = Boolean.parseBoolean(autoInitPropValue);
cbAlways.setSelected(isAutoInit);
cbAlways.setActionCommand(ACTION_COMMAND_CB_AUTO);
cbAlways.addActionListener(this);
@ -290,7 +305,22 @@ private void buildMenu()
cbRequire.setText(OtrActivator.resourceService
.getI18NString("plugin.otr.menu.CB_REQUIRE"));
cbRequire.setEnabled(policy.getEnableManual());
cbRequire.setState(policy.getRequireEncryption());
String otrMandatoryPropValue
= OtrActivator.configService.getString(
OtrActivator.OTR_MANDATORY_PROP);
String defaultOtrPropValue
= OtrActivator.resourceService.getSettingsString(
OtrActivator.OTR_MANDATORY_PROP);
boolean isMandatory = policy.getRequireEncryption();
if (otrMandatoryPropValue != null)
isMandatory = Boolean.parseBoolean(otrMandatoryPropValue);
else if (!isMandatory && defaultOtrPropValue != null)
isMandatory = Boolean.parseBoolean(defaultOtrPropValue);
cbRequire.setSelected(isMandatory);
cbRequire.setActionCommand(ACTION_COMMAND_CB_REQUIRE);
cbRequire.addActionListener(this);

Loading…
Cancel
Save