tizen 2.4 release
[framework/web/wrt-commons.git] / examples / fake_rpc / fake_rpc.cpp
index bab1069..62d16c9 100644 (file)
@@ -29,7 +29,7 @@
 #include <dpl/application.h>
 #include <dpl/controller.h>
 #include <dpl/thread.h>
-#include <dpl/log/log.h>
+#include <dpl/log/wrt_log.h>
 #include <string>
 
 // FLOW:
@@ -67,27 +67,27 @@ private:
 
     virtual void OnEventReceived(const AsyncCallEvent &event)
     {
-        LogDebug("CLIENT: AsyncCallEvent received");
+        WrtLogD("CLIENT: AsyncCallEvent received");
 
         event.GetArg0().ConsumeArg(m_receivedData);
-        LogDebug("CLIENT: Result from server: " << m_receivedData);
+        WrtLogD("CLIENT: Result from server: %i", m_receivedData);
 
         if (m_receivedData != m_sentData)
-            LogError("Wrong data Received!");
+            WrtLogE("Wrong data Received!");
     }
 
     virtual void OnEventReceived(const ConnectionEstablishedEvent &event)
     {
         if (dynamic_cast<DPL::FakeRpcConnection *>(event.GetArg1())){
             ++m_connections;
-            LogDebug("CLIENT: Acquiring new fake connection");
+            WrtLogD("CLIENT: Acquiring new fake connection");
             m_rpcFakeConnection.reset(event.GetArg1());
             //this is not used on this side
 //            m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
         }
         else{
             ++m_connections;
-            LogDebug("CLIENT: Acquiring new unix connection");
+            WrtLogD("CLIENT: Acquiring new unix connection");
             m_rpcUnixConnection.reset(event.GetArg1());
             m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
         }
@@ -96,7 +96,7 @@ private:
             // Emit RPC function call
             DPL::RPCFunction proc;
             proc.AppendArg(m_sentData);
-            LogDebug("CLIENT: Calling RPC function");
+            WrtLogD("CLIENT: Calling RPC function");
             m_rpcFakeConnection->AsyncCall(proc);
         }
     }
@@ -120,41 +120,41 @@ public:
     {
         m_connections = 0;
         // Attach RPC listeners
-        LogDebug("CLIENT: Attaching connection established event");
+        WrtLogD("CLIENT: Attaching connection established event");
         m_rpcUnixClient.DPL::EventSupport<ConnectionEstablishedEvent>::AddListener(this);
         m_rpcFakeClient.DPL::EventSupport<ConnectionEstablishedEvent>::AddListener(this);
 
         // Open connection to server
-        LogDebug("CLIENT: Opening connection to RPC");
+        WrtLogD("CLIENT: Opening connection to RPC");
         m_rpcUnixClient.Open(UNIX_RPC_NAME);
         m_rpcFakeClient.Open(FAKE_RPC_NAME);
 
         // Start message loop
-        LogDebug("CLIENT: Starting thread event loop");
+        WrtLogD("CLIENT: Starting thread event loop");
         int ret = Exec();
 
         if (m_rpcUnixConnection.get()){
-            LogDebug("CLIENT: Removing Unix connection");
+            WrtLogD("CLIENT: Removing Unix connection");
             m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
             m_rpcUnixConnection.reset();
         }
 
-        LogDebug("CLIENT: Closing");
+        WrtLogD("CLIENT: Closing");
 
         if (m_rpcFakeConnection.get()){
-            LogDebug("CLIENT: Removing Fake connection");
+            WrtLogD("CLIENT: Removing Fake connection");
             //this is not used on this side
 //            m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::RemoveListener(this);
             m_rpcFakeConnection.reset();
         }
 
         // Detach RPC client listener
-        LogDebug("CLIENT: Detaching connection established event");
+        WrtLogD("CLIENT: Detaching connection established event");
         m_rpcUnixClient.DPL::EventSupport<ConnectionEstablishedEvent>::RemoveListener(this);
         m_rpcFakeClient.DPL::EventSupport<ConnectionEstablishedEvent>::RemoveListener(this);
 
         // Close RPC
-        LogDebug("CLIENT: Closing RPC client");
+        WrtLogD("CLIENT: Closing RPC client");
         m_rpcUnixClient.CloseAll();
         m_rpcFakeClient.Close();//not needed
 
@@ -185,7 +185,7 @@ private:
     // Quit application event occurred
     virtual void OnEventReceived(const QuitEvent &/*event*/){
         // Close RPC now
-        LogDebug("SERVER: Closing RPC connection...");
+        WrtLogD("SERVER: Closing RPC connection...");
 
         // Detach RPC connection listeners
         if (m_rpcUnixConnection.get()) {
@@ -199,13 +199,13 @@ private:
             m_rpcFakeConnection.reset();
         }
 
-        LogDebug("SERVER: Closing Server");
+        WrtLogD("SERVER: Closing Server");
         m_rpcUnixServer.CloseAll();
         m_rpcFakeServer.CloseAll();//not needed
         m_rpcUnixServer.DPL::EventSupport<ConnectionEstablishedEvent>::RemoveListener(this);
         m_rpcFakeServer.DPL::EventSupport<ConnectionEstablishedEvent>::RemoveListener(this);
 
-        LogDebug("SERVER: Server closed");
+        WrtLogD("SERVER: Server closed");
 
         Quit();
     }
@@ -216,17 +216,17 @@ private:
 
     virtual void OnEventReceived(const AsyncCallEvent &event)
     {
-        LogDebug("SERVER: AsyncCallEvent received");
+        WrtLogD("SERVER: AsyncCallEvent received");
 
         int value;
         event.GetArg0().ConsumeArg(value);
-        LogDebug("SERVER: Result from client: " << value);
+        WrtLogD("SERVER: Result from client: %i", value);
 
         // send back data to client (via fake)
         // Emit RPC function call
         DPL::RPCFunction proc;
         proc.AppendArg(value);
-        LogDebug("SERVER: Calling RPC function");
+        WrtLogD("SERVER: Calling RPC function");
         m_rpcUnixConnection->AsyncCall(proc);
     }
 
@@ -234,12 +234,12 @@ private:
     {
         // Save connection pointer
         if (dynamic_cast<DPL::FakeRpcConnection *>(event.GetArg1())){
-            LogDebug("SERVER: Acquiring Fake RPC connection");
+            WrtLogD("SERVER: Acquiring Fake RPC connection");
             m_rpcFakeConnection.reset(event.GetArg1());
             m_rpcFakeConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
         }
         else{
-            LogDebug("SERVER: Acquiring Unix RPC connection");
+            WrtLogD("SERVER: Acquiring Unix RPC connection");
             m_rpcUnixConnection.reset(event.GetArg1());
             //this is not used on this side
 //            m_rpcUnixConnection->DPL::EventSupport<AsyncCallEvent>::AddListener(this);
@@ -251,25 +251,25 @@ public:
         : Application(argc, argv, "rpc")
     {
         // Attach RPC server listeners
-        LogDebug("SERVER: Attaching connection established event");
+        WrtLogD("SERVER: Attaching connection established event");
         m_rpcUnixServer.DPL::EventSupport<ConnectionEstablishedEvent>::AddListener(this);
         m_rpcFakeServer.DPL::EventSupport<ConnectionEstablishedEvent>::AddListener(this);
 
         // Self touch
-        LogDebug("SERVER: Touching controller");
+        WrtLogD("SERVER: Touching controller");
         Touch();
 
         // Open RPC server
-        LogDebug("SERVER: Opening server RPC");
+        WrtLogD("SERVER: Opening server RPC");
         m_rpcUnixServer.Open(UNIX_RPC_NAME);
         m_rpcFakeServer.Open(FAKE_RPC_NAME);
 
         // Run RPC client in thread
-        LogDebug("SERVER: Starting RPC client thread");
+        WrtLogD("SERVER: Starting RPC client thread");
         m_thread.Run();
 
         // Quit application automatically in few seconds
-        LogDebug("SERVER: Sending control timed events");
+        WrtLogD("SERVER: Sending control timed events");
         DPL::ControllerEventHandler<CloseThreadEvent>::PostTimedEvent(CloseThreadEvent(), 2);
         DPL::ControllerEventHandler<QuitEvent>::PostTimedEvent(QuitEvent(), 3);
     }
@@ -277,13 +277,13 @@ public:
     virtual ~MyApplication()
     {
         // Quit thread
-        LogDebug("SERVER: Quitting thread");
+        WrtLogD("SERVER: Quitting thread");
     }
 };
 
 int main(int argc, char *argv[])
 {
-    LogDebug("Starting");
+    WrtLogD("Starting");
     MyApplication app(argc, argv);
     return app.Exec();
 }