use of org.awesomeapp.messenger.crypto.IOtrChatSession in project Zom-Android by zom.
the class ConversationView method setSelected.
public void setSelected(boolean isSelected) {
mIsSelected = isSelected;
if (mIsSelected) {
// bindChat(mLastChatId);
startListening();
updateWarningView();
mComposeMessage.requestFocus();
userActionDetected();
updateGroupTitle();
try {
mApp.dismissChatNotification(mProviderId, XmppAddress.stripResource(mRemoteAddress));
mCurrentChatSession.markAsRead();
} catch (Exception e) {
}
try {
if (mConn == null)
if (!checkConnection())
return;
if (mConn == null)
return;
IContactListManager manager = mConn.getContactListManager();
Contact contact = manager.getContactByAddress(mRemoteAddress);
if (contact != null) {
if (contact.getPresence() != null) {
mLastSeen = contact.getPresence().getLastSeen();
if (mLastSeen != null)
mActivity.updateLastSeen(mLastSeen);
}
if (!TextUtils.isEmpty(contact.getForwardingAddress())) {
showContactMoved(contact);
}
}
if ((mLastSessionStatus == null || mLastSessionStatus == SessionStatus.PLAINTEXT)) {
boolean otrPolicyAuto = getOtrPolicy() == OtrPolicy.OPPORTUNISTIC || getOtrPolicy() == OtrPolicy.OTRL_POLICY_ALWAYS;
if (mCurrentChatSession == null)
mCurrentChatSession = getChatSession();
if (mCurrentChatSession == null)
return;
IOtrChatSession otrChatSession = mCurrentChatSession.getDefaultOtrChatSession();
if (otrChatSession != null && (!isGroupChat())) {
String remoteJID = otrChatSession.getRemoteUserId();
boolean doOtr = (remoteJID != null && (remoteJID.toLowerCase().contains("chatsecure") || remoteJID.toLowerCase().contains("zom")));
if (!doOtr)
doOtr = OtrAndroidKeyManagerImpl.getInstance(mActivity).hasRemoteFingerprint(remoteJID);
if (// if set to auto, and is chatsecure, then start encryption
otrPolicyAuto && doOtr) {
// automatically attempt to turn on OTR after 1 second
mHandler.postDelayed(new Runnable() {
public void run() {
setOTRState(true);
scheduleRequery(DEFAULT_QUERY_INTERVAL);
}
}, 100);
}
}
}
} catch (RemoteException re) {
}
} else {
stopListening();
sendTypingStatus(false);
}
}
use of org.awesomeapp.messenger.crypto.IOtrChatSession in project Zom-Android by zom.
the class ConversationView method showVerifyDialog.
/**
* public void verifyScannedFingerprint (String scannedFingerprint)
* {
* try
* {
* IOtrChatSession otrChatSession = mCurrentChatSession.getDefaultOtrChatSession();
*
* if (scannedFingerprint != null && scannedFingerprint.equalsIgnoreCase(otrChatSession.getRemoteFingerprint())) {
* verifyRemoteFingerprint();
* }
* }
* catch (RemoteException e)
* {
* LogCleaner.error(ImApp.LOG_TAG, "unable to perform manual key verification", e);
* }
* }
*/
public void showVerifyDialog() {
Intent intent = new Intent(mContext, ContactDisplayActivity.class);
intent.putExtra("nickname", mRemoteNickname);
intent.putExtra("address", mRemoteAddress);
intent.putExtra("provider", mProviderId);
intent.putExtra("account", mAccountId);
intent.putExtra("contactId", mLastChatId);
if (mCurrentChatSession != null) {
try {
IOtrChatSession otrChatSession = mCurrentChatSession.getDefaultOtrChatSession();
if (otrChatSession != null)
intent.putExtra("fingerprint", otrChatSession.getRemoteFingerprint());
} catch (RemoteException re) {
}
}
mContext.startActivity(intent);
}
use of org.awesomeapp.messenger.crypto.IOtrChatSession in project Zom-Android by zom.
the class SmpResponseActivity method respondSmp.
private void respondSmp(String sid, String answer) {
ImApp app = (ImApp) getApplication();
IOtrChatSession iOtrSession;
try {
IChatSession chatSession = app.getChatSession(mProviderId, -1, Address.stripResource(sid));
iOtrSession = chatSession.getDefaultOtrChatSession();
if (iOtrSession == null) {
OtrDebugLogger.log("no session in progress for provider " + mProviderId);
return;
}
iOtrSession.respondSmpVerification(answer);
} catch (RemoteException e) {
OtrDebugLogger.log("could not respond to SMP", e);
}
}
use of org.awesomeapp.messenger.crypto.IOtrChatSession in project Zom-Android by zom.
the class ContactDisplayActivity method initSmp.
private void initSmp(String question, String answer) {
try {
IChatSessionManager manager = mConn.getChatSessionManager();
IChatSession session = manager.getChatSession(mUsername);
IOtrChatSession iOtrSession = session.getDefaultOtrChatSession();
iOtrSession.initSmpVerification(question, answer);
} catch (RemoteException e) {
Log.e(ImApp.LOG_TAG, "error init SMP", e);
}
}
use of org.awesomeapp.messenger.crypto.IOtrChatSession in project Zom-Android by zom.
the class ConversationView method setOTRState.
public void setOTRState(boolean otrEnabled) {
try {
if (mCurrentChatSession == null)
mCurrentChatSession = getChatSession();
if (mCurrentChatSession != null) {
IOtrChatSession otrChatSession = mCurrentChatSession.getDefaultOtrChatSession();
if (otrChatSession != null) {
if (otrEnabled && (otrChatSession.getChatStatus() != SessionStatus.ENCRYPTED.ordinal())) {
otrChatSession.startChatEncryption();
mIsStartingOtr = true;
} else // else if ((!otrEnabled) && otrChatSession.getChatStatus() == SessionStatus.ENCRYPTED.ordinal())
{
otrChatSession.stopChatEncryption();
}
}
}
updateWarningView();
} catch (RemoteException e) {
Log.d(ImApp.LOG_TAG, "error getting remote activity", e);
}
}
Aggregations