aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/calendar-conduit.c
diff options
context:
space:
mode:
authorEskil Heyn Olsen <eskil@src.gnome.org>1999-10-22 09:16:15 +0800
committerEskil Heyn Olsen <eskil@src.gnome.org>1999-10-22 09:16:15 +0800
commit47f01927e15b6eb279d2cbf046b2707467096666 (patch)
tree9a61c996094c07640cad5f1d77b0956e4f361b48 /calendar/calendar-conduit.c
parent0a505aa40e7504dec10119c0bb4c84087e3d06d4 (diff)
downloadgsoc2013-evolution-47f01927e15b6eb279d2cbf046b2707467096666.tar
gsoc2013-evolution-47f01927e15b6eb279d2cbf046b2707467096666.tar.gz
gsoc2013-evolution-47f01927e15b6eb279d2cbf046b2707467096666.tar.bz2
gsoc2013-evolution-47f01927e15b6eb279d2cbf046b2707467096666.tar.lz
gsoc2013-evolution-47f01927e15b6eb279d2cbf046b2707467096666.tar.xz
gsoc2013-evolution-47f01927e15b6eb279d2cbf046b2707467096666.tar.zst
gsoc2013-evolution-47f01927e15b6eb279d2cbf046b2707467096666.zip
now it doesn't build todo conduit anymore. Since the conduit is just a
* Makefile.am: now it doesn't build todo conduit anymore. Since the conduit is just a skeleton, no need to build and install it. * calendar-conduit-control-applet.c: revamped for all the changes in calendar-conduit.h. Also fixed the pilotId bug that all conduit capplets had. * calendar-conduit-control-applet.desktop: renamed to GnomeCalendar. * calendar-conduit.h: Fixed namespace pollution, appended GCal to structures, gcalconduit to methods. Introduced the GCalConduitContext. * calendar-conduit.c: No more global variables, all is contained in a GCalConduitContext variable, that all the signals are passed as user data. svn path=/trunk/; revision=1338
Diffstat (limited to 'calendar/calendar-conduit.c')
-rw-r--r--calendar/calendar-conduit.c389
1 files changed, 196 insertions, 193 deletions
diff --git a/calendar/calendar-conduit.c b/calendar/calendar-conduit.c
index 193cc52e04..400824186a 100644
--- a/calendar/calendar-conduit.c
+++ b/calendar/calendar-conduit.c
@@ -32,16 +32,10 @@
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;
-
-struct _ConduitData {
- struct AppointmentAppInfo ai;
-};
+void local_record_from_icalobject(GCalLocalRecord *local,iCalObject *obj);
#define CONDUIT_VERSION "0.8.0"
-#define DEBUG_CALCONDUIT
+/* #define DEBUG_CALCONDUIT */
#ifdef DEBUG_CALCONDUIT
#define show_exception(e) g_warning ("Exception: %s\n", CORBA_exception_id (e))
@@ -54,30 +48,28 @@ struct _ConduitData {
#define WARN(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_WARNING, e)
#define INFO(e...) g_log(G_LOG_DOMAIN,G_LOG_LEVEL_MESSAGE, "calconduit: "##e)
-#define GET_DATA(c) ((ConduitData*)gtk_object_get_data(GTK_OBJECT(c),"conduit_data"))
-
-GNOME_Calendar_Repository calendar;
-CORBA_Environment ev;
-CORBA_ORB orb;
-
-static GNOME_Calendar_Repository
-start_calendar_server (GnomePilotConduitStandardAbs *conduit)
+static int
+start_calendar_server (GnomePilotConduitStandardAbs *conduit,
+ GCalConduitContext *ctxt)
{
- g_return_val_if_fail(conduit!=NULL,CORBA_OBJECT_NIL);
-
- calendar = goad_server_activate_with_id (NULL,
- "IDL:GNOME:Calendar:Repository:1.0",
- 0, NULL);
- if (calendar == CORBA_OBJECT_NIL)
+
+ g_return_val_if_fail(conduit!=NULL,-2);
+ g_return_val_if_fail(ctxt!=NULL,-2);
+
+ ctxt->calendar = goad_server_activate_with_id (NULL,
+ "IDL:GNOME:Calendar:Repository:1.0",
+ 0, NULL);
+ if (ctxt->calendar == CORBA_OBJECT_NIL) {
g_error ("Can not communicate with GnomeCalendar server");
-
- if (ev._major != CORBA_NO_EXCEPTION){
- show_exception(&ev);
- CORBA_exception_free(&ev);
- return CORBA_OBJECT_NIL;
+ return -1;
}
- return calendar;
+ if (ctxt->ev._major != CORBA_NO_EXCEPTION){
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
+ return -1;
+ }
+ return 0;
}
@@ -88,25 +80,27 @@ calendar_notify (time_t time, CalendarAlarm *which, void *data)
}
static GList *
-get_calendar_objects(GnomePilotConduitStandardAbs *conduit)
+get_calendar_objects(GnomePilotConduitStandardAbs *conduit,
+ GCalConduitContext *ctxt)
{
GList *result;
GNOME_Calendar_Repository_String_Sequence *uids;
g_return_val_if_fail(conduit!=NULL,NULL);
+ g_return_val_if_fail(ctxt!=NULL,NULL);
result = NULL;
- uids = GNOME_Calendar_Repository_get_object_id_list (calendar, &ev);
+ uids = GNOME_Calendar_Repository_get_object_id_list (ctxt->calendar, &(ctxt->ev));
- if (ev._major == CORBA_USER_EXCEPTION){
+ if (ctxt->ev._major == CORBA_USER_EXCEPTION){
INFO ("Object did not exist");
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return NULL;
- } else if(ev._major != CORBA_NO_EXCEPTION) {
+ } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
WARN (_("Error while communicating with calendar server"));
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return NULL;
}
@@ -174,25 +168,26 @@ get_calendar_objects(GnomePilotConduitStandardAbs *conduit)
#endif
static void
-local_record_from_ical_uid(CalLocalRecord *local,
- char *uid)
+local_record_from_ical_uid(GCalLocalRecord *local,
+ char *uid,
+ GCalConduitContext *ctxt)
{
iCalObject *obj;
char *vcalendar_string;
g_assert(local!=NULL);
- vcalendar_string = GNOME_Calendar_Repository_get_object(calendar, uid, &ev);
+ vcalendar_string = GNOME_Calendar_Repository_get_object(ctxt->calendar, uid, &(ctxt->ev));
- if (ev._major == CORBA_USER_EXCEPTION){
+ if (ctxt->ev._major == CORBA_USER_EXCEPTION){
INFO ("Object did not exist");
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return;
- } else if(ev._major != CORBA_NO_EXCEPTION) {
+ } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
WARN (_("Error while communicating with calendar server"));
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return;
}
g_return_if_fail(vcalendar_string!=NULL);
@@ -206,11 +201,11 @@ local_record_from_ical_uid(CalLocalRecord *local,
/*
- * converts a iCalObject to a CalLocalRecord
+ * converts a iCalObject to a GCalLocalRecord
*/
void
-local_record_from_icalobject(CalLocalRecord *local,
+local_record_from_icalobject(GCalLocalRecord *local,
iCalObject *obj)
{
g_return_if_fail(local!=NULL);
@@ -250,33 +245,34 @@ local_record_from_icalobject(CalLocalRecord *local,
* Given a PilotRecord, find the matching record in
* the calendar repository. If no match, return NULL
*/
-static CalLocalRecord *
+static GCalLocalRecord *
find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote)
+ PilotRecord *remote,
+ GCalConduitContext *ctxt)
{
char *vcal_string;
- CalLocalRecord *loc;
+ GCalLocalRecord *loc;
g_return_val_if_fail(conduit!=NULL,NULL);
g_return_val_if_fail(remote!=NULL,NULL);
vcal_string =
- GNOME_Calendar_Repository_get_object_by_pilot_id (calendar, remote->ID, &ev);
+ GNOME_Calendar_Repository_get_object_by_pilot_id (ctxt->calendar, remote->ID, &(ctxt->ev));
- if (ev._major == CORBA_USER_EXCEPTION){
+ if (ctxt->ev._major == CORBA_USER_EXCEPTION){
INFO ("Object did not exist");
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return NULL;
- } else if(ev._major != CORBA_NO_EXCEPTION) {
+ } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
WARN (_("Error while communicating with calendar server"));
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return NULL;
} else {
LOG ("Found");
- loc = g_new0(CalLocalRecord,1);
+ loc = g_new0(GCalLocalRecord,1);
/* memory allocated in new_from_string is freed in free_match */
local_record_from_icalobject(loc,
ical_object_new_from_string (vcal_string));
@@ -292,7 +288,8 @@ find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
*/
static void
update_calendar_entry_in_repository(GnomePilotConduitStandardAbs *conduit,
- iCalObject *obj)
+ iCalObject *obj,
+ GCalConduitContext *ctxt)
{
char *str;
@@ -301,17 +298,17 @@ update_calendar_entry_in_repository(GnomePilotConduitStandardAbs *conduit,
str = calendar_string_from_object (obj);
- GNOME_Calendar_Repository_update_object (calendar, obj->uid, str, &ev);
+ GNOME_Calendar_Repository_update_object (ctxt->calendar, obj->uid, str, &(ctxt->ev));
- if (ev._major == CORBA_USER_EXCEPTION){
+ if (ctxt->ev._major == CORBA_USER_EXCEPTION){
INFO ("Object did not exist");
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return;
- } else if(ev._major != CORBA_NO_EXCEPTION) {
+ } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
WARN (_("Error while communicating with calendar server"));
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return;
}
@@ -506,7 +503,8 @@ ical_from_remote_record(GnomePilotConduitStandardAbs *conduit,
*/
static gint
update_record (GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote)
+ PilotRecord *remote,
+ GCalConduitContext *ctxt)
{
char *vcal_string;
iCalObject *obj;
@@ -522,17 +520,17 @@ update_record (GnomePilotConduitStandardAbs *conduit,
a.description ? a.description : "");
LOG ("requesting %ld [%s]", remote->ID, a.description);
- vcal_string = GNOME_Calendar_Repository_get_object_by_pilot_id (calendar, remote->ID, &ev);
+ vcal_string = GNOME_Calendar_Repository_get_object_by_pilot_id (ctxt->calendar, remote->ID, &(ctxt->ev));
- if (ev._major == CORBA_USER_EXCEPTION){
- WARN (_("Object did not exist, creating a new one"));
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ if (ctxt->ev._major == CORBA_USER_EXCEPTION){
+ LOG (_("Object did not exist, creating a new one"));
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
ical_from_remote_record(conduit,remote,obj);
- } else if(ev._major != CORBA_NO_EXCEPTION) {
+ } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
WARN (_("Error while communicating with calendar server"));
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
ical_object_destroy (obj);
free_Appointment(&a);
return -1;
@@ -546,7 +544,7 @@ update_record (GnomePilotConduitStandardAbs *conduit,
/* update record on server */
- update_calendar_entry_in_repository(conduit,obj);
+ update_calendar_entry_in_repository(conduit,obj,ctxt);
/*
* Shutdown
@@ -559,16 +557,18 @@ update_record (GnomePilotConduitStandardAbs *conduit,
static gint
-pre_sync(GnomePilotConduit *c, GnomePilotDBInfo *dbi)
+pre_sync(GnomePilotConduit *c,
+ GnomePilotDBInfo *dbi,
+ GCalConduitContext *ctxt)
{
int l;
unsigned char *buf;
- INFO (CONDUIT_VERSION);
+ g_message ("GnomeCal Conduit v.%s",CONDUIT_VERSION);
- calendar = CORBA_OBJECT_NIL;
- calendar = start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c));
- if(calendar == CORBA_OBJECT_NIL) {
+ ctxt->calendar = CORBA_OBJECT_NIL;
+
+ if (start_calendar_server(GNOME_PILOT_CONDUIT_STANDARD_ABS(c),GET_GCALCONTEXT(c)) != 0) {
return -1;
}
@@ -580,7 +580,7 @@ pre_sync(GnomePilotConduit *c, GnomePilotDBInfo *dbi)
if((l=dlp_ReadAppBlock(dbi->pilot_socket,dbi->db_handle,0,(unsigned char *)buf,0xffff))<0) {
return -1;
}
- unpack_AppointmentAppInfo(&(GET_DATA(c)->ai),buf,l);
+ unpack_AppointmentAppInfo(&(ctxt->ai),buf,l);
g_free(buf);
return 0;
@@ -596,16 +596,16 @@ pre_sync(GnomePilotConduit *c, GnomePilotDBInfo *dbi)
static gint
match_record (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord **local,
+ GCalLocalRecord **local,
PilotRecord *remote,
- gpointer data)
+ GCalConduitContext *ctxt)
{
LOG ("in match_record");
g_return_val_if_fail(local!=NULL,-1);
g_return_val_if_fail(remote!=NULL,-1);
- *local = find_record_in_repository(conduit,remote);
+ *local = find_record_in_repository(conduit,remote,ctxt);
if (*local==NULL) return -1;
return 0;
@@ -618,15 +618,15 @@ match_record (GnomePilotConduitStandardAbs *conduit,
*/
static gint
free_match (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord **local,
- gpointer data)
+ GCalLocalRecord **local,
+ GCalConduitContext *ctxt)
{
LOG ("entering free_match");
g_return_val_if_fail(local!=NULL,-1);
g_return_val_if_fail(*local!=NULL,-1);
- ical_object_destroy (CALLOCALRECORD(*local)->ical);
+ ical_object_destroy (GCAL_LOCALRECORD(*local)->ical);
g_free(*local);
*local = NULL;
@@ -638,8 +638,8 @@ free_match (GnomePilotConduitStandardAbs *conduit,
*/
static gint
archive_local (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord *local,
- gpointer data)
+ GCalLocalRecord *local,
+ GCalConduitContext *ctxt)
{
LOG ("entering archive_local");
@@ -653,9 +653,9 @@ archive_local (GnomePilotConduitStandardAbs *conduit,
*/
static gint
archive_remote (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord *local,
+ GCalLocalRecord *local,
PilotRecord *remote,
- gpointer data)
+ GCalConduitContext *ctxt)
{
LOG ("entering archive_remote");
@@ -671,19 +671,19 @@ archive_remote (GnomePilotConduitStandardAbs *conduit,
static gint
store_remote (GnomePilotConduitStandardAbs *conduit,
PilotRecord *remote,
- gpointer data)
+ GCalConduitContext *ctxt)
{
LOG ("entering store_remote");
g_return_val_if_fail(remote!=NULL,-1);
- return update_record(conduit,remote);
+ return update_record(conduit,remote,ctxt);
}
static gint
clear_status_archive_local (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord *local,
- gpointer data)
+ GCalLocalRecord *local,
+ GCalConduitContext *ctxt)
{
LOG ("entering clear_status_archive_local");
@@ -694,8 +694,8 @@ clear_status_archive_local (GnomePilotConduitStandardAbs *conduit,
static gint
iterate (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord **local,
- gpointer data)
+ GCalLocalRecord **local,
+ GCalConduitContext *ctxt)
{
static GList *events,*iterator;
static int hest;
@@ -705,14 +705,14 @@ iterate (GnomePilotConduitStandardAbs *conduit,
if(*local==NULL) {
LOG ("beginning iteration");
- events = get_calendar_objects(conduit);
+ events = get_calendar_objects(conduit,ctxt);
hest = 0;
if(events!=NULL) {
LOG ("iterating over %d records",g_list_length(events));
- *local = g_new0(CalLocalRecord,1);
+ *local = g_new0(GCalLocalRecord,1);
- local_record_from_ical_uid(*local,(gchar*)events->data);
+ local_record_from_ical_uid(*local,(gchar*)events->data,ctxt);
iterator = events;
} else {
LOG ("no events");
@@ -739,7 +739,7 @@ iterate (GnomePilotConduitStandardAbs *conduit,
return 0;
} else {
iterator = g_list_next(iterator);
- local_record_from_ical_uid(*local,(gchar*)(iterator->data));
+ local_record_from_ical_uid(*local,(gchar*)(iterator->data),ctxt);
}
}
return 1;
@@ -747,10 +747,10 @@ iterate (GnomePilotConduitStandardAbs *conduit,
static gint
iterate_specific (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord **local,
+ GCalLocalRecord **local,
gint flag,
gint archived,
- gpointer data)
+ GCalConduitContext *ctxt)
{
#ifdef DEBUG_CALCONDUIT
{
@@ -769,7 +769,6 @@ 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)); */
if(archived && ((*local)->local.archived==archived)) break;
if(((*local)->local.attr == flag)) break;
}
@@ -779,7 +778,7 @@ iterate_specific (GnomePilotConduitStandardAbs *conduit,
static gint
purge (GnomePilotConduitStandardAbs *conduit,
- gpointer data)
+ GCalConduitContext *ctxt)
{
LOG ("entering purge");
@@ -791,9 +790,9 @@ purge (GnomePilotConduitStandardAbs *conduit,
static gint
set_status (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord *local,
+ GCalLocalRecord *local,
gint status,
- gpointer data)
+ GCalConduitContext *ctxt)
{
LOG ("entering set_status");
@@ -816,23 +815,23 @@ set_status (GnomePilotConduitStandardAbs *conduit,
}
if ( status != GnomePilotRecordDeleted)
- GNOME_Calendar_Repository_update_pilot_id(calendar,
+ GNOME_Calendar_Repository_update_pilot_id(ctxt->calendar,
local->ical->uid,
local->local.ID,
local->ical->pilot_status,
- &ev);
+ &(ctxt->ev));
else
- GNOME_Calendar_Repository_delete_object(calendar,local->ical->uid,&ev);
+ GNOME_Calendar_Repository_delete_object(ctxt->calendar,local->ical->uid,&(ctxt->ev));
- if (ev._major == CORBA_USER_EXCEPTION){
+ if (ctxt->ev._major == CORBA_USER_EXCEPTION){
LOG ("Object did not exist");
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return -1;
- } else if(ev._major != CORBA_NO_EXCEPTION) {
+ } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
WARN (_("Error while communicating with calendar server"));
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return -1;
}
return 0;
@@ -840,9 +839,9 @@ set_status (GnomePilotConduitStandardAbs *conduit,
static gint
set_archived (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord *local,
+ GCalLocalRecord *local,
gint archived,
- gpointer data)
+ GCalConduitContext *ctxt)
{
LOG ("entering set_archived");
@@ -850,7 +849,7 @@ set_archived (GnomePilotConduitStandardAbs *conduit,
g_assert(local->ical!=NULL);
local->local.archived = archived;
- update_calendar_entry_in_repository(conduit,local->ical);
+ update_calendar_entry_in_repository(conduit,local->ical,ctxt);
/* FIXME: This should move the entry into a speciel
calendar file, eg. Archive, or (by config option), simply
delete it */
@@ -859,9 +858,9 @@ set_archived (GnomePilotConduitStandardAbs *conduit,
static gint
set_pilot_id (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord *local,
+ GCalLocalRecord *local,
guint32 ID,
- gpointer data)
+ GCalConduitContext *ctxt)
{
LOG ("entering set_pilot_id");
@@ -870,21 +869,21 @@ set_pilot_id (GnomePilotConduitStandardAbs *conduit,
local->local.ID = ID;
local->ical->pilot_id = ID;
- GNOME_Calendar_Repository_update_pilot_id(calendar,
+ GNOME_Calendar_Repository_update_pilot_id(ctxt->calendar,
local->ical->uid,
local->local.ID,
local->ical->pilot_status,
- &ev);
+ &(ctxt->ev));
- if (ev._major == CORBA_USER_EXCEPTION){
+ if (ctxt->ev._major == CORBA_USER_EXCEPTION){
LOG ("Object did not exist");
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return -1;
- } else if(ev._major != CORBA_NO_EXCEPTION) {
+ } else if(ctxt->ev._major != CORBA_NO_EXCEPTION) {
WARN (_("Error while communicating with calendar server"));
- show_exception(&ev);
- CORBA_exception_free(&ev);
+ show_exception(&(ctxt->ev));
+ CORBA_exception_free(&(ctxt->ev));
return -1;
}
return 0;
@@ -892,9 +891,9 @@ set_pilot_id (GnomePilotConduitStandardAbs *conduit,
static gint
compare (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord *local,
+ GCalLocalRecord *local,
PilotRecord *remote,
- gpointer data)
+ GCalConduitContext *ctxt)
{
LOG ("entering compare");
@@ -906,9 +905,9 @@ compare (GnomePilotConduitStandardAbs *conduit,
static gint
compare_backup (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord *local,
+ GCalLocalRecord *local,
PilotRecord *remote,
- gpointer data)
+ GCalConduitContext *ctxt)
{
LOG ("entering compare_backup");
@@ -920,9 +919,9 @@ compare_backup (GnomePilotConduitStandardAbs *conduit,
static gint
free_transmit (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord *local,
+ GCalLocalRecord *local,
PilotRecord **remote,
- gpointer data)
+ GCalConduitContext *ctxt)
{
LOG ("entering free_transmit");
@@ -937,7 +936,7 @@ free_transmit (GnomePilotConduitStandardAbs *conduit,
static gint
delete_all (GnomePilotConduitStandardAbs *conduit,
- gpointer data)
+ GCalConduitContext *ctxt)
{
LOG ("entering delete_all");
@@ -946,13 +945,12 @@ delete_all (GnomePilotConduitStandardAbs *conduit,
static gint
transmit (GnomePilotConduitStandardAbs *conduit,
- CalLocalRecord *local,
+ GCalLocalRecord *local,
PilotRecord **remote,
- gpointer data)
+ GCalConduitContext *ctxt)
{
PilotRecord *p;
int daycount;
- int x,y;
LOG ("entering transmit");
@@ -1059,18 +1057,23 @@ transmit (GnomePilotConduitStandardAbs *conduit,
p->length = pack_Appointment(local->a,p->record,0xffff);
#if 0
- g_message("calconduit: new item from %s to %s",asctime(&(local->a->begin)),asctime(&(local->a->end)));
-
- g_message("local->a->note = %s",local->a->note);
- g_message("local->a->description = %s",local->a->description);
- g_message("sizeof(p->record) = %d, length is %d",sizeof(p->record),p->length);
- for(x=0;x<p->length;x+=32) {
- for(y=x;y<x+32;y++)
- if(p->record[y]<33 || p->record[y]>128)
- printf("%02X",p->record[y]);
- else
- printf(" %c",p->record[y]);
- printf("\n");
+ /* This is some debug code that hexdumps the calendar entry...
+ You won't need this. */
+ {
+ int x,y;
+ g_message("calconduit: new item from %s to %s",asctime(&(local->a->begin)),asctime(&(local->a->end)));
+
+ g_message("local->a->note = %s",local->a->note);
+ g_message("local->a->description = %s",local->a->description);
+ g_message("sizeof(p->record) = %d, length is %d",sizeof(p->record),p->length);
+ for(x=0;x<p->length;x+=32) {
+ for(y=x;y<x+32;y++)
+ if(p->record[y]<33 || p->record[y]>128)
+ printf("%02X",p->record[y]);
+ else
+ printf(" %c",p->record[y]);
+ printf("\n");
+ }
}
#endif
@@ -1083,43 +1086,42 @@ GnomePilotConduit *
conduit_get_gpilot_conduit (guint32 pilotId)
{
GtkObject *retval;
- ConduitCfg *cfg;
- ConduitData *cdata;
+ GCalConduitCfg *cfg;
+ GCalConduitContext *ctxt;
- CORBA_exception_init (&ev);
retval = gnome_pilot_conduit_standard_abs_new ("DatebookDB", 0x64617465);
g_assert (retval != NULL);
- gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"calendar");
-
- cfg = g_new0(ConduitCfg,1);
- g_assert(cfg != NULL);
- gtk_object_set_data(retval,"conduit_cfg",cfg);
-
- cdata = g_new0(ConduitData,1);
- g_assert(cdata != NULL);
- gtk_object_set_data(retval,"conduit_data",cdata);
-
- gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, NULL);
- gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, NULL);
- gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, NULL);
- gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, NULL);
- gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, NULL);
- gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, NULL);
- gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, NULL);
- gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, NULL);
- gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, NULL);
- gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, NULL);
- gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, NULL);
- gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, NULL);
- gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, NULL);
- gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, NULL);
- gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, NULL);
- gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, NULL);
- gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, NULL);
- gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, NULL);
-
- load_configuration(&cfg,pilotId);
+ gnome_pilot_conduit_construct(GNOME_PILOT_CONDUIT(retval),"GnomeCalConduit");
+
+ gcalconduit_load_configuration(&cfg,pilotId);
+ gtk_object_set_data(retval,"gcalconduit_cfg",cfg);
+
+ gcalconduit_new_context(&ctxt,cfg);
+ /* No real need to set it, since all signal are given this
+ as their user data */
+ gtk_object_set_data(retval,"gcalconduit_context",ctxt);
+
+ gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, ctxt);
+ gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt);
+ gtk_signal_connect (retval, "archive_local", (GtkSignalFunc) archive_local, ctxt);
+ gtk_signal_connect (retval, "archive_remote", (GtkSignalFunc) archive_remote, ctxt);
+ gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, ctxt);
+ gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, ctxt);
+ gtk_signal_connect (retval, "iterate", (GtkSignalFunc) iterate, ctxt);
+ gtk_signal_connect (retval, "iterate_specific", (GtkSignalFunc) iterate_specific, ctxt);
+ gtk_signal_connect (retval, "purge", (GtkSignalFunc) purge, ctxt);
+ gtk_signal_connect (retval, "set_status", (GtkSignalFunc) set_status, ctxt);
+ gtk_signal_connect (retval, "set_archived", (GtkSignalFunc) set_archived, ctxt);
+ gtk_signal_connect (retval, "set_pilot_id", (GtkSignalFunc) set_pilot_id, ctxt);
+ gtk_signal_connect (retval, "compare", (GtkSignalFunc) compare, ctxt);
+ gtk_signal_connect (retval, "compare_backup", (GtkSignalFunc) compare_backup, ctxt);
+ gtk_signal_connect (retval, "free_transmit", (GtkSignalFunc) free_transmit, ctxt);
+ gtk_signal_connect (retval, "delete_all", (GtkSignalFunc) delete_all, ctxt);
+ gtk_signal_connect (retval, "transmit", (GtkSignalFunc) transmit, ctxt);
+ gtk_signal_connect (retval, "pre_sync", (GtkSignalFunc) pre_sync, ctxt);
+
+
return GNOME_PILOT_CONDUIT (retval);
}
@@ -1127,17 +1129,18 @@ conduit_get_gpilot_conduit (guint32 pilotId)
void
conduit_destroy_gpilot_conduit (GnomePilotConduit *conduit)
{
- ConduitCfg *cc;
- ConduitData *cd;
+ GCalConduitCfg *cc;
+ GCalConduitContext *ctxt;
+
+ cc = GET_GCALCONFIG(conduit);
+ ctxt = GET_GCALCONTEXT(conduit);
- if(calendar!=CORBA_OBJECT_NIL)
- GNOME_Calendar_Repository_done (calendar, &ev);
+ if(ctxt->calendar!=CORBA_OBJECT_NIL)
+ GNOME_Calendar_Repository_done (ctxt->calendar, &(ctxt->ev));
- cc = GET_CONFIG(conduit);
- destroy_configuration(&cc);
+ gcalconduit_destroy_configuration(&cc);
- cd = GET_DATA(conduit);
- g_free(cd);
+ gcalconduit_destroy_context(&ctxt);
gtk_object_destroy (GTK_OBJECT (conduit));