[balsa] address: Remove libbalsa_address_set_addr_list()
- From: Peter Bloomfield <peterb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] address: Remove libbalsa_address_set_addr_list()
- Date: Mon, 24 Jun 2019 01:15:55 +0000 (UTC)
commit dbb3e04fc1f6d5ce530815d86431ca65c4b468a2
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Sun Jun 23 21:15:04 2019 -0400
address: Remove libbalsa_address_set_addr_list()
Step 1 in keeping address->addr_list private.
* libbalsa/address-book-ldif.c (address_new_prefill): use
libbalsa_address_add_addr() instead;
* libbalsa/address-book-rubrica.c (extract_cards),
(extract_net): ditto;
* libbalsa/address-book-vcard.c
(libbalsa_address_book_vcard_parse_address): ditto;
* libbalsa/address.c: remove it;
* libbalsa/address.h: ditto.
ChangeLog | 15 +++++++++++++++
libbalsa/address-book-ldif.c | 5 ++++-
libbalsa/address-book-rubrica.c | 27 ++++++++++++++++-----------
libbalsa/address-book-vcard.c | 8 ++++++--
libbalsa/address.c | 10 ----------
libbalsa/address.h | 2 --
6 files changed, 41 insertions(+), 26 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1ab8a60c8..46f8a92c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2019-06-23 Peter Bloomfield <pbloomfield bellsouth net>
+
+ address: Remove libbalsa_address_set_addr_list()
+
+ Step 1 in keeping address->addr_list private.
+
+ * libbalsa/address-book-ldif.c (address_new_prefill): use
+ libbalsa_address_add_addr() instead;
+ * libbalsa/address-book-rubrica.c (extract_cards),
+ (extract_net): ditto;
+ * libbalsa/address-book-vcard.c
+ (libbalsa_address_book_vcard_parse_address): ditto;
+ * libbalsa/address.c: remove it;
+ * libbalsa/address.h: ditto.
+
2019-06-22 Peter Bloomfield <pbloomfield bellsouth net>
Address edit widget cosmetics
diff --git a/libbalsa/address-book-ldif.c b/libbalsa/address-book-ldif.c
index 34a2dd675..28ca8f453 100644
--- a/libbalsa/address-book-ldif.c
+++ b/libbalsa/address-book-ldif.c
@@ -202,9 +202,12 @@ address_new_prefill(LibBalsaAddress * address, GList * address_list,
gchar * nickn, gchar * givenn, gchar * surn,
gchar * fulln, gchar * org)
{
+ GList *list;
gchar *full_name;
- libbalsa_address_set_addr_list(address, address_list);
+ for (list = address_list; list != NULL; list = list->next)
+ libbalsa_address_add_addr(address, (const gchar *) list->data);
+ g_list_free_full(address_list, g_free);
if (givenn != NULL) {
libbalsa_address_set_first_name(address, givenn);
diff --git a/libbalsa/address-book-rubrica.c b/libbalsa/address-book-rubrica.c
index 2385328d4..ebb1962bc 100644
--- a/libbalsa/address-book-rubrica.c
+++ b/libbalsa/address-book-rubrica.c
@@ -77,7 +77,7 @@ static GSList *extract_cards(xmlNodePtr card);
static void extract_data(xmlNodePtr entry, gchar ** first_name,
gchar ** last_name, gchar ** nick_name);
static void extract_work(xmlNodePtr entry, gchar ** org);
-static void extract_net(xmlNodePtr entry, GList ** mail_addrs);
+static gint extract_net(xmlNodePtr entry, LibBalsaAddress *address);
static gchar *xml_node_get_attr(xmlNodePtr node, const xmlChar * attname);
static gchar *xml_node_get_text(xmlNodePtr node);
@@ -563,7 +563,7 @@ extract_cards(xmlNodePtr card)
LibBalsaAddress *address = libbalsa_address_new();
xmlNodePtr children;
gchar *full_name;
- GList *address_list = NULL;
+ gint n_addrs = 0;
full_name = xml_node_get_attr(card, CXMLCHARP("name"));
libbalsa_address_set_full_name(address, full_name);
@@ -593,18 +593,16 @@ extract_cards(xmlNodePtr card)
libbalsa_address_set_organization(address, organization);
g_free(organization);
} else if (!xmlStrcmp(children->name, CXMLCHARP("Net"))) {
- extract_net(children->children, &address_list);
+ n_addrs += extract_net(children->children, address);
}
children = children->next;
}
- if (address_list != NULL) {
- libbalsa_address_set_addr_list(address, address_list);
+ if (n_addrs > 0)
addrlist = g_slist_prepend(addrlist, address);
- } else {
+ else
g_object_unref(address);
- }
}
card = card->next;
@@ -690,9 +688,11 @@ extract_work(xmlNodePtr entry, gchar ** org)
}
-static void
-extract_net(xmlNodePtr entry, GList ** mail_addrs)
+static gint
+extract_net(xmlNodePtr entry, LibBalsaAddress *address)
{
+ gint n_addrs = 0;
+
while (entry) {
gchar *uri_type = NULL;
gchar *mail_addr;
@@ -700,12 +700,17 @@ extract_net(xmlNodePtr entry, GList ** mail_addrs)
if (!xmlStrcmp(entry->name, CXMLCHARP("Uri"))
&& g_strcmp0(uri_type = xml_node_get_attr(entry, CXMLCHARP("type")),
"email") == 0
- && (mail_addr = xml_node_get_text(entry)) != NULL)
- *mail_addrs = g_list_prepend(*mail_addrs, mail_addr);
+ && (mail_addr = xml_node_get_text(entry)) != NULL) {
+ libbalsa_address_add_addr(address, mail_addr);
+ g_free(mail_addr);
+ ++n_addrs;
+ }
g_free(uri_type);
entry = entry->next;
}
+
+ return n_addrs;
}
diff --git a/libbalsa/address-book-vcard.c b/libbalsa/address-book-vcard.c
index 8f891c012..c14b8fadf 100644
--- a/libbalsa/address-book-vcard.c
+++ b/libbalsa/address-book-vcard.c
@@ -235,6 +235,8 @@ libbalsa_address_book_vcard_parse_address(FILE * stream,
res = lbab_vcard_write_end(stream_out);
}
if (address != NULL) {
+ GList *list;
+
if (full_name != NULL)
libbalsa_address_set_full_name(address, full_name);
else if (name != NULL)
@@ -248,8 +250,10 @@ libbalsa_address_book_vcard_parse_address(FILE * stream,
libbalsa_address_set_first_name(address, first_name);
libbalsa_address_set_nick_name(address, nick_name);
libbalsa_address_set_organization(address, org);
- libbalsa_address_set_addr_list(address,
- g_list_reverse(addr_list));
+
+ for (list = addr_list; list != NULL; list=list->next)
+ libbalsa_address_add_addr(address, (const gchar *) list->data);
+ g_list_free_full(addr_list, g_free);
res = LBABERR_OK;
g_free(full_name);
diff --git a/libbalsa/address.c b/libbalsa/address.c
index 0c429da65..9439c2001 100644
--- a/libbalsa/address.c
+++ b/libbalsa/address.c
@@ -1235,16 +1235,6 @@ libbalsa_address_set_organization(LibBalsaAddress * address,
address->organization = g_strdup(organization);
}
-void
-libbalsa_address_set_addr_list(LibBalsaAddress * address,
- GList * addr_list)
-{
- g_return_if_fail(LIBBALSA_IS_ADDRESS(address));
-
- g_list_free_full(address->addr_list, g_free);
- address->addr_list = addr_list;
-}
-
void
libbalsa_address_add_addr(LibBalsaAddress * address,
const gchar * addr)
diff --git a/libbalsa/address.h b/libbalsa/address.h
index 244b44994..5f3729299 100644
--- a/libbalsa/address.h
+++ b/libbalsa/address.h
@@ -117,8 +117,6 @@ void libbalsa_address_set_nick_name (LibBalsaAddress * address,
const gchar * nick_name);
void libbalsa_address_set_organization(LibBalsaAddress * address,
const gchar * organization);
-void libbalsa_address_set_addr_list (LibBalsaAddress * address,
- GList * addr_list);
void libbalsa_address_add_addr (LibBalsaAddress * address,
const gchar * addr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]