1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include <config_folders.h>
32 #define _LINUX_SOURCE_COMPAT
33 #include <sys/timer.h>
34 #undef _LINUX_SOURCE_COMPAT
37 #include <sys/types.h>
40 #include <osl/file.hxx>
41 #include <osl/thread.h>
42 #include <rtl/bootstrap.hxx>
43 #include <sal/log.hxx>
45 #include <plugin/impl.hxx>
48 ::boost::shared_ptr
<SysPlugData
> CreateSysPlugData()
50 return ::boost::shared_ptr
<SysPlugData
>();
53 UnxPluginComm::UnxPluginComm(
54 const OUString
& /*mimetype*/,
55 const OUString
& library
,
60 PluginComm( OUStringToOString( library
, osl_getThreadTextEncoding() ), false ),
61 PluginConnector( nDescriptor2
),
65 if (!getPluginappPath(&path
))
67 SAL_WARN("extensions.plugin", "cannot construct path to pluginapp.bin");
73 sprintf( pWindow
, "%d", (int)aParent
);
74 sprintf( pDesc
, "%d", nDescriptor1
);
75 OString
aLib(OUStringToOString(library
, osl_getThreadTextEncoding()));
78 pArgs
[0] = path
.getStr();
80 pArgs
[2] = aLib
.getStr();
86 "try to launch: " << pArgs
[0] << " " << pArgs
[1] << " " << pArgs
[2]
87 << " " << pArgs
[3] << ", descriptors are " << nDescriptor1
<< ", "
93 execvp( pArgs
[0], const_cast< char ** >(pArgs
) );
94 SAL_WARN("extensions.plugin", "could not exec " << pArgs
[0]);
100 SAL_WARN("extensions.plugin", "fork failed");
105 // wait for pluginapp.bin to start up
106 if( ! WaitForMessage( 5000 ) )
110 "timeout on command: " << pArgs
[0] << " " << pArgs
[1] << " "
111 << pArgs
[2] << " " << pArgs
[3]);
116 MediatorMessage
* pMessage
= GetNextMessage( true );
117 Respond( pMessage
->m_nID
,
118 const_cast<char*>("init ack"),8,
125 UnxPluginComm::~UnxPluginComm()
128 if( m_nCommPID
!= 0 )
130 int status
= 16777216;
131 pid_t nExit
= waitpid( m_nCommPID
, &status
, WUNTRACED
);
134 "child " << nExit
<< " (plugin app child " << m_nCommPID
135 << ") exited with status " << WEXITSTATUS(status
));
139 bool UnxPluginComm::getPluginappPath(OString
* path
) {
140 OSL_ASSERT(path
!= NULL
);
141 OUString
p("$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER
"/pluginapp.bin");
142 rtl::Bootstrap::expandMacros(p
);
144 (osl::FileBase::getSystemPathFromFileURL(p
, p
) ==
145 osl::FileBase::E_None
) &&
147 path
, osl_getThreadTextEncoding(),
148 (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR
|
149 RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR
));
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */