BuildmLearn Toolkit  2.0.4
BuildmLearn Toolkit is an easy-to-use program that helps users make mobile apps without any knowledge of application development.
 All Classes Functions Enumerations Groups Pages
SystemFactory Class Reference

Some miscellaneous methods. More...

#include <systemfactory.h>

Collaboration diagram for SystemFactory:
Collaboration graph

Static Public Member Functions

static UpdateInfo parseUpdatesFile (const QByteArray &updates_file)
 Performs parsing of downloaded file with list of updates. More...
 
static QPair< UpdateInfo,
QNetworkReply::NetworkError > 
checkForUpdates ()
 Tries to synchronously download list with new updates. More...
 

Detailed Description

Some miscellaneous methods.

Definition at line 72 of file systemfactory.h.

Member Function Documentation

QPair< UpdateInfo, QNetworkReply::NetworkError > SystemFactory::checkForUpdates ( )
static

Tries to synchronously download list with new updates.

Returns
Returns information about new updates + network download status.

Definition at line 54 of file systemfactory.cpp.

54  {
55  QPair<UpdateInfo, QNetworkReply::NetworkError> result;
56  QByteArray releases_xml;
57 
58  result.second = NetworkFactory::downloadFile(RELEASES_LIST,
59  5000,
60  releases_xml);
61 
62  if (result.second == QNetworkReply::NoError) {
63  result.first = parseUpdatesFile(releases_xml);
64  }
65 
66  return result;
67 }
static UpdateInfo parseUpdatesFile(const QByteArray &updates_file)
Performs parsing of downloaded file with list of updates.
static QNetworkReply::NetworkError downloadFile(const QString &url, int timeout, QByteArray &output, bool protected_contents=false, const QString &username=QString(), const QString &password=QString())
Performs SYNCHRONOUS download of file with given URL and given timeout.

Here is the call graph for this function:

Here is the caller graph for this function:

UpdateInfo SystemFactory::parseUpdatesFile ( const QByteArray &  updates_file)
static

Performs parsing of downloaded file with list of updates.

Parameters
updates_fileFile to parse.
Returns
Returns parsed update information.

Definition at line 69 of file systemfactory.cpp.

69  {
70  UpdateInfo update;
71  QDomDocument document; document.setContent(updates_file, false);
72  QDomNodeList releases = document.elementsByTagName("release");
73 
74  if (releases.size() == 1) {
75  QDomElement rel_elem = releases.at(0).toElement();
76  QString type = rel_elem.attributes().namedItem("type").toAttr().value();
77 
78  update.m_availableVersion = rel_elem.attributes().namedItem("version").toAttr().value();
79  update.m_changes = rel_elem.namedItem("changes").toElement().text();
80 
81  QDomNodeList urls = rel_elem.elementsByTagName("url");
82 
83  for (int j = 0; j < urls.size(); j++) {
84  UpdateUrl url;
85  QDomElement url_elem = urls.at(j).toElement();
86 
87  url.m_fileUrl = url_elem.text();
88  url.m_os = url_elem.attributes().namedItem("os").toAttr().value();
89  url.m_platform = url_elem.attributes().namedItem("platform").toAttr().value();
90 
91  update.m_urls.insert(url.m_os,
92  url);
93  }
94 
95  if (type == "maintenance") {
96  update.m_type = UpdateInfo::Maintenance;
97  }
98  else {
99  update.m_type = UpdateInfo::Evolution;
100  }
101  }
102  else {
103  update.m_availableVersion = QString();
104  }
105 
106 
107  return update;
108 }
Information about available update.
Definition: systemfactory.h:49
Information about update metadata.
Definition: systemfactory.h:41

Here is the caller graph for this function:


The documentation for this class was generated from the following files: