2 // Tizen Web Device API
3 // Copyright (c) 2012 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 #include <Commons/FunctionDefinition.h>
19 #include <Commons/FunctionDeclaration.h>
22 #include "plugin_config.h"
24 #define POWER_FEATURE_API "http://tizen.org/privilege/power"
26 #define POWER_DEVICE_CAP "power"
28 using namespace WrtDeviceApis::Commons;
33 static FunctionMapping createPowerFunctions();
35 static FunctionMapping PowerFunctions =
36 createPowerFunctions();
38 DEFINE_FUNCTION_GETTER(Power, PowerFunctions);
40 static FunctionMapping createPowerFunctions()
45 ACE_CREATE_DEVICE_CAP(DEVICE_CAP_POWER, POWER_DEVICE_CAP);
47 ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_POWER);
48 ACE_ADD_DEVICE_CAP(DEVICE_LIST_POWER, DEVICE_CAP_POWER);
53 ACE_CREATE_FEATURE(FEATURE_POWER, POWER_FEATURE_API);
55 ACE_CREATE_FEATURE_LIST(POWER_FEATURES);
56 ACE_ADD_API_FEATURE(POWER_FEATURES, FEATURE_POWER);
61 FunctionMapping powerMapping;
64 AceFunction requestFunc = ACE_CREATE_FUNCTION(
66 POWER_FUNCTION_API_REQUEST,
70 powerMapping.insert(std::make_pair(
71 POWER_FUNCTION_API_REQUEST,
75 AceFunction releaseFunc = ACE_CREATE_FUNCTION(
77 POWER_FUNCTION_API_RELEASE,
81 powerMapping.insert(std::make_pair(
82 POWER_FUNCTION_API_RELEASE,
85 // setScreenStateChangeListener
86 AceFunction setScreenStateChangeListenerFunc = ACE_CREATE_FUNCTION(
87 FUNCTION_SET_SCREEN_STATE_CHANGE_LISTENER,
88 POWER_FUNCTION_API_SET_SCREEN_STATE_CHANGE_LISTENER,
92 powerMapping.insert(std::make_pair(
93 POWER_FUNCTION_API_SET_SCREEN_STATE_CHANGE_LISTENER,
94 setScreenStateChangeListenerFunc));
96 // setScreenStateChangeListenerFunc
97 AceFunction setScreenStateChangeListenerFuncFunc = ACE_CREATE_FUNCTION(
98 FUNCTION_UNSET_SCREEN_STATE_CHANGE_LISTENER,
99 POWER_FUNCTION_API_UNSET_SCREEN_STATE_CHANGE_LISTENER,
103 powerMapping.insert(std::make_pair(
104 POWER_FUNCTION_API_UNSET_SCREEN_STATE_CHANGE_LISTENER,
105 setScreenStateChangeListenerFuncFunc));
107 // getScreenBrightness
108 AceFunction getScreenBrightnessFunc = ACE_CREATE_FUNCTION(
109 FUNCTION_GET_SCREEN_BRIGHTNESS,
110 POWER_FUNCTION_API_GET_SCREEN_BRIGHTNESS,
114 powerMapping.insert(std::make_pair(
115 POWER_FUNCTION_API_GET_SCREEN_BRIGHTNESS,
116 getScreenBrightnessFunc));
118 // setScreenBrightness
119 AceFunction setScreenBrightnessFunc = ACE_CREATE_FUNCTION(
120 FUNCTION_SET_SCREEN_BRIGHTNESS,
121 POWER_FUNCTION_API_SET_SCREEN_BRIGHTNESS,
125 powerMapping.insert(std::make_pair(
126 POWER_FUNCTION_API_SET_SCREEN_BRIGHTNESS,
127 setScreenBrightnessFunc));
130 AceFunction isScreenOnFunc = ACE_CREATE_FUNCTION(
131 FUNCTION_IS_SCREEN_ON,
132 POWER_FUNCTION_API_IS_SCREEN_ON,
136 powerMapping.insert(std::make_pair(
137 POWER_FUNCTION_API_IS_SCREEN_ON,
140 // restoreScreenBrightness
141 AceFunction restoreScreenBrightnessFunc = ACE_CREATE_FUNCTION(
142 FUNCTION_RESTORE_SCREEN_BRIGHTNESS,
143 POWER_FUNCTION_API_RESTORE_SCREEN_BRIGHTNESS,
147 powerMapping.insert(std::make_pair(
148 POWER_FUNCTION_API_RESTORE_SCREEN_BRIGHTNESS,
149 restoreScreenBrightnessFunc));
152 AceFunction turnScreenOnFunc = ACE_CREATE_FUNCTION(
153 FUNCTION_TURN_SCREEN_ON,
154 POWER_FUNCTION_API_TURN_SCREEN_ON,
158 powerMapping.insert(std::make_pair(
159 POWER_FUNCTION_API_TURN_SCREEN_ON,
163 AceFunction turnScreenOffFunc = ACE_CREATE_FUNCTION(
164 FUNCTION_TURN_SCREEN_OFF,
165 POWER_FUNCTION_API_TURN_SCREEN_OFF,
169 powerMapping.insert(std::make_pair(
170 POWER_FUNCTION_API_TURN_SCREEN_OFF,