[Xfce4-commits] <orage:master> Version 4.7.5.0: Possibility to use upstream libical code

Juha Kautto noreply at xfce.org
Tue Dec 8 15:08:01 CET 2009


Updating branch refs/heads/master
         to cb970bcdd6282bb4d7f16e8cdbb86263ef30ff96 (commit)
       from 6b5557c7a94bb1ce259306d5e586f901b4a548b0 (commit)

commit cb970bcdd6282bb4d7f16e8cdbb86263ef30ff96
Author: Juha Kautto <juha at xfce.org>
Date:   Tue Dec 8 16:01:58 2009 +0200

    Version 4.7.5.0: Possibility to use upstream libical code
    
    Upstream libical is again active and useable. Made changes to Orage
    so that it is now possible to use it instead of internal version.
    Internal version is still available also.
    
    Also modified make files to work better with new autotools.
    
    Minor tunings to new tray icon also.

 configure.in.in          |   60 +++++++++++++++------
 doc/Makefile.am          |    2 +-
 globaltime/Makefile.am   |   22 ++++----
 panel-plugin/Makefile.am |    3 +-
 src/Makefile.am          |    8 ++-
 src/appointment.c        |   19 +++++++
 src/ical-code.c          |   50 ++++++++++++++---
 src/main.c               |    5 ++
 src/timezone_selection.c |    5 ++
 src/tray_icon.c          |   97 ++++++++++++++++++++--------------
 src/tz_zoneinfo_read.c   |  130 +++++++++++++++++++++++++++++-----------------
 tz_convert/Makefile.am   |    2 +-
 12 files changed, 272 insertions(+), 131 deletions(-)

diff --git a/configure.in.in b/configure.in.in
index 2bc6ea3..c4e69b2 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -9,13 +9,14 @@ dnl Written for Xfce by Juha Kautto <juha at xfce.org>
 dnl
 
 dnl Version information
-m4_define([orage_version], [4.7.4.11-test])
+m4_define([orage_version], [4.7.5.0-git])
 
 m4_define([gtk_minimum_version], [2.10.0])
 m4_define([xfce_minimum_version], [4.6.0])
 m4_define([dbus_minimum_version], [0.34])
 m4_define([notify_minimum_version], [0.3.2])
 m4_define([intltool_minimum_version], [0.31])
+m4_define([libical_minimum_version], [0.43])
 
 
 dnl # DO NOT MODIFY ANYTHING BELOW THIS LINE, UNLESS YOU KNOW WHAT
@@ -23,7 +24,7 @@ dnl # YOU ARE DOING.
 
 
 dnl Initialize autoconf
-AC_COPYRIGHT([Copyright (c) 2003-2007
+AC_COPYRIGHT([Copyright (c) 2003-2010
         The Xfce development team. All rights reserved.
 
 Written for Xfce by Juha Kautto <juha at xfce.org>.])
@@ -52,10 +53,7 @@ AC_PROG_LIBTOOL()
 AC_PROG_YACC()
 AC_PROG_LN_S()
 AM_PROG_LEX()
-
-dnl Check for additional programs (libical)
-AC_CHECK_PROGS([AR], [ar aal], [ar])
-AC_CHECK_PROGS([PERL], [perl5 perl])  
+AM_PROG_CC_C_O()
  
 dnl Check for standard header files
 AC_HEADER_STDC()
@@ -79,8 +77,26 @@ XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [xfce_minimum_version])
 dnl Needed for panel plugin
 XDT_CHECK_PACKAGE([LIBXFCE4PANEL], [libxfce4panel-1.0], [xfce_minimum_version])
 
+dnl *********************************************
+dnl *** Optional support for external libical ***
+dnl *********************************************
+dnl *** This is optional NOW, but will become mandatory after external
+dnl *** libical can do what Orage internal version can do or Orage works
+dnl *** with it.
+XDT_CHECK_OPTIONAL_PACKAGE([LIBICAL], [libical],
+                           [libical_minimum_version], [libical],
+                           [LIBICAL support])
+
+if test x"$LIBICAL_FOUND" = x"yes"; then
+echo "* LIBICAL support:           yes"
+else
+echo "* LIBICAL support:           no"
 dnl the ical magic
 ac_INCLUDED_LIBICAL=yes
+
+dnl Check for additional programs (libical)
+AC_CHECK_PROGS([AR], [ar aal], [ar])
+AC_CHECK_PROGS([PERL], [perl5 perl])  
  
 AC_MSG_CHECKING(for Berkeley DB4 support)
 AC_ARG_WITH(bdb4, [  --with-bdb4             Add support for Berkeley DB 4.0],
@@ -171,6 +187,17 @@ case "${host}" in
   fi;;
 esac
 AC_SUBST([PTHREAD_LIBS])
+LIBICAL_DIRS="
+libical/Makefile
+libical/design-data/Makefile
+libical/doc/Makefile
+libical/scripts/Makefile
+libical/src/Makefile
+libical/src/libical/Makefile
+libical/src/libical/icalversion.h
+libical/src/libicalss/Makefile
+libical/zoneinfo/Makefile"
+fi
 
 dnl **********************************
 dnl *** check if we have _NL_TIME_FIRST_WEEKDAY 
@@ -195,15 +222,17 @@ dnl **********************************
 dnl *** Optional support for D-BUS ***
 dnl **********************************
 XDT_CHECK_OPTIONAL_PACKAGE([DBUS], [dbus-glib-1],
-                           [dbus_minimum_version], [dbus], [D-BUS support])
+                           [dbus_minimum_version], [dbus],
+                           [D-BUS support])
 
 dnl **************************************
 dnl *** Optional support for libnotify ***
 dnl **************************************
 XDT_CHECK_OPTIONAL_PACKAGE([NOTIFY], [libnotify],
-                           [notify_minimum_version], [libnotify], 
+                           [notify_minimum_version], [libnotify],
                            [LIBNOTIFY support])
 
+
 dnl ************************************************
 dnl *** Optional support for automatic archiving ***
 dnl ************************************************
@@ -224,15 +253,7 @@ XDT_FEATURE_DEBUG
 
 AC_OUTPUT([ 
 Makefile
-libical/Makefile
-libical/design-data/Makefile
-libical/doc/Makefile
-libical/scripts/Makefile
-libical/src/Makefile
-libical/src/libical/Makefile
-libical/src/libical/icalversion.h
-libical/src/libicalss/Makefile
-libical/zoneinfo/Makefile
+$LIBICAL_DIRS
 xfcalendar.spec
 icons/Makefile
 icons/48x48/Makefile
@@ -265,5 +286,10 @@ echo "* LIBNOTIFY support:         yes"
 else
 echo "* LIBNOTIFY support:         no"
 fi
+if test x"$LIBICAL_FOUND" = x"yes"; then
+echo "* LIBICAL support:           External package"
+else
+echo "* LIBICAL support:           Orage local"
+fi
 echo "* Automatic archiving:       $have_archive"
 echo
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 3f236c5..259bf9b 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -8,7 +8,7 @@ man_MANS = \
 	orage.1
 
 if MAINTAINER_MODE
-%.1: %.xml
+orage.1: orage.xml
 	xsltproc -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
 endif
 
diff --git a/globaltime/Makefile.am b/globaltime/Makefile.am
index f848d37..2c8b44e 100644
--- a/globaltime/Makefile.am
+++ b/globaltime/Makefile.am
@@ -1,10 +1,20 @@
 bin_PROGRAMS = globaltime
 
+globaltime_SOURCES =						\
+	globaltime.c							\
+	globaltime.h							\
+	gt_parfile.c							\
+	gt_prefs.c								\
+	timezone_selection.c                    \
+	timezone_selection.h                    \
+	tz_zoneinfo_read.c                      \
+	tz_zoneinfo_read.h
+
 man_MANS =                             		 \
 	globaltime.1
 
 if MAINTAINER_MODE
-%.1: %.xml
+globaltime.1: globaltime.xml
 	xsltproc -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
 endif
 
@@ -13,16 +23,6 @@ desktop_in_files = globaltime.desktop.in
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 @INTLTOOL_DESKTOP_RULE@
 
-globaltime_SOURCES =						\
-	globaltime.c							\
-	globaltime.h							\
-	gt_parfile.c							\
-	gt_prefs.c								\
-	timezone_selection.c                    \
-	timezone_selection.h                    \
-	tz_zoneinfo_read.c                      \
-	tz_zoneinfo_read.h
-
 
 globaltime_CFLAGS =							\
 	$(LIBXFCEGUI4_CFLAGS)					\
diff --git a/panel-plugin/Makefile.am b/panel-plugin/Makefile.am
index 35189d8..03a8a70 100644
--- a/panel-plugin/Makefile.am
+++ b/panel-plugin/Makefile.am
@@ -46,7 +46,8 @@ DISTCLEANFILES =							\
 	$(desktop_DATA) $(desktop_in_files)
 	
 # get full path into .desktop file
-%.desktop.in: %.desktop.in.in
+#%.desktop.in: %.desktop.in.in
+xfce4-orageclock-plugin.desktop.in: xfce4-orageclock-plugin.desktop.in.in
 	sed -e "s^@PLUGIN_PATH@^$(libexecdir)/xfce4/panel-plugins^" \
 		$< > $@
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 1f66830..65f5b30 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,14 +36,12 @@ orage_SOURCES =					\
 
 orage_CFLAGS =							\
 	$(LIBXFCEGUI4_CFLAGS)						\
-	$(ICAL_CFLAGS)								\
 	-DPACKAGE_DATA_DIR=\""$(datadir)"\"			\
 	-DPACKAGE_LOCALE_DIR=\""$(localedir)"\"
 
 orage_LDADD =							\
 	$(LIBXFCEGUI4_LIBS)						\
 	$(LIBXFCEUTIL_LIBS)						\
-	$(ICAL_LIBS)							\
 	$(INTLLIBS)
 
 if INCLUDED_LIBICAL
@@ -57,6 +55,12 @@ orage_LDADD +=							\
 	$(PTHREAD_LIBS)											\
 	$(top_builddir)/libical/src/libical/libical.la			\
 	$(top_builddir)/libical/src/libicalss/libicalss.la
+else
+orage_CFLAGS +=							\
+	$(LIBICAL_CFLAGS)
+
+orage_LDADD +=							\
+	$(LIBICAL_LIBS)
 endif
 
 if HAVE_DBUS
diff --git a/src/appointment.c b/src/appointment.c
index f4ecdeb..11845bd 100644
--- a/src/appointment.c
+++ b/src/appointment.c
@@ -1360,7 +1360,14 @@ static xfical_exception *new_exception(char *text)
     }
     else {
         strcpy(recur_exception->type, "EXDATE");
+#ifdef HAVE_LIBICAL
+        /* need to add time also as standard libical can not handle dates
+           correctly yet. Check more from BUG 5764.
+           We use start time from appointment. */
+        strcpy(recur_exception->time, orage_i18_time_to_icaltime(text));
+#else
         strcpy(recur_exception->time, orage_i18_date_to_icaldate(text));
+#endif
     }
     text[i-2] = ' ';
     return(recur_exception);
@@ -1482,7 +1489,19 @@ static void recur_day_selected_double_click_cb(GtkCalendar *calendar
     if (gtk_toggle_button_get_active(
             GTK_TOGGLE_BUTTON(apptw->Recur_exception_excl_rb))) {
         type = "-";
+#ifdef HAVE_LIBICAL
+        /* need to add time also as standard libical can not handle dates
+           correctly yet. Check more from BUG 5764.
+           We use start time from appointment. */
+        hh =  gtk_spin_button_get_value_as_int(
+                GTK_SPIN_BUTTON(apptw->StartTime_spin_hh));
+        mm =  gtk_spin_button_get_value_as_int(
+                GTK_SPIN_BUTTON(apptw->StartTime_spin_mm));
+        cal_date = g_strdup(orage_cal_to_i18_time(calendar, hh, mm));
+#else
+        /* date is enough */
         cal_date = g_strdup(orage_cal_to_i18_date(calendar));
+#endif
     }
     else { /* extra day. This needs also time */
         type = "+";
diff --git a/src/ical-code.c b/src/ical-code.c
index cf99642..fc14e24 100644
--- a/src/ical-code.c
+++ b/src/ical-code.c
@@ -179,15 +179,12 @@ static xfical_timezone_array get_ical_timezones()
             l_tz = (icaltimezone *)icalarray_element_at(tz_array, tz.count);
             /* ical timezones are static so this is safe although not
              * exactly pretty */
-            tz.city[tz.count] = icaltimezone_get_location(l_tz);
+            tz.city[tz.count] = (char *)icaltimezone_get_location(l_tz);
             /*
             g_print(P_N "before %d %s\n", tz.count, tz.city[tz.count]);
             */
             tz.utc_offset[tz.count] = icaltimezone_get_utc_offset(
                     l_tz, &ctime, &tz.dst[tz.count]);
-            /*
-            g_print(P_N "after %d %s offset:%d dst: %d\n", tz.count, tz.city[tz.count], tz.utc_offset[tz.count], tz.dst[tz.count]);
-            */
         }
         tz.utc_offset[tz.count] = 0;
         tz.dst[tz.count] = 0;
@@ -3213,7 +3210,7 @@ static gboolean xfical_mark_calendar_days(GtkCalendar *gtkcal
 
 /* note that this not understand timezones, but gets always raw time,
  * which we need to convert to correct timezone */
-void mark_calendar(icalcomponent *c, struct icaltime_span *span , void *data)
+void mark_calendar(icalcomponent *c, icaltime_span *span , void *data)
 {
 #undef P_N
 #define P_N "mark_calendar: "
@@ -3440,7 +3437,7 @@ void xfical_mark_calendar(GtkCalendar *gtkcal)
 
 /* note that this not understand timezones, but gets always raw time,
  * which we need to convert to correct timezone */
-void add_appt_to_list(icalcomponent *c, struct icaltime_span *span , void *data)
+void add_appt_to_list(icalcomponent *c, icaltime_span *span , void *data)
 {
 #undef P_N
 #define P_N "add_appt_to_list: "
@@ -3453,8 +3450,18 @@ void add_appt_to_list(icalcomponent *c, struct icaltime_span *span , void *data)
     {
         GList **list;
         gchar *file_type;
+#ifdef HAVE_LIBICAL
+        /* Need to check that returned value is withing limits.
+           Check more from BUG 5764. */
+        struct icaltimetype asdate, aedate;
+#endif
     } app_data;
     app_data *data1;
+#ifdef HAVE_LIBICAL
+        /* Need to check that returned value is withing limits.
+           Check more from BUG 5764. */
+    icaltime_span limit_span;
+#endif
 
 #ifdef ORAGE_DEBUG
     orage_message(-100, P_N);
@@ -3474,13 +3481,27 @@ void add_appt_to_list(icalcomponent *c, struct icaltime_span *span , void *data)
     end = icaltime_from_string(orage_tm_time_to_icaltime(&end_tm));
     end = convert_to_zone(end, appt->end_tz_loc);
     end = icaltime_convert_to_zone(end, local_icaltimezone);
+
     strcpy(appt->starttimecur, icaltime_as_ical_string(start));
     strcpy(appt->endtimecur, icaltime_as_ical_string(end));
-    *data1->list = g_list_prepend(*data1->list, appt);
+#ifdef HAVE_LIBICAL
     /*
-    orage_message(10, P_N "Title (%s) Start:%s End:%s \n"
-            , appt->title, appt->starttimecur, appt->endtimecur);
+    orage_message(10, P_N "Title (%s)\n\tfound Start:%s End:%s\n\tlimit Start:%s End:%s"
+            , appt->title, appt->starttimecur, appt->endtimecur, icaltime_as_ical_string(data1->asdate), icaltime_as_ical_string(data1->aedate));
             */
+        /* Need to check that returned value is withing limits.
+           Check more from BUG 5764. */
+    limit_span = icaltime_span_new(data1->asdate, data1->aedate, TRUE);
+    if (!icaltime_span_overlaps(span, &limit_span)) {
+        /* we do not need this. Free the memory */
+        xfical_appt_free(appt);
+        /*
+    orage_message(10, P_N "\n\tDROPped");
+    */
+    } 
+    else /* add to list like with internal libical */
+#endif
+    *data1->list = g_list_prepend(*data1->list, appt);
 }
 
 /* Fetch each appointment within the specified time period and add those
@@ -3502,6 +3523,11 @@ static void xfical_get_each_app_within_time_internal(char *a_day, gint days
     {
         GList **list;
         gchar *file_type;
+#ifdef HAVE_LIBICAL
+        /* Need to check that returned value is withing limits.
+           Check more from BUG 5764. */
+        struct icaltimetype asdate, aedate;
+#endif
     } app_data;
     app_data data1;
 
@@ -3524,6 +3550,12 @@ static void xfical_get_each_app_within_time_internal(char *a_day, gint days
 
     data1.list = data;
     data1.file_type = file_type;
+#ifdef HAVE_LIBICAL
+        /* Need to check that returned value is withing limits.
+           Check more from BUG 5764. */
+    data1.asdate = asdate;
+    data1.aedate = aedate;
+#endif
     for (c = icalcomponent_get_first_component(base, ikind);
          c != 0;
          c = icalcomponent_get_next_component(base, ikind)) {
diff --git a/src/main.c b/src/main.c
index 944544d..8b614e5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -211,6 +211,11 @@ static void print_version(void)
 #else
     g_print(_("\tNot using archiving.\n"));
 #endif
+#ifdef HAVE_LIBICAL
+    g_print(_("\tUsing operating system package libical.\n"));
+#else
+    g_print(_("\tUsing Oracle local version of libical.\n"));
+#endif
     g_print("\n");
 }
 
diff --git a/src/timezone_selection.c b/src/timezone_selection.c
index 44e18a9..7f8318f 100644
--- a/src/timezone_selection.c
+++ b/src/timezone_selection.c
@@ -95,6 +95,7 @@ static GtkTreeStore *tz_button_create_store(gboolean details
     /*
     g_print(P_N "number of timezones %d\n", tz_a.count);
     */
+#ifndef HAVE_LIBICAL
     /* Create special "area" for first level timezones, which do not have
      * any real area */
     gtk_tree_store_append(store, &iter1, NULL);
@@ -106,6 +107,7 @@ static GtkTreeStore *tz_button_create_store(gboolean details
             , COUNTRY, " "
             , -1);
     main = iter1; /* need to remember that */
+#endif
 
     for (i=0; i < tz_a.count-2; i++) {
         /* first check area */
@@ -133,6 +135,9 @@ static GtkTreeStore *tz_button_create_store(gboolean details
                  * plain names on main level. We do this by adding / */
                 area_old[j++] = '/';
                 area_old[j] = 0;
+#ifdef HAVE_LIBICAL
+                main = iter1; /* need to remember that */
+#endif
             }
             else {
                 g_print(P_N "too long line in zones.tab %s", tz_a.city[i]);
diff --git a/src/tray_icon.c b/src/tray_icon.c
index 4e91b38..0a510da 100644
--- a/src/tray_icon.c
+++ b/src/tray_icon.c
@@ -101,59 +101,70 @@ void create_icon_pango_layout(gint line, PangoLayout *pl, struct tm *t
     PangoRectangle real_rect, log_rect;
     gint x_size;
     gboolean first_try = TRUE, done = FALSE;
+    gchar *row1_1_data = "%^A";
+    gchar *row1_1b_data = "%A";
+    gchar *row1_2_data = "%^a";
+    gchar *row1_2b_data = "%a";
+    gchar *row1_color = "black";
+    gchar *row1_font = "Ariel bold 24";
+    gchar *row2_color = "red";
+    gchar *row2_font = "Sans bold 72";
+    gchar *row3_1_data = "%^B";
+    gchar *row3_1b_data = "%B";
+    gchar *row3_2_data = "%^b";
+    gchar *row3_2b_data = "%b";
+    gchar *row3_color = "black";
+    gchar *row3_font = "Ariel bold 26";
+    gchar *row_format = "<span foreground=\"%s\" font_desc=\"%s\">%s</span>";
+    gchar *strfttime_failed = "create_icon_pango_layout: strftime %s failed";
 
     while (!done) {
         switch (line) {
             case 1:
                 if (first_try) {
-                    if (strftime(row, 19, "%^A", t) == 0) {
-                        g_warning("create_icon_pango_layout: strftime %%^A failed");
-                        if (strftime(row, 19, "%A", t) == 0) {
-                            g_warning("create_icon_pango_layout: strftime %%A failed");
+                    if (strftime(row, 19, row1_1_data, t) == 0) {
+                        g_warning(strfttime_failed, row1_1_data);
+                        if (strftime(row, 19, row1_1b_data, t) == 0) {
+                            g_warning(strfttime_failed, row1_1b_data);
                             g_sprintf(row, "orage");
                         }
                     }
                 }
                 else { /* we failed once, let's try shorter string */
-                    if (strftime(row, 19, "%^a", t) == 0) {
-                        g_warning("create_icon_pango_layout: strftime %%^a failed");
-                        if (strftime(row, 19, "%a", t) == 0) {
-                            g_warning("create_icon_pango_layout: strftime %%a failed");
+                    if (strftime(row, 19, row1_2_data, t) == 0) {
+                        g_warning(strfttime_failed, row1_2_data);
+                        if (strftime(row, 19, row1_2b_data, t) == 0) {
+                            g_warning(strfttime_failed, row1_2b_data);
                             g_sprintf(row, "orage");
                         }
                     }
                 }
-                g_snprintf(ts, 199
-                        , "<span foreground=\"black\" font_desc=\"Ariel bold 20\">%s</span>"
-                        , row);
+                g_snprintf(ts, 199, row_format, row1_color, row1_font, row);
                 break;
             case 2:
-                g_snprintf(ts, 199
-                        , "<span foreground=\"red\" font_desc=\"Sans bold 72\">%02d</span>"
-                        , t->tm_mday);
+                g_snprintf(row, 19, "%02d", t->tm_mday);
+                g_snprintf(ts, 199, row_format, row2_color, row2_font, row);
                 break;
             case 3:
                 if (first_try) {
-                    if (strftime(row, 19, "%^B", t) == 0) {
-                        g_warning("create_icon_pango_layout: strftime %%^B failed");
-                        if (strftime(row, 19, "%B", t) == 0) {
-                            g_warning("create_icon_pango_layout: strftime %%B failed");
+                    if (strftime(row, 19, row3_1_data, t) == 0) {
+                        g_warning(strfttime_failed, row3_1_data);
+                        if (strftime(row, 19, row3_1b_data, t) == 0) {
+                            g_warning(strfttime_failed, row3_1b_data);
                             g_sprintf(row, "orage");
                         }
                     }
                 }
                 else { /* we failed once, let's try shorter string */
-                    if (strftime(row, 19, "%^b", t) == 0) {
-                        g_warning("create_icon_pango_layout: strftime %%^b failed");
-                        if (strftime(row, 19, "%b", t) == 0) {
-                            g_warning("create_icon_pango_layout: strftime %%b failed");
+                    if (strftime(row, 19, row3_2_data, t) == 0) {
+                        g_warning(strfttime_failed, row3_2_data);
+                        if (strftime(row, 19, row3_2b_data, t) == 0) {
+                            g_warning(strfttime_failed, row3_2b_data);
                             g_sprintf(row, "orage");
                         }
                     }
                 }
-                g_snprintf(ts, 199
-                        , "<span foreground=\"black\" font_desc=\"Ariel bold 24\">%s</span>"
-                        , row);
+                g_snprintf(ts, 199, row_format, row3_color, row3_font, row);
                 break;
             default:
                 g_warning("create_icon_pango_layout: wrong line number %d", line);
@@ -171,11 +182,25 @@ void create_icon_pango_layout(gint line, PangoLayout *pl, struct tm *t
         *y_size = PANGO_PIXELS(log_rect.height);
         *x_offset = (width - x_size)/2;
         if (line == 1)
-            *y_offset = 2; /* we have 1 pixel border line */
+            *y_offset = 4; /* we have 1 pixel border line */
         else if (line == 2)
-            *y_offset = (height - *y_size)/2;
+            *y_offset = (height - *y_size + 2)/2;
         else if (line == 3)
             *y_offset = (height - *y_size);
+        /*
+    g_print("\n\norage row %d offset. First trial %d\n"
+            "width=%d x-offset=%d\n"
+            "\t(real pixel text width=%d logical pixel text width=%d)\n"
+            "height=%d y-offset=%d\n"
+            "\t(real pixel text height=%d logical pixel text height=%d)\n"
+            "\n" 
+            , line, first_try
+            , width, *x_offset
+            , PANGO_PIXELS(real_rect.width), x_size
+            , height, *y_offset
+            , PANGO_PIXELS(real_rect.height), *y_size
+            ); 
+            */
         if (*x_offset < 0) { /* it does not fit */
             if (first_try) {
                 first_try = FALSE;
@@ -189,20 +214,6 @@ void create_icon_pango_layout(gint line, PangoLayout *pl, struct tm *t
             done = TRUE;
     }
     /*
-    g_print("\n\norage row %d offset\n"
-            "width=%d x-offset=%d\n"
-            "\t(real pixel text width=%d logical pixel text width=%d)\n"
-            "height=%d y-offset=%d\n"
-            "\t(real pixel text height=%d logical pixel text height=%d)\n"
-            "\n" 
-            , line
-            , width, *x_offset
-            , PANGO_PIXELS(real_rect.width), x_size
-            , height, *y_offset
-            , PANGO_PIXELS(real_rect.height), *y_size
-            ); 
-            */
-    /*
     gdk_draw_rectangle(pic1, pic1_gc2, FALSE
             , *x_offset+(x_size-PANGO_PIXELS(real_rect.width))/2
             , *y_offset+(*y_size-PANGO_PIXELS(real_rect.height))/2
@@ -249,6 +260,10 @@ GdkPixbuf *orage_create_icon(gboolean static_icon, gint size)
     depth = pic1_vis->depth;
     pic1 = gdk_pixmap_new(NULL, width, height, depth);
     gdk_drawable_set_colormap(pic1, pic1_cmap);
+    /*
+    pic1 = gdk_pixmap_colormap_create_from_xpm(NULL, pic1_cmap, NULL, NULL
+            , "/home/juha/ohjelmat/Orage/dev/orage/icons/orage.xpm");
+    */
     /* pic1_cmap = gtk_widget_get_colormap(xfcal->mWindow); */
     pic1_gc1 = gdk_gc_new(pic1);
     pic1_gc2 = gdk_gc_new(pic1);
diff --git a/src/tz_zoneinfo_read.c b/src/tz_zoneinfo_read.c
index 508b427..c89950a 100644
--- a/src/tz_zoneinfo_read.c
+++ b/src/tz_zoneinfo_read.c
@@ -19,6 +19,10 @@
         Boston, MA 02110-1301 USA
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <error.h>
 #include <errno.h>
     /* errno */
@@ -46,7 +50,7 @@
  * Documentation says the define is _XOPEN_SOURCE, but it
  * does not work. __USE_XOPEN_EXTENDED works 
  * Same with _GNU_SOURCE and __USE_GNU */
-#define _XOPEN_SOURCE 500
+/* #define _XOPEN_SOURCE 500 */
 #define __USE_XOPEN_EXTENDED 1
 #define _GNU_SOURCE 1
 #define __USE_GNU 1
@@ -132,13 +136,19 @@ static void read_file(const char *file_name, const struct stat *file_stat)
     if (debug > 1) {
         printf("read_file: start\n");
         printf("\n***** size of file %s is %d bytes *****\n\n", file_name
-                , file_stat->st_size);
+                , (int)file_stat->st_size);
     }
     in_buf = malloc(file_stat->st_size);
     in_head = in_buf;
     in_tail = in_buf + file_stat->st_size - 1;
     file = fopen(file_name, "r");
-    fread(in_buf, 1, file_stat->st_size, file);
+    if (!fread(in_buf, 1, file_stat->st_size, file))
+        if (ferror(file)) {
+            printf("read_file: file read failed (%s)\n", file_name);
+            fclose(file);
+            perror("\tfread");
+            return;
+        }
     fclose(file);
     if (debug > 1)
         printf("read_file: end\n");
@@ -168,22 +178,22 @@ static int process_header()
     in_head += 16; /* reserved */
     gmtcnt  = get_long();
     if (debug > 2)
-        printf("gmtcnt=%u \n", gmtcnt);
+        printf("gmtcnt=%lu \n", gmtcnt);
     stdcnt  = get_long();
     if (debug > 2)
-        printf("stdcnt=%u \n", stdcnt);
+        printf("stdcnt=%lu \n", stdcnt);
     leapcnt = get_long();
     if (debug > 2)
-        printf("leapcnt=%u \n", leapcnt);
+        printf("leapcnt=%lu \n", leapcnt);
     timecnt = get_long();
     if (debug > 2)
-        printf("number of time changes: timecnt=%u \n", timecnt);
+        printf("number of time changes: timecnt=%lu \n", timecnt);
     typecnt = get_long();
     if (debug > 2)
-        printf("number of time change types: typecnt=%u \n", typecnt);
+        printf("number of time change types: typecnt=%lu \n", typecnt);
     charcnt = get_long();
     if (debug > 2)
-        printf("lenght of different timezone names table: charcnt=%u \n"
+        printf("lenght of different timezone names table: charcnt=%lu \n"
                 , charcnt);
     return(0);
 }
@@ -199,9 +209,9 @@ static process_local_time_table()
     for (i = 0; i < timecnt; i++) {
         tmp = get_long();
         if (debug > 3) {
-            printf("GMT %d: %u =  %s", i, tmp
+            printf("GMT %d: %lu =  %s", i, tmp
                     , asctime(gmtime((const time_t*)&tmp)));
-            printf("\tLOC %d: %u =  %s", i, tmp
+            printf("\tLOC %d: %lu =  %s", i, tmp
                     , asctime(localtime((const time_t*)&tmp)));
         }
     }
@@ -239,7 +249,7 @@ static process_ttinfo_table()
         tmp3 = in_head[0];
         in_head++;
         if (debug > 3)
-            printf("%d: gmtoffset:%d isdst:%d abbr:%d\n", i, tmp
+            printf("%d: gmtoffset:%ld isdst:%d abbr:%d\n", i, tmp
                     , (unsigned int)tmp2, (unsigned int)tmp3);
     }
 }
@@ -272,7 +282,7 @@ static process_leap_table()
         tmp = get_long();
         tmp2 = get_long();
         if (debug > 3)
-            printf("leaps %d: %u =  %s (%u)", i, tmp
+            printf("leaps %d: %lu =  %s (%lu)", i, tmp
                     , asctime(localtime((const time_t *)&tmp)), tmp2);
     }
 }
@@ -376,12 +386,22 @@ static void get_country()
 static int timezone_exists_in_ical()
 { /* in_timezone_name contains the timezone name.
      We will search if it exists also in the ical zones.tab file */
+  /* new libical checks os zone.tab file, so we need to use that if using
+     that library instead of our own private libical */
     char *str;
 
+#ifdef HAVE_LIBICAL
+    if ((str = strchr(in_timezone_name, '/')) 
+    &&  (str = strstr(zone_tab_buf, in_timezone_name)))
+        return(1); /* yes, it is there */
+    else
+        return(0); /* not found */
+#else
     if (str = strstr(zones_tab_buf, in_timezone_name))
         return(1); /* yes, it is there */
     else
         return(0); /* not found */
+#endif
 }
 
 /* FIXME: need to check that if OUTFILE is given as a parameter,
@@ -593,8 +613,8 @@ static int check_parameters()
         }
         else { /* no errors */
             in_file = malloc(par_file_stat.st_size+1);
-            fread(in_file, 1, par_file_stat.st_size, par_file);
-            if (ferror(par_file)) {
+            if (!fread(in_file, 1, par_file_stat.st_size, par_file)
+            && (ferror(par_file))) {
                 printf("check_parameters: error reading (%s)\n"
                         , TZ_CONVERT_PAR_FILE_LOC);
                 free(in_file);
@@ -703,13 +723,17 @@ static int check_parameters()
     return(0); /* continue */
 }
 
-static void read_countries()
+static void read_os_timezones()
 {
-    char *tz_dir, *zone_tab_file_name, *country_file_name;
+    char *tz_dir, *zone_tab_file_name;
     int zoneinfo_len=strlen("zoneinfo/");
-    FILE *zone_tab_file, *country_file;
-    struct stat zone_tab_file_stat, country_file_stat;
+    FILE *zone_tab_file;
+    struct stat zone_tab_file_stat;
 
+    /****** zone.tab file ******/
+    if (zone_tab_buf) {
+        return;
+    }
     tz_dir = malloc(in_file_base_offset + zoneinfo_len + 1); /* '\0' */
     strncpy(tz_dir, in_file, in_file_base_offset);
     tz_dir[in_file_base_offset] = '\0'; 
@@ -719,47 +743,29 @@ static void read_countries()
     strcpy(zone_tab_file_name, tz_dir);
     strcat(zone_tab_file_name, ZONETAB_FILE);
 
-    country_file_name = malloc(strlen(tz_dir) + strlen(COUNTRY_FILE) + 1);
-    strcpy(country_file_name, tz_dir);
-    strcat(country_file_name, COUNTRY_FILE);
-
-    /*
-    printf("read_countries: tzdir:(%s) zone.tab:(%s) iso.tab:(%s)\n"
-            , tz_dir, zone_tab_file_name, country_file_name);
-    */
-
     free(tz_dir);
 
-    /****** zone.tab file ******/
-    if (zone_tab_buf) {
-        free(zone_tab_file_name);
-        free(country_file_name);
-        return;
-    }
     if (!(zone_tab_file = fopen(zone_tab_file_name, "r"))) {
-        printf("read_countries: zone.tab file open failed (%s)\n"
+        printf("read_os_timezones: zone.tab file open failed (%s)\n"
                 , zone_tab_file_name);
         free(zone_tab_file_name);
-        free(country_file_name);
         perror("\tfopen");
         return;
     }
     if (stat(zone_tab_file_name, &zone_tab_file_stat) == -1) {
-        printf("read_countries: zone.tab file stat failed (%s)\n"
+        printf("read_os_timezones: zone.tab file stat failed (%s)\n"
                 , zone_tab_file_name);
         free(zone_tab_file_name);
-        free(country_file_name);
         fclose(zone_tab_file);
         perror("\tstat");
         return;
     }
     zone_tab_buf = malloc(zone_tab_file_stat.st_size+1);
-    fread(zone_tab_buf, 1, zone_tab_file_stat.st_size, zone_tab_file);
-    if (ferror(zone_tab_file)) {
-        printf("read_countries: zone.tab file read failed (%s)\n"
+    if (!fread(zone_tab_buf, 1, zone_tab_file_stat.st_size, zone_tab_file)
+    && (ferror(zone_tab_file))) {
+        printf("read_os_timezones: zone.tab file read failed (%s)\n"
                 , zone_tab_file_name);
         free(zone_tab_file_name);
-        free(country_file_name);
         fclose(zone_tab_file);
         perror("\tfread");
         return;
@@ -767,8 +773,27 @@ static void read_countries()
     zone_tab_buf[zone_tab_file_stat.st_size] = '\0';
     free(zone_tab_file_name);
     fclose(zone_tab_file);
+}
+
+static void read_countries()
+{
+    char *tz_dir, *country_file_name;
+    int zoneinfo_len=strlen("zoneinfo/");
+    FILE *country_file;
+    struct stat country_file_stat;
 
     /****** country=iso3166.tab file ******/
+    tz_dir = malloc(in_file_base_offset + zoneinfo_len + 1); /* '\0' */
+    strncpy(tz_dir, in_file, in_file_base_offset);
+    tz_dir[in_file_base_offset] = '\0'; 
+    strcat(tz_dir, "zoneinfo/"); /* now we have the base directory */
+
+    country_file_name = malloc(strlen(tz_dir) + strlen(COUNTRY_FILE) + 1);
+    strcpy(country_file_name, tz_dir);
+    strcat(country_file_name, COUNTRY_FILE);
+
+    free(tz_dir);
+
     if (country_buf) {
         free(country_file_name);
         return;
@@ -789,8 +814,8 @@ static void read_countries()
         return;
     }
     country_buf = malloc(country_file_stat.st_size+1);
-    fread(country_buf, 1, country_file_stat.st_size, country_file);
-    if (ferror(country_file)) {
+    if (fread(country_buf, 1, country_file_stat.st_size, country_file)
+    && (ferror(country_file))) {
         printf("read_countries: iso3166.tab file read failed (%s)\n"
                 , country_file_name);
         free(country_file_name);
@@ -823,16 +848,18 @@ static void read_ical_timezones()
         return;
     }
     zones_tab_buf = malloc(zones_tab_file_stat.st_size+1);
-    fread(zones_tab_buf, 1, zones_tab_file_stat.st_size, zones_tab_file);
-    if (ferror(zones_tab_file)) {
+    if (!fread(zones_tab_buf, 1, zones_tab_file_stat.st_size, zones_tab_file)
+    && (ferror(zones_tab_file))) {
         printf("read_ical_timezones: zones.tab file read failed (%s)\n"
                 , ICAL_ZONES_TAB_FILE_LOC);
         perror("\tfread");
         return;
     }
     zones_tab_buf[zones_tab_file_stat.st_size] = '\0';
+    /*
     printf("read_ical_timezones: zones.tab file read (%s) (%d bytes)\n"
                 , ICAL_ZONES_TAB_FILE_LOC, strlen(zones_tab_buf));
+                */
     fclose(zones_tab_file);
 }
 
@@ -863,10 +890,17 @@ orage_timezone_array get_orage_timezones(int show_details, int ical)
         check_parameters();
         if (debug > 0)
             printf("Processing %s files\n", in_file);
-        if (details)
+        if (details) {
+            read_os_timezones();
             read_countries();
-        if (check_ical)
+        }
+        if (check_ical) {
+#ifdef HAVE_LIBICAL
+            read_os_timezones();
+#else
             read_ical_timezones();
+#endif
+        }
         if (nftw(in_file, file_call, 10, FTW_PHYS | FTW_ACTIONRETVAL) == -1) {
             perror("nftw error in file handling");
             exit(EXIT_FAILURE);
diff --git a/tz_convert/Makefile.am b/tz_convert/Makefile.am
index 7d1a58c..a71dd5b 100644
--- a/tz_convert/Makefile.am
+++ b/tz_convert/Makefile.am
@@ -4,7 +4,7 @@ man_MANS =                             		 \
 	tz_convert.1
 
 if MAINTAINER_MODE
-%.1: %.xml
+tz_convert.1: tz_convert.xml
 	xsltproc -nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
 endif
 



More information about the Xfce4-commits mailing list