merge with master
[platform/framework/web/wrt-plugins-tizen.git] / src / Power / plugin_config.cpp
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 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 <Commons/FunctionDefinition.h>
19 #include <Commons/FunctionDeclaration.h>
20 #include <map>
21
22 #include "plugin_config.h"
23
24 #define POWER_FEATURE_API "http://tizen.org/privilege/power"
25
26 #define POWER_DEVICE_CAP "power"
27
28 using namespace WrtDeviceApis::Commons;
29
30 namespace DeviceAPI {
31 namespace Power {
32
33 static FunctionMapping createPowerFunctions();
34
35 static FunctionMapping PowerFunctions =
36     createPowerFunctions();
37
38 DEFINE_FUNCTION_GETTER(Power, PowerFunctions);
39
40 static FunctionMapping createPowerFunctions()
41 {
42     /**
43      * Device capabilities
44      */
45     ACE_CREATE_DEVICE_CAP(DEVICE_CAP_POWER, POWER_DEVICE_CAP);
46
47     ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_POWER);
48     ACE_ADD_DEVICE_CAP(DEVICE_LIST_POWER, DEVICE_CAP_POWER);
49
50     /**
51      * Api Features
52      */
53     ACE_CREATE_FEATURE(FEATURE_POWER, POWER_FEATURE_API);
54
55     ACE_CREATE_FEATURE_LIST(POWER_FEATURES);
56     ACE_ADD_API_FEATURE(POWER_FEATURES, FEATURE_POWER);
57
58     /**
59      * Functions
60      */
61     FunctionMapping powerMapping;
62
63     // request
64     AceFunction requestFunc = ACE_CREATE_FUNCTION(
65             FUNCTION_REQUEST,
66             POWER_FUNCTION_API_REQUEST,
67             POWER_FEATURES,
68             DEVICE_LIST_POWER);
69
70     powerMapping.insert(std::make_pair(
71                                POWER_FUNCTION_API_REQUEST,
72                                requestFunc));
73
74     // release
75     AceFunction releaseFunc = ACE_CREATE_FUNCTION(
76             FUNCTION_RELEASE,
77             POWER_FUNCTION_API_RELEASE,
78             POWER_FEATURES,
79             DEVICE_LIST_POWER);
80
81     powerMapping.insert(std::make_pair(
82                                POWER_FUNCTION_API_RELEASE,
83                                releaseFunc));
84
85     // setScreenStateChangeListener
86     AceFunction setScreenStateChangeListenerFunc = ACE_CREATE_FUNCTION(
87             FUNCTION_SET_SCREEN_STATE_CHANGE_LISTENER,
88             POWER_FUNCTION_API_SET_SCREEN_STATE_CHANGE_LISTENER,
89             POWER_FEATURES,
90             DEVICE_LIST_POWER);
91
92     powerMapping.insert(std::make_pair(
93                                POWER_FUNCTION_API_SET_SCREEN_STATE_CHANGE_LISTENER,
94                                setScreenStateChangeListenerFunc));
95
96     // setScreenStateChangeListenerFunc
97     AceFunction setScreenStateChangeListenerFuncFunc = ACE_CREATE_FUNCTION(
98             FUNCTION_UNSET_SCREEN_STATE_CHANGE_LISTENER,
99             POWER_FUNCTION_API_UNSET_SCREEN_STATE_CHANGE_LISTENER,
100             POWER_FEATURES,
101             DEVICE_LIST_POWER);
102
103     powerMapping.insert(std::make_pair(
104                                POWER_FUNCTION_API_UNSET_SCREEN_STATE_CHANGE_LISTENER,
105                                setScreenStateChangeListenerFuncFunc));
106
107     // getScreenBrightness
108     AceFunction getScreenBrightnessFunc = ACE_CREATE_FUNCTION(
109             FUNCTION_GET_SCREEN_BRIGHTNESS,
110             POWER_FUNCTION_API_GET_SCREEN_BRIGHTNESS,
111             POWER_FEATURES,
112             DEVICE_LIST_POWER);
113
114     powerMapping.insert(std::make_pair(
115                                POWER_FUNCTION_API_GET_SCREEN_BRIGHTNESS,
116                                getScreenBrightnessFunc));
117
118     // setScreenBrightness
119     AceFunction setScreenBrightnessFunc = ACE_CREATE_FUNCTION(
120             FUNCTION_SET_SCREEN_BRIGHTNESS,
121             POWER_FUNCTION_API_SET_SCREEN_BRIGHTNESS,
122             POWER_FEATURES,
123             DEVICE_LIST_POWER);
124
125     powerMapping.insert(std::make_pair(
126                                POWER_FUNCTION_API_SET_SCREEN_BRIGHTNESS,
127                                setScreenBrightnessFunc));
128
129     // isScreenOn
130     AceFunction isScreenOnFunc = ACE_CREATE_FUNCTION(
131             FUNCTION_IS_SCREEN_ON,
132             POWER_FUNCTION_API_IS_SCREEN_ON,
133             POWER_FEATURES,
134             DEVICE_LIST_POWER);
135
136     powerMapping.insert(std::make_pair(
137                                POWER_FUNCTION_API_IS_SCREEN_ON,
138                                isScreenOnFunc));
139
140     // restoreScreenBrightness
141     AceFunction restoreScreenBrightnessFunc = ACE_CREATE_FUNCTION(
142             FUNCTION_RESTORE_SCREEN_BRIGHTNESS,
143             POWER_FUNCTION_API_RESTORE_SCREEN_BRIGHTNESS,
144             POWER_FEATURES,
145             DEVICE_LIST_POWER);
146
147     powerMapping.insert(std::make_pair(
148                                POWER_FUNCTION_API_RESTORE_SCREEN_BRIGHTNESS,
149                                restoreScreenBrightnessFunc));
150
151     // turnScreenOn
152     AceFunction turnScreenOnFunc = ACE_CREATE_FUNCTION(
153             FUNCTION_TURN_SCREEN_ON,
154             POWER_FUNCTION_API_TURN_SCREEN_ON,
155             POWER_FEATURES,
156             DEVICE_LIST_POWER);
157
158     powerMapping.insert(std::make_pair(
159                                POWER_FUNCTION_API_TURN_SCREEN_ON,
160                                turnScreenOnFunc));
161
162     // turnScreenOff
163     AceFunction turnScreenOffFunc = ACE_CREATE_FUNCTION(
164             FUNCTION_TURN_SCREEN_OFF,
165             POWER_FUNCTION_API_TURN_SCREEN_OFF,
166             POWER_FEATURES,
167             DEVICE_LIST_POWER);
168
169     powerMapping.insert(std::make_pair(
170                                POWER_FUNCTION_API_TURN_SCREEN_OFF,
171                                turnScreenOffFunc));
172
173     return powerMapping;
174 }
175
176
177 }