Mercurial > wow > mailopener
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 30:4ab03ed958ed | 31:90d58723ac0a |
|---|---|
| 1 local MailOpener = LibStub("AceAddon-3.0"):GetAddon("MailOpener"); | 1 local MailOpener = LibStub("AceAddon-3.0"):GetAddon("MailOpener"); |
| 2 local FailSafe = MailOpener:NewModule("FailSafe", "AceEvent-3.0", "AceTimer-3.0"); | 2 local mod = MailOpener:NewModule("FailSafe", "AceEvent-3.0", "AceTimer-3.0"); |
| 3 | 3 |
| 4 --[[ | 4 mod.moduleDescription = "Prevents the mail opening from completely stopping when the opening of a single mail gets stuck."; |
| 5 Module name: FailSafe | 5 mod.moduleRequired = false; |
| 6 Description: Prevents the mail opening from stopping when the execution of a single mail opening function fails (e.g. because of mail functions throttling). | |
| 7 Required: No. | |
| 8 ]] | |
| 9 | 6 |
| 10 function FailSafe:OnInitialize() | 7 function mod:OnInitialize() |
| 11 local defaults = { | 8 local defaults = { |
| 12 profile = { | 9 profile = { |
| 13 timeout = 20, | 10 timeout = 20, |
| 14 }, | 11 }, |
| 15 }; | 12 }; |
| 16 | 13 |
| 17 -- Register our saved variables NameSpace | 14 -- Register our saved variables NameSpace |
| 18 self.db = MailOpener.db:RegisterNamespace("FailSafe", defaults); | 15 self.db = MailOpener.db:RegisterNamespace("FailSafe", defaults); |
| 19 end | 16 end |
| 20 | 17 |
| 21 function FailSafe:OnEnable() | 18 function mod:OnEnable() |
| 22 self:Debug("OnEnable"); | 19 self:Debug("OnEnable"); |
| 23 | 20 |
| 24 self:RegisterEvent("MAIL_SHOW"); | 21 self:RegisterEvent("MAIL_SHOW"); |
| 22 | |
| 23 -- If we were toggling this module on while the mailbox is opened we must register all events again | |
| 24 if MailFrame:IsVisible() then | |
| 25 self:MAIL_SHOW(); | |
| 26 end | |
| 25 end | 27 end |
| 26 | 28 |
| 27 -- Even though Ace can unregister our events it's neater to do it manually too | 29 -- Even though Ace can unregister our events it's neater to do it manually too |
| 28 function FailSafe:OnDisable() | 30 function mod:OnDisable() |
| 29 self:Debug("OnDisable"); | 31 self:Debug("OnDisable"); |
| 30 | 32 |
| 31 self:UnregisterEvent("MAIL_SHOW"); | 33 self:UnregisterEvent("MAIL_SHOW"); |
| 32 | 34 |
| 33 self:Stop(); | 35 self:Stop(); |
| 34 end | 36 end |
| 35 | 37 |
| 36 function FailSafe:MAIL_SHOW() | 38 function mod:MAIL_SHOW() |
| 37 self:Debug("MAIL_SHOW"); | 39 self:Debug("MAIL_SHOW"); |
| 38 | 40 |
| 39 self:RegisterEvent("MAIL_CLOSED"); | 41 self:RegisterEvent("MAIL_CLOSED"); |
| 40 | 42 |
| 41 self:RegisterMessage("MO_OPENING_MAIL"); | 43 self:RegisterMessage("MO_OPENING_MAIL"); |
| 42 self:RegisterMessage("MO_MAIL_EMPTIED"); | 44 self:RegisterMessage("MO_MAIL_EMPTIED"); |
| 43 end | 45 end |
| 44 | 46 |
| 45 function FailSafe:MAIL_CLOSED() | 47 function mod:MAIL_CLOSED() |
| 46 self:Debug("MAIL_CLOSED"); | 48 self:Debug("MAIL_CLOSED"); |
| 47 | 49 |
| 48 self:UnregisterEvent("MAIL_CLOSED"); | 50 self:UnregisterEvent("MAIL_CLOSED"); |
| 49 | 51 |
| 50 self:UnregisterMessage("MO_OPENING_MAIL"); | 52 self:UnregisterMessage("MO_OPENING_MAIL"); |
| 51 self:UnregisterMessage("MO_OPENING_MAIL_FINISHED"); | 53 self:UnregisterMessage("MO_OPENING_MAIL_FINISHED"); |
| 52 | 54 |
| 53 self:CancelTimer(self.tmrTimeout, true); | 55 self:CancelTimer(self.tmrTimeout, true); |
| 54 end | 56 end |
| 55 | 57 |
| 56 function FailSafe:MO_OPENING_MAIL() | 58 function mod:MO_OPENING_MAIL() |
| 57 -- Single mail being opened | 59 -- Single mail being opened |
| 58 | 60 |
| 59 self:CancelTimer(self.tmrTimeout, true); -- insurance | 61 self:CancelTimer(self.tmrTimeout, true); -- insurance |
| 60 self.tmrTimeout = self:ScheduleTimer("Continue", self.db.profile.timeout); | 62 self.tmrTimeout = self:ScheduleTimer("Continue", self.db.profile.timeout); |
| 61 end | 63 end |
| 62 | 64 |
| 63 function FailSafe:MO_MAIL_EMPTIED() | 65 function mod:MO_MAIL_EMPTIED() |
| 64 -- Single mail has been opened | 66 -- Single mail has been opened |
| 65 | 67 |
| 66 self:CancelTimer(self.tmrTimeout, true); | 68 self:CancelTimer(self.tmrTimeout, true); |
| 67 end | 69 end |
| 68 | 70 |
| 69 function FailSafe:Continue() | 71 function mod:Continue() |
| 70 MailOpener:GetModule("OpenAll"):Continue(); | 72 MailOpener:GetModule("OpenAll"):Continue(); |
| 71 | 73 |
| 72 print("|cff15ff00Mail Opener|r (FailSafe): Mail opening timeout, continueing with the next mail."); | 74 print("|cff15ff00Mail Opener|r (FailSafe): Mail opening timeout, continueing with the next mail."); |
| 73 end | 75 end |
| 74 | 76 |
| 75 function FailSafe:GetOptionsGroup() | 77 function mod:GetOptionsGroup() |
| 76 local configGroup = { | 78 local configGroup = { |
| 77 order = 450, | 79 order = 0, |
| 78 type = "group", | 80 type = "modulesSubGroup", |
| 79 name = "FailSafe", | 81 name = "FailSafe", |
| 80 desc = "Change settings for the FailSafe module.", | 82 desc = "Change settings for the FailSafe module.", |
| 81 args = { | 83 args = { |
| 82 General = { | 84 General = { |
| 83 order = 10, | 85 order = 10, |
| 87 args = { | 89 args = { |
| 88 description = { | 90 description = { |
| 89 order = 10, | 91 order = 10, |
| 90 type = "description", | 92 type = "description", |
| 91 name = function() | 93 name = function() |
| 92 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"; | 94 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"; |
| 93 | 95 |
| 94 if self:IsEnabled() then | 96 if self:IsEnabled() then |
| 95 return default .. "Status: |cff00ff00Enabled|r"; | 97 descText = descText .. "Status: |cff00ff00Enabled|r"; |
| 96 else | 98 else |
| 97 return default .. "Status: |cffff0000Disabled|r"; | 99 descText = descText .. "Status: |cffff0000Disabled|r"; |
| 98 end | 100 end |
| 101 | |
| 102 return descText; | |
| 99 end, | 103 end, |
| 100 }, | 104 }, |
| 101 disable = { | 105 disable = { |
| 102 order = 20, | 106 order = 20, |
| 103 type = "execute", | 107 type = "execute", |
| 153 }; | 157 }; |
| 154 | 158 |
| 155 return configGroup; | 159 return configGroup; |
| 156 end | 160 end |
| 157 | 161 |
| 158 function FailSafe:Debug(t) | 162 function mod:Debug(t) |
| 159 return MailOpener:Debug("|cffff0000FailSafe|r:" .. t); | 163 return MailOpener:Debug("|cffff0000FailSafe|r:" .. t); |
| 160 end | 164 end |
