use of eu.siacs.conversations.xmpp.jid.InvalidJidException in project Conversations by siacs.
the class OtrService method setSmpStatus.
private void setSmpStatus(SessionID id, int status) {
try {
final Jid jid = Jid.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account, jid);
if (conversation != null) {
conversation.smp().status = status;
mXmppConnectionService.updateConversationUi();
}
} catch (final InvalidJidException ignored) {
}
}
use of eu.siacs.conversations.xmpp.jid.InvalidJidException in project Conversations by siacs.
the class OtrService method askForSecret.
@Override
public void askForSecret(SessionID id, InstanceTag instanceTag, String question) {
try {
final Jid jid = Jid.fromSessionID(id);
Conversation conversation = this.mXmppConnectionService.find(this.account, jid);
if (conversation != null) {
conversation.smp().hint = question;
conversation.smp().status = Conversation.Smp.STATUS_CONTACT_REQUESTED;
mXmppConnectionService.updateConversationUi();
}
} catch (InvalidJidException e) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": smp in invalid session " + id.toString());
}
}
use of eu.siacs.conversations.xmpp.jid.InvalidJidException in project Conversations by siacs.
the class PushManagementService method registerPushTokenOnServer.
public void registerPushTokenOnServer(final Account account) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": has push support");
retrieveGcmInstanceToken(new OnGcmInstanceTokenRetrieved() {
@Override
public void onGcmInstanceTokenRetrieved(String token) {
try {
final String deviceId = Settings.Secure.getString(mXmppConnectionService.getContentResolver(), Settings.Secure.ANDROID_ID);
IqPacket packet = mXmppConnectionService.getIqGenerator().pushTokenToAppServer(Jid.fromString(APP_SERVER), token, deviceId);
mXmppConnectionService.sendIqPacket(account, packet, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
Element command = packet.findChild("command", "http://jabber.org/protocol/commands");
if (packet.getType() == IqPacket.TYPE.RESULT && command != null) {
Element x = command.findChild("x", "jabber:x:data");
if (x != null) {
Data data = Data.parse(x);
try {
String node = data.getValue("node");
String secret = data.getValue("secret");
Jid jid = Jid.fromString(data.getValue("jid"));
if (node != null && secret != null) {
enablePushOnServer(account, jid, node, secret);
}
} catch (InvalidJidException e) {
e.printStackTrace();
}
}
} else {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": invalid response from app server");
}
}
});
} catch (InvalidJidException ignored) {
}
}
});
}
use of eu.siacs.conversations.xmpp.jid.InvalidJidException in project Conversations by siacs.
the class SettingsActivity method deleteOmemoIdentities.
private void deleteOmemoIdentities() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.pref_delete_omemo_identities);
final List<CharSequence> accounts = new ArrayList<>();
for (Account account : xmppConnectionService.getAccounts()) {
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
accounts.add(account.getJid().toBareJid().toString());
}
}
final boolean[] checkedItems = new boolean[accounts.size()];
builder.setMultiChoiceItems(accounts.toArray(new CharSequence[accounts.size()]), checkedItems, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
checkedItems[which] = isChecked;
final AlertDialog alertDialog = (AlertDialog) dialog;
for (boolean item : checkedItems) {
if (item) {
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(true);
return;
}
}
alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(false);
}
});
builder.setNegativeButton(R.string.cancel, null);
builder.setPositiveButton(R.string.delete_selected_keys, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
for (int i = 0; i < checkedItems.length; ++i) {
if (checkedItems[i]) {
try {
Jid jid = Jid.fromString(accounts.get(i).toString());
Account account = xmppConnectionService.findAccountByJid(jid);
if (account != null) {
account.getAxolotlService().regenerateKeys(true);
}
} catch (InvalidJidException e) {
//
}
}
}
}
});
AlertDialog dialog = builder.create();
dialog.show();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
use of eu.siacs.conversations.xmpp.jid.InvalidJidException in project Conversations by siacs.
the class ShareWithActivity method share.
private void share() {
final Conversation conversation;
if (share.uuid != null) {
conversation = xmppConnectionService.findConversationByUuid(share.uuid);
if (conversation == null) {
return;
}
} else {
Account account;
try {
account = xmppConnectionService.findAccountByJid(Jid.fromString(share.account));
} catch (final InvalidJidException e) {
account = null;
}
if (account == null) {
return;
}
try {
conversation = xmppConnectionService.findOrCreateConversation(account, Jid.fromString(share.contact), false);
} catch (final InvalidJidException e) {
return;
}
}
share(conversation);
}
Aggregations