Search in sources :

Example 1 with IOtrChatSession

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);
    }
}
Also used : IOtrChatSession(org.awesomeapp.messenger.crypto.IOtrChatSession) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) RemoteException(android.os.RemoteException) IOException(java.io.IOException) CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException) Contact(org.awesomeapp.messenger.model.Contact)

Example 2 with IOtrChatSession

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);
}
Also used : IOtrChatSession(org.awesomeapp.messenger.crypto.IOtrChatSession) Intent(android.content.Intent) RemoteException(android.os.RemoteException)

Example 3 with IOtrChatSession

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);
    }
}
Also used : IOtrChatSession(org.awesomeapp.messenger.crypto.IOtrChatSession) ImApp(org.awesomeapp.messenger.ImApp) RemoteException(android.os.RemoteException) IChatSession(org.awesomeapp.messenger.service.IChatSession)

Example 4 with IOtrChatSession

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);
    }
}
Also used : IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) IOtrChatSession(org.awesomeapp.messenger.crypto.IOtrChatSession) RemoteException(android.os.RemoteException) IChatSession(org.awesomeapp.messenger.service.IChatSession)

Example 5 with IOtrChatSession

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);
    }
}
Also used : IOtrChatSession(org.awesomeapp.messenger.crypto.IOtrChatSession) RemoteException(android.os.RemoteException)

Aggregations

RemoteException (android.os.RemoteException)5 IOtrChatSession (org.awesomeapp.messenger.crypto.IOtrChatSession)5 IChatSession (org.awesomeapp.messenger.service.IChatSession)2 Intent (android.content.Intent)1 CursorIndexOutOfBoundsException (android.database.CursorIndexOutOfBoundsException)1 IOException (java.io.IOException)1 ImApp (org.awesomeapp.messenger.ImApp)1 Contact (org.awesomeapp.messenger.model.Contact)1 IChatSessionManager (org.awesomeapp.messenger.service.IChatSessionManager)1 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)1