Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / FUi_UiNotificationEvent.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 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  * @file                FUi_UiNotificationEvent.cpp
19  * @brief               This is the implementation file for the _UiNotificationEvent class.
20  */
21
22 #include <FBaseResult.h>
23 #include <FBaseSysLog.h>
24 #include "FUi_UiNotificationEvent.h"
25 #include "FUi_INotificationEventListener.h"
26 #include "FUi_INotificationEventPreviewer.h"
27 #include "FUi_Control.h"
28
29 namespace Tizen { namespace Ui
30 {
31
32 _UiNotificationEvent::_UiNotificationEvent(const _UiObjectHandle& destination, Tizen::Base::Collection::IList* pArgs, _UiEventRouteType routeType, const _UiObjectHandle& source)
33         : _UiEvent(destination, source, routeType)
34         , __pArgs(pArgs)
35 {
36 }
37
38 _UiNotificationEvent::~_UiNotificationEvent(void)
39 {
40 }
41
42 _UiNotificationEvent::_UiNotificationEvent(const _UiNotificationEvent& rhs)
43         : _UiEvent(rhs)
44         , __pArgs(rhs.__pArgs)
45 {
46 }
47
48 _UiNotificationEvent&
49 _UiNotificationEvent::operator =(const _UiNotificationEvent& rhs)
50 {
51         _UiEvent::operator =(rhs);
52
53         if (this != &rhs)
54         {
55                 __pArgs = rhs.__pArgs;
56         }
57
58         return *this;
59 }
60
61 Tizen::Base::Collection::IList*
62 _UiNotificationEvent::GetArgs(void) const
63 {
64         return __pArgs;
65 }
66
67 _UiNotificationEvent*
68 _UiNotificationEvent::CloneN(void) const
69 {
70         return new (std::nothrow) _UiNotificationEvent(*this);
71 }
72
73 _UiEventType
74 _UiNotificationEvent::GetEventType(void) const
75 {
76         return _UI_EVENT_NOTIFICAITON;
77 }
78
79 bool
80 _UiNotificationEvent::IsEventEnabled(const _Control& control) const
81 {
82         return true;
83 }
84
85 result
86 _UiNotificationEvent::OnPreviewEventProcessing(const _Control& control, bool& isFiltered)
87 {
88         result r = E_SUCCESS;
89
90         _INotificationEventPreviewer* pNotificationPreviewer = control.GetEventPreviewer<_UI_EVENT_NOTIFICAITON, _INotificationEventPreviewer*>();
91         SysTryReturn(NID_UI, pNotificationPreviewer, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
92
93         const _Control* pTarget = GetControl(GetDestination());
94         SysTryReturn(NID_UI, pTarget, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
95
96         isFiltered = pNotificationPreviewer->OnPreviewNotifiedN(*pTarget, GetArgs());
97
98         return r;
99 }
100
101 result
102 _UiNotificationEvent::OnEventProcessing(const _Control& control, bool& isFiltered)
103 {
104         if (isFiltered)
105         {
106                 return E_SUCCESS;
107         }
108
109         _INotificationEventListener* pNotificationListener = control.GetEventListener<_UI_EVENT_NOTIFICAITON, _INotificationEventListener*>();
110         SysTryReturn(NID_UI, pNotificationListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
111
112         return FireListener(pNotificationListener, isFiltered);
113 }
114
115 result
116 _UiNotificationEvent::OnListenerProcessing(const _IUiEventListener& listener, bool& isFiltered)
117 {
118         _INotificationEventListener* pNotificationListener = dynamic_cast <_INotificationEventListener*>(const_cast <_IUiEventListener*>(&listener));
119         SysTryReturn(NID_UI, pNotificationListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
120
121         return FireListener(pNotificationListener, isFiltered);
122 }
123
124 result
125 _UiNotificationEvent::FireListener(const _INotificationEventListener* pListener, bool& isFiltered)
126 {
127         result r = E_SUCCESS;
128
129         _INotificationEventListener* pNotificationListener = const_cast <_INotificationEventListener*>(pListener);
130         SysTryReturn(NID_UI, pNotificationListener, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
131
132         const _Control* pTarget = GetControl(GetDestination());
133         SysTryReturn(NID_UI, pTarget, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
134
135         isFiltered = pNotificationListener->OnNotifiedN(*pTarget, GetArgs());
136
137         return r;
138 }
139
140 }} // Tizen::Ui