TizenRefApp-7735 Files are not shared via Messages on Emulator 85/105385/3 submit/tizen_3.0/20161216.124609 submit/tizen_3.0/20161221.121652
authorDenis Dolzhenko <d.dolzhenko@samsung.com>
Wed, 30 Nov 2016 11:40:37 +0000 (13:40 +0200)
committerDenis Dolzhenko <d.dolzhenko@samsung.com>
Fri, 16 Dec 2016 10:52:07 +0000 (12:52 +0200)
Change-Id: Ie0bc34e1b6dc979c6ef8f3e4ec9c87c9f196c75f
Signed-off-by: Denis Dolzhenko <d.dolzhenko@samsung.com>
src/Conversation/Utils/inc/AttachmentHandler.h
src/Conversation/Utils/src/AttachmentHandler.cpp

index 882db8e..27d6682 100644 (file)
@@ -23,6 +23,7 @@
 #include <condition_variable>
 #include <string>
 #include <atomic>
+#include <Eina.h>
 #include "WorkingDir.h"
 
 namespace Msg
@@ -48,12 +49,15 @@ namespace Msg
             static void *safeCallOnFileReady(void *data);
             static void *safeCallOnFileFails(void *data);
 
+            static void *on_routine_cb(void *data, Eina_Thread t);
             void onRoutine();
+
         private:
             IAttachmentHandlerListener *m_pListener;
             WorkingDirRef m_WorkingDir;
             std::string m_CurrentFile;
-            std::thread m_Thread;
+            Eina_Thread m_Thread;
+            bool m_ThreadCreated;
             long long m_CurrentFreeSpace;
             mutable std::mutex m_Mutex;
             std::condition_variable m_Condition;
index ea646fd..6700614 100644 (file)
@@ -27,22 +27,39 @@ using namespace Msg;
 AttachmentHandler::AttachmentHandler(WorkingDirRef workingDir)
     : m_pListener(nullptr)
     , m_WorkingDir(workingDir)
+    , m_Thread()
+    , m_ThreadCreated(false)
     , m_NeedTerminate(false)
 {
+
 }
 
 AttachmentHandler::~AttachmentHandler()
 {
     m_NeedTerminate = true;
     m_Condition.notify_one();
-    if (m_Thread.joinable())
-        m_Thread.join();
+
+    if (m_ThreadCreated)
+        eina_thread_join(m_Thread);
+    m_ThreadCreated = false;
 }
 
 void AttachmentHandler::processFile(const std::string &file)
 {
-    if (!m_Thread.joinable())
-        m_Thread = std::thread(&AttachmentHandler::onRoutine, this);
+    if (!m_ThreadCreated)
+    {
+        if (eina_thread_create(&m_Thread, EINA_THREAD_NORMAL, 0, on_routine_cb, this))
+        {
+            m_ThreadCreated = true;
+        } else {
+            if(m_pListener)
+                m_pListener->onFileFails();
+        }
+    }
+
+    // TODO: revert this code (eina_thread), when C++11 will work on Emulator, JIRA: SDKRM-1187
+    /*if (!m_Thread.joinable())
+        m_Thread = std::thread(&AttachmentHandler::onRoutine, this);*/
 
     std::unique_lock<std::mutex> _lock(m_Mutex);
     m_Task.push(file);
@@ -79,6 +96,12 @@ void *AttachmentHandler::safeCallOnFileFails(void *data)
     return nullptr;
 }
 
+void *AttachmentHandler::on_routine_cb(void *data, Eina_Thread t)
+{
+    ((AttachmentHandler*)data)->onRoutine();
+    return nullptr;
+}
+
 void AttachmentHandler::onRoutine()
 {
     while (!m_NeedTerminate)