Update LibVersionCheck to 0.03

Mere [06-30-13 - 10:35]
Update LibVersionCheck to 0.03
Filename
Libs/LibVersionCheck/RiftAddon.toc
Libs/LibVersionCheck/main.lua
diff --git a/Libs/LibVersionCheck/RiftAddon.toc b/Libs/LibVersionCheck/RiftAddon.toc
index f600c86..87867a3 100644
--- a/Libs/LibVersionCheck/RiftAddon.toc
+++ b/Libs/LibVersionCheck/RiftAddon.toc
@@ -9,10 +9,11 @@ Description = {
 }

 Email = "blohm@s.netic.de"
-Version = "0.02"
+Version = "0.03"
 Environment = "2.2"
 SavedVariables = {
    LibVersionCheckVersions = "global",
+   LibVersionCheckSpy      = "global",
    LibVersionCheckSettings = "account",
 }

diff --git a/Libs/LibVersionCheck/main.lua b/Libs/LibVersionCheck/main.lua
index c8ef73d..0304b29 100644
--- a/Libs/LibVersionCheck/main.lua
+++ b/Libs/LibVersionCheck/main.lua
@@ -1,5 +1,6 @@
 local AddonData, privateTable = ...

+
 if LibVersionCheck then
 	return
 end
@@ -23,6 +24,9 @@ end

 local TempLibVersionCheckVersions
 local function varsLoaded(handle, identifier)
+	if not LibVersionCheckSpy then
+		LibVersionCheckSpy={}
+	end
 	if not LibVersionCheckSettings then
 		LibVersionCheckSettings={}
 	end
@@ -57,19 +61,15 @@ local function unitAvailable(handle, units)
 	local now=Inspect.Time.Server()
 	local k,v
 	for k,v in pairs(units) do
-		if k ~= nil and type(k) == "string" then
+		if k ~= nil and type(k) == "string" and k ~= player.id and not didQuery[k] then
 			local unit = Inspect.Unit.Detail(k)
 			if unit and unit.availability
 			and unit.availability=="full"
 			and unit.player==true
 			then
-				unitname=unit.name
-				if unitname ~= player.name
-				and didQuery[unitname]==nil then
-					didQuery[unitname]=now
-					if debugMode then print("querying "..unitname) end
-					Command.Message.Send(unitname, "LibVersionCheck", "query", ignoreme)
-				end
+				didQuery[k]=now
+				if debugMode then print("querying "..unit.name) end
+				Command.Message.Send(unit.name, "LibVersionCheck", "query", ignoreme)
 			end
 		end
 	end
@@ -98,15 +98,17 @@ local function gotMessage(handle, from, type, channel, identifier, data)
 		if debugMode then
 			print("Got Query from "..from)
 		end
-		for k, v in pairs(LibVersionCheckVersions) do
-			if v.myVersion and v.myVersion ~= 0 then
-				table.insert(sendToList, { from, k })
+		if not LibVersionCheckSettings.developer then
+			for k, v in pairs(LibVersionCheckVersions) do
+				if v.myVersion and v.myVersion ~= 0 and v.myVersion ~= "0" then
+					table.insert(sendToList, { from, k })
+				end
 			end
 		end
 	end

 	if data:len()>=7 and data:sub(1,7) == "version" then
-		if debugMode then print("got version info: "..data.." from "..unitname) end
+		if debugMode then print("got version info: "..data.." from "..from) end
 		local token
 		local tnum=1
 		local parms={}
@@ -124,6 +126,12 @@ local function gotMessage(handle, from, type, channel, identifier, data)
 			       LibVersionCheckVersions[parms[2]].newestVersion = parms[3]
 			       LibVersionCheckVersions[parms[2]].sender = from
 			end
+			if LibVersionCheckSettings.spymode then
+				if not LibVersionCheckSpy then LibVersionCheckSpy={} end
+				if not LibVersionCheckSpy[from] then LibVersionCheckSpy[from]={} end
+				LibVersionCheckSpy[from][parms[2]]=parms[3]
+				LibVersionCheckSpy[from][parms[2].."_date"]=Inspect.Time.Server()
+			end
 		end
 	end
 end
@@ -135,9 +143,9 @@ end

 local function systemUpdate(handle)

-	local now=Inspect.Time.Real()
 	if #sendToList<1 then return end

+	local now=Inspect.Time.Real()
 	if now < lastSendProcessed+0.1 then return end
 	lastSendProcessed=now

@@ -151,7 +159,7 @@ end


 local function allAddonsLoaded(handle)
-	anythingToShow=false
+	local anythingToShow=false
 	for k, v in pairs(LibVersionCheckVersions) do
 		if v.myVersion and v.newestVersion
 		and ""..v.myVersion ~= "0"
@@ -214,6 +222,18 @@ local function slashHandler(h, args)
 			print("libVersionCheck now debugging");
 		elseif (r[1] == "reset") then
 			didQuery={}
+		elseif (r[1] == "spy" and numargs>2 and r[2] == "on") then
+			LibVersionCheckSettings.spymode = true
+			print("Spy mode enabled")
+		elseif (r[1] == "spy") then
+			LibVersionCheckSettings.spymode = false
+			print("Spy mode disabled")
+		elseif (r[1] == "developer" and numargs>2 and r[2] == "on") then
+			LibVersionCheckSettings.developer = true
+			print("Developer mode enabled")
+		elseif (r[1] == "developer") then
+			LibVersionCheckSettings.developer = false
+			print("Developer mode disabled")
 		else
 			print(L("Usage") .. ": /LibVersionCheck list | debug | query <name>")
 		end
@@ -222,8 +242,6 @@ local function slashHandler(h, args)
 	end
 end

-
-
 -- This is the only function other addons will ever need to know about.

 function LibVersionCheck.register(addonName, addonVersion)