Salome HOME
Porting to OCCT 7.8.0
[modules/kernel.git] / src / Notification / NOTIFICATION.cxx
index 1058d706edc3bfa88b84d54984ff83c7b79413e5..73a0fc6a1d5288cfa08e66b34c157a3e13614ae7 100644 (file)
@@ -1,40 +1,36 @@
-//  SALOME Notification : wrapping of Notification service services
+// Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  SALOME Notification : wrapping of Notification service services
 //  File   : NOTIFICATION.cxx
 //  Author : Laurent DADA / Francis KLOSS
 //  Module : SALOME
-
-using namespace std;
+//
 #include "NOTIFICATION.hxx"
 
-using namespace std;
-#include "Utils_ORB_INIT.hxx"
-#include "Utils_SINGLETON.hxx"
+#include "OpUtil.hxx"
 
 CosNA_EventChannel_ptr NOTIFICATION_channel() {
-    ORB_INIT&      init = *SINGLETON_<ORB_INIT>::Instance(); ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
-    CORBA::ORB_ptr orb  = init(0, 0);
+    CORBA::ORB_ptr orb  = KERNEL::GetRefToORB();
 
     CosNA_EventChannel_ptr       channel = CosNA_EventChannel::_nil();
     CosNaming::NamingContext_var name_context;
@@ -48,10 +44,10 @@ CosNA_EventChannel_ptr NOTIFICATION_channel() {
             MESSAGE("NOTIFICATION Error : failed to obtain context for NameService");
             return(channel);
         };
-    } catch(CORBA::ORB::InvalidName& ex) {
+    } catch(CORBA::ORB::InvalidName& ) {
         MESSAGE("NOTIFICATION Error : service required is invalid [does not exist]");
         return(channel);
-    } catch (CORBA::COMM_FAILURE& ex) {
+    } catch (CORBA::SystemException& ) {
         MESSAGE("NOTIFICATION Error : caught system exception COMM_FAILURE");
         return(channel);
     } catch (...) {
@@ -69,9 +65,9 @@ CosNA_EventChannel_ptr NOTIFICATION_channel() {
         if (CORBA::is_nil(channel)) {
             MESSAGE("NOTIFICATION Error : failed to narrow object found in naming service");
         };
-    } catch(CORBA::ORB::InvalidName& ex) {
+    } catch(CORBA::ORB::InvalidName& ) {
         MESSAGE("NOTIFICATION Error : invalid name");
-    } catch (CORBA::COMM_FAILURE& ex) {
+    } catch (CORBA::SystemException& ) {
         MESSAGE("NOTIFICATION Error : caught system exception COMM_FAILURE while resolving event channel name");
     } catch (...) {
         MESSAGE("NOTIFICATION Error : caught exception while resolving event channel name");
@@ -90,11 +86,16 @@ static char Mois[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug
 static char NOTIFICATION_DATE[50];
 
 char* NOTIFICATION_date() {
+#ifndef WIN32
     time_t aTime;
     time(&aTime);
     struct tm* temps = localtime(&aTime);
 
     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);
-
+#else 
+       SYSTEMTIME    st;
+       GetLocalTime(&st);
+       sprintf(NOTIFICATION_DATE, "%4d %3d %3s %2d %3s %02d:%02d:%02d", st.wYear, st.wMonth, Mois[st.wMonth-1], st.wDay, JourSemaine[st.wDay], st.wHour, st.wMinute, st.wSecond);
+#endif
     return(NOTIFICATION_DATE);
 }