local function InstallTdAtOnce()
	local theShell= XLGetObject("Xunlei.Thunder.Shell")
	--判断TDAtOnce是否存在
	local thunderDir = theShell:GetThunderInstallDir()
	local tdAtOncePath = thunderDir.."\\ComDlls\\TDAtOnce_Now.dll"
	if theShell:QueryFileExists(tdAtOncePath) then
		XLOutputString("tdatonce already install")
	else
		--需要安装
		XLOutputString("Start install TDAtOnce")
		local function OnTdAtOnceDownloadFinish(strName,nStatus)
			if strName ~= "TdAtOnce" then
				return true
			else
				if nStatus == 4 then
					--安装
					local tdAtOnceInstallPath = thunderDir.."\\ComDlls\\TDAtOnce.dll"
					theShell:RegisterCOM(tdAtOnceInstallPath)
					return false
				end
				
			end
			return true
		end
		
		local theDownloadMgr = XLGetObject("Xunlei.Thunder.ModuleDownloadMgr")	
		theDownloadMgr:AttachEventFinish(OnTdAtOnceDownloadFinish,true)
		theDownloadMgr:AddModule("TdAtOnce",thunderDir,100,"",0)
		theDownloadMgr:BeginDownload("TdAtOnce")
	end

end

--[[
local function InstallKankanReal()
	local theShell= XLGetObject("Xunlei.Thunder.Shell")
	--判断RealMediaSplitter.ax是否存在
	local thunderDir = theShell:GetThunderInstallDir()
	local rmSplitterPath = thunderDir.."\\Components\\Kankan\\Codecs\\RealMediaSplitter.ax"
	if theShell:QueryFileExists(rmSplitterPath) then
		XLOutputString("RealMediaSplitter.ax already install")
	else
		--需要安装
		XLOutputString("Start install KankanReal")
		local function OnKankanRealDownloadFinish(strName,nStatus)
			if strName ~= "KankanReal" then
				return true
			else
				if nStatus == 4 then
					--安装
					local kankanRealInstallPath = thunderDir.."\\Components\\Kankan\\Codecs\\RealMediaSplitter.ax"
					theShell:RegisterCOM(kankanRealInstallPath)
					local dapFireFoxInstallPath = thunderDir.."\\Components\\Kankan\\npDapCtrlFirefox.dll"
					theShell:RegisterCOM(dapFireFoxInstallPath)
					local tsfInstallPath = thunderDir.."\\Components\\Kankan\\TSF.dll"
					theShell:RegisterCOM(tsfInstallPath)
					return false
				end
			end
			return true
		end
		
		local theDownloadMgr = XLGetObject("Xunlei.Thunder.ModuleDownloadMgr")	
		theDownloadMgr:AttachEventFinish(OnKankanRealDownloadFinish,true)
		theDownloadMgr:AddModule("KankanReal",thunderDir,100,"",0)
		theDownloadMgr:BeginDownload("KankanReal")
	end

end
]]

local function InstallFTPExplorer()
end


local function onInstallTimer (timerID)
	InstallTdAtOnce()
	InstallFTPExplorer()
--	InstallKankanReal()
	return false
end

local theTimerObj = XLGetObject("Xunlei.Thunder.Timer")
theTimerObj:AddTimer(onInstallTimer,30000,false)

