]> SALOME platform Git repositories - modules/gui.git/blob - src/Loader/SALOME_Session_Loader.cxx
Salome HOME
Splash screen was implemented. Changes in packages SUIT and Session are integrated.
[modules/gui.git] / src / Loader / SALOME_Session_Loader.cxx
1 //  Copyright (C) 2003  CEA/DEN, EDF R&D
2 //
3 //
4 //
5 //  File   : SALOME_Session_loader.cxx
6 //  Author : Paul RASCLE, EDF
7 //  Module : SALOME
8 //  $Header$
9
10 using namespace std;
11 /*! \file SALOME_Session_loader.cxx
12  */
13
14 #include <SALOMEconfig.h>
15 #include CORBA_CLIENT_HEADER(SALOME_Session)
16 #include CORBA_CLIENT_HEADER(Logger)
17
18 #include "Utils_ORB_INIT.hxx"
19 #include "Utils_SINGLETON.hxx"
20 #include "SALOME_NamingService.hxx"
21 #include "utilities.h"
22
23 //! CORBA client for SALOME Session server : launch GUI
24 /*!
25  *  SALOME_Session Loader launches a SALOME GUI on the SALOME session servant process
26  */
27
28 #include <qapplication.h>
29 #include "InquireServersQThread.h"
30
31 void MessageOutput( QtMsgType type, const char *msg )
32 {
33   switch ( type ) {
34   case QtDebugMsg:
35     MESSAGE( "Debug: " << msg );
36     break;
37   case QtWarningMsg:
38     MESSAGE( "Warning: " << msg );
39     break;
40   case QtFatalMsg:
41     MESSAGE( "Fatal: " << msg );
42     break;
43   }
44 }
45
46 int main(int argc, char **argv)
47 {
48   qInstallMsgHandler( MessageOutput );
49 //VRV: T2.4 - Trace management improvement
50   QApplication myQApp(argc, argv) ;
51   InquireServersGUI myIS;
52   myQApp.setMainWidget(&myIS);
53   ASSERT(QObject::connect(&myQApp, SIGNAL(lastWindowClosed()), &myQApp, SLOT(quit()) ) );
54   myIS.show();
55   myQApp.exec();
56
57   if (myIS.getExitStatus())
58     exit(1);
59 //VRV: T2.4 - Trace management improvement
60   if (myIS.withGUI()) {
61     try
62       {
63         CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv) ;
64         
65         SALOME_NamingService &NS = *SINGLETON_<SALOME_NamingService>::Instance() ;
66         ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
67         NS.init_orb( orb ) ;
68         
69         CORBA::Object_var obj = NS.Resolve("/Kernel/Session");
70         
71         SALOME::Session_var session = SALOME::Session::_narrow(obj) ;
72         ASSERT(! CORBA::is_nil(session));
73         MESSAGE("SALOME::Session::_narrow(obj)");
74         INFOS("Corba initialisation, Distant server");
75         
76         // -------------------------------------------------------------
77         
78         session->GetInterface() ;
79
80         // -------------------------------------------------------------
81         
82         orb->destroy() ;
83       }
84     catch (ServiceUnreachable&)
85       {
86         INFOS("Caught exception: Naming Service Unreachable");
87       }
88     catch (CORBA::COMM_FAILURE&)
89       {
90         INFOS("Caught CORBA::SystemException CommFailure.");
91       }
92     catch (CORBA::SystemException&)
93       {
94         INFOS("Caught CORBA::SystemException.");
95       }
96     catch (CORBA::Exception&)
97       {
98         INFOS("Caught CORBA::Exception.");
99       }
100     catch (...)
101       {
102         INFOS("Caught unknown exception.");
103       }
104     return 0 ;
105   }
106 }
107
108