24#include <config_folders.h>
28#include <rtl/bootstrap.hxx>
29#include <rtl/ustrbuf.hxx>
31#include <osl/process.h>
32#include <osl/file.hxx>
39#include <com/sun/star/lang/XMultiServiceFactory.hpp>
40#include <com/sun/star/ucb/UniversalContentBroker.hpp>
57 assert(info !=
nullptr);
60 buf.appendAscii(info->
m_name);
63 buf.append(
" (short -" );
68 buf.append(
" <argument>" );
69 return buf.makeStringAndClear();
75 OUString
const & opt )
77 for ( ; list->
m_name !=
nullptr; ++list )
96 assert(option_info !=
nullptr);
97 if (osl_getCommandArgCount() <= *pIndex)
101 osl_getCommandArg( *pIndex, &arg.pData );
102 sal_Int32 len = arg.getLength();
104 if (len < 2 || arg[ 0 ] !=
'-')
114 if (arg[ 1 ] ==
'-' && rtl_ustr_ascii_compare(
115 arg.pData->buffer + 2, option_info->
m_name ) == 0)
119 + OUString::createFromAscii(option_info->
m_name) +
"\'\n");
128 OSL_ASSERT(osl_getCommandArgCount() >= *pIndex);
131 osl_getCommandArg(*pIndex, &arg.pData);
132 if (arg.match(
"-env:"))
142 OUString * pValue,
OptionInfo const * option_info, sal_uInt32 * pIndex )
144 if (
isOption( option_info, pIndex ))
146 if (*pIndex < osl_getCommandArgCount())
148 OSL_ASSERT( pValue !=
nullptr );
149 osl_getCommandArg( *pIndex, &pValue->pData );
163 static const OUString EXEC =
167 if (osl_getExecutableFile( &path.pData ) != osl_Process_E_None) {
170 return path.copy( 0, path.lastIndexOf(
'/' ) );
178 static const OUString WORKING =
190 OUString
const & sys_path, OUString
const & base_url )
194 oslFileError rc = osl_getFileURLFromSystemPath( sys_path.pData, &file_url.pData );
195 if ( rc != osl_File_E_None) {
197 if ( osl_getSystemPathFromFileURL( sys_path.pData, &tempPath.pData) != osl_File_E_None )
206 if (osl_getAbsoluteFileURL(
207 base_url.pData, file_url.pData, &
abs.pData ) != osl_File_E_None)
210 "making absolute file url failed: \"" + base_url
211 +
"\" (base-url) and \"" + file_url +
"\" (file-url)!" );
213 return abs[
abs.getLength() -1 ] ==
'/'
214 ?
abs.copy( 0,
abs.getLength() -1 ) :
abs;
221void printf_space( sal_Int32 space )
229 std::u16string_view name, std::u16string_view value, sal_Int32 level )
231 printf_space( level );
237 Reference<deployment::XPackage>
const & xPackage,
238 Reference<XCommandEnvironment>
const & xCmdEnv, sal_Int32 level )
240 beans::Optional< OUString > id(
242 ? beans::Optional< OUString >(
244 : xPackage->getIdentifier() );
246 printf_line( u
"Identifier",
id.Value, level );
247 OUString version(xPackage->getVersion());
248 if (!version.isEmpty())
249 printf_line( u
"Version", version, level + 1 );
250 printf_line( u
"URL", xPackage->getURL(), level + 1 );
252 beans::Optional< beans::Ambiguous<sal_Bool> >
option(
253 xPackage->isRegistered( Reference<task::XAbortChannel>(), xCmdEnv ) );
256 beans::Ambiguous<sal_Bool>
const & reg =
option.Value;
260 value = reg.Value ? std::u16string_view(u
"yes") :
std::u16string_view(
u"no");
264 printf_line( u
"is registered", value, level + 1 );
266 const Reference<deployment::XPackageTypeInfo> xPackageType(
267 xPackage->getPackageType() );
268 OSL_ASSERT( xPackageType.is() );
269 if (xPackageType.is()) {
270 printf_line( u
"Media-Type", xPackageType->getMediaType(), level + 1 );
272 printf_line( u
"Description", xPackage->getDescription(), level + 1 );
273 if (!xPackage->isBundle())
276 Sequence< Reference<deployment::XPackage> > seq(
277 xPackage->getBundle( Reference<task::XAbortChannel>(), xCmdEnv ) );
278 printf_space( level + 1 );
280 std::vector<Reference<deployment::XPackage> >vec_bundle;
281 ::comphelper::sequenceToContainer(vec_bundle, seq);
283 xCmdEnv, level + 2 );
284 printf_space( level + 1 );
291 Reference<deployment::XPackage>
const & ext)
295 printf_line(
u"Identifier",
id, 0 );
302 std::vector< Reference<deployment::XPackage> >
const & allExtensions,
303 std::vector<bool>
const & vecUnaccepted,
304 Reference<XCommandEnvironment>
const & xCmdEnv, sal_Int32 level )
306 OSL_ASSERT(allExtensions.size() == vecUnaccepted.size());
308 if (allExtensions.empty())
310 printf_space( level );
316 for (
auto const& extension : allExtensions)
318 if (vecUnaccepted[
index])
321 printf_package( extension, xCmdEnv, level );
332Reference<XComponentContext> bootstrapStandAlone()
334 Reference<XComponentContext>
xContext =
335 ::cppu::defaultBootstrap_InitialComponentContext();
337 Reference<lang::XMultiServiceFactory> xServiceManager(
338 xContext->getServiceManager(), UNO_QUERY_THROW );
340 ::comphelper::setProcessServiceFactory( xServiceManager );
350Reference<XComponentContext> connectToOffice(
351 Reference<XComponentContext>
const & xLocalComponentContext,
355 OUString acceptArg =
"--accept=pipe,name=" + pipeId +
";urp;";
357 Sequence<OUString>
args {
"--nologo",
"--nodefault", acceptArg };
363 "Raising process: " + appURL +
364 "\nArguments: --nologo --nodefault " + args[2] +
373 OUString sUnoUrl =
"uno:pipe,name=" + pipeId +
";urp;StarOffice.ComponentContext";
374 Reference<XComponentContext> xRet(
376 sUnoUrl, xLocalComponentContext ),
392 OUString sBootstrap(
"${$BRAND_BASE_DIR/" LIBO_ETC_FOLDER
"/" SAL_CONFIGFILE(
"bootstrap")
":UserInstallation}");
393 rtl::Bootstrap::expandMacros(sBootstrap);
395 if (::osl::File::E_None == ::osl::File::getAbsoluteFileURL(
396 sBootstrap,
".lock", sAbs))
398 if (::osl::File::E_None ==
399 ::osl::File::getSystemPathFromFileURL(sAbs, sBootstrap))
409 bool verbose,
bool bGui,
const OUString& sTempDir,
410 Reference<XComponentContext> & out_localContext)
413 if (!sTempDir.isEmpty())
414 rtl::Bootstrap::set(
"UserInstallation", sTempDir);
417 static ::desktop::Lockfile s_lockfile(
false );
418 Reference<XComponentContext> xComponentContext( bootstrapStandAlone() );
419 out_localContext = xComponentContext;
421 xComponentContext.set(
422 connectToOffice( xComponentContext,
verbose ) );
426 if (! s_lockfile.check(
nullptr ))
428 OUString sMsg(
DpResId(RID_STR_CONCURRENTINSTANCE));
429 OUString sError(
DpResId(RID_STR_UNOPKG_ERROR));
441 VclMessageType::Warning, VclButtonsType::Ok,
453 return xComponentContext;
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static bool getProcessWorkingDir(OUString &rUrl)
static OUString getProductName()
#define SAL_CONFIGFILE(name)
OUString DpResId(TranslateId aId)
static uno::Reference< css::uno::XComponentContext > xContext
#define SAL_WARN(area, stream)
void TRACE(OUString const &sText)
print the text to the console in a debug build.
Reference< XInterface > resolveUnoURL(OUString const &connectString, Reference< XComponentContext > const &xLocalContext, AbortChannel const *abortChannel)
OUString generateRandomPipeId()
void writeConsole(std::u16string_view sText)
writes the argument string to the console.
oslProcess raiseProcess(OUString const &appURL, Sequence< OUString > const &args)
DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString getIdentifier(css::uno::Reference< css::deployment::XPackage > const &package)
Gets the identifier of a package.
css::uno::Reference< css::deployment::XPackageRegistry > create(css::uno::Reference< css::deployment::XPackageRegistry > const &xRootRegistry, OUString const &context, OUString const &cachePath, css::uno::Reference< css::uno::XComponentContext > const &xComponentContext)
Reference< XComponentContext > getUNO(bool verbose, bool bGui, const OUString &sTempDir, Reference< XComponentContext > &out_localContext)
OUString toString(OptionInfo const *info)
bool isOption(OptionInfo const *option_info, sal_uInt32 *pIndex)
OUString const & getProcessWorkingDir()
static OUString getLockFilePath()
returns the path to the lock file used by unopkg.
bool readArgument(OUString *pValue, OptionInfo const *option_info, sal_uInt32 *pIndex)
OUString const & getExecutableDir()
void printf_packages(std::vector< Reference< deployment::XPackage > > const &allExtensions, std::vector< bool > const &vecUnaccepted, Reference< XCommandEnvironment > const &xCmdEnv, sal_Int32 level)
static void printf_unaccepted_licenses(Reference< deployment::XPackage > const &ext)
bool isBootstrapVariable(sal_uInt32 *pIndex)
checks if an argument is a bootstrap variable.
OptionInfo const * getOptionInfo(OptionInfo const *list, OUString const &opt)
OUString makeAbsoluteFileUrl(OUString const &sys_path, OUString const &base_url)
SwNodeOffset abs(const SwNodeOffset &a)
sal_Unicode m_short_option
VCL_DLLPUBLIC bool InitVCL()
VCL_DLLPUBLIC void DeInitVCL()