From f6cd982a68528ac1bfd130080cea3f96e6cc7edd Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Fri, 21 Mar 2014 09:46:40 +0000 Subject: move the cups password dialog from padmin to vcl now we don't have to dlopen padmin to get it so we can drop that complicated stuff. Change-Id: I2f01bd104aae8f17ada9a445da653b441a927c70 --- padmin/UIConfig_spa.mk | 1 - padmin/source/prtsetup.cxx | 52 ----------- padmin/uiconfig/ui/cupspassworddialog.ui | 155 ------------------------------- vcl/UIConfig_vcl.mk | 1 + vcl/uiconfig/ui/cupspassworddialog.ui | 155 +++++++++++++++++++++++++++++++ vcl/unx/generic/printer/cupsmgr.cxx | 92 +++++++++++++----- 6 files changed, 224 insertions(+), 232 deletions(-) delete mode 100644 padmin/uiconfig/ui/cupspassworddialog.ui create mode 100644 vcl/uiconfig/ui/cupspassworddialog.ui diff --git a/padmin/UIConfig_spa.mk b/padmin/UIConfig_spa.mk index 242b30523646..565f0cc57536 100644 --- a/padmin/UIConfig_spa.mk +++ b/padmin/UIConfig_spa.mk @@ -10,7 +10,6 @@ $(eval $(call gb_UIConfig_UIConfig,spa)) $(eval $(call gb_UIConfig_add_uifiles,spa,\ - padmin/uiconfig/ui/cupspassworddialog \ padmin/uiconfig/ui/printerdevicepage \ padmin/uiconfig/ui/printerpaperpage \ padmin/uiconfig/ui/printerpropertiesdialog \ diff --git a/padmin/source/prtsetup.cxx b/padmin/source/prtsetup.cxx index 38494d55fe96..938e00b32356 100644 --- a/padmin/source/prtsetup.cxx +++ b/padmin/source/prtsetup.cxx @@ -472,43 +472,6 @@ void RTSDevicePage::FillValueBox( const PPDKey* pKey ) m_pPPDValueBox->SelectEntryPos( m_pPPDValueBox->GetEntryPos( (void*)pValue ) ); } -class RTSPWDialog : public ModalDialog -{ - FixedText* m_pText; - Edit* m_pUserEdit; - Edit* m_pPassEdit; - -public: - RTSPWDialog(const OString& rServer, const OString& rUserName, Window* pParent); - - OString getUserName() const; - OString getPassword() const; -}; - -RTSPWDialog::RTSPWDialog( const OString& rServer, const OString& rUserName, Window* pParent ) - : ModalDialog(pParent, "CUPSPasswordDialog", - "spa/ui/cupspassworddialog.ui") -{ - get(m_pText, "text"); - get(m_pUserEdit, "user"); - get(m_pPassEdit, "pass"); - - OUString aText(m_pText->GetText()); - aText = aText.replaceFirst("%s", OStringToOUString(rServer, osl_getThreadTextEncoding())); - m_pText->SetText(aText); - m_pUserEdit->SetText( OStringToOUString(rUserName, osl_getThreadTextEncoding())); -} - -OString RTSPWDialog::getUserName() const -{ - return OUStringToOString( m_pUserEdit->GetText(), osl_getThreadTextEncoding() ); -} - -OString RTSPWDialog::getPassword() const -{ - return OUStringToOString( m_pPassEdit->GetText(), osl_getThreadTextEncoding() ); -} - extern "C" { int SPA_DLLPUBLIC Sal_SetupPrinterDriver( ::psp::PrinterInfo& rJobData ) @@ -524,21 +487,6 @@ extern "C" { return nRet; } - - bool SPA_DLLPUBLIC Sal_authenticateQuery( const OString& rServer, OString& rUserName, OString& rPassword ) - { - bool bRet = false; - - RTSPWDialog aDialog( rServer, rUserName, NULL ); - if( aDialog.Execute() ) - { - rUserName = aDialog.getUserName(); - rPassword = aDialog.getPassword(); - bRet = true; - } - return bRet; - } - } // extern "C" /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/padmin/uiconfig/ui/cupspassworddialog.ui b/padmin/uiconfig/ui/cupspassworddialog.ui deleted file mode 100644 index 81f80e8d3665..000000000000 --- a/padmin/uiconfig/ui/cupspassworddialog.ui +++ /dev/null @@ -1,155 +0,0 @@ - - - - - - False - 6 - Authentication request - normal - - - False - vertical - 12 - - - False - end - - - gtk-ok - True - True - True - True - True - True - - - False - True - 0 - - - - - gtk-cancel - True - True - True - True - - - False - True - 1 - - - - - False - True - end - 0 - - - - - True - False - True - True - 6 - 12 - - - True - False - 0 - _User - True - user - - - 0 - 1 - 1 - 1 - - - - - True - False - 0 - _Password - True - pass - - - 0 - 2 - 1 - 1 - - - - - True - False - 0 - Please enter your authentication data for server %s - True - True - 56 - - - 0 - 0 - 2 - 1 - - - - - True - True - True - - - 1 - 1 - 1 - 1 - - - - - True - True - True - False - - - 1 - 2 - 1 - 1 - - - - - False - True - 1 - - - - - - ok - cancel - - - diff --git a/vcl/UIConfig_vcl.mk b/vcl/UIConfig_vcl.mk index bdc028e3137d..f2937b531e49 100644 --- a/vcl/UIConfig_vcl.mk +++ b/vcl/UIConfig_vcl.mk @@ -10,6 +10,7 @@ $(eval $(call gb_UIConfig_UIConfig,vcl)) $(eval $(call gb_UIConfig_add_uifiles,vcl,\ + vcl/uiconfig/ui/cupspassworddialog \ vcl/uiconfig/ui/errornocontentdialog \ vcl/uiconfig/ui/errornoprinterdialog \ vcl/uiconfig/ui/printdialog \ diff --git a/vcl/uiconfig/ui/cupspassworddialog.ui b/vcl/uiconfig/ui/cupspassworddialog.ui new file mode 100644 index 000000000000..81f80e8d3665 --- /dev/null +++ b/vcl/uiconfig/ui/cupspassworddialog.ui @@ -0,0 +1,155 @@ + + + + + + False + 6 + Authentication request + normal + + + False + vertical + 12 + + + False + end + + + gtk-ok + True + True + True + True + True + True + + + False + True + 0 + + + + + gtk-cancel + True + True + True + True + + + False + True + 1 + + + + + False + True + end + 0 + + + + + True + False + True + True + 6 + 12 + + + True + False + 0 + _User + True + user + + + 0 + 1 + 1 + 1 + + + + + True + False + 0 + _Password + True + pass + + + 0 + 2 + 1 + 1 + + + + + True + False + 0 + Please enter your authentication data for server %s + True + True + 56 + + + 0 + 0 + 2 + 1 + + + + + True + True + True + + + 1 + 1 + 1 + 1 + + + + + True + True + True + False + + + 1 + 2 + 1 + 1 + + + + + False + True + 1 + + + + + + ok + cancel + + + diff --git a/vcl/unx/generic/printer/cupsmgr.cxx b/vcl/unx/generic/printer/cupsmgr.cxx index 9c7af07c020e..b9e5af03bb19 100644 --- a/vcl/unx/generic/printer/cupsmgr.cxx +++ b/vcl/unx/generic/printer/cupsmgr.cxx @@ -35,6 +35,10 @@ #include +#include +#include +#include + #include using namespace psp; @@ -827,36 +831,76 @@ bool CUPSManager::writePrinterConfig() return PrinterInfoManager::writePrinterConfig(); } -const char* CUPSManager::authenticateUser( const char* /*pIn*/ ) +namespace { - const char* pRet = NULL; - oslModule pLib = osl_loadModuleAscii( _XSALSET_LIBNAME, SAL_LOADMODULE_LAZY ); - if( pLib ) + class RTSPWDialog : public ModalDialog { - OUString aSym( "Sal_authenticateQuery" ); - bool (*getpw)( const OString& rServer, OString& rUser, OString& rPw) = - (bool(*)(const OString&,OString&,OString&))osl_getFunctionSymbol( pLib, aSym.pData ); - if( getpw ) - { - osl::MutexGuard aGuard( m_aCUPSMutex ); + FixedText* m_pText; + Edit* m_pUserEdit; + Edit* m_pPassEdit; - OString aUser = cupsUser(); - OString aServer = cupsServer(); - OString aPassword; - if( getpw( aServer, aUser, aPassword ) ) - { - m_aPassword = aPassword; - m_aUser = aUser; - cupsSetUser( m_aUser.getStr() ); - pRet = m_aPassword.getStr(); - } + public: + RTSPWDialog(const OString& rServer, const OString& rUserName, Window* pParent); + + OString getUserName() const; + OString getPassword() const; + }; + + RTSPWDialog::RTSPWDialog( const OString& rServer, const OString& rUserName, Window* pParent ) + : ModalDialog(pParent, "CUPSPasswordDialog", + "vcl/ui/cupspassworddialog.ui") + { + get(m_pText, "text"); + get(m_pUserEdit, "user"); + get(m_pPassEdit, "pass"); + + OUString aText(m_pText->GetText()); + aText = aText.replaceFirst("%s", OStringToOUString(rServer, osl_getThreadTextEncoding())); + m_pText->SetText(aText); + m_pUserEdit->SetText( OStringToOUString(rUserName, osl_getThreadTextEncoding())); + } + + OString RTSPWDialog::getUserName() const + { + return OUStringToOString( m_pUserEdit->GetText(), osl_getThreadTextEncoding() ); + } + + OString RTSPWDialog::getPassword() const + { + return OUStringToOString( m_pPassEdit->GetText(), osl_getThreadTextEncoding() ); + } + + bool AuthenticateQuery(const OString& rServer, OString& rUserName, OString& rPassword) + { + bool bRet = false; + + RTSPWDialog aDialog(rServer, rUserName, NULL); + if (aDialog.Execute()) + { + rUserName = aDialog.getUserName(); + rPassword = aDialog.getPassword(); + bRet = true; } - osl_unloadModule( pLib ); + + return bRet; } - else +} + +const char* CUPSManager::authenticateUser( const char* /*pIn*/ ) +{ + const char* pRet = NULL; + + osl::MutexGuard aGuard( m_aCUPSMutex ); + + OString aUser = cupsUser(); + OString aServer = cupsServer(); + OString aPassword; + if (AuthenticateQuery(aServer, aUser, aPassword)) { - SAL_WARN("vcl.unx.print", - "loading of module " << _XSALSET_LIBNAME << " failed\n"); + m_aPassword = aPassword; + m_aUser = aUser; + cupsSetUser( m_aUser.getStr() ); + pRet = m_aPassword.getStr(); } return pRet; -- cgit