• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision3c597521dfec331b761453636a974a76eba951a3 (tree)
Time2008-06-28 14:18:20
Authoreru <eru01@user...>
Commitereru

Log Message

トラフィックモニタを追加

Change Summary

Incremental Difference

--- a/PeerCast.root/PeerCast/core/common/version2.h
+++ b/PeerCast.root/PeerCast/core/common/version2.h
@@ -45,8 +45,8 @@ extern int version_ex; // PP
4545 //#define VERSION_EX 1
4646 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
4747 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)";
5050 #endif
5151
5252 // ------------------------------------------------
--- a/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj
+++ b/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj
@@ -1469,106 +1469,10 @@
14691469 <Filter
14701470 Name="Unix Source"
14711471 >
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>
15601472 </Filter>
15611473 <Filter
15621474 Name="Unix Includes"
15631475 >
1564- <File
1565- RelativePath="..\..\unix\usocket.h"
1566- >
1567- </File>
1568- <File
1569- RelativePath="..\..\unix\usys.h"
1570- >
1571- </File>
15721476 </Filter>
15731477 </Files>
15741478 <Globals>
--- a/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
+++ b/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
@@ -32,6 +32,8 @@
3232 #include "version2.h"
3333 #include "gdiplus.h"
3434 #include "time.h"
35+#include "stats.h"
36+#include "sys.h"
3537 #ifdef _DEBUG
3638 #include "chkMemoryLeak.h"
3739 #define DEBUG_NEW new(__FILE__, __LINE__)
@@ -75,8 +77,13 @@ bool chanInfoIsRelayed;
7577 String exePath;
7678 ULONG_PTR gdiplusToken;
7779
80+extern Stats stats;
81+ThreadInfo trafficDlgThread;
82+HWND trafficDlg = NULL;
83+
7884 // プロトタイプ宣言
7985 void createGUI(HWND);
86+LRESULT CALLBACK TrafficDlgProc(HWND, UINT, WPARAM, LPARAM);
8087
8188 // ---------------------------------
8289 Sys * APICALL MyPeercastInst::createSys()
@@ -1268,6 +1275,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
12681275 peercastInst->saveSettings();
12691276 break;
12701277
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+
12711290 case ID_POPUP_EXIT_CONFIRM:
12721291 case IDM_EXIT:
12731292 DestroyWindow(hWnd);
@@ -1496,3 +1515,102 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
14961515 }
14971516 return FALSE;
14981517 }
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
--- a/PeerCast.root/PeerCast/ui/win32/simple/Simple.rc
+++ b/PeerCast.root/PeerCast/ui/win32/simple/Simple.rc
@@ -21,6 +21,54 @@
2121 #undef APSTUDIO_READONLY_SYMBOLS
2222
2323 /////////////////////////////////////////////////////////////////////////////
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+/////////////////////////////////////////////////////////////////////////////
2472 // ニュートラル (システム標準) resources
2573
2674 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD)
@@ -39,6 +87,7 @@ BEGIN
3987 POPUP "popup"
4088 BEGIN
4189 MENUITEM "情報", ID_POPUP_ABOUT
90+ MENUITEM "トラフィックモニタ", ID_POPUP_TRAFFIC
4291 MENUITEM "ヘルプ", ID_POPUP_HELP
4392 MENUITEM SEPARATOR
4493 POPUP "ポップアップメッセージ"
--- a/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj
+++ b/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj
@@ -765,138 +765,10 @@
765765 <Filter
766766 Name="Linux"
767767 >
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>
848768 </Filter>
849769 <Filter
850770 Name="OSX"
851771 >
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>
900772 </Filter>
901773 </Files>
902774 <Globals>
--- a/PeerCast.root/PeerCast/ui/win32/simple/gui.h
+++ b/PeerCast.root/PeerCast/ui/win32/simple/gui.h
@@ -38,7 +38,8 @@ enum
3838 WM_TRAYICON,
3939 WM_SHOWGUI,
4040 WM_SHOWMENU,
41- WM_PROCURL
41+ WM_PROCURL,
42+ WM_UPDATETRAFFIC
4243 };
4344
4445 class IdData
--- a/PeerCast.root/PeerCast/ui/win32/simple/resource.h
+++ b/PeerCast.root/PeerCast/ui/win32/simple/resource.h
@@ -19,6 +19,7 @@
1919 #define IDR_VERMENU 133
2020 #define IDD_CHANINFO 136
2121 #define IDR_LTRAYMENU 137
22+#define IDD_TRAFFIC 143
2223 #define IDC_LIST1 1000
2324 #define IDC_BUTTON7 1001
2425 #define IDC_ABOUTVER 1002
@@ -52,8 +53,9 @@
5253 #define IDC_BUTTON5 1020
5354 #define IDC_EDIT_MAXRELAYS 1020
5455 #define IDC_BUTTON6 1021
55-#define IDC_APPLY_MAX_RELAYS 1021
5656 #define IDC_APPLY_MAXRELAYS 1021
57+#define IDC_STATIC_UP 1023
58+#define IDC_STATIC_DOWN 1024
5759 #define IDC_EDIT3 1025
5860 #define IDC_EDIT5 1027
5961 #define IDC_LOGDEBUG 1037
@@ -104,15 +106,17 @@
104106 #define ID_POPUP_TOPMOST 32828
105107 #define ID_32829 32829
106108 #define ID_POPUP_START_WITH_GUI 32830
109+#define ID_POPUP_32831 32831
110+#define ID_POPUP_TRAFFIC 32832
107111 #define IDC_STATIC -1
108112
109113 // Next default values for new objects
110114 //
111115 #ifdef APSTUDIO_INVOKED
112116 #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
116120 #define _APS_NEXT_SYMED_VALUE 110
117121 #endif
118122 #endif
--- a/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
@@ -45,8 +45,8 @@ extern int version_ex; // PP
4545 //#define VERSION_EX 1
4646 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
4747 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)";
5050 #endif
5151
5252 // ------------------------------------------------
--- a/c:/Git/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj
+++ b/c:/Git/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj
@@ -1469,106 +1469,10 @@
14691469 <Filter
14701470 Name="Unix Source"
14711471 >
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>
15601472 </Filter>
15611473 <Filter
15621474 Name="Unix Includes"
15631475 >
1564- <File
1565- RelativePath="..\..\unix\usocket.h"
1566- >
1567- </File>
1568- <File
1569- RelativePath="..\..\unix\usys.h"
1570- >
1571- </File>
15721476 </Filter>
15731477 </Files>
15741478 <Globals>
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
@@ -32,6 +32,8 @@
3232 #include "version2.h"
3333 #include "gdiplus.h"
3434 #include "time.h"
35+#include "stats.h"
36+#include "sys.h"
3537 #ifdef _DEBUG
3638 #include "chkMemoryLeak.h"
3739 #define DEBUG_NEW new(__FILE__, __LINE__)
@@ -75,8 +77,13 @@ bool chanInfoIsRelayed;
7577 String exePath;
7678 ULONG_PTR gdiplusToken;
7779
80+extern Stats stats;
81+ThreadInfo trafficDlgThread;
82+HWND trafficDlg = NULL;
83+
7884 // プロトタイプ宣言
7985 void createGUI(HWND);
86+LRESULT CALLBACK TrafficDlgProc(HWND, UINT, WPARAM, LPARAM);
8087
8188 // ---------------------------------
8289 Sys * APICALL MyPeercastInst::createSys()
@@ -1268,6 +1275,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
12681275 peercastInst->saveSettings();
12691276 break;
12701277
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+
12711290 case ID_POPUP_EXIT_CONFIRM:
12721291 case IDM_EXIT:
12731292 DestroyWindow(hWnd);
@@ -1496,3 +1515,102 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
14961515 }
14971516 return FALSE;
14981517 }
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
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.rc
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.rc
@@ -21,6 +21,54 @@
2121 #undef APSTUDIO_READONLY_SYMBOLS
2222
2323 /////////////////////////////////////////////////////////////////////////////
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+/////////////////////////////////////////////////////////////////////////////
2472 // ニュートラル (システム標準) resources
2573
2674 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD)
@@ -39,6 +87,7 @@ BEGIN
3987 POPUP "popup"
4088 BEGIN
4189 MENUITEM "情報", ID_POPUP_ABOUT
90+ MENUITEM "トラフィックモニタ", ID_POPUP_TRAFFIC
4291 MENUITEM "ヘルプ", ID_POPUP_HELP
4392 MENUITEM SEPARATOR
4493 POPUP "ポップアップメッセージ"
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj
@@ -765,138 +765,10 @@
765765 <Filter
766766 Name="Linux"
767767 >
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>
848768 </Filter>
849769 <Filter
850770 Name="OSX"
851771 >
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>
900772 </Filter>
901773 </Files>
902774 <Globals>
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/gui.h
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/gui.h
@@ -38,7 +38,8 @@ enum
3838 WM_TRAYICON,
3939 WM_SHOWGUI,
4040 WM_SHOWMENU,
41- WM_PROCURL
41+ WM_PROCURL,
42+ WM_UPDATETRAFFIC
4243 };
4344
4445 class IdData
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/resource.h
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/resource.h
@@ -19,6 +19,7 @@
1919 #define IDR_VERMENU 133
2020 #define IDD_CHANINFO 136
2121 #define IDR_LTRAYMENU 137
22+#define IDD_TRAFFIC 143
2223 #define IDC_LIST1 1000
2324 #define IDC_BUTTON7 1001
2425 #define IDC_ABOUTVER 1002
@@ -52,8 +53,9 @@
5253 #define IDC_BUTTON5 1020
5354 #define IDC_EDIT_MAXRELAYS 1020
5455 #define IDC_BUTTON6 1021
55-#define IDC_APPLY_MAX_RELAYS 1021
5656 #define IDC_APPLY_MAXRELAYS 1021
57+#define IDC_STATIC_UP 1023
58+#define IDC_STATIC_DOWN 1024
5759 #define IDC_EDIT3 1025
5860 #define IDC_EDIT5 1027
5961 #define IDC_LOGDEBUG 1037
@@ -104,15 +106,17 @@
104106 #define ID_POPUP_TOPMOST 32828
105107 #define ID_32829 32829
106108 #define ID_POPUP_START_WITH_GUI 32830
109+#define ID_POPUP_32831 32831
110+#define ID_POPUP_TRAFFIC 32832
107111 #define IDC_STATIC -1
108112
109113 // Next default values for new objects
110114 //
111115 #ifdef APSTUDIO_INVOKED
112116 #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
116120 #define _APS_NEXT_SYMED_VALUE 110
117121 #endif
118122 #endif