aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorEskil Heyn Olsen <eskil@src.gnome.org>1999-09-25 22:30:22 +0800
committerEskil Heyn Olsen <eskil@src.gnome.org>1999-09-25 22:30:22 +0800
commit008fb50b9f799f202453759650a2b4ec4fc2b5af (patch)
tree90f8d7ff4d1afc99ae2e77c6ee1722853a0e97d4 /calendar/gui
parent6ed1a40852d43229bec2509d7d0b9e35efde163f (diff)
downloadgsoc2013-evolution-008fb50b9f799f202453759650a2b4ec4fc2b5af.tar
gsoc2013-evolution-008fb50b9f799f202453759650a2b4ec4fc2b5af.tar.gz
gsoc2013-evolution-008fb50b9f799f202453759650a2b4ec4fc2b5af.tar.bz2
gsoc2013-evolution-008fb50b9f799f202453759650a2b4ec4fc2b5af.tar.lz
gsoc2013-evolution-008fb50b9f799f202453759650a2b4ec4fc2b5af.tar.xz
gsoc2013-evolution-008fb50b9f799f202453759650a2b4ec4fc2b5af.tar.zst
gsoc2013-evolution-008fb50b9f799f202453759650a2b4ec4fc2b5af.zip
the g_free that was commented out since glib said was a duplicate free,
* corba-cal.c: the g_free that was commented out since glib said was a duplicate free, was supposed to be a free. * GnomeCal.idl/corba-cal.c: added a get_object_id_list and a get_objects_by_id_list. Latter is not done. * calendar-conduit.c: rewrote the way the conduit iterates over records. It no longers fetches all entries (since that didn't work with more then 285 entries. It now fetches the id list, and gets each record. (will be using get_objects_by_id_list to get records in amounts of 10 or so later, to reduce amount of corba calls). * calendar-conduit.c: now sets alarm parameters when transferring from gnomecal to pilot. svn path=/trunk/; revision=1257
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/GnomeCal.idl29
-rw-r--r--calendar/gui/calendar-conduit.c169
-rw-r--r--calendar/gui/calendar-conduit.h2
-rw-r--r--calendar/gui/corba-cal.c45
4 files changed, 190 insertions, 55 deletions
diff --git a/calendar/gui/GnomeCal.idl b/calendar/gui/GnomeCal.idl
index 036dc55db0..5c5d400d9e 100644
--- a/calendar/gui/GnomeCal.idl
+++ b/calendar/gui/GnomeCal.idl
@@ -5,6 +5,7 @@ module GNOME {
interface Repository {
exception NotFound {};
+ typedef sequence<string> String_Sequence;
/*
* get_object:
@@ -17,6 +18,18 @@ module GNOME {
raises (NotFound);
/*
+ * get_objects_by_id_list:
+ * @uid_list: a sequence of Unique Identifiers
+ *
+ * Returns a vCalendar object for the objects
+ * that matches the given UID list @uid_list;
+ * NotFound is raised if any of the given UIDs
+ * were not found.
+ */
+ string get_objects_by_id_list (in String_Sequence uid)
+ raises (NotFound);
+
+ /*
* get_object_by_pilot_id:
* @pilot_id: the pilot id
*
@@ -26,6 +39,13 @@ module GNOME {
string get_object_by_pilot_id (in long pilot_id)
raises (NotFound);
+ /*
+ * get_id_from_pilot_id:
+ * @pilot_id: the pilot id
+ *
+ * Returns the object id that matches the @pilot_id
+ * identifier.
+ */
string get_id_from_pilot_id (in long pilot_id)
raises (NotFound);
@@ -55,11 +75,20 @@ module GNOME {
/*
* get_objects:
*
+ * Danger Will Robinson : This can result in a
+ * huge string, namely the size of all your entries.
* Returns a vCalendar with all the objects
*/
string get_objects ();
/*
+ * get_object_id_list
+ *
+ * Returns a sequence of the UID's of the entries
+ */
+ String_Sequence get_object_id_list();
+
+ /*
* get_updated_objects:
*
* Returns a vCalendar with all the objects that have been
diff --git a/calendar/gui/calendar-conduit.c b/calendar/gui/calendar-conduit.c
index cb8f53eba9..3fd110100a 100644
--- a/calendar/gui/calendar-conduit.c
+++ b/calendar/gui/calendar-conduit.c
@@ -32,6 +32,7 @@
GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
+void local_record_from_icalobject(CalLocalRecord *local,iCalObject *obj);
typedef struct _ConduitData ConduitData;
@@ -74,6 +75,43 @@ calendar_notify (time_t time, CalendarAlarm *which, void *data)
static GList *
get_calendar_objects(GnomePilotConduitStandardAbs *conduit)
{
+ GList *result;
+ GNOME_Calendar_Repository_String_Sequence *uids;
+
+ g_return_val_if_fail(conduit!=NULL,NULL);
+
+ result = NULL;
+ uids = GNOME_Calendar_Repository_get_object_id_list (calendar, &ev);
+
+ if (ev._major == CORBA_USER_EXCEPTION){
+ g_message ("calconduit: \tObject did not exist\n");
+ g_warning("\texception id = %s\n",CORBA_exception_id(&ev));
+ CORBA_exception_free(&ev);
+ return NULL;
+ } else if(ev._major != CORBA_NO_EXCEPTION) {
+ g_warning(_("\tError while communicating with calendar server\n"));
+ g_warning("\texception id = %s\n",CORBA_exception_id(&ev));
+ CORBA_exception_free(&ev);
+ return NULL;
+ }
+
+ if(uids->_length>0) {
+ int i;
+ for(i=0;i<uids->_length;i++) {
+ result = g_list_prepend(result,g_strdup(uids->_buffer[i]));
+ }
+ } else
+ g_message("No entries found");
+
+ CORBA_free(uids);
+
+ return result;
+}
+
+#if 0
+static GList *
+get_calendar_objects(GnomePilotConduitStandardAbs *conduit)
+{
char *vcalendar_string;
char *error;
GList *retval,*l;
@@ -87,6 +125,19 @@ get_calendar_objects(GnomePilotConduitStandardAbs *conduit)
cal = calendar_new("Temporary");
error = calendar_load_from_memory(cal,vcalendar_string);
+
+ if (ev._major == CORBA_USER_EXCEPTION){
+ g_message ("calconduit: \tObject did not exist\n");
+ g_warning("\texception id = %s\n",CORBA_exception_id(&ev));
+ CORBA_exception_free(&ev);
+ return;
+ } else if(ev._major != CORBA_NO_EXCEPTION) {
+ g_warning(_("\tError while communicating with calendar server\n"));
+ g_warning("\texception id = %s\n",CORBA_exception_id(&ev));
+ CORBA_exception_free(&ev);
+ return;
+ }
+
if(error != NULL) {
g_warning("Error while converting records");
g_warning("Error : %s",error);
@@ -105,50 +156,79 @@ get_calendar_objects(GnomePilotConduitStandardAbs *conduit)
return retval;
}
+#endif
+
+static void
+local_record_from_ical_uid(CalLocalRecord *local,
+ char *uid)
+{
+ iCalObject *obj;
+ char *vcalendar_string;
+
+ g_assert(local!=NULL);
+
+ vcalendar_string = GNOME_Calendar_Repository_get_object(calendar, uid, &ev);
+
+ if (ev._major == CORBA_USER_EXCEPTION){
+ g_message ("calconduit: \tObject did not exist\n");
+ g_warning("\texception id = %s\n",CORBA_exception_id(&ev));
+ CORBA_exception_free(&ev);
+ return;
+ } else if(ev._major != CORBA_NO_EXCEPTION) {
+ g_warning(_("\tError while communicating with calendar server\n"));
+ g_warning("\texception id = %s\n",CORBA_exception_id(&ev));
+ CORBA_exception_free(&ev);
+ return;
+ }
+ g_return_if_fail(vcalendar_string!=NULL);
+
+ obj = ical_object_new_from_string (vcalendar_string);
+
+ local_record_from_icalobject(local,obj);
+
+ return;
+}
+
/*
* converts a iCalObject to a CalLocalRecord
*/
-static void
-local_record_from_icalobject(CalLocalRecord **local,
+void
+local_record_from_icalobject(CalLocalRecord *local,
iCalObject *obj)
{
g_return_if_fail(local!=NULL);
- g_return_if_fail(*local!=NULL);
g_return_if_fail(obj!=NULL);
- (*local)->ical = obj;
- (*local)->local.ID = (*local)->ical->pilot_id;
+ local->ical = obj;
+ local->local.ID = local->ical->pilot_id;
- g_print("calconduit: (*local)->Id = %ld [%s], status = %d\n",
- (*local)->local.ID,obj->summary,(*local)->ical->pilot_status);
+ g_print("calconduit: local->Id = %ld [%s], status = %d\n",
+ local->local.ID,obj->summary,local->ical->pilot_status);
- switch((*local)->ical->pilot_status) {
+ switch(local->ical->pilot_status) {
case ICAL_PILOT_SYNC_NONE:
- (*local)->local.attr = GnomePilotRecordNothing;
+ local->local.attr = GnomePilotRecordNothing;
break;
case ICAL_PILOT_SYNC_MOD:
- (*local)->local.attr = GnomePilotRecordModified;
+ local->local.attr = GnomePilotRecordModified;
break;
case ICAL_PILOT_SYNC_DEL:
- (*local)->local.attr = GnomePilotRecordDeleted;
+ local->local.attr = GnomePilotRecordDeleted;
break;
}
/* Records without a pilot_id are new */
- if((*local)->local.ID == 0)
- (*local)->local.attr = GnomePilotRecordNew;
+ if(local->local.ID == 0)
+ local->local.attr = GnomePilotRecordNew;
- (*local)->local.secret = 0;
+ local->local.secret = 0;
if(obj->class!=NULL)
if(strcmp(obj->class,"PRIVATE")==0)
- (*local)->local.secret = 1;
+ local->local.secret = 1;
- (*local)->local.archived = 0;
-
- /* used by iterations */
- (*local)->list_ptr = NULL;
+ local->local.archived = 0;
}
/*
@@ -165,7 +245,6 @@ find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
g_return_val_if_fail(conduit!=NULL,NULL);
g_return_val_if_fail(remote!=NULL,NULL);
- g_message ("calconduit: requesting %ld []\n", remote->ID);
vcal_string =
GNOME_Calendar_Repository_get_object_by_pilot_id (calendar, remote->ID, &ev);
@@ -182,7 +261,7 @@ find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
g_message ("calconduit: \tFound\n");
loc = g_new0(CalLocalRecord,1);
/* memory allocated in new_from_string is freed in free_match */
- local_record_from_icalobject(&loc,
+ local_record_from_icalobject(loc,
ical_object_new_from_string (vcal_string));
/* g_free(vcal_string); FIXME: this coredumps, but won't it leak without ? */
return loc;
@@ -589,7 +668,8 @@ iterate (GnomePilotConduitStandardAbs *conduit,
CalLocalRecord **local,
gpointer data)
{
- static GList *events;
+ static GList *events,*iterator;
+ static int hest;
g_return_val_if_fail(local!=NULL,0);
@@ -597,29 +677,31 @@ iterate (GnomePilotConduitStandardAbs *conduit,
g_print("calconduit: beginning iteration\n");
events = get_calendar_objects(conduit);
-
+ hest = 0;
+
if(events!=NULL) {
g_print("calconduit: iterating over %d records\n",g_list_length(events));
*local = g_new0(CalLocalRecord,1);
- local_record_from_icalobject(local,(iCalObject*)events->data);
- (*local)->list_ptr = events;
+ local_record_from_ical_uid(*local,(gchar*)events->data);
+ iterator = events;
} else {
g_print("calconduit: no events\n");
(*local) = NULL;
}
} else {
g_print("calconduit: continuing iteration\n");
- if(g_list_next((*local)->list_ptr)==NULL) {
+ hest++;
+ if(g_list_next(iterator)==NULL) {
GList *l;
g_print("calconduit: ending\n");
/** free stuff allocated for iteration */
g_free((*local));
- g_print("calconduit: iterated over %d records\n",g_list_length(events));
+ g_print("calconduit: iterated over %d records\n",hest);
for(l=events;l;l=l->next)
- ical_object_destroy(l->data);
+ g_free(l->data);
g_list_free(events);
@@ -627,8 +709,8 @@ iterate (GnomePilotConduitStandardAbs *conduit,
(*local) = NULL;
return 0;
} else {
- local_record_from_icalobject(local,(iCalObject*)(g_list_next((*local)->list_ptr)->data));
- (*local)->list_ptr = g_list_next((*local)->list_ptr);
+ iterator = g_list_next(iterator);
+ local_record_from_ical_uid(*local,(gchar*)(iterator->data));
}
}
return 1;
@@ -647,7 +729,7 @@ iterate_specific (GnomePilotConduitStandardAbs *conduit,
/** iterate until a record meets the criteria */
while(gnome_pilot_conduit_standard_abs_iterate(conduit,(LocalRecord**)local)) {
if((*local)==NULL) break;
- g_print("calconduit: local->attr = %d, flag = %d, & %d\n",(*local)->local.attr,flag,((*local)->local.attr & flag));
+ /* g_print("calconduit: local->attr = %d, flag = %d, & %d\n",(*local)->local.attr,flag,((*local)->local.attr & flag)); */
if(archived && ((*local)->local.archived==archived)) break;
if(((*local)->local.attr == flag)) break;
}
@@ -835,10 +917,28 @@ transmit (GnomePilotConduitStandardAbs *conduit,
local->a->begin = *localtime(&local->ical->dtstart);
local->a->end = *localtime(&local->ical->dtend);
- local->a->alarm = 0;
- local->a->advance = 0;
- local->a->advanceUnits = advMinutes;
+ /* set the Audio Alarm parameters */
+ if(local->ical->aalarm.enabled) {
+ local->a->alarm = 1;
+ local->a->advance = local->ical->aalarm.count;
+ switch(local->ical->aalarm.units) {
+ case ALARM_MINUTES:
+ local->a->advanceUnits = advMinutes;
+ break;
+ case ALARM_HOURS:
+ local->a->advanceUnits = advHours;
+ break;
+ case ALARM_DAYS:
+ local->a->advanceUnits = advDays;
+ break;
+ }
+ } else {
+ local->a->alarm = 0;
+ local->a->advance = 0;
+ local->a->advanceUnits = advMinutes;
+ }
+ /* set the recurrence parameters */
if (local->ical->recur != NULL) {
switch (local->ical->recur->type) {
case RECUR_DAILY:
@@ -898,6 +998,7 @@ transmit (GnomePilotConduitStandardAbs *conduit,
local->a->description =
local->ical->summary==NULL?NULL:strdup(local->ical->summary);
+ /* Generate pilot record structure */
p->record = g_new0(char,0xffff);
p->length = pack_Appointment(local->a,p->record,0xffff);
diff --git a/calendar/gui/calendar-conduit.h b/calendar/gui/calendar-conduit.h
index 86b38cc802..d8b320c1ce 100644
--- a/calendar/gui/calendar-conduit.h
+++ b/calendar/gui/calendar-conduit.h
@@ -25,8 +25,6 @@ struct _CalLocalRecord {
LocalRecord local;
/* The corresponding iCal object */
iCalObject *ical;
- /* used by iterations, points to a GList element */
- GList *list_ptr;
/* pilot-link appointment structure, used for implementing Transmit */
struct Appointment *a;
};
diff --git a/calendar/gui/corba-cal.c b/calendar/gui/corba-cal.c
index 49978a5bf1..ddeb5ccb45 100644
--- a/calendar/gui/corba-cal.c
+++ b/calendar/gui/corba-cal.c
@@ -198,33 +198,39 @@ cal_repo_get_objects (PortableServer_Servant servant,
CORBA_Environment *ev)
{
GnomeCalendar *gcal = gnomecal_from_servant (servant);
- Calendar *dirty_cal;
- GList *l;
char *str;
CORBA_char *res;
- int items_dbg=0;
- g_message("in cal_repo_get_objects");
-
- dirty_cal = calendar_new ("Temporal");
-
- for (l = gcal->cal->events; l; l = l->next){
- iCalObject *obj = l->data;
+ str = calendar_get_as_vcal_string (gcal->cal);
+ g_message("length of result is %d",strlen(str));
+ res = CORBA_string_dup (str);
+ free(str); /* ...get_as_vcal calls writeMemVObject, which uses realloc to
+ allocate this string */
- obj = ical_object_duplicate (l->data);
+ return res;
+}
- calendar_add_object (dirty_cal, obj);
+static GNOME_Calendar_Repository_String_Sequence*
+cal_repo_get_object_id_list(PortableServer_Servant servant,
+ CORBA_Environment *ev)
+{
+ GnomeCalendar *gcal = gnomecal_from_servant (servant);
+ GList *l;
+ GNOME_Calendar_Repository_String_Sequence *result;
+ int counter;
+
+ result = GNOME_Calendar_Repository_String_Sequence__alloc();
+ result->_length = g_list_length(gcal->cal->events);
+ result->_buffer = CORBA_sequence_CORBA_string_allocbuf(result->_length);
- items_dbg++;
+ counter = 0;
+ for (l = gcal->cal->events ; l; l = l->next){
+ iCalObject *obj = l->data;
+ result->_buffer[counter] = CORBA_string_dup(obj->uid);
+ counter++;
}
- str = calendar_get_as_vcal_string (dirty_cal);
- res = CORBA_string_dup (str);
- /* g_free (str); glib with memcheck enabled says this is already freed */
- calendar_destroy (dirty_cal);
- g_message("added %d items to return value",items_dbg);
-
- return res;
+ return result;
}
static CORBA_char *
@@ -277,6 +283,7 @@ init_calendar_repo_class (void)
calendar_repository_epv.get_objects = cal_repo_get_objects;
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;