summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-12-27 19:48:21 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-12-27 19:48:21 +0000
commit08997af71f3b28d1fc23f22b63552de23b0ab883 (patch)
treed741b4a5639a96fc02bcbaeeabad50125a8d6017
parent8d164e182630c7077055ac779de5f1ae5610f694 (diff)
Nudge to create its own type of events
git-svn-id: http://svn.miranda-ng.org/main/trunk@7398 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Nudge/src/Version.h24
-rw-r--r--plugins/Nudge/src/main.cpp441
-rw-r--r--plugins/Nudge/src/nudge.cpp152
-rw-r--r--plugins/Nudge/src/nudge.h3
-rw-r--r--plugins/Nudge/src/options.cpp653
-rw-r--r--plugins/Nudge/src/options.h8
-rw-r--r--plugins/Nudge/src/shake.cpp124
7 files changed, 660 insertions, 745 deletions
diff --git a/plugins/Nudge/src/Version.h b/plugins/Nudge/src/Version.h
index 943c4f1c9d..1b7943e7db 100644
--- a/plugins/Nudge/src/Version.h
+++ b/plugins/Nudge/src/Version.h
@@ -1,14 +1,14 @@
-#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 0
-#define __RELEASE_NUM 2
-#define __BUILD_NUM 0
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 1
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 0
-#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
-#define __PLUGIN_NAME "Nudge"
-#define __FILENAME "Nudge.dll"
-#define __DESCRIPTION "Plugin to shake the clist and chat window."
-#define __AUTHOR "Tweety/GouZ, FREAK_THEMIGHTY"
-#define __AUTHOREMAIL "francois.mean@skynet.be, Sylvain.gougouzian@gmail.com, wishmaster51@googlemail.com"
-#define __AUTHORWEB "http://miranda-ng.org/p/Nudge/"
-#define __COPYRIGHT "© the miranda community"
+#define __PLUGIN_NAME "Nudge"
+#define __FILENAME "Nudge.dll"
+#define __DESCRIPTION "Plugin to shake the clist and chat window."
+#define __AUTHOR "Tweety/GouZ, FREAK_THEMIGHTY"
+#define __AUTHOREMAIL "francois.mean@skynet.be, Sylvain.gougouzian@gmail.com, wishmaster51@googlemail.com"
+#define __AUTHORWEB "http://miranda-ng.org/p/Nudge/"
+#define __COPYRIGHT "© the miranda community"
diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp
index 2bc4ddbfbb..d8cefa3bd2 100644
--- a/plugins/Nudge/src/main.cpp
+++ b/plugins/Nudge/src/main.cpp
@@ -14,7 +14,7 @@ int hLangpack = 0;
//========================
// MirandaPluginInfo
//========================
-PLUGININFOEX pluginInfo={
+PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_NAME,
PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
@@ -25,13 +25,13 @@ PLUGININFOEX pluginInfo={
__AUTHORWEB,
UNICODE_AWARE,
// {E47CC215-0D28-462D-A0F6-3AE4443D2926}
- {0xe47cc215, 0xd28, 0x462d, {0xa0, 0xf6, 0x3a, 0xe4, 0x44, 0x3d, 0x29, 0x26}}
+ { 0xe47cc215, 0xd28, 0x462d, { 0xa0, 0xf6, 0x3a, 0xe4, 0x44, 0x3d, 0x29, 0x26 } }
};
INT_PTR NudgeShowMenu(WPARAM wParam,LPARAM lParam)
{
- for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
- if (!strcmp((char *) wParam,n->item.ProtocolName)) {
+ for (NudgeElementList *n = NudgeList; n != NULL; n = n->next)
+ if (!strcmp((char *)wParam, n->item.ProtocolName)) {
Menu_ShowItem(n->item.hContactMenu, lParam != 0);
break;
}
@@ -39,35 +39,33 @@ INT_PTR NudgeShowMenu(WPARAM wParam,LPARAM lParam)
return 0;
}
-INT_PTR NudgeSend(WPARAM wParam,LPARAM lParam)
+INT_PTR NudgeSend(WPARAM wParam, LPARAM lParam)
{
char *protoName = GetContactProto((HANDLE)wParam);
- int diff = time(NULL) - db_get_dw((HANDLE) wParam, "Nudge", "LastSent", time(NULL)-30);
-
- if(diff < GlobalNudge.sendTimeSec)
- {
+ int diff = time(NULL) - db_get_dw((HANDLE)wParam, "Nudge", "LastSent", time(NULL) - 30);
+ if (diff < GlobalNudge.sendTimeSec) {
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);
- 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);
+ 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);
+ 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;
}
- db_set_dw((HANDLE) wParam, "Nudge", "LastSent", time(NULL));
+ db_set_dw((HANDLE)wParam, "Nudge", "LastSent", time(NULL));
- if(GlobalNudge.useByProtocol) {
- for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
- if (!strcmp(protoName,n->item.ProtocolName))
- if(n->item.showStatus)
- Nudge_SentStatus(n->item, (HANDLE) wParam);
+ if (GlobalNudge.useByProtocol) {
+ for (NudgeElementList *n = NudgeList; n != NULL; n = n->next)
+ if (!strcmp(protoName, n->item.ProtocolName))
+ if (n->item.showStatus)
+ Nudge_SentStatus(n->item, (HANDLE)wParam);
}
- else if(DefaultNudge.showStatus)
- Nudge_SentStatus(DefaultNudge, (HANDLE) wParam);
+ else if (DefaultNudge.showStatus)
+ Nudge_SentStatus(DefaultNudge, (HANDLE)wParam);
CallProtoService(protoName, PS_SEND_NUDGE, wParam, lParam);
return 0;
@@ -80,123 +78,114 @@ void OpenContactList()
ShowWindow(hWnd, SW_SHOW);
}
-int NudgeReceived(WPARAM wParam,LPARAM lParam)
+int NudgeReceived(WPARAM wParam, LPARAM lParam)
{
char *protoName = GetContactProto((HANDLE)wParam);
DWORD currentTimestamp = time(NULL);
DWORD nudgeSentTimestamp = lParam ? (DWORD)lParam : currentTimestamp;
- int diff = currentTimestamp - db_get_dw((HANDLE) wParam, "Nudge", "LastReceived", currentTimestamp-30);
- int diff2 = nudgeSentTimestamp - db_get_dw((HANDLE) wParam, "Nudge", "LastReceived2", nudgeSentTimestamp-30);
+ int diff = currentTimestamp - db_get_dw((HANDLE)wParam, "Nudge", "LastReceived", currentTimestamp - 30);
+ int diff2 = nudgeSentTimestamp - db_get_dw((HANDLE)wParam, "Nudge", "LastReceived2", nudgeSentTimestamp - 30);
- if(diff >= GlobalNudge.recvTimeSec)
- db_set_dw((HANDLE) wParam, "Nudge", "LastReceived", currentTimestamp);
- if(diff2 >= GlobalNudge.recvTimeSec)
- db_set_dw((HANDLE) wParam, "Nudge", "LastReceived2", nudgeSentTimestamp);
+ if (diff >= GlobalNudge.recvTimeSec)
+ db_set_dw((HANDLE)wParam, "Nudge", "LastReceived", currentTimestamp);
+ if (diff2 >= GlobalNudge.recvTimeSec)
+ db_set_dw((HANDLE)wParam, "Nudge", "LastReceived2", nudgeSentTimestamp);
- if(GlobalNudge.useByProtocol)
- {
- for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
- {
- if (!strcmp(protoName,n->item.ProtocolName))
- {
+ if (GlobalNudge.useByProtocol) {
+ for (NudgeElementList *n = NudgeList; n != NULL; n = n->next) {
+ if (!strcmp(protoName, n->item.ProtocolName)) {
- if(n->item.enabled)
- {
- if(n->item.useIgnoreSettings && CallService(MS_IGNORE_ISIGNORED,wParam,IGNOREEVENT_USERONLINE))
+ if (n->item.enabled) {
+ if (n->item.useIgnoreSettings && CallService(MS_IGNORE_ISIGNORED, wParam, IGNOREEVENT_USERONLINE))
return 0;
- DWORD Status = CallProtoService(protoName,PS_GETSTATUS,0,0);
-
- if ( ((n->item.statusFlags & NUDGE_ACC_ST0) && (Status<=ID_STATUS_OFFLINE)) ||
- ((n->item.statusFlags & NUDGE_ACC_ST1) && (Status==ID_STATUS_ONLINE)) ||
- ((n->item.statusFlags & NUDGE_ACC_ST2) && (Status==ID_STATUS_AWAY)) ||
- ((n->item.statusFlags & NUDGE_ACC_ST3) && (Status==ID_STATUS_DND)) ||
- ((n->item.statusFlags & NUDGE_ACC_ST4) && (Status==ID_STATUS_NA)) ||
- ((n->item.statusFlags & NUDGE_ACC_ST5) && (Status==ID_STATUS_OCCUPIED)) ||
- ((n->item.statusFlags & NUDGE_ACC_ST6) && (Status==ID_STATUS_FREECHAT)) ||
- ((n->item.statusFlags & NUDGE_ACC_ST7) && (Status==ID_STATUS_INVISIBLE)) ||
- ((n->item.statusFlags & NUDGE_ACC_ST8) && (Status==ID_STATUS_ONTHEPHONE)) ||
- ((n->item.statusFlags & NUDGE_ACC_ST9) && (Status==ID_STATUS_OUTTOLUNCH)))
+ DWORD Status = CallProtoService(protoName, PS_GETSTATUS, 0, 0);
+
+ if (((n->item.statusFlags & NUDGE_ACC_ST0) && (Status <= ID_STATUS_OFFLINE)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST1) && (Status == ID_STATUS_ONLINE)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST2) && (Status == ID_STATUS_AWAY)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST3) && (Status == ID_STATUS_DND)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST4) && (Status == ID_STATUS_NA)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST5) && (Status == ID_STATUS_OCCUPIED)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST6) && (Status == ID_STATUS_FREECHAT)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST7) && (Status == ID_STATUS_INVISIBLE)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST8) && (Status == ID_STATUS_ONTHEPHONE)) ||
+ ((n->item.statusFlags & NUDGE_ACC_ST9) && (Status == ID_STATUS_OUTTOLUNCH)))
{
- if(diff >= GlobalNudge.recvTimeSec)
- {
- if(n->item.showPopup)
- Nudge_ShowPopup(n->item, (HANDLE) wParam, n->item.recText);
- if(n->item.openContactList)
+ if (diff >= GlobalNudge.recvTimeSec) {
+ if (n->item.showPopup)
+ Nudge_ShowPopup(n->item, (HANDLE)wParam, n->item.recText);
+ if (n->item.openContactList)
OpenContactList();
- if(n->item.shakeClist)
- ShakeClist(wParam,lParam);
- if(n->item.openMessageWindow)
- CallService(MS_MSG_SENDMESSAGET,wParam,0);
- if(n->item.shakeChat)
- ShakeChat(wParam,lParam);
- if(n->item.autoResend)
- mir_forkthread(AutoResendNudge,(void *)wParam);
-
- SkinPlaySound( n->item.NudgeSoundname );
+ if (n->item.shakeClist)
+ ShakeClist(wParam, lParam);
+ if (n->item.openMessageWindow)
+ CallService(MS_MSG_SENDMESSAGET, wParam, 0);
+ if (n->item.shakeChat)
+ ShakeChat(wParam, lParam);
+ if (n->item.autoResend)
+ mir_forkthread(AutoResendNudge, (void *)wParam);
+
+ SkinPlaySound(n->item.NudgeSoundname);
}
}
- if(diff2 >= GlobalNudge.recvTimeSec)
- {
- if(n->item.showStatus)
- Nudge_ShowStatus(n->item, (HANDLE) wParam, nudgeSentTimestamp);
- }
+
+ if (diff2 >= GlobalNudge.recvTimeSec)
+ if (n->item.showStatus)
+ Nudge_ShowStatus(n->item, (HANDLE)wParam, nudgeSentTimestamp);
}
break;
}
}
}
- else
- {
- if(DefaultNudge.enabled)
- {
- if(DefaultNudge.useIgnoreSettings && CallService(MS_IGNORE_ISIGNORED,wParam,IGNOREEVENT_USERONLINE))
+ else {
+ if (DefaultNudge.enabled) {
+ if (DefaultNudge.useIgnoreSettings && CallService(MS_IGNORE_ISIGNORED, wParam, IGNOREEVENT_USERONLINE))
return 0;
- DWORD Status = CallService(MS_CLIST_GETSTATUSMODE,0,0);
- if ( ((DefaultNudge.statusFlags & NUDGE_ACC_ST0) && (Status<=ID_STATUS_OFFLINE)) ||
- ((DefaultNudge.statusFlags & NUDGE_ACC_ST1) && (Status==ID_STATUS_ONLINE)) ||
- ((DefaultNudge.statusFlags & NUDGE_ACC_ST2) && (Status==ID_STATUS_AWAY)) ||
- ((DefaultNudge.statusFlags & NUDGE_ACC_ST3) && (Status==ID_STATUS_DND)) ||
- ((DefaultNudge.statusFlags & NUDGE_ACC_ST4) && (Status==ID_STATUS_NA)) ||
- ((DefaultNudge.statusFlags & NUDGE_ACC_ST5) && (Status==ID_STATUS_OCCUPIED)) ||
- ((DefaultNudge.statusFlags & NUDGE_ACC_ST6) && (Status==ID_STATUS_FREECHAT)) ||
- ((DefaultNudge.statusFlags & NUDGE_ACC_ST7) && (Status==ID_STATUS_INVISIBLE)) ||
- ((DefaultNudge.statusFlags & NUDGE_ACC_ST8) && (Status==ID_STATUS_ONTHEPHONE)) ||
- ((DefaultNudge.statusFlags & NUDGE_ACC_ST9) && (Status==ID_STATUS_OUTTOLUNCH)))
+
+ DWORD Status = CallService(MS_CLIST_GETSTATUSMODE, 0, 0);
+ if (((DefaultNudge.statusFlags & NUDGE_ACC_ST0) && (Status <= ID_STATUS_OFFLINE)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST1) && (Status == ID_STATUS_ONLINE)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST2) && (Status == ID_STATUS_AWAY)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST3) && (Status == ID_STATUS_DND)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST4) && (Status == ID_STATUS_NA)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST5) && (Status == ID_STATUS_OCCUPIED)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST6) && (Status == ID_STATUS_FREECHAT)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST7) && (Status == ID_STATUS_INVISIBLE)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST8) && (Status == ID_STATUS_ONTHEPHONE)) ||
+ ((DefaultNudge.statusFlags & NUDGE_ACC_ST9) && (Status == ID_STATUS_OUTTOLUNCH)))
{
- if(diff >= GlobalNudge.recvTimeSec)
- {
- if(DefaultNudge.showPopup)
- Nudge_ShowPopup(DefaultNudge, (HANDLE) wParam, DefaultNudge.recText);
- if(DefaultNudge.openContactList)
+ if (diff >= GlobalNudge.recvTimeSec) {
+ if (DefaultNudge.showPopup)
+ Nudge_ShowPopup(DefaultNudge, (HANDLE)wParam, DefaultNudge.recText);
+ if (DefaultNudge.openContactList)
OpenContactList();
- if(DefaultNudge.shakeClist)
- ShakeClist(wParam,lParam);
- if(DefaultNudge.openMessageWindow)
- CallService(MS_MSG_SENDMESSAGET,wParam,0);
- if(DefaultNudge.shakeChat)
- ShakeChat(wParam,lParam);
- if(DefaultNudge.autoResend)
- mir_forkthread(AutoResendNudge,(void *)wParam);
-
- SkinPlaySound( DefaultNudge.NudgeSoundname );
+ if (DefaultNudge.shakeClist)
+ ShakeClist(wParam, lParam);
+ if (DefaultNudge.openMessageWindow)
+ CallService(MS_MSG_SENDMESSAGET, wParam, 0);
+ if (DefaultNudge.shakeChat)
+ ShakeChat(wParam, lParam);
+ if (DefaultNudge.autoResend)
+ mir_forkthread(AutoResendNudge, (void *)wParam);
+
+ SkinPlaySound(DefaultNudge.NudgeSoundname);
}
}
- if(diff2 >= GlobalNudge.recvTimeSec)
- {
- if(DefaultNudge.showStatus)
- Nudge_ShowStatus(DefaultNudge, (HANDLE) wParam, nudgeSentTimestamp);
- }
+
+ if (diff2 >= GlobalNudge.recvTimeSec)
+ if (DefaultNudge.showStatus)
+ Nudge_ShowStatus(DefaultNudge, (HANDLE)wParam, nudgeSentTimestamp);
}
}
return 0;
}
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
+extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
- hInst=hinstDLL;
+ hInst = hinstDLL;
return TRUE;
}
@@ -208,19 +197,19 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
void LoadProtocols(void)
{
//Load the default nudge
- mir_snprintf(DefaultNudge.ProtocolName,sizeof(DefaultNudge.ProtocolName),"Default");
- mir_snprintf(DefaultNudge.NudgeSoundname,sizeof(DefaultNudge.NudgeSoundname),"Nudge : Default");
- SkinAddNewSoundEx( DefaultNudge.NudgeSoundname, LPGEN("Nudge"), LPGEN("Default Nudge"));
+ mir_snprintf(DefaultNudge.ProtocolName, sizeof(DefaultNudge.ProtocolName), "Default");
+ mir_snprintf(DefaultNudge.NudgeSoundname, sizeof(DefaultNudge.NudgeSoundname), "Nudge : Default");
+ SkinAddNewSoundEx(DefaultNudge.NudgeSoundname, LPGEN("Nudge"), LPGEN("Default Nudge"));
DefaultNudge.Load();
GlobalNudge.Load();
int numberOfProtocols = 0;
PROTOACCOUNT **ppProtocolDescriptors;
- INT_PTR ret = ProtoEnumAccounts(&numberOfProtocols,&ppProtocolDescriptors);
- if(ret == 0)
- for(int i = 0; i < numberOfProtocols ; i++)
- Nudge_AddAccount(ppProtocolDescriptors[i]);
+ INT_PTR ret = ProtoEnumAccounts(&numberOfProtocols, &ppProtocolDescriptors);
+ if (ret == 0)
+ for (int i = 0; i < numberOfProtocols; i++)
+ Nudge_AddAccount(ppProtocolDescriptors[i]);
shake.Load();
}
@@ -239,9 +228,9 @@ void LoadIcons(void)
// Nudge support
static int TabsrmmButtonPressed(WPARAM wParam, LPARAM lParam)
{
- CustomButtonClickData *cbcd=(CustomButtonClickData *)lParam;
+ CustomButtonClickData *cbcd = (CustomButtonClickData *)lParam;
- if (!strcmp(cbcd->pszModule,"Nudge"))
+ if (!strcmp(cbcd->pszModule, "Nudge"))
NudgeSend(wParam, 0);
return 0;
@@ -265,7 +254,7 @@ static int TabsrmmButtonInit(WPARAM wParam, LPARAM lParam)
void HideNudgeButton(HANDLE hContact)
{
char *szProto = GetContactProto(hContact);
- if ( !ProtoServiceExists(szProto, PS_SEND_NUDGE)) {
+ if (!ProtoServiceExists(szProto, PS_SEND_NUDGE)) {
BBButton bbd = { sizeof(bbd) };
bbd.bbbFlags = BBSF_HIDDEN | BBSF_DISABLED;
bbd.pszModuleName = "Nudge";
@@ -274,32 +263,31 @@ void HideNudgeButton(HANDLE hContact)
}
}
-static int ContactWindowOpen(WPARAM wparam,LPARAM lParam)
+static int ContactWindowOpen(WPARAM wparam, LPARAM lParam)
{
- MessageWindowEventData *MWeventdata = (MessageWindowEventData*)lParam;
- if(MWeventdata->uType == MSG_WINDOW_EVT_OPENING&&MWeventdata->hContact)
- HideNudgeButton(MWeventdata->hContact);
+ MessageWindowEventData *MWeventdata = (MessageWindowEventData*)lParam;
+ if (MWeventdata->uType == MSG_WINDOW_EVT_OPENING && MWeventdata->hContact)
+ HideNudgeButton(MWeventdata->hContact);
- return 0;
+ return 0;
}
-int ModulesLoaded(WPARAM,LPARAM)
+int ModulesLoaded(WPARAM, LPARAM)
{
LoadProtocols();
- LoadIcons();
LoadPopupClass();
- if ( HookEvent(ME_MSG_TOOLBARLOADED, TabsrmmButtonInit)) {
+ if (HookEvent(ME_MSG_TOOLBARLOADED, TabsrmmButtonInit)) {
HookEvent(ME_MSG_BUTTONPRESSED, TabsrmmButtonPressed);
- HookEvent(ME_MSG_WINDOWEVENT,ContactWindowOpen);
+ HookEvent(ME_MSG_WINDOWEVENT, ContactWindowOpen);
}
return 0;
}
-int AccListChanged(WPARAM wParam,LPARAM lParam)
+int AccListChanged(WPARAM wParam, LPARAM lParam)
{
- PROTOACCOUNT *proto = (PROTOACCOUNT*) wParam;
- if (proto==NULL)
+ PROTOACCOUNT *proto = (PROTOACCOUNT*)wParam;
+ if (proto == NULL)
return 0;
if (lParam == PRAC_ADDED)
@@ -311,42 +299,50 @@ extern "C" int __declspec(dllexport) Load(void)
{
mir_getLP(&pluginInfo);
+ LoadIcons();
+
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- HookEvent(ME_PROTO_ACCLISTCHANGED,AccListChanged);
+ HookEvent(ME_PROTO_ACCLISTCHANGED, AccListChanged);
HookEvent(ME_OPT_INITIALISE, NudgeOptInit);
- //Create function for plugins
- CreateServiceFunction(MS_SHAKE_CLIST,ShakeClist);
- CreateServiceFunction(MS_SHAKE_CHAT,ShakeChat);
- CreateServiceFunction(MS_NUDGE_SEND,NudgeSend);
- CreateServiceFunction(MS_NUDGE_SHOWMENU,NudgeShowMenu);
+ // Create function for plugins
+ CreateServiceFunction(MS_SHAKE_CLIST, ShakeClist);
+ CreateServiceFunction(MS_SHAKE_CHAT, ShakeChat);
+ CreateServiceFunction(MS_NUDGE_SEND, NudgeSend);
+ CreateServiceFunction(MS_NUDGE_SHOWMENU, NudgeShowMenu);
+
+ // register special type of event
+ // there's no need to declare the special service for getting text
+ // because a blob contains only text
+ DBEVENTTYPEDESCR evtype = { sizeof(evtype) };
+ evtype.module = MODULENAME;
+ evtype.eventType = 1;
+ evtype.descr = LPGEN("Nudge");
+ evtype.eventIcon = iconList[0].hIcolib;
+ evtype.flags = DETF_HISTORY | DETF_MSGWINDOW;
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&evtype);
return 0;
}
extern "C" int __declspec(dllexport) Unload(void)
{
- NudgeElementList* p = NudgeList;
- while ( p != NULL )
- {
- if(p->item.hEvent) UnhookEvent(p->item.hEvent);
+ NudgeElementList *p = NudgeList;
+ while (p != NULL) {
+ if (p->item.hEvent) UnhookEvent(p->item.hEvent);
NudgeElementList* p1 = p->next;
- //free( p );
delete p;
p = p1;
}
return 0;
}
-LRESULT CALLBACK NudgePopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
+LRESULT CALLBACK NudgePopupProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch(msg) {
+ switch (msg) {
case WM_COMMAND:
- {
- HANDLE hContact = PUGetContact(hWnd);
- CallService(MS_MSG_SENDMESSAGET, (WPARAM)hContact, 0);
- PUDeletePopup(hWnd);
- break;
- }
+ CallService(MS_MSG_SENDMESSAGET, (WPARAM)PUGetContact(hWnd), 0);
+ PUDeletePopup(hWnd);
+ break;
case WM_CONTEXTMENU:
PUDeletePopup(hWnd);
@@ -355,10 +351,10 @@ LRESULT CALLBACK NudgePopupProc(HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam)
//Here we'd free our own data, if we had it.
return FALSE;
}
- return DefWindowProc(hWnd,msg,wParam,lParam);
+ return DefWindowProc(hWnd, msg, wParam, lParam);
}
-static int OnShutdown(WPARAM,LPARAM)
+static int OnShutdown(WPARAM, LPARAM)
{
Popup_UnregisterClass(hPopupClass);
return 0;
@@ -382,41 +378,36 @@ void LoadPopupClass()
int Preview()
{
HANDLE hContact = db_find_first();
- if ( GlobalNudge.useByProtocol )
- {
- for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
- {
- if(n->item.enabled)
- {
- SkinPlaySound( n->item.NudgeSoundname );
- if(n->item.showPopup)
+ if (GlobalNudge.useByProtocol) {
+ for (NudgeElementList *n = NudgeList; n != NULL; n = n->next) {
+ if (n->item.enabled) {
+ SkinPlaySound(n->item.NudgeSoundname);
+ if (n->item.showPopup)
Nudge_ShowPopup(n->item, hContact, n->item.recText);
- if(n->item.openContactList)
+ if (n->item.openContactList)
OpenContactList();
- if(n->item.shakeClist)
- ShakeClist(0,0);
- if(n->item.openMessageWindow)
- CallService(MS_MSG_SENDMESSAGET,(WPARAM)hContact,NULL);
- if(n->item.shakeChat)
- ShakeChat((WPARAM)hContact,(LPARAM)time(NULL));
+ if (n->item.shakeClist)
+ ShakeClist(0, 0);
+ if (n->item.openMessageWindow)
+ CallService(MS_MSG_SENDMESSAGET, (WPARAM)hContact, NULL);
+ if (n->item.shakeChat)
+ ShakeChat((WPARAM)hContact, (LPARAM)time(NULL));
}
}
}
- else
- {
- if(DefaultNudge.enabled)
- {
- SkinPlaySound( DefaultNudge.NudgeSoundname );
- if(DefaultNudge.showPopup)
+ else {
+ if (DefaultNudge.enabled) {
+ SkinPlaySound(DefaultNudge.NudgeSoundname);
+ if (DefaultNudge.showPopup)
Nudge_ShowPopup(DefaultNudge, hContact, DefaultNudge.recText);
- if(DefaultNudge.openContactList)
+ if (DefaultNudge.openContactList)
OpenContactList();
- if(DefaultNudge.shakeClist)
- ShakeClist(0,0);
- if(DefaultNudge.openMessageWindow)
- CallService(MS_MSG_SENDMESSAGET,(WPARAM)hContact,NULL);
- if(DefaultNudge.shakeChat)
- ShakeChat((WPARAM)hContact,(LPARAM)time(NULL));
+ if (DefaultNudge.shakeClist)
+ ShakeClist(0, 0);
+ if (DefaultNudge.openMessageWindow)
+ CallService(MS_MSG_SENDMESSAGET, (WPARAM)hContact, NULL);
+ if (DefaultNudge.shakeChat)
+ ShakeChat((WPARAM)hContact, (LPARAM)time(NULL));
}
}
return 0;
@@ -425,11 +416,10 @@ int Preview()
void Nudge_ShowPopup(CNudgeElement n, HANDLE hContact, TCHAR * Message)
{
hContact = Nudge_GethContact(hContact);
- TCHAR * lpzContactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hContact,GCDNF_TCHAR);
+ TCHAR * lpzContactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR);
- if(ServiceExists(MS_POPUP_ADDPOPUPCLASS))
- {
- POPUPDATACLASS NudgePopup = {0};
+ if (ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
+ POPUPDATACLASS NudgePopup = { 0 };
NudgePopup.cbSize = sizeof(NudgePopup);
NudgePopup.hContact = hContact;
NudgePopup.ptszText = Message;
@@ -437,9 +427,8 @@ void Nudge_ShowPopup(CNudgeElement n, HANDLE hContact, TCHAR * Message)
NudgePopup.pszClassName = "nudge";
CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&NudgePopup);
}
- else if(ServiceExists(MS_POPUP_ADDPOPUPT))
- {
- POPUPDATAT NudgePopup = {0};
+ else if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
+ POPUPDATAT NudgePopup = { 0 };
NudgePopup.lchContact = hContact;
NudgePopup.lchIcon = Skin_GetIconByHandle(n.hIcoLibItem);
NudgePopup.colorBack = 0;
@@ -453,29 +442,65 @@ void Nudge_ShowPopup(CNudgeElement n, HANDLE hContact, TCHAR * Message)
lstrcpy(NudgePopup.lptzContactName, lpzContactName);
- CallService(MS_POPUP_ADDPOPUPT,(WPARAM)&NudgePopup,0);
- }
- else
- {
- MessageBox(NULL,Message,lpzContactName,0);
+ CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&NudgePopup, 0);
}
+ else MessageBox(NULL, Message, lpzContactName, 0);
}
void Nudge_SentStatus(CNudgeElement n, HANDLE hContact)
{
+ char *buff = mir_utf8encodeT(n.senText);
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.szModule = MODULENAME;
+ dbei.flags = DBEF_SENT | DBEF_UTF;
+ dbei.timestamp = (DWORD)time(NULL);
+ dbei.eventType = 1;
+ dbei.cbBlob = (DWORD)strlen(buff) + 1;
+ dbei.pBlob = (PBYTE)buff;
+
+ INT_PTR res = CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0); //try to retrieve the metacontact if some
+ if (res != CALLSERVICE_NOTFOUND) {
+ HANDLE hMetaContact = (HANDLE)res;
+ if (hMetaContact != NULL) // metacontact
+ db_event_add(hMetaContact, &dbei);
+ }
+
+ db_event_add(hContact, &dbei);
+ mir_free(buff);
}
void Nudge_ShowStatus(CNudgeElement n, HANDLE hContact, DWORD timestamp)
{
+ char *buff = mir_utf8encodeT(n.recText);
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.szModule = MODULENAME;
+ dbei.eventType = 1;
+ dbei.flags = DBEF_UTF;
+ dbei.timestamp = timestamp;
+ dbei.cbBlob = (DWORD)strlen(buff) + 1;
+ dbei.pBlob = (PBYTE)buff;
+
+ INT_PTR res = CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0); //try to retrieve the metacontact if some
+ if (res != CALLSERVICE_NOTFOUND) {
+ HANDLE hMetaContact = (HANDLE)res;
+ if (hMetaContact != NULL) { //metacontact
+ db_event_add(hMetaContact, &dbei);
+ dbei.flags |= DBEF_READ;
+ }
+ }
+
+ db_event_add(hContact, &dbei);
+ mir_free(buff);
}
HANDLE Nudge_GethContact(HANDLE hContact)
{
- INT_PTR res = CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0 );
- if(res!=CALLSERVICE_NOTFOUND)
- {
- HANDLE hMetaContact = (HANDLE) res;
- if(hMetaContact!=NULL)
+ INT_PTR res = CallService(MS_MC_GETMETACONTACT, (WPARAM)hContact, 0);
+ if (res != CALLSERVICE_NOTFOUND) {
+ HANDLE hMetaContact = (HANDLE)res;
+ if (hMetaContact != NULL)
return hMetaContact;
}
@@ -485,37 +510,37 @@ HANDLE Nudge_GethContact(HANDLE hContact)
void Nudge_AddAccount(PROTOACCOUNT *proto)
{
char str[MAXMODULELABELLENGTH + 10];
- mir_snprintf(str,sizeof(str),"%s/Nudge",proto->szModuleName);
+ mir_snprintf(str, sizeof(str), "%s/Nudge", proto->szModuleName);
HANDLE hevent = HookEvent(str, NudgeReceived);
- if(hevent == NULL)
+ if (hevent == NULL)
return;
- nProtocol ++;
+ nProtocol++;
//Add a specific sound per protocol
NudgeElementList *newNudge = new NudgeElementList;
//newNudge = (NudgeElementList*) malloc(sizeof(NudgeElementList));
- mir_snprintf(newNudge->item.NudgeSoundname,sizeof(newNudge->item.NudgeSoundname),"%s: Nudge",proto->szModuleName);
+ mir_snprintf(newNudge->item.NudgeSoundname, sizeof(newNudge->item.NudgeSoundname), "%s: Nudge", proto->szModuleName);
- strcpy( newNudge->item.ProtocolName, proto->szProtoName );
- _tcscpy(newNudge->item.AccountName, proto->tszAccountName );
+ strcpy(newNudge->item.ProtocolName, proto->szProtoName);
+ _tcscpy(newNudge->item.AccountName, proto->tszAccountName);
newNudge->item.Load();
newNudge->item.hEvent = hevent;
TCHAR soundDesc[MAXMODULELABELLENGTH + 10];
- mir_sntprintf(soundDesc,sizeof(soundDesc), LPGENT("Nudge for %s"),proto->tszAccountName);
+ mir_sntprintf(soundDesc, sizeof(soundDesc), LPGENT("Nudge for %s"), proto->tszAccountName);
SkinAddNewSoundExT(newNudge->item.NudgeSoundname, LPGENT("Nudge"), soundDesc);
newNudge->next = NudgeList;
NudgeList = newNudge;
char iconName[MAXMODULELABELLENGTH + 10];
- mir_snprintf(iconName,sizeof(iconName),"Nudge_%s",proto->szModuleName);
+ mir_snprintf(iconName, sizeof(iconName), "Nudge_%s", proto->szModuleName);
TCHAR szFilename[MAX_PATH], iconDesc[MAXMODULELABELLENGTH + 10];
- GetModuleFileName(hInst,szFilename,MAX_PATH);
+ GetModuleFileName(hInst, szFilename, MAX_PATH);
mir_sntprintf(iconDesc, SIZEOF(iconDesc), TranslateT("Nudge for %s"), proto->tszAccountName);
SKINICONDESC sid = { sizeof(sid) };
@@ -535,7 +560,7 @@ void Nudge_AddAccount(PROTOACCOUNT *proto)
mi.flags = CMIF_NOTOFFLINE | CMIF_TCHAR;
mi.position = -500050004;
mi.icolibItem = newNudge->item.hIcoLibItem;
- mi.ptszName = LPGENT( "Send &Nudge" );
+ mi.ptszName = LPGENT("Send &Nudge");
mi.pszService = MS_NUDGE_SEND;
newNudge->item.hContactMenu = Menu_AddContactMenuItem(&mi);
}
@@ -543,5 +568,5 @@ void Nudge_AddAccount(PROTOACCOUNT *proto)
void AutoResendNudge(void *wParam)
{
Sleep(GlobalNudge.resendDelaySec * 1000);
- NudgeSend((WPARAM) wParam,NULL);
+ NudgeSend((WPARAM)wParam, NULL);
}
diff --git a/plugins/Nudge/src/nudge.cpp b/plugins/Nudge/src/nudge.cpp
index 5c83b6cfe9..66f8c47fbb 100644
--- a/plugins/Nudge/src/nudge.cpp
+++ b/plugins/Nudge/src/nudge.cpp
@@ -3,102 +3,98 @@
void CNudge::Save(void)
{
char SectionName[512];
- mir_snprintf(SectionName,512,"useByProtocol");
- db_set_b(NULL, "Nudge", SectionName, this->useByProtocol);
- mir_snprintf(SectionName,512,"RecvTimeSec");
- db_set_dw(NULL, "Nudge", SectionName, this->recvTimeSec);
- mir_snprintf(SectionName,512,"SendTimeSec");
- db_set_dw(NULL, "Nudge", SectionName, this->sendTimeSec);
- mir_snprintf(SectionName,512,"ResendDelaySec");
- db_set_dw(NULL, "Nudge", SectionName, this->resendDelaySec);
+ mir_snprintf(SectionName, 512, "useByProtocol");
+ db_set_b(NULL, MODULENAME, SectionName, this->useByProtocol);
+ mir_snprintf(SectionName, 512, "RecvTimeSec");
+ db_set_dw(NULL, MODULENAME, SectionName, this->recvTimeSec);
+ mir_snprintf(SectionName, 512, "SendTimeSec");
+ db_set_dw(NULL, MODULENAME, SectionName, this->sendTimeSec);
+ mir_snprintf(SectionName, 512, "ResendDelaySec");
+ db_set_dw(NULL, MODULENAME, SectionName, this->resendDelaySec);
}
-
void CNudge::Load(void)
{
char SectionName[512];
- mir_snprintf(SectionName,512,"useByProtocol");
- this->useByProtocol = db_get_b(NULL, "Nudge", SectionName, FALSE) != 0;
- mir_snprintf(SectionName,512,"RecvTimeSec");
- this->recvTimeSec = db_get_dw(NULL, "Nudge", SectionName, 30);
- mir_snprintf(SectionName,512,"SendTimeSec");
- this->sendTimeSec = db_get_dw(NULL, "Nudge", SectionName, 30);
- mir_snprintf(SectionName,512,"ResendDelaySec");
- this->resendDelaySec = db_get_dw(NULL, "Nudge", SectionName, 3);
+ mir_snprintf(SectionName, 512, "useByProtocol");
+ this->useByProtocol = db_get_b(NULL, MODULENAME, SectionName, FALSE) != 0;
+ mir_snprintf(SectionName, 512, "RecvTimeSec");
+ this->recvTimeSec = db_get_dw(NULL, MODULENAME, SectionName, 30);
+ mir_snprintf(SectionName, 512, "SendTimeSec");
+ this->sendTimeSec = db_get_dw(NULL, MODULENAME, SectionName, 30);
+ mir_snprintf(SectionName, 512, "ResendDelaySec");
+ this->resendDelaySec = db_get_dw(NULL, MODULENAME, SectionName, 3);
}
void CNudgeElement::Save(void)
{
char SectionName[512];
- mir_snprintf(SectionName,512,"%s-openMessageWindow", ProtocolName);
- db_set_b(NULL, "Nudge", SectionName, this->openMessageWindow);
- mir_snprintf(SectionName,512,"%s-openContactList", ProtocolName);
- db_set_b(NULL, "Nudge", SectionName, this->openContactList);
- mir_snprintf(SectionName,512,"%s-useIgnore", ProtocolName);
- db_set_b(NULL, "Nudge", SectionName, this->useIgnoreSettings);
- mir_snprintf(SectionName,512,"%s-showStatus", ProtocolName);
- db_set_b(NULL, "Nudge", SectionName, this->showStatus);
- mir_snprintf(SectionName,512,"%s-showPopup", ProtocolName);
- db_set_b(NULL, "Nudge", SectionName, this->showPopup);
- mir_snprintf(SectionName,512,"%s-shakeClist", ProtocolName);
- db_set_b(NULL, "Nudge", SectionName, this->shakeClist);
- mir_snprintf(SectionName,512,"%s-shakeChat", ProtocolName);
- db_set_b(NULL, "Nudge", SectionName, this->shakeChat);
- mir_snprintf(SectionName,512,"%s-enabled", ProtocolName);
- db_set_b(NULL, "Nudge", SectionName, this->enabled);
- mir_snprintf(SectionName,512,"%s-autoResend", ProtocolName);
- db_set_b(NULL, "Nudge", SectionName, this->autoResend);
- mir_snprintf(SectionName,512,"%s-statusFlags", ProtocolName);
- db_set_dw(NULL, "Nudge", SectionName, this->statusFlags);
- mir_snprintf(SectionName,512,"%s-recText", ProtocolName);
- db_set_ts(NULL, "Nudge", SectionName, this->recText);
- mir_snprintf(SectionName,512,"%s-senText", ProtocolName);
- db_set_ts(NULL, "Nudge", SectionName, this->senText);
+ mir_snprintf(SectionName, 512, "%s-openMessageWindow", ProtocolName);
+ db_set_b(NULL, MODULENAME, SectionName, this->openMessageWindow);
+ mir_snprintf(SectionName, 512, "%s-openContactList", ProtocolName);
+ db_set_b(NULL, MODULENAME, SectionName, this->openContactList);
+ mir_snprintf(SectionName, 512, "%s-useIgnore", ProtocolName);
+ db_set_b(NULL, MODULENAME, SectionName, this->useIgnoreSettings);
+ mir_snprintf(SectionName, 512, "%s-showStatus", ProtocolName);
+ db_set_b(NULL, MODULENAME, SectionName, this->showStatus);
+ mir_snprintf(SectionName, 512, "%s-showPopup", ProtocolName);
+ db_set_b(NULL, MODULENAME, SectionName, this->showPopup);
+ mir_snprintf(SectionName, 512, "%s-shakeClist", ProtocolName);
+ db_set_b(NULL, MODULENAME, SectionName, this->shakeClist);
+ mir_snprintf(SectionName, 512, "%s-shakeChat", ProtocolName);
+ db_set_b(NULL, MODULENAME, SectionName, this->shakeChat);
+ mir_snprintf(SectionName, 512, "%s-enabled", ProtocolName);
+ db_set_b(NULL, MODULENAME, SectionName, this->enabled);
+ mir_snprintf(SectionName, 512, "%s-autoResend", ProtocolName);
+ db_set_b(NULL, MODULENAME, SectionName, this->autoResend);
+ mir_snprintf(SectionName, 512, "%s-statusFlags", ProtocolName);
+ db_set_dw(NULL, MODULENAME, SectionName, this->statusFlags);
+ mir_snprintf(SectionName, 512, "%s-recText", ProtocolName);
+ db_set_ts(NULL, MODULENAME, SectionName, this->recText);
+ mir_snprintf(SectionName, 512, "%s-senText", ProtocolName);
+ db_set_ts(NULL, MODULENAME, SectionName, this->senText);
}
-
void CNudgeElement::Load(void)
{
DBVARIANT dbv;
char SectionName[512];
- mir_snprintf(SectionName,512,"%s-openMessageWindow", ProtocolName);
- this->openMessageWindow = db_get_b(NULL, "Nudge", SectionName, TRUE) != 0;
- mir_snprintf(SectionName,512,"%s-openContactList", ProtocolName);
- this->openContactList = db_get_b(NULL, "Nudge", SectionName, TRUE) != 0;
- mir_snprintf(SectionName,512,"%s-useIgnore", ProtocolName);
- this->useIgnoreSettings = db_get_b(NULL, "Nudge", SectionName, TRUE) != 0;
- mir_snprintf(SectionName,512,"%s-showStatus", ProtocolName);
- this->showStatus = db_get_b(NULL, "Nudge", SectionName, TRUE) != 0;
- mir_snprintf(SectionName,512,"%s-showPopup", ProtocolName);
- this->showPopup = db_get_b(NULL, "Nudge", SectionName, TRUE) != 0;
- mir_snprintf(SectionName,512,"%s-shakeClist", ProtocolName);
- this->shakeClist = db_get_b(NULL, "Nudge", SectionName, TRUE) != 0;
- mir_snprintf(SectionName,512,"%s-shakeChat", ProtocolName);
- this->shakeChat = db_get_b(NULL, "Nudge", SectionName, TRUE) != 0;
- mir_snprintf(SectionName,512,"%s-enabled", ProtocolName);
- this->enabled = db_get_b(NULL, "Nudge", SectionName, TRUE) != 0;
- mir_snprintf(SectionName,512,"%s-autoResend", ProtocolName);
- this->autoResend = db_get_b(NULL, "Nudge", SectionName, FALSE) != 0;
- mir_snprintf(SectionName,512,"%s-statusFlags", ProtocolName);
- this->statusFlags = db_get_dw(NULL, "Nudge", SectionName, 967);
+ mir_snprintf(SectionName, 512, "%s-openMessageWindow", ProtocolName);
+ this->openMessageWindow = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
+ mir_snprintf(SectionName, 512, "%s-openContactList", ProtocolName);
+ this->openContactList = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
+ mir_snprintf(SectionName, 512, "%s-useIgnore", ProtocolName);
+ this->useIgnoreSettings = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
+ mir_snprintf(SectionName, 512, "%s-showStatus", ProtocolName);
+ this->showStatus = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
+ mir_snprintf(SectionName, 512, "%s-showPopup", ProtocolName);
+ this->showPopup = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
+ mir_snprintf(SectionName, 512, "%s-shakeClist", ProtocolName);
+ this->shakeClist = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
+ mir_snprintf(SectionName, 512, "%s-shakeChat", ProtocolName);
+ this->shakeChat = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
+ mir_snprintf(SectionName, 512, "%s-enabled", ProtocolName);
+ this->enabled = db_get_b(NULL, MODULENAME, SectionName, TRUE) != 0;
+ mir_snprintf(SectionName, 512, "%s-autoResend", ProtocolName);
+ this->autoResend = db_get_b(NULL, MODULENAME, SectionName, FALSE) != 0;
+ mir_snprintf(SectionName, 512, "%s-statusFlags", ProtocolName);
+ this->statusFlags = db_get_dw(NULL, MODULENAME, SectionName, 967);
+
mir_snprintf(SectionName,512,"%s-recText", ProtocolName);
- if (!db_get_ts(NULL,"Nudge",SectionName,&dbv))
- {
- _tcsncpy(this->recText,dbv.ptszVal,TEXT_LEN);
- if(_tcsclen(this->recText) < 1)
- _tcsncpy(this->recText,TranslateT("You received a nudge"),TEXT_LEN);
+ if (!db_get_ts(NULL, MODULENAME, SectionName, &dbv)) {
+ _tcsncpy(this->recText, dbv.ptszVal, TEXT_LEN);
+ if (_tcsclen(this->recText) < 1)
+ _tcsncpy(this->recText, TranslateT("You received a nudge"), TEXT_LEN);
db_free(&dbv);
}
- else
- _tcsncpy(this->recText,TranslateT("You received a nudge"),TEXT_LEN);
- mir_snprintf(SectionName,512,"%s-senText", ProtocolName);
- if (!db_get_ts(NULL,"Nudge",SectionName,&dbv))
- {
- _tcsncpy(this->senText,dbv.ptszVal,TEXT_LEN);
- if(_tcsclen(this->senText) < 1)
- _tcsncpy(this->senText,TranslateT("You sent a nudge"),TEXT_LEN);
+ else _tcsncpy(this->recText, TranslateT("You received a nudge"), TEXT_LEN);
+
+ mir_snprintf(SectionName, 512, "%s-senText", ProtocolName);
+ if (!db_get_ts(NULL, MODULENAME, SectionName, &dbv)) {
+ _tcsncpy(this->senText, dbv.ptszVal, TEXT_LEN);
+ if (_tcsclen(this->senText) < 1)
+ _tcsncpy(this->senText, TranslateT("You sent a nudge"), TEXT_LEN);
db_free(&dbv);
}
- else
- _tcsncpy(this->senText,TranslateT("You sent a nudge"),TEXT_LEN);
-} \ No newline at end of file
+ else _tcsncpy(this->senText, TranslateT("You sent a nudge"), TEXT_LEN);
+}
diff --git a/plugins/Nudge/src/nudge.h b/plugins/Nudge/src/nudge.h
index 0a8023104d..1098c2eda4 100644
--- a/plugins/Nudge/src/nudge.h
+++ b/plugins/Nudge/src/nudge.h
@@ -1,6 +1,8 @@
#ifndef NUDGE_H
#define NUDGE_H
+#define MODULENAME "Nudge"
+
// NUDGE account status flags
#define NUDGE_ACC_ST0 0x00000001 //Check (countdown) when Offline
#define NUDGE_ACC_ST1 0x00000002 //Check (countdown) when Online
@@ -13,7 +15,6 @@
#define NUDGE_ACC_ST8 0x00000100 //Check (countdown) when On the phone
#define NUDGE_ACC_ST9 0x00000200 //Check (countdown) when Out to lunch
-// For status log
#define TEXT_LEN 1024
class CNudge
diff --git a/plugins/Nudge/src/options.cpp b/plugins/Nudge/src/options.cpp
index b89cadc97d..63fc12ad3a 100644
--- a/plugins/Nudge/src/options.cpp
+++ b/plugins/Nudge/src/options.cpp
@@ -2,137 +2,169 @@
CNudgeElement* ActualNudge = NULL;
-int NudgeOptInit(WPARAM wParam,LPARAM lParam)
+static int GetSelProto(HWND hwnd, HTREEITEM hItem)
{
- OPTIONSDIALOGPAGE odp = { sizeof(odp) };
- odp.position = -790000000;
- odp.hInstance = hInst;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NUDGE);
- odp.pszTitle = LPGEN("Nudge");
- odp.pszGroup = LPGEN("Events");
- odp.pszTab = LPGEN("Nudge");
- odp.flags = ODPF_BOLDGROUPS;
- odp.pfnDlgProc = DlgProcNudgeOpt;
- Options_AddPage(wParam, &odp);
+ HWND hLstView = GetDlgItem(hwnd, IDC_PROTOLIST);
+ TVITEM tvi = { 0 };
- odp.position = -790000001;
- odp.pszTab = LPGEN("Window Shaking");
- odp.pfnDlgProc = DlgProcShakeOpt;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SHAKE);
- Options_AddPage(wParam, &odp);
- return 0;
+ tvi.mask = TVIF_IMAGE;
+ tvi.hItem = hItem == NULL ? TreeView_GetSelection(hLstView) : hItem;
+
+ TreeView_GetItem(hLstView, &tvi);
+
+ return tvi.iImage;
}
-INT_PTR CALLBACK DlgProcShakeOpt(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
+static void UpdateControls(HWND hwnd)
{
- switch(msg)
- {
- case WM_INITDIALOG:
+ int proto = nProtocol;
+ if (GlobalNudge.useByProtocol) {
+ proto = GetSelProto(hwnd, NULL);
+ ActualNudge = NULL;
+ for (NudgeElementList *n = NudgeList; n != NULL; n = n->next)
+ if (n->item.iProtoNumber == proto)
+ ActualNudge = &n->item;
+ }
+ else ActualNudge = &DefaultNudge;
+
+ SetDlgItemInt(hwnd, IDC_SENDTIME, GlobalNudge.sendTimeSec, FALSE);
+ SetDlgItemInt(hwnd, IDC_RECVTIME, GlobalNudge.recvTimeSec, FALSE);
+ SetDlgItemInt(hwnd, IDC_RESENDDELAY, GlobalNudge.resendDelaySec, FALSE);
+ CheckDlgButton(hwnd, IDC_USEBYPROTOCOL, (WPARAM)GlobalNudge.useByProtocol);
+
+ if (ActualNudge) { // fix NULL pointer then no nudge support protocols
+ CheckDlgButton(hwnd, IDC_CHECKPOP, (WPARAM)ActualNudge->showPopup);
+ CheckDlgButton(hwnd, IDC_CHECKCLIST, (WPARAM)ActualNudge->shakeClist);
+ CheckDlgButton(hwnd, IDC_CHECKCHAT, (WPARAM)ActualNudge->shakeChat);
+ CheckDlgButton(hwnd, IDC_CHECKSTATUS, (WPARAM)ActualNudge->showStatus);
+ CheckDlgButton(hwnd, IDC_AUTORESEND, (WPARAM)ActualNudge->autoResend);
+ CheckDlgButton(hwnd, IDC_OPENMESSAGE, (WPARAM)ActualNudge->openMessageWindow);
+ CheckDlgButton(hwnd, IDC_OPENCONTACTLIST, (WPARAM)ActualNudge->openContactList);
+ CheckDlgButton(hwnd, IDC_IGNORE, (WPARAM)ActualNudge->useIgnoreSettings);
+ EnableWindow(GetDlgItem(hwnd, IDC_RESENDDELAY), ActualNudge->autoResend);
+ CheckDlgButton(hwnd, IDC_CHECKST0, ActualNudge->statusFlags & NUDGE_ACC_ST0 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECKST1, ActualNudge->statusFlags & NUDGE_ACC_ST1 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECKST2, ActualNudge->statusFlags & NUDGE_ACC_ST2 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECKST3, ActualNudge->statusFlags & NUDGE_ACC_ST3 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECKST4, ActualNudge->statusFlags & NUDGE_ACC_ST4 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECKST5, ActualNudge->statusFlags & NUDGE_ACC_ST5 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECKST6, ActualNudge->statusFlags & NUDGE_ACC_ST6 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECKST7, ActualNudge->statusFlags & NUDGE_ACC_ST7 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECKST8, ActualNudge->statusFlags & NUDGE_ACC_ST8 ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwnd, IDC_CHECKST9, ActualNudge->statusFlags & NUDGE_ACC_ST9 ? BST_CHECKED : BST_UNCHECKED);
+ SetDlgItemText(hwnd, IDC_SENDTEXT, ActualNudge->senText);
+ SetDlgItemText(hwnd, IDC_RECVTEXT, ActualNudge->recText);
+ }
+ else EnableWindow(GetDlgItem(hwnd, IDC_PROTOLIST), FALSE);
+}
+
+static void CheckChange(HWND hwnd, HTREEITEM hItem)
+{
+ HWND hLstView = GetDlgItem(hwnd, IDC_PROTOLIST);
+ bool isChecked = !TreeView_GetCheckState(hLstView, hItem);
+
+ TreeView_SelectItem(hLstView, hItem);
+
+ int proto = nProtocol;
+ if (GlobalNudge.useByProtocol) {
+ proto = GetSelProto(hwnd, hItem);
+ ActualNudge = NULL;
+ for (NudgeElementList *n = NudgeList; n != NULL; n = n->next)
+ if (n->item.iProtoNumber == proto)
+ ActualNudge = &n->item;
+ }
+ else ActualNudge = &DefaultNudge;
+
+ if (ActualNudge)// fix NULL pointer then no nudge support protocols
+ ActualNudge->enabled = isChecked;
+
+ UpdateControls(hwnd);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static INT_PTR CALLBACK DlgProcShakeOpt(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwnd);
+ {
TCHAR szBuf[20];
- TranslateDialogDefault(hwnd);
mir_sntprintf(szBuf, 10, _T("%d"), shake.nMoveClist);
- SetDlgItemText(hwnd,IDC_LNUMBER_CLIST,szBuf);
+ SetDlgItemText(hwnd, IDC_LNUMBER_CLIST, szBuf);
mir_sntprintf(szBuf, 10, _T("%d"), shake.nMoveChat);
- SetDlgItemText(hwnd,IDC_LNUMBER_CHAT,szBuf);
+ SetDlgItemText(hwnd, IDC_LNUMBER_CHAT, szBuf);
mir_sntprintf(szBuf, 10, _T("%d"), shake.nScaleClist);
- SetDlgItemText(hwnd,IDC_LSCALE_CLIST,szBuf);
+ SetDlgItemText(hwnd, IDC_LSCALE_CLIST, szBuf);
mir_sntprintf(szBuf, 10, _T("%d"), shake.nScaleChat);
- SetDlgItemText(hwnd,IDC_LSCALE_CHAT,szBuf);
+ SetDlgItemText(hwnd, IDC_LSCALE_CHAT, szBuf);
+ }
- SendDlgItemMessage(hwnd, IDC_SNUMBER_CLIST, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 60));
- SendDlgItemMessage(hwnd, IDC_SNUMBER_CHAT, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 60));
+ SendDlgItemMessage(hwnd, IDC_SNUMBER_CLIST, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 60));
+ SendDlgItemMessage(hwnd, IDC_SNUMBER_CHAT, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 60));
- SendDlgItemMessage(hwnd, IDC_SSCALE_CLIST, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 40));
- SendDlgItemMessage(hwnd, IDC_SSCALE_CHAT, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 40));
+ SendDlgItemMessage(hwnd, IDC_SSCALE_CLIST, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 40));
+ SendDlgItemMessage(hwnd, IDC_SSCALE_CHAT, TBM_SETRANGE, 0, (LPARAM)MAKELONG(1, 40));
- SendDlgItemMessage(hwnd, IDC_SNUMBER_CLIST, TBM_SETPOS, TRUE, shake.nMoveClist);
- SendDlgItemMessage(hwnd, IDC_SNUMBER_CHAT, TBM_SETPOS, TRUE, shake.nMoveChat);
+ SendDlgItemMessage(hwnd, IDC_SNUMBER_CLIST, TBM_SETPOS, TRUE, shake.nMoveClist);
+ SendDlgItemMessage(hwnd, IDC_SNUMBER_CHAT, TBM_SETPOS, TRUE, shake.nMoveChat);
- SendDlgItemMessage(hwnd, IDC_SSCALE_CLIST, TBM_SETPOS, TRUE, shake.nScaleClist);
- SendDlgItemMessage(hwnd, IDC_SSCALE_CHAT, TBM_SETPOS, TRUE, shake.nScaleChat);
+ SendDlgItemMessage(hwnd, IDC_SSCALE_CLIST, TBM_SETPOS, TRUE, shake.nScaleClist);
+ SendDlgItemMessage(hwnd, IDC_SSCALE_CHAT, TBM_SETPOS, TRUE, shake.nScaleChat);
+ break;
- break;
- case WM_COMMAND:
- {
- WORD wNotifyCode = HIWORD(wParam);
- switch(LOWORD(wParam))
- {
- case IDC_PREVIEW:
- ShakeClist(0,0);
- //SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
- break;
- }
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_PREVIEW:
+ ShakeClist(0, 0);
break;
}
- case WM_HSCROLL:
- if ((HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CLIST) || (HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CHAT)
- || (HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CLIST) || (HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CHAT))
- {
- TCHAR szBuf[20];
- DWORD dwPos = SendMessage((HWND) lParam, TBM_GETPOS, 0, 0);
- mir_sntprintf(szBuf, sizeof(szBuf), _T("%d"), dwPos);
- if ((HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CLIST))
- SetDlgItemText(hwnd,IDC_LNUMBER_CLIST,szBuf);
- if ((HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CHAT))
- SetDlgItemText(hwnd,IDC_LNUMBER_CHAT,szBuf);
- if ((HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CLIST))
- SetDlgItemText(hwnd,IDC_LSCALE_CLIST,szBuf);
- if ((HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CHAT))
- SetDlgItemText(hwnd,IDC_LSCALE_CHAT,szBuf);
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
- break;
-
- case WM_SHOWWINDOW:
- break;
+ break;
- case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom)
- {
- case 0:
- switch(((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- shake.nMoveClist = (int) SendMessage(GetDlgItem(hwnd, IDC_SNUMBER_CLIST), TBM_GETPOS, 0, 0);
- shake.nMoveChat = (int) SendMessage(GetDlgItem(hwnd, IDC_SNUMBER_CHAT), TBM_GETPOS, 0, 0);
- shake.nScaleClist = (int) SendMessage(GetDlgItem(hwnd, IDC_SSCALE_CLIST), TBM_GETPOS, 0, 0);
- shake.nScaleChat = (int) SendMessage(GetDlgItem(hwnd, IDC_SSCALE_CHAT), TBM_GETPOS, 0, 0);
- shake.Save();
- }
- }
+ case WM_HSCROLL:
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CLIST) || (HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CHAT)
+ || (HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CLIST) || (HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CHAT))
+ {
+ TCHAR szBuf[20];
+ DWORD dwPos = SendMessage((HWND)lParam, TBM_GETPOS, 0, 0);
+ mir_sntprintf(szBuf, sizeof(szBuf), _T("%d"), dwPos);
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CLIST))
+ SetDlgItemText(hwnd, IDC_LNUMBER_CLIST, szBuf);
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SNUMBER_CHAT))
+ SetDlgItemText(hwnd, IDC_LNUMBER_CHAT, szBuf);
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CLIST))
+ SetDlgItemText(hwnd, IDC_LSCALE_CLIST, szBuf);
+ if ((HWND)lParam == GetDlgItem(hwnd, IDC_SSCALE_CHAT))
+ SetDlgItemText(hwnd, IDC_LSCALE_CHAT, szBuf);
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
+ break;
+
+ case WM_SHOWWINDOW:
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ shake.nMoveClist = (int)SendMessage(GetDlgItem(hwnd, IDC_SNUMBER_CLIST), TBM_GETPOS, 0, 0);
+ shake.nMoveChat = (int)SendMessage(GetDlgItem(hwnd, IDC_SNUMBER_CHAT), TBM_GETPOS, 0, 0);
+ shake.nScaleClist = (int)SendMessage(GetDlgItem(hwnd, IDC_SSCALE_CLIST), TBM_GETPOS, 0, 0);
+ shake.nScaleChat = (int)SendMessage(GetDlgItem(hwnd, IDC_SSCALE_CHAT), TBM_GETPOS, 0, 0);
+ shake.Save();
}
- break;
+ }
+ break;
}
return FALSE;
}
-void CreateImageList(HWND hWnd)
-{
- // Create and populate image list
- HIMAGELIST hImList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR32, nProtocol, 0);
-
- for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
- {
- INT_PTR res = CallProtoService(n->item.ProtocolName, PS_LOADICON,PLI_PROTOCOL | PLIF_SMALL | PLIF_ICOLIB, 0);
- if(res==CALLSERVICE_NOTFOUND)
- res = (INT_PTR)Skin_GetIconByHandle(n->item.hIcoLibItem);
+/////////////////////////////////////////////////////////////////////////////////////////
- HICON hIcon = (HICON) res;
- ImageList_AddIcon(hImList, hIcon);
- }
- //ADD default Icon for nudge
- HICON hIcon = (HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_NUDGE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
- ImageList_AddIcon(hImList, hIcon);
- DestroyIcon(hIcon);
-
- HWND hLstView = GetDlgItem(hWnd, IDC_PROTOLIST);
- TreeView_SetImageList(hLstView, hImList, TVSIL_NORMAL);
-}
-
-void PopulateProtocolList(HWND hWnd)
+static void PopulateProtocolList(HWND hWnd)
{
bool useOne = IsDlgButtonChecked(hWnd, IDC_USEBYPROTOCOL) == BST_UNCHECKED;
@@ -140,287 +172,228 @@ void PopulateProtocolList(HWND hWnd)
TreeView_DeleteAllItems(hLstView);
- TVINSERTSTRUCT tvi = {0};
+ TVINSERTSTRUCT tvi = { 0 };
tvi.hParent = TVI_ROOT;
tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_STATE | TVIF_SELECTEDIMAGE;
tvi.item.stateMask = TVIS_STATEIMAGEMASK;
int i = 0;
- if (GlobalNudge.useByProtocol)
- {
- for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
- {
+ if (GlobalNudge.useByProtocol) {
+ for (NudgeElementList *n = NudgeList; n != NULL; n = n->next) {
tvi.item.pszText = n->item.AccountName;
- tvi.item.iImage = i;
+ tvi.item.iImage = i;
n->item.iProtoNumber = i;
tvi.item.iSelectedImage = i;
- tvi.item.state = INDEXTOSTATEIMAGEMASK(n->item.enabled?2:1);
+ tvi.item.state = INDEXTOSTATEIMAGEMASK(n->item.enabled ? 2 : 1);
TreeView_InsertItem(hLstView, &tvi);
i++;
}
}
- else
- {
+ else {
tvi.item.pszText = TranslateT("Nudge");
- tvi.item.iImage = nProtocol;
+ tvi.item.iImage = nProtocol;
DefaultNudge.iProtoNumber = nProtocol;
tvi.item.iSelectedImage = nProtocol;
- tvi.item.state = INDEXTOSTATEIMAGEMASK(DefaultNudge.enabled?2:1);
+ tvi.item.state = INDEXTOSTATEIMAGEMASK(DefaultNudge.enabled ? 2 : 1);
TreeView_InsertItem(hLstView, &tvi);
}
TreeView_SelectItem(hLstView, TreeView_GetRoot(hLstView));
- //TreeView_SetCheckState(hLstView, TreeView_GetRoot(hLstView), TRUE)
}
+static void CreateImageList(HWND hWnd)
+{
+ // Create and populate image list
+ HIMAGELIST hImList = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_MASK | ILC_COLOR32, nProtocol, 0);
+
+ for (NudgeElementList *n = NudgeList; n != NULL; n = n->next) {
+ INT_PTR res = CallProtoService(n->item.ProtocolName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL | PLIF_ICOLIB, 0);
+ if (res == CALLSERVICE_NOTFOUND)
+ res = (INT_PTR)Skin_GetIconByHandle(n->item.hIcoLibItem);
+
+ HICON hIcon = (HICON)res;
+ ImageList_AddIcon(hImList, hIcon);
+ }
+ //ADD default Icon for nudge
+ HICON hIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(IDI_NUDGE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0);
+ ImageList_AddIcon(hImList, hIcon);
+ DestroyIcon(hIcon);
+
+ HWND hLstView = GetDlgItem(hWnd, IDC_PROTOLIST);
+ TreeView_SetImageList(hLstView, hImList, TVSIL_NORMAL);
+}
-INT_PTR CALLBACK DlgProcNudgeOpt(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK DlgProcNudgeOpt(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static bool iInitDone = true;
- switch(msg)
- {
- case WM_INITDIALOG:
- iInitDone = false;
- TranslateDialogDefault(hwnd);
- CreateImageList(hwnd);
- PopulateProtocolList(hwnd);
- UpdateControls(hwnd);
- iInitDone = true;
- break;
- case WM_DESTROY:
+ switch (msg) {
+ case WM_INITDIALOG:
+ iInitDone = false;
+ TranslateDialogDefault(hwnd);
+ CreateImageList(hwnd);
+ PopulateProtocolList(hwnd);
+ UpdateControls(hwnd);
+ iInitDone = true;
+ break;
+
+ case WM_DESTROY:
{
HIMAGELIST hImList = TreeView_GetImageList(GetDlgItem(hwnd, IDC_PROTOLIST), TVSIL_NORMAL);
- if (hImList)
- {
+ if (hImList) {
TreeView_SetImageList(GetDlgItem(hwnd, IDC_PROTOLIST), NULL, TVSIL_NORMAL); // Avoiding Access Violation in CommonControls DLL
ImageList_Destroy(hImList);
}
- break;
}
- case WM_COMMAND:
- {
- WORD wNotifyCode = HIWORD(wParam);
- switch(LOWORD(wParam))
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_PREVIEW:
+ Preview();
+ break;
+ case IDC_USEBYPROTOCOL:
+ GlobalNudge.useByProtocol = (IsDlgButtonChecked(hwnd, IDC_USEBYPROTOCOL) == BST_CHECKED);
+ PopulateProtocolList(hwnd);
+ UpdateControls(hwnd);
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ break;
+ case IDC_AUTORESEND:
+ if (ActualNudge)// fix NULL pointer then no nudge support protocols
{
- case IDC_PREVIEW:
- Preview();
- break;
- case IDC_USEBYPROTOCOL:
- GlobalNudge.useByProtocol = (IsDlgButtonChecked(hwnd,IDC_USEBYPROTOCOL)==BST_CHECKED);
- PopulateProtocolList(hwnd);
- UpdateControls(hwnd);
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
- break;
- case IDC_AUTORESEND:
+ ActualNudge->autoResend = (IsDlgButtonChecked(hwnd, IDC_AUTORESEND) == BST_CHECKED);
+ EnableWindow(GetDlgItem(hwnd, IDC_RESENDDELAY), ActualNudge->autoResend);
+ }
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ break;
+ case IDC_CHECKST0:
+ case IDC_CHECKST1:
+ case IDC_CHECKST2:
+ case IDC_CHECKST3:
+ case IDC_CHECKST4:
+ case IDC_CHECKST5:
+ case IDC_CHECKST6:
+ case IDC_CHECKST7:
+ case IDC_CHECKST8:
+ case IDC_CHECKST9:
+ case IDC_CHECKPOP:
+ case IDC_OPENMESSAGE:
+ case IDC_CHECKCLIST:
+ case IDC_CHECKCHAT:
+ case IDC_CHECKSTATUS:
+ case IDC_IGNORE:
+ case IDC_OPENCONTACTLIST:
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ break;
+ case IDC_RESENDDELAY:
+ case IDC_SENDTEXT:
+ case IDC_RECVTEXT:
+ case IDC_SENDTIME:
+ case IDC_RECVTIME:
+ if (iInitDone && (HIWORD(wParam) == EN_CHANGE))
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ break;
+ }
+ break;
+
+ case WM_SHOWWINDOW:
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ {
+ BOOL Translated;
+ GlobalNudge.sendTimeSec = GetDlgItemInt(hwnd, IDC_SENDTIME, &Translated, FALSE);
+ GlobalNudge.recvTimeSec = GetDlgItemInt(hwnd, IDC_RECVTIME, &Translated, FALSE);
+ GlobalNudge.resendDelaySec = GetDlgItemInt(hwnd, IDC_RESENDDELAY, &Translated, FALSE);
+ if (GlobalNudge.resendDelaySec > 10) GlobalNudge.resendDelaySec = 10;
+ if (GlobalNudge.resendDelaySec < 1) GlobalNudge.resendDelaySec = 1;
if (ActualNudge)// fix NULL pointer then no nudge support protocols
{
- ActualNudge->autoResend = (IsDlgButtonChecked(hwnd,IDC_AUTORESEND)==BST_CHECKED);
- EnableWindow(GetDlgItem(hwnd,IDC_RESENDDELAY),ActualNudge->autoResend);
+ ActualNudge->shakeClist = (IsDlgButtonChecked(hwnd, IDC_CHECKCLIST) == BST_CHECKED);
+ ActualNudge->shakeChat = (IsDlgButtonChecked(hwnd, IDC_CHECKCHAT) == BST_CHECKED);
+ ActualNudge->openMessageWindow = (IsDlgButtonChecked(hwnd, IDC_OPENMESSAGE) == BST_CHECKED);
+ ActualNudge->openContactList = (IsDlgButtonChecked(hwnd, IDC_OPENCONTACTLIST) == BST_CHECKED);
+ ActualNudge->useIgnoreSettings = (IsDlgButtonChecked(hwnd, IDC_IGNORE) == BST_CHECKED);
+ ActualNudge->showStatus = (IsDlgButtonChecked(hwnd, IDC_CHECKSTATUS) == BST_CHECKED);
+ ActualNudge->showPopup = (IsDlgButtonChecked(hwnd, IDC_CHECKPOP) == BST_CHECKED);
+ ActualNudge->statusFlags =
+ ((IsDlgButtonChecked(hwnd, IDC_CHECKST0) == BST_CHECKED) ? NUDGE_ACC_ST0 : 0) |
+ ((IsDlgButtonChecked(hwnd, IDC_CHECKST1) == BST_CHECKED) ? NUDGE_ACC_ST1 : 0) |
+ ((IsDlgButtonChecked(hwnd, IDC_CHECKST2) == BST_CHECKED) ? NUDGE_ACC_ST2 : 0) |
+ ((IsDlgButtonChecked(hwnd, IDC_CHECKST3) == BST_CHECKED) ? NUDGE_ACC_ST3 : 0) |
+ ((IsDlgButtonChecked(hwnd, IDC_CHECKST4) == BST_CHECKED) ? NUDGE_ACC_ST4 : 0) |
+ ((IsDlgButtonChecked(hwnd, IDC_CHECKST5) == BST_CHECKED) ? NUDGE_ACC_ST5 : 0) |
+ ((IsDlgButtonChecked(hwnd, IDC_CHECKST6) == BST_CHECKED) ? NUDGE_ACC_ST6 : 0) |
+ ((IsDlgButtonChecked(hwnd, IDC_CHECKST7) == BST_CHECKED) ? NUDGE_ACC_ST7 : 0) |
+ ((IsDlgButtonChecked(hwnd, IDC_CHECKST8) == BST_CHECKED) ? NUDGE_ACC_ST8 : 0) |
+ ((IsDlgButtonChecked(hwnd, IDC_CHECKST9) == BST_CHECKED) ? NUDGE_ACC_ST9 : 0);
+
+ GetDlgItemText(hwnd, IDC_SENDTEXT, ActualNudge->senText, TEXT_LEN);
+ GetDlgItemText(hwnd, IDC_RECVTEXT, ActualNudge->recText, TEXT_LEN);
+ ActualNudge->Save();
}
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
- break;
- case IDC_CHECKST0:
- case IDC_CHECKST1:
- case IDC_CHECKST2:
- case IDC_CHECKST3:
- case IDC_CHECKST4:
- case IDC_CHECKST5:
- case IDC_CHECKST6:
- case IDC_CHECKST7:
- case IDC_CHECKST8:
- case IDC_CHECKST9:
- case IDC_CHECKPOP:
- case IDC_OPENMESSAGE:
- case IDC_CHECKCLIST:
- case IDC_CHECKCHAT:
- case IDC_CHECKSTATUS:
- case IDC_IGNORE:
- case IDC_OPENCONTACTLIST:
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
- break;
- case IDC_RESENDDELAY:
- case IDC_SENDTEXT:
- case IDC_RECVTEXT:
- case IDC_SENDTIME:
- case IDC_RECVTIME:
- if(iInitDone && (wNotifyCode == EN_CHANGE))
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
- break;
+ GlobalNudge.Save();
+ }
}
break;
- }
- case WM_SHOWWINDOW:
- break;
- case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom)
- {
- case 0:
- switch(((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- BOOL Translated;
- GlobalNudge.sendTimeSec = GetDlgItemInt(hwnd,IDC_SENDTIME,&Translated,FALSE);
- GlobalNudge.recvTimeSec = GetDlgItemInt(hwnd,IDC_RECVTIME,&Translated,FALSE);
- GlobalNudge.resendDelaySec = GetDlgItemInt(hwnd,IDC_RESENDDELAY,&Translated,FALSE);
- if(GlobalNudge.resendDelaySec > 10 ) GlobalNudge.resendDelaySec = 10;
- if(GlobalNudge.resendDelaySec < 1 ) GlobalNudge.resendDelaySec = 1;
- if (ActualNudge)// fix NULL pointer then no nudge support protocols
- {
- ActualNudge->shakeClist = (IsDlgButtonChecked(hwnd,IDC_CHECKCLIST)==BST_CHECKED);
- ActualNudge->shakeChat = (IsDlgButtonChecked(hwnd,IDC_CHECKCHAT)==BST_CHECKED);
- ActualNudge->openMessageWindow = (IsDlgButtonChecked(hwnd,IDC_OPENMESSAGE)==BST_CHECKED);
- ActualNudge->openContactList = (IsDlgButtonChecked(hwnd,IDC_OPENCONTACTLIST)==BST_CHECKED);
- ActualNudge->useIgnoreSettings = (IsDlgButtonChecked(hwnd,IDC_IGNORE)==BST_CHECKED);
- ActualNudge->showStatus = (IsDlgButtonChecked(hwnd,IDC_CHECKSTATUS)==BST_CHECKED);
- ActualNudge->showPopup = (IsDlgButtonChecked(hwnd,IDC_CHECKPOP)==BST_CHECKED);
- ActualNudge->statusFlags =
- ((IsDlgButtonChecked(hwnd,IDC_CHECKST0)==BST_CHECKED) ? NUDGE_ACC_ST0 : 0) |
- ((IsDlgButtonChecked(hwnd,IDC_CHECKST1)==BST_CHECKED) ? NUDGE_ACC_ST1 : 0) |
- ((IsDlgButtonChecked(hwnd,IDC_CHECKST2)==BST_CHECKED) ? NUDGE_ACC_ST2 : 0) |
- ((IsDlgButtonChecked(hwnd,IDC_CHECKST3)==BST_CHECKED) ? NUDGE_ACC_ST3 : 0) |
- ((IsDlgButtonChecked(hwnd,IDC_CHECKST4)==BST_CHECKED) ? NUDGE_ACC_ST4 : 0) |
- ((IsDlgButtonChecked(hwnd,IDC_CHECKST5)==BST_CHECKED) ? NUDGE_ACC_ST5 : 0) |
- ((IsDlgButtonChecked(hwnd,IDC_CHECKST6)==BST_CHECKED) ? NUDGE_ACC_ST6 : 0) |
- ((IsDlgButtonChecked(hwnd,IDC_CHECKST7)==BST_CHECKED) ? NUDGE_ACC_ST7 : 0) |
- ((IsDlgButtonChecked(hwnd,IDC_CHECKST8)==BST_CHECKED) ? NUDGE_ACC_ST8 : 0) |
- ((IsDlgButtonChecked(hwnd,IDC_CHECKST9)==BST_CHECKED) ? NUDGE_ACC_ST9 : 0) ;
-
- GetDlgItemText(hwnd,IDC_SENDTEXT,ActualNudge->senText,TEXT_LEN);
- GetDlgItemText(hwnd,IDC_RECVTEXT,ActualNudge->recText,TEXT_LEN);
- ActualNudge->Save();
- }
- GlobalNudge.Save();
- }
- }
- case IDC_PROTOLIST:
- switch (((LPNMHDR)lParam)->code)
- {
- case NM_CLICK:
- {
- TVHITTESTINFO ht = {0};
-
- DWORD dwpos = GetMessagePos();
- POINTSTOPOINT(ht.pt, MAKEPOINTS(dwpos));
- MapWindowPoints(HWND_DESKTOP, ((LPNMHDR)lParam)->hwndFrom, &ht.pt, 1);
-
- TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &ht);
- /*if (TVHT_ONITEM & ht.flags)
- CheckChange(hwnd,ht.hItem);*/
- if (TVHT_ONITEMSTATEICON & ht.flags)
- CheckChange(hwnd,ht.hItem);
- }
-
- case TVN_KEYDOWN:
- if (((LPNMTVKEYDOWN) lParam)->wVKey == VK_SPACE)
- CheckChange(hwnd, TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom));
- break;
-
- case TVN_SELCHANGED:
- {
- LPNMTREEVIEW pnmtv = (LPNMTREEVIEW) lParam;
- if (pnmtv->itemNew.state & TVIS_SELECTED)
- UpdateControls(hwnd);
- }
- break;
- }
- break;
+ case IDC_PROTOLIST:
+ switch (((LPNMHDR)lParam)->code) {
+ case NM_CLICK:
+ {
+ TVHITTESTINFO ht = { 0 };
+
+ DWORD dwpos = GetMessagePos();
+ POINTSTOPOINT(ht.pt, MAKEPOINTS(dwpos));
+ MapWindowPoints(HWND_DESKTOP, ((LPNMHDR)lParam)->hwndFrom, &ht.pt, 1);
+
+ TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &ht);
+ if (TVHT_ONITEMSTATEICON & ht.flags)
+ CheckChange(hwnd, ht.hItem);
+ }
+
+ case TVN_KEYDOWN:
+ if (((LPNMTVKEYDOWN)lParam)->wVKey == VK_SPACE)
+ CheckChange(hwnd, TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom));
+ break;
+
+ case TVN_SELCHANGED:
+ LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
+ if (pnmtv->itemNew.state & TVIS_SELECTED)
+ UpdateControls(hwnd);
+ break;
}
break;
+ }
+ break;
}
return FALSE;
}
-void CheckChange(HWND hwnd, HTREEITEM hItem)
-{
- HWND hLstView = GetDlgItem(hwnd, IDC_PROTOLIST);
- bool isChecked = !TreeView_GetCheckState(hLstView, hItem);
+/////////////////////////////////////////////////////////////////////////////////////////
- TreeView_SelectItem(hLstView, hItem);
-
- int proto = nProtocol;
- if (GlobalNudge.useByProtocol)
- {
- proto = GetSelProto(hwnd, hItem);
- ActualNudge = NULL;
- for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
- {
- if(n->item.iProtoNumber == proto)
- ActualNudge = &n->item;
- }
- }
- else
- ActualNudge = &DefaultNudge;
-
- if (ActualNudge)// fix NULL pointer then no nudge support protocols
- ActualNudge->enabled = isChecked;
-
- UpdateControls(hwnd);
-}
-
-void UpdateControls(HWND hwnd)
+int NudgeOptInit(WPARAM wParam, LPARAM lParam)
{
- int proto = nProtocol;
- if (GlobalNudge.useByProtocol)
- {
- proto = GetSelProto(hwnd,NULL);
- ActualNudge = NULL;
- for(NudgeElementList *n = NudgeList;n != NULL; n = n->next)
- {
- if(n->item.iProtoNumber == proto)
- ActualNudge = &n->item;
- }
- }
- else
- ActualNudge = &DefaultNudge;
-
- SetDlgItemInt(hwnd, IDC_SENDTIME, GlobalNudge.sendTimeSec,FALSE);
- SetDlgItemInt(hwnd, IDC_RECVTIME, GlobalNudge.recvTimeSec,FALSE);
- SetDlgItemInt(hwnd, IDC_RESENDDELAY, GlobalNudge.resendDelaySec,FALSE);
- CheckDlgButton(hwnd, IDC_USEBYPROTOCOL, (WPARAM) GlobalNudge.useByProtocol);
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.position = -790000000;
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_NUDGE);
+ odp.pszTitle = LPGEN("Nudge");
+ odp.pszGroup = LPGEN("Events");
+ odp.pszTab = LPGEN("Nudge");
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pfnDlgProc = DlgProcNudgeOpt;
+ Options_AddPage(wParam, &odp);
- if (ActualNudge)// fix NULL pointer then no nudge support protocols
- {
- CheckDlgButton(hwnd, IDC_CHECKPOP, (WPARAM) ActualNudge->showPopup);
- CheckDlgButton(hwnd, IDC_CHECKCLIST, (WPARAM) ActualNudge->shakeClist);
- CheckDlgButton(hwnd, IDC_CHECKCHAT, (WPARAM) ActualNudge->shakeChat);
- CheckDlgButton(hwnd, IDC_CHECKSTATUS, (WPARAM) ActualNudge->showStatus);
- CheckDlgButton(hwnd, IDC_AUTORESEND, (WPARAM) ActualNudge->autoResend);
- CheckDlgButton(hwnd, IDC_OPENMESSAGE, (WPARAM) ActualNudge->openMessageWindow);
- CheckDlgButton(hwnd, IDC_OPENCONTACTLIST, (WPARAM) ActualNudge->openContactList);
- CheckDlgButton(hwnd, IDC_IGNORE, (WPARAM) ActualNudge->useIgnoreSettings);
- EnableWindow(GetDlgItem(hwnd,IDC_RESENDDELAY),ActualNudge->autoResend);
- CheckDlgButton(hwnd,IDC_CHECKST0,ActualNudge->statusFlags & NUDGE_ACC_ST0 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd,IDC_CHECKST1,ActualNudge->statusFlags & NUDGE_ACC_ST1 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd,IDC_CHECKST2,ActualNudge->statusFlags & NUDGE_ACC_ST2 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd,IDC_CHECKST3,ActualNudge->statusFlags & NUDGE_ACC_ST3 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd,IDC_CHECKST4,ActualNudge->statusFlags & NUDGE_ACC_ST4 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd,IDC_CHECKST5,ActualNudge->statusFlags & NUDGE_ACC_ST5 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd,IDC_CHECKST6,ActualNudge->statusFlags & NUDGE_ACC_ST6 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd,IDC_CHECKST7,ActualNudge->statusFlags & NUDGE_ACC_ST7 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd,IDC_CHECKST8,ActualNudge->statusFlags & NUDGE_ACC_ST8 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwnd,IDC_CHECKST9,ActualNudge->statusFlags & NUDGE_ACC_ST9 ? BST_CHECKED : BST_UNCHECKED);
- SetDlgItemText(hwnd,IDC_SENDTEXT,ActualNudge->senText);
- SetDlgItemText(hwnd,IDC_RECVTEXT,ActualNudge->recText);
- }
- else
- {
- EnableWindow(GetDlgItem(hwnd,IDC_PROTOLIST),FALSE);
- }
+ odp.position = -790000001;
+ odp.pszTab = LPGEN("Window Shaking");
+ odp.pfnDlgProc = DlgProcShakeOpt;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_SHAKE);
+ Options_AddPage(wParam, &odp);
+ return 0;
}
-
-int GetSelProto(HWND hwnd, HTREEITEM hItem)
-{
- HWND hLstView = GetDlgItem(hwnd, IDC_PROTOLIST);
- TVITEM tvi = {0};
-
- tvi.mask = TVIF_IMAGE;
- tvi.hItem = hItem == NULL ? TreeView_GetSelection(hLstView) : hItem;
-
- TreeView_GetItem(hLstView, &tvi);
-
- return tvi.iImage;
-} \ No newline at end of file
diff --git a/plugins/Nudge/src/options.h b/plugins/Nudge/src/options.h
index 68f648a0bb..57fe368350 100644
--- a/plugins/Nudge/src/options.h
+++ b/plugins/Nudge/src/options.h
@@ -4,11 +4,3 @@ extern int nProtocol;
extern CNudgeElement DefaultNudge;
extern CShake shake;
extern CNudge GlobalNudge;
-
-static INT_PTR CALLBACK OptionsDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-static INT_PTR CALLBACK DlgProcNudgeOpt(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
-static INT_PTR CALLBACK DlgProcShakeOpt(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
-
-void UpdateControls(HWND hwnd);
-int GetSelProto(HWND hwnd, HTREEITEM hItem);
-void CheckChange(HWND hwnd, HTREEITEM hItem);
diff --git a/plugins/Nudge/src/shake.cpp b/plugins/Nudge/src/shake.cpp
index e1b27d24bc..3998327e89 100644
--- a/plugins/Nudge/src/shake.cpp
+++ b/plugins/Nudge/src/shake.cpp
@@ -2,56 +2,55 @@
void CShake::Load(void)
{
-
Shaking = false;
ShakingChat = false;
- nScaleClist = db_get_dw(NULL, "Nudge", "ScaleClist", 5);
- nScaleChat = db_get_dw(NULL, "Nudge", "ScaleChat", 2);
- nMoveClist = db_get_dw(NULL, "Nudge", "MoveClist", 15);
- nMoveChat = db_get_dw(NULL, "Nudge", "MoveChat", 15);
+ nScaleClist = db_get_dw(NULL, MODULENAME, "ScaleClist", 5);
+ nScaleChat = db_get_dw(NULL, MODULENAME, "ScaleChat", 2);
+ nMoveClist = db_get_dw(NULL, MODULENAME, "MoveClist", 15);
+ nMoveChat = db_get_dw(NULL, MODULENAME, "MoveChat", 15);
}
void CShake::Save(void)
{
- 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);
+ db_set_dw(NULL, MODULENAME, "ScaleClist", this->nScaleClist);
+ db_set_dw(NULL, MODULENAME, "ScaleChat", this->nScaleChat);
+ db_set_dw(NULL, MODULENAME, "MoveClist", this->nMoveClist);
+ db_set_dw(NULL, MODULENAME, "MoveChat", this->nMoveChat);
}
DWORD WINAPI ShakeChatWindow(LPVOID Param)
{
- HWND hWnd = (HWND) Param;
+ HWND hWnd = (HWND)Param;
shake.ShakeChat(hWnd);
return 1;
}
DWORD WINAPI ShakeClistWindow(LPVOID Param)
{
- HWND hWnd = (HWND) Param;
+ HWND hWnd = (HWND)Param;
shake.ShakeClist(hWnd);
return 0;
}
-INT_PTR ShakeClist( WPARAM wParam, LPARAM lParam )
+INT_PTR ShakeClist(WPARAM wParam, LPARAM lParam)
{
- DWORD tid;
- HWND hWnd = (HWND) CallService(MS_CLUI_GETHWND, 0, 0 );
+ HWND hWnd = (HWND)CallService(MS_CLUI_GETHWND, 0, 0);
- CreateThread(NULL,0,ShakeClistWindow,(LPVOID) hWnd,0,&tid);
+ DWORD tid;
+ CreateThread(NULL, 0, ShakeClistWindow, (LPVOID)hWnd, 0, &tid);
return 0;
}
-INT_PTR ShakeChat( WPARAM wParam, LPARAM lParam )
+INT_PTR ShakeChat(WPARAM wParam, LPARAM lParam)
{
- if (((HANDLE) wParam) == NULL) return -1;
-
+ if (((HANDLE)wParam) == NULL) return -1;
+
DWORD tid;
//char srmmName[100];
MessageWindowData mwd;
MessageWindowInputData mwid;
mwd.cbSize = sizeof(MessageWindowData);
- mwd.hContact = Nudge_GethContact((HANDLE) wParam);
+ mwd.hContact = Nudge_GethContact((HANDLE)wParam);
mwd.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
mwid.cbSize = sizeof(MessageWindowInputData);
@@ -59,93 +58,24 @@ INT_PTR ShakeChat( WPARAM wParam, LPARAM lParam )
mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
- CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd );
+ CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd);
//CallService(MS_MSG_GETWINDOWCLASS,(WPARAM)srmmName,(LPARAM)100 );
HWND parent;
HWND hWnd = mwd.hwndWindow;
- while((parent = GetParent(hWnd)) != 0) hWnd = parent; // ensure we have the top level window (need parent window for scriver & tabsrmm)
-
- CreateThread(NULL,0,ShakeChatWindow,(LPVOID) hWnd,0,&tid);
- return 0;
-}
-
-/*
-
-int TriggerShakeClist( WPARAM wParam, LPARAM lParam )
-{
- DWORD tid;
- HWND hWnd;
- int flags;
- flags = (int)wParam;
-
- if (!flags&ACT_PERFORM)
- return 0;
-
- hWnd = (HWND) CallService(MS_CLUI_GETHWND, 0, 0 );
-
- CreateThread(NULL,0,ShakeClistWindow,(LPVOID) hWnd,0,&tid);
- return 0;
-}
-
-int TriggerShakeChat( WPARAM wParam, LPARAM lParam )
-{
- DWORD tid;
- HWND hWnd;
- char srmmName[100];
- MessageWindowData mwd;
- MessageWindowInputData mwid;
- int flags;
- flags = (int)wParam;
-
- if (!flags&ACT_PERFORM)
- return 0;
-
- SPECIFICACTIONINFO *sai;
- HANDLE hContact;
+ while ((parent = GetParent(hWnd)) != 0) hWnd = parent; // ensure we have the top level window (need parent window for scriver & tabsrmm)
-
- sai = (SPECIFICACTIONINFO *) lParam;
-
- if ( (sai->td != NULL) && (sai->td->dFlags&DF_CONTACT))
- hContact = sai->td->hContact;
- else
- return 0;
-
- mwd.cbSize = sizeof(MessageWindowData);
- mwd.hContact = Nudge_GethContact((HANDLE) hContact);
- mwd.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
-
- mwid.cbSize = sizeof(MessageWindowInputData);
- mwid.hContact = Nudge_GethContact((HANDLE) hContact);
- mwid.uFlags = MSG_WINDOW_UFLAG_MSG_BOTH;
-
- CallService(MS_MSG_GETWINDOWDATA, (WPARAM)&mwid, (LPARAM)&mwd );
- CallService(MS_MSG_GETWINDOWCLASS,(WPARAM)srmmName,(LPARAM)100 );
-
- if ( !strnicmp( srmmName,"tabSRMM ", 7 ))
- hWnd = GetParent(GetParent(mwd.hwndWindow));
-
- if ( !strnicmp( srmmName,"SRMM ", 4))
- hWnd = mwd.hwndWindow;
-
- if ( !strnicmp( srmmName,"Scriver ", 7 ))
- hWnd = GetParent(mwd.hwndWindow);
-
- CreateThread(NULL,0,ShakeChatWindow,(LPVOID) hWnd,0,&tid);
+ CreateThread(NULL, 0, ShakeChatWindow, (LPVOID)hWnd, 0, &tid);
return 0;
}
-*/
int CShake::ShakeChat(HWND hWnd)
{
- if (!ShakingChat)
- {
+ if (!ShakingChat) {
ShakingChat = true;
RECT rect;
GetWindowRect(hWnd, &rect);
- for(int i = 0; i < nMoveChat; i++)
- {
+ for (int i = 0; i < nMoveChat; i++) {
SetWindowPos(hWnd, 0, rect.left - nScaleChat, rect.top, 0, 0, SWP_NOSIZE);
Sleep(10);
SetWindowPos(hWnd, 0, rect.left, rect.top - nScaleChat, 0, 0, SWP_NOSIZE);
@@ -163,13 +93,11 @@ int CShake::ShakeChat(HWND hWnd)
int CShake::ShakeClist(HWND hWnd)
{
- if (!Shaking)
- {
+ if (!Shaking) {
Shaking = true;
RECT rect;
GetWindowRect(hWnd, &rect);
- for(int i = 0; i < nMoveClist; i++)
- {
+ for (int i = 0; i < nMoveClist; i++) {
SetWindowPos(hWnd, 0, rect.left - nScaleClist, rect.top, 0, 0, SWP_NOSIZE);
Sleep(10);
SetWindowPos(hWnd, 0, rect.left, rect.top - nScaleClist, 0, 0, SWP_NOSIZE);
@@ -183,4 +111,4 @@ int CShake::ShakeClist(HWND hWnd)
Shaking = false;
}
return 0;
-} \ No newline at end of file
+}