コード例 #1
0
void QXmppDataForm::toXml(QXmlStreamWriter *writer) const
{
    if (isNull())
        return;

    writer->writeStartElement("x");
    writer->writeAttribute("xmlns", ns_data);

    /* form type */
    QString typeStr;
    if (d->type == QXmppDataForm::Form)
        typeStr = "form";
    else if (d->type == QXmppDataForm::Submit)
        typeStr = "submit";
    else if (d->type == QXmppDataForm::Cancel)
        typeStr = "cancel";
    else if (d->type == QXmppDataForm::Result)
        typeStr = "result";
    writer->writeAttribute("type", typeStr);

    /* form properties */
    if (!d->title.isEmpty())
        writer->writeTextElement("title", d->title);
    if (!d->instructions.isEmpty())
        writer->writeTextElement("instructions", d->instructions);

    foreach (const QXmppDataForm::Field &field, d->fields) {
        writer->writeStartElement("field");

        /* field type */
        const QXmppDataForm::Field::Type type = field.type();
        QString typeStr;
        struct field_type *ptr;
        for (ptr = field_types; ptr->str; ptr++)
        {
            if (type == ptr->type)
            {
                typeStr = ptr->str;
                break;
            }
        }
        writer->writeAttribute("type", typeStr);

        /* field attributes */
        helperToXmlAddAttribute(writer, "label", field.label());
        helperToXmlAddAttribute(writer, "var", field.key());

        /* field value(s) */
        if (type == QXmppDataForm::Field::BooleanField)
        {
            helperToXmlAddTextElement(writer, "value", field.value().toBool() ? "1" : "0");
        }
        else if (type == QXmppDataForm::Field::ListMultiField ||
            type == QXmppDataForm::Field::JidMultiField ||
            type == QXmppDataForm::Field::TextMultiField)
        {
            foreach (const QString &value, field.value().toStringList())
                helperToXmlAddTextElement(writer, "value", value);
        }
        else if (!field.value().isNull())
コード例 #2
0
void QXmppPresence::toXml(QXmlStreamWriter *xmlWriter) const
{
    xmlWriter->writeStartElement("presence");
    helperToXmlAddAttribute(xmlWriter,"xml:lang", lang());
    helperToXmlAddAttribute(xmlWriter,"id", id());
    helperToXmlAddAttribute(xmlWriter,"to", to());
    helperToXmlAddAttribute(xmlWriter,"from", from());
    helperToXmlAddAttribute(xmlWriter,"type", presence_types[d->type]);
    d->status.toXml(xmlWriter);

    error().toXml(xmlWriter);

    // XEP-0045: Multi-User Chat
    if(d->mucSupported) {
        xmlWriter->writeStartElement("x");
        xmlWriter->writeAttribute("xmlns", ns_muc);
        if (!d->mucPassword.isEmpty())
            xmlWriter->writeTextElement("password", d->mucPassword);
        xmlWriter->writeEndElement();
    }

    if(!d->mucItem.isNull() || !d->mucStatusCodes.isEmpty())
    {
        xmlWriter->writeStartElement("x");
        xmlWriter->writeAttribute("xmlns", ns_muc_user);
        if (!d->mucItem.isNull())
            d->mucItem.toXml(xmlWriter);
        foreach (int code, d->mucStatusCodes) {
            xmlWriter->writeStartElement("status");
            xmlWriter->writeAttribute("code", QString::number(code));
            xmlWriter->writeEndElement();
        }
        xmlWriter->writeEndElement();
    }
コード例 #3
0
 foreach (const QXmppBookmarkUrl &url, m_urls)
 {
     writer->writeStartElement("url");
     helperToXmlAddAttribute(writer, "name", url.name());
     helperToXmlAddAttribute(writer, "url", url.url().toString());
     writer->writeEndElement();
 }
コード例 #4
0
ファイル: QXmppStanza.cpp プロジェクト: jankusanagi/qxmpp
void QXmppStanza::Error::toXml( QXmlStreamWriter *writer ) const
{
    QString cond = getConditionStr();
    QString type = getTypeStr();

    if(cond.isEmpty() && type.isEmpty())
        return;

    writer->writeStartElement("error");
    helperToXmlAddAttribute(writer, "type", type);

    if (m_code > 0)
        helperToXmlAddAttribute(writer, "code", QString::number(m_code));

    if(!cond.isEmpty())
    {
        writer->writeStartElement(cond);
        writer->writeAttribute("xmlns", ns_stanza);
        writer->writeEndElement();
    }
    if(!m_text.isEmpty())
    {
        writer->writeStartElement("text");
        writer->writeAttribute("xml:lang", "en");
        writer->writeAttribute("xmlns", ns_stanza);
        writer->writeCharacters(m_text);
        writer->writeEndElement();
    }

    writer->writeEndElement();
}
コード例 #5
0
ファイル: QXmppIq.cpp プロジェクト: Aseman-Land/qxmpp
void QXmppIq::toXml( QXmlStreamWriter *xmlWriter ) const
{
    xmlWriter->writeStartElement("iq");

    helperToXmlAddAttribute(xmlWriter, "id", id());
    helperToXmlAddAttribute(xmlWriter, "to", to());
    helperToXmlAddAttribute(xmlWriter, "from", from());
    helperToXmlAddAttribute(xmlWriter, "type", iq_types[d->type]);
    toXmlElementFromChild(xmlWriter);
    error().toXml(xmlWriter);
    xmlWriter->writeEndElement();
}
コード例 #6
0
void QXmppBookmarkSet::toXml(QXmlStreamWriter *writer) const
{
    writer->writeStartElement("storage");
    writer->writeAttribute("xmlns", ns_bookmarks);
    foreach (const QXmppBookmarkConference &conference, m_conferences)
    {
        writer->writeStartElement("conference");
        if (conference.autoJoin())
            helperToXmlAddAttribute(writer, "autojoin", "true");
        helperToXmlAddAttribute(writer, "jid", conference.jid());
        helperToXmlAddAttribute(writer, "name", conference.name());
        if (!conference.nickName().isEmpty())
            helperToXmlAddTextElement(writer, "nick", conference.nickName());
        writer->writeEndElement();
    }
コード例 #7
0
ファイル: QXmppPresence.cpp プロジェクト: Ilyatk/qxmpp
void QXmppPresence::toXml(QXmlStreamWriter *xmlWriter) const
{
    xmlWriter->writeStartElement("presence");
    helperToXmlAddAttribute(xmlWriter,"xml:lang", lang());
    helperToXmlAddAttribute(xmlWriter,"id", id());
    helperToXmlAddAttribute(xmlWriter,"to", to());
    helperToXmlAddAttribute(xmlWriter,"from", from());
    helperToXmlAddAttribute(xmlWriter,"type", presence_types[d->type]);

    const QString show = presence_shows[d->availableStatusType];
    if (!show.isEmpty())
        helperToXmlAddTextElement(xmlWriter, "show", show);
    if (!d->statusText.isEmpty())
        helperToXmlAddTextElement(xmlWriter, "status", d->statusText);
    if (d->priority != 0)
        helperToXmlAddTextElement(xmlWriter, "priority", QString::number(d->priority));

    error().toXml(xmlWriter);

    // XEP-0045: Multi-User Chat
    if(d->mucSupported) {
        xmlWriter->writeStartElement("x");
        xmlWriter->writeAttribute("xmlns", ns_muc);
        if (!d->mucPassword.isEmpty())
            xmlWriter->writeTextElement("password", d->mucPassword);

        if (!d->mucHistoryConfigType.isEmpty()) {
            xmlWriter->writeStartElement("history");
            xmlWriter->writeAttribute(d->mucHistoryConfigType, d->mucHistoryConfigValue);
            xmlWriter->writeEndElement();
        }

        xmlWriter->writeEndElement();
    }

    if(!d->mucItem.isNull() || !d->mucStatusCodes.isEmpty())
    {
        xmlWriter->writeStartElement("x");
        xmlWriter->writeAttribute("xmlns", ns_muc_user);
        if (!d->mucItem.isNull())
            d->mucItem.toXml(xmlWriter);
        foreach (int code, d->mucStatusCodes) {
            xmlWriter->writeStartElement("status");
            xmlWriter->writeAttribute("code", QString::number(code));
            xmlWriter->writeEndElement();
        }
        xmlWriter->writeEndElement();
    }
コード例 #8
0
ファイル: QXmppVCard.cpp プロジェクト: chloerei/qxmpp
void QXmppVCard::toXmlElementFromChild(QXmlStreamWriter *writer) const
{
    writer->writeStartElement("vCard");
    helperToXmlAddAttribute(writer,"xmlns", ns_vcard);
    if (!m_fullName.isEmpty())
        helperToXmlAddTextElement(writer, "FN", m_fullName);
    if(!m_nickName.isEmpty())
        helperToXmlAddTextElement(writer, "NICKNAME", m_nickName);
    if (!m_firstName.isEmpty() ||
        !m_lastName.isEmpty() ||
        !m_middleName.isEmpty())
    {
        writer->writeStartElement("N");
        if (!m_firstName.isEmpty())
            helperToXmlAddTextElement(writer, "GIVEN", m_firstName);
        if (!m_lastName.isEmpty())
            helperToXmlAddTextElement(writer, "FAMILY", m_lastName);
        if (!m_middleName.isEmpty())
            helperToXmlAddTextElement(writer, "MIDDLE", m_middleName);
        writer->writeEndElement();
    }
    if (!m_url.isEmpty())
        helperToXmlAddTextElement(writer, "URL", m_url);

    if(!photo().isEmpty())
    {
        writer->writeStartElement("PHOTO");
        helperToXmlAddTextElement(writer, "TYPE", getImageType(photo()));
        helperToXmlAddTextElement(writer, "BINVAL", photo().toBase64());
        writer->writeEndElement();
    }

    writer->writeEndElement();
}
コード例 #9
0
ファイル: QXmppPresence.cpp プロジェクト: mecalwang/imXmpp
void QXmppPresence::toXml(QXmlStreamWriter *xmlWriter) const
{
    xmlWriter->writeStartElement("presence");
    helperToXmlAddAttribute(xmlWriter,"xml:lang", lang());
    helperToXmlAddAttribute(xmlWriter,"id", id());
    helperToXmlAddAttribute(xmlWriter,"to", to());
    helperToXmlAddAttribute(xmlWriter,"from", from());
    helperToXmlAddAttribute(xmlWriter,"type", getTypeStr());
    m_status.toXml(xmlWriter);

    error().toXml(xmlWriter);
    foreach (const QXmppElement &extension, extensions())
        extension.toXml(xmlWriter);
    
    xmlWriter->writeEndElement();
}
コード例 #10
0
void PrivateStorageIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
{
    writer->writeStartElement("query");
    helperToXmlAddAttribute(writer, "xmlns", ns_private_storage);
    m_payload.toXml(writer);
    writer->writeEndElement();
}
コード例 #11
0
void QXmppRosterIq::Item::toXml(QXmlStreamWriter *writer) const
{
    writer->writeStartElement("item");
    helperToXmlAddAttribute(writer,"jid", m_bareJid);
    helperToXmlAddAttribute(writer,"name", m_name);
    helperToXmlAddAttribute(writer,"subscription", getSubscriptionTypeStr());
    helperToXmlAddAttribute(writer, "ask", subscriptionStatus());

    QSet<QString>::const_iterator i = m_groups.constBegin();
    while(i != m_groups.constEnd())
    {
        helperToXmlAddTextElement(writer,"group", *i);
        ++i;
    }
    writer->writeEndElement();
}
コード例 #12
0
ファイル: QXmppDialback.cpp プロジェクト: glwu/WinT-Messenger
void QXmppDialback::toXml (QXmlStreamWriter *xmlWriter) const
{
    if (m_command == Result)
        xmlWriter->writeStartElement ("db:result");

    else
        xmlWriter->writeStartElement ("db:verify");

    helperToXmlAddAttribute (xmlWriter, "id", id());
    helperToXmlAddAttribute (xmlWriter, "to", to());
    helperToXmlAddAttribute (xmlWriter, "from", from());
    helperToXmlAddAttribute (xmlWriter, "type", m_type);

    if (!m_key.isEmpty())
        xmlWriter->writeCharacters (m_key);

    xmlWriter->writeEndElement();
}
コード例 #13
0
ファイル: QXmppSession.cpp プロジェクト: RJ/conjist
QByteArray QXmppSession::toXmlElementFromChild() const
{
    QString data;
    QTextStream stream(&data);

    stream << "<session";
    helperToXmlAddAttribute(stream, "xmlns", ns_session);
    stream << "/>";

    return data.toAscii();
}
コード例 #14
0
void QXmppJingleIq::Content::toXml(QXmlStreamWriter *writer) const
{
    if (m_creator.isEmpty() || m_name.isEmpty())
        return;

    writer->writeStartElement("content");
    helperToXmlAddAttribute(writer, "creator", m_creator);
    helperToXmlAddAttribute(writer, "disposition", m_disposition);
    helperToXmlAddAttribute(writer, "name", m_name);
    helperToXmlAddAttribute(writer, "senders", m_senders);

    // description
    if (!m_descriptionType.isEmpty() || !m_payloadTypes.isEmpty())
    {
        writer->writeStartElement("description");
        writer->writeAttribute("xmlns", m_descriptionType);
        helperToXmlAddAttribute(writer, "media", m_descriptionMedia);
        foreach (const QXmppJinglePayloadType &payload, m_payloadTypes)
            payload.toXml(writer);
        writer->writeEndElement();
    }
コード例 #15
0
ファイル: QXmppRosterIq.cpp プロジェクト: RJ/conjist
QString QXmppRosterIq::Item::toXml() const
{
    QString data;
    QTextStream stream(&data);

    stream << "<item";
    helperToXmlAddAttribute(stream, "jid", m_bareJid);
    helperToXmlAddAttribute(stream, "name", m_name);
    helperToXmlAddAttribute(stream, "subscription", getSubscriptionTypeStr());
    helperToXmlAddAttribute(stream, "ask", getSubscriptionStatus());
    stream << ">";

    QSet<QString>::const_iterator i = m_groups.constBegin();
    while(i != m_groups.constEnd())
    {
        helperToXmlAddElement(stream, "group", *i);
        ++i;
    }
    stream << "</item>";
    return data.toAscii();
}
コード例 #16
0
ファイル: QXmppJingleIq.cpp プロジェクト: Aseman-Land/qxmpp
void QXmppJingleIq::Content::toXml(QXmlStreamWriter *writer) const
{
    if (d->creator.isEmpty() || d->name.isEmpty())
        return;

    writer->writeStartElement("content");
    helperToXmlAddAttribute(writer, "creator", d->creator);
    helperToXmlAddAttribute(writer, "disposition", d->disposition);
    helperToXmlAddAttribute(writer, "name", d->name);
    helperToXmlAddAttribute(writer, "senders", d->senders);

    // description
    if (!d->descriptionType.isEmpty() || !d->payloadTypes.isEmpty())
    {
        writer->writeStartElement("description");
        writer->writeAttribute("xmlns", d->descriptionType);
        helperToXmlAddAttribute(writer, "media", d->descriptionMedia);
        if (d->descriptionSsrc)
            writer->writeAttribute("ssrc", QString::number(d->descriptionSsrc));
        foreach (const QXmppJinglePayloadType &payload, d->payloadTypes)
            payload.toXml(writer);
        writer->writeEndElement();
    }
コード例 #17
0
ファイル: QXmppRosterIq.cpp プロジェクト: RJ/conjist
QByteArray QXmppRosterIq::toXmlElementFromChild() const
{
    QString data;
    QTextStream stream(&data);

    stream << "<query";
    helperToXmlAddAttribute(stream, "xmlns", ns_roster);
    stream << ">";
    for(int i = 0; i < m_items.count(); ++i)
        stream << m_items.at(i).toXml();
    stream << "</query>";

    return data.toAscii();
}
コード例 #18
0
ファイル: QXmppSimpleArchiveIq.cpp プロジェクト: Ilyatk/qxmpp
void QXmppSimpleArchiveQueryIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
{
    writer->writeStartElement("query");
    writer->writeAttribute("xmlns", ns_simple_archive);
    if (!m_queryId.isEmpty())
        helperToXmlAddAttribute(writer, "queryid", m_queryId);
    if (!m_with.isEmpty())
        helperToXmlAddTextElement(writer, "with", m_with);
    if (m_start.isValid())
        helperToXmlAddTextElement(writer, "start", QXmppUtils::datetimeToString(m_start));
    if (m_end.isValid())
        helperToXmlAddTextElement(writer, "end", QXmppUtils::datetimeToString(m_end));
    if (!m_rsmQuery.isNull())
        m_rsmQuery.toXml(writer);
    else if (!m_rsmReply.isNull())
        m_rsmReply.toXml(writer);
    writer->writeEndElement();
}
コード例 #19
0
void QXmppByteStreamIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
{
    writer->writeStartElement("query");
    writer->writeAttribute("xmlns", ns_bytestreams);
    helperToXmlAddAttribute(writer, "sid", m_sid);
    QString modeStr;
    if (m_mode == Tcp)
        modeStr = "tcp";
    else if (m_mode == Udp)
        modeStr = "udp";
    helperToXmlAddAttribute(writer, "mode", modeStr);
    foreach (const StreamHost& streamHost, m_streamHosts)
    {
        writer->writeStartElement("streamhost");
        helperToXmlAddAttribute(writer, "host", streamHost.host());
        helperToXmlAddAttribute(writer, "jid", streamHost.jid());
        helperToXmlAddAttribute(writer, "port", QString::number(streamHost.port()));
        helperToXmlAddAttribute(writer, "zeroconf", streamHost.zeroconf());
        writer->writeEndElement();
    }
コード例 #20
0
ファイル: QXmppArchiveIq.cpp プロジェクト: Aseman-Land/qxmpp
void QXmppArchiveChat::toXml(QXmlStreamWriter *writer, const QXmppResultSetReply &rsm) const
{
    writer->writeStartElement("chat");
    writer->writeAttribute("xmlns", ns_archive);
    helperToXmlAddAttribute(writer, "with", m_with);
    if (m_start.isValid())
        helperToXmlAddAttribute(writer, "start", QXmppUtils::datetimeToString(m_start));
    helperToXmlAddAttribute(writer, "subject", m_subject);
    helperToXmlAddAttribute(writer, "thread", m_thread);
    if (m_version)
        helperToXmlAddAttribute(writer, "version", QString::number(m_version));

    QDateTime prevTime = m_start;

    foreach (const QXmppArchiveMessage &message, m_messages)
    {
        writer->writeStartElement(message.isReceived() ? "from" : "to");
        helperToXmlAddAttribute(writer, "secs", QString::number(prevTime.secsTo(message.date())));
        writer->writeTextElement("body", message.body());
        writer->writeEndElement();
        prevTime = message.date();
    }
コード例 #21
0
void QXmppMessage::toXml(QXmlStreamWriter *xmlWriter) const
{
    xmlWriter->writeStartElement("message");
    helperToXmlAddAttribute(xmlWriter, "xml:lang", lang());
    helperToXmlAddAttribute(xmlWriter, "id", id());
    helperToXmlAddAttribute(xmlWriter, "to", to());
    helperToXmlAddAttribute(xmlWriter, "from", from());
    helperToXmlAddAttribute(xmlWriter, "type", message_types[d->type]);
    if (!d->subject.isEmpty())
        helperToXmlAddTextElement(xmlWriter, "subject", d->subject);
    if (!d->body.isEmpty())
        helperToXmlAddTextElement(xmlWriter, "body", d->body);
    if (!d->thread.isEmpty())
        helperToXmlAddTextElement(xmlWriter, "thread", d->thread);
    error().toXml(xmlWriter);

    // chat states
    if (d->state > None && d->state <= Paused)
    {
        xmlWriter->writeStartElement(chat_states[d->state]);
        xmlWriter->writeAttribute("xmlns", ns_chat_states);
        xmlWriter->writeEndElement();
    }

    // XEP-0071: XHTML-IM
    if (!d->xhtml.isEmpty()) {
        xmlWriter->writeStartElement("html");
        xmlWriter->writeAttribute("xmlns", ns_xhtml_im);
        xmlWriter->writeStartElement("body");
        xmlWriter->writeAttribute("xmlns", ns_xhtml);
        xmlWriter->writeCharacters("");
        xmlWriter->device()->write(d->xhtml.toUtf8());
        xmlWriter->writeEndElement();
        xmlWriter->writeEndElement();
    }

    // time stamp
    if (d->stamp.isValid())
    {
        QDateTime utcStamp = d->stamp.toUTC();
        if (d->stampType == DelayedDelivery)
        {
            // XEP-0203: Delayed Delivery
            xmlWriter->writeStartElement("delay");
            xmlWriter->writeAttribute("xmlns", ns_delayed_delivery);
            helperToXmlAddAttribute(xmlWriter, "stamp", QXmppUtils::datetimeToString(utcStamp));
            xmlWriter->writeEndElement();
        } else {
            // XEP-0091: Legacy Delayed Delivery
            xmlWriter->writeStartElement("x");
            xmlWriter->writeAttribute("xmlns", ns_legacy_delayed_delivery);
            helperToXmlAddAttribute(xmlWriter, "stamp", utcStamp.toString("yyyyMMddThh:mm:ss"));
            xmlWriter->writeEndElement();
        }
    }

    // XEP-0184: Message Delivery Receipts
    if (!d->receiptId.isEmpty()) {
        xmlWriter->writeStartElement("received");
        xmlWriter->writeAttribute("xmlns", ns_message_receipts);
        xmlWriter->writeAttribute("id", d->receiptId);
        xmlWriter->writeEndElement();
    }
    if (d->receiptRequested) {
        xmlWriter->writeStartElement("request");
        xmlWriter->writeAttribute("xmlns", ns_message_receipts);
        xmlWriter->writeEndElement();
    }

    // XEP-0224: Attention
    if (d->attentionRequested) {
        xmlWriter->writeStartElement("attention");
        xmlWriter->writeAttribute("xmlns", ns_attention);
        xmlWriter->writeEndElement();
    }

    // XEP-0249: Direct MUC Invitations
    if (!d->mucInvitationJid.isEmpty()) {
        xmlWriter->writeStartElement("x");
        xmlWriter->writeAttribute("xmlns", ns_conference);
        xmlWriter->writeAttribute("jid", d->mucInvitationJid);
        if (!d->mucInvitationPassword.isEmpty())
            xmlWriter->writeAttribute("password", d->mucInvitationPassword);
        if (!d->mucInvitationReason.isEmpty())
            xmlWriter->writeAttribute("reason", d->mucInvitationReason);
        xmlWriter->writeEndElement();
    }

    // XEP-0334: Message Processing Hints
    Q_FOREACH(const Hint hint, d->hints)
    {
        xmlWriter->writeStartElement(hint_types[hint]);
        xmlWriter->writeAttribute("xmlns", ns_message_processing_hints);
        xmlWriter->writeEndElement();
    }

    // XEP-0333: Chat Markers
    if (d->markable) {
        xmlWriter->writeStartElement("markable");
        xmlWriter->writeAttribute("xmlns", ns_chat_markers);
        xmlWriter->writeEndElement();
    }
    if (d->marker != NoMarker) {
        xmlWriter->writeStartElement(marker_types[d->marker]);
        xmlWriter->writeAttribute("xmlns", ns_chat_markers);
        xmlWriter->writeAttribute("id", d->markedId);
        if (!d->markedThread.isNull() && !d->markedThread.isEmpty()) {
            xmlWriter->writeAttribute("thread", d->markedThread);
        }
        xmlWriter->writeEndElement();
    }

    // XEP-0308: Last Message Correction
    if(d->replace) {
        xmlWriter->writeStartElement("replace");
        xmlWriter->writeAttribute("id",d->replaceId);
        xmlWriter->writeAttribute("xmlns",ns_replace_message);
        xmlWriter->writeEndElement();
    }

    // other extensions
    QXmppStanza::extensionsToXml(xmlWriter);

    xmlWriter->writeEndElement();
}
コード例 #22
0
ファイル: QXmppMessage.cpp プロジェクト: qxmpp-project/qxmpp
void QXmppMessage::toXml(QXmlStreamWriter *xmlWriter) const
{
    xmlWriter->writeStartElement("message");
    helperToXmlAddAttribute(xmlWriter, "xml:lang", lang());
    helperToXmlAddAttribute(xmlWriter, "id", id());
    helperToXmlAddAttribute(xmlWriter, "to", to());
    helperToXmlAddAttribute(xmlWriter, "from", from());
    helperToXmlAddAttribute(xmlWriter, "type", message_types[d->type]);
    if (!d->subject.isEmpty())
        helperToXmlAddTextElement(xmlWriter, "subject", d->subject);
    if (!d->body.isEmpty())
        helperToXmlAddTextElement(xmlWriter, "body", d->body);
    if (!d->thread.isEmpty())
        helperToXmlAddTextElement(xmlWriter, "thread", d->thread);
    error().toXml(xmlWriter);

    // chat states
    if (d->state > None && d->state <= Paused)
    {
        xmlWriter->writeStartElement(chat_states[d->state]);
        xmlWriter->writeAttribute("xmlns", ns_chat_states);
        xmlWriter->writeEndElement();
    }

    // XEP-0071: XHTML-IM
    if (!d->xhtml.isEmpty()) {
        xmlWriter->writeStartElement("html");
        xmlWriter->writeAttribute("xmlns", ns_xhtml_im);
        xmlWriter->writeStartElement("body");
        xmlWriter->writeAttribute("xmlns", ns_xhtml);
        xmlWriter->writeCharacters("");
        xmlWriter->device()->write(d->xhtml.toUtf8());
        xmlWriter->writeEndElement();
        xmlWriter->writeEndElement();
    }

    // time stamp
    if (d->stamp.isValid())
    {
        QDateTime utcStamp = d->stamp.toUTC();
        if (d->stampType == DelayedDelivery)
        {
            // XEP-0203: Delayed Delivery
            xmlWriter->writeStartElement("delay");
            xmlWriter->writeAttribute("xmlns", ns_delayed_delivery);
            helperToXmlAddAttribute(xmlWriter, "stamp", QXmppUtils::datetimeToString(utcStamp));
            xmlWriter->writeEndElement();
        } else {
            // XEP-0091: Legacy Delayed Delivery
            xmlWriter->writeStartElement("x");
            xmlWriter->writeAttribute("xmlns", ns_legacy_delayed_delivery);
            helperToXmlAddAttribute(xmlWriter, "stamp", utcStamp.toString("yyyyMMddThh:mm:ss"));
            xmlWriter->writeEndElement();
        }
    }

    // XEP-0184: Message Delivery Receipts
    if (!d->receiptId.isEmpty()) {
        xmlWriter->writeStartElement("received");
        xmlWriter->writeAttribute("xmlns", ns_message_receipts);
        xmlWriter->writeAttribute("id", d->receiptId);
        xmlWriter->writeEndElement();
    }
    if (d->receiptRequested) {
        xmlWriter->writeStartElement("request");
        xmlWriter->writeAttribute("xmlns", ns_message_receipts);
        xmlWriter->writeEndElement();
    }

    // XEP-0224: Attention
    if (d->attentionRequested) {
        xmlWriter->writeStartElement("attention");
        xmlWriter->writeAttribute("xmlns", ns_attention);
        xmlWriter->writeEndElement();
    }

    // XEP-0249: Direct MUC Invitations
    if (!d->mucInvitationJid.isEmpty()) {
        xmlWriter->writeStartElement("x");
        xmlWriter->writeAttribute("xmlns", ns_conference);
        xmlWriter->writeAttribute("jid", d->mucInvitationJid);
        if (!d->mucInvitationPassword.isEmpty())
            xmlWriter->writeAttribute("password", d->mucInvitationPassword);
        if (!d->mucInvitationReason.isEmpty())
            xmlWriter->writeAttribute("reason", d->mucInvitationReason);
        xmlWriter->writeEndElement();
    }

    // XEP-0333: Chat Markers
    if (d->markable) {
        xmlWriter->writeStartElement("markable");
        xmlWriter->writeAttribute("xmlns", ns_chat_markers);
        xmlWriter->writeEndElement();
    }
    if (d->marker != NoMarker) {
        xmlWriter->writeStartElement(marker_types[d->marker]);
        xmlWriter->writeAttribute("xmlns", ns_chat_markers);
        xmlWriter->writeAttribute("id", d->markedId);
        if (!d->markedThread.isNull() && !d->markedThread.isEmpty()) {
            xmlWriter->writeAttribute("thread", d->markedThread);
        }
        xmlWriter->writeEndElement();
    }

    // XEP-0280: Message Carbons
    if (d->privatemsg) {
        xmlWriter->writeStartElement("private");
        xmlWriter->writeAttribute("xmlns", ns_carbons);
        xmlWriter->writeEndElement();
    }

    // XEP-0066: Out of Band Data
    if (!d->outOfBandUrl.isEmpty()) {
        xmlWriter->writeStartElement("x");
        xmlWriter->writeAttribute("xmlns", ns_oob);
        xmlWriter->writeTextElement("url", d->outOfBandUrl);
        xmlWriter->writeEndElement();
    }

    // XEP-0308: Last Message Correction
    if (!d->replaceId.isEmpty()) {
        xmlWriter->writeStartElement("replace");
        xmlWriter->writeAttribute("xmlns", ns_message_correct);
        xmlWriter->writeAttribute("id", d->replaceId);
        xmlWriter->writeEndElement();
    }

    // XEP-0369: Mediated Information eXchange (MIX)
    if (!d->mixUserJid.isEmpty() || !d->mixUserNick.isEmpty()) {
        xmlWriter->writeStartElement("mix");
        xmlWriter->writeAttribute("xmlns", ns_mix);
        helperToXmlAddTextElement(xmlWriter, "jid", d->mixUserJid);
        helperToXmlAddTextElement(xmlWriter, "nick", d->mixUserNick);
        xmlWriter->writeEndElement();
    }

    // XEP-0382: Spoiler messages
    if (d->isSpoiler) {
        xmlWriter->writeStartElement("spoiler");
        xmlWriter->writeAttribute("xmlns", ns_spoiler);
        xmlWriter->writeCharacters(d->spoilerHint);
        xmlWriter->writeEndElement();
    }

    // other extensions
    QXmppStanza::extensionsToXml(xmlWriter);

    xmlWriter->writeEndElement();
}
コード例 #23
0
ファイル: QXmppPingIq.cpp プロジェクト: chloerei/qxmpp
void QXmppPingIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
{
    writer->writeStartElement("ping");
    helperToXmlAddAttribute(writer, "xmlns", ns_ping);
    writer->writeEndElement();
}