summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-17 08:35:51 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-17 08:35:51 +0000
commitee2e419778605a5445474a33a29f2cfbb7eed245 (patch)
tree404194e1d202f6433693f3833792e940c04e2d7e
parent1ca120b165c2f2d9f521a04bfc31c7956d2ce422 (diff)
bunch of fixes for various memory-related problems
git-svn-id: http://svn.miranda-ng.org/main/trunk@1001 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/NewEventNotify/neweventnotify.h65
-rw-r--r--plugins/NewEventNotify/popup.cpp140
-rw-r--r--plugins/NewXstatusNotify/main.cpp1
-rw-r--r--plugins/NewXstatusNotify/xstatus.cpp19
-rw-r--r--plugins/Sessions/Src/Utils.cpp75
-rw-r--r--plugins/YAPP/message_pump.cpp116
-rw-r--r--plugins/YAPP/popwin.cpp39
-rw-r--r--plugins/YAPP/popwin.h26
-rw-r--r--plugins/YAPP/services.cpp91
-rw-r--r--protocols/Gadu-Gadu/avatar.cpp3
10 files changed, 253 insertions, 322 deletions
diff --git a/plugins/NewEventNotify/neweventnotify.h b/plugins/NewEventNotify/neweventnotify.h
index c00ba0012e..3818e410e9 100644
--- a/plugins/NewEventNotify/neweventnotify.h
+++ b/plugins/NewEventNotify/neweventnotify.h
@@ -154,30 +154,30 @@
//---------------------------
//---Structures
-typedef struct PLUGIN_OPTIONS_struct
+struct PLUGIN_OPTIONS
{
- HINSTANCE hInst;
- BOOL bDisable;
- BOOL bPreview;
- BOOL bMenuitem;
- BOOL bDefaultColorMsg;
- BOOL bDefaultColorUrl;
- BOOL bDefaultColorFile;
- BOOL bDefaultColorOthers;
- COLORREF colBackMsg;
- COLORREF colTextMsg;
- COLORREF colBackUrl;
- COLORREF colTextUrl;
- COLORREF colBackFile;
- COLORREF colTextFile;
- COLORREF colBackOthers;
- COLORREF colTextOthers;
- UINT maskNotify;
- UINT maskActL;
- UINT maskActR;
- UINT maskActTE;
- BOOL bMsgWindowCheck;
- BOOL bMsgReplyWindow;
+ HINSTANCE hInst;
+ BOOL bDisable;
+ BOOL bPreview;
+ BOOL bMenuitem;
+ BOOL bDefaultColorMsg;
+ BOOL bDefaultColorUrl;
+ BOOL bDefaultColorFile;
+ BOOL bDefaultColorOthers;
+ COLORREF colBackMsg;
+ COLORREF colTextMsg;
+ COLORREF colBackUrl;
+ COLORREF colTextUrl;
+ COLORREF colBackFile;
+ COLORREF colTextFile;
+ COLORREF colBackOthers;
+ COLORREF colTextOthers;
+ UINT maskNotify;
+ UINT maskActL;
+ UINT maskActR;
+ UINT maskActTE;
+ BOOL bMsgWindowCheck;
+ BOOL bMsgReplyWindow;
int iDelayMsg;
int iDelayUrl;
int iDelayFile;
@@ -192,28 +192,29 @@ typedef struct PLUGIN_OPTIONS_struct
BOOL bHideSend;
BOOL bNoRSS;
BOOL bReadCheck;
-} PLUGIN_OPTIONS;
+};
-typedef struct EVENT_DATA_EX{
+struct EVENT_DATA_EX
+{
HANDLE hEvent;
int number;
struct EVENT_DATA_EX* next;
struct EVENT_DATA_EX* prev;
-} EVENT_DATA_EX;
+};
-typedef struct PLUGIN_DATA_struct {
- UINT eventType;
- HANDLE hContact;
- PLUGIN_OPTIONS* pluginOptions;
+struct PLUGIN_DATA
+{
+ UINT eventType;
+ HANDLE hContact;
+ PLUGIN_OPTIONS* pluginOptions;
HWND hWnd;
- int isUnicode;
struct EVENT_DATA_EX* firstEventData;
struct EVENT_DATA_EX* firstShowEventData;
struct EVENT_DATA_EX* lastEventData;
long countEvent;
long iSeconds;
int iLock;
-} PLUGIN_DATA;
+};
//---------------------------
//---External Procedure Definitions
diff --git a/plugins/NewEventNotify/popup.cpp b/plugins/NewEventNotify/popup.cpp
index be2f1b2ba8..355ef6cc86 100644
--- a/plugins/NewEventNotify/popup.cpp
+++ b/plugins/NewEventNotify/popup.cpp
@@ -141,7 +141,7 @@ static BOOL CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
break;
case UM_FREEPLUGINDATA:
PopupCount--;
- free(pdata);
+ mir_free(pdata);
return TRUE;
case UM_INITPOPUP:
pdata->hWnd = hWnd;
@@ -187,45 +187,39 @@ static TCHAR* GetEventPreview(DBEVENTINFO *dbei)
if (dbei->pBlob) {
if (dbei->flags & DBEF_UTF) {
// utf-8 in blob
- char* com = mir_utf8encodeT((TCHAR*)dbei->pBlob);
- comment1 = _A2T(com);
- mir_free(com);
+ comment1 = mir_utf8decodeT((char*)dbei->pBlob);
}
else if (dbei->cbBlob == (_tcslen((TCHAR *)dbei->pBlob)+1)*(sizeof(TCHAR)+1)) {
// wchar in blob (the old hack)
comment1 = mir_tstrdup((TCHAR*)dbei->pBlob);
}
- else comment1 = _A2T((char *)dbei->pBlob);
+ else comment1 = mir_a2t((char *)dbei->pBlob);
}
commentFix = POPUP_COMMENT_MESSAGE;
break;
case EVENTTYPE_URL:
// url
- if (dbei->pBlob) comment2 = _A2T((char *)dbei->pBlob);
+ if (dbei->pBlob) comment2 = mir_a2t((char *)dbei->pBlob);
// comment
- if (dbei->pBlob) comment1 = _A2T((char *)dbei->pBlob + strlen((char *)dbei->pBlob) + 1);
+ if (dbei->pBlob) comment1 = mir_a2t((char *)dbei->pBlob + strlen((char *)dbei->pBlob) + 1);
commentFix = POPUP_COMMENT_URL;
break;
case EVENTTYPE_FILE:
// filenames
if (dbei->pBlob) {
- if (dbei->flags & DBEF_UTF) {
- char* com = mir_utf8encode((char*)dbei->pBlob + 4);
- comment2 = _A2T(com);
- mir_free(com);
- }
- else comment2 = _A2T((char*)dbei->pBlob + 4);
+ if (dbei->flags & DBEF_UTF)
+ comment2 = mir_utf8decodeT((char*)dbei->pBlob + 4);
+ else
+ comment2 = mir_a2t((char*)dbei->pBlob + 4);
}
// description
if (dbei->pBlob) {
- if (dbei->flags & DBEF_UTF) {
- char* com = mir_utf8encode((char *)dbei->pBlob + strlen((char *)dbei->pBlob + 4) + 1);
- comment1 = _A2T(com);
- mir_free(com);
- }
- else comment1 = _A2T((char *)dbei->pBlob + strlen((char *)dbei->pBlob + 4) + 1);
+ if (dbei->flags & DBEF_UTF)
+ comment1 = mir_utf8decodeT((char *)dbei->pBlob + strlen((char *)dbei->pBlob + 4) + 1);
+ else
+ comment1 = mir_a2t((char *)dbei->pBlob + strlen((char *)dbei->pBlob + 4) + 1);
}
commentFix = POPUP_COMMENT_FILE;
break;
@@ -275,20 +269,16 @@ static TCHAR* GetEventPreview(DBEVENTINFO *dbei)
_snprintf(szUin, 16, "%d", *((DWORD*)dbei->pBlob));
if (strlen(pszNick) > 0) {
- if (dbei->flags & DBEF_UTF) {
- char *nick = mir_utf8encode(pszNick);
- szNick = mir_a2t(nick);
- mir_free(nick);
- }
- else szNick = mir_a2t(pszNick);
+ if (dbei->flags & DBEF_UTF)
+ szNick = mir_utf8decodeT(pszNick);
+ else
+ szNick = mir_a2t(pszNick);
}
else if (strlen(pszEmail) > 0) {
- if (dbei->flags & DBEF_UTF) {
- char *nick = mir_utf8encode(pszEmail);
- szNick = mir_a2t(nick);
- mir_free(nick);
- }
- else szNick = mir_a2t(pszEmail);
+ if (dbei->flags & DBEF_UTF)
+ szNick = mir_utf8decodeT(pszEmail);
+ else
+ szNick = mir_a2t(pszEmail);
}
else if (*((DWORD*)dbei->pBlob) > 0)
szNick = mir_a2t(szUin);
@@ -316,21 +306,15 @@ static TCHAR* GetEventPreview(DBEVENTINFO *dbei)
_snprintf(szUin, 16, "%d", *((DWORD*)dbei->pBlob));
if (strlen(pszNick) > 0) {
if (dbei->flags & DBEF_UTF)
- {
- char *nick = mir_utf8encode(pszNick);
- szNick = mir_a2t(nick);
- mir_free(nick);
- }
- else szNick = mir_a2t(pszNick);
+ szNick = mir_utf8decodeT(pszNick);
+ else
+ szNick = mir_a2t(pszNick);
}
else if (strlen(pszEmail) > 0) {
if (dbei->flags & DBEF_UTF)
- {
- char *nick = mir_utf8encode(pszEmail);
- szNick = mir_a2t(nick);
- mir_free(nick);
- }
- else szNick = mir_a2t(pszEmail);
+ szNick = mir_utf8decodeT(pszEmail);
+ else
+ szNick = mir_a2t(pszEmail);
}
else if (*((DWORD*)dbei->pBlob) > 0)
szNick = mir_a2t(szUin);
@@ -400,10 +384,7 @@ static TCHAR* GetEventPreview(DBEVENTINFO *dbei)
int PopupShow(PLUGIN_OPTIONS* pluginOptions, HANDLE hContact, HANDLE hEvent, UINT eventType)
{
- POPUPDATAEX puda;
- POPUPDATAW pudw;
PLUGIN_DATA* pdata;
- DBEVENTINFO dbe = {0};
EVENT_DATA_EX* eventData;
TCHAR* sampleEvent;
long iSeconds;
@@ -415,6 +396,7 @@ int PopupShow(PLUGIN_OPTIONS* pluginOptions, HANDLE hContact, HANDLE hEvent, UIN
//check if we should report this kind of event
//get the prefered icon as well
//CHANGE: iSeconds is -1 because I use my timer to hide popup
+ POPUPDATAW pudw;
pudw.iSeconds = -1;
switch (eventType) {
@@ -456,17 +438,18 @@ int PopupShow(PLUGIN_OPTIONS* pluginOptions, HANDLE hContact, HANDLE hEvent, UIN
}
//get DBEVENTINFO with pBlob if preview is needed (when is test then is off)
+ DBEVENTINFO dbe = {0};
dbe.cbSize = sizeof(dbe);
if ((pluginOptions->bPreview || eventType == EVENTTYPE_ADDED || eventType == EVENTTYPE_AUTHREQUEST) && hEvent) {
dbe.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)hEvent, 0);
- dbe.pBlob = (PBYTE)malloc(dbe.cbBlob);
+ dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob);
}
if (hEvent)
CallService(MS_DB_EVENT_GET, (WPARAM)hEvent, (LPARAM)&dbe);
- eventData = (EVENT_DATA_EX*)malloc(sizeof(EVENT_DATA_EX));
+ eventData = (EVENT_DATA_EX*)mir_alloc(sizeof(EVENT_DATA_EX));
eventData->hEvent = hEvent;
eventData->number = 1;
eventData->next = NULL;
@@ -477,7 +460,7 @@ int PopupShow(PLUGIN_OPTIONS* pluginOptions, HANDLE hContact, HANDLE hEvent, UIN
hContact = *((PHANDLE)(dbe.pBlob + sizeof(DWORD)));
// set plugin_data ... will be usable within PopupDlgProc
- pdata = (PLUGIN_DATA*)malloc(sizeof(PLUGIN_DATA));
+ pdata = (PLUGIN_DATA*)mir_alloc(sizeof(PLUGIN_DATA));
pdata->eventType = eventType;
pdata->hContact = hContact;
pdata->pluginOptions = pluginOptions;
@@ -512,45 +495,12 @@ int PopupShow(PLUGIN_OPTIONS* pluginOptions, HANDLE hContact, HANDLE hEvent, UIN
if (ServiceExists(MS_POPUP_ADDPOPUPT))
{
- pdata->isUnicode = 1;
if (CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pudw, 0) < 0)
{ // popup creation failed, release popupdata
FreePopupEventData(pdata);
mir_free(pdata);
}
}
- else // convert to ansi
- {
- pdata->isUnicode = 0;
- puda.iSeconds = pudw.iSeconds;
- puda.lchIcon = pudw.lchIcon;
- puda.colorBack = pudw.colorBack;
- puda.colorText = pudw.colorText;
- puda.lchContact = pudw.lchContact;
- puda.PluginWindowProc = pudw.PluginWindowProc;
- puda.PluginData = pudw.PluginData;
-
- char* szAnsi;
-
- szAnsi = _T2A((TCHAR*)pudw.lptzContactName);
- if (szAnsi)
- strncpy(puda.lpzContactName, szAnsi, MAX_CONTACTNAME);
- else
- strcpy(puda.lpzContactName, "");
- mir_free(szAnsi);
- szAnsi = _T2A((TCHAR*)pudw.lptzText);
- if (szAnsi)
- strncpy(puda.lpzText, szAnsi, MAX_SECONDLINE);
- else
- strcpy(puda.lpzText, "");
- mir_free(szAnsi);
-
- // popup creation failed, release popupdata
- if (CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&puda, 0) < 0) {
- FreePopupEventData(pdata);
- mir_free(pdata);
- }
- }
if (dbe.pBlob)
mir_free(dbe.pBlob);
@@ -564,8 +514,6 @@ int PopupUpdate(HANDLE hContact, HANDLE hEvent)
DBEVENTINFO dbe = {0};
EVENT_DATA_EX* eventData;
TCHAR lpzText[MAX_SECONDLINE*2] = _T("\0\0");
- char timestamp[MAX_DATASIZE] = "";
- char formatTime[MAX_DATASIZE] = "";
int iEvent = 0;
int doReverse = 0;
@@ -575,7 +523,7 @@ int PopupUpdate(HANDLE hContact, HANDLE hEvent)
if (hEvent) {
pdata->countEvent++;
- pdata->lastEventData->next = (EVENT_DATA_EX *)malloc(sizeof(EVENT_DATA_EX));
+ pdata->lastEventData->next = (EVENT_DATA_EX *)mir_alloc(sizeof(EVENT_DATA_EX));
pdata->lastEventData->next->prev = pdata->lastEventData;
pdata->lastEventData = pdata->lastEventData->next;
pdata->lastEventData->hEvent = hEvent;
@@ -613,19 +561,21 @@ int PopupUpdate(HANDLE hContact, HANDLE hEvent)
dbe.cbBlob = 0;
if (pdata->pluginOptions->bPreview && eventData->hEvent) {
dbe.cbBlob = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM)eventData->hEvent, 0);
- dbe.pBlob = (PBYTE)malloc(dbe.cbBlob);
+ dbe.pBlob = (PBYTE)mir_alloc(dbe.cbBlob);
}
if (eventData->hEvent)
CallService(MS_DB_EVENT_GET, (WPARAM)eventData->hEvent, (LPARAM)&dbe);
if (pdata->pluginOptions->bShowDate || pdata->pluginOptions->bShowTime) {
- strncpy(formatTime,"",sizeof(formatTime));
+ TCHAR timestamp[MAX_DATASIZE];
+ TCHAR formatTime[MAX_DATASIZE];
if (pdata->pluginOptions->bShowDate)
- strncpy(formatTime, "%Y.%m.%d ", sizeof(formatTime));
- if (pdata->pluginOptions->bShowTime)
- strncat(formatTime, "%H:%M", sizeof(formatTime));
- strftime(timestamp,sizeof(timestamp), formatTime, localtime((const time_t *)&dbe.timestamp));
+ _tcsncpy(formatTime, _T("%Y.%m.%d"), SIZEOF(formatTime));
+ else if (pdata->pluginOptions->bShowTime)
+ _tcsncat(formatTime, _T(" %H:%M"), SIZEOF(formatTime));
+ time_t localTime = dbe.timestamp;
+ _tcsftime(timestamp, SIZEOF(timestamp), formatTime, localtime(&localTime));
mir_sntprintf(lpzText, SIZEOF(lpzText), _T("%s[b][i]%s[/i][/b]\n"), lpzText, timestamp);
}
@@ -649,13 +599,7 @@ int PopupUpdate(HANDLE hContact, HANDLE hEvent)
if ((doReverse && eventData->next) || (!doReverse && eventData->prev))
mir_sntprintf(lpzText, SIZEOF(lpzText), _T("%s\n..."), lpzText);
- if (pdata->isUnicode)
- CallService(MS_POPUP_CHANGETEXTW, (WPARAM)pdata->hWnd, (LPARAM)lpzText);
- else {
- char* szAnsi = _T2A(lpzText);
- CallService(MS_POPUP_CHANGETEXT, (WPARAM)pdata->hWnd, (LPARAM)szAnsi);
- mir_free(szAnsi);
- }
+ CallService(MS_POPUP_CHANGETEXTT, (WPARAM)pdata->hWnd, (LPARAM)lpzText);
return 0;
}
diff --git a/plugins/NewXstatusNotify/main.cpp b/plugins/NewXstatusNotify/main.cpp
index 2e9974cc8d..82370f15f5 100644
--- a/plugins/NewXstatusNotify/main.cpp
+++ b/plugins/NewXstatusNotify/main.cpp
@@ -1364,5 +1364,6 @@ extern "C" int __declspec(dllexport) Unload(void)
{
DestroyHookableEvent(hHookContactStatusChanged);
DestroyServiceFunction(hServiceMenu);
+ xstatusList.destroy();
return 0;
} \ No newline at end of file
diff --git a/plugins/NewXstatusNotify/xstatus.cpp b/plugins/NewXstatusNotify/xstatus.cpp
index 94415dbb21..4356af37fb 100644
--- a/plugins/NewXstatusNotify/xstatus.cpp
+++ b/plugins/NewXstatusNotify/xstatus.cpp
@@ -66,16 +66,15 @@ void RemoveLoggedEvents(HANDLE hContact)
TCHAR *GetStatusTypeAsString(int type, TCHAR *buff)
{
- switch (type)
- {
- case TYPE_JABBER_MOOD:
- _tcscpy(buff, TranslateT("Mood")); break;
- case TYPE_JABBER_ACTIVITY:
- _tcscpy(buff, TranslateT("Activity")); break;
- case TYPE_ICQ_XSTATUS:
- _tcscpy(buff, TranslateT("Xstatus")); break;
- default:
- _tcscpy(buff, TranslateT("<unknown>"));
+ switch (type) {
+ case TYPE_JABBER_MOOD:
+ _tcscpy(buff, TranslateT("Mood")); break;
+ case TYPE_JABBER_ACTIVITY:
+ _tcscpy(buff, TranslateT("Activity")); break;
+ case TYPE_ICQ_XSTATUS:
+ _tcscpy(buff, TranslateT("Xstatus")); break;
+ default:
+ _tcscpy(buff, TranslateT("<unknown>"));
}
return buff;
diff --git a/plugins/Sessions/Src/Utils.cpp b/plugins/Sessions/Src/Utils.cpp
index 26adc41513..8ac041e7e9 100644
--- a/plugins/Sessions/Src/Utils.cpp
+++ b/plugins/Sessions/Src/Utils.cpp
@@ -146,34 +146,24 @@ void SetSessionMark(HANDLE hContact,int mode,char bit,unsigned int marknum)
BOOL LoadContactsFromMask(HANDLE hContact,int mode,int count)
{
- if(mode==0)
- {
+ if (mode == 0) {
DBVARIANT dbv;
- if (!DBGetContactSettingString(hContact, __INTERNAL_NAME, "LastSessionsMarks", &dbv) && dbv.pszVal)
- {
- if (dbv.pszVal[count]=='1')
- {
- DBFreeVariant(&dbv);
- return 1;
- }
- }
- else
+ if ( DBGetContactSettingString(hContact, __INTERNAL_NAME, "LastSessionsMarks", &dbv))
return 0;
+
+ BOOL res = dbv.pszVal[count] == '1';
+ DBFreeVariant(&dbv);
+ return res;
}
- if (mode==1)
- {
+ if (mode == 1) {
DBVARIANT dbv;
- if (!DBGetContactSettingString(hContact, __INTERNAL_NAME, "UserSessionsMarks", &dbv) && dbv.pszVal)
- {
- if (dbv.pszVal[count]=='1')
- {
- DBFreeVariant(&dbv);
- return 1;
- }
- }
- else
+ if ( DBGetContactSettingString(hContact, __INTERNAL_NAME, "UserSessionsMarks", &dbv))
return 0;
+
+ BOOL res = dbv.pszVal[count] == '1';
+ DBFreeVariant(&dbv);
+ return res;
}
return 0;
}
@@ -194,7 +184,7 @@ void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode)
if(mode==0)
{
DBVARIANT dbv;
- if (!DBGetContactSettingString(hContact, __INTERNAL_NAME, "LastSessionsOrder", &dbv) && dbv.pszVal)
+ if (!DBGetContactSettingString(hContact, __INTERNAL_NAME, "LastSessionsOrder", &dbv))
{
char* temp=NULL;
char* temp2=NULL;
@@ -351,27 +341,28 @@ BOOL ResaveSettings(char* szName,int iFirst,int iLimit,TCHAR* szBuffer)
for (int i = iFirst; i < iLimit; i++)
{
- if (szBuffer)
- {
- DBVARIANT dbv_temp = {0};
- mir_snprintf(szNameBuf, SIZEOF(szNameBuf), "%s_%u", szName, i);
- DBGetContactSettingTString(NULL, __INTERNAL_NAME, szNameBuf, &dbv_temp);
- DBWriteContactSettingTString(NULL, __INTERNAL_NAME, szNameBuf, szBuffer);
- marked=IsMarkedUserDefSession(i);
- MarkUserDefSession(i,(BYTE)((i==iFirst)?IsMarkedUserDefSession(iFirst-1):marked_t));
- marked_t=marked;
- mir_free(szBuffer);
- if (dbv_temp.ptszVal)
- {
- szBuffer = mir_tstrdup(dbv_temp.ptszVal);
- DBFreeVariant(&dbv_temp);
- }
- else
- return 0;
- }
- else
+ if (szBuffer == NULL)
break;
+
+ mir_snprintf(szNameBuf, SIZEOF(szNameBuf), "%s_%u", szName, i);
+
+ DBVARIANT dbv_temp;
+ int res = DBGetContactSettingTString(NULL, __INTERNAL_NAME, szNameBuf, &dbv_temp);
+ DBWriteContactSettingTString(NULL, __INTERNAL_NAME, szNameBuf, szBuffer);
+ mir_free(szBuffer);
+
+ marked = IsMarkedUserDefSession(i);
+ MarkUserDefSession(i,(BYTE)((i==iFirst)?IsMarkedUserDefSession(iFirst-1):marked_t));
+ marked_t = marked;
+
+ if (res) // read failed
+ return 0;
+
+ szBuffer = mir_tstrdup(dbv_temp.ptszVal);
+ DBFreeVariant(&dbv_temp);
}
+
+ mir_free(szBuffer);
return 1;
}
diff --git a/plugins/YAPP/message_pump.cpp b/plugins/YAPP/message_pump.cpp
index 4a2b05b081..7e2cea5f0c 100644
--- a/plugins/YAPP/message_pump.cpp
+++ b/plugins/YAPP/message_pump.cpp
@@ -72,7 +72,8 @@ bool is_workstation_locked()
}
-unsigned __stdcall MessagePumpThread(void* param) {
+unsigned __stdcall MessagePumpThread(void* param)
+{
InitWindowStack();
if(param) SetEvent((HANDLE)param);
@@ -81,65 +82,64 @@ unsigned __stdcall MessagePumpThread(void* param) {
while(GetMessage(&hwndMsg, 0, 0, 0) > 0 && !Miranda_Terminated()) {
if (!IsDialogMessage(hwndMsg.hwnd, &hwndMsg)) {
switch(hwndMsg.message) {
- case MUM_CREATEPOPUP:
- {
- bool enabled = true;
- int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
- if(status >= ID_STATUS_OFFLINE && status <= ID_STATUS_OUTTOLUNCH && options.disable_status[status - ID_STATUS_OFFLINE])
- enabled = false;
- if ((options.disable_full_screen && is_full_screen()) || is_workstation_locked())
- enabled = false;
-
- PopupData *pd = (PopupData *)hwndMsg.lParam;
- if(enabled && num_popups < MAX_POPUPS) {
- //HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, GetDesktopWindow(), 0, hInst, (LPVOID)hwndMsg.lParam);
- HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)hwndMsg.lParam);
- num_popups++;
- if(hwndMsg.wParam) // set notifyer handle
- SendMessage(hwnd, PUM_SETNOTIFYH, hwndMsg.wParam, 0);
- } else {
- if (pd) {
- mir_free(pd->pwzTitle);
- mir_free(pd->pwzText);
- mir_free(pd);
- }
- }
- }
- break;
-
- case MUM_DELETEPOPUP:
- {
- HWND hwnd = (HWND)hwndMsg.lParam;
- if(IsWindow(hwnd)) {
- DestroyWindow(hwnd);
- num_popups--;
+ case MUM_CREATEPOPUP:
+ {
+ bool enabled = true;
+ int status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
+ if(status >= ID_STATUS_OFFLINE && status <= ID_STATUS_OUTTOLUNCH && options.disable_status[status - ID_STATUS_OFFLINE])
+ enabled = false;
+ if ((options.disable_full_screen && is_full_screen()) || is_workstation_locked())
+ enabled = false;
+
+ PopupData *pd = (PopupData *)hwndMsg.lParam;
+ if(enabled && num_popups < MAX_POPUPS) {
+ //HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, GetDesktopWindow(), 0, hInst, (LPVOID)hwndMsg.lParam);
+ HWND hwnd = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, POP_WIN_CLASS, _T("Popup"), WS_POPUP, 0, 0, 0, 0, 0, 0, hInst, (LPVOID)hwndMsg.lParam);
+ num_popups++;
+ if(hwndMsg.wParam) // set notifyer handle
+ SendMessage(hwnd, PUM_SETNOTIFYH, hwndMsg.wParam, 0);
+ } else {
+ if (pd) {
+ mir_free(pd->pwzTitle);
+ mir_free(pd->pwzText);
+ mir_free(pd);
}
}
- break;
- case MUM_NMUPDATE:
- {
- HANDLE hNotify = (HANDLE)hwndMsg.wParam;
- BroadcastMessage(PUM_UPDATENOTIFY, (WPARAM)hNotify, 0);
- }
- break;
- case MUM_NMREMOVE:
- {
- HANDLE hNotify = (HANDLE)hwndMsg.wParam;
- BroadcastMessage(PUM_KILLNOTIFY, (WPARAM)hNotify, 0);
- }
- break;
- case MUM_NMAVATAR:
- RepositionWindows();
- break;
- default:
- {
- TranslateMessage(&hwndMsg);
- DispatchMessage(&hwndMsg);
- // do this here in case the window has gone
- if(hwndMsg.message == PUM_CHANGE || hwndMsg.message == PUM_SETTEXT)
- mir_free((void *)hwndMsg.lParam);
+ }
+ break;
+
+ case MUM_DELETEPOPUP:
+ {
+ HWND hwnd = (HWND)hwndMsg.lParam;
+ if(IsWindow(hwnd)) {
+ DestroyWindow(hwnd);
+ num_popups--;
}
- break;
+ }
+ break;
+
+ case MUM_NMUPDATE:
+ {
+ HANDLE hNotify = (HANDLE)hwndMsg.wParam;
+ BroadcastMessage(PUM_UPDATENOTIFY, (WPARAM)hNotify, 0);
+ }
+ break;
+
+ case MUM_NMREMOVE:
+ {
+ HANDLE hNotify = (HANDLE)hwndMsg.wParam;
+ BroadcastMessage(PUM_KILLNOTIFY, (WPARAM)hNotify, 0);
+ }
+ break;
+
+ case MUM_NMAVATAR:
+ RepositionWindows();
+ break;
+
+ default:
+ TranslateMessage(&hwndMsg);
+ DispatchMessage(&hwndMsg);
+ break;
}
}
}
@@ -149,7 +149,7 @@ unsigned __stdcall MessagePumpThread(void* param) {
//if(param) SetEvent((HANDLE)param);
- DeinitOptions();
+ DeinitOptions();
DeinitServices();
return 0;
diff --git a/plugins/YAPP/popwin.cpp b/plugins/YAPP/popwin.cpp
index 50e99cdd36..682a3f7b05 100644
--- a/plugins/YAPP/popwin.cpp
+++ b/plugins/YAPP/popwin.cpp
@@ -523,6 +523,7 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
//}
}
return 0;
+
case WM_DESTROY:
if(pwd->mouse_in) global_mouse_in--;
@@ -546,8 +547,8 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
}
mir_free(pwd); pwd = 0; pd = 0;
SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
-
break;
+
case PUM_UPDATERGN:
// round corners
if(pwd->is_round) {
@@ -566,32 +567,24 @@ LRESULT CALLBACK PopupWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa
return TRUE;
case PUM_MOVE:
- {
- if(options.animate) {
- KillTimer(hwnd, ID_MOVETIMER);
- pwd->new_x = (int)wParam;
- pwd->new_y = (int)lParam;
- SetTimer(hwnd, ID_MOVETIMER, 10, 0);
- } else {
- SetWindowPos(hwnd, 0, (int)wParam, (int)lParam, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
- if (!IsWindowVisible(hwnd)) {
- ShowWindow(hwnd, SW_SHOWNOACTIVATE);
- UpdateWindow(hwnd);
- }
+ if(options.animate) {
+ KillTimer(hwnd, ID_MOVETIMER);
+ pwd->new_x = (int)wParam;
+ pwd->new_y = (int)lParam;
+ SetTimer(hwnd, ID_MOVETIMER, 10, 0);
+ } else {
+ SetWindowPos(hwnd, 0, (int)wParam, (int)lParam, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
+ if (!IsWindowVisible(hwnd)) {
+ ShowWindow(hwnd, SW_SHOWNOACTIVATE);
+ UpdateWindow(hwnd);
}
}
return TRUE;
+
case PUM_SETTEXT:
- {
- mir_free(pd->pszText);
- if(lParam)
- pd->pwzText = mir_wstrdup((wchar_t *)lParam);
- else
- pd->pwzText = NULL;
- // mir_free((void *)lParam); // freed in message pump in case the window has gone
- InvalidateRect(hwnd, 0, TRUE);
- RepositionWindows();
- }
+ replaceStrT(pd->ptzText, (TCHAR*)lParam);
+ InvalidateRect(hwnd, 0, TRUE);
+ RepositionWindows();
return TRUE;
case PUM_GETCONTACT:
diff --git a/plugins/YAPP/popwin.h b/plugins/YAPP/popwin.h
index 63038c470b..4d826ceade 100644
--- a/plugins/YAPP/popwin.h
+++ b/plugins/YAPP/popwin.h
@@ -1,19 +1,19 @@
#ifndef _POPWIN_INC
#define _POPWIN_INC
-#define POP_WIN_CLASS _T(MODULE) _T("YAPPWindowClass")
-
-#define PUM_SETTEXT (WM_USER + 0x020)
-#define PUM_GETCONTACT (WM_USER + 0x021)
-#define PUM_GETOPAQUE (WM_USER + 0x022)
-#define PUM_CHANGE (WM_USER + 0x023)
-#define PUM_MOVE (WM_USER + 0x024)
-#define PUM_GETHEIGHT (WM_USER + 0x025)
-#define PUM_UPDATERGN (WM_USER + 0x026)
-
-#define PUM_SETNOTIFYH (WM_USER + 0x030)
-#define PUM_KILLNOTIFY (WM_USER + 0x031)
-#define PUM_UPDATENOTIFY (WM_USER + 0x032)
+#define POP_WIN_CLASS _T(MODULE) _T("YAPPWindowClass")
+
+#define PUM_SETTEXT (WM_USER + 0x020)
+#define PUM_GETCONTACT (WM_USER + 0x021)
+#define PUM_GETOPAQUE (WM_USER + 0x022)
+#define PUM_CHANGE (WM_USER + 0x023)
+#define PUM_MOVE (WM_USER + 0x024)
+#define PUM_GETHEIGHT (WM_USER + 0x025)
+#define PUM_UPDATERGN (WM_USER + 0x026)
+
+#define PUM_SETNOTIFYH (WM_USER + 0x030)
+#define PUM_KILLNOTIFY (WM_USER + 0x031)
+#define PUM_UPDATENOTIFY (WM_USER + 0x032)
void InitWindowStack();
void DeinitWindowStack();
diff --git a/plugins/YAPP/services.cpp b/plugins/YAPP/services.cpp
index ea60b013b4..84e4330151 100644
--- a/plugins/YAPP/services.cpp
+++ b/plugins/YAPP/services.cpp
@@ -155,13 +155,14 @@ INT_PTR OldCreatePopupW(WPARAM wParam, LPARAM lParam) {
return 0;
}
-INT_PTR ChangeTextW(WPARAM wParam, LPARAM lParam) {
+INT_PTR ChangeTextW(WPARAM wParam, LPARAM lParam)
+{
HWND hwndPop = (HWND)wParam;
- wchar_t *newText = mir_wstrdup((wchar_t *)lParam);
+ wchar_t *newText = NEWWSTR_ALLOCA((wchar_t *)lParam);
StripBBCodesInPlace(newText);
if(IsWindow(hwndPop))
- PostMessage(hwndPop, PUM_SETTEXT, 0, (LPARAM)newText);
+ SendMessage(hwndPop, PUM_SETTEXT, 0, (LPARAM)newText);
else
mir_free(newText);
return 0;
@@ -174,9 +175,9 @@ INT_PTR ChangeTextA(WPARAM wParam, LPARAM lParam) {
StripBBCodesInPlace(buff);
if(IsWindow(hwndPop))
- PostMessage(hwndPop, PUM_SETTEXT, 0, (LPARAM)buff);
- else
- mir_free(buff);
+ SendMessage(hwndPop, PUM_SETTEXT, 0, (LPARAM)buff);
+
+ mir_free(buff);
return 0;
}
@@ -286,32 +287,32 @@ INT_PTR PopupChangeA(WPARAM wParam, LPARAM lParam) {
POPUPDATAEX *pd_in = (POPUPDATAEX *)lParam;
if(IsWindow(hwndPop)) {
- PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData));
- pd_out->cbSize = sizeof(PopupData);
- pd_out->flags = PDF_UNICODE;
+ PopupData pd_out;
+ pd_out.cbSize = sizeof(PopupData);
+ pd_out.flags = PDF_UNICODE;
- pd_out->pwzTitle = mir_a2u(pd_in->lpzContactName);
- pd_out->pwzText = mir_a2u(pd_in->lpzText);
- StripBBCodesInPlace(pd_out->pwzTitle);
- StripBBCodesInPlace(pd_out->pwzText);
+ pd_out.pwzTitle = mir_a2u(pd_in->lpzContactName);
+ pd_out.pwzText = mir_a2u(pd_in->lpzText);
+ StripBBCodesInPlace(pd_out.pwzTitle);
+ StripBBCodesInPlace(pd_out.pwzText);
- pd_out->hContact = pd_in->lchContact;
- pd_out->hIcon = pd_in->lchIcon;
+ pd_out.hContact = pd_in->lchContact;
+ pd_out.hIcon = pd_in->lchIcon;
if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg'
- pd_out->colorBack = pd_out->colorText = 0;
+ pd_out.colorBack = pd_out.colorText = 0;
else {
- pd_out->colorBack = pd_in->colorBack & 0xFFFFFF;
- pd_out->colorText = pd_in->colorText & 0xFFFFFF;
+ pd_out.colorBack = pd_in->colorBack & 0xFFFFFF;
+ pd_out.colorText = pd_in->colorText & 0xFFFFFF;
}
- pd_out->colorBack = pd_in->colorBack;
- pd_out->colorText = pd_in->colorText;
- pd_out->windowProc = pd_in->PluginWindowProc;
- pd_out->opaque = pd_in->PluginData;
- pd_out->timeout = pd_in->iSeconds;
+ pd_out.colorBack = pd_in->colorBack;
+ pd_out.colorText = pd_in->colorText;
+ pd_out.windowProc = pd_in->PluginWindowProc;
+ pd_out.opaque = pd_in->PluginData;
+ pd_out.timeout = pd_in->iSeconds;
- lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0));
-
- PostMessage(hwndPop, PUM_CHANGE, 0, (LPARAM)pd_out);
+ lstPopupHistory.Add(pd_out.pwzTitle, pd_out.pwzText, time(0));
+
+ SendMessage(hwndPop, PUM_CHANGE, 0, (LPARAM)&pd_out);
}
return 0;
}
@@ -321,32 +322,32 @@ INT_PTR PopupChangeW(WPARAM wParam, LPARAM lParam) {
POPUPDATAW *pd_in = (POPUPDATAW *)lParam;
if(IsWindow(hwndPop)) {
- PopupData *pd_out = (PopupData *)mir_alloc(sizeof(PopupData));
- pd_out->cbSize = sizeof(PopupData);
- pd_out->flags = PDF_UNICODE;
+ PopupData pd_out;
+ pd_out.cbSize = sizeof(PopupData);
+ pd_out.flags = PDF_UNICODE;
- pd_out->pwzTitle = mir_wstrdup(pd_in->lpwzContactName);
- pd_out->pwzText = mir_wstrdup(pd_in->lpwzText);
- StripBBCodesInPlace(pd_out->pwzTitle);
- StripBBCodesInPlace(pd_out->pwzText);
+ pd_out.pwzTitle = mir_wstrdup(pd_in->lpwzContactName);
+ pd_out.pwzText = mir_wstrdup(pd_in->lpwzText);
+ StripBBCodesInPlace(pd_out.pwzTitle);
+ StripBBCodesInPlace(pd_out.pwzText);
- pd_out->hContact = pd_in->lchContact;
- pd_out->hIcon = pd_in->lchIcon;
+ pd_out.hContact = pd_in->lchContact;
+ pd_out.hIcon = pd_in->lchIcon;
if(pd_in->colorBack == 0xffffffff) // that's the old #define for 'skinned bg'
- pd_out->colorBack = pd_out->colorText = 0;
+ pd_out.colorBack = pd_out.colorText = 0;
else {
- pd_out->colorBack = pd_in->colorBack & 0xFFFFFF;
- pd_out->colorText = pd_in->colorText & 0xFFFFFF;
+ pd_out.colorBack = pd_in->colorBack & 0xFFFFFF;
+ pd_out.colorText = pd_in->colorText & 0xFFFFFF;
}
- pd_out->colorBack = pd_in->colorBack;
- pd_out->colorText = pd_in->colorText;
- pd_out->windowProc = pd_in->PluginWindowProc;
- pd_out->opaque = pd_in->PluginData;
- pd_out->timeout = pd_in->iSeconds;
+ pd_out.colorBack = pd_in->colorBack;
+ pd_out.colorText = pd_in->colorText;
+ pd_out.windowProc = pd_in->PluginWindowProc;
+ pd_out.opaque = pd_in->PluginData;
+ pd_out.timeout = pd_in->iSeconds;
- lstPopupHistory.Add(pd_out->pwzTitle, pd_out->pwzText, time(0));
+ lstPopupHistory.Add(pd_out.pwzTitle, pd_out.pwzText, time(0));
- PostMessage(hwndPop, PUM_CHANGE, 0, (LPARAM)pd_out);
+ SendMessage(hwndPop, PUM_CHANGE, 0, (LPARAM)&pd_out);
}
return 0;
}
diff --git a/protocols/Gadu-Gadu/avatar.cpp b/protocols/Gadu-Gadu/avatar.cpp
index 2dc6de1bbd..ace7871b6a 100644
--- a/protocols/Gadu-Gadu/avatar.cpp
+++ b/protocols/Gadu-Gadu/avatar.cpp
@@ -299,7 +299,6 @@ void GGPROTO::uninitavatarrequestthread()
void __cdecl GGPROTO::getuseravatarthread(void*)
{
- PROTO_AVATAR_INFORMATIONT pai = {0};
char *AvatarURL;
int AvatarType;
@@ -310,7 +309,9 @@ void __cdecl GGPROTO::getuseravatarthread(void*)
db_unset(NULL, m_szModuleName, GG_KEY_AVATARURL);
db_set_b(NULL, m_szModuleName, GG_KEY_AVATARTYPE, (BYTE)AvatarType);
db_set_b(NULL, m_szModuleName, GG_KEY_AVATARREQUESTED, 1);
+ mir_free(AvatarURL);
+ PROTO_AVATAR_INFORMATIONT pai = {0};
pai.cbSize = sizeof(pai);
getavatarinfo((WPARAM)GAIF_FORCE, (LPARAM)&pai);
}