diff options
-rw-r--r-- | plugins/NewsAggregator/Src/Options.cpp | 4 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/dialog.cpp | 26 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/files.cpp | 34 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/main.cpp | 13 | ||||
-rw-r--r-- | plugins/Non-IM Contact/src/stdafx.h | 2 | ||||
-rw-r--r-- | plugins/PackUpdater/Src/Notifications.cpp | 18 | ||||
-rw-r--r-- | plugins/PackUpdater/Src/Options.cpp | 2 | ||||
-rw-r--r-- | plugins/PackUpdater/Src/Utils.cpp | 18 | ||||
-rw-r--r-- | plugins/PackUpdater/Src/stdafx.h | 16 | ||||
-rw-r--r-- | plugins/PasteIt/src/Options.cpp | 828 | ||||
-rw-r--r-- | plugins/Ping/src/collection.h | 272 | ||||
-rw-r--r-- | plugins/Ping/src/pingthread.cpp | 635 | ||||
-rw-r--r-- | plugins/Popup/Popup.vcxproj | 5 | ||||
-rw-r--r-- | plugins/Popup/src/effects.cpp | 16 | ||||
-rw-r--r-- | plugins/Popup/src/opt_adv.cpp | 9 | ||||
-rw-r--r-- | plugins/Popup/src/opt_adv.h | 2 | ||||
-rw-r--r-- | plugins/Popup/src/opt_class.cpp | 2 | ||||
-rw-r--r-- | plugins/Popup/src/popup_wnd2.cpp | 2 | ||||
-rw-r--r-- | plugins/Popup/src/skin.cpp | 42 |
19 files changed, 912 insertions, 1034 deletions
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp index ad0f4eaa46..dfdf630c21 100644 --- a/plugins/NewsAggregator/Src/Options.cpp +++ b/plugins/NewsAggregator/Src/Options.cpp @@ -500,7 +500,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case IDC_REMOVE:
if (MessageBox(hwndDlg, TranslateT("Are you sure?"), TranslateT("Contact deleting"), MB_YESNO | MB_ICONWARNING) == IDYES) {
TCHAR nick[MAX_PATH], url[MAX_PATH];
- int sel = ListView_GetSelectionMark(hwndList);
+ sel = ListView_GetSelectionMark(hwndList);
ListView_GetItemText(hwndList, sel, 0, nick, _countof(nick));
ListView_GetItemText(hwndList, sel, 1, url, _countof(url));
@@ -570,7 +570,7 @@ INT_PTR CALLBACK UpdateNotifyOptsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPA case LVN_ITEMCHANGED:
NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;
- int sel = ListView_GetSelectionMark(hwndList);
+ sel = ListView_GetSelectionMark(hwndList);
if (sel == -1) {
EnableWindow(GetDlgItem(hwndDlg, IDC_CHANGE), FALSE);
EnableWindow(GetDlgItem(hwndDlg, IDC_REMOVE), FALSE);
diff --git a/plugins/Non-IM Contact/src/dialog.cpp b/plugins/Non-IM Contact/src/dialog.cpp index 5690b5a2f9..c5fdf36770 100644 --- a/plugins/Non-IM Contact/src/dialog.cpp +++ b/plugins/Non-IM Contact/src/dialog.cpp @@ -17,9 +17,10 @@ filename(0) <- will display the filename of the 0th file\r\nfile(0)wholeline( INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ TCHAR tmp[5];
+
switch (msg) {
case WM_INITDIALOG:
- TCHAR tmp[5];
TranslateDialogDefault(hwnd);
CheckDlgButton(hwnd, IDC_AWAYISNOTONLINE, db_get_b(NULL, MODNAME, "AwayAsStatus", 0) ? BST_CHECKED : BST_UNCHECKED);
if (db_get_w(NULL, MODNAME, "Timer", 1)) {
@@ -57,7 +58,6 @@ INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- TCHAR tmp[5];
db_set_b(NULL, MODNAME, "AwayAsStatus", (BYTE)IsDlgButtonChecked(hwnd, IDC_AWAYISNOTONLINE));
if (BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_DISABLETIMER) && GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER_INT))) {
GetDlgItemText(hwnd, IDC_TIMER_INT, tmp, _countof(tmp));
@@ -123,7 +123,7 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_HELPMSG:
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_HELP), 0, HelpWindowDlgProc);
+ CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_HELP), 0, HelpWindowDlgProc);
break;
case IDCANCEL:
@@ -205,13 +205,13 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM) INT_PTR testStringReplacer(WPARAM, LPARAM)
{
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_TEST_LINE), 0, TestWindowDlgProc);
+ CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_TEST_LINE), 0, TestWindowDlgProc);
return 0;
}
INT_PTR LoadFilesDlg(WPARAM, LPARAM)
{
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_ADD_FILE), 0, DlgProcFiles);
+ CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_ADD_FILE), 0, DlgProcFiles);
return 0;
}
@@ -233,7 +233,7 @@ static int CALLBACK PropSheetProc(HWND, UINT uMsg, LPARAM lParam) return 0;
}
-void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
+void DoPropertySheet(MCONTACT hContact)
{
char title[256], nick[256];
PROPSHEETPAGEA psp[4] = { 0 };
@@ -241,7 +241,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst) /* contact info */
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[0].hInstance = hInst;
+ psp[0].hInstance = g_hInst;
psp[0].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_INFO);
psp[0].pszIcon = NULL;
psp[0].pfnDlgProc = DlgProcContactInfo;
@@ -252,7 +252,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst) /* other settings */
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[1].hInstance = hInst;
+ psp[1].hInstance = g_hInst;
psp[1].pszTemplate = MAKEINTRESOURCEA(IDD_OTHER_STUFF);
psp[1].pszIcon = NULL;
psp[1].pfnDlgProc = DlgProcOtherStuff;
@@ -263,7 +263,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst) /* copy contact */
psp[2].dwSize = sizeof(PROPSHEETPAGE);
psp[2].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[2].hInstance = hInst;
+ psp[2].hInstance = g_hInst;
psp[2].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COPYEXPORT);
psp[2].pszIcon = NULL;
psp[2].pfnDlgProc = DlgProcCopy;
@@ -274,7 +274,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst) /* files */
psp[3].dwSize = sizeof(PROPSHEETPAGE);
psp[3].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[3].hInstance = hInst;
+ psp[3].hInstance = g_hInst;
psp[3].pszTemplate = MAKEINTRESOURCEA(IDD_ADD_FILE);
psp[3].pszIcon = NULL;
psp[3].pfnDlgProc = DlgProcFiles;
@@ -285,7 +285,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst) /* propery sheet header.. dont touch !!!! */
PROPSHEETHEADERA psh = { sizeof(psh) };
psh.dwFlags = PSH_USEICONID | PSH_PROPSHEETPAGE | PSH_USECALLBACK;
- psh.hInstance = hInst;
+ psh.hInstance = g_hInst;
psh.pszIcon = MAKEINTRESOURCEA(IDI_MAIN);
db_get_static(hContact, MODNAME, "Nick", nick, _countof(nick));
mir_snprintf(title, _countof(title), Translate("Edit Non-IM Contact \"%s\""), nick);
@@ -305,7 +305,7 @@ INT_PTR addContact(WPARAM, LPARAM) Proto_AddToContact(hContact, MODNAME);
CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
db_set_ts(hContact, MODNAME, "Nick", TranslateT("New Non-IM Contact"));
- DoPropertySheet(hContact, hInst);
+ DoPropertySheet(hContact);
if (!db_get_static(hContact, MODNAME, "Name", tmp, _countof(tmp)))
CallService(MS_DB_CONTACT_DELETE, hContact, 0);
replaceAllStrings(hContact);
@@ -322,7 +322,7 @@ INT_PTR editContact(WPARAM wParam, LPARAM) CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact"));
}
- DoPropertySheet(hContact, hInst);
+ DoPropertySheet(hContact);
if (!db_get_static(hContact, MODNAME, "Name", tmp, _countof(tmp)))
CallService(MS_DB_CONTACT_DELETE, hContact, 0);
replaceAllStrings(hContact);
diff --git a/plugins/Non-IM Contact/src/files.cpp b/plugins/Non-IM Contact/src/files.cpp index 0ba3631be1..c97369d641 100644 --- a/plugins/Non-IM Contact/src/files.cpp +++ b/plugins/Non-IM Contact/src/files.cpp @@ -102,12 +102,15 @@ int savehtml(char* outFile) void readFile(HWND hwnd)
{
int lineNumber, fileLength = 0;
- char temp[MAX_STRING_LENGTH], szFileName[512], temp1[MAX_STRING_LENGTH], fn[8];
+ char temp[MAX_STRING_LENGTH], szFileName[512], temp1[MAX_STRING_LENGTH];
int fileNumber = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
- mir_snprintf(fn, "fn%d", fileNumber);
- if (!db_get_static(NULL, MODNAME, fn, szFileName, _countof(szFileName))) {
- msg(Translate("File couldn't be opened"), fn);
- return;
+ {
+ char fn[10];
+ mir_snprintf(fn, "fn%d", fileNumber);
+ if (!db_get_static(NULL, MODNAME, fn, szFileName, _countof(szFileName))) {
+ msg(Translate("File couldn't be opened"), fn);
+ return;
+ }
}
if (!strncmp("http://", szFileName, mir_strlen("http://")) || !strncmp("https://", szFileName, mir_strlen("https://")))
@@ -141,11 +144,14 @@ void readFile(HWND hwnd) INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ char tmp[MAX_PATH], fn[MAX_PATH];
+
switch (msg) {
case WM_RELOADWINDOW:
- char fn[MAX_PATH], string[MAX_STRING_LENGTH], tmp[MAX_STRING_LENGTH];
- reloadFiles(GetDlgItem(hwnd, IDC_FILE_LIST));
{
+ char string[MAX_STRING_LENGTH];
+ reloadFiles(GetDlgItem(hwnd, IDC_FILE_LIST));
+
int i = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
mir_snprintf(fn, "fn%d", i);
SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS, LB_RESETCONTENT, 0, 0);
@@ -170,7 +176,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) switch (LOWORD(wParam)) {
case IDC_ADD_URL:
if (GetWindowTextLength(GetDlgItem(hwnd, IDC_URL))) {
- char text[512], url[512], fn[10] = "fn0", szFileName[MAX_PATH], temp[512];
+ char text[512], url[512], szFileName[MAX_PATH], temp[512];
int i, timer;
GetDlgItemTextA(hwnd, IDC_URL, text, _countof(text));
mir_strcpy(url, text);
@@ -202,9 +208,10 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (HIWORD(wParam) == EN_CHANGE)
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
+
case IDC_ADD_FILE:
int i, index;
- char file[MAX_PATH], fn[6];
+ char file[MAX_PATH];
for (i = 0;; i++) {
mir_snprintf(fn, "fn%d", i);
if (!db_get_static(NULL, MODNAME, fn, file, _countof(file)))
@@ -222,9 +229,8 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) break;
case IDC_DEL_FILE:
- char fn1[4], tmp[256];
+ index = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0), i = (int)SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETITEMDATA, index, 0);
{
- int index = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0), i = (int)SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETITEMDATA, index, 0);
int count = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCOUNT, 0, 0) - 1;
if (index == count) {
mir_snprintf(fn, "fn%d", index);
@@ -239,6 +245,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) }
else {
mir_snprintf(fn, "fn%d", i);
+ char fn1[4];
while (db_get_static(NULL, MODNAME, fn, tmp, _countof(tmp))) {
mir_snprintf(fn1, "fn%d", i - 1);
db_set_s(NULL, MODNAME, fn1, tmp);
@@ -254,8 +261,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case IDC_FILE_LIST:
if (HIWORD(wParam) == CBN_SELCHANGE) {
- int index = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
- char fn[20], tmp[MAX_PATH];
+ index = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
SetDlgItemTextA(hwnd, IDC_FN, _itoa(index, fn, 10));
mir_snprintf(fn, "fn%d", index);
if (db_get_static(NULL, MODNAME, fn, tmp, _countof(tmp))) {
@@ -285,7 +291,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case PSN_APPLY:
int i = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
int timer;
- char fn[MAX_PATH], string[1000];
+ char string[1000];
mir_snprintf(fn, "fn%d", i);
if (GetWindowTextLength(GetDlgItem(hwnd, IDC_WWW_TIMER))) {
TCHAR text[5];
diff --git a/plugins/Non-IM Contact/src/main.cpp b/plugins/Non-IM Contact/src/main.cpp index 7c431bb8e3..15c251fb5b 100644 --- a/plugins/Non-IM Contact/src/main.cpp +++ b/plugins/Non-IM Contact/src/main.cpp @@ -7,7 +7,7 @@ #include "Version.h"
CLIST_INTERFACE *pcli;
-HINSTANCE hInst;
+HINSTANCE g_hInst;
int hLangpack;
PLUGININFOEX pluginInfoEx = {
@@ -27,7 +27,7 @@ PLUGININFOEX pluginInfoEx = { INT_PTR doubleClick(WPARAM wParam, LPARAM)
{
char program[MAX_PATH], params[MAX_PATH];
- int shellEXEerror = 0;
+ INT_PTR shellEXEerror = 0;
char* proto = GetContactProto(wParam);
if (proto && !mir_strcmp(proto, MODNAME)) {
if (GetKeyState(VK_CONTROL) & 0x8000) // ctrl is pressed
@@ -37,7 +37,8 @@ INT_PTR doubleClick(WPARAM wParam, LPARAM) mir_strcpy(params, "");
if (strstr(program, "http://") || strstr(program, "https://"))
Utils_OpenUrl(program);
- else shellEXEerror = (int)ShellExecuteA(NULL, NULL, program, params, NULL, SW_SHOW); //ignore the warning, its M$'s backwards compatabilty screwup :)
+ else
+ shellEXEerror = (INT_PTR)ShellExecuteA(NULL, NULL, program, params, NULL, SW_SHOW); //ignore the warning, its M$'s backwards compatabilty screwup :)
if (shellEXEerror == ERROR_FILE_NOT_FOUND || shellEXEerror == ERROR_PATH_NOT_FOUND)
Utils_OpenUrl(program);
}
@@ -62,7 +63,7 @@ int LCStatus = ID_STATUS_OFFLINE; int NimcOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.pszGroup = LPGEN("Plugins");
odp.pszTitle = LPGEN("Non-IM Contacts");
@@ -91,7 +92,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID)
{
- hInst = hinst;
+ g_hInst = hinst;
return TRUE;
}
@@ -118,7 +119,7 @@ extern "C" __declspec(dllexport) int Load() mir_getLP(&pluginInfoEx);
mir_getCLI();
- Icon_Register(hInst, LPGEN("Non-IM Contact"), icoList, _countof(icoList));
+ Icon_Register(g_hInst, LPGEN("Non-IM Contact"), icoList, _countof(icoList));
HookEvent(ME_CLIST_DOUBLECLICKED, (MIRANDAHOOK)doubleClick);
HookEvent(ME_OPT_INITIALISE, NimcOptInit);
diff --git a/plugins/Non-IM Contact/src/stdafx.h b/plugins/Non-IM Contact/src/stdafx.h index 099240c3cf..c6494d2f46 100644 --- a/plugins/Non-IM Contact/src/stdafx.h +++ b/plugins/Non-IM Contact/src/stdafx.h @@ -69,7 +69,7 @@ struct DLGTEMPLATEEX // Defines
//=======================================================
//General
-extern HINSTANCE hInst;
+extern HINSTANCE g_hInst;
extern int LCStatus;
extern IconItem icoList[];
diff --git a/plugins/PackUpdater/Src/Notifications.cpp b/plugins/PackUpdater/Src/Notifications.cpp index abb89e65c5..656219ef27 100644 --- a/plugins/PackUpdater/Src/Notifications.cpp +++ b/plugins/PackUpdater/Src/Notifications.cpp @@ -87,7 +87,7 @@ static INT_PTR CALLBACK PopupDlgProc2(HWND hDlg, UINT uMsg, WPARAM wParam, LPARA return DefWindowProc(hDlg, uMsg, wParam, lParam);
}
-static VOID MakePopupAction(POPUPACTION &pa, INT id)
+static void MakePopupAction(POPUPACTION &pa, INT id)
{
pa.cbSize = sizeof(POPUPACTION);
pa.flags = PAF_ENABLED;
@@ -105,7 +105,7 @@ static VOID MakePopupAction(POPUPACTION &pa, INT id) }
}
-VOID show_popup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, int Number, int ActType)
+void show_popup(HWND hDlg, LPCTSTR pszTitle, LPCTSTR pszText, int iNumber, int ActType)
{
LPMSGPOPUPDATA pmpd = (LPMSGPOPUPDATA)mir_alloc(sizeof(MSGPOPUPDATA));
if (!pmpd)
@@ -114,28 +114,28 @@ VOID show_popup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, int Number, int ActType) POPUPDATAT_V2 pd = { 0 };
pd.cbSize = sizeof(pd);
pd.lchContact = NULL; //(HANDLE)wParam;
- pd.lchIcon = Skin_LoadIcon(PopupsList[Number].Icon);
- mir_tstrncpy(pd.lptzText, Text, _countof(pd.lptzText));
- mir_tstrncpy(pd.lptzContactName, Title, _countof(pd.lptzContactName));
+ pd.lchIcon = Skin_LoadIcon(PopupsList[iNumber].Icon);
+ mir_tstrncpy(pd.lptzText, pszText, _countof(pd.lptzText));
+ mir_tstrncpy(pd.lptzContactName, pszTitle, _countof(pd.lptzContactName));
switch (MyOptions.DefColors) {
case byCOLOR_WINDOWS:
pd.colorBack = GetSysColor(COLOR_BTNFACE);
pd.colorText = GetSysColor(COLOR_WINDOWTEXT);
break;
case byCOLOR_OWN:
- pd.colorBack = PopupsList[Number].colorBack;
- pd.colorText = PopupsList[Number].colorText;
+ pd.colorBack = PopupsList[iNumber].colorBack;
+ pd.colorText = PopupsList[iNumber].colorText;
break;
case byCOLOR_POPUP:
pd.colorBack = pd.colorText = 0;
break;
}
- if (Number == 0 && ActType != 0)
+ if (iNumber == 0 && ActType != 0)
pd.PluginWindowProc = (WNDPROC)PopupDlgProc;
else
pd.PluginWindowProc = (WNDPROC)PopupDlgProc2;
pd.PluginData = pmpd;
- if (Number == 0)
+ if (iNumber == 0)
pd.iSeconds = -1;
else
pd.iSeconds = MyOptions.Timeout;
diff --git a/plugins/PackUpdater/Src/Options.cpp b/plugins/PackUpdater/Src/Options.cpp index a0ecf9820a..53a498be66 100644 --- a/plugins/PackUpdater/Src/Options.cpp +++ b/plugins/PackUpdater/Src/Options.cpp @@ -292,7 +292,7 @@ INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) case IDC_PREVIEW:
Title = TranslateT("Pack Updater");
Text = TranslateT("Test");
- for (int i = 0; i < POPUPS; i++) {
+ for (i = 0; i < POPUPS; i++) {
if ((BST_UNCHECKED == IsDlgButtonChecked(hdlg, (i + 40071))) || (!IsWindowEnabled(GetDlgItem(hdlg, (i + 40071)))))
continue;
show_popup(0, Title, Text, i, 0);
diff --git a/plugins/PackUpdater/Src/Utils.cpp b/plugins/PackUpdater/Src/Utils.cpp index 10dd3a5c05..5c2d660079 100644 --- a/plugins/PackUpdater/Src/Utils.cpp +++ b/plugins/PackUpdater/Src/Utils.cpp @@ -41,7 +41,7 @@ IconItem iconList[] = { LPGEN("'No' Button"), "btn_cancel", IDI_CANCEL }
};
-VOID IcoLibInit()
+void IcoLibInit()
{
Icon_Register(hInst, MODULEA, iconList, _countof(iconList));
}
@@ -58,13 +58,13 @@ BOOL NetlibInit() return hNetlibUser != NULL;
}
-VOID NetlibUnInit()
+void NetlibUnInit()
{
Netlib_CloseHandle(hNetlibUser);
hNetlibUser = NULL;
}
-VOID InitPopupList()
+void InitPopupList()
{
int index = 0;
PopupsList[index].ID = index;
@@ -91,7 +91,7 @@ VOID InitPopupList() PopupsList[index].colorText = db_get_dw(NULL, MODNAME, "Popups3Tx", COLOR_TX_DEFAULT);
}
-VOID LoadOptions()
+void LoadOptions()
{
MyOptions.DefColors = db_get_b(NULL, MODNAME, "DefColors", DEFAULT_COLORS);
MyOptions.LeftClickAction = db_get_b(NULL, MODNAME, "LeftClickAction", DEFAULT_POPUP_LCLICK);
@@ -147,12 +147,12 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal) return ret;
}
-VOID __stdcall ExitMe(void*)
+void __stdcall ExitMe(void*)
{
CallService("CloseAction", 0, 0);
}
-VOID __stdcall RestartMe(void*)
+void __stdcall RestartMe(void*)
{
CallService(MS_SYSTEM_RESTART, 1, 0);
}
@@ -172,7 +172,7 @@ BOOL IsPluginDisabled(TCHAR* filename) size_t getVer(const TCHAR* verStr)
{
- size_t v1 = 0, v2 = 0, v3 = 0, v4 = 0;
+ int v1 = 0, v2 = 0, v3 = 0, v4 = 0;
_stscanf(verStr, _T("%d.%d.%d.%d"), &v1, &v2, &v3, &v4);
return v1 * 10000000 + v2 * 100000 + v3 * 1000 + v4;
}
@@ -410,12 +410,12 @@ LONG PeriodToMilliseconds(const INT period, BYTE& periodMeasure) return result;
}
-VOID CALLBACK TimerAPCProc(LPVOID, DWORD, DWORD)
+void CALLBACK TimerAPCProc(LPVOID, DWORD, DWORD)
{
DoCheck(TRUE);
}
-VOID InitTimer()
+void InitTimer()
{
CancelWaitableTimer(Timer);
if (UpdateOnPeriod) {
diff --git a/plugins/PackUpdater/Src/stdafx.h b/plugins/PackUpdater/Src/stdafx.h index 0c6eeafa2f..a52356f503 100644 --- a/plugins/PackUpdater/Src/stdafx.h +++ b/plugins/PackUpdater/Src/stdafx.h @@ -100,23 +100,23 @@ extern aPopups PopupsList[POPUPS]; extern LPCTSTR Title, Text;
extern HANDLE Timer;
-VOID InitPopupList();
-VOID LoadOptions();
+void InitPopupList();
+void LoadOptions();
BOOL NetlibInit();
-VOID IcoLibInit();
-VOID NetlibUnInit();
+void IcoLibInit();
+void NetlibUnInit();
INT ModulesLoaded(WPARAM wParam, LPARAM lParam);
INT_PTR MenuCommand(WPARAM wParam, LPARAM lParam);
INT_PTR EmptyFolder(WPARAM wParam, LPARAM lParam);
INT OnPreShutdown(WPARAM wParam, LPARAM lParam);
INT OptInit(WPARAM wParam, LPARAM lParam);
-VOID DoCheck(INT iFlag);
+void DoCheck(INT iFlag);
BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal);
-VOID show_popup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, INT Number, INT ActType);
-VOID DlgDownloadProc();
+void show_popup(HWND hDlg, LPCTSTR Title, LPCTSTR Text, INT Number, INT ActType);
+void DlgDownloadProc();
INT_PTR CALLBACK DlgUpdate(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DlgMsgPop(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
void __stdcall ExitMe(void*);
void __stdcall RestartMe(void*);
BOOL AllowUpdateOnStartup();
-VOID InitTimer();
\ No newline at end of file +void InitTimer();
diff --git a/plugins/PasteIt/src/Options.cpp b/plugins/PasteIt/src/Options.cpp index 65781ac2f0..24405b97de 100644 --- a/plugins/PasteIt/src/Options.cpp +++ b/plugins/PasteIt/src/Options.cpp @@ -20,7 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. Options *Options::instance;
-struct TCpTable {
+struct TCpTable
+{
UINT cpId;
TCHAR *cpName;
}
@@ -55,8 +56,7 @@ Options::Options() autoUTF = true;
confDlg = true;
autoSend = false;
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
webOptions[i] = new WebOptions(i);
}
}
@@ -64,8 +64,7 @@ Options::Options() Options::~Options()
{
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
delete webOptions[i];
webOptions[i] = NULL;
}
@@ -75,55 +74,50 @@ void DefWebPageChanged(); INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- CheckDlgButton(hwndDlg, IDC_AUTOUTF, instance->autoUTF ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CONFDLG, instance->confDlg ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_AUTOSEND, instance->autoSend ? BST_CHECKED : BST_UNCHECKED);
-
- for (int i = 0; i < PasteToWeb::pages; ++i)
{
- ComboBox_AddString(GetDlgItem(hwndDlg, IDC_WEBLIST), pasteToWebs[i]->GetName());
- }
+ TranslateDialogDefault(hwndDlg);
+ CheckDlgButton(hwndDlg, IDC_AUTOUTF, instance->autoUTF ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CONFDLG, instance->confDlg ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_AUTOSEND, instance->autoSend ? BST_CHECKED : BST_UNCHECKED);
- ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_WEBLIST), instance->defWeb);
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
+ ComboBox_AddString(GetDlgItem(hwndDlg, IDC_WEBLIST), pasteToWebs[i]->GetName());
+ }
- InitCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), instance->codepage);
- return TRUE;
- }
+ ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_WEBLIST), instance->defWeb);
+
+ InitCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), instance->codepage);
+ return TRUE;
+ }
case WM_COMMAND:
- {
- if (LOWORD(wParam) == IDC_CODEPAGE)
{
- if (HIWORD(wParam) == CBN_KILLFOCUS)
- {
- GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), true, instance->codepage);
+ if (LOWORD(wParam) == IDC_CODEPAGE) {
+ if (HIWORD(wParam) == CBN_KILLFOCUS) {
+ GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), true, instance->codepage);
+ }
}
- }
- if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return TRUE;
- }
+ if (HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ }
case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == PSN_APPLY)
{
- instance->codepage = GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), false, instance->codepage);
- instance->autoUTF = IsDlgButtonChecked(hwndDlg, IDC_AUTOUTF) ? true : false;
- instance->confDlg = IsDlgButtonChecked(hwndDlg, IDC_CONFDLG) ? true : false;
- instance->autoSend = IsDlgButtonChecked(hwndDlg, IDC_AUTOSEND) ? true : false;
- instance->defWeb = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBLIST));
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ instance->codepage = GetCodepageCB(GetDlgItem(hwndDlg, IDC_CODEPAGE), false, instance->codepage);
+ instance->autoUTF = IsDlgButtonChecked(hwndDlg, IDC_AUTOUTF) ? true : false;
+ instance->confDlg = IsDlgButtonChecked(hwndDlg, IDC_CONFDLG) ? true : false;
+ instance->autoSend = IsDlgButtonChecked(hwndDlg, IDC_AUTOSEND) ? true : false;
+ instance->defWeb = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBLIST));
- DefWebPageChanged();
+ DefWebPageChanged();
- Options::instance->Save();
+ Options::instance->Save();
+ }
+ return TRUE;
}
- return TRUE;
- }
}
return FALSE;
@@ -136,16 +130,14 @@ public: : lastPage(0)
{
init = false;
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
webOptions[i] = Options::instance->webOptions[i]->Copy();
}
}
~OptsPagesData()
{
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
delete webOptions[i];
webOptions[i] = NULL;
}
@@ -173,15 +165,13 @@ void ReloadFormatsCombo(HWND hWnd, WebOptions* wo) while (ComboBox_DeleteString(hWnd, 0) > 0);
int sel = 0;
int i = 0;
- for (std::list<PasteFormat>::iterator it = wo->formats.begin(); it != wo->formats.end(); ++it)
- {
+ for (std::list<PasteFormat>::iterator it = wo->formats.begin(); it != wo->formats.end(); ++it) {
ComboBox_AddString(hWnd, it->name.c_str());
if (it->id == wo->defFormatId)
sel = i;
++i;
}
- if (!wo->formats.empty())
- {
+ if (!wo->formats.empty()) {
ComboBox_SetCurSel(hWnd, sel);
}
}
@@ -190,12 +180,9 @@ void GetPagesSettings(HWND hwndDlg, OptsPagesData* optsPagesData) {
int selected = optsPagesData->lastPage;
int format = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_DEFFORMAT));
- if (format >= 0 && format < (int)optsPagesData->webOptions[selected]->formats.size())
- {
- for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[selected]->formats.begin(); it != optsPagesData->webOptions[selected]->formats.end(); ++it)
- {
- if (format-- <= 0)
- {
+ if (format >= 0 && format < (int)optsPagesData->webOptions[selected]->formats.size()) {
+ for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[selected]->formats.begin(); it != optsPagesData->webOptions[selected]->formats.end(); ++it) {
+ if (format-- <= 0) {
optsPagesData->webOptions[selected]->defFormatId = it->id;
break;
}
@@ -206,29 +193,22 @@ void GetPagesSettings(HWND hwndDlg, OptsPagesData* optsPagesData) optsPagesData->webOptions[selected]->sendFileName = IsDlgButtonChecked(hwndDlg, IDC_AUTOFORMAT) ? true : false;
if (optsPagesData->webOptions[selected]->isPublicPaste)
optsPagesData->webOptions[selected]->publicPaste = IsDlgButtonChecked(hwndDlg, IDC_PUBLICPASTE) ? true : false;
- if (optsPagesData->webOptions[selected]->isCombo1)
- {
+ if (optsPagesData->webOptions[selected]->isCombo1) {
int sel = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_COMBO1));
- if (sel >= 0 && sel < (int)optsPagesData->webOptions[selected]->combo1Values.size())
- {
- for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[selected]->combo1Values.begin(); it != optsPagesData->webOptions[selected]->combo1Values.end(); ++it)
- {
- if (sel-- <= 0)
- {
+ if (sel >= 0 && sel < (int)optsPagesData->webOptions[selected]->combo1Values.size()) {
+ for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[selected]->combo1Values.begin(); it != optsPagesData->webOptions[selected]->combo1Values.end(); ++it) {
+ if (sel-- <= 0) {
optsPagesData->webOptions[selected]->combo1 = it->id;
break;
}
}
}
}
- if (optsPagesData->webOptions[selected]->isPublicPaste)
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_GUEST))
- {
+ if (optsPagesData->webOptions[selected]->isPublicPaste) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_GUEST)) {
optsPagesData->webOptions[selected]->pastebinUserKey = _T("");
}
- else
- {
+ else {
TCHAR buf[100];
Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), buf, 100);
optsPagesData->webOptions[selected]->pastebinUserKey = buf;
@@ -238,194 +218,68 @@ void GetPagesSettings(HWND hwndDlg, OptsPagesData* optsPagesData) INT_PTR CALLBACK Options::DlgProcOptsPages(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- OptsPagesData* optsPagesData = new OptsPagesData();
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)optsPagesData);
-
- HWND btnhwnd = GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN);
- int btSize = Button_GetTextLength(btnhwnd);
- if (btSize > 20)
- {
- SetWindowPos(btnhwnd, NULL, 0, 0, 115, 34, SWP_NOZORDER | SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOREDRAW);
- }
-
- for (int i = 0; i < PasteToWeb::pages; ++i)
{
- ComboBox_AddString(GetDlgItem(hwndDlg, IDC_WEBPAGE), pasteToWebs[i]->GetName());
- }
-
- ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE), 0);
- ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), optsPagesData->webOptions[0]);
- if (optsPagesData->webOptions[0]->isSendFileName)
- CheckDlgButton(hwndDlg, IDC_AUTOFORMAT, optsPagesData->webOptions[0]->sendFileName ? BST_CHECKED : BST_UNCHECKED);
- else
- ShowWindow(GetDlgItem(hwndDlg, IDC_AUTOFORMAT), SW_HIDE);
-
- if (Options::instance->webOptions[0]->isPublicPaste)
- CheckDlgButton(hwndDlg, IDC_PUBLICPASTE, Options::instance->webOptions[0]->publicPaste ? BST_CHECKED : BST_UNCHECKED);
- else
- ShowWindow(GetDlgItem(hwndDlg, IDC_PUBLICPASTE), SW_HIDE);
+ TranslateDialogDefault(hwndDlg);
+ OptsPagesData* optsPagesData = new OptsPagesData();
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)optsPagesData);
- if (Options::instance->webOptions[0]->isCombo1)
- {
- int sel = 0;
- int i = 0;
- std::wstring &val = Options::instance->webOptions[0]->combo1;
- HWND cb = GetDlgItem(hwndDlg, IDC_COMBO1);
- for (std::list<PasteFormat>::iterator it = Options::instance->webOptions[0]->combo1Values.begin(); it != Options::instance->webOptions[0]->combo1Values.end(); ++it)
- {
- ComboBox_AddString(cb, it->name.c_str());
- if (val == it->id)
- sel = i;
- ++i;
+ HWND btnhwnd = GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN);
+ int btSize = Button_GetTextLength(btnhwnd);
+ if (btSize > 20) {
+ SetWindowPos(btnhwnd, NULL, 0, 0, 115, 34, SWP_NOZORDER | SWP_NOMOVE | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOREDRAW);
}
- ComboBox_SetCurSel(cb, sel);
- Static_SetText(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), Options::instance->webOptions[0]->combo1Desc.c_str());
- }
- else
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), SW_HIDE);
- }
- Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), 99);
- if (Options::instance->webOptions[0]->isPastebin)
- {
- std::wstring pastebinUserKey = Options::instance->webOptions[0]->pastebinUserKey;
- if (pastebinUserKey.empty())
- {
- CheckDlgButton(hwndDlg, IDC_GUEST, BST_CHECKED);
- Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), FALSE);
- Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), FALSE);
- Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), FALSE);
- }
- else
- {
- Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), pastebinUserKey.c_str());
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
+ ComboBox_AddString(GetDlgItem(hwndDlg, IDC_WEBPAGE), pasteToWebs[i]->GetName());
}
- }
- else
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_HIDE);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), SW_HIDE);
- }
- optsPagesData->init = true;
- return TRUE;
- }
- case WM_COMMAND:
- {
- OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_CONFIGURE)
- {
- GetPagesSettings(hwndDlg, optsPagesData);
- OptsConfigureData d;
- d.page = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE));
- WebOptions* wo = optsPagesData->webOptions[d.page];
- d.tempFormats = wo->formats;
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_CONFIGURE), hwndDlg, DlgProcOptsConfigure, (LPARAM)&d) == IDOK)
- {
- wo->formats = d.tempFormats;
- ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), wo);
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- }
- }
- else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_PASTEBIN_LOGIN)
- {
- OptsLoginData d;
- if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_PASTEBIN_LOGIN), hwndDlg, DlgProcOptsLogin, (LPARAM)&d) == IDOK)
- {
- PasteToWeb1 *web = (PasteToWeb1*)pasteToWebs[optsPagesData->lastPage];
- Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), web->GetUserKey(d.user, d.password).c_str());
- }
- }
- else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_GUEST)
- {
- BOOL enabled = IsDlgButtonChecked(hwndDlg, IDC_GUEST) ? FALSE : TRUE;
- Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), enabled);
- Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), enabled);
- Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), enabled);
- }
- else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_WEBPAGE)
- {
- GetPagesSettings(hwndDlg, optsPagesData);
- optsPagesData->init = false;
- optsPagesData->lastPage = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE));
- ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), optsPagesData->webOptions[optsPagesData->lastPage]);
- if (optsPagesData->webOptions[optsPagesData->lastPage]->isSendFileName)
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_AUTOFORMAT), SW_SHOW);
- CheckDlgButton(hwndDlg, IDC_AUTOFORMAT, optsPagesData->webOptions[optsPagesData->lastPage]->sendFileName ? BST_CHECKED : BST_UNCHECKED);
- }
+ ComboBox_SetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE), 0);
+ ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), optsPagesData->webOptions[0]);
+ if (optsPagesData->webOptions[0]->isSendFileName)
+ CheckDlgButton(hwndDlg, IDC_AUTOFORMAT, optsPagesData->webOptions[0]->sendFileName ? BST_CHECKED : BST_UNCHECKED);
else
ShowWindow(GetDlgItem(hwndDlg, IDC_AUTOFORMAT), SW_HIDE);
- if (optsPagesData->webOptions[optsPagesData->lastPage]->isPublicPaste)
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_PUBLICPASTE), SW_SHOW);
- CheckDlgButton(hwndDlg, IDC_PUBLICPASTE, optsPagesData->webOptions[optsPagesData->lastPage]->publicPaste ? BST_CHECKED : BST_UNCHECKED);
- }
+ if (Options::instance->webOptions[0]->isPublicPaste)
+ CheckDlgButton(hwndDlg, IDC_PUBLICPASTE, Options::instance->webOptions[0]->publicPaste ? BST_CHECKED : BST_UNCHECKED);
else
ShowWindow(GetDlgItem(hwndDlg, IDC_PUBLICPASTE), SW_HIDE);
- if (optsPagesData->webOptions[optsPagesData->lastPage]->isCombo1)
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), SW_SHOW);
+ if (Options::instance->webOptions[0]->isCombo1) {
int sel = 0;
int i = 0;
- std::wstring &val = optsPagesData->webOptions[optsPagesData->lastPage]->combo1;
+ std::wstring &val = Options::instance->webOptions[0]->combo1;
HWND cb = GetDlgItem(hwndDlg, IDC_COMBO1);
- while (ComboBox_DeleteString(cb, 0) > 0);
- for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[optsPagesData->lastPage]->combo1Values.begin(); it != optsPagesData->webOptions[optsPagesData->lastPage]->combo1Values.end(); ++it)
- {
+ for (std::list<PasteFormat>::iterator it = Options::instance->webOptions[0]->combo1Values.begin(); it != Options::instance->webOptions[0]->combo1Values.end(); ++it) {
ComboBox_AddString(cb, it->name.c_str());
if (val == it->id)
sel = i;
++i;
}
ComboBox_SetCurSel(cb, sel);
- SetDlgItemText(hwndDlg, IDC_COMBO1_DESC, optsPagesData->webOptions[optsPagesData->lastPage]->combo1Desc.c_str());
+ Static_SetText(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), Options::instance->webOptions[0]->combo1Desc.c_str());
}
- else
- {
+ else {
ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), SW_HIDE);
}
-
- if (optsPagesData->webOptions[optsPagesData->lastPage]->isPastebin)
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_SHOW);
- ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), SW_SHOW);
- std::wstring pastebinUserKey = optsPagesData->webOptions[optsPagesData->lastPage]->pastebinUserKey;
- if (pastebinUserKey.empty())
- {
+ Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), 99);
+ if (Options::instance->webOptions[0]->isPastebin) {
+ std::wstring pastebinUserKey = Options::instance->webOptions[0]->pastebinUserKey;
+ if (pastebinUserKey.empty()) {
CheckDlgButton(hwndDlg, IDC_GUEST, BST_CHECKED);
Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), FALSE);
Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), FALSE);
Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), FALSE);
}
- else
- {
- CheckDlgButton(hwndDlg, IDC_GUEST, BST_UNCHECKED);
- Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), TRUE);
- Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), TRUE);
- Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), TRUE);
+ else {
+ Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), pastebinUserKey.c_str());
}
-
- Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), pastebinUserKey.c_str());
}
- else
- {
+ else {
ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_HIDE);
@@ -433,34 +287,133 @@ INT_PTR CALLBACK Options::DlgProcOptsPages(HWND hwndDlg, UINT msg, WPARAM wParam }
optsPagesData->init = true;
+ return TRUE;
}
-
- if (optsPagesData->init && ((HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) != IDC_CONFIGURE && LOWORD(wParam) != IDC_PASTEBIN_LOGIN) || (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) != IDC_WEBPAGE) || HIWORD(wParam) == EN_CHANGE))
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- return TRUE;
- }
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == PSN_APPLY)
+ case WM_COMMAND:
{
OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- GetPagesSettings(hwndDlg, optsPagesData);
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
- *Options::instance->webOptions[i] = *optsPagesData->webOptions[i];
+ if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_CONFIGURE) {
+ GetPagesSettings(hwndDlg, optsPagesData);
+ OptsConfigureData d;
+ d.page = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE));
+ WebOptions* wo = optsPagesData->webOptions[d.page];
+ d.tempFormats = wo->formats;
+ if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_CONFIGURE), hwndDlg, DlgProcOptsConfigure, (LPARAM)&d) == IDOK) {
+ wo->formats = d.tempFormats;
+ ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), wo);
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
+ }
+ else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_PASTEBIN_LOGIN) {
+ OptsLoginData d;
+ if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_DLG_PASTEBIN_LOGIN), hwndDlg, DlgProcOptsLogin, (LPARAM)&d) == IDOK) {
+ PasteToWeb1 *web = (PasteToWeb1*)pasteToWebs[optsPagesData->lastPage];
+ Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), web->GetUserKey(d.user, d.password).c_str());
+ }
+ }
+ else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_GUEST) {
+ BOOL enabled = IsDlgButtonChecked(hwndDlg, IDC_GUEST) ? FALSE : TRUE;
+ Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), enabled);
+ Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), enabled);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), enabled);
}
+ else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_WEBPAGE) {
+ GetPagesSettings(hwndDlg, optsPagesData);
+ optsPagesData->init = false;
+ optsPagesData->lastPage = ComboBox_GetCurSel(GetDlgItem(hwndDlg, IDC_WEBPAGE));
+ ReloadFormatsCombo(GetDlgItem(hwndDlg, IDC_DEFFORMAT), optsPagesData->webOptions[optsPagesData->lastPage]);
+ if (optsPagesData->webOptions[optsPagesData->lastPage]->isSendFileName) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_AUTOFORMAT), SW_SHOW);
+ CheckDlgButton(hwndDlg, IDC_AUTOFORMAT, optsPagesData->webOptions[optsPagesData->lastPage]->sendFileName ? BST_CHECKED : BST_UNCHECKED);
+ }
+ else
+ ShowWindow(GetDlgItem(hwndDlg, IDC_AUTOFORMAT), SW_HIDE);
+
+ if (optsPagesData->webOptions[optsPagesData->lastPage]->isPublicPaste) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PUBLICPASTE), SW_SHOW);
+ CheckDlgButton(hwndDlg, IDC_PUBLICPASTE, optsPagesData->webOptions[optsPagesData->lastPage]->publicPaste ? BST_CHECKED : BST_UNCHECKED);
+ }
+ else
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PUBLICPASTE), SW_HIDE);
+
+ if (optsPagesData->webOptions[optsPagesData->lastPage]->isCombo1) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), SW_SHOW);
+ int sel = 0;
+ int i = 0;
+ std::wstring &val = optsPagesData->webOptions[optsPagesData->lastPage]->combo1;
+ HWND cb = GetDlgItem(hwndDlg, IDC_COMBO1);
+ while (ComboBox_DeleteString(cb, 0) > 0);
+ for (std::list<PasteFormat>::iterator it = optsPagesData->webOptions[optsPagesData->lastPage]->combo1Values.begin(); it != optsPagesData->webOptions[optsPagesData->lastPage]->combo1Values.end(); ++it) {
+ ComboBox_AddString(cb, it->name.c_str());
+ if (val == it->id)
+ sel = i;
+ ++i;
+ }
+ ComboBox_SetCurSel(cb, sel);
+ SetDlgItemText(hwndDlg, IDC_COMBO1_DESC, optsPagesData->webOptions[optsPagesData->lastPage]->combo1Desc.c_str());
+ }
+ else {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_COMBO1_DESC), SW_HIDE);
+ }
+
+
+ if (optsPagesData->webOptions[optsPagesData->lastPage]->isPastebin) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), SW_SHOW);
+ std::wstring pastebinUserKey = optsPagesData->webOptions[optsPagesData->lastPage]->pastebinUserKey;
+ if (pastebinUserKey.empty()) {
+ CheckDlgButton(hwndDlg, IDC_GUEST, BST_CHECKED);
+ Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), FALSE);
+ Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), FALSE);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), FALSE);
+ }
+ else {
+ CheckDlgButton(hwndDlg, IDC_GUEST, BST_UNCHECKED);
+ Edit_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), TRUE);
+ Static_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), TRUE);
+ Button_Enable(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), TRUE);
+ }
- Options::instance->Save();
+ Edit_SetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), pastebinUserKey.c_str());
+ }
+ else {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_GUEST), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_KEY_DESC), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_PASTEBIN_LOGIN), SW_HIDE);
+ }
+
+ optsPagesData->init = true;
+ }
+
+ if (optsPagesData->init && ((HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) != IDC_CONFIGURE && LOWORD(wParam) != IDC_PASTEBIN_LOGIN) || (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) != IDC_WEBPAGE) || HIWORD(wParam) == EN_CHANGE))
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ return TRUE;
+ }
+ case WM_NOTIFY:
+ {
+ if (((LPNMHDR)lParam)->code == PSN_APPLY) {
+ OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ GetPagesSettings(hwndDlg, optsPagesData);
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
+ *Options::instance->webOptions[i] = *optsPagesData->webOptions[i];
+ }
+
+ Options::instance->Save();
+ }
+ return TRUE;
}
- return TRUE;
- }
case WM_CLOSE:
- {
- OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- delete optsPagesData;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
- break;
- }
+ {
+ OptsPagesData* optsPagesData = (OptsPagesData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ delete optsPagesData;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
+ break;
+ }
}
return FALSE;
@@ -468,8 +421,7 @@ INT_PTR CALLBACK Options::DlgProcOptsPages(HWND hwndDlg, UINT msg, WPARAM wParam void SelectLbConfigure(HWND hwndDlg, int sel, OptsConfigureData* optsConfigureData)
{
- if (sel >= 0 && sel < (int)optsConfigureData->tempFormats.size())
- {
+ if (sel >= 0 && sel < (int)optsConfigureData->tempFormats.size()) {
Button_Enable(GetDlgItem(hwndDlg, IDC_DELETE), TRUE);
if (sel == 0)
Button_Enable(GetDlgItem(hwndDlg, IDC_UP), FALSE);
@@ -480,8 +432,7 @@ void SelectLbConfigure(HWND hwndDlg, int sel, OptsConfigureData* optsConfigureDa else
Button_Enable(GetDlgItem(hwndDlg, IDC_DOWN), TRUE);
}
- else
- {
+ else {
Button_Enable(GetDlgItem(hwndDlg, IDC_DELETE), FALSE);
Button_Enable(GetDlgItem(hwndDlg, IDC_UP), FALSE);
Button_Enable(GetDlgItem(hwndDlg, IDC_DOWN), FALSE);
@@ -490,152 +441,129 @@ void SelectLbConfigure(HWND hwndDlg, int sel, OptsConfigureData* optsConfigureDa INT_PTR CALLBACK Options::DlgProcOptsConfigure(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
-
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
{
- ListBox_AddString(lb, it->name.c_str());
- }
+ TranslateDialogDefault(hwndDlg);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- SelectLbConfigure(hwndDlg, -1, optsConfigureData);
- return TRUE;
- }
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ ListBox_AddString(lb, it->name.c_str());
+ }
+
+ SelectLbConfigure(hwndDlg, -1, optsConfigureData);
+ return TRUE;
+ }
case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED)
{
- if (LOWORD(wParam) == IDOK)
- {
- EndDialog(hwndDlg, IDOK);
- }
- else if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hwndDlg, IDCANCEL);
- }
- else if (LOWORD(wParam) == IDC_DELETE)
- {
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- int sel = ListBox_GetCurSel(lb);
- if (sel >= 0)
- {
- ListBox_DeleteString(lb, sel);
- int i = sel;
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
- {
- if (i-- <= 0)
- {
- optsConfigureData->tempFormats.erase(it);
- ListBox_SetCurSel(lb, sel);
- SelectLbConfigure(hwndDlg, sel, optsConfigureData);
- break;
+ if (HIWORD(wParam) == BN_CLICKED) {
+ if (LOWORD(wParam) == IDOK) {
+ EndDialog(hwndDlg, IDOK);
+ }
+ else if (LOWORD(wParam) == IDCANCEL) {
+ EndDialog(hwndDlg, IDCANCEL);
+ }
+ else if (LOWORD(wParam) == IDC_DELETE) {
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ListBox_GetCurSel(lb);
+ if (sel >= 0) {
+ ListBox_DeleteString(lb, sel);
+ int i = sel;
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ if (i-- <= 0) {
+ optsConfigureData->tempFormats.erase(it);
+ ListBox_SetCurSel(lb, sel);
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
+ break;
+ }
}
}
}
- }
- else if (LOWORD(wParam) == IDC_UP)
- {
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- int sel = ListBox_GetCurSel(lb);
- if (sel > 0)
- {
- int i = sel;
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
- {
- if (i-- <= 0)
- {
- PasteFormat pf = *it;
- std::list<PasteFormat>::iterator prevIt = it;
- --prevIt;
- optsConfigureData->tempFormats.erase(it);
- optsConfigureData->tempFormats.insert(prevIt, pf);
- ListBox_DeleteString(lb, sel--);
- ListBox_InsertString(lb, sel, pf.name.c_str());
- ListBox_SetCurSel(lb, sel);
- SelectLbConfigure(hwndDlg, sel, optsConfigureData);
- break;
+ else if (LOWORD(wParam) == IDC_UP) {
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ListBox_GetCurSel(lb);
+ if (sel > 0) {
+ int i = sel;
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ if (i-- <= 0) {
+ PasteFormat pf = *it;
+ std::list<PasteFormat>::iterator prevIt = it;
+ --prevIt;
+ optsConfigureData->tempFormats.erase(it);
+ optsConfigureData->tempFormats.insert(prevIt, pf);
+ ListBox_DeleteString(lb, sel--);
+ ListBox_InsertString(lb, sel, pf.name.c_str());
+ ListBox_SetCurSel(lb, sel);
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
+ break;
+ }
}
}
}
- }
- else if (LOWORD(wParam) == IDC_DOWN)
- {
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- int sel = ListBox_GetCurSel(lb);
- if (sel >= 0 && sel + 1 < (int)optsConfigureData->tempFormats.size())
- {
- int i = sel;
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
- {
- if (i-- <= 0)
- {
- PasteFormat pf = *it;
- std::list<PasteFormat>::iterator nextIt = it;
- ++(++nextIt);
- optsConfigureData->tempFormats.erase(it);
- optsConfigureData->tempFormats.insert(nextIt, pf);
- ListBox_DeleteString(lb, sel++);
- ListBox_InsertString(lb, sel, pf.name.c_str());
- ListBox_SetCurSel(lb, sel);
- SelectLbConfigure(hwndDlg, sel, optsConfigureData);
- break;
+ else if (LOWORD(wParam) == IDC_DOWN) {
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ int sel = ListBox_GetCurSel(lb);
+ if (sel >= 0 && sel + 1 < (int)optsConfigureData->tempFormats.size()) {
+ int i = sel;
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ if (i-- <= 0) {
+ PasteFormat pf = *it;
+ std::list<PasteFormat>::iterator nextIt = it;
+ ++(++nextIt);
+ optsConfigureData->tempFormats.erase(it);
+ optsConfigureData->tempFormats.insert(nextIt, pf);
+ ListBox_DeleteString(lb, sel++);
+ ListBox_InsertString(lb, sel, pf.name.c_str());
+ ListBox_SetCurSel(lb, sel);
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
+ break;
+ }
}
}
}
- }
- else if (LOWORD(wParam) == IDC_DOWNLOAD)
- {
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- while (ListBox_DeleteString(lb, 0) > 0);
- SelectLbConfigure(hwndDlg, -1, optsConfigureData);
- optsConfigureData->tempFormats = pasteToWebs[optsConfigureData->page]->GetFormats();
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
- {
- ListBox_AddString(lb, it->name.c_str());
+ else if (LOWORD(wParam) == IDC_DOWNLOAD) {
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ while (ListBox_DeleteString(lb, 0) > 0);
+ SelectLbConfigure(hwndDlg, -1, optsConfigureData);
+ optsConfigureData->tempFormats = pasteToWebs[optsConfigureData->page]->GetFormats();
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ ListBox_AddString(lb, it->name.c_str());
+ }
+ }
+ else if (LOWORD(wParam) == IDC_RESTORE) {
+ OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
+ while (ListBox_DeleteString(lb, 0) > 0);
+ SelectLbConfigure(hwndDlg, -1, optsConfigureData);
+ optsConfigureData->tempFormats = pasteToWebs[optsConfigureData->page]->GetDefFormats();
+ for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it) {
+ ListBox_AddString(lb, it->name.c_str());
+ }
}
}
- else if (LOWORD(wParam) == IDC_RESTORE)
- {
+ else if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_FORMATTING) {
OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- HWND lb = GetDlgItem(hwndDlg, IDC_FORMATTING);
- while (ListBox_DeleteString(lb, 0) > 0);
- SelectLbConfigure(hwndDlg, -1, optsConfigureData);
- optsConfigureData->tempFormats = pasteToWebs[optsConfigureData->page]->GetDefFormats();
- for (std::list<PasteFormat>::iterator it = optsConfigureData->tempFormats.begin(); it != optsConfigureData->tempFormats.end(); ++it)
- {
- ListBox_AddString(lb, it->name.c_str());
- }
+ int sel = ListBox_GetCurSel(GetDlgItem(hwndDlg, IDC_FORMATTING));
+ SelectLbConfigure(hwndDlg, sel, optsConfigureData);
}
+ return TRUE;
}
- else if (HIWORD(wParam) == LBN_SELCHANGE && LOWORD(wParam) == IDC_FORMATTING)
- {
- OptsConfigureData* optsConfigureData = (OptsConfigureData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- int sel = ListBox_GetCurSel(GetDlgItem(hwndDlg, IDC_FORMATTING));
- SelectLbConfigure(hwndDlg, sel, optsConfigureData);
- }
- return TRUE;
- }
case WM_VKEYTOITEM:
- if (LOWORD(wParam) == VK_DELETE && (HWND)lParam == GetDlgItem(hwndDlg, IDC_FORMATTING))
- {
+ if (LOWORD(wParam) == VK_DELETE && (HWND)lParam == GetDlgItem(hwndDlg, IDC_FORMATTING)) {
DlgProcOptsConfigure(hwndDlg, WM_COMMAND, MAKELONG(IDC_DELETE, BN_CLICKED), NULL);
return -2;
}
return -1;
case WM_NOTIFY:
- {
- return TRUE;
- }
+ {
+ return TRUE;
+ }
}
return FALSE;
@@ -643,41 +571,37 @@ INT_PTR CALLBACK Options::DlgProcOptsConfigure(HWND hwndDlg, UINT msg, WPARAM wP INT_PTR CALLBACK Options::DlgProcOptsLogin(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
+ switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
- Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_USER), 99);
- Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_PASSWORD), 99);
- return TRUE;
- }
+ {
+ TranslateDialogDefault(hwndDlg);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_USER), 99);
+ Edit_LimitText(GetDlgItem(hwndDlg, IDC_PASTEBIN_PASSWORD), 99);
+ return TRUE;
+ }
case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED)
{
- if (LOWORD(wParam) == IDOK)
- {
- TCHAR buf[100];
- OptsLoginData* optsLoginData = (OptsLoginData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_USER), buf, 100);
- optsLoginData->user = buf;
- Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_PASSWORD), buf, 100);
- optsLoginData->password = buf;
- EndDialog(hwndDlg, IDOK);
- }
- else if (LOWORD(wParam) == IDCANCEL)
- {
- EndDialog(hwndDlg, IDCANCEL);
+ if (HIWORD(wParam) == BN_CLICKED) {
+ if (LOWORD(wParam) == IDOK) {
+ TCHAR buf[100];
+ OptsLoginData* optsLoginData = (OptsLoginData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_USER), buf, 100);
+ optsLoginData->user = buf;
+ Edit_GetText(GetDlgItem(hwndDlg, IDC_PASTEBIN_PASSWORD), buf, 100);
+ optsLoginData->password = buf;
+ EndDialog(hwndDlg, IDOK);
+ }
+ else if (LOWORD(wParam) == IDCANCEL) {
+ EndDialog(hwndDlg, IDCANCEL);
+ }
}
+ return TRUE;
}
- return TRUE;
- }
case WM_NOTIFY:
- {
- return TRUE;
- }
+ {
+ return TRUE;
+ }
}
return FALSE;
@@ -686,14 +610,12 @@ INT_PTR CALLBACK Options::DlgProcOptsLogin(HWND hwndDlg, UINT msg, WPARAM wParam unsigned int Options::GetCodepageCB(HWND hwndCB, bool errorReport, unsigned int defCp)
{
int selCpIdx = ComboBox_GetCurSel(hwndCB);
- if (selCpIdx < 0)
- {
+ if (selCpIdx < 0) {
TCHAR text[128];
ComboBox_GetText(hwndCB, text, 128);
TCHAR * stopOn = NULL;
long cp = _tcstol(text, &stopOn, 10);
- if (errorReport && (stopOn == text || *stopOn != '\0' || cp < 0 || cp > 0xffff))
- {
+ if (errorReport && (stopOn == text || *stopOn != '\0' || cp < 0 || cp > 0xffff)) {
MessageBox(GetParent(hwndCB), TranslateT("You've entered invalid codepage. Select codepage from combo box or enter correct number."), TranslateT("Invalid codepage"), MB_OK | MB_ICONERROR);
SetFocus(hwndCB);
SetCodepageCB(hwndCB, defCp);
@@ -716,21 +638,18 @@ void Options::InitCodepageCB(HWND hwndCB, unsigned int codepage) {
int cpCount = sizeof(cpTable) / sizeof(cpTable[0]);
int selCpIdx = -1;
- for (int i = 0; i < cpCount; ++i)
- {
+ for (int i = 0; i < cpCount; ++i) {
ComboBox_AddString(hwndCB, TranslateTS(cpTable[i].cpName));
if (cpTable[i].cpId == codepage)
selCpIdx = i;
}
- if (selCpIdx == -1)
- {
+ if (selCpIdx == -1) {
TCHAR buf[10];
mir_sntprintf(buf, _T("%d"), codepage);
ComboBox_SetText(hwndCB, buf);
}
- else
- {
+ else {
ComboBox_SetCurSel(hwndCB, selCpIdx);
}
@@ -741,20 +660,17 @@ void Options::SetCodepageCB(HWND hwndCB, unsigned int codepage) {
int cpCount = sizeof(cpTable) / sizeof(cpTable[0]);
int selCpIdx = -1;
- for (int i = 0; i < cpCount; ++i)
- {
+ for (int i = 0; i < cpCount; ++i) {
if (cpTable[i].cpId == codepage)
selCpIdx = i;
}
- if (selCpIdx == -1)
- {
+ if (selCpIdx == -1) {
TCHAR buf[10];
mir_sntprintf(buf, _T("%d"), codepage);
ComboBox_SetText(hwndCB, buf);
}
- else
- {
+ else {
ComboBox_SetCurSel(hwndCB, selCpIdx);
}
}
@@ -787,13 +703,11 @@ void Options::Save() db_set_b(0, MODULE, "autoUTF", autoUTF ? 1 : 0);
db_set_b(0, MODULE, "confDlg", confDlg ? 1 : 0);
db_set_b(0, MODULE, "autoSend", autoSend ? 1 : 0);
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
char buf[256];
TCHAR* name = pasteToWebs[i]->GetName();
int j = 0;
- while (name[j])
- {
+ while (name[j]) {
buf[j] = (char)name[j];
++j;
}
@@ -801,8 +715,7 @@ void Options::Save() mir_strncpy(buf + j, "formats", _countof(buf) - j);
std::wstring forms;
- for (std::list<PasteFormat>::iterator it = webOptions[i]->formats.begin(); it != webOptions[i]->formats.end(); ++it)
- {
+ for (std::list<PasteFormat>::iterator it = webOptions[i]->formats.begin(); it != webOptions[i]->formats.end(); ++it) {
forms += it->id + L'=' + it->name + L';';
}
@@ -811,26 +724,22 @@ void Options::Save() mir_strncpy(buf + j, "defFormatId", _countof(buf) - j);
db_set_ws(0, MODULE, buf, webOptions[i]->defFormatId.c_str());
- if (webOptions[i]->isSendFileName)
- {
+ if (webOptions[i]->isSendFileName) {
mir_strncpy(buf + j, "sendFileName", _countof(buf) - j);
db_set_b(0, MODULE, buf, webOptions[i]->sendFileName ? 1 : 0);
}
- if (webOptions[i]->isPublicPaste)
- {
+ if (webOptions[i]->isPublicPaste) {
mir_strncpy(buf + j, "publicPaste", _countof(buf) - j);
db_set_b(0, MODULE, buf, webOptions[i]->publicPaste ? 1 : 0);
}
- if (webOptions[i]->isCombo1)
- {
+ if (webOptions[i]->isCombo1) {
mir_strncpy(buf + j, "combo1", _countof(buf) - j);
db_set_ws(0, MODULE, buf, webOptions[i]->combo1.c_str());
}
- if (webOptions[i]->isPastebin)
- {
+ if (webOptions[i]->isPastebin) {
mir_strncpy(buf + j, "pastebinUserKey", _countof(buf) - j);
db_set_ws(0, MODULE, buf, webOptions[i]->pastebinUserKey.c_str());
}
@@ -840,12 +749,9 @@ void Options::Save() void Options::Load()
{
DBVARIANT defWebV;
- if (!db_get_ws(0, MODULE, "defWeb", &defWebV))
- {
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
- if (!mir_wstrcmp(pasteToWebs[i]->GetName(), defWebV.pwszVal))
- {
+ if (!db_get_ws(0, MODULE, "defWeb", &defWebV)) {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
+ if (!mir_wstrcmp(pasteToWebs[i]->GetName(), defWebV.pwszVal)) {
defWeb = i;
break;
}
@@ -856,35 +762,31 @@ void Options::Load() autoUTF = db_get_b(0, MODULE, "autoUTF", 1) ? true : false;
confDlg = db_get_b(0, MODULE, "confDlg", 1) ? true : false;
autoSend = db_get_b(0, MODULE, "autoSend", 0) ? true : false;
- for (int i = 0; i < PasteToWeb::pages; ++i)
- {
+ for (int i = 0; i < PasteToWeb::pages; ++i) {
char buf[256];
- TCHAR* name = pasteToWebs[i]->GetName();
int j = 0;
- while (name[j])
{
- buf[j] = (char)name[j];
- ++j;
+ TCHAR *name = pasteToWebs[i]->GetName();
+ while (name[j]) {
+ buf[j] = (char)name[j];
+ ++j;
+ }
+ buf[j++] = '_';
}
- buf[j++] = '_';
mir_strncpy(buf + j, "formats", _countof(buf) - j);
DBVARIANT forms;
- if (!db_get_ws(0, MODULE, buf, &forms))
- {
+ if (!db_get_ws(0, MODULE, buf, &forms)) {
webOptions[i]->formats.clear();
int k = 0;
- wchar_t * id = forms.pwszVal;
- wchar_t * name = NULL;
- while (forms.pwszVal[k])
- {
- if (forms.pwszVal[k] == L'=')
- {
+ wchar_t *id = forms.pwszVal;
+ wchar_t *name = NULL;
+ while (forms.pwszVal[k]) {
+ if (forms.pwszVal[k] == L'=') {
forms.pwszVal[k] = 0;
name = forms.pwszVal + k + 1;
}
- else if (forms.pwszVal[k] == L';')
- {
+ else if (forms.pwszVal[k] == L';') {
forms.pwszVal[k] = 0;
PasteFormat pf;
pf.id = id;
@@ -901,41 +803,34 @@ void Options::Load() mir_strncpy(buf + j, "defFormatId", _countof(buf) - j);
DBVARIANT defForm;
- if (!db_get_ws(0, MODULE, buf, &defForm))
- {
+ if (!db_get_ws(0, MODULE, buf, &defForm)) {
webOptions[i]->defFormatId = defForm.pwszVal;
db_free(&defForm);
}
- if (webOptions[i]->isSendFileName)
- {
+ if (webOptions[i]->isSendFileName) {
mir_strncpy(buf + j, "sendFileName", _countof(buf) - j);
webOptions[i]->sendFileName = db_get_b(0, MODULE, buf, 1) ? true : false;
}
- if (webOptions[i]->isPublicPaste)
- {
+ if (webOptions[i]->isPublicPaste) {
mir_strncpy(buf + j, "publicPaste", _countof(buf) - j);
webOptions[i]->publicPaste = db_get_b(0, MODULE, buf, 0) ? true : false;
}
- if (webOptions[i]->isCombo1)
- {
+ if (webOptions[i]->isCombo1) {
mir_strncpy(buf + j, "combo1", _countof(buf) - j);
DBVARIANT combo1;
- if (!db_get_ws(0, MODULE, buf, &combo1))
- {
+ if (!db_get_ws(0, MODULE, buf, &combo1)) {
webOptions[i]->combo1 = combo1.pwszVal;
db_free(&combo1);
}
}
- if (webOptions[i]->isPastebin)
- {
+ if (webOptions[i]->isPastebin) {
mir_strncpy(buf + j, "pastebinUserKey", _countof(buf) - j);
DBVARIANT pastebinUserKey;
- if (!db_get_ws(0, MODULE, buf, &pastebinUserKey))
- {
+ if (!db_get_ws(0, MODULE, buf, &pastebinUserKey)) {
webOptions[i]->pastebinUserKey = pastebinUserKey.pwszVal;
db_free(&pastebinUserKey);
}
@@ -944,7 +839,7 @@ void Options::Load() }
WebOptions::WebOptions(int serv)
- :server(serv),
+ : server(serv),
formats(pasteToWebs[serv]->GetDefFormats()),
sendFileName(true),
isSendFileName(true),
@@ -956,7 +851,6 @@ WebOptions::WebOptions(int serv) defFormatId = formats.front().id;
}
-
WebOptions::~WebOptions()
{
}
diff --git a/plugins/Ping/src/collection.h b/plugins/Ping/src/collection.h index 927d3db53d..6e1615ea01 100644 --- a/plugins/Ping/src/collection.h +++ b/plugins/Ping/src/collection.h @@ -1,4 +1,5 @@ -template<class T> class Collection {
+template<class T> class Collection
+{
protected:
unsigned long count;
public:
@@ -11,7 +12,8 @@ public: const unsigned long size() const { return count; }
};
-template<class T> class Node {
+template<class T> class Node
+{
public:
T val;
@@ -19,24 +21,28 @@ public: virtual ~Node() {}
};
-template<class T> class ListNode : public Node < T > {
+template<class T> class ListNode : public Node < T >
+{
public:
ListNode<T> *next, *prev;
ListNode(const T &v) : Node<T>(v), next(0), prev(0) {}
- virtual ~ListNode() {
+ virtual ~ListNode()
+ {
if (next) next->prev = prev;
if (prev) prev->next = next;
}
};
-template<class T> class LinkedList : public Collection < T > {
+template<class T> class LinkedList : public Collection < T >
+{
protected:
ListNode<T> *head, *tail;
public:
- class Iterator {
- friend class LinkedList < T > ;
+ class Iterator
+ {
+ friend class LinkedList < T >;
protected:
ListNode<T> *n;
Iterator(ListNode<T> *start) : n(start) {}
@@ -50,7 +56,8 @@ public: };
LinkedList() : Collection<T>(), head(0), tail(0) {};
- LinkedList(const LinkedList<T> &other) : Collection<T>(), head(0), tail(0) {
+ LinkedList(const LinkedList<T> &other) : Collection<T>(), head(0), tail(0)
+ {
for (Iterator i = other.begin(); i.has_val(); i.next())
add(i.val());
}
@@ -78,7 +85,8 @@ public: virtual Iterator begin() const { return Iterator(head); }
- virtual void add_front(T &val) {
+ virtual void add_front(T &val)
+ {
ListNode<T> *n = new ListNode<T>(val);
n->next = head;
if (head) head->prev = n;
@@ -87,7 +95,8 @@ public: Collection<T>::count++;
}
- virtual void add(const T &val) {
+ virtual void add(const T &val)
+ {
ListNode<T> *n = new ListNode<T>(val);
n->prev = tail;
if (tail) tail->next = n;
@@ -96,7 +105,8 @@ public: Collection<T>::count++;
}
- virtual const bool remove(const T &val) {
+ virtual const bool remove(const T &val)
+ {
ListNode<T> *n = head;
while (n) {
if (n->val == val) {
@@ -114,7 +124,8 @@ public: return false;
}
- virtual const bool contains(T &val) const {
+ virtual const bool contains(T &val) const
+ {
ListNode<T> *n = head;
while (n) {
if (n->val == val) {
@@ -130,15 +141,18 @@ public: // queue/stack functions
// stack - use push/pop
// queue - use push_back/pop
- virtual void push(T val) {
+ virtual void push(T val)
+ {
add_front(val);
}
- virtual void push_back(T &val) {
+ virtual void push_back(T &val)
+ {
add(val);
}
- virtual const bool pop(T &val) {
+ virtual const bool pop(T &val)
+ {
if (!head) return false;
ListNode<T> *n = head;
@@ -155,15 +169,17 @@ public: }
};
-template<class T> class DynamicArray : public Collection < T > {
+template<class T> class DynamicArray : public Collection < T >
+{
protected:
T *ar;
unsigned long initial, limit, increment;
public:
- class Iterator {
- friend class DynamicArray < T > ;
+ class Iterator
+ {
+ friend class DynamicArray < T >;
protected:
T *ar;
unsigned long count;
@@ -178,12 +194,14 @@ public: virtual const bool has_val() { return pos < count; }
};
- DynamicArray(unsigned long init = 0, unsigned long inc = 1) : Collection<T>(), ar(0), initial(init), limit(init), increment(inc) {
+ DynamicArray(unsigned long init = 0, unsigned long inc = 1) : Collection<T>(), ar(0), initial(init), limit(init), increment(inc)
+ {
if (limit) ar = (T *)malloc(limit * sizeof(T));
}
virtual ~DynamicArray() { if (ar) free(ar); }
- virtual void clear() {
+ virtual void clear()
+ {
Collection<T>::count = 0;
limit = initial;
if (limit) ar = (T *)realloc(ar, limit * sizeof(T));
@@ -195,7 +213,8 @@ public: virtual Iterator begin() const { return Iterator(ar, Collection<T>::count, 0); }
- virtual void add(const T &val) {
+ virtual void add(const T &val)
+ {
if (Collection<T>::count == limit) {
limit += increment;
ar = (T *)realloc(ar, limit * sizeof(T));
@@ -205,13 +224,15 @@ public: ar[Collection<T>::count++] = val;
}
- virtual void add_all(DynamicArray<T> &other) {
+ virtual void add_all(DynamicArray<T> &other)
+ {
for (Iterator i = other.begin(); i != pl.end(); ++i) {
add(i.val());
}
}
- virtual const bool remove(const T &val) {
+ virtual const bool remove(const T &val)
+ {
for (unsigned long i = 0; i < Collection<T>::count; i++) {
if (ar[i] == val) {
memmove(ar + i, ar + i + 1, (Collection<T>::count - i) * sizeof(T));
@@ -222,7 +243,8 @@ public: return false;
}
- virtual const bool remove(const unsigned long index) {
+ virtual const bool remove(const unsigned long index)
+ {
if (index >= Collection<T>::count) return false;
memmove(ar + index, ar + index + 1, (Collection<T>::count - index) * sizeof(T));
@@ -230,7 +252,8 @@ public: return true;
}
- virtual const bool insert(const T &val, const unsigned long index) {
+ virtual const bool insert(const T &val, const unsigned long index)
+ {
if (index > Collection<T>::count) return false;
if (Collection<T>::count == limit) {
@@ -246,11 +269,13 @@ public: return true;
}
- virtual T &operator[](const int index) {
+ virtual T &operator[](const int index)
+ {
return ar[index];
}
- const bool index_of(const T &val, unsigned long &index) const {
+ const bool index_of(const T &val, unsigned long &index) const
+ {
for (int i = 0; i < Collection<T>::count; i++) {
if (ar[index] == val) {
index = i;
@@ -260,7 +285,8 @@ public: return false;
}
- const int index_of(const T &val) const {
+ const int index_of(const T &val) const
+ {
for (int i = 0; i < Collection<T>::count; i++) {
if (ar[i] == val) {
return i;
@@ -270,7 +296,8 @@ public: }
// stack functions
- virtual const bool pop(T &val) {
+ virtual const bool pop(T &val)
+ {
if (Collection<T>::count) {
val = ar[Collection<T>::count - 1];
remove(Collection<T>::count - 1);
@@ -279,25 +306,26 @@ public: return false;
}
- virtual void push(const T &val) {
+ virtual void push(const T &val)
+ {
add(val);
}
};
-template<class T> class SortedDynamicArray : public DynamicArray < T > {
+template<class T> class SortedDynamicArray : public DynamicArray < T >
+{
public:
SortedDynamicArray(unsigned long init = 0, unsigned long inc = 1) : DynamicArray<T>(init, inc) {}
virtual ~SortedDynamicArray() {}
- const bool get_index(const T &val, unsigned long &index) {
+ const bool get_index(const T &val, unsigned long &index)
+ {
unsigned long low = 0;
unsigned long high = Collection<T>::count - 1;
- while (high < Collection<T>::count && low <= high)
- {
+ while (high < Collection<T>::count && low <= high) {
unsigned long i = (low + high) / 2;
- if (DynamicArray<T>::ar[i] == val)
- {
+ if (DynamicArray<T>::ar[i] == val) {
index = i;
return true;
}
@@ -312,19 +340,22 @@ public: return false;
}
- virtual void add(const T &val) {
+ virtual void add(const T &val)
+ {
unsigned long index;
get_index(val, index);
insert(val, index);
}
};
-template<class T> class TreeNode : public Node < T > {
+template<class T> class TreeNode : public Node < T >
+{
public:
TreeNode<T> *parent, *left, *right;
TreeNode(const T &v, TreeNode<T> *par) : Node<T>(v), parent(par), left(0), right(0) {}
- virtual ~TreeNode() {
+ virtual ~TreeNode()
+ {
if (parent) {
if (parent->left == this) parent->left = 0;
if (parent->right == this)parent->right = 0;
@@ -332,12 +363,14 @@ public: }
};
-template<class T, class N = TreeNode<T> > class BinaryTree : public Collection < T > {
+template<class T, class N = TreeNode<T> > class BinaryTree : public Collection < T >
+{
protected:
N *root;
- virtual void delete_node(N *n) {
+ virtual void delete_node(N *n)
+ {
if (n->left && n->right) {
N *minmax = n->left;
while (minmax->right) minmax = minmax->right;
@@ -370,7 +403,8 @@ protected: Collection<T>::count--;
}
- virtual void insert_node(N *n) {
+ virtual void insert_node(N *n)
+ {
N *current = root, *parent = 0;
while (current) {
parent = current;
@@ -396,11 +430,13 @@ protected: }
public:
- class Iterator {
- friend class BinaryTree < T, N > ;
+ class Iterator
+ {
+ friend class BinaryTree < T, N >;
protected:
- class EvalNode {
+ class EvalNode
+ {
public:
bool evaluate;
N *node;
@@ -416,7 +452,8 @@ public: LinkedList<EvalNode> stack;
- Iterator(N *start) : n(0) {
+ Iterator(N *start) : n(0)
+ {
if (start) {
stack.push(EvalNode(true, start));
next();
@@ -424,11 +461,12 @@ public: }
public:
- Iterator(const Iterator &other) :n(other.n), stack(other.stack) {}
+ Iterator(const Iterator &other) :n(other.n), stack(other.stack) {}
virtual ~Iterator() {}
virtual T &val() { return n->val; }
- virtual void next() {
+ virtual void next()
+ {
EvalNode en;
bool popped = false;
while ((popped = stack.pop(en)) && en.evaluate) {
@@ -443,20 +481,23 @@ public: };
BinaryTree() : Collection<T>(), root(0) {};
- BinaryTree(BinaryTree<T> &other) : Collection<T>(), root(0) {
+ BinaryTree(BinaryTree<T> &other) : Collection<T>(), root(0)
+ {
for (Iterator i = other.begin(); i != pl.end(); ++i)
add(i.val());
}
virtual ~BinaryTree() { clear(); }
- BinaryTree &operator=(BinaryTree<T> &other) {
+ BinaryTree &operator=(BinaryTree<T> &other)
+ {
clear();
for (Iterator i = other.begin(); i != pl.end(); ++i)
add(i.val());
return *this;
}
- virtual void clear() {
+ virtual void clear()
+ {
N *current = root, *parent = 0;
while (current) {
if (current->left) current = current->left;
@@ -472,12 +513,14 @@ public: Collection<T>::count = 0;
}
- void add(const T &val) {
+ void add(const T &val)
+ {
N *n = new N(val, 0);
insert_node(n);
}
- const bool remove(const T &val) {
+ const bool remove(const T &val)
+ {
N *current = root;
while (current) {
if (current->val == val)
@@ -496,7 +539,8 @@ public: return false;
}
- const bool contains(const T &val) const {
+ const bool contains(const T &val) const
+ {
N *current = root;
while (current) {
if (current->val == val)
@@ -517,13 +561,15 @@ public: #define BLACK 0
// thanks to wikipedia (http://en.wikipedia.org/wiki/Red_black_tree)
-template<class T> class ColouredTreeNode : public Node < T > {
+template<class T> class ColouredTreeNode : public Node < T >
+{
public:
ColouredTreeNode<T> *parent, *left, *right;
char color;
ColouredTreeNode(const T &v, ColouredTreeNode<T> *par) : Node<T>(v), parent(par), left(0), right(0), color(BLACK) {}
- virtual ~ColouredTreeNode() {
+ virtual ~ColouredTreeNode()
+ {
if (parent) {
if (parent->left == this) parent->left = 0;
if (parent->right == this)parent->right = 0;
@@ -531,15 +577,18 @@ public: }
};
-template<class T, class N = ColouredTreeNode<T> > class RedBlackTree : public BinaryTree < T, N > {
+template<class T, class N = ColouredTreeNode<T> > class RedBlackTree : public BinaryTree < T, N >
+{
protected:
- N *grandparent(N *n) {
+ N *grandparent(N *n)
+ {
if (n && n->parent)
return n->parent->parent;
else
return NULL;
}
- N *uncle(N *n) {
+ N *uncle(N *n)
+ {
if (grandparent(n)) {
if (n->parent == grandparent(n)->left)
return grandparent(n)->right;
@@ -549,7 +598,8 @@ protected: else
return NULL;
}
- N *sibling(N *n) {
+ N *sibling(N *n)
+ {
if (n->parent) {
if (n == n->parent->left)
return n->parent->right;
@@ -559,11 +609,13 @@ protected: else
return NULL;
}
- bool is_leaf(N *n) {
+ bool is_leaf(N *n)
+ {
return n == 0;
}
- void replace_node(N *o, N *n) {
+ void replace_node(N *o, N *n)
+ {
n->parent = o->parent;
if (n->parent) {
if (n->parent->left == o) n->parent->left = n;
@@ -573,7 +625,8 @@ protected: BinaryTree<T, N>::root = n;
}
- void rotate_left(N *n) {
+ void rotate_left(N *n)
+ {
N *p = n->right;
N *q = n;
@@ -589,7 +642,8 @@ protected: else
BinaryTree<T, N>::root = p;
}
- void rotate_right(N *n) {
+ void rotate_right(N *n)
+ {
N *p = n->left;
N *q = n;
@@ -606,19 +660,22 @@ protected: BinaryTree<T, N>::root = p;
}
- void insert_case1(N *n) {
+ void insert_case1(N *n)
+ {
if (n->parent == NULL)
n->color = BLACK;
else
insert_case2(n);
}
- void insert_case2(N *n) {
+ void insert_case2(N *n)
+ {
if (n->parent->color == BLACK)
return; /* Tree is still valid */
else
insert_case3(n);
}
- void insert_case3(N *n) {
+ void insert_case3(N *n)
+ {
if (uncle(n) != NULL && uncle(n)->color == RED) {
n->parent->color = BLACK;
uncle(n)->color = BLACK;
@@ -628,7 +685,8 @@ protected: else
insert_case4(n);
}
- void insert_case4(N *n) {
+ void insert_case4(N *n)
+ {
if (n == n->parent->right && n->parent == grandparent(n)->left) {
rotate_left(n->parent);
n = n->left;
@@ -639,7 +697,8 @@ protected: }
insert_case5(n);
}
- void insert_case5(N *n) {
+ void insert_case5(N *n)
+ {
n->parent->color = BLACK;
grandparent(n)->color = RED;
if (n == n->parent->left && n->parent == grandparent(n)->left) {
@@ -651,7 +710,8 @@ protected: }
}
- void delete_case0(N *n) {
+ void delete_case0(N *n)
+ {
/* Precondition: n has at most one non-null child */
N *child = is_leaf(n->right) ? n->left : n->right;
if (child) replace_node(n, child);
@@ -669,13 +729,15 @@ protected: delete n;
Collection<T>::count--;
}
- void delete_case1(N *n) {
+ void delete_case1(N *n)
+ {
if (n->parent == NULL)
return;
else
delete_case2(n);
}
- void delete_case2(N *n) {
+ void delete_case2(N *n)
+ {
if (sibling(n) && sibling(n)->color == RED) {
n->parent->color = RED;
sibling(n)->color = BLACK;
@@ -686,40 +748,40 @@ protected: }
delete_case3(n);
}
- void delete_case3(N *n) {
+ void delete_case3(N *n)
+ {
if (n->parent->color == BLACK &&
sibling(n) &&
sibling(n)->color == BLACK &&
(sibling(n)->left == 0 || sibling(n)->left->color == BLACK) &&
- (sibling(n)->right == 0 || sibling(n)->right->color == BLACK))
- {
+ (sibling(n)->right == 0 || sibling(n)->right->color == BLACK)) {
sibling(n)->color = RED;
delete_case1(n->parent);
}
else
delete_case4(n);
}
- void delete_case4(N *n) {
+ void delete_case4(N *n)
+ {
if (n->parent->color == RED &&
sibling(n) &&
sibling(n)->color == BLACK &&
(sibling(n)->left == 0 || sibling(n)->left->color == BLACK) &&
- (sibling(n)->right == 0 || sibling(n)->right->color == BLACK))
- {
+ (sibling(n)->right == 0 || sibling(n)->right->color == BLACK)) {
sibling(n)->color = RED;
n->parent->color = BLACK;
}
else
delete_case5(n);
}
- void delete_case5(N *n) {
+ void delete_case5(N *n)
+ {
if (n == n->parent->left &&
sibling(n) &&
sibling(n)->color == BLACK &&
sibling(n)->left &&
sibling(n)->left->color == RED &&
- (sibling(n)->right == 0 || sibling(n)->right->color == BLACK))
- {
+ (sibling(n)->right == 0 || sibling(n)->right->color == BLACK)) {
sibling(n)->color = RED;
sibling(n)->left->color = BLACK;
rotate_right(sibling(n));
@@ -729,15 +791,15 @@ protected: sibling(n)->color == BLACK &&
sibling(n)->right &&
sibling(n)->right->color == RED &&
- (sibling(n)->left == 0 || sibling(n)->left->color == BLACK))
- {
+ (sibling(n)->left == 0 || sibling(n)->left->color == BLACK)) {
sibling(n)->color = RED;
sibling(n)->right->color = BLACK;
rotate_left(sibling(n));
}
delete_case6(n);
}
- void delete_case6(N *n) {
+ void delete_case6(N *n)
+ {
sibling(n)->color = n->parent->color;
n->parent->color = BLACK;
if (n == n->parent->left) {
@@ -752,20 +814,23 @@ protected: }
}
- N *get_predecessor(N *n) {
+ N *get_predecessor(N *n)
+ {
N *minmax = n->left;
while (minmax->right) minmax = minmax->right;
return minmax;
}
- virtual void insert_node(N *n) {
+ virtual void insert_node(N *n)
+ {
BinaryTree<T, N>::insert_node(n);
n->color = RED;
insert_case1(n);
}
- virtual void delete_node(N *n) {
+ virtual void delete_node(N *n)
+ {
if (n->left && n->right) {
N *predecessor = get_predecessor(n);
n->val = predecessor->val;
@@ -780,7 +845,8 @@ public: virtual ~RedBlackTree() {}
};
-template<class A, class B> class Pair {
+template<class A, class B> class Pair
+{
public:
A first;
B second;
@@ -796,10 +862,12 @@ public: };
//template<class A, class B, class N = TreeNode<Pair<A, B> > > class Map: public BinaryTree< Pair< A, B >, N > {
-template<class A, class B, class N = ColouredTreeNode<Pair<A, B> > > class Map : public RedBlackTree < Pair< A, B >, N > {
+template<class A, class B, class N = ColouredTreeNode<Pair<A, B> > > class Map : public RedBlackTree < Pair< A, B >, N >
+{
protected:
- N *find(A &key) const {
+ N *find(A &key) const
+ {
N *n = RedBlackTree< Pair< A, B >, N >::root;
while (n) {
if (n->val.first == key)
@@ -817,11 +885,13 @@ public: Map() : RedBlackTree< Pair<A, B>, N >() {}
virtual ~Map() {}
- void put(A &key, B &value) {
+ void put(A &key, B &value)
+ {
add(Pair<A, B>(key, value));
}
- const bool get(A &key, B &val) const {
+ const bool get(A &key, B &val) const
+ {
const N *n = find(key);
if (n) {
val = n->val.second;
@@ -831,28 +901,26 @@ public: return false;
}
- B &operator[](A &key) {
+ B &operator[](A &key)
+ {
N *n = find(key);
if (n)
return n->val.second;
else {
Pair< A, B > p(key);
- N *n = new N(p, 0);
+ n = new N(p, 0);
insert_node(n);
return n->val.second;
}
}
- virtual const bool exists(A &key) const {
- const N *n = find(key);
- if (n) {
- return true;
- }
- else
- return false;
+ virtual const bool exists(A &key) const
+ {
+ return find(key) != NULL;
}
- virtual const bool remove(A &key) {
+ virtual const bool remove(A &key)
+ {
N *n = find(key);
if (n) {
delete_node(n);
diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp index c9b6e87421..ca291c835d 100644 --- a/plugins/Ping/src/pingthread.cpp +++ b/plugins/Ping/src/pingthread.cpp @@ -29,37 +29,41 @@ COLORREF bk_col = RGB(255, 255, 255); static int transparentFocus = 1;
/////////////////
-bool get_thread_finished() {
+bool get_thread_finished()
+{
mir_cslock lck(thread_finished_cs);
bool retval = thread_finished;
return retval;
}
-void set_thread_finished(bool f) {
+void set_thread_finished(bool f)
+{
mir_cslock lck(thread_finished_cs);
thread_finished = f;
}
-bool get_list_changed() {
+bool get_list_changed()
+{
mir_cslock lck(list_changed_cs);
bool retval = list_changed;
return retval;
}
-void set_list_changed(bool f) {
+void set_list_changed(bool f)
+{
mir_cslock lck(list_changed_cs);
list_changed = f;
}
-void SetProtoStatus(TCHAR *pszLabel, char *pszProto, int if_status, int new_status) {
+void SetProtoStatus(TCHAR *pszLabel, char *pszProto, int if_status, int new_status)
+{
if (mir_strcmp(pszProto, Translate("<all>")) == 0) {
int num_protocols;
PROTOACCOUNT **pppDesc;
Proto_EnumAccounts(&num_protocols, &pppDesc);
- for (int i = 0; i < num_protocols; i++) {
+ for (int i = 0; i < num_protocols; i++)
SetProtoStatus(pszLabel, pppDesc[i]->szModuleName, if_status, new_status);
- }
}
else {
if (ProtoServiceExists(pszProto, PS_GETSTATUS)) {
@@ -78,8 +82,7 @@ void SetProtoStatus(TCHAR *pszLabel, char *pszProto, int if_status, int new_stat void __cdecl sttCheckStatusThreadProc(void*)
{
clock_t start_t = clock(), end_t;
- while (!get_thread_finished())
- {
+ while (!get_thread_finished()) {
end_t = clock();
int wait = (int)((options.ping_period - ((end_t - start_t) / (double)CLOCKS_PER_SEC)) * 1000);
@@ -94,35 +97,35 @@ void __cdecl sttCheckStatusThreadProc(void*) bool reply = false;
int count = 0;
- PINGADDRESS pa;
+ PINGADDRESS pa = { 0 };
HistPair history_entry;
-
- mir_cslock lck(data_list_cs);
- set_list_changed(false);
- size_t size = data_list.size();
-
- size_t index = 0;
- for (; index < size; index++)
+ size_t size;
{
mir_cslock lck(data_list_cs);
- size_t c = 0;
- for (pinglist_it i = data_list.begin(); i != data_list.end() && c <= index; ++i, c++)
+ set_list_changed(false);
+ size = data_list.size();
+ }
+
+ size_t index = 0;
+ for (; index < size; index++) {
{
- if (c == index)
- {
- // copy just what we need - i.e. not history, not command
- pa.get_status = i->get_status;
- pa.item_id = i->item_id;
- pa.miss_count = i->miss_count;
- pa.port = i->port;
- mir_tstrncpy(pa.pszLabel, i->pszLabel, _countof(pa.pszLabel));
- mir_tstrncpy(pa.pszName, i->pszName, _countof(pa.pszName));
- mir_strncpy(pa.pszProto, i->pszProto, _countof(pa.pszProto));
- pa.set_status = i->set_status;
- pa.status = i->status;
- break;
+ mir_cslock lck(data_list_cs);
+ size_t c = 0;
+ for (pinglist_it i = data_list.begin(); i != data_list.end() && c <= index; ++i, c++) {
+ if (c == index) {
+ // copy just what we need - i.e. not history, not command
+ pa.get_status = i->get_status;
+ pa.item_id = i->item_id;
+ pa.miss_count = i->miss_count;
+ pa.port = i->port;
+ mir_tstrncpy(pa.pszLabel, i->pszLabel, _countof(pa.pszLabel));
+ mir_tstrncpy(pa.pszName, i->pszName, _countof(pa.pszName));
+ mir_strncpy(pa.pszProto, i->pszProto, _countof(pa.pszProto));
+ pa.set_status = i->set_status;
+ pa.status = i->status;
+ break;
+ }
}
-
}
if (get_thread_finished()) break;
@@ -132,12 +135,9 @@ void __cdecl sttCheckStatusThreadProc(void*) if (!options.no_test_icon) {
mir_cslock lck(data_list_cs);
for (pinglist_it i = data_list.begin(); i != data_list.end(); ++i)
- {
if (i->item_id == pa.item_id)
- {
i->status = PS_TESTING;
- }
- }
+
InvalidateRect(list_hwnd, 0, FALSE);
}
@@ -146,42 +146,40 @@ void __cdecl sttCheckStatusThreadProc(void*) if (get_thread_finished()) break;
if (get_list_changed()) break;
- mir_cslock lck(data_list_cs);
- for (pinglist_it i = data_list.begin(); i != data_list.end(); ++i)
- {
- if (i->item_id == pa.item_id)
- {
- i->responding = pa.responding;
- i->round_trip_time = pa.round_trip_time;
- history_entry.first = i->round_trip_time;
- history_entry.second = time(0);
- history_map[i->item_id].push_back(history_entry);
- // maintain history (-1 represents no response)
- while (history_map[i->item_id].size() >= MAX_HISTORY)
- //history_map[i->item_id].pop_front();
- history_map[i->item_id].remove(history_map[i->item_id].begin().val());
-
- if (pa.responding)
- {
- if (pa.miss_count > 0)
- pa.miss_count = -1;
- else
- pa.miss_count--;
- pa.status = PS_RESPONDING;
- }
- else
- {
- if (pa.miss_count < 0)
- pa.miss_count = 1;
- else
- pa.miss_count++;
- pa.status = PS_NOTRESPONDING;
+ { mir_cslock lck(data_list_cs);
+
+ for (pinglist_it i = data_list.begin(); i != data_list.end(); ++i) {
+ if (i->item_id == pa.item_id) {
+ i->responding = pa.responding;
+ i->round_trip_time = pa.round_trip_time;
+ history_entry.first = i->round_trip_time;
+ history_entry.second = time(0);
+ history_map[i->item_id].push_back(history_entry);
+ // maintain history (-1 represents no response)
+ while (history_map[i->item_id].size() >= MAX_HISTORY)
+ //history_map[i->item_id].pop_front();
+ history_map[i->item_id].remove(history_map[i->item_id].begin().val());
+
+ if (pa.responding) {
+ if (pa.miss_count > 0)
+ pa.miss_count = -1;
+ else
+ pa.miss_count--;
+ pa.status = PS_RESPONDING;
+ }
+ else {
+ if (pa.miss_count < 0)
+ pa.miss_count = 1;
+ else
+ pa.miss_count++;
+ pa.status = PS_NOTRESPONDING;
+ }
+
+ i->miss_count = pa.miss_count;
+ i->status = pa.status;
+
+ break;
}
-
- i->miss_count = pa.miss_count;
- i->status = pa.status;
-
- break;
}
}
@@ -189,8 +187,7 @@ void __cdecl sttCheckStatusThreadProc(void*) count++;
if (pa.miss_count == -1 - options.retries ||
- (((-pa.miss_count) % (options.retries + 1)) == 0 && !options.block_reps))
- {
+ (((-pa.miss_count) % (options.retries + 1)) == 0 && !options.block_reps)) {
reply = true;
if (options.show_popup2 && ServiceExists(MS_POPUP_SHOWMESSAGE)) {
ShowPopup(TranslateT("Ping Reply"), pa.pszLabel, 1);
@@ -204,10 +201,8 @@ void __cdecl sttCheckStatusThreadProc(void*) SetProtoStatus(pa.pszLabel, pa.pszProto, pa.get_status, pa.set_status);
}
else {
-
if (pa.miss_count == 1 + options.retries ||
- ((pa.miss_count % (options.retries + 1)) == 0 && !options.block_reps))
- {
+ ((pa.miss_count % (options.retries + 1)) == 0 && !options.block_reps)) {
timeout = true;
if (options.show_popup)
ShowPopup(TranslateT("Ping Timeout"), pa.pszLabel, 0);
@@ -241,7 +236,8 @@ void start_ping_thread() status_update_thread = mir_forkthread(sttCheckStatusThreadProc, 0);
}
-void stop_ping_thread() {
+void stop_ping_thread()
+{
set_thread_finished(true);
SetEvent(hWakeEvent);
//ICMP::get_instance()->stop();
@@ -251,14 +247,16 @@ void stop_ping_thread() { status_update_thread = 0;
}
-bool FrameIsFloating() {
+bool FrameIsFloating()
+{
if (frame_id == -1)
return true; // no frames, always floating
return (CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS, MAKEWPARAM(FO_FLOATING, frame_id), 0) != 0);
}
-int FillList(WPARAM, LPARAM) {
+int FillList(WPARAM, LPARAM)
+{
if (options.logging)
CallService(PLUG "/Log", (WPARAM)_T("ping address list reload"), 0);
@@ -267,20 +265,19 @@ int FillList(WPARAM, LPARAM) { CallService(PLUG "/GetPingList", 0, (LPARAM)&pl);
SendMessage(list_hwnd, WM_SETREDRAW, FALSE, 0);
- mir_cslock lck(data_list_cs);
-
- data_list = pl;
- SendMessage(list_hwnd, LB_RESETCONTENT, 0, 0);
-
- int index = 0;
- for (pinglist_it j = data_list.begin(); j != data_list.end(); ++j, index++)
{
- SendMessage(list_hwnd, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)&(*j));
- }
- set_list_changed(true);
+ mir_cslock lck(data_list_cs);
+ data_list = pl;
+ SendMessage(list_hwnd, LB_RESETCONTENT, 0, 0);
- list_size = data_list.size();
+ int index = 0;
+ for (pinglist_it j = data_list.begin(); j != data_list.end(); ++j, index++) {
+ SendMessage(list_hwnd, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)&(*j));
+ }
+ set_list_changed(true);
+ list_size = data_list.size();
+ }
SendMessage(list_hwnd, WM_SETREDRAW, TRUE, 0);
InvalidateRect(list_hwnd, 0, FALSE);
@@ -295,8 +292,7 @@ int FillList(WPARAM, LPARAM) { INT_PTR PingPlugShowWindow(WPARAM, LPARAM)
{
- if (hpwnd)
- {
+ if (hpwnd) {
if (frame_id != -1 && ServiceExists(MS_CLIST_FRAMES_SHFRAME))
CallService(MS_CLIST_FRAMES_SHFRAME, (WPARAM)frame_id, 0);
else
@@ -305,16 +301,11 @@ INT_PTR PingPlugShowWindow(WPARAM, LPARAM) return 0;
}
-#define TIMER_ID 11042
-void CALLBACK TimerProc(
- HWND , // handle to window
- UINT, // WM_TIMER message
- UINT_PTR, // timer identifier
- DWORD // current system time
- )
+#define TIMER_ID 11042
+
+void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
{
- if (frame_id != -1 && ServiceExists(MS_CLIST_FRAMES_ADDFRAME))
- {
+ if (frame_id != -1 && ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
TCHAR TBcapt[255];
if (total > 0)
mir_sntprintf(TBcapt, _countof(TBcapt), _T("Ping (%d/%d)"), upCount, total);
@@ -325,11 +316,6 @@ void CALLBACK TimerProc( CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS, MAKEWPARAM(FO_TBTIPNAME | FO_TCHAR, frame_id), (LPARAM)TBcapt);
CallService(MS_CLIST_FRAMES_UPDATEFRAME, frame_id, FU_TBREDRAW);
}
- else {
- // if(options.attach_to_clist) {
- // AttachToClist(true);
- // }
- }
}
DWORD context_point;
@@ -340,13 +326,11 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar MEASUREITEMSTRUCT *mis;
LPDRAWITEMSTRUCT dis;
SIZE textSize;
- PINGADDRESS itemData;
RECT r;
LPARAM lp;
int sel;
- switch (msg)
- {
+ switch (msg) {
case WM_MEASUREITEM:
mis = (MEASUREITEMSTRUCT *)lParam;
@@ -360,25 +344,25 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar HBRUSH ttbrush = 0;
COLORREF tcol;
if (dis->itemID != -1) {
- mir_cslock lck(data_list_cs);
- itemData = *(PINGADDRESS *)dis->itemData;
-
+ PINGADDRESS itemData;
+ {
+ mir_cslock lck(data_list_cs);
+ itemData = *(PINGADDRESS *)dis->itemData;
+ }
SendMessage(list_hwnd, LB_SETITEMHEIGHT, 0, (LPARAM)options.row_height);
- //dis->rcItem.bottom = dis->rcItem.top + options.row_height;
LONG x, y;
if (context_point_valid) {
- RECT r;
GetWindowRect(list_hwnd, &r);
- x = LOWORD(context_point) - r.left,
- y = HIWORD(context_point) - r.top;
+ x = LOWORD(context_point) - r.left;
+ y = HIWORD(context_point) - r.top;
}
+ else x = y = 0;
GetClientRect(hwnd, &r);
if ((dis->itemState & ODS_SELECTED && dis->itemState & ODS_FOCUS)
- || (context_point_valid && (x >= dis->rcItem.left && x <= dis->rcItem.right) && (y >= dis->rcItem.top && y <= dis->rcItem.bottom)))
- {
+ || (context_point_valid && (x >= dis->rcItem.left && x <= dis->rcItem.right) && (y >= dis->rcItem.top && y <= dis->rcItem.bottom))) {
tcol = db_get_dw(NULL, "CLC", "SelBkColour", GetSysColor(COLOR_HIGHLIGHT));
SetBkColor(dis->hDC, tcol);
FillRect(dis->hDC, &dis->rcItem, (ttbrush = CreateSolidBrush(tcol)));
@@ -398,8 +382,6 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar SetBkMode(dis->hDC, TRANSPARENT);
HICON hIcon = (itemData.status != PS_DISABLED ? (itemData.status == PS_TESTING ? hIconTesting : (itemData.status == PS_RESPONDING ? hIconResponding : hIconNotResponding)) : hIconDisabled);
dis->rcItem.left += options.indent;
- //DrawIconEx(dis->hDC,dis->rcItem.left,(dis->rcItem.top + dis->rcItem.bottom - GetSystemMetrics(SM_CYSMICON))>>1,hIcon,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),0,NULL,DI_NORMAL);
- //DrawIconEx(dis->hDC,dis->rcItem.left,(dis->rcItem.top + dis->rcItem.bottom - GetSystemMetrics(SM_CYSMICON))>>1,hIcon,0, 0, 0, NULL, DI_NORMAL);
DrawIconEx(dis->hDC, dis->rcItem.left, dis->rcItem.top + ((options.row_height - 16) >> 1), hIcon, 0, 0, 0, NULL, DI_NORMAL);
GetTextExtentPoint32(dis->hDC, itemData.pszLabel, (int)mir_tstrlen(itemData.pszLabel), &textSize);
@@ -423,81 +405,72 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if (ttbrush) DeleteObject(ttbrush);
return TRUE;
}
- //return DefWindowProc(hwnd, msg, wParam, lParam);
return TRUE;
case WM_CTLCOLORLISTBOX:
- {
- if (tbrush) DeleteObject(tbrush);
-
- return (BOOL)(tbrush = CreateSolidBrush(bk_col));
- }
+ if (tbrush)
+ DeleteObject(tbrush);
+ return (INT_PTR)(tbrush = CreateSolidBrush(bk_col));
case WM_ERASEBKGND:
- {
- RECT r;
GetClientRect(hwnd, &r);
- if (!tbrush) tbrush = CreateSolidBrush(bk_col);
+ if (!tbrush)
+ tbrush = CreateSolidBrush(bk_col);
FillRect((HDC)wParam, &r, tbrush);
- }
- return TRUE;
+ return TRUE;
case WM_CONTEXTMENU:
- {
- context_point = lParam;
- context_point_valid = true;
- InvalidateRect(list_hwnd, 0, FALSE);
- HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)),
- submenu = GetSubMenu(menu, 0);
-
- POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
-
- RECT r;
- GetClientRect(list_hwnd, &r);
- ScreenToClient(list_hwnd, &pt);
-
- DWORD item = SendMessage(list_hwnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
- bool found = false;
- if (HIWORD(item) == 0) {
- int count = LOWORD(item);
- mir_cslock lck(data_list_cs);
- if (count >= 0 && count < (int)data_list.size()) {
- itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
- found = true;
+ {
+ context_point = lParam;
+ context_point_valid = true;
+ InvalidateRect(list_hwnd, 0, FALSE);
+ HMENU menu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_MENU1)),
+ submenu = GetSubMenu(menu, 0);
+
+ POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
+
+ GetClientRect(list_hwnd, &r);
+ ScreenToClient(list_hwnd, &pt);
+
+ PINGADDRESS itemData;
+ DWORD item = SendMessage(list_hwnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(pt.x, pt.y));
+ bool found = false;
+ if (HIWORD(item) == 0) {
+ int count = LOWORD(item);
+ mir_cslock lck(data_list_cs);
+ if (count >= 0 && count < (int)data_list.size()) {
+ itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
+
+ found = true;
+ EnableMenuItem(submenu, ID_MENU_GRAPH, MF_BYCOMMAND | MF_ENABLED);
+ EnableMenuItem(submenu, ID_MENU_EDIT, MF_BYCOMMAND | MF_ENABLED);
+ EnableMenuItem(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_ENABLED);
+ if (itemData.status == PS_DISABLED)
+ ModifyMenu(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_MENU_TOGGLE, TranslateT("Enable"));
+ else
+ ModifyMenu(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_MENU_TOGGLE, TranslateT("Disable"));
+ }
}
- }
- if (found) {
- EnableMenuItem(submenu, ID_MENU_GRAPH, MF_BYCOMMAND | MF_ENABLED);
- EnableMenuItem(submenu, ID_MENU_EDIT, MF_BYCOMMAND | MF_ENABLED);
- EnableMenuItem(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_ENABLED);
- if (itemData.status == PS_DISABLED) {
- ModifyMenu(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_MENU_TOGGLE, TranslateT("Enable"));
+ if (!found) {
+ EnableMenuItem(submenu, ID_MENU_GRAPH, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(submenu, ID_MENU_EDIT, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_GRAYED);
}
- else {
- ModifyMenu(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_STRING, ID_MENU_TOGGLE, TranslateT("Disable"));
- }
- }
- else {
- EnableMenuItem(submenu, ID_MENU_GRAPH, MF_BYCOMMAND | MF_GRAYED);
- EnableMenuItem(submenu, ID_MENU_EDIT, MF_BYCOMMAND | MF_GRAYED);
- EnableMenuItem(submenu, ID_MENU_TOGGLE, MF_BYCOMMAND | MF_GRAYED);
- }
- TranslateMenu(submenu);
+ TranslateMenu(submenu);
+
+ GetCursorPos(&pt);
+ BOOL ret = TrackPopupMenu(submenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
+ DestroyMenu(menu);
+ if (ret)
+ SendMessage(hwnd, WM_COMMAND, ret, 0);
- //ClientToScreen(list_hwnd, &pt);
- GetCursorPos(&pt);
- BOOL ret = TrackPopupMenu(submenu, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
- DestroyMenu(menu);
- if (ret) {
- SendMessage(hwnd, WM_COMMAND, ret, 0);
+ context_point_valid = false;
+ InvalidateRect(list_hwnd, 0, FALSE);
}
- context_point_valid = false;
- InvalidateRect(list_hwnd, 0, FALSE);
- }
- return TRUE;
+ return TRUE;
case WM_SYSCOLORCHANGE:
SendMessage(list_hwnd, msg, wParam, lParam);
@@ -509,18 +482,17 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar (WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_NOTIFY)
& ~WS_BORDER, 0, 0, 0, 0, hwnd, NULL, hInst, 0);
- if (db_get_b(NULL, "CList", "Transparent", 0))
- {
+ if (db_get_b(NULL, "CList", "Transparent", 0)) {
if (ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
}
else {
-#ifdef WS_EX_LAYERED
+ #ifdef WS_EX_LAYERED
SetWindowLongPtr(hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
-#endif
-#ifdef LWA_ALPHA
+ #endif
+ #ifdef LWA_ALPHA
SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA);
-#endif
+ #endif
}
}
@@ -541,9 +513,9 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar else {
if (db_get_b(NULL, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT)) {
KillTimer(hwnd, TM_AUTOALPHA);
-#ifdef LWA_ALPHA
+ #ifdef LWA_ALPHA
SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA);
-#endif
+ #endif
transparentFocus = 1;
}
}
@@ -552,9 +524,9 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case WM_SETCURSOR:
if (db_get_b(NULL, "CList", "Transparent", SETTING_TRANSPARENT_DEFAULT)) {
if (!transparentFocus && GetForegroundWindow() != hwnd) {
-#ifdef LWA_ALPHA
+ #ifdef LWA_ALPHA
SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA);
-#endif
+ #endif
transparentFocus = 1;
SetTimer(hwnd, TM_AUTOALPHA, 250, NULL);
}
@@ -562,8 +534,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar return DefWindowProc(hwnd, msg, wParam, lParam);
case WM_TIMER:
- if ((int)wParam == TM_AUTOALPHA)
- {
+ if ((int)wParam == TM_AUTOALPHA) {
int inwnd;
if (GetForegroundWindow() == hwnd) {
@@ -578,13 +549,12 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar hwndPt = WindowFromPoint(pt);
inwnd = (hwndPt == hwnd || GetParent(hwndPt) == hwnd);
}
- if (inwnd != transparentFocus)
- { //change
+ if (inwnd != transparentFocus) { //change
transparentFocus = inwnd;
-#ifdef LWA_ALPHA
+ #ifdef LWA_ALPHA
if (transparentFocus) SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_ALPHA_DEFAULT), LWA_ALPHA);
else SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)db_get_b(NULL, "CList", "AutoAlpha", SETTING_AUTOALPHA_DEFAULT), LWA_ALPHA);
-#endif
+ #endif
}
if (!transparentFocus) KillTimer(hwnd, TM_AUTOALPHA);
return TRUE;
@@ -592,135 +562,103 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar return FALSE;
case WM_SHOWWINDOW:
- {
- static int noRecurse = 0;
- if (lParam) break;
- if (noRecurse) break;
- if (!db_get_b(NULL, "CLUI", "FadeInOut", 0))
- break;
-#ifdef WS_EX_LAYERED
- if (GetWindowLongPtr(hwnd, GWL_EXSTYLE)&WS_EX_LAYERED) {
- DWORD thisTick, startTick;
- int sourceAlpha, destAlpha;
- if (wParam) {
- sourceAlpha = 0;
- destAlpha = (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_AUTOALPHA_DEFAULT);
-#ifdef LWA_ALPHA
- SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 0, LWA_ALPHA);
-#endif
- noRecurse = 1;
- ShowWindow(hwnd, SW_SHOW);
- noRecurse = 0;
- }
- else {
- sourceAlpha = (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_AUTOALPHA_DEFAULT);
- destAlpha = 0;
- }
- for (startTick = GetTickCount();;) {
- thisTick = GetTickCount();
- if (thisTick >= startTick + 200) break;
-#ifdef LWA_ALPHA
- SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)(sourceAlpha + (destAlpha - sourceAlpha)*(int)(thisTick - startTick) / 200), LWA_ALPHA);
-#endif
+ {
+ static int noRecurse = 0;
+ if (lParam) break;
+ if (noRecurse) break;
+ if (!db_get_b(NULL, "CLUI", "FadeInOut", 0))
+ break;
+ #ifdef WS_EX_LAYERED
+ if (GetWindowLongPtr(hwnd, GWL_EXSTYLE)&WS_EX_LAYERED) {
+ DWORD thisTick, startTick;
+ int sourceAlpha, destAlpha;
+ if (wParam) {
+ sourceAlpha = 0;
+ destAlpha = (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_AUTOALPHA_DEFAULT);
+ #ifdef LWA_ALPHA
+ SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 0, LWA_ALPHA);
+ #endif
+ noRecurse = 1;
+ ShowWindow(hwnd, SW_SHOW);
+ noRecurse = 0;
+ }
+ else {
+ sourceAlpha = (BYTE)db_get_b(NULL, "CList", "Alpha", SETTING_AUTOALPHA_DEFAULT);
+ destAlpha = 0;
+ }
+ for (startTick = GetTickCount();;) {
+ thisTick = GetTickCount();
+ if (thisTick >= startTick + 200) break;
+ #ifdef LWA_ALPHA
+ SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)(sourceAlpha + (destAlpha - sourceAlpha)*(int)(thisTick - startTick) / 200), LWA_ALPHA);
+ #endif
+ }
+ #ifdef LWA_ALPHA
+ SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)destAlpha, LWA_ALPHA);
+ #endif
}
-#ifdef LWA_ALPHA
- SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), (BYTE)destAlpha, LWA_ALPHA);
-#endif
+ else AnimateWindow(hwnd, 200, AW_BLEND | (wParam ? 0 : AW_HIDE));
+ #endif
}
- else {
- // if(wParam) SetForegroundWindow(hwnd);
- AnimateWindow(hwnd, 200, AW_BLEND | (wParam ? 0 : AW_HIDE));
- //SetWindowPos(label,0,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_FRAMECHANGED);
- }
-#endif
- //int res = DefWindowProc(hwnd, msg, wParam, lParam);
- //return res;
- //break;
- //return FALSE; //break;
return DefWindowProc(hwnd, msg, wParam, lParam);
- }
-
- /*
- case WM_PAINT:
- {
- paintDC = BeginPaint(hwnd, &paintStruct); //
- //SelectObject(paintDC,TitleBarFont);
- //SetBkMode(paintDC,TRANSPARENT);
-
- //paintStruct.fErase=TRUE;
- //color=RGB(1,1,1);
- //brush=CreateSolidBrush(RGB(200,20,20));
-
- //GetClientRect(hwnd,&rect);
- //FillRect(paintDC,&rect,brush);
- //TextOut(paintDC,4,4,"cl1 Bottom window",sizeof("cl1 Bottom window")-1);
- //DeleteObject(brush);
- EndPaint(hwnd, &paintStruct); //
-
- };
- return TRUE;
- */
case WM_COMMAND:
- //CreateServiceFunction("PingPlug/DisableAll", PingPlugDisableAll);
- //CreateServiceFunction("PingPlug/EnableAll", PingPlugEnableAll);
switch (LOWORD(wParam)) {
case ID_MENU_GRAPH:
if (context_point_valid) {
- WORD x = LOWORD(context_point),
- y = HIWORD(context_point);
- RECT r;
+ WORD x = LOWORD(context_point), y = HIWORD(context_point);
GetWindowRect(list_hwnd, &r);
DWORD item = SendMessage(list_hwnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(x - r.left, y - r.top));
if (HIWORD(item) == 0) {
int count = LOWORD(item);
bool found = false;
- mir_cslock lck(data_list_cs);
- if (count >= 0 && count < (int)data_list.size()) {
- itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
- found = true;
+ PINGADDRESS itemData;
+ {
+ mir_cslock lck(data_list_cs);
+ if (count >= 0 && count < (int)data_list.size()) {
+ itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
+ found = true;
+ }
}
if (found)
CallService(PLUG "/ShowGraph", (WPARAM)itemData.item_id, (LPARAM)itemData.pszLabel);
}
}
return TRUE;
+
case ID_MENU_TOGGLE:
if (context_point_valid) {
- WORD x = LOWORD(context_point),
- y = HIWORD(context_point);
- RECT r;
+ WORD x = LOWORD(context_point), y = HIWORD(context_point);
GetWindowRect(list_hwnd, &r);
DWORD item = SendMessage(list_hwnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(x - r.left, y - r.top));
if (HIWORD(item) == 0) {
int count = LOWORD(item);
- bool found = false;
+
mir_cslock lck(data_list_cs);
if (count >= 0 && count < (int)data_list.size()) {
- itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
- found = true;
- }
- if (found)
+ PINGADDRESS itemData = *(PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
CallService(PLUG "/ToggleEnabled", (WPARAM)itemData.item_id, 0);
+ }
}
}
return TRUE;
+
case ID_MENU_EDIT:
if (context_point_valid) {
- WORD x = LOWORD(context_point),
- y = HIWORD(context_point);
- RECT r;
+ WORD x = LOWORD(context_point), y = HIWORD(context_point);
GetWindowRect(list_hwnd, &r);
DWORD item = SendMessage(list_hwnd, LB_ITEMFROMPOINT, 0, MAKELPARAM(x - r.left, y - r.top));
PINGADDRESS *temp = 0;
if (HIWORD(item) == 0) {
int count = LOWORD(item);
- mir_cslock lck(data_list_cs);
- if (count >= 0 && count < (int)data_list.size()) {
- temp = (PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
+ {
+ mir_cslock lck(data_list_cs);
+ if (count >= 0 && count < (int)data_list.size()) {
+ temp = (PINGADDRESS *)SendMessage(list_hwnd, LB_GETITEMDATA, count, 0);
+ }
}
if (temp) {
- itemData = *temp;
+ PINGADDRESS itemData = *temp;
if (Edit(hwnd, itemData)) {
mir_cslock lck(data_list_cs);
*temp = itemData;
@@ -730,42 +668,46 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar }
}
return TRUE;
+
case ID_MENU_DISABLEALLPINGS:
CallService(PLUG "/DisableAll", 0, 0);
return TRUE;
+
case ID_MENU_ENABLEALLPINGS:
CallService(PLUG "/EnableAll", 0, 0);
return TRUE;
+
case ID_MENU_OPTIONS:
- {
- OPENOPTIONSDIALOG oop = { 0 };
- oop.cbSize = sizeof(oop);
- oop.pszGroup = "Network";
- oop.pszPage = "Ping";
- oop.pszTab = "Settings";
- Options_Open(&oop);
- }
- return TRUE;
+ {
+ OPENOPTIONSDIALOG oop = { 0 };
+ oop.cbSize = sizeof(oop);
+ oop.pszGroup = "Network";
+ oop.pszPage = "Ping";
+ oop.pszTab = "Settings";
+ Options_Open(&oop);
+ }
+ return TRUE;
+
case ID_MENU_DESTINATIONS:
- {
- OPENOPTIONSDIALOG oop = { 0 };
- oop.cbSize = sizeof(oop);
- oop.pszGroup = "Network";
- oop.pszPage = "Ping";
- oop.pszTab = "Hosts";
- Options_Open(&oop);
- }
- return TRUE;
+ {
+ OPENOPTIONSDIALOG oop = { 0 };
+ oop.cbSize = sizeof(oop);
+ oop.pszGroup = "Network";
+ oop.pszPage = "Ping";
+ oop.pszTab = "Hosts";
+ Options_Open(&oop);
+ }
+ return TRUE;
}
+
if (HIWORD(wParam) == LBN_DBLCLK) {
sel = SendMessage(list_hwnd, LB_GETCURSEL, 0, 0);
if (sel != LB_ERR) {
lp = SendMessage(list_hwnd, LB_GETITEMDATA, sel, 0);
if (lp != LB_ERR) {
- PINGADDRESS *pItemData = (PINGADDRESS *)lp;
-
mir_cslock lck(data_list_cs);
+ PINGADDRESS *pItemData = (PINGADDRESS *)lp;
if (pItemData) {
DWORD item_id = pItemData->item_id;
@@ -778,7 +720,6 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar mir_sntprintf(buf, _T("%s - %s"), pItemData->pszLabel, (wake ? TranslateT("enabled") : TranslateT("double clicked")));
CallService(PLUG "/Log", (WPARAM)buf, 0);
}
-
}
}
}
@@ -789,26 +730,23 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar case WM_MOVE: // needed for docked frames in clist_mw (not needed in clist_modern)
if (FrameIsFloating())
break;
- case WM_SIZE:
- {
- //PostMessage(label, WM_SIZE, wParam, lParam);
+ case WM_SIZE:
GetClientRect(hwnd, &rect);
- //SetWindowPos(list_hwnd, 0, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER);
- //InvalidateRect(list_hwnd, &rect, FALSE);
- int winheight = rect.bottom - rect.top,
- itemheight = SendMessage(list_hwnd, LB_GETITEMHEIGHT, 0, 0),
- count = SendMessage(list_hwnd, LB_GETCOUNT, 0, 0),
-#ifdef min
- height = min(winheight - winheight % itemheight, itemheight * count);
-#else
- height = std::min(winheight - winheight % itemheight, itemheight * count);
-#endif
- SetWindowPos(list_hwnd, 0, rect.left, rect.top, rect.right - rect.left, height, SWP_NOZORDER);
- InvalidateRect(list_hwnd, 0, FALSE);
- }
- InvalidateRect(hwnd, 0, TRUE);
- return DefWindowProc(hwnd, msg, wParam, lParam);
+ {
+ int winheight = rect.bottom - rect.top,
+ itemheight = SendMessage(list_hwnd, LB_GETITEMHEIGHT, 0, 0),
+ count = SendMessage(list_hwnd, LB_GETCOUNT, 0, 0),
+ #ifdef min
+ height = min(winheight - winheight % itemheight, itemheight * count);
+ #else
+ height = std::min(winheight - winheight % itemheight, itemheight * count);
+ #endif
+ SetWindowPos(list_hwnd, 0, rect.left, rect.top, rect.right - rect.left, height, SWP_NOZORDER);
+ InvalidateRect(list_hwnd, 0, FALSE);
+ }
+ InvalidateRect(hwnd, 0, TRUE);
+ return DefWindowProc(hwnd, msg, wParam, lParam);
case WM_DESTROY:
if (!ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) {
@@ -829,37 +767,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar return 0;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
- /*
- case WM_POWERBROADCAST:
-
- if(options.logging) {
- std::ostringstream oss;
- switch(wParam) {
- case PBT_APMSUSPEND:
- CallService("PingPlug/Log", (WPARAM)"system suspend", 0);
- break;
- case PBT_APMRESUMESUSPEND:
- oss << "system resume";
- if(lParam == PBTF_APMRESUMEFROMFAILURE)
- oss << " [suspend failure!]";
- CallService("PingPlug/Log", (WPARAM)oss.str().c_str(), 0);
- break;
- case PBT_APMRESUMEAUTOMATIC:
- oss << "system resume (automatic)";
- if(lParam == PBTF_APMRESUMEFROMFAILURE)
- oss << " [suspend failure!]";
- CallService("PingPlug/Log", (WPARAM)oss.str().c_str(), 0);
- break;
- case PBT_APMRESUMECRITICAL:
- oss << "system resume (critical)";
- if(lParam == PBTF_APMRESUMEFROMFAILURE)
- oss << " [suspend failure!]";
- CallService("PingPlug/Log", (WPARAM)oss.str().c_str(), 0);
- break;
- }
- }
- break;
- */
+
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
@@ -868,7 +776,8 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar return(TRUE);
};
-int ReloadFont(WPARAM, LPARAM) {
+int ReloadFont(WPARAM, LPARAM)
+{
if (hFont) DeleteObject(hFont);
LOGFONT log_font;
@@ -882,13 +791,15 @@ int ReloadFont(WPARAM, LPARAM) { return 0;
}
-int RefreshWindow(WPARAM, LPARAM) {
+int RefreshWindow(WPARAM, LPARAM)
+{
InvalidateRect(list_hwnd, 0, TRUE);
InvalidateRect(hpwnd, 0, TRUE);
return 0;
}
-void UpdateFrame() {
+void UpdateFrame()
+{
if (IsWindowVisible(hwnd_clist) != IsWindowVisible(hpwnd))
ShowWindow(hpwnd, IsWindowVisible(hwnd_clist) ? SW_SHOW : SW_HIDE);
@@ -916,8 +827,7 @@ LRESULT APIENTRY ClistSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l if (uMsg == WM_NCCALCSIZE) { // possible window style change
if (GetWindowLongPtr(hwnd_clist, GWL_STYLE) != GetWindowLong(hpwnd, GWL_STYLE)
- || GetWindowLongPtr(hwnd_clist, GWL_STYLE) != GetWindowLongPtr(hpwnd, GWL_STYLE))
- {
+ || GetWindowLongPtr(hwnd_clist, GWL_STYLE) != GetWindowLongPtr(hpwnd, GWL_STYLE)) {
SetWindowLongPtr(hpwnd, GWL_STYLE, GetWindowLongPtr(hwnd_clist, GWL_STYLE));
SetWindowLongPtr(hpwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd_clist, GWL_EXSTYLE));
SetWindowPos(hpwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
@@ -1035,8 +945,9 @@ void InitList() start_ping_thread();
}
-void DeinitList() {
+void DeinitList()
+{
DestroyWindow(hpwnd);
stop_ping_thread();
if (hFont) DeleteObject(hFont);
-}
\ No newline at end of file +}
diff --git a/plugins/Popup/Popup.vcxproj b/plugins/Popup/Popup.vcxproj index 4e7e70524e..4499109c4e 100644 --- a/plugins/Popup/Popup.vcxproj +++ b/plugins/Popup/Popup.vcxproj @@ -25,4 +25,9 @@ <ImportGroup Label="PropertySheets">
<Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" />
</ImportGroup>
+ <ItemDefinitionGroup>
+ <ClCompile>
+ <ExceptionHandling>Sync</ExceptionHandling>
+ </ClCompile>
+ </ItemDefinitionGroup>
</Project>
\ No newline at end of file diff --git a/plugins/Popup/src/effects.cpp b/plugins/Popup/src/effects.cpp index ede4d633f1..dfc8139d08 100644 --- a/plugins/Popup/src/effects.cpp +++ b/plugins/Popup/src/effects.cpp @@ -37,17 +37,17 @@ protected: int alpha;
public:
- virtual void beginEffect(int w, int h, int alpha0, int alpha1, int frameCount)
+ virtual void beginEffect(int _w, int _h, int _alpha0, int _alpha1, int _frameCount)
{
- this->w = w;
- this->h = h;
- this->alpha0 = alpha0;
- this->alpha1 = alpha1;
- this->frameCount = frameCount;
+ w = _w;
+ h = _h;
+ alpha0 = _alpha0;
+ alpha1 = _alpha1;
+ frameCount = _frameCount;
}
- virtual void beginFrame(int frame)
+ virtual void beginFrame(int _frame)
{
- this->frame = frame;
+ frame = _frame;
stage = (frame * 2 > frameCount) ? 1 : 0;
if (stage == 0)
alpha = alpha0 + (alpha1 - alpha0) * frame * 2 / frameCount;
diff --git a/plugins/Popup/src/opt_adv.cpp b/plugins/Popup/src/opt_adv.cpp index 68dd085240..b5fa1f5d20 100644 --- a/plugins/Popup/src/opt_adv.cpp +++ b/plugins/Popup/src/opt_adv.cpp @@ -199,19 +199,16 @@ INT_PTR CALLBACK DlgProcPopupAdvOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM EnableWindow(GetDlgItem(hwnd, IDC_FADEOUT_TXT2), how);
// effects drop down
{
- DWORD dwItem, dwActiveItem = 0;
-
- BOOL how = TRUE;
-
+ how = TRUE;
EnableWindow(GetDlgItem(hwnd, IDC_EFFECT), how);
EnableWindow(GetDlgItem(hwnd, IDC_EFFECT_TXT), how);
HWND hCtrl = GetDlgItem(hwnd, IDC_EFFECT);
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("No effect")), -2);
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateT("Fade in/out")), -1);
- dwActiveItem = (DWORD)PopupOptions.UseEffect;
+ DWORD dwActiveItem = (DWORD)PopupOptions.UseEffect;
for (int i = 0; i < g_lstPopupVfx.getCount(); ++i) {
- dwItem = ComboBox_AddString(hCtrl, TranslateTS(g_lstPopupVfx[i]));
+ DWORD dwItem = ComboBox_AddString(hCtrl, TranslateTS(g_lstPopupVfx[i]));
ComboBox_SetItemData(hCtrl, dwItem, i);
if (PopupOptions.UseEffect && !mir_tstrcmp(g_lstPopupVfx[i], PopupOptions.Effect))
dwActiveItem = dwItem;
diff --git a/plugins/Popup/src/opt_adv.h b/plugins/Popup/src/opt_adv.h index 07e6a96617..6a0c1e66d1 100644 --- a/plugins/Popup/src/opt_adv.h +++ b/plugins/Popup/src/opt_adv.h @@ -24,8 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __opt_adv_h__
#define __opt_adv_h__
-extern HWND hwndBox;
-
void OptAdv_RegisterVfx(char *name);
void OptAdv_UnregisterVfx();
diff --git a/plugins/Popup/src/opt_class.cpp b/plugins/Popup/src/opt_class.cpp index da96d69c60..25a1f78d6f 100644 --- a/plugins/Popup/src/opt_class.cpp +++ b/plugins/Popup/src/opt_class.cpp @@ -315,7 +315,7 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l } // end if (tvi.lParam)
else {
// enable / disable controls
- for (int i = 0; i < _countof(ctrlsAll); ++i) {
+ for (i = 0; i < _countof(ctrlsAll); ++i) {
ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0 ? SW_SHOW : SW_HIDE);
EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0);
}
diff --git a/plugins/Popup/src/popup_wnd2.cpp b/plugins/Popup/src/popup_wnd2.cpp index a0dd244046..efd5aa0086 100644 --- a/plugins/Popup/src/popup_wnd2.cpp +++ b/plugins/Popup/src/popup_wnd2.cpp @@ -1129,7 +1129,7 @@ LRESULT CALLBACK PopupWnd2::WindowProc(UINT message, WPARAM wParam, LPARAM lPara break;
case CURSOR_TIMER:
- POINT pt; GetCursorPos(&pt);
+ GetCursorPos(&pt);
if (abs(pt.x - m_ptPrevCursor.x) + abs(pt.y - m_ptPrevCursor.y) > 4) {
SetWindowLongPtr(m_hwnd, GWL_EXSTYLE, GetWindowLongPtr(m_hwnd, GWL_EXSTYLE) & ~WS_EX_TRANSPARENT);
KillTimer(m_hwnd, CURSOR_TIMER);
diff --git a/plugins/Popup/src/skin.cpp b/plugins/Popup/src/skin.cpp index 723b6f6a41..544069e276 100644 --- a/plugins/Popup/src/skin.cpp +++ b/plugins/Popup/src/skin.cpp @@ -344,7 +344,7 @@ void PopupSkin::measure(HDC hdc, PopupWnd2 *wnd, int maxw, POPUPOPTIONS *options }
else {
HFONT hfnSave = (HFONT)SelectObject(hdc, fonts.clock);
- SIZE sz; GetTextExtentPoint32(hdc, wnd->getTime(), (int)mir_tstrlen(wnd->getTime()), &sz);
+ GetTextExtentPoint32(hdc, wnd->getTime(), (int)mir_tstrlen(wnd->getTime()), &sz);
SelectObject(hdc, hfnSave);
wnd->getArgs()->add("clock.width", sz.cx + 2 * STYLE_SZ_GAP);
wnd->getArgs()->add("clock.height", sz.cy);
@@ -483,16 +483,15 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW else
SetTextColor(hdc, wnd->getTextColor());
{
- POINT pos;
- pos.x = head->fx.eval(wnd->getArgs());
- pos.y = head->fy.eval(wnd->getArgs());
- SIZE sz;
+ POINT pt;
+ pt.x = head->fx.eval(wnd->getArgs());
+ pt.y = head->fy.eval(wnd->getArgs());
sz.cx = wnd->getRenderInfo()->textw;
sz.cy = 1000;
- SetRect(&wnd->getRenderInfo()->textRect, pos.x, pos.y,
- pos.x + wnd->getRenderInfo()->realtextw,
- pos.y + wnd->getRenderInfo()->texth);
+ SetRect(&wnd->getRenderInfo()->textRect, pt.x, pt.y,
+ pt.x + wnd->getRenderInfo()->realtextw,
+ pt.y + wnd->getRenderInfo()->texth);
if ((drawFlags&DF_STATIC) && !wnd->isTextEmpty()) {
HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.text);
@@ -500,13 +499,13 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW switch (wnd->getTextType()) {
case PopupWnd2::TT_UNICODE:
{
- RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy);
+ RECT rc; SetRect(&rc, pt.x, pt.y, pt.x + sz.cx, pt.y + sz.cy);
DrawTextEx(hdc, wnd->getText(), (int)mir_tstrlen(wnd->getText()), &rc,
DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
}
break;
case PopupWnd2::TT_MTEXT:
- MText.Display(hdc, pos, sz, wnd->getTextM());
+ MText.Display(hdc, pt, sz, wnd->getTextM());
break;
}
SelectObject(hdc, hFntSave);
@@ -519,12 +518,12 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW drawActionBar(bmp, wnd,
db_get_b(NULL, MODULNAME, "CenterActions", 0) ?
- (pos.x + (textAreaWidth - wnd->getRenderInfo()->actw) / 2) :
+ (pt.x + (textAreaWidth - wnd->getRenderInfo()->actw) / 2) :
(PopupOptions.actions&ACT_RIGHTICONS) ?
- (pos.x + textAreaWidth - wnd->getRenderInfo()->actw) :
+ (pt.x + textAreaWidth - wnd->getRenderInfo()->actw) :
// else
- pos.x,
- pos.y + wnd->getRenderInfo()->texth + 3);
+ pt.x,
+ pt.y + wnd->getRenderInfo()->texth + 3);
actionsRendered = true;
}
@@ -538,10 +537,9 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW SetTextColor(hdc, wnd->getTitleColor());
{
bmp->saveAlpha();
- POINT pos;
- pos.x = head->fx.eval(wnd->getArgs());
- pos.y = head->fy.eval(wnd->getArgs());
- SIZE sz;
+ POINT pt;
+ pt.x = head->fx.eval(wnd->getArgs());
+ pt.y = head->fy.eval(wnd->getArgs());
sz.cx = wnd->getRenderInfo()->titlew;
sz.cy = 1000;
@@ -549,7 +547,7 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW case PopupWnd2::TT_UNICODE:
{
HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title);
- RECT rc; SetRect(&rc, pos.x, pos.y, pos.x + sz.cx, pos.y + sz.cy);
+ RECT rc; SetRect(&rc, pt.x, pt.y, pt.x + sz.cx, pt.y + sz.cy);
DrawTextEx(hdc, wnd->getTitle(), (int)mir_tstrlen(wnd->getTitle()), &rc,
DT_EXPANDTABS | DT_LEFT | DT_NOPREFIX | DT_TOP | DT_WORDBREAK/*|DT_RTLREADING*/, NULL);
SelectObject(hdc, hFntSave);
@@ -557,7 +555,7 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW break;
case PopupWnd2::TT_MTEXT:
HFONT hFntSave = (HFONT)SelectObject(hdc, fonts.title);
- MText.Display(hdc, pos, sz, wnd->getTitleM());
+ MText.Display(hdc, pt, sz, wnd->getTitleM());
SelectObject(hdc, hFntSave);
break;
}
@@ -690,7 +688,7 @@ void PopupSkin::display(MyBitmap *bmp, PopupWnd2 *wnd, POPUPOPTIONS *options, DW SetTextColor(hdc, wnd->getClockColor());
HFONT hfnSave = (HFONT)SelectObject(bmp->getDC(), fonts.clock);
- SIZE sz; GetTextExtentPoint32(bmp->getDC(), wnd->getTime(), (int)mir_tstrlen(wnd->getTime()), &sz);
+ GetTextExtentPoint32(bmp->getDC(), wnd->getTime(), (int)mir_tstrlen(wnd->getTime()), &sz);
bmp->Draw_Text(wnd->getTime(), x, y);
SelectObject(bmp->getDC(), hfnSave);
}
@@ -1115,7 +1113,7 @@ bool Skins::load() if ((ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && mir_tstrcmp(_T("."), ffd.cFileName) && mir_tstrcmp(_T(".."), ffd.cFileName)) {
SetCurrentDirectory(ffd.cFileName);
- SKINLIST *skin = new SKINLIST;
+ skin = new SKINLIST;
skin->next = m_skins;
m_skins = skin;
m_skins->name = mir_tstrdup(ffd.cFileName);
|