Search in sources :

Example 81 with Element

use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.

the class IqGenerator method publishVerification.

public IqPacket publishVerification(byte[] signature, X509Certificate[] certificates, final int deviceId) {
    final Element item = new Element("item");
    final Element verification = item.addChild("verification", AxolotlService.PEP_PREFIX);
    final Element chain = verification.addChild("chain");
    for (int i = 0; i < certificates.length; ++i) {
        try {
            Element certificate = chain.addChild("certificate");
            certificate.setContent(Base64.encodeToString(certificates[i].getEncoded(), Base64.DEFAULT));
            certificate.setAttribute("index", i);
        } catch (CertificateEncodingException e) {
            Log.d(Config.LOGTAG, "could not encode certificate");
        }
    }
    verification.addChild("signature").setContent(Base64.encodeToString(signature, Base64.DEFAULT));
    return publish(AxolotlService.PEP_VERIFICATION + ":" + deviceId, item);
}
Also used : Element(de.pixart.messenger.xml.Element) CertificateEncodingException(java.security.cert.CertificateEncodingException)

Example 82 with Element

use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.

the class IqGenerator method publishDeviceIds.

public IqPacket publishDeviceIds(final Set<Integer> ids, final Bundle publishOptions) {
    final Element item = new Element("item");
    final Element list = item.addChild("list", AxolotlService.PEP_PREFIX);
    for (Integer id : ids) {
        final Element device = new Element("device");
        device.setAttribute("id", id);
        list.addChild(device);
    }
    return publish(AxolotlService.PEP_DEVICE_LIST, item, publishOptions);
}
Also used : Element(de.pixart.messenger.xml.Element)

Example 83 with Element

use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.

the class IqGenerator method retrieve.

protected IqPacket retrieve(String node, Element item) {
    final IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
    final Element pubsub = packet.addChild("pubsub", "http://jabber.org/protocol/pubsub");
    final Element items = pubsub.addChild("items");
    items.setAttribute("node", node);
    if (item != null) {
        items.addChild(item);
    }
    return packet;
}
Also used : Element(de.pixart.messenger.xml.Element) IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Example 84 with Element

use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.

the class IqGenerator method changeRole.

public IqPacket changeRole(Conversation conference, String nick, String role) {
    IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
    packet.setTo(conference.getJid().toBareJid());
    packet.setFrom(conference.getAccount().getJid());
    Element item = packet.query("http://jabber.org/protocol/muc#admin").addChild("item");
    item.setAttribute("nick", nick);
    item.setAttribute("role", role);
    return packet;
}
Also used : Element(de.pixart.messenger.xml.Element) IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Example 85 with Element

use of de.pixart.messenger.xml.Element in project Pix-Art-Messenger by kriztan.

the class IqGenerator method pushTokenToAppServer.

public IqPacket pushTokenToAppServer(Jid appServer, String token, String deviceId) {
    IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
    packet.setTo(appServer);
    Element command = packet.addChild("command", "http://jabber.org/protocol/commands");
    command.setAttribute("node", "register-push-gcm");
    command.setAttribute("action", "execute");
    Data data = new Data();
    data.put("token", token);
    data.put("device-id", deviceId);
    data.submit();
    command.addChild(data);
    return packet;
}
Also used : Element(de.pixart.messenger.xml.Element) Data(de.pixart.messenger.xmpp.forms.Data) IqPacket(de.pixart.messenger.xmpp.stanzas.IqPacket)

Aggregations

Element (de.pixart.messenger.xml.Element)100 IqPacket (de.pixart.messenger.xmpp.stanzas.IqPacket)48 Account (de.pixart.messenger.entities.Account)23 Jid (de.pixart.messenger.xmpp.jid.Jid)19 OnIqPacketReceived (de.pixart.messenger.xmpp.OnIqPacketReceived)17 Contact (de.pixart.messenger.entities.Contact)9 MessagePacket (de.pixart.messenger.xmpp.stanzas.MessagePacket)8 ArrayList (java.util.ArrayList)7 Conversation (de.pixart.messenger.entities.Conversation)6 IOException (java.io.IOException)6 Data (de.pixart.messenger.xmpp.forms.Data)5 Avatar (de.pixart.messenger.xmpp.pep.Avatar)5 HashSet (java.util.HashSet)5 AxolotlService (de.pixart.messenger.crypto.axolotl.AxolotlService)4 MucOptions (de.pixart.messenger.entities.MucOptions)4 ECPublicKey (org.whispersystems.libsignal.ecc.ECPublicKey)4 PreKeyBundle (org.whispersystems.libsignal.state.PreKeyBundle)4 Pair (android.util.Pair)3 Bookmark (de.pixart.messenger.entities.Bookmark)3 Message (de.pixart.messenger.entities.Message)3