Fix checkstyle issue in otr package
authorDa Risk <da_risk@beem-project.com>
Mon, 15 Jun 2015 20:16:04 +0200
changeset 1066 0af23b43e3ad
parent 1065 688e12c61c9f
child 1067 401b33f78a4d
Fix checkstyle issue in otr package
app/src/main/java/com/beem/project/beem/otr/BeemOtrManager.java
app/src/main/java/com/beem/project/beem/otr/OtrEngine.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());
 		}
 	    }
--- 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 <http://www.gnu.org/licenses/>.
+
+    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<SessionID, Session> sessions;
+    private final OtrEngineListener listener;
 
-	private OtrEngineHost host;
-	private Map<SessionID, Session> 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<SessionID, Session>();
+	if (sessionID == null || sessionID.equals(SessionID.Empty))
+	    throw new IllegalArgumentException();
+
+	if (sessions == null)
+	    sessions = new Hashtable<SessionID, Session>();
+
+	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;
 }