jaromail

a commandline tool to easily and privately handle your e-mail
git clone git://parazyd.org/jaromail.git
Log | Files | Refs | Submodules | README

commit 3efc9776c92a861b4cc3130f7991cf50487e1a0a
parent c0e223f0c990c8dc3600dedc94797952429cfe04
Author: Jaromil <jaromil@dyne.org>
Date:   Thu, 19 Jul 2012 19:37:46 +0200

vcard importer avoids to import duplicates

Diffstat:
Msrc/zlibs/addressbook | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/zlibs/addressbook b/src/zlibs/addressbook @@ -83,7 +83,7 @@ search_email() { SELECT rowid FROM $list WHERE email IS "${1}"; EOF -return $? + return $? } address() { { test ! -r ${WORKDIR}/addressbook } && { create_addressbook } @@ -189,6 +189,9 @@ import_vcard() { notice "Import in addressbook VCard ${vcard}" tmp=$TMPDIR/import.$datestamp.$RANDOM + # parse the vcard and print a simple name and email list + # each value on a single line, entry tuples followed by a # + # we skip entries that don't have an email cat ${vcard} | awk ' BEGIN { newcard=0; c=0; name=""; email=""; } /^BEGIN:VCARD/ { newcard=1 } @@ -209,13 +212,18 @@ BEGIN { newcard=0; c=0; name=""; email=""; } } ' | cut -d: -f2 > $tmp + # now parse the temporary list of name and emails addresses=`cat $tmp` newa=1; _name=""; _email="" for a in ${(f)addresses}; do { test "${a[1]}" = "#" } && { - newa=1; - insert_address "${_email}" "${_name}" - { test $? = 0 } && { act "${a} ${_name} <${_email}>" } + newa=1; # its the end of the entry + # check if we have this email already + foundemail=`search_email "${_email}"` + { test "$foundemail" != "" } && { + insert_address "${_email}" "${_name}" + act "${a} ${_name} <${_email}>" + } continue } { test $newa -eq 1 } && {