use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class ChatStateManager method updateChatState.
/**
* Update chat state information and send message if necessary.
*/
private void updateChatState(AccountJid account, UserJid user, ChatState chatState) {
if (!SettingsManager.chatsStateNotification() || sent.get(account.toString(), user.toString()) == chatState) {
return;
}
AbstractChat chat = MessageManager.getInstance().getChat(account, user);
if (chat == null || !isSupported(chat, false)) {
return;
}
sent.put(chat.getAccount().toString(), chat.getUser().toString(), chatState);
Message message = new Message();
message.setType(chat.getType());
message.setTo(chat.getTo());
message.addExtension(new ChatStateExtension(chatState));
try {
StanzaSender.sendStanza(account, message);
} catch (NetworkException e) {
// Just ignore it.
}
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class MUCManager method createRoom.
/**
* Creates or updates existed room.
*/
public void createRoom(AccountJid account, EntityBareJid room, Resourcepart nickname, String password, boolean join) {
removeInvite(getInvite(account, room));
AbstractChat chat = null;
try {
chat = MessageManager.getInstance().getChat(account, UserJid.from(room));
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
}
RoomChat roomChat;
if (chat == null || !(chat instanceof RoomChat)) {
if (chat != null) {
MessageManager.getInstance().removeChat(chat);
}
try {
roomChat = RoomChat.create(account, room, nickname, password);
MessageManager.getInstance().addChat(roomChat);
} catch (UserJid.UserJidCreateException e) {
LogManager.exception(this, e);
}
} else {
roomChat = (RoomChat) chat;
roomChat.setNickname(nickname);
roomChat.setPassword(password);
}
requestToWriteRoom(account, room, nickname, password, join);
if (join) {
joinRoom(account, room, true);
}
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class OTRManager method endSession.
private void endSession(String account, String user) throws NetworkException {
LogManager.i(this, "Ending session for " + user);
try {
getOrCreateSession(account, user).endSession();
} catch (OtrException e) {
throw new NetworkException(R.string.OTR_ERROR, e);
}
AbstractChat abstractChat = getChat(account, user);
if (abstractChat != null) {
SSNManager.getInstance().setSessionOtrMode(account, user, abstractChat.getThreadId(), OtrMode.concede);
LogManager.i(this, "Ended session for " + user);
}
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class OTRManager method newAction.
/**
* Creates new action in specified chat.
*/
private void newAction(String account, String user, String text, ChatAction action) {
LogManager.i(this, "newAction. text: " + text + " action " + action);
AbstractChat chat = getChat(account, user);
if (chat != null) {
chat.newAction(null, text, action);
}
}
use of com.xabber.android.data.message.AbstractChat in project xabber-android by redsolution.
the class OTRManager method injectMessage.
private void injectMessage(String account, String user, String msg) throws OtrException {
LogManager.i(this, "injectMessage. user: " + user + " message: " + msg);
AbstractChat abstractChat = getChat(account, user);
SSNManager.getInstance().setSessionOtrMode(account, user, abstractChat.getThreadId(), OtrMode.prefer);
Message message = abstractChat.createMessagePacket(msg);
CarbonManager.getInstance().setMessageToIgnoreCarbons(message);
try {
StanzaSender.sendStanza(abstractChat.getAccount(), message);
} catch (NetworkException e) {
throw new OtrException(e);
}
}
Aggregations