Fix Coverity issues
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / clipboard-impl-ecore-wl.cpp
index f913814..68a10e5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -19,6 +19,9 @@
 #include "clipboard-impl.h"
 
 // EXTERNAL INCLUDES
+// Ecore is littered with C style cast
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
 #include <Ecore.h>
 #include <Ecore_Wayland.h>
 #include <dali/public-api/object/any.h>
@@ -37,8 +40,7 @@
 #ifndef CBHM_DBUS_INTERFACE
 #define CBHM_DBUS_INTERFACE "org.tizen.cbhm.dbus"
 #endif /* CBHM_DBUS_INTERFACE */
-
-#define CLIPBOARD_STR  "CLIPBOARD_STR"
+#define CBHM_COUNT_ALL 0    // ATOM_INDEX_CBHM_COUNT_ALL
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // Clipboard
@@ -97,8 +99,6 @@ struct Clipboard::Impl
     // ELM_SEL_TYPE_CLIPBOARD - To distinguish clipboard selection in cbhm
     types[++i] = "CLIPBOARD_BEGIN";
 
-    types[++i] = "application/x-elementary-markup";
-    types[++i] = "text/plain";
     types[++i] = "text/plain;charset=utf-8";
 
     // ELM_SEL_TYPE_CLIPBOARD - To distinguish clipboard selection in cbhm
@@ -111,8 +111,6 @@ struct Clipboard::Impl
     const char *types[10] = {0, };
     int i = -1;
 
-    types[++i] = "application/x-elementary-markup";
-    types[++i] = "text/plain";
     types[++i] = "text/plain;charset=utf-8";
     ecore_wl_dnd_selection_get(ecore_wl_input_get(), *types);
   }
@@ -157,12 +155,17 @@ struct Clipboard::Impl
     }
 
     eldbus_message_ref(req);
+    eldbus_message_arguments_append(req, "i", CBHM_COUNT_ALL) ;
     reply = eldbus_proxy_send_and_block(eldbus_proxy, req, 100);
     if (!reply || eldbus_message_error_get(reply, &errname, &errmsg))
     {
       DALI_LOG_ERROR("Unable to call method org.freedesktop.DBus.Properties.Get: %s %s",
       errname, errmsg);
       eldbus_message_unref(req);
+      if( reply )
+      {
+        eldbus_message_unref(reply);
+      }
       return -1;
     }
 
@@ -170,10 +173,12 @@ struct Clipboard::Impl
     {
       DALI_LOG_ERROR("Cannot get arguments from eldbus");
       eldbus_message_unref(req);
+      eldbus_message_unref(reply);
       return -1;
     }
 
     eldbus_message_unref(req);
+    eldbus_message_unref(reply);
     DALI_LOG_ERROR("cbhm item count(%d)", count);
     return count;
   }
@@ -222,6 +227,7 @@ Clipboard::Clipboard(Impl* impl)
 
 Clipboard::~Clipboard()
 {
+  delete mImpl;
 }
 
 Dali::Clipboard Clipboard::Get()
@@ -296,3 +302,5 @@ char* Clipboard::ExcuteBuffered( bool type, void *event )
 } // namespace Internal
 
 } // namespace Dali
+
+#pragma GCC diagnostic pop