Kaydet (Commit) db8074cb authored tarafından David Ostrovsky's avatar David Ostrovsky Kaydeden (comit) Michael Stahl

Mork: Reuse profile discovery from mozilla bootstrap

Mozilla bootstrap driver is used in xmlsecurity to discover default
profile and induce the path to the public keys file location from
certification authorities. The same profile discovery code is used
in mork driver. Remove duplicated code and re-use the service from
mozilla bootstrap driver in mork driver.

Change-Id: I6bc271ccf75e89eb81767186ddd9078c1f64b73d
Reviewed-on: https://gerrit.libreoffice.org/20111Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
Tested-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 795c61e0
......@@ -44,9 +44,6 @@ $(eval $(call gb_Library_use_sdk_api,mork))
$(eval $(call gb_Library_add_exception_objects,mork, \
connectivity/source/drivers/mork/MColumns \
connectivity/source/drivers/mork/MColumnAlias \
connectivity/source/drivers/mork/MNSFolders \
connectivity/source/drivers/mork/MNSINIParser \
connectivity/source/drivers/mork/MNSProfileDiscover \
connectivity/source/drivers/mork/MorkParser \
connectivity/source/drivers/mork/MCatalog \
connectivity/source/drivers/mork/MConnection \
......
......@@ -7,7 +7,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include "MNSProfileDiscover.hxx"
#include "MConnection.hxx"
#include "MDriver.hxx"
#include "MDatabaseMetaData.hxx"
......@@ -51,7 +50,6 @@ OConnection::OConnection(MorkDriver* _pDriver)
,m_aColumnAlias( _pDriver->getFactory() )
{
m_pDriver->acquire();
m_pProfileAccess = new ProfileAccess();
m_pBook = new MorkParser();
m_pHistory = new MorkParser();
}
......@@ -62,7 +60,6 @@ OConnection::~OConnection()
close();
m_pDriver->release();
m_pDriver = nullptr;
delete m_pProfileAccess;
delete m_pBook;
delete m_pHistory;
}
......@@ -121,9 +118,7 @@ void OConnection::construct(const OUString& url,const Sequence< PropertyValue >&
// production?
if (unittestIndex == -1)
{
OUString defaultProfile = m_pProfileAccess->getDefaultProfile(::com::sun::star::mozilla::MozillaProductType_Thunderbird);
OUString path = m_pProfileAccess->getProfilePath(::com::sun::star::mozilla::MozillaProductType_Thunderbird, defaultProfile);
SAL_INFO("connectivity.mork", "DefaultProfile: " << defaultProfile);
OUString path = m_pDriver->getProfilePath();
SAL_INFO("connectivity.mork", "ProfilePath: " << path);
abook = path + "/abook.mab";
history = path + "/history.mab";
......
......@@ -30,7 +30,6 @@ namespace connectivity
namespace mork
{
class MorkDriver;
class ProfileAccess;
class ErrorDescriptor;
typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding
......@@ -48,8 +47,6 @@ namespace connectivity
MorkDriver* m_pDriver; // Pointer to the owning
// driver object
OColumnAlias m_aColumnAlias;
// Profile Access
ProfileAccess* m_pProfileAccess;
// Mork Parser (abook)
MorkParser* m_pBook;
// Mork Parser (history)
......
......@@ -10,7 +10,9 @@
#include <cppuhelper/supportsservice.hxx>
#include "MDriver.hxx"
#include "MConnection.hxx"
#include "MNSProfileDiscover.hxx"
#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
#include <com/sun/star/mozilla/MozillaProductType.hpp>
#include "resource/mork_res.hrc"
#include "resource/common_res.hrc"
......@@ -33,8 +35,6 @@ MorkDriver::MorkDriver(css::uno::Reference< css::uno::XComponentContext > const
m_xFactory(context_->getServiceManager(), css::uno::UNO_QUERY)
{
SAL_INFO("connectivity.mork", "=> MorkDriver::MorkDriver()" );
// css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceFactory(;
assert(context.is());
}
// static ServiceInfo
......@@ -77,6 +77,25 @@ css::uno::Reference< css::sdbc::XConnection > MorkDriver::connect(
SAL_INFO("connectivity.mork", "=> MorkDriver::connect()" );
(void) url; (void) info; // avoid warnings
// Profile discovery
css::uno::Reference<css::uno::XInterface> xInstance = context_->getServiceManager()->createInstanceWithContext("com.sun.star.mozilla.MozillaBootstrap", context_);
OSL_ENSURE( xInstance.is(), "failed to create instance" );
css::uno::Reference<::com::sun::star::mozilla::XMozillaBootstrap> xMozillaBootstrap(xInstance, css::uno::UNO_QUERY);
OSL_ENSURE( xMozillaBootstrap.is(), "failed to create instance" );
if (xMozillaBootstrap.is())
{
OUString defaultProfile = xMozillaBootstrap->getDefaultProfile(::com::sun::star::mozilla::MozillaProductType_Thunderbird);
if (!defaultProfile.isEmpty())
{
m_sProfilePath = xMozillaBootstrap->getProfilePath(::com::sun::star::mozilla::MozillaProductType_Thunderbird, defaultProfile);
SAL_INFO("connectivity.mork", "Using Thunderbird profile " << m_sProfilePath);
}
}
css::uno::Reference< css::sdbc::XConnection > xCon;
OConnection* pCon = new OConnection(this);
xCon = pCon; // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
......
......@@ -58,6 +58,7 @@ public:
throw (css::uno::RuntimeException);
css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > getFactory(){return m_xFactory;}
OUString getProfilePath() {return m_sProfilePath;}
private:
virtual ~MorkDriver() {}
......@@ -94,6 +95,7 @@ private:
css::uno::Reference< css::uno::XComponentContext > context_;
css::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xFactory;
OUString m_sProfilePath;
};
} }
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#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 OUString lcl_getUserDataDirectory()
{
::osl::Security aSecurity;
OUString aConfigPath;
#if defined(WNT) || defined(MACOSX)
aSecurity.getConfigDir( aConfigPath );
#else
//This is to find the dir under which .mozilla/.thunderbird is created.
//mozilla doesn't honour XDG_CONFIG_HOME, so raw home dir required here
//not xdg-config dir
aSecurity.getHomeDir( aConfigPath );
#endif
return aConfigPath + "/";
}
const size_t NB_PRODUCTS = 3;
const size_t NB_CANDIDATES = 4;
// The order (index) of entries in DefaultProductDir and
// ProductRootEnvironmentVariable *must* match the constants
// (minus 1) in offapi/com/sun/star/mozilla/MozillaProductType.idl
// DO NOT CHANGE THE ORDER; ADD ONLY TO THE END
static const char* DefaultProductDir[NB_PRODUCTS][NB_CANDIDATES] =
{
#if defined(WNT)
{ "Mozilla/SeaMonkey/", NULL, NULL, NULL },
{ "Mozilla/Firefox/", NULL, NULL, NULL },
{ "Thunderbird/", "Mozilla/Thunderbird/", NULL, NULL }
#elif defined(MACOSX)
{ "../Mozilla/SeaMonkey/", nullptr, nullptr, nullptr },
{ "Firefox/", nullptr, nullptr, nullptr },
{ "../Thunderbird/", nullptr, nullptr, nullptr }
#else
{ ".mozilla/seamonkey/", nullptr, nullptr, nullptr },
{ ".mozilla/firefox/", nullptr, nullptr, nullptr },
{ ".thunderbird/", ".mozilla-thunderbird/", ".mozilla/thunderbird/", ".icedove/" }
#endif
};
static const char* ProductRootEnvironmentVariable[NB_PRODUCTS] =
{
"MOZILLA_PROFILE_ROOT",
"MOZILLA_FIREFOX_PROFILE_ROOT",
"MOZILLA_THUNDERBIRD_PROFILE_ROOT",
};
static OUString lcl_guessProfileRoot( MozillaProductType _product )
{
size_t productIndex = _product - 1;
static OUString s_productDirectories[NB_PRODUCTS];
if ( s_productDirectories[ productIndex ].isEmpty() )
{
OUString sProductPath;
// check whether we have an anevironment variable which helps us
const char* pProfileByEnv = getenv( ProductRootEnvironmentVariable[ productIndex ] );
if ( pProfileByEnv )
{
sProductPath = OUString( pProfileByEnv, rtl_str_getLength( pProfileByEnv ), osl_getThreadTextEncoding() );
// assume that this is fine, no further checks
}
else
{
OUString sProductDirCandidate;
const char* pProfileRegistry = "profiles.ini";
// check all possible candidates
for ( size_t i=0; i<NB_CANDIDATES; ++i )
{
if ( nullptr == DefaultProductDir[ productIndex ][ i ] )
break;
sProductDirCandidate = lcl_getUserDataDirectory() +
OUString::createFromAscii( DefaultProductDir[ productIndex ][ i ] );
// check existence
::osl::DirectoryItem aRegistryItem;
::osl::FileBase::RC result = ::osl::DirectoryItem::get( sProductDirCandidate + OUString::createFromAscii( pProfileRegistry ), aRegistryItem );
if ( result == ::osl::FileBase::E_None )
{
::osl::FileStatus aStatus( osl_FileStatus_Mask_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 ];
}
}
OUString getRegistryDir(MozillaProductType product)
{
if (product == MozillaProductType_Default)
return OUString();
return lcl_guessProfileRoot( product );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MNSFOLDERS_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MNSFOLDERS_HXX
#include <sal/types.h>
#include <osl/diagnose.h>
#include <osl/conditn.hxx>
#include <com/sun/star/mozilla/MozillaProductType.hpp>
#include <rtl/ustring.hxx>
OUString getRegistryDir(::com::sun::star::mozilla::MozillaProductType product);
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "MNSINIParser.hxx"
#include <rtl/byteseq.hxx>
IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException )
{
OUString iniUrl;
oslFileError fileError = osl_getFileURLFromSystemPath(
rIniName.pData, &iniUrl.pData);
if (fileError != osl_File_E_None)
{
SAL_WARN(
"connectivity.mork",
"InitParser, getFileURLFromSystemPath(" << rIniName << "): "
<< +fileError);
return;
}
SAL_INFO("connectivity.mork", "IniParser: " << iniUrl);
oslFileHandle handle=nullptr;
fileError = osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read);
if (osl_File_E_None == fileError)
{
rtl::ByteSequence seq;
sal_uInt64 nSize = 0;
osl_getFileSize(handle, &nSize);
OUString sectionName( "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 , reinterpret_cast<sal_Sequence **>(&seq)))
break;
OString line( reinterpret_cast<const 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.isEmpty())
sectionName = "no name section";
ini_Section *aSection = &mAllSection[sectionName];
aSection->sName = sectionName;
}
}
}
osl_closeFile(handle);
}
else
{
SAL_INFO(
"connectivity.mork",
"IniParser couldn't open file " << iniUrl << ": " << +fileError);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MNSINIPARSER_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MNSINIPARSER_HXX
#include <rtl/ustring.hxx>
#include <com/sun/star/io/IOException.hpp>
#include <osl/process.h>
#include <map>
#include <list>
struct ini_NameValue
{
OUString sName;
OUString sValue;
inline ini_NameValue()
{}
inline ini_NameValue(
OUString const & name, OUString const & value )
: sName( name ),
sValue( value )
{}
};
typedef std::list<
ini_NameValue
> NameValueList;
struct ini_Section
{
OUString sName;
NameValueList lList;
};
typedef std::map<OUString,
ini_Section
>IniSectionMap;
class IniParser
{
IniSectionMap mAllSection;
public:
IniSectionMap& getAllSection() { return mAllSection; }
explicit IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException);
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "MNSProfileDiscover.hxx"
#include "MNSFolders.hxx"
#include "MNSINIParser.hxx"
namespace connectivity
{
namespace mork
{
ProfileStruct::ProfileStruct(MozillaProductType aProduct, const OUString& aProfileName,
const OUString& aProfilePath
)
{
product=aProduct;
profileName = aProfileName;
profilePath = aProfilePath;
}
ProfileAccess::~ProfileAccess()
{
}
ProfileAccess::ProfileAccess()
{
LoadProductsInfo();
}
sal_Int32 ProfileAccess::LoadProductsInfo()
{
//tdf#39279: LO should search Thunderbird first then Seamonkey and finally Firefox
//load thunderbird profiles to m_ProductProfileList
sal_Int32 count = LoadXPToolkitProfiles(MozillaProductType_Thunderbird);
//load SeaMonkey 2 profiles to m_ProductProfileList
count += LoadXPToolkitProfiles(MozillaProductType_Mozilla);
//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];
OUString regDir = getRegistryDir(product);
OUString profilesIni = regDir + "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;
OUString profileName;
OUString profilePath;
OUString sIsRelative;
OUString sIsDefault;
for(NameValueList::iterator itor=aSection->lList.begin();
itor != aSection->lList.end();
++itor)
{
struct ini_NameValue * aValue = &(*itor);
if ( aValue->sName == "Name" )
{
profileName = aValue->sValue;
}
else if ( aValue->sName == "IsRelative" )
{
sIsRelative = aValue->sValue;
}
else if ( aValue->sName == "Path" )
{
profilePath = aValue->sValue;
}
else if ( aValue->sName == "Default" )
{
sIsDefault = aValue->sValue;
}
}
if (!(profileName.isEmpty() && profilePath.isEmpty()))
{
sal_Int32 isRelative = 0;
if (!sIsRelative.isEmpty())
{
isRelative = sIsRelative.toInt32();
}
OUString fullProfilePath;
if(isRelative)
{
fullProfilePath = regDir + profilePath;
}
else
{
fullProfilePath = profilePath;
}
m_Product.mProfileList[profileName] = ProfileStruct(product,profileName,
fullProfilePath
);
sal_Int32 isDefault = 0;
if (!sIsDefault.isEmpty())
{
isDefault = sIsDefault.toInt32();
}
if (isDefault)
m_Product.mCurrentProfileName = profileName;
}
}
return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
}
OUString ProfileAccess::getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
{
sal_Int32 index=product;
ProductStruct &m_Product = m_ProductProfileList[index];
if (m_Product.mProfileList.empty() || m_Product.mProfileList.find(profileName) == m_Product.mProfileList.end())
{
//Profile not found
return OUString();
}
else
return m_Product.mProfileList[profileName].getProfilePath();
}
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.isEmpty())
{
//default profile setted in mozilla registry
return m_Product.mCurrentProfileName;
}
if (m_Product.mProfileList.empty())
{
//there are not any profiles
return OUString();
}
return (*m_Product.mProfileList.begin()).second.getProfileName();
}
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MNSPROFILEDISCOVER_HXX
#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MNSPROFILEDISCOVER_HXX
#include <sal/types.h>
#include <osl/diagnose.h>
#include <osl/conditn.hxx>
#include <com/sun/star/mozilla/MozillaProductType.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
#include <com/sun/star/uno/Sequence.hxx>
#include <rtl/ustring.hxx>
#include <vector>
#include <map>
#include "dllapi.h"
using namespace com::sun::star::mozilla;
namespace connectivity
{
namespace mork
{
class ProfileStruct
{
public:
ProfileStruct(MozillaProductType aProduct = MozillaProductType_Default, const OUString& aProfileName = OUString(),
const OUString &aProfilePath = OUString()
);
OUString getProfileName(){ return profileName;}
OUString getProfilePath() { return profilePath; }
protected:
MozillaProductType product;
OUString profileName;
OUString profilePath;
};
typedef ::std::map < OUString, ProfileStruct > ProfileList;
class ProductStruct
{
public:
OUString mCurrentProfileName;
ProfileList mProfileList;
};
//Used to query profiles information
class LO_DLLPUBLIC_MORK ProfileAccess
{
public:
virtual ~ProfileAccess();
ProfileAccess();
OUString getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
OUString getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
protected:
ProductStruct m_ProductProfileList[4];
sal_Int32 LoadProductsInfo();
sal_Int32 LoadXPToolkitProfiles(MozillaProductType product);
};
}
}
#endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MORK_MNSPROFILEDISCOVER_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#include "MNSProfileDiscover.hxx"
#include "MorkParser.hxx"
using namespace connectivity::mork;
#include "MorkParser.hxx"
#include <iostream>
bool openAddressBook(const std::string& path)
{
......@@ -35,20 +33,21 @@ bool openAddressBook(const std::string& path)
return true;
}
int main(void)
int main(int argc, char* argv[])
{
ProfileAccess* access = new ProfileAccess();
OUString defaultProfile = access->getDefaultProfile(::com::sun::star::mozilla::MozillaProductType_Thunderbird);
SAL_INFO("connectivity.mork", "DefaultProfile: " << defaultProfile);
if (argc < 2)
{
std::cerr << "Usage: " << argv[0] << " <path-to>/abook.mab" << std::endl;
std::cerr << "Example: " << argv[0] << " /home/johndoe/.thunderbird/m0tpqlky.default/abook.mab" << std::endl;
OUString profilePath = access->getProfilePath(::com::sun::star::mozilla::MozillaProductType_Thunderbird, defaultProfile);
SAL_INFO("connectivity.mork", "ProfilePath: " << profilePath);
return 1;
}
profilePath += "/abook.mab";
OString aOString(argv[1]);
SAL_INFO("connectivity.mork", "abook.mab: " << aOString);
openAddressBook(aOString.getStr());
SAL_INFO("connectivity.mork", "abook.mab: " << profilePath);
OString aOString = OUStringToOString( profilePath, RTL_TEXTENCODING_UTF8 );
openAddressBook(aOString.getStr());
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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