aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2001-07-09 11:29:31 +0800
committerJon Trowbridge <trow@src.gnome.org>2001-07-09 11:29:31 +0800
commit864046c7e4c1af311fd1b26bf6120f543e64c9a0 (patch)
treeeb4ab5bf71f485d6bbea44bf402eefa49640a31d /addressbook
parent7cc3d5f443de8cb8f67006e8d28d85aca6ca0507 (diff)
downloadgsoc2013-evolution-864046c7e4c1af311fd1b26bf6120f543e64c9a0.tar
gsoc2013-evolution-864046c7e4c1af311fd1b26bf6120f543e64c9a0.tar.gz
gsoc2013-evolution-864046c7e4c1af311fd1b26bf6120f543e64c9a0.tar.bz2
gsoc2013-evolution-864046c7e4c1af311fd1b26bf6120f543e64c9a0.tar.lz
gsoc2013-evolution-864046c7e4c1af311fd1b26bf6120f543e64c9a0.tar.xz
gsoc2013-evolution-864046c7e4c1af311fd1b26bf6120f543e64c9a0.tar.zst
gsoc2013-evolution-864046c7e4c1af311fd1b26bf6120f543e64c9a0.zip
Check that str isn't the empty string before doing an insert.
2001-07-08 Jon Trowbridge <trow@ximian.com> * gui/component/select-names/e-select-names-text-model.c (e_select_names_text_model_insert_length): Check that str isn't the empty string before doing an insert. * backend/ebook/e-destination.c (e_destination_set_string): We were being too smart for our own good here, and causing problems for the completion code... (bug #4253, bug #4255, bug #4280) (e_destination_set_name): Clear any cached address. (e_destination_set_email): Clear any cached address. (e_destination_get_address): Handle the cases where the name contains some e-mail information. svn path=/trunk/; revision=10901
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog14
-rw-r--r--addressbook/backend/ebook/e-destination.c52
-rw-r--r--addressbook/gui/component/select-names/e-select-names-text-model.c6
3 files changed, 58 insertions, 14 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 352dab776d..026d3b6fb8 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,17 @@
+2001-07-08 Jon Trowbridge <trow@ximian.com>
+
+ * gui/component/select-names/e-select-names-text-model.c
+ (e_select_names_text_model_insert_length): Check that str isn't
+ the empty string before doing an insert.
+
+ * backend/ebook/e-destination.c (e_destination_set_string): We were
+ being too smart for our own good here, and causing problems for
+ the completion code... (bug #4253, bug #4255, bug #4280)
+ (e_destination_set_name): Clear any cached address.
+ (e_destination_set_email): Clear any cached address.
+ (e_destination_get_address): Handle the cases where the name
+ contains some e-mail information.
+
2001-07-09 Kjartan Maraas <kmaraas@gnome.org>
* gui/contact-list-editor/e-contact-list-editor.c: Marked a
diff --git a/addressbook/backend/ebook/e-destination.c b/addressbook/backend/ebook/e-destination.c
index 421b13cf07..c05b15b380 100644
--- a/addressbook/backend/ebook/e-destination.c
+++ b/addressbook/backend/ebook/e-destination.c
@@ -243,6 +243,11 @@ e_destination_set_name (EDestination *dest, const gchar *name)
g_free (dest->priv->name);
dest->priv->name = g_strdup (name);
+
+ if (dest->priv->addr) {
+ g_free (dest->priv->addr);
+ dest->priv->addr = NULL;
+ }
}
void
@@ -253,6 +258,11 @@ e_destination_set_email (EDestination *dest, const gchar *email)
g_free (dest->priv->email);
dest->priv->email = g_strdup (email);
+
+ if (dest->priv->addr) {
+ g_free (dest->priv->addr);
+ dest->priv->addr = NULL;
+ }
}
@@ -268,6 +278,8 @@ e_destination_set_string (EDestination *dest, const gchar *str)
g_return_if_fail (dest && E_IS_DESTINATION (dest));
g_return_if_fail (str != NULL);
+ /* This turned out to be an overly-clever approach... */
+#if 0
/* Look for something of the form Jane Smith <jane@assbarn.com> */
if ( (lt = strrchr (str, '<')) && (gt = strrchr (str, '>')) && lt+1 < gt) {
name = g_strndup (str, lt-str);
@@ -288,20 +300,21 @@ e_destination_set_string (EDestination *dest, const gchar *str)
name = g_strdup (str);
goto finished;
}
+#endif
- /* Default: Just treat it as an e-mail address. */
- email = g_strdup (str);
+ /* Default: Just treat it as a name address. */
+ name = g_strdup (str);
finished:
if (name) {
- g_strstrip (name);
+ g_message ("name: [%s]", name);
if (*name)
e_destination_set_name (dest, name);
g_free (name);
}
if (email) {
- g_strstrip (email);
+ g_message ("email: [%s]", email);
if (*email)
e_destination_set_email (dest, email);
g_free (email);
@@ -459,7 +472,14 @@ e_destination_get_email (const EDestination *dest)
}
}
- }
+ } else if (priv->name) {
+ gchar *lt = strchr (priv->name, '<');
+ gchar *gt = strchr (priv->name, '>');
+
+ if (lt && gt && lt+1 < gt) {
+ priv->email = g_strndup (lt+1, gt-lt-1);
+ }
+ }
}
return priv->email;
@@ -499,27 +519,37 @@ e_destination_get_address (const EDestination *dest)
} else {
+ const gchar *name = e_destination_get_name (dest);
const gchar *email = e_destination_get_email (dest);
if (email) { /* If this isn't set, we return NULL */
-
- const gchar *name = e_destination_get_name (dest);
-
+
if (name) {
- gboolean needs_quotes = (strchr (name, '.') != NULL);
+ gchar *lt = strchr (name, '<');
+ gchar *namecpy = lt ? g_strndup (name, lt-name) : g_strdup (name);
+ gboolean needs_quotes = (strchr (namecpy, '.') != NULL);
+
+ g_strstrip (namecpy);
priv->addr = g_strdup_printf ("%s%s%s <%s>",
needs_quotes ? "\"" : "",
- name,
+ namecpy,
needs_quotes ? "\"" : "",
email);
+ g_free (namecpy);
} else {
priv->addr = g_strdup (email);
}
+
+ } else {
+
+ /* Just use the name, which is the best we can do. */
+ priv->addr = g_strdup (name);
+
}
}
}
@@ -542,7 +572,7 @@ e_destination_get_textrep (const EDestination *dest)
if (txt)
return txt;
- return NULL;
+ return "";
}
gboolean
diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.c b/addressbook/gui/component/select-names/e-select-names-text-model.c
index 50a09bd010..0183fdd236 100644
--- a/addressbook/gui/component/select-names/e-select-names-text-model.c
+++ b/addressbook/gui/component/select-names/e-select-names-text-model.c
@@ -333,7 +333,7 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha
/* This is the case of hitting , first thing in an empty entry */
if (index == -1) {
EReposAbsolute repos;
-
+
e_select_names_model_insert (source, 0, e_destination_new ());
e_select_names_model_insert (source, 0, e_destination_new ());
@@ -361,7 +361,7 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha
repos.len = SEPLEN;
e_text_model_reposition (model, e_repos_insert_shift, &repos);
pos += SEPLEN;
- }
+ }
} else {
EReposInsertShift repos;
@@ -396,7 +396,7 @@ e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gcha
gboolean whitespace = isspace ((gint) text[i]);
str = index >= 0 ? e_select_names_model_get_string (source, index) : NULL;
- if (str) {
+ if (str && *str) {
if (pos <= start_pos) {
if (whitespace) {
/* swallow leading whitespace */