Search in sources :

Example 6 with Contact

use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.

the class ConversationView method startChat.

private void startChat(String username) {
    if (username != null) {
        new ChatSessionInitTask(((ImApp) mActivity.getApplication()), mProviderId, mAccountId, Imps.Contacts.TYPE_NORMAL, true) {

            @Override
            protected void onPostExecute(Long chatId) {
                if (chatId != -1 && true) {
                    Intent intent = new Intent(mActivity, ConversationDetailActivity.class);
                    intent.putExtra("id", chatId);
                    mActivity.startActivity(intent);
                }
                super.onPostExecute(chatId);
            }
        }.executeOnExecutor(ImApp.sThreadPoolExecutor, new Contact(new XmppAddress(username)));
        mActivity.finish();
    }
}
Also used : ChatSessionInitTask(org.awesomeapp.messenger.tasks.ChatSessionInitTask) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) Intent(android.content.Intent) Contact(org.awesomeapp.messenger.model.Contact)

Example 7 with Contact

use of org.awesomeapp.messenger.model.Contact 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 8 with Contact

use of org.awesomeapp.messenger.model.Contact 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 9 with Contact

use of org.awesomeapp.messenger.model.Contact 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)

Example 10 with Contact

use of org.awesomeapp.messenger.model.Contact in project Zom-Android by zom.

the class ChatSessionAdapter method insertOrUpdateGroupContactInDb.

private long insertOrUpdateGroupContactInDb(ChatGroup group) {
    // Insert a record in contacts table
    ContentValues values = new ContentValues(4);
    values.put(Imps.Contacts.USERNAME, group.getAddress().getAddress());
    values.put(Imps.Contacts.NICKNAME, group.getName());
    values.put(Imps.Contacts.CONTACTLIST, ContactListManagerAdapter.LOCAL_GROUP_LIST_ID);
    values.put(Imps.Contacts.TYPE, Imps.Contacts.TYPE_GROUP);
    Uri contactUri = ContentUris.withAppendedId(ContentUris.withAppendedId(Imps.Contacts.CONTENT_URI, mConnection.mProviderId), mConnection.mAccountId);
    ContactListManagerAdapter listManager = (ContactListManagerAdapter) mConnection.getContactListManager();
    long id = listManager.queryGroup(group);
    if (id == -1) {
        id = ContentUris.parseId(mContentResolver.insert(contactUri, values));
        for (Contact member : group.getMembers()) {
            insertGroupMemberInDb(member);
        }
    }
    return id;
}
Also used : ContentValues(android.content.ContentValues) Uri(android.net.Uri) Contact(org.awesomeapp.messenger.model.Contact)

Aggregations

Contact (org.awesomeapp.messenger.model.Contact)33 RemoteException (android.os.RemoteException)11 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)10 Presence (org.awesomeapp.messenger.model.Presence)6 XmppStringprepException (org.jxmpp.stringprep.XmppStringprepException)6 Intent (android.content.Intent)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 ImException (org.awesomeapp.messenger.model.ImException)5 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)5 ContentValues (android.content.ContentValues)4 Uri (android.net.Uri)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 KeyManagementException (java.security.KeyManagementException)4 KeyStoreException (java.security.KeyStoreException)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 CertificateException (java.security.cert.CertificateException)4 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)4 ContactList (org.awesomeapp.messenger.model.ContactList)4 IChatSession (org.awesomeapp.messenger.service.IChatSession)4