fix gbs/obs build failure
[framework/osp/uifw.git] / src / ui / FUiSystemUtil.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 #include <FBaseSysLog.h>
19 #include <FUiSystemUtil.h>
20 #include <FUi_SystemUtilImpl.h>
21 #include <FGrpPoint.h>
22 #include <FGrpBitmap.h>
23 #include <FAppAppManager.h>
24 #include "FSec_AccessController.h"
25 #include "FApp_AppInfo.h"
26 #include "FUi_UiKeyEvent.h"
27
28 using namespace Tizen::Security;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Base;
31
32 namespace Tizen { namespace Ui
33 {
34
35 SystemUtil::SystemUtil(void)
36 {
37 }
38
39 SystemUtil::~SystemUtil(void)
40 {
41 }
42
43 result
44 SystemUtil::GenerateKeyEvent(KeyEventType KeyEvent, KeyCode keyCode)
45 {
46         result r = E_SUCCESS;
47
48         const String& packageId = Tizen::App::_AppInfo::GetPackageId();
49
50         r = _AccessController::CheckSystemPrivilege(packageId, _PRV_INPUTMANAGER);
51
52         SysTryReturn(NID_UI, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
53
54         r = _SystemUtilImpl::GenerateKeyEvent(KeyEvent, static_cast<Tizen::Ui::_KeyCode>(keyCode));
55
56         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
57         return r;
58 }
59
60 result
61 SystemUtil::GenerateTouchEvent(TouchEventType touchEvent, const Tizen::Graphics::Point& point)
62 {
63         result r = E_SUCCESS;
64         const String& packageId = Tizen::App::_AppInfo::GetPackageId();
65
66         r = _AccessController::CheckSystemPrivilege(packageId, _PRV_INPUTMANAGER);
67
68         SysTryReturn(NID_UI, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
69
70         r = _SystemUtilImpl::GenerateTouchEvent(touchEvent, point);
71
72         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
73         return r;
74 }
75
76 result
77 SystemUtil::GenerateTouchEvent(TouchEventType touchEvent, const Tizen::Graphics::FloatPoint& point)
78 {
79         result r = E_SUCCESS;
80         const String& packageId = Tizen::App::_AppInfo::GetPackageId();
81
82         r = _AccessController::CheckSystemPrivilege(packageId, _PRV_INPUTMANAGER);
83
84         SysTryReturn(NID_UI, r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, ("[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method."));
85
86         r = _SystemUtilImpl::GenerateTouchEvent(touchEvent, point);
87
88         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
89         return r;
90 }
91
92 Tizen::Graphics::Bitmap*
93 SystemUtil::CaptureScreenN(void)
94 {
95         result r = E_SUCCESS;
96         const String& packageId = Tizen::App::_AppInfo::GetPackageId();
97
98         r = _AccessController::CheckSystemPrivilege(packageId, _PRV_INPUTMANAGER);
99
100         SysTryReturn(NID_UI, r == E_SUCCESS, null, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] The application does not have the privilege to call this method.");
101
102         return _SystemUtilImpl::CaptureScreenN();
103 }
104
105 }} //Tizen::Ui