[Xfce4-commits] <orage:master> 4.8.2.5: Fixed bug 8121 Orage is unable to process read-only foreign files.

Juha Kautto noreply at xfce.org
Fri Nov 25 14:32:02 CET 2011


Updating branch refs/heads/master
         to 29c33f40d79391b8eda07baaa341396926b4e89e (commit)
       from 57318457d2eb6dc7124192049a3df954d28e2955 (commit)

commit 29c33f40d79391b8eda07baaa341396926b4e89e
Author: Juha Kautto <juha at xfce.org>
Date:   Fri Nov 25 15:25:18 2011 +0200

    4.8.2.5: Fixed bug 8121 Orage is unable to process read-only foreign files.
    
    Orage can now work with read-only files in the file system. It opens files
    for reading only when read-only flag is set. Error messages are still bad
    and modifications should be prevented earlier.
    Also prevented double tray icon updates after suspend by delaying the
    update code.

 configure.in.in     |    2 +-
 src/functions.c     |   13 ++++---------
 src/ical-archive.c  |    2 +-
 src/ical-code.c     |   19 +++++++++++++------
 src/ical-expimp.c   |   10 ++++++----
 src/ical-internal.h |    3 ++-
 src/main.c          |   17 +++++++++++++----
 src/parameters.c    |    4 +++-
 src/parameters.h    |    2 +-
 src/reminder.c      |    8 ++++++--
 10 files changed, 50 insertions(+), 30 deletions(-)

diff --git a/configure.in.in b/configure.in.in
index 61e13a3..a0bee12 100644
--- a/configure.in.in
+++ b/configure.in.in
@@ -9,7 +9,7 @@ dnl Written for Xfce by Juha Kautto <juha at xfce.org>
 dnl
 
 dnl Version information
-m4_define([orage_version], [4.8.2.4-git])
+m4_define([orage_version], [4.8.2.5-git])
 
 m4_define([gtk_minimum_version], [2.10.0])
 m4_define([xfce_minimum_version], [4.6.0])
diff --git a/src/functions.c b/src/functions.c
index 3587a1d..5e31802 100644
--- a/src/functions.c
+++ b/src/functions.c
@@ -89,6 +89,7 @@ void orage_message(gint level, const char *format, ...)
 {
     va_list args;
     char *formatted;
+    struct tm *t = orage_localtime();
 
     if (level < g_log_level)
         return;
@@ -96,15 +97,9 @@ void orage_message(gint level, const char *format, ...)
     formatted = g_strdup_vprintf(format, args);
     va_end(args);
 
-    if (level < 0) {
-        if (g_log_level < -1000) {
-            struct tm *t = orage_localtime();
-            
-            g_debug("%d:%d:%d %s", t->tm_hour, t->tm_min, t->tm_sec, formatted);
-        }
-        else
-            g_debug("%s", formatted);
-    }
+    g_print("%02d:%02d:%02d ", t->tm_hour, t->tm_min, t->tm_sec);
+    if (level < 0)
+        g_debug("%s", formatted);
     else if (level < 100) 
         g_message("Orage **: %s", formatted);
     else if (level < 200) 
diff --git a/src/ical-archive.c b/src/ical-archive.c
index ec266c3..9585de6 100644
--- a/src/ical-archive.c
+++ b/src/ical-archive.c
@@ -101,7 +101,7 @@ gboolean xfical_archive_open(void)
         return(FALSE);
 
     return(ic_internal_file_open(&ic_aical, &ic_afical, g_par.archive_file
-            , FALSE));
+            , FALSE, FALSE));
 }
 #endif
 
diff --git a/src/ical-code.c b/src/ical-code.c
index bcf536a..1015e5d 100644
--- a/src/ical-code.c
+++ b/src/ical-code.c
@@ -279,7 +279,8 @@ static void xfical_add_timezone(icalcomponent *p_ical, icalset *p_fical
 */
 
 gboolean ic_internal_file_open(icalcomponent **p_ical
-        , icalset **p_fical, gchar *file_icalpath, gboolean test)
+        , icalset **p_fical, gchar *file_icalpath, gboolean read_only
+        , gboolean test)
 {
 #undef P_N
 #define P_N "ic_internal_file_open: "
@@ -311,7 +312,11 @@ gboolean ic_internal_file_open(icalcomponent **p_ical
             orage_message(350, P_N "file empty");
         return(FALSE);
     }
-    if ((*p_fical = icalset_new_file(file_icalpath)) == NULL) {
+    if (read_only)
+        *p_fical = icalset_new_file_reader(file_icalpath);
+    else 
+        *p_fical = icalset_new_file(file_icalpath);
+    if (*p_fical == NULL) {
         if (test)
             orage_message(150, P_N "Could not open ical file (%s) %s"
                     , file_icalpath, icalerror_strerror(icalerrno));
@@ -381,11 +386,13 @@ gboolean xfical_file_open(gboolean foreign)
 #ifdef ORAGE_DEBUG
     orage_message(-100, P_N);
 #endif
-    ok = ic_internal_file_open(&ic_ical, &ic_fical, g_par.orage_file, FALSE);
+    ok = ic_internal_file_open(&ic_ical, &ic_fical, g_par.orage_file, FALSE
+            , FALSE);
     if (ok && foreign) /* let's open foreign files */
         for (i = 0; i < g_par.foreign_count; i++) {
-            ok = ic_internal_file_open(&(ic_f_ical[i].ical), &(ic_f_ical[i].fical)
-                    , g_par.foreign_data[i].file, FALSE);
+            ok = ic_internal_file_open(&(ic_f_ical[i].ical)
+                    , &(ic_f_ical[i].fical), g_par.foreign_data[i].file
+                    , g_par.foreign_data[i].read_only , FALSE);
             if (!ok) {
                 ic_f_ical[i].ical = NULL;
                 ic_f_ical[i].fical = NULL;
@@ -404,7 +411,7 @@ gboolean xfical_file_check(gchar *file_name)
 #ifdef ORAGE_DEBUG
     orage_message(-100, P_N);
 #endif
-    return(ic_internal_file_open(&x_ical, &x_fical, file_name, TRUE));
+    return(ic_internal_file_open(&x_ical, &x_fical, file_name, FALSE, TRUE));
 }
 
 static gboolean delayed_file_close(gpointer user_data)
diff --git a/src/ical-expimp.c b/src/ical-expimp.c
index 2db9fe3..29adb1b 100644
--- a/src/ical-expimp.c
+++ b/src/ical-expimp.c
@@ -92,7 +92,8 @@ typedef struct _foreign_ical_files
 extern ic_foreign_ical_files ic_f_ical[10];
 
 gboolean ic_internal_file_open(icalcomponent **p_ical
-                , icalset **p_fical, gchar *file_icalpath, gboolean test);
+                , icalset **p_fical, gchar *file_icalpath, gboolean read_only
+                , gboolean test);
 
 static gboolean add_event(icalcomponent *c)
 {
@@ -395,7 +396,7 @@ static gboolean export_selected(char *file_name, char *uids)
         orage_message(150, P_N "UID list is empty");
         return(FALSE);
     }
-    if (!ic_internal_file_open(&x_ical, &x_fical, file_name, FALSE)) {
+    if (!ic_internal_file_open(&x_ical, &x_fical, file_name, FALSE, FALSE)) {
         orage_message(150, P_N "Failed to create export file %s"
                 , file_name);
         return(FALSE);
@@ -425,13 +426,14 @@ static gboolean export_selected(char *file_name, char *uids)
                 export_selected_uid(ic_f_ical[i].ical, uid_int, x_ical);
             }
             else {
-                orage_message(150, P_N "unknown foreign file number %s", uid);
+                orage_message(150, P_N "unknown foreign file number %d, %s"
+                        , i, uid);
                 return(FALSE);
             }
 
         }
         else {
-            orage_message(150, P_N "Unknown uid type %s", uid);
+            orage_message(150, P_N "Unknown uid type (%s)", uid);
         }
         
         if (uid_end != NULL)  /* we have more uids */
diff --git a/src/ical-internal.h b/src/ical-internal.h
index 9ed7877..61b2635 100644
--- a/src/ical-internal.h
+++ b/src/ical-internal.h
@@ -34,7 +34,8 @@ typedef struct
 } xfical_period;
 
 gboolean ic_internal_file_open(icalcomponent **p_ical
-        , icalset **p_fical, gchar *file_icalpath, gboolean test);
+        , icalset **p_fical, gchar *file_icalpath, gboolean read_only
+        , gboolean test);
 char *ic_get_char_timezone(icalproperty *p);
 xfical_period ic_get_period(icalcomponent *c, gboolean local);
 char *ic_generate_uid(void);
diff --git a/src/main.c b/src/main.c
index ff748f1..d2e87ad 100644
--- a/src/main.c
+++ b/src/main.c
@@ -66,11 +66,20 @@ static SessionClient	*session_client = NULL;
 static GdkAtom atom_alive;
 
 #ifdef HAVE_DBUS
-static void resuming_cb(DBusGProxy *proxy, gpointer user_data)
+static gboolean resume_after_sleep(gpointer user_data)
 {
-    orage_message(10, "Resuming");
+    orage_message(10, "Resuming after sleep");
     alarm_read();
     orage_day_change(&g_par);
+    return(FALSE); /* only once */
+}
+
+static void resuming_cb(DBusGProxy *proxy, gpointer user_data)
+{
+    orage_message(10, "Resuming");
+    /* we need this delay to prevent updating tray icon too quickly when
+       the normal code handles it also */
+    g_timeout_add_seconds(2, (GtkFunction) resume_after_sleep, NULL);
 }
 
 static void handle_resuming(void)
@@ -117,14 +126,14 @@ gboolean check_wakeup(gpointer user_data)
         /* user_data is normally NULL, but first call it has some value, 
            which means that this is init call */
         if (!user_data) { /* normal timer call */
-            orage_message(10, "waking up from suspend/resume\n");
+            orage_message(10, "wakeup timer refreshing");
             alarm_read();
             /* It is quite possible that day did not change, 
                but we need to reset timers */
             orage_day_change(&tt_prev); 
         }
         else {
-            orage_message(10, "wakeup timer init %d\n", tt_prev);
+            orage_message(10, "wakeup timer init %d", tt_prev);
         }
     }
     tt_prev = tt_new;
diff --git a/src/parameters.c b/src/parameters.c
index bc9c4c2..c4b564d 100644
--- a/src/parameters.c
+++ b/src/parameters.c
@@ -489,8 +489,10 @@ static void el_extra_days_spin_changed(GtkSpinButton *sb, gpointer user_data)
 /* start monitoring lost seconds due to hibernate or suspend */
 static void set_wakeup_timer()
 {
-    if (g_par.wakeup_timer) /* need to stop it if running */
+    if (g_par.wakeup_timer) { /* need to stop it if running */
         g_source_remove(g_par.wakeup_timer);
+        g_par.wakeup_timer=0;
+    }
     if (g_par.use_wakeup_timer) {
         check_wakeup(&g_par); /* init */
         g_par.wakeup_timer = 
diff --git a/src/parameters.h b/src/parameters.h
index 4808445..208efd3 100644
--- a/src/parameters.h
+++ b/src/parameters.h
@@ -24,7 +24,7 @@
 #define __ORAGE_PARAMETERS_H__
 
 #define BORDER 5
-#define ORAGE_WAKEUP_TIMER_PERIOD 10
+#define ORAGE_WAKEUP_TIMER_PERIOD 60
 typedef struct _foreign_file
 {
     char *file;
diff --git a/src/reminder.c b/src/reminder.c
index db5cfcb..23c980d 100644
--- a/src/reminder.c
+++ b/src/reminder.c
@@ -955,8 +955,10 @@ gboolean orage_day_change(gpointer user_data)
     || previous_month != t->tm_mon
     || previous_year != t->tm_year + 1900) {
         if (user_data) {
-            if (g_par.day_timer) /* need to stop it if running */
+            if (g_par.day_timer) { /* need to stop it if running */
                 g_source_remove(g_par.day_timer);
+                g_par.day_timer = 0;
+            }
         }
         current_year  = t->tm_year + 1900;
         current_month = t->tm_mon;
@@ -1043,8 +1045,10 @@ static void reset_orage_alarm_clock(void)
 #ifdef ORAGE_DEBUG
     orage_message(-100, P_N);
 #endif
-    if (g_par.alarm_timer) /* need to stop it if running */
+    if (g_par.alarm_timer) { /* need to stop it if running */
         g_source_remove(g_par.alarm_timer);
+        g_par.alarm_timer = 0;
+    }
     if (g_par.alarm_list) { /* we have alarms */
         t = orage_localtime();
         t->tm_mon++;


More information about the Xfce4-commits mailing list