Author: bklaas
Date: Thu Sep  9 15:02:51 2010
New Revision: 9102

URL: http://svn.slimdevices.com/jive?rev=9102&view=rev
Log:
Bug: n/a
Description: significant cleanup of Diags applet, moving a bunch of local 
variables into an init() method
add networkTroubleshootingMenu service method to Diags for pushing directed 
communication to user about network/server failures
add notification support to SlimMenus and SlimBrowser for network errors, 
pushing to a troubleshooting menu where necessary
add EN strings for support of this

Modified:
    
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
    
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/SlimMenus/SlimMenusApplet.lua
    
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsApplet.lua
    
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsMeta.lua
    
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/strings.txt

Modified: 
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
URL: 
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua?rev=9102&r1=9101&r2=9102&view=diff
==============================================================================
--- 
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
 (original)
+++ 
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
 Thu Sep  9 15:02:51 2010
@@ -102,6 +102,9 @@
 local _player = false
 local _server = false
 
+local _networkOrServerError = false
+local _diagWindow = false
+
 -- The path of enlightenment
 local _stepStack = {}
 
@@ -780,6 +783,23 @@
 
        -- it's very helpful at times to dump the request table here to see 
what command is being issued
        -- debug.dump(request)
+
+       -- there's an existing network or server error, so trap this request 
and push to a diags troubleshooting window
+       if _networkOrServerError then
+               log:warn('_networkOrServerError is not false, therefore push on 
an error window for diags')
+               local currentStep = _getCurrentStep()
+               _diagWindow = 
appletManager:callService("networkTroubleshootingMenu", _networkOrServerError)
+               -- make sure we got a window generated to confirm we can leave 
this method
+               if _diagWindow then
+                       -- FIXME: this part doesn't work. Menu item on home 
menu shows "locked" spinny icon after hitting back arrow from diags window
+                       if currentStep then
+                               if currentStep.menu then
+                                       currentStep.menu:unlock()
+                               end
+                       end
+                       return
+               end
+       end
 
        if not useCachedResponse then
                -- send the command
@@ -3038,6 +3058,20 @@
 end
 
 
+function notify_networkOrServerNotOK(self, iface)
+       _networkOrServerError = iface -- store the interface object in 
_networkOrServerError
+end
+
+
+function notify_networkAndServerOK(self, iface)
+       _networkOrServerError = false
+       if _diagWindow then
+               _diagWindow:hide()
+               _diagWindow = false
+       end
+end
+
+
 function notify_serverConnected(self, server)
        if _server ~= server then
                return

Modified: 
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/SlimMenus/SlimMenusApplet.lua
URL: 
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay/share/applets/SlimMenus/SlimMenusApplet.lua?rev=9102&r1=9101&r2=9102&view=diff
==============================================================================
--- 
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/SlimMenus/SlimMenusApplet.lua
 (original)
+++ 
7.6/trunk/squeezeplay/src/squeezeplay/share/applets/SlimMenus/SlimMenusApplet.lua
 Thu Sep  9 15:02:51 2010
@@ -183,6 +183,23 @@
 
 end
 
+
+function notify_networkOrServerNotOK(self, iface)
+       log:warn('notify_networkOrServerNotOK')
+       self.networkOrServerError = iface
+
+end
+
+
+function notify_networkAndServerOK(self, iface)
+       self.networkOrServerError = false
+       if self.diagWindow then
+               self.diagWindow:hide()
+               self.diagWindow = nil
+       end
+end
+
+
 function notify_serverConnected(self, server)
        log:debug("***serverConnected\t", server)
        local currentPlayer = appletManager:callService("getCurrentPlayer")
@@ -692,6 +709,17 @@
                                                end
 
                                        local currentPlayer = 
appletManager:callService("getCurrentPlayer")
+
+                                       -- if we know there is a network error 
condition, push on a diags window immediately
+                                       if self.networkOrServerError then
+                                               log:warn('Network or Server 
reported as not OK')
+                                               self.diagWindow = 
appletManager:callService("networkTroubleshootingMenu", 
self.networkOrServerError)
+                                               -- make sure we got a window 
generated to confirm we can leave this method
+                                               if self.diagWindow then
+                                                       log:warn("we've pushed 
a diag window, so we're done here")
+                                                       return
+                                               end
+                                       end
 
                                        if not _server then
                                                --should only happen if we load 
SN disconnected items and user selects one prior to _server being set on 
notify_playerCurrent

Modified: 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsApplet.lua
URL: 
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsApplet.lua?rev=9102&r1=9101&r2=9102&view=diff
==============================================================================
--- 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsApplet.lua
 (original)
+++ 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsApplet.lua
 Thu Sep  9 15:02:51 2010
@@ -40,74 +40,111 @@
 module(..., Framework.constants)
 oo.class(_M, Applet)
 
-
-local generalTests = {
-      "FIRMWARE_VERSION",
-      "HARDWARE_VERSION",
-      "MAC_ADDRESS",
-      "CURRENT_PLAYER",
-      "PLAYER_TYPE",
-      "UPTIME",
-      "MEMORY",
-}
-
-local wirelessTests = {
-      "WLAN_SSID",
-      "WLAN_ENCRYPTION",
-      "WLAN_STRENGTH",
-      -- (for testing): "WLAN_SNR",
-      "IP_ADDRESS",
-      "SUBNET_MASK",
-      "GATEWAY",
-      "DNS_SERVER",
-}
-
-local ethernetTests = {
-      "ETH_CONNECTION",
-      "IP_ADDRESS",
-      "SUBNET_MASK",
-      "GATEWAY",
-      "DNS_SERVER",
-}
-
-local serverTests = {
-      "SN_ADDRESS",
-      "SN_PING",
-      "SN_PORT_3483",
-      "SN_PORT_9000",
-      "SN_REG",
-      "SC_ADDRESS",
-      "SC_NAME",
-      "SC_PING",
-      "SC_PORT_3483",
-      "SC_PORT_9000",
-}
-
-local powerTests = {
-      "MSP_VERSION",
-      "POWER_MODE",
-      "WALL_VOLTAGE",
-      "CHARGE_STATE",
-      "BATTERY_TEMPERATURE",
-      "BATTERY_VOLTAGE",
-      "BATTERY_VMON1",
-      "BATTERY_VMON2",
-}
-
-local powerMode = {
-         ["3"] = "POWER_ON_AC",
-         ["7"] = "POWER_ON_AC_AND_BATT",
-         ["5"] = "POWER_ON_BATT",
-}
-
-local chargerState = {
-         ["1"]  = "BATT_NONE",
-         ["2"]  = "BATT_IDLE",
-         ["3"]  = "BATT_DISCHARGING",
-         ["35"] = "BATT_DISCHARGING_WARNING",
-         ["8"]  = "BATT_CHARGING",
-         ["24"] = "BATT_CHARGING_PAUSED",
-}
+function init(self)
+       self.generalTests = {
+             "FIRMWARE_VERSION",
+             "HARDWARE_VERSION",
+             "MAC_ADDRESS",
+             "CURRENT_PLAYER",
+             "PLAYER_TYPE",
+             "UPTIME",
+             "MEMORY",
+       }
+
+       self.wirelessTests = {
+             "WLAN_SSID",
+             "WLAN_ENCRYPTION",
+             "WLAN_STRENGTH",
+             -- (for testing): "WLAN_SNR",
+             "IP_ADDRESS",
+             "SUBNET_MASK",
+             "GATEWAY",
+             "DNS_SERVER",
+       }
+
+       self.ethernetTests = {
+             "ETH_CONNECTION",
+             "IP_ADDRESS",
+             "SUBNET_MASK",
+             "GATEWAY",
+             "DNS_SERVER",
+       }
+
+       self.serverTests = {
+             "SN_ADDRESS",
+             "SN_PING",
+             "SN_PORT_3483",
+             "SN_PORT_9000",
+             "SN_REG",
+             "SC_ADDRESS",
+             "SC_NAME",
+             "SC_PING",
+             "SC_PORT_3483",
+             "SC_PORT_9000",
+       }
+
+       self.powerTests = {
+             "MSP_VERSION",
+             "POWER_MODE",
+             "WALL_VOLTAGE",
+             "CHARGE_STATE",
+             "BATTERY_TEMPERATURE",
+             "BATTERY_VOLTAGE",
+             "BATTERY_VMON1",
+             "BATTERY_VMON2",
+       }
+
+       self.powerMode = {
+                 ["3"] = "POWER_ON_AC",
+                 ["7"] = "POWER_ON_AC_AND_BATT",
+                 ["5"] = "POWER_ON_BATT",
+       }
+
+       self.chargerState = {
+                 ["1"]  = "BATT_NONE",
+                 ["2"]  = "BATT_IDLE",
+                 ["3"]  = "BATT_DISCHARGING",
+                 ["35"] = "BATT_DISCHARGING_WARNING",
+                 ["8"]  = "BATT_CHARGING",
+                 ["24"] = "BATT_CHARGING_PAUSED",
+       }
+
+       self.netResultToText = {
+               [1] = {         text="NET_INTERFACE",           },
+               [-1] = {        text="NET_INTERFACE_NOK",       },
+               [3] = {         text="NET_LINK",                },
+               [5] = {         text="NET_LINK_WIRELESS_OK",    },
+               [-5] = {        text="NET_LINK_WIRELESS_NOK",   
help="NET_LINK_WIRELESS_NOK_HELP"},
+               [6] = {         text="NET_LINK_ETHERNET_OK",    },
+               [-6] = {        text="NET_LINK_ETHERNET_NOK",   
help="NET_LINK_ETHERNET_NOK_HELP"},
+               [8] = {         text="NET_IP_OK",               },
+               [-8] = {        text="NET_IP_NOK",              
help="NET_IP_NOK_HELP"},
+               [10] = {        text="NET_GATEWAY_OK",          },
+               [-10] = {       text="NET_GATEWAY_NOK",         
help="NET_GATEWAY_NOK_HELP"},
+               [12] = {        text="NET_DNS_OK",              },
+               [-12] = {       text="NET_DNS_NOK",             
help="NET_DNS_NOK_HELP"},
+               [20] = {        text="NET_ARPING",              },
+               [21] = {        text="NET_ARPING_OK",           },
+               [-21] = {       text="NET_ARPING_NOK",          
help="NET_ARPING_NOK_HELP"},
+               [-23] = {       text="NET_SERVER_NOK",          },
+               [25] = {        text="NET_RESOLVE",             },
+               [27] = {        text="NET_RESOLVE_OK",          },
+               [-27] = {       text="NET_RESOLVE_NOK",         
help="NET_RESOLVE_NOK_HELP"},
+               [29] = {        text="NET_PING",                },
+               [31] = {        text="NET_PING_OK",             },
+               [-31] = {       text="NET_PING_NOK",            
help="NET_PING_NOK_HELP"},
+               [33] = {        text="NET_PORT",                },
+               [35] = {        text="NET_PORT_OK",             },
+               [-35] = {       text="NET_PORT_NOK",            
help="NET_PORT_NOK_HELP"},
+               [37] = {        text="NET_PORT_OK",             },
+               [-37] = {       text="NET_PORT_NOK",            
help="NET_PORT_NOK_HELP"},
+               [100] = {       text="NET_BRINGING_NETWORK_DOWN",       },
+               [102] = {       text="NET_BRINGING_NETWORK_UP",         },
+               [104] = {       text="NET_REPAIR_NETWORK_DONE",         },
+       }
+
+end
+
 
 
 function setValue(self, key, value, customLabel)
@@ -463,7 +500,7 @@
        self:setValue("MSP_VERSION", self:_getSysValue("fw"))
 
        local mode = self:_getPowerSysValue("power_mode"):gsub("^%s*(.-)%s*$", 
"%1")
-       self:setValue("POWER_MODE", tostring(self:string(powerMode[mode])))
+       self:setValue("POWER_MODE", tostring(self:string(self.powerMode[mode])))
 
        -- Battery only
        if mode == "5" then
@@ -475,7 +512,7 @@
        end
 
        local mode = 
self:_getPowerSysValue("charger_state"):gsub("^%s*(.-)%s*$", "%1")
-       self:setValue("CHARGE_STATE", tostring(self:string(chargerState[mode])))
+       self:setValue("CHARGE_STATE", 
tostring(self:string(self.chargerState[mode])))
 
        -- No battery installed
        if mode == "1" then
@@ -510,7 +547,7 @@
 
        self.labels = {}
 
-       for i,name in ipairs(generalTests) do
+       for i,name in ipairs(self.generalTests) do
                self.labels[name] = {
                        text = self:string(name, ''),
                        style = 'item_info',
@@ -539,7 +576,7 @@
 
        self.labels = {}
 
-       for i,name in ipairs(wirelessTests) do
+       for i,name in ipairs(self.wirelessTests) do
                self.labels[name] = {
                        text = self:string(name, ''),
                        style = 'item_info',
@@ -568,7 +605,7 @@
 
        self.labels = {}
 
-       for i,name in ipairs(ethernetTests) do
+       for i,name in ipairs(self.ethernetTests) do
                self.labels[name] = {
                        text = self:string(name, ''),
                        style = 'item_info',
@@ -597,7 +634,7 @@
 
        self.labels = {}
 
-       for i,name in ipairs(serverTests) do
+       for i,name in ipairs(self.serverTests) do
                local label
                if name == 'SC_PORT_9000' then
                        label = self:string(name, '9000', '-')
@@ -633,7 +670,7 @@
 
        self.labels = {}
 
-       for i,name in ipairs(powerTests) do
+       for i,name in ipairs(self.powerTests) do
                self.labels[name] = {
                        text = self:string(name, ''),
                        style = 'item_info',
@@ -650,6 +687,40 @@
 
        self:tieAndShowWindow(window)
        return window
+end
+
+
+-- Error Troubleshooting menu
+function networkTroubleshootingMenu(self, iface)
+
+       log:warn('networkTroubleshootingMenu: ', iface)
+       if not iface then
+               log:error('You must specify the interface object when calling 
this method')
+               return false
+       end
+
+        local errorCode = iface:getNetworkResult()
+       if not errorCode then
+               log:error('There is no network problem registered on this 
interface')
+               return
+       end
+
+        local window = Window("text_list", self:string("NETWORK_PROBLEM") )
+       window:setButtonAction("rbutton", nil)
+
+        local menu = SimpleMenu("menu")
+       
+        local helpTextToken = self.netResultToText[errorCode] and 
self.netResultToText[errorCode].help or "NETWORK_PROBLEM_HELP"
+       menu:setHeaderWidget( Textarea( "help_text", self:string(helpTextToken) 
) )
+
+       self:_addDiagnosticsMenuItem(menu)
+       self:_addRepairNetworkItem(menu)
+
+        window:addWidget(menu)
+
+        window:show()
+       return window
+
 end
 
 
@@ -762,13 +833,7 @@
 
        local menu = SimpleMenu("menu")
 
-       menu:addItem({
-               text = self:string("DIAGNOSTICS"),
-               sound = "WINDOWSHOW",           
-               callback = function()
-                       self:diagnosticsMenu(true)
-               end,
-       })
+       self:_addDiagnosticsMenuItem(menu, true)
 
        menu:setHeaderWidget(Textarea("help_text", self:string("SUPPORT_HELP")))
        window:addWidget(menu)
@@ -811,6 +876,28 @@
 --             end
 --     })
 
+       self:_addRepairNetworkItem(menu)
+       self.networkHealthMenu = menu
+
+       window:addWidget(menu)
+
+       self:tieAndShowWindow(window)
+
+       return window
+end
+
+function _addDiagnosticsMenuItem(self, menu, suppressNetworkingItem)
+       menu:addItem({
+               text = self:string("DIAGNOSTICS"),
+               style = 'item',
+               callback = function ()
+                       self:diagnosticsMenu(suppressNetworkingItem)
+               end
+       })
+end
+
+
+function _addRepairNetworkItem(self, menu)
        menu:addItem({
                text = self:string("REPAIR_NETWORK"),
                style = 'item',
@@ -818,53 +905,10 @@
                        self:manualRepairNetwork()
                end
        })
-
-       self.networkHealthMenu = menu
-
-       window:addWidget(menu)
-
-       self:tieAndShowWindow(window)
-
-       return window
-end
-
-
-local netResultToText = {
-       [1] = {         text="NET_INTERFACE",           help=""},
-       [-1] = {        text="NET_INTERFACE_NOK",       help=""},
-       [3] = {         text="NET_LINK",                help=""},
-       [5] = {         text="NET_LINK_WIRELESS_OK",    help=""},
-       [-5] = {        text="NET_LINK_WIRELESS_NOK",   
help="NET_LINK_WIRELESS_NOK_HELP"},
-       [6] = {         text="NET_LINK_ETHERNET_OK",    help=""},
-       [-6] = {        text="NET_LINK_ETHERNET_NOK",   
help="NET_LINK_ETHERNET_NOK_HELP"},
-       [8] = {         text="NET_IP_OK",               help=""},
-       [-8] = {        text="NET_IP_NOK",              help="NET_IP_NOK_HELP"},
-       [10] = {        text="NET_GATEWAY_OK",          help=""},
-       [-10] = {       text="NET_GATEWAY_NOK",         
help="NET_GATEWAY_NOK_HELP"},
-       [12] = {        text="NET_DNS_OK",              help=""},
-       [-12] = {       text="NET_DNS_NOK",             
help="NET_DNS_NOK_HELP"},
-       [20] = {        text="NET_ARPING",              help=""},
-       [21] = {        text="NET_ARPING_OK",           help=""},
-       [-21] = {       text="NET_ARPING_NOK",          
help="NET_ARPING_NOK_HELP"},
-       [-23] = {       text="NET_SERVER_NOK",          help=""},
-       [25] = {        text="NET_RESOLVE",             help=""},
-       [27] = {        text="NET_RESOLVE_OK",          help=""},
-       [-27] = {       text="NET_RESOLVE_NOK",         
help="NET_RESOLVE_NOK_HELP"},
-       [29] = {        text="NET_PING",                help=""},
-       [31] = {        text="NET_PING_OK",             help=""},
-       [-31] = {       text="NET_PING_NOK",            
help="NET_PING_NOK_HELP"},
-       [33] = {        text="NET_PORT",                help=""},
-       [35] = {        text="NET_PORT_OK",             help=""},
-       [-35] = {       text="NET_PORT_NOK",            
help="NET_PORT_NOK_HELP"},
-       [37] = {        text="NET_PORT_OK",             help=""},
-       [-37] = {       text="NET_PORT_NOK",            
help="NET_PORT_NOK_HELP"},
-       [100] = {       text="NET_BRINGING_NETWORK_DOWN",       help=""},
-       [102] = {       text="NET_BRINGING_NETWORK_UP",         help=""},
-       [104] = {       text="NET_REPAIR_NETWORK_DONE",         help=""},
-}
-
-
-local function setResult(self, index, result, msgStr)
+end
+
+
+function setResult(self, index, result, msgStr)
        self:addExtraStyle(jive.ui.style)
 
        local myItem = self.labels[index]
@@ -921,7 +965,7 @@
        Networking:checkNetworkHealth(
                ifObj,
                function(continue, result, msg_param)
-                       local msg = netResultToText[result].text
+                       local msg = self.netResultToText[result].text
                        local msgStr = tostring(self:string(msg, msg_param))
 
                        log:debug("checkNetworkHealth status: ", msgStr)
@@ -962,7 +1006,7 @@
        Networking:repairNetwork(
                ifObj,
                function(continue, result)
-                       local msg = netResultToText[result].text
+                       local msg = self.netResultToText[result].text
                        local msgStr = tostring(self:string(msg))
 
                        log:debug("repairNetwork status: ", msgStr)
@@ -984,7 +1028,7 @@
 
 
 -- defines a new style that inherrits from an existing style
-local function _uses(parent, value)
+function _uses(parent, value)
        if parent == nil then
                log:warn("nil parent in _uses at:\n", debug.traceback())
        end

Modified: 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsMeta.lua
URL: 
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsMeta.lua?rev=9102&r1=9101&r2=9102&view=diff
==============================================================================
--- 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsMeta.lua
 (original)
+++ 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsMeta.lua
 Thu Sep  9 15:02:51 2010
@@ -21,6 +21,7 @@
 function registerApplet(meta)
        meta:registerService("diagnosticsMenu")
        meta:registerService("supportMenu")
+       meta:registerService("networkTroubleshootingMenu")
 
        Framework:addActionListener("help", nil, function()
                appletManager:callService("supportMenu")

Modified: 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/strings.txt
URL: 
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/strings.txt?rev=9102&r1=9101&r2=9102&view=diff
==============================================================================
--- 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/strings.txt
 (original)
+++ 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/strings.txt
 Thu Sep  9 15:02:51 2010
@@ -1107,3 +1107,10 @@
 NET_SUCCESS
        EN      All network tests passed successfully
 
+NETWORK_PROBLEM
+       EN      Network Problem
+
+# for a generic troubleshooting message when no specific help is available
+NETWORK_PROBLEM_HELP
+       EN      Your squeezebox is experiencing a network problem.\nPossible 
solutions:\n - Confirm that a PC on your home network can connect to the 
internet.\n - Reboot the device that manages your home network. This is 
typically a wireless router or broadband modem.
+

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/jive-checkins

Reply via email to