mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-12-01 12:27:58 +00:00
SPARK-1365 some fixes for otr plugin to prevent multiple messages and disconnect/reconnect problem. updated translation
git-svn-id: http://svn.igniterealtime.org/svn/repos/spark/trunk@12477 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
committed by
holger.bergunde
parent
4730d783b3
commit
12935c2777
@ -1,7 +1,7 @@
|
|||||||
<!-- Define your plugins -->
|
<!-- Define your plugins -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<name>OTR Plugin</name>
|
<name>OTR Plugin</name>
|
||||||
<version>0.2 Beta </version>
|
<version>0.3 Beta </version>
|
||||||
<author>Holger Bergunde</author>
|
<author>Holger Bergunde</author>
|
||||||
<homePage>http://www.stytrix.de</homePage>
|
<homePage>http://www.stytrix.de</homePage>
|
||||||
<email>holger@bergunde.de</email>
|
<email>holger@bergunde.de</email>
|
||||||
|
|||||||
@ -37,7 +37,9 @@ public class OTRSession {
|
|||||||
private OTRManager _manager = OTRManager.getInstance();
|
private OTRManager _manager = OTRManager.getInstance();
|
||||||
final ChatRoomButton _otrButton = new ChatRoomButton();
|
final ChatRoomButton _otrButton = new ChatRoomButton();
|
||||||
private OTRConnectionPanel _conPanel;
|
private OTRConnectionPanel _conPanel;
|
||||||
|
private MessageEventListener _msgEvnt;
|
||||||
private boolean _OtrEnabled = false;
|
private boolean _OtrEnabled = false;
|
||||||
|
private OtrEngineListener _otrListener;
|
||||||
|
|
||||||
public OTRSession(ChatRoomImpl chatroom, String myJID, String remoteJID) {
|
public OTRSession(ChatRoomImpl chatroom, String myJID, String remoteJID) {
|
||||||
_chatRoom = chatroom;
|
_chatRoom = chatroom;
|
||||||
@ -54,6 +56,22 @@ public class OTRSession {
|
|||||||
setUpMessageListener();
|
setUpMessageListener();
|
||||||
|
|
||||||
createButton();
|
createButton();
|
||||||
|
|
||||||
|
//Only initialize the actionListener once
|
||||||
|
_otrButton.addActionListener(
|
||||||
|
new ActionListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (_engine.getSessionStatus(_mySession).equals(SessionStatus.ENCRYPTED)) {
|
||||||
|
stopSession();
|
||||||
|
} else {
|
||||||
|
startSession();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
_OtrEnabled = OTRProperties.getInstance().getIsOTREnabled();
|
_OtrEnabled = OTRProperties.getInstance().getIsOTREnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,11 +83,9 @@ public class OTRSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setUpMessageListener() {
|
private void setUpMessageListener() {
|
||||||
|
|
||||||
_conPanel = new OTRConnectionPanel(_chatRoom);
|
_conPanel = new OTRConnectionPanel(_chatRoom);
|
||||||
|
_chatRoom.removeMessageEventListener(_msgEvnt);
|
||||||
|
_msgEvnt = new MessageEventListener() {
|
||||||
_chatRoom.addMessageEventListener(new MessageEventListener() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendingMessage(Message message) {
|
public void sendingMessage(Message message) {
|
||||||
@ -92,7 +108,6 @@ public class OTRSession {
|
|||||||
mesg = _engine.transformReceiving(_mySession, old);
|
mesg = _engine.transformReceiving(_mySession, old);
|
||||||
}
|
}
|
||||||
if (_engine.getSessionStatus(_mySession).equals(SessionStatus.ENCRYPTED)) {
|
if (_engine.getSessionStatus(_mySession).equals(SessionStatus.ENCRYPTED)) {
|
||||||
|
|
||||||
message.setBody(mesg);
|
message.setBody(mesg);
|
||||||
} else {
|
} else {
|
||||||
if (old.length() > 3 && old.substring(0, 4).equals("?OTR")) {
|
if (old.length() > 3 && old.substring(0, 4).equals("?OTR")) {
|
||||||
@ -112,8 +127,8 @@ public class OTRSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
_chatRoom.addMessageEventListener(_msgEvnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createButton() {
|
private void createButton() {
|
||||||
@ -124,28 +139,17 @@ public class OTRSession {
|
|||||||
ImageIcon otricon = null;
|
ImageIcon otricon = null;
|
||||||
if (_engine.getSessionStatus(_mySession).equals(SessionStatus.ENCRYPTED)) {
|
if (_engine.getSessionStatus(_mySession).equals(SessionStatus.ENCRYPTED)) {
|
||||||
otricon = new ImageIcon(cl.getResource("otr_on.png"));
|
otricon = new ImageIcon(cl.getResource("otr_on.png"));
|
||||||
_chatRoom.getTranscriptWindow().insertNotificationMessage("From now on, your conversation is encrypted", Color.gray);
|
_conPanel.sucessfullyCon();
|
||||||
} else {
|
} else {
|
||||||
otricon = new ImageIcon(cl.getResource("otr_off.png"));
|
otricon = new ImageIcon(cl.getResource("otr_off.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
_otrButton.setIcon(otricon);
|
_otrButton.setIcon(otricon);
|
||||||
|
|
||||||
_otrButton.addActionListener(new ActionListener() {
|
|
||||||
|
_engine.removeOtrEngineListener(_otrListener);
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (_engine.getSessionStatus(_mySession).equals(SessionStatus.ENCRYPTED)) {
|
|
||||||
stopSession();
|
|
||||||
} else {
|
|
||||||
startSession();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
_chatRoom.getToolBar().addChatRoomButton(_otrButton);
|
_chatRoom.getToolBar().addChatRoomButton(_otrButton);
|
||||||
_engine.addOtrEngineListener(new OtrEngineListener() {
|
_otrListener = new OtrEngineListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sessionStatusChanged(SessionID arg0) {
|
public void sessionStatusChanged(SessionID arg0) {
|
||||||
@ -180,7 +184,8 @@ public class OTRSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
_engine.addOtrEngineListener(_otrListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public class OTRConnectionPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
if (_i != 0 && !_succesfull) {
|
if (_i > 0 && !_succesfull) {
|
||||||
_waiting = true;
|
_waiting = true;
|
||||||
_label.setText(OTRResources.getString("otr.try.to.connect.for.seconds",_i));
|
_label.setText(OTRResources.getString("otr.try.to.connect.for.seconds",_i));
|
||||||
decI();
|
decI();
|
||||||
@ -126,16 +126,23 @@ public class OTRConnectionPanel {
|
|||||||
private void decI() {
|
private void decI() {
|
||||||
--_i;
|
--_i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setConnected(boolean con)
|
||||||
|
{
|
||||||
|
_succesfull = con;
|
||||||
|
}
|
||||||
|
|
||||||
public void sucessfullyCon() {
|
public void sucessfullyCon() {
|
||||||
if(!_waiting)
|
if (!_succesfull) {
|
||||||
renewPanel();
|
if (!_waiting)
|
||||||
_retry.setVisible(false);
|
renewPanel();
|
||||||
_conPanel.setVisible(true);
|
_retry.setVisible(false);
|
||||||
_succesfull = true;
|
_conPanel.setVisible(true);
|
||||||
_waiting = false;
|
_succesfull = true;
|
||||||
_icon.setImage(SparkRes.getImageIcon(SparkRes.SMALL_CHECK).getImage());
|
_waiting = false;
|
||||||
_label.setText(OTRResources.getString("otr.successfull"));
|
_icon.setImage(SparkRes.getImageIcon(SparkRes.SMALL_CHECK).getImage());
|
||||||
|
_label.setText(OTRResources.getString("otr.successfull"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,8 +13,8 @@ otr.key.not.verified.title = Key not verified
|
|||||||
otr.question.verify = Verify?
|
otr.question.verify = Verify?
|
||||||
otr.key.not.verified.text = Following key is not verified!
|
otr.key.not.verified.text = Following key is not verified!
|
||||||
otr.start.session.with = OTR encrypted Session with {0}
|
otr.start.session.with = OTR encrypted Session with {0}
|
||||||
|
|
||||||
otr.not.enabled = You recieved an OTR request. You should enable OTR in preferences.
|
otr.not.enabled = You recieved an OTR request. You should enable OTR in preferences.
|
||||||
|
otr.chat.is.still.encrypted = This conversation is still encrypted.
|
||||||
|
|
||||||
#Table Columns
|
#Table Columns
|
||||||
otr.table.jid = User's JID
|
otr.table.jid = User's JID
|
||||||
|
|||||||
@ -15,7 +15,7 @@ otr.key.not.verified.text = Folgender Schl
|
|||||||
otr.start.session.with = OTR Sitzung mit {0}
|
otr.start.session.with = OTR Sitzung mit {0}
|
||||||
|
|
||||||
otr.not.enabled = Sie haben eine OTR Anfrage empfagen. Sie sollten OTR in den Einstellungen aktivieren.
|
otr.not.enabled = Sie haben eine OTR Anfrage empfagen. Sie sollten OTR in den Einstellungen aktivieren.
|
||||||
|
otr.chat.is.still.encrypted = OTR Sitzung aktiv. Nachrichten werden verschl<68>sselt.
|
||||||
#Table Columns
|
#Table Columns
|
||||||
otr.table.jid = Kontakt
|
otr.table.jid = Kontakt
|
||||||
otr.table.public.key = <EFBFBD>ffentlicher Schl<68>ssel
|
otr.table.public.key = <EFBFBD>ffentlicher Schl<68>ssel
|
||||||
|
|||||||
Reference in New Issue
Block a user