/** * Try to refresh roundcube session * * @param * roundcube host to use $rcHost * @param * port of the roundcube server $rcPort * @param * context path of roundcube $maildir * @return true if session refresh was successfull, otherwise false */ public static function refresh($rcHost, $rcPort, $maildir) { $ocUser = OCP\User::getUser(); // Create RC login object. $enableDebug = OCP\Config::getAppValue('roundcube', 'enableDebug', 'false'); $disableSSLverify = OCP\Config::getAppValue('roundcube', 'noSSLverify', 'false'); $rcl = new OC_RoundCube_Login($rcHost, $rcPort, $maildir, $disableSSLverify, $enableDebug, false); // reuse session ID $sessId = self::getSessionVariable(self::SESSION_ATTR_RCSESSID); if ($sessId !== false) { $rcl->setSessionID($sessId); } $sessAuth = self::getSessionVariable(self::SESSION_ATTR_RCSESSAUTH); if ($sessAuth !== false) { $rcl->setSessionAuth($sessAuth); } // Try to refresh OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->refresh(): Trying to refresh RoundCube session under ' . $maildir, OCP\Util::DEBUG); if ($rcl->isLoggedIn()) { OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->refresh(): Successfully refreshed the RC session.', OCP\Util::INFO); self::setSessionVariable(self::SESSION_ATTR_RCSESSAUTH, $rcl->getSessionAuth()); return true; } else { // login errors, let's try once again if ($rcl->isLoggedIn()) { OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->refresh(): Trying again to refresh RoundCube session under ' . $maildir, OCP\Util::DEBUG); self::setSessionVariable(self::SESSION_ATTR_RCSESSAUTH, $rcl->getSessionAuth()); return true; } else { // TODO add new exception here for relogin OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->refresh(): Failed to refresh the RC session.', OCP\Util::INFO); return false; } } }