# HG changeset patch # User Da Risk # Date 1434392164 -7200 # Node ID 0af23b43e3ad68cb4acdf701428cf5849ab8468e # Parent 688e12c61c9f2cf1d593dea2c4dbbfd740fe5575 Fix checkstyle issue in otr package diff -r 688e12c61c9f -r 0af23b43e3ad app/src/main/java/com/beem/project/beem/otr/BeemOtrManager.java --- a/app/src/main/java/com/beem/project/beem/otr/BeemOtrManager.java Mon Jun 15 19:57:41 2015 +0200 +++ b/app/src/main/java/com/beem/project/beem/otr/BeemOtrManager.java Mon Jun 15 20:16:04 2015 +0200 @@ -270,8 +270,7 @@ } catch (OtrException e) { Log.w(TAG, "error when closing local otr session", e); } - } - else { + } else { mChats.get(sessionID).otrStateChanged(status.toString()); } } diff -r 688e12c61c9f -r 0af23b43e3ad app/src/main/java/com/beem/project/beem/otr/OtrEngine.java --- a/app/src/main/java/com/beem/project/beem/otr/OtrEngine.java Mon Jun 15 19:57:41 2015 +0200 +++ b/app/src/main/java/com/beem/project/beem/otr/OtrEngine.java Mon Jun 15 20:16:04 2015 +0200 @@ -1,4 +1,29 @@ +/* + BEEM is a videoconference application on the Android Platform. + Copyright (C) 2009-2011 by Frederic-Charles Barthelery, + Nikita Kozlov, + Vincent Veronis. + + This file is part of BEEM. + + BEEM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + BEEM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with BEEM. If not, see . + + Please send bug reports with examples or suggestions to + contact@beem-project.com or http://www.beem-project.com/ + +*/ package com.beem.project.beem.otr; import net.java.otr4j.OtrEngineHost; @@ -13,63 +38,124 @@ import java.util.Hashtable; import java.util.Map; +/** + * This class handle the OTR behavior. + */ public class OtrEngine { - public OtrEngine(OtrEngineHost host, OtrEngineListener listener) { - this.host = host; - this.listener = listener; - } + private OtrEngineHost host; + private Map sessions; + private final OtrEngineListener listener; - private OtrEngineHost host; - private Map sessions; + /** + * Create an OtrEngine. + * + * @param host the host part of the OTR engine + * @param listener the listener for OTR events + */ + public OtrEngine(OtrEngineHost host, OtrEngineListener listener) { + this.host = host; + this.listener = listener; + } - private Session getSession(SessionID sessionID) { - - if (sessionID == null || sessionID.equals(SessionID.Empty)) - throw new IllegalArgumentException(); + /** + * Get the OTR session. + * + * @param sessionID the session id + * @return the OTR session + */ + private Session getSession(SessionID sessionID) { - if (sessions == null) - sessions = new Hashtable(); + if (sessionID == null || sessionID.equals(SessionID.Empty)) + throw new IllegalArgumentException(); + + if (sessions == null) + sessions = new Hashtable(); + + if (!sessions.containsKey(sessionID)) { + Session session = new SessionImpl(sessionID, host); + sessions.put(sessionID, session); - if (!sessions.containsKey(sessionID)) { - Session session = new SessionImpl(sessionID, host); - sessions.put(sessionID, session); + session.addOtrEngineListener(listener); + return session; + } else + return sessions.get(sessionID); + } - session.addOtrEngineListener(listener); - return session; - } else - return sessions.get(sessionID); - } + /** + * Get the status of an OTR session. + * + * @param sessionID the session id + * @return the status + */ + public SessionStatus getSessionStatus(SessionID sessionID) { + return this.getSession(sessionID).getSessionStatus(); + } - public SessionStatus getSessionStatus(SessionID sessionID) { - return this.getSession(sessionID).getSessionStatus(); - } + /** + * Transform a message received in an OTR session. + * + * @param sessionID the session id + * @param msgText the encrypted message received + * @return the decrypted message + * @throws OtrException if an error occurs + */ + public String transformReceiving(SessionID sessionID, String msgText) + throws OtrException { + return this.getSession(sessionID).transformReceiving(msgText); + } - public String transformReceiving(SessionID sessionID, String msgText) - throws OtrException { - return this.getSession(sessionID).transformReceiving(msgText); - } - - public String[] transformSending(SessionID sessionID, String msgText) - throws OtrException { - return this.getSession(sessionID).transformSending(msgText, null); - } + /** + * Transform a message to be sent in an OTR session. + * + * @param sessionID the session id + * @param msgText the clear message to send + * @return the encrypted message + * @throws OtrException if an error occurs + */ + public String[] transformSending(SessionID sessionID, String msgText) + throws OtrException { + return this.getSession(sessionID).transformSending(msgText, null); + } - public void endSession(SessionID sessionID) throws OtrException { - this.getSession(sessionID).endSession(); - } + /** + * End an OTR session. + * + * @param sessionID the session id + * @throws OtrException if an error occurs + */ + public void endSession(SessionID sessionID) throws OtrException { + this.getSession(sessionID).endSession(); + } - public void startSession(SessionID sessionID) throws OtrException { - this.getSession(sessionID).startSession(); - } + /** + * Start an OTR session. + * + * @param sessionID the session id + * @throws OtrException if an error occurs + */ + public void startSession(SessionID sessionID) throws OtrException { + this.getSession(sessionID).startSession(); + } - public void refreshSession(SessionID sessionID) throws OtrException { - this.getSession(sessionID).refreshSession(); - } + /** + * Refresh an OTR session. + * + * @param sessionID the session id + * @throws OtrException if an error occurs + */ + public void refreshSession(SessionID sessionID) throws OtrException { + this.getSession(sessionID).refreshSession(); + } - public PublicKey getRemotePublicKey(SessionID sessionID) { - return this.getSession(sessionID).getRemotePublicKey(); - } + /** + * Get the remote public key of an OTR session. + * + * @param sessionID the session id + * @return the public key of the remote peer + */ + public PublicKey getRemotePublicKey(SessionID sessionID) { + return this.getSession(sessionID).getRemotePublicKey(); + } - private final OtrEngineListener listener; }