aboutsummaryrefslogtreecommitdiff
path: root/paperreplay.h
blob: e77158467c95087a9d7be407463d82c74f2d67fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef PAPERREPLAY_H
#define PAPERREPLAY_H

#include <QtCore/QDateTime>
#include <QtCore/QDir>
#include <QtCore/QHash>
#include <QtCore/QMultiMap>
#include <QtCore/QVector>

#define PAPER_REPLAY "Paper Replay"

class PaperReplay : public QObject
{
	Q_OBJECT

	struct SessionData : public QSharedData {
		QString name;
		QDateTime start, end;
		QVector<quint64> pages;
		QString file;
	};

public:
	explicit PaperReplay(QObject *parent = 0);

	class Session {
	public:
		Session();
		~Session();

		QString name() const;

		QDateTime startTime() const;
		QDateTime endTime() const;

		QVector<quint64> pages() const;

		QString fileName() const;

	private:
		QSharedDataPointer<SessionData> d;

		friend class PaperReplay;
	};

	bool open(const QString &path, const QString &penSerial, quint64 notebookGuid);
	void close();

	QList<Session> sessions() const;
	QList<Session> sessions(quint64 pageAddress) const;

private:
	static bool parseSessionInfo(SessionData *session, const QString &path);
	static bool parseSessionInfo(SessionData *session, QIODevice *dev);
	static bool parseSessionInfoV3(SessionData *session, QIODevice *dev);

	static bool parseSessionPages(SessionData *session, const QString &path);
	static bool parseSessionPages(SessionData *session, QIODevice *dev);
	static bool parseSessionPagesV1(SessionData *session, QIODevice *dev);

private:
	QDir _dir;
	QHash<quint64, Session> _sessions;
	QMultiMap<quint64, quint64> _byPage;
};

#endif // PAPERREPLAY_H