Quantcast

* Updated to Dongle-r849

James Whitehead II [05-20-07 - 14:17]
* Updated to Dongle-r849
Filename
Dongle.lua
PerfectRaid.lua
diff --git a/Dongle.lua b/Dongle.lua
index 1a76e32..dbf5e11 100644
--- a/Dongle.lua
+++ b/Dongle.lua
@@ -155,9 +155,13 @@ end
 ---------------------------------------------------------------------------]]

 local major = "Dongle-1.0"
-local minor = tonumber(string.match("$Revision: 317 $", "(%d+)") or 1)
+local minor = tonumber(string.match("$Revision: 349 $", "(%d+)") or 1) + 500
+-- ** IMPORTANT NOTE **
+-- Due to some issues we had previously with Dongle revision numbers
+-- we need to artificially inflate the minor revision number, to ensure
+-- we load sequentially.

-assert(DongleStub, string.format("Dongle requires DongleStub.", major))
+assert(DongleStub, string.format("%s requires DongleStub.", major))

 if not DongleStub:IsNewerVersion(major, minor) then return end

@@ -183,7 +187,7 @@ local messages = {}
 local frame

 --[[-------------------------------------------------------------------------
-  Message Localization
+	Message Localization
 ---------------------------------------------------------------------------]]

 local L = {
@@ -191,7 +195,7 @@ local L = {
 	["ALREADY_REGISTERED"] = "A Dongle with the name '%s' is already registered.",
 	["BAD_ARGUMENT"] = "bad argument #%d to '%s' (%s expected, got %s)",
 	["BAD_ARGUMENT_DB"] = "bad argument #%d to '%s' (DongleDB expected)",
-	["CANNOT_DELETE_ACTIVE_PROFILE"] = "You cannot delete your active profile.  Change profiles, then attempt to delete.",
+	["CANNOT_DELETE_ACTIVE_PROFILE"] = "You cannot delete your active profile. Change profiles, then attempt to delete.",
 	["DELETE_NONEXISTANT_PROFILE"] = "You cannot delete a non-existant profile.",
 	["MUST_CALLFROM_DBOBJECT"] = "You must call '%s' from a Dongle database object.",
 	["MUST_CALLFROM_REGISTERED"] = "You must call '%s' from a registered Dongle.",
@@ -199,7 +203,7 @@ local L = {
 	["PROFILE_DOES_NOT_EXIST"] = "Profile '%s' doesn't exist.",
 	["REPLACE_DEFAULTS"] = "You are attempting to register defaults with a database that already contains defaults.",
 	["SAME_SOURCE_DEST"] = "Source/Destination profile cannot be the same profile.",
-	["EVENT_REGISTER_SPECIAL"] = "You cannot register for the '%s' event.  Use the '%s' method instead.",
+	["EVENT_REGISTER_SPECIAL"] = "You cannot register for the '%s' event. Use the '%s' method instead.",
 	["Unknown"] = "Unknown",
 	["INJECTDB_USAGE"] = "Usage: DongleCmd:InjectDBCommands(db, ['copy', 'delete', 'list', 'reset', 'set'])",
 	["DBSLASH_PROFILE_COPY_DESC"] = "profile copy <name> - Copies profile <name> into your current profile.",
@@ -216,7 +220,7 @@ local L = {
 }

 --[[-------------------------------------------------------------------------
-  Utility functions for Dongle use
+	Utility functions for Dongle use
 ---------------------------------------------------------------------------]]

 local function assert(level,condition,message)
@@ -247,7 +251,7 @@ local function safecall(func,...)
 end

 --[[-------------------------------------------------------------------------
-  Dongle constructor, and DongleModule system
+	Dongle constructor, and DongleModule system
 ---------------------------------------------------------------------------]]

 function Dongle:New(name, obj)
@@ -297,7 +301,7 @@ function Dongle:HasModule(module)
 	assert(3, reg, string.format(L["MUST_CALLFROM_REGISTERED"], "HasModule"))
 	argcheck(module, 2, "string", "table")

-	return reg.modules[module]
+	return reg.modules and reg.modules[module]
 end

 local function ModuleIterator(t, name)
@@ -318,7 +322,7 @@ function Dongle:IterateModules()
 end

 --[[-------------------------------------------------------------------------
-  Event registration system
+	Event registration system
 ---------------------------------------------------------------------------]]

 local function OnEvent(frame, event, ...)
@@ -400,7 +404,7 @@ function Dongle:IsEventRegistered(event)
 end

 --[[-------------------------------------------------------------------------
-  Inter-Addon Messaging System
+	Inter-Addon Messaging System
 ---------------------------------------------------------------------------]]

 function Dongle:RegisterMessage(msg, func)
@@ -467,7 +471,7 @@ function Dongle:IsMessageRegistered(msg)
 end

 --[[-------------------------------------------------------------------------
-  Debug and Print utility functions
+	Debug and Print utility functions
 ---------------------------------------------------------------------------]]

 function Dongle:EnableDebug(level, frame)
@@ -583,12 +587,12 @@ function Dongle:DebugF(level, ...)
 end

 --[[-------------------------------------------------------------------------
-  Database System
+	Database System
 ---------------------------------------------------------------------------]]

 local dbMethods = {
 	"RegisterDefaults", "SetProfile", "GetProfiles", "DeleteProfile", "CopyProfile",
-	"ResetProfile", "ResetDB",
+	"GetCurrentProfile", "ResetProfile", "ResetDB",
 	"RegisterNamespace",
 }

@@ -892,6 +896,11 @@ function Dongle.GetProfiles(db, t)
 	return t, i - 1
 end

+function Dongle.GetCurrentProfile(db)
+	assert(e, databases[db], string.format(L["MUST_CALLFROM_DBOBJECT"], "GetCurrentProfile"))
+	return db.keys.profile
+end
+
 function Dongle.DeleteProfile(db, name)
 	assert(3, databases[db], string.format(L["MUST_CALLFROM_DBOBJECT"], "DeleteProfile"))
 	argcheck(name, 2, "string")
@@ -939,7 +948,7 @@ end

 function Dongle.ResetDB(db, defaultProfile)
 	assert(3, databases[db], string.format(L["MUST_CALLFROM_DBOBJECT"], "ResetDB"))
-    argcheck(defaultProfile, 2, "nil", "string")
+		argcheck(defaultProfile, 2, "nil", "string")

 	local sv = db.sv
 	for k,v in pairs(sv) do
@@ -956,7 +965,7 @@ end

 function Dongle.RegisterNamespace(db, name, defaults)
 	assert(3, databases[db], string.format(L["MUST_CALLFROM_DBOBJECT"], "RegisterNamespace"))
-    argcheck(name, 2, "string")
+		argcheck(name, 2, "string")
 	argcheck(defaults, 3, "nil", "string")

 	local sv = db.sv
@@ -975,7 +984,7 @@ function Dongle.RegisterNamespace(db, name, defaults)
 end

 --[[-------------------------------------------------------------------------
-  Slash Command System
+	Slash Command System
 ---------------------------------------------------------------------------]]

 local slashCmdMethods = {
@@ -1124,7 +1133,7 @@ function Dongle.InjectDBCommands(cmd, db, ...)
 end

 --[[-------------------------------------------------------------------------
-  Internal Message/Event Handlers
+	Internal Message/Event Handlers
 ---------------------------------------------------------------------------]]

 local function PLAYER_LOGOUT(event)
@@ -1197,7 +1206,7 @@ local function DONGLE_PROFILE_CHANGED(msg, db, parent, sv_name, profileKey)
 end

 --[[-------------------------------------------------------------------------
-  DongleStub required functions and registration
+	DongleStub required functions and registration
 ---------------------------------------------------------------------------]]

 function Dongle:GetVersion() return major,minor end
@@ -1213,8 +1222,6 @@ local function Activate(self, old)
 		commands = old.commands or commands
 		messages = old.messages or messages
 		frame = old.frame or CreateFrame("Frame")
-
-		registry[major].obj = self
 	else
 		frame = CreateFrame("Frame")
 		local reg = {obj = self, name = "Dongle"}
@@ -1233,17 +1240,15 @@ local function Activate(self, old)
 	self.messages = messages
 	self.frame = frame

-	local reg = self.registry[major]
-	lookup[self] = reg
-	lookup[major] = reg
-
 	frame:SetScript("OnEvent", OnEvent)

+	local lib = old or self
+
 	-- Register for events using Dongle itself
-	self:RegisterEvent("ADDON_LOADED", ADDON_LOADED)
-	self:RegisterEvent("PLAYER_LOGIN", PLAYER_LOGIN)
-	self:RegisterEvent("PLAYER_LOGOUT", PLAYER_LOGOUT)
-	self:RegisterMessage("DONGLE_PROFILE_CHANGED", DONGLE_PROFILE_CHANGED)
+	lib:RegisterEvent("ADDON_LOADED", ADDON_LOADED)
+	lib:RegisterEvent("PLAYER_LOGIN", PLAYER_LOGIN)
+	lib:RegisterEvent("PLAYER_LOGOUT", PLAYER_LOGOUT)
+	lib:RegisterMessage("DONGLE_PROFILE_CHANGED", DONGLE_PROFILE_CHANGED)

 	-- Convert all the modules handles
 	for name,obj in pairs(registry) do
@@ -1267,9 +1272,4 @@ local function Activate(self, old)
 	end
 end

-local function Deactivate(self, new)
-	self:UnregisterAllEvents()
-	lookup[self] = nil
-end
-
-Dongle = DongleStub:Register(Dongle, Activate, Deactivate)
+Dongle = DongleStub:Register(Dongle, Activate)
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index bff3f1e..f01c8f9 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -80,7 +80,12 @@ function PerfectRaid:Initialize()
 			if PerfectRaidDB.global.sv_converted then
 				PerfectRaidDB.global.sv_converted = nil
 				PerfectRaidDB.global.sv_version = self.rev
-			elseif PerfectRaidDB.global.sv_version < 693 then
+			elseif PerfectRaidDB.global.sv_version > self.rev then
+				-- Got the bad rev number, revert
+				PerfectRaidDB.global.sv_version = self.rev
+			elseif PerfectRaidDB.global.sv_version < 112 then
+				-- We do this once, to make sure we catch everyone from
+				-- the last version of PerfectRaid
 				self:Print("You're upgrading from an old version of PerfectRaid")
 				PerfectRaidDB = {}
 				self:Print("All settings have been set to default")