Attica

remoteaccountparser.cpp
1 /*
2  This file is part of KDE.
3 
4  SPDX-FileCopyrightText: 2010 Sebastian Kügler <[email protected]>
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 
12 using namespace Attica;
13 
14 RemoteAccount 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 
45 QStringList RemoteAccount::Parser::xmlElement() const
46 {
47  return QStringList(QStringLiteral("remoteaccount")) << QStringLiteral("user");
48 }
bool isEndElement() const const
QStringRef name() const const
QXmlStreamReader::TokenType readNext()
QString readElementText(QXmlStreamReader::ReadElementTextBehaviour behaviour)
The Attica namespace,.
bool isStartElement() const const
bool atEnd() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 3 2023 04:08:16 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.