From a56fe59ac345e61c04632dc20785e52aefd1c2e9 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Tue, 14 Jan 2014 14:56:30 +0000 Subject: -Converted Ping to Unicode -Fixed minor bugs (fixes #526) git-svn-id: http://svn.miranda-ng.org/main/trunk@7644 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Ping/ping_10.vcxproj | 8 +- plugins/Ping/ping_11.vcxproj | 8 +- plugins/Ping/ping_12.vcxproj | 8 +- plugins/Ping/src/common.h | 12 +- plugins/Ping/src/log.cpp | 29 ++-- plugins/Ping/src/options.cpp | 367 +++++++++++++++++----------------------- plugins/Ping/src/ping.cpp | 8 +- plugins/Ping/src/pinggraph.cpp | 26 +-- plugins/Ping/src/pinglist.cpp | 34 ++-- plugins/Ping/src/pingthread.cpp | 70 ++++---- plugins/Ping/src/rawping.cpp | 22 +-- plugins/Ping/src/utils.cpp | 60 ++++--- plugins/Ping/src/utils.h | 2 +- 13 files changed, 297 insertions(+), 357 deletions(-) (limited to 'plugins/Ping') diff --git a/plugins/Ping/ping_10.vcxproj b/plugins/Ping/ping_10.vcxproj index de3c728eef..f8d8450949 100644 --- a/plugins/Ping/ping_10.vcxproj +++ b/plugins/Ping/ping_10.vcxproj @@ -25,21 +25,21 @@ DynamicLibrary - MultiByte + Unicode true DynamicLibrary - MultiByte + Unicode DynamicLibrary - MultiByte + Unicode true DynamicLibrary - MultiByte + Unicode diff --git a/plugins/Ping/ping_11.vcxproj b/plugins/Ping/ping_11.vcxproj index 570e9328b9..e83e3c67e9 100644 --- a/plugins/Ping/ping_11.vcxproj +++ b/plugins/Ping/ping_11.vcxproj @@ -25,24 +25,24 @@ DynamicLibrary - MultiByte + Unicode true v110_xp DynamicLibrary - MultiByte + Unicode v110_xp DynamicLibrary - MultiByte + Unicode true v110_xp DynamicLibrary - MultiByte + Unicode v110_xp diff --git a/plugins/Ping/ping_12.vcxproj b/plugins/Ping/ping_12.vcxproj index fb725a33f2..73d63d672a 100644 --- a/plugins/Ping/ping_12.vcxproj +++ b/plugins/Ping/ping_12.vcxproj @@ -25,24 +25,24 @@ DynamicLibrary - MultiByte + Unicode true v120_xp DynamicLibrary - MultiByte + Unicode v120_xp DynamicLibrary - MultiByte + Unicode true v120_xp DynamicLibrary - MultiByte + Unicode v120_xp diff --git a/plugins/Ping/src/common.h b/plugins/Ping/src/common.h index f2d7259c65..35792e7ea7 100644 --- a/plugins/Ping/src/common.h +++ b/plugins/Ping/src/common.h @@ -53,7 +53,7 @@ #define DEFAULT_SHOW_POPUP2 false #define DEFAULT_BLOCK_REPS true #define DEFAULT_LOGGING_ENABLED false -#define DEFAULT_LOG_FILENAME "ping_log.txt" +#define DEFAULT_LOG_FILENAME _T("ping_log.txt") #define DEFAULT_NO_TEST_ICON true #define DEFAULT_ATTACH_TO_CLIST false @@ -63,7 +63,7 @@ typedef struct { int ping_period, ping_timeout; bool show_popup, show_popup2, block_reps, logging; - char log_filename[MAX_PATH]; + TCHAR log_filename[MAX_PATH]; bool no_test_icon; int row_height; int indent; @@ -90,16 +90,16 @@ typedef LinkedList< HistPair > HistoryList; struct PINGADDRESS { int cbSize; //size in bytes of this structure DWORD item_id; - char pszName[MAX_PINGADDRESS_STRING_LENGTH]; //IP address or domain name - char pszLabel[MAX_PINGADDRESS_STRING_LENGTH]; + TCHAR pszName[MAX_PINGADDRESS_STRING_LENGTH]; //IP address or domain name + TCHAR pszLabel[MAX_PINGADDRESS_STRING_LENGTH]; bool responding; int status; short round_trip_time; int miss_count; int port; // -1 for ICMP, non-zero for TCP char pszProto[MAX_PINGADDRESS_STRING_LENGTH]; - char pszCommand[MAX_PATH]; - char pszParams[MAX_PATH]; + TCHAR pszCommand[MAX_PATH]; + TCHAR pszParams[MAX_PATH]; unsigned int get_status; // on success, if status equals this unsigned int set_status; // set it to this int index; diff --git a/plugins/Ping/src/log.cpp b/plugins/Ping/src/log.cpp index ce4d90d752..65695872b9 100644 --- a/plugins/Ping/src/log.cpp +++ b/plugins/Ping/src/log.cpp @@ -1,6 +1,6 @@ #include "common.h" -INT_PTR Log(WPARAM wParam, LPARAM lParam) { +INT_PTR Log(WPARAM wParam, LPARAM) { TCHAR buf[1024], tbuf[512], dbuf[512]; CallService(PLUG "/GetLogFilename", (WPARAM)1024, (LPARAM)buf); @@ -13,14 +13,14 @@ INT_PTR Log(WPARAM wParam, LPARAM lParam) { GetTimeFormat(LOCALE_USER_DEFAULT, 0, &systime, 0, tbuf, 512); GetDateFormat(LOCALE_USER_DEFAULT, 0, &systime, 0, dbuf, 512); - char *line = (char *)wParam; + TCHAR *line = (TCHAR *)wParam; FILE *f = _tfopen(buf, _T("a+")); if(f) { if(options.log_csv) { - fprintf(f, "%s, %s, %s\n", dbuf, tbuf, line); + _ftprintf(f, _T("%s, %s, %s\n"), dbuf, tbuf, line); } else { - fprintf(f, "%s, %s: %s\n", dbuf, tbuf, line); + _ftprintf(f, _T("%s, %s: %s\n"), dbuf, tbuf, line); } fclose(f); } @@ -30,28 +30,27 @@ INT_PTR Log(WPARAM wParam, LPARAM lParam) { INT_PTR GetLogFilename(WPARAM wParam, LPARAM lParam) { DBVARIANT dbv; - char *filename = (char *)lParam; - if(db_get(0, PLUG, "LogFilename", &dbv)) { - CallService(MS_DB_GETPROFILEPATH, (WPARAM)wParam, (LPARAM)filename); - strcat(filename, "\\"); - strcat(filename, "ping_log.txt"); + TCHAR *filename = (TCHAR *)lParam; + if(db_get_ts(0, PLUG, "LogFilename", &dbv)) { + CallService(MS_DB_GETPROFILEPATHT, wParam, (LPARAM)filename); + _tcsncat(filename, _T("\\ping_log.txt"),wParam); } else { - strncpy(filename, dbv.pszVal, wParam); + _tcsncpy(filename, dbv.ptszVal, wParam); db_free(&dbv); } - ((char *)lParam)[wParam - 1] = 0; + ((TCHAR *)lParam)[wParam - 1] = 0; return 0; } -INT_PTR SetLogFilename(WPARAM wParam, LPARAM lParam) { - db_set_s(0, PLUG, "LogFilename", (char *)lParam); +INT_PTR SetLogFilename(WPARAM, LPARAM lParam) { + db_set_ts(0, PLUG, "LogFilename", (TCHAR *)lParam); return 0; } -INT_PTR ViewLogData(WPARAM wParam, LPARAM lParam) { - char buf[1024]; +INT_PTR ViewLogData(WPARAM wParam, LPARAM) { + TCHAR buf[MAX_PATH]; CallService(PLUG "/GetLogFilename", (WPARAM)MAX_PATH, (LPARAM)buf); return (INT_PTR)ShellExecute((HWND)wParam, _T("edit"), buf, _T(""), _T(""), SW_SHOW); } diff --git a/plugins/Ping/src/options.cpp b/plugins/Ping/src/options.cpp index b8d08b20d4..e5a2a7dea8 100644 --- a/plugins/Ping/src/options.cpp +++ b/plugins/Ping/src/options.cpp @@ -5,17 +5,13 @@ PingOptions options; // main ping options static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - HWND hw; - OPENFILENAME ofn = {0}; - switch ( msg ) { case WM_INITDIALOG: { TranslateDialogDefault( hwndDlg ); - if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { - hw = GetDlgItem(hwndDlg, IDC_CHK_ATTACH); - EnableWindow(hw, FALSE); - } + if(ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ATTACH), FALSE); + CheckDlgButton(hwndDlg, IDC_CHK_ATTACH, options.attach_to_clist); SetDlgItemInt(hwndDlg, IDC_PPM, options.ping_period, FALSE); @@ -27,30 +23,24 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA CheckDlgButton(hwndDlg, IDC_CHK_LOGCSV, options.log_csv); CheckDlgButton(hwndDlg, IDC_CHK_NOTESTICON, options.no_test_icon); - SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 0)); - SendMessage(GetDlgItem(hwndDlg, IDC_SP_INDENT), UDM_SETPOS, 0, options.indent); - SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 6)); - SendMessage(GetDlgItem(hwndDlg, IDC_SP_ROWHEIGHT), UDM_SETPOS, 0, options.row_height); + SendDlgItemMessage(hwndDlg, IDC_SP_INDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 0)); + SendDlgItemMessage(hwndDlg, IDC_SP_INDENT, UDM_SETPOS, 0, options.indent); + SendDlgItemMessage(hwndDlg, IDC_SP_ROWHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(500, 6)); + SendDlgItemMessage(hwndDlg, IDC_SP_ROWHEIGHT, UDM_SETPOS, 0, options.row_height); SetDlgItemInt(hwndDlg, IDC_RPT, options.retries, FALSE); SetDlgItemText(hwndDlg, IDC_ED_FILENAME, options.log_filename); if(!options.logging) { - hw = GetDlgItem(hwndDlg, IDC_ED_FILENAME); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_BTN_LOGBROWSE); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_CHK_LOGCSV); - EnableWindow(hw, FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_ED_FILENAME), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_LOGBROWSE), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_LOGCSV), FALSE); } - if( !ServiceExists( MS_POPUP_ADDPOPUP )) { - hw = GetDlgItem(hwndDlg, IDC_CHECKPOPUP); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_CHECKPOPUP2); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_CHK_BLOCK); - EnableWindow(hw, FALSE); + if( !ServiceExists( MS_POPUP_ADDPOPUPT )) { + EnableWindow(GetDlgItem(hwndDlg, IDC_CHECKPOPUP), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHECKPOPUP2), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_BLOCK), FALSE); } return TRUE; } @@ -74,12 +64,9 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA if ( HIWORD( wParam ) == BN_CLICKED ) { switch( LOWORD( wParam )) { case IDC_CHK_LOG: - hw = GetDlgItem(hwndDlg, IDC_ED_FILENAME); - EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG)); - hw = GetDlgItem(hwndDlg, IDC_BTN_LOGBROWSE); - EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG)); - hw = GetDlgItem(hwndDlg, IDC_CHK_LOGCSV); - EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG)); + EnableWindow(GetDlgItem(hwndDlg, IDC_ED_FILENAME), IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG)); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_LOGBROWSE), IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG)); + EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_LOGCSV), IsDlgButtonChecked(hwndDlg, IDC_CHK_LOG)); // drop through case IDC_CHK_LOGCSV: case IDC_CHECKPOPUP: @@ -94,12 +81,13 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA CallService(PLUG "/ViewLogData", 0, 0); break; case IDC_BTN_LOGBROWSE: + { + OPENFILENAME ofn = {0}; ofn.lStructSize = sizeof(ofn); ofn.lpstrFile = options.log_filename; ofn.hwndOwner = hwndDlg; - ofn.Flags = CC_FULLOPEN; - //ofn.lpstrFile[0] = '\0'; - ofn.nMaxFile = sizeof(options.log_filename); + ofn.nMaxFile = SIZEOF(options.log_filename); + ofn.lpstrTitle = TranslateT("Open log file"); ofn.lpstrFilter = LPGENT("All\0*.*\0Text\0*.TXT\0"); ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; @@ -111,6 +99,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SetDlgItemText(hwndDlg, IDC_ED_FILENAME, ofn.lpstrFile); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } + } break; } break; @@ -160,7 +149,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA RefreshWindow(0, 0); - if(options.logging) CallService(PLUG "/Log", (WPARAM)"options changed", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("options changed"), 0); if(hWakeEvent) SetEvent(hWakeEvent); return TRUE; } @@ -175,76 +164,62 @@ PINGADDRESS add_edit_addr; // host edit INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - HWND hw; - int sel; - char *strptr; - switch ( msg ) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); + for(int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { + INT_PTR ret = CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)i, GSMDF_TCHAR); + SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)ret); + SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT2, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)ret); + } + + SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT, CB_SETCURSEL, 1, 0); + SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT2, CB_SETCURSEL, 0, 0); + + SetDlgItemText(hwndDlg, IDC_ED_DESTADDR, add_edit_addr.pszName); + SetDlgItemText(hwndDlg, IDC_ED_DESTLAB, add_edit_addr.pszLabel); + SetDlgItemText(hwndDlg, IDC_ED_COMMAND, add_edit_addr.pszCommand); + SetDlgItemText(hwndDlg, IDC_ED_PARAMS, add_edit_addr.pszParams); + + CheckDlgButton(hwndDlg, IDC_CHK_DESTTCP, add_edit_addr.port != -1); + if(add_edit_addr.port != -1) { + EnableWindow(GetDlgItem(hwndDlg, IDC_ED_DESTPORT), TRUE); + SetDlgItemInt(hwndDlg, IDC_ED_DESTPORT, add_edit_addr.port, FALSE); + } + + SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)TranslateT("")); + SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)TranslateT("")); + { - for(int i = ID_STATUS_OFFLINE; i <= ID_STATUS_OUTTOLUNCH; i++) { - strptr = (char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)i, (LPARAM)0); - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT); - SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)strptr); - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT2); - SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)strptr); - } + int num_protocols; + PROTOACCOUNT **pppDesc; - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT); - SendMessage(hw, CB_SETCURSEL, 1, 0); - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT2); - SendMessage(hw, CB_SETCURSEL, 0, 0); - - SetDlgItemText(hwndDlg, IDC_ED_DESTADDR, add_edit_addr.pszName); - SetDlgItemText(hwndDlg, IDC_ED_DESTLAB, add_edit_addr.pszLabel); - SetDlgItemText(hwndDlg, IDC_ED_COMMAND, add_edit_addr.pszCommand); - SetDlgItemText(hwndDlg, IDC_ED_PARAMS, add_edit_addr.pszParams); - - CheckDlgButton(hwndDlg, IDC_CHK_DESTTCP, add_edit_addr.port != -1); - if(add_edit_addr.port != -1) { - hw = GetDlgItem(hwndDlg, IDC_ED_DESTPORT); - EnableWindow(hw, TRUE); - SetDlgItemInt(hwndDlg, IDC_ED_DESTPORT, add_edit_addr.port, FALSE); - } - { - int num_protocols; - PROTOACCOUNT **pppDesc; - - ProtoEnumAccounts(&num_protocols,&pppDesc); - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTPROTO); - SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)Translate("")); - SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)Translate("")); - for(int i = 0; i < num_protocols; i++) { - SendMessage(hw, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)pppDesc[i]->tszAccountName); - } + ProtoEnumAccounts(&num_protocols,&pppDesc); + for(int i = 0; i < num_protocols; i++) + SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_INSERTSTRING, (WPARAM)-1, (LPARAM)pppDesc[i]->tszAccountName); + + } - if(add_edit_addr.pszProto[0] == '\0') { - SendMessage(hw, CB_SETCURSEL, 0, 0); - } else { - SendMessage(hw, CB_SELECTSTRING, 0, (LPARAM)add_edit_addr.pszProto); - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT); - EnableWindow(hw, TRUE); - SendMessage(hw, CB_SETCURSEL, (WPARAM)(add_edit_addr.set_status - ID_STATUS_OFFLINE), 0); - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT2); - EnableWindow(hw, TRUE); - SendMessage(hw, CB_SETCURSEL, (WPARAM)(add_edit_addr.get_status - ID_STATUS_OFFLINE), 0); - } - } - // ? doesn't work? ? - hw = GetDlgItem(hwndDlg, IDC_ED_DESTLAB); - SetFocus(hw); + if(add_edit_addr.pszProto[0] == '\0') { + SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_SETCURSEL, 0, 0); + } else { + SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_SELECTSTRING, 0, (LPARAM)add_edit_addr.pszProto); + EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT), TRUE); + SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT, CB_SETCURSEL, (WPARAM)(add_edit_addr.set_status - ID_STATUS_OFFLINE), 0); + + EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT2), TRUE); + SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT2, CB_SETCURSEL, (WPARAM)(add_edit_addr.get_status - ID_STATUS_OFFLINE), 0); } + + // ? doesn't work? ? + SetFocus(GetDlgItem(hwndDlg, IDC_ED_DESTLAB)); return FALSE; case WM_COMMAND: if (HIWORD( wParam ) == LBN_SELCHANGE && LOWORD(wParam) == IDC_COMBO_DESTPROTO) { - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTPROTO); - sel = SendMessage(hw, CB_GETCURSEL, 0, 0); + int sel = SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_GETCURSEL, 0, 0); if(sel != CB_ERR) { - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT); - EnableWindow(hw, sel != 0); - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT2); - EnableWindow(hw, sel != 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT), sel != 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT2), sel != 0); } } @@ -253,8 +228,7 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l switch( LOWORD( wParam )) { case IDC_CHK_DESTTCP: - hw = GetDlgItem(hwndDlg, IDC_ED_DESTPORT); - EnableWindow(hw, IsDlgButtonChecked(hwndDlg, IDC_CHK_DESTTCP)); + EnableWindow(GetDlgItem(hwndDlg, IDC_ED_DESTPORT), IsDlgButtonChecked(hwndDlg, IDC_CHK_DESTTCP)); break; case IDOK: GetDlgItemText(hwndDlg, IDC_ED_DESTADDR, add_edit_addr.pszName, MAX_PINGADDRESS_STRING_LENGTH); @@ -262,19 +236,18 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l GetDlgItemText(hwndDlg, IDC_ED_COMMAND, add_edit_addr.pszCommand, MAX_PATH); GetDlgItemText(hwndDlg, IDC_ED_PARAMS, add_edit_addr.pszParams, MAX_PATH); - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTPROTO); - if(SendMessage(hw, CB_GETCURSEL, 0, 0) != -1) + if(SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTPROTO, CB_GETCURSEL, 0, 0) != -1) { - GetDlgItemText(hwndDlg, IDC_COMBO_DESTPROTO, add_edit_addr.pszProto, MAX_PINGADDRESS_STRING_LENGTH); - if(!strcmp(add_edit_addr.pszProto, Translate(""))) add_edit_addr.pszProto[0] = '\0'; + GetDlgItemTextA(hwndDlg, IDC_COMBO_DESTPROTO, add_edit_addr.pszProto, MAX_PINGADDRESS_STRING_LENGTH); + if(!strcmp(add_edit_addr.pszProto, Translate(""))) + add_edit_addr.pszProto[0] = '\0'; else { - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT); - sel = SendMessage(hw, CB_GETCURSEL, 0, 0); - if(sel != -1) + int sel = SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT, CB_GETCURSEL, 0, 0); + if(sel != CB_ERR) add_edit_addr.set_status = ID_STATUS_OFFLINE + sel; - hw = GetDlgItem(hwndDlg, IDC_COMBO_DESTSTAT2); - sel = SendMessage(hw, CB_GETCURSEL, 0, 0); - if(sel != -1) + + sel = SendDlgItemMessage(hwndDlg, IDC_COMBO_DESTSTAT2, CB_GETCURSEL, 0, 0); + if(sel != CB_ERR) add_edit_addr.get_status = ID_STATUS_OFFLINE + sel; } } else @@ -290,12 +263,12 @@ INT_PTR CALLBACK DlgProcDestEdit(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l add_edit_addr.port = -1; EndDialog(hwndDlg, IDOK); + RefreshWindow(0, 0); break; case IDCANCEL: EndDialog(hwndDlg, IDCANCEL); break; } - } return TRUE; @@ -318,47 +291,33 @@ bool Edit(HWND hwnd, PINGADDRESS &addr) // ping hosts list window static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - //OPENFILENAME ofn = {0}; - HWND hw; - int sel; - switch ( msg ) { case WM_INITDIALOG: - { TranslateDialogDefault( hwndDlg ); Lock(&data_list_cs, "init options dialog"); temp_list = data_list; Unlock(&data_list_cs); - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); for (pinglist_it i = temp_list.begin(); i != temp_list.end(); ++i) { - int index = SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)i->pszLabel); - SendMessage(hw, LB_SETITEMDATA, index, (LPARAM)&(*i)); + int index = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)i->pszLabel); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, index, (LPARAM)&(*i)); } - - } return TRUE; case WM_COMMAND: if (HIWORD( wParam ) == LBN_SELCHANGE && LOWORD(wParam) == IDC_LST_DEST) { - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); - sel = SendMessage(hw, LB_GETCURSEL, 0, 0); + int sel = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0); if(sel != LB_ERR) { - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTREM); - EnableWindow(hw, TRUE); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT); - EnableWindow(hw, TRUE); - - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); - EnableWindow(hw, (sel > 0)); - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); - int count = SendMessage(hw, LB_GETCOUNT, 0, 0); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN); - EnableWindow(hw, (sel < count - 1)); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTREM), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT), TRUE); + + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), (sel > 0)); + int count = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCOUNT, 0, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel < count - 1)); } } @@ -367,33 +326,30 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR switch( LOWORD( wParam )) { case IDC_BTN_DESTEDIT: - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); - sel = SendMessage(hw, LB_GETCURSEL, 0, 0); + { + int sel = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0); if (sel != LB_ERR) { - PINGADDRESS *item = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel, 0); + PINGADDRESS *item = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel, 0); PINGADDRESS temp = *item; if (Edit(hwndDlg, temp)) { *item = temp; - SendMessage(hw, LB_DELETESTRING, (WPARAM)sel, 0); - SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel, (LPARAM)item->pszLabel); - SendMessage(hw, LB_SETITEMDATA, (WPARAM)sel, (LPARAM)item); - SendMessage(hw, LB_SETCURSEL, (WPARAM)sel, 0); - - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTREM); - EnableWindow(hw, TRUE); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT); - EnableWindow(hw, TRUE); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); - EnableWindow(hw, sel > 0); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN); - int count = SendMessage(hw, LB_GETCOUNT, 0, 0); - EnableWindow(hw, (sel < count - 1)); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)sel, 0); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)sel, (LPARAM)item->pszLabel); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)sel, (LPARAM)item); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETCURSEL, (WPARAM)sel, 0); + + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTREM), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), sel > 0); + int count = SendDlgItemMessage(hwndDlg, IDC_BTN_DESTDOWN, LB_GETCOUNT, 0, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel < count - 1)); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } } + } break; case IDC_BTN_DESTADD: @@ -410,56 +366,46 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { temp_list.push_back(add_edit_addr); - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); - int index = SendMessage(hw, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)add_edit_addr.pszLabel); - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); - SendMessage(hw, LB_SETCURSEL, (WPARAM)index, 0); - SendMessage(hw, LB_SETITEMDATA, (WPARAM)index, (LPARAM)&(temp_list.back())); - - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTREM); - EnableWindow(hw, TRUE); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT); - EnableWindow(hw, TRUE); - - sel = (int)temp_list.size() - 1; - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); - EnableWindow(hw, (sel > 0)); - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); - int count = SendMessage(hw, LB_GETCOUNT, 0, 0); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN); - EnableWindow(hw, (sel < count - 1)); + int index = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)-1, (LPARAM)add_edit_addr.pszLabel); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETCURSEL, (WPARAM)index, 0); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)index, (LPARAM)&(temp_list.back())); + + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTREM), TRUE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT), TRUE); + + int sel = (int)temp_list.size() - 1; + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), (sel > 0)); + int count = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCOUNT, 0, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel < count - 1)); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } break; case IDC_BTN_DESTREM: - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); - sel = SendMessage(hw, LB_GETCURSEL, 0, 0); + { + int sel = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0); if(sel != LB_ERR) { - PINGADDRESS *item = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel, 0); - SendMessage(hw, LB_DELETESTRING, (WPARAM)sel, 0); + PINGADDRESS *item = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel, 0); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)sel, 0); temp_list.remove(*item); } - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTREM); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); - EnableWindow(hw, FALSE); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN); - EnableWindow(hw, FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTREM), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTEDIT), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), FALSE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), FALSE); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); + RefreshWindow(0, 0); break; + } case IDC_BTN_DESTDOWN: { - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); - int sel2 = SendMessage(hw, LB_GETCURSEL, 0, 0); + int sel2 = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0); if(sel2 != LB_ERR) { - PINGADDRESS *item = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel2, 0), - *item2 = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel2 + 1, 0); + PINGADDRESS *item = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2, 0), + *item2 = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2 + 1, 0); if(item && item2) { add_edit_addr = *item; @@ -471,20 +417,17 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR item->index = index2; item2->index = index; - SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0); - SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel); - SendMessage(hw, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item); - SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 + 1), (LPARAM)0); - SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 + 1), (LPARAM)item2->pszLabel); - SendMessage(hw, LB_SETITEMDATA, (WPARAM)(sel2 + 1), (LPARAM)item2); - SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 + 1), 0); - - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); - EnableWindow(hw, (sel2 + 1 > 0)); - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); - int count = SendMessage(hw, LB_GETCOUNT, 0, 0); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN); - EnableWindow(hw, (sel2 + 1 < count - 1)); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)(sel2 + 1), (LPARAM)0); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)(sel2 + 1), (LPARAM)item2->pszLabel); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)(sel2 + 1), (LPARAM)item2); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETCURSEL, (WPARAM)(sel2 + 1), 0); + + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), (sel2 + 1 > 0)); + int count = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCOUNT, 0, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel2 + 1 < count - 1)); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } @@ -493,11 +436,10 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break; case IDC_BTN_DESTUP: { - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); - int sel2 = SendMessage(hw, LB_GETCURSEL, 0, 0); + int sel2 = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCURSEL, 0, 0); if(sel2 != LB_ERR) { - PINGADDRESS *item = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel2, 0), - *item2 = (PINGADDRESS *)SendMessage(hw, LB_GETITEMDATA, sel2 - 1, 0); + PINGADDRESS *item = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2, 0), + *item2 = (PINGADDRESS *)SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETITEMDATA, sel2 - 1, 0); if (item && item2) { @@ -510,22 +452,19 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR item->index = index2; item2->index = index; - SendMessage(hw, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0); - SendMessage(hw, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel); - SendMessage(hw, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)sel2, (LPARAM)0); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)sel2, (LPARAM)item->pszLabel); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)sel2, (LPARAM)item); - SendMessage(hw, LB_DELETESTRING, (WPARAM)(sel2 - 1), (LPARAM)0); - SendMessage(hw, LB_INSERTSTRING, (WPARAM)(sel2 - 1), (LPARAM)item2->pszLabel); - SendMessage(hw, LB_SETITEMDATA, (WPARAM)(sel2 - 1), (LPARAM)item2); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_DELETESTRING, (WPARAM)(sel2 - 1), (LPARAM)0); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_INSERTSTRING, (WPARAM)(sel2 - 1), (LPARAM)item2->pszLabel); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETITEMDATA, (WPARAM)(sel2 - 1), (LPARAM)item2); - SendMessage(hw, LB_SETCURSEL, (WPARAM)(sel2 - 1), 0); + SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_SETCURSEL, (WPARAM)(sel2 - 1), 0); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTUP); - EnableWindow(hw, (sel2 - 1 > 0)); - hw = GetDlgItem(hwndDlg, IDC_LST_DEST); - int count = SendMessage(hw, LB_GETCOUNT, 0, 0); - hw = GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN); - EnableWindow(hw, (sel2 - 1 < count - 1)); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTUP), (sel2 - 1 > 0)); + int count = SendDlgItemMessage(hwndDlg, IDC_LST_DEST, LB_GETCOUNT, 0, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BTN_DESTDOWN), (sel2 - 1 < count - 1)); SendMessage( GetParent( hwndDlg ), PSM_CHANGED, 0, 0 ); } @@ -557,7 +496,7 @@ static INT_PTR CALLBACK DlgProcOpts2(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR return FALSE; } -int PingOptInit(WPARAM wParam,LPARAM lParam) +int PingOptInit(WPARAM wParam,LPARAM) { OPTIONSDIALOGPAGE odp = { sizeof(odp) }; odp.hInstance = hInst; @@ -566,12 +505,12 @@ int PingOptInit(WPARAM wParam,LPARAM lParam) odp.ptszTitle = LPGENT("PING"); odp.ptszTab = LPGENT("Settings"); - odp.pszTemplate = MAKEINTRESOURCE(IDD_DIALOG1); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG1); odp.pfnDlgProc = DlgProcOpts; Options_AddPage(wParam,&odp); odp.ptszTab = LPGENT("Hosts"); - odp.pszTemplate = MAKEINTRESOURCE(IDD_DIALOG2); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_DIALOG2); odp.pfnDlgProc = DlgProcOpts2; Options_AddPage(wParam,&odp); return 0; diff --git a/plugins/Ping/src/ping.cpp b/plugins/Ping/src/ping.cpp index f107f5a9d3..64dd259a65 100644 --- a/plugins/Ping/src/ping.cpp +++ b/plugins/Ping/src/ping.cpp @@ -79,12 +79,10 @@ int OnShutdown(WPARAM wParam, LPARAM lParam) { return 0; } -int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { +int OnModulesLoaded(WPARAM, LPARAM) { NETLIBUSER nl_user = {0}; nl_user.cbSize = sizeof(nl_user); nl_user.szSettingsModule = PLUG; - //nl_user.flags = NUF_OUTGOING | NUF_HTTPGATEWAY | NUF_NOOPTIONS; - //nl_user.flags = NUF_OUTGOING | NUF_NOOPTIONS; nl_user.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR; nl_user.ptszDescriptiveName = TranslateT("Ping Plugin"); nl_user.szHttpGatewayHello = 0; @@ -114,7 +112,7 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam) { graphs_init(); - if(options.logging) CallService(PLUG "/Log", (WPARAM)"start", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("start"), 0); return 0; } @@ -164,7 +162,7 @@ extern "C" __declspec(dllexport) int Unload(void) CloseHandle( mainThread ); - if(options.logging) CallService(PLUG "/Log", (WPARAM)"stop", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("stop"), 0); return 0; } diff --git a/plugins/Ping/src/pinggraph.cpp b/plugins/Ping/src/pinggraph.cpp index 453303fb5a..cc2252a521 100644 --- a/plugins/Ping/src/pinggraph.cpp +++ b/plugins/Ping/src/pinggraph.cpp @@ -187,23 +187,23 @@ LRESULT CALLBACK GraphWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar SetBkMode(hdc, TRANSPARENT); SetTextColor(hdc, GetSysColor(COLOR_3DDKSHADOW)); - char buff[64]; + TCHAR buff[64]; if(wd->show_grid) { - mir_snprintf(buff, SIZEOF(buff), Translate("%d ms"), MARK_TIME); - TextOut(hdc, r.right - 100, r.bottom - (int)(unit_height * MARK_TIME + 0.5f), buff, (int)strlen(buff)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("%d ms"), MARK_TIME); + TextOut(hdc, r.right - 100, r.bottom - (int)(unit_height * MARK_TIME + 0.5f), buff, (int)_tcslen(buff)); } if (wd->show_stat) { SetTextColor(hdc, RGB(255, 0, 0)); - mir_snprintf(buff, SIZEOF(buff), Translate("AVG %.1lf ms"), avg); - TextOut(hdc, r.left + 10, r.bottom - (int)(avg * unit_height + 0.5f), buff, (int)strlen(buff)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("AVG %.1lf ms"), avg); + TextOut(hdc, r.left + 10, r.bottom - (int)(avg * unit_height + 0.5f), buff, (int)_tcslen(buff)); if (max_value != avg) { - mir_snprintf(buff, SIZEOF(buff), Translate("MAX %hd ms"), max_value); - TextOut(hdc, r.left + 10, r.bottom - (int)(max_value * unit_height + 0.5f), buff, (int)strlen(buff)); - mir_snprintf(buff, SIZEOF(buff), Translate("MIN %hd ms"), min_value); - TextOut(hdc, r.left + 10, r.bottom - (int)(min_value * unit_height + 0.5f), buff, (int)strlen(buff)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("MAX %hd ms"), max_value); + TextOut(hdc, r.left + 10, r.bottom - (int)(max_value * unit_height + 0.5f), buff, (int)_tcslen(buff)); + mir_sntprintf(buff, SIZEOF(buff), TranslateT("MIN %hd ms"), min_value); + TextOut(hdc, r.left + 10, r.bottom - (int)(min_value * unit_height + 0.5f), buff, (int)_tcslen(buff)); } } @@ -275,11 +275,11 @@ INT_PTR ShowGraph(WPARAM wParam, LPARAM lParam) { wndclass.lpszClassName = _T(PLUG) _T("GraphWindow"); RegisterClass(&wndclass); - char title[256]; - strcpy(title, "Ping Graph"); + TCHAR title[256]; + _tcsncpy(title, TranslateT("Ping Graph"), SIZEOF(title)); if(lParam) { - strcat(title, " - "); - strncat(title, (char *)lParam, 256 - 13); + _tcsncat(title, _T(" - "), SIZEOF(title)); + _tcsncat(title, (TCHAR *)lParam, SIZEOF(title)); } HWND parent = 0; diff --git a/plugins/Ping/src/pinglist.cpp b/plugins/Ping/src/pinglist.cpp index 1151ba37f6..ccd95600c6 100644 --- a/plugins/Ping/src/pinglist.cpp +++ b/plugins/Ping/src/pinglist.cpp @@ -33,7 +33,7 @@ const bool PINGADDRESS::operator<(const PINGADDRESS &b) const // lParam is address of pointer to a std::list // copies data into this structure -INT_PTR GetPingList(WPARAM wParam,LPARAM lParam) +INT_PTR GetPingList(WPARAM,LPARAM lParam) { PINGLIST *pa = (PINGLIST *)lParam; @@ -44,7 +44,7 @@ INT_PTR GetPingList(WPARAM wParam,LPARAM lParam) return 0; } -INT_PTR GetListSize(WPARAM wParam, LPARAM lParam) +INT_PTR GetListSize(WPARAM, LPARAM) { INT_PTR ret = 0; EnterCriticalSection(&list_cs); @@ -65,17 +65,17 @@ void write_ping_address(PINGADDRESS &i) } db_set_dw(0, buff, "Id", i.item_id); - db_set_s(0, buff, "Address", i.pszName); - db_set_s(0, buff, "Label", i.pszLabel); + db_set_ts(0, buff, "Address", i.pszName); + db_set_ts(0, buff, "Label", i.pszLabel); db_set_w(0, buff, "Status", i.status); db_set_dw(0, buff, "Port", i.port); db_set_s(0, buff, "Proto", i.pszProto); - if(strlen(i.pszCommand)) - db_set_s(0, buff, "Command", i.pszCommand); + if(_tcslen(i.pszCommand)) + db_set_ts(0, buff, "Command", i.pszCommand); else db_unset(0, buff, "Command"); - if(strlen(i.pszParams)) - db_set_s(0, buff, "CommandParams", i.pszParams); + if(_tcslen(i.pszParams)) + db_set_ts(0, buff, "CommandParams", i.pszParams); else db_unset(0, buff, "CommandParams"); db_set_w(0, buff, "SetStatus", i.set_status); @@ -117,13 +117,13 @@ bool read_ping_address(PINGADDRESS &pa) { if((pa.item_id = db_get_dw(0, buff, "Id", 0)) == 0) return false; DBVARIANT dbv; - if(!db_get(0, buff, "Address", &dbv)) { - strncpy(pa.pszName, dbv.pszVal, MAX_PINGADDRESS_STRING_LENGTH); + if(!db_get_ts(0, buff, "Address", &dbv)) { + _tcsncpy(pa.pszName, dbv.ptszVal, MAX_PINGADDRESS_STRING_LENGTH); db_free(&dbv); } else return false; - if(!db_get(0, buff, "Label", &dbv)) { - strncpy(pa.pszLabel, dbv.pszVal, MAX_PINGADDRESS_STRING_LENGTH); + if(!db_get_ts(0, buff, "Label", &dbv)) { + _tcsncpy(pa.pszLabel, dbv.ptszVal, MAX_PINGADDRESS_STRING_LENGTH); db_free(&dbv); } else return false; @@ -132,18 +132,18 @@ bool read_ping_address(PINGADDRESS &pa) { pa.port = (int)db_get_dw(0, buff, "Port", -1); - if(!db_get(0, buff, "Proto", &dbv)) { + if(!db_get_s(0, buff, "Proto", &dbv)) { strncpy(pa.pszProto, dbv.pszVal, MAX_PINGADDRESS_STRING_LENGTH); db_free(&dbv); } else pa.pszProto[0] = '\0'; - if(!db_get(0, buff, "Command", &dbv)) { - strncpy(pa.pszCommand, dbv.pszVal, MAX_PATH); + if(!db_get_ts(0, buff, "Command", &dbv)) { + _tcsncpy(pa.pszCommand, dbv.ptszVal, MAX_PATH); db_free(&dbv); } else pa.pszCommand[0] = '\0'; - if(!db_get(0, buff, "CommandParams", &dbv)) { - strncpy(pa.pszParams, dbv.pszVal, MAX_PATH); + if(!db_get_ts(0, buff, "CommandParams", &dbv)) { + _tcsncpy(pa.pszParams, dbv.ptszVal, MAX_PATH); db_free(&dbv); } else pa.pszParams[0] = '\0'; diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp index f785976e51..283f407934 100644 --- a/plugins/Ping/src/pingthread.cpp +++ b/plugins/Ping/src/pingthread.cpp @@ -55,7 +55,7 @@ void set_list_changed(bool f) { Unlock(&list_changed_cs); } -void SetProtoStatus(char *pszLabel, char *pszProto, int if_status, int new_status) { +void SetProtoStatus(TCHAR *pszLabel, char *pszProto, int if_status, int new_status) { if(strcmp(pszProto, Translate("")) == 0) { int num_protocols; PROTOACCOUNT **pppDesc; @@ -68,8 +68,8 @@ void SetProtoStatus(char *pszLabel, char *pszProto, int if_status, int new_statu if(ProtoServiceExists(pszProto, PS_GETSTATUS)) { if(ProtoCallService(pszProto, PS_GETSTATUS, 0, 0) == if_status) { if(options.logging) { - char buf[1024]; - mir_snprintf(buf, 1024, Translate("%s - setting status of protocol '%s' (%d)"), pszLabel, pszProto, new_status); + TCHAR buf[1024]; + mir_sntprintf(buf, 1024, TranslateT("%s - setting status of protocol '%S' (%d)"), pszLabel, pszProto, new_status); CallService(PLUG "/Log", (WPARAM)buf, 0); } ProtoCallService(pszProto, PS_SETSTATUS, new_status, 0); @@ -119,9 +119,9 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp) pa.item_id = i->item_id; pa.miss_count = i->miss_count; pa.port = i->port; - strcpy(pa.pszLabel, i->pszLabel); - strcpy(pa.pszName, i->pszName); - strcpy(pa.pszProto, i->pszProto); + _tcsncpy(pa.pszLabel, i->pszLabel, MAX_PINGADDRESS_STRING_LENGTH); + _tcsncpy(pa.pszName, i->pszName, MAX_PINGADDRESS_STRING_LENGTH); + strncpy(pa.pszProto, i->pszProto, MAX_PINGADDRESS_STRING_LENGTH); pa.set_status = i->set_status; pa.status = i->status; break; @@ -200,12 +200,12 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp) { reply = true; if(options.show_popup2 && ServiceExists(MS_POPUP_SHOWMESSAGE)) { - ShowPopup("Ping Reply", pa.pszLabel, 1); + ShowPopup(TranslateT("Ping Reply"), pa.pszLabel, 1); } } if(pa.miss_count == -1 - options.retries && options.logging) { - char buf[512]; - mir_snprintf(buf, 512, Translate("%s - reply, %d"), pa.pszLabel, pa.round_trip_time); + TCHAR buf[512]; + mir_sntprintf(buf, 512, TranslateT("%s - reply, %d"), pa.pszLabel, pa.round_trip_time); CallService(PLUG "/Log", (WPARAM)buf, 0); } SetProtoStatus(pa.pszLabel, pa.pszProto, pa.get_status, pa.set_status); @@ -215,13 +215,12 @@ DWORD WINAPI sttCheckStatusThreadProc( void *vp) ((pa.miss_count % (options.retries + 1)) == 0 && !options.block_reps)) { timeout = true; - if(options.show_popup && ServiceExists(MS_POPUP_SHOWMESSAGE)) { - ShowPopup("Ping Timeout", pa.pszLabel, 0); - } + if(options.show_popup) + ShowPopup(TranslateT("Ping Timeout"), pa.pszLabel, 0); } if(pa.miss_count == 1 + options.retries && options.logging) { - char buf[512]; - mir_snprintf(buf, 512, Translate("%s - timeout"), pa.pszLabel); + TCHAR buf[512]; + mir_sntprintf(buf, 512, TranslateT("%s - timeout"), pa.pszLabel); CallService(PLUG "/Log", (WPARAM)buf, 0); } } @@ -271,7 +270,7 @@ bool FrameIsFloating() { int FillList(WPARAM wParam, LPARAM lParam) { if(options.logging) - CallService(PLUG "/Log", (WPARAM)"ping address list reload", 0); + CallService(PLUG "/Log", (WPARAM)_T("ping address list reload"), 0); PINGLIST pl; CallService(PLUG "/GetPingList", 0, (LPARAM)&pl); @@ -326,14 +325,14 @@ void CALLBACK TimerProc( { if(frame_id != -1 && ServiceExists(MS_CLIST_FRAMES_ADDFRAME)) { - char TBcapt[255]; + TCHAR TBcapt[255]; if (total > 0) - mir_sntprintf(TBcapt, SIZEOF(TBcapt), "Ping (%d/%d)", upCount, total); + mir_sntprintf(TBcapt, SIZEOF(TBcapt), _T("Ping (%d/%d)"), upCount, total); else - mir_sntprintf(TBcapt, SIZEOF(TBcapt), "Ping"); + mir_sntprintf(TBcapt, SIZEOF(TBcapt), _T("Ping")); - CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBNAME,frame_id),(LPARAM)TBcapt); - CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBTIPNAME,frame_id),(LPARAM)TBcapt); + CallService(MS_CLIST_FRAMES_SETFRAMEOPTIONS,MAKEWPARAM(FO_TBNAME | FO_TCHAR,frame_id),(LPARAM)TBcapt); + 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) { @@ -416,13 +415,13 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar TextOut(dis->hDC,dis->rcItem.left + 16 + 4,(dis->rcItem.top + dis->rcItem.bottom - textSize.cy)>>1,itemData.pszLabel,lstrlen(itemData.pszLabel)); if(itemData.status != PS_DISABLED) { - char buf[256]; + TCHAR buf[256]; if(itemData.responding) { - mir_snprintf(buf, 256, Translate("%d ms"), itemData.round_trip_time); + mir_sntprintf(buf, 256, TranslateT("%d ms"), itemData.round_trip_time); GetTextExtentPoint32(dis->hDC,buf,lstrlen(buf),&textSize); TextOut(dis->hDC,dis->rcItem.right - textSize.cx - 2,(dis->rcItem.top + dis->rcItem.bottom -textSize.cy)>>1,buf,lstrlen(buf)); } else if(itemData.miss_count > 0) { - mir_snprintf(buf, 256, "[%d]", itemData.miss_count); + mir_sntprintf(buf, 256, _T("[%d]"), itemData.miss_count); GetTextExtentPoint32(dis->hDC,buf,lstrlen(buf),&textSize); TextOut(dis->hDC,dis->rcItem.right - textSize.cx - 2,(dis->rcItem.top + dis->rcItem.bottom -textSize.cy)>>1,buf,lstrlen(buf)); } @@ -513,7 +512,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar return DefWindowProc(hwnd, msg, wParam, lParam); case WM_CREATE: - list_hwnd = CreateWindow("LISTBOX", "", + list_hwnd = CreateWindow(_T("LISTBOX"), _T(""), //(WS_VISIBLE | WS_CHILD | LBS_NOINTEGRALHEIGHT| LBS_STANDARD | WS_CLIPCHILDREN | LBS_OWNERDRAWVARIABLE | LBS_NOTIFY) (WS_VISIBLE | WS_CHILD | LBS_STANDARD | LBS_OWNERDRAWFIXED | LBS_NOTIFY) & ~WS_BORDER, 0, 0, 0, 0, hwnd, NULL, hInst,0); @@ -786,8 +785,8 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar if(wake) SetEvent(hWakeEvent); if(options.logging) { - char buf[1024]; - mir_snprintf(buf, 1024, "%s - %s", pItemData->pszLabel, (wake ? Translate("enabled") : Translate("double clicked"))); + TCHAR buf[1024]; + mir_sntprintf(buf, 1024, _T("%s - %s"), pItemData->pszLabel, (wake ? TranslateT("enabled") : TranslateT("double clicked"))); CallService(PLUG "/Log", (WPARAM)buf, 0); } @@ -882,7 +881,7 @@ LRESULT CALLBACK FrameWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar return(TRUE); }; -int ReloadFont(WPARAM wParam, LPARAM lParam) { +int ReloadFont(WPARAM, LPARAM) { if(hFont) DeleteObject(hFont); LOGFONT log_font; @@ -896,7 +895,7 @@ int ReloadFont(WPARAM wParam, LPARAM lParam) { return 0; } -int RefreshWindow(WPARAM wParam, LPARAM lParam) { +int RefreshWindow(WPARAM, LPARAM) { InvalidateRect(list_hwnd, 0, TRUE); InvalidateRect(hpwnd, 0, TRUE); return 0; @@ -1019,22 +1018,29 @@ void InitList() } { - font_id.cbSize = sizeof(FontID); - _tcsncpy(font_id.group, _T("Ping"), SIZEOF(font_id.group)); - _tcsncpy(font_id.name, _T("List"), SIZEOF(font_id.name)); + font_id.cbSize = sizeof(FontIDT); + _tcsncpy(font_id.group, LPGENT("Ping"), SIZEOF(font_id.group)); + _tcsncpy(font_id.name, LPGENT("List"), SIZEOF(font_id.name)); strncpy(font_id.dbSettingsGroup, "PING", sizeof(font_id.dbSettingsGroup)); strncpy(font_id.prefix, "Font", sizeof(font_id.prefix)); _tcsncpy(font_id.backgroundGroup, _T("Ping"), SIZEOF(font_id.backgroundGroup)); _tcsncpy(font_id.backgroundName, _T("Background"), SIZEOF(font_id.backgroundName)); font_id.order = 0; + font_id.flags = FIDF_DEFAULTVALID; + font_id.deffontsettings.charset = DEFAULT_CHARSET; + font_id.deffontsettings.size = -14; + font_id.deffontsettings.style = 0; + font_id.deffontsettings.colour = RGB(255, 255, 255); + _tcsncpy(font_id.deffontsettings.szFace, _T("Tahoma"), SIZEOF(font_id.deffontsettings.szFace)); FontRegisterT(&font_id); - bk_col_id.cbSize = sizeof(ColourID); + bk_col_id.cbSize = sizeof(ColourIDT); _tcsncpy(bk_col_id.group, _T("Ping"), SIZEOF(bk_col_id.group)); _tcsncpy(bk_col_id.name, _T("Background"), SIZEOF(bk_col_id.name)); strncpy(bk_col_id.dbSettingsGroup, "PING", sizeof(bk_col_id.dbSettingsGroup)); strncpy(bk_col_id.setting, "BgColor", sizeof(bk_col_id.setting)); + bk_col_id.defcolour = RGB(0,0,0); ColourRegisterT(&bk_col_id); HookEvent(ME_FONT_RELOAD, ReloadFont); diff --git a/plugins/Ping/src/rawping.cpp b/plugins/Ping/src/rawping.cpp index 65bc99a775..007200fa23 100644 --- a/plugins/Ping/src/rawping.cpp +++ b/plugins/Ping/src/rawping.cpp @@ -95,7 +95,7 @@ extern int raw_ping(char *host, int timeout) } else { // Not a recognized hostname either! - if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: unrecognised host", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: unrecognised host"), 0); return -1; } } @@ -117,7 +117,7 @@ extern int raw_ping(char *host, int timeout) // send packet int bwrote = sendto(sd, (char*)packet, sizeof(ICMPHeader), 0, (sockaddr*)&dest, sizeof(dest)); if (bwrote == SOCKET_ERROR) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: unable to send", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: unable to send"), 0); return -1; } @@ -149,45 +149,45 @@ extern int raw_ping(char *host, int timeout) if (bread == SOCKET_ERROR) { if(WSAGetLastError() != WSAETIMEDOUT) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: socket error...cycling", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: socket error...cycling"), 0); } continue; } if(reply_header->proto != ICMP_PROTO) - if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: packet not ICMP...cycling", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: packet not ICMP...cycling"), 0); continue; if(reply_header->tos != 0) - if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: TOS not 0...cycling", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: TOS not 0...cycling"), 0); continue; reply = (ICMPHeader *)(recv_buff + reply_header->h_len * 4); if((unsigned)bread < reply_header->h_len * 4 + sizeof(ICMPHeader)) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: short header", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: short header"), 0); continue; } if(reply->id != (USHORT)GetCurrentProcessId()) - if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: wrong ID...cycling", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong ID...cycling"), 0); continue; if(reply->type != PT_ICMP_ECHO_REPLY && reply->type != PT_ICMP_SOURCE_QUENCH) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: wrong type...cycling", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong type...cycling"), 0); continue; } //if(reply->seq < seq_no) continue; //if(reply->seq > seq_no) return -1; if(reply->seq != seq_no) { - if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: wrong sequence number...cycling", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: wrong sequence number...cycling"), 0); continue; } if(reply->type == PT_ICMP_SOURCE_QUENCH) { char buff[1024]; mir_snprintf(buff, SIZEOF(buff), Translate("Host %s requests that you reduce the amount of traffic you are sending."), host); - MessageBox(0, buff, Translate(PLUG " Warning"), MB_OK | MB_ICONWARNING); + MessageBoxA(0, buff, Translate(PLUG " Warning"), MB_OK | MB_ICONWARNING); } if(use_hi_res) { @@ -197,7 +197,7 @@ extern int raw_ping(char *host, int timeout) } else return current_time - send_time; } - if(options.logging) CallService(PLUG "/Log", (WPARAM)"rawping error: timeout", 0); + if(options.logging) CallService(PLUG "/Log", (WPARAM)_T("rawping error: timeout"), 0); return -1; } diff --git a/plugins/Ping/src/utils.cpp b/plugins/Ping/src/utils.cpp index 57ef772773..6d089eb633 100644 --- a/plugins/Ping/src/utils.cpp +++ b/plugins/Ping/src/utils.cpp @@ -18,25 +18,27 @@ LRESULT CALLBACK NullWindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM void CALLBACK sttMainThreadCallback( ULONG_PTR dwParam ) { - POPUPDATA* ppd = ( POPUPDATA* )dwParam; + POPUPDATAT* ppd = ( POPUPDATAT* )dwParam; - if ( ServiceExists(MS_POPUP_ADDPOPUP)) - PUAddPopup(ppd); + if ( ServiceExists(MS_POPUP_ADDPOPUPT)) + PUAddPopupT(ppd); free( ppd ); } -void __stdcall ShowPopup( const char* line1, const char* line2, int flags ) +void __stdcall ShowPopup(TCHAR *line1,TCHAR *line2, int flags ) { if(CallService(MS_SYSTEM_TERMINATED, 0, 0)) return; - if ( ServiceExists(MS_POPUP_ADDPOPUP)) { - POPUPDATA* ppd = ( POPUPDATA* )calloc( sizeof( POPUPDATA ), 1 ); + if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) { + ShowClassPopupT("pingpopups",line1,line2); + } else if ( ServiceExists(MS_POPUP_ADDPOPUPT)) { + POPUPDATAT *ppd = ( POPUPDATAT* )calloc( sizeof( POPUPDATAT ), 1 ); ppd->lchContact = NULL; ppd->lchIcon = (flags ? hIconResponding : hIconNotResponding); - strncpy( ppd->lpzContactName, line1,MAX_CONTACTNAME); - strncpy( ppd->lpzText, line2, MAX_SECONDLINE); + _tcsncpy( ppd->lptzContactName, line1, MAX_CONTACTNAME); + _tcsncpy( ppd->lptzText, line2, MAX_SECONDLINE); ppd->colorBack = GetSysColor( COLOR_BTNFACE ); ppd->colorText = GetSysColor( COLOR_WINDOWTEXT ); @@ -45,15 +47,10 @@ void __stdcall ShowPopup( const char* line1, const char* line2, int flags ) ppd->PluginWindowProc = NullWindowProc; ppd->PluginData = NULL; - QueueUserAPC(sttMainThreadCallback, mainThread, ( ULONG )ppd ); + QueueUserAPC(sttMainThreadCallback, mainThread, ( ULONG_PTR)ppd ); } - else if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) { - POPUPDATACLASS d = {sizeof(d), "pingpopups"}; - d.pwszTitle = (wchar_t *)line1; - d.pwszText = (wchar_t *)line2; - CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&d); - } else { - MessageBox( NULL, line2, PLUG " Message", MB_OK | MB_ICONINFORMATION ); + else{ + MessageBox( NULL, line2, _T(PLUG) _T(" Message"), MB_OK | MB_ICONINFORMATION ); return; } } @@ -63,19 +60,19 @@ void __stdcall ShowPopup( const char* line1, const char* line2, int flags ) // wParam is zero // lParam is address of PINGADDRESS structure where ping result is placed (i.e. modifies 'responding' // and 'round_trip_time') -INT_PTR PluginPing(WPARAM wParam,LPARAM lParam) +INT_PTR PluginPing(WPARAM,LPARAM lParam) { PINGADDRESS *pa = (PINGADDRESS *)lParam; if(pa->port == -1) { // ICMP echo if(use_raw_ping) { - pa->round_trip_time = raw_ping(pa->pszName, options.ping_timeout * 1000); + pa->round_trip_time = raw_ping(_T2A(pa->pszName), options.ping_timeout * 1000); pa->responding = (pa->round_trip_time != -1); } else { ICMP_ECHO_REPLY result; - pa->responding = ICMP::get_instance()->ping(pa->pszName, result); + pa->responding = ICMP::get_instance()->ping(_T2A(pa->pszName), result); if(pa->responding) pa->round_trip_time = (short)result.RoundTripTime; else @@ -89,11 +86,12 @@ INT_PTR PluginPing(WPARAM wParam,LPARAM lParam) //GetLocalTime(&systime); NETLIBOPENCONNECTION conn = {0}; conn.cbSize = sizeof(NETLIBOPENCONNECTION); - conn.szHost = pa->pszName; + conn.szHost = mir_t2a(pa->pszName); conn.wPort = pa->port; conn.timeout = options.ping_timeout; HANDLE s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)hNetlibUser, (LPARAM)&conn); + mir_free((void*)conn.szHost); clock_t end_tcp = clock(); @@ -225,8 +223,8 @@ INT_PTR DblClick(WPARAM wParam, LPARAM lParam) { CallService(PLUG "/GetPingList", 0, (LPARAM)&pl); for(pinglist_it i = pl.begin(); i != pl.end(); ++i) { if(i->item_id == (DWORD)wParam) { - if(strlen(i->pszCommand)) { - ShellExecute(0, "open", i->pszCommand, i->pszParams, 0, SW_SHOW); + if(_tcslen(i->pszCommand)) { + ShellExecute(0, _T("open"), i->pszCommand, i->pszParams, 0, SW_SHOW); } else { return CallService(PLUG "/ToggleEnabled", wParam, 0); } @@ -240,24 +238,24 @@ void import_ping_address(int index, PINGADDRESS &pa) { DBVARIANT dbv; char buf[256]; mir_snprintf(buf, 256, "Address%d", index); - if(!db_get(0, "PingPlug", buf, &dbv)) { - strncpy(pa.pszName, dbv.pszVal, MAX_PINGADDRESS_STRING_LENGTH); + if(!db_get_ts(0, "PingPlug", buf, &dbv)) { + _tcsncpy(pa.pszName, dbv.ptszVal, MAX_PINGADDRESS_STRING_LENGTH); db_free(&dbv); } else - strcpy(pa.pszName, Translate("Unknown Address")); + _tcsncpy(pa.pszName, TranslateT("Unknown Address"), MAX_PINGADDRESS_STRING_LENGTH); mir_snprintf(buf, 256, "Label%d", index); - if(!db_get(0, "PingPlug", buf, &dbv)) { - strncpy(pa.pszLabel, dbv.pszVal, MAX_PINGADDRESS_STRING_LENGTH); + if(!db_get_ts(0, "PingPlug", buf, &dbv)) { + _tcsncpy(pa.pszLabel, dbv.ptszVal, MAX_PINGADDRESS_STRING_LENGTH); db_free(&dbv); } else - strcpy(pa.pszLabel, Translate("Unknown")); + _tcsncpy(pa.pszLabel, TranslateT("Unknown"), MAX_PINGADDRESS_STRING_LENGTH); mir_snprintf(buf, 256, "Port%d", index); pa.port = (int)db_get_dw(0, "PingPlug", buf, -1); mir_snprintf(buf, 256, "Proto%d", index); - if(!db_get(0, "PingPlug", buf, &dbv)) { + if(!db_get_s(0, "PingPlug", buf, &dbv)) { strncpy(pa.pszProto, dbv.pszVal, MAX_PINGADDRESS_STRING_LENGTH); db_free(&dbv); mir_snprintf(buf, 256, "Status%d", index); @@ -309,7 +307,7 @@ static int OnShutdown(WPARAM, LPARAM) return 0; } -static int ReloadIcons(WPARAM wParam, LPARAM lParam) +static int ReloadIcons(WPARAM, LPARAM) { hIconResponding = Skin_GetIcon("ping_responding"); hIconNotResponding = Skin_GetIcon("ping_not_responding"); @@ -330,7 +328,7 @@ static IconItem iconList[] = void InitUtils() { - Icon_Register(hInst, LPGENT("Ping"), iconList, SIZEOF(iconList)); + Icon_Register(hInst, LPGEN("Ping"), iconList, SIZEOF(iconList)); hIconResponding = Skin_GetIcon("ping_responding"); hIconNotResponding = Skin_GetIcon("ping_not_responding"); diff --git a/plugins/Ping/src/utils.h b/plugins/Ping/src/utils.h index 15d8a736e5..1cb3a19405 100644 --- a/plugins/Ping/src/utils.h +++ b/plugins/Ping/src/utils.h @@ -1,7 +1,7 @@ #ifndef _PING_UTILS #define _PING_UTILS -void __stdcall ShowPopup( const char* line1, const char* line2, int flags ); +void __stdcall ShowPopup(TCHAR *line1, TCHAR *line2, int flags ); INT_PTR PluginPing(WPARAM wParam,LPARAM lParam); -- cgit v1.2.3