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();
}
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;
}
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();
}
}
}
});
}
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;
}
}
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();
}
}
}
Aggregations