This repository has been archived by the owner on Dec 11, 2018. It is now read-only.
forked from Aseman-Land/TelegramQML
-
Notifications
You must be signed in to change notification settings - Fork 1
/
database.h
98 lines (75 loc) · 2.71 KB
/
database.h
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef DATABASE_H
#define DATABASE_H
#include <QObject>
#include "telegramqml_global.h"
#include "databaseabstractencryptor.h"
#include "databasecore.h"
class Peer;
class Message;
class User;
class Dialog;
class Contact;
class Chat;
class DbUser;
class DbDialog;
class DbMessage;
class DbContact;
class DbChat;
class TELEGRAMQMLSHARED_EXPORT Database : public QObject
{
Q_OBJECT
Q_PROPERTY(QString phoneNumber READ phoneNumber WRITE setPhoneNumber NOTIFY phoneNumberChanged)
Q_PROPERTY(QString configPath READ configPath WRITE setConfigPath NOTIFY configPathChanged)
public:
Database(QObject *parent = 0);
~Database();
void setPhoneNumber(const QString &phoneNumber);
QString phoneNumber() const;
void setConfigPath(const QString &path);
QString configPath() const;
void setEncrypter(DatabaseAbstractEncryptor *encrypter);
DatabaseAbstractEncryptor *encrypter() const;
public Q_SLOTS:
void insertUser(const User &user);
void insertChat(const Chat &chat);
void insertDialog(const Dialog &dialog, bool encrypted);
void insertContact(const Contact &contact);
void insertMessage(const Message &message, bool encrypted);
void insertMediaEncryptedKeys(qint64 mediaId, const QByteArray &key, const QByteArray &iv);
void updateUnreadCount(qint64 chatId, int unreadCount);
void readFullDialogs();
void readMessages(const Peer &peer, int offset, int limit);
void markMessagesAsRead(const qint32 msgId, const Peer &peer);
void markMessagesAsReadFromMaxDate(qint32 chatId, qint32 maxDate);
void deleteMessage(qint64 msgId);
void deleteDialog(qint64 dlgId);
void deleteHistory(qint64 dlgId);
void blockUser(qint64 userId);
void unblockUser(qint64 userId);
int getMessagesAvailable(const Peer &peer);
Q_SIGNALS:
void userFounded(const User &user);
void chatFounded(const Chat &chat);
void dialogFounded(const Dialog &dialog, bool encrypted);
void contactFounded(const Contact &contact);
void messageFounded(const Message &message);
void mediaKeyFounded(qint64 mediaId, const QByteArray &key, const QByteArray &iv);
void phoneNumberChanged();
void configPathChanged();
private Q_SLOTS:
void userFounded_slt(const DbUser &user);
void chatFounded_slt(const DbChat &chat);
void dialogFounded_slt(const DbDialog &dialog, bool encrypted);
void messageFounded_slt(const DbMessage &message);
void contactFounded_slt(const DbContact &contact);
private:
void refresh();
//from DatabasePrivate
QString path;
QThread *thread;
DatabaseCore *core;
DatabaseAbstractEncryptor *internal_encrypter;
QString internal_phoneNumber;
QString internal_configPath;
};
#endif // DATABASE_H