Removed singletons from the type registry
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / clipboard-impl-ecore-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/object/any.h>
25 #include <dali/public-api/object/type-registry.h>
26 #include <dali/integration-api/debug.h>
27
28 // INTERNAL INCLUDES
29 #include <singleton-service-impl.h>
30
31 namespace //unnamed namespace
32 {
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";
41 }
42
43 ///////////////////////////////////////////////////////////////////////////////////////////////////
44 // Clipboard
45 ///////////////////////////////////////////////////////////////////////////////////////////////////
46
47 namespace Dali
48 {
49
50 namespace Internal
51 {
52
53 namespace Adaptor
54 {
55
56 struct Clipboard::Impl
57 {
58   // Put implementation here.
59 };
60
61 Clipboard::Clipboard(Impl* impl)
62 : mImpl(impl)
63 {
64 }
65
66 Clipboard::~Clipboard()
67 {
68 }
69
70 Dali::Clipboard Clipboard::Get()
71 {
72   Dali::Clipboard clipboard;
73
74   Dali::SingletonService service( SingletonService::Get() );
75   if ( service )
76   {
77     // Check whether the singleton is already created
78     Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::Clipboard ) );
79     if(handle)
80     {
81       // If so, downcast the handle
82       clipboard = Dali::Clipboard( dynamic_cast< Clipboard* >( handle.GetObjectPtr() ) );
83     }
84     else
85     {
86       Clipboard::Impl* impl( new Clipboard::Impl() );
87       clipboard = Dali::Clipboard( new Clipboard(impl) );
88       service.Register( typeid(Dali::Clipboard), clipboard );
89     }
90   }
91
92   return clipboard;
93 }
94
95 bool Clipboard::SetItem(const std::string &itemData )
96 {
97   return true;
98 }
99
100 /*
101  * Get string at given index of clipboard
102  */
103 std::string Clipboard::GetItem( unsigned int index )  // change string to a Dali::Text object.
104 {
105   if ( index >= NumberOfItems() )
106   {
107     return "";
108   }
109
110   std::string emptyString( "" );
111   char sendBuf[20];
112
113   snprintf( sendBuf, 20,  "%s%d", CBHM_ITEM, index );
114   return emptyString;
115 }
116
117 /*
118  * Get number of items in clipboard
119  */
120 unsigned int Clipboard::NumberOfItems()
121 {
122   int count = -1;
123
124   return count;
125 }
126
127 /**
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
131  */
132 void Clipboard::ShowClipboard()
133 {
134 }
135
136 void Clipboard::HideClipboard()
137 {
138 }
139
140
141 } // namespace Adaptor
142
143 } // namespace Internal
144
145 } // namespace Dali