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