Author: fmueller
Date: Thu Sep  2 00:53:36 2010
New Revision: 9090

URL: http://svn.slimdevices.com/jive?rev=9090&view=rev
Log:
Bug: 16408 
Description:  
- Add window show shound for Diagnostics submenus
- Preliminary work to allow to provide context help for specific network issues

Modified:
    
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/DiagnosticsApplet.lua
    
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/applets/Diagnostics/strings.txt
    
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua

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=9090&r1=9089&r2=9090&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  2 00:53:36 2010
@@ -665,6 +665,7 @@
 
        menu:addItem({
                text = self:string("MENU_GENERAL"),
+               sound = "WINDOWSHOW",           
                style = 'item',
                callback = function ()
                        self:showGeneralDiagnosticsMenu()
@@ -673,6 +674,7 @@
 
        menu:addItem({
                text = self:string("MENU_NETWORK_HEALTH"),
+               sound = "WINDOWSHOW",           
                style = 'item',
                callback = function ()
                        self:showNetworkHealthDiagnosticsMenu()
@@ -681,6 +683,7 @@
 
        menu:addItem({
                text = self:string("MENU_WIRELESS"),
+               sound = "WINDOWSHOW",           
                style = 'item',
                callback = function ()
                        self:showWirelessDiagnosticsMenu()
@@ -690,6 +693,7 @@
        if System:getMachine() ~= 'jive' then
                menu:addItem({
                        text = self:string("MENU_ETHERNET"),
+                       sound = "WINDOWSHOW",           
                        style = 'item',
                        callback = function ()
                                self:showEthernetDiagnosticsMenu()
@@ -699,6 +703,7 @@
 
        menu:addItem({
                text = self:string("MENU_SERVER"),
+               sound = "WINDOWSHOW",           
                style = 'item',
                callback = function ()
                        self:showServerDiagnosticsMenu()
@@ -708,6 +713,7 @@
        if System:getMachine() == "baby" then
                menu:addItem({
                        text = self:string("POWER"),
+                       sound = "WINDOWSHOW",           
                        style = 'item',
                        callback = function ()
                                self:showPowerDiagnosticsMenu()
@@ -718,6 +724,7 @@
        if System:isHardware() then
                menu:addItem({
                        text = self:string("SOFTWARE_UPDATE"),
+                       sound = "WINDOWSHOW",           
                        style = 'item',
                        callback = function ()
                                --todo: this does setup style FW upgrade only 
(since this menu is avilable from setup).  When we want different support for a 
non-setup version, make sure to leave the setup style behavior
@@ -728,6 +735,7 @@
                if not suppressNetworkingItem then
                        menu:addItem({
                                text = self:string("DIAGNOSTICS_NETWORKING"),
+                               sound = "WINDOWSHOW",           
                                style = 'item',
                                callback = function ()
                                        
appletManager:callService("settingsNetworking")
@@ -821,6 +829,64 @@
 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=""},
+       [6] = {         text="NET_LINK_ETHERNET_OK",    help=""},
+       [-6] = {        text="NET_LINK_ETHERNET_NOK",   help=""},
+       [8] = {         text="NET_IP_OK",               help=""},
+       [-8] = {        text="NET_IP_NOK",              help=""},
+       [10] = {        text="NET_GATEWAY_OK",          help=""},
+       [-10] = {       text="NET_GATEWAY_NOK",         help=""},
+       [12] = {        text="NET_DNS_OK",              help=""},
+       [-12] = {       text="NET_DNS_NOK",             help=""},
+       [20] = {        text="NET_ARPING",              help=""},
+       [21] = {        text="NET_ARPING_OK",           help=""},
+       [-21] = {       text="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=""},
+       [29] = {        text="NET_PING",                help=""},
+       [31] = {        text="NET_PING_OK",             help=""},
+       [-31] = {       text="NET_PING_NOK",            help=""},
+       [33] = {        text="NET_PORT",                help=""},
+       [35] = {        text="NET_PORT_OK",             help=""},
+       [-35] = {       text="NET_PORT_NOK",            help=""},
+       [37] = {        text="NET_PORT_OK",             help=""},
+       [-37] = {       text="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)
+       self:addExtraStyle(jive.ui.style)
+
+       local myItem = self.labels[index]
+
+       -- no error
+       if result >= 0 then
+               -- Replace everything's ok message with a user friendly one
+               msgStr = tostring(self:string("NET_SUCCESS"))
+               myItem.style = "item_info_green"
+       -- some error
+       else
+               myItem.style = "item_info_red"
+       end
+
+       self.networkHealthMenu:setText(self.labels[index], self:string(index, 
msgStr))
+       self.networkHealthMenu:setSelectedIndex(1)
+
+-- TODO: needed?
+--     self.networkHealthMenu:replaceIndex(myItem, 1)
+end
+
+
 function manualCheckNetworkHealth(self, full_check)
        local popup = Popup("waiting_popup")
        popup:setAllowScreensaver(false)
@@ -854,23 +920,20 @@
 
        Networking:checkNetworkHealth(
                ifObj,
-               function(continue, err, msg, msg_param)
-                       local message = self:string(msg, msg_param)
-                       log:debug("checkNetworkHealth status: ", message)
+               function(continue, result, msg_param)
+                       local msg = netResultToText[result].text
+                       local msgStr = tostring(self:string(msg, msg_param))
+
+                       log:debug("checkNetworkHealth status: ", msgStr)
 
                        if continue then
                                -- Update spinny message
-                               status:setValue(self:string("STATUS_MSG", 
message))
+                               status:setValue(self:string("STATUS_MSG", 
msgStr))
                        else
-                               log:debug("Network health error: ", err)
+                               log:debug("Network health error: ", result)
 
                                -- Update final message
-                               self:setResult("NETWORK_STATUS", err)
-
---                             self:setValue("NETWORK_STATUS", message)
-                               
self.networkHealthMenu:setText(self.labels["NETWORK_STATUS"], 
self:string("NETWORK_STATUS", message))
-
-                               self.networkHealthMenu:setSelectedIndex(1)
+                               setResult(self, "NETWORK_STATUS", result, 
msgStr)
 
                                popup:hide()
                        end
@@ -882,20 +945,6 @@
        self:tieAndShowWindow(popup)
 end
 
-function setResult(self, index, err)
-       self:addExtraStyle(jive.ui.style)
-
-       local myItem = self.labels[index]
-
-       if err == 0 then
-               myItem.style = "item_info_green"
-       else
-               myItem.style = "item_info_red"
-       end
--- TODO: needed?
---     self.networkHealthMenu:replaceIndex(myItem, 1)
-end
-
 
 function manualRepairNetwork(self)
        local popup = Popup("waiting_popup")
@@ -912,16 +961,18 @@
 
        Networking:repairNetwork(
                ifObj,
-               function(continue, err, msg, msg_param)
-                       local message = self:string(msg, msg_param)
-                       log:debug("repairNetwork status: ", message)
+               function(continue, result)
+                       local msg = netResultToText[result].text
+                       local msgStr = tostring(self:string(msg))
+
+                       log:debug("repairNetwork status: ", msgStr)
 
                        if continue then
                                -- Update spinny message
-                               status:setValue(self:string("STATUS_MSG", 
message))
+                               status:setValue(self:string("STATUS_MSG", 
msgStr))
                        else
                                -- Update final message
-                               log:debug("Repair network error: ", err)
+                               log:debug("Repair network error: ", result)
 
                                popup:hide()
                        end

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=9090&r1=9089&r2=9090&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  2 00:53:36 2010
@@ -1002,8 +1002,8 @@
 NET_REPAIR_NETWORK_DONE
        EN      Repair network done
 
-NET_CONNECTION_NOK
-       EN      Not connected
+NET_INTERFACE
+       EN      Check network interface
 
 NET_INTERFACE_NOK
        EN      No network interface
@@ -1080,4 +1080,6 @@
 NET_PORT_NOK
        EN      Connection to %s not ok
 
-
+NET_SUCCESS
+       EN      All network tests passed successfully
+

Modified: 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
URL: 
http://svn.slimdevices.com/jive/7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua?rev=9090&r1=9089&r2=9090&view=diff
==============================================================================
--- 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua 
(original)
+++ 
7.6/trunk/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua 
Thu Sep  2 00:53:36 2010
@@ -1984,11 +1984,11 @@
 - Ping server (SC or SN)
 - Try to connect to port 3483 and 9000
 
-While the checks are running status messages are returned
+While the checks are running status values are returned
 via callback function. The callback provides three params:
 - continue: true or false
-- err: -1 or 0
-- message: message according to what is happening or failed
+- result: ok >= 0, nok < 0 (for specific values see code below or sample use 
in DiagnosticsApplet)
+- msg_param: additional message info
 
 class          - Networking class
 ifObj          - network object
@@ -2005,18 +2005,18 @@
        Task("checknetworkhealth", ifObj, function()
                log:debug("checkNetworkHealth task started")
 
-               callback(true, -1, "NET_CONNECTION_NOK")
+               callback(true, 1)
 
                -- ------------------------------------------------------------
                -- Check for valid network interface
                if ifObj == nil then
-                       callback(false, -1, "NET_INTERFACE_NOK")
+                       callback(false, -1)
                        return
                end
 
                -- ------------------------------------------------------------
                -- Getting network status (link / no link)
-               callback(true, 0, "NET_LINK")
+               callback(true, 3)
 
                local status = ifObj:t_wpaStatus()
 
@@ -2024,16 +2024,16 @@
                        local percentage, quality = ifObj:getSignalStrength()
 
                        if (status.wpa_state ~= "COMPLETED") or (quality == 0) 
then
-                               callback(false, -1, "NET_LINK_WIRELESS_NOK")
+                               callback(false, -5)
                                return
                        end
-                       callback(true, 0, "NET_LINK_WIRELESS_OK")
+                       callback(true, 5)
                else
                        if status.link ~= true then
-                               callback(false, -1, "NET_LINK_ETHERNET_NOK")
+                               callback(false, -6)
                                return
                        end
-                       callback(true, 0, "NET_LINK_ETHERNET_OK")
+                       callback(true, 6)
                end
 
                -- We have a network link (wired or wireless)
@@ -2041,37 +2041,37 @@
                -- ------------------------------------------------------------
                -- Check for valid ip address
                if status.ip_address == nil or string.match(status.ip_address, 
"^169.254.") then
-                       callback(false, -1, "NET_IP_NOK")
+                       callback(false, -8)
                        return
                end
 
                -- We have a valid ip address
-               callback(true, 0, "NET_IP_OK", tostring(status.ip_address))
+               callback(true, 8, tostring(status.ip_address))
 
                -- ------------------------------------------------------------
                -- Check for valid gateway
                if status.ip_gateway == nil then
-                       callback(false, -1, "NET_GATEWAY_NOK")
+                       callback(false, -10)
                        return
                end
 
                -- We have a valid gateway
-               callback(true, 0, "NET_GATEWAY_OK", tostring(status.ip_gateway))
+               callback(true, 10, tostring(status.ip_gateway))
 
                -- ------------------------------------------------------------
                -- Check for valid dns sever ip
                if status.ip_dns == nil then
-                       callback(false, -1, "NET_DNS_NOK")
+                       callback(false, -12)
                        return
                end
 
                -- We have a valid dns server ip
-               callback(true, 0, "NET_DNS_OK", tostring(status.ip_dns))
+               callback(true, 12, tostring(status.ip_dns))
 
                -- ------------------------------------------------------------
                -- Stop here if not full check is needed
                if not full_check then
-                       callback(false, 0, "NET_DNS_OK", 
tostring(status.ip_dns))
+                       callback(false, 12, tostring(status.ip_dns))
 
                        log:debug("checkNetworkHealth task done (part)")
                        return
@@ -2079,7 +2079,7 @@
 
                -- ------------------------------------------------------------
                -- Arping our own ip address
-               callback(true, 0, "NET_ARPING", tostring(status.ip_address))
+               callback(true, 20, tostring(status.ip_address))
 
                -- Arping
                local arpingOK = false
@@ -2091,9 +2091,9 @@
                                end
                        else
                                if arpingOK then
-                                       callback(true, 0, "NET_ARPING_OK")
+                                       callback(true, 21)
                                else
-                                       callback(false, -1, "NET_ARPING_NOK", 
tostring(status.ip_address))
+                                       callback(false, -21, 
tostring(status.ip_address))
                                end
                        end
                end)
@@ -2110,7 +2110,7 @@
                -- ------------------------------------------------------------
                -- Check for server
                if not server then
-                       callback(false, -1, "NET_SERVER_NOK")
+                       callback(false, -23)
                        return
                end
 
@@ -2123,22 +2123,22 @@
                if DNS:isip(server_uri) then
                        server_ip = server_uri
                else
-                       callback(true, 0, "NET_RESOLVE", server_name)
+                       callback(true, 25, server_name)
                        server_ip, err = DNS:toip(server_uri)
                end
 
                -- Check for valid SN ip address
                if server_ip == nil then
-                       callback(false, -1, "NET_RESOLVE_NOK", server_name)
+                       callback(false, -27, server_name)
                        return
                end
 
                -- We have a valid ip address for SN
-               callback(true, 0, "NET_RESOLVE_OK", server_name .. ": " .. 
server_ip)
+               callback(true, 27, server_name .. ": " .. server_ip)
 
                -- ------------------------------------------------------------
                -- Ping server (SC or SN)
-               callback(true, 0, "NET_PING", server_name)
+               callback(true, 29, server_name)
 
                local pingOK = false
                local pingProc = Process(jnt, "ping -c 1 " .. server_ip)
@@ -2149,9 +2149,9 @@
                                end
                        else
                                if pingOK then
-                                       callback(true, 0, "NET_PING_OK", 
server_name .. " (" .. server_ip .. ")")
+                                       callback(true, 31, server_name .. " (" 
.. server_ip .. ")")
                                else
-                                       callback(false, -1, "NET_PING_NOK", 
server_name .. " (" .. server_ip .. ")")
+                                       callback(false, -31, server_name .. " 
(" .. server_ip .. ")")
                                end
                        end
                end)
@@ -2167,7 +2167,7 @@
 
                -- ------------------------------------------------------------
                -- Port 3483 test
-               callback(true, 0, "NET_PORT", server_name .. " (3483)")
+               callback(true, 33, server_name .. " (3483)")
 
                local portOk_3483 = false
                local tcp_3483 = SocketTcp(jnt, server_ip, 3483, "porttest")
@@ -2179,9 +2179,9 @@
                        end
 
                        if portOk_3483 then
-                               callback(true, 0, "NET_PORT_OK", server_name .. 
" (3483)")
+                               callback(true, 35, server_name .. " (3483)")
                        else
-                               callback(false, 0, "NET_PORT_NOK", server_name 
.. " (3483)")
+                               callback(false, -35, server_name .. " (3483)")
                        end
                        tcp_3483:close()
                end)
@@ -2197,7 +2197,7 @@
 
                -- ------------------------------------------------------------
                -- Port 9000 test
-               callback(true, 0, "NET_PORT", server_name .. " (" .. 
server_port .. ")")
+               callback(true, 33, server_name .. " (" .. server_port .. ")")
 
                local portOk = false
                local tcp = SocketTcp(jnt, server_ip, server_port, "porttest")
@@ -2209,9 +2209,9 @@
                        end
 
                        if portOk then
-                               callback(false, 0, "NET_PORT_OK", server_name 
.. " (" .. server_port .. ")")
+                               callback(false, 37, server_name .. " (" .. 
server_port .. ")")
                        else
-                               callback(false, 0, "NET_PORT_NOK", server_name 
.. " (" .. server_port .. ")")
+                               callback(false, -37, server_name .. " (" .. 
server_port .. ")")
                        end
                        tcp:close()
                end)
@@ -2240,11 +2240,10 @@
 - Bring up the active network - this also starts DHCP
 - Connect to wireless network / wired network
 
-While it's running status messages are returned
-via callback function. The callback provides three params:
+While it's running status values are returned via
+callback function. The callback provides two params:
 - continue: true or false
-- err: -1 or 0
-- message: message according to what is happening or failed
+- result: ok >= 0, nok < 0
 
 class          - Networking class
 ifObj          - network object
@@ -2261,15 +2260,15 @@
 
                local active = ifObj:_ifstate()
 
-               callback(true, 0, "NET_BRINGING_NETWORK_DOWN")
+               callback(true, 100)
 
                ifObj:_ifDown()
 
-               callback(true, 0, "NET_BRINGING_NETWORK_UP")
+               callback(true, 102)
 
                ifObj:_ifUp(active)
 
-               callback(false, 0, "NET_REPAIR_NETWORK_DONE")
+               callback(false, 104)
 
                log:info("repairNetwork task done")
        end):addTask()

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

Reply via email to