From db6000569132e17eb311d570347b2c286d20a957 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 11 Oct 2011 16:08:24 +0000 Subject: [PATCH] * email: handle folder status cache for active sync --- felamimail/inc/class.felamimail_activesync.inc.php | 4 +++- felamimail/inc/class.felamimail_bo.inc.php | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/felamimail/inc/class.felamimail_activesync.inc.php b/felamimail/inc/class.felamimail_activesync.inc.php index 3a1bf13079..e8db500410 100644 --- a/felamimail/inc/class.felamimail_activesync.inc.php +++ b/felamimail/inc/class.felamimail_activesync.inc.php @@ -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; diff --git a/felamimail/inc/class.felamimail_bo.inc.php b/felamimail/inc/class.felamimail_bo.inc.php index a4f040d793..d744c9c75e 100644 --- a/felamimail/inc/class.felamimail_bo.inc.php +++ b/felamimail/inc/class.felamimail_bo.inc.php @@ -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;