diff Modules/FailSafe.lua @ 31:90d58723ac0a

- Removed all BeanCounter checks in files. + Added a new module: BeanCounter Support. This module will now take care of preventing mail opening while BeanCounter is scanning. + Added AceHook library for the BeanCounter Support module. ~ Sorted the Core.lua OnInitialize to properly toggle modules before doing time consuming things. ~ All module comments are now a property of the modules themselves and can be retrieved with (string)?.moduleDescription? and (bool)?.moduleRequired?. ~ All module references are now called ?mod?. ! Added a new config group: Modules. This group will show the module statuses and descriptions and it will contain all optional modules (with their settings) as subgroups. - Removed all libraries from the repository.
author Zerotorescue
date Fri, 10 Sep 2010 18:59:58 +0200
parents fb952805d8b7
children 2b2bea9c7446
line wrap: on
line diff
--- a/Modules/FailSafe.lua	Thu Sep 09 22:16:50 2010 +0200
+++ b/Modules/FailSafe.lua	Fri Sep 10 18:59:58 2010 +0200
@@ -1,13 +1,10 @@
 local MailOpener = LibStub("AceAddon-3.0"):GetAddon("MailOpener");
-local FailSafe = MailOpener:NewModule("FailSafe", "AceEvent-3.0", "AceTimer-3.0");
+local mod = MailOpener:NewModule("FailSafe", "AceEvent-3.0", "AceTimer-3.0");
 
---[[
-Module name:	FailSafe
-Description:	Prevents the mail opening from stopping when the execution of a single mail opening function fails (e.g. because of mail functions throttling).
-Required:		No.
-]]
+mod.moduleDescription = "Prevents the mail opening from completely stopping when the opening of a single mail gets stuck.";
+mod.moduleRequired = false;
 
-function FailSafe:OnInitialize()
+function mod:OnInitialize()
 	local defaults = {
 		profile = {
 			timeout = 20,
@@ -18,14 +15,19 @@
 	self.db = MailOpener.db:RegisterNamespace("FailSafe", defaults);
 end
 
-function FailSafe:OnEnable()
+function mod:OnEnable()
 	self:Debug("OnEnable");
 	
 	self:RegisterEvent("MAIL_SHOW");
+	
+	-- If we were toggling this module on while the mailbox is opened we must register all events again
+	if MailFrame:IsVisible() then
+		self:MAIL_SHOW();
+	end
 end
 
 -- Even though Ace can unregister our events it's neater to do it manually too
-function FailSafe:OnDisable()
+function mod:OnDisable()
 	self:Debug("OnDisable");
 	
 	self:UnregisterEvent("MAIL_SHOW");
@@ -33,7 +35,7 @@
 	self:Stop();
 end
 
-function FailSafe:MAIL_SHOW()
+function mod:MAIL_SHOW()
 	self:Debug("MAIL_SHOW");
 	
 	self:RegisterEvent("MAIL_CLOSED");
@@ -42,7 +44,7 @@
 	self:RegisterMessage("MO_MAIL_EMPTIED");
 end
 
-function FailSafe:MAIL_CLOSED()
+function mod:MAIL_CLOSED()
 	self:Debug("MAIL_CLOSED");
 	
 	self:UnregisterEvent("MAIL_CLOSED");
@@ -53,29 +55,29 @@
 	self:CancelTimer(self.tmrTimeout, true);
 end
 
-function FailSafe:MO_OPENING_MAIL()
+function mod:MO_OPENING_MAIL()
 	-- Single mail being opened
 	
 	self:CancelTimer(self.tmrTimeout, true); -- insurance
 	self.tmrTimeout = self:ScheduleTimer("Continue", self.db.profile.timeout);
 end
 
-function FailSafe:MO_MAIL_EMPTIED()
+function mod:MO_MAIL_EMPTIED()
 	-- Single mail has been opened
 	
 	self:CancelTimer(self.tmrTimeout, true);
 end
 
-function FailSafe:Continue()
+function mod:Continue()
 	MailOpener:GetModule("OpenAll"):Continue();
 	
 	print("|cff15ff00Mail Opener|r (FailSafe): Mail opening timeout, continueing with the next mail.");
 end
 
-function FailSafe:GetOptionsGroup()
+function mod:GetOptionsGroup()
 	local configGroup = {
-		order = 450,
-		type = "group",
+		order = 0,
+		type = "modulesSubGroup",
 		name = "FailSafe",
 		desc = "Change settings for the FailSafe module.",
 		args = {
@@ -89,13 +91,15 @@
 						order = 10,
 						type = "description",
 						name = function()
-							local default = "With this button you can completely toggle this module |cff00ff00on|r or |cffff0000off|r. This setting will be remembered and the module will be automatically toggled |cff00ff00on|r or |cffff0000off|r upon logon as it was last set.\n\n";
+							local descText = "With this button you can completely toggle this module |cff00ff00on|r or |cffff0000off|r. This setting will be remembered and the module will be automatically toggled |cff00ff00on|r or |cffff0000off|r upon logon as it was last set.\n\n";
 							
 							if self:IsEnabled() then
-								return default .. "Status: |cff00ff00Enabled|r";
+								descText = descText .. "Status: |cff00ff00Enabled|r";
 							else
-								return default .. "Status: |cffff0000Disabled|r";
+								descText = descText .. "Status: |cffff0000Disabled|r";
 							end
+							
+							return descText;
 						end,
 					},
 					disable = {
@@ -155,6 +159,6 @@
 	return configGroup;
 end
 
-function FailSafe:Debug(t)
+function mod:Debug(t)
 	return MailOpener:Debug("|cffff0000FailSafe|r:" .. t);
 end
\ No newline at end of file