use of eu.siacs.conversations.xmpp.jid.Jid in project Conversations by siacs.
the class ConversationActivity method quickOmemoDebugger.
private boolean quickOmemoDebugger(Conversation c) {
if (c != null) {
boolean single = c.getMode() == Conversation.MODE_SINGLE;
AxolotlService axolotlService = c.getAccount().getAxolotlService();
Pair<AxolotlService.AxolotlCapability, Jid> capabilityJidPair = axolotlService.isConversationAxolotlCapableDetailed(c);
switch(capabilityJidPair.first) {
case MISSING_PRESENCE:
Toast.makeText(ConversationActivity.this, single ? getString(R.string.missing_presence_subscription) : getString(R.string.missing_presence_subscription_with_x, capabilityJidPair.second.toBareJid().toString()), Toast.LENGTH_SHORT).show();
return true;
case MISSING_KEYS:
Toast.makeText(ConversationActivity.this, single ? getString(R.string.missing_omemo_keys) : getString(R.string.missing_keys_from_x, capabilityJidPair.second.toBareJid().toString()), Toast.LENGTH_SHORT).show();
return true;
case WRONG_CONFIGURATION:
Toast.makeText(ConversationActivity.this, R.string.wrong_conference_configuration, Toast.LENGTH_SHORT).show();
return true;
case NO_MEMBERS:
Toast.makeText(ConversationActivity.this, R.string.this_conference_has_no_members, Toast.LENGTH_SHORT).show();
return true;
}
}
return false;
}
use of eu.siacs.conversations.xmpp.jid.Jid in project Conversations by siacs.
the class ConversationActivity method handleViewConversationIntent.
private void handleViewConversationIntent(final Intent intent) {
final String uuid = intent.getStringExtra(CONVERSATION);
final String downloadUuid = intent.getStringExtra(EXTRA_DOWNLOAD_UUID);
final String text = intent.getStringExtra(TEXT);
final String nick = intent.getStringExtra(NICK);
final boolean pm = intent.getBooleanExtra(PRIVATE_MESSAGE, false);
if (selectConversationByUuid(uuid)) {
this.mConversationFragment.reInit(getSelectedConversation());
if (nick != null) {
if (pm) {
Jid jid = getSelectedConversation().getJid();
try {
Jid next = Jid.fromParts(jid.getLocalpart(), jid.getDomainpart(), nick);
this.mConversationFragment.privateMessageWith(next);
} catch (final InvalidJidException ignored) {
//do nothing
}
} else {
this.mConversationFragment.highlightInConference(nick);
}
} else {
this.mConversationFragment.appendText(text);
}
hideConversationsOverview();
mUnprocessedNewIntent = false;
openConversation();
if (mContentView instanceof SlidingPaneLayout) {
//fixes bug where slp isn't properly closed yet
updateActionBarTitle(true);
}
if (downloadUuid != null) {
final Message message = mSelectedConversation.findMessageWithFileAndUuid(downloadUuid);
if (message != null) {
startDownloadable(message);
}
}
} else {
mUnprocessedNewIntent = false;
}
}
use of eu.siacs.conversations.xmpp.jid.Jid in project Conversations by siacs.
the class ConversationActivity method trustKeysIfNeeded.
protected boolean trustKeysIfNeeded(int requestCode, int attachmentChoice) {
AxolotlService axolotlService = mSelectedConversation.getAccount().getAxolotlService();
final List<Jid> targets = axolotlService.getCryptoTargets(mSelectedConversation);
boolean hasUnaccepted = !mSelectedConversation.getAcceptedCryptoTargets().containsAll(targets);
boolean hasUndecidedOwn = !axolotlService.getKeysWithTrust(FingerprintStatus.createActiveUndecided()).isEmpty();
boolean hasUndecidedContacts = !axolotlService.getKeysWithTrust(FingerprintStatus.createActiveUndecided(), targets).isEmpty();
boolean hasPendingKeys = !axolotlService.findDevicesWithoutSession(mSelectedConversation).isEmpty();
boolean hasNoTrustedKeys = axolotlService.anyTargetHasNoTrustedKeys(targets);
if (hasUndecidedOwn || hasUndecidedContacts || hasPendingKeys || hasNoTrustedKeys || hasUnaccepted) {
axolotlService.createSessionsIfNeeded(mSelectedConversation);
Intent intent = new Intent(getApplicationContext(), TrustKeysActivity.class);
String[] contacts = new String[targets.size()];
for (int i = 0; i < contacts.length; ++i) {
contacts[i] = targets.get(i).toString();
}
intent.putExtra("contacts", contacts);
intent.putExtra(EXTRA_ACCOUNT, mSelectedConversation.getAccount().getJid().toBareJid().toString());
intent.putExtra("choice", attachmentChoice);
intent.putExtra("conversation", mSelectedConversation.getUuid());
startActivityForResult(intent, requestCode);
return true;
} else {
return false;
}
}
use of eu.siacs.conversations.xmpp.jid.Jid in project Conversations by siacs.
the class XmppConnectionService method fetchBookmarks.
public void fetchBookmarks(final Account account) {
final IqPacket iqPacket = new IqPacket(IqPacket.TYPE.GET);
final Element query = iqPacket.query("jabber:iq:private");
query.addChild("storage", "storage:bookmarks");
final OnIqPacketReceived callback = new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(final Account account, final IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT) {
final Element query = packet.query();
final HashMap<Jid, Bookmark> bookmarks = new HashMap<>();
final Element storage = query.findChild("storage", "storage:bookmarks");
final boolean autojoin = respectAutojoin();
if (storage != null) {
for (final Element item : storage.getChildren()) {
if (item.getName().equals("conference")) {
final Bookmark bookmark = Bookmark.parse(item, account);
Bookmark old = bookmarks.put(bookmark.getJid(), bookmark);
if (old != null && old.getBookmarkName() != null && bookmark.getBookmarkName() == null) {
bookmark.setBookmarkName(old.getBookmarkName());
}
Conversation conversation = find(bookmark);
if (conversation != null) {
conversation.setBookmark(bookmark);
} else if (bookmark.autojoin() && bookmark.getJid() != null && autojoin) {
conversation = findOrCreateConversation(account, bookmark.getJid(), true, true);
conversation.setBookmark(bookmark);
}
}
}
}
account.setBookmarks(new ArrayList<>(bookmarks.values()));
} else {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not fetch bookmarks");
}
}
};
sendIqPacket(account, iqPacket, callback);
}
use of eu.siacs.conversations.xmpp.jid.Jid in project Conversations by siacs.
the class XmppConnectionService method createAdhocConference.
public boolean createAdhocConference(final Account account, final String subject, final Iterable<Jid> jids, final UiCallback<Conversation> callback) {
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": creating adhoc conference with " + jids.toString());
if (account.getStatus() == Account.State.ONLINE) {
try {
String server = findConferenceServer(account);
if (server == null) {
if (callback != null) {
callback.error(R.string.no_conference_server_found, null);
}
return false;
}
final Jid jid = Jid.fromParts(new BigInteger(64, getRNG()).toString(Character.MAX_RADIX), server, null);
final Conversation conversation = findOrCreateConversation(account, jid, true, false);
joinMuc(conversation, new OnConferenceJoined() {
@Override
public void onConferenceJoined(final Conversation conversation) {
pushConferenceConfiguration(conversation, IqGenerator.defaultRoomConfiguration(), new OnConfigurationPushed() {
@Override
public void onPushSucceeded() {
if (subject != null && !subject.trim().isEmpty()) {
pushSubjectToConference(conversation, subject.trim());
}
for (Jid invite : jids) {
invite(conversation, invite);
}
if (account.countPresences() > 1) {
directInvite(conversation, account.getJid().toBareJid());
}
saveConversationAsBookmark(conversation, subject);
if (callback != null) {
callback.success(conversation);
}
}
@Override
public void onPushFailed() {
archiveConversation(conversation);
if (callback != null) {
callback.error(R.string.conference_creation_failed, conversation);
}
}
});
}
});
return true;
} catch (InvalidJidException e) {
if (callback != null) {
callback.error(R.string.conference_creation_failed, null);
}
return false;
}
} else {
if (callback != null) {
callback.error(R.string.not_connected_try_again, null);
}
return false;
}
}
Aggregations