blob: 1776d37c7c5c75cd78831fcf86ae87f0e40a2a0e [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
75public slots:
76 /**
77 * @brief reset the panel when identity is updated
78 *
79 */
80 void
81 onIdentityUpdated(const QString& identity);
82
83 /**
84 * @brief print the chatroom list on the panel
85 *
86 * @param list list of chatroom name get from discovery backend
87 */
88 void
89 onChatroomListReady(const QStringList& list);
90
91 /**
92 * @brief print the chatroom info on the panel
93 *
94 * @param info chatroom info get from discovery backend
95 */
96 void
97 onChatroomInfoReady(const ChatroomInfo& info);
98
99private slots:
100 void
101 onSelectedChatroomChanged(const QItemSelection& selected,
102 const QItemSelection& deselected);
103
104 void
105 onSelectedParticipantChanged(const QItemSelection& selected,
106 const QItemSelection& deselected);
107
108 void
109 onJoinClicked();
110
111private:
112 Ui::DiscoveryPanel* ui;
113
114 // Models.
115 QStringListModel* m_chatroomListModel;
116 QStringListModel* m_rosterListModel;
117
118 // Internal data structure.
119 QStringList m_chatroomList;
120 QStringList m_rosterList;
121 QString m_chatroom;
122 QString m_participant;
123};
124
125} // namespace chronochat
126
127#endif // CHRONOCHAT_DISCOVERY_PANEL_HPP