2014-12-28, 15:21
I have created an improved network manager addon which generates a listing of available wifi connections,
Currently it is using the container 53 view. I would like it to utilize a custom window I have created custom_network.xml
Is there a way to have the addon utilize a window I have previously created (custom_network.xml)
I cannot find any reference of how to point the addon to this when generating a listing (listing code below)
The code is envoked via the default.py script within the addon directory.
Thanks
Currently it is using the container 53 view. I would like it to utilize a custom window I have created custom_network.xml
Is there a way to have the addon utilize a window I have previously created (custom_network.xml)
I cannot find any reference of how to point the addon to this when generating a listing (listing code below)
The code is envoked via the default.py script within the addon directory.
PHP Code:
def GENERATE_LISTING():
global wifi_string
global active_wifi
active_wifi = 'None'
proc = Popen("nmcli dev wifi",shell=True, stdout=PIPE)
ethernet_mask = my_addon.getSetting('ethernet.mask')
listing = []
for line in proc.stdout:
try:
scan_secure = "secure"
scan_connect = "no"
scan_essid = line.rsplit("'")[1]
scan_signal = line.rsplit("'")[2].rsplit()[6]
if line.rsplit("'")[2].rsplit()[-2] == "--" : scan_secure = "open"
if line.rsplit("'")[2].rsplit()[-1] == "yes" : scan_connect = "connected"
listing.append(scan_essid + "," + scan_signal + "," + scan_secure + "," + scan_connect)
except IndexError:
pass
#show the correct icon
for item in listing:
supress = False
if (device_name in item.rsplit(",")[0] or "mediabadger" in item.rsplit(",")[0]) and "NetConnect" not in item.rsplit(",")[0]: supress = True
wifi_image = 'wifi_0'
sort_filter = 105 - int(item.rsplit(',')[1])
if int(item.rsplit(',')[1]) > 0 : wifi_image='wifi_25'
if int(item.rsplit(',')[1]) > 24 : wifi_image='wifi_50'
if int(item.rsplit(',')[1]) > 49 : wifi_image='wifi_75'
if int(item.rsplit(',')[1]) > 75 : wifi_image='wifi_100'
if str(item.rsplit(',')[3]) == "connected": sort_filter = "1"
if str(item.split(',')[2]) == "secure" : wifi_image = wifi_image + "l"
if str(item.split(',')[3]) == "connected" : wifi_image = wifi_image + "c"
if str(item.split(',')[3]) == "connected" : active_wifi = item.rsplit(",")[0]
wifi_image = wifi_image + ".png"
#build an ethernet port image for the netdongle
if ("MediaBadger NetConnect" in item.rsplit(",")[0]):
wifi_image = 'wifi_eth'
if str(item.rsplit(',')[3]) == "connected": sort_filter = "1"
if str(item.split(',')[3]) == "connected": wifi_image = wifi_image + "c"
wifi_image = wifi_image + ".png"
#now build the list
url = BUILD_URL({'SSID': item.rsplit(',')[0], 'ACTIVE': active_wifi})
li = xbmcgui.ListItem(item.rsplit(',')[0], iconImage=wifi_image, thumbnailImage=wifi_image)
li.addContextMenuItems([ ('Refresh', 'Container.Refresh') ] , replaceItems=True)
li.setInfo('video', {'director': "Something sexy", 'tracknumber': sort_filter, 'title': item.rsplit(',')[0] })
xbmcplugin.addSortMethod(addon_handle,xbmcplugin.SORT_METHOD_TRACKNUM)
if not supress: xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True)
#build ethernet port (only when not supressed)
if ethernet_mask == 'false' :
if not subprocess.call("ifconfig eth0 |grep 'inet add'",shell=True, stdin=None, stderr=None, stdout=None):
wifi_image = 'wifi_ethc.png'
else:
wifi_image = 'wifi_eth.png'
url = BUILD_URL({'SSID': 'Ethernet'})
li = xbmcgui.ListItem('Ethernet', iconImage=wifi_image, thumbnailImage=wifi_image)
li.addContextMenuItems([ ('Refresh', 'Container.Refresh') ] , replaceItems=True)
li.setInfo('video', {'director': "Something sexy", 'tracknumber': 2, 'title': 'Ethernet' })
xbmcplugin.addSortMethod(addon_handle,xbmcplugin.SORT_METHOD_TRACKNUM)
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True)
#build refresh button
wifi_image = 'wifi_broadcast.png'
url = BUILD_URL({'SSID': 'Broadcast'})
li = xbmcgui.ListItem('Re-broadcast Services', iconImage=wifi_image, thumbnailImage=wifi_image)
li.setInfo('video', {'director': "Something sexy", 'tracknumber': 0, 'title': 'Re-broadcast Services' })
xbmcplugin.addSortMethod(addon_handle,xbmcplugin.SORT_METHOD_TRACKNUM)
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True)
#build broadcast button
wifi_image = 'wifi_refresh.png'
url = BUILD_URL({'SSID': 'Refresh Connections'})
li = xbmcgui.ListItem('Refresh Connections', iconImage=wifi_image, thumbnailImage=wifi_image)
li.setInfo('video', {'director': "Something sexy", 'tracknumber': 0, 'title': 'Refresh' })
xbmcplugin.addSortMethod(addon_handle,xbmcplugin.SORT_METHOD_TRACKNUM)
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True)
xbmcplugin.endOfDirectory(addon_handle)
Thanks