summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/WhenWasIt/src/date_utils.cpp7
-rw-r--r--plugins/WhenWasIt/src/date_utils.h2
-rw-r--r--plugins/WhenWasIt/src/hooked_events.cpp11
3 files changed, 14 insertions, 6 deletions
diff --git a/plugins/WhenWasIt/src/date_utils.cpp b/plugins/WhenWasIt/src/date_utils.cpp
index eba383bd48..179d9174f1 100644
--- a/plugins/WhenWasIt/src/date_utils.cpp
+++ b/plugins/WhenWasIt/src/date_utils.cpp
@@ -33,6 +33,11 @@ bool IsDOBValid(int, int month, int day)
return (month != 0 && day != 0);
}
+const char* GetModule(MCONTACT hContact, int mode)
+{
+ return (mode == DOB_PROTOCOL) ? Proto_GetBaseAccountName(hContact) : "UserInfo";
+}
+
int GetContactDOB(MCONTACT hContact, int &year, int &month, int &day, int iModule)
{
if (iModule != DOB_PROTOCOL) {
@@ -173,7 +178,7 @@ void DeleteBirthday(MCONTACT hContact)
void SaveBirthday(MCONTACT hContact, int year, int month, int day, int mode)
{
- const char *szModule = (mode == DOB_PROTOCOL) ? Proto_GetBaseAccountName(hContact) : "UserInfo";
+ auto *szModule = GetModule(hContact, mode);
db_set_dw(hContact, szModule, "BirthYear", year);
db_set_b(hContact, szModule, "BirthMonth", month);
diff --git a/plugins/WhenWasIt/src/date_utils.h b/plugins/WhenWasIt/src/date_utils.h
index 341ccabb3f..9eb72e6ff8 100644
--- a/plugins/WhenWasIt/src/date_utils.h
+++ b/plugins/WhenWasIt/src/date_utils.h
@@ -42,4 +42,6 @@ int GetContactAge(int year, int month, int day);
void SaveBirthday(MCONTACT hContact, int year, int month, int day, int mode);
void DeleteBirthday(MCONTACT hContact);
+const char *GetModule(MCONTACT hContact, int mode);
+
#endif //H_WWI_DATE_UTILS_H \ No newline at end of file
diff --git a/plugins/WhenWasIt/src/hooked_events.cpp b/plugins/WhenWasIt/src/hooked_events.cpp
index 6c83cd2408..e356854b44 100644
--- a/plugins/WhenWasIt/src/hooked_events.cpp
+++ b/plugins/WhenWasIt/src/hooked_events.cpp
@@ -107,11 +107,12 @@ int RefreshContactListIcons(MCONTACT hContact)
int dab = NotifyMissedContactBirthday(hContact, today, g_plugin.daysAfter);
if (ok && (dtb >= 0 || dab > 0)) {
- int age = GetContactAge(hContact);
- db_set_b(hContact, "UserInfo", "Age", age);
+ int year, month, day;
+ int mode = GetContactDOB(hContact, year, month, day);
+ int age = GetContactAge(year, month, day);
+ db_set_b(hContact, GetModule(hContact, mode), "Age", age);
- if ((bShouldCheckBirthdays) && (g_plugin.bUsePopups))
- {
+ if (bShouldCheckBirthdays && g_plugin.bUsePopups) {
if (dtb >= 0) {
bBirthdayFound = 1; //only set it if we're called from our CheckBirthdays service
PopupNotifyBirthday(hContact, dtb, age);
@@ -124,7 +125,7 @@ int RefreshContactListIcons(MCONTACT hContact)
if (dtb >= 0)
SoundNotifyBirthday(dtb);
- if ((bShouldCheckBirthdays) && (g_plugin.bUseDialog)) {
+ if (bShouldCheckBirthdays && g_plugin.bUseDialog) {
if (dtb >= 0)
DialogNotifyBirthday(hContact, dtb, age);
else if (dab > 0)