summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/WhenWasIt/src/WhenWasIt.cpp3
-rw-r--r--plugins/WhenWasIt/src/commonheaders.h1
-rw-r--r--plugins/WhenWasIt/src/dlg_handlers.cpp155
-rw-r--r--plugins/WhenWasIt/src/notifiers.cpp51
-rw-r--r--plugins/WhenWasIt/src/utils.cpp166
-rw-r--r--plugins/WhenWasIt/src/utils.h5
-rw-r--r--plugins/WhenWasIt/src/version.h12
7 files changed, 168 insertions, 225 deletions
diff --git a/plugins/WhenWasIt/src/WhenWasIt.cpp b/plugins/WhenWasIt/src/WhenWasIt.cpp
index 496becd813..d5d3217807 100644
--- a/plugins/WhenWasIt/src/WhenWasIt.cpp
+++ b/plugins/WhenWasIt/src/WhenWasIt.cpp
@@ -29,6 +29,8 @@ int hLangpack;
CommonData commonData = {0};
+CLIST_INTERFACE *pcli;
+
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
@@ -53,6 +55,7 @@ extern "C" int __declspec(dllexport) Load(void)
Log("%s", "Entering function " __FUNCTION__);
mir_getLP(&pluginInfo);
+ mir_getCLI();
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(icex);
diff --git a/plugins/WhenWasIt/src/commonheaders.h b/plugins/WhenWasIt/src/commonheaders.h
index 3ab56ea9ff..3434e38223 100644
--- a/plugins/WhenWasIt/src/commonheaders.h
+++ b/plugins/WhenWasIt/src/commonheaders.h
@@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_skin.h>
#include <m_options.h>
#include <m_langpack.h>
+#include <m_clistint.h>
#include <m_contacts.h>
#include <m_popup.h>
#include <m_fontservice.h>
diff --git a/plugins/WhenWasIt/src/dlg_handlers.cpp b/plugins/WhenWasIt/src/dlg_handlers.cpp
index 589e4c27e0..c67a16f68b 100644
--- a/plugins/WhenWasIt/src/dlg_handlers.cpp
+++ b/plugins/WhenWasIt/src/dlg_handlers.cpp
@@ -413,20 +413,20 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
case WM_SHOWWINDOW:
{
- int year, month, day;
TCHAR *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.");
TCHAR *szCurrentModuleTooltip = NULL;
- const int maxSize = 2048;
- TCHAR buffer[maxSize];
char *szProto = GetContactProto(hContact);
- TCHAR *name = GetContactName(hContact, szProto);
- mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("Set birthday for %s:"), name);
- free(name);
+
+ TCHAR buffer[2048];
+ mir_sntprintf(buffer, SIZEOF(buffer), TranslateT("Set birthday for %s:"), pcli->pfnGetContactDisplayName(hContact, 0));
SetWindowText(hWnd, buffer);
+
HWND hDate = GetDlgItem(hWnd, IDC_DATE);
+
+ int year, month, day;
int loc = GetContactDOB(hContact, year, month, day);
- if ( IsDOBValid(year, month, day)) {
- SYSTEMTIME st = {0};
+ if (IsDOBValid(year, month, day)) {
+ SYSTEMTIME st = { 0 };
st.wDay = day;
st.wMonth = month;
st.wYear = year;
@@ -450,7 +450,7 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
DateTime_SetMonthCalColor(hDate, MCSC_TITLEBK, COLOR_BIRTHDAYREMINDER);
szCurrentModuleTooltip = _T("Birthday Reminder");
break;
-
+
case DOB_USERINFO:
DateTime_SetMonthCalColor(hDate, MCSC_TITLEBK, COLOR_USERINFO);
szCurrentModuleTooltip = _T("UserInfo");
@@ -469,14 +469,13 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
CreateToolTip(GetDlgItem(hWnd, IDC_COMPATIBILITY), szTooltipText, 500);
if (szCurrentModuleTooltip)
CreateToolTip(hDate, szCurrentModuleTooltip, 400);
-
- break;
}
+ break;
case WM_DESTROY:
RefreshContactListIcons(hContact); //the birthday might be changed, refresh icon.
Skin_ReleaseIcon((HICON)SendMessage(hWnd, WM_GETICON, ICON_BIG, 0));
- Utils_SaveWindowPosition(hWnd,hContact,ModuleName,"BirthdayWnd");
+ Utils_SaveWindowPosition(hWnd, hContact, ModuleName, "BirthdayWnd");
WindowList_Remove(hAddBirthdayWndsList, hWnd);
break;
@@ -487,22 +486,19 @@ INT_PTR CALLBACK DlgProcAddBirthday(HWND hWnd, UINT msg, WPARAM wParam, LPARAM l
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
- {
- SYSTEMTIME st;
- MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hWnd, GWLP_USERDATA);
- HWND hDate = GetDlgItem(hWnd, IDC_DATE);
- if (DateTime_GetSystemtime(hDate, &st) == GDT_VALID) {
- int mode = SendMessage(GetDlgItem(hWnd, IDC_COMPATIBILITY), CB_GETCURSEL, 0, 0); //SAVE modes in date_utils.h are synced
- SaveBirthday(hContact, st.wYear, st.wMonth, st.wDay, mode);
- }
- else SaveBirthday(hContact, 0, 0, 0, SAVE_MODE_DELETEALL);
+ SYSTEMTIME st;
+ MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hWnd, GWLP_USERDATA);
+ HWND hDate = GetDlgItem(hWnd, IDC_DATE);
+ if (DateTime_GetSystemtime(hDate, &st) == GDT_VALID) {
+ int mode = SendMessage(GetDlgItem(hWnd, IDC_COMPATIBILITY), CB_GETCURSEL, 0, 0); //SAVE modes in date_utils.h are synced
+ SaveBirthday(hContact, st.wYear, st.wMonth, st.wDay, mode);
+ }
+ else SaveBirthday(hContact, 0, 0, 0, SAVE_MODE_DELETEALL);
- if (hBirthdaysDlg != NULL)
- SendMessage(hBirthdaysDlg, WWIM_UPDATE_BIRTHDAY, (WPARAM) hContact, NULL);
+ if (hBirthdaysDlg != NULL)
+ SendMessage(hBirthdaysDlg, WWIM_UPDATE_BIRTHDAY, (WPARAM)hContact, NULL);
- SendMessage(hWnd, WM_CLOSE, 0, 0);
- break;
- }
+ SendMessage(hWnd, WM_CLOSE, 0, 0);
}
break;
}
@@ -522,11 +518,11 @@ void AddAnchorWindowToDeferList(HDWP &hdWnds, HWND window, RECT *rParent, WINDOW
TCHAR *GetBirthdayModule(int module, MCONTACT hContact)
{
switch (module) {
- case DOB_MBIRTHDAY: return _T("mBirthday");
- case DOB_PROTOCOL: return TranslateT("Protocol module");
- case DOB_BIRTHDAYREMINDER: return _T("Birthday Reminder");
- case DOB_USERINFO: return _T("UserInfo");
- case DOB_MICQBIRTHDAY: return _T("mICQBirthday");
+ case DOB_MBIRTHDAY: return _T("mBirthday");
+ case DOB_PROTOCOL: return TranslateT("Protocol module");
+ case DOB_BIRTHDAYREMINDER: return _T("Birthday Reminder");
+ case DOB_USERINFO: return _T("UserInfo");
+ case DOB_MICQBIRTHDAY: return _T("mICQBirthday");
}
return NA;
}
@@ -540,13 +536,13 @@ struct BirthdaysSortParams{
INT_PTR CALLBACK BirthdaysCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam)
{
- BirthdaysSortParams params = *(BirthdaysSortParams *) myParam;
+ BirthdaysSortParams params = *(BirthdaysSortParams *)myParam;
const int maxSize = 1024;
TCHAR text1[maxSize];
TCHAR text2[maxSize];
long value1, value2;
- ListView_GetItemText(params.hList, (int) lParam1, params.column, text1, maxSize);
- ListView_GetItemText(params.hList, (int) lParam2, params.column, text2, maxSize);
+ ListView_GetItemText(params.hList, (int)lParam1, params.column, text1, maxSize);
+ ListView_GetItemText(params.hList, (int)lParam2, params.column, text2, maxSize);
int res = 0;
@@ -559,7 +555,7 @@ INT_PTR CALLBACK BirthdaysCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam
res = (err1[0]) ? 1 : -1;
else if (value1 < value2)
res = -1;
- else
+ else
res = (value1 != value2);
}
else res = _tcsicmp(text1, text2);
@@ -595,10 +591,10 @@ int UpdateBirthdayEntry(HWND hList, MCONTACT hContact, int entry, int bShowAll,
PROTOACCOUNT *pAcc = ProtoGetAccount(szProto);
TCHAR *ptszAccName = (pAcc == NULL) ? TranslateT("Unknown") : pAcc->tszAccountName;
- LVITEM item = {0};
+ LVITEM item = { 0 };
item.mask = LVIF_TEXT | LVIF_PARAM;
item.iItem = entry;
- item.lParam = (LPARAM) hContact;
+ item.lParam = (LPARAM)hContact;
item.pszText = ptszAccName;
if (bAdd)
@@ -606,8 +602,7 @@ int UpdateBirthdayEntry(HWND hList, MCONTACT hContact, int entry, int bShowAll,
else
ListView_SetItemText(hList, entry, 0, ptszAccName);
- ptrT name( GetContactName(hContact, szProto));
- ListView_SetItemText(hList, entry, 1, name);
+ ListView_SetItemText(hList, entry, 1, pcli->pfnGetContactDisplayName(hContact, 0));
TCHAR buffer[2048];
if ((dtb <= 366) && (dtb >= 0))
@@ -636,7 +631,7 @@ int UpdateBirthdayEntry(HWND hList, MCONTACT hContact, int entry, int bShowAll,
else if (!bShowAll && !bAdd)
ListView_DeleteItem(hList, entry);
- return res;
+ return res;
}
static LRESULT CALLBACK BirthdaysListSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -653,21 +648,19 @@ static LRESULT CALLBACK BirthdaysListSubclassProc(HWND hWnd, UINT msg, WPARAM wP
break;
case WM_LBUTTONDBLCLK:
- {
- int count = ListView_GetItemCount(hWnd);
- MCONTACT hContact;
- LVITEM item = {0};
- item.mask = LVIF_PARAM;
- for (int i = 0; i < count; i++) {
- if (ListView_GetItemState(hWnd, i, LVIS_SELECTED)) {
- item.iItem = i;
- ListView_GetItem(hWnd, &item);
- hContact = (MCONTACT)item.lParam;
- CallService(MS_WWI_ADD_BIRTHDAY, (WPARAM) hContact, 0);
- }
+ int count = ListView_GetItemCount(hWnd);
+ MCONTACT hContact;
+ LVITEM item = { 0 };
+ item.mask = LVIF_PARAM;
+ for (int i = 0; i < count; i++) {
+ if (ListView_GetItemState(hWnd, i, LVIS_SELECTED)) {
+ item.iItem = i;
+ ListView_GetItem(hWnd, &item);
+ hContact = (MCONTACT)item.lParam;
+ CallService(MS_WWI_ADD_BIRTHDAY, (WPARAM)hContact, 0);
}
- break;
}
+ break;
}
return mir_callNextSubclass(hWnd, BirthdaysListSubclassProc, msg, wParam, lParam);
}
@@ -687,7 +680,7 @@ int LoadBirthdays(HWND hWnd, int bShowAll)
int count = 0;
for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
- count = UpdateBirthdayEntry(hList, hContact, count, bShowAll, commonData.cShowAgeMode, 1);
+ count = UpdateBirthdayEntry(hList, hContact, count, bShowAll, commonData.cShowAgeMode, 1);
SetBirthdaysCount(hWnd);
return 0;
@@ -730,12 +723,12 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
LoadBirthdays(hWnd, 0);
int column = db_get_b(NULL, ModuleName, "SortColumn", 0);
- BirthdaysSortParams params = {0};
+ BirthdaysSortParams params = { 0 };
params.hList = GetDlgItem(hWnd, IDC_BIRTHDAYS_LIST);
params.column = column;
- ListView_SortItemsEx(params.hList, BirthdaysCompare, (LPARAM) &params);
+ ListView_SortItemsEx(params.hList, BirthdaysCompare, (LPARAM)&params);
- Utils_RestoreWindowPosition(hWnd,NULL,ModuleName,"BirthdayList");
+ Utils_RestoreWindowPosition(hWnd, NULL, ModuleName, "BirthdayList");
}
return TRUE;
@@ -744,13 +737,13 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
break;
case WWIM_UPDATE_BIRTHDAY:
- {//wParam = hContact
- HWND hList = GetDlgItem(hWnd, IDC_BIRTHDAYS_LIST);
+ {
MCONTACT hContact = wParam;
+ HWND hList = GetDlgItem(hWnd, IDC_BIRTHDAYS_LIST);
int i;
int count = ListView_GetItemCount(hList);
//int bShowCurrentAge = db_get_b(NULL, ModuleName, "ShowCurrentAge", 0);
- LVITEM item = {0};
+ LVITEM item = { 0 };
int found = 0;
item.mask = LVIF_PARAM;
@@ -758,11 +751,11 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
item.iItem = i;
ListView_GetItem(hList, &item);
if (hContact == (MCONTACT)item.lParam) {
- UpdateBirthdayEntry(hList, hContact, i, IsDlgButtonChecked(hWnd, IDC_SHOW_ALL), commonData.cShowAgeMode, 0);
+ UpdateBirthdayEntry(hList, hContact, i, IsDlgButtonChecked(hWnd, IDC_SHOW_ALL), commonData.cShowAgeMode, 0);
found = 1;
}
}
- if ( !found)
+ if (!found)
UpdateBirthdayEntry(hList, hContact, count, IsDlgButtonChecked(hWnd, IDC_SHOW_ALL), commonData.cShowAgeMode, 1);
SetBirthdaysCount(hWnd);
@@ -773,7 +766,7 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
{
HDWP hdWnds = BeginDeferWindowPos(2);
RECT rParent;
- WINDOWPOS *wndPos = (WINDOWPOS *) lParam;
+ WINDOWPOS *wndPos = (WINDOWPOS *)lParam;
GetWindowRect(hWnd, &rParent);
if (wndPos->cx < MIN_BIRTHDAYS_WIDTH)
@@ -803,28 +796,26 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
break;
case WM_NOTIFY:
- switch (((LPNMHDR) lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case IDC_BIRTHDAYS_LIST:
switch (((LPNMHDR)lParam)->code) {
case LVN_COLUMNCLICK:
- {
- LPNMLISTVIEW lv = (LPNMLISTVIEW) lParam;
- int column = lv->iSubItem;
- db_set_b(NULL, ModuleName, "SortColumn", column);
- BirthdaysSortParams params = {0};
- params.hList = GetDlgItem(hWnd, IDC_BIRTHDAYS_LIST);
- params.column = column;
- ListView_SortItemsEx(params.hList, BirthdaysCompare, (LPARAM) &params);
- lastColumn = (params.column == lastColumn) ? -1 : params.column;
- break;
- }
+ LPNMLISTVIEW lv = (LPNMLISTVIEW)lParam;
+ int column = lv->iSubItem;
+ db_set_b(NULL, ModuleName, "SortColumn", column);
+ BirthdaysSortParams params = { 0 };
+ params.hList = GetDlgItem(hWnd, IDC_BIRTHDAYS_LIST);
+ params.column = column;
+ ListView_SortItemsEx(params.hList, BirthdaysCompare, (LPARAM)&params);
+ lastColumn = (params.column == lastColumn) ? -1 : params.column;
+ break;
}
}
break;
case WM_DESTROY:
hBirthdaysDlg = NULL;
- Utils_SaveWindowPosition(hWnd,NULL,ModuleName,"BirthdayList");
+ Utils_SaveWindowPosition(hWnd, NULL, ModuleName, "BirthdayList");
Skin_ReleaseIcon((HICON)SendMessage(hWnd, WM_GETICON, ICON_BIG, 0));
lastColumn = -1;
break;
@@ -837,13 +828,13 @@ INT_PTR CALLBACK DlgProcBirthdays(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPa
INT_PTR CALLBACK UpcomingCompare(LPARAM lParam1, LPARAM lParam2, LPARAM myParam)
{
HWND hList = GetDlgItem(hUpcomingDlg, IDC_UPCOMING_LIST);
- LVITEM item = {0};
- item.iItem = (int) lParam1;
+ LVITEM item = { 0 };
+ item.iItem = (int)lParam1;
item.mask = LVIF_PARAM;
ListView_GetItem(hList, &item);
int dtb1 = item.lParam;
- item.iItem = (int) lParam2;
+ item.iItem = (int)lParam2;
ListView_GetItem(hList, &item);
int dtb2 = item.lParam;
@@ -899,15 +890,15 @@ INT_PTR CALLBACK DlgProcUpcoming(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPar
case WWIM_ADD_UPCOMING_BIRTHDAY:
{
- PUpcomingBirthday data = (PUpcomingBirthday) wParam;
+ PUpcomingBirthday data = (PUpcomingBirthday)wParam;
HWND hList = GetDlgItem(hWnd, IDC_UPCOMING_LIST);
- LVITEM item = {0};
+ LVITEM item = { 0 };
int index = ListView_GetItemCount(hList);
item.iItem = index;
item.mask = LVIF_PARAM | LVIF_TEXT;
//item.lParam = (LPARAM) data->hContact;
- item.lParam = (LPARAM) data->dtb;
+ item.lParam = (LPARAM)data->dtb;
item.pszText = data->message;
ListView_InsertItem(hList, &item);
diff --git a/plugins/WhenWasIt/src/notifiers.cpp b/plugins/WhenWasIt/src/notifiers.cpp
index 71e701dc7b..1e0dbd1e8a 100644
--- a/plugins/WhenWasIt/src/notifiers.cpp
+++ b/plugins/WhenWasIt/src/notifiers.cpp
@@ -66,16 +66,16 @@ TCHAR *BuildDABText(int dab, TCHAR *name, TCHAR *text, int size)
int PopupNotifyBirthday(MCONTACT hContact, int dtb, int age)
{
- TCHAR *name = GetContactName(hContact, NULL);
- const int MAX_SIZE = 1024;
- TCHAR text[MAX_SIZE];
- //int bIgnoreSubcontacts = db_get_b(NULL, ModuleName, "IgnoreSubcontacts", FALSE);
if (commonData.bIgnoreSubcontacts) {
MCONTACT hMetacontact = (MCONTACT)CallService(MS_MC_GETMETACONTACT, (WPARAM) hContact, 0);
if ((hMetacontact) && (hMetacontact != hContact)) //not main metacontact
return 0;
}
- BuildDTBText(dtb, name, text, MAX_SIZE);
+
+ TCHAR *name = pcli->pfnGetContactDisplayName(hContact, 0);
+
+ TCHAR text[1024];
+ BuildDTBText(dtb, name, text, SIZEOF(text));
int gender = GetContactGender(hContact);
POPUPDATAT pd = {0};
@@ -104,22 +104,21 @@ int PopupNotifyBirthday(MCONTACT hContact, int dtb, int age)
PUAddPopupT(&pd);
- free(name);
return 0;
}
int PopupNotifyMissedBirthday(MCONTACT hContact, int dab, int age)
{
- TCHAR *name = GetContactName(hContact, NULL);
- const int MAX_SIZE = 1024;
- TCHAR text[MAX_SIZE];
- //int bIgnoreSubcontacts = db_get_b(NULL, ModuleName, "IgnoreSubcontacts", FALSE);
if (commonData.bIgnoreSubcontacts) {
MCONTACT hMetacontact = (MCONTACT)CallService(MS_MC_GETMETACONTACT, (WPARAM) hContact, 0);
if (hMetacontact && hMetacontact != hContact) //not main metacontact
return 0;
}
- BuildDABText(dab, name, text, MAX_SIZE);
+
+ TCHAR *name = pcli->pfnGetContactDisplayName(hContact, 0);
+
+ TCHAR text[1024];
+ BuildDABText(dab, name, text, SIZEOF(text));
int gender = GetContactGender(hContact);
POPUPDATAT pd = {0};
@@ -147,23 +146,20 @@ int PopupNotifyMissedBirthday(MCONTACT hContact, int dab, int age)
mir_sntprintf(pd.lptzText, MAX_SECONDLINE, TranslateT("%s\n%s just turned %d."), text, sex, age);
PUAddPopupT(&pd);
-
- free(name);
return 0;
}
int DialogNotifyBirthday(MCONTACT hContact, int dtb, int age)
{
- TCHAR *name = GetContactName(hContact, NULL);
- const int MAX_SIZE = 1024;
- TCHAR text[MAX_SIZE];
-
- BuildDTBText(dtb, name, text, MAX_SIZE);
- if ( !hUpcomingDlg) {
+ TCHAR *name = pcli->pfnGetContactDisplayName(hContact, 0);
+
+ TCHAR text[1024];
+ BuildDTBText(dtb, name, text, SIZEOF(text));
+ if (!hUpcomingDlg) {
hUpcomingDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_UPCOMING), NULL, DlgProcUpcoming);
ShowWindow(hUpcomingDlg, commonData.bOpenInBackground ? SW_SHOWNOACTIVATE : SW_SHOW);
}
-
+
TUpcomingBirthday data = {0};
data.name = name;
data.message = text;
@@ -172,19 +168,15 @@ int DialogNotifyBirthday(MCONTACT hContact, int dtb, int age)
data.age = age;
SendMessage(hUpcomingDlg, WWIM_ADD_UPCOMING_BIRTHDAY, (WPARAM) &data, NULL);
-
- free(name);
-
return 0;
}
int DialogNotifyMissedBirthday(MCONTACT hContact, int dab, int age)
{
- TCHAR *name = GetContactName(hContact, NULL);
- const int MAX_SIZE = 1024;
- TCHAR text[MAX_SIZE];
-
- BuildDABText(dab, name, text, MAX_SIZE);
+ TCHAR *name = pcli->pfnGetContactDisplayName(hContact, 0);
+
+ TCHAR text[1024];
+ BuildDABText(dab, name, text, SIZEOF(text));
if ( !hUpcomingDlg) {
hUpcomingDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_UPCOMING), NULL, DlgProcUpcoming);
ShowWindow(hUpcomingDlg, commonData.bOpenInBackground ? SW_SHOWNOACTIVATE : SW_SHOW);
@@ -198,9 +190,6 @@ int DialogNotifyMissedBirthday(MCONTACT hContact, int dab, int age)
data.age = age;
SendMessage(hUpcomingDlg, WWIM_ADD_UPCOMING_BIRTHDAY, (WPARAM) &data, NULL);
-
- free(name);
-
return 0;
}
diff --git a/plugins/WhenWasIt/src/utils.cpp b/plugins/WhenWasIt/src/utils.cpp
index ec04582ed2..11f10e26e6 100644
--- a/plugins/WhenWasIt/src/utils.cpp
+++ b/plugins/WhenWasIt/src/utils.cpp
@@ -31,36 +31,30 @@ int LogInit()
int Log(char *format, ...)
{
-#ifdef _DEBUG
- char str[4096];
- va_list vararg;
- int tBytes;
- FILE *fout = fopen(LOG_FILE, "at");
- if ( !fout)
- {
-// MessageBox(0, "can't open file", NULL, MB_OK);
+ #ifdef _DEBUG
+ char str[4096];
+ va_list vararg;
+ int tBytes;
+ FILE *fout = fopen(LOG_FILE, "at");
+ if (!fout)
return -1;
- }
- time_t tNow = time(NULL);
- struct tm *now = localtime(&tNow);
- strftime(str, sizeof(str), "%d %b %Y @ %H:%M:%S: ", now);
- fputs(str, fout);
- va_start(vararg, format);
-
- tBytes = mir_vsnprintf(str, sizeof(str), format, vararg);
- if (tBytes > 0)
- {
+
+ time_t tNow = time(NULL);
+ struct tm *now = localtime(&tNow);
+ strftime(str, sizeof(str), "%d %b %Y @ %H:%M:%S: ", now);
+ fputs(str, fout);
+ va_start(vararg, format);
+
+ tBytes = mir_vsnprintf(str, sizeof(str), format, vararg);
+ if (tBytes > 0)
str[tBytes] = 0;
- }
- va_end(vararg);
- if (str[strlen(str) - 1] != '\n')
- {
+ va_end(vararg);
+ if (str[strlen(str) - 1] != '\n')
strcat(str, "\n");
- }
- fputs(str, fout);
- fclose(fout);
-#endif
+ fputs(str, fout);
+ fclose(fout);
+ #endif
return 0;
}
@@ -72,80 +66,70 @@ int Info(char *title, char *format, ...)
va_start(vararg, format);
tBytes = mir_vsnprintf(str, sizeof(str), format, vararg);
if (tBytes > 0)
- {
- str[tBytes] = 0;
- }
+ str[tBytes] = 0;
va_end(vararg);
- return MessageBoxA(0, str, title, MB_OK | MB_ICONINFORMATION);
+ return MessageBoxA(0, str, title, MB_OK | MB_ICONINFORMATION);
}
#define HEX_SIZE 8
-char *BinToHex(int size, PBYTE data)
+char* BinToHex(int size, PBYTE data)
{
char *szresult = NULL;
- char buffer[32] = {0}; //should be more than enough
+ char buffer[32] = { 0 }; //should be more than enough
int maxSize = size * 2 + HEX_SIZE + 1;
- szresult = (char *) new char[ maxSize ];
+ szresult = (char *) new char[maxSize];
memset(szresult, 0, maxSize);
mir_snprintf(buffer, SIZEOF(buffer), "%0*X", HEX_SIZE, size);
strcpy(szresult, buffer);
- int i;
- for (i = 0; i < size; i++)
- {
- mir_snprintf(buffer, SIZEOF(buffer), "%02X", data[i]);
- strcpy(szresult + (HEX_SIZE + i * 2), buffer);
- }
- return szresult;
+
+ for (int i = 0; i < size; i++) {
+ mir_snprintf(buffer, SIZEOF(buffer), "%02X", data[i]);
+ strcpy(szresult + (HEX_SIZE + i * 2), buffer);
+ }
+ return szresult;
}
void HexToBin(char *inData, ULONG &size, LPBYTE &outData)
{
- char buffer[32] = {0};
+ char buffer[32] = { 0 };
strcpy(buffer, "0x");
strncpy(buffer + 2, inData, HEX_SIZE);
sscanf(buffer, "%x", &size);
- outData = (unsigned char*)new char[size*2];
- UINT i;
- //size = i;
+ outData = (unsigned char*)new char[size * 2];
+
char *tmp = inData + HEX_SIZE;
buffer[4] = '\0'; //mark the end of the string
- for (i = 0; i < size; i++)
- {
- strncpy(buffer + 2, &tmp[i * 2], 2);
- sscanf(buffer, "%x", &outData[i]);
- }
- i = size;
+ for (UINT i = 0; i < size; i++) {
+ strncpy(buffer + 2, &tmp[i * 2], 2);
+ sscanf(buffer, "%x", &outData[i]);
+ }
}
int GetStringFromDatabase(MCONTACT hContact, char *szModule, char *szSettingName, char *szError, char *szResult, size_t size)
{
- DBVARIANT dbv = {0};
+ 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 = strlen(dbv.pszVal);
+ if (db_get(hContact, szModule, szSettingName, &dbv) == 0) {
+ res = 0;
+ size_t tmp = 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 = strlen(szError);
len = (tmp < size - 1) ? tmp : size - 1;
- strncpy(szResult, dbv.pszVal, len);
+ strncpy(szResult, szError, len);
szResult[len] = '\0';
- mir_free(dbv.pszVal);
- }
- else{
- res = 1;
- if (szError)
- {
- size_t tmp = strlen(szError);
- len = (tmp < size - 1) ? tmp : size - 1;
- strncpy(szResult, szError, len);
- szResult[len] = '\0';
- }
- else{
- szResult[0] = '\0';
- }
}
+ else szResult[0] = '\0';
+ }
return res;
}
@@ -154,42 +138,20 @@ int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, si
return GetStringFromDatabase(NULL, ModuleName, szSettingName, szError, szResult, size);
}
-
-#pragma warning (disable: 4312)
-TCHAR *GetContactName(MCONTACT hContact, char *szProto)
-{
- CONTACTINFO ctInfo = { sizeof(ctInfo) };
- ctInfo.szProto = (szProto) ? szProto : GetContactProto(hContact);
- ctInfo.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- ctInfo.hContact = hContact;
- //_debug_message("retrieving contact name for %d", hContact);
- INT_PTR ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo);
- //_debug_message(" contact name %s", ctInfo.pszVal);
- TCHAR *buffer;
- if ( !ret)
- buffer = _tcsdup(ctInfo.pszVal);
-
- mir_free(ctInfo.pszVal);
- if (ret)
- return NULL;
-
- return buffer;
-}
-
-TCHAR *GetContactID(MCONTACT hContact)
+TCHAR* GetContactID(MCONTACT hContact)
{
return GetContactID(hContact, GetContactProto(hContact));
}
-TCHAR *GetContactID(MCONTACT hContact, char *szProto)
+TCHAR* GetContactID(MCONTACT hContact, char *szProto)
{
CONTACTINFO ctInfo = { sizeof(ctInfo) };
ctInfo.szProto = szProto;
ctInfo.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
ctInfo.hContact = hContact;
- INT_PTR ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo);
+ INT_PTR ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ctInfo);
TCHAR *buffer;
- if ( !ret) {
+ if (!ret) {
TCHAR tmp[16];
switch (ctInfo.type) {
case CNFT_BYTE:
@@ -241,11 +203,9 @@ MCONTACT GetContactFromID(TCHAR *szID, wchar_t *szProto)
void ScreenToClient(HWND hWnd, LPRECT rect)
{
- POINT pt;
int cx = rect->right - rect->left;
int cy = rect->bottom - rect->top;
- pt.x = rect->left;
- pt.y = rect->top;
+ POINT pt = { rect->left, rect->top };
ScreenToClient(hWnd, &pt);
rect->left = pt.x;
rect->top = pt.y;
@@ -284,10 +244,10 @@ RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos,
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;
-
+ cy = (rTmp.top) ? -rTmp.top : rTmp.bottom;
+
rChild.right += cx;
rChild.bottom += cy;
//expanded the window accordingly, now we need to enforce the anchors
@@ -304,4 +264,4 @@ RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos,
rChild.top += cy;
return rChild;
-} \ No newline at end of file
+}
diff --git a/plugins/WhenWasIt/src/utils.h b/plugins/WhenWasIt/src/utils.h
index ce7001b6dd..a90f9a83f3 100644
--- a/plugins/WhenWasIt/src/utils.h
+++ b/plugins/WhenWasIt/src/utils.h
@@ -44,9 +44,8 @@ RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos,
int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, int size);
-TCHAR *GetContactName(MCONTACT hContact, char *szProto);
-TCHAR *GetContactID(MCONTACT hContact);
-TCHAR *GetContactID(MCONTACT hContact, char *szProto);
+TCHAR* GetContactID(MCONTACT hContact);
+TCHAR* GetContactID(MCONTACT hContact, char *szProto);
MCONTACT GetContactFromID(TCHAR *szID, char *szProto);
MCONTACT GetContactFromID(TCHAR *szID, wchar_t *szProto);
diff --git a/plugins/WhenWasIt/src/version.h b/plugins/WhenWasIt/src/version.h
index c2e9ecf29a..1959c0e023 100644
--- a/plugins/WhenWasIt/src/version.h
+++ b/plugins/WhenWasIt/src/version.h
@@ -1,14 +1,14 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 3
-#define __RELEASE_NUM 3
-#define __BUILD_NUM 4
+#define __RELEASE_NUM 3
+#define __BUILD_NUM 5
#include <stdver.h>
-#define __PLUGIN_NAME "Birthday reminder"
-#define __FILENAME "WhenWasIt.dll"
+#define __PLUGIN_NAME "Birthday reminder"
+#define __FILENAME "WhenWasIt.dll"
#define __DESCRIPTION "Notifies you of upcoming birthdays."
-#define __AUTHOR "Cristian Libotean"
-#define __AUTHOREMAIL "eblis102@yahoo.com"
+#define __AUTHOR "Cristian Libotean"
+#define __AUTHOREMAIL "eblis102@yahoo.com"
#define __AUTHORWEB "http://miranda-ng.org/p/WhenWasIt/"
#define __COPYRIGHT "© 2006-2011 Cristian Libotean"