* email: handle folder status cache for active sync

This commit is contained in:
Klaus Leithoff 2011-10-11 16:08:24 +00:00
parent 67f3c40ef7
commit db60005691
2 changed files with 7 additions and 5 deletions

View File

@ -922,6 +922,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
if ($addressObject->host == '.SYNTAX-ERROR.') continue;
$mailObject->From = $addressObject->mailbox. (!empty($addressObject->host) ? '@'.$addressObject->host : '');
$mailObject->FromName = $addressObject->personal;
//error_log(__METHOD__.__LINE__.'Address to add (FROM):'.array2string($addressObject));
}
// to
$address_array = imap_rfc822_parse_adrlist((get_magic_quotes_gpc()?stripslashes($headers['TO']):$headers['TO']),'');
@ -1085,6 +1086,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
// $output->to = $this->messages[$id]['to_address']; //$stat['FETCHED_HEADER']['to_name']
// $output->from = $this->messages[$id]['sender_address']; //$stat['FETCHED_HEADER']['sender_name']
$output->to = $headers['TO'];
//error_log(__METHOD__.__LINE__.' From:'.$headers['FROM'].' Charset:'.$this->mail->detect_encoding($headers['FROM']));
$output->from = $headers['FROM'];
$output->cc = ($headers['CC'] ? $headers['CC']:null);
$output->reply_to = ($headers['REPLY_TO']?$headers['REPLY_TO']:null);
@ -1530,7 +1532,7 @@ class felamimail_activesync implements activesync_plugin_write, activesync_plugi
debugLog("AlterPingChanges on $folderid ($folder) stat: ". $syncstate);
$this->mail->reopen($folder);
$status = $this->mail->getFolderStatus($folder);
$status = $this->mail->getFolderStatus($folder,$ignoreStatusCache=true);
if (!$status) {
debugLog("AlterPingChanges: could not stat folder $folder ");
return false;

View File

@ -998,10 +998,10 @@ class felamimail_bo
return true; // as we do not catch/examine setFlags returnValue
}
function _getStatus($folderName)
function _getStatus($folderName,$ignoreStatusCache=false)
{
static $folderStatus;
if (isset($folderStatus[$this->icServer->ImapServerId][$folderName]))
if (!$ignoreStatusCache && isset($folderStatus[$this->icServer->ImapServerId][$folderName]))
{
//error_log(__METHOD__.__LINE__.' Using cache for status on Server:'.$this->icServer->ImapServerId.' for folder:'.$folderName.'->'.array2string($folderStatus[$this->icServer->ImapServerId][$folderName]));
return $folderStatus[$this->icServer->ImapServerId][$folderName];
@ -1643,7 +1643,7 @@ class felamimail_bo
*
* @return array
*/
function getFolderStatus($_folderName)
function getFolderStatus($_folderName,$ignoreStatusCache=false)
{
if (self::$debug) error_log(__METHOD__." called with:".$_folderName);
$retValue = array();
@ -1684,7 +1684,7 @@ class felamimail_bo
$retValue['displayName'] = $retValue['shortDisplayName'] = lang($retValue['shortName']);
}
if ( PEAR::isError($folderStatus = $this->_getStatus($_folderName)) ) {
if ( PEAR::isError($folderStatus = $this->_getStatus($_folderName,$ignoreStatusCache)) ) {
/*if ($folderStatus = $this->bofelamimail->getMailBoxCounters($_folderName)) {
$retValue['messages'] = $folderStatus->messages;
$retValue['recent'] = $folderStatus->recent;