LibreOffice Module framework (master) 1
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
framework::ShellJob Class Referencefinal

implements a job component which can be used to execute system shell commands. More...

#include <shelljob.hxx>

Inheritance diagram for framework::ShellJob:
[legend]
Collaboration diagram for framework::ShellJob:
[legend]

Public Member Functions

 ShellJob (css::uno::Reference< css::uno::XComponentContext > xContext)
 create new instance of this class. More...
 
virtual ~ShellJob () override
 does nothing real ... More...
 
virtual OUString SAL_CALL getImplementationName () override
 
virtual sal_Bool SAL_CALL supportsService (const OUString &sServiceName) override
 
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames () override
 
virtual css::uno::Any SAL_CALL execute (const css::uno::Sequence< css::beans::NamedValue > &lArguments) override
 

Private Member Functions

OUString impl_substituteCommandVariables (const OUString &sCommand)
 substitute all might existing placeholder variables within the configured command. More...
 
bool impl_execute (const OUString &sCommand, const css::uno::Sequence< OUString > &lArguments, bool bCheckExitCode)
 executes the command. More...
 

Static Private Member Functions

static css::uno::Any impl_generateAnswer4Deactivation ()
 generate a return value for method execute() which will force deactivation of this job for further requests. More...
 

Private Attributes

css::uno::Reference< css::uno::XComponentContext > m_xContext
 reference to a uno service manager. More...
 

Detailed Description

implements a job component which can be used to execute system shell commands.

@descr Because the job will be implemented generic it can be bound to any event where jobs can be registered for. Further there is a generic way to configure the shell command and it's list of arguments.

Definition at line 39 of file shelljob.hxx.

Constructor & Destructor Documentation

◆ ShellJob()

framework::ShellJob::ShellJob ( css::uno::Reference< css::uno::XComponentContext >  xContext)

create new instance of this class.

Parameters
xContextreference to the uno service manager, which created this instance. Can be used later to create own needed uno resources on demand.

Definition at line 59 of file shelljob.cxx.

◆ ~ShellJob()

framework::ShellJob::~ShellJob ( )
overridevirtual

does nothing real ...

@descr But it should exists as virtual function, so this class can't make trouble related to inline/symbols etcpp.!

Definition at line 64 of file shelljob.cxx.

Member Function Documentation

◆ execute()

css::uno::Any SAL_CALL framework::ShellJob::execute ( const css::uno::Sequence< css::beans::NamedValue > &  lArguments)
overridevirtual

address job configuration inside argument set provided on method execute().

Definition at line 68 of file shelljob.cxx.

References comphelper::SequenceAsHashMap::getUnpackedValueOrDefault(), impl_execute(), impl_generateAnswer4Deactivation(), and impl_substituteCommandVariables().

◆ getImplementationName()

OUString SAL_CALL framework::ShellJob::getImplementationName ( )
overridevirtual

Definition at line 43 of file shelljob.cxx.

◆ getSupportedServiceNames()

css::uno::Sequence< OUString > SAL_CALL framework::ShellJob::getSupportedServiceNames ( )
overridevirtual

Definition at line 53 of file shelljob.cxx.

References framework::SERVICENAME_JOB.

◆ impl_execute()

bool framework::ShellJob::impl_execute ( const OUString &  sCommand,
const css::uno::Sequence< OUString > &  lArguments,
bool  bCheckExitCode 
)
private

executes the command.

Parameters
sCommandthe absolute command as URL or system path (without any argument !).
lArgumentsthe complete list of arguments configured for these job.
bCheckExitCodebind the execution result to the exit code of the started process. If it's set to false we return false only in case executable couldn't be found or couldn't be started.
Returns
sal_True if command was executed successfully; sal_False otherwise.

Definition at line 125 of file shelljob.cxx.

Referenced by execute().

◆ impl_generateAnswer4Deactivation()

css::uno::Any framework::ShellJob::impl_generateAnswer4Deactivation ( )
staticprivate

generate a return value for method execute() which will force deactivation of this job for further requests.

Returns
an Any following the job protocol for deactivation.

Definition at line 103 of file shelljob.cxx.

References framework::JobConst::ANSWER_DEACTIVATE_JOB.

Referenced by execute().

◆ impl_substituteCommandVariables()

OUString framework::ShellJob::impl_substituteCommandVariables ( const OUString &  sCommand)
private

substitute all might existing placeholder variables within the configured command.

The command is part of the job configuration. These will make changes more easy (no code changes required). Further the command can use placeholder as they are supported by the global substitution service (e.g. etcpp)

Parameters
sCommandthe command containing placeholder variables.
Returns
the substituted command.

Definition at line 109 of file shelljob.cxx.

References m_xContext.

Referenced by execute().

◆ supportsService()

sal_Bool SAL_CALL framework::ShellJob::supportsService ( const OUString &  sServiceName)
overridevirtual

Definition at line 48 of file shelljob.cxx.

References sServiceName, and cppu::supportsService().

Member Data Documentation

◆ m_xContext

css::uno::Reference< css::uno::XComponentContext > framework::ShellJob::m_xContext
private

reference to a uno service manager.

Definition at line 46 of file shelljob.hxx.

Referenced by impl_substituteCommandVariables().


The documentation for this class was generated from the following files: