Search in sources :

Example 61 with Jid

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);
}
Also used : InvalidJid(eu.siacs.conversations.xmpp.InvalidJid) Jid(eu.siacs.conversations.xmpp.Jid)

Example 62 with Jid

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);
    });
}
Also used : Jid(eu.siacs.conversations.xmpp.Jid) ArrayList(java.util.ArrayList) IOException(java.io.IOException) File(java.io.File) HashSet(java.util.HashSet)

Example 63 with Jid

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);
        }
    }
}
Also used : Jid(eu.siacs.conversations.xmpp.Jid)

Example 64 with Jid

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);
            }
        }
    }
}
Also used : Account(eu.siacs.conversations.entities.Account) Jid(eu.siacs.conversations.xmpp.Jid) SecureRandom(java.security.SecureRandom)

Example 65 with Jid

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();
    }
}
Also used : Account(eu.siacs.conversations.entities.Account) Jid(eu.siacs.conversations.xmpp.Jid) Intent(android.content.Intent) RtpEndUserState(eu.siacs.conversations.xmpp.jingle.RtpEndUserState)

Aggregations

Jid (eu.siacs.conversations.xmpp.Jid)106 Account (eu.siacs.conversations.entities.Account)35 Element (eu.siacs.conversations.xml.Element)24 Conversation (eu.siacs.conversations.entities.Conversation)22 Contact (eu.siacs.conversations.entities.Contact)17 InvalidJid (eu.siacs.conversations.xmpp.InvalidJid)16 IqPacket (eu.siacs.conversations.xmpp.stanzas.IqPacket)16 Intent (android.content.Intent)15 ArrayList (java.util.ArrayList)13 MucOptions (eu.siacs.conversations.entities.MucOptions)12 Bookmark (eu.siacs.conversations.entities.Bookmark)10 AxolotlService (eu.siacs.conversations.crypto.axolotl.AxolotlService)7 Message (eu.siacs.conversations.entities.Message)7 OnIqPacketReceived (eu.siacs.conversations.xmpp.OnIqPacketReceived)6 MessagePacket (eu.siacs.conversations.xmpp.stanzas.MessagePacket)6 Map (java.util.Map)6 XmppUri (eu.siacs.conversations.utils.XmppUri)5 XmppConnectionService (eu.siacs.conversations.services.XmppConnectionService)4 Avatar (eu.siacs.conversations.xmpp.pep.Avatar)4 HashMap (java.util.HashMap)4