Tag: cws_dev300_cmcfixes48
User: cmc     
Date: 2008-07-24 13:16:25+0000
Modified:
   dba/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx
   dba/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx
   dba/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx
   dba/connectivity/source/drivers/mozab/bootstrap/makefile.mk

Log:
 #i92087# minimal firefox/etc profile finder implementation

File Changes:

Directory: /dba/connectivity/source/drivers/mozab/bootstrap/
============================================================

File [changed]: MMozillaBootstrap.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx?r1=1.6&r2=1.6.52.1
Delta lines:  +133 -3
---------------------
--- MMozillaBootstrap.cxx       2008-04-10 10:08:06+0000        1.6
+++ MMozillaBootstrap.cxx       2008-07-24 13:16:23+0000        1.6.52.1
@@ -38,8 +38,10 @@
 using namespace connectivity::mozab;
 #include <MNSFolders.hxx>
 #include "MNSProfileDiscover.hxx"
-#include "MNSProfileManager.hxx"
-#include "MNSRunnable.hxx"
+#ifndef MINIMAL_PROFILEDISCOVER
+#  include "MNSProfileManager.hxx"
+#  include "MNSRunnable.hxx"
+#endif
 #include <MNSInit.hxx>
 
 static MozillaBootstrap *pMozillaBootstrap=NULL;
@@ -72,10 +74,13 @@
 void MozillaBootstrap::Init()
 {
        sal_Bool aProfileExists=sal_False;
+
+#ifndef MINIMAL_PROFILEDISCOVER
        //This must be call before any mozilla code
        MNS_Init(aProfileExists);
 
        m_ProfileManager = new ProfileManager();
+#endif
        m_ProfileAccess = new ProfileAccess();
        
bootupProfile(::com::sun::star::mozilla::MozillaProductType_Mozilla,rtl::OUString());
 }
@@ -157,32 +162,57 @@
 // XProfileManager
 ::sal_Int32 SAL_CALL MozillaBootstrap::bootupProfile( 
::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& 
profileName ) throw (::com::sun::star::uno::RuntimeException)
 {
+#ifndef MINIMAL_PROFILEDISCOVER
        return m_ProfileManager->bootupProfile(product,profileName);
+#else
+        return -1;
+#endif
 }
 ::sal_Int32 SAL_CALL MozillaBootstrap::shutdownProfile(  ) throw 
(::com::sun::star::uno::RuntimeException)
 {
+#ifndef MINIMAL_PROFILEDISCOVER
        return m_ProfileManager->shutdownProfile();
+#else
+       return -1;
+#endif
 }
 ::com::sun::star::mozilla::MozillaProductType SAL_CALL 
MozillaBootstrap::getCurrentProduct(  ) throw 
(::com::sun::star::uno::RuntimeException)
 {
+#ifndef MINIMAL_PROFILEDISCOVER
        return m_ProfileManager->getCurrentProduct();
+#else
+       return ::com::sun::star::mozilla::MozillaProductType_Default;
+#endif
 }
 ::rtl::OUString SAL_CALL MozillaBootstrap::getCurrentProfile(  ) throw 
(::com::sun::star::uno::RuntimeException)
 {
+#ifndef MINIMAL_PROFILEDISCOVER
        return m_ProfileManager->getCurrentProfile();
+#else
+       return ::rtl::OUString();
+#endif
 }
 ::sal_Bool SAL_CALL MozillaBootstrap::isCurrentProfileLocked(  ) throw 
(::com::sun::star::uno::RuntimeException)
 {
+#ifndef MINIMAL_PROFILEDISCOVER
        return 
isProfileLocked(getCurrentProduct(),m_ProfileManager->getCurrentProfile());
+#else
+       return true;
+#endif
 }
 ::rtl::OUString SAL_CALL MozillaBootstrap::setCurrentProfile( 
::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& 
profileName ) throw (::com::sun::star::uno::RuntimeException)
 {
+#ifndef MINIMAL_PROFILEDISCOVER
        return m_ProfileManager->setCurrentProfile(product,profileName);
+#else
+       return ::rtl::OUString();
+#endif
 }
 
 // XProxyRunner
 ::sal_Int32 SAL_CALL MozillaBootstrap::Run( const 
::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& 
aCode ) throw (::com::sun::star::uno::RuntimeException)
 {
+#ifndef MINIMAL_PROFILEDISCOVER
        ::rtl::OUString profileName = aCode->getProfileName();
        ::rtl::OUString currProfileName = getCurrentProfile();
        ::com::sun::star::mozilla::MozillaProductType currProduct = 
getCurrentProduct();
@@ -194,5 +224,105 @@
        MNSRunnable xRunnable;
        
        return xRunnable.StartProxy(aCode);;
+#else
+       return -1;
+#endif
+}
+
+#ifdef MINIMAL_PROFILEDISCOVER
+#include <cppuhelper/factory.hxx>
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+                const sal_Char  **ppEnvTypeName,
+                uno_Environment ** /*ppEnv*/
+            )
+{
+    *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+        const ::rtl::OUString& aServiceImplName,
+        const Sequence< ::rtl::OUString>& Services,
+        const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+    ::rtl::OUString aMainKeyName;
+    aMainKeyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/"));
+    aMainKeyName += aServiceImplName;
+    aMainKeyName += ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
+
+    Reference< ::com::sun::star::registry::XRegistryKey >  xNewKey( 
xKey->createKey(aMainKeyName) );
+    OSL_ENSURE(xNewKey.is(), "MOZAB::component_writeInfo : could not create a 
registry key !");
+
+    for (sal_Int32 i=0; i<Services.getLength(); ++i)
+        xNewKey->createKey(Services[i]);
+}
+
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+                void* /*pServiceManager*/,
+                void* pRegistryKey
+            )
+{
+    if (pRegistryKey)
+    try
+    {
+        Reference< ::com::sun::star::registry::XRegistryKey > 
xKey(reinterpret_cast< 
::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+        Sequence< ::rtl::OUString > aSNS( 1 );
+        aSNS[0] = ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
+        REGISTER_PROVIDER(
+             ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.mozilla.MozillaBootstrap")),
+             aSNS, xKey);
+
+        return sal_True;
+    }
+    catch (::com::sun::star::registry::InvalidRegistryException& )
+    {
+        OSL_ENSURE(sal_False, "Mozab::component_writeInfo : could not create a 
registry key ! ## InvalidRegistryException !");
+    }
+
+    return sal_False;
+}
+
+static Reference< XInterface > SAL_CALL createInstance( const Reference< 
XMultiServiceFactory >& rServiceManager )
+{
+        MozillaBootstrap * pBootstrap = 
reinterpret_cast<MozillaBootstrap*>(OMozillaBootstrap_CreateInstance(rServiceManager));
+        return *pBootstrap;
 }
 
+extern "C" void* SAL_CALL component_getFactory(
+                                        const sal_Char* pImplementationName,
+                                        void* pServiceManager,
+                                        void* /*pRegistryKey*/)
+{
+        void* pRet = 0;
+
+        if (pServiceManager)
+        {
+                ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( 
pImplementationName ) );
+                Reference< XSingleServiceFactory > xFactory;
+                if (aImplName.equals(  ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.mozilla.MozillaBootstrap"))  ))
+                {
+                    Sequence< ::rtl::OUString > aSNS( 1 );
+                    aSNS[0] = ::rtl::OUString( 
RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
+
+                    xFactory = ::cppu::createSingleFactory(
+                        reinterpret_cast< XMultiServiceFactory* > ( 
pServiceManager),
+                        aImplName, createInstance, aSNS );
+                }
+                if ( xFactory.is() )
+                {
+                    xFactory->acquire();
+                    pRet = xFactory.get();
+                }
+        }
+
+        return pRet;
+};
+
+#endif

File [changed]: MNSProfileDiscover.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx?r1=1.8&r2=1.8.24.1
Delta lines:  +43 -8
--------------------
--- MNSProfileDiscover.cxx      2008-06-06 08:36:43+0000        1.8
+++ MNSProfileDiscover.cxx      2008-07-24 13:16:23+0000        1.8.24.1
@@ -32,6 +32,7 @@
 #include "precompiled_connectivity.hxx"
 
 #include "MNSProfileDiscover.hxx"
+#ifndef MINIMAL_PROFILEDISCOVER
 #include "MNSProfile.hxx"
 
 #include "pratom.h"
@@ -88,6 +89,7 @@
 
 // IID and CIDs of all the services needed
 static NS_DEFINE_CID(kCharsetConverterManagerCID, 
NS_ICHARSETCONVERTERMANAGER_CID);
+#endif
 
 // Registry Keys
 
@@ -105,7 +107,13 @@
 {
        namespace mozab
        {
-               ProfileStruct::ProfileStruct(MozillaProductType 
aProduct,::rtl::OUString aProfileName,nsILocalFile * aProfilePath)
+               ProfileStruct::ProfileStruct(MozillaProductType 
aProduct,::rtl::OUString aProfileName,
+#ifdef MINIMAL_PROFILEDISCOVER
+            const ::rtl::OUString& aProfilePath
+#else
+            nsILocalFile * aProfilePath
+#endif
+          )
                {
                        product=aProduct;
                        profileName = aProfileName;
@@ -113,6 +121,9 @@
                }
                ::rtl::OUString ProfileStruct::getProfilePath() 
                {
+#ifdef MINIMAL_PROFILEDISCOVER
+                       return profilePath;
+#else
                        if (profilePath)
                        {
                                nsAutoString path;
@@ -122,9 +133,9 @@
                        }
                        else
                 return ::rtl::OUString();
+#endif
                }
 
-
                ProfileAccess::~ProfileAccess()
                {
                }
@@ -132,20 +143,24 @@
                {
                        LoadProductsInfo();
                }
+
                sal_Int32 ProfileAccess::LoadProductsInfo()
                {
+#ifndef MINIMAL_PROFILEDISCOVER
                        //load mozilla profiles to m_ProductProfileList
                        LoadMozillaProfiles();
-                       sal_Int32 index=MozillaProductType_Mozilla;
-                       sal_Int32 
count=m_ProductProfileList[index].mProfileList.size();
+#endif
+                       sal_Int32 
count=m_ProductProfileList[MozillaProductType_Mozilla].mProfileList.size();
                        
                        //load thunderbird profiles to m_ProductProfileList
                        count += 
LoadXPToolkitProfiles(MozillaProductType_Thunderbird);
+
                        //load firefox profiles to m_ProductProfileList
                        //firefox profile does not containt address book, but 
maybe others need them
                        count += 
LoadXPToolkitProfiles(MozillaProductType_Firefox);
                        return count;
                }
+#ifndef MINIMAL_PROFILEDISCOVER
                nsresult ProfileAccess::LoadMozillaProfiles()
                {
                        sal_Int32 index=MozillaProductType_Mozilla;
@@ -249,13 +264,16 @@
                        }
                        return rv;
                }
+#endif
                //Thunderbird and firefox profiles are saved in profiles.ini
                sal_Int32 
ProfileAccess::LoadXPToolkitProfiles(MozillaProductType product)
                {
                        sal_Int32 index=product;
                        ProductStruct &m_Product = m_ProductProfileList[index];
 
+#ifndef MINIMAL_PROFILEDISCOVER
                        nsresult rv;
+#endif
                        ::rtl::OUString regDir = getRegistryDir(product);
             ::rtl::OUString profilesIni( regDir );
             profilesIni += ::rtl::OUString::createFromAscii( "profiles.ini" );
@@ -302,6 +320,7 @@
                                                isRelative = 
sIsRelative.toInt32();
                                        }
                                        
+#ifndef MINIMAL_PROFILEDISCOVER
                                        nsCOMPtr<nsILocalFile> rootDir;
                                        rv = NS_NewLocalFile(EmptyString(), 
PR_TRUE,
                                                                                
        getter_AddRefs(rootDir));
@@ -321,8 +340,15 @@
                                                rv = 
rootDir->SetPersistentDescriptor(filePath);
                                        }
                                        if (NS_FAILED(rv)) continue;
+#endif
 
-                                       ProfileStruct*  profileItem     = new 
ProfileStruct(product,profileName,rootDir);
+                                       ProfileStruct*  profileItem     = new 
ProfileStruct(product,profileName,
+#ifdef MINIMAL_PROFILEDISCOVER
+                                                       regDir + profilePath
+#else
+                                                       rootDir
+#endif
+                                               );
                                        m_Product.mProfileList[profileName] = 
profileItem;
 
                                        sal_Int32 isDefault = 0;
@@ -338,6 +364,7 @@
                        }
                        return m_Product.mProfileList.size();
                }
+
                ::rtl::OUString ProfileAccess::getProfilePath( 
::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& 
profileName ) throw (::com::sun::star::uno::RuntimeException)
                {
                        sal_Int32 index=product;
@@ -350,6 +377,7 @@
                        else
                                return 
m_Product.mProfileList[profileName]->getProfilePath();
                }
+
                ::sal_Int32 ProfileAccess::getProfileCount( 
::com::sun::star::mozilla::MozillaProductType product) throw 
(::com::sun::star::uno::RuntimeException)
                {
                        sal_Int32 index=product;
@@ -373,6 +401,7 @@
                        
                        return m_Product.mProfileList.size();
                }
+
                ::rtl::OUString ProfileAccess::getDefaultProfile( 
::com::sun::star::mozilla::MozillaProductType product ) throw 
(::com::sun::star::uno::RuntimeException)
                {
                        sal_Int32 index=product;
@@ -390,6 +419,7 @@
                        ProfileStruct * aProfile = 
(*m_Product.mProfileList.begin()).second;
                        return aProfile->getProfileName();
                }
+#ifndef MINIMAL_PROFILEDISCOVER
                nsresult ProfileAccess::isExistFileOrSymlink(nsILocalFile* 
aFile,PRBool *bExist)
                {
                        nsresult rv;
@@ -448,9 +478,12 @@
                        return nExist;
                }
 
-
+#endif
                ::sal_Bool ProfileAccess::isProfileLocked( 
::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& 
profileName ) throw (::com::sun::star::uno::RuntimeException)
                {
+#ifdef MINIMAL_PROFILEDISCOVER
+                       return sal_True;
+#else
                        ::rtl::OUString path = 
getProfilePath(product,profileName);
                        if (!path.getLength())
                                return sal_True;
@@ -474,7 +507,9 @@
                        if (rv)
                                return sal_True;
                        return sal_False;
+#endif
                }
+
                ::sal_Bool ProfileAccess::getProfileExists( 
::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& 
profileName ) throw (::com::sun::star::uno::RuntimeException)
                {
                        sal_Int32 index=product;
@@ -486,7 +521,7 @@
                        else
                                return sal_True;
                }
-
-
        }
 }
+
+

File [changed]: MNSProfileDiscover.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx?r1=1.5&r2=1.5.52.1
Delta lines:  +19 -3
--------------------
--- MNSProfileDiscover.hxx      2008-04-10 10:12:57+0000        1.5
+++ MNSProfileDiscover.hxx      2008-07-24 13:16:23+0000        1.5.52.1
@@ -31,7 +31,9 @@
 #ifndef __MNSProfileDiscover_h___
 #define __MNSProfileDiscover_h___
 
+#ifndef MINIMAL_PROFILEDISCOVER
 #include "mozilla_profile_discover.h"
+#endif
 
 #include <sal/types.h>
 #include <osl/diagnose.h>
@@ -68,15 +70,27 @@
                class ProfileStruct
                {
                public:
-                       ProfileStruct(MozillaProductType 
aProduct,::rtl::OUString aProfileName,nsILocalFile * aProfilePath);
+                       ProfileStruct(MozillaProductType 
aProduct,::rtl::OUString aProfileName,
+#ifdef MINIMAL_PROFILEDISCOVER
+                          const ::rtl::OUString &aProfilePath
+#else
+                          nsILocalFile * aProfilePath
+#endif
+                            );
                        MozillaProductType getProductType() { return product;}
                        ::rtl::OUString getProfileName(){ return profileName;}
                        ::rtl::OUString getProfilePath() ;
+#ifndef MINIMAL_PROFILEDISCOVER
                        nsILocalFile    *getProfileLocal(){ return profilePath;}
+#endif
                protected:
                        MozillaProductType product;
                        ::rtl::OUString profileName;
+#ifdef MINIMAL_PROFILEDISCOVER
+                       ::rtl::OUString profilePath;
+#else
                        nsCOMPtr<nsILocalFile> profilePath;
+#endif
                };
 
                class ProductStruct
@@ -102,16 +116,18 @@
                        ::rtl::OUString getDefaultProfile( 
::com::sun::star::mozilla::MozillaProductType product ) throw 
(::com::sun::star::uno::RuntimeException);
                        ::sal_Bool SAL_CALL isProfileLocked( 
::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& 
profileName ) throw (::com::sun::star::uno::RuntimeException);
                        ::sal_Bool SAL_CALL getProfileExists( 
::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& 
profileName ) throw (::com::sun::star::uno::RuntimeException);
-
                protected:
                        ProductStruct m_ProductProfileList[4];
                        sal_Int32 LoadProductsInfo();
+#ifndef MINIMAL_PROFILEDISCOVER
                        nsresult  LoadMozillaProfiles();
+#endif
                        sal_Int32 LoadXPToolkitProfiles(MozillaProductType 
product);
-
+#ifndef MINIMAL_PROFILEDISCOVER
                        //used by isProfileLocked
                        nsresult isExistFileOrSymlink(nsILocalFile* 
aFile,PRBool *bExist);
                        nsresult isLockExist(nsILocalFile* aFile);
+#endif
                };
 
        }

File [changed]: makefile.mk
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/mozab/bootstrap/makefile.mk?r1=1.13&r2=1.13.52.1
Delta lines:  +21 -14
---------------------
--- makefile.mk 2008-04-10 10:14:31+0000        1.13
+++ makefile.mk 2008-07-24 13:16:23+0000        1.13.52.1
@@ -51,30 +51,38 @@
 
 .INCLUDE : settings.mk
 
-.IF ("$(SYSTEM_MOZILLA)" == "YES" && "$(WITH_MOZILLA)" == "YES") || 
"$(WITH_MOZILLA)" == "NO"
-dummy:
-       @echo "         Not building the mozillasrc stuff in OpenOffice.org 
build"
-       @echo "         dependency to Mozilla developer snapshots not feasable 
at the moment"
-
-.ELSE
-
 .INCLUDE :  $(PRJ)$/version.mk
 
 
 #mozilla specific stuff.
 # --- Files -------------------------------------
 
-SLOFILES = \
-       $(SLO)$/MMozillaBootstrap.obj   \
-       $(SLO)$/MNSFolders.obj  \
+SLOFILES += \
+       $(SLO)$/MNSINIParser.obj \
        $(SLO)$/MNSProfileDiscover.obj                          \
+       $(SLO)$/MMozillaBootstrap.obj \
+       $(SLO)$/MNSFolders.obj
+
+.IF ("$(SYSTEM_MOZILLA)" == "YES" && "$(WITH_MOZILLA)" == "YES") || 
"$(WITH_MOZILLA)" == "NO"
+CDEFS+=-DMINIMAL_PROFILEDISCOVER
+
+SHL1TARGET=$(TARGET)
+SHL1OBJS=$(SLOFILES)
+
+SHL1STDLIBS=\
+        $(CPPULIB)       \
+        $(CPPUHELPERLIB) \
+        $(SALLIB)        \
+        $(COMPHELPERLIB)
+
+.ELSE
+SLOFILES += \
        $(SLO)$/MNSInit.obj                                 \
        $(SLO)$/MNSProfileManager.obj   \
-       $(SLO)$/MNSINIParser.obj        \
        $(SLO)$/MNSRunnable.obj \
        $(SLO)$/MNSProfile.obj                                  \
        $(SLO)$/MNSProfileDirServiceProvider.obj
-
+.ENDIF
 
 .IF "$(GUI)"=="UNX"
 .IF "$(COMNAME)"=="sunpro5"
@@ -158,7 +166,6 @@
             -Wno-long-long
 CDEFS     += -DTRACING
 .ENDIF
-.ENDIF
 
 SHL1TARGET_NAME=$(TARGET)$(MOZAB_MAJOR)
 




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to