Search in sources :

Example 71 with Jid

use of de.pixart.messenger.xmpp.jid.Jid in project Pix-Art-Messenger by kriztan.

the class ChooseContactActivity method showEnterJidDialog.

protected void showEnterJidDialog() {
    EnterJidDialog dialog = new EnterJidDialog(this, mKnownHosts, mActivatedAccounts, getString(R.string.enter_contact), getString(R.string.select), null, getIntent().getStringExtra(EXTRA_ACCOUNT), true, xmppConnectionService.multipleAccounts());
    dialog.setOnEnterJidDialogPositiveListener(new EnterJidDialog.OnEnterJidDialogPositiveListener() {

        @Override
        public boolean onEnterJidDialogPositive(Jid accountJid, Jid contactJid) throws EnterJidDialog.JidError {
            final Intent request = getIntent();
            final Intent data = new Intent();
            data.putExtra("contact", contactJid.toString());
            data.putExtra(EXTRA_ACCOUNT, accountJid.toString());
            data.putExtra("conversation", request.getStringExtra("conversation"));
            data.putExtra("multiple", false);
            data.putExtra("subject", request.getStringExtra("subject"));
            setResult(RESULT_OK, data);
            finish();
            return true;
        }
    });
    dialog.show();
}
Also used : Jid(de.pixart.messenger.xmpp.jid.Jid) Intent(android.content.Intent)

Example 72 with Jid

use of de.pixart.messenger.xmpp.jid.Jid in project Pix-Art-Messenger by kriztan.

the class ChooseContactActivity method create.

public static Intent create(Activity activity, Conversation conversation) {
    final Intent intent = new Intent(activity, ChooseContactActivity.class);
    List<String> contacts = new ArrayList<>();
    if (conversation.getMode() == Conversation.MODE_MULTI) {
        for (MucOptions.User user : conversation.getMucOptions().getUsers(false)) {
            Jid jid = user.getRealJid();
            if (jid != null) {
                contacts.add(jid.toBareJid().toString());
            }
        }
    } else {
        contacts.add(conversation.getJid().toBareJid().toString());
    }
    intent.putExtra("filter_contacts", contacts.toArray(new String[contacts.size()]));
    intent.putExtra("conversation", conversation.getUuid());
    intent.putExtra("multiple", true);
    intent.putExtra("show_enter_jid", true);
    intent.putExtra(EXTRA_ACCOUNT, conversation.getAccount().getJid().toBareJid().toString());
    return intent;
}
Also used : MucOptions(de.pixart.messenger.entities.MucOptions) Jid(de.pixart.messenger.xmpp.jid.Jid) ArrayList(java.util.ArrayList) Intent(android.content.Intent)

Example 73 with Jid

use of de.pixart.messenger.xmpp.jid.Jid in project Pix-Art-Messenger by kriztan.

the class XmppConnection method sendServiceDiscoveryItems.

private void sendServiceDiscoveryItems(final Jid server) {
    mPendingServiceDiscoveries.incrementAndGet();
    final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
    iq.setTo(server.toDomainJid());
    iq.query("http://jabber.org/protocol/disco#items");
    this.sendIqPacket(iq, new OnIqPacketReceived() {

        @Override
        public void onIqPacketReceived(final Account account, final IqPacket packet) {
            if (packet.getType() == IqPacket.TYPE.RESULT) {
                HashSet<Jid> items = new HashSet<Jid>();
                final List<Element> elements = packet.query().getChildren();
                for (final Element element : elements) {
                    if (element.getName().equals("item")) {
                        final Jid jid = element.getAttributeAsJid("jid");
                        if (jid != null && !jid.equals(account.getServer())) {
                            items.add(jid);
                        }
                    }
                }
                for (Jid jid : items) {
                    sendServiceDiscoveryInfo(jid);
                }
            } else {
                Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco items of " + server);
            }
            if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
                if (mPendingServiceDiscoveries.decrementAndGet() == 0 && mWaitForDisco.compareAndSet(true, false)) {
                    finalizeBind();
                }
            }
        }
    });
}
Also used : Account(de.pixart.messenger.entities.Account) Jid(de.pixart.messenger.xmpp.jid.Jid) Element(de.pixart.messenger.xml.Element) List(java.util.List) ArrayList(java.util.ArrayList) IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket) HashSet(java.util.HashSet)

Example 74 with Jid

use of de.pixart.messenger.xmpp.jid.Jid in project Pix-Art-Messenger by kriztan.

the class UIHelper method getDisplayName.

public static String getDisplayName(MucOptions.User user) {
    Contact contact = user.getContact();
    if (contact != null) {
        return contact.getDisplayName();
    } else {
        final String name = user.getName();
        if (name != null) {
            return name;
        }
        final Jid realJid = user.getRealJid();
        if (realJid != null) {
            return JidHelper.localPartOrFallback(realJid);
        }
        return null;
    }
}
Also used : Jid(de.pixart.messenger.xmpp.jid.Jid) Contact(de.pixart.messenger.entities.Contact)

Example 75 with Jid

use of de.pixart.messenger.xmpp.jid.Jid in project Pix-Art-Messenger by kriztan.

the class DatabaseBackend method getAccountJids.

public List<Jid> getAccountJids() {
    SQLiteDatabase db = this.getReadableDatabase();
    final List<Jid> jids = new ArrayList<>();
    final String[] columns = new String[] { Account.USERNAME, Account.SERVER };
    Cursor cursor = db.query(Account.TABLENAME, columns, null, null, null, null, null);
    try {
        while (cursor.moveToNext()) {
            jids.add(Jid.fromParts(cursor.getString(0), cursor.getString(1), null));
        }
        return jids;
    } catch (Exception e) {
        return jids;
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}
Also used : Jid(de.pixart.messenger.xmpp.jid.Jid) SQLiteDatabase(android.database.sqlite.SQLiteDatabase) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) JSONException(org.json.JSONException) CertificateEncodingException(java.security.cert.CertificateEncodingException) InvalidJidException(de.pixart.messenger.xmpp.jid.InvalidJidException) InvalidKeyException(org.whispersystems.libsignal.InvalidKeyException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException)

Aggregations

Jid (de.pixart.messenger.xmpp.jid.Jid)75 InvalidJidException (de.pixart.messenger.xmpp.jid.InvalidJidException)26 Account (de.pixart.messenger.entities.Account)24 Element (de.pixart.messenger.xml.Element)19 Conversation (de.pixart.messenger.entities.Conversation)18 IqPacket (de.pixart.messenger.xmpp.stanzas.IqPacket)15 Contact (de.pixart.messenger.entities.Contact)14 MucOptions (de.pixart.messenger.entities.MucOptions)11 ArrayList (java.util.ArrayList)11 OnIqPacketReceived (de.pixart.messenger.xmpp.OnIqPacketReceived)8 Message (de.pixart.messenger.entities.Message)7 Intent (android.content.Intent)6 AxolotlService (de.pixart.messenger.crypto.axolotl.AxolotlService)6 Bookmark (de.pixart.messenger.entities.Bookmark)6 MessagePacket (de.pixart.messenger.xmpp.stanzas.MessagePacket)4 Map (java.util.Map)4 SuppressLint (android.annotation.SuppressLint)3 AlertDialog (android.support.v7.app.AlertDialog)3 XmppAxolotlMessage (de.pixart.messenger.crypto.axolotl.XmppAxolotlMessage)3 HashMap (java.util.HashMap)3