1 /*
2     Copyright © 2019 by The qTox Project Contributors
3 
4     This file is part of qTox, a Qt-based graphical interface for Tox.
5 
6     qTox is libre software: you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation, either version 3 of the License, or
9     (at your option) any later version.
10 
11     qTox is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with qTox.  If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef GROUP_MESSAGE_DISPATCHER_H
21 #define GROUP_MESSAGE_DISPATCHER_H
22 
23 #include "src/core/icoregroupmessagesender.h"
24 #include "src/core/icoreidhandler.h"
25 #include "src/model/group.h"
26 #include "src/model/imessagedispatcher.h"
27 #include "src/model/message.h"
28 
29 #include <QObject>
30 #include <QString>
31 
32 #include <cstdint>
33 
34 class IGroupSettings;
35 
36 class GroupMessageDispatcher : public IMessageDispatcher
37 {
38     Q_OBJECT
39 public:
40     GroupMessageDispatcher(Group& group, MessageProcessor processor, ICoreIdHandler& idHandler,
41                            ICoreGroupMessageSender& messageSender,
42                            const IGroupSettings& groupSettings);
43 
44     std::pair<DispatchedMessageId, DispatchedMessageId> sendMessage(bool isAction,
45                                                                     QString const& content) override;
46     void onMessageReceived(ToxPk const& sender, bool isAction, QString const& content);
47 
48 private:
49     Group& group;
50     MessageProcessor processor;
51     ICoreIdHandler& idHandler;
52     ICoreGroupMessageSender& messageSender;
53     const IGroupSettings& groupSettings;
54     DispatchedMessageId nextMessageId{0};
55 };
56 
57 
58 #endif /* IMESSAGE_DISPATCHER_H */
59