LCOV - code coverage report
Current view: top level - extensions/source/plugin/unx - sysplug.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 43 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 5 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*************************************************************************
       3             :  *
       4             :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5             :  *
       6             :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7             :  *
       8             :  * OpenOffice.org - a multi-platform office productivity suite
       9             :  *
      10             :  * This file is part of OpenOffice.org.
      11             :  *
      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.
      15             :  *
      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).
      21             :  *
      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.
      26             :  *
      27             :  ************************************************************************/
      28             : 
      29             : #include <config_folders.h>
      30             : 
      31             : #ifdef AIX
      32             : #define _LINUX_SOURCE_COMPAT
      33             : #include <sys/timer.h>
      34             : #undef _LINUX_SOURCE_COMPAT
      35             : #endif
      36             : 
      37             : #include <sys/types.h>
      38             : #include <signal.h>
      39             : #include <sys/wait.h>
      40             : #include <osl/file.hxx>
      41             : #include <osl/thread.h>
      42             : #include <rtl/bootstrap.hxx>
      43             : #include <sal/log.hxx>
      44             : 
      45             : #include <plugin/impl.hxx>
      46             : 
      47             : 
      48           0 : ::boost::shared_ptr<SysPlugData> CreateSysPlugData()
      49             : {
      50           0 :     return ::boost::shared_ptr<SysPlugData>();
      51             : }
      52             : 
      53           0 : UnxPluginComm::UnxPluginComm(
      54             :                              const OUString& /*mimetype*/,
      55             :                              const OUString& library,
      56             :                              Window aParent,
      57             :                              int nDescriptor1,
      58             :                              int nDescriptor2
      59             :                              ) :
      60           0 :         PluginComm( OUStringToOString( library, osl_getThreadTextEncoding() ), false ),
      61             :         PluginConnector( nDescriptor2 ),
      62           0 :         m_nCommPID( 0 )
      63             : {
      64           0 :     OString path;
      65           0 :     if (!getPluginappPath(&path))
      66             :     {
      67             :         SAL_WARN("extensions.plugin", "cannot construct path to pluginapp.bin");
      68           0 :         return;
      69             :     }
      70             : 
      71             :     char pDesc[32];
      72             :     char pWindow[32];
      73           0 :     sprintf( pWindow, "%d", (int)aParent );
      74           0 :     sprintf( pDesc, "%d", nDescriptor1 );
      75           0 :     OString aLib(OUStringToOString(library, osl_getThreadTextEncoding()));
      76             : 
      77             :     char const* pArgs[5];
      78           0 :     pArgs[0] = path.getStr();
      79           0 :     pArgs[1] = pDesc;
      80           0 :     pArgs[2] = aLib.getStr();
      81           0 :     pArgs[3] = pWindow;
      82           0 :     pArgs[4] = NULL;
      83             : 
      84             :     SAL_INFO(
      85             :         "extensions.plugin",
      86             :         "try to launch: " << pArgs[0] << " " << pArgs[1] << " " << pArgs[2]
      87             :             << " " << pArgs[3] << ", descriptors are " << nDescriptor1 << ", "
      88             :             << nDescriptor2);
      89             : 
      90           0 :     pid_t pid = fork();
      91           0 :     if( pid == 0 )
      92             :     {
      93           0 :         execvp( pArgs[0], const_cast< char ** >(pArgs) );
      94             :         SAL_WARN("extensions.plugin", "could not exec " << pArgs[0]);
      95           0 :         _exit(255);
      96             :     }
      97             : 
      98           0 :     if( pid == -1 )
      99             :     {
     100             :         SAL_WARN("extensions.plugin", "fork failed");
     101           0 :         return;
     102             :     }
     103             : 
     104           0 :     m_nCommPID = pid;
     105             :     // wait for pluginapp.bin to start up
     106           0 :     if( ! WaitForMessage( 5000 ) )
     107             :     {
     108             :         SAL_WARN(
     109             :             "extensions.plugin",
     110             :             "timeout on command: " << pArgs[0] << " " << pArgs[1] << " "
     111             :                 << pArgs[2] << " " << pArgs[3]);
     112           0 :         invalidate();
     113             :     }
     114             :     else
     115             :     {
     116           0 :         MediatorMessage* pMessage = GetNextMessage( true );
     117             :         Respond( pMessage->m_nID,
     118             :                  const_cast<char*>("init ack"),8,
     119           0 :                  NULL );
     120           0 :         delete pMessage;
     121           0 :         NPP_Initialize();
     122           0 :     }
     123             : }
     124             : 
     125           0 : UnxPluginComm::~UnxPluginComm()
     126             : {
     127           0 :     NPP_Shutdown();
     128           0 :     if( m_nCommPID != 0 )
     129             :     {
     130           0 :         int status = 16777216;
     131           0 :         pid_t nExit = waitpid( m_nCommPID, &status, WUNTRACED );
     132             :         SAL_INFO(
     133             :             "extensions.plugin",
     134             :             "child " << nExit << " (plugin app child " << m_nCommPID
     135             :                 << ") exited with status " << WEXITSTATUS(status));
     136             :     }
     137           0 : }
     138             : 
     139           0 : bool UnxPluginComm::getPluginappPath(OString * path) {
     140             :     OSL_ASSERT(path != NULL);
     141           0 :     OUString p("$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER "/pluginapp.bin");
     142           0 :     rtl::Bootstrap::expandMacros(p);
     143             :     return
     144           0 :         (osl::FileBase::getSystemPathFromFileURL(p, p) ==
     145           0 :          osl::FileBase::E_None) &&
     146             :         p.convertToString(
     147           0 :             path, osl_getThreadTextEncoding(),
     148             :             (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
     149           0 :              RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR));
     150             : }
     151             : 
     152             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11