Revision | 3c597521dfec331b761453636a974a76eba951a3 (tree) |
---|---|
Time | 2008-06-28 14:18:20 |
Author | eru <eru01@user...> |
Commiter | eru |
トラフィックモニタを追加
@@ -45,8 +45,8 @@ extern int version_ex; // PP | ||
45 | 45 | //#define VERSION_EX 1 |
46 | 46 | static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only |
47 | 47 | static const int PCP_CLIENT_VERSION_EX_NUMBER = 27; |
48 | -static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-4)"; | |
49 | -static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-4)"; | |
48 | +static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-5)"; | |
49 | +static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-5)"; | |
50 | 50 | #endif |
51 | 51 | |
52 | 52 | // ------------------------------------------------ |
@@ -1469,106 +1469,10 @@ | ||
1469 | 1469 | <Filter |
1470 | 1470 | Name="Unix Source" |
1471 | 1471 | > |
1472 | - <File | |
1473 | - RelativePath="..\..\unix\usocket.cpp" | |
1474 | - > | |
1475 | - <FileConfiguration | |
1476 | - Name="Private Release|Win32" | |
1477 | - ExcludedFromBuild="true" | |
1478 | - > | |
1479 | - <Tool | |
1480 | - Name="VCCLCompilerTool" | |
1481 | - AdditionalIncludeDirectories="" | |
1482 | - PreprocessorDefinitions="" | |
1483 | - /> | |
1484 | - </FileConfiguration> | |
1485 | - <FileConfiguration | |
1486 | - Name="Debug|Win32" | |
1487 | - ExcludedFromBuild="true" | |
1488 | - > | |
1489 | - <Tool | |
1490 | - Name="VCCLCompilerTool" | |
1491 | - AdditionalIncludeDirectories="" | |
1492 | - PreprocessorDefinitions="" | |
1493 | - /> | |
1494 | - </FileConfiguration> | |
1495 | - <FileConfiguration | |
1496 | - Name="Release|Win32" | |
1497 | - ExcludedFromBuild="true" | |
1498 | - > | |
1499 | - <Tool | |
1500 | - Name="VCCLCompilerTool" | |
1501 | - AdditionalIncludeDirectories="" | |
1502 | - PreprocessorDefinitions="" | |
1503 | - /> | |
1504 | - </FileConfiguration> | |
1505 | - <FileConfiguration | |
1506 | - Name="Private Debug|Win32" | |
1507 | - ExcludedFromBuild="true" | |
1508 | - > | |
1509 | - <Tool | |
1510 | - Name="VCCLCompilerTool" | |
1511 | - AdditionalIncludeDirectories="" | |
1512 | - PreprocessorDefinitions="" | |
1513 | - /> | |
1514 | - </FileConfiguration> | |
1515 | - </File> | |
1516 | - <File | |
1517 | - RelativePath="..\..\unix\usys.cpp" | |
1518 | - > | |
1519 | - <FileConfiguration | |
1520 | - Name="Private Release|Win32" | |
1521 | - ExcludedFromBuild="true" | |
1522 | - > | |
1523 | - <Tool | |
1524 | - Name="VCCLCompilerTool" | |
1525 | - AdditionalIncludeDirectories="" | |
1526 | - PreprocessorDefinitions="" | |
1527 | - /> | |
1528 | - </FileConfiguration> | |
1529 | - <FileConfiguration | |
1530 | - Name="Debug|Win32" | |
1531 | - ExcludedFromBuild="true" | |
1532 | - > | |
1533 | - <Tool | |
1534 | - Name="VCCLCompilerTool" | |
1535 | - AdditionalIncludeDirectories="" | |
1536 | - PreprocessorDefinitions="" | |
1537 | - /> | |
1538 | - </FileConfiguration> | |
1539 | - <FileConfiguration | |
1540 | - Name="Release|Win32" | |
1541 | - ExcludedFromBuild="true" | |
1542 | - > | |
1543 | - <Tool | |
1544 | - Name="VCCLCompilerTool" | |
1545 | - AdditionalIncludeDirectories="" | |
1546 | - PreprocessorDefinitions="" | |
1547 | - /> | |
1548 | - </FileConfiguration> | |
1549 | - <FileConfiguration | |
1550 | - Name="Private Debug|Win32" | |
1551 | - ExcludedFromBuild="true" | |
1552 | - > | |
1553 | - <Tool | |
1554 | - Name="VCCLCompilerTool" | |
1555 | - AdditionalIncludeDirectories="" | |
1556 | - PreprocessorDefinitions="" | |
1557 | - /> | |
1558 | - </FileConfiguration> | |
1559 | - </File> | |
1560 | 1472 | </Filter> |
1561 | 1473 | <Filter |
1562 | 1474 | Name="Unix Includes" |
1563 | 1475 | > |
1564 | - <File | |
1565 | - RelativePath="..\..\unix\usocket.h" | |
1566 | - > | |
1567 | - </File> | |
1568 | - <File | |
1569 | - RelativePath="..\..\unix\usys.h" | |
1570 | - > | |
1571 | - </File> | |
1572 | 1476 | </Filter> |
1573 | 1477 | </Files> |
1574 | 1478 | <Globals> |
@@ -32,6 +32,8 @@ | ||
32 | 32 | #include "version2.h" |
33 | 33 | #include "gdiplus.h" |
34 | 34 | #include "time.h" |
35 | +#include "stats.h" | |
36 | +#include "sys.h" | |
35 | 37 | #ifdef _DEBUG |
36 | 38 | #include "chkMemoryLeak.h" |
37 | 39 | #define DEBUG_NEW new(__FILE__, __LINE__) |
@@ -75,8 +77,13 @@ bool chanInfoIsRelayed; | ||
75 | 77 | String exePath; |
76 | 78 | ULONG_PTR gdiplusToken; |
77 | 79 | |
80 | +extern Stats stats; | |
81 | +ThreadInfo trafficDlgThread; | |
82 | +HWND trafficDlg = NULL; | |
83 | + | |
78 | 84 | // プロトタイプ宣言 |
79 | 85 | void createGUI(HWND); |
86 | +LRESULT CALLBACK TrafficDlgProc(HWND, UINT, WPARAM, LPARAM); | |
80 | 87 | |
81 | 88 | // --------------------------------- |
82 | 89 | Sys * APICALL MyPeercastInst::createSys() |
@@ -1268,6 +1275,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | ||
1268 | 1275 | peercastInst->saveSettings(); |
1269 | 1276 | break; |
1270 | 1277 | |
1278 | + case ID_POPUP_TRAFFIC: | |
1279 | + // トラフィックモニタ起動 | |
1280 | + if (winDistinctionNT) | |
1281 | + DialogBox(hInst, (LPCTSTR)IDD_TRAFFIC, hWnd, (DLGPROC)TrafficDlgProc); | |
1282 | + else | |
1283 | + { | |
1284 | + HWND WKDLG; //JP-Patch | |
1285 | + WKDLG = CreateDialog(hInst, (LPCTSTR)IDD_CHANINFO, hWnd, (DLGPROC)TrafficDlgProc); //JP-Patch | |
1286 | + ShowWindow(WKDLG,SW_SHOWNORMAL); //JP-Patch | |
1287 | + } | |
1288 | + break; | |
1289 | + | |
1271 | 1290 | case ID_POPUP_EXIT_CONFIRM: |
1272 | 1291 | case IDM_EXIT: |
1273 | 1292 | DestroyWindow(hWnd); |
@@ -1496,3 +1515,102 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa | ||
1496 | 1515 | } |
1497 | 1516 | return FALSE; |
1498 | 1517 | } |
1518 | + | |
1519 | +// control thread (Traffic dialog) | |
1520 | +THREAD_PROC trafficDlgUpdate(ThreadInfo *thread) | |
1521 | +{ | |
1522 | + thread->finish = false; | |
1523 | + | |
1524 | + while (trafficDlg && thread->active) | |
1525 | + { | |
1526 | + SendMessage(trafficDlg, WM_UPDATETRAFFIC, 0, 0); | |
1527 | + Sleep(1000); | |
1528 | + } | |
1529 | + | |
1530 | + thread->finish = true; | |
1531 | + | |
1532 | + return 0; | |
1533 | +} | |
1534 | + | |
1535 | +// Dialog procedure (Traffic dialog) | |
1536 | +LRESULT CALLBACK TrafficDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) | |
1537 | +{ | |
1538 | + switch (message) | |
1539 | + { | |
1540 | + case WM_INITDIALOG: | |
1541 | + // 既に開いてる | |
1542 | + if (trafficDlg || trafficDlgThread.active) | |
1543 | + { | |
1544 | + if (winDistinctionNT) | |
1545 | + EndDialog(hDlg, 0); | |
1546 | + else | |
1547 | + DestroyWindow(hDlg); | |
1548 | + return FALSE; | |
1549 | + } | |
1550 | + | |
1551 | + trafficDlg = hDlg; | |
1552 | + trafficDlgThread.func = trafficDlgUpdate; | |
1553 | + if (!sys->startThread(&trafficDlgThread)){ | |
1554 | + MessageBox(NULL,"Unable to start GUI","PeerCast",MB_OK|MB_ICONERROR); | |
1555 | + PostMessage(hDlg,WM_DESTROY,0,0); | |
1556 | + } | |
1557 | + | |
1558 | + break; | |
1559 | + | |
1560 | + case WM_UPDATETRAFFIC: | |
1561 | + { | |
1562 | + enum unitSymbol { B, KB, MB, GB }; | |
1563 | + const unsigned long int unit[] = { 1, 1024, 1024*1024, 1024*1024*1024 }; | |
1564 | + char suffix[][3] = { "B", "KB", "MB", "GB" }; | |
1565 | + const int bufsize = 60; | |
1566 | + char szUp[bufsize], szDown[bufsize]; | |
1567 | + unsigned int totalDown = stats.getCurrent(Stats::BYTESIN) - stats.getCurrent(Stats::LOCALBYTESIN); | |
1568 | + unsigned int totalUp = stats.getCurrent(Stats::BYTESOUT) - stats.getCurrent(Stats::LOCALBYTESOUT); | |
1569 | + | |
1570 | + // up | |
1571 | + for (int i=GB; i>0; --i) | |
1572 | + { | |
1573 | + if (totalUp >= unit[i]) | |
1574 | + { | |
1575 | + sprintf_s<bufsize>(szUp, "%.2f%s", (double)totalUp/unit[i], suffix[i]); | |
1576 | + break; | |
1577 | + } | |
1578 | + | |
1579 | + if (i == 1) | |
1580 | + sprintf_s<bufsize>(szUp, "%d%s", totalUp, suffix[0]); | |
1581 | + } | |
1582 | + | |
1583 | + // down | |
1584 | + for (int i=GB; i>0; --i) | |
1585 | + { | |
1586 | + if (totalDown >= unit[i]) | |
1587 | + { | |
1588 | + sprintf_s<bufsize>(szDown, "%.2f%s", (double)totalDown/unit[i], suffix[i]); | |
1589 | + break; | |
1590 | + } | |
1591 | + | |
1592 | + if (i == 1) | |
1593 | + sprintf_s<bufsize>(szDown, "%d%s", totalDown, suffix[0]); | |
1594 | + } | |
1595 | + | |
1596 | + SetDlgItemText(hDlg, IDC_STATIC_UP, szUp); | |
1597 | + SetDlgItemText(hDlg, IDC_STATIC_DOWN, szDown); | |
1598 | + } | |
1599 | + break; | |
1600 | + | |
1601 | + case WM_CLOSE: | |
1602 | + trafficDlg = NULL; | |
1603 | + trafficDlgThread.active = false; | |
1604 | + if (winDistinctionNT) | |
1605 | + EndDialog(hDlg, 0); | |
1606 | + else | |
1607 | + DestroyWindow(hDlg); | |
1608 | + | |
1609 | + break; | |
1610 | + | |
1611 | + case WM_DESTROY: | |
1612 | + break; | |
1613 | + } | |
1614 | + | |
1615 | + return FALSE; | |
1616 | +} | |
\ No newline at end of file |
@@ -21,6 +21,54 @@ | ||
21 | 21 | #undef APSTUDIO_READONLY_SYMBOLS |
22 | 22 | |
23 | 23 | ///////////////////////////////////////////////////////////////////////////// |
24 | +// 日本語 resources | |
25 | + | |
26 | +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN) | |
27 | +#ifdef _WIN32 | |
28 | +LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT | |
29 | +#pragma code_page(932) | |
30 | +#endif //_WIN32 | |
31 | + | |
32 | +///////////////////////////////////////////////////////////////////////////// | |
33 | +// | |
34 | +// Dialog | |
35 | +// | |
36 | + | |
37 | +IDD_TRAFFIC DIALOGEX 0, 0, 73, 62 | |
38 | +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | |
39 | +CAPTION "トラフィックモニタ" | |
40 | +FONT 8, "MS Shell Dlg", 400, 0, 0x1 | |
41 | +BEGIN | |
42 | + GROUPBOX "Up",IDC_STATIC,7,7,58,23 | |
43 | + RTEXT "0B",IDC_STATIC_UP,12,16,47,9 | |
44 | + GROUPBOX "Down",IDC_STATIC,7,32,58,23 | |
45 | + RTEXT "0B",IDC_STATIC_DOWN,12,41,47,9 | |
46 | +END | |
47 | + | |
48 | + | |
49 | +///////////////////////////////////////////////////////////////////////////// | |
50 | +// | |
51 | +// DESIGNINFO | |
52 | +// | |
53 | + | |
54 | +#ifdef APSTUDIO_INVOKED | |
55 | +GUIDELINES DESIGNINFO | |
56 | +BEGIN | |
57 | + IDD_TRAFFIC, DIALOG | |
58 | + BEGIN | |
59 | + LEFTMARGIN, 7 | |
60 | + RIGHTMARGIN, 65 | |
61 | + TOPMARGIN, 7 | |
62 | + BOTTOMMARGIN, 55 | |
63 | + END | |
64 | +END | |
65 | +#endif // APSTUDIO_INVOKED | |
66 | + | |
67 | +#endif // 日本語 resources | |
68 | +///////////////////////////////////////////////////////////////////////////// | |
69 | + | |
70 | + | |
71 | +///////////////////////////////////////////////////////////////////////////// | |
24 | 72 | // ニュートラル (システム標準) resources |
25 | 73 | |
26 | 74 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD) |
@@ -39,6 +87,7 @@ BEGIN | ||
39 | 87 | POPUP "popup" |
40 | 88 | BEGIN |
41 | 89 | MENUITEM "情報", ID_POPUP_ABOUT |
90 | + MENUITEM "トラフィックモニタ", ID_POPUP_TRAFFIC | |
42 | 91 | MENUITEM "ヘルプ", ID_POPUP_HELP |
43 | 92 | MENUITEM SEPARATOR |
44 | 93 | POPUP "ポップアップメッセージ" |
@@ -765,138 +765,10 @@ | ||
765 | 765 | <Filter |
766 | 766 | Name="Linux" |
767 | 767 | > |
768 | - <File | |
769 | - RelativePath="..\..\linux\main.cpp" | |
770 | - > | |
771 | - <FileConfiguration | |
772 | - Name="Private Debug|Win32" | |
773 | - ExcludedFromBuild="true" | |
774 | - > | |
775 | - <Tool | |
776 | - Name="VCCLCompilerTool" | |
777 | - AdditionalIncludeDirectories="" | |
778 | - PreprocessorDefinitions="" | |
779 | - /> | |
780 | - </FileConfiguration> | |
781 | - <FileConfiguration | |
782 | - Name="Release|Win32" | |
783 | - ExcludedFromBuild="true" | |
784 | - > | |
785 | - <Tool | |
786 | - Name="VCCLCompilerTool" | |
787 | - AdditionalIncludeDirectories="" | |
788 | - PreprocessorDefinitions="" | |
789 | - /> | |
790 | - </FileConfiguration> | |
791 | - <FileConfiguration | |
792 | - Name="Private Release|Win32" | |
793 | - ExcludedFromBuild="true" | |
794 | - > | |
795 | - <Tool | |
796 | - Name="VCCLCompilerTool" | |
797 | - AdditionalIncludeDirectories="" | |
798 | - PreprocessorDefinitions="" | |
799 | - /> | |
800 | - </FileConfiguration> | |
801 | - <FileConfiguration | |
802 | - Name="Debug|Win32" | |
803 | - ExcludedFromBuild="true" | |
804 | - > | |
805 | - <Tool | |
806 | - Name="VCCLCompilerTool" | |
807 | - AdditionalIncludeDirectories="" | |
808 | - PreprocessorDefinitions="" | |
809 | - /> | |
810 | - </FileConfiguration> | |
811 | - </File> | |
812 | - <File | |
813 | - RelativePath="..\..\linux\makefile" | |
814 | - > | |
815 | - <FileConfiguration | |
816 | - Name="Private Debug|Win32" | |
817 | - ExcludedFromBuild="true" | |
818 | - > | |
819 | - <Tool | |
820 | - Name="VCCustomBuildTool" | |
821 | - /> | |
822 | - </FileConfiguration> | |
823 | - <FileConfiguration | |
824 | - Name="Release|Win32" | |
825 | - ExcludedFromBuild="true" | |
826 | - > | |
827 | - <Tool | |
828 | - Name="VCCustomBuildTool" | |
829 | - /> | |
830 | - </FileConfiguration> | |
831 | - <FileConfiguration | |
832 | - Name="Private Release|Win32" | |
833 | - ExcludedFromBuild="true" | |
834 | - > | |
835 | - <Tool | |
836 | - Name="VCCustomBuildTool" | |
837 | - /> | |
838 | - </FileConfiguration> | |
839 | - <FileConfiguration | |
840 | - Name="Debug|Win32" | |
841 | - ExcludedFromBuild="true" | |
842 | - > | |
843 | - <Tool | |
844 | - Name="VCCustomBuildTool" | |
845 | - /> | |
846 | - </FileConfiguration> | |
847 | - </File> | |
848 | 768 | </Filter> |
849 | 769 | <Filter |
850 | 770 | Name="OSX" |
851 | 771 | > |
852 | - <File | |
853 | - RelativePath="..\..\osx\main.cpp" | |
854 | - > | |
855 | - <FileConfiguration | |
856 | - Name="Private Debug|Win32" | |
857 | - ExcludedFromBuild="true" | |
858 | - > | |
859 | - <Tool | |
860 | - Name="VCCLCompilerTool" | |
861 | - AdditionalIncludeDirectories="" | |
862 | - PreprocessorDefinitions="" | |
863 | - /> | |
864 | - </FileConfiguration> | |
865 | - <FileConfiguration | |
866 | - Name="Release|Win32" | |
867 | - ExcludedFromBuild="true" | |
868 | - > | |
869 | - <Tool | |
870 | - Name="VCCLCompilerTool" | |
871 | - AdditionalIncludeDirectories="" | |
872 | - PreprocessorDefinitions="" | |
873 | - /> | |
874 | - </FileConfiguration> | |
875 | - <FileConfiguration | |
876 | - Name="Private Release|Win32" | |
877 | - ExcludedFromBuild="true" | |
878 | - > | |
879 | - <Tool | |
880 | - Name="VCCLCompilerTool" | |
881 | - AdditionalIncludeDirectories="" | |
882 | - PreprocessorDefinitions="" | |
883 | - /> | |
884 | - </FileConfiguration> | |
885 | - <FileConfiguration | |
886 | - Name="Debug|Win32" | |
887 | - ExcludedFromBuild="true" | |
888 | - > | |
889 | - <Tool | |
890 | - Name="VCCLCompilerTool" | |
891 | - AdditionalIncludeDirectories="" | |
892 | - PreprocessorDefinitions="" | |
893 | - /> | |
894 | - </FileConfiguration> | |
895 | - </File> | |
896 | - <File | |
897 | - RelativePath="..\..\osx\makefile" | |
898 | - > | |
899 | - </File> | |
900 | 772 | </Filter> |
901 | 773 | </Files> |
902 | 774 | <Globals> |
@@ -38,7 +38,8 @@ enum | ||
38 | 38 | WM_TRAYICON, |
39 | 39 | WM_SHOWGUI, |
40 | 40 | WM_SHOWMENU, |
41 | - WM_PROCURL | |
41 | + WM_PROCURL, | |
42 | + WM_UPDATETRAFFIC | |
42 | 43 | }; |
43 | 44 | |
44 | 45 | class IdData |
@@ -19,6 +19,7 @@ | ||
19 | 19 | #define IDR_VERMENU 133 |
20 | 20 | #define IDD_CHANINFO 136 |
21 | 21 | #define IDR_LTRAYMENU 137 |
22 | +#define IDD_TRAFFIC 143 | |
22 | 23 | #define IDC_LIST1 1000 |
23 | 24 | #define IDC_BUTTON7 1001 |
24 | 25 | #define IDC_ABOUTVER 1002 |
@@ -52,8 +53,9 @@ | ||
52 | 53 | #define IDC_BUTTON5 1020 |
53 | 54 | #define IDC_EDIT_MAXRELAYS 1020 |
54 | 55 | #define IDC_BUTTON6 1021 |
55 | -#define IDC_APPLY_MAX_RELAYS 1021 | |
56 | 56 | #define IDC_APPLY_MAXRELAYS 1021 |
57 | +#define IDC_STATIC_UP 1023 | |
58 | +#define IDC_STATIC_DOWN 1024 | |
57 | 59 | #define IDC_EDIT3 1025 |
58 | 60 | #define IDC_EDIT5 1027 |
59 | 61 | #define IDC_LOGDEBUG 1037 |
@@ -104,15 +106,17 @@ | ||
104 | 106 | #define ID_POPUP_TOPMOST 32828 |
105 | 107 | #define ID_32829 32829 |
106 | 108 | #define ID_POPUP_START_WITH_GUI 32830 |
109 | +#define ID_POPUP_32831 32831 | |
110 | +#define ID_POPUP_TRAFFIC 32832 | |
107 | 111 | #define IDC_STATIC -1 |
108 | 112 | |
109 | 113 | // Next default values for new objects |
110 | 114 | // |
111 | 115 | #ifdef APSTUDIO_INVOKED |
112 | 116 | #ifndef APSTUDIO_READONLY_SYMBOLS |
113 | -#define _APS_NEXT_RESOURCE_VALUE 143 | |
114 | -#define _APS_NEXT_COMMAND_VALUE 32831 | |
115 | -#define _APS_NEXT_CONTROL_VALUE 1022 | |
117 | +#define _APS_NEXT_RESOURCE_VALUE 144 | |
118 | +#define _APS_NEXT_COMMAND_VALUE 32833 | |
119 | +#define _APS_NEXT_CONTROL_VALUE 1025 | |
116 | 120 | #define _APS_NEXT_SYMED_VALUE 110 |
117 | 121 | #endif |
118 | 122 | #endif |
@@ -45,8 +45,8 @@ extern int version_ex; // PP | ||
45 | 45 | //#define VERSION_EX 1 |
46 | 46 | static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only |
47 | 47 | static const int PCP_CLIENT_VERSION_EX_NUMBER = 27; |
48 | -static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-4)"; | |
49 | -static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-4)"; | |
48 | +static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-5)"; | |
49 | +static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-5)"; | |
50 | 50 | #endif |
51 | 51 | |
52 | 52 | // ------------------------------------------------ |
@@ -1469,106 +1469,10 @@ | ||
1469 | 1469 | <Filter |
1470 | 1470 | Name="Unix Source" |
1471 | 1471 | > |
1472 | - <File | |
1473 | - RelativePath="..\..\unix\usocket.cpp" | |
1474 | - > | |
1475 | - <FileConfiguration | |
1476 | - Name="Private Release|Win32" | |
1477 | - ExcludedFromBuild="true" | |
1478 | - > | |
1479 | - <Tool | |
1480 | - Name="VCCLCompilerTool" | |
1481 | - AdditionalIncludeDirectories="" | |
1482 | - PreprocessorDefinitions="" | |
1483 | - /> | |
1484 | - </FileConfiguration> | |
1485 | - <FileConfiguration | |
1486 | - Name="Debug|Win32" | |
1487 | - ExcludedFromBuild="true" | |
1488 | - > | |
1489 | - <Tool | |
1490 | - Name="VCCLCompilerTool" | |
1491 | - AdditionalIncludeDirectories="" | |
1492 | - PreprocessorDefinitions="" | |
1493 | - /> | |
1494 | - </FileConfiguration> | |
1495 | - <FileConfiguration | |
1496 | - Name="Release|Win32" | |
1497 | - ExcludedFromBuild="true" | |
1498 | - > | |
1499 | - <Tool | |
1500 | - Name="VCCLCompilerTool" | |
1501 | - AdditionalIncludeDirectories="" | |
1502 | - PreprocessorDefinitions="" | |
1503 | - /> | |
1504 | - </FileConfiguration> | |
1505 | - <FileConfiguration | |
1506 | - Name="Private Debug|Win32" | |
1507 | - ExcludedFromBuild="true" | |
1508 | - > | |
1509 | - <Tool | |
1510 | - Name="VCCLCompilerTool" | |
1511 | - AdditionalIncludeDirectories="" | |
1512 | - PreprocessorDefinitions="" | |
1513 | - /> | |
1514 | - </FileConfiguration> | |
1515 | - </File> | |
1516 | - <File | |
1517 | - RelativePath="..\..\unix\usys.cpp" | |
1518 | - > | |
1519 | - <FileConfiguration | |
1520 | - Name="Private Release|Win32" | |
1521 | - ExcludedFromBuild="true" | |
1522 | - > | |
1523 | - <Tool | |
1524 | - Name="VCCLCompilerTool" | |
1525 | - AdditionalIncludeDirectories="" | |
1526 | - PreprocessorDefinitions="" | |
1527 | - /> | |
1528 | - </FileConfiguration> | |
1529 | - <FileConfiguration | |
1530 | - Name="Debug|Win32" | |
1531 | - ExcludedFromBuild="true" | |
1532 | - > | |
1533 | - <Tool | |
1534 | - Name="VCCLCompilerTool" | |
1535 | - AdditionalIncludeDirectories="" | |
1536 | - PreprocessorDefinitions="" | |
1537 | - /> | |
1538 | - </FileConfiguration> | |
1539 | - <FileConfiguration | |
1540 | - Name="Release|Win32" | |
1541 | - ExcludedFromBuild="true" | |
1542 | - > | |
1543 | - <Tool | |
1544 | - Name="VCCLCompilerTool" | |
1545 | - AdditionalIncludeDirectories="" | |
1546 | - PreprocessorDefinitions="" | |
1547 | - /> | |
1548 | - </FileConfiguration> | |
1549 | - <FileConfiguration | |
1550 | - Name="Private Debug|Win32" | |
1551 | - ExcludedFromBuild="true" | |
1552 | - > | |
1553 | - <Tool | |
1554 | - Name="VCCLCompilerTool" | |
1555 | - AdditionalIncludeDirectories="" | |
1556 | - PreprocessorDefinitions="" | |
1557 | - /> | |
1558 | - </FileConfiguration> | |
1559 | - </File> | |
1560 | 1472 | </Filter> |
1561 | 1473 | <Filter |
1562 | 1474 | Name="Unix Includes" |
1563 | 1475 | > |
1564 | - <File | |
1565 | - RelativePath="..\..\unix\usocket.h" | |
1566 | - > | |
1567 | - </File> | |
1568 | - <File | |
1569 | - RelativePath="..\..\unix\usys.h" | |
1570 | - > | |
1571 | - </File> | |
1572 | 1476 | </Filter> |
1573 | 1477 | </Files> |
1574 | 1478 | <Globals> |
@@ -32,6 +32,8 @@ | ||
32 | 32 | #include "version2.h" |
33 | 33 | #include "gdiplus.h" |
34 | 34 | #include "time.h" |
35 | +#include "stats.h" | |
36 | +#include "sys.h" | |
35 | 37 | #ifdef _DEBUG |
36 | 38 | #include "chkMemoryLeak.h" |
37 | 39 | #define DEBUG_NEW new(__FILE__, __LINE__) |
@@ -75,8 +77,13 @@ bool chanInfoIsRelayed; | ||
75 | 77 | String exePath; |
76 | 78 | ULONG_PTR gdiplusToken; |
77 | 79 | |
80 | +extern Stats stats; | |
81 | +ThreadInfo trafficDlgThread; | |
82 | +HWND trafficDlg = NULL; | |
83 | + | |
78 | 84 | // プロトタイプ宣言 |
79 | 85 | void createGUI(HWND); |
86 | +LRESULT CALLBACK TrafficDlgProc(HWND, UINT, WPARAM, LPARAM); | |
80 | 87 | |
81 | 88 | // --------------------------------- |
82 | 89 | Sys * APICALL MyPeercastInst::createSys() |
@@ -1268,6 +1275,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) | ||
1268 | 1275 | peercastInst->saveSettings(); |
1269 | 1276 | break; |
1270 | 1277 | |
1278 | + case ID_POPUP_TRAFFIC: | |
1279 | + // トラフィックモニタ起動 | |
1280 | + if (winDistinctionNT) | |
1281 | + DialogBox(hInst, (LPCTSTR)IDD_TRAFFIC, hWnd, (DLGPROC)TrafficDlgProc); | |
1282 | + else | |
1283 | + { | |
1284 | + HWND WKDLG; //JP-Patch | |
1285 | + WKDLG = CreateDialog(hInst, (LPCTSTR)IDD_CHANINFO, hWnd, (DLGPROC)TrafficDlgProc); //JP-Patch | |
1286 | + ShowWindow(WKDLG,SW_SHOWNORMAL); //JP-Patch | |
1287 | + } | |
1288 | + break; | |
1289 | + | |
1271 | 1290 | case ID_POPUP_EXIT_CONFIRM: |
1272 | 1291 | case IDM_EXIT: |
1273 | 1292 | DestroyWindow(hWnd); |
@@ -1496,3 +1515,102 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa | ||
1496 | 1515 | } |
1497 | 1516 | return FALSE; |
1498 | 1517 | } |
1518 | + | |
1519 | +// control thread (Traffic dialog) | |
1520 | +THREAD_PROC trafficDlgUpdate(ThreadInfo *thread) | |
1521 | +{ | |
1522 | + thread->finish = false; | |
1523 | + | |
1524 | + while (trafficDlg && thread->active) | |
1525 | + { | |
1526 | + SendMessage(trafficDlg, WM_UPDATETRAFFIC, 0, 0); | |
1527 | + Sleep(1000); | |
1528 | + } | |
1529 | + | |
1530 | + thread->finish = true; | |
1531 | + | |
1532 | + return 0; | |
1533 | +} | |
1534 | + | |
1535 | +// Dialog procedure (Traffic dialog) | |
1536 | +LRESULT CALLBACK TrafficDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) | |
1537 | +{ | |
1538 | + switch (message) | |
1539 | + { | |
1540 | + case WM_INITDIALOG: | |
1541 | + // 既に開いてる | |
1542 | + if (trafficDlg || trafficDlgThread.active) | |
1543 | + { | |
1544 | + if (winDistinctionNT) | |
1545 | + EndDialog(hDlg, 0); | |
1546 | + else | |
1547 | + DestroyWindow(hDlg); | |
1548 | + return FALSE; | |
1549 | + } | |
1550 | + | |
1551 | + trafficDlg = hDlg; | |
1552 | + trafficDlgThread.func = trafficDlgUpdate; | |
1553 | + if (!sys->startThread(&trafficDlgThread)){ | |
1554 | + MessageBox(NULL,"Unable to start GUI","PeerCast",MB_OK|MB_ICONERROR); | |
1555 | + PostMessage(hDlg,WM_DESTROY,0,0); | |
1556 | + } | |
1557 | + | |
1558 | + break; | |
1559 | + | |
1560 | + case WM_UPDATETRAFFIC: | |
1561 | + { | |
1562 | + enum unitSymbol { B, KB, MB, GB }; | |
1563 | + const unsigned long int unit[] = { 1, 1024, 1024*1024, 1024*1024*1024 }; | |
1564 | + char suffix[][3] = { "B", "KB", "MB", "GB" }; | |
1565 | + const int bufsize = 60; | |
1566 | + char szUp[bufsize], szDown[bufsize]; | |
1567 | + unsigned int totalDown = stats.getCurrent(Stats::BYTESIN) - stats.getCurrent(Stats::LOCALBYTESIN); | |
1568 | + unsigned int totalUp = stats.getCurrent(Stats::BYTESOUT) - stats.getCurrent(Stats::LOCALBYTESOUT); | |
1569 | + | |
1570 | + // up | |
1571 | + for (int i=GB; i>0; --i) | |
1572 | + { | |
1573 | + if (totalUp >= unit[i]) | |
1574 | + { | |
1575 | + sprintf_s<bufsize>(szUp, "%.2f%s", (double)totalUp/unit[i], suffix[i]); | |
1576 | + break; | |
1577 | + } | |
1578 | + | |
1579 | + if (i == 1) | |
1580 | + sprintf_s<bufsize>(szUp, "%d%s", totalUp, suffix[0]); | |
1581 | + } | |
1582 | + | |
1583 | + // down | |
1584 | + for (int i=GB; i>0; --i) | |
1585 | + { | |
1586 | + if (totalDown >= unit[i]) | |
1587 | + { | |
1588 | + sprintf_s<bufsize>(szDown, "%.2f%s", (double)totalDown/unit[i], suffix[i]); | |
1589 | + break; | |
1590 | + } | |
1591 | + | |
1592 | + if (i == 1) | |
1593 | + sprintf_s<bufsize>(szDown, "%d%s", totalDown, suffix[0]); | |
1594 | + } | |
1595 | + | |
1596 | + SetDlgItemText(hDlg, IDC_STATIC_UP, szUp); | |
1597 | + SetDlgItemText(hDlg, IDC_STATIC_DOWN, szDown); | |
1598 | + } | |
1599 | + break; | |
1600 | + | |
1601 | + case WM_CLOSE: | |
1602 | + trafficDlg = NULL; | |
1603 | + trafficDlgThread.active = false; | |
1604 | + if (winDistinctionNT) | |
1605 | + EndDialog(hDlg, 0); | |
1606 | + else | |
1607 | + DestroyWindow(hDlg); | |
1608 | + | |
1609 | + break; | |
1610 | + | |
1611 | + case WM_DESTROY: | |
1612 | + break; | |
1613 | + } | |
1614 | + | |
1615 | + return FALSE; | |
1616 | +} | |
\ No newline at end of file |
@@ -21,6 +21,54 @@ | ||
21 | 21 | #undef APSTUDIO_READONLY_SYMBOLS |
22 | 22 | |
23 | 23 | ///////////////////////////////////////////////////////////////////////////// |
24 | +// 日本語 resources | |
25 | + | |
26 | +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN) | |
27 | +#ifdef _WIN32 | |
28 | +LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT | |
29 | +#pragma code_page(932) | |
30 | +#endif //_WIN32 | |
31 | + | |
32 | +///////////////////////////////////////////////////////////////////////////// | |
33 | +// | |
34 | +// Dialog | |
35 | +// | |
36 | + | |
37 | +IDD_TRAFFIC DIALOGEX 0, 0, 73, 62 | |
38 | +STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | |
39 | +CAPTION "トラフィックモニタ" | |
40 | +FONT 8, "MS Shell Dlg", 400, 0, 0x1 | |
41 | +BEGIN | |
42 | + GROUPBOX "Up",IDC_STATIC,7,7,58,23 | |
43 | + RTEXT "0B",IDC_STATIC_UP,12,16,47,9 | |
44 | + GROUPBOX "Down",IDC_STATIC,7,32,58,23 | |
45 | + RTEXT "0B",IDC_STATIC_DOWN,12,41,47,9 | |
46 | +END | |
47 | + | |
48 | + | |
49 | +///////////////////////////////////////////////////////////////////////////// | |
50 | +// | |
51 | +// DESIGNINFO | |
52 | +// | |
53 | + | |
54 | +#ifdef APSTUDIO_INVOKED | |
55 | +GUIDELINES DESIGNINFO | |
56 | +BEGIN | |
57 | + IDD_TRAFFIC, DIALOG | |
58 | + BEGIN | |
59 | + LEFTMARGIN, 7 | |
60 | + RIGHTMARGIN, 65 | |
61 | + TOPMARGIN, 7 | |
62 | + BOTTOMMARGIN, 55 | |
63 | + END | |
64 | +END | |
65 | +#endif // APSTUDIO_INVOKED | |
66 | + | |
67 | +#endif // 日本語 resources | |
68 | +///////////////////////////////////////////////////////////////////////////// | |
69 | + | |
70 | + | |
71 | +///////////////////////////////////////////////////////////////////////////// | |
24 | 72 | // ニュートラル (システム標準) resources |
25 | 73 | |
26 | 74 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD) |
@@ -39,6 +87,7 @@ BEGIN | ||
39 | 87 | POPUP "popup" |
40 | 88 | BEGIN |
41 | 89 | MENUITEM "情報", ID_POPUP_ABOUT |
90 | + MENUITEM "トラフィックモニタ", ID_POPUP_TRAFFIC | |
42 | 91 | MENUITEM "ヘルプ", ID_POPUP_HELP |
43 | 92 | MENUITEM SEPARATOR |
44 | 93 | POPUP "ポップアップメッセージ" |
@@ -765,138 +765,10 @@ | ||
765 | 765 | <Filter |
766 | 766 | Name="Linux" |
767 | 767 | > |
768 | - <File | |
769 | - RelativePath="..\..\linux\main.cpp" | |
770 | - > | |
771 | - <FileConfiguration | |
772 | - Name="Private Debug|Win32" | |
773 | - ExcludedFromBuild="true" | |
774 | - > | |
775 | - <Tool | |
776 | - Name="VCCLCompilerTool" | |
777 | - AdditionalIncludeDirectories="" | |
778 | - PreprocessorDefinitions="" | |
779 | - /> | |
780 | - </FileConfiguration> | |
781 | - <FileConfiguration | |
782 | - Name="Release|Win32" | |
783 | - ExcludedFromBuild="true" | |
784 | - > | |
785 | - <Tool | |
786 | - Name="VCCLCompilerTool" | |
787 | - AdditionalIncludeDirectories="" | |
788 | - PreprocessorDefinitions="" | |
789 | - /> | |
790 | - </FileConfiguration> | |
791 | - <FileConfiguration | |
792 | - Name="Private Release|Win32" | |
793 | - ExcludedFromBuild="true" | |
794 | - > | |
795 | - <Tool | |
796 | - Name="VCCLCompilerTool" | |
797 | - AdditionalIncludeDirectories="" | |
798 | - PreprocessorDefinitions="" | |
799 | - /> | |
800 | - </FileConfiguration> | |
801 | - <FileConfiguration | |
802 | - Name="Debug|Win32" | |
803 | - ExcludedFromBuild="true" | |
804 | - > | |
805 | - <Tool | |
806 | - Name="VCCLCompilerTool" | |
807 | - AdditionalIncludeDirectories="" | |
808 | - PreprocessorDefinitions="" | |
809 | - /> | |
810 | - </FileConfiguration> | |
811 | - </File> | |
812 | - <File | |
813 | - RelativePath="..\..\linux\makefile" | |
814 | - > | |
815 | - <FileConfiguration | |
816 | - Name="Private Debug|Win32" | |
817 | - ExcludedFromBuild="true" | |
818 | - > | |
819 | - <Tool | |
820 | - Name="VCCustomBuildTool" | |
821 | - /> | |
822 | - </FileConfiguration> | |
823 | - <FileConfiguration | |
824 | - Name="Release|Win32" | |
825 | - ExcludedFromBuild="true" | |
826 | - > | |
827 | - <Tool | |
828 | - Name="VCCustomBuildTool" | |
829 | - /> | |
830 | - </FileConfiguration> | |
831 | - <FileConfiguration | |
832 | - Name="Private Release|Win32" | |
833 | - ExcludedFromBuild="true" | |
834 | - > | |
835 | - <Tool | |
836 | - Name="VCCustomBuildTool" | |
837 | - /> | |
838 | - </FileConfiguration> | |
839 | - <FileConfiguration | |
840 | - Name="Debug|Win32" | |
841 | - ExcludedFromBuild="true" | |
842 | - > | |
843 | - <Tool | |
844 | - Name="VCCustomBuildTool" | |
845 | - /> | |
846 | - </FileConfiguration> | |
847 | - </File> | |
848 | 768 | </Filter> |
849 | 769 | <Filter |
850 | 770 | Name="OSX" |
851 | 771 | > |
852 | - <File | |
853 | - RelativePath="..\..\osx\main.cpp" | |
854 | - > | |
855 | - <FileConfiguration | |
856 | - Name="Private Debug|Win32" | |
857 | - ExcludedFromBuild="true" | |
858 | - > | |
859 | - <Tool | |
860 | - Name="VCCLCompilerTool" | |
861 | - AdditionalIncludeDirectories="" | |
862 | - PreprocessorDefinitions="" | |
863 | - /> | |
864 | - </FileConfiguration> | |
865 | - <FileConfiguration | |
866 | - Name="Release|Win32" | |
867 | - ExcludedFromBuild="true" | |
868 | - > | |
869 | - <Tool | |
870 | - Name="VCCLCompilerTool" | |
871 | - AdditionalIncludeDirectories="" | |
872 | - PreprocessorDefinitions="" | |
873 | - /> | |
874 | - </FileConfiguration> | |
875 | - <FileConfiguration | |
876 | - Name="Private Release|Win32" | |
877 | - ExcludedFromBuild="true" | |
878 | - > | |
879 | - <Tool | |
880 | - Name="VCCLCompilerTool" | |
881 | - AdditionalIncludeDirectories="" | |
882 | - PreprocessorDefinitions="" | |
883 | - /> | |
884 | - </FileConfiguration> | |
885 | - <FileConfiguration | |
886 | - Name="Debug|Win32" | |
887 | - ExcludedFromBuild="true" | |
888 | - > | |
889 | - <Tool | |
890 | - Name="VCCLCompilerTool" | |
891 | - AdditionalIncludeDirectories="" | |
892 | - PreprocessorDefinitions="" | |
893 | - /> | |
894 | - </FileConfiguration> | |
895 | - </File> | |
896 | - <File | |
897 | - RelativePath="..\..\osx\makefile" | |
898 | - > | |
899 | - </File> | |
900 | 772 | </Filter> |
901 | 773 | </Files> |
902 | 774 | <Globals> |
@@ -38,7 +38,8 @@ enum | ||
38 | 38 | WM_TRAYICON, |
39 | 39 | WM_SHOWGUI, |
40 | 40 | WM_SHOWMENU, |
41 | - WM_PROCURL | |
41 | + WM_PROCURL, | |
42 | + WM_UPDATETRAFFIC | |
42 | 43 | }; |
43 | 44 | |
44 | 45 | class IdData |
@@ -19,6 +19,7 @@ | ||
19 | 19 | #define IDR_VERMENU 133 |
20 | 20 | #define IDD_CHANINFO 136 |
21 | 21 | #define IDR_LTRAYMENU 137 |
22 | +#define IDD_TRAFFIC 143 | |
22 | 23 | #define IDC_LIST1 1000 |
23 | 24 | #define IDC_BUTTON7 1001 |
24 | 25 | #define IDC_ABOUTVER 1002 |
@@ -52,8 +53,9 @@ | ||
52 | 53 | #define IDC_BUTTON5 1020 |
53 | 54 | #define IDC_EDIT_MAXRELAYS 1020 |
54 | 55 | #define IDC_BUTTON6 1021 |
55 | -#define IDC_APPLY_MAX_RELAYS 1021 | |
56 | 56 | #define IDC_APPLY_MAXRELAYS 1021 |
57 | +#define IDC_STATIC_UP 1023 | |
58 | +#define IDC_STATIC_DOWN 1024 | |
57 | 59 | #define IDC_EDIT3 1025 |
58 | 60 | #define IDC_EDIT5 1027 |
59 | 61 | #define IDC_LOGDEBUG 1037 |
@@ -104,15 +106,17 @@ | ||
104 | 106 | #define ID_POPUP_TOPMOST 32828 |
105 | 107 | #define ID_32829 32829 |
106 | 108 | #define ID_POPUP_START_WITH_GUI 32830 |
109 | +#define ID_POPUP_32831 32831 | |
110 | +#define ID_POPUP_TRAFFIC 32832 | |
107 | 111 | #define IDC_STATIC -1 |
108 | 112 | |
109 | 113 | // Next default values for new objects |
110 | 114 | // |
111 | 115 | #ifdef APSTUDIO_INVOKED |
112 | 116 | #ifndef APSTUDIO_READONLY_SYMBOLS |
113 | -#define _APS_NEXT_RESOURCE_VALUE 143 | |
114 | -#define _APS_NEXT_COMMAND_VALUE 32831 | |
115 | -#define _APS_NEXT_CONTROL_VALUE 1022 | |
117 | +#define _APS_NEXT_RESOURCE_VALUE 144 | |
118 | +#define _APS_NEXT_COMMAND_VALUE 32833 | |
119 | +#define _APS_NEXT_CONTROL_VALUE 1025 | |
116 | 120 | #define _APS_NEXT_SYMED_VALUE 110 |
117 | 121 | #endif |
118 | 122 | #endif |