aboutsummaryrefslogtreecommitdiff
path: root/paperreplay.cc
diff options
context:
space:
mode:
authorJavier <dev.git@javispedro.com>2015-06-13 17:35:15 +0200
committerJavier <dev.git@javispedro.com>2015-06-13 17:35:15 +0200
commit72a71a2003028fc97d74cebecebb1541d66ded86 (patch)
treef9850b0091f50c0dab524bec47445380fed62ef3 /paperreplay.cc
parent41f9a9b0563c3bd523bd534b854e50161a2626b3 (diff)
downloadscribiu-72a71a2003028fc97d74cebecebb1541d66ded86.tar.gz
scribiu-72a71a2003028fc97d74cebecebb1541d66ded86.zip
split afdpageaddress into new class
Diffstat (limited to 'paperreplay.cc')
-rw-r--r--paperreplay.cc55
1 files changed, 35 insertions, 20 deletions
diff --git a/paperreplay.cc b/paperreplay.cc
index 8bfb20e..579ea3c 100644
--- a/paperreplay.cc
+++ b/paperreplay.cc
@@ -24,6 +24,14 @@ PaperReplay::PaperReplay(QObject *parent) :
{
}
+PaperReplay::Session::Session() : d(new SessionData)
+{
+}
+
+PaperReplay::Session::~Session()
+{
+}
+
bool PaperReplay::open(const QString &path, const QString &penSerial, quint64 notebookGuid)
{
_dir.setPath(path + QString("/userdata/%1/Paper Replay/99/%2/sessions")
@@ -43,10 +51,10 @@ bool PaperReplay::open(const QString &path, const QString &penSerial, quint64 no
qWarning() << "Invalid session identifier:" << sessionDir.dirName();
}
Session &session = _sessions[sessionId];
- if (!parseSessionInfo(session, sessionDir.filePath("session.info"))) {
+ if (!parseSessionInfo(session.d, sessionDir.filePath("session.info"))) {
qWarning() << "Could not parse:" << sessionDir.absoluteFilePath("session.info");
}
- if (!parseSessionPages(session, sessionDir.filePath("session.pages"))) {
+ if (!parseSessionPages(session.d, sessionDir.filePath("session.pages"))) {
qWarning() << "Could not parse:" << sessionDir.absoluteFilePath("session.pages");
}
}
@@ -61,22 +69,22 @@ void PaperReplay::close()
_dir.setPath(QString());
}
-QList<PaperReplay::Session> PaperReplay::sessions()
+QList<PaperReplay::Session> PaperReplay::sessions() const
{
return _sessions.values();
}
-QList<PaperReplay::Session> PaperReplay::sessions(quint64 pageAddress)
+QList<PaperReplay::Session> PaperReplay::sessions(quint64 pageAddress) const
{
QList<Session> sessions;
- QMultiMap<quint64, quint64>::iterator it = _byPage.find(pageAddress);
+ QMultiMap<quint64, quint64>::const_iterator it = _byPage.constFind(pageAddress);
while (it != _byPage.end() && it.key() == pageAddress) {
sessions.append(_sessions[it.value()]);
}
return sessions;
}
-bool PaperReplay::parseSessionInfo(Session &session, const QString &path)
+bool PaperReplay::parseSessionInfo(SessionData *session, const QString &path)
{
QFile f(path);
if (f.open(QIODevice::ReadOnly)) {
@@ -86,7 +94,7 @@ bool PaperReplay::parseSessionInfo(Session &session, const QString &path)
}
}
-bool PaperReplay::parseSessionInfo(Session &session, QIODevice *dev)
+bool PaperReplay::parseSessionInfo(SessionData *session, QIODevice *dev)
{
unsigned char magic[2];
if (dev->read(reinterpret_cast<char*>(magic), 2) != 2 ||
@@ -110,12 +118,12 @@ bool PaperReplay::parseSessionInfo(Session &session, QIODevice *dev)
}
}
-bool PaperReplay::parseSessionInfoV3(Session &session, QIODevice *dev)
+bool PaperReplay::parseSessionInfoV3(SessionData *session, QIODevice *dev)
{
QDataStream s(dev);
if (s.skipRawData(5) != 5) return false;
- qint64 startTime, endTime, creationTime;
+ quint64 startTime, endTime, creationTime;
QString name;
s >> startTime >> endTime >> creationTime;
@@ -123,19 +131,26 @@ bool PaperReplay::parseSessionInfoV3(Session &session, QIODevice *dev)
return false;
}
- qDebug() << "Name:" << name << Smartpen::fromPenTime(startTime) << Smartpen::fromPenTime(endTime) << creationTime;
+ session->name = name;
+ session->start = Smartpen::fromPenTime(startTime);
+ session->end = Smartpen::fromPenTime(endTime);
+
+ qDebug() << "Session:" << name << session->start << session->end;
quint16 num_clips;
s >> num_clips;
+ Q_ASSERT(num_clips == 1); // TODO: We do not yet know how to handle this scenario
+
for (uint i = 0; i < num_clips; ++i) {
QString file;
if (!readUtfString(s, file)) {
return false;
}
s >> startTime >> endTime;
- qDebug() << " Clip:" << file << startTime << endTime;
- qDebug() << " " << QDateTime::fromTime_t(startTime) << QDateTime::fromTime_t(endTime);
+
+ qDebug() << " Clip:" << file << Smartpen::fromPenTime(startTime) << Smartpen::fromPenTime(endTime);
+ session->file = file;
}
quint16 num_strokes;
@@ -157,7 +172,7 @@ bool PaperReplay::parseSessionInfoV3(Session &session, QIODevice *dev)
return true;
}
-bool PaperReplay::parseSessionPages(Session &session, const QString &path)
+bool PaperReplay::parseSessionPages(SessionData *session, const QString &path)
{
QFile f(path);
if (f.open(QIODevice::ReadOnly)) {
@@ -167,7 +182,7 @@ bool PaperReplay::parseSessionPages(Session &session, const QString &path)
}
}
-bool PaperReplay::parseSessionPages(Session &session, QIODevice *dev)
+bool PaperReplay::parseSessionPages(SessionData *session, QIODevice *dev)
{
unsigned char magic[2];
if (dev->read(reinterpret_cast<char*>(magic), 2) != 2 ||
@@ -191,21 +206,21 @@ bool PaperReplay::parseSessionPages(Session &session, QIODevice *dev)
}
}
-bool PaperReplay::parseSessionPagesV1(Session &session, QIODevice *dev)
+bool PaperReplay::parseSessionPagesV1(SessionData *session, QIODevice *dev)
{
QDataStream s(dev);
if (s.skipRawData(1) != 1) return false;
quint16 num_pages = 0;
s >> num_pages;
- session.pages.reserve(session.pages.size() + num_pages);
+ session->pages.reserve(session->pages.size() + num_pages);
for (uint i = 0; i < num_pages; ++i) {
- quint64 address, unk;
- s >> address >> unk;
+ quint64 address, time;
+ s >> address >> time;
- session.pages.append(address);
- qDebug() << " Page:" << address << unk;
+ session->pages.append(address);
+ qDebug() << " Page:" << address << time << Smartpen::fromPenTime(time);
}
return true;