From 1c008b3bda59815fbe9e690826accfb043b27c07 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 30 Jan 2022 18:39:25 +0300 Subject: fixes #3001 (WhenWasIt: remove mBirthday support) --- plugins/WhenWasIt/src/date_utils.cpp | 52 ++++++++++------------------------ plugins/WhenWasIt/src/date_utils.h | 14 ++++----- plugins/WhenWasIt/src/dlg_handlers.cpp | 22 ++++---------- plugins/WhenWasIt/src/version.h | 2 +- 4 files changed, 28 insertions(+), 62 deletions(-) (limited to 'plugins/WhenWasIt/src') diff --git a/plugins/WhenWasIt/src/date_utils.cpp b/plugins/WhenWasIt/src/date_utils.cpp index 96da0e9436..02a10a8e0a 100644 --- a/plugins/WhenWasIt/src/date_utils.cpp +++ b/plugins/WhenWasIt/src/date_utils.cpp @@ -54,12 +54,6 @@ int GetContactDOB(MCONTACT hContact, int &year, int &month, int &day) if (IsDOBValid(year, month, day)) return DOB_BIRTHDAYREMINDER; - year = db_get_w(hContact, "mBirthday", "BirthYear", 0); - month = db_get_b(hContact, "mBirthday", "BirthMonth", 0); - day = db_get_b(hContact, "mBirthday", "BirthDay", 0); - if (IsDOBValid(year, month, day)) - return DOB_MBIRTHDAY; - year = db_get_dw(hContact, "micqBirthday", "BirthYear", 0); month = db_get_dw(hContact, "micqBirthday", "BirthMonth", 0); day = db_get_dw(hContact, "micqBirthday", "BirthDay", 0); @@ -172,14 +166,6 @@ void FillProtocol(char *&sYear, char *&sMonth, char *&sDay) sDay = "BirthDay"; } -void FillmBirthday(char *&module, char *&sYear, char *&sMonth, char *&sDay) -{ - module = "mBirthday"; - sYear = "BirthYear"; - sMonth = "BirthMonth"; - sDay = "BirthDay"; -} - void FillStandard(char *&module, char *&sYear, char *&sMonth, char *&sDay) { module = "UserInfo"; @@ -196,29 +182,17 @@ int SaveBirthday(MCONTACT hContact, int year, int month, int day, int mode) char *sDay, *sdDay, *sd2Day; char *protocol = Proto_GetBaseAccountName(hContact); - switch (mode) { - case SAVE_MODE_MBIRTHDAY: - FillmBirthday(sModule, sYear, sMonth, sDay); - FillStandard(sdModule, sdYear, sdMonth, sdDay); - sd2Module = protocol; - FillProtocol(sd2Year, sd2Month, sd2Day); - break; - - case SAVE_MODE_PROTOCOL: + if (mode == SAVE_MODE_PROTOCOL) { sModule = protocol; FillProtocol(sYear, sMonth, sDay); - - FillmBirthday(sd2Module, sd2Year, sd2Month, sd2Day); FillStandard(sdModule, sdYear, sdMonth, sdDay); - break; - - case SAVE_MODE_STANDARD: - default: + sd2Module = sd2Year = sd2Month = sd2Day = nullptr; + } + else { FillStandard(sModule, sYear, sMonth, sDay); - FillmBirthday(sdModule, sdYear, sdMonth, sdDay); sd2Module = protocol; FillProtocol(sd2Year, sd2Month, sd2Day); - break; + sdModule = sdYear = sdMonth = sdDay = nullptr; } if (mode == SAVE_MODE_DELETEALL) { @@ -232,13 +206,17 @@ int SaveBirthday(MCONTACT hContact, int year, int month, int day, int mode) db_set_b(hContact, sModule, sDay, day); } - db_unset(hContact, sdModule, sdYear); - db_unset(hContact, sdModule, sdMonth); - db_unset(hContact, sdModule, sdDay); + if (sdYear) { + db_unset(hContact, sdModule, sdYear); + db_unset(hContact, sdModule, sdMonth); + db_unset(hContact, sdModule, sdDay); + } - db_unset(hContact, sd2Module, sd2Year); - db_unset(hContact, sd2Module, sd2Month); - db_unset(hContact, sd2Module, sd2Day); + if (sd2Year) { + db_unset(hContact, sd2Module, sd2Year); + db_unset(hContact, sd2Module, sd2Month); + db_unset(hContact, sd2Module, sd2Day); + } db_unset(hContact, "BirthDay", "BirthYear"); db_unset(hContact, "BirthDay", "BirthMonth"); diff --git a/plugins/WhenWasIt/src/date_utils.h b/plugins/WhenWasIt/src/date_utils.h index 3cfcf235d5..8baff33b63 100644 --- a/plugins/WhenWasIt/src/date_utils.h +++ b/plugins/WhenWasIt/src/date_utils.h @@ -25,16 +25,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define SAVE_MODE_STANDARD 0 #define SAVE_MODE_PROTOCOL 1 -#define SAVE_MODE_MBIRTHDAY 2 -#define DOB_UNKNOWN 100 -#define DOB_USERINFO 101 -#define DOB_MBIRTHDAY 102 -#define DOB_PROTOCOL 103 -#define DOB_BIRTHDAYREMINDER 104 -#define DOB_MICQBIRTHDAY 105 +#define DOB_UNKNOWN 100 +#define DOB_USERINFO 101 +#define DOB_PROTOCOL 103 +#define DOB_BIRTHDAYREMINDER 104 +#define DOB_MICQBIRTHDAY 105 -#define SAVE_MODE_DELETEALL 100 +#define SAVE_MODE_DELETEALL 100 time_t Today(); bool IsLeapYear(int year); diff --git a/plugins/WhenWasIt/src/dlg_handlers.cpp b/plugins/WhenWasIt/src/dlg_handlers.cpp index 78cd26bbad..d78eb66ec4 100644 --- a/plugins/WhenWasIt/src/dlg_handlers.cpp +++ b/plugins/WhenWasIt/src/dlg_handlers.cpp @@ -30,16 +30,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define UPCOMING_TIMER_ID 1002 const wchar_t *szShowAgeMode[] = { LPGENW("Upcoming age"), LPGENW("Current age") }; -const int cShowAgeMode = sizeof(szShowAgeMode) / sizeof(szShowAgeMode[0]); -const wchar_t *szSaveModule[] = { LPGENW("UserInfo module"), LPGENW("Protocol module"), LPGENW("mBirthday module") }; -const int cSaveModule = sizeof(szSaveModule) / sizeof(szSaveModule[0]); +const wchar_t *szSaveModule[] = { LPGENW("UserInfo module"), LPGENW("Protocol module") }; const wchar_t *szPopupClick[] = { LPGENW("Nothing"), LPGENW("Dismiss"), LPGENW("Message window") }; -const int cPopupClick = sizeof(szPopupClick) / sizeof(szPopupClick[0]); const wchar_t *szNotifyFor[] = { LPGENW("All contacts"), LPGENW("All contacts except hidden ones"), LPGENW("All contacts except ignored ones"), LPGENW("All contacts except hidden and ignored ones") }; -const int cNotifyFor = sizeof(szNotifyFor) / sizeof(szNotifyFor[0]); #define MIN_BIRTHDAYS_WIDTH 200 #define MIN_BIRTHDAYS_HEIGHT 200 @@ -98,18 +94,18 @@ int AddInfoToComboBoxes(HWND hWnd) { int i; - for (i = 0; i < cShowAgeMode; i++) + for (i = 0; i < _countof(szShowAgeMode); i++) SendDlgItemMessage(hWnd, IDC_AGE_COMBOBOX, CB_ADDSTRING, 0, (LPARAM)TranslateW(szShowAgeMode[i])); - for (i = 0; i < cSaveModule; i++) + for (i = 0; i < _countof(szSaveModule); i++) SendDlgItemMessage(hWnd, IDC_DEFAULT_MODULE, CB_ADDSTRING, 0, (LPARAM)TranslateW(szSaveModule[i])); - for (i = 0; i < cPopupClick; i++) { + for (i = 0; i < _countof(szPopupClick); i++) { SendDlgItemMessage(hWnd, IDC_LEFT_CLICK, CB_ADDSTRING, 0, (LPARAM)TranslateW(szPopupClick[i])); SendDlgItemMessage(hWnd, IDC_RIGHT_CLICK, CB_ADDSTRING, 0, (LPARAM)TranslateW(szPopupClick[i])); } - for (i = 0; i < cNotifyFor; i++) + for (i = 0; i < _countof(szNotifyFor); i++) SendDlgItemMessage(hWnd, IDC_NOTIFYFOR, CB_ADDSTRING, 0, (LPARAM)TranslateW(szNotifyFor[i])); return i; @@ -399,7 +395,7 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l Window_SetIcon_IcoLib(hWnd, hAddBirthdayContact); - for (int i = 0; i < cSaveModule; i++) + for (int i = 0; i < _countof(szSaveModule); i++) SendDlgItemMessage(hWnd, IDC_COMPATIBILITY, CB_ADDSTRING, 0, (LPARAM)TranslateW(szSaveModule[i])); SendDlgItemMessage(hWnd, IDC_COMPATIBILITY, CB_SETCURSEL, commonData.cDefaultModule, 0); break; @@ -428,11 +424,6 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l else DateTime_SetSystemtime(hDate, GDT_NONE, NULL); switch (loc) { - case DOB_MBIRTHDAY: - DateTime_SetMonthCalColor(hDate, MCSC_TITLEBK, COLOR_MBIRTHDAY); - szCurrentModuleTooltip = L"mBirthday"; - break; - case DOB_PROTOCOL: DateTime_SetMonthCalColor(hDate, MCSC_TITLEBK, COLOR_PROTOCOL); mir_snwprintf(buffer, TranslateT("%S protocol"), szProto); @@ -513,7 +504,6 @@ void AddAnchorWindowToDeferList(HDWP &hdWnds, HWND window, RECT *rParent, WINDOW wchar_t* GetBirthdayModule(int module, MCONTACT) { switch (module) { - case DOB_MBIRTHDAY: return L"mBirthday"; case DOB_PROTOCOL: return TranslateT("Protocol module"); case DOB_BIRTHDAYREMINDER: return L"Birthday Reminder"; case DOB_USERINFO: return L"UserInfo"; diff --git a/plugins/WhenWasIt/src/version.h b/plugins/WhenWasIt/src/version.h index 6cc416903c..c1f40e84c3 100644 --- a/plugins/WhenWasIt/src/version.h +++ b/plugins/WhenWasIt/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 3 #define __RELEASE_NUM 3 -#define __BUILD_NUM 5 +#define __BUILD_NUM 6 #include -- cgit v1.2.3