Author: jbeich
Date: Sat Jul 13 19:20:24 2013
New Revision: 1281

Log:
add proper geolocation support

PR:             ports/180530

Added:
   trunk/www/firefox-nightly/files/patch-bug893397
   trunk/www/firefox/files/patch-bug893397
   trunk/www/seamonkey/files/patch-bug893397
Modified:
   trunk/Mk/bsd.gecko.mk
   trunk/www/firefox-nightly/files/patch-bug803480
   trunk/www/firefox/files/patch-bug803480
   trunk/www/seamonkey/files/patch-bug803480

Modified: trunk/Mk/bsd.gecko.mk
==============================================================================
--- trunk/Mk/bsd.gecko.mk       Sat Jul 13 19:20:15 2013        (r1280)
+++ trunk/Mk/bsd.gecko.mk       Sat Jul 13 19:20:24 2013        (r1281)
@@ -680,7 +680,7 @@
 LIBS+=         -Wl,--as-needed,-lcxxrt,--no-as-needed
 .endif
 
-.if !exists(${FILESDIR}/patch-bug803480) || ! ${PORT_OPTIONS:MDBUS}
+.if !exists(${FILESDIR}/patch-bug803480)
 MOZ_OPTIONS+=  --disable-necko-wifi
 .endif
 

Modified: trunk/www/firefox-nightly/files/patch-bug803480
==============================================================================
--- trunk/www/firefox-nightly/files/patch-bug803480     Sat Jul 13 19:20:15 
2013        (r1280)
+++ trunk/www/firefox-nightly/files/patch-bug803480     Sat Jul 13 19:20:24 
2013        (r1281)
@@ -1,8 +1,55 @@
 diff --git configure.in configure.in
-index fa283d0..936b6e0 100644
+index a0575dc..be327fd 100644
 --- configure.in
 +++ configure.in
-@@ -8229,16 +8229,26 @@ MOZ_ARG_DISABLE_BOOL(necko-wifi,
+@@ -4306,7 +4306,6 @@ NS_PRINTING=1
+ MOZ_PDF_PRINTING=
+ MOZ_DISABLE_CRYPTOLEGACY=
+ NSS_DISABLE_DBM=
+-NECKO_WIFI=1
+ NECKO_COOKIES=1
+ NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket 
wyciwyg device"
+ USE_ARM_KUSER=
+@@ -4336,11 +4335,6 @@ case "${target}" in
+         fi
+ 
+         NSS_DISABLE_DBM=1
+-        if test -z "$gonkdir"; then
+-          NECKO_WIFI=
+-        else
+-          NECKO_WIFI=1
+-        fi
+         MOZ_THEME_FASTSTRIPE=1
+         MOZ_TREE_FREETYPE=1
+         MOZ_MEMORY=1
+@@ -8485,28 +8479,39 @@ done
+ dnl
+ dnl option to disable necko's wifi scanner
+ dnl
++
++case "$OS_TARGET" in
++  OS2)
++    dnl OS/2 implementation of Necko-WiFi support will be added in bug 506566
++    ;;
++  Android)
++    if test -n "$gonkdir"; then
++      NECKO_WIFI=1
++    fi
++    ;;
++  Darwin|SunOS|WINNT)
++    NECKO_WIFI=1
++    ;;
++  Linux)
++    if test -z "$MOZ_ENABLE_DBUS"; then
++      AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove 
--disable-dbus or use --disable-necko-wifi])
++    fi
++    NECKO_WIFI=1
++    NECKO_WIFI_DBUS=1
++    ;;
++esac
++
+ MOZ_ARG_DISABLE_BOOL(necko-wifi,
+ [  --disable-necko-wifi    Disable necko wifi scanner],
      NECKO_WIFI=,
      NECKO_WIFI=1)
  
@@ -16,26 +63,40 @@
 -        "$OS_ARCH" != "SunOS" -a \
 -        "$OS_ARCH" != "WINNT"; then
 -  AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use 
--disable-necko-wifi])
-+if test "$NECKO_WIFI"; then
-+  case "$OS_TARGET" in
-+    Android)
-+      ;;
-+    Darwin)
-+      ;;
-+    SunOS)
-+      ;;
-+    WINNT)
-+      ;;
-+    OS2)
-+      dnl OS/2 implementation of Necko-WiFi support will be added in bug 
506566
-+      NECKO_WIFI=
-+      ;;
-+    *)
-+      if test -z "$MOZ_ENABLE_DBUS"; then
-+        AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove 
--disable-dbus or use --disable-necko-wifi])
-+      fi
-+      ;;
-+  esac
+-fi
+-
+ if test "$NECKO_WIFI"; then
+   AC_DEFINE(NECKO_WIFI)
+   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
  fi
+ AC_SUBST(NECKO_WIFI)
++AC_SUBST(NECKO_WIFI_DBUS)
  
- if test "$NECKO_WIFI"; then
+ dnl
+ dnl option to disable cookies
+diff --git netwerk/wifi/Makefile.in netwerk/wifi/Makefile.in
+index 26dbd79..4cbf912 100644
+--- netwerk/wifi/Makefile.in
++++ netwerk/wifi/Makefile.in
+@@ -20,7 +20,7 @@ ifeq ($(OS_ARCH),SunOS)
+ OS_INCLUDES += $(GLIB_CFLAGS)
+ endif
+ 
+-ifdef MOZ_ENABLE_DBUS
++ifdef NECKO_WIFI_DBUS
+ OS_INCLUDES += $(MOZ_DBUS_GLIB_CFLAGS)
+ endif
+ 
+diff --git netwerk/wifi/moz.build netwerk/wifi/moz.build
+index 5e70211..07b01de 100644
+--- netwerk/wifi/moz.build
++++ netwerk/wifi/moz.build
+@@ -43,7 +43,7 @@ elif CONFIG['OS_ARCH'] == 'SunOS':
+         'nsWifiScannerSolaris.cpp',
+     ]
+ 
+-if CONFIG['MOZ_ENABLE_DBUS']:
++if CONFIG['NECKO_WIFI_DBUS']:
+     CPP_SOURCES += [
+         'nsWifiScannerDBus.cpp',
+     ]

Added: trunk/www/firefox-nightly/files/patch-bug893397
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/www/firefox-nightly/files/patch-bug893397     Sat Jul 13 19:20:24 
2013        (r1281)
@@ -0,0 +1,221 @@
+diff --git configure.in configure.in
+index 549ad06..2878d9f 100644
+--- configure.in
++++ configure.in
+@@ -8491,7 +8491,7 @@ case "$OS_TARGET" in
+       NECKO_WIFI=1
+     fi
+     ;;
+-  Darwin|SunOS|WINNT)
++  Darwin|FreeBSD|SunOS|WINNT)
+     NECKO_WIFI=1
+     ;;
+   Linux)
+diff --git netwerk/wifi/moz.build netwerk/wifi/moz.build
+index 07b01de..11706af 100644
+--- netwerk/wifi/moz.build
++++ netwerk/wifi/moz.build
+@@ -34,6 +34,10 @@ if CONFIG['OS_ARCH'] == 'Darwin':
+     CMMSRCS += [
+         'osx_corewlan.mm',
+     ]
++elif CONFIG['OS_ARCH'] == 'FreeBSD':
++    CPP_SOURCES += [
++        'nsWifiScannerFreeBSD.cpp',
++    ]
+ elif CONFIG['OS_ARCH'] == 'WINNT':
+     CPP_SOURCES += [
+         'nsWifiScannerWin.cpp',
+diff --git netwerk/wifi/nsWifiScannerFreeBSD.cpp 
netwerk/wifi/nsWifiScannerFreeBSD.cpp
+new file mode 100644
+index 0000000..80d4cb6
+--- /dev/null
++++ netwerk/wifi/nsWifiScannerFreeBSD.cpp
+@@ -0,0 +1,187 @@
++/* 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/. */
++
++// Developed by J.R. Oldroyd <[email protected]> and offered to the FreeBSD
++// www/chromium and www/firefox ports under the terms of each browser's
++// license.
++
++// For FreeBSD we use the getifaddrs(3) to obtain the list of interfaces
++// and then check for those with an 802.11 media type and able to return
++// a list of stations.  This is similar to ifconfig(8).
++
++#include "nsCOMPtr.h"
++#include "nsComponentManagerUtils.h"
++#include "nsServiceManagerUtils.h"
++#include "nsThreadUtils.h"
++#include "nsXPCOM.h"
++#include "nsXPCOMCID.h"
++#include "nsIObserver.h"
++#include "nsIObserverService.h"
++#include "nsWifiMonitor.h"
++#include "nsWifiAccessPoint.h"
++
++#include "nsServiceManagerUtils.h"
++#include "nsComponentManagerUtils.h"
++#include "mozilla/Services.h"
++
++using namespace mozilla;
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <sys/sockio.h>
++#include <net/if.h>
++#include <net/if_media.h>
++#include <ifaddrs.h>
++#include <net80211/ieee80211_ioctl.h>
++#include <net/ethernet.h>
++
++// Convert a wifi frequency to the corresponding channel.
++// Taken from wifi_data_provider_linux.cc where it says this was
++// adapted from geolocaiton/wifilib.cc in googleclient (internal to google).
++int frequency_to_channel(int frequency_Mhz) {
++      if (frequency_Mhz >= 2412 && frequency_Mhz <= 2472)  // Channels 1-13.
++              return (frequency_Mhz - 2407) / 5;
++      if (frequency_Mhz == 2484)
++              return 14;
++      if (frequency_Mhz > 5000 && frequency_Mhz < 6000)  // .11a bands.
++              return (frequency_Mhz - 5000) / 5;
++      // Ignore everything else.
++      return -1;  // invalid channel
++}
++
++nsresult
++FreeBSDGetAccessPointData(nsCOMArray<nsWifiAccessPoint> &accessPoints) {
++      bool                    res;
++      char                    *dupn;
++      struct ifaddrs          *ifal, *ifa;
++      struct ifreq            ifr;
++      struct ifmediareq       ifmr;
++      struct ieee80211req     i802r;
++      int                     s;
++      char                    iscanbuf[32*1024], *vsr;
++      unsigned                len;
++      nsWifiAccessPoint       *ap;
++
++      if (getifaddrs(&ifal) < 0)
++              return NS_ERROR_FAILURE;
++
++      accessPoints.Clear();
++
++      res = false;
++      dupn = NULL;
++      for (ifa = ifal; ifa; ifa = ifa->ifa_next) {
++              memset(&ifr, 0, sizeof(ifr));
++
++              if (dupn != NULL && strcmp(dupn, ifa->ifa_name) == 0)
++                      continue;
++              dupn = ifa->ifa_name;
++
++              strncpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name));
++              ifr.ifr_addr.sa_family = AF_LOCAL;
++                 
++              if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0)
++                      continue;
++
++              (void) memset(&ifmr, 0, sizeof(ifmr));
++              (void) strncpy(ifmr.ifm_name, ifa->ifa_name, 
sizeof(ifmr.ifm_name));
++
++              if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
++                      close(s);
++                      continue;
++              }
++              if (IFM_TYPE(ifmr.ifm_active) != IFM_IEEE80211) {
++                      close(s);
++                      continue;
++              }
++
++              (void) memset(&i802r, 0, sizeof(i802r));
++              (void) strncpy(i802r.i_name, ifa->ifa_name, 
sizeof(i802r.i_name));
++              i802r.i_type = IEEE80211_IOC_SCAN_RESULTS;
++              i802r.i_data = iscanbuf;
++              i802r.i_len = sizeof(iscanbuf);
++              if (ioctl(s, SIOCG80211, &i802r) < 0) {
++                      close(s);
++                      continue;
++              }
++
++              close(s);
++
++              vsr = (char *) i802r.i_data;
++              len = i802r.i_len;
++              while (len >= sizeof(struct ieee80211req_scan_result)) {
++                      struct ieee80211req_scan_result *isr;
++                      char            *id;
++                      int             idlen;
++                      char            ssid[IEEE80211_NWID_LEN+1];
++
++                      isr = (struct ieee80211req_scan_result *) vsr;
++
++                      if (isr->isr_meshid_len) {
++                              id = vsr + isr->isr_ie_off + isr->isr_ssid_len;
++                              idlen = isr->isr_meshid_len;
++                      }
++                      else {
++                              id = vsr + isr->isr_ie_off;
++                              idlen = isr->isr_ssid_len;
++                      }
++                      strncpy(ssid, id, idlen);
++                      ssid[idlen] = '\0';
++                      ap = new nsWifiAccessPoint();
++                      ap->setSSID(ssid, strlen(ssid));
++                      ap->setMac(isr->isr_bssid);
++                      ap->setSignal(isr->isr_rssi);
++                      // apd.radio_signal_strength = (isr->isr_rssi/2) + 
isr->isr_noise;
++                      // apd.signal_to_noise = apd.radio_signal_strength - 
isr->isr_noise;
++                      // apd.channel = frequency_to_channel(isr->isr_freq);
++                      LOG((      "FreeBSD access point: "
++                              << "SSID: " << apd.ssid << ", "
++                              << "MAC: " << apd.mac_address << ", "
++                              << "Strength: " << apd.radio_signal_strength << 
":"
++                                              << apd.signal_to_noise << ", "
++                              << "Channel: " << apd.channel ));
++                      accessPoints.AppendObject(ap);
++                      res = true;
++                      len -= isr->isr_len;
++                      vsr += isr->isr_len;
++              }
++        }
++
++      freeifaddrs(ifal);
++
++      return res ? NS_OK : NS_ERROR_FAILURE;
++}
++
++nsresult
++nsWifiMonitor::DoScan()
++{
++      // Regularly get the access point data.
++
++      nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
++      nsCOMArray<nsWifiAccessPoint> accessPoints;
++
++      do {
++              nsresult rv = FreeBSDGetAccessPointData(accessPoints);
++              if (NS_FAILED(rv))
++                      return rv;
++
++              bool accessPointsChanged = !AccessPointsEqual(accessPoints, 
lastAccessPoints);
++              ReplaceArray(lastAccessPoints, accessPoints);
++
++              rv = CallWifiListeners(lastAccessPoints, accessPointsChanged);
++              NS_ENSURE_SUCCESS(rv, rv);
++
++              // wait for some reasonable amount of time.  pref?
++              LOG(("waiting on monitor\n"));
++
++              ReentrantMonitorAutoEnter mon(mReentrantMonitor);
++              mon.Wait(PR_SecondsToInterval(60));
++      }
++      while (mKeepGoing);
++
++      return NS_OK;
++}

Modified: trunk/www/firefox/files/patch-bug803480
==============================================================================
--- trunk/www/firefox/files/patch-bug803480     Sat Jul 13 19:20:15 2013        
(r1280)
+++ trunk/www/firefox/files/patch-bug803480     Sat Jul 13 19:20:24 2013        
(r1281)
@@ -1,8 +1,55 @@
 diff --git configure.in configure.in
-index fa283d0..936b6e0 100644
+index a0575dc..be327fd 100644
 --- configure.in
 +++ configure.in
-@@ -8229,16 +8229,26 @@ MOZ_ARG_DISABLE_BOOL(necko-wifi,
+@@ -4306,7 +4306,6 @@ NS_PRINTING=1
+ MOZ_PDF_PRINTING=
+ MOZ_DISABLE_CRYPTOLEGACY=
+ NSS_DISABLE_DBM=
+-NECKO_WIFI=1
+ NECKO_COOKIES=1
+ NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket 
wyciwyg device"
+ USE_ARM_KUSER=
+@@ -4336,11 +4335,6 @@ case "${target}" in
+         fi
+ 
+         NSS_DISABLE_DBM=1
+-        if test -z "$gonkdir"; then
+-          NECKO_WIFI=
+-        else
+-          NECKO_WIFI=1
+-        fi
+         MOZ_THEME_FASTSTRIPE=1
+         MOZ_TREE_FREETYPE=1
+         MOZ_MEMORY=1
+@@ -8485,28 +8479,39 @@ done
+ dnl
+ dnl option to disable necko's wifi scanner
+ dnl
++
++case "$OS_TARGET" in
++  OS2)
++    dnl OS/2 implementation of Necko-WiFi support will be added in bug 506566
++    ;;
++  Android)
++    if test -n "$gonkdir"; then
++      NECKO_WIFI=1
++    fi
++    ;;
++  Darwin|SunOS|WINNT)
++    NECKO_WIFI=1
++    ;;
++  Linux)
++    if test -z "$MOZ_ENABLE_DBUS"; then
++      AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove 
--disable-dbus or use --disable-necko-wifi])
++    fi
++    NECKO_WIFI=1
++    NECKO_WIFI_DBUS=1
++    ;;
++esac
++
+ MOZ_ARG_DISABLE_BOOL(necko-wifi,
+ [  --disable-necko-wifi    Disable necko wifi scanner],
      NECKO_WIFI=,
      NECKO_WIFI=1)
  
@@ -16,26 +63,27 @@
 -        "$OS_ARCH" != "SunOS" -a \
 -        "$OS_ARCH" != "WINNT"; then
 -  AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use 
--disable-necko-wifi])
-+if test "$NECKO_WIFI"; then
-+  case "$OS_TARGET" in
-+    Android)
-+      ;;
-+    Darwin)
-+      ;;
-+    SunOS)
-+      ;;
-+    WINNT)
-+      ;;
-+    OS2)
-+      dnl OS/2 implementation of Necko-WiFi support will be added in bug 
506566
-+      NECKO_WIFI=
-+      ;;
-+    *)
-+      if test -z "$MOZ_ENABLE_DBUS"; then
-+        AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove 
--disable-dbus or use --disable-necko-wifi])
-+      fi
-+      ;;
-+  esac
+-fi
+-
+ if test "$NECKO_WIFI"; then
+   AC_DEFINE(NECKO_WIFI)
+   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
  fi
+ AC_SUBST(NECKO_WIFI)
++AC_SUBST(NECKO_WIFI_DBUS)
  
- if test "$NECKO_WIFI"; then
+ dnl
+ dnl option to disable cookies
+diff --git netwerk/wifi/Makefile.in netwerk/wifi/Makefile.in
+index 39d7364..e8d276b 100644
+--- netwerk/wifi/Makefile.in
++++ netwerk/wifi/Makefile.in
+@@ -41,7 +41,7 @@ CPPSRCS += nsWifiScannerSolaris.cpp
+ OS_INCLUDES += $(GLIB_CFLAGS)
+ endif
+ 
+-ifdef MOZ_ENABLE_DBUS
++ifdef NECKO_WIFI_DBUS
+ CPPSRCS += nsWifiScannerDBus.cpp
+ OS_INCLUDES += $(MOZ_DBUS_GLIB_CFLAGS)
+ endif

Added: trunk/www/firefox/files/patch-bug893397
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/www/firefox/files/patch-bug893397     Sat Jul 13 19:20:24 2013        
(r1281)
@@ -0,0 +1,221 @@
+diff --git configure.in configure.in
+index 549ad06..2878d9f 100644
+--- configure.in
++++ configure.in
+@@ -8491,7 +8491,7 @@ case "$OS_TARGET" in
+       NECKO_WIFI=1
+     fi
+     ;;
+-  Darwin|SunOS|WINNT)
++  Darwin|FreeBSD|SunOS|WINNT)
+     NECKO_WIFI=1
+     ;;
+   Linux)
+diff --git netwerk/wifi/Makefile.in netwerk/wifi/Makefile.in
+index 07b01de..11706af 100644
+--- netwerk/wifi/Makefile.in
++++ netwerk/wifi/Makefile.in
+@@ -32,6 +32,10 @@ CPPSRCS += nsWifiScannerMac.cpp
+ CMMSRCS = osx_corewlan.mm
+ endif
+ 
++ifeq ($(OS_ARCH),FreeBSD)
++CPPSRCS += nsWifiScannerFreeBSD.cpp
++endif
++
+ ifneq (,$(filter WINNT,$(OS_ARCH)))
+ CPPSRCS += nsWifiScannerWin.cpp
+ endif
+diff --git netwerk/wifi/nsWifiScannerFreeBSD.cpp 
netwerk/wifi/nsWifiScannerFreeBSD.cpp
+new file mode 100644
+index 0000000..80d4cb6
+--- /dev/null
++++ netwerk/wifi/nsWifiScannerFreeBSD.cpp
+@@ -0,0 +1,187 @@
++/* 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/. */
++
++// Developed by J.R. Oldroyd <[email protected]> and offered to the FreeBSD
++// www/chromium and www/firefox ports under the terms of each browser's
++// license.
++
++// For FreeBSD we use the getifaddrs(3) to obtain the list of interfaces
++// and then check for those with an 802.11 media type and able to return
++// a list of stations.  This is similar to ifconfig(8).
++
++#include "nsCOMPtr.h"
++#include "nsComponentManagerUtils.h"
++#include "nsServiceManagerUtils.h"
++#include "nsThreadUtils.h"
++#include "nsXPCOM.h"
++#include "nsXPCOMCID.h"
++#include "nsIObserver.h"
++#include "nsIObserverService.h"
++#include "nsWifiMonitor.h"
++#include "nsWifiAccessPoint.h"
++
++#include "nsServiceManagerUtils.h"
++#include "nsComponentManagerUtils.h"
++#include "mozilla/Services.h"
++
++using namespace mozilla;
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <sys/sockio.h>
++#include <net/if.h>
++#include <net/if_media.h>
++#include <ifaddrs.h>
++#include <net80211/ieee80211_ioctl.h>
++#include <net/ethernet.h>
++
++// Convert a wifi frequency to the corresponding channel.
++// Taken from wifi_data_provider_linux.cc where it says this was
++// adapted from geolocaiton/wifilib.cc in googleclient (internal to google).
++int frequency_to_channel(int frequency_Mhz) {
++      if (frequency_Mhz >= 2412 && frequency_Mhz <= 2472)  // Channels 1-13.
++              return (frequency_Mhz - 2407) / 5;
++      if (frequency_Mhz == 2484)
++              return 14;
++      if (frequency_Mhz > 5000 && frequency_Mhz < 6000)  // .11a bands.
++              return (frequency_Mhz - 5000) / 5;
++      // Ignore everything else.
++      return -1;  // invalid channel
++}
++
++nsresult
++FreeBSDGetAccessPointData(nsCOMArray<nsWifiAccessPoint> &accessPoints) {
++      bool                    res;
++      char                    *dupn;
++      struct ifaddrs          *ifal, *ifa;
++      struct ifreq            ifr;
++      struct ifmediareq       ifmr;
++      struct ieee80211req     i802r;
++      int                     s;
++      char                    iscanbuf[32*1024], *vsr;
++      unsigned                len;
++      nsWifiAccessPoint       *ap;
++
++      if (getifaddrs(&ifal) < 0)
++              return NS_ERROR_FAILURE;
++
++      accessPoints.Clear();
++
++      res = false;
++      dupn = NULL;
++      for (ifa = ifal; ifa; ifa = ifa->ifa_next) {
++              memset(&ifr, 0, sizeof(ifr));
++
++              if (dupn != NULL && strcmp(dupn, ifa->ifa_name) == 0)
++                      continue;
++              dupn = ifa->ifa_name;
++
++              strncpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name));
++              ifr.ifr_addr.sa_family = AF_LOCAL;
++                 
++              if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0)
++                      continue;
++
++              (void) memset(&ifmr, 0, sizeof(ifmr));
++              (void) strncpy(ifmr.ifm_name, ifa->ifa_name, 
sizeof(ifmr.ifm_name));
++
++              if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
++                      close(s);
++                      continue;
++              }
++              if (IFM_TYPE(ifmr.ifm_active) != IFM_IEEE80211) {
++                      close(s);
++                      continue;
++              }
++
++              (void) memset(&i802r, 0, sizeof(i802r));
++              (void) strncpy(i802r.i_name, ifa->ifa_name, 
sizeof(i802r.i_name));
++              i802r.i_type = IEEE80211_IOC_SCAN_RESULTS;
++              i802r.i_data = iscanbuf;
++              i802r.i_len = sizeof(iscanbuf);
++              if (ioctl(s, SIOCG80211, &i802r) < 0) {
++                      close(s);
++                      continue;
++              }
++
++              close(s);
++
++              vsr = (char *) i802r.i_data;
++              len = i802r.i_len;
++              while (len >= sizeof(struct ieee80211req_scan_result)) {
++                      struct ieee80211req_scan_result *isr;
++                      char            *id;
++                      int             idlen;
++                      char            ssid[IEEE80211_NWID_LEN+1];
++
++                      isr = (struct ieee80211req_scan_result *) vsr;
++
++                      if (isr->isr_meshid_len) {
++                              id = vsr + isr->isr_ie_off + isr->isr_ssid_len;
++                              idlen = isr->isr_meshid_len;
++                      }
++                      else {
++                              id = vsr + isr->isr_ie_off;
++                              idlen = isr->isr_ssid_len;
++                      }
++                      strncpy(ssid, id, idlen);
++                      ssid[idlen] = '\0';
++                      ap = new nsWifiAccessPoint();
++                      ap->setSSID(ssid, strlen(ssid));
++                      ap->setMac(isr->isr_bssid);
++                      ap->setSignal(isr->isr_rssi);
++                      // apd.radio_signal_strength = (isr->isr_rssi/2) + 
isr->isr_noise;
++                      // apd.signal_to_noise = apd.radio_signal_strength - 
isr->isr_noise;
++                      // apd.channel = frequency_to_channel(isr->isr_freq);
++                      LOG((      "FreeBSD access point: "
++                              << "SSID: " << apd.ssid << ", "
++                              << "MAC: " << apd.mac_address << ", "
++                              << "Strength: " << apd.radio_signal_strength << 
":"
++                                              << apd.signal_to_noise << ", "
++                              << "Channel: " << apd.channel ));
++                      accessPoints.AppendObject(ap);
++                      res = true;
++                      len -= isr->isr_len;
++                      vsr += isr->isr_len;
++              }
++        }
++
++      freeifaddrs(ifal);
++
++      return res ? NS_OK : NS_ERROR_FAILURE;
++}
++
++nsresult
++nsWifiMonitor::DoScan()
++{
++      // Regularly get the access point data.
++
++      nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
++      nsCOMArray<nsWifiAccessPoint> accessPoints;
++
++      do {
++              nsresult rv = FreeBSDGetAccessPointData(accessPoints);
++              if (NS_FAILED(rv))
++                      return rv;
++
++              bool accessPointsChanged = !AccessPointsEqual(accessPoints, 
lastAccessPoints);
++              ReplaceArray(lastAccessPoints, accessPoints);
++
++              rv = CallWifiListeners(lastAccessPoints, accessPointsChanged);
++              NS_ENSURE_SUCCESS(rv, rv);
++
++              // wait for some reasonable amount of time.  pref?
++              LOG(("waiting on monitor\n"));
++
++              ReentrantMonitorAutoEnter mon(mReentrantMonitor);
++              mon.Wait(PR_SecondsToInterval(60));
++      }
++      while (mKeepGoing);
++
++      return NS_OK;
++}

Modified: trunk/www/seamonkey/files/patch-bug803480
==============================================================================
--- trunk/www/seamonkey/files/patch-bug803480   Sat Jul 13 19:20:15 2013        
(r1280)
+++ trunk/www/seamonkey/files/patch-bug803480   Sat Jul 13 19:20:24 2013        
(r1281)
@@ -1,8 +1,43 @@
 diff --git configure.in configure.in
-index fa283d0..936b6e0 100644
+index a0575dc..be327fd 100644
 --- configure.in
 +++ configure.in
-@@ -8229,16 +8229,26 @@ MOZ_ARG_DISABLE_BOOL(necko-wifi,
+@@ -3810,7 +3810,6 @@ MOZ_XUL=1
+ MOZ_ZIPWRITER=1
+ NS_PRINTING=1
+ NSS_DISABLE_DBM=
+-NECKO_WIFI=1
+ BUILD_CTYPES=1
+ 
+ 
+@@ -5944,27 +5943,38 @@ AC_SUBST(MOZ_RDF)
+ dnl
+ dnl option to disable necko's wifi scanner
+ dnl
++
++case "$OS_TARGET" in
++  OS2)
++    dnl OS/2 implementation of Necko-WiFi support will be added in bug 506566
++    ;;
++  Android)
++    if test -n "$gonkdir"; then
++      NECKO_WIFI=1
++    fi
++    ;;
++  Darwin|SunOS|WINNT)
++    NECKO_WIFI=1
++    ;;
++  Linux)
++    if test -z "$MOZ_ENABLE_DBUS"; then
++      AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove 
--disable-dbus or use --disable-necko-wifi])
++    fi
++    NECKO_WIFI=1
++    NECKO_WIFI_DBUS=1
++    ;;
++esac
++
+ MOZ_ARG_DISABLE_BOOL(necko-wifi,
+ [  --disable-necko-wifi    Disable necko wifi scanner],
      NECKO_WIFI=,
      NECKO_WIFI=1)
  
@@ -16,34 +51,68 @@
 -        "$OS_ARCH" != "SunOS" -a \
 -        "$OS_ARCH" != "WINNT"; then
 -  AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use 
--disable-necko-wifi])
-+if test "$NECKO_WIFI"; then
-+  case "$OS_TARGET" in
-+    Android)
-+      ;;
-+    Darwin)
-+      ;;
-+    SunOS)
-+      ;;
-+    WINNT)
-+      ;;
-+    OS2)
-+      dnl OS/2 implementation of Necko-WiFi support will be added in bug 
506566
-+      NECKO_WIFI=
-+      ;;
-+    *)
-+      if test -z "$MOZ_ENABLE_DBUS"; then
-+        AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove 
--disable-dbus or use --disable-necko-wifi])
-+      fi
-+      ;;
-+  esac
+-fi
+-
+ if test "$NECKO_WIFI"; then
+   AC_DEFINE(NECKO_WIFI)
  fi
+ AC_SUBST(NECKO_WIFI)
++AC_SUBST(NECKO_WIFI_DBUS)
  
- if test "$NECKO_WIFI"; then
+ dnl
+ dnl Build jsctypes on the platforms we can, unless it's explicitly disabled.
 diff --git configure.in configure.in
-index fa283d0..936b6e0 100644
+index a0575dc..be327fd 100644
 --- mozilla/configure.in
 +++ mozilla/configure.in
-@@ -8229,16 +8229,26 @@ MOZ_ARG_DISABLE_BOOL(necko-wifi,
+@@ -4306,7 +4306,6 @@ NS_PRINTING=1
+ MOZ_PDF_PRINTING=
+ MOZ_DISABLE_CRYPTOLEGACY=
+ NSS_DISABLE_DBM=
+-NECKO_WIFI=1
+ NECKO_COOKIES=1
+ NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket 
wyciwyg device"
+ USE_ARM_KUSER=
+@@ -4336,11 +4335,6 @@ case "${target}" in
+         fi
+ 
+         NSS_DISABLE_DBM=1
+-        if test -z "$gonkdir"; then
+-          NECKO_WIFI=
+-        else
+-          NECKO_WIFI=1
+-        fi
+         MOZ_THEME_FASTSTRIPE=1
+         MOZ_TREE_FREETYPE=1
+         MOZ_MEMORY=1
+@@ -8485,28 +8479,39 @@ done
+ dnl
+ dnl option to disable necko's wifi scanner
+ dnl
++
++case "$OS_TARGET" in
++  OS2)
++    dnl OS/2 implementation of Necko-WiFi support will be added in bug 506566
++    ;;
++  Android)
++    if test -n "$gonkdir"; then
++      NECKO_WIFI=1
++    fi
++    ;;
++  Darwin|SunOS|WINNT)
++    NECKO_WIFI=1
++    ;;
++  Linux)
++    if test -z "$MOZ_ENABLE_DBUS"; then
++      AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove 
--disable-dbus or use --disable-necko-wifi])
++    fi
++    NECKO_WIFI=1
++    NECKO_WIFI_DBUS=1
++    ;;
++esac
++
+ MOZ_ARG_DISABLE_BOOL(necko-wifi,
+ [  --disable-necko-wifi    Disable necko wifi scanner],
      NECKO_WIFI=,
      NECKO_WIFI=1)
  
@@ -57,26 +126,27 @@
 -        "$OS_ARCH" != "SunOS" -a \
 -        "$OS_ARCH" != "WINNT"; then
 -  AC_MSG_ERROR([Necko WiFi scanning not supported on your platform, use 
--disable-necko-wifi])
-+if test "$NECKO_WIFI"; then
-+  case "$OS_TARGET" in
-+    Android)
-+      ;;
-+    Darwin)
-+      ;;
-+    SunOS)
-+      ;;
-+    WINNT)
-+      ;;
-+    OS2)
-+      dnl OS/2 implementation of Necko-WiFi support will be added in bug 
506566
-+      NECKO_WIFI=
-+      ;;
-+    *)
-+      if test -z "$MOZ_ENABLE_DBUS"; then
-+        AC_MSG_ERROR([Necko WiFi scanning needs DBus on your platform, remove 
--disable-dbus or use --disable-necko-wifi])
-+      fi
-+      ;;
-+  esac
+-fi
+-
+ if test "$NECKO_WIFI"; then
+   AC_DEFINE(NECKO_WIFI)
+   _NON_GLOBAL_ACDEFINES="$_NON_GLOBAL_ACDEFINES NECKO_WIFI"
  fi
+ AC_SUBST(NECKO_WIFI)
++AC_SUBST(NECKO_WIFI_DBUS)
  
- if test "$NECKO_WIFI"; then
+ dnl
+ dnl option to disable cookies
+diff --git netwerk/wifi/Makefile.in netwerk/wifi/Makefile.in
+index 39d7364..e8d276b 100644
+--- mozilla/netwerk/wifi/Makefile.in
++++ mozilla/netwerk/wifi/Makefile.in
+@@ -41,7 +41,7 @@ CPPSRCS += nsWifiScannerSolaris.cpp
+ OS_INCLUDES += $(GLIB_CFLAGS)
+ endif
+ 
+-ifdef MOZ_ENABLE_DBUS
++ifdef NECKO_WIFI_DBUS
+ CPPSRCS += nsWifiScannerDBus.cpp
+ OS_INCLUDES += $(MOZ_DBUS_GLIB_CFLAGS)
+ endif

Added: trunk/www/seamonkey/files/patch-bug893397
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ trunk/www/seamonkey/files/patch-bug893397   Sat Jul 13 19:20:24 2013        
(r1281)
@@ -0,0 +1,234 @@
+diff --git configure.in configure.in
+index 549ad06..2878d9f 100644
+--- configure.in
++++ configure.in
+@@ -8491,7 +8491,7 @@ case "$OS_TARGET" in
+       NECKO_WIFI=1
+     fi
+     ;;
+-  Darwin|SunOS|WINNT)
++  Darwin|FreeBSD|SunOS|WINNT)
+     NECKO_WIFI=1
+     ;;
+   Linux)
+diff --git configure.in configure.in
+index 549ad06..2878d9f 100644
+--- mozilla/configure.in
++++ mozilla/configure.in
+@@ -8491,7 +8491,7 @@ case "$OS_TARGET" in
+       NECKO_WIFI=1
+     fi
+     ;;
+-  Darwin|SunOS|WINNT)
++  Darwin|FreeBSD|SunOS|WINNT)
+     NECKO_WIFI=1
+     ;;
+   Linux)
+diff --git netwerk/wifi/Makefile.in netwerk/wifi/Makefile.in
+index 07b01de..11706af 100644
+--- mozilla/netwerk/wifi/Makefile.in
++++ mozilla/netwerk/wifi/Makefile.in
+@@ -32,6 +32,10 @@ CPPSRCS += nsWifiScannerMac.cpp
+ CMMSRCS = osx_corewlan.mm
+ endif
+ 
++ifeq ($(OS_ARCH),FreeBSD)
++CPPSRCS += nsWifiScannerFreeBSD.cpp
++endif
++
+ ifneq (,$(filter WINNT,$(OS_ARCH)))
+ CPPSRCS += nsWifiScannerWin.cpp
+ endif
+diff --git netwerk/wifi/nsWifiScannerFreeBSD.cpp 
netwerk/wifi/nsWifiScannerFreeBSD.cpp
+new file mode 100644
+index 0000000..80d4cb6
+--- /dev/null
++++ mozilla/netwerk/wifi/nsWifiScannerFreeBSD.cpp
+@@ -0,0 +1,187 @@
++/* 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/. */
++
++// Developed by J.R. Oldroyd <[email protected]> and offered to the FreeBSD
++// www/chromium and www/firefox ports under the terms of each browser's
++// license.
++
++// For FreeBSD we use the getifaddrs(3) to obtain the list of interfaces
++// and then check for those with an 802.11 media type and able to return
++// a list of stations.  This is similar to ifconfig(8).
++
++#include "nsCOMPtr.h"
++#include "nsComponentManagerUtils.h"
++#include "nsServiceManagerUtils.h"
++#include "nsThreadUtils.h"
++#include "nsXPCOM.h"
++#include "nsXPCOMCID.h"
++#include "nsIObserver.h"
++#include "nsIObserverService.h"
++#include "nsWifiMonitor.h"
++#include "nsWifiAccessPoint.h"
++
++#include "nsServiceManagerUtils.h"
++#include "nsComponentManagerUtils.h"
++#include "mozilla/Services.h"
++
++using namespace mozilla;
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <sys/sockio.h>
++#include <net/if.h>
++#include <net/if_media.h>
++#include <ifaddrs.h>
++#include <net80211/ieee80211_ioctl.h>
++#include <net/ethernet.h>
++
++// Convert a wifi frequency to the corresponding channel.
++// Taken from wifi_data_provider_linux.cc where it says this was
++// adapted from geolocaiton/wifilib.cc in googleclient (internal to google).
++int frequency_to_channel(int frequency_Mhz) {
++      if (frequency_Mhz >= 2412 && frequency_Mhz <= 2472)  // Channels 1-13.
++              return (frequency_Mhz - 2407) / 5;
++      if (frequency_Mhz == 2484)
++              return 14;
++      if (frequency_Mhz > 5000 && frequency_Mhz < 6000)  // .11a bands.
++              return (frequency_Mhz - 5000) / 5;
++      // Ignore everything else.
++      return -1;  // invalid channel
++}
++
++nsresult
++FreeBSDGetAccessPointData(nsCOMArray<nsWifiAccessPoint> &accessPoints) {
++      bool                    res;
++      char                    *dupn;
++      struct ifaddrs          *ifal, *ifa;
++      struct ifreq            ifr;
++      struct ifmediareq       ifmr;
++      struct ieee80211req     i802r;
++      int                     s;
++      char                    iscanbuf[32*1024], *vsr;
++      unsigned                len;
++      nsWifiAccessPoint       *ap;
++
++      if (getifaddrs(&ifal) < 0)
++              return NS_ERROR_FAILURE;
++
++      accessPoints.Clear();
++
++      res = false;
++      dupn = NULL;
++      for (ifa = ifal; ifa; ifa = ifa->ifa_next) {
++              memset(&ifr, 0, sizeof(ifr));
++
++              if (dupn != NULL && strcmp(dupn, ifa->ifa_name) == 0)
++                      continue;
++              dupn = ifa->ifa_name;
++
++              strncpy(ifr.ifr_name, ifa->ifa_name, sizeof(ifr.ifr_name));
++              ifr.ifr_addr.sa_family = AF_LOCAL;
++                 
++              if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0)
++                      continue;
++
++              (void) memset(&ifmr, 0, sizeof(ifmr));
++              (void) strncpy(ifmr.ifm_name, ifa->ifa_name, 
sizeof(ifmr.ifm_name));
++
++              if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
++                      close(s);
++                      continue;
++              }
++              if (IFM_TYPE(ifmr.ifm_active) != IFM_IEEE80211) {
++                      close(s);
++                      continue;
++              }
++
++              (void) memset(&i802r, 0, sizeof(i802r));
++              (void) strncpy(i802r.i_name, ifa->ifa_name, 
sizeof(i802r.i_name));
++              i802r.i_type = IEEE80211_IOC_SCAN_RESULTS;
++              i802r.i_data = iscanbuf;
++              i802r.i_len = sizeof(iscanbuf);
++              if (ioctl(s, SIOCG80211, &i802r) < 0) {
++                      close(s);
++                      continue;
++              }
++
++              close(s);
++
++              vsr = (char *) i802r.i_data;
++              len = i802r.i_len;
++              while (len >= sizeof(struct ieee80211req_scan_result)) {
++                      struct ieee80211req_scan_result *isr;
++                      char            *id;
++                      int             idlen;
++                      char            ssid[IEEE80211_NWID_LEN+1];
++
++                      isr = (struct ieee80211req_scan_result *) vsr;
++
++                      if (isr->isr_meshid_len) {
++                              id = vsr + isr->isr_ie_off + isr->isr_ssid_len;
++                              idlen = isr->isr_meshid_len;
++                      }
++                      else {
++                              id = vsr + isr->isr_ie_off;
++                              idlen = isr->isr_ssid_len;
++                      }
++                      strncpy(ssid, id, idlen);
++                      ssid[idlen] = '\0';
++                      ap = new nsWifiAccessPoint();
++                      ap->setSSID(ssid, strlen(ssid));
++                      ap->setMac(isr->isr_bssid);
++                      ap->setSignal(isr->isr_rssi);
++                      // apd.radio_signal_strength = (isr->isr_rssi/2) + 
isr->isr_noise;
++                      // apd.signal_to_noise = apd.radio_signal_strength - 
isr->isr_noise;
++                      // apd.channel = frequency_to_channel(isr->isr_freq);
++                      LOG((      "FreeBSD access point: "
++                              << "SSID: " << apd.ssid << ", "
++                              << "MAC: " << apd.mac_address << ", "
++                              << "Strength: " << apd.radio_signal_strength << 
":"
++                                              << apd.signal_to_noise << ", "
++                              << "Channel: " << apd.channel ));
++                      accessPoints.AppendObject(ap);
++                      res = true;
++                      len -= isr->isr_len;
++                      vsr += isr->isr_len;
++              }
++        }
++
++      freeifaddrs(ifal);
++
++      return res ? NS_OK : NS_ERROR_FAILURE;
++}
++
++nsresult
++nsWifiMonitor::DoScan()
++{
++      // Regularly get the access point data.
++
++      nsCOMArray<nsWifiAccessPoint> lastAccessPoints;
++      nsCOMArray<nsWifiAccessPoint> accessPoints;
++
++      do {
++              nsresult rv = FreeBSDGetAccessPointData(accessPoints);
++              if (NS_FAILED(rv))
++                      return rv;
++
++              bool accessPointsChanged = !AccessPointsEqual(accessPoints, 
lastAccessPoints);
++              ReplaceArray(lastAccessPoints, accessPoints);
++
++              rv = CallWifiListeners(lastAccessPoints, accessPointsChanged);
++              NS_ENSURE_SUCCESS(rv, rv);
++
++              // wait for some reasonable amount of time.  pref?
++              LOG(("waiting on monitor\n"));
++
++              ReentrantMonitorAutoEnter mon(mReentrantMonitor);
++              mon.Wait(PR_SecondsToInterval(60));
++      }
++      while (mKeepGoing);
++
++      return NS_OK;
++}
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-gecko
To unsubscribe, send any mail to "[email protected]"

Reply via email to