return false;
xml.readNextStartElement(); // end currentTime element
- xml.readNextStartElement(); // start result element
+ bool inResult = xml.readNextStartElement(); // start result element
if (xml.name() != "result") {
qDebug() << "Wrong element:" << xml.name();
return false;
}
- qDebug() << "passed, element is result";
- bool inResult = true;
+
while (inResult) {
- inResult = xml.readNextStartElement();
qDebug() << "element:" << xml.name();
if (xml.name() == "trainingEndTime") {
qDebug() << "Parse end time";
currentTime = QDateTime::fromString(xml.readElementText(),"yyyy-MM-dd hh:mm:ss");
startTime.setTimeSpec(Qt::UTC);
qDebug() << "Current: " << currentTime;
- } else
+ } if (xml.name() == "cachedUntil" ) {
+ cachedUntil = QDateTime::fromString(xml.readElementText(),"yyyy-MM-dd hh:mm:ss");
+ cachedUntil.setTimeSpec(Qt::UTC);
+ qDebug() << "Cached until " << cachedUntil.toString(Qt::SystemLocaleShortDate);
+ } else {
// Noop
+ qDebug() << " Skip this";
xml.skipCurrentElement();
+ }
+ inResult = xml.readNextStartElement();
} // while
- bool cached = xml.readNextStartElement(); // cachedUntil
- if (cached) {
- QDateTime cachedTime = QDateTime::fromString(xml.readElementText(),"yyyy-MM-dd hh:mm:ss");
- cachedTime.setTimeSpec(Qt::UTC);
- }
+
qDebug() << "Parsing finished";
return true;
}
{
if (m_character == NULL || m_account == NULL)
return;
+ if (cachedUntil.isValid()) {
+ if (cachedUntil > QDateTime::currentDateTime().toUTC() ) {
+ qDebug() << "Cached until " << cachedUntil.toString(Qt::SystemLocaleShortDate);
+ return;
+ }
+ }
QNetworkRequest req(QUrl(QString("http://api.eveonline.com/char/SkillInTraining.xml.aspx?apiKey=%1&userID=%2&characterID=%3")
.arg(m_account->apiKey())
.arg(m_account->userId())