Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / FUi_TouchEffectImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file                FUi_TouchEffectImpl.cpp
20  * @brief               This is the implementation for _TouchEffectImpl class.
21  *
22  * This file contains definitions of %_TouchEffectImpl class.
23  */
24 #include <feedback.h>
25 #include <FBaseErrors.h>
26 #include <FBaseSysLog.h>
27 #include <FUiTouchEffect.h>
28 #include <FUi_TouchEffectImpl.h>
29
30 namespace Tizen { namespace Ui
31 {
32
33 _TouchEffectImpl::_TouchEffectImpl(void)
34 {
35 }
36
37 _TouchEffectImpl::~_TouchEffectImpl(void)
38 {
39 }
40
41 result
42 _TouchEffectImpl::Construct(void)
43 {
44         int feedbackError = FEEDBACK_ERROR_NONE;
45
46         feedbackError = feedback_initialize();
47         SysTryReturn(NID_UI, feedbackError == FEEDBACK_ERROR_NONE, E_OPERATION_FAILED, E_OPERATION_FAILED,
48                     "[E_OPERATION_FAILED,] Failed to initialize feedback API");
49
50         return E_SUCCESS;
51 }
52
53 result
54 _TouchEffectImpl::Play(TouchEffectType type)
55 {
56         int feedbackError = FEEDBACK_PATTERN_NONE;
57         switch(type)
58         {
59         case TOUCH_EFFECT_TAP:
60                 feedbackError = feedback_play(FEEDBACK_PATTERN_TAP);
61                 SysTryReturn(NID_UI, feedbackError == FEEDBACK_ERROR_NONE, E_SYSTEM, E_SYSTEM,
62                             "[E_SYSTEM] Failed to play the TAP effect.");
63                 SysLog(NID_UI, "It failed to play the TAP effect.");
64                 break;
65
66         case TOUCH_EFFECT_SIP:
67                 feedbackError = feedback_play(FEEDBACK_PATTERN_SIP);
68                 SysTryReturn(NID_UI, feedbackError == FEEDBACK_ERROR_NONE, E_SYSTEM, E_SYSTEM,
69                             "[E_SYSTEM] Failed to play the SIP effect.");
70                 SysLog(NID_UI, "It failed to play the SIP effect.");
71                 break;
72
73         case TOUCH_EFFECT_NO_SOUND:
74                 feedbackError = feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_SIP);
75                 SysTryReturn(NID_UI, feedbackError == FEEDBACK_ERROR_NONE, E_SYSTEM, E_SYSTEM,
76                             "[E_SYSTEM] Failed to play the NO_SOUND effect.");
77                 SysLog(NID_UI, "It failed to play the NO_SOUND effect.");
78                 break;
79
80         default:
81                 SysTryReturn(NID_UI, false, E_INVALID_ARG, E_INVALID_ARG,
82                             "[E_INVALID_ARG] The specified type is invalid.");
83                 break;
84         }
85
86         return E_SUCCESS;
87 }
88
89 _TouchEffectImpl*
90 _TouchEffectImpl::GetInstance(TouchEffect& touchEffect)
91 {
92     return touchEffect.__pTouchEffectImpl;
93 }
94
95 const _TouchEffectImpl*
96 _TouchEffectImpl::GetInstance(const TouchEffect& touchEffect)
97 {
98     return touchEffect.__pTouchEffectImpl;
99 }
100
101 } }// Tizen::Ui