-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ruslan Nigmatullin
committed
Apr 12, 2012
1 parent
bf74cda
commit d84592c
Showing
6 changed files
with
493 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/**************************************************************************** | ||
** | ||
** Jreen | ||
** | ||
** Copyright © 2012 Ruslan Nigmatullin <euroelessar@yandex.ru> | ||
** | ||
***************************************************************************** | ||
** | ||
** $JREEN_BEGIN_LICENSE$ | ||
** This program is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 2 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** This program is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
** See the GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with this program. If not, see http://www.gnu.org/licenses/. | ||
** $JREEN_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#include "metacontacts_p.h" | ||
|
||
namespace Jreen { | ||
|
||
} // namespace Jreen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/**************************************************************************** | ||
** | ||
** Jreen | ||
** | ||
** Copyright © 2012 Ruslan Nigmatullin <euroelessar@yandex.ru> | ||
** | ||
***************************************************************************** | ||
** | ||
** $JREEN_BEGIN_LICENSE$ | ||
** This program is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 2 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** This program is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
** See the GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with this program. If not, see http://www.gnu.org/licenses/. | ||
** $JREEN_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef JREEN_METACONTACTS_P_H | ||
#define JREEN_METACONTACTS_P_H | ||
|
||
#include "metacontactstorage.h" | ||
|
||
namespace Jreen | ||
{ | ||
|
||
class JREEN_AUTOTEST_EXPORT MetaContacts : public Payload | ||
{ | ||
J_PAYLOAD(Jreen::MetaContacts) | ||
public: | ||
MetaContacts(MetaContactStorage::ItemList items) : items(items) {} | ||
MetaContacts() {} | ||
|
||
MetaContactStorage::ItemList items; | ||
}; | ||
|
||
} // namespace Jreen | ||
|
||
#endif // JREEN_METACONTACTS_P_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/**************************************************************************** | ||
** | ||
** Jreen | ||
** | ||
** Copyright © 2012 Ruslan Nigmatullin <euroelessar@yandex.ru> | ||
** | ||
***************************************************************************** | ||
** | ||
** $JREEN_BEGIN_LICENSE$ | ||
** This program is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 2 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** This program is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
** See the GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with this program. If not, see http://www.gnu.org/licenses/. | ||
** $JREEN_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#include "metacontactsfactory_p.h" | ||
#include <QStringList> | ||
#define NS_METACONTACTS QLatin1String("storage:metacontacts") | ||
|
||
namespace Jreen { | ||
|
||
MetaContactsFactory::MetaContactsFactory() | ||
{ | ||
m_depth = 0; | ||
} | ||
|
||
MetaContactsFactory::~MetaContactsFactory() | ||
{ | ||
} | ||
|
||
QStringList MetaContactsFactory::features() const | ||
{ | ||
return QStringList(NS_METACONTACTS); | ||
} | ||
|
||
bool MetaContactsFactory::canParse(const QStringRef &name, const QStringRef &uri, | ||
const QXmlStreamAttributes &attributes) | ||
{ | ||
Q_UNUSED(attributes); | ||
return name == QLatin1String("storage") && uri == NS_METACONTACTS; | ||
} | ||
|
||
void MetaContactsFactory::handleStartElement(const QStringRef &name, const QStringRef &uri, | ||
const QXmlStreamAttributes &attributes) | ||
{ | ||
Q_UNUSED(uri); | ||
m_depth++; | ||
if(m_depth == 1) { | ||
m_metacontacts.reset(new MetaContacts); | ||
} else if (m_depth == 2 && name == QLatin1String("meta")) { | ||
Jreen::MetaContactStorage::Item item; | ||
item.setJID(attributes.value(QLatin1String("jid")).toString()); | ||
item.setTag(attributes.value(QLatin1String("tag")).toString()); | ||
QString orderStr = attributes.value(QLatin1String("order")).toString(); | ||
bool ok = true; | ||
uint order = orderStr.toUInt(&ok); | ||
if (ok) | ||
item.setOrder(order); | ||
m_metacontacts->items << item; | ||
} | ||
} | ||
|
||
void MetaContactsFactory::handleEndElement(const QStringRef &name, const QStringRef &uri) | ||
{ | ||
Q_UNUSED(name); | ||
Q_UNUSED(uri); | ||
m_depth--; | ||
} | ||
|
||
void MetaContactsFactory::handleCharacterData(const QStringRef &text) | ||
{ | ||
Q_UNUSED(text); | ||
} | ||
|
||
void MetaContactsFactory::serialize(Payload *extension, QXmlStreamWriter *writer) | ||
{ | ||
MetaContacts *metacontacts = se_cast<MetaContacts*>(extension); | ||
writer->writeStartElement(QLatin1String("storage")); | ||
writer->writeDefaultNamespace(NS_METACONTACTS); | ||
foreach (const MetaContactStorage::Item &item, metacontacts->items) { | ||
writer->writeStartElement(QLatin1String("meta")); | ||
writer->writeAttribute(QLatin1String("jid"), item.jid().full()); | ||
writer->writeAttribute(QLatin1String("tag"), item.tag()); | ||
if (item.hasOrder()) | ||
writer->writeAttribute(QLatin1String("order"), QString::number(item.order())); | ||
writer->writeEndElement(); | ||
} | ||
writer->writeEndElement(); | ||
} | ||
|
||
Payload::Ptr MetaContactsFactory::createPayload() | ||
{ | ||
return Payload::Ptr(m_metacontacts.take()); | ||
} | ||
|
||
} // namespace Jreen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/**************************************************************************** | ||
** | ||
** Jreen | ||
** | ||
** Copyright © 2012 Ruslan Nigmatullin <euroelessar@yandex.ru> | ||
** | ||
***************************************************************************** | ||
** | ||
** $JREEN_BEGIN_LICENSE$ | ||
** This program is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 2 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** This program is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
** See the GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with this program. If not, see http://www.gnu.org/licenses/. | ||
** $JREEN_END_LICENSE$ | ||
** | ||
****************************************************************************/ | ||
|
||
#ifndef JREEN_METACONTACTSFACTORY_P_H | ||
#define JREEN_METACONTACTSFACTORY_P_H | ||
|
||
#include "metacontacts_p.h" | ||
|
||
namespace Jreen { | ||
|
||
class JREEN_AUTOTEST_EXPORT MetaContactsFactory : public PayloadFactory<MetaContacts> | ||
{ | ||
public: | ||
MetaContactsFactory(); | ||
~MetaContactsFactory(); | ||
QStringList features() const; | ||
bool canParse(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes); | ||
void handleStartElement(const QStringRef &name, const QStringRef &uri, const QXmlStreamAttributes &attributes); | ||
void handleEndElement(const QStringRef &name, const QStringRef &uri); | ||
void handleCharacterData(const QStringRef &text); | ||
void serialize(Payload *extension, QXmlStreamWriter *writer); | ||
Payload::Ptr createPayload(); | ||
private: | ||
int m_depth; | ||
QScopedPointer<MetaContacts> m_metacontacts; | ||
}; | ||
|
||
} // namespace Jreen | ||
|
||
#endif // JREEN_METACONTACTSFACTORY_P_H |
Oops, something went wrong.