From 8650735ac6fc68c6465554fd2b0e3edc26d87b14 Mon Sep 17 00:00:00 2001
From: JP Rosevear <jpr@ximian.com>
Date: Mon, 29 Oct 2001 16:39:09 +0000
Subject: a card also needs to have its phone nums in priority order to be

2001-10-29  JP Rosevear  <jpr@ximian.com>

	* conduit/address-conduit.c (is_syncable): a card also needs to
	have its phone nums in priority order to be "syncable"

svn path=/trunk/; revision=14344
---
 addressbook/conduit/address-conduit.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

(limited to 'addressbook/conduit')

diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c
index 00d52eb6d5..1cff3c234f 100644
--- a/addressbook/conduit/address-conduit.c
+++ b/addressbook/conduit/address-conduit.c
@@ -502,8 +502,32 @@ is_syncable (EAddrConduitContext *ctxt, EAddrLocalRecord *local)
 	ECardSimpleField next_mail, next_home, next_work, next_fax;
 	ECardSimpleField next_other, next_main, next_pager, next_mobile;
 	gboolean syncable = TRUE;
-	int i;
+	int i, l = 0, lastphone = entryPhone5;
+
+	/* See if the fields are in priority order */
+	for ( ; lastphone >= entryPhone1; lastphone--) {
+		const char *phone_str = local->addr->entry[lastphone];
+
+		if (phone_str && *phone_str)
+			break;
+	}
+
+	/* if they are all blank */
+	if (lastphone < entryPhone1)
+		return TRUE;
 
+	/* See if the fields are in priority order */
+	for (i = entryPhone1; i <= lastphone && priority_label[l] != NULL; i++) {
+		char *phonelabel = ctxt->ai.phoneLabels[local->addr->phoneLabel[i - entryPhone1]];
+
+		for ( ; priority_label[l] != NULL; l++)
+			if (!strcmp (phonelabel, priority_label[l]))
+				break;
+	}
+	
+	if (priority_label[l] == NULL)
+		return FALSE;
+			 
 	/* See if there are fields we can't sync */
 	get_next_init (&next_mail, &next_home, &next_work, &next_fax,
 		       &next_other, &next_main, &next_pager, &next_mobile);
-- 
cgit