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