Search in sources :

Example 1 with IContactListManager

use of org.awesomeapp.messenger.service.IContactListManager in project Zom-Android by zom.

the class ConversationView method blockContact.

public void blockContact() {
    // TODO: unify with codes in ContactListView
    DialogInterface.OnClickListener confirmListener = new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            try {
                checkConnection();
                mConn = mApp.getConnection(mProviderId, mAccountId);
                IContactListManager manager = mConn.getContactListManager();
                manager.blockContact(Address.stripResource(mRemoteAddress));
            // mNewChatActivity.finish();
            } catch (Exception e) {
                mHandler.showServiceErrorAlert(e.getLocalizedMessage());
                LogCleaner.error(ImApp.LOG_TAG, "send message error", e);
            }
        }
    };
    Resources r = mActivity.getResources();
    // The positive button is deliberately set as no so that
    // the no is the default value
    new AlertDialog.Builder(mContext).setTitle(R.string.confirm).setMessage(r.getString(R.string.confirm_block_contact, mRemoteNickname)).setPositiveButton(R.string.yes, // default button
    confirmListener).setNegativeButton(R.string.no, null).setCancelable(false).show();
}
Also used : DialogInterface(android.content.DialogInterface) SpannableStringBuilder(android.text.SpannableStringBuilder) Resources(android.content.res.Resources) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) IOException(java.io.IOException) CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException)

Example 2 with IContactListManager

use of org.awesomeapp.messenger.service.IContactListManager in project Zom-Android by zom.

the class ConversationView method registerChatListener.

void registerChatListener() {
    if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
        log("registerChatListener " + mLastChatId);
    }
    try {
        checkConnection();
        if (getChatSession() != null) {
            getChatSession().registerChatListener(mChatListener);
        }
        if (mConn != null) {
            IContactListManager listMgr = mConn.getContactListManager();
            listMgr.registerContactListListener(mContactListListener);
            listMgr.registerSubscriptionListener(mSubscriptionListener);
        }
    } catch (Exception e) {
        Log.w(ImApp.LOG_TAG, "<ChatView> registerChatListener fail:" + e.getMessage());
    }
}
Also used : IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) IOException(java.io.IOException) CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException)

Example 3 with IContactListManager

use of org.awesomeapp.messenger.service.IContactListManager in project Zom-Android by zom.

the class ConversationView method declineSubscription.

void declineSubscription() {
    if (mConn != null) {
        try {
            IContactListManager manager = mConn.getContactListManager();
            manager.declineSubscription(new Contact(new XmppAddress(mRemoteAddress), mRemoteNickname, Imps.Contacts.TYPE_NORMAL));
        } catch (RemoteException e) {
            // mHandler.showServiceErrorAlert(e.getLocalizedMessage());
            LogCleaner.error(ImApp.LOG_TAG, "decline sub error", e);
        }
    }
}
Also used : XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) Contact(org.awesomeapp.messenger.model.Contact)

Example 4 with IContactListManager

use of org.awesomeapp.messenger.service.IContactListManager 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 5 with IContactListManager

use of org.awesomeapp.messenger.service.IContactListManager in project Zom-Android by zom.

the class ConversationView method approveSubscription.

void approveSubscription() {
    if (mConn != null) {
        try {
            IContactListManager manager = mConn.getContactListManager();
            manager.approveSubscription(new Contact(new XmppAddress(mRemoteAddress), mRemoteNickname, Imps.Contacts.TYPE_NORMAL));
        } catch (RemoteException e) {
            // mHandler.showServiceErrorAlert(e.getLocalizedMessage());
            LogCleaner.error(ImApp.LOG_TAG, "approve sub error", e);
        }
    }
}
Also used : XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) Contact(org.awesomeapp.messenger.model.Contact)

Aggregations

RemoteException (android.os.RemoteException)21 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)21 IImConnection (org.awesomeapp.messenger.service.IImConnection)9 ImApp (org.awesomeapp.messenger.ImApp)6 IOException (java.io.IOException)5 Contact (org.awesomeapp.messenger.model.Contact)5 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)5 CursorIndexOutOfBoundsException (android.database.CursorIndexOutOfBoundsException)4 IContactList (org.awesomeapp.messenger.service.IContactList)4 Activity (android.app.Activity)3 DialogInterface (android.content.DialogInterface)3 Resources (android.content.res.Resources)3 Paint (android.graphics.Paint)3 IBinder (android.os.IBinder)3 IChatSession (org.awesomeapp.messenger.service.IChatSession)2 IChatSessionManager (org.awesomeapp.messenger.service.IChatSessionManager)2 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1