Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
remove unnecessary access and use of OTR
Browse files Browse the repository at this point in the history
  • Loading branch information
iamironrabbit committed Dec 3, 2018
1 parent 6f7574e commit 79b6b98
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
*/
public class OtrChatManager implements OtrEngineListener {

//the singleton instance
private static OtrChatManager mInstance;

private OtrEngineHost mOtrEngineHost;
private Hashtable<String, Session> mSessions;
private OtrAndroidKeyManagerImpl mKeyManager;
Expand All @@ -47,7 +44,7 @@ public class OtrChatManager implements OtrEngineListener {

private final static String TAG = "OtrChatManager";

private OtrChatManager(int otrPolicy, RemoteImService imService, OtrAndroidKeyManagerImpl otrKeyManager) throws Exception {
public OtrChatManager(RemoteImService imService, OtrAndroidKeyManagerImpl otrKeyManager) throws Exception {

mContext = imService;
mKeyManager = otrKeyManager;
Expand All @@ -66,6 +63,7 @@ private OtrChatManager(int otrPolicy, RemoteImService imService, OtrAndroidKeyMa
}


/**
public static synchronized OtrChatManager getInstance(int otrPolicy, RemoteImService imService, OtrAndroidKeyManagerImpl otrKeyManager)
throws Exception {
Expand All @@ -79,7 +77,7 @@ public static synchronized OtrChatManager getInstance(int otrPolicy, RemoteImSer
public static OtrChatManager getInstance()
{
return mInstance;
}
}**/


public void setPolicy(int otrPolicy) {
Expand Down
24 changes: 15 additions & 9 deletions app/src/main/java/org/awesomeapp/messenger/model/ChatSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,26 @@ public int sendMessageAsync(Message message, boolean sendOmemo) {
if (mJid.hasNoResource())
initJid();

/**
OtrChatManager cm = OtrChatManager.getInstance();
SessionID sId = cm.getSessionId(message.getFrom().getAddress(), mJid.toString());
SessionStatus otrStatus = cm.getSessionStatus(sId);
boolean verified = cm.getKeyManager().isVerified(sId);
**/

message.setTo(mXa);
message.setType(Imps.MessageType.QUEUED);

//if we can't omemo, check it again to be sure
if (!mCanOmemo) {
mCanOmemo = mManager.resourceSupportsOmemo(mJid);
}
// if (!mCanOmemo) {
// mCanOmemo = mManager.resourceSupportsOmemo(mJid);
// }

mManager.sendMessageAsync(this, message);

/**
if (mCanOmemo && otrStatus != SessionStatus.ENCRYPTED) {
mManager.sendMessageAsync(this, message);
} else {
//do OTR!
Expand Down Expand Up @@ -219,7 +223,7 @@ public int sendMessageAsync(Message message, boolean sendOmemo) {
}
}
}**/

}
else if (mParticipant instanceof ChatGroup)
Expand Down Expand Up @@ -256,12 +260,13 @@ else if (mParticipant instanceof ChatGroup)
*/
public void sendDataAsync(Message message, boolean isResponse, byte[] data) {

OtrChatManager cm = OtrChatManager.getInstance();
sendDataAsync(cm, message, isResponse, data);
// OtrChatManager cm = OtrChatManager.getInstance();
//sendDataAsync(cm, message, isResponse, data);


}

/**
private void sendDataAsync (OtrChatManager cm, Message message, boolean isResponse, byte[] data)
{
SessionID sId = cm.getSessionId(message.getFrom().getAddress(), message.getTo().getAddress());
Expand All @@ -285,7 +290,7 @@ private void sendDataAsync (OtrChatManager cm, Message message, boolean isRespon
}
}
}**/

/**
* Called by ChatSessionManager when received a message of the ChatSession.
Expand Down Expand Up @@ -354,6 +359,7 @@ public List<Message> getHistoryMessages() {
return Collections.unmodifiableList(mHistoryMessages);
}*/

/**
public void sendPushWhitelistTokenAsync(@NonNull Message message,
@NonNull String[] whitelistTokens) {
Expand All @@ -378,7 +384,7 @@ public void sendPushWhitelistTokenAsync(@NonNull Message message,
mManager.sendMessageAsync(this, message);
}
}
}**/

public boolean isSubscribed() {
return mIsSubscribed;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3005,7 +3005,6 @@ public void processStanza(Stanza stanza) throws SmackException.NotConnectedExcep
} catch (CryptoFailedException cfe) {
debug(TAG, "crypto failed", cfe);
} catch (UndecidedOmemoIdentityException uoie) {
debug(TAG, "crypto failed", uoie);

//if we are connected, then try again
if (mConnection != null && mConnection.isConnected()) {
Expand All @@ -3018,6 +3017,11 @@ public void processStanza(Stanza stanza) throws SmackException.NotConnectedExcep
thisChat.send(msgEncrypted);
message.setType(Imps.MessageType.OUTGOING_ENCRYPTED_VERIFIED);
}
else
{
debug(TAG, "crypto failed", uoie);

}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ private synchronized OtrChatManager initOtrChatManager() {

if (otrKeyManager != null)
{
mOtrChatManager = OtrChatManager.getInstance(otrPolicy, this, otrKeyManager);
// mOtrChatManager.addOtrEngineListener(this);
mOtrChatManager = new OtrChatManager(this, otrKeyManager);
mOtrChatManager.setPolicy(otrPolicy);


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,9 @@ public synchronized boolean onTransferRequested(String offerId, String from, Str

}


public boolean sendPushWhitelistToken(@NonNull String token) {
/**
if (mConnection.getState() == ImConnection.SUSPENDED) {
// TODO Is it possible to postpone a TLV message? e.g: insertMessageInDb with type QUEUED
return false;
Expand All @@ -1860,6 +1862,8 @@ public boolean sendPushWhitelistToken(@NonNull String token) {
mChatSession.sendPushWhitelistTokenAsync(msg, new String[]{token});
return true;
**/
return false;
}

public synchronized void setContactTyping (Contact contact, boolean isTyping)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ protected Boolean doInBackground(String... strings) {

mRemoteOtrFingerprint = strings[0];

if (mRemoteOtrFingerprint == null) {
mRemoteOtrFingerprint = OtrChatManager.getInstance().getRemoteKeyFingerprint(mUsername);
}
// if (mRemoteOtrFingerprint == null) {
// mRemoteOtrFingerprint = OtrChatManager.getInstance().getRemoteKeyFingerprint(mUsername);
// }


try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ public class ConversationView {

private SessionStatus mLastSessionStatus = null;
private boolean mIsStartingOtr = false;
private boolean mIsVerified = false;

private ConversationRecyclerViewAdapter mMessageAdapter;
// private boolean isServiceUp;
Expand Down Expand Up @@ -2413,17 +2412,6 @@ else if (mCurrentChatSession != null) {



if (otrChatSession != null) {
try {
String rFingerprint = otrChatSession.getRemoteFingerprint();
mIsVerified = (OtrChatManager.getInstance().isRemoteKeyVerified(mRemoteAddress, rFingerprint));
} catch (RemoteException re) {
}
}


// mActivity.findViewById(R.id.waiting_view).setVisibility(View.GONE);


}
else if (mIsStartingOtr)
Expand Down Expand Up @@ -2451,11 +2439,6 @@ else if (mLastSessionStatus == SessionStatus.FINISHED) {
}


public boolean isOtrSessionVerified ()
{
return mIsVerified;
}

public int getRemotePresence ()
{
return mPresenceStatus;
Expand Down

0 comments on commit 79b6b98

Please sign in to comment.