diff options
author | George Hazan <ghazan@miranda.im> | 2022-07-31 20:07:18 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-07-31 20:07:18 +0300 |
commit | 559dbc7b53b097c0beb326bf82302aaed6cfa0a8 (patch) | |
tree | a7562045ef397aec23d9aec4de150ff3a92ead17 /plugins/WhenWasIt/src | |
parent | f6b30701f54f28912b19994606888e109f9ac3f4 (diff) |
fixes #3130 (WhenWasIt ведёт себя странно)
Diffstat (limited to 'plugins/WhenWasIt/src')
-rw-r--r-- | plugins/WhenWasIt/src/WhenWasIt.cpp | 3 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/add_birthday.cpp | 49 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/date_utils.cpp | 90 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/date_utils.h | 10 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/dlg_handlers.cpp | 35 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/options.cpp | 10 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/resource.h | 5 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/services.cpp | 4 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/stdafx.h | 2 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/utils.cpp | 148 | ||||
-rw-r--r-- | plugins/WhenWasIt/src/utils.h | 11 |
11 files changed, 74 insertions, 293 deletions
diff --git a/plugins/WhenWasIt/src/WhenWasIt.cpp b/plugins/WhenWasIt/src/WhenWasIt.cpp index 8a97f7f513..b58b577ac6 100644 --- a/plugins/WhenWasIt/src/WhenWasIt.cpp +++ b/plugins/WhenWasIt/src/WhenWasIt.cpp @@ -56,7 +56,6 @@ CMPlugin::CMPlugin() : bNoBirthdaysPopup(MODULENAME, "NoBirthdaysPopup", false),
bOpenInBackground(MODULENAME, "OpenInBackground", false),
cSoundNearDays(MODULENAME, "SoundNearDays", BIRTHDAY_NEAR_DEFAULT_DAYS),
- cDefaultModule(MODULENAME, "DefaultModule", 0),
lPopupClick(MODULENAME, "PopupLeftClick", 2),
rPopupClick(MODULENAME, "PopupRightClick", 1),
bOncePerDay(MODULENAME, "OncePerDay", false),
@@ -83,6 +82,8 @@ int CMPlugin::Load() Log("%s", "Hooking events ...");
HookEvents();
+ CheckConvert();
+
hAddBirthdayWndsList = WindowList_Create();
CMenuItem mi(&g_plugin);
diff --git a/plugins/WhenWasIt/src/add_birthday.cpp b/plugins/WhenWasIt/src/add_birthday.cpp index 215c7c7761..9a1fac5ff5 100644 --- a/plugins/WhenWasIt/src/add_birthday.cpp +++ b/plugins/WhenWasIt/src/add_birthday.cpp @@ -26,19 +26,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define COLOR_MICQBIRTHDAY RGB(88, 88, 240) #define COLOR_PROTOCOL RGB(255, 153, 153) -extern const wchar_t* szSaveModule[2]; - class CAddBirthdayDlg : public CDlgBase { MCONTACT m_hContact; - CCtrlCombo cmbCompat; - public: CAddBirthdayDlg(MCONTACT hContact) : CDlgBase(g_plugin, IDD_ADD_BIRTHDAY), - m_hContact(hContact), - cmbCompat(this, IDC_COMPATIBILITY) + m_hContact(hContact) { } @@ -49,19 +44,13 @@ public: Window_SetIcon_IcoLib(m_hwnd, hAddBirthdayContact); - for (auto &it : szSaveModule) - cmbCompat.AddString(TranslateW(it)); - cmbCompat.SetCurSel(g_plugin.cDefaultModule); - - wchar_t *szTooltipText = TranslateT("Please select the module where you want the date of birth to be saved.\r\n\"UserInfo\" is the default location.\r\nUse \"Protocol module\" to make the data visible in User Details.\n\"mBirthday module\" uses the same module as mBirthday plugin."); - CMStringW buf(FORMAT, TranslateT("Set birthday for %s:"), Clist_GetContactDisplayName(m_hContact)); SetCaption(buf); HWND hDate = GetDlgItem(m_hwnd, IDC_DATE); int year, month, day; - int loc = GetContactDOB(m_hContact, year, month, day); + GetContactDOB(m_hContact, year, month, day); if (IsDOBValid(year, month, day)) { SYSTEMTIME st = { 0 }; st.wDay = day; @@ -71,37 +60,7 @@ public: } else DateTime_SetSystemtime(hDate, GDT_NONE, NULL); - const wchar_t *szCurrentModuleTooltip; - switch (loc) { - case DOB_PROTOCOL: - DateTime_SetMonthCalColor(hDate, MCSC_TITLEBK, COLOR_PROTOCOL); - buf.Format(TranslateT("%S protocol"), Proto_GetBaseAccountName(m_hContact)); - szCurrentModuleTooltip = buf; - break; - - case DOB_BIRTHDAYREMINDER: - DateTime_SetMonthCalColor(hDate, MCSC_TITLEBK, COLOR_BIRTHDAYREMINDER); - szCurrentModuleTooltip = L"Birthday Reminder"; - break; - - case DOB_USERINFO: - DateTime_SetMonthCalColor(hDate, MCSC_TITLEBK, COLOR_USERINFO); - szCurrentModuleTooltip = L"UserInfo"; - break; - - case DOB_MICQBIRTHDAY: - DateTime_SetMonthCalColor(hDate, MCSC_TITLEBK, COLOR_MICQBIRTHDAY); - szCurrentModuleTooltip = L"mICQBirthday"; - break; - - default: - szCurrentModuleTooltip = nullptr; - break; - } - - CreateToolTip(cmbCompat.GetHwnd(), szTooltipText, 500); - if (szCurrentModuleTooltip) - CreateToolTip(hDate, szCurrentModuleTooltip, 400); + DateTime_SetMonthCalColor(hDate, MCSC_TITLEBK, COLOR_USERINFO); return true; } @@ -110,7 +69,7 @@ public: HWND hDate = GetDlgItem(m_hwnd, IDC_DATE); SYSTEMTIME st; if (DateTime_GetSystemtime(hDate, &st) == GDT_VALID) - SaveBirthday(m_hContact, st.wYear, st.wMonth, st.wDay, cmbCompat.GetCurSel()); + SaveBirthday(m_hContact, st.wYear, st.wMonth, st.wDay, SAVE_MODE_STANDARD); else SaveBirthday(m_hContact, 0, 0, 0, SAVE_MODE_DELETEALL); diff --git a/plugins/WhenWasIt/src/date_utils.cpp b/plugins/WhenWasIt/src/date_utils.cpp index 02a10a8e0a..bc24fc89ab 100644 --- a/plugins/WhenWasIt/src/date_utils.cpp +++ b/plugins/WhenWasIt/src/date_utils.cpp @@ -33,13 +33,17 @@ bool IsDOBValid(int, int month, int day) return (month != 0 && day != 0);
}
-int GetContactDOB(MCONTACT hContact, int &year, int &month, int &day)
+int GetContactDOB(MCONTACT hContact, int &year, int &month, int &day, int module)
{
- year = db_get_w(hContact, "UserInfo", "DOBy", 0);
- month = db_get_b(hContact, "UserInfo", "DOBm", 0);
- day = db_get_b(hContact, "UserInfo", "DOBd", 0);
- if (IsDOBValid(year, month, day))
- return DOB_USERINFO;
+ if (module != DOB_PROTOCOL) {
+ year = db_get_w(hContact, "UserInfo", "BirthYear", 0);
+ month = db_get_b(hContact, "UserInfo", "BirthMonth", 0);
+ day = db_get_b(hContact, "UserInfo", "BirthDay", 0);
+ if (IsDOBValid(year, month, day))
+ return DOB_USERINFO;
+ if (module == DOB_USERINFO)
+ return DOB_UNKNOWN;
+ }
char *szProto = Proto_GetBaseAccountName(hContact);
year = db_get_w(hContact, szProto, "BirthYear", 0);
@@ -48,18 +52,6 @@ int GetContactDOB(MCONTACT hContact, int &year, int &month, int &day) if (IsDOBValid(year, month, day))
return DOB_PROTOCOL;
- year = db_get_w(hContact, "BirthDay", "BirthYear", 0);
- month = db_get_b(hContact, "BirthDay", "BirthMonth", 0);
- day = db_get_b(hContact, "BirthDay", "BirthDay", 0);
- if (IsDOBValid(year, month, day))
- return DOB_BIRTHDAYREMINDER;
-
- year = db_get_dw(hContact, "micqBirthday", "BirthYear", 0);
- month = db_get_dw(hContact, "micqBirthday", "BirthMonth", 0);
- day = db_get_dw(hContact, "micqBirthday", "BirthDay", 0);
- if (IsDOBValid(year, month, day))
- return DOB_MICQBIRTHDAY;
-
return DOB_UNKNOWN;
}
@@ -159,67 +151,17 @@ int DaysAfterBirthday(time_t now, int ctYear, int ctMonth, int ctDay) return -1;
}
-void FillProtocol(char *&sYear, char *&sMonth, char *&sDay)
-{
- sYear = "BirthYear";
- sMonth = "BirthMonth";
- sDay = "BirthDay";
-}
-
-void FillStandard(char *&module, char *&sYear, char *&sMonth, char *&sDay)
-{
- module = "UserInfo";
- sYear = "DOBy";
- sMonth = "DOBm";
- sDay = "DOBd";
-}
-
int SaveBirthday(MCONTACT hContact, int year, int month, int day, int mode)
{
- char *sModule, *sdModule, *sd2Module; //s* = keep, sd* = delete, sd2* = delete
- char *sYear, *sdYear, *sd2Year;
- char *sMonth, *sdMonth, *sd2Month;
- char *sDay, *sdDay, *sd2Day;
- char *protocol = Proto_GetBaseAccountName(hContact);
-
- if (mode == SAVE_MODE_PROTOCOL) {
- sModule = protocol;
- FillProtocol(sYear, sMonth, sDay);
- FillStandard(sdModule, sdYear, sdMonth, sdDay);
- sd2Module = sd2Year = sd2Month = sd2Day = nullptr;
- }
- else {
- FillStandard(sModule, sYear, sMonth, sDay);
- sd2Module = protocol;
- FillProtocol(sd2Year, sd2Month, sd2Day);
- sdModule = sdYear = sdMonth = sdDay = nullptr;
- }
-
if (mode == SAVE_MODE_DELETEALL) {
- db_unset(hContact, sModule, sYear);
- db_unset(hContact, sModule, sMonth);
- db_unset(hContact, sModule, sDay);
+ db_unset(hContact, "UserInfo", "BirthYear");
+ db_unset(hContact, "UserInfo", "BirthMonth");
+ db_unset(hContact, "UserInfo", "BirthDay");
}
else {
- db_set_dw(hContact, sModule, sYear, year);
- db_set_b(hContact, sModule, sMonth, month);
- db_set_b(hContact, sModule, sDay, day);
+ db_set_dw(hContact, "UserInfo", "BirthYear", year);
+ db_set_b(hContact, "UserInfo", "BirthMonth", month);
+ db_set_b(hContact, "UserInfo", "BirthDay", day);
}
-
- if (sdYear) {
- db_unset(hContact, sdModule, sdYear);
- db_unset(hContact, sdModule, sdMonth);
- db_unset(hContact, sdModule, sdDay);
- }
-
- 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");
- db_unset(hContact, "BirthDay", "BirthDay");
return 0;
}
diff --git a/plugins/WhenWasIt/src/date_utils.h b/plugins/WhenWasIt/src/date_utils.h index 8baff33b63..a111a1c0b8 100644 --- a/plugins/WhenWasIt/src/date_utils.h +++ b/plugins/WhenWasIt/src/date_utils.h @@ -23,16 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "errno.h"
-#define SAVE_MODE_STANDARD 0
-#define SAVE_MODE_PROTOCOL 1
+#define SAVE_MODE_STANDARD 0
+#define SAVE_MODE_DELETEALL 100
#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
time_t Today();
bool IsLeapYear(int year);
@@ -41,7 +37,7 @@ bool IsDOBValid(int year, int month, int day); unsigned int DaysToBirthday(time_t now, int ctYear, int ctMonth, int ctDay);
int DaysAfterBirthday(time_t now, int ctYear, int ctMonth, int ctDay);
int GetContactAge(MCONTACT hContact);
-int GetContactDOB(MCONTACT hContact, int &year, int &month, int &day);
+int GetContactDOB(MCONTACT hContact, int &year, int &month, int &day, int module = DOB_UNKNOWN);
char GetContactGender(MCONTACT hContact);
int SaveBirthday(MCONTACT hContact, int year, int month, int day, int mode);
diff --git a/plugins/WhenWasIt/src/dlg_handlers.cpp b/plugins/WhenWasIt/src/dlg_handlers.cpp index 9f8c0d582c..f6ac30149c 100644 --- a/plugins/WhenWasIt/src/dlg_handlers.cpp +++ b/plugins/WhenWasIt/src/dlg_handlers.cpp @@ -27,9 +27,7 @@ wchar_t* GetBirthdayModule(int module, MCONTACT) {
switch (module) {
case DOB_PROTOCOL: return TranslateT("Protocol module");
- case DOB_BIRTHDAYREMINDER: return L"Birthday Reminder";
case DOB_USERINFO: return L"UserInfo";
- case DOB_MICQBIRTHDAY: return L"mICQBirthday";
}
return NA;
}
@@ -140,13 +138,15 @@ class CBirthdaysDlg : public CBasicListDlg SetCaption(CMStringW(FORMAT, TranslateT("Birthday list (%d)"), m_list.GetItemCount()));
}
- int LoadBirthdays(int bShowAll)
+ int LoadBirthdays()
{
m_list.DeleteAllItems();
int count = 0;
- for (auto &hContact : Contacts())
- count = UpdateBirthdayEntry(hContact, count, bShowAll, g_plugin.cShowAgeMode, 1);
+ for (auto &hContact : Contacts()) {
+ count = UpdateBirthdayEntry(hContact, count, 1, DOB_USERINFO);
+ count = UpdateBirthdayEntry(hContact, count, 1, DOB_PROTOCOL);
+ }
SetBirthdaysCount();
return 0;
@@ -156,23 +156,24 @@ class CBirthdaysDlg : public CBasicListDlg {
LVFINDINFO fi = { 0 };
fi.flags = LVFI_PARAM;
- fi.lParam = hContact;
+ fi.lParam = -hContact;
int idx = m_list.FindItem(-1, &fi);
if (-1 == idx)
- UpdateBirthdayEntry(hContact, m_list.GetItemCount(), IsDlgButtonChecked(m_hwnd, IDC_SHOW_ALL), g_plugin.cShowAgeMode, 1);
+ UpdateBirthdayEntry(hContact, m_list.GetItemCount(), 1, DOB_USERINFO);
else
- UpdateBirthdayEntry(hContact, idx, IsDlgButtonChecked(m_hwnd, IDC_SHOW_ALL), g_plugin.cShowAgeMode, 0);
+ UpdateBirthdayEntry(hContact, idx, 0, DOB_USERINFO);
SetBirthdaysCount();
return 0;
}
//only updates the birthday part of the list view entry. Won't update the szProto and the contact name (those shouldn't change anyway :))
- int UpdateBirthdayEntry(MCONTACT hContact, int entry, int bShowAll, int bShowCurrentAge, int bAdd)
+ int UpdateBirthdayEntry(MCONTACT hContact, int entry, int bAdd, int module)
{
int currentMonth, currentDay;
int res = entry;
+ bool bShowAll = chkShowAll.GetState();
- if (bShowCurrentAge) {
+ if (g_plugin.cShowAgeMode) {
time_t now = Today();
struct tm *today = gmtime(&now);
currentDay = today->tm_mday + 1;
@@ -180,13 +181,13 @@ class CBirthdaysDlg : public CBasicListDlg }
else currentMonth = currentDay = 0;
- int year, month, day;
- int module = GetContactDOB(hContact, year, month, day);
+ int year = 0, month = 0, day = 0;
+ GetContactDOB(hContact, year, month, day, module);
if (bShowAll || IsDOBValid(year, month, day)) {
lastColumn = -1; //list isn't sorted anymore
int dtb = DaysToBirthday(Today(), year, month, day);
int age = GetContactAge(hContact);
- if (bShowCurrentAge)
+ if (g_plugin.cShowAgeMode)
if (month > currentMonth || (month == currentMonth) && (day > currentDay)) // birthday still to come
age--;
@@ -197,7 +198,7 @@ class CBirthdaysDlg : public CBasicListDlg LVITEM item = { 0 };
item.mask = LVIF_TEXT | LVIF_PARAM;
item.iItem = entry;
- item.lParam = hContact;
+ item.lParam = (module == DOB_PROTOCOL) ? hContact : -hContact;
item.pszText = ptszAccName;
if (bAdd)
@@ -281,7 +282,7 @@ public: col.cx = 108;
m_list.InsertColumn(5, &col);
- LoadBirthdays(0);
+ LoadBirthdays();
int column = g_plugin.getByte("SortColumn", 0);
Sort(column);
@@ -310,9 +311,9 @@ public: lastColumn = -1;
}
- void onChange_ShowAll(CCtrlCheck *pCheck)
+ void onChange_ShowAll(CCtrlCheck*)
{
- LoadBirthdays(pCheck->GetState());
+ LoadBirthdays();
}
void onColumnClick(CCtrlListView::TEventInfo *ev)
diff --git a/plugins/WhenWasIt/src/options.cpp b/plugins/WhenWasIt/src/options.cpp index ca7c2e5759..cd4fb8463d 100644 --- a/plugins/WhenWasIt/src/options.cpp +++ b/plugins/WhenWasIt/src/options.cpp @@ -22,8 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. const wchar_t* szShowAgeMode[] = { LPGENW("Upcoming age"), LPGENW("Current age") }; -const wchar_t* szSaveModule[] = { LPGENW("UserInfo module"), LPGENW("Protocol module") }; - const wchar_t* szPopupClick[] = { LPGENW("Nothing"), LPGENW("Dismiss"), LPGENW("Message window") }; 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") }; @@ -74,7 +72,7 @@ class COptionsDlg : public CDlgBase { CCtrlButton btnPreview; CCtrlCheck chkPopups, chkClistIcon, chkDialog, chkOncePerDay; - CCtrlCombo cmbModule, cmbAge, cmbLClick, cmbRClick, cmbNotify; + CCtrlCombo cmbAge, cmbLClick, cmbRClick, cmbNotify; CCtrlColor clrFore, clrBack; public: @@ -84,7 +82,6 @@ public: clrFore(this, IDC_FOREGROUND), clrBack(this, IDC_BACKGROUND), cmbAge(this, IDC_AGE_COMBOBOX), - cmbModule(this, IDC_DEFAULT_MODULE), cmbNotify(this, IDC_NOTIFYFOR), cmbLClick(this, IDC_LEFT_CLICK), cmbRClick(this, IDC_RIGHT_CLICK), @@ -117,9 +114,6 @@ public: for (auto &it : szShowAgeMode) cmbAge.AddString(TranslateW(it)); - for (auto &it : szSaveModule) - cmbModule.AddString(TranslateW(it)); - for (auto &it : szPopupClick) { cmbLClick.AddString(TranslateW(it)); cmbRClick.AddString(TranslateW(it)); @@ -128,7 +122,6 @@ public: for (auto &it : szNotifyFor) cmbNotify.AddString(TranslateW(it)); - cmbModule.SetCurSel(g_plugin.cDefaultModule); cmbLClick.SetCurSel(g_plugin.lPopupClick); cmbRClick.SetCurSel(g_plugin.rPopupClick); cmbNotify.SetCurSel(g_plugin.notifyFor); @@ -176,7 +169,6 @@ public: g_plugin.bUseDialog = IsDlgButtonChecked(m_hwnd, IDC_USE_DIALOG); g_plugin.bIgnoreSubcontacts = IsDlgButtonChecked(m_hwnd, IDC_IGNORE_SUBCONTACTS); g_plugin.bNoBirthdaysPopup = IsDlgButtonChecked(m_hwnd, IDC_NOBIRTHDAYS_POPUP); - g_plugin.cDefaultModule = cmbModule.GetCurSel(); g_plugin.cShowAgeMode = cmbAge.GetCurSel(); g_plugin.lPopupClick = cmbLClick.GetCurSel(); g_plugin.rPopupClick = cmbRClick.GetCurSel(); diff --git a/plugins/WhenWasIt/src/resource.h b/plugins/WhenWasIt/src/resource.h index 57eedddbb2..063a8e2ef8 100644 --- a/plugins/WhenWasIt/src/resource.h +++ b/plugins/WhenWasIt/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by ..\res\WhenWasIt.rc
+// Used by W:\miranda-ng\plugins\WhenWasIt\res\WhenWasIt.rc
//
#define IDD_OPT_WWI 101
#define IDI_BIRTHDAYS 102
@@ -46,7 +46,6 @@ #define IDC_NOBIRTHDAYS_POPUP 1026
#define IDC_COMPATIBILITY 1027
#define IDC_SOUND_NEAR_DAYS_EDIT 1028
-#define IDC_DEFAULT_MODULE 1029
#define IDC_PREVIEW 1030
#define IDC_LEFT_CLICK 1031
#define IDC_RIGHT_CLICK 1032
@@ -69,7 +68,7 @@ //
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 129
+#define _APS_NEXT_RESOURCE_VALUE 130
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1048
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/plugins/WhenWasIt/src/services.cpp b/plugins/WhenWasIt/src/services.cpp index 0226489c98..e5f67af75f 100644 --- a/plugins/WhenWasIt/src/services.cpp +++ b/plugins/WhenWasIt/src/services.cpp @@ -219,8 +219,6 @@ int DoImport(wchar_t *fileName) return 1;
}
- int mode = g_plugin.cDefaultModule;
-
while (!feof(fin)) {
wchar_t buffer[4096];
fgetws(buffer, _countof(buffer), fin);
@@ -244,7 +242,7 @@ int DoImport(wchar_t *fileName) int year, month, day;
swscanf(delAccount, L" : %02d/%02d/%04d", &day, &month, &year);
- SaveBirthday(hContact, year, month, day, mode);
+ SaveBirthday(hContact, year, month, day, SAVE_MODE_STANDARD);
}
else {
CMStringW msg(FORMAT, TranslateT("Could not find UID '%s [%S]' in current database, skipping"), szHandle, szProto);
diff --git a/plugins/WhenWasIt/src/stdafx.h b/plugins/WhenWasIt/src/stdafx.h index ed09270122..d6ffa93b56 100644 --- a/plugins/WhenWasIt/src/stdafx.h +++ b/plugins/WhenWasIt/src/stdafx.h @@ -67,7 +67,7 @@ struct CMPlugin : public PLUGIN<CMPlugin> CMOption<uint32_t> foreground, background;
CMOption<bool> bUsePopups, bUseDialog, bIgnoreSubcontacts, bNoBirthdaysPopup, bOncePerDay, bOpenInBackground;
CMOption<uint16_t> checkInterval, daysInAdvance, popupTimeout, popupTimeoutToday, cDlgTimeout, daysAfter;
- CMOption<uint8_t> cShowAgeMode, cSoundNearDays, cDefaultModule;
+ CMOption<uint8_t> cShowAgeMode, cSoundNearDays;
CMOption<uint8_t> lPopupClick, rPopupClick, notifyFor;
CMPlugin();
diff --git a/plugins/WhenWasIt/src/utils.cpp b/plugins/WhenWasIt/src/utils.cpp index 1318b15a7e..5cdcc29103 100644 --- a/plugins/WhenWasIt/src/utils.cpp +++ b/plugins/WhenWasIt/src/utils.cpp @@ -71,72 +71,33 @@ int Info(char *title, char *format, ...) return MessageBoxA(nullptr, str, title, MB_OK | MB_ICONINFORMATION);
}
-#define HEX_SIZE 8
+///////////////////////////////////////////////////////////////////////////////
-char* BinToHex(int size, uint8_t *data)
+void CheckConvert(void)
{
- char *szresult = nullptr;
- char buffer[32] = { 0 }; //should be more than enough
- int maxSize = size * 2 + HEX_SIZE + 1;
- szresult = (char *) new char[maxSize];
- memset(szresult, 0, maxSize);
- mir_snprintf(buffer, "%0*X", HEX_SIZE, size);
- mir_strcpy(szresult, buffer);
-
- for (int i = 0; i < size; i++) {
- mir_snprintf(buffer, "%02X", data[i]);
- mir_strcpy(szresult + (HEX_SIZE + i * 2), buffer);
- }
- return szresult;
-}
-
-void HexToBin(char *inData, ULONG &size, LPBYTE &outData)
-{
- char buffer[32] = { 0 };
- mir_strcpy(buffer, "0x");
- strncpy(buffer + 2, inData, HEX_SIZE);
- sscanf(buffer, "%x", &size);
- outData = (unsigned char*)new char[size * 2];
-
- char *tmp = inData + HEX_SIZE;
- buffer[4] = '\0'; //mark the end of the string
- for (UINT i = 0; i < size; i++) {
- strncpy(buffer + 2, &tmp[i * 2], 2);
- sscanf(buffer, "%hhx", &outData[i]);
- }
-}
-
-int GetStringFromDatabase(MCONTACT hContact, char *szModule, char *szSettingName, char *szError, char *szResult, size_t size)
-{
- DBVARIANT dbv = { 0 };
- int res = 1;
- size_t len;
- dbv.type = DBVT_ASCIIZ;
- if (db_get(hContact, szModule, szSettingName, &dbv) == 0) {
- res = 0;
- size_t tmp = mir_strlen(dbv.pszVal);
- len = (tmp < size - 1) ? tmp : size - 1;
- strncpy(szResult, dbv.pszVal, len);
- szResult[len] = '\0';
- mir_free(dbv.pszVal);
- }
- else {
- res = 1;
- if (szError) {
- size_t tmp = mir_strlen(szError);
- len = (tmp < size - 1) ? tmp : size - 1;
- strncpy(szResult, szError, len);
- szResult[len] = '\0';
+ if (db_get_b(0, "Compatiblilty", MODULENAME) < 1) {
+ for (auto &hContact : Contacts()) {
+ int bday = db_get_dw(hContact, "UserInfo", "DOBd", -1);
+ if (bday == -1)
+ continue;
+
+ int bmonth = db_get_dw(hContact, "UserInfo", "DOBm");
+ int byear = db_get_dw(hContact, "UserInfo", "DOBy");
+
+ db_unset(hContact, "UserInfo", "DOBd");
+ db_unset(hContact, "UserInfo", "DOBm");
+ db_unset(hContact, "UserInfo", "DOBy");
+
+ db_set_dw(hContact, "UserInfo", "BirthDay", bday);
+ db_set_dw(hContact, "UserInfo", "BirthMonth", bmonth);
+ db_set_dw(hContact, "UserInfo", "BirthYear", byear);
}
- else szResult[0] = '\0';
+
+ db_set_b(0, "Compatiblilty", MODULENAME, 1);
}
- return res;
}
-int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, size_t size)
-{
- return GetStringFromDatabase(0, MODULENAME, szSettingName, szError, szResult, size);
-}
+///////////////////////////////////////////////////////////////////////////////
wchar_t* GetContactID(MCONTACT hContact)
{
@@ -149,6 +110,8 @@ wchar_t* GetContactID(MCONTACT hContact, char *szProto) return (res) ? wcsdup(res) : nullptr;
}
+///////////////////////////////////////////////////////////////////////////////
+
MCONTACT GetContactFromID(wchar_t *szID, char *szProto)
{
for (auto &hContact : Contacts()) {
@@ -171,70 +134,7 @@ MCONTACT GetContactFromID(wchar_t *szID, wchar_t *szProto) return GetContactFromID(szID, protocol);
}
-void ScreenToClient(HWND hWnd, LPRECT rect)
-{
- int cx = rect->right - rect->left;
- int cy = rect->bottom - rect->top;
- POINT pt = { rect->left, rect->top };
- ScreenToClient(hWnd, &pt);
- rect->left = pt.x;
- rect->top = pt.y;
- rect->right = pt.x + cx;
- rect->bottom = pt.y + cy;
-}
-
-void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors)
-{
- if (parentPos->flags & SWP_NOSIZE)
- return;
-
- RECT rParent;
- GetWindowRect(parentPos->hwnd, &rParent);
-
- RECT rChild = AnchorCalcPos(window, &rParent, parentPos, anchors);
- MoveWindow(window, rChild.left, rChild.top, rChild.right - rChild.left, rChild.bottom - rChild.top, FALSE);
-}
-
-RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int anchors)
-{
- RECT rChild;
- GetWindowRect(window, &rChild);
- ScreenToClient(parentPos->hwnd, &rChild);
-
- int cx = rParent->right - rParent->left;
- int cy = rParent->bottom - rParent->top;
- if ((cx == parentPos->cx) && (cy == parentPos->cy))
- return rChild;
-
- if (parentPos->flags & SWP_NOSIZE)
- return rChild;
-
- RECT rTmp;
- rTmp.left = parentPos->x - rParent->left;
- rTmp.right = (parentPos->x + parentPos->cx) - rParent->right;
- rTmp.bottom = (parentPos->y + parentPos->cy) - rParent->bottom;
- rTmp.top = parentPos->y - rParent->top;
-
- cx = (rTmp.left) ? -rTmp.left : rTmp.right;
- cy = (rTmp.top) ? -rTmp.top : rTmp.bottom;
-
- rChild.right += cx;
- rChild.bottom += cy;
- //expanded the window accordingly, now we need to enforce the anchors
- if ((anchors & ANCHOR_LEFT) && (!(anchors & ANCHOR_RIGHT)))
- rChild.right -= cx;
-
- if ((anchors & ANCHOR_TOP) && (!(anchors & ANCHOR_BOTTOM)))
- rChild.bottom -= cy;
-
- if ((anchors & ANCHOR_RIGHT) && (!(anchors & ANCHOR_LEFT)))
- rChild.left += cx;
-
- if ((anchors & ANCHOR_BOTTOM) && (!(anchors & ANCHOR_TOP)))
- rChild.top += cy;
-
- return rChild;
-}
+///////////////////////////////////////////////////////////////////////////////
void CreateToolTip(HWND target, const wchar_t* tooltip, LPARAM width)
{
diff --git a/plugins/WhenWasIt/src/utils.h b/plugins/WhenWasIt/src/utils.h index 5b4d967f28..919f0c7bf8 100644 --- a/plugins/WhenWasIt/src/utils.h +++ b/plugins/WhenWasIt/src/utils.h @@ -35,15 +35,6 @@ int LogInit(); int Log(char *format, ...);
int Info(char *title, char *format, ...);
-char *BinToHex(int size, uint8_t *data);
-void HexToBin(char *inData, ULONG &size, uint8_t *&outData);
-
-void ScreenToClient(HWND hWnd, LPRECT rect);
-void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors);
-RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int anchors);
-
-int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, int size);
-
wchar_t* GetContactID(MCONTACT hContact);
wchar_t* GetContactID(MCONTACT hContact, char *szProto);
MCONTACT GetContactFromID(wchar_t *szID, char *szProto);
@@ -51,4 +42,6 @@ MCONTACT GetContactFromID(wchar_t *szID, wchar_t *szProto); void CreateToolTip(HWND target, const wchar_t *tooltip, LPARAM width);
+void CheckConvert(void);
+
#endif
\ No newline at end of file |