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 battery_cb(int percent, void* ud)
29 char* txt = (char*)ud;
30 printf("battery capacity [%d] -- %s\n", percent, txt);
33 static void sig_quit(int signo)
37 g_main_loop_quit(mainloop);
41 static void errp(device_error_e e){
43 case DEVICE_ERROR_INVALID_PARAMETER:
44 printf("invalid parameter!\n");
46 case DEVICE_ERROR_OPERATION_FAILED:
47 printf("operation failed!\n");
49 case DEVICE_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( (err = device_battery_is_charging(&charging)) < 0){
69 printf("is charging return ");
72 printf("charging state -> %s\n", charging?"charging...":"not charging");
74 if( (err=device_battery_set_cb(battery_cb, "PIUS!!")) < 0){
75 printf("set cb return ");
79 g_main_loop_run(mainloop);
80 g_main_loop_unref(mainloop);
82 if( (err=device_battery_unset_cb()) < 0){
83 printf("unset cb return ");