Search in sources :

Example 1 with IChatSession

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

the class ImUrlActivity method sendOtrInBand.

private void sendOtrInBand(String username, long providerId, long accountId) {
    try {
        IImConnection conn = ((ImApp) getApplication()).getConnection(providerId, accountId);
        if (conn == null)
            // can't send without a connection
            return;
        mChatSessionManager = conn.getChatSessionManager();
        IChatSession session = getChatSession(username);
        if (mSendText != null)
            session.sendMessage(mSendText, false);
        else if (mSendUri != null) {
            try {
                String offerId = UUID.randomUUID().toString();
                // Log.i(TAG, "mSendUrl " +mSendUrl);
                Uri vfsUri = null;
                if (SecureMediaStore.isVfsUri(mSendUri)) {
                    vfsUri = mSendUri;
                    boolean sent = session.offerData(offerId, vfsUri.toString(), mSendType);
                    if (sent)
                        return;
                } else {
                    InputStream is = getContentResolver().openInputStream(mSendUri);
                    String fileName = mSendUri.getLastPathSegment();
                    FileInfo importInfo = SystemServices.getFileInfoFromURI(this, mSendUri);
                    if (!TextUtils.isEmpty(importInfo.type)) {
                        if (importInfo.type.startsWith("image"))
                            vfsUri = SecureMediaStore.resizeAndImportImage(this, session.getId() + "", mSendUri, importInfo.type);
                        else
                            vfsUri = SecureMediaStore.importContent(session.getId() + "", fileName, is);
                        boolean sent = session.offerData(offerId, vfsUri.toString(), importInfo.type);
                        if (sent)
                            return;
                    }
                }
            } catch (Exception e) {
                Log.e(TAG, "error sending external file", e);
            }
            Toast.makeText(this, R.string.unable_to_securely_share_this_file, Toast.LENGTH_LONG).show();
        }
    } catch (RemoteException e) {
        Log.e(TAG, "Error sending data", e);
    }
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) FileInfo(org.awesomeapp.messenger.util.SystemServices.FileInfo) InputStream(java.io.InputStream) RemoteException(android.os.RemoteException) IChatSession(org.awesomeapp.messenger.service.IChatSession) Uri(android.net.Uri) RemoteException(android.os.RemoteException)

Example 2 with IChatSession

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

the class ImUrlActivity method openChat.

private void openChat(long provider, long account) {
    try {
        IChatSessionManager manager = mConn.getChatSessionManager();
        IChatSession session = manager.getChatSession(mToAddress);
        if (session == null) {
            session = manager.createChatSession(mToAddress, false);
        }
        Uri data = ContentUris.withAppendedId(Imps.Chats.CONTENT_URI, session.getId());
        Intent intent = new Intent(Intent.ACTION_VIEW, data);
        intent.putExtra(ImServiceConstants.EXTRA_INTENT_FROM_ADDRESS, mToAddress);
        intent.putExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, provider);
        intent.putExtra(ImServiceConstants.EXTRA_INTENT_ACCOUNT_ID, account);
        intent.addCategory(ImApp.IMPS_CATEGORY);
        startActivity(intent);
    } catch (RemoteException e) {
        // Ouch!  Service died!  We'll just disappear.
        Log.w("ImUrlActivity", "Connection disappeared!");
    }
}
Also used : IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) Intent(android.content.Intent) RemoteException(android.os.RemoteException) IChatSession(org.awesomeapp.messenger.service.IChatSession) Uri(android.net.Uri)

Example 3 with IChatSession

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

the class ConversationView method inviteContacts.

public void inviteContacts(ArrayList<String> invitees) {
    if (mConn == null)
        return;
    try {
        IChatSessionManager manager = mConn.getChatSessionManager();
        IChatSession session = manager.getChatSession(mRemoteAddress);
        for (String invitee : invitees) session.inviteContact(invitee);
    } catch (Exception e) {
        Log.e(ImApp.LOG_TAG, "error inviting contacts to group", e);
    }
}
Also used : IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) IChatSession(org.awesomeapp.messenger.service.IChatSession) RemoteException(android.os.RemoteException) IOException(java.io.IOException) CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException)

Example 4 with IChatSession

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

the class ConversationView method createChatSession.

private IChatSession createChatSession() {
    try {
        if (mConn != null) {
            IChatSessionManager sessionMgr = mConn.getChatSessionManager();
            if (sessionMgr != null) {
                String remoteAddress = mRemoteAddress;
                IChatSession session = null;
                if (mContactType == Imps.Contacts.TYPE_GROUP) {
                    // Contact contactGroup = new Contact(new XmppAddress(mRemoteAddress),mRemoteNickname,Imps.Contacts.TYPE_GROUP);
                    session = sessionMgr.createMultiUserChatSession(mRemoteAddress, mRemoteNickname, null, false);
                // new ChatSessionInitTask(((ImApp)mActivity.getApplication()),mProviderId, mAccountId, Imps.Contacts.TYPE_GROUP)
                // .executeOnExecutor(ImApp.sThreadPoolExecutor,contactGroup);
                } else {
                    remoteAddress = Address.stripResource(mRemoteAddress);
                    session = sessionMgr.createChatSession(remoteAddress, false);
                }
                return session;
            }
        }
    } catch (Exception e) {
        // mHandler.showServiceErrorAlert(e.getLocalizedMessage());
        LogCleaner.error(ImApp.LOG_TAG, "issue getting chat session", e);
    }
    return null;
}
Also used : IChatSessionManager(org.awesomeapp.messenger.service.IChatSessionManager) IChatSession(org.awesomeapp.messenger.service.IChatSession) RemoteException(android.os.RemoteException) IOException(java.io.IOException) CursorIndexOutOfBoundsException(android.database.CursorIndexOutOfBoundsException)

Example 5 with IChatSession

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

the class GroupDisplayActivity method changeGroupSubject.

private void changeGroupSubject(String subject) {
    try {
        IChatSession session = mConn.getChatSessionManager().getChatSession(mAddress);
        session.setGroupChatSubject(subject);
    } catch (Exception e) {
    }
}
Also used : IChatSession(org.awesomeapp.messenger.service.IChatSession) DecoderException(org.apache.commons.codec.DecoderException) RemoteException(android.os.RemoteException)

Aggregations

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