aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/conduits/todo/todo-conduit.c
diff options
context:
space:
mode:
authorSeth Alves <alves@src.gnome.org>2000-08-12 12:19:56 +0800
committerSeth Alves <alves@src.gnome.org>2000-08-12 12:19:56 +0800
commitaa30b83241a0ba4b342fe234e555fb663efc8ea3 (patch)
tree1b84f7ff058343982915acb4c1a1e53827d79f6d /calendar/conduits/todo/todo-conduit.c
parent4430ec83ec3ae4770c08d74bd9434b694e7ee628 (diff)
downloadgsoc2013-evolution-aa30b83241a0ba4b342fe234e555fb663efc8ea3.tar
gsoc2013-evolution-aa30b83241a0ba4b342fe234e555fb663efc8ea3.tar.gz
gsoc2013-evolution-aa30b83241a0ba4b342fe234e555fb663efc8ea3.tar.bz2
gsoc2013-evolution-aa30b83241a0ba4b342fe234e555fb663efc8ea3.tar.lz
gsoc2013-evolution-aa30b83241a0ba4b342fe234e555fb663efc8ea3.tar.xz
gsoc2013-evolution-aa30b83241a0ba4b342fe234e555fb663efc8ea3.tar.zst
gsoc2013-evolution-aa30b83241a0ba4b342fe234e555fb663efc8ea3.zip
stubs for pilot id accessors (cal_component_get_pilot_status):
* cal-util/cal-component.c (cal_component_get_pilot_id): (cal_component_set_pilot_id): stubs for pilot id accessors (cal_component_get_pilot_status): (cal_component_set_pilot_status): stubs for pilot status accessors * conduits/calendar/calendar-conduit.c (transmit): start to convert to cal-component interface * conduits/todo/todo-conduit.c (transmit): same svn path=/trunk/; revision=4767
Diffstat (limited to 'calendar/conduits/todo/todo-conduit.c')
-rw-r--r--calendar/conduits/todo/todo-conduit.c505
1 files changed, 300 insertions, 205 deletions
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
index 387a79936d..2a3c643a3d 100644
--- a/calendar/conduits/todo/todo-conduit.c
+++ b/calendar/conduits/todo/todo-conduit.c
@@ -9,7 +9,7 @@
#include <errno.h>
#include <cal-client/cal-client.h>
-#include <cal-util/calobj.h>
+// #include <cal-util/calobj.h>
#include <cal-util/timeutil.h>
#include <pi-source.h>
#include <pi-socket.h>
@@ -21,6 +21,7 @@
#include <gpilotd/gnome-pilot-conduit.h>
#include <gpilotd/gnome-pilot-conduit-standard-abs.h>
#include <todo-conduit.h>
+#include <libical/src/libical/icaltypes.h>
#include <bonobo.h>
@@ -28,7 +29,7 @@
GnomePilotConduit * conduit_get_gpilot_conduit (guint32);
void conduit_destroy_gpilot_conduit (GnomePilotConduit*);
-void local_record_from_icalobject (GCalLocalRecord *local, iCalObject *obj);
+void local_record_from_icalobject (GCalLocalRecord *local, CalComponent *obj);
#define CONDUIT_VERSION "0.8.11"
#ifdef G_LOG_DOMAIN
@@ -61,28 +62,42 @@ void local_record_from_icalobject (GCalLocalRecord *local, iCalObject *obj);
/* debug spew DELETE ME */
-static char *print_ical (iCalObject *obj)
+static char *print_ical (CalComponent *obj
+ /*iCalObject *obj*/)
{
static char buff[ 4096 ];
+ int indefinite;
+ CalComponentDateTime dtend;
+ int priority;
+ struct icaltimetype *complete;
+ CalComponentText summary;
+ GSList *comments;
+ CalComponentText *first_comment = NULL;
+
if (obj == NULL) {
sprintf (buff, "[NULL]");
return buff;
}
- if (obj->summary) {
- sprintf (buff, "[%d %ld %d %ld '%s' '%s']",
- /* indefinite */ (obj->dtend == 0),
- /* due */ obj->dtend,
- /* priority */ obj->priority,
- /* complete */ (unsigned long int) obj->completed, /* obj->percent ? */
- /* description */ obj->summary,
- /* note */ /* obj->desc ? obj->desc : "" */ obj->comment ? obj->comment : ""
- );
- return buff;
- }
-
- sprintf (buff, "[???]");
+ indefinite = 0; /* FIX ME how do i get this */
+ cal_component_get_dtend (obj, &dtend);
+ priority = 1; /* FIX ME how do i get this */
+ cal_component_get_completed (obj, &complete);
+
+ cal_component_get_summary (obj, &summary);
+ cal_component_get_comment_list (obj, &comments);
+ if (comments)
+ first_comment = (CalComponentText *) comments->data;
+
+ sprintf (buff, "[%d %d-%d-%d %d %d-%d-%d '%s' '%s']",
+ indefinite,
+ dtend.value->year, dtend.value->month, dtend.value->day,
+ priority,
+ complete->year, complete->month, complete->day,
+ summary.value, /* description */
+ first_comment ? first_comment->value : "" /* note */
+ );
return buff;
}
@@ -187,16 +202,16 @@ gnome_calendar_load_cb (GtkWidget *cal_client,
{
CalClient *client = CAL_CLIENT (cal_client);
- printf (" entering gnome_calendar_load_cb, tried=%d\n",
+ LOG (" todo-conduit entering gnome_calendar_load_cb, tried=%d\n",
ctxt->calendar_load_tried);
if (status == CAL_CLIENT_LOAD_SUCCESS) {
ctxt->calendar_load_success = TRUE;
- printf (" success\n");
+ LOG (" success\n");
gtk_main_quit (); /* end the sub event loop */
} else {
if (ctxt->calendar_load_tried) {
- printf (" load and create of calendar failed\n");
+ LOG (" load and create of calendar failed\n");
gtk_main_quit (); /* end the sub event loop */
return;
}
@@ -227,7 +242,7 @@ start_calendar_server (GnomePilotConduitStandardAbs *conduit,
gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_loaded",
gnome_calendar_load_cb, ctxt);
- printf (" calling cal_client_load_calendar\n");
+ LOG (" calling cal_client_load_calendar\n");
cal_client_load_calendar (ctxt->client, ctxt->calendar_file);
/* run a sub event loop to turn cal-client's async load
@@ -261,7 +276,7 @@ get_calendar_objects(GnomePilotConduitStandardAbs *conduit,
uids = cal_client_get_uids (ctxt->client, CALOBJ_TYPE_TODO);
- // printf ("got %d todo entries from cal server\n", g_list_length (uids));
+ // LOG ("got %d todo entries from cal server\n", g_list_length (uids));
if (status != NULL)
(*status) = TRUE;
@@ -284,7 +299,8 @@ local_record_from_ical_uid (GCalLocalRecord *local,
char *uid,
GCalConduitContext *ctxt)
{
- iCalObject *obj;
+ //iCalObject *obj;
+ CalComponent *obj;
CalClientGetStatus status;
g_assert(local!=NULL);
@@ -292,7 +308,7 @@ local_record_from_ical_uid (GCalLocalRecord *local,
status = cal_client_get_object (ctxt->client, uid, &obj);
if (status == CAL_CLIENT_GET_SUCCESS)
- local_record_from_icalobject(local,obj);
+ local_record_from_icalobject (local, obj);
else
INFO ("Object did not exist");
}
@@ -320,48 +336,45 @@ static char *gnome_pilot_status_to_string (gint status)
void
local_record_from_icalobject(GCalLocalRecord *local,
- iCalObject *obj)
+ CalComponent *obj)
{
+ //iCalPilotState pilot_status;
+ unsigned long int pilot_status;
+
g_return_if_fail(local!=NULL);
g_return_if_fail(obj!=NULL);
local->ical = obj;
local->todo = NULL; /* ??? */
- local->local.ID = local->ical->pilot_id;
-/*
- LOG ("local->Id = %ld [%s], status = %d",
- local->local.ID,obj->summary,local->ical->pilot_status);
-*/
- switch(local->ical->pilot_status) {
+ cal_component_get_pilot_id (obj, &local->local.ID);
+ cal_component_get_pilot_status (obj, &pilot_status);
+
+ switch (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;
break;
default:
- g_warning ("unhandled pilot status: %d\n", local->ical->pilot_status);
+ g_warning ("unhandled pilot status: %ld\n", pilot_status);
}
/* Records without a pilot_id are new */
- if(local->local.ID == 0)
- local->local.attr = GnomePilotRecordNew;
-
- local->local.secret = 0;
- if(obj->class!=NULL)
- if(strcmp(obj->class,"PRIVATE")==0)
- local->local.secret = 1;
-
- local->local.archived = 0;
+ if(local->local.ID == 0)
+ local->local.attr = GnomePilotRecordNew;
/*
- printf ("local_record_from_icalobject: %s %s\n",
- print_ical (obj),
- gnome_pilot_status_to_string (local->local.attr));
+ local->local.secret = 0;
+ if (obj->class!=NULL)
+ if (strcmp(obj->class,"PRIVATE")==0)
+ local->local.secret = 1;
*/
+
+ local->local.archived = 0;
}
@@ -377,12 +390,14 @@ find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
char *uid = NULL;
GCalLocalRecord *loc;
CalClientGetStatus status;
- iCalObject *obj;
+ //iCalObject *obj;
+ CalComponent *obj;
g_return_val_if_fail(conduit!=NULL,NULL);
g_return_val_if_fail(remote!=NULL,NULL);
- printf ("find_record_in_repository: remote=%s... ", print_remote (remote));
+ LOG ("find_record_in_repository: remote=%s... ",
+ print_remote (remote));
// LOG ("requesting %ld", remote->ID);
@@ -391,8 +406,7 @@ find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
if (status == CAL_CLIENT_GET_SUCCESS) {
status = cal_client_get_object (ctxt->client, uid, &obj);
if (status == CAL_CLIENT_GET_SUCCESS) {
- printf ("found %s\n", print_ical (obj));
- // LOG ("Found");
+ LOG ("found %s\n", print_ical (obj));
loc = g_new0(GCalLocalRecord,1);
/* memory allocated in new_from_string is freed in free_match */
local_record_from_icalobject (loc, obj);
@@ -401,7 +415,7 @@ find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
}
// INFO ("Object did not exist");
- printf ("not found\n");
+ LOG ("not found\n");
return NULL;
}
@@ -411,15 +425,16 @@ find_record_in_repository(GnomePilotConduitStandardAbs *conduit,
*/
static void
update_calendar_entry_in_repository(GnomePilotConduitStandardAbs *conduit,
- iCalObject *obj,
+ CalComponent *obj,
GCalConduitContext *ctxt)
{
gboolean success;
- g_return_if_fail(conduit!=NULL);
- g_return_if_fail(obj!=NULL);
+ g_return_if_fail (conduit!=NULL);
+ g_return_if_fail (obj!=NULL);
- printf (" update_calendar_entry_in_repository saving %s to desktop\n",
+ LOG (" update_calendar_entry_in_repository "
+ "saving %s to desktop\n",
print_ical (obj));
success = cal_client_update_object (ctxt->client, obj);
@@ -430,83 +445,106 @@ update_calendar_entry_in_repository(GnomePilotConduitStandardAbs *conduit,
}
-static iCalObject *
-ical_from_remote_record(GnomePilotConduitStandardAbs *conduit,
- PilotRecord *remote,
- iCalObject *in_obj)
+static CalComponent *
+ical_from_remote_record (GnomePilotConduitStandardAbs *conduit,
+ PilotRecord *remote,
+ CalComponent *in_obj)
{
- iCalObject *obj;
+ CalComponent *obj;
struct ToDo todo;
- time_t now;
+ struct icaltimetype now = icaltimetype_from_timet (time (NULL), FALSE);
- now = time (NULL);
+ CalComponentText summary = {NULL, NULL};
+ CalComponentText comment = {NULL, NULL};
+ GSList *comment_list;
g_return_val_if_fail(remote!=NULL,NULL);
memset (&todo, 0, sizeof (struct ToDo));
unpack_ToDo (&todo, remote->record, remote->length);
- printf (" ical_from_remote_record: merging remote %s into local %s\n",
+ LOG (" ical_from_remote_record: "
+ "merging remote %s into local %s\n",
print_remote (remote), print_ical (in_obj));
- if (in_obj == NULL)
- obj = ical_new (todo.note ? todo.note : "",
- g_get_user_name (),
- todo.description ? todo.description : "");
- else
+ if (in_obj == NULL) {
+ obj = cal_component_new ();
+ } else {
obj = in_obj;
-
- if (todo.note) {
- /* FIX ME which one ? */
- /*
- g_free (obj->desc);
- obj->desc = g_strdup (todo.note);
- */
-
- g_free (obj->comment);
- obj->comment = g_strdup (todo.note);
- }
- if (todo.description) {
- g_free (obj->summary);
- obj->summary = g_strdup (todo.description);
}
- obj->type = ICAL_TODO;
- obj->new = TRUE;
- obj->created = now;
- obj->last_mod = now;
- obj->priority = 0;
- obj->transp = 0;
- obj->related = NULL;
- obj->pilot_id = remote->ID;
- obj->pilot_status = ICAL_PILOT_SYNC_NONE;
+ summary.value = todo.description;
+ cal_component_set_summary (obj, &summary);
+
+ comment.value = todo.note;
+ comment_list = g_slist_append (NULL, &comment);
+ cal_component_set_comment_list (obj, comment_list);
+ g_slist_free (comment_list);
+
+ cal_component_set_new_vtype (obj, CAL_COMPONENT_TODO);
+ // obj->new = TRUE;
+ // obj->created = now;
+ cal_component_set_created (obj, &now);
+ // obj->last_mod = now;
+ cal_component_set_last_modified (obj, &now);
+ /* obj->priority = 0; */
+ // obj->transp = 0;
+ cal_component_set_transparency (obj,
+ /*CalComponentTransparency transp*/
+ CAL_COMPONENT_TRANSP_NONE);
+ /* obj->related = NULL; */
+
+ // cal_component_set_pilot_status (obj, ICAL_PILOT_SYNC_NONE);
/*
* Begin and end
*/
-
- obj->dtend = mktime (& todo.due);
+ // obj->dtend = mktime (& todo.due);
+ {
+ /* do i need to malloc these? FIX ME */
+ struct icaltimetype dtend_ictt;
+ CalComponentDateTime dtend;
+
+ dtend_ictt = icaltimetype_from_timet (mktime (& todo.due), FALSE);
+ dtend.value = &dtend_ictt;
+ dtend.tzid = NULL;
+ cal_component_set_dtend (obj, &dtend);
+ }
+
+
+ /*
if (todo.complete) {
- obj->completed = now-5; /* FIX ME */
+ obj->completed = now-5;
obj->percent = 100;
}
+ */
+ {
+ cal_component_set_completed (obj, &now);
+ }
/*
- printf ("[%s] from pilot, complete=%d/%ld\n",
+ LOG ("[%s] from pilot, complete=%d/%ld\n",
todo.description,
todo.complete,
obj->completed);
*/
- obj->priority = todo.priority;
- g_free (obj->class);
-
+ //obj->priority = todo.priority; FIX ME
+
+ /* g_free (obj->class); */
+
+ /*
if (remote->attr & dlpRecAttrSecret)
obj->class = g_strdup ("PRIVATE");
else
obj->class = g_strdup ("PUBLIC");
+ */
+ if (remote->attr & dlpRecAttrSecret)
+ cal_component_set_classification (obj, CAL_COMPONENT_CLASS_PRIVATE);
+ else
+ cal_component_set_classification (obj, CAL_COMPONENT_CLASS_PUBLIC);
free_ToDo(&todo);
@@ -530,63 +568,89 @@ update_record (GnomePilotConduitStandardAbs *conduit,
PilotRecord *remote,
GCalConduitContext *ctxt)
{
- iCalObject *obj;
+ //iCalObject *obj;
+ CalComponent *obj;
struct ToDo todo;
CalClientGetStatus status;
char *uid;
+ CalComponentText summary = {NULL, NULL};
+ CalComponentText comment = {NULL, NULL};
+ GSList *comment_list;
+
g_return_val_if_fail(remote!=NULL,-1);
memset (&todo, 0, sizeof (struct ToDo));
unpack_ToDo (&todo, remote->record, remote->length);
- // LOG ("requesting %ld [%s]", remote->ID, todo.description);
- printf (" cal_client_get_uid_by_pilot_id... ");
+ LOG (" cal_client_get_uid_by_pilot_id... ");
- status = cal_client_get_uid_by_pilot_id (ctxt->client, remote->ID, &uid);
+ status = cal_client_get_uid_by_pilot_id (ctxt->client,
+ remote->ID, &uid);
if (status == CAL_CLIENT_GET_SUCCESS) {
- printf (" succeeded with '%s'\n", uid);
- printf (" cal_client_get_object... ");
+ LOG (" succeeded with '%s'\n", uid);
+ LOG (" cal_client_get_object... ");
status = cal_client_get_object (ctxt->client, uid, &obj);
}
if (status != CAL_CLIENT_GET_SUCCESS) {
- time_t now = time (NULL);
-
- printf ("failed, making a new one.\n");
-
- obj = ical_new (todo.note ? todo.note : "",
- g_get_user_name (),
- todo.description ? todo.description : "");
-
- obj->type = ICAL_TODO;
- obj->new = TRUE;
- obj->created = now;
- obj->last_mod = now;
- obj->priority = 0;
- obj->transp = 0;
- obj->related = NULL;
- obj->pilot_id = remote->ID;
- obj->pilot_status = ICAL_PILOT_SYNC_NONE;
+ struct icaltimetype now = icaltimetype_from_timet (time (NULL), FALSE);
+
+ LOG ("failed, making a new one.\n");
+
+ obj = cal_component_new ();
+
+ summary.value = todo.description;
+ cal_component_set_summary (obj, &summary);
+
+ comment.value = todo.note;
+ comment_list = g_slist_append (NULL, &comment);
+ cal_component_set_comment_list (obj, comment_list);
+ g_slist_free (comment_list);
+
+ // obj->type = ICAL_TODO;
+ cal_component_set_new_vtype (obj, CAL_COMPONENT_TODO);
+ // obj->new = TRUE;
+ // obj->created = now;
+ cal_component_set_created (obj, &now);
+ // obj->last_mod = now;
+ cal_component_set_last_modified (obj, &now);
+ // obj->priority = 0;
+ // obj->transp = 0;
+ cal_component_set_transparency (obj,
+ /*CalComponentTransparency transp*/
+ CAL_COMPONENT_TRANSP_NONE);
+ // obj->related = NULL;
+ //obj->pilot_id = remote->ID;
+ //obj->pilot_status = ICAL_PILOT_SYNC_NONE;
+ cal_component_set_pilot_id (obj, remote->ID);
+ cal_component_set_pilot_status (obj, ICAL_PILOT_SYNC_NONE);
} else {
- iCalObject *new_obj;
+ CalComponent *new_obj;
- printf ("succeeded %s\n", print_ical (obj));
+ LOG ("succeeded %s\n", print_ical (obj));
new_obj = ical_from_remote_record (conduit, remote, obj);
obj = new_obj;
}
/* update record on server */
-
- update_calendar_entry_in_repository (conduit, obj, ctxt);
- cal_client_update_pilot_id (ctxt->client, obj->uid, obj->pilot_id,
- ICAL_PILOT_SYNC_NONE);
+ {
+ const char *uid;
+ unsigned long pilot_id;
+
+ cal_component_get_uid (obj, &uid);
+ cal_component_get_pilot_id (obj, &pilot_id);
+
+ update_calendar_entry_in_repository (conduit, obj, ctxt);
+ cal_client_update_pilot_id (ctxt->client, (char *) uid, pilot_id,
+ ICAL_PILOT_SYNC_NONE);
+ }
/*
* Shutdown
*/
- ical_object_unref (obj);
+ //ical_object_unref (obj);
free_ToDo(&todo);
return 0;
@@ -602,15 +666,14 @@ check_for_slow_setting (GnomePilotConduit *c, GCalConduitContext *ctxt)
entry_number = g_list_length (uids);
- // LOG (_("Calendar holds %ld todo entries"), entry_number);
/* If the local base is empty, do a slow sync */
if (entry_number == 0) {
GnomePilotConduitStandard *conduit;
- printf (" doing slow sync\n");
+ LOG (" doing slow sync\n");
conduit = GNOME_PILOT_CONDUIT_STANDARD (c);
gnome_pilot_conduit_standard_set_slow (conduit);
} else {
- printf (" doing fast sync\n");
+ LOG (" doing fast sync\n");
}
}
@@ -634,8 +697,9 @@ pre_sync (GnomePilotConduit *c,
conduit = GNOME_PILOT_CONDUIT_STANDARD_ABS(c);
- printf ("---------------------------------------------------------------------\n");
- printf ("pre_sync: GnomeCal Conduit v.%s", CONDUIT_VERSION);
+ LOG ("---------------------------------------------------------\n");
+ LOG ("pre_sync: ToDo Conduit v.%s", CONDUIT_VERSION);
+ g_message ("ToDo Conduit v.%s", CONDUIT_VERSION);
ctxt->client = NULL;
@@ -698,7 +762,8 @@ match_record (GnomePilotConduitStandardAbs *conduit,
PilotRecord *remote,
GCalConduitContext *ctxt)
{
- printf ("match_record: looking for local copy of %s\n", print_remote (remote));
+ LOG ("match_record: looking for local copy of %s\n",
+ print_remote (remote));
g_return_val_if_fail (local != NULL, -1);
g_return_val_if_fail (remote != NULL, -1);
@@ -706,9 +771,9 @@ match_record (GnomePilotConduitStandardAbs *conduit,
*local = find_record_in_repository(conduit,remote,ctxt);
if (*local == NULL)
- printf (" match_record: not found.\n");
+ LOG (" match_record: not found.\n");
else
- printf (" match_record: found, %s\n", print_local (*local));
+ LOG (" match_record: found, %s\n", print_local (*local));
if (*local==NULL) return -1;
return 0;
@@ -724,15 +789,14 @@ free_match (GnomePilotConduitStandardAbs *conduit,
GCalLocalRecord **local,
GCalConduitContext *ctxt)
{
- // LOG ("entering free_match");
- printf ("free_match: %s\n", print_local (*local));
+ LOG ("free_match: %s\n", print_local (*local));
- g_return_val_if_fail(local!=NULL,-1);
- g_return_val_if_fail(*local!=NULL,-1);
+ g_return_val_if_fail (local!=NULL, -1);
+ g_return_val_if_fail (*local!=NULL, -1);
+
+ // ical_object_unref (GCAL_LOCALRECORD(*local)->ical);
+ g_free (*local);
- ical_object_unref (GCAL_LOCALRECORD(*local)->ical);
- g_free(*local);
-
*local = NULL;
return 0;
}
@@ -745,8 +809,7 @@ archive_local (GnomePilotConduitStandardAbs *conduit,
GCalLocalRecord *local,
GCalConduitContext *ctxt)
{
- // LOG ("entering archive_local");
- printf ("archive_local: doing nothing with %s\n", print_local (local));
+ LOG ("archive_local: doing nothing with %s\n", print_local (local));
g_return_val_if_fail(local!=NULL,-1);
@@ -762,8 +825,8 @@ archive_remote (GnomePilotConduitStandardAbs *conduit,
PilotRecord *remote,
GCalConduitContext *ctxt)
{
- // LOG ("entering archive_remote");
- printf ("archive_remote: doing nothing with %s\n", print_local (local));
+ LOG ("archive_remote: doing nothing with %s\n",
+ print_local (local));
//g_return_val_if_fail(remote!=NULL,-1);
//g_return_val_if_fail(local!=NULL,-1);
@@ -779,14 +842,7 @@ store_remote (GnomePilotConduitStandardAbs *conduit,
PilotRecord *remote,
GCalConduitContext *ctxt)
{
- struct ToDo todo; /* for debugging */
- memset (&todo, 0, sizeof (struct ToDo)); /* for debugging */
- unpack_ToDo (&todo, remote->record, remote->length); /* for debugging */
-
-
- // LOG ("entering store_remote");
-
- printf ("store_remote: copying pilot record %s to desktop\n",
+ LOG ("store_remote: copying pilot record %s to desktop\n",
print_remote (remote));
g_return_val_if_fail(remote!=NULL,-1);
@@ -800,7 +856,7 @@ clear_status_archive_local (GnomePilotConduitStandardAbs *conduit,
GCalLocalRecord *local,
GCalConduitContext *ctxt)
{
- printf ("clear_status_archive_local: doing nothing\n");
+ LOG ("clear_status_archive_local: doing nothing\n");
g_return_val_if_fail(local!=NULL,-1);
@@ -834,7 +890,7 @@ iterate (GnomePilotConduitStandardAbs *conduit,
(*local) = NULL;
}
} else {
- /* printf ("continuing iteration\n"); */
+ /* LOG ("continuing iteration\n"); */
hest++;
if(g_slist_next(iterator)==NULL) {
GSList *l;
@@ -874,29 +930,34 @@ iterate_specific (GnomePilotConduitStandardAbs *conduit,
{
gchar *tmp;
switch (flag) {
- case GnomePilotRecordNothing: tmp = g_strdup("RecordNothing"); break;
- case GnomePilotRecordModified: tmp = g_strdup("RecordModified"); break;
- case GnomePilotRecordDeleted: tmp = g_strdup("RecordDeleted"); break;
- case GnomePilotRecordNew: tmp = g_strdup("RecordNew"); break;
+ case GnomePilotRecordNothing:
+ tmp = g_strdup("RecordNothing"); break;
+ case GnomePilotRecordModified:
+ tmp = g_strdup("RecordModified"); break;
+ case GnomePilotRecordDeleted:
+ tmp = g_strdup("RecordDeleted"); break;
+ case GnomePilotRecordNew:
+ tmp = g_strdup("RecordNew"); break;
default: tmp = g_strdup_printf("0x%x",flag); break;
}
- printf ("\niterate_specific: (flag = %s)... ", tmp);
+ LOG ("\niterate_specific: (flag = %s)... ", tmp);
g_free(tmp);
}
g_return_val_if_fail(local!=NULL,-1);
/* iterate until a record meets the criteria */
- while(gnome_pilot_conduit_standard_abs_iterate(conduit,(LocalRecord**)local)) {
+ while (gnome_pilot_conduit_standard_abs_iterate (conduit,
+ (LocalRecord**)local)) {
if((*local)==NULL) break;
if(archived && ((*local)->local.archived==archived)) break;
if(((*local)->local.attr == flag)) break;
}
if ((*local)) {
- printf (" found %s\n", print_local (*local));
+ LOG (" found %s\n", print_local (*local));
} else {
- printf (" no more found.\n");
+ LOG (" no more found.\n");
}
return (*local)==NULL?0:1;
@@ -906,7 +967,7 @@ static gint
purge (GnomePilotConduitStandardAbs *conduit,
GCalConduitContext *ctxt)
{
- printf ("purge: doing nothing\n");
+ LOG ("purge: doing nothing\n");
/* HEST, gem posterne her */
@@ -922,14 +983,12 @@ set_status (GnomePilotConduitStandardAbs *conduit,
{
gboolean success;
iCalPilotState new_state;
- // LOG ("entering set_status(status=%d)",status);
- printf ("set_status: %s status is now '%s'\n",
+ LOG ("set_status: %s status is now '%s'\n",
print_local (local),
gnome_pilot_status_to_string (status));
g_return_val_if_fail(local!=NULL,-1);
-
g_assert(local->ical!=NULL);
local->local.attr = status;
@@ -947,12 +1006,19 @@ set_status (GnomePilotConduitStandardAbs *conduit,
}
if (status == GnomePilotRecordDeleted) {
- success = cal_client_remove_object (ctxt->client, local->ical->uid);
+ const char *uid;
+ cal_component_get_uid (local->ical, &uid);
+ success = cal_client_remove_object (ctxt->client, uid);
} else {
+ const char *uid;
+ unsigned long pilot_id;
+
+ cal_component_get_uid (local->ical, &uid);
+ cal_component_get_pilot_id (local->ical, &pilot_id);
+
success = cal_client_update_object (ctxt->client, local->ical);
- cal_client_update_pilot_id (ctxt->client, local->ical->uid,
- local->local.ID,
- new_state);
+ cal_client_update_pilot_id (ctxt->client, (char *) uid,
+ pilot_id, new_state);
}
if (! success) {
@@ -968,9 +1034,7 @@ set_archived (GnomePilotConduitStandardAbs *conduit,
gint archived,
GCalConduitContext *ctxt)
{
- // LOG ("entering set_archived");
-
- printf ("set_archived: %s archived flag is now '%d'\n",
+ LOG ("set_archived: %s archived flag is now '%d'\n",
print_local (local), archived);
g_return_val_if_fail(local!=NULL,-1);
@@ -990,22 +1054,25 @@ set_pilot_id (GnomePilotConduitStandardAbs *conduit,
guint32 ID,
GCalConduitContext *ctxt)
{
- // LOG ("entering set_pilot_id(id=%d)",ID);
+ const char *uid;
+ unsigned long int pilot_status;
- printf ("set_pilot_id: %s pilot ID is now '%d'\n",
+ LOG ("set_pilot_id: %s pilot ID is now '%d'\n",
print_local (local), ID);
-
g_return_val_if_fail(local!=NULL,-1);
g_assert(local->ical!=NULL);
local->local.ID = ID;
- local->ical->pilot_id = ID;
+ cal_component_set_pilot_id (local->ical, ID);
+
+ cal_component_get_uid (local->ical, &uid);
+ cal_component_get_pilot_status (local->ical, &pilot_status);
cal_client_update_pilot_id (ctxt->client,
- local->ical->uid,
+ (char *) uid,
local->local.ID,
- local->ical->pilot_status);
+ pilot_status);
return 0;
}
@@ -1017,8 +1084,13 @@ transmit (GnomePilotConduitStandardAbs *conduit,
GCalConduitContext *ctxt)
{
PilotRecord *p;
+ /* priority; FIX ME */
+ struct icaltimetype *completed;
+ CalComponentText summary;
+ GSList *comment_list = NULL;
+ CalComponentText *comment;
- printf ("transmit: encoding local %s\n", print_local (local));
+ LOG ("transmit: encoding local %s\n", print_local (local));
g_return_val_if_fail(local!=NULL,-1);
g_return_val_if_fail(remote!=NULL,-1);
@@ -1033,23 +1105,46 @@ transmit (GnomePilotConduitStandardAbs *conduit,
local->todo = g_new0(struct ToDo,1);
- local->todo->indefinite = (local->ical->dtend == 0);
- local->todo->due = *localtime (&local->ical->dtend);
- local->todo->priority = local->ical->priority;
+ {
+ CalComponentDateTime dtend;
+ time_t dtend_time_t;
+
+ cal_component_get_dtend (local->ical, &dtend);
+ dtend_time_t = time_from_icaltimetype (*dtend.value);
+
+ local->todo->due = *localtime (&dtend_time_t);
+ local->todo->indefinite = (dtend.value->year == 0);
+ }
- if (local->ical->completed > 0)
+ //local->todo->priority = local->ical->priority;
+ local->todo->priority = 1; /* FIX ME */
+
+ cal_component_get_completed (local->ical, &completed);
+ if (completed->year > 0)
local->todo->complete = 1; /* FIX ME */
/* STOP: don't replace these with g_strdup, since free_ToDo
uses free to deallocte */
+
+ cal_component_get_summary (local->ical, &summary);
local->todo->description =
- local->ical->summary==NULL?NULL:strdup(local->ical->summary);
- local->todo->note =
- local->ical->comment==NULL?NULL:strdup(local->ical->comment);
- //local->ical->desc==NULL?NULL:strdup(local->ical->desc);
+ //local->ical->summary == NULL ? NULL : strdup (summary.value);
+ strdup ((char *) summary.value);
+
+
+ cal_component_get_comment_list (local->ical, &comment_list);
+ if (comment_list) {
+ comment = (CalComponentText *) comment_list->data;
+ if (comment && comment->value)
+ local->todo->note = strdup (comment->value);
+ else
+ local->todo->note = NULL;
+ } else {
+ local->todo->note = NULL;
+ }
/*
- printf ("transmitting todo to pilot [%s] complete=%d/%ld\n",
+ LOG ("transmitting todo to pilot [%s] complete=%d/%ld\n",
local->ical->summary==NULL?"NULL":local->ical->summary,
local->todo->complete, local->ical->completed);
*/
@@ -1069,19 +1164,19 @@ free_transmit (GnomePilotConduitStandardAbs *conduit,
PilotRecord **remote,
GCalConduitContext *ctxt)
{
- // LOG ("entering free_transmit");
- printf ("free_transmit: freeing %s\n",
+ LOG ("free_transmit: freeing %s\n",
print_local (local));
g_return_val_if_fail(local!=NULL,-1);
g_return_val_if_fail(remote!=NULL,-1);
- // free_ToDo(local->todo);
+ /* free_ToDo(local->todo); */ /* FIX ME is this needed? */
g_free((*remote)->record);
*remote = NULL;
return 0;
}
+
static gint
compare (GnomePilotConduitStandardAbs *conduit,
GCalLocalRecord *local,
@@ -1093,10 +1188,9 @@ compare (GnomePilotConduitStandardAbs *conduit,
int err;
int retval;
- printf ("compare: local=%s remote=%s...\n",
+ LOG ("compare: local=%s remote=%s...\n",
print_local (local), print_remote (remote));
-
g_return_val_if_fail (local!=NULL,-1);
g_return_val_if_fail (remote!=NULL,-1);
@@ -1105,22 +1199,23 @@ compare (GnomePilotConduitStandardAbs *conduit,
retval = 0;
if (remote->length == remoteOfLocal->length) {
- if (memcmp(remoteOfLocal->record,remote->record,remote->length)!=0) {
- printf (" compare failed on contents\n");
+ if (memcmp (remoteOfLocal->record,
+ remote->record, remote->length)!=0) {
+ LOG (" compare failed on contents\n");
retval = 1;
}
} else {
- printf(" compare failed on length\n");
+ LOG(" compare failed on length\n");
retval = 1;
}
if (retval == 0) {
- printf (" match.\n");
+ LOG (" match.\n");
} else {
/* debug spew */
- printf (" local:%s\n", print_remote (remoteOfLocal));
- printf (" remote:%s\n", print_remote (remote));
+ LOG (" local:%s\n", print_remote (remoteOfLocal));
+ LOG (" remote:%s\n", print_remote (remote));
}
free_transmit(conduit,local,&remoteOfLocal,ctxt);
@@ -1134,7 +1229,7 @@ compare_backup (GnomePilotConduitStandardAbs *conduit,
PilotRecord *remote,
GCalConduitContext *ctxt)
{
- printf ("compare_backup: doing nothing\n");
+ LOG ("compare_backup: doing nothing\n");
g_return_val_if_fail(local!=NULL,-1);
g_return_val_if_fail(remote!=NULL,-1);
@@ -1153,7 +1248,7 @@ delete_all (GnomePilotConduitStandardAbs *conduit,
events = get_calendar_objects(conduit,&error,ctxt);
- printf ("delete_all: deleting all objects from desktop\n");
+ LOG ("delete_all: deleting all objects from desktop\n");
if (error == FALSE) return -1;
for (it=events; it; it = g_slist_next (it)) {
@@ -1187,7 +1282,7 @@ conduit_get_gpilot_conduit (guint32 pilotId)
GCalConduitCfg *cfg;
GCalConduitContext *ctxt;
- printf ("in todo's conduit_get_gpilot_conduit\n");
+ LOG ("in todo's conduit_get_gpilot_conduit\n");
/* we need to find wombat with oaf, so make sure oaf
is initialized here. once the desktop is converted