Commit f0173cc4 authored by Manfred Kutas's avatar Manfred Kutas

ZP-743 Implement Picture for ResolveRecipients.

Released under the Affero GNU General Public License (AGPL) version 3.
parent fd2ebc3e
......@@ -749,11 +749,13 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider {
*
* @param string $searchquery string to be searched for
* @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
*
* @access public
* @return array search results
* @throws StatusException
*/
public function GetGALSearchResults($searchquery, $searchrange) {
public function GetGALSearchResults($searchquery, $searchrange, $searchpicture) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV->GetGALSearchResults(%s, %s)", $searchquery, $searchrange));
if ($this->gal_url !== false && $this->server !== false) {
// Don't search if the length is < 5, we are typing yet
......
......@@ -569,23 +569,24 @@ class BackendCombined extends Backend implements ISearchProvider {
*
* @param string $searchquery string to be searched for
* @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
*
* @access public
* @return array search results
* @throws StatusException
*/
public function GetGALSearchResults($searchquery, $searchrange) {
public function GetGALSearchResults($searchquery, $searchrange, $searchpicture) {
ZLog::Write(LOGLEVEL_DEBUG, "Combined->GetGALSearchResults()");
$i = $this->getSearchBackend(ISearchProvider::SEARCH_GAL);
$result = false;
if ($i !== false) {
$result = $this->backends[$i]->GetGALSearchResults($searchquery, $searchrange);
$result = $this->backends[$i]->GetGALSearchResults($searchquery, $searchrange, $searchpicture);
}
return $result;
}
/**
* Searches for the emails on the server
*
......
......@@ -1799,11 +1799,13 @@ class BackendIMAP extends BackendDiff implements ISearchProvider {
*
* @param string $searchquery string to be searched for
* @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
*
* @access public
* @return array search results
* @throws StatusException
*/
public function GetGALSearchResults($searchquery, $searchrange) {
public function GetGALSearchResults($searchquery, $searchrange, $searchpicture) {
return false;
}
......
......@@ -1143,14 +1143,15 @@ class BackendKopano implements IBackend, ISearchProvider {
* Searches the GAB of Kopano
* Can be overwitten globally by configuring a SearchBackend
*
* @param string $searchquery
* @param string $searchrange
* @param string $searchquery string to be searched for
* @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
*
* @access public
* @return array
* @return array search results
* @throws StatusException
*/
public function GetGALSearchResults($searchquery, $searchrange){
public function GetGALSearchResults($searchquery, $searchrange, $searchpicture) {
// only return users whose displayName or the username starts with $name
//TODO: use PR_ANR for this restriction instead of PR_DISPLAY_NAME and PR_ACCOUNT
$addrbook = $this->getAddressbook();
......@@ -1189,7 +1190,7 @@ class BackendKopano implements IBackend, ISearchProvider {
$querylimit = (($rangeend + 1) < $querycnt) ? ($rangeend + 1) : $querycnt;
if ($querycnt > 0)
$abentries = mapi_table_queryrows($table, array(PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER, PR_GIVEN_NAME, PR_SURNAME, PR_MOBILE_TELEPHONE_NUMBER, PR_HOME_TELEPHONE_NUMBER, PR_TITLE, PR_COMPANY_NAME, PR_OFFICE_LOCATION), $rangestart, $querylimit);
$abentries = mapi_table_queryrows($table, array(PR_ENTRYID, PR_ACCOUNT, PR_DISPLAY_NAME, PR_SMTP_ADDRESS, PR_BUSINESS_TELEPHONE_NUMBER, PR_GIVEN_NAME, PR_SURNAME, PR_MOBILE_TELEPHONE_NUMBER, PR_HOME_TELEPHONE_NUMBER, PR_TITLE, PR_COMPANY_NAME, PR_OFFICE_LOCATION, PR_EMS_AB_THUMBNAIL_PHOTO), $rangestart, $querylimit);
for ($i = 0; $i < $querylimit; $i++) {
if (!isset($abentries[$i][PR_SMTP_ADDRESS])) {
......@@ -1234,6 +1235,10 @@ class BackendKopano implements IBackend, ISearchProvider {
if (isset($abentries[$i][PR_OFFICE_LOCATION]))
$items[$i][SYNC_GAL_OFFICE] = w2u($abentries[$i][PR_OFFICE_LOCATION]);
if (isset($abentries[$i][PR_EMS_AB_THUMBNAIL_PHOTO])) {
$items[$i][SYNC_GAL_PICTURE] = StringStreamWrapper::Open($abentries[$i][PR_EMS_AB_THUMBNAIL_PHOTO]);
}
}
$nrResults = count($items);
$items['range'] = ($nrResults > 0) ? $rangestart.'-'.($nrResults - 1) : '0-0';
......
......@@ -1213,6 +1213,7 @@ define('PR_EMS_AB_IS_MEMBER_OF_DL' ,mapi_prop_tag(PT_MV_BINAR
define('PR_EMS_AB_OWNER' ,mapi_prop_tag(PT_BINARY, 0x800C));
define('PR_EMS_AB_ROOM_CAPACITY' ,mapi_prop_tag(PT_LONG, 0x0807));
define('PR_EMS_AB_TAGGED_X509_CERT' ,mapi_prop_tag(PT_MV_BINARY, 0x8C6A));
define('PR_EMS_AB_THUMBNAIL_PHOTO' ,mapi_prop_tag(PT_BINARY, 0x8C9E));
define('PR_EC_ARCHIVE_SERVERS' ,mapi_prop_tag(PT_MV_TSTRING, 0x67c4));
......
......@@ -83,15 +83,17 @@ class BackendSearchLDAP implements ISearchProvider {
/**
* Queries the LDAP backend
* Queries the LDAP backend.
*
* @param string $searchquery string to be searched for
* @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
*
* @access public
* @return array search results
* @throws StatusException
*/
public function GetGALSearchResults($searchquery, $searchrange) {
public function GetGALSearchResults($searchquery, $searchrange, $searchpicture) {
global $ldap_field_map;
if (isset($this->connection) && $this->connection !== false) {
$searchfilter = str_replace("SEARCHVALUE", $searchquery, LDAP_SEARCH_FILTER);
......
......@@ -63,12 +63,13 @@ class SearchProvider implements ISearchProvider{
*
* @param string $searchquery string to be searched for
* @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
*
* @access public
* @return array search results
* @throws StatusException
*/
public function GetGALSearchResults($searchquery, $searchrange) {
public function GetGALSearchResults($searchquery, $searchrange, $searchpicture) {
return array();
}
......
......@@ -47,16 +47,17 @@ interface ISearchProvider {
public function SupportsType($searchtype);
/**
* Searches the GAL
* Searches the GAL.
*
* @param string $searchquery
* @param string $searchrange
* @param string $searchquery string to be searched for
* @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
*
* @access public
* @return array
* @return array search results
* @throws StatusException
*/
public function GetGALSearchResults($searchquery, $searchrange);
public function GetGALSearchResults($searchquery, $searchrange, $searchpicture);
/**
* Searches for the emails on the server
......
......@@ -35,6 +35,7 @@ class Search extends RequestProcessor {
*/
public function Handle($commandCode) {
$searchrange = '0';
$searchpicture = new SyncResolveRecipientsPicture();
$cpo = new ContentParameters();
if(!self::$decoder->getElementStartTag(SYNC_SEARCH_SEARCH))
......@@ -252,6 +253,27 @@ class Search extends RequestProcessor {
return false;
}
if(self::$decoder->getElementStartTag(SYNC_SEARCH_PICTURE)) { // TODO - do something with maxsize and maxpictures in the backend
if(self::$decoder->getElementStartTag(SYNC_SEARCH_MAXSIZE)) {
$searchpicture->maxsize = self::$decoder->getElementContent();
if(!self::$decoder->getElementEndTag())
return false;
}
if(self::$decoder->getElementStartTag(SYNC_SEARCH_MAXPICTURES)) {
$searchpicture->maxpictures = self::$decoder->getElementContent();
if(!self::$decoder->getElementEndTag())
return false;
}
// iOs devices send empty picture tag: <Search:Picture/>
$e = self::$decoder->peek();
if($e[EN_TYPE] == EN_TYPE_ENDTAG) {
if(!self::$decoder->getElementEndTag()) // SYNC_SEARCH_PICTURE
return false;
}
}
$e = self::$decoder->peek();
if($e[EN_TYPE] == EN_TYPE_ENDTAG) {
self::$decoder->getElementEndTag();
......@@ -276,7 +298,7 @@ class Search extends RequestProcessor {
try {
if ($searchname == ISearchProvider::SEARCH_GAL) {
//get search results from the searchprovider
$rows = $searchprovider->GetGALSearchResults($searchquery, $searchrange);
$rows = $searchprovider->GetGALSearchResults($searchquery, $searchrange, $searchpicture);
}
elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) {
$backendFolderId = self::$deviceManager->GetBackendIdForFolderId($cpo->GetSearchFolderid());
......@@ -386,6 +408,19 @@ class Search extends RequestProcessor {
self::$encoder->content((isset($u[SYNC_GAL_EMAILADDRESS]))?$u[SYNC_GAL_EMAILADDRESS]:"");
self::$encoder->endTag();
if (isset($u[SYNC_GAL_PICTURE])) {
self::$encoder->startTag(SYNC_GAL_PICTURE);
self::$encoder->startTag(SYNC_GAL_STATUS);
self::$encoder->content(SYNC_SEARCHSTATUS_PICTURE_SUCCESS); //FIXME: status code
self::$encoder->endTag(); // SYNC_SEARCH_STATUS
self::$encoder->startTag(SYNC_GAL_DATA);
self::$encoder->contentStream($u[SYNC_GAL_PICTURE], false, true);
self::$encoder->endTag(); // SYNC_GAL_DATA
self::$encoder->endTag(); // SYNC_GAL_PICTURE
}
self::$encoder->endTag();//result
self::$encoder->endTag();//properties
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment