]> SALOME platform Git repositories - modules/gui.git/blob - src/Session/InquireServersQThread.h
Salome HOME
Improve the look-n-feel of the splash window
[modules/gui.git] / src / Session / InquireServersQThread.h
1 //  Copyright (C) 2003  CEA/DEN, EDF R&D
2 //
3 //
4 //
5 //  File   : InquireServersQThread.h
6 //  Author : Vasily RUSYAEV
7 //  Module : SALOME
8 //  $Header$
9
10 #include <qthread.h> 
11 #include <qvbox.h> 
12 #include <qguardedptr.h> 
13
14 /**********************************************************
15 **  Class:   InquireEvent
16 **  Descr:   Contains QCustomEvents for posting to InquireServersQThread
17 **  Level:   Private
18 ***********************************************************/
19 class InquireEvent : public QCustomEvent
20 {
21 public:
22
23   enum myCustomEvents{ ProgressEvent = QEvent::User + 10, ProgressEventLabel, ProgressEventError };
24   
25   InquireEvent( QEvent::Type type , void* data = 0 )
26         : QCustomEvent( type, data ) {}
27   ~InquireEvent() 
28       {
29         type() == (QEvent::Type)ProgressEvent ?
30           delete ( int* )data() : delete ( QString* )data();
31       }
32 };
33
34 class InquireServersGUI;
35
36 class InquireServersQThread : public QThread
37 {
38 public:
39   InquireServersQThread( InquireServersGUI* r );
40   virtual ~InquireServersQThread();
41
42   //the main loop of this thread
43   virtual void run() ;
44   //stop to ask servers
45   void stop() 
46     {
47       IsChecking = false;
48       myExitStatus = 1;
49     }
50   //return exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
51   int getExitStatus() { return myExitStatus;}
52   //return count of inquired servers
53   int getInquiredServers() { return myServersCount; }
54
55 private:
56
57 //functions:
58
59   bool AskServer(int iteration, QString ** message);
60   bool pingServer(int iteration, QString& errMessage);
61
62 //variables:
63
64   QGuardedPtr<InquireServersGUI> receiver;
65   int _argc ;
66   char ** _argv;
67   //this variable is true if we are checking servers
68   bool IsChecking;
69   //count of inquired servers
70   int myServersCount;
71   //how many times we should repeat attempt to get response from all needed for launching SALOME servers
72   int myRepeat;
73   //define delay time between two attempts in microseconds
74   int myDelay;
75   //this strings' array contains messages for each server (e.g. "Loading: SALOMEDS_Server") 
76   QString myMessages[8];
77   //exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
78   int myExitStatus;
79
80 } ;
81
82 class QLabel;
83 class QFrame;
84 class QProgressBar;
85 class InquireServersGUI : public QVBox
86 {
87     Q_OBJECT
88
89 public:
90   InquireServersGUI() ;
91   ~InquireServersGUI();
92
93   //returns arguments of QApplication
94   //they are needed for CORBA servers initialization
95   void getArgs(  int& _argc, char *** _argv);
96   //return exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
97   int getExitStatus();
98   //launch IAPP
99   //  bool withGUI() { return myGUI; }
100   //  void withGUI(bool gui) { myGUI = gui; }
101
102   void setPixmap( QPixmap );
103
104 protected:
105   virtual void customEvent( QCustomEvent* ); 
106   virtual void closeEvent ( QCloseEvent * );
107
108 private:
109   InquireServersQThread* myThread;
110   QProgressBar* myPrgBar;
111   //this string contains description of currently asked server
112   QLabel* myLabel;
113   QLabel* mySplash;
114   QFrame* mySplashFrame;
115   //  bool myGUI;
116
117 private slots:
118
119     void ClickOnCancel();
120 } ;