Version 6.1.0.2, tag libreoffice-6.1.0.2
[LibreOffice.git] / framework / inc / jobs / shelljob.hxx
bloba25eb448ceb8fe928460bb6aeb1657d32dec6b3a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FRAMEWORK_INC_JOBS_SHELLJOB_HXX
21 #define INCLUDED_FRAMEWORK_INC_JOBS_SHELLJOB_HXX
23 #include <macros/xserviceinfo.hxx>
25 #include <cppuhelper/implbase.hxx>
27 #include <com/sun/star/task/XJob.hpp>
28 #include <com/sun/star/lang/XEventListener.hpp>
29 #include <com/sun/star/container/XNameAccess.hpp>
31 namespace framework{
33 /** @short implements a job component which can be used
34 to execute system shell commands.
36 @descr Because the job will be implemented generic
37 it can be bound to any event where jobs can be
38 registered for. Further there is a generic
39 way to configure the shell command and it's list
40 of arguments.
42 class ShellJob : public ::cppu::WeakImplHelper< css::lang::XServiceInfo,css::task::XJob >
45 // member
46 private:
48 /** @short reference to an uno service manager. */
49 css::uno::Reference< css::uno::XComponentContext > m_xContext;
51 // native interface
52 public:
54 /** @short create new instance of this class.
56 @param xContext
57 reference to the uno service manager, which created this instance.
58 Can be used later to create own needed uno resources on demand.
60 ShellJob(const css::uno::Reference< css::uno::XComponentContext >& xContext);
62 /** @short does nothing real ...
64 @descr But it should exists as virtual function,
65 so this class can't make trouble
66 related to inline/symbols etcpp.!
68 virtual ~ShellJob() override;
70 // uno interface
71 public:
73 // css.lang.XServiceInfo
74 DECLARE_XSERVICEINFO_NOFACTORY
75 /* Helper for registry */
76 /// @throws css::uno::Exception
77 static css::uno::Reference< css::uno::XInterface > SAL_CALL impl_createInstance ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
78 static css::uno::Reference< css::lang::XSingleServiceFactory > impl_createFactory ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xServiceManager );
80 // css.task.XJob
81 virtual css::uno::Any SAL_CALL execute(const css::uno::Sequence< css::beans::NamedValue >& lArguments) override;
83 // helper
84 private:
86 /** generate a return value for method execute()
87 which will force deactivation of this job for further requests.
89 @return an Any following the job protocol for deactivation.
91 static css::uno::Any impl_generateAnswer4Deactivation();
93 /** substitute all might existing placeholder variables
94 within the configured command.
96 The command is part of the job configuration.
97 These will make changes more easy (no code changes required).
98 Further the command can use placeholder as they are supported
99 by the global substitution service (e.g. $(prog) etcpp)
101 @param sCommand
102 the command containing placeholder variables.
104 @return the substituted command.
106 OUString impl_substituteCommandVariables(const OUString& sCommand);
108 /** executes the command.
110 @param sCommand
111 the absolute command as URL or system path (without any argument !).
113 @param lArguments
114 the complete list of arguments configured for these job.
116 @param bCheckExitCode
117 bind the execution result to the exit code of the started process.
118 If it's set to false we return false only in case executable couldn't be found
119 or couldn't be started.
121 @return sal_True if command was executed successfully; sal_False otherwise.
123 bool impl_execute(const OUString& sCommand ,
124 const css::uno::Sequence< OUString >& lArguments ,
125 bool bCheckExitCode);
128 } // namespace framework
130 #endif // INCLUDED_FRAMEWORK_INC_JOBS_SHELLJOB_HXX
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */