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>
30 #include <singleton-service-impl.h>
32 #define CLIPBOARD_STR "CLIPBOARD_STR"
34 ///////////////////////////////////////////////////////////////////////////////////////////////////
36 ///////////////////////////////////////////////////////////////////////////////////////////////////
47 struct Clipboard::Impl
51 mBundle = bundle_create();
54 void SetItem(const char *data)
58 if (bundle_get_str(mBundle, CLIPBOARD_STR, &temp) == BUNDLE_ERROR_NONE)
60 bundle_del(mBundle, CLIPBOARD_STR);
62 bundle_add_str(mBundle, CLIPBOARD_STR, data);
69 if ( bundle_get_count(mBundle) )
71 bundle_get_str(mBundle, CLIPBOARD_STR, &data);
78 return bundle_get_count(mBundle);
84 Clipboard::Clipboard(Impl* impl)
89 Clipboard::~Clipboard()
93 Dali::Clipboard Clipboard::Get()
95 Dali::Clipboard clipboard;
97 Dali::SingletonService service( SingletonService::Get() );
100 // Check whether the singleton is already created
101 Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) );
104 // If so, downcast the handle
105 clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
109 Clipboard::Impl* impl( new Clipboard::Impl() );
110 clipboard = Dali::Clipboard( new Clipboard(impl) );
111 service.Register( typeid(Dali::Clipboard), clipboard );
118 bool Clipboard::SetItem(const std::string &itemData )
120 mImpl->SetItem( const_cast<char*>( itemData.c_str()) );
125 * Get string at given index of clipboard
127 std::string Clipboard::GetItem( unsigned int index ) // change string to a Dali::Text object.
129 std::string clipboardString(mImpl->GetItem());
130 return clipboardString;
134 * Get number of items in clipboard
136 unsigned int Clipboard::NumberOfItems()
138 return mImpl->GetCount();
142 * Show clipboard window
143 * Function to send message to show the Clipboard (cbhm) as no direct API available
144 * Reference elementary/src/modules/ctxpopup_copypasteUI/cbhm_helper.c
146 void Clipboard::ShowClipboard()
150 void Clipboard::HideClipboard()
155 } // namespace Adaptor
157 } // namespace Internal