summaryrefslogtreecommitdiffstats
path: root/src/server/mainwindow/mainwindow.h
blob: 5349903ccb146aa1f69ccb9d2a95407cd7a9db2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#ifndef _MAINWINDOW_H_
#define _MAINWINDOW_H_

#include <QtGui>
#include <QMainWindow>
#include "../net/client.h"
#include "../net/filedownloader.h"

class SessionNameWindow;
class ConnectionFrame;
class ListenServer;
class DiscoveryListener;
class HelpWindow;
class ReloadWindow;

namespace Ui{
	class MainWindow;
}

/**
 * Initializing MainWindow.
 * Handle ButtonEvents and initialize ListenServer.
 */
class MainWindow : public QMainWindow
{
	Q_OBJECT

public:

	MainWindow(QString ipListUrl, QWidget *parent = 0);
	~MainWindow();	

private:

	// Ui stuff
	Ui::MainWindow    *ui;
	SessionNameWindow *_sessionNameWindow;
	HelpWindow        *_helpWindow;
	ReloadWindow			*_reloadWindow;
	QLabel            *_sessionNameLabel;
	int               _tbIconSize;
	Qt::ToolBarArea   _tbArea;
	int               _tileWidth, _tileHeight;
	static const int  _tilesX = 9;
	static const int  _tilesY = 7;

	// Button block stuff
	QTimer              *_buttonLockTimer;
	QList<QAction*>     _lockingButtons;
	static const qint64 _buttonBlockTime = 2000;

	// Management stuff
	enum class Mode {
		Broadcast,
		Multicast,
		Unicast,
		LockedUnicast,
		None
	} _mode;
	int _streamingSource;
	int _countSessionNameUpdate;

	QList<ConnectionFrame*> _clientFrames;
	ListenServer            *_listenServer;
	DiscoveryListener       *_discoveryListener;
	FileDownloader          _fileDownloader;
	QStringList             _tutorList;
	QMap<QString, QList<QPair<QString, QPoint> > > _rooms;

	static const QString sStrTutorNdef;
	static const QString sStrTutorOffline;
	static const QString sStrSourceNdef;
	static const QString sStrSourceOffline;
	static const QString sStrDestNdef;
	static const QString sStrDestOffline;
	static const QString sStrSourceDestSame;
	static const QString sStrClientOnline;
	static const QString sStrNoDestAv;

	void placeFrameInFreeSlot(ConnectionFrame* frame);
	ConnectionFrame* createFrame();
	ConnectionFrame* createFrame(QString computerId, QPoint position);
	bool loadPosition(QSettings& settings, const QString& id, int& x, int& y);
	void savePosition(ConnectionFrame *cf);
	void startVncServerIfNecessary(int from);
	void tellClientCurrentSituation(Client* client);
	void tryToUseRoomTemplate();
	void reset();
	Client* getClientFromId(int id);
	ConnectionFrame* getTutorFrame();
	ConnectionFrame* getSelectedFrame();

	void closeEvent(QCloseEvent *e);
	void changeEvent(QEvent *e);
	void resizeEvent(QResizeEvent *e);
	void mouseReleaseEvent(QMouseEvent* e);


protected slots:
	void onTutorListDownloaded(QByteArray& tutorList);
	void onSessionNameClick();
	void onSessionNameUpdate();

	void onButtonLock(bool checked);
	void onButtonStudentToTutor();
	void onButtonStudentToTutorExclusive();
	void onButtonTutorToAll();
	void onButtonTutorToStudent();
	void onButtonStopProjection();

	void onButtonSetAsTutor();
	void onButtonReloadRoomConfig();

	void onButtonExit();
	void onButtonHelp();
	void DisableButtons();
	void EnableButtons();
	// connection frame
	void onPlaceFrame(bool activateTrash, ConnectionFrame* frame);
	void onFrameClicked(ConnectionFrame* frame);
	// Net
	void onClientConnected(Client* client);
	void onClientAuthenticating(Client* client, ClientLogin* request);
	void onClientAuthenticated(Client* client);
	void onVncServerStateChange(Client* client);
	void onVncClientStateChange(Client* client);
};
#endif