diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-05-14 10:50:01 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-05-14 10:50:01 +0200 |
commit | e9dd029f5d00590e1a53e63b0ab805110a10b54c (patch) | |
tree | 1126ca5dda925a62be3dc12c99c90e953d08afcf /dom/wifi/WifiUtils.h | |
parent | 9d6a7ae25d7f5da855a8f8df884de483b4e2a538 (diff) | |
parent | 36b8fd734f590eb726ca2e50f8d1ff9cc968b8e1 (diff) | |
download | UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.gz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.lz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.tar.xz UXP-e9dd029f5d00590e1a53e63b0ab805110a10b54c.zip |
Merge branch 'master' into Basilisk-release
Diffstat (limited to 'dom/wifi/WifiUtils.h')
-rw-r--r-- | dom/wifi/WifiUtils.h | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/dom/wifi/WifiUtils.h b/dom/wifi/WifiUtils.h deleted file mode 100644 index a83ba9c15..000000000 --- a/dom/wifi/WifiUtils.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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/. */ - -/** - * Abstraction on top of the wifi support from libhardware_legacy that we - * use to talk to the wpa_supplicant. - */ - -#ifndef WifiUtils_h -#define WifiUtils_h - -#include "nsString.h" -#include "mozilla/dom/WifiOptionsBinding.h" -#include "mozilla/UniquePtr.h" -#include "WifiHotspotUtils.h" - -// Needed to add a copy constructor to WifiCommandOptions. -struct CommandOptions -{ -public: - CommandOptions(const mozilla::dom::WifiCommandOptions& aOther) { - -#define COPY_OPT_FIELD(prop, defaultValue) \ - if (aOther.prop.WasPassed()) { \ - prop = aOther.prop.Value(); \ - } else { \ - prop = defaultValue; \ - } - -#define COPY_FIELD(prop) prop = aOther.prop; - COPY_FIELD(mId) - COPY_FIELD(mCmd) - COPY_OPT_FIELD(mRequest, EmptyString()) - -#undef COPY_OPT_FIELD -#undef COPY_FIELD - } - - // All the fields, not Optional<> anymore to get copy constructors. - nsString mCmd; - int32_t mId; - nsString mRequest; -}; - -// Abstract class that exposes libhardware_legacy functions we need for -// wifi management. -// We use the ICS signatures here since they are likely more future-proof. -class WpaSupplicantImpl -{ -public: - // Suppress warning from |UniquePtr| - virtual ~WpaSupplicantImpl() {} - - virtual int32_t - do_wifi_wait_for_event(const char *iface, char *buf, size_t len) = 0; // KK == ICS != JB - - virtual int32_t - do_wifi_command(const char* iface, const char* cmd, char* buff, size_t* len) = 0; // KK == ICS != JB - - virtual int32_t - do_wifi_load_driver() = 0; - - virtual int32_t - do_wifi_unload_driver() = 0; - - virtual int32_t - do_wifi_start_supplicant(int32_t) = 0; // ICS != JB == KK - - virtual int32_t - do_wifi_stop_supplicant(int32_t) = 0; //ICS != JB == KK - - virtual int32_t - do_wifi_connect_to_supplicant(const char* iface) = 0; // KK == ICS != JB - - virtual void - do_wifi_close_supplicant_connection(const char* iface) = 0; // KK == ICS != JB -}; - -// Concrete class to use to access the wpa supplicant. -class WpaSupplicant final -{ -public: - WpaSupplicant(); - - // Use nsCString as the type of aInterface to guarantee it's - // null-terminated so that we can pass it to c API without - // conversion - void WaitForEvent(nsAString& aEvent, const nsCString& aInterface); - bool ExecuteCommand(CommandOptions aOptions, - mozilla::dom::WifiResultOptions& result, - const nsCString& aInterface); - -private: - UniquePtr<WpaSupplicantImpl> mImpl; - UniquePtr<WifiHotspotUtils> mWifiHotspotUtils; - - uint32_t mSdkVersion; - -protected: - void CheckBuffer(char* buffer, int32_t length, nsAString& aEvent); - uint32_t MakeMask(uint32_t len); -}; - -#endif // WifiUtils_h |