summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-13 19:24:27 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-13 19:24:27 +0000
commit9f1350bd4fb0df56a4115e80343285eef8acb954 (patch)
tree1ba6a93fbf45e23ecf5574e4bf27274553ff0d93 /plugins
parent3b7c325eda9d15675755888f604767fab93170ca (diff)
fix for rare crash
git-svn-id: http://svn.miranda-ng.org/main/trunk@955 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/NewXstatusNotify/common.h1
-rw-r--r--plugins/NewXstatusNotify/popup.cpp80
-rw-r--r--plugins/NewXstatusNotify/xstatus.cpp19
3 files changed, 46 insertions, 54 deletions
diff --git a/plugins/NewXstatusNotify/common.h b/plugins/NewXstatusNotify/common.h
index b7358a3b7e..e085537294 100644
--- a/plugins/NewXstatusNotify/common.h
+++ b/plugins/NewXstatusNotify/common.h
@@ -42,6 +42,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <tchar.h>
+#include <malloc.h>
#include <newpluginapi.h>
#include <m_system.h>
diff --git a/plugins/NewXstatusNotify/popup.cpp b/plugins/NewXstatusNotify/popup.cpp
index c62b061b94..c8e7d32e32 100644
--- a/plugins/NewXstatusNotify/popup.cpp
+++ b/plugins/NewXstatusNotify/popup.cpp
@@ -80,38 +80,35 @@ void ReceivedAwayMessage(HWND hWnd, LPARAM lParam, PLUGINDATA * pdp)
void PopupAction(HWND hWnd, BYTE action)
{
HANDLE hContact = PUGetContact(hWnd);
- if (hContact && hContact != INVALID_HANDLE_VALUE)
- {
- switch (action)
- {
- case PCA_OPENMESSAGEWND:
- {
- CallServiceSync(ServiceExists("SRMsg/LaunchMessageWindow") ? "SRMsg/LaunchMessageWindow" : MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
- break;
- }
- case PCA_OPENMENU:
+ if (hContact && hContact != INVALID_HANDLE_VALUE) {
+ switch (action) {
+ case PCA_OPENMESSAGEWND:
+ CallServiceSync(ServiceExists("SRMsg/LaunchMessageWindow") ? "SRMsg/LaunchMessageWindow" : MS_MSG_SENDMESSAGE, (WPARAM)hContact, 0);
+ break;
+
+ case PCA_OPENMENU:
{
POINT pt = {0};
HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)hContact, 0);
GetCursorPos(&pt);
TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hWnd, NULL);
DestroyMenu(hMenu);
- return;
- }
- case PCA_OPENDETAILS:
- {
- CallServiceSync(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
- break;
- }
- case PCA_OPENHISTORY:
- {
- CallServiceSync(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)hContact, 0);
- break;
}
- case PCA_CLOSEPOPUP:
- break;
- case PCA_DONOTHING:
- return;
+ return;
+
+ case PCA_OPENDETAILS:
+ CallServiceSync(MS_USERINFO_SHOWDIALOG, (WPARAM)hContact, 0);
+ break;
+
+ case PCA_OPENHISTORY:
+ CallServiceSync(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)hContact, 0);
+ break;
+
+ case PCA_CLOSEPOPUP:
+ break;
+
+ case PCA_DONOTHING:
+ return;
}
PUDeletePopUp(hWnd);
@@ -126,29 +123,26 @@ INT_PTR CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
{
case WM_MEASUREITEM: //Needed by the contact's context menu
return CallService(MS_CLIST_MENUMEASUREITEM, wParam, lParam);
+
case WM_DRAWITEM: //Needed by the contact's context menu
return CallService(MS_CLIST_MENUDRAWITEM, wParam, lParam);
+
case WM_COMMAND:
- {
//This one returns TRUE if it processed the menu command, and FALSE if it did not process it.
if (CallServiceSync(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)PUGetContact(hwnd)))
break;
PopupAction(hwnd, opt.LeftClickAction);
break;
- }
+
case WM_CONTEXTMENU:
- {
PopupAction(hwnd, opt.RightClickAction);
break;
- }
+
case UM_FREEPLUGINDATA:
- {
- PLUGINDATA *pdp = (PLUGINDATA *)PUGetPluginData(hwnd);
- if (pdp != NULL)
- {
- if (pdp->hAwayMsgHook != NULL)
- {
+ pdp = (PLUGINDATA *)PUGetPluginData(hwnd);
+ if (pdp != NULL) {
+ if (pdp->hAwayMsgHook != NULL) {
UnhookEvent(pdp->hAwayMsgHook);
pdp->hAwayMsgHook = NULL;
}
@@ -156,15 +150,12 @@ INT_PTR CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
mir_free(pdp);
}
return FALSE;
- }
+
case UM_INITPOPUP:
- {
pdp = (PLUGINDATA *)PUGetPluginData(hwnd);
- if (pdp != NULL)
- {
+ if (pdp != NULL) {
char *szProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)PUGetContact(hwnd), 0);
- if (szProto && opt.ReadAwayMsg && StatusHasAwayMessage(szProto, pdp->newStatus))
- {
+ if (szProto && opt.ReadAwayMsg && StatusHasAwayMessage(szProto, pdp->newStatus)) {
WORD myStatus = (WORD)CallProtoService(szProto, PS_GETSTATUS, 0, 0);
if (myStatus != ID_STATUS_INVISIBLE)
QueryAwayMessage(hwnd, pdp);
@@ -172,13 +163,12 @@ INT_PTR CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
}
return FALSE;
- }
+
case WM_AWAYMSG: //We're here because ME_PROTO_ACK has been hooked to this window (too!).
- {
pdp = (PLUGINDATA *)PUGetPluginData(hwnd);
- if (pdp != NULL) ReceivedAwayMessage(hwnd, lParam, pdp);
+ if (pdp != NULL)
+ ReceivedAwayMessage(hwnd, lParam, pdp);
return FALSE;
- }
}
return DefWindowProc(hwnd, message, wParam, lParam);
diff --git a/plugins/NewXstatusNotify/xstatus.cpp b/plugins/NewXstatusNotify/xstatus.cpp
index c427a8d427..94415dbb21 100644
--- a/plugins/NewXstatusNotify/xstatus.cpp
+++ b/plugins/NewXstatusNotify/xstatus.cpp
@@ -193,19 +193,20 @@ void ShowPopup(XSTATUSCHANGE *xsc)
break;
}
-
- _tcscpy(ppd.lptzContactName, (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)xsc->hContact, GSMDF_TCHAR));
- if (opt.ShowGroup) //add group name to popup title
- {
- if (!DBGetContactSettingTString(xsc->hContact, "CList", "Group", &dbv))
- {
- _tcscat(ppd.lptzContactName, _T(" ("));
- _tcscat(ppd.lptzContactName, dbv.ptszVal);
- _tcscat(ppd.lptzContactName, _T(")"));
+ TCHAR *ptszGroup = NULL,
+ *ptszNick = (TCHAR *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)xsc->hContact, GSMDF_TCHAR);
+ if (opt.ShowGroup) { //add group name to popup title
+ if (!DBGetContactSettingTString(xsc->hContact, "CList", "Group", &dbv)) {
+ ptszGroup = NEWTSTR_ALLOCA(dbv.ptszVal);
DBFreeVariant(&dbv);
}
}
+ if (ptszGroup)
+ mir_sntprintf(ppd.lptzContactName, SIZEOF(ppd.lptzContactName),_T("%s (%s)"), ptszNick, ptszGroup);
+ else
+ _tcsncpy(ppd.lptzContactName, ptszNick, SIZEOF(ppd.lptzContactName));
+
// cut message if needed
if (opt.PTruncateMsg && (opt.PMsgLen > 0) && xsc->stzText && (_tcslen(xsc->stzText) > opt.PMsgLen))
{