JS8Call-Improved master
Loading...
Searching...
No Matches
Inbox.h
1#pragma once
2
7
8#include "Message.h"
9
10#include <QList>
11#include <QMap>
12#include <QPair>
13#include <QString>
14
15class Inbox {
16 public:
17 explicit Inbox(QString path);
18 ~Inbox();
19
20 bool isOpen();
21 bool open();
22 void close();
23 QString error();
24
25 // Low-level
26 int count(QString type, QString query, QString match);
27 QList<QPair<int, Message>> values(QString type, QString query, QString match,
28 int offset, int limit);
29 Message value(int key);
30 int append(Message value);
31 bool set(int key, Message value);
32 bool del(int key);
33
34 // High-level
35 QList<QPair<int, Message>> fetchForCall(const QString& callPattern);
36 int getLookaheadMessageIdForCallsign(const QString& callsign, int afterMsgId);
37 int countUnreadFrom(QString from);
38 QPair<int, Message> firstUnreadFrom(QString from);
39
40 QMap<QString, int> getGroupMessageCounts();
41 bool markGroupMsgDeliveredForCallsign(int msgId, QString callsign);
42 int getNextGroupMessageIdForCallsign(const QString& group_name, const QString& callsign);
43 int getLookaheadGroupMessageIdForCallsign(const QString& group_name,
44 const QString& callsign, int afterMsgId);
45 int countUnreadForCallsign(const QString& callsign);
46 int countGroupUnreadForCallsign(const QString& group_name, const QString& callsign);
47
48 private:
49 QString path_;
50 struct sqlite3* db_;
51
52 // Schema + one-time v1 -> v2 migration. inbox_v2 is the only schema this
53 // (or any future) version of the software creates or writes to; inbox_v1
54 // (the legacy JSON-blob table) is only ever read, and only during the
55 // one-time migration below, if an older version of the software left one
56 // behind. We never write to inbox_v1 again, and never re-create it.
57 // It will be deprecated in a future release when migration is deemed complete.
58 bool ensureSchemaAndMigrate();
59 bool createV2Schema();
60 bool hasTable(const char* tableName);
61 bool migrateV1ToV2();
62};
bool isOpen()
Definition Inbox.cpp:113
int getLookaheadMessageIdForCallsign(const QString &callsign, int afterMsgId)
Definition Inbox.cpp:563
Definition Message.h:16
Definition qpriorityqueue.h:39