/**
  * Refreshs the roundcube HTTP session
  * @return boolean true if refresh was successfull, otherwise false
  */
 public static function refresh()
 {
     try {
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_AuthHelper.class.php->refresh(): Preparing refresh for roundcube', OCP\Util::DEBUG);
         $maildir = OCP\Config::getAppValue('roundcube', 'maildir', '');
         $rc_host = OCP\Config::getAppValue('roundcube', 'rcHost', '');
         if ($rc_host == '') {
             $rc_host = OC_Request::serverHost();
         }
         $rc_port = OCP\Config::getAppValue('roundcube', 'rcPort', '');
         OC_RoundCube_App::refresh($rc_host, $rc_port, $maildir);
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_AuthHelper.class.php->refresh(): Finished refresh for roundcube', OCP\Util::DEBUG);
         return true;
     } catch (Exception $e) {
         // We got an exception during login/refresh
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_AuthHelper.class.php: ' . 'Login error during refresh.' . $e, OCP\Util::DEBUG);
         return false;
     }
 }
Exemplo n.º 2
0
 /**
  *
  * @brief showing up roundcube iFrame
  * @param roundcube host $rcHost
  * @param roundcube port $rcPort
  * @param path to roundcube installation, Note: The first parameter is the URL-path of the RC inst
  * NOT the file-system path http://host.com/path/to/roundcube/ --> "/path/to/roundcube" $maildir
  *
  */
 public static function showMailFrame($rcHost, $rcPort, $maildir)
 {
     $returnObject = new OC_Mail_Object();
     $enableDebug = OCP\Config::getAppValue('roundcube', 'enableDebug', true);
     $enableAutologin = OCP\Config::getAppValue('roundcube', 'autoLogin', false);
     // Create RC login object.
     $rcl = new OC_RoundCube_Login($rcHost, $rcPort, $maildir, $enableDebug);
     try {
         if (!$rcl->isLoggedIn()) {
             // If the login fails, display an error message in the loggs
             OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): Not logged in.', OCP\Util::ERROR);
             OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): Trying to refresh session.', OCP\Util::INFO);
             if (!OC_RoundCube_App::refresh($rcHost, $rcPort, $maildir)) {
                 throw new OC_Mail_LoginException("Unable to login to roundcube");
             }
         }
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): Preparing iFrame for roundcube:' . $rcl->getRedirectPath(), OCP\Util::DEBUG);
         // loader image
         $loader_image = OCP\Util::imagePath('roundcube', 'loader.gif');
         $disable_header_nav = OCP\Config::getAppValue('roundcube', 'removeHeaderNav', 'false');
         $disable_control_nav = OCP\Config::getAppValue('roundcube', 'removeControlNav', 'false');
         // create iFrame begin
         $returnObject->appendHtmlOutput('<img src="' . $loader_image . '" id="roundcubeLoader">');
         $returnObject->appendHtmlOutput('<iframe src="' . $rcl->getRedirectPath() . '" id="roundcubeFrame"  name="roundcube" width="100%" style="display:none;">  </iframe>');
         $returnObject->appendHtmlOutput('<input type="hidden" id="disable_header_nav" value="' . $disable_header_nav . '"/>');
         $returnObject->appendHtmlOutput('<input type="hidden" id="disable_control_nav" value="' . $disable_control_nav . '"/>');
         // create iFrame end
     } catch (OC_Mail_NetworkingException $ex_net) {
         $returnObject->setErrorOccurred(true);
         $returnObject->setErrorCode(OC_Mail_Object::ERROR_CODE_NETWORK);
         $returnObject->setHtmlOutput('');
         $returnObject->setErrorDetails("ERROR: Technical problem during trying to connect to roundcube server, " . $ex_net->getMessage());
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): RoundCube can\'t login to roundcube due to a network connection exception to roundcube', OCP\Util::ERROR);
     } catch (OC_Mail_LoginException $ex_login) {
         $returnObject->setErrorOccurred(true);
         if ($enableAutologin) {
             OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): Autologin is enabled. Seems that the owncloud and roundcube login details do not match', OCP\Util::ERROR);
             $returnObject->setErrorCode(OC_Mail_Object::ERROR_CODE_AUTOLOGIN);
         } else {
             $returnObject->setErrorCode(OC_Mail_Object::ERROR_CODE_LOGIN);
         }
         $returnObject->setHtmlOutput('');
         $returnObject->setErrorDetails("ERROR: Technical problem, " . $ex_login->getMessage());
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): RoundCube can\'t login to roundcube due to a login exception to roundcube', OCP\Util::ERROR);
     } catch (OC_Mail_RC_InstallNotFoundException $ex_login) {
         $returnObject->setErrorOccurred(true);
         $returnObject->setErrorCode(OC_Mail_Object::ERROR_CODE_RC_NOT_FOUND);
         $returnObject->setHtmlOutput('');
         $returnObject->setErrorDetails("ERROR: Technical problem, " . $ex_login->getMessage());
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): RoundCube can\'t be found on the given path.', OCP\Util::ERROR);
     } catch (Exception $ex_login) {
         $returnObject->setErrorOccurred(true);
         $returnObject->setErrorCode(OC_Mail_Object::ERROR_CODE_GENERAL);
         $returnObject->setHtmlOutput('');
         $returnObject->setErrorDetails("ERROR: Technical problem, " . $ex_login->getMessage());
         OCP\Util::writeLog('roundcube', 'OC_RoundCube_App.class.php->showMailFrame(): RoundCube can\'t login to roundcube due to a unkown exception to roundcube', OCP\Util::ERROR);
     }
     return $returnObject;
 }