14035Sphitran /*************************************************************************** 24035Sphitran * 34035Sphitran * addon-acpi.c : Poll battery and AC adapter devices and update 44035Sphitran * properties 54035Sphitran * 6*6573Sphitran * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 74035Sphitran * Use is subject to license terms. 84035Sphitran * 94035Sphitran * Licensed under the Academic Free License version 2.1 104035Sphitran * 114035Sphitran **************************************************************************/ 124035Sphitran 134035Sphitran #pragma ident "%Z%%M% %I% %E% SMI" 144035Sphitran 154035Sphitran #ifdef HAVE_CONFIG_H 164035Sphitran #include <config.h> 174035Sphitran #endif 184035Sphitran 194035Sphitran #include <stdio.h> 204035Sphitran #include <unistd.h> 214035Sphitran #include <stdlib.h> 224035Sphitran #include <fcntl.h> 234035Sphitran #include <sys/dkio.h> 244035Sphitran #include <sys/stat.h> 254035Sphitran #include <glib.h> 264035Sphitran 274035Sphitran #include <libhal.h> 284035Sphitran #include "../../hald/logger.h" 294035Sphitran #include "../../hald/util_helper.h" 30*6573Sphitran #include "../../utils/acpi.h" 314035Sphitran 324035Sphitran int main(int argc,char ** argv)334035Sphitranmain(int argc, char **argv) 344035Sphitran { 354035Sphitran LibHalContext *ctx = NULL; 364035Sphitran DBusError error; 374035Sphitran 384035Sphitran GMainLoop *loop = g_main_loop_new(NULL, FALSE); 394035Sphitran 404035Sphitran drop_privileges(0); 414035Sphitran setup_logger(); 424035Sphitran 434035Sphitran dbus_error_init(&error); 444035Sphitran if ((ctx = libhal_ctx_init_direct(&error)) == NULL) { 454035Sphitran printf("main(): init_direct failed\n"); 464035Sphitran return (0); 474035Sphitran } 484035Sphitran dbus_error_init(&error); 494035Sphitran if (!libhal_device_addon_is_ready(ctx, getenv("UDI"), &error)) { 504035Sphitran return (0); 514035Sphitran } 524035Sphitran 534035Sphitran g_timeout_add(BATTERY_POLL_TIMER, update_devices, ctx); 544035Sphitran 554035Sphitran g_main_loop_run(loop); 564035Sphitran } 57