blob: f15906b38588ee3e4f1cea18f76a66ab386f9953 [file] [log] [blame]
Qiuhan Ding43c8e162015-02-02 15:16:48 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 *
5 * BSD license, See the LICENSE file for more information
6 *
7 * Author: Qiuhan Ding <qiuhanding@cs.ucla.edu>
8 * Yingdi Yu <yingdi@cs.ucla.edu>
9 */
10
11#ifndef CHRONOCHAT_DISCOVERY_PANEL_HPP
12#define CHRONOCHAT_DISCOVERY_PANEL_HPP
13
14#include <QDialog>
15#include <QStringListModel>
16
17#ifndef Q_MOC_RUN
18#include "chatroom-info.hpp"
19#endif
20
21namespace Ui {
22class DiscoveryPanel;
23}
24
25namespace chronochat {
26
27class DiscoveryPanel : public QDialog
28{
29 Q_OBJECT
30
31public:
32 explicit
33 DiscoveryPanel(QWidget* parent = 0);
34
35 virtual
36 ~DiscoveryPanel();
37
38private:
39 void
40 resetPanel();
41
42 void
43 refreshPanel();
44
45signals:
46 /**
47 * @brief get chatroom info from discovery backend
48 *
49 * @param chatroomName the name of chatroom we want to get info from
50 */
51 void
52 waitForChatroomInfo(const QString& chatroomName);
53
54 /**
55 * @brief send warning if strange things happen
56 *
57 * @param msg the message that print in the warning
58 */
59 void
60 warning(const QString& msg);
61
62 /**
63 * @brief join the chatroom the user clicked
64 *
65 * This function will be called if the join button is clicked. The join button is enabled
66 * when there is no trust model for the chatroom.
67 * The user will join the chatroom he choose directly.
68 *
69 * @param chatroomName the chatroom to join
70 * @param secured if security is enabled in this chatroom
71 */
72 void
73 startChatroom(const QString& chatroomName, bool secured);
74
Qiuhan Dingba3e57a2015-01-08 19:07:39 -080075 /**
76 * @brief send request for invitation to a chatroom
77 *
78 * This function will be called if request invitation button is clicked.
79 *
80 * @param chatroomName the chatroom to join
81 * @param identity the person that the user send the request to
82 */
83 void
84 sendInvitationRequest(const QString& chatroomName, const QString& identity);
85
Qiuhan Ding43c8e162015-02-02 15:16:48 -080086public slots:
87 /**
88 * @brief reset the panel when identity is updated
89 *
90 */
91 void
92 onIdentityUpdated(const QString& identity);
93
94 /**
95 * @brief print the chatroom list on the panel
96 *
97 * @param list list of chatroom name get from discovery backend
98 */
99 void
100 onChatroomListReady(const QStringList& list);
101
102 /**
103 * @brief print the chatroom info on the panel
104 *
105 * @param info chatroom info get from discovery backend
Qiuhan Dingba3e57a2015-01-08 19:07:39 -0800106 * @param isParticipant if the user is a participant of the chatroom
Qiuhan Ding43c8e162015-02-02 15:16:48 -0800107 */
108 void
Qiuhan Dingba3e57a2015-01-08 19:07:39 -0800109 onChatroomInfoReady(const ChatroomInfo& info, bool isParticipant);
Qiuhan Ding43c8e162015-02-02 15:16:48 -0800110
111private slots:
112 void
113 onSelectedChatroomChanged(const QItemSelection& selected,
114 const QItemSelection& deselected);
115
116 void
117 onSelectedParticipantChanged(const QItemSelection& selected,
118 const QItemSelection& deselected);
119
120 void
121 onJoinClicked();
122
Qiuhan Dingba3e57a2015-01-08 19:07:39 -0800123 void
124 onRequestInvitation();
125
126 void
127 onInvitationRequestResult(const std::string& message);
128
Qiuhan Ding43c8e162015-02-02 15:16:48 -0800129private:
130 Ui::DiscoveryPanel* ui;
131
132 // Models.
133 QStringListModel* m_chatroomListModel;
134 QStringListModel* m_rosterListModel;
135
136 // Internal data structure.
137 QStringList m_chatroomList;
138 QStringList m_rosterList;
139 QString m_chatroom;
140 QString m_participant;
141};
142
143} // namespace chronochat
144
145#endif // CHRONOCHAT_DISCOVERY_PANEL_HPP