Merge "Add DataSelectedSignal for clipboard" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / clipboard / generic / clipboard-impl-generic.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/clipboard/common/clipboard-impl.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/common/singleton-service.h>
23
24 namespace Dali
25 {
26 namespace Internal
27 {
28 namespace Adaptor
29 {
30 struct Clipboard::Impl
31 {
32   Dali::Clipboard::DataSentSignalType     mDataSentSignal;
33   Dali::Clipboard::DataReceivedSignalType mDataReceivedSignal;
34   Dali::Clipboard::DataSelectedSignalType mDataSelectedSignal;
35 };
36
37 Clipboard::Clipboard(Impl* impl)
38 : mImpl(impl)
39 {
40 }
41
42 Clipboard::~Clipboard()
43 {
44 }
45
46 Dali::Clipboard Clipboard::Get()
47 {
48   Dali::Clipboard clipboard;
49
50   Dali::SingletonService service(SingletonService::Get());
51   if(service)
52   {
53     // Check whether the singleton is already created
54     Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard));
55     if(handle)
56     {
57       // If so, downcast the handle
58       clipboard = Dali::Clipboard(dynamic_cast<Clipboard*>(handle.GetObjectPtr()));
59     }
60     else
61     {
62       Clipboard::Impl* impl(new Clipboard::Impl());
63       clipboard = Dali::Clipboard(new Clipboard(impl));
64       service.Register(typeid(Dali::Clipboard), clipboard);
65     }
66   }
67
68   return clipboard;
69 }
70
71 bool Clipboard::IsAvailable()
72 {
73   Dali::SingletonService service(SingletonService::Get());
74   if(service)
75   {
76     Dali::BaseHandle handle = service.GetSingleton(typeid(Dali::Clipboard));
77     if(handle)
78     {
79       return true;
80     }
81   }
82   return false;
83 }
84
85 Dali::Clipboard::DataSentSignalType& Clipboard::DataSentSignal()
86 {
87   return mImpl->mDataSentSignal;
88 }
89
90 Dali::Clipboard::DataReceivedSignalType& Clipboard::DataReceivedSignal()
91 {
92   return mImpl->mDataReceivedSignal;
93 }
94
95 Dali::Clipboard::DataSelectedSignalType& Clipboard::DataSelectedSignal()
96 {
97   return mImpl->mDataSelectedSignal;
98 }
99
100 bool Clipboard::SetData(const Dali::Clipboard::ClipData& clipData)
101 {
102   return true;
103 }
104
105 uint32_t Clipboard::GetData(const std::string &mimeType)
106 {
107   return 0u;
108 }
109
110 size_t Clipboard::NumberOfItems()
111 {
112   return 0u;
113 }
114
115 void Clipboard::ShowClipboard()
116 {
117 }
118
119 void Clipboard::HideClipboard(bool skipFirstHide)
120 {
121 }
122
123 bool Clipboard::IsVisible() const
124 {
125   return false;
126 }
127
128 bool Clipboard::OnReceiveData()
129 {
130   return false;
131 }
132
133 } // namespace Adaptor
134
135 } // namespace Internal
136
137 } // namespace Dali