summaryrefslogtreecommitdiff
path: root/plugins/UserInfoEx/src/svc_reminder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/UserInfoEx/src/svc_reminder.cpp')
-rw-r--r--plugins/UserInfoEx/src/svc_reminder.cpp52
1 files changed, 22 insertions, 30 deletions
diff --git a/plugins/UserInfoEx/src/svc_reminder.cpp b/plugins/UserInfoEx/src/svc_reminder.cpp
index ba2d059ead..e479924df2 100644
--- a/plugins/UserInfoEx/src/svc_reminder.cpp
+++ b/plugins/UserInfoEx/src/svc_reminder.cpp
@@ -56,13 +56,12 @@ REMINDEROPTIONS, *LPREMINDEROPTIONS;
static HANDLE ExtraIcon = INVALID_HANDLE_VALUE;
+static HANDLE ghCListIA = nullptr;
+static HANDLE ghCListIR = nullptr;
+static HANDLE ghSettingsChanged = nullptr;
-static HANDLE ghCListIA = nullptr;
-static HANDLE ghCListIR = nullptr;
-static HANDLE ghSettingsChanged = nullptr;
-
-static UINT_PTR ghRemindTimer = 0;
-static UINT_PTR ghRemindDateChangeTimer = 0;
+static UINT_PTR ghRemindTimer = 0;
+static UINT_PTR ghRemindDateChangeTimer = 0;
HANDLE ghCListAnnivIcons[11];
HANDLE ghCListBirthdayIcons[11];
@@ -339,7 +338,7 @@ static void NotifyFlashCListIcon(MCONTACT hContact, const CEvent &evt)
static uint8_t NotifyWithSound(const CEvent &evt)
{
- if (evt._wDaysLeft <= min(g_plugin.getByte(SET_REMIND_SOUNDOFFSET, DEFVAL_REMIND_SOUNDOFFSET), gRemindOpts.wDaysEarlier)) {
+ if (evt._wDaysLeft <= min(g_plugin.wRemindSoundOffset, gRemindOpts.wDaysEarlier)) {
switch (evt._eType) {
case CEvent::BIRTHDAY:
Skin_PlaySound(evt._wDaysLeft == 0 ? SOUND_BIRTHDAY_TODAY : SOUND_BIRTHDAY_SOON);
@@ -434,13 +433,12 @@ static uint8_t CheckAnniversaries(MCONTACT hContact, MTime &Now, CEvent &evt, ui
* @param Now - current time
* @param evt - the reference to a structure, which retrieves the resulting DTB
* @param bNotify - if TRUE, a popup will be displayed for a contact having birthday within the next few days.
-* @param LastAnswer - this parameter is used for the automatic backup function
*
* @retval TRUE - contact has a birthday to remind of
* @retval FALSE - contact has no birthday or it is not within the desired period of time.
**/
-static bool CheckBirthday(MCONTACT hContact, MTime &Now, CEvent &evt, uint8_t bNotify, PWORD LastAnwer)
+static bool CheckBirthday(MCONTACT hContact, MTime &Now, CEvent &evt, uint8_t bNotify)
{
if (gRemindOpts.RemindState == REMIND_BIRTH || gRemindOpts.RemindState == REMIND_ALL) {
MAnnivDate mtb;
@@ -511,18 +509,17 @@ static bool CheckBirthday(MCONTACT hContact, MTime &Now, CEvent &evt, uint8_t bN
* @param Now - current time
* @param evt - the reference to a structure, which retrieves the resulting DTB
* @param bNotify - if TRUE, a popup will be displayed for a contact having birthday within the next few days.
-* @param LastAnswer - this parameter is used for the automatic backup function
*
* @return nothing
**/
-static void CheckContact(MCONTACT hContact, MTime &Now, CEvent &evt, uint8_t bNotify, PWORD LastAnwer = nullptr)
+static void CheckContact(MCONTACT hContact, MTime &Now, CEvent &evt, uint8_t bNotify)
{
// ignore meta subcontacts here as their birthday information are collected explicitly
if (hContact && (!gRemindOpts.bCheckVisibleOnly || !Contact::IsHidden(hContact)) && !db_mc_isSub(hContact)) {
CEvent ca;
- if (CheckBirthday(hContact, Now, ca, bNotify, LastAnwer) || CheckAnniversaries(hContact, Now, ca, bNotify)) {
+ if (CheckBirthday(hContact, Now, ca, bNotify) || CheckAnniversaries(hContact, Now, ca, bNotify)) {
evt << ca;
if (bNotify)
NotifyFlashCListIcon(hContact, ca);
@@ -549,9 +546,8 @@ void SvcReminderCheckAll(const ENotify notify)
// walk through all the contacts stored in the DB
CEvent evt;
- uint16_t a1 = 0;
for (auto &hContact : Contacts())
- CheckContact(hContact, now, evt, notify != NOTIFY_CLIST, &a1);
+ CheckContact(hContact, now, evt, notify != NOTIFY_CLIST);
if (notify != NOTIFY_CLIST) {
// play sound for the next anniversary
@@ -641,11 +637,7 @@ static int OnContactSettingChanged(MCONTACT hContact, DBCONTACTWRITESETTING* pdb
CEvent evt;
MTime now;
now.GetLocalTime();
- if (!mir_strcmp(pdbcws->szModule, USERINFO)) {
- uint16_t LastAnswer = IDNONE;
- CheckContact(hContact, now, evt, FALSE, &LastAnswer);
- }
- else CheckContact(hContact, now, evt, FALSE, nullptr);
+ CheckContact(hContact, now, evt, FALSE);
}
return 0;
}
@@ -721,7 +713,7 @@ static void CALLBACK TimerProc_Check(HWND, UINT, UINT_PTR, DWORD)
static void UpdateTimer(uint8_t bStartup)
{
- LONG wNotifyInterval = 60 * 60 * (LONG)g_plugin.getWord(SET_REMIND_NOTIFYINTERVAL, DEFVAL_REMIND_NOTIFYINTERVAL);
+ LONG wNotifyInterval = 60 * 60 * (LONG)g_plugin.wRemindNotifyInterval;
MTime now, last;
now.GetTimeUTC();
@@ -730,7 +722,7 @@ static void UpdateTimer(uint8_t bStartup)
last.DBGetStamp(0, MODULENAME, SET_REMIND_LASTCHECK);
// if last check occured at least one day before just do it on startup again
- if (now.Year() > last.Year() || now.Month() > last.Month() || now.Day() > last.Day() || g_plugin.getByte(SET_REMIND_CHECKON_STARTUP, FALSE))
+ if (now.Year() > last.Year() || now.Month() > last.Month() || now.Day() > last.Day() || g_plugin.bRemindFlashIcon)
wNotifyInterval = 5;
else
wNotifyInterval -= now.Compare(last);
@@ -748,7 +740,7 @@ static void UpdateTimer(uint8_t bStartup)
* module loading & unloading
***********************************************************************************************************/
-void SvcReminderEnable(uint8_t bEnable)
+void SvcReminderEnable(bool bEnable)
{
if (bEnable) { // Reminder is on
// init hooks
@@ -759,12 +751,12 @@ void SvcReminderEnable(uint8_t bEnable)
ghSettingsChanged = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, (MIRANDAHOOK)OnContactSettingChanged);
// reinit reminder options
- gRemindOpts.RemindState = g_plugin.getByte(SET_REMIND_ENABLED, DEFVAL_REMIND_ENABLED);
- gRemindOpts.wDaysEarlier = g_plugin.getWord(SET_REMIND_OFFSET, DEFVAL_REMIND_OFFSET);
- gRemindOpts.bCListExtraIcon = g_plugin.getByte(SET_REMIND_EXTRAICON, 1);
- gRemindOpts.bCheckVisibleOnly = g_plugin.getByte(SET_REMIND_CHECKVISIBLE, DEFVAL_REMIND_CHECKVISIBLE);
- gRemindOpts.bFlashCList = g_plugin.getByte(SET_REMIND_FLASHICON, FALSE);
- gRemindOpts.bPopups = g_plugin.getByte(SET_POPUP_ENABLED, DEFVAL_POPUP_ENABLED);
+ gRemindOpts.RemindState = g_plugin.iRemindEnabled;
+ gRemindOpts.wDaysEarlier = g_plugin.wRemindOffset;
+ gRemindOpts.bCListExtraIcon = g_plugin.bRemindExtraIcon;
+ gRemindOpts.bCheckVisibleOnly = g_plugin.bRemindCheckVisible;
+ gRemindOpts.bFlashCList = g_plugin.bRemindFlashIcon;
+ gRemindOpts.bPopups = g_plugin.getByte(SET_POPUP_ENABLED, TRUE);
// init the timer
UpdateTimer(TRUE);
@@ -791,7 +783,7 @@ void SvcReminderOnModulesLoaded(void)
// init clist extra icon structure
OnCListRebuildIcons(0, 0);
- SvcReminderEnable(g_plugin.getByte(SET_REMIND_ENABLED, DEFVAL_REMIND_ENABLED) != REMIND_OFF);
+ SvcReminderEnable(g_plugin.iRemindEnabled != REMIND_OFF);
}
/**
@@ -816,7 +808,7 @@ void SvcReminderLoadModule(void)
hk.pszService = MS_USERINFO_REMINDER_CHECK;
g_plugin.addHotkey(&hk);
- if (g_plugin.getByte(SET_REMIND_ENABLED, DEFVAL_REMIND_ENABLED) != REMIND_OFF && ExtraIcon == INVALID_HANDLE_VALUE)
+ if (g_plugin.iRemindEnabled != REMIND_OFF && ExtraIcon == INVALID_HANDLE_VALUE)
ExtraIcon = ExtraIcon_RegisterIcolib("Reminder", LPGEN("Reminder (UInfoEx)"), g_plugin.getIconHandle(IDI_ANNIVERSARY));
}