[ooo-build-commit] Branch 'ooo/master' - 3 commits - extensions/source forms/qa forms/source package/inc package/source
Jan Holesovsky
kendy at kemper.freedesktop.org
Tue Sep 8 19:23:20 PDT 2009
extensions/source/config/ldap/ldapaccess.cxx | 89 ++++-
extensions/source/config/ldap/ldapaccess.hxx | 35 ++
extensions/source/config/ldap/ldapuserprof.cxx | 6
extensions/source/config/ldap/ldapuserprofilebe.cxx | 29 -
extensions/source/config/ldap/makefile.mk | 1
extensions/source/plugin/aqua/macmgr.cxx | 39 ++
forms/qa/makefile.mk | 9
forms/source/xforms/xpathlib/xpathlib.cxx | 2
package/inc/ZipFile.hxx | 14
package/inc/ZipPackage.hxx | 17 -
package/inc/ZipPackageBuffer.hxx | 2
package/inc/zipfileaccess.hxx | 6
package/source/zipapi/XUnbufferedStream.cxx | 13
package/source/zipapi/XUnbufferedStream.hxx | 13
package/source/zipapi/ZipFile.cxx | 25 -
package/source/zippackage/ZipPackage.cxx | 321 +++++++++++---------
package/source/zippackage/ZipPackageStream.cxx | 32 -
package/source/zippackage/ZipPackageStream.hxx | 2
package/source/zippackage/zipfileaccess.cxx | 33 +-
19 files changed, 446 insertions(+), 242 deletions(-)
New commits:
commit a6c9ab67af9c1aa61d5dd94e4d89ee4adbef2fb2
Author: Oliver Bolte <obo at openoffice.org>
Date: Tue Sep 8 10:44:42 2009 +0000
CWS-TOOLING: integrate CWS vcl104
diff --git a/extensions/source/plugin/aqua/macmgr.cxx b/extensions/source/plugin/aqua/macmgr.cxx
index fd0f257..8c09bef 100644
--- a/extensions/source/plugin/aqua/macmgr.cxx
+++ b/extensions/source/plugin/aqua/macmgr.cxx
@@ -400,12 +400,48 @@ static int parseMimeResource( CFBundleRef i_xBundle,
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) );
+
+ // #i102735# VLC plugin prior to 1.0 tends to crash
+ if( aBundleName.equalsAscii( "VLC Plug-in" ) )
+ {
+ sal_Int32 nIndex = 0;
+ rtl::OUString aMajor( aBundleVersion.getToken( 0, '.', nIndex ) );
+ if( aMajor.toInt32() < 1 )
+ {
+ #if OSL_DEBUG_LEVEL > 1
+ fprintf( stderr, "rejecting VCL plugin (%s %s)\n",
+ rtl::OUStringToOString( aBundleName, RTL_TEXTENCODING_UTF8 ).getStr(),
+ rtl::OUStringToOString( aBundleVersion, RTL_TEXTENCODING_UTF8 ).getStr()
+ );
+ #endif
+ return true;
+ }
+ }
+
+ return false;
+}
+
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 );
@@ -424,7 +460,8 @@ static int getPluginDescriptions( CFBundleRef i_xBundle , list< PluginDescriptio
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() );
+ rtl::OUStringToOString( aPlugDescription, RTL_TEXTENCODING_UTF8 ).getStr()
+ );
#endif
commit 6630b6cd803ca59525f3b5df909b97e15626fb14
Author: Oliver Bolte <obo at openoffice.org>
Date: Tue Sep 8 08:54:47 2009 +0000
CWS-TOOLING: integrate CWS dba32f
2009-08-31 10:43:51 +0200 msc r275590 : #no issuezilla available# make the testcase more error proof
2009-08-31 10:43:28 +0200 msc r275589 : #no issuezilla available# make the testcase more error proof
2009-08-31 10:40:33 +0200 msc r275588 : i85993 remove bugid
2009-08-31 10:38:28 +0200 msc r275587 : i100000
2009-08-27 13:27:32 +0200 fs r275476 : #i103882#
2009-08-27 12:47:54 +0200 fs r275474 : #i104544#
do not allow re-entrance for impl_ensureControl_nothrow
Actually, this is part of the fix only. I also removed the code which triggered this re-entrance (from
the grid control implementation), but to ensure it won't happen, again, I added some safety herein.
2009-08-27 12:47:16 +0200 fs r275473 : #i104544# SetState: Do not call Update at the window which we just set text for. It should (sic\!) not be needed, but causes trouble
2009-08-27 10:18:05 +0200 mav r275461 : #i103266# do not allow any stream operation on package streams while commiting the package
2009-08-20 15:25:48 +0200 fs r275184 : #i104362# fall back to a ViewObjectContactOfSdrObj in case we don't have a page view
2009-08-20 15:25:06 +0200 fs r275183 : AUGMENT_LIBRARY_PATH
2009-08-20 15:10:34 +0200 fs r275182 : AUGMENT_LIBRARY_PATH
2009-08-20 09:50:36 +0200 oj r275167 : #i104266# notify propertyforward when new dest was created
2009-08-19 08:01:28 +0200 mav r275133 : #i103266# fix the typo
2009-08-18 22:45:34 +0200 fs r275131 : #i10000#
2009-08-18 13:53:07 +0200 oj r275105 : #i104266# set column settings after alter columns
2009-08-18 13:41:49 +0200 fs r275103 : #i102550# do not interpret names of existing data sources as system path
2009-08-18 13:13:05 +0200 oj r275097 : #i103882# use correct number Format
2009-08-18 12:59:13 +0200 fs r275094 : #i104181#
2009-08-18 09:07:48 +0200 fs r275079 : updated readme to refer to proper 1.1.14
2009-08-18 08:32:31 +0200 oj r275077 : #i104187# wrong default for FirstCellAsLabel corrected
2009-08-18 08:10:00 +0200 oj r275076 : #i104187# dispose status controller to avoid access of dead statusBar in sfx
2009-08-17 21:56:19 +0200 fs r275074 : merge fix for issue #102564# from dba32e
2009-08-17 15:34:40 +0200 fs r275058 : don't set MaxFieldSize to 0 unconditionally
2009-08-17 14:33:57 +0200 oj r275054 : #i103528# patch for bitxtor
2009-08-17 14:12:26 +0200 oj r275051 : #i104160# fix VerticalAlignment
2009-08-17 14:11:47 +0200 oj r275050 : #i104160# fix VerticalAlignment
2009-08-14 15:54:04 +0200 mav r274989 : #i103266# avoid possibility for race condition
2009-08-13 13:52:43 +0200 fs r274939 : improved diagnostics
2009-08-13 13:52:28 +0200 fs r274938 : typo
2009-08-13 12:51:03 +0200 fs r274934 : #i103763# provided by cloph: correct libIDL check when compiling Mozilla
2009-08-13 12:43:23 +0200 fs r274933 : #i103763# provided by cloph: allow to cross-compile prebuilt zips on Mac
2009-08-13 12:41:15 +0200 fs r274932 : #i103371# fire PREPARECLOSEDOC even for embedded objects (why not?)
2009-08-13 12:24:49 +0200 fs r274930 : #i99890# remove 'Insert Control' from the popup menu
2009-08-13 12:23:38 +0200 fs r274929 : #i99890# DoToolboxAction: assert unknown/unimplemented actions
2009-08-13 09:32:07 +0200 fs r274923 : #i103721#
2009-08-13 09:26:32 +0200 fs r274922 : #i99894# provided by dtardon: xforms_nowFunction: use proper memory allocation function
2009-08-13 09:20:21 +0200 fs r274921 : #i103938# provided by cmc: pass proper arguments to OUString::intern
2009-08-12 22:34:28 +0200 fs r274916 : #i104139# when executing a PopupMenu, pass the POPUPMENU_NOMOUSEUPCLOSE flag
diff --git a/forms/qa/makefile.mk b/forms/qa/makefile.mk
index 822f67e..b34529e 100644
--- a/forms/qa/makefile.mk
+++ b/forms/qa/makefile.mk
@@ -73,15 +73,18 @@ ALL: ALLDEP
.INCLUDE : target.mk
+test:
+ echo $(SOLARBINDIR)
+
.IF "$(BUILD_QADEVOOO)" == "YES"
show_targets:
- + at java $(RUNNER_CLASSPATH) complexlib.ShowTargets $(foreach,i,$(JAVAFILES) $(i:s/.\$///:s/.java//))
+ +@$(AUGMENT_LIBRARY_PATH) java $(RUNNER_CLASSPATH) complexlib.ShowTargets $(foreach,i,$(JAVAFILES) $(i:s/.\$///:s/.java//))
run:
- +$(COPY) integration$/forms$/*.props $(CLASSDIR)$/$(PACKAGE) && java $(RUNNER_CLASSPATH) $(RUNNER_ARGS) -sce forms_all.sce
+ +$(COPY) integration$/forms$/*.props $(CLASSDIR)$/$(PACKAGE) && $(AUGMENT_LIBRARY_PATH) java $(RUNNER_CLASSPATH) $(RUNNER_ARGS) -sce forms_all.sce
run_%:
- +$(COPY) integration$/forms$/*.props $(CLASSDIR)$/$(PACKAGE) && java $(RUNNER_CLASSPATH) $(RUNNER_ARGS) -o integration.$(PRJNAME).$(@:s/run_//)
+ +$(COPY) integration$/forms$/*.props $(CLASSDIR)$/$(PACKAGE) && $(AUGMENT_LIBRARY_PATH) java $(RUNNER_CLASSPATH) $(RUNNER_ARGS) -o integration.$(PRJNAME).$(@:s/run_//)
.ELSE
run: show_targets
diff --git a/forms/source/xforms/xpathlib/xpathlib.cxx b/forms/source/xforms/xpathlib/xpathlib.cxx
index 1c4bf3f..a4dfbe3 100644
--- a/forms/source/xforms/xpathlib/xpathlib.cxx
+++ b/forms/source/xforms/xpathlib/xpathlib.cxx
@@ -293,7 +293,7 @@ void xforms_nowFunction(xmlXPathParserContextPtr ctxt, int /*nargs*/)
*/
DateTime aDateTime;
::rtl::OString aDateTimeString = makeDateTimeString(aDateTime);
- xmlChar *pString = (xmlChar*)rtl_allocateMemory(aDateTimeString.getLength()+1);
+ xmlChar *pString = static_cast<xmlChar*>(xmlMalloc(aDateTimeString.getLength()+1));
strncpy((char*)pString, (char*)aDateTimeString.getStr(), aDateTimeString.getLength());
pString[aDateTimeString.getLength()] = 0;
xmlXPathReturnString(ctxt, pString);
diff --git a/package/inc/ZipFile.hxx b/package/inc/ZipFile.hxx
index 7f01e7c..93d26a0 100644
--- a/package/inc/ZipFile.hxx
+++ b/package/inc/ZipFile.hxx
@@ -40,6 +40,7 @@
#include <Inflater.hxx>
#endif
+#include <mutexholder.hxx>
namespace com { namespace sun { namespace star {
namespace lang { class XMultiServiceFactory; }
@@ -90,6 +91,7 @@ protected:
// aMediaType parameter is used only for raw stream header creation
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > createUnbufferedStream(
+ SotMutexHolderRef aMutexHolder,
ZipEntry & rEntry,
const vos::ORef < EncryptionData > &rData,
sal_Int8 nStreamMode,
@@ -128,7 +130,8 @@ public:
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getRawData(
ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bDecrypt)
+ sal_Bool bDecrypt,
+ SotMutexHolderRef aMutexHolder )
throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException);
static sal_Bool StaticGetCipher ( const vos::ORef < EncryptionData > & xEncryptionData, rtlCipher &rCipher, sal_Bool bDecode );
@@ -157,13 +160,15 @@ public:
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream(
ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bDecrypt )
+ sal_Bool bDecrypt,
+ SotMutexHolderRef aMutexHolder )
throw(::com::sun::star::io::IOException, ::com::sun::star::packages::zip::ZipException, ::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getDataStream(
ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bDecrypt )
+ sal_Bool bDecrypt,
+ SotMutexHolderRef aMutexHolder )
throw ( ::com::sun::star::packages::WrongPasswordException,
::com::sun::star::io::IOException,
::com::sun::star::packages::zip::ZipException,
@@ -172,7 +177,8 @@ public:
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getWrappedRawStream(
ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- const ::rtl::OUString& aMediaType )
+ const ::rtl::OUString& aMediaType,
+ SotMutexHolderRef aMutexHolder )
throw ( ::com::sun::star::packages::NoEncryptionException,
::com::sun::star::io::IOException,
::com::sun::star::packages::zip::ZipException,
diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx
index a1e7579..2fd8afc 100644
--- a/package/inc/ZipPackage.hxx
+++ b/package/inc/ZipPackage.hxx
@@ -37,12 +37,15 @@
#include <com/sun/star/util/XChangesBatch.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
#ifndef _COM_SUN_STAR_LANG_XPSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#include <HashMaps.hxx>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <osl/file.h>
+#include <mutexholder.hxx>
+
class ZipOutputStream;
class ZipPackageFolder;
class ZipFile;
@@ -81,6 +84,8 @@ class ZipPackage : public cppu::WeakImplHelper7
>
{
protected:
+ SotMutexHolderRef m_aMutexHolder;
+
::com::sun::star::uno::Sequence < sal_Int8 > aEncryptionKey;
FolderHash aRecent;
::rtl::OUString sURL;
@@ -106,9 +111,13 @@ protected:
void parseManifest();
void parseContentType();
void getZipFileContents();
- sal_Bool writeFileIsTemp();
- ::com::sun::star::uno::Reference < ::com::sun::star::io::XActiveDataStreamer > openOriginalForOutput();
+
void WriteMimetypeMagicFile( ZipOutputStream& aZipOut );
+ void WriteManifest( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
+ void WriteContentTypes( ZipOutputStream& aZipOut, const ::std::vector< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > >& aManList );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > writeTempFile();
+ ::com::sun::star::uno::Reference < ::com::sun::star::io::XActiveDataStreamer > openOriginalForOutput();
void DisconnectFromTargetAndThrowException_Impl(
const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xTempStream );
@@ -119,6 +128,10 @@ public:
const com::sun::star::uno::Sequence < sal_Int8 > & getEncryptionKey ( ) {return aEncryptionKey;}
sal_Int16 getFormat() const { return m_nFormat; }
+ SotMutexHolderRef GetSharedMutexRef() { return m_aMutexHolder; }
+
+ void ConnectTo( const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInStream );
+
// XInitialization
virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
diff --git a/package/inc/ZipPackageBuffer.hxx b/package/inc/ZipPackageBuffer.hxx
index c69059f..b4462dc 100644
--- a/package/inc/ZipPackageBuffer.hxx
+++ b/package/inc/ZipPackageBuffer.hxx
@@ -56,7 +56,7 @@ public:
inline void realloc ( sal_Int32 nSize ) { m_aBuffer.realloc ( nSize ); }
inline const sal_Int8 * getConstArray () const { return m_aBuffer.getConstArray(); }
- inline const com::sun::star::uno::Sequence < sal_Int8> & getSequence () const { return m_aBuffer; }
+ inline const com::sun::star::uno::Sequence < sal_Int8> getSequence () const { return m_aBuffer; }
// XInputStream
virtual sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
diff --git a/package/inc/zipfileaccess.hxx b/package/inc/zipfileaccess.hxx
index 2f6ad04..aaf45e0 100644
--- a/package/inc/zipfileaccess.hxx
+++ b/package/inc/zipfileaccess.hxx
@@ -40,7 +40,8 @@
#include <cppuhelper/interfacecontainer.h>
#include <cppuhelper/implbase5.hxx>
-#include <osl/mutex.hxx>
+
+#include <mutexholder.hxx>
#include <ZipFile.hxx>
#include <HashMaps.hxx>
@@ -52,7 +53,8 @@ class OZipFileAccess : public ::cppu::WeakImplHelper5<
::com::sun::star::lang::XComponent,
::com::sun::star::lang::XServiceInfo >
{
- ::osl::Mutex m_aMutex;
+ SotMutexHolderRef m_aMutexHolder;
+
::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > m_xContentStream;
diff --git a/package/source/zipapi/XUnbufferedStream.cxx b/package/source/zipapi/XUnbufferedStream.cxx
index 66976d5..0328837 100644
--- a/package/source/zipapi/XUnbufferedStream.cxx
+++ b/package/source/zipapi/XUnbufferedStream.cxx
@@ -41,6 +41,8 @@
#include <algorithm>
#include <string.h>
+#include <osl/mutex.hxx>
+
#if 0
// for debugging purposes here
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
@@ -55,14 +57,16 @@ using com::sun::star::lang::IllegalArgumentException;
using com::sun::star::packages::zip::ZipIOException;
using ::rtl::OUString;
-XUnbufferedStream::XUnbufferedStream( ZipEntry & rEntry,
+XUnbufferedStream::XUnbufferedStream( SotMutexHolderRef aMutexHolder,
+ ZipEntry & rEntry,
Reference < XInputStream > xNewZipStream,
const vos::ORef < EncryptionData > &rData,
sal_Int8 nStreamMode,
sal_Bool bIsEncrypted,
const ::rtl::OUString& aMediaType,
sal_Bool bRecoveryMode )
-: mxZipStream ( xNewZipStream )
+: maMutexHolder( aMutexHolder.Is() ? aMutexHolder : SotMutexHolderRef( new SotMutexHolder ) )
+, mxZipStream ( xNewZipStream )
, mxZipSeek ( xNewZipStream, UNO_QUERY )
, maEntry ( rEntry )
, mxData ( rData )
@@ -115,7 +119,8 @@ XUnbufferedStream::XUnbufferedStream( ZipEntry & rEntry,
// allows to read package raw stream
XUnbufferedStream::XUnbufferedStream( const Reference < XInputStream >& xRawStream,
const vos::ORef < EncryptionData > &rData )
-: mxZipStream ( xRawStream )
+: maMutexHolder( new SotMutexHolder )
+, mxZipStream ( xRawStream )
, mxZipSeek ( xRawStream, UNO_QUERY )
, mxData ( rData )
, maCipher ( NULL )
@@ -159,6 +164,8 @@ XUnbufferedStream::~XUnbufferedStream()
sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead )
throw( NotConnectedException, BufferSizeExceededException, IOException, RuntimeException)
{
+ ::osl::MutexGuard aGuard( maMutexHolder->GetMutex() );
+
sal_Int32 nRequestedBytes = nBytesToRead;
OSL_ENSURE( !mnHeaderToRead || mbWrappedRaw, "Only encrypted raw stream can be provided with header!" );
if ( mnMyCurrent + nRequestedBytes > mnZipSize + maHeader.getLength() )
diff --git a/package/source/zipapi/XUnbufferedStream.hxx b/package/source/zipapi/XUnbufferedStream.hxx
index f63d1b2..63b4951 100644
--- a/package/source/zipapi/XUnbufferedStream.hxx
+++ b/package/source/zipapi/XUnbufferedStream.hxx
@@ -36,16 +36,11 @@
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/io/XOutputStream.hpp>
#include <cppuhelper/implbase1.hxx>
-#ifndef _VOS_REF_H_
#include <vos/ref.hxx>
-#endif
-#ifndef _INFLATER_HXX
#include <Inflater.hxx>
-#endif
#include <ZipEntry.hxx>
-#ifndef _CRC32_HXX_
#include <CRC32.hxx>
-#endif
+#include <mutexholder.hxx>
#define UNBUFF_STREAM_DATA 0
#define UNBUFF_STREAM_RAW 1
@@ -59,6 +54,8 @@ class XUnbufferedStream : public cppu::WeakImplHelper1
>
{
protected:
+ SotMutexHolderRef maMutexHolder;
+
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > mxZipStream;
com::sun::star::uno::Reference < com::sun::star::io::XSeekable > mxZipSeek;
com::sun::star::uno::Sequence < sal_Int8 > maCompBuffer, maHeader;
@@ -73,7 +70,9 @@ protected:
sal_Bool mbCheckCRC;
public:
- XUnbufferedStream( ZipEntry & rEntry,
+ XUnbufferedStream(
+ SotMutexHolderRef aMutexHolder,
+ ZipEntry & rEntry,
com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xNewZipStream,
const vos::ORef < EncryptionData > &rData,
sal_Int8 nStreamMode,
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 4bd3a35..89dbbb2 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -492,13 +492,14 @@ Reference < XInputStream > ZipFile::createMemoryStream(
}
#endif
Reference < XInputStream > ZipFile::createUnbufferedStream(
+ SotMutexHolderRef aMutexHolder,
ZipEntry & rEntry,
const ORef < EncryptionData > &rData,
sal_Int8 nStreamMode,
sal_Bool bIsEncrypted,
::rtl::OUString aMediaType )
{
- return new XUnbufferedStream ( rEntry, xStream, rData, nStreamMode, bIsEncrypted, aMediaType, bRecoveryMode );
+ return new XUnbufferedStream ( aMutexHolder, rEntry, xStream, rData, nStreamMode, bIsEncrypted, aMediaType, bRecoveryMode );
}
@@ -509,7 +510,8 @@ ZipEnumeration * SAL_CALL ZipFile::entries( )
Reference< XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bIsEncrypted )
+ sal_Bool bIsEncrypted,
+ SotMutexHolderRef aMutexHolder )
throw(IOException, ZipException, RuntimeException)
{
if ( rEntry.nOffset <= 0 )
@@ -525,7 +527,8 @@ Reference< XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry,
if ( bIsEncrypted && !rData.isEmpty() && rData->aDigest.getLength() )
bNeedRawStream = !hasValidPassword ( rEntry, rData );
- return createUnbufferedStream ( rEntry,
+ return createUnbufferedStream ( aMutexHolder,
+ rEntry,
rData,
bNeedRawStream ? UNBUFF_STREAM_RAW : UNBUFF_STREAM_DATA,
bIsEncrypted );
@@ -533,7 +536,8 @@ Reference< XInputStream > SAL_CALL ZipFile::getInputStream( ZipEntry& rEntry,
Reference< XInputStream > SAL_CALL ZipFile::getDataStream( ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bIsEncrypted )
+ sal_Bool bIsEncrypted,
+ SotMutexHolderRef aMutexHolder )
throw ( packages::WrongPasswordException,
IOException,
ZipException,
@@ -562,7 +566,8 @@ Reference< XInputStream > SAL_CALL ZipFile::getDataStream( ZipEntry& rEntry,
else
bNeedRawStream = ( rEntry.nMethod == STORED );
- return createUnbufferedStream ( rEntry,
+ return createUnbufferedStream ( aMutexHolder,
+ rEntry,
rData,
bNeedRawStream ? UNBUFF_STREAM_RAW : UNBUFF_STREAM_DATA,
bIsEncrypted );
@@ -570,19 +575,21 @@ Reference< XInputStream > SAL_CALL ZipFile::getDataStream( ZipEntry& rEntry,
Reference< XInputStream > SAL_CALL ZipFile::getRawData( ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- sal_Bool bIsEncrypted )
+ sal_Bool bIsEncrypted,
+ SotMutexHolderRef aMutexHolder )
throw(IOException, ZipException, RuntimeException)
{
if ( rEntry.nOffset <= 0 )
readLOC( rEntry );
- return createUnbufferedStream ( rEntry, rData, UNBUFF_STREAM_RAW, bIsEncrypted );
+ return createUnbufferedStream ( aMutexHolder, rEntry, rData, UNBUFF_STREAM_RAW, bIsEncrypted );
}
Reference< XInputStream > SAL_CALL ZipFile::getWrappedRawStream(
ZipEntry& rEntry,
const vos::ORef < EncryptionData > &rData,
- const ::rtl::OUString& aMediaType )
+ const ::rtl::OUString& aMediaType,
+ SotMutexHolderRef aMutexHolder )
throw ( packages::NoEncryptionException,
IOException,
ZipException,
@@ -594,7 +601,7 @@ Reference< XInputStream > SAL_CALL ZipFile::getWrappedRawStream(
if ( rEntry.nOffset <= 0 )
readLOC( rEntry );
- return createUnbufferedStream ( rEntry, rData, UNBUFF_STREAM_WRAPPEDRAW, sal_True, aMediaType );
+ return createUnbufferedStream ( aMutexHolder, rEntry, rData, UNBUFF_STREAM_WRAPPEDRAW, sal_True, aMediaType );
}
sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index 34fbea0..427a2ca 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -83,6 +83,7 @@
#include <comphelper/seekableinput.hxx>
#include <comphelper/storagehelper.hxx>
#include <comphelper/ofopxmlhelper.hxx>
+#include <comphelper/documentconstants.hxx>
using namespace rtl;
using namespace std;
@@ -106,6 +107,8 @@ using namespace com::sun::star::packages::zip::ZipConstants;
#define LOGFILE_AUTHOR "mg115289"
+namespace {
+
sal_Bool isLocalFile_Impl( ::rtl::OUString aURL )
{
::rtl::OUString aSystemPath;
@@ -132,6 +135,27 @@ sal_Bool isLocalFile_Impl( ::rtl::OUString aURL )
return ( aSystemPath.getLength() != 0 );
}
+class PostinitializationGuard
+{
+ uno::Reference< io::XInputStream > m_xTempStream;
+
+ ZipPackage& m_rZipPackage;
+
+public:
+ PostinitializationGuard( const uno::Reference< io::XInputStream >& xTempStream,
+ ZipPackage& rZipPackage )
+ : m_xTempStream( xTempStream )
+ , m_rZipPackage( rZipPackage )
+ {}
+
+ virtual ~PostinitializationGuard()
+ {
+ m_rZipPackage.ConnectTo( m_xTempStream );
+ }
+};
+
+}
+
//===========================================================================
class ActiveDataStreamer : public ::cppu::WeakImplHelper1< XActiveDataStreamer >
@@ -174,7 +198,8 @@ class DummyInputStream : public ::cppu::WeakImplHelper1< XInputStream >
//===========================================================================
ZipPackage::ZipPackage (const uno::Reference < XMultiServiceFactory > &xNewFactory)
-: bHasEncryptedEntries ( sal_False )
+: m_aMutexHolder( new SotMutexHolder )
+, bHasEncryptedEntries ( sal_False )
, bUseManifest ( sal_True )
, bForceRecovery ( sal_False )
, m_bMediaTypeFallbackUsed ( sal_False )
@@ -928,21 +953,138 @@ void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut )
}
}
-sal_Bool ZipPackage::writeFileIsTemp()
+void ZipPackage::WriteManifest( ZipOutputStream& aZipOut, const vector< Sequence < PropertyValue > >& aManList )
+{
+ // Write the manifest
+ uno::Reference < XOutputStream > xManOutStream;
+ OUString sManifestWriter( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.packages.manifest.ManifestWriter" ) );
+ uno::Reference < XManifestWriter > xWriter ( xFactory->createInstance( sManifestWriter ), UNO_QUERY );
+ if ( xWriter.is() )
+ {
+ ZipEntry * pEntry = new ZipEntry;
+ ZipPackageBuffer *pBuffer = new ZipPackageBuffer( n_ConstBufferSize );
+ xManOutStream = uno::Reference < XOutputStream > (*pBuffer, UNO_QUERY);
+
+ pEntry->sName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "META-INF/manifest.xml") );
+ pEntry->nMethod = DEFLATED;
+ pEntry->nCrc = pEntry->nSize = pEntry->nCompressedSize = -1;
+ pEntry->nTime = ZipOutputStream::getCurrentDosTime();
+
+ // Convert vector into a Sequence
+ Sequence < Sequence < PropertyValue > > aManifestSequence ( aManList.size() );
+ Sequence < PropertyValue > * pSequence = aManifestSequence.getArray();
+ for (vector < Sequence < PropertyValue > >::const_iterator aIter = aManList.begin(), aEnd = aManList.end();
+ aIter != aEnd;
+ aIter++, pSequence++)
+ *pSequence= (*aIter);
+ xWriter->writeManifestSequence ( xManOutStream, aManifestSequence );
+
+ sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
+ pBuffer->realloc( nBufferLength );
+
+ // the manifest.xml is never encrypted - so pass an empty reference
+ vos::ORef < EncryptionData > xEmpty;
+ aZipOut.putNextEntry( *pEntry, xEmpty );
+ aZipOut.write( pBuffer->getSequence(), 0, nBufferLength );
+ aZipOut.closeEntry();
+ }
+ else
+ {
+ VOS_ENSURE ( 0, "Couldn't get a ManifestWriter!" );
+ IOException aException;
+ throw WrappedTargetException(
+ OUString( RTL_CONSTASCII_USTRINGPARAM ( OSL_LOG_PREFIX "Couldn't get a ManifestWriter!" ) ),
+ static_cast < OWeakObject * > ( this ),
+ makeAny( aException ) );
+ }
+}
+
+void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const vector< Sequence < PropertyValue > >& aManList )
+{
+ const OUString sFullPath ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
+ const OUString sMediaType ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
+
+ ZipEntry* pEntry = new ZipEntry;
+ ZipPackageBuffer *pBuffer = new ZipPackageBuffer( n_ConstBufferSize );
+ uno::Reference< io::XOutputStream > xConTypeOutStream( *pBuffer, UNO_QUERY );
+
+ pEntry->sName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "[Content_Types].xml") );
+ pEntry->nMethod = DEFLATED;
+ pEntry->nCrc = pEntry->nSize = pEntry->nCompressedSize = -1;
+ pEntry->nTime = ZipOutputStream::getCurrentDosTime();
+
+ // Convert vector into a Sequence
+ // TODO/LATER: use Defaulst entries in future
+ uno::Sequence< beans::StringPair > aDefaultsSequence;
+ uno::Sequence< beans::StringPair > aOverridesSequence( aManList.size() );
+ sal_Int32 nSeqLength = 0;
+ for ( vector< uno::Sequence< beans::PropertyValue > >::const_iterator aIter = aManList.begin(),
+ aEnd = aManList.end();
+ aIter != aEnd;
+ aIter++)
+ {
+ ::rtl::OUString aPath;
+ ::rtl::OUString aType;
+ OSL_ENSURE( (*aIter)[PKG_MNFST_MEDIATYPE].Name.equals( sMediaType ) && (*aIter)[PKG_MNFST_FULLPATH].Name.equals( sFullPath ),
+ "The mediatype sequence format is wrong!\n" );
+ (*aIter)[PKG_MNFST_MEDIATYPE].Value >>= aType;
+ if ( aType.getLength() )
+ {
+ // only nonempty type makes sence here
+ nSeqLength++;
+ (*aIter)[PKG_MNFST_FULLPATH].Value >>= aPath;
+ aOverridesSequence[nSeqLength-1].First = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) + aPath;
+ aOverridesSequence[nSeqLength-1].Second = aType;
+ }
+ }
+ aOverridesSequence.realloc( nSeqLength );
+
+ ::comphelper::OFOPXMLHelper::WriteContentSequence(
+ xConTypeOutStream, aDefaultsSequence, aOverridesSequence, xFactory );
+
+ sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
+ pBuffer->realloc( nBufferLength );
+
+ // there is no encryption in this format currently
+ vos::ORef < EncryptionData > xEmpty;
+ aZipOut.putNextEntry( *pEntry, xEmpty );
+ aZipOut.write( pBuffer->getSequence(), 0, nBufferLength );
+ aZipOut.closeEntry();
+}
+
+void ZipPackage::ConnectTo( const uno::Reference< io::XInputStream >& xInStream )
+{
+ xContentSeek.set( xInStream, uno::UNO_QUERY_THROW );
+ xContentStream = xInStream;
+
+ // seek back to the beginning of the temp file so we can read segments from it
+ xContentSeek->seek( 0 );
+ if ( pZipFile )
+ pZipFile->setInputStream( xContentStream );
+ else
+ pZipFile = new ZipFile ( xContentStream, xFactory, sal_False );
+}
+
+uno::Reference< io::XInputStream > ZipPackage::writeTempFile()
{
// In case the target local file does not exist or empty
- // write directly to it otherwize create a temporary file to write to
+ // write directly to it otherwize create a temporary file to write to.
+ // If a temporary file is created it is returned back by the method.
+ // If the data written directly, xComponentStream will be switched here
sal_Bool bUseTemp = sal_True;
- uno::Reference < XOutputStream > xTempOut;
- uno::Reference< XActiveDataStreamer > xSink;
+ uno::Reference < io::XInputStream > xResult;
+ uno::Reference < io::XInputStream > xTempIn;
+
+ uno::Reference < io::XOutputStream > xTempOut;
+ uno::Reference< io::XActiveDataStreamer > xSink;
if ( eMode == e_IMode_URL && !pZipFile && isLocalFile_Impl( sURL ) )
{
xSink = openOriginalForOutput();
if( xSink.is() )
{
- uno::Reference< XStream > xStr = xSink->getStream();
+ uno::Reference< io::XStream > xStr = xSink->getStream();
if( xStr.is() )
{
xTempOut = xStr->getOutputStream();
@@ -963,7 +1105,9 @@ sal_Bool ZipPackage::writeFileIsTemp()
{
// create temporary file
const OUString sServiceName ( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.io.TempFile" ) );
- xTempOut = uno::Reference < XOutputStream > ( xFactory->createInstance ( sServiceName ), UNO_QUERY );
+ uno::Reference < io::XStream > xTempFile( xFactory->createInstance ( sServiceName ), UNO_QUERY_THROW );
+ xTempOut.set( xTempFile->getOutputStream(), UNO_SET_THROW );
+ xTempIn.set( xTempFile->getInputStream(), UNO_SET_THROW );
}
// Hand it to the ZipOutputStream:
@@ -995,7 +1139,7 @@ sal_Bool ZipPackage::writeFileIsTemp()
// Write a magic file with mimetype
WriteMimetypeMagicFile( aZipOut );
}
- if ( m_nFormat == OFOPXML_FORMAT )
+ else if ( m_nFormat == OFOPXML_FORMAT )
{
// Remove the old [Content_Types].xml file as the
// file will be re-generated
@@ -1009,9 +1153,6 @@ sal_Bool ZipPackage::writeFileIsTemp()
// Create a vector to store data for the manifest.xml file
vector < Sequence < PropertyValue > > aManList;
- // Make a reference to the manifest output stream so it persists
- // until the call to ZipOutputStream->finish()
- uno::Reference < XOutputStream > xManOutStream;
const OUString sMediaType ( RTL_CONSTASCII_USTRINGPARAM ( "MediaType" ) );
const OUString sVersion ( RTL_CONSTASCII_USTRINGPARAM ( "Version" ) );
const OUString sFullPath ( RTL_CONSTASCII_USTRINGPARAM ( "FullPath" ) );
@@ -1047,107 +1188,20 @@ sal_Bool ZipPackage::writeFileIsTemp()
if( bUseManifest && m_nFormat == PACKAGE_FORMAT )
{
- // Write the manifest
- OUString sManifestWriter( RTL_CONSTASCII_USTRINGPARAM ( "com.sun.star.packages.manifest.ManifestWriter" ) );
- uno::Reference < XManifestWriter > xWriter ( xFactory->createInstance( sManifestWriter ), UNO_QUERY );
- if ( xWriter.is() )
- {
- ZipEntry * pEntry = new ZipEntry;
- ZipPackageBuffer *pBuffer = new ZipPackageBuffer( n_ConstBufferSize );
- xManOutStream = uno::Reference < XOutputStream > (*pBuffer, UNO_QUERY);
-
- pEntry->sName = OUString( RTL_CONSTASCII_USTRINGPARAM ( "META-INF/manifest.xml") );
- pEntry->nMethod = DEFLATED;
- pEntry->nCrc = pEntry->nSize = pEntry->nCompressedSize = -1;
- pEntry->nTime = ZipOutputStream::getCurrentDosTime();
-
- // Convert vector into a Sequence
- Sequence < Sequence < PropertyValue > > aManifestSequence ( aManList.size() );
- Sequence < PropertyValue > * pSequence = aManifestSequence.getArray();
- for (vector < Sequence < PropertyValue > >::const_iterator aIter = aManList.begin(), aEnd = aManList.end();
- aIter != aEnd;
- aIter++, pSequence++)
- *pSequence= (*aIter);
- xWriter->writeManifestSequence ( xManOutStream, aManifestSequence );
-
- sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
- pBuffer->realloc( nBufferLength );
-
- // the manifest.xml is never encrypted - so pass an empty reference
- vos::ORef < EncryptionData > xEmpty;
- aZipOut.putNextEntry( *pEntry, xEmpty );
- aZipOut.write( pBuffer->getSequence(), 0, nBufferLength );
- aZipOut.closeEntry();
- }
- else
- {
- VOS_ENSURE ( 0, "Couldn't get a ManifestWriter!" );
- IOException aException;
- throw WrappedTargetException(
- OUString( RTL_CONSTASCII_USTRINGPARAM ( OSL_LOG_PREFIX "Couldn't get a ManifestWriter!" ) ),
- static_cast < OWeakObject * > ( this ),
- makeAny( aException ) );
- }
+ WriteManifest( aZipOut, aManList );
}
else if( m_nFormat == OFOPXML_FORMAT )
{
- ZipEntry* pEntry = new ZipEntry;
- ZipPackageBuffer *pBuffer = new ZipPackageBuffer( n_ConstBufferSize );
- uno::Reference< io::XOutputStream > xConTypeOutStream( *pBuffer, UNO_QUERY );
-
- pEntry->sName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( "[Content_Types].xml") );
- pEntry->nMethod = DEFLATED;
- pEntry->nCrc = pEntry->nSize = pEntry->nCompressedSize = -1;
- pEntry->nTime = ZipOutputStream::getCurrentDosTime();
-
- // Convert vector into a Sequence
- // TODO/LATER: use Defaulst entries in future
- uno::Sequence< beans::StringPair > aDefaultsSequence;
- uno::Sequence< beans::StringPair > aOverridesSequence( aManList.size() );
- sal_Int32 nSeqLength = 0;
- for ( vector< uno::Sequence< beans::PropertyValue > >::const_iterator aIter = aManList.begin(),
- aEnd = aManList.end();
- aIter != aEnd;
- aIter++)
- {
- ::rtl::OUString aPath;
- ::rtl::OUString aType;
- OSL_ENSURE( (*aIter)[PKG_MNFST_MEDIATYPE].Name.equals( sMediaType ) && (*aIter)[PKG_MNFST_FULLPATH].Name.equals( sFullPath ),
- "The mediatype sequence format is wrong!\n" );
- (*aIter)[PKG_MNFST_MEDIATYPE].Value >>= aType;
- if ( aType.getLength() )
- {
- // only nonempty type makes sence here
- nSeqLength++;
- (*aIter)[PKG_MNFST_FULLPATH].Value >>= aPath;
- aOverridesSequence[nSeqLength-1].First = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "/" ) ) + aPath;
- aOverridesSequence[nSeqLength-1].Second = aType;
- }
- }
- aOverridesSequence.realloc( nSeqLength );
-
- ::comphelper::OFOPXMLHelper::WriteContentSequence(
- xConTypeOutStream, aDefaultsSequence, aOverridesSequence, xFactory );
-
- sal_Int32 nBufferLength = static_cast < sal_Int32 > ( pBuffer->getPosition() );
- pBuffer->realloc( nBufferLength );
-
- // there is no encryption in this format currently
- vos::ORef < EncryptionData > xEmpty;
- aZipOut.putNextEntry( *pEntry, xEmpty );
- aZipOut.write( pBuffer->getSequence(), 0, nBufferLength );
- aZipOut.closeEntry();
+ WriteContentTypes( aZipOut, aManList );
}
aZipOut.finish();
- // Update our References to point to the new temp file
if( bUseTemp )
- {
- xContentStream = uno::Reference < XInputStream > ( xTempOut, UNO_QUERY_THROW );
- xContentSeek = uno::Reference < XSeekable > ( xTempOut, UNO_QUERY_THROW );
- }
- else
+ xResult = xTempIn;
+
+ // Update our References to point to the new temp file
+ if( !bUseTemp )
{
// the case when the original contents were written directly
xTempOut->flush();
@@ -1158,14 +1212,15 @@ sal_Bool ZipPackage::writeFileIsTemp()
if ( asyncOutputMonitor.is() )
asyncOutputMonitor->waitForCompletion();
+ // no need to postpone switching to the new stream since the target was written directly
+ uno::Reference< io::XInputStream > xNewStream;
if ( eMode == e_IMode_URL )
- xContentStream = xSink->getStream()->getInputStream();
- else if ( eMode == e_IMode_XStream )
- xContentStream = xStream->getInputStream();
+ xNewStream = xSink->getStream()->getInputStream();
+ else if ( eMode == e_IMode_XStream && xStream.is() )
+ xNewStream = xStream->getInputStream();
- xContentSeek = uno::Reference < XSeekable > ( xContentStream, UNO_QUERY_THROW );
-
- OSL_ENSURE( xContentStream.is() && xContentSeek.is(), "XSeekable interface is required!" );
+ if ( xNewStream.is() )
+ ConnectTo( xNewStream );
}
}
catch ( uno::Exception& )
@@ -1197,14 +1252,7 @@ sal_Bool ZipPackage::writeFileIsTemp()
}
}
- // seek back to the beginning of the temp file so we can read segments from it
- xContentSeek->seek ( 0 );
- if ( pZipFile )
- pZipFile->setInputStream ( xContentStream );
- else
- pZipFile = new ZipFile ( xContentStream, xFactory, sal_False );
-
- return bUseTemp;
+ return xResult;
}
uno::Reference< XActiveDataStreamer > ZipPackage::openOriginalForOutput()
@@ -1259,9 +1307,12 @@ uno::Reference< XActiveDataStreamer > ZipPackage::openOriginalForOutput()
}
// XChangesBatch
-void SAL_CALL ZipPackage::commitChanges( )
+void SAL_CALL ZipPackage::commitChanges()
throw(WrappedTargetException, RuntimeException)
{
+ // lock the component for the time of commiting
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
+
if ( eMode == e_IMode_XInputStream )
{
IOException aException;
@@ -1269,13 +1320,19 @@ void SAL_CALL ZipPackage::commitChanges( )
static_cast < OWeakObject * > ( this ), makeAny ( aException ) );
}
- RTL_LOGFILE_TRACE_AUTHOR ( "package", LOGFILE_AUTHOR, "{ ZipPackage::commitChanges" );
- // First we write the entire package to a temporary file. After writeTempFile,
- // xContentSeek and xContentStream will reference the new temporary file.
- // Exception - empty or nonexistent local file that is written directly
+ RTL_LOGFILE_TRACE_AUTHOR ( "package", LOGFILE_AUTHOR, "{ ZipPackage::commitChanges" );
+
+ // first the writeTempFile is called, if it returns a stream the stream should be written to the target
+ // if no stream was returned, the file was written directly, nothing should be done
- if ( writeFileIsTemp() )
+ uno::Reference< io::XInputStream > xTempInStream = writeTempFile();
+ if ( xTempInStream.is() )
{
+ uno::Reference< io::XSeekable > xTempSeek( xTempInStream, uno::UNO_QUERY_THROW );
+
+ // switch to the new temporary stream only after the transfer
+ PostinitializationGuard( xTempInStream, *this );
+
if ( eMode == e_IMode_XStream )
{
// First truncate our output stream
@@ -1284,7 +1341,7 @@ void SAL_CALL ZipPackage::commitChanges( )
// preparation for copy step
try
{
- xContentSeek->seek( 0 );
+ xTempSeek->seek( 0 );
xOutputStream = xStream->getOutputStream();
uno::Reference < XTruncate > xTruncate ( xOutputStream, UNO_QUERY );
@@ -1303,7 +1360,7 @@ void SAL_CALL ZipPackage::commitChanges( )
try
{
// then copy the contents of the tempfile to our output stream
- ::comphelper::OStorageHelper::CopyInputToOutput( xContentStream, xOutputStream );
+ ::comphelper::OStorageHelper::CopyInputToOutput( xTempInStream, xOutputStream );
xOutputStream->flush();
uno::Reference< io::XAsyncOutputMonitor > asyncOutputMonitor(
xOutputStream, uno::UNO_QUERY);
@@ -1316,7 +1373,7 @@ void SAL_CALL ZipPackage::commitChanges( )
// if anything goes wrong in this block the target file becomes corrupted
// so an exception should be thrown as a notification about it
// and the package must disconnect from the stream
- DisconnectFromTargetAndThrowException_Impl( xContentStream );
+ DisconnectFromTargetAndThrowException_Impl( xTempInStream );
}
}
else if ( eMode == e_IMode_URL )
@@ -1349,7 +1406,7 @@ void SAL_CALL ZipPackage::commitChanges( )
{
try
{
- ::comphelper::OStorageHelper::CopyInputToOutput( xContentStream, aOrigFileStream );
+ ::comphelper::OStorageHelper::CopyInputToOutput( xTempInStream, aOrigFileStream );
aOrigFileStream->closeOutput();
}
catch( uno::Exception& )
@@ -1369,7 +1426,7 @@ void SAL_CALL ZipPackage::commitChanges( )
{
try
{
- uno::Reference < XPropertySet > xPropSet ( xContentStream, UNO_QUERY );
+ uno::Reference < XPropertySet > xPropSet ( xTempInStream, UNO_QUERY );
OSL_ENSURE( xPropSet.is(), "This is a temporary file that must implement XPropertySet!\n" );
if ( !xPropSet.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -1396,7 +1453,7 @@ void SAL_CALL ZipPackage::commitChanges( )
catch (::com::sun::star::uno::Exception& r)
{
if ( bCanBeCorrupted )
- DisconnectFromTargetAndThrowException_Impl( xContentStream );
+ DisconnectFromTargetAndThrowException_Impl( xTempInStream );
throw WrappedTargetException(
OUString( RTL_CONSTASCII_USTRINGPARAM ( OSL_LOG_PREFIX "This package may be read only!" ) ),
@@ -1410,7 +1467,7 @@ void SAL_CALL ZipPackage::commitChanges( )
// after successful storing it can be set to false
m_bMediaTypeFallbackUsed = sal_False;
- RTL_LOGFILE_TRACE_AUTHOR ( "package", LOGFILE_AUTHOR, "} ZipPackage::commitChanges" );
+ RTL_LOGFILE_TRACE_AUTHOR ( "package", LOGFILE_AUTHOR, "} ZipPackage::commitChanges" );
}
void ZipPackage::DisconnectFromTargetAndThrowException_Impl( const uno::Reference< io::XInputStream >& xTempStream )
@@ -1423,7 +1480,7 @@ void ZipPackage::DisconnectFromTargetAndThrowException_Impl( const uno::Referenc
::rtl::OUString aTempURL;
try {
- uno::Reference< beans::XPropertySet > xTempFile( xContentStream, uno::UNO_QUERY_THROW );
+ uno::Reference< beans::XPropertySet > xTempFile( xTempStream, uno::UNO_QUERY_THROW );
uno::Any aUrl = xTempFile->getPropertyValue( ::rtl::OUString::createFromAscii( "Uri" ) );
aUrl >>= aTempURL;
xTempFile->setPropertyValue( ::rtl::OUString::createFromAscii( "RemoveFile" ),
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index b95a20a..c82759b 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -229,10 +229,8 @@ Reference< io::XInputStream > ZipPackageStream::TryToGetRawFromDataStream( sal_B
if ( !xNewPackStream.is() )
throw RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- if ( !m_aSharedMutexRef.Is() )
- m_aSharedMutexRef = new SotMutexHolder();
xNewPackStream->setDataStream( static_cast< io::XInputStream* >(
- new WrapStreamForShare( GetOwnSeekStream(), m_aSharedMutexRef ) ) );
+ new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() ) ) );
Reference< XPropertySet > xNewPSProps( xNewPackStream, UNO_QUERY );
if ( !xNewPSProps.is() )
@@ -385,7 +383,6 @@ void SAL_CALL ZipPackageStream::setInputStream( const Reference< io::XInputStrea
throw(RuntimeException)
{
// if seekable access is required the wrapping will be done on demand
- m_aSharedMutexRef = new SotMutexHolder();
xStream = aStream;
m_bHasSeekable = sal_False;
SetPackageMember ( sal_False );
@@ -403,13 +400,11 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawData()
{
if ( !xEncryptionData.isEmpty() && !bHaveOwnKey )
xEncryptionData->aKey = rZipPackage.getEncryptionKey();
- return rZipPackage.getZipFile().getRawData( aEntry, xEncryptionData, bIsEncrypted );
+ return rZipPackage.getZipFile().getRawData( aEntry, xEncryptionData, bIsEncrypted, rZipPackage.GetSharedMutexRef() );
}
else if ( GetOwnSeekStream().is() )
{
- if ( !m_aSharedMutexRef.Is() )
- m_aSharedMutexRef = new SotMutexHolder();
- return new WrapStreamForShare( GetOwnSeekStream(), m_aSharedMutexRef );
+ return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
}
else
return Reference < io::XInputStream > ();
@@ -436,13 +431,11 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getInputStream( )
{
if ( !xEncryptionData.isEmpty() && !bHaveOwnKey )
xEncryptionData->aKey = rZipPackage.getEncryptionKey();
- return rZipPackage.getZipFile().getInputStream( aEntry, xEncryptionData, bIsEncrypted );
+ return rZipPackage.getZipFile().getInputStream( aEntry, xEncryptionData, bIsEncrypted, rZipPackage.GetSharedMutexRef() );
}
else if ( GetOwnSeekStream().is() )
{
- if ( !m_aSharedMutexRef.Is() )
- m_aSharedMutexRef = new SotMutexHolder();
- return new WrapStreamForShare( GetOwnSeekStream(), m_aSharedMutexRef );
+ return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
}
else
return Reference < io::XInputStream > ();
@@ -482,15 +475,13 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getDataStream()
if ( !xEncryptionData.isEmpty() && !bHaveOwnKey )
xEncryptionData->aKey = rZipPackage.getEncryptionKey();
- return rZipPackage.getZipFile().getDataStream( aEntry, xEncryptionData, bIsEncrypted );
+ return rZipPackage.getZipFile().getDataStream( aEntry, xEncryptionData, bIsEncrypted, rZipPackage.GetSharedMutexRef() );
}
else if ( m_nStreamMode == PACKAGE_STREAM_RAW )
return ZipFile::StaticGetDataFromRawStream( GetOwnSeekStream(), xEncryptionData );
else if ( GetOwnSeekStream().is() )
{
- if ( !m_aSharedMutexRef.Is() )
- m_aSharedMutexRef = new SotMutexHolder();
- return new WrapStreamForShare( GetOwnSeekStream(), m_aSharedMutexRef );
+ return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
}
else
return uno::Reference< io::XInputStream >();
@@ -515,15 +506,13 @@ Reference< io::XInputStream > SAL_CALL ZipPackageStream::getRawStream()
if ( !bIsEncrypted || xEncryptionData.isEmpty() )
throw packages::NoEncryptionException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
- return rZipPackage.getZipFile().getWrappedRawStream( aEntry, xEncryptionData, sMediaType );
+ return rZipPackage.getZipFile().getWrappedRawStream( aEntry, xEncryptionData, sMediaType, rZipPackage.GetSharedMutexRef() );
}
else if ( GetOwnSeekStream().is() )
{
if ( m_nStreamMode == PACKAGE_STREAM_RAW )
{
- if ( !m_aSharedMutexRef.Is() )
- m_aSharedMutexRef = new SotMutexHolder();
- return new WrapStreamForShare( GetOwnSeekStream(), m_aSharedMutexRef );
+ return new WrapStreamForShare( GetOwnSeekStream(), rZipPackage.GetSharedMutexRef() );
}
else if ( m_nStreamMode == PACKAGE_STREAM_DATA && bToBeEncrypted )
return TryToGetRawFromDataStream( sal_True );
@@ -568,7 +557,6 @@ void SAL_CALL ZipPackageStream::setRawStream( const Reference< io::XInputStream
// the raw stream MUST have seekable access
m_bHasSeekable = sal_True;
- m_aSharedMutexRef = new SotMutexHolder();
SetPackageMember ( sal_False );
aEntry.nTime = -1;
m_nStreamMode = PACKAGE_STREAM_RAW;
@@ -589,7 +577,7 @@ uno::Reference< io::XInputStream > SAL_CALL ZipPackageStream::getPlainRawStream(
if (IsPackageMember())
{
- return rZipPackage.getZipFile().getRawData( aEntry, xEncryptionData, bIsEncrypted );
+ return rZipPackage.getZipFile().getRawData( aEntry, xEncryptionData, bIsEncrypted, rZipPackage.GetSharedMutexRef() );
}
else if ( GetOwnSeekStream().is() )
{
diff --git a/package/source/zippackage/ZipPackageStream.hxx b/package/source/zippackage/ZipPackageStream.hxx
index 9080a9e..94861e4 100644
--- a/package/source/zippackage/ZipPackageStream.hxx
+++ b/package/source/zippackage/ZipPackageStream.hxx
@@ -70,8 +70,6 @@ protected:
sal_uInt32 m_nMagicalHackPos;
sal_uInt32 m_nMagicalHackSize;
- SotMutexHolderRef m_aSharedMutexRef;
-
sal_Bool m_bHasSeekable;
sal_Bool m_bCompressedIsSetFromOutside;
diff --git a/package/source/zippackage/zipfileaccess.cxx b/package/source/zippackage/zipfileaccess.cxx
index c4f04cb..26a01c7 100644
--- a/package/source/zippackage/zipfileaccess.cxx
+++ b/package/source/zippackage/zipfileaccess.cxx
@@ -53,7 +53,8 @@ using namespace ::com::sun::star;
// ----------------------------------------------------------------
OZipFileAccess::OZipFileAccess( const uno::Reference< lang::XMultiServiceFactory >& xFactory )
-: m_xFactory( xFactory )
+: m_aMutexHolder( new SotMutexHolder )
+, m_xFactory( xFactory )
, m_pZipFile( NULL )
, m_pListenersContainer( NULL )
, m_bDisposed( sal_False )
@@ -66,7 +67,7 @@ OZipFileAccess::OZipFileAccess( const uno::Reference< lang::XMultiServiceFactory
OZipFileAccess::~OZipFileAccess()
{
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( !m_bDisposed )
{
try {
@@ -179,7 +180,7 @@ void SAL_CALL OZipFileAccess::initialize( const uno::Sequence< uno::Any >& aArgu
throw ( uno::Exception,
uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -242,7 +243,7 @@ uno::Any SAL_CALL OZipFileAccess::getByName( const ::rtl::OUString& aName )
lang::WrappedTargetException,
uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -256,7 +257,8 @@ uno::Any SAL_CALL OZipFileAccess::getByName( const ::rtl::OUString& aName )
uno::Reference< io::XInputStream > xEntryStream( m_pZipFile->getDataStream( (*aIter).second,
new EncryptionData(),
- sal_False ) );
+ sal_False,
+ m_aMutexHolder ) );
if ( !xEntryStream.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -268,7 +270,7 @@ uno::Any SAL_CALL OZipFileAccess::getByName( const ::rtl::OUString& aName )
uno::Sequence< ::rtl::OUString > SAL_CALL OZipFileAccess::getElementNames()
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -303,7 +305,7 @@ uno::Sequence< ::rtl::OUString > SAL_CALL OZipFileAccess::getElementNames()
sal_Bool SAL_CALL OZipFileAccess::hasByName( const ::rtl::OUString& aName )
throw (uno::RuntimeException)
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -320,7 +322,7 @@ sal_Bool SAL_CALL OZipFileAccess::hasByName( const ::rtl::OUString& aName )
uno::Type SAL_CALL OZipFileAccess::getElementType()
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -335,7 +337,7 @@ uno::Type SAL_CALL OZipFileAccess::getElementType()
sal_Bool SAL_CALL OZipFileAccess::hasElements()
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -353,7 +355,7 @@ uno::Reference< io::XInputStream > SAL_CALL OZipFileAccess::getStreamByPattern(
io::IOException,
uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -370,7 +372,8 @@ uno::Reference< io::XInputStream > SAL_CALL OZipFileAccess::getStreamByPattern(
{
uno::Reference< io::XInputStream > xEntryStream( m_pZipFile->getDataStream( (*aIter).second,
new EncryptionData(),
- sal_False ) );
+ sal_False,
+ m_aMutexHolder ) );
if ( !xEntryStream.is() )
throw uno::RuntimeException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -386,7 +389,7 @@ uno::Reference< io::XInputStream > SAL_CALL OZipFileAccess::getStreamByPattern(
void SAL_CALL OZipFileAccess::dispose()
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
@@ -418,13 +421,13 @@ void SAL_CALL OZipFileAccess::dispose()
void SAL_CALL OZipFileAccess::addEventListener( const uno::Reference< lang::XEventListener >& xListener )
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
if ( !m_pListenersContainer )
- m_pListenersContainer = new ::cppu::OInterfaceContainerHelper( m_aMutex );
+ m_pListenersContainer = new ::cppu::OInterfaceContainerHelper( m_aMutexHolder->GetMutex() );
m_pListenersContainer->addInterface( xListener );
}
@@ -432,7 +435,7 @@ void SAL_CALL OZipFileAccess::addEventListener( const uno::Reference< lang::XEve
void SAL_CALL OZipFileAccess::removeEventListener( const uno::Reference< lang::XEventListener >& xListener )
throw ( uno::RuntimeException )
{
- ::osl::MutexGuard aGuard( m_aMutex );
+ ::osl::MutexGuard aGuard( m_aMutexHolder->GetMutex() );
if ( m_bDisposed )
throw lang::DisposedException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
commit 601ecee4d6616f6462095e49ffdd8ae68ac6d085
Author: Oliver Bolte <obo at openoffice.org>
Date: Tue Sep 8 04:57:32 2009 +0000
CWS-TOOLING: integrate CWS oj18
2009-08-21 15:08:49 +0200 oj r275263 : wrong check
2009-08-21 08:56:01 +0200 oj r275215 : missing not
2009-08-20 07:27:13 +0200 oj r275164 : use new method from global
2009-08-19 10:22:35 +0200 oj r275138 : call GetLocale instead of pLocale
2009-08-18 10:39:32 +0200 oj r275082 : missing header include
2009-08-18 10:09:44 +0200 oj r275081 : new methods at global
2009-08-18 10:09:00 +0200 oj r275080 : unused var
2009-08-18 08:59:04 +0200 oj r275078 : move files from classes to xml
2009-08-17 14:58:16 +0200 oj r275056 : CWS-TOOLING: rebase CWS oj18 to trunk at 275001 (milestone: DEV300:m55)
2009-08-17 13:29:44 +0200 oj r275047 : compile error
2009-08-17 13:27:47 +0200 oj r275045 : compile error
2009-08-17 11:44:54 +0200 oj r275040 : add dep
2009-07-22 14:26:05 +0200 oj r274240 : move unused services into fwl
2009-07-22 14:25:35 +0200 oj r274239 : move unused services into fwl
2009-07-22 13:47:45 +0200 oj r274233 : remove some unused code
2009-07-22 09:06:20 +0200 oj r274219 : export dbtoolsclient dbcharsethelper for sc
2009-07-22 08:48:58 +0200 oj r274218 : create NumberFormatter on demand
2009-07-22 08:39:23 +0200 oj r274217 : change char to sal_Char
2009-07-22 07:33:34 +0200 oj r274214 : export dbtoolsclient dbcharsethelper for sc
2009-07-22 07:30:04 +0200 oj r274213 : late init of numberformatter and breakiterator
2009-07-22 07:28:55 +0200 oj r274212 : export dbtoolsclient dbcharsethelper for sc
2009-07-21 13:43:28 +0200 oj r274196 : check if quick start is enbaled
2009-07-21 13:40:09 +0200 oj r274195 : check config entry for UiEventsLogger
2009-07-21 13:37:40 +0200 oj r274194 : code refactoring, remove of duplicate code and some late inits and removale of not needed files
2009-07-21 13:35:38 +0200 oj r274193 : code refactoring, remove of duplicate code and some late inits and removale of not needed files
2009-07-21 13:33:41 +0200 oj r274192 : doc meta data will now be created on demand
2009-07-21 13:13:40 +0200 oj r274187 : load ldap functions on demand
2009-07-21 13:03:17 +0200 oj r274183 : late init of TransliterationImpl
2009-07-21 12:36:10 +0200 oj r274180 : late init of charClass
diff --git a/extensions/source/config/ldap/ldapaccess.cxx b/extensions/source/config/ldap/ldapaccess.cxx
index 6a28c3d..1c5e3f2 100644
--- a/extensions/source/config/ldap/ldapaccess.cxx
+++ b/extensions/source/config/ldap/ldapaccess.cxx
@@ -40,14 +40,30 @@
namespace extensions { namespace config { namespace ldap {
-
+oslModule LdapConnection::s_Ldap_Module = NULL;
+t_ldap_unbind_s LdapConnection::s_p_unbind_s = NULL;
+t_ldap_simple_bind_s LdapConnection::s_p_simple_bind_s = NULL;
+t_ldap_set_option LdapConnection::s_p_set_option = NULL;
+t_ldap_err2string LdapConnection::s_p_err2string = NULL;
+t_ldap_init LdapConnection::s_p_init = NULL;
+t_ldap_msgfree LdapConnection::s_p_msgfree = NULL;
+t_ldap_get_dn LdapConnection::s_p_get_dn = NULL;
+t_ldap_first_entry LdapConnection::s_p_first_entry = NULL;
+t_ldap_search_s LdapConnection::s_p_search_s = NULL;
+t_ldap_value_free LdapConnection::s_p_value_free = NULL;
+t_ldap_get_values LdapConnection::s_p_get_values = NULL;
+t_ldap_memfree LdapConnection::s_p_memfree = NULL;
//------------------------------------------------------------------------------
typedef int LdapErrCode;
//------------------------------------------------------------------------------
struct LdapMessageHolder
{
LdapMessageHolder() : msg(0) {}
- ~LdapMessageHolder() { if (msg) ldap_msgfree(msg); }
+ ~LdapMessageHolder()
+ {
+ if (msg)
+ (*LdapConnection::s_p_msgfree)(msg);
+ }
LDAPMessage * msg;
@@ -66,7 +82,7 @@ void LdapConnection::disconnect()
{
if (mConnection != NULL)
{
- ldap_unbind_s(mConnection) ;
+ (*s_p_unbind_s)(mConnection) ;
mConnection = NULL;
}
}
@@ -85,11 +101,11 @@ static void checkLdapReturnCode(const sal_Char *aOperation,
{
message.appendAscii(aOperation).appendAscii(": ") ;
}
- message.appendAscii(ldap_err2string(aRetCode)).appendAscii(" (") ;
+ message.appendAscii((*LdapConnection::s_p_err2string)(aRetCode)).appendAscii(" (") ;
sal_Char *stub = NULL ;
#ifndef LDAP_OPT_SIZELIMIT // for use with OpenLDAP
- ldap_get_lderrno(aConnection, NULL, &stub) ;
+ (*s_p_get_lderrno)(aConnection, NULL, &stub) ;
#endif
if (stub != NULL)
{
@@ -99,7 +115,7 @@ static void checkLdapReturnCode(const sal_Char *aOperation,
// string itself. At any rate freeing it seems to
// cause some undue problems at least on Windows.
// This call is thus disabled for the moment.
- //ldap_memfree(stub) ;
+ //(*s_p_memfree)(stub) ;
}
else { message.appendAscii(kNoSpecificMessage) ; }
message.appendAscii(")") ;
@@ -126,20 +142,20 @@ void LdapConnection::connectSimple()
initConnection() ;
// Set Protocol V3
int version = LDAP_VERSION3;
- ldap_set_option(mConnection,
+ (*s_p_set_option)(mConnection,
LDAP_OPT_PROTOCOL_VERSION,
&version);
#ifdef LDAP_X_OPT_CONNECT_TIMEOUT // OpenLDAP doesn't support this and the func
/* timeout is specified in milliseconds -> 4 seconds*/
int timeout = 4000;
- ldap_set_option( mConnection,
+ (*s_p_set_option)( mConnection,
LDAP_X_OPT_CONNECT_TIMEOUT,
&timeout );
#endif
// Do the bind
- LdapErrCode retCode = ldap_simple_bind_s(mConnection,
+ LdapErrCode retCode = (*s_p_simple_bind_s)(mConnection,
mLdapDefinition.mAnonUser ,
mLdapDefinition.mAnonCredentials) ;
@@ -160,7 +176,7 @@ void LdapConnection::initConnection()
if (mLdapDefinition.mPort == 0) mLdapDefinition.mPort = LDAP_PORT;
- mConnection = ldap_init(mLdapDefinition.mServer,
+ mConnection = (*s_p_init)(mLdapDefinition.mServer,
mLdapDefinition.mPort) ;
if (mConnection == NULL)
{
@@ -186,7 +202,7 @@ void LdapConnection::initConnection()
rtl::OString aUserDn =findUserDn( rtl::OUStringToOString(aUser, RTL_TEXTENCODING_ASCII_US));
LdapMessageHolder result;
- LdapErrCode retCode = ldap_search_s(mConnection,
+ LdapErrCode retCode = (*s_p_search_s)(mConnection,
aUserDn,
LDAP_SCOPE_BASE,
"(objectclass=*)",
@@ -228,21 +244,21 @@ void LdapConnection::initConnection()
sal_Char * attributes [2];
attributes[0]= const_cast<sal_Char *>(LDAP_NO_ATTRS);
attributes[1]= NULL;
- LdapErrCode retCode = ldap_search_s(mConnection,
+ LdapErrCode retCode = (*s_p_search_s)(mConnection,
mLdapDefinition.mBaseDN,
LDAP_SCOPE_SUBTREE,
filter.makeStringAndClear(), attributes, 0, &result.msg) ;
checkLdapReturnCode("FindUserDn", retCode,mConnection) ;
rtl::OString userDn ;
- LDAPMessage *entry = ldap_first_entry(mConnection, result.msg) ;
+ LDAPMessage *entry = (*s_p_first_entry)(mConnection, result.msg) ;
if (entry != NULL)
{
- sal_Char *charsDn = ldap_get_dn(mConnection, entry) ;
+ sal_Char *charsDn = (*s_p_get_dn)(mConnection, entry) ;
userDn = charsDn ;
- ldap_memfree(charsDn) ;
+ (*s_p_memfree)(charsDn) ;
}
else
{
@@ -264,7 +280,7 @@ rtl::OString LdapConnection::getSingleAttribute(
attributes [0] = aAttribute ;
attributes [1] = 0 ;
LdapMessageHolder result ;
- LdapErrCode retCode = ldap_search_s(mConnection,
+ LdapErrCode retCode = (*s_p_search_s)(mConnection,
aDn,
LDAP_SCOPE_BASE,
"(objectclass=*)",
@@ -277,22 +293,57 @@ rtl::OString LdapConnection::getSingleAttribute(
return value ;
}
checkLdapReturnCode("GetSingleAttribute", retCode, mConnection) ;
- LDAPMessage *entry = ldap_first_entry(mConnection, result.msg) ;
+ LDAPMessage *entry = (*s_p_first_entry)(mConnection, result.msg) ;
if (entry != NULL)
{
- sal_Char **values = ldap_get_values(mConnection, entry,
+ sal_Char **values = (*s_p_get_values)(mConnection, entry,
aAttribute) ;
if (values != NULL)
{
if (*values != NULL) { value = *values ; }
- ldap_value_free(values) ;
+ (*s_p_value_free)(values) ;
}
}
return value ;
}
+extern "C" { static void SAL_CALL thisModule() {} }
+void LdapConnection::loadModule()
+{
+ if ( !s_Ldap_Module )
+ {
+#if defined(WIN) || defined(WNT)
+ const ::rtl::OUString sModuleName(RTL_CONSTASCII_USTRINGPARAM("nsldap32v50.dll"));
+#else
+#ifdef WITH_OPENLDAP
+ const ::rtl::OUString sModuleName(RTL_CONSTASCII_USTRINGPARAM("libldap.so"));
+#else
+ const ::rtl::OUString sModuleName(RTL_CONSTASCII_USTRINGPARAM("libldap50.so"));
+#endif
+#endif
+
+ // load the dbtools library
+ s_Ldap_Module = osl_loadModuleRelative(&thisModule, sModuleName.pData, 0);
+ if ( s_Ldap_Module != NULL )
+ {
+ s_p_unbind_s = (t_ldap_unbind_s)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_unbind_s").pData));
+ s_p_simple_bind_s = (t_ldap_simple_bind_s)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_simple_bind_s").pData));
+ s_p_set_option = (t_ldap_set_option)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_set_option").pData));
+ s_p_err2string = (t_ldap_err2string)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_err2string").pData));
+ s_p_init = (t_ldap_init)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_init").pData));
+ s_p_msgfree = (t_ldap_msgfree)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_msgfree").pData));
+ s_p_get_dn = (t_ldap_get_dn)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_get_dn").pData));
+ s_p_first_entry = (t_ldap_first_entry)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_first_entry").pData));
+ s_p_search_s = (t_ldap_search_s)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_search_s").pData));
+ s_p_value_free = (t_ldap_value_free)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_value_free").pData));
+ s_p_get_values = (t_ldap_get_values)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_get_values").pData));
+ s_p_memfree = (t_ldap_memfree)(osl_getFunctionSymbol(s_Ldap_Module, ::rtl::OUString::createFromAscii("ldap_memfree").pData));
+ }
+ }
+}
+
//------------------------------------------------------------------------------
} } } // extensions.config.ldap
diff --git a/extensions/source/config/ldap/ldapaccess.hxx b/extensions/source/config/ldap/ldapaccess.hxx
index ea176fb..9a662f8 100644
--- a/extensions/source/config/ldap/ldapaccess.hxx
+++ b/extensions/source/config/ldap/ldapaccess.hxx
@@ -34,10 +34,9 @@
#include "wrapldapinclude.hxx"
#include <com/sun/star/ldap/LdapGenericException.hpp>
-#ifndef _COM_SUN_STAR_LDAP_LDAP_CONNECTIONEXCEPTION_HPP_
#include <com/sun/star/ldap/LdapConnectionException.hpp>
-#endif // _COM_SUN_STAR_LDAP_LDAP_CONNECTIONEXCEPTION_HPP_
#include <com/sun/star/lang/IllegalArgumentException.hpp>
+#include <osl/module.h>
namespace extensions { namespace config { namespace ldap {
@@ -50,6 +49,18 @@ namespace ldap = css::ldap ;
struct LdapUserProfile;
class LdapUserProfileMap;
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_unbind_s)( LDAP *ld );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_simple_bind_s)( LDAP *ld, const char *who, const char *passwd );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_set_option)( LDAP *ld, int option, const void *optdata );
+typedef LDAP_API(char *) (LDAP_CALL *t_ldap_err2string)( int err );
+typedef LDAP_API(LDAP *) (LDAP_CALL *t_ldap_init)( const char *defhost, int defport );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_msgfree)( LDAPMessage *lm );
+typedef LDAP_API(char *) (LDAP_CALL *t_ldap_get_dn)( LDAP *ld, LDAPMessage *entry );
+typedef LDAP_API(LDAPMessage *) (LDAP_CALL *t_ldap_first_entry)( LDAP *ld, LDAPMessage *chain );
+typedef LDAP_API(int) (LDAP_CALL *t_ldap_search_s)( LDAP *ld, const char *base, int scope, const char *filter, char **attrs, int attrsonly, LDAPMessage **res );
+typedef LDAP_API(void) (LDAP_CALL *t_ldap_value_free)( char **vals );
+typedef LDAP_API(char **) (LDAP_CALL *t_ldap_get_values)( LDAP *ld, LDAPMessage *entry, const char *target );
+typedef LDAP_API(void) (LDAP_CALL *t_ldap_memfree)( void *p );
//------------------------------------------------------------------------------
/** Struct containing the information on LDAP connection */
struct LdapDefinition
@@ -75,6 +86,7 @@ struct LdapDefinition
/** Class encapulating all LDAP functionality */
class LdapConnection
{
+ friend struct LdapMessageHolder;
public:
/** Default constructor */
@@ -124,6 +136,12 @@ public:
throw (lang::IllegalArgumentException,
ldap::LdapConnectionException,
ldap::LdapGenericException);
+
+ void loadModule();
+
+ static t_ldap_err2string s_p_err2string;
+ static t_ldap_value_free s_p_value_free;
+ static t_ldap_get_values s_p_get_values;
private:
void initConnection()
@@ -142,6 +160,19 @@ private:
/** LDAP connection object */
LDAP* mConnection ;
LdapDefinition mLdapDefinition;
+
+ static oslModule s_Ldap_Module;
+ static t_ldap_unbind_s s_p_unbind_s;
+ static t_ldap_simple_bind_s s_p_simple_bind_s;
+ static t_ldap_set_option s_p_set_option;
+ static t_ldap_init s_p_init;
+ static t_ldap_msgfree s_p_msgfree;
+ static t_ldap_get_dn s_p_get_dn;
+ static t_ldap_first_entry s_p_first_entry;
+ static t_ldap_search_s s_p_search_s;
+
+ static t_ldap_memfree s_p_memfree;
+
} ;
//------------------------------------------------------------------------------
}} }
diff --git a/extensions/source/config/ldap/ldapuserprof.cxx b/extensions/source/config/ldap/ldapuserprof.cxx
index 22d7c6b..881b921 100644
--- a/extensions/source/config/ldap/ldapuserprof.cxx
+++ b/extensions/source/config/ldap/ldapuserprof.cxx
@@ -31,7 +31,7 @@
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_extensions.hxx"
#include "ldapuserprof.hxx"
-
+#include "ldapaccess.hxx"
namespace extensions { namespace config { namespace ldap {
//==============================================================================
@@ -127,14 +127,14 @@ void LdapUserProfileMap::ldapToUserProfile(LDAP *aConnection,
for (sal_uInt32 j = 0 ;
j < mMapping [i].mLdapAttributes.size() ; ++ j)
{
- values = ldap_get_values(aConnection, aEntry,
+ values = (*LdapConnection::s_p_get_values)(aConnection, aEntry,
mMapping [i].mLdapAttributes [j]) ;
if (values != NULL)
{
aProfile.mProfile[i].mValue = rtl::OStringToOUString(
*values, RTL_TEXTENCODING_UTF8);
- ldap_value_free(values);
+ (*LdapConnection::s_p_value_free)(values);
break;
}
}
diff --git a/extensions/source/config/ldap/ldapuserprofilebe.cxx b/extensions/source/config/ldap/ldapuserprofilebe.cxx
index 4b7430d..6e1eebb 100644
--- a/extensions/source/config/ldap/ldapuserprofilebe.cxx
+++ b/extensions/source/config/ldap/ldapuserprofilebe.cxx
@@ -112,27 +112,30 @@ LdapUserProfileBe::LdapUserProfileBe( const uno::Reference<uno::XComponentContex
OSL_ENSURE(!bReentrantCall, "configuration: Ldap Backend constructor called reentrantly - probably a registration error.");
if (!bReentrantCall)
- try
{
- bReentrantCall = true ;
- if (! readLdapConfiguration(aDefinition) )
+ try
{
- throw backend::BackendSetupException(
- rtl::OUString::createFromAscii("LdapUserProfileBe- LDAP not configured"),
- NULL, uno::Any());
+ bReentrantCall = true ;
+ if (! readLdapConfiguration(aDefinition) )
+ {
+ throw backend::BackendSetupException(
+ rtl::OUString::createFromAscii("LdapUserProfileBe- LDAP not configured"),
+ NULL, uno::Any());
+ }
+
+ bReentrantCall = false ;
+ }
+ catch (uno::Exception&)
+ {
+ bReentrantCall = false;
+ throw;
}
-
- bReentrantCall = false ;
- }
- catch (uno::Exception&)
- {
- bReentrantCall = false;
- throw;
}
}
try
{
+ mLdapSource->mConnection.loadModule();
mLdapSource->mConnection.connectSimple(aDefinition);
//Set the UserDN
mUserDN = mLdapSource->mConnection.findUserDn(
diff --git a/extensions/source/config/ldap/makefile.mk b/extensions/source/config/ldap/makefile.mk
index acd47ab..5ff3da4 100644
--- a/extensions/source/config/ldap/makefile.mk
+++ b/extensions/source/config/ldap/makefile.mk
@@ -82,7 +82,6 @@ SHL1DEF=$(MISC)$/$(SHL1TARGET).def
SHL1LIBS=$(LIB1TARGET)
SHL1IMPLIB=i$(SHL1TARGET)
SHL1STDLIBS= \
- $(LDAPSDKLIB) \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(SALHELPERLIB) \
More information about the ooo-build-commit
mailing list