NAME

AddressBook - Abstract class for using AddressBooks

SYNOPSIS

use AddressBook;
$a = AddressBook->new(source => "LDAP:localhost");
$b = AddressBook->new(source => "DBI:CSV:f_dir=/tmp/data");
$c = AddressBook->new(source => "PDB");

$a->search(name => "hersh");
$entry = $a->read;
$b->add($entry);

$entry = AddressBook::Entry->new(attr=>{name => "dleigh"});
$c->write($entry);

AddressBook::sync(master=>$a,slave=>$c);

DESCRIPTION

AddressBook provides a unified interface to access various databases for keeping track of contacts. Included with this module are several backends:

AddressBook::DB::LDAP
AddressBook::DB::LDIF
AddressBook::DB::DBI
AddressBook::DB::PDB
AddressBook::DB::Text
AddressBook::DB::HTML

More will be added in the future.

new

Create a new AddressBook object.

AddressBook->new(source=$source,\%args)

See the appropriate backend documentation for constructor details.

sync

AddressBook::sync(master=>$master_db, slave=>$slave_db)

Synchronizes the "master" and "slave" databases. The "master" database type must be one that supports random-access methods. The "slave" database type must be one that supports sequential-access methods.

  1. For each record in the slave, look for a corresponding record in the master, using the key_fields of each.

    If no match is found, the entry is added to the master.

    If multiple matches are found, an error occurrs.

    If one match is found, then:

    If the records match, nothing is done.

    If the records do not match, then:

    If the slave record's timestamp is newer, the master's entry is updated with the slave entry's data.

    If the master record's timestamp is newer, nothing is done.

  2. The slave database is truncated.

  3. Each record of the master is added to the slave

Note that deletions made on the slave database are effectively ignored during synchronization.

$abook->search(attr=>\%filter);
while ($entry=$abook->read) {
  print $entry->dump;
}

\%filter is a list of cannonical attribute/value pairs.

read

$entry=$abook->read;

Returns an AddressBook::Entry object

update

$abook->update(filter=>\%filter,entry=>$entry)

\%filter is a list of cannonical attriute/value pairs used to identify the entry to be updated.

$entry is an AddressBook::Entry object

add

$abook->add($entry)

$entry is an AddressBook::Entry object

delete

$abook->delete($entry)

$entry is an AddressBook::Entry object

truncate

$abook->truncate

Removes all records from the database.

AUTHOR

Mark A. Hershberger, <mah@everybody.org> David L. Leigh, <dleigh@sameasiteverwas.net>

SEE ALSO

AddressBook::Config AddressBook::Entry

AddressBook::DB::LDAP AddressBook::DB::LDIF AddressBook::DB::DBI AddressBook::DB::PDB AddressBook::DB::Text AddressBook::DB::HTML