summaryrefslogblamecommitdiffstats
path: root/src/server/mainwindow/mainwindow.h
blob: 4f40a67053029e478730b9e7dfb8113b740d5680 (plain) (tree)
1
2
3
4
5
6
7




                      
                          
                                  




                        
                 
 
             


                         



                                                   

                                     
                
 




                                                           
        

                              
                                              
                                






                                                        

                             

                                              
                                                   
 

                                              



                                              
 






                                                




                                                                                  
                                           
                                     
                                                                         
 



                                               
 
 
                
                                                          

                                   

                                      
                                               

                                      
                                      

                                        
                                  
                            

                              







                                                                          
                                                                              
  
      
#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;

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;
	QLabel            *_sessionNameLabel;
	int               _tbIconSize;
	Qt::ToolBarArea   _tbArea;
	int               _tileWidth, _tileHeight;
	ConnectionFrame   *_tutorFrame, *_selectedFrame;
	static const int  _tilesX = 9;
	static const int  _tilesY = 7;

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

	// Internal stuff
	QList<ConnectionFrame*> _clientFrames;
	ListenServer      *_listenServer;
	DiscoveryListener *_discoveryListener;
	FileDownloader    _fileDownloader;
	QStringList       _tutorList;

	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;

	void placeFrameInFreeSlot(ConnectionFrame* frame);
	ConnectionFrame* createFrame();
	bool loadPosition(QSettings& settings, const QString& id, int& x, int& y);
	void savePosition(ConnectionFrame *cf);
	bool isValidClient(Client* client);
	void broadcast(Client *from);
	void unicast(Client *from, Client *to, bool blockOthers = false);

	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 onButtonStudentToAll();
	void onButtonStudentToTutor();
	void onButtonStudentToTutorExclusive();
	void onButtonTutorToAll();
	void onButtonTutorToStudent();
	void onButtonStopProjection();
	void onButtonLock(bool checked);
	void onButtonExit();
	void onButtonSetAsTutor();
	void onButtonHelp();
	void DisableButtons();
	void EnableButtons();
	// connection frame
	void onPlaceFrame(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, int lastProjectionSource);
};
#endif