tizen 2.4 release
[framework/web/wrt-commons.git] / examples / tcpsock / tcpsock.cpp
index 57141ca..6af7ab1 100644 (file)
  * @brief       This file is the implementation file of tcpsock example
  */
 #include <stddef.h>
+#include <memory>
 #include <dpl/tcp_socket.h>
 #include <dpl/abstract_socket.h>
 #include <dpl/application.h>
 #include <dpl/generic_event.h>
 #include <dpl/binary_queue.h>
-#include <dpl/scoped_array.h>
-#include <dpl/log/log.h>
+#include <dpl/log/wrt_log.h>
 #include <string>
 #include <dpl/assert.h>
 
@@ -41,7 +41,7 @@ private:
     virtual void OnEventReceived(const DPL::AbstractSocketEvents::ConnectedEvent &event)
     {
         (void)event;
-        LogDebug("Connected!");
+        WrtLogD("Connected!");
 
         // Send request
         DPL::BinaryQueue data;
@@ -53,7 +53,7 @@ private:
     virtual void OnEventReceived(const DPL::AbstractSocketEvents::ReadEvent &event)
     {
         (void)event;
-        LogDebug("Read!");
+        WrtLogD("Read!");
 
         DPL::BinaryQueueAutoPtr data = m_socket.Read(100); // Bad: DLOG cannot log more than about 450 bytes...
 
@@ -61,7 +61,7 @@ private:
 
         if (data->Empty())
         {
-            LogDebug("Connection closed!");
+            WrtLogD("Connection closed!");
             m_socket.Close();
 
             // Done
@@ -70,11 +70,11 @@ private:
         }
 
         // Show data
-        DPL::ScopedArray<char> text(new char[data->Size()]);
-        data->Flatten(text.Get(), data->Size());
+        std::unique_ptr<char[]> text(new char[data->Size()]);
+        data->Flatten(text.get(), data->Size());
 
-        LogPedantic("READ: \n--------------------------------------------------------\n"
-                            << std::string(text.Get(), text.Get() + data->Size()) <<
+        WrtLogD("READ: \n--------------------------------------------------------\n"
+                            << std::string(text.Get(), text.get() + data->Size()) <<
                           "\n--------------------------------------------------------");
     }
 
@@ -82,7 +82,7 @@ public:
     MyApplication(int argc, char **argv)
         : Application(argc, argv, "tcpsock")
     {
-        LogDebug("CTOR!");
+        WrtLogD("CTOR!");
 
         // Add listeners
         m_socket.DPL::EventSupport<DPL::AbstractSocketEvents::ConnectedEvent>::AddListener(this);
@@ -90,13 +90,13 @@ public:
 
         // Connect
         m_socket.Open();
-        LogDebug("Connecting...");
+        WrtLogD("Connecting...");
         m_socket.Connect(DPL::Address("en.wikipedia.org", 80));
     }
 
     virtual ~MyApplication()
     {
-        LogDebug("DTOR!");
+        WrtLogD("DTOR!");
 
         // Remove listeners
         m_socket.DPL::EventSupport<DPL::AbstractSocketEvents::ConnectedEvent>::RemoveListener(this);