Package: lbdb
Version: 0.42.1
Severity: wishlist
Tags: patch

Hi,

I'm using lbdb with khard as part of a CardDAV contacts system I set up
for myself recently, documented at
https://www.chiark.greenend.org.uk/~cjwatson/blog/new-address-book.html.
Would you consider taking this patch for lbdb so that others can use it
more easily?

diff --git a/README b/README
index 17baf44..b62c385 100644
--- a/README
+++ b/README
@@ -179,6 +179,9 @@ m_vcf
        This module uses libvformat to search for addresses from the
        space-separated set of vCard files defined in $VCF_FILES.
 
+m_khard
+       This module searches a CardDAV address book via khard.
+
 
 Feel free to create your own modules to query other kinds of
 databases.  m_finger should be a good example of how to do it.
@@ -214,3 +217,4 @@ Many thanks to the authors of the several modules and 
extensions:
 - Dave Pearson <da...@davep.org>                   (m_palm, lbdb.el)
 - Brian Salter-Duke <b_d...@bigpond.net.au>        (m_muttalias)
 - François Charlier <fcharl...@ploup.net>          (m_goobook)
+- Colin Watson <cjwat...@debian.org>               (m_khard)
diff --git a/configure b/configure
index 6a72461..6bd6f56 100755
--- a/configure
+++ b/configure
@@ -628,6 +628,7 @@ VFORMAT
 PBXBUILD
 XCODEBUILD
 PERL
+KHARD
 EVOLUTION_ADDRESSBOOK_EXPORT
 PGP
 PGPK
@@ -733,6 +734,7 @@ with_gpg
 with_pgpk
 with_pgp
 with_evolution_addressbook_export
+with_khard
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1376,6 +1378,7 @@ Optional Packages:
   --with-pgp              with PGP 2.* support
   --with-evolution-addressbook-export
                           with Evolution support ('auto' searchs at runtime)
+  --with-khard            with khard support
 
 Some influential environment variables:
   CC          C compiler command
@@ -6198,6 +6201,114 @@ fi
     fi
 
 
+    withval=""
+
+# Check whether --with-khard was given.
+if test "${with_khard+set}" = set; then :
+  withval=$with_khard;
+fi
+
+    if test x$withval = xyes; then
+        # Extract the first word of "khard", so it can be a program name with 
args.
+set dummy khard; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_KHARD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $KHARD in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_KHARD="$KHARD" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_KHARD="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" 
>&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_path_KHARD" && ac_cv_path_KHARD=""no""
+  ;;
+esac
+fi
+KHARD=$ac_cv_path_KHARD
+if test -n "$KHARD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $KHARD" >&5
+$as_echo "$KHARD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+        if test x$KHARD = xno; then
+           as_fn_error $? "khard not in PATH" "$LINENO" 5
+        else
+           MODULES="$MODULES m_khard"
+
+        fi
+    elif test x$withval = x; then
+        # Extract the first word of "khard", so it can be a program name with 
args.
+set dummy khard; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_KHARD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $KHARD in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_KHARD="$KHARD" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_KHARD="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" 
>&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  test -z "$ac_cv_path_KHARD" && ac_cv_path_KHARD=""no""
+  ;;
+esac
+fi
+KHARD=$ac_cv_path_KHARD
+if test -n "$KHARD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $KHARD" >&5
+$as_echo "$KHARD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+        if test x$KHARD != xno; then
+           MODULES="$MODULES m_khard"
+
+        fi
+    elif test x$withval != xno; then
+        KHARD=$withval
+        MODULES="$MODULES m_khard"
+
+    fi
+
+
 # Extract the first word of "perl", so it can be a program name with args.
 set dummy perl; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
diff --git a/configure.in b/configure.in
index c64fa3b..20fa85a 100644
--- a/configure.in
+++ b/configure.in
@@ -175,6 +175,7 @@ LBDB_ARG_WITH(PGPK, pgpk, m_pgp5, [with PGP 5.* support])
 LBDB_ARG_WITH(PGP, pgp, m_pgp2, [with PGP 2.* support])
 LBDB_ARG_WITH(EVOLUTION_ADDRESSBOOK_EXPORT, evolution-addressbook-export,
               m_evolution, [with Evolution support ('auto' searchs at 
runtime)])
+LBDB_ARG_WITH(KHARD, khard, m_khard, [with khard support])
 
 AC_PATH_PROG(PERL, perl, "no")
 if test "x$PERL" != xno ; then
diff --git a/debian/control b/debian/control
index 9aa5159..56a48b8 100644
--- a/debian/control
+++ b/debian/control
@@ -15,6 +15,7 @@ Depends: emacsen-common (>= 2.0.8),
 Suggests: abook,
           finger,
           goobook,
+          khard,
           libauthen-sasl-perl,
           libnet-ldap-perl,
           libpalm-perl,
@@ -45,3 +46,4 @@ Description: Little Brother's DataBase for the mutt mail 
reader
   - m_ldap (query some LDAP server)
   - m_evolution (search in the Evolution addressbook)
   - m_vcf (search in vcard files using libvformat)
+  - m_khard (search a CardDAV address book via khard)
diff --git a/debian/rules b/debian/rules
index eeb41e0..aa1dc8d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -27,7 +27,8 @@ override_dh_auto_configure:
                        --with-gpg=/usr/bin/gpg \
                        --with-pgpk=/usr/bin/pgpk \
                        --with-pgp=/usr/bin/pgp \
-                       --with-evolution-addressbook-export=auto
+                       --with-evolution-addressbook-export=auto \
+                       --with-khard=/usr/bin/khard
 
 override_dh_auto_install:
        $(MAKE) install_prefix=$(DROOT) install
diff --git a/lbdb.rc.in b/lbdb.rc.in
index 7dd0089..b45718d 100644
--- a/lbdb.rc.in
+++ b/lbdb.rc.in
@@ -38,6 +38,7 @@
 # - m_osx_addressbook  search the OS X addressbook (only available on OS X).
 # - m_evolution  search in the Ximan Evolution addressbook.
 # - m_vcf        search a vcard (according to RFC2426) file.
+# - m_khard      search a CardDAV address book via khard
 
 METHODS="m_inmail m_passwd m_finger"
 
diff --git a/lbdbq.man.in b/lbdbq.man.in
index b9b2270..912fc38 100644
--- a/lbdbq.man.in
+++ b/lbdbq.man.in
@@ -304,6 +304,10 @@ which is shipped with evolution.
 This module uses libvformat to search for addresses from the
 space\-separated set of vCard files defined in
 .IR $VCF_FILES .
+.TP
+.BR m_khard
+This module searches a CardDAV address book via
+.BR khard (1).
 .PP
 Feel free to create your own modules to query other database resources,
 YP maps, and the like.
@@ -379,8 +383,9 @@ Torsten Jerzembeck <t...@nightingale.ms.sub.org> 
(m_addr_email),
 Adrian Likins <alik...@redhat.com> (m_getent),
 Gergely Nagy <alger...@debian.org> (m_wanderlust),
 Dave Pearson <da...@davep.org> (m_palm, lbdb.el),
-Brian Salter-Duke <b_d...@bigpond.net.au> (m_muttalias), and
-François Charlier <fcharl...@ploup.net> (m_goobook)
+Brian Salter-Duke <b_d...@bigpond.net.au> (m_muttalias),
+François Charlier <fcharl...@ploup.net> (m_goobook), and
+Colin Watson <cjwat...@debian.org> (m_khard)
 .SH AUTHOR
 The lbdb package was initially written by Thomas Roessler
 <roess...@guug.de> and is now maintained and heavily extended by
diff --git a/m_khard.sh.in b/m_khard.sh.in
new file mode 100644
index 0000000..404ccd1
--- /dev/null
+++ b/m_khard.sh.in
@@ -0,0 +1,30 @@
+#! @SH@
+#
+# -*-sh-mode-*-
+#
+#     Copyright (C) 2017 Colin Watson <cjwat...@debian.org>
+#
+#     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_khard_query() {
+    KHARD=@KHARD@
+
+    if [ -x "$KHARD" ]
+    then
+        "$KHARD" email \
+            --parsable --remove-first-line --search-in-source-files \
+            "$1"
+    fi
+}
-- 
2.11.0

-- System Information:
Debian Release: 9.0
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.9.0-3-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages lbdb depends on:
ii  emacsen-common  2.0.8
ii  libc6           2.24-11+deb9u1
ii  libvformat0     1.13-10
ii  perl            5.24.1-3

lbdb recommends no packages.

Versions of packages lbdb suggests:
ii  abook                0.6.1-1+b1
ii  finger               0.17-15.1
pn  goobook              <none>
ii  libauthen-sasl-perl  2.1600-1
ii  libnet-ldap-perl     1:0.6500+dfsg-1
ii  libpalm-perl         1:1.400-1
ii  mutt                 1.7.2-1
ii  procmail             3.22-25+b1

-- no debconf information

Thanks,

-- 
Colin Watson                                       [cjwat...@debian.org]

Reply via email to