summaryrefslogtreecommitdiff
path: root/plugins/WhenWasIt/src/notifiers.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-02-15 14:16:39 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-02-15 14:16:39 +0000
commit1cf6571cfa07177c3cccb21e58bd4c32842c8ae7 (patch)
treedac228d45bddf6be2e27bc29b00b5c1495dfface /plugins/WhenWasIt/src/notifiers.cpp
parentc34659715b28686158d512ba674f8c8529986788 (diff)
fix for a memory allocation conflict in WWI
git-svn-id: http://svn.miranda-ng.org/main/trunk@8129 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/WhenWasIt/src/notifiers.cpp')
-rw-r--r--plugins/WhenWasIt/src/notifiers.cpp51
1 files changed, 20 insertions, 31 deletions
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;
}