Search in sources :

Example 6 with ImConnectionAdapter

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

the class RemoteImService method sendHeartbeat.

public void sendHeartbeat() {
    Debug.onHeartbeat();
    try {
        if (mNeedCheckAutoLogin && mNetworkState != NetworkConnectivityReceiver.State.NOT_CONNECTED) {
            debug("autoLogin from heartbeat");
            mNeedCheckAutoLogin = !autoLogin();
            ;
        }
        mHeartbeatInterval = Preferences.getHeartbeatInterval();
        debug("heartbeat interval: " + mHeartbeatInterval);
        for (ImConnectionAdapter conn : mConnections.values()) {
            conn.sendHeartbeat();
        }
    } finally {
        return;
    }
}
Also used : ImConnectionAdapter(org.awesomeapp.messenger.service.adapters.ImConnectionAdapter)

Example 7 with ImConnectionAdapter

use of org.awesomeapp.messenger.service.adapters.ImConnectionAdapter 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)

Example 8 with ImConnectionAdapter

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

the class OtrChatManager method askForSecret.

@Override
public void askForSecret(SessionID sessionID, String question) {
    Intent dialog = new Intent(mContext.getApplicationContext(), SmpResponseActivity.class);
    dialog.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    dialog.putExtra("q", question);
    // yes "sid" = remoteUserId in this case - see SMPResponseActivity
    dialog.putExtra("sid", sessionID.getRemoteUserId());
    ImConnectionAdapter connection = mOtrEngineHost.findConnection(sessionID);
    if (connection == null) {
        OtrDebugLogger.log("Could ask for secret - no connection for " + sessionID.toString());
        return;
    }
    dialog.putExtra(ImServiceConstants.EXTRA_INTENT_PROVIDER_ID, connection.getProviderId());
    mContext.getApplicationContext().startActivity(dialog);
}
Also used : Intent(android.content.Intent) ImConnectionAdapter(org.awesomeapp.messenger.service.adapters.ImConnectionAdapter)

Aggregations

ImConnectionAdapter (org.awesomeapp.messenger.service.adapters.ImConnectionAdapter)8 Date (java.util.Date)2 ContentResolver (android.content.ContentResolver)1 Intent (android.content.Intent)1 Cursor (android.database.Cursor)1 Handler (android.os.Handler)1 PowerManager (android.os.PowerManager)1 RemoteException (android.os.RemoteException)1 CacheWordHandler (info.guardianproject.cacheword.CacheWordHandler)1 Address (org.awesomeapp.messenger.model.Address)1 ConnectionFactory (org.awesomeapp.messenger.model.ConnectionFactory)1 ConnectionListener (org.awesomeapp.messenger.model.ConnectionListener)1 ImConnection (org.awesomeapp.messenger.model.ImConnection)1 ImErrorInfo (org.awesomeapp.messenger.model.ImErrorInfo)1 ImException (org.awesomeapp.messenger.model.ImException)1 Message (org.awesomeapp.messenger.model.Message)1 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)1 Imps (org.awesomeapp.messenger.provider.Imps)1 ChatSessionAdapter (org.awesomeapp.messenger.service.adapters.ChatSessionAdapter)1 ChatSessionManagerAdapter (org.awesomeapp.messenger.service.adapters.ChatSessionManagerAdapter)1