Skip to content

Commit

Permalink
Merge pull request #8 from agordon/fix_known_wifi_networks
Browse files Browse the repository at this point in the history
Known Wifi Networks plugin: bugfix for no SSID.
  • Loading branch information
PicciMario committed Oct 11, 2013
2 parents a2de682 + c885801 commit 3fd0dfa
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions ipba2-plugins/plg_knownnetworks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PySide import QtCore, QtGui
from knownnetworks_ui import Ui_KnownNetworks

import os, sqlite3, plistlib
import os, sqlite3, plistlib, sys
from datetime import datetime

PLUGIN_NAME = "Known WiFi Networks"
Expand Down Expand Up @@ -30,7 +30,7 @@ def __init__(self, cursor, path, daemon = False):

#self.ui.listTree.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
#QtCore.QObject.connect(self.ui.listTree, QtCore.SIGNAL('customContextMenuRequested(QPoint)'), self.ctxMenu)

if (daemon == False):

self.ui.networksTree.setColumnHidden(0,True)
Expand All @@ -45,14 +45,28 @@ def populateUI(self):

index = 0
for network in self.networks:

element = QtGui.QTreeWidgetItem(None)
element.setText(0, str(index))
element.setText(1, network['SSID'])
element.setText(1, self.getNetworkName(network))
self.ui.networksTree.addTopLevelItem(element)

index += 1

def getNetworkName(self, network):
"""
Given a DICT/Plist of "known networks", returns a descriptive name of the network.
Typically, this will be the SSID.
But some entries do not have SSID (possibly related to Enterprise networks?).
If so, try other keys.
"""
# Observed keys with some decsriptive identifiers.
keys = [ 'SSID', 'PayloadOrganization', 'SSID_STR', 'PayloadIdentifier', 'BSSID' ]
for k in keys:
if k in network:
return network[k]
return "(Unknown Network)"


def onTreeClick(self):

Expand Down Expand Up @@ -124,4 +138,4 @@ def parseNode(self, newNode, parentNode):


def main(cursor, path):
return KnownNetworksWidget(cursor, path)
return KnownNetworksWidget(cursor, path)

0 comments on commit 3fd0dfa

Please sign in to comment.