use of eu.siacs.conversations.xmpp.Jid in project Conversations by siacs.
the class Bookmark method match.
@Override
public boolean match(Context context, String needle) {
if (needle == null) {
return true;
}
needle = needle.toLowerCase(Locale.US);
final Jid jid = getJid();
return (jid != null && jid.toString().contains(needle)) || getDisplayName().toLowerCase(Locale.US).contains(needle) || matchInTag(context, needle);
}
use of eu.siacs.conversations.xmpp.Jid in project Conversations by siacs.
the class ImportBackupService method loadBackupFiles.
public void loadBackupFiles(final OnBackupFilesLoaded onBackupFilesLoaded) {
executor.execute(() -> {
final List<Jid> accounts = mDatabaseBackend.getAccountJids(false);
final ArrayList<BackupFile> backupFiles = new ArrayList<>();
final Set<String> apps = new HashSet<>(Arrays.asList("Conversations", "Quicksy", getString(R.string.app_name)));
for (String app : apps) {
final File directory = new File(FileBackend.getBackupDirectory(app));
if (!directory.exists() || !directory.isDirectory()) {
Log.d(Config.LOGTAG, "directory not found: " + directory.getAbsolutePath());
continue;
}
final File[] files = directory.listFiles();
if (files == null) {
onBackupFilesLoaded.onBackupFilesLoaded(backupFiles);
return;
}
for (final File file : files) {
if (file.isFile() && file.getName().endsWith(".ceb")) {
try {
final BackupFile backupFile = BackupFile.read(file);
if (accounts.contains(backupFile.getHeader().getJid())) {
Log.d(Config.LOGTAG, "skipping backup for " + backupFile.getHeader().getJid());
} else {
backupFiles.add(backupFile);
}
} catch (IOException | IllegalArgumentException e) {
Log.d(Config.LOGTAG, "unable to read backup file ", e);
}
}
}
}
Collections.sort(backupFiles, (a, b) -> a.header.getJid().toString().compareTo(b.header.getJid().toString()));
onBackupFilesLoaded.onBackupFilesLoaded(backupFiles);
});
}
use of eu.siacs.conversations.xmpp.Jid in project Conversations by siacs.
the class MagicCreateActivity method updateFullJidInformation.
private void updateFullJidInformation(final String username) {
if (username.trim().isEmpty()) {
binding.fullJid.setVisibility(View.INVISIBLE);
} else {
try {
binding.fullJid.setVisibility(View.VISIBLE);
final Jid jid;
if (this.domain == null) {
jid = Jid.ofLocalAndDomainEscaped(username, Config.MAGIC_CREATE_DOMAIN);
} else {
jid = Jid.ofLocalAndDomainEscaped(username, this.domain);
}
binding.fullJid.setText(getString(R.string.your_full_jid_will_be, jid.toEscapedString()));
} catch (IllegalArgumentException e) {
binding.fullJid.setVisibility(View.INVISIBLE);
}
}
}
use of eu.siacs.conversations.xmpp.Jid in project Conversations by siacs.
the class QuickConversationsService method createAccountAndWait.
private void createAccountAndWait(Phonenumber.PhoneNumber phoneNumber, final long timestamp) {
String local = PhoneNumberUtilWrapper.normalize(service, phoneNumber);
Log.d(Config.LOGTAG, "requesting verification for " + PhoneNumberUtilWrapper.normalize(service, phoneNumber));
Jid jid = Jid.of(local, Config.QUICKSY_DOMAIN, null);
Account account = AccountUtils.getFirst(service);
if (account == null || !account.getJid().asBareJid().equals(jid.asBareJid())) {
if (account != null) {
service.deleteAccount(account);
}
account = new Account(jid, CryptoHelper.createPassword(new SecureRandom()));
account.setOption(Account.OPTION_DISABLED, true);
account.setOption(Account.OPTION_MAGIC_CREATE, true);
account.setOption(Account.OPTION_UNVERIFIED, true);
service.createAccount(account);
}
synchronized (mOnVerificationRequested) {
for (OnVerificationRequested onVerificationRequested : mOnVerificationRequested) {
if (timestamp <= 0) {
onVerificationRequested.onVerificationRequested();
} else {
onVerificationRequested.onVerificationRequestedRetryAt(timestamp);
}
}
}
}
use of eu.siacs.conversations.xmpp.Jid in project Conversations by siacs.
the class RtpSessionActivity method onBackendConnected.
@Override
void onBackendConnected() {
final Intent intent = getIntent();
final String action = intent.getAction();
final Account account = extractAccount(intent);
final Jid with = Jid.ofEscaped(intent.getStringExtra(EXTRA_WITH));
final String sessionId = intent.getStringExtra(EXTRA_SESSION_ID);
if (sessionId != null) {
if (initializeActivityWithRunningRtpSession(account, with, sessionId)) {
return;
}
if (ACTION_ACCEPT_CALL.equals(intent.getAction())) {
Log.d(Config.LOGTAG, "intent action was accept");
requestPermissionsAndAcceptCall();
resetIntent(intent.getExtras());
}
} else if (asList(ACTION_MAKE_VIDEO_CALL, ACTION_MAKE_VOICE_CALL).contains(action)) {
proposeJingleRtpSession(account, with, actionToMedia(action));
binding.with.setText(account.getRoster().getContact(with).getDisplayName());
} else if (Intent.ACTION_VIEW.equals(action)) {
final String extraLastState = intent.getStringExtra(EXTRA_LAST_REPORTED_STATE);
final RtpEndUserState state = extraLastState == null ? null : RtpEndUserState.valueOf(extraLastState);
if (state != null) {
Log.d(Config.LOGTAG, "restored last state from intent extra");
updateButtonConfiguration(state);
updateVerifiedShield(false);
updateStateDisplay(state);
updateProfilePicture(state);
invalidateOptionsMenu();
}
binding.with.setText(account.getRoster().getContact(with).getDisplayName());
if (xmppConnectionService.getJingleConnectionManager().fireJingleRtpConnectionStateUpdates()) {
return;
}
if (END_CARD.contains(state) || xmppConnectionService.getJingleConnectionManager().hasMatchingProposal(account, with)) {
return;
}
Log.d(Config.LOGTAG, "restored state (" + state + ") was not an end card. finishing");
finish();
}
}
Aggregations