Hi,

I have updated the m_evolution module to correctly join long addresses.
It now also handles multiple addresses for one contact (which it didn't
do before).

Jan

-- 
OpenPGP Key-ID: CF1635D4
"Fashion is a form of ugliness so intolerable that we have to alter it
every six months."  -- Oscar Wilde
#! /bin/sh
#
# -*-sh-*-
#
#     m_evolution - Evolution Address book module for lbdb
#     Copyright (C) 2004 Guido Guenther <a...@sigxcpu.org>
#     Copyright (C) 2004-2006 Roland Rosenfeld <rol...@spinnaker.de>
#     Copyright (C) 2008 brian m. carlson <sand...@crustytoothpaste.ath.cx>
#     Copyright (C) 2009 Jan Larres <j...@majutsushi.net>
#
#     loosely based on m_gnomecard
#
#     This program is free software; you can redistribute it and/or modify
#     it under the terms of the GNU General Public License as published by
#     the Free Software Foundation; either version 2 of the License, or
#     (at your option) any later version.
# 
#     This program is distributed in the hope that it will be useful,
#     but WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#     GNU General Public License for more details.
# 
#     You should have received a copy of the GNU General Public License
#     along with this program; if not, write to the Free Software Foundation,
#     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,, USA.
#

m_evolution_query ()
{
    AWK=/usr/bin/awk
    EVOLUTION_ADDRESSBOOK_EXPORT=/usr/bin/evolution-addressbook-export

    if [ -x $EVOLUTION_ADDRESSBOOK_EXPORT ]; then
        $EVOLUTION_ADDRESSBOOK_EXPORT 2>/dev/null \
        | $AWK 'BEGIN {
                    FS = ":"
                    RS = "\r\n"
                    name = ""
                    emails = ""
                    last_email = 0
                }
                /^END:VCARD/ {
                    if ((name != "" || fileas != "") && emails != "") {
                        sub("^#", "", emails)
                        split(emails, emails_arr, "#")
                        for (email in emails_arr)
                            
printf("%s\t%s\tEV:%s\n",emails_arr[email],name,fileas)
                    }
                    name = ""; fileas = ""; emails = ""
                }
                /^FN:/ {
                    name = $2
                }
                /^X-EVOLUTION-FILE-AS:/ {
                    fileas = $2
                    gsub("\\\\", "", fileas)
                }
                # DEST-EMAIL is needed to skip addresses in list contacts
                /^EMAIL[;:]/ && ! /X-EVOLUTION-DEST-EMAIL/ {
                    emails = emails "#" $2
                    last_email = 1
                }
                # only join email lines for performance reasons
                /^ [^ ]/ && last_email == 1 {
                    cont = $1
                    sub("^ ", "", cont)
                    emails = emails cont
                }
                ! /^EMAIL[;:]/ && ! /^ [^ ]/ {
                    last_email = 0
                }' \
        | grep -ia "$@"
    fi
}

Attachment: signature.asc
Description: Digital signature

Reply via email to