2 // File : NOTIFICATION.cxx
3 // Created : 1 Avril 2002
4 // Author : Laurent DADA / Francis KLOSS
6 // Module : Notification General
7 // Copyright : CEA / Open CASCADE
9 #include "NOTIFICATION.hxx"
12 #include "Utils_ORB_INIT.hxx"
13 #include "Utils_SINGLETON.hxx"
15 CosNA_EventChannel_ptr NOTIFICATION_channel() {
16 ORB_INIT& init = *SINGLETON_<ORB_INIT>::Instance(); ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
17 CORBA::ORB_ptr orb = init(0, 0);
19 CosNA_EventChannel_ptr channel = CosNA_EventChannel::_nil();
20 CosNaming::NamingContext_var name_context;
22 CORBA::Object_var name_service;
25 name_service = orb->resolve_initial_references("NameService");
26 name_context = CosNaming::NamingContext::_narrow(name_service);
27 if (CORBA::is_nil(name_context)) {
28 MESSAGE("NOTIFICATION Error : failed to obtain context for NameService");
31 } catch(CORBA::ORB::InvalidName& ex) {
32 MESSAGE("NOTIFICATION Error : service required is invalid [does not exist]");
34 } catch (CORBA::COMM_FAILURE& ex) {
35 MESSAGE("NOTIFICATION Error : caught system exception COMM_FAILURE");
38 MESSAGE("NOTIFICATION Error : caught exception while resolving the naming service");
43 name[0].id = CORBA::string_dup((const char*)NOTIFICATION_ChannelName);
44 name[0].kind = CORBA::string_dup((const char*)NOTIFICATION_ChannelName);
47 CORBA::Object_var channel_ref = name_context->resolve(name);
48 channel = CosNA_EventChannel::_narrow(channel_ref);
49 if (CORBA::is_nil(channel)) {
50 MESSAGE("NOTIFICATION Error : failed to narrow object found in naming service");
52 } catch(CORBA::ORB::InvalidName& ex) {
53 MESSAGE("NOTIFICATION Error : invalid name");
54 } catch (CORBA::COMM_FAILURE& ex) {
55 MESSAGE("NOTIFICATION Error : caught system exception COMM_FAILURE while resolving event channel name");
57 MESSAGE("NOTIFICATION Error : caught exception while resolving event channel name");
66 static char JourSemaine[7][4] = {"Sun", "Mon", "Tue", "Wed", "Thu" , "Fri", "Sat"};
68 static char Mois[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
70 static char NOTIFICATION_DATE[50];
72 char* NOTIFICATION_date() {
75 struct tm* temps = localtime(&aTime);
77 sprintf(NOTIFICATION_DATE, "%4d %3d %3s %2d %3s %02d:%02d:%02d", 1900+temps->tm_year, temps->tm_mon+1, Mois[temps->tm_mon], temps->tm_mday, JourSemaine[temps->tm_wday], temps->tm_hour, temps->tm_min, temps->tm_sec);
79 return(NOTIFICATION_DATE);