]> SALOME platform Git repositories - modules/gui.git/blob - src/Session/InquireServersQThread.h
Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / Session / InquireServersQThread.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 //  File   : InquireServersQThread.h
20 //  Author : Vasily RUSYAEV
21 //  Module : SALOME
22
23 #include <qthread.h> 
24 #include <qvbox.h> 
25 #include <qguardedptr.h> 
26
27 #ifdef WNT
28 #include <SALOME_WNT.hxx>
29 #else
30 #define SALOME_WNT_EXPORT
31 #endif
32
33 /*!
34   \class InquireEvent
35   Contains QCustomEvents for posting to InquireServersQThread
36 */
37 class SALOME_WNT_EXPORT InquireEvent : public QCustomEvent
38 {
39 public:
40
41   enum myCustomEvents{ ProgressEvent = QEvent::User + 10, ProgressEventLabel, ProgressEventError };
42   
43   InquireEvent( QEvent::Type type , void* data = 0 )
44         : QCustomEvent( type, data ) {}
45   ~InquireEvent() 
46       {
47         type() == (QEvent::Type)ProgressEvent ?
48           delete ( int* )data() : delete ( QString* )data();
49       }
50 };
51
52 class InquireServersGUI;
53
54 class SALOME_WNT_EXPORT InquireServersQThread : public QThread
55 {
56 public:
57   InquireServersQThread( InquireServersGUI* r );
58   virtual ~InquireServersQThread();
59
60   //the main loop of this thread
61   virtual void run() ;
62   //stop to ask servers
63   void stop(); 
64   //return exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
65   int getExitStatus() { return myExitStatus;}
66   //return count of inquired servers
67   int getInquiredServers() { return myServersCount; }
68
69 private:
70
71 //functions:
72
73   bool AskServer(int iteration, QString ** message);
74   bool pingServer(int iteration, QString& errMessage);
75
76 //variables:
77
78   QGuardedPtr<InquireServersGUI> receiver;
79   int _argc ;
80   char ** _argv;
81   //this variable is true if we are checking servers
82   bool IsChecking;
83   //count of inquired servers
84   int myServersCount;
85   //how many times we should repeat attempt to get response from all needed for launching SALOME servers
86   int myRepeat;
87   //define delay time between two attempts in microseconds
88   int myDelay;
89   //this strings' array contains messages for each server (e.g. "Loading: SALOMEDS_Server") 
90   QString myMessages[8];
91   //exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
92   int myExitStatus;
93
94 } ;
95
96 class QLabel;
97 class QFrame;
98 class QProgressBar;
99 class SALOME_WNT_EXPORT InquireServersGUI : public QVBox
100 {
101     Q_OBJECT
102
103 public:
104   InquireServersGUI() ;
105   ~InquireServersGUI();
106
107   //returns arguments of QApplication
108   //they are needed for CORBA servers initialization
109   void getArgs(  int& _argc, char *** _argv);
110   //return exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
111   int getExitStatus();
112   //launch IAPP
113   //  bool withGUI() { return myGUI; }
114   //  void withGUI(bool gui) { myGUI = gui; }
115
116   void setPixmap( QPixmap );
117
118 protected:
119   virtual void customEvent( QCustomEvent* ); 
120
121 private:
122   InquireServersQThread* myThread;
123   QProgressBar* myPrgBar;
124   //this string contains description of currently asked server
125   QLabel* myLabel;
126   QLabel* mySplash;
127   QFrame* mySplashFrame;
128   //  bool myGUI;
129
130 private slots:
131
132     void ClickOnCancel();
133 } ;