aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2000-07-26 08:05:34 +0800
committerChris Toshok <toshok@src.gnome.org>2000-07-26 08:05:34 +0800
commit270ca5fae4e9775d3c19195132566a6273280794 (patch)
tree9af6d54dc14d479a6f2084ec0dc7645ac1aeadd7
parent43c1a59230a924858a6f9c04d0f679f3fa29676a (diff)
downloadgsoc2013-evolution-270ca5fae4e9775d3c19195132566a6273280794.tar
gsoc2013-evolution-270ca5fae4e9775d3c19195132566a6273280794.tar.gz
gsoc2013-evolution-270ca5fae4e9775d3c19195132566a6273280794.tar.bz2
gsoc2013-evolution-270ca5fae4e9775d3c19195132566a6273280794.tar.lz
gsoc2013-evolution-270ca5fae4e9775d3c19195132566a6273280794.tar.xz
gsoc2013-evolution-270ca5fae4e9775d3c19195132566a6273280794.tar.zst
gsoc2013-evolution-270ca5fae4e9775d3c19195132566a6273280794.zip
add enum for e-card pilot status.
2000-07-25 Chris Toshok <toshok@helixcode.com> * backend/ebook/e-card-types.h: add enum for e-card pilot status. * conduit/address-conduit.c: #ifdef out all the archiving code with SUPPORT_ARCHIVING. (purge): implement correctly - deleting ecards whose pilot status is DELETED. (set_status): implement. (set_pilot_id): add gtk_main call here to change commit_card into a synchronous (delete_all): implement correctly - don't delete the records, just set their status to DELETED. (local_record_from_ecard): get the current status from the ecard. * backend/ebook/e-card.c (e_card_get_vcard): add vcard support for pilot status. (parse_pilot_status): new function. (e_card_class_init): add pilot status object arg. (e_card_set_arg): add pilot status support. (e_card_get_arg): same. (e_card_init): initialize pilot_status to 0. svn path=/trunk/; revision=4340
-rw-r--r--addressbook/ChangeLog18
-rw-r--r--addressbook/backend/ebook/e-card-types.h8
-rw-r--r--addressbook/backend/ebook/e-card.c30
-rw-r--r--addressbook/backend/ebook/e-card.h2
-rw-r--r--addressbook/conduit/address-conduit.c192
5 files changed, 161 insertions, 89 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index e276a4a925..d831f311a8 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,23 @@
2000-07-25 Chris Toshok <toshok@helixcode.com>
+ * backend/ebook/e-card-types.h: add enum for e-card pilot status.
+
+ * conduit/address-conduit.c: #ifdef out all the archiving code with SUPPORT_ARCHIVING.
+ (purge): implement correctly - deleting ecards whose pilot status is DELETED.
+ (set_status): implement.
+ (set_pilot_id): add gtk_main call here to change commit_card into a synchronous
+ (delete_all): implement correctly - don't delete the records, just set their status to DELETED.
+ (local_record_from_ecard): get the current status from the ecard.
+
+ * backend/ebook/e-card.c (e_card_get_vcard): add vcard support for pilot status.
+ (parse_pilot_status): new function.
+ (e_card_class_init): add pilot status object arg.
+ (e_card_set_arg): add pilot status support.
+ (e_card_get_arg): same.
+ (e_card_init): initialize pilot_status to 0.
+
+2000-07-25 Chris Toshok <toshok@helixcode.com>
+
* conduit/address-conduit.c: add comment headers to signals that
didn't have any.
diff --git a/addressbook/backend/ebook/e-card-types.h b/addressbook/backend/ebook/e-card-types.h
index 57aed690aa..a2563d4bf6 100644
--- a/addressbook/backend/ebook/e-card-types.h
+++ b/addressbook/backend/ebook/e-card-types.h
@@ -86,4 +86,12 @@ typedef struct {
char *value;
} ECardArbitrary;
+/* PILOT SYNC STATUS */
+
+enum {
+ E_CARD_PILOT_STATUS_NONE,
+ E_CARD_PILOT_STATUS_MOD,
+ E_CARD_PILOT_STATUS_DEL
+};
+
#endif /* __E_CARD_TYPES_H__ */
diff --git a/addressbook/backend/ebook/e-card.c b/addressbook/backend/ebook/e-card.c
index 26f5df0f67..8008e052ba 100644
--- a/addressbook/backend/ebook/e-card.c
+++ b/addressbook/backend/ebook/e-card.c
@@ -26,6 +26,7 @@
#define has(obj,prop) (vo = isAPropertyOf ((obj), (prop)))
#define XEV_PILOT_ID "X-EVOLUTION-PILOTID"
+#define XEV_PILOT_STATUS "X-EVOLUTION-PILOTSTATUS"
#define XEV_ARBITRARY "X-EVOLUTION-ARBITRARY"
/* Object argument IDs */
@@ -56,6 +57,7 @@ enum {
ARG_CATEGORIES,
ARG_CATEGORY_LIST,
ARG_PILOTID,
+ ARG_PILOTSTATUS,
ARG_ARBITRARY,
ARG_ID,
};
@@ -99,6 +101,7 @@ static void parse_fburl(ECard *card, VObject *object);
static void parse_note(ECard *card, VObject *object);
static void parse_categories(ECard *card, VObject *object);
static void parse_pilot_id(ECard *card, VObject *object);
+static void parse_pilot_status(ECard *card, VObject *object);
static void parse_arbitrary(ECard *card, VObject *object);
static void parse_id(ECard *card, VObject *object);
@@ -137,6 +140,7 @@ struct {
{ VCNoteProp, parse_note },
{ "CATEGORIES", parse_categories },
{ XEV_PILOT_ID, parse_pilot_id },
+ { XEV_PILOT_STATUS, parse_pilot_status },
{ XEV_ARBITRARY, parse_arbitrary },
{ VCUniqueStringProp, parse_id }
};
@@ -434,6 +438,13 @@ char
g_free (pilotid_str);
}
+ if (card->pilot_status) {
+ gchar *pilotstatus_str;
+ pilotstatus_str = g_strdup_printf ("%d", card->pilot_status);
+ addPropValue (vobj, XEV_PILOT_STATUS, pilotstatus_str);
+ g_free (pilotstatus_str);
+ }
+
if (card->arbitrary) {
EIterator *iterator;
for (iterator = e_list_get_iterator(card->arbitrary); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
@@ -834,6 +845,16 @@ parse_pilot_id(ECard *card, VObject *vobj)
}
}
+static void
+parse_pilot_status(ECard *card, VObject *vobj)
+{
+ if ( vObjectValueType (vobj) ) {
+ char *str = fakeCString (vObjectUStringZValue (vobj));
+ card->pilot_status = atoi(str);
+ free(str);
+ }
+}
+
typedef union ValueItem {
const char *strs;
const wchar_t *ustrs;
@@ -989,6 +1010,8 @@ e_card_class_init (ECardClass *klass)
GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_CATEGORY_LIST);
gtk_object_add_arg_type ("ECard::pilot_id",
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_PILOTID);
+ gtk_object_add_arg_type ("ECard::pilot_status",
+ GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_PILOTSTATUS);
gtk_object_add_arg_type ("ECard::arbitrary",
GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_ARBITRARY);
gtk_object_add_arg_type ("ECard::id",
@@ -1418,6 +1441,9 @@ e_card_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_PILOTID:
card->pilot_id = GTK_VALUE_INT(*arg);
break;
+ case ARG_PILOTSTATUS:
+ card->pilot_status = GTK_VALUE_INT(*arg);
+ break;
case ARG_ARBITRARY:
if (card->arbitrary)
gtk_object_unref(GTK_OBJECT(card->arbitrary));
@@ -1555,6 +1581,9 @@ e_card_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
case ARG_PILOTID:
GTK_VALUE_INT(*arg) = card->pilot_id;
break;
+ case ARG_PILOTSTATUS:
+ GTK_VALUE_INT(*arg) = card->pilot_status;
+ break;
case ARG_ARBITRARY:
if (!card->arbitrary)
card->arbitrary = e_list_new((EListCopyFunc) e_card_arbitrary_copy,
@@ -1605,6 +1634,7 @@ e_card_init (ECard *card)
card->note = NULL;
card->categories = NULL;
card->pilot_id = 0;
+ card->pilot_status = 0;
card->arbitrary = NULL;
#if 0
diff --git a/addressbook/backend/ebook/e-card.h b/addressbook/backend/ebook/e-card.h
index 89ee88388c..5b122ad550 100644
--- a/addressbook/backend/ebook/e-card.h
+++ b/addressbook/backend/ebook/e-card.h
@@ -70,7 +70,7 @@ struct _ECard {
EList *arbitrary; /* Arbitrary fields. */
guint32 pilot_id; /* id of the corresponding pilot */
-
+ guint32 pilot_status; /* status information */
#if 0
ECardPhoto *logo; /* This person's org's logo. */
diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c
index f6a73621fc..14b25da8de 100644
--- a/addressbook/conduit/address-conduit.c
+++ b/addressbook/conduit/address-conduit.c
@@ -31,8 +31,8 @@ void local_record_from_ecard (AddressbookLocalRecord *local, ECard *ecard);
#endif
#define G_LOG_DOMAIN "addressconduit"
-#define DEBUG_CALCONDUIT 1
-/* #undef DEBUG_CALCONDUIT */
+/* #define SUPPORT_ARCHIVING 1 */
+#define DEBUG_ADDRESSBOOKCONDUIT 1
#ifdef DEBUG_ADDRESSBOOKCONDUIT
#define show_exception(e) g_warning ("Exception: %s\n", CORBA_exception_id (e))
@@ -178,29 +178,27 @@ void
local_record_from_ecard(AddressbookLocalRecord *local,
ECard *ecard)
{
+ guint32 current_status;
+
g_return_if_fail(local!=NULL);
g_return_if_fail(ecard!=NULL);
local->ecard = ecard;
local->local.ID = local->ecard->pilot_id;
-#if 0
- LOG ("local->Id = %ld [%s], status = %d",
- local->local.ID,obj->summary,local->ical->pilot_status);
- switch(local->ical->pilot_status) {
- case ICAL_PILOT_SYNC_NONE:
+ gtk_object_get (GTK_OBJECT(ecard), "pilot_status", &current_status);
+
+ switch(current_status) {
+ case E_CARD_PILOT_STATUS_NONE:
local->local.attr = GnomePilotRecordNothing;
break;
- case ICAL_PILOT_SYNC_MOD:
+ case E_CARD_PILOT_STATUS_MOD:
local->local.attr = GnomePilotRecordModified;
break;
- case ICAL_PILOT_SYNC_DEL:
+ case E_CARD_PILOT_STATUS_DEL:
local->local.attr = GnomePilotRecordDeleted;
break;
}
-#endif
-
- local->local.attr = GnomePilotRecordNothing;
/* Records without a pilot_id are new */
if(local->local.ID == 0)
@@ -501,6 +499,7 @@ free_match (GnomePilotConduitStandardAbs *conduit,
return 0;
}
+#if SUPPORT_ARCHIVING
/*
Move to archive and set status to Nothing
*/
@@ -538,6 +537,45 @@ archive_remote (GnomePilotConduitStandardAbs *conduit,
}
/*
+** Called when copying records to the pilot.
+**
+** XXX more here.
+*/
+static gint
+clear_status_archive_local (GnomePilotConduitStandardAbs *conduit,
+ AddressbookLocalRecord *local,
+ AddressbookConduitContext *ctxt)
+{
+ LOG ("entering clear_status_archive_local");
+
+ g_return_val_if_fail(local!=NULL,-1);
+
+ return -1;
+}
+
+/*
+** presumably used to set the archived flag on a local record. not
+** actually used in the gnome-pilot source.
+*/
+static gint
+set_archived (GnomePilotConduitStandardAbs *conduit,
+ AddressbookLocalRecord *local,
+ gint archived,
+ AddressbookConduitContext *ctxt)
+{
+ LOG ("entering set_archived");
+
+ g_return_val_if_fail(local!=NULL,-1);
+ g_assert(local->ecard!=NULL);
+
+ local->local.archived = archived;
+ update_address_entry_in_repository (conduit, local->ical, ctxt);
+ return 0;
+}
+
+#endif
+
+/*
** used when copying information from the pilot to the desktop. if
** the archived flags and deleted flags are not set to true in the
** PilotRecord, this method is called.
@@ -558,23 +596,6 @@ store_remote (GnomePilotConduitStandardAbs *conduit,
}
/*
-** Called when copying records to the pilot.
-**
-** XXX more here.
-*/
-static gint
-clear_status_archive_local (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- AddressbookConduitContext *ctxt)
-{
- LOG ("entering clear_status_archive_local");
-
- g_return_val_if_fail(local!=NULL,-1);
-
- return -1;
-}
-
-/*
** Used when looping over records on the local side of things.
** function should maintain state such that *local moves along the
** list of records.
@@ -638,7 +659,7 @@ iterate_specific (GnomePilotConduitStandardAbs *conduit,
gint archived,
AddressbookConduitContext *ctxt)
{
-#ifdef DEBUG_CALCONDUIT
+#ifdef DEBUG_ADDRESSBOOKCONDUIT
{
gchar *tmp;
switch (flag) {
@@ -656,7 +677,9 @@ 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;
+#if SUPPORT_ARCHIVING
if(archived && ((*local)->local.archived==archived)) break;
+#endif
if(((*local)->local.attr == flag)) break;
}
@@ -673,11 +696,35 @@ static gint
purge (GnomePilotConduitStandardAbs *conduit,
AddressbookConduitContext *ctxt)
{
- LOG ("entering purge");
+ GList *it;
+ gint retval = 0;
- /* HEST, gem posterne her */
+ for (it=ctxt->cards; it;) {
+ guint32 current_status;
- return -1;
+ gtk_object_get (GTK_OBJECT (it->data), "pilot_status", &current_status);
+
+ if (current_status == E_CARD_PILOT_STATUS_DEL) {
+ EBookStatus remove_status;
+
+ e_book_remove_card (ctxt->ebook, it->data, status_cb, &remove_status);
+ gtk_main(); /* enter sub loop */
+
+ if (remove_status == E_BOOK_STATUS_SUCCESS) {
+ GList *l = it;
+ it = g_list_next (it);
+ gtk_object_unref (GTK_OBJECT (it->data));
+ ctxt->cards = g_list_remove_link(ctxt->cards, l);
+ g_list_free_1 (l);
+ }
+ else {
+ retval = -1;
+ it = g_list_next (it);
+ }
+ }
+ }
+
+ return retval;
}
@@ -693,64 +740,38 @@ set_status (GnomePilotConduitStandardAbs *conduit,
gint status,
AddressbookConduitContext *ctxt)
{
-#if 0
- gboolean success;
+ EBookStatus commit_status;
+ guint32 ecard_status;
+
LOG ("entering set_status(status=%d)",status);
g_return_val_if_fail(local!=NULL,-1);
-
- g_assert(local->ical!=NULL);
+ g_assert(local->ecard!=NULL);
local->local.attr = status;
switch(status) {
- case GnomePilotRecordPending:
- case GnomePilotRecordNothing:
- local->ical->pilot_status = ICAL_PILOT_SYNC_NONE;
- break;
case GnomePilotRecordDeleted:
+ ecard_status = E_CARD_PILOT_STATUS_DEL;
break;
case GnomePilotRecordNew:
case GnomePilotRecordModified:
- local->ical->pilot_status = ICAL_PILOT_SYNC_MOD;
- break;
+ ecard_status = E_CARD_PILOT_STATUS_MOD;
+ break;
+ default:
+ ecard_status = E_CARD_PILOT_STATUS_NONE;
+ break;
}
- if (status == GnomePilotRecordDeleted) {
- success = cal_client_remove_object (ctxt->client, local->ical->uid);
- } else {
- success = cal_client_update_object (ctxt->client, local->ical);
- cal_client_update_pilot_id (ctxt->client, local->ical->uid,
- local->local.ID,
- local->ical->pilot_status);
- }
+ gtk_object_set (GTK_OBJECT (local->ecard), "pilot_status", ecard_status);
- if (! success) {
- WARN (_("Error while communicating with address server"));
- }
-#endif
-
- return 0;
-}
+ e_book_commit_card (ctxt->ebook, local->ecard, status_cb, &commit_status);
-/*
-** presumably used to set the archived flag on a local record. not
-** actually used in the gnome-pilot source.
-*/
-static gint
-set_archived (GnomePilotConduitStandardAbs *conduit,
- AddressbookLocalRecord *local,
- gint archived,
- AddressbookConduitContext *ctxt)
-{
-#if 0
- LOG ("entering set_archived");
+ gtk_main (); /* enter sub loop */
- g_return_val_if_fail(local!=NULL,-1);
- g_assert(local->ecard!=NULL);
+ if (commit_status != E_BOOK_STATUS_SUCCESS) {
+ WARN (_("Error while communicating with address server"));
+ }
- local->local.archived = archived;
- update_address_entry_in_repository (conduit, local->ical, ctxt);
-#endif
return 0;
}
@@ -781,6 +802,8 @@ set_pilot_id (GnomePilotConduitStandardAbs *conduit,
gtk_object_set (GTK_OBJECT(local->ecard), "pilot_id", local->local.ID);
e_book_commit_card (ctxt->ebook, local->ecard, status_cb, &commit_status);
+ gtk_main (); /* enter sub loop */
+
if (commit_status == E_BOOK_STATUS_SUCCESS) {
return 0;
}
@@ -966,19 +989,10 @@ delete_all (GnomePilotConduitStandardAbs *conduit,
GList *it;
for (it=ctxt->cards; it; it = g_list_next (it)) {
- EBookStatus remove_status;
- e_book_remove_card (ctxt->ebook, it->data, status_cb, &remove_status);
- gtk_main (); /* enter sub main loop */
-
- if (E_BOOK_STATUS_SUCCESS != remove_status)
- WARN ("Failed to remove ecard");
-
- gtk_object_unref (it->data);
+ gtk_object_set (GTK_OBJECT (it->data), "pilot_status", E_CARD_PILOT_STATUS_DEL);
}
- g_list_free (ctxt->cards);
- ctxt->cards = NULL;
- return -1;
+ return 0;
}
@@ -1005,15 +1019,17 @@ conduit_get_gpilot_conduit (guint32 pilotId)
gtk_signal_connect (retval, "match_record", (GtkSignalFunc) match_record, ctxt);
gtk_signal_connect (retval, "free_match", (GtkSignalFunc) free_match, ctxt);
+#ifdef SUPPORT_ARCHIVING
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, "set_archived", (GtkSignalFunc) set_archived, ctxt);
gtk_signal_connect (retval, "clear_status_archive_local", (GtkSignalFunc) clear_status_archive_local, ctxt);
+#endif
+ gtk_signal_connect (retval, "store_remote", (GtkSignalFunc) store_remote, 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);