Salome HOME
NRI : Merge from V1_2.
[modules/kernel.git] / src / Loader / SALOME_Session_Loader.cxx
1 using namespace std;
2 //=============================================================================
3 // File      : SALOME_Session_Loader.cxx
4 // Created   : jeu jun 21 07:37:59 CEST 2001
5 // Author    : Paul RASCLE, EDF
6 // Project   : SALOME
7 // Copyright : EDF 2001
8 // $Header$
9 //=============================================================================
10
11 /*! \file SALOME_Session_loader.cxx
12  */
13
14 #include <SALOMEconfig.h>
15 #include CORBA_CLIENT_HEADER(SALOME_Session)
16
17 #include "Utils_ORB_INIT.hxx"
18 #include "Utils_SINGLETON.hxx"
19 #include "SALOME_NamingService.hxx"
20 #include "utilities.h"
21
22 //! CORBA client for SALOME Session server : launch GUI
23 /*!
24  *  SALOME_Session Loader launches a SALOME GUI on the SALOME session servant process
25  */
26
27 #include <qapplication.h>
28 #include "InquireServersQThread.h"
29
30 int main(int argc, char **argv)
31 {
32 //VRV: T2.4 - Trace management improvement
33   QApplication myQApp(argc, argv) ;
34   InquireServersGUI myIS;
35   myQApp.setMainWidget(&myIS);
36   ASSERT(QObject::connect(&myQApp, SIGNAL(lastWindowClosed()), &myQApp, SLOT(quit()) ) );
37   myIS.show();
38   myQApp.exec();
39
40   if (myIS.getExitStatus())
41     exit(1);
42 //VRVcd: T2.4 - Trace management improvement
43   if (myIS.withGUI()) {
44     try
45       {
46         CORBA::ORB_ptr orb = CORBA::ORB_init(argc,argv) ;
47         
48         SALOME_NamingService &NS = *SINGLETON_<SALOME_NamingService>::Instance() ;
49         ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting()) ;
50         NS.init_orb( orb ) ;
51         
52         CORBA::Object_var obj = NS.Resolve("/Kernel/Session");
53         
54         SALOME::Session_var session = SALOME::Session::_narrow(obj) ;
55         ASSERT(! CORBA::is_nil(session));
56         MESSAGE("SALOME::Session::_narrow(obj)");
57         INFOS("Corba initialisation, Distant server");
58         
59         // -------------------------------------------------------------
60         
61         session->GetInterface() ;
62         
63         // -------------------------------------------------------------
64         
65         orb->destroy() ;
66       }
67     catch (ServiceUnreachable&)
68       {
69         INFOS("Caught exception: Naming Service Unreachable");
70       }
71     catch (CORBA::COMM_FAILURE&)
72       {
73         INFOS("Caught CORBA::SystemException CommFailure.");
74       }
75     catch (CORBA::SystemException&)
76       {
77         INFOS("Caught CORBA::SystemException.");
78       }
79     catch (CORBA::Exception&)
80       {
81         INFOS("Caught CORBA::Exception.");
82       }
83     catch (...)
84       {
85         INFOS("Caught unknown exception.");
86       }
87   }
88   return 0 ;
89 }
90
91