Kaydet (Commit) 7496ed4f authored tarafından Jürgen Schmidt's avatar Jürgen Schmidt

#124701# bring back moz bootstrap to find profile

üst 46d6cabf
......@@ -22,6 +22,7 @@ ex extensions\source\config\ldap nmake - all ex_ldap ex_inc N
ex extensions\source\update\feed nmake - all ex_updchkfeed ex_inc NULL
ex extensions\source\update\check nmake - all ex_updchk ex_inc NULL
ex extensions\source\update\ui nmake - all ex_updchkui ex_inc NULL
ex extensions\source\mozbootstrap nmake - all ex_mozbootstrap ex_inc NULL
ex extensions\util nmake - all ex_util ex_preload ex_abpilot ex_dbpilots ex_logging ex_ldap ex_propctrlr ex_bib ex_oooimprovecore NULL
# Fails at the moment
......
......@@ -12,6 +12,7 @@ mkdir: %_DEST%\bin%_EXT%\so
..\%__SRC%\lib\ldapbe2.uno.so %_DEST%\lib%_EXT%\ldapbe2.uno.so
..\%__SRC%\lib\updchk.uno.so %_DEST%\lib%_EXT%\updchk.uno.so
..\%__SRC%\lib\updatefeed.uno.so %_DEST%\lib%_EXT%\updatefeed.uno.so
..\%__SRC%\lib\mozbootstrap.uno.so %_DEST%\lib%_EXT%\mozbootstrap.uno.so
..\%__SRC%\bin\oleautobridge2.uno.dll %_DEST%\bin%_EXT%\odf4ms\oleautobridge.uno.dll
..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib
..\%__SRC%\bin\*.res %_DEST%\bin%_EXT%\*.res
......@@ -50,3 +51,4 @@ mkdir: %_DEST%\xml%_EXT%\registry\spool\org\openoffice\Office\Logging
..\%__SRC%\misc\updchk.component %_DEST%\xml%_EXT%\updchk.component
..\%__SRC%\misc\updchk.uno.component %_DEST%\xml%_EXT%\updchk.uno.component
..\%__SRC%\misc\xmx.component %_DEST%\xml%_EXT%\xmx.component
..\%__SRC%\misc\mozbootstrap.component %_DEST%\xml%_EXT%\mozbootstrap.component
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_extensions.hxx"
#include "MMozillaBootstrap.hxx"
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::mozilla;
using namespace connectivity::mozab;
#include <MNSFolders.hxx>
#include "MNSProfileDiscover.hxx"
static MozillaBootstrap *pMozillaBootstrap=NULL;
static Reference<XMozillaBootstrap> xMozillaBootstrap;
extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL OMozillaBootstrap_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
{
if (!pMozillaBootstrap)
{
pMozillaBootstrap=new connectivity::mozab::MozillaBootstrap( _rxFactory );
pMozillaBootstrap->Init();
xMozillaBootstrap = pMozillaBootstrap;
}
return pMozillaBootstrap;
}
// --------------------------------------------------------------------------------
// --------------------------------------------------------------------------------
MozillaBootstrap::MozillaBootstrap(
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
: OMozillaBootstrap_BASE(m_aMutex), m_xMSFactory( _rxFactory )
{
}
// -----------------------------------------------------------------------------
MozillaBootstrap::~MozillaBootstrap()
{
}
// -----------------------------------------------------------------------------
void MozillaBootstrap::Init()
{
sal_Bool aProfileExists=sal_False;
(void)aProfileExists; /* avoid warning about unused parameter */
m_ProfileAccess = new ProfileAccess();
bootupProfile(::com::sun::star::mozilla::MozillaProductType_Mozilla,rtl::OUString());
}
// --------------------------------------------------------------------------------
void MozillaBootstrap::disposing()
{
::osl::MutexGuard aGuard(m_aMutex);
OMozillaBootstrap_BASE::disposing();
}
// static ServiceInfo
//------------------------------------------------------------------------------
rtl::OUString MozillaBootstrap::getImplementationName_Static( ) throw(RuntimeException)
{
return rtl::OUString::createFromAscii(MOZAB_MozillaBootstrap_IMPL_NAME);
}
//------------------------------------------------------------------------------
Sequence< ::rtl::OUString > MozillaBootstrap::getSupportedServiceNames_Static( ) throw (RuntimeException)
{
// which service is supported
// for more information @see com.sun.star.mozilla.MozillaBootstrap
Sequence< ::rtl::OUString > aSNS( 1 );
aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
return aSNS;
}
//------------------------------------------------------------------
::rtl::OUString SAL_CALL MozillaBootstrap::getImplementationName( ) throw(RuntimeException)
{
return getImplementationName_Static();
}
//------------------------------------------------------------------
sal_Bool SAL_CALL MozillaBootstrap::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
{
Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
const ::rtl::OUString* pSupported = aSupported.getConstArray();
const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
;
return pSupported != pEnd;
}
//------------------------------------------------------------------
Sequence< ::rtl::OUString > SAL_CALL MozillaBootstrap::getSupportedServiceNames( ) throw(RuntimeException)
{
return getSupportedServiceNames_Static();
}
// XProfileDiscover
::sal_Int32 SAL_CALL MozillaBootstrap::getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException)
{
return m_ProfileAccess->getProfileCount(product);
}
::sal_Int32 SAL_CALL MozillaBootstrap::getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException)
{
return m_ProfileAccess->getProfileList(product,list);
}
::rtl::OUString SAL_CALL MozillaBootstrap::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException)
{
return m_ProfileAccess->getDefaultProfile(product);
}
::rtl::OUString SAL_CALL MozillaBootstrap::getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
{
return m_ProfileAccess->getProfilePath(product,profileName);
}
::sal_Bool SAL_CALL MozillaBootstrap::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
{
return m_ProfileAccess->isProfileLocked(product,profileName);
}
::sal_Bool SAL_CALL MozillaBootstrap::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
{
return m_ProfileAccess->getProfileExists(product,profileName);
}
// XProfileManager
::sal_Int32 SAL_CALL MozillaBootstrap::bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
{
(void)product; /* avoid warning about unused parameter */
(void)profileName; /* avoid warning about unused parameter */
return -1;
}
::sal_Int32 SAL_CALL MozillaBootstrap::shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException)
{
return -1;
}
::com::sun::star::mozilla::MozillaProductType SAL_CALL MozillaBootstrap::getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException)
{
return ::com::sun::star::mozilla::MozillaProductType_Default;
}
::rtl::OUString SAL_CALL MozillaBootstrap::getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException)
{
return ::rtl::OUString();
}
::sal_Bool SAL_CALL MozillaBootstrap::isCurrentProfileLocked( ) throw (::com::sun::star::uno::RuntimeException)
{
return true;
}
::rtl::OUString SAL_CALL MozillaBootstrap::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
{
(void)product; /* avoid warning about unused parameter */
(void)profileName; /* avoid warning about unused parameter */
return ::rtl::OUString();
}
// 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)
{
(void)aCode; /* avoid warning about unused parameter */
return -1;
}
#include <cppuhelper/factory.hxx>
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
using ::com::sun::star::lang::XSingleServiceFactory;
using ::com::sun::star::lang::XMultiServiceFactory;
extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
component_getImplementationEnvironment(
const sal_Char **ppEnvTypeName,
uno_Environment ** /*ppEnv*/
)
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
{
MozillaBootstrap * pBootstrap = reinterpret_cast<MozillaBootstrap*>(OMozillaBootstrap_CreateInstance(rServiceManager));
return *pBootstrap;
}
extern "C" SAL_DLLPUBLIC_EXPORT 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;
};
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#ifndef _SMOZILLABOOTSTRAP_HXX
#define _SMOZILLABOOTSTRAP_HXX
#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <cppuhelper/compbase2.hxx>
#include <osl/module.h>
#define MOZAB_MozillaBootstrap_IMPL_NAME "com.sun.star.comp.mozilla.MozillaBootstrap"
namespace connectivity
{
namespace mozab
{
typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::mozilla::XMozillaBootstrap,
::com::sun::star::lang::XServiceInfo > OMozillaBootstrap_BASE;
class ProfileAccess;
class ProfileManager;
class MozillaBootstrap : public OMozillaBootstrap_BASE
{
protected:
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xMSFactory;
::osl::Mutex m_aMutex; // mutex is need to control member access
virtual ~MozillaBootstrap();
protected:
ProfileAccess * m_ProfileAccess;
ProfileManager * m_ProfileManager;
public:
void Init();
MozillaBootstrap(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
// OComponentHelper
virtual void SAL_CALL disposing(void);
// XInterface
static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
// XServiceInfo
virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
// XMozillaBootstrap
// XProfileDiscover
virtual ::sal_Int32 SAL_CALL getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
// XProfileManager
virtual ::sal_Int32 SAL_CALL bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Int32 SAL_CALL shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::mozilla::MozillaProductType SAL_CALL getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::sal_Bool SAL_CALL isCurrentProfileLocked( ) throw (::com::sun::star::uno::RuntimeException);
virtual ::rtl::OUString SAL_CALL setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
// XProxyRunner
virtual ::sal_Int32 SAL_CALL Run( const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode ) throw (::com::sun::star::uno::RuntimeException);
const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
& getMSFactory(void) const { return m_xMSFactory; }
};
}
}
#endif // _SMozillaBootstrap_HXX
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_extensions.hxx"
#include <MNSFolders.hxx>
#ifdef UNIX
#include <sys/types.h>
#include <strings.h>
#include <string.h>
#endif // End UNIX
#ifdef WNT
#include "pre_include_windows.h"
#include <windows.h>
#include <stdlib.h>
#include <shlobj.h>
#include <objidl.h>
#include "post_include_windows.h"
#endif // End WNT
#include <osl/security.hxx>
#include <osl/file.hxx>
#include <osl/thread.h>
using namespace ::com::sun::star::mozilla;
namespace
{
// -------------------------------------------------------------------
static ::rtl::OUString lcl_getUserDataDirectory()
{
::osl::Security aSecurity;
::rtl::OUString aConfigPath;
aSecurity.getConfigDir( aConfigPath );
return aConfigPath + ::rtl::OUString::createFromAscii( "/" );
}
// -------------------------------------------------------------------
static const char* DefaultProductDir[3][3] =
{
#if defined(XP_WIN)
{ "Mozilla/SeaMonkey/", NULL, NULL },
{ "Mozilla/Firefox/", NULL, NULL },
{ "Thunderbird/", "Mozilla/Thunderbird/", NULL }
#elif(MACOSX)
{ "../Mozilla/SeaMonkey/", NULL, NULL },
{ "Firefox/", NULL, NULL },
{ "../Thunderbird/", NULL, NULL }
#else
{ ".mozilla/seamonkey/", NULL, NULL },
{ ".mozilla/firefox/", NULL, NULL },
{ ".thunderbird/", ".mozilla-thunderbird/", ".mozilla/thunderbird/" }
#endif
};
static const char* ProductRootEnvironmentVariable[3] =
{
"MOZILLA_PROFILE_ROOT",
"MOZILLA_FIREFOX_PROFILE_ROOT",
"MOZILLA_THUNDERBIRD_PROFILE_ROOT",
};
// -------------------------------------------------------------------
static ::rtl::OUString lcl_guessProfileRoot( MozillaProductType _product )
{
size_t productIndex = _product - 1;
static ::rtl::OUString s_productDirectories[3];
if ( !s_productDirectories[ productIndex ].getLength() )
{
::rtl::OUString sProductPath;
// check whether we have an anevironment variable which helps us
const char* pProfileByEnv = getenv( ProductRootEnvironmentVariable[ productIndex ] );
if ( pProfileByEnv )
{
sProductPath = ::rtl::OUString( pProfileByEnv, rtl_str_getLength( pProfileByEnv ), osl_getThreadTextEncoding() );
// asume that this is fine, no further checks
}
else
{
::rtl::OUString sProductDirCandidate;
const char* pProfileRegistry = "profiles.ini";
// check all possible candidates
for ( size_t i=0; i<3; ++i )
{
if ( NULL == DefaultProductDir[ productIndex ][ i ] )
break;
sProductDirCandidate = lcl_getUserDataDirectory() +
::rtl::OUString::createFromAscii( DefaultProductDir[ productIndex ][ i ] );
// check existence
::osl::DirectoryItem aRegistryItem;
::osl::FileBase::RC result = ::osl::DirectoryItem::get( sProductDirCandidate + ::rtl::OUString::createFromAscii( pProfileRegistry ), aRegistryItem );
if ( result == ::osl::FileBase::E_None )
{
::osl::FileStatus aStatus( FileStatusMask_Validate );
result = aRegistryItem.getFileStatus( aStatus );
if ( result == ::osl::FileBase::E_None )
{
// the registry file exists
break;
}
}
}
::osl::FileBase::getSystemPathFromFileURL( sProductDirCandidate, sProductPath );
}
s_productDirectories[ productIndex ] = sProductPath;
}
return s_productDirectories[ productIndex ];
}
}
// -----------------------------------------------------------------------
::rtl::OUString getRegistryDir(MozillaProductType product)
{
if (product == MozillaProductType_Default)
return ::rtl::OUString();
return lcl_guessProfileRoot( product );
}
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#ifndef _MNSFOLDERS_HXX_
#define _MNSFOLDERS_HXX_
#include <sal/types.h>
#include <osl/diagnose.h>
#include <osl/conditn.hxx>
#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_
#include <com/sun/star/mozilla/MozillaProductType.hpp>
#endif
#include <rtl/ustring.hxx>
::rtl::OUString getRegistryDir(::com::sun::star::mozilla::MozillaProductType product);
#endif
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_extensions.hxx"
#include <MNSINIParser.hxx>
#include <rtl/byteseq.hxx>
IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException )
{
OUString iniUrl;
if (osl_File_E_None != osl_getFileURLFromSystemPath(rIniName.pData, &iniUrl.pData))
return;
#if OSL_DEBUG_LEVEL > 0
OString sFile = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
OSL_TRACE(__FILE__" -- parser() - %s\n", sFile.getStr());
#endif
oslFileHandle handle=NULL;
oslFileError fileError = osl_File_E_INVAL;
try{
if (iniUrl.getLength())
fileError = osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read);
}
catch(::com::sun::star::io::IOException e)
{
#if OSL_DEBUG_LEVEL > 0
OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() );
#endif
}
if (osl_File_E_None == fileError)
{
rtl::ByteSequence seq;
sal_uInt64 nSize = 0;
osl_getFileSize(handle, &nSize);
OUString sectionName = OUString::createFromAscii("no name section");
while (true)
{
sal_uInt64 nPos;
if (osl_File_E_None != osl_getFilePos(handle, &nPos) || nPos >= nSize)
break;
if (osl_File_E_None != osl_readLine(handle , (sal_Sequence **) &seq))
break;
OString line( (const sal_Char *) seq.getConstArray(), seq.getLength() );
sal_Int32 nIndex = line.indexOf('=');
if (nIndex >= 1)
{
ini_Section *aSection = &mAllSection[sectionName];
struct ini_NameValue nameValue;
nameValue.sName = OStringToOUString(
line.copy(0,nIndex).trim(), RTL_TEXTENCODING_ASCII_US );
nameValue.sValue = OStringToOUString(
line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8 );
aSection->lList.push_back(nameValue);
}
else
{
sal_Int32 nIndexStart = line.indexOf('[');
sal_Int32 nIndexEnd = line.indexOf(']');
if ( nIndexEnd > nIndexStart && nIndexStart >=0)
{
sectionName = OStringToOUString(
line.copy(nIndexStart + 1,nIndexEnd - nIndexStart -1).trim(), RTL_TEXTENCODING_ASCII_US );
if (!sectionName.getLength())
sectionName = OUString::createFromAscii("no name section");
ini_Section *aSection = &mAllSection[sectionName];
aSection->sName = sectionName;
}
}
}
osl_closeFile(handle);
}
#if OSL_DEBUG_LEVEL > 0
else
{
OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() );
}
#endif
}
#if OSL_DEBUG_LEVEL > 0
void IniParser::Dump()
{
IniSectionMap::iterator iBegin = mAllSection.begin();
IniSectionMap::iterator iEnd = mAllSection.end();
for(;iBegin != iEnd;iBegin++)
{
ini_Section *aSection = &(*iBegin).second;
OString sec_name_tmp = OUStringToOString(aSection->sName, RTL_TEXTENCODING_ASCII_US);
for(NameValueList::iterator itor=aSection->lList.begin();
itor != aSection->lList.end();
itor++)
{
struct ini_NameValue * aValue = &(*itor);
OString name_tmp = OUStringToOString(aValue->sName, RTL_TEXTENCODING_ASCII_US);
OString value_tmp = OUStringToOString(aValue->sValue, RTL_TEXTENCODING_UTF8);
OSL_TRACE(
" section=%s name=%s value=%s\n",
sec_name_tmp.getStr(),
name_tmp.getStr(),
value_tmp.getStr() );
}
}
}
#endif
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#ifndef __MNSINIPARSER_HXX__
#define __MNSINIPARSER_HXX__
#include <rtl/ustring.hxx>
#include <com/sun/star/io/IOException.hpp>
#include <osl/process.h>
using namespace rtl;
#include <map>
#include <list>
#if OSL_DEBUG_LEVEL > 0
#include <stdio.h>
#endif
struct ini_NameValue
{
rtl::OUString sName;
rtl::OUString sValue;
inline ini_NameValue() SAL_THROW( () )
{}
inline ini_NameValue(
OUString const & name, OUString const & value ) SAL_THROW( () )
: sName( name ),
sValue( value )
{}
};
typedef std::list<
ini_NameValue
> NameValueList;
struct ini_Section
{
rtl::OUString sName;
NameValueList lList;
};
typedef std::map<rtl::OUString,
ini_Section
>IniSectionMap;
class IniParser
{
IniSectionMap mAllSection;
public:
IniSectionMap * getAllSection(){return &mAllSection;};
IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException );
#if OSL_DEBUG_LEVEL > 0
void Dump();
#endif
};
#endif
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_extensions.hxx"
#include "MNSProfileDiscover.hxx"
// Registry Keys
static ::rtl::OUString szProfileSubtreeString=::rtl::OUString::createFromAscii("Profiles");
static ::rtl::OUString szCurrentProfileString= ::rtl::OUString::createFromAscii("CurrentProfile");
static ::rtl::OUString szDirectoryString =::rtl::OUString::createFromAscii("directory");
#ifndef MAXPATHLEN
#define MAXPATHLEN 1024
#endif
#include <MNSFolders.hxx>
#include <MNSINIParser.hxx>
namespace connectivity
{
namespace mozab
{
ProfileStruct::ProfileStruct(MozillaProductType aProduct,::rtl::OUString aProfileName,
const ::rtl::OUString& aProfilePath)
{
product=aProduct;
profileName = aProfileName;
profilePath = aProfilePath;
}
::rtl::OUString ProfileStruct::getProfilePath()
{
return profilePath;
}
ProfileAccess::~ProfileAccess()
{
}
ProfileAccess::ProfileAccess()
{
LoadProductsInfo();
}
sal_Int32 ProfileAccess::LoadProductsInfo()
{
//load SeaMonkey 2 profiles to m_ProductProfileList
sal_Int32 count = LoadXPToolkitProfiles(MozillaProductType_Mozilla);
//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;
}
//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];
::rtl::OUString regDir = getRegistryDir(product);
::rtl::OUString profilesIni( regDir );
profilesIni += ::rtl::OUString::createFromAscii( "profiles.ini" );
IniParser parser( profilesIni );
IniSectionMap &mAllSection = *(parser.getAllSection());
IniSectionMap::iterator iBegin = mAllSection.begin();
IniSectionMap::iterator iEnd = mAllSection.end();
for(;iBegin != iEnd;iBegin++)
{
ini_Section *aSection = &(*iBegin).second;
::rtl::OUString profileName;
::rtl::OUString profilePath;
::rtl::OUString sIsRelative;
::rtl::OUString sIsDefault;
for(NameValueList::iterator itor=aSection->lList.begin();
itor != aSection->lList.end();
itor++)
{
struct ini_NameValue * aValue = &(*itor);
if (aValue->sName.equals(::rtl::OUString::createFromAscii("Name")))
{
profileName = aValue->sValue;
}
else if (aValue->sName.equals(::rtl::OUString::createFromAscii("IsRelative")))
{
sIsRelative = aValue->sValue;
}
else if (aValue->sName.equals(::rtl::OUString::createFromAscii("Path")))
{
profilePath = aValue->sValue;
}
else if (aValue->sName.equals(::rtl::OUString::createFromAscii("Default")))
{
sIsDefault = aValue->sValue;
}
}
if (profileName.getLength() != 0 || profilePath.getLength() != 0)
{
sal_Int32 isRelative = 0;
if (sIsRelative.getLength() != 0)
{
isRelative = sIsRelative.toInt32();
}
ProfileStruct* profileItem = new ProfileStruct(product,profileName,
regDir + profilePath);
m_Product.mProfileList[profileName] = profileItem;
sal_Int32 isDefault = 0;
if (sIsDefault.getLength() != 0)
{
isDefault = sIsDefault.toInt32();
}
if (isDefault)
m_Product.mCurrentProfileName = profileName;
}
}
return static_cast< ::sal_Int32 >(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;
ProductStruct &m_Product = m_ProductProfileList[index];
if (!m_Product.mProfileList.size() || m_Product.mProfileList.find(profileName) == m_Product.mProfileList.end())
{
//Profile not found
return ::rtl::OUString();
}
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;
ProductStruct &m_Product = m_ProductProfileList[index];
return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
}
::sal_Int32 ProfileAccess::getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException)
{
sal_Int32 index=product;
ProductStruct &m_Product = m_ProductProfileList[index];
list.realloc(static_cast<sal_Int32>(m_Product.mProfileList.size()));
sal_Int32 i=0;
for(ProfileList::iterator itor=m_Product.mProfileList.begin();
itor != m_Product.mProfileList.end();
itor++)
{
ProfileStruct * aProfile = (*itor).second;
list[i] = aProfile->getProfileName();
i++;
}
return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
}
::rtl::OUString ProfileAccess::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException)
{
sal_Int32 index=product;
ProductStruct &m_Product = m_ProductProfileList[index];
if (m_Product.mCurrentProfileName.getLength() != 0)
{
//default profile setted in mozilla registry
return m_Product.mCurrentProfileName;
}
if (m_Product.mProfileList.size() == 0)
{
//there are not any profiles
return ::rtl::OUString();
}
ProfileStruct * aProfile = (*m_Product.mProfileList.begin()).second;
return aProfile->getProfileName();
}
::sal_Bool ProfileAccess::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
{
(void)product; /* avoid warning about unused parameter */
(void)profileName; /* avoid warning about unused parameter */
return sal_True;
}
::sal_Bool ProfileAccess::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
{
sal_Int32 index=product;
ProductStruct &m_Product = m_ProductProfileList[index];
if (!m_Product.mProfileList.size() || m_Product.mProfileList.find(profileName) == m_Product.mProfileList.end())
{
return sal_False;
}
else
return sal_True;
}
}
}
/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
#ifndef __MNSProfileDiscover_h___
#define __MNSProfileDiscover_h___
#include <sal/types.h>
#include <osl/diagnose.h>
#include <osl/conditn.hxx>
#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_
#include <com/sun/star/mozilla/MozillaProductType.hpp>
#endif
#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <rtl/ustring.hxx>
#include <vector>
#include <map>
using namespace com::sun::star::mozilla;
namespace connectivity
{
namespace mozab
{
class ProfileStruct;
}
}
typedef ::std::map < ::rtl::OUString, ::connectivity::mozab::ProfileStruct* > ProfileList;
namespace connectivity
{
namespace mozab
{
class ProfileStruct
{
public:
ProfileStruct(MozillaProductType aProduct,::rtl::OUString aProfileName,
const ::rtl::OUString &aProfilePath );
MozillaProductType getProductType() { return product;}
::rtl::OUString getProfileName(){ return profileName;}
::rtl::OUString getProfilePath() ;
protected:
MozillaProductType product;
::rtl::OUString profileName;
::rtl::OUString profilePath;
};
class ProductStruct
{
public:
void setCurrentProfile(::rtl::OUString aProfileName){mCurrentProfileName = aProfileName;}
::rtl::OUString mCurrentProfileName;
ProfileList mProfileList;
};
//Used to query profiles information
class ProfileAccess
{
public:
virtual ~ProfileAccess();
ProfileAccess();
::rtl::OUString getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
::sal_Int32 getProfileCount( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
::sal_Int32 getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException);
::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();
sal_Int32 LoadXPToolkitProfiles(MozillaProductType product);
};
}
}
#endif // __MNSProfileDiscover_h___
#**************************************************************
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#**************************************************************
CALL_CDECL=TRUE
PRJ=..$/..
PRJNAME=extensions
TARGET=mozbootstrap
.IF "$(OS)" == "OS2" || "$(OS)" == "WNT"
all:
@echo " Not building under Windows / OS/2"
.ENDIF
# --- Settings ----------------------------------
LIBTARGET=NO
ENABLE_EXCEPTIONS=TRUE
VISIBILITY_HIDDEN=TRUE
.INCLUDE : settings.mk
# no "lib" prefix
DLLPRE =
# --- Files -------------------------------------
SLOFILES += \
$(SLO)$/MNSINIParser.obj \
$(SLO)$/MNSProfileDiscover.obj \
$(SLO)$/MMozillaBootstrap.obj \
$(SLO)$/MNSFolders.obj
# CDEFS+=-DMINIMAL_PROFILEDISCOVER
SHL1TARGET=$(TARGET).uno
SHL1VERSIONMAP=$(SOLARENV)/src/component.map
SHL1OBJS=$(SLOFILES)
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
DEF1NAME=$(SHL1TARGET)
SHL1STDLIBS=\
$(CPPULIB) \
$(CPPUHELPERLIB) \
$(SALLIB) \
$(COMPHELPERLIB)
ALLTAR : $(MISC)/mozbootstrap.component
$(MISC)/mozbootstrap.component .ERRREMOVE : \
$(SOLARENV)/bin/createcomponent.xslt mozbootstrap.component
$(XSLTPROC) --nonet --stringparam uri \
'$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \
$(SOLARENV)/bin/createcomponent.xslt mozbootstrap.component
# --- Targets ----------------------------------
.INCLUDE : target.mk
<?xml version="1.0" encoding="UTF-8"?>
<!--***********************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
***********************************************************-->
<component loader="com.sun.star.loader.SharedLibrary"
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.mozilla.MozillaBootstrap">
<service name="com.sun.star.mozilla.MozillaBootstrap"/>
</implementation>
</component>
......@@ -211,6 +211,10 @@ my_components += component/vcl/vcl.unx
my_components += updchk.uno
.END
.IF "$(OS)" != "WNT" && "$(OS)" != "OS2"
my_components += mozbootstrap
.END
.IF "$(ENABLE_OOOIMPROVEMENT)" != ""
my_components += oooimprovement
.END
......
......@@ -553,6 +553,15 @@ End
#endif
#if !defined WNT && !defined OS2
File gid_File_Lib_Mozbootstrap
TXT_FILE_BODY;
Styles = (PACKED);
Dir = SCP2_OOO_BIN_DIR;
Name = SPECIAL_COMPONENT_LIB_NAME(mozbootstrap.uno);
End
#endif
#if defined UNX && ! defined MACOSX
File gid_File_Lib_Desktopbe
......
......@@ -373,6 +373,9 @@ Module gid_Module_Root_Files_5
gid_File_Lib_XSec_XMLSecurity,
gid_File_Lib_XSec_Framework,
gid_File_Lib_XSec_XmlSec,
#if !defined WNT && ! defined OS2
gid_File_Lib_Mozbootstrap,
#endif
gid_File_Lib_Xstor,
gid_File_CanvasFactory,
gid_File_SimpleCanvas,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment