Search in sources :

Example 21 with IqPacket

use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.

the class IqGenerator method queryAffiliation.

public IqPacket queryAffiliation(Conversation conversation, String affiliation) {
    IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
    packet.setTo(conversation.getJid().toBareJid());
    packet.query("http://jabber.org/protocol/muc#admin").addChild("item").setAttribute("affiliation", affiliation);
    return packet;
}
Also used : IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Example 22 with IqPacket

use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.

the class IqGenerator method generateGetBlockList.

public IqPacket generateGetBlockList() {
    final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
    iq.addChild("blocklist", Namespace.BLOCKING);
    return iq;
}
Also used : IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Example 23 with IqPacket

use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.

the class IqGenerator method generateSetPassword.

public IqPacket generateSetPassword(final Account account, final String newPassword) {
    final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
    packet.setTo(account.getServer());
    final Element query = packet.addChild("query", Namespace.REGISTER);
    final Jid jid = account.getJid();
    query.addChild("username").setContent(jid.getLocalpart());
    query.addChild("password").setContent(newPassword);
    return packet;
}
Also used : Jid(de.pixart.messenger.xmpp.jid.Jid) Element(de.pixart.messenger.xml.Element) IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Example 24 with IqPacket

use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.

the class IqGenerator method entityTimeResponse.

public IqPacket entityTimeResponse(IqPacket request) {
    final IqPacket packet = request.generateResponse(IqPacket.TYPE.RESULT);
    Element time = packet.addChild("time", "urn:xmpp:time");
    final long now = System.currentTimeMillis();
    time.addChild("utc").setContent(getTimestamp(now));
    TimeZone ourTimezone = TimeZone.getDefault();
    long offsetSeconds = ourTimezone.getOffset(now) / 1000;
    long offsetMinutes = Math.abs((offsetSeconds % 3600) / 60);
    long offsetHours = offsetSeconds / 3600;
    String hours;
    if (offsetHours < 0) {
        hours = String.format(Locale.US, "%03d", offsetHours);
    } else {
        hours = String.format(Locale.US, "%02d", offsetHours);
    }
    String minutes = String.format(Locale.US, "%02d", offsetMinutes);
    time.addChild("tzo").setContent(hours + ":" + minutes);
    return packet;
}
Also used : TimeZone(java.util.TimeZone) Element(de.pixart.messenger.xml.Element) IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Example 25 with IqPacket

use of de.pixart.messenger.xmpp.stanzas.IqPacket in project Pix-Art-Messenger by kriztan.

the class IqGenerator method purgeOfflineMessages.

public IqPacket purgeOfflineMessages() {
    final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
    packet.addChild("offline", Namespace.FLEXIBLE_OFFLINE_MESSAGE_RETRIEVAL).addChild("purge");
    return packet;
}
Also used : IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Aggregations

IqPacket (de.pixart.messenger.xmpp.stanzas.IqPacket)81 Element (de.pixart.messenger.xml.Element)48 Account (de.pixart.messenger.entities.Account)39 OnIqPacketReceived (de.pixart.messenger.xmpp.OnIqPacketReceived)31 Jid (de.pixart.messenger.xmpp.jid.Jid)15 ArrayList (java.util.ArrayList)7 Data (de.pixart.messenger.xmpp.forms.Data)6 InvalidJidException (de.pixart.messenger.xmpp.jid.InvalidJidException)6 PreKeyBundle (org.whispersystems.libsignal.state.PreKeyBundle)5 JinglePacket (de.pixart.messenger.xmpp.jingle.stanzas.JinglePacket)4 IOException (java.io.IOException)4 InvalidKeyException (org.whispersystems.libsignal.InvalidKeyException)4 Bundle (android.os.Bundle)3 Pair (android.util.Pair)3 Contact (de.pixart.messenger.entities.Contact)3 Conversation (de.pixart.messenger.entities.Conversation)3 FileNotFoundException (java.io.FileNotFoundException)3 InputStream (java.io.InputStream)3 HashSet (java.util.HashSet)3 List (java.util.List)3