r1341 - in trunk/src/target/OM-2007/applications/openmoko-today: . src tests

dodji at sita.openmoko.org dodji at sita.openmoko.org
Tue Mar 13 17:51:36 CET 2007


Author: dodji
Date: 2007-03-13 17:51:30 +0100 (Tue, 13 Mar 2007)
New Revision: 1341

Added:
   trunk/src/target/OM-2007/applications/openmoko-today/tests/
   trunk/src/target/OM-2007/applications/openmoko-today/tests/Makefile.am
   trunk/src/target/OM-2007/applications/openmoko-today/tests/ecal-test.c
Modified:
   trunk/src/target/OM-2007/applications/openmoko-today/Makefile.am
   trunk/src/target/OM-2007/applications/openmoko-today/autogen.sh
   trunk/src/target/OM-2007/applications/openmoko-today/configure.ac
   trunk/src/target/OM-2007/applications/openmoko-today/src/Makefile.am
   trunk/src/target/OM-2007/applications/openmoko-today/src/today-main.c
Log:
first attempt at pulling today's event from eds

src/today-main.c: pull all events and quickly show them using the existing infoline widget
tests/ecal-test.c: cooked up some tests to ease ecal functions debugging


Modified: trunk/src/target/OM-2007/applications/openmoko-today/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/Makefile.am	2007-03-13 14:27:40 UTC (rev 1340)
+++ trunk/src/target/OM-2007/applications/openmoko-today/Makefile.am	2007-03-13 16:51:30 UTC (rev 1341)
@@ -1,4 +1,4 @@
-SUBDIRS = src po
+SUBDIRS = src tests po
 
 # Extra clean files so that maintainer-clean removes *everything*
 MAINTAINERCLEANFILES = aclocal.m4 compile config.guess config.sub \

Modified: trunk/src/target/OM-2007/applications/openmoko-today/autogen.sh
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/autogen.sh	2007-03-13 14:27:40 UTC (rev 1340)
+++ trunk/src/target/OM-2007/applications/openmoko-today/autogen.sh	2007-03-13 16:51:30 UTC (rev 1341)
@@ -18,6 +18,6 @@
     echo "You need to install gnome-common from the GNOME CVS"
     exit 1
 }
-USE_GNOME2_MACROS=1 . gnome-autogen.sh
+USE_GNOME2_MACROS=1 . gnome-autogen.sh --prefix=/home/dodji/prefix/om
 
 

Modified: trunk/src/target/OM-2007/applications/openmoko-today/configure.ac
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/configure.ac	2007-03-13 14:27:40 UTC (rev 1340)
+++ trunk/src/target/OM-2007/applications/openmoko-today/configure.ac	2007-03-13 16:51:30 UTC (rev 1341)
@@ -25,11 +25,16 @@
                   libebook-1.2 >= $LIBEBOOK_VERSION
                   libecal-1.2 >= $LIBEBOOK_VERSION)
 
-CFLAGS=$TODAY_CFLAGS
-LIBS=$TODAY_LIBS
+AC_SUBST(TODAY_LIBS)
+AC_SUBST(TODAY_CFLAGS)
 
+if test x$TODAY_DEVEL != x ; then
+    CFLAGS="-Wall -Werror -Wextra -Wshadow -Wpointer-arith -g"
+fi
+
 AC_OUTPUT([
 Makefile
 po/Makefile.in
 src/Makefile
+tests/Makefile
 ])

Modified: trunk/src/target/OM-2007/applications/openmoko-today/src/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/src/Makefile.am	2007-03-13 14:27:40 UTC (rev 1340)
+++ trunk/src/target/OM-2007/applications/openmoko-today/src/Makefile.am	2007-03-13 16:51:30 UTC (rev 1341)
@@ -1,16 +1,16 @@
 INCLUDES = 						\
 	-I$(top_srcdir)
 
-AM_CPPFLAGS=-DPKGDATADIR=\"$(pkgdatadir)\" \
-            -DDATADIR=\""$(datadir)"\"
+AM_CPPFLAGS           =-DPKGDATADIR=\"$(pkgdatadir)\" \
+-DDATADIR=\""$(datadir)"\"
 
-AM_CFLAGS =  -Wall -pedantic -std=c99 $(CFLAGS)
+AM_CFLAGS             = -Wall -pedantic -std=c99 @TODAY_CFLAGS@
 
-bin_PROGRAMS = today
+bin_PROGRAMS          = today
 
-today_SOURCES = today-main.c
+today_SOURCES         = today-main.c
 
-today_LDADD   = $(TODAY_LIBS)
-today_LDFLAGS = @TODAY_LIBS@
+today_LDADD          = @TODAY_LIBS@
 
-MAINTAINERCLEANFILES = config.h.in Makefile.in
+MAINTAINERCLEANFILES  = config.h.in Makefile.in
+

Modified: trunk/src/target/OM-2007/applications/openmoko-today/src/today-main.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/src/today-main.c	2007-03-13 14:27:40 UTC (rev 1340)
+++ trunk/src/target/OM-2007/applications/openmoko-today/src/today-main.c	2007-03-13 16:51:30 UTC (rev 1341)
@@ -128,8 +128,9 @@
   }
 
   query = g_strdup_printf ("(occur-in-time-range? "
-                           "(time-day-begin (time-now)) "
-                           "(time-day-end   (time-now))" ")");
+                               "(time-day-begin (time-now)) "
+                               "(time-day-end   (time-now)) "
+                           ")");
   e_cal_get_object_list (ecal, query, &ical_comps, &error);
   if (error)
   {
@@ -164,16 +165,22 @@
 
 out:
   if (ical_comps)
+  {
     e_cal_free_object_list (ical_comps);
+  }
 
   if (ecal_comps)
+  {
     e_cal_component_list_free (ecal_comps);
+  }
   ecal_comps = NULL;
 
   g_object_unref (G_OBJECT (ecal));
 
   if (error)
+  {
     g_error_free (error);
+  }
 
   g_free (query);
 
@@ -249,6 +256,7 @@
 today_launcher_button_new (gchar * icon, gchar * exec)
 {
   GtkWidget *button = gtk_button_new ();
+  if (exec) {/*unused parameter, to be used in the future*/}
 
   gtk_container_add (GTK_CONTAINER (button),
                      gtk_image_new_from_stock (icon, GTK_ICON_SIZE_BUTTON));
@@ -297,7 +305,9 @@
     infoline = today_infoline_new (GTK_STOCK_NO, "No events for today");
 
   if (events)
+  {
     e_cal_component_list_free (events);
+  }
 
   if (lines)
   {

Added: trunk/src/target/OM-2007/applications/openmoko-today/tests/Makefile.am
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/tests/Makefile.am	2007-03-13 14:27:40 UTC (rev 1340)
+++ trunk/src/target/OM-2007/applications/openmoko-today/tests/Makefile.am	2007-03-13 16:51:30 UTC (rev 1341)
@@ -0,0 +1,4 @@
+noinst_PROGRAMS    = ecaltest
+ecaltest_SOURCES   = ecal-test.c
+ecaltest_LDADD     = @TODAY_LIBS@
+INCLUDES           = -I$(top_srcdir) @TODAY_CFLAGS@

Added: trunk/src/target/OM-2007/applications/openmoko-today/tests/ecal-test.c
===================================================================
--- trunk/src/target/OM-2007/applications/openmoko-today/tests/ecal-test.c	2007-03-13 14:27:40 UTC (rev 1340)
+++ trunk/src/target/OM-2007/applications/openmoko-today/tests/ecal-test.c	2007-03-13 16:51:30 UTC (rev 1341)
@@ -0,0 +1,136 @@
+/*
+ *  Today - At a glance view of date, time, calender events, todo items and
+ *  other images.
+ *
+ * Copyright (C) 2007 by OpenMoko, Inc.
+ * Written by OpenedHand Ltd <info at openedhand.com>
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+#include <libecal/e-cal-component.h>
+#include <libecal/e-cal.h>
+#include <libecal/e-cal-time-util.h>
+
+#define LOG_ERROR \
+g_warning ("Got error '%s', code '%d'", \
+           error->message, error->code);
+
+#define FREE_ERROR g_error_free (error) ; error = NULL ;
+/*static const char *s_query = "" ;*/
+
+void
+display_usage (const char *prog_name)
+{
+    g_return_if_fail (prog_name) ;
+    printf ("usage: %s <query sexpression>\n", prog_name) ;
+    printf ("or: %s\n", prog_name) ;
+}
+
+void
+display_events (GList *a_events/*list of icalcomponents*/)
+{
+    GList          *cur         = NULL ;
+    ECalComponent  *cal_comp    = NULL ;
+    char           *event_str   = NULL ;
+
+    if (!a_events) {
+        g_message ("No events") ;
+        return ;
+    }
+    cal_comp = e_cal_component_new () ;
+    g_return_if_fail (cal_comp) ;
+
+    for (cur = a_events ; cur ; cur = cur->next) {
+        if (!cur->data) {continue;}
+        e_cal_component_set_icalcomponent (cal_comp, cur->data) ;
+        if (e_cal_component_get_vtype (cal_comp) != E_CAL_COMPONENT_EVENT) {
+            g_warning ("component is not an event, rather of type %d",
+                       e_cal_component_get_vtype (cal_comp));
+            continue ;
+        }
+        event_str = e_cal_component_get_as_string (cal_comp) ;
+        if (event_str) {
+            g_message ("Got event '%s'", event_str) ;
+            g_free (event_str) ;
+        }
+    }
+}
+
+int
+main (int argc, char **argv)
+{
+    int            ret       = 0 ;
+    ECal           *cal      = NULL ;
+    char           *query    = NULL ;
+    GList          *objects  = NULL ;
+    GError         *error    = NULL ;
+
+    g_type_init () ;
+
+    if (argc != 1 && (!strcmp (argv[1], "--help") || !strcmp (argv[0], "-h"))) {
+        display_usage (argv[0]) ;
+        return -1 ;
+    }
+
+    cal = e_cal_new_system_calendar () ;
+    g_return_val_if_fail (cal, -1) ;
+    if (!e_cal_open (cal, TRUE, &error)) {
+        g_warning ("failed to open the calendar") ;
+        ret= -1 ;
+    }
+    if (error) {
+        ret = -1 ;
+        LOG_ERROR ;
+        FREE_ERROR ;
+    }
+    if (ret) {goto out ;}
+
+    query = g_strdup_printf ("(occur-in-time-range? "
+                                 "(time-day-begin (time-now)) "
+                                 "(time-day-end   (time-now))"
+                             ")");
+
+    printf ("Issuing query: '%s'\n", query) ;
+    if (!e_cal_get_object_list (cal, query, &objects, &error)) {
+        g_message ("Querying system calendar failed\n") ;
+        ret = -1 ;
+    }
+    if (error) {
+        ret = -1 ;
+        LOG_ERROR ;
+        FREE_ERROR ;
+    }
+    if (ret) {goto out ;}
+    g_message ("Query succeded\n") ;
+    if (objects) {
+        display_events (objects) ;
+    }
+
+out:
+    if (cal) {
+        g_object_unref (G_OBJECT (cal)) ;
+    }
+    if (objects) {
+        e_cal_free_object_list (objects) ;
+    }
+    if (query) {
+        g_free (query) ;
+    }
+    return ret ;
+}





More information about the commitlog mailing list