LCOV - code coverage report
Current view: top level - extensions/source/plugin/unx - nppapi.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 293 0.7 %
Date: 2015-06-13 12:38:46 Functions: 2 24 8.3 %
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             : 
      30             : #ifdef AIX
      31             : #define _LINUX_SOURCE_COMPAT
      32             : #include <sys/timer.h>
      33             : #undef _LINUX_SOURCE_COMPAT
      34             : #endif
      35             : 
      36             : #include <cstdarg>
      37             : 
      38             : #include <sal/log.hxx>
      39             : #include <vcl/svapp.hxx>
      40             : 
      41             : #include <plugin/unx/plugcon.hxx>
      42             : #include <plugin/impl.hxx>
      43             : 
      44           1 : std::vector<PluginConnector*> PluginConnector::allConnectors;
      45             : 
      46           0 : PluginConnector::PluginConnector( int nSocket ) :
      47           0 :         Mediator( nSocket )
      48             : {
      49           0 :     allConnectors.push_back( this );
      50           0 :     SetNewMessageHdl( LINK( this, PluginConnector, NewMessageHdl ) );
      51           0 : }
      52             : 
      53           0 : PluginConnector::~PluginConnector()
      54             : {
      55           0 :     osl::MutexGuard aGuard( m_aUserEventMutex );
      56           0 :     for( std::vector< PluginConnector* >::iterator it = allConnectors.begin();
      57           0 :          it != allConnectors.end(); ++it )
      58             :     {
      59           0 :         if( *it == this )
      60             :         {
      61           0 :             allConnectors.erase( it );
      62           0 :             break;
      63             :         }
      64           0 :     }
      65           0 : }
      66             : 
      67           0 : IMPL_LINK( PluginConnector, NewMessageHdl, Mediator*, /*pMediator*/ )
      68             : {
      69           0 :     osl::MutexGuard aGuard( m_aUserEventMutex );
      70           0 :     bool bFound = false;
      71           0 :     for( std::vector< PluginConnector* >::iterator it = allConnectors.begin();
      72           0 :          it != allConnectors.end() && !bFound; ++it )
      73             :     {
      74           0 :         if( *it == this )
      75           0 :             bFound = true;
      76             :     }
      77           0 :     if( ! bFound )
      78           0 :         return 0;
      79           0 :     Application::PostUserEvent( LINK( this, PluginConnector, WorkOnNewMessageHdl ) );
      80           0 :     return 0;
      81             : }
      82             : 
      83           0 : IMPL_LINK( PluginConnector, WorkOnNewMessageHdl, Mediator*, /*pMediator*/ )
      84             : {
      85           0 :     bool bFound = false;
      86           0 :     for( std::vector< PluginConnector* >::iterator it = allConnectors.begin();
      87           0 :          it != allConnectors.end() && !bFound; ++it )
      88             :     {
      89           0 :         if( *it == this )
      90           0 :             bFound = true;
      91             :     }
      92           0 :     if( ! bFound )
      93           0 :         return 0;
      94             : 
      95             :     MediatorMessage* pMessage;
      96             :     CommandAtoms nCommand;
      97           0 :     while( (pMessage = GetNextMessage( false )) )
      98             :     {
      99           0 :         nCommand = (CommandAtoms)pMessage->GetUINT32();
     100             :         SAL_INFO("extensions.plugin", GetCommandName(nCommand));
     101           0 :         switch( nCommand )
     102             :         {
     103             :             case eNPN_GetURL:
     104             :             {
     105           0 :                 sal_uInt32 nInstance    = pMessage->GetUINT32();
     106           0 :                 NPP instance        = m_aInstances[ nInstance ]->instance;
     107           0 :                 char* pUrl          = pMessage->GetString();
     108           0 :                 char* pWindow       = pMessage->GetString();
     109           0 :                 NPError aRet = NPN_GetURL( instance, pUrl, pWindow );
     110             :                 Respond( pMessage->m_nID,
     111           0 :                          reinterpret_cast<char*>(&aRet), sizeof( NPError ), NULL );
     112           0 :                 delete [] pUrl;
     113           0 :                 delete [] pWindow;
     114             :             }
     115           0 :             break;
     116             :             case eNPN_GetURLNotify:
     117             :             {
     118           0 :                 sal_uInt32 nInstance    = pMessage->GetUINT32();
     119           0 :                 NPP instance        = m_aInstances[ nInstance ]->instance;
     120           0 :                 char* pUrl          = pMessage->GetString();
     121           0 :                 char* pWindow       = pMessage->GetString();
     122           0 :                 void** pNotifyData  = static_cast<void**>(pMessage->GetBytes());
     123             :                 NPError aRet = NPN_GetURLNotify( instance, pUrl, pWindow,
     124           0 :                                                  *pNotifyData );
     125             :                 Respond( pMessage->m_nID,
     126           0 :                          reinterpret_cast<char*>(&aRet), sizeof( NPError ), NULL );
     127           0 :                 delete [] pUrl;
     128           0 :                 delete [] pWindow;
     129           0 :                 delete [] pNotifyData;
     130             :             }
     131           0 :             break;
     132             :             case eNPN_DestroyStream:
     133             :             {
     134           0 :                 sal_uInt32 nInstance    = pMessage->GetUINT32();
     135           0 :                 NPP instance        = m_aInstances[ nInstance ]->instance;
     136           0 :                 sal_uInt32 nFileID      = pMessage->GetUINT32();
     137           0 :                 char* pUrl          = pMessage->GetString();
     138           0 :                 NPError* pReason    = static_cast<NPError*>(pMessage->GetBytes());
     139           0 :                 NPError aRet = NPERR_FILE_NOT_FOUND;
     140           0 :                 if( nFileID < static_cast<sal_uInt32>(m_aNPWrapStreams.size()) )
     141             :                 {
     142           0 :                     if( ! strcmp( m_aNPWrapStreams[ nFileID ]->url, pUrl ) )
     143             :                     {
     144             :                         aRet =
     145           0 :                             NPN_DestroyStream( instance, m_aNPWrapStreams[ nFileID ],
     146           0 :                                                *pReason );
     147           0 :                         m_aNPWrapStreams.erase( m_aNPWrapStreams.begin() + nFileID );
     148             :                     }
     149             :                     else
     150             :                         SAL_WARN(
     151             :                             "extensions.plugin",
     152             :                             "StreamID " << nFileID << " has incoherent urls "
     153             :                                 << pUrl << " and "
     154             :                                 << m_aNPWrapStreams[nFileID]->url);
     155             :                 }
     156             :                 else
     157             :                     SAL_WARN(
     158             :                         "extensions.plugin",
     159             :                         "nonexistent StreamID " << nFileID);
     160             : 
     161             :                 Respond( pMessage->m_nID,
     162           0 :                          reinterpret_cast<char*>(&aRet), sizeof( NPError ), NULL );
     163             : 
     164           0 :                 delete [] pUrl;
     165           0 :                 delete [] pReason;
     166             :             }
     167           0 :             break;
     168             :             case eNPN_NewStream:
     169             :             {
     170           0 :                 sal_uInt32 nInstance    = pMessage->GetUINT32();
     171           0 :                 NPP instance        = m_aInstances[ nInstance ]->instance;
     172           0 :                 NPMIMEType pType    = pMessage->GetString();
     173           0 :                 char* pTarget       = pMessage->GetString();
     174             : 
     175           0 :                 NPStream* pStream = NULL;
     176             : 
     177           0 :                 NPError aRet = NPN_NewStream( instance, pType, pTarget, &pStream );
     178             : 
     179           0 :                 if( aRet != NPERR_NO_ERROR )
     180             :                 {
     181           0 :                     sal_uInt32 nDummy = 0;
     182             :                     Respond( pMessage->m_nID,
     183             :                              reinterpret_cast<char*>(&aRet), sizeof( aRet ),
     184             :                              "", 0,
     185             :                              &nDummy, sizeof(sal_uInt32),
     186             :                              &nDummy, sizeof(sal_uInt32),
     187           0 :                              NULL );
     188             :                 }
     189             :                 else
     190             :                 {
     191           0 :                     m_aNPWrapStreams.push_back( pStream );
     192             : 
     193           0 :                     sal_uLong nLen = strlen( pStream->url );
     194             :                     Respond( pMessage->m_nID,
     195             :                              reinterpret_cast<char*>(&aRet), sizeof( aRet ),
     196             :                              pStream->url, nLen,
     197             :                              &pStream->end, sizeof(sal_uInt32),
     198             :                              &pStream->lastmodified, sizeof(sal_uInt32),
     199           0 :                              NULL );
     200             :                 }
     201             : 
     202           0 :                 delete [] pTarget;
     203           0 :                 delete [] pType;
     204             :             }
     205           0 :             break;
     206             :             case eNPN_PostURLNotify:
     207             :             {
     208           0 :                 sal_uInt32 nInstance    = pMessage->GetUINT32();
     209           0 :                 NPP instance        = m_aInstances[ nInstance ]->instance;
     210           0 :                 char* pUrl      = pMessage->GetString();
     211           0 :                 char* pTarget   = pMessage->GetString();
     212           0 :                 sal_uInt32 nLen     = pMessage->GetUINT32();
     213           0 :                 char* pBuf      = static_cast<char*>(pMessage->GetBytes());
     214           0 :                 NPBool* pFile   = static_cast<NPBool*>(pMessage->GetBytes());
     215           0 :                 void** pNData   = static_cast<void**>(pMessage->GetBytes());
     216             :                 NPError aRet =
     217           0 :                     NPN_PostURLNotify( instance, pUrl, pTarget, nLen, pBuf, *pFile, *pNData );
     218           0 :                 Respond( pMessage->m_nID, reinterpret_cast<char*>(&aRet), sizeof( aRet ), NULL );
     219           0 :                 delete [] pUrl;
     220           0 :                 delete [] pTarget;
     221           0 :                 delete [] pBuf;
     222           0 :                 delete [] pFile;
     223           0 :                 delete [] pNData;
     224             :             }
     225           0 :             break;
     226             :             case eNPN_PostURL:
     227             :             {
     228           0 :                 sal_uInt32 nInstance    = pMessage->GetUINT32();
     229           0 :                 NPP instance        = m_aInstances[ nInstance ]->instance;
     230           0 :                 char* pUrl      = pMessage->GetString();
     231           0 :                 char* pWindow   = pMessage->GetString();
     232           0 :                 sal_uInt32 nLen     = pMessage->GetUINT32();
     233           0 :                 char* pBuf      = static_cast<char*>(pMessage->GetBytes());
     234           0 :                 NPBool* pFile   = static_cast<NPBool*>(pMessage->GetBytes());
     235             :                 NPError aRet =
     236           0 :                     NPN_PostURL( instance, pUrl, pWindow, nLen, pBuf, *pFile );
     237           0 :                 Respond( pMessage->m_nID, reinterpret_cast<char*>(&aRet), sizeof( aRet ), NULL );
     238           0 :                 delete [] pUrl;
     239           0 :                 delete [] pWindow;
     240           0 :                 delete [] pBuf;
     241           0 :                 delete [] pFile;
     242             :             }
     243           0 :             break;
     244             :             case eNPN_RequestRead:
     245             :             {
     246           0 :                 sal_uInt32 nFileID      = pMessage->GetUINT32();
     247           0 :                 NPStream* pStream   = m_aNPWrapStreams[ nFileID ];
     248           0 :                 sal_uInt32 nRanges      = pMessage->GetUINT32();
     249           0 :                 sal_uInt32* pArray      = static_cast<sal_uInt32*>(pMessage->GetBytes());
     250             :                 // build ranges table
     251           0 :                 NPByteRange* pFirst = new NPByteRange;
     252           0 :                 NPByteRange* pRun   = pFirst;
     253           0 :                 for( sal_uInt32 n = 0; n < nRanges; n++ )
     254             :                 {
     255           0 :                     pRun->offset = pArray[ 2*n ];
     256           0 :                     pRun->length = pArray[ 2*n+1 ];
     257           0 :                     pRun->next = n < nRanges-1 ? new NPByteRange : NULL;
     258           0 :                     pRun = pRun->next;
     259             :                 }
     260           0 :                 NPError aRet = NPN_RequestRead( pStream, pFirst );
     261           0 :                 Respond( pMessage->m_nID, reinterpret_cast<char*>(&aRet), sizeof( aRet ), NULL );
     262           0 :                 while( pFirst )
     263             :                 {
     264           0 :                     pRun = pFirst->next;
     265           0 :                     delete pFirst;
     266           0 :                     pFirst = pRun;
     267             :                 }
     268           0 :                 delete [] pArray;
     269             :             }
     270           0 :             break;
     271             :             case eNPN_Status:
     272             :             {
     273           0 :                 sal_uInt32 nInstance    = pMessage->GetUINT32();
     274           0 :                 NPP instance        = m_aInstances[ nInstance ]->instance;
     275           0 :                 char* pString   = pMessage->GetString();
     276           0 :                 NPN_Status( instance, pString );
     277           0 :                 delete [] pString;
     278             :             }
     279           0 :             break;
     280             :             case eNPN_Version:
     281             :             {
     282             :                 int major, minor, net_major, net_minor;
     283           0 :                 NPN_Version( &major, &minor, &net_major, &net_minor );
     284             :                 Respond( pMessage->m_nID,
     285             :                          reinterpret_cast<char*>(&major), sizeof( int ),
     286             :                          &minor, sizeof( int ),
     287             :                          &net_major, sizeof( int ),
     288             :                          &net_minor, sizeof( int ),
     289           0 :                          NULL );
     290             :             }
     291           0 :             break;
     292             :             case eNPN_Write:
     293             :             {
     294           0 :                 sal_uInt32 nInstance    = pMessage->GetUINT32();
     295           0 :                 NPP instance        = m_aInstances[ nInstance ]->instance;
     296           0 :                 sal_uInt32 nFileID      = pMessage->GetUINT32();
     297           0 :                 NPStream* pStream   = m_aNPWrapStreams[ nFileID ];
     298           0 :                 sal_Int32 nLen          = pMessage->GetUINT32();
     299           0 :                 void* pBuffer       = pMessage->GetBytes();
     300           0 :                 sal_Int32 nRet = NPN_Write( instance, pStream, nLen, pBuffer );
     301             :                 Respond( pMessage->m_nID,
     302             :                          reinterpret_cast<char*>(&nRet), sizeof( nRet ),
     303           0 :                          NULL );
     304           0 :                 delete [] static_cast<char*>(pBuffer);
     305           0 :                 delete instance;
     306             :             }
     307           0 :             break;
     308             :             case eNPN_UserAgent:
     309             :             {
     310           0 :                 sal_uInt32 nInstance    = pMessage->GetUINT32();
     311           0 :                 NPP instance        = m_aInstances[ nInstance ]->instance;
     312           0 :                 const char* pAnswer = NPN_UserAgent( instance );
     313             :                 Respond( pMessage->m_nID,
     314             :                          const_cast<char*>(pAnswer), strlen( pAnswer ),
     315           0 :                          NULL );
     316             :             }
     317           0 :             break;
     318             :             default:
     319             :                 SAL_WARN(
     320             :                     "extensions.plugin",
     321             :                     "caught unknown NPN request " << +nCommand);
     322             :         }
     323             : 
     324           0 :         delete pMessage;
     325             :     }
     326           0 :     return 0;
     327             : }
     328             : 
     329             : #define GET_INSTANCE() \
     330             :     sal_uInt32 nInstance;  \
     331             :     nInstance = GetNPPID( instance );
     332             : 
     333             : #define GET_INSTANCE_RET( err ) \
     334             :     GET_INSTANCE() \
     335             :     if( nInstance == PluginConnector::UnknownNPPID ) \
     336             :         return err
     337             : 
     338             : 
     339             : #define POST_INSTANCE() reinterpret_cast<char*>(&nInstance), sizeof( nInstance )
     340             : 
     341           0 : NPError UnxPluginComm::NPP_Destroy( NPP instance, NPSavedData** save )
     342             : {
     343           0 :     NPError aRet = NPERR_GENERIC_ERROR;
     344           0 :     GET_INSTANCE_RET( aRet );
     345             :     MediatorMessage* pMes =
     346             :         Transact( eNPP_Destroy,
     347             :                   POST_INSTANCE(),
     348           0 :                   NULL );
     349           0 :     if( ! pMes )
     350           0 :         return NPERR_GENERIC_ERROR;
     351           0 :     delete pMes;
     352             : 
     353             :     pMes = Transact( eNPP_DestroyPhase2,
     354             :                      POST_INSTANCE(),
     355           0 :                      NULL );
     356           0 :     if( ! pMes )
     357           0 :         return NPERR_GENERIC_ERROR;
     358             : 
     359           0 :     aRet = GetNPError( pMes );
     360             :     sal_uLong nSaveBytes;
     361           0 :     void* pSaveData = pMes->GetBytes( nSaveBytes );
     362           0 :     if( nSaveBytes == 4 && *static_cast<sal_uInt32*>(pSaveData) == 0 )
     363           0 :         *save = NULL;
     364             :     else
     365             :     {
     366           0 :         *save = new NPSavedData;
     367           0 :         (*save)->len = nSaveBytes;
     368           0 :         (*save)->buf = pSaveData;
     369             :     }
     370           0 :     delete pMes;
     371             : 
     372           0 :     return aRet;
     373             : }
     374             : 
     375           0 : NPError UnxPluginComm::NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason )
     376             : {
     377           0 :     NPError aRet = NPERR_GENERIC_ERROR;
     378           0 :     GET_INSTANCE_RET( aRet );
     379           0 :     sal_uInt32 nFileID = GetStreamID( stream );
     380           0 :     if( nFileID == PluginConnector::UnknownStreamID )
     381           0 :         return NPERR_GENERIC_ERROR;
     382             : 
     383             :     MediatorMessage* pMes =
     384             :         Transact( eNPP_DestroyStream,
     385             :                   POST_INSTANCE(),
     386             :                   &nFileID, sizeof( nFileID ),
     387             :                   &reason, sizeof( reason ),
     388           0 :                   NULL );
     389           0 :     m_aNPWrapStreams.erase( m_aNPWrapStreams.begin() + nFileID );
     390           0 :     if( ! pMes )
     391           0 :         return NPERR_GENERIC_ERROR;
     392             : 
     393           0 :     aRet = GetNPError( pMes );
     394           0 :     delete pMes;
     395           0 :     return aRet;
     396             : }
     397             : 
     398           0 : void* UnxPluginComm::NPP_GetJavaClass()
     399             : {
     400           0 :     return NULL;
     401             : }
     402             : 
     403           0 : NPError UnxPluginComm::NPP_Initialize()
     404             : {
     405             :     MediatorMessage* pMes =
     406             :         Transact( eNPP_Initialize,
     407           0 :                   NULL );
     408           0 :     if( ! pMes )
     409           0 :         return NPERR_GENERIC_ERROR;
     410             : 
     411           0 :     NPError aRet = GetNPError( pMes );
     412           0 :     delete pMes;
     413           0 :     return aRet;
     414             : }
     415             : 
     416           0 : NPError UnxPluginComm::NPP_New( NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc,
     417             :                  char* argn[], char* argv[], NPSavedData *saved )
     418             : {
     419             :     m_aInstances.push_back(
     420             :         new ConnectorInstance( instance, pluginType, 0,
     421             :                                NULL, 0, NULL, 0,
     422             :                                saved ? static_cast<char*>(saved->buf) : NULL,
     423           0 :                                saved ? saved->len : 0 ) );
     424             : 
     425             :     char *pArgnBuf, *pArgvBuf;
     426           0 :     size_t nArgnLen = 0, nArgvLen = 0;
     427             :     int i;
     428           0 :     for( i = 0; i < argc; i++ )
     429             :     {
     430           0 :         nArgnLen += strlen( argn[i] ) +1;
     431           0 :         nArgvLen += strlen( argv[i] ) +1;
     432             :     }
     433           0 :     pArgnBuf = new char[ nArgnLen ];
     434           0 :     pArgvBuf = new char[ nArgvLen ];
     435           0 :     char* pRunArgn = pArgnBuf;
     436           0 :     char* pRunArgv = pArgvBuf;
     437           0 :     for( i = 0; i < argc; i++ )
     438             :     {
     439           0 :         strcpy( pRunArgn, argn[i] );
     440           0 :         strcpy( pRunArgv, argv[i] );
     441           0 :         pRunArgn += strlen( argn[i] ) +1;
     442           0 :         pRunArgv += strlen( argv[i] ) +1;
     443             :     }
     444             : 
     445             :     MediatorMessage* pMes;
     446           0 :     if( saved )
     447             :         pMes =
     448             :             Transact( eNPP_New,
     449             :                       pluginType, strlen( pluginType ),
     450             :                       &mode, sizeof( mode ),
     451             :                       &argc, sizeof( argc ),
     452             :                       pArgnBuf, nArgnLen,
     453             :                       pArgvBuf, nArgvLen,
     454             :                       saved->buf, static_cast<size_t>(saved->len),
     455           0 :                       NULL );
     456             :     else
     457             :         pMes =
     458             :             Transact( eNPP_New,
     459             :                       pluginType, strlen( pluginType ),
     460             :                       &mode, sizeof( mode ),
     461             :                       &argc, sizeof( argc ),
     462             :                       pArgnBuf, nArgnLen,
     463             :                       pArgvBuf, nArgvLen,
     464             :                       "0000", size_t(4),
     465           0 :                       NULL );
     466           0 :     delete [] pArgnBuf;
     467           0 :     delete [] pArgvBuf;
     468           0 :     if( ! pMes )
     469           0 :         return NPERR_GENERIC_ERROR;
     470             : 
     471           0 :     NPError aRet = GetNPError( pMes );
     472           0 :     delete pMes;
     473             : 
     474           0 :     return aRet;
     475             : }
     476             : 
     477           0 : NPError UnxPluginComm::NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream,
     478             :                        NPBool seekable, uint16_t* stype )
     479             : {
     480           0 :     NPError aRet = NPERR_GENERIC_ERROR;
     481           0 :     GET_INSTANCE_RET( aRet );
     482             : 
     483           0 :     m_aNPWrapStreams.push_back( stream );
     484             :     MediatorMessage* pMes =
     485             :         Transact( eNPP_NewStream,
     486             :                   POST_INSTANCE(),
     487             :                   type, strlen( type ),
     488             :                   stream->url, strlen( stream->url ),
     489             :                   &stream->end, sizeof( stream->end ),
     490             :                   &stream->lastmodified, sizeof( stream->lastmodified ),
     491             :                   &seekable, sizeof( seekable ),
     492           0 :                   NULL );
     493             : 
     494           0 :     if( ! pMes )
     495           0 :         return NPERR_GENERIC_ERROR;
     496             : 
     497           0 :     aRet = GetNPError( pMes );
     498           0 :     uint16_t* pSType = static_cast<uint16_t*>(pMes->GetBytes());
     499           0 :     *stype = *pSType;
     500             : 
     501           0 :     delete [] pSType;
     502           0 :     delete pMes;
     503           0 :     return aRet;
     504             : }
     505             : 
     506           0 : void UnxPluginComm::NPP_Print( NPP /*instance*/, NPPrint* /*platformPrint*/ )
     507             : {
     508           0 : }
     509             : 
     510           0 : NPError UnxPluginComm::NPP_SetWindow( NPP instance, NPWindow* window )
     511             : {
     512           0 :     NPError aRet = NPERR_GENERIC_ERROR;
     513           0 :     GET_INSTANCE_RET( aRet );
     514             : 
     515             :     MediatorMessage* pMes =
     516             :         Transact( eNPP_SetWindow,
     517             :                   POST_INSTANCE(),
     518             :                   window, sizeof( NPWindow ),
     519           0 :                   NULL );
     520           0 :     if( ! pMes )
     521           0 :         return NPERR_GENERIC_ERROR;
     522             : 
     523           0 :     aRet = GetNPError( pMes );
     524           0 :     delete pMes;
     525           0 :     return aRet;
     526             : }
     527             : 
     528           0 : void UnxPluginComm::NPP_Shutdown()
     529             : {
     530           0 :     Send( eNPP_Shutdown, NULL );
     531           0 : }
     532             : 
     533           0 : void UnxPluginComm::NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname )
     534             : {
     535           0 :     GET_INSTANCE();
     536           0 :     sal_uInt32 nFileID = GetStreamID( stream );
     537           0 :     if( nFileID == PluginConnector::UnknownStreamID )
     538           0 :         return;
     539             : 
     540             :     Send( eNPP_StreamAsFile,
     541             :           POST_INSTANCE(),
     542             :           &nFileID, sizeof( nFileID ),
     543             :           fname, strlen( fname ),
     544           0 :           NULL );
     545             : }
     546             : 
     547           0 : void UnxPluginComm::NPP_URLNotify( NPP instance, const char* url, NPReason reason, void* notifyData )
     548             : {
     549           0 :     GET_INSTANCE();
     550             : 
     551             :     Send( eNPP_URLNotify,
     552             :           POST_INSTANCE(),
     553             :           url, strlen( url ),
     554             :           &reason, sizeof( reason ),
     555             :           &notifyData, sizeof( void* ),
     556           0 :           NULL );
     557           0 : }
     558             : 
     559           0 : int32_t UnxPluginComm::NPP_Write( NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer )
     560             : {
     561           0 :     GET_INSTANCE_RET( -1 );
     562           0 :     sal_uInt32 nFileID = GetStreamID( stream );
     563           0 :     if( nFileID == PluginConnector::UnknownStreamID )
     564           0 :         return -1;
     565             : 
     566             :     MediatorMessage* pMes =
     567             :         Transact( eNPP_Write,
     568             :                   POST_INSTANCE(),
     569             :                   &nFileID, sizeof( nFileID ),
     570             :                   &offset, sizeof( offset ),
     571             :                   buffer, static_cast<size_t>(len),
     572           0 :                   NULL );
     573           0 :     if( ! pMes )
     574           0 :         return 0;
     575             : 
     576           0 :     int32_t aRet = pMes->GetUINT32();
     577           0 :     delete pMes;
     578             : 
     579           0 :     return aRet;
     580             : }
     581             : 
     582           0 : int32_t UnxPluginComm::NPP_WriteReady( NPP instance, NPStream* stream )
     583             : {
     584           0 :     GET_INSTANCE_RET( -1 );
     585           0 :     sal_uInt32 nFileID = GetStreamID( stream );
     586           0 :     if( nFileID == PluginConnector::UnknownStreamID )
     587           0 :         return -1;
     588             : 
     589             :     MediatorMessage* pMes =
     590             :         Transact( eNPP_WriteReady,
     591             :                   POST_INSTANCE(),
     592             :                   &nFileID, sizeof( nFileID ),
     593           0 :                   NULL );
     594             : 
     595           0 :     if( ! pMes )
     596           0 :         return 0;
     597             : 
     598           0 :     int32_t aRet = pMes->GetUINT32();
     599           0 :     delete pMes;
     600             : 
     601           0 :     return aRet;
     602             : }
     603             : 
     604           0 : NPError UnxPluginComm::NPP_GetValue( NPP /*instance*/, NPPVariable /*variable*/, void* /*value*/ )
     605             : {
     606           0 :     return 0;
     607             : }
     608             : 
     609           0 : NPError UnxPluginComm::NPP_SetValue( NPP /*instance*/, NPNVariable /*variable*/, void* /*value*/ )
     610             : {
     611           0 :     return 0;
     612           3 : }
     613             : 
     614             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11