Search in sources :

Example 1 with Address

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

the class ChatSessionManagerAdapter method getChatSessionAdapter.

public synchronized ChatSessionAdapter getChatSessionAdapter(ChatSession session, boolean isNewSession) {
    Address participantAddress = session.getParticipant().getAddress();
    String key = Address.stripResource(participantAddress.getAddress());
    ChatSessionAdapter adapter = mActiveChatSessionAdapters.get(key);
    if (adapter == null) {
        adapter = new ChatSessionAdapter(session, mConnection, isNewSession);
        mActiveChatSessionAdapters.put(key, adapter);
    }
    return adapter;
}
Also used : Address(org.awesomeapp.messenger.model.Address) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress)

Example 2 with Address

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

the class ChatSessionManagerAdapter method createMultiUserChatSession.

public IChatSession createMultiUserChatSession(String roomAddress, String subject, String nickname, boolean isNewChat) {
    ChatGroupManager groupMan = mConnection.getAdaptee().getChatGroupManager();
    try {
        if (roomAddress.endsWith("@")) {
            String confServer = groupMan.getDefaultGroupChatService();
            if (confServer != null)
                roomAddress += confServer;
        }
        // TODO hard coding XMPP for now
        Address address = new XmppAddress(roomAddress);
        groupMan.createChatGroupAsync(roomAddress, subject, nickname);
        ChatGroup chatGroup = groupMan.getChatGroup(address);
        if (chatGroup != null && mConnection.getState() == ImConnection.LOGGED_IN) {
            ChatSession session = getChatSessionManager().createChatSession(chatGroup, isNewChat);
            ChatSessionAdapter adapter = getChatSessionAdapter(session, isNewChat);
            groupMan.loadMembers(chatGroup);
            return adapter;
        } else {
            return null;
        }
    } catch (Exception e) {
        Log.e(ImApp.LOG_TAG, "unable to join group chat" + e.getMessage());
        return null;
    }
}
Also used : Address(org.awesomeapp.messenger.model.Address) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) ChatGroup(org.awesomeapp.messenger.model.ChatGroup) IChatSession(org.awesomeapp.messenger.service.IChatSession) ChatSession(org.awesomeapp.messenger.model.ChatSession) RemoteException(android.os.RemoteException) ChatGroupManager(org.awesomeapp.messenger.model.ChatGroupManager)

Example 3 with Address

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

the class XmppConnection method findOrCreateParticipant.

synchronized ImEntity findOrCreateParticipant(String address, boolean isGroupChat) {
    ImEntity participant = null;
    if (isGroupChat) {
        Address xmppAddress = new XmppAddress(address);
        participant = mChatGroupManager.getChatGroup(xmppAddress);
        if (participant == null) {
            try {
                mChatGroupManager.createChatGroupAsync(address, xmppAddress.getUser(), mUser.getName());
                participant = mChatGroupManager.getChatGroup(xmppAddress);
            } catch (Exception e) {
                debug(TAG, "unable to join group chat: " + e);
                return null;
            }
        }
    } else {
        return mContactListManager.getContact(address);
    }
    return participant;
}
Also used : Address(org.awesomeapp.messenger.model.Address) HostAddress(org.jivesoftware.smack.util.dns.HostAddress) InetAddress(java.net.InetAddress) InetSocketAddress(java.net.InetSocketAddress) ImEntity(org.awesomeapp.messenger.model.ImEntity) KeyStoreException(java.security.KeyStoreException) UndecidedOmemoIdentityException(org.jivesoftware.smackx.omemo.exceptions.UndecidedOmemoIdentityException) XMPPException(org.jivesoftware.smack.XMPPException) RemoteException(android.os.RemoteException) IOException(java.io.IOException) ImException(org.awesomeapp.messenger.model.ImException) KeyManagementException(java.security.KeyManagementException) InvocationTargetException(java.lang.reflect.InvocationTargetException) XmppStringprepException(org.jxmpp.stringprep.XmppStringprepException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SmackException(org.jivesoftware.smack.SmackException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) MultiUserChatException(org.jivesoftware.smackx.muc.MultiUserChatException) CryptoFailedException(org.jivesoftware.smackx.omemo.exceptions.CryptoFailedException) CertificateException(java.security.cert.CertificateException)

Example 4 with Address

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

the class OtrEngineHostImpl method injectMessage.

public void injectMessage(SessionID sessionID, String text) {
    OtrDebugLogger.log(sessionID.toString() + ": injecting message: " + text);
    ImConnectionAdapter connection = findConnection(sessionID);
    if (connection != null) {
        ChatSessionManagerAdapter chatSessionManagerAdapter = (ChatSessionManagerAdapter) connection.getChatSessionManager();
        ChatSessionAdapter chatSessionAdapter = (ChatSessionAdapter) chatSessionManagerAdapter.getChatSession(sessionID.getRemoteUserId());
        if (chatSessionAdapter != null) {
            String body = text;
            if (body == null)
                // don't allow null messages, only empty ones!
                body = "";
            Message msg = new Message(body);
            Address to = new XmppAddress(sessionID.getRemoteUserId());
            msg.setTo(to);
            if (!to.getAddress().contains("/")) {
                // always send OTR messages to a resource
                msg.setTo(appendSessionResource(sessionID, to));
            }
            boolean verified = mOtrKeyManager.isVerified(sessionID);
            if (verified) {
                msg.setType(Imps.MessageType.OUTGOING_ENCRYPTED_VERIFIED);
            } else {
                msg.setType(Imps.MessageType.OUTGOING_ENCRYPTED);
            }
            // msg ID is set by plugin
            chatSessionManagerAdapter.getChatSessionManager().sendMessageAsync(chatSessionAdapter.getAdaptee(), msg);
        } else {
            OtrDebugLogger.log(sessionID.toString() + ": could not find chatSession");
        }
    } else {
        OtrDebugLogger.log(sessionID.toString() + ": could not find ImConnection");
    }
}
Also used : Message(org.awesomeapp.messenger.model.Message) Address(org.awesomeapp.messenger.model.Address) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) ChatSessionAdapter(org.awesomeapp.messenger.service.adapters.ChatSessionAdapter) XmppAddress(org.awesomeapp.messenger.plugin.xmpp.XmppAddress) ImConnectionAdapter(org.awesomeapp.messenger.service.adapters.ImConnectionAdapter) ChatSessionManagerAdapter(org.awesomeapp.messenger.service.adapters.ChatSessionManagerAdapter)

Aggregations

Address (org.awesomeapp.messenger.model.Address)4 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)3 RemoteException (android.os.RemoteException)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 ChatGroup (org.awesomeapp.messenger.model.ChatGroup)1 ChatGroupManager (org.awesomeapp.messenger.model.ChatGroupManager)1 ChatSession (org.awesomeapp.messenger.model.ChatSession)1 ImEntity (org.awesomeapp.messenger.model.ImEntity)1 ImException (org.awesomeapp.messenger.model.ImException)1 Message (org.awesomeapp.messenger.model.Message)1 IChatSession (org.awesomeapp.messenger.service.IChatSession)1 ChatSessionAdapter (org.awesomeapp.messenger.service.adapters.ChatSessionAdapter)1