use of eu.siacs.conversations.xmpp.Jid in project Conversations by siacs.
the class ShareViaAccountActivity method onBackendConnected.
@Override
void onBackendConnected() {
final int numAccounts = xmppConnectionService.getAccounts().size();
if (numAccounts == 1) {
final String body = getIntent().getStringExtra(EXTRA_BODY);
final Account account = xmppConnectionService.getAccounts().get(0);
try {
final Jid contact = Jid.of(getIntent().getStringExtra(EXTRA_CONTACT));
final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, contact, false, false);
switchToConversation(conversation, body);
} catch (IllegalArgumentException e) {
// ignore error
}
finish();
} else {
refreshUiReal();
}
}
use of eu.siacs.conversations.xmpp.Jid in project Conversations by siacs.
the class ProvisioningUtils method provision.
public static void provision(final Activity activity, final String json) {
final AccountConfiguration accountConfiguration;
try {
accountConfiguration = AccountConfiguration.parse(json);
} catch (final IllegalArgumentException e) {
Toast.makeText(activity, R.string.improperly_formatted_provisioning, Toast.LENGTH_LONG).show();
return;
}
final Jid jid = accountConfiguration.getJid();
final List<Jid> accounts = DatabaseBackend.getInstance(activity).getAccountJids(true);
if (accounts.contains(jid)) {
Toast.makeText(activity, R.string.account_already_exists, Toast.LENGTH_LONG).show();
return;
}
final Intent serviceIntent = new Intent(activity, XmppConnectionService.class);
serviceIntent.setAction(XmppConnectionService.ACTION_PROVISION_ACCOUNT);
serviceIntent.putExtra("address", jid.asBareJid().toEscapedString());
serviceIntent.putExtra("password", accountConfiguration.password);
Compatibility.startService(activity, serviceIntent);
final Intent intent = new Intent(activity, EditAccountActivity.class);
intent.putExtra("jid", jid.asBareJid().toEscapedString());
intent.putExtra("init", true);
activity.startActivity(intent);
}
use of eu.siacs.conversations.xmpp.Jid in project Conversations by siacs.
the class XmppConnectionService method sendBlockRequest.
public boolean sendBlockRequest(final Blockable blockable, boolean reportSpam) {
if (blockable != null && blockable.getBlockedJid() != null) {
final Jid jid = blockable.getBlockedJid();
this.sendIqPacket(blockable.getAccount(), getIqGenerator().generateSetBlockRequest(jid, reportSpam), (a, response) -> {
if (response.getType() == IqPacket.TYPE.RESULT) {
a.getBlocklist().add(jid);
updateBlocklistUi(OnUpdateBlocklist.Status.BLOCKED);
}
});
if (blockable.getBlockedJid().isFullJid()) {
return false;
} else if (removeBlockedConversations(blockable.getAccount(), jid)) {
updateConversationUi();
return true;
} else {
return false;
}
} else {
return false;
}
}
use of eu.siacs.conversations.xmpp.Jid in project Conversations by siacs.
the class XmppConnectionService method renameInMuc.
public boolean renameInMuc(final Conversation conversation, final String nick, final UiCallback<Conversation> callback) {
final MucOptions options = conversation.getMucOptions();
final Jid joinJid = options.createJoinJid(nick);
if (joinJid == null) {
return false;
}
if (options.online()) {
Account account = conversation.getAccount();
options.setOnRenameListener(new OnRenameListener() {
@Override
public void onSuccess() {
callback.success(conversation);
}
@Override
public void onFailure() {
callback.error(R.string.nick_in_use, conversation);
}
});
final PresencePacket packet = mPresenceGenerator.selfPresence(account, Presence.Status.ONLINE, options.nonanonymous());
packet.setTo(joinJid);
sendPresencePacket(account, packet);
} else {
conversation.setContactJid(joinJid);
databaseBackend.updateConversation(conversation);
if (conversation.getAccount().getStatus() == Account.State.ONLINE) {
Bookmark bookmark = conversation.getBookmark();
if (bookmark != null) {
bookmark.setNick(nick);
createBookmark(bookmark.getAccount(), bookmark);
}
joinMuc(conversation);
}
}
return true;
}
use of eu.siacs.conversations.xmpp.Jid in project Conversations by siacs.
the class MessageSearchTask method findOrGenerateStub.
private Conversational findOrGenerateStub(String conversationUuid, String accountUuid, String contactJid, int mode) throws Exception {
Conversation conversation = xmppConnectionService.findConversationByUuid(conversationUuid);
if (conversation != null) {
return conversation;
}
Account account = xmppConnectionService.findAccountByUuid(accountUuid);
Jid jid = Jid.of(contactJid);
if (account != null && jid != null) {
return new StubConversation(account, conversationUuid, jid.asBareJid(), mode);
}
throw new Exception("Unable to generate stub for " + contactJid);
}
Aggregations