987530e6e09fe43452628df87d771d4be10b80cf
[platform/core/uifw/dali-adaptor.git] / adaptors / wayland / clipboard-impl-wl.cpp
1 /*
2  * Copyright (c) 2014 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 "clipboard-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <Ecore.h>
23 #include <Ecore_Wayland.h>
24 #include <dali/public-api/dali-core.h>
25 #include <dali/integration-api/debug.h>
26
27 // INTERNAL INCLUDES
28 #include <adaptor.h>
29 #include <dali/public-api/object/any.h>
30 #include <adaptor-impl.h>
31
32 namespace //unnamed namespace
33 {
34 const char* const CBHM_WINDOW = "CBHM_XWIN";
35 const char* const CBHM_MSG = "CBHM_MSG";
36 const char* const CBHM_ITEM = "CBHM_ITEM";
37 const char* const CBHM_cCOUNT = "CBHM_cCOUNT";
38 const char* const CBHM_ERROR = "CBHM_ERROR";
39 const char* const SET_ITEM = "SET_ITEM";
40 const char* const SHOW = "show0";
41 const char* const HIDE = "cbhm_hide";
42 }
43
44 ///////////////////////////////////////////////////////////////////////////////////////////////////
45 // Clipboard
46 ///////////////////////////////////////////////////////////////////////////////////////////////////
47
48 namespace Dali
49 {
50
51 namespace Internal
52 {
53
54 namespace Adaptor
55 {
56
57 namespace
58 {
59 BaseHandle Create()
60 {
61   BaseHandle handle( Clipboard::Get() );
62
63   return handle;
64 }
65 TypeRegistration CLIPBOARD_TYPE( typeid(Dali::Clipboard), typeid(Dali::BaseHandle), Create, true /* Create Instance At Startup */ );
66
67 } // unnamed namespace
68
69 Clipboard::~Clipboard()
70 {
71 }
72
73 Dali::Clipboard Clipboard::Get()
74 {
75   Dali::Clipboard clipboard;
76
77   if ( Adaptor::IsAvailable() )
78   {
79     // Check whether the singleton is already created
80     Dali::BaseHandle handle = Adaptor::Get().GetSingleton( typeid( Dali::Clipboard ) );
81     if(handle)
82     {
83       // If so, downcast the handle
84       clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
85     }
86   }
87
88   return clipboard;
89 }
90 bool Clipboard::SetItem(const std::string &itemData )
91 {
92   return true;
93 }
94
95 /*
96  * Get string at given index of clipboard
97  */
98 std::string Clipboard::GetItem( unsigned int index )  // change string to a Dali::Text object.
99 {
100   if ( index >= NumberOfItems() )
101   {
102     return "";
103   }
104
105   std::string emptyString( "" );
106   char sendBuf[20];
107
108   snprintf( sendBuf, 20,  "%s%d", CBHM_ITEM, index );
109   return emptyString;
110 }
111
112 /*
113  * Get number of items in clipboard
114  */
115 unsigned int Clipboard::NumberOfItems()
116 {
117   int count = -1;
118
119   return count;
120 }
121
122 /**
123  * Show clipboard window
124  * Function to send message to show the Clipboard (cbhm) as no direct API available
125  * Reference elementary/src/modules/ctxpopup_copypasteUI/cbhm_helper.c
126  */
127 void Clipboard::ShowClipboard()
128 {
129 }
130
131 void Clipboard::HideClipboard()
132 {
133 }
134
135
136 } // namespace Adaptor
137
138 } // namespace Internal
139
140 } // namespace Dali