aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--resources/languages/resources.properties3
-rw-r--r--src/net/java/sip/communicator/plugin/otr/OtrBuddyAuthenticationDialog.java141
-rw-r--r--src/net/java/sip/communicator/plugin/otr/OtrContactMenu.java50
-rw-r--r--src/net/java/sip/communicator/plugin/otr/OtrMetaContactButton.java11
-rw-r--r--src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java11
-rw-r--r--src/net/java/sip/communicator/plugin/otr/ScOtrEngineListener.java8
6 files changed, 172 insertions, 52 deletions
diff --git a/resources/languages/resources.properties b/resources/languages/resources.properties
index a539457..f121aca 100644
--- a/resources/languages/resources.properties
+++ b/resources/languages/resources.properties
@@ -811,6 +811,9 @@ plugin.otr.authbuddydialog.CANCEL=Cancel
plugin.otr.authbuddydialog.HELP=Help
plugin.otr.authbuddydialog.TITLE=Authenticate Buddy
plugin.otr.authbuddydialog.AUTHENTICATE_BUDDY=Authenticate Buddy
+plugin.otr.authbuddydialog.I_HAVE=I have
+plugin.otr.authbuddydialog.I_HAVE_NOT=I have not
+plugin.otr.authbuddydialog.VERIFY_ACTION=verified that this is in fact the correct fingerprint for {0}.
plugin.otr.configform.TITLE=Off-the-Record Messaging
plugin.otr.configform.DEFAULT_SETTINGS=Default Off-the-Record Settings
plugin.otr.configform.MY_PRIVATE_KEYS=My Private Keys
diff --git a/src/net/java/sip/communicator/plugin/otr/OtrBuddyAuthenticationDialog.java b/src/net/java/sip/communicator/plugin/otr/OtrBuddyAuthenticationDialog.java
index c8fa0c5..1652d67 100644
--- a/src/net/java/sip/communicator/plugin/otr/OtrBuddyAuthenticationDialog.java
+++ b/src/net/java/sip/communicator/plugin/otr/OtrBuddyAuthenticationDialog.java
@@ -31,9 +31,13 @@ public class OtrBuddyAuthenticationDialog
loadContact();
}
- JTextArea txtLocalFingerprint;
+ private JTextArea txtLocalFingerprint;
- JTextArea txtRemoteFingerprint;
+ private JTextArea txtRemoteFingerprint;
+
+ private JComboBox cbAction;
+
+ private JTextArea txtAction;
private void loadContact()
{
@@ -55,6 +59,59 @@ public class OtrBuddyAuthenticationDialog
.getI18NString("plugin.otr.authbuddydialog.REMOTE_FINGERPRINT",
new String[]
{ user, remoteFingerprint }));
+
+ // Action
+ txtAction.setText(OtrActivator.resourceService.getI18NString(
+ "plugin.otr.authbuddydialog.VERIFY_ACTION", new String[]
+ { user }));
+ }
+
+ class CustomTextArea
+ extends JTextArea
+ {
+ public CustomTextArea()
+ {
+ this.setBackground(new java.awt.Color(212, 208, 200));
+ this.setColumns(20);
+ this.setEditable(false);
+ this.setLineWrap(true);
+ this.setWrapStyleWord(true);
+ }
+ }
+
+ enum ActionComboBoxItemIndex
+ {
+ I_HAVE, I_HAVE_NOT
+ }
+
+ class ActionComboBoxItem
+ {
+ public ActionComboBoxItemIndex action;
+
+ private String text;
+
+ public ActionComboBoxItem(ActionComboBoxItemIndex actionIndex)
+ {
+ this.action = actionIndex;
+ switch (action)
+ {
+ case I_HAVE:
+ text =
+ OtrActivator.resourceService
+ .getI18NString("plugin.otr.authbuddydialog.I_HAVE");
+ break;
+ case I_HAVE_NOT:
+ text =
+ OtrActivator.resourceService
+ .getI18NString("plugin.otr.authbuddydialog.I_HAVE_NOT");
+ break;
+ }
+ }
+
+ public String toString()
+ {
+ return text;
+ }
}
private void initComponents()
@@ -67,35 +124,46 @@ public class OtrBuddyAuthenticationDialog
mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
mainPanel.setPreferredSize(new Dimension(400, 300));
- JTextArea generalInformation = new JTextArea();
- generalInformation.setBackground(new java.awt.Color(212, 208, 200));
- generalInformation.setColumns(20);
- generalInformation.setEditable(false);
- generalInformation.setLineWrap(true);
- generalInformation.setWrapStyleWord(true);
+ JTextArea generalInformation = new CustomTextArea();
generalInformation.setText(OtrActivator.resourceService
.getI18NString("plugin.otr.authbuddydialog.AUTHENTICATION_INFO"));
mainPanel.add(generalInformation);
- txtLocalFingerprint = new JTextArea();
- txtLocalFingerprint.setBackground(new java.awt.Color(212, 208, 200));
- txtLocalFingerprint.setColumns(20);
- txtLocalFingerprint.setEditable(false);
- txtLocalFingerprint.setLineWrap(true);
- generalInformation.setWrapStyleWord(true);
-
+ txtLocalFingerprint = new CustomTextArea();
mainPanel.add(txtLocalFingerprint);
- txtRemoteFingerprint = new JTextArea();
- txtRemoteFingerprint.setBackground(new java.awt.Color(212, 208, 200));
- txtRemoteFingerprint.setColumns(20);
- txtRemoteFingerprint.setEditable(false);
- txtRemoteFingerprint.setLineWrap(true);
- generalInformation.setWrapStyleWord(true);
-
+ txtRemoteFingerprint = new CustomTextArea();
mainPanel.add(txtRemoteFingerprint);
- JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
+ // Action Panel (the panel that holds the I have/I have not dropdown)
+ JPanel pnlAction = new JPanel(new GridBagLayout());
+ pnlAction.setBorder(BorderFactory.createEtchedBorder());
+ mainPanel.add(pnlAction);
+
+ GridBagConstraints c = new GridBagConstraints();
+ c.fill = GridBagConstraints.HORIZONTAL;
+ c.insets = new Insets(5, 5, 5, 5);
+ c.weightx = 0.0;
+
+ cbAction = new JComboBox();
+
+ ActionComboBoxItem iHave =
+ new ActionComboBoxItem(ActionComboBoxItemIndex.I_HAVE);
+ ActionComboBoxItem iHaveNot =
+ new ActionComboBoxItem(ActionComboBoxItemIndex.I_HAVE_NOT);
+ cbAction.addItem(iHave);
+ cbAction.addItem(iHaveNot);
+ cbAction.setSelectedItem(OtrActivator.scOtrEngine
+ .isContactVerified(contact) ? iHave : iHaveNot);
+
+ pnlAction.add(cbAction, c);
+
+ txtAction = new CustomTextArea();
+ c.weightx = 1.0;
+ pnlAction.add(txtAction, c);
+
+ // Buttons panel.
+ JPanel buttonPanel = new JPanel(new GridBagLayout());
JButton helpButton =
new JButton(OtrActivator.resourceService
@@ -107,7 +175,15 @@ public class OtrBuddyAuthenticationDialog
OtrActivator.scOtrEngine.launchHelp();
}
});
- buttonPanel.add(helpButton);
+
+ c.weightx = 0.0;
+ buttonPanel.add(helpButton, c);
+
+ // Provide space between help and the other two button, not sure if this
+ // is optimal..
+ c.weightx = 1.0;
+ buttonPanel.add(new JLabel(), c);
+ c.weightx = 0.0;
JButton cancelButton =
new JButton(OtrActivator.resourceService
@@ -119,7 +195,7 @@ public class OtrBuddyAuthenticationDialog
dispose();
}
});
- buttonPanel.add(cancelButton);
+ buttonPanel.add(cancelButton, c);
JButton authenticateButton =
new JButton(OtrActivator.resourceService
@@ -128,11 +204,22 @@ public class OtrBuddyAuthenticationDialog
{
public void actionPerformed(ActionEvent e)
{
- OtrActivator.scOtrEngine.verifyContactFingerprint(contact);
+ ActionComboBoxItem actionItem =
+ (ActionComboBoxItem) cbAction.getSelectedItem();
+ switch (actionItem.action)
+ {
+ case I_HAVE:
+ OtrActivator.scOtrEngine.verifyContactFingerprint(contact);
+ break;
+ case I_HAVE_NOT:
+ OtrActivator.scOtrEngine.forgetContactFingerprint(contact);
+ break;
+ }
+
dispose();
}
});
- buttonPanel.add(authenticateButton);
+ buttonPanel.add(authenticateButton, c);
mainPanel.add(buttonPanel);
diff --git a/src/net/java/sip/communicator/plugin/otr/OtrContactMenu.java b/src/net/java/sip/communicator/plugin/otr/OtrContactMenu.java
index 8869099..73c8b4d 100644
--- a/src/net/java/sip/communicator/plugin/otr/OtrContactMenu.java
+++ b/src/net/java/sip/communicator/plugin/otr/OtrContactMenu.java
@@ -57,6 +57,15 @@ class OtrContactMenu
setOtrPolicy(policy);
}
+
+ public void contactVerificationStatusChanged(Contact contact)
+ {
+ SessionStatus status =
+ OtrActivator.scOtrEngine.getSessionStatus(contact);
+
+ if (contact.equals(OtrContactMenu.this.contact))
+ setSessionStatus(status);
+ }
});
setSessionStatus(OtrActivator.scOtrEngine.getSessionStatus(contact));
@@ -123,30 +132,27 @@ class OtrContactMenu
refreshOtr.setEnabled(policy.getEnableManual());
this.add(refreshOtr);
- if (!OtrActivator.scOtrEngine.isContactVerified(contact))
+ JMenuItem authBuddy = new JMenuItem();
+ authBuddy.setText(OtrActivator.resourceService
+ .getI18NString("plugin.otr.menu.AUTHENTICATE_BUDDY"));
+ authBuddy.addActionListener(new ActionListener()
{
- JMenuItem authBuddy = new JMenuItem();
- authBuddy.setText(OtrActivator.resourceService
- .getI18NString("plugin.otr.menu.AUTHENTICATE_BUDDY"));
- authBuddy.addActionListener(new ActionListener()
+ public void actionPerformed(ActionEvent e)
{
- public void actionPerformed(ActionEvent e)
- {
- // Launch auth buddy dialog.
- OtrBuddyAuthenticationDialog authenticateBuddyDialog =
- new OtrBuddyAuthenticationDialog(contact);
-
- authenticateBuddyDialog.setLocation(Toolkit
- .getDefaultToolkit().getScreenSize().width
- / 2 - authenticateBuddyDialog.getWidth() / 2,
- Toolkit.getDefaultToolkit().getScreenSize().height
- / 2 - authenticateBuddyDialog.getHeight() / 2);
-
- authenticateBuddyDialog.setVisible(true);
- }
- });
- this.add(authBuddy);
- }
+ // Launch auth buddy dialog.
+ OtrBuddyAuthenticationDialog authenticateBuddyDialog =
+ new OtrBuddyAuthenticationDialog(contact);
+
+ authenticateBuddyDialog.setLocation(Toolkit
+ .getDefaultToolkit().getScreenSize().width
+ / 2 - authenticateBuddyDialog.getWidth() / 2, Toolkit
+ .getDefaultToolkit().getScreenSize().height
+ / 2 - authenticateBuddyDialog.getHeight() / 2);
+
+ authenticateBuddyDialog.setVisible(true);
+ }
+ });
+ this.add(authBuddy);
break;
case FINISHED:
this.setIcon(OtrActivator.resourceService
diff --git a/src/net/java/sip/communicator/plugin/otr/OtrMetaContactButton.java b/src/net/java/sip/communicator/plugin/otr/OtrMetaContactButton.java
index 9c7c15e..da8c5ca 100644
--- a/src/net/java/sip/communicator/plugin/otr/OtrMetaContactButton.java
+++ b/src/net/java/sip/communicator/plugin/otr/OtrMetaContactButton.java
@@ -67,6 +67,17 @@ public class OtrMetaContactButton
setPolicy(OtrActivator.scOtrEngine
.getContactPolicy(contact));
}
+
+ public void contactVerificationStatusChanged(Contact contact)
+ {
+ // OtrMetaContactButton.this.contact can be null.
+ if (contact.equals(OtrMetaContactButton.this.contact))
+ {
+ setStatus(OtrActivator.scOtrEngine
+ .getSessionStatus(contact));
+ }
+
+ }
});
this.addActionListener(new ActionListener()
diff --git a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java
index f661cc1..41e43e7 100644
--- a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java
+++ b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineImpl.java
@@ -343,8 +343,14 @@ public class ScOtrEngineImpl
if (contact == null)
return;
+ if (isContactVerified(contact))
+ return;
+
this.configurator.setProperty(getSessionID(contact)
+ "publicKey.verified", true);
+
+ for (ScOtrEngineListener l : listeners)
+ l.contactVerificationStatusChanged(contact);
}
public void forgetContactFingerprint(Contact contact)
@@ -352,9 +358,14 @@ public class ScOtrEngineImpl
if (contact == null)
return;
+ if (!isContactVerified(contact))
+ return;
+
this.configurator.removeProperty(getSessionID(contact)
+ "publicKey.verified");
+ for (ScOtrEngineListener l : listeners)
+ l.contactVerificationStatusChanged(contact);
}
public OtrPolicy getGlobalPolicy()
diff --git a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineListener.java b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineListener.java
index 0bda8f6..90ff6f6 100644
--- a/src/net/java/sip/communicator/plugin/otr/ScOtrEngineListener.java
+++ b/src/net/java/sip/communicator/plugin/otr/ScOtrEngineListener.java
@@ -1,6 +1,6 @@
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
- *
+ *
* Distributable under LGPL license. See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.otr;
@@ -10,13 +10,15 @@ import net.java.sip.communicator.service.protocol.*;
/**
*
* @author George Politis
- *
+ *
*/
public interface ScOtrEngineListener
{
+ public abstract void contactVerificationStatusChanged(Contact contact);
+
public abstract void sessionStatusChanged(Contact contact);
public abstract void contactPolicyChanged(Contact contact);
-
+
public abstract void globalPolicyChanged();
}