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