
function ExeCommand(cmd, param)
    local addinManager = XLGetObject("Xunlei.Thunder.AddinManager")
	addinManager:LoadAddinMainDll("VipService")
	
	local OfflinePanelInstance =  XLGetGlobal("offlinepanel.globalfunction")
	if OfflinePanelInstance == nil then
		return
	end
	
	if cmd == "CreateOfflineTask" then			--展示PreNewTaskDlg
		OfflinePanelInstance.CreateOfflineTask()
		
	elseif cmd == "ShowNewOfflineDlg" then		--创建电驴或p2sp任务，param = url
		OfflinePanelInstance.ShowNewOfflineDlg(param)
		
	elseif cmd == "CreateBTOfflineTask" then	--创建BT任务，param = 带本地路径
		OfflinePanelInstance.CreateBTOfflineTask(param)
	
	elseif cmd == "CommitSuperSpeedTask" then	--创建高速任务,param = table ( table[1] = taskid_1,table[2] = taskid_2 ...)
		XLGetGlobal("VipService.globalfunction").AsycCommitSuperSpeed(param)
	end
end

--异步加载插件
function LoadVipService()
	local function OnAysnLoadXAR(name, _type)
		local xarMgr = XLGetObject("Xunlei.UIEngine.XARManager")
		local objFactory = xarMgr:GetXARFactory()
	
		local uiCtrlProvider = XLGetGlobal("xunlei.UIControlProvider")
		local bkg = uiCtrlProvider:GetMainWndBkg()

		local VipServiceEntry = objFactory:CreateUIObject("VipService.Entry.ID", "VipService.Entry")
		VipServiceEntry:SetObjPos(0,0,0,0)
		bkg:AddChild(VipServiceEntry)
		
		LoadAutoSkin()
	end

	local theManager = XLGetObject("Xunlei.UIEngine.XARManager")
	theManager:AsynLoadXAR("VipService",OnAysnLoadXAR)
	theManager:AsynLoadXAR("OfflinePanel",nil)
end

function LoadAutoSkin()
	local skinHelp = XLGetGlobal("xunlei.LuaSkinHelper")
	local PathTool = XLGetObject("Xunlei.Thunder.Path")
	if skinHelp and PathTool then
		userPath = PathTool:GetAddinsPath()
		local xmlFilePath = userPath.."VipService\\XAR\\OfflinePanel\\skin.xml"
		skinHelp:InsertAddinColorScheme("OfflinePanel", xmlFilePath)
	end
end

--加载“我的下载”事件
function OnConnectMyDownLoad()
	LoadVipService()
end

function OnConnect()
	local addin_helper = XLGetGlobal( "xunlei.AddinManagerHelper")

	if addin_helper.IsMyDownloadLoad() then
		OnConnectMyDownLoad()
	else
		addin_helper.AttachMyDownloadLoadEvent(OnConnectMyDownLoad)
	end
end

function PostQuit(quitcode)
end



