diff options
author | Rene Engelhard <rene@debian.org> | 2015-12-12 11:36:25 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2015-12-17 15:31:17 +0000 |
commit | 4c18af27bf95b332ee2006cfc0bbf469fb1a84d4 (patch) | |
tree | 5ff484eada8d6782b70c323a340bf197709ecc1e /extensions | |
parent | 57b1cf5862429d86a82158eb5e8cf425fd2f4527 (diff) |
tdf#96398 kill remaining NPAPI support for plugins _inside_ LO
- probably out of date
- links against Gtk2 and thus causes a GTk2 dependency in core packages
- the only serious usecase (Flash) is doomed anyway
Change-Id: I7264ab5eb04c2f4b6c31a815e45b9818209e5ae2
Reviewed-on: https://gerrit.libreoffice.org/20658
Reviewed-by: David Ostrovsky <david@ostrovsky.org>
Reviewed-by: Bryan Quigley <gquigs@gmail.com>
Tested-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'extensions')
37 files changed, 0 insertions, 11130 deletions
diff --git a/extensions/Executable_pluginapp.bin.mk b/extensions/Executable_pluginapp.bin.mk deleted file mode 100644 index 96a25cca4c4d..000000000000 --- a/extensions/Executable_pluginapp.bin.mk +++ /dev/null @@ -1,69 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# - -$(eval $(call gb_Executable_Executable,pluginapp.bin)) - -$(eval $(call gb_Executable_use_external,pluginapp.bin,npapi_headers)) - -$(eval $(call gb_Executable_set_include,pluginapp.bin,\ - $$(INCLUDE) \ - -I$(SRCDIR)/extensions/source/plugin/inc \ -)) - -$(eval $(call gb_Executable_use_sdk_api,pluginapp.bin)) - -$(eval $(call gb_Executable_add_exception_objects,pluginapp.bin,\ - extensions/source/plugin/unx/npwrap \ - extensions/source/plugin/unx/npnapi \ -)) - -$(eval $(call gb_Executable_use_static_libraries,pluginapp.bin,\ - plugcon \ -)) - -$(eval $(call gb_Executable_use_libraries,pluginapp.bin,\ - sal \ -)) - -ifeq ($(filter-out FREEBSD NETBSD OPENBSD DRAGONFLY,$(OS)),) -$(eval $(call gb_Executable_add_libs,pluginapp.bin,\ - -lXt \ - -lXext \ - -lX11 \ -)) -else ifeq ($(OS),AIX) -$(eval $(call gb_Executable_add_libs,pluginapp.bin,\ - -lXpm \ - -lXmu \ - -lXt \ - -lXext \ - -lX11 \ - -ldl \ -)) -else -$(eval $(call gb_Executable_add_libs,pluginapp.bin,\ - -lXt \ - -lXext \ - -lX11 \ - -ldl \ -)) -endif - - -ifeq ($(ENABLE_GTK),TRUE) -$(eval $(call gb_Executable_use_externals,pluginapp.bin,\ - gthread \ - gtk \ -)) - -endif - -# vim:set noet sw=4 ts=4: diff --git a/extensions/Library_pl.mk b/extensions/Library_pl.mk deleted file mode 100644 index 82a71d6bcdbe..000000000000 --- a/extensions/Library_pl.mk +++ /dev/null @@ -1,120 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# -# - -$(eval $(call gb_Library_Library,pl)) - -$(eval $(call gb_Library_set_componentfile,pl,extensions/source/plugin/pl)) - -$(eval $(call gb_Library_use_externals,pl,\ - boost_headers \ - npapi_headers \ -)) - -$(eval $(call gb_Library_set_include,pl,\ - $$(INCLUDE) \ - -I$(SRCDIR)/extensions/source/plugin/inc \ -)) - -$(eval $(call gb_Library_use_sdk_api,pl)) - -ifeq ($(ENABLE_JAVA),TRUE) -$(eval $(call gb_Library_add_defs,pl,\ - -DOJI \ -)) - -endif # ENABLE_JAVA=YES - -ifeq ($(OS),SOLARIS) -$(eval $(call gb_Library_add_libs,pl,\ - -lsocket \ -)) -endif # OS=SOLARIS - -ifeq ($(OS),WNT) -$(eval $(call gb_Library_use_system_win32_libs,pl,\ - advapi32 \ - ole32 \ - version \ -)) - -$(eval $(call gb_Library_add_exception_objects,pl,\ - extensions/source/plugin/win/winmgr \ - extensions/source/plugin/win/sysplug \ -)) - -else ifeq ($(OS),MACOSX) - -$(eval $(call gb_Library_add_objcxxobjects,pl,\ - extensions/source/plugin/aqua/macmgr \ - extensions/source/plugin/aqua/sysplug \ -)) - -$(eval $(call gb_Library_use_system_darwin_frameworks,pl,\ - Cocoa \ - Carbon \ - CoreFoundation \ -)) - -else - -ifeq ($(ENABLE_GTK),TRUE) -$(eval $(call gb_Library_add_defs,pl,\ - -DENABLE_GTK \ -)) - -$(eval $(call gb_Library_use_external,pl,gtk)) -endif # ENABLE_GTK=TRUE - -$(eval $(call gb_Library_add_exception_objects,pl,\ - extensions/source/plugin/unx/nppapi \ - extensions/source/plugin/unx/sysplug \ - extensions/source/plugin/unx/unxmgr \ -)) - -$(eval $(call gb_Library_use_static_libraries,pl,\ - plugcon \ -)) - -$(eval $(call gb_Library_add_libs,pl,\ - -lX11 \ -)) - -endif - -$(eval $(call gb_Library_use_libraries,pl,\ - tk \ - vcl \ - svl \ - utl \ - tl \ - comphelper \ - ucbhelper \ - cppuhelper \ - cppu \ - sal \ - salhelper \ - $(gb_UWINAPI) \ -)) - -$(eval $(call gb_Library_add_exception_objects,pl,\ - extensions/source/plugin/base/context \ - extensions/source/plugin/base/evtlstnr \ - extensions/source/plugin/base/manager \ - extensions/source/plugin/base/multiplx \ - extensions/source/plugin/base/nfuncs \ - extensions/source/plugin/base/plcom \ - extensions/source/plugin/base/plctrl \ - extensions/source/plugin/base/plmodel \ - extensions/source/plugin/base/service \ - extensions/source/plugin/base/xplugin \ -)) - -# vim:set noet sw=4 ts=4: diff --git a/extensions/Module_extensions.mk b/extensions/Module_extensions.mk index fa527f5f1364..f5a27bf301b6 100644 --- a/extensions/Module_extensions.mk +++ b/extensions/Module_extensions.mk @@ -94,23 +94,6 @@ endif # DISABLE_ATL endif # WNT -ifeq ($(ENABLE_NPAPI_FROM_BROWSER),TRUE) - -$(eval $(call gb_Module_add_targets,extensions,\ - Library_pl \ -)) - -ifneq ($(OS),WNT) -ifneq ($(OS),MACOSX) -$(eval $(call gb_Module_add_targets,extensions,\ - StaticLibrary_plugcon \ - Executable_pluginapp.bin \ -)) -endif -endif - -endif # ENABLE_NPAPI_FROM_BROWSER=TRUE - ifeq ($(OS),MACOSX) $(eval $(call gb_Module_add_targets,extensions,\ Library_OOoSpotlightImporter \ diff --git a/extensions/StaticLibrary_plugcon.mk b/extensions/StaticLibrary_plugcon.mk deleted file mode 100644 index 149e86b05925..000000000000 --- a/extensions/StaticLibrary_plugcon.mk +++ /dev/null @@ -1,61 +0,0 @@ -# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*- -# -# -# This file is part of the LibreOffice project. -# -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. -# - -ifeq ($(OS),WNT) -$(error only for UNX) -endif - -$(eval $(call gb_StaticLibrary_StaticLibrary,plugcon)) - -$(eval $(call gb_StaticLibrary_use_externals,plugcon,\ - boost_headers \ - npapi_headers \ -)) - -$(eval $(call gb_StaticLibrary_set_include,plugcon,\ - $$(INCLUDE) \ - -I$(SRCDIR)/extensions/source/plugin/inc \ -)) - -$(eval $(call gb_StaticLibrary_use_api,plugcon,\ - offapi \ - udkapi \ -)) - -ifeq ($(ENABLE_JAVA),TRUE) -$(eval $(call gb_StaticLibrary_add_defs,plugcon,\ - -DOJI \ -)) - -endif # ENABLE_JAVA=YES - -ifeq ($(ENABLE_GTK),TRUE) -$(eval $(call gb_StaticLibrary_add_defs,plugcon,\ - -DENABLE_GTK \ -)) - -$(eval $(call gb_StaticLibrary_use_external,plugcon,gtk)) - -# Gtk uses cairo, and if we build internal cairo, the linker could -# pick up our cairo libs before they're fully ready, causing problems -# (e.g. using our libpixman and system libcairo). Depend on cairo -# to delay build until cairo is done. -ifeq ($(SYSTEM_CAIRO),) -$(eval $(call gb_StaticLibrary_use_external,plugcon,cairo)) -endif -endif # ENABLE_GTK=TRUE - -$(eval $(call gb_StaticLibrary_add_exception_objects,plugcon,\ - extensions/source/plugin/unx/mediator \ - extensions/source/plugin/unx/plugcon \ -)) - -# vim:set noet sw=4 ts=4: - diff --git a/extensions/source/plugin/aqua/macmgr.mm b/extensions/source/plugin/aqua/macmgr.mm deleted file mode 100644 index 878571a9377e..000000000000 --- a/extensions/source/plugin/aqua/macmgr.mm +++ /dev/null @@ -1,654 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "rtl/ustrbuf.hxx" -#include "rtl/strbuf.hxx" - -#include "plugin/impl.hxx" -#include "osl/file.h" -#include "osl/module.hxx" - -using namespace std; -using namespace com::sun::star::uno; -using namespace com::sun::star::plugin; - -using ::rtl::OUString; -using ::rtl::OString; -using ::rtl::OUStringBuffer; -using ::rtl::OStringBuffer; -using ::rtl::OUStringToOString; -using ::rtl::OStringToOUString; - -namespace plugstringhelper -{ - -rtl::OUString getString( CFStringRef i_xString ) -{ - rtl::OUStringBuffer aBuf; - if( i_xString ) - { - CFIndex nChars = CFStringGetLength( i_xString ); - CFRange aRange = { 0, nChars }; - aBuf.setLength( nChars ); - CFStringGetCharacters( i_xString, aRange, static_cast< UniChar* >(const_cast<sal_Unicode*>(aBuf.getStr())) ); - } - return aBuf.makeStringAndClear(); -} - -rtl::OUString getString( CFURLRef i_xURL ) -{ - CFStringRef xString = CFURLGetString( i_xURL ); - return getString( xString ); -} - -CFMutableStringRef createString( const rtl::OUString& i_rString ) -{ - CFMutableStringRef xString = CFStringCreateMutable( NULL, 0 ); - if( xString ) - CFStringAppendCharacters( xString, i_rString.getStr(), i_rString.getLength() ); - return xString; -} - -CFURLRef createURL( const rtl::OUString& i_rString ) -{ - - CFMutableStringRef xMutableString = createString( i_rString ); - CFURLRef xURL = CFURLCreateWithString( NULL, xMutableString, NULL ); - CFRelease( xMutableString ); - return xURL; -} - -rtl::OUString getURLFromPath( const rtl::OUString& i_rPath ) -{ - CFMutableStringRef xMutableString = createString( i_rPath ); - CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true ); - CFRelease( xMutableString ); - CFStringRef xString = CFURLGetString( xURL ); - rtl::OUString aRet = getString( xString ); - CFRelease( xURL ); - return aRet; -} - -CFURLRef createURLFromPath( const rtl::OUString& i_rPath ) -{ - CFMutableStringRef xMutableString = createString( i_rPath ); - CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true ); - return xURL; -} - -rtl::OUString CFURLtoOSLURL( CFURLRef i_xURL ) -{ - // make URL absolute - CFURLRef xAbsURL = CFURLCopyAbsoluteURL( i_xURL ); - // copy system path - CFStringRef xSysPath = CFURLCopyFileSystemPath( xAbsURL ? xAbsURL : i_xURL, kCFURLPOSIXPathStyle ); - if( xAbsURL ) - CFRelease( xAbsURL ); - rtl::OUString aSysPath( getString( xSysPath ) ); - CFRelease( xSysPath ); - rtl::OUString aFileURL; - osl_getFileURLFromSystemPath( aSysPath.pData, &aFileURL.pData ); - return aFileURL; -} - -} - -using namespace plugstringhelper; - -static int parsePlist( CFBundleRef i_xBundle, const rtl::OUString& i_rBundleURL , list< PluginDescription* >& io_rDescriptions ) -{ - CFTypeRef xMimeDict = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginMIMETypes")); - int nMimetypes = 0; - if( xMimeDict == 0 || - CFGetTypeID(xMimeDict) != CFDictionaryGetTypeID() || - (nMimetypes = CFDictionaryGetCount( static_cast<CFDictionaryRef>(xMimeDict))) <= 0 ) - { - return 0; - } - - // prepare an array of key and value refs - std::vector< CFTypeRef > aKeys( nMimetypes, CFTypeRef(NULL) ); - std::vector< CFTypeRef > aValues( nMimetypes, CFTypeRef(NULL) ); - CFDictionaryGetKeysAndValues(static_cast<CFDictionaryRef>(xMimeDict), &aKeys[0], &aValues[0] ); - - int nAdded = 0; - for( int i = 0; i < nMimetypes; i++ ) - { - // get the mimetype - CFTypeRef xKey = aKeys[i]; - if( ! xKey || CFGetTypeID(xKey) != CFStringGetTypeID() ) - continue; - rtl::OUString aMimetype = getString( (CFStringRef)xKey ); - - // the correspoding value should be a dictionary - CFTypeRef xDict = aValues[i]; - if( ! xDict || CFGetTypeID( xDict ) != CFDictionaryGetTypeID() ) - continue; - - // get the extension list - CFTypeRef xExtArray = CFDictionaryGetValue( (CFDictionaryRef)xDict, CFSTR("WebPluginExtensions" ) ); - if( !xExtArray || CFGetTypeID( xExtArray ) != CFArrayGetTypeID() ) - continue; - - OUStringBuffer aExtBuf; - int nExtensions = CFArrayGetCount( (CFArrayRef)xExtArray ); - for( int n = 0; n < nExtensions; n++ ) - { - CFTypeRef xExt = CFArrayGetValueAtIndex( (CFArrayRef)xExtArray, n ); - if( xExt && CFGetTypeID( xExt ) == CFStringGetTypeID() ) - { - if( aExtBuf.getLength() > 0 ) - aExtBuf.append( sal_Unicode(';') ); - OUString aExt( getString( (CFStringRef)xExt ) ); - if( aExt.indexOfAsciiL( "*.", 2 ) != 0 ) - aExtBuf.appendAscii( "*." ); - aExtBuf.append( aExt ); - } - } - - // get the description string - CFTypeRef xDescString = CFDictionaryGetValue( (CFDictionaryRef)xDict, CFSTR("WebPluginTypeDescription" ) ); - if( !xDescString || CFGetTypeID( xDescString ) != CFStringGetTypeID() ) - continue; - rtl::OUString aDescription = getString( (CFStringRef)xDescString ); - - PluginDescription* pNew = new PluginDescription; - // set plugin name (path to library) - pNew->PluginName = i_rBundleURL; - // set mimetype - pNew->Mimetype = aMimetype; - // set extension line - pNew->Extension = aExtBuf.makeStringAndClear(); - // set description - pNew->Description= aDescription; - - io_rDescriptions.push_back( pNew ); - nAdded++; - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, - "Inserting from PList:\n" - " Mimetype: %s\n" - " Extension: %s\n" - " Description: %s\n", - OUStringToOString( pNew->Mimetype, RTL_TEXTENCODING_UTF8 ).getStr(), - OUStringToOString( pNew->Extension, RTL_TEXTENCODING_UTF8 ).getStr(), - OUStringToOString( pNew->Description, RTL_TEXTENCODING_UTF8 ).getStr() - ); -#endif - - } - - return nAdded; -} - -static int parseMimeString( const rtl::OUString& i_rBundleURL , list< PluginDescription* >& io_rDescriptions, const char* i_pMime ) -{ - if( ! i_pMime ) - return 0; - - rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); - - OStringBuffer aMIME; - aMIME.append( i_pMime ); - - if( aMIME.getLength() < 1 ) - return 0; - - OString aLine = aMIME.makeStringAndClear(); - - int nAdded = 0; - sal_Int32 nIndex = 0; - while( nIndex != -1 ) - { - OString aType = aLine.getToken( 0, ';', nIndex ); - - sal_Int32 nTypeIndex = 0; - OString aMimetype = aType.getToken( 0, ':', nTypeIndex ); - OString aExtLine = aType.getToken( 0, ':', nTypeIndex ); - if( nTypeIndex < 0 ) // ensure at least three tokens - continue; - OString aDesc = aType.getToken( 0, ':', nTypeIndex ); - - // create extension list string - sal_Int32 nExtIndex = 0; - OStringBuffer aExtension; - while( nExtIndex != -1 ) - { - OString aExt = aExtLine.getToken( 0, ',', nExtIndex); - if( aExt.indexOf( "*." ) != 0 ) - aExtension.append( "*." ); - aExtension.append( aExt ); - if( nExtIndex != -1 ) - aExtension.append( ';' ); - } - - PluginDescription* pNew = new PluginDescription; - // set plugin name (path to library) - pNew->PluginName = i_rBundleURL; - // set mimetype - pNew->Mimetype = OStringToOUString( aMimetype, aEncoding ); - // set extension line - pNew->Extension = OStringToOUString( aExtension.makeStringAndClear(), aEncoding ); - // set description - pNew->Description= OStringToOUString( aDesc, aEncoding ); - io_rDescriptions.push_back( pNew ); - nAdded++; - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, - "Inserting from mime string:\n" - " Mimetype: %s\n" - " Extension: %s\n" - " Description: %s\n", - OUStringToOString( pNew->Mimetype, aEncoding ).getStr(), - OUStringToOString( pNew->Extension, aEncoding ).getStr(), - OUStringToOString( pNew->Description, aEncoding ).getStr() - ); -#endif - } - return nAdded; -} - -// this is so ugly it you want to tear your eyes out -static rtl::OUString GetNextPluginStringFromHandle(Handle h, short *index) -{ - char* pPascalBytes = (*h + *index); - sal_uInt32 nLen = (unsigned char)pPascalBytes[0]; - rtl::OStringBuffer aBuf( nLen ); - aBuf.append( pPascalBytes+1, nLen ); - *index += nLen + 1; - return rtl::OStringToOUString( aBuf.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ); -} - -static int parseMimeResource( CFBundleRef i_xBundle, - oslModule& i_rMod, - const rtl::OUString& i_rBundleURL, - list< PluginDescription* >& io_rDescriptions ) -{ - int nAdded = 0; - // just to hurt our eyes more there is an alternative mimetype function plus the possibility - // of a resource fork. Must be a case of think different. - #if defined __LP64__ - int - #else - SInt16 - #endif - xRes = 0; - BPSupportedMIMETypes aMIMETypesStrangeStruct = {kBPSupportedMIMETypesStructVers_1, NULL, NULL}; - - BP_GetSupportedMIMETypesUPP pBPGetSupp = (BP_GetSupportedMIMETypesUPP)osl_getAsciiFunctionSymbol( i_rMod, "BP_GetSupportedMIMETypes" ); - if( pBPGetSupp && - noErr == pBPGetSupp( &aMIMETypesStrangeStruct, 0 ) && - aMIMETypesStrangeStruct.typeStrings ) - { - HLock( aMIMETypesStrangeStruct.typeStrings ); - if( aMIMETypesStrangeStruct.infoStrings ) // it's possible some plugins have infoStrings missing - HLock( aMIMETypesStrangeStruct.infoStrings ); - } - else // Try to get data from the resource fork - { - xRes = CFBundleOpenBundleResourceMap( i_xBundle ); - if( xRes > 0 ) - { - aMIMETypesStrangeStruct.typeStrings = Get1Resource('STR#', 128); - if( aMIMETypesStrangeStruct.typeStrings ) - { - DetachResource( aMIMETypesStrangeStruct.typeStrings ); - HLock( aMIMETypesStrangeStruct.typeStrings ); - aMIMETypesStrangeStruct.infoStrings = Get1Resource('STR#', 127); - if( aMIMETypesStrangeStruct.infoStrings ) - { - DetachResource( aMIMETypesStrangeStruct.infoStrings ); - HLock( aMIMETypesStrangeStruct.infoStrings ); - } - } - } - } - - if( aMIMETypesStrangeStruct.typeStrings && aMIMETypesStrangeStruct.infoStrings ) - { - short nVariantCount = (**(short**)aMIMETypesStrangeStruct.typeStrings) / 2; - // Fill in the info struct based on the data in the BPSupportedMIMETypes struct - // this is an array of pascal string of unknown (!) encoding - // whoever thought of this deserves a fair beating - short mimeIndex = 2; - short descriptionIndex = 2; - for( int i = 0; i < nVariantCount; i++ ) - { - rtl::OUString aMimetype = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.typeStrings, &mimeIndex ); - rtl::OUString aExtLine = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.typeStrings, &mimeIndex ); - rtl::OUString aDescription; - if( aMIMETypesStrangeStruct.infoStrings ) - aDescription = GetNextPluginStringFromHandle( aMIMETypesStrangeStruct.infoStrings, &descriptionIndex ); - - // create extension list string - sal_Int32 nExtIndex = 0; - OUStringBuffer aExtension; - while( nExtIndex != -1 ) - { - OUString aExt = aExtLine.getToken( 0, ',', nExtIndex); - if( aExt.indexOfAsciiL( "*.", 2 ) != 0 ) - aExtension.appendAscii( "*." ); - aExtension.append( aExt ); - if( nExtIndex != -1 ) - aExtension.append( sal_Unicode(';') ); - } - - PluginDescription* pNew = new PluginDescription; - // set plugin name (path to library) - pNew->PluginName = i_rBundleURL; - // set mimetype - pNew->Mimetype = aMimetype; - // set extension line - pNew->Extension = aExtension.makeStringAndClear(); - // set description - pNew->Description= aDescription; - io_rDescriptions.push_back( pNew ); - nAdded++; - - #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, - "Inserting from resource:\n" - " Mimetype: %s\n" - " Extension: %s\n" - " Description: %s\n", - OUStringToOString( pNew->Mimetype, RTL_TEXTENCODING_UTF8 ).getStr(), - OUStringToOString( pNew->Extension, RTL_TEXTENCODING_UTF8 ).getStr(), - OUStringToOString( pNew->Description, RTL_TEXTENCODING_UTF8 ).getStr() - ); - #endif - } - } - - - // clean up - if( aMIMETypesStrangeStruct.typeStrings ) - { - HUnlock( aMIMETypesStrangeStruct.typeStrings ); - DisposeHandle( aMIMETypesStrangeStruct.typeStrings ); - } - if( aMIMETypesStrangeStruct.infoStrings ) - { - HUnlock( aMIMETypesStrangeStruct.infoStrings ); - DisposeHandle( aMIMETypesStrangeStruct.infoStrings ); - } - if( xRes ) - CFBundleCloseBundleResourceMap( i_xBundle, xRes ); - - return nAdded; -} - -// check some known bad plugins to avoid crashes -static bool checkBlackList( CFBundleRef i_xBundle ) -{ - rtl::OUString aBundleName; - CFTypeRef bundlename = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("CFBundleName")); - if( bundlename && CFGetTypeID(bundlename) == CFStringGetTypeID() ) - aBundleName = getString( static_cast<CFStringRef>(bundlename) ); - - rtl::OUString aBundleVersion; - CFTypeRef bundleversion = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("CFBundleVersion")); - if( bundleversion && CFGetTypeID(bundleversion) == CFStringGetTypeID() ) - aBundleVersion = getString( static_cast<CFStringRef>(bundleversion) ); - - bool bReject = false; - // #i102735# VLC plugin prior to 1.0 tends to crash - if( aBundleName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "VLC Plug-in" ) ) ) - { - sal_Int32 nIndex = 0; - rtl::OUString aMajor( aBundleVersion.getToken( 0, '.', nIndex ) ); - if( aMajor.toInt32() < 1 ) - { - bReject = true; - } - } - // #i103674# Garmin Communicator Plugin crashes - else if( aBundleName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Garmin Communicator Plugin" ) ) ) - { - bReject = true; - } - - #if OSL_DEBUG_LEVEL > 1 - if( bReject ) - fprintf( stderr, "rejecting plugin \"%s\" version %s\n", - rtl::OUStringToOString( aBundleName, RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( aBundleVersion, RTL_TEXTENCODING_UTF8 ).getStr() - ); - #endif - - return bReject; -} - -static int getPluginDescriptions( CFBundleRef i_xBundle , list< PluginDescription* >& io_rDescriptions ) -{ - int nDescriptions = 0; - if( ! i_xBundle ) - return nDescriptions; - - if( checkBlackList( i_xBundle ) ) - return 0; - - rtl::OUString aPlugURL; - CFURLRef xURL = CFBundleCopyBundleURL( i_xBundle ); - aPlugURL = getString( xURL ); - CFRelease( xURL ); - - #if OSL_DEBUG_LEVEL > 1 - rtl::OUString aPlugName, aPlugDescription; - CFTypeRef name = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginName")); - if( name && CFGetTypeID(name) == CFStringGetTypeID() ) - aPlugName = getString( static_cast<CFStringRef>(name) ); - - CFTypeRef description = CFBundleGetValueForInfoDictionaryKey( i_xBundle, CFSTR("WebPluginDescription")); - if( description && CFGetTypeID(description) == CFStringGetTypeID() ) - aPlugDescription = getString( static_cast<CFStringRef>(description) ); - - fprintf( stderr, "URL: %s\nname: %s\ndescription: %s\n", - rtl::OUStringToOString( aPlugURL, RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( aPlugName, RTL_TEXTENCODING_UTF8 ).getStr(), - rtl::OUStringToOString( aPlugDescription, RTL_TEXTENCODING_UTF8 ).getStr() - ); - #endif - - - // get location of plugin library - CFURLRef xLibURL = CFBundleCopyExecutableURL( i_xBundle ); - if( ! xLibURL ) - return 0; - // get the file system path - rtl::OUString aModuleURL( CFURLtoOSLURL( xLibURL ) ); - CFRelease( xLibURL ); - - #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "exec URL = %s\n", rtl::OUStringToOString( aModuleURL, RTL_TEXTENCODING_UTF8 ).getStr() ); - #endif - - /* TODO: originally the C++ wrapper for oslModule was used here, but that led to - mysterious crashes in the event loop (pointing to heap corruption). Why using - the C style oslModule should fix this is completely unknown. It may be that - we have just hidden the heap corruption a little more. - */ - oslModule aMod = osl_loadModule( aModuleURL.pData, SAL_LOADMODULE_DEFAULT ); - if( ! aMod ) - return 0; - - // check for at least the init function of a plugin - if( ! osl_getAsciiFunctionSymbol( aMod, "NP_Initialize") && - ! osl_getAsciiFunctionSymbol( aMod, "NP_GetEntryPoints" ) ) - { - return 0; - } - - // ask the plist of the bundle for mimetypes - nDescriptions = parsePlist( i_xBundle, aPlugURL, io_rDescriptions ); - if( nDescriptions ) - { - osl_unloadModule( aMod ); - return nDescriptions; - } - - // resolve the symbol that might get us the mimetypes - const char* (*pGetMimeDescription)() = (const char*(*)())osl_getAsciiFunctionSymbol( aMod, "_NP_GetMIMEDescription" ); - if( pGetMimeDescription ) - { - const char* pMime = pGetMimeDescription(); - if( pMime ) - { - nDescriptions = parseMimeString( aPlugURL, io_rDescriptions, pMime ); - if( nDescriptions ) - { - osl_unloadModule( aMod ); - return nDescriptions; - } - } - } - - // and as last resort check the resource of the bundle - nDescriptions = parseMimeResource( i_xBundle, aMod, aPlugURL, io_rDescriptions ); - osl_unloadModule( aMod ); - - return nDescriptions; -} - -// Unix specific implementation -static bool CheckPlugin( const rtl::OUString& rPath, list< PluginDescription* >& rDescriptions ) -{ -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "Trying path %s ... ", rtl::OUStringToOString( rPath, RTL_TEXTENCODING_UTF8 ).getStr() ); -#endif - CFURLRef xURL = createURL( rPath ); - - CFArrayRef xBundles = CFBundleCreateBundlesFromDirectory( NULL, xURL, CFSTR("plugin") ); - if( ! xBundles ) - return false; - - CFIndex nBundles = CFArrayGetCount( xBundles ); - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "got %d bundles\n", (int)nBundles ); -#endif - - int nDescriptions = 0; - for( CFIndex i = 0; i < nBundles; i++ ) - { - CFBundleRef xBundle = (CFBundleRef)CFArrayGetValueAtIndex( xBundles, i ); - nDescriptions += getPluginDescriptions( xBundle, rDescriptions ); - - CFRelease( xBundle ); - } - CFRelease( xBundles ); - - - return nDescriptions > 0; -} - -static rtl::OUString FindFolderURL( FSVolumeRefNum vRefNum, OSType folderType ) -{ - rtl::OUString aRet; - - FSRef aFSRef; - OSErr err = FSFindFolder( vRefNum, folderType, kDontCreateFolder, &aFSRef ); - if( err == noErr ) - { - CFURLRef xURL = CFURLCreateFromFSRef( NULL, &aFSRef ); - aRet = getString( xURL ); - CFRelease( xURL ); - } - - return aRet; -} - -Sequence<PluginDescription> XPluginManager_Impl::impl_getPluginDescriptions() throw(css::uno::RuntimeException, std::exception) -{ - static Sequence<PluginDescription> aDescriptions; - static sal_Bool bHavePlugins = sal_False; - if( ! bHavePlugins ) - { - std::list<PluginDescription*> aPlugins; - - static const char* pNPXPluginPath = getenv( "MOZ_PLUGIN_PATH" ); - - // get directories - std::list< rtl::OUString > aPaths; - if( pNPXPluginPath ) - { - CFMutableStringRef xMutableString = CFStringCreateMutable( NULL, 0 ); - CFStringAppendCString( xMutableString, pNPXPluginPath, kCFStringEncodingUTF8 ); - CFURLRef xURL = CFURLCreateWithFileSystemPath( NULL, xMutableString, kCFURLPOSIXPathStyle, true ); - CFRelease( xMutableString ); - aPaths.push_back( getString( xURL ) ); - CFRelease( xURL ); - } - - rtl::OUString aPath = FindFolderURL( kUserDomain, kInternetPlugInFolderType ); - if( aPath.getLength() ) - aPaths.push_back( aPath ); - aPath = FindFolderURL( kLocalDomain, kInternetPlugInFolderType ); - if( aPath.getLength() ) - aPaths.push_back( aPath ); - aPath = FindFolderURL( kOnAppropriateDisk, kInternetPlugInFolderType ); - if( aPath.getLength() ) - aPaths.push_back( aPath ); - - - const Sequence< ::rtl::OUString >& rPaths( PluginManager::getAdditionalSearchPaths() ); - for( sal_Int32 i = 0; i < rPaths.getLength(); i++ ) - { - aPaths.push_back( getURLFromPath( rPaths.getConstArray()[i] ) ); - } - - for( std::list< rtl::OUString >::const_iterator it = aPaths.begin(); it != aPaths.end(); ++it ) - { - rtl::OUString aPath( *it ); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "check path %s\n", rtl::OUStringToOString( *it, RTL_TEXTENCODING_UTF8 ).getStr() ); -#endif - CheckPlugin( aPath, aPlugins ); - } - - - // create return value - aDescriptions = Sequence<PluginDescription>( aPlugins.size() ); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "found %d plugins\n", (int)aPlugins.size() ); -#endif - list<PluginDescription*>::iterator iter; - sal_Int32 nPlug = 0; - for( iter = aPlugins.begin(); iter != aPlugins.end(); ++iter ) - { - aDescriptions.getArray()[ nPlug++ ] = **iter; - delete *iter; - } - aPlugins.clear(); - bHavePlugins = sal_True; - } - return aDescriptions; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/aqua/sysplug.mm b/extensions/source/plugin/aqua/sysplug.mm deleted file mode 100644 index a9b54a8ec2e1..000000000000 --- a/extensions/source/plugin/aqua/sysplug.mm +++ /dev/null @@ -1,882 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <config_lgpl.h> - -#include <cstdarg> - -#include <sys/types.h> -#include <signal.h> -#include <sys/wait.h> - -#include "premac.h" -#include <Cocoa/Cocoa.h> -#include "postmac.h" - -#include <osl/thread.h> - -#include <plugin/impl.hxx> - -extern NPNetscapeFuncs aNPNFuncs; - -#include <tools/debug.hxx> - -using namespace plugstringhelper; - -using ::rtl::OUString; -using ::rtl::OUStringToOString; - -#if OSL_DEBUG_LEVEL > 1 -void TRACE( char const * s ); -void TRACEN( char const * s, long n ); -#else -#define TRACE(x) -#define TRACEN(x,n) -#endif - - -struct SysPlugData -{ - MacPluginComm::NP_CGContext m_aCGContext; - NP_Port m_aNPPort; - NSView* m_pParentView; - NSView* m_pPlugView; - int m_nDrawingModel; - NSPoint m_aLastPlugViewOrigin; - bool m_bSetWindowOnDraw; - SysPlugData() - { - memset( this, 0, sizeof(*this) ); - } -}; - -std::shared_ptr<SysPlugData> CreateSysPlugData() -{ - return std::shared_ptr<SysPlugData>(new SysPlugData); -} - -void XPlugin_Impl::SetSysPlugDataParentView(SystemEnvData const& rEnvData) -{ - m_pSysPlugData->m_pParentView = rEnvData.mpNSView; -} - -extern "C" { - -void /*SAL_CALL NP_LOADDS*/ NPN_ForceRedraw_Impl(NPP instance) -{ - TRACE( "NPN_ForceRedraw_Impl" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( pImpl ) - { - SysPlugData& rPlugData( pImpl->getSysPlugData() ); - if( rPlugData.m_pPlugView ) - [rPlugData.m_pPlugView setNeedsDisplay: YES]; - } -} - -NPError /*SAL_CALL NP_LOADDS*/ NPN_SetValue_Impl( NPP instance, - NPPVariable variable, - void* value ) -{ - TRACE( "NPN_SetValue_Impl" ); - switch( variable ) - { - case (NPPVariable)1000: // NPNVpluginDrawingModel - { - // ugly, but that's the way we need to do it - int nDrawingModel = (int)value; - - TRACEN( "drawing model: ", nDrawingModel ); - XPlugin_Impl* pImpl = - XPluginManager_Impl::getXPluginFromNPP( instance ); - if (pImpl) - pImpl->getSysPlugData().m_nDrawingModel = nDrawingModel; - } - break; - default: - break; - } - return NPERR_NO_ERROR; -} - -} // extern "C" - -struct FakeEventRecord : public EventRecord -{ - FakeEventRecord() - { - memset( this, 0, sizeof(EventRecord) ); - ::GetGlobalMouse( &where ); - when = ::TickCount(); - modifiers = ::GetCurrentEventKeyModifiers(); - } -}; - - -@interface OOoPluginView : NSView -{ - XPlugin_Impl* m_pImpl; - MacPluginComm* m_pCom; -} --(id)initWithInstance: (XPlugin_Impl*)i_pImpl pluginComm: (MacPluginComm*)i_pCom frame: (NSRect)i_aRect; --(void)drawRect: (NSRect)i_aRect; --(BOOL)isOpaque; --(BOOL)isFlipped; - -// NSResponder --(void)mouseMoved: (NSEvent*)i_pEvent; --(void)mouseDown: (NSEvent*)i_pEvent; --(void)mouseDragged: (NSEvent*)i_pEvent; --(void)mouseUp: (NSEvent*)i_pEvent; --(void)rightMouseDown: (NSEvent*)i_pEvent; --(void)rightMouseDragged: (NSEvent*)i_pEvent; --(void)rightMouseUp: (NSEvent*)i_pEvent; --(void)otherMouseDown: (NSEvent*)i_pEvent; --(void)otherMouseDragged: (NSEvent*)i_pEvent; --(void)otherMouseUp: (NSEvent*)i_pEvent; --(void)mouseEntered: (NSEvent*)i_pEvent; --(void)mouseExited: (NSEvent*)i_pEvent; -@end - -@implementation OOoPluginView --(id)initWithInstance: (XPlugin_Impl*)i_pImpl pluginComm: (MacPluginComm*)i_pCom frame: (NSRect) i_aRect -{ - if( (self = [super initWithFrame: i_aRect]) ) - { - m_pImpl = i_pImpl; - m_pCom = i_pCom; - } - return self; -} - --(void)drawRect: (NSRect) i_aRect -{ - (void) i_aRect; // unused - m_pCom->drawView( m_pImpl ); -} - --(BOOL)isOpaque -{ - return NO; -} - --(BOOL)isFlipped -{ - return YES; -} - -// NSResponder --(void)mouseMoved: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - --(void)mouseDown: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = mouseDown; - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - --(void)mouseDragged: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - --(void)mouseUp: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = mouseUp; - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - --(void)rightMouseDown: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = mouseDown; - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - --(void)rightMouseDragged: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - --(void)rightMouseUp: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = mouseUp; - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - --(void)otherMouseDown: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = mouseDown; - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - --(void)otherMouseDragged: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - --(void)otherMouseUp: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = mouseUp; - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - --(void)mouseEntered: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - --(void)mouseExited: (NSEvent*)i_pEvent -{ - (void) i_pEvent; // unused - FakeEventRecord aRec; - aRec.what = aRec.what = osEvt + 18; // NPEventType_AdjustCursorEvent - m_pCom->NPP_HandleEvent( &m_pImpl->getNPPInstance(), &aRec ); -} - -@end - - -MacPluginComm::MacPluginComm( const rtl::OUString& i_rMimetype, const rtl::OUString& i_rBundle, NSView* i_pParent ) - : PluginComm( OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ) ), - m_xBundle( NULL ), - m_hPlugLib( NULL ), - m_pNullTimer( NULL ) -{ - (void) i_rMimetype; // unused - (void) i_pParent; // unused - // initialize plugin function table - memset( &m_aNPPfuncs, 0, sizeof( m_aNPPfuncs ) ); - - // load the bundle - CFURLRef xURL = createURL( i_rBundle ); - m_xBundle = CFBundleCreate( NULL, xURL ); - CFRelease( xURL ); - if( m_xBundle ) - { - // ask the plugin library - // first get its location - CFURLRef xLibURL = CFBundleCopyExecutableURL( m_xBundle ); - if( xLibURL ) - { - // get the file system path - rtl::OUString aModuleURL( CFURLtoOSLURL( xLibURL ) ); - CFRelease( xLibURL ); - m_hPlugLib = osl_loadModule( aModuleURL.pData, SAL_LOADMODULE_DEFAULT ); - #if OSL_DEBUG_LEVEL > 1 - if( ! m_hPlugLib ) - fprintf( stderr, "module %s could not be loaded\n", OUStringToOString( aModuleURL, RTL_TEXTENCODING_UTF8 ).getStr() ); - #endif - } - #if OSL_DEBUG_LEVEL > 1 - else - fprintf( stderr, "bundle %s has no exectutable URL\n", OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ).getStr() ); - #endif - } - else - { - #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "bundle %s could not be loaded\n", OUStringToOString( i_rBundle, RTL_TEXTENCODING_UTF8 ).getStr() ); - #endif - } - - DBG_ASSERT( m_xBundle && m_hPlugLib, "loading plugin bundle failed!" ); - - - m_aNPPfuncs.size = sizeof( m_aNPPfuncs ); - m_aNPPfuncs.version = 0; - - - m_eCall = eNP_Initialize; - execute(); -} - - -MacPluginComm::~MacPluginComm() -{ - if( m_hPlugLib ) - { - // NPP_Shutdown(); - NPError (*pShutdown)(); - if( retrieveFunction( "NP_Shutdown", (void**)&pShutdown ) ) - { - NPError nErr = (*pShutdown)(); (void)nErr; - DBG_ASSERT( nErr == NPERR_NO_ERROR, "NP_Shutdown() failed!" ); - } - osl_unloadModule( m_hPlugLib ); - } - if( m_xBundle ) - CFRelease( m_xBundle ); -} - - -sal_Bool MacPluginComm::retrieveFunction( const char* i_pName, void** o_ppFunc ) const -{ - if( ! m_hPlugLib || ! o_ppFunc ) - return sal_False; - - *o_ppFunc = (void*)osl_getAsciiFunctionSymbol( m_hPlugLib, i_pName ); - - if( ! *o_ppFunc && m_xBundle ) - { - rtl::OUString aName( OUString::createFromAscii( *i_pName == '_' ? i_pName+1 : i_pName ) ); - CFStringRef xName = createString( aName ); - if( xName ) - { - *o_ppFunc = CFBundleGetFunctionPointerForName( m_xBundle, xName ); - CFRelease( xName ); - } - } - - return (*o_ppFunc != NULL); -} - -IMPL_LINK_NOARG_TYPED(MacPluginComm, NullTimerHdl, Timer*, void) -{ - // note: this is a Timer handler, we are already protected by the SolarMutex - - FakeEventRecord aRec; - aRec.what = nullEvent; - aRec.where.h = aRec.where.v = 20000; - - for( std::list< XPlugin_Impl* >::iterator it = m_aNullEventClients.begin(); - it != m_aNullEventClients.end(); ++it ) - { - SysPlugData& rPlugData( (*it)->getSysPlugData() ); - if( rPlugData.m_pPlugView ) // for safety do not dispatch null events before first NPP_SetWindow - (*m_aNPPfuncs.event)( &(*it)->getNPPInstance(), &aRec ); - } -} - - - -long MacPluginComm::doIt() -{ - long nRet = 0; - switch( m_eCall ) - { - case eNP_Initialize: - { - TRACE( "eNP_Initialize" ); - NPError (*pInit)( NPNetscapeFuncs* ); - if( retrieveFunction( "NP_Initialize", (void**)&pInit ) ) - { - nRet = (*pInit)( &aNPNFuncs ); - - NPError nErr = NPERR_NO_ERROR; - NPError (*pEntry)( NPPluginFuncs* ); - retrieveFunction( "NP_GetEntryPoints", (void**)&pEntry ); - nErr = (*pEntry)( &m_aNPPfuncs ); - - DBG_ASSERT( nErr == NPERR_NO_ERROR, "NP_GetEntryPoints() failed!" ); - } - else - { - nRet = NPERR_GENERIC_ERROR; - } - DBG_ASSERT( nRet == NPERR_NO_ERROR, "### NP_Initialize() failed!" ); - } - break; - case eNPP_Destroy: - if( m_aNullEventClients.empty() ) - delete m_pNullTimer, m_pNullTimer = NULL; - - TRACE( "eNPP_Destroy" ); - nRet = (m_aNPPfuncs.destroy - ? (*m_aNPPfuncs.destroy)( - (NPP)m_aArgs[0], - (NPSavedData**)m_aArgs[1] ) - : NPERR_GENERIC_ERROR); - break; - case eNPP_DestroyStream: - TRACE( "eNPP_DestroyStream" ); - nRet = (m_aNPPfuncs.destroystream - ? (*m_aNPPfuncs.destroystream)( - (NPP)m_aArgs[0], - (NPStream*)m_aArgs[1], - (NPError)(sal_IntPtr)m_aArgs[2] ) - : NPERR_GENERIC_ERROR); - break; - case eNPP_New: - TRACE( "eNPP_New" ); - nRet = (m_aNPPfuncs.newp - ? (*m_aNPPfuncs.newp)( - (NPMIMEType)m_aArgs[0], - (NPP)m_aArgs[1], - (uint16_t)(sal_IntPtr)m_aArgs[2], - (int16_t)(sal_IntPtr)m_aArgs[3], - (char**)m_aArgs[4], - (char**)m_aArgs[5], - (NPSavedData*)m_aArgs[6] ) - : NPERR_GENERIC_ERROR); - - if( ! m_pNullTimer && m_aNPPfuncs.event ) - { - m_pNullTimer = new AutoTimer(); - m_pNullTimer->SetTimeout( 50 ); - m_pNullTimer->SetTimeoutHdl( LINK( this, MacPluginComm, NullTimerHdl ) ); - m_pNullTimer->Start(); - } - - break; - case eNPP_NewStream: - TRACE( "eNPP_NewStream" ); - nRet = (m_aNPPfuncs.newstream - ? (*m_aNPPfuncs.newstream)( - (NPP)m_aArgs[0], - (NPMIMEType)m_aArgs[1], - (NPStream*)m_aArgs[2], - (NPBool)(sal_IntPtr)m_aArgs[3], - (uint16_t*)m_aArgs[4] ) - : NPERR_GENERIC_ERROR); - break; - case eNPP_Print: - TRACE( "eNPP_Print" ); - if (m_aNPPfuncs.print) - (*m_aNPPfuncs.print)( - (NPP)m_aArgs[0], - (NPPrint*)m_aArgs[1] ); - break; - case eNPP_SetWindow: - { - TRACE( "eNPP_SetWindow" ); - nRet = (m_aNPPfuncs.setwindow - ? (*m_aNPPfuncs.setwindow)( - (NPP)m_aArgs[0], - (NPWindow*)m_aArgs[1] ) - : NPERR_GENERIC_ERROR); - - break; - } - case eNPP_HandleEvent: - { - TRACE( "eNPP_HandleEvent" ); - nRet = (m_aNPPfuncs.event - ? (*m_aNPPfuncs.event)( - (NPP)m_aArgs[0], - m_aArgs[1] ) - : NPERR_GENERIC_ERROR); - - break; - } - case eNPP_StreamAsFile: - TRACE( "eNPP_StreamAsFile" ); - if (m_aNPPfuncs.asfile) - (*m_aNPPfuncs.asfile)( - (NPP)m_aArgs[0], - (NPStream*)m_aArgs[1], - (char*)m_aArgs[2] ); - break; - case eNPP_URLNotify: - TRACE( "eNPP_URLNotify" ); - if (m_aNPPfuncs.urlnotify) - (*m_aNPPfuncs.urlnotify)( - (NPP)m_aArgs[0], - (char*)m_aArgs[1], - (NPReason)(sal_IntPtr)m_aArgs[2], - m_aArgs[3] ); - break; - case eNPP_Write: - TRACEN( "eNPP_Write n=", (int32_t)m_aArgs[3] ); - nRet = (m_aNPPfuncs.write - ? (*m_aNPPfuncs.write)( - (NPP)m_aArgs[0], - (NPStream*)m_aArgs[1], - (int32_t)m_aArgs[2], - (int32_t)m_aArgs[3], - m_aArgs[4] ) - : 0); - break; - case eNPP_WriteReady: - TRACE( "eNPP_WriteReady" ); - nRet = (m_aNPPfuncs.writeready - ? (*m_aNPPfuncs.writeready)( - (NPP)m_aArgs[0], - (NPStream*)m_aArgs[1] ) - : 0); - break; - case eNPP_GetValue: - TRACE( "eNPP_GetValue" ); - nRet = (m_aNPPfuncs.getvalue - ? (*m_aNPPfuncs.getvalue)( - (NPP)m_aArgs[0], - (NPPVariable)(int)m_aArgs[1], - m_aArgs[2] ) - : NPERR_GENERIC_ERROR); - break; - case eNPP_SetValue: - TRACE( "eNPP_SetValue" ); - nRet = (m_aNPPfuncs.setvalue - ? (*m_aNPPfuncs.setvalue)( - (NPP)m_aArgs[0], - (NPNVariable)(int)m_aArgs[1], - m_aArgs[2] ) - : NPERR_GENERIC_ERROR); - break; - case eNPP_Shutdown: - { - TRACE( "eNPP_Shutdown" ); - NPP_ShutdownUPP pFunc; - if (retrieveFunction( "NPP_Shutdown", (void**)&pFunc )) - (*pFunc)(); - } - break; - case eNPP_Initialize: - TRACE( "eNPP_Initialize" ); - OSL_FAIL( "NPP_Initialize: not implemented!" ); - break; - case eNPP_GetJavaClass: - TRACE( "eNPP_GetJavaClass" ); - OSL_FAIL( "NPP_GetJavaClass: not implemented!" ); - break; - } - return nRet; -} - - -NPError MacPluginComm::NPP_Destroy( XPlugin_Impl* i_pImpl, NPSavedData** save ) -{ - // remove from NullEvent timer - m_aNullEventClients.remove( i_pImpl ); - - NPError nErr = NPP_Destroy( &i_pImpl->getNPPInstance(), save ); - - // release plugin view - SysPlugData& rPlugData( i_pImpl->getSysPlugData() ); - if( rPlugData.m_pPlugView ) - { - [rPlugData.m_pPlugView removeFromSuperview]; - [rPlugData.m_pPlugView release]; - rPlugData.m_pPlugView = nil; - } - - return nErr; -} - - -NPError MacPluginComm::NPP_Destroy( NPP instance, NPSavedData** save ) -{ - DBG_ASSERT( m_aNPPfuncs.destroy, "### NPP_Destroy(): null pointer in NPP functions table!" ); - m_eCall = eNPP_Destroy; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)save; - return (NPError)execute(); -} - - -NPError MacPluginComm::NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ) -{ - DBG_ASSERT( m_aNPPfuncs.destroystream, "### NPP_DestroyStream(): null pointer in NPP functions table!" ); - m_eCall = eNPP_DestroyStream; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)stream; - m_aArgs[2] = (void*)(intptr_t)reason; - return (NPError)execute(); -} - - -NPError MacPluginComm::NPP_New( NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, - char* argn[], char* argv[], NPSavedData *saved ) -{ - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - DBG_ASSERT( pImpl, "no instance found" ); - - if( pImpl ) // sanity check - m_aNullEventClients.push_back( pImpl ); - - DBG_ASSERT( m_aNPPfuncs.newp, "### NPP_New(): null pointer in NPP functions table!" ); - #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "NPP_New( %s. %p, %d, %d", - pluginType, instance, (int)mode, (int)argc ); - for( int16_t i = 0; i < argc; i++ ) - fprintf( stderr, "\n%s = %s", argn[i], argv[i] ); - fprintf( stderr, ", %p )\n", saved ); - #endif - m_eCall = eNPP_New; - m_aArgs[0] = (void*)pluginType; - m_aArgs[1] = (void*)instance; - m_aArgs[2] = (void*)(intptr_t)mode; - m_aArgs[3] = (void*)(intptr_t)argc; - m_aArgs[4] = (void*)argn; - m_aArgs[5] = (void*)argv; - m_aArgs[6] = (void*)saved; - - return (NPError)execute(); -} - - -NPError MacPluginComm::NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, - NPBool seekable, uint16_t* stype ) -{ - DBG_ASSERT( m_aNPPfuncs.newstream, "### NPP_NewStream(): null pointer in NPP functions table!" ); - m_eCall = eNPP_NewStream; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)type; - m_aArgs[2] = (void*)stream; - m_aArgs[3] = (void*)(intptr_t)seekable; - m_aArgs[4] = (void*)stype; - return (NPError)execute(); -} - - -void MacPluginComm::NPP_Print( NPP instance, NPPrint* platformPrint ) -{ - DBG_ASSERT( m_aNPPfuncs.print, "### NPP_Print(): null pointer in NPP functions table!" ); - m_eCall = eNPP_Print; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)platformPrint; - execute(); -} - - -NPError MacPluginComm::NPP_SetWindow( NPP instance, NPWindow* window ) -{ - DBG_ASSERT( m_aNPPfuncs.setwindow, "### NPP_SetWindow(): null pointer in NPP functions table!" ); - m_eCall = eNPP_SetWindow; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)window; - return (NPError)execute(); -} - - -NPError MacPluginComm::NPP_HandleEvent( NPP instance, void* event ) -{ - DBG_ASSERT( m_aNPPfuncs.event, "### NPP_HandleEvent(): null pointer in NPP functions table!" ); - m_eCall = eNPP_HandleEvent; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = event; - return (NPError)execute(); -} - - -void MacPluginComm::NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ) -{ - DBG_ASSERT( m_aNPPfuncs.asfile, "### NPP_StreamAsFile(): null pointer in NPP functions table!" ); - m_eCall = eNPP_StreamAsFile; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)stream; - m_aArgs[2] = (void*)fname; - execute(); -} - - -void MacPluginComm::NPP_URLNotify( NPP instance, const char* url, NPReason reason, void* notifyData ) -{ - DBG_ASSERT( m_aNPPfuncs.urlnotify, "### NPP_URLNotify(): null pointer in NPP functions table!" ); - m_eCall = eNPP_URLNotify; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)url; - m_aArgs[2] = (void*)(intptr_t)reason; - m_aArgs[3] = notifyData; - execute(); -} - - -int32_t MacPluginComm::NPP_Write( NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer ) -{ - DBG_ASSERT( m_aNPPfuncs.write, "### NPP_Write(): null pointer in NPP functions table!" ); - m_eCall = eNPP_Write; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)stream; - m_aArgs[2] = (void*)offset; - m_aArgs[3] = (void*)len; - m_aArgs[4] = buffer; - return (NPError)execute(); -} - - -int32_t MacPluginComm::NPP_WriteReady( NPP instance, NPStream* stream ) -{ - DBG_ASSERT( m_aNPPfuncs.writeready, "### NPP_WriteReady(): null pointer in NPP functions table!" ); - m_eCall = eNPP_WriteReady; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)stream; - return execute(); -} - - -NPError MacPluginComm::NPP_GetValue( NPP instance, NPPVariable variable, void *ret_value ) -{ - DBG_ASSERT( m_aNPPfuncs.getvalue, "### NPP_GetValue(): null pointer in NPP functions table!" ); - m_eCall = eNPP_GetValue; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)variable; - m_aArgs[2] = ret_value; - return (NPError)execute(); -} - - -NPError MacPluginComm::NPP_Initialize() -{ - return NPERR_NO_ERROR; -} - - -void MacPluginComm::NPP_Shutdown() -{ - m_eCall = eNPP_Shutdown; - execute(); -} - - -NPError MacPluginComm::NPP_SetWindow( XPlugin_Impl* i_pImpl ) -{ - // update window NPWindow from view - SysPlugData& rPlugData( i_pImpl->getSysPlugData() ); - - // update plug view - NSRect aPlugRect = [rPlugData.m_pParentView frame]; - aPlugRect.origin.x = aPlugRect.origin.y = 0; - if( ! rPlugData.m_pPlugView ) - { - rPlugData.m_pPlugView = [[OOoPluginView alloc] initWithInstance: i_pImpl pluginComm: this frame: aPlugRect]; - [rPlugData.m_pParentView addSubview: rPlugData.m_pPlugView]; - } - else - [rPlugData.m_pPlugView setFrame: aPlugRect]; - - NPWindow* pNPWin = &i_pImpl->getNPWindow(); - NSWindow* pWin = [rPlugData.m_pPlugView window]; - NSRect aWinRect = [pWin frame]; - NSRect aBounds = [rPlugData.m_pPlugView frame]; - NSRect aVisibleBounds = [rPlugData.m_pPlugView visibleRect]; - - #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "visible bounds = %d+%d+%dx%d\n", - (int)aVisibleBounds.origin.x, (int)aVisibleBounds.origin.y, - (int)aVisibleBounds.size.width, (int)aVisibleBounds.size.height ); - #endif - - NSPoint aViewOrigin = [rPlugData.m_pPlugView convertPoint: NSZeroPoint toView: nil]; - // save view origin so we can notice movement of the view in drawView - // in case of a moved view we need to reset the port/context - rPlugData.m_aLastPlugViewOrigin = aViewOrigin; - - // convert view origin to topdown coordinates - aViewOrigin.y = aWinRect.size.height - aViewOrigin.y; - - // same for clipping - NSPoint aClipOrigin = [rPlugData.m_pPlugView convertPoint: aVisibleBounds.origin toView: nil]; - aClipOrigin.y = aWinRect.size.height - aClipOrigin.y; - - #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "view origin: %d+%d, clip origin = %d+%d\n", - (int)aViewOrigin.x, (int)aViewOrigin.y, - (int)aClipOrigin.x, (int)aClipOrigin.y ); - #endif - - pNPWin->x = aViewOrigin.x; - pNPWin->y = aViewOrigin.y; - pNPWin->width = aBounds.size.width; - pNPWin->height = aBounds.size.height; - pNPWin->clipRect.left = aClipOrigin.x; - pNPWin->clipRect.top = aClipOrigin.y; - pNPWin->clipRect.right = aClipOrigin.x + aVisibleBounds.size.width; - pNPWin->clipRect.bottom = aClipOrigin.y + aVisibleBounds.size.height; - - if( rPlugData.m_nDrawingModel == 1 ) - { - rPlugData.m_aCGContext.window = reinterpret_cast<WindowRef>([pWin windowRef]); - pNPWin->window = &rPlugData.m_aCGContext; - rPlugData.m_aCGContext.context = reinterpret_cast<CGContextRef>([[pWin graphicsContext] graphicsPort]); - #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "window is %p, context is %p\n", - rPlugData.m_aCGContext.window, rPlugData.m_aCGContext.context ); - #endif - } - else - { - rPlugData.m_aNPPort.port = GetWindowPort( reinterpret_cast<WindowRef>([pWin windowRef]) ); - rPlugData.m_aNPPort.portx = aClipOrigin.x; - rPlugData.m_aNPPort.porty = aClipOrigin.y; - pNPWin->window = &rPlugData.m_aNPPort; - #if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "port is %p at (%d,%d)\n", - rPlugData.m_aNPPort.port, (int)rPlugData.m_aNPPort.portx, (int)rPlugData.m_aNPPort.porty ); - #endif - } - - if( pNPWin->width == 0 || pNPWin->height == 0 || [rPlugData.m_pPlugView isHiddenOrHasHiddenAncestor] ) - rPlugData.m_bSetWindowOnDraw = true; - - NPError nErr = NPP_SetWindow( &i_pImpl->getNPPInstance(), &i_pImpl->getNPWindow() ); - - return nErr; -} - -void MacPluginComm::drawView( XPlugin_Impl* i_pImpl ) -{ - SysPlugData& rPlugData( i_pImpl->getSysPlugData() ); - - // check if the view was moved since the last SetWindow - NSPoint aViewOrigin = [rPlugData.m_pPlugView convertPoint: NSZeroPoint toView: nil]; - if( rPlugData.m_bSetWindowOnDraw || - aViewOrigin.x != rPlugData.m_aLastPlugViewOrigin.x || - aViewOrigin.y != rPlugData.m_aLastPlugViewOrigin.y ) - { - NPP_SetWindow( i_pImpl ); - rPlugData.m_bSetWindowOnDraw = false; - } - - // send a paint event - NSWindow* pWin = [rPlugData.m_pPlugView window]; - FakeEventRecord aRec; - aRec.what = updateEvt; - aRec.message = (uint32_t)[pWin windowRef]; - this->NPP_HandleEvent( &i_pImpl->getNPPInstance(), &aRec ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/context.cxx b/extensions/source/plugin/base/context.cxx deleted file mode 100644 index 478562aa7035..000000000000 --- a/extensions/source/plugin/base/context.cxx +++ /dev/null @@ -1,345 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#endif - -#include <cstdarg> -#include <cstdio> - -#include <plugin/impl.hxx> - -#include <sal/log.hxx> -#include <com/sun/star/frame/FrameSearchFlag.hpp> -#include <com/sun/star/frame/XComponentLoader.hpp> -#include <com/sun/star/uno/XComponentContext.hpp> -#include <com/sun/star/frame/Desktop.hpp> -#include <comphelper/fileurl.hxx> -#include <tools/urlobj.hxx> -#include <osl/file.hxx> - -#include <cppuhelper/implbase1.hxx> - -using namespace com::sun::star::io; -using namespace com::sun::star::frame; - -namespace ext_plug { - -class FileSink : public ::cppu::WeakAggImplHelper1< css::io::XOutputStream > -{ -private: - Reference< css::uno::XComponentContext > m_xContext; - FILE* fp; - Reference< css::plugin::XPlugin > m_xPlugin; - OUString m_aTarget; - OUString m_aFileName; - -public: - FileSink( const Reference< css::uno::XComponentContext > &, - const Reference< css::plugin::XPlugin > & plugin, - const OUString& target, - const Reference< css::io::XActiveDataSource > & source ); - virtual ~FileSink(); - - // css::io::XOutputStream - virtual void SAL_CALL writeBytes( const Sequence<sal_Int8>& ) throw(std::exception) override; - virtual void SAL_CALL flush() throw(std::exception) override; - virtual void SAL_CALL closeOutput() throw (RuntimeException, std::exception) override; -}; - -} -using namespace ext_plug; - -class XPluginContext_Impl : public ::cppu::WeakAggImplHelper1< css::plugin::XPluginContext > -{ - Reference< css::uno::XComponentContext > m_xContext; - rtl_TextEncoding m_aEncoding; -public: - - XPluginContext_Impl( const Reference< css::uno::XComponentContext > & ); - virtual ~XPluginContext_Impl(); - - - virtual OUString SAL_CALL getValue(const Reference< css::plugin::XPlugin > & plugin, css::plugin::PluginVariable variable) throw( css::plugin::PluginException, RuntimeException, std::exception ) override; - virtual void SAL_CALL getURLNotify(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Reference< css::lang::XEventListener > & listener) throw( css::plugin::PluginException, RuntimeException, std::exception ) override; - virtual void SAL_CALL getURL(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target) throw( css::plugin::PluginException, RuntimeException, std::exception ) override; - virtual void SAL_CALL postURLNotify(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file, const Reference< css::lang::XEventListener > & listener) throw( css::plugin::PluginException, RuntimeException, std::exception ) override; - virtual void SAL_CALL postURL(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file) throw( css::plugin::PluginException, RuntimeException, std::exception ) override; - virtual void SAL_CALL newStream(const Reference< css::plugin::XPlugin > & plugin, const OUString& mimetype, const OUString& target, const Reference< css::io::XActiveDataSource > & source) throw( css::plugin::PluginException, RuntimeException, std::exception ) override; - virtual void SAL_CALL displayStatusText(const Reference< css::plugin::XPlugin > & plugin, const OUString& message) throw( css::plugin::PluginException, RuntimeException, std::exception ) override; - virtual OUString SAL_CALL getUserAgent(const Reference< css::plugin::XPlugin > & plugin) throw( css::plugin::PluginException, RuntimeException, std::exception ) override; -}; - -Reference< css::plugin::XPluginContext > XPluginManager_Impl::createPluginContext() throw(std::exception) -{ - return new XPluginContext_Impl( m_xContext ); -} - -XPluginContext_Impl::XPluginContext_Impl( const Reference< css::uno::XComponentContext > & rxContext ) - : m_xContext( rxContext ), - m_aEncoding( osl_getThreadTextEncoding() ) -{ -} - -XPluginContext_Impl::~XPluginContext_Impl() -{ -} - -OUString XPluginContext_Impl::getValue( const Reference< css::plugin::XPlugin > & /*plugin*/, css::plugin::PluginVariable /*variable*/ ) - throw( css::plugin::PluginException, RuntimeException, std::exception ) -{ - return OUString(); -} - - -void XPluginContext_Impl::getURL(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target) throw( css::plugin::PluginException, RuntimeException, std::exception ) -{ - Reference< XDesktop2 > xDesktop = Desktop::create(m_xContext); - - if( target.isEmpty() ) - { - INetURLObject aURL; - aURL.SetSmartProtocol( INetProtocol::File ); - aURL.SetSmartURL( url ); - - OUString aUrl = aURL.GetMainURL(INetURLObject::DECODE_TO_IURI); - // the mimetype cannot be specified - plugin->provideNewStream( OUString(), - Reference< XActiveDataSource >(), - aUrl, - 0, 0, comphelper::isFileUrl(aUrl) ); - return; - } - - XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( plugin ); - - if( pPlugin ) - { - try - { - css::beans::PropertyValue aValue; - aValue.Name = "Referer"; - aValue.Value <<= pPlugin->getRefererURL(); - - Sequence< css::beans::PropertyValue > aArgs( &aValue, 1 ); - Reference< css::lang::XComponent > xComp = - xDesktop->loadComponentFromURL( - url, - target, - css::frame::FrameSearchFlag::PARENT | - css::frame::FrameSearchFlag::SELF | - css::frame::FrameSearchFlag::CHILDREN | - css::frame::FrameSearchFlag::SIBLINGS | - css::frame::FrameSearchFlag::TASKS | - css::frame::FrameSearchFlag::CREATE, - aArgs - ); - } - catch(...) - { - throw css::plugin::PluginException(); - } - } -} - -void XPluginContext_Impl::getURLNotify(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Reference< css::lang::XEventListener > & listener ) - throw( css::plugin::PluginException, RuntimeException, std::exception ) -{ - getURL( plugin, url, target ); - if( listener.is() ) - listener->disposing( css::lang::EventObject() ); -} - -OUString XPluginContext_Impl::getUserAgent(const Reference< css::plugin::XPlugin > & /*plugin*/) - throw( css::plugin::PluginException, RuntimeException, std::exception ) -{ - return OUString("Mozilla 3.0"); -} - -void XPluginContext_Impl::displayStatusText(const Reference< css::plugin::XPlugin > & /*plugin*/, const OUString& /*message*/) - throw( css::plugin::PluginException, RuntimeException, std::exception ) -{ -} - -void XPluginContext_Impl::postURL(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file) - throw( css::plugin::PluginException, RuntimeException, std::exception ) -{ - Sequence< sal_Int8 > aBuf; - - if( file ) - { - OUString aFileName( reinterpret_cast<char const *>(buf.getConstArray()), strlen(reinterpret_cast<char const *>(buf.getConstArray())), m_aEncoding ); - INetURLObject aFilePath( aFileName ); - aFileName = aFilePath.PathToFileName(); - SvFileStream aStream( aFileName, StreamMode::READ ); - if( aStream.IsOpen() ) - { - sal_Int64 const nBytes = aStream.remainingSize(); - aBuf = Sequence<sal_Int8>( nBytes ); - aStream.Read( aBuf.getArray(), nBytes ); - aStream.Close(); - osl::FileBase::getFileURLFromSystemPath( aFileName, aFileName ); - osl::File::remove( aFileName ); - } - } - - Reference< XDesktop2 > xDesktop = Desktop::create(m_xContext); - - XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( plugin ); - if( pPlugin ) - { - try - { - css::beans::PropertyValue aValues[2]; - aValues[0].Name = "Referer"; - aValues[0].Value <<= pPlugin->getRefererURL(); - - aValues[1].Name = "PostString"; - aValues[1].Value <<= OStringToOUString( reinterpret_cast<char const *>(( file ? aBuf : buf ).getConstArray()), m_aEncoding ); - Sequence< css::beans::PropertyValue > aArgs( aValues, 2 ); - Reference< css::lang::XComponent > xComp = - xDesktop->loadComponentFromURL( - url, - target, - css::frame::FrameSearchFlag::PARENT | - css::frame::FrameSearchFlag::SELF | - css::frame::FrameSearchFlag::CHILDREN | - css::frame::FrameSearchFlag::SIBLINGS | - css::frame::FrameSearchFlag::TASKS | - css::frame::FrameSearchFlag::CREATE, - aArgs - ); - } - catch( ... ) - { - throw css::plugin::PluginException(); - } - } -} - -void XPluginContext_Impl::postURLNotify(const Reference< css::plugin::XPlugin > & plugin, const OUString& url, const OUString& target, const Sequence< sal_Int8 >& buf, sal_Bool file, const Reference< css::lang::XEventListener > & listener ) - throw( css::plugin::PluginException, RuntimeException, std::exception ) -{ - postURL( plugin, url, target, buf, file ); - if( listener.is() ) - listener->disposing( css::lang::EventObject() ); -} - -void XPluginContext_Impl::newStream( const Reference< css::plugin::XPlugin > & plugin, const OUString&, const OUString& target, const Reference< css::io::XActiveDataSource > & source ) - throw( css::plugin::PluginException, RuntimeException, std::exception ) -{ - FileSink* pNewSink = new FileSink( m_xContext, plugin, target, source ); - pNewSink->acquire(); -} - - - -FileSink::FileSink( const Reference< css::uno::XComponentContext > & rxContext, const Reference< css::plugin::XPlugin > & plugin, - const OUString& target, const Reference< css::io::XActiveDataSource > & source ) : - m_xContext( rxContext ), - m_xPlugin( plugin ), - m_aTarget( target ) -{ - osl::FileBase::createTempFile( nullptr, nullptr, &m_aFileName ); - OString aFile = OUStringToOString( m_aFileName, osl_getThreadTextEncoding() ); - fp = fopen( aFile.getStr() , "wb" ); - - Reference< css::io::XActiveDataControl > xControl( source, UNO_QUERY ); - - source->setOutputStream( Reference< css::io::XOutputStream > ( this ) ); - if( xControl.is() ) - xControl->start(); -} - -FileSink::~FileSink() -{ - osl::File::remove( m_aFileName ); -} - -void FileSink::closeOutput() throw (RuntimeException, std::exception) -{ - if( fp ) - fclose( fp ); - - Reference< XDesktop2 > xDesktop = Desktop::create(m_xContext); - XPlugin_Impl* pPlugin = XPluginManager_Impl::getPluginImplementation( m_xPlugin ); - - if( pPlugin ) - { - try - { - css::beans::PropertyValue aValue; - aValue.Name = "Referer"; - aValue.Value <<= pPlugin->getRefererURL(); - - Sequence< css::beans::PropertyValue > aArgs( &aValue, 1 ); - Reference< css::lang::XComponent > xComp = - xDesktop->loadComponentFromURL( - m_aFileName, - m_aTarget, - css::frame::FrameSearchFlag::PARENT | - css::frame::FrameSearchFlag::SELF | - css::frame::FrameSearchFlag::CHILDREN | - css::frame::FrameSearchFlag::SIBLINGS | - css::frame::FrameSearchFlag::TASKS | - css::frame::FrameSearchFlag::CREATE, - aArgs - ); - } - catch( ... ) - { - } - } - release(); -} - -void FileSink::writeBytes( const Sequence<sal_Int8>& Buffer ) throw(std::exception) -{ - if( fp ) - { - size_t nItems = Buffer.getLength(); - bool bSuccess = (fwrite(Buffer.getConstArray(), 1, nItems, fp) == nItems); - SAL_WARN_IF( !bSuccess, "extensions.plugin", "short write"); - } -} - -void FileSink::flush() throw(std::exception) -{ - if( fp ) - fflush( fp ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/evtlstnr.cxx b/extensions/source/plugin/base/evtlstnr.cxx deleted file mode 100644 index ef865fdf6d04..000000000000 --- a/extensions/source/plugin/base/evtlstnr.cxx +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#endif - -#include <cstdarg> - -#include <plugin/impl.hxx> - -PluginEventListener::PluginEventListener( XPlugin_Impl* pPlugin, - const char* url, - const char* normurl, - void* notifyData ) : - m_pPlugin( pPlugin ), - m_xPlugin( pPlugin ), - m_pUrl( strdup( url ) ), - m_pNormalizedUrl( strdup( normurl ) ), - m_pNotifyData( notifyData ) -{ -} - -PluginEventListener::~PluginEventListener() -{ - if( m_pUrl ) - free( m_pUrl ); - if( m_pNormalizedUrl ) - free( m_pNormalizedUrl ); -} - -void PluginEventListener::disposing( const css::lang::EventObject& /*rEvt*/ ) throw(std::exception) -{ - m_pPlugin->getPluginComm()-> - NPP_URLNotify( &m_pPlugin->getNPPInstance(), - m_pUrl, - NPRES_DONE, - m_pNotifyData ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/manager.cxx b/extensions/source/plugin/base/manager.cxx deleted file mode 100644 index 21e354242acb..000000000000 --- a/extensions/source/plugin/base/manager.cxx +++ /dev/null @@ -1,234 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#endif - -#include <cstdarg> - -#include <comphelper/fileurl.hxx> -#include <comphelper/string.hxx> -#include <comphelper/processfactory.hxx> - -#include "plugin/impl.hxx" - -#include "osl/mutex.hxx" -#include "unotools/pathoptions.hxx" -#include "vcl/configsettings.hxx" - -#include "com/sun/star/container/XEnumerationAccess.hpp" -#include "com/sun/star/container/XNameAccess.hpp" -#include "com/sun/star/container/XEnumeration.hpp" -#include "com/sun/star/container/XElementAccess.hpp" -#include "com/sun/star/container/XIndexAccess.hpp" -#include "com/sun/star/loader/XImplementationLoader.hpp" - -#include <cppuhelper/supportsservice.hxx> - -PluginManager* PluginManager::pManager = nullptr; - -PluginManager& PluginManager::get() -{ - if( ! pManager ) - pManager = new PluginManager(); - return *pManager; -} - -void PluginManager::setServiceFactory( const Reference< css::lang::XMultiServiceFactory >& xFactory ) -{ - PluginManager& rManager = get(); - if( ! rManager.m_xSMgr.is() ) - rManager.m_xSMgr = xFactory; -} - -PluginManager::PluginManager() -{ -} - -const Sequence< OUString >& PluginManager::getAdditionalSearchPaths() -{ - static Sequence< OUString > aPaths; - - if( ! aPaths.getLength() ) - { - SvtPathOptions aOptions; - OUString aPluginPath( aOptions.GetPluginPath() ); - if( !aPluginPath.isEmpty() ) - { - sal_Int32 nPaths = comphelper::string::getTokenCount(aPluginPath, ';'); - aPaths.realloc( nPaths ); - for( sal_Int32 i = 0; i < nPaths; i++ ) - aPaths.getArray()[i] = aPluginPath.getToken(i, ';'); - } - } - - return aPaths; -} - - -Reference< XInterface > SAL_CALL PluginManager_CreateInstance( const Reference< css::lang::XMultiServiceFactory > & rSMgr ) throw( Exception ) -{ - Reference< XInterface > xService = *new XPluginManager_Impl( comphelper::getComponentContext(rSMgr) ); - return xService; -} - -// css::lang::XServiceInfo -OUString XPluginManager_Impl::getImplementationName() throw( ) - -{ - return getImplementationName_Static(); - -} - -// css::lang::XServiceInfo -sal_Bool XPluginManager_Impl::supportsService(const OUString& ServiceName) throw( ) -{ - return cppu::supportsService(this, ServiceName); -} - -// css::lang::XServiceInfo -Sequence< OUString > XPluginManager_Impl::getSupportedServiceNames() throw( ) -{ - return getSupportedServiceNames_Static(); -} - -// XPluginManager_Impl -Sequence< OUString > XPluginManager_Impl::getSupportedServiceNames_Static() throw( ) -{ - Sequence<OUString> aSNS { "com.sun.star.plugin.PluginManager" }; - return aSNS; -} - -XPluginManager_Impl::XPluginManager_Impl( const Reference< css::uno::XComponentContext > & rxContext ) -: m_xContext( rxContext ) -{ - PluginManager::setServiceFactory( Reference< css::lang::XMultiServiceFactory>(rxContext->getServiceManager(), UNO_QUERY_THROW) ); -} - -XPluginManager_Impl::~XPluginManager_Impl() -{ -} - -XPlugin_Impl* XPluginManager_Impl::getXPluginFromNPP( NPP instance ) -{ - ::std::list<XPlugin_Impl*>::iterator iter; - for( iter = PluginManager::get().getPlugins().begin(); - iter != PluginManager::get().getPlugins().end(); ++iter ) - { - if( &(*iter)->getNPPInstance() == instance ) - return *iter; - } - - return nullptr; -} - -XPlugin_Impl* XPluginManager_Impl::getPluginImplementation( const Reference< css::plugin::XPlugin >& plugin ) -{ - ::std::list<XPlugin_Impl*>::iterator iter; - for( iter = PluginManager::get().getPlugins().begin(); - iter != PluginManager::get().getPlugins().end(); ++iter ) - { - if( plugin == Reference< css::plugin::XPlugin >((*iter)) ) - return *iter; - } - - return nullptr; -} - -Sequence<css::plugin::PluginDescription> XPluginManager_Impl::getPluginDescriptions() - throw (RuntimeException, std::exception) -{ - Sequence<css::plugin::PluginDescription> aRet; - - vcl::SettingsConfigItem* pCfg = vcl::SettingsConfigItem::get(); - OUString aVal( pCfg->getValue( "BrowserPlugins", - "Disabled" ) ); - if( ! aVal.toBoolean() ) - { - aRet = impl_getPluginDescriptions(); - } - return aRet; -} - -Reference< css::plugin::XPlugin > XPluginManager_Impl::createPlugin( const Reference< css::plugin::XPluginContext >& acontext, sal_Int16 mode, const Sequence< OUString >& argn, const Sequence< OUString >& argv, const css::plugin::PluginDescription& plugintype) - throw( RuntimeException,css::plugin::PluginException, std::exception ) -{ - XPlugin_Impl* pImpl = new XPlugin_Impl( Reference< css::lang::XMultiServiceFactory>(m_xContext->getServiceManager(), UNO_QUERY_THROW) ); - pImpl->setPluginContext( acontext ); - - PluginManager::get().getPlugins().push_back( pImpl ); - - pImpl->initInstance( plugintype, - argn, - argv, - mode ); - - return pImpl; -} - -Reference< css::plugin::XPlugin > XPluginManager_Impl::createPluginFromURL( const Reference< css::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< OUString >& argn, const Sequence< OUString >& argv, const Reference< css::awt::XToolkit > & toolkit, const Reference< css::awt::XWindowPeer > & parent, const OUString& url ) throw (RuntimeException, std::exception) -{ - XPlugin_Impl* pImpl = new XPlugin_Impl( Reference< css::lang::XMultiServiceFactory>(m_xContext->getServiceManager(), UNO_QUERY_THROW) ); - Reference< css::plugin::XPlugin > xRef = pImpl; - - pImpl->setPluginContext( acontext ); - - PluginManager::get().getPlugins().push_back( pImpl ); - - - pImpl->initInstance( url, - argn, - argv, - mode ); - - pImpl->createPeer( toolkit, parent ); - - pImpl->provideNewStream( pImpl->getDescription().Mimetype, - Reference< css::io::XActiveDataSource >(), - url, - 0, 0, comphelper::isFileUrl(url) ); - - if( ! pImpl->getPluginComm() ) - { - pImpl->dispose(); - xRef = nullptr; - } - - return xRef; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/multiplx.cxx b/extensions/source/plugin/base/multiplx.cxx deleted file mode 100644 index faf41001285d..000000000000 --- a/extensions/source/plugin/base/multiplx.cxx +++ /dev/null @@ -1,333 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <osl/diagnose.h> -#include <plugin/multiplx.hxx> - - -// class MRCListenerMultiplexerHelper - -MRCListenerMultiplexerHelper::MRCListenerMultiplexerHelper -( - const Reference< css::awt::XWindow > & rControl - , const Reference< css::awt::XWindow > & rPeer -) - : xPeer( rPeer ) - , xControl( Reference< css::awt::XControl >( rControl, UNO_QUERY ) ) - , aListenerHolder( aMutex ) -{ -} - - -void MRCListenerMultiplexerHelper::setPeer( const Reference< css::awt::XWindow > & rPeer ) -{ - ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); - if( xPeer != rPeer ) - { - if( xPeer.is() ) - { - // get all uiks from the listener added to the peer - Sequence<Type> aContainedTypes = aListenerHolder.getContainedTypes(); - const Type* pArray = aContainedTypes.getConstArray(); - sal_Int32 nCount = aContainedTypes.getLength(); - // loop over all listener types and remove the listeners from the peer - for( sal_Int32 i = 0; i < nCount; i++ ) - unadviseFromPeer( xPeer, pArray[i] ); - } - xPeer = rPeer; - if( xPeer.is() ) - { - // get all uiks from the listener added to the peer - Sequence<Type> aContainedTypes = aListenerHolder.getContainedTypes(); - const Type * pArray = aContainedTypes.getConstArray(); - sal_Int32 nCount = aContainedTypes.getLength(); - // loop over all listener types and add the listeners to the peer - for( sal_Int32 i = 0; i < nCount; i++ ) - adviseToPeer( xPeer, pArray[i] ); - } - } -} - -// MRCListenerMultiplexerHelper -void MRCListenerMultiplexerHelper::disposeAndClear() -{ - css::lang::EventObject aEvt; - aEvt.Source = xControl; - aListenerHolder.disposeAndClear( aEvt ); -} - -// MRCListenerMultiplexerHelper -void MRCListenerMultiplexerHelper::adviseToPeer( const Reference< css::awt::XWindow > & rPeer, const Type & type ) -{ - // add a listener to the source (peer) - if( type == cppu::UnoType<css::awt::XWindowListener>::get()) - rPeer->addWindowListener( this ); - else if( type == cppu::UnoType<css::awt::XKeyListener>::get()) - rPeer->addKeyListener( this ); - else if( type == cppu::UnoType<css::awt::XFocusListener>::get()) - rPeer->addFocusListener( this ); - else if( type == cppu::UnoType<css::awt::XMouseListener>::get()) - rPeer->addMouseListener( this ); - else if( type == cppu::UnoType<css::awt::XMouseMotionListener>::get()) - rPeer->addMouseMotionListener( this ); - else if( type == cppu::UnoType<css::awt::XPaintListener>::get()) - rPeer->addPaintListener( this ); - else if( type == cppu::UnoType<css::awt::XTopWindowListener>::get()) - { - Reference< css::awt::XTopWindow > xTop( rPeer, UNO_QUERY ); - if( xTop.is() ) - xTop->addTopWindowListener( this ); - } - else - { - OSL_FAIL( "unknown listener" ); - } -} - -// MRCListenerMultiplexerHelper -void MRCListenerMultiplexerHelper::unadviseFromPeer( const Reference< css::awt::XWindow > & rPeer, const Type & type ) -{ - // the last listener is removed, remove the listener from the source (peer) - if( type == cppu::UnoType<css::awt::XWindowListener>::get()) - rPeer->removeWindowListener( this ); - else if( type == cppu::UnoType<css::awt::XKeyListener>::get()) - rPeer->removeKeyListener( this ); - else if( type == cppu::UnoType<css::awt::XFocusListener>::get()) - rPeer->removeFocusListener( this ); - else if( type == cppu::UnoType<css::awt::XMouseListener>::get()) - rPeer->removeMouseListener( this ); - else if( type == cppu::UnoType<css::awt::XMouseMotionListener>::get()) - rPeer->removeMouseMotionListener( this ); - else if( type == cppu::UnoType<css::awt::XPaintListener>::get()) - rPeer->removePaintListener( this ); - else if( type == cppu::UnoType<css::awt::XTopWindowListener>::get()) - { - Reference< css::awt::XTopWindow > xTop( rPeer, UNO_QUERY ); - if( xTop.is() ) - xTop->removeTopWindowListener( this ); - } - else - { - OSL_FAIL( "unknown listener" ); - } -} - -// MRCListenerMultiplexerHelper -void MRCListenerMultiplexerHelper::advise( const Type & type, const Reference< XInterface > & listener) -{ - ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); - if( 1 == aListenerHolder.addInterface( type, listener ) ) - { - // the first listener is added - if( xPeer.is() ) - adviseToPeer( xPeer, type ); - } -} - -// MRCListenerMultiplexerHelper -void MRCListenerMultiplexerHelper::unadvise(const Type & type, const Reference< XInterface > & listener) -{ - ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); - ::cppu::OInterfaceContainerHelper * pCont = aListenerHolder.getContainer( type ); - if( pCont ) - { - if( 0 == pCont->removeInterface( listener ) && xPeer.is() ) - // the last listener is removed - unadviseFromPeer( xPeer, type ); - } -} - -// css::lang::XEventListener -void MRCListenerMultiplexerHelper::disposing(const css::lang::EventObject& ) throw(std::exception) -{ - ::osl::Guard< ::osl::Mutex > aGuard( aMutex ); - // peer is disposed, clear the reference - xPeer.clear(); -} - -#define MULTIPLEX( InterfaceName, MethodName, EventName ) \ -::cppu::OInterfaceContainerHelper * pCont; \ -pCont = aListenerHolder.getContainer( cppu::UnoType< InterfaceName >::get()); \ -if( pCont ) \ -{ \ - ::cppu::OInterfaceIteratorHelper aIt( *pCont ); \ - EventName aEvt = e; \ - /* Remark: The control is the event source not the peer. We must change */ \ - /* the source of the event */ \ - aEvt.Source = xControl;\ - /*.is the control not destroyed */ \ - if( aEvt.Source.is() ) \ - { \ - if( aIt.hasMoreElements() ) \ - { \ - InterfaceName * pListener = static_cast<InterfaceName *>(aIt.next()); \ - try \ - { \ - pListener->MethodName( aEvt ); \ - } \ - catch(const RuntimeException&) \ - { \ - /* ignore all usr system exceptions from the listener */ \ - } \ - } \ - } \ -} - -// css::awt::XFocusListener -void MRCListenerMultiplexerHelper::focusGained(const css::awt::FocusEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XFocusListener, focusGained, css::awt::FocusEvent ) -} - -// css::awt::XFocusListener -void MRCListenerMultiplexerHelper::focusLost(const css::awt::FocusEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XFocusListener, focusLost, css::awt::FocusEvent ) -} - -// css::awt::XWindowListener -void MRCListenerMultiplexerHelper::windowResized(const css::awt::WindowEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XWindowListener, windowResized, css::awt::WindowEvent ) -} - -// css::awt::XWindowListener -void MRCListenerMultiplexerHelper::windowMoved(const css::awt::WindowEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XWindowListener, windowMoved, css::awt::WindowEvent ) -} - -// css::awt::XWindowListener -void MRCListenerMultiplexerHelper::windowShown(const css::lang::EventObject& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XWindowListener, windowShown, css::lang::EventObject ) -} - -// css::awt::XWindowListener -void MRCListenerMultiplexerHelper::windowHidden(const css::lang::EventObject& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XWindowListener, windowHidden, css::lang::EventObject ) -} - -// css::awt::XKeyListener -void MRCListenerMultiplexerHelper::keyPressed(const css::awt::KeyEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XKeyListener, keyPressed, css::awt::KeyEvent ) -} - -// css::awt::XKeyListener -void MRCListenerMultiplexerHelper::keyReleased(const css::awt::KeyEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XKeyListener, keyReleased, css::awt::KeyEvent ) -} - -// css::awt::XMouseListener -void MRCListenerMultiplexerHelper::mousePressed(const css::awt::MouseEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XMouseListener, mousePressed, css::awt::MouseEvent ) -} - -// css::awt::XMouseListener -void MRCListenerMultiplexerHelper::mouseReleased(const css::awt::MouseEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XMouseListener, mouseReleased, css::awt::MouseEvent ) -} - -// css::awt::XMouseListener -void MRCListenerMultiplexerHelper::mouseEntered(const css::awt::MouseEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XMouseListener, mouseEntered, css::awt::MouseEvent ) -} - -// css::awt::XMouseListener -void MRCListenerMultiplexerHelper::mouseExited(const css::awt::MouseEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XMouseListener, mouseExited, css::awt::MouseEvent ) -} - -// css::awt::XMouseMotionListener -void MRCListenerMultiplexerHelper::mouseDragged(const css::awt::MouseEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XMouseMotionListener, mouseDragged, css::awt::MouseEvent ) -} - -// css::awt::XMouseMotionListener -void MRCListenerMultiplexerHelper::mouseMoved(const css::awt::MouseEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XMouseMotionListener, mouseMoved, css::awt::MouseEvent ) -} - -// css::awt::XPaintListener -void MRCListenerMultiplexerHelper::windowPaint(const css::awt::PaintEvent& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XPaintListener, windowPaint, css::awt::PaintEvent ) -} - -// css::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowOpened(const css::lang::EventObject& e) throw(std::exception) -{ - MULTIPLEX( css::awt::XTopWindowListener, windowOpened, css::lang::EventObject ) -} - -// css::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowClosing( const css::lang::EventObject& e ) throw(std::exception) -{ - MULTIPLEX( css::awt::XTopWindowListener, windowClosing, css::lang::EventObject ) -} - -// css::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowClosed( const css::lang::EventObject& e ) throw(std::exception) -{ - MULTIPLEX( css::awt::XTopWindowListener, windowClosed, css::lang::EventObject ) -} - -// css::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowMinimized( const css::lang::EventObject& e ) throw(std::exception) -{ - MULTIPLEX( css::awt::XTopWindowListener, windowMinimized, css::lang::EventObject ) -} - -// css::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowNormalized( const css::lang::EventObject& e ) throw(std::exception) -{ - MULTIPLEX( css::awt::XTopWindowListener, windowNormalized, css::lang::EventObject ) -} - -// css::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowActivated( const css::lang::EventObject& e ) throw(std::exception) -{ - MULTIPLEX( css::awt::XTopWindowListener, windowActivated, css::lang::EventObject ) -} - -// css::awt::XTopWindowListener -void MRCListenerMultiplexerHelper::windowDeactivated( const css::lang::EventObject& e ) throw(std::exception) -{ - MULTIPLEX( css::awt::XTopWindowListener, windowDeactivated, css::lang::EventObject ) -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/nfuncs.cxx b/extensions/source/plugin/base/nfuncs.cxx deleted file mode 100644 index 21dbb45324dd..000000000000 --- a/extensions/source/plugin/base/nfuncs.cxx +++ /dev/null @@ -1,644 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#endif - -#include <cstdarg> -#include <list> - -#include <plugin/impl.hxx> -#include <vcl/svapp.hxx> -#include <memory> - -#if OSL_DEBUG_LEVEL > 1 -#include <osl/thread.h> -#include <osl/thread.hxx> -#include <stdio.h> -static FILE * s_file = 0; -void TRACE( char const * s ) -{ - if (! s_file) - s_file = stderr; - if (s_file) - { - oslThreadIdentifier t = osl::Thread::getCurrentIdentifier(); - fprintf( s_file, "log [t_id=%" SAL_PRIuUINT32 "]: %s\n", t, s ); - fflush( s_file ); - } -} -void TRACEN( char const * s, long n ) -{ - if (! s_file) - s_file = stderr; - if (s_file) - { - oslThreadIdentifier t = osl::Thread::getCurrentIdentifier(); - fprintf( s_file, "log [t_id=%" SAL_PRIuUINT32 "]: %s%ld\n", t, s, n ); - fflush( s_file ); - } -} -void TRACES( char const* s, char const* s2 ) -{ - if (! s_file) - s_file = stderr; - if (s_file) - { - oslThreadIdentifier t = osl::Thread::getCurrentIdentifier(); - fprintf( s_file, "log [t_id=%" SAL_PRIuUINT32 "]: %s %s\n", t, s, s2 ); - fflush( s_file ); - } -} -#else -#define TRACE(x) -#define TRACEN(x,n) -#define TRACES(x,s) -#endif - -using namespace com::sun::star::lang; - - -// Move deprecated functions which no longer appear in npapi.h before -// their use to avoid errors that they're undeclared at point of use -extern "C" -{ - const JRIEnvInterface** SAL_CALL NP_LOADDS NPN_GetJavaEnv() - { - TRACE( "NPN_GetJavaEnv" ); - // no java in this program - return nullptr; - } - - jref SAL_CALL NP_LOADDS NPN_GetJavaPeer( NPP /*instance*/ ) - { - TRACE( "NPN_GetJavaPeer" ); - return nullptr; - } -} - -NPNetscapeFuncs aNPNFuncs = -{ - sizeof( NPNetscapeFuncs ), - (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR, - NPN_GetURL, - NPN_PostURL, - NPN_RequestRead, - NPN_NewStream, - NPN_Write, - NPN_DestroyStream, - NPN_Status, - NPN_UserAgent, - NPN_MemAlloc, - NPN_MemFree, - NPN_MemFlush, - NPN_ReloadPlugins, - NPN_GetJavaEnv, - NPN_GetJavaPeer, - NPN_GetURLNotify, - NPN_PostURLNotify, - NPN_GetValue, - NPN_SetValue, - NPN_InvalidateRect, - NPN_InvalidateRegion, - NPN_ForceRedraw -}; - -static OString normalizeURL( XPlugin_Impl* plugin, const OString& url ) -{ - OString aLoadURL; - if( url.indexOf( ':' ) == -1 ) - { - aLoadURL = OUStringToOString( plugin->getCreationURL(), plugin->getTextEncoding() ); - int nPos; - if( ( nPos = aLoadURL.indexOf( "://" ) ) != -1 ) - { - if( url.indexOf( '/' ) != -1 ) - { - // this means same server but new path - nPos = aLoadURL.indexOf( '/', nPos+3 ); - - if( nPos != -1 ) - aLoadURL = aLoadURL.copy( 0, url.startsWith("/") ? nPos : nPos+1 ); - } - else - { - // same server but new file - nPos = aLoadURL.lastIndexOf( '/' ); - aLoadURL = aLoadURL.copy( 0, nPos+1 ); - } - aLoadURL += url; - } - else - aLoadURL = url; - } - else if( url.indexOf( ":/" ) != -1 ) - aLoadURL = url; - - return aLoadURL; -} - -struct AsynchronousGetURL -{ - OUString aUrl; - OUString aTarget; - Reference< XEventListener > xListener; - - DECL_LINK_TYPED( getURL, void*, void ); -}; - -IMPL_LINK_TYPED( AsynchronousGetURL, getURL, void*, p, void ) -{ - XPlugin_Impl* pImpl = static_cast<XPlugin_Impl*>(p); - try - { - pImpl->enterPluginCallback(); - if( xListener.is() ) - pImpl->getPluginContext()-> - getURLNotify( pImpl, - aUrl, - aTarget, - xListener ); - else - pImpl->getPluginContext()-> - getURL( pImpl, - aUrl, - aTarget ); - } - catch(const css::plugin::PluginException&) - { - } - pImpl->leavePluginCallback(); - delete this; -} - - -extern "C" { - - void* SAL_CALL NP_LOADDS NPN_MemAlloc( uint32_t nBytes ) - { - TRACE( "NPN_MemAlloc" ); - void* pMem = malloc( nBytes ); - return pMem; - } - - void SAL_CALL NP_LOADDS NPN_MemFree( void* pMem ) - { - TRACE( "NPN_MemFree" ); - free( pMem ); - } - - uint32_t SAL_CALL NP_LOADDS NPN_MemFlush( uint32_t /*nSize*/ ) - { - TRACE( "NPN_MemFlush" ); - return 0; - } - - NPError SAL_CALL NP_LOADDS NPN_DestroyStream( NPP instance, NPStream* stream, NPError /*reason*/ ) - { - TRACE( "NPN_DestroyStream" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - PluginStream* pStream = pImpl->getStreamFromNPStream( stream ); - if( pStream ) - { - if( pStream->getStreamType() == InputStream ) - static_cast<PluginInputStream*>(pStream)->releaseSelf(); - else - delete pStream; - } - - return NPERR_NO_ERROR; - } - - NPError SAL_CALL NP_LOADDS NPN_GetURL( NPP instance, const char* url, const char* window ) - { - TRACES( "NPN_GetURL", url ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - AsynchronousGetURL* pAsync = new AsynchronousGetURL(); - - OString aLoadURL = normalizeURL( pImpl, url ); - TRACES( "NPN_GetURL", aLoadURL.getStr() ); - pAsync->aUrl = OStringToOUString( aLoadURL, pImpl->getTextEncoding() ); - pAsync->aTarget = OStringToOUString( window, pImpl->getTextEncoding() ); - pImpl->setLastGetUrl( aLoadURL ); - Application::PostUserEvent( LINK( pAsync, AsynchronousGetURL, getURL ), pImpl ); - return NPERR_NO_ERROR; - } - - NPError SAL_CALL NP_LOADDS NPN_GetURLNotify( NPP instance, const char* url, const char* target, - void* notifyData ) - { - TRACES( "NPN_GetURLNotify", url ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - OString aLoadURL = normalizeURL( pImpl, url ); - if( aLoadURL.isEmpty() ) - return NPERR_INVALID_URL; - - AsynchronousGetURL* pAsync = new AsynchronousGetURL(); - PluginEventListener* pListener = - new PluginEventListener( pImpl, url, aLoadURL.getStr(), notifyData ); - if( ! target || ! *target ) - { - // stream will be fed back to plugin, - // notify immediately after destruction of stream - pImpl->addPluginEventListener( pListener ); - pListener = nullptr; - } - pAsync->aUrl = OStringToOUString( aLoadURL, pImpl->getTextEncoding() ); - pAsync->aTarget = OStringToOUString( target, pImpl->getTextEncoding() ); - pAsync->xListener = pListener; - pImpl->setLastGetUrl( aLoadURL ); - Application::PostUserEvent( LINK( pAsync, AsynchronousGetURL, getURL ), pImpl ); - - return NPERR_NO_ERROR; - } - - NPError SAL_CALL NP_LOADDS NPN_NewStream( NPP instance, NPMIMEType type, const char* target, - NPStream** stream ) - // stream is a return value - { - TRACE( "NPN_NewStream" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - PluginOutputStream* pStream = new PluginOutputStream( pImpl, - "", 0, 0 ); - *stream = &pStream->getStream(); - - try - { - pImpl->enterPluginCallback(); - pImpl->getPluginContext()-> - newStream( - pImpl, - OStringToOUString( type, pImpl->getTextEncoding () ), - OStringToOUString( target, pImpl->getTextEncoding() ), - css::uno::Reference< css::io::XActiveDataSource > ( pStream->getOutputStream(), UNO_QUERY ) - ); - pImpl->leavePluginCallback(); - } - catch( const css::plugin::PluginException& e ) - { - pImpl->leavePluginCallback(); - return e.ErrorCode; - } - - return NPERR_NO_ERROR; - } - - NPError SAL_CALL NP_LOADDS NPN_PostURLNotify( NPP instance, const char* url, const char* target, uint32_t len, const char* buf, NPBool file, void* notifyData ) - { - TRACE( "NPN_PostURLNotify" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - css::uno::Sequence<sal_Int8> Bytes( reinterpret_cast<sal_Int8 const *>(buf), len ); - - OString aPostURL = normalizeURL( pImpl, url ); - PluginEventListener* pListener = - new PluginEventListener( pImpl, url, aPostURL.getStr(), notifyData ); - - if( ! target || ! *target ) - { - // stream will be fed back to plugin, - // notify immediately after destruction of stream - pImpl->addPluginEventListener( pListener ); - pListener = nullptr; - } - - try - { - pImpl->enterPluginCallback(); - pImpl->getPluginContext()-> - postURLNotify( pImpl, - OStringToOUString( aPostURL, pImpl->getTextEncoding() ), - OStringToOUString( target, pImpl->getTextEncoding() ), - Bytes, - file, - css::uno::Reference< css::lang::XEventListener > ( pListener ) ); - pImpl->leavePluginCallback(); - } - catch( const css::plugin::PluginException& e ) - { - pImpl->leavePluginCallback(); - return e.ErrorCode; - } - - return NPERR_NO_ERROR; - } - - NPError SAL_CALL NP_LOADDS NPN_PostURL( NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file ) - { - TRACE( "NPN_PostURL" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return NPERR_INVALID_INSTANCE_ERROR; - - css::uno::Sequence<sal_Int8> Bytes( reinterpret_cast<sal_Int8 const *>(buf), len ); - OString aPostURL = normalizeURL( pImpl, url ); - try - { - pImpl->enterPluginCallback(); - pImpl->getPluginContext()-> - postURL( pImpl, - OStringToOUString( aPostURL, pImpl->getTextEncoding() ), - OStringToOUString( window, pImpl->getTextEncoding () ), - Bytes, - file ); - pImpl->leavePluginCallback(); - } - catch( const css::plugin::PluginException& e ) - { - pImpl->leavePluginCallback(); - return e.ErrorCode; - } - - return NPERR_NO_ERROR; - } - - NPError SAL_CALL NP_LOADDS NPN_RequestRead( NPStream* stream, NPByteRange* rangeList ) - { - TRACE( "NPN_RequestRead" ); - if( ! rangeList ) - return NPERR_NO_ERROR; - - ::std::list<XPlugin_Impl*>& rList = PluginManager::get().getPlugins(); - ::std::list<XPlugin_Impl*>::iterator iter; - XPlugin_Impl* pPlugin = nullptr; - PluginStream* pStream = nullptr; - for( iter = rList.begin(); iter!= rList.end(); ++iter ) - { - pStream = (*iter)->getStreamFromNPStream( stream ); - if( pStream ) - { - pPlugin = *iter; - break; - } - } - if( ! pPlugin ) - return NPERR_INVALID_INSTANCE_ERROR; - if( ! pStream || pStream->getStreamType() != InputStream ) - return NPERR_FILE_NOT_FOUND; - - PluginInputStream* pInputStream = static_cast<PluginInputStream*>(pStream); - std::unique_ptr<sal_Int8[]> pBytes; - int nBytes = 0; - pPlugin->enterPluginCallback(); - while( rangeList ) - { - if( pBytes && nBytes < (int)rangeList->length ) - pBytes.reset(); - if( ! pBytes ) { - nBytes = rangeList->length; - pBytes.reset(new sal_Int8[ nBytes ]); - } - int nRead = - pInputStream->read( rangeList->offset, pBytes.get(), rangeList->length ); - int nPos = 0; - int nNow; - do - { - nNow = pPlugin->getPluginComm()-> - NPP_WriteReady( &pPlugin->getNPPInstance(), - stream ); - nNow = pPlugin->getPluginComm()-> - NPP_Write( &pPlugin->getNPPInstance(), - stream, - rangeList->offset + nPos, - nNow, - pBytes.get()+nPos ); - nPos += nNow; - nRead -= nNow; - } while( nRead > 0 && nNow ); - rangeList = rangeList->next; - } - pPlugin->leavePluginCallback(); - - return NPERR_NO_ERROR; - } - - void SAL_CALL NP_LOADDS NPN_Status( NPP instance, const char* message ) - { - TRACE( "NPN_Status" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return; - - try - { - pImpl->enterPluginCallback(); - pImpl->getPluginContext()-> - displayStatusText( pImpl, OStringToOUString( message, pImpl->getTextEncoding() ) ); - pImpl->leavePluginCallback(); - } - catch( const css::plugin::PluginException& ) - { - pImpl->leavePluginCallback(); - return; - } - } - - const char* SAL_CALL NP_LOADDS NPN_UserAgent( NPP instance ) - { - static char* pAgent = strdup( "Mozilla 3.0" ); - - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( pImpl ) - { - OUString UserAgent; - try - { - pImpl->enterPluginCallback(); - UserAgent = pImpl->getPluginContext()-> - getUserAgent( pImpl ); - pImpl->leavePluginCallback(); - if( pAgent ) - free( pAgent ); - pAgent = strdup( OUStringToOString( UserAgent, pImpl->getTextEncoding() ).getStr() ); - } - catch( const css::plugin::PluginException& ) - { - pImpl->leavePluginCallback(); - } - } - - TRACES( "NPN_UserAgent: returning", pAgent ); - - return pAgent; - } - -void SAL_CALL NP_LOADDS NPN_Version( int* major, int* minor, int* net_major, int* net_minor ) -{ - TRACE( "NPN_Version" ); - *major = 4; - *minor = 0; - *net_major = 4; - *net_minor = 5; -} - -int32_t SAL_CALL NP_LOADDS NPN_Write( NPP instance, NPStream* stream, int32_t len, - void* buffer ) -{ - TRACE( "NPN_Write" ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - if( ! pImpl ) - return 0; - - PluginStream* pStream = pImpl->getStreamFromNPStream( stream ); - if( ! pStream || pStream->getStreamType() != OutputStream ) - return 0; - - pImpl->enterPluginCallback(); - css::uno::Sequence<sal_Int8> Bytes( static_cast<sal_Int8*>(buffer), len ); - static_cast<PluginOutputStream*>(pStream)->getOutputStream()->writeBytes( Bytes ); - pImpl->leavePluginCallback(); - - return len; -} - - -NPError SAL_CALL NP_LOADDS NPN_GetValue( NPP instance, NPNVariable variable, void* value ) -{ - TRACEN( "NPN_GetValue: ", variable ); - XPlugin_Impl* pImpl = XPluginManager_Impl::getXPluginFromNPP( instance ); - - if( ! pImpl ) - return 0; - - NPError aResult( NPERR_NO_ERROR ); - - switch( variable ) - { - case NPNVxDisplay: - // Unix only, handled in sysdep part - case NPNVxtAppContext: - // Unix only, handled in sysdep part - default: - aResult = NPERR_INVALID_PARAM; - break; - #ifdef MACOSX - case 2000: // NPNVsupportsQuickDrawBool - *(NPBool*)value = false; - break; - case 2001: // NPNVsupportsCoreGraphicsBool - *(NPBool*)value = true; - break; - #endif - case NPNVjavascriptEnabledBool: - // no javascript - *static_cast<NPBool*>(value) = false; - break; - case NPNVasdEnabledBool: - // no SmartUpdate - *static_cast<NPBool*>(value) = false; - break; - case NPNVisOfflineBool: - // no offline browsing - *static_cast<NPBool*>(value) = false; - break; - } - - return aResult; -} - -void SAL_CALL NP_LOADDS NPN_ReloadPlugins(NPBool /*reloadPages*/) -{ - TRACE( "NPN_ReloadPlugins" ); -} - - -NPError SAL_CALL NP_LOADDS NPN_SetValue( NPP instance, - NPPVariable variable, - void* value ) -{ - NPError nError = NPERR_NO_ERROR; - TRACEN( "NPN_SetValue ", variable ); - #ifdef MACOSX - NPN_SetValue_Impl(instance, variable, value); - #else - (void)instance; - (void)variable; - (void)value; - #endif - return nError; -} - -void SAL_CALL NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect* /*invalidRect*/) -{ - TRACE( "NPN_InvalidateRect" ); - - #ifdef MACOSX - NPN_ForceRedraw( instance ); - #else - (void)instance; - #endif -} - -void SAL_CALL NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion /*invalidRegion*/) -{ - TRACE( "NPN_InvalidateRegion" ); - - #ifdef MACOSX - NPN_ForceRedraw( instance ); - #else - (void)instance; - #endif -} - -void SAL_CALL NP_LOADDS NPN_ForceRedraw(NPP instance) -{ - TRACE( "NPN_ForceRedraw" ); - #ifdef MACOSX - NPN_ForceRedraw_Impl(instance); - #else - (void)instance; - #endif -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/plcom.cxx b/extensions/source/plugin/base/plcom.cxx deleted file mode 100644 index c5c620624488..000000000000 --- a/extensions/source/plugin/base/plcom.cxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#endif - -#ifdef SOLARIS -#include <limits> -#endif - -#include <cstdarg> - -#include <osl/file.hxx> -#include <plugin/impl.hxx> - -PluginComm::PluginComm( const OString& rLibName, bool bReusable ) : - m_nRefCount( 0 ), - m_aLibName( rLibName ) -{ - if( bReusable ) - PluginManager::get().getPluginComms().push_back( this ); -} - -PluginComm::~PluginComm() -{ - PluginManager::get().getPluginComms().remove( this ); - while( m_aFilesToDelete.size() ) - { - OUString aFile( m_aFilesToDelete.front() ); - m_aFilesToDelete.pop_front(); - osl::FileBase::getFileURLFromSystemPath( aFile, aFile ); - osl::File::remove( aFile ); - } -} - -NPError PluginComm::NPP_SetWindow( XPlugin_Impl* i_pImpl ) -{ - return NPP_SetWindow( &i_pImpl->getNPPInstance(), &i_pImpl->getNPWindow() ); -} - -NPError PluginComm::NPP_Destroy( XPlugin_Impl* i_pImpl, NPSavedData** save ) -{ - return NPP_Destroy( &i_pImpl->getNPPInstance(), save ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/plctrl.cxx b/extensions/source/plugin/base/plctrl.cxx deleted file mode 100644 index 918715599d4f..000000000000 --- a/extensions/source/plugin/base/plctrl.cxx +++ /dev/null @@ -1,322 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <com/sun/star/awt/XAdjustmentListener.hpp> -#include <com/sun/star/awt/XActionListener.hpp> -#include <com/sun/star/awt/XTextListener.hpp> -#include <com/sun/star/awt/XSpinListener.hpp> -#include <com/sun/star/awt/XItemListener.hpp> -#include <com/sun/star/awt/XVclContainerListener.hpp> -#include <com/sun/star/awt/PosSize.hpp> - -#include <plugin/plctrl.hxx> -#include <vcl/syschild.hxx> -#include <toolkit/helper/vclunohelper.hxx> - -PluginControl_Impl::PluginControl_Impl() - : _pMultiplexer( nullptr ) - , _nX( 0 ) - , _nY( 0 ) - , _nWidth( 100 ) - , _nHeight( 100 ) - , _nFlags( css::awt::PosSize::POSSIZE ) - , _bVisible(false) - , _bInDesignMode(false) - , _bEnable(true) - , _pSysChild(nullptr) -{ -} - -PluginControl_Impl::~PluginControl_Impl() -{ -} - -MRCListenerMultiplexerHelper* PluginControl_Impl::getMultiplexer() -{ - if( ! _pMultiplexer ) - _pMultiplexer = new MRCListenerMultiplexerHelper( this, _xPeerWindow ); - return _pMultiplexer; -} - - -void PluginControl_Impl::addEventListener( const Reference< css::lang::XEventListener > & l ) - throw( RuntimeException, std::exception ) -{ - _aDisposeListeners.push_back( l ); -} - -//---- css::lang::XComponent ---------------------------------------------------------------------------------- -void PluginControl_Impl::removeEventListener( const Reference< css::lang::XEventListener > & l ) - throw( RuntimeException, std::exception ) -{ - _aDisposeListeners.remove( l ); -} - -//---- css::lang::XComponent ---------------------------------------------------------------------------------- -void PluginControl_Impl::dispose() - throw( RuntimeException, std::exception ) -{ - // send disposing events - css::lang::EventObject aEvt; - if( getMultiplexer() ) - getMultiplexer()->disposeAndClear(); - - // release context - _xContext.clear(); - releasePeer(); -} - - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) - throw( RuntimeException, std::exception ) -{ - _nX = nX_ >=0 ? nX_ : 0; - _nY = nY_ >=0 ? nY_ : 0; - _nWidth = nWidth_ >=0 ? nWidth_ : 0; - _nHeight = nHeight_ >=0 ? nHeight_ : 0; - _nFlags = nFlags; - - if (_xPeerWindow.is()) - _xPeerWindow->setPosSize( _nX, _nY, _nWidth, _nHeight, nFlags ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -css::awt::Rectangle PluginControl_Impl::getPosSize() - throw( RuntimeException, std::exception ) -{ - return _xPeerWindow->getPosSize(); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::setVisible( sal_Bool bVisible ) - throw( RuntimeException, std::exception ) -{ - _bVisible = bVisible; - if (_xPeerWindow.is()) - _xPeerWindow->setVisible( _bVisible && !_bInDesignMode ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::setEnable( sal_Bool bEnable ) - throw( RuntimeException, std::exception ) -{ - _bEnable = bEnable; - if (_xPeerWindow.is()) - _xPeerWindow->setEnable( _bEnable ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::setFocus() throw( RuntimeException, std::exception ) -{ - if (_xPeerWindow.is()) - _xPeerWindow->setFocus(); -} - - - -void PluginControl_Impl::releasePeer() -{ - if (_xPeer.is()) - { - _xParentWindow->removeFocusListener( this ); - _xPeerWindow->dispose(); - _pSysChild = nullptr; - _xPeerWindow.clear(); - _xPeer.clear(); - getMultiplexer()->setPeer( Reference< css::awt::XWindow > () ); - } -} - -//---- css::awt::XControl ------------------------------------------------------------------------------------ -void PluginControl_Impl::createPeer( const Reference< css::awt::XToolkit > & /*xToolkit*/, const Reference< css::awt::XWindowPeer > & xParentPeer ) - throw( RuntimeException, std::exception ) -{ - if (_xPeer.is()) - { - OSL_FAIL( "### Peer is already set!" ); - return; - } - - _xParentPeer = xParentPeer; - _xParentWindow.set( xParentPeer, UNO_QUERY ); - DBG_ASSERT( _xParentWindow.is(), "### no parent peer window!" ); - - vcl::Window* pImpl = VCLUnoHelper::GetWindow( xParentPeer ); - if (pImpl) - { - _pSysChild = VclPtr<SystemChildWindow>::Create( pImpl, WB_CLIPCHILDREN ); - if (pImpl->HasFocus()) - _pSysChild->GrabFocus(); - - // get peer - _xPeer.set( _pSysChild->GetComponentInterface() ); - _xPeerWindow.set( _xPeer, UNO_QUERY ); - // !_BOTH_ MUST BE VALID! - DBG_ASSERT( (_xPeer.is() && _xPeerWindow.is()), "### no peer!" ); - - _xParentWindow->addFocusListener( this ); - _xPeerWindow->setPosSize( _nX, _nY, _nWidth, _nHeight, _nFlags ); - _xPeerWindow->setEnable( _bEnable ); - _xPeerWindow->setVisible( _bVisible && !_bInDesignMode ); - } - else - { - OSL_FAIL( "### cannot get implementation of parent peer!" ); - } - - getMultiplexer()->setPeer( _xPeerWindow ); -} - -//---- css::awt::XControl ------------------------------------------------------------------------------------ -void PluginControl_Impl::setDesignMode( sal_Bool bOn ) - throw( RuntimeException, std::exception ) -{ - _bInDesignMode = bOn; - if (_xPeerWindow.is()) - _xPeerWindow->setVisible( _bVisible && !_bInDesignMode ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addPaintListener( const Reference< css::awt::XPaintListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->advise( cppu::UnoType<css::awt::XPaintListener>::get(), l ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removePaintListener( const Reference< css::awt::XPaintListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->unadvise( cppu::UnoType<css::awt::XPaintListener>::get(), l ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addWindowListener( const Reference< css::awt::XWindowListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->advise( cppu::UnoType<css::awt::XWindowListener>::get(), l ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removeWindowListener( const Reference< css::awt::XWindowListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->unadvise( cppu::UnoType<css::awt::XWindowListener>::get(), l ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addFocusListener( const Reference< css::awt::XFocusListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->advise( cppu::UnoType<css::awt::XFocusListener>::get(), l ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removeFocusListener( const Reference< css::awt::XFocusListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->unadvise( cppu::UnoType<css::awt::XFocusListener>::get(), l ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addKeyListener( const Reference< css::awt::XKeyListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->advise( cppu::UnoType<css::awt::XKeyListener>::get(), l ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removeKeyListener( const Reference< css::awt::XKeyListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->unadvise( cppu::UnoType<css::awt::XKeyListener>::get(), l ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addMouseListener( const Reference< css::awt::XMouseListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->advise( cppu::UnoType<css::awt::XMouseListener>::get(), l ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removeMouseListener( const Reference< css::awt::XMouseListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->unadvise( cppu::UnoType<css::awt::XMouseListener>::get(), l ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::addMouseMotionListener( const Reference< css::awt::XMouseMotionListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->advise( cppu::UnoType<css::awt::XMouseMotionListener>::get(), l ); -} - -//---- css::awt::XWindow ------------------------------------------------------------------------------------- -void PluginControl_Impl::removeMouseMotionListener( const Reference< css::awt::XMouseMotionListener > & l ) - throw( RuntimeException, std::exception ) -{ - getMultiplexer()->unadvise( cppu::UnoType<css::awt::XMouseMotionListener>::get(), l ); -} - - -//---- css::awt::XView --------------------------------------------------------------------------------------- -void PluginControl_Impl::draw( sal_Int32 /*x*/, sal_Int32 /*y*/ ) - throw( RuntimeException, std::exception ) -{ - // has to be done by further implementation of control -} - -//---- css::awt::XView --------------------------------------------------------------------------------------- -void PluginControl_Impl::setZoom( float /*ZoomX*/, float /*ZoomY*/ ) - throw( RuntimeException, std::exception ) -{ - // has to be done by further implementation of control -} - -//---- css::lang::XEventListener ------------------------------------------------------------------------------ -void PluginControl_Impl::disposing( const css::lang::EventObject & /*rSource*/ ) - throw( RuntimeException, std::exception ) -{ -} -//---- css::awt::XFocusListener ------------------------------------------------------------------------------ -void PluginControl_Impl::focusGained( const css::awt::FocusEvent & /*rEvt*/ ) - throw( RuntimeException, std::exception ) -{ - if (_xPeerWindow.is()) - _xPeerWindow->setFocus(); -} -//---- css::awt::XFocusListener ------------------------------------------------------------------------------ -void PluginControl_Impl::focusLost( const css::awt::FocusEvent & /*rEvt*/ ) - throw( RuntimeException, std::exception ) -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/plmodel.cxx b/extensions/source/plugin/base/plmodel.cxx deleted file mode 100644 index e3f3aed6e49c..000000000000 --- a/extensions/source/plugin/base/plmodel.cxx +++ /dev/null @@ -1,204 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <plugin/model.hxx> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <cppuhelper/queryinterface.hxx> - -using namespace com::sun::star::uno; - - -Reference< XInterface > SAL_CALL PluginModel_CreateInstance( const Reference< css::lang::XMultiServiceFactory > & ) throw( Exception ) -{ - Reference< XInterface > xService = *new PluginModel(); - return xService; -} - -Any PluginModel::queryAggregation( const Type& type ) throw( RuntimeException, std::exception ) -{ - Any aRet( ::cppu::queryInterface( type, - static_cast< css::lang::XComponent* >(this), - static_cast< css::io::XPersistObject* >(this ), - static_cast< css::awt::XControlModel* >(this), - static_cast< css::beans::XPropertySet* >(this), - static_cast< css::beans::XMultiPropertySet* >(this), - static_cast< css::beans::XFastPropertySet* >(this) - ) ); - return aRet.hasValue() ? aRet : OWeakAggObject::queryAggregation( type ); -} - - -// XPluginManager_Impl -Sequence< OUString > PluginModel::getSupportedServiceNames_Static() throw() -{ - Sequence<OUString> aSNS { "com.sun.star.plugin.PluginModel" }; - return aSNS; -} - - -static const char* aCreationURL = "URL"; -static const char* aMime = "TYPE"; - -static ::osl::Mutex aPropertyMutex; - -static css::beans::Property aProps[] = -{ - css::beans::Property( - OUString::createFromAscii( aMime ), - 1, - ::cppu::UnoType<OUString>::get(), - css::beans::PropertyAttribute::BOUND ), - css::beans::Property( - OUString::createFromAscii( aCreationURL ), - 2, - ::cppu::UnoType<OUString>::get(), - css::beans::PropertyAttribute::BOUND ) -}; - -PluginModel::PluginModel() : - BroadcasterHelperHolder( aPropertyMutex ), - OPropertySetHelper( m_aHelper ), - OPropertyArrayHelper( aProps, 2 ) -{ -} - -PluginModel::PluginModel(const OUString& rURL, const OUString& rMimeType ) : - BroadcasterHelperHolder( aPropertyMutex ), - OPropertySetHelper( m_aHelper ), - OPropertyArrayHelper( aProps, 2 ), - m_aCreationURL( rURL ), - m_aMimeType( rMimeType ) -{ -} - -PluginModel::~PluginModel() -{ -} - -Reference< css::beans::XPropertySetInfo > PluginModel::getPropertySetInfo() throw(std::exception) -{ - static Reference< css::beans::XPropertySetInfo > aInfo = - createPropertySetInfo( *this ); - return aInfo; -} - -::cppu::IPropertyArrayHelper& PluginModel::getInfoHelper() -{ - return *this; -} - -sal_Bool PluginModel::convertFastPropertyValue( Any & rConvertedValue, - Any & rOldValue, - sal_Int32 nHandle, - const Any& rValue ) throw() -{ - if( nHandle == 1 || nHandle == 2 ) - { - if( rValue.getValueTypeClass() == TypeClass_STRING ) - { - rConvertedValue = rValue; - if( nHandle == 2 ) - rOldValue <<= m_aCreationURL; - else if( nHandle == 1 ) - rOldValue <<= m_aMimeType; - return sal_True; - } - } - return sal_False; -} - -void PluginModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, - const Any& rValue ) - throw(css::uno::Exception, std::exception) -{ - if( rValue.getValueTypeClass() == TypeClass_STRING ) // FIXME wrong type! - - { - if( nHandle == 2 ) - rValue >>= m_aCreationURL; - else if( nHandle == 1 ) - rValue >>= m_aMimeType; - } - else - throw css::lang::IllegalArgumentException(); -} - -void PluginModel::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw() -{ - if( nHandle == 2 ) - rValue <<= m_aCreationURL; - else if( nHandle == 1 ) - rValue <<= m_aMimeType; -} - -//---- css::lang::XComponent ---------------------------------------------------------------------------------- -void PluginModel::addEventListener( const Reference< css::lang::XEventListener > & l ) throw(std::exception) -{ - m_aDisposeListeners.push_back( l ); -} - -//---- css::lang::XComponent ---------------------------------------------------------------------------------- -void PluginModel::removeEventListener( const Reference< css::lang::XEventListener > & l ) throw(std::exception) -{ - m_aDisposeListeners.remove( l ); -} - -//---- css::lang::XComponent ---------------------------------------------------------------------------------- -void PluginModel::dispose() throw(std::exception) -{ - // send disposing events - css::lang::EventObject aEvt; - aEvt.Source = static_cast<cppu::OWeakObject*>(this); - ::std::list< Reference< css::lang::XEventListener > > aLocalListeners = m_aDisposeListeners; - for( ::std::list< Reference< css::lang::XEventListener > >::iterator it = aLocalListeners.begin(); - it != aLocalListeners.end(); ++it ) - (*it)->disposing( aEvt ); - - m_aDisposeListeners.clear(); - - disposing(); -} - - -// css::io::XPersistObject -OUString PluginModel::getServiceName() throw(std::exception) -{ - return OUString("com.sun.star.plugin.PluginModel"); -} - -void PluginModel::write(const Reference< css::io::XObjectOutputStream > & OutStream) throw(std::exception) -{ - OutStream->writeUTF( m_aCreationURL ); -} - -void PluginModel::read(const Reference< css::io::XObjectInputStream > & InStream) throw(std::exception) -{ - m_aCreationURL = InStream->readUTF(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/service.cxx b/extensions/source/plugin/base/service.cxx deleted file mode 100644 index f40de1dc4aa5..000000000000 --- a/extensions/source/plugin/base/service.cxx +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#endif - -#include <cstdarg> - -#include <plugin/impl.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/container/XSet.hpp> -#include <com/sun/star/registry/XRegistryKey.hpp> - -#include <uno/dispatcher.h> -#include <uno/mapping.hxx> - -#include <cppuhelper/factory.hxx> - -using namespace cppu; - -extern "C" { - SAL_DLLPUBLIC_EXPORT void* SAL_CALL pl_component_getFactory( - const sal_Char* pImplementationName, - void* pXUnoSMgr, - void* /*pXUnoKey*/ - ) - { - void* pRet = nullptr; - - OUString aImplName( OUString::createFromAscii( pImplementationName ) ); - - if( pXUnoSMgr ) - { - Reference< css::lang::XMultiServiceFactory > xMgr( - static_cast< css::lang::XMultiServiceFactory* >( pXUnoSMgr ) - ); - Reference< css::lang::XSingleServiceFactory > xFactory; - if( aImplName.equals( XPluginManager_Impl::getImplementationName_Static() ) ) - { - xFactory = ::cppu::createSingleFactory( - xMgr, aImplName, PluginManager_CreateInstance, - XPluginManager_Impl::getSupportedServiceNames_Static() ); - } - else if( aImplName.equals( PluginModel::getImplementationName_Static() ) ) - { - xFactory = ::cppu::createSingleFactory( - xMgr, aImplName, PluginModel_CreateInstance, - PluginModel::getSupportedServiceNames_Static() ); - } - if( xFactory.is() ) - { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - return pRet; - } -} /* extern "C" */ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/base/xplugin.cxx b/extensions/source/plugin/base/xplugin.cxx deleted file mode 100644 index 46e903466ad1..000000000000 --- a/extensions/source/plugin/base/xplugin.cxx +++ /dev/null @@ -1,1206 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#ifdef WNT -#include <prewin.h> -#include <postwin.h> -#endif - -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/loader/XImplementationLoader.hpp> -#include <com/sun/star/plugin/PluginManager.hpp> - -#include <cppuhelper/queryinterface.hxx> -#include <comphelper/fileurl.hxx> -#include <comphelper/processfactory.hxx> -#include <plugin/impl.hxx> -#include <sal/log.hxx> -#include <ucbhelper/content.hxx> -#include <tools/urlobj.hxx> -#include <vcl/svapp.hxx> -#include <salhelper/timer.hxx> -#include <osl/file.hxx> - -#ifdef UNX -#include <sys/types.h> -#include <sys/socket.h> -#endif - -#if OSL_DEBUG_LEVEL > 1 -#include <stdio.h> -#endif - -#include <memory> - -using namespace com::sun::star; -using namespace com::sun::star::io; -using namespace com::sun::star::beans; -using namespace com::sun::star::plugin; -using namespace osl; - -class PluginDisposer : public salhelper::Timer -{ -private: - XPlugin_Impl* m_pPlugin; - - virtual void SAL_CALL onShot() override; -public: - PluginDisposer( XPlugin_Impl* pPlugin ) : - salhelper::Timer( salhelper::TTimeValue( 2, 0 ), - salhelper::TTimeValue( 2, 0 ) ), - m_pPlugin( pPlugin ) - { start(); } - virtual ~PluginDisposer() {} -}; - -void PluginDisposer::onShot() -{ - if( m_pPlugin ) - { - if( m_pPlugin->isDisposable() ) - { - Application::PostUserEvent( LINK( m_pPlugin, XPlugin_Impl, secondLevelDispose ), static_cast<void*>(m_pPlugin) ); - } - } - else - release(); -} - -Any XPlugin_Impl::queryInterface( const Type& type ) throw( RuntimeException, std::exception ) -{ - return OWeakAggObject::queryInterface( type ); -} - -Any XPlugin_Impl::queryAggregation( const Type& type ) throw( RuntimeException, std::exception ) -{ - Any aRet( cppu::queryInterface( type, static_cast< XPlugin* >(this) ) ); - if( ! aRet.hasValue() ) - aRet = PluginControl_Impl::queryAggregation( type ); - return aRet; -} - - -XPlugin_Impl::XPlugin_Impl( const uno::Reference< css::lang::XMultiServiceFactory > & rSMgr) : - PluginControl_Impl(), - m_xSMgr( rSMgr ), - m_pPluginComm( nullptr ), - m_pSysPlugData( CreateSysPlugData() ), - m_aEncoding( osl_getThreadTextEncoding() ), - m_pArgv( nullptr ), - m_pArgn( nullptr ), - m_nArgs( 0 ), - m_aPluginMode( NP_FULL ), - m_nProvidingState( PROVIDING_NONE ), - m_nCalledFromPlugin( 0 ), - m_pDisposer( nullptr ), - m_bIsDisposed( false ) -{ - memset( &m_aInstance, 0, sizeof( m_aInstance ) ); - memset( &m_aNPWindow, 0, sizeof( m_aNPWindow ) ); - - m_xModel = new PluginModel(); - uno::Reference< css::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); - xPS->addPropertyChangeListener( OUString(), this ); - - Guard< Mutex > aGuard( ::PluginManager::get().getPluginMutex() ); - ::PluginManager::get().getPlugins().push_back( this ); -} - -void XPlugin_Impl::destroyInstance() -{ - Guard< Mutex > aGuard( m_aMutex ); - - NPSavedData* pSavedData = nullptr; - - destroyStreams(); - if( getPluginComm() ) - { - getPluginComm()->NPP_Destroy( this, &pSavedData ); - getPluginComm()->decRef(); - m_pPluginComm = nullptr; - } - - freeArgs(); - - while( m_aPEventListeners.size() ) - { - delete *m_aPEventListeners.begin(); - m_aPEventListeners.pop_front(); - } -} - -XPlugin_Impl::~XPlugin_Impl() -{ - destroyInstance(); -} - -void XPlugin_Impl::checkListeners( const char* normalizedURL ) -{ - if( ! normalizedURL ) - return; - - Guard< Mutex > aGuard( m_aMutex ); - - std::list<PluginEventListener*>::iterator iter; - for( iter = m_aPEventListeners.begin(); - iter != m_aPEventListeners.end(); - ++iter ) - { - if( ! strcmp( normalizedURL, (*iter)->getURL() ) || - ! strcmp( normalizedURL, (*iter)->getNormalizedURL() ) ) - { - (*iter)->disposing( css::lang::EventObject() ); - delete *iter; - m_aPEventListeners.remove( *iter ); - return; - } - } -} - -IMPL_LINK_NOARG_TYPED( XPlugin_Impl, secondLevelDispose, void*, void ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - // may have become undisposable between PostUserEvent and here - // or may have disposed and receive a second UserEvent - std::list<XPlugin_Impl*>& rList = ::PluginManager::get().getPlugins(); - std::list<XPlugin_Impl*>::iterator iter; - - { - Guard< Mutex > aPluginGuard( ::PluginManager::get().getPluginMutex() ); - for( iter = rList.begin(); iter != rList.end(); ++iter ) - { - if( *iter == this ) - break; - } - if( iter == rList.end() || ! isDisposable() ) - return; - } - - if (m_pDisposer) - { - m_pDisposer->release(); - m_pDisposer = nullptr; - } - - uno::Reference< XPlugin > xProtection( this ); - uno::Reference< css::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); - xPS->removePropertyChangeListener( OUString(), this ); - { - Guard< Mutex > aPluginGuard( ::PluginManager::get().getPluginMutex() ); - rList.remove( this ); - } - m_aNPWindow.window = nullptr; -#ifndef UNX - // acrobat does an unconditional XtParent on the windows widget - getPluginComm()->NPP_SetWindow( this ); -#endif - destroyInstance(); - PluginControl_Impl::dispose(); -} - -void XPlugin_Impl::dispose() throw(std::exception) -{ - Guard< Mutex > aGuard( m_aMutex ); - - if (m_bIsDisposed || !getPluginComm()) - return; - m_bIsDisposed = true; - - if( isDisposable() ) - secondLevelDispose( this ); - else - { - m_pDisposer = new PluginDisposer( this ); - m_pDisposer->acquire(); - } -} - -void XPlugin_Impl::initArgs( const Sequence< OUString >& argn, - const Sequence< OUString >& argv, - sal_Int16 mode ) -{ - m_aPluginMode = mode; - - m_nArgs = argn.getLength(); - m_pArgn = new const char*[m_nArgs]; - m_pArgv = new const char*[m_nArgs]; - const OUString* pUArgn = argn.getConstArray(); - const OUString* pUArgv = argv.getConstArray(); - for( int i = 0; i < m_nArgs; i++ ) - { - m_pArgn[i] = strdup( - OUStringToOString( pUArgn[i], m_aEncoding ).getStr() - ); - m_pArgv[i] = strdup( - OUStringToOString( pUArgv[i], m_aEncoding ).getStr() - ); - } -} - -void XPlugin_Impl::freeArgs() -{ - if( m_nArgs > 0 ) - { - for( ; m_nArgs--; ) - { - free( const_cast<char *>(m_pArgn[m_nArgs]) ); - free( const_cast<char *>(m_pArgv[m_nArgs]) ); - } - delete [] m_pArgn; - delete [] m_pArgv; - } -} - -void XPlugin_Impl::prependArg( const char* pName, const char* pValue ) -{ - const char** pNewNames = new const char*[m_nArgs+1]; - const char** pNewValues = new const char*[m_nArgs+1]; - - pNewNames[0] = strdup( pName ); - pNewValues[0] = strdup( pValue ); - for( int nIndex = 0; nIndex < m_nArgs; ++nIndex ) - { - pNewNames[nIndex+1] = m_pArgn[nIndex]; - pNewValues[nIndex+1]= m_pArgv[nIndex]; - } - // free old arrays - delete [] m_pArgn; - delete [] m_pArgv; - // set new arrays - m_pArgn = pNewNames; - m_pArgv = pNewValues; - // set new number of arguments - m_nArgs++; -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "inserted %s=%s\n", pNewNames[0], pNewValues[0] ); -#endif -} - -void XPlugin_Impl::handleSpecialArgs() -{ - // special handling for real audio which needs a lot of parameters - // or won't function at all - if( m_aDescription.Mimetype == "audio/x-pn-realaudio-plugin" && m_nArgs < 1 ) - { - OUString aURL; - if( m_xModel.is() ) - { - try - { - uno::Reference< XPropertySet > xProp( m_xModel, UNO_QUERY ); - Any aProp = xProp->getPropertyValue("URL"); - aProp >>= aURL; - } - catch(const UnknownPropertyException &) - { - } - } - - if( !aURL.isEmpty() ) - { - // set new args, old args need not be freed as there were none set - m_nArgs = 6; - m_pArgn = new const char*[m_nArgs]; - m_pArgv = new const char*[m_nArgs]; - - // SRC - m_pArgn[0] = strdup( "SRC" ); - m_pArgv[0] = strdup( OUStringToOString( aURL, m_aEncoding ).getStr() ); - // WIDTH - m_pArgn[1] = strdup( "WIDTH" ); - m_pArgv[1] = strdup( "200" ); - // HEIGHT - m_pArgn[2] = strdup( "HEIGHT" ); - m_pArgv[2] = strdup( "200" ); - // CONTROLS - m_pArgn[3] = strdup( "CONTROLS" ); - m_pArgv[3] = strdup( "PlayButton,StopButton,ImageWindow" ); - // AUTOSTART - m_pArgn[4] = strdup( "AUTOSTART" ); - m_pArgv[4] = strdup( "TRUE" ); - // NOJAVA - m_pArgn[5] = strdup( "NOJAVA" ); - m_pArgv[5] = strdup( "TRUE" ); - } - } - // #69333# special for pdf - else if( m_aDescription.Mimetype == "application/pdf" ) - m_aPluginMode = PluginMode::FULL; - - // see if we have a TYPE tag - int nIndex; - for( nIndex = 0; nIndex < m_nArgs; ++nIndex ) - if( m_pArgn[nIndex][0] == 'T' && - m_pArgn[nIndex][1] == 'Y' && - m_pArgn[nIndex][2] == 'P' && - m_pArgn[nIndex][3] == 'E' && - m_pArgn[nIndex][4] == 0 ) - break; - if( nIndex >= m_nArgs ) - { - // TYPE - prependArg( "TYPE", OUStringToOString( m_aDescription.Mimetype, m_aEncoding ).getStr() ); - } - - // see if we have a SRC tag - for( nIndex = 0; nIndex < m_nArgs; ++nIndex ) - if( m_pArgn[nIndex][0] == 'S' && - m_pArgn[nIndex][1] == 'R' && - m_pArgn[nIndex][2] == 'C' && - m_pArgn[nIndex][3] == 0 ) - break; - if( nIndex >= m_nArgs ) - { - // need a SRC parameter (as all browser set one on the plugin - OUString aURL; - if( m_xModel.is() ) - { - try - { - uno::Reference< XPropertySet > xProp( m_xModel, UNO_QUERY ); - Any aProp = xProp->getPropertyValue("URL"); - aProp >>= aURL; - } - catch(const UnknownPropertyException &) - { - } - } - - if( !aURL.isEmpty() ) - { - // SRC - prependArg( "SRC", OUStringToOString( aURL, m_aEncoding ).getStr() ); - } - } -} - -void XPlugin_Impl::initInstance( const PluginDescription& rDescription, - const Sequence< OUString >& argn, - const Sequence< OUString >& argv, - sal_Int16 mode ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - m_aDescription = rDescription; - initArgs( argn, argv, mode ); - handleSpecialArgs(); -} - -void XPlugin_Impl::initInstance( const OUString& rURL, - const Sequence< OUString >& argn, - const Sequence< OUString >& argv, - sal_Int16 mode ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - initArgs( argn, argv, mode ); - m_aDescription = fitDescription( rURL ); - - m_xModel = new PluginModel( rURL, m_aDescription.Mimetype ); - handleSpecialArgs(); -} - -void XPlugin_Impl::modelChanged() -{ - Guard< Mutex > aGuard( m_aMutex ); - - m_nProvidingState = PROVIDING_MODEL_UPDATE; - - m_aDescription = fitDescription( getCreationURL() ); - destroyInstance(); - if( m_aDescription.Mimetype.isEmpty() ) - { - m_nProvidingState = PROVIDING_NONE; - return; - } - - OUString aURL = getCreationURL(); - provideNewStream( m_aDescription.Mimetype, - uno::Reference< XActiveDataSource >(), - aURL, - 0, 0, comphelper::isFileUrl(aURL) ); - m_nProvidingState = PROVIDING_NONE; -} - -OUString XPlugin_Impl::getCreationURL() -{ - Guard< Mutex > aGuard( m_aMutex ); - - OUString aRet; - uno::Reference< css::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); - if( xPS.is() ) - { - Any aValue = xPS->getPropertyValue("URL"); - aValue >>= aRet; - } - return aRet; -} - - -sal_Bool XPlugin_Impl::setModel( const uno::Reference< css::awt::XControlModel > & Model ) - throw( RuntimeException, std::exception ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - uno::Reference< css::beans::XPropertySet > xPS( Model, UNO_QUERY ); - if( ! xPS.is() ) - return sal_False; - - if( !getCreationURL().isEmpty() ) - { - m_xModel = Model; - modelChanged(); - xPS->addPropertyChangeListener( OUString(), this ); - return sal_True; - } - return sal_False; -} - -void XPlugin_Impl::createPeer( const uno::Reference< css::awt::XToolkit > & xToolkit, const uno::Reference< css::awt::XWindowPeer > & Parent ) - throw( RuntimeException, std::exception ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - if( ! _xPeer.is() ) - { - if( ! Parent.is() ) - throw RuntimeException(); - PluginControl_Impl::createPeer( xToolkit, Parent ); - } -} - -void XPlugin_Impl::loadPlugin() -{ - Guard< Mutex > aGuard( m_aMutex ); - - std::list<PluginComm*>::iterator iter; - for( iter = ::PluginManager::get().getPluginComms().begin(); - iter != ::PluginManager::get().getPluginComms().end(); ++iter ) - { - if( OStringToOUString( (*iter)->getLibName(), m_aEncoding ) == m_aDescription.PluginName ) - { - setPluginComm( *iter ); - break; - } - } - const SystemEnvData* pEnvData = getSysChildSysData(); -#if defined( UNX ) && !(defined(MACOSX)) - if (pEnvData->pDisplay) // headless? - { - XSync( static_cast<Display*>(pEnvData->pDisplay), False ); - } -#endif - if( ! getPluginComm() ) - { - if( !m_aDescription.PluginName.isEmpty() ) - { -#if defined MACOSX - PluginComm* pComm = new MacPluginComm( m_aDescription.Mimetype, - m_aDescription.PluginName, - pEnvData->mpNSView ); -#elif defined UNX - // need a new PluginComm - PluginComm* pComm = nullptr; - int sv[2]; - if( !socketpair( AF_UNIX, SOCK_STREAM, 0, sv ) ) - pComm = new UnxPluginComm( m_aDescription.Mimetype, - m_aDescription.PluginName, - (Window)pEnvData->aWindow, - sv[0], - sv[1] - ); - - SAL_WARN_IF( !pComm, "extensions.plugin", "no PluginComm"); - if (!pComm) - return; - -#elif defined WNT - PluginComm* pComm; - try { - pComm = new PluginComm_Impl( - m_aDescription.Mimetype, m_aDescription.PluginName, - (HWND)pEnvData->hWnd); - } catch (PluginComm_Impl::CannotInitializeException &) { - return; - } -#endif - - setPluginComm( pComm ); - } - else - return; - } - - getPluginComm()-> - NPP_New( const_cast<char*>(OUStringToOString( m_aDescription.Mimetype, - m_aEncoding).getStr()), - &getNPPInstance(), - m_aPluginMode == PluginMode::FULL ? NP_FULL : NP_EMBED, - ::sal::static_int_cast< int16_t, int >( m_nArgs ), - const_cast<char**>(m_nArgs ? m_pArgn : nullptr), - const_cast<char**>(m_nArgs ? m_pArgv : nullptr), - nullptr ); -#ifdef MACOSX - // m_aNPWindow is set up in the MacPluginComm from the view - SetSysPlugDataParentView(*pEnvData); -#elif defined( UNX ) - if (pEnvData->pDisplay) // headless? - { - XSync( static_cast<Display*>(pEnvData->pDisplay), False ); - m_aNPWindow.window = reinterpret_cast<void*>(pEnvData->aWindow); - } - else - { - m_aNPWindow.window = nullptr; - } - m_aNPWindow.ws_info = nullptr; -#else - m_aNPWindow.window = (void*)pEnvData->hWnd; -#endif - css::awt::Rectangle aPosSize = getPosSize(); - - for( int i = 0; i < m_nArgs; i++ ) - { - OString aName( m_pArgn[i] ); - if( aName.equalsIgnoreAsciiCase( "width" ) ) - { - OString aValue( m_pArgv[i] ); - aPosSize.Width = aValue.toInt32(); - } - else if( aName.equalsIgnoreAsciiCase( "height" ) ) - { - OString aValue( m_pArgv[i] ); - aPosSize.Height = aValue.toInt32(); - } - } - - m_aNPWindow.clipRect.top = 0; - m_aNPWindow.clipRect.left = 0; - m_aNPWindow.clipRect.bottom = ::sal::static_int_cast< uint16_t, sal_Int32 >( aPosSize.Height ); - m_aNPWindow.clipRect.right = ::sal::static_int_cast< uint16_t, sal_Int32 >( aPosSize.Width ); - m_aNPWindow.type = NPWindowTypeWindow; - - m_aNPWindow.x = 0; - m_aNPWindow.y = 0; - m_aNPWindow.width = aPosSize.Width ? aPosSize.Width : 600; - m_aNPWindow.height = aPosSize.Height ? aPosSize.Height : 600; - - getPluginComm()->NPP_SetWindow( this ); -} - -void XPlugin_Impl::destroyStreams() -{ - Guard< Mutex > aGuard( m_aMutex ); - - // streams remove themselves from this list when deleted - while( m_aOutputStreams.size() ) - delete *m_aOutputStreams.begin(); - - // input streams are XOutputStreams, they cannot be simply deleted - std::list<PluginInputStream*> aLocalList( m_aInputStreams ); - for( std::list<PluginInputStream*>::iterator it = aLocalList.begin(); - it != aLocalList.end(); ++it ) - (*it)->setMode( -1 ); -} - -PluginStream* XPlugin_Impl::getStreamFromNPStream( NPStream* stream ) -{ - Guard< Mutex > aGuard( m_aMutex ); - - std::list<PluginInputStream*>::iterator iter; - for( iter = m_aInputStreams.begin(); iter != m_aInputStreams.end(); ++iter ) - if( &(*iter)->getStream() == stream ) - return *iter; - - std::list<PluginOutputStream*>::iterator iter2; - for( iter2 = m_aOutputStreams.begin(); iter2 != m_aOutputStreams.end(); ++iter2 ) - if( &(*iter2)->getStream() == stream ) - return *iter2; - - return nullptr; -} - -sal_Bool XPlugin_Impl::provideNewStream(const OUString& mimetype, - const uno::Reference< css::io::XActiveDataSource > & stream, - const OUString& url, sal_Int32 length, - sal_Int32 lastmodified, sal_Bool isfile) throw(std::exception) - -{ - Guard< Mutex > aGuard( m_aMutex ); - bool bRet = false; - - if( m_nProvidingState != PROVIDING_NONE ) - { - m_nProvidingState = PROVIDING_NOW; - Any aAny; - aAny <<= url; - uno::Reference< css::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); - if( xPS.is() ) - { - try - { - xPS->setPropertyValue("URL", aAny ); - aAny <<= mimetype; - xPS->setPropertyValue("TYPE", aAny ); - } - catch(...) - { - } - } - } - m_nProvidingState = PROVIDING_NOW; - - OString aMIME; - if( !mimetype.isEmpty() ) - aMIME = OUStringToOString( mimetype, m_aEncoding ); - else - aMIME = OUStringToOString( m_aDescription.Mimetype, m_aEncoding ); - - OString aURL = OUStringToOString( url, m_aEncoding ); - - // check whether there is a notifylistener for this stream - // this means that the stream is created from the plugin - // via NPN_GetURLNotify or NPN_PostURLNotify - std::list<PluginEventListener*>::iterator iter; - for( iter = m_aPEventListeners.begin(); - iter != m_aPEventListeners.end(); - ++iter ) - { - if( (*iter)->getNormalizedURL() == aURL ) - { - aURL = (*iter)->getURL(); - break; - } - } - - if( ! m_pPluginComm ) - { - loadPlugin(); - if( !m_aLastGetUrl.isEmpty() && m_aLastGetUrl == aURL ) - { - // plugin is pulling data, don't push the same stream; - // this complicated method could have been avoided if - // all plugins respected the SRC parameter; but e.g. - // acrobat reader plugin does not - m_nProvidingState = PROVIDING_NONE; - return sal_True; - } - } - if( ! m_pPluginComm ) - return sal_False; - - if( url.isEmpty() ) - // this is valid if the plugin is supposed to - // pull data (via e.g. NPN_GetURL) - return sal_True; - - // set mimetype on model - { - uno::Reference< css::beans::XPropertySet > xPS( m_xModel, UNO_QUERY ); - if( xPS.is() ) - { - try - { - Any aAny; - aAny <<= m_aDescription.Mimetype; - xPS->setPropertyValue("TYPE", aAny ); - } - catch(...) - { - } - } - } - - // there may be plugins that can use the file length information, - // but currently none are known. Since this file opening/seeking/closing - // is rather costly, it is not implemented. If there are plugins known to - // make use of the file length, simply put it in - - PluginInputStream* pStream = new PluginInputStream( this, aURL.getStr(), - length, lastmodified ); - uno::Reference< css::io::XOutputStream > xNewStream( pStream ); - - if( iter != m_aPEventListeners.end() ) - pStream->getStream().notifyData = (*iter)->getNotifyData(); - - uint16_t stype = 0; - - // special handling acrobat reader - // presenting a seekable stream to it does not seem to work correctly - if( aMIME.equals( "application/pdf" ) ) - isfile = sal_False; - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, - "new stream \"%s\" of MIMEType \"%s\"\n" - "for plugin \"%s\"\n" - "seekable = %s, length = %" SAL_PRIdINT32 "\n", - aURL.getStr(), aMIME.getStr(), getPluginComm()->getLibName().getStr(), - isfile ? "true" : "false", length ); - -#endif - if( ! m_pPluginComm->NPP_NewStream( &m_aInstance, - const_cast<char*>(aMIME.getStr()), - &pStream->getStream(), isfile, - &stype ) ) - { -#if OSL_DEBUG_LEVEL > 1 - const char* pType; - switch( stype ) - { - case NP_NORMAL: pType = "NP_NORMAL";break; - case NP_SEEK: pType = "NP_SEEK";break; - case NP_ASFILE: pType = "NP_ASFILE";break; - case NP_ASFILEONLY: pType = "NP_ASFILEONLY";break; - default: pType = "unknown!!!"; - } - fprintf( stderr, "Plugin wants it in Mode %s\n", pType ); -#endif - if( isfile && stype == NP_ASFILEONLY ) - { - OString aFileName; - if( comphelper::isFileUrl(url) ) - { - OUString aSysName; - osl_getSystemPathFromFileURL( url.pData, &aSysName.pData ); - aFileName = OUStringToOString( aSysName, m_aEncoding ); - } - else - aFileName = OUStringToOString( url, m_aEncoding ); - m_pPluginComm-> - NPP_StreamAsFile( &m_aInstance, - &pStream->getStream(), - aFileName.getStr() ); - } - else - { - pStream->setMode( stype ); - - if( ! stream.is() ) - { - // stream has to be loaded by PluginStream itself via UCB - pStream->load(); - } - else - { - uno::Reference< css::io::XConnectable > xConnectable( stream, UNO_QUERY ); - pStream->setPredecessor( xConnectable ); - if( xConnectable.is() ) - { - xConnectable->setSuccessor( static_cast< css::io::XConnectable* >(pStream) ); - while( xConnectable->getPredecessor().is() ) - xConnectable = xConnectable->getPredecessor(); - } - stream->setOutputStream( xNewStream ); - pStream->setSource( stream ); - uno::Reference< css::io::XActiveDataControl > xController; - if( xConnectable.is() ) - xController.set( xConnectable, UNO_QUERY ); - else - xController.set( stream, UNO_QUERY ); - - if( xController.is() ) - xController->start(); - } - } - bRet = true; - } - - m_nProvidingState = PROVIDING_NONE; - - return bRet; -} - -void XPlugin_Impl::disposing( const css::lang::EventObject& /*rSource*/ ) throw(std::exception) -{ -} - -void XPlugin_Impl::propertyChange(const css::beans::PropertyChangeEvent& rEvent) - throw (css::uno::RuntimeException, std::exception) -{ - Guard< Mutex > aGuard( m_aMutex ); - - if( rEvent.PropertyName == "URL" ) - { - OUString aStr; - rEvent.NewValue >>= aStr; - if( m_nProvidingState == PROVIDING_NONE ) - { - if( aStr != m_aURL ) - { - m_aURL = aStr; - modelChanged(); - } - } - } -} - -void XPlugin_Impl::setPluginContext( const uno::Reference< XPluginContext > & rContext ) -{ - m_rBrowserContext = rContext; -} - -void XPlugin_Impl::setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) - throw( RuntimeException, std::exception ) -{ - Guard< Mutex > aGuard( m_aMutex ); - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "XPlugin_Impl::setPosSize( %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 ", %" SAL_PRIdINT32 ", %d )\n", - nX_, nY_, nWidth_, nHeight_, nFlags ); -#endif - - PluginControl_Impl::setPosSize(nX_, nY_, nWidth_, nHeight_, nFlags); - - m_aNPWindow.x = 0; - m_aNPWindow.y = 0; - m_aNPWindow.width = nWidth_; - m_aNPWindow.height = nHeight_; - m_aNPWindow.clipRect.top = 0; - m_aNPWindow.clipRect.left = 0; - m_aNPWindow.clipRect.right = ::sal::static_int_cast< uint16_t, sal_Int32 >( nWidth_ ); - m_aNPWindow.clipRect.bottom = ::sal::static_int_cast< uint16_t, sal_Int32 >( nHeight_ ); - - if( getPluginComm() ) - getPluginComm()->NPP_SetWindow( this ); -} - -PluginDescription XPlugin_Impl::fitDescription( const OUString& rURL ) -{ - uno::Reference< XPluginManager > xPMgr( plugin::PluginManager::create(comphelper::getComponentContext(m_xSMgr)) ); - - Sequence< PluginDescription > aDescrs = xPMgr->getPluginDescriptions(); - const PluginDescription* pDescrs = aDescrs.getConstArray(); - - for( int nArg = 0; nArg < m_nArgs; nArg++ ) - { - if( strncmp( m_pArgn[nArg], "TYPE", 4 ) == 0 && - m_pArgn[nArg][4] == 0 ) - { - for( int i = 0; i < aDescrs.getLength(); i++ ) - { - if( pDescrs[i].Mimetype.equalsAscii( m_pArgv[nArg] ) ) - return pDescrs[i]; - } - } - } - - int nPos = rURL.lastIndexOf( (sal_Unicode)'.' ); - if( nPos != -1 ) - { - OUString const aExt = rURL.copy( nPos ).toAsciiLowerCase(); - for( int i = 0; i < aDescrs.getLength(); i++ ) - { - OUString aThisExt = pDescrs[ i ].Extension.toAsciiLowerCase(); - if( aThisExt.indexOf( aExt ) != -1 ) - { - return pDescrs[i]; - } - } - } - return PluginDescription(); -} - - -PluginStream::PluginStream( XPlugin_Impl* pPlugin, - const char* url, sal_uInt32 len, sal_uInt32 lastmod) - : m_wPlugin(static_cast< ::cppu::OWeakObject* >(pPlugin)) - , m_pPlugin(pPlugin) - -{ - memset( &m_aNPStream, 0, sizeof( m_aNPStream ) ); - m_aNPStream.url = strdup( url ); - m_aNPStream.end = len; - m_aNPStream.lastmodified = lastmod; -} - -PluginStream::~PluginStream() -{ - uno::Reference<uno::XInterface> const xPlugin(m_wPlugin); - XPlugin_Impl *const pPlugin(m_pPlugin); - if (xPlugin.is() && pPlugin) - { - Guard< Mutex > aGuard( pPlugin->getMutex() ); - - if( m_pPlugin && m_pPlugin->getPluginComm() ) - { - m_pPlugin->getPluginComm()->NPP_DestroyStream( &m_pPlugin->getNPPInstance(), - &m_aNPStream, NPRES_DONE ); - m_pPlugin->checkListeners( m_aNPStream.url ); - m_pPlugin->getPluginComm()->NPP_SetWindow( m_pPlugin ); - } - } - ::free( const_cast<char *>(m_aNPStream.url) ); -} - -PluginInputStream::PluginInputStream( XPlugin_Impl* pPlugin, - const char* url, - sal_uInt32 len, - sal_uInt32 lastmod ) : - PluginStream( pPlugin, url, len, lastmod ), - m_pContent( nullptr ), - m_nMode( NP_NORMAL ), - m_nWritePos( 0 ) -{ - assert(m_pPlugin); - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - m_pPlugin->getInputStreams().push_back( this ); - OUString aTmpFile; - osl::FileBase::createTempFile( nullptr, nullptr, &aTmpFile ); - - // set correct extension, some plugins need that - OUString aName( m_aNPStream.url, strlen( m_aNPStream.url ), m_pPlugin->getTextEncoding() ); - OUString aExtension; - sal_Int32 nSepInd = aName.lastIndexOf('.'); - if( nSepInd != -1 ) - { - aExtension = aName.copy( nSepInd + 1, aName.getLength() - nSepInd - 1 ); - } - if( !aExtension.isEmpty() ) - { - aTmpFile += aExtension; - } - m_aFileStream.Open( aTmpFile, StreamMode::READ | StreamMode::WRITE ); - if( ! m_aFileStream.IsOpen() ) - { - // might be that the extension scrambled the whole filename - osl::FileBase::createTempFile( nullptr, nullptr, &aTmpFile ); - m_aFileStream.Open( aTmpFile, StreamMode::READ | StreamMode::WRITE ); - } -} - -PluginInputStream::~PluginInputStream() -{ - OUString aFile( m_aFileStream.GetFileName() ); - - m_aFileStream.Close(); - - uno::Reference<uno::XInterface> const xPlugin(m_wPlugin); - XPlugin_Impl *const pPlugin(m_pPlugin); - if (xPlugin.is() && pPlugin) - { - Guard< Mutex > aGuard( pPlugin->getMutex() ); - - pPlugin->getInputStreams().remove( this ); - - if( m_pPlugin ) - { - OString aFileName(OUStringToOString(aFile, m_pPlugin->getTextEncoding())); - if( m_pPlugin->getPluginComm() && m_nMode != -1 ) - // mode -1 means either an error occurred, - // or the plugin is already disposing - { - m_pPlugin->getPluginComm()->addFileToDelete( aFile ); - if( m_nMode == NP_ASFILE ) - { - m_pPlugin->getPluginComm()-> - NPP_StreamAsFile( &m_pPlugin->getNPPInstance(), - &m_aNPStream, - aFileName.getStr() ); - } - m_pPlugin->getPluginComm()->NPP_SetWindow( m_pPlugin ); - m_pPlugin->getInputStreams().remove( this ); - } - else - osl::File::remove( aFile ); - } - else - osl::File::remove( aFile ); - } - else - osl::File::remove( aFile ); - delete m_pContent; -} - -PluginStreamType PluginInputStream::getStreamType() -{ - return InputStream; -} - -void PluginInputStream::load() -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - INetURLObject aUrl; - aUrl.SetSmartProtocol( INetProtocol::File ); - aUrl.SetSmartURL( - OUString( getStream().url, - strlen( getStream().url ), - RTL_TEXTENCODING_MS_1252 - ) ); - try - { - m_pContent = - new ::ucbhelper::Content( - aUrl.GetMainURL(INetURLObject::DECODE_TO_IURI), - uno::Reference< css::ucb::XCommandEnvironment >(), - comphelper::getProcessComponentContext() - ); - m_pContent->openStream( static_cast< XOutputStream* >( this ) ); - } - catch(const css::uno::Exception &) - { - } -} - -void PluginInputStream::setMode( sal_Int32 nMode ) -{ - assert(m_pPlugin); // this is currently only called from two places... - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - m_nMode = nMode; - - // invalidation by plugin - if (m_nMode == -1) - { - m_pPlugin->getInputStreams().remove( this ); - m_pPlugin = nullptr; - m_wPlugin.clear(); - } -} - -void PluginInputStream::writeBytes( const Sequence<sal_Int8>& Buffer ) throw(std::exception) -{ - uno::Reference<uno::XInterface> const xPlugin(m_wPlugin); - XPlugin_Impl *const pPlugin(m_pPlugin); - if (!xPlugin.is() || !pPlugin) - return; - - Guard< Mutex > aGuard( pPlugin->getMutex() ); - - m_aFileStream.Seek( STREAM_SEEK_TO_END ); - m_aFileStream.Write( Buffer.getConstArray(), Buffer.getLength() ); - - if( m_nMode == NP_SEEK ) - // hold reference, stream gets destroyed in NPN_DestroyStream - m_xSelf = this; - - if( m_nMode == -1 || !m_pPlugin->getPluginComm() ) - return; - - sal_Size nPos = m_aFileStream.Tell(); - sal_Size nBytes = 0; - while( m_nMode != NP_ASFILEONLY && - m_nWritePos < nPos && - (nBytes = m_pPlugin->getPluginComm()-> NPP_WriteReady( - &m_pPlugin->getNPPInstance(), &m_aNPStream )) > 0 ) - { - nBytes = (nBytes > nPos - m_nWritePos) ? nPos - m_nWritePos : nBytes; - - std::unique_ptr<char[]> pBuffer(new char[ nBytes ]); - m_aFileStream.Seek( m_nWritePos ); - nBytes = m_aFileStream.Read( pBuffer.get(), nBytes ); - - int32_t nBytesRead = 0; - try - { - nBytesRead = m_pPlugin->getPluginComm()->NPP_Write( - &m_pPlugin->getNPPInstance(), &m_aNPStream, m_nWritePos, nBytes, pBuffer.get() ); - } - catch( ... ) - { - nBytesRead = 0; - } - - if( nBytesRead < 0 ) - { - m_nMode = -1; - return; - } - - m_nWritePos += nBytesRead; - } -} - -void PluginInputStream::closeOutput() throw(std::exception) -{ - uno::Reference<uno::XInterface> const xPlugin(m_wPlugin); - XPlugin_Impl *const pPlugin(m_pPlugin); - if (!xPlugin.is() || !pPlugin) - return; - - Guard< Mutex > aGuard( pPlugin->getMutex() ); - - flush(); - m_xSource.clear(); -} - -sal_uInt32 PluginInputStream::read( sal_uInt32 offset, sal_Int8* buffer, sal_uInt32 size ) -{ - uno::Reference<uno::XInterface> const xPlugin(m_wPlugin); - XPlugin_Impl *const pPlugin(m_pPlugin); - if (!xPlugin.is() || !pPlugin) - return 0; - - Guard< Mutex > aGuard( pPlugin->getMutex() ); - - if( m_nMode != NP_SEEK ) - return 0; - - m_aFileStream.Seek( offset ); - return m_aFileStream.Read( buffer, size ); -} - -void PluginInputStream::flush() throw(std::exception) -{ -} - -PluginOutputStream::PluginOutputStream( XPlugin_Impl* pPlugin, - const char* url, - sal_uInt32 len, - sal_uInt32 lastmod ) : - PluginStream( pPlugin, url, len, lastmod ), - m_xStream( pPlugin->getServiceManager()->createInstance("com.sun.star.io.DataOutputStream"), UNO_QUERY ) -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - m_pPlugin->getOutputStreams().push_back( this ); -} - -PluginOutputStream::~PluginOutputStream() -{ - Guard< Mutex > aGuard( m_pPlugin->getMutex() ); - - m_pPlugin->getOutputStreams().remove( this ); -} - -PluginStreamType PluginOutputStream::getStreamType() -{ - return OutputStream; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx b/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx deleted file mode 100644 index 3a1638a9381e..000000000000 --- a/extensions/source/plugin/inc/plugin/aqua/sysplug.hxx +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_AQUA_SYSPLUG_HXX -#define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_AQUA_SYSPLUG_HXX - -#include <unistd.h> - -#include <list> -#include <map> -#include <algorithm> -#include "premac.h" -#include <Carbon/Carbon.h> -#include <Security/cssmconfig.h> -#include "postmac.h" -#undef uint32 - -#define XP_MAC -#include "npapi.h" -#include "npsdk/npupp.h" - -#include "plugin/plcom.hxx" - -#include "vcl/sysdata.hxx" -#include "vcl/threadex.hxx" -#include "vcl/timer.hxx" -#include "osl/module.h" - -#ifdef __OBJC__ -@class NSView; -#else -class NSView; -#endif - -class XPlugin_Impl; - -namespace plugstringhelper -{ -OUString getString( CFStringRef i_xString ); -OUString getString( CFURLRef i_xURL ); -CFMutableStringRef createString( const OUString& i_rString ); -CFURLRef createURL( const OUString& i_rString ); -OUString getURLFromPath( const OUString& i_rPath ); -CFURLRef createURLFromPath( const OUString& i_rPath ); -OUString CFURLtoOSLURL( CFURLRef i_xURL ); -} - - -class MacPluginComm : - public PluginComm, - public vcl::SolarThreadExecutor - -{ - enum CallType { - eNPP_Destroy, - eNPP_DestroyStream, - eNPP_GetJavaClass, - eNPP_Initialize, - eNPP_New, - eNPP_NewStream, - eNPP_Print, - eNPP_SetWindow, - eNPP_Shutdown, - eNPP_StreamAsFile, - eNPP_URLNotify, - eNPP_Write, - eNPP_WriteReady, - eNPP_GetValue, - eNPP_SetValue, - eNPP_HandleEvent, - eNP_Initialize - }; - - void* m_aArgs[ 8 ]; - CallType m_eCall; - - virtual long doIt(); -public: - MacPluginComm( const OUString& rMIME, const OUString& rName, NSView* pView ); - virtual ~MacPluginComm(); - - // FIXME: - // this actually should be from the NP headers - // but currently we have too old a version - // changes this when we have updated our headers - typedef struct NP_CGContext - { - CGContextRef context; - WindowRef window; - } NP_CGContext; - -public: - virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); - virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ); - virtual NPError NPP_Initialize(); - virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, - char* argn[], char* argv[], NPSavedData *saved ); - virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, - NPBool seekable, uint16_t* stype ); - virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); - virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); - virtual void NPP_Shutdown(); - virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ); - virtual void NPP_URLNotify( NPP instance, const char* url, - NPReason reason, void* notifyData ); - virtual int32_t NPP_Write( NPP instance, NPStream* stream, int32_t offset, - int32_t len, void* buffer ); - virtual int32_t NPP_WriteReady( NPP instance, NPStream* stream ); - virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void *ret_value ); - virtual int16_t NPP_HandleEvent( NPP instance, void* event ); - - virtual NPError NPP_SetWindow( XPlugin_Impl* ); - virtual NPError NPP_Destroy( XPlugin_Impl*, NPSavedData** save ); - - void drawView( XPlugin_Impl* ); -private: - sal_Bool retrieveFunction( const char* i_pName, void** i_ppFunc ) const; - DECL_LINK_TYPED( NullTimerHdl, Timer*, void ); - -private: - CFBundleRef m_xBundle; - oslModule m_hPlugLib; - NPPluginFuncs m_aNPPfuncs; - - // timer for sending nullEvents - AutoTimer* m_pNullTimer; - std::list< XPlugin_Impl* > m_aNullEventClients; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/inc/plugin/impl.hxx b/extensions/source/plugin/inc/plugin/impl.hxx deleted file mode 100644 index 85d74184a05b..000000000000 --- a/extensions/source/plugin/inc/plugin/impl.hxx +++ /dev/null @@ -1,437 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_IMPL_HXX -#define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_IMPL_HXX - -#include <config_lgpl.h> - -#include <limits> -#include <memory> - -#include "cppuhelper/weak.hxx" - -#include "com/sun/star/awt/Key.hpp" -#include "com/sun/star/awt/KeyFunction.hpp" -#include "com/sun/star/beans/PropertyAttribute.hpp" -#include "com/sun/star/plugin/PluginMode.hpp" -#include "com/sun/star/plugin/PluginDescription.hpp" -#include "com/sun/star/plugin/PluginException.hpp" -#include "com/sun/star/plugin/PluginVariable.hpp" -#include "com/sun/star/plugin/XPlugin.hpp" -#include "com/sun/star/plugin/XPluginManager.hpp" -#include "com/sun/star/plugin/XPluginContext.hpp" -#include "com/sun/star/io/XConnectable.hpp" -#include "com/sun/star/io/XOutputStream.hpp" -#include "com/sun/star/io/XDataOutputStream.hpp" -#include "com/sun/star/io/XActiveDataControl.hpp" -#include "com/sun/star/io/XDataInputStream.hpp" -#include "com/sun/star/io/XMarkableStream.hpp" -#include "com/sun/star/io/XInputStream.hpp" -#include "com/sun/star/io/XStreamListener.hpp" -#include "com/sun/star/io/XActiveDataSink.hpp" -#include "com/sun/star/io/XActiveDataSource.hpp" -#include "com/sun/star/lang/XServiceName.hpp" -#include "com/sun/star/lang/XServiceInfo.hpp" -#include "com/sun/star/lang/XMultiServiceFactory.hpp" -#include "com/sun/star/lang/XSingleServiceFactory.hpp" -#include "com/sun/star/awt/GradientStyle.hpp" -#include "com/sun/star/awt/RasterOperation.hpp" -#include "com/sun/star/awt/Gradient.hpp" -#include "com/sun/star/awt/XGraphics.hpp" -#include <com/sun/star/uno/XComponentContext.hpp> - -#include "cppuhelper/implbase2.hxx" -#include "cppuhelper/implbase1.hxx" - -#include <list> - -#ifdef WNT -#include <plugin/win/sysplug.hxx> -#elif defined(MACOSX) -#include "plugin/aqua/sysplug.hxx" -#elif defined(UNX) -#include "plugin/unx/sysplug.hxx" -#endif - -struct SysPlugData; - -std::shared_ptr<SysPlugData> CreateSysPlugData(); - -extern "C" { - -void /*SAL_CALL NP_LOADDS*/ NPN_ForceRedraw_Impl(NPP instance); -NPError /*SAL_CALL NP_LOADDS*/ NPN_SetValue_Impl( NPP instance, - NPPVariable variable, - void* value ); -} // extern "C" - -#include "plugin/plctrl.hxx" -#include "plugin/model.hxx" - -#include "vcl/sysdata.hxx" -#include "vcl/syschild.hxx" - -#include "tools/link.hxx" -#include "tools/stream.hxx" - - -using namespace com::sun::star::uno; - -#define PROVIDING_NONE 0 -#define PROVIDING_NOW 1 -#define PROVIDING_MODEL_UPDATE 2 - -// forwards -namespace ucbhelper { class Content; } -class PluginStream; -class PluginInputStream; -class PluginOutputStream; -class XPlugin_Impl; -class PluginDisposer; -class PluginEventListener; - -class XPlugin_Impl : public css::plugin::XPlugin, - public PluginControl_Impl, - public css::beans::XPropertyChangeListener -{ -private: - ::osl::Mutex m_aMutex; - Reference< css::lang::XMultiServiceFactory > m_xSMgr; - Reference< css::plugin::XPluginContext > m_rBrowserContext; - - PluginComm* m_pPluginComm; - NPP_t m_aInstance; - NPWindow m_aNPWindow; - std::shared_ptr<SysPlugData> m_pSysPlugData; - rtl_TextEncoding m_aEncoding; - - const char** m_pArgv; - const char** m_pArgn; - int m_nArgs; - OString m_aLastGetUrl; - - Reference< css::awt::XControlModel > m_xModel; - - css::plugin::PluginDescription m_aDescription; - sal_Int16 m_aPluginMode; - - int m_nProvidingState; - int m_nCalledFromPlugin; - PluginDisposer* m_pDisposer; - - ::std::list<PluginInputStream*> m_aInputStreams; - ::std::list<PluginOutputStream*> m_aOutputStreams; - ::std::list<PluginEventListener*> m_aPEventListeners; - OUString m_aURL; - - bool m_bIsDisposed; - -#ifdef MACOSX - void SetSysPlugDataParentView(SystemEnvData const& rEnvData); -#endif - - void prependArg( const char* pName, const char* pValue ); // arguments will be strdup'ed - void initArgs( const Sequence< OUString >& argn, - const Sequence< OUString >& argv, - sal_Int16 mode ); - void freeArgs(); - void handleSpecialArgs(); - - void loadPlugin(); - void destroyInstance(); - void modelChanged(); - -public: - XPlugin_Impl( const Reference< css::lang::XMultiServiceFactory > & rSMgr ); - virtual ~XPlugin_Impl(); - - ::osl::Mutex& getMutex() { return m_aMutex; } - - void destroyStreams(); - - void setLastGetUrl( const OString& rUrl ) { m_aLastGetUrl = rUrl; } - - css::plugin::PluginDescription fitDescription( const OUString& rURL ); - - ::std::list<PluginInputStream*>& getInputStreams() { return m_aInputStreams; } - ::std::list<PluginOutputStream*>& getOutputStreams() { return m_aOutputStreams; } - PluginComm* getPluginComm() { return m_pPluginComm; } - void setPluginComm( PluginComm* comm ) - { - if( ! m_pPluginComm ) - { - m_pPluginComm = comm; - m_pPluginComm->addRef(); - } - } - Reference< css::lang::XMultiServiceFactory > getServiceManager() { return m_xSMgr; } - const css::plugin::PluginDescription& getDescription() const { return m_aDescription; } - rtl_TextEncoding getTextEncoding() { return m_aEncoding; } - NPP_t& getNPPInstance() { return m_aInstance; } - NPWindow& getNPWindow() { return m_aNPWindow; } - - void enterPluginCallback() { m_nCalledFromPlugin++; } - void leavePluginCallback() { m_nCalledFromPlugin--; } - bool isDisposable() { return m_nCalledFromPlugin < 1; } - DECL_LINK_TYPED( secondLevelDispose, void*, void ); - - void addPluginEventListener( PluginEventListener* pListener ) - { m_aPEventListeners.push_back( pListener ); } - void checkListeners( const char* normalizedURL ); - - void initInstance( - const css::plugin::PluginDescription& rDescription, - const Sequence< OUString >& argn, - const Sequence< OUString >& argv, - sal_Int16 mode ); - void initInstance( - const OUString& rURL, - const Sequence< OUString >& argn, - const Sequence< OUString >& argv, - sal_Int16 mode ); - - const OUString& getRefererURL() { return m_aURL; } - OUString getCreationURL(); - - PluginStream* getStreamFromNPStream( NPStream* ); - - const SystemEnvData* getSysChildSysData() - { return _pSysChild->GetSystemData(); } - - const Reference< css::plugin::XPluginContext > & getPluginContext() const - { return m_rBrowserContext; } - void setPluginContext( const Reference< css::plugin::XPluginContext > & ); - - // XInterface - virtual Any SAL_CALL queryInterface( const Type& ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL acquire() throw() override - { OWeakAggObject::acquire(); } - virtual void SAL_CALL release() throw() override - { OWeakAggObject::release(); } - - // OWeakAggObject - virtual Any SAL_CALL queryAggregation( const Type& ) - throw( css::uno::RuntimeException, std::exception ) override; - - // PluginContol_Impl - virtual void SAL_CALL dispose() throw(std::exception) override; - virtual void SAL_CALL createPeer( const Reference< css::awt::XToolkit > & xToolkit, const Reference< css::awt::XWindowPeer > & Parent) throw( RuntimeException, std::exception ) override; - - virtual sal_Bool SAL_CALL setModel( const Reference< css::awt::XControlModel > & Model ) throw( RuntimeException, std::exception ) override; - virtual Reference< css::awt::XControlModel > SAL_CALL getModel()throw( RuntimeException, std::exception ) override - { return m_xModel; } - - virtual void SAL_CALL setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) throw( RuntimeException, std::exception ) override; - - // css::plugin::XPlugin - virtual sal_Bool SAL_CALL provideNewStream(const OUString& mimetype, const Reference< css::io::XActiveDataSource > & stream, const OUString& url, sal_Int32 length, sal_Int32 lastmodified, sal_Bool isfile) throw(std::exception) override; - - // css::beans::XPropertyChangeListener - virtual void SAL_CALL disposing( const css::lang::EventObject& rSource ) throw(std::exception) override; - virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& rEvent) - throw (css::uno::RuntimeException, std::exception) override; -}; - -class PluginManager -{ -private: - Reference< css::lang::XMultiServiceFactory > m_xSMgr; - ::std::list<PluginComm*> m_aPluginComms; - ::std::list<XPlugin_Impl*> m_aAllPlugins; - ::osl::Mutex m_aPluginMutex; - - static PluginManager* pManager; - - PluginManager(); -public: - - static PluginManager& get(); - static void setServiceFactory( const Reference< css::lang::XMultiServiceFactory >& xFactory ); - static const Sequence< OUString >& getAdditionalSearchPaths(); - - ::std::list<PluginComm*>& getPluginComms() { return m_aPluginComms; } - ::std::list<XPlugin_Impl*>& getPlugins() { return m_aAllPlugins; } - ::osl::Mutex& getPluginMutex() { return m_aPluginMutex; } -}; - -class XPluginManager_Impl : - public cppu::WeakAggImplHelper2< css::plugin::XPluginManager, - css::lang::XServiceInfo > -{ - Reference< css::uno::XComponentContext > m_xContext; -public: - XPluginManager_Impl( const Reference< css::uno::XComponentContext > & ); - virtual ~XPluginManager_Impl(); - - static XPlugin_Impl* getXPluginFromNPP( NPP ); - static XPlugin_Impl* getPluginImplementation( const Reference< css::plugin::XPlugin >& plugin ); - - virtual Reference< css::plugin::XPluginContext > SAL_CALL createPluginContext() throw(std::exception) override; - - // has to be implemented per system - static Sequence< css::plugin::PluginDescription > SAL_CALL impl_getPluginDescriptions() throw(css::uno::RuntimeException, std::exception); - // calls system specific impl_getPluginDescriptions - // checks whether plugins are disabled - virtual Sequence< css::plugin::PluginDescription > SAL_CALL getPluginDescriptions() - throw (css::uno::RuntimeException, std::exception) override; - - virtual Reference< css::plugin::XPlugin > SAL_CALL createPlugin( const Reference< css::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< OUString >& argn, const Sequence< OUString >& argv, const css::plugin::PluginDescription& plugintype) throw( RuntimeException,css::plugin::PluginException, std::exception ) override; - - virtual Reference< css::plugin::XPlugin > SAL_CALL createPluginFromURL( const Reference< css::plugin::XPluginContext > & acontext, sal_Int16 mode, const Sequence< OUString >& argn, const Sequence< OUString >& argv, const Reference< css::awt::XToolkit > & toolkit, const Reference< css::awt::XWindowPeer > & parent, const OUString& url ) throw (css::uno::RuntimeException, std::exception) override; - - virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw() override; - virtual OUString SAL_CALL getImplementationName() throw() override; - - Sequence< OUString > SAL_CALL getSupportedServiceNames() throw( ) override; - static Sequence< OUString > getSupportedServiceNames_Static() throw( ); - static OUString getImplementationName_Static() throw( ) - { - /** the soplayer uses this name in its source! maybe not after 5.2 */ - return OUString( "com.sun.star.extensions.PluginManager" ); - } -}; -Reference< XInterface > SAL_CALL PluginManager_CreateInstance( const Reference< css::lang::XMultiServiceFactory > & ) throw( Exception ); - -enum PluginStreamType { InputStream, OutputStream }; - -class PluginStream -{ -protected: - css::uno::WeakReference<css::uno::XInterface> m_wPlugin; - XPlugin_Impl* m_pPlugin; - NPStream m_aNPStream; -public: - PluginStream( XPlugin_Impl* pPlugin, - const char* url, sal_uInt32 len, sal_uInt32 lastmod ); - virtual ~PluginStream(); - - NPStream& getStream() { return m_aNPStream; } - - virtual PluginStreamType getStreamType() = 0; -}; - -class PluginInputStream : - public PluginStream, - public cppu::WeakAggImplHelper2< - css::io::XOutputStream, - css::io::XConnectable - > -{ -private: - ::ucbhelper::Content* m_pContent; - sal_Int32 m_nMode; - sal_uInt32 m_nWritePos; - - Reference< css::io::XActiveDataSource > m_xSource; - // hold a reference on input until closeOutput is called - - Reference< css::io::XConnectable > m_xPredecessor; - Reference< css::io::XConnectable > m_xSuccessor; - - // needed to hold a reference to self in NP_SEEK mode - Reference< css::io::XOutputStream > m_xSelf; - - SvFileStream m_aFileStream; -public: - PluginInputStream( XPlugin_Impl* pPlugin, - const char* url, sal_uInt32 len, sal_uInt32 lastmod ); - - PluginInputStream() : PluginStream( nullptr, nullptr, 0, 0 ) {} - - virtual ~PluginInputStream(); - - virtual PluginStreamType getStreamType() override; - - void setMode( sal_Int32 nMode ); - sal_uInt32 read( sal_uInt32 offset, sal_Int8* buffer, sal_uInt32 size ); - void setSource( const Reference< css::io::XActiveDataSource >& xSource ) { m_xSource = xSource; } - // get contents ot url via ucbhelper::Content - void load(); - - // clear reference - bool releaseSelf() - { bool bRet = m_xSelf.is(); m_xSelf.clear(); return bRet; } - - // XOutputStream - virtual void SAL_CALL writeBytes( const Sequence<sal_Int8>& ) throw(std::exception) override; - virtual void SAL_CALL flush() throw(std::exception) override; - virtual void SAL_CALL closeOutput() throw(std::exception) override; - - // XConnectable - virtual void SAL_CALL setPredecessor( const Reference< css::io::XConnectable >& xPredecessor ) throw(std::exception) override - { m_xPredecessor = xPredecessor; } - virtual Reference< css::io::XConnectable > SAL_CALL getPredecessor() throw(std::exception) override - { return m_xPredecessor; } - - virtual void SAL_CALL setSuccessor( const Reference< css::io::XConnectable >& xSuccessor ) throw(std::exception) override - { m_xSuccessor = xSuccessor; } - virtual Reference< css::io::XConnectable > SAL_CALL getSuccessor() throw(std::exception) override - { return m_xSuccessor; } -}; - -class PluginOutputStream : public PluginStream -{ -private: - Reference< css::io::XOutputStream > m_xStream; -public: - PluginOutputStream( XPlugin_Impl* pPlugin, const char* url, - sal_uInt32 len, sal_uInt32 lastmod ); - virtual ~PluginOutputStream(); - - virtual PluginStreamType getStreamType() override; - - Reference< css::io::XOutputStream > & getOutputStream() { return m_xStream; } -}; - -class PluginEventListener : - public cppu::WeakAggImplHelper1< css::lang::XEventListener > -{ -private: - XPlugin_Impl* m_pPlugin; - Reference< css::plugin::XPlugin > m_xPlugin; // just to hold the plugin - char* m_pUrl; - char* m_pNormalizedUrl; - void* m_pNotifyData; -public: - PluginEventListener( XPlugin_Impl*, - const char* url, - const char* normurl, - void* notifyData ); - virtual ~PluginEventListener(); - - const char* getURL() { return m_pUrl; } - const char* getNormalizedURL() { return m_pNormalizedUrl; } - void* getNotifyData() { return m_pNotifyData; } - - // css::lang::XEventListener - virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw(std::exception) override; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/inc/plugin/model.hxx b/extensions/source/plugin/inc/plugin/model.hxx deleted file mode 100644 index 227ae6f545bb..000000000000 --- a/extensions/source/plugin/inc/plugin/model.hxx +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MODEL_HXX -#define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MODEL_HXX - -#include <com/sun/star/io/XObjectInputStream.hpp> -#include <com/sun/star/io/XPersistObject.hpp> -#include <com/sun/star/io/XObjectOutputStream.hpp> -#include <com/sun/star/lang/XServiceName.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/awt/XControlModel.hpp> -#include <com/sun/star/awt/XControl.hpp> - -#include <cppuhelper/propshlp.hxx> -#include <cppuhelper/weakagg.hxx> -#include <rtl/alloc.h> - -#include <list> - -using namespace com::sun::star::uno; - -class BroadcasterHelperHolder -{ -protected: - ::cppu::OBroadcastHelper m_aHelper; -public: - BroadcasterHelperHolder( osl::Mutex& rMutex ) : - m_aHelper( rMutex ) {} - ~BroadcasterHelperHolder() {} -}; - -class PluginModel : public BroadcasterHelperHolder, - public cppu::OPropertySetHelper, - public cppu::OPropertyArrayHelper, - public cppu::OWeakAggObject, - public css::lang::XComponent, - public css::io::XPersistObject, - public css::awt::XControlModel -{ - private: - OUString m_aCreationURL; - OUString m_aMimeType; - - std::list< Reference< css::lang::XEventListener > > - m_aDisposeListeners; - public: - // these are here to force memory de/allocation to sal lib. - static void * SAL_CALL operator new( size_t nSize ) throw() - { return rtl_allocateMemory( nSize ); } - static void SAL_CALL operator delete( void * pMem ) throw() - { rtl_freeMemory( pMem ); } - - PluginModel(); - PluginModel( const OUString& rURL, const OUString& rMimeType ); - virtual ~PluginModel(); - - // XInterface - virtual Any SAL_CALL queryInterface( const Type& rType ) throw( css::uno::RuntimeException, std::exception ) override - { return OWeakAggObject::queryInterface( rType ); } - virtual void SAL_CALL acquire() throw() override - { OWeakAggObject::acquire(); } - virtual void SAL_CALL release() throw() override - { OWeakAggObject::release(); } - - virtual Any SAL_CALL queryAggregation( const Type& ) throw( css::uno::RuntimeException, std::exception ) override; - - - // css::lang::XTypeProvider - - static Sequence< OUString > SAL_CALL getSupportedServiceNames_Static() throw( ); - static OUString SAL_CALL getImplementationName_Static() throw( ) - { - /** the soplayer uses this name in its source! maybe not after 5.2 */ - return OUString( "com.sun.star.extensions.PluginModel" ); - } - - // OPropertySetHelper - virtual cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() override; - virtual sal_Bool SAL_CALL convertFastPropertyValue( Any & rConvertedValue, - Any & rOldValue, - sal_Int32 nHandle, - const Any& rValue ) throw() override; - virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, - const Any& rValue ) - throw(css::uno::Exception, std::exception) override; - virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const throw() override; - virtual Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() throw(std::exception) override; - - // css::io::XPersistObject - virtual OUString SAL_CALL getServiceName() throw(std::exception) override; - virtual void SAL_CALL write(const Reference< css::io::XObjectOutputStream > & OutStream) throw(std::exception) override; - virtual void SAL_CALL read(const Reference< css::io::XObjectInputStream > & InStream) throw(std::exception) override; - - // css::lang::XComponent - virtual void SAL_CALL addEventListener( const Reference< css::lang::XEventListener > & l ) throw(std::exception) override; - virtual void SAL_CALL removeEventListener( const Reference< css::lang::XEventListener > & l ) throw(std::exception) override; - virtual void SAL_CALL dispose() throw(std::exception) override; - private: - using cppu::OPropertySetHelper::getFastPropertyValue; -}; -Reference< XInterface > SAL_CALL PluginModel_CreateInstance( const Reference< css::lang::XMultiServiceFactory > & ) throw( Exception ); - -#endif // INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MODEL_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/inc/plugin/multiplx.hxx b/extensions/source/plugin/inc/plugin/multiplx.hxx deleted file mode 100644 index dc0e480e1b33..000000000000 --- a/extensions/source/plugin/inc/plugin/multiplx.hxx +++ /dev/null @@ -1,169 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MULTIPLX_HXX -#define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MULTIPLX_HXX - -#include <com/sun/star/awt/XControl.hpp> -#include <com/sun/star/awt/XKeyListener.hpp> -#include <com/sun/star/awt/XPaintListener.hpp> -#include <com/sun/star/awt/KeyEvent.hpp> -#include <com/sun/star/awt/KeyModifier.hpp> -#include <com/sun/star/awt/XMouseMotionListener.hpp> -#include <com/sun/star/awt/FocusEvent.hpp> -#include <com/sun/star/awt/XWindowListener.hpp> -#include <com/sun/star/awt/XActivateListener.hpp> -#include <com/sun/star/awt/MouseEvent.hpp> -#include <com/sun/star/awt/XTopWindowListener.hpp> -#include <com/sun/star/awt/PaintEvent.hpp> -#include <com/sun/star/awt/InputEvent.hpp> -#include <com/sun/star/awt/KeyGroup.hpp> -#include <com/sun/star/awt/Key.hpp> -#include <com/sun/star/awt/WindowEvent.hpp> -#include <com/sun/star/awt/XMouseListener.hpp> -#include <com/sun/star/awt/KeyFunction.hpp> -#include <com/sun/star/awt/FocusChangeReason.hpp> -#include <com/sun/star/awt/MouseButton.hpp> -#include <com/sun/star/awt/XFocusListener.hpp> -#include <com/sun/star/awt/XTopWindow.hpp> -#include <com/sun/star/awt/XWindow.hpp> -#include <com/sun/star/awt/PosSize.hpp> - -#include <cppuhelper/implbase7.hxx> -#include <cppuhelper/interfacecontainer.hxx> - -using namespace com::sun::star::uno; - -struct MRCListenerMultiplexerHelper_Mutex -{ - ::osl::Mutex aMutex; -}; - -class MRCListenerMultiplexerHelper : - public MRCListenerMultiplexerHelper_Mutex, - - public ::cppu::WeakAggImplHelper7< - css::awt::XFocusListener, - css::awt::XWindowListener, - css::awt::XKeyListener, - css::awt::XMouseListener, - css::awt::XMouseMotionListener, - css::awt::XPaintListener, - css::awt::XTopWindowListener > -{ -public: - /** - * Create a Multiplexer of XWindowEvents. - * - * @param rControl The control. All listeners think that this is the original - * broadcaster. - * @param rPeer The peer from which the original events are dispatched. Null is - * allowed. - */ - MRCListenerMultiplexerHelper( const Reference< css::awt::XWindow > & rControl, const Reference< css::awt::XWindow > & rPeer ); - - /** - * Remove all listeners from the previous set peer and add the needed listeners to rPeer. - * @param rPeer The peer from which the original events are dispatched. Null is - * allowed. - */ - void setPeer( const Reference< css::awt::XWindow > & rPeer ); - - /** - * Remove all listeners and send a disposing message. - */ - void disposeAndClear(); - - /** - * Add the specified listener to the source. - */ - void advise( const Type& type, const Reference< XInterface > & listener); - /** - * Remove the specified listener from the source. - */ - void unadvise(const Type& type, const Reference< XInterface > & listener); - - // css::lang::XEventListener - void SAL_CALL disposing(const css::lang::EventObject& Source) throw(std::exception) override; - // css::awt::XFocusListener - void SAL_CALL focusGained(const css::awt::FocusEvent& e) throw(std::exception) override; - void SAL_CALL focusLost(const css::awt::FocusEvent& e) throw(std::exception) override; - // css::awt::XWindowListener - void SAL_CALL windowResized(const css::awt::WindowEvent& e) throw(std::exception) override; - void SAL_CALL windowMoved(const css::awt::WindowEvent& e) throw(std::exception) override; - void SAL_CALL windowShown(const css::lang::EventObject& e) throw(std::exception) override; - void SAL_CALL windowHidden(const css::lang::EventObject& e) throw(std::exception) override; - // css::awt::XKeyListener - void SAL_CALL keyPressed( const css::awt::KeyEvent& e ) throw(std::exception) override; - void SAL_CALL keyReleased( const css::awt::KeyEvent& e ) throw(std::exception) override; - // css::awt::XMouseListener - void SAL_CALL mousePressed(const css::awt::MouseEvent& e) throw(std::exception) override; - void SAL_CALL mouseReleased(const css::awt::MouseEvent& e) throw(std::exception) override; - void SAL_CALL mouseEntered(const css::awt::MouseEvent& e) throw(std::exception) override; - void SAL_CALL mouseExited(const css::awt::MouseEvent& e) throw(std::exception) override; - // css::awt::XMouseMotionListener - void SAL_CALL mouseDragged(const css::awt::MouseEvent& e) throw(std::exception) override; - void SAL_CALL mouseMoved(const css::awt::MouseEvent& e) throw(std::exception) override; - // css::awt::XPaintListener - void SAL_CALL windowPaint(const css::awt::PaintEvent& e) throw(std::exception) override; - // css::awt::XTopWindowListener - void SAL_CALL windowOpened( const css::lang::EventObject& e ) throw(std::exception) override; - void SAL_CALL windowClosing( const css::lang::EventObject& e ) throw(std::exception) override; - void SAL_CALL windowClosed( const css::lang::EventObject& e ) throw(std::exception) override; - void SAL_CALL windowMinimized( const css::lang::EventObject& e ) throw(std::exception) override; - void SAL_CALL windowNormalized( const css::lang::EventObject& e ) throw(std::exception) override; - void SAL_CALL windowActivated( const css::lang::EventObject& e ) throw(std::exception) override; - void SAL_CALL windowDeactivated( const css::lang::EventObject& e ) throw(std::exception) override; -protected: - /** - * Remove the listener with the uik rUik from the peer rPeer. - * @param rPeer the peer from which the listener is removed. - * @param rUik the listener uik, which specify the type of the listener. - */ - void adviseToPeer( const Reference< css::awt::XWindow > & rPeer, const Type & type ); - /** - * Add the listener with the uik rUik to the peer rPeer. - * @param rPeer the peer to which the listener is added. - * @param rUik the listener uik, which specify the type of the listener. - */ - void unadviseFromPeer( const Reference< css::awt::XWindow > & rPeer, const Type & type ); -private: - /** The source of the events. Normally this is the peer object.*/ - Reference< css::awt::XWindow > xPeer; - WeakReference< css::awt::XControl > xControl; - ::cppu::OMultiTypeInterfaceContainerHelper aListenerHolder; - - - MRCListenerMultiplexerHelper( const MRCListenerMultiplexerHelper & ) = delete; - MRCListenerMultiplexerHelper & operator = ( const MRCListenerMultiplexerHelper & ) = delete; -}; - -#endif // INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_MULTIPLX_HXX - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/inc/plugin/plcom.hxx b/extensions/source/plugin/inc/plugin/plcom.hxx deleted file mode 100644 index 213c6c494a96..000000000000 --- a/extensions/source/plugin/inc/plugin/plcom.hxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_PLCOM_HXX -#define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_PLCOM_HXX - -#include <list> - -class XPlugin_Impl; - -class PluginComm -{ -protected: - int m_nRefCount; - OString m_aLibName; - std::list< OUString > m_aFilesToDelete; -public: - PluginComm( const OString& rLibName, bool bReusable = true ); - virtual ~PluginComm(); - - void addRef() { m_nRefCount++; } - void decRef() { m_nRefCount--; if( ! m_nRefCount ) delete this; } - - const OString& getLibName() { return m_aLibName; } - - void addFileToDelete( const OUString& filename ) - { m_aFilesToDelete.push_back( filename ); } - - virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ) = 0; - virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, - NPError reason ) = 0; - virtual NPError NPP_Initialize() = 0; - virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, - uint16_t mode, int16_t argc, - char* argn[], char* argv[], - NPSavedData *saved ) = 0; - virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, - NPStream* stream, - NPBool seekable, uint16_t* stype ) = 0; - virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ) = 0; - virtual void NPP_Shutdown() = 0; - virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, - const char* fname ) = 0; - virtual void NPP_URLNotify( NPP instance, const char* url, - NPReason reason, void* notifyData ) = 0; - virtual int32_t NPP_Write( NPP instance, NPStream* stream, int32_t offset, - int32_t len, void* buffer ) = 0; - virtual int32_t NPP_WriteReady( NPP instance, NPStream* stream ) = 0; - - NPError NPP_SetWindow( XPlugin_Impl* ); - NPError NPP_Destroy( XPlugin_Impl*, NPSavedData** save ); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/inc/plugin/plctrl.hxx b/extensions/source/plugin/inc/plugin/plctrl.hxx deleted file mode 100644 index 6f75cef3d8ec..000000000000 --- a/extensions/source/plugin/inc/plugin/plctrl.hxx +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_PLCTRL_HXX -#define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_PLCTRL_HXX - -#include <cppuhelper/weak.hxx> -#include <plugin/multiplx.hxx> -#include <com/sun/star/beans/PropertyValues.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/beans/PropertyState.hpp> -#include <com/sun/star/beans/XPropertySetInfo.hpp> -#include <com/sun/star/beans/XMultiPropertySet.hpp> -#include <com/sun/star/beans/XFastPropertySet.hpp> -#include <com/sun/star/beans/XVetoableChangeListener.hpp> -#include <com/sun/star/beans/XPropertyState.hpp> -#include <com/sun/star/beans/XPropertyStateChangeListener.hpp> -#include <com/sun/star/beans/PropertyAttribute.hpp> -#include <com/sun/star/beans/XPropertiesChangeListener.hpp> -#include <com/sun/star/beans/XPropertyChangeListener.hpp> -#include <com/sun/star/beans/XPropertyAccess.hpp> -#include <com/sun/star/beans/XPropertyContainer.hpp> -#include <com/sun/star/beans/PropertyStateChangeEvent.hpp> -#include <com/sun/star/beans/PropertyChangeEvent.hpp> -#include <com/sun/star/awt/XVclContainerPeer.hpp> -#include <com/sun/star/awt/XVclWindowPeer.hpp> -#include <com/sun/star/awt/XControlModel.hpp> -#include <com/sun/star/awt/XUnoControlContainer.hpp> -#include <com/sun/star/awt/XControlContainer.hpp> -#include <com/sun/star/awt/VclWindowPeerAttribute.hpp> -#include <com/sun/star/awt/XVclContainer.hpp> -#include <com/sun/star/awt/XControl.hpp> -#include <com/sun/star/awt/XTopWindow.hpp> -#include <com/sun/star/awt/XWindow.hpp> -#include <com/sun/star/awt/PosSize.hpp> - -#include <cppuhelper/implbase4.hxx> -#include <vcl/vclptr.hxx> - -#include <list> - -class SystemChildWindow; - - -class PluginControl_Impl : public ::cppu::WeakAggImplHelper4< - css::awt::XControl, - css::awt::XWindow, - css::awt::XFocusListener, - css::awt::XView > -{ -public: - // css::awt::XControl - virtual void SAL_CALL setContext( const css::uno::Reference< css::uno::XInterface > & xContext ) throw( css::uno::RuntimeException, std::exception ) override - { _xContext = xContext; } - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getContext() throw( css::uno::RuntimeException, std::exception ) override - { return _xContext; } - - virtual sal_Bool SAL_CALL setModel( const css::uno::Reference< css::awt::XControlModel > & Model ) throw( css::uno::RuntimeException, std::exception ) override = 0; - virtual css::uno::Reference< css::awt::XControlModel > SAL_CALL getModel() throw( css::uno::RuntimeException, std::exception ) override = 0; - - virtual css::uno::Reference< css::awt::XView > SAL_CALL getView() throw( css::uno::RuntimeException, std::exception ) override - { return static_cast<css::awt::XView*>(this); } - - virtual sal_Bool SAL_CALL isTransparent() throw( css::uno::RuntimeException, std::exception ) override - { return sal_False; } - - virtual void SAL_CALL setDesignMode( sal_Bool bOn ) throw( css::uno::RuntimeException, std::exception ) override; - virtual sal_Bool SAL_CALL isDesignMode() throw( css::uno::RuntimeException, std::exception ) override - { return _bInDesignMode; } - - virtual void SAL_CALL createPeer( const css::uno::Reference< css::awt::XToolkit > & xToolkit, const css::uno::Reference< css::awt::XWindowPeer > & Parent) throw( css::uno::RuntimeException, std::exception ) override; - virtual css::uno::Reference< css::awt::XWindowPeer > SAL_CALL getPeer() throw( css::uno::RuntimeException, std::exception ) override - { return _xPeer; } - - // css::awt::XWindow - virtual void SAL_CALL setVisible( sal_Bool bVisible ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL setEnable( sal_Bool bEnable ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL setFocus() throw( css::uno::RuntimeException, std::exception ) override; - - virtual void SAL_CALL setPosSize( sal_Int32 nX_, sal_Int32 nY_, sal_Int32 nWidth_, sal_Int32 nHeight_, sal_Int16 nFlags ) throw( css::uno::RuntimeException, std::exception ) override; - virtual css::awt::Rectangle SAL_CALL getPosSize() throw( css::uno::RuntimeException, std::exception ) override; - - virtual void SAL_CALL addWindowListener( const css::uno::Reference< css::awt::XWindowListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL removeWindowListener( const css::uno::Reference< css::awt::XWindowListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL addFocusListener( const css::uno::Reference< css::awt::XFocusListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL removeFocusListener( const css::uno::Reference< css::awt::XFocusListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL addKeyListener( const css::uno::Reference< css::awt::XKeyListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL removeKeyListener( const css::uno::Reference< css::awt::XKeyListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL addMouseListener( const css::uno::Reference< css::awt::XMouseListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL removeMouseListener( const css::uno::Reference< css::awt::XMouseListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL addMouseMotionListener( const Reference< css::awt::XMouseMotionListener > & l ) throw( RuntimeException, std::exception ) override; - virtual void SAL_CALL removeMouseMotionListener( const css::uno::Reference< css::awt::XMouseMotionListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL addPaintListener( const css::uno::Reference< css::awt::XPaintListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL removePaintListener( const css::uno::Reference< css::awt::XPaintListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - - // css::lang::XEventListener - virtual void SAL_CALL disposing( const css::lang::EventObject & rSource ) throw( css::uno::RuntimeException, std::exception ) override; - // css::awt::XFocusListener - virtual void SAL_CALL focusGained( const css::awt::FocusEvent & rEvt ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL focusLost( const css::awt::FocusEvent & rEvt ) throw( css::uno::RuntimeException, std::exception ) override; - - // css::lang::XComponent - virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener > & l ) throw( css::uno::RuntimeException, std::exception ) override; - - virtual void SAL_CALL dispose() throw( css::uno::RuntimeException, std::exception ) override; - - // css::awt::XView - virtual sal_Bool SAL_CALL setGraphics( const css::uno::Reference< css::awt::XGraphics > & /*aDevice*/ ) throw( css::uno::RuntimeException, std::exception ) override - { return sal_False; } - virtual css::uno::Reference< css::awt::XGraphics > SAL_CALL getGraphics() throw( css::uno::RuntimeException, std::exception ) override - { return css::uno::Reference< css::awt::XGraphics > (); } - - virtual css::awt::Size SAL_CALL getSize() throw( css::uno::RuntimeException, std::exception ) override - { return css::awt::Size(_nWidth, _nHeight); } - - virtual void SAL_CALL draw( sal_Int32 x, sal_Int32 y ) throw( css::uno::RuntimeException, std::exception ) override; - virtual void SAL_CALL setZoom( float ZoomX, float ZoomY ) throw( css::uno::RuntimeException, std::exception ) override; - -public: - PluginControl_Impl(); - virtual ~PluginControl_Impl(); - - MRCListenerMultiplexerHelper* getMultiplexer(); - -protected: - void releasePeer(); - -protected: - ::std::list< Reference< css::lang::XEventListener > > _aDisposeListeners; - MRCListenerMultiplexerHelper* _pMultiplexer; - - Reference< XInterface > _xContext; - - sal_Int32 _nX; - sal_Int32 _nY; - sal_Int32 _nWidth; - sal_Int32 _nHeight; - sal_Int16 _nFlags; - - bool _bVisible; - bool _bInDesignMode; - bool _bEnable; - - VclPtr<SystemChildWindow> _pSysChild; - css::uno::Reference< css::awt::XWindowPeer > _xPeer; - css::uno::Reference< css::awt::XWindow > _xPeerWindow; - - css::uno::Reference< css::awt::XWindow > _xParentWindow; - css::uno::Reference< css::awt::XWindowPeer > _xParentPeer; -}; - -#endif - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/inc/plugin/unx/mediator.hxx b/extensions/source/plugin/inc/plugin/unx/mediator.hxx deleted file mode 100644 index 8c8dbcf94602..000000000000 --- a/extensions/source/plugin/inc/plugin/unx/mediator.hxx +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_MEDIATOR_HXX -#define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_MEDIATOR_HXX - -#include <string.h> -#include <tools/link.hxx> -#include <tools/solar.h> -#include <osl/pipe.hxx> -#include <osl/mutex.hxx> -#include <osl/conditn.hxx> -#include <osl/thread.hxx> - -#include <vector> - -struct MediatorMessage -{ - sal_uLong m_nID; - sal_uLong m_nBytes; - char* m_pBytes; - char* m_pRun; - - MediatorMessage() : m_nID( 0 ), m_nBytes( 0 ), - m_pBytes( nullptr ), m_pRun( nullptr ) {} - MediatorMessage( sal_uLong nID, sal_uLong nBytes, char* pBytes ) : - m_nID( nID ),m_nBytes( nBytes ), m_pRun( nullptr ) - { - m_pBytes = new char[ m_nBytes ]; - memcpy( m_pBytes, pBytes, (size_t)m_nBytes ); - } - - ~MediatorMessage() - { - if( m_pBytes ) - delete [] m_pBytes; - } - - sal_uLong ExtractULONG(); - char* GetString(); - sal_uInt32 GetUINT32(); - void* GetBytes( sal_uLong& ); - void* GetBytes() { sal_uLong nBytes; return GetBytes( nBytes ); } -}; - -class MediatorListener; - -class Mediator -{ - friend class MediatorListener; -protected: - int m_nSocket; - - std::vector<MediatorMessage*> m_aMessageQueue; - osl::Mutex m_aQueueMutex; - osl::Mutex m_aSendMutex; - // only one thread can send a message at any given time - osl::Condition m_aNewMessageCdtn; - MediatorListener* m_pListener; - // thread to fill the queue - - sal_uLong m_nCurrentID; - // will be constantly increased with each message sent - bool m_bValid; - - Link<Mediator*,void> m_aConnectionLostHdl; - Link<Mediator*,void> m_aNewMessageHdl; -public: - Mediator( int nSocket ); - virtual ~Mediator(); - - // mark mediator as invalid. No more messages will be processed, - // SendMessage, WaitForMessage, TransactMessage will return immediately - // with error - void invalidate() { m_bValid = false; } - - sal_uLong SendMessage( sal_uLong nBytes, const char* pBytes, sal_uLong nMessageID = 0 ); - - bool WaitForMessage( sal_uLong nTimeOut = 5000 ); - // timeout in ms - // TRUE: Message came in - // FALSE: timed out - // if timeout is set, WaitForMessage will wait even if there are messages - // in the queue - - virtual MediatorMessage* WaitForAnswer( sal_uLong nMessageID ); - // wait for an answer message ( ID >= 1 << 24 ) - // the message will be removed from the queue and returned - - MediatorMessage* TransactMessage( sal_uLong nBytes, char* pBytes ); - // sends a message and waits for an answer - - MediatorMessage* GetNextMessage( bool bWait = false ); - - - void SetConnectionLostHdl( const Link<Mediator*,void>& rLink ) - { - m_aConnectionLostHdl = rLink; - } - - void SetNewMessageHdl( const Link<Mediator*,void>& rLink ) - { - m_aNewMessageHdl = rLink; - } -}; - -class MediatorListener : public osl::Thread -{ - friend class Mediator; -private: - Mediator* m_pMediator; - ::osl::Mutex m_aMutex; - - MediatorListener( Mediator* ); - virtual ~MediatorListener(); - - virtual void run() override; - virtual void onTerminated() override; -}; - -#endif // INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_MEDIATOR_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/inc/plugin/unx/plugcon.hxx b/extensions/source/plugin/inc/plugin/unx/plugcon.hxx deleted file mode 100644 index 81325eb30f59..000000000000 --- a/extensions/source/plugin/inc/plugin/unx/plugcon.hxx +++ /dev/null @@ -1,206 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_PLUGCON_HXX -#define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_PLUGCON_HXX - -#include <stdarg.h> -#include <string.h> - -#include <list> -#include <vector> -#include <plugin/unx/mediator.hxx> - -#include <prex.h> - -#include <X11/Xlib.h> -extern "C" { -#include <X11/Intrinsic.h> -} -#include <X11/Shell.h> -#include <X11/IntrinsicP.h> /* Intrinsics Definitions*/ -#include <X11/StringDefs.h> /* Standard Name-String definitions*/ -#if defined USE_MOTIF -#include <Xm/DrawingA.h> -#else -#include <X11/Composite.h> -#endif -#include <X11/Xatom.h> -#ifndef XP_UNIX -# define XP_UNIX -#endif -#define MOZ_X11 -#include <stdio.h> - -#if ! defined ( _NPAPI_H_) && ! defined (npapi_h_) -extern "C" { -#include <npsdk/npupp.h> -} -#include "npapi.h" - -#if NP_VERSION_MINOR < 17 -// compatibility hack: compile with older NPN api header, but define -// some later introduced constants -// for gcc 3 -#define NP_ABI_MASK 0x10000000 -#define NPNVSupportsXEmbedBool ((NPNVariable)14) -#define NPPVpluginNeedsXEmbed ((NPPVariable)14) -#define NPNVToolkit ((int)(13 | NP_ABI_MASK)) -#define NPNVGtk12 1 -#define NPNVGtk2 2 -#endif -#endif - -#include <config_vclplug.h> - -#if ENABLE_GTK -#define GLIB_DISABLE_DEPRECATION_WARNINGS -#include <gtk/gtk.h> -#include <gdk/gdkx.h> -#else -#define GtkWidget void -#endif - -#include <postx.h> - -#include <tools/solar.h> - -class ConnectorInstance -{ -public: - NPP instance; - NPWindow window; - NPSetWindowCallbackStruct ws_info; - char* pMimeType; - void* pShell; - void* pWidget; - - GtkWidget* pGtkWindow; - GtkWidget* pGtkWidget; - - bool bShouldUseXEmbed; - - int nArg; - char** argn; - char** argv; - char* pArgnBuf; - char* pArgvBuf; - NPSavedData aData; - - ConnectorInstance( NPP inst, char* type, - int args, char* pargnbuf, sal_uLong nargnbytes, - char* pargvbuf, sal_uLong nargvbytes, - char* savedata, sal_uLong savebytes ); - ~ConnectorInstance(); -}; - -class PluginConnector : public Mediator -{ -protected: - osl::Mutex m_aUserEventMutex; - - static std::vector<PluginConnector*> allConnectors; - - DECL_LINK_TYPED( NewMessageHdl, Mediator*, void ); - DECL_LINK_TYPED( WorkOnNewMessageHdl, void*, void ); - - std::vector<NPStream*> m_aNPWrapStreams; - std::vector<ConnectorInstance*> m_aInstances; - - static sal_uLong FillBuffer( char*&, const char*, sal_uLong, va_list ); -public: - PluginConnector( int nSocket ); - virtual ~PluginConnector(); - - virtual MediatorMessage* WaitForAnswer( sal_uLong nMessageID ) override; - MediatorMessage* Transact( const char*, sal_uLong, ... ); - MediatorMessage* Transact( sal_uInt32, ... ); - void Respond( sal_uLong nID, char*, sal_uLong, ... ); - sal_uLong Send( sal_uInt32, ... ); - - static const sal_uInt32 UnknownStreamID = 0xffffffff; - static const sal_uInt32 UnknownNPPID = 0xffffffff; - - sal_uInt32 GetStreamID( NPStream* pStream ); - sal_uInt32 GetNPPID( NPP ); - - std::vector<NPStream*>& getStreamList() { return m_aNPWrapStreams; } - - static NPError GetNPError( MediatorMessage* pMes ) - { - NPError* pErr = static_cast<NPError*>(pMes->GetBytes()); - NPError aErr = *pErr; - delete [] pErr; - return aErr; - } - - void CallWorkHandler() - { - LINK( this, PluginConnector, WorkOnNewMessageHdl ). - Call( static_cast<Mediator*>(this) ); - } -}; - -enum CommandAtoms -{ - eNPN_GetURL, - eNPN_GetURLNotify, - eNPN_DestroyStream, - eNPN_NewStream, - eNPN_PostURLNotify, - eNPN_PostURL, - eNPN_RequestRead, - eNPN_Status, - eNPN_Version, - eNPN_Write, - eNPN_UserAgent, - - eNPP_DestroyStream, - eNPP_Destroy, - eNPP_DestroyPhase2, - eNPP_NewStream, - eNPP_New, - eNPP_SetWindow, - eNPP_StreamAsFile, - eNPP_URLNotify, - eNPP_WriteReady, - eNPP_Write, - eNPP_GetMIMEDescription, - eNPP_Initialize, - eNPP_Shutdown, - - eMaxCommand -}; - -const char* GetCommandName( CommandAtoms ); - -#define POST_NONCONST_STRING( x ) x ? x : const_cast<char*>(""), x ? strlen(x) : 1 -#define POST_STRING( x ) x ? x : "", x ? strlen(x) : 1 - -#endif // INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_PLUGCON_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/inc/plugin/unx/sysplug.hxx b/extensions/source/plugin/inc/plugin/unx/sysplug.hxx deleted file mode 100644 index 03772a62ae2b..000000000000 --- a/extensions/source/plugin/inc/plugin/unx/sysplug.hxx +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_SYSPLUG_HXX -#define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_UNX_SYSPLUG_HXX - -#include <unistd.h> - -#include <plugin/unx/plugcon.hxx> -#include <plugin/plcom.hxx> -#include <vcl/sysdata.hxx> - -class UnxPluginComm : public PluginComm, public PluginConnector -{ -private: - pid_t m_nCommPID; -public: - UnxPluginComm( const OUString& mimetype, - const OUString& library, - Window aParent, - int nDescriptor1, - int nDescriptor2 - ); - virtual ~UnxPluginComm(); - - using PluginComm::NPP_Destroy; - virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ) override; - virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, - NPError reason ) override; - virtual NPError NPP_Initialize() override; - virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, - uint16_t mode, int16_t argc, - char* argn[], char* argv[], NPSavedData *saved ) override; - virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, - NPStream* stream, - NPBool seekable, uint16_t* stype ) override; - - using PluginComm::NPP_SetWindow; - virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ) override; - virtual void NPP_Shutdown() override; - virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, - const char* fname ) override; - virtual void NPP_URLNotify( NPP instance, const char* url, NPReason reason, - void* notifyData ) override; - virtual int32_t NPP_Write( NPP instance, NPStream* stream, int32_t offset, - int32_t len, void* buffer ) override; - virtual int32_t NPP_WriteReady( NPP instance, NPStream* stream ) override; - - static bool getPluginappPath(OString * path); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/inc/plugin/win/sysplug.hxx b/extensions/source/plugin/inc/plugin/win/sysplug.hxx deleted file mode 100644 index 38c5abf3d62f..000000000000 --- a/extensions/source/plugin/inc/plugin/win/sysplug.hxx +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_WIN_SYSPLUG_HXX -#define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_INC_PLUGIN_WIN_SYSPLUG_HXX - -#if defined _MSC_VER -#pragma warning (push,1) -#pragma warning (disable:4005) -#endif - -#include <tchar.h> - -#if defined _MSC_VER -#pragma pack( push, 8 ) -#endif -#include "npapi.h" -#include <npsdk/npupp.h> -#if defined _MSC_VER -#pragma pack( pop ) -#endif - -#if defined _MSC_VER -#pragma warning (pop) -#endif - -#include <list> -#include <map> -#include <algorithm> - -#include <plugin/plcom.hxx> -#include <vcl/threadex.hxx> - - -class PluginComm_Impl : - public PluginComm, - public vcl::SolarThreadExecutor - -{ - enum CallType { - eNPP_Destroy, - eNPP_DestroyStream, - eNPP_GetJavaClass, - eNPP_Initialize, - eNPP_New, - eNPP_NewStream, - eNPP_Print, - eNPP_SetWindow, - eNPP_Shutdown, - eNPP_StreamAsFile, - eNPP_URLNotify, - eNPP_Write, - eNPP_WriteReady, - eNPP_GetValue, - eNPP_SetValue, - eNP_Initialize - }; - - void* m_aArgs[ 8 ]; - CallType m_eCall; - - virtual long doIt(); -public: - struct CannotInitializeException {}; - - PluginComm_Impl( const OUString& rMIME, const OUString& rName, HWND hWnd ); - virtual ~PluginComm_Impl(); - -public: - using PluginComm::NPP_Destroy; - virtual NPError NPP_Destroy( NPP instance, NPSavedData** save ); - virtual NPError NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ); - virtual NPError NPP_Initialize(); - virtual NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, - char* argn[], char* argv[], NPSavedData *saved ); - virtual NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, - NPBool seekable, uint16_t* stype ); - virtual void NPP_Print( NPP instance, NPPrint* platformPrint ); - - using PluginComm::NPP_SetWindow; - virtual NPError NPP_SetWindow( NPP instance, NPWindow* window ); - virtual void NPP_Shutdown(); - virtual void NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ); - virtual void NPP_URLNotify( NPP instance, const char* url, - NPReason reason, void* notifyData ); - virtual int32_t NPP_Write( NPP instance, NPStream* stream, int32_t offset, - int32_t len, void* buffer ); - virtual int32_t NPP_WriteReady( NPP instance, NPStream* stream ); - virtual NPError NPP_GetValue( NPP instance, NPPVariable variable, void *ret_alue ); - -private: - void shutdown(); - BOOL retrieveFunction( TCHAR const * pName, void** ppFunc ) const; - -private: - HINSTANCE _plDLL; - - NPPluginFuncs _NPPfuncs; -}; - - -#endif - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/pl.component b/extensions/source/plugin/pl.component deleted file mode 100644 index 7f74fca066d5..000000000000 --- a/extensions/source/plugin/pl.component +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!--********************************************************************** -* -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* Copyright 2000, 2010 Oracle and/or its affiliates. -* -* OpenOffice.org - a multi-platform office productivity suite -* -* This file is part of OpenOffice.org. -* -* OpenOffice.org is free software: you can redistribute it and/or modify -* it under the terms of the GNU Lesser General Public License version 3 -* only, as published by the Free Software Foundation. -* -* OpenOffice.org is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Lesser General Public License version 3 for more details -* (a copy is included in the LICENSE file that accompanied this code). -* -* You should have received a copy of the GNU Lesser General Public License -* version 3 along with OpenOffice.org. If not, see -* <http://www.openoffice.org/license.html> -* for a copy of the LGPLv3 License. -* -**********************************************************************--> - -<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - prefix="pl" xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.extensions.PluginManager"> - <service name="com.sun.star.plugin.PluginManager"/> - </implementation> - <implementation name="com.sun.star.extensions.PluginModel"> - <service name="com.sun.star.plugin.PluginModel"/> - </implementation> -</component> diff --git a/extensions/source/plugin/unx/mediator.cxx b/extensions/source/plugin/unx/mediator.cxx deleted file mode 100644 index 390c960a1d03..000000000000 --- a/extensions/source/plugin/unx/mediator.cxx +++ /dev/null @@ -1,337 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <errno.h> -#include <unistd.h> - -#include <plugin/unx/mediator.hxx> -#include <sal/log.hxx> -#include <vcl/svapp.hxx> -#include <memory> - -#define MEDIATOR_MAGIC 0xf7a8d2f4 - -Mediator::Mediator( int nSocket ) : - m_nSocket( nSocket ), - m_pListener( nullptr ), - m_nCurrentID( 1 ), - m_bValid( true ) -{ - m_pListener = new MediatorListener( this ); - m_pListener->create(); -} - -Mediator::~Mediator() -{ - if( m_pListener ) - { - { - ::osl::MutexGuard aGuard( m_pListener->m_aMutex ); - m_pListener->m_pMediator = nullptr; - } - m_pListener = nullptr; - if( m_bValid ) - { - sal_uLong aHeader[3]; - aHeader[0] = 0; - aHeader[1] = 0; - aHeader[2] = MEDIATOR_MAGIC; - ssize_t nToWrite = sizeof(aHeader); - bool bSuccess = (nToWrite == write(m_nSocket, aHeader, nToWrite)); - SAL_WARN_IF(!bSuccess, "extensions.plugin", "short write"); - } - // kick the thread out of its run method; it deletes itself - close( m_nSocket ); - } - else - close( m_nSocket ); - for( std::vector< MediatorMessage* >::iterator it = m_aMessageQueue.begin(); - it != m_aMessageQueue.end(); ++it ) - { - delete *it; - } -} - - -sal_uLong Mediator::SendMessage( sal_uLong nBytes, const char* pBytes, sal_uLong nMessageID ) -{ - if( ! m_pListener ) - return 0; - - osl::MutexGuard aGuard( m_aSendMutex ); - if( ! nMessageID ) - nMessageID = m_nCurrentID; - - m_nCurrentID++; - if( m_nCurrentID >= 1 << 24 ) // protection against overflow - m_nCurrentID = 1; - - if( ! m_bValid ) - return nMessageID; - - std::unique_ptr<sal_uLong[]> pBuffer(new sal_uLong[ (nBytes/sizeof(sal_uLong)) + 4 ]); - pBuffer[ 0 ] = nMessageID; - pBuffer[ 1 ] = nBytes; - pBuffer[ 2 ] = MEDIATOR_MAGIC; - memcpy( &pBuffer[3], pBytes, (size_t)nBytes ); - ssize_t nToWrite = nBytes + 3*sizeof( sal_uLong ); - bool bSuccess = (nToWrite == write( m_nSocket, pBuffer.get(), nToWrite )); - SAL_WARN_IF(!bSuccess, "extensions.plugin", "short write"); - - return nMessageID; -} - -bool Mediator::WaitForMessage( sal_uLong nTimeOut ) -{ - if( ! m_pListener ) - return false; - - size_t nItems = m_aMessageQueue.size(); - - if( ! nTimeOut && nItems > 0 ) - return true; - - TimeValue aValue; - aValue.Seconds = nTimeOut/1000; - aValue.Nanosec = ( nTimeOut % 1000 ) * 1000; - - while( m_aMessageQueue.size() == nItems ) - { - m_aNewMessageCdtn.wait( & aValue ); - m_aNewMessageCdtn.reset(); - if( nTimeOut && m_aMessageQueue.size() == nItems ) - return false; - } - return true; -} - -MediatorMessage* Mediator::WaitForAnswer( sal_uLong nMessageID ) -{ - nMessageID &= 0x00ffffff; - while( m_pListener ) - { - { - osl::MutexGuard aGuard( m_aQueueMutex ); - for( size_t i = 0; i < m_aMessageQueue.size(); i++ ) - { - MediatorMessage* pMessage = m_aMessageQueue[ i ]; - sal_uLong nID = pMessage->m_nID; - if( ( nID & 0xff000000 ) && - ( ( nID & 0x00ffffff ) == nMessageID ) ) - { - m_aMessageQueue.erase( m_aMessageQueue.begin() + i ); - return pMessage; - } - } - } - WaitForMessage( 10 ); - } - return nullptr; -} - -MediatorMessage* Mediator::GetNextMessage( bool bWait ) -{ - while( m_pListener ) - { - { - // guard must be after WaitForMessage, else the listener - // cannot insert a new one -> deadlock - osl::MutexGuard aGuard( m_aQueueMutex ); - for( size_t i = 0; i < m_aMessageQueue.size(); i++ ) - { - MediatorMessage* pMessage = m_aMessageQueue[ i ]; - if( ! ( pMessage->m_nID & 0xff000000 ) ) - { - m_aMessageQueue.erase( m_aMessageQueue.begin() + i ); - return pMessage; - } - } - if( ! bWait ) - return nullptr; - } - WaitForMessage(); - } - return nullptr; -} - -MediatorMessage* Mediator::TransactMessage( sal_uLong nBytes, char* pBytes ) -{ - sal_uLong nID = SendMessage( nBytes, pBytes ); - return WaitForAnswer( nID ); -} - -MediatorListener::MediatorListener( Mediator* pMediator ) : - m_pMediator( pMediator ) -{ -} - -MediatorListener::~MediatorListener() -{ -} - -void MediatorListener::run() -{ - osl_setThreadName("MediatorListener"); - - bool bRun = true; - while( schedule() && m_pMediator && bRun ) - { - sal_uLong nHeader[ 3 ]; - int nBytes; - - if( ( nBytes = read( m_pMediator->m_nSocket, nHeader, sizeof( nHeader ) ) ) == sizeof( nHeader ) && nHeader[2] == MEDIATOR_MAGIC) - { - if( nHeader[ 0 ] == 0 && nHeader[ 1 ] == 0 ) - return; - std::unique_ptr<char[]> pBuffer(new char[ nHeader[ 1 ] ]); - if( m_pMediator && (sal_uLong)read( m_pMediator->m_nSocket, pBuffer.get(), nHeader[ 1 ] ) == nHeader[ 1 ] ) - { - ::osl::MutexGuard aMyGuard( m_aMutex ); - { - osl::MutexGuard - aGuard( m_pMediator->m_aQueueMutex ); - MediatorMessage* pMessage = - new MediatorMessage( nHeader[ 0 ], nHeader[ 1 ], pBuffer.get() ); - m_pMediator->m_aMessageQueue.push_back( pMessage ); - } - m_pMediator->m_aNewMessageCdtn.set(); - m_pMediator->m_aNewMessageHdl.Call( m_pMediator ); - } - else - { - SAL_WARN( - "extensions.plugin", - "got incomplete MediatorMessage: { " << nHeader[0] << ", " - << nHeader[1] << ", ... }"); - bRun = false; - } - } - else - { - SAL_WARN( - "extensions.plugin", - "got incomplete message header of " << nBytes - << " bytes (nHeader = [" << nHeader[0] << ", " << nHeader[1] - << "]), errno is " << errno); - bRun = false; - } - } -} - -void MediatorListener::onTerminated() -{ - if( m_pMediator ) - { - m_pMediator->m_aConnectionLostHdl.Call( m_pMediator ); - m_pMediator->m_pListener = nullptr; - } - delete this; -} - -sal_uLong MediatorMessage::ExtractULONG() -{ - if( ! m_pRun ) - m_pRun = m_pBytes; - - SAL_WARN_IF( - (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin", - "overflow in MediatorMessage::ExtractULONG"); - sal_uLong nCount; - memcpy( &nCount, m_pRun, sizeof( sal_uLong ) ); - m_pRun += sizeof( sal_uLong ); - return nCount; -} - -void* MediatorMessage::GetBytes( sal_uLong& rBytes ) -{ - if( ! m_pRun ) - m_pRun = m_pBytes; - - SAL_WARN_IF( - (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin", - "overflow in MediatorMessage::GetBytes"); - sal_uLong nBytes = ExtractULONG(); - - if( nBytes == 0 ) - return nullptr; - - SAL_WARN_IF( - (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin", - "overflow in MediatorMessage::GetBytes"); - char* pBuffer = new char[ nBytes ]; - memcpy( pBuffer, m_pRun, nBytes ); - m_pRun += nBytes; - rBytes = nBytes; - return pBuffer; -} - -char* MediatorMessage::GetString() -{ - if( ! m_pRun ) - m_pRun = m_pBytes; - - SAL_WARN_IF( - (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin", - "overflow in MediatorMessage::GetString"); - sal_uLong nBytes = ExtractULONG(); - - if( nBytes == 0 ) - return nullptr; - - SAL_WARN_IF( - (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin", - "overflow in MediatorMessage::GetString"); - char* pBuffer = new char[ nBytes+1 ]; - memcpy( pBuffer, m_pRun, nBytes ); - pBuffer[ nBytes ] = 0; - m_pRun += nBytes; - return pBuffer; -} - -sal_uInt32 MediatorMessage::GetUINT32() -{ - if( ! m_pRun ) - m_pRun = m_pBytes; - - SAL_WARN_IF( - (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin", - "overflow in MediatorMessage::GetUINT32"); - sal_uLong nBytes = ExtractULONG(); - SAL_WARN_IF( - nBytes != sizeof( sal_uInt32 ), "extensions.plugin", - "no sal_uInt32 in MediatorMessage::GetUINT32"); - SAL_WARN_IF( - (sal_uLong)(m_pRun - m_pBytes) >= m_nBytes, "extensions.plugin", - "overflow in MediatorMessage::GetUINT32"); - sal_uInt32 nRet; - memcpy( &nRet, m_pRun, sizeof( nRet ) ); - m_pRun += sizeof( sal_uInt32 ); - return nRet; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/unx/npnapi.cxx b/extensions/source/plugin/unx/npnapi.cxx deleted file mode 100644 index 80a201f27b7f..000000000000 --- a/extensions/source/plugin/unx/npnapi.cxx +++ /dev/null @@ -1,949 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#include <plugin/unx/plugcon.hxx> - -#include <unistd.h> -#include <dlfcn.h> - -#include <osl/module.h> -#include <sal/log.hxx> - -#include <config_vclplug.h> - -#include <npwrap.hxx> -#include <memory> - -extern PluginConnector* pConnector; -extern XtAppContext app_context; -extern int wakeup_fd[]; -extern Widget topLevel, topBox; -extern Display* pAppDisplay; -extern Display* pXtAppDisplay; -extern int nAppArguments; -extern char** pAppArguments; - -// begin Netscape plugin api calls -extern "C" { - -static void* l_NPN_MemAlloc( uint32_t nBytes ) -{ - void* pMem = new char[nBytes]; - return pMem; -} - -static void l_NPN_MemFree( void* pMem ) -{ - delete [] static_cast<char*>(pMem); -} - -static uint32_t l_NPN_MemFlush( uint32_t /*nSize*/ ) -{ - return 0; -} - -static NPError l_NPN_DestroyStream( NPP instance, NPStream* stream, NPError reason ) -{ - sal_uInt32 nInstance = pConnector->GetNPPID( instance ); - if( nInstance == PluginConnector::UnknownNPPID ) - return NPERR_GENERIC_ERROR; - - sal_uInt32 nFileID = pConnector->GetStreamID( stream ); - MediatorMessage* pMes= - pConnector-> - Transact( eNPN_DestroyStream, - &nInstance, sizeof( nInstance ), - &nFileID, sizeof( nFileID ), - POST_STRING( stream->url ), - &reason, sizeof( reason ), - nullptr ); - - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - for( std::vector< NPStream* >::iterator it = pConnector->getStreamList().begin(); - it != pConnector->getStreamList().end(); ++it ) - { - if( *it == stream ) - { - pConnector->getStreamList().erase( it ); - break; - } - } - delete [] stream->url; - delete stream; - // returns NPError - NPError aRet = PluginConnector::GetNPError( pMes ); - delete pMes; - return aRet; -} - -#ifdef OJI -static JRIEnv* l_NPN_GetJavaEnv() -{ - // no java in this program - SAL_INFO("extensions.plugin", "SNI: NPN_GetJavaEnv"); - return NULL; -} - -static jref l_NPN_GetJavaPeer( NPP /*instance*/ ) -{ - SAL_INFO("extensions.plugin", "SNI: NPN_GetJavaPeer"); - return NULL; -} -#endif - -static NPError l_NPN_GetURL( NPP instance, const char* url, const char* window ) -{ - sal_uInt32 nInstance = pConnector->GetNPPID( instance ); - if( nInstance == PluginConnector::UnknownNPPID ) - return NPERR_GENERIC_ERROR; - - MediatorMessage* pMes= - pConnector-> - Transact( eNPN_GetURL, - &nInstance, sizeof( nInstance ), - POST_STRING(url), - POST_STRING(window), - nullptr ); - SAL_WARN_IF(!pMes, "extensions.plugin", "geturl: message unanswered"); - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - // returns NPError - NPError aRet = PluginConnector::GetNPError( pMes ); - SAL_WARN_IF(aRet, "extensions.plugin", "geturl returns " << aRet); - delete pMes; - return aRet; -} - -static NPError l_NPN_GetURLNotify( NPP instance, const char* url, const char* target, - void* notifyData ) -{ - sal_uInt32 nInstance = pConnector->GetNPPID( instance ); - if( nInstance == PluginConnector::UnknownNPPID ) - return NPERR_GENERIC_ERROR; - - MediatorMessage* pMes= - pConnector-> - Transact( eNPN_GetURLNotify, - &nInstance, sizeof( nInstance ), - POST_STRING(url), - POST_STRING(target), - ¬ifyData, sizeof( void* ), // transmit the actual pointer - // since it is a pointer to private data fed back - // by NPP_URLNotify; this can be thought of as an ID - nullptr ); - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - // returns NPError - NPError aRet = PluginConnector::GetNPError( pMes ); - delete pMes; - return aRet; -} - -static NPError l_NPN_NewStream( NPP instance, NPMIMEType type, const char* target, - NPStream** stream ) - // stream is a return value -{ - sal_uInt32 nInstance = pConnector->GetNPPID( instance ); - if( nInstance == PluginConnector::UnknownNPPID ) - return NPERR_GENERIC_ERROR; - - MediatorMessage* pMes= - pConnector-> - Transact( eNPN_NewStream, - &nInstance, sizeof( nInstance ), - POST_STRING(type), - POST_STRING(target), - nullptr ); - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - // returns a new NPStream and an error - NPError aRet = PluginConnector::GetNPError( pMes ); - if( ! aRet ) - { - NPStream* pStream = new NPStream; - pStream->url = pMes->GetString(); - pStream->end = pMes->GetUINT32(); - pStream->lastmodified = pMes->GetUINT32(); - pStream->ndata = pStream->pdata = pStream->notifyData = nullptr; - - pConnector->getStreamList().push_back( pStream ); - *stream = pStream; - } - - delete pMes; - return aRet; -} - -static NPError l_NPN_PostURLNotify( NPP instance, const char* url, const char* target, uint32_t len, const char* buf, NPBool file, void* notifyData ) -{ - sal_uInt32 nInstance = pConnector->GetNPPID( instance ); - if( nInstance == PluginConnector::UnknownNPPID ) - return NPERR_GENERIC_ERROR; - - MediatorMessage* pMes = pConnector-> - Transact( eNPN_PostURLNotify, - &nInstance, sizeof( nInstance ), - POST_STRING( url ), - POST_STRING( target ), - &len, sizeof( len ), - buf, len, - &file, sizeof( NPBool ), - ¬ifyData, sizeof( void* ), // send the real pointer - nullptr ); - - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - NPError aRet = PluginConnector::GetNPError( pMes ); - delete pMes; - return aRet; -} - -static NPError l_NPN_PostURL( NPP instance, const char* url, const char* window, uint32_t len, const char* buf, NPBool file ) -{ - sal_uInt32 nInstance = pConnector->GetNPPID( instance ); - if( nInstance == PluginConnector::UnknownNPPID ) - return NPERR_GENERIC_ERROR; - - MediatorMessage* pMes = pConnector-> - Transact( eNPN_PostURL, - &nInstance, sizeof( nInstance ), - POST_STRING( url ), - POST_STRING( window ), - &len, sizeof( len ), - buf, len, - &file, sizeof( NPBool ), - nullptr ); - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - NPError aRet = PluginConnector::GetNPError( pMes ); - delete pMes; - return aRet; -} - -static NPError l_NPN_RequestRead( NPStream* stream, NPByteRange* rangeList ) -{ - SAL_INFO("extensions.plugin", "pluginapp: NPN_RequestRead"); - - NPByteRange* pRange = rangeList; - sal_uInt32 nRanges = 0; - while( pRange ) - { - nRanges++; - pRange = pRange->next; - } - - std::unique_ptr<sal_uInt32[]> pArray(new sal_uInt32[ 2 * nRanges ]); - pRange = rangeList; - sal_uInt32 n = 0; - while( pRange ) - { - pArray[ 2*n ] = (sal_uInt32)pRange->offset; - pArray[ 2*n + 1] = (sal_uInt32)pRange->length; - n++; - pRange = pRange->next; - } - sal_uInt32 nFileID = pConnector->GetStreamID( stream ); - MediatorMessage* pMes = pConnector-> - Transact( eNPN_RequestRead, - &nFileID, sizeof( nFileID ), - &nRanges, sizeof( nRanges ), - pArray.get(), sizeof( sal_uInt32 ) * 2 * nRanges, - nullptr ); - - if( ! pMes ) - { - return NPERR_GENERIC_ERROR; - } - - NPError aRet = PluginConnector::GetNPError( pMes ); - delete pMes; - return aRet; -} - -static void l_NPN_Status( NPP instance, const char* message ) -{ - sal_uInt32 nInstance = pConnector->GetNPPID( instance ); - if( nInstance == PluginConnector::UnknownNPPID ) - return; - - pConnector->Send( eNPN_Status, - &nInstance, sizeof( nInstance ), - POST_STRING( message ), - nullptr ); -} - -static const char* l_NPN_UserAgent( NPP instance ) -{ - static char* pAgent = nullptr; - - sal_uInt32 nInstance = pConnector->GetNPPID( instance ); - if( nInstance == PluginConnector::UnknownNPPID ) - { - if( instance ) - return "Mozilla 3.0"; - else // e.g. flashplayer calls NPN_UserAgent with NULL - nInstance = 0; - } - - MediatorMessage* pMes = pConnector-> - Transact( eNPN_UserAgent, - &nInstance, sizeof( nInstance ), - nullptr ); - - if( ! pMes ) - return pAgent; - - if( pAgent ) - delete [] pAgent; - pAgent = pMes->GetString(); - - delete pMes; - - SAL_INFO("extensions.plugin", "NPN_UserAgent returns " << pAgent); - - return pAgent; -} - -static int32_t l_NPN_Write( NPP instance, NPStream* stream, int32_t len, void* buffer ) -{ - sal_uInt32 nFileID = pConnector->GetStreamID( stream ); - if( nFileID == PluginConnector::UnknownStreamID ) - return NPERR_GENERIC_ERROR; - sal_uInt32 nInstance = pConnector->GetNPPID( instance ); - if( nInstance == PluginConnector::UnknownNPPID ) - return NPERR_GENERIC_ERROR; - - MediatorMessage* pMes = pConnector-> - Transact( eNPN_Write, - &nInstance, sizeof( nInstance ), - &nFileID, sizeof( nFileID ), - &len, sizeof( len ), - buffer, len, - nullptr ); - - if( ! pMes ) - return 0; - - sal_Int32 nRet = pMes->GetUINT32(); - return nRet; -} - -static void l_NPN_ReloadPlugins( NPBool /*reloadPages*/ ) -{ - SAL_INFO("extensions.plugin", "NPN_ReloadPlugins: SNI"); -} - -static NPError l_NPN_GetValue( NPP, NPNVariable variable, void* value ) -{ - /* - * We want to handle values injected into a NPNVariable which aren't in - * the old enum we build against, but that we know are in the new enum - * we want to support - */ - switch( (int)variable ) - { - case NPNVxDisplay: - *static_cast<Display**>(value) = pXtAppDisplay; - SAL_INFO("extensions.plugin", "Display requested"); - break; - case NPNVxtAppContext: - *static_cast<XtAppContext*>(value) = app_context; - SAL_INFO("extensions.plugin", "AppContext requested"); - break; - case NPNVjavascriptEnabledBool: - // no javascript - *static_cast<NPBool*>(value) = false; - SAL_INFO("extensions.plugin", "javascript enabled requested"); - break; - case NPNVasdEnabledBool: - // no SmartUpdate - *static_cast<NPBool*>(value) = false; - SAL_INFO("extensions.plugin", "smart update enabled requested"); - break; - case NPNVisOfflineBool: - // no offline browsing - *static_cast<NPBool*>(value) = false; - SAL_INFO("extensions.plugin", "offline browsing requested"); - break; - case NPNVSupportsXEmbedBool: - // asking xembed - *static_cast<int*>(value) = int(true); - SAL_INFO("extensions.plugin", "xembed requested"); - break; - case NPNVToolkit: -# if ENABLE_GTK - *static_cast<int*>(value) = NPNVGtk2; -# else - *(int*)value = 0; -# endif - SAL_INFO("extensions.plugin", "toolkit requested"); - break; - default: - SAL_WARN( - "extensions.plugin", - "unknown NPNVariable " << +variable << " requested"); - return NPERR_INVALID_PARAM; - } - return NPERR_NO_ERROR; -} - -static NPError l_NPN_SetValue(NPP /*instance*/, NPPVariable variable, void *value) -{ - SAL_INFO("extensions.plugin", "NPN_SetValue " << +variable << "=" << value); - return 0; -} - -static void l_NPN_InvalidateRect(NPP /*instance*/, NPRect* /*invalidRect*/) -{ - SAL_INFO("extensions.plugin", "NPN_InvalidateRect"); -} - -static void l_NPN_InvalidateRegion(NPP /*instance*/, NPRegion /*invalidRegion*/) -{ - SAL_INFO("extensions.plugin", "NPN_InvalidateRegion"); -} - -static void l_NPN_ForceRedraw(NPP /*instance*/) -{ - SAL_INFO("extensions.plugin", "NPN_ForceRedraw"); -} - -} - -static NPNetscapeFuncs aNetscapeFuncs = -{ - sizeof(aNetscapeFuncs), - (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR, - l_NPN_GetURL, - l_NPN_PostURL, - l_NPN_RequestRead, - l_NPN_NewStream, - l_NPN_Write, - l_NPN_DestroyStream, - l_NPN_Status, - l_NPN_UserAgent, - l_NPN_MemAlloc, - l_NPN_MemFree, - l_NPN_MemFlush, - l_NPN_ReloadPlugins, -# ifdef OJI - l_NPN_GetJavaEnv, - l_NPN_GetJavaPeer, -# else - nullptr, - nullptr, -# endif - l_NPN_GetURLNotify, - l_NPN_PostURLNotify, - l_NPN_GetValue, - l_NPN_SetValue, - l_NPN_InvalidateRect, - l_NPN_InvalidateRegion, - l_NPN_ForceRedraw -}; - -static NPPluginFuncs aPluginFuncs = -{ - sizeof(aPluginFuncs), - (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr -}; - - -oslModule pPluginLib = nullptr; -char*(*pNPP_GetMIMEDescription)() = nullptr; -NPError (*pNP_Initialize)(NPNetscapeFuncs*,NPPluginFuncs*) = nullptr; -NPError (*pNP_Shutdown)() = nullptr; - -std::vector< PluginConnector* > PluginConnector::allConnectors; - -PluginConnector::PluginConnector( int nSocket ) : - Mediator( nSocket ) -{ - SetNewMessageHdl( LINK( this, PluginConnector, NewMessageHdl ) ); -} - -PluginConnector::~PluginConnector() -{ -} - -IMPL_LINK_NOARG_TYPED( PluginConnector, WorkOnNewMessageHdl, void*, void ) -{ - MediatorMessage* pMessage; - CommandAtoms nCommand; - while( (pMessage = GetNextMessage()) ) - { - nCommand = (CommandAtoms)pMessage->GetUINT32(); - SAL_INFO( - "extensions.plugin", "pluginapp: " << GetCommandName(nCommand)); - switch( nCommand ) - { - case eNPP_DestroyStream: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - sal_uInt32 nFileID = pMessage->GetUINT32(); - NPStream* pStream = m_aNPWrapStreams[ nFileID ]; - NPError aReason = GetNPError( pMessage ); - m_aNPWrapStreams.erase( m_aNPWrapStreams.begin() + nFileID ); - - aReason = aPluginFuncs.destroystream( instance, pStream, aReason ); - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&aReason), sizeof( aReason ), - nullptr ); - - delete [] pStream->url; - delete pStream; - } - break; - case eNPP_Destroy: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - ConnectorInstance* pInst= m_aInstances[ nInstance ]; - - // some plugin rely on old netscapes behaviour - // to first destroy the widget and then destroy - // the instance, so mimic that behaviour here - if( pInst->pShell ) - XtDestroyWidget( static_cast<Widget>(pInst->pShell) ); - - pInst->pWidget = pInst->pShell = nullptr; - - // the other side will call eNPP_DestroyPhase2 after this - NPError aReason = NPERR_NO_ERROR; - Respond( pMessage->m_nID, reinterpret_cast<char*>(&aReason), sizeof( aReason ), nullptr ); - } - break; - case eNPP_DestroyPhase2: - { - // now really destroy the instance - sal_uInt32 nInstance = pMessage->GetUINT32(); - ConnectorInstance* pInst= m_aInstances[ nInstance ]; - NPP instance = pInst->instance; - NPSavedData* pSave = nullptr; - - NPError aRet = aPluginFuncs.destroy( instance, &pSave ); - if( pSave ) - { - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&aRet), sizeof( aRet ), - pSave->buf, pSave->len, - nullptr ); - delete [] static_cast<char*>(pSave->buf); - } - else - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&aRet), sizeof( aRet ), - "0000", 4, - nullptr ); - - #if ENABLE_GTK - if( pInst->pGtkWindow ) - g_object_unref( G_OBJECT(pInst->pGtkWindow) ); - if( pInst->pGtkWidget ) - g_object_unref( G_OBJECT(pInst->pGtkWidget) ); - #endif - - m_aInstances.erase( m_aInstances.begin() + nInstance ); - delete pInst; - delete instance; - SAL_INFO( - "extensions.plugin", - "destroyed instance (returning " << aRet << ")"); - } - break; - case eNPP_NewStream: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - char* pType = pMessage->GetString(); - NPStream* pStream = new NPStream; - pStream->url = pMessage->GetString(); - pStream->end = pMessage->GetUINT32(); - pStream->lastmodified = pMessage->GetUINT32(); - pStream->pdata = pStream->ndata = pStream->notifyData = nullptr; - NPBool* pSeekable = static_cast<NPBool*>(pMessage->GetBytes()); - m_aNPWrapStreams.push_back( pStream ); - uint16_t nStype = NP_ASFILE; - NPError aRet = aPluginFuncs.newstream( instance, pType, pStream, - *pSeekable, &nStype ); - SAL_INFO( - "extensions.plugin", - "pluginapp: NPP_NewStream(" << instance << ", " << pType - << ", " << pStream << ", " - << (*pSeekable ? "seekable" : "not seekable") << ", " - << &nStype << ") returns " << aRet - << "; stream = { pdata = " << pStream->pdata - << ", ndata = " << pStream->ndata << ", url = " - << pStream->url << ", end = " << pStream->end - << ", lastmodified = " << pStream->lastmodified - << ", notifyData = " << pStream->notifyData << " }"); - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&aRet), sizeof( aRet ), - &nStype, sizeof( nStype ), - nullptr ); - delete [] pType; - delete [] pSeekable; - } - break; - case eNPP_New: - { - char* pType = pMessage->GetString(); - uint16_t* pMode = static_cast<uint16_t*>(pMessage->GetBytes()); - int16_t* pArgc = static_cast<int16_t*>(pMessage->GetBytes()); - NPP instance = new NPP_t; - instance->pdata = instance->ndata = nullptr; - sal_uLong nArgnBytes, nArgvBytes; - char* pArgn = static_cast<char*>(pMessage->GetBytes( nArgnBytes )); - char* pArgv = static_cast<char*>(pMessage->GetBytes( nArgvBytes )); - sal_uLong nSaveBytes; - char* pSavedData = static_cast<char*>(pMessage->GetBytes( nSaveBytes )); - ConnectorInstance* pInst = - new ConnectorInstance( instance, pType, - *pArgc, - pArgn, nArgnBytes, - pArgv, nArgvBytes, - pSavedData, nSaveBytes ); - m_aInstances.push_back( pInst ); - NPError aRet; - aRet = aPluginFuncs.newp( pInst->pMimeType, instance, *pMode, *pArgc, - pInst->nArg ? pInst->argn : nullptr, - pInst->nArg ? pInst->argv : nullptr, - ( nSaveBytes == 4 && *reinterpret_cast<sal_uInt32*>(pSavedData) == 0 ) ? - &(pInst->aData) : nullptr ); - SAL_INFO( - "extensions.plugin", - "pluginapp: NPP_New( " << pInst->pMimeType << ", " - << instance << ", " << *pMode << ", " << pInst->nArg - << ", " << pInst->argn << ", " << pInst->argv << ", " - << &pInst->aData << ") returns" << aRet); - for( int i = 0; i < pInst->nArg; i++ ) - SAL_INFO( - "extensions.plugin", - " \"" << pInst->argn[i] << "\"=\"" << pInst->argv[i] - << "\""); - - #if ENABLE_GTK - // check if XEMBED is to be used - // ask for Bool. there seems to be no clear definition whether the - // return value should be an int or unsigned char - // int can hold both and will be nonzero in case of "true" - if( aPluginFuncs.getvalue ) - { - int bNeedsXEmbed = 0; - NPError error = aPluginFuncs.getvalue( instance, NPPVpluginNeedsXEmbed, static_cast<void *>(&bNeedsXEmbed) ); - if( error == NPERR_NO_ERROR ) - pInst->bShouldUseXEmbed = (bNeedsXEmbed != 0); - SAL_INFO( - "extensions.plugin", - "should use xembed = " - << (pInst->bShouldUseXEmbed ? "true" : "false")); - } - #endif - - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&aRet), sizeof( aRet ), - nullptr ); - delete [] pMode; - delete [] pArgc; - delete [] pType; - } - break; - case eNPP_SetWindow: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - ConnectorInstance* pInst= m_aInstances[ nInstance ]; - NPWindow* pWindow = static_cast<NPWindow*>(pMessage->GetBytes()); - - if( pWindow->width < 1 ) - pWindow->width = 1; - if( pWindow->height < 1 ) - pWindow->height = 1; - - #if ENABLE_GTK - if( pInst->bShouldUseXEmbed ) - { - if( ! pInst->pGtkWidget ) - { - SAL_INFO( - "extensions.plugin", - "creating gtk plug and socket"); - - pInst->pGtkWindow = gtk_plug_new((GdkNativeWindow)reinterpret_cast<sal_uIntPtr>(pWindow->window)); - gtk_widget_show( pInst->pGtkWindow ); - pInst->pGtkWidget = gtk_socket_new(); - gtk_widget_show( pInst->pGtkWidget ); - gtk_container_add( GTK_CONTAINER(pInst->pGtkWindow), pInst->pGtkWidget ); - gtk_widget_show_all( pInst->pGtkWindow ); - pInst->window.window = reinterpret_cast<void *>(gtk_socket_get_id( GTK_SOCKET(pInst->pGtkWidget ) )); - - XSync( pAppDisplay, False ); - - XMapWindow( pAppDisplay, GDK_WINDOW_XWINDOW(pInst->pGtkWindow->window) ); - - XSync( pAppDisplay, False ); - } - - // update widget size; alas out parent is not yet really XEMBED conformant - gtk_widget_set_size_request( pInst->pGtkWidget, pWindow->width, pWindow->height ); - gtk_window_resize( GTK_WINDOW(pInst->pGtkWindow), pWindow->width, pWindow->height ); - - GdkScreen* pGdkScreen = gtk_widget_get_screen( pInst->pGtkWidget ); - Screen* pScreen = ScreenOfDisplay( pAppDisplay, gdk_screen_get_number( pGdkScreen ) ); - - pInst->window.x = 0; - pInst->window.y = 0; - pInst->window.width = pWindow->width; - pInst->window.height = pWindow->height; - pInst->window.clipRect.left = 0; - pInst->window.clipRect.top = 0; - pInst->window.clipRect.right = pWindow->width; - pInst->window.clipRect.bottom = pWindow->height; - pInst->window.ws_info = &pInst->ws_info; - pInst->window.type = NPWindowTypeWindow; - pInst->ws_info.type = NP_SETWINDOW; - pInst->ws_info.display = pAppDisplay; - pInst->ws_info.visual = DefaultVisualOfScreen( pScreen ); - pInst->ws_info.colormap = DefaultColormapOfScreen( pScreen ); - pInst->ws_info.depth = DefaultDepthOfScreen( pScreen ); - } - else - #endif - { - if( ! pInst->pWidget ) - { - pInst->pWidget = CreateNewShell( &(pInst->pShell), reinterpret_cast<Window>(pWindow->window) ); - } - - // fill in NPWindow and NPCallbackStruct - pInst->window.window = reinterpret_cast<void*>(XtWindow( static_cast<Widget>(pInst->pWidget) )); - pInst->window.x = 0; - pInst->window.y = 0; - pInst->window.width = pWindow->width; - pInst->window.height = pWindow->height; - pInst->window.clipRect.left = 0; - pInst->window.clipRect.top = 0; - pInst->window.clipRect.right = pWindow->width; - pInst->window.clipRect.bottom = pWindow->height; - pInst->window.ws_info = &pInst->ws_info; - pInst->window.type = NPWindowTypeWindow; - pInst->ws_info.type = NP_SETWINDOW; - pInst->ws_info.display = XtDisplay( static_cast<Widget>(pInst->pWidget) ); - pInst->ws_info.visual = DefaultVisualOfScreen( XtScreen( static_cast<Widget>(pInst->pWidget) ) ); - pInst->ws_info.colormap = DefaultColormapOfScreen( XtScreen( static_cast<Widget>(pInst->pWidget) ) ); - pInst->ws_info.depth = DefaultDepthOfScreen( XtScreen( static_cast<Widget>(pInst->pWidget) ) ); - - XtResizeWidget( static_cast<Widget>(pInst->pShell), - pInst->window.width, - pInst->window.height, - 0 ); - XtResizeWidget( static_cast<Widget>(pInst->pWidget), - pInst->window.width, - pInst->window.height, - 0 ); - } - - NPError aRet = aPluginFuncs.setwindow( pInst->instance, &pInst->window ); - SAL_INFO( - "extensions.plugin", - "pluginapp: NPP_SetWindow returns " << aRet); - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&aRet), sizeof( aRet ), - nullptr ); - delete [] reinterpret_cast<char*>(pWindow); - } - break; - case eNPP_StreamAsFile: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - sal_uInt32 nFileID = pMessage->GetUINT32(); - NPStream* pStream = m_aNPWrapStreams[ nFileID ]; - char* fname = pMessage->GetString(); - SAL_INFO( - "extensions.plugin", - "pluginapp: NPP_StreamAsFile " << fname); - aPluginFuncs.asfile( instance, pStream, fname ); - delete [] fname; - } - break; - case eNPP_URLNotify: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - char* url = pMessage->GetString(); - NPReason* pReason = static_cast<NPReason*>(pMessage->GetBytes()); - void** notifyData = static_cast<void**>(pMessage->GetBytes()); - aPluginFuncs.urlnotify( instance, url, *pReason, *notifyData ); - delete [] url; - delete [] pReason; - delete [] notifyData; - } - break; - case eNPP_WriteReady: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - sal_uInt32 nFileID = pMessage->GetUINT32(); - NPStream* pStream = m_aNPWrapStreams[ nFileID ]; - int32_t nRet = aPluginFuncs.writeready( instance, pStream ); - - SAL_INFO( - "extensions.plugin", - "pluginapp: NPP_WriteReady(" << instance << ", " << pStream - << ") (stream id = " << nFileID << ") returns " - << nRet); - - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&nRet), sizeof( nRet ), - nullptr ); - } - break; - case eNPP_Write: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - sal_uInt32 nFileID = pMessage->GetUINT32(); - NPStream* pStream = m_aNPWrapStreams[ nFileID ]; - int32_t offset = pMessage->GetUINT32(); - sal_uLong len; - char* buffer = static_cast<char*>(pMessage->GetBytes( len )); - int32_t nRet = aPluginFuncs.write( instance, pStream, offset, len, buffer ); - - SAL_INFO( - "extensions.plugin", - "pluginapp: NPP_Write(" << instance << ", " << pStream - << ", " << offset << ", " << len << ", " << buffer - << ") returns " << nRet << "; stream = { pdata = " - << pStream->pdata << ", ndata = " << pStream->ndata - << ", url = " << pStream->url << ", end = " - << pStream->end << ", lastmodified = " - << pStream->lastmodified << ", notifyData = " - << pStream->notifyData << " }"); - - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&nRet), sizeof( nRet ), - nullptr ); - delete [] buffer; - } - break; - case eNPP_GetMIMEDescription: - { - if( ! pNPP_GetMIMEDescription ) - pNPP_GetMIMEDescription = reinterpret_cast<char*(*)()>( - osl_getAsciiFunctionSymbol( pPluginLib, "NPP_GetMIMEDescription" )); - char* pMIME = pNPP_GetMIMEDescription(); - Respond( pMessage->m_nID, - POST_NONCONST_STRING( pMIME ), - nullptr ); - } - break; - case eNPP_Initialize: - { - - pNP_Initialize = - reinterpret_cast<NPError(*)(NPNetscapeFuncs*, NPPluginFuncs*)>( - osl_getAsciiFunctionSymbol( pPluginLib, "NP_Initialize" )); - SAL_WARN_IF( - !pNP_Initialize, "extensions.plugin", - "no NP_Initialize, " << dlerror()); - pNP_Shutdown = reinterpret_cast<NPError(*)()>( - osl_getAsciiFunctionSymbol( pPluginLib, "NP_Shutdown" )); - SAL_WARN_IF( - !pNP_Initialize, "extensions.plugin", - "no NP_Shutdown, " << dlerror()); - - SAL_INFO("extensions.plugin", "entering NP_Initialize"); - NPError aRet = pNP_Initialize( &aNetscapeFuncs, &aPluginFuncs ); - SAL_INFO( - "extensions.plugin", - "pluginapp: NP_Initialize returns " << aRet); - Respond( pMessage->m_nID, reinterpret_cast<char*>(&aRet), sizeof( aRet ), nullptr ); - } - break; - case eNPP_Shutdown: - { - bool bSuccess = (4 == write(wakeup_fd[1], "xxxx", 4)); - SAL_WARN_IF(!bSuccess, "extensions.plugin", "short write"); - } - break; - default: - SAL_WARN( - "extensions.plugin", - "caught unknown NPP request " << +nCommand); - break; - } - delete pMessage; - } -} - -void LoadAdditionalLibs( const char* _pPluginLib ) -{ - SAL_INFO("extensions.plugin", "LoadAdditionalLibs " << _pPluginLib); - - if( ! strncmp( _pPluginLib, "libflashplayer.so", 17 ) ) - { - /* #b4951312# flash 7 implicitly assumes a gtk application - * if the API version is greater or equal to 12 (probably - * because they think they run in mozilla then). In that - * case they try to find gtk within the process and crash - * when they don't find it. - */ - aNetscapeFuncs.version = 11; - aPluginFuncs.version = 11; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/unx/nppapi.cxx b/extensions/source/plugin/unx/nppapi.cxx deleted file mode 100644 index ec842dc87eef..000000000000 --- a/extensions/source/plugin/unx/nppapi.cxx +++ /dev/null @@ -1,593 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#include <cstdarg> - -#include <sal/log.hxx> -#include <vcl/svapp.hxx> - -#include <plugin/unx/plugcon.hxx> -#include <plugin/impl.hxx> - -std::vector<PluginConnector*> PluginConnector::allConnectors; - -PluginConnector::PluginConnector( int nSocket ) : - Mediator( nSocket ) -{ - allConnectors.push_back( this ); - SetNewMessageHdl( LINK( this, PluginConnector, NewMessageHdl ) ); -} - -PluginConnector::~PluginConnector() -{ - osl::MutexGuard aGuard( m_aUserEventMutex ); - for( std::vector< PluginConnector* >::iterator it = allConnectors.begin(); - it != allConnectors.end(); ++it ) - { - if( *it == this ) - { - allConnectors.erase( it ); - break; - } - } -} - -IMPL_LINK_NOARG_TYPED( PluginConnector, NewMessageHdl, Mediator*, void ) -{ - osl::MutexGuard aGuard( m_aUserEventMutex ); - bool bFound = false; - for( std::vector< PluginConnector* >::iterator it = allConnectors.begin(); - it != allConnectors.end() && !bFound; ++it ) - { - if( *it == this ) - bFound = true; - } - if( ! bFound ) - return; - Application::PostUserEvent( LINK( this, PluginConnector, WorkOnNewMessageHdl ) ); -} - -IMPL_LINK_NOARG_TYPED( PluginConnector, WorkOnNewMessageHdl, void*, void ) -{ - bool bFound = false; - for( std::vector< PluginConnector* >::iterator it = allConnectors.begin(); - it != allConnectors.end() && !bFound; ++it ) - { - if( *it == this ) - bFound = true; - } - if( ! bFound ) - return; - - MediatorMessage* pMessage; - CommandAtoms nCommand; - while( (pMessage = GetNextMessage()) ) - { - nCommand = (CommandAtoms)pMessage->GetUINT32(); - SAL_INFO("extensions.plugin", GetCommandName(nCommand)); - switch( nCommand ) - { - case eNPN_GetURL: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - char* pUrl = pMessage->GetString(); - char* pWindow = pMessage->GetString(); - NPError aRet = NPN_GetURL( instance, pUrl, pWindow ); - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&aRet), sizeof( NPError ), nullptr ); - delete [] pUrl; - delete [] pWindow; - } - break; - case eNPN_GetURLNotify: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - char* pUrl = pMessage->GetString(); - char* pWindow = pMessage->GetString(); - void** pNotifyData = static_cast<void**>(pMessage->GetBytes()); - NPError aRet = NPN_GetURLNotify( instance, pUrl, pWindow, - *pNotifyData ); - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&aRet), sizeof( NPError ), nullptr ); - delete [] pUrl; - delete [] pWindow; - delete [] pNotifyData; - } - break; - case eNPN_DestroyStream: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - sal_uInt32 nFileID = pMessage->GetUINT32(); - char* pUrl = pMessage->GetString(); - NPError* pReason = static_cast<NPError*>(pMessage->GetBytes()); - NPError aRet = NPERR_FILE_NOT_FOUND; - if( nFileID < static_cast<sal_uInt32>(m_aNPWrapStreams.size()) ) - { - if( ! strcmp( m_aNPWrapStreams[ nFileID ]->url, pUrl ) ) - { - aRet = - NPN_DestroyStream( instance, m_aNPWrapStreams[ nFileID ], - *pReason ); - m_aNPWrapStreams.erase( m_aNPWrapStreams.begin() + nFileID ); - } - else - SAL_WARN( - "extensions.plugin", - "StreamID " << nFileID << " has incoherent urls " - << pUrl << " and " - << m_aNPWrapStreams[nFileID]->url); - } - else - SAL_WARN( - "extensions.plugin", - "nonexistent StreamID " << nFileID); - - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&aRet), sizeof( NPError ), nullptr ); - - delete [] pUrl; - delete [] pReason; - } - break; - case eNPN_NewStream: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - NPMIMEType pType = pMessage->GetString(); - char* pTarget = pMessage->GetString(); - - NPStream* pStream = nullptr; - - NPError aRet = NPN_NewStream( instance, pType, pTarget, &pStream ); - - if( aRet != NPERR_NO_ERROR ) - { - sal_uInt32 nDummy = 0; - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&aRet), sizeof( aRet ), - "", 0, - &nDummy, sizeof(sal_uInt32), - &nDummy, sizeof(sal_uInt32), - nullptr ); - } - else - { - m_aNPWrapStreams.push_back( pStream ); - - sal_uLong nLen = strlen( pStream->url ); - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&aRet), sizeof( aRet ), - pStream->url, nLen, - &pStream->end, sizeof(sal_uInt32), - &pStream->lastmodified, sizeof(sal_uInt32), - nullptr ); - } - - delete [] pTarget; - delete [] pType; - } - break; - case eNPN_PostURLNotify: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - char* pUrl = pMessage->GetString(); - char* pTarget = pMessage->GetString(); - sal_uInt32 nLen = pMessage->GetUINT32(); - char* pBuf = static_cast<char*>(pMessage->GetBytes()); - NPBool* pFile = static_cast<NPBool*>(pMessage->GetBytes()); - void** pNData = static_cast<void**>(pMessage->GetBytes()); - NPError aRet = - NPN_PostURLNotify( instance, pUrl, pTarget, nLen, pBuf, *pFile, *pNData ); - Respond( pMessage->m_nID, reinterpret_cast<char*>(&aRet), sizeof( aRet ), nullptr ); - delete [] pUrl; - delete [] pTarget; - delete [] pBuf; - delete [] pFile; - delete [] pNData; - } - break; - case eNPN_PostURL: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - char* pUrl = pMessage->GetString(); - char* pWindow = pMessage->GetString(); - sal_uInt32 nLen = pMessage->GetUINT32(); - char* pBuf = static_cast<char*>(pMessage->GetBytes()); - NPBool* pFile = static_cast<NPBool*>(pMessage->GetBytes()); - NPError aRet = - NPN_PostURL( instance, pUrl, pWindow, nLen, pBuf, *pFile ); - Respond( pMessage->m_nID, reinterpret_cast<char*>(&aRet), sizeof( aRet ), nullptr ); - delete [] pUrl; - delete [] pWindow; - delete [] pBuf; - delete [] pFile; - } - break; - case eNPN_RequestRead: - { - sal_uInt32 nFileID = pMessage->GetUINT32(); - NPStream* pStream = m_aNPWrapStreams[ nFileID ]; - sal_uInt32 nRanges = pMessage->GetUINT32(); - sal_uInt32* pArray = static_cast<sal_uInt32*>(pMessage->GetBytes()); - // build ranges table - NPByteRange* pFirst = new NPByteRange; - NPByteRange* pRun = pFirst; - for( sal_uInt32 n = 0; n < nRanges; n++ ) - { - pRun->offset = pArray[ 2*n ]; - pRun->length = pArray[ 2*n+1 ]; - pRun->next = n < nRanges-1 ? new NPByteRange : nullptr; - pRun = pRun->next; - } - NPError aRet = NPN_RequestRead( pStream, pFirst ); - Respond( pMessage->m_nID, reinterpret_cast<char*>(&aRet), sizeof( aRet ), nullptr ); - while( pFirst ) - { - pRun = pFirst->next; - delete pFirst; - pFirst = pRun; - } - delete [] pArray; - } - break; - case eNPN_Status: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - char* pString = pMessage->GetString(); - NPN_Status( instance, pString ); - delete [] pString; - } - break; - case eNPN_Version: - { - int major, minor, net_major, net_minor; - NPN_Version( &major, &minor, &net_major, &net_minor ); - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&major), sizeof( int ), - &minor, sizeof( int ), - &net_major, sizeof( int ), - &net_minor, sizeof( int ), - nullptr ); - } - break; - case eNPN_Write: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - sal_uInt32 nFileID = pMessage->GetUINT32(); - NPStream* pStream = m_aNPWrapStreams[ nFileID ]; - sal_Int32 nLen = pMessage->GetUINT32(); - void* pBuffer = pMessage->GetBytes(); - sal_Int32 nRet = NPN_Write( instance, pStream, nLen, pBuffer ); - Respond( pMessage->m_nID, - reinterpret_cast<char*>(&nRet), sizeof( nRet ), - nullptr ); - delete [] static_cast<char*>(pBuffer); - delete instance; - } - break; - case eNPN_UserAgent: - { - sal_uInt32 nInstance = pMessage->GetUINT32(); - NPP instance = m_aInstances[ nInstance ]->instance; - const char* pAnswer = NPN_UserAgent( instance ); - Respond( pMessage->m_nID, - const_cast<char*>(pAnswer), strlen( pAnswer ), - nullptr ); - } - break; - default: - SAL_WARN( - "extensions.plugin", - "caught unknown NPN request " << +nCommand); - } - - delete pMessage; - } -} - -#define GET_INSTANCE() \ - sal_uInt32 nInstance; \ - nInstance = GetNPPID( instance ); - -#define GET_INSTANCE_RET( err ) \ - GET_INSTANCE() \ - if( nInstance == PluginConnector::UnknownNPPID ) \ - return err - - -#define POST_INSTANCE() reinterpret_cast<char*>(&nInstance), sizeof( nInstance ) - -NPError UnxPluginComm::NPP_Destroy( NPP instance, NPSavedData** save ) -{ - NPError aRet = NPERR_GENERIC_ERROR; - GET_INSTANCE_RET( aRet ); - MediatorMessage* pMes = - Transact( eNPP_Destroy, - POST_INSTANCE(), - nullptr ); - if( ! pMes ) - return NPERR_GENERIC_ERROR; - delete pMes; - - pMes = Transact( eNPP_DestroyPhase2, - POST_INSTANCE(), - nullptr ); - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - aRet = GetNPError( pMes ); - sal_uLong nSaveBytes; - void* pSaveData = pMes->GetBytes( nSaveBytes ); - if( nSaveBytes == 4 && *static_cast<sal_uInt32*>(pSaveData) == 0 ) - *save = nullptr; - else - { - *save = new NPSavedData; - (*save)->len = nSaveBytes; - (*save)->buf = pSaveData; - } - delete pMes; - - return aRet; -} - -NPError UnxPluginComm::NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ) -{ - NPError aRet = NPERR_GENERIC_ERROR; - GET_INSTANCE_RET( aRet ); - sal_uInt32 nFileID = GetStreamID( stream ); - if( nFileID == PluginConnector::UnknownStreamID ) - return NPERR_GENERIC_ERROR; - - MediatorMessage* pMes = - Transact( eNPP_DestroyStream, - POST_INSTANCE(), - &nFileID, sizeof( nFileID ), - &reason, sizeof( reason ), - nullptr ); - m_aNPWrapStreams.erase( m_aNPWrapStreams.begin() + nFileID ); - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - aRet = GetNPError( pMes ); - delete pMes; - return aRet; -} - -NPError UnxPluginComm::NPP_Initialize() -{ - MediatorMessage* pMes = - Transact( eNPP_Initialize, - nullptr ); - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - NPError aRet = GetNPError( pMes ); - delete pMes; - return aRet; -} - -NPError UnxPluginComm::NPP_New( NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, - char* argn[], char* argv[], NPSavedData *saved ) -{ - m_aInstances.push_back( - new ConnectorInstance( instance, pluginType, 0, - nullptr, 0, nullptr, 0, - saved ? static_cast<char*>(saved->buf) : nullptr, - saved ? saved->len : 0 ) ); - - char *pArgnBuf, *pArgvBuf; - size_t nArgnLen = 0, nArgvLen = 0; - int i; - for( i = 0; i < argc; i++ ) - { - nArgnLen += strlen( argn[i] ) +1; - nArgvLen += strlen( argv[i] ) +1; - } - pArgnBuf = new char[ nArgnLen ]; - pArgvBuf = new char[ nArgvLen ]; - char* pRunArgn = pArgnBuf; - char* pRunArgv = pArgvBuf; - for( i = 0; i < argc; i++ ) - { - strcpy( pRunArgn, argn[i] ); - strcpy( pRunArgv, argv[i] ); - pRunArgn += strlen( argn[i] ) +1; - pRunArgv += strlen( argv[i] ) +1; - } - - MediatorMessage* pMes; - if( saved ) - pMes = - Transact( eNPP_New, - pluginType, strlen( pluginType ), - &mode, sizeof( mode ), - &argc, sizeof( argc ), - pArgnBuf, nArgnLen, - pArgvBuf, nArgvLen, - saved->buf, static_cast<size_t>(saved->len), - nullptr ); - else - pMes = - Transact( eNPP_New, - pluginType, strlen( pluginType ), - &mode, sizeof( mode ), - &argc, sizeof( argc ), - pArgnBuf, nArgnLen, - pArgvBuf, nArgvLen, - "0000", size_t(4), - nullptr ); - delete [] pArgnBuf; - delete [] pArgvBuf; - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - NPError aRet = GetNPError( pMes ); - delete pMes; - - return aRet; -} - -NPError UnxPluginComm::NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, - NPBool seekable, uint16_t* stype ) -{ - NPError aRet = NPERR_GENERIC_ERROR; - GET_INSTANCE_RET( aRet ); - - m_aNPWrapStreams.push_back( stream ); - MediatorMessage* pMes = - Transact( eNPP_NewStream, - POST_INSTANCE(), - type, strlen( type ), - stream->url, strlen( stream->url ), - &stream->end, sizeof( stream->end ), - &stream->lastmodified, sizeof( stream->lastmodified ), - &seekable, sizeof( seekable ), - nullptr ); - - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - aRet = GetNPError( pMes ); - uint16_t* pSType = static_cast<uint16_t*>(pMes->GetBytes()); - *stype = *pSType; - - delete [] pSType; - delete pMes; - return aRet; -} - -NPError UnxPluginComm::NPP_SetWindow( NPP instance, NPWindow* window ) -{ - NPError aRet = NPERR_GENERIC_ERROR; - GET_INSTANCE_RET( aRet ); - - MediatorMessage* pMes = - Transact( eNPP_SetWindow, - POST_INSTANCE(), - window, sizeof( NPWindow ), - nullptr ); - if( ! pMes ) - return NPERR_GENERIC_ERROR; - - aRet = GetNPError( pMes ); - delete pMes; - return aRet; -} - -void UnxPluginComm::NPP_Shutdown() -{ - Send( eNPP_Shutdown, nullptr ); -} - -void UnxPluginComm::NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ) -{ - GET_INSTANCE(); - sal_uInt32 nFileID = GetStreamID( stream ); - if( nFileID == PluginConnector::UnknownStreamID ) - return; - - Send( eNPP_StreamAsFile, - POST_INSTANCE(), - &nFileID, sizeof( nFileID ), - fname, strlen( fname ), - nullptr ); -} - -void UnxPluginComm::NPP_URLNotify( NPP instance, const char* url, NPReason reason, void* notifyData ) -{ - GET_INSTANCE(); - - Send( eNPP_URLNotify, - POST_INSTANCE(), - url, strlen( url ), - &reason, sizeof( reason ), - ¬ifyData, sizeof( void* ), - nullptr ); -} - -int32_t UnxPluginComm::NPP_Write( NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer ) -{ - GET_INSTANCE_RET( -1 ); - sal_uInt32 nFileID = GetStreamID( stream ); - if( nFileID == PluginConnector::UnknownStreamID ) - return -1; - - MediatorMessage* pMes = - Transact( eNPP_Write, - POST_INSTANCE(), - &nFileID, sizeof( nFileID ), - &offset, sizeof( offset ), - buffer, static_cast<size_t>(len), - nullptr ); - if( ! pMes ) - return 0; - - int32_t aRet = pMes->GetUINT32(); - delete pMes; - - return aRet; -} - -int32_t UnxPluginComm::NPP_WriteReady( NPP instance, NPStream* stream ) -{ - GET_INSTANCE_RET( -1 ); - sal_uInt32 nFileID = GetStreamID( stream ); - if( nFileID == PluginConnector::UnknownStreamID ) - return -1; - - MediatorMessage* pMes = - Transact( eNPP_WriteReady, - POST_INSTANCE(), - &nFileID, sizeof( nFileID ), - nullptr ); - - if( ! pMes ) - return 0; - - int32_t aRet = pMes->GetUINT32(); - delete pMes; - - return aRet; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/unx/npwrap.cxx b/extensions/source/plugin/unx/npwrap.cxx deleted file mode 100644 index e58c0f28de5e..000000000000 --- a/extensions/source/plugin/unx/npwrap.cxx +++ /dev/null @@ -1,495 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif -#include <errno.h> -#include <dlfcn.h> -#include <unistd.h> -#include <sys/poll.h> -#include <fcntl.h> -#include <signal.h> - -#include <plugin/unx/plugcon.hxx> - -#include <osl/file.h> -#include <osl/module.h> -#include <sal/log.hxx> - -#include <config_vclplug.h> - -#include <npwrap.hxx> - -PluginConnector* pConnector = nullptr; - -int nAppArguments = 0; -char** pAppArguments = nullptr; -Display* pAppDisplay = nullptr; -Display* pXtAppDisplay = nullptr; - -extern oslModule pPluginLib; -extern NPError (*pNP_Shutdown)(); - -XtAppContext app_context; -Widget topLevel = nullptr, topBox = nullptr; -int wakeup_fd[2] = { 0, 0 }; -static bool bPluginAppQuit = false; - -static void GlobalConnectionLostHdl( void* /*pInst*/, Mediator* /*pArg*/ ) -{ - SAL_WARN("extensions.plugin", "pluginapp exiting due to connection lost"); - - bool bSuccess = (4 == write(wakeup_fd[1], "xxxx", 4 )); - SAL_WARN_IF(!bSuccess, "extensions.plugin", "short write"); -} - -extern "C" -{ - static int plugin_x_error_handler( Display*, XErrorEvent* ) - { - return 0; - } - -#if ! ENABLE_GTK - static void ThreadEventHandler( XtPointer /*client_data*/, int* /*source*/, XtInputId* id ) - { - char buf[256]; - // clear pipe - int len, nLast = -1; - - while( (len = read( wakeup_fd[0], buf, sizeof( buf ) ) ) > 0 ) - nLast = len-1; - if( ! bPluginAppQuit ) { - if( ( nLast == -1 || buf[nLast] != 'x' ) && pConnector ) - pConnector->CallWorkHandler(); - else { - // it seems you can use XtRemoveInput only - // safely from within the callback - // why is that ? - SAL_INFO("extensions.plugin", "removing wakeup pipe"); - XtRemoveInput( *id ); - XtAppSetExitFlag( app_context ); - bPluginAppQuit = true; - - delete pConnector; - pConnector = NULL; - } - } - } -#endif -} - - -IMPL_LINK_NOARG_TYPED( PluginConnector, NewMessageHdl, Mediator*, void ) -{ - (void) this; // loplugin:staticmethods - SAL_INFO("extensions.plugin", "new message handler"); - bool bSuccess = (4 == write(wakeup_fd[1], "cccc", 4)); - SAL_WARN_IF(!bSuccess, "extensions.plugin", "short write"); -} - -Widget createSubWidget( char* /*pPluginText*/, Widget shell, Window aParentWindow ) -{ - Widget newWidget = XtVaCreateManagedWidget( -#if defined USE_MOTIF - "drawingArea", - xmDrawingAreaWidgetClass, -#else - "", - compositeWidgetClass, -#endif - shell, - XtNwidth, 200, - XtNheight, 200, - nullptr ); - XtRealizeWidget( shell ); - XtRealizeWidget( newWidget ); - - SAL_INFO( - "extensions.plugin", - "reparenting new widget " << XtWindow( newWidget ) << " to " - << aParentWindow); - XReparentWindow( pXtAppDisplay, - XtWindow( shell ), - aParentWindow, - 0, 0 ); - XtMapWidget( shell ); - XtMapWidget( newWidget ); - XRaiseWindow( pXtAppDisplay, XtWindow( shell ) ); - XSync( pXtAppDisplay, False ); - - return newWidget; -} - -void* CreateNewShell( void** pShellReturn, Window aParentWindow ) -{ - String n, c; - XtGetApplicationNameAndClass(pXtAppDisplay, &n, &c); - - Widget newShell = - XtVaAppCreateShell( "pane", c, - topLevelShellWidgetClass, - pXtAppDisplay, - XtNwidth, 200, - XtNheight, 200, - XtNoverrideRedirect, True, - nullptr ); - *pShellReturn = newShell; - - char pText[1024]; - sprintf( pText, "starting plugin %s ...", pAppArguments[2] ); - - Widget newWidget = createSubWidget( pText, newShell, aParentWindow ); - - return newWidget; -} - -static oslModule LoadModule( const char* pPath ) -{ - OUString sSystemPath( OUString::createFromAscii( pPath ) ); - OUString sFileURL; - osl_getFileURLFromSystemPath( sSystemPath.pData, &sFileURL.pData ); - - oslModule pLib = osl_loadModule( sFileURL.pData, SAL_LOADMODULE_LAZY ); - SAL_INFO_IF(!pLib, "extensions.plugin", "could not open " << pPath); - return pLib; -} - -// Unix specific implementation -static void CheckPlugin( const char* pPath ) -{ - oslModule pLib = LoadModule( pPath ); - if (pLib != nullptr) { - char*(*pNP_GetMIMEDescription)() = reinterpret_cast<char*(*)()>( - osl_getAsciiFunctionSymbol( pLib, "NP_GetMIMEDescription" )); - if( pNP_GetMIMEDescription ) - printf( "%s\n", pNP_GetMIMEDescription() ); - else - SAL_WARN( - "extensions.plugin", - "could not get symbol NP_GetMIMEDescription " << dlerror()); - osl_unloadModule( pLib ); - } -} - -#if OSL_DEBUG_LEVEL > 1 && defined LINUX -#include <execinfo.h> -#endif - -extern "C" { - - static void signal_handler( int nSig ) - { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "caught signal %d, exiting\n", nSig ); -#ifdef LINUX - void* pStack[64]; - int nStackLevels = backtrace( pStack, SAL_N_ELEMENTS(pStack) ); - backtrace_symbols_fd( pStack, nStackLevels, STDERR_FILENO ); -#endif -#endif - if( pConnector ) { - // ensure that a read on the other side will wakeup - delete pConnector; - pConnector = nullptr; - } - - _exit(nSig); - } - -#if ENABLE_GTK - - static gboolean noClosure( gpointer ) - { - return sal_True; - } - -// Xt events - static gboolean prepareXtEvent( GSource*, gint* ) - { - int nMask = XtAppPending( app_context ); - return (nMask & XtIMAll) != 0; - } - - static gboolean checkXtEvent( GSource* ) - { - int nMask = XtAppPending( app_context ); - return (nMask & XtIMAll) != 0; - } - - static gboolean dispatchXtEvent( GSource*, GSourceFunc, gpointer ) - { - XtAppProcessEvent( app_context, XtIMAll ); - return sal_True; - } - - static GSourceFuncs aXtEventFuncs = { - prepareXtEvent, - checkXtEvent, - dispatchXtEvent, - nullptr, - noClosure, - nullptr - }; - - static gboolean pollXtTimerCallback(gpointer) - { - for(int i = 0; i < 5; i++) { - if( (XtAppPending(app_context) & (XtIMAll & ~XtIMXEvent)) == 0 ) - break; - XtAppProcessEvent(app_context, XtIMAll & ~XtIMXEvent); - } - return sal_True; - } - - static gboolean prepareWakeupEvent( GSource*, gint* ) - { - struct pollfd aPoll = { wakeup_fd[0], POLLIN, 0 }; - (void)poll(&aPoll, 1, 0); - return (aPoll.revents & POLLIN ) != 0; - } - - static gboolean checkWakeupEvent( GSource* pSource ) - { - gint nDum = 0; - return prepareWakeupEvent( pSource, &nDum ); - } - - static gboolean dispatchWakeupEvent( GSource*, GSourceFunc, gpointer ) - { - char buf[256]; - // clear pipe - int len, nLast = -1; - - while( (len = read( wakeup_fd[0], buf, sizeof( buf ) ) ) > 0 ) - nLast = len-1; - if( ( nLast == -1 || buf[nLast] != 'x' ) && pConnector ) - pConnector->CallWorkHandler(); - else { - XtAppSetExitFlag( app_context ); - bPluginAppQuit = true; - - delete pConnector; - pConnector = nullptr; - } - - return sal_True; - } - - static GSourceFuncs aWakeupEventFuncs = { - prepareWakeupEvent, - checkWakeupEvent, - dispatchWakeupEvent, - nullptr, - noClosure, - nullptr - }; - -#endif // GTK - -} - -int main( int argc, char **argv) -{ - try - { - struct sigaction aSigAction; - aSigAction.sa_handler = signal_handler; - sigemptyset( &aSigAction.sa_mask ); - aSigAction.sa_flags = SA_NOCLDSTOP; - sigaction( SIGSEGV, &aSigAction, nullptr ); - sigaction( SIGBUS, &aSigAction, nullptr ); - sigaction( SIGABRT, &aSigAction, nullptr ); - sigaction( SIGTERM, &aSigAction, nullptr ); - sigaction( SIGILL, &aSigAction, nullptr ); - - int nArg = (argc < 3) ? 1 : 2; - char* pBaseName = argv[nArg] + strlen(argv[nArg]); - while( pBaseName > argv[nArg] && pBaseName[-1] != '/' ) - pBaseName--; - LoadAdditionalLibs( pBaseName ); - - if( argc == 2 ) { - CheckPlugin(argv[1]); - exit(0); - } - nAppArguments = argc; - pAppArguments = argv; - - XSetErrorHandler( plugin_x_error_handler ); - - if( pipe( wakeup_fd ) ) { - SAL_WARN("extensions.plugin", "could not pipe()"); - return 1; - } - // initialize 'wakeup' pipe. - int flags; - - // set close-on-exec descriptor flag. - if ((flags = fcntl (wakeup_fd[0], F_GETFD)) != -1) { - flags |= FD_CLOEXEC; - (void)fcntl(wakeup_fd[0], F_SETFD, flags); - } - if ((flags = fcntl (wakeup_fd[1], F_GETFD)) != -1) { - flags |= FD_CLOEXEC; - (void)fcntl(wakeup_fd[1], F_SETFD, flags); - } - - // set non-blocking I/O flag. - if ((flags = fcntl (wakeup_fd[0], F_GETFL)) != -1) { - flags |= O_NONBLOCK; - (void)fcntl(wakeup_fd[0], F_SETFL, flags); - } - if ((flags = fcntl (wakeup_fd[1], F_GETFL)) != -1) { - flags |= O_NONBLOCK; - (void)fcntl(wakeup_fd[1], F_SETFL, flags); - } - - pPluginLib = LoadModule( argv[2] ); - if( ! pPluginLib ) { - exit(255); - } - int nSocket = atol( argv[1] ); - - #if ENABLE_GTK - g_thread_init(nullptr); - gtk_init(&argc, &argv); - #endif - - pConnector = new PluginConnector( nSocket ); - pConnector->SetConnectionLostHdl( Link<Mediator*,void>( nullptr, GlobalConnectionLostHdl ) ); - - XtSetLanguageProc( nullptr, nullptr, nullptr ); - - XtToolkitInitialize(); - app_context = XtCreateApplicationContext(); - pXtAppDisplay = XtOpenDisplay( app_context, nullptr, "SOPlugin", "SOPlugin", nullptr, 0, &argc, argv ); - - - #if ENABLE_GTK - // integrate Xt events into GTK event loop - GPollFD aXtPollDesc, aWakeupPollDesc; - - GSource* pXTSource = g_source_new( &aXtEventFuncs, sizeof(GSource) ); - if( !pXTSource ) { - SAL_WARN("extensions.plugin", "could not get Xt GSource"); - return 1; - } - - g_source_set_priority( pXTSource, GDK_PRIORITY_EVENTS ); - g_source_set_can_recurse( pXTSource, sal_True ); - g_source_attach( pXTSource, nullptr ); - aXtPollDesc.fd = ConnectionNumber( pXtAppDisplay ); - aXtPollDesc.events = G_IO_IN; - aXtPollDesc.revents = 0; - g_source_add_poll( pXTSource, &aXtPollDesc ); - - gint xt_polling_timer_id = g_timeout_add( 25, pollXtTimerCallback, nullptr); - // Initialize wakeup events listener - GSource *pWakeupSource = g_source_new( &aWakeupEventFuncs, sizeof(GSource) ); - if ( pWakeupSource == nullptr ) { - SAL_WARN("extensions.plugin", "could not get wakeup source"); - return 1; - } - g_source_set_priority( pWakeupSource, GDK_PRIORITY_EVENTS); - g_source_attach( pWakeupSource, nullptr ); - aWakeupPollDesc.fd = wakeup_fd[0]; - aWakeupPollDesc.events = G_IO_IN; - aWakeupPollDesc.revents = 0; - g_source_add_poll( pWakeupSource, &aWakeupPollDesc ); - - pAppDisplay = gdk_x11_display_get_xdisplay( gdk_display_get_default() ); - #else - pAppDisplay = pXtAppDisplay; - XtAppAddInput( app_context, - wakeup_fd[0], - (XtPointer)XtInputReadMask, - ThreadEventHandler, NULL ); - #endif - - // send that we are ready to go - MediatorMessage* pMessage = - pConnector->Transact( "init req", 8, - nullptr ); - delete pMessage; - - #if OSL_DEBUG_LEVEL > 3 - int nPID = getpid(); - int nChild = fork(); - if( nChild == 0 ) { - char pidbuf[16]; - char* pArgs[] = { "xterm", "-sl", "2000", "-sb", "-e", "gdb", "pluginapp.bin", pidbuf, NULL }; - sprintf( pidbuf, "%d", nPID ); - execvp( pArgs[0], pArgs ); - _exit(255); - } else - sleep( 10 ); - #endif - - /* - * Loop for events. - */ - // for some reason XtAppSetExitFlag won't quit the application - // in ThreadEventHandler most of times; Xt will hang in select - // (hat is in XtAppNextEvent). Have our own mainloop instead - // of XtAppMainLoop - do { - #if ENABLE_GTK - g_main_context_iteration( nullptr, sal_True ); - #else - XtAppProcessEvent( app_context, XtIMAll ); - #endif - } while( ! XtAppGetExitFlag( app_context ) && ! bPluginAppQuit ); - - SAL_INFO("extensions.plugin", "left plugin app main loop"); - - #if ENABLE_GTK - g_source_remove(xt_polling_timer_id); - #endif - - pNP_Shutdown(); - SAL_INFO("extensions.plugin", "NP_Shutdown done"); - osl_unloadModule( pPluginLib ); - SAL_INFO("extensions.plugin", "plugin close"); - - close( wakeup_fd[0] ); - close( wakeup_fd[1] ); - - return 0; - } - catch (std::exception& e) - { - SAL_WARN("extensions.plugin", "exception: " << e.what()); - return 255; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/unx/npwrap.hxx b/extensions/source/plugin/unx/npwrap.hxx deleted file mode 100644 index ffadf00e0e78..000000000000 --- a/extensions/source/plugin/unx/npwrap.hxx +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#ifndef INCLUDED_EXTENSIONS_SOURCE_PLUGIN_UNX_NPWRAP_HXX -#define INCLUDED_EXTENSIONS_SOURCE_PLUGIN_UNX_NPWRAP_HXX - -#include <sal/config.h> - -void* CreateNewShell( void** pShellReturn, Window aParentWindow ); - -void LoadAdditionalLibs(const char*); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/unx/plugcon.cxx b/extensions/source/plugin/unx/plugcon.cxx deleted file mode 100644 index d50d72a0a64b..000000000000 --- a/extensions/source/plugin/unx/plugcon.cxx +++ /dev/null @@ -1,281 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#include <sal/log.hxx> - -#include <plugin/unx/plugcon.hxx> - -#include <cstdarg> -#include <vector> - -sal_uInt32 PluginConnector::GetStreamID( NPStream* pStream ) -{ - size_t nLen = m_aNPWrapStreams.size(); - for( size_t i = 0; i < nLen; i++ ) - if( m_aNPWrapStreams[ i ] == pStream ) - return static_cast<sal_uInt32>(i); - SAL_WARN("extensions.plugin", "NPStream has no ID"); - return UnknownStreamID; -} - -sal_uInt32 PluginConnector::GetNPPID( NPP instance ) -{ - size_t nLen = m_aInstances.size(); - for( size_t i=0; i <nLen; i++ ) - if( m_aInstances[ i ]->instance == instance ) - return static_cast<sal_uInt32>(i); - SAL_WARN("extensions.plugin", "NPP has no ID"); - - return UnknownNPPID; -} - -struct PtrStruct -{ - char* pData; - sal_uLong nBytes; - - PtrStruct( char* i_pData, sal_uLong i_nBytes ) - : pData( i_pData ), nBytes( i_nBytes ) {} -}; - -sal_uLong PluginConnector::FillBuffer( char*& rpBuffer, - const char* pFunction, - sal_uLong nFunctionLen, - va_list ap ) -{ - std::vector< PtrStruct > aList; - aList.reserve( 5 ); - - sal_uLong nDataSize = nFunctionLen + sizeof( sal_uLong ); - char* pNext; - - do { - pNext = va_arg( ap, char* ); - if( pNext ) - { - aList.push_back( PtrStruct( pNext, va_arg( ap, sal_uLong ) ) ); - nDataSize += aList.back().nBytes + sizeof(sal_uLong); - } - } while( pNext ); - - rpBuffer = new char[ nDataSize ]; - char* pRun = rpBuffer; - memcpy( pRun, &nFunctionLen, sizeof( nFunctionLen ) ); - pRun += sizeof( nFunctionLen ); - memcpy( pRun, pFunction, nFunctionLen ); - pRun += nFunctionLen; - - for( std::vector<PtrStruct>::const_iterator it = aList.begin(); it != aList.end(); ++it ) - { - memcpy( pRun, &it->nBytes, sizeof( sal_uLong ) ); - pRun += sizeof( sal_uLong ); - memcpy( pRun, it->pData, it->nBytes ); - pRun += it->nBytes; - } - return nDataSize; -} - -MediatorMessage* PluginConnector::Transact( const char* pFunction, - sal_uLong nFunctionLen, ... ) -{ - va_list ap; - char* pBuffer; - - va_start( ap, nFunctionLen ); - sal_uLong nSize = FillBuffer( pBuffer, pFunction, nFunctionLen, ap ); - va_end( ap ); - MediatorMessage* pRet = TransactMessage( nSize, pBuffer ); - delete[] pBuffer; - return pRet; -} - -MediatorMessage* PluginConnector::Transact( sal_uInt32 nFunction, ... ) -{ - va_list ap; - char* pBuffer; - - va_start( ap, nFunction ); - sal_uLong nSize = FillBuffer( pBuffer, reinterpret_cast<char*>(&nFunction), sizeof( nFunction ), ap ); - va_end( ap ); - MediatorMessage* pRet = TransactMessage( nSize, pBuffer ); - delete[] pBuffer; - return pRet; -} - -sal_uLong PluginConnector::Send( sal_uInt32 nFunction, ... ) -{ - va_list ap; - char* pBuffer; - - va_start( ap, nFunction ); - sal_uLong nSize = FillBuffer( pBuffer, reinterpret_cast<char*>(&nFunction), sizeof( nFunction ), ap ); - va_end( ap ); - sal_uLong nRet = SendMessage( nSize, pBuffer ); - delete[] pBuffer; - return nRet; -} - -void PluginConnector::Respond( sal_uLong nID, - char* pFunction, - sal_uLong nFunctionLen, ... ) -{ - va_list ap; - char* pBuffer; - - va_start( ap, nFunctionLen ); - sal_uLong nSize = FillBuffer( pBuffer, pFunction, nFunctionLen, ap ); - va_end( ap ); - SendMessage( nSize, pBuffer, nID | ( 1 << 24 ) ); - delete[] pBuffer; -} - -MediatorMessage* PluginConnector::WaitForAnswer( sal_uLong nMessageID ) -{ - if( ! m_bValid ) - return nullptr; - - nMessageID &= 0x00ffffff; - while( m_pListener ) - { - { - osl::MutexGuard aGuard( m_aQueueMutex ); - for( size_t i = 0; i < m_aMessageQueue.size(); i++ ) - { - MediatorMessage* pMessage = m_aMessageQueue[ i ]; - sal_uLong nID = pMessage->m_nID; - if( ( nID & 0xff000000 ) && - ( ( nID & 0x00ffffff ) == nMessageID ) ) - { - m_aMessageQueue.erase( m_aMessageQueue.begin() + i ); - return pMessage; - } - } - } - if( ! m_aMessageQueue.empty() ) - CallWorkHandler(); - WaitForMessage( 2000 ); - } - return nullptr; -} - -ConnectorInstance::ConnectorInstance( NPP inst, char* type, - int args, char* pargnbuf, sal_uLong nargnbytes, - char* pargvbuf, sal_uLong nargvbytes, - char* savedata, sal_uLong savebytes ) : - instance( inst ), - pShell( nullptr ), - pWidget( nullptr ), - pGtkWindow( nullptr ), - pGtkWidget( nullptr ), - bShouldUseXEmbed( false ), - nArg( args ), - pArgnBuf( pargnbuf ), - pArgvBuf( pargvbuf ) -{ - memset( &window, 0, sizeof(window) ); - pMimeType = new char[ strlen( type ) + 1 ]; - strcpy( pMimeType, type ); - aData.len = savebytes; - aData.buf = savedata; - argn = new char*[ nArg ]; - argv = new char*[ nArg ]; - int i; - char* pRun = pArgnBuf; - for( i = 0; i < nArg; i++ ) - { - argn[i] = pRun; - while( *pRun != 0 && (sal_uLong)(pRun - pArgnBuf) < nargnbytes ) - pRun++; - if( (sal_uLong)(pRun - pArgnBuf) < nargnbytes ) - pRun++; - } - pRun = pArgvBuf; - for( i = 0; i < nArg; i++ ) - { - argv[i] = pRun; - while( *pRun != 0 && (sal_uLong)(pRun - pArgvBuf) < nargvbytes ) - pRun++; - if( (sal_uLong)(pRun - pArgvBuf) < nargvbytes ) - pRun++; - } -} - -ConnectorInstance::~ConnectorInstance() -{ - delete [] pMimeType; - delete [] argn; - delete [] argv; - delete [] pArgnBuf; - delete [] pArgvBuf; - delete [] static_cast<char*>(aData.buf); -} - -const char* GetCommandName( CommandAtoms eCommand ) -{ - switch( eCommand ) - { - case eNPN_GetURL: return "NPN_GetURL"; - case eNPN_GetURLNotify: return "NPN_GetURLNotify"; - case eNPN_DestroyStream: return "NPN_DestroyStream"; - case eNPN_NewStream: return "NPN_NewStream"; - case eNPN_PostURLNotify: return "NPN_PostURLNotify"; - case eNPN_PostURL: return "NPN_PostURL"; - case eNPN_RequestRead: return "NPN_RequestRead"; - case eNPN_Status: return "NPN_Status"; - case eNPN_Version: return "NPN_Version"; - case eNPN_Write: return "NPN_Write"; - case eNPN_UserAgent: return "NPN_UserAgent"; - - case eNPP_DestroyStream: return "NPP_DestroyStream"; - case eNPP_Destroy: return "NPP_Destroy"; - case eNPP_DestroyPhase2: return "NPP_DestroyPhase2"; - case eNPP_NewStream: return "NPP_NewStream"; - case eNPP_New: return "NPP_New"; - case eNPP_SetWindow: return "NPP_SetWindow"; - case eNPP_StreamAsFile: return "NPP_StreamAsFile"; - case eNPP_URLNotify: return "NPP_URLNotify"; - case eNPP_WriteReady: return "NPP_WriteReady"; - case eNPP_Write: return "NPP_Write"; - case eNPP_GetMIMEDescription: return "NPP_GetMIMEDescription"; - case eNPP_Initialize: return "NPP_Initialize"; - case eNPP_Shutdown: return "NPP_Shutdown"; - - case eMaxCommand: return "eMaxCommand"; - default: return "unknown command"; - } - return nullptr; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/unx/sysplug.cxx b/extensions/source/plugin/unx/sysplug.cxx deleted file mode 100644 index 0693033c81f7..000000000000 --- a/extensions/source/plugin/unx/sysplug.cxx +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <config_folders.h> - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#include <sys/types.h> -#include <signal.h> -#include <sys/wait.h> -#include <osl/file.hxx> -#include <osl/thread.h> -#include <rtl/bootstrap.hxx> -#include <sal/log.hxx> - -#include <plugin/impl.hxx> - - -std::shared_ptr<SysPlugData> CreateSysPlugData() -{ - return std::shared_ptr<SysPlugData>(); -} - -UnxPluginComm::UnxPluginComm( - const OUString& /*mimetype*/, - const OUString& library, - Window aParent, - int nDescriptor1, - int nDescriptor2 - ) : - PluginComm( OUStringToOString( library, osl_getThreadTextEncoding() ), false ), - PluginConnector( nDescriptor2 ), - m_nCommPID( 0 ) -{ - OString path; - if (!getPluginappPath(&path)) - { - SAL_WARN("extensions.plugin", "cannot construct path to pluginapp.bin"); - return; - } - - char pDesc[32]; - char pWindow[32]; - sprintf( pWindow, "%d", (int)aParent ); - sprintf( pDesc, "%d", nDescriptor1 ); - OString aLib(OUStringToOString(library, osl_getThreadTextEncoding())); - - char const* pArgs[5]; - pArgs[0] = path.getStr(); - pArgs[1] = pDesc; - pArgs[2] = aLib.getStr(); - pArgs[3] = pWindow; - pArgs[4] = nullptr; - - SAL_INFO( - "extensions.plugin", - "try to launch: " << pArgs[0] << " " << pArgs[1] << " " << pArgs[2] - << " " << pArgs[3] << ", descriptors are " << nDescriptor1 << ", " - << nDescriptor2); - - pid_t pid = fork(); - if( pid == 0 ) - { - execvp( pArgs[0], const_cast< char ** >(pArgs) ); - SAL_WARN("extensions.plugin", "could not exec " << pArgs[0]); - _exit(255); - } - - if( pid == -1 ) - { - SAL_WARN("extensions.plugin", "fork failed"); - return; - } - - m_nCommPID = pid; - // wait for pluginapp.bin to start up - if( ! WaitForMessage() ) - { - SAL_WARN( - "extensions.plugin", - "timeout on command: " << pArgs[0] << " " << pArgs[1] << " " - << pArgs[2] << " " << pArgs[3]); - invalidate(); - } - else - { - MediatorMessage* pMessage = GetNextMessage( true ); - Respond( pMessage->m_nID, - const_cast<char*>("init ack"),8, - nullptr ); - delete pMessage; - NPP_Initialize(); - } -} - -UnxPluginComm::~UnxPluginComm() -{ - NPP_Shutdown(); - if( m_nCommPID != 0 ) - { - int status = 16777216; - pid_t nExit = waitpid( m_nCommPID, &status, WUNTRACED ); - SAL_INFO( - "extensions.plugin", - "child " << nExit << " (plugin app child " << m_nCommPID - << ") exited with status " << WEXITSTATUS(status)); - } -} - -bool UnxPluginComm::getPluginappPath(OString * path) { - OSL_ASSERT(path != nullptr); - OUString p("$BRAND_BASE_DIR/" LIBO_LIBEXEC_FOLDER "/pluginapp.bin"); - rtl::Bootstrap::expandMacros(p); - return - (osl::FileBase::getSystemPathFromFileURL(p, p) == - osl::FileBase::E_None) && - p.convertToString( - path, osl_getThreadTextEncoding(), - (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | - RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/unx/unxmgr.cxx b/extensions/source/plugin/unx/unxmgr.cxx deleted file mode 100644 index 3e82c38dfb0b..000000000000 --- a/extensions/source/plugin/unx/unxmgr.cxx +++ /dev/null @@ -1,313 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#ifdef AIX -#define _LINUX_SOURCE_COMPAT -#include <sys/timer.h> -#undef _LINUX_SOURCE_COMPAT -#endif - -#include <cstdarg> -#include <sys/stat.h> -#include <sys/types.h> -#include <dirent.h> -#include <osl/thread.h> -#include <rtl/strbuf.hxx> -#include <tools/appendunixshellword.hxx> - -#include <vcl/svapp.hxx> -#include <plugin/impl.hxx> - -using namespace std; -using namespace com::sun::star::uno; -using namespace com::sun::star::plugin; - - -// Unix specific implementation -static bool CheckPlugin( const OString& rPath, list< PluginDescription* >& rDescriptions ) -{ -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "Trying plugin %s ... ", rPath.getStr() ); -#endif - - sal_Int32 nPos = rPath.lastIndexOf('/'); - if (nPos == -1) - { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "no absolute path to plugin\n" ); -#endif - return false; - } - - OString aBaseName = rPath.copy(nPos+1); - if (aBaseName == "libnullplugin.so") - { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "don't like %s\n", aBaseName.getStr() ); -#endif - return false; - } - - struct stat aStat; - if (stat(rPath.getStr(), &aStat) || !S_ISREG(aStat.st_mode)) - { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "%s is not a regular file\n", rPath.getStr() ); -#endif - return false; - } - - rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); - - OString path; - if (!UnxPluginComm::getPluginappPath(&path)) - { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "cannot construct path to pluginapp.bin\n" ); -#endif - return false; - } - OStringBuffer cmd; - tools::appendUnixShellWord(&cmd, path); - cmd.append(' '); - tools::appendUnixShellWord(&cmd, rPath); - OString aCommand(cmd.makeStringAndClear()); - - FILE* pResult = popen( aCommand.getStr(), "r" ); - int nDescriptions = 0; - if( pResult ) - { - OStringBuffer aMIME; - char buf[256]; - while( fgets( buf, sizeof( buf ), pResult ) ) - { - for( size_t i = 0; i < sizeof(buf) && buf[i]; ++i ) - { - if( buf[i] == '\n' ) - buf[i] = ';'; - } - aMIME.append( buf ); - } - pclose( pResult ); - - if( !aMIME.isEmpty() ) - { - OString aLine = aMIME.makeStringAndClear(); - - sal_Int32 nIndex = 0; - while( nIndex != -1 ) - { - OString aType = aLine.getToken( 0, ';', nIndex ); - - sal_Int32 nTypeIndex = 0; - OString aMimetype = aType.getToken( 0, ':', nTypeIndex ); - OString aExtLine = aType.getToken( 0, ':', nTypeIndex ); - if( nTypeIndex < 0 ) // ensure at least three tokens - continue; - OString aDesc = aType.getToken( 0, ':', nTypeIndex ); - - // create extension list string - sal_Int32 nExtIndex = 0; - OStringBuffer aExtension; - while( nExtIndex != -1 ) - { - OString aExt = aExtLine.getToken( 0, ',', nExtIndex); - if( aExt.indexOf( "*." ) != 0 ) - aExtension.append( "*." ); - aExtension.append( aExt ); - if( nExtIndex != -1 ) - aExtension.append( ';' ); - } - - PluginDescription* pNew = new PluginDescription; - // set plugin name (path to library) - pNew->PluginName = OStringToOUString( rPath, aEncoding ); - // set mimetype - pNew->Mimetype = OStringToOUString( aMimetype, aEncoding ); - // set extension line - pNew->Extension = OStringToOUString( aExtension.makeStringAndClear(), aEncoding ); - // set description - pNew->Description= OStringToOUString( aDesc, aEncoding ); - rDescriptions.push_back( pNew ); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "Mimetype: %s\nExtension: %s\n" - "Description: %s\n", - OUStringToOString( pNew->Mimetype, aEncoding ).getStr(), - OUStringToOString( pNew->Extension, aEncoding ).getStr(), - OUStringToOString( pNew->Description, aEncoding ).getStr() - ); -#endif - } - } -#if OSL_DEBUG_LEVEL > 1 - else - fprintf( stderr, "result of \"%s\" contains no mimtype\n", - aCommand.getStr() ); -#endif - } -#if OSL_DEBUG_LEVEL > 1 - else - fprintf( stderr, "command \"%s\" failed\n", aCommand.getStr() ); -#endif - return nDescriptions > 0; -} - -static void CheckPluginRegistryFiles( const OString& rPath, list< PluginDescription* >& rDescriptions ) -{ - OStringBuffer aPath( 1024 ); - aPath.append( rPath ); - aPath.append( "/pluginreg.dat" ); - FILE* fp = fopen( aPath.getStr(), "r" ); - if( fp ) - { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "parsing %s\n", aPath.getStr() ); -#endif - char aLine[1024]; - while( fgets( aLine, sizeof( aLine ), fp ) ) - { - int nLineLen = strlen( aLine ); - int nDotPos; - for( nDotPos = nLineLen-1; nDotPos > 0 && aLine[nDotPos] != ':'; nDotPos-- ) - ; - if( aLine[0] == '/' && aLine[nDotPos] == ':' && aLine[nDotPos+1] == '$' ) - CheckPlugin( OString(aLine, nDotPos), rDescriptions ); - } - fclose( fp ); - } - - // check subdirectories - DIR* pDIR = opendir( rPath.getStr() ); - struct dirent* pDirEnt = nullptr; - struct stat aStat; - struct dirent u; - while( pDIR && ! readdir_r( pDIR, &u, &pDirEnt ) && pDirEnt ) - { - char* pBaseName = u.d_name; - if( rtl_str_compare( ".", pBaseName ) && rtl_str_compare( "..", pBaseName ) ) - { - OStringBuffer aBuf( 1024 ); - aBuf.append( rPath ); - aBuf.append( '/' ); - aBuf.append( pBaseName ); - - if( ! stat( aBuf.getStr(), &aStat ) ) - { - if( S_ISDIR( aStat.st_mode ) ) - CheckPluginRegistryFiles( aBuf.makeStringAndClear(), rDescriptions ); - } - } - } - if( pDIR ) - closedir( pDIR ); -} - -Sequence<PluginDescription> XPluginManager_Impl::impl_getPluginDescriptions() throw(css::uno::RuntimeException, std::exception) -{ - static Sequence<PluginDescription> aDescriptions; - static bool bHavePlugins = false; - if( ! bHavePlugins ) - { - rtl_TextEncoding aEncoding = osl_getThreadTextEncoding(); - list<PluginDescription*> aPlugins; - int i; - - // unix: search for plugins in /usr/lib/netscape/plugins, - // ~/.netscape/plugins und NPX_PLUGIN_PATH - // additionally: search in PluginsPath - static const char* pHome = getenv( "HOME" ); - static const char* pNPXPluginPath = getenv( "NPX_PLUGIN_PATH" ); - - // netscape!, quick, beam me back to the 90's when Motif roamed the earth - OStringBuffer aSearchBuffer("/usr/lib/netscape/plugins"); - if( pHome ) - aSearchBuffer.append(':').append(pHome).append("/.netscape/plugins"); - if( pNPXPluginPath ) - aSearchBuffer.append(':').append(pNPXPluginPath); - - const Sequence< OUString >& rPaths( PluginManager::getAdditionalSearchPaths() ); - for( i = 0; i < rPaths.getLength(); i++ ) - { - aSearchBuffer.append(':').append(OUStringToOString( - rPaths.getConstArray()[i], aEncoding)); - } - - OString aSearchPath = aSearchBuffer.makeStringAndClear(); - - sal_Int32 nIndex = 0; - struct dirent u; - do - { - OString aPath(aSearchPath.getToken(0, ':', nIndex)); - if (!aPath.isEmpty()) - { - DIR* pDIR = opendir(aPath.getStr()); - struct dirent* pDirEnt = nullptr; - while( pDIR && ! readdir_r( pDIR, &u, &pDirEnt ) && pDirEnt ) - { - char* pBaseName = u.d_name; - if( pBaseName[0] != '.' || - pBaseName[1] != '.' || - pBaseName[2] != 0 ) - { - OStringBuffer aFileName(aPath); - aFileName.append('/').append(pBaseName); - CheckPlugin( aFileName.makeStringAndClear(), aPlugins ); - } - } - if( pDIR ) - closedir( pDIR ); - } - } - while ( nIndex >= 0 ); - - // try ~/.mozilla/pluginreg.dat - OStringBuffer aBuf(256); - aBuf.append( pHome ); - aBuf.append( "/.mozilla" ); - CheckPluginRegistryFiles( aBuf.makeStringAndClear(), aPlugins ); - - // create return value - aDescriptions = Sequence<PluginDescription>( aPlugins.size() ); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "found %" SAL_PRI_SIZET "u plugins\n", aPlugins.size() ); -#endif - list<PluginDescription*>::iterator iter; - for( iter = aPlugins.begin(), i=0; iter != aPlugins.end(); ++iter ,i++ ) - { - aDescriptions.getArray()[ i ] = **iter; - delete *iter; - } - aPlugins.clear(); - bHavePlugins = true; - } - return aDescriptions; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/win/sysplug.cxx b/extensions/source/plugin/win/sysplug.cxx deleted file mode 100644 index 9c25da3c219d..000000000000 --- a/extensions/source/plugin/win/sysplug.cxx +++ /dev/null @@ -1,441 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include <prewin.h> -#include <postwin.h> - -#include <sal/log.hxx> - -#include <plugin/impl.hxx> - -#if defined _MSC_VER -#pragma warning (push,1) -#pragma warning (disable:4005) -#endif - -#include <string.h> -#include <tchar.h> -#include <objbase.h> - -#if defined _MSC_VER -#pragma warning (pop) -#endif - -#include <list> -#include <map> -#include <algorithm> - - -extern NPNetscapeFuncs aNPNFuncs; - -#include <tools/debug.hxx> - - -#if OSL_DEBUG_LEVEL > 1 -void TRACE( char const * s ); -void TRACEN( char const * s, long n ); -#else -#define TRACE(x) -#define TRACEN(x,n) -#endif - -std::shared_ptr<SysPlugData> CreateSysPlugData() -{ - return std::shared_ptr<SysPlugData>(); -} - - -PluginComm_Impl::PluginComm_Impl( const OUString& /*rMIME*/, const OUString& rName, HWND /*hWnd*/ ) - : PluginComm( OUStringToOString( rName, RTL_TEXTENCODING_MS_1252 ) ) -{ - // initialize plugin function table - memset( &_NPPfuncs, 0, sizeof( _NPPfuncs ) ); -#ifdef UNICODE - _plDLL = ::LoadLibrary( rName.getStr() ); -#else - OString aStr( OUStringToOString( rName, RTL_TEXTENCODING_MS_1252 ) ); - _plDLL = ::LoadLibrary( aStr.getStr() ); -#endif - DBG_ASSERT( _plDLL, "### loading plugin dll failed!" ); - - NPError (WINAPI * pEntry)( NPPluginFuncs* ); - retrieveFunction( _T("NP_GetEntryPoints"), (void**)&pEntry ); - - _NPPfuncs.size = sizeof( _NPPfuncs ); - _NPPfuncs.version = 0; - NPError nErr = (*pEntry)( &_NPPfuncs ); - - SAL_WARN_IF( - nErr != NPERR_NO_ERROR, "extensions.plugin", - "NP_GetEntryPoints() failed"); - DBG_ASSERT( (_NPPfuncs.version >> 8) >= NP_VERSION_MAJOR, - "### version failure!" ); - - m_eCall = eNP_Initialize; - if (execute() != NPERR_NO_ERROR) { - shutdown(); - throw CannotInitializeException(); - } -} - - -PluginComm_Impl::~PluginComm_Impl() -{ - shutdown(); -} - -void PluginComm_Impl::shutdown() -{ - if (_plDLL) - { -// NPP_Shutdown(); - - NPError (WINAPI * pShutdown)(); - if (retrieveFunction( _T("NP_Shutdown"), (void**)&pShutdown )) - { - NPError nErr = (*pShutdown)(); (void)nErr; - DBG_ASSERT( nErr == NPERR_NO_ERROR, "### NP_Shutdown() failed!" ); - } - - BOOL bRet = (BOOL)::FreeLibrary( _plDLL ); (void)bRet; - DBG_ASSERT( bRet, "### unloading plugin dll failed!" ); - _plDLL = NULL; - } -} - - -BOOL PluginComm_Impl::retrieveFunction( TCHAR const * pName, void** ppFunc ) const -{ - if( ! _plDLL ) - return FALSE; - - *ppFunc = (void*)::GetProcAddress( _plDLL, pName ); - - return (*ppFunc != NULL); -} - - - -long PluginComm_Impl::doIt() -{ - long nRet = 0; - switch( m_eCall ) - { - case eNP_Initialize: - { - TRACE( "eNP_Initialize" ); - NPError (WINAPI * pInit)( NPNetscapeFuncs* ); - if ((_NPPfuncs.version >> 8) >= NP_VERSION_MAJOR && - (retrieveFunction( _T("NP_Initialize"), (void**)&pInit ) || - retrieveFunction( _T("NP_PluginInit"), (void**)&pInit ))) - { - nRet = (*pInit)( &aNPNFuncs ); - } - else - { - nRet = NPERR_GENERIC_ERROR; - } - DBG_ASSERT( nRet == NPERR_NO_ERROR, "### NP_Initialize() failed!" ); - } - break; - case eNPP_Destroy: - TRACE( "eNPP_Destroy" ); - nRet = (_NPPfuncs.destroy - ? (*_NPPfuncs.destroy)( - (NPP)m_aArgs[0], - (NPSavedData**)m_aArgs[1] ) - : NPERR_GENERIC_ERROR); - break; - case eNPP_DestroyStream: - TRACE( "eNPP_DestroyStream" ); - nRet = (_NPPfuncs.destroystream - ? (*_NPPfuncs.destroystream)( - (NPP)m_aArgs[0], - (NPStream*)m_aArgs[1], - (NPError)(sal_IntPtr)m_aArgs[2] ) - : NPERR_GENERIC_ERROR); - break; - case eNPP_New: - TRACE( "eNPP_New" ); - nRet = (_NPPfuncs.newp - ? (*_NPPfuncs.newp)( - (NPMIMEType)m_aArgs[0], - (NPP)m_aArgs[1], - (uint16_t)(sal_IntPtr)m_aArgs[2], - (int16_t)(sal_IntPtr)m_aArgs[3], - (char**)m_aArgs[4], - (char**)m_aArgs[5], - (NPSavedData*)m_aArgs[6] ) - : NPERR_GENERIC_ERROR); - break; - case eNPP_NewStream: - TRACE( "eNPP_NewStream" ); - nRet = (_NPPfuncs.newstream - ? (*_NPPfuncs.newstream)( - (NPP)m_aArgs[0], - (NPMIMEType)m_aArgs[1], - (NPStream*)m_aArgs[2], - (NPBool)(sal_IntPtr)m_aArgs[3], - (uint16_t*)m_aArgs[4] ) - : NPERR_GENERIC_ERROR); - break; - case eNPP_Print: - TRACE( "eNPP_Print" ); - if (_NPPfuncs.print) - (*_NPPfuncs.print)( - (NPP)m_aArgs[0], - (NPPrint*)m_aArgs[1] ); - break; - case eNPP_SetWindow: - { - TRACE( "eNPP_SetWindow" ); - nRet = (_NPPfuncs.setwindow - ? (*_NPPfuncs.setwindow)( - (NPP)m_aArgs[0], - (NPWindow*)m_aArgs[1] ) - : NPERR_GENERIC_ERROR); - break; - } - case eNPP_StreamAsFile: - TRACE( "eNPP_StreamAsFile" ); - if (_NPPfuncs.asfile) - (*_NPPfuncs.asfile)( - (NPP)m_aArgs[0], - (NPStream*)m_aArgs[1], - (char*)m_aArgs[2] ); - break; - case eNPP_URLNotify: - TRACE( "eNPP_URLNotify" ); - if (_NPPfuncs.urlnotify) - (*_NPPfuncs.urlnotify)( - (NPP)m_aArgs[0], - (char*)m_aArgs[1], - (NPReason)(sal_IntPtr)m_aArgs[2], - m_aArgs[3] ); - break; - case eNPP_Write: - TRACEN( "eNPP_Write n=", (int32_t)m_aArgs[3] ); - nRet = (_NPPfuncs.write - ? (*_NPPfuncs.write)( - (NPP)m_aArgs[0], - (NPStream*)m_aArgs[1], - (sal_IntPtr)m_aArgs[2], - (sal_IntPtr)m_aArgs[3], - m_aArgs[4] ) - : 0); - break; - case eNPP_WriteReady: - TRACE( "eNPP_WriteReady" ); - nRet = (_NPPfuncs.writeready - ? (*_NPPfuncs.writeready)( - (NPP)m_aArgs[0], - (NPStream*)m_aArgs[1] ) - : 0); - break; - case eNPP_GetValue: - TRACE( "eNPP_GetValue" ); - nRet = (_NPPfuncs.getvalue - ? (*_NPPfuncs.getvalue)( - (NPP)m_aArgs[0], - (NPPVariable)(sal_IntPtr)m_aArgs[1], - m_aArgs[2] ) - : NPERR_GENERIC_ERROR); - break; - case eNPP_SetValue: - TRACE( "eNPP_SetValue" ); - nRet = (_NPPfuncs.setvalue - ? (*_NPPfuncs.setvalue)( - (NPP)m_aArgs[0], - (NPNVariable)(sal_IntPtr)m_aArgs[1], - m_aArgs[2] ) - : NPERR_GENERIC_ERROR); - break; - case eNPP_Shutdown: - { - TRACE( "eNPP_Shutdown" ); - NPP_ShutdownUPP pFunc; - if (retrieveFunction( _T("NPP_Shutdown"), (void**)&pFunc )) - (*pFunc)(); - } - break; - case eNPP_Initialize: - TRACE( "eNPP_Initialize" ); - OSL_FAIL( "NPP_Initialize: not implemented!" ); - break; - case eNPP_GetJavaClass: - TRACE( "eNPP_GetJavaClass" ); - OSL_FAIL( "NPP_GetJavaClass: not implemented!" ); - break; - } - return nRet; -} - - -NPError PluginComm_Impl::NPP_Destroy( NPP instance, NPSavedData** save ) -{ - DBG_ASSERT( _NPPfuncs.destroy, "### NPP_Destroy(): null pointer in NPP functions table!" ); - m_eCall = eNPP_Destroy; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)save; - return (NPError)execute(); -} - - -NPError PluginComm_Impl::NPP_DestroyStream( NPP instance, NPStream* stream, NPError reason ) -{ - DBG_ASSERT( _NPPfuncs.destroystream, "### NPP_DestroyStream(): null pointer in NPP functions table!" ); - m_eCall = eNPP_DestroyStream; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)stream; - m_aArgs[2] = reinterpret_cast< void * >(static_cast< sal_IntPtr >(reason)); - return (NPError)execute(); -} - - -NPError PluginComm_Impl::NPP_New( NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, - char* argn[], char* argv[], NPSavedData *saved ) -{ - DBG_ASSERT( _NPPfuncs.newp, "### NPP_New(): null pointer in NPP functions table!" ); - m_eCall = eNPP_New; - m_aArgs[0] = (void*)pluginType; - m_aArgs[1] = (void*)instance; - m_aArgs[2] = reinterpret_cast< void * >(static_cast< sal_uIntPtr >(mode)); - m_aArgs[3] = reinterpret_cast< void * >(static_cast< sal_IntPtr >(argc)); - m_aArgs[4] = (void*)argn; - m_aArgs[5] = (void*)argv; - m_aArgs[6] = (void*)saved; - return (NPError)execute(); -} - - -NPError PluginComm_Impl::NPP_NewStream( NPP instance, NPMIMEType type, NPStream* stream, - NPBool seekable, uint16_t* stype ) -{ - DBG_ASSERT( _NPPfuncs.newstream, "### NPP_NewStream(): null pointer in NPP functions table!" ); - m_eCall = eNPP_NewStream; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)type; - m_aArgs[2] = (void*)stream; - m_aArgs[3] = reinterpret_cast< void * >( - static_cast< sal_uIntPtr >(seekable)); - m_aArgs[4] = (void*)stype; - return (NPError)execute(); -} - - -void PluginComm_Impl::NPP_Print( NPP instance, NPPrint* platformPrint ) -{ - DBG_ASSERT( _NPPfuncs.print, "### NPP_Print(): null pointer in NPP functions table!" ); - m_eCall = eNPP_Print; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)platformPrint; - execute(); -} - - -NPError PluginComm_Impl::NPP_SetWindow( NPP instance, NPWindow* window ) -{ - DBG_ASSERT( _NPPfuncs.setwindow, "### NPP_SetWindow(): null pointer in NPP functions table!" ); - m_eCall = eNPP_SetWindow; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)window; - return (NPError)execute(); -} - - -void PluginComm_Impl::NPP_StreamAsFile( NPP instance, NPStream* stream, const char* fname ) -{ - DBG_ASSERT( _NPPfuncs.asfile, "### NPP_StreamAsFile(): null pointer in NPP functions table!" ); - m_eCall = eNPP_StreamAsFile; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)stream; - m_aArgs[2] = (void*)fname; - execute(); -} - - -void PluginComm_Impl::NPP_URLNotify( NPP instance, const char* url, NPReason reason, void* notifyData ) -{ - DBG_ASSERT( _NPPfuncs.urlnotify, "### NPP_URLNotify(): null pointer in NPP functions table!" ); - m_eCall = eNPP_URLNotify; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)url; - m_aArgs[2] = reinterpret_cast< void * >(static_cast< sal_IntPtr >(reason)); - m_aArgs[3] = notifyData; - execute(); -} - - -int32_t PluginComm_Impl::NPP_Write( NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer ) -{ - DBG_ASSERT( _NPPfuncs.write, "### NPP_Write(): null pointer in NPP functions table!" ); - m_eCall = eNPP_Write; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)stream; - m_aArgs[2] = (void*)(sal_IntPtr)offset; - m_aArgs[3] = (void*)(sal_IntPtr)len; - m_aArgs[4] = buffer; - return (NPError)execute(); -} - - -int32_t PluginComm_Impl::NPP_WriteReady( NPP instance, NPStream* stream ) -{ - DBG_ASSERT( _NPPfuncs.writeready, "### NPP_WriteReady(): null pointer in NPP functions table!" ); - m_eCall = eNPP_WriteReady; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)stream; - return execute(); -} - - -NPError PluginComm_Impl::NPP_GetValue( NPP instance, NPPVariable variable, void *ret_value ) -{ - DBG_ASSERT( _NPPfuncs.getvalue, "### NPP_GetValue(): null pointer in NPP functions table!" ); - m_eCall = eNPP_GetValue; - m_aArgs[0] = (void*)instance; - m_aArgs[1] = (void*)variable; - m_aArgs[2] = ret_value; - return (NPError)execute(); -} - - -NPError PluginComm_Impl::NPP_Initialize() -{ - return NPERR_NO_ERROR; -} - - -void PluginComm_Impl::NPP_Shutdown() -{ - m_eCall = eNPP_Shutdown; - execute(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/plugin/win/winmgr.cxx b/extensions/source/plugin/win/winmgr.cxx deleted file mode 100644 index b84315e1873f..000000000000 --- a/extensions/source/plugin/win/winmgr.cxx +++ /dev/null @@ -1,445 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#include <prewin.h> -#include <postwin.h> - -#include "vcl/svapp.hxx" -#include "tools/urlobj.hxx" -#include "osl/mutex.hxx" - -#include "rtl/string.hxx" -#include "rtl/ustring.hxx" -#include "rtl/ustrbuf.hxx" - -#include "plugin/impl.hxx" - -#if defined _MSC_VER -#pragma warning (push,1) -#pragma warning (disable:4005) -#endif - -#include <string.h> -#include <tchar.h> -#include <objbase.h> - -#if defined _MSC_VER -#pragma warning (pop) -#endif - -#include <list> -#include <map> -#include <algorithm> - - -using namespace std; -using namespace osl; -using namespace com::sun::star::uno; -using namespace com::sun::star::plugin; - - -typedef map< OString, OUString, less< OString > > PluginLocationMap; - - -static void addPluginsFromPath( const TCHAR * pPluginsPath, PluginLocationMap & rPlugins ) -{ - // append dll name pattern we are looking for - TCHAR arPluginsPath[MAX_PATH]; - arPluginsPath[0] = 0; - - if (::rtl_str_indexOfStr( pPluginsPath, "%programfiles%" ) == 0) - { - const char * p = ::getenv( "ProgramFiles" ); - if (p) - { - ::lstrcpy( arPluginsPath, p ); - pPluginsPath += 14; - } - } - ::lstrcat( arPluginsPath, pPluginsPath ); - ::lstrcat( arPluginsPath, _T("\\") ); - - TCHAR arPluginsPattern[MAX_PATH]; - ::lstrcpy( arPluginsPattern, arPluginsPath ); - ::lstrcat( arPluginsPattern, _T("NP*.DLL") ); - - WIN32_FIND_DATA aFindData; - HANDLE hFind = ::FindFirstFile( arPluginsPattern, &aFindData ); - - while (hFind != INVALID_HANDLE_VALUE) - { - OString aName = OString( aFindData.cFileName ).toAsciiLowerCase(); - - // no netscape default plugin anymore... - // and no double plugin dlls - if ( !aName.equals( "npnul32.dll" ) && - ! aName.equals( "npnrvp.dll" ) && - rPlugins.find( aName ) == rPlugins.end()) - { - TCHAR arComplete[MAX_PATH]; - ::lstrcpy( arComplete, arPluginsPath ); - ::lstrcat( arComplete, aFindData.cFileName ); - - OUString path( OStringToOUString( arComplete, RTL_TEXTENCODING_MS_1252 ) ); - rPlugins[ aName ] = path; - } - - if (! ::FindNextFile( hFind, &aFindData )) - break; - } - - if (hFind != INVALID_HANDLE_VALUE) - ::FindClose( hFind ); -} - -static void addPluginsFromPath( const OUString & rPath, PluginLocationMap & rPlugins ) -{ - TCHAR arPluginsPath[MAX_PATH]; - DWORD dwPluginsPathSize = sizeof(arPluginsPath); - arPluginsPath[dwPluginsPathSize-1] = 0; - - OString aStr( OUStringToOString( rPath, RTL_TEXTENCODING_MS_1252 ) ); - ::strncpy( arPluginsPath, aStr.getStr(), dwPluginsPathSize ); - - addPluginsFromPath( arPluginsPath, rPlugins ); -} - - - -static void add_IE_Plugins( PluginLocationMap & rPlugins ) -{ - HKEY hKey; - TCHAR arCurrent[MAX_PATH]; - DWORD dwType, dwCurrentSize = sizeof(arCurrent); - - if (::RegOpenKeyEx( HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\IE4\\SETUP"), - 0, KEY_READ, &hKey ) == ERROR_SUCCESS) - { - if (::RegQueryValueEx( hKey, _T("Path"), NULL, &dwType, - (LPBYTE)arCurrent, &dwCurrentSize ) == ERROR_SUCCESS && - (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) - { - // add \\Plugins - ::lstrcat( arCurrent, _T("\\Plugins") ); - - addPluginsFromPath( arCurrent, rPlugins ); - } - ::RegCloseKey( hKey ); - } -} - - -static void add_NS_keys( HKEY hKey, PluginLocationMap & rPlugins ) -{ - TCHAR value[MAX_PATH]; - DWORD dwType, size; - - // 4.7 - size = sizeof(value); - if (::RegQueryValueEx( - hKey, _T("Plugins Directory"), NULL, &dwType, - (LPBYTE)value, &size ) == ERROR_SUCCESS && - (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) - { - addPluginsFromPath( value, rPlugins ); - } - // 6 - size = sizeof(value); - if (::RegQueryValueEx( - hKey, _T("Install Directory"), NULL, &dwType, - (LPBYTE)value, &size ) == ERROR_SUCCESS && - (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) - { - int n = size / sizeof (TCHAR); - if ('\\' != value[ n -2 ]) - { - value[ n -1 ] = '\\'; - value[ n ] = 0; - } - addPluginsFromPath( ::lstrcat( value, _T("Plugins") ), rPlugins ); - } - size = sizeof(value); - if (::RegQueryValueEx( - hKey, _T("Plugins"), NULL, &dwType, - (LPBYTE)value, &size ) == ERROR_SUCCESS && - (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) - { - addPluginsFromPath( value, rPlugins ); - } -} - -static void add_NS_lookupRecursive( HKEY hKey, PluginLocationMap & rPlugins ) -{ - add_NS_keys( hKey, rPlugins ); - - TCHAR keyName[MAX_PATH]; - DWORD dwIndex = 0, size = sizeof (keyName); - - while (::RegEnumKeyEx( hKey, dwIndex, keyName, &size, NULL, NULL, NULL, NULL ) == ERROR_SUCCESS) - { - size = sizeof (keyName); - HKEY hSubKey; - if (::RegOpenKeyEx( hKey, keyName, 0, KEY_READ, &hSubKey ) == ERROR_SUCCESS) - { - add_NS_lookupRecursive( hSubKey, rPlugins ); - ::RegCloseKey( hSubKey ); - } - ++dwIndex; - } -} - -static void add_MozPlugin( HKEY hKey, PluginLocationMap & rPlugins ) -{ - TCHAR value[MAX_PATH]; - DWORD dwType, size; - - size = sizeof(value); - if (::RegQueryValueEx( - hKey, _T("Path"), NULL, &dwType, - (LPBYTE)value, &size ) == ERROR_SUCCESS && - (dwType == REG_SZ || dwType == REG_EXPAND_SZ)) - { - OUString aUPath( OStringToOUString( value, RTL_TEXTENCODING_MS_1252 ) ); - INetURLObject aURL( aUPath ); - OString aName( OUStringToOString( aURL.GetName().toAsciiLowerCase(), RTL_TEXTENCODING_MS_1252 ) ); - - // no netscape default plugin anymore... - // and no double plugin dlls - if ( !aName.equals( "npnul32.dll" ) && - ! aName.equals( "npnrvp.dll" ) && - rPlugins.find( aName ) == rPlugins.end()) - { - rPlugins[ aName ] = aUPath; - } - } -} -static void add_MozillaPlugin( HKEY hKey, PluginLocationMap & rPlugins ) -{ - TCHAR keyName[MAX_PATH]; - DWORD dwIndex = 0, size = sizeof (keyName); - - while (::RegEnumKeyEx( hKey, dwIndex, keyName, &size, NULL, NULL, NULL, NULL ) == ERROR_SUCCESS) - { - size = sizeof (keyName); - HKEY hSubKey; - if (::RegOpenKeyEx( hKey, keyName, 0, KEY_READ, &hSubKey ) == ERROR_SUCCESS) - { - add_MozPlugin( hSubKey, rPlugins ); - ::RegCloseKey( hSubKey ); - } - ++dwIndex; - } -} - -static void add_NS_Plugins( PluginLocationMap & rPlugins ) -{ - HKEY hKey; - // Netscape - if (::RegOpenKeyEx( - HKEY_LOCAL_MACHINE, _T("Software\\Netscape"), - 0, KEY_READ, &hKey ) == ERROR_SUCCESS) - { - add_NS_lookupRecursive( hKey, rPlugins ); - ::RegCloseKey( hKey ); - } - // Mozilla - if (::RegOpenKeyEx( - HKEY_LOCAL_MACHINE, _T("Software\\Mozilla"), - 0, KEY_READ, &hKey ) == ERROR_SUCCESS) - { - add_NS_lookupRecursive( hKey, rPlugins ); - ::RegCloseKey( hKey ); - } - // Mozilla - plugins - if (::RegOpenKeyEx( - HKEY_LOCAL_MACHINE, _T("Software\\MozillaPlugins"), - 0, KEY_READ, &hKey ) == ERROR_SUCCESS) - { - add_MozillaPlugin( hKey, rPlugins ); - ::RegCloseKey( hKey ); - } -} - - -static void add_SO_Plugins( PluginLocationMap & rPlugins ) -{ - const Sequence< OUString > & rPaths = PluginManager::getAdditionalSearchPaths(); - - const OUString * pPaths = rPaths.getConstArray(); - for ( UINT32 nPos = rPaths.getLength(); nPos--; ) - { - addPluginsFromPath( pPaths[nPos], rPlugins ); - } -} - - -Sequence< PluginDescription > XPluginManager_Impl::impl_getPluginDescriptions() throw(css::uno::RuntimeException, std::exception) -{ - Guard< Mutex > aGuard( Mutex::getGlobalMutex() ); - static Sequence<PluginDescription > s_aDescriptions( 0 ); - static bool s_bInit = FALSE; - - if (! s_bInit) - { - // collect all distinct plugin dlls - PluginLocationMap aPlugins; - add_SO_Plugins( aPlugins ); - add_NS_Plugins( aPlugins ); - add_IE_Plugins( aPlugins ); - - // collect mime types of plugin dlls - for ( PluginLocationMap::iterator iPos( aPlugins.begin() ); - iPos != aPlugins.end(); - ++iPos ) - { - TCHAR arFileName[MAX_PATH]; - DWORD dwDummy, dwSize; - - // DLL name - OUString aName( (*iPos).second.getStr() ); - - OString aStr( OUStringToOString( aName, RTL_TEXTENCODING_MS_1252 ) ); - ::strcpy( arFileName, aStr.getStr() ); - dwSize = ::GetFileVersionInfoSize( arFileName, &dwDummy ); - - if ( !dwSize ) - continue; - - char * pVersionData = new char[dwSize]; - if (::GetFileVersionInfo( arFileName, 0, dwSize, pVersionData)) - { - // optional comment - OUString aComment; - - TCHAR * pInfo = NULL, * pInfo2 = NULL; - UINT nSize = 0; - if (::VerQueryValue( pVersionData, _T("\\StringFileInfo\\040904E4\\ProductName"), - (void**)&pInfo, &nSize ) && pInfo) - { - aComment.operator=( OStringToOUString( OString(pInfo), RTL_TEXTENCODING_MS_1252 ) ); - } - - // mandatory mime type and file extensions - if (::VerQueryValue( pVersionData, _T("\\StringFileInfo\\040904E4\\MIMEType"), - (void**)&pInfo, &nSize ) && pInfo && - ::VerQueryValue( pVersionData, _T("\\StringFileInfo\\040904E4\\FileExtents"), - (void**)&pInfo2, &nSize ) && pInfo2) - { - OString aExt( pInfo2 ); - OString aMIME( pInfo ); - aMIME.trim(); - - // count mime tokens - USHORT nToken = 0; - if (aMIME.getLength()) - { - ++nToken; - for ( sal_Int32 n = aMIME.getLength(); n--; ) - { - if (aMIME[ n ] == '|') - { - ++nToken; - } - } - } - sal_Int32 nIndex = 0, nIndex2 = 0; - - UINT32 nStart = s_aDescriptions.getLength(); - s_aDescriptions.realloc( nStart + nToken ); - PluginDescription* pDescriptions = s_aDescriptions.getArray(); - // for every MIME Type - sal_Int32 nTok = 0; - while (true) - { - if (nIndex < 0 || nIndex2 < 0) - break; - - PluginDescription & rDescr = pDescriptions[nStart+nTok]; - OString aMIMEToken( aMIME.getToken( 0, '|', nIndex ) ); - OString aExtToken2( aExt.getToken( 0, '|', nIndex2 ) ); - if( aMIMEToken.isEmpty() || aExtToken2.isEmpty() ) - continue; - - rDescr.Mimetype = OUString( - aMIMEToken.getStr(), aMIMEToken.getLength(), RTL_TEXTENCODING_MS_1252 ); - if (! rDescr.Mimetype.getLength()) - break; - - OUString aExtToken( aExtToken2.getStr(), aExtToken2.getLength(), RTL_TEXTENCODING_MS_1252 ); - rDescr.PluginName = aName; - rDescr.Description = aComment; - - sal_Int32 nPos = 0, nLen = aExtToken.getLength(); - OUString aExtensions = nLen ? OUString("*.") : OUString("*.*"); - - for ( ; nPos < nLen; ++nPos ) - { - sal_Unicode c = aExtToken[nPos]; - switch (c) - { - case ',': - case ';': - aExtensions += ";*."; - case ' ': - break; - case '*': - if (nPos < (nLen-1) && aExtToken[ nPos+1 ] == '.') - { - ++nPos; - break; - } - default: - aExtensions += OUString( &c, 1 ); - } - } - rDescr.Extension = aExtensions; - - ++nTok; - } - - if (nToken != nTok) - { - s_aDescriptions.realloc( nTok ); - } - } -#if OSL_DEBUG_LEVEL > 1 - else - OSL_FAIL( "### cannot get MIME type or extensions!" ); -#endif - } - delete[] pVersionData; - } - - s_bInit = TRUE; - } - return s_aDescriptions; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |