blob: c1c7615eaee0b37accd88f3c01f19fdaf4d1b162 (
plain) (
blame)
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
|
/*
(c) Copyright 2012 - 2018 Anton Sviridenko
https://picapica.im
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef HISTORY_H
#define HISTORY_H
#include <QString>
#include <QtSql>
#include <QSqlDatabase>
#include <QList>
#include <QMap>
class History
{
public:
struct HistoryRecord
{
QByteArray peer_id;
bool is_me;
bool is_delivered;
quint32 timestamp;
QString message;
};
History(QString storage, QByteArray my_id);
void Add(QByteArray peer_id, QString message, bool is_me);//is_me - true - message from me to peer, false - from peer to me
void SetDelivered(QByteArray peer_id); //mark first undelivered message from me to peer as delivered
QList<HistoryRecord> GetMessages(QByteArray peer_id, quint32 start_timestamp, quint32 end_timestamp);
QList<HistoryRecord> GetMessages(QByteArray peer_id, QString keyword);
QMap<QByteArray, QList<QString> > GetUndeliveredMessages();
bool isOK();
QString GetLastError();
private:
QSqlDatabase dbconn;
QSqlError lasterr;
QByteArray me_;
};
#endif // HISTORY_H
|