From db8074cb7b1e8453d05ca361030b0ccd1801d368 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Sat, 21 Nov 2015 22:31:33 +0100 Subject: 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/20111 Reviewed-by: Michael Stahl Tested-by: Michael Stahl --- connectivity/Library_mork.mk | 3 - connectivity/source/drivers/mork/MConnection.cxx | 7 +- connectivity/source/drivers/mork/MConnection.hxx | 3 - connectivity/source/drivers/mork/MDriver.cxx | 25 ++- connectivity/source/drivers/mork/MDriver.hxx | 2 + connectivity/source/drivers/mork/MNSFolders.cxx | 160 ------------------- connectivity/source/drivers/mork/MNSFolders.hxx | 34 ---- connectivity/source/drivers/mork/MNSINIParser.cxx | 95 ----------- connectivity/source/drivers/mork/MNSINIParser.hxx | 68 -------- .../source/drivers/mork/MNSProfileDiscover.cxx | 173 --------------------- .../source/drivers/mork/MNSProfileDiscover.hxx | 85 ---------- connectivity/source/drivers/mork/mork_helper.cxx | 27 ++-- 12 files changed, 38 insertions(+), 644 deletions(-) delete mode 100644 connectivity/source/drivers/mork/MNSFolders.cxx delete mode 100644 connectivity/source/drivers/mork/MNSFolders.hxx delete mode 100644 connectivity/source/drivers/mork/MNSINIParser.cxx delete mode 100644 connectivity/source/drivers/mork/MNSINIParser.hxx delete mode 100644 connectivity/source/drivers/mork/MNSProfileDiscover.cxx delete mode 100644 connectivity/source/drivers/mork/MNSProfileDiscover.hxx (limited to 'connectivity') diff --git a/connectivity/Library_mork.mk b/connectivity/Library_mork.mk index 18917c572978..dd655ca751cc 100644 --- a/connectivity/Library_mork.mk +++ b/connectivity/Library_mork.mk @@ -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 \ diff --git a/connectivity/source/drivers/mork/MConnection.cxx b/connectivity/source/drivers/mork/MConnection.cxx index e836938ca6c1..3016c79706d9 100644 --- a/connectivity/source/drivers/mork/MConnection.cxx +++ b/connectivity/source/drivers/mork/MConnection.cxx @@ -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"; diff --git a/connectivity/source/drivers/mork/MConnection.hxx b/connectivity/source/drivers/mork/MConnection.hxx index ad65d18258d6..fd101a20e249 100644 --- a/connectivity/source/drivers/mork/MConnection.hxx +++ b/connectivity/source/drivers/mork/MConnection.hxx @@ -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) diff --git a/connectivity/source/drivers/mork/MDriver.cxx b/connectivity/source/drivers/mork/MDriver.cxx index 4c944b90650e..58da828842b6 100644 --- a/connectivity/source/drivers/mork/MDriver.cxx +++ b/connectivity/source/drivers/mork/MDriver.cxx @@ -10,7 +10,9 @@ #include #include "MDriver.hxx" #include "MConnection.hxx" -#include "MNSProfileDiscover.hxx" + +#include +#include #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 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) diff --git a/connectivity/source/drivers/mork/MDriver.hxx b/connectivity/source/drivers/mork/MDriver.hxx index 63480bdec364..7f3e75e6d225 100644 --- a/connectivity/source/drivers/mork/MDriver.hxx +++ b/connectivity/source/drivers/mork/MDriver.hxx @@ -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; }; } } diff --git a/connectivity/source/drivers/mork/MNSFolders.cxx b/connectivity/source/drivers/mork/MNSFolders.cxx deleted file mode 100644 index 46da642c288f..000000000000 --- a/connectivity/source/drivers/mork/MNSFolders.cxx +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- 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 -#include -#include -#endif // End UNIX - -#ifdef WNT -#include "pre_include_windows.h" -#include -#include -#include -#include -#include "post_include_windows.h" -#endif // End WNT -#include -#include -#include - -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 -#include -#include -#include - -#include - -OUString getRegistryDir(::com::sun::star::mozilla::MozillaProductType product); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/connectivity/source/drivers/mork/MNSINIParser.cxx b/connectivity/source/drivers/mork/MNSINIParser.cxx deleted file mode 100644 index 585b58497b52..000000000000 --- a/connectivity/source/drivers/mork/MNSINIParser.cxx +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- 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 - -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(&seq))) - break; - OString line( reinterpret_cast(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: */ diff --git a/connectivity/source/drivers/mork/MNSINIParser.hxx b/connectivity/source/drivers/mork/MNSINIParser.hxx deleted file mode 100644 index fd3c518b190f..000000000000 --- a/connectivity/source/drivers/mork/MNSINIParser.hxx +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- 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 -#include -#include - -#include -#include - -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::mapIniSectionMap; - - -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: */ diff --git a/connectivity/source/drivers/mork/MNSProfileDiscover.cxx b/connectivity/source/drivers/mork/MNSProfileDiscover.cxx deleted file mode 100644 index ada471aeb904..000000000000 --- a/connectivity/source/drivers/mork/MNSProfileDiscover.cxx +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- 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: */ diff --git a/connectivity/source/drivers/mork/MNSProfileDiscover.hxx b/connectivity/source/drivers/mork/MNSProfileDiscover.hxx deleted file mode 100644 index a7aae562a254..000000000000 --- a/connectivity/source/drivers/mork/MNSProfileDiscover.hxx +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- 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 -#include -#include -#include -#include -#include -#include - -#include -#include - -#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: */ diff --git a/connectivity/source/drivers/mork/mork_helper.cxx b/connectivity/source/drivers/mork/mork_helper.cxx index 8231d716a620..d2779cf4c5b5 100644 --- a/connectivity/source/drivers/mork/mork_helper.cxx +++ b/connectivity/source/drivers/mork/mork_helper.cxx @@ -1,9 +1,7 @@ /* -*- 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 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] << " /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: */ -- cgit