[maemo-commits] [maemo-commits] r10681 - in projects/haf/trunk/libosso: src ut/misc-test-executables

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed Mar 21 13:59:33 EET 2007
Author: kihamala
Date: 2007-03-21 13:59:32 +0200 (Wed, 21 Mar 2007)
New Revision: 10681

Added:
   projects/haf/trunk/libosso/ut/misc-test-executables/display-sig-test.c
Modified:
   projects/haf/trunk/libosso/src/osso-display.c
Log:
added ut program + fixed minor bug in signal detection


Modified: projects/haf/trunk/libosso/src/osso-display.c
===================================================================
--- projects/haf/trunk/libosso/src/osso-display.c	2007-03-21 11:53:50 UTC (rev 10680)
+++ projects/haf/trunk/libosso/src/osso-display.c	2007-03-21 11:59:32 UTC (rev 10681)
@@ -79,13 +79,13 @@
         }
 
         if (strncmp(s, MCE_DISPLAY_ON_STRING,
-                    strlen(MCE_DISPLAY_ON_STRING)) == 0) {
+                    strlen(MCE_DISPLAY_ON_STRING) + 1) == 0) {
                 new_state = OSSO_DISPLAY_ON;
         } else if (strncmp(s, MCE_DISPLAY_DIM_STRING,
-                           strlen(MCE_DISPLAY_DIM_STRING)) == 0) {
+                           strlen(MCE_DISPLAY_DIM_STRING) + 1) == 0) {
                 new_state = OSSO_DISPLAY_DIMMED;
         } else if (strncmp(s, MCE_DISPLAY_OFF_STRING,
-                           strlen(MCE_DISPLAY_OFF_STRING)) == 0) {
+                           strlen(MCE_DISPLAY_OFF_STRING) + 1) == 0) {
                 new_state = OSSO_DISPLAY_OFF;
         } else {
                 ULOG_ERR_F("Unknown argument: %s", s);
@@ -176,13 +176,13 @@
         }
 
         if (strncmp(tmp, MCE_DISPLAY_ON_STRING,
-                    strlen(MCE_DISPLAY_ON_STRING)) == 0) {
+                    strlen(MCE_DISPLAY_ON_STRING) + 1) == 0) {
             new_state = OSSO_DISPLAY_ON;
         } else if (strncmp(tmp, MCE_DISPLAY_DIM_STRING,
-                           strlen(MCE_DISPLAY_DIM_STRING)) == 0) {
+                           strlen(MCE_DISPLAY_DIM_STRING) + 1) == 0) {
             new_state = OSSO_DISPLAY_DIMMED;
         } else if (strncmp(tmp, MCE_DISPLAY_OFF_STRING,
-                           strlen(MCE_DISPLAY_OFF_STRING)) == 0) {
+                           strlen(MCE_DISPLAY_OFF_STRING) + 1) == 0) {
             new_state = OSSO_DISPLAY_OFF;
         } else {
             ULOG_ERR_F("Unknown argument: %s", tmp);

Added: projects/haf/trunk/libosso/ut/misc-test-executables/display-sig-test.c
===================================================================
--- projects/haf/trunk/libosso/ut/misc-test-executables/display-sig-test.c	2007-03-21 11:53:50 UTC (rev 10680)
+++ projects/haf/trunk/libosso/ut/misc-test-executables/display-sig-test.c	2007-03-21 11:59:32 UTC (rev 10681)
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <glib.h>
+#include <libosso.h>
+
+static GMainLoop *loop;
+
+void cb(osso_display_state_t state, gpointer data)
+{
+        printf("display signal received: %d\n", state);
+}
+
+int main(int argc, char* argv[])
+{
+        osso_context_t *context;
+
+	loop = g_main_loop_new(NULL, 1);
+        context = osso_initialize("displaysigtest", "0.1", 0,
+                                  g_main_loop_get_context(loop));
+
+        osso_hw_set_display_event_cb(context, cb, NULL);
+
+        g_main_loop_run(loop);
+
+        osso_deinitialize(context);
+
+        return 0;
+}


More information about the maemo-commits mailing list