2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include "clipboard-impl.h"
23 #include <Ecore_Wayland.h>
24 #include <dali/public-api/object/any.h>
25 #include <dali/public-api/object/type-registry.h>
26 #include <dali/integration-api/debug.h>
29 #include <singleton-service-impl.h>
31 namespace //unnamed namespace
33 const char* const CBHM_WINDOW = "CBHM_XWIN";
34 const char* const CBHM_MSG = "CBHM_MSG";
35 const char* const CBHM_ITEM = "CBHM_ITEM";
36 const char* const CBHM_cCOUNT = "CBHM_cCOUNT";
37 const char* const CBHM_ERROR = "CBHM_ERROR";
38 const char* const SET_ITEM = "SET_ITEM";
39 const char* const SHOW = "show0";
40 const char* const HIDE = "cbhm_hide";
43 ///////////////////////////////////////////////////////////////////////////////////////////////////
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
56 struct Clipboard::Impl
58 // Put implementation here.
61 Clipboard::Clipboard(Impl* impl)
66 Clipboard::~Clipboard()
70 Dali::Clipboard Clipboard::Get()
72 Dali::Clipboard clipboard;
74 Dali::SingletonService service( SingletonService::Get() );
77 // Check whether the singleton is already created
78 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) );
81 // If so, downcast the handle
82 clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
86 Clipboard::Impl* impl( new Clipboard::Impl() );
87 clipboard = Dali::Clipboard( new Clipboard(impl) );
88 service.Register( typeid(Dali::Clipboard), clipboard );
95 bool Clipboard::SetItem(const std::string &itemData )
101 * Get string at given index of clipboard
103 std::string Clipboard::GetItem( unsigned int index ) // change string to a Dali::Text object.
105 if ( index >= NumberOfItems() )
110 std::string emptyString( "" );
113 snprintf( sendBuf, 20, "%s%d", CBHM_ITEM, index );
118 * Get number of items in clipboard
120 unsigned int Clipboard::NumberOfItems()
128 * Show clipboard window
129 * Function to send message to show the Clipboard (cbhm) as no direct API available
130 * Reference elementary/src/modules/ctxpopup_copypasteUI/cbhm_helper.c
132 void Clipboard::ShowClipboard()
136 void Clipboard::HideClipboard()
141 } // namespace Adaptor
143 } // namespace Internal