2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
18 * @file FUi_ActiveWindowEvent.cpp
19 * @brief This is the implementation for the _ActiveWindowEvent class.
23 #include <FBaseErrors.h>
24 #include <FBaseSysLog.h>
25 #include "FUi_ActiveWindowEvent.h"
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Runtime;
29 using namespace Tizen::App;
31 namespace Tizen { namespace Ui
34 class _ActiveWindowEventArg
35 : public Tizen::Base::Runtime::IEventArg
36 , public Tizen::Base::Object
39 _ActiveWindowEventArg(unsigned int xid, int pid, char* pAppName);
41 virtual ~_ActiveWindowEventArg(void);
43 unsigned int GetWindowId(void) const;
44 int GetProcessId(void) const;
45 char* GetAppName(void) const;
48 _ActiveWindowEventArg(const _ActiveWindowEventArg& rhs);
49 _ActiveWindowEventArg& operator =(const _ActiveWindowEventArg& rhs);
55 }; // _ActiveWindowEventArg
57 _ActiveWindowEventArg::_ActiveWindowEventArg(unsigned int xid, int pid, char* pAppName)
60 , __pAppName(pAppName)
64 _ActiveWindowEventArg::~_ActiveWindowEventArg(void)
69 _ActiveWindowEventArg::GetWindowId(void) const
75 _ActiveWindowEventArg::GetProcessId(void) const
81 _ActiveWindowEventArg::GetAppName(void) const
87 _ActiveWindowEvent::CreateInstanceN(void)
89 _ActiveWindowEvent* pActiveWindowEvent = new (std::nothrow) _ActiveWindowEvent();
90 SysTryReturn(NID_UI, pActiveWindowEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
92 result r = GetLastResult();
93 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
95 SetLastResult(E_SUCCESS);
97 return pActiveWindowEvent;
100 delete pActiveWindowEvent;
105 _ActiveWindowEvent::CreateActiveWindowEventArgN(unsigned int xid, int pid, char* pAppName)
107 _ActiveWindowEventArg* pEventArg = new (std::nothrow) _ActiveWindowEventArg(xid, pid, pAppName);
108 SysTryReturn(NID_UI, pEventArg, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
110 SetLastResult(E_SUCCESS);
115 _ActiveWindowEvent::~_ActiveWindowEvent(void)
120 _ActiveWindowEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
122 _IActiveWindowEventListener* pEventListener = dynamic_cast <_IActiveWindowEventListener*>(&listener);
123 SysTryReturnVoidResult(NID_UI, pEventListener, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid.");
125 const _ActiveWindowEventArg* pArg = dynamic_cast <const _ActiveWindowEventArg*>(&arg);
126 SysTryReturnVoidResult(NID_UI, pArg, E_INVALID_ARG, "[E_INVALID_ARG] A specified input parameter is invalid.");
128 pEventListener->OnActiveWindowChanged(pArg->GetWindowId(), pArg->GetProcessId(), pArg->GetAppName());
130 SetLastResult(E_SUCCESS);
133 _ActiveWindowEvent::_ActiveWindowEvent(void)
135 result r = _Event::Initialize();
136 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
138 SetLastResult(E_SUCCESS);