michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsAutodialWin_h__ michael@0: #define nsAutodialWin_h__ michael@0: michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include "nscore.h" michael@0: #include "nspr.h" michael@0: michael@0: // For Windows NT 4, 2000, and XP, we sometimes want to open the RAS dialup michael@0: // window ourselves, since those versions aren't very nice about it. michael@0: // See bug 93002. If the RAS autodial service is running, (Remote Access michael@0: // Auto Connection Manager, aka RasAuto) we will force it to dial michael@0: // on network error by adding the target address to the autodial michael@0: // database. If the service is not running, we will open the RAS dialogs michael@0: // instead. michael@0: // michael@0: // The OS can be configured to always dial, or dial when there is no michael@0: // connection. We implement both by dialing when a network error occurs. michael@0: // michael@0: // An object of this class checks with the OS when it is constructed and michael@0: // remembers those settings. If required, it can be resynced with michael@0: // the OS at anytime with the Init() method. At the time of implementation, michael@0: // the caller creates an object of this class each time a network error occurs. michael@0: // In this case, the initialization overhead is not significant, and it will michael@0: // guaranteed to be in sync with OS. michael@0: // michael@0: // To use, create an instance and call ShouldDialOnNetworkError() to determine michael@0: // if you should dial or not. That function only return true for the michael@0: // target OS's so the caller doesn't have to deal with OS version checking. michael@0: // michael@0: michael@0: class nsAutodial michael@0: { michael@0: private: michael@0: michael@0: // michael@0: // Some helper functions to query the OS for autodial configuration. michael@0: // michael@0: michael@0: // Determine if the autodial service is running on this PC. michael@0: bool IsAutodialServiceRunning(); michael@0: michael@0: // Get the number of RAS connection entries configured from the OS. michael@0: int NumRASEntries(); michael@0: michael@0: // Get the name of the default connection from the OS. michael@0: nsresult GetDefaultEntryName(wchar_t* entryName, int bufferSize); michael@0: michael@0: // Get the name of the first RAS dial entry from the OS. michael@0: nsresult GetFirstEntryName(wchar_t* entryName, int bufferSize); michael@0: michael@0: // Check to see if RAS already has a dialup connection going. michael@0: bool IsRASConnected(); michael@0: michael@0: // Get the autodial behavior from the OS. michael@0: int QueryAutodialBehavior(); michael@0: michael@0: // Add the specified address to the autodial directory. michael@0: bool AddAddressToAutodialDirectory(char16ptr_t hostName); michael@0: michael@0: // Get the current TAPI dialing location. michael@0: int GetCurrentLocation(); michael@0: michael@0: // See if autodial is enabled for specified location. michael@0: bool IsAutodialServiceEnabled(int location); michael@0: michael@0: // michael@0: // Autodial behavior. This comes from the Windows registry, set in the ctor. michael@0: // Object won't pick up changes to the registry automatically, but can be michael@0: // refreshed at anytime by calling Init(). So if the user changed the michael@0: // autodial settings, they wouldn't be noticed unless Init() is called. michael@0: int mAutodialBehavior; michael@0: michael@0: int mAutodialServiceDialingLocation; michael@0: michael@0: enum { AUTODIAL_NEVER = 1 }; // Never autodial. michael@0: enum { AUTODIAL_ALWAYS = 2 }; // Always autodial as set in Internet Options. michael@0: enum { AUTODIAL_ON_NETWORKERROR = 3 }; // Autodial when a connection error occurs as set in Internet Options. michael@0: enum { AUTODIAL_USE_SERVICE = 4 }; // Use the RAS autodial service to dial. michael@0: michael@0: // Number of RAS connection entries in the phonebook. michael@0: int mNumRASConnectionEntries; michael@0: michael@0: // Default connection entry name. michael@0: wchar_t mDefaultEntryName[RAS_MaxEntryName + 1]; michael@0: michael@0: // Don't try to dial again within a few seconds of when user pressed cancel. michael@0: static PRIntervalTime mDontRetryUntil; michael@0: michael@0: public: michael@0: michael@0: // ctor michael@0: nsAutodial(); michael@0: michael@0: // dtor michael@0: virtual ~nsAutodial(); michael@0: michael@0: // Get the autodial info from the OS and init this obj with it. Call it any michael@0: // time to refresh the object's settings from the OS. michael@0: nsresult Init(); michael@0: michael@0: // Dial the default RAS dialup connection. michael@0: nsresult DialDefault(const char16_t* hostName); michael@0: michael@0: // Should we try to dial on network error? michael@0: bool ShouldDialOnNetworkError(); michael@0: }; michael@0: michael@0: #endif // !nsAutodialWin_h__ michael@0: