[Xfce4-commits] r26681 - xfcalendar/trunk/src
Juha Kautto
juha at xfce.org
Mon Mar 17 19:12:48 CET 2008
Author: juha
Date: 2008-03-17 18:12:48 +0000 (Mon, 17 Mar 2008)
New Revision: 26681
Modified:
xfcalendar/trunk/src/appointment.c
xfcalendar/trunk/src/ical-code.c
xfcalendar/trunk/src/main.c
xfcalendar/trunk/src/reminder.c
Log:
Minor changes to help to support the code.
Added tracing and changed tracing levels.
Modified: xfcalendar/trunk/src/appointment.c
===================================================================
--- xfcalendar/trunk/src/appointment.c 2008-03-15 00:45:00 UTC (rev 26680)
+++ xfcalendar/trunk/src/appointment.c 2008-03-17 18:12:48 UTC (rev 26681)
@@ -1087,17 +1087,17 @@
apptw->appointment_add = FALSE;
gtk_widget_set_sensitive(apptw->Duplicate, TRUE);
gtk_widget_set_sensitive(apptw->File_menu_duplicate, TRUE);
- orage_message(30, "Added: %s", apptw->xf_uid);
+ orage_message(10, "Added: %s", apptw->xf_uid);
}
else
- g_warning("Addition failed: %s", apptw->xf_uid);
+ orage_message(150, "Addition failed: %s", apptw->xf_uid);
}
else {
ok = xfical_appt_mod(apptw->xf_uid, appt);
if (ok)
- orage_message(30, "Modified: %s", apptw->xf_uid);
+ orage_message(10, "Modified: %s", apptw->xf_uid);
else
- g_warning("Modification failed: %s", apptw->xf_uid);
+ orage_message(150, "Modification failed: %s", apptw->xf_uid);
}
xfical_file_close(TRUE);
if (ok) {
@@ -1156,7 +1156,7 @@
return;
result = xfical_appt_del(apptw->xf_uid);
if (result)
- orage_message(30, "Removed: %s", apptw->xf_uid);
+ orage_message(10, "Removed: %s", apptw->xf_uid);
else
g_warning("Removal failed: %s", apptw->xf_uid);
xfical_file_close(TRUE);
@@ -1417,7 +1417,6 @@
if (!xfical_file_open(TRUE))
return(NULL);
if ((appt = xfical_appt_get(par)) == NULL) {
- orage_message(120, "appointment not found: %s", par);
xfce_message_dialog(GTK_WINDOW(apptw->Window)
, _("Info")
, GTK_STOCK_DIALOG_INFO
@@ -1887,7 +1886,7 @@
char *untildate_to_display;
int i;
- orage_message(30, "%s appointment: %s", action, par);
+ orage_message(10, "%s appointment: %s", action, par);
if ((appt = fill_appt_window_get_appt(apptw, action, par)) == NULL) {
apptw->appt = NULL;
return;
Modified: xfcalendar/trunk/src/ical-code.c
===================================================================
--- xfcalendar/trunk/src/ical-code.c 2008-03-15 00:45:00 UTC (rev 26680)
+++ xfcalendar/trunk/src/ical-code.c 2008-03-17 18:12:48 UTC (rev 26681)
@@ -894,16 +894,38 @@
return(ctime);
}
+static char *get_char_timezone(icalproperty *p)
+{
+#undef P_N
+#define P_N "get_char_timezone: "
+ icalparameter *itime_tz;
+ gchar *tz_loc = NULL;
+
+#ifdef ORAGE_DEBUG
+ orage_message(-300, P_N);
+#endif
+ if (itime_tz = icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER))
+ tz_loc = (char *)icalparameter_get_tzid(itime_tz);
+ return(tz_loc);
+}
+
static icaltimezone *get_builtin_timezone(gchar *tz_loc)
{
+#undef P_N
+#define P_N "get_builtin_timezone: "
/* This probably is evolution format,
* which has /xxx/xxx/timezone and we should remove the
* extra /xxx/xxx/ from it */
char **new_str;
icaltimezone *l_icaltimezone = NULL;
+#ifdef ORAGE_DEBUG
+ orage_message(-300, P_N);
+#endif
if (tz_loc[0] == '/') {
+#ifdef ORAGE_DEBUG
orage_message(-20, P_N "evolution timezone fix %s", tz_loc);
+#endif
new_str = g_strsplit(tz_loc, "/", 4);
if (new_str[0] != NULL && new_str[1] != NULL && new_str[2] != NULL
&& new_str[3] != NULL)
@@ -920,21 +942,17 @@
{
#undef P_N
#define P_N "convert_to_timezone: "
- icalparameter *itime_tz = NULL;
- gchar *tz_loc = NULL;
- icaltimezone *l_icaltimezone = NULL;
+ gchar *tz_loc;
+ icaltimezone *l_icaltimezone;
struct icaltimetype tz;
#ifdef ORAGE_DEBUG
orage_message(-300, P_N);
#endif
- itime_tz = icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER);
- if (itime_tz) {
- tz_loc = (char *)icalparameter_get_tzid(itime_tz);
+ if (tz_loc = get_char_timezone(p)) {
/* FIXME: could we now call convert_to_zone or is it a problem
* if we always move to zone format ? */
- l_icaltimezone = get_builtin_timezone(tz_loc);
- if (!l_icaltimezone) {
+ if (!(l_icaltimezone = get_builtin_timezone(tz_loc))) {
orage_message(250, P_N "builtin timezone %s not found, conversion failed.", tz_loc);
}
tz = icaltime_convert_to_zone(t, l_icaltimezone);
@@ -1803,7 +1821,7 @@
}
if (appt->freq != XFICAL_FREQ_NONE) {
/* NOTE: according to standard VJOURNAL _has_ recurrency,
- * but I can't understand how it coud be usefull,
+ * but I can't understand how it could be usefull,
* so Orage takes it away */
appt_add_recur_internal(appt, icmp);
}
@@ -2042,7 +2060,6 @@
#undef P_N
#define P_N "process_start_date: "
const char *text;
- icalparameter *itime_tz;
#ifdef ORAGE_DEBUG
orage_message(-200, P_N);
@@ -2060,13 +2077,9 @@
appt->start_tz_loc = "UTC";
}
else { /* let's check timezone */
- itime_tz = icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER);
- if (itime_tz) {
- appt->start_tz_loc = (char *)icalparameter_get_tzid(itime_tz);
- }
- else {
- appt->start_tz_loc = "floating";
- }
+ char *t;
+
+ appt->start_tz_loc = ((t = get_char_timezone(p)) ? t : "floating");
}
if (appt->endtime[0] == '\0') {
g_strlcpy(appt->endtime, appt->starttime, 17);
@@ -2082,7 +2095,6 @@
#undef P_N
#define P_N "process_end_date: "
const char *text;
- icalparameter *itime_tz;
#ifdef ORAGE_DEBUG
orage_message(-200, P_N);
@@ -2102,13 +2114,9 @@
appt->end_tz_loc = "UTC";
}
else { /* let's check timezone */
- itime_tz = icalproperty_get_first_parameter(p, ICAL_TZID_PARAMETER);
- if (itime_tz) {
- appt->end_tz_loc = (char *)icalparameter_get_tzid(itime_tz);
- }
- else {
- appt->end_tz_loc = "floating";
- }
+ char *t;
+
+ appt->end_tz_loc = ((t = get_char_timezone(p)) ? t : "floating");
}
appt->use_due_time = TRUE;
}
@@ -2139,7 +2147,6 @@
#undef P_N
#define P_N "ical_appt_get_rrule_internal: "
struct icalrecurrencetype rrule;
- const char *text;
int i, cnt, day;
#ifdef ORAGE_DEBUG
@@ -2166,6 +2173,8 @@
if ((appt->recur_count = rrule.count))
appt->recur_limit = 1;
else if(! icaltime_is_null_time(rrule.until)) {
+ const char *text;
+
appt->recur_limit = 2;
text = icaltime_as_ical_string(rrule.until);
g_strlcpy(appt->recur_until, text, 17);
@@ -2719,7 +2728,7 @@
#define P_N "alarm_order: "
#ifdef ORAGE_DEBUG
- orage_message(-200, P_N);
+ orage_message(-300, P_N);
#endif
return(strcmp(((alarm_struct *)a)->alarm_time
@@ -3010,9 +3019,9 @@
}
} /* COMPONENT */
if (first_list_today) {
- orage_message(20, _("Build alarm list: Added %d alarms. Processed %d events.")
+ orage_message(60, _("Build alarm list: Added %d alarms. Processed %d events.")
, cnt_alarm_add, cnt_event);
- orage_message(20, _("\tFound %d alarms of which %d are active. (Searched %d recurring alarms.)")
+ orage_message(60, _("\tFound %d alarms of which %d are active. (Searched %d recurring alarms.)")
, cnt_alarm, cnt_act_alarm, cnt_repeat);
}
}
@@ -3431,7 +3440,6 @@
struct icalrecurrencetype rrule;
struct icaldurationtype duration;
icalrecur_iterator* ri;
- icalparameter *itime_tz;
gchar *stz_loc = NULL, *etz_loc = NULL;
const char *text;
char *text2;
@@ -3451,9 +3459,7 @@
*/
sdate = icalcomponent_get_dtstart(e);
pdtstart = icalcomponent_get_first_property(e, ICAL_DTSTART_PROPERTY);
- itime_tz = icalproperty_get_first_parameter(pdtstart, ICAL_TZID_PARAMETER);
- if (itime_tz)
- stz_loc = (char *)icalparameter_get_tzid(itime_tz);
+ stz_loc = get_char_timezone(pdtstart);
sdate = convert_to_timezone(sdate, pdtstart);
edate = icalcomponent_get_dtend(e);
@@ -3462,11 +3468,7 @@
}
pdtend = icalcomponent_get_first_property(e, ICAL_DTEND_PROPERTY);
if (pdtend) { /* we have DTEND, so we need to adjust it. */
- itime_tz = icalproperty_get_first_parameter(pdtend
- , ICAL_TZID_PARAMETER);
- if (itime_tz)
- etz_loc = (char *)icalparameter_get_tzid(itime_tz);
-
+ etz_loc = get_char_timezone(pdtend);
edate = convert_to_timezone(edate, pdtend);
duration = icaltime_subtract(edate, sdate);
upd_edate = TRUE;
Modified: xfcalendar/trunk/src/main.c
===================================================================
--- xfcalendar/trunk/src/main.c 2008-03-15 00:45:00 UTC (rev 26680)
+++ xfcalendar/trunk/src/main.c 2008-03-17 18:12:48 UTC (rev 26681)
@@ -242,7 +242,7 @@
/* let's use dbus since server is running there already */
#ifdef HAVE_DBUS
if (orage_dbus_import_file(file_name))
- orage_message(30, "import done file=%s", file_name);
+ orage_message(40, "import done file=%s", file_name);
else
g_warning("import failed file=%s\n", file_name);
#else
@@ -251,7 +251,7 @@
}
else if (!running && initialized) {/* do it self directly */
if (xfical_import_file(file_name))
- orage_message(30, "import done file=%s", file_name);
+ orage_message(40, "import done file=%s", file_name);
else
g_warning("import failed file=%s\n", file_name);
}
Modified: xfcalendar/trunk/src/reminder.c
===================================================================
--- xfcalendar/trunk/src/reminder.c 2008-03-15 00:45:00 UTC (rev 26680)
+++ xfcalendar/trunk/src/reminder.c 2008-03-17 18:12:48 UTC (rev 26681)
@@ -57,6 +57,9 @@
#include "tray_icon.h"
#include "parameters.h"
+/*
+#define ORAGE_DEBUG 1
+*/
static void create_notify_reminder(alarm_struct *alarm);
static void create_reminders(alarm_struct *alarm);
@@ -69,7 +72,7 @@
alarm_struct *alarm = (alarm_struct *)galarm;
#ifdef ORAGE_DEBUG
- g_print(P_N "\n");
+ orage_message(-100, P_N);
#endif
g_free(alarm->alarm_time);
g_free(alarm->uid);
@@ -87,7 +90,7 @@
#define P_N "alarm_free_all: "
#ifdef ORAGE_DEBUG
- g_print(P_N "\n");
+ orage_message(-100, P_N);
#endif
g_list_foreach(g_par.alarm_list, alarm_free, NULL);
g_list_free(g_par.alarm_list);
@@ -96,6 +99,12 @@
static void alarm_free_memory(alarm_struct *alarm)
{
+#undef P_N
+#define P_N "alarm_free_memory: "
+
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
if (!alarm->display_orage && !alarm->display_notify && !alarm->audio)
/* all gone, need to clean memory */
alarm_free(alarm, NULL);
@@ -117,7 +126,7 @@
OrageRc *orc;
#ifdef ORAGE_DEBUG
- g_print(P_N "\n");
+ orage_message(-100, P_N);
#endif
fpath = orage_data_file_location(ORAGE_PERSISTENT_ALARMS_FILE);
if (!read_only) /* we need to empty it before each write */
@@ -138,7 +147,7 @@
gchar *alarm_time;
#ifdef ORAGE_DEBUG
- g_print(P_N "\n");
+ orage_message(-100, P_N);
#endif
/* let's first check if the time has gone so that we need to
@@ -187,7 +196,7 @@
gint i;
#ifdef ORAGE_DEBUG
- g_print(P_N "\n");
+ orage_message(-100, P_N);
#endif
t = orage_localtime();
@@ -214,7 +223,7 @@
OrageRc *orc = (OrageRc *)par;
#ifdef ORAGE_DEBUG
- g_print(P_N "\n");
+ orage_message(-200, P_N);
#endif
if (!alarm->persistent)
return; /* only store persistent alarms */
@@ -249,7 +258,7 @@
OrageRc *orc;
#ifdef ORAGE_DEBUG
- g_print(P_N "\n");
+ orage_message(-100, P_N);
#endif
orc = orage_persistent_file_open(FALSE);
g_list_foreach(g_par.alarm_list, alarm_store, (gpointer)orc);
@@ -264,8 +273,13 @@
static void notify_action_open(NotifyNotification *n, const char *action
, gpointer par)
{
+#undef P_N
+#define P_N "notify_action_open: "
alarm_struct *alarm = (alarm_struct *)par;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
/*
* These two lines would keep notify window active and make it possible
* to start several times the appointment or start it and still be
@@ -279,11 +293,16 @@
static gboolean sound_alarm(gpointer data)
{
+#undef P_N
+#define P_N "sound_alarm: "
alarm_struct *alarm = (alarm_struct *)data;
GError *error = NULL;
gboolean status;
GtkWidget *stop;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
/* note: -1 loops forever */
if (alarm->repeat_cnt != 0) {
if (alarm->active_alarm->sound_active) {
@@ -324,6 +343,12 @@
static void create_sound_reminder(alarm_struct *alarm)
{
+#undef P_N
+#define P_N "create_sound_reminder: "
+
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
/* done in initialisation
g_string_prepend(alarm->sound, " \"");
g_string_prepend(alarm->sound, g_par.sound_application);
@@ -343,8 +368,13 @@
#ifdef HAVE_NOTIFY
static void notify_closed(NotifyNotification *n, gpointer par)
{
+#undef P_N
+#define P_N "notify_closed: "
alarm_struct *alarm = (alarm_struct *)par;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
/*
g_print("notify_closed: start %d %d\n", alarm->audio, alarm->display_notify);
*/
@@ -362,8 +392,13 @@
static void notify_action_silence(NotifyNotification *n, const char *action
, gpointer par)
{
+#undef P_N
+#define P_N "notify_action_silence: "
alarm_struct *alarm = (alarm_struct *)par;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
alarm->notify_refresh = TRUE;
alarm->repeat_cnt = 0;
create_notify_reminder(alarm);
@@ -372,6 +407,12 @@
static void create_notify_reminder(alarm_struct *alarm)
{
+#undef P_N
+#define P_N "create_notify_reminder: "
+
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
#ifdef HAVE_NOTIFY
char heading[250];
NotifyNotification *n;
@@ -417,8 +458,13 @@
static void destroy_orage_reminder(GtkWidget *wReminder, gpointer user_data)
{
+#undef P_N
+#define P_N "destroy_orage_reminder: "
alarm_struct *alarm = (alarm_struct *)user_data;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
alarm->display_orage = FALSE; /* I am gone */
alarm_free_memory(alarm);
}
@@ -426,28 +472,45 @@
static void on_btStopNoiseReminder_clicked(GtkButton *button
, gpointer user_data)
{
+#undef P_N
+#define P_N "on_btStopNoiseReminder_clicked: "
alarm_struct *alarm = (alarm_struct *)user_data;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
alarm->repeat_cnt = 0;
gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
}
static void on_btOkReminder_clicked(GtkButton *button, gpointer user_data)
{
+#undef P_N
+#define P_N "on_btOkReminder_clicked: "
GtkWidget *wReminder = (GtkWidget *)user_data;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
gtk_widget_destroy(wReminder); /* destroy the specific appointment window */
}
static void on_btOpenReminder_clicked(GtkButton *button, gpointer user_data)
{
+#undef P_N
+#define P_N "on_btOpenReminder_clicked: "
alarm_struct *alarm = (alarm_struct *)user_data;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
create_appt_win("UPDATE", alarm->uid);
}
static void create_orage_reminder(alarm_struct *alarm)
{
+#undef P_N
+#define P_N "create_orage_reminder: "
GtkWidget *wReminder;
GtkWidget *vbReminder;
GtkWidget *lbReminder;
@@ -458,6 +521,9 @@
GtkWidget *swReminder;
GtkWidget *hdReminder;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
wReminder = gtk_dialog_new();
gtk_widget_set_size_request(wReminder, 300, 250);
gtk_window_set_title(GTK_WINDOW(wReminder), _("Reminder - Orage"));
@@ -517,9 +583,14 @@
static void create_procedure_reminder(alarm_struct *alarm)
{
+#undef P_N
+#define P_N "create_procedure_reminder: "
gboolean status, active; /* active not used */
GError *error = NULL;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
status = orage_exec(alarm->cmd, &active, &error);
if (!status)
g_warning("create_procedure_reminder: cmd failed(%s)", alarm->cmd);
@@ -527,8 +598,13 @@
static void create_reminders(alarm_struct *alarm)
{
+#undef P_N
+#define P_N "create_reminders: "
alarm_struct *n_alarm;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
/* FIXME: instead of copying this new private version of the alarm,
* g_list_remove(GList *g_par.alarm_list, gconstpointer alarm);
* remove it and use the original. saves time */
@@ -570,12 +646,17 @@
*/
static gboolean orage_day_change(gpointer user_data)
{
+#undef P_N
+#define P_N "orage_day_change: "
CalWin *xfcal;
struct tm *t;
static guint previous_year=0, previous_month=0, previous_day=0;
guint selected_year=0, selected_month=0, selected_day=0;
guint current_year=0, current_month=0, current_day=0;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
t = orage_localtime();
/* See if the day just changed */
if (previous_day != t->tm_mday
@@ -623,9 +704,14 @@
void reset_orage_day_change(gboolean changed)
{
+#undef P_N
+#define P_N "reset_orage_day_change: "
struct tm *t;
gint secs_left;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
if (changed) { /* date was change, need to count next change time */
t = orage_localtime();
/* t format is 23:59:59 -> 00:00:00 so we can use
@@ -643,6 +729,8 @@
/* check and raise alarms if there are any */
static gboolean orage_alarm_clock(gpointer user_data)
{
+#undef P_N
+#define P_N "orage_alarm_clock: "
struct tm *t;
GList *alarm_l;
alarm_struct *cur_alarm;
@@ -650,6 +738,9 @@
gboolean more_alarms=TRUE;
gchar *time_now;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
t = orage_localtime();
time_now = orage_tm_time_to_icaltime(t);
/* Check if there are any alarms to show */
@@ -675,6 +766,8 @@
static void reset_orage_alarm_clock()
{
+#undef P_N
+#define P_N "reset_orage_alarm_clock: "
struct tm *t, t_alarm;
GList *alarm_l;
alarm_struct *cur_alarm;
@@ -682,6 +775,9 @@
gint secs_to_alarm;
gint dd;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
if (g_par.alarm_timer) /* need to stop it if running */
g_source_remove(g_par.alarm_timer);
if (g_par.alarm_list) { /* we have alarms */
@@ -709,6 +805,8 @@
/* refresh trayicon tooltip once per minute */
gboolean orage_tooltip_update(gpointer user_data)
{
+#undef P_N
+#define P_N "orage_tooltip_update: "
struct tm *t;
GList *alarm_l;
alarm_struct *cur_alarm;
@@ -720,6 +818,9 @@
gint dd, hh, min;
GDate *g_now, *g_alarm;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
if (!(g_par.trayIcon && NETK_IS_TRAY_ICON(g_par.trayIcon->tray))) {
/* no trayicon => no need to update the tooltip */
return(FALSE);
@@ -770,6 +871,12 @@
/* start timer to fire every minute to keep tooltip accurate */
gboolean start_orage_tooltip_update(gpointer user_data)
{
+#undef P_N
+#define P_N "start_orage_tooltip_update: "
+
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
if (g_par.tooltip_timer) { /* need to stop it if running */
g_source_remove(g_par.tooltip_timer);
}
@@ -783,9 +890,14 @@
/* adjust the call to happen when minute changes */
gboolean reset_orage_tooltip_update()
{
+#undef P_N
+#define P_N "reset_orage_tooltip_update: "
struct tm *t;
gint secs_left;
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
t = orage_localtime();
secs_left = 60 - t->tm_sec;
if (secs_left > 10)
@@ -802,6 +914,12 @@
void setup_orage_alarm_clock()
{
+#undef P_N
+#define P_N "setup_orage_alarm_clock: "
+
+#ifdef ORAGE_DEBUG
+ orage_message(-100, P_N);
+#endif
reset_orage_alarm_clock();
store_persistent_alarms(); /* keep track of alarms when orage is down */
/* We need to use timer since for some reason it does not work if we
More information about the Xfce4-commits
mailing list