void DiscoInfoFactory::serialize(Payload *extension, QXmlStreamWriter *writer) { Disco::Info *info = se_cast<Disco::Info*>(extension); if (!info) return; writer->writeStartElement(QLatin1String("query")); if (!info->node().isEmpty()) writer->writeAttribute(QLatin1String("node"),info->node()); writer->writeDefaultNamespace(NS_DISCO_INFO); foreach (const Disco::Identity &identity, info->identities()) { writer->writeEmptyElement(QLatin1String("identity")); writer->writeAttribute(QLatin1String("category"), identity.category()); writer->writeAttribute(QLatin1String("type"), identity.type()); writer->writeAttribute(QLatin1String("name"), identity.name()); if (!identity.lang().isEmpty()) writer->writeAttribute(QLatin1String("xml:lang"), identity.lang()); } foreach (const QString &feature, info->features()) { writer->writeEmptyElement(QLatin1String("feature")); writer->writeAttribute(QLatin1String("var"), feature); } if (info->form()) m_factory.serialize(info->form().data(), writer); writer->writeEndElement(); }
void FlexibleOffline::handleDiscoInfo( const JID& /*from*/, const Disco::Info& info, int context ) { if( !m_flexibleOfflineHandler ) return; switch( context ) { case FOCheckSupport: m_flexibleOfflineHandler->handleFlexibleOfflineSupport( info.hasFeature( XMLNS_OFFLINE ) ); break; case FORequestNum: int num = -1; if( info.form() && info.form()->hasField( "number_of_messages" ) ) num = atoi( info.form()->field( "number_of_messages" )->value().c_str() ); m_flexibleOfflineHandler->handleFlexibleOfflineMsgNum( num ); break; } }