1 /*
2  * Copyright 2014 Canonical Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17 
18 #ifndef ENCRYPTER_H
19 #define ENCRYPTER_H
20 
21 #include "core/outboundpkt.h"
22 #include "secret/decryptedmessage.h"
23 #include "secret/secretchat.h"
24 #include <QLoggingCategory>
25 
Q_DECLARE_LOGGING_CATEGORY(TG_SECRET_ENCRYPTER)26 Q_DECLARE_LOGGING_CATEGORY(TG_SECRET_ENCRYPTER)
27 
28 class Encrypter : public OutboundPkt
29 {
30 public:
31     explicit Encrypter(Settings *settings);
32 
33     void setSecretChat(SecretChat *secretChat);
34 
35     QByteArray generateEncryptedData(const DecryptedMessage &decryptedMessage);
36 
37 protected:
38     qint32 *mEncrExtra;
39     qint32 *mEncrPtr;
40     qint32 *mEncrStart;
41     qint32 *mEncrEnd;
42     SecretChat *mSecretChat;
43 
44     void startEncryption();
45     void endEncryption();
46     qint32 *encryptDecryptedMessage();
47     QByteArray getGeneratedBytes();
48 
49     void appendDecryptedMessage(const DecryptedMessage &decryptedMessage);
50     void appendDecryptedMessageMedia(const DecryptedMessageMedia &media);
51     void appendDecryptedMessageAction(const DecryptedMessageAction &action);
52     void appendSendMessageAction(const SendMessageAction &sendMessageAction);
53 };
54 
55 #endif // ENCRYPTER_H
56