aboutsummaryrefslogtreecommitdiff
path: root/smartpensyncer.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-06-11 01:16:26 +0200
committerJavier <dev.git@javispedro.com>2015-06-11 01:16:26 +0200
commit6cb50e66f3c196a2a4bcc95a419260d6b8c2461f (patch)
tree610963526dbd205500db145965309b1de2b18a97 /smartpensyncer.cc
parenta69e97943539a8abc4d2762638c169dc19c88516 (diff)
downloadscribiu-6cb50e66f3c196a2a4bcc95a419260d6b8c2461f.tar.gz
scribiu-6cb50e66f3c196a2a4bcc95a419260d6b8c2461f.zip
experiment with audio/paperreplay data
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);