netwerk/base/src/nsAutodialWin.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/base/src/nsAutodialWin.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,116 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef nsAutodialWin_h__
     1.9 +#define nsAutodialWin_h__
    1.10 +
    1.11 +#include <windows.h>
    1.12 +#include <ras.h>
    1.13 +#include <rasdlg.h>
    1.14 +#include <raserror.h>
    1.15 +#include "nscore.h"
    1.16 +#include "nspr.h"
    1.17 +
    1.18 +// For Windows NT 4, 2000, and XP, we sometimes want to open the RAS dialup 
    1.19 +// window ourselves, since those versions aren't very nice about it. 
    1.20 +// See bug 93002. If the RAS autodial service is running, (Remote Access 
    1.21 +// Auto Connection Manager, aka RasAuto) we will force it to dial
    1.22 +// on network error by adding the target address to the autodial
    1.23 +// database. If the service is not running, we will open the RAS dialogs
    1.24 +// instead.
    1.25 +//
    1.26 +// The OS can be configured to always dial, or dial when there is no 
    1.27 +// connection. We implement both by dialing when a network error occurs.
    1.28 +//
    1.29 +// An object of this class checks with the OS when it is constructed and 
    1.30 +// remembers those settings. If required, it can be resynced with
    1.31 +// the OS at anytime with the Init() method. At the time of implementation,
    1.32 +// the caller creates an object of this class each time a network error occurs. 
    1.33 +// In this case, the initialization overhead is not significant, and it will
    1.34 +// guaranteed to be in sync with OS.
    1.35 +//
    1.36 +// To use, create an instance and call ShouldDialOnNetworkError() to determine 
    1.37 +// if you should dial or not. That function only return true for the
    1.38 +// target OS's so the caller doesn't have to deal with OS version checking.
    1.39 +//
    1.40 +
    1.41 +class nsAutodial
    1.42 +{
    1.43 +private:
    1.44 +
    1.45 +    //
    1.46 +    // Some helper functions to query the OS for autodial configuration.
    1.47 +    //
    1.48 +
    1.49 +    // Determine if the autodial service is running on this PC.
    1.50 +    bool IsAutodialServiceRunning();
    1.51 +
    1.52 +    // Get the number of RAS connection entries configured from the OS.
    1.53 +    int NumRASEntries();
    1.54 +
    1.55 +    // Get the name of the default connection from the OS.
    1.56 +    nsresult GetDefaultEntryName(wchar_t* entryName, int bufferSize);
    1.57 +
    1.58 +    // Get the name of the first RAS dial entry from the OS.
    1.59 +    nsresult GetFirstEntryName(wchar_t* entryName, int bufferSize);
    1.60 +
    1.61 +    // Check to see if RAS already has a dialup connection going.
    1.62 +    bool IsRASConnected();
    1.63 +
    1.64 +    // Get the autodial behavior from the OS.
    1.65 +    int QueryAutodialBehavior();
    1.66 +
    1.67 +    // Add the specified address to the autodial directory.
    1.68 +    bool AddAddressToAutodialDirectory(char16ptr_t hostName);
    1.69 +
    1.70 +    // Get the  current TAPI dialing location.
    1.71 +    int GetCurrentLocation();
    1.72 +
    1.73 +    // See if autodial is enabled for specified location.
    1.74 +    bool IsAutodialServiceEnabled(int location);
    1.75 +
    1.76 +    //
    1.77 +    // Autodial behavior. This comes from the Windows registry, set in the ctor. 
    1.78 +    // Object won't pick up changes to the registry automatically, but can be 
    1.79 +    // refreshed at anytime by calling Init(). So if the user changed the 
    1.80 +    // autodial settings, they wouldn't be noticed unless Init() is called.
    1.81 +    int mAutodialBehavior;
    1.82 +
    1.83 +    int mAutodialServiceDialingLocation;
    1.84 +
    1.85 +    enum { AUTODIAL_NEVER = 1 };            // Never autodial.
    1.86 +    enum { AUTODIAL_ALWAYS = 2 };           // Always autodial as set in Internet Options.
    1.87 +    enum { AUTODIAL_ON_NETWORKERROR = 3 };  // Autodial when a connection error occurs as set in Internet Options.
    1.88 +    enum { AUTODIAL_USE_SERVICE = 4 };      // Use the RAS autodial service to dial.
    1.89 +
    1.90 +    // Number of RAS connection entries in the phonebook. 
    1.91 +    int mNumRASConnectionEntries;
    1.92 +
    1.93 +    // Default connection entry name.
    1.94 +    wchar_t mDefaultEntryName[RAS_MaxEntryName + 1];
    1.95 +
    1.96 +    // Don't try to dial again within a few seconds of when user pressed cancel.
    1.97 +    static PRIntervalTime mDontRetryUntil;
    1.98 +
    1.99 +public:
   1.100 +  
   1.101 +    // ctor
   1.102 +    nsAutodial();
   1.103 +
   1.104 +    // dtor
   1.105 +    virtual ~nsAutodial();
   1.106 +
   1.107 +    // Get the autodial info from the OS and init this obj with it. Call it any
   1.108 +    // time to refresh the object's settings from the OS.
   1.109 +    nsresult Init();
   1.110 +
   1.111 +    // Dial the default RAS dialup connection.
   1.112 +    nsresult DialDefault(const char16_t* hostName);
   1.113 +
   1.114 +    // Should we try to dial on network error?
   1.115 +    bool ShouldDialOnNetworkError();
   1.116 +};
   1.117 +
   1.118 +#endif // !nsAutodialWin_h__
   1.119 +

mercurial