From 94bf6c6fadb294697395c74a5036aa2033cc42ac Mon Sep 17 00:00:00 2001 From: Alexey Shpakovsky Date: Sat, 29 May 2021 16:49:45 +0200 Subject: [PATCH] add a shortcut - avoid costly (1sec) discover process if address book uri is known --- abook_class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/abook_class.php b/abook_class.php index 13a3ea1..9308011 100755 --- a/abook_class.php +++ b/abook_class.php @@ -62,6 +62,13 @@ class abook_carddav extends addressbook_backend { function open() { // backend open function $this->account = new Account(DISCOVERY_URI, USERNAME, PASSWORD); + // Use stored addressbook uri if it exists + if(defined('abook_uri')){ + $this->abook = new AddressbookCollection(abook_uri, $this->account); + // TODO: check that it's valid + return true; + } + // Discover the addressbooks for that account try { $discover = new Discovery(); @@ -73,6 +80,8 @@ class abook_carddav extends addressbook_backend { return $this->set_error("Cannot proceed because no addressbooks were found - exiting"); } $this->abook = $abooks[0]; + // HINT: use this line to get your discovered addressbook URI + // echo "discovered: " . $this->abook->getUri(); return true; }