netwerk/base/src/nsAutodialWin.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef nsAutodialWin_h__
     6 #define nsAutodialWin_h__
     8 #include <windows.h>
     9 #include <ras.h>
    10 #include <rasdlg.h>
    11 #include <raserror.h>
    12 #include "nscore.h"
    13 #include "nspr.h"
    15 // For Windows NT 4, 2000, and XP, we sometimes want to open the RAS dialup 
    16 // window ourselves, since those versions aren't very nice about it. 
    17 // See bug 93002. If the RAS autodial service is running, (Remote Access 
    18 // Auto Connection Manager, aka RasAuto) we will force it to dial
    19 // on network error by adding the target address to the autodial
    20 // database. If the service is not running, we will open the RAS dialogs
    21 // instead.
    22 //
    23 // The OS can be configured to always dial, or dial when there is no 
    24 // connection. We implement both by dialing when a network error occurs.
    25 //
    26 // An object of this class checks with the OS when it is constructed and 
    27 // remembers those settings. If required, it can be resynced with
    28 // the OS at anytime with the Init() method. At the time of implementation,
    29 // the caller creates an object of this class each time a network error occurs. 
    30 // In this case, the initialization overhead is not significant, and it will
    31 // guaranteed to be in sync with OS.
    32 //
    33 // To use, create an instance and call ShouldDialOnNetworkError() to determine 
    34 // if you should dial or not. That function only return true for the
    35 // target OS's so the caller doesn't have to deal with OS version checking.
    36 //
    38 class nsAutodial
    39 {
    40 private:
    42     //
    43     // Some helper functions to query the OS for autodial configuration.
    44     //
    46     // Determine if the autodial service is running on this PC.
    47     bool IsAutodialServiceRunning();
    49     // Get the number of RAS connection entries configured from the OS.
    50     int NumRASEntries();
    52     // Get the name of the default connection from the OS.
    53     nsresult GetDefaultEntryName(wchar_t* entryName, int bufferSize);
    55     // Get the name of the first RAS dial entry from the OS.
    56     nsresult GetFirstEntryName(wchar_t* entryName, int bufferSize);
    58     // Check to see if RAS already has a dialup connection going.
    59     bool IsRASConnected();
    61     // Get the autodial behavior from the OS.
    62     int QueryAutodialBehavior();
    64     // Add the specified address to the autodial directory.
    65     bool AddAddressToAutodialDirectory(char16ptr_t hostName);
    67     // Get the  current TAPI dialing location.
    68     int GetCurrentLocation();
    70     // See if autodial is enabled for specified location.
    71     bool IsAutodialServiceEnabled(int location);
    73     //
    74     // Autodial behavior. This comes from the Windows registry, set in the ctor. 
    75     // Object won't pick up changes to the registry automatically, but can be 
    76     // refreshed at anytime by calling Init(). So if the user changed the 
    77     // autodial settings, they wouldn't be noticed unless Init() is called.
    78     int mAutodialBehavior;
    80     int mAutodialServiceDialingLocation;
    82     enum { AUTODIAL_NEVER = 1 };            // Never autodial.
    83     enum { AUTODIAL_ALWAYS = 2 };           // Always autodial as set in Internet Options.
    84     enum { AUTODIAL_ON_NETWORKERROR = 3 };  // Autodial when a connection error occurs as set in Internet Options.
    85     enum { AUTODIAL_USE_SERVICE = 4 };      // Use the RAS autodial service to dial.
    87     // Number of RAS connection entries in the phonebook. 
    88     int mNumRASConnectionEntries;
    90     // Default connection entry name.
    91     wchar_t mDefaultEntryName[RAS_MaxEntryName + 1];
    93     // Don't try to dial again within a few seconds of when user pressed cancel.
    94     static PRIntervalTime mDontRetryUntil;
    96 public:
    98     // ctor
    99     nsAutodial();
   101     // dtor
   102     virtual ~nsAutodial();
   104     // Get the autodial info from the OS and init this obj with it. Call it any
   105     // time to refresh the object's settings from the OS.
   106     nsresult Init();
   108     // Dial the default RAS dialup connection.
   109     nsresult DialDefault(const char16_t* hostName);
   111     // Should we try to dial on network error?
   112     bool ShouldDialOnNetworkError();
   113 };
   115 #endif // !nsAutodialWin_h__

mercurial