3 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * PROPRIETARY/CONFIDENTIAL
6 * This software is the confidential and proprietary information of SAMSUNG
7 * ELECTRONICS ("Confidential Information"). You agree and acknowledge that
8 * this software is owned by Samsung and you shall not disclose such
9 * Confidential Information and shall use it only in accordance with the terms
10 * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG
11 * make no representations or warranties about the suitability of the software,
12 * either express or implied, including but not limited to the implied
13 * warranties of merchantability, fitness for a particular purpose, or
14 * non-infringement. SAMSUNG shall not be liable for any damages suffered by
15 * licensee arising out of or related to this software.
25 static GMainLoop *mainloop;
27 void power_cb(power_state_e state, void *ud)
29 char* txt = (char*)ud;
30 printf("power state [%d] -- %s\n", state, txt);
33 static void sig_quit(int signo)
37 g_main_loop_quit(mainloop);
41 static void errp(power_error_e e){
43 case POWER_ERROR_INVALID_PARAMETER:
44 printf("invalid parameter!\n");
46 case POWER_ERROR_IO_ERROR:
47 printf("operation failed!\n");
49 case POWER_ERROR_NONE:
57 int main(int argc, char *argv[])
61 signal(SIGINT, sig_quit);
62 signal(SIGTERM, sig_quit);
63 signal(SIGQUIT, sig_quit);
65 mainloop = g_main_loop_new(NULL, FALSE);
68 if( (state = power_get_state()) < 0){
69 printf("power state return ");
72 printf("current state -> %d\n", state);
74 if( (err=power_set_changed_cb(power_cb, "PIUS!!")) < 0){
75 printf("set cb return ");
79 g_main_loop_run(mainloop);
80 g_main_loop_unref(mainloop);
82 if( (err=power_unset_changed_cb()) < 0){
83 printf("unset cb return ");