OSDN Git Service

トラフィックモニタを追加 IM0027-5
authoreru <eru01@users.sourceforge.jp>
Sat, 28 Jun 2008 05:18:20 +0000 (05:18 +0000)
committereru <eru01@users.sourceforge.jp>
Sat, 28 Jun 2008 05:18:20 +0000 (05:18 +0000)
14 files changed:
PeerCast.root/PeerCast/core/common/version2.h
PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj
PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
PeerCast.root/PeerCast/ui/win32/simple/Simple.rc
PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj
PeerCast.root/PeerCast/ui/win32/simple/gui.h
PeerCast.root/PeerCast/ui/win32/simple/resource.h
c:/Git/PeerCast.root/PeerCast/core/common/version2.h
c:/Git/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj
c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.rc
c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj
c:/Git/PeerCast.root/PeerCast/ui/win32/simple/gui.h
c:/Git/PeerCast.root/PeerCast/ui/win32/simple/resource.h

index f9517a0..6dec935 100644 (file)
@@ -45,8 +45,8 @@ extern int version_ex; // PP
 //#define VERSION_EX 1
 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
 static const int  PCP_CLIENT_VERSION_EX_NUMBER = 27;
-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-4)";
-static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-4)";
+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-5)";
+static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-5)";
 #endif
 
 // ------------------------------------------------
index a8ddb0d..c7beea7 100644 (file)
                <Filter
                        Name="Unix Source"
                        >
-                       <File
-                               RelativePath="..\..\unix\usocket.cpp"
-                               >
-                               <FileConfiguration
-                                       Name="Private Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Private Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\unix\usys.cpp"
-                               >
-                               <FileConfiguration
-                                       Name="Private Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Private Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
                </Filter>
                <Filter
                        Name="Unix Includes"
                        >
-                       <File
-                               RelativePath="..\..\unix\usocket.h"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\unix\usys.h"
-                               >
-                       </File>
                </Filter>
        </Files>
        <Globals>
index 1575e87..d7b4fd4 100644 (file)
@@ -32,6 +32,8 @@
 #include "version2.h"
 #include "gdiplus.h"
 #include "time.h"
+#include "stats.h"
+#include "sys.h"
 #ifdef _DEBUG
 #include "chkMemoryLeak.h"
 #define DEBUG_NEW new(__FILE__, __LINE__)
@@ -75,8 +77,13 @@ bool chanInfoIsRelayed;
 String exePath;
 ULONG_PTR gdiplusToken;
 
+extern Stats stats;
+ThreadInfo trafficDlgThread;
+HWND trafficDlg = NULL;
+
 // \83v\83\8d\83g\83^\83C\83v\90é\8c¾
 void createGUI(HWND);
+LRESULT CALLBACK TrafficDlgProc(HWND, UINT, WPARAM, LPARAM);
 
 // ---------------------------------
 Sys * APICALL MyPeercastInst::createSys()
@@ -1268,6 +1275,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
                                        peercastInst->saveSettings();
                                        break;
 
+                               case ID_POPUP_TRAFFIC:
+                                       // \83g\83\89\83t\83B\83b\83N\83\82\83j\83^\8bN\93®
+                                       if (winDistinctionNT)
+                                               DialogBox(hInst, (LPCTSTR)IDD_TRAFFIC, hWnd, (DLGPROC)TrafficDlgProc);
+                                       else
+                                       {
+                                               HWND WKDLG; //JP-Patch
+                                               WKDLG = CreateDialog(hInst, (LPCTSTR)IDD_CHANINFO, hWnd, (DLGPROC)TrafficDlgProc); //JP-Patch
+                                               ShowWindow(WKDLG,SW_SHOWNORMAL); //JP-Patch
+                                       }
+                                       break;
+
                                case ID_POPUP_EXIT_CONFIRM:
                                case IDM_EXIT:
                                   DestroyWindow(hWnd);
@@ -1496,3 +1515,102 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
        }
     return FALSE;
 }
+
+// control thread (Traffic dialog)
+THREAD_PROC trafficDlgUpdate(ThreadInfo *thread)
+{
+       thread->finish = false;
+
+       while (trafficDlg && thread->active)
+       {
+               SendMessage(trafficDlg, WM_UPDATETRAFFIC, 0, 0);
+               Sleep(1000);
+       }
+
+       thread->finish = true;
+
+       return 0;
+}
+
+// Dialog procedure (Traffic dialog)
+LRESULT CALLBACK TrafficDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+       switch (message)
+       {
+       case WM_INITDIALOG:
+               // \8aù\82É\8aJ\82¢\82Ä\82é
+               if (trafficDlg || trafficDlgThread.active)
+               {
+                       if (winDistinctionNT)
+                               EndDialog(hDlg, 0);
+                       else
+                               DestroyWindow(hDlg);
+                       return FALSE;
+               }
+
+               trafficDlg = hDlg;
+               trafficDlgThread.func = trafficDlgUpdate;
+               if (!sys->startThread(&trafficDlgThread)){
+                       MessageBox(NULL,"Unable to start GUI","PeerCast",MB_OK|MB_ICONERROR);
+                       PostMessage(hDlg,WM_DESTROY,0,0);
+               }
+
+               break;
+
+       case WM_UPDATETRAFFIC:
+               {
+                       enum unitSymbol { B, KB, MB, GB };
+                       const unsigned long int unit[] = { 1, 1024, 1024*1024, 1024*1024*1024 };
+                       char suffix[][3] = { "B", "KB", "MB", "GB" };
+                       const int bufsize = 60;
+                       char szUp[bufsize], szDown[bufsize];
+                       unsigned int totalDown = stats.getCurrent(Stats::BYTESIN) - stats.getCurrent(Stats::LOCALBYTESIN);
+                       unsigned int totalUp = stats.getCurrent(Stats::BYTESOUT) - stats.getCurrent(Stats::LOCALBYTESOUT);
+
+                       // up
+                       for (int i=GB; i>0; --i)
+                       {
+                               if (totalUp >= unit[i])
+                               {
+                                       sprintf_s<bufsize>(szUp, "%.2f%s", (double)totalUp/unit[i], suffix[i]);
+                                       break;
+                               }
+
+                               if (i == 1)
+                                       sprintf_s<bufsize>(szUp, "%d%s", totalUp, suffix[0]);
+                       }
+
+                       // down
+                       for (int i=GB; i>0; --i)
+                       {
+                               if (totalDown >= unit[i])
+                               {
+                                       sprintf_s<bufsize>(szDown, "%.2f%s", (double)totalDown/unit[i], suffix[i]);
+                                       break;
+                               }
+
+                               if (i == 1)
+                                       sprintf_s<bufsize>(szDown, "%d%s", totalDown, suffix[0]);
+                       }
+
+                       SetDlgItemText(hDlg, IDC_STATIC_UP, szUp);
+                       SetDlgItemText(hDlg, IDC_STATIC_DOWN, szDown);
+               }
+               break;
+
+       case WM_CLOSE:
+               trafficDlg = NULL;
+               trafficDlgThread.active = false;
+               if (winDistinctionNT)
+                       EndDialog(hDlg, 0);
+               else
+                       DestroyWindow(hDlg);
+
+               break;
+
+       case WM_DESTROY:
+               break;
+       }
+
+       return FALSE;
+}
\ No newline at end of file
index d7e0440..dd97f4c 100644 (file)
 #undef APSTUDIO_READONLY_SYMBOLS
 
 /////////////////////////////////////////////////////////////////////////////
+// \93ú\96{\8cê resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)
+#ifdef _WIN32
+LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
+#pragma code_page(932)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_TRAFFIC DIALOGEX 0, 0, 73, 62
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "\83g\83\89\83t\83B\83b\83N\83\82\83j\83^"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+    GROUPBOX        "Up",IDC_STATIC,7,7,58,23
+    RTEXT           "0B",IDC_STATIC_UP,12,16,47,9
+    GROUPBOX        "Down",IDC_STATIC,7,32,58,23
+    RTEXT           "0B",IDC_STATIC_DOWN,12,41,47,9
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO 
+BEGIN
+    IDD_TRAFFIC, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 65
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 55
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+#endif    // \93ú\96{\8cê resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
 // \83j\83\85\81[\83g\83\89\83\8b (\83V\83X\83e\83\80\95W\8f\80) resources
 
 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD)
@@ -39,6 +87,7 @@ BEGIN
     POPUP "popup"
     BEGIN
         MENUITEM "\8fî\95ñ",                          ID_POPUP_ABOUT
+        MENUITEM "\83g\83\89\83t\83B\83b\83N\83\82\83j\83^",                   ID_POPUP_TRAFFIC
         MENUITEM "\83w\83\8b\83v",                         ID_POPUP_HELP
         MENUITEM SEPARATOR
         POPUP "\83|\83b\83v\83A\83b\83v\83\81\83b\83Z\81[\83W"
index 4a5a924..eda2cee 100644 (file)
                <Filter
                        Name="Linux"
                        >
-                       <File
-                               RelativePath="..\..\linux\main.cpp"
-                               >
-                               <FileConfiguration
-                                       Name="Private Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Private Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\linux\makefile"
-                               >
-                               <FileConfiguration
-                                       Name="Private Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCustomBuildTool"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCustomBuildTool"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Private Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCustomBuildTool"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCustomBuildTool"
-                                       />
-                               </FileConfiguration>
-                       </File>
                </Filter>
                <Filter
                        Name="OSX"
                        >
-                       <File
-                               RelativePath="..\..\osx\main.cpp"
-                               >
-                               <FileConfiguration
-                                       Name="Private Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Private Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\osx\makefile"
-                               >
-                       </File>
                </Filter>
        </Files>
        <Globals>
index 239f7d0..ad783e8 100644 (file)
@@ -38,7 +38,8 @@ enum
        WM_TRAYICON,
        WM_SHOWGUI,
        WM_SHOWMENU,
-       WM_PROCURL
+       WM_PROCURL,
+       WM_UPDATETRAFFIC
 };
 
 class IdData
index 798c282..ae6df11 100644 (file)
@@ -19,6 +19,7 @@
 #define IDR_VERMENU                     133
 #define IDD_CHANINFO                    136
 #define IDR_LTRAYMENU                   137
+#define IDD_TRAFFIC                     143
 #define IDC_LIST1                       1000
 #define IDC_BUTTON7                     1001
 #define IDC_ABOUTVER                    1002
@@ -52,8 +53,9 @@
 #define IDC_BUTTON5                     1020
 #define IDC_EDIT_MAXRELAYS              1020
 #define IDC_BUTTON6                     1021
-#define IDC_APPLY_MAX_RELAYS            1021
 #define IDC_APPLY_MAXRELAYS             1021
+#define IDC_STATIC_UP                   1023
+#define IDC_STATIC_DOWN                 1024
 #define IDC_EDIT3                       1025
 #define IDC_EDIT5                       1027
 #define IDC_LOGDEBUG                    1037
 #define ID_POPUP_TOPMOST                32828
 #define ID_32829                        32829
 #define ID_POPUP_START_WITH_GUI         32830
+#define ID_POPUP_32831                  32831
+#define ID_POPUP_TRAFFIC                32832
 #define IDC_STATIC                      -1
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        143
-#define _APS_NEXT_COMMAND_VALUE         32831
-#define _APS_NEXT_CONTROL_VALUE         1022
+#define _APS_NEXT_RESOURCE_VALUE        144
+#define _APS_NEXT_COMMAND_VALUE         32833
+#define _APS_NEXT_CONTROL_VALUE         1025
 #define _APS_NEXT_SYMED_VALUE           110
 #endif
 #endif
index f9517a0..6dec935 100644 (file)
@@ -45,8 +45,8 @@ extern int version_ex; // PP
 //#define VERSION_EX 1
 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
 static const int  PCP_CLIENT_VERSION_EX_NUMBER = 27;
-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-4)";
-static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-4)";
+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-5)";
+static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-5)";
 #endif
 
 // ------------------------------------------------
index a8ddb0d..c7beea7 100644 (file)
                <Filter
                        Name="Unix Source"
                        >
-                       <File
-                               RelativePath="..\..\unix\usocket.cpp"
-                               >
-                               <FileConfiguration
-                                       Name="Private Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Private Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\unix\usys.cpp"
-                               >
-                               <FileConfiguration
-                                       Name="Private Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Private Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
                </Filter>
                <Filter
                        Name="Unix Includes"
                        >
-                       <File
-                               RelativePath="..\..\unix\usocket.h"
-                               >
-                       </File>
-                       <File
-                               RelativePath="..\..\unix\usys.h"
-                               >
-                       </File>
                </Filter>
        </Files>
        <Globals>
index 1575e87..d7b4fd4 100644 (file)
@@ -32,6 +32,8 @@
 #include "version2.h"
 #include "gdiplus.h"
 #include "time.h"
+#include "stats.h"
+#include "sys.h"
 #ifdef _DEBUG
 #include "chkMemoryLeak.h"
 #define DEBUG_NEW new(__FILE__, __LINE__)
@@ -75,8 +77,13 @@ bool chanInfoIsRelayed;
 String exePath;
 ULONG_PTR gdiplusToken;
 
+extern Stats stats;
+ThreadInfo trafficDlgThread;
+HWND trafficDlg = NULL;
+
 // \83v\83\8d\83g\83^\83C\83v\90é\8c¾
 void createGUI(HWND);
+LRESULT CALLBACK TrafficDlgProc(HWND, UINT, WPARAM, LPARAM);
 
 // ---------------------------------
 Sys * APICALL MyPeercastInst::createSys()
@@ -1268,6 +1275,18 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
                                        peercastInst->saveSettings();
                                        break;
 
+                               case ID_POPUP_TRAFFIC:
+                                       // \83g\83\89\83t\83B\83b\83N\83\82\83j\83^\8bN\93®
+                                       if (winDistinctionNT)
+                                               DialogBox(hInst, (LPCTSTR)IDD_TRAFFIC, hWnd, (DLGPROC)TrafficDlgProc);
+                                       else
+                                       {
+                                               HWND WKDLG; //JP-Patch
+                                               WKDLG = CreateDialog(hInst, (LPCTSTR)IDD_CHANINFO, hWnd, (DLGPROC)TrafficDlgProc); //JP-Patch
+                                               ShowWindow(WKDLG,SW_SHOWNORMAL); //JP-Patch
+                                       }
+                                       break;
+
                                case ID_POPUP_EXIT_CONFIRM:
                                case IDM_EXIT:
                                   DestroyWindow(hWnd);
@@ -1496,3 +1515,102 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa
        }
     return FALSE;
 }
+
+// control thread (Traffic dialog)
+THREAD_PROC trafficDlgUpdate(ThreadInfo *thread)
+{
+       thread->finish = false;
+
+       while (trafficDlg && thread->active)
+       {
+               SendMessage(trafficDlg, WM_UPDATETRAFFIC, 0, 0);
+               Sleep(1000);
+       }
+
+       thread->finish = true;
+
+       return 0;
+}
+
+// Dialog procedure (Traffic dialog)
+LRESULT CALLBACK TrafficDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
+{
+       switch (message)
+       {
+       case WM_INITDIALOG:
+               // \8aù\82É\8aJ\82¢\82Ä\82é
+               if (trafficDlg || trafficDlgThread.active)
+               {
+                       if (winDistinctionNT)
+                               EndDialog(hDlg, 0);
+                       else
+                               DestroyWindow(hDlg);
+                       return FALSE;
+               }
+
+               trafficDlg = hDlg;
+               trafficDlgThread.func = trafficDlgUpdate;
+               if (!sys->startThread(&trafficDlgThread)){
+                       MessageBox(NULL,"Unable to start GUI","PeerCast",MB_OK|MB_ICONERROR);
+                       PostMessage(hDlg,WM_DESTROY,0,0);
+               }
+
+               break;
+
+       case WM_UPDATETRAFFIC:
+               {
+                       enum unitSymbol { B, KB, MB, GB };
+                       const unsigned long int unit[] = { 1, 1024, 1024*1024, 1024*1024*1024 };
+                       char suffix[][3] = { "B", "KB", "MB", "GB" };
+                       const int bufsize = 60;
+                       char szUp[bufsize], szDown[bufsize];
+                       unsigned int totalDown = stats.getCurrent(Stats::BYTESIN) - stats.getCurrent(Stats::LOCALBYTESIN);
+                       unsigned int totalUp = stats.getCurrent(Stats::BYTESOUT) - stats.getCurrent(Stats::LOCALBYTESOUT);
+
+                       // up
+                       for (int i=GB; i>0; --i)
+                       {
+                               if (totalUp >= unit[i])
+                               {
+                                       sprintf_s<bufsize>(szUp, "%.2f%s", (double)totalUp/unit[i], suffix[i]);
+                                       break;
+                               }
+
+                               if (i == 1)
+                                       sprintf_s<bufsize>(szUp, "%d%s", totalUp, suffix[0]);
+                       }
+
+                       // down
+                       for (int i=GB; i>0; --i)
+                       {
+                               if (totalDown >= unit[i])
+                               {
+                                       sprintf_s<bufsize>(szDown, "%.2f%s", (double)totalDown/unit[i], suffix[i]);
+                                       break;
+                               }
+
+                               if (i == 1)
+                                       sprintf_s<bufsize>(szDown, "%d%s", totalDown, suffix[0]);
+                       }
+
+                       SetDlgItemText(hDlg, IDC_STATIC_UP, szUp);
+                       SetDlgItemText(hDlg, IDC_STATIC_DOWN, szDown);
+               }
+               break;
+
+       case WM_CLOSE:
+               trafficDlg = NULL;
+               trafficDlgThread.active = false;
+               if (winDistinctionNT)
+                       EndDialog(hDlg, 0);
+               else
+                       DestroyWindow(hDlg);
+
+               break;
+
+       case WM_DESTROY:
+               break;
+       }
+
+       return FALSE;
+}
\ No newline at end of file
index d7e0440..dd97f4c 100644 (file)
 #undef APSTUDIO_READONLY_SYMBOLS
 
 /////////////////////////////////////////////////////////////////////////////
+// \93ú\96{\8cê resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_JPN)
+#ifdef _WIN32
+LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
+#pragma code_page(932)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_TRAFFIC DIALOGEX 0, 0, 73, 62
+STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "\83g\83\89\83t\83B\83b\83N\83\82\83j\83^"
+FONT 8, "MS Shell Dlg", 400, 0, 0x1
+BEGIN
+    GROUPBOX        "Up",IDC_STATIC,7,7,58,23
+    RTEXT           "0B",IDC_STATIC_UP,12,16,47,9
+    GROUPBOX        "Down",IDC_STATIC,7,32,58,23
+    RTEXT           "0B",IDC_STATIC_DOWN,12,41,47,9
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO 
+BEGIN
+    IDD_TRAFFIC, DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 65
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 55
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+#endif    // \93ú\96{\8cê resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+/////////////////////////////////////////////////////////////////////////////
 // \83j\83\85\81[\83g\83\89\83\8b (\83V\83X\83e\83\80\95W\8f\80) resources
 
 #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD)
@@ -39,6 +87,7 @@ BEGIN
     POPUP "popup"
     BEGIN
         MENUITEM "\8fî\95ñ",                          ID_POPUP_ABOUT
+        MENUITEM "\83g\83\89\83t\83B\83b\83N\83\82\83j\83^",                   ID_POPUP_TRAFFIC
         MENUITEM "\83w\83\8b\83v",                         ID_POPUP_HELP
         MENUITEM SEPARATOR
         POPUP "\83|\83b\83v\83A\83b\83v\83\81\83b\83Z\81[\83W"
index 4a5a924..eda2cee 100644 (file)
                <Filter
                        Name="Linux"
                        >
-                       <File
-                               RelativePath="..\..\linux\main.cpp"
-                               >
-                               <FileConfiguration
-                                       Name="Private Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Private Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\linux\makefile"
-                               >
-                               <FileConfiguration
-                                       Name="Private Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCustomBuildTool"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCustomBuildTool"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Private Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCustomBuildTool"
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCustomBuildTool"
-                                       />
-                               </FileConfiguration>
-                       </File>
                </Filter>
                <Filter
                        Name="OSX"
                        >
-                       <File
-                               RelativePath="..\..\osx\main.cpp"
-                               >
-                               <FileConfiguration
-                                       Name="Private Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Private Release|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                               <FileConfiguration
-                                       Name="Debug|Win32"
-                                       ExcludedFromBuild="true"
-                                       >
-                                       <Tool
-                                               Name="VCCLCompilerTool"
-                                               AdditionalIncludeDirectories=""
-                                               PreprocessorDefinitions=""
-                                       />
-                               </FileConfiguration>
-                       </File>
-                       <File
-                               RelativePath="..\..\osx\makefile"
-                               >
-                       </File>
                </Filter>
        </Files>
        <Globals>
index 239f7d0..ad783e8 100644 (file)
@@ -38,7 +38,8 @@ enum
        WM_TRAYICON,
        WM_SHOWGUI,
        WM_SHOWMENU,
-       WM_PROCURL
+       WM_PROCURL,
+       WM_UPDATETRAFFIC
 };
 
 class IdData
index 798c282..ae6df11 100644 (file)
@@ -19,6 +19,7 @@
 #define IDR_VERMENU                     133
 #define IDD_CHANINFO                    136
 #define IDR_LTRAYMENU                   137
+#define IDD_TRAFFIC                     143
 #define IDC_LIST1                       1000
 #define IDC_BUTTON7                     1001
 #define IDC_ABOUTVER                    1002
@@ -52,8 +53,9 @@
 #define IDC_BUTTON5                     1020
 #define IDC_EDIT_MAXRELAYS              1020
 #define IDC_BUTTON6                     1021
-#define IDC_APPLY_MAX_RELAYS            1021
 #define IDC_APPLY_MAXRELAYS             1021
+#define IDC_STATIC_UP                   1023
+#define IDC_STATIC_DOWN                 1024
 #define IDC_EDIT3                       1025
 #define IDC_EDIT5                       1027
 #define IDC_LOGDEBUG                    1037
 #define ID_POPUP_TOPMOST                32828
 #define ID_32829                        32829
 #define ID_POPUP_START_WITH_GUI         32830
+#define ID_POPUP_32831                  32831
+#define ID_POPUP_TRAFFIC                32832
 #define IDC_STATIC                      -1
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE        143
-#define _APS_NEXT_COMMAND_VALUE         32831
-#define _APS_NEXT_CONTROL_VALUE         1022
+#define _APS_NEXT_RESOURCE_VALUE        144
+#define _APS_NEXT_COMMAND_VALUE         32833
+#define _APS_NEXT_CONTROL_VALUE         1025
 #define _APS_NEXT_SYMED_VALUE           110
 #endif
 #endif