LCOV - code coverage report
Current view: top level - netwerk/wifi - nsWifiAccessPoint.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 0 45 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 11 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/. */
       4             : 
       5             : #include "nsWifiAccessPoint.h"
       6             : #include "nsString.h"
       7             : #include "nsMemory.h"
       8             : #include "mozilla/Logging.h"
       9             : 
      10             : extern mozilla::LazyLogModule gWifiMonitorLog;
      11             : #define LOG(args)     MOZ_LOG(gWifiMonitorLog, mozilla::LogLevel::Debug, args)
      12             : 
      13           0 : NS_IMPL_ISUPPORTS(nsWifiAccessPoint, nsIWifiAccessPoint)
      14             : 
      15           0 : nsWifiAccessPoint::nsWifiAccessPoint()
      16             : {
      17             :   // make sure these are null terminated (because we are paranoid)
      18           0 :   mMac[0] = '\0';
      19           0 :   mSsid[0] = '\0';
      20           0 :   mSsidLen = 0;
      21           0 :   mSignal = -1000;
      22           0 : }
      23             : 
      24           0 : nsWifiAccessPoint::~nsWifiAccessPoint()
      25             : {
      26           0 : }
      27             : 
      28           0 : NS_IMETHODIMP nsWifiAccessPoint::GetMac(nsACString& aMac)
      29             : {
      30           0 :   aMac.Assign(mMac);
      31           0 :   return NS_OK;
      32             : }
      33             : 
      34           0 : NS_IMETHODIMP nsWifiAccessPoint::GetSsid(nsAString& aSsid)
      35             : {
      36             :   // just assign and embedded nulls will truncate resulting
      37             :   // in a displayable string.
      38           0 :   CopyASCIItoUTF16(mSsid, aSsid);
      39           0 :   return NS_OK;
      40             : }
      41             : 
      42             : 
      43           0 : NS_IMETHODIMP nsWifiAccessPoint::GetRawSSID(nsACString& aRawSsid)
      44             : {
      45           0 :   aRawSsid.Assign(mSsid, mSsidLen); // SSIDs are 32 chars long
      46           0 :   return NS_OK;
      47             : }
      48             : 
      49           0 : NS_IMETHODIMP nsWifiAccessPoint::GetSignal(int32_t *aSignal)
      50             : {
      51           0 :   NS_ENSURE_ARG(aSignal);
      52           0 :   *aSignal = mSignal;
      53           0 :   return NS_OK;
      54             : }
      55             : 
      56             : // Helper functions:
      57             : 
      58           0 : bool AccessPointsEqual(nsCOMArray<nsWifiAccessPoint>& a, nsCOMArray<nsWifiAccessPoint>& b)
      59             : {
      60           0 :   if (a.Count() != b.Count()) {
      61           0 :     LOG(("AccessPoint lists have different lengths\n"));
      62           0 :     return false;
      63             :   }
      64             : 
      65           0 :   for (int32_t i = 0; i < a.Count(); i++) {
      66           0 :     LOG(("++ Looking for %s\n", a[i]->mSsid));
      67           0 :     bool found = false;
      68           0 :     for (int32_t j = 0; j < b.Count(); j++) {
      69           0 :       LOG(("   %s->%s | %s->%s\n", a[i]->mSsid, b[j]->mSsid, a[i]->mMac, b[j]->mMac));
      70           0 :       if (!strcmp(a[i]->mSsid, b[j]->mSsid) &&
      71           0 :           !strcmp(a[i]->mMac, b[j]->mMac) &&
      72           0 :           a[i]->mSignal == b[j]->mSignal) {
      73           0 :         found = true;
      74             :       }
      75             :     }
      76           0 :     if (!found)
      77           0 :       return false;
      78             :   }
      79           0 :   LOG(("   match!\n"));
      80           0 :   return true;
      81             : }
      82             : 
      83           0 : void ReplaceArray(nsCOMArray<nsWifiAccessPoint>& a, nsCOMArray<nsWifiAccessPoint>& b)
      84             : {
      85           0 :   a.Clear();
      86             : 
      87             :   // better way to copy?
      88           0 :   for (int32_t i = 0; i < b.Count(); i++) {
      89           0 :     a.AppendObject(b[i]);
      90             :   }
      91             : 
      92           0 :   b.Clear();
      93           0 : }
      94             : 
      95             : 

Generated by: LCOV version 1.13