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;
}
}
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");
}
}
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);
}
Aggregations