1/*
2 This file is part of KDE.
3
4 SPDX-FileCopyrightText: 2010 Sebastian K├╝gler <sebas@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7*/
8
9#include "remoteaccountparser.h"
10#include <qdebug.h>
11
12using namespace Attica;
13
14RemoteAccount RemoteAccount::Parser::parseXml(QXmlStreamReader &xml)
15{
16 RemoteAccount remoteaccount;
17
18 // For specs about the XML provided, see here:
19 // http://www.freedesktop.org/wiki/Specifications/open-collaboration-services-draft#RemoteAccounts
20 while (!xml.atEnd()) {
21 // qCDebug(ATTICA) << "XML returned:" << xml.text().toString();
22 xml.readNext();
23
24 if (xml.isStartElement()) {
25 if (xml.name() == QLatin1String("id")) {
26 remoteaccount.setId(xml.readElementText());
27 } else if (xml.name() == QLatin1String("type")) {
28 remoteaccount.setType(xml.readElementText());
29 } else if (xml.name() == QLatin1String("typeid")) { // FIXME: change to remoteserviceid sometime soon (OCS API change pending
30 remoteaccount.setRemoteServiceId(xml.readElementText());
31 } else if (xml.name() == QLatin1String("data")) {
32 remoteaccount.setData(xml.readElementText());
33 } else if (xml.name() == QLatin1String("login")) {
34 remoteaccount.setLogin(xml.readElementText());
35 } else if (xml.name() == QLatin1String("password")) {
36 remoteaccount.setPassword(xml.readElementText());
37 }
38 } else if (xml.isEndElement() && (xml.name() == QLatin1String("remoteaccount") || xml.name() == QLatin1String("user"))) {
39 break;
40 }
41 }
42 return remoteaccount;
43}
44
45QStringList RemoteAccount::Parser::xmlElement() const
46{
47 return QStringList(QStringLiteral("remoteaccount")) << QStringLiteral("user");
48}
49

source code of attica/src/remoteaccountparser.cpp