1*b5088357SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b5088357SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b5088357SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b5088357SAndrew Rist * distributed with this work for additional information 6*b5088357SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b5088357SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b5088357SAndrew Rist * "License"); you may not use this file except in compliance 9*b5088357SAndrew Rist * with the License. You may obtain a copy of the License at 10*b5088357SAndrew Rist * 11*b5088357SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*b5088357SAndrew Rist * 13*b5088357SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b5088357SAndrew Rist * software distributed under the License is distributed on an 15*b5088357SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b5088357SAndrew Rist * KIND, either express or implied. See the License for the 17*b5088357SAndrew Rist * specific language governing permissions and limitations 18*b5088357SAndrew Rist * under the License. 19*b5088357SAndrew Rist * 20*b5088357SAndrew Rist *************************************************************/ 21*b5088357SAndrew Rist 22*b5088357SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_unotools.hxx" 26cdf0e10cSrcweir #include <unotools/inetoptions.hxx> 27cdf0e10cSrcweir #include "rtl/instance.hxx" 28cdf0e10cSrcweir #include <tools/urlobj.hxx> 29cdf0e10cSrcweir #ifndef _WILDCARD_HXX 30cdf0e10cSrcweir #include <tools/wldcrd.hxx> 31cdf0e10cSrcweir #endif 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <algorithm> 34cdf0e10cSrcweir #include <map> 35cdf0e10cSrcweir #include <set> 36cdf0e10cSrcweir #include <vector> 37cdf0e10cSrcweir #include <utility> 38cdf0e10cSrcweir #include <com/sun/star/beans/PropertyChangeEvent.hpp> 39cdf0e10cSrcweir #include <com/sun/star/beans/XPropertiesChangeListener.hpp> 40cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 41cdf0e10cSrcweir #include <com/sun/star/system/XProxySettings.hpp> 42cdf0e10cSrcweir #include <com/sun/star/uno/Any.hxx> 43cdf0e10cSrcweir #include <com/sun/star/uno/Exception.hpp> 44cdf0e10cSrcweir #include <com/sun/star/uno/Reference.hxx> 45cdf0e10cSrcweir #include <com/sun/star/uno/RuntimeException.hpp> 46cdf0e10cSrcweir #include <osl/mutex.hxx> 47cdf0e10cSrcweir #include <rtl/ustring.h> 48cdf0e10cSrcweir #include <rtl/ustring.hxx> 49cdf0e10cSrcweir #include <sal/types.h> 50cdf0e10cSrcweir #include <unotools/configitem.hxx> 51cdf0e10cSrcweir #include <unotools/processfactory.hxx> 52cdf0e10cSrcweir #include <osl/diagnose.h> 53cdf0e10cSrcweir #include <salhelper/refobj.hxx> 54cdf0e10cSrcweir #include <rtl/logfile.hxx> 55cdf0e10cSrcweir #include "itemholder1.hxx" 56cdf0e10cSrcweir 57cdf0e10cSrcweir using namespace com::sun; 58cdf0e10cSrcweir 59cdf0e10cSrcweir //============================================================================ 60cdf0e10cSrcweir // 61cdf0e10cSrcweir // takeAny 62cdf0e10cSrcweir // 63cdf0e10cSrcweir //============================================================================ 64cdf0e10cSrcweir 65cdf0e10cSrcweir namespace { 66cdf0e10cSrcweir 67cdf0e10cSrcweir template< typename T > inline T takeAny(star::uno::Any const & rAny) 68cdf0e10cSrcweir { 69cdf0e10cSrcweir T aValue = T(); 70cdf0e10cSrcweir rAny >>= aValue; 71cdf0e10cSrcweir return aValue; 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir } 75cdf0e10cSrcweir 76cdf0e10cSrcweir //============================================================================ 77cdf0e10cSrcweir // 78cdf0e10cSrcweir // SvtInetOptions::Impl 79cdf0e10cSrcweir // 80cdf0e10cSrcweir //============================================================================ 81cdf0e10cSrcweir 82cdf0e10cSrcweir class SvtInetOptions::Impl: public salhelper::ReferenceObject, 83cdf0e10cSrcweir public utl::ConfigItem 84cdf0e10cSrcweir { 85cdf0e10cSrcweir public: 86cdf0e10cSrcweir enum Index 87cdf0e10cSrcweir { 88cdf0e10cSrcweir INDEX_NO_PROXY, 89cdf0e10cSrcweir INDEX_PROXY_TYPE, 90cdf0e10cSrcweir INDEX_FTP_PROXY_NAME, 91cdf0e10cSrcweir INDEX_FTP_PROXY_PORT, 92cdf0e10cSrcweir INDEX_HTTP_PROXY_NAME, 93cdf0e10cSrcweir INDEX_HTTP_PROXY_PORT 94cdf0e10cSrcweir }; 95cdf0e10cSrcweir 96cdf0e10cSrcweir Impl(); 97cdf0e10cSrcweir 98cdf0e10cSrcweir star::uno::Any getProperty(Index nIndex); 99cdf0e10cSrcweir 100cdf0e10cSrcweir void 101cdf0e10cSrcweir setProperty(Index nIndex, star::uno::Any const & rValue, bool bFlush); 102cdf0e10cSrcweir 103cdf0e10cSrcweir inline void flush() { Commit(); } 104cdf0e10cSrcweir 105cdf0e10cSrcweir void 106cdf0e10cSrcweir addPropertiesChangeListener( 107cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > const & rPropertyNames, 108cdf0e10cSrcweir star::uno::Reference< star::beans::XPropertiesChangeListener > const & 109cdf0e10cSrcweir rListener); 110cdf0e10cSrcweir 111cdf0e10cSrcweir void 112cdf0e10cSrcweir removePropertiesChangeListener( 113cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > const & rPropertyNames, 114cdf0e10cSrcweir star::uno::Reference< star::beans::XPropertiesChangeListener > const & 115cdf0e10cSrcweir rListener); 116cdf0e10cSrcweir 117cdf0e10cSrcweir private: 118cdf0e10cSrcweir enum { ENTRY_COUNT = INDEX_HTTP_PROXY_PORT + 1 }; 119cdf0e10cSrcweir 120cdf0e10cSrcweir struct Entry 121cdf0e10cSrcweir { 122cdf0e10cSrcweir enum State { UNKNOWN, KNOWN, MODIFIED }; 123cdf0e10cSrcweir 124cdf0e10cSrcweir inline Entry(): m_eState(UNKNOWN) {} 125cdf0e10cSrcweir 126cdf0e10cSrcweir rtl::OUString m_aName; 127cdf0e10cSrcweir star::uno::Any m_aValue; 128cdf0e10cSrcweir State m_eState; 129cdf0e10cSrcweir }; 130cdf0e10cSrcweir 131cdf0e10cSrcweir // MSVC has problems with the below Map type when 132cdf0e10cSrcweir // star::uno::Reference< star::beans::XPropertiesChangeListener > is not 133cdf0e10cSrcweir // wrapped in class Listener: 134cdf0e10cSrcweir class Listener: 135cdf0e10cSrcweir public star::uno::Reference< star::beans::XPropertiesChangeListener > 136cdf0e10cSrcweir { 137cdf0e10cSrcweir public: 138cdf0e10cSrcweir Listener(star::uno::Reference< 139cdf0e10cSrcweir star::beans::XPropertiesChangeListener > const & 140cdf0e10cSrcweir rListener): 141cdf0e10cSrcweir star::uno::Reference< star::beans::XPropertiesChangeListener >( 142cdf0e10cSrcweir rListener) 143cdf0e10cSrcweir {} 144cdf0e10cSrcweir }; 145cdf0e10cSrcweir 146cdf0e10cSrcweir typedef std::map< Listener, std::set< rtl::OUString > > Map; 147cdf0e10cSrcweir 148cdf0e10cSrcweir osl::Mutex m_aMutex; 149cdf0e10cSrcweir Entry m_aEntries[ENTRY_COUNT]; 150cdf0e10cSrcweir Map m_aListeners; 151cdf0e10cSrcweir 152cdf0e10cSrcweir virtual inline ~Impl() { Commit(); } 153cdf0e10cSrcweir 154cdf0e10cSrcweir virtual void Notify(star::uno::Sequence< rtl::OUString > const & rKeys); 155cdf0e10cSrcweir 156cdf0e10cSrcweir virtual void Commit(); 157cdf0e10cSrcweir 158cdf0e10cSrcweir void notifyListeners(star::uno::Sequence< rtl::OUString > const & rKeys); 159cdf0e10cSrcweir }; 160cdf0e10cSrcweir 161cdf0e10cSrcweir //============================================================================ 162cdf0e10cSrcweir // virtual 163cdf0e10cSrcweir void 164cdf0e10cSrcweir SvtInetOptions::Impl::Notify(star::uno::Sequence< rtl::OUString > const & 165cdf0e10cSrcweir rKeys) 166cdf0e10cSrcweir { 167cdf0e10cSrcweir { 168cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 169cdf0e10cSrcweir for (sal_Int32 i = 0; i < rKeys.getLength(); ++i) 170cdf0e10cSrcweir for (sal_Int32 j = 0; j < ENTRY_COUNT; ++j) 171cdf0e10cSrcweir if (rKeys[i] == m_aEntries[j].m_aName) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir m_aEntries[j].m_eState = Entry::UNKNOWN; 174cdf0e10cSrcweir break; 175cdf0e10cSrcweir } 176cdf0e10cSrcweir } 177cdf0e10cSrcweir notifyListeners(rKeys); 178cdf0e10cSrcweir } 179cdf0e10cSrcweir 180cdf0e10cSrcweir //============================================================================ 181cdf0e10cSrcweir // virtual 182cdf0e10cSrcweir void SvtInetOptions::Impl::Commit() 183cdf0e10cSrcweir { 184cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > aKeys(ENTRY_COUNT); 185cdf0e10cSrcweir star::uno::Sequence< star::uno::Any > aValues(ENTRY_COUNT); 186cdf0e10cSrcweir sal_Int32 nCount = 0; 187cdf0e10cSrcweir { 188cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 189cdf0e10cSrcweir for (sal_Int32 i = 0; i < ENTRY_COUNT; ++i) 190cdf0e10cSrcweir if (m_aEntries[i].m_eState == Entry::MODIFIED) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir aKeys[nCount] = m_aEntries[i].m_aName; 193cdf0e10cSrcweir aValues[nCount] = m_aEntries[i].m_aValue; 194cdf0e10cSrcweir ++nCount; 195cdf0e10cSrcweir m_aEntries[i].m_eState = Entry::KNOWN; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir } 198cdf0e10cSrcweir if (nCount > 0) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir aKeys.realloc(nCount); 201cdf0e10cSrcweir aValues.realloc(nCount); 202cdf0e10cSrcweir PutProperties(aKeys, aValues); 203cdf0e10cSrcweir } 204cdf0e10cSrcweir } 205cdf0e10cSrcweir 206cdf0e10cSrcweir //============================================================================ 207cdf0e10cSrcweir void 208cdf0e10cSrcweir SvtInetOptions::Impl::notifyListeners( 209cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > const & rKeys) 210cdf0e10cSrcweir { 211cdf0e10cSrcweir typedef 212cdf0e10cSrcweir std::vector< std::pair< star::uno::Reference< 213cdf0e10cSrcweir star::beans::XPropertiesChangeListener >, 214cdf0e10cSrcweir star::uno::Sequence< 215cdf0e10cSrcweir star::beans::PropertyChangeEvent > > > 216cdf0e10cSrcweir List; 217cdf0e10cSrcweir List aNotifications; 218cdf0e10cSrcweir { 219cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 220cdf0e10cSrcweir aNotifications.reserve(m_aListeners.size()); 221cdf0e10cSrcweir Map::const_iterator aMapEnd(m_aListeners.end()); 222cdf0e10cSrcweir for (Map::const_iterator aIt(m_aListeners.begin()); aIt != aMapEnd; 223cdf0e10cSrcweir ++aIt) 224cdf0e10cSrcweir { 225cdf0e10cSrcweir const Map::mapped_type &rSet = aIt->second; 226cdf0e10cSrcweir Map::mapped_type::const_iterator aSetEnd(rSet.end()); 227cdf0e10cSrcweir star::uno::Sequence< star::beans::PropertyChangeEvent > 228cdf0e10cSrcweir aEvents(rKeys.getLength()); 229cdf0e10cSrcweir sal_Int32 nCount = 0; 230cdf0e10cSrcweir for (sal_Int32 i = 0; i < rKeys.getLength(); ++i) 231cdf0e10cSrcweir { 232cdf0e10cSrcweir rtl::OUString 233cdf0e10cSrcweir aTheKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( 234cdf0e10cSrcweir "Inet/"))); 235cdf0e10cSrcweir aTheKey += rKeys[i]; 236cdf0e10cSrcweir if (rSet.find(aTheKey) != aSetEnd) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir aEvents[nCount].PropertyName = aTheKey; 239cdf0e10cSrcweir aEvents[nCount].PropertyHandle = -1; 240cdf0e10cSrcweir ++nCount; 241cdf0e10cSrcweir } 242cdf0e10cSrcweir } 243cdf0e10cSrcweir if (nCount > 0) 244cdf0e10cSrcweir { 245cdf0e10cSrcweir aEvents.realloc(nCount); 246cdf0e10cSrcweir aNotifications. 247cdf0e10cSrcweir push_back(std::make_pair< List::value_type::first_type, 248cdf0e10cSrcweir List::value_type::second_type >( 249cdf0e10cSrcweir aIt->first, aEvents)); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir } 252cdf0e10cSrcweir } 253cdf0e10cSrcweir for (List::size_type i = 0; i < aNotifications.size(); ++i) 254cdf0e10cSrcweir if (aNotifications[i].first.is()) 255cdf0e10cSrcweir aNotifications[i].first-> 256cdf0e10cSrcweir propertiesChange(aNotifications[i].second); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir 259cdf0e10cSrcweir //============================================================================ 260cdf0e10cSrcweir SvtInetOptions::Impl::Impl(): 261cdf0e10cSrcweir ConfigItem(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Inet/Settings"))) 262cdf0e10cSrcweir { 263cdf0e10cSrcweir m_aEntries[INDEX_NO_PROXY].m_aName 264cdf0e10cSrcweir = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetNoProxy")); 265cdf0e10cSrcweir m_aEntries[INDEX_PROXY_TYPE].m_aName 266cdf0e10cSrcweir = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetProxyType")); 267cdf0e10cSrcweir m_aEntries[INDEX_FTP_PROXY_NAME].m_aName 268cdf0e10cSrcweir = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyName")); 269cdf0e10cSrcweir m_aEntries[INDEX_FTP_PROXY_PORT].m_aName 270cdf0e10cSrcweir = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyPort")); 271cdf0e10cSrcweir m_aEntries[INDEX_HTTP_PROXY_NAME].m_aName 272cdf0e10cSrcweir = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyName")); 273cdf0e10cSrcweir m_aEntries[INDEX_HTTP_PROXY_PORT].m_aName 274cdf0e10cSrcweir = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyPort")); 275cdf0e10cSrcweir 276cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > aKeys(ENTRY_COUNT); 277cdf0e10cSrcweir for (sal_Int32 i = 0; i < ENTRY_COUNT; ++i) 278cdf0e10cSrcweir aKeys[i] = m_aEntries[i].m_aName; 279cdf0e10cSrcweir if (!EnableNotification(aKeys)) 280cdf0e10cSrcweir OSL_ENSURE(false, 281cdf0e10cSrcweir "SvtInetOptions::Impl::Impl(): Bad EnableNotifications()"); 282cdf0e10cSrcweir } 283cdf0e10cSrcweir 284cdf0e10cSrcweir //============================================================================ 285cdf0e10cSrcweir star::uno::Any SvtInetOptions::Impl::getProperty(Index nPropIndex) 286cdf0e10cSrcweir { 287cdf0e10cSrcweir for (int nTryCount = 0; nTryCount < 10; ++nTryCount) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir { 290cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 291cdf0e10cSrcweir if (m_aEntries[nPropIndex].m_eState != Entry::UNKNOWN) 292cdf0e10cSrcweir return m_aEntries[nPropIndex].m_aValue; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > aKeys(ENTRY_COUNT); 295cdf0e10cSrcweir int nIndices[ENTRY_COUNT]; 296cdf0e10cSrcweir sal_Int32 nCount = 0; 297cdf0e10cSrcweir { 298cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 299cdf0e10cSrcweir for (int i = 0; i < ENTRY_COUNT; ++i) 300cdf0e10cSrcweir if (m_aEntries[i].m_eState == Entry::UNKNOWN) 301cdf0e10cSrcweir { 302cdf0e10cSrcweir aKeys[nCount] = m_aEntries[i].m_aName; 303cdf0e10cSrcweir nIndices[nCount] = i; 304cdf0e10cSrcweir ++nCount; 305cdf0e10cSrcweir } 306cdf0e10cSrcweir } 307cdf0e10cSrcweir if (nCount > 0) 308cdf0e10cSrcweir { 309cdf0e10cSrcweir aKeys.realloc(nCount); 310cdf0e10cSrcweir star::uno::Sequence< star::uno::Any > 311cdf0e10cSrcweir aValues(GetProperties(aKeys)); 312cdf0e10cSrcweir OSL_ENSURE(aValues.getLength() == nCount, 313cdf0e10cSrcweir "SvtInetOptions::Impl::getProperty():" 314cdf0e10cSrcweir " Bad GetProperties() result"); 315cdf0e10cSrcweir nCount = std::min(nCount, aValues.getLength()); 316cdf0e10cSrcweir { 317cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 318cdf0e10cSrcweir for (sal_Int32 i = 0; i < nCount; ++i) 319cdf0e10cSrcweir { 320cdf0e10cSrcweir int nIndex = nIndices[i]; 321cdf0e10cSrcweir if (m_aEntries[nIndex].m_eState == Entry::UNKNOWN) 322cdf0e10cSrcweir { 323cdf0e10cSrcweir m_aEntries[nIndices[i]].m_aValue = aValues[i]; 324cdf0e10cSrcweir m_aEntries[nIndices[i]].m_eState = Entry::KNOWN; 325cdf0e10cSrcweir } 326cdf0e10cSrcweir } 327cdf0e10cSrcweir } 328cdf0e10cSrcweir } 329cdf0e10cSrcweir } 330cdf0e10cSrcweir OSL_ENSURE(false, 331cdf0e10cSrcweir "SvtInetOptions::Impl::getProperty(): Possible life lock"); 332cdf0e10cSrcweir { 333cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 334cdf0e10cSrcweir return m_aEntries[nPropIndex].m_aValue; 335cdf0e10cSrcweir } 336cdf0e10cSrcweir } 337cdf0e10cSrcweir 338cdf0e10cSrcweir //============================================================================ 339cdf0e10cSrcweir void SvtInetOptions::Impl::setProperty(Index nIndex, 340cdf0e10cSrcweir star::uno::Any const & rValue, 341cdf0e10cSrcweir bool bFlush) 342cdf0e10cSrcweir { 343cdf0e10cSrcweir SetModified(); 344cdf0e10cSrcweir { 345cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 346cdf0e10cSrcweir m_aEntries[nIndex].m_aValue = rValue; 347cdf0e10cSrcweir m_aEntries[nIndex].m_eState = bFlush ? Entry::KNOWN : Entry::MODIFIED; 348cdf0e10cSrcweir } 349cdf0e10cSrcweir 350cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > aKeys(1); 351cdf0e10cSrcweir aKeys[0] = m_aEntries[nIndex].m_aName; 352cdf0e10cSrcweir if (bFlush) 353cdf0e10cSrcweir { 354cdf0e10cSrcweir star::uno::Sequence< star::uno::Any > aValues(1); 355cdf0e10cSrcweir aValues[0] = rValue; 356cdf0e10cSrcweir PutProperties(aKeys, aValues); 357cdf0e10cSrcweir } 358cdf0e10cSrcweir else 359cdf0e10cSrcweir notifyListeners(aKeys); 360cdf0e10cSrcweir } 361cdf0e10cSrcweir 362cdf0e10cSrcweir //============================================================================ 363cdf0e10cSrcweir void 364cdf0e10cSrcweir SvtInetOptions::Impl::addPropertiesChangeListener( 365cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > const & rPropertyNames, 366cdf0e10cSrcweir star::uno::Reference< star::beans::XPropertiesChangeListener > const & 367cdf0e10cSrcweir rListener) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 370cdf0e10cSrcweir Map::mapped_type & rEntry = m_aListeners[rListener]; 371cdf0e10cSrcweir for (sal_Int32 i = 0; i < rPropertyNames.getLength(); ++i) 372cdf0e10cSrcweir rEntry.insert(rPropertyNames[i]); 373cdf0e10cSrcweir } 374cdf0e10cSrcweir 375cdf0e10cSrcweir //============================================================================ 376cdf0e10cSrcweir void 377cdf0e10cSrcweir SvtInetOptions::Impl::removePropertiesChangeListener( 378cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > const & rPropertyNames, 379cdf0e10cSrcweir star::uno::Reference< star::beans::XPropertiesChangeListener > const & 380cdf0e10cSrcweir rListener) 381cdf0e10cSrcweir { 382cdf0e10cSrcweir osl::MutexGuard aGuard(m_aMutex); 383cdf0e10cSrcweir Map::iterator aIt(m_aListeners.find(rListener)); 384cdf0e10cSrcweir if (aIt != m_aListeners.end()) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir for (sal_Int32 i = 0; i < rPropertyNames.getLength(); ++i) 387cdf0e10cSrcweir aIt->second.erase(rPropertyNames[i]); 388cdf0e10cSrcweir if (aIt->second.empty()) 389cdf0e10cSrcweir m_aListeners.erase(aIt); 390cdf0e10cSrcweir } 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393cdf0e10cSrcweir //============================================================================ 394cdf0e10cSrcweir // 395cdf0e10cSrcweir // SvtInetOptions 396cdf0e10cSrcweir // 397cdf0e10cSrcweir //============================================================================ 398cdf0e10cSrcweir 399cdf0e10cSrcweir namespace 400cdf0e10cSrcweir { 401cdf0e10cSrcweir class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton > 402cdf0e10cSrcweir { 403cdf0e10cSrcweir }; 404cdf0e10cSrcweir } 405cdf0e10cSrcweir 406cdf0e10cSrcweir // static 407cdf0e10cSrcweir SvtInetOptions::Impl * SvtInetOptions::m_pImpl = 0; 408cdf0e10cSrcweir 409cdf0e10cSrcweir //============================================================================ 410cdf0e10cSrcweir SvtInetOptions::SvtInetOptions() 411cdf0e10cSrcweir { 412cdf0e10cSrcweir osl::MutexGuard aGuard(LocalSingleton::get()); 413cdf0e10cSrcweir if (!m_pImpl) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtInetOptions_Impl::ctor()"); 416cdf0e10cSrcweir m_pImpl = new Impl; 417cdf0e10cSrcweir 418cdf0e10cSrcweir ItemHolder1::holdConfigItem(E_INETOPTIONS); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir m_pImpl->acquire(); 421cdf0e10cSrcweir } 422cdf0e10cSrcweir 423cdf0e10cSrcweir //============================================================================ 424cdf0e10cSrcweir SvtInetOptions::~SvtInetOptions() 425cdf0e10cSrcweir { 426cdf0e10cSrcweir osl::MutexGuard aGuard(LocalSingleton::get()); 427cdf0e10cSrcweir if (m_pImpl->release() == 0) 428cdf0e10cSrcweir m_pImpl = 0; 429cdf0e10cSrcweir } 430cdf0e10cSrcweir 431cdf0e10cSrcweir //============================================================================ 432cdf0e10cSrcweir rtl::OUString SvtInetOptions::GetProxyNoProxy() const 433cdf0e10cSrcweir { 434cdf0e10cSrcweir return takeAny< rtl::OUString >(m_pImpl-> 435cdf0e10cSrcweir getProperty(Impl::INDEX_NO_PROXY)); 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir //============================================================================ 439cdf0e10cSrcweir sal_Int32 SvtInetOptions::GetProxyType() const 440cdf0e10cSrcweir { 441cdf0e10cSrcweir return takeAny< sal_Int32 >(m_pImpl-> 442cdf0e10cSrcweir getProperty(Impl::INDEX_PROXY_TYPE)); 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir //============================================================================ 446cdf0e10cSrcweir rtl::OUString SvtInetOptions::GetProxyFtpName() const 447cdf0e10cSrcweir { 448cdf0e10cSrcweir return takeAny< rtl::OUString >(m_pImpl-> 449cdf0e10cSrcweir getProperty( 450cdf0e10cSrcweir Impl::INDEX_FTP_PROXY_NAME)); 451cdf0e10cSrcweir } 452cdf0e10cSrcweir 453cdf0e10cSrcweir //============================================================================ 454cdf0e10cSrcweir sal_Int32 SvtInetOptions::GetProxyFtpPort() const 455cdf0e10cSrcweir { 456cdf0e10cSrcweir return takeAny< sal_Int32 >(m_pImpl-> 457cdf0e10cSrcweir getProperty(Impl::INDEX_FTP_PROXY_PORT)); 458cdf0e10cSrcweir } 459cdf0e10cSrcweir 460cdf0e10cSrcweir //============================================================================ 461cdf0e10cSrcweir rtl::OUString SvtInetOptions::GetProxyHttpName() const 462cdf0e10cSrcweir { 463cdf0e10cSrcweir return takeAny< rtl::OUString >(m_pImpl-> 464cdf0e10cSrcweir getProperty( 465cdf0e10cSrcweir Impl::INDEX_HTTP_PROXY_NAME)); 466cdf0e10cSrcweir } 467cdf0e10cSrcweir 468cdf0e10cSrcweir //============================================================================ 469cdf0e10cSrcweir sal_Int32 SvtInetOptions::GetProxyHttpPort() const 470cdf0e10cSrcweir { 471cdf0e10cSrcweir return takeAny< sal_Int32 >(m_pImpl-> 472cdf0e10cSrcweir getProperty(Impl::INDEX_HTTP_PROXY_PORT)); 473cdf0e10cSrcweir } 474cdf0e10cSrcweir 475cdf0e10cSrcweir //============================================================================ 476cdf0e10cSrcweir void SvtInetOptions::SetProxyNoProxy(rtl::OUString const & rValue, 477cdf0e10cSrcweir bool bFlush) 478cdf0e10cSrcweir { 479cdf0e10cSrcweir m_pImpl->setProperty(Impl::INDEX_NO_PROXY, 480cdf0e10cSrcweir star::uno::makeAny(rValue), 481cdf0e10cSrcweir bFlush); 482cdf0e10cSrcweir } 483cdf0e10cSrcweir 484cdf0e10cSrcweir //============================================================================ 485cdf0e10cSrcweir void SvtInetOptions::SetProxyType(ProxyType eValue, bool bFlush) 486cdf0e10cSrcweir { 487cdf0e10cSrcweir m_pImpl->setProperty(Impl::INDEX_PROXY_TYPE, 488cdf0e10cSrcweir star::uno::makeAny(sal_Int32(eValue)), 489cdf0e10cSrcweir bFlush); 490cdf0e10cSrcweir } 491cdf0e10cSrcweir 492cdf0e10cSrcweir //============================================================================ 493cdf0e10cSrcweir void SvtInetOptions::SetProxyFtpName(rtl::OUString const & rValue, 494cdf0e10cSrcweir bool bFlush) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir m_pImpl->setProperty(Impl::INDEX_FTP_PROXY_NAME, 497cdf0e10cSrcweir star::uno::makeAny(rValue), 498cdf0e10cSrcweir bFlush); 499cdf0e10cSrcweir } 500cdf0e10cSrcweir 501cdf0e10cSrcweir //============================================================================ 502cdf0e10cSrcweir void SvtInetOptions::SetProxyFtpPort(sal_Int32 nValue, bool bFlush) 503cdf0e10cSrcweir { 504cdf0e10cSrcweir m_pImpl->setProperty(Impl::INDEX_FTP_PROXY_PORT, 505cdf0e10cSrcweir star::uno::makeAny(nValue), 506cdf0e10cSrcweir bFlush); 507cdf0e10cSrcweir } 508cdf0e10cSrcweir 509cdf0e10cSrcweir //============================================================================ 510cdf0e10cSrcweir void SvtInetOptions::SetProxyHttpName(rtl::OUString const & rValue, 511cdf0e10cSrcweir bool bFlush) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir m_pImpl->setProperty(Impl::INDEX_HTTP_PROXY_NAME, 514cdf0e10cSrcweir star::uno::makeAny(rValue), 515cdf0e10cSrcweir bFlush); 516cdf0e10cSrcweir } 517cdf0e10cSrcweir 518cdf0e10cSrcweir //============================================================================ 519cdf0e10cSrcweir void SvtInetOptions::SetProxyHttpPort(sal_Int32 nValue, bool bFlush) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir m_pImpl->setProperty(Impl::INDEX_HTTP_PROXY_PORT, 522cdf0e10cSrcweir star::uno::makeAny(nValue), 523cdf0e10cSrcweir bFlush); 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir //============================================================================ 527cdf0e10cSrcweir void SvtInetOptions::flush() 528cdf0e10cSrcweir { 529cdf0e10cSrcweir m_pImpl->flush(); 530cdf0e10cSrcweir } 531cdf0e10cSrcweir 532cdf0e10cSrcweir //============================================================================ 533cdf0e10cSrcweir void 534cdf0e10cSrcweir SvtInetOptions::addPropertiesChangeListener( 535cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > const & rPropertyNames, 536cdf0e10cSrcweir star::uno::Reference< star::beans::XPropertiesChangeListener > const & 537cdf0e10cSrcweir rListener) 538cdf0e10cSrcweir { 539cdf0e10cSrcweir m_pImpl->addPropertiesChangeListener(rPropertyNames, rListener); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir 542cdf0e10cSrcweir //============================================================================ 543cdf0e10cSrcweir void 544cdf0e10cSrcweir SvtInetOptions::removePropertiesChangeListener( 545cdf0e10cSrcweir star::uno::Sequence< rtl::OUString > const & rPropertyNames, 546cdf0e10cSrcweir star::uno::Reference< star::beans::XPropertiesChangeListener > const & 547cdf0e10cSrcweir rListener) 548cdf0e10cSrcweir { 549cdf0e10cSrcweir m_pImpl->removePropertiesChangeListener(rPropertyNames, rListener); 550cdf0e10cSrcweir } 551