update credits
[LibreOffice.git] / desktop / source / deployment / inc / dp_misc.h
blob4ec4c6e3498909e5f1d882c67e42f3a58746bf46
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_DP_MISC_H
21 #define INCLUDED_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"
35 #define ARLEN(x) (sizeof (x) / sizeof *(x))
37 namespace dp_misc {
39 const sal_Char CR = 0x0d;
40 const sal_Char LF = 0x0a;
42 //==============================================================================
43 class MutexHolder
45 mutable ::osl::Mutex m_mutex;
46 protected:
47 inline ::osl::Mutex & getMutex() const { return m_mutex; }
50 //==============================================================================
51 inline void try_dispose( ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> const & x )
53 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent> xComp( x, ::com::sun::star::uno::UNO_QUERY );
54 if (xComp.is())
55 xComp->dispose();
58 //##############################################################################
60 //==============================================================================
61 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
62 OUString expandUnoRcTerm( OUString const & term );
64 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
65 OUString makeRcTerm( OUString const & url );
67 //==============================================================================
68 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
69 OUString expandUnoRcUrl( OUString const & url );
71 //==============================================================================
73 /** appends a relative path to a url.
75 The relative path must already be correctly encoded for use in an URL.
76 If the URL starts with vnd.sun.star.expand then the relative path will
77 be again encoded for use in an "expand" URL.
79 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString makeURL(
80 OUString const & baseURL, OUString const & relPath );
83 /** appends a relative path to a url.
85 This is the same as makeURL, but the relative Path must me a segment
86 of an system path.
88 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString makeURLAppendSysPathSegment(
89 OUString const & baseURL, OUString const & relPath );
91 //==============================================================================
92 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString generateRandomPipeId();
94 class AbortChannel;
95 //==============================================================================
96 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
97 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> resolveUnoURL(
98 OUString const & connectString,
99 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const & xLocalContext,
100 AbortChannel * abortChannel = 0 );
102 //==============================================================================
103 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC bool office_is_running();
105 //==============================================================================
106 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
107 oslProcess raiseProcess( OUString const & appURL,
108 ::com::sun::star::uno::Sequence< OUString > const & args );
110 //==============================================================================
112 /** writes the argument string to the console.
113 On Linux/Unix/etc. it converts the UTF16 string to an ANSI string using
114 osl_getThreadTextEncoding() as target encoding. On Windows it uses WriteFile
115 with the standard out stream. unopkg.com reads the data and prints them out using
116 WriteConsoleW.
118 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
119 void writeConsole(OUString const & sText);
121 /** writes the argument to the console using the error stream.
122 Otherwise the same as writeConsole.
124 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
125 void writeConsoleError(OUString const & sText);
128 /** reads from the console.
129 On Linux/Unix/etc. it uses fgets to read char values and converts them to OUString
130 using osl_getThreadTextEncoding as target encoding. The returned string has a maximum
131 size of 1024 and does NOT include leading and trailing white space(applied OUString::trim())
133 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
134 OUString readConsole();
136 /** print the text to the console in a debug build.
137 The argument is forwarded to writeConsole. The function does not add new line.
138 The code is only executed if OSL_DEBUG_LEVEL > 1
140 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
141 void TRACE(OUString const & sText);
143 /** registers or revokes shared or bundled extensions which have been
144 recently added or removed.
146 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
147 void syncRepositories(
148 bool force,
149 ::com::sun::star::uno::Reference<
150 ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv);
152 /** workaround: for some reason the bridge threads which communicate with the
153 uno.exe process are not released on time
155 DESKTOP_DEPLOYMENTMISC_DLLPUBLIC
156 void disposeBridges(
157 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
158 const & ctx);
162 #endif
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */