diff options
author | obo <obo@openoffice.org> | 2010-06-18 10:54:35 +0200 |
---|---|---|
committer | obo <obo@openoffice.org> | 2010-06-18 10:54:35 +0200 |
commit | b71f8795d5e9e2e3ec4810d50b4cd7d43d682852 (patch) | |
tree | 3bf2d2993830a5783c090fa74ed02c215ad4248a /uui | |
parent | 289d583c1652466d3ac73230f1e021368eb34346 (diff) | |
parent | c44ba0727fecc1a1a70f525e72b0854527ab3e22 (diff) |
CWS-TOOLING: integrate CWS tl78
Diffstat (limited to 'uui')
-rw-r--r-- | uui/prj/build.lst | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | uui/source/iahndl-authentication.cxx | 1451 | ||||
-rwxr-xr-x[-rw-r--r--] | uui/source/ids.hrc | 257 | ||||
-rwxr-xr-x[-rw-r--r--] | uui/source/loginerr.hxx | 120 | ||||
-rwxr-xr-x[-rw-r--r--] | uui/source/passworddlg.cxx | 30 | ||||
-rwxr-xr-x[-rw-r--r--] | uui/source/passworddlg.hxx | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | uui/source/passworddlg.src | 28 | ||||
-rwxr-xr-x[-rw-r--r--] | uui/source/passworderrs.src | 9 |
8 files changed, 990 insertions, 909 deletions
diff --git a/uui/prj/build.lst b/uui/prj/build.lst index 0ebacfcb814f..dbe31cb1b57e 100644 --- a/uui/prj/build.lst +++ b/uui/prj/build.lst @@ -1,4 +1,4 @@ -uu uui : l10n svtools NULL +uu uui : l10n vcl svtools NULL uu uui usr1 - all uu_mkout NULL uu uui\source nmake - all uu_source NULL uu uui\util nmake - all uu_util uu_source NULL diff --git a/uui/source/iahndl-authentication.cxx b/uui/source/iahndl-authentication.cxx index 2b0182fd2a83..deea16ccad98 100644..100755 --- a/uui/source/iahndl-authentication.cxx +++ b/uui/source/iahndl-authentication.cxx @@ -1,700 +1,751 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "com/sun/star/task/DocumentPasswordRequest.hpp" -#include "com/sun/star/task/DocumentMSPasswordRequest.hpp" -#include "com/sun/star/task/MasterPasswordRequest.hpp" -#include "com/sun/star/task/XInteractionAbort.hpp" -#include "com/sun/star/task/XInteractionPassword.hpp" -#include "com/sun/star/task/XInteractionRetry.hpp" -#include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp" -#include "com/sun/star/ucb/URLAuthenticationRequest.hpp" - -#include "rtl/digest.h" -#include "vos/mutex.hxx" -#include "tools/errcode.hxx" -#include "vcl/msgbox.hxx" -#include "vcl/svapp.hxx" - -#include "ids.hrc" -#include "getcontinuations.hxx" -#include "passwordcontainer.hxx" -#include "loginerr.hxx" -#include "logindlg.hxx" -#include "masterpasscrtdlg.hxx" -#include "masterpassworddlg.hxx" -#include "passcrtdlg.hxx" -#include "passworddlg.hxx" - -#include "iahndl.hxx" - -using namespace com::sun::star; - -namespace { - -void -executeLoginDialog( - Window * pParent, - LoginErrorInfo & rInfo, - rtl::OUString const & rRealm) - SAL_THROW((uno::RuntimeException)) -{ - try - { - vos::OGuard aGuard(Application::GetSolarMutex()); - - bool bAccount - = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) != 0; - bool bSavePassword = rInfo.GetCanRememberPassword(); - bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials(); - - sal_uInt16 nFlags = 0; - if (rInfo.GetPath().Len() == 0) - nFlags |= LF_NO_PATH; - if (rInfo.GetErrorText().Len() == 0) - nFlags |= LF_NO_ERRORTEXT; - if (!bAccount) - nFlags |= LF_NO_ACCOUNT; - if (!(rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_USER_NAME)) - nFlags |= LF_USERNAME_READONLY; - - if (!bSavePassword) - nFlags |= LF_NO_SAVEPASSWORD; - - if (!bCanUseSysCreds) - nFlags |= LF_NO_USESYSCREDS; - - std::auto_ptr< ResMgr > xManager( - ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui))); - UniString aRealm(rRealm); - std::auto_ptr< LoginDialog > xDialog( - new LoginDialog(pParent, - nFlags, - rInfo.GetServer(), - &aRealm, - xManager.get())); - if (rInfo.GetErrorText().Len() != 0) - xDialog->SetErrorText(rInfo.GetErrorText()); - xDialog->SetName(rInfo.GetUserName()); - if (bAccount) - xDialog->ClearAccount(); - else - xDialog->ClearPassword(); - xDialog->SetPassword(rInfo.GetPassword()); - - if (bSavePassword) - { - xDialog->SetSavePasswordText( - ResId(rInfo.GetIsRememberPersistent() - ? RID_SAVE_PASSWORD - : RID_KEEP_PASSWORD, - *xManager.get())); - - xDialog->SetSavePassword(rInfo.GetIsRememberPassword()); - } - - if ( bCanUseSysCreds ) - xDialog->SetUseSystemCredentials( - rInfo.GetIsUseSystemCredentials() ); - - rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : - ERRCODE_BUTTON_CANCEL); - rInfo.SetUserName(xDialog->GetName()); - rInfo.SetPassword(xDialog->GetPassword()); - rInfo.SetAccount(xDialog->GetAccount()); - rInfo.SetIsRememberPassword(xDialog->IsSavePassword()); - - if ( bCanUseSysCreds ) - rInfo.SetIsUseSystemCredentials( xDialog->IsUseSystemCredentials() ); - } - catch (std::bad_alloc const &) - { - throw uno::RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")), - uno::Reference< uno::XInterface >()); - } -} - -void getRememberModes( - uno::Sequence< ucb::RememberAuthentication > const & rRememberModes, - ucb::RememberAuthentication & rPreferredMode, - ucb::RememberAuthentication & rAlternateMode ) -{ - sal_Int32 nCount = rRememberModes.getLength(); - OSL_ENSURE( (nCount > 0) && (nCount < 4), - "ucb::RememberAuthentication sequence size mismatch!" ); - if ( nCount == 1 ) - { - rPreferredMode = rAlternateMode = rRememberModes[ 0 ]; - return; - } - else - { - //bool bHasRememberModeNo = false; - bool bHasRememberModeSession = false; - bool bHasRememberModePersistent = false; - - for (sal_Int32 i = 0; i < nCount; ++i) - { - switch ( rRememberModes[i] ) - { - case ucb::RememberAuthentication_NO: - //bHasRememberModeNo = true; - break; - case ucb::RememberAuthentication_SESSION: - bHasRememberModeSession = true; - break; - case ucb::RememberAuthentication_PERSISTENT: - bHasRememberModePersistent = true; - break; - default: - OSL_TRACE( "Unsupported RememberAuthentication value" ); - break; - } - } - - if (bHasRememberModePersistent) - { - rPreferredMode = ucb::RememberAuthentication_PERSISTENT; - if (bHasRememberModeSession) - rAlternateMode = ucb::RememberAuthentication_SESSION; - else - rAlternateMode = ucb::RememberAuthentication_NO; - } - else - { - rPreferredMode = ucb::RememberAuthentication_SESSION; - rAlternateMode = ucb::RememberAuthentication_NO; - } - } -} - -void -handleAuthenticationRequest_( - Window * pParent, - uno::Reference< task::XInteractionHandler > const & xIH, - uno::Reference< lang::XMultiServiceFactory > const & xServiceFactory, - ucb::AuthenticationRequest const & rRequest, - uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & - rContinuations, - const rtl::OUString & rURL) - SAL_THROW((uno::RuntimeException)) -{ - uno::Reference< task::XInteractionRetry > xRetry; - uno::Reference< task::XInteractionAbort > xAbort; - uno::Reference< ucb::XInteractionSupplyAuthentication > - xSupplyAuthentication; - uno::Reference< ucb::XInteractionSupplyAuthentication2 > - xSupplyAuthentication2; - getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication); - if (xSupplyAuthentication.is()) - xSupplyAuthentication2.set(xSupplyAuthentication, uno::UNO_QUERY); - - ////////////////////////// - // First, try to obtain credentials from password container service. - uui::PasswordContainerHelper aPwContainerHelper(xServiceFactory); - if (aPwContainerHelper.handleAuthenticationRequest(rRequest, - xSupplyAuthentication, - rURL, - xIH)) - { - xSupplyAuthentication->select(); - return; - } - - ////////////////////////// - // Second, try to obtain credentials from user via password dialog. - ucb::RememberAuthentication eDefaultRememberMode - = ucb::RememberAuthentication_SESSION; - ucb::RememberAuthentication ePreferredRememberMode - = eDefaultRememberMode; - ucb::RememberAuthentication eAlternateRememberMode - = ucb::RememberAuthentication_NO; - - if (xSupplyAuthentication.is()) - { - getRememberModes( - xSupplyAuthentication->getRememberPasswordModes( - eDefaultRememberMode), - ePreferredRememberMode, - eAlternateRememberMode); - } - - sal_Bool bCanUseSystemCredentials; - sal_Bool bDefaultUseSystemCredentials; - if (xSupplyAuthentication2.is()) - { - bCanUseSystemCredentials - = xSupplyAuthentication2->canUseSystemCredentials( - bDefaultUseSystemCredentials); - } - else - { - bCanUseSystemCredentials = sal_False; - bDefaultUseSystemCredentials = sal_False; - } - - LoginErrorInfo aInfo; - aInfo.SetTitle(rRequest.ServerName); - aInfo.SetServer(rRequest.ServerName); - if (rRequest.HasAccount) - aInfo.SetAccount(rRequest.Account); - if (rRequest.HasUserName) - aInfo.SetUserName(rRequest.UserName); - if (rRequest.HasPassword) - aInfo.SetPassword(rRequest.Password); - aInfo.SetErrorText(rRequest.Diagnostic); - - aInfo.SetCanRememberPassword( - ePreferredRememberMode != eAlternateRememberMode); - aInfo.SetIsRememberPassword( - eDefaultRememberMode != ucb::RememberAuthentication_NO); - aInfo.SetIsRememberPersistent( - ePreferredRememberMode == ucb::RememberAuthentication_PERSISTENT); - - aInfo.SetCanUseSystemCredentials(bCanUseSystemCredentials); - aInfo.SetIsUseSystemCredentials( bDefaultUseSystemCredentials ); - aInfo.SetModifyAccount(rRequest.HasAccount - && xSupplyAuthentication.is() - && xSupplyAuthentication->canSetAccount()); - aInfo.SetModifyUserName(rRequest.HasUserName - && xSupplyAuthentication.is() - && xSupplyAuthentication->canSetUserName()); - executeLoginDialog(pParent, - aInfo, - rRequest.HasRealm ? rRequest.Realm : rtl::OUString()); - switch (aInfo.GetResult()) - { - case ERRCODE_BUTTON_OK: - if (xSupplyAuthentication.is()) - { - if (xSupplyAuthentication->canSetUserName()) - xSupplyAuthentication->setUserName(aInfo.GetUserName()); - if (xSupplyAuthentication->canSetPassword()) - xSupplyAuthentication->setPassword(aInfo.GetPassword()); - - if (ePreferredRememberMode != eAlternateRememberMode) - { - // user had te choice. - if (aInfo.GetIsRememberPassword()) - xSupplyAuthentication->setRememberPassword( - ePreferredRememberMode); - else - xSupplyAuthentication->setRememberPassword( - eAlternateRememberMode); - } - else - { - // user had no choice. - xSupplyAuthentication->setRememberPassword( - ePreferredRememberMode); - } - - if (rRequest.HasRealm) - { - if (xSupplyAuthentication->canSetRealm()) - xSupplyAuthentication->setRealm(aInfo.GetAccount()); - } - else if (xSupplyAuthentication->canSetAccount()) - xSupplyAuthentication->setAccount(aInfo.GetAccount()); - - if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials ) - xSupplyAuthentication2->setUseSystemCredentials( - aInfo.GetIsUseSystemCredentials() ); - - xSupplyAuthentication->select(); - } - - ////////////////////////// - // Third, store credentials in password container. - - if ( aInfo.GetIsUseSystemCredentials() ) - { - if (aInfo.GetIsRememberPassword()) - { - if (!aPwContainerHelper.addRecord( - rURL.getLength() ? rURL : rRequest.ServerName, - rtl::OUString(), // empty u/p -> sys creds - uno::Sequence< rtl::OUString >(), - xIH, - ePreferredRememberMode - == ucb::RememberAuthentication_PERSISTENT)) - { - xSupplyAuthentication->setRememberPassword( - ucb::RememberAuthentication_NO); - } - } - else if (eAlternateRememberMode - == ucb::RememberAuthentication_SESSION) - { - if (!aPwContainerHelper.addRecord( - rURL.getLength() ? rURL : rRequest.ServerName, - rtl::OUString(), // empty u/p -> sys creds - uno::Sequence< rtl::OUString >(), - xIH, - false /* SESSION */)) - { - xSupplyAuthentication->setRememberPassword( - ucb::RememberAuthentication_NO); - } - } - } - // Empty user name can not be valid: - else if (aInfo.GetUserName().Len() != 0) - { - uno::Sequence< rtl::OUString > - aPassList(aInfo.GetAccount().Len() == 0 ? 1 : 2); - aPassList[0] = aInfo.GetPassword(); - if (aInfo.GetAccount().Len() != 0) - aPassList[1] = aInfo.GetAccount(); - - if (aInfo.GetIsRememberPassword()) - { - if (!aPwContainerHelper.addRecord( - rURL.getLength() ? rURL : rRequest.ServerName, - aInfo.GetUserName(), - aPassList, - xIH, - ePreferredRememberMode - == ucb::RememberAuthentication_PERSISTENT)) - { - xSupplyAuthentication->setRememberPassword( - ucb::RememberAuthentication_NO); - } - } - else if (eAlternateRememberMode - == ucb::RememberAuthentication_SESSION) - { - if (!aPwContainerHelper.addRecord( - rURL.getLength() ? rURL : rRequest.ServerName, - aInfo.GetUserName(), - aPassList, - xIH, - false /* SESSION */)) - { - xSupplyAuthentication->setRememberPassword( - ucb::RememberAuthentication_NO); - } - } - } - break; - - case ERRCODE_BUTTON_RETRY: - if (xRetry.is()) - xRetry->select(); - break; - - default: - if (xAbort.is()) - xAbort->select(); - break; - } -} - -void -executeMasterPasswordDialog( - Window * pParent, - LoginErrorInfo & rInfo, - task::PasswordRequestMode nMode) - SAL_THROW((uno::RuntimeException)) -{ - rtl::OString aMaster; - try - { - vos::OGuard aGuard(Application::GetSolarMutex()); - - std::auto_ptr< ResMgr > xManager( - ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui))); - if( nMode == task::PasswordRequestMode_PASSWORD_CREATE ) - { - std::auto_ptr< MasterPasswordCreateDialog > xDialog( - new MasterPasswordCreateDialog(pParent, xManager.get())); - rInfo.SetResult(xDialog->Execute() - == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL); - aMaster = rtl::OUStringToOString( - xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8); - } - else - { - std::auto_ptr< MasterPasswordDialog > xDialog( - new MasterPasswordDialog(pParent, nMode, xManager.get())); - rInfo.SetResult(xDialog->Execute() - == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL); - aMaster = rtl::OUStringToOString( - xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8); - } - } - catch (std::bad_alloc const &) - { - throw uno::RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")), - uno::Reference< uno::XInterface >()); - } - - sal_uInt8 aKey[RTL_DIGEST_LENGTH_MD5]; - rtl_digest_PBKDF2(aKey, - RTL_DIGEST_LENGTH_MD5, - reinterpret_cast< sal_uInt8 const * >(aMaster.getStr()), - aMaster.getLength(), - reinterpret_cast< sal_uInt8 const * >( - "3B5509ABA6BC42D9A3A1F3DAD49E56A51"), - 32, - 1000); - - rtl::OUStringBuffer aBuffer; - for (int i = 0; i < RTL_DIGEST_LENGTH_MD5; ++i) - { - aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] >> 4))); - aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] & 15))); - } - rInfo.SetPassword(aBuffer.makeStringAndClear()); -} - -void -handleMasterPasswordRequest_( - Window * pParent, - task::PasswordRequestMode nMode, - uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & - rContinuations) - SAL_THROW((uno::RuntimeException)) -{ - uno::Reference< task::XInteractionRetry > xRetry; - uno::Reference< task::XInteractionAbort > xAbort; - uno::Reference< ucb::XInteractionSupplyAuthentication > - xSupplyAuthentication; - getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication); - LoginErrorInfo aInfo; - - // in case of master password a hash code is returned - executeMasterPasswordDialog(pParent, aInfo, nMode); - - switch (aInfo.GetResult()) - { - case ERRCODE_BUTTON_OK: - if (xSupplyAuthentication.is()) - { - if (xSupplyAuthentication->canSetPassword()) - xSupplyAuthentication->setPassword(aInfo.GetPassword()); - xSupplyAuthentication->select(); - } - break; - - case ERRCODE_BUTTON_RETRY: - if (xRetry.is()) - xRetry->select(); - break; - - default: - if (xAbort.is()) - xAbort->select(); - break; - } -} - -void -executePasswordDialog( - Window * pParent, - LoginErrorInfo & rInfo, - task::PasswordRequestMode nMode, - ::rtl::OUString aDocName, - bool bMSCryptoMode) - SAL_THROW((uno::RuntimeException)) -{ - try - { - vos::OGuard aGuard(Application::GetSolarMutex()); - - std::auto_ptr< ResMgr > xManager( - ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui))); - if( nMode == task::PasswordRequestMode_PASSWORD_CREATE ) - { - std::auto_ptr< PasswordCreateDialog > xDialog( - new PasswordCreateDialog(pParent, - xManager.get(), - bMSCryptoMode)); - - rInfo.SetResult(xDialog->Execute() - == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL); - rInfo.SetPassword( xDialog->GetPassword() ); - } - else - { - std::auto_ptr< PasswordDialog > xDialog( - new PasswordDialog(pParent, nMode, xManager.get(), aDocName)); - - rInfo.SetResult(xDialog->Execute() - == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL); - rInfo.SetPassword( xDialog->GetPassword() ); - } - } - catch (std::bad_alloc const &) - { - throw uno::RuntimeException( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")), - uno::Reference< uno::XInterface>()); - } -} - -void -handlePasswordRequest_( - Window * pParent, - task::PasswordRequestMode nMode, - uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & - rContinuations, - ::rtl::OUString aDocumentName, - bool bMSCryptoMode ) - SAL_THROW((uno::RuntimeException)) -{ - uno::Reference< task::XInteractionRetry > xRetry; - uno::Reference< task::XInteractionAbort > xAbort; - uno::Reference< task::XInteractionPassword > xPassword; - getContinuations(rContinuations, &xRetry, &xAbort, &xPassword); - LoginErrorInfo aInfo; - - executePasswordDialog(pParent, - aInfo, - nMode, - aDocumentName, - bMSCryptoMode); - - switch (aInfo.GetResult()) - { - case ERRCODE_BUTTON_OK: - if (xPassword.is()) - { - xPassword->setPassword(aInfo.GetPassword()); - xPassword->select(); - } - break; - - case ERRCODE_BUTTON_RETRY: - if (xRetry.is()) - xRetry->select(); - break; - - default: - if (xAbort.is()) - xAbort->select(); - break; - } -} - -} // namespace - -bool -UUIInteractionHelper::handleAuthenticationRequest( - uno::Reference< task::XInteractionRequest > const & rRequest) - SAL_THROW((uno::RuntimeException)) -{ - uno::Any aAnyRequest(rRequest->getRequest()); - - ucb::URLAuthenticationRequest aURLAuthenticationRequest; - if (aAnyRequest >>= aURLAuthenticationRequest) - { - handleAuthenticationRequest_(getParentProperty(), - getInteractionHandler(), - m_xServiceFactory, - aURLAuthenticationRequest, - rRequest->getContinuations(), - aURLAuthenticationRequest.URL); - return true; - } - - ucb::AuthenticationRequest aAuthenticationRequest; - if (aAnyRequest >>= aAuthenticationRequest) - { - handleAuthenticationRequest_(getParentProperty(), - getInteractionHandler(), - m_xServiceFactory, - aAuthenticationRequest, - rRequest->getContinuations(), - rtl::OUString()); - return true; - } - return false; -} - -bool -UUIInteractionHelper::handleMasterPasswordRequest( - uno::Reference< task::XInteractionRequest > const & rRequest) - SAL_THROW((uno::RuntimeException)) -{ - uno::Any aAnyRequest(rRequest->getRequest()); - - task::MasterPasswordRequest aMasterPasswordRequest; - if (aAnyRequest >>= aMasterPasswordRequest) - { - handleMasterPasswordRequest_(getParentProperty(), - aMasterPasswordRequest.Mode, - rRequest->getContinuations()); - return true; - } - return false; -} - -bool -UUIInteractionHelper::handlePasswordRequest( - uno::Reference< task::XInteractionRequest > const & rRequest) - SAL_THROW((uno::RuntimeException)) -{ - uno::Any aAnyRequest(rRequest->getRequest()); - - task::DocumentPasswordRequest aDocumentPasswordRequest; - if (aAnyRequest >>= aDocumentPasswordRequest) - { - handlePasswordRequest_(getParentProperty(), - aDocumentPasswordRequest.Mode, - rRequest->getContinuations(), - aDocumentPasswordRequest.Name, - false /* bool bMSCryptoMode */); - return true; - } - - task::DocumentMSPasswordRequest aDocumentMSPasswordRequest; - if (aAnyRequest >>= aDocumentMSPasswordRequest) - { - handlePasswordRequest_(getParentProperty(), - aDocumentMSPasswordRequest.Mode, - rRequest->getContinuations(), - aDocumentMSPasswordRequest.Name, - true /* bool bMSCryptoMode */); - return true; - } - - task::PasswordRequest aPasswordRequest; - if( aAnyRequest >>= aPasswordRequest ) - { - handlePasswordRequest_(getParentProperty(), - aPasswordRequest.Mode, - rRequest->getContinuations(), - rtl::OUString(), - false /* bool bMSCryptoMode */); - return true; - } - - return false; -} +/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "com/sun/star/task/DocumentPasswordRequest.hpp"
+#include "com/sun/star/task/DocumentPasswordRequest2.hpp"
+#include "com/sun/star/task/DocumentMSPasswordRequest.hpp"
+#include "com/sun/star/task/DocumentMSPasswordRequest2.hpp"
+#include "com/sun/star/task/MasterPasswordRequest.hpp"
+#include "com/sun/star/task/XInteractionAbort.hpp"
+#include "com/sun/star/task/XInteractionPassword.hpp"
+#include "com/sun/star/task/XInteractionPassword2.hpp"
+#include "com/sun/star/task/XInteractionRetry.hpp"
+#include "com/sun/star/ucb/XInteractionSupplyAuthentication2.hpp"
+#include "com/sun/star/ucb/URLAuthenticationRequest.hpp"
+
+#include "osl/diagnose.h"
+#include "rtl/digest.h"
+#include "vos/mutex.hxx"
+#include "tools/errcode.hxx"
+#include "vcl/msgbox.hxx"
+#include "vcl/abstdlg.hxx"
+#include "vcl/svapp.hxx"
+
+#include "ids.hrc"
+#include "getcontinuations.hxx"
+#include "passwordcontainer.hxx"
+#include "loginerr.hxx"
+#include "logindlg.hxx"
+#include "masterpasscrtdlg.hxx"
+#include "masterpassworddlg.hxx"
+#include "passcrtdlg.hxx"
+#include "passworddlg.hxx"
+
+#include "iahndl.hxx"
+
+using namespace com::sun::star;
+
+namespace {
+
+void
+executeLoginDialog(
+ Window * pParent,
+ LoginErrorInfo & rInfo,
+ rtl::OUString const & rRealm)
+ SAL_THROW((uno::RuntimeException))
+{
+ try
+ {
+ vos::OGuard aGuard(Application::GetSolarMutex());
+
+ bool bAccount = (rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_ACCOUNT) != 0;
+ bool bSavePassword = rInfo.GetCanRememberPassword();
+ bool bCanUseSysCreds = rInfo.GetCanUseSystemCredentials();
+
+ sal_uInt16 nFlags = 0;
+ if (rInfo.GetPath().Len() == 0)
+ nFlags |= LF_NO_PATH;
+ if (rInfo.GetErrorText().Len() == 0)
+ nFlags |= LF_NO_ERRORTEXT;
+ if (!bAccount)
+ nFlags |= LF_NO_ACCOUNT;
+ if (!(rInfo.GetFlags() & LOGINERROR_FLAG_MODIFY_USER_NAME))
+ nFlags |= LF_USERNAME_READONLY;
+
+ if (!bSavePassword)
+ nFlags |= LF_NO_SAVEPASSWORD;
+
+ if (!bCanUseSysCreds)
+ nFlags |= LF_NO_USESYSCREDS;
+
+ std::auto_ptr< ResMgr > xManager( ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
+ UniString aRealm(rRealm);
+ std::auto_ptr< LoginDialog > xDialog(
+ new LoginDialog( pParent, nFlags, rInfo.GetServer(), &aRealm, xManager.get()));
+ if (rInfo.GetErrorText().Len() != 0)
+ xDialog->SetErrorText(rInfo.GetErrorText());
+ xDialog->SetName(rInfo.GetUserName());
+ if (bAccount)
+ xDialog->ClearAccount();
+ else
+ xDialog->ClearPassword();
+ xDialog->SetPassword(rInfo.GetPassword());
+
+ if (bSavePassword)
+ {
+ xDialog->SetSavePasswordText(
+ ResId(rInfo.GetIsRememberPersistent()
+ ? RID_SAVE_PASSWORD
+ : RID_KEEP_PASSWORD,
+ *xManager.get()));
+
+ xDialog->SetSavePassword(rInfo.GetIsRememberPassword());
+ }
+
+ if ( bCanUseSysCreds )
+ xDialog->SetUseSystemCredentials( rInfo.GetIsUseSystemCredentials() );
+
+ rInfo.SetResult(xDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK :
+ ERRCODE_BUTTON_CANCEL);
+ rInfo.SetUserName(xDialog->GetName());
+ rInfo.SetPassword(xDialog->GetPassword());
+ rInfo.SetAccount(xDialog->GetAccount());
+ rInfo.SetIsRememberPassword(xDialog->IsSavePassword());
+
+ if ( bCanUseSysCreds )
+ rInfo.SetIsUseSystemCredentials( xDialog->IsUseSystemCredentials() );
+ }
+ catch (std::bad_alloc const &)
+ {
+ throw uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
+ uno::Reference< uno::XInterface >());
+ }
+}
+
+void getRememberModes(
+ uno::Sequence< ucb::RememberAuthentication > const & rRememberModes,
+ ucb::RememberAuthentication & rPreferredMode,
+ ucb::RememberAuthentication & rAlternateMode )
+{
+ sal_Int32 nCount = rRememberModes.getLength();
+ OSL_ENSURE( (nCount > 0) && (nCount < 4),
+ "ucb::RememberAuthentication sequence size mismatch!" );
+ if ( nCount == 1 )
+ {
+ rPreferredMode = rAlternateMode = rRememberModes[ 0 ];
+ return;
+ }
+ else
+ {
+ //bool bHasRememberModeNo = false;
+ bool bHasRememberModeSession = false;
+ bool bHasRememberModePersistent = false;
+
+ for (sal_Int32 i = 0; i < nCount; ++i)
+ {
+ switch ( rRememberModes[i] )
+ {
+ case ucb::RememberAuthentication_NO:
+ //bHasRememberModeNo = true;
+ break;
+ case ucb::RememberAuthentication_SESSION:
+ bHasRememberModeSession = true;
+ break;
+ case ucb::RememberAuthentication_PERSISTENT:
+ bHasRememberModePersistent = true;
+ break;
+ default:
+ OSL_TRACE( "Unsupported RememberAuthentication value" );
+ break;
+ }
+ }
+
+ if (bHasRememberModePersistent)
+ {
+ rPreferredMode = ucb::RememberAuthentication_PERSISTENT;
+ if (bHasRememberModeSession)
+ rAlternateMode = ucb::RememberAuthentication_SESSION;
+ else
+ rAlternateMode = ucb::RememberAuthentication_NO;
+ }
+ else
+ {
+ rPreferredMode = ucb::RememberAuthentication_SESSION;
+ rAlternateMode = ucb::RememberAuthentication_NO;
+ }
+ }
+}
+
+void
+handleAuthenticationRequest_(
+ Window * pParent,
+ uno::Reference< task::XInteractionHandler > const & xIH,
+ uno::Reference< lang::XMultiServiceFactory > const & xServiceFactory,
+ ucb::AuthenticationRequest const & rRequest,
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
+ rContinuations,
+ const rtl::OUString & rURL)
+ SAL_THROW((uno::RuntimeException))
+{
+ uno::Reference< task::XInteractionRetry > xRetry;
+ uno::Reference< task::XInteractionAbort > xAbort;
+ uno::Reference< ucb::XInteractionSupplyAuthentication >
+ xSupplyAuthentication;
+ uno::Reference< ucb::XInteractionSupplyAuthentication2 >
+ xSupplyAuthentication2;
+ getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication);
+ if (xSupplyAuthentication.is())
+ xSupplyAuthentication2.set(xSupplyAuthentication, uno::UNO_QUERY);
+
+ //////////////////////////
+ // First, try to obtain credentials from password container service.
+ uui::PasswordContainerHelper aPwContainerHelper(xServiceFactory);
+ if (aPwContainerHelper.handleAuthenticationRequest(rRequest,
+ xSupplyAuthentication,
+ rURL,
+ xIH))
+ {
+ xSupplyAuthentication->select();
+ return;
+ }
+
+ //////////////////////////
+ // Second, try to obtain credentials from user via password dialog.
+ ucb::RememberAuthentication eDefaultRememberMode
+ = ucb::RememberAuthentication_SESSION;
+ ucb::RememberAuthentication ePreferredRememberMode
+ = eDefaultRememberMode;
+ ucb::RememberAuthentication eAlternateRememberMode
+ = ucb::RememberAuthentication_NO;
+
+ if (xSupplyAuthentication.is())
+ {
+ getRememberModes(
+ xSupplyAuthentication->getRememberPasswordModes(
+ eDefaultRememberMode),
+ ePreferredRememberMode,
+ eAlternateRememberMode);
+ }
+
+ sal_Bool bCanUseSystemCredentials;
+ sal_Bool bDefaultUseSystemCredentials;
+ if (xSupplyAuthentication2.is())
+ {
+ bCanUseSystemCredentials
+ = xSupplyAuthentication2->canUseSystemCredentials(
+ bDefaultUseSystemCredentials);
+ }
+ else
+ {
+ bCanUseSystemCredentials = sal_False;
+ bDefaultUseSystemCredentials = sal_False;
+ }
+
+ LoginErrorInfo aInfo;
+ aInfo.SetTitle(rRequest.ServerName);
+ aInfo.SetServer(rRequest.ServerName);
+ if (rRequest.HasAccount)
+ aInfo.SetAccount(rRequest.Account);
+ if (rRequest.HasUserName)
+ aInfo.SetUserName(rRequest.UserName);
+ if (rRequest.HasPassword)
+ aInfo.SetPassword(rRequest.Password);
+ aInfo.SetErrorText(rRequest.Diagnostic);
+
+ aInfo.SetCanRememberPassword(
+ ePreferredRememberMode != eAlternateRememberMode);
+ aInfo.SetIsRememberPassword(
+ eDefaultRememberMode != ucb::RememberAuthentication_NO);
+ aInfo.SetIsRememberPersistent(
+ ePreferredRememberMode == ucb::RememberAuthentication_PERSISTENT);
+
+ aInfo.SetCanUseSystemCredentials(bCanUseSystemCredentials);
+ aInfo.SetIsUseSystemCredentials( bDefaultUseSystemCredentials );
+ aInfo.SetModifyAccount(rRequest.HasAccount
+ && xSupplyAuthentication.is()
+ && xSupplyAuthentication->canSetAccount());
+ aInfo.SetModifyUserName(rRequest.HasUserName
+ && xSupplyAuthentication.is()
+ && xSupplyAuthentication->canSetUserName());
+ executeLoginDialog(pParent,
+ aInfo,
+ rRequest.HasRealm ? rRequest.Realm : rtl::OUString());
+ switch (aInfo.GetResult())
+ {
+ case ERRCODE_BUTTON_OK:
+ if (xSupplyAuthentication.is())
+ {
+ if (xSupplyAuthentication->canSetUserName())
+ xSupplyAuthentication->setUserName(aInfo.GetUserName());
+ if (xSupplyAuthentication->canSetPassword())
+ xSupplyAuthentication->setPassword(aInfo.GetPassword());
+
+ if (ePreferredRememberMode != eAlternateRememberMode)
+ {
+ // user had te choice.
+ if (aInfo.GetIsRememberPassword())
+ xSupplyAuthentication->setRememberPassword(
+ ePreferredRememberMode);
+ else
+ xSupplyAuthentication->setRememberPassword(
+ eAlternateRememberMode);
+ }
+ else
+ {
+ // user had no choice.
+ xSupplyAuthentication->setRememberPassword(
+ ePreferredRememberMode);
+ }
+
+ if (rRequest.HasRealm)
+ {
+ if (xSupplyAuthentication->canSetRealm())
+ xSupplyAuthentication->setRealm(aInfo.GetAccount());
+ }
+ else if (xSupplyAuthentication->canSetAccount())
+ xSupplyAuthentication->setAccount(aInfo.GetAccount());
+
+ if ( xSupplyAuthentication2.is() && bCanUseSystemCredentials )
+ xSupplyAuthentication2->setUseSystemCredentials(
+ aInfo.GetIsUseSystemCredentials() );
+
+ xSupplyAuthentication->select();
+ }
+
+ //////////////////////////
+ // Third, store credentials in password container.
+
+ if ( aInfo.GetIsUseSystemCredentials() )
+ {
+ if (aInfo.GetIsRememberPassword())
+ {
+ if (!aPwContainerHelper.addRecord(
+ rURL.getLength() ? rURL : rRequest.ServerName,
+ rtl::OUString(), // empty u/p -> sys creds
+ uno::Sequence< rtl::OUString >(),
+ xIH,
+ ePreferredRememberMode
+ == ucb::RememberAuthentication_PERSISTENT))
+ {
+ xSupplyAuthentication->setRememberPassword(
+ ucb::RememberAuthentication_NO);
+ }
+ }
+ else if (eAlternateRememberMode
+ == ucb::RememberAuthentication_SESSION)
+ {
+ if (!aPwContainerHelper.addRecord(
+ rURL.getLength() ? rURL : rRequest.ServerName,
+ rtl::OUString(), // empty u/p -> sys creds
+ uno::Sequence< rtl::OUString >(),
+ xIH,
+ false /* SESSION */))
+ {
+ xSupplyAuthentication->setRememberPassword(
+ ucb::RememberAuthentication_NO);
+ }
+ }
+ }
+ // Empty user name can not be valid:
+ else if (aInfo.GetUserName().Len() != 0)
+ {
+ uno::Sequence< rtl::OUString >
+ aPassList(aInfo.GetAccount().Len() == 0 ? 1 : 2);
+ aPassList[0] = aInfo.GetPassword();
+ if (aInfo.GetAccount().Len() != 0)
+ aPassList[1] = aInfo.GetAccount();
+
+ if (aInfo.GetIsRememberPassword())
+ {
+ if (!aPwContainerHelper.addRecord(
+ rURL.getLength() ? rURL : rRequest.ServerName,
+ aInfo.GetUserName(),
+ aPassList,
+ xIH,
+ ePreferredRememberMode
+ == ucb::RememberAuthentication_PERSISTENT))
+ {
+ xSupplyAuthentication->setRememberPassword(
+ ucb::RememberAuthentication_NO);
+ }
+ }
+ else if (eAlternateRememberMode
+ == ucb::RememberAuthentication_SESSION)
+ {
+ if (!aPwContainerHelper.addRecord(
+ rURL.getLength() ? rURL : rRequest.ServerName,
+ aInfo.GetUserName(),
+ aPassList,
+ xIH,
+ false /* SESSION */))
+ {
+ xSupplyAuthentication->setRememberPassword(
+ ucb::RememberAuthentication_NO);
+ }
+ }
+ }
+ break;
+
+ case ERRCODE_BUTTON_RETRY:
+ if (xRetry.is())
+ xRetry->select();
+ break;
+
+ default:
+ if (xAbort.is())
+ xAbort->select();
+ break;
+ }
+}
+
+void
+executeMasterPasswordDialog(
+ Window * pParent,
+ LoginErrorInfo & rInfo,
+ task::PasswordRequestMode nMode)
+ SAL_THROW((uno::RuntimeException))
+{
+ rtl::OString aMaster;
+ try
+ {
+ vos::OGuard aGuard(Application::GetSolarMutex());
+
+ std::auto_ptr< ResMgr > xManager(
+ ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
+ if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
+ {
+ std::auto_ptr< MasterPasswordCreateDialog > xDialog(
+ new MasterPasswordCreateDialog(pParent, xManager.get()));
+ rInfo.SetResult(xDialog->Execute()
+ == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
+ aMaster = rtl::OUStringToOString(
+ xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
+ }
+ else
+ {
+ std::auto_ptr< MasterPasswordDialog > xDialog(
+ new MasterPasswordDialog(pParent, nMode, xManager.get()));
+ rInfo.SetResult(xDialog->Execute()
+ == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL);
+ aMaster = rtl::OUStringToOString(
+ xDialog->GetMasterPassword(), RTL_TEXTENCODING_UTF8);
+ }
+ }
+ catch (std::bad_alloc const &)
+ {
+ throw uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
+ uno::Reference< uno::XInterface >());
+ }
+
+ sal_uInt8 aKey[RTL_DIGEST_LENGTH_MD5];
+ rtl_digest_PBKDF2(aKey,
+ RTL_DIGEST_LENGTH_MD5,
+ reinterpret_cast< sal_uInt8 const * >(aMaster.getStr()),
+ aMaster.getLength(),
+ reinterpret_cast< sal_uInt8 const * >(
+ "3B5509ABA6BC42D9A3A1F3DAD49E56A51"),
+ 32,
+ 1000);
+
+ rtl::OUStringBuffer aBuffer;
+ for (int i = 0; i < RTL_DIGEST_LENGTH_MD5; ++i)
+ {
+ aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] >> 4)));
+ aBuffer.append(static_cast< sal_Unicode >('a' + (aKey[i] & 15)));
+ }
+ rInfo.SetPassword(aBuffer.makeStringAndClear());
+}
+
+void
+handleMasterPasswordRequest_(
+ Window * pParent,
+ task::PasswordRequestMode nMode,
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
+ rContinuations)
+ SAL_THROW((uno::RuntimeException))
+{
+ uno::Reference< task::XInteractionRetry > xRetry;
+ uno::Reference< task::XInteractionAbort > xAbort;
+ uno::Reference< ucb::XInteractionSupplyAuthentication >
+ xSupplyAuthentication;
+ getContinuations(rContinuations, &xRetry, &xAbort, &xSupplyAuthentication);
+ LoginErrorInfo aInfo;
+
+ // in case of master password a hash code is returned
+ executeMasterPasswordDialog(pParent, aInfo, nMode);
+
+ switch (aInfo.GetResult())
+ {
+ case ERRCODE_BUTTON_OK:
+ if (xSupplyAuthentication.is())
+ {
+ if (xSupplyAuthentication->canSetPassword())
+ xSupplyAuthentication->setPassword(aInfo.GetPassword());
+ xSupplyAuthentication->select();
+ }
+ break;
+
+ case ERRCODE_BUTTON_RETRY:
+ if (xRetry.is())
+ xRetry->select();
+ break;
+
+ default:
+ if (xAbort.is())
+ xAbort->select();
+ break;
+ }
+}
+
+void
+executePasswordDialog(
+ Window * pParent,
+ LoginErrorInfo & rInfo,
+ task::PasswordRequestMode nMode,
+ ::rtl::OUString aDocName,
+ bool bMSCryptoMode,
+ bool bIsPasswordToModify )
+ SAL_THROW((uno::RuntimeException))
+{
+ try
+ {
+ vos::OGuard aGuard(Application::GetSolarMutex());
+
+ std::auto_ptr< ResMgr > xManager(
+ ResMgr::CreateResMgr(CREATEVERSIONRESMGR_NAME(uui)));
+ if( nMode == task::PasswordRequestMode_PASSWORD_CREATE )
+ {
+ const sal_uInt16 nMaxPasswdLen = bMSCryptoMode ? 15 : 0; // 0 -> allow any length
+
+ VclAbstractDialogFactory * pFact = VclAbstractDialogFactory::Create();
+ AbstractPasswordToOpenModifyDialog *pTmp = pFact->CreatePasswordToOpenModifyDialog( pParent, 0, nMaxPasswdLen, bIsPasswordToModify );
+ std::auto_ptr< AbstractPasswordToOpenModifyDialog > pDialog( pTmp );
+
+ rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL );
+ rInfo.SetPassword( pDialog->GetPasswordToOpen() );
+ rInfo.SetPasswordToModify( pDialog->GetPasswordToModify() );
+ rInfo.SetRecommendToOpenReadonly( pDialog->IsRecommendToOpenReadonly() );
+ }
+ else
+ {
+ std::auto_ptr< PasswordDialog > pDialog(
+ new PasswordDialog( pParent, nMode, xManager.get(), aDocName, bIsPasswordToModify ) );
+
+ rInfo.SetResult( pDialog->Execute() == RET_OK ? ERRCODE_BUTTON_OK : ERRCODE_BUTTON_CANCEL );
+ rInfo.SetPassword( bIsPasswordToModify ? String() : pDialog->GetPassword() );
+ rInfo.SetPasswordToModify( bIsPasswordToModify ? pDialog->GetPassword() : String() );
+ }
+ }
+ catch (std::bad_alloc const &)
+ {
+ throw uno::RuntimeException(
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("out of memory")),
+ uno::Reference< uno::XInterface>());
+ }
+}
+
+void
+handlePasswordRequest_(
+ Window * pParent,
+ task::PasswordRequestMode nMode,
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > const &
+ rContinuations,
+ ::rtl::OUString aDocumentName,
+ bool bMSCryptoMode,
+ bool bIsPasswordToModify )
+ SAL_THROW((uno::RuntimeException))
+{
+ uno::Reference< task::XInteractionRetry > xRetry;
+ uno::Reference< task::XInteractionAbort > xAbort;
+ uno::Reference< task::XInteractionPassword > xPassword;
+ uno::Reference< task::XInteractionPassword2 > xPassword2;
+ getContinuations(rContinuations, &xRetry, &xAbort, &xPassword2, &xPassword);
+
+ if ( xPassword2.is() && !xPassword.is() )
+ xPassword.set( xPassword2, uno::UNO_QUERY_THROW );
+
+ LoginErrorInfo aInfo;
+
+ executePasswordDialog( pParent, aInfo, nMode,
+ aDocumentName, bMSCryptoMode, bIsPasswordToModify );
+
+ switch (aInfo.GetResult())
+ {
+ case ERRCODE_BUTTON_OK:
+ OSL_ENSURE( !bIsPasswordToModify || xPassword2.is(), "PasswordToModify is requested, but there is no Interaction!" );
+ if (xPassword.is())
+ {
+ if (xPassword2.is())
+ {
+ xPassword2->setPasswordToModify( aInfo.GetPasswordToModify() );
+ xPassword2->setRecommendReadOnly( aInfo.IsRecommendToOpenReadonly() );
+ }
+
+ xPassword->setPassword(aInfo.GetPassword());
+ xPassword->select();
+ }
+ break;
+
+ case ERRCODE_BUTTON_RETRY:
+ if (xRetry.is())
+ xRetry->select();
+ break;
+
+ default:
+ if (xAbort.is())
+ xAbort->select();
+ break;
+ }
+}
+
+} // namespace
+
+bool
+UUIInteractionHelper::handleAuthenticationRequest(
+ uno::Reference< task::XInteractionRequest > const & rRequest)
+ SAL_THROW((uno::RuntimeException))
+{
+ uno::Any aAnyRequest(rRequest->getRequest());
+
+ ucb::URLAuthenticationRequest aURLAuthenticationRequest;
+ if (aAnyRequest >>= aURLAuthenticationRequest)
+ {
+ handleAuthenticationRequest_(getParentProperty(),
+ getInteractionHandler(),
+ m_xServiceFactory,
+ aURLAuthenticationRequest,
+ rRequest->getContinuations(),
+ aURLAuthenticationRequest.URL);
+ return true;
+ }
+
+ ucb::AuthenticationRequest aAuthenticationRequest;
+ if (aAnyRequest >>= aAuthenticationRequest)
+ {
+ handleAuthenticationRequest_(getParentProperty(),
+ getInteractionHandler(),
+ m_xServiceFactory,
+ aAuthenticationRequest,
+ rRequest->getContinuations(),
+ rtl::OUString());
+ return true;
+ }
+ return false;
+}
+
+bool
+UUIInteractionHelper::handleMasterPasswordRequest(
+ uno::Reference< task::XInteractionRequest > const & rRequest)
+ SAL_THROW((uno::RuntimeException))
+{
+ uno::Any aAnyRequest(rRequest->getRequest());
+
+ task::MasterPasswordRequest aMasterPasswordRequest;
+ if (aAnyRequest >>= aMasterPasswordRequest)
+ {
+ handleMasterPasswordRequest_(getParentProperty(),
+ aMasterPasswordRequest.Mode,
+ rRequest->getContinuations());
+ return true;
+ }
+ return false;
+}
+
+bool
+UUIInteractionHelper::handlePasswordRequest(
+ uno::Reference< task::XInteractionRequest > const & rRequest)
+ SAL_THROW((uno::RuntimeException))
+{
+ // parameters to be filled for the call to handlePasswordRequest_
+ Window * pParent = getParentProperty();
+ task::PasswordRequestMode nMode = task::PasswordRequestMode_PASSWORD_ENTER;
+ uno::Sequence< uno::Reference< task::XInteractionContinuation > > const & rContinuations = rRequest->getContinuations();
+ ::rtl::OUString aDocumentName;
+ bool bMSCryptoMode = false;
+ bool bIsPasswordToModify = false;
+
+ bool bDoHandleRequest = false;
+
+ uno::Any aAnyRequest(rRequest->getRequest());
+
+ task::DocumentPasswordRequest2 aDocumentPasswordRequest2;
+ if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest2))
+ {
+ nMode = aDocumentPasswordRequest2.Mode;
+ aDocumentName = aDocumentPasswordRequest2.Name;
+ OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" );
+ bIsPasswordToModify = aDocumentPasswordRequest2.IsRequestPasswordToModify;
+
+ bDoHandleRequest = true;
+ }
+
+ task::DocumentPasswordRequest aDocumentPasswordRequest;
+ if (!bDoHandleRequest && (aAnyRequest >>= aDocumentPasswordRequest))
+ {
+ nMode = aDocumentPasswordRequest.Mode;
+ aDocumentName = aDocumentPasswordRequest.Name;
+ OSL_ENSURE( bMSCryptoMode == false, "bMSCryptoMode should be false" );
+ OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" );
+
+ bDoHandleRequest = true;
+ }
+
+ task::DocumentMSPasswordRequest2 aDocumentMSPasswordRequest2;
+ if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest2))
+ {
+ nMode = aDocumentMSPasswordRequest2.Mode;
+ aDocumentName = aDocumentMSPasswordRequest2.Name;
+ bMSCryptoMode = true;
+ bIsPasswordToModify = aDocumentMSPasswordRequest2.IsRequestPasswordToModify;
+
+ bDoHandleRequest = true;
+ }
+
+ task::DocumentMSPasswordRequest aDocumentMSPasswordRequest;
+ if (!bDoHandleRequest && (aAnyRequest >>= aDocumentMSPasswordRequest))
+ {
+ nMode = aDocumentMSPasswordRequest.Mode;
+ aDocumentName = aDocumentMSPasswordRequest.Name;
+ bMSCryptoMode = true;
+ OSL_ENSURE( bIsPasswordToModify == false, "bIsPasswordToModify should be false" );
+
+ bDoHandleRequest = true;
+ }
+
+ if (bDoHandleRequest)
+ {
+ handlePasswordRequest_( pParent, nMode, rContinuations,
+ aDocumentName, bMSCryptoMode, bIsPasswordToModify );
+ return true;
+ }
+
+ task::PasswordRequest aPasswordRequest;
+ if( aAnyRequest >>= aPasswordRequest )
+ {
+ handlePasswordRequest_(getParentProperty(),
+ aPasswordRequest.Mode,
+ rRequest->getContinuations(),
+ rtl::OUString(),
+ false /* bool bMSCryptoMode */);
+ return true;
+ }
+
+ return false;
+}
+
diff --git a/uui/source/ids.hrc b/uui/source/ids.hrc index 9bf5856bc270..6a6f38385013 100644..100755 --- a/uui/source/ids.hrc +++ b/uui/source/ids.hrc @@ -35,126 +35,129 @@ #include "tools/errcode.hxx" #endif -#define RID_KEEP_PASSWORD (RID_UUI_START + 0) -#define RID_SAVE_PASSWORD (RID_UUI_START + 1) -#define DLG_UUI_LOGIN (RID_UUI_START + 2) -#define DLG_COOKIES (RID_UUI_START + 3) -#define STR_COOKIES_RECV_START (RID_UUI_START + 4) -#define STR_COOKIES_RECV_COOKIES (RID_UUI_START + 5) -#define STR_COOKIES_RECV_TITLE (RID_UUI_START + 6) -#define STR_COOKIES_SEND_START (RID_UUI_START + 7) -#define STR_COOKIES_SEND_COOKIES (RID_UUI_START + 8) -#define STR_COOKIES_SEND_TITLE (RID_UUI_START + 9) -#define DLG_FILTER_SELECT (RID_UUI_START + 10) +#define RID_KEEP_PASSWORD (RID_UUI_START + 0) +#define RID_SAVE_PASSWORD (RID_UUI_START + 1) +#define DLG_UUI_LOGIN (RID_UUI_START + 2) +#define DLG_COOKIES (RID_UUI_START + 3) +#define STR_COOKIES_RECV_START (RID_UUI_START + 4) +#define STR_COOKIES_RECV_COOKIES (RID_UUI_START + 5) +#define STR_COOKIES_RECV_TITLE (RID_UUI_START + 6) +#define STR_COOKIES_SEND_START (RID_UUI_START + 7) +#define STR_COOKIES_SEND_COOKIES (RID_UUI_START + 8) +#define STR_COOKIES_SEND_TITLE (RID_UUI_START + 9) +#define DLG_FILTER_SELECT (RID_UUI_START + 10) // RID_UUI_START + 11 moved to ERRCODE_UUI_WRONGMEDIUM -#define DLG_UUI_MASTERPASSWORD (RID_UUI_START + 12) -#define STR_ERROR_PASSWORDS_NOT_IDENTICAL (RID_UUI_START + 13) -#define STR_ERROR_MASTERPASSWORD_WRONG (RID_UUI_START + 14) +#define DLG_UUI_MASTERPASSWORD (RID_UUI_START + 12) +#define STR_ERROR_PASSWORDS_NOT_IDENTICAL (RID_UUI_START + 13) +#define STR_ERROR_MASTERPASSWORD_WRONG (RID_UUI_START + 14) // RID_UUI_START + 15, 16, 17 are misused by syncaccess/source/ui/resids.hrc -#define RID_UUI_ERRHDL (RID_UUI_START + 20) -#define DLG_UUI_MASTERPASSWORD_CRT (RID_UUI_START + 21) -#define DLG_UUI_PASSWORD (RID_UUI_START + 22) -#define DLG_UUI_PASSWORD_CRT (RID_UUI_START + 23) -#define STR_ERROR_PASSWORD_WRONG (RID_UUI_START + 24) -#define STR_WARNING_BROKENSIGNATURE_TITLE (RID_UUI_START + 25) -#define DLG_UUI_UNKNOWNAUTH (RID_UUI_START + 26) -#define DLG_UUI_UNKNOWNAUTH_CRT (RID_UUI_START + 27) -#define DLG_UUI_SSLWARN (RID_UUI_START + 28) -#define DLG_UUI_SSLWARN_CRT (RID_UUI_START + 29) -#define RID_XMLSECDLG_MACROWARN (RID_UUI_START + 30) -#define STR_UNKNOWNUSER (RID_UUI_START + 31) -#define STR_OPENLOCKED_TITLE (RID_UUI_START + 32) -#define STR_OPENLOCKED_MSG (RID_UUI_START + 33) -#define STR_OPENLOCKED_OPENREADONLY_BTN (RID_UUI_START + 34) -#define STR_OPENLOCKED_OPENCOPY_BTN (RID_UUI_START + 35) -#define STR_FILECHANGED_TITLE (RID_UUI_START + 36) -#define STR_FILECHANGED_MSG (RID_UUI_START + 37) -#define STR_FILECHANGED_SAVEANYWAY_BTN (RID_UUI_START + 38) -#define STR_ALREADYOPEN_TITLE (RID_UUI_START + 39) -#define STR_ALREADYOPEN_MSG (RID_UUI_START + 40) -#define STR_ALREADYOPEN_READONLY_BTN (RID_UUI_START + 41) -#define STR_ALREADYOPEN_OPEN_BTN (RID_UUI_START + 42) -#define STR_LOCKFAILED_TITLE (RID_UUI_START + 43) -#define STR_LOCKFAILED_MSG (RID_UUI_START + 44) -#define STR_LOCKFAILED_DONTSHOWAGAIN (RID_UUI_START + 45) -#define STR_TRYLATER_TITLE (RID_UUI_START + 46) -#define STR_TRYLATER_MSG (RID_UUI_START + 47) -#define STR_TRYLATER_RETRYSAVING_BTN (RID_UUI_START + 48) -#define STR_TRYLATER_SAVEAS_BTN (RID_UUI_START + 49) -#define STR_ALREADYOPEN_SAVE_MSG (RID_UUI_START + 50) -#define STR_ALREADYOPEN_RETRY_SAVE_BTN (RID_UUI_START + 51) -#define STR_ALREADYOPEN_SAVE_BTN (RID_UUI_START + 52) -#define RID_DLG_NEWER_VERSION_WARNING (RID_UUI_START + 53) -#define STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE (RID_UUI_START + 54) +#define RID_UUI_ERRHDL (RID_UUI_START + 20) +#define DLG_UUI_MASTERPASSWORD_CRT (RID_UUI_START + 21) +#define DLG_UUI_PASSWORD (RID_UUI_START + 22) +#define DLG_UUI_PASSWORD_CRT (RID_UUI_START + 23) +#define STR_ERROR_PASSWORD_TO_OPEN_WRONG (RID_UUI_START + 24) +#define STR_ERROR_PASSWORD_TO_MODIFY_WRONG (RID_UUI_START + 25) +#define DLG_UUI_UNKNOWNAUTH (RID_UUI_START + 26) +#define DLG_UUI_UNKNOWNAUTH_CRT (RID_UUI_START + 27) +#define DLG_UUI_SSLWARN (RID_UUI_START + 28) +#define DLG_UUI_SSLWARN_CRT (RID_UUI_START + 29) +#define RID_XMLSECDLG_MACROWARN (RID_UUI_START + 30) +#define STR_UNKNOWNUSER (RID_UUI_START + 31) +#define STR_OPENLOCKED_TITLE (RID_UUI_START + 32) +#define STR_OPENLOCKED_MSG (RID_UUI_START + 33) +#define STR_OPENLOCKED_OPENREADONLY_BTN (RID_UUI_START + 34) +#define STR_OPENLOCKED_OPENCOPY_BTN (RID_UUI_START + 35) +#define STR_FILECHANGED_TITLE (RID_UUI_START + 36) +#define STR_FILECHANGED_MSG (RID_UUI_START + 37) +#define STR_FILECHANGED_SAVEANYWAY_BTN (RID_UUI_START + 38) +#define STR_ALREADYOPEN_TITLE (RID_UUI_START + 39) +#define STR_ALREADYOPEN_MSG (RID_UUI_START + 40) +#define STR_ALREADYOPEN_READONLY_BTN (RID_UUI_START + 41) +#define STR_ALREADYOPEN_OPEN_BTN (RID_UUI_START + 42) +#define STR_LOCKFAILED_TITLE (RID_UUI_START + 43) +#define STR_LOCKFAILED_MSG (RID_UUI_START + 44) +#define STR_LOCKFAILED_DONTSHOWAGAIN (RID_UUI_START + 45) +#define STR_TRYLATER_TITLE (RID_UUI_START + 46) +#define STR_TRYLATER_MSG (RID_UUI_START + 47) +#define STR_TRYLATER_RETRYSAVING_BTN (RID_UUI_START + 48) +#define STR_TRYLATER_SAVEAS_BTN (RID_UUI_START + 49) +#define STR_ALREADYOPEN_SAVE_MSG (RID_UUI_START + 50) +#define STR_ALREADYOPEN_RETRY_SAVE_BTN (RID_UUI_START + 51) +#define STR_ALREADYOPEN_SAVE_BTN (RID_UUI_START + 52) +#define RID_DLG_NEWER_VERSION_WARNING (RID_UUI_START + 53) +#define STR_WARNING_INCOMPLETE_ENCRYPTION_TITLE (RID_UUI_START + 54) +#define STR_WARNING_BROKENSIGNATURE_TITLE (RID_UUI_START + 55) +#define STR_ENTER_PASSWORD_TO_OPEN (RID_UUI_START + 56) +#define STR_ENTER_PASSWORD_TO_MODIFY (RID_UUI_START + 57) -#define ERRCODE_UUI_IO_ABORT (ERRCODE_AREA_UUI + 0) -#define ERRCODE_UUI_IO_ACCESSDENIED (ERRCODE_AREA_UUI + 1) -#define ERRCODE_UUI_IO_ALREADYEXISTS (ERRCODE_AREA_UUI + 2) -#define ERRCODE_UUI_IO_BADCRC (ERRCODE_AREA_UUI + 3) -#define ERRCODE_UUI_IO_CANTCREATE (ERRCODE_AREA_UUI + 4) -#define ERRCODE_UUI_IO_CANTREAD (ERRCODE_AREA_UUI + 5) -#define ERRCODE_UUI_IO_CANTSEEK (ERRCODE_AREA_UUI + 6) -#define ERRCODE_UUI_IO_CANTTELL (ERRCODE_AREA_UUI + 7) -#define ERRCODE_UUI_IO_CANTWRITE (ERRCODE_AREA_UUI + 8) -#define ERRCODE_UUI_IO_CURRENTDIR (ERRCODE_AREA_UUI + 9) -#define ERRCODE_UUI_IO_NOTREADY (ERRCODE_AREA_UUI + 10) -#define ERRCODE_UUI_IO_NOTSAMEDEVICE (ERRCODE_AREA_UUI + 11) -#define ERRCODE_UUI_IO_GENERAL (ERRCODE_AREA_UUI + 12) -#define ERRCODE_UUI_IO_INVALIDACCESS (ERRCODE_AREA_UUI + 13) -#define ERRCODE_UUI_IO_INVALIDCHAR (ERRCODE_AREA_UUI + 14) -#define ERRCODE_UUI_IO_INVALIDDEVICE (ERRCODE_AREA_UUI + 15) -#define ERRCODE_UUI_IO_INVALIDLENGTH (ERRCODE_AREA_UUI + 16) -#define ERRCODE_UUI_IO_INVALIDPARAMETER (ERRCODE_AREA_UUI + 17) -#define ERRCODE_UUI_IO_ISWILDCARD (ERRCODE_AREA_UUI + 18) -#define ERRCODE_UUI_IO_LOCKVIOLATION (ERRCODE_AREA_UUI + 19) -#define ERRCODE_UUI_IO_MISPLACEDCHAR (ERRCODE_AREA_UUI + 20) -#define ERRCODE_UUI_IO_NAMETOOLONG (ERRCODE_AREA_UUI + 21) -#define ERRCODE_UUI_IO_NOTEXISTS (ERRCODE_AREA_UUI + 22) -#define ERRCODE_UUI_IO_NOTEXISTSPATH (ERRCODE_AREA_UUI + 23) -#define ERRCODE_UUI_IO_NOTSUPPORTED (ERRCODE_AREA_UUI + 24) -#define ERRCODE_UUI_IO_NOTADIRECTORY (ERRCODE_AREA_UUI + 25) -#define ERRCODE_UUI_IO_NOTAFILE (ERRCODE_AREA_UUI + 26) -#define ERRCODE_UUI_IO_OUTOFSPACE (ERRCODE_AREA_UUI + 27) -#define ERRCODE_UUI_IO_TOOMANYOPENFILES (ERRCODE_AREA_UUI + 28) -#define ERRCODE_UUI_IO_OUTOFMEMORY (ERRCODE_AREA_UUI + 29) -#define ERRCODE_UUI_IO_PENDING (ERRCODE_AREA_UUI + 30) -#define ERRCODE_UUI_IO_RECURSIVE (ERRCODE_AREA_UUI + 31) -#define ERRCODE_UUI_IO_UNKNOWN (ERRCODE_AREA_UUI + 32) -#define ERRCODE_UUI_IO_WRITEPROTECTED (ERRCODE_AREA_UUI + 33) -#define ERRCODE_UUI_IO_WRONGFORMAT (ERRCODE_AREA_UUI + 34) -#define ERRCODE_UUI_IO_WRONGVERSION (ERRCODE_AREA_UUI + 35) -#define ERRCODE_UUI_IO_NOTEXISTS_VOLUME (ERRCODE_AREA_UUI + 36) -#define ERRCODE_UUI_IO_NOTEXISTS_FOLDER (ERRCODE_AREA_UUI + 37) -#define ERRCODE_UUI_WRONGJAVA (ERRCODE_AREA_UUI + 38) -#define ERRCODE_UUI_WRONGJAVA_VERSION (ERRCODE_AREA_UUI + 39) -#define ERRCODE_UUI_WRONGJAVA_MIN (ERRCODE_AREA_UUI + 40) -#define ERRCODE_UUI_WRONGJAVA_VERSION_MIN (ERRCODE_AREA_UUI + 41) -#define ERRCODE_UUI_BADPARTNERSHIP (ERRCODE_AREA_UUI + 42) -#define ERRCODE_UUI_BADPARTNERSHIP_NAME (ERRCODE_AREA_UUI + 43) -#define ERRCODE_UUI_IO_NOTREADY_VOLUME (ERRCODE_AREA_UUI + 44) -#define ERRCODE_UUI_IO_NOTREADY_REMOVABLE (ERRCODE_AREA_UUI + 45) -#define ERRCODE_UUI_IO_NOTREADY_VOLUME_REMOVABLE (ERRCODE_AREA_UUI + 46) -#define ERRCODE_UUI_WRONGMEDIUM (ERRCODE_AREA_UUI + 47) -#define ERRCODE_UUI_IO_CANTCREATE_NONAME (ERRCODE_AREA_UUI + 48) -#define ERRCODE_UUI_IO_TARGETALREADYEXISTS (ERRCODE_AREA_UUI + 49) -#define ERRCODE_UUI_IO_UNSUPPORTEDOVERWRITE (ERRCODE_AREA_UUI + 50) -#define ERRCODE_UUI_IO_BROKENPACKAGE (ERRCODE_AREA_UUI + 51) -#define ERRCODE_UUI_IO_BROKENPACKAGE_CANTREPAIR (ERRCODE_AREA_UUI + 52) -#define ERRCODE_UUI_CONFIGURATION_BROKENDATA_NOREMOVE (ERRCODE_AREA_UUI + 53) -#define ERRCODE_UUI_CONFIGURATION_BROKENDATA_WITHREMOVE (ERRCODE_AREA_UUI + 54) -#define ERRCODE_UUI_CONFIGURATION_BACKENDMISSING (ERRCODE_AREA_UUI + 55) -#define ERRCODE_UUI_CONFIGURATION_BACKENDMISSING_WITHRECOVER (ERRCODE_AREA_UUI + 56) -#define ERRCODE_UUI_INVALID_XFORMS_SUBMISSION_DATA (ERRCODE_AREA_UUI + 57) -#define ERRCODE_UUI_IO_MODULESIZEEXCEEDED (ERRCODE_AREA_UUI + 58) -#define ERRCODE_UUI_LOCKING_LOCKED (ERRCODE_AREA_UUI + 59) -#define ERRCODE_UUI_LOCKING_LOCKED_SELF (ERRCODE_AREA_UUI + 60) -#define ERRCODE_UUI_LOCKING_NOT_LOCKED (ERRCODE_AREA_UUI + 61) -#define ERRCODE_UUI_LOCKING_LOCK_EXPIRED (ERRCODE_AREA_UUI + 62) +#define ERRCODE_UUI_IO_ABORT (ERRCODE_AREA_UUI + 0) +#define ERRCODE_UUI_IO_ACCESSDENIED (ERRCODE_AREA_UUI + 1) +#define ERRCODE_UUI_IO_ALREADYEXISTS (ERRCODE_AREA_UUI + 2) +#define ERRCODE_UUI_IO_BADCRC (ERRCODE_AREA_UUI + 3) +#define ERRCODE_UUI_IO_CANTCREATE (ERRCODE_AREA_UUI + 4) +#define ERRCODE_UUI_IO_CANTREAD (ERRCODE_AREA_UUI + 5) +#define ERRCODE_UUI_IO_CANTSEEK (ERRCODE_AREA_UUI + 6) +#define ERRCODE_UUI_IO_CANTTELL (ERRCODE_AREA_UUI + 7) +#define ERRCODE_UUI_IO_CANTWRITE (ERRCODE_AREA_UUI + 8) +#define ERRCODE_UUI_IO_CURRENTDIR (ERRCODE_AREA_UUI + 9) +#define ERRCODE_UUI_IO_NOTREADY (ERRCODE_AREA_UUI + 10) +#define ERRCODE_UUI_IO_NOTSAMEDEVICE (ERRCODE_AREA_UUI + 11) +#define ERRCODE_UUI_IO_GENERAL (ERRCODE_AREA_UUI + 12) +#define ERRCODE_UUI_IO_INVALIDACCESS (ERRCODE_AREA_UUI + 13) +#define ERRCODE_UUI_IO_INVALIDCHAR (ERRCODE_AREA_UUI + 14) +#define ERRCODE_UUI_IO_INVALIDDEVICE (ERRCODE_AREA_UUI + 15) +#define ERRCODE_UUI_IO_INVALIDLENGTH (ERRCODE_AREA_UUI + 16) +#define ERRCODE_UUI_IO_INVALIDPARAMETER (ERRCODE_AREA_UUI + 17) +#define ERRCODE_UUI_IO_ISWILDCARD (ERRCODE_AREA_UUI + 18) +#define ERRCODE_UUI_IO_LOCKVIOLATION (ERRCODE_AREA_UUI + 19) +#define ERRCODE_UUI_IO_MISPLACEDCHAR (ERRCODE_AREA_UUI + 20) +#define ERRCODE_UUI_IO_NAMETOOLONG (ERRCODE_AREA_UUI + 21) +#define ERRCODE_UUI_IO_NOTEXISTS (ERRCODE_AREA_UUI + 22) +#define ERRCODE_UUI_IO_NOTEXISTSPATH (ERRCODE_AREA_UUI + 23) +#define ERRCODE_UUI_IO_NOTSUPPORTED (ERRCODE_AREA_UUI + 24) +#define ERRCODE_UUI_IO_NOTADIRECTORY (ERRCODE_AREA_UUI + 25) +#define ERRCODE_UUI_IO_NOTAFILE (ERRCODE_AREA_UUI + 26) +#define ERRCODE_UUI_IO_OUTOFSPACE (ERRCODE_AREA_UUI + 27) +#define ERRCODE_UUI_IO_TOOMANYOPENFILES (ERRCODE_AREA_UUI + 28) +#define ERRCODE_UUI_IO_OUTOFMEMORY (ERRCODE_AREA_UUI + 29) +#define ERRCODE_UUI_IO_PENDING (ERRCODE_AREA_UUI + 30) +#define ERRCODE_UUI_IO_RECURSIVE (ERRCODE_AREA_UUI + 31) +#define ERRCODE_UUI_IO_UNKNOWN (ERRCODE_AREA_UUI + 32) +#define ERRCODE_UUI_IO_WRITEPROTECTED (ERRCODE_AREA_UUI + 33) +#define ERRCODE_UUI_IO_WRONGFORMAT (ERRCODE_AREA_UUI + 34) +#define ERRCODE_UUI_IO_WRONGVERSION (ERRCODE_AREA_UUI + 35) +#define ERRCODE_UUI_IO_NOTEXISTS_VOLUME (ERRCODE_AREA_UUI + 36) +#define ERRCODE_UUI_IO_NOTEXISTS_FOLDER (ERRCODE_AREA_UUI + 37) +#define ERRCODE_UUI_WRONGJAVA (ERRCODE_AREA_UUI + 38) +#define ERRCODE_UUI_WRONGJAVA_VERSION (ERRCODE_AREA_UUI + 39) +#define ERRCODE_UUI_WRONGJAVA_MIN (ERRCODE_AREA_UUI + 40) +#define ERRCODE_UUI_WRONGJAVA_VERSION_MIN (ERRCODE_AREA_UUI + 41) +#define ERRCODE_UUI_BADPARTNERSHIP (ERRCODE_AREA_UUI + 42) +#define ERRCODE_UUI_BADPARTNERSHIP_NAME (ERRCODE_AREA_UUI + 43) +#define ERRCODE_UUI_IO_NOTREADY_VOLUME (ERRCODE_AREA_UUI + 44) +#define ERRCODE_UUI_IO_NOTREADY_REMOVABLE (ERRCODE_AREA_UUI + 45) +#define ERRCODE_UUI_IO_NOTREADY_VOLUME_REMOVABLE (ERRCODE_AREA_UUI + 46) +#define ERRCODE_UUI_WRONGMEDIUM (ERRCODE_AREA_UUI + 47) +#define ERRCODE_UUI_IO_CANTCREATE_NONAME (ERRCODE_AREA_UUI + 48) +#define ERRCODE_UUI_IO_TARGETALREADYEXISTS (ERRCODE_AREA_UUI + 49) +#define ERRCODE_UUI_IO_UNSUPPORTEDOVERWRITE (ERRCODE_AREA_UUI + 50) +#define ERRCODE_UUI_IO_BROKENPACKAGE (ERRCODE_AREA_UUI + 51) +#define ERRCODE_UUI_IO_BROKENPACKAGE_CANTREPAIR (ERRCODE_AREA_UUI + 52) +#define ERRCODE_UUI_CONFIGURATION_BROKENDATA_NOREMOVE (ERRCODE_AREA_UUI + 53) +#define ERRCODE_UUI_CONFIGURATION_BROKENDATA_WITHREMOVE (ERRCODE_AREA_UUI + 54) +#define ERRCODE_UUI_CONFIGURATION_BACKENDMISSING (ERRCODE_AREA_UUI + 55) +#define ERRCODE_UUI_CONFIGURATION_BACKENDMISSING_WITHRECOVER (ERRCODE_AREA_UUI + 56) +#define ERRCODE_UUI_INVALID_XFORMS_SUBMISSION_DATA (ERRCODE_AREA_UUI + 57) +#define ERRCODE_UUI_IO_MODULESIZEEXCEEDED (ERRCODE_AREA_UUI + 58) +#define ERRCODE_UUI_LOCKING_LOCKED (ERRCODE_AREA_UUI + 59) +#define ERRCODE_UUI_LOCKING_LOCKED_SELF (ERRCODE_AREA_UUI + 60) +#define ERRCODE_UUI_LOCKING_NOT_LOCKED (ERRCODE_AREA_UUI + 61) +#define ERRCODE_UUI_LOCKING_LOCK_EXPIRED (ERRCODE_AREA_UUI + 62) -#define ERRCODE_AREA_UUI_UNKNOWNAUTH 25000 -#define SSLWARN_TYPE_DOMAINMISMATCH 10 -#define SSLWARN_TYPE_EXPIRED 20 -#define SSLWARN_TYPE_INVALID 30 +#define ERRCODE_AREA_UUI_UNKNOWNAUTH 25000 +#define SSLWARN_TYPE_DOMAINMISMATCH 10 +#define SSLWARN_TYPE_EXPIRED 20 +#define SSLWARN_TYPE_INVALID 30 #define ERRCODE_UUI_UNKNOWNAUTH_UNTRUSTED (ERRCODE_AREA_UUI_UNKNOWNAUTH + 1) @@ -167,17 +170,17 @@ #define ERRCODE_UUI_SSLWARN_INVALID_1 (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 1) #define TITLE_UUI_SSLWARN_INVALID (ERRCODE_AREA_UUI_UNKNOWNAUTH + SSLWARN_TYPE_INVALID + 3) -#define HID_DLG_LOGIN (HID_UUI_START + 0) -#define HID_DLG_COOKIES (HID_UUI_START + 1) -#define HID_DLG_MASTERPASSWORD_UUI (HID_UUI_START+2) -#define HID_DLG_MASTERPASSWORD_CRT (HID_UUI_START+3) -#define HID_DLG_FILTER_SELECT (HID_UUI_START+4) -#define HID_DLG_PASSWORD_UUI (HID_UUI_START+5) -#define HID_DLG_PASSWORD_CRT (HID_UUI_START+6) -#define HID_DLG_UNKNOWNAUTH_UUI (HID_UUI_START+7) -#define HID_DLG_SSLWARN_UUI (HID_UUI_START+8) -#define HID_XMLSECDLG_MACROWARN (HID_UUI_START+9) -#define HID_DLG_NEWERVERSIONWARNING (HID_UUI_START+10) +#define HID_DLG_LOGIN (HID_UUI_START + 0) +#define HID_DLG_COOKIES (HID_UUI_START + 1) +#define HID_DLG_MASTERPASSWORD_UUI (HID_UUI_START + 2) +#define HID_DLG_MASTERPASSWORD_CRT (HID_UUI_START + 3) +#define HID_DLG_FILTER_SELECT (HID_UUI_START + 4) +#define HID_DLG_PASSWORD_UUI (HID_UUI_START + 5) +#define HID_DLG_PASSWORD_CRT (HID_UUI_START + 6) +#define HID_DLG_UNKNOWNAUTH_UUI (HID_UUI_START + 7) +#define HID_DLG_SSLWARN_UUI (HID_UUI_START + 8) +#define HID_XMLSECDLG_MACROWARN (HID_UUI_START + 9) +#define HID_DLG_NEWERVERSIONWARNING (HID_UUI_START +10) // HID_UUI_END (aka HID_CHAOS_NEW_DATABASE) is reserved in // sfx2/util/hidother.src diff --git a/uui/source/loginerr.hxx b/uui/source/loginerr.hxx index 39e5b81caf85..73d61bea359f 100644..100755 --- a/uui/source/loginerr.hxx +++ b/uui/source/loginerr.hxx @@ -25,8 +25,8 @@ * ************************************************************************/ -#ifndef _LOGINERR_HXX -#define _LOGINERR_HXX +#ifndef m_LOGINERR_HXX +#define m_LOGINERR_HXX #include <tools/string.hxx> @@ -43,61 +43,66 @@ class LoginErrorInfo { private: - String _aTitle; - String _aServer; - String _aAccount; - String _aUserName; - String _aPassword; - String _aPath; - String _aErrorText; - BYTE _nFlags; - USHORT _nRet; + String m_aTitle; + String m_aServer; + String m_aAccount; + String m_aUserName; + String m_aPassword; + String m_aPasswordToModify; + String m_aPath; + String m_aErrorText; + BYTE m_nFlags; + USHORT m_nRet; + bool m_bRecommendToOpenReadonly; public: LoginErrorInfo() - : _nFlags( LOGINERROR_FLAG_MODIFY_USER_NAME ), - _nRet( ERRCODE_BUTTON_CANCEL ) - {} - - const String& GetTitle() const { return _aTitle; } - const String& GetServer() const { return _aServer; } - const String& GetAccount() const { return _aAccount; } - const String& GetUserName() const { return _aUserName; } - const String& GetPassword() const { return _aPassword; } - const String& GetPath() const { return _aPath; } - const String& GetErrorText() const { return _aErrorText; } - - BOOL GetCanRememberPassword() const - { return ( _nFlags & LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD ); } - BOOL GetIsRememberPersistent() const - { return ( _nFlags & LOGINERROR_FLAG_REMEMBER_PERSISTENT ); } - BOOL GetIsRememberPassword() const - { return ( _nFlags & LOGINERROR_FLAG_IS_REMEMBER_PASSWORD ); } + : m_nFlags( LOGINERROR_FLAG_MODIFY_USER_NAME ), + m_nRet( ERRCODE_BUTTON_CANCEL ) + { + } + + const String& GetTitle() const { return m_aTitle; } + const String& GetServer() const { return m_aServer; } + const String& GetAccount() const { return m_aAccount; } + const String& GetUserName() const { return m_aUserName; } + const String& GetPassword() const { return m_aPassword; } + const String& GetPasswordToModify() const { return m_aPasswordToModify; } + const bool IsRecommendToOpenReadonly() const { return m_bRecommendToOpenReadonly; } + const String& GetPath() const { return m_aPath; } + const String& GetErrorText() const { return m_aErrorText; } + BOOL GetCanRememberPassword() const { return ( m_nFlags & LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD ); } + BOOL GetIsRememberPersistent() const { return ( m_nFlags & LOGINERROR_FLAG_REMEMBER_PERSISTENT ); } + BOOL GetIsRememberPassword() const { return ( m_nFlags & LOGINERROR_FLAG_IS_REMEMBER_PASSWORD ); } BOOL GetCanUseSystemCredentials() const - { return ( _nFlags & LOGINERROR_FLAG_CAN_USE_SYSCREDS ); } + { return ( m_nFlags & LOGINERROR_FLAG_CAN_USE_SYSCREDS ); } BOOL GetIsUseSystemCredentials() const - { return ( _nFlags & LOGINERROR_FLAG_IS_USE_SYSCREDS ) == + { return ( m_nFlags & LOGINERROR_FLAG_IS_USE_SYSCREDS ) == LOGINERROR_FLAG_IS_USE_SYSCREDS; } - BYTE GetFlags() const { return _nFlags; } - USHORT GetResult() const { return _nRet; } + BYTE GetFlags() const { return m_nFlags; } + USHORT GetResult() const { return m_nRet; } void SetTitle( const String& aTitle ) - { _aTitle = aTitle; } + { m_aTitle = aTitle; } void SetServer( const String& aServer ) - { _aServer = aServer; } + { m_aServer = aServer; } void SetAccount( const String& aAccount ) - { _aAccount = aAccount; } + { m_aAccount = aAccount; } void SetUserName( const String& aUserName ) - { _aUserName = aUserName; } + { m_aUserName = aUserName; } void SetPassword( const String& aPassword ) - { _aPassword = aPassword; } + { m_aPassword = aPassword; } + void SetPasswordToModify( const String& aPassword ) + { m_aPasswordToModify = aPassword; } + void SetRecommendToOpenReadonly( bool bVal ) + { m_bRecommendToOpenReadonly = bVal; } void SetPath( const String& aPath ) - { _aPath = aPath; } + { m_aPath = aPath; } void SetErrorText( const String& aErrorText ) - { _aErrorText = aErrorText; } + { m_aErrorText = aErrorText; } void SetFlags( BYTE nFlags ) - { _nFlags = nFlags; } + { m_nFlags = nFlags; } inline void SetCanRememberPassword( BOOL bSet ); inline void SetIsRememberPassword( BOOL bSet ); @@ -107,64 +112,67 @@ public: inline void SetIsUseSystemCredentials( BOOL bSet ); inline void SetModifyAccount( BOOL bSet ); inline void SetModifyUserName( BOOL bSet ); + void SetResult( USHORT nRet ) - { _nRet = nRet; } + { m_nRet = nRet; } }; inline void LoginErrorInfo::SetCanRememberPassword( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD; + m_nFlags |= LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD; else - _nFlags &= ~LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD; + m_nFlags &= ~LOGINERROR_FLAG_CAN_REMEMBER_PASSWORD; } inline void LoginErrorInfo::SetIsRememberPassword( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_IS_REMEMBER_PASSWORD; + m_nFlags |= LOGINERROR_FLAG_IS_REMEMBER_PASSWORD; else - _nFlags &= ~LOGINERROR_FLAG_IS_REMEMBER_PASSWORD; + m_nFlags &= ~LOGINERROR_FLAG_IS_REMEMBER_PASSWORD; } inline void LoginErrorInfo::SetIsRememberPersistent( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_REMEMBER_PERSISTENT; + m_nFlags |= LOGINERROR_FLAG_REMEMBER_PERSISTENT; else - _nFlags &= ~LOGINERROR_FLAG_REMEMBER_PERSISTENT; + m_nFlags &= ~LOGINERROR_FLAG_REMEMBER_PERSISTENT; } inline void LoginErrorInfo::SetCanUseSystemCredentials( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_CAN_USE_SYSCREDS; + m_nFlags |= LOGINERROR_FLAG_CAN_USE_SYSCREDS; else - _nFlags &= ~LOGINERROR_FLAG_CAN_USE_SYSCREDS; + m_nFlags &= ~LOGINERROR_FLAG_CAN_USE_SYSCREDS; } inline void LoginErrorInfo::SetIsUseSystemCredentials( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_IS_USE_SYSCREDS; + m_nFlags |= LOGINERROR_FLAG_IS_USE_SYSCREDS; else - _nFlags &= ~LOGINERROR_FLAG_IS_USE_SYSCREDS; + m_nFlags &= ~LOGINERROR_FLAG_IS_USE_SYSCREDS; } inline void LoginErrorInfo::SetModifyAccount( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_MODIFY_ACCOUNT; + m_nFlags |= LOGINERROR_FLAG_MODIFY_ACCOUNT; else - _nFlags &= ~LOGINERROR_FLAG_MODIFY_ACCOUNT; + m_nFlags &= ~LOGINERROR_FLAG_MODIFY_ACCOUNT; } inline void LoginErrorInfo::SetModifyUserName( BOOL bSet ) { if ( bSet ) - _nFlags |= LOGINERROR_FLAG_MODIFY_USER_NAME; + m_nFlags |= LOGINERROR_FLAG_MODIFY_USER_NAME; else - _nFlags &= ~LOGINERROR_FLAG_MODIFY_USER_NAME; + m_nFlags &= ~LOGINERROR_FLAG_MODIFY_USER_NAME; } #endif + + diff --git a/uui/source/passworddlg.cxx b/uui/source/passworddlg.cxx index 4962563601c3..c89184f54bc1 100644..100755 --- a/uui/source/passworddlg.cxx +++ b/uui/source/passworddlg.cxx @@ -48,30 +48,34 @@ IMPL_LINK( PasswordDialog, OKHdl_Impl, OKButton *, EMPTYARG ) // ----------------------------------------------------------------------- -PasswordDialog::PasswordDialog -( +PasswordDialog::PasswordDialog( Window* _pParent, ::com::sun::star::task::PasswordRequestMode nDlgMode, ResMgr * pResMgr, - rtl::OUString& aDocURL - ) + rtl::OUString& aDocURL, + bool bOpenToModify ) + :ModalDialog( _pParent, ResId( DLG_UUI_PASSWORD, *pResMgr ) ) - ,aFTPassword ( this, ResId( FT_PASSWORD, *pResMgr ) ) - ,aEDPassword ( this, ResId( ED_PASSWORD, *pResMgr ) ) - ,aOKBtn ( this, ResId( BTN_PASSWORD_OK, *pResMgr ) ) - ,aCancelBtn ( this, ResId( BTN_PASSWORD_CANCEL, *pResMgr ) ) - ,aHelpBtn ( this, ResId( BTN_PASSWORD_HELP, *pResMgr ) ) - ,aFixedLine1 ( this, ResId( FL_FIXED_LINE_1, *pResMgr ) ) - ,nDialogMode ( nDlgMode ) - ,pResourceMgr ( pResMgr ) + ,aFTPassword( this, ResId( FT_PASSWORD, *pResMgr )) + ,aEDPassword( this, ResId( ED_PASSWORD, *pResMgr )) + ,aOKBtn ( this, ResId( BTN_PASSWORD_OK, *pResMgr )) + ,aCancelBtn ( this, ResId( BTN_PASSWORD_CANCEL, *pResMgr )) + ,aHelpBtn ( this, ResId( BTN_PASSWORD_HELP, *pResMgr )) + ,aFixedLine1( this, ResId( FL_FIXED_LINE_1, *pResMgr )) + ,nDialogMode( nDlgMode ) + ,pResourceMgr ( pResMgr ) { if( nDialogMode == ::com::sun::star::task::PasswordRequestMode_PASSWORD_REENTER ) { - String aErrorMsg( ResId( STR_ERROR_PASSWORD_WRONG, *pResourceMgr )); + USHORT nErrStrId = bOpenToModify ? STR_ERROR_PASSWORD_TO_MODIFY_WRONG : STR_ERROR_PASSWORD_TO_OPEN_WRONG; + String aErrorMsg( ResId( nErrStrId, *pResourceMgr )); ErrorBox aErrorBox( _pParent, WB_OK, aErrorMsg ); aErrorBox.Execute(); } + USHORT nStrId = bOpenToModify ? STR_ENTER_PASSWORD_TO_MODIFY : STR_ENTER_PASSWORD_TO_OPEN; + aFTPassword.SetText( String( ResId( nStrId, *pResourceMgr ) ) ); + FreeResource(); aFTPassword.SetText( aFTPassword.GetText() + aDocURL ); diff --git a/uui/source/passworddlg.hxx b/uui/source/passworddlg.hxx index d07399012616..fe5fe7f2ef84 100644..100755 --- a/uui/source/passworddlg.hxx +++ b/uui/source/passworddlg.hxx @@ -50,7 +50,7 @@ class PasswordDialog : public ModalDialog DECL_LINK( OKHdl_Impl, OKButton * ); public: - PasswordDialog( Window* pParent, ::com::sun::star::task::PasswordRequestMode nDlgMode, ResMgr * pResMgr, ::rtl::OUString& aDocURL ); + PasswordDialog( Window* pParent, ::com::sun::star::task::PasswordRequestMode nDlgMode, ResMgr * pResMgr, ::rtl::OUString& aDocURL, bool bOpenToModify = false ); String GetPassword() const { return aEDPassword.GetText(); } diff --git a/uui/source/passworddlg.src b/uui/source/passworddlg.src index 96863ad9ca32..33767057e1bd 100644..100755 --- a/uui/source/passworddlg.src +++ b/uui/source/passworddlg.src @@ -41,27 +41,33 @@ ModalDialog DLG_UUI_PASSWORD Moveable = TRUE ; OutputSize = TRUE ; SVLook = TRUE ; - Size = MAP_APPFONT( 145, 75 ); + Size = MAP_APPFONT( 145, 91 ); Text [ en-US ] = "Enter password"; + FixedText FT_PASSWORD { Pos = MAP_APPFONT( 3, 4 ); Size = MAP_APPFONT( 139, 28 ); - Text [ en-US ] = "Enter password to open file: \n"; WordBreak = TRUE; }; Edit ED_PASSWORD { - Pos = MAP_APPFONT( 3, 35 ); + Pos = MAP_APPFONT( 3, 51 ); Size = MAP_APPFONT( 139, 13 ); Border = TRUE ; PassWord = TRUE ; }; + FixedLine FL_FIXED_LINE_1 + { + Pos = MAP_APPFONT( 0, 66 ); + Size = MAP_APPFONT( 145, 6 ); + }; + OKButton BTN_PASSWORD_OK { - Pos = MAP_APPFONT( 27, 56 ); + Pos = MAP_APPFONT( 27, 72 ); Size = MAP_APPFONT( 37, 15 ); DefButton = TRUE ; DefButton = TRUE; @@ -69,20 +75,24 @@ ModalDialog DLG_UUI_PASSWORD CancelButton BTN_PASSWORD_CANCEL { - Pos = MAP_APPFONT( 66, 56 ); + Pos = MAP_APPFONT( 66, 72 ); Size = MAP_APPFONT( 37, 15 ); }; HelpButton BTN_PASSWORD_HELP { - Pos = MAP_APPFONT( 105, 56 ); + Pos = MAP_APPFONT( 105, 72 ); Size = MAP_APPFONT( 37, 15 ); }; - FixedLine FL_FIXED_LINE_1 + String STR_ENTER_PASSWORD_TO_OPEN { - Pos = MAP_APPFONT( 0, 50 ); - Size = MAP_APPFONT( 145, 6 ); + Text [ en-US ] = "Enter password to open file: \n"; + }; + + String STR_ENTER_PASSWORD_TO_MODIFY + { + Text [ en-US ] = "Enter password to modify file: \n"; }; }; diff --git a/uui/source/passworderrs.src b/uui/source/passworderrs.src index fe631257c9d2..91b244ae543e 100644..100755 --- a/uui/source/passworderrs.src +++ b/uui/source/passworderrs.src @@ -31,9 +31,14 @@ #include <ids.hrc> #endif -String STR_ERROR_PASSWORD_WRONG +String STR_ERROR_PASSWORD_TO_OPEN_WRONG { - Text [ en-US ] = "The password is incorrect. The document cannot be opened."; + Text [ en-US ] = "The password is incorrect. The file cannot be opened."; +}; + +String STR_ERROR_PASSWORD_TO_MODIFY_WRONG +{ + Text [ en-US ] = "The password is incorrect. The file cannot be modified."; }; String STR_ERROR_MASTERPASSWORD_WRONG |