use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class OtrService method verify.
@Override
public void verify(SessionID id, String fingerprint, boolean approved) {
Log.d(Config.LOGTAG, "OtrService.verify(" + id.toString() + "," + fingerprint + "," + String.valueOf(approved) + ")");
try {
final Jid jid = Jid.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account, jid);
if (conversation != null) {
if (approved) {
conversation.getContact().addOtrFingerprint(fingerprint);
}
conversation.smp().hint = null;
conversation.smp().status = Conversation.Smp.STATUS_VERIFIED;
mXmppConnectionService.updateConversationUi();
mXmppConnectionService.syncRosterToDisk(conversation.getAccount());
}
} catch (final InvalidJidException ignored) {
}
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ConversationFragment method saveMessageDraftStopAudioPlayer.
private void saveMessageDraftStopAudioPlayer() {
final Conversation previousConversation = this.conversation;
if (this.activity == null || this.binding == null || previousConversation == null) {
return;
}
Log.d(Config.LOGTAG, "ConversationFragment.saveMessageDraftStopAudioPlayer()");
final String msg = this.binding.textinput.getText().toString();
if (previousConversation.setNextMessage(msg)) {
activity.xmppConnectionService.updateConversation(previousConversation);
}
updateChatState(this.conversation, msg);
messageListAdapter.stopAudioPlayer();
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ConversationFragment method sendMessage.
private void sendMessage() {
final String body = binding.textinput.getText().toString();
final Conversation conversation = this.conversation;
if (body.length() == 0 || conversation == null) {
return;
}
final Message message;
if (conversation.getCorrectingMessage() == null) {
message = new Message(conversation, body, conversation.getNextEncryption());
if (conversation.getMode() == Conversation.MODE_MULTI) {
final Jid nextCounterpart = conversation.getNextCounterpart();
if (nextCounterpart != null) {
message.setCounterpart(nextCounterpart);
message.setTrueCounterpart(conversation.getMucOptions().getTrueCounterpart(nextCounterpart));
message.setType(Message.TYPE_PRIVATE);
}
}
} else {
message = conversation.getCorrectingMessage();
message.setBody(body);
message.setEdited(message.getUuid());
message.setUuid(UUID.randomUUID().toString());
}
switch(message.getConversation().getNextEncryption()) {
case Message.ENCRYPTION_OTR:
sendOtrMessage(message);
break;
case Message.ENCRYPTION_PGP:
sendPgpMessage(message);
break;
case Message.ENCRYPTION_AXOLOTL:
if (!trustKeysIfNeeded(REQUEST_TRUST_KEYS_TEXT)) {
sendAxolotlMessage(message);
}
break;
default:
sendPlainTextMessage(message);
}
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ConversationsOverviewFragment method getSuggestion.
public static Conversation getSuggestion(Activity activity) {
final Conversation exception;
Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment);
if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
exception = ((ConversationsOverviewFragment) fragment).swipedConversation.peek();
} else {
exception = null;
}
return getSuggestion(activity, exception);
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class XmppConnectionService method deleteAccount.
public void deleteAccount(final Account account) {
synchronized (this.conversations) {
for (final Conversation conversation : conversations) {
if (conversation.getAccount() == account) {
if (conversation.getMode() == Conversation.MODE_MULTI) {
leaveMuc(conversation);
} else if (conversation.getMode() == Conversation.MODE_SINGLE) {
conversation.endOtrIfNeeded();
}
conversations.remove(conversation);
}
}
if (account.getXmppConnection() != null) {
new Thread(() -> disconnect(account, true)).start();
}
final Runnable runnable = () -> {
if (!databaseBackend.deleteAccount(account)) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": unable to delete account");
}
};
mDatabaseWriterExecutor.execute(runnable);
this.accounts.remove(account);
updateAccountUi();
getNotificationService().updateErrorNotification();
syncEnabledAccountSetting();
}
}
Aggregations