forked from Aseman-Land/TelegramQML
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtelegramcache.h
More file actions
133 lines (96 loc) · 4.28 KB
/
telegramcache.h
File metadata and controls
133 lines (96 loc) · 4.28 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#ifndef TELEGRAMCACHE_H
#define TELEGRAMCACHE_H
#include "tqobject.h"
#include <QJSValue>
#include <QObject>
#include <telegram/types/types.h>
class TelegramEngine;
class TelegramCachePrivate;
class TELEGRAMQMLSHARED_EXPORT TelegramCache : public TqObject
{
Q_OBJECT
Q_PROPERTY(QString path READ path WRITE setPath NOTIFY pathChanged)
Q_PROPERTY(QJSValue encryptMethod READ encryptMethod WRITE setEncryptMethod NOTIFY encryptMethodChanged)
Q_PROPERTY(QJSValue decryptMethod READ decryptMethod WRITE setDecryptMethod NOTIFY decryptMethodChanged)
Q_PROPERTY(TelegramEngine* engine READ engine NOTIFY engineChanged)
Q_PROPERTY(qint32 pts READ pts NOTIFY ptsChanged)
Q_PROPERTY(bool updating READ updating NOTIFY updatingChanged)
Q_PROPERTY(bool isValid READ isValid NOTIFY pathChanged)
public:
TelegramCache(QObject *parent = 0);
~TelegramCache();
void setPath(const QString &path);
QString path() const;
void setEncryptMethod(const QJSValue &method);
QJSValue encryptMethod() const;
void setDecryptMethod(const QJSValue &method);
QJSValue decryptMethod() const;
void setEngine(TelegramEngine *engine);
TelegramEngine *engine() const;
void setPts(qint32 pts);
qint32 pts() const;
void setQts(qint32 qts);
qint32 qts() const;
bool updating() const;
void setUpdating(bool updating);
virtual bool isValid() const;
void insert(const Message &message);
void insert(const SecretChatMessage &msg);
void insert(const User &user);
void insert(const Chat &chat);
void insert(const ChatFull &chat);
void insert(const UserFull &user);
void insert(const QList<Dialog> &dialogs);
void insert(const Dialog &dialog);
void insert(const QList<Document> &recentStickers);
void insertMe(const UserFull &user);
UserFull readMe() const;
MessagesMessages readMessages(const InputPeer &peer, int offset, int limit) const;
MessagesMessages readMessages(const Peer &peer, int offset, int limit) const;
QList<SecretChatMessage> readSecretMessages(const Peer &peer, int offset, int limit) const;
void deleteMessage(const InputPeer &peer, int msgId);
void deleteMessage(const Peer &peer, int msgId);
void deleteMessages(const InputPeer &peer);
void deleteMessages(const Peer &peer);
Chat readChat(const InputPeer &peer) const;
Chat readChat(const Peer &peer) const;
ChatFull readChatFull(const InputPeer &peer) const;
ChatFull readChatFull(const Peer &peer) const;
User readUser(const InputPeer &peer) const;
User readUser(const Peer &peer) const;
UserFull readUserFull(const InputPeer &peer) const;
UserFull readUserFull(const Peer &peer) const;
QList<Document> readRecentStickers() const;
MessagesDialogs readDialogs() const;
static QStringList requiredProperties();
Q_SIGNALS:
void pathChanged();
void encryptMethodChanged();
void decryptMethodChanged();
void engineChanged();
void ptsChanged();
void qtsChanged();
void updatingChanged();
protected:
void refresh();
QString getMessageFolder(const Peer &peer) const;
QMap<QString, QVariant> readMap(const QString &path) const;
bool writeMap(const QString &path, const QMap<QString, QVariant> &map) const;
QList<QVariant> readList(const QString &path) const;
bool writeList(const QString &path, const QList<QVariant> &list) const;
QByteArray read(const QString &path) const;
bool write(const QString &path, QByteArray data) const;
bool zeroFile(const QString &path) const;
private:
void messagesReaded(qint64 msgId, const MessagesMessages &messages);
void dialogsReaded(qint64 msgId, const MessagesDialogs &dialogs);
void onUpdates(const UpdatesType &update);
void insertUpdate(const Update &update);
void updates(qint64 msgId, const UpdatesType &result);
void updatesGetDifferenceAnswer(qint64 id, const QList<Message> &messages, const QList<class SecretChatMessage> &secretChatMessages, const QList<Update> &otherUpdates, const QList<Chat> &chats, const QList<User> &users, const UpdatesState &state, bool isIntermediateState);
void updateSecretChatMessage(const class SecretChatMessage &secretChatMessage, qint32 qts);
void loadFromPts(qint32 pts);
private:
TelegramCachePrivate *p;
};
#endif // TELEGRAMCACHE_H