[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / internal / clipboard / common / clipboard-impl.h
1 #ifndef DALI_INTERNAL_CLIPBOARD_H
2 #define DALI_INTERNAL_CLIPBOARD_H
3
4 /*
5  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/base-object.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/devel-api/adaptor-framework/clipboard.h>
26
27 namespace Dali
28 {
29 namespace Internal
30 {
31 namespace Adaptor
32 {
33 /**
34  * Implementation of the Clipboard
35  */
36 class Clipboard : public Dali::BaseObject, public ConnectionTracker
37 {
38 const char* MIME_TYPE_TEXT_PLAIN = "text/plain;charset=utf-8";
39 const char* MIME_TYPE_HTML       = "application/xhtml+xml";
40 const char* MIME_TYPE_TEXT_URI   = "text/uri-list";
41
42 public:
43   struct Impl;
44
45   /**
46    * @copydoc Dali::Clipboard::Get()
47    */
48   static Dali::Clipboard Get();
49
50   /**
51    * @copydoc Dali::Clipboard::IsAvailable()
52    */
53   static bool IsAvailable();
54
55   /**
56    * Constructor
57    * @param[in] impl Clipboard impl.
58    */
59   Clipboard(Impl* impl);
60
61   /**
62    * Destructor
63    */
64   ~Clipboard() override;
65
66   /**
67    * @copydoc Dali::Clipboard::DataSentSignal()
68    */
69   Dali::Clipboard::DataSentSignalType& DataSentSignal();
70
71   /**
72    * @copydoc Dali::Clipboard::DataReceivedSignal()
73    */
74   Dali::Clipboard::DataReceivedSignalType& DataReceivedSignal();
75
76   /**
77    * @copydoc Dali::Clipboard::DataSelectedSignal()
78    */
79   Dali::Clipboard::DataSelectedSignalType& DataSelectedSignal();
80
81   /**
82    * @copydoc Dali::Clipboard::HasType()
83    */
84   bool HasType(const std::string& mimeType);
85
86   /**
87    * @copydoc Dali::Clipboard::SetData()
88    */
89   bool SetData(const Dali::Clipboard::ClipData& clipData);
90
91   /**
92    * @copydoc Dali::Clipboard::GetData()
93    */
94   uint32_t GetData(const std::string &mimeType);
95
96   /**
97    * @copydoc Dali::Clipboard::NumberOfClipboardItems()
98    */
99   size_t NumberOfItems();
100
101   /**
102    * @copydoc Dali::Clipboard::ShowClipboard()
103    */
104   void ShowClipboard();
105
106   /**
107    * @copydoc Dali::Clipboard::HideClipboard()
108    */
109   void HideClipboard(bool skipFirstHide);
110
111   /**
112   * @copydoc Dali::Clipboard::IsVisible()
113   */
114   bool IsVisible() const;
115
116   /**
117    * This is called after a timeout when no new data event is received for a certain period of time on X.
118    * @return will return false; one-shot timer.
119    */
120   bool OnReceiveData();
121
122 private:
123   // Undefined
124   Clipboard(const Clipboard&);
125   Clipboard& operator=(Clipboard&);
126
127 private:
128   Impl* mImpl;
129
130 public:
131 }; // class Clipboard
132
133 } // namespace Adaptor
134
135 } // namespace Internal
136
137 inline static Internal::Adaptor::Clipboard& GetImplementation(Dali::Clipboard& clipboard)
138 {
139   DALI_ASSERT_ALWAYS(clipboard && "Clipboard handle is empty");
140   BaseObject& handle = clipboard.GetBaseObject();
141   return static_cast<Internal::Adaptor::Clipboard&>(handle);
142 }
143
144 inline static const Internal::Adaptor::Clipboard& GetImplementation(const Dali::Clipboard& clipboard)
145 {
146   DALI_ASSERT_ALWAYS(clipboard && "Clipboard handle is empty");
147   const BaseObject& handle = clipboard.GetBaseObject();
148   return static_cast<const Internal::Adaptor::Clipboard&>(handle);
149 }
150
151 } // namespace Dali
152
153 #endif // DALI_INTERNAL_CLIPBOARD_H