summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/mozab/mozillasrc
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers/mozab/mozillasrc')
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx806
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx80
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx77
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.cxx450
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.hxx75
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSDeclares.hxx52
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx81
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.cxx404
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.hxx119
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.cxx86
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.hxx57
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNameMapper.cxx142
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNameMapper.hxx83
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx823
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx282
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx635
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx142
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.cxx138
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.hxx66
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/makefile.mk77
20 files changed, 4675 insertions, 0 deletions
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx
new file mode 100644
index 000000000000..ae143d7c4d0f
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx
@@ -0,0 +1,806 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+// Mozilla includes.
+#include <MNSInclude.hxx>
+
+#include "resource/mozab_res.hrc"
+#include "MDatabaseMetaDataHelper.hxx"
+#ifndef _CONNECTIVITY_MAB_CONVERSIONS_HXX_
+#include "MTypeConverter.hxx"
+#endif
+#ifndef CONNECTIVITY_MOZAB_MCONFIGACCESS_HXX
+#include "MConfigAccess.hxx"
+#endif
+#include <connectivity/dbexception.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/sequence.hxx>
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+
+#include <nsIAbDirFactoryService.h>
+#include <MNSInit.hxx>
+#include <MNameMapper.hxx>
+#include "MNSMozabProxy.hxx"
+#include <MNSDeclares.hxx>
+
+static ::osl::Mutex m_aMetaMutex;
+
+#include <osl/diagnose.h>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#include <unotools/processfactory.hxx>
+#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
+
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+
+static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
+static NS_DEFINE_CID(kAbDirFactoryServiceCID, NS_ABDIRFACTORYSERVICE_CID);
+static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
+
+using namespace connectivity::mozab;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace com::sun::star::mozilla;
+using namespace com::sun::star::sdb;
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ static const char * const s_pADDRESSBOOKROOTDIR = "moz-abdirectory://";
+ }
+}
+
+extern sal_Bool MNS_Init(sal_Bool& aProfileExists);
+
+// -------------------------------------------------------------------------
+MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()
+ :m_bProfileExists(sal_False)
+{
+ OSL_TRACE( "IN MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()\n" );
+
+ OSL_TRACE( "\tOUT MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()\n" );
+
+}
+// -------------------------------------------------------------------------
+MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper()
+{
+ m_aTableNames.clear();
+ m_aTableTypes.clear();
+
+ if (m_bProfileExists)
+ {
+ Reference<XMozillaBootstrap> xMozillaBootstrap;
+ Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xFactory.is(), "can't get service factory" );
+
+ Reference<XInterface> xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+ xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY);
+ m_bProfileExists = xMozillaBootstrap->shutdownProfile() > 0;
+ }
+
+ OSL_TRACE( "IN/OUT MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper()\n" );
+}
+
+static nsresult enumSubs(nsISimpleEnumerator * subDirs,nsISupportsArray * array);
+//enum all sub folders
+static nsresult enumSubs(nsIAbDirectory * parentDir,nsISupportsArray * array)
+{
+ nsresult rv = NS_OK ;
+ nsCOMPtr<nsISimpleEnumerator> subDirectories;
+ rv = parentDir->GetChildNodes(getter_AddRefs(subDirectories));
+ if (NS_FAILED(rv)) { return rv; }
+
+ rv = enumSubs(subDirectories,array);
+ return rv;
+}
+
+#include <prmem.h> //need for PR_FREEIF
+static nsresult insertPABDescription()
+{
+ nsresult rv = NS_OK ;
+ // mozilla loads the descriptions of pab and history from a file named addressbook.properties
+ // we never deliver it with OOo,so mozab does not auot load personal addressbook and Collected addresses
+ // If we want to deliver addressbook.properties with OOo,we have to deal with hole mozilla chrome mechanism.
+ // So I insert the descriptiones as user prefes,they will cover the default value.
+
+ //"Personal Address Book" "Collected Addresses" are loaded from officecfg
+ nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCAutoString pabPrefName(NS_LITERAL_CSTRING("ldap_2.servers.pab.description"));
+
+ sal_Bool bSetted=sal_False;
+ char *value = nsnull;
+ if (0 == prefs->CopyCharPref(pabPrefName.get(), &value))
+ {
+ if (!(value == nsnull || value[0] == 0))
+ {
+ bSetted = sal_True;
+ }
+ }
+ PR_FREEIF (value);
+ value=nsnull;
+ if (bSetted == sal_True)
+ {
+ const char* pPabDescription = static_cast< const char* >( getPabDescription( ) );
+ rv = prefs->SetCharPref (pabPrefName.get(), pPabDescription);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
+ nsCAutoString hisPrefName(NS_LITERAL_CSTRING("ldap_2.servers.history.description"));
+
+ bSetted=sal_False;
+ if (0 == prefs->CopyCharPref(hisPrefName.get(), &value))
+ {
+ if (!(value == nsnull || value[0] == 0))
+ {
+ bSetted = sal_True;
+ }
+ }
+ PR_FREEIF (value);
+ value=nsnull;
+ if (bSetted == sal_True)
+ {
+ const char* pHisDescription = static_cast< const char* >( getHisDescription( ) );
+
+ rv = prefs->SetCharPref (hisPrefName.get(), pHisDescription);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+ return rv;
+}
+//
+// nsAbDirectoryDataSource
+//
+#define NS_RDF_CONTRACTID "@mozilla.org/rdf"
+#define NS_RDF_DATASOURCE_CONTRACTID NS_RDF_CONTRACTID "/datasource;1"
+#define NS_RDF_DATASOURCE_CONTRACTID_PREFIX NS_RDF_DATASOURCE_CONTRACTID "?name="
+#define NS_ABDIRECTORYDATASOURCE_CONTRACTID \
+ NS_RDF_DATASOURCE_CONTRACTID_PREFIX "addressdirectory"
+#define database_uri "@mozilla.org/rdf/datasource;1?name=addressdirectory"
+#define NS_ABDIRECTORYDATASOURCE_CID \
+{ /* 0A79186D-F754-11d2-A2DA-001083003D0C */ \
+ 0xa79186d, 0xf754, 0x11d2, \
+ {0xa2, 0xda, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
+}
+
+// -------------------------------------------------------------------------
+// Case where we get a parent uri, and need to list its children.
+static nsresult getSubsFromParent(const rtl::OString& aParent, nsIEnumerator **aSubs)
+{
+
+ if (aSubs == nsnull) { return NS_ERROR_NULL_POINTER ; }
+ *aSubs = nsnull ;
+ nsresult retCode = NS_OK ;
+ nsCOMPtr<nsISupportsArray> array ;
+
+ NS_NewISupportsArray(getter_AddRefs(array)) ;
+
+ retCode = insertPABDescription();
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+
+ nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &retCode)) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsCOMPtr<nsIRDFResource> rdfResource ;
+
+ nsCOMPtr<nsIRDFDataSource> rdfDirectory ;
+
+ rtl::OString dir("rdf:addressdirectory");
+ retCode = rdfService->GetDataSource(dir.getStr(),getter_AddRefs(rdfDirectory)) ;
+
+
+
+ OSL_TRACE("uri: %s\n", aParent.getStr()) ;
+ retCode = rdfService->GetResource(nsDependentCString(aParent.getStr(),aParent.getLength()), getter_AddRefs(rdfResource)) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(rdfResource, &retCode) ;
+ nsCOMPtr<nsISimpleEnumerator> tempEnum ;
+
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ retCode = directory->GetChildNodes(getter_AddRefs(tempEnum)) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+
+ PRBool hasMore = PR_TRUE ;
+ while (NS_SUCCEEDED(tempEnum->HasMoreElements(&hasMore)) && hasMore) {
+ nsCOMPtr<nsIAbDirectory> element ;
+ retCode = tempEnum->GetNext(getter_AddRefs(element)) ;
+ if (NS_SUCCEEDED(retCode))
+ {
+ array->AppendElement(element) ;
+ enumSubs(element,array);
+ }
+ }
+
+ array->Enumerate(aSubs) ;
+ return retCode ;
+}
+
+static nsresult enumSubs(nsISimpleEnumerator * subDirs,nsISupportsArray * array)
+{
+ PRBool hasMore = PR_TRUE ;
+ nsresult rv = NS_OK ;
+ while (NS_SUCCEEDED(subDirs->HasMoreElements(&hasMore)) && hasMore) {
+ nsCOMPtr<nsISupports> newDirSupports ;
+
+ rv = subDirs->GetNext(getter_AddRefs(newDirSupports)) ;
+ NS_ENSURE_SUCCESS(rv, rv);
+ nsCOMPtr<nsIAbDirectory> childDir = do_QueryInterface(newDirSupports, &rv) ;
+ NS_ENSURE_SUCCESS(rv, rv);
+ array->AppendElement(childDir);
+
+ rv = enumSubs(childDir,array);
+ }
+ return rv;
+}
+
+// Case where we get a factory uri and need to have it build the directories.
+static nsresult getSubsFromFactory(const rtl::OString& aFactory, nsIEnumerator **aSubs)
+{
+ if (aSubs == nsnull) { return NS_ERROR_NULL_POINTER ; }
+ *aSubs = nsnull ;
+ nsresult retCode = NS_OK ;
+
+ nsCOMPtr<nsIAbDirFactoryService> dirFactoryService = do_GetService(NS_ABDIRFACTORYSERVICE_CONTRACTID, &retCode);
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsCOMPtr<nsIAbDirFactory> dirFactory ;
+
+ retCode = dirFactoryService->GetDirFactory(aFactory.getStr(), getter_AddRefs(dirFactory)) ;
+ NS_ENSURE_SUCCESS (retCode, retCode) ;
+ nsCOMPtr <nsIAbDirectoryProperties> properties;
+ properties = do_CreateInstance(NS_ABDIRECTORYPROPERTIES_CONTRACTID, &retCode);
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+
+ retCode = properties->SetURI(aFactory.getStr());
+ NS_ENSURE_SUCCESS(retCode,retCode);
+
+ nsCOMPtr<nsISimpleEnumerator> subDirs ;
+ retCode = dirFactory->CreateDirectory(properties, getter_AddRefs(subDirs));
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsCOMPtr<nsISupportsArray> array ;
+
+ NS_NewISupportsArray(getter_AddRefs(array)) ;
+ retCode = enumSubs(subDirs,array);
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ array->Enumerate(aSubs) ;
+ return retCode ;
+}
+
+// Case where the uri itself is the directory we're looking for.
+static nsresult getSubsFromURI(const rtl::OString& aUri, nsIEnumerator **aSubs)
+{
+ if (aSubs == nsnull) { return NS_ERROR_NULL_POINTER ; }
+ *aSubs = nsnull ;
+ nsresult retCode = NS_OK ;
+
+ nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &retCode)) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsCOMPtr<nsIRDFResource> rdfResource ;
+
+ retCode = rdfService->GetResource(nsDependentCString(aUri.getStr(),aUri.getLength()), getter_AddRefs(rdfResource)) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ retCode = rdfService->UnregisterResource(rdfResource) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+
+ nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(rdfResource, &retCode) ;
+
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsAutoString nameAB ;
+
+ nameAB.AssignWithConversion("LDAP Directory") ;
+ directory->SetDirName(nameAB.get()) ;
+ nsCOMPtr<nsISupportsArray> array ;
+
+ NS_NewISupportsArray(getter_AddRefs(array)) ;
+ array->AppendElement(directory) ;
+ array->Enumerate(aSubs) ;
+ return retCode ;
+}
+
+namespace
+{
+ static void lcl_setNoAddressBookFoundError( ErrorDescriptor& _rError, OConnection& _rCon, MozillaProductType _eProductType,
+ sal_Bool bGivenURI )
+ {
+ sal_uInt16 nAddressBookNameRes = 0;
+ if ( !bGivenURI && _eProductType == MozillaProductType_Mozilla)
+ {
+ nAddressBookNameRes = STR_MOZILLA_ADDRESSBOOKS;
+ }
+ else
+ {
+ if ( _eProductType == MozillaProductType_Thunderbird )
+ {
+ nAddressBookNameRes = STR_THUNDERBIRD_ADDRESSBOOKS;
+ }
+ else
+ {
+ if ( _rCon.usesFactory() )
+ {
+ if ( _rCon.isOutlookExpress() )
+ {
+ nAddressBookNameRes = STR_OE_ADDRESSBOOK;
+ }
+ else
+ {
+ nAddressBookNameRes = STR_OUTLOOK_MAPI_ADDRESSBOOK;
+ }
+ }
+ else
+ {
+ OSL_ENSURE( !_rCon.isLDAP(), "lcl_setNoAddressBookFoundError: not to be called for LDAP connections!" );
+ nAddressBookNameRes = STR_MOZILLA_ADDRESSBOOKS;
+ }
+ }
+ }
+ _rError.set( 0, ErrorCondition::AB_ADDRESSBOOK_NOT_FOUND, _rCon.getResources().getResourceString( nAddressBookNameRes ) );
+ }
+}
+
+nsresult getTableStringsProxied(const sal_Char* sAbURI, sal_Int32 *nDirectoryType,MNameMapper *nmap,
+ ::std::vector< ::rtl::OUString >* _rStrings,
+ ::std::vector< ::rtl::OUString >* _rTypes,
+ sal_Int32* pErrorId )
+{
+ if (!sAbURI || !nmap || !_rStrings || !_rTypes || !pErrorId)
+ {
+ return NS_ERROR_NULL_POINTER;
+ }
+ OSL_TRACE("Using URI %s to getTables()\n",sAbURI );
+
+ // Get the mozilla addressbooks from the base directory.
+ nsresult rv = NS_OK;
+ nsCOMPtr<nsIEnumerator> subDirectories;
+
+ switch(*nDirectoryType)
+ {
+ case SDBCAddress::Mozilla:
+ rv = getSubsFromParent(sAbURI, getter_AddRefs(subDirectories)) ;
+ break;
+ case SDBCAddress::Outlook:
+ case SDBCAddress::OutlookExp:
+ rv = getSubsFromFactory(sAbURI, getter_AddRefs(subDirectories)) ;
+ break;
+ case SDBCAddress::LDAP:
+ rv = getSubsFromURI(sAbURI, getter_AddRefs(subDirectories)) ;
+ break;
+ default:
+ rv = getSubsFromParent(sAbURI, getter_AddRefs(subDirectories));
+ }
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // At this point we have a list containing the nsIAbDirectory we need to map as tables
+ rv = subDirectories -> First();
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ PRUnichar *name = nsnull;
+ PRBool bIsMailList = PR_FALSE;
+
+ ::rtl::OUString aTableName;
+ nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv)) ;
+ NS_ENSURE_SUCCESS(rv, rv) ;
+
+ nmap->reset();
+ do {
+ nsCOMPtr<nsIAbDirectory> subDirectory;
+
+ nsCOMPtr<nsISupports> item;
+ rv = subDirectories -> CurrentItem(getter_AddRefs(item));
+ if ( NS_FAILED( rv ) )
+ {
+ *pErrorId = STR_COULD_NOT_RETRIEVE_AB_ENTRY;
+ return NS_ERROR_FAILURE;
+ }
+
+ subDirectory = do_QueryInterface(item, &rv);
+
+ subDirectory -> GetIsMailList(&bIsMailList);
+ // For now we're not interested in mailing lists.
+ rv = subDirectory -> GetDirName(&name);
+ if ( NS_FAILED( rv ) ) {
+ *pErrorId = STR_COULD_NOT_GET_DIRECTORY_NAME;
+ return NS_ERROR_FAILURE;
+ }
+ MTypeConverter::prUnicharToOUString(name, aTableName);
+ OSL_TRACE("TableName = >%s<\n", OUtoCStr( aTableName ) );
+
+ ODatabaseMetaDataResultSet::ORow aRow(3);
+
+ // Insert table into map
+ if ( aTableName.getLength() == 0 )
+ aTableName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AddressBook"));
+
+ OSL_TRACE("TableName = >%s<\n", OUtoCStr( aTableName ) );
+
+ rv = nmap->add( aTableName, subDirectory);
+ nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface(subDirectory, &rv) ;
+ if (!NS_FAILED(rv))
+ rdfService->UnregisterResource(rdfResource);
+
+ if (!NS_FAILED(rv)) //failed means we have added this directory
+ {
+ //map mailing lists as views
+ _rStrings->push_back( aTableName ); // Table name
+ if (!bIsMailList) {
+ ::rtl::OUString aTableType(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TABLE")));
+ _rTypes->push_back( aTableType ); // Table type
+ }
+ else
+ {
+ ::rtl::OUString aTableType(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VIEW")));
+ _rTypes->push_back( aTableType ); // Table type
+ }
+ }
+ rv = subDirectories -> Next();
+ } while ( rv == NS_OK);
+
+ return( NS_OK );
+}
+sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection* _pCon,
+ ::std::vector< ::rtl::OUString >& _rStrings,
+ ::std::vector< ::rtl::OUString >& _rTypes)
+{
+ sal_Bool bGivenURI;
+ ::rtl::OUString sAbURI;
+ ::rtl::OString sAbURIString;
+
+ OSL_TRACE( "IN MDatabaseMetaDataHelper::getTableStrings( 0x%08X, %s)\n", _pCon, _pCon->getForceLoadTables()?"True":"False" );
+
+ ::osl::MutexGuard aGuard( m_aMetaMutex );
+ // Only do the query if we have to - performance degrades otherwise
+ if ( ! _pCon->getForceLoadTables() && m_aTableNames.size() > 0 ) {
+ _rStrings = m_aTableNames;
+ _rTypes = m_aTableTypes;
+ return( sal_True );
+ }
+
+ m_aTableNames.clear();
+ m_aTableTypes.clear();
+
+ sAbURI = _pCon->getMozURI();
+
+ OSL_TRACE("AbURI = %s\n", OUtoCStr( sAbURI ) );
+ if ( sAbURI.getLength() == 0 )
+ bGivenURI = sal_False;
+ else {
+ sAbURIString = ::rtl::OUStringToOString( sAbURI,
+ RTL_TEXTENCODING_ASCII_US);
+ bGivenURI = sal_True;
+ }
+
+ if ( bGivenURI )
+ OSL_TRACE("Using URI %s to getTables()\n", sAbURIString.getStr() );
+ else
+ OSL_TRACE("Using URI of ROOTDIR to getTables()\n");
+
+ // Get the mozilla addressbooks from the base directory.
+ nsresult rv = NS_OK;
+ nsCOMPtr<nsIEnumerator> subDirectories;
+ sal_Int32 nDirectoryType=0;
+ m_ProductType = MozillaProductType_Mozilla;
+ m_ProfileName = _pCon->getMozProfile();
+
+
+ if (_pCon->isThunderbird())
+ {
+ if (!bGivenURI)
+ sAbURIString = s_pADDRESSBOOKROOTDIR;
+ nDirectoryType = SDBCAddress::ThunderBird;
+ m_ProductType = MozillaProductType_Thunderbird;
+ }
+ else if (!bGivenURI)
+ {
+ sAbURIString = s_pADDRESSBOOKROOTDIR;
+ nDirectoryType = SDBCAddress::Mozilla;
+ }
+ else
+ {
+ if (_pCon->usesFactory())
+ {
+ nDirectoryType = SDBCAddress::Outlook;
+ }
+ else
+ {
+ if (_pCon->isLDAP())
+ {
+ nDirectoryType = SDBCAddress::LDAP;
+ }
+ else
+ {
+ sAbURIString = s_pADDRESSBOOKROOTDIR;
+ nDirectoryType = SDBCAddress::Mozilla;
+ }
+ }
+ }
+
+ if ( !_pCon->isLDAP() && !m_bProfileExists )
+ { // no need to boot up a Mozilla profile for an LDAP connection
+ Reference<XMozillaBootstrap> xMozillaBootstrap;
+ Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xFactory.is(), "can't get service factory" );
+ Reference<XInterface> xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+ xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY);
+ m_bProfileExists = sal_False;
+ //If there are no profiles for this product
+ //Or the given profile name does not found
+ //We will reaise a "No Addressbook Directories Exist" error
+ if ( xMozillaBootstrap->getProfileCount(m_ProductType) == 0 ||
+ ( m_ProfileName.getLength() && !(xMozillaBootstrap->getProfilePath(m_ProductType,m_ProfileName).getLength())))
+ m_bProfileExists = sal_False;
+ else
+ if (xMozillaBootstrap->bootupProfile(m_ProductType,m_ProfileName) > 0)
+ m_bProfileExists = sal_True;
+
+ }
+ if ( !m_bProfileExists
+ && !_pCon->isLDAP()
+ && ( ( nDirectoryType == SDBCAddress::Mozilla )
+ || ( nDirectoryType == SDBCAddress::ThunderBird )
+ )
+ )
+ {
+ lcl_setNoAddressBookFoundError( m_aError, *_pCon, m_ProductType, bGivenURI );
+ return sal_False;
+ }
+
+ MNameMapper *nmap = _pCon->getNameMapper();
+ nmap->reset();
+
+ sal_Int32 nErrorResourceId( 0 );
+
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_GET_TABLE_STRINGS;
+ args.argCount = 6;
+ args.arg1 = (void*)sAbURIString.getStr();
+ args.arg2 = (void*)&nDirectoryType;
+ args.arg3 = (void*)nmap;
+ args.arg4 = (void*)&m_aTableNames;
+ args.arg5 = (void*)&m_aTableTypes;
+ args.arg6 = (void*)&nErrorResourceId;
+ rv = xMProxy.StartProxy(&args,m_ProductType,m_ProfileName);
+ m_aError.setResId( static_cast<sal_uInt16>(nErrorResourceId) );
+
+ if (NS_FAILED(rv))
+ {
+ if ( nErrorResourceId == 0 )
+ m_aError.setResId( STR_UNSPECIFIED_ERROR );
+ return sal_False;
+ }
+ OSL_TRACE( "\tOUT MDatabaseMetaDataHelper::getTableStrings()\n" );
+ _rStrings = m_aTableNames;
+ _rTypes = m_aTableTypes;
+
+ _pCon->setForceLoadTables(sal_False);
+ return( sal_True );
+}
+
+sal_Bool MDatabaseMetaDataHelper::getTables( OConnection* _pCon,
+ const ::rtl::OUString& tableNamePattern,
+ const Sequence< ::rtl::OUString >& types,
+ ODatabaseMetaDataResultSet::ORows& _rRows)
+{
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+
+ OSL_TRACE( "IN MDatabaseMetaDataHelper::getTables()\n" );
+ ::osl::MutexGuard aGuard( m_aMetaMutex );
+
+ ODatabaseMetaDataResultSet::ORows().swap(aRows); // this makes real clear where memory is freed as well
+ aRows.clear();
+
+ ::std::vector< ::rtl::OUString > tables;
+ ::std::vector< ::rtl::OUString > tabletypes;
+ ::rtl::OUString matchAny = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));;
+
+ if ( !getTableStrings( _pCon, tables,tabletypes ) )
+ return sal_False;
+
+ for ( size_t i = 0; i < tables.size(); i++ ) {
+ ODatabaseMetaDataResultSet::ORow aRow(3);
+
+ ::rtl::OUString aTableName = tables[i];
+ ::rtl::OUString aTableType = tabletypes[i];
+ OSL_TRACE("TableName = >%s<\n", OUtoCStr( aTableName ) );
+
+
+ // return tables to caller
+ if (match( tableNamePattern, aTableName, '\0' ) &&
+ ( 0 == types.getLength() || //types is null or types include aTableType or types include "%"
+ 0 != ::comphelper::findValue( types, aTableType, sal_True ).getLength() ||
+ 0 != ::comphelper::findValue( types, matchAny, sal_True ).getLength())) {
+ if ( aTableName.getLength() == 0 ) {
+ aTableName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AddressBook"));
+ }
+
+ OSL_TRACE( "TableName = %s ; TableType = %s\n", OUtoCStr(aTableName), OUtoCStr(aTableType) );
+
+ aRow.push_back( new ORowSetValueDecorator( aTableName ) ); // Table name
+ aRow.push_back( new ORowSetValueDecorator( aTableType ) ); // Table type
+ aRow.push_back( ODatabaseMetaDataResultSet::getEmptyValue() ); // Remarks
+ aRows.push_back(aRow);
+ }
+ }
+
+ OSL_TRACE( "\tOUT MDatabaseMetaDataHelper::getTables()\n" );
+ _rRows = aRows;
+ return(sal_True);
+}
+
+
+sal_Bool
+MDatabaseMetaDataHelper::testLDAPConnection( OConnection* _pCon )
+{
+ const sal_Unicode QUERY_CHAR = '?';
+ const sal_Char* MOZ_SCHEMA = "moz-abldapdirectory://";
+ const sal_Char* LDAP_SCHEMA = "ldap://";
+
+ rtl::OString sAbURI;
+ rtl::OUString sAbBindDN;
+ rtl::OUString sAbPassword;
+ sal_Bool useSSL = _pCon->getUseSSL();
+
+ nsresult rv(0);
+
+ sAbURI = OUStringToOString( _pCon->getMozURI(), RTL_TEXTENCODING_ASCII_US );
+ sAbBindDN = _pCon->getBindDN();
+ sAbPassword = _pCon->getPassword();
+
+
+ sal_Int32 pos = sAbURI.indexOf( MOZ_SCHEMA );
+ if ( pos != -1 ) {
+ sAbURI = sAbURI.replaceAt (pos, rtl_str_getLength( MOZ_SCHEMA ), ::rtl::OString(LDAP_SCHEMA) );
+ }
+
+ pos = sAbURI.indexOf( QUERY_CHAR );
+ if ( pos != -1 ) {
+ sal_Int32 len = sAbURI.getLength();
+ sAbURI = sAbURI.replaceAt( pos, len - pos, ::rtl::OString("") );
+ }
+ const sal_Unicode* bindDN=nsnull;
+ if (sAbBindDN.getLength() != 0)
+ {
+ bindDN = sAbBindDN.getStr();
+ }
+
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_TESTLDAP_INIT_LDAP;
+ args.argCount = 4;
+ args.arg1 = (void*)sAbURI.getStr();
+ args.arg2 = (void*)bindDN;
+ args.arg3 = (void*)sAbPassword.getStr();
+ args.arg4 = (void*)&useSSL;
+
+ MNSMozabProxy xMProxy;
+ rv = xMProxy.StartProxy( &args, m_ProductType, ::rtl::OUString() );
+ if ( NS_SUCCEEDED( rv ) ) //Init LDAP,pass OUString() to StarProxy to ignore profile switch
+ {
+ args.funcIndex = ProxiedFunc::FUNC_TESTLDAP_IS_LDAP_CONNECTED;
+ TimeValue timeValue = { 1, 0 }; // 1 * 30 Seconds timeout
+ sal_Int32 times=0;
+ while ( times++ < 30 )
+ {
+ rv = xMProxy.StartProxy( &args, m_ProductType, ::rtl::OUString() );
+ if ( NS_SUCCEEDED( rv ) )
+ // connected successfully
+ break;
+
+ if ( rv == (nsresult)PR_NOT_CONNECTED_ERROR )
+ // connection failed
+ break;
+
+ // not yet decided - continue waiting
+ osl_waitThread( &timeValue );
+ }
+ }
+ m_aError.setResId( STR_COULD_NOT_CONNECT_LDAP );
+ return NS_SUCCEEDED( rv ) ? sal_True : sal_False;
+}
+
+sal_Bool MDatabaseMetaDataHelper::NewAddressBook(OConnection* _pCon,const ::rtl::OUString & aTableName)
+{
+ sal_Bool bIsMozillaAB;
+
+ bIsMozillaAB = !_pCon->usesFactory() && ! _pCon->isLDAP();
+
+ if ( !bIsMozillaAB )
+ {
+ m_aError.setResId( STR_NO_TABLE_CREATION_SUPPORT );
+ return sal_False;
+ }
+ else
+ OSL_TRACE("Create table\n");
+
+ // Get the mozilla addressbooks from the base directory.
+ nsresult rv = NS_OK;
+
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_NEW_ADDRESS_BOOK;
+ args.argCount = 1;
+ args.arg1 = (void*)&aTableName;
+ rv = xMProxy.StartProxy(&args,m_ProductType,m_ProfileName);
+
+ _pCon->setForceLoadTables(sal_True); //force reload table next time
+ if (rv == NS_ERROR_FILE_IS_LOCKED)
+ {
+ m_aError.setResId( STR_MOZILLA_IS_RUNNING );
+ }
+ else if (NS_FAILED(rv))
+ {
+ m_aError.set( STR_COULD_NOT_CREATE_ADDRESSBOOK, 0, ::rtl::OUString::valueOf( sal_Int32(rv), 16 ) );
+ }
+ OSL_TRACE( "OUT MDatabaseMetaDataHelper::NewAddressBook()\n" );
+ return( NS_SUCCEEDED(rv) ? sal_True : sal_False );
+}
+nsresult NewAddressBook(const ::rtl::OUString * aName)
+{
+ if (isProfileLocked(NULL))
+ return NS_ERROR_FILE_IS_LOCKED;
+ nsresult rv;
+ nsCOMPtr<nsIAbDirectoryProperties> aProperties = do_CreateInstance(NS_ABDIRECTORYPROPERTIES_CONTRACTID, &rv);
+ NS_ENSURE_ARG_POINTER(aProperties);
+ const ::rtl::OUString& uName = *aName;
+ nsString nsName;
+ MTypeConverter::ouStringToNsString(uName,nsName);
+ aProperties->SetDescription(nsName);
+
+ nsCOMPtr<nsIRDFService> rdfService = do_GetService (kRDFServiceCID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsIRDFResource> parentResource;
+ rv = rdfService->GetResource(NS_LITERAL_CSTRING(kAllDirectoryRoot), getter_AddRefs(parentResource));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsIAbDirectory> parentDir = do_QueryInterface(parentResource, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = parentDir->CreateNewDirectory(aProperties);
+ return rv;
+}
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx
new file mode 100644
index 000000000000..39c6e34408d4
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * 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 _CONNECTIVITY_MAB_DATABASEMETADATAHELPER_HXX_
+#define _CONNECTIVITY_MAB_DATABASEMETADATAHELPER_HXX_
+
+#include "MErrorResource.hxx"
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include "FDatabaseMetaDataResultSet.hxx"
+
+#ifndef _CONNECTIVITY_MAB_CONNECTION_HXX_
+#include <MConnection.hxx>
+#endif
+#include <com/sun/star/uno/Sequence.hxx>
+#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+#endif
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class MDatabaseMetaDataHelper
+ {
+ private:
+ sal_Bool m_bProfileExists ;
+ ::std::vector< ::rtl::OUString > m_aTableNames;
+ ::std::vector< ::rtl::OUString > m_aTableTypes;
+ ::com::sun::star::mozilla::MozillaProductType m_ProductType;
+ ::rtl::OUString m_ProfileName;
+ ErrorDescriptor m_aError;
+
+ public:
+ MDatabaseMetaDataHelper();
+ ~MDatabaseMetaDataHelper();
+
+ //
+ sal_Bool getTableStrings( OConnection* _pCon,
+ ::std::vector< ::rtl::OUString >& _rStrings,
+ ::std::vector< ::rtl::OUString >& _rTypes);
+
+ sal_Bool getTables( OConnection* _pCon,
+ const ::rtl::OUString& tableNamePattern,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types,
+ ODatabaseMetaDataResultSet::ORows& _rRows);
+ sal_Bool testLDAPConnection( OConnection* _pCon );
+ sal_Bool NewAddressBook( OConnection* _pCon,const ::rtl::OUString & aTableName);
+
+ inline const ErrorDescriptor& getError() const { return m_aError; }
+ };
+ }
+
+}
+#endif // _CONNECTIVITY_MAB_DATABASEMETADATAHELPER_HXX_
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx b/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx
new file mode 100644
index 000000000000..5e975087bcfd
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * 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 CONNECITIVITY_MOZAB_ERROR_RESOURCE_HXX
+#define CONNECITIVITY_MOZAB_ERROR_RESOURCE_HXX
+
+#include <rtl/ustring.hxx>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class ErrorDescriptor
+ {
+ private:
+ sal_uInt16 m_nErrorResourceId;
+ sal_Int32 m_nErrorCondition;
+ ::rtl::OUString m_sParameter;
+
+ public:
+ ErrorDescriptor()
+ :m_nErrorResourceId(0)
+ ,m_nErrorCondition(0)
+ ,m_sParameter()
+ {
+ }
+
+ inline void set( const sal_uInt16 _nErrorResourceId, const sal_Int32 _nErrorCondition, const ::rtl::OUString& _rParam )
+ {
+ m_nErrorResourceId = _nErrorResourceId;
+ m_nErrorCondition = _nErrorCondition;
+ m_sParameter = _rParam;
+ }
+ inline void setResId( const sal_uInt16 _nErrorResourceId )
+ {
+ m_nErrorResourceId = _nErrorResourceId;
+ }
+ inline void reset()
+ {
+ m_nErrorResourceId = 0;
+ m_nErrorCondition = 0;
+ }
+
+ inline sal_uInt16 getResId() const { return m_nErrorResourceId; }
+ inline sal_Int32 getErrorCondition() const { return m_nErrorCondition; }
+ inline const ::rtl::OUString& getParameter() const { return m_sParameter; }
+
+ inline bool is() const { return ( m_nErrorResourceId != 0 ) || ( m_nErrorCondition != 0 ); }
+ };
+ }
+}
+
+#endif // CONNECITIVITY_MOZAB_ERROR_RESOURCE_HXX
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.cxx b/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.cxx
new file mode 100644
index 000000000000..73c3fb16908b
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.cxx
@@ -0,0 +1,450 @@
+/*************************************************************************
+ * 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.
+ *
+************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <rtl/strbuf.hxx>
+ // keep this include at the beginning. Some of the other includes seems to inject a symbol "l" into the
+ // global namespace, which leads to a compiler warning in strbuf.hxx, about some parameters named "l"
+ // hiding objects "in an outer scope".
+
+#include "MLdapAttributeMap.hxx"
+#include "MTypeConverter.hxx"
+#include "MQueryHelper.hxx"
+
+#include <tools/diagnose_ex.h>
+
+#include <hash_map>
+
+//........................................................................
+namespace connectivity { namespace mozab {
+//........................................................................
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ typedef nsresult (NS_STDCALL nsIAbCard::*CardPropertyGetter)( PRUnichar** aFirstName );
+ typedef nsresult (NS_STDCALL nsIAbCard::*CardPropertySetter)( const PRUnichar* aFirstName );
+ struct CardPropertyData
+ {
+ const sal_Char* pLDAPAttributeList;
+ CardPropertyGetter PropGetter;
+ CardPropertySetter PropSetter;
+
+ CardPropertyData()
+ :pLDAPAttributeList( NULL )
+ ,PropGetter( NULL )
+ ,PropSetter( NULL )
+ {
+ }
+ CardPropertyData( const sal_Char* _pLDAPAttributeList, CardPropertyGetter _PropGetter, CardPropertySetter _PropSetter )
+ :pLDAPAttributeList( _pLDAPAttributeList )
+ ,PropGetter( _PropGetter )
+ ,PropSetter( _PropSetter )
+ {
+ }
+ };
+
+ typedef ::std::hash_map< ::rtl::OString, CardPropertyData, ::rtl::OStringHash > MapPropertiesToAttributes;
+
+ #define DEF_CARD_ACCESS( PropertyName ) \
+ &nsIAbCard::Get##PropertyName, &nsIAbCard::Set##PropertyName
+
+ static const MapPropertiesToAttributes& lcl_getPropertyMap()
+ {
+ static MapPropertiesToAttributes aMap;
+ if ( aMap.empty() )
+ {
+ struct MapEntry
+ {
+ const sal_Char* pAsciiPropertyName;
+ const sal_Char* pAsciiAttrributeList;
+ CardPropertyGetter PropGetter;
+ CardPropertySetter PropSetter;
+ };
+ const MapEntry aEntries[] = {
+ { "FirstName", "givenname", DEF_CARD_ACCESS( FirstName ) },
+ { "LastName", "sn,surnname", DEF_CARD_ACCESS( LastName ) },
+ { "DisplayName", "cn,commonname,displayname", DEF_CARD_ACCESS( DisplayName ) },
+ { "NickName", "xmozillanickname", DEF_CARD_ACCESS( NickName ) },
+ { "PrimaryEmail", "mail", DEF_CARD_ACCESS( PrimaryEmail ) },
+ { "SecondEmail", "xmozillasecondemail", DEF_CARD_ACCESS( SecondEmail ) },
+ { "WorkPhone", "telephonenumber", DEF_CARD_ACCESS( WorkPhone ) },
+ { "HomePhone", "homephone", DEF_CARD_ACCESS( HomePhone ) },
+ { "FaxNumber", "fax,facsimiletelephonenumber", DEF_CARD_ACCESS( FaxNumber ) },
+ { "PagerNumber", "pager,pagerphone", DEF_CARD_ACCESS( PagerNumber ) },
+ { "CellularNumber", "mobile,cellphone,carphone", DEF_CARD_ACCESS( CellularNumber ) },
+ { "HomeAddress", "homepostaladdress,mozillaHomeStreet", DEF_CARD_ACCESS( HomeAddress ) },
+ { "HomeAddress2", "mozillaHomeStreet2", DEF_CARD_ACCESS( HomeAddress2 ) },
+ { "HomeCity", "homelocality,mozillaHomeLocalityName", DEF_CARD_ACCESS( HomeCity ) },
+ { "HomeState", "homeregion,mozillaHomeState", DEF_CARD_ACCESS( HomeState ) },
+ { "HomeZipCode", "homepostalcode,mozillaHomePostalCode", DEF_CARD_ACCESS( HomeZipCode ) },
+ { "HomeCountry", "homecountryname,mozillaHomeCountryName", DEF_CARD_ACCESS( HomeCountry ) },
+ { "WorkAddress", "postofficebox,streetaddress,streetaddress1", DEF_CARD_ACCESS( WorkAddress ) },
+ { "WorkAddress2", "streetaddress2", DEF_CARD_ACCESS( WorkAddress2 ) },
+ { "WorkCity", "l,locality", DEF_CARD_ACCESS( WorkCity ) },
+ { "WorkState", "st,region", DEF_CARD_ACCESS( WorkState ) },
+ { "WorkZipCode", "postalcode,zip", DEF_CARD_ACCESS( WorkZipCode ) },
+ { "WorkCountry", "countryname", DEF_CARD_ACCESS( WorkCountry ) },
+ { "JobTitle", "title", DEF_CARD_ACCESS( JobTitle ) },
+ { "Department", "ou,orgunit,department,departmentnumber", DEF_CARD_ACCESS( Department ) },
+ { "Company", "o,company", DEF_CARD_ACCESS( Company ) },
+ { "WebPage1", "workurl", DEF_CARD_ACCESS( WebPage1 ) },
+ { "WebPage2", "homeurl", DEF_CARD_ACCESS( WebPage2 ) },
+ { "BirthYear", "birthyear", DEF_CARD_ACCESS( BirthYear ) },
+ { "BirthMonth", "birthmonth", DEF_CARD_ACCESS( BirthMonth ) },
+ { "BirthYear", "birthday", DEF_CARD_ACCESS( BirthDay ) },
+ { "Custom1", "custom1", DEF_CARD_ACCESS( Custom1 ) },
+ { "Custom2", "custom2", DEF_CARD_ACCESS( Custom2 ) },
+ { "Custom3", "custom3", DEF_CARD_ACCESS( Custom3 ) },
+ { "Custom4", "custom4", DEF_CARD_ACCESS( Custom4 ) },
+ { "Notes", "notes,description", DEF_CARD_ACCESS( Notes ) },
+ { "PreferMailFormat", "xmozillausehtmlmail", NULL, NULL },
+ { NULL, NULL, NULL, NULL }
+ };
+ const MapEntry* loop = aEntries;
+ while ( loop->pAsciiPropertyName )
+ {
+ aMap[ ::rtl::OString( loop->pAsciiPropertyName ) ] =
+ CardPropertyData( loop->pAsciiAttrributeList, loop->PropGetter, loop->PropSetter );
+ ++loop;
+ }
+ }
+ return aMap;
+ }
+ }
+
+ //====================================================================
+ //= AttributeMap_Data
+ //====================================================================
+ struct AttributeMap_Data
+ {
+ };
+
+ //====================================================================
+ //= MLdapAttributeMap
+ //====================================================================
+ // -------------------------------------------------------------------
+ MLdapAttributeMap::MLdapAttributeMap()
+ :m_pData( new AttributeMap_Data )
+ {
+ }
+
+ // -------------------------------------------------------------------
+ MLdapAttributeMap::~MLdapAttributeMap()
+ {
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMPL_THREADSAFE_ISUPPORTS1( MLdapAttributeMap, nsIAbLDAPAttributeMap )
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::GetAttributeList(const nsACString & aProperty, nsACString & _retval)
+ {
+ ::rtl::OString sProperty( MTypeConverter::nsACStringToOString( aProperty ) );
+
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+ MapPropertiesToAttributes::const_iterator pos = rPropertyMap.find( sProperty );
+
+ if ( pos == rPropertyMap.end() )
+ {
+ _retval.SetIsVoid( PR_TRUE );
+ }
+ else
+ {
+ MTypeConverter::asciiToNsACString( pos->second.pLDAPAttributeList, _retval );
+ }
+
+ return NS_OK;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::GetAttributes(const nsACString & aProperty, PRUint32* aCount, char*** aAttrs)
+ {
+ OSL_ENSURE( false, "MLdapAttributeMap::GetAttributes: not implemented!" );
+ (void)aProperty;
+ (void)aCount;
+ (void)aAttrs;
+ return NS_ERROR_NOT_IMPLEMENTED;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::GetFirstAttribute(const nsACString & aProperty, nsACString & _retval)
+ {
+ ::rtl::OString sProperty( MTypeConverter::nsACStringToOString( aProperty ) );
+
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+ MapPropertiesToAttributes::const_iterator pos = rPropertyMap.find( sProperty );
+
+ if ( pos == rPropertyMap.end() )
+ {
+ _retval.SetIsVoid( PR_TRUE );
+ }
+ else
+ {
+ sal_Int32 tokenPos(0);
+ ::rtl::OString sAttributeList( pos->second.pLDAPAttributeList );
+ MTypeConverter::asciiToNsACString( sAttributeList.getToken( 0, ',', tokenPos ).getStr(), _retval );
+ }
+
+ return NS_OK;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::SetAttributeList(const nsACString & aProperty, const nsACString & aAttributeList, PRBool allowInconsistencies)
+ {
+ OSL_ENSURE( false, "MLdapAttributeMap::SetAttributeList: not implemented!" );
+ (void)aProperty;
+ (void)aAttributeList;
+ (void)allowInconsistencies;
+ return NS_ERROR_NOT_IMPLEMENTED;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::GetProperty(const nsACString & aAttribute, nsACString & _retval)
+ {
+ OSL_ENSURE( false, "MLdapAttributeMap::GetProperty: not implemented!" );
+ (void)aAttribute;
+ (void)_retval;
+ return NS_ERROR_NOT_IMPLEMENTED;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::GetAllCardAttributes(nsACString & _retval)
+ {
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+
+ ::rtl::OStringBuffer aAllAttributes;
+ for ( MapPropertiesToAttributes::const_iterator loop = rPropertyMap.begin();
+ loop != rPropertyMap.end();
+ ++loop
+ )
+ {
+ aAllAttributes.append( loop->second.pLDAPAttributeList );
+ if ( loop != rPropertyMap.end() )
+ aAllAttributes.append( ',' );
+ }
+
+ MTypeConverter::asciiToNsACString( aAllAttributes.getStr(), _retval );
+ return NS_OK;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::CheckState(void)
+ {
+ // we do not allow modifying the map, so we're always in a valid state
+ return NS_OK;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::SetFromPrefs(const nsACString & aPrefBranchName)
+ {
+ OSL_ENSURE( false, "MLdapAttributeMap::SetFromPrefs: not implemented!" );
+ (void)aPrefBranchName;
+ return NS_ERROR_NOT_IMPLEMENTED;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::SetCardPropertiesFromLDAPMessage(nsILDAPMessage* aMessage, nsIAbCard* aCard)
+ {
+ NS_ENSURE_ARG_POINTER( aMessage );
+ NS_ENSURE_ARG_POINTER( aCard );
+
+ // in case that's not present in the LDAP message: set the "preferred mail format" to "none"
+ aCard->SetPreferMailFormat( nsIAbPreferMailFormat::unknown );
+
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+ for ( MapPropertiesToAttributes::const_iterator prop = rPropertyMap.begin();
+ prop != rPropertyMap.end();
+ ++prop
+ )
+ {
+ // split the list of attributes for the current property
+ ::rtl::OString sAttributeList( prop->second.pLDAPAttributeList );
+ ::rtl::OString sAttribute;
+
+ sal_Int32 tokenPos = 0;
+ while ( tokenPos != -1 )
+ {
+ sAttribute = sAttributeList.getToken( 0, ',', tokenPos );
+
+ // retrieve the values for the current attribute
+ PRUint32 valueCount = 0;
+ PRUnichar** values = NULL;
+ nsresult rv = aMessage->GetValues( sAttribute.getStr(), &valueCount, &values );
+ if ( NS_FAILED( rv ) )
+ // try the next attribute
+ continue;
+
+ if ( valueCount )
+ {
+ CardPropertySetter propSetter = prop->second.PropSetter;
+ OSL_ENSURE( propSetter,
+ "MLdapAttributeMap::SetCardPropertiesFromLDAPMessage: "
+ "unexpected: could retrieve an attribute value, but have no setter for it!" );
+ if ( propSetter )
+ {
+ (aCard->*propSetter)( values[0] );
+ }
+
+ // we're done with this property - no need to handle the remaining attributes which
+ // map to it
+ break;
+ }
+ }
+ }
+ return NS_OK;
+ }
+
+ // -------------------------------------------------------------------
+ namespace
+ {
+ struct PreferMailFormatType
+ {
+ const sal_Char* description;
+ PRUint32 formatType;
+
+ PreferMailFormatType()
+ :description( NULL )
+ ,formatType( nsIAbPreferMailFormat::unknown )
+ {
+ }
+
+ PreferMailFormatType( const sal_Char* _description, PRUint32 _formatType )
+ :description( _description )
+ ,formatType( _formatType )
+ {
+ }
+ };
+
+ static const PreferMailFormatType* lcl_getMailFormatTypes()
+ {
+ static const PreferMailFormatType aMailFormatTypes[] =
+ {
+ PreferMailFormatType( "text/plain", nsIAbPreferMailFormat::plaintext ),
+ PreferMailFormatType( "text/html", nsIAbPreferMailFormat::html ),
+ PreferMailFormatType( "unknown", nsIAbPreferMailFormat::unknown ),
+ PreferMailFormatType()
+ };
+ return aMailFormatTypes;
+ }
+ }
+
+ // -------------------------------------------------------------------
+ void MLdapAttributeMap::fillCardFromResult( nsIAbCard& _card, const MQueryHelperResultEntry& _result )
+ {
+ _card.SetPreferMailFormat( nsIAbPreferMailFormat::unknown );
+
+ ::rtl::OUString resultValue;
+
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+ for ( MapPropertiesToAttributes::const_iterator prop = rPropertyMap.begin();
+ prop != rPropertyMap.end();
+ ++prop
+ )
+ {
+ resultValue = _result.getValue( prop->first );
+
+ CardPropertySetter propSetter = prop->second.PropSetter;
+ if ( propSetter )
+ {
+ // PRUnichar != sal_Unicode in mingw
+ (_card.*propSetter)( reinterpret_cast_mingw_only<const PRUnichar *>(resultValue.getStr()) );
+ }
+ else
+ {
+ if ( prop->first.equals( "PreferMailFormat" ) )
+ {
+ unsigned int format = nsIAbPreferMailFormat::unknown;
+ const PreferMailFormatType* pMailFormatType = lcl_getMailFormatTypes();
+ while ( pMailFormatType->description )
+ {
+ if ( resultValue.equalsAscii( pMailFormatType->description ) )
+ {
+ format = pMailFormatType->formatType;
+ break;
+ }
+ ++pMailFormatType;
+ }
+ _card.SetPreferMailFormat(format);
+ }
+ else
+ OSL_ENSURE( false, "MLdapAttributeMap::fillCardFromResult: unexpected property without default setters!" );
+ }
+ }
+ }
+
+ // -------------------------------------------------------------------
+ void MLdapAttributeMap::fillResultFromCard( MQueryHelperResultEntry& _result, nsIAbCard& _card )
+ {
+ nsXPIDLString value;
+ ::rtl::OUString resultValue;
+
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+ for ( MapPropertiesToAttributes::const_iterator prop = rPropertyMap.begin();
+ prop != rPropertyMap.end();
+ ++prop
+ )
+ {
+ CardPropertyGetter propGetter = prop->second.PropGetter;
+ if ( propGetter )
+ {
+ (_card.*propGetter)( getter_Copies( value ) );
+
+ nsAutoString temp( value );
+ MTypeConverter::nsStringToOUString( temp, resultValue );
+ }
+ else
+ {
+ if ( prop->first.equals( "PreferMailFormat" ) )
+ {
+ unsigned int format = nsIAbPreferMailFormat::unknown;
+ _card.GetPreferMailFormat( &format );
+ const PreferMailFormatType* pMailFormatType = lcl_getMailFormatTypes();
+ while ( pMailFormatType->description )
+ {
+ if ( format == pMailFormatType->formatType )
+ {
+ resultValue = ::rtl::OUString::createFromAscii( pMailFormatType->description );
+ break;
+ }
+ ++pMailFormatType;
+ }
+ }
+ else
+ OSL_ENSURE( false, "MLdapAttributeMap::fillResultFromCard: unexpected property without default getters!" );
+ }
+
+ _result.insert( prop->first, resultValue );
+ }
+ }
+
+//........................................................................
+} } // namespace connectivity::mozab
+//........................................................................
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.hxx b/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.hxx
new file mode 100644
index 000000000000..043b0179ee99
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ * 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 CONNECTIVITY_MLDAPATTRIBUTEMAP_HXX
+#define CONNECTIVITY_MLDAPATTRIBUTEMAP_HXX
+
+#include <MNSInclude.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace connectivity { namespace mozab {
+//........................................................................
+
+ struct AttributeMap_Data;
+ class MQueryHelperResultEntry;
+
+ //====================================================================
+ //= class MLdapAttributeMap
+ //====================================================================
+ /** implements the nsIAbLDAPAttributeMap interface
+
+ Somewhere between Mozilla 1.7.5 and SeaMonkey 1.1.12, the LDAP address book
+ implementation was changed to take the attribute mapping (from LDAP attributes
+ to address book properties) not directly from the preferences. Instead, this mapping
+ is now delivered by a dedicated implementation (supporting the nsIAbLDAPAttributeMap
+ interface).
+
+ */
+ class MLdapAttributeMap : public nsIAbLDAPAttributeMap
+ {
+ public:
+ MLdapAttributeMap();
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIABLDAPATTRIBUTEMAP
+
+ static void fillCardFromResult( nsIAbCard& _card, const MQueryHelperResultEntry& _result );
+ static void fillResultFromCard( MQueryHelperResultEntry& _result, nsIAbCard& _card );
+
+ protected:
+ virtual ~MLdapAttributeMap();
+
+ private:
+ ::std::auto_ptr< AttributeMap_Data > m_pData;
+ };
+
+//........................................................................
+} } // namespace connectivity::mozab
+//........................................................................
+
+#endif // CONNECTIVITY_MLDAPATTRIBUTEMAP_HXX
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSDeclares.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSDeclares.hxx
new file mode 100644
index 000000000000..84c2a2a7e20f
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSDeclares.hxx
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * 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 _CONNECTIVITY_MAB_NS_DECLARES_HXX_
+#define _CONNECTIVITY_MAB_NS_DECLARES_HXX_
+
+#include <sal/types.h>
+
+
+const sal_Int32 RowStates_Normal = 0;
+const sal_Int32 RowStates_Inserted = 1;
+const sal_Int32 RowStates_Updated = 2;
+const sal_Int32 RowStates_Deleted = 4;
+const sal_Int32 RowStates_Error = 32;
+
+namespace connectivity{
+ namespace mozab{
+ class OConnection;
+ }
+}
+sal_Bool isProfileLocked(connectivity::mozab::OConnection* _pCon);
+
+class nsIAbDirectory;
+sal_Int32 getDirectoryType(const nsIAbDirectory* directory);
+
+
+#endif // _CONNECTIVITY_MAB_NS_DECLARES_HXX_ 1
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx
new file mode 100644
index 000000000000..80a9bec5ad3d
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * 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 _CONNECTIVITY_MAB_NS_INCLUDE_HXX_
+#define _CONNECTIVITY_MAB_NS_INCLUDE_HXX_ 1
+
+//
+// Only include Mozilla include files once and using this file...
+//
+
+// moved this here and in first position due to "long l;" unxsoli4 warning
+#include <rtl/ustrbuf.hxx>
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include <nsDebug.h>
+
+#include <nsCOMPtr.h>
+#include <nsISupportsArray.h>
+#include <nsString.h>
+
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+#include <nsMemory.h>
+#include <prtypes.h>
+#include <nsRDFCID.h>
+#include <nsXPIDLString.h>
+#include <nsIRDFService.h>
+#include <nsIRDFResource.h>
+#include <nsReadableUtils.h>
+#include <msgCore.h>
+#include <nsIServiceManager.h>
+#include <nsIAbCard.h>
+#include <nsAbBaseCID.h>
+#include <nsAbAddressCollecter.h>
+#include <nsIPref.h>
+#include <nsIAddrBookSession.h>
+#include <nsIMsgHeaderParser.h>
+#include <nsIAddrBookSession.h>
+#include <nsIAbDirectory.h>
+#include <nsAbDirectoryQuery.h>
+#include <nsIAbDirectoryQuery.h>
+#include <nsIAbDirectoryQueryProxy.h>
+#include <nsIAbDirFactory.h>
+#include <nsIRunnable.h>
+#include <nsIAbLDAPAttributeMap.h>
+#include <nsILDAPMessage.h>
+
+#include <prerr.h>
+
+#include "post_include_mozilla.h"
+
+#endif // _CONNECTIVITY_MAB_NS_INCLUDE_HXX_
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.cxx b/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.cxx
new file mode 100644
index 000000000000..88cf400bf651
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.cxx
@@ -0,0 +1,404 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "MNSMozabProxy.hxx"
+
+#include "resource/mozab_res.hrc"
+#include "MDatabaseMetaDataHelper.hxx"
+#include "MQuery.hxx"
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+
+#include "pre_include_mozilla.h"
+#include <nsIProxyObjectManager.h>
+// More Mozilla includes for LDAP Connection Test
+#include "prprf.h"
+#include "nsILDAPURL.h"
+#include "nsILDAPMessage.h"
+#include "nsILDAPMessageListener.h"
+#include "nsILDAPErrors.h"
+#include "nsILDAPConnection.h"
+#include "nsILDAPOperation.h"
+#include "post_include_mozilla.h"
+#include "MQuery.hxx"
+#include <MQueryHelper.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <unotools/processfactory.hxx>
+#include "com/sun/star/mozilla/XProxyRunner.hpp"
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::mozilla;
+
+
+#define TYPEASSERT(value,type) if (value != type) return !NS_OK;
+
+using namespace connectivity::mozab;
+
+/* Implementation file */
+
+static ::osl::Mutex m_aThreadMutex;
+extern nsresult NewAddressBook(const ::rtl::OUString * aName);
+
+
+MNSMozabProxy::MNSMozabProxy()
+{
+ m_Args = NULL;
+#if OSL_DEBUG_LEVEL > 0
+ m_oThreadID = osl_getThreadIdentifier(NULL);
+#endif
+ acquire();
+}
+
+MNSMozabProxy::~MNSMozabProxy()
+{
+}
+
+sal_Int32 MNSMozabProxy::StartProxy(RunArgs * args,::com::sun::star::mozilla::MozillaProductType aProduct,const ::rtl::OUString &aProfile)
+{
+ OSL_TRACE( "IN : MNSMozabProxy::StartProxy() \n" );
+ ::osl::MutexGuard aGuard(m_aThreadMutex);
+ m_Product = aProduct;
+ m_Profile = aProfile;
+ m_Args = args;
+ if (!xRunner.is())
+ {
+ Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xFactory.is(), "can't get service factory" );
+ ::com::sun::star::uno::Reference<XInterface> xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+ xRunner = ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XProxyRunner >(xInstance,UNO_QUERY);
+ }
+ const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy > aCode(this);
+ return xRunner->Run(aCode);
+}
+
+extern nsresult getTableStringsProxied(const sal_Char* sAbURI, sal_Int32 *nDirectoryType,MNameMapper *nmap,
+ ::std::vector< ::rtl::OUString >* _rStrings,
+ ::std::vector< ::rtl::OUString >* _rTypes,
+ sal_Int32* pErrorId );
+
+::com::sun::star::mozilla::MozillaProductType SAL_CALL MNSMozabProxy::getProductType( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_Product;
+}
+::rtl::OUString SAL_CALL MNSMozabProxy::getProfileName( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_Profile;
+}
+
+sal_Int32 SAL_CALL MNSMozabProxy::run( ) throw (::com::sun::star::uno::RuntimeException)
+{
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE( "IN : MNSMozabProxy::Run() Caller thread :%4d \n" , m_oThreadID );
+#else
+ OSL_TRACE( "IN : MNSMozabProxy::Run() \n" );
+#endif
+ nsresult rv = NS_ERROR_INVALID_ARG;
+ if (m_Args == NULL)
+ return NS_ERROR_INVALID_ARG;
+ switch(m_Args->funcIndex)
+ {
+ case ProxiedFunc::FUNC_TESTLDAP_INIT_LDAP:
+ case ProxiedFunc::FUNC_TESTLDAP_IS_LDAP_CONNECTED:
+ case ProxiedFunc::FUNC_TESTLDAP_RELEASE_RESOURCE:
+ rv = testLDAPConnection();
+ break;
+ case ProxiedFunc::FUNC_GET_TABLE_STRINGS:
+ rv = getTableStringsProxied((const sal_Char*)m_Args->arg1,
+ (sal_Int32 *)m_Args->arg2,
+ (MNameMapper *)m_Args->arg3,
+ (::std::vector< ::rtl::OUString >*)m_Args->arg4,
+ (::std::vector< ::rtl::OUString >*)m_Args->arg5,
+ (sal_Int32 *)m_Args->arg6);
+ break;
+ case ProxiedFunc::FUNC_EXECUTE_QUERY:
+ if (m_Args->arg1 && m_Args->arg2)
+ {
+ rv = ((MQuery*)m_Args->arg1)->executeQueryProxied((OConnection*)m_Args->arg2);
+ }
+ break;
+ case ProxiedFunc::FUNC_QUERYHELPER_CREATE_NEW_CARD:
+ case ProxiedFunc::FUNC_QUERYHELPER_DELETE_CARD:
+ case ProxiedFunc::FUNC_QUERYHELPER_COMMIT_CARD:
+ case ProxiedFunc::FUNC_QUERYHELPER_RESYNC_CARD:
+ if (m_Args->arg1)
+ {
+ rv = QueryHelperStub();
+ }
+ break;
+ case ProxiedFunc::FUNC_NEW_ADDRESS_BOOK:
+ if (m_Args->arg1)
+ {
+ rv = NewAddressBook((const ::rtl::OUString*)m_Args->arg1 );
+ }
+ break;
+ default:
+ return NS_ERROR_INVALID_ARG;
+ }
+ return rv;
+}
+
+nsresult MNSMozabProxy::QueryHelperStub()
+{
+ nsresult rv = NS_ERROR_INVALID_ARG;
+ MQueryHelper * mHelper=(MQueryHelper*) m_Args->arg1;
+ switch(m_Args->funcIndex)
+ {
+ case ProxiedFunc::FUNC_QUERYHELPER_CREATE_NEW_CARD:
+ if (m_Args->arg2 ) //m_Args->arg2 used to return cord number
+ {
+ *((sal_Int32*)m_Args->arg2) = mHelper->createNewCard();
+ rv = NS_OK;
+ }
+ break;
+ case ProxiedFunc::FUNC_QUERYHELPER_DELETE_CARD:
+ if (m_Args->arg2 && m_Args->arg3 ) //m_Args->arg2 used to get the cord number
+ {
+ rv = mHelper->deleteCard(*((sal_Int32*)m_Args->arg2),(nsIAbDirectory*)m_Args->arg3);
+ }
+ break;
+ case ProxiedFunc::FUNC_QUERYHELPER_COMMIT_CARD:
+ if (m_Args->arg2 && m_Args->arg3 ) //m_Args->arg2 used to get the cord number
+ {
+ rv = mHelper->commitCard(*((sal_Int32*)m_Args->arg2),(nsIAbDirectory*)m_Args->arg3);
+ }
+ break;
+ case ProxiedFunc::FUNC_QUERYHELPER_RESYNC_CARD:
+ if (m_Args->arg2) //m_Args->arg2 used to get the cord number
+ {
+ rv = mHelper->resyncRow(*((sal_Int32*)m_Args->arg2));
+ }
+ break;
+ default:
+ break;
+ }
+ return rv;
+}
+//-------------------------------------------------------------------
+
+#define NS_LDAPCONNECTION_CONTRACTID "@mozilla.org/network/ldap-connection;1"
+#define NS_LDAPOPERATION_CONTRACTID "@mozilla.org/network/ldap-operation;1"
+#define NS_LDAPMESSAGE_CONTRACTID "@mozilla.org/network/ldap-message;1"
+#define NS_LDAPURL_CONTRACTID "@mozilla.org/network/ldap-url;1"
+
+namespace connectivity {
+ namespace mozab {
+ class MLDAPMessageListener : public nsILDAPMessageListener
+ {
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSILDAPMESSAGELISTENER
+
+ MLDAPMessageListener();
+ virtual ~MLDAPMessageListener();
+
+ sal_Bool initialized() const;
+ sal_Bool goodConnection() const { return initialized() && m_GoodConnection; }
+
+ protected:
+
+ ::osl::Mutex m_aMutex;
+ ::osl::Condition m_aCondition;
+
+ sal_Bool m_IsComplete;
+ sal_Bool m_GoodConnection;
+
+ void setConnectionStatus( sal_Bool _good );
+ };
+ }
+}
+
+NS_IMPL_THREADSAFE_ISUPPORTS1(MLDAPMessageListener, nsILDAPMessageListener)
+
+MLDAPMessageListener::MLDAPMessageListener()
+ : mRefCnt( 0 )
+ , m_IsComplete( sal_False )
+ , m_GoodConnection( sal_False )
+{
+ m_aCondition.reset();
+}
+
+MLDAPMessageListener::~MLDAPMessageListener()
+{
+}
+
+sal_Bool MLDAPMessageListener::initialized() const
+{
+ return const_cast< MLDAPMessageListener* >( this )->m_aCondition.check();
+}
+
+void MLDAPMessageListener::setConnectionStatus( sal_Bool _good )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_IsComplete = sal_True;
+ m_GoodConnection = _good;
+
+ m_aCondition.set();
+}
+
+NS_IMETHODIMP MLDAPMessageListener::OnLDAPInit(nsILDAPConnection* /*aConn*/, nsresult aStatus )
+{
+ setConnectionStatus( NS_SUCCEEDED( aStatus ) ? sal_True : sal_False );
+ return aStatus;
+}
+
+NS_IMETHODIMP MLDAPMessageListener::OnLDAPMessage( nsILDAPMessage* aMessage )
+{
+ nsresult rv;
+
+ PRInt32 messageType;
+ rv = aMessage->GetType(&messageType);
+ NS_ENSURE_SUCCESS(rv, rv);
+ PRInt32 errCode;
+ switch (messageType)
+ {
+ case nsILDAPMessage::RES_BIND:
+ rv = aMessage->GetErrorCode(&errCode);
+ // if the login failed
+ if (errCode != (PRInt32)nsILDAPErrors::SUCCESS) {
+ setConnectionStatus( sal_False );
+ }
+ else
+ setConnectionStatus( sal_True );
+ break;
+ case nsILDAPMessage::RES_SEARCH_RESULT:
+ setConnectionStatus( sal_True );
+ break;
+ default:
+ break;
+ }
+
+ return NS_OK;
+}
+
+//-------------------------------------------------------------------
+
+nsresult
+MNSMozabProxy::testLDAPConnection( )
+{
+ nsresult rv=NS_ERROR_INVALID_ARG;
+ switch(m_Args->funcIndex)
+ {
+ case ProxiedFunc::FUNC_TESTLDAP_INIT_LDAP:
+ if (m_Args->arg1 && m_Args->arg4 )
+ {
+ rv = InitLDAP((sal_Char*)m_Args->arg1,(sal_Unicode*)m_Args->arg2,(sal_Unicode*)m_Args->arg3,(sal_Bool*)m_Args->arg4);
+ }
+ break;
+ case ProxiedFunc::FUNC_TESTLDAP_IS_LDAP_CONNECTED:
+ if (m_Args->arg5)
+ {
+ const MLDAPMessageListener* pListener( static_cast< const MLDAPMessageListener* >( m_Args->arg5 ) );
+ if ( pListener->initialized() )
+ rv = pListener->goodConnection() ? 0 : (nsresult)PR_NOT_CONNECTED_ERROR;
+ else
+ rv = (nsresult)PR_CONNECT_TIMEOUT_ERROR;
+ }
+ break;
+ case ProxiedFunc::FUNC_TESTLDAP_RELEASE_RESOURCE:
+ if (m_Args->arg5)
+ {
+ ((MLDAPMessageListener*)m_Args->arg5)->Release();
+ delete (MLDAPMessageListener*)m_Args->arg5;
+ m_Args->arg5 = NULL;
+ rv = 0;
+ }
+ break;
+ default:
+ return NS_ERROR_INVALID_ARG;
+ }
+ return rv;
+}
+nsresult
+MNSMozabProxy::InitLDAP(sal_Char* sUri, sal_Unicode* sBindDN, sal_Unicode* pPasswd,sal_Bool * nUseSSL)
+{
+ sal_Bool useSSL = *nUseSSL;
+ nsresult rv;
+
+ nsCOMPtr<nsILDAPURL> url;
+ url = do_CreateInstance(NS_LDAPURL_CONTRACTID, &rv);
+ if ( NS_FAILED(rv) )
+ return NS_ERROR_INVALID_ARG;
+
+ rv = url->SetSpec( nsDependentCString(sUri) );
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCAutoString host;
+ rv = url->GetAsciiHost(host);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ PRInt32 port;
+ rv = url->GetPort(&port);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCString dn;
+ rv = url->GetDn(dn);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+
+
+ // Get the ldap connection
+ nsCOMPtr<nsILDAPConnection> ldapConnection;
+ ldapConnection = do_CreateInstance(NS_LDAPCONNECTION_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ MLDAPMessageListener* messageListener =
+ new MLDAPMessageListener ( );
+ if (messageListener == NULL)
+ return NS_ERROR_INVALID_ARG;
+
+ messageListener->AddRef();
+
+ nsCAutoString nsBind;
+ // PRUnichar != sal_Unicode in mingw
+ nsBind.AssignWithConversion(reinterpret_cast_mingw_only<const PRUnichar *>(sBindDN));
+
+ // Now lets initialize the LDAP connection properly.
+ rv = ldapConnection->Init(host.get(), port, useSSL, nsBind,
+ messageListener,NULL,nsILDAPConnection::VERSION3);
+ // Initiate the LDAP operation
+ nsCOMPtr<nsILDAPOperation> ldapOperation =
+ do_CreateInstance(NS_LDAPOPERATION_CONTRACTID, &rv);
+
+ rv = ldapOperation->Init(ldapConnection, messageListener, nsnull);
+ if (NS_FAILED(rv))
+ return NS_ERROR_UNEXPECTED; // this should never happen
+
+ if ( pPasswd && *pPasswd )
+ {
+ nsCAutoString nsPassword;
+ // PRUnichar != sal_Unicode in mingw
+ nsPassword.AssignWithConversion(reinterpret_cast_mingw_only<const PRUnichar *>(pPasswd));
+ rv = ldapOperation->SimpleBind(nsPassword);
+ }
+
+ if (NS_SUCCEEDED(rv))
+ m_Args->arg5 = messageListener;
+ return rv;
+}
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.hxx
new file mode 100644
index 000000000000..4cd7c9805c9e
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.hxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * 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 _CONNECTIVITY_MAB_MOZABHELPER_HXX_
+#define _CONNECTIVITY_MAB_MOZABHELPER_HXX_
+#include "MNSDeclares.hxx"
+#include <osl/thread.hxx>
+
+#include <MNSInclude.hxx>
+#ifndef _CPPUHELPER_COMPBASE2_HXX_
+#include <cppuhelper/compbase1.hxx>
+#endif
+#ifndef _COM_SUN_STAR_MOZILLA_XCODEPROXY_HDL_
+#include <com/sun/star/mozilla/XCodeProxy.hpp>
+#endif
+#ifndef _COM_SUN_STAR_MOZILLA_XPROXYRUNNER_HDL_
+#include "com/sun/star/mozilla/XProxyRunner.hdl"
+#endif
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ namespace ProxiedFunc
+ {
+ enum
+ {
+ FUNC_TESTLDAP_INIT_LDAP=1,
+ FUNC_TESTLDAP_IS_LDAP_CONNECTED,
+ FUNC_TESTLDAP_RELEASE_RESOURCE,
+ FUNC_GET_TABLE_STRINGS,
+ FUNC_EXECUTE_QUERY,
+ FUNC_QUERYHELPER_CREATE_NEW_CARD,
+ FUNC_QUERYHELPER_DELETE_CARD,
+ FUNC_QUERYHELPER_COMMIT_CARD,
+ FUNC_QUERYHELPER_RESYNC_CARD,
+ FUNC_NEW_ADDRESS_BOOK
+ };
+ }
+
+ struct RunArgs
+ {
+ sal_Int32 funcIndex; //Function Index
+ sal_Int32 argCount; //parameter count
+ void * arg1;
+ void * arg2;
+ void * arg3;
+ void * arg4;
+ void * arg5;
+ void * arg6;
+ RunArgs()
+ {
+ arg1 = NULL;
+ arg2 = NULL;
+ arg3 = NULL;
+ arg4 = NULL;
+ arg5 = NULL;
+ arg6 = NULL;
+ }
+ };
+ typedef RunArgs RunArgs;
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::mozilla::XCodeProxy > MNSMozabProxy_BASE;
+
+
+ class MNSMozabProxy : public MNSMozabProxy_BASE
+ {
+ public:
+ MNSMozabProxy();
+ virtual ~MNSMozabProxy();
+
+ //XCodeProxy
+ virtual sal_Int32 SAL_CALL run( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::mozilla::MozillaProductType SAL_CALL getProductType( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getProfileName( ) throw (::com::sun::star::uno::RuntimeException);
+
+ public:
+ sal_Int32 StartProxy(RunArgs * args,::com::sun::star::mozilla::MozillaProductType aProduct,const ::rtl::OUString &aProfile); //Call this to start proxy
+
+ protected:
+ nsresult testLDAPConnection();
+ nsresult InitLDAP(sal_Char* sUri, sal_Unicode* sBindDN, sal_Unicode* sPasswd,sal_Bool * nUseSSL);
+ nsresult QueryHelperStub();
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XProxyRunner > xRunner;
+
+ RunArgs * m_Args;
+ ::com::sun::star::mozilla::MozillaProductType m_Product;
+ ::rtl::OUString m_Profile;
+#if OSL_DEBUG_LEVEL > 0
+ oslThreadIdentifier m_oThreadID;
+#endif
+ };
+ }
+}
+#endif //_CONNECTIVITY_MAB_MOZABHELPER_HXX_
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.cxx b/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.cxx
new file mode 100644
index 000000000000..b4c16cd562e6
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.cxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <MNSTerminateListener.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <MNSInit.hxx>
+
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+::com::sun::star::uno::Reference< ::com::sun::star::frame::XTerminateListener> MNSTerminateListener::mxTerminateListener = new MNSTerminateListener();
+
+// -----------------------------------------
+// - MNSTerminateListener -
+// -----------------------------------------
+
+MNSTerminateListener::MNSTerminateListener( )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+MNSTerminateListener::~MNSTerminateListener()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL MNSTerminateListener::disposing( const EventObject& /*Source*/ ) throw( RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL MNSTerminateListener::queryTermination( const EventObject& /*aEvent*/ ) throw( TerminationVetoException, RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL MNSTerminateListener::notifyTermination( const EventObject& /*aEvent*/ ) throw( RuntimeException )
+{
+ MNS_Term(sal_True); //Force XPCOM to shutdown
+}
+
+void MNSTerminateListener::addTerminateListener()
+{
+ Reference< XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() );
+
+ if( xFact.is() )
+ {
+ Reference< XDesktop > xDesktop( xFact->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ), UNO_QUERY );
+
+ if( xDesktop.is() )
+ xDesktop->addTerminateListener(mxTerminateListener);
+ }
+}
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.hxx
new file mode 100644
index 000000000000..7c173699b6c9
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.hxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * 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 _MNSTERMINATELISTENER_HXX
+#define _MNSTERMINATELISTENER_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+
+//class to implement the XTerminateListener interface
+class MNSTerminateListener : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XTerminateListener >
+{
+
+private:
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
+
+
+public:
+ MNSTerminateListener();
+ virtual ~MNSTerminateListener();
+public:
+ static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTerminateListener> mxTerminateListener;
+ static void addTerminateListener();
+};
+
+#endif
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.cxx b/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.cxx
new file mode 100644
index 000000000000..f488c4c4f298
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.cxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+
+#include <MNameMapper.hxx>
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+
+using namespace connectivity::mozab;
+using namespace rtl;
+
+bool
+MNameMapper::ltstr::operator()( const ::rtl::OUString &s1, const ::rtl::OUString &s2) const
+{
+ return s1.compareTo(s2) < 0;
+}
+
+MNameMapper::MNameMapper()
+{
+ mDirMap = new MNameMapper::dirMap;
+ mUriMap = new MNameMapper::uriMap;
+}
+MNameMapper::~MNameMapper()
+{
+ clear();
+}
+
+void MNameMapper::reset()
+{
+ clear();
+ mDirMap = new MNameMapper::dirMap;
+ mUriMap = new MNameMapper::uriMap;
+}
+void MNameMapper::clear()
+{
+ if ( mUriMap != NULL ) {
+ delete mUriMap;
+ }
+ if ( mDirMap != NULL ) {
+ MNameMapper::dirMap::iterator iter;
+ for (iter = mDirMap -> begin(); iter != mDirMap -> end(); ++iter) {
+ NS_IF_RELEASE(((*iter).second));
+ }
+ delete mDirMap;
+ }
+}
+const char * getURI(const nsIAbDirectory* directory)
+{
+ nsresult retCode;
+ nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)directory, &retCode) ;
+ if (NS_FAILED(retCode)) { return NULL; }
+ const char * uri;
+ retCode=rdfResource->GetValueConst(&uri);
+ if (NS_FAILED(retCode)) { return NULL; }
+ return uri;
+}
+
+// May modify the name passed in so that it's unique
+nsresult
+MNameMapper::add( ::rtl::OUString& str, nsIAbDirectory* abook )
+{
+ MNameMapper::dirMap::iterator iter;
+
+ OSL_TRACE( "IN MNameMapper::add()\n" );
+
+ if ( abook == NULL ) {
+ OSL_TRACE( "\tOUT MNameMapper::add() called with null abook\n" );
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ ::rtl::OUString ouUri=::rtl::OUString::createFromAscii(getURI(abook));
+ if ( mUriMap->find (ouUri) != mUriMap->end() ) //There's already an entry with same uri
+ {
+ return NS_ERROR_FILE_NOT_FOUND;
+ }
+ mUriMap->insert( MNameMapper::uriMap::value_type( ouUri, abook ) );
+
+ ::rtl::OUString tempStr=str;
+ long count =1;
+ while ( mDirMap->find( tempStr ) != mDirMap->end() ) {
+
+ tempStr = str + ::rtl::OUString::valueOf(count);;
+ count ++;
+ }
+ str = tempStr;
+ NS_IF_ADDREF(abook);
+ mDirMap->insert( MNameMapper::dirMap::value_type( str, abook ) );
+ OSL_TRACE( "\tOUT MNameMapper::add()\n" );
+ return 0;
+}
+
+bool
+MNameMapper::getDir( const ::rtl::OUString& str, nsIAbDirectory* *abook )
+{
+ MNameMapper::dirMap::iterator iter;
+
+ OSL_TRACE( "IN MNameMapper::getDir( %s )\n", OUtoCStr(str)?OUtoCStr(str):"NULL" );
+
+ if ( (iter = mDirMap->find( str )) != mDirMap->end() ) {
+ *abook = (*iter).second;
+ NS_IF_ADDREF(*abook);
+ } else {
+ *abook = NULL;
+ }
+
+ OSL_TRACE( "\tOUT MNameMapper::getDir() : %s\n", (*abook)?"True":"False" );
+
+ return( (*abook) != NULL );
+}
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.hxx
new file mode 100644
index 000000000000..eb5d7c97e578
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * 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 _CONNECTIVITY_MAB_NAMEMAPPER_HXX_
+#define _CONNECTIVITY_MAB_NAMEMAPPER_HXX_ 1
+
+#include <map>
+
+// Mozilla includes
+#include <MNSInclude.hxx>
+
+// Star Includes
+#include <rtl/ustring.hxx>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class MNameMapper
+ {
+ private:
+
+ struct ltstr
+ {
+ bool operator()( const ::rtl::OUString &s1, const ::rtl::OUString &s2) const;
+ };
+
+
+ typedef ::std::multimap< ::rtl::OUString, nsIAbDirectory *, ltstr > dirMap;
+ typedef ::std::multimap< ::rtl::OUString, nsIAbDirectory *, ltstr > uriMap;
+
+ static MNameMapper *instance;
+ dirMap *mDirMap;
+ uriMap *mUriMap;
+
+ //clear dirs
+ void clear();
+
+ public:
+ static MNameMapper* getInstance();
+
+ MNameMapper();
+ ~MNameMapper();
+
+ // May modify the name passed in so that it's unique
+ nsresult add( ::rtl::OUString& str, nsIAbDirectory* abook );
+
+ //reset dirs
+ void reset();
+
+ // Get the directory corresponding to str
+ bool getDir( const ::rtl::OUString& str, nsIAbDirectory* *abook );
+
+ };
+
+ }
+}
+
+#endif //_CONNECTIVITY_MAB_NAMEMAPPER_HXX_
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx b/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx
new file mode 100644
index 000000000000..33534979f085
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx
@@ -0,0 +1,823 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <MQueryHelper.hxx>
+#include <MNameMapper.hxx>
+#include <MConnection.hxx>
+#include <connectivity/dbexception.hxx>
+#include "MQuery.hxx"
+#include "MLdapAttributeMap.hxx"
+#include "MTypeConverter.hxx"
+#include "MNSMozabProxy.hxx"
+#include <com/sun/star/uno/Reference.hxx>
+#include <unotools/processfactory.hxx>
+#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
+static NS_DEFINE_CID(kAbDirectoryQueryArgumentsCID, NS_ABDIRECTORYQUERYARGUMENTS_CID);
+static NS_DEFINE_CID(kBooleanConditionStringCID, NS_BOOLEANCONDITIONSTRING_CID);
+static NS_DEFINE_CID(kBooleanExpressionCID, NS_BOOLEANEXPRESSION_CID);
+static NS_DEFINE_CID(kAbDirectoryQueryProxyCID, NS_ABDIRECTORYQUERYPROXY_CID);
+static NS_DEFINE_CID(kAbLDAPAttributeMap, NS_IABLDAPATTRIBUTEMAP_IID);
+
+using namespace connectivity::mozab;
+using namespace connectivity;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace connectivity;
+
+// -------------------------------------------------------------------------
+// Used to store an nsIAbDirectoryQuery member without the need to use Mozilla
+// types in the MQuery.hxx file.
+//
+namespace connectivity {
+ namespace mozab {
+ struct MQueryDirectory {
+ nsCOMPtr<nsIAbDirectory> directory;
+ nsCOMPtr<nsIAbDirectoryQuery> directoryQuery;
+ PRInt32 contextId;
+ MQueryDirectory() : contextId(-1) {}
+ };
+ }
+}
+
+// -------------------------------------------------------------------------
+/*
+MQuery::MQuery()
+{
+ OSL_TRACE( "IN MQuery::MQuery()\n" );
+
+ construct();
+#if OSL_DEBUG_LEVEL > 0
+ m_oThreadID = osl_getThreadIdentifier(NULL);
+#endif
+
+ OSL_TRACE( "\tOUT MQuery::MQuery()\n" );
+}
+*/
+// -------------------------------------------------------------------------
+MQuery::MQuery( const OColumnAlias& _ca )
+ :m_rColumnAlias( _ca )
+{
+ OSL_TRACE( "IN MQuery::MQuery( ca )\n" );
+
+ construct();
+
+#if OSL_DEBUG_LEVEL > 0
+ m_oThreadID = osl_getThreadIdentifier(NULL);
+#endif
+
+ OSL_TRACE( "\tOUT MQuery::MQuery( ca )\n" );
+}
+// -------------------------------------------------------------------------
+MQuery::~MQuery()
+{
+ OSL_TRACE("IN MQuery::~MQuery()\n");
+
+ // MQueryHelper is reference counted, so we need to decrement the
+ // count here.
+ //
+ if ( m_aQueryDirectory->contextId != -1 && m_aQueryDirectory->directoryQuery !=
+ NULL )
+ m_aQueryDirectory->directoryQuery->StopQuery(m_aQueryDirectory->contextId);
+
+ if ( m_aQueryDirectory )
+ delete m_aQueryDirectory;
+
+ NS_IF_RELEASE( m_aQueryHelper);
+
+ OSL_TRACE("\tOUT MQuery::~MQuery()\n");
+}
+// -----------------------------------------------------------------------------
+void MQuery::construct()
+{
+ // Set default values. (For now just as a reminder).
+ m_aError.reset();
+ m_bQuerySubDirs = sal_True; // LDAP Queryies require this to be set!
+ m_nMaxNrOfReturns = -1; // Unlimited number of returns.
+
+ m_aQueryDirectory = new MQueryDirectory();
+ // MQueryHelper is reference counted, so we need to add to the
+ // count here to prevent accidental deletion else where...
+ //
+ m_aQueryHelper = new MQueryHelper();
+ NS_IF_ADDREF( m_aQueryHelper);
+}
+// -------------------------------------------------------------------------
+void MQuery::setAddressbook(::rtl::OUString &ab)
+{
+ OSL_TRACE("IN MQuery::setAddressbook()\n");
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_aAddressbook = ab;
+
+ OSL_TRACE("\tOUT MQuery::setAddressbook()\n");
+}
+// -------------------------------------------------------------------------
+::rtl::OUString MQuery::getAddressbook() const
+{
+ OSL_TRACE("IN MQuery::getAddressbook()\n");
+
+ OSL_TRACE("\tOUT MQuery::getAddressbook()\n");
+
+ return(m_aAddressbook);
+}
+// -------------------------------------------------------------------------
+void MQuery::setMaxNrOfReturns(const sal_Int32 mnr)
+{
+ OSL_TRACE( "IN MQuery::setMaxNrOfReturns()\n" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_nMaxNrOfReturns = mnr;
+ OSL_TRACE("\tOUT MQuery::setMaxNrOfReturns()\n" );
+}
+// -------------------------------------------------------------------------
+sal_Int32 MQuery::getMaxNrOfReturns() const
+{
+ OSL_TRACE("IN MQuery::getMaxNrOfReturns()\n");
+
+ OSL_TRACE("\tOUT MQuery::getMaxNrOfReturns()\n");
+
+ return(m_nMaxNrOfReturns);
+}
+// -------------------------------------------------------------------------
+void MQuery::setQuerySubDirs(sal_Bool &qsd)
+{
+ OSL_TRACE("IN MQuery::setQuerySubDirs()\n");
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_bQuerySubDirs = qsd;
+ OSL_TRACE("\tOUT MQuery::setQuerySubDirs()\n");
+}
+// -------------------------------------------------------------------------
+sal_Bool MQuery::getQuerySubDirs() const
+{
+ OSL_TRACE("IN MQuery::getQuerySubDirs()\n");
+
+ OSL_TRACE("\tOUT MQuery::getQuerySubDirs()\n");
+
+ return(m_bQuerySubDirs);
+}
+// -------------------------------------------------------------------------
+void MQuery::setExpression( MQueryExpression &_expr )
+{
+ OSL_TRACE("IN MQuery::setExpression()\n");
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_aExpr = _expr;
+
+ OSL_TRACE("\tOUT MQuery::setExpression()\n");
+}
+// -------------------------------------------------------------------------
+static sal_Int32 generateExpression( MQuery* _aQuery, MQueryExpression* _aExpr,
+ nsIAbBooleanExpression* queryExpression )
+{
+ nsresult rv; // Store return values.
+ // Array that holds all matchItems, to be passed to DoQuery().
+ nsCOMPtr<nsISupportsArray> matchItems;
+ NS_NewISupportsArray(getter_AddRefs(matchItems));
+
+ // Add every individual boolString to matchItems array.
+ nsString matchValue;
+ // Initialise the matchItems container.
+ MQueryExpression::ExprVector::iterator evIter;
+ for( evIter = _aExpr->getExpressions().begin();
+ evIter != _aExpr->getExpressions().end();
+ ++evIter )
+ {
+ if ( (*evIter)->isStringExpr() ) {
+ nsCOMPtr<nsIAbBooleanConditionString> boolString = do_CreateInstance (kBooleanConditionStringCID, &rv);
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ MQueryExpressionString* evStr = static_cast<MQueryExpressionString*> (*evIter);
+
+ // Set the 'name' property of the boolString.
+ // Check if it's an alias first...
+ rtl::OString attrName = _aQuery->getColumnAlias().getProgrammaticNameOrFallbackToUTF8Alias( evStr->getName() );
+ boolString->SetName( strdup( attrName.getStr() ) );
+ OSL_TRACE("Name = %s ;", attrName.getStr() );
+ // Set the 'matchType' property of the boolString. Check for equal length.
+ sal_Bool requiresValue = sal_True;
+ switch(evStr->getCond()) {
+ case MQueryOp::Exists:
+ OSL_TRACE("MQueryOp::Exists; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::Exists);
+ requiresValue = sal_False;
+ break;
+ case MQueryOp::DoesNotExist:
+ OSL_TRACE("MQueryOp::DoesNotExist; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::DoesNotExist);
+ requiresValue = sal_False;
+ break;
+ case MQueryOp::Contains:
+ OSL_TRACE("MQueryOp::Contains; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::Contains);
+ break;
+ case MQueryOp::DoesNotContain:
+ OSL_TRACE("MQueryOp::DoesNotContain; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::DoesNotContain);
+ break;
+ case MQueryOp::Is:
+ OSL_TRACE("MQueryOp::Is; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::Is);
+ break;
+ case MQueryOp::IsNot:
+ OSL_TRACE("MQueryOp::IsNot; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::IsNot);
+ break;
+ case MQueryOp::BeginsWith:
+ OSL_TRACE("MQueryOp::BeginsWith; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::BeginsWith);
+ break;
+ case MQueryOp::EndsWith:
+ OSL_TRACE("MQueryOp::EndsWith; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::EndsWith);
+ break;
+ case MQueryOp::SoundsLike:
+ OSL_TRACE("MQueryOp::SoundsLike; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::SoundsLike);
+ break;
+ case MQueryOp::RegExp:
+ OSL_TRACE("MQueryOp::RegExp; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::RegExp);
+ break;
+ default:
+ OSL_TRACE("(default) MQueryOp::Is; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::Is);
+ break;
+ }
+ // Set the 'matchValue' property of the boolString. Value returned in unicode.
+ if ( requiresValue )
+ {
+ OSL_TRACE("Value = %s \n", OUtoCStr( evStr->getValue() ) );
+ MTypeConverter::ouStringToNsString( evStr->getValue(), matchValue);
+ boolString->SetValue(matchValue.get ());
+ }
+ // Add the individual boolString to the container of matchItems.
+ matchItems->AppendElement(boolString);
+ }
+ else if ( (*evIter)->isExpr() ) {
+ nsCOMPtr< nsIAbBooleanExpression > subQueryExpr = do_CreateInstance( kBooleanExpressionCID , &rv);
+ NS_ENSURE_SUCCESS( rv, rv );
+ rv = generateExpression( _aQuery, static_cast< MQueryExpression* >(*evIter),
+ subQueryExpr );
+ NS_ENSURE_SUCCESS( rv, rv );
+ matchItems->AppendElement(subQueryExpr);
+ }
+ else {
+ // Should never see this...
+ OSL_ASSERT("Unknown Expression Type!");
+ return( NS_ERROR_UNEXPECTED );
+ }
+ }
+
+ queryExpression->SetExpressions(matchItems);
+ if ( _aExpr->getExpressionCondition() == MQueryExpression::AND )
+ queryExpression->SetOperation(nsIAbBooleanOperationTypes::AND);
+ else
+ queryExpression->SetOperation(nsIAbBooleanOperationTypes::OR);
+
+ return( NS_OK );
+}
+sal_uInt32 MQuery::InsertLoginInfo(OConnection* _pCon)
+{
+ nsresult rv; // Store return values.
+
+ rtl::OUString nameAB = _pCon->getHost().replace('.','_');
+ rtl::OUString bindDN = _pCon->getBindDN();
+ rtl::OUString password = _pCon->getPassword();
+ sal_Bool useSSL = _pCon->getUseSSL();
+
+ nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // create the ldap maxHits entry for the preferences file.
+ // Note: maxHits is applicable to LDAP only in mozilla.
+ nsCAutoString prefName(NS_LITERAL_CSTRING("ldap_2.servers."));
+ const char *pAddressBook = MTypeConverter::ouStringToCCharStringAscii(nameAB.getStr());
+ prefName.Append(pAddressBook);
+
+ if (bindDN.getLength())
+ {
+ nsCAutoString bindPrefName=prefName;
+ bindPrefName.Append(NS_LITERAL_CSTRING(".auth.dn"));
+ rv = prefs->SetCharPref (bindPrefName.get(),
+ MTypeConverter::ouStringToCCharStringAscii( bindDN.getStr() ) );
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCAutoString pwdPrefName=prefName;
+ pwdPrefName.Append(NS_LITERAL_CSTRING(".auth.pwd"));
+ rv = prefs->SetCharPref (pwdPrefName.get(),
+ MTypeConverter::ouStringToCCharStringAscii( password.getStr() ) );
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+ if (useSSL)
+ {
+ nsCAutoString sslPrefName=prefName;
+ sslPrefName.Append(NS_LITERAL_CSTRING(".UseSSL"));
+ rv = prefs->SetBoolPref (sslPrefName.get(),useSSL);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+ return rv;
+}
+
+//determine whether current profile is locked,any error will lead to return true
+sal_Bool isProfileLocked(OConnection* _pCon)
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XMozillaBootstrap > xMozillaBootstrap;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xFactory.is(), "can't get service factory" );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+ xMozillaBootstrap = ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XMozillaBootstrap >(xInstance,::com::sun::star::uno::UNO_QUERY);
+ if (_pCon)
+ return xMozillaBootstrap->isProfileLocked(_pCon->getProduct(),_pCon->getMozProfile());
+ else
+ return xMozillaBootstrap->isCurrentProfileLocked();
+}
+
+
+// -------------------------------------------------------------------------
+sal_Int32 getDirectoryType(const nsIAbDirectory* directory)
+{
+ nsresult retCode;
+ nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)directory, &retCode) ;
+ if (NS_FAILED(retCode)) { return SDBCAddress::Unknown; }
+ const char * uri;
+ retCode=rdfResource->GetValueConst(&uri);
+ if (NS_FAILED(retCode)) { return SDBCAddress::Unknown; }
+ const sal_Char *sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_LDAP );
+ if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0)
+ {
+ return SDBCAddress::LDAP;
+ }
+ sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_MOZILLA );
+ if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0)
+ {
+ return SDBCAddress::Mozilla;
+ }
+ sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_MOZILLA_MDB );
+ if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0)
+ {
+ return SDBCAddress::Mozilla;
+ }
+ sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_OUTLOOK_EXPRESS );
+ if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0)
+ {
+ return SDBCAddress::OutlookExp;
+ }
+ sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_OUTLOOK_MAPI );
+ if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0)
+ {
+ return SDBCAddress::Outlook;
+ }
+ return SDBCAddress::Unknown;
+
+}
+// -------------------------------------------------------------------------
+sal_Bool isForceQueryProxyUsed(const nsIAbDirectory* directory)
+{
+ sal_Int32 nType = getDirectoryType(directory);
+ if (nType == SDBCAddress::Outlook || nType == SDBCAddress::OutlookExp)
+ return sal_True;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 MQuery::commitRow(const sal_Int32 rowIndex)
+{
+ if (!m_aQueryHelper || !m_aQueryDirectory || !m_aQueryDirectory->directoryQuery)
+ return sal_False;
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_COMMIT_CARD;
+ args.argCount = 3;
+ args.arg1 = (void*)m_aQueryHelper;
+ args.arg2 = (void*)&rowIndex;
+ args.arg3 = (void*)m_aQueryDirectory->directory;
+ nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile);
+ m_aError = m_aQueryHelper->getError();
+ return rv;
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 MQuery::deleteRow(const sal_Int32 rowIndex)
+{
+ if (!m_aQueryHelper || !m_aQueryDirectory || !m_aQueryDirectory->directoryQuery)
+ return sal_False;
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_DELETE_CARD;
+ args.argCount = 3;
+ args.arg1 = (void*)m_aQueryHelper;
+ args.arg2 = (void*)&rowIndex;
+ args.arg3 = (void*)m_aQueryDirectory->directory;
+ nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile);
+ m_aError = m_aQueryHelper->getError();
+ return rv;
+
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 MQuery::executeQuery(OConnection* _pCon)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ OSL_TRACE("IN MQuery::executeQuery()\n");
+ m_Product = _pCon->getProduct();
+ m_Profile = _pCon->getMozProfile();
+
+ nsresult rv;
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_EXECUTE_QUERY;
+ args.argCount = 2;
+ args.arg1 = (void*)this;
+ args.arg2 = (void*)_pCon;
+ rv = xMProxy.StartProxy(&args,m_Product,m_Profile);
+ return rv;
+}
+// -------------------------------------------------------------------------
+sal_Int32 MQuery::executeQueryProxied(OConnection* _pCon)
+{
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("IN MQuery::executeQueryProxied() Caller thread: %4d \n", m_oThreadID);
+#endif
+
+ nsresult rv; // Store return values.
+ // MTypeConverter aTypeConverter;
+ // Create a nsIAbDirectory object to initialise the nsIAbDirectoryQuery object.
+ nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv)) ;
+ if (NS_FAILED(rv))
+ return(-1);
+
+ nsCOMPtr<nsIAbDirectory> directory;
+ MNameMapper *nmap = _pCon->getNameMapper();
+
+
+ if ( nmap->getDir( m_aAddressbook, getter_AddRefs( directory ) ) == sal_False )
+ return( -1 );
+
+
+ //insert ldap bind info to mozilla profile(in memery,none saved),so we can use it in mozilla part codes
+ if (_pCon->isLDAP())
+ {
+ rv = InsertLoginInfo(_pCon);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ }
+ // Since Outlook Express and Outlook in OCL mode support a very limited query capability,
+ // we use the following bool to judge whether we need bypass any use of a DirectoryQuery
+ // interface and instead force the use of the QueryProxy.
+ sal_Bool forceQueryProxyUse = isForceQueryProxyUsed(directory);
+
+ m_aQueryDirectory->directory = directory;
+ // Initialize directory in cases of LDAP and Mozilla
+ if (!forceQueryProxyUse) m_aQueryDirectory->directoryQuery = do_QueryInterface(directory, &rv);
+
+ if ( NS_FAILED(rv) || forceQueryProxyUse)
+ {
+ // Create a nsIAbDirectoryQuery object which eventually will execute
+ // the query by calling DoQuery().
+ nsCOMPtr< nsIAbDirectoryQueryProxy > directoryQueryProxy = do_CreateInstance( kAbDirectoryQueryProxyCID, &rv);
+
+ // Need to turn this off for anything using the Query Proxy since it
+ // treats Mailing Lists as directories!
+
+ m_bQuerySubDirs = sal_False;
+
+ rv = directoryQueryProxy->Initiate (directory);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ m_aQueryDirectory->directoryQuery = do_QueryInterface (directoryQueryProxy, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+ OSL_TRACE("Using the directoryQueryProxy\n");
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else
+ OSL_TRACE("Not using a Query Proxy, Query i/f supported by directory\n");
+#endif /* OSL_DEBUG_LEVEL */
+
+ /*
+ // The problem here is that an LDAP Address Book may exist as
+ // a Mozilla Address Book. So we need to limit the number of
+ // records returned by the Server:
+ // 1. Determine if this is an LDAP Address Book
+ // [LDAP overrides the default operations(write|read|search) of all types with search only].
+ // 2. Determine if the limit is already set by us.
+ // 3. Use the mozilla preferences to see if this value is set.
+ // 4. Use value or else default to 100.
+ */
+ PRBool isWriteable;
+ rv = directory->GetOperations (&isWriteable);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (!(isWriteable & nsIAbDirectory::opWrite))
+ {
+ if(m_nMaxNrOfReturns == -1)
+ {
+ // Determine if the limit maxHits has been set in the mozilla preferences
+ // if set, then use the value otherwise default to 100
+ nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // create the ldap maxHits entry for the preferences file.
+ // Note: maxHits is applicable to LDAP only in mozilla.
+ nsCAutoString prefName(NS_LITERAL_CSTRING("ldap_2.servers."));
+ const char *pAddressBook = MTypeConverter::ouStringToCCharStringAscii(m_aAddressbook);
+ prefName.Append(pAddressBook);
+ prefName.Append(NS_LITERAL_CSTRING(".maxHits"));
+
+ PRInt32 maxHits;
+ rv = prefs->GetIntPref(prefName.get(), &maxHits);
+ if (NS_FAILED(rv))
+ m_nMaxNrOfReturns = 100;
+ else
+ m_nMaxNrOfReturns = maxHits;
+ }
+ }
+
+
+ nsCOMPtr< nsIAbBooleanExpression > queryExpression = do_CreateInstance( kBooleanExpressionCID , &rv);
+ NS_ENSURE_SUCCESS( rv, rv );
+ rv = generateExpression( this, &m_aExpr, queryExpression );
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ // Use the nsIAbCard to return the card properties.
+ const char *returnProperties[] = {"card:nsIAbCard"};
+ PRInt32 count=1;
+
+ nsCOMPtr< nsIAbDirectoryQueryArguments > arguments = do_CreateInstance( kAbDirectoryQueryArgumentsCID, &rv);
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ rv = arguments->SetExpression(queryExpression);
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ rv = arguments->SetReturnProperties(count, returnProperties);
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ rv = arguments->SetQuerySubDirectories(m_bQuerySubDirs);
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ nsCOMPtr< nsIAbLDAPAttributeMap > attributeMap( new MLdapAttributeMap );
+ rv = arguments->SetTypeSpecificArg( attributeMap );
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ // Execute the query.
+ OSL_TRACE( "****** calling DoQuery\n");
+
+ m_aError.reset();
+
+ m_aQueryHelper->reset();
+
+ rv = m_aQueryDirectory->directoryQuery->DoQuery(arguments, m_aQueryHelper, m_nMaxNrOfReturns, -1, &m_aQueryDirectory->contextId);
+
+
+ if (NS_FAILED(rv)) {
+ m_aQueryDirectory->contextId = -1;
+ OSL_TRACE( "****** DoQuery failed\n");
+ OSL_TRACE("\tOUT MQuery::executeQueryProxied()\n");
+ m_aQueryHelper->notifyQueryError() ;
+ return(-1);
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else {
+ OSL_TRACE( "****** DoQuery succeeded \n");
+ }
+#endif
+
+ OSL_TRACE("\tOUT MQuery::executeQueryProxied()\n");
+
+ return(0);
+}
+
+// -------------------------------------------------------------------------
+//
+//
+// If the query executed is being done asynchronously then this may return
+// -1 as the count, ie. it's undetermined.
+//
+sal_Int32
+MQuery::getRowCount()
+{
+ return( m_aQueryHelper->getResultCount() );
+}
+
+// -------------------------------------------------------------------------
+//
+//
+// As opposed to getRowCount() this returns the actual number of rows fetched
+// so far (if is an async query)
+//
+sal_uInt32
+MQuery::getRealRowCount()
+{
+ return( m_aQueryHelper->getRealCount() );
+}
+
+//
+// If the query executed is being done asynchronously then this may be
+// false
+//
+sal_Bool
+MQuery::queryComplete( void )
+{
+ return( hadError() || m_aQueryHelper->queryComplete() );
+}
+
+sal_Bool
+MQuery::waitForQueryComplete( void )
+{
+ if( m_aQueryHelper->waitForQueryComplete( ) )
+ return sal_True;
+ m_aError = m_aQueryHelper->getError();
+ return( sal_False );
+}
+
+// -------------------------------------------------------------------------
+
+sal_Bool
+MQuery::checkRowAvailable( sal_Int32 nDBRow )
+{
+ while( !queryComplete() && m_aQueryHelper->getRealCount() <= (sal_uInt32)nDBRow )
+ if ( !m_aQueryHelper->waitForRow( nDBRow ) ) {
+ m_aError = m_aQueryHelper->getError();
+ return( sal_False );
+ }
+
+ return( getRowCount() > nDBRow );
+}
+// -------------------------------------------------------------------------
+sal_Bool
+MQuery::setRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const rtl::OUString& aDBColumnName, sal_Int32 nType ) const
+{
+ MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow );
+
+ OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL");
+ if (xResEntry == NULL )
+ {
+ const_cast< MQuery* >( this )->m_aError = m_aQueryHelper->getError();
+ return sal_False;
+ }
+ switch ( nType )
+ {
+ case DataType::VARCHAR:
+ xResEntry->setValue( m_rColumnAlias.getProgrammaticNameOrFallbackToUTF8Alias( aDBColumnName ), rValue.getString() );
+ break;
+ default:
+ OSL_ENSURE( sal_False, "invalid data type!" );
+ break;
+ }
+
+ return sal_True;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool
+MQuery::getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const rtl::OUString& aDBColumnName, sal_Int32 nType ) const
+{
+ MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow );
+
+ OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL");
+ if (xResEntry == NULL )
+ {
+ const_cast< MQuery* >( this )->m_aError = m_aQueryHelper->getError();
+ rValue.setNull();
+ return sal_False;
+ }
+ switch ( nType )
+ {
+ case DataType::VARCHAR:
+ rValue = xResEntry->getValue( m_rColumnAlias.getProgrammaticNameOrFallbackToUTF8Alias( aDBColumnName ) );
+ break;
+
+ default:
+ rValue.setNull();
+ break;
+ }
+
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32
+MQuery::getRowStates(sal_Int32 nDBRow)
+{
+ MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow );
+
+ OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL");
+ if (xResEntry == NULL )
+ {
+ m_aError = m_aQueryHelper->getError();
+ return RowStates_Error;
+ }
+ return xResEntry->getRowStates();
+}
+sal_Bool
+MQuery::setRowStates(sal_Int32 nDBRow,sal_Int32 aState)
+{
+ MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow );
+
+ OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL");
+ if (xResEntry == NULL )
+ {
+ m_aError = m_aQueryHelper->getError();
+ return sal_False;
+ }
+ return xResEntry->setRowStates(aState);
+}
+
+sal_Bool
+MQuery::resyncRow(sal_Int32 nDBRow)
+{
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_RESYNC_CARD;
+ args.argCount = 2;
+ args.arg1 = (void*)m_aQueryHelper;
+ args.arg2 = (void*)&nDBRow;
+ nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile);
+ m_aError = m_aQueryHelper->getError();
+ return NS_SUCCEEDED( rv ) ? sal_True : sal_False;
+}
+
+sal_Int32
+MQuery::createNewCard()
+{
+ sal_Int32 nNumber = 0;
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_CREATE_NEW_CARD;
+ args.argCount = 2;
+ args.arg1 = (void*)m_aQueryHelper;
+ args.arg2 = (void*)&nNumber;
+ nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile);
+
+ m_aError = m_aQueryHelper->getError();
+ NS_ENSURE_SUCCESS(rv,0);
+ return nNumber;
+}
+// -------------------------------------------------------------------------
+
+MNameMapper*
+MQuery::CreateNameMapper()
+{
+ return( new MNameMapper() );
+}
+
+// -------------------------------------------------------------------------
+void
+MQuery::FreeNameMapper( MNameMapper* _ptr )
+{
+ delete _ptr;
+}
+// -------------------------------------------------------------------------
+sal_Bool MQuery::isWritable(OConnection* _pCon)
+{
+ if ( !m_aQueryDirectory )
+ return sal_False;
+
+ nsresult rv; // Store return values.
+ nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(m_aQueryDirectory->directory, &rv);;
+ if (NS_FAILED(rv))
+ return sal_False;
+ if (getDirectoryType(directory) == SDBCAddress::Mozilla && isProfileLocked(_pCon))
+ return sal_False;
+
+ PRBool isWriteable;
+ rv = directory->GetOperations (&isWriteable);
+ if (NS_FAILED(rv))
+ return sal_False;
+ sal_Bool bWritable = ( isWriteable & nsIAbDirectory::opWrite ) == nsIAbDirectory::opWrite;
+ return bWritable;
+}
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx b/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx
new file mode 100644
index 000000000000..8d7d52e6eb97
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx
@@ -0,0 +1,282 @@
+/*************************************************************************
+ *
+ * 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 _CONNECTIVITY_MAB_QUERY_HXX_
+#define _CONNECTIVITY_MAB_QUERY_HXX_
+
+#include "MColumnAlias.hxx"
+#include "MErrorResource.hxx"
+#include <connectivity/FValue.hxx>
+#include "MNSDeclares.hxx"
+#include <osl/thread.hxx>
+#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+#endif
+
+namespace connectivity
+{
+ namespace mozab
+ {
+
+ class MQueryHelper;
+ struct MQueryDirectory;
+
+ namespace MQueryOp {
+ typedef enum {
+ Exists = 0,
+ DoesNotExist = 1,
+ Contains = 2,
+ DoesNotContain = 3,
+ Is = 4,
+ IsNot = 5,
+ BeginsWith = 6,
+ EndsWith = 7,
+ SoundsLike = 8,
+ RegExp = 9
+ } cond_type;
+ }
+
+ class MQueryExpressionBase {
+ public:
+ typedef enum {
+ Unknown,
+ StringExpr,
+ Expr
+ } node_type;
+
+ protected:
+ node_type m_eNodeType;
+
+ MQueryExpressionBase() : m_eNodeType( Unknown ) {}
+ MQueryExpressionBase( node_type _eNodeType ) : m_eNodeType( _eNodeType ) {}
+
+ public:
+ sal_Bool isUnknown( ) { return m_eNodeType == Unknown; }
+ sal_Bool isStringExpr( ) { return m_eNodeType == StringExpr; }
+ sal_Bool isExpr( ) { return m_eNodeType == Expr; }
+ };
+
+ class MQueryExpressionString : public MQueryExpressionBase {
+ protected:
+ ::rtl::OUString m_aName; // LHS
+ MQueryOp::cond_type m_aBooleanCondition;
+ ::rtl::OUString m_aValue; // RHS
+
+ public:
+
+ MQueryExpressionString( ::rtl::OUString& lhs,
+ MQueryOp::cond_type cond,
+ ::rtl::OUString rhs )
+ : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
+ , m_aName( lhs )
+ , m_aBooleanCondition( cond )
+ , m_aValue( rhs )
+ {
+ }
+
+ MQueryExpressionString( ::rtl::OUString& lhs,
+ MQueryOp::cond_type cond )
+ : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
+ , m_aName( lhs )
+ , m_aBooleanCondition( cond )
+ , m_aValue( ::rtl::OUString() )
+ {
+ }
+
+ const ::rtl::OUString& getName() const { return m_aName; }
+ MQueryOp::cond_type getCond() const { return m_aBooleanCondition; }
+ const ::rtl::OUString& getValue() const { return m_aValue; }
+ };
+
+ class MQuery;
+
+ class MQueryExpression : public MQueryExpressionBase
+ {
+ friend class MQuery;
+
+ public:
+ typedef ::std::vector< MQueryExpressionBase* > ExprVector;
+
+ typedef enum {
+ AND,
+ OR
+ } bool_cond;
+
+ void setExpressions( ExprVector& _exprVector )
+ { m_aExprVector = _exprVector; }
+
+ // All expressions on a peer level use same condition operator
+ void setExpressionCondition( bool_cond _cond )
+ { m_aExprCondType = _cond; }
+
+ ExprVector& getExpressions( )
+ { return m_aExprVector; }
+
+ // All expressions on a peer level use same condition operator
+ bool_cond getExpressionCondition( )
+ { return m_aExprCondType; }
+
+ MQueryExpression() : MQueryExpressionBase( MQueryExpressionBase::Expr ),
+ m_aExprCondType( OR )
+ { m_aExprVector.clear(); }
+
+
+ protected:
+ ExprVector m_aExprVector;
+ bool_cond m_aExprCondType;
+
+ };
+
+
+ class MQuery
+ {
+ /*
+ * A query resultset with a maximum limit of
+ * m_nMaxNrOfReturns return items, is created from
+ * the following SQL statement:
+ *
+ * -------------------------------------------------
+ * SELECT m_aAttributes FROM m_aAddressbook
+ * WHERE m_aMatchItems SQL_OPR m_aMatchValue
+ * -------------------------------------------------
+ *
+ * We are\are not, depending on boolean m_bQuerySubDirs,
+ * interested in querying the sub-directories of the
+ * addressbook directory, if any.
+ *
+ * SQL_OPR:
+ * m_aSqlOppr contains the SQL operations for every
+ * attribute in m_aAttributes.
+ * This member must be initialised together with
+ * m_aAttributes.
+ *
+ * The SQL operations defined for 'SQL_OPR' are:
+ * matchExists = 0,
+ * matchDoesNotExist = 1,
+ * matchContains = 2,
+ * matchDoesNotContain = 3,
+ * matchIs = 4,
+ * matchIsNot = 5,
+ * matchBeginsWith = 6,
+ * matchEndsWith = 7,
+ * matchSoundsLike = 8,
+ * matchRegExp = 9.
+ * There must be mapping to one of these values.
+ *
+ * The following members MUST be initialised before
+ * a query is executed:
+ * m_Attributes, m_aMapAttrOppr, m_aAddressbook,
+ * m_aMatchItems and m_aMatchValue.
+ *
+ * m_bQuerySubDirs and m_nMaxNrReturns are set to a
+ * default value in the constructor which can be
+ * overridden. If (element of) m_aSqlOppr is not set,
+ * the default SQL operation is 'matchIs'.
+ *
+ */
+ private:
+ MQueryDirectory *m_aQueryDirectory;
+ MQueryHelper *m_aQueryHelper;
+ ::rtl::OUString m_aAddressbook;
+ sal_Int32 m_nMaxNrOfReturns;
+ sal_Bool m_bQuerySubDirs;
+ MQueryExpression m_aExpr;
+ const OColumnAlias& m_rColumnAlias;
+ ::com::sun::star::mozilla::MozillaProductType
+ m_Product;
+ ::rtl::OUString m_Profile;
+ ErrorDescriptor m_aError;
+
+ void construct();
+ protected:
+ ::osl::Mutex m_aMutex;
+#if OSL_DEBUG_LEVEL > 0
+ oslThreadIdentifier m_oThreadID;
+#endif
+
+ public:
+ /*
+ * - Contains accessors to the members of this class.
+ * - executeQuery() initiates a non-blocking query.
+ */
+ sal_Int32 executeQuery(OConnection* _pCon);
+ sal_Int32 executeQueryProxied(OConnection* _pCon); //Used only by MNSMozabProxy
+
+ sal_Int32 createNewCard(); //return Row count number
+ sal_Int32 deleteRow(const sal_Int32 rowIndex);
+ sal_Int32 commitRow(const sal_Int32 rowIndex);
+ sal_Bool resyncRow(sal_Int32 nDBRow);
+
+ sal_Bool isWritable(OConnection* _pCon);
+
+ sal_uInt32 InsertLoginInfo(OConnection* _pCon);
+
+ void setAddressbook( ::rtl::OUString&);
+ ::rtl::OUString getAddressbook(void) const;
+
+ const OColumnAlias& getColumnAlias() const { return m_rColumnAlias; }
+
+ void setExpression( MQueryExpression &_expr );
+
+ void setMaxNrOfReturns( const sal_Int32);
+ sal_Int32 getMaxNrOfReturns(void) const;
+
+ void setQuerySubDirs( sal_Bool&);
+ sal_Bool getQuerySubDirs(void) const;
+
+ sal_Int32 getRowCount( void );
+ sal_uInt32 getRealRowCount( void );
+ sal_Bool queryComplete( void );
+ sal_Bool waitForQueryComplete( void );
+ sal_Bool checkRowAvailable( sal_Int32 nDBRow );
+ sal_Bool getRowValue( connectivity::ORowSetValue& rValue,
+ sal_Int32 nDBRow,
+ const rtl::OUString& aDBColumnName,
+ sal_Int32 nType ) const;
+ sal_Bool setRowValue( connectivity::ORowSetValue& rValue,
+ sal_Int32 nDBRow,
+ const rtl::OUString& aDBColumnName,
+ sal_Int32 nType ) const;
+ sal_Int32 getRowStates(sal_Int32 nDBRow);
+ sal_Bool setRowStates(sal_Int32 nDBRow,sal_Int32 aState);
+
+ bool hadError() const { return m_aError.is(); }
+ inline const ErrorDescriptor& getError() const { return m_aError; }
+
+ public:
+// MQuery();
+ MQuery( const OColumnAlias& _ca );
+ virtual ~MQuery();
+ static MNameMapper* CreateNameMapper();
+ static void FreeNameMapper( MNameMapper* _ptr );
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MAB_QUERY_HXX_
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx
new file mode 100644
index 000000000000..f63336870d95
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx
@@ -0,0 +1,635 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MQueryHelper.hxx"
+#include "MTypeConverter.hxx"
+#include "MConnection.hxx"
+#include "MNSDeclares.hxx"
+#include "MLdapAttributeMap.hxx"
+
+#include <connectivity/dbexception.hxx>
+
+#include "resource/mozab_res.hrc"
+
+using namespace connectivity::mozab;
+
+
+NS_IMPL_THREADSAFE_ISUPPORTS1(connectivity::mozab::MQueryHelper,nsIAbDirectoryQueryResultListener)
+
+//
+// class MQueryHelperResultEntry
+//
+
+
+MQueryHelperResultEntry::MQueryHelperResultEntry()
+{
+ m_Card = NULL;
+ m_RowStates = 0;
+}
+
+MQueryHelperResultEntry::~MQueryHelperResultEntry()
+{
+ OSL_TRACE("IN MQueryHelperResultEntry::~MQueryHelperResultEntry()\n");
+ OSL_TRACE("OUT MQueryHelperResultEntry::~MQueryHelperResultEntry()\n");
+
+}
+void
+MQueryHelperResultEntry::setCard(nsIAbCard *card)
+{
+ m_Card = card;
+}
+nsIAbCard *
+MQueryHelperResultEntry::getCard()
+{
+ return m_Card;
+}
+void MQueryHelperResultEntry::insert( const rtl::OString &key, rtl::OUString &value )
+{
+ m_Fields[ key ] = value;
+}
+
+rtl::OUString MQueryHelperResultEntry::getValue( const rtl::OString &key ) const
+{
+ FieldMap::const_iterator iter = m_Fields.find( key );
+ if ( iter == m_Fields.end() )
+ {
+ return rtl::OUString();
+ }
+ else
+ {
+ return iter->second;
+ }
+}
+
+void MQueryHelperResultEntry::setValue( const rtl::OString &key, const rtl::OUString & rValue)
+{
+ m_Fields[ key ] = rValue;
+}
+//
+// class MQueryHelper
+//
+MQueryHelper::MQueryHelper()
+ :m_nIndex( 0 )
+ ,m_bHasMore( sal_True )
+ ,m_bAtEnd( sal_False )
+ ,m_bErrorCondition( sal_False )
+ ,m_bQueryComplete( sal_False )
+ ,mRefCnt( 0 ) // NSISUPPORTS - Initialize RefCnt to 0
+{
+ m_aResults.clear();
+#if OSL_DEBUG_LEVEL > 0
+ m_oThreadID = osl_getThreadIdentifier(NULL);
+#endif
+}
+
+MQueryHelper::~MQueryHelper()
+{
+ OSL_TRACE("IN MQueryHelper::~MQueryHelper()\n");
+ clear_results();
+ OSL_TRACE("OUT MQueryHelper::~MQueryHelper()\n");
+}
+
+void
+MQueryHelper::append(MQueryHelperResultEntry* resEnt )
+{
+ if ( resEnt != NULL ) {
+ m_aResults.push_back( resEnt );
+ m_bAtEnd = sal_False;
+ }
+}
+
+void
+MQueryHelper::clear_results()
+{
+ resultsArray::iterator iter = m_aResults.begin();
+ while ( iter != m_aResults.end() ) {
+ delete (*iter);
+ ++iter;
+ }
+ m_aResults.clear();
+}
+
+void
+MQueryHelper::rewind()
+{
+ m_nIndex = 0;
+}
+
+void
+MQueryHelper::reset()
+{
+ m_nIndex = 0;
+ m_bHasMore = sal_True;
+ m_bQueryComplete = sal_False;
+ m_bAtEnd = sal_False;
+ m_bErrorCondition = sal_False;
+ clear_results();
+}
+
+void
+MQueryHelper::clearResultOrComplete()
+{
+ // Don't use a Mutex, it should be called by a method already holding it.
+ OSL_TRACE("In/Out : clearResultOrComplete()");
+ m_aCondition.reset();
+}
+
+void
+MQueryHelper::notifyResultOrComplete()
+{
+ OSL_TRACE("In/Out : notifyResultOrComplete()");
+ m_aCondition.set();
+}
+
+sal_Bool
+MQueryHelper::waitForResultOrComplete( )
+{
+ TimeValue timeValue = { 1, 0 }; // 20 Seconds 0 NanoSecond timeout
+ sal_Int32 times=0;
+ osl::Condition::Result rv = ::osl::Condition::result_ok;
+
+ OSL_TRACE("In : waitForResultOrComplete()");
+ // Can't hold mutex or condition would never get set...
+ while( (m_aCondition.check() == sal_False || rv == ::osl::Condition::result_error) && times < 20) {
+ rv = m_aCondition.wait( &timeValue );
+ times ++;
+ }
+ if (times >= 20 && rv == ::osl::Condition::result_timeout ) {
+ OSL_TRACE("waitForResultOrComplete() : Timeout!");
+ m_aError.setResId( STR_TIMEOUT_WAITING );
+ return sal_False;
+ }
+
+ if ( isError() ) {
+ OSL_TRACE("waitForResultOrComplete() : Error returned!");
+ m_aError.setResId( STR_ERR_EXECUTING_QUERY );
+ return sal_False;
+ }
+ m_aError.reset();
+ OSL_TRACE(" Out : waitForResultOrComplete()");
+ return sal_True;
+}
+
+
+MQueryHelperResultEntry*
+MQueryHelper::next( )
+{
+ MQueryHelperResultEntry* result;
+ sal_Int32 index;
+
+ m_aMutex.acquire();
+ index = m_nIndex;
+ m_aMutex.release();
+
+ result = getByIndex( m_nIndex + 1) ; // Add 1 as Row is numbered from 1 to N
+
+ if ( result ) {
+ m_aMutex.acquire();
+ m_nIndex++;
+ m_aMutex.release();
+ }
+
+ return( result );
+}
+
+MQueryHelperResultEntry*
+MQueryHelper::getByIndex( sal_uInt32 nRow )
+{
+ // Row numbers are from 1 to N, need to ensure this, and then
+ // substract 1
+ if ( nRow < 1 ) {
+ return( NULL );
+ }
+
+ do {
+ // Obtain the Mutex - don't use a guard as we want to be able to release
+ // and acquire again...
+ m_aMutex.acquire();
+ if ( nRow > m_aResults.size() )
+ {
+ if ( m_bQueryComplete )
+ {
+ m_bAtEnd = sal_True;
+ m_aMutex.release();
+ return( NULL );
+ }
+ else
+ {
+ clearResultOrComplete();
+ m_aMutex.release();
+ if ( !waitForResultOrComplete( ) )
+ return( NULL );
+ }
+ }
+ else
+ {
+ m_aMutex.release();
+ return( m_aResults[ nRow -1 ] );
+ }
+ } while ( sal_True );
+}
+
+sal_Bool
+MQueryHelper::hasMore() const
+{
+ return m_bHasMore;
+}
+
+sal_Bool
+MQueryHelper::atEnd() const
+{
+ return m_bAtEnd;
+}
+
+sal_Bool
+MQueryHelper::isError() const
+{
+ return m_bErrorCondition;
+}
+
+sal_Bool
+MQueryHelper::queryComplete() const
+{
+ return m_bQueryComplete;
+}
+
+sal_Bool
+MQueryHelper::waitForQueryComplete( )
+{
+ m_aMutex.acquire();
+
+ OSL_TRACE("In : waitForQueryComplete()");
+ if ( ! m_bQueryComplete ) {
+ do
+ {
+ m_aMutex.release();
+ clearResultOrComplete();
+ if ( !waitForResultOrComplete( ) )
+ return( sal_False );
+ m_aMutex.acquire();
+ }
+ while ( !m_bQueryComplete );
+ }
+
+ m_aMutex.release();
+ OSL_TRACE("Out : waitForQueryComplete()");
+ return( sal_True );
+}
+
+sal_Bool
+MQueryHelper::waitForRow( sal_Int32 rowNum )
+{
+ m_aMutex.acquire();
+ do
+ {
+ m_aMutex.release();
+ clearResultOrComplete();
+ if ( !waitForResultOrComplete() )
+ return( sal_False );
+ m_aMutex.acquire();
+ }
+ while ( !m_bQueryComplete && m_aResults.size() < (size_t)rowNum );
+
+ m_aMutex.release();
+ return( sal_True );
+}
+
+// -------------------------------------------------------------------------
+
+sal_Int32
+MQueryHelper::getResultCount() const
+{
+ OSL_TRACE( "IN MQueryHelper::getResultCount()" );
+ if ( !m_bQueryComplete )
+ {
+ OSL_TRACE( "\tOUT MQueryHelper::getResultCount() = -1\n");
+ return -1;
+ }
+ else
+ {
+ OSL_TRACE( "\tOUT MQueryHelper::getResultCount() = %d\n", m_aResults.size() );
+ return static_cast<sal_Int32>(m_aResults.size());
+ }
+}
+
+// -------------------------------------------------------------------------
+
+sal_uInt32
+MQueryHelper::getRealCount() const
+{
+ OSL_TRACE( "IN/OUT MQueryHelper::getRealCount() = %d\n", m_aResults.size() );
+ return static_cast<sal_Int32>(m_aResults.size());
+}
+
+// -------------------------------------------------------------------------
+NS_IMETHODIMP MQueryHelper::OnQueryItem(nsIAbDirectoryQueryResult *result)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE( "IN MQueryHelper::OnQueryItem() Caller thread: %4d \n",m_oThreadID );
+#endif
+ nsresult rv;
+ PRInt32 resultType;
+
+ if ( result == NULL ) {
+ OSL_TRACE("\tresult ptr is NULL\n");
+ return NS_OK;
+ }
+
+ // Get return status of executeQuery() call.
+ rv = result -> GetType(&resultType);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // Check for errors of the executeQuery() call.
+ switch ( resultType ) {
+ case nsIAbDirectoryQueryResult::queryResultError:
+ OSL_TRACE("\tresultType == nsIAbDirectoryQueryResult::queryResultError\n");
+ m_bQueryComplete = sal_True;
+ m_bErrorCondition = sal_True;
+ notifyResultOrComplete();
+ return NS_OK;
+ case nsIAbDirectoryQueryResult::queryResultStopped:
+ OSL_TRACE("\tresultType == nsIAbDirectoryQueryResult::queryResultStopped\n");
+ m_bQueryComplete = sal_True;
+ notifyResultOrComplete();
+ return NS_OK;
+ case nsIAbDirectoryQueryResult::queryResultComplete:
+ OSL_TRACE("\tresultType == nsIAbDirectoryQueryResult::queryResultComplete\n");
+ m_bQueryComplete = sal_True;
+ notifyResultOrComplete();
+ return NS_OK;
+ case nsIAbDirectoryQueryResult::queryResultMatch:
+ OSL_TRACE("IN MQueryHelper::OnQueryItem --> queryResultMatch\n");
+ // Don't return, continues onto rest of method.
+ break;
+ default:
+ OSL_TRACE("\t******** Unexpected : resultType\n");
+ m_bQueryComplete = sal_True;
+ return NS_OK;
+ }
+
+ // Initialise an array that holds the resultset of the query.
+ nsCOMPtr<nsISupportsArray> properties;
+ rv = result -> GetResult(getter_AddRefs (properties));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+
+ nsCOMPtr<nsISupports> item;
+ rv = properties -> GetElementAt(0, getter_AddRefs(item));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsIAbDirectoryQueryPropertyValue> property(do_QueryInterface(item, &rv));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ char *name;
+ rv = property -> GetName(&name);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if ( !strcmp(name,"card:nsIAbCard") )
+ {
+ nsCOMPtr<nsISupports> cardSupports;
+ property->GetValueISupports (getter_AddRefs (cardSupports));
+ nsCOMPtr<nsIAbCard> card(do_QueryInterface(cardSupports, &rv));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ getCardValues(card);
+ }
+ nsMemory::Free(name);
+
+ OSL_TRACE( "\tOUT MQueryHelper::OnQueryItem()\n" );
+
+ notifyResultOrComplete();
+
+ return(NS_OK);
+}
+
+// -----------------------------------------------------------------------------
+void MQueryHelper::notifyQueryError()
+{
+ m_bQueryComplete = sal_True ;
+ notifyResultOrComplete() ;
+}
+
+const char * getAddrURI(const nsIAbDirectory* directory)
+{
+ nsresult retCode;
+ nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)directory, &retCode) ;
+ if (NS_FAILED(retCode)) { return NULL; }
+ const char * uri;
+ retCode=rdfResource->GetValueConst(&uri);
+ if (NS_FAILED(retCode)) { return NULL; }
+ return uri;
+ }
+
+#define ENSURE_GETUPDATECARD(x) \
+ if (NS_FAILED(retCode)) \
+ { \
+ OSL_TRACE( x ); \
+ return card; \
+ }
+static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
+
+//Some address book does not support query uri on card
+//In this case, we can't resync the cards, we just return the old cards
+nsIAbCard * getUpdatedCard( nsIAbCard* card)
+{
+ OSL_ENSURE(card != NULL, "getUpdatedCard for NULL");
+ nsresult retCode;
+ nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)card, &retCode) ;
+ ENSURE_GETUPDATECARD( "IN getUpdatedCard: Card does not support nsIRDFResource\n" );
+
+ const char * uri;
+ retCode=rdfResource->GetValueConst(&uri);
+ ENSURE_GETUPDATECARD( "IN getUpdatedCard: Card does not has a uri\n" );
+
+ nsCOMPtr<nsIRDFService> rdfService (do_GetService(kRDFServiceCID, &retCode)) ;
+ ENSURE_GETUPDATECARD( "IN getUpdatedCard: Card does not has a uri\n" );
+
+ nsCOMPtr<nsIRDFResource> rdfCard;
+
+ retCode = rdfService->GetResource(nsDependentCString(uri), getter_AddRefs(rdfCard)) ;
+ ENSURE_GETUPDATECARD( "IN getUpdatedCard: Can not get the updated card\n" );
+
+ nsCOMPtr<nsIAbCard> aNewCard=do_QueryInterface((nsISupports *)rdfCard, &retCode);
+ ENSURE_GETUPDATECARD( "IN getUpdatedCard: Error in get new card\n" );
+
+ return aNewCard;
+ }
+
+#define ENSURE_MOZAB_PROFILE_NOT_LOOKED(directory) \
+ if (getDirectoryType(directory) == SDBCAddress::Mozilla && isProfileLocked(NULL)) \
+ { \
+ m_aError.setResId( STR_MOZILLA_IS_RUNNIG_NO_CHANGES ); \
+ return sal_False; \
+ }
+
+sal_Int32 MQueryHelper::commitCard(const sal_Int32 rowIndex,nsIAbDirectory * directory)
+{
+ ENSURE_MOZAB_PROFILE_NOT_LOOKED(directory);
+
+ MQueryHelperResultEntry *resEntry = getByIndex(rowIndex);
+ if (!resEntry)
+ {
+ return sal_False;
+ }
+ nsIAbCard *card=resEntry->getCard();
+ if (!card)
+ {
+ return sal_False;
+ }
+ nsresult rv;
+ PRBool hasCard;
+ rv = directory->HasCard(card,&hasCard);
+ if (setCardValues(rowIndex) != sal_True)
+ return sal_False;
+
+ if (!NS_FAILED(rv) && hasCard)
+ {
+ rv = card->EditCardToDatabase(getAddrURI(directory));
+ }
+ else
+ {
+ nsIAbCard *addedCard=NULL;
+ rv = directory->AddCard(card,&addedCard);
+ if (!NS_FAILED(rv))
+ resEntry->setCard(addedCard);
+ }
+ //We return NS_ERROR_FILE_ACCESS_DENIED in the case the mozillaAB has been changed out side of our process
+ if (rv == NS_ERROR_FILE_ACCESS_DENIED )
+ m_aError.setResId( STR_FOREIGN_PROCESS_CHANGED_AB );
+
+ return !(NS_FAILED(rv));
+}
+
+sal_Int32 MQueryHelper::deleteCard(const sal_Int32 rowIndex,nsIAbDirectory * directory)
+{
+ ENSURE_MOZAB_PROFILE_NOT_LOOKED(directory);
+ MQueryHelperResultEntry *resEntry = getByIndex(rowIndex);
+ if (!resEntry)
+ {
+ return sal_False;
+ }
+ nsIAbCard *card=resEntry->getCard();
+ if (!card)
+ {
+ return sal_False;
+ }
+ nsresult rv;
+ PRBool hasCard;
+ if (resEntry->getRowStates() == RowStates_Inserted)
+ {
+ rv = 0;
+ hasCard = sal_True;
+ }
+ else
+ rv = directory->HasCard(card,&hasCard);
+
+ if (!NS_FAILED(rv) && hasCard)
+ {
+ nsCOMPtr <nsISupportsArray> cardsToDelete;
+ rv = NS_NewISupportsArray(getter_AddRefs(cardsToDelete));
+ if (NS_SUCCEEDED(rv))
+ {
+ nsCOMPtr<nsISupports> supports = do_QueryInterface(card, &rv);
+ if (NS_SUCCEEDED(rv))
+ {
+ rv = cardsToDelete->AppendElement(supports);
+ if (NS_SUCCEEDED(rv))
+ rv = directory->DeleteCards(cardsToDelete);
+ }
+ }
+ }
+
+ if (NS_SUCCEEDED(rv))
+ resEntry->setRowStates(RowStates_Deleted);
+ //We return NS_ERROR_FILE_ACCESS_DENIED in the case the mozillaAB has been changed out side of our process
+ if (rv == NS_ERROR_FILE_ACCESS_DENIED )
+ m_aError.setResId( STR_FOREIGN_PROCESS_CHANGED_AB );
+ return !(NS_FAILED(rv));
+}
+
+sal_Bool MQueryHelper::setCardValues(const sal_Int32 rowIndex)
+{
+ MQueryHelperResultEntry *resEntry = getByIndex(rowIndex);
+ if (!resEntry)
+ {
+ m_aError.setResId( STR_CANT_FIND_ROW );
+ return sal_False;
+ }
+ nsIAbCard *card=resEntry->getCard();
+ if (!card)
+ {
+ m_aError.setResId( STR_CANT_FIND_CARD_FOR_ROW );
+ return sal_False;
+ }
+
+ MLdapAttributeMap::fillCardFromResult( *card, *resEntry );
+ return sal_True;
+}
+
+void MQueryHelper::getCardValues(nsIAbCard *card,sal_Int32 rowIndex)
+{
+ MQueryHelperResultEntry *resEntry;
+ if (rowIndex>0)
+ {
+ resEntry = getByIndex(rowIndex);
+ }
+ else
+ resEntry = new MQueryHelperResultEntry();
+
+ MLdapAttributeMap::fillResultFromCard( *resEntry, *card );
+ resEntry->setCard(card);
+ if (!rowIndex)
+ append( resEntry );
+}
+sal_Bool MQueryHelper::resyncRow(sal_Int32 rowIndex)
+{
+
+ MQueryHelperResultEntry *resEntry = getByIndex(rowIndex);
+ if (!resEntry)
+ {
+ m_aError.setResId( STR_CANT_FIND_ROW );
+ return sal_False;
+ }
+ nsIAbCard *card=resEntry->getCard();
+ card = getUpdatedCard(card);
+ getCardValues(card,rowIndex);
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 MQueryHelper::createNewCard()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ nsresult rv;
+ nsCOMPtr <nsIAbCard> card = do_CreateInstance(NS_ABCARDPROPERTY_CONTRACTID, &rv);
+ //set default values
+ getCardValues(card);
+ return static_cast<sal_Int32>(m_aResults.size());
+}
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx
new file mode 100644
index 000000000000..233b57a7fe6d
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * 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 _CONNECTIVITY_MAB_QUERYHELPER_HXX_
+#define _CONNECTIVITY_MAB_QUERYHELPER_HXX_
+
+#include <MNSInclude.hxx>
+#include "MErrorResource.hxx"
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+#include <comphelper/stl_types.hxx>
+#include <osl/thread.hxx>
+
+#include <hash_map>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class MQueryHelperResultEntry
+ {
+ private:
+ typedef ::std::hash_map< ::rtl::OString, ::rtl::OUString, ::rtl::OStringHash > FieldMap;
+
+ mutable ::osl::Mutex m_aMutex;
+ FieldMap m_Fields;
+ nsCOMPtr<nsIAbCard> m_Card;
+ sal_Int32 m_RowStates;
+
+ public:
+ MQueryHelperResultEntry();
+ ~MQueryHelperResultEntry();
+
+ void insert( const rtl::OString &key, rtl::OUString &value );
+ rtl::OUString getValue( const rtl::OString &key ) const;
+ void setValue( const rtl::OString &key, const rtl::OUString & rValue);
+
+ void setCard(nsIAbCard *card);
+ nsIAbCard *getCard();
+ sal_Bool setRowStates(sal_Int32 state){m_RowStates = state; return sal_True;};
+ sal_Int32 getRowStates() { return m_RowStates;};
+ };
+
+ class MQueryHelper : public nsIAbDirectoryQueryResultListener
+ {
+ private:
+ typedef std::vector< MQueryHelperResultEntry* > resultsArray;
+
+ mutable ::osl::Mutex m_aMutex;
+ ::osl::Condition m_aCondition;
+ resultsArray m_aResults;
+ sal_Int32 m_nIndex;
+ sal_Bool m_bHasMore;
+ sal_Bool m_bAtEnd;
+ sal_Bool m_bErrorCondition;
+ sal_Bool m_bQueryComplete;
+ ErrorDescriptor m_aError;
+
+ void append(MQueryHelperResultEntry* resEnt );
+
+ void clear_results();
+
+ void clearResultOrComplete();
+ void notifyResultOrComplete();
+ sal_Bool waitForResultOrComplete( );
+ void getCardValues(nsIAbCard *card,sal_Int32 rowIndex=0);
+#if OSL_DEBUG_LEVEL > 0
+ oslThreadIdentifier m_oThreadID;
+#endif
+
+ public:
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIABDIRECTORYQUERYRESULTLISTENER
+
+ MQueryHelper();
+
+ virtual ~MQueryHelper();
+
+ void reset();
+
+ void rewind();
+
+ MQueryHelperResultEntry* next( );
+
+ MQueryHelperResultEntry* getByIndex( sal_uInt32 nRow );
+
+ const ErrorDescriptor& getError() const { return m_aError; }
+
+ sal_Bool isError() const;
+
+ sal_Bool hasMore() const;
+
+ sal_Bool atEnd() const;
+
+ sal_Bool queryComplete() const;
+
+ sal_Bool waitForQueryComplete( );
+
+ sal_Bool waitForRow( sal_Int32 rowNum );
+
+ sal_Int32 getResultCount() const;
+
+ sal_uInt32 getRealCount() const;
+ sal_Int32 createNewCard(); //return Row count number
+ sal_Bool resyncRow(sal_Int32 rowIndex);
+
+ void notifyQueryError() ;
+ sal_Bool setCardValues(const sal_Int32 rowIndex);
+ sal_Int32 commitCard(const sal_Int32 rowIndex, nsIAbDirectory * directory);
+ sal_Int32 deleteCard(const sal_Int32 rowIndex, nsIAbDirectory * directory);
+ };
+ }
+}
+#endif // _CONNECTIVITY_MAB_QUERYHELPER_HXX_
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.cxx b/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.cxx
new file mode 100644
index 000000000000..b0c422031475
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.cxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <MNSInclude.hxx>
+#include "MTypeConverter.hxx"
+#include <ucbhelper/content.hxx>
+
+using namespace connectivity::mozab;
+
+// -------------------------------------------------------------------------
+void MTypeConverter::ouStringToNsString(::rtl::OUString const &ous, nsString &nss)
+{
+ // Convert to ::rtl::OString (utf-8 encoding).
+ ::rtl::OString os(ous,ous.getLength(), RTL_TEXTENCODING_UTF8);
+
+ const char *cs = os.getStr();
+ PRUint32 csLen = os.getLength();
+
+ NS_ConvertUTF8toUCS2 mozString(cs, csLen);
+ //const PRUnichar* uniMozString = (const PRUnichar*) mozString;
+ nss = mozString; // temp.
+}
+// -------------------------------------------------------------------------
+::rtl::OUString MTypeConverter::nsACStringToOUString( const nsACString& _source )
+{
+ const char* buffer = _source.BeginReading();
+ const char* bufferEnd = _source.EndReading();
+ return ::rtl::OUString( buffer, static_cast<sal_Int32>(bufferEnd - buffer), RTL_TEXTENCODING_ASCII_US );
+}
+// -------------------------------------------------------------------------
+::rtl::OString MTypeConverter::nsACStringToOString( const nsACString& _source )
+{
+ const char* buffer = _source.BeginReading();
+ const char* bufferEnd = _source.EndReading();
+ return ::rtl::OString( buffer, static_cast<sal_Int32>(bufferEnd - buffer) );
+}
+// -------------------------------------------------------------------------
+void MTypeConverter::asciiOUStringToNsACString( const ::rtl::OUString& _asciiString, nsACString& _dest )
+{
+ ::rtl::OString sAsciiVersion( _asciiString.getStr(), _asciiString.getLength(), RTL_TEXTENCODING_ASCII_US );
+ asciiToNsACString( sAsciiVersion.getStr(), _dest );
+}
+// -------------------------------------------------------------------------
+void MTypeConverter::asciiToNsACString( const sal_Char* _asciiString, nsACString& _dest )
+{
+ _dest.Truncate();
+ _dest.AppendASCII( _asciiString );
+}
+// -------------------------------------------------------------------------
+void MTypeConverter::nsStringToOUString(nsString const &nss, ::rtl::OUString &ous)
+{
+ // Get clone of buffer.
+ PRUnichar *uc = ToNewUnicode(nss);
+ sal_Int32 nssLen = nss.Length();
+
+ // TODO check if this is ok.
+ // PRUnichar != sal_Unicode in mingw
+ ::rtl::OUString _ous(reinterpret_cast_mingw_only<sal_Unicode *>(uc), nssLen);
+ ous = _ous;
+
+ nsMemory::Free(uc);
+}
+// -------------------------------------------------------------------------
+void MTypeConverter::prUnicharToOUString(PRUnichar const *pru, ::rtl::OUString &ous)
+{
+ // TODO, specify length.
+ // PRUnichar != sal_Unicode in mingw
+ ::rtl::OUString _ous(reinterpret_cast_mingw_only<const sal_Unicode *>(pru));
+ ous = _ous;
+}
+// -------------------------------------------------------------------------
+char *MTypeConverter::ouStringToCCharStringUtf8(::rtl::OUString const &ous)
+{
+ // Convert to ::rtl::OString,
+ ::rtl::OString os(ous,ous.getLength(), RTL_TEXTENCODING_UTF8);
+
+ const char *cs = os.getStr();
+
+ return(strdup(cs));
+}
+// -------------------------------------------------------------------------
+char *MTypeConverter::ouStringToCCharStringAscii(::rtl::OUString const &ous)
+{
+ // Convert ::rtl::OUString to ::rtl::OString,
+ ::rtl::OString os(ous,ous.getLength(), RTL_TEXTENCODING_ASCII_US);
+
+ return(strdup(os.getStr()));
+}
+// -------------------------------------------------------------------------
+char *MTypeConverter::nsStringToCCharStringAscii(nsString const &nss)
+{
+ char cs[1024];
+ nss.ToCString(cs, 1024);
+
+ return(strdup(cs));
+}
+// -------------------------------------------------------------------------
+::std::string MTypeConverter::ouStringToStlString(::rtl::OUString const &ous)
+{
+ // Convert ::rtl::OUString to ::rtl::OString.
+ ::rtl::OString os(ous,ous.getLength(),RTL_TEXTENCODING_ASCII_US);
+ return( ::std::string(os.getStr()));
+}
+#if 0
+// -------------------------------------------------------------------------
+::std::string MTypeConverter::nsStringToStlString(nsString const &nss)
+{
+ return( ::std::string(nss.GetBuffer()));
+}
+#endif
+// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.hxx b/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.hxx
new file mode 100644
index 000000000000..266bf2aad486
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * 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 _CONNECTIVITY_MAB_TYPECONVERTER_HXX_
+#define _CONNECTIVITY_MAB_TYPECONVERTER_HXX_
+
+#include <rtl/ustring.hxx>
+
+#include<string>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class MTypeConverter
+ {
+ public:
+ static void ouStringToNsString(const ::rtl::OUString&, nsString&);
+ static void nsStringToOUString(const nsString&, ::rtl::OUString&);
+ static void prUnicharToOUString(const PRUnichar*, ::rtl::OUString&);
+ // Use free() for the following 3 calls.
+ static char *ouStringToCCharStringAscii(const ::rtl::OUString&);
+ static char *nsStringToCCharStringAscii(const nsString&);
+ static char *ouStringToCCharStringUtf8(const ::rtl::OUString&);
+ // Convert to stl-string.
+ static ::std::string ouStringToStlString(const ::rtl::OUString&);
+ static ::std::string nsStringToStlString(const nsString&);
+
+ static ::rtl::OUString nsACStringToOUString( const nsACString& _source );
+ static ::rtl::OString nsACStringToOString( const nsACString& _source );
+ static void asciiOUStringToNsACString( const ::rtl::OUString& _asciiString, nsACString& _dest );
+ static void asciiToNsACString( const sal_Char* _asciiString, nsACString& _dest );
+
+ private:
+ MTypeConverter() {};
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MAB_TYPECONVERTER_HXX_
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/makefile.mk b/connectivity/source/drivers/mozab/mozillasrc/makefile.mk
new file mode 100644
index 000000000000..4c3e5380f451
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/makefile.mk
@@ -0,0 +1,77 @@
+#*************************************************************************
+#
+# 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.
+#
+#*************************************************************************
+CALL_CDECL=TRUE
+
+#mozilla specific stuff.
+MOZ_LIB=$(SOLARVERSION)$/$(INPATH)$/lib$(UPDMINOREXT)
+MOZ_INC=$(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/mozilla
+#End of mozilla specific stuff.
+
+PRJ=..$/..$/..$/..
+PRJINC=..$/..$/..
+PRJNAME=connectivity
+TARGET=mozabsrc
+
+# --- Settings ----------------------------------
+
+USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+.INCLUDE : settings.mk
+
+.IF ("$(SYSTEM_MOZILLA)" == "YES" && "$(WITH_MOZILLA)" == "YES") || "$(WITH_MOZILLA)" == "NO" || "$(OS)" == "OS2"
+dummy:
+ @echo " Not building the mozillasrc stuff in OpenOffice.org build"
+ @echo " dependency to Mozilla developer snapshots not feasable at the moment"
+ @echo " see http://bugzilla.mozilla.org/show_bug.cgi?id=135137"
+.ELSE
+
+.INCLUDE : $(PRJ)$/version.mk
+
+.INCLUDE : ../makefile_mozab.mk
+
+INCPRE += -I../bootstrap
+
+# --- Files -------------------------------------
+
+SLOFILES = \
+ $(SLO)$/MQueryHelper.obj \
+ $(SLO)$/MDatabaseMetaDataHelper.obj \
+ $(SLO)$/MQuery.obj \
+ $(SLO)$/MTypeConverter.obj \
+ $(SLO)$/MNameMapper.obj \
+ $(SLO)$/MNSMozabProxy.obj \
+ $(SLO)$/MNSTerminateListener.obj \
+ $(SLO)$/MLdapAttributeMap.obj \
+
+.ENDIF
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+