aboutsummaryrefslogtreecommitdiff
path: root/smartpensyncer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'smartpensyncer.cc')
-rw-r--r--smartpensyncer.cc37
1 files changed, 34 insertions, 3 deletions
diff --git a/smartpensyncer.cc b/smartpensyncer.cc
index 50304a3..fe7a281 100644
--- a/smartpensyncer.cc
+++ b/smartpensyncer.cc
@@ -108,9 +108,16 @@ bool SmartpenSyncer::syncPen()
QList<Smartpen::ChangeReport> changes = _pen->getChangeList(lastSyncTime);
foreach(const Smartpen::ChangeReport &change, changes) {
- qDebug() << "Synchronizing guid: " << change.guid << change.title;
- if (!syncNotebook(change)) {
- return false;
+ if (!change.guid.isEmpty()) {
+ qDebug() << "Synchronizing guid: " << change.guid << change.title;
+ if (!syncNotebook(change)) {
+ return false;
+ }
+ } else if (change.className == "com.livescribe.paperreplay.PaperReplay") {
+ qDebug() << "Synchronizing paper replay";
+ if (!syncPaperReplay()) {
+ return false;
+ }
}
}
@@ -143,6 +150,30 @@ bool SmartpenSyncer::syncNotebook(const Smartpen::ChangeReport &change)
return true;
}
+bool SmartpenSyncer::syncPaperReplay()
+{
+ QDir replayDir(_penDataDir.filePath("PaperReplay"));
+ if (!replayDir.exists()) {
+ if (!replayDir.mkpath(".")) {
+ qWarning() << "Cannot create PaperReplay data directory:" << replayDir.absolutePath();
+ }
+ }
+
+ setTimestampFileDate(replayDir.filePath(".sync.lck"));
+
+ QDateTime lastSyncTime = getTimestampFileDate(replayDir.filePath(".lastsync"));
+ QByteArray replayData = _pen->getPaperReplay(lastSyncTime);
+
+ if (!extractZip(replayData, replayDir)) {
+ return false;
+ }
+
+ setTimestampFileDate(replayDir.filePath(".lastsync"));
+ removeTimestampFile(replayDir.filePath(".sync.lck"));
+
+ return true;
+}
+
bool SmartpenSyncer::extractZip(QByteArray &zipData, QDir &dir)
{
QBuffer zipBuffer(&zipData);