Tag: cws_src680_odbmacros2 User: fs Date: 2008-01-24 14:10:22+0000 Modified: dba/dbaccess/source/ui/uno/dbinteraction.hxx dba/dbaccess/source/ui/uno/dbinteraction.cxx
Log: during #i49133#: its not necessary at all to have an own implementation for the authentication request - the generic interaction handler can easily do this File Changes: Directory: /dba/dbaccess/source/ui/uno/ ======================================= File [changed]: dbinteraction.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/uno/dbinteraction.hxx?r1=1.7&r2=1.7.98.1 Delta lines: +3 -9 ------------------- --- dbinteraction.hxx 2007-07-06 08:45:13+0000 1.7 +++ dbinteraction.hxx 2008-01-24 14:10:20+0000 1.7.98.1 @@ -4,9 +4,9 @@ * * $RCSfile: dbinteraction.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.7.98.1 $ * - * last change: $Author: rt $ $Date: 2007/07/06 08:45:13 $ + * last change: $Author: fs $ $Date: 2008/01/24 14:10:20 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -113,11 +113,6 @@ const ::dbtools::SQLExceptionInfo& _rSqlInfo, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations); - /// handle authentication requests - void implHandle( - const ::com::sun::star::ucb::AuthenticationRequest& _rAuthRequest, - const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionContinuation > >& _rContinuations); - /// handle parameter requests void implHandle( const ::com::sun::star::sdb::ParametersRequest& _rParamRequest, @@ -139,7 +134,6 @@ DISAPPROVE, RETRY, ABORT, - SUPPLY_AUTHENTICATION, SUPPLY_PARAMETERS, SUPPLY_DOCUMENTSAVE }; File [changed]: dbinteraction.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/ui/uno/dbinteraction.cxx?r1=1.15&r2=1.15.196.1 Delta lines: +9 -146 --------------------- --- dbinteraction.cxx 2006-09-17 07:34:07+0000 1.15 +++ dbinteraction.cxx 2008-01-24 14:10:20+0000 1.15.196.1 @@ -4,9 +4,9 @@ * * $RCSfile: dbinteraction.cxx,v $ * - * $Revision: 1.15 $ + * $Revision: 1.15.196.1 $ * - * last change: $Author: obo $ $Date: 2006/09/17 07:34:07 $ + * last change: $Author: fs $ $Date: 2008/01/24 14:10:20 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -45,6 +45,9 @@ #ifndef _TOOLS_DEBUG_HXX #include <tools/debug.hxx> #endif +#ifndef TOOLS_DIAGNOSE_EX_H +#include <tools/diagnose_ex.h> +#endif #ifndef _SV_MSGBOX_HXX #include <vcl/msgbox.hxx> #endif @@ -66,9 +69,6 @@ #ifndef _COM_SUN_STAR_TASK_XINTERACTIONABORT_HPP_ #include <com/sun/star/task/XInteractionAbort.hpp> #endif -#ifndef _COM_SUN_STAR_UCB_XINTERACTIONSUPPLYAUTHENTICATION_HPP_ -#include <com/sun/star/ucb/XInteractionSupplyAuthentication.hpp> -#endif #ifndef _COM_SUN_STAR_SDB_XINTERACTIONSUPPLYPARAMETERS_HPP_ #include <com/sun/star/sdb/XInteractionSupplyParameters.hpp> #endif @@ -158,16 +158,9 @@ return; } - AuthenticationRequest aAuthentRequest; - if (aRequest >>= aAuthentRequest) - { // it's an authentification request - implHandle(aAuthentRequest, aContinuations); - return; - } - ParametersRequest aParamRequest; if (aRequest >>= aParamRequest) - { // it's an authentification request + { // it's an authentication request implHandle(aParamRequest, aContinuations); return; } @@ -227,126 +220,6 @@ } //------------------------------------------------------------------------- - void OInteractionHandler::implHandle(const AuthenticationRequest& _rAuthRequest, const Sequence< Reference< XInteractionContinuation > >& _rContinuations) - { - ::vos::OGuard aGuard(Application::GetSolarMutex()); - // want to open a dialog .... - - // search the continuations we can handle - sal_Int32 nAbortPos = getContinuation(ABORT, _rContinuations); - sal_Int32 nRetryPos = getContinuation(RETRY, _rContinuations); - sal_Int32 nAuthentPos = getContinuation(SUPPLY_AUTHENTICATION, _rContinuations); - - // we strongly need an XInteractionSupplyAuthentication (else we can't return the input given by the user) - Reference< XInteractionSupplyAuthentication > xSuppAuthent; - if (-1 != nAuthentPos) - xSuppAuthent = Reference< XInteractionSupplyAuthentication >(_rContinuations[nAuthentPos], UNO_QUERY); - DBG_ASSERT(xSuppAuthent.is(), "OInteractionHandler::implHandle: need an XInteractionSupplyAuthentication to return the results!"); - - // check which "remember password" modes are allowed - sal_Bool bRemember(sal_False); - sal_Bool bRememberPersistent(sal_False); - if (xSuppAuthent.is()) - { - RememberAuthentication eDefault; - Sequence< RememberAuthentication > aModes(xSuppAuthent->getRememberPasswordModes(eDefault)); - const RememberAuthentication* pModes = aModes.getConstArray(); - bRemember = eDefault != RememberAuthentication_NO; - for (sal_Int32 i=0; i<aModes.getLength(); ++i, ++pModes) - if (*pModes == RememberAuthentication_PERSISTENT) - { - bRememberPersistent = sal_True; - break; - } - } - - // extract some infor from the authentication request - // use the account as realm - String sRealm; - if (_rAuthRequest.HasRealm) - sRealm = _rAuthRequest.Realm.getStr(); - - // determine the flags for - sal_uInt16 nFlags = 0; - nFlags |= LF_NO_PATH; // the AuthenticationRequest does not support a path - - if (0 == _rAuthRequest.Diagnostic.getLength()) - nFlags |= LF_NO_ERRORTEXT; - if (!_rAuthRequest.HasAccount) - nFlags |= LF_NO_ACCOUNT; - if (!_rAuthRequest.HasUserName || !xSuppAuthent.is() || !xSuppAuthent->canSetUserName()) - nFlags |= LF_USERNAME_READONLY; - - // create the dialog - ::rtl::OUString sName = _rAuthRequest.ServerName; - sName = ::dbaui::getStrippedDatabaseName(NULL,sName); - ::svt::LoginDialog aLogin(NULL, nFlags, sName, sRealm.Len() ? &sRealm : NULL); - - // initialize it - aLogin.SetErrorText(_rAuthRequest.Diagnostic.getStr()); - aLogin.SetName(_rAuthRequest.UserName); - if (_rAuthRequest.HasAccount) - aLogin.ClearAccount(); - else - aLogin.ClearPassword(); - - aLogin.SetPassword(_rAuthRequest.Password.getStr()); - - aLogin.SetSavePassword(bRemember); - aLogin.SetSavePasswordText(ModuleRes(bRememberPersistent ? STR_REMEMBERPASSWORD_PERSISTENT : STR_REMEMBERPASSWORD_SESSION)); - - String sLoginRequest(ModuleRes(STR_ENTER_CONNECTION_PASSWORD)); - if (sName.getLength()) - sLoginRequest.SearchAndReplaceAscii("$name$", sName.getStr()); - else - { - sLoginRequest.SearchAndReplaceAscii("\"$name$\"", String()); - sLoginRequest.SearchAndReplaceAscii("$name$", String()); // just to be sure that in other languages the string will be deleted - } - aLogin.SetLoginRequestText(sLoginRequest); - - // execute - sal_Int32 nResult = aLogin.Execute(); - - // dispatch the result - try - { - switch (nResult) - { - case RET_OK: - if (xSuppAuthent.is()) - { - xSuppAuthent->setUserName(aLogin.GetName()); - xSuppAuthent->setPassword(aLogin.GetPassword()); - xSuppAuthent->setRememberPassword( - aLogin.IsSavePassword() - ? - bRememberPersistent - ? RememberAuthentication_PERSISTENT - : RememberAuthentication_SESSION - : RememberAuthentication_NO); - if (_rAuthRequest.HasAccount) - xSuppAuthent->setAccount(aLogin.GetAccount()); - xSuppAuthent->select(); - } - break; - case RET_RETRY: - if (-1 != nRetryPos) - _rContinuations[nRetryPos]->select(); - break; - default: - if (-1 != nAbortPos) - _rContinuations[nAbortPos]->select(); - break; - } - } - catch(Exception&) - { - DBG_ERROR("OInteractionHandler::implHandle(AuthenticationRequest): error while calling back into the InteractionContinuation!"); - } - } - - //------------------------------------------------------------------------- void OInteractionHandler::implHandle(const SQLExceptionInfo& _rSqlInfo, const Sequence< Reference< XInteractionContinuation > >& _rContinuations) { ::vos::OGuard aGuard(Application::GetSolarMutex()); @@ -355,12 +228,6 @@ sal_Int32 nApprovePos = getContinuation(APPROVE, _rContinuations); sal_Int32 nAbortPos = getContinuation(ABORT, _rContinuations); sal_Int32 nRetryPos = getContinuation(RETRY, _rContinuations); -#ifdef DBG_UTIL - sal_Int32 nDisapprovePos = getContinuation(DISAPPROVE, _rContinuations); - sal_Int32 nAuthentPos = getContinuation(SUPPLY_AUTHENTICATION, _rContinuations); - DBG_ASSERT((-1 == nDisapprovePos) && (-1 == nAuthentPos), "OInteractionHandler::implHandle(SQLExceptionInfo): unsupported continuation type!"); - // "Retry" and "Authenticate" do not make sense if the request refered to an SQLException -#endif // determine the style of the dialog, dependent on the present continuation types WinBits nDialogStyle = WB_OK | WB_DEF_OK; if (-1 != nAbortPos) @@ -390,9 +257,9 @@ break; } } - catch(RuntimeException&) + catch( const Exception& ) { - DBG_ERROR("OInteractionHandler::implHandle(SQLExceptionInfo): caught a RuntimeException while calling the continuation callback!"); + DBG_UNHANDLED_EXCEPTION(); } } //------------------------------------------------------------------------- @@ -501,10 +368,6 @@ if (Reference< XInteractionAbort >(*pContinuations, UNO_QUERY).is()) return i; break; - case SUPPLY_AUTHENTICATION: - if (Reference< XInteractionSupplyAuthentication >(*pContinuations, UNO_QUERY).is()) - return i; - break; case SUPPLY_PARAMETERS: if (Reference< XInteractionSupplyParameters >(*pContinuations, UNO_QUERY).is()) return i; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
