From d334906cdb5ad988c9e3ad1e9827eab774d1a283 Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 21 Jun 2015 20:49:42 +0200 Subject: use pen time, not host wall clock to store lastsync timestamp --- smartpen.cc | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'smartpen.cc') diff --git a/smartpen.cc b/smartpen.cc index c89cf2d..79e9a01 100644 --- a/smartpen.cc +++ b/smartpen.cc @@ -157,12 +157,14 @@ QVariantMap Smartpen::getPenInfo() return result; } -QList Smartpen::getChangeList(const QDateTime &from) +QList Smartpen::getChangeList(PenTime from) { QList result; - QByteArray data = getObject(QString("changelist?start_time=%1").arg(toPenTime(from))); + QByteArray data = getObject(QString("changelist?start_time=%1").arg(from)); QXmlStreamReader r(data); + qDebug() << QString::fromAscii(data); + advanceToFirstChildElement(r, "xml"); advanceToFirstChildElement(r, "changelist"); @@ -176,13 +178,30 @@ QList Smartpen::getChangeList(const QDateTime &from) if (attrs.hasAttribute("guid")) { report.guid = attrs.value("guid").toString(); report.title = attrs.value("title").toString(); + + // Figure out the change record endtime to enumerating the + // endtime of all the record's changed pages + report.endTime = 0; + while (r.readNextStartElement()) { + if (r.name() == "page") { + QXmlStreamAttributes attrs = r.attributes(); + PenTime endTime = attrs.value("end_time").toString().toLongLong(); + if (endTime > report.endTime) report.endTime = endTime; + } + r.skipCurrentElement(); + } + result.append(report); } else if (attrs.hasAttribute("classname")) { report.className = attrs.value("classname").toString(); report.title = attrs.value("title").toString(); + report.endTime = attrs.value("end_time").toString().toLongLong(); result.append(report); + r.skipCurrentElement(); + } else { + qWarning() << "Unknown change report format"; + r.skipCurrentElement(); } - r.skipCurrentElement(); } else { r.skipCurrentElement(); } @@ -195,14 +214,14 @@ QList Smartpen::getChangeList(const QDateTime &from) return result; } -QByteArray Smartpen::getLspData(const QString &name, const QDateTime &from) +QByteArray Smartpen::getLspData(const QString &name, PenTime from) { - return getObject(QString("lspdata?name=%1&start_time=%2").arg(name).arg(toPenTime(from))); + return getObject(QString("lspdata?name=%1&start_time=%2").arg(name).arg(from)); } -QByteArray Smartpen::getPaperReplay(const QDateTime &from) +QByteArray Smartpen::getPaperReplay(PenTime from) { - return getObject(QString("lspdata?name=com.livescribe.paperreplay.PaperReplay&start_time=%1&returnVersion=0.3&remoteCaller=WIN_LD_200").arg(toPenTime(from))); + return getObject(QString("lspdata?name=com.livescribe.paperreplay.PaperReplay&start_time=%1&returnVersion=0.3&remoteCaller=WIN_LD_200").arg(from)); } qint64 Smartpen::toPenTime(const QDateTime &dt) -- cgit v1.2.3