1 /*
2     Copyright © 2014-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 FRIEND_CHATROOM_H
21 #define FRIEND_CHATROOM_H
22 
23 #include "chatroom.h"
24 
25 #include <QObject>
26 #include <QString>
27 #include <QVector>
28 
29 class IDialogsManager;
30 class Friend;
31 class Group;
32 
33 struct GroupToDisplay
34 {
35     QString name;
36     Group* group;
37 };
38 
39 struct CircleToDisplay
40 {
41     QString name;
42     int circleId;
43 };
44 
45 class FriendChatroom : public QObject, public Chatroom
46 {
47     Q_OBJECT
48 public:
49     FriendChatroom(Friend* frnd, IDialogsManager* dialogsManager);
50 
51     Contact* getContact() override;
52 
53 public slots:
54 
55     Friend* getFriend();
56 
57     void setActive(bool active);
58 
59     bool canBeInvited() const;
60 
61     int getCircleId() const;
62     QString getCircleName() const;
63 
64     void inviteToNewGroup();
65     void inviteFriend(const Group* group);
66 
67     bool autoAcceptEnabled() const;
68     QString getAutoAcceptDir() const;
69     void disableAutoAccept();
70     void setAutoAcceptDir(const QString& dir);
71 
72     QVector<GroupToDisplay> getGroups() const;
73     QVector<CircleToDisplay> getOtherCircles() const;
74 
75     void resetEventFlags();
76 
77     bool possibleToOpenInNewWindow() const;
78     bool canBeRemovedFromWindow() const;
79     bool friendCanBeRemoved() const;
80     void removeFriendFromDialogs();
81 
82 signals:
83     void activeChanged(bool activated);
84 
85 private:
86     bool active{false};
87     Friend* frnd{nullptr};
88     IDialogsManager* dialogsManager{nullptr};
89 };
90 
91 #endif // FRIEND_H
92