Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_PublicProgressPopupEvent.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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        FUiCtrl_PublicProgressPopupEvent.cpp
19  * @brief       This is the implementation for the _PublicProgressPopupEvent class.
20  */
21
22 #include <new>
23 #include <FUiCtrlIProgressPopupEventListener.h>
24 #include <FBaseErrors.h>
25 #include <FBaseSysLog.h>
26 #include "FUiCtrl_PublicProgressPopupEvent.h"
27
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Runtime;
31
32
33 namespace Tizen { namespace Ui { namespace Controls
34 {
35
36 /**
37  * @class       _PublicProgressPopupEventArg
38  * @brief       This class is used as the argument to progresspopup event listener.
39  *
40  */
41 class _OSP_EXPORT_ _PublicProgressPopupEventArg
42         : public Object
43         , public IEventArg
44 {
45 public:
46         _PublicProgressPopupEventArg(void);
47         virtual ~_PublicProgressPopupEventArg(void);
48
49 }; // _PublicProgressPopupEventArg
50
51
52 _PublicProgressPopupEventArg::_PublicProgressPopupEventArg(void)
53 {
54         // empty statement
55 }
56
57 _PublicProgressPopupEventArg::~_PublicProgressPopupEventArg(void)
58 {
59         // empty statement
60 }
61
62
63
64 _PublicProgressPopupEvent::_PublicProgressPopupEvent(const Tizen::Ui::Control& source)
65         : __pSource(null)
66 {
67         result r = _Event::Initialize();
68
69         // set event source
70         if (r == E_SUCCESS)
71         {
72                 __pSource = &source;
73                 SetLastResult(E_SUCCESS);
74         }
75 }
76
77 _PublicProgressPopupEvent::~_PublicProgressPopupEvent(void)
78 {
79         // empty statement
80 }
81
82 _PublicProgressPopupEvent*
83 _PublicProgressPopupEvent::CreateInstanceN(const Control& source)
84 {
85         _PublicProgressPopupEvent* pPublicProgressPopupEvent = new (std::nothrow) _PublicProgressPopupEvent(source);
86         SysTryReturn(NID_UI_CTRL, pPublicProgressPopupEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
87
88         if (IsFailed(GetLastResult()))
89         {
90                 goto CATCH;
91         }
92
93         return pPublicProgressPopupEvent;
94
95 CATCH:
96         delete pPublicProgressPopupEvent;
97         return null;
98 }
99
100 const Control*
101 _PublicProgressPopupEvent::GetSource(void) const
102 {
103         return __pSource;
104 }
105
106 void
107 _PublicProgressPopupEvent::FireImpl(IEventListener& pListener, const IEventArg& arg)
108 {
109         // cast to IProgressPopupEventListener
110         IProgressPopupEventListener* pProgressPopupListener = dynamic_cast <IProgressPopupEventListener*>(&pListener);
111         SysTryReturnVoidResult(NID_UI_CTRL, pProgressPopupListener != null, E_INVALID_ARG,
112                                 "[E_INVALID_ARG] The invalid listener was given.");
113
114         // cast to _PublicProgressPopupEventArg
115 //      const _PublicProgressPopupEventArg* pArg = dynamic_cast <const _PublicProgressPopupEventArg*>(&arg);
116 //      SysTryReturn(NID_UI_CTRL, pArg != null, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.");
117
118         // call progresspopup event listener method
119         pProgressPopupListener->OnProgressPopupCanceled();
120 }
121
122 IEventArg*
123 _PublicProgressPopupEvent::CreateProgressPopupEventArgN(void)
124 {
125         _PublicProgressPopupEventArg* pEventArg = new (std::nothrow) _PublicProgressPopupEventArg();
126         SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
127
128         return pEventArg;
129 }
130
131 }}} // Tizen::Ui::Controls