Enlightenment CVS committal

Author  : raster
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/modules/battery


Modified Files:
        batget.c 


Log Message:


suspend/resume brokeon power class - lost event file node and never got it
back. now try get them all back if they get lost.

===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/battery/batget.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -3 -r1.10 -r1.11
--- batget.c    30 Apr 2008 05:33:44 -0000      1.10
+++ batget.c    4 May 2008 06:13:26 -0000       1.11
@@ -442,6 +442,33 @@
    return 0;
 }
 
+static Ecore_Timer *re_init_timer = NULL;
+
+static int
+linux_sys_class_powe_supply_cb_re_init(void *data)
+{
+   Sys_Class_Power_Supply_Uevent *sysev;
+   
+   if (events)
+     {
+       while ((sysev = ecore_list_first_goto(events)))
+         {
+            ecore_list_remove(events);
+            
+            if (sysev->fd_handler)
+              ecore_main_fd_handler_del(sysev->fd_handler);
+            if (sysev->fd >= 0) close(sysev->fd);
+            free(sysev->name);
+            free(sysev);
+         }
+       ecore_list_destroy(events);
+       events = NULL;
+     }
+   linux_sys_class_power_supply_init();
+   re_init_timer = NULL;
+   return 0;
+}     
+
 static int
 linux_sys_class_power_supply_cb_event_fd_active(void *data, Ecore_Fd_Handler 
*fd_handler)
 {
@@ -477,6 +504,9 @@
             if (sysev->fd >= 0) close(sysev->fd);
             free(sysev->name);
             free(sysev);
+            
+            if (re_init_timer) ecore_timer_del(re_init_timer);
+            re_init_timer = ecore_timer_add(1.0, 
linux_sys_class_powe_supply_cb_re_init, NULL);
          }
        else
          {
@@ -633,6 +663,7 @@
        Sys_Class_Power_Supply_Uevent *sysev;
        int total_pwr_now;
        int total_pwr_max;
+       int nofull = 0;
        
        total_pwr_now = 0;
        total_pwr_max = 0;
@@ -694,6 +725,7 @@
              * wrong. that's a buggy battery or driver */
             if (!full)
               {
+                 nofull++;
                  if (charging)
                    {
                       snprintf(buf, sizeof(buf), 
"/sys/class/power_supply/%s/time_to_full_now", name);
@@ -764,12 +796,13 @@
                         }
                    }
               }
-            
             total_pwr_now += pwr_now - pwr_empty;
             total_pwr_max += pwr_full - pwr_empty;
          }
        if (total_pwr_max > 0)
          battery_full = ((long long)total_pwr_now * 100) / total_pwr_max;
+       if (nofull == 0)
+         time_left = -1;
      }
 }
 



-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to