summaryrefslogtreecommitdiff
path: root/plugins/Nudge
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-04-09 15:09:56 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-04-09 15:09:56 +0000
commit11a0c05e56a9ef98dcb8473e5c4ccd2a519ad730 (patch)
treeda78d1bf31d4922c7c7a91c8af698ac94be0b8b2 /plugins/Nudge
parent74a2e42b34d8495bf1e3676d4580e1d286384722 (diff)
Nudge:
- old ugly list replaced with OBJLIST<>; - plugin to reuse the same popup menu item instead of creating a menu item for each protocol; - fix for a bug in options; - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@12698 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Nudge')
-rw-r--r--plugins/Nudge/nudge_10.vcxproj1
-rw-r--r--plugins/Nudge/nudge_10.vcxproj.filters3
-rw-r--r--plugins/Nudge/nudge_12.vcxproj1
-rw-r--r--plugins/Nudge/nudge_12.vcxproj.filters3
-rw-r--r--plugins/Nudge/src/Version.h2
-rw-r--r--plugins/Nudge/src/headers.h10
-rw-r--r--plugins/Nudge/src/main.cpp190
-rw-r--r--plugins/Nudge/src/nudge.h26
-rw-r--r--plugins/Nudge/src/options.cpp98
-rw-r--r--plugins/Nudge/src/options.h6
10 files changed, 153 insertions, 187 deletions
diff --git a/plugins/Nudge/nudge_10.vcxproj b/plugins/Nudge/nudge_10.vcxproj
index f672e018b7..43b5952911 100644
--- a/plugins/Nudge/nudge_10.vcxproj
+++ b/plugins/Nudge/nudge_10.vcxproj
@@ -194,7 +194,6 @@
<ItemGroup>
<ClInclude Include="src\headers.h" />
<ClInclude Include="src\nudge.h" />
- <ClInclude Include="src\options.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\shake.h" />
<ClInclude Include="src\Version.h" />
diff --git a/plugins/Nudge/nudge_10.vcxproj.filters b/plugins/Nudge/nudge_10.vcxproj.filters
index ef11e6e178..e6465ed126 100644
--- a/plugins/Nudge/nudge_10.vcxproj.filters
+++ b/plugins/Nudge/nudge_10.vcxproj.filters
@@ -35,9 +35,6 @@
<ClInclude Include="src\nudge.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\options.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/plugins/Nudge/nudge_12.vcxproj b/plugins/Nudge/nudge_12.vcxproj
index b7f93a7573..abb02b3340 100644
--- a/plugins/Nudge/nudge_12.vcxproj
+++ b/plugins/Nudge/nudge_12.vcxproj
@@ -197,7 +197,6 @@
<ItemGroup>
<ClInclude Include="src\headers.h" />
<ClInclude Include="src\nudge.h" />
- <ClInclude Include="src\options.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\shake.h" />
<ClInclude Include="src\Version.h" />
diff --git a/plugins/Nudge/nudge_12.vcxproj.filters b/plugins/Nudge/nudge_12.vcxproj.filters
index ef11e6e178..e6465ed126 100644
--- a/plugins/Nudge/nudge_12.vcxproj.filters
+++ b/plugins/Nudge/nudge_12.vcxproj.filters
@@ -35,9 +35,6 @@
<ClInclude Include="src\nudge.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\options.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\resource.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/plugins/Nudge/src/Version.h b/plugins/Nudge/src/Version.h
index 965767c3bb..e3e9d259c6 100644
--- a/plugins/Nudge/src/Version.h
+++ b/plugins/Nudge/src/Version.h
@@ -1,5 +1,5 @@
#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 1
+#define __MINOR_VERSION 2
#define __RELEASE_NUM 0
#define __BUILD_NUM 1
diff --git a/plugins/Nudge/src/headers.h b/plugins/Nudge/src/headers.h
index 86c31a568e..3260969903 100644
--- a/plugins/Nudge/src/headers.h
+++ b/plugins/Nudge/src/headers.h
@@ -51,7 +51,6 @@
#include "shake.h"
#include "Version.h"
#include "nudge.h"
-#include "options.h"
/*
*
@@ -93,4 +92,13 @@ void LoadPopupClass();
****************************/
void AutoResendNudge(void *wParam) ;
+///////////////////////////////////////////////////////////////////////////////
+// external variables
+
+extern HINSTANCE hInst;
+extern int nProtocol;
extern CShake shake;
+extern CNudge GlobalNudge;
+
+extern CNudgeElement DefaultNudge;
+extern OBJLIST<CNudgeElement> arNudges; \ No newline at end of file
diff --git a/plugins/Nudge/src/main.cpp b/plugins/Nudge/src/main.cpp
index 12395c6d7c..a4c3b2143b 100644
--- a/plugins/Nudge/src/main.cpp
+++ b/plugins/Nudge/src/main.cpp
@@ -4,7 +4,8 @@ int nProtocol = 0;
static HANDLE hPopupClass;
HINSTANCE hInst;
-NudgeElementList *NudgeList = NULL;
+HGENMENU g_hContactMenu;
+OBJLIST<CNudgeElement> arNudges(5);
CNudgeElement DefaultNudge;
CShake shake;
CNudge GlobalNudge;
@@ -30,14 +31,17 @@ PLUGININFOEX pluginInfo = {
INT_PTR NudgeShowMenu(WPARAM wParam, LPARAM lParam)
{
- for (NudgeElementList *n = NudgeList; n != NULL; n = n->next) {
- if (!strcmp((char *)wParam, n->item.ProtocolName)) {
- bool bEnabled = GlobalNudge.useByProtocol ? n->item.enabled : DefaultNudge.enabled;
- Menu_ShowItem(n->item.hContactMenu, bEnabled && lParam != 0);
+ bool bEnabled = false;
+
+ for (int i = 0; i < arNudges.getCount(); i++) {
+ CNudgeElement &p = arNudges[i];
+ if (!strcmp((char*)wParam, p.ProtocolName)) {
+ bEnabled = GlobalNudge.useByProtocol ? p.enabled : DefaultNudge.enabled;
break;
}
}
+ Menu_ShowItem(g_hContactMenu, bEnabled && lParam != 0);
return 0;
}
@@ -49,9 +53,11 @@ INT_PTR NudgeSend(WPARAM hContact, LPARAM lParam)
TCHAR msg[500];
mir_sntprintf(msg, SIZEOF(msg), 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, hContact, msg);
+ for (int i = 0; i < arNudges.getCount(); i++) {
+ CNudgeElement &p = arNudges[i];
+ if (!strcmp(protoName, p.ProtocolName))
+ Nudge_ShowPopup(&p, hContact, msg);
+ }
}
else Nudge_ShowPopup(&DefaultNudge, hContact, msg);
@@ -61,10 +67,12 @@ INT_PTR NudgeSend(WPARAM hContact, LPARAM lParam)
db_set_dw(hContact, "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, hContact);
+ for (int i = 0; i < arNudges.getCount(); i++) {
+ CNudgeElement &p = arNudges[i];
+ if (!strcmp(protoName, p.ProtocolName))
+ if (p.showStatus)
+ Nudge_SentStatus(&p, hContact);
+ }
}
else if (DefaultNudge.showStatus)
Nudge_SentStatus(&DefaultNudge, hContact);
@@ -96,47 +104,48 @@ int NudgeReceived(WPARAM hContact, LPARAM lParam)
db_set_dw(hContact, "Nudge", "LastReceived2", nudgeSentTimestamp);
if (GlobalNudge.useByProtocol) {
- for (NudgeElementList *n = NudgeList; n != NULL; n = n->next) {
- if (!strcmp(protoName, n->item.ProtocolName)) {
+ for (int i = 0; i < arNudges.getCount(); i++) {
+ CNudgeElement &p = arNudges[i];
+ if (!strcmp(protoName, p.ProtocolName)) {
- if (n->item.enabled) {
- if (n->item.useIgnoreSettings && CallService(MS_IGNORE_ISIGNORED, hContact, IGNOREEVENT_USERONLINE))
+ if (p.enabled) {
+ if (p.useIgnoreSettings && CallService(MS_IGNORE_ISIGNORED, hContact, 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)))
+ if (((p.statusFlags & NUDGE_ACC_ST0) && (Status <= ID_STATUS_OFFLINE)) ||
+ ((p.statusFlags & NUDGE_ACC_ST1) && (Status == ID_STATUS_ONLINE)) ||
+ ((p.statusFlags & NUDGE_ACC_ST2) && (Status == ID_STATUS_AWAY)) ||
+ ((p.statusFlags & NUDGE_ACC_ST3) && (Status == ID_STATUS_DND)) ||
+ ((p.statusFlags & NUDGE_ACC_ST4) && (Status == ID_STATUS_NA)) ||
+ ((p.statusFlags & NUDGE_ACC_ST5) && (Status == ID_STATUS_OCCUPIED)) ||
+ ((p.statusFlags & NUDGE_ACC_ST6) && (Status == ID_STATUS_FREECHAT)) ||
+ ((p.statusFlags & NUDGE_ACC_ST7) && (Status == ID_STATUS_INVISIBLE)) ||
+ ((p.statusFlags & NUDGE_ACC_ST8) && (Status == ID_STATUS_ONTHEPHONE)) ||
+ ((p.statusFlags & NUDGE_ACC_ST9) && (Status == ID_STATUS_OUTTOLUNCH)))
{
if (diff >= GlobalNudge.recvTimeSec) {
- if (n->item.showPopup)
- Nudge_ShowPopup(&n->item, hContact, n->item.recText);
- if (n->item.openContactList)
+ if (p.showPopup)
+ Nudge_ShowPopup(&p, hContact, p.recText);
+ if (p.openContactList)
OpenContactList();
- if (n->item.shakeClist)
+ if (p.shakeClist)
ShakeClist(hContact, lParam);
- if (n->item.openMessageWindow)
+ if (p.openMessageWindow)
CallService(MS_MSG_SENDMESSAGET, hContact, 0);
- if (n->item.shakeChat)
+ if (p.shakeChat)
ShakeChat(hContact, lParam);
- if (n->item.autoResend)
+ if (p.autoResend)
mir_forkthread(AutoResendNudge, (void*)hContact);
- SkinPlaySound(n->item.NudgeSoundname);
+ SkinPlaySound(p.NudgeSoundname);
}
}
if (diff2 >= GlobalNudge.recvTimeSec)
- if (n->item.showStatus)
- Nudge_ShowStatus(&n->item, hContact, nudgeSentTimestamp);
+ if (p.showStatus)
+ Nudge_ShowStatus(&p, hContact, nudgeSentTimestamp);
}
break;
}
@@ -221,9 +230,9 @@ static IconItem iconList[] =
{ LPGEN("Nudge as Default"), "Nudge_Default", IDI_NUDGE }
};
+// Load icons
void LoadIcons(void)
{
- //Load icons
Icon_Register(hInst, LPGEN("Nudge"), iconList, SIZEOF(iconList));
}
@@ -265,7 +274,7 @@ void HideNudgeButton(MCONTACT hContact)
}
}
-static int ContactWindowOpen(WPARAM wParam, LPARAM lParam)
+static int ContactWindowOpen(WPARAM, LPARAM lParam)
{
MessageWindowEventData *MWeventdata = (MessageWindowEventData*)lParam;
if (MWeventdata->uType == MSG_WINDOW_EVT_OPENING && MWeventdata->hContact)
@@ -274,12 +283,12 @@ static int ContactWindowOpen(WPARAM wParam, LPARAM lParam)
return 0;
}
-static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
+static int PrebuildContactMenu(WPARAM hContact, LPARAM)
{
- char *szProto = GetContactProto(wParam);
+ char *szProto = GetContactProto(hContact);
if (szProto != NULL) {
- bool isChat = db_get_b(wParam, szProto, "ChatRoom", false) != 0;
- NudgeShowMenu((WPARAM)szProto, (LPARAM)!isChat);
+ bool isChat = db_get_b(hContact, szProto, "ChatRoom", false) != 0;
+ NudgeShowMenu((WPARAM)szProto, !isChat);
}
return 0;
@@ -326,6 +335,17 @@ extern "C" int __declspec(dllexport) Load(void)
CreateServiceFunction(MS_NUDGE_SEND, NudgeSend);
CreateServiceFunction(MS_NUDGE_SHOWMENU, NudgeShowMenu);
+ // Add contact menu entry
+ CLISTMENUITEM mi = { 0 };
+ mi.cbSize = sizeof(mi);
+ mi.popupPosition = 500085000;
+ mi.flags = CMIF_NOTOFFLINE | CMIF_TCHAR;
+ mi.position = -500050004;
+ mi.icolibItem = iconList[0].hIcolib;
+ mi.ptszName = LPGENT("Send &Nudge");
+ mi.pszService = MS_NUDGE_SEND;
+ g_hContactMenu = Menu_AddContactMenuItem(&mi);
+
// register special type of event
// there's no need to declare the special service for getting text
// because a blob contains only text
@@ -341,13 +361,7 @@ extern "C" int __declspec(dllexport) Load(void)
extern "C" int __declspec(dllexport) Unload(void)
{
- NudgeElementList *p = NudgeList;
- while (p != NULL) {
- if (p->item.hEvent) UnhookEvent(p->item.hEvent);
- NudgeElementList* p1 = p->next;
- delete p;
- p = p1;
- }
+ arNudges.destroy();
return 0;
}
@@ -394,18 +408,19 @@ int Preview()
{
MCONTACT 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)
- Nudge_ShowPopup(&n->item, hContact, n->item.recText);
- if (n->item.openContactList)
+ for (int i = 0; i < arNudges.getCount(); i++) {
+ CNudgeElement &p = arNudges[i];
+ if (p.enabled) {
+ SkinPlaySound(p.NudgeSoundname);
+ if (p.showPopup)
+ Nudge_ShowPopup(&p, hContact, p.recText);
+ if (p.openContactList)
OpenContactList();
- if (n->item.shakeClist)
+ if (p.shakeClist)
ShakeClist(0, 0);
- if (n->item.openMessageWindow)
+ if (p.openMessageWindow)
CallService(MS_MSG_SENDMESSAGET, hContact, NULL);
- if (n->item.shakeChat)
+ if (p.shakeChat)
ShakeChat(hContact, (LPARAM)time(NULL));
}
}
@@ -431,7 +446,7 @@ int Preview()
void Nudge_ShowPopup(CNudgeElement *n, MCONTACT hContact, TCHAR * Message)
{
hContact = db_mc_tryMeta(hContact);
- TCHAR * lpzContactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR);
+ TCHAR *lpzContactName = (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR);
if (ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
POPUPDATACLASS NudgePopup = { 0 };
@@ -445,17 +460,15 @@ void Nudge_ShowPopup(CNudgeElement *n, MCONTACT hContact, TCHAR * Message)
else if (ServiceExists(MS_POPUP_ADDPOPUPT)) {
POPUPDATAT NudgePopup = { 0 };
NudgePopup.lchContact = hContact;
- NudgePopup.lchIcon = Skin_GetIconByHandle(n->hIcoLibItem);
+ NudgePopup.lchIcon = Skin_GetIconByHandle(iconList[0].hIcolib);
NudgePopup.colorBack = 0;
NudgePopup.colorText = 0;
NudgePopup.iSeconds = 0;
NudgePopup.PluginWindowProc = NudgePopupProc;
NudgePopup.PluginData = (void *)1;
- //mir_tstrcpy(NudgePopup.lpzText, Translate(Message));
- mir_tstrcpy(NudgePopup.lptzText, Message);
-
- mir_tstrcpy(NudgePopup.lptzContactName, lpzContactName);
+ _tcscpy_s(NudgePopup.lptzText, Message);
+ _tcscpy_s(NudgePopup.lptzContactName, lpzContactName);
CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&NudgePopup, 0);
}
@@ -502,52 +515,21 @@ void Nudge_AddAccount(PROTOACCOUNT *proto)
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);
-
- strcpy(newNudge->item.ProtocolName, proto->szProtoName);
- _tcscpy(newNudge->item.AccountName, proto->tszAccountName);
+ // Add a specific sound per protocol
+ CNudgeElement *p = new CNudgeElement();
+ mir_snprintf(p->NudgeSoundname, SIZEOF(p->NudgeSoundname), "%s: Nudge", proto->szModuleName);
- newNudge->item.Load();
+ strcpy_s(p->ProtocolName, proto->szModuleName);
+ _tcscpy_s(p->AccountName, proto->tszAccountName);
- newNudge->item.hEvent = hevent;
+ p->Load();
+ p->hEvent = hevent;
TCHAR soundDesc[MAXMODULELABELLENGTH + 10];
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);
-
- TCHAR szFilename[MAX_PATH], iconDesc[MAXMODULELABELLENGTH + 10];
- GetModuleFileName(hInst, szFilename, MAX_PATH);
- mir_sntprintf(iconDesc, SIZEOF(iconDesc), TranslateT("Nudge for %s"), proto->tszAccountName);
-
- SKINICONDESC sid = { sizeof(sid) };
- sid.flags = SIDF_ALL_TCHAR;
- sid.ptszSection = LPGENT("Nudge");
- sid.ptszDefaultFile = szFilename;
- sid.pszName = iconName;
- sid.ptszDescription = iconDesc;
- sid.iDefaultIndex = -IDI_NUDGE;
- newNudge->item.hIcoLibItem = Skin_AddIcon(&sid);
+ SkinAddNewSoundExT(p->NudgeSoundname, LPGENT("Nudge"), soundDesc);
- //Add contact menu entry
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.popupPosition = 500085000;
- mi.pszContactOwner = proto->szModuleName;
- mi.pszPopupName = proto->szModuleName;
- mi.flags = CMIF_NOTOFFLINE | CMIF_TCHAR;
- mi.position = -500050004;
- mi.icolibItem = newNudge->item.hIcoLibItem;
- mi.ptszName = LPGENT("Send &Nudge");
- mi.pszService = MS_NUDGE_SEND;
- newNudge->item.hContactMenu = Menu_AddContactMenuItem(&mi);
+ arNudges.insert(p);
}
void AutoResendNudge(void *wParam)
diff --git a/plugins/Nudge/src/nudge.h b/plugins/Nudge/src/nudge.h
index 1098c2eda4..9140b39667 100644
--- a/plugins/Nudge/src/nudge.h
+++ b/plugins/Nudge/src/nudge.h
@@ -4,11 +4,11 @@
#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
-#define NUDGE_ACC_ST2 0x00000004 //Check (countdown) when Away
-#define NUDGE_ACC_ST3 0x00000008 //Check (countdown) when N/A
-#define NUDGE_ACC_ST4 0x00000010 //Check (countdown) when Occupied
+#define NUDGE_ACC_ST0 0x00000001 //Check (countdown) when Offline
+#define NUDGE_ACC_ST1 0x00000002 //Check (countdown) when Online
+#define NUDGE_ACC_ST2 0x00000004 //Check (countdown) when Away
+#define NUDGE_ACC_ST3 0x00000008 //Check (countdown) when N/A
+#define NUDGE_ACC_ST4 0x00000010 //Check (countdown) when Occupied
#define NUDGE_ACC_ST5 0x00000020 //Check (countdown) when DND
#define NUDGE_ACC_ST6 0x00000040 //Check (countdown) when Free for chat
#define NUDGE_ACC_ST7 0x00000080 //Check (countdown) when Invisible
@@ -17,9 +17,8 @@
#define TEXT_LEN 1024
-class CNudge
+struct CNudge
{
-public:
bool useByProtocol;
int sendTimeSec;
int recvTimeSec;
@@ -29,9 +28,8 @@ public:
void Save(void);
};
-class CNudgeElement
+struct CNudgeElement : public MZeroedObject
{
-public:
char ProtocolName[64];
TCHAR AccountName[128];
char NudgeSoundname[100];
@@ -48,18 +46,10 @@ public:
bool autoResend;
DWORD statusFlags;
int iProtoNumber;
- HANDLE hIcoLibItem;
HANDLE hEvent;
- HGENMENU hContactMenu;
void Load(void);
void Save(void);
};
-typedef struct NudgeElementList
-{
- CNudgeElement item;
- NudgeElementList *next;
-} NUDGEELEMENTLIST;
-
-#endif \ No newline at end of file
+#endif // NUDGE_H
diff --git a/plugins/Nudge/src/options.cpp b/plugins/Nudge/src/options.cpp
index 16a9f9486e..7f06e491e1 100644
--- a/plugins/Nudge/src/options.cpp
+++ b/plugins/Nudge/src/options.cpp
@@ -21,9 +21,11 @@ static void UpdateControls(HWND hwnd)
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;
+ for (int i = 0; i < arNudges.getCount(); i++) {
+ CNudgeElement &p = arNudges[i];
+ if (p.iProtoNumber == proto)
+ ActualNudge = &p;
+ }
}
else ActualNudge = &DefaultNudge;
@@ -69,9 +71,11 @@ static void CheckChange(HWND hwnd, HTREEITEM hItem)
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;
+ for (int i = 0; i < arNudges.getCount(); i++) {
+ CNudgeElement &p = arNudges[i];
+ if (p.iProtoNumber == proto)
+ ActualNudge = &p;
+ }
}
else ActualNudge = &DefaultNudge;
@@ -178,16 +182,15 @@ static void PopulateProtocolList(HWND hWnd)
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) {
- tvi.item.pszText = n->item.AccountName;
+ for (int i = 0; i < arNudges.getCount(); i++) {
+ CNudgeElement &p = arNudges[i];
+ tvi.item.pszText = p.AccountName;
tvi.item.iImage = i;
- n->item.iProtoNumber = i;
+ p.iProtoNumber = i;
tvi.item.iSelectedImage = i;
- tvi.item.state = INDEXTOSTATEIMAGEMASK(n->item.enabled ? 2 : 1);
+ tvi.item.state = INDEXTOSTATEIMAGEMASK(p.enabled ? 2 : 1);
TreeView_InsertItem(hLstView, &tvi);
- i++;
}
}
else {
@@ -207,10 +210,11 @@ 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);
+ for (int i = 0; i < arNudges.getCount(); i++) {
+ CNudgeElement &p = arNudges[i];
+ INT_PTR res = CallProtoService(p.ProtocolName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL | PLIF_ICOLIB, 0);
if (res == CALLSERVICE_NOTFOUND)
- res = (INT_PTR)Skin_GetIconByHandle(n->item.hIcoLibItem);
+ res = (INT_PTR)Skin_GetIcon("Nudge_Default");
HICON hIcon = (HICON)res;
ImageList_AddIcon(hImList, hIcon);
@@ -259,8 +263,7 @@ static INT_PTR CALLBACK DlgProcNudgeOpt(HWND hwnd, UINT msg, WPARAM wParam, LPAR
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
case IDC_AUTORESEND:
- if (ActualNudge)// fix NULL pointer then no nudge support protocols
- {
+ 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);
}
@@ -304,38 +307,35 @@ static INT_PTR CALLBACK DlgProcNudgeOpt(HWND hwnd, UINT msg, WPARAM wParam, LPAR
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();
- }
+ 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();
}
}
diff --git a/plugins/Nudge/src/options.h b/plugins/Nudge/src/options.h
deleted file mode 100644
index 57fe368350..0000000000
--- a/plugins/Nudge/src/options.h
+++ /dev/null
@@ -1,6 +0,0 @@
-extern HINSTANCE hInst;
-extern NudgeElementList* NudgeList;
-extern int nProtocol;
-extern CNudgeElement DefaultNudge;
-extern CShake shake;
-extern CNudge GlobalNudge;