[Xfce4-commits] r26448 - xfcalendar/trunk/src
Juha Kautto
juha at xfce.org
Fri Dec 7 22:20:32 CET 2007
Author: juha
Date: 2007-12-07 21:20:32 +0000 (Fri, 07 Dec 2007)
New Revision: 26448
Modified:
xfcalendar/trunk/src/appointment.c
xfcalendar/trunk/src/day-view.c
xfcalendar/trunk/src/event-list.c
xfcalendar/trunk/src/functions.c
xfcalendar/trunk/src/functions.h
xfcalendar/trunk/src/ical-code.c
xfcalendar/trunk/src/ical-code.h
xfcalendar/trunk/src/interface.c
xfcalendar/trunk/src/interface.h
xfcalendar/trunk/src/main.c
xfcalendar/trunk/src/mainbox.c
xfcalendar/trunk/src/mainbox.h
xfcalendar/trunk/src/parameters.c
xfcalendar/trunk/src/parameters.h
xfcalendar/trunk/src/reminder.c
xfcalendar/trunk/src/reminder.h
xfcalendar/trunk/src/tray_icon.c
Log:
removing static variables and replacing them with allocated variables.
Modified: xfcalendar/trunk/src/appointment.c
===================================================================
--- xfcalendar/trunk/src/appointment.c 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/appointment.c 2007-12-07 21:20:32 UTC (rev 26448)
@@ -1427,7 +1427,7 @@
static void fill_appt_window(appt_win *apptw, char *action, char *par)
{
- int year, month, day, hours, minutes;
+ int day, hours, minutes;
xfical_appt *appt;
struct tm *t, tm_date;
char *untildate_to_display, *tmp;
Modified: xfcalendar/trunk/src/day-view.c
===================================================================
--- xfcalendar/trunk/src/day-view.c 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/day-view.c 2007-12-07 21:20:32 UTC (rev 26448)
@@ -27,6 +27,7 @@
#include <time.h>
#include <glib.h>
+#include <glib/gprintf.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
@@ -35,7 +36,10 @@
#include "day-view.h"
#include "ical-code.h"
#include "parameters.h"
+#include "event-list.h"
+#include "appointment.h"
+void program_log (const char *format, ...);
static void refresh_day_view_table(day_win *dw);
static GtkWidget *build_line(day_win *dw, gint left_x, gint top_y
@@ -174,7 +178,6 @@
static void header_button_clicked_cb(GtkWidget *button, gpointer *user_data)
{
- day_win *dw = (day_win *)user_data;
gchar *start_date;
start_date = (char *)gtk_button_get_label(GTK_BUTTON(button));
@@ -184,7 +187,6 @@
static void on_button_press_event_cb(GtkWidget *widget
, GdkEventButton *event, gpointer *user_data)
{
- day_win *dw = (day_win *)user_data;
gchar *uid;
g_print("pressed button %d\n", event->button);
@@ -192,37 +194,33 @@
create_appt_win("UPDATE", uid, NULL);
}
-static void event_button_clicked_cb(GtkWidget *button, gpointer *user_data)
-{
- day_win *dw = (day_win *)user_data;
- gchar *uid;
-
- uid = g_object_get_data(G_OBJECT(button), "UID");
- create_appt_win("UPDATE", uid, NULL);
-}
-
static void add_row(day_win *dw, xfical_appt *appt, char *a_day, gint days)
{
gint row, start_row, end_row;
gint col, start_col, end_col, first_col, last_col;
gint height, start_height, end_height;
- gchar *text, *tip, *uid, *start_date, *end_date;
+ gchar *text, *tip, *start_date, *end_date;
GtkWidget *ev, *lab, *hb;
struct tm tm_start, tm_end, tm_first;
+ /*
GDate *g_start, *g_end, *g_first;
+ */
/* First clarify timings */
tm_start = orage_icaltime_to_tm_time(appt->starttimecur, FALSE);
tm_end = orage_icaltime_to_tm_time(appt->endtimecur, FALSE);
tm_first = orage_icaltime_to_tm_time(a_day, FALSE);
+ /*
g_start = g_date_new_dmy(tm_start.tm_mday, tm_start.tm_mon
, tm_start.tm_year);
g_end = g_date_new_dmy(tm_end.tm_mday, tm_end.tm_mon
, tm_end.tm_year);
g_first = g_date_new_dmy(tm_first.tm_mday, tm_first.tm_mon
, tm_first.tm_year);
- col = g_date_days_between(g_first, g_start)+1; /* col 0 == hour headers */
+ col = g_date_days_between(g_first, g_start)+1; / * col 0 == hour headers * /
+ */
+ col = orage_days_between(&tm_first, &tm_start)+1;
if (col < 1) {
col = 1;
row = 0;
@@ -256,7 +254,10 @@
hb = gtk_hbox_new(TRUE, 1);
else
hb = dw->element[row][col];
+ /*
if (g_date_days_between(g_start, g_end) == 0)
+ */
+ if (orage_days_between(&tm_start, &tm_end) == 0)
tip = g_strdup_printf("%s\n%02d:%02d-%02d:%02d\n%s"
, appt->title
, tm_start.tm_hour, tm_start.tm_min
@@ -300,12 +301,18 @@
/*
* same_date = !strncmp(start_ical_time, end_ical_time, 8);
* */
+ /*
start_col = g_date_days_between(g_first, g_start)+1;
+ */
+ start_col = orage_days_between(&tm_first, &tm_start)+1;
if (start_col < 1)
first_col = 1;
else
first_col = start_col;
+ /*
end_col = g_date_days_between(g_first, g_end)+1;
+ */
+ end_col = orage_days_between(&tm_first, &tm_end)+1;
if (end_col > days)
last_col = days;
else
@@ -333,9 +340,11 @@
}
}
}
+ /*
g_date_free(g_start);
g_date_free(g_end);
g_date_free(g_first);
+ */
}
static void app_rows(day_win *dw, char *a_day , xfical_type ical_type
@@ -390,7 +399,7 @@
static void fill_days(day_win *dw, gint days)
{
gint row, col, height, width;
- GtkWidget *name, *ev, *hb;
+ GtkWidget *ev, *hb;
GtkWidget *marker;
program_log("fill_days started");
@@ -533,7 +542,7 @@
{
gint days; /* number of days to show */
int year, month, day;
- gint i, j, sunday;
+ gint i, sunday;
GtkWidget *name, *label, *ev;
char text[5+1], *date, *today;
struct tm tm_date;
Modified: xfcalendar/trunk/src/event-list.c
===================================================================
--- xfcalendar/trunk/src/event-list.c 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/event-list.c 2007-12-07 21:20:32 UTC (rev 26448)
@@ -145,7 +145,7 @@
static char *format_time(el_win *el, xfical_appt *appt, char *par)
{
- static char result[50];
+ char *result;
char *tmp;
int i = 0;
char *start_ical_time;
@@ -156,7 +156,7 @@
start_ical_time = appt->starttimecur;
end_ical_time = appt->endtimecur;
same_date = !strncmp(start_ical_time, end_ical_time, 8);
- result[0] = '\0';
+ result = g_new0(char, 51);
if (el->page == EVENT_PAGE && el->days == 0) {
/* special formatting for 1 day VEVENTS */
@@ -172,8 +172,7 @@
i += append_time(result, end_ical_time, i);
}
else {/* date only appointment */
- strncpy(result, _("All day"), 49);
- i = strlen(result); /* because we add null to i-pos */
+ i = g_strlcpy(result, _("All day"), 50);
}
}
else { /* normally show date and time */
@@ -316,7 +315,6 @@
gchar flags[6];
gchar *stime;
gchar /* *s_sort,*/ *s_sort1;
- gchar source[5];
gint len = 50;
stime = format_time(el, appt, par);
@@ -385,6 +383,7 @@
, -1);
g_free(title);
g_free(s_sort1);
+ g_free(stime);
/*
g_free(s_sort);
*/
@@ -463,6 +462,7 @@
ical_type = XFICAL_TYPE_JOURNAL;
break;
default:
+ ical_type = XFICAL_TYPE_EVENT; /* to satisfy c-compiler checks */
g_error("wrong page in app_data (%d)\n", el->page);
}
@@ -506,7 +506,6 @@
static void event_data(el_win *el)
{
- guint year, month, day;
char *title; /* in %x strftime format */
char *s_time; /* in icaltime format */
char a_day[9]; /* yyyymmdd */
@@ -661,7 +660,7 @@
GtkTreePath *path;
GtkTreeIter iter;
GList *list;
- gint list_len, i;
+ gint list_len;
gchar *uid = NULL, *flags = NULL;
appt_win *apptw;
@@ -830,16 +829,9 @@
static void create_new_appointment(el_win *el)
{
appt_win *apptw;
- char *title, *s_title, a_day[10];
- struct tm tm_date = {0,0,0,0,0,0,0,0,0};
+ char *title, a_day[10];
title = (char *)gtk_window_get_title(GTK_WINDOW(el->Window));
- /*
- tm_date = orage_i18_date_to_tm_date(title);
- s_title = orage_tm_time_to_icaltime(&tm_date);
- strncpy(a_day, s_title, 8);
- a_day[8] = '\0';
- */
strcpy(a_day, orage_i18_date_to_icaltime(title));
apptw = create_appt_win("NEW", a_day, el);
@@ -1176,7 +1168,7 @@
static void build_search_tab(el_win *el)
{
gint row;
- GtkWidget *label, *hbox;
+ GtkWidget *label;
el->search_tab_label = gtk_label_new(_("Search"));
el->search_notebook_page = orage_table_new(2, 10);
Modified: xfcalendar/trunk/src/functions.c
===================================================================
--- xfcalendar/trunk/src/functions.c 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/functions.c 2007-12-07 21:20:32 UTC (rev 26448)
@@ -371,6 +371,19 @@
return(orage_tm_date_to_i18_date(t));
}
+gint orage_days_between(struct tm *t1, struct tm *t2)
+{
+ GDate *g_t1, *g_t2;
+ gint dd;
+
+ g_t1 = g_date_new_dmy(t1->tm_mday, t1->tm_mon, t1->tm_year);
+ g_t2 = g_date_new_dmy(t2->tm_mday, t2->tm_mon, t2->tm_year);
+ dd = g_date_days_between(g_t1, g_t2);
+ g_date_free(g_t1);
+ g_date_free(g_t2);
+ return(dd);
+}
+
void orage_select_date(GtkCalendar *cal
, guint year, guint month, guint day)
{
Modified: xfcalendar/trunk/src/functions.h
===================================================================
--- xfcalendar/trunk/src/functions.h 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/functions.h 2007-12-07 21:20:32 UTC (rev 26448)
@@ -40,48 +40,33 @@
GtkWidget *orage_toolbar_append_button(GtkWidget *toolbar
, const gchar *stock_id, GtkTooltips *tooltips
, const char *tooltip_text, gint pos);
-
GtkWidget *orage_toolbar_append_separator(GtkWidget *toolbar, gint pos);
GtkWidget *orage_table_new(guint rows, guint border);
-
void orage_table_add_row(GtkWidget *table, GtkWidget *label
, GtkWidget *input, guint row
, GtkAttachOptions input_x_option, GtkAttachOptions input_y_option);
GtkWidget *orage_menu_new(const gchar *menu_header_title, GtkWidget *menu_bar);
-
GtkWidget *orage_image_menu_item_new_from_stock(const gchar *stock_id
, GtkWidget *menu, GtkAccelGroup *ag);
-
GtkWidget *orage_separator_menu_item_new(GtkWidget *menu);
-
GtkWidget *orage_menu_item_new_with_mnemonic(const gchar *label
, GtkWidget *menu);
struct tm *orage_localtime();
-
-void orage_select_date(GtkCalendar *cal
- , guint year, guint month, guint day);
-
-void orage_select_today(GtkCalendar *cal);
-
struct tm orage_i18_date_to_tm_date(const char *display);
-
char *orage_tm_time_to_i18_time(struct tm *tm_date);
-
char *orage_tm_date_to_i18_date(struct tm *tm_date);
-
struct tm orage_icaltime_to_tm_time(const char *i18_date, gboolean real_tm);
-
char *orage_tm_time_to_icaltime(struct tm *t);
-
char *orage_icaltime_to_i18_time(const char *icaltime);
-
char *orage_i18_date_to_icaltime(const char *i18_date);
-
char *orage_cal_to_i18_date(GtkCalendar *cal);
-
char *orage_localdate_i18();
+gint orage_days_between(struct tm *t1, struct tm *t2);
+void orage_select_date(GtkCalendar *cal, guint year, guint month, guint day);
+void orage_select_today(GtkCalendar *cal);
+
#endif /* !__ORAGE_FUNCTIONS_H__ */
Modified: xfcalendar/trunk/src/ical-code.c
===================================================================
--- xfcalendar/trunk/src/ical-code.c 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/ical-code.c 2007-12-07 21:20:32 UTC (rev 26448)
@@ -854,7 +854,7 @@
#undef P_N
#define P_N "ical_get_current_local_time: "
struct tm *tm;
- static struct icaltimetype ctime;
+ struct icaltimetype ctime;
#ifdef ORAGE_DEBUG
g_print(P_N "\n");
@@ -879,7 +879,7 @@
ctime.minute = tm->tm_min;
ctime.second = tm->tm_sec;
- return (ctime);
+ return(ctime);
}
static struct icaltimetype convert_to_timezone(struct icaltimetype t
@@ -1219,13 +1219,14 @@
#undef P_N
#define P_N "generate_uid: "
gchar xf_host[XFICAL_UID_LEN/2+1];
- static gchar xf_uid[XFICAL_UID_LEN+1];
+ gchar *xf_uid;
static int seq = 0;
struct icaltimetype dtstamp;
#ifdef ORAGE_DEBUG
g_print(P_N "\n");
#endif
+ xf_uid = g_new(char, XFICAL_UID_LEN+1);
dtstamp = icaltime_current_time_with_zone(utc_icaltimezone);
gethostname(xf_host, XFICAL_UID_LEN/2);
xf_host[XFICAL_UID_LEN/2] = '\0';
@@ -1600,7 +1601,7 @@
create_time = dtstamp;
}
else { /* mod */
- int_uid = uid+4;
+ int_uid = g_strdup(uid+4);
ext_uid = uid;
if (icaltime_is_null_time(cre_time))
create_time = dtstamp;
@@ -1625,6 +1626,7 @@
, icalproperty_new_created(create_time)
, icalproperty_new_lastmodified(dtstamp)
, NULL);
+ g_free(int_uid);
if ORAGE_STR_EXISTS(appt->title)
icalcomponent_add_property(icmp
@@ -2075,7 +2077,6 @@
#undef P_N
#define P_N "process_completed_date: "
const char *text;
- icalparameter *itime_tz;
struct icaltimetype itime;
struct icaltimetype eltime;
@@ -2089,10 +2090,6 @@
text = icaltime_as_ical_string(eltime);
appt->completed_tz_loc = g_par.local_timezone;
g_strlcpy(appt->completedtime, text, 17);
- /*
- g_strlcpy(appt->completedtime, text, 17);
- appt->completed_tz_loc = "UTC";
- */
appt->completed = TRUE;
}
@@ -2185,9 +2182,7 @@
* returns: if failed: NULL
* if successfull: xfical_appt pointer to xfical_appt struct
* filled with data.
- * This xfical_appt struct is owned by the routine.
- * Do not deallocate it.
- * It will be overdriven by next invocation of this function.
+ * You need to deallocate the struct after it is not used.
* NOTE: This routine does not fill starttimecur nor endtimecur,
* Those are always initialized to null string
*/
@@ -2196,18 +2191,17 @@
{
#undef P_N
#define P_N "xfical_appt_get_internal: "
- static xfical_appt appt;
+ xfical_appt appt;
icalcomponent *c = NULL;
icalproperty *p = NULL;
gboolean key_found = FALSE;
const char *text;
struct icaltimetype itime, stime, etime, sltime, eltime, wtime;
icaltimezone *l_icaltimezone = NULL;
- icalparameter *itime_tz;
icalproperty_transp xf_transp;
struct icaldurationtype duration, duration_tmp;
int i;
- gboolean stime_found = FALSE, etime_found = FALSE, valid_comp = FALSE;
+ gboolean stime_found = FALSE, etime_found = FALSE;
#ifdef ORAGE_DEBUG
g_print(P_N "\n");
@@ -2409,7 +2403,7 @@
text = icaltime_as_ical_string(wtime);
g_strlcpy(appt.recur_until, text, 17);
}
- return(&appt);
+ return(g_memdup(&appt, sizeof(xfical_appt)));
}
else {
return(NULL);
@@ -2456,8 +2450,7 @@
#ifdef ORAGE_DEBUG
g_print(P_N "\n");
#endif
- if ((appt = g_memdup(xfical_appt_get_internal(ical_uid, base)
- , sizeof(xfical_appt)))) {
+ if (appt = xfical_appt_get_internal(ical_uid, base)) {
xfical_appt_get_fill_internal(appt, file_type);
}
return(appt);
@@ -2662,79 +2655,29 @@
return(FALSE);
}
-static void alarm_free(gpointer galarm, gpointer dummy)
-{
-#undef P_N
-#define P_N "alarm_free: "
- alarm_struct *alarm = (alarm_struct *)galarm;
-
-#ifdef ORAGE_DEBUG
- g_print(P_N "\n");
-#endif
- g_free(alarm->alarm_time);
- g_free(alarm->uid);
- if (alarm->title != NULL)
- g_free(alarm->title);
- if (alarm->description != NULL)
- g_free(alarm->description);
- if (alarm->sound != NULL)
- g_free(alarm->sound);
- if (alarm->cmd != NULL)
- g_free(alarm->cmd);
- g_free(alarm);
-}
-
static gint alarm_order(gconstpointer a, gconstpointer b)
{
#undef P_N
#define P_N "alarm_order: "
+ /*
struct icaltimetype t1, t2;
+ */
#ifdef ORAGE_DEBUG
g_print(P_N "\n");
#endif
+ /*
t1=icaltime_from_string(((alarm_struct *)a)->alarm_time);
t2=icaltime_from_string(((alarm_struct *)b)->alarm_time);
+ */
+ return(strcmp(((alarm_struct *)a)->alarm_time
+ , ((alarm_struct *)b)->alarm_time));
+ /*
return(icaltime_compare(t1, t2));
+ */
}
- /*
-static void alarm_add(icalproperty_status action
- , char *uid, char *file_type, char *title, char *description
- , char *sound, gint repeat_cnt, gint repeat_delay
- , struct icaltimetype alarm_time, struct icaltimetype event_time)
-{
-#undef P_N
-#define P_N "alarm_add: "
- alarm_struct *new_alarm;
-
-#ifdef ORAGE_DEBUG
- g_print(P_N "\n");
-#endif
- new_alarm = g_new(alarm_struct, 1);
- new_alarm->uid = g_string_new(file_type);
- new_alarm->uid = g_string_append(new_alarm->uid, uid);
- new_alarm->title = g_string_new(title);
- new_alarm->alarm_time = g_strdup(icaltime_as_ical_string(alarm_time));
- new_alarm->event_time = g_strdup(icaltime_as_ical_string(event_time));
- new_alarm->description = g_string_new(description);
- new_alarm->sound = g_string_new(sound);
- new_alarm->repeat_cnt = repeat_cnt;
- new_alarm->repeat_delay = repeat_delay;
- if (description != NULL)
- new_alarm->display = TRUE;
- else
- new_alarm->display = FALSE;
- if (sound != NULL)
- new_alarm->audio = TRUE;
- else
- new_alarm->audio = FALSE;
-
- g_par.alarm_list = g_list_append(g_par.alarm_list, new_alarm);
-}
- */
-
/* let's find the trigger and check that it is active.
* return new alarm struct if alarm is active and NULL if it is not
* FIXME: We assume all alarms have similar trigger, which
@@ -2961,12 +2904,9 @@
#undef P_N
#define P_N "xfical_alarm_build_list_internal_real: "
icalcomponent *c, *ca;
- icalproperty *p;
- icalproperty_status stat=ICAL_ACTION_DISPLAY;
struct icaltimetype cur_time;
- char *suid, *ssummary, *sdescription, *ssound = NULL;
+ char *suid;
gboolean trg_processed = FALSE, trg_active = FALSE;
- gint repeat_cnt = 0, repeat_delay = 0;
gint cnt_alarm=0, cnt_repeat=0, cnt_event=0, cnt_act_alarm=0
, cnt_alarm_add=0;
icalcompiter ci;
@@ -2993,12 +2933,7 @@
new_alarm = process_alarm_trigger(c, ca, cur_time, &cnt_repeat);
if (new_alarm) {
trg_active = TRUE;
- /*
- new_alarm->uid = g_strdup(file_type);
suid = (char *)icalcomponent_get_uid(c);
- new_alarm->uid = g_string_append(new_alarm->uid, suid);
- */
- suid = (char *)icalcomponent_get_uid(c);
new_alarm->uid = g_strconcat(file_type, suid, NULL);
new_alarm->title = g_strdup(
(char *)icalcomponent_get_summary(c));
@@ -3043,9 +2978,7 @@
g_print(P_N "\n");
#endif
/* first remove all old alarms by cleaning the whole structure */
- g_list_foreach(g_par.alarm_list, alarm_free, NULL);
- g_list_free(g_par.alarm_list);
- g_par.alarm_list = NULL;
+ alarm_list_free();
/* first search base orage file */
strcpy(file_type, "O00.");
@@ -3334,43 +3267,15 @@
#define P_N "xfical_mark_calendar_internal: "
xfical_period per;
struct icaltimetype nsdate, nedate;
- static icalcomponent *c;
+ icalcomponent *c;
struct icalrecurrencetype rrule;
icalrecur_iterator* ri;
icalproperty *p = NULL;
- gint start_day, day_cnt, end_day;
gboolean marked;
#ifdef ORAGE_DEBUG
g_print(P_N "\n");
#endif
- /*
- for (c = icalcomponent_get_first_component(base, ICAL_VEVENT_COMPONENT);
- c != 0;
- c = icalcomponent_get_next_component(base, ICAL_VEVENT_COMPONENT)) {
- per = get_period(c);
- xfical_mark_calendar_days(gtkcal, year, month
- , per.stime.year, per.stime.month, per.stime.day
- , per.etime.year, per.etime.month, per.etime.day);
- if ((p = icalcomponent_get_first_property(c
- , ICAL_RRULE_PROPERTY)) != 0) {
- nsdate = icaltime_null_time();
- rrule = icalproperty_get_rrule(p);
- ri = icalrecur_iterator_new(rrule, per.stime);
- for (nsdate = icalrecur_iterator_next(ri),
- nedate = icaltime_add(nsdate, per.duration);
- !icaltime_is_null_time(nsdate)
- && (nsdate.year*12+nsdate.month) <= (year*12+month);
- nsdate = icalrecur_iterator_next(ri),
- nedate = icaltime_add(nsdate, per.duration)) {
- xfical_mark_calendar_days(gtkcal, year, month
- , nsdate.year, nsdate.month, nsdate.day
- , nedate.year, nedate.month, nedate.day);
- }
- icalrecur_iterator_free(ri);
- }
- }
- */
/* Note that all VEVENTS are marked, but only the first VTODO
* end date is marked */
for (c = icalcomponent_get_first_component(base, ICAL_ANY_COMPONENT);
@@ -3480,15 +3385,12 @@
struct icalrecurrencetype rrule;
struct icaldurationtype duration;
icalrecur_iterator* ri;
- icalcomponent *d, *a;
icalparameter *itime_tz;
gchar *stz_loc = NULL, *etz_loc = NULL;
- icaltimezone *l_icaltimezone = NULL;
- gboolean key_found = FALSE;
const char *text;
char *text2;
icalproperty *p, *pdtstart, *pdtend;
- icalproperty *p_orig, *p_origdtstart, *p_origdtend;
+ icalproperty *p_orig, *p_origdtstart = NULL, *p_origdtend = NULL;
gboolean upd_edate = FALSE;
gboolean has_orig_dtstart = FALSE, has_orig_dtend = FALSE;
@@ -3841,10 +3743,6 @@
#undef P_N
#define P_N "add_event: "
icalcomponent *ca = NULL;
- icalproperty *p = NULL;
- int prop_cnt = 0;
- icalparameter *par = NULL;
- int par_cnt = 0;
char *uid;
#ifdef ORAGE_DEBUG
@@ -3855,6 +3753,7 @@
uid = generate_uid();
icalcomponent_add_property(ca, icalproperty_new_uid(uid));
orage_message("Generated UID %s\n", uid);
+ g_free(uid);
}
if (!xfical_file_open(FALSE)) {
@@ -3862,28 +3761,6 @@
return(FALSE);
}
icalcomponent_add_component(ical, ca);
- /*********** Properties ***********/
- /*
- for (p = icalcomponent_get_first_property(c, ICAL_ANY_PROPERTY);
- p != 0;
- p = icalcomponent_get_next_property(c, ICAL_ANY_PROPERTY)) {
- */
- /* these are in icalderivedproperty.h */
- /*
- g_print("\t***add_event: property %s\n", (char *)icalproperty_get_property_name(p));
- g_print("\t***add_event: property value%s\n", (char *)icalproperty_get_value_as_string(p));
- g_print("\t***add_event: continue...\n");
- */
- /*********** Parameters ***********/
- /*
- for (par = icalproperty_get_first_parameter(p, ICAL_ANY_PARAMETER);
- par != 0;
- par = icalproperty_get_next_parameter(p, ICAL_ANY_PARAMETER)) {
- g_print("\t\tadd_event: parameter %s\n", icalparameter_as_ical_string(par));
- }
- }
- */
-
file_modified = TRUE;
icalset_mark(fical);
icalset_commit(fical);
@@ -3891,16 +3768,16 @@
return(TRUE);
}
+/* pre process the file to rule out some features, which orage does not
+ * support so that we can do better conversion
+ */
static gboolean pre_format(char *file_name_in, char *file_name_out)
{
#undef P_N
#define P_N "pre_format: "
gchar *text, *tmp, *tmp2, *tmp3;
- gsize text_len, cnt;
+ gsize text_len;
GError *error = NULL;
- /* pre process the file to rule out some features, which orage does not
- * support so that we can do better conversion
- */
#ifdef ORAGE_DEBUG
g_print(P_N "\n");
@@ -3934,32 +3811,7 @@
g_print("utf8 safe now\n");
*/
- /* 1: remove ;CHARSET=...: parameter */
- /* not needed anymore since added CHARSET parameter into libical in
- * Orage 4.5.9.4 */
- /*
- for (tmp = g_strrstr(text, ";CHARSET=");
- tmp != NULL;
- tmp = g_strrstr(text, ";CHARSET=")) {
- for (tmp2 = tmp; *tmp2 != ':'; tmp2++) {
- *tmp2 = ' ';
- if (tmp2 >= text + text_len) {
- g_warning(P_N "failed. CHARSET missing :");
- return(FALSE);
- }
- }
- for (tmp2 = tmp; *tmp2 != '\n'; tmp2--) {
- if (tmp2 <= text) {
- g_warning(P_N "failed. CHARSET missing property");
- return(FALSE);
- }
- }
- tmp3 = g_strndup(tmp2+1, tmp-tmp2);
- orage_message("... Removed CHARSET from %s", tmp3);
- g_free(tmp3);
- }
- */
- /* 2: change DCREATED to CREATED */
+ /* 1: change DCREATED to CREATED */
for (tmp = g_strrstr(text, "DCREATED:");
tmp != NULL;
tmp = g_strrstr(text, "DCREATED:")) {
@@ -3993,7 +3845,7 @@
{
#undef P_N
#define P_N "xfical_import_file: "
- static icalset *file_ical = NULL;
+ icalset *file_ical = NULL;
char *ical_file_name = NULL;
icalcomponent *c1, *c2;
int cnt1 = 0, cnt2 = 0;
@@ -4139,7 +3991,7 @@
#define P_N "export_selected: "
icalcomponent *x_ical = NULL;
icalset *x_fical = NULL;
- gchar *uid_ical, *uid, *uid_end, *uid_int;
+ gchar *uid, *uid_end, *uid_int;
gboolean more_uids;
int i;
@@ -4356,8 +4208,10 @@
|| g_str_has_prefix(tmp, "LOCATION"))
found_valid = TRUE;
*cur = mem;
- if (!found_valid)
- cur = g_strstr_len(++cur, end-cur, str);
+ if (!found_valid) {
+ cur++;
+ cur = g_strstr_len(cur, end-cur, str);
+ }
}
if (!cur) {
search_done = TRUE;
Modified: xfcalendar/trunk/src/ical-code.h
===================================================================
--- xfcalendar/trunk/src/ical-code.h 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/ical-code.h 2007-12-07 21:20:32 UTC (rev 26448)
@@ -122,6 +122,8 @@
gboolean xfical_file_open(gboolean foreign);
void xfical_file_close(gboolean foreign);
void xfical_file_close_force(void);
+gboolean xfical_archive_open(void);
+void xfical_archive_close(void);
xfical_appt *xfical_appt_alloc();
char *xfical_appt_add(xfical_appt *app);
Modified: xfcalendar/trunk/src/interface.c
===================================================================
--- xfcalendar/trunk/src/interface.c 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/interface.c 2007-12-07 21:20:32 UTC (rev 26448)
@@ -46,8 +46,6 @@
#include "ical-code.h"
#include "parameters.h"
-#define FILETYPE_SIZE 2
-#define ORAGE_PERSISTENT_ALARMS "orage_persistent_alarms.txt"
/*
enum {
@@ -84,28 +82,6 @@
static void refresh_foreign_files(intf_win *intf_w, gboolean first);
-int orage_persistent_file_open(gboolean write)
-{
- int p_file;
- char *file_name;
-
- file_name = xfce_resource_save_location(XFCE_RESOURCE_DATA
- , ORAGE_DIR ORAGE_PERSISTENT_ALARMS, TRUE);
- if (!file_name) {
- g_warning("orage_persistent_file_open: Persistent alarms filename build failed, alarms not saved (%s)\n", file_name);
- return(-1);
- }
- if (write)
- p_file = g_open(file_name, O_WRONLY|O_CREAT|O_APPEND|O_TRUNC
- , S_IRUSR|S_IWUSR);
- else
- p_file = g_open(file_name, O_RDONLY|O_CREAT, S_IRUSR|S_IWUSR);
- g_free(file_name);
- if (p_file == -1)
- g_warning("orage_persistent_file_open: Persistent alarms file open failed, alarms not saved (%s)\n", file_name);
- return(p_file);
-}
-
gboolean orage_foreign_files_check(gpointer user_data)
{
static time_t latest_foreign_file_change = (time_t)0;
@@ -113,7 +89,6 @@
gint i;
gboolean changes_present = FALSE;
- g_print("orage_foreign_files_check: start\n");
if (!latest_foreign_file_change)
latest_foreign_file_change = time(NULL);
@@ -360,7 +335,7 @@
gchar *rcfile;
gchar *s;
- rcfile = xfce_resource_save_location(XFCE_RESOURCE_DATA, ORAGE_DIR, TRUE);
+ rcfile = orage_resource_file_location(ORAGE_DIR);
f_chooser = orage_file_chooser(intf_w->main_window, TRUE
, g_par.orage_file, rcfile, APPFILE);
g_free(rcfile);
@@ -386,7 +361,7 @@
gchar *rcfile;
gchar *s;
- rcfile = xfce_resource_save_location(XFCE_RESOURCE_DATA, ORAGE_DIR, TRUE);
+ rcfile = orage_resource_file_location(ORAGE_DIR);
f_chooser = orage_file_chooser(intf_w->main_window, TRUE
, g_par.archive_file, rcfile, ARCFILE);
g_free(rcfile);
@@ -468,7 +443,6 @@
void on_archive_button_clicked_cb(GtkButton *button, gpointer user_data)
{
- intf_win *intf_w = (intf_win *)user_data;
xfical_archive();
}
@@ -548,7 +522,7 @@
app_count = 1;
}
else {
- g_warning("UNKNOWN select appointment %s\n");
+ g_warning("UNKNOWN select appointment\n");
}
if (orage_export_file(entry_filename, app_count, entry_uids))
@@ -775,7 +749,9 @@
void create_menu(intf_win *intf_w)
{
+ /*
GtkWidget *menu_separator;
+ */
/* Menu bar */
intf_w->menubar = gtk_menu_bar_new();
@@ -808,7 +784,6 @@
void create_toolbar(intf_win *intf_w)
{
gint i = 0;
- GtkWidget *toolbar_separator;
/* Toolbar */
intf_w->toolbar = gtk_toolbar_new();
@@ -839,8 +814,6 @@
void handle_file_drag_data(GtkWidget *widget, GdkDragContext *context
, GtkSelectionData *data, guint time, gboolean imp)
{
- gchar *contents;
- gsize length;
gchar **file_list;
gchar *file;
gint i, pos;
@@ -1125,8 +1098,6 @@
void create_orage_file_tab(intf_win *intf_w)
{
GtkWidget *label, *hbox, *vbox, *m_vbox;
- gchar *file;
- char *str;
m_vbox = gtk_vbox_new(FALSE, 0);
intf_w->fil_notebook_page = xfce_create_framebox_with_content(NULL, m_vbox);
@@ -1258,10 +1229,7 @@
static void create_foreign_file_tab(intf_win *intf_w)
{
- GtkWidget *label, *hbox, *vbox, *button;
- gchar *file;
- gchar *str, num[3];
- gint i;
+ GtkWidget *label, *hbox, *vbox;
intf_w->for_tab_main_vbox = gtk_vbox_new(FALSE, 0);
intf_w->for_notebook_page = xfce_create_framebox_with_content(NULL
Modified: xfcalendar/trunk/src/interface.h
===================================================================
--- xfcalendar/trunk/src/interface.h 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/interface.h 2007-12-07 21:20:32 UTC (rev 26448)
@@ -98,6 +98,5 @@
gboolean orage_foreign_files_check(gpointer user_data);
gboolean orage_foreign_file_add(gchar *filename, gboolean read_only);
gboolean orage_foreign_file_remove(gchar *filename);
-int orage_persistent_file_open(gboolean write);
#endif /* !__INTERFACE_H__ */
Modified: xfcalendar/trunk/src/main.c
===================================================================
--- xfcalendar/trunk/src/main.c 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/main.c 2007-12-07 21:20:32 UTC (rev 26448)
@@ -214,6 +214,11 @@
#else
g_print(_("\tNot using DBUS. Import works only partially.\n"));
#endif
+#ifdef HAVE_NOTIFY
+ g_print(_("\tUsing libnotify.\n"));
+#else
+ g_print(_("\tNot using libnotify.\n"));
+#endif
g_print("\n");
}
@@ -244,7 +249,7 @@
static void import_file(gboolean running, char *file_name, gboolean initialized)
{
- if (running && !initialized)
+ if (running && !initialized) {
/* let's use dbus since server is running there already */
#ifdef HAVE_DBUS
if (orage_dbus_import_file(file_name))
@@ -254,11 +259,13 @@
#else
g_warning("Can not do import without dbus. import failed file=%s\n", file_name);
#endif
- else if (!running && initialized) /* do it self directly */
+ }
+ else if (!running && initialized) {/* do it self directly */
if (xfical_import_file(file_name))
orage_message("import done file=%s", file_name);
else
g_warning("import failed file=%s\n", file_name);
+ }
}
static void add_foreign(gboolean running, char *file_name, gboolean initialized
@@ -401,7 +408,7 @@
return(FALSE);
}
-static gboolean mark_orage_alive()
+static void mark_orage_alive()
{
GtkWidget *hidden;
@@ -486,7 +493,7 @@
* delayed using timer, so that we save another 1-2 secs in startup
orage_mark_appointments();
*/
- mCalendar_month_changed_cb(g_par.xfcal->mCalendar, NULL);
+ mCalendar_month_changed_cb((GtkCalendar *)g_par.xfcal->mCalendar, NULL);
g_par.day_timer = 0;
alarm_read();
orage_day_change(NULL); /* first day change after we start */
Modified: xfcalendar/trunk/src/mainbox.c
===================================================================
--- xfcalendar/trunk/src/mainbox.c 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/mainbox.c 2007-12-07 21:20:32 UTC (rev 26448)
@@ -33,6 +33,8 @@
#include <string.h>
#include <stdio.h>
+#include <glib.h>
+#include <glib/gprintf.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
@@ -47,6 +49,7 @@
#include "interface.h"
#include "parameters.h"
#include "tray_icon.h"
+#include "day-view.h"
gboolean orage_mark_appointments()
Modified: xfcalendar/trunk/src/mainbox.h
===================================================================
--- xfcalendar/trunk/src/mainbox.h 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/mainbox.h 2007-12-07 21:20:32 UTC (rev 26448)
@@ -59,5 +59,6 @@
void build_mainWin();
gboolean orage_mark_appointments();
void build_mainbox_info();
+void mCalendar_month_changed_cb(GtkCalendar *calendar, gpointer user_data);
#endif /* !__MAINBOX_H__ */
Modified: xfcalendar/trunk/src/parameters.c
===================================================================
--- xfcalendar/trunk/src/parameters.c 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/parameters.c 2007-12-07 21:20:32 UTC (rev 26448)
@@ -28,6 +28,8 @@
#include <string.h>
#endif
+#include <glib.h>
+#include <glib/gprintf.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
@@ -109,6 +111,15 @@
} Itf;
+gchar *orage_resource_file_location(char *name)
+{
+ char *file_name;
+
+ file_name = xfce_resource_save_location(XFCE_RESOURCE_DATA
+ , name, TRUE);
+ return(file_name);
+}
+
static void dialog_response(GtkWidget *dialog, gint response_id)
{
gchar *helpdoc;
@@ -826,11 +837,9 @@
g_strdup(xfce_rc_read_entry(rc, "Timezone", "floating"));
g_par.archive_limit = xfce_rc_read_int_entry(rc, "Archive limit", 0);
g_par.archive_file = g_strdup(xfce_rc_read_entry(rc, "Archive file"
- , xfce_resource_save_location(XFCE_RESOURCE_DATA, ORAGE_DIR ARCFILE
- , TRUE)));
+ , orage_resource_file_location(ORAGE_DIR ARCFILE)));
g_par.orage_file = g_strdup(xfce_rc_read_entry(rc, "Orage file"
- , xfce_resource_save_location(XFCE_RESOURCE_DATA, ORAGE_DIR APPFILE
- , TRUE)));
+ , orage_resource_file_location(ORAGE_DIR APPFILE)));
g_par.sound_application =
g_strdup(xfce_rc_read_entry(rc, "Sound application", "play"));
g_par.pos_x = xfce_rc_read_int_entry(rc, "Main window X", 0);
@@ -884,8 +893,6 @@
void set_parameters()
{
- static Itf *dialog = NULL;
-
set_menu();
set_border();
set_taskbar();
Modified: xfcalendar/trunk/src/parameters.h
===================================================================
--- xfcalendar/trunk/src/parameters.h 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/parameters.h 2007-12-07 21:20:32 UTC (rev 26448)
@@ -101,7 +101,7 @@
extern global_parameters g_par; /* refer to existing global parameters */
#endif
-
+gchar *orage_resource_file_location(char *name);
void show_parameters(void);
void write_parameters(void);
void read_parameters(void);
Modified: xfcalendar/trunk/src/reminder.c
===================================================================
--- xfcalendar/trunk/src/reminder.c 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/reminder.c 2007-12-07 21:20:32 UTC (rev 26448)
@@ -30,13 +30,16 @@
#include <sys/types.h>
#include <sys/stat.h>
+#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
+#include <stdlib.h>
#include <glib.h>
#include <glib/gprintf.h>
+#include <glib/gstdio.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#ifdef HAVE_NOTIFY
@@ -54,6 +57,8 @@
#include "tray_icon.h"
#include "parameters.h"
+#define ORAGE_PERSISTENT_ALARMS "orage_persistent_alarms.txt"
+
static void create_notify_reminder(alarm_struct *alarm);
gboolean orage_alarm_clock(gpointer user_data);
gboolean orage_tooltip_update(gpointer user_data);
@@ -61,26 +66,38 @@
/* this is almost the same than in ical-code.c.
* Perhaps these can be combined */
-static void alarm_free(alarm_struct *alarm)
+static void alarm_free(gpointer galarm, gpointer dummy)
{
#undef P_N
#define P_N "alarm_free: "
+ alarm_struct *alarm = (alarm_struct *)galarm;
#ifdef ORAGE_DEBUG
g_print(P_N "\n");
#endif
+ g_free(alarm->alarm_time);
g_free(alarm->uid);
- if (alarm->title != NULL)
- g_free(alarm->title);
- if (alarm->description != NULL)
- g_free(alarm->description);
- if (alarm->sound != NULL)
- g_free(alarm->sound);
- if (alarm->cmd != NULL)
- g_free(alarm->cmd);
+ g_free(alarm->title);
+ g_free(alarm->description);
+ g_free(alarm->sound);
+ g_free(alarm->cmd);
+ g_free(alarm->active_alarm);
g_free(alarm);
}
+void alarm_list_free()
+{
+#undef P_N
+#define P_N "alarm_free_all: "
+
+#ifdef ORAGE_DEBUG
+ g_print(P_N "\n");
+#endif
+ g_list_foreach(g_par.alarm_list, alarm_free, NULL);
+ g_list_free(g_par.alarm_list);
+ g_par.alarm_list = NULL;
+}
+
static void alarm_free_memory(alarm_struct *alarm)
{
/*
@@ -88,7 +105,7 @@
*/
if (!alarm->display_orage && !alarm->display_notify && !alarm->audio)
/* all gone, need to clean memory */
- alarm_free(alarm);
+ alarm_free(alarm, NULL);
else if (!alarm->display_orage && !alarm->display_notify)
/* if both visuals are gone we can't stop audio anymore, so stop it
* now before it is too late */
@@ -98,6 +115,31 @@
*/
}
+static int orage_persistent_file_open(gboolean write)
+{
+ int p_file;
+ char *file_name;
+
+ /*
+ file_name = xfce_resource_save_location(XFCE_RESOURCE_DATA
+ , ORAGE_DIR ORAGE_PERSISTENT_ALARMS, TRUE);
+ */
+ file_name = orage_resource_file_location(ORAGE_DIR ORAGE_PERSISTENT_ALARMS);
+ if (!file_name) {
+ g_warning("orage_persistent_file_open: Persistent alarms filename build failed, alarms not saved (%s)\n", file_name);
+ return(-1);
+ }
+ if (write)
+ p_file = g_open(file_name, O_WRONLY|O_CREAT|O_APPEND|O_TRUNC
+ , S_IRUSR|S_IWUSR);
+ else
+ p_file = g_open(file_name, O_RDONLY|O_CREAT, S_IRUSR|S_IWUSR);
+ g_free(file_name);
+ if (p_file == -1)
+ g_warning("orage_persistent_file_open: Persistent alarms file open failed, alarms not saved (%s)\n", file_name);
+ return(p_file);
+}
+
static gboolean alarm_read_next_value(int p_file, char *buf)
{
#undef P_N
@@ -216,7 +258,7 @@
new_alarm = alarm_read_next_alarm(p_file, buf)) {
if (strcmp(time_now, new_alarm->alarm_time) > 0) {
create_reminders(new_alarm);
- alarm_free(new_alarm);
+ alarm_free(new_alarm, NULL);
}
}
close(p_file);
@@ -722,14 +764,16 @@
return(FALSE); /* we started new timer, so we end here */
}
-gboolean reset_orage_alarm_clock()
+static gboolean reset_orage_alarm_clock()
{
struct tm *t, t_alarm;
GList *alarm_l;
alarm_struct *cur_alarm;
gchar *next_alarm;
gint secs_to_alarm;
+ /*
GDate *g_now, *g_alarm;
+ */
gint dd;
if (g_par.alarm_timer) /* need to stop it if running */
@@ -738,23 +782,28 @@
return(FALSE);
}
t = orage_localtime();
+ t->tm_mon++;
+ t->tm_year = t->tm_year + 1900;
alarm_l = g_list_first(g_par.alarm_list);
cur_alarm = (alarm_struct *)alarm_l->data;
next_alarm = cur_alarm->alarm_time;
t_alarm = orage_icaltime_to_tm_time(next_alarm, FALSE);
/* let's find out how much time we have until alarm happens */
+ /*
g_now = g_date_new_dmy(t->tm_mday, t->tm_mon + 1, t->tm_year + 1900);
g_alarm = g_date_new_dmy(t_alarm.tm_mday, t_alarm.tm_mon, t_alarm.tm_year);
dd = g_date_days_between(g_now, g_alarm);
g_date_free(g_now);
g_date_free(g_alarm);
+ */
+ dd = orage_days_between(t, &t_alarm);
secs_to_alarm = t_alarm.tm_sec - t->tm_sec
+ 60*(t_alarm.tm_min - t->tm_min)
- + 60*60*(t_alarm.tm_hour - t->tm_hour)
- + 24*60*60*dd;
+ + 60*60*(t_alarm.tm_hour - t->tm_hour)
+ + 24*60*60*dd;
secs_to_alarm += 1; /* alarm needs to come a bit later */
if (secs_to_alarm < 1) /* were rare, but possible */
- secs_to_alarm = 1;
+ secs_to_alarm = 1;
g_par.alarm_timer = g_timeout_add(secs_to_alarm * 1000
, (GtkFunction) orage_alarm_clock, NULL);
return(TRUE);
@@ -806,7 +855,7 @@
return(FALSE);
}
-/* adjust the call t happen when minute changes */
+/* adjust the call to happen when minute changes */
gboolean reset_orage_tooltip_update()
{
struct tm *t;
Modified: xfcalendar/trunk/src/reminder.h
===================================================================
--- xfcalendar/trunk/src/reminder.h 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/reminder.h 2007-12-07 21:20:32 UTC (rev 26448)
@@ -63,5 +63,6 @@
gboolean orage_day_change(gpointer user_data);
gboolean setup_orage_alarm_clock(void);
void alarm_read();
+void alarm_list_free();
#endif /* !__REMINDER_H__ */
Modified: xfcalendar/trunk/src/tray_icon.c
===================================================================
--- xfcalendar/trunk/src/tray_icon.c 2007-12-07 19:42:23 UTC (rev 26447)
+++ xfcalendar/trunk/src/tray_icon.c 2007-12-07 21:20:32 UTC (rev 26448)
@@ -62,16 +62,12 @@
el = create_el_win(NULL);
}
-void
-on_preferences_activate(GtkMenuItem *menuitem
- , gpointer user_data)
+void on_preferences_activate(GtkMenuItem *menuitem, gpointer user_data)
{
show_parameters();
}
-void
-on_new_appointment_activate(GtkMenuItem *menuitem
- , gpointer user_data)
+void on_new_appointment_activate(GtkMenuItem *menuitem, gpointer user_data)
{
appt_win *app;
struct tm *t;
@@ -83,14 +79,12 @@
app = create_appt_win("NEW", cur_date, NULL);
}
-void
-on_about_activate(GtkMenuItem *menuitem, gpointer user_data)
+void on_about_activate(GtkMenuItem *menuitem, gpointer user_data)
{
create_wAbout((GtkWidget *)menuitem, user_data);
}
-void
-toggle_visible_cb ()
+void toggle_visible_cb ()
{
orage_toggle_visible ();
}
@@ -202,9 +196,9 @@
/* month */
if (strftime(month, 19, "%^b", t) == 0) {
- g_warning("orage_create_icon: strftime %^b failed");
+ g_warning("orage_create_icon: strftime %%^b failed");
if (strftime(month, 19, "%b", t) == 0) {
- g_warning("orage_create_icon: strftime %b failed");
+ g_warning("orage_create_icon: strftime %%b failed");
g_sprintf(month, "orage");
}
}
More information about the Xfce4-commits
mailing list