
--[[
=head1 NAME

applets.JogglerRegistration.JogglerRegistrationApplet

=head1 DESCRIPTION

Registration applet for mysqueezebox.com for the Joggler.

=cut
--]]


-- stuff we use
local setmetatable, tonumber, tostring = setmetatable, tonumber, tostring

local os                     = require("os")
local io                     = require("io")
local oo                     = require("loop.simple")
local math                   = require("math")
local string                 = require("string")
local table                  = require("jive.utils.table")
local debug                  = require("jive.utils.debug")

local Applet                 = require("jive.Applet")
local System                 = require("jive.System")
local Checkbox               = require("jive.ui.Checkbox")
local Choice                 = require("jive.ui.Choice")
local Framework              = require("jive.ui.Framework")
local Event                  = require("jive.ui.Event")
local Icon                   = require("jive.ui.Icon")
local Label                  = require("jive.ui.Label")
local Button                 = require("jive.ui.Button")
local Popup                  = require("jive.ui.Popup")
local Group                  = require("jive.ui.Group")
local RadioButton            = require("jive.ui.RadioButton")
local RadioGroup             = require("jive.ui.RadioGroup")
local SimpleMenu             = require("jive.ui.SimpleMenu")
local Slider                 = require("jive.ui.Slider")
local Surface                = require("jive.ui.Surface")
local Textarea               = require("jive.ui.Textarea")
local Textinput              = require("jive.ui.Textinput")
local Window                 = require("jive.ui.Window")
local ContextMenuWindow      = require("jive.ui.ContextMenuWindow")
local Keyboard               = require("jive.ui.Keyboard")

local appletManager = appletManager


module(..., Framework.constants)
oo.class(_M, Applet)


function menu(self, menuItem)

	log:info("menu")

	local group = RadioGroup()

	headermsg = Textarea("help_text", self:string("REGHELP"))

	local menu = SimpleMenu("menu",
		{
			{ text = self:string("MYSQBREG"),
				sound = "WINDOWSHOW",
				callback = function(event, menuItem)
					appletManager:callService("squeezeNetworkRequest", { 'register', 0, 100, 'service:SN' })
				end
			},
			{ text = self:string("MYSQBRESET"),
			    style = 'item_choice',
				sound = "WINDOWSHOW",
				callback = function(event, menuItem)
					appletManager:callService("squeezeNetworkRequest", { 'playerReset', 0, 100, 'service:SN' })
				end
			},
			{ text = self:string("ALLRESET"),
			    style = 'item_choice',
				sound = "WINDOWSHOW",
				callback = function(event, menuItem)
					os.execute("sleep 2; rm -rf ~/.squeezeplay")
					Framework:quit()
				end
			},
		})

	local window = Window("text_list", menuItem.text, "SQBREG")
	window:addWidget(menu)
	menu:setHeaderWidget(headermsg)
	self:tieAndShowWindow(window)
	return window
end


--[[

=head1 LICENSE

This source code is public domain. It is intended for you to use as a starting
point to create your own applet.

=cut
--]]

