Salome HOME
9aada570ca2b2bb1aabc496376bfb65b3f7a4d5e
[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 #ifdef WNT
15 #include <SALOME_WNT.hxx>
16 #else
17 #define SALOME_WNT_EXPORT
18 #endif
19
20 /*!
21   \class InquireEvent
22   Contains QCustomEvents for posting to InquireServersQThread
23 */
24 class SALOME_WNT_EXPORT InquireEvent : public QCustomEvent
25 {
26 public:
27
28   enum myCustomEvents{ ProgressEvent = QEvent::User + 10, ProgressEventLabel, ProgressEventError };
29   
30   InquireEvent( QEvent::Type type , void* data = 0 )
31         : QCustomEvent( type, data ) {}
32   ~InquireEvent() 
33       {
34         type() == (QEvent::Type)ProgressEvent ?
35           delete ( int* )data() : delete ( QString* )data();
36       }
37 };
38
39 class InquireServersGUI;
40
41 class SALOME_WNT_EXPORT InquireServersQThread : public QThread
42 {
43 public:
44   InquireServersQThread( InquireServersGUI* r );
45   virtual ~InquireServersQThread();
46
47   //the main loop of this thread
48   virtual void run() ;
49   //stop to ask servers
50   void stop(); 
51   //return exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
52   int getExitStatus() { return myExitStatus;}
53   //return count of inquired servers
54   int getInquiredServers() { return myServersCount; }
55
56 private:
57
58 //functions:
59
60   bool AskServer(int iteration, QString ** message);
61   bool pingServer(int iteration, QString& errMessage);
62
63 //variables:
64
65   QGuardedPtr<InquireServersGUI> receiver;
66   int _argc ;
67   char ** _argv;
68   //this variable is true if we are checking servers
69   bool IsChecking;
70   //count of inquired servers
71   int myServersCount;
72   //how many times we should repeat attempt to get response from all needed for launching SALOME servers
73   int myRepeat;
74   //define delay time between two attempts in microseconds
75   int myDelay;
76   //this strings' array contains messages for each server (e.g. "Loading: SALOMEDS_Server") 
77   QString myMessages[8];
78   //exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
79   int myExitStatus;
80
81 } ;
82
83 class QLabel;
84 class QFrame;
85 class QProgressBar;
86 class SALOME_WNT_EXPORT InquireServersGUI : public QVBox
87 {
88     Q_OBJECT
89
90 public:
91   InquireServersGUI() ;
92   ~InquireServersGUI();
93
94   //returns arguments of QApplication
95   //they are needed for CORBA servers initialization
96   void getArgs(  int& _argc, char *** _argv);
97   //return exit status: 0 - OK, >0 - BAD (some servers doesn't exists or user click cancel button) 
98   int getExitStatus();
99   //launch IAPP
100   //  bool withGUI() { return myGUI; }
101   //  void withGUI(bool gui) { myGUI = gui; }
102
103   void setPixmap( QPixmap );
104
105 protected:
106   virtual void customEvent( QCustomEvent* ); 
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 } ;