Add privilege check code.
[platform/framework/native/appfw.git] / src / server / app / FApp_AppManagerEvent.cpp
1 //
2 // Copyright (c) 2012 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  * @file         FApp_AppManagerEvent.cpp
19  * @brief       This is the implementation for the _AppManagerEvent.cpp class.
20  */
21
22 #include <FBaseSysLog.h>
23
24 #include "FApp_Types.h"
25 #include "FApp_AppManagerEvent.h"
26 #include "FApp_AppManagerEventArg.h"
27 #include "FApp_IAppManagerEventListener.h"
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Runtime;
31
32
33 namespace Tizen { namespace App
34 {
35
36 _AppManagerEventArg::_AppManagerEventArg(void)
37         : __appType(_APP_TYPE_UI_APP)
38         , __eventType(_AppManagerEvent::_APP_MANAGER_EVENT_INVALID)
39 {
40 }
41
42 _AppManagerEventArg::_AppManagerEventArg(const AppId& appId, _AppType appType, _AppManagerEvent::_Type eventType)
43         : __appId(appId)
44         , __appType(appType)
45         , __eventType(eventType)
46 {
47 }
48
49 _AppManagerEventArg::_AppManagerEventArg(const _AppManagerEventArg& value)
50 {
51 //      *this = value;
52         __appId = value.__appId;
53         __appType = value.__appType;
54         __eventType = value.__eventType;
55 }
56
57 _AppManagerEventArg::~_AppManagerEventArg(void)
58 {
59 }
60
61 const AppId
62 _AppManagerEventArg::GetAppId(void) const
63 {
64         return __appId;
65 }
66
67 _AppType
68 _AppManagerEventArg::GetAppType(void) const
69 {
70         return __appType;
71 }
72
73 _AppManagerEvent::_Type
74 _AppManagerEventArg::GetEventType(void) const
75 {
76         return __eventType;
77 }
78
79 _AppManagerEventArg&
80 _AppManagerEventArg::operator =(const _AppManagerEventArg& source)
81 {
82         if (&source == this)
83         {
84                 return *this;
85         }
86
87         __appId = source.__appId;
88         __appType = source.__appType;
89         __eventType = source.__eventType;
90
91         return *this;
92 }
93
94
95 ///////////////////////////////////////////////////////
96 //_AppManagerEvent
97 ///////////////////////////////////////////////////////
98 result
99 _AppManagerEvent::Construct(void)
100 {
101         return _Event::Initialize();
102 }
103
104 void
105 _AppManagerEvent::FireImpl(IEventListener& listener, const IEventArg& arg)
106 {
107         _IAppManagerEventListener* pListener = dynamic_cast<_IAppManagerEventListener*>(&listener);
108         SysTryReturnVoidResult(NID_APP, pListener != null, E_INVALID_STATE, "Invalid listener : listener(0x%x), arg(0x%x)", &listener, &arg);
109
110         const _AppManagerEventArg* pEventArg = dynamic_cast<const _AppManagerEventArg*>(&arg);
111         SysTryReturnVoidResult(NID_APP, pEventArg != null, E_INVALID_STATE, "Invalid arg : listener(0x%x), arg(0x%x)", &listener, &arg);
112
113         switch (pEventArg->GetEventType())
114         {
115         case _APP_MANAGER_EVENT_LAUNCHED:
116                 pListener->OnApplicationLaunched(pEventArg->GetAppId(), pEventArg->GetAppType());
117                 break;
118
119         case _APP_MANAGER_EVENT_TERMINATED:
120                 pListener->OnApplicationTerminated(pEventArg->GetAppId(), pEventArg->GetAppType());
121                 break;
122
123         default:
124                 SysLog(NID_APP, "Invalid event type(%d)!!", pEventArg->GetEventType());
125                 break;
126         }
127 }
128
129 } } // Tizen::App