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 { ...@@ -749,11 +749,13 @@ class BackendCardDAV extends BackendDiff implements ISearchProvider {
* *
* @param string $searchquery string to be searched for * @param string $searchquery string to be searched for
* @param string $searchrange specified searchrange * @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
* *
* @access public * @access public
* @return array search results * @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)); ZLog::Write(LOGLEVEL_DEBUG, sprintf("BackendCardDAV->GetGALSearchResults(%s, %s)", $searchquery, $searchrange));
if ($this->gal_url !== false && $this->server !== false) { if ($this->gal_url !== false && $this->server !== false) {
// Don't search if the length is < 5, we are typing yet // Don't search if the length is < 5, we are typing yet
......
...@@ -569,23 +569,24 @@ class BackendCombined extends Backend implements ISearchProvider { ...@@ -569,23 +569,24 @@ class BackendCombined extends Backend implements ISearchProvider {
* *
* @param string $searchquery string to be searched for * @param string $searchquery string to be searched for
* @param string $searchrange specified searchrange * @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
* *
* @access public * @access public
* @return array search results * @return array search results
* @throws StatusException
*/ */
public function GetGALSearchResults($searchquery, $searchrange) { public function GetGALSearchResults($searchquery, $searchrange, $searchpicture) {
ZLog::Write(LOGLEVEL_DEBUG, "Combined->GetGALSearchResults()"); ZLog::Write(LOGLEVEL_DEBUG, "Combined->GetGALSearchResults()");
$i = $this->getSearchBackend(ISearchProvider::SEARCH_GAL); $i = $this->getSearchBackend(ISearchProvider::SEARCH_GAL);
$result = false; $result = false;
if ($i !== false) { if ($i !== false) {
$result = $this->backends[$i]->GetGALSearchResults($searchquery, $searchrange); $result = $this->backends[$i]->GetGALSearchResults($searchquery, $searchrange, $searchpicture);
} }
return $result; return $result;
} }
/** /**
* Searches for the emails on the server * Searches for the emails on the server
* *
......
...@@ -1799,11 +1799,13 @@ class BackendIMAP extends BackendDiff implements ISearchProvider { ...@@ -1799,11 +1799,13 @@ class BackendIMAP extends BackendDiff implements ISearchProvider {
* *
* @param string $searchquery string to be searched for * @param string $searchquery string to be searched for
* @param string $searchrange specified searchrange * @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
* *
* @access public * @access public
* @return array search results * @return array search results
* @throws StatusException
*/ */
public function GetGALSearchResults($searchquery, $searchrange) { public function GetGALSearchResults($searchquery, $searchrange, $searchpicture) {
return false; return false;
} }
......
...@@ -1143,14 +1143,15 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -1143,14 +1143,15 @@ class BackendKopano implements IBackend, ISearchProvider {
* Searches the GAB of Kopano * Searches the GAB of Kopano
* Can be overwitten globally by configuring a SearchBackend * Can be overwitten globally by configuring a SearchBackend
* *
* @param string $searchquery * @param string $searchquery string to be searched for
* @param string $searchrange * @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
* *
* @access public * @access public
* @return array * @return array search results
* @throws StatusException * @throws StatusException
*/ */
public function GetGALSearchResults($searchquery, $searchrange){ public function GetGALSearchResults($searchquery, $searchrange, $searchpicture) {
// only return users whose displayName or the username starts with $name // 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 //TODO: use PR_ANR for this restriction instead of PR_DISPLAY_NAME and PR_ACCOUNT
$addrbook = $this->getAddressbook(); $addrbook = $this->getAddressbook();
...@@ -1189,7 +1190,7 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -1189,7 +1190,7 @@ class BackendKopano implements IBackend, ISearchProvider {
$querylimit = (($rangeend + 1) < $querycnt) ? ($rangeend + 1) : $querycnt; $querylimit = (($rangeend + 1) < $querycnt) ? ($rangeend + 1) : $querycnt;
if ($querycnt > 0) 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++) { for ($i = 0; $i < $querylimit; $i++) {
if (!isset($abentries[$i][PR_SMTP_ADDRESS])) { if (!isset($abentries[$i][PR_SMTP_ADDRESS])) {
...@@ -1234,6 +1235,10 @@ class BackendKopano implements IBackend, ISearchProvider { ...@@ -1234,6 +1235,10 @@ class BackendKopano implements IBackend, ISearchProvider {
if (isset($abentries[$i][PR_OFFICE_LOCATION])) if (isset($abentries[$i][PR_OFFICE_LOCATION]))
$items[$i][SYNC_GAL_OFFICE] = w2u($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); $nrResults = count($items);
$items['range'] = ($nrResults > 0) ? $rangestart.'-'.($nrResults - 1) : '0-0'; $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 ...@@ -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_OWNER' ,mapi_prop_tag(PT_BINARY, 0x800C));
define('PR_EMS_AB_ROOM_CAPACITY' ,mapi_prop_tag(PT_LONG, 0x0807)); 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_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)); define('PR_EC_ARCHIVE_SERVERS' ,mapi_prop_tag(PT_MV_TSTRING, 0x67c4));
......
...@@ -83,15 +83,17 @@ class BackendSearchLDAP implements ISearchProvider { ...@@ -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 $searchquery string to be searched for
* @param string $searchrange specified searchrange * @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
* *
* @access public * @access public
* @return array search results * @return array search results
* @throws StatusException
*/ */
public function GetGALSearchResults($searchquery, $searchrange) { public function GetGALSearchResults($searchquery, $searchrange, $searchpicture) {
global $ldap_field_map; global $ldap_field_map;
if (isset($this->connection) && $this->connection !== false) { if (isset($this->connection) && $this->connection !== false) {
$searchfilter = str_replace("SEARCHVALUE", $searchquery, LDAP_SEARCH_FILTER); $searchfilter = str_replace("SEARCHVALUE", $searchquery, LDAP_SEARCH_FILTER);
......
...@@ -63,12 +63,13 @@ class SearchProvider implements ISearchProvider{ ...@@ -63,12 +63,13 @@ class SearchProvider implements ISearchProvider{
* *
* @param string $searchquery string to be searched for * @param string $searchquery string to be searched for
* @param string $searchrange specified searchrange * @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
* *
* @access public * @access public
* @return array search results * @return array search results
* @throws StatusException * @throws StatusException
*/ */
public function GetGALSearchResults($searchquery, $searchrange) { public function GetGALSearchResults($searchquery, $searchrange, $searchpicture) {
return array(); return array();
} }
......
...@@ -47,16 +47,17 @@ interface ISearchProvider { ...@@ -47,16 +47,17 @@ interface ISearchProvider {
public function SupportsType($searchtype); public function SupportsType($searchtype);
/** /**
* Searches the GAL * Searches the GAL.
* *
* @param string $searchquery * @param string $searchquery string to be searched for
* @param string $searchrange * @param string $searchrange specified searchrange
* @param SyncResolveRecipientsPicture $searchpicture limitations for picture
* *
* @access public * @access public
* @return array * @return array search results
* @throws StatusException * @throws StatusException
*/ */
public function GetGALSearchResults($searchquery, $searchrange); public function GetGALSearchResults($searchquery, $searchrange, $searchpicture);
/** /**
* Searches for the emails on the server * Searches for the emails on the server
......
...@@ -35,6 +35,7 @@ class Search extends RequestProcessor { ...@@ -35,6 +35,7 @@ class Search extends RequestProcessor {
*/ */
public function Handle($commandCode) { public function Handle($commandCode) {
$searchrange = '0'; $searchrange = '0';
$searchpicture = new SyncResolveRecipientsPicture();
$cpo = new ContentParameters(); $cpo = new ContentParameters();
if(!self::$decoder->getElementStartTag(SYNC_SEARCH_SEARCH)) if(!self::$decoder->getElementStartTag(SYNC_SEARCH_SEARCH))
...@@ -252,6 +253,27 @@ class Search extends RequestProcessor { ...@@ -252,6 +253,27 @@ class Search extends RequestProcessor {
return false; 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(); $e = self::$decoder->peek();
if($e[EN_TYPE] == EN_TYPE_ENDTAG) { if($e[EN_TYPE] == EN_TYPE_ENDTAG) {
self::$decoder->getElementEndTag(); self::$decoder->getElementEndTag();
...@@ -276,7 +298,7 @@ class Search extends RequestProcessor { ...@@ -276,7 +298,7 @@ class Search extends RequestProcessor {
try { try {
if ($searchname == ISearchProvider::SEARCH_GAL) { if ($searchname == ISearchProvider::SEARCH_GAL) {
//get search results from the searchprovider //get search results from the searchprovider
$rows = $searchprovider->GetGALSearchResults($searchquery, $searchrange); $rows = $searchprovider->GetGALSearchResults($searchquery, $searchrange, $searchpicture);
} }
elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) { elseif ($searchname == ISearchProvider::SEARCH_MAILBOX) {
$backendFolderId = self::$deviceManager->GetBackendIdForFolderId($cpo->GetSearchFolderid()); $backendFolderId = self::$deviceManager->GetBackendIdForFolderId($cpo->GetSearchFolderid());
...@@ -386,6 +408,19 @@ class Search extends RequestProcessor { ...@@ -386,6 +408,19 @@ class Search extends RequestProcessor {
self::$encoder->content((isset($u[SYNC_GAL_EMAILADDRESS]))?$u[SYNC_GAL_EMAILADDRESS]:""); self::$encoder->content((isset($u[SYNC_GAL_EMAILADDRESS]))?$u[SYNC_GAL_EMAILADDRESS]:"");
self::$encoder->endTag(); 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();//result
self::$encoder->endTag();//properties 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