summaryrefslogtreecommitdiff
path: root/dali
diff options
context:
space:
mode:
authorBowon Ryu <bowon.ryu@samsung.com>2024-04-18 16:46:14 +0900
committerBowon Ryu <bowon.ryu@samsung.com>2024-04-22 12:16:23 +0900
commitab3aafe1a7c5651e6907a42fca1fb796b7b441ca (patch)
tree50b250e4126765d9613e346e69677f76c5cc3f9a /dali
parentac7f2f1a39d57e35be3b3ff9e5664f663594ed30 (diff)
downloaddali-adaptor-ab3aafe1a7c5651e6907a42fca1fb796b7b441ca.tar.gz
dali-adaptor-ab3aafe1a7c5651e6907a42fca1fb796b7b441ca.tar.bz2
dali-adaptor-ab3aafe1a7c5651e6907a42fca1fb796b7b441ca.zip
Add HasType to Clipboard
Change-Id: Ifeeb380f8da7d24f2febdc5f271d10d7bdafd52a Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
Diffstat (limited to 'dali')
-rw-r--r--dali/devel-api/adaptor-framework/clipboard.cpp5
-rw-r--r--dali/devel-api/adaptor-framework/clipboard.h7
-rw-r--r--dali/internal/clipboard/common/clipboard-impl.h9
-rw-r--r--dali/internal/clipboard/generic/clipboard-impl-generic.cpp5
-rw-r--r--dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp35
-rw-r--r--dali/internal/clipboard/ubuntu-x11/clipboard-impl-x.cpp14
6 files changed, 71 insertions, 4 deletions
diff --git a/dali/devel-api/adaptor-framework/clipboard.cpp b/dali/devel-api/adaptor-framework/clipboard.cpp
index e69c0a761..a070d003e 100644
--- a/dali/devel-api/adaptor-framework/clipboard.cpp
+++ b/dali/devel-api/adaptor-framework/clipboard.cpp
@@ -61,6 +61,11 @@ Clipboard::DataSelectedSignalType& Clipboard::DataSelectedSignal()
return GetImplementation(*this).DataSelectedSignal();
}
+bool Clipboard::HasType(const std::string& mimeType)
+{
+ return GetImplementation(*this).HasType(mimeType);
+}
+
bool Clipboard::SetData(const ClipData& clipData)
{
return GetImplementation(*this).SetData(clipData);
diff --git a/dali/devel-api/adaptor-framework/clipboard.h b/dali/devel-api/adaptor-framework/clipboard.h
index 3096b2de4..707b936e3 100644
--- a/dali/devel-api/adaptor-framework/clipboard.h
+++ b/dali/devel-api/adaptor-framework/clipboard.h
@@ -139,6 +139,13 @@ public:
DataSelectedSignalType& DataSelectedSignal();
/**
+ * @brief Check if there is data in the clipboard with a given mime type.
+ * @param[in] mimeType mime type to search for.
+ * @return bool true if there is data, otherwise false.
+ */
+ bool HasType(const std::string& mimeType);
+
+ /**
* @brief Send the given data to the clipboard.
* @param[in] clipData data to send to the clipboard
* @return bool true if the internal clipboard sending was successful.
diff --git a/dali/internal/clipboard/common/clipboard-impl.h b/dali/internal/clipboard/common/clipboard-impl.h
index d4e36c169..cf508ea36 100644
--- a/dali/internal/clipboard/common/clipboard-impl.h
+++ b/dali/internal/clipboard/common/clipboard-impl.h
@@ -35,6 +35,10 @@ namespace Adaptor
*/
class Clipboard : public Dali::BaseObject, public ConnectionTracker
{
+const char* MIME_TYPE_TEXT_PLAIN = "text/plain;charset=utf-8";
+const char* MIME_TYPE_HTML = "application/xhtml+xml";
+const char* MIME_TYPE_TEXT_URI = "text/uri-list";
+
public:
struct Impl;
@@ -75,6 +79,11 @@ public:
Dali::Clipboard::DataSelectedSignalType& DataSelectedSignal();
/**
+ * @copydoc Dali::Clipboard::HasType()
+ */
+ bool HasType(const std::string& mimeType);
+
+ /**
* @copydoc Dali::Clipboard::SetData()
*/
bool SetData(const Dali::Clipboard::ClipData& clipData);
diff --git a/dali/internal/clipboard/generic/clipboard-impl-generic.cpp b/dali/internal/clipboard/generic/clipboard-impl-generic.cpp
index c4bef697e..ce788bd87 100644
--- a/dali/internal/clipboard/generic/clipboard-impl-generic.cpp
+++ b/dali/internal/clipboard/generic/clipboard-impl-generic.cpp
@@ -97,6 +97,11 @@ Dali::Clipboard::DataSelectedSignalType& Clipboard::DataSelectedSignal()
return mImpl->mDataSelectedSignal;
}
+bool Clipboard::HasType(const std::string& mimeType)
+{
+ return true;
+}
+
bool Clipboard::SetData(const Dali::Clipboard::ClipData& clipData)
{
return true;
diff --git a/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp b/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp
index fdd365716..0dc294958 100644
--- a/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp
+++ b/dali/internal/clipboard/tizen-wayland/clipboard-impl-ecore-wl.cpp
@@ -50,6 +50,32 @@ struct Clipboard::Impl
ecore_event_handler_del(mSelectionHanlder);
}
+ bool HasType(const std::string& mimeType)
+ {
+ Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
+ Ecore_Wl2_Input* input = ecore_wl2_input_default_input_get(display);
+ Ecore_Wl2_Offer* offer = ecore_wl2_dnd_selection_get(input);
+
+ if(!offer)
+ {
+ DALI_LOG_ERROR("selection_get fail, request type:%s\n", mimeType.c_str());
+ return false;
+ }
+
+ Eina_Array* availableTypes = ecore_wl2_offer_mimes_get(offer);
+ unsigned int typeCount = (unsigned int)eina_array_count((Eina_Array *)availableTypes);
+
+ for(unsigned int i = 0; i < typeCount; ++i)
+ {
+ char* availableType = (char*)eina_array_data_get((Eina_Array *)availableTypes, i);
+ if(!mimeType.compare(availableType))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
bool SetData(const Dali::Clipboard::ClipData& clipData)
{
mMimeType = clipData.GetMimeType();
@@ -395,6 +421,11 @@ Dali::Clipboard::DataSelectedSignalType& Clipboard::DataSelectedSignal()
return mImpl->mDataSelectedSignal;
}
+bool Clipboard::HasType(const std::string& mimeType)
+{
+ return mImpl->HasType(mimeType);
+}
+
bool Clipboard::SetData(const Dali::Clipboard::ClipData& clipData)
{
return mImpl->SetData(clipData);
@@ -407,8 +438,8 @@ uint32_t Clipboard::GetData(const std::string &mimeType)
size_t Clipboard::NumberOfItems()
{
- // TODO: We should to check if the data is empty in the clipboard service.
- return 1u;
+ bool isItem = HasType(MIME_TYPE_TEXT_PLAIN) || HasType(MIME_TYPE_HTML) || HasType(MIME_TYPE_TEXT_URI);
+ return isItem ? 1u : 0u;
}
void Clipboard::ShowClipboard()
diff --git a/dali/internal/clipboard/ubuntu-x11/clipboard-impl-x.cpp b/dali/internal/clipboard/ubuntu-x11/clipboard-impl-x.cpp
index 2681ea94a..9c15021c3 100644
--- a/dali/internal/clipboard/ubuntu-x11/clipboard-impl-x.cpp
+++ b/dali/internal/clipboard/ubuntu-x11/clipboard-impl-x.cpp
@@ -43,6 +43,11 @@ struct Clipboard::Impl
mApplicationWindow = ecoreXwin;
}
+ bool HasType(const std::string& mimeType)
+ {
+ return mMimeType == mimeType ? true : false;
+ }
+
bool SetData(const Dali::Clipboard::ClipData& clipData)
{
mMimeType = clipData.GetMimeType();
@@ -173,6 +178,11 @@ Dali::Clipboard::DataSelectedSignalType& Clipboard::DataSelectedSignal()
return mImpl->mDataSelectedSignal;
}
+bool Clipboard::HasType(const std::string& mimeType)
+{
+ return mImpl->HasType(mimeType);
+}
+
bool Clipboard::SetData(const Dali::Clipboard::ClipData& clipData)
{
return mImpl->SetData(clipData);
@@ -185,8 +195,8 @@ uint32_t Clipboard::GetData(const std::string &mimeType)
size_t Clipboard::NumberOfItems()
{
- // TODO: We should to check if the data is empty in the clipboard service.
- return 1u;
+ bool isItem = HasType(MIME_TYPE_TEXT_PLAIN) || HasType(MIME_TYPE_HTML) || HasType(MIME_TYPE_TEXT_URI);
+ return isItem ? 1u : 0u;
}
void Clipboard::ShowClipboard()