1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_DESKTOP_INC_DP_MISC_H
21 #define INCLUDED_DESKTOP_INC_DP_MISC_H
23 #include <rtl/ustrbuf.hxx>
24 #include <rtl/instance.hxx>
25 #include <osl/mutex.hxx>
26 #include <osl/process.h>
27 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <com/sun/star/lang/XComponent.hpp>
29 #include <com/sun/star/lang/DisposedException.hpp>
30 #include <com/sun/star/deployment/XPackageRegistry.hpp>
31 #include <com/sun/star/ucb/XCommandEnvironment.hpp>
32 #include <com/sun/star/awt/XWindow.hpp>
33 #include <dp_misc_api.hxx>
37 const sal_Char CR
= 0x0d;
38 const sal_Char LF
= 0x0a;
43 mutable ::osl::Mutex m_mutex
;
45 ::osl::Mutex
& getMutex() const { return m_mutex
; }
49 inline void try_dispose( css::uno::Reference
< css::uno::XInterface
> const & x
)
51 css::uno::Reference
< css::lang::XComponent
> xComp( x
, css::uno::UNO_QUERY
);
59 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
60 OUString
expandUnoRcTerm( OUString
const & term
);
62 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
63 OUString
makeRcTerm( OUString
const & url
);
66 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
67 OUString
expandUnoRcUrl( OUString
const & url
);
71 /** appends a relative path to a url.
73 The relative path must already be correctly encoded for use in a URL.
74 If the URL starts with vnd.sun.star.expand then the relative path will
75 be again encoded for use in an "expand" URL.
77 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString
makeURL(
78 OUString
const & baseURL
, OUString
const & relPath
);
81 /** appends a relative path to a url.
83 This is the same as makeURL, but the relative Path must me a segment
86 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString
makeURLAppendSysPathSegment(
87 OUString
const & baseURL
, OUString
const & relPath
);
90 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString
generateRandomPipeId();
94 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
95 css::uno::Reference
< css::uno::XInterface
> resolveUnoURL(
96 OUString
const & connectString
,
97 css::uno::Reference
< css::uno::XComponentContext
> const & xLocalContext
,
98 AbortChannel
const * abortChannel
= nullptr );
101 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
bool office_is_running();
104 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
105 oslProcess
raiseProcess( OUString
const & appURL
,
106 css::uno::Sequence
< OUString
> const & args
);
110 /** writes the argument string to the console.
111 On Linux/Unix/etc. it converts the UTF16 string to an ANSI string using
112 osl_getThreadTextEncoding() as target encoding. On Windows it uses WriteFile
113 with the standard out stream. unopkg.com reads the data and prints them out using
116 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
117 void writeConsole(OUString
const & sText
);
119 /** writes the argument to the console using the error stream.
120 Otherwise the same as writeConsole.
122 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
123 void writeConsoleError(OUString
const & sText
);
126 /** reads from the console.
127 On Linux/Unix/etc. it uses fgets to read char values and converts them to OUString
128 using osl_getThreadTextEncoding as target encoding. The returned string has a maximum
129 size of 1024 and does NOT include leading and trailing white space(applied OUString::trim())
131 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
132 OUString
readConsole();
134 /** print the text to the console in a debug build.
135 The argument is forwarded to writeConsole. The function does not add new line.
136 The code is only executed if OSL_DEBUG_LEVEL > 1
138 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
139 void TRACE(OUString
const & sText
);
141 /** registers or revokes shared or bundled extensions which have been
142 recently added or removed.
144 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
145 void syncRepositories(
148 css::ucb::XCommandEnvironment
> const & xCmdEnv
);
150 /** workaround: for some reason the bridge threads which communicate with the
151 uno.exe process are not released on time
153 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
155 css::uno::Reference
< css::uno::XComponentContext
>
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */