Search in sources :

Example 66 with Element

use of eu.siacs.conversations.xml.Element in project Conversations by siacs.

the class XmppConnectionService method pushBookmarks.

public void pushBookmarks(Account account) {
    Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": pushing bookmarks");
    IqPacket iqPacket = new IqPacket(IqPacket.TYPE.SET);
    Element query = iqPacket.query("jabber:iq:private");
    Element storage = query.addChild("storage", "storage:bookmarks");
    for (Bookmark bookmark : account.getBookmarks()) {
        storage.addChild(bookmark);
    }
    sendIqPacket(account, iqPacket, mDefaultIqHandler);
}
Also used : Bookmark(eu.siacs.conversations.entities.Bookmark) Element(eu.siacs.conversations.xml.Element) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Example 67 with Element

use of eu.siacs.conversations.xml.Element in project Conversations by siacs.

the class XmppAxolotlMessage method toElement.

public Element toElement() {
    Element encryptionElement = new Element(CONTAINERTAG, AxolotlService.PEP_PREFIX);
    Element headerElement = encryptionElement.addChild(HEADER);
    headerElement.setAttribute(SOURCEID, sourceDeviceId);
    for (Map.Entry<Integer, XmppAxolotlSession.AxolotlKey> keyEntry : keys.entrySet()) {
        Element keyElement = new Element(KEYTAG);
        keyElement.setAttribute(REMOTEID, keyEntry.getKey());
        if (keyEntry.getValue().prekey) {
            keyElement.setAttribute("prekey", "true");
        }
        keyElement.setContent(Base64.encodeToString(keyEntry.getValue().key, Base64.NO_WRAP));
        headerElement.addChild(keyElement);
    }
    headerElement.addChild(IVTAG).setContent(Base64.encodeToString(iv, Base64.NO_WRAP));
    if (ciphertext != null) {
        Element payload = encryptionElement.addChild(PAYLOAD);
        payload.setContent(Base64.encodeToString(ciphertext, Base64.NO_WRAP));
    }
    return encryptionElement;
}
Also used : Element(eu.siacs.conversations.xml.Element) HashMap(java.util.HashMap) Map(java.util.Map)

Example 68 with Element

use of eu.siacs.conversations.xml.Element in project Conversations by siacs.

the class IqGenerator method generateCreateAccountWithCaptcha.

public IqPacket generateCreateAccountWithCaptcha(Account account, String id, Data data) {
    final IqPacket register = new IqPacket(IqPacket.TYPE.SET);
    register.setFrom(account.getJid().toBareJid());
    register.setTo(account.getServer());
    register.setId(id);
    Element query = register.query("jabber:iq:register");
    if (data != null) {
        query.addChild(data);
    }
    return register;
}
Also used : Element(eu.siacs.conversations.xml.Element) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Example 69 with Element

use of eu.siacs.conversations.xml.Element in project Conversations by siacs.

the class IqGenerator method changeAffiliation.

public IqPacket changeAffiliation(Conversation conference, List<Jid> jids, String affiliation) {
    IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
    packet.setTo(conference.getJid().toBareJid());
    packet.setFrom(conference.getAccount().getJid());
    Element query = packet.query("http://jabber.org/protocol/muc#admin");
    for (Jid jid : jids) {
        Element item = query.addChild("item");
        item.setAttribute("jid", jid.toString());
        item.setAttribute("affiliation", affiliation);
    }
    return packet;
}
Also used : Jid(eu.siacs.conversations.xmpp.jid.Jid) Element(eu.siacs.conversations.xml.Element) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Example 70 with Element

use of eu.siacs.conversations.xml.Element in project Conversations by siacs.

the class IqGenerator method requestHttpUploadSlot.

public IqPacket requestHttpUploadSlot(Jid host, DownloadableFile file, String mime) {
    IqPacket packet = new IqPacket(IqPacket.TYPE.GET);
    packet.setTo(host);
    Element request = packet.addChild("request", Namespace.HTTP_UPLOAD);
    request.addChild("filename").setContent(convertFilename(file.getName()));
    request.addChild("size").setContent(String.valueOf(file.getExpectedSize()));
    if (mime != null) {
        request.addChild("content-type").setContent(mime);
    }
    return packet;
}
Also used : Element(eu.siacs.conversations.xml.Element) IqPacket(eu.siacs.conversations.xmpp.stanzas.IqPacket)

Aggregations

Element (eu.siacs.conversations.xml.Element)93 IqPacket (eu.siacs.conversations.xmpp.stanzas.IqPacket)43 Account (eu.siacs.conversations.entities.Account)21 Jid (eu.siacs.conversations.xmpp.jid.Jid)17 OnIqPacketReceived (eu.siacs.conversations.xmpp.OnIqPacketReceived)16 MessagePacket (eu.siacs.conversations.xmpp.stanzas.MessagePacket)8 Contact (eu.siacs.conversations.entities.Contact)7 Conversation (eu.siacs.conversations.entities.Conversation)6 ArrayList (java.util.ArrayList)6 Data (eu.siacs.conversations.xmpp.forms.Data)5 Avatar (eu.siacs.conversations.xmpp.pep.Avatar)5 IOException (java.io.IOException)5 MucOptions (eu.siacs.conversations.entities.MucOptions)4 PresencePacket (eu.siacs.conversations.xmpp.stanzas.PresencePacket)4 Pair (android.util.Pair)3 Bookmark (eu.siacs.conversations.entities.Bookmark)3 Message (eu.siacs.conversations.entities.Message)3 InvalidJidException (eu.siacs.conversations.xmpp.jid.InvalidJidException)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3