Author: titmuss
Date: Thu Jan 31 03:50:05 2008
New Revision: 1714
URL: http://svn.slimdevices.com?rev=1714&root=Jive&view=rev
Log:
Bug: 6764
Description:
Fix SN pin entry to work better from both Choose Player and Choose Music Source
menus. If SN is select in both cases the SN
pin screen is displayed before any actions are taken. This allows the user to
cancel this choice (press left to go back).
The active pin page now polls SN, and will continue automatically once the pin
is entered correctly.
In Choose Player with SN option is renamed "Activate SqueezeNetwork" and put at
the button of the list.
This checkin does not cover the cases where your player is not linked SN when
using Choose Music Source.
Modified:
branches/7.0/jive/src/pkg/jive/share/applets/ChooseMusicSource/ChooseMusicSourceApplet.lua
branches/7.0/jive/src/pkg/jive/share/applets/SelectPlayer/SelectPlayerApplet.lua
branches/7.0/jive/src/pkg/jive/share/applets/SelectPlayer/strings.txt
branches/7.0/jive/src/pkg/jive/share/applets/SqueezeNetworkPIN/SqueezeNetworkPINApplet.lua
branches/7.0/jive/src/pkg/jive/share/jive/AppletManager.lua
branches/7.0/jive/src/pkg/jive/share/jive/net/Comet.lua
branches/7.0/jive/src/pkg/jive/share/jive/slim/SlimServer.lua
Modified:
branches/7.0/jive/src/pkg/jive/share/applets/ChooseMusicSource/ChooseMusicSourceApplet.lua
URL:
http://svn.slimdevices.com/branches/7.0/jive/src/pkg/jive/share/applets/ChooseMusicSource/ChooseMusicSourceApplet.lua?rev=1714&root=Jive&r1=1713&r2=1714&view=diff
==============================================================================
---
branches/7.0/jive/src/pkg/jive/share/applets/ChooseMusicSource/ChooseMusicSourceApplet.lua
(original)
+++
branches/7.0/jive/src/pkg/jive/share/applets/ChooseMusicSource/ChooseMusicSourceApplet.lua
Thu Jan 31 03:50:05 2008
@@ -265,6 +265,25 @@
-- connect player to server
function connectPlayer(self, player, server)
+
+ -- if connecting to SqueezeNetwork, first check jive is linked
+ if server:getPin() then
+ local snpin = appletManager:loadApplet("SqueezeNetworkPIN")
+ snpin:enterPin(server, nil,
+ function()
+ self:connectPlayer(player, server)
+ end)
+
+ return
+ end
+
+ -- make sure the player is linked on SqueezeNetwork, this may return an
+ -- error if the player can't be linked, for example it is linked to
another
+ -- account already.
+ --
+ -- XXX send a playerRegister, we'll need to check the response to make
sure
+ -- the player is not linked to another account.
+
-- tell the player to move servers
self.waitForConnect = {
player = player,
Modified:
branches/7.0/jive/src/pkg/jive/share/applets/SelectPlayer/SelectPlayerApplet.lua
URL:
http://svn.slimdevices.com/branches/7.0/jive/src/pkg/jive/share/applets/SelectPlayer/SelectPlayerApplet.lua?rev=1714&root=Jive&r1=1713&r2=1714&view=diff
==============================================================================
---
branches/7.0/jive/src/pkg/jive/share/applets/SelectPlayer/SelectPlayerApplet.lua
(original)
+++
branches/7.0/jive/src/pkg/jive/share/applets/SelectPlayer/SelectPlayerApplet.lua
Thu Jan 31 03:50:05 2008
@@ -42,8 +42,9 @@
local SetupSqueezeboxApplet =
require("applets.SetupSqueezebox.SetupSqueezeboxApplet")
+local jnt = jnt
local jiveMain = jiveMain
-local jnt = jnt
+local appletManager = appletManager
local EVENT_WINDOW_POP = jive.ui.EVENT_WINDOW_POP
local EVENT_WINDOW_ACTIVE = jive.ui.EVENT_WINDOW_ACTIVE
@@ -160,19 +161,27 @@
function _addPlayerItem(self, player)
local mac = player.id
local playerName = player.name
+ local playerWeight = 1
+
+ -- if waiting for a SN pin modify name
+ if player:getPin() then
+ playerName = self:string("SQUEEZEBOX_ACTIVATE", player.name)
+ playerWeight = 10
+ end
local item = {
id = _unifyMac(mac),
text = playerName,
sound = "WINDOWSHOW",
callback = function()
- self:selectPlayer(player)
- self.setupNext()
+ if self:selectPlayer(player) then
+ self.setupNext()
+ end
end,
focusGained = function(event)
self:_showWallpaper(mac)
end,
- weight = 1
+ weight = playerWeight
}
if player == self.selectedPlayer then
@@ -382,7 +391,7 @@
for ssid, entry in pairs(scanTable) do
local mac, ether = SetupSqueezeboxApplet:ssidIsSqueezebox(ssid)
- log:warn("MAC=", mac, " ETHER=", ether)
+ log:debug("MAC=", mac, " ETHER=", ether)
if mac and not self.scanResults[mac] and
-- FIXME Wireless class should be timing out entries
@@ -400,6 +409,17 @@
function selectPlayer(self, player)
+ -- if connecting to SqueezeNetwork, first check we are linked
+ if player:getPin() then
+ -- as we are not linked this is a dummy player, after we need
linked we
+ -- need to return to the choose player screen
+ local snpin = appletManager:loadApplet("SqueezeNetworkPIN")
+ snpin:enterPin(nil, player)
+
+ return false
+ end
+
+ -- set the current player
local manager = AppletManager:getAppletInstance("SlimDiscovery")
if manager then
manager:setCurrentPlayer(player)
Modified: branches/7.0/jive/src/pkg/jive/share/applets/SelectPlayer/strings.txt
URL:
http://svn.slimdevices.com/branches/7.0/jive/src/pkg/jive/share/applets/SelectPlayer/strings.txt?rev=1714&root=Jive&r1=1713&r2=1714&view=diff
==============================================================================
--- branches/7.0/jive/src/pkg/jive/share/applets/SelectPlayer/strings.txt
(original)
+++ branches/7.0/jive/src/pkg/jive/share/applets/SelectPlayer/strings.txt Thu
Jan 31 03:50:05 2008
@@ -26,3 +26,11 @@
IT Squeezebox %s
NL Squeezebox %s
+SQUEEZEBOX_ACTIVATE
+ DE %s
+ EN Activate %s
+ ES %s
+ FR %s
+ IT %s
+ NL %s
+
Modified:
branches/7.0/jive/src/pkg/jive/share/applets/SqueezeNetworkPIN/SqueezeNetworkPINApplet.lua
URL:
http://svn.slimdevices.com/branches/7.0/jive/src/pkg/jive/share/applets/SqueezeNetworkPIN/SqueezeNetworkPINApplet.lua?rev=1714&root=Jive&r1=1713&r2=1714&view=diff
==============================================================================
---
branches/7.0/jive/src/pkg/jive/share/applets/SqueezeNetworkPIN/SqueezeNetworkPINApplet.lua
(original)
+++
branches/7.0/jive/src/pkg/jive/share/applets/SqueezeNetworkPIN/SqueezeNetworkPINApplet.lua
Thu Jan 31 03:50:05 2008
@@ -28,50 +28,60 @@
module(...)
oo.class(_M, Applet)
+
+function enterPin(self, server, player, next)
+ self:_enterPin(false, server, player, next)
+end
+
+
function forcePin(self, player)
+ self:_enterPin(false, player:getSlimServer(), player)
+end
+
+
+function _enterPin(self, force, server, player, next)
local window = Window("window",
self:string("SQUEEZENETWORK_PIN_TITLE"), "settingstitle")
window:setAllowScreensaver(false)
local menu = SimpleMenu("menu")
- menu:setCloseable(false)
+ if force then
+ menu:setCloseable(false)
+ end
+
+ self.pin = player and player:getPin() or server:getPin()
+
+ if not server then
+ server = player:getSlimServer()
+ end
- local slimServer = player.slimServer
+ local nextfunc = function()
+ -- Always close the pin entry window
+ window:hide()
+ if next then
+ next()
+ end
+ end
menu:addItem( {
- text = self:string( "SQUEEZENETWORK_PIN", player:getPin() ),
+ text = self:string( "SQUEEZENETWORK_PIN", self.pin ),
sound = "WINDOWSHOW",
callback = function()
- -- When the user clicks the button, ask SN if we're
registered
- local uuid, mac = jnt:getUUID()
- local cmd = { 'islinked', uuid }
-
- local checkLinkedSink = function(chunk, err)
- if err then
- log:warn(err)
- return
- end
-
- if chunk.data.islinked and chunk.data.islinked
== 1 then
- -- Jive is linked!
- log:debug("checkLinkedSink: Jive is
linked")
-
- -- Reconnect to SN, refreshes the list
of players
- slimServer:reconnect()
-
- -- close pin menu, back to main
- -- XXX: Not sure if this should so
something more...
- menu:hide()
- else
- log:debug("checkLinkedSink: Jive is not
linked yet")
-
- -- display error
- self:displayNotLinked()
- end
- end
-
- slimServer.comet:request( checkLinkedSink, nil, cmd )
+ self:_checkLinked(server,
+ nextfunc,
+ function()
+ self:displayNotLinked()
+ end)
end
} )
+
+ -- automatically check if we are linked every 5 seconds
+ -- XXX check this is ok with Andy and Dean...
+ menu:addTimer(5000,
+ function()
+ self:_checkLinked(server,
+ nextfunc,
+ nil)
+ end)
-- XXX this is temporary until the :3000 "production" beta goes away by
-- some means or other
@@ -80,13 +90,55 @@
addport = ":3000"
end
- local help = Textarea("help", self:string("SQUEEZENETWORK_PIN_HELP",
jnt:getSNHostname() .. addport))
- window:addWidget(help)
+ window:addWidget(Textarea("help",
self:string("SQUEEZENETWORK_PIN_HELP", jnt:getSNHostname() .. addport)))
window:addWidget(menu)
self:tieAndShowWindow(window)
return window
end
+
+
+function _checkLinked(self, server, next, fail)
+ -- When the user clicks the button, ask SN if we're registered
+ local uuid, mac = jnt:getUUID()
+ local cmd = { 'islinked', uuid }
+
+ local checkLinkedSink = function(chunk, err)
+ if err then
+ log:warn(err)
+ return
+ end
+
+ if chunk.data.islinked and chunk.data.islinked == 1 then
+
+ -- Jive is linked!
+ log:debug("checkLinkedSink: Jive is linked")
+
+ -- The pin will be cleared on the next serverstatus,
+ -- but this is not instant, so clear the pin now
+ server:linked(self.pin)
+
+ -- Reconnect to SN, refreshes the list of players
+ server:reconnect()
+
+ if next then
+ next()
+ end
+ else
+ log:debug("checkLinkedSink: Jive is not linked yet")
+
+ if fail then
+ fail()
+ end
+ end
+ end
+
+ -- make sure the server is connected
+ server.comet:connect()
+
+ server.comet:request( checkLinkedSink, nil, cmd )
+end
+
function displayNotLinked(self)
local window = Window("window",
self:string("SQUEEZENETWORK_PIN_TITLE"), "settingstitle")
Modified: branches/7.0/jive/src/pkg/jive/share/jive/AppletManager.lua
URL:
http://svn.slimdevices.com/branches/7.0/jive/src/pkg/jive/share/jive/AppletManager.lua?rev=1714&root=Jive&r1=1713&r2=1714&view=diff
==============================================================================
--- branches/7.0/jive/src/pkg/jive/share/jive/AppletManager.lua (original)
+++ branches/7.0/jive/src/pkg/jive/share/jive/AppletManager.lua Thu Jan 31
03:50:05 2008
@@ -28,6 +28,7 @@
local io = require("io")
local lfs = require("lfs")
+local debug = require("jive.utils.debug")
local log = require("jive.utils.log").logger("applets.misc")
local locale = require("jive.utils.locale")
local serialize = require("jive.utils.serialize")
Modified: branches/7.0/jive/src/pkg/jive/share/jive/net/Comet.lua
URL:
http://svn.slimdevices.com/branches/7.0/jive/src/pkg/jive/share/jive/net/Comet.lua?rev=1714&root=Jive&r1=1713&r2=1714&view=diff
==============================================================================
--- branches/7.0/jive/src/pkg/jive/share/jive/net/Comet.lua (original)
+++ branches/7.0/jive/src/pkg/jive/share/jive/net/Comet.lua Thu Jan 31 03:50:05
2008
@@ -36,7 +36,7 @@
comet:removeCallback('/slim/serverstatus', func)
-- start!
- comet:start()
+ comet:connect()
-- disconnect
comet:disconnect()
Modified: branches/7.0/jive/src/pkg/jive/share/jive/slim/SlimServer.lua
URL:
http://svn.slimdevices.com/branches/7.0/jive/src/pkg/jive/share/jive/slim/SlimServer.lua?rev=1714&root=Jive&r1=1713&r2=1714&view=diff
==============================================================================
--- branches/7.0/jive/src/pkg/jive/share/jive/slim/SlimServer.lua (original)
+++ branches/7.0/jive/src/pkg/jive/share/jive/slim/SlimServer.lua Thu Jan 31
03:50:05 2008
@@ -131,11 +131,17 @@
for k,v in pairs(self.players) do
selfPlayers[k] = k
end
+
+ self.pin = nil
if tonumber(data["player count"]) > 0 then
for i, player_info in ipairs(serverPlayers) do
-
+
+ if player_info.pin then
+ self.pin = player_info.pin
+ end
+
-- remove the player from our list since it is reported
by the server
selfPlayers[player_info.playerid] = nil
@@ -280,6 +286,40 @@
return self.name == "SqueezeNetwork Beta"
else
return self.name == "SqueezeNetwork"
+ end
+end
+
+
+--[[
+
+=head2 jive.slim.SlimServer:getPin()
+
+Returns the PIN for SqueezeNetwork, if it needs to be registered
+
+=cut
+--]]
+function getPin(self)
+ return self.pin
+end
+
+
+--[[
+
+=head2 jive.slim.SlimServer:linked(pin)
+
+Called once the server or player are linked on SqueezeNetwork.
+
+=cut
+--]]
+function linked(self, pin)
+ if self.pin == pin then
+ self.pin = nil
+ end
+
+ for id, player in pairs(self.players) do
+ if player.pin == pin then
+ player.pin = nil
+ end
end
end
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins