aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-10-12 11:47:18 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-10-12 11:47:18 +0800
commit3253815c84e1746ba0217ced7e03a5f15106f14c (patch)
tree6480b0fde9bccfce74e1f758fb166f6a3754ba41
parent8afca4e07100eec5991e6b281c5293fd86a2b2c2 (diff)
downloadgsoc2013-evolution-3253815c84e1746ba0217ced7e03a5f15106f14c.tar.gz
gsoc2013-evolution-3253815c84e1746ba0217ced7e03a5f15106f14c.tar.zst
gsoc2013-evolution-3253815c84e1746ba0217ced7e03a5f15106f14c.zip
Added. Heuristic for whether or not we want to revert to an earlier
2001-10-11 Jon Trowbridge <trow@ximian.com> * backend/ebook/e-destination.c (e_destination_reverting_is_a_good_idea): Added. Heuristic for whether or not we want to revert to an earlier cardified state. (e_destination_cardify): Don't be quite as aggressive about reverting to previous cardified states. (Bug #11890) svn path=/trunk/; revision=13610
-rw-r--r--addressbook/ChangeLog8
-rw-r--r--addressbook/backend/ebook/e-destination.c44
2 files changed, 46 insertions, 6 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 2ffea5b70e..52e264864d 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,11 @@
+2001-10-11 Jon Trowbridge <trow@ximian.com>
+
+ * backend/ebook/e-destination.c
+ (e_destination_reverting_is_a_good_idea): Added. Heuristic for
+ whether or not we want to revert to an earlier cardified state.
+ (e_destination_cardify): Don't be quite as aggressive about
+ reverting to previous cardified states. (Bug #11890)
+
2001-10-11 Christopher James Lahey <clahey@ximian.com>
* backend/ebook/e-card-simple.c (e_card_simple_destroy,
diff --git a/addressbook/backend/ebook/e-destination.c b/addressbook/backend/ebook/e-destination.c
index ecbda7b497..c3bf4de5ab 100644
--- a/addressbook/backend/ebook/e-destination.c
+++ b/addressbook/backend/ebook/e-destination.c
@@ -61,6 +61,7 @@ struct _EDestinationPrivate {
ECard *old_card;
gint old_card_email_num;
+ gchar *old_textrep;
gchar *name;
gchar *email;
@@ -101,6 +102,8 @@ e_destination_destroy (GtkObject *obj)
if (dest->priv->cardify_book)
gtk_object_unref (GTK_OBJECT (dest->priv->cardify_book));
+ g_free (dest->priv->old_textrep);
+
g_free (dest->priv);
if (parent_class->destroy)
@@ -221,6 +224,7 @@ e_destination_copy (const EDestination *dest)
new_dest->priv->addr = g_strdup (dest->priv->addr);
new_dest->priv->card_email_num = dest->priv->card_email_num;
new_dest->priv->old_card_email_num = dest->priv->old_card_email_num;
+ new_dest->priv->old_textrep = g_strdup (dest->priv->old_textrep);
new_dest->priv->card = dest->priv->card;
if (new_dest->priv->card)
@@ -244,11 +248,6 @@ e_destination_copy (const EDestination *dest)
static void
e_destination_clear_card (EDestination *dest)
{
- g_free (dest->priv->book_uri);
- dest->priv->book_uri = NULL;
- g_free (dest->priv->card_uid);
- dest->priv->card_uid = NULL;
-
if (dest->priv->card) {
if (dest->priv->old_card)
@@ -256,8 +255,16 @@ e_destination_clear_card (EDestination *dest)
dest->priv->old_card = dest->priv->card;
dest->priv->old_card_email_num = dest->priv->card_email_num;
+
+ g_free (dest->priv->old_textrep);
+ dest->priv->old_textrep = g_strdup (e_destination_get_textrep (dest));
}
+ g_free (dest->priv->book_uri);
+ dest->priv->book_uri = NULL;
+ g_free (dest->priv->card_uid);
+ dest->priv->card_uid = NULL;
+
dest->priv->card = NULL;
dest->priv->card_email_num = -1;
@@ -1003,6 +1010,27 @@ use_local_book_cb (EBook *book, gpointer closure)
}
+static gboolean
+e_destination_reverting_is_a_good_idea (EDestination *dest)
+{
+ const gchar *textrep;
+ gint len, old_len;
+
+ g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE);
+ if (dest->priv->old_textrep == NULL)
+ return FALSE;
+
+ textrep = e_destination_get_textrep (dest);
+
+ len = g_utf8_strlen (textrep, -1);
+ old_len = g_utf8_strlen (dest->priv->old_textrep, -1);
+
+ if (len < old_len/2)
+ return FALSE;
+
+ return TRUE;
+}
+
void
e_destination_cardify (EDestination *dest, EBook *book)
{
@@ -1024,7 +1052,9 @@ e_destination_cardify (EDestination *dest, EBook *book)
e_destination_cancel_cardify (dest);
/* In some cases, we can revert to the previous card. */
- if (!e_destination_is_valid (dest) && e_destination_revert (dest)) {
+ if (!e_destination_is_valid (dest)
+ && e_destination_reverting_is_a_good_idea (dest)
+ && e_destination_revert (dest)) {
return;
}
@@ -1118,6 +1148,8 @@ e_destination_revert (EDestination *dest)
card_email_num = dest->priv->old_card_email_num;
dest->priv->old_card = NULL;
+ g_free (dest->priv->old_textrep);
+ dest->priv->old_textrep = NULL;
e_destination_freeze (dest);
e_destination_clear (dest);