use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.
the class XmppConnectionService method pushMamPreferences.
public void pushMamPreferences(Account account, Element prefs) {
IqPacket set = new IqPacket(IqPacket.TYPE.SET);
set.addChild(prefs);
sendIqPacket(account, set, null);
}
use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.
the class XmppConnection method sendPing.
public void sendPing() {
if (!r()) {
final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
iq.setFrom(account.getJid());
iq.addChild("ping", "urn:xmpp:ping");
this.sendIqPacket(iq, null);
}
this.lastPingSent = SystemClock.elapsedRealtime();
}
use of de.pixart.messenger.xmpp.stanzas.IqPacket 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.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.
the class XmppConnection method sendStartSession.
private void sendStartSession() {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": sending legacy session to outdated server");
final IqPacket startSession = new IqPacket(IqPacket.TYPE.SET);
startSession.addChild("session", "urn:ietf:params:xml:ns:xmpp-session");
this.sendUnmodifiedIqPacket(startSession, (account, packet) -> {
if (packet.getType() == IqPacket.TYPE.RESULT) {
sendPostBindInitialization();
} else if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
throw new StateChangingError(Account.State.SESSION_FAILURE);
}
}, true);
}
use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.
the class XmppConnection method sendEnableCarbons.
private void sendEnableCarbons() {
final IqPacket iq = new IqPacket(IqPacket.TYPE.SET);
iq.addChild("enable", "urn:xmpp:carbons:2");
this.sendIqPacket(iq, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(final Account account, final IqPacket packet) {
if (!packet.hasChild("error")) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": successfully enabled carbons");
features.carbonsEnabled = true;
} else {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": error enableing carbons " + packet.toString());
}
}
});
}
Aggregations