diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-04-25 17:18:44 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-04-25 17:27:08 +0200 |
commit | 7d25cd63b1460b5fefee0e6be3a6bf093dac3ebf (patch) | |
tree | 47fd289cc6cab20edb4b30248653189902127ee6 /desktop | |
parent | fb68711fc3fbab99e47cc94f5abd27b1425bc468 (diff) |
Proper handling of multiple --accept arguments
...and some further clean up of needlessly complex class CommandLineArgs.
Diffstat (limited to 'desktop')
-rw-r--r-- | desktop/source/app/app.cxx | 2 | ||||
-rw-r--r-- | desktop/source/app/appinit.cxx | 24 | ||||
-rw-r--r-- | desktop/source/app/cmdlineargs.cxx | 91 | ||||
-rw-r--r-- | desktop/source/app/cmdlineargs.hxx | 19 | ||||
-rw-r--r-- | desktop/source/app/officeipcthread.cxx | 19 |
5 files changed, 53 insertions, 102 deletions
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx index 5d299e125526..95894ae9a5aa 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -2970,7 +2970,7 @@ void Desktop::OpenSplashScreen() // Which splash to use OUString aSplashService( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.office.SplashScreen" )); - if ( !rCmdLine.GetStringParam( CommandLineArgs::CMD_STRINGPARAM_SPLASHPIPE ).isEmpty() ) + if ( !rCmdLine.GetSplashPipe().isEmpty() ) aSplashService = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.office.PipeSplashScreen")); bVisible = sal_True; diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index 4c27e53ca983..4dfb785277a6 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -217,30 +217,28 @@ void Desktop::RegisterServices( Reference< XMultiServiceFactory >& xSMgr ) RTL_LOGFILE_CONTEXT( aLog, "desktop (cd100003) ::registerServices" ); // read command line parameters - ::rtl::OUString conDcp; ::rtl::OUString aClientDisplay; - ::rtl::OUString aTmpString; sal_Bool bHeadlessMode = sal_False; // interpret command line arguments CommandLineArgs& rCmdLine = GetCommandLineArgs(); - // read accept string from configuration - conDcp = SvtStartOptions().GetConnectionURL(); - - if ( rCmdLine.GetAcceptString( aTmpString )) - conDcp = aTmpString; - // Headless mode for FAT Office bHeadlessMode = rCmdLine.IsHeadless(); if ( bHeadlessMode ) Application::EnableHeadlessMode(false); - if ( !conDcp.isEmpty() ) + // read accept string from configuration + rtl::OUString conDcpCfg(SvtStartOptions().GetConnectionURL()); + if (!conDcpCfg.isEmpty()) { + createAcceptor(conDcpCfg); + } + + std::vector< ::rtl::OUString > const & conDcp = rCmdLine.GetAccept(); + for (std::vector< ::rtl::OUString >::const_iterator i(conDcp.begin()); + i != conDcp.end(); ++i) { - // accept incoming connections (scripting and one rvp) - RTL_LOGFILE_CONTEXT( aLog, "desktop (lo119109) desktop::Desktop::createAcceptor()" ); - createAcceptor(conDcp); + createAcceptor(*i); } // improves parallel processing on Sun ONE Webtop @@ -257,7 +255,7 @@ void Desktop::RegisterServices( Reference< XMultiServiceFactory >& xSMgr ) if ( !rEnum.is() ) { // Reset server parameter so it is ignored in the furthermore startup process - rCmdLine.SetBoolParam( CommandLineArgs::CMD_BOOLPARAM_SERVER, sal_False ); + rCmdLine.ClearServer(); } } } diff --git a/desktop/source/app/cmdlineargs.cxx b/desktop/source/app/cmdlineargs.cxx index 60d40af145c1..9ffac20d9ee0 100644 --- a/desktop/source/app/cmdlineargs.cxx +++ b/desktop/source/app/cmdlineargs.cxx @@ -118,14 +118,14 @@ CommandLineArgs::Supplier::~Supplier() {} // intialize class with command line parameters from process environment CommandLineArgs::CommandLineArgs() { - ResetParamValues(); + InitParamValues(); ExtCommandLineSupplier s; ParseCommandLine_Impl( s ); } CommandLineArgs::CommandLineArgs( Supplier& supplier ) { - ResetParamValues(); + InitParamValues(); ParseCommandLine_Impl( supplier ); } @@ -465,7 +465,7 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& } else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "server" )) == sal_True ) { - SetBoolParam_Impl( CMD_BOOLPARAM_SERVER, sal_True ); + m_server = true; } else if ( oArg.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "headless" )) == sal_True ) { @@ -563,11 +563,11 @@ sal_Bool CommandLineArgs::InterpretCommandLineParameter( const ::rtl::OUString& } else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("accept="))) { - AddStringListParam_Impl( CMD_STRINGPARAM_ACCEPT, oArg.copy(RTL_CONSTASCII_LENGTH("accept=")) ); + m_accept.push_back(oArg.copy(RTL_CONSTASCII_LENGTH("accept="))); } else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("unaccept="))) { - AddStringListParam_Impl( CMD_STRINGPARAM_UNACCEPT, oArg.copy(RTL_CONSTASCII_LENGTH("unaccept=")) ); + m_unaccept.push_back(oArg.copy(RTL_CONSTASCII_LENGTH("unaccept="))); } else if ( oArg.matchIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("portal,"))) { @@ -676,7 +676,7 @@ sal_Bool CommandLineArgs::CheckGroupMembers( GroupParamId nGroupId, BoolParam nE return sal_False; } -void CommandLineArgs::ResetParamValues() +void CommandLineArgs::InitParamValues() { int i; for ( i = 0; i < CMD_BOOLPARAM_COUNT; i++ ) @@ -685,321 +685,268 @@ void CommandLineArgs::ResetParamValues() m_aStrSetParams[i] = sal_False; m_eArgumentCount = NONE; m_bDocumentArgs = false; + m_server = false; } -void CommandLineArgs::SetBoolParam( BoolParam eParam, sal_Bool bNewValue ) +void CommandLineArgs::ClearServer() { osl::MutexGuard aMutexGuard( m_aMutex ); - - OSL_ASSERT( ( eParam >= 0 && eParam < CMD_BOOLPARAM_COUNT ) ); - m_aBoolParams[eParam] = bNewValue; -} - -const rtl::OUString& CommandLineArgs::GetStringParam( StringParam eParam ) const -{ - osl::MutexGuard aMutexGuard( m_aMutex ); - - OSL_ASSERT( ( eParam >= 0 && eParam < CMD_STRINGPARAM_COUNT ) ); - return m_aStrParams[eParam]; + m_server = false; } sal_Bool CommandLineArgs::IsMinimized() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_MINIMIZED ]; } sal_Bool CommandLineArgs::IsInvisible() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_INVISIBLE ]; } sal_Bool CommandLineArgs::IsNoRestore() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_NORESTORE ]; } sal_Bool CommandLineArgs::IsNoDefault() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_NODEFAULT ]; } sal_Bool CommandLineArgs::IsServer() const { osl::MutexGuard aMutexGuard( m_aMutex ); - return m_aBoolParams[ CMD_BOOLPARAM_SERVER ]; + return m_server; } sal_Bool CommandLineArgs::IsHeadless() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_HEADLESS ]; } sal_Bool CommandLineArgs::IsQuickstart() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_QUICKSTART ]; } sal_Bool CommandLineArgs::IsNoQuickstart() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_NOQUICKSTART ]; } sal_Bool CommandLineArgs::IsTerminateAfterInit() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_TERMINATEAFTERINIT ]; } sal_Bool CommandLineArgs::IsNoLogo() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_NOLOGO ]; } sal_Bool CommandLineArgs::IsNoLockcheck() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_NOLOCKCHECK ]; } sal_Bool CommandLineArgs::IsHelp() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_HELP ]; } sal_Bool CommandLineArgs::IsHelpWriter() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_HELPWRITER ]; } sal_Bool CommandLineArgs::IsHelpCalc() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_HELPCALC ]; } sal_Bool CommandLineArgs::IsHelpDraw() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_HELPDRAW ]; } sal_Bool CommandLineArgs::IsHelpImpress() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_HELPIMPRESS ]; } sal_Bool CommandLineArgs::IsHelpBase() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_HELPBASE ]; } sal_Bool CommandLineArgs::IsHelpMath() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_HELPMATH ]; } sal_Bool CommandLineArgs::IsHelpBasic() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_HELPBASIC ]; } sal_Bool CommandLineArgs::IsWriter() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_WRITER ]; } sal_Bool CommandLineArgs::IsCalc() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_CALC ]; } sal_Bool CommandLineArgs::IsDraw() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_DRAW ]; } sal_Bool CommandLineArgs::IsImpress() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_IMPRESS ]; } sal_Bool CommandLineArgs::IsBase() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_BASE ]; } sal_Bool CommandLineArgs::IsGlobal() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_GLOBAL ]; } sal_Bool CommandLineArgs::IsMath() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_MATH ]; } sal_Bool CommandLineArgs::IsWeb() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_WEB ]; } sal_Bool CommandLineArgs::IsVersion() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_VERSION ]; } sal_Bool CommandLineArgs::HasUnknown() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_aBoolParams[ CMD_BOOLPARAM_UNKNOWN ]; } sal_Bool CommandLineArgs::HasModuleParam() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return CheckGroupMembers( CMD_GRPID_MODULE, CMD_BOOLPARAM_COUNT ); } sal_Bool CommandLineArgs::GetPortalConnectString( ::rtl::OUString& rPara ) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_PORTAL ]; return m_aStrSetParams[ CMD_STRINGPARAM_PORTAL ]; } -sal_Bool CommandLineArgs::GetAcceptString( ::rtl::OUString& rPara ) const +rtl::OUString CommandLineArgs::GetSplashPipe() const { - osl::MutexGuard aMutexGuard( m_aMutex ); - rPara = m_aStrParams[ CMD_STRINGPARAM_ACCEPT ]; - return m_aStrSetParams[ CMD_STRINGPARAM_ACCEPT ]; + return m_aStrParams[CMD_STRINGPARAM_SPLASHPIPE]; } -sal_Bool CommandLineArgs::GetUnAcceptString( ::rtl::OUString& rPara ) const +std::vector< rtl::OUString > const & CommandLineArgs::GetAccept() const { - osl::MutexGuard aMutexGuard( m_aMutex ); - rPara = m_aStrParams[ CMD_STRINGPARAM_UNACCEPT ]; - return m_aStrSetParams[ CMD_STRINGPARAM_UNACCEPT ]; + return m_accept; +} + +std::vector< rtl::OUString > const & CommandLineArgs::GetUnaccept() const +{ + return m_unaccept; } sal_Bool CommandLineArgs::GetOpenList( ::rtl::OUString& rPara) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_OPENLIST ]; return m_aStrSetParams[ CMD_STRINGPARAM_OPENLIST ]; } sal_Bool CommandLineArgs::GetViewList( ::rtl::OUString& rPara) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_VIEWLIST ]; return m_aStrSetParams[ CMD_STRINGPARAM_VIEWLIST ]; } sal_Bool CommandLineArgs::GetStartList( ::rtl::OUString& rPara) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_STARTLIST ]; return m_aStrSetParams[ CMD_STRINGPARAM_STARTLIST ]; } sal_Bool CommandLineArgs::GetForceOpenList( ::rtl::OUString& rPara) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_FORCEOPENLIST ]; return m_aStrSetParams[ CMD_STRINGPARAM_FORCEOPENLIST ]; } sal_Bool CommandLineArgs::GetForceNewList( ::rtl::OUString& rPara) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_FORCENEWLIST ]; return m_aStrSetParams[ CMD_STRINGPARAM_FORCENEWLIST ]; } sal_Bool CommandLineArgs::GetPrintList( ::rtl::OUString& rPara) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTLIST ]; return m_aStrSetParams[ CMD_STRINGPARAM_PRINTLIST ]; } sal_Bool CommandLineArgs::GetPrintToList( ::rtl::OUString& rPara ) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTTOLIST ]; return m_aStrSetParams[ CMD_STRINGPARAM_PRINTTOLIST ]; } sal_Bool CommandLineArgs::GetPrinterName( ::rtl::OUString& rPara ) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_PRINTERNAME ]; return m_aStrSetParams[ CMD_STRINGPARAM_PRINTERNAME ]; } sal_Bool CommandLineArgs::GetLanguage( ::rtl::OUString& rPara ) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_LANGUAGE ]; return m_aStrSetParams[ CMD_STRINGPARAM_LANGUAGE ]; } sal_Bool CommandLineArgs::GetInFilter( ::rtl::OUString& rPara ) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_INFILTER ]; return m_aStrSetParams[ CMD_STRINGPARAM_INFILTER ]; } sal_Bool CommandLineArgs::GetConversionList( ::rtl::OUString& rPara ) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONLIST ]; return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONLIST ]; } sal_Bool CommandLineArgs::GetConversionParams( ::rtl::OUString& rPara ) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONPARAMS ]; return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONPARAMS ]; } sal_Bool CommandLineArgs::GetConversionOut( ::rtl::OUString& rPara ) const { - osl::MutexGuard aMutexGuard( m_aMutex ); rPara = m_aStrParams[ CMD_STRINGPARAM_CONVERSIONOUT ]; return m_aStrSetParams[ CMD_STRINGPARAM_CONVERSIONOUT ]; } sal_Bool CommandLineArgs::IsEmpty() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_eArgumentCount == NONE; } sal_Bool CommandLineArgs::WantsToLoadDocument() const { - osl::MutexGuard aMutexGuard( m_aMutex ); return m_bDocumentArgs; } diff --git a/desktop/source/app/cmdlineargs.hxx b/desktop/source/app/cmdlineargs.hxx index 29b2f463e55f..bc9382eb5e36 100644 --- a/desktop/source/app/cmdlineargs.hxx +++ b/desktop/source/app/cmdlineargs.hxx @@ -44,7 +44,6 @@ class CommandLineArgs CMD_BOOLPARAM_MINIMIZED = 0, CMD_BOOLPARAM_INVISIBLE, CMD_BOOLPARAM_NORESTORE, - CMD_BOOLPARAM_SERVER, CMD_BOOLPARAM_HEADLESS, CMD_BOOLPARAM_QUICKSTART, CMD_BOOLPARAM_NOQUICKSTART, @@ -79,8 +78,6 @@ class CommandLineArgs { CMD_STRINGPARAM_PORTAL = 0, CMD_STRINGPARAM_SPLASHPIPE, - CMD_STRINGPARAM_ACCEPT, - CMD_STRINGPARAM_UNACCEPT, CMD_STRINGPARAM_USERDIR, CMD_STRINGPARAM_CLIENTDISPLAY, CMD_STRINGPARAM_OPENLIST, @@ -128,10 +125,7 @@ class CommandLineArgs boost::optional< rtl::OUString > getCwdUrl() const { return m_cwdUrl; } - // generic methods to access parameter - void SetBoolParam( BoolParam eParam, sal_Bool bNewValue ); - - const rtl::OUString& GetStringParam( StringParam eParam ) const; + void ClearServer(); // Access to bool parameters sal_Bool IsMinimized() const; @@ -168,8 +162,9 @@ class CommandLineArgs // Access to string parameters sal_Bool GetPortalConnectString( ::rtl::OUString& rPara) const; - sal_Bool GetAcceptString( ::rtl::OUString& rPara) const; - sal_Bool GetUnAcceptString( ::rtl::OUString& rPara) const; + rtl::OUString GetSplashPipe() const; + std::vector< rtl::OUString > const & GetAccept() const; + std::vector< rtl::OUString > const & GetUnaccept() const; sal_Bool GetOpenList( ::rtl::OUString& rPara) const; sal_Bool GetViewList( ::rtl::OUString& rPara) const; sal_Bool GetStartList( ::rtl::OUString& rPara) const; @@ -203,7 +198,7 @@ class CommandLineArgs sal_Bool InterpretCommandLineParameter( const ::rtl::OUString&, ::rtl::OUString& ); void ParseCommandLine_Impl( Supplier& supplier ); - void ResetParamValues(); + void InitParamValues(); sal_Bool CheckGroupMembers( GroupParamId nGroup, BoolParam nExcludeMember ) const; void AddStringListParam_Impl( StringParam eParam, const rtl::OUString& aParam ); @@ -215,7 +210,11 @@ class CommandLineArgs sal_Bool m_aStrSetParams[ CMD_STRINGPARAM_COUNT ]; // Stores if string parameters are provided on cmdline Count m_eArgumentCount; // Number of Args bool m_bDocumentArgs; // A document creation/open/load arg is used + std::vector< rtl::OUString > m_accept; + std::vector< rtl::OUString > m_unaccept; + mutable ::osl::Mutex m_aMutex; + bool m_server; // static definition for groups where only one member can be true static GroupDefinition m_pGroupDefinitions[ CMD_GRPID_COUNT ]; diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx index 58daf1f5189c..f246034aaf91 100644 --- a/desktop/source/app/officeipcthread.cxx +++ b/desktop/source/app/officeipcthread.cxx @@ -725,17 +725,24 @@ void OfficeIPCThread::execute() } // handle request for acceptor - OUString aAcceptString; - if ( aCmdLineArgs->GetAcceptString(aAcceptString) ) { + std::vector< rtl::OUString > const & accept = aCmdLineArgs-> + GetAccept(); + for (std::vector< rtl::OUString >::const_iterator i(accept.begin()); + i != accept.end(); ++i) + { ApplicationEvent* pAppEvent = new ApplicationEvent( - ApplicationEvent::TYPE_ACCEPT, aAcceptString); + ApplicationEvent::TYPE_ACCEPT, *i); ImplPostForeignAppEvent( pAppEvent ); } // handle acceptor removal - OUString aUnAcceptString; - if ( aCmdLineArgs->GetUnAcceptString(aUnAcceptString) ) { + std::vector< rtl::OUString > const & unaccept = aCmdLineArgs-> + GetUnaccept(); + for (std::vector< rtl::OUString >::const_iterator i( + unaccept.begin()); + i != unaccept.end(); ++i) + { ApplicationEvent* pAppEvent = new ApplicationEvent( - ApplicationEvent::TYPE_UNACCEPT, aUnAcceptString); + ApplicationEvent::TYPE_UNACCEPT, *i); ImplPostForeignAppEvent( pAppEvent ); } |