netwerk/wifi/win_wlanLibrary.h
author Mark Finkle <mfinkle@mozilla.com>
Wed, 26 Nov 2014 11:37:07 -0500
changeset 233547 a3cc435fd3c315e5dfe9329d03d5943bb893cced
parent 197550 221ded3982a7b6278d850b04b13d28a81940df9d
child 308102 851dc8327772d5f6491b1bed591fc328baea50b7
permissions -rw-r--r--
Bug 1105284 - Update the CDN location for OTA distributions on CLOSED TREE r=rnewman a=lmandel

/* 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/. */

#pragma once

// Moz headers (alphabetical)

// System headers (alphabetical)
#include <windows.h>   // HINSTANCE, HANDLE
#include <wlanapi.h>   // Wlan* functions


class WinWLANLibrary {
 public:
  static WinWLANLibrary* Load();
  ~WinWLANLibrary();

  HANDLE GetWLANHandle() const;
  decltype(::WlanEnumInterfaces)* GetWlanEnumInterfacesPtr() const;
  decltype(::WlanGetNetworkBssList)* GetWlanGetNetworkBssListPtr() const;
  decltype(::WlanFreeMemory)* GetWlanFreeMemoryPtr() const;
  decltype(::WlanCloseHandle)* GetWlanCloseHandlePtr() const;
  decltype(::WlanOpenHandle)* GetWlanOpenHandlePtr() const;
  decltype(::WlanRegisterNotification)* GetWlanRegisterNotificationPtr() const;
  decltype(::WlanScan)* GetWlanScanPtr() const;

 private:
  WinWLANLibrary();
  bool Initialize();

  HMODULE mWlanLibrary;
  HANDLE mWlanHandle;
  decltype(::WlanEnumInterfaces)* mWlanEnumInterfacesPtr;
  decltype(::WlanGetNetworkBssList)* mWlanGetNetworkBssListPtr;
  decltype(::WlanFreeMemory)* mWlanFreeMemoryPtr;
  decltype(::WlanCloseHandle)* mWlanCloseHandlePtr;
  decltype(::WlanOpenHandle)* mWlanOpenHandlePtr;
  decltype(::WlanRegisterNotification)* mWlanRegisterNotificationPtr;
  decltype(::WlanScan)* mWlanScanPtr;
};

class ScopedWLANObject {
public:
 ScopedWLANObject(WinWLANLibrary* library, void* object)
   : mObject(object),
    mLibrary(library)
  {
  }

  ~ScopedWLANObject()
  {
    (*(mLibrary->GetWlanFreeMemoryPtr()))(mObject);
  }

 private:
  WinWLANLibrary *mLibrary;
  void *mObject;
};