OSSP CVS Repository

ossp - Difference in ossp-pkg/as/as-gui/as_slot.cpp versions 1.77 and 1.78
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/as/as-gui/as_slot.cpp 1.77 -> 1.78

--- as_slot.cpp  2003/01/16 08:32:31     1.77
+++ as_slot.cpp  2003/01/16 08:37:40     1.78
@@ -38,6 +38,8 @@
 
 // RPC headers
 #include <easysoap/SOAP.h>
+#include <coss/CosNaming.h>
+#include "asdb.h"               // CORBA stubs and skeletons
 
 // User interface
 #include "as_gui.h"             // Main classes
@@ -1154,8 +1156,86 @@
 //
 void Titraqform::syncIiop(void)
 {
-    Prototype Unimp;
-    Unimp.doMbox();
+    int nNada = 0;          // Some false parameters
+    char **ppcNada = NULL;  // to fake out the ORB
+    CORBA::ORB_var Orb;     // The ORB
+
+    CORBA::Object_var Nameobj;      // Name service reference
+    CosNaming::NamingContext_var Namectx; // COSS ns context
+    CosNaming::Name Cosname;        // Our requested obj name
+
+    CORBA::Object_var Objcaster;    // Generic CORBA object
+    Asdatabase_var Asdbase;         // Casted object to ASDB
+    Astuple Singlerow;              // A single row of AS data
+
+    try {
+        // Initialization of the ORB and COSS naming service
+        Orb = CORBA::ORB_init(nNada, ppcNada, "mico-local-orb");
+        Nameobj = Orb->resolve_initial_references("NameService");
+        Namectx = CosNaming::NamingContext::_narrow(Nameobj);
+        if (CORBA::is_nil(Namectx)) { // Verify sanity
+            m_pStatbar->message(trUtf8("Could not find the COSS naming service"));
+            qWarning("Could not find the COSS naming service\n");
+        }
+
+        // Prepare the COSS name request
+        Cosname.length(1);
+        Cosname[0].id = CORBA::string_dup("Asdatabase");
+        Cosname[0].kind = CORBA::string_dup("");
+
+        try { // Resolve to a CORBA object
+            Objcaster = Namectx->resolve(Cosname);
+        }
+        catch (CosNaming::NamingContext::NotFound &Cossex) {
+            m_pStatbar->message(trUtf8("NotFound exception thrown"));
+            qWarning("NotFound exception thrown\n");
+            return;
+        }
+        catch (CosNaming::NamingContext::CannotProceed &Cossex) {
+            m_pStatbar->message(trUtf8("CannotProceed exception thrown"));
+            qWarning("CannotProceed exception thrown\n");
+            return;
+        }
+        catch (CosNaming::NamingContext::InvalidName &Cossex) {
+            m_pStatbar->message(trUtf8("InvalidName exception thrown"));
+            qWarning("InvalidName exception thrown\n");
+            return;
+        }
+
+        // Cast the generic CORBA object to a AS database type
+        Asdbase = Asdatabase::_narrow(Objcaster);
+        if (CORBA::is_nil(Asdbase)) { // Verify sanity
+            m_pStatbar->message(trUtf8("Could not find the AS database"));
+            qWarning("Could not find the AS database\n");
+            return;
+        }
+
+        // Open an account object on the remote server
+        Account_var Account = Asdbase->Open("/tmp/corbadb.txt"); // Security problem!
+        if (CORBA::is_nil(Account)) { // Verify sanity
+            m_pStatbar->message(trUtf8("Could not create an account object on the server"));
+            qWarning("Could not create an account object on the server\n");
+            return;
+        }
+
+        // Fill an account object to marshall and transmit
+        int nLastrow = m_pMaintable->numRows() - 1;
+        Singlerow.nDate = m_pMaintable->text(nLastrow, TITRAQ_IDXDATE).toInt();
+        Singlerow.nTime = m_pMaintable->text(nLastrow, TITRAQ_IDXSTART).toInt();
+        Singlerow.szName = CORBA::string_dup(m_pMaintable->text(nLastrow, TITRAQ_IDXUSER));
+        Singlerow.szTask = CORBA::string_dup(m_pMaintable->text(nLastrow, TITRAQ_IDXTASK));
+        Singlerow.szRemark = CORBA::string_dup(m_pMaintable->text(nLastrow, TITRAQ_IDXREMARK));
+
+        Account->Log(Singlerow); // Finally transmit to server
+        m_pStatbar->message(trUtf8("Successful transmission of accounting data"));
+    }
+    catch (const CORBA::Exception &Corbex) {
+        m_pStatbar->message(trUtf8("Caught CORBA exception: %1").arg(Corbex._repoid()));
+        qWarning("Caught CORBA exception: %s\n", Corbex._repoid());
+    }
+    catch (...) {
+        qWarning("Caught unknown exception\n");
+    }
 }
 
 //
@@ -1190,6 +1270,9 @@
         m_pStatbar->message(trUtf8("Caught SOAP exception: %1").arg(Soapex.What().Str()));
         qDebug("Caught SOAP exception: %s\n", Soapex.What().Str());
     }
+    catch (...) {
+        qDebug("Caught unknown exception\n");
+    }
 }
 
 //

CVSTrac 2.0.1