diff options
Diffstat (limited to 'plugins/ConnectionNotify/src')
-rw-r--r-- | plugins/ConnectionNotify/src/ConnectionNotify.cpp | 903 | ||||
-rw-r--r-- | plugins/ConnectionNotify/src/debug.cpp | 72 | ||||
-rw-r--r-- | plugins/ConnectionNotify/src/debug.h | 2 | ||||
-rw-r--r-- | plugins/ConnectionNotify/src/filter.cpp | 191 | ||||
-rw-r--r-- | plugins/ConnectionNotify/src/filter.h | 2 | ||||
-rw-r--r-- | plugins/ConnectionNotify/src/netstat.cpp | 40 | ||||
-rw-r--r-- | plugins/ConnectionNotify/src/netstat.h | 4 | ||||
-rw-r--r-- | plugins/ConnectionNotify/src/pid2name.cpp | 7 | ||||
-rw-r--r-- | plugins/ConnectionNotify/src/stdafx.h (renamed from plugins/ConnectionNotify/src/ConnectionNotify.h) | 2 |
9 files changed, 603 insertions, 620 deletions
diff --git a/plugins/ConnectionNotify/src/ConnectionNotify.cpp b/plugins/ConnectionNotify/src/ConnectionNotify.cpp index b579d937de..3b8417abfd 100644 --- a/plugins/ConnectionNotify/src/ConnectionNotify.cpp +++ b/plugins/ConnectionNotify/src/ConnectionNotify.cpp @@ -1,46 +1,46 @@ -#include "ConnectionNotify.h"
+#include "stdafx.h"
HINSTANCE hInst;
//PLUGINLINK *pluginLink=NULL;
-HANDLE hOptInit=NULL;
+HANDLE hOptInit = NULL;
static HWND hTimerWnd = (HWND)NULL;
static UINT TID = (UINT)12021;
//HANDLE hHookModulesLoaded=NULL;
-HANDLE hCheckEvent=NULL;
-HANDLE hCheckHook=NULL;
-HANDLE hHookModulesLoaded=NULL;
-HANDLE hHookPreShutdown=NULL;
+HANDLE hCheckEvent = NULL;
+HANDLE hCheckHook = NULL;
+HANDLE hHookModulesLoaded = NULL;
+HANDLE hHookPreShutdown = NULL;
HANDLE hConnectionCheckThread = NULL;
-HANDLE hFilterOptionsThread=NULL;
-HANDLE killCheckThreadEvent=NULL;
-HANDLE hExceptionsMutex=NULL;
+HANDLE hFilterOptionsThread = NULL;
+HANDLE killCheckThreadEvent = NULL;
+HANDLE hExceptionsMutex = NULL;
//HANDLE hCurrentEditMutex=NULL;
-int hLangpack=0;
+int hLangpack = 0;
DWORD FilterOptionsThreadId;
DWORD ConnectionCheckThreadId;
-BYTE settingSetColours=0;
+BYTE settingSetColours = 0;
COLORREF settingBgColor;
COLORREF settingFgColor;
-int settingInterval=0;
-int settingInterval1=0;
-BYTE settingResolveIp=0;
+int settingInterval = 0;
+int settingInterval1 = 0;
+BYTE settingResolveIp = 0;
BOOL settingStatus[STATUS_COUNT];
-int settingFiltersCount=0;
-BOOL settingDefaultAction=TRUE;
-WORD settingStatusMask=0;
+int settingFiltersCount = 0;
+BOOL settingDefaultAction = TRUE;
+WORD settingStatusMask = 0;
-struct CONNECTION *first=NULL;
-struct CONNECTION *connExceptions=NULL;
+struct CONNECTION *first = NULL;
+struct CONNECTION *connExceptions = NULL;
struct CONNECTION *connCurrentEdit;
-struct CONNECTION *connExceptionsTmp=NULL;
-struct CONNECTION *connCurrentEditModal=NULL;
-int currentStatus = ID_STATUS_OFFLINE,diffstat=0;
-BOOL bOptionsOpen=FALSE;
-TCHAR *tcpStates[]={_T("CLOSED"),_T("LISTEN"),_T("SYN_SENT"),_T("SYN_RCVD"),_T("ESTAB"),_T("FIN_WAIT1"),_T("FIN_WAIT2"),_T("CLOSE_WAIT"),_T("CLOSING"),_T("LAST_ACK"),_T("TIME_WAIT"),_T("DELETE_TCB")};
+struct CONNECTION *connExceptionsTmp = NULL;
+struct CONNECTION *connCurrentEditModal = NULL;
+int currentStatus = ID_STATUS_OFFLINE, diffstat = 0;
+BOOL bOptionsOpen = FALSE;
+TCHAR *tcpStates[] = { _T("CLOSED"), _T("LISTEN"), _T("SYN_SENT"), _T("SYN_RCVD"), _T("ESTAB"), _T("FIN_WAIT1"), _T("FIN_WAIT2"), _T("CLOSE_WAIT"), _T("CLOSING"), _T("LAST_ACK"), _T("TIME_WAIT"), _T("DELETE_TCB") };
-PLUGININFOEX pluginInfo={
+PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
PLUGINNAME,
__VERSION_DWORD,
@@ -51,7 +51,7 @@ PLUGININFOEX pluginInfo={ __AUTHORWEB,
UNICODE_AWARE, //not transient
// 4BB5B4AA-C364-4F23-9746-D5B708A286A5
- {0x4bb5b4aa, 0xc364, 0x4f23, { 0x97, 0x46, 0xd5, 0xb7, 0x8, 0xa2, 0x86, 0xa5 } }
+ { 0x4bb5b4aa, 0xc364, 0x4f23, { 0x97, 0x46, 0xd5, 0xb7, 0x8, 0xa2, 0x86, 0xa5 } }
};
extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_CONNECTIONNOTIFY, MIID_PROTOCOL, MIID_LAST };
@@ -61,14 +61,14 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_CONNEC //=========================================================================================
-BOOL strrep(TCHAR *src,TCHAR *needle,TCHAR *newstring)
+BOOL strrep(TCHAR *src, TCHAR *needle, TCHAR *newstring)
{
TCHAR *found, begining[MAX_SETTING_STR], tail[MAX_SETTING_STR];
size_t pos = 0;
//strset(begining, ' ');
//strset(tail, ' ');
- if (!(found=_tcsstr(src, needle)))
+ if (!(found = _tcsstr(src, needle)))
return FALSE;
pos = (found - src);
@@ -83,7 +83,7 @@ BOOL strrep(TCHAR *src,TCHAR *needle,TCHAR *newstring) return TRUE;
}
-extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
+extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD)
{
return &pluginInfo;
}
@@ -91,84 +91,85 @@ extern "C" __declspec(dllexport) const PLUGININFOEX* MirandaPluginInfoEx(DWORD m void saveSettingsConnections(struct CONNECTION *connHead)
{
char buff[128];
- int i=0;
- struct CONNECTION *tmp=connHead;
- while(tmp!=NULL)
+ int i = 0;
+ struct CONNECTION *tmp = connHead;
+ while (tmp != NULL)
{
- mir_snprintf(buff,SIZEOF(buff), "%dFilterIntIp", i);
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterIntIp", i);
db_set_ts(NULL, PLUGINNAME, buff, tmp->strIntIp);
- mir_snprintf(buff,SIZEOF(buff), "%dFilterExtIp", i);
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterExtIp", i);
db_set_ts(NULL, PLUGINNAME, buff, tmp->strExtIp);
- mir_snprintf(buff,SIZEOF(buff), "%dFilterPName", i);
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterPName", i);
db_set_ws(NULL, PLUGINNAME, buff, tmp->PName);
- mir_snprintf(buff,SIZEOF(buff), "%dFilterIntPort", i);
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterIntPort", i);
db_set_dw(NULL, PLUGINNAME, buff, tmp->intIntPort);
- mir_snprintf(buff,SIZEOF(buff), "%dFilterExtPort", i);
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterExtPort", i);
db_set_dw(NULL, PLUGINNAME, buff, tmp->intExtPort);
- mir_snprintf(buff,SIZEOF(buff), "%dFilterAction", i);
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterAction", i);
db_set_dw(NULL, PLUGINNAME, buff, tmp->Pid);
i++;
- tmp=tmp->next;
+ tmp = tmp->next;
}
- settingFiltersCount=i;
- db_set_dw(NULL, PLUGINNAME, "FiltersCount", settingFiltersCount );
-
+ settingFiltersCount = i;
+ db_set_dw(NULL, PLUGINNAME, "FiltersCount", settingFiltersCount);
+
}
+
//load filters from db
struct CONNECTION* LoadSettingsConnections()
{
- struct CONNECTION *connHead=NULL;
+ struct CONNECTION *connHead = NULL;
DBVARIANT dbv;
char buff[128];
- int i=0;
- for(i=settingFiltersCount-1;i>=0;i--)
+ int i = 0;
+ for (i = settingFiltersCount - 1; i >= 0; i--)
{
- struct CONNECTION *conn=(struct CONNECTION*)mir_alloc(sizeof(struct CONNECTION));
- mir_snprintf(buff,SIZEOF(buff), "%dFilterIntIp", i);
+ struct CONNECTION *conn = (struct CONNECTION*)mir_alloc(sizeof(struct CONNECTION));
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterIntIp", i);
if (!db_get_ts(NULL, PLUGINNAME, buff, &dbv))
- wcsncpy(conn->strIntIp,dbv.ptszVal,_countof(conn->strIntIp));
+ wcsncpy(conn->strIntIp, dbv.ptszVal, _countof(conn->strIntIp));
db_free(&dbv);
- mir_snprintf(buff,SIZEOF(buff), "%dFilterExtIp", i);
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterExtIp", i);
if (!db_get_ts(NULL, PLUGINNAME, buff, &dbv))
- wcsncpy(conn->strExtIp,dbv.ptszVal,_countof(conn->strExtIp));
+ wcsncpy(conn->strExtIp, dbv.ptszVal, _countof(conn->strExtIp));
db_free(&dbv);
- mir_snprintf(buff,SIZEOF(buff), "%dFilterPName", i);
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterPName", i);
if (!db_get_ts(NULL, PLUGINNAME, buff, &dbv))
- wcsncpy(conn->PName,dbv.ptszVal,_countof(conn->PName));
+ wcsncpy(conn->PName, dbv.ptszVal, _countof(conn->PName));
db_free(&dbv);
-
- mir_snprintf(buff,SIZEOF(buff), "%dFilterIntPort", i);
+
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterIntPort", i);
conn->intIntPort = db_get_dw(0, PLUGINNAME, buff, -1);
-
- mir_snprintf(buff,SIZEOF(buff), "%dFilterExtPort", i);
+
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterExtPort", i);
conn->intExtPort = db_get_dw(0, PLUGINNAME, buff, -1);
- mir_snprintf(buff,SIZEOF(buff), "%dFilterAction", i);
+ mir_snprintf(buff, SIZEOF(buff), "%dFilterAction", i);
conn->Pid = db_get_dw(0, PLUGINNAME, buff, 0);
conn->next = connHead;
- connHead=conn;
+ connHead = conn;
}
return connHead;
}
//called to load settings from database
void LoadSettings()
{
- settingInterval=(INT)db_get_dw(NULL, PLUGINNAME, "Interval", 500);
- settingInterval1=(INT)db_get_dw (NULL, PLUGINNAME, "PopupInterval", 0);
- settingResolveIp=db_get_b (NULL, PLUGINNAME, "ResolveIp",TRUE);
- settingDefaultAction=db_get_b (NULL, PLUGINNAME, "FilterDefaultAction",TRUE);
-
- settingSetColours=db_get_b (NULL, PLUGINNAME, "PopupSetColours",0);
+ settingInterval = (INT)db_get_dw(NULL, PLUGINNAME, "Interval", 500);
+ settingInterval1 = (INT)db_get_dw(NULL, PLUGINNAME, "PopupInterval", 0);
+ settingResolveIp = db_get_b(NULL, PLUGINNAME, "ResolveIp", TRUE);
+ settingDefaultAction = db_get_b(NULL, PLUGINNAME, "FilterDefaultAction", TRUE);
+
+ settingSetColours = db_get_b(NULL, PLUGINNAME, "PopupSetColours", 0);
settingBgColor = (COLORREF)db_get_dw(NULL, PLUGINNAME, "PopupBgColor", (DWORD)0xFFFFFF);
settingFgColor = (COLORREF)db_get_dw(NULL, PLUGINNAME, "PopupFgColor", (DWORD)0x000000);
- settingFiltersCount=(INT)db_get_dw (NULL, PLUGINNAME, "FiltersCount", 0);
- settingStatusMask=(WORD)db_get_w(NULL, PLUGINNAME, "StatusMask", 16);
- for(int i = 0; i < STATUS_COUNT; i++)
+ settingFiltersCount = (INT)db_get_dw(NULL, PLUGINNAME, "FiltersCount", 0);
+ settingStatusMask = (WORD)db_get_w(NULL, PLUGINNAME, "StatusMask", 16);
+ for (int i = 0; i < STATUS_COUNT; i++)
{
char buff[128];
- mir_snprintf(buff,SIZEOF(buff), "Status%d", i);
+ mir_snprintf(buff, SIZEOF(buff), "Status%d", i);
settingStatus[i] = (db_get_b(0, PLUGINNAME, buff, 0) == 1);
}
//lookupLotusDefaultSettings();
@@ -176,10 +177,10 @@ void LoadSettings() void fillExceptionsListView(HWND hwndDlg)
{
- LVITEM lvI={0};
+ LVITEM lvI = { 0 };
- int i=0;
- struct CONNECTION *tmp=connExceptionsTmp;
+ int i = 0;
+ struct CONNECTION *tmp = connExceptionsTmp;
HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS);
ListView_DeleteAllItems(hwndList);
@@ -187,104 +188,104 @@ void fillExceptionsListView(HWND hwndDlg) // Initialize LVITEM members that are common to all
// items.
lvI.mask = LVIF_TEXT;
- while(tmp)
+ while (tmp)
{
TCHAR tmpAddress[25];
- lvI.iItem=i++;
- lvI.iSubItem=0;
- lvI.pszText=tmp->PName;
+ lvI.iItem = i++;
+ lvI.iSubItem = 0;
+ lvI.pszText = tmp->PName;
ListView_InsertItem(hwndList, &lvI);
- lvI.iSubItem=1;
- if (tmp->intIntPort==-1)
+ lvI.iSubItem = 1;
+ if (tmp->intIntPort == -1)
mir_sntprintf(tmpAddress, SIZEOF(tmpAddress), _T("%s:*"), tmp->strIntIp);
else
mir_sntprintf(tmpAddress, SIZEOF(tmpAddress), _T("%s:%d"), tmp->strIntIp, tmp->intIntPort);
- lvI.pszText=tmpAddress;
+ lvI.pszText = tmpAddress;
ListView_SetItem(hwndList, &lvI);
- lvI.iSubItem=2;
- if (tmp->intExtPort==-1)
+ lvI.iSubItem = 2;
+ if (tmp->intExtPort == -1)
mir_sntprintf(tmpAddress, SIZEOF(tmpAddress), _T("%s:*"), tmp->strExtIp);
else
mir_sntprintf(tmpAddress, SIZEOF(tmpAddress), _T("%s:%d"), tmp->strExtIp, tmp->intExtPort);
- lvI.pszText=tmpAddress;
+ lvI.pszText = tmpAddress;
ListView_SetItem(hwndList, &lvI);
- lvI.iSubItem=3;
- lvI.pszText=tmp->Pid? LPGENT("Show"):LPGENT("Hide");
+ lvI.iSubItem = 3;
+ lvI.pszText = tmp->Pid ? LPGENT("Show") : LPGENT("Hide");
ListView_SetItem(hwndList, &lvI);
- tmp=tmp->next;
+ tmp = tmp->next;
}
-
+
}
//filter editor dialog box procedure opened modally from options dialog
static INT_PTR CALLBACK FilterEditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message)
+ switch (message)
{
- case WM_INITDIALOG:
- {
- struct CONNECTION *conn=(struct CONNECTION*)lParam;
- TranslateDialogDefault(hWnd);
- connCurrentEditModal=conn;
- SetDlgItemText(hWnd, ID_TEXT_NAME,conn->PName);
- SetDlgItemText(hWnd, ID_TXT_LOCAL_IP,conn->strIntIp);
- SetDlgItemText(hWnd, ID_TXT_REMOTE_IP,conn->strExtIp);
-
- if (conn->intIntPort==-1)
- SetDlgItemText(hWnd, ID_TXT_LOCAL_PORT,_T("*"));
- else
- SetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT,conn->intIntPort,FALSE);
+ case WM_INITDIALOG:
+ {
+ struct CONNECTION *conn = (struct CONNECTION*)lParam;
+ TranslateDialogDefault(hWnd);
+ connCurrentEditModal = conn;
+ SetDlgItemText(hWnd, ID_TEXT_NAME, conn->PName);
+ SetDlgItemText(hWnd, ID_TXT_LOCAL_IP, conn->strIntIp);
+ SetDlgItemText(hWnd, ID_TXT_REMOTE_IP, conn->strExtIp);
+
+ if (conn->intIntPort == -1)
+ SetDlgItemText(hWnd, ID_TXT_LOCAL_PORT, _T("*"));
+ else
+ SetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT, conn->intIntPort, FALSE);
+
+ if (conn->intExtPort == -1)
+ SetDlgItemText(hWnd, ID_TXT_REMOTE_PORT, _T("*"));
+ else
+ SetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT, conn->intExtPort, FALSE);
- if (conn->intExtPort==-1)
- SetDlgItemText(hWnd, ID_TXT_REMOTE_PORT,_T("*"));
+ SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Always show popup"));
+ SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Never show popup"));
+ SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_SETCURSEL, conn->Pid == 0 ? 1 : 0, 0);
+ return TRUE;
+ }
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case ID_OK:
+ {
+ TCHAR tmpPort[6];
+ GetDlgItemText(hWnd, ID_TXT_LOCAL_PORT, tmpPort, SIZEOF(tmpPort));
+ if (tmpPort[0] == '*')
+ connCurrentEditModal->intIntPort = -1;
else
- SetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT,conn->intExtPort,FALSE);
+ connCurrentEditModal->intIntPort = GetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT, NULL, FALSE);
+ GetDlgItemText(hWnd, ID_TXT_REMOTE_PORT, tmpPort, SIZEOF(tmpPort));
+ if (tmpPort[0] == '*')
+ connCurrentEditModal->intExtPort = -1;
+ else
+ connCurrentEditModal->intExtPort = GetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT, NULL, FALSE);
+
+ GetDlgItemText(hWnd, ID_TXT_LOCAL_IP, connCurrentEditModal->strIntIp, SIZEOF(connCurrentEditModal->strIntIp));
+ GetDlgItemText(hWnd, ID_TXT_REMOTE_IP, connCurrentEditModal->strExtIp, SIZEOF(connCurrentEditModal->strExtIp));
+ GetDlgItemText(hWnd, ID_TEXT_NAME, connCurrentEditModal->PName, SIZEOF(connCurrentEditModal->PName));
- SendDlgItemMessage(hWnd, ID_CBO_ACTION , CB_ADDSTRING, 0, (LPARAM)TranslateT("Always show popup"));
- SendDlgItemMessage(hWnd, ID_CBO_ACTION , CB_ADDSTRING, 0, (LPARAM)TranslateT("Never show popup"));
- SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_SETCURSEL ,conn->Pid==0?1:0,0);
+ connCurrentEditModal->Pid = !(BOOL)SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_GETCURSEL, 0, 0);
+
+ connCurrentEditModal = NULL;
+ EndDialog(hWnd, IDOK);
+ return TRUE;
+ }
+ case ID_CANCEL:
+ connCurrentEditModal = NULL;
+ EndDialog(hWnd, IDCANCEL);
return TRUE;
- }
- case WM_COMMAND:
- switch(LOWORD(wParam))
- {
- case ID_OK:
- {
- TCHAR tmpPort[6];
- GetDlgItemText(hWnd, ID_TXT_LOCAL_PORT, tmpPort, SIZEOF(tmpPort));
- if (tmpPort[0]=='*')
- connCurrentEditModal->intIntPort=-1;
- else
- connCurrentEditModal->intIntPort=GetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT, NULL, FALSE);
- GetDlgItemText(hWnd, ID_TXT_REMOTE_PORT, tmpPort, SIZEOF(tmpPort));
- if (tmpPort[0]=='*')
- connCurrentEditModal->intExtPort=-1;
- else
- connCurrentEditModal->intExtPort = GetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT, NULL, FALSE);
-
- GetDlgItemText(hWnd, ID_TXT_LOCAL_IP, connCurrentEditModal->strIntIp, SIZEOF(connCurrentEditModal->strIntIp));
- GetDlgItemText(hWnd, ID_TXT_REMOTE_IP, connCurrentEditModal->strExtIp, SIZEOF(connCurrentEditModal->strExtIp));
- GetDlgItemText(hWnd, ID_TEXT_NAME, connCurrentEditModal->PName, SIZEOF(connCurrentEditModal->PName));
-
- connCurrentEditModal->Pid = !(BOOL)SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_GETCURSEL, 0, 0);
-
- connCurrentEditModal=NULL;
- EndDialog(hWnd,IDOK);
- return TRUE;
- }
- case ID_CANCEL:
- connCurrentEditModal=NULL;
- EndDialog(hWnd,IDCANCEL);
- return TRUE;
- }
- return FALSE;
- break;
- case WM_CLOSE:
- {
- connCurrentEditModal=NULL;
- EndDialog(hWnd,IDCANCEL);
- break;
}
+ return FALSE;
+ break;
+ case WM_CLOSE:
+ {
+ connCurrentEditModal = NULL;
+ EndDialog(hWnd, IDCANCEL);
+ break;
+ }
}
return FALSE;
}
@@ -293,246 +294,245 @@ static INT_PTR CALLBACK FilterEditProc(HWND hWnd, UINT message, WPARAM wParam, L INT_PTR CALLBACK DlgProcConnectionNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
HWND hwndList;
- switch(msg) {
+ switch (msg) {
case WM_INITDIALOG://initialize dialog, so set properties from db.
- {
- LVCOLUMN lvc={0};
- LVITEM lvI={0};
- TCHAR buff[256];
- struct CONNECTION *tmp=connExceptions;
- bOptionsOpen=TRUE;
- TranslateDialogDefault(hwndDlg);//translate miranda function
+ {
+ LVCOLUMN lvc = { 0 };
+ LVITEM lvI = { 0 };
+ TCHAR buff[256];
+ bOptionsOpen = TRUE;
+ TranslateDialogDefault(hwndDlg);//translate miranda function
#ifdef _WIN64
- mir_sntprintf(buff,SIZEOF(buff),_T("%d.%d.%d.%d/64"), HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version)));
+ mir_sntprintf(buff,SIZEOF(buff),_T("%d.%d.%d.%d/64"), HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version)));
#else
- mir_sntprintf(buff,SIZEOF(buff),_T("%d.%d.%d.%d/32"), HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version)));
+ mir_sntprintf(buff, SIZEOF(buff), _T("%d.%d.%d.%d/32"), HIBYTE(HIWORD(pluginInfo.version)), LOBYTE(HIWORD(pluginInfo.version)), HIBYTE(LOWORD(pluginInfo.version)), LOBYTE(LOWORD(pluginInfo.version)));
#endif
- SetDlgItemText(hwndDlg, IDC_VERSION, buff);
- LoadSettings();
- //connExceptionsTmp=LoadSettingsConnections();
- SetDlgItemInt(hwndDlg, IDC_INTERVAL , settingInterval,FALSE);
- SetDlgItemInt(hwndDlg, IDC_INTERVAL1 , settingInterval1,TRUE);
- CheckDlgButton(hwndDlg, IDC_SETCOLOURS, settingSetColours ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_RESOLVEIP, settingResolveIp ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, ID_CHK_DEFAULTACTION, settingDefaultAction ? BST_CHECKED : BST_UNCHECKED);
-
- SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingBgColor);
- SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingFgColor);
- if (!settingSetColours) {
- HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR);
- CheckDlgButton(hwndDlg, IDC_SETCOLOURS, BST_UNCHECKED);
- EnableWindow(hwnd, FALSE);
- hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR);
- EnableWindow(hwnd, FALSE);
+ SetDlgItemText(hwndDlg, IDC_VERSION, buff);
+ LoadSettings();
+ //connExceptionsTmp=LoadSettingsConnections();
+ SetDlgItemInt(hwndDlg, IDC_INTERVAL, settingInterval, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_INTERVAL1, settingInterval1, TRUE);
+ CheckDlgButton(hwndDlg, IDC_SETCOLOURS, settingSetColours ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_RESOLVEIP, settingResolveIp ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, ID_CHK_DEFAULTACTION, settingDefaultAction ? BST_CHECKED : BST_UNCHECKED);
+
+ SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingBgColor);
+ SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingFgColor);
+ if (!settingSetColours) {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR);
+ CheckDlgButton(hwndDlg, IDC_SETCOLOURS, BST_UNCHECKED);
+ EnableWindow(hwnd, FALSE);
+ hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR);
+ EnableWindow(hwnd, FALSE);
+ }
+ SendDlgItemMessage(hwndDlg, ID_ADD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON6), IMAGE_ICON, 16, 16, 0));
+ SendDlgItemMessage(hwndDlg, ID_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON3), IMAGE_ICON, 16, 16, 0));
+ SendDlgItemMessage(hwndDlg, ID_DOWN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON4), IMAGE_ICON, 16, 16, 0));
+ SendDlgItemMessage(hwndDlg, ID_UP, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst, MAKEINTRESOURCE(IDI_ICON5), IMAGE_ICON, 16, 16, 0));
+ // initialise and fill listbox
+ hwndList = GetDlgItem(hwndDlg, IDC_STATUS);
+ ListView_DeleteAllItems(hwndList);
+ SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
+ // Initialize the LVCOLUMN structure.
+ // The mask specifies that the format, width, text, and
+ // subitem members of the structure are valid.
+ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ lvc.fmt = LVCFMT_LEFT;
+ lvc.iSubItem = 0;
+ lvc.pszText = TranslateT("Status");
+ lvc.cx = 120; // width of column in pixels
+ ListView_InsertColumn(hwndList, 0, &lvc);
+ // Some code to create the list-view control.
+ // Initialize LVITEM members that are common to all
+ // items.
+ lvI.mask = LVIF_TEXT;
+ for (int i = 0; i < STATUS_COUNT; i++) {
+ lvI.pszText = (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, ID_STATUS_ONLINE + i, GSMDF_TCHAR);
+ lvI.iItem = i;
+ ListView_InsertItem(hwndList, &lvI);
+ ListView_SetCheckState(hwndList, i, settingStatus[i]);
+ }
+
+ connExceptionsTmp = LoadSettingsConnections();
+ hwndList = GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS);
+ SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT);
+
+ lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
+ lvc.fmt = LVCFMT_LEFT;
+ lvc.iSubItem = 0;
+ lvc.cx = 120; // width of column in pixels
+ lvc.pszText = TranslateT("Application");
+ ListView_InsertColumn(hwndList, 1, &lvc);
+ lvc.pszText = TranslateT("Internal socket");
+ ListView_InsertColumn(hwndList, 2, &lvc);
+ lvc.pszText = TranslateT("External socket");
+ ListView_InsertColumn(hwndList, 3, &lvc);
+ lvc.pszText = TranslateT("Action");
+ lvc.cx = 50;
+ ListView_InsertColumn(hwndList, 4, &lvc);
+
+ //fill exceptions list
+ fillExceptionsListView(hwndDlg);
+ }
+ break;
+
+ case WM_COMMAND://user changed something, so get changes to variables
+ PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ switch (LOWORD(wParam)) {
+ case IDC_INTERVAL: settingInterval = GetDlgItemInt(hwndDlg, IDC_INTERVAL, NULL, FALSE); break;
+ case IDC_INTERVAL1: settingInterval1 = GetDlgItemInt(hwndDlg, IDC_INTERVAL1, NULL, TRUE); break;
+ case IDC_RESOLVEIP: settingResolveIp = (BYTE)IsDlgButtonChecked(hwndDlg, IDC_RESOLVEIP); break;
+ case ID_CHK_DEFAULTACTION: settingDefaultAction = (BYTE)IsDlgButtonChecked(hwndDlg, ID_CHK_DEFAULTACTION); break;
+ case ID_ADD:
+ {
+ struct CONNECTION *cur = (struct CONNECTION *)mir_alloc(sizeof(struct CONNECTION));
+ memset(cur, 0, sizeof(struct CONNECTION));
+ cur->intExtPort = -1;
+ cur->intIntPort = -1;
+ cur->Pid = 0;
+ cur->PName[0] = '*';
+ cur->strExtIp[0] = '*';
+ cur->strIntIp[0] = '*';
+
+ if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, FilterEditProc, (LPARAM)cur) == IDCANCEL) {
+ mir_free(cur);
+ cur = NULL;
}
- SendDlgItemMessage(hwndDlg, ID_ADD, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst,MAKEINTRESOURCE(IDI_ICON6),IMAGE_ICON,16,16,0));
- SendDlgItemMessage(hwndDlg, ID_DELETE, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst,MAKEINTRESOURCE(IDI_ICON3),IMAGE_ICON,16,16,0));
- SendDlgItemMessage(hwndDlg, ID_DOWN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst,MAKEINTRESOURCE(IDI_ICON4),IMAGE_ICON,16,16,0));
- SendDlgItemMessage(hwndDlg, ID_UP, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(hInst,MAKEINTRESOURCE(IDI_ICON5),IMAGE_ICON,16,16,0));
- // initialise and fill listbox
- hwndList = GetDlgItem(hwndDlg, IDC_STATUS);
- ListView_DeleteAllItems(hwndList);
- SendMessage(hwndList,LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
- // Initialize the LVCOLUMN structure.
- // The mask specifies that the format, width, text, and
- // subitem members of the structure are valid.
- lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
- lvc.fmt = LVCFMT_LEFT;
- lvc.iSubItem = 0;
- lvc.pszText = TranslateT("Status");
- lvc.cx = 120; // width of column in pixels
- ListView_InsertColumn(hwndList, 0, &lvc);
- // Some code to create the list-view control.
- // Initialize LVITEM members that are common to all
- // items.
- lvI.mask = LVIF_TEXT;
- for(int i = 0; i < STATUS_COUNT; i++) {
- lvI.pszText = (TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, ID_STATUS_ONLINE+i, GSMDF_TCHAR);
- lvI.iItem = i;
- ListView_InsertItem(hwndList, &lvI);
- ListView_SetCheckState(hwndList, i, settingStatus[i]);
+ else {
+ cur->next = connExceptionsTmp;
+ connExceptionsTmp = cur;
}
- connExceptionsTmp=LoadSettingsConnections();
- hwndList = GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS);
- SendMessage(hwndList,LVM_SETEXTENDEDLISTVIEWSTYLE, 0,LVS_EX_FULLROWSELECT);
-
- lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
- lvc.fmt = LVCFMT_LEFT;
- lvc.iSubItem = 0;
- lvc.cx = 120; // width of column in pixels
- lvc.pszText = TranslateT("Application");
- ListView_InsertColumn(hwndList, 1, &lvc);
- lvc.pszText = TranslateT("Internal socket");
- ListView_InsertColumn(hwndList, 2, &lvc);
- lvc.pszText = TranslateT("External socket");
- ListView_InsertColumn(hwndList, 3, &lvc);
- lvc.pszText = TranslateT("Action");
- lvc.cx = 50;
- ListView_InsertColumn(hwndList, 4, &lvc);
-
- //fill exceptions list
fillExceptionsListView(hwndDlg);
+ ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), 0, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
+ SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
}
break;
- case WM_COMMAND://user changed something, so get changes to variables
- PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- switch(LOWORD(wParam)) {
- case IDC_INTERVAL: settingInterval =GetDlgItemInt(hwndDlg, IDC_INTERVAL, NULL, FALSE); break;
- case IDC_INTERVAL1: settingInterval1 =GetDlgItemInt(hwndDlg, IDC_INTERVAL1, NULL, TRUE); break;
- case IDC_RESOLVEIP: settingResolveIp=(BYTE) IsDlgButtonChecked(hwndDlg, IDC_RESOLVEIP); break;
- case ID_CHK_DEFAULTACTION: settingDefaultAction=(BYTE) IsDlgButtonChecked(hwndDlg, ID_CHK_DEFAULTACTION); break;
- case ID_ADD:
- {
- struct CONNECTION *cur=(struct CONNECTION *)mir_alloc(sizeof(struct CONNECTION));
- memset(cur,0,sizeof(struct CONNECTION));
- cur->intExtPort=-1;
- cur->intIntPort=-1;
- cur->Pid=0;
- cur->PName[0]='*';
- cur->strExtIp[0]='*';
- cur->strIntIp[0]='*';
-
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, FilterEditProc, (LPARAM)cur)==IDCANCEL) {
- mir_free(cur);
- cur = NULL;
- }
- else {
- cur->next = connExceptionsTmp;
- connExceptionsTmp = cur;
- }
+ case ID_DELETE:
+ {
+ int pos, pos1;
+ struct CONNECTION *cur = connExceptionsTmp, *pre = NULL;
- fillExceptionsListView(hwndDlg);
- ListView_SetItemState(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS),0,LVNI_FOCUSED|LVIS_SELECTED , LVNI_FOCUSED|LVIS_SELECTED );
- SetFocus(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS));
+ pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
+ if (pos == -1)break;
+ pos1 = pos;
+ while (pos--)
+ {
+ pre = cur;
+ cur = cur->next;
}
+ if (pre == NULL)
+ connExceptionsTmp = connExceptionsTmp->next;
+ else
+ (pre)->next = cur->next;
+ mir_free(cur);
+ fillExceptionsListView(hwndDlg);
+ ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
+ SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
break;
+ }
+ case ID_UP:
+ {
+ int pos, pos1;
+ struct CONNECTION *cur = NULL, *pre = NULL, *prepre = NULL;
- case ID_DELETE:
- {
- int pos,pos1;
- struct CONNECTION *cur = connExceptionsTmp, *pre = NULL;
+ cur = connExceptionsTmp;
- pos=(int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS),-1,LVNI_FOCUSED );
- if (pos==-1)break;
- pos1=pos;
- while(pos--)
- {
- pre=cur;
- cur=cur->next;
- }
- if (pre==NULL)
- connExceptionsTmp=connExceptionsTmp->next;
- else
- (pre)->next=cur->next;
- mir_free(cur);
- fillExceptionsListView(hwndDlg);
- ListView_SetItemState(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS),pos1,LVNI_FOCUSED|LVIS_SELECTED , LVNI_FOCUSED|LVIS_SELECTED );
- SetFocus(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS));
- break;
+ pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
+ if (pos == -1)break;
+ pos1 = pos;
+ while (pos--)
+ {
+ prepre = pre;
+ pre = cur;
+ cur = cur->next;
}
- case ID_UP:
+ if (prepre != NULL)
{
- int pos,pos1;
- struct CONNECTION *cur=NULL,*pre=NULL,*prepre=NULL;
-
- cur=connExceptionsTmp;
-
- pos=(int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS),-1,LVNI_FOCUSED );
- if (pos==-1)break;
- pos1=pos;
- while(pos--)
- {
- prepre=pre;
- pre=cur;
- cur=cur->next;
- }
- if (prepre!=NULL)
- {
- pre->next=cur->next;
- cur->next=pre;
- prepre->next=cur;
- }
- else if (pre!=NULL)
- {
- pre->next=cur->next;
- cur->next=pre;
- connExceptionsTmp=cur;
- }
- fillExceptionsListView(hwndDlg);
- ListView_SetItemState(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS),pos1-1,LVNI_FOCUSED|LVIS_SELECTED , LVNI_FOCUSED|LVIS_SELECTED );
- SetFocus(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS));
- break;
+ pre->next = cur->next;
+ cur->next = pre;
+ prepre->next = cur;
}
- case ID_DOWN:
+ else if (pre != NULL)
{
- int pos,pos1;
- struct CONNECTION *cur=NULL,*pre=NULL;
+ pre->next = cur->next;
+ cur->next = pre;
+ connExceptionsTmp = cur;
+ }
+ fillExceptionsListView(hwndDlg);
+ ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1 - 1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
+ SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
+ break;
+ }
+ case ID_DOWN:
+ {
+ int pos, pos1;
+ struct CONNECTION *cur = NULL, *pre = NULL;
- cur=connExceptionsTmp;
+ cur = connExceptionsTmp;
- pos=(int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS),-1,LVNI_FOCUSED );
- if (pos==-1)break;
- pos1=pos;
- while(pos--)
- {
- pre=cur;
- cur=cur->next;
- }
- if (cur==connExceptionsTmp&&cur->next!=NULL)
- {
- connExceptionsTmp=cur->next;
- cur->next=cur->next->next;
- connExceptionsTmp->next=cur;
- }
- else if (cur->next!=NULL)
- {
- struct CONNECTION *tmp=cur->next->next;
- pre->next=cur->next;
- cur->next->next=cur;
- cur->next=tmp;
- }
- fillExceptionsListView(hwndDlg);
- ListView_SetItemState(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS),pos1+1,LVNI_FOCUSED|LVIS_SELECTED , LVNI_FOCUSED|LVIS_SELECTED );
- SetFocus(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS));
- break;
- }
- case IDC_SETCOLOURS:
+ pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
+ if (pos == -1)break;
+ pos1 = pos;
+ while (pos--)
{
- HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR);
- settingSetColours=IsDlgButtonChecked(hwndDlg, IDC_SETCOLOURS);
- EnableWindow(hwnd,settingSetColours );
- hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR);
- EnableWindow(hwnd, settingSetColours);
- break;
+ pre = cur;
+ cur = cur->next;
+ }
+ if (cur == connExceptionsTmp&&cur->next != NULL)
+ {
+ connExceptionsTmp = cur->next;
+ cur->next = cur->next->next;
+ connExceptionsTmp->next = cur;
}
- case IDC_BGCOLOR: settingBgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0);break;
- case IDC_FGCOLOR: settingFgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_GETCOLOUR, 0, 0);break;
+ else if (cur->next != NULL)
+ {
+ struct CONNECTION *tmp = cur->next->next;
+ pre->next = cur->next;
+ cur->next->next = cur;
+ cur->next = tmp;
+ }
+ fillExceptionsListView(hwndDlg);
+ ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1 + 1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
+ SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
+ break;
+ }
+ case IDC_SETCOLOURS:
+ {
+ HWND hwnd = GetDlgItem(hwndDlg, IDC_BGCOLOR);
+ settingSetColours = IsDlgButtonChecked(hwndDlg, IDC_SETCOLOURS);
+ EnableWindow(hwnd, settingSetColours);
+ hwnd = GetDlgItem(hwndDlg, IDC_FGCOLOR);
+ EnableWindow(hwnd, settingSetColours);
+ break;
+ }
+ case IDC_BGCOLOR: settingBgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0); break;
+ case IDC_FGCOLOR: settingFgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_GETCOLOUR, 0, 0); break;
}
break;
case WM_NOTIFY://apply changes so write it to db
- switch(((LPNMHDR)lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_RESET:
LoadSettings();
deleteConnectionsTable(connExceptionsTmp);
- connExceptionsTmp=LoadSettingsConnections();
+ connExceptionsTmp = LoadSettingsConnections();
return TRUE;
case PSN_APPLY:
- db_set_dw (NULL, PLUGINNAME, "Interval", settingInterval );
- db_set_dw (NULL, PLUGINNAME, "PopupInterval", settingInterval1 );
+ db_set_dw(NULL, PLUGINNAME, "Interval", settingInterval);
+ db_set_dw(NULL, PLUGINNAME, "PopupInterval", settingInterval1);
db_set_b(NULL, PLUGINNAME, "PopupSetColours", settingSetColours);
db_set_dw(NULL, PLUGINNAME, "PopupBgColor", (DWORD)settingBgColor);
db_set_dw(NULL, PLUGINNAME, "PopupFgColor", (DWORD)settingFgColor);
db_set_b(NULL, PLUGINNAME, "ResolveIp", settingResolveIp);
db_set_b(NULL, PLUGINNAME, "FilterDefaultAction", settingDefaultAction);
- for(int i = 0; i < STATUS_COUNT ; i++) {
+ for (int i = 0; i < STATUS_COUNT; i++) {
char buff[128];
mir_snprintf(buff, SIZEOF(buff), "Status%d", i);
settingStatus[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_STATUS), i) ? TRUE : FALSE);
@@ -550,135 +550,135 @@ INT_PTR CALLBACK DlgProcConnectionNotifyOpts(HWND hwndDlg, UINT msg, WPARAM wPar break;
}
- if (GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS)==((LPNMHDR) lParam)->hwndFrom) {
- switch (((LPNMHDR) lParam)->code) {
+ if (GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS) == ((LPNMHDR)lParam)->hwndFrom) {
+ switch (((LPNMHDR)lParam)->code) {
case NM_DBLCLK:
- {
- int pos,pos1;
- struct CONNECTION *cur=NULL;
+ {
+ int pos, pos1;
+ struct CONNECTION *cur = NULL;
- cur=connExceptionsTmp;
+ cur = connExceptionsTmp;
- pos=(int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS),-1,LVNI_FOCUSED );
- if (pos==-1)break;
- pos1=pos;
- while(pos--)
- {
- cur=cur->next;
- }
- DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, FilterEditProc, (LPARAM)cur);
- fillExceptionsListView(hwndDlg);
- ListView_SetItemState(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS),pos1,LVNI_FOCUSED|LVIS_SELECTED , LVNI_FOCUSED|LVIS_SELECTED );
- SetFocus(GetDlgItem(hwndDlg,IDC_LIST_EXCEPTIONS));
- break;
+ pos = (int)ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), -1, LVNI_FOCUSED);
+ if (pos == -1)break;
+ pos1 = pos;
+ while (pos--)
+ {
+ cur = cur->next;
}
+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), hwndDlg, FilterEditProc, (LPARAM)cur);
+ fillExceptionsListView(hwndDlg);
+ ListView_SetItemState(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS), pos1, LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
+ SetFocus(GetDlgItem(hwndDlg, IDC_LIST_EXCEPTIONS));
+ break;
+ }
}
}
- if (GetDlgItem(hwndDlg, IDC_STATUS) == ((LPNMHDR) lParam)->hwndFrom) {
- switch (((LPNMHDR) lParam)->code) {
+ if (GetDlgItem(hwndDlg, IDC_STATUS) == ((LPNMHDR)lParam)->hwndFrom) {
+ switch (((LPNMHDR)lParam)->code) {
case LVN_ITEMCHANGED:
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK)
- SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 );
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
}
break;
case WM_DESTROY:
- bOptionsOpen=FALSE;
+ bOptionsOpen = FALSE;
deleteConnectionsTable(connExceptionsTmp);
- connExceptionsTmp=NULL;
+ connExceptionsTmp = NULL;
return TRUE;
}
return 0;
}
//options page on miranda called
-int ConnectionNotifyOptInit(WPARAM wParam,LPARAM)
+int ConnectionNotifyOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
odp.hInstance = hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_DIALOG);
odp.ptszTitle = _T(PLUGINNAME);
odp.ptszGroup = LPGENT("Plugins");
- odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR;
odp.pfnDlgProc = DlgProcConnectionNotifyOpts;//callback function name
Options_AddPage(wParam, &odp);
return 0;
}
//gives protocol avainable statuses
-INT_PTR GetCaps(WPARAM wParam,LPARAM lParam)
+INT_PTR GetCaps(WPARAM wParam, LPARAM)
{
- if (wParam==PFLAGNUM_1)
+ if (wParam == PFLAGNUM_1)
return 0;
- if (wParam==PFLAGNUM_2)
+ if (wParam == PFLAGNUM_2)
return PF2_ONLINE; // add the possible statuses here.
- if (wParam==PFLAGNUM_3)
+ if (wParam == PFLAGNUM_3)
return 0;
return 0;
}
//gives name to protocol module
-INT_PTR GetName(WPARAM wParam,LPARAM lParam)
+INT_PTR GetName(WPARAM wParam, LPARAM lParam)
{
- mir_strncpy((char*)lParam,PLUGINNAME,wParam);
+ mir_strncpy((char*)lParam, PLUGINNAME, wParam);
return 0;
}
//gives icon for proto module
-INT_PTR TMLoadIcon(WPARAM wParam,LPARAM lParam)
+INT_PTR TMLoadIcon(WPARAM wParam, LPARAM)
{
UINT id;
- switch(wParam & 0xFFFF) {
- case PLI_ONLINE:
- case PLI_PROTOCOL: id=IDI_ICON1; break; // IDI_TM is the main icon for the protocol
- case PLI_OFFLINE: id=IDI_ICON2; break;
- default: return 0;
+ switch (wParam & 0xFFFF) {
+ case PLI_ONLINE:
+ case PLI_PROTOCOL: id = IDI_ICON1; break; // IDI_TM is the main icon for the protocol
+ case PLI_OFFLINE: id = IDI_ICON2; break;
+ default: return 0;
}
- return (INT_PTR)LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON, GetSystemMetrics(wParam&PLIF_SMALL?SM_CXSMICON:SM_CXICON), GetSystemMetrics(wParam&PLIF_SMALL?SM_CYSMICON:SM_CYICON), 0);
+ return (INT_PTR)LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON, GetSystemMetrics(wParam&PLIF_SMALL ? SM_CXSMICON : SM_CXICON), GetSystemMetrics(wParam&PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0);
}
//=======================================================
//SetStatus
//=======================================================
-INT_PTR SetStatus(WPARAM wParam,LPARAM lParam)
+INT_PTR SetStatus(WPARAM wParam, LPARAM lParam)
{
if (wParam == ID_STATUS_OFFLINE)
{
- diffstat=0;
+ diffstat = 0;
//PostThreadMessage(ConnectionCheckThreadId,WM_QUIT ,0, 0);
SetEvent(killCheckThreadEvent);
}
else if (wParam == ID_STATUS_ONLINE)
{
- diffstat=0;
+ diffstat = 0;
ResetEvent(killCheckThreadEvent);
if (!hConnectionCheckThread)
hConnectionCheckThread = (HANDLE)mir_forkthreadex(checkthread, 0, (unsigned int*)&ConnectionCheckThreadId);
}
else
{
- int retv=0;
-
+ int retv = 0;
+
if (settingStatus[wParam - ID_STATUS_ONLINE])
- retv= SetStatus(ID_STATUS_OFFLINE,lParam);
+ retv = SetStatus(ID_STATUS_OFFLINE, lParam);
else
- retv= SetStatus(ID_STATUS_ONLINE,lParam);
+ retv = SetStatus(ID_STATUS_ONLINE, lParam);
//LNEnableMenuItem(hMenuHandle ,TRUE);
- diffstat=wParam;
+ diffstat = wParam;
return retv;
// the status has been changed to unknown (maybe run some more code)
}
//broadcast the message
-
+
//oldStatus = currentStatus;
- if (currentStatus!=wParam)
- ProtoBroadcastAck(PLUGINNAME,NULL,ACKTYPE_STATUS,ACKRESULT_SUCCESS,(HANDLE)currentStatus,wParam);
+ if (currentStatus != (int)wParam)
+ ProtoBroadcastAck(PLUGINNAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)currentStatus, wParam);
currentStatus = wParam;
return 0;
@@ -686,80 +686,75 @@ INT_PTR SetStatus(WPARAM wParam,LPARAM lParam) //=======================================================
//GetStatus
//=======================================================
-INT_PTR GetStatus(WPARAM,LPARAM)
+INT_PTR GetStatus(WPARAM, LPARAM)
{
return currentStatus;
- if (diffstat )
- return diffstat;
- else
- return currentStatus ;
-
}
//thread function with connections check loop
-static unsigned __stdcall checkthread(void *dummy)
+static unsigned __stdcall checkthread(void *)
{
#ifdef _DEBUG
_OutputDebugString(_T("check thread started"));
#endif
- while(1)
+ while (1)
{
- struct CONNECTION* conn=NULL,*connOld=first,*cur=NULL;
+ struct CONNECTION* conn = NULL, *connOld = first, *cur = NULL;
#ifdef _DEBUG
_OutputDebugString(_T("checking connections table..."));
#endif
- if (WAIT_OBJECT_0 == WaitForSingleObject(killCheckThreadEvent,100))
+ if (WAIT_OBJECT_0 == WaitForSingleObject(killCheckThreadEvent, 100))
{
- hConnectionCheckThread=NULL;
+ hConnectionCheckThread = NULL;
return 0;
}
- conn=GetConnectionsTable();
- cur=conn;
- while(cur!=NULL) {
- if (searchConnection(first,cur->strIntIp,cur->strExtIp,cur->intIntPort,cur->intExtPort,cur->state)==NULL && (settingStatusMask & (1 << (cur->state-1)))) {
+ conn = GetConnectionsTable();
+ cur = conn;
+ while (cur != NULL) {
+ if (searchConnection(first, cur->strIntIp, cur->strExtIp, cur->intIntPort, cur->intExtPort, cur->state) == NULL && (settingStatusMask & (1 << (cur->state - 1)))) {
#ifdef _DEBUG
TCHAR msg[1024];
mir_sntprintf(msg, SIZEOF(msg), _T("%s:%d\n%s:%d"), cur->strIntIp, cur->intIntPort, cur->strExtIp, cur->intExtPort);
- _OutputDebugString(_T("New connection: %s"),msg);
+ _OutputDebugString(_T("New connection: %s"), msg);
#endif
pid2name(cur->Pid, cur->PName, SIZEOF(cur->PName));
- if ( WAIT_OBJECT_0 == WaitForSingleObject( hExceptionsMutex, 100 ))
+ if (WAIT_OBJECT_0 == WaitForSingleObject(hExceptionsMutex, 100))
{
- if (checkFilter(connExceptions,cur))
+ if (checkFilter(connExceptions, cur))
{
- showMsg(cur->PName,cur->Pid,cur->strIntIp,cur->strExtIp,cur->intIntPort,cur->intExtPort,cur->state);
+ showMsg(cur->PName, cur->Pid, cur->strIntIp, cur->strExtIp, cur->intIntPort, cur->intExtPort, cur->state);
SkinPlaySound(PLUGINNAME_NEWSOUND);
}
ReleaseMutex(hExceptionsMutex);
}
}
- cur=cur->next;
+ cur = cur->next;
}
- first=conn;
+ first = conn;
deleteConnectionsTable(connOld);
Sleep(settingInterval);
}
- hConnectionCheckThread=NULL;
+ hConnectionCheckThread = NULL;
return 1;
}
//popup reactions
static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message) {
+ switch (message) {
case WM_COMMAND:
if (HIWORD(wParam) == STN_CLICKED)//client clicked on popup with left mouse button
{
struct CONNECTION *conn = (struct CONNECTION*)mir_alloc(sizeof(struct CONNECTION));
- struct CONNECTION *mpd=(struct CONNECTION*) PUGetPluginData(hWnd);
+ struct CONNECTION *mpd = (struct CONNECTION*) PUGetPluginData(hWnd);
- memcpy(conn,mpd,sizeof(struct CONNECTION));
+ memcpy(conn, mpd, sizeof(struct CONNECTION));
PUDeletePopup(hWnd);
- PostThreadMessage(FilterOptionsThreadId,WM_ADD_FILTER,0, (LPARAM)conn);
+ PostThreadMessage(FilterOptionsThreadId, WM_ADD_FILTER, 0, (LPARAM)conn);
}
break;
@@ -774,7 +769,7 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA //PUDeletePopUp(hWnd);
break;
- case UM_FREEPLUGINDATA:
+ case UM_FREEPLUGINDATA:
struct CONNECTION *mpd = (struct CONNECTION*)PUGetPluginData(hWnd);
if (mpd > 0) mir_free(mpd);
return TRUE; //TRUE or FALSE is the same, it gets ignored.
@@ -784,7 +779,7 @@ static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPA //show popup
-void showMsg(TCHAR *pName, DWORD pid,TCHAR *intIp,TCHAR *extIp,int intPort,int extPort,int state)
+void showMsg(TCHAR *pName, DWORD pid, TCHAR *intIp, TCHAR *extIp, int intPort, int extPort, int state)
{
POPUPDATAT ppd;
@@ -808,10 +803,10 @@ void showMsg(TCHAR *pName, DWORD pid,TCHAR *intIp,TCHAR *extIp,int intPort,int e }
else mir_sntprintf(ppd.lptzText, SIZEOF(ppd.lptzText), _T("%s:%d\n%s:%d"), extIp, extPort, intIp, intPort);
- mir_sntprintf(ppd.lptzContactName, SIZEOF(ppd.lptzContactName), _T("%s (%s)"), pName, tcpStates[state-1]);
+ mir_sntprintf(ppd.lptzContactName, SIZEOF(ppd.lptzContactName), _T("%s (%s)"), pName, tcpStates[state - 1]);
if (settingSetColours) {
- ppd.colorBack = settingBgColor;
+ ppd.colorBack = settingBgColor;
ppd.colorText = settingFgColor;
}
ppd.PluginWindowProc = PopupDlgProc;
@@ -834,81 +829,81 @@ void showMsg(TCHAR *pName, DWORD pid,TCHAR *intIp,TCHAR *extIp,int intPort,int e //called after all plugins loaded.
//all Connection staff will be called, that will not hang miranda on startup
-static int modulesloaded(WPARAM,LPARAM)
+static int modulesloaded(WPARAM, LPARAM)
{
-
+
#ifdef _DEBUG
_OutputDebugString(_T("Modules loaded, lets start TN..."));
#endif
-// hConnectionCheckThread = (HANDLE)mir_forkthreadex(checkthread, 0, 0, ConnectionCheckThreadId);
+ // hConnectionCheckThread = (HANDLE)mir_forkthreadex(checkthread, 0, 0, ConnectionCheckThreadId);
-//#ifdef _DEBUG
-// _OutputDebugString("started check thread %d",hConnectionCheckThread);
-//#endif
- killCheckThreadEvent=CreateEvent(NULL,FALSE,FALSE,_T("killCheckThreadEvent"));
- hFilterOptionsThread=startFilterThread();
+ //#ifdef _DEBUG
+ // _OutputDebugString("started check thread %d",hConnectionCheckThread);
+ //#endif
+ killCheckThreadEvent = CreateEvent(NULL, FALSE, FALSE, _T("killCheckThreadEvent"));
+ hFilterOptionsThread = startFilterThread();
//updaterRegister();
-
+
return 0;
}
//function hooks before unload
-static int preshutdown(WPARAM,LPARAM)
+static int preshutdown(WPARAM, LPARAM)
{
deleteConnectionsTable(first);
deleteConnectionsTable(connExceptions);
deleteConnectionsTable(connExceptionsTmp);
- PostThreadMessage(ConnectionCheckThreadId,WM_QUIT ,0, 0);
- PostThreadMessage(FilterOptionsThreadId,WM_QUIT ,0, 0);
-
+ PostThreadMessage(ConnectionCheckThreadId, WM_QUIT, 0, 0);
+ PostThreadMessage(FilterOptionsThreadId, WM_QUIT, 0, 0);
+
return 0;
}
-extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
+extern "C" BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID)
{
- hInst=hinstDLL;
+ hInst = hinstDLL;
return TRUE;
}
extern "C" int __declspec(dllexport) Load(void)
{
- char service[100]={""};
+ char service[100] = { "" };
- PROTOCOLDESCRIPTOR pd={ PROTOCOLDESCRIPTOR_V3_SIZE };
+ PROTOCOLDESCRIPTOR pd = { PROTOCOLDESCRIPTOR_V3_SIZE };
#ifdef _DEBUG
_OutputDebugString(_T("Entering Load dll"));
#endif
- mir_getLP( &pluginInfo );
+ mir_getLP(&pluginInfo);
//hCurrentEditMutex=CreateMutex(NULL,FALSE,_T("CurrentEditMutex"));
- hExceptionsMutex=CreateMutex(NULL,FALSE,_T("ExceptionsMutex"));
+ hExceptionsMutex = CreateMutex(NULL, FALSE, _T("ExceptionsMutex"));
LoadSettings();
- connExceptions=LoadSettingsConnections();
-//create protocol
+ connExceptions = LoadSettingsConnections();
+ //create protocol
//memset(&pd, 0, sizeof(pd));
//pd.cbSize=sizeof(pd);
- pd.szName=PLUGINNAME;
- pd.type=PROTOTYPE_PROTOCOL;
- CallService(MS_PROTO_REGISTERMODULE,0,(LPARAM)&pd);
+ pd.szName = PLUGINNAME;
+ pd.type = PROTOTYPE_PROTOCOL;
+ CallService(MS_PROTO_REGISTERMODULE, 0, (LPARAM)&pd);
//set all contacts to offline
- for (MCONTACT hContact = db_find_first(PLUGINNAME); hContact != NULL; hContact = db_find_next(hContact,PLUGINNAME))
- db_set_w(hContact,PLUGINNAME,"status",ID_STATUS_OFFLINE);
+ for (MCONTACT hContact = db_find_first(PLUGINNAME); hContact != NULL; hContact = db_find_next(hContact, PLUGINNAME))
+ db_set_w(hContact, PLUGINNAME, "status", ID_STATUS_OFFLINE);
- mir_snprintf(service,SIZEOF(service), "%s%s", PLUGINNAME, PS_GETCAPS);
+ mir_snprintf(service, SIZEOF(service), "%s%s", PLUGINNAME, PS_GETCAPS);
CreateServiceFunction(service, GetCaps);
- mir_snprintf(service,SIZEOF(service), "%s%s", PLUGINNAME, PS_GETNAME);
+ mir_snprintf(service, SIZEOF(service), "%s%s", PLUGINNAME, PS_GETNAME);
CreateServiceFunction(service, GetName);
- mir_snprintf(service,SIZEOF(service), "%s%s", PLUGINNAME, PS_LOADICON);
+ mir_snprintf(service, SIZEOF(service), "%s%s", PLUGINNAME, PS_LOADICON);
CreateServiceFunction(service, TMLoadIcon);
- mir_snprintf(service,SIZEOF(service), "%s%s", PLUGINNAME, PS_SETSTATUS);
+ mir_snprintf(service, SIZEOF(service), "%s%s", PLUGINNAME, PS_SETSTATUS);
CreateServiceFunction(service, SetStatus);
- mir_snprintf(service,SIZEOF(service), "%s%s", PLUGINNAME, PS_GETSTATUS);
+ mir_snprintf(service, SIZEOF(service), "%s%s", PLUGINNAME, PS_GETSTATUS);
CreateServiceFunction(service, GetStatus);
- SkinAddNewSoundEx(PLUGINNAME_NEWSOUND,PLUGINNAME, LPGEN("New Connection Notification"));
+ SkinAddNewSoundEx(PLUGINNAME_NEWSOUND, PLUGINNAME, LPGEN("New Connection Notification"));
hOptInit = HookEvent(ME_OPT_INITIALISE, ConnectionNotifyOptInit);//register service to hook option call
assert(hOptInit);
hHookModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, modulesloaded);//hook event that all plugins are loaded
@@ -920,7 +915,7 @@ extern "C" int __declspec(dllexport) Load(void) extern "C" int __declspec(dllexport) Unload(void)
{
WaitForSingleObjectEx(hConnectionCheckThread, INFINITE, FALSE);
- if (hConnectionCheckThread )CloseHandle(hConnectionCheckThread);
+ if (hConnectionCheckThread)CloseHandle(hConnectionCheckThread);
if (hCheckEvent)DestroyHookableEvent(hCheckEvent);
if (hOptInit) UnhookEvent(hOptInit);
if (hCheckHook)UnhookEvent(hCheckHook);
diff --git a/plugins/ConnectionNotify/src/debug.cpp b/plugins/ConnectionNotify/src/debug.cpp index 2af13f218c..d20d46f314 100644 --- a/plugins/ConnectionNotify/src/debug.cpp +++ b/plugins/ConnectionNotify/src/debug.cpp @@ -1,17 +1,17 @@ -#include "ConnectionNotify.h"
+#include "stdafx.h"
-void _OutputDebugString(TCHAR* lpOutputString, ... )
+void _OutputDebugString(TCHAR* lpOutputString, ...)
{
TCHAR OutMsg[MAX_LENGTH];
TCHAR format[MAX_LENGTH];
- int i,j;
- va_list argptr;
+ int i, j;
+ va_list argptr;
- va_start( argptr, lpOutputString );
+ va_start(argptr, lpOutputString);
- for(i=0,j=0;lpOutputString[i] != '\0';i++)
+ for (i = 0, j = 0; lpOutputString[i] != '\0'; i++)
{
format[j++] = lpOutputString[i];
format[j] = '\0';
@@ -21,44 +21,44 @@ void _OutputDebugString(TCHAR* lpOutputString, ... ) format[j++] = lpOutputString[++i];
format[j] = '\0';
- switch(lpOutputString[i])
+ switch (lpOutputString[i])
{
// string
case 's':
- {
- TCHAR* s = va_arg( argptr, TCHAR * );
- mir_sntprintf(OutMsg, SIZEOF(OutMsg), format, s);
- _tcsncpy(format,OutMsg,_countof(OutMsg));
- j = (int)_tcslen(format);
- _tcscat(format,_T(" "));
- break;
- }
- // character
+ {
+ TCHAR* s = va_arg(argptr, TCHAR *);
+ mir_sntprintf(OutMsg, SIZEOF(OutMsg), format, s);
+ _tcsncpy(format, OutMsg, _countof(OutMsg));
+ j = (int)_tcslen(format);
+ _tcscat(format, _T(" "));
+ break;
+ }
+ // character
case 'c':
- {
- char c = (char) va_arg( argptr, int );
- mir_sntprintf(OutMsg, SIZEOF(OutMsg), format, c);
- _tcsncpy(format,OutMsg,_countof(OutMsg));
- j = (int)_tcslen(format);
- _tcscat(format,_T(" "));
- break;
- }
- // integer
+ {
+ char c = (char)va_arg(argptr, int);
+ mir_sntprintf(OutMsg, SIZEOF(OutMsg), format, c);
+ _tcsncpy(format, OutMsg, _countof(OutMsg));
+ j = (int)_tcslen(format);
+ _tcscat(format, _T(" "));
+ break;
+ }
+ // integer
case 'd':
- {
- int d = va_arg( argptr, int );
- mir_sntprintf(OutMsg, SIZEOF(OutMsg), format, d);
- _tcsncpy(format,OutMsg,_countof(OutMsg));
- j = (int)_tcslen(format);
- _tcscat(format,_T(" "));
- break;
- }
+ {
+ int d = va_arg(argptr, int);
+ mir_sntprintf(OutMsg, SIZEOF(OutMsg), format, d);
+ _tcsncpy(format, OutMsg, _countof(OutMsg));
+ j = (int)_tcslen(format);
+ _tcscat(format, _T(" "));
+ break;
+ }
}
- format[j+1] = '\0';
+ format[j + 1] = '\0';
}
- _tcscat(format,_T("\n"));
+ _tcscat(format, _T("\n"));
OutputDebugString(format);
- va_end( argptr );
+ va_end(argptr);
}
diff --git a/plugins/ConnectionNotify/src/debug.h b/plugins/ConnectionNotify/src/debug.h index fd5b070c9e..90c46be0f5 100644 --- a/plugins/ConnectionNotify/src/debug.h +++ b/plugins/ConnectionNotify/src/debug.h @@ -6,5 +6,5 @@ #include <stdio.h>
#include <tchar.h>
-void _OutputDebugString(TCHAR* lpOutputString, ... );
+void _OutputDebugString(TCHAR* lpOutputString, ...);
#endif
\ No newline at end of file diff --git a/plugins/ConnectionNotify/src/filter.cpp b/plugins/ConnectionNotify/src/filter.cpp index a3295c59b1..f825ac9dba 100644 --- a/plugins/ConnectionNotify/src/filter.cpp +++ b/plugins/ConnectionNotify/src/filter.cpp @@ -1,15 +1,6 @@ +#include "stdafx.h"
-#include <Windows.h>
-#include <newpluginapi.h>
-#include <m_system.h>
-#include <m_langpack.h>
-
-#include "resource.h"
-#include "netstat.h"
-#include "Filter.h"
-#include "ConnectionNotify.h"
-
-HWND filterAddDlg=NULL;
+HWND filterAddDlg = NULL;
extern HINSTANCE hInst;
extern struct CONNECTION *connExceptions;
extern HANDLE hFilterOptionsThread;
@@ -26,18 +17,18 @@ HANDLE startFilterThread() return (HANDLE)mir_forkthreadex(filterQueue, 0, (unsigned int*)&FilterOptionsThreadId);
}
-static unsigned __stdcall filterQueue(void *dummy)
+static unsigned __stdcall filterQueue(void *)
{
BOOL bRet;
MSG msg;
//while(1)
- while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0)
+ while ((bRet = GetMessage(&msg, NULL, 0, 0)) != 0)
{
- if (msg.message==WM_ADD_FILTER )
+ if (msg.message == WM_ADD_FILTER)
{
- struct CONNECTION *conn=(struct CONNECTION *)msg.lParam;
- filterAddDlg=CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), NULL, ConnectionFilterEditProc,(LPARAM)conn);
- ShowWindow(filterAddDlg,SW_SHOW);
+ struct CONNECTION *conn = (struct CONNECTION *)msg.lParam;
+ filterAddDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FILTER_DIALOG), NULL, ConnectionFilterEditProc, (LPARAM)conn);
+ ShowWindow(filterAddDlg, SW_SHOW);
}
if (NULL == filterAddDlg || !IsDialogMessage(filterAddDlg, &msg)) { /* Wine fix. */
@@ -45,107 +36,107 @@ static unsigned __stdcall filterQueue(void *dummy) DispatchMessage(&msg);
}
}
- hFilterOptionsThread=NULL;
+ hFilterOptionsThread = NULL;
return TRUE;
}
static INT_PTR CALLBACK ConnectionFilterEditProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message)
+ switch (message)
+ {
+ case WM_INITDIALOG:
{
- case WM_INITDIALOG:
+ struct CONNECTION *conn = (struct CONNECTION*)lParam;
+ TranslateDialogDefault(hWnd);
+
+ SetDlgItemText(hWnd, ID_TEXT_NAME, conn->PName);
+ SetDlgItemText(hWnd, ID_TXT_LOCAL_IP, conn->strIntIp);
+ SetDlgItemText(hWnd, ID_TXT_REMOTE_IP, conn->strExtIp);
+ SetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT, conn->intIntPort, FALSE);
+ SetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT, conn->intExtPort, FALSE);
+ SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Always show popup"));
+ SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_ADDSTRING, 0, (LPARAM)TranslateT("Never show popup"));
+ SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_SETCURSEL, 0, 0);
+ mir_free(conn);
+ return TRUE;
+ }
+ case WM_ACTIVATE:
+ if (0 == wParam) // becoming inactive
+ filterAddDlg = NULL;
+ else // becoming active
+ filterAddDlg = hWnd;
+ return FALSE;
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case ID_OK:
+ {
+ TCHAR tmpPort[6];
+ if (bOptionsOpen)
{
- struct CONNECTION *conn=(struct CONNECTION*)lParam;
- TranslateDialogDefault(hWnd);
-
- SetDlgItemText(hWnd, ID_TEXT_NAME,conn->PName);
- SetDlgItemText(hWnd, ID_TXT_LOCAL_IP,conn->strIntIp);
- SetDlgItemText(hWnd, ID_TXT_REMOTE_IP,conn->strExtIp);
- SetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT,conn->intIntPort,FALSE);
- SetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT,conn->intExtPort,FALSE);
- SendDlgItemMessage(hWnd, ID_CBO_ACTION , CB_ADDSTRING, 0, (LPARAM)TranslateT("Always show popup"));
- SendDlgItemMessage(hWnd, ID_CBO_ACTION , CB_ADDSTRING, 0, (LPARAM)TranslateT("Never show popup"));
- SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_SETCURSEL ,0,0);
- mir_free(conn);
- return TRUE;
+ MessageBox(hWnd, TranslateT("First close options window"), _T("ConnectionNotify"), MB_OK | MB_ICONSTOP);
+ break;
}
- case WM_ACTIVATE:
- if (0 == wParam) // becoming inactive
- filterAddDlg = NULL;
- else // becoming active
- filterAddDlg = hWnd;
- return FALSE;
- case WM_COMMAND:
- switch(LOWORD(wParam))
+ if (WAIT_OBJECT_0 == WaitForSingleObject(hExceptionsMutex, 100))
+ {
+ if (connCurrentEdit == NULL)
{
- case ID_OK:
- {
- TCHAR tmpPort[6];
- if (bOptionsOpen)
- {
- MessageBox(hWnd,TranslateT("First close options window"),_T("ConnectionNotify"),MB_OK | MB_ICONSTOP);
- break;
- }
- if ( WAIT_OBJECT_0 == WaitForSingleObject( hExceptionsMutex, 100 ))
- {
- if (connCurrentEdit==NULL)
- {
- connCurrentEdit=(struct CONNECTION*)mir_alloc(sizeof(struct CONNECTION));
- connCurrentEdit->next=connExceptions;
- connExceptions=connCurrentEdit;
- }
- GetDlgItemText(hWnd, ID_TXT_LOCAL_PORT, tmpPort, SIZEOF(tmpPort));
- if (tmpPort[0]=='*')
- connCurrentEdit->intIntPort=-1;
- else
- connCurrentEdit->intIntPort=GetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT, NULL, FALSE);
- GetDlgItemText(hWnd, ID_TXT_REMOTE_PORT, tmpPort, SIZEOF(tmpPort));
- if (tmpPort[0]=='*')
- connCurrentEdit->intExtPort=-1;
- else
- connCurrentEdit->intExtPort = GetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT, NULL, FALSE);
-
- GetDlgItemText(hWnd, ID_TXT_LOCAL_IP, connCurrentEdit->strIntIp, SIZEOF(connCurrentEdit->strIntIp));
- GetDlgItemText(hWnd, ID_TXT_REMOTE_IP, connCurrentEdit->strExtIp, SIZEOF(connCurrentEdit->strExtIp));
- GetDlgItemText(hWnd, ID_TEXT_NAME, connCurrentEdit->PName, SIZEOF(connCurrentEdit->PName));
-
- connCurrentEdit->Pid = !(BOOL)SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_GETCURSEL, 0, 0);
- connCurrentEdit = NULL;
- saveSettingsConnections(connExceptions);
- ReleaseMutex(hExceptionsMutex);
- }
- //EndDialog(hWnd,IDOK);
- DestroyWindow(hWnd);
- return TRUE;
- }
- case ID_CANCEL:
- connCurrentEdit=NULL;
- DestroyWindow(hWnd);
- //EndDialog(hWnd,IDCANCEL);
- return TRUE;
+ connCurrentEdit = (struct CONNECTION*)mir_alloc(sizeof(struct CONNECTION));
+ connCurrentEdit->next = connExceptions;
+ connExceptions = connCurrentEdit;
}
- return FALSE;
+ GetDlgItemText(hWnd, ID_TXT_LOCAL_PORT, tmpPort, SIZEOF(tmpPort));
+ if (tmpPort[0] == '*')
+ connCurrentEdit->intIntPort = -1;
+ else
+ connCurrentEdit->intIntPort = GetDlgItemInt(hWnd, ID_TXT_LOCAL_PORT, NULL, FALSE);
+ GetDlgItemText(hWnd, ID_TXT_REMOTE_PORT, tmpPort, SIZEOF(tmpPort));
+ if (tmpPort[0] == '*')
+ connCurrentEdit->intExtPort = -1;
+ else
+ connCurrentEdit->intExtPort = GetDlgItemInt(hWnd, ID_TXT_REMOTE_PORT, NULL, FALSE);
- break;
- case WM_CLOSE:
+ GetDlgItemText(hWnd, ID_TXT_LOCAL_IP, connCurrentEdit->strIntIp, SIZEOF(connCurrentEdit->strIntIp));
+ GetDlgItemText(hWnd, ID_TXT_REMOTE_IP, connCurrentEdit->strExtIp, SIZEOF(connCurrentEdit->strExtIp));
+ GetDlgItemText(hWnd, ID_TEXT_NAME, connCurrentEdit->PName, SIZEOF(connCurrentEdit->PName));
+
+ connCurrentEdit->Pid = !(BOOL)SendDlgItemMessage(hWnd, ID_CBO_ACTION, CB_GETCURSEL, 0, 0);
+ connCurrentEdit = NULL;
+ saveSettingsConnections(connExceptions);
+ ReleaseMutex(hExceptionsMutex);
+ }
+ //EndDialog(hWnd,IDOK);
+ DestroyWindow(hWnd);
+ return TRUE;
+ }
+ case ID_CANCEL:
+ connCurrentEdit = NULL;
DestroyWindow(hWnd);
- case WM_DESTROY:
- filterAddDlg=NULL;
- connCurrentEdit=NULL;
- //DestroyWindow(hWnd);
- //PostQuitMessage(0);
- break;
+ //EndDialog(hWnd,IDCANCEL);
+ return TRUE;
+ }
+ return FALSE;
+
+ break;
+ case WM_CLOSE:
+ DestroyWindow(hWnd);
+ case WM_DESTROY:
+ filterAddDlg = NULL;
+ connCurrentEdit = NULL;
+ //DestroyWindow(hWnd);
+ //PostQuitMessage(0);
+ break;
}
return FALSE;
}
-BOOL checkFilter(struct CONNECTION *head,struct CONNECTION *conn)
+BOOL checkFilter(struct CONNECTION *head, struct CONNECTION *conn)
{
- for(struct CONNECTION *cur=head; cur!=NULL; cur=cur->next)
- if (wildcmpt(conn->PName,cur->PName)&&wildcmpt(conn->strIntIp,cur->strIntIp)&&wildcmpt(conn->strExtIp,cur->strExtIp)
- &&(cur->intIntPort==-1||cur->intIntPort==conn->intIntPort)&&(cur->intExtPort==-1||cur->intExtPort==conn->intExtPort))
+ for (struct CONNECTION *cur = head; cur != NULL; cur = cur->next)
+ if (wildcmpt(conn->PName, cur->PName) && wildcmpt(conn->strIntIp, cur->strIntIp) && wildcmpt(conn->strExtIp, cur->strExtIp)
+ && (cur->intIntPort == -1 || cur->intIntPort == conn->intIntPort) && (cur->intExtPort == -1 || cur->intExtPort == conn->intExtPort))
return cur->Pid;
-
+
return settingDefaultAction;
}
diff --git a/plugins/ConnectionNotify/src/filter.h b/plugins/ConnectionNotify/src/filter.h index 0d40a4cf73..c415f7422e 100644 --- a/plugins/ConnectionNotify/src/filter.h +++ b/plugins/ConnectionNotify/src/filter.h @@ -3,7 +3,7 @@ #define _INC_FILTER
HANDLE startFilterThread();
-BOOL checkFilter(struct CONNECTION *head,struct CONNECTION *conn);
+BOOL checkFilter(struct CONNECTION *head, struct CONNECTION *conn);
#define WM_ADD_FILTER (WM_APP + 1)
#endif
diff --git a/plugins/ConnectionNotify/src/netstat.cpp b/plugins/ConnectionNotify/src/netstat.cpp index 8b7d5e75ee..14536477f4 100644 --- a/plugins/ConnectionNotify/src/netstat.cpp +++ b/plugins/ConnectionNotify/src/netstat.cpp @@ -1,21 +1,21 @@ -#include "ConnectionNotify.h" - +#include "stdafx.h" + struct CONNECTION *GetConnectionsTable() { // Declare and initialize variables - MIB_TCPTABLE_OWNER_PID *pTcpTable = (MIB_TCPTABLE_OWNER_PID *) MALLOC(sizeof (MIB_TCPTABLE_OWNER_PID)); + MIB_TCPTABLE_OWNER_PID *pTcpTable = (MIB_TCPTABLE_OWNER_PID *)MALLOC(sizeof(MIB_TCPTABLE_OWNER_PID)); if (pTcpTable == NULL) { //printf("Error allocating memory!\n"); return NULL; } - DWORD dwSize = sizeof (MIB_TCPTABLE_OWNER_PID); + DWORD dwSize = sizeof(MIB_TCPTABLE_OWNER_PID); // Make an initial call to GetTcpTable to // get the necessary size into the dwSize variable - DWORD dwRetVal = GetExtendedTcpTable(pTcpTable, &dwSize, TRUE,AF_INET,TCP_TABLE_OWNER_PID_ALL,0); - if (dwRetVal == ERROR_INSUFFICIENT_BUFFER) { + DWORD dwRetVal = GetExtendedTcpTable(pTcpTable, &dwSize, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0); + if (dwRetVal == ERROR_INSUFFICIENT_BUFFER) { FREE(pTcpTable); - pTcpTable = (MIB_TCPTABLE_OWNER_PID *) MALLOC(dwSize); + pTcpTable = (MIB_TCPTABLE_OWNER_PID *)MALLOC(dwSize); if (pTcpTable == NULL) { //printf("Error allocating memory\n"); return NULL; @@ -24,7 +24,7 @@ struct CONNECTION *GetConnectionsTable() // Make a second call to GetTcpTable to get // the actual data we require - if ((dwRetVal = GetExtendedTcpTable(pTcpTable, &dwSize, TRUE,AF_INET,TCP_TABLE_OWNER_PID_ALL,0)) != NO_ERROR) { + if ((dwRetVal = GetExtendedTcpTable(pTcpTable, &dwSize, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) != NO_ERROR) { //printf("\tGetTcpTable() failed with return value %d\n", dwRetVal); FREE(pTcpTable); return NULL; @@ -33,23 +33,23 @@ struct CONNECTION *GetConnectionsTable() //printf("Number of entries: %d\n", (int) pTcpTable->dwNumEntries); struct in_addr IpAddr; struct CONNECTION *connHead = NULL; - for (DWORD i = 0; i < pTcpTable->dwNumEntries; i ++) { + for (DWORD i = 0; i < pTcpTable->dwNumEntries; i++) { struct CONNECTION *newConn = (struct CONNECTION*)mir_alloc(sizeof(struct CONNECTION)); memset(newConn, 0, sizeof(struct CONNECTION)); //pid2name(pTcpTable->table[i].dwOwningPid,&newConn->Pname); - + if (pTcpTable->table[i].dwLocalAddr) { - IpAddr.S_un.S_addr = (ULONG) pTcpTable->table[i].dwLocalAddr; + IpAddr.S_un.S_addr = (ULONG)pTcpTable->table[i].dwLocalAddr; //_snprintf(newConn->strIntIp,_countof(newConn->strIntIp),"%d.%d.%d.%d",IpAddr.S_un.S_un_b.s_b1,IpAddr.S_un.S_un_b.s_b2,IpAddr.S_un.S_un_b.s_b3,IpAddr.S_un.S_un_b.s_b4); TCHAR *strIntIp = mir_a2t(inet_ntoa(IpAddr)); - _tcsncpy(newConn->strIntIp, strIntIp, SIZEOF(newConn->strIntIp)-1); + _tcsncpy(newConn->strIntIp, strIntIp, SIZEOF(newConn->strIntIp) - 1); mir_free(strIntIp); } - + if (pTcpTable->table[i].dwRemoteAddr) { - IpAddr.S_un.S_addr = (u_long) pTcpTable->table[i].dwRemoteAddr; + IpAddr.S_un.S_addr = (u_long)pTcpTable->table[i].dwRemoteAddr; TCHAR *strExtIp = mir_a2t(inet_ntoa(IpAddr)); - _tcsncpy(newConn->strExtIp, strExtIp, SIZEOF(newConn->strExtIp)-1); + _tcsncpy(newConn->strExtIp, strExtIp, SIZEOF(newConn->strExtIp) - 1); mir_free(strExtIp); } newConn->state = pTcpTable->table[i].dwState; @@ -125,12 +125,12 @@ void deleteConnectionsTable(struct CONNECTION *head) struct CONNECTION *searchConnection(struct CONNECTION *head, TCHAR *intIp, TCHAR *extIp, int intPort, int extPort, int state) { - for(struct CONNECTION *cur = head; cur != NULL; cur = cur->next) { + for (struct CONNECTION *cur = head; cur != NULL; cur = cur->next) { if (_tcscmp(cur->strIntIp, intIp) == 0 && - _tcscmp(cur->strExtIp, extIp) == 0 && - cur->intExtPort == extPort && - cur->intIntPort == intPort && - cur->state == state) + _tcscmp(cur->strExtIp, extIp) == 0 && + cur->intExtPort == extPort && + cur->intIntPort == intPort && + cur->state == state) return cur; } return NULL; diff --git a/plugins/ConnectionNotify/src/netstat.h b/plugins/ConnectionNotify/src/netstat.h index ccfff64a0c..8ea8ed564a 100644 --- a/plugins/ConnectionNotify/src/netstat.h +++ b/plugins/ConnectionNotify/src/netstat.h @@ -1,5 +1,5 @@ #pragma once
-
+
struct CONNECTION
@@ -16,5 +16,5 @@ struct CONNECTION struct CONNECTION* GetConnectionsTable();
void deleteConnectionsTable(struct CONNECTION* head);
-struct CONNECTION* searchConnection(struct CONNECTION* head,TCHAR *intIp,TCHAR *extIp,int intPort,int extPort,int state);
+struct CONNECTION* searchConnection(struct CONNECTION* head, TCHAR *intIp, TCHAR *extIp, int intPort, int extPort, int state);
void getDnsName(TCHAR *strIp, TCHAR *strHostName, size_t len);
\ No newline at end of file diff --git a/plugins/ConnectionNotify/src/pid2name.cpp b/plugins/ConnectionNotify/src/pid2name.cpp index 76d7b49441..e30b032bdd 100644 --- a/plugins/ConnectionNotify/src/pid2name.cpp +++ b/plugins/ConnectionNotify/src/pid2name.cpp @@ -1,4 +1,4 @@ -#include "ConnectionNotify.h"
+#include "stdafx.h"
void pid2name(DWORD procid, TCHAR *buffer, size_t bufLen)
{
@@ -15,8 +15,7 @@ void pid2name(DWORD procid, TCHAR *buffer, size_t bufLen) _tcsncpy_s(buffer, bufLen, ProcessStruct.szExeFile, _TRUNCATE);
break;
}
- }
- while( Process32Next( hSnap, &ProcessStruct ));
+ } while (Process32Next(hSnap, &ProcessStruct));
- CloseHandle( hSnap );
+ CloseHandle(hSnap);
}
diff --git a/plugins/ConnectionNotify/src/ConnectionNotify.h b/plugins/ConnectionNotify/src/stdafx.h index 7480c5b38f..75b64b0148 100644 --- a/plugins/ConnectionNotify/src/ConnectionNotify.h +++ b/plugins/ConnectionNotify/src/stdafx.h @@ -1,5 +1,3 @@ -#define _CRT_SECURE_NO_WARNINGS
-
#include <windows.h>
#include <Commctrl.h>
#include <assert.h>
|