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