Merge "Fix build errors with GCC4.8." into tizen
[platform/core/uifw/dali-adaptor.git] / adaptors / common / physical-keyboard-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 // EXTERNAL INCLUDES
19
20 // CLASS HEADER
21 #include <physical-keyboard-impl.h>
22
23 // INTERNAL INCLUDES
24 #include <adaptor-impl.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 namespace Adaptor
33 {
34
35 Dali::PhysicalKeyboard PhysicalKeyboard::New()
36 {
37   Dali::PhysicalKeyboard keyboardHandle;
38
39   if ( Adaptor::IsAvailable() )
40   {
41     Dali::Adaptor& adaptor = Adaptor::Get();
42     keyboardHandle = Dali::PhysicalKeyboard( new PhysicalKeyboard() );
43     adaptor.RegisterSingleton( typeid( keyboardHandle ), keyboardHandle );
44   }
45
46   return keyboardHandle;
47 }
48
49 Dali::PhysicalKeyboard PhysicalKeyboard::Get()
50 {
51   Dali::PhysicalKeyboard keyboardHandle;
52
53   // Ensure the adaptor has been created
54   if ( Adaptor::IsAvailable() )
55   {
56     Dali::Adaptor& adaptor = Adaptor::Get();
57
58     BaseHandle handle = adaptor.GetSingleton( typeid( Dali::PhysicalKeyboard ) );
59     if( handle )
60     {
61       // If so, downcast the handle of singleton to focus manager
62       keyboardHandle = Dali::PhysicalKeyboard( dynamic_cast< PhysicalKeyboard* >( handle.GetObjectPtr() ) );
63     }
64   }
65
66   return keyboardHandle;
67 }
68
69 bool PhysicalKeyboard::IsAttached() const
70 {
71   return mAttached;
72 }
73
74 void PhysicalKeyboard::KeyReceived( bool fromPhysicalKeyboard )
75 {
76   if ( mAttached != fromPhysicalKeyboard )
77   {
78     mAttached = fromPhysicalKeyboard;
79
80     Dali::PhysicalKeyboard handle( this );
81     mStatusChangedSignal.Emit( handle );
82   }
83 }
84
85 PhysicalKeyboard::~PhysicalKeyboard()
86 {
87 }
88
89 PhysicalKeyboard::PhysicalKeyboard()
90 : mAttached( false )
91 {
92 }
93
94 } // Adaptor
95
96 } // Internal
97
98 } // Dali