summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-03-17 14:22:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-03-17 14:22:17 +0000
commit15267ea2d489606fb4b99d011bc3ea7c2a644a9f (patch)
tree607fb948632ec8b348508cbd08ef41fffe21d8c2
parent5e6e1e8838fe7637ef588e0fb080ad07fc5700aa (diff)
fix for popup-related memory leaks
git-svn-id: http://svn.miranda-ng.org/main/trunk@4077 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/delphi/m_popup.inc1
-rw-r--r--include/m_popup.h17
-rw-r--r--plugins/BasicHistory/src/Scheduler.cpp29
-rw-r--r--plugins/Clist_modern/src/modern_skinengine.cpp10
-rw-r--r--plugins/ExternalAPI/delphi/m_yapp.inc2
-rw-r--r--plugins/Nudge/src/main.cpp217
-rw-r--r--plugins/Nudge/src/nudge.cpp8
-rw-r--r--plugins/Nudge/src/shake.cpp8
-rw-r--r--plugins/Ping/src/utils.cpp34
-rw-r--r--plugins/Popup/src/main.cpp1
-rw-r--r--plugins/Popup/src/notifications.cpp30
-rw-r--r--plugins/Popup/src/notifications.h1
-rw-r--r--plugins/Popup/src/opt_class.cpp814
-rw-r--r--plugins/Popup/src/services.cpp82
-rw-r--r--plugins/Popup/src/services.h1
-rw-r--r--plugins/YAPP/src/options.cpp71
-rw-r--r--plugins/YAPP/src/services.cpp54
-rw-r--r--plugins/YAPP/src/services.h3
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.cpp3
-rw-r--r--protocols/Gadu-Gadu/src/gg_proto.h1
-rw-r--r--protocols/Gadu-Gadu/src/popups.cpp8
-rw-r--r--protocols/JabberG/src/jabber.h2
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp2
-rw-r--r--protocols/JabberG/src/jabber_misc.cpp15
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp3
-rw-r--r--protocols/JabberG/src/jabber_proto.h2
-rw-r--r--protocols/MSN/src/msn_misc.cpp16
-rw-r--r--protocols/MSN/src/msn_proto.cpp4
-rw-r--r--protocols/MSN/src/msn_proto.h4
29 files changed, 691 insertions, 752 deletions
diff --git a/include/delphi/m_popup.inc b/include/delphi/m_popup.inc
index 0a47fccba4..4e870963f4 100644
--- a/include/delphi/m_popup.inc
+++ b/include/delphi/m_popup.inc
@@ -336,6 +336,7 @@ const
// wParam = 0
// lParam = (POPUPCLASS *)&pc
MS_POPUP_REGISTERCLASS = 'PopUp/RegisterClass';
+ MS_POPUP_UNREGISTERCLASS = 'PopUp/UnregisterClass';
type
TPOPUPDATACLASS = record
diff --git a/include/m_popup.h b/include/m_popup.h
index b715345c40..1a633ac14b 100644
--- a/include/m_popup.h
+++ b/include/m_popup.h
@@ -332,7 +332,22 @@ typedef struct {
// wParam = 0
// lParam = (POPUPCLASS *)&pc
-#define MS_POPUP_REGISTERCLASS "PopUp/RegisterClass"
+#define MS_POPUP_REGISTERCLASS "PopUp/RegisterClass"
+
+HANDLE __forceinline Popup_RegisterClass(POPUPCLASS *pc)
+{
+ if ( !ServiceExists(MS_POPUP_REGISTERCLASS))
+ return NULL;
+ return (HANDLE)CallService(MS_POPUP_REGISTERCLASS, 0, LPARAM(pc));
+}
+
+#define MS_POPUP_UNREGISTERCLASS "PopUp/UnregisterClass"
+
+void __forceinline Popup_UnregisterClass(HANDLE ppc)
+{
+ if (ppc)
+ CallService(MS_POPUP_UNREGISTERCLASS, 0, LPARAM(ppc));
+}
typedef struct {
int cbSize;
diff --git a/plugins/BasicHistory/src/Scheduler.cpp b/plugins/BasicHistory/src/Scheduler.cpp
index a317a7dac4..d408563e72 100644
--- a/plugins/BasicHistory/src/Scheduler.cpp
+++ b/plugins/BasicHistory/src/Scheduler.cpp
@@ -56,26 +56,31 @@ bool FtpGetFiles(const std::wstring& dir, const std::list<std::wstring>& files,
void CreatePath(const TCHAR *szDir);
void DoError(const TaskOptions& to, const std::wstring error);
+static HANDLE hPopupClass;
+
void OptionsSchedulerChanged()
{
StartThread(false);
}
+static int OnShutdown(WPARAM, LPARAM)
+{
+ Popup_UnregisterClass(hPopupClass);
+ return 0;
+}
+
void InitScheduler()
{
bPopupsEnabled = ServiceExists(MS_POPUP_ADDPOPUPT) || ServiceExists(MS_POPUP_ADDPOPUPCLASS);
- if (ServiceExists(MS_POPUP_REGISTERCLASS))
- {
- //hPopupIcon = LoadIconEx(I_CHKUPD);
- POPUPCLASS test = {0};
- test.cbSize = sizeof(POPUPCLASS);
- test.flags = PCF_TCHAR;
- test.hIcon = LoadSkinnedIcon(SKINICON_OTHER_HISTORY);
- test.iSeconds = 10;
- test.ptszDescription = TranslateT("History task");
- test.pszName = MODULE;
- CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&test);
- }
+
+ POPUPCLASS test = { sizeof(test) };
+ test.flags = PCF_TCHAR;
+ test.hIcon = LoadSkinnedIcon(SKINICON_OTHER_HISTORY);
+ test.iSeconds = 10;
+ test.ptszDescription = TranslateT("History task");
+ test.pszName = MODULE;
+ if (hPopupClass = Popup_RegisterClass(&test))
+ HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown);
StartThread(true);
}
diff --git a/plugins/Clist_modern/src/modern_skinengine.cpp b/plugins/Clist_modern/src/modern_skinengine.cpp
index 5c6e7df153..4349d02416 100644
--- a/plugins/Clist_modern/src/modern_skinengine.cpp
+++ b/plugins/Clist_modern/src/modern_skinengine.cpp
@@ -466,7 +466,7 @@ HRESULT SkinEngineLoadModule()
CreateServiceFunction(MS_SKINENG_ALPHATEXTOUT,ske_Service_AlphaTextOut);
CreateServiceFunction(MS_SKINENG_DRAWICONEXFIX,ske_Service_DrawIconEx);
- CreateServiceFunction(MS_DRAW_TEXT_WITH_EFFECT,ske_Service_DrawTextWithEffect);
+ CreateServiceFunction(MS_DRAW_TEXT_WITH_EFFECT,ske_Service_DrawTextWithEffect);
//create event handle
hSkinLoadedEvent = HookEvent(ME_SKIN_SERVICESCREATED,CLUI_OnSkinLoad);
@@ -563,7 +563,7 @@ CRITICAL_SECTION BufferListCS = {0};
SortedList * BufferList = NULL;
enum
{
- BUFFER_DRAWICON = 0,
+ BUFFER_DRAWICON = 0,
BUFFER_DRAWIMAGE
};
@@ -1589,7 +1589,7 @@ int ske_AddDescriptorToSkinObjectList (LPSKINOBJECTDESCRIPTOR lpDescr, SKINOBJEC
GLYPHOBJECT * gl = (GLYPHOBJECT*)lpDescr->Data;
sk->pObjects[sk->dwObjLPAlocated].Data = mir_alloc(sizeof(GLYPHOBJECT));
obdat = (GLYPHOBJECT*)sk->pObjects[sk->dwObjLPAlocated].Data;
- memmove(obdat,gl,sizeof(GLYPHOBJECT));
+ memcpy(obdat,gl,sizeof(GLYPHOBJECT));
if (gl->szFileName != NULL)
{
obdat->szFileName = mir_strdup(gl->szFileName);
@@ -1668,7 +1668,7 @@ INT_PTR ske_Service_DrawGlyph(WPARAM wParam,LPARAM lParam)
int iStyle = gl->Style & 7;
if (iStyle == ST_SKIP)
return ST_SKIP;
-
+
if (gl->hGlyph == NULL && gl->hGlyph != (HBITMAP)-1 && (iStyle == ST_IMAGE || iStyle == ST_FRAGMENT || iStyle == ST_SOLARIZE))
if (gl->szFileName) {
gl->hGlyph = ske_LoadGlyphImage( _A2T(gl->szFileName));
@@ -1998,7 +1998,7 @@ static HBITMAP ske_LoadGlyphImageByDecoders(const TCHAR *tszFileName)
ImgDeleteDecoder(m_pImgDecoder);
}
}
-
+
if (hBitmap) {
GetObject(hBitmap, sizeof(BITMAP), &bmpInfo);
if (bmpInfo.bmBitsPixel == 32)
diff --git a/plugins/ExternalAPI/delphi/m_yapp.inc b/plugins/ExternalAPI/delphi/m_yapp.inc
index 772c5cca81..e85d382bec 100644
--- a/plugins/ExternalAPI/delphi/m_yapp.inc
+++ b/plugins/ExternalAPI/delphi/m_yapp.inc
@@ -66,7 +66,6 @@ const
// wParam = 0
// lParam = (POPUPCLASS *)&pc
- MS_YAPP_REGISTERCLASS = 'YAPP/RegisterClass'; // old
MS_POPUP_REGISTERCLASS = 'PopUp/RegisterClass';
type
@@ -82,7 +81,6 @@ type
const
// wParam = 0
// lParam = (POPUPDATACLASS *)&pdc
- MS_YAPP_CLASSINSTANCE = 'YAPP/ClassInstance'; // old
MS_POPUP_ADDPOPUPCLASS = 'PopUp/AddPopupClass';
{$ENDIF}
diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp
index d65f708f7f..e9216bc737 100644
--- a/plugins/Nudge/src/main.cpp
+++ b/plugins/Nudge/src/main.cpp
@@ -1,7 +1,7 @@
#include "headers.h"
int nProtocol = 0;
-static HANDLE g_hEventModulesLoaded = NULL, hEventOptionsInitialize = NULL, g_hEventDbWindowEvent = NULL, g_hEventToolbarLoaded = NULL, g_hEventButtonPressed = NULL, g_hEventAccountsChanged = NULL;
+static HANDLE hPopupClass;
HINSTANCE hInst;
NudgeElementList *NudgeList = NULL;
@@ -46,47 +46,26 @@ INT_PTR NudgeSend(WPARAM wParam,LPARAM lParam)
{
TCHAR msg[500];
mir_sntprintf(msg,500, TranslateT("You are not allowed to send too much nudge (only 1 each %d sec, %d sec left)"),GlobalNudge.sendTimeSec, 30 - diff);
- //MessageBox(NULL,msg,NULL,0);
- if(GlobalNudge.useByProtocol)
- {
+ if(GlobalNudge.useByProtocol) {
for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
- {
if (!strcmp(protoName,n->item.ProtocolName))
- {
Nudge_ShowPopup(n->item, (HANDLE) wParam, msg);
- }
- }
- }
- else
- {
- Nudge_ShowPopup(DefaultNudge, (HANDLE) wParam, msg);
}
+ else Nudge_ShowPopup(DefaultNudge, (HANDLE) wParam, msg);
+
return 0;
}
- DBWriteContactSettingDword((HANDLE) wParam, "Nudge", "LastSent", time(NULL));
+ db_set_dw((HANDLE) wParam, "Nudge", "LastSent", time(NULL));
- if(GlobalNudge.useByProtocol)
- {
- NudgeElementList *n;
- for(n = NudgeList;n != NULL; n = n->next)
- {
+ if(GlobalNudge.useByProtocol) {
+ for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
if (!strcmp(protoName,n->item.ProtocolName))
- {
- //if(n->item.showPopup)
- // Nudge_ShowPopup(n->item, (HANDLE) wParam, n->item.senText);
if(n->item.showStatus)
Nudge_SentStatus(n->item, (HANDLE) wParam);
- }
- }
- }
- else
- {
- //if(DefaultNudge.showPopup)
- // Nudge_ShowPopup(DefaultNudge, (HANDLE) wParam, DefaultNudge.senText);
- if(DefaultNudge.showStatus)
- Nudge_SentStatus(DefaultNudge, (HANDLE) wParam);
}
+ else if(DefaultNudge.showStatus)
+ Nudge_SentStatus(DefaultNudge, (HANDLE) wParam);
CallProtoService(protoName,"/SendNudge",wParam,lParam);
return 0;
@@ -99,9 +78,8 @@ void OpenContactList()
ShowWindow(hWnd, SW_SHOW);
}
-int NudgeRecieved(WPARAM wParam,LPARAM lParam)
+int NudgeReceived(WPARAM wParam,LPARAM lParam)
{
-
char *protoName = GetContactProto((HANDLE)wParam);
DWORD currentTimestamp = time(NULL);
@@ -111,9 +89,9 @@ int NudgeRecieved(WPARAM wParam,LPARAM lParam)
int diff2 = nudgeSentTimestamp - DBGetContactSettingDword((HANDLE) wParam, "Nudge", "LastReceived2", nudgeSentTimestamp-30);
if(diff >= GlobalNudge.recvTimeSec)
- DBWriteContactSettingDword((HANDLE) wParam, "Nudge", "LastReceived", currentTimestamp);
+ db_set_dw((HANDLE) wParam, "Nudge", "LastReceived", currentTimestamp);
if(diff2 >= GlobalNudge.recvTimeSec)
- DBWriteContactSettingDword((HANDLE) wParam, "Nudge", "LastReceived2", nudgeSentTimestamp);
+ db_set_dw((HANDLE) wParam, "Nudge", "LastReceived2", nudgeSentTimestamp);
if(GlobalNudge.useByProtocol)
{
@@ -163,7 +141,6 @@ int NudgeRecieved(WPARAM wParam,LPARAM lParam)
if(n->item.showStatus)
Nudge_ShowStatus(n->item, (HANDLE) wParam, nudgeSentTimestamp);
}
-
}
break;
}
@@ -226,38 +203,31 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
return &pluginInfo;
}
-static INT_PTR CALLBACK DlgProcOptsTrigger(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
+static INT_PTR CALLBACK DlgProcOptsTrigger(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ BOOL bshakeClist,bshakeChat;
+ DWORD actionID = (DWORD)lParam;
- switch (msg) {
- case WM_INITDIALOG: {
+ switch (msg) {
+ case WM_INITDIALOG:
// lParam = (LPARAM)(DWORD)actionID or 0 if this is a new trigger entry
- BOOL bshakeClist,bshakeChat;
-
- DWORD actionID = (DWORD)lParam;
- TranslateDialogDefault(hwnd);
+ TranslateDialogDefault(hwnd);
// Initialize the dialog according to the action ID
bshakeClist = DBGetActionSettingByte(actionID, NULL, "Nudge", "ShakeClist",FALSE);
bshakeChat = DBGetActionSettingByte(actionID, NULL, "Nudge", "ShakeChat",FALSE);
CheckDlgButton(hwnd, IDC_TRIGGER_SHAKECLIST, bshakeClist ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwnd, IDC_TRIGGER_SHAKECHAT, bshakeChat ? BST_CHECKED : BST_UNCHECKED);
- break;
- }
-
- case TM_ADDACTION: {
- // save your settings
- // wParam = (WPARAM)(DWORD)actionID
- bool bshakeClist,bshakeChat;
+ break;
- DWORD actionID = (DWORD)wParam;
+ case TM_ADDACTION:
bshakeClist = (IsDlgButtonChecked(hwnd,IDC_TRIGGER_SHAKECLIST)==BST_CHECKED);
bshakeChat = (IsDlgButtonChecked(hwnd,IDC_TRIGGER_SHAKECHAT)==BST_CHECKED);
DBWriteActionSettingByte(actionID, NULL, "Nudge", "ShakeClist",bshakeClist);
DBWriteActionSettingByte(actionID, NULL, "Nudge", "ShakeChat",bshakeChat);
break;
- }
}
- return FALSE;
+ return FALSE;
}
int TriggerActionRecv( DWORD actionID, REPORTINFO *ri)
@@ -306,27 +276,15 @@ void LoadProtocols(void)
PROTOACCOUNT **ppProtocolDescriptors;
INT_PTR ret = ProtoEnumAccounts(&numberOfProtocols,&ppProtocolDescriptors);
if(ret == 0)
- {
for(int i = 0; i < numberOfProtocols ; i++)
- {
Nudge_AddAccount(ppProtocolDescriptors[i]);
- }
-
- }
shake.Load();
-
- /*CNudgeElement *n;
- for(n = NudgeList;n != NULL; n = n->next)
- {
- MessageBox(NULL,n->ProtocolName,n->NudgeSoundname,0);
- }*/
}
void RegisterToTrigger(void)
{
- if ( ServiceExists(MS_TRIGGER_REGISTERACTION))
- {
+ if ( ServiceExists(MS_TRIGGER_REGISTERACTION)) {
ACTIONREGISTER ar;
ZeroMemory(&ar, sizeof(ar));
ar.cbSize = sizeof(ar);
@@ -381,17 +339,15 @@ static int TabsrmmButtonPressed(WPARAM wParam, LPARAM lParam)
static int TabsrmmButtonInit(WPARAM wParam, LPARAM lParam)
{
- BBButton bbd = {0};
-
- bbd.cbSize = sizeof(BBButton);
+ BBButton bbd = { sizeof(bbd) };
bbd.pszModuleName = "Nudge";
bbd.ptszTooltip = LPGENT("Send Nudge");
bbd.dwDefPos = 300;
- bbd.bbbFlags = BBBF_ISIMBUTTON|BBBF_ISLSIDEBUTTON|BBBF_CANBEHIDDEN;
+ bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISLSIDEBUTTON | BBBF_CANBEHIDDEN;
bbd.hIcon = iconList[0].hIcolib;
bbd.dwButtonID = 6000;
bbd.iButtonWidth = 0;
- CallService (MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
+ CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd);
return 0;
}
@@ -402,25 +358,21 @@ void HideNudgeButton(HANDLE hContact)
char *szProto = GetContactProto(hContact);
mir_snprintf(str,MAXMODULELABELLENGTH + 12,"%s/SendNudge", szProto);
- if (!ServiceExists(str))
- {
- BBButton bbd={0};
- bbd.cbSize=sizeof(BBButton);
- bbd.bbbFlags=BBSF_HIDDEN|BBSF_DISABLED;
- bbd.pszModuleName="Nudge";
- bbd.dwButtonID = 6000;
- CallService(MS_BB_SETBUTTONSTATE, (WPARAM)hContact, (LPARAM)&bbd);
- }
+ if (!ServiceExists(str)) {
+ BBButton bbd = { sizeof(bbd) };
+ bbd.bbbFlags = BBSF_HIDDEN | BBSF_DISABLED;
+ bbd.pszModuleName="Nudge";
+ bbd.dwButtonID = 6000;
+ CallService(MS_BB_SETBUTTONSTATE, (WPARAM)hContact, (LPARAM)&bbd);
+ }
}
static int ContactWindowOpen(WPARAM wparam,LPARAM lParam)
{
MessageWindowEventData *MWeventdata = (MessageWindowEventData*)lParam;
-
if(MWeventdata->uType == MSG_WINDOW_EVT_OPENING&&MWeventdata->hContact)
- {
HideNudgeButton(MWeventdata->hContact);
- }
+
return 0;
}
@@ -432,11 +384,9 @@ int ModulesLoaded(WPARAM,LPARAM)
LoadIcons();
LoadPopupClass();
- g_hEventToolbarLoaded = HookEvent(ME_MSG_TOOLBARLOADED, TabsrmmButtonInit);
- if (g_hEventToolbarLoaded)
- {
- g_hEventButtonPressed = HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed);
- g_hEventDbWindowEvent = HookEvent(ME_MSG_WINDOWEVENT,ContactWindowOpen);
+ if ( HookEvent(ME_MSG_TOOLBARLOADED, TabsrmmButtonInit)) {
+ HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed);
+ HookEvent(ME_MSG_WINDOWEVENT,ContactWindowOpen);
}
return 0;
}
@@ -447,47 +397,29 @@ int AccListChanged(WPARAM wParam,LPARAM lParam)
if (proto==NULL)
return 0;
- switch (lParam)
- {
- case PRAC_ADDED:
- Nudge_AddAccount(proto);
- break;
- }
+ if (lParam == PRAC_ADDED)
+ Nudge_AddAccount(proto);
return 0;
}
-HANDLE hShakeClist=NULL,hShakeChat=NULL,hNudgeSend=NULL,hNudgeShowMenu=NULL;
extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
- g_hEventModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED,ModulesLoaded);
- g_hEventAccountsChanged = HookEvent(ME_PROTO_ACCLISTCHANGED,AccListChanged);
- hEventOptionsInitialize = HookEvent(ME_OPT_INITIALISE, NudgeOptInit);
+ HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ HookEvent(ME_PROTO_ACCLISTCHANGED,AccListChanged);
+ HookEvent(ME_OPT_INITIALISE, NudgeOptInit);
//Create function for plugins
- hShakeClist=CreateServiceFunction(MS_SHAKE_CLIST,ShakeClist);
- hShakeChat=CreateServiceFunction(MS_SHAKE_CHAT,ShakeChat);
- hNudgeSend=CreateServiceFunction(MS_NUDGE_SEND,NudgeSend);
- hNudgeShowMenu=CreateServiceFunction(MS_NUDGE_SHOWMENU,NudgeShowMenu);
+ CreateServiceFunction(MS_SHAKE_CLIST,ShakeClist);
+ CreateServiceFunction(MS_SHAKE_CHAT,ShakeChat);
+ CreateServiceFunction(MS_NUDGE_SEND,NudgeSend);
+ CreateServiceFunction(MS_NUDGE_SHOWMENU,NudgeShowMenu);
return 0;
}
extern "C" int __declspec(dllexport) Unload(void)
{
- if(g_hEventToolbarLoaded) UnhookEvent(g_hEventToolbarLoaded);
- if(g_hEventDbWindowEvent) UnhookEvent(g_hEventButtonPressed);
- if(g_hEventDbWindowEvent) UnhookEvent(g_hEventDbWindowEvent);
-
- UnhookEvent(g_hEventModulesLoaded);
- UnhookEvent(g_hEventAccountsChanged);
- UnhookEvent(hEventOptionsInitialize);
-
- DestroyServiceFunction(hShakeClist);
- DestroyServiceFunction(hShakeChat);
- DestroyServiceFunction(hNudgeSend);
- DestroyServiceFunction(hNudgeShowMenu);
-
NudgeElementList* p = NudgeList;
while ( p != NULL )
{
@@ -502,9 +434,8 @@ extern "C" int __declspec(dllexport) Unload(void)
LRESULT CALLBACK NudgePopUpProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
- switch(msg)
- {
- case WM_COMMAND:
+ switch(msg) {
+ case WM_COMMAND:
{
HANDLE hContact = PUGetContact(hWnd);
CallService(MS_MSG_SENDMESSAGET, (WPARAM)hContact, 0);
@@ -512,39 +443,35 @@ LRESULT CALLBACK NudgePopUpProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
break;
}
- case WM_CONTEXTMENU:
- PUDeletePopUp(hWnd);
- break;
- case UM_FREEPLUGINDATA:
- //Here we'd free our own data, if we had it.
- return FALSE;
- case UM_INITPOPUP:
- break;
- case UM_DESTROYPOPUP:
- break;
- case WM_NOTIFY:
- default:
- break;
+ case WM_CONTEXTMENU:
+ PUDeletePopUp(hWnd);
+ break;
+ case UM_FREEPLUGINDATA:
+ //Here we'd free our own data, if we had it.
+ return FALSE;
}
return DefWindowProc(hWnd,msg,wParam,lParam);
}
+static int OnShutdown(WPARAM,LPARAM)
+{
+ Popup_UnregisterClass(hPopupClass);
+ return 0;
+}
+
void LoadPopupClass()
{
- if(ServiceExists(MS_POPUP_REGISTERCLASS))
- {
- POPUPCLASS ppc = {0};
- ppc.cbSize = sizeof(ppc);
- ppc.flags = PCF_TCHAR;
- ppc.pszName = "Nudge";
- ppc.ptszDescription = LPGENT("Show Nudge");
- ppc.hIcon = Skin_GetIconByHandle(iconList[0].hIcolib);
- ppc.colorBack = NULL;
- ppc.colorText = NULL;
- ppc.iSeconds = 0;
- ppc.PluginWindowProc = NudgePopUpProc;
- CallService(MS_POPUP_REGISTERCLASS,0,(LPARAM)&ppc);
- }
+ POPUPCLASS ppc = { sizeof(ppc) };
+ ppc.flags = PCF_TCHAR;
+ ppc.pszName = "Nudge";
+ ppc.ptszDescription = LPGENT("Show Nudge");
+ ppc.hIcon = Skin_GetIconByHandle(iconList[0].hIcolib);
+ ppc.colorBack = NULL;
+ ppc.colorText = NULL;
+ ppc.iSeconds = 0;
+ ppc.PluginWindowProc = NudgePopUpProc;
+ if (hPopupClass = Popup_RegisterClass(&ppc))
+ HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown);
}
int Preview()
@@ -703,7 +630,7 @@ void Nudge_AddAccount(PROTOACCOUNT *proto)
{
char str[MAXMODULELABELLENGTH + 10];
mir_snprintf(str,sizeof(str),"%s/Nudge",proto->szModuleName);
- HANDLE hevent = HookEvent(str, NudgeRecieved);
+ HANDLE hevent = HookEvent(str, NudgeReceived);
if(hevent == NULL)
return;
diff --git a/plugins/Nudge/src/nudge.cpp b/plugins/Nudge/src/nudge.cpp
index 9fb9d377e4..51b6af9824 100644
--- a/plugins/Nudge/src/nudge.cpp
+++ b/plugins/Nudge/src/nudge.cpp
@@ -6,11 +6,11 @@ void CNudge::Save(void)
mir_snprintf(SectionName,512,"useByProtocol");
DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->useByProtocol);
mir_snprintf(SectionName,512,"RecvTimeSec");
- DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->recvTimeSec);
+ db_set_dw(NULL, "Nudge", SectionName, this->recvTimeSec);
mir_snprintf(SectionName,512,"SendTimeSec");
- DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->sendTimeSec);
+ db_set_dw(NULL, "Nudge", SectionName, this->sendTimeSec);
mir_snprintf(SectionName,512,"ResendDelaySec");
- DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->resendDelaySec);
+ db_set_dw(NULL, "Nudge", SectionName, this->resendDelaySec);
}
@@ -58,7 +58,7 @@ void CNudgeElement::Save(void)
mir_snprintf(SectionName,512,"%s-autoResend", ProtocolName);
DBWriteContactSettingByte(NULL, "Nudge", SectionName, this->autoResend);
mir_snprintf(SectionName,512,"%s-statusFlags", ProtocolName);
- DBWriteContactSettingDword(NULL, "Nudge", SectionName, this->statusFlags);
+ db_set_dw(NULL, "Nudge", SectionName, this->statusFlags);
mir_snprintf(SectionName,512,"%s-recText", ProtocolName);
DBWriteContactSettingTString(NULL, "Nudge", SectionName, this->recText);
mir_snprintf(SectionName,512,"%s-senText", ProtocolName);
diff --git a/plugins/Nudge/src/shake.cpp b/plugins/Nudge/src/shake.cpp
index 649646589f..7976d8fe88 100644
--- a/plugins/Nudge/src/shake.cpp
+++ b/plugins/Nudge/src/shake.cpp
@@ -12,10 +12,10 @@ void CShake::Load(void)
}
void CShake::Save(void)
{
- DBWriteContactSettingDword(NULL, "Nudge", "ScaleClist", this->nScaleClist);
- DBWriteContactSettingDword(NULL, "Nudge", "ScaleChat", this->nScaleChat);
- DBWriteContactSettingDword(NULL, "Nudge", "MoveClist", this->nMoveClist);
- DBWriteContactSettingDword(NULL, "Nudge", "MoveChat", this->nMoveChat);
+ db_set_dw(NULL, "Nudge", "ScaleClist", this->nScaleClist);
+ db_set_dw(NULL, "Nudge", "ScaleChat", this->nScaleChat);
+ db_set_dw(NULL, "Nudge", "MoveClist", this->nMoveClist);
+ db_set_dw(NULL, "Nudge", "MoveChat", this->nMoveChat);
}
DWORD WINAPI ShakeChatWindow(LPVOID Param)
diff --git a/plugins/Ping/src/utils.cpp b/plugins/Ping/src/utils.cpp
index 972d60845c..c87793fee8 100644
--- a/plugins/Ping/src/utils.cpp
+++ b/plugins/Ping/src/utils.cpp
@@ -300,11 +300,16 @@ void import_ping_addresses()
LeaveCriticalSection(&list_cs);
}
-HANDLE hIcoLibIconsChanged;
+HANDLE hPopupClass;
+HICON hIconResponding, hIconNotResponding, hIconTesting, hIconDisabled;
-HICON hIconResponding, hIconNotResponding, hIconTesting, hIconDisabled;
+static int OnShutdown(WPARAM, LPARAM)
+{
+ Popup_UnregisterClass(hPopupClass);
+ return 0;
+}
-int ReloadIcons(WPARAM wParam, LPARAM lParam)
+static int ReloadIcons(WPARAM wParam, LPARAM lParam)
{
hIconResponding = Skin_GetIcon("ping_responding");
hIconNotResponding = Skin_GetIcon("ping_not_responding");
@@ -332,16 +337,15 @@ void InitUtils()
hIconTesting = Skin_GetIcon("ping_testing");
hIconDisabled = Skin_GetIcon("ping_disabled");
- hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
-
- if (ServiceExists(MS_POPUP_REGISTERCLASS)) {
- POPUPCLASS test = { sizeof(test) };
- test.flags = PCF_TCHAR;
- test.hIcon = hIconResponding;
- test.iSeconds = -1;
- test.ptszDescription = TranslateT("Ping");
- test.pszName = "pingpopups";
- test.PluginWindowProc = NullWindowProc;
- CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&test);
- }
+ HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
+
+ POPUPCLASS test = { sizeof(test) };
+ test.flags = PCF_TCHAR;
+ test.hIcon = hIconResponding;
+ test.iSeconds = -1;
+ test.ptszDescription = TranslateT("Ping");
+ test.pszName = "pingpopups";
+ test.PluginWindowProc = NullWindowProc;
+ if (hPopupClass = Popup_RegisterClass(&test))
+ HookEvent(ME_SYSTEM_PRESHUTDOWN, OnShutdown);
}
diff --git a/plugins/Popup/src/main.cpp b/plugins/Popup/src/main.cpp
index b68a7e54f6..9eb494ad05 100644
--- a/plugins/Popup/src/main.cpp
+++ b/plugins/Popup/src/main.cpp
@@ -413,6 +413,7 @@ MIRAPI int Load(void)
CreateServiceFunction(MS_POPUP_REGISTERVFX, PopUp_RegisterVfx);
CreateServiceFunction(MS_POPUP_REGISTERCLASS, PopUp_RegisterPopupClass);
+ CreateServiceFunction(MS_POPUP_UNREGISTERCLASS, PopUp_UnregisterPopupClass);
CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, PopUp_CreateClassPopup);
//load icons / create hook
diff --git a/plugins/Popup/src/notifications.cpp b/plugins/Popup/src/notifications.cpp
index aa2a92338a..5c01266b9f 100644
--- a/plugins/Popup/src/notifications.cpp
+++ b/plugins/Popup/src/notifications.cpp
@@ -71,16 +71,21 @@ void LoadNotifications()
g_hntfError = RegisterNotification(&notification);
}
-void UnloadTreeData()
+void FreePopupClass(POPUPTREEDATA *ptd)
{
- for (int i=0; i < gTreeData.getCount(); ++i) {
- if (gTreeData[i]->typ == 2) {
- mir_free(gTreeData[i]->pupClass.pszName);
- mir_free(gTreeData[i]->pupClass.pszDescription);
- }
- mir_free(gTreeData[i]->pszTreeRoot);
- mir_free(gTreeData[i]->pszDescription);
+ if (ptd->typ == 2) {
+ mir_free(ptd->pupClass.pszName);
+ mir_free(ptd->pupClass.pszDescription);
}
+ mir_free(ptd->pszTreeRoot);
+ mir_free(ptd->pszDescription);
+ mir_free(ptd);
+}
+
+void UnloadTreeData()
+{
+ for (int i=0; i < gTreeData.getCount(); ++i)
+ FreePopupClass(gTreeData[i]);
gTreeData.destroy();
}
@@ -234,11 +239,12 @@ HANDLE RegisterNotification(POPUPNOTIFICATION *notification)
HANDLE FindTreeData(LPTSTR group, LPTSTR name, BYTE typ)
{
for(int i=0; i < gTreeData.getCount(); i++) {
- if ( gTreeData[i]->typ == typ &&
- (!group || (_tcscmp(gTreeData[i]->pszTreeRoot, group) == 0)) &&
- (!name || (_tcscmp(gTreeData[i]->pszDescription, name) == 0)))
+ POPUPTREEDATA *p = gTreeData[i];
+ if (p->typ == typ &&
+ (!group || (_tcscmp(p->pszTreeRoot, group) == 0)) &&
+ (!name || (_tcscmp(p->pszDescription, name) == 0)))
{
- return gTreeData[i];
+ return p;
}
}
return NULL;
diff --git a/plugins/Popup/src/notifications.h b/plugins/Popup/src/notifications.h
index 76b7bd2869..98aae6e144 100644
--- a/plugins/Popup/src/notifications.h
+++ b/plugins/Popup/src/notifications.h
@@ -49,6 +49,7 @@ extern HANDLE g_hntfError, g_hntfWarning, g_hntfNotification;
int TreeDataSortFunc(const POPUPTREEDATA *p1, const POPUPTREEDATA *p2);
HANDLE FindTreeData(LPTSTR group, LPTSTR name, BYTE typ);
+void FreePopupClass(POPUPTREEDATA *ptd);
void UnloadTreeData();
void LoadNotifications();
diff --git a/plugins/Popup/src/opt_class.cpp b/plugins/Popup/src/opt_class.cpp
index c3fce0c0b6..246eef9bfa 100644
--- a/plugins/Popup/src/opt_class.cpp
+++ b/plugins/Popup/src/opt_class.cpp
@@ -43,503 +43,453 @@ int ComboBox_SelectItem(HWND hwndCtl, int indexStart, char* data) {
//---------------------------------------------------------------------------
//Dialog Proc
-INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
- static TVITEM tvi = {0};
- static struct {
- UINT idCtrl;
- BYTE onTyp0;
- BYTE onTyp1;
- BYTE onTyp2;
- } ctrlsAll[] = {
- {IDC_TXT_TITLE1 ,0 ,1 ,1},
- {IDC_ENABLE ,0 ,1 ,1},
-
- {IDC_TXT_TIMEOUT ,0 ,1 ,1},
- {IDC_TIMEOUT ,0 ,1 ,1},
- {IDC_TIMEOUT_SPIN ,0 ,1 ,1},
- {IDC_TXT_TIMEOUT_SEC ,0 ,1 ,1},
- {IDC_TXT_TIMEOUT_DEFAULT ,0 ,1 ,1},
- {IDC_TXT_TIMEOUT_INFINITE ,0 ,1 ,1},
-
- {IDC_TXT_LACTION ,0 ,1 ,1},
- {IDC_LACTION ,0 ,1 ,1},
-
- {IDC_TXT_RACTION ,0 ,1 ,1},
- {IDC_RACTION ,0 ,1 ,1},
-
- {IDC_CHECKWINDOW ,0 ,0 ,0}, //may be delete ??
-
- {IDC_TXT_TITLE3 ,0 ,1 ,0},
- {IDC_SOFFLINE ,0 ,1 ,0},
- {IDC_SONLINE ,0 ,1 ,0},
- {IDC_SAWAY ,0 ,1 ,0},
- {IDC_SNA ,0 ,1 ,0},
- {IDC_SOCCUPIED ,0 ,1 ,0},
- {IDC_SDND ,0 ,1 ,0},
- {IDC_SFREE4CHAT ,0 ,1 ,0},
- {IDC_SINVISIBLE ,0 ,1 ,0},
- {IDC_SPHONE ,0 ,1 ,0},
- {IDC_SLUNCH ,0 ,1 ,0},
-
- {IDC_TXT_TITLE4 ,0 ,0 ,0},
- {IDC_SOFFLINE2 ,0 ,0 ,0},
- {IDC_SONLINE2 ,0 ,0 ,0},
- {IDC_SAWAY2 ,0 ,0 ,0},
- {IDC_SNA2 ,0 ,0 ,0},
- {IDC_SOCCUPIED2 ,0 ,0 ,0},
- {IDC_SDND2 ,0 ,0 ,0},
- {IDC_SFREE4CHAT2 ,0 ,0 ,0},
- {IDC_SINVISIBLE2 ,0 ,0 ,0},
- {IDC_SPHONE2 ,0 ,0 ,0},
- {IDC_SLUNCH2 ,0 ,0 ,0},
-
- {IDC_ICO_INFO ,0 ,1 ,1},
- {IDC_TXT_COLORS ,0 ,1 ,1},
- {IDC_MORE ,0 ,1 ,1},
-
- {IDC_PREVIEW ,0 ,1 ,1},
- };
-
- static UINT ctrlsClass[] = {
- IDC_TXT_TITLE1, /*IDC_TXT_TITLE3,*/
- IDC_TXT_TIMEOUT, IDC_TIMEOUT,
- IDC_TIMEOUT_SPIN, IDC_TXT_TIMEOUT_SEC,
- IDC_TXT_TIMEOUT_DEFAULT, IDC_TXT_TIMEOUT_INFINITE,
- IDC_TXT_LACTION, IDC_LACTION,
- IDC_TXT_RACTION, IDC_RACTION,
- IDC_ICO_INFO, IDC_TXT_COLORS,
- };
-
- static UINT ctrlsEnable[] = {
- IDC_TXT_TIMEOUT, IDC_TIMEOUT, IDC_TIMEOUT_SPIN,
- IDC_TXT_TIMEOUT_SEC , IDC_TXT_TIMEOUT_DEFAULT, IDC_TXT_TIMEOUT_INFINITE,
- IDC_TXT_LACTION, IDC_LACTION,
- IDC_TXT_RACTION, IDC_RACTION,
- /*IDC_CHECKWINDOW,*/ IDC_TXT_TITLE3, IDC_TXT_TITLE4,
- IDC_ICO_INFO, IDC_TXT_COLORS, IDC_MORE,
-
- IDC_SOFFLINE, IDC_SONLINE, IDC_SAWAY, IDC_SNA,
- IDC_SOCCUPIED, IDC_SDND, IDC_SFREE4CHAT,
- IDC_SINVISIBLE, IDC_SPHONE, IDC_SLUNCH,
-
- IDC_SOFFLINE2, IDC_SONLINE2, IDC_SAWAY2, IDC_SNA2,
- IDC_SOCCUPIED2, IDC_SDND2, IDC_SFREE4CHAT2,
- IDC_SINVISIBLE2, IDC_SPHONE2, IDC_SLUNCH2,
- };
-
- static UINT ctrlsContact[] = {
- /*IDC_CHECKWINDOW,*/ IDC_TXT_TITLE4,
- IDC_SOFFLINE2, IDC_SONLINE2, IDC_SAWAY2, IDC_SNA2,
- IDC_SOCCUPIED2, IDC_SDND2, IDC_SFREE4CHAT2,
- IDC_SINVISIBLE2, IDC_SPHONE2, IDC_SLUNCH2,
- };
-
- static int titleIds[] = {
- IDC_TXT_TITLE1,
- IDC_TXT_TITLE3,
- IDC_TXT_TITLE4,
- };
-
- static struct {
- int idCtrl;
- int iconId;
- char *title;
- DWORD statusFlag;
- DWORD disableWhenFlag;
- } statusButtons[] = {
- {IDC_SOFFLINE, SKINICON_STATUS_OFFLINE, "Offline", PF2_IDLE, PF2_IDLE},
- {IDC_SONLINE, SKINICON_STATUS_ONLINE, "Online", PF2_ONLINE, PF2_ONLINE},
- {IDC_SAWAY, SKINICON_STATUS_AWAY, "Away", PF2_SHORTAWAY, PF2_SHORTAWAY},
- {IDC_SNA, SKINICON_STATUS_NA, "NA", PF2_LONGAWAY, PF2_LONGAWAY},
- {IDC_SOCCUPIED, SKINICON_STATUS_OCCUPIED, "Occupied", PF2_LIGHTDND, PF2_LIGHTDND},
- {IDC_SDND, SKINICON_STATUS_DND, "DND", PF2_HEAVYDND, PF2_HEAVYDND},
- {IDC_SFREE4CHAT, SKINICON_STATUS_FREE4CHAT, "Free for chat", PF2_FREECHAT, PF2_FREECHAT},
- {IDC_SINVISIBLE, SKINICON_STATUS_INVISIBLE, "Invisible", PF2_INVISIBLE, PF2_INVISIBLE},
- {IDC_SPHONE, SKINICON_STATUS_ONTHEPHONE, "On the phone", PF2_ONTHEPHONE, PF2_ONTHEPHONE},
- {IDC_SLUNCH, SKINICON_STATUS_OUTTOLUNCH, "Out to lunch", PF2_OUTTOLUNCH, PF2_OUTTOLUNCH},
-
- {IDC_SOFFLINE2, SKINICON_STATUS_OFFLINE, "Offline", PF2_IDLE, PF2_IDLE<<16},
- {IDC_SONLINE2, SKINICON_STATUS_ONLINE, "Online", PF2_ONLINE, PF2_ONLINE<<16},
- {IDC_SAWAY2, SKINICON_STATUS_AWAY, "Away", PF2_SHORTAWAY, PF2_SHORTAWAY<<16},
- {IDC_SNA2, SKINICON_STATUS_NA, "NA", PF2_LONGAWAY, PF2_LONGAWAY<<16},
- {IDC_SOCCUPIED2, SKINICON_STATUS_OCCUPIED, "Occupied", PF2_LIGHTDND, PF2_LIGHTDND<<16},
- {IDC_SDND2, SKINICON_STATUS_DND, "DND", PF2_HEAVYDND, PF2_HEAVYDND<<16},
- {IDC_SFREE4CHAT2, SKINICON_STATUS_FREE4CHAT, "Free for chat", PF2_FREECHAT, PF2_FREECHAT<<16},
- {IDC_SINVISIBLE2, SKINICON_STATUS_INVISIBLE, "Invisible", PF2_INVISIBLE, PF2_INVISIBLE<<16},
- {IDC_SPHONE2, SKINICON_STATUS_ONTHEPHONE, "On the phone", PF2_ONTHEPHONE, PF2_ONTHEPHONE<<16},
- {IDC_SLUNCH2, SKINICON_STATUS_OUTTOLUNCH, "Out to lunch", PF2_OUTTOLUNCH, PF2_OUTTOLUNCH<<16},
- };
+struct {
+ UINT idCtrl;
+ BYTE onTyp0;
+ BYTE onTyp1;
+ BYTE onTyp2;
+}
+static ctrlsAll[] = {
+ {IDC_TXT_TITLE1 ,0 ,1 ,1},
+ {IDC_ENABLE ,0 ,1 ,1},
+
+ {IDC_TXT_TIMEOUT ,0 ,1 ,1},
+ {IDC_TIMEOUT ,0 ,1 ,1},
+ {IDC_TIMEOUT_SPIN ,0 ,1 ,1},
+ {IDC_TXT_TIMEOUT_SEC ,0 ,1 ,1},
+ {IDC_TXT_TIMEOUT_DEFAULT ,0 ,1 ,1},
+ {IDC_TXT_TIMEOUT_INFINITE ,0 ,1 ,1},
+
+ {IDC_TXT_LACTION ,0 ,1 ,1},
+ {IDC_LACTION ,0 ,1 ,1},
+
+ {IDC_TXT_RACTION ,0 ,1 ,1},
+ {IDC_RACTION ,0 ,1 ,1},
+
+ {IDC_CHECKWINDOW ,0 ,0 ,0}, //may be delete ??
+
+ {IDC_TXT_TITLE3 ,0 ,1 ,0},
+ {IDC_SOFFLINE ,0 ,1 ,0},
+ {IDC_SONLINE ,0 ,1 ,0},
+ {IDC_SAWAY ,0 ,1 ,0},
+ {IDC_SNA ,0 ,1 ,0},
+ {IDC_SOCCUPIED ,0 ,1 ,0},
+ {IDC_SDND ,0 ,1 ,0},
+ {IDC_SFREE4CHAT ,0 ,1 ,0},
+ {IDC_SINVISIBLE ,0 ,1 ,0},
+ {IDC_SPHONE ,0 ,1 ,0},
+ {IDC_SLUNCH ,0 ,1 ,0},
+
+ {IDC_TXT_TITLE4 ,0 ,0 ,0},
+ {IDC_SOFFLINE2 ,0 ,0 ,0},
+ {IDC_SONLINE2 ,0 ,0 ,0},
+ {IDC_SAWAY2 ,0 ,0 ,0},
+ {IDC_SNA2 ,0 ,0 ,0},
+ {IDC_SOCCUPIED2 ,0 ,0 ,0},
+ {IDC_SDND2 ,0 ,0 ,0},
+ {IDC_SFREE4CHAT2 ,0 ,0 ,0},
+ {IDC_SINVISIBLE2 ,0 ,0 ,0},
+ {IDC_SPHONE2 ,0 ,0 ,0},
+ {IDC_SLUNCH2 ,0 ,0 ,0},
+
+ {IDC_ICO_INFO ,0 ,1 ,1},
+ {IDC_TXT_COLORS ,0 ,1 ,1},
+ {IDC_MORE ,0 ,1 ,1},
+
+ {IDC_PREVIEW ,0 ,1 ,1},
+};
+
+static UINT ctrlsClass[] = {
+ IDC_TXT_TITLE1, /*IDC_TXT_TITLE3,*/
+ IDC_TXT_TIMEOUT, IDC_TIMEOUT,
+ IDC_TIMEOUT_SPIN, IDC_TXT_TIMEOUT_SEC,
+ IDC_TXT_TIMEOUT_DEFAULT, IDC_TXT_TIMEOUT_INFINITE,
+ IDC_TXT_LACTION, IDC_LACTION,
+ IDC_TXT_RACTION, IDC_RACTION,
+ IDC_ICO_INFO, IDC_TXT_COLORS,
+};
+
+static UINT ctrlsEnable[] = {
+ IDC_TXT_TIMEOUT, IDC_TIMEOUT, IDC_TIMEOUT_SPIN,
+ IDC_TXT_TIMEOUT_SEC , IDC_TXT_TIMEOUT_DEFAULT, IDC_TXT_TIMEOUT_INFINITE,
+ IDC_TXT_LACTION, IDC_LACTION,
+ IDC_TXT_RACTION, IDC_RACTION,
+ /*IDC_CHECKWINDOW,*/ IDC_TXT_TITLE3, IDC_TXT_TITLE4,
+ IDC_ICO_INFO, IDC_TXT_COLORS, IDC_MORE,
+
+ IDC_SOFFLINE, IDC_SONLINE, IDC_SAWAY, IDC_SNA,
+ IDC_SOCCUPIED, IDC_SDND, IDC_SFREE4CHAT,
+ IDC_SINVISIBLE, IDC_SPHONE, IDC_SLUNCH,
+
+ IDC_SOFFLINE2, IDC_SONLINE2, IDC_SAWAY2, IDC_SNA2,
+ IDC_SOCCUPIED2, IDC_SDND2, IDC_SFREE4CHAT2,
+ IDC_SINVISIBLE2, IDC_SPHONE2, IDC_SLUNCH2,
+};
+
+static UINT ctrlsContact[] = {
+ /*IDC_CHECKWINDOW,*/ IDC_TXT_TITLE4,
+ IDC_SOFFLINE2, IDC_SONLINE2, IDC_SAWAY2, IDC_SNA2,
+ IDC_SOCCUPIED2, IDC_SDND2, IDC_SFREE4CHAT2,
+ IDC_SINVISIBLE2, IDC_SPHONE2, IDC_SLUNCH2,
+};
+
+static int titleIds[] = {
+ IDC_TXT_TITLE1,
+ IDC_TXT_TITLE3,
+ IDC_TXT_TITLE4,
+};
+
+struct {
+ int idCtrl;
+ int iconId;
+ char *title;
+ DWORD statusFlag;
+ DWORD disableWhenFlag;
+}
+static statusButtons[] = {
+ {IDC_SOFFLINE, SKINICON_STATUS_OFFLINE, "Offline", PF2_IDLE, PF2_IDLE},
+ {IDC_SONLINE, SKINICON_STATUS_ONLINE, "Online", PF2_ONLINE, PF2_ONLINE},
+ {IDC_SAWAY, SKINICON_STATUS_AWAY, "Away", PF2_SHORTAWAY, PF2_SHORTAWAY},
+ {IDC_SNA, SKINICON_STATUS_NA, "NA", PF2_LONGAWAY, PF2_LONGAWAY},
+ {IDC_SOCCUPIED, SKINICON_STATUS_OCCUPIED, "Occupied", PF2_LIGHTDND, PF2_LIGHTDND},
+ {IDC_SDND, SKINICON_STATUS_DND, "DND", PF2_HEAVYDND, PF2_HEAVYDND},
+ {IDC_SFREE4CHAT, SKINICON_STATUS_FREE4CHAT, "Free for chat", PF2_FREECHAT, PF2_FREECHAT},
+ {IDC_SINVISIBLE, SKINICON_STATUS_INVISIBLE, "Invisible", PF2_INVISIBLE, PF2_INVISIBLE},
+ {IDC_SPHONE, SKINICON_STATUS_ONTHEPHONE, "On the phone", PF2_ONTHEPHONE, PF2_ONTHEPHONE},
+ {IDC_SLUNCH, SKINICON_STATUS_OUTTOLUNCH, "Out to lunch", PF2_OUTTOLUNCH, PF2_OUTTOLUNCH},
+
+ {IDC_SOFFLINE2, SKINICON_STATUS_OFFLINE, "Offline", PF2_IDLE, PF2_IDLE<<16},
+ {IDC_SONLINE2, SKINICON_STATUS_ONLINE, "Online", PF2_ONLINE, PF2_ONLINE<<16},
+ {IDC_SAWAY2, SKINICON_STATUS_AWAY, "Away", PF2_SHORTAWAY, PF2_SHORTAWAY<<16},
+ {IDC_SNA2, SKINICON_STATUS_NA, "NA", PF2_LONGAWAY, PF2_LONGAWAY<<16},
+ {IDC_SOCCUPIED2, SKINICON_STATUS_OCCUPIED, "Occupied", PF2_LIGHTDND, PF2_LIGHTDND<<16},
+ {IDC_SDND2, SKINICON_STATUS_DND, "DND", PF2_HEAVYDND, PF2_HEAVYDND<<16},
+ {IDC_SFREE4CHAT2, SKINICON_STATUS_FREE4CHAT, "Free for chat", PF2_FREECHAT, PF2_FREECHAT<<16},
+ {IDC_SINVISIBLE2, SKINICON_STATUS_INVISIBLE, "Invisible", PF2_INVISIBLE, PF2_INVISIBLE<<16},
+ {IDC_SPHONE2, SKINICON_STATUS_ONTHEPHONE, "On the phone", PF2_ONTHEPHONE, PF2_ONTHEPHONE<<16},
+ {IDC_SLUNCH2, SKINICON_STATUS_OUTTOLUNCH, "Out to lunch", PF2_OUTTOLUNCH, PF2_OUTTOLUNCH<<16},
+};
+
+INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ int i;
switch ( msg ) {
case WM_INITDIALOG:
- {
- int i;
TranslateDialogDefault( hwnd );
-
- //Treeview
- HWND hwndTree = GetDlgItem(hwnd, IDC_TREE1);
{
- int iconIndex = 0;
- char iconName[MAXMODULELABELLENGTH];
- TCHAR itemName[MAXMODULELABELLENGTH];
+ //Treeview
+ HWND hwndTree = GetDlgItem(hwnd, IDC_TREE1);
+
+ int iconIndex = 0;
+ char iconName[MAXMODULELABELLENGTH];
+ TCHAR itemName[MAXMODULELABELLENGTH];
TreeView_DeleteAllItems(hwndTree);
//Treeview create image list
HIMAGELIST hImgLst = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR|ILC_COLOR32|ILC_MASK, 5, num_classes+1);
ImageList_ReplaceIcon(hImgLst, -1, IcoLib_GetIcon(ICO_OPT_GROUP,0));
TreeView_SetImageList(hwndTree, hImgLst, TVSIL_NORMAL);
- for (i = 0; i < gTreeData.getCount(); ++i) {
+ for (i=0; i < gTreeData.getCount(); ++i) {
switch (gTreeData[i]->typ) {
- case 1: //Treeview part for typ 1 (notification)
- mir_snprintf(iconName, sizeof(iconName), "%s_%S_%S", MODULNAME, gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription);
- iconIndex = ImageList_ReplaceIcon(hImgLst, -1, IcoLib_GetIcon(iconName));
- wsprintf(itemName, _T("%s/%s"), gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription);
- break;
- case 2: //Treeview part typ 2 (popup class api)
- iconIndex = ImageList_ReplaceIcon(hImgLst, -1, gTreeData[i]->pupClass.hIcon);
- wsprintf(itemName, _T("%s/%s"), LPGENT("CLASS Plugins")/*gTreeData[i]->pszTreeRoot*/, gTreeData[i]->pszDescription);
- break;
- default:
- break;
+ case 1: //Treeview part for typ 1 (notification)
+ mir_snprintf(iconName, sizeof(iconName), "%s_%S_%S", MODULNAME, gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription);
+ iconIndex = ImageList_ReplaceIcon(hImgLst, -1, IcoLib_GetIcon(iconName));
+ wsprintf(itemName, _T("%s/%s"), gTreeData[i]->pszTreeRoot, gTreeData[i]->pszDescription);
+ break;
+ case 2: //Treeview part typ 2 (popup class api)
+ iconIndex = ImageList_ReplaceIcon(hImgLst, -1, gTreeData[i]->pupClass.hIcon);
+ wsprintf(itemName, _T("%s/%s"), LPGENT("CLASS Plugins")/*gTreeData[i]->pszTreeRoot*/, gTreeData[i]->pszDescription);
+ break;
}
OptTree_AddItem(hwndTree, itemName, (LPARAM)gTreeData[i], iconIndex);
}
OptTree_Translate(hwndTree);
- } // end Treeview
- //Bold Title
- for (i = 0; i < SIZEOF(titleIds); ++i)
- {
- LOGFONT lf;
- GetObject((HFONT)SendDlgItemMessage(hwnd, titleIds[i], WM_GETFONT, 0, 0), sizeof(lf), &lf);
- lf.lfWeight = FW_BOLD;
- SendDlgItemMessage(hwnd, titleIds[i], WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE);
- }
+ //Bold Title
+ for (i = 0; i < SIZEOF(titleIds); ++i) {
+ LOGFONT lf;
+ GetObject((HFONT)SendDlgItemMessage(hwnd, titleIds[i], WM_GETFONT, 0, 0), sizeof(lf), &lf);
+ lf.lfWeight = FW_BOLD;
+ SendDlgItemMessage(hwnd, titleIds[i], WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE);
+ }
- //spindown for Timeout
- SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(SETTING_LIFETIME_MAX, SETTING_LIFETIME_INFINITE));
- SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)0, TRUE);
- //status buttons
- for (i = 0; i < SIZEOF(statusButtons); ++i)
- {
- SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONSETASPUSHBTN, TRUE, 0);
- SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BM_SETIMAGE,
- IMAGE_ICON, (LPARAM)LoadSkinnedIcon(statusButtons[i].iconId));
- SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONADDTOOLTIP,
- (WPARAM)Translate(statusButtons[i].title), 0);
+ //spindown for Timeout
+ SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(SETTING_LIFETIME_MAX, SETTING_LIFETIME_INFINITE));
+ SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)0, TRUE);
+ //status buttons
+ for (i = 0; i < SIZEOF(statusButtons); ++i) {
+ SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONSETASPUSHBTN, TRUE, 0);
+ SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BM_SETIMAGE,
+ IMAGE_ICON, (LPARAM)LoadSkinnedIcon(statusButtons[i].iconId));
+ SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONADDTOOLTIP,
+ (WPARAM)Translate(statusButtons[i].title), 0);
+ }
+ //info icon
+ SendDlgItemMessage(hwnd, IDC_ICO_INFO, STM_SETICON, (WPARAM)IcoLib_GetIcon(ICO_MISC_NOTIFY,0), 0);
+ //more button
+ EnableWindow(GetDlgItem(hwnd, IDC_MORE), FALSE);
+ //preview button
+ ShowWindow(GetDlgItem(hwnd, IDC_CHECKWINDOW), SW_HIDE);
+
+ SendMessage(hwnd, WM_USER, 0, 0);
}
- //info icon
- SendDlgItemMessage(hwnd, IDC_ICO_INFO, STM_SETICON, (WPARAM)IcoLib_GetIcon(ICO_MISC_NOTIFY,0), 0);
- //more button
- EnableWindow(GetDlgItem(hwnd, IDC_MORE), FALSE);
- //preview button
- ShowWindow(GetDlgItem(hwnd, IDC_CHECKWINDOW), SW_HIDE);
-
- SendMessage(hwnd, WM_USER, 0, 0);
-
return TRUE;
- }
+
case WM_USER:
- {
- int i;
- HWND hTV = GetDlgItem(hwnd, IDC_TREE1);
- //get TreeView selection
- tvi.hItem = TreeView_GetSelection(hTV);
- tvi.mask = TVIF_PARAM|TVIF_HANDLE|TVIF_TEXT;
- if (tvi.hItem) TreeView_GetItem(hTV, &tvi);
- SetWindowLongPtr(hwnd, GWLP_USERDATA, tvi.lParam);
-
- if (tvi.lParam) {
- POPUPTREEDATA* ptd = (POPUPTREEDATA *)tvi.lParam;
- HWND hCtrl = 0;
- LPTSTR psztSelect = NULL;
- int index = 0;
- //combo left action (default)
- {
- hCtrl = GetDlgItem(hwnd, IDC_LACTION);
+ {
+ HWND hTV = GetDlgItem(hwnd, IDC_TREE1);
+ //get TreeView selection
+ TVITEM tvi = { 0 };
+ tvi.hItem = TreeView_GetSelection(hTV);
+ tvi.mask = TVIF_PARAM|TVIF_HANDLE|TVIF_TEXT;
+ if (tvi.hItem) TreeView_GetItem(hTV, &tvi);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, tvi.lParam);
+
+ if (tvi.lParam) {
+ POPUPTREEDATA* ptd = (POPUPTREEDATA *)tvi.lParam;
+ LPTSTR psztSelect = NULL;
+ int index = 0;
+ //combo left action (default)
+
+ HWND hCtrl = GetDlgItem(hwnd, IDC_LACTION);
ComboBox_ResetContent(hCtrl);
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT(POPUP_ACTION_DISMISS)),POPUP_ACTION_DISMISS);
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT(POPUP_ACTION_NOTHING)),POPUP_ACTION_NOTHING);
- }
- //combo right action (default)
- {
+
+ //combo right action (default)
hCtrl = GetDlgItem(hwnd, IDC_RACTION);
ComboBox_ResetContent(hCtrl);
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT(POPUP_ACTION_DISMISS)),POPUP_ACTION_DISMISS);
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT(POPUP_ACTION_NOTHING)),POPUP_ACTION_NOTHING);
- }
-
- //element typ1 (Notification)
- if (ptd->typ == 1) {
- LPTSTR psztAction = NULL;
- //Timeout
- SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)ptd->timeoutValue, TRUE);
- SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, -1));
- //combo left action (EXTRA)
- hCtrl = GetDlgItem(hwnd, IDC_LACTION);
- for (i = 0; i < ptd->notification.actionCount; ++i) {
- psztAction = mir_a2t(ptd->notification.lpActions[i].lpzTitle);
- ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateTS(psztAction)),ptd->notification.lpActions[i].lpzTitle);
- mir_free(psztAction); psztAction = NULL;
- }
- //combo right action (EXTRA)
- hCtrl = GetDlgItem(hwnd, IDC_RACTION);
- psztAction = NULL;
- for (i = 0; i < ptd->notification.actionCount; ++i) {
- psztAction = mir_a2t(ptd->notification.lpActions[i].lpzTitle);
- ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateTS(psztAction)),ptd->notification.lpActions[i].lpzTitle);
- mir_free(psztAction); psztAction = NULL;
+
+ //element typ1 (Notification)
+ if (ptd->typ == 1) {
+ LPTSTR psztAction = NULL;
+ //Timeout
+ SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)ptd->timeoutValue, TRUE);
+ SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, -1));
+ //combo left action (EXTRA)
+ hCtrl = GetDlgItem(hwnd, IDC_LACTION);
+ for (i = 0; i < ptd->notification.actionCount; ++i) {
+ psztAction = mir_a2t(ptd->notification.lpActions[i].lpzTitle);
+ ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateTS(psztAction)),ptd->notification.lpActions[i].lpzTitle);
+ mir_free(psztAction); psztAction = NULL;
+ }
+ //combo right action (EXTRA)
+ hCtrl = GetDlgItem(hwnd, IDC_RACTION);
+ psztAction = NULL;
+ for (i = 0; i < ptd->notification.actionCount; ++i) {
+ psztAction = mir_a2t(ptd->notification.lpActions[i].lpzTitle);
+ ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateTS(psztAction)),ptd->notification.lpActions[i].lpzTitle);
+ mir_free(psztAction); psztAction = NULL;
+ }
+ //enable all controls
+ for (i = 0; i < SIZEOF(ctrlsAll); ++i){
+ ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp1 ? SW_SHOW : SW_HIDE);
+ EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp1);
+ }
+ //enable or disable controls ctrlsEnable
+ for (i = 0; i < SIZEOF(ctrlsEnable); ++i)
+ EnableWindow(GetDlgItem(hwnd, ctrlsEnable[i]), ptd->enabled ? TRUE : FALSE);
+ //show or hide controls ctrlsContact
+ for (i = 0; i < SIZEOF(ctrlsContact); ++i)
+ ShowWindow(GetDlgItem(hwnd, ctrlsContact[i]), ptd->notification.dwFlags&PNF_CONTACT ? SW_SHOW : SW_HIDE);
+ //statusButtons state
+ for (i = 0; i < SIZEOF(statusButtons); ++i)
+ CheckDlgButton(hwnd, statusButtons[i].idCtrl, ptd->disableWhen & statusButtons[i].disableWhenFlag ? TRUE : FALSE);
}
- //enable all controls
- for (i = 0; i < SIZEOF(ctrlsAll); ++i){
- ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp1 ? SW_SHOW : SW_HIDE);
- EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp1);
+ //element typ2 (CLASS Plugins)
+ else if (ptd->typ == 2) {
+ //Timeout
+ SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)ptd->timeoutValue, TRUE);
+ SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, -1));
+ //enable ctrls
+ for (i = 0; i < SIZEOF(ctrlsAll); ++i){
+ ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp2 ? SW_SHOW : SW_HIDE);
+ EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp2);
+ }
}
- //enable or disable controls ctrlsEnable
- for (i = 0; i < SIZEOF(ctrlsEnable); ++i)
- EnableWindow(GetDlgItem(hwnd, ctrlsEnable[i]), ptd->enabled ? TRUE : FALSE);
- //show or hide controls ctrlsContact
- for (i = 0; i < SIZEOF(ctrlsContact); ++i)
- ShowWindow(GetDlgItem(hwnd, ctrlsContact[i]), ptd->notification.dwFlags&PNF_CONTACT ? SW_SHOW : SW_HIDE);
- //statusButtons state
- for (i = 0; i < SIZEOF(statusButtons); ++i)
- CheckDlgButton(hwnd, statusButtons[i].idCtrl, ptd->disableWhen & statusButtons[i].disableWhenFlag ? TRUE : FALSE);
- }
- //element typ2 (CLASS Plugins)
- else if (ptd->typ == 2) {
- //Timeout
- SetDlgItemInt(hwnd,IDC_TIMEOUT, (UINT)ptd->timeoutValue, TRUE);
- SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, -1));
- //enable ctrls
- for (i = 0; i < SIZEOF(ctrlsAll); ++i){
- ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp2 ? SW_SHOW : SW_HIDE);
- EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp2);
+ //checkbox enable notify
+ CheckDlgButton(hwnd, IDC_ENABLE, ptd->enabled ? TRUE : FALSE);
+ //combo left action (SELECT)
+ hCtrl = GetDlgItem(hwnd, IDC_LACTION);
+ ComboBox_SelectItem (hCtrl, -1, ptd->leftAction); //use Workaround for MS bug ComboBox_SelectItemData
+ //combo right action (SELECT)
+ hCtrl = GetDlgItem(hwnd, IDC_RACTION);
+ ComboBox_SelectItem (hCtrl, -1, ptd->rightAction); //use Workaround for MS bug ComboBox_SelectItemData
+ } //end if (tvi.lParam)
+ else {
+ //enable / disable controls
+ for (int i=0; i < SIZEOF(ctrlsAll); ++i) {
+ ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0 ? SW_SHOW : SW_HIDE);
+ EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0);
}
}
- //checkbox enable notify
- CheckDlgButton(hwnd, IDC_ENABLE, ptd->enabled ? TRUE : FALSE);
- //combo left action (SELECT)
- hCtrl = GetDlgItem(hwnd, IDC_LACTION);
- ComboBox_SelectItem (hCtrl, -1, ptd->leftAction); //use Workaround for MS bug ComboBox_SelectItemData
- //combo right action (SELECT)
- hCtrl = GetDlgItem(hwnd, IDC_RACTION);
- ComboBox_SelectItem (hCtrl, -1, ptd->rightAction); //use Workaround for MS bug ComboBox_SelectItemData
- } //end if (tvi.lParam)
- else {
- //enable / disable controls
- for (int i=0; i < SIZEOF(ctrlsAll); ++i) {
- ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0 ? SW_SHOW : SW_HIDE);
- EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0);
- }
}
break;
- }
+
case WM_COMMAND:
- {
- UINT idCtrl = LOWORD(wParam);
- POPUPTREEDATA* ptd = (POPUPTREEDATA *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (!ptd) break;
- switch (HIWORD(wParam)) {
- int i;
+ {
+ UINT idCtrl = LOWORD(wParam);
+ POPUPTREEDATA* ptd = (POPUPTREEDATA *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ if (!ptd) break;
+ switch (HIWORD(wParam)) {
case BN_CLICKED: //Button controls
switch(idCtrl) {
- case IDC_ENABLE:
- ptd->enabled = (BYTE)Button_GetCheck((HWND)lParam);
- for (i = 0; i < SIZEOF(ctrlsEnable); ++i)
- EnableWindow(GetDlgItem(hwnd, ctrlsEnable[i]), ptd->enabled);
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- break;
- case IDC_PREVIEW:
- {
- POPUPDATA2 ppd = {0};
- ppd.cbSize = sizeof(ppd);
- ppd.flags = PU2_TCHAR;
- ppd.lptzTitle = ptd->pszDescription;
- ppd.lptzText = TranslateT("Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!");
- ppd.iSeconds = ptd->timeoutValue;
- ppd.colorBack = ptd->colorBack;
- ppd.colorText = ptd->colorText;
- POPUPTREEDATA *ptdPrev = NULL;
- if (ptd->typ == 1) {
- //we work with a copy for preview
- ptdPrev = (POPUPTREEDATA *)mir_alloc(sizeof(POPUPTREEDATA));
- memcpy(ptdPrev, ptd, sizeof(POPUPTREEDATA));
- ptdPrev->enabled = ptd->enabled;
- ptdPrev->timeoutValue = ptd->timeoutValue;
- strcpy(ptdPrev->leftAction, ptd->leftAction); //geht noch nicht??
- strcpy(ptdPrev->rightAction, ptd->rightAction); //geht noch nicht??
- ptdPrev->disableWhen = ptd->disableWhen;
-
- ppd.lchNotification = (HANDLE)ptdPrev;
- }
- else if (ptd->typ == 2)
- ppd.lchIcon = ptd->pupClass.hIcon;
-
- CallService(MS_POPUP_ADDPOPUP2, (WPARAM)&ppd, APF_NO_HISTORY);
- mir_free(ptdPrev); ptdPrev = NULL;
- }
- break;
- case IDC_MORE:
- {
- OPENOPTIONSDIALOG ood = {0};
- ood.cbSize = sizeof(OPENOPTIONSDIALOG);
- ood.pszGroup = "Customize";
- ood.pszPage = "Fonts & Colors";
- Options_Open(&ood);
- }
- break;
- case IDC_SOFFLINE: case IDC_SONLINE: case IDC_SAWAY: case IDC_SNA: case IDC_SOCCUPIED:
- case IDC_SDND: case IDC_SFREE4CHAT: case IDC_SINVISIBLE: case IDC_SPHONE: case IDC_SLUNCH:
- case IDC_SOFFLINE2: case IDC_SONLINE2: case IDC_SAWAY2: case IDC_SNA2: case IDC_SOCCUPIED2:
- case IDC_SDND2: case IDC_SFREE4CHAT2: case IDC_SINVISIBLE2: case IDC_SPHONE2: case IDC_SLUNCH2:
- {
- ptd->disableWhen = 0;
- for (i = 0; i < SIZEOF(statusButtons); ++i) {
- if (IsDlgButtonChecked(hwnd, statusButtons[i].idCtrl))
- ptd->disableWhen |= statusButtons[i].disableWhenFlag;
- if (idCtrl == statusButtons[i].idCtrl)
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
+ case IDC_ENABLE:
+ ptd->enabled = (BYTE)Button_GetCheck((HWND)lParam);
+ for (i = 0; i < SIZEOF(ctrlsEnable); ++i)
+ EnableWindow(GetDlgItem(hwnd, ctrlsEnable[i]), ptd->enabled);
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_PREVIEW:
+ {
+ POPUPDATA2 ppd = {0};
+ ppd.cbSize = sizeof(ppd);
+ ppd.flags = PU2_TCHAR;
+ ppd.lptzTitle = ptd->pszDescription;
+ ppd.lptzText = TranslateT("Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn!");
+ ppd.iSeconds = ptd->timeoutValue;
+ ppd.colorBack = ptd->colorBack;
+ ppd.colorText = ptd->colorText;
+ POPUPTREEDATA *ptdPrev = NULL;
+ if (ptd->typ == 1) {
+ //we work with a copy for preview
+ ptdPrev = (POPUPTREEDATA *)mir_alloc(sizeof(POPUPTREEDATA));
+ memcpy(ptdPrev, ptd, sizeof(POPUPTREEDATA));
+ ptdPrev->enabled = ptd->enabled;
+ ptdPrev->timeoutValue = ptd->timeoutValue;
+ strcpy(ptdPrev->leftAction, ptd->leftAction); //geht noch nicht??
+ strcpy(ptdPrev->rightAction, ptd->rightAction); //geht noch nicht??
+ ptdPrev->disableWhen = ptd->disableWhen;
+
+ ppd.lchNotification = (HANDLE)ptdPrev;
}
- break;
- default:
- break;
+ else if (ptd->typ == 2)
+ ppd.lchIcon = ptd->pupClass.hIcon;
+
+ CallService(MS_POPUP_ADDPOPUP2, (WPARAM)&ppd, APF_NO_HISTORY);
+ mir_free(ptdPrev); ptdPrev = NULL;
+ }
+ break;
+ case IDC_MORE:
+ {
+ OPENOPTIONSDIALOG ood = { sizeof(ood) };
+ ood.pszGroup = "Customize";
+ ood.pszPage = "Fonts & Colors";
+ Options_Open(&ood);
+ }
+ break;
+
+ case IDC_SOFFLINE: case IDC_SONLINE: case IDC_SAWAY: case IDC_SNA: case IDC_SOCCUPIED:
+ case IDC_SDND: case IDC_SFREE4CHAT: case IDC_SINVISIBLE: case IDC_SPHONE: case IDC_SLUNCH:
+ case IDC_SOFFLINE2: case IDC_SONLINE2: case IDC_SAWAY2: case IDC_SNA2: case IDC_SOCCUPIED2:
+ case IDC_SDND2: case IDC_SFREE4CHAT2: case IDC_SINVISIBLE2: case IDC_SPHONE2: case IDC_SLUNCH2:
+ ptd->disableWhen = 0;
+ for (i = 0; i < SIZEOF(statusButtons); ++i) {
+ if (IsDlgButtonChecked(hwnd, statusButtons[i].idCtrl))
+ ptd->disableWhen |= statusButtons[i].disableWhenFlag;
+ if (idCtrl == statusButtons[i].idCtrl)
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
}
break;
+
case CBN_SELCHANGE: //ComboBox controls
switch(idCtrl) {
- //lParam = Handle to the control
- case IDC_LACTION:
- lstrcpynA(ptd->leftAction,
- (char *)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)),
- sizeof(ptd->leftAction));
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- break;
- case IDC_RACTION:
- lstrcpynA(ptd->rightAction,
- (char *)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)),
- sizeof(ptd->rightAction));
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- break;
- default:
- break;
+ case IDC_LACTION:
+ lstrcpynA(ptd->leftAction,
+ (char *)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)),
+ sizeof(ptd->leftAction));
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ break;
+ case IDC_RACTION:
+ lstrcpynA(ptd->rightAction,
+ (char *)ComboBox_GetItemData((HWND)lParam, ComboBox_GetCurSel((HWND)lParam)),
+ sizeof(ptd->rightAction));
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ break;
}
break;
+
case EN_CHANGE: //Edit controls
switch(idCtrl) {
- //lParam = Handle to the control
- case IDC_TIMEOUT:
- {
- int seconds = GetDlgItemInt(hwnd, idCtrl, NULL, TRUE);
- if ( seconds >= SETTING_LIFETIME_INFINITE &&
- seconds <= SETTING_LIFETIME_MAX &&
- seconds != ptd->timeoutValue) {
- ptd->timeoutValue = seconds;
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
- }
- break;
- default:
- break;
+ case IDC_TIMEOUT:
+ int seconds = GetDlgItemInt(hwnd, idCtrl, NULL, TRUE);
+ if (seconds >= SETTING_LIFETIME_INFINITE && seconds <= SETTING_LIFETIME_MAX && seconds != ptd->timeoutValue) {
+ ptd->timeoutValue = seconds;
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
}
break;
+
case EN_KILLFOCUS: //Edit controls lost fokus
switch(idCtrl) {
- //lParam = Handle to the control
- case IDC_TIMEOUT:
- {
- int seconds = GetDlgItemInt(hwnd, idCtrl, NULL, TRUE);
- if (seconds > SETTING_LIFETIME_MAX)
- ptd->timeoutValue = SETTING_LIFETIME_MAX;
- else if (seconds < SETTING_LIFETIME_INFINITE)
- ptd->timeoutValue = SETTING_LIFETIME_INFINITE;
- if (seconds != ptd->timeoutValue) {
- SetDlgItemInt(hwnd, idCtrl, ptd->timeoutValue, TRUE);
- ErrorMSG(SETTING_LIFETIME_INFINITE, SETTING_LIFETIME_MAX);
- SetFocus((HWND)lParam);
- }
- }
- break;
- default:
- break;
- }//end switch(idCtrl)
- break;
- default:
- break;
+ case IDC_TIMEOUT:
+ int seconds = GetDlgItemInt(hwnd, idCtrl, NULL, TRUE);
+ if (seconds > SETTING_LIFETIME_MAX)
+ ptd->timeoutValue = SETTING_LIFETIME_MAX;
+ else if (seconds < SETTING_LIFETIME_INFINITE)
+ ptd->timeoutValue = SETTING_LIFETIME_INFINITE;
+ if (seconds != ptd->timeoutValue) {
+ SetDlgItemInt(hwnd, idCtrl, ptd->timeoutValue, TRUE);
+ ErrorMSG(SETTING_LIFETIME_INFINITE, SETTING_LIFETIME_MAX);
+ SetFocus((HWND)lParam);
+ }
+ }
+ }
}
break;
- }
+
case WM_NOTIFY:
- {
switch(((LPNMHDR)lParam)->idFrom) {
- case 0:
- {
- switch (((LPNMHDR)lParam)->code) {
- case PSN_RESET:
- {
- for(int i=0; i < gTreeData.getCount(); ++i) {
- switch (gTreeData[i]->typ) {
- case 1:
- LoadNotificationSettings(gTreeData[i], "PopUpNotifications");
- break;
- case 2: //not finish
- LoadClassSettings(gTreeData[i], PU_MODULCLASS);
- gTreeData[i]->timeoutValue = gTreeData[i]->pupClass.iSeconds;
- break;
- default:
- break;
- }
- }
- return TRUE;
- }
- case PSN_APPLY:
- {
- for(int i=0; i < gTreeData.getCount(); ++i) {
- switch (gTreeData[i]->typ) {
- case 1:
- gTreeData[i]->notification.iSeconds = gTreeData[i]->timeoutValue;
- SaveNotificationSettings(gTreeData[i],"PopUpNotifications");
- break;
- case 2: //not finish
- gTreeData[i]->pupClass.iSeconds = gTreeData[i]->timeoutValue;
- SaveClassSettings(gTreeData[i],"PopUpCLASS");
- break;
- default:
- break;
- }
- }
- return TRUE;
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_RESET:
+ for(i=0; i < gTreeData.getCount(); ++i) {
+ switch (gTreeData[i]->typ) {
+ case 1:
+ LoadNotificationSettings(gTreeData[i], "PopUpNotifications");
+ break;
+ case 2: //not finish
+ LoadClassSettings(gTreeData[i], PU_MODULCLASS);
+ gTreeData[i]->timeoutValue = gTreeData[i]->pupClass.iSeconds;
+ break;
}
}
- break;
- }
-
- case IDC_TREE1:
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case TVN_SELCHANGEDA:
- case TVN_SELCHANGEDW:
- {
- PostMessage(hwnd, WM_USER, 0, 0);
+ return TRUE;
+
+ case PSN_APPLY:
+ for(i=0; i < gTreeData.getCount(); ++i) {
+ switch (gTreeData[i]->typ) {
+ case 1:
+ gTreeData[i]->notification.iSeconds = gTreeData[i]->timeoutValue;
+ SaveNotificationSettings(gTreeData[i],"PopUpNotifications");
+ break;
+ case 2: //not finish
+ gTreeData[i]->pupClass.iSeconds = gTreeData[i]->timeoutValue;
+ SaveClassSettings(gTreeData[i],"PopUpCLASS");
break;
}
}
+ return TRUE;
+ }
+ break;
+
+ case IDC_TREE1:
+ switch (((LPNMHDR)lParam)->code) {
+ case TVN_SELCHANGEDA:
+ case TVN_SELCHANGEDW:
+ PostMessage(hwnd, WM_USER, 0, 0);
break;
}
}
break;
}
-
- case WM_DESTROY:
- ZeroMemory(&tvi,sizeof(tvi));
- break;
-
- default:
- return FALSE;
- }
return FALSE;
}
diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp
index 191cb42e47..9e3c4ca797 100644
--- a/plugins/Popup/src/services.cpp
+++ b/plugins/Popup/src/services.cpp
@@ -28,28 +28,24 @@ int num_classes = 0; //for core class api support
// isWorkstationLocked() code from core
bool isWorkstationLocked()
{
- bool rc = false;
-
if (OpenInputDesktop != NULL) {
HDESK hDesk = OpenInputDesktop(0, FALSE, DESKTOP_SWITCHDESKTOP);
if (hDesk == NULL)
- rc = true;
- else if (CloseDesktop != NULL)
+ return true;
+ if (CloseDesktop != NULL)
CloseDesktop(hDesk);
}
- return rc;
+ return false;
}
// isFullScreen() code from core
static bool isFullScreen()
{
RECT rcScreen = {0};
-
rcScreen.right = GetSystemMetrics(SM_CXSCREEN);
rcScreen.bottom = GetSystemMetrics(SM_CYSCREEN);
- if (MonitorFromWindow != NULL)
- {
+ if (MonitorFromWindow != NULL) {
HMONITOR hMon = MonitorFromWindow(GetForegroundWindow(), MONITOR_DEFAULTTONEAREST);
MONITORINFO mi;
mi.cbSize = sizeof(mi);
@@ -461,24 +457,24 @@ INT_PTR PopUp_RegisterVfx(WPARAM wParam, LPARAM lParam)
}
//===== PopUp/RegisterClass (for core class api support)
-INT_PTR PopUp_RegisterPopupClass(WPARAM wParam, LPARAM lParam) {
+INT_PTR PopUp_RegisterPopupClass(WPARAM wParam, LPARAM lParam)
+{
char setting[256];
- POPUPCLASS *pc = (POPUPCLASS *)lParam;
- POPUPTREEDATA *ptd = (POPUPTREEDATA *)mir_alloc(sizeof(POPUPTREEDATA));
- memset(ptd,0,sizeof(POPUPTREEDATA));
- ptd->cbSize = sizeof(POPUPTREEDATA);
+ POPUPCLASS *pc = (POPUPCLASS *)lParam;
+ POPUPTREEDATA *ptd = (POPUPTREEDATA *)mir_calloc(sizeof(POPUPTREEDATA));
+ ptd->cbSize = sizeof(POPUPTREEDATA);
ptd->signature = 0/*PopupNotificationData_SIGNATURE*/;
- ptd->typ = 2;
+ ptd->typ = 2;
memcpy(&ptd->pupClass, pc, sizeof(POPUPCLASS));
- ptd->pszTreeRoot = mir_a2t(pc->pszName);
- ptd->pupClass.pszName = mir_strdup(pc->pszName);
+ ptd->pszTreeRoot = mir_a2t(pc->pszName);
+ ptd->pupClass.pszName = mir_strdup(pc->pszName);
if (pc->flags & PCF_UNICODE) {
ptd->pupClass.pwszDescription = mir_wstrdup(pc->pwszDescription);
- ptd->pszDescription = mir_u2t(pc->pwszDescription);
+ ptd->pszDescription = mir_u2t(pc->pwszDescription);
}
else {
- ptd->pupClass.pszDescription = mir_strdup (pc->pszDescription);
- ptd->pszDescription = mir_a2t(pc->pszDescription);
+ ptd->pupClass.pszDescription = mir_strdup(pc->pszDescription);
+ ptd->pszDescription = mir_a2t(pc->pszDescription);
}
LoadClassSettings(ptd, PU_MODULCLASS);
@@ -514,8 +510,23 @@ INT_PTR PopUp_RegisterPopupClass(WPARAM wParam, LPARAM lParam) {
gTreeData.insert(ptd);
num_classes++;
+ return (INT_PTR)ptd;
+}
- return 0;
+INT_PTR PopUp_UnregisterPopupClass(WPARAM wParam, LPARAM lParam)
+{
+ POPUPTREEDATA *ptd = (POPUPTREEDATA*)lParam;
+ if (ptd == NULL)
+ return 1;
+
+ for (int i=0; i < gTreeData.getCount(); i++)
+ if (gTreeData[i] == ptd) {
+ gTreeData.remove(i);
+ FreePopupClass(ptd);
+ return 0;
+ }
+
+ return 1;
}
//===== PopUp/AddPopupClass (for core class api support)
@@ -527,32 +538,31 @@ INT_PTR PopUp_CreateClassPopup(WPARAM wParam, LPARAM lParam) {
POPUPCLASS *pc = NULL;
POPUPTREEDATA *ptd = NULL;
- if (wParam) pc = (POPUPCLASS *)wParam;
+ if (wParam) pc = (POPUPCLASS*)wParam;
else {
LPTSTR group = mir_a2t(pdc->pszClassName);
ptd = (POPUPTREEDATA *)FindTreeData(group, NULL, 2);
if (ptd) pc = &ptd->pupClass;
}
if (pc) {
- POPUPDATA2 ppd2 = {0};
- ppd2.cbSize = sizeof(POPUPDATA2);
- ppd2.colorBack = pc->colorBack;
- ppd2.colorText = pc->colorText;
- ppd2.lchIcon = pc->hIcon;
- ppd2.iSeconds = pc->iSeconds;
- ppd2.PluginWindowProc = pc->PluginWindowProc;
+ POPUPDATA2 ppd2 = { sizeof(ppd2) };
+ ppd2.colorBack = pc->colorBack;
+ ppd2.colorText = pc->colorText;
+ ppd2.lchIcon = pc->hIcon;
+ ppd2.iSeconds = pc->iSeconds;
+ ppd2.PluginWindowProc= pc->PluginWindowProc;
if (pc->flags & PCF_UNICODE) {
- ppd2.flags = PU2_UNICODE;
- ppd2.lpwzTitle = (WCHAR*)pdc->pwszTitle;
- ppd2.lpwzText = (WCHAR*)pdc->pwszText;
+ ppd2.flags = PU2_UNICODE;
+ ppd2.lpwzTitle = (WCHAR*)pdc->pwszTitle;
+ ppd2.lpwzText = (WCHAR*)pdc->pwszText;
}
else {
- ppd2.flags = PU2_ANSI;
- ppd2.lpzTitle = (char *)pdc->pszTitle;
- ppd2.lpzText = (char *)pdc->pszText;
+ ppd2.flags = PU2_ANSI;
+ ppd2.lpzTitle = (char *)pdc->pszTitle;
+ ppd2.lpzText = (char *)pdc->pszText;
}
- ppd2.lchContact = pdc->hContact;
- ppd2.PluginData = pdc->PluginData;
+ ppd2.lchContact = pdc->hContact;
+ ppd2.PluginData = pdc->PluginData;
ret = PopUp_AddPopUp2((WPARAM)&ppd2, 0);
}
diff --git a/plugins/Popup/src/services.h b/plugins/Popup/src/services.h
index 30258db64a..1e965fbbe2 100644
--- a/plugins/Popup/src/services.h
+++ b/plugins/Popup/src/services.h
@@ -50,6 +50,7 @@ INT_PTR PopUp_UnhookEventAsync(WPARAM wParam, LPARAM lParam);
INT_PTR PopUp_RegisterVfx(WPARAM wParam, LPARAM lParam);
INT_PTR PopUp_RegisterPopupClass(WPARAM wParam, LPARAM lParam);
+INT_PTR PopUp_UnregisterPopupClass(WPARAM wParam, LPARAM lParam);
INT_PTR PopUp_CreateClassPopup(WPARAM wParam, LPARAM lParam);
#endif // __services_h__
diff --git a/plugins/YAPP/src/options.cpp b/plugins/YAPP/src/options.cpp
index e8f06ceea2..182504ac21 100644
--- a/plugins/YAPP/src/options.cpp
+++ b/plugins/YAPP/src/options.cpp
@@ -346,26 +346,24 @@ static INT_PTR CALLBACK DlgProcOpts1(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
return 0;
}
-POPUPCLASS *newclasses = 0;
+LIST<POPUPCLASS> arNewClasses(3);
+
static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch ( msg ) {
case WM_INITDIALOG:
TranslateDialogDefault( hwndDlg );
- if (num_classes) {
- newclasses = (POPUPCLASS *)mir_alloc(num_classes * sizeof(POPUPCLASS));
- memcpy(newclasses, classes, num_classes * sizeof(POPUPCLASS));
-
- POPUPCLASS *pc;
+ arNewClasses = arClasses;
+ {
int index;
- for (int i = 0; i < num_classes; i++) {
- pc = &newclasses[i];
- if (pc->flags & PCF_UNICODE) {
+ for (int i = 0; i < arNewClasses.getCount(); i++) {
+ POPUPCLASS *pc = arNewClasses[i];
+ if (pc->flags & PCF_UNICODE)
index = SendDlgItemMessageW(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pwszDescription);
- } else {
+ else
index = SendDlgItemMessageA(hwndDlg, IDC_LST_CLASSES, LB_ADDSTRING, 0, (LPARAM)pc->pszDescription);
- }
+
SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_SETITEMDATA, index, i);
}
}
@@ -380,24 +378,26 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_TIMEOUT), index != -1);
if (index != -1) {
int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
- SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_SETCOLOUR, 0, (LPARAM)newclasses[i].colorText);
- SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_SETCOLOUR, 0, (LPARAM)newclasses[i].colorBack);
- CheckDlgButton(hwndDlg, IDC_CHK_TIMEOUT, newclasses[i].iSeconds != -1);
- SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].iSeconds, TRUE);
+ SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_SETCOLOUR, 0, (LPARAM)arNewClasses[i]->colorText);
+ SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_SETCOLOUR, 0, (LPARAM)arNewClasses[i]->colorBack);
+ CheckDlgButton(hwndDlg, IDC_CHK_TIMEOUT, arNewClasses[i]->iSeconds != -1);
+ SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, arNewClasses[i]->iSeconds, TRUE);
}
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), index != -1 && IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT));
return TRUE;
- } else if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
+ }
+ if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus()) {
int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
if (index != -1) {
int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
BOOL tr;
int t = GetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, &tr, FALSE);
- newclasses[i].iSeconds = t;
+ arNewClasses[i]->iSeconds = t;
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
}
- } else {
+ }
+ else {
int index = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETCURSEL, 0, 0);
if (index != -1) {
int i = SendDlgItemMessage(hwndDlg, IDC_LST_CLASSES, LB_GETITEMDATA, index, 0);
@@ -406,33 +406,33 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
{
BOOL isChecked = IsDlgButtonChecked(hwndDlg, IDC_CHK_TIMEOUT);
EnableWindow(GetDlgItem(hwndDlg, IDC_ED_TIMEOUT), isChecked);
- if (isChecked) newclasses[i].iSeconds = 0;
- else newclasses[i].iSeconds = -1;
- SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, newclasses[i].iSeconds, TRUE);
+ if (isChecked) arNewClasses[i]->iSeconds = 0;
+ else arNewClasses[i]->iSeconds = -1;
+ SetDlgItemInt(hwndDlg, IDC_ED_TIMEOUT, arNewClasses[i]->iSeconds, TRUE);
}
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
break;
case IDC_COL_TEXT:
- newclasses[i].colorText = SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_GETCOLOUR, 0, 0);
+ arNewClasses[i]->colorText = SendDlgItemMessage(hwndDlg, IDC_COL_TEXT, CPM_GETCOLOUR, 0, 0);
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
break;
case IDC_COL_BG:
- newclasses[i].colorBack = SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_GETCOLOUR, 0, 0);
+ arNewClasses[i]->colorBack = SendDlgItemMessage(hwndDlg, IDC_COL_BG, CPM_GETCOLOUR, 0, 0);
SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
break;
case IDC_BTN_PREVIEW:
- if (newclasses[i].flags & PCF_UNICODE) {
- POPUPCLASS pc = newclasses[i];
+ if (arNewClasses[i]->flags & PCF_UNICODE) {
+ POPUPCLASS pc = *arNewClasses[i];
pc.PluginWindowProc = 0;
POPUPDATACLASS d = {sizeof(d), pc.pszName};
d.pwszTitle = L"Preview";
d.pwszText = L"The quick brown fox jumps over the lazy dog.";
CallService(MS_POPUP_ADDPOPUPCLASS, (WPARAM)&pc, (LPARAM)&d);
} else {
- POPUPCLASS pc = newclasses[i];
+ POPUPCLASS pc = *arNewClasses[i];
pc.PluginWindowProc = 0;
POPUPDATACLASS d = {sizeof(d), pc.pszName};
d.pszTitle = "Preview";
@@ -447,22 +447,23 @@ static INT_PTR CALLBACK DlgProcOptsClasses(HWND hwndDlg, UINT msg, WPARAM wParam
case WM_NOTIFY:
if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY ) {
- memcpy(classes, newclasses, num_classes * sizeof(POPUPCLASS));
+ arClasses = arNewClasses;
char setting[256];
- for (int i = 0; i < num_classes; i++) {
- mir_snprintf(setting, 256, "%s/Timeout", classes[i].pszName);
- DBWriteContactSettingWord(0, MODULE, setting, classes[i].iSeconds);
- mir_snprintf(setting, 256, "%s/TextCol", classes[i].pszName);
- db_set_dw(0, MODULE, setting, (DWORD)classes[i].colorText);
- mir_snprintf(setting, 256, "%s/BgCol", classes[i].pszName);
- db_set_dw(0, MODULE, setting, (DWORD)classes[i].colorBack);
+ for (int i = 0; i < arClasses.getCount(); i++) {
+ POPUPCLASS *pc = arClasses[i];
+ mir_snprintf(setting, 256, "%s/Timeout", pc->pszName);
+ DBWriteContactSettingWord(0, MODULE, setting, pc->iSeconds);
+ mir_snprintf(setting, 256, "%s/TextCol", pc->pszName);
+ db_set_dw(0, MODULE, setting, (DWORD)pc->colorText);
+ mir_snprintf(setting, 256, "%s/BgCol", pc->pszName);
+ db_set_dw(0, MODULE, setting, (DWORD)pc->colorBack);
}
return TRUE;
}
break;
case WM_DESTROY:
- mir_free(newclasses);
+ arNewClasses.destroy();
break;
}
return 0;
diff --git a/plugins/YAPP/src/services.cpp b/plugins/YAPP/src/services.cpp
index 2a22a6d99e..4848788544 100644
--- a/plugins/YAPP/src/services.cpp
+++ b/plugins/YAPP/src/services.cpp
@@ -299,15 +299,12 @@ INT_PTR PopUp_ShowHistory(WPARAM wParam, LPARAM lParam)
return 0;
}
-int num_classes = 0;
-POPUPCLASS *classes = 0;
+LIST<POPUPCLASS> arClasses(3);
static INT_PTR RegisterPopupClass(WPARAM wParam, LPARAM lParam)
{
- classes = (POPUPCLASS *)mir_realloc(classes, sizeof(POPUPCLASS) * (num_classes + 1));
- memcpy(classes + num_classes, (PVOID)lParam, sizeof(POPUPCLASS));
- POPUPCLASS *pc = classes + num_classes;
- num_classes++;
+ POPUPCLASS *pc = (POPUPCLASS*)mir_alloc( sizeof(POPUPCLASS));
+ memcpy(pc, (PVOID)lParam, sizeof(POPUPCLASS));
pc->pszName = mir_strdup(pc->pszName);
if (pc->flags & PCF_UNICODE)
@@ -324,7 +321,31 @@ static INT_PTR RegisterPopupClass(WPARAM wParam, LPARAM lParam)
mir_snprintf(setting, 256, "%s/BgCol", pc->pszName);
pc->colorBack = (COLORREF)db_get_dw(0, MODULE, setting, (DWORD)pc->colorBack);
- return 0;
+ arClasses.insert(pc);
+ return (INT_PTR)pc;
+}
+
+static void FreePopupClass(POPUPCLASS *pc)
+{
+ mir_free(pc->pszName);
+ mir_free(pc->pszDescription);
+ mir_free(pc);
+}
+
+static INT_PTR UnregisterPopupClass(WPARAM wParam, LPARAM lParam)
+{
+ POPUPCLASS *pc = (POPUPCLASS*)lParam;
+ if (pc == NULL)
+ return 1;
+
+ for (int i=0; i < arClasses.getCount(); i++)
+ if (arClasses[i] == pc) {
+ arClasses.remove(i);
+ FreePopupClass(pc);
+ return 0;
+ }
+
+ return 1;
}
static INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam)
@@ -336,9 +357,9 @@ static INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam)
if (wParam)
pc = (POPUPCLASS *)wParam;
else {
- for (int i = 0; i < num_classes; i++) {
- if (strcmp(classes[i].pszName, pdc->pszClassName) == 0) {
- pc = &classes[i];
+ for (int i = 0; i < arClasses.getCount(); i++) {
+ if ( strcmp(arClasses[i]->pszName, pdc->pszClassName) == 0) {
+ pc = arClasses[i];
break;
}
}
@@ -367,6 +388,8 @@ static INT_PTR CreateClassPopup(WPARAM wParam, LPARAM lParam)
void InitServices()
{
CreateServiceFunction(MS_POPUP_REGISTERCLASS, RegisterPopupClass);
+ CreateServiceFunction(MS_POPUP_UNREGISTERCLASS, UnregisterPopupClass);
+
CreateServiceFunction(MS_POPUP_ADDPOPUPCLASS, CreateClassPopup);
CreateServiceFunction(MS_POPUP_ADDPOPUP, CreatePopup);
CreateServiceFunction(MS_POPUP_ADDPOPUPW, CreatePopupW);
@@ -383,9 +406,6 @@ void InitServices()
CreateServiceFunction(MS_POPUP_SHOWHISTORY, PopUp_ShowHistory);
CreateServiceFunction("PopUp/ToggleEnabled", TogglePopups);
- CreateServiceFunction("YAPP/RegisterClass", RegisterPopupClass);
- CreateServiceFunction("YAPP/ClassInstance", CreateClassPopup);
-
////////////////////////////////////////////////////////////////////////////
// Menus
@@ -408,9 +428,7 @@ void InitServices()
void DeinitServices()
{
- for (int i = 0; i < num_classes; i++) {
- mir_free(classes[i].pszName);
- mir_free(classes[i].pszDescription);
- }
- mir_free(classes); num_classes = 0;
+ for (int i = 0; i < arClasses.getCount(); i++)
+ FreePopupClass(arClasses[i]);
+ arClasses.destroy();
}
diff --git a/plugins/YAPP/src/services.h b/plugins/YAPP/src/services.h
index 8243b0ba8b..91e9500b02 100644
--- a/plugins/YAPP/src/services.h
+++ b/plugins/YAPP/src/services.h
@@ -4,7 +4,6 @@
void InitServices();
void DeinitServices();
-extern int num_classes;
-extern POPUPCLASS *classes;
+extern LIST<POPUPCLASS> arClasses;
#endif
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp
index f753f2a863..af082ae1f3 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.cpp
+++ b/protocols/Gadu-Gadu/src/gg_proto.cpp
@@ -93,6 +93,9 @@ GGPROTO::~GGPROTO()
keepalive_destroy();
gc_destroy();
+ Popup_UnregisterClass(hPopupError);
+ Popup_UnregisterClass(hPopupNotify);
+
if (hMenuRoot)
CallService(MS_CLIST_REMOVEMAINMENUITEM, (WPARAM)hMenuRoot, 0);
diff --git a/protocols/Gadu-Gadu/src/gg_proto.h b/protocols/Gadu-Gadu/src/gg_proto.h
index 6bb5a1565c..d462f420f3 100644
--- a/protocols/Gadu-Gadu/src/gg_proto.h
+++ b/protocols/Gadu-Gadu/src/gg_proto.h
@@ -286,6 +286,7 @@ struct GGPROTO : public PROTO_INTERFACE
HANDLE hAvatarsFolder;
HANDLE hImagesFolder;
HWND hwndSessionsDlg;
+ HANDLE hPopupNotify, hPopupError;
};
typedef struct
diff --git a/protocols/Gadu-Gadu/src/popups.cpp b/protocols/Gadu-Gadu/src/popups.cpp
index 386435c973..fcd58ea3e9 100644
--- a/protocols/Gadu-Gadu/src/popups.cpp
+++ b/protocols/Gadu-Gadu/src/popups.cpp
@@ -79,9 +79,9 @@ void GGPROTO::initpopups()
puc.cbSize = sizeof(puc);
puc.PluginWindowProc = PopupWindowProc;
puc.flags = PCF_TCHAR;
-
puc.ptszDescription = szDescr;
puc.pszName = szName;
+
puc.colorBack = RGB(173, 206, 247);
puc.colorText = GetSysColor(COLOR_WINDOWTEXT);
puc.hIcon = CopyIcon(LoadIconEx("main", FALSE));
@@ -89,17 +89,15 @@ void GGPROTO::initpopups()
puc.iSeconds = 4;
mir_sntprintf(szDescr, SIZEOF(szDescr), _T("%s/%s"), m_tszUserName, TranslateT("Notify"));
mir_snprintf(szName, SIZEOF(szName), "%s_%s", m_szModuleName, "Notify");
- CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&puc);
+ hPopupNotify = Popup_RegisterClass(&puc);
- puc.ptszDescription = szDescr;
- puc.pszName = szName;
puc.colorBack = RGB(191, 0, 0); // Red
puc.colorText = RGB(255, 245, 225); // Yellow
puc.iSeconds = 60;
puc.hIcon = (HICON)LoadImage(NULL, IDI_WARNING, IMAGE_ICON, 0, 0, LR_SHARED);
mir_sntprintf(szDescr, SIZEOF(szDescr), _T("%s/%s"), m_tszUserName, TranslateT("Error"));
mir_snprintf(szName, SIZEOF(szName), "%s_%s", m_szModuleName, "Error");
- CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&puc);
+ hPopupError = Popup_RegisterClass(&puc);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber.h b/protocols/JabberG/src/jabber.h
index 36787c6fdb..1eedf528db 100644
--- a/protocols/JabberG/src/jabber.h
+++ b/protocols/JabberG/src/jabber.h
@@ -78,6 +78,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_timezones.h>
#include <m_jabber.h>
#include <m_fingerprint.h>
+#include <m_popup.h>
+#include <m_folders.h>
#include <m_xstatus.h>
#include <m_extraicons.h>
#include <win2k.h>
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index d33595adeb..4182cccb23 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -1357,7 +1357,7 @@ static void sttLogListHook(CJabberProto* ppro, JABBER_LIST_ITEM* item, GCHOOK* g
mir_ptr<TCHAR> ptszBuf((TCHAR*)mir_alloc( sizeof(TCHAR) * cbLen));
if (item->itemResource.statusMessage) {
TCHAR *d = ptszBuf;
- for (int i = 0; i < cbLen; i++) {
+ for (int i = 0; i < (int)cbLen; i++) {
if (item->itemResource.statusMessage[ i ] != _T('\n') || (i && item->itemResource.statusMessage[ i - 1 ] == _T('\r')))
*d++ = item->itemResource.statusMessage[ i ];
else {
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index 31f10ad5c5..0d8167fa89 100644
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -26,9 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_list.h"
#include "jabber_caps.h"
-#include <m_popup.h>
-#include "m_folders.h"
-
///////////////////////////////////////////////////////////////////////////////
// JabberAddContactToRoster() - adds a contact to the roster
@@ -623,22 +620,20 @@ void CJabberProto::SetContactOfflineStatus(HANDLE hContact)
void CJabberProto::InitPopups(void)
{
TCHAR desc[256];
+ mir_sntprintf(desc, SIZEOF(desc), _T("%s %s"), m_tszUserName, TranslateT("Errors"));
+
char name[256];
+ mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Error");
- POPUPCLASS ppc = {0};
- ppc.cbSize = sizeof(ppc);
+ POPUPCLASS ppc = { sizeof(ppc) };
ppc.flags = PCF_TCHAR;
-
ppc.ptszDescription = desc;
ppc.pszName = name;
ppc.hIcon = LoadIconEx("main");
ppc.colorBack = RGB(191, 0, 0); //Red
ppc.colorText = RGB(255, 245, 225); //Yellow
ppc.iSeconds = 60;
- mir_sntprintf(desc, SIZEOF(desc), _T("%s %s"), m_tszUserName, TranslateT("Errors"));
- mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Error");
-
- CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&ppc);
+ m_hPopupClass = Popup_RegisterClass(&ppc);
}
void CJabberProto::MsgPopup(HANDLE hContact, const TCHAR *szMsg, const TCHAR *szTitle)
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index eb81e2002a..9958742177 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -215,6 +215,9 @@ CJabberProto::~CJabberProto()
ConsoleUninit();
GlobalMenuUninit();
+ if (m_hPopupClass)
+ Popup_UnregisterClass(m_hPopupClass);
+
delete m_pInfoFrame;
DestroyHookableEvent(m_hEventNudge);
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index f37f1f264d..44c1e3352c 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -991,6 +991,8 @@ private:
DWORD m_lastTicks;
+ HANDLE m_hPopupClass;
+
HANDLE m_hJabberAvatarsFolder;
BOOL m_bFoldersInitDone;
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp
index e6b86d244f..f39fe781c0 100644
--- a/protocols/MSN/src/msn_misc.cpp
+++ b/protocols/MSN/src/msn_misc.cpp
@@ -974,33 +974,27 @@ void CMsnProto::InitPopups(void)
TCHAR desc[256];
char name[256];
- POPUPCLASS ppc = {0};
- ppc.cbSize = sizeof(ppc);
+ POPUPCLASS ppc = { sizeof(ppc) };
ppc.flags = PCF_TCHAR;
ppc.PluginWindowProc = NullWindowProc;
-
ppc.hIcon = LoadIconEx("main");
-
ppc.ptszDescription = desc;
ppc.pszName = name;
+
ppc.colorBack = RGB(173, 206, 247);
ppc.colorText = GetSysColor(COLOR_WINDOWTEXT);
ppc.iSeconds = 3;
mir_sntprintf(desc, SIZEOF(desc), _T("%s/%s"), m_tszUserName, TranslateT("Hotmail"));
mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Hotmail");
- CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&ppc);
+ hPopupHotmail = Popup_RegisterClass(&ppc);
- ppc.ptszDescription = desc;
- ppc.pszName = name;
ppc.colorBack = RGB(173, 206, 247);
ppc.colorText = GetSysColor(COLOR_WINDOWTEXT);
ppc.iSeconds = 3;
mir_sntprintf(desc, SIZEOF(desc), _T("%s/%s"), m_tszUserName, TranslateT("Notify"));
mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Notify");
- CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&ppc);
+ hPopupNotify = Popup_RegisterClass(&ppc);
- ppc.ptszDescription = desc;
- ppc.pszName = name;
ppc.hIcon = (HICON)LoadImage(NULL, IDI_WARNING, IMAGE_ICON, 0, 0, LR_SHARED);
ppc.colorBack = RGB(191, 0, 0); //Red
ppc.colorText = RGB(255, 245, 225); //Yellow
@@ -1008,7 +1002,7 @@ void CMsnProto::InitPopups(void)
mir_sntprintf(desc, SIZEOF(desc), _T("%s/%s"), m_tszUserName, TranslateT("Error"));
mir_snprintf(name, SIZEOF(name), "%s_%s", m_szModuleName, "Error");
- CallService(MS_POPUP_REGISTERCLASS, 0, (WPARAM)&ppc);
+ hPopupError = Popup_RegisterClass(&ppc);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/MSN/src/msn_proto.cpp b/protocols/MSN/src/msn_proto.cpp
index 5b9872f84a..c1ed5e4f56 100644
--- a/protocols/MSN/src/msn_proto.cpp
+++ b/protocols/MSN/src/msn_proto.cpp
@@ -227,6 +227,10 @@ int CMsnProto::OnModulesLoaded(WPARAM, LPARAM)
int CMsnProto::OnPreShutdown(WPARAM, LPARAM)
{
SetEvent(hevAvatarQueue);
+
+ Popup_UnregisterClass(hPopupError);
+ Popup_UnregisterClass(hPopupHotmail);
+ Popup_UnregisterClass(hPopupNotify);
return 0;
}
diff --git a/protocols/MSN/src/msn_proto.h b/protocols/MSN/src/msn_proto.h
index e572663f0d..b9819eb099 100644
--- a/protocols/MSN/src/msn_proto.h
+++ b/protocols/MSN/src/msn_proto.h
@@ -187,10 +187,10 @@ struct CMsnProto : public PROTO_INTERFACE
clock_t mStatusMsgTS;
HANDLE msnSearchId;
- HANDLE hNetlibUser;
- HANDLE hNetlibUserHttps;
+ HANDLE hNetlibUser, hNetlibUserHttps;
HANDLE hHttpsConnection;
HANDLE hMSNNudge;
+ HANDLE hPopupError, hPopupHotmail, hPopupNotify;
HANDLE hMSNAvatarsFolder;
HANDLE hCustomSmileyFolder;