Search in sources :

Example 1 with XmppAddress

use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress in project Zom-Android by zom.

the class ImUrlActivity method startChat.

public void startChat(long providerId, long accountId, String username, final boolean openChat) {
    if (username != null)
        new ChatSessionInitTask(((ImApp) getApplication()), providerId, accountId, Imps.Contacts.TYPE_NORMAL, true) {

            @Override
            protected void onPostExecute(Long chatId) {
                if (chatId != -1 && openChat) {
                    Intent intent = new Intent(ImUrlActivity.this, ConversationDetailActivity.class);
                    intent.putExtra("id", chatId);
                    startActivity(intent);
                }
                finish();
                super.onPostExecute(chatId);
            }
        }.executeOnExecutor(ImApp.sThreadPoolExecutor, new Contact(new XmppAddress(username)));
}
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 2 with XmppAddress

use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress in project Zom-Android by zom.

the class ChatSession method initJid.

private void initJid() {
    try {
        mJid = JidCreate.from(mParticipant.getAddress().getAddress());
        mXa = new XmppAddress(mJid.toString());
        if (mJid.hasNoResource()) {
            if (!TextUtils.isEmpty(mParticipant.getAddress().getResource())) {
                mJid = JidCreate.from(mParticipant.getAddress().getAddress());
            } else if (mParticipant instanceof Contact) {
                String resource = ((Contact) mParticipant).getPresence().getResource();
                if (!TextUtils.isEmpty(resource)) {
                    mJid = JidCreate.from(mParticipant.getAddress().getBareAddress() + '/' + resource);
                }
            }
            mXa = new XmppAddress(mJid.toString());
        }
        // not for groups yet
        if (mParticipant instanceof Contact) {
            // if we can't omemo, check it again to be sure
            if (!mCanOmemo) {
                mCanOmemo = mManager.resourceSupportsOmemo(mJid);
            }
        }
    } catch (XmppStringprepException xe) {
        throw new RuntimeException("Error with address that shouldn't happen: " + xe);
    }
}
Also used : XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) XmppStringprepException(org.jxmpp.stringprep.XmppStringprepException)

Example 3 with XmppAddress

use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress 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 4 with XmppAddress

use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress 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 5 with XmppAddress

use of org.awesomeapp.messenger.plugin.xmpp.XmppAddress 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

XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)17 Contact (org.awesomeapp.messenger.model.Contact)10 RemoteException (android.os.RemoteException)8 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)5 Intent (android.content.Intent)4 IChatSession (org.awesomeapp.messenger.service.IChatSession)4 ChatSessionInitTask (org.awesomeapp.messenger.tasks.ChatSessionInitTask)4 ImApp (org.awesomeapp.messenger.ImApp)3 Activity (android.app.Activity)2 DecoderException (org.apache.commons.codec.DecoderException)2 Address (org.awesomeapp.messenger.model.Address)2 ChatSession (org.awesomeapp.messenger.model.ChatSession)2 IChatSessionManager (org.awesomeapp.messenger.service.IChatSessionManager)2 IImConnection (org.awesomeapp.messenger.service.IImConnection)2 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 View (android.view.View)1 TextView (android.widget.TextView)1 IOException (java.io.IOException)1