aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/Makefile.am7
-rw-r--r--calendar/gui/calendar-conduit.c2
-rw-r--r--calendar/gui/calendar-pilot-sync.c2
-rw-r--r--calendar/gui/calendar.c2
-rw-r--r--calendar/gui/corba-cal-factory.c4
-rw-r--r--calendar/gui/corba-cal.c186
-rw-r--r--calendar/gui/eventedit.c2
-rw-r--r--calendar/gui/gncal-day-view.c10
-rw-r--r--calendar/gui/gncal-full-day.c9
-rw-r--r--calendar/gui/gncal-full-day.h2
-rw-r--r--calendar/gui/gncal-todo.c24
-rw-r--r--calendar/gui/gnome-cal.c33
-rw-r--r--calendar/gui/gnome-cal.h9
-rw-r--r--calendar/gui/goto.c2
-rw-r--r--calendar/gui/main.c142
-rw-r--r--calendar/gui/main.h23
-rw-r--r--calendar/gui/mark.c7
-rw-r--r--calendar/gui/mark.h9
-rw-r--r--calendar/gui/month-view.c8
-rw-r--r--calendar/gui/view-utils.c2
-rw-r--r--calendar/gui/view-utils.h3
-rw-r--r--calendar/gui/year-view.c11
22 files changed, 376 insertions, 123 deletions
diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am
index 82fcd76fb5..9398f6dc94 100644
--- a/calendar/gui/Makefile.am
+++ b/calendar/gui/Makefile.am
@@ -78,8 +78,6 @@ gnomecal_SOURCES = \
goto.c \
layout.c \
layout.h \
- main.c \
- main.h \
mark.c \
mark.h \
month-view.c \
@@ -93,7 +91,10 @@ gnomecal_SOURCES = \
view-utils.h \
view-utils.c \
year-view.c \
- year-view.h
+ year-view.h \
+ main.c \
+ main.h
+
# calobj.c \
# calobj.h \
diff --git a/calendar/gui/calendar-conduit.c b/calendar/gui/calendar-conduit.c
index 9c758b3263..8d9ba6002d 100644
--- a/calendar/gui/calendar-conduit.c
+++ b/calendar/gui/calendar-conduit.c
@@ -25,7 +25,7 @@
#include "GnomeCal.h"
#include "calobj.h"
-#include "calendar.h"
+/*#include "calendar.h" DELETE */
#include "timeutil.h"
#include "calendar-conduit.h"
diff --git a/calendar/gui/calendar-pilot-sync.c b/calendar/gui/calendar-pilot-sync.c
index 5039bb37b7..7378f796fd 100644
--- a/calendar/gui/calendar-pilot-sync.c
+++ b/calendar/gui/calendar-pilot-sync.c
@@ -15,7 +15,7 @@
#include <libgnorba/gnome-factory.h>
#include <libgnorba/gnorba.h>
#include "calobj.h"
-#include "calendar.h"
+/* #include "calendar.h" DELETE */
#include "timeutil.h"
#include "GnomeCal.h"
#include "pi-source.h"
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index 2d0ea7bb87..776f38452d 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -18,7 +18,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include "calendar.h"
-/*#include "alarm.h"*/
+#include "alarm.h"
#include "timeutil.h"
#include "libversit/vcc.h"
#include "icalendar.h"
diff --git a/calendar/gui/corba-cal-factory.c b/calendar/gui/corba-cal-factory.c
index e53834165c..68f98f4229 100644
--- a/calendar/gui/corba-cal-factory.c
+++ b/calendar/gui/corba-cal-factory.c
@@ -68,7 +68,7 @@ calendar_create_object (PortableServer_Servant servant,
gcal = gnome_calendar_locate (name);
if (gcal != NULL)
- return CORBA_Object_duplicate (gcal->cal->corba_server, ev);
+ return CORBA_Object_duplicate (gcal->calc->corba_server, ev);
if (stat (name, &s) != 0){
CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
@@ -79,7 +79,7 @@ calendar_create_object (PortableServer_Servant servant,
gcal = new_calendar ("", name, NULL, NULL, FALSE);
- return CORBA_Object_duplicate (gcal->cal->corba_server, ev);
+ return CORBA_Object_duplicate (gcal->calc->corba_server, ev);
}
void
diff --git a/calendar/gui/corba-cal.c b/calendar/gui/corba-cal.c
index 759b989893..a547c2dc2b 100644
--- a/calendar/gui/corba-cal.c
+++ b/calendar/gui/corba-cal.c
@@ -9,7 +9,7 @@
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
-#include "calendar.h"
+/*#include "calendar.h" DELETE */
#include "gnome-cal.h"
#include "alarm.h"
#include "cal-util/timeutil.h"
@@ -19,6 +19,10 @@
#include "corba-cal-factory.h"
#include "corba-cal.h"
+static iCalObject *
+calendar_object_find_by_pilot (GnomeCalendar *cal, int pilot_id);
+
+
typedef struct {
POA_GNOME_Calendar_Repository servant;
GnomeCalendar *calendar;
@@ -50,10 +54,15 @@ cal_repo_get_object (PortableServer_Servant servant,
{
GnomeCalendar *gcal = gnomecal_from_servant (servant);
iCalObject *obj;
+ char *obj_string;
char *buffer;
CORBA_char *ret;
- obj = calendar_object_find_event (gcal->cal, uid);
+ /*obj = calendar_object_find_event (gcal->cal, uid); DELETE */
+ obj_string = cal_client_get_object (gcal->calc, uid);
+ obj = string_to_ical_object (obj_string);
+ free (obj_string);
+
if (obj == NULL){
GNOME_Calendar_Repository_NotFound *exn;
@@ -66,13 +75,16 @@ cal_repo_get_object (PortableServer_Servant servant,
return NULL;
}
- buffer = calendar_string_from_object (obj);
+ /* buffer = calendar_string_from_object (obj); DELETE */
+ buffer = ical_object_to_string (obj);
ret = CORBA_string_dup (buffer);
free (buffer);
return ret;
}
+
+
static CORBA_char *
cal_repo_get_object_by_pilot_id (PortableServer_Servant servant,
CORBA_long pilot_id,
@@ -83,7 +95,7 @@ cal_repo_get_object_by_pilot_id (PortableServer_Servant servant,
char *buffer;
CORBA_char *ret;
- obj = calendar_object_find_by_pilot (gcal->cal, pilot_id);
+ obj = calendar_object_find_by_pilot (gcal, pilot_id);
if (obj == NULL){
GNOME_Calendar_Repository_NotFound *exn;
@@ -94,7 +106,8 @@ cal_repo_get_object_by_pilot_id (PortableServer_Servant servant,
return NULL;
}
- buffer = calendar_string_from_object (obj);
+ /* buffer = calendar_string_from_object (obj); DELETE */
+ buffer = ical_object_to_string (obj);
ret = CORBA_string_dup (buffer);
free (buffer);
@@ -102,6 +115,40 @@ cal_repo_get_object_by_pilot_id (PortableServer_Servant servant,
}
+/* where should this go? FIX ME */
+static iCalObject *
+calendar_object_find_by_pilot (GnomeCalendar *cal, int pilot_id)
+{
+ GList *l, *uids;
+
+ g_return_val_if_fail (cal != NULL, NULL);
+
+ uids = cal_client_get_uids (cal->calc,
+ CALOBJ_TYPE_EVENT |
+ CALOBJ_TYPE_TODO |
+ CALOBJ_TYPE_JOURNAL |
+ CALOBJ_TYPE_OTHER |
+ CALOBJ_TYPE_ANY);
+ for (l = uids; l; l = l->next){
+ char *obj_string = cal_client_get_object (cal->calc, l->data);
+ iCalObject *obj = string_to_ical_object (obj_string);
+
+ if (obj->pilot_id == pilot_id)
+ return obj;
+ }
+
+ /* DELETE
+ for (l = cal->todo; l; l = l->next){
+ iCalObject *obj = l->data;
+
+ if (obj->pilot_id == pilot_id)
+ return obj;
+ }
+ */
+
+ return NULL;
+}
+
static CORBA_char *
cal_repo_get_id_from_pilot_id (PortableServer_Servant servant,
CORBA_long pilot_id,
@@ -110,7 +157,7 @@ cal_repo_get_id_from_pilot_id (PortableServer_Servant servant,
GnomeCalendar *gcal = gnomecal_from_servant (servant);
iCalObject *obj;
- obj = calendar_object_find_by_pilot (gcal->cal, pilot_id);
+ obj = calendar_object_find_by_pilot (gcal, pilot_id);
if (obj == NULL){
GNOME_Calendar_Repository_NotFound *exn;
@@ -131,15 +178,21 @@ cal_repo_delete_object (PortableServer_Servant servant,
{
GnomeCalendar *gcal = gnomecal_from_servant (servant);
iCalObject *obj;
+ char *obj_string;
+
+ /* obj = calendar_object_find_event (gcal->cal, uid); */
+ obj_string = cal_client_get_object (gcal->calc, uid);
+ obj = string_to_ical_object (obj_string);
+ free (obj_string);
- obj = calendar_object_find_event (gcal->cal, uid);
if (obj == NULL){
GNOME_Calendar_Repository_NotFound *exn;
exn = GNOME_Calendar_Repository_NotFound__alloc();
CORBA_exception_set (ev,
CORBA_USER_EXCEPTION,
- ex_GNOME_Calendar_Repository_NotFound, exn);
+ ex_GNOME_Calendar_Repository_NotFound,
+ exn);
return;
}
@@ -153,17 +206,29 @@ cal_repo_update_object (PortableServer_Servant servant,
CORBA_Environment *ev)
{
GnomeCalendar *gcal = gnomecal_from_servant (servant);
- iCalObject *obj;
+ /* iCalObject *obj; char *obj_string; */
iCalObject *new_object;
+ char *new_object_string;
new_object = ical_object_new_from_string (vcalendar_object);
-
- obj = calendar_object_find_event (gcal->cal, uid);
+
+#if 0 /* it looks like this is taken care of in cal_client_update_object? */
+ /* DELETE */
+ /* obj = calendar_object_find_event (gcal->cal, uid); DELETE */
+ obj_string = cal_client_get_object (gcal->calc, uid);
+ obj = string_to_ical_object (obj_string);
+ free (obj_string);
+
if (obj != NULL){
- calendar_remove_object (gcal->cal, obj);
+ /* calendar_remove_object (gcal->cal, obj); DELETE */
+ cal_client_remove_object (gcal->calc, uid);
}
+#endif /* 0 */
- calendar_add_object (gcal->cal, new_object);
+ /* calendar_add_object (gcal->cal, new_object); DELETE */
+ new_object_string = ical_object_to_string (new_object);
+ cal_client_update_object (gcal->calc, uid, new_object_string);
+ free (new_object_string);
}
static void
@@ -175,8 +240,13 @@ cal_repo_update_pilot_id (PortableServer_Servant servant,
{
GnomeCalendar *gcal = gnomecal_from_servant (servant);
iCalObject *obj;
+ char *obj_string;
- obj = calendar_object_find_event (gcal->cal, uid);
+ /* obj = calendar_object_find_event (gcal->cal, uid); DELETE */
+ obj_string = cal_client_get_object (gcal->calc, uid);
+ obj = string_to_ical_object (obj_string);
+ free (obj_string);
+
if (obj == NULL){
GNOME_Calendar_Repository_NotFound *exn;
@@ -193,6 +263,13 @@ cal_repo_update_pilot_id (PortableServer_Servant servant,
obj->pilot_status = pilot_status;
}
+
+static void list_free_string (gpointer data, gpointer user_data)
+{
+ free (data);
+}
+
+
static CORBA_long
cal_repo_get_number_of_objects (PortableServer_Servant servant,
GNOME_Calendar_Repository_RecordStatus record_status,
@@ -200,11 +277,17 @@ cal_repo_get_number_of_objects (PortableServer_Servant servant,
{
GnomeCalendar *gcal = gnomecal_from_servant (servant);
CORBA_long res;
- GList *l;
iCalPilotState real_record_status;
+ GList *l, *uids;
if (record_status == GNOME_Calendar_Repository_ANY) {
- return g_list_length(gcal->cal->events);
+ /* return g_list_length(gcal->cal->events); DELETE */
+ GList *uids = cal_client_get_uids (gcal->calc,
+ CALOBJ_TYPE_EVENT);
+ res = g_list_length (uids);
+ g_list_foreach (uids, list_free_string, NULL);
+ g_list_free (uids);
+ return res;
}
switch (record_status) {
@@ -221,13 +304,17 @@ cal_repo_get_number_of_objects (PortableServer_Servant servant,
res = 0;
- for (l = gcal->cal->events; l; l = l->next){
- iCalObject *obj = l->data;
+ uids = cal_client_get_uids (gcal->calc, CALOBJ_TYPE_EVENT);
+ for (l = uids; l; l = l->next){
+ char *obj_string = cal_client_get_object (gcal->calc, l->data);
+ iCalObject *obj = string_to_ical_object (obj_string);
if (obj->pilot_status == real_record_status)
res ++;
+ g_free (l->data);
}
-
+ g_list_free (uids);
+
return res;
}
@@ -236,20 +323,24 @@ cal_repo_get_object_id_list(PortableServer_Servant servant,
CORBA_Environment *ev)
{
GnomeCalendar *gcal = gnomecal_from_servant (servant);
- GList *l;
+ GList *l, *uids;
GNOME_Calendar_Repository_String_Sequence *result;
int counter;
+
+ uids = cal_client_get_uids (gcal->calc, CALOBJ_TYPE_EVENT);
result = GNOME_Calendar_Repository_String_Sequence__alloc();
- result->_length = g_list_length(gcal->cal->events);
- result->_buffer = CORBA_sequence_CORBA_string_allocbuf(result->_length);
+ result->_length = g_list_length (uids);
+ result->_buffer =
+ CORBA_sequence_CORBA_string_allocbuf(result->_length);
counter = 0;
- for (l = gcal->cal->events ; l; l = l->next){
- iCalObject *obj = l->data;
- result->_buffer[counter] = CORBA_string_dup(obj->uid);
+ for (l = uids; l; l = l->next){
+ result->_buffer[counter] = CORBA_string_dup(l->data);
counter++;
+ g_free (l->data);
}
+ g_list_free (uids);
return result;
}
@@ -258,28 +349,46 @@ static CORBA_char *
cal_repo_get_updated_objects (PortableServer_Servant servant,
CORBA_Environment *ev)
{
+ /* FIX ME -- this might be wrong */
GnomeCalendar *gcal = gnomecal_from_servant (servant);
- Calendar *dirty_cal;
- GList *l;
+ /* Calendar *dirty_cal; DELETE */
+ VObject *vcalobj, *vobj;
+ GList *l, *uids;
CORBA_char *res;
char *str;
- dirty_cal = calendar_new ("Temporal",CALENDAR_INIT_NIL);
+ /* dirty_cal = calendar_new ("Temporal",CALENDAR_INIT_NIL); DELETE */
+ vcalobj = newVObject (VCCalProp);
- for (l = gcal->cal->events; l; l = l->next){
- iCalObject *obj = l->data;
+ uids = cal_client_get_uids (gcal->calc, CALOBJ_TYPE_EVENT);
+ for (l = uids; l; l = l->next){
+ char *obj_string = cal_client_get_object (gcal->calc, l->data);
+ iCalObject *obj = string_to_ical_object (obj_string);
if (obj->pilot_status != ICAL_PILOT_SYNC_MOD)
continue;
- obj = ical_object_duplicate (l->data);
-
- calendar_add_object (dirty_cal, obj);
+ /* calendar_add_object (dirty_cal, obj); DELETE */
+ vobj = ical_object_to_vobject (obj);
+ addVObjectProp (vcalobj, vobj);
+ g_free (l->data);
}
+ g_list_free (uids);
+
+# if 0
+ /* DELETE */
str = calendar_get_as_vcal_string (dirty_cal);
res = CORBA_string_dup (str);
free (str); /* calendar_get_as_vcal_string() uses writeMemVObject(), which uses realloc() */
calendar_destroy (dirty_cal);
+# endif /* 0 */
+
+ str = writeMemVObject (NULL, NULL, vcalobj);
+ res = CORBA_string_dup (str);
+ free (str); /* calendar_get_as_vcal_string() uses writeMemVObject(),
+ which uses realloc() */
+ cleanVObject (vcalobj);
+ cleanStrTbl ();
return res;
}
@@ -288,9 +397,10 @@ static void
cal_repo_done (PortableServer_Servant servant,
CORBA_Environment *ev)
{
- GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ /* GnomeCalendar *gcal = gnomecal_from_servant (servant); */
- calendar_save (gcal->cal, NULL);
+ /* calendar_save (gcal->cal, NULL); DELETE */
+ /* FIX ME -- i dont know what to do here */
}
static void
@@ -305,7 +415,6 @@ init_calendar_repo_class (void)
calendar_repository_epv.get_updated_objects = cal_repo_get_updated_objects;
calendar_repository_epv.update_pilot_id = cal_repo_update_pilot_id;
calendar_repository_epv.get_object_id_list = cal_repo_get_object_id_list;
-
calendar_repository_epv.done = cal_repo_done;
calendar_repository_vepv.GNOME_Calendar_Repository_epv =
@@ -337,7 +446,8 @@ gnome_calendar_create_corba_server (GnomeCalendar *calendar)
POA_GNOME_Calendar_Repository__init ((PortableServer_Servant) calendar_servant, &ev);
CORBA_free (
PortableServer_POA_activate_object (poa, calendar_servant, &ev));
- calendar->cal->corba_server = PortableServer_POA_servant_to_reference (
- poa, calendar_servant, &ev);
+ calendar->calc->corba_server =
+ PortableServer_POA_servant_to_reference (poa, calendar_servant, &ev);
+
CORBA_exception_free (&ev);
}
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
index e65db4e3da..d3f44b702b 100644
--- a/calendar/gui/eventedit.c
+++ b/calendar/gui/eventedit.c
@@ -8,7 +8,7 @@
#include <config.h>
#include <gnome.h>
#include <string.h>
-#include "calendar.h"
+/* #include "calendar.h" DELETE */
#include "eventedit.h"
#include "main.h"
#include "cal-util/timeutil.h"
diff --git a/calendar/gui/gncal-day-view.c b/calendar/gui/gncal-day-view.c
index 955aac0ef9..a93929e569 100644
--- a/calendar/gui/gncal-day-view.c
+++ b/calendar/gui/gncal-day-view.c
@@ -100,8 +100,10 @@ gncal_day_view_destroy (GtkObject *object)
if (dview->day_str)
g_free (dview->day_str);
+ /* DELETE
if (dview->events)
calendar_destroy_event_list (dview->events);
+ */
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
@@ -364,7 +366,7 @@ gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags)
g_return_if_fail (dview != NULL);
g_return_if_fail (GNCAL_IS_DAY_VIEW (dview));
- g_return_if_fail (dview->calendar->cal);
+ g_return_if_fail (dview->calendar->calc);
if (dview->day_str)
g_free (dview->day_str);
@@ -373,10 +375,12 @@ gncal_day_view_update (GncalDayView *dview, iCalObject *ico, int flags)
strftime (buf, sizeof (buf)-1, "%A %d", &tm);
dview->day_str = g_strdup (buf);
- if (dview->events)
+ /*
+ if (dview->events) DELETE
calendar_destroy_event_list (dview->events);
+ */
- dview->events = calendar_get_events_in_range (dview->calendar->cal,
+ dview->events = calendar_get_events_in_range (dview->calendar->calc,
dview->lower,
dview->upper);
diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c
index c07d9a5710..f402707e73 100644
--- a/calendar/gui/gncal-full-day.c
+++ b/calendar/gui/gncal-full-day.c
@@ -2134,19 +2134,20 @@ gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags)
g_return_if_fail (fullday != NULL);
g_return_if_fail (GNCAL_IS_FULL_DAY (fullday));
- if (!fullday->calendar->cal)
+ if (!fullday->calendar->calc)
return;
/* Try to find child that changed */
- for (children = fullday->children; children; children = children->next) {
+ for (children=fullday->children; children; children = children->next) {
child = children->data;
if (child->ico == ico)
break;
}
- /* If child was found and nothing but the summary changed, we can just paint the child and return */
+ /* If child was found and nothing but the summary changed,
+ we can just paint the child and return */
if (children && !(flags & ~CHANGE_SUMMARY)) {
child_draw (fullday, child, NULL, NULL, TRUE);
@@ -2157,7 +2158,7 @@ gncal_full_day_update (GncalFullDay *fullday, iCalObject *ico, int flags)
destroy_children (fullday);
- calendar_iterate (fullday->calendar->cal,
+ calendar_iterate (fullday->calendar,
fullday->lower,
fullday->upper,
fullday_add_children,
diff --git a/calendar/gui/gncal-full-day.h b/calendar/gui/gncal-full-day.h
index 287c5f63f6..b616308f24 100644
--- a/calendar/gui/gncal-full-day.h
+++ b/calendar/gui/gncal-full-day.h
@@ -11,7 +11,7 @@
#include <gtk/gtkcontainer.h>
#include <libgnome/gnome-defs.h>
-#include "calendar.h"
+/*#include "calendar.h"*/
#include "gnome-cal.h"
diff --git a/calendar/gui/gncal-todo.c b/calendar/gui/gncal-todo.c
index 64ea8d0638..87fd1b68ba 100644
--- a/calendar/gui/gncal-todo.c
+++ b/calendar/gui/gncal-todo.c
@@ -798,7 +798,6 @@ insert_in_clist (GncalTodo *todo, iCalObject *ico)
void
gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags)
{
- GList *list;
GSList *current_list;
g_return_if_fail (todo != NULL);
@@ -844,7 +843,9 @@ gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags)
gtk_clist_set_column_visibility (todo->clist, 2, 0);
/* free the memory locations that were used in the previous display */
- for (current_list = todo->data_ptrs; current_list != NULL; current_list = g_slist_next(current_list)){
+ for (current_list = todo->data_ptrs;
+ current_list != NULL;
+ current_list = g_slist_next(current_list)){
g_free(current_list->data);
}
@@ -854,8 +855,25 @@ gncal_todo_update (GncalTodo *todo, iCalObject *ico, int flags)
gtk_clist_clear (todo->clist);
- for (list = todo->calendar->cal->todo; list; list = list->next)
+ {
+ /* DELETE
+ for (list = todo->calendar->cal->todo; list; list = list->next)
insert_in_clist (todo, list->data);
+ */
+
+ GList *l, *uids;
+ uids = cal_client_get_uids (todo->calendar->calc,
+ CALOBJ_TYPE_EVENT);
+ for (l = uids; l; l = l->next){
+ char *obj_string =
+ cal_client_get_object (todo->calendar->calc,
+ l->data);
+ iCalObject *obj = string_to_ical_object (obj_string);
+ insert_in_clist (todo, obj);
+ g_free (l->data);
+ }
+ g_list_free (uids);
+ }
/* if we are autoresizing then do it now */
if(todo_list_autoresize && todo->clist->rows != 0)
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 038a893192..408f6b5396 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -10,8 +10,8 @@
#include <signal.h>
#include <sys/wait.h>
#include <fcntl.h>
-/*#include "alarm.h"*/
-#include "calendar.h"
+#include "alarm.h"
+/* #include "calendar.h" DELETE */
#include "gnome-cal.h"
#include "gncal-day-panel.h"
#include "gncal-week-view.h"
@@ -228,7 +228,8 @@ gnome_calendar_new (char *title)
gtk_window_set_title(GTK_WINDOW(retval), title);
gcal->current_display = time_day_begin (time (NULL));
- gcal->cal = calendar_new (title, CALENDAR_INIT_ALARMS);
+ /*gcal->cal = calendar_new (title, CALENDAR_INIT_ALARMS); DELETE */
+ gcal->calc = cal_client_new ();
setup_widgets (gcal);
gnome_calendar_create_corba_server (gcal);
@@ -247,14 +248,13 @@ gnome_calendar_update_all (GnomeCalendar *cal, iCalObject *object, int flags)
int
gnome_calendar_load (GnomeCalendar *gcal, char *file)
{
- char *r;
-
g_return_val_if_fail (gcal != NULL, 0);
g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), 0);
g_return_val_if_fail (file != NULL, 0);
- if ((r = calendar_load (gcal->cal, file)) != NULL){
- printf ("Error loading calendar: %s\n", r);
+ /* if ((r = calendar_load (gcal->cal, file)) != NULL){ DELETE */
+ if (cal_client_load_calendar (gcal->calc, file) == FALSE){
+ printf ("Error loading calendar: %s\n", file);
return 0;
}
gnome_calendar_update_all (gcal, NULL, 0);
@@ -264,22 +264,29 @@ gnome_calendar_load (GnomeCalendar *gcal, char *file)
void
gnome_calendar_add_object (GnomeCalendar *gcal, iCalObject *obj)
{
+ char *obj_string;
g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
g_return_if_fail (obj != NULL);
- calendar_add_object (gcal->cal, obj);
+ /*calendar_add_object (gcal->cal, obj); DELETE */
+ obj_string = ical_object_to_string (obj);
+ cal_client_update_object (gcal->calc, obj->uid, obj_string);
+ g_free (obj_string);
gnome_calendar_update_all (gcal, obj, CHANGE_NEW);
}
void
gnome_calendar_remove_object (GnomeCalendar *gcal, iCalObject *obj)
{
+ gboolean r;
+
g_return_if_fail (gcal != NULL);
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
g_return_if_fail (obj != NULL);
- calendar_remove_object (gcal->cal, obj);
+ /* calendar_remove_object (gcal->cal, obj); DELETE */
+ r = cal_client_remove_object (gcal->calc, obj->uid);
gnome_calendar_update_all (gcal, obj, CHANGE_ALL);
}
@@ -290,10 +297,11 @@ gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
g_return_if_fail (obj != NULL);
- gcal->cal->modified = TRUE;
+ /* FIX ME -- i don't know what to do here */
+ /* gcal->cal->modified = TRUE; */
gnome_calendar_update_all (gcal, obj, flags);
- calendar_object_changed (gcal->cal, obj, flags);
+ /* calendar_object_changed (gcal->cal, obj, flags); */
}
static int
@@ -567,7 +575,8 @@ gnome_calendar_tag_calendar (GnomeCalendar *cal, GtkCalendar *gtk_cal)
gtk_calendar_freeze (gtk_cal);
gtk_calendar_clear_marks (gtk_cal);
- calendar_iterate (cal->cal, month_begin, month_end, mark_gtk_calendar_day, gtk_cal);
+ calendar_iterate (cal, month_begin, month_end,
+ mark_gtk_calendar_day, gtk_cal);
gtk_calendar_thaw (gtk_cal);
}
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index da53f29882..6bdbf4ca1b 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -10,7 +10,8 @@
#include <gnome.h>
-#include "calendar.h"
+/*#include "calendar.h"*/
+#include "cal-client/cal-client.h"
BEGIN_GNOME_DECLS
@@ -20,9 +21,9 @@ BEGIN_GNOME_DECLS
typedef struct {
GnomeApp gnome_app;
- Calendar *cal;
+ CalClient *calc; /* was Calendar *cal; */
time_t current_display;
-
+
GtkWidget *notebook;
GtkWidget *day_view;
GtkWidget *week_view;
@@ -63,6 +64,8 @@ void gnome_calendar_object_changed (GnomeCalendar *gcal,
iCalObject *obj,
int flags);
+void calendar_notify (time_t time, CalendarAlarm *which, void *data);
+
GnomeCalendar *gnome_calendar_locate (const char *pathname);
/* Notifies the calendar that the time format has changed and it must update all its views */
diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c
index ef756a5463..57ba67f821 100644
--- a/calendar/gui/goto.c
+++ b/calendar/gui/goto.c
@@ -31,7 +31,7 @@ update (void)
struct tm tm;
unmark_month_item (month_item);
- mark_month_item (month_item, gnome_calendar->cal);
+ mark_month_item (month_item, gnome_calendar);
if (current_index != -1) {
item = gnome_month_item_num2child (month_item,
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index ea30d1275c..c4cd11b860 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -16,8 +16,8 @@
#include <string.h>
#include <ctype.h>
#include <errno.h>
-#include "calendar.h"
-/*#include "alarm.h"*/
+/* #include "calendar.h" DELETE */
+#include "alarm.h"
#include "eventedit.h"
#include "gnome-cal.h"
#include "main.h"
@@ -97,13 +97,7 @@ const guint MAX_SNOOZE_SECS = 3600;
gboolean enable_snooze = 0;
guint snooze_secs = 60;
-/* Default values for alarms */
-CalendarAlarm alarm_defaults[4] = {
- { ALARM_MAIL, 0, 15, ALARM_MINUTES },
- { ALARM_PROGRAM, 0, 15, ALARM_MINUTES },
- { ALARM_DISPLAY, 0, 15, ALARM_MINUTES },
- { ALARM_AUDIO, 0, 15, ALARM_MINUTES }
-};
+extern CalendarAlarm alarm_defaults[4];
static void
init_username (void)
@@ -251,7 +245,7 @@ init_calendar (void)
-static void save_calendar_cmd (GtkWidget *widget, void *data);
+/* static void save_calendar_cmd (GtkWidget *widget, void *data); DELETE */
static void
about_calendar_cmd (GtkWidget *widget, void *data)
@@ -311,7 +305,7 @@ gnome_calendar_locate (const char *pathname)
for (l = all_calendars; l; l = l->next){
GnomeCalendar *gcal = l->data;
- if (strcmp (gcal->cal->filename, pathname) == 0){
+ if (strcmp (gcal->calc->filename, pathname) == 0){
return gcal;
}
}
@@ -323,12 +317,15 @@ close_cmd (GtkWidget *widget, GnomeCalendar *gcal)
{
all_calendars = g_list_remove (all_calendars, gcal);
+ /* DELETE
+ FIX ME -- what do i do here?
if (gcal->cal->modified){
if (!gcal->cal->filename)
save_calendar_cmd (widget, gcal);
else
calendar_save (gcal->cal, gcal->cal->filename);
}
+ */
gtk_widget_destroy (GTK_WIDGET (gcal));
active_calendars--;
@@ -483,7 +480,7 @@ save_ok (GtkWidget *widget, GtkFileSelection *fs)
gtk_window_set_wmclass (GTK_WINDOW (gcal), "gnomecal", "gnomecal");
fname = g_strdup (gtk_file_selection_get_filename (fs));
- calendar_save (gcal->cal, fname);
+ /* calendar_save (gcal->cal, fname); DELETE / FIX ME*/
g_free(fname);
gtk_main_quit ();
}
@@ -523,7 +520,8 @@ properties_cmd (GtkWidget *widget, GtkWidget *gcal)
{
properties (gcal);
}
-
+
+# if 0 /* DELETE */
static void
save_calendar_cmd (GtkWidget *widget, void *data)
{
@@ -563,6 +561,7 @@ save_calendar_cmd (GtkWidget *widget, void *data)
} else
save_as_calendar_cmd (widget, data);
}
+#endif /* 0 */
/*
* Saves @gcal if it is the default calendar
@@ -570,10 +569,10 @@ save_calendar_cmd (GtkWidget *widget, void *data)
void
save_default_calendar (GnomeCalendar *gcal)
{
- if (!gcal->cal->filename)
+ if (!gcal->calc->filename)
return;
- save_calendar_cmd (NULL, gcal);
+ /* save_calendar_cmd (NULL, gcal); FIX ME */
}
static GnomeUIInfo gnome_cal_file_menu [] = {
@@ -583,7 +582,7 @@ static GnomeUIInfo gnome_cal_file_menu [] = {
GNOMEUIINFO_MENU_OPEN_ITEM(open_calendar_cmd, NULL),
- GNOMEUIINFO_MENU_SAVE_ITEM(save_calendar_cmd, NULL),
+ /* GNOMEUIINFO_MENU_SAVE_ITEM(save_calendar_cmd, NULL), FIX ME */
GNOMEUIINFO_MENU_SAVE_AS_ITEM(save_as_calendar_cmd, NULL),
@@ -705,7 +704,7 @@ new_calendar (char *full_name, char *calendar_file, char *geometry, char *page,
if (calendar_file && g_file_exists (calendar_file))
gnome_calendar_load (GNOME_CALENDAR (toplevel), calendar_file);
else
- GNOME_CALENDAR (toplevel)->cal->filename = g_strdup (calendar_file);
+ GNOME_CALENDAR (toplevel)->calc->filename = g_strdup (calendar_file);
gtk_signal_connect (GTK_OBJECT (toplevel), "delete_event",
GTK_SIGNAL_FUNC(calendar_close_event), toplevel);
@@ -764,22 +763,33 @@ same_day (struct tm *a, struct tm *b)
static void
dump_events (void)
{
- Calendar *cal;
+ CalClient *calc;
+ gboolean r;
GList *l;
- char *s;
time_t now = time (NULL);
struct tm today = *localtime (&now);
process_dates ();
init_calendar ();
+ /* DELETE
cal = calendar_new (full_name, CALENDAR_INIT_ALARMS);
s = calendar_load (cal, load_file ? load_file : user_calendar_file);
if (s){
printf ("error: %s\n", s);
exit (1);
}
- l = calendar_get_events_in_range (cal, from_t, to_t);
+ */
+
+ r = cal_client_load_calendar (calc,
+ load_file ? load_file : user_calendar_file);
+ if (r == FALSE) {
+ printf ("error: loading %s\n",
+ load_file ? load_file : user_calendar_file);
+ exit (1);
+ }
+ l = calendar_get_events_in_range (calc, from_t, to_t);
+
for (; l; l = l->next){
char start [80], end [80];
CalendarObject *co = l->data;
@@ -802,36 +812,49 @@ dump_events (void)
printf ("%s -- %s\n", start, end);
printf (" %s\n", co->ico->summary);
}
- calendar_destroy_event_list (l);
- calendar_destroy (cal);
+ /* calendar_destroy_event_list (l); DELETE / FIX ME */
+ /* calendar_destroy (cal); DELETE */
exit (0);
}
static void
dump_todo (void)
{
- Calendar *cal;
+ CalClient *calc;
+ gboolean r;
GList *l;
- char *s;
process_dates ();
init_calendar ();
+ /* DELETE
cal = calendar_new (full_name, CALENDAR_INIT_ALARMS);
s = calendar_load (cal, load_file ? load_file : user_calendar_file);
if (s){
printf ("error: %s\n", s);
exit (1);
}
- for (l = cal->todo; l; l = l->next){
- iCalObject *object = l->data;
+ */
+
+ r = cal_client_load_calendar (calc,
+ load_file ? load_file : user_calendar_file);
+ if (r == FALSE) {
+ printf ("error: loading %s\n",
+ load_file ? load_file : user_calendar_file);
+ exit (1);
+ }
+ l = calendar_get_events_in_range (calc, from_t, to_t);
+
+ for (; l; l = l->next){
+ CalendarObject *co = l->data;
+ iCalObject *object = co->ico;
if (object->type != ICAL_TODO)
continue;
printf ("[%s]: %s\n",object->organizer->addr, object->summary);
}
- calendar_destroy (cal);
+ /* calendar_destroy (cal); DELETE */
exit (0);
}
@@ -939,18 +962,18 @@ session_save_state (GnomeClient *client, gint phase, GnomeRestartStyle save_styl
geometry = gnome_geometry_string (GTK_WIDGET (gcal)->window);
- if (strcmp (gcal->cal->filename, user_calendar_file) == 0)
+ if (strcmp (gcal->calc->filename, user_calendar_file) == 0)
argv [i++] = "--userfile";
else {
argv [i++] = "--file";
- argv [i++] = gcal->cal->filename;
+ argv [i++] = gcal->calc->filename;
}
argv [i++] = "--geometry";
argv [i++] = geometry;
argv [i++] = "--view";
argv [i++] = gnome_calendar_get_current_view_name (gcal);
free_list = g_list_append (free_list, geometry);
- calendar_save (gcal->cal, gcal->cal->filename);
+ /* calendar_save (gcal->cal, gcal->cal->filename); FIX ME */
}
argv [i] = NULL;
gnome_client_set_clone_command (client, i, argv);
@@ -1042,3 +1065,62 @@ main(int argc, char *argv[])
gtk_main ();
return 0;
}
+
+
+
+/* FIX ME -- where should this go? */
+void
+calendar_iterate (GnomeCalendar *cal,
+ time_t start, time_t end,
+ calendarfn cb, void *closure)
+{
+ GList *l, *uids = 0;
+
+ uids = cal_client_get_uids (cal->calc, CALOBJ_TYPE_EVENT);
+
+ for (l = uids; l; l = l->next){
+ char *obj_string = cal_client_get_object (cal->calc, l->data);
+ iCalObject *obj = string_to_ical_object (obj_string);
+
+ ical_object_generate_events (obj, start, end, cb, closure);
+ g_free (l->data);
+ }
+ g_list_free (uids);
+}
+
+
+
+static gint
+calendar_object_compare_by_start (gconstpointer a, gconstpointer b)
+{
+ const CalendarObject *ca = a;
+ const CalendarObject *cb = b;
+ time_t diff;
+
+ diff = ca->ev_start - cb->ev_start;
+ return (diff < 0) ? -1 : (diff > 0) ? 1 : 0;
+}
+
+/* FIX ME -- where should this (and calendar_object_compare_by_start) go? */
+/* returns a list of events in the form of CalendarObject* */
+GList *calendar_get_events_in_range (CalClient *calc,
+ time_t start, time_t end)
+{
+ GList *l, *uids, *res = 0;
+ uids = cal_client_get_events_in_range (calc, start, end);
+
+ for (l = uids; l; l = l->next){
+ char *obj_string = cal_client_get_object (calc, l->data);
+ iCalObject *obj = string_to_ical_object (obj_string);
+
+ CalendarObject *co = g_new (CalendarObject, 1);
+ co->ev_start = start;
+ co->ev_end = end;
+ co->ico = obj;
+
+ res = g_list_insert_sorted (res, co,
+ calendar_object_compare_by_start);
+ }
+
+ return res;
+}
diff --git a/calendar/gui/main.h b/calendar/gui/main.h
index 2785e1d2d1..e05fd4367b 100644
--- a/calendar/gui/main.h
+++ b/calendar/gui/main.h
@@ -93,9 +93,24 @@ void save_default_calendar (GnomeCalendar *gcal);
GnomeCalendar *new_calendar (char *full_name, char *calendar_file,
char *geometry, char *page, gboolean hidden);
-#endif
-
-
-
+/*----------------------------------------------------------------------*/
+/* FIX ME -- where should this stuff go? */
+/*----------------------------------------------------------------------*/
+/* This is only used by the calendar_get_events_in_range routine to get
+ * a list of objects that recur on a specific date
+ */
+typedef struct {
+ time_t ev_start;
+ time_t ev_end;
+ iCalObject *ico;
+} CalendarObject;
+
+GList *calendar_get_events_in_range (CalClient *calc,
+ time_t start, time_t end);
+void
+calendar_iterate (GnomeCalendar *cal,
+ time_t start, time_t end,
+ calendarfn cb, void *closure);
+#endif
diff --git a/calendar/gui/mark.c b/calendar/gui/mark.c
index 288b6d3b11..660fdba6ab 100644
--- a/calendar/gui/mark.c
+++ b/calendar/gui/mark.c
@@ -101,7 +101,7 @@ mark_event_in_month (GnomeMonthItem *mitem, time_t start, time_t end)
}
void
-mark_month_item (GnomeMonthItem *mitem, Calendar *cal)
+mark_month_item (GnomeMonthItem *mitem, GnomeCalendar *cal)
{
time_t month_begin, month_end;
GList *list, *l;
@@ -114,7 +114,8 @@ mark_month_item (GnomeMonthItem *mitem, Calendar *cal)
month_begin = time_month_begin (time_from_day (mitem->year, mitem->month, 1));
month_end = time_month_end (month_begin);
- list = calendar_get_events_in_range (cal, month_begin, month_end);
+ list =
+ calendar_get_events_in_range (cal->calc, month_begin, month_end);
for (l = list; l; l = l->next) {
co = l->data;
@@ -124,7 +125,7 @@ mark_month_item (GnomeMonthItem *mitem, Calendar *cal)
mark_event_in_month (mitem, MAX (co->ev_start, month_begin), MIN (co->ev_end, month_end));
}
- calendar_destroy_event_list (list);
+ /* calendar_destroy_event_list (list); DELETE / FIX ME */
}
void
diff --git a/calendar/gui/mark.h b/calendar/gui/mark.h
index cf8f7c1496..ea7315a43f 100644
--- a/calendar/gui/mark.h
+++ b/calendar/gui/mark.h
@@ -8,7 +8,7 @@
#ifndef MARK_H
#define MARK_H
-#include "calendar.h"
+/*#include "calendar.h"*/
#include "gnome-month-item.h"
@@ -34,10 +34,11 @@ typedef char * (* GetColorFunc) (ColorProp propnum, gpointer data);
/* Sets the user-configured colors and font for a month item. It also tags the days as unmarked. */
void colorify_month_item (GnomeMonthItem *month, GetColorFunc func, gpointer func_data);
-/* Takes a monthly calendar item and marks the days that have events scheduled for them in the
- * specified calendar. It also highlights the current day.
+/* Takes a monthly calendar item and marks the days that have events
+ * scheduled for them in the specified calendar. It also highlights
+ * the current day.
*/
-void mark_month_item (GnomeMonthItem *mitem, Calendar *cal);
+void mark_month_item (GnomeMonthItem *mitem, GnomeCalendar *cal);
/* Marks a day specified by index, not by day number */
void mark_month_item_index (GnomeMonthItem *mitem, int index, GetColorFunc func, gpointer func_data);
diff --git a/calendar/gui/month-view.c b/calendar/gui/month-view.c
index 0a7386f9e4..7d2d6c29bb 100644
--- a/calendar/gui/month-view.c
+++ b/calendar/gui/month-view.c
@@ -83,7 +83,8 @@ do_quick_view_popup (MonthView *mv, GdkEventButton *event, int day)
day_begin_time = time_from_day (mv->year, mv->month, day);
day_end_time = time_day_end (day_begin_time);
- list = calendar_get_events_in_range (mv->calendar->cal, day_begin_time, day_end_time);
+ list = calendar_get_events_in_range (mv->calendar->calc,
+ day_begin_time, day_end_time);
strftime (date_str, sizeof (date_str), _("%a %b %d %Y"), localtime (&day_begin_time));
qv = quick_view_new (mv->calendar, date_str, list);
@@ -91,7 +92,7 @@ do_quick_view_popup (MonthView *mv, GdkEventButton *event, int day)
quick_view_do_popup (QUICK_VIEW (qv), event);
gtk_widget_destroy (qv);
- calendar_destroy_event_list (list);
+ /* calendar_destroy_event_list (list); DELETE / FIX ME*/
}
/* Callback used to destroy the popup menu when the month view is destroyed */
@@ -679,7 +680,8 @@ month_view_update (MonthView *mv, iCalObject *object, int flags)
ii.month_begin = time_month_begin (t);
ii.month_end = time_month_end (t);
- calendar_iterate (mv->calendar->cal, ii.month_begin, ii.month_end, add_event, &ii);
+ calendar_iterate (mv->calendar,
+ ii.month_begin, ii.month_end, add_event, &ii);
for (i = 0; i < 42; i++) {
/* Delete the last character if it is a newline */
diff --git a/calendar/gui/view-utils.c b/calendar/gui/view-utils.c
index 8cb7893377..98e04f0e1c 100644
--- a/calendar/gui/view-utils.c
+++ b/calendar/gui/view-utils.c
@@ -9,6 +9,8 @@
#include <string.h>
#include "view-utils.h"
#include <libgnomeui/gnome-icon-text.h>
+#include "gnome-cal.h"
+#include "main.h"
int am_pm_flag = 0;
diff --git a/calendar/gui/view-utils.h b/calendar/gui/view-utils.h
index a1876b6032..4d850375fb 100644
--- a/calendar/gui/view-utils.h
+++ b/calendar/gui/view-utils.h
@@ -10,7 +10,8 @@
#include <gtk/gtk.h>
-#include "calendar.h"
+/*#include "calendar.h"*/
+#include "cal-util/calobj.h"
enum {
diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c
index 567340bde1..42c85a0d32 100644
--- a/calendar/gui/year-view.c
+++ b/calendar/gui/year-view.c
@@ -307,7 +307,8 @@ do_quick_view_popup (YearView *yv, GdkEventButton *event, int year, int month, i
day_start = time_from_day (year, month, day);
day_end = time_day_end (day_start);
- list = calendar_get_events_in_range (yv->calendar->cal, day_start, day_end);
+ list = calendar_get_events_in_range (yv->calendar->calc,
+ day_start, day_end);
strftime (date_str, sizeof (date_str), _("%a %b %d %Y"), localtime (&day_start));
qv = quick_view_new (yv->calendar, date_str, list);
@@ -315,7 +316,7 @@ do_quick_view_popup (YearView *yv, GdkEventButton *event, int year, int month, i
quick_view_do_popup (QUICK_VIEW (qv), event);
gtk_widget_destroy (qv);
- calendar_destroy_event_list (list);
+ /* calendar_destroy_event_list (list); DELETE */
}
/* Event handler for days in the year's month items */
@@ -702,7 +703,8 @@ year_view_set (YearView *yv, time_t year)
for (i = 0; i < 12; i++) {
unmark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]));
- mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
+ mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]),
+ yv->calendar);
}
mark_current_day (yv);
@@ -734,7 +736,8 @@ year_view_colors_changed (YearView *yv)
for (i = 0; i < 12; i++) {
colorify_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), default_color_func, NULL);
- mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]), yv->calendar->cal);
+ mark_month_item (GNOME_MONTH_ITEM (yv->mitems[i]),
+ yv->calendar);
}
mark_current_day (yv);