zlibcompressionfeature.cpp | zlibcompressionfeature.cpp | |||
---|---|---|---|---|
skipping to change at line 30 | skipping to change at line 30 | |||
** You should have received a copy of the GNU General Public License | ** You should have received a copy of the GNU General Public License | |||
** along with this program. If not, see http://www.gnu.org/licenses/. | ** along with this program. If not, see http://www.gnu.org/licenses/. | |||
** $JREEN_END_LICENSE$ | ** $JREEN_END_LICENSE$ | |||
** | ** | |||
*************************************************************************** */ | *************************************************************************** */ | |||
#include "zlibcompressionfeature_p.h" | #include "zlibcompressionfeature_p.h" | |||
#include "zlibdatastream_p.h" | #include "zlibdatastream_p.h" | |||
#include <QXmlStreamWriter> | #include <QXmlStreamWriter> | |||
#define NS_COMPRESS_FEATURE QLatin1String("http://jabber.org/features/compr | ||||
ess") | ||||
#define NS_COMPRESS_PROTOCOL QLatin1String("http://jabber.org/protocol/comp | ||||
ress") | ||||
namespace Jreen | namespace Jreen | |||
{ | { | |||
ZLibCompressionFeature::ZLibCompressionFeature() : StreamFeature(Compressio nLayer) | ZLibCompressionFeature::ZLibCompressionFeature() : StreamFeature(Compressio nLayer) | |||
{ | { | |||
reset(); | reset(); | |||
} | } | |||
void ZLibCompressionFeature::reset() | void ZLibCompressionFeature::reset() | |||
{ | { | |||
m_state = AtStart; | m_state = AtStart; | |||
m_depth = 0; | m_depth = 0; | |||
m_methods.clear(); | m_methods.clear(); | |||
} | } | |||
bool ZLibCompressionFeature::canParse(const QStringRef &name, const QString Ref &uri, const QXmlStreamAttributes &attributes) | bool ZLibCompressionFeature::canParse(const QStringRef &name, const QString Ref &uri, const QXmlStreamAttributes &attributes) | |||
{ | { | |||
Q_UNUSED(name); | Q_UNUSED(name); | |||
Q_UNUSED(attributes); | Q_UNUSED(attributes); | |||
return uri == QLatin1String("http://jabber.org/features/compress") | | uri == QLatin1String("http://jabber.org/protocol/compress"); | return uri == NS_COMPRESS_FEATURE || uri == NS_COMPRESS_PROTOCOL; | |||
} | } | |||
void ZLibCompressionFeature::handleStartElement(const QStringRef &name, con st QStringRef &uri, const QXmlStreamAttributes &attributes) | void ZLibCompressionFeature::handleStartElement(const QStringRef &name, con st QStringRef &uri, const QXmlStreamAttributes &attributes) | |||
{ | { | |||
Q_UNUSED(uri); | Q_UNUSED(uri); | |||
Q_UNUSED(attributes); | Q_UNUSED(attributes); | |||
m_depth++; | m_depth++; | |||
if (m_depth == 1 && name == QLatin1String("compression")) { | if (m_depth == 1 && name == QLatin1String("compression")) { | |||
m_state = AtMethods; | m_state = AtMethods; | |||
} else if (m_depth == 2 && m_state == AtMethods && name == QLatin1St ring("method")) { | } else if (m_depth == 2 && m_state == AtMethods && name == QLatin1St ring("method")) { | |||
skipping to change at line 93 | skipping to change at line 96 | |||
bool ZLibCompressionFeature::isActivatable() | bool ZLibCompressionFeature::isActivatable() | |||
{ | { | |||
return m_methods.contains(QLatin1String("zlib")); | return m_methods.contains(QLatin1String("zlib")); | |||
} | } | |||
bool ZLibCompressionFeature::activate() | bool ZLibCompressionFeature::activate() | |||
{ | { | |||
QXmlStreamWriter *writer = m_info->writer(); | QXmlStreamWriter *writer = m_info->writer(); | |||
writer->writeStartElement(QLatin1String("compress")); | writer->writeStartElement(QLatin1String("compress")); | |||
writer->writeDefaultNamespace(QLatin1String("http://jabber.org/proto col/compress")); | writer->writeDefaultNamespace(NS_COMPRESS_PROTOCOL); | |||
writer->writeTextElement(QLatin1String("method"), QLatin1String("zli b")); | writer->writeTextElement(QLatin1String("method"), QLatin1String("zli b")); | |||
writer->writeEndElement(); | writer->writeEndElement(); | |||
return true; | return true; | |||
} | } | |||
} | } | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 7 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |