r2777 - in trunk/src/target/OM-2007.2/applications/openmoko-dialer2: . src

njp at sita.openmoko.org njp at sita.openmoko.org
Wed Aug 22 16:06:57 CEST 2007


Author: njp
Date: 2007-08-22 16:06:56 +0200 (Wed, 22 Aug 2007)
New Revision: 2777

Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
   trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c
Log:
2007-08-22  Neil J. Patel  <njp at o-hand.com>
	
	* src/moko-notify.c: (moko_notify_check_brightness):
	Some fixes to the brightness manipulation.

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-08-22 13:37:19 UTC (rev 2776)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog	2007-08-22 14:06:56 UTC (rev 2777)
@@ -1,5 +1,10 @@
 2007-08-22  Neil J. Patel  <njp at o-hand.com>
+	
+	* src/moko-notify.c: (moko_notify_check_brightness):
+	Some fixes to the brightness manipulation.
 
+2007-08-22  Neil J. Patel  <njp at o-hand.com>
+
 	* src/moko-dialer.c: (on_incoming_clip):
 	* src/moko-notify.c: (moko_notify_check_brightness):
 	Use the right device to set brightness.

Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c	2007-08-22 13:37:19 UTC (rev 2776)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c	2007-08-22 14:06:56 UTC (rev 2777)
@@ -66,7 +66,9 @@
 {
   gint fd;
   gchar buf[50];
-  gint brightness, len;
+  GIOChannel *dev;
+  gsize bytes = 0;
+  GError *err = NULL;
 
   fd = g_open (SYS_BRIGHTNESS"/brightness", O_WRONLY, 0);
   if (fd == -1)
@@ -74,26 +76,28 @@
     g_warning ("Unable to open brightness device");
     return;
   }
+  
+  dev = g_io_channel_unix_new (fd);
 
-  
-  if (read (fd, buf, sizeof (buf)) == -1)
+  if (g_io_channel_read_chars (dev, buf, 50, &bytes, &err) 
+        == G_IO_STATUS_NORMAL)
   {
-    close (fd);
-    g_warning ("Unable to read from brightness device");
-    return;
+    buf[bytes] = '\0';
+    g_print ("%s\n", buf);
   }
-  brightness = atoi (buf);
-  g_print ("Brightness = %d\n", brightness);
-  /*
-  brightness = 0;
-  if (brightness >= 5000)
+  else
   {
-    close (fd);
-    return;
+    g_warning (err->message);
+    g_error_free (err);
   }
-  */
-  len = g_sprintf (buf, "%d", 5000);
-  write (fd, buf, len);
+  err = NULL;
+  if (g_io_channel_write_chars (dev, "5000", -1, &bytes, &err)
+        != G_IO_STATUS_NORMAL)
+  {
+    g_warning (err->message);
+    g_error_free (err);
+  }
+  g_io_channel_shutdown (dev, TRUE, NULL);
   close (fd);
 }
 





More information about the commitlog mailing list