Merge "Use existing callback ID for recurring callbacks" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / clipboard / tizen-wayland / clipboard-impl-ecore-wl.cpp
old mode 100644 (file)
new mode 100755 (executable)
index 821a730..52b18d6
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
 
 // CLASS HEADER
 #include <dali/internal/clipboard/common/clipboard-impl.h>
+#include <dali/devel-api/adaptor-framework/clipboard-event-notifier.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/internal/system/linux/dali-ecore.h>
+
+#ifdef ECORE_WAYLAND2
+#include <dali/internal/adaptor/tizen-wayland/dali-ecore-wl2.h>
+#else
+#include <dali/internal/adaptor/tizen-wayland/dali-ecore-wayland.h>
+#endif
+
 #include <dali/public-api/object/any.h>
 #include <dali/public-api/object/type-registry.h>
+#include <dali/devel-api/common/singleton-service.h>
 #include <dali/integration-api/debug.h>
 #include <unistd.h>
 
@@ -33,9 +38,6 @@
 #include <Eldbus.h>
 #endif // DALI_ELDBUS_AVAILABLE
 
-// INTERNAL INCLUDES
-#include <dali/internal/system/common/singleton-service-impl.h>
-
 #define CBHM_DBUS_OBJPATH "/org/tizen/cbhm/dbus"
 #ifndef CBHM_DBUS_INTERFACE
 #define CBHM_DBUS_INTERFACE "org.tizen.cbhm.dbus"
@@ -60,6 +62,7 @@ struct Clipboard::Impl
   Impl()
   {
     Eldbus_Object *eldbus_obj;
+    eldbus_init();
     cbhm_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
     eldbus_obj = eldbus_object_get(cbhm_conn, CBHM_DBUS_INTERFACE, CBHM_DBUS_OBJPATH);
     eldbus_proxy = eldbus_proxy_get(eldbus_obj, CBHM_DBUS_INTERFACE);
@@ -73,6 +76,7 @@ struct Clipboard::Impl
   {
     if (cbhm_conn)
       eldbus_connection_unref(cbhm_conn);
+    eldbus_shutdown();
   }
 
   Eldbus_Proxy* cbhm_proxy_get()
@@ -103,21 +107,44 @@ struct Clipboard::Impl
 
     // ELM_SEL_TYPE_CLIPBOARD - To distinguish clipboard selection in cbhm
     types[++i] = "CLIPBOARD_END";
-    ecore_wl_dnd_selection_set(ecore_wl_input_get(), types);
+
+#ifdef ECORE_WAYLAND2
+    Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get( ecore_wl2_connected_display_get( NULL ) );
+    ecore_wl2_dnd_selection_set( input, types );
+#else
+    ecore_wl_dnd_selection_set( ecore_wl_input_get(), types );
+#endif
   }
 
   void RequestItem()
   {
+#ifdef ECORE_WAYLAND2
+    Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get( ecore_wl2_connected_display_get( NULL ) );
+    ecore_wl2_dnd_selection_get( input );
+#else
     const char *types[10] = {0, };
     int i = -1;
 
     types[++i] = "text/plain;charset=utf-8";
     ecore_wl_dnd_selection_get(ecore_wl_input_get(), *types);
+#endif
+
+    Dali::ClipboardEventNotifier clipboardEventNotifier(Dali::ClipboardEventNotifier::Get());
+    if ( clipboardEventNotifier )
+    {
+      clipboardEventNotifier.SetContent( mSendBuffer );
+      clipboardEventNotifier.EmitContentSelectedSignal();
+    }
   }
 
   char *ExcuteSend( void *event )
   {
-    Ecore_Wl_Event_Data_Source_Send *ev = (Ecore_Wl_Event_Data_Source_Send *)event;
+#ifdef ECORE_WAYLAND2
+    Ecore_Wl2_Event_Data_Source_Send *ev = reinterpret_cast<Ecore_Wl2_Event_Data_Source_Send *>( event );
+#else
+    Ecore_Wl_Event_Data_Source_Send *ev = reinterpret_cast<Ecore_Wl_Event_Data_Source_Send *>( event );
+#endif
+
     int len_buf = mSendBuffer.length();
     int len_remained = len_buf;
     int len_written = 0, ret;
@@ -137,9 +164,13 @@ struct Clipboard::Impl
 
   char *ExcuteReceive( void *event )
   {
-    Ecore_Wl_Event_Selection_Data_Ready *ev = (Ecore_Wl_Event_Selection_Data_Ready *)event;
+#ifdef ECORE_WAYLAND2
+    Ecore_Wl2_Event_Selection_Data_Ready *ev = reinterpret_cast<Ecore_Wl2_Event_Selection_Data_Ready *>( event );
+#else
+    Ecore_Wl_Event_Selection_Data_Ready *ev = reinterpret_cast<Ecore_Wl_Event_Selection_Data_Ready *>( event );
+#endif
 
-    return (char *)ev->data;
+    return reinterpret_cast<char *>( ev->data );
   }
 
   int GetCount()
@@ -302,5 +333,3 @@ char* Clipboard::ExcuteBuffered( bool type, void *event )
 } // namespace Internal
 
 } // namespace Dali
-
-#pragma GCC diagnostic pop