e0274723f60b9fdb8fe87dc347dc21a6882e5258
[platform/core/uifw/dali-adaptor.git] / dali / internal / clipboard / common / clipboard-event-notifier-impl.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 <dali/internal/clipboard/common/clipboard-event-notifier-impl.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/object/type-registry.h>
23
24 // INTERNAL INCLUDES
25 #include <dali/internal/system/common/singleton-service-impl.h>
26
27 namespace Dali
28 {
29
30 namespace Internal
31 {
32
33 namespace Adaptor
34 {
35
36 Dali::ClipboardEventNotifier ClipboardEventNotifier::New()
37 {
38   Dali::ClipboardEventNotifier notifier = Dali::ClipboardEventNotifier(new ClipboardEventNotifier());
39
40   return notifier;
41 }
42
43 Dali::ClipboardEventNotifier ClipboardEventNotifier::Get()
44 {
45   Dali::ClipboardEventNotifier notifier;
46
47   Dali::SingletonService service( SingletonService::Get() );
48   if ( service )
49   {
50     // Check whether the singleton is already created
51     Dali::BaseHandle handle = service.GetSingleton( typeid( Dali::ClipboardEventNotifier ) );
52     if(handle)
53     {
54       // If so, downcast the handle
55       notifier = Dali::ClipboardEventNotifier( dynamic_cast< ClipboardEventNotifier* >( handle.GetObjectPtr() ) );
56     }
57     else
58     {
59       notifier = Dali::ClipboardEventNotifier( ClipboardEventNotifier::New() );
60       service.Register( typeid( notifier ), notifier );
61     }
62   }
63
64   return notifier;
65 }
66
67 const std::string& ClipboardEventNotifier::GetContent() const
68 {
69   return mContent;
70 }
71
72 void ClipboardEventNotifier::SetContent( const std::string& content )
73 {
74   mContent = content;
75 }
76
77 void ClipboardEventNotifier::ClearContent()
78 {
79   mContent.clear();
80 }
81
82 void ClipboardEventNotifier::EmitContentSelectedSignal()
83 {
84   if ( !mContentSelectedSignal.Empty() )
85   {
86     Dali::ClipboardEventNotifier handle( this );
87     mContentSelectedSignal.Emit( handle );
88   }
89 }
90
91 ClipboardEventNotifier::ClipboardEventNotifier()
92 : mContent()
93 {
94 }
95
96 ClipboardEventNotifier::~ClipboardEventNotifier()
97 {
98 }
99
100 } // namespace Adaptor
101
102 } // namespace Internal
103
104 } // namespace Dali