Search in sources :

Example 6 with IChatSessionManager

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

the class ContactsListFragment method deleteContact.

private static void deleteContact(Activity activity, long itemId, String address, long providerId, long accountId) {
    try {
        IImConnection mConn;
        ImApp app = ((ImApp) activity.getApplication());
        mConn = app.getConnection(providerId, accountId);
        // first leave, delete an existing chat session
        IChatSessionManager sessionMgr = mConn.getChatSessionManager();
        if (sessionMgr != null) {
            IChatSession session = sessionMgr.getChatSession(Address.stripResource(address));
        }
        // then delete the contact from our list
        IContactListManager manager = mConn.getContactListManager();
        int res = manager.removeContact(address);
        if (res != ImErrorInfo.NO_ERROR) {
        // mHandler.showAlert(R.string.error,
        // ErrorResUtils.getErrorRes(getResources(), res, address));
        }
    } catch (RemoteException re) {
    }
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) ImApp(org.awesomeapp.messenger.ImApp) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException) IChatSession(org.awesomeapp.messenger.service.IChatSession) Paint(android.graphics.Paint)

Example 7 with IChatSessionManager

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

the class ContactDisplayActivity method startChat.

public void startChat() {
    if (mConn == null)
        return;
    try {
        IChatSessionManager manager = mConn.getChatSessionManager();
        if (manager != null) {
            IChatSession session = manager.getChatSession(mUsername);
            if (session == null) {
                new ChatSessionInitTask(((ImApp) getApplication()), mProviderId, mAccountId, Imps.Contacts.TYPE_NORMAL, false) {

                    @Override
                    protected void onPostExecute(Long chatId) {
                        super.onPostExecute(chatId);
                        if (mContactId == -1) {
                            Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
                            intent.putExtra("id", chatId);
                            startActivity(intent);
                            finish();
                        }
                    }
                }.executeOnExecutor(ImApp.sThreadPoolExecutor, new Contact(new XmppAddress(mUsername)));
            // Toast.makeText(this, getString(R.string.message_waiting_for_friend), Toast.LENGTH_LONG).show();
            } else {
                Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
                intent.putExtra("id", session.getId());
                startActivity(intent);
                finish();
            }
        }
    } catch (RemoteException re) {
    }
    if (mContactId != -1) {
        Intent intent = new Intent(ContactDisplayActivity.this, ConversationDetailActivity.class);
        intent.putExtra("id", mContactId);
        startActivity(intent);
        finish();
    }
}
Also used : IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) ChatSessionInitTask(org.awesomeapp.messenger.tasks.ChatSessionInitTask) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) Intent(android.content.Intent) RemoteException(android.os.RemoteException) IChatSession(org.awesomeapp.messenger.service.IChatSession) Contact(org.awesomeapp.messenger.model.Contact)

Example 8 with IChatSessionManager

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

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

the class GroupDisplayActivity method inviteContacts.

public void inviteContacts(ArrayList<String> invitees) {
    if (mConn == null)
        return;
    try {
        IChatSessionManager manager = mConn.getChatSessionManager();
        IChatSession session = manager.getChatSession(mAddress);
        for (String invitee : invitees) {
            session.inviteContact(invitee);
            GroupMemberDisplay member = new GroupMemberDisplay();
            XmppAddress address = new XmppAddress(invitee);
            member.username = address.getBareAddress();
            member.nickname = address.getUser();
            try {
                member.avatar = DatabaseUtils.getAvatarFromAddress(getContentResolver(), member.username, ImApp.SMALL_AVATAR_WIDTH, ImApp.SMALL_AVATAR_HEIGHT);
            } catch (DecoderException e) {
                e.printStackTrace();
            }
            mMembers.add(member);
        }
        mRecyclerView.getAdapter().notifyDataSetChanged();
    } catch (Exception e) {
        Log.e(ImApp.LOG_TAG, "error inviting contacts to group", e);
    }
}
Also used : IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) DecoderException(org.apache.commons.codec.DecoderException) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) IChatSession(org.awesomeapp.messenger.service.IChatSession) DecoderException(org.apache.commons.codec.DecoderException) RemoteException(android.os.RemoteException)

Example 10 with IChatSessionManager

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

the class ImApp method getChatSession.

public IChatSession getChatSession(long providerId, long accountId, String remoteAddress) {
    IImConnection conn = getConnection(providerId, accountId);
    IChatSessionManager chatSessionManager = null;
    if (conn != null) {
        try {
            chatSessionManager = conn.getChatSessionManager();
        } catch (RemoteException e) {
            Log.e(LOG_TAG, "error in getting ChatSessionManager", e);
        }
    }
    if (chatSessionManager != null) {
        try {
            return chatSessionManager.getChatSession(remoteAddress);
        } catch (RemoteException e) {
            Log.e(LOG_TAG, "error in getting ChatSession", e);
        }
    }
    return null;
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) RemoteException(android.os.RemoteException)

Aggregations

RemoteException (android.os.RemoteException)11 IChatSessionManager (org.awesomeapp.messenger.service.IChatSessionManager)11 IChatSession (org.awesomeapp.messenger.service.IChatSession)10 IOException (java.io.IOException)4 Intent (android.content.Intent)3 CursorIndexOutOfBoundsException (android.database.CursorIndexOutOfBoundsException)2 DecoderException (org.apache.commons.codec.DecoderException)2 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)2 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)2 IImConnection (org.awesomeapp.messenger.service.IImConnection)2 ProgressDialog (android.app.ProgressDialog)1 Paint (android.graphics.Paint)1 Uri (android.net.Uri)1 FileNotFoundException (java.io.FileNotFoundException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 KeyPair (java.security.KeyPair)1 ImApp (org.awesomeapp.messenger.ImApp)1 IOtrChatSession (org.awesomeapp.messenger.crypto.IOtrChatSession)1 OtrAndroidKeyManagerImpl (org.awesomeapp.messenger.crypto.otr.OtrAndroidKeyManagerImpl)1 Contact (org.awesomeapp.messenger.model.Contact)1