b2c02bb0bb1a62676cf6a596e209cda0e17f24b8
[platform/core/appfw/app-core.git] / src / appcore-pmcontrol.c
1 /*
2  *  app-core
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22
23 #include <sys/types.h>
24 #include <sys/socket.h>
25 #include <sys/un.h>
26 #include <unistd.h>
27 #include <errno.h>
28
29 #include <pmapi.h>
30
31 #include "appcore-internal.h"
32
33 EXPORT_API int appcore_lock_power_state(int s_bits)
34 {
35         switch (s_bits) {
36         case LCD_NORMAL:
37                 return pm_lock_state(s_bits, GOTO_STATE_NOW, 0);
38
39         case LCD_DIM:
40                 if (pm_lock_state(s_bits, STAY_CUR_STATE, 0) < 0)
41                         return -1;
42                 return pm_change_state(LCD_NORMAL);
43
44         case LCD_OFF:
45                 return pm_lock_state(s_bits, STAY_CUR_STATE, 0);
46
47         default:
48                 break;
49         }
50
51         return -1;
52 }
53
54 EXPORT_API int appcore_unlock_power_state(int s_bits)
55 {
56         return pm_unlock_state(s_bits, STAY_CUR_STATE);
57 }