From 6692fefc16d0da00669c68f7584bfe12c34f40df Mon Sep 17 00:00:00 2001 From: eru Date: Thu, 22 Oct 2009 13:39:03 +0000 Subject: [PATCH] Vss2Git --- .../PeerCast/core/win32/lib/corelib.vcproj | 2752 ++++++++++++++++++-- .../PeerCast/ui/win32/Simple_vp/Simple.cpp | 1360 ++++++++++ PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.h | 65 + .../PeerCast/ui/win32/Simple_vp/Simple.ico | Bin 0 -> 1078 bytes .../PeerCast/ui/win32/Simple_vp/Simple.rc | 364 +++ .../PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj | 767 ++++++ .../ui/win32/Simple_vp/Simple_vp.vcproj.vspscc | 10 + .../PeerCast/ui/win32/Simple_vp/StdAfx.cpp | 9 + PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.h | 32 + .../PeerCast/ui/win32/Simple_vp/chkMemoryLeak.cpp | 21 + .../PeerCast/ui/win32/Simple_vp/chkMemoryLeak.h | 24 + PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.cpp | 1715 ++++++++++++ PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.h | 44 + .../PeerCast/ui/win32/Simple_vp/resource.h | 110 + .../PeerCast/ui/win32/Simple_vp/small.ico | Bin 0 -> 318 bytes .../PeerCast/ui/win32/Simple_vp/small1.ico | Bin 0 -> 318 bytes .../PeerCast/ui/win32/Simple_vp/small3.ico | Bin 0 -> 318 bytes .../PeerCast/ui/win32/simple/Simple.vcproj | 1369 +++++++++- .../PeerCast/core/win32/lib/corelib.vcproj | 2752 ++++++++++++++++++-- .../PeerCast/ui/win32/Simple_vp/Simple.cpp | 1360 ++++++++++ .../PeerCast/ui/win32/Simple_vp/Simple.h | 65 + .../PeerCast/ui/win32/Simple_vp/Simple.ico | Bin 0 -> 1078 bytes .../PeerCast/ui/win32/Simple_vp/Simple.rc | 364 +++ .../PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj | 767 ++++++ .../ui/win32/Simple_vp/Simple_vp.vcproj.vspscc | 10 + .../PeerCast/ui/win32/Simple_vp/StdAfx.cpp | 9 + .../PeerCast/ui/win32/Simple_vp/StdAfx.h | 32 + .../PeerCast/ui/win32/Simple_vp/chkMemoryLeak.cpp | 21 + .../PeerCast/ui/win32/Simple_vp/chkMemoryLeak.h | 24 + .../PeerCast/ui/win32/Simple_vp/gui.cpp | 1715 ++++++++++++ .../PeerCast/ui/win32/Simple_vp/gui.h | 44 + .../PeerCast/ui/win32/Simple_vp/resource.h | 110 + .../PeerCast/ui/win32/Simple_vp/small.ico | Bin 0 -> 318 bytes .../PeerCast/ui/win32/Simple_vp/small1.ico | Bin 0 -> 318 bytes .../PeerCast/ui/win32/Simple_vp/small3.ico | Bin 0 -> 318 bytes .../PeerCast/ui/win32/simple/Simple.vcproj | 1369 +++++++++- 36 files changed, 16558 insertions(+), 726 deletions(-) create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.cpp create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.h create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.ico create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.rc create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj.vspscc create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.cpp create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.h create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.cpp create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.h create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.cpp create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.h create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/resource.h create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/small.ico create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/small1.ico create mode 100644 PeerCast.root/PeerCast/ui/win32/Simple_vp/small3.ico create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.cpp create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.h create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.ico create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.rc create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj.vspscc create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.cpp create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.h create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.cpp create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.h create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.cpp create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.h create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/resource.h create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/small.ico create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/small1.ico create mode 100644 c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/small3.ico diff --git a/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj b/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj index d12268c..f135ffa 100644 --- a/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj +++ b/PeerCast.root/PeerCast/core/win32/lib/corelib.vcproj @@ -17,6 +17,9 @@ + @@ -173,6 +176,94 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + + + + - - - - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#include +#include "stdafx.h" +#include "resource.h" +#include "gui.h" +#include "channel.h" +#include "servent.h" +#include "servmgr.h" +#include "win32/wsys.h" +#include "peercast.h" +#include "simple.h" +#include "version2.h" +#ifdef _DEBUG +#include "chkMemoryLeak.h" +#define DEBUG_NEW new(__FILE__, __LINE__) +#define new DEBUG_NEW +#endif + +#define MAX_LOADSTRING 100 + +#define PLAY_CMD 7000 +#define RELAY_CMD 8000 +#define INFO_CMD 9000 +#define URL_CMD 10000 + +#define MAX_CHANNELS 999 + +extern "C" +{ + void loadIcons(HINSTANCE hInstance, HWND hWnd); +}; + +UINT g_iTaskbarCreated = ~0; // for PCRaw (tray icon) + +// PeerCast globals + +static int currNotify=0; +String iniFileName; +HWND guiWnd; +HWND mainWnd; +static HMENU trayMenu = NULL,ltrayMenu = NULL; // for PCRaw (tray icon) +bool showGUI=true; +bool allowMulti=false; +bool killMe=false; +bool allowTrayMenu=true; +static bool winDistinctionNT=false; +int seenNewVersionTime=0; +HICON icon1,icon2; +ChanInfo chanInfo; +bool chanInfoIsRelayed; +//GnuID lastPlayID; +String exePath; +FileStream fs; + +// --------------------------------- +Sys * APICALL MyPeercastInst::createSys() +{ + return new WSys(mainWnd); +} +// --------------------------------- +const char * APICALL MyPeercastApp ::getIniFilename() +{ + return iniFileName.cstr(); +} + +// --------------------------------- +const char *APICALL MyPeercastApp ::getClientTypeOS() +{ + return PCX_OS_WIN32; +} + +// --------------------------------- +const char * APICALL MyPeercastApp::getPath() +{ + return exePath.cstr(); +} + +// --------------------------------- JP-EX +void APICALL MyPeercastApp ::openLogFile() +{ + logFile.openWriteReplace("log.txt"); +} +// --------------------------------- JP-EX +void APICALL MyPeercastApp ::getDirectory() +{ + char path_buffer[256],drive[32],dir[128]; + GetModuleFileName(NULL,path_buffer,255); + _splitpath(path_buffer,drive,dir,NULL,NULL); + sprintf(servMgr->modulePath,"%s%s",drive,dir); +} +// --------------------------------- JP-EX +bool APICALL MyPeercastApp ::clearTemp() +{ + if (servMgr->clearPLS) + return true; + + return false; +} + + +class NOTIFYICONDATA2 +{ +public: + DWORD cbSize; // DWORD + HWND hWnd; // HWND + UINT uID; // UINT + UINT uFlags; // UINT + UINT uCallbackMessage; // UINT + HICON hIcon; // HICON + char szTip[128]; // char[128] + DWORD dwState; // DWORD + DWORD dwStateMask; // DWORD + char szInfo[256]; // char[256] + UINT uTimeoutOrVersion; // UINT + char szInfoTitle[64]; // char[64] + DWORD dwInfoFlags; // DWORD + //GUID guidItem; > IE 6 +}; + +NOTIFYICONDATA2 trayIcon; + + +// Global Variables: +HINSTANCE hInst; // current instance +TCHAR szTitle[MAX_LOADSTRING]; // The title bar text +TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text + +// Foward declarations of functions included in this code module: +ATOM MyRegisterClass(HINSTANCE hInstance); +BOOL InitInstance(HINSTANCE, int); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); +LRESULT CALLBACK ChanInfoProc(HWND, UINT, WPARAM, LPARAM); + +void setTrayIcon(int type, const char *,const char *,bool); +void flipNotifyPopup(int id, ServMgr::NOTIFY_TYPE nt); + + +HWND chWnd=NULL; + +// -------------------------------------------------- +void LOG2(const char *fmt,...) +{ + va_list ap; + va_start(ap, fmt); + char str[4096]; + vsprintf(str,fmt,ap); + OutputDebugString(str); + va_end(ap); +} + + + +// --------------------------------------- + +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ +#ifdef _DEBUG + // memory leak check + ::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif + + char tmpURL[8192]; + tmpURL[0]=0; + char *chanURL=NULL; + + //VERSION_EX = 0; + + iniFileName.set(".\\peercast.ini"); + + WIN32_FIND_DATA fd; //JP-EX + HANDLE hFind; //JP-EX + + OSVERSIONINFO osInfo; //JP-EX + osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); //JP-EX + GetVersionEx(&osInfo); + if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) + winDistinctionNT = true; + else + winDistinctionNT = false; + + // off by default now + showGUI = false; + + if (strlen(lpCmdLine) > 0) + { + char *p; + if ((p = strstr(lpCmdLine,"-inifile"))!=NULL) + iniFileName.setFromString(p+8); + + if (strstr(lpCmdLine,"-zen")) + showGUI = false; + + if (strstr(lpCmdLine,"-multi")) + allowMulti = true; + + if (strstr(lpCmdLine,"-kill")) + killMe = true; + + if ((p = strstr(lpCmdLine,"-url"))!=NULL) + { + p+=4; + while (*p) + { + if (*p=='"') + { + p++; + break; + } + if (*p != ' ') + break; + p++; + } + if (*p) + strncpy(tmpURL,p,sizeof(tmpURL)-1); + } + } + + // get current path + { + exePath = iniFileName; + char *s = exePath.cstr(); + char *end = NULL; + while (*s) + { + if (*s++ == '\\') + end = s; + } + if (end) + *end = 0; + } + + + if (strnicmp(tmpURL,"peercast://",11)==0) + { + if (strnicmp(tmpURL+11,"pls/",4)==0) + chanURL = tmpURL+11+4; + else + chanURL = tmpURL+11; + showGUI = false; + } + + + MSG msg; + HACCEL hAccelTable; + + // Initialize global strings + //LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + //LoadString(hInstance, IDC_APP_TITLE, szWindowClass, MAX_LOADSTRING); + + strcpy(szTitle,"PeerCast"); + strcpy(szWindowClass,"PeerCast"); + + if (!allowMulti) + { + HANDLE mutex = CreateMutex(NULL,TRUE,szWindowClass); + + if (GetLastError() == ERROR_ALREADY_EXISTS) + { + HWND oldWin = FindWindow(szWindowClass,NULL); + if (oldWin) + { + if (killMe) + { + SendMessage(oldWin,WM_DESTROY,0,0); + return 0; + } + + if (chanURL) + { + COPYDATASTRUCT copy; + copy.dwData = WM_PLAYCHANNEL; + copy.cbData = strlen(chanURL)+1; // plus null term + copy.lpData = chanURL; + SendMessage(oldWin,WM_COPYDATA,NULL,(LPARAM)©); + }else{ + if (showGUI) + SendMessage(oldWin,WM_SHOWGUI,0,0); + } + } + return 0; + } + } + + if (killMe) + return 0; + + MyRegisterClass(hInstance); + + // Perform application initialization: + if (!InitInstance (hInstance, nCmdShow)) + return FALSE; + + peercastInst = new MyPeercastInst(); + peercastApp = new MyPeercastApp(); + + peercastInst->init(); + + LOG_DEBUG("Set OS Type: %s",winDistinctionNT?"WinNT":"Win9x"); + + if (peercastApp->clearTemp()) //JP-EX + { + DeleteFile("play.pls"); + hFind = FindFirstFile("*.asx",&fd); + if (hFind != INVALID_HANDLE_VALUE) + { + do + { + DeleteFile((char *)&fd.cFileName); + } + while (FindNextFile(hFind,&fd)); + + FindClose(hFind); + } + } + + if (chanURL) + { + ChanInfo info; + servMgr->procConnectArgs(chanURL,info); + chanMgr->findAndPlayChannel(info,false); + } + + + hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SIMPLE); + + // setup menu notifes + int mask = peercastInst->getNotifyMask(); + if (mask & ServMgr::NT_PEERCAST) + CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_PEERCAST,MF_CHECKED|MF_BYCOMMAND); + if (mask & ServMgr::NT_BROADCASTERS) + CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_BROADCASTERS,MF_CHECKED|MF_BYCOMMAND); + if (mask & ServMgr::NT_TRACKINFO) + CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_TRACKINFO,MF_CHECKED|MF_BYCOMMAND); + + // Main message loop: + while (GetMessage(&msg, NULL, 0, 0)) + { + if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + Shell_NotifyIcon(NIM_DELETE, (NOTIFYICONDATA*)&trayIcon); + + peercastInst->saveSettings(); + peercastInst->quit(); + + return msg.wParam; +} + + + +// +// FUNCTION: MyRegisterClass() +// +// PURPOSE: Registers the window class. +// +// COMMENTS: +// +// This function and its usage is only necessary if you want this code +// to be compatible with Win32 systems prior to the 'RegisterClassEx' +// function that was added to Windows 95. It is important to call this function +// so that the application will get 'well formed' small icons associated +// with it. +// +ATOM MyRegisterClass(HINSTANCE hInstance) +{ + WNDCLASSEX wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = (WNDPROC)WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SIMPLE); + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = (LPCSTR)IDC_SIMPLE; + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); + + return RegisterClassEx(&wcex); + +} + +//----------------------------- +void loadIcons(HINSTANCE hInstance, HWND hWnd) +{ + icon1 = LoadIcon(hInstance, (LPCTSTR)IDI_SMALL); + icon2 = LoadIcon(hInstance, (LPCTSTR)IDI_SMALL2); + + trayIcon.cbSize = sizeof(trayIcon); + trayIcon.hWnd = hWnd; + trayIcon.uID = 100; + trayIcon.uFlags = NIF_MESSAGE + NIF_ICON + NIF_TIP; + trayIcon.uCallbackMessage = WM_TRAYICON; + trayIcon.hIcon = icon1; + strcpy(trayIcon.szTip, "PeerCast"); + + Shell_NotifyIcon(NIM_ADD, (NOTIFYICONDATA*)&trayIcon); + + //ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + if(!trayMenu) // for PCRaw (tray icon) + trayMenu = LoadMenu(hInstance,MAKEINTRESOURCE(IDR_TRAYMENU)); + if(!ltrayMenu) // for PCRaw (tray icon) + ltrayMenu = LoadMenu(hInstance,MAKEINTRESOURCE(IDR_LTRAYMENU)); + + +} + +//----------------------------- +// +// FUNCTION: InitInstance(HANDLE, int) +// +// PURPOSE: Saves instance handle and creates main window +// +// COMMENTS: +// +// In this function, we save the instance handle in a global variable and +// create and display the main program window. +// +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + HWND hWnd; + + hInst = hInstance; // Store instance handle in our global variable + + hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + + if (!hWnd) + { + return FALSE; + } + + mainWnd = hWnd; + + g_iTaskbarCreated = RegisterWindowMessage("TaskbarCreated"); // for PCRaw (tray icon) + + loadIcons(hInstance,hWnd); + + return TRUE; +} +//----------------------------- +//static String trackTitle; +//static String channelComment; + +//----------------------------- +void channelPopup(const char *title, const char *msg, bool isPopup = true) +{ + String both; + + if (*title == '\0') return; + both.append(msg); + both.append(" ("); + both.append(title); + both.append(")"); + + trayIcon.uFlags = NIF_ICON|NIF_TIP; + strncpy(trayIcon.szTip, both.cstr(),sizeof(trayIcon.szTip)-1); + trayIcon.szTip[sizeof(trayIcon.szTip)-1]=0; + + if (isPopup) trayIcon.uFlags |= 16; + trayIcon.uTimeoutOrVersion = 10000; + strncpy(trayIcon.szInfo,msg,sizeof(trayIcon.szInfo)-1); + strncpy(trayIcon.szInfoTitle,title,sizeof(trayIcon.szInfoTitle)-1); + + Shell_NotifyIcon(NIM_MODIFY, (NOTIFYICONDATA*)&trayIcon); +} +//----------------------------- +void clearChannelPopup() +{ + trayIcon.uFlags = NIF_ICON|16; + trayIcon.uTimeoutOrVersion = 10000; + strncpy(trayIcon.szInfo,"",sizeof(trayIcon.szInfo)-1); + strncpy(trayIcon.szInfoTitle,"",sizeof(trayIcon.szInfoTitle)-1); + Shell_NotifyIcon(NIM_MODIFY, (NOTIFYICONDATA*)&trayIcon); +} + +//----------------------------- +// PopupEntry +struct PopupEntry { + GnuID id; + String name; + String track; + String comment; + PopupEntry *next; +}; +static PopupEntry *PEList = NULL; +static WLock PELock; + +static void putPopupEntry(PopupEntry *pe) +{ + PELock.on(); + pe->next = PEList; + PEList = pe; + PELock.off(); +} + +static PopupEntry *getPopupEntry(GnuID id) +{ + PELock.on(); + PopupEntry *pe = PEList; + PopupEntry *prev = NULL; + while (pe) { + if (id.isSame(pe->id)) { + if (prev) prev->next = pe->next; + else PEList = pe->next; + PELock.off(); + pe->next = NULL; + return pe; + } + prev = pe; + pe = pe->next; + } + PELock.off(); + return NULL; +} + +static PopupEntry *getTopPopupEntry() +{ + PopupEntry *p = NULL; + PELock.on(); + if (PEList) { + p = PEList; + PEList = PEList->next; + } + PELock.off(); + return p; +} + +//----------------------------- +void APICALL MyPeercastApp::channelStart(ChanInfo *info) +{ + +// lastPlayID = info->id; +// +// if(!isIndexTxt(info)) // for PCRaw (popup) +// clearChannelPopup(); + + PopupEntry *pe = getPopupEntry(info->id); + if (!pe) { + pe = new PopupEntry; + pe->id = info->id; + } + if (!isIndexTxt(info)) + putPopupEntry(pe); + else + delete pe; +} +//----------------------------- +void APICALL MyPeercastApp::channelStop(ChanInfo *info) +{ +// if (info->id.isSame(lastPlayID)) +// { +// lastPlayID.clear(); +// +// if(!isIndexTxt(info)) // for PCRaw (popup) +// clearChannelPopup(); +// } + + PopupEntry *pe = getPopupEntry(info->id); + if (pe) delete pe; + + pe = getTopPopupEntry(); + if (!pe) { + clearChannelPopup(); + } else { + if (ServMgr::NT_TRACKINFO & peercastInst->getNotifyMask()) + { + String name,track; //JP-Patch + name = pe->name; //JP-Patch + track = pe->track; //JP-Patch + name.convertTo(String::T_SJIS); //JP-Patch + track.convertTo(String::T_SJIS); //JP-Patch + clearChannelPopup(); + // channelPopup(info->name.cstr(),trackTitle.cstr()); + channelPopup(name.cstr(),track.cstr(), false); //JP-Patch + } + putPopupEntry(pe); + } +} +//----------------------------- +void APICALL MyPeercastApp::channelUpdate(ChanInfo *info) +{ + if (info) + { + PopupEntry *pe = getPopupEntry(info->id); + if (!pe) return; + + String tmp; + tmp.append(info->track.artist); + tmp.append(" "); + tmp.append(info->track.title); + + + if (!tmp.isSame(pe->track)) + { + pe->name = info->name; + pe->track = tmp; + if (ServMgr::NT_TRACKINFO & peercastInst->getNotifyMask()) + { + //trackTitle=tmp; + String name,track; //JP-Patch + name = info->name; //JP-Patch + track = tmp; //JP-Patch + name.convertTo(String::T_SJIS); //JP-Patch + track.convertTo(String::T_SJIS); //JP-Patch + if(!isIndexTxt(info)) // for PCRaw (popup) + { + clearChannelPopup(); + // channelPopup(info->name.cstr(),trackTitle.cstr()); + channelPopup(name.cstr(),track.cstr()); //JP-Patch + } + } + } else if (!info->comment.isSame(pe->comment)) + { + pe->name = info->name; + pe->comment = info->comment; + if (ServMgr::NT_BROADCASTERS & peercastInst->getNotifyMask()) + { + //channelComment = info->comment; + String name,comment; //JP-Patch + name = info->name; //JP-Patch + comment = info->comment; //JP-Patch + name.convertTo(String::T_SJIS); //JP-Patch + comment.convertTo(String::T_SJIS); //JP-Patch + if(!isIndexTxt(info)) // for PCRaw (popup) + { + clearChannelPopup(); + // channelPopup(info->name.cstr(),channelComment.cstr()); + channelPopup(name.cstr(),comment.cstr()); + } + } + } + + if (!isIndexTxt(info)) + putPopupEntry(pe); + else + delete pe; + } +} +//----------------------------- +void APICALL MyPeercastApp::notifyMessage(ServMgr::NOTIFY_TYPE type, const char *msg) +{ + static bool shownUpgradeAlert=false; + + currNotify = type; + + trayIcon.uFlags = 0; + + if (!shownUpgradeAlert) + { + trayIcon.uFlags = NIF_ICON; + + if (type == ServMgr::NT_UPGRADE) + { + shownUpgradeAlert = true; + trayIcon.hIcon = icon2; + }else + { + trayIcon.hIcon = icon1; + } + }else + { + if (type == ServMgr::NT_UPGRADE) + return; + } + + const char *title=""; + + switch(type) + { + case ServMgr::NT_UPGRADE: + title = "Upgrade alert"; + break; + case ServMgr::NT_PEERCAST: + title = "Message from PeerCast:"; + break; + + } + + if (type & peercastInst->getNotifyMask()) + { + trayIcon.uFlags |= 16; + trayIcon.uTimeoutOrVersion = 10000; + strncpy(trayIcon.szInfo,msg,sizeof(trayIcon.szInfo)-1); + strncpy(trayIcon.szInfoTitle,title,sizeof(trayIcon.szInfoTitle)-1); + Shell_NotifyIcon(NIM_MODIFY, (NOTIFYICONDATA*)&trayIcon); + } +} +//----------------------------- + +// createGUI() +// +void createGUI(HWND hWnd) +{ + if (!guiWnd) + guiWnd = CreateDialog(hInst, (LPCTSTR)IDD_MAINWINDOW, hWnd, (DLGPROC)GUIProc); + ShowWindow(guiWnd,SW_SHOWNORMAL); +} + + +// +// addRelayedChannelsMenu(HMENU m) +// +// +void addRelayedChannelsMenu(HMENU cm) +{ + int cnt = GetMenuItemCount(cm); + for(int i=0; ichannel; + while(c) + { + if (c->isActive()) + { + char str[128],name[64]; + strncpy(name,c->info.name,32); + name[32]=0; + if (strlen(c->info.name) > 32) + strcat(name,"..."); + + + sprintf(str,"%s (%d kb/s %s)",name,c->info.bitrate,ChanInfo::getTypeStr(c->info.contentType)); + //InsertMenu(cm,0,MF_BYPOSITION,RELAY_CMD+i,str); + } + c=c->next; + } +} + +typedef int (*COMPARE_FUNC)(const void *,const void *); + +static int compareHitLists(ChanHitList **c2, ChanHitList **c1) +{ + return stricmp(c1[0]->info.name.cstr(),c2[0]->info.name.cstr()); +} + +static int compareChannels(Channel **c2, Channel **c1) +{ + return stricmp(c1[0]->info.name.cstr(),c2[0]->info.name.cstr()); +} + +// +// addAllChannelsMenu(HMENU m) +// +// +void addAllChannelsMenu(HMENU cm) +{ + int cnt = GetMenuItemCount(cm); +/* for(int i=0; irootHost2.isEmpty()){ + InsertMenu(yMenu,0,MF_BYPOSITION,ID_POPUP_YELLOWPAGES2,servMgr->rootHost2); + } + if (!servMgr->rootHost.isEmpty()){ + InsertMenu(yMenu,0,MF_BYPOSITION,ID_POPUP_YELLOWPAGES1,servMgr->rootHost); + } + + InsertMenu(cm,0,MF_BYPOSITION|MF_POPUP,(UINT)yMenu,"ƒCƒGƒ[ƒy[ƒW"); + InsertMenu(cm,0,MF_BYPOSITION|MF_SEPARATOR,NULL,NULL); + // add channels to menu + int numActive=0; + Channel *ch = chanMgr->channel; + while(ch) + { + char str[128],name[64]; + String sjis; //JP-Patch + sjis = ch->info.name; //JP-Patch + sjis.convertTo(String::T_SJIS); //JP-Patch + strncpy(name,sjis.cstr(),32); + //strncpy(name,ch->info.name,32); + name[32]=0; + //if (strlen(ch->info.name) > 32) + if (strlen(sjis.cstr()) > 32) //JP-Patch + strcat(name,"..."); + + sprintf(str,"%s (%d kb/s %s)",name,ch->info.bitrate,ChanInfo::getTypeStr(ch->info.contentType)); + + HMENU opMenu = CreatePopupMenu(); + InsertMenu(opMenu,0,MF_BYPOSITION,INFO_CMD+numActive,"Info"); + if (ch->info.url.isValidURL()) + InsertMenu(opMenu,0,MF_BYPOSITION,URL_CMD+numActive,"URL"); + InsertMenu(opMenu,0,MF_BYPOSITION,PLAY_CMD+numActive,"Play"); + + UINT fl = MF_BYPOSITION|MF_POPUP; + if (ch) + fl |= (ch->isPlaying()?MF_CHECKED:0); + + InsertMenu(cm,0,fl,(UINT)opMenu,str); + + numActive++; + + ch=ch->next; + } + + + //if (!numActive) + // InsertMenu(cm,0,MF_BYPOSITION,0,""); + + + + +} + + +// +// flipNotifyPopup(id, flag) +void flipNotifyPopup(int id, ServMgr::NOTIFY_TYPE nt) +{ + int mask = peercastInst->getNotifyMask(); + + mask ^= nt; + if (mask & nt) + CheckMenuItem(trayMenu,id,MF_CHECKED|MF_BYCOMMAND); + else + CheckMenuItem(trayMenu,id,MF_UNCHECKED|MF_BYCOMMAND); + + peercastInst->setNotifyMask(mask); + peercastInst->saveSettings(); +} + + +static void showHTML(const char *file) +{ + char url[256]; + sprintf(url,"%s/%s",servMgr->htmlPath,file); + +// sys->callLocalURL(url,servMgr->serverHost.port); + sys->callLocalURL(url, // for PCRaw (url) + (servMgr->allowServer1&Servent::ALLOW_HTML)?(servMgr->serverHost.port):(servMgr->serverHost.port+1)); +} + +static ChanInfo getChannelInfo(int index) +{ + Channel *c = chanMgr->findChannelByIndex(index); + if (c) + return c->info; + + ChanInfo info; + return info; +} + +// +// FUNCTION: WndProc(HWND, unsigned, WORD, LONG) +// +// PURPOSE: Processes messages for the main window. +// +// WM_COMMAND - process the application menu +// WM_PAINT - Paint the main window +// WM_DESTROY - post a quit message and return +// +// +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + int wmId, wmEvent; + POINT point; + char buf[1024]; + + if(message == g_iTaskbarCreated) // for PCRaw (tray icon) + loadIcons(hInst, hWnd); + + switch (message) + { + case WM_SHOWGUI: + createGUI(hWnd); + break; + + + case WM_TRAYICON: + switch((UINT)lParam) + { + case WM_LBUTTONDOWN: + if (allowTrayMenu) + SendMessage(hWnd,WM_SHOWMENU,2,0); + SetForegroundWindow(hWnd); + break; + case WM_RBUTTONDOWN: + if (allowTrayMenu) + SendMessage(hWnd,WM_SHOWMENU,1,0); + SetForegroundWindow(hWnd); + break; + case WM_LBUTTONDBLCLK: + createGUI(hWnd); + break; + } + break; + + case WM_COPYDATA: + { + COPYDATASTRUCT *pc = (COPYDATASTRUCT *)lParam; + LOG_DEBUG("URL request: %s",pc->lpData); + if (pc->dwData == WM_PLAYCHANNEL) + { + ChanInfo info; + servMgr->procConnectArgs((char *)pc->lpData,info); + chanMgr->findAndPlayChannel(info,false); + } + //sys->callLocalURL((const char *)pc->lpData,servMgr->serverHost.port); + } + break; + case WM_GETPORTNUMBER: + { + int port; + port=servMgr->serverHost.port; + ReplyMessage(port); + } + break; + + case WM_SHOWMENU: + { + if (servMgr->saveGuiPos){ + CheckMenuItem(trayMenu, ID_POPUP_SAVE_GUI_POS, MF_CHECKED|MF_BYCOMMAND); + } else { + CheckMenuItem(trayMenu, ID_POPUP_SAVE_GUI_POS, MF_UNCHECKED|MF_BYCOMMAND); + } + + SetForegroundWindow(hWnd); + bool skipMenu=false; + + allowTrayMenu = false; + + // check for notifications + if (currNotify & ServMgr::NT_UPGRADE) + { + if (servMgr->downloadURL[0]) + { + if ((sys->getTime()-seenNewVersionTime) > (60*60)) // notify every hour + { + if (MessageBox(hWnd,"A newer version of PeerCast is available, press OK to upgrade.","PeerCast",MB_OKCANCEL|MB_APPLMODAL|MB_ICONEXCLAMATION) == IDOK) + sys->getURL(servMgr->downloadURL); + + seenNewVersionTime=sys->getTime(); + skipMenu=true; + } + } + } + + + if (!skipMenu) + { + RECT rcWnd; + HMENU menu; + UINT flg = 0; + + SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWnd, 0); + GetCursorPos(&point); + + if (point.x < rcWnd.left){ + point.x = rcWnd.left; + flg |= TPM_LEFTALIGN; + } + if (point.x > rcWnd.right){ + point.x = rcWnd.right; + flg |= TPM_RIGHTALIGN; + } + if (point.y < rcWnd.top){ + point.y = rcWnd.top; + flg |= TPM_TOPALIGN; + } + if (point.y > rcWnd.bottom){ + point.y = rcWnd.bottom; + flg |= TPM_BOTTOMALIGN; + } + if (flg == 0){ + flg = TPM_RIGHTALIGN; + } + + switch (wParam) + { + case 1: + menu = GetSubMenu(trayMenu,0); + addAllChannelsMenu(GetSubMenu(menu,0)); + addRelayedChannelsMenu(GetSubMenu(menu,1)); + break; + case 2: + menu = GetSubMenu(ltrayMenu,0); + addAllChannelsMenu(menu); + break; + } + if (!TrackPopupMenu(menu,flg,point.x,point.y,0,hWnd,NULL)) + { + LOG_ERROR("Can`t track popup menu: %d",GetLastError()); + } + PostMessage(hWnd,WM_NULL,0,0); + + } + allowTrayMenu = true; + } + break; + + case WM_CREATE: + if (showGUI) + createGUI(hWnd); + break; + + case WM_COMMAND: + wmId = LOWORD(wParam); + wmEvent = HIWORD(wParam); + + if ((wmId >= INFO_CMD) && (wmId < INFO_CMD+MAX_CHANNELS)) + { + int c = wmId - INFO_CMD; + chanInfo = getChannelInfo(c); + chanInfoIsRelayed = false; + if (winDistinctionNT) + DialogBox(hInst, (LPCTSTR)IDD_CHANINFO, hWnd, (DLGPROC)ChanInfoProc); + else + { + HWND WKDLG; //JP-Patch + WKDLG = CreateDialog(hInst, (LPCTSTR)IDD_CHANINFO, hWnd, (DLGPROC)ChanInfoProc); //JP-Patch + ShowWindow(WKDLG,SW_SHOWNORMAL); //JP-Patch + } + return 0; + } + if ((wmId >= URL_CMD) && (wmId < URL_CMD+MAX_CHANNELS)) + { + int c = wmId - URL_CMD; + chanInfo = getChannelInfo(c); + if (chanInfo.url.isValidURL()) + sys->getURL(chanInfo.url); + return 0; + } + if ((wmId >= PLAY_CMD) && (wmId < PLAY_CMD+MAX_CHANNELS)) + { + int c = wmId - PLAY_CMD; + chanInfo = getChannelInfo(c); + chanMgr->findAndPlayChannel(chanInfo,false); + return 0; + } + if ((wmId >= RELAY_CMD) && (wmId < RELAY_CMD+MAX_CHANNELS)) + { + int c = wmId - RELAY_CMD; + chanInfo = getChannelInfo(c); + chanMgr->findAndPlayChannel(chanInfo,true); + return 0; + } + + // Parse the menu selections: + switch (wmId) + { + case ID_POPUP_SHOWMESSAGES_PEERCAST: + flipNotifyPopup(ID_POPUP_SHOWMESSAGES_PEERCAST,ServMgr::NT_PEERCAST); + break; + case ID_POPUP_SHOWMESSAGES_BROADCASTERS: + flipNotifyPopup(ID_POPUP_SHOWMESSAGES_BROADCASTERS,ServMgr::NT_BROADCASTERS); + break; + case ID_POPUP_SHOWMESSAGES_TRACKINFO: + flipNotifyPopup(ID_POPUP_SHOWMESSAGES_TRACKINFO,ServMgr::NT_TRACKINFO); + break; + + case ID_POPUP_ABOUT: + case IDM_ABOUT: + DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); + break; + case ID_POPUP_SHOWGUI: + case IDM_SETTINGS_GUI: + case ID_POPUP_ADVANCED_SHOWGUI: + { + createGUI(hWnd); + break; + } + case ID_POPUP_YELLOWPAGES: + sys->getURL("http://yp.peercast.org/"); + break; + case ID_POPUP_YELLOWPAGES1: + sprintf(buf, "http://%s",servMgr->rootHost.cstr()); + sys->getURL(buf); + break; + case ID_POPUP_YELLOWPAGES2: + sprintf(buf, "http://%s",servMgr->rootHost2.cstr()); + sys->getURL(buf); + break; + + case ID_POPUP_ADVANCED_VIEWLOG: + showHTML("viewlog.html"); + break; + case ID_POPUP_ADVANCED_SAVESETTINGS: + servMgr->saveSettings(iniFileName.cstr()); + break; + case ID_POPUP_ADVANCED_INFORMATION: + showHTML("index.html"); + break; + case ID_FIND_CHANNELS: + case ID_POPUP_ADVANCED_ALLCHANNELS: + case ID_POPUP_UPGRADE: + sys->callLocalURL("admin?cmd=upgrade",servMgr->serverHost.port); + break; + case ID_POPUP_ADVANCED_RELAYEDCHANNELS: + case ID_POPUP_FAVORITES_EDIT: + showHTML("relays.html"); + break; + case ID_POPUP_ADVANCED_BROADCAST: + showHTML("broadcast.html"); + break; + case ID_POPUP_SETTINGS: + showHTML("settings.html"); + break; + case ID_POPUP_CONNECTIONS: + showHTML("connections.html"); + break; + case ID_POPUP_HELP: + sys->getURL("http://www.peercast.org/help.php"); + break; + + case ID_POPUP_SAVE_GUI_POS: + if (servMgr->saveGuiPos){ + servMgr->saveGuiPos = false; + CheckMenuItem(trayMenu, ID_POPUP_SAVE_GUI_POS, MF_UNCHECKED|MF_BYCOMMAND); + } else { + servMgr->saveGuiPos = true; + CheckMenuItem(trayMenu, ID_POPUP_SAVE_GUI_POS, MF_CHECKED|MF_BYCOMMAND); + } + peercastInst->saveSettings(); + break; + + case ID_POPUP_KEEP_DOWNSTREAMS: + if (servMgr->keepDownstreams){ + servMgr->keepDownstreams = false; + CheckMenuItem(trayMenu, ID_POPUP_KEEP_DOWNSTREAMS, MF_UNCHECKED|MF_BYCOMMAND); + } else { + servMgr->keepDownstreams = true; + CheckMenuItem(trayMenu, ID_POPUP_KEEP_DOWNSTREAMS, MF_CHECKED|MF_BYCOMMAND); + } + //peercastInst->saveSettings(); + break; + + case ID_POPUP_EXIT_CONFIRM: + case IDM_EXIT: + DestroyWindow(hWnd); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} +// Mesage handler for about box. +LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + //SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENT); +// SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTJP); + //SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTVP); + + if (version_ex) + { + SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LPARAM)PCX_AGENTEX); // x64‘Ήž + } else + { + SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTVP); + } + + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + case IDCANCEL: + EndDialog(hDlg, LOWORD(wParam)); + return TRUE; + case IDC_BUTTON1: + sys->getURL("http://www.peercast.org"); + EndDialog(hDlg, LOWORD(wParam)); + return TRUE; + + } + break; + case WM_DESTROY: + break; + } + return FALSE; +} + +// Mesage handler for chaninfo box +LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + { + char str[1024]; + //strcpy(str,chanInfo.track.artist.cstr()); + strcpy(str,chanInfo.track.artist); //JP-Patch + strcat(str," - "); + //strcat(str,chanInfo.track.title.cstr()); + strcat(str,chanInfo.track.title); + String name,track,comment,desc,genre; //JP-Patch + name = chanInfo.name; //JP-Patch + track = str; //JP-Patch + comment = chanInfo.comment; //JP-Patch + desc = chanInfo.desc; //JP-Patc + genre = chanInfo.genre; //JP-Patch + name.convertTo(String::T_SJIS); //JP-Patc + track.convertTo(String::T_SJIS); //JP-Patch + comment.convertTo(String::T_SJIS); //JP-Patch + desc.convertTo(String::T_SJIS); //JP-Patch + genre.convertTo(String::T_SJIS); //JP-Patch + + //SendDlgItemMessage(hDlg,IDC_EDIT_NAME,WM_SETTEXT,0,(LONG)chanInfo.name.cstr()); + SendDlgItemMessage(hDlg,IDC_EDIT_NAME,WM_SETTEXT,0,(LONG)name.cstr()); //JP-Patch + //SendDlgItemMessage(hDlg,IDC_EDIT_PLAYING,WM_SETTEXT,0,(LONG)str); + SendDlgItemMessage(hDlg,IDC_EDIT_PLAYING,WM_SETTEXT,0,(LONG)track.cstr()); //JP-Patch + //SendDlgItemMessage(hDlg,IDC_EDIT_MESSAGE,WM_SETTEXT,0,(LONG)chanInfo.comment.cstr()); + SendDlgItemMessage(hDlg,IDC_EDIT_MESSAGE,WM_SETTEXT,0,(LONG)comment.cstr()); //JP-Patch + //SendDlgItemMessage(hDlg,IDC_EDIT_DESC,WM_SETTEXT,0,(LONG)chanInfo.desc.cstr()); + SendDlgItemMessage(hDlg,IDC_EDIT_DESC,WM_SETTEXT,0,(LONG)desc.cstr()); //JP-Patch + //SendDlgItemMessage(hDlg,IDC_EDIT_GENRE,WM_SETTEXT,0,(LONG)chanInfo.genre.cstr()); + SendDlgItemMessage(hDlg,IDC_EDIT_GENRE,WM_SETTEXT,0,(LONG)genre.cstr()); //JP-Patch + + sprintf(str,"%d kb/s %s",chanInfo.bitrate,ChanInfo::getTypeStr(chanInfo.contentType)); + SendDlgItemMessage(hDlg,IDC_FORMAT,WM_SETTEXT,0,(LONG)str); + + + if (!chanInfo.url.isValidURL()) + EnableWindow(GetDlgItem(hDlg,IDC_CONTACT),false); + + Channel *ch = chanMgr->findChannelByID(chanInfo.id); + if (ch) + { + SendDlgItemMessage(hDlg,IDC_EDIT_STATUS,WM_SETTEXT,0,(LONG)ch->getStatusStr()); + SendDlgItemMessage(hDlg, IDC_KEEP,BM_SETCHECK, ch->stayConnected, 0); + }else + { + SendDlgItemMessage(hDlg,IDC_EDIT_STATUS,WM_SETTEXT,0,(LONG)"OK"); + EnableWindow(GetDlgItem(hDlg,IDC_KEEP),false); + } + + + + POINT point; + RECT rect,drect; + HWND hDsk = GetDesktopWindow(); + GetWindowRect(hDsk,&drect); + GetWindowRect(hDlg,&rect); + GetCursorPos(&point); + + POINT pos,size; + size.x = rect.right-rect.left; + size.y = rect.bottom-rect.top; + + if (point.x-drect.left < size.x) + pos.x = point.x; + else + pos.x = point.x-size.x; + + if (point.y-drect.top < size.y) + pos.y = point.y; + else + pos.y = point.y-size.y; + + SetWindowPos(hDlg,HWND_TOPMOST,pos.x,pos.y,size.x,size.y,0); + chWnd = hDlg; + } + return TRUE; + + case WM_COMMAND: + { + char str[1024],idstr[64]; + chanInfo.id.toStr(idstr); + + switch (LOWORD(wParam)) + { + case IDC_CONTACT: + { + sys->getURL(chanInfo.url); + return TRUE; + } + case IDC_DETAILS: + { + sprintf(str,"admin?page=chaninfo&id=%s&relay=%d",idstr,chanInfoIsRelayed); + sys->callLocalURL(str,servMgr->serverHost.port); + return TRUE; + } + case IDC_KEEP: + { + Channel *ch = chanMgr->findChannelByID(chanInfo.id); + if (ch) + ch->stayConnected = SendDlgItemMessage(hDlg, IDC_KEEP,BM_GETCHECK, 0, 0) == BST_CHECKED;; + return TRUE; + } + + + case IDC_PLAY: + { + chanMgr->findAndPlayChannel(chanInfo,false); + return TRUE; + } + + } + } + break; + + case WM_CLOSE: + if (winDistinctionNT) + EndDialog(hDlg, 0); + else + DestroyWindow(hDlg); //JP-Patch + break; + + case WM_ACTIVATE: + if (LOWORD(wParam) == WA_INACTIVE) + if (winDistinctionNT) + EndDialog(hDlg, 0); + else + DestroyWindow(hDlg); //JP-Patch + break; + case WM_DESTROY: + chWnd = NULL; + break; + + + } + return FALSE; +} diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.h b/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.h new file mode 100644 index 0000000..ad59a96 --- /dev/null +++ b/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.h @@ -0,0 +1,65 @@ + +// ------------------------------------------------ +// File : simple.h +// Date: 4-apr-2002 +// Author: giles +// +// (c) 2002 peercast.org +// ------------------------------------------------ +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// ------------------------------------------------ + +#if !defined(AFX_SIMPLE_H__F2E64B1B_62DE_473C_A6B6_E7826D41E0FA__INCLUDED_) +#define AFX_SIMPLE_H__F2E64B1B_62DE_473C_A6B6_E7826D41E0FA__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "resource.h" + +// --------------------------------- +class MyPeercastInst : public PeercastInstance +{ +public: + virtual Sys * APICALL createSys(); +}; +// --------------------------------- +class MyPeercastApp : public PeercastApplication +{ +public: + MyPeercastApp () + { + //logFile.openWriteReplace("log.txt"); + } + + virtual const char * APICALL getPath(); + + virtual const char * APICALL getIniFilename(); + virtual const char *APICALL getClientTypeOS(); + virtual void APICALL openLogFile(); //JP-EX + virtual void APICALL getDirectory(); //JP-EX + virtual bool APICALL clearTemp(); //JP-EX + virtual void APICALL printLog(LogBuffer::TYPE t, const char *str); + + virtual void APICALL updateSettings(); + virtual void APICALL notifyMessage(ServMgr::NOTIFY_TYPE, const char *); + + virtual void APICALL channelStart(ChanInfo *); + virtual void APICALL channelStop(ChanInfo *); + virtual void APICALL channelUpdate(ChanInfo *); + + FileStream logFile; + +}; + + +#endif // !defined(AFX_SIMPLE_H__F2E64B1B_62DE_473C_A6B6_E7826D41E0FA__INCLUDED_) diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.ico b/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.ico new file mode 100644 index 0000000000000000000000000000000000000000..51811ea4819dbdb4726fbb0f5f4347425ca2a566 GIT binary patch literal 1078 zcma)6v2KGv41F|}%+&G+WvcQQ?I*Eaww%-}Ol7KSw$g}-y zpYJeMfDBJ4%L2B3o`84iqDXw30WTY1OJ7NR5*eN;fyms)D>BGPj7d?_BqG|jWkCH0 zRkH{_<}%?+!emUULbY@(xj+`-HLq6jb-61~$6mL)KZLYhs1f+s3L)(310e1N^180| z#`A{nqD-CQPKVu+_r_sW;qksUE-UU=_xNG3xZNS;hl#U9?#G={oYEa3Vs4XEtia=D z&N_|SK?Yxv8^3E~RWG^N#qQ#6U$c#M?IvU=1!iUXyL6pQi=Pm8WD^8c- zd^5phG#AA`=6vo(mAW=lNrqI^6am5swC?jGyKZz~tl}5!Pc|<}Lw4Fn+bd0Yi1o;Ujh literal 0 HcmV?d00001 diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.rc b/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.rc new file mode 100644 index 0000000..78d8067 --- /dev/null +++ b/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.rc @@ -0,0 +1,364 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +// Generated Help ID header file +#define APSTUDIO_HIDDEN_SYMBOLS +#include "resource.hm" +#undef APSTUDIO_HIDDEN_SYMBOLS + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +#include "resource.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Æ­°Ä×Ù (¼½ÃѕW€) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT +#pragma code_page(932) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_TRAYMENU MENU DISCARDABLE +BEGIN + POPUP "popup" + BEGIN + MENUITEM "î•ñ", ID_POPUP_ABOUT + MENUITEM "ƒwƒ‹ƒv", ID_POPUP_HELP + MENUITEM SEPARATOR + POPUP "ƒ|ƒbƒvƒAƒbƒvƒƒbƒZ[ƒW" + BEGIN + MENUITEM "PeerCast", ID_POPUP_SHOWMESSAGES_PEERCAST + + MENUITEM "”zMŽÒ", ID_POPUP_SHOWMESSAGES_BROADCASTERS + + MENUITEM "ƒgƒ‰ƒbƒNî•ñ", ID_POPUP_SHOWMESSAGES_TRACKINFO + + MENUITEM "ƒAƒbƒvƒf[ƒgî•ñ", ID_POPUP_POPUPMESSAGES_UPGRADEALERTS + , CHECKED, GRAYED + END + POPUP "‚“x" + BEGIN + MENUITEM "î•ñ", ID_POPUP_ADVANCED_INFORMATION + + MENUITEM "ƒŠƒŒ[ƒ`ƒƒƒ“ƒlƒ‹", ID_POPUP_ADVANCED_RELAYEDCHANNELS + + MENUITEM "”zM", ID_POPUP_ADVANCED_BROADCAST + + MENUITEM "ƒRƒlƒNƒVƒ‡ƒ“", ID_POPUP_CONNECTIONS + MENUITEM "ƒƒO", ID_POPUP_ADVANCED_VIEWLOG + + MENUITEM "Ý’è", ID_POPUP_SETTINGS + MENUITEM "GUI‚ðŠJ‚­", ID_POPUP_ADVANCED_SHOWGUI + + END + POPUP "’ljÁÝ’è" + BEGIN + MENUITEM "I—¹ŽžA•\Ž¦ˆÊ’u‚ð•Û‘¶", ID_POPUP_SAVE_GUI_POS + , CHECKED + MENUITEM "ÄÚ‘±Žž‰º—¬ˆÛŽ", ID_POPUP_KEEP_DOWNSTREAMS + , CHECKED + END + MENUITEM SEPARATOR + POPUP "I—¹" + BEGIN + MENUITEM "‚Í‚¢", ID_POPUP_EXIT_CONFIRM + MENUITEM "‚¢‚¢‚¦", ID_POPUP_EXIT_NO + END + END +END + +IDR_LTRAYMENU MENU DISCARDABLE +BEGIN + POPUP "popup" + BEGIN + MENUITEM SEPARATOR + MENUITEM "ƒCƒGƒ[ƒy[ƒW", ID_POPUP_YELLOWPAGES + POPUP "ƒCƒGƒ[ƒy[ƒW" + BEGIN + MENUITEM "AAA", ID_POPUP_YELLOWPAGES1 + MENUITEM "BBB", ID_POPUP_YELLOWPAGES2 + END + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_MAINWINDOW DIALOGEX 0, 0, 298, 341 +STYLE DS_CENTER | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +EXSTYLE WS_EX_APPWINDOW +CAPTION "PeerCast" +FONT 9, "MS UI Gothic", 0, 0, 0x1 +BEGIN + LISTBOX IDC_LIST1,3,291,291,43,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | + WS_TABSTOP + CONTROL "—LŒø",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,9,29,60,20,WS_EX_TRANSPARENT + EDITTEXT IDC_EDIT1,127,18,47,12,ES_AUTOHSCROLL + RTEXT "ƒ|[ƒg :",IDC_STATIC,107,20,18,8 + LISTBOX IDC_LIST2,3,206,291,71,LBS_OWNERDRAWFIXED | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + LTEXT "ƒƒO",IDC_STATIC_LOG,3,282,13,8 + LTEXT "ƒRƒlƒNƒVƒ‡ƒ“",IDC_STATIC_CONNECTION,3,184,40,8 + GROUPBOX "",IDC_STATIC,3,4,291,49 + PUSHBUTTON "ƒNƒŠƒA",IDC_BUTTON1,35,279,25,11 + LISTBOX IDC_LIST3,3,81,291,67,LBS_OWNERDRAWFIXED | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Ø’f",IDC_BUTTON5,67,65,43,13 + GROUPBOX "ƒŠƒŒ[",IDC_GROUPBOX_RELAY,3,54,291,96 + EDITTEXT IDC_EDIT3,127,34,47,12,ES_PASSWORD | ES_AUTOHSCROLL + RTEXT "ƒpƒXƒ[ƒh :",IDC_STATIC,89,36,36,8 + CONTROL "ƒfƒoƒbƒO",IDC_LOGDEBUG,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,127,279,32,11 + CONTROL "ƒlƒbƒgƒ[ƒN",IDC_LOGNETWORK,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,185,279,35,11 + CONTROL "ƒGƒ‰[",IDC_LOGERRORS,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,159,279,25,11 + CONTROL "’âŽ~",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,60,279,30,11 + PUSHBUTTON "Ä¶",IDC_BUTTON8,10,65,22,13 + CONTROL "ƒ`ƒƒƒ“ƒlƒ‹",IDC_LOGCHANNELS,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,221,279,35,11 + PUSHBUTTON "ÄÚ‘±",IDC_BUTTON3,41,65,24,13 + EDITTEXT IDC_EDIT9,33,159,261,14,ES_AUTOHSCROLL + CONTROL "DJ",IDC_CHECK11,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,5,160,23,12 + RTEXT "Å‘僊ƒŒ[” :",IDC_STATIC,194,36,40,8 + EDITTEXT IDC_MAXRELAYS,241,33,40,14,ES_AUTOHSCROLL | ES_NUMBER + PUSHBUTTON "ƒL[ƒv",IDC_BUTTON9,112,65,24,13 + PUSHBUTTON "Ø’f",IDC_BUTTON6,47,179,43,13 + LTEXT "Peercast-VP",IDC_STATIC,21,14,39,8 +END + +IDD_CHANINFO DIALOGEX 0, 0, 184, 207 +STYLE DS_SETFOREGROUND | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_TOOLWINDOW +CAPTION "Channel Information" +FONT 9, "MS UI Gothic", 400, 0, 0x80 +BEGIN + LTEXT "–¼‘O:",IDC_STATIC,7,8,24,9 + EDITTEXT IDC_EDIT_NAME,7,18,170,21,ES_MULTILINE | ES_READONLY | + NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE + LTEXT "“à—e:",IDC_STATIC,7,79,93,9 + EDITTEXT IDC_EDIT_PLAYING,8,90,170,21,ES_MULTILINE | ES_READONLY | + NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE + LTEXT "DJ ƒƒbƒZ[ƒW:",IDC_STATIC,7,117,41,9 + EDITTEXT IDC_EDIT_MESSAGE,8,128,170,21,ES_MULTILINE | ES_READONLY | + NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE + PUSHBUTTON "URL",IDC_CONTACT,7,185,34,15,0,0,HIDC_CONTACT + LTEXT "Ú×:",IDC_STATIC,7,43,67,8 + EDITTEXT IDC_EDIT_DESC,8,53,170,21,ES_MULTILINE | ES_READONLY | + NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE + RTEXT "Œ`Ž®",IDC_FORMAT,69,80,107,8 + LTEXT "ƒWƒƒƒ“ƒ‹:",IDC_STATIC,63,5,22,8 + EDITTEXT IDC_EDIT_GENRE,87,3,90,12,ES_AUTOHSCROLL | ES_READONLY | + NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE + CONTROL "ƒL[ƒv",IDC_KEEP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 144,188,33,10 + LTEXT "ƒXƒe[ƒ^ƒX:",IDC_STATIC,7,153,41,9 + EDITTEXT IDC_EDIT_STATUS,8,163,82,12,ES_READONLY | NOT WS_BORDER | + NOT WS_TABSTOP,WS_EX_STATICEDGE + PUSHBUTTON "Ä¶",IDC_PLAY,56,185,34,15 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO MOVEABLE PURE +BEGIN + IDD_MAINWINDOW, DIALOG + BEGIN + LEFTMARGIN, 3 + RIGHTMARGIN, 294 + TOPMARGIN, 3 + BOTTOMMARGIN, 336 + END + + IDD_CHANINFO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 177 + TOPMARGIN, 7 + BOTTOMMARGIN, 200 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Æ­°Ä×Ù (¼½ÃѕW€) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// ‰pŒê (±Òض) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDC_SIMPLE MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", IDM_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About ...", IDM_ABOUT + END + POPUP "Settings" + BEGIN + MENUITEM "GUI", IDM_SETTINGS_GUI + END +END + +IDR_VERMENU MENU DISCARDABLE +BEGIN + POPUP "popup" + BEGIN + MENUITEM "Please upgrade PeerCast. Click here to download.", + ID_POPUP_UPGRADE + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 163, 59 +STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_CAPTION | WS_SYSMENU +CAPTION "About" +FONT 8, "System" +BEGIN + ICON IDI_SIMPLE,IDC_MYICON,14,9,20,20 + LTEXT "PeerCast",IDC_ABOUTVER,43,9,103,8,SS_NOPREFIX + LTEXT "Copyright (C) 2005-2007",IDC_STATIC,43,22,119,8 + PUSHBUTTON "OK",IDOK,134,40,24,12,WS_GROUP + PUSHBUTTON "www.peercast.org",IDC_BUTTON1,42,40,66,12 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO MOVEABLE PURE +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + BOTTOMMARGIN, 58 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_SIMPLE ICON DISCARDABLE "Simple.ICO" +IDI_SMALL2 ICON DISCARDABLE "small1.ico" +IDI_SMALL ICON DISCARDABLE "small3.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDC_SIMPLE ACCELERATORS MOVEABLE PURE +BEGIN + "?", IDM_ABOUT, ASCII, ALT + "/", IDM_ABOUT, ASCII, ALT +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +2 TEXTINCLUDE MOVEABLE PURE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""resource.h""\r\n" + "\0" +END + +3 TEXTINCLUDE MOVEABLE PURE +BEGIN + "\r\n" + "\0" +END + +1 TEXTINCLUDE MOVEABLE PURE +BEGIN + "resource.h\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_APP_TITLE "PeerCast" +END + +#endif // ‰pŒê (±Òض) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj b/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj new file mode 100644 index 0000000..0b377e1 --- /dev/null +++ b/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj @@ -0,0 +1,767 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj.vspscc b/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj.vspscc new file mode 100644 index 0000000..72b221b --- /dev/null +++ b/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:ui\\win32\\Simple_vp" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" +} diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.cpp b/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.cpp new file mode 100644 index 0000000..fe41f64 --- /dev/null +++ b/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.cpp @@ -0,0 +1,9 @@ +// stdafx.cpp : source file that includes just the standard includes +// Simple.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file + diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.h b/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.h new file mode 100644 index 0000000..1e47eff --- /dev/null +++ b/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.h @@ -0,0 +1,32 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) +#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + + +// Windows Header Files: +#include + +// C RunTime Header Files +#include +#include +#include +#include + +// Local Header Files + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.cpp b/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.cpp new file mode 100644 index 0000000..3cc4408 --- /dev/null +++ b/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.cpp @@ -0,0 +1,21 @@ +#ifdef _DEBUG +#include "stdafx.h" +#include "chkMemoryLeak.h" + +#ifdef __AFXWIN_H__ // MFC‚̃EƒBƒ“ƒhƒE‚ðŽg‚¤ê‡‚ÉŒÀ’肵‚Ä‚¢‚Ü‚· +#else + #if defined(_DEBUG) + #define __chkMemoryLeak_H__ + void* operator new(size_t size, const char *filename, int linenumber) + { + return _malloc_dbg(size, _NORMAL_BLOCK, filename, linenumber); + } + void operator delete(void * _P, const char *filename, int linenumber) + { + _free_dbg(_P, _NORMAL_BLOCK); + return; + } + + #endif +#endif +#endif diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.h b/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.h new file mode 100644 index 0000000..cf72ed3 --- /dev/null +++ b/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.h @@ -0,0 +1,24 @@ +#ifndef _CHKMEMORYLEAK_H +#define _CHKMEMORYLEAK_H + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifdef _DEBUG + #define _CRTDBG_MAP_ALLOC + + #define SET_CRT_DEBUG_FIELD(a) _CrtSetDbgFlag((a) | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)) + #define CLEAR_CRT_DEBUG_FIELD(a) _CrtSetDbgFlag(~(a) & _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)) + + void* operator new(size_t size, const char *filename, int linenumber); + void operator delete(void * _P, const char *filename, int linenumber); +#else + #define SET_CRT_DEBUG_FIELD(a) ((void) 0) + #define CLEAR_CRT_DEBUG_FIELD(a) ((void) 0) +#endif + +#include +#include + +#endif diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.cpp b/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.cpp new file mode 100644 index 0000000..5d933b2 --- /dev/null +++ b/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.cpp @@ -0,0 +1,1715 @@ +// ------------------------------------------------ +// File : gui.cpp +// Date: 4-apr-2002 +// Author: giles +// Desc: +// Windows front end GUI, PeerCast core is not dependant on any of this. +// Its very messy at the moment, but then again Windows UI always is. +// I really don`t like programming win32 UI.. I want my borland back.. +// +// (c) 2002 peercast.org +// ------------------------------------------------ +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// ------------------------------------------------ + +#include +#include "stdio.h" +#include "string.h" +#include "stdarg.h" +#include "resource.h" +#include "socket.h" +#include "win32/wsys.h" +#include "servent.h" +#include "win32/wsocket.h" +#include "inifile.h" +#include "gui.h" +#include "servmgr.h" +#include "peercast.h" +#include "simple.h" +#ifdef _DEBUG +#include "chkMemoryLeak.h" +#define DEBUG_NEW new(__FILE__, __LINE__) +#define new DEBUG_NEW +#endif + +ThreadInfo guiThread; +bool shownChannels=false; + +class ListData{ +public: + int channel_id; + char name[21]; + int bitRate; + int status; + const char *statusStr; + int totalListeners; + int totalRelays; + int localListeners; + int localRelays; + bool stayConnected; + ChanHit chDisp; + bool bTracker; + + bool flg; + ListData *next; +}; + +class ServentData{ +public: + int servent_id; + unsigned int tnum; + int type; + int status; + String agent; + Host h; + unsigned int syncpos; + char *typeStr; + char *statusStr; + bool infoFlg; + bool relay; + bool firewalled; + unsigned int numRelays; + unsigned int totalRelays; + unsigned int totalListeners; + int vp_ver; + char ver_ex_prefix[2]; + int ver_ex_number; + + bool flg; + ServentData *next; + + unsigned int lastSkipTime; + unsigned int lastSkipCount; +}; + +ListData *list_top = NULL; +ServentData *servent_top = NULL; + +// -------------------------------------------------- +// for PCRaw (connection list) start +WNDPROC wndOldListBox = NULL, wndOldConnListBox = NULL; +bool sleep_skip = false; + +LRESULT CALLBACK ListBoxProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch(message) + { + case WM_LBUTTONDOWN: + { + int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam); + if(index >= 0x10000) + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L); + } + sleep_skip = true; + } + break; + + case WM_LBUTTONDBLCLK: + { + int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam); + if(index < 0x10000) + { + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON8, NULL); + } + } + break; + + case WM_RBUTTONDOWN: + { + POINT pos; + MENUITEMINFO info, separator; + HMENU hMenu; + DWORD dwID; + + int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam); + if(index < 0x10000) + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)index, 1L); + } + else + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L); + sleep_skip = true; + break; + } + + hMenu = CreatePopupMenu(); + + memset(&separator, 0, sizeof(MENUITEMINFO)); + separator.cbSize = sizeof(MENUITEMINFO); + separator.fMask = MIIM_ID | MIIM_TYPE; + separator.fType = MFT_SEPARATOR; + separator.wID = 8000; + + memset(&info, 0, sizeof(MENUITEMINFO)); + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_ID | MIIM_TYPE; + info.fType = MFT_STRING; + + info.wID = 1001; + info.dwTypeData = "Ø’f(&X)"; + InsertMenuItem(hMenu, -1, true, &info); + + InsertMenuItem(hMenu, -1, true, &separator); + + info.wID = 1000; + info.dwTypeData = "Ä¶(&P)"; + InsertMenuItem(hMenu, -1, true, &info); + + InsertMenuItem(hMenu, -1, true, &separator); + + info.wID = 1002; + info.dwTypeData = "ÄÚ‘±(&R)"; + InsertMenuItem(hMenu, -1, true, &info); + + info.wID = 1003; + info.dwTypeData = "ƒL[ƒv(&K)"; + InsertMenuItem(hMenu, -1, true, &info); + + InsertMenuItem(hMenu, -1, true, &separator); + + info.wID = 2000; + info.dwTypeData = "‘I‘ð‰ðœ(&D)"; + InsertMenuItem(hMenu, -1, true, &info); + + GetCursorPos(&pos); + dwID = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pos.x, pos.y, 0, hwnd, NULL); + + DestroyMenu(hMenu); + + switch(dwID) + { + case 1000: + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON8, NULL); + break; + + case 1001: + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON5, NULL); + break; + + case 1002: + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON3, NULL); + break; + + case 1003: + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON9, NULL); + break; + + case 2000: + SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L); + sleep_skip = true; + break; + } + + } + break; + + case WM_KEYDOWN: + sleep_skip = true; + break; + } + + return CallWindowProc(wndOldListBox, hwnd, message, wParam, lParam); +} + +LRESULT CALLBACK ConnListBoxProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch(message) + { + case WM_LBUTTONDOWN: + { + int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam); + if(index >= 0x10000) + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L); + } + } + break; + + case WM_RBUTTONDOWN: + { + POINT pos; + MENUITEMINFO info; + HMENU hMenu; + DWORD dwID; + + int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam); + if(index < 0x10000) + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)index, 1L); + } + else + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L); + break; + } + + hMenu = CreatePopupMenu(); + + memset(&info, 0, sizeof(MENUITEMINFO)); + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_ID | MIIM_TYPE; + info.fType = MFT_STRING; + + info.wID = 1001; + info.dwTypeData = "Ø’f(&X)"; + InsertMenuItem(hMenu, -1, true, &info); + + GetCursorPos(&pos); + dwID = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pos.x, pos.y, 0, hwnd, NULL); + + DestroyMenu(hMenu); + + switch(dwID) + { + case 1001: + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON6, NULL); + break; + } + + } + break; + } + + return CallWindowProc(wndOldConnListBox, hwnd, message, wParam, lParam); +} +// for PCRaw (connection list) end +// -------------------------------------------------- +int logID,statusID,hitID,chanID; + +// -------------------------------------------------- +bool getButtonState(int id) +{ + return SendDlgItemMessage(guiWnd, id,BM_GETCHECK, 0, 0) == BST_CHECKED; +} + +// -------------------------------------------------- +void enableControl(int id, bool on) +{ + EnableWindow(GetDlgItem(guiWnd,id),on); +} + +// -------------------------------------------------- +void enableEdit(int id, bool on) +{ + SendDlgItemMessage(guiWnd, id,WM_ENABLE, on, 0); + SendDlgItemMessage(guiWnd, id,EM_SETREADONLY, !on, 0); +} +// -------------------------------------------------- +int getEditInt(int id) +{ + char str[128]; + SendDlgItemMessage(guiWnd, id,WM_GETTEXT, 128, (LONG)str); + return atoi(str); +} +// -------------------------------------------------- +char * getEditStr(int id) +{ + static char str[128]; + SendDlgItemMessage(guiWnd, id,WM_GETTEXT, 128, (LONG)str); + return str; +} +// -------------------------------------------------- +void setEditStr(int id, char *str) +{ + SendDlgItemMessage(guiWnd, id,WM_SETTEXT, 0, (LONG)str); +} +// -------------------------------------------------- +void setEditInt(int id, int v) +{ + char str[128]; + sprintf(str,"%d",v); + SendDlgItemMessage(guiWnd, id,WM_SETTEXT, 0, (LONG)str); +} + +// -------------------------------------------------- +void *getListBoxSelData(int id) +{ + int sel = SendDlgItemMessage(guiWnd, id,LB_GETCURSEL, 0, 0); + if (sel >= 0) + return (void *)SendDlgItemMessage(guiWnd, id,LB_GETITEMDATA, sel, 0); + return NULL; +} + +Channel *getListBoxChannel(){ + int sel = SendDlgItemMessage(guiWnd, chanID ,LB_GETCURSEL, 0, 0); + if (sel >= 0){ + ListData *ld = list_top; + int idx = 0; + + while(ld){ + if (sel == idx){ + return chanMgr->findChannelByChannelID(ld->channel_id); + } + ld = ld->next; + idx++; + } + } + return NULL; +} + +Servent *getListBoxServent(){ + int sel = SendDlgItemMessage(guiWnd, statusID ,LB_GETCURSEL, 0, 0); + if (sel >= 0){ + ServentData *sd = servent_top; + int idx = 0; + + while(sd){ + if (sel == idx){ + return servMgr->findServentByServentID(sd->servent_id); + } + sd = sd->next; + idx++; + } + } + return NULL; +} + +// -------------------------------------------------- +void setButtonState(int id, bool on) +{ + SendDlgItemMessage(guiWnd, id,BM_SETCHECK, on, 0); + SendMessage(guiWnd,WM_COMMAND,id,0); +} +// -------------------------------------------------- +void ADDLOG(const char *str,int id,bool sel,void *data, LogBuffer::TYPE type) +{ + if (guiWnd) + { + + String sjis; //JP-EX + int num = SendDlgItemMessage(guiWnd, id,LB_GETCOUNT, 0, 0); + if (num > 100) + { + SendDlgItemMessage(guiWnd, id, LB_DELETESTRING, 0, 0); + num--; + } + sjis = str; //JP-Patch + sjis.convertTo(String::T_SJIS); //JP-Patch + //int idx = SendDlgItemMessage(guiWnd, id, LB_ADDSTRING, 0, (LONG)(LPSTR)str); + int idx = SendDlgItemMessage(guiWnd, id, LB_ADDSTRING, 0, (LONG)(LPSTR)sjis.cstr()); + SendDlgItemMessage(guiWnd, id, LB_SETITEMDATA, idx, (LONG)data); + + if (sel) + SendDlgItemMessage(guiWnd, id, LB_SETCURSEL, num, 0); + + } + + if (type != LogBuffer::T_NONE) + { +#if _DEBUG + OutputDebugString(str); + OutputDebugString("\n"); +#endif + } + +} + + +// -------------------------------------------------- +void ADDLOG2(const char *fmt,va_list ap,int id,bool sel,void *data, LogBuffer::TYPE type) +{ + char str[4096]; + vsprintf(str,fmt,ap); + + ADDLOG(str,id,sel,data,type); +} + +// -------------------------------------------------- +void ADDCHAN(void *d, const char *fmt,...) +{ + va_list ap; + va_start(ap, fmt); + ADDLOG2(fmt,ap,chanID,false,d,LogBuffer::T_NONE); + va_end(ap); +} +// -------------------------------------------------- +void ADDHIT(void *d, const char *fmt,...) +{ + va_list ap; + va_start(ap, fmt); + ADDLOG2(fmt,ap,hitID,false,d,LogBuffer::T_NONE); + va_end(ap); +} +// -------------------------------------------------- +void ADDCONN(void *d, const char *fmt,...) +{ + va_list ap; + va_start(ap, fmt); + ADDLOG2(fmt,ap,statusID,false,d,LogBuffer::T_NONE); + va_end(ap); +} + +WLock sd_lock; +WLock ld_lock; + +// -------------------------------------------------- +THREAD_PROC showConnections(ThreadInfo *thread) +{ +// thread->lock(); + while (thread->active) + { + int sel,top,i; +/* sel = SendDlgItemMessage(guiWnd, statusID,LB_GETCURSEL, 0, 0); + top = SendDlgItemMessage(guiWnd, statusID,LB_GETTOPINDEX, 0, 0); + + SendDlgItemMessage(guiWnd, statusID, LB_RESETCONTENT, 0, 0); + Servent *s = servMgr->servents; + while (s) + { + if (s->type != Servent::T_NONE) + { + Host h = s->getHost(); + { + unsigned int ip = h.ip; + unsigned short port = h.port; + + Host h(ip,port); + char hostName[64]; + h.toStr(hostName); + + unsigned int tnum = 0; + char tdef = 's'; + if (s->lastConnect) + tnum = sys->getTime()-s->lastConnect; + + if ((s->type == Servent::T_RELAY) || (s->type == Servent::T_DIRECT)) + { + ADDCONN(s,"%s-%s-%d%c - %s - %d - %s ", + s->getTypeStr(),s->getStatusStr(),tnum,tdef, + hostName, + s->syncPos,s->agent.cstr() + ); //JP-Patch + }else{ + if (s->status == Servent::S_CONNECTED) + { + ADDCONN(s,"%s-%s-%d%c - %s - %d/%d", + s->getTypeStr(),s->getStatusStr(),tnum,tdef, + hostName, + s->gnuStream.packetsIn,s->gnuStream.packetsOut); + }else{ + ADDCONN(s,"%s-%s-%d%c - %s", + s->getTypeStr(),s->getStatusStr(),tnum,tdef, + hostName + ); + } + + } + + } + } + s=s->next; + } + if (sel >= 0) + SendDlgItemMessage(guiWnd, statusID,LB_SETCURSEL, sel, 0); + if (top >= 0) + SendDlgItemMessage(guiWnd, statusID,LB_SETTOPINDEX, top, 0);*/ + + int sd_count = 0; + int diff = 0; + + sel = SendDlgItemMessage(guiWnd, statusID,LB_GETCURSEL, 0, 0); + top = SendDlgItemMessage(guiWnd, statusID,LB_GETTOPINDEX, 0, 0); + + ServentData *sd = servent_top; + while(sd){ + sd->flg = false; + sd = sd->next; + sd_count++; + } + + servMgr->lock.on(); + Servent *s = servMgr->servents; + + Channel *sel_ch = getListBoxChannel(); // for PCRaw (connection list) + + while(s){ + Servent *next; + bool foundFlg = false; + ChanHitList *chl; + bool infoFlg = false; + bool relay = true; + bool firewalled = false; + unsigned int numRelays = 0; + unsigned int totalRelays = 0; + unsigned int totalListeners = 0; + int vp_ver = 0; + char ver_ex_prefix[2] = {' ', ' '}; + int ver_ex_number = 0; + + next = s->next; + + // for PCRaw (connection list) start + if(sel_ch && !sel_ch->info.id.isSame(s->chanID)) + { + s = next; + continue; + } + // for PCRaw (connection list) end + + if (s->type != Servent::T_NONE){ + + chanMgr->hitlistlock.on(); + + chl = chanMgr->findHitListByID(s->chanID); + if (chl){ + ChanHit *hit = chl->hit; + while(hit){ + if (hit->servent_id == s->servent_id){ + if ((hit->numHops == 1)/* && (hit->host.ip == s->getHost().ip)*/){ + infoFlg = true; + relay = hit->relay; + firewalled = hit->firewalled; + numRelays = hit->numRelays; + vp_ver = hit->version_vp; + ver_ex_prefix[0] = hit->version_ex_prefix[0]; + ver_ex_prefix[1] = hit->version_ex_prefix[1]; + ver_ex_number = hit->version_ex_number; + } + totalRelays += hit->numRelays; + totalListeners += hit->numListeners; + } + hit = hit->next; + } + } + chanMgr->hitlistlock.off(); + } + + sd = servent_top; + while(sd){ + if (sd->servent_id == s->servent_id){ + foundFlg = true; + if (s->thread.finish) break; + sd->flg = true; + sd->type = s->type; + sd->status = s->status; + sd->agent = s->agent; + sd->h = s->getHost(); + sd->syncpos = s->syncPos; + sd->tnum = (s->lastConnect) ? sys->getTime()-s->lastConnect : 0; + sd->typeStr = s->getTypeStr(); + sd->statusStr = s->getStatusStr(); + sd->infoFlg = infoFlg; + sd->relay = relay; + sd->firewalled = firewalled; + sd->numRelays = numRelays; + sd->totalRelays = totalRelays; + sd->totalListeners = totalListeners; + sd->vp_ver = vp_ver; + sd->lastSkipTime = s->lastSkipTime; + sd->lastSkipCount = s->lastSkipCount; + sd->ver_ex_prefix[0] = ver_ex_prefix[0]; + sd->ver_ex_prefix[1] = ver_ex_prefix[1]; + sd->ver_ex_number = ver_ex_number; + break; + } + sd = sd->next; + } + if (!foundFlg && (s->type != Servent::T_NONE) && !s->thread.finish){ + ServentData *newData = new ServentData(); + newData->next = servent_top; + servent_top = newData; + newData->flg = true; + newData->servent_id = s->servent_id; + newData->type = s->type; + newData->status = s->status; + newData->agent = s->agent; + newData->h = s->getHost(); + newData->syncpos = s->syncPos; + newData->tnum = (s->lastConnect) ? sys->getTime()-s->lastConnect : 0; + newData->typeStr = s->getTypeStr(); + newData->statusStr = s->getStatusStr(); + newData->infoFlg = infoFlg; + newData->relay = relay; + newData->firewalled = firewalled; + newData->numRelays = numRelays; + newData->totalRelays = totalRelays; + newData->totalListeners = totalListeners; + newData->vp_ver = vp_ver; + newData->lastSkipTime = s->lastSkipTime; + newData->lastSkipCount = s->lastSkipCount; + newData->ver_ex_prefix[0] = ver_ex_prefix[0]; + newData->ver_ex_prefix[1] = ver_ex_prefix[1]; + newData->ver_ex_number = ver_ex_number; + + int idx = SendDlgItemMessage(guiWnd, statusID, LB_ADDSTRING, 0, (LONG)""); + SendDlgItemMessage(guiWnd, statusID, LB_SETITEMDATA, idx, (LONG)(newData->servent_id)); + diff++; + } + s = next; + } + servMgr->lock.off(); + + sd_lock.on(); + sd = servent_top; + int idx = 0; + ServentData *prev = NULL; + //int *idxs; + //if (sd_count){ + // idxs = new int[sd_count]; + //} + while(sd){ + if (!sd->flg || (sd->type == Servent::T_NONE)){ + ServentData *next = sd->next; + if (!prev){ + servent_top = next; + } else { + prev->next = next; + } + delete sd; + + PostMessage(GetDlgItem(guiWnd, statusID), LB_DELETESTRING, idx, 0); +// SendDlgItemMessage(guiWnd, statusID, LB_DELETESTRING, idx, 0); + sd = next; +// diff--; + } else { + idx++; + prev = sd; + sd = sd->next; + } + } + sd_lock.off(); + + if ((sel >= 0) && (diff != 0)){ + PostMessage(GetDlgItem(guiWnd, statusID), LB_SETCURSEL, sel+diff, 0); + } + if (top >= 0){ + PostMessage(GetDlgItem(guiWnd, statusID), LB_SETTOPINDEX, top, 0); + } + InvalidateRect(GetDlgItem(guiWnd, statusID), NULL, FALSE); + + char cname[34]; + + { +// sel = SendDlgItemMessage(guiWnd, chanID,LB_GETCURSEL, 0, 0); +// top = SendDlgItemMessage(guiWnd, chanID,LB_GETTOPINDEX, 0, 0); +// SendDlgItemMessage(guiWnd, chanID, LB_RESETCONTENT, 0, 0); + + ListData *ld = list_top; + while(ld){ + ld->flg = false; + ld = ld->next; + } + + Channel *c = chanMgr->channel; + + while (c) + { + Channel *next; + bool foundFlg = false; + String sjis; + sjis = c->getName(); + sjis.convertTo(String::T_SJIS); + + next = c->next; + + ld = list_top; + while(ld){ + if (ld->channel_id == c->channel_id){ + foundFlg = true; + if (c->thread.finish) break; + ld->flg = true; + strncpy(ld->name, sjis, 20); + ld->name[20] = '\0'; + ld->bitRate = c->info.bitrate; + ld->status = c->status; + ld->statusStr = c->getStatusStr(); + ld->totalListeners = c->totalListeners(); + ld->totalRelays = c->totalRelays(); + ld->localListeners = c->localListeners(); + ld->localRelays = c->localRelays(); + ld->stayConnected = c->stayConnected; + ld->chDisp = c->chDisp; + ld->bTracker = c->sourceHost.tracker; + break; + } + ld = ld->next; + } + if (!foundFlg && !c->thread.finish){ + ListData *newData = new ListData(); + newData->next = list_top; + list_top = newData; + newData->flg = true; + newData->channel_id = c->channel_id; + strncpy(newData->name, sjis, 20); + newData->name[20] = '\0'; + newData->bitRate = c->info.bitrate; + newData->status = c->status; + newData->statusStr = c->getStatusStr(); + newData->totalListeners = c->totalListeners(); + newData->totalRelays = c->totalRelays(); + newData->localListeners = c->localListeners(); + newData->localRelays = c->localRelays(); + newData->stayConnected = c->stayConnected; + newData->chDisp = c->chDisp; + newData->bTracker = c->sourceHost.tracker; + + int idx = SendDlgItemMessage(guiWnd, chanID, LB_ADDSTRING, 0, (LONG)""); + SendDlgItemMessage(guiWnd, chanID, LB_SETITEMDATA, idx, (LONG)(newData->channel_id)); + } + c = next; + } + + ld = list_top; + int idx = 0; + ListData *prev = NULL; + while(ld){ + if (!ld->flg){ + ListData *next = ld->next; + if (!prev){ + list_top = next; + } else { + prev->next = next; + } + delete ld; + + SendDlgItemMessage(guiWnd, chanID, LB_DELETESTRING, idx, 0); + ld = next; + } else { + idx++; + prev = ld; + ld = ld->next; + } + } + + InvalidateRect(GetDlgItem(guiWnd, chanID), NULL, FALSE); + +/* String sjis; //JP-Patch + sjis = c->getName(); //JP-Patch + sjis.convertTo(String::T_SJIS); //JP-Patch + strncpy(cname,sjis.cstr(),16); //JP-Patch + //strncpy(cname,c->getName(),16); + cname[16] = 0; + //int sec = ((c->currSPacket*c->bitrate*SPacket::DATA_LEN)/8)/(c->bitrate*1024); + //int k = ((c->currSPacket*SPacket::DATA_LEN))/(1024); + //ADDCHAN(c,"%d. %s - %d KB/s - %du - %dk",num,cname,c->bitrate,c->listeners,k); + //ADDCHAN(c,"%d. %s - %d kb/s - %s",c->index,cname,c->getBitrate(),c->getStatusStr()); + ADDCHAN(c,"%s - %d kb/s - %s - %d/%d-[%d/%d] - %s",cname,c->getBitrate(),c->getStatusStr(), + c->totalListeners(),c->totalRelays(),c->localListeners(),c->localRelays(),c->stayConnected?"Yes":"No"); //JP-Patch + } + c=c->next; + }*/ +// if (sel >= 0) +// SendDlgItemMessage(guiWnd, chanID,LB_SETCURSEL, sel, 0); +// if (top >= 0) +// SendDlgItemMessage(guiWnd, chanID,LB_SETTOPINDEX, top, 0); + } + + + + bool update = ((sys->getTime() - chanMgr->lastHit) < 3)||(!shownChannels); + + if (update) + { + shownChannels = true; + { + sel = SendDlgItemMessage(guiWnd, hitID,LB_GETCURSEL, 0, 0); + top = SendDlgItemMessage(guiWnd, hitID,LB_GETTOPINDEX, 0, 0); + SendDlgItemMessage(guiWnd, hitID, LB_RESETCONTENT, 0, 0); + + chanMgr->hitlistlock.on(); + + ChanHitList *chl = chanMgr->hitlist; + + while (chl) + { + if (chl->isUsed()) + { + if (chl->info.match(chanMgr->searchInfo)) + { + strncpy(cname,chl->info.name.cstr(),16); + cname[16] = 0; + ADDHIT(chl,"%s - %d kb/s - %d/%d",cname,chl->info.bitrate,chl->numListeners(),chl->numHits()); + } + } + chl = chl->next; + } + chanMgr->hitlistlock.off(); + } + + if (sel >= 0) + SendDlgItemMessage(guiWnd, hitID,LB_SETCURSEL, sel, 0); + if (top >= 0) + SendDlgItemMessage(guiWnd, hitID,LB_SETTOPINDEX, top, 0); + } + + + + + { + switch (servMgr->getFirewall()) + { + case ServMgr::FW_ON: + SendDlgItemMessage(guiWnd, IDC_EDIT4,WM_SETTEXT, 0, (LONG)"Firewalled"); + break; + case ServMgr::FW_UNKNOWN: + SendDlgItemMessage(guiWnd, IDC_EDIT4,WM_SETTEXT, 0, (LONG)"Unknown"); + break; + case ServMgr::FW_OFF: + SendDlgItemMessage(guiWnd, IDC_EDIT4,WM_SETTEXT, 0, (LONG)"Normal"); + break; + } + } + + // sleep for 1 second .. check every 1/10th for shutdown + for(i=0; i<10; i++) + { + if(sleep_skip) // for PCRaw (connection list) + { + sleep_skip = false; + break; + } + + if (!thread->active) + break; + sys->sleep(100); + } + } + + ListData *ld = list_top; + while(ld){ + ListData *next; + next = ld->next; + + delete ld; + + ld = next; + } + list_top = NULL; + + ServentData *sd = servent_top; + while(sd){ + ServentData *next; + next = sd->next; + + delete sd; + + sd = next; + } + servent_top = NULL; + +// thread->unlock(); + return 0; +} + + +// -------------------------------------------------- +void tryConnect() +{ +#if 0 + ClientSocket sock; + + char tmp[32]; + + char *sendStr = "GET / HTTP/1.1\n\n"; + + try { + sock.open("taiyo",80); + sock.write(sendStr,strlen(sendStr)); + sock.read(tmp,32); + LOG("Connected: %s",tmp); + }catch(IOException &e) + { + LOG(e.msg); + } +#endif +} + + +// --------------------------------- +void APICALL MyPeercastApp ::printLog(LogBuffer::TYPE t, const char *str) +{ + ADDLOG(str,logID,true,NULL,t); + if (logFile.isOpen()) + { + logFile.writeLine(str); + logFile.flush(); + } +} + + +// -------------------------------------------------- +static void setControls(bool fromGUI) +{ + if (!guiWnd) + return; + setEditInt(IDC_EDIT1,servMgr->serverHost.port); + setEditStr(IDC_EDIT3,servMgr->password); + setEditStr(IDC_EDIT9,chanMgr->broadcastMsg.cstr()); + setEditInt(IDC_MAXRELAYS,servMgr->maxRelays); + + setButtonState(IDC_CHECK11,chanMgr->broadcastMsg[0]!=0); + + setButtonState(IDC_LOGDEBUG,(servMgr->showLog&(1<showLog&(1<showLog&(1<showLog&(1<pauseLog); + + + if (!fromGUI) + setButtonState(IDC_CHECK1,servMgr->autoServe); + + +} +// -------------------------------------------------- +void APICALL MyPeercastApp::updateSettings() +{ + setControls(true); +} + +void MoveControl(HWND hWnd, int cx, int cy, int y, HDWP& hDwp){ + RECT rc2; + POINT pos; + + GetWindowRect(hWnd, &rc2); + pos.x = rc2.left; + pos.y = rc2.top; + ScreenToClient(guiWnd, &pos); + hDwp = DeferWindowPos(hDwp, hWnd, HWND_TOP, + pos.x,cy-y-(rc2.bottom-rc2.top),rc2.right-rc2.left,rc2.bottom-rc2.top,SWP_SHOWWINDOW); +} + +void MoveControl2(HWND hWnd, int cx, int cy, int y, HDWP& hDwp){ + RECT rc; + POINT pos; + + GetWindowRect(hWnd, &rc); + pos.x = rc.left; + pos.y = rc.top; + ScreenToClient(guiWnd, &pos); + hDwp = DeferWindowPos(hDwp, hWnd, HWND_TOP, + pos.x,pos.y,rc.right-rc.left,cy-y,SWP_SHOWWINDOW); +} + +// -------------------------------------------------- +void MoveControls(LPARAM lParam){ + HDWP hDwp; + //IDC_LIST1 3,291,291,43 +/* CONTROL "—LŒø",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,9,29,60,20,WS_EX_TRANSPARENT + EDITTEXT IDC_EDIT1,127,18,47,12,ES_AUTOHSCROLL + RTEXT "ƒ|[ƒg :",IDC_STATIC,107,20,18,8 + GROUPBOX "",IDC_STATIC,3,4,291,49 + PUSHBUTTON "Ø’f",IDC_BUTTON5,67,65,43,13 + EDITTEXT IDC_EDIT3,127,34,47,12,ES_PASSWORD | ES_AUTOHSCROLL + RTEXT "ƒpƒXƒ[ƒh :",IDC_STATIC,89,36,36,8 + PUSHBUTTON "Ä¶",IDC_BUTTON8,10,65,22,13 + PUSHBUTTON "ÄÚ‘±",IDC_BUTTON3,41,65,24,13 + RTEXT "Å‘僊ƒŒ[” :",IDC_STATIC,203,20,40,8 + EDITTEXT IDC_MAXRELAYS,248,18,40,14,ES_AUTOHSCROLL | ES_NUMBER + PUSHBUTTON "ƒL[ƒv",IDC_BUTTON9,112,65,24,13 + LTEXT "Peercast-VP",IDC_STATIC,21,14,39,8*/ + +/* + GROUPBOX "ƒŠƒŒ[",IDC_GROUPBOX_RELAY,3,54,291,132 + LISTBOX IDC_LIST3,3,81,291,102,LBS_OWNERDRAWFIXED | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + CONTROL "DJ",IDC_CHECK11,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,5,190,23,12 + EDITTEXT IDC_EDIT9,33,189,261,14,ES_AUTOHSCROLL + LTEXT "ƒRƒlƒNƒVƒ‡ƒ“",IDC_STATIC_CONNECTION,3,214,40,8 + PUSHBUTTON "Ø’f",IDC_BUTTON6,47,209,43,13 + LISTBOX IDC_LIST2,3,224,291,53,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | + WS_TABSTOP + LTEXT "ƒƒO",IDC_STATIC_LOG,3,282,13,8 + PUSHBUTTON "ƒNƒŠƒA",IDC_BUTTON1,35,279,25,11 + CONTROL "’âŽ~",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,60,279,30,11 + CONTROL "ƒfƒoƒbƒO",IDC_LOGDEBUG,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,127,279,32,11 + CONTROL "ƒGƒ‰[",IDC_LOGERRORS,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,159,279,25,11 + CONTROL "ƒlƒbƒgƒ[ƒN",IDC_LOGNETWORK,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,185,279,35,11 + CONTROL "ƒ`ƒƒƒ“ƒlƒ‹",IDC_LOGCHANNELS,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,221,279,35,11 + LISTBOX IDC_LIST1,3,291,291,43,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | + WS_TABSTOP*/ + + hDwp = BeginDeferWindowPos(15); + int cx = LOWORD(lParam); + int cy = HIWORD(lParam); + + MoveControl2(GetDlgItem(guiWnd, IDC_GROUPBOX_RELAY), cx, cy, 343, hDwp); + MoveControl2(GetDlgItem(guiWnd, IDC_LIST3), cx, cy, 385, hDwp); + + MoveControl(GetDlgItem(guiWnd, IDC_EDIT9), cx, cy, 233, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_CHECK11), cx, cy, 232, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_STATIC_CONNECTION), cx, cy, 209, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_BUTTON6), cx, cy, 208, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LIST2), cx, cy, 94, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_STATIC_LOG), cx, cy, 72, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_CHECK9), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_BUTTON1), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LOGDEBUG), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LOGNETWORK), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LOGERRORS), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LOGCHANNELS), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LIST1), cx, cy, 3, hDwp); + + EndDeferWindowPos(hDwp); +} + +WINDOWPLACEMENT winPlace; +bool guiFlg = false; + +// -------------------------------------------------- +LRESULT CALLBACK GUIProc (HWND hwnd, UINT message, + WPARAM wParam, LPARAM lParam) +{ + + static const struct + { + LRESULT from; // •ÏŠ·Œ³ + LRESULT to; // •ÏŠ·æ + } + trans[] = + { + { HTLEFT, HTBORDER }, // ¶’[‚̍¶‰E–îˆó ¨ –îˆó‚È‚µ + { HTRIGHT, HTBORDER }, // ‰E’[‚̍¶‰E–îˆó ¨ –îˆó‚È‚µ + { HTTOPLEFT, HTTOP }, // ¶ã‹÷‚̎΂ߖîˆó ¨ c–îˆó + { HTTOPRIGHT, HTTOP }, // ‰Eã‹÷‚̎΂ߖîˆó ¨ c–îˆó + { HTBOTTOMLEFT, HTBOTTOM }, // ¶‰º‹÷‚̎΂ߖîˆó ¨ c–îˆó + { HTBOTTOMRIGHT, HTBOTTOM }, // ‰E‰º‹÷‚̎΂ߖîˆó ¨ c–îˆó + { HTTOP, HTTOP }, + { HTBOTTOM, HTBOTTOM } + }; + + + bool rectflg = false; + + switch (message) + { + case WM_INITDIALOG: + guiWnd = hwnd; + + shownChannels = false; + logID = IDC_LIST1; // log + statusID = IDC_LIST2; // status + hitID = IDC_LIST4; // hit + chanID = IDC_LIST3; // channels + + enableControl(IDC_BUTTON8,false); + enableControl(IDC_BUTTON11,false); + enableControl(IDC_BUTTON10,false); + + peercastApp->updateSettings(); + + if (servMgr->autoServe) + setButtonState(IDC_CHECK1,true); + if (servMgr->autoConnect) + setButtonState(IDC_CHECK2,true); + + + guiThread.func = showConnections; + if (!sys->startThread(&guiThread)) + { + MessageBox(hwnd,"Unable to start GUI","PeerCast",MB_OK|MB_ICONERROR); + PostMessage(hwnd,WM_DESTROY,0,0); + } + + if (guiFlg){ + SetWindowPlacement(hwnd, &winPlace); + } + + { // for PCRaw (connection list) + HWND hwndList; + + hwndList = GetDlgItem(guiWnd, chanID); + wndOldListBox = (WNDPROC)GetWindowLong(hwndList, GWL_WNDPROC); + SetWindowLong(hwndList, GWL_WNDPROC, (DWORD)ListBoxProc); + + hwndList = GetDlgItem(guiWnd, statusID); + wndOldConnListBox = (WNDPROC)GetWindowLong(hwndList, GWL_WNDPROC); + SetWindowLong(hwndList, GWL_WNDPROC, (DWORD)ConnListBoxProc); + } + + break; + + case WM_COMMAND: + switch( wParam ) + { + case IDC_CHECK1: // start server + if (getButtonState(IDC_CHECK1)) + { + //SendDlgItemMessage(hwnd, IDC_CHECK1,WM_SETTEXT, 0, (LPARAM)"Deactivate"); + + SendDlgItemMessage(hwnd, IDC_EDIT3,WM_GETTEXT, 64, (LONG)servMgr->password); + + servMgr->serverHost.port = (unsigned short)getEditInt(IDC_EDIT1); + servMgr->setMaxRelays(getEditInt(IDC_MAXRELAYS)); + + + enableControl(IDC_EDIT1,false); + enableControl(IDC_EDIT3,false); + enableControl(IDC_MAXRELAYS,false); + enableControl(IDC_BUTTON8,true); + enableControl(IDC_BUTTON11,true); + enableControl(IDC_BUTTON10,true); + + //writeSettings(); + servMgr->autoServe = true; + + setEditStr(IDC_CHECK1,"Enabled"); + + + }else{ + //SendDlgItemMessage(hwnd, IDC_CHECK1,WM_SETTEXT, 0, (LPARAM)"Activate"); + + servMgr->autoServe = false; + + enableControl(IDC_EDIT1,true); + enableControl(IDC_EDIT3,true); + enableControl(IDC_MAXRELAYS,true); + enableControl(IDC_BUTTON8,false); + enableControl(IDC_BUTTON11,false); + enableControl(IDC_BUTTON10,false); + + setEditStr(IDC_CHECK1,"Disabled"); + + } + setControls(true); + + break; + case IDC_CHECK11: // DJ message + if (getButtonState(IDC_CHECK11)) + { + enableControl(IDC_EDIT9,false); + SendDlgItemMessage(hwnd, IDC_EDIT9,WM_GETTEXT, 128, (LONG)chanMgr->broadcastMsg.cstr()); + }else{ + enableControl(IDC_EDIT9,true); + chanMgr->broadcastMsg.clear(); + } + break; + case IDC_LOGDEBUG: // log debug + servMgr->showLog = getButtonState(wParam) ? servMgr->showLog|(1<showLog&~(1<showLog = getButtonState(wParam) ? servMgr->showLog|(1<showLog&~(1<showLog = getButtonState(wParam) ? servMgr->showLog|(1<showLog&~(1<showLog = getButtonState(wParam) ? servMgr->showLog|(1<showLog&~(1<pauseLog = getButtonState(wParam); + break; + case IDC_CHECK2: // start outgoing + + if (getButtonState(IDC_CHECK2)) + { + + SendDlgItemMessage(hwnd, IDC_COMBO1,WM_GETTEXT, 128, (LONG)servMgr->connectHost); + servMgr->autoConnect = true; + //SendDlgItemMessage(hwnd, IDC_CHECK2,WM_SETTEXT, 0, (LPARAM)"Disconnect"); + enableControl(IDC_COMBO1,false); + }else{ + servMgr->autoConnect = false; + //SendDlgItemMessage(hwnd, IDC_CHECK2,WM_SETTEXT, 0, (LPARAM)"Connect"); + enableControl(IDC_COMBO1,true); + } + break; + case IDC_BUTTON11: // broadcast + { + Host sh = servMgr->serverHost; + if (sh.isValid()) + { + char cmd[256]; + sprintf(cmd,"http://localhost:%d/admin?page=broadcast",sh.port); + ShellExecute(hwnd, NULL, cmd, NULL, NULL, SW_SHOWNORMAL); + + }else{ + MessageBox(hwnd,"Server is not currently connected.\nPlease wait until you have a connection.","PeerCast",MB_OK); + } + } + break; + case IDC_BUTTON8: // play selected + { + Channel *c = getListBoxChannel(); + if (c){ + chanMgr->playChannel(c->info); + } + } + break; + case IDC_BUTTON7: // advanced + sys->callLocalURL("admin?page=settings",servMgr->serverHost.port); + break; + case IDC_BUTTON6: // servent disconnect + { +/* Servent *s = (Servent *)getListBoxSelData(statusID); + if (s) + s->thread.active = false;*/ + Servent *s = getListBoxServent(); + if (s){ + s->thread.active = false; + s->thread.finish = true; + } + sleep_skip = true; + } + break; + case IDC_BUTTON5: // chan disconnect + { +/* Channel *c = (Channel *)getListBoxSelData(chanID); + if (c) + c->thread.active = false;*/ + +// Channel *c = chanMgr->findChannelByChannelID((int)getListBoxSelData(chanID)); + Channel *c = getListBoxChannel(); + if (c){ + c->thread.active = false; + c->thread.finish = true; + } + sleep_skip = true; + } + break; + case IDC_BUTTON3: // chan bump + { +/* Channel *c = (Channel *)getListBoxSelData(chanID); + if (c) + c->bump = true;*/ + +// Channel *c = chanMgr->findChannelByChannelID((int)getListBoxSelData(chanID)); + Channel *c = getListBoxChannel(); + if (c){ + c->bump = true; + } + } + + break; + case IDC_BUTTON4: // get channel + { + ChanHitList *chl = (ChanHitList *)getListBoxSelData(hitID); + if (chl) + { + if (!chanMgr->findChannelByID(chl->info.id)) + { + Channel *c = chanMgr->createChannel(chl->info,NULL); + if (c) + c->startGet(); + } + }else{ + MessageBox(hwnd,"Please select a channel","PeerCast",MB_OK); + } + } + break; + + case IDC_BUTTON9: //JP-EX chan keep + { +/* Channel *c = (Channel *)getListBoxSelData(chanID); + if (c) + { + if (!c->stayConnected) + { + //if (servMgr->getFirewall() == ServMgr::FW_OFF) + c->stayConnected = true; + } + else + c->stayConnected = false; + }*/ + +// Channel *c = chanMgr->findChannelByChannelID((int)getListBoxSelData(chanID)); + Channel *c = getListBoxChannel(); + if (c){ + if (!c->stayConnected){ + c->stayConnected = true; + } else { + c->stayConnected = false; + } + } + } + break; + + case IDC_BUTTON1: // clear log + SendDlgItemMessage(guiWnd, logID, LB_RESETCONTENT, 0, 0); + sys->logBuf->clear(); // for PCRaw (clear log) + break; + + case IDC_BUTTON2: // find + { + char str[64]; + SendDlgItemMessage(hwnd, IDC_EDIT2,WM_GETTEXT, 64, (LONG)str); + SendDlgItemMessage(hwnd, hitID, LB_RESETCONTENT, 0, 0); + ChanInfo info; + info.init(); + info.name.set(str); + chanMgr->startSearch(info); + } + break; + + } + break; + + case WM_MEASUREITEM: + if ((UINT) wParam==IDC_LIST3){ + LPMEASUREITEMSTRUCT lpMI = (LPMEASUREITEMSTRUCT)lParam; + lpMI->itemHeight = 12; + } else if ((UINT) wParam==IDC_LIST2){ + LPMEASUREITEMSTRUCT lpMI = (LPMEASUREITEMSTRUCT)lParam; + lpMI->itemHeight = 12; + } + break; + case WM_DRAWITEM: + if ((UINT) wParam==IDC_LIST3) + { + LPDRAWITEMSTRUCT _DrawItem=(LPDRAWITEMSTRUCT)lParam; + HBRUSH hBrush; + ListData *ld; + unsigned int idx = 0; + bool flg = false; + + ld = list_top; + while(ld){ + if (_DrawItem->itemID == idx){ + flg = true; + break; + } + ld = ld->next; + idx++; + } + if ((_DrawItem->itemState) & (ODS_SELECTED)) + { + hBrush=CreateSolidBrush(RGB(49,106,197)); + } + else + { + hBrush=CreateSolidBrush(RGB(255,255,255)); + } + FillRect(_DrawItem->hDC,&_DrawItem->rcItem,hBrush); + DeleteObject(hBrush); + if (flg){ + char buf[256]; + if (ld->status == Channel::S_RECEIVING){ + if (ld->chDisp.status == Channel::S_RECEIVING){ + if (ld->chDisp.relay){ + /* relay ok */ + SetTextColor(_DrawItem->hDC,RGB(0,255,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } else { + /* no more relay */ + if (ld->chDisp.numRelays){ + /* relay full */ + SetTextColor(_DrawItem->hDC,RGB(0,0,255)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } else { + /* relay ng */ + SetTextColor(_DrawItem->hDC,RGB(255,0,255)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } + } + } else { + /* status unmatch */ + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + "¡", + 2); + } else { + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + " ", + 2); + } + if ((_DrawItem->itemState) & (ODS_SELECTED)) + { + SetTextColor(_DrawItem->hDC,RGB(255,255,255)); + SetBkColor(_DrawItem->hDC,RGB(49,106,197)) ; + } else { + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } + if (servMgr->getFirewall() == ServMgr::FW_ON){ + SetTextColor(_DrawItem->hDC,RGB(255,0,0)); + } else if (ld->bTracker && (ld->status == Channel::S_RECEIVING)){ + if ((_DrawItem->itemState) & (ODS_SELECTED)) + { + SetTextColor(_DrawItem->hDC,RGB(0,255,0)); + SetBkColor(_DrawItem->hDC,RGB(49,106,197)) ; + } else { + SetTextColor(_DrawItem->hDC,RGB(0,128,0)); + } + } + + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12, + _DrawItem->rcItem.top, + ld->name, + strlen(ld->name)); +/* sprintf(buf, "- %4dkbps -", ld->bitRate); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12 + 118, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12 + 118 + 80, + _DrawItem->rcItem.top, + ld->statusStr, + strlen(ld->statusStr)); + sprintf(buf, "- %3d/%3d - [%3d/%3d] -", ld->totalListeners, ld->totalRelays, ld->localListeners, ld->localRelays); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12 + 118 + 80 + 80, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + strcpy(buf, ld->stayConnected?"YES":"NO"); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12 + 118 + 80 + 80 + 130, + _DrawItem->rcItem.top, + buf, + strlen(buf));*/ + sprintf(buf, "- %4dkbps - %s - %3d/%3d - [%3d/%3d] - %s", + ld->bitRate, + ld->statusStr, + ld->totalListeners, + ld->totalRelays, + ld->localListeners, + ld->localRelays, + ld->stayConnected?"YES":"NO"); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12 + 118, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + } + } else if ((UINT) wParam==IDC_LIST2) { + LPDRAWITEMSTRUCT _DrawItem=(LPDRAWITEMSTRUCT)lParam; + HBRUSH hBrush; + ServentData *sd; + unsigned int idx = 0; + bool flg = false; + + sd_lock.on(); + + sd = servent_top; + while(sd){ + if (_DrawItem->itemID == idx){ + flg = true; + break; + } + sd = sd->next; + idx++; + } + if (flg){ + char buf[256]; + char hostName[64]; + sd->h.toStr(hostName); + + if ((_DrawItem->itemState) & (ODS_SELECTED)) + { + hBrush=CreateSolidBrush(RGB(49,106,197)); + } + else + { + hBrush=CreateSolidBrush(RGB(255,255,255)); + } + FillRect(_DrawItem->hDC,&_DrawItem->rcItem,hBrush); + DeleteObject(hBrush); + + if (sd->infoFlg){ + if (sd->relay){ + /* relay ok */ + SetTextColor(_DrawItem->hDC,RGB(0,255,0)); +// SetBkColor(_DrawItem->hDC,RGB(255,255,255)); + } else { + /* no more relay */ + if (sd->numRelays){ + /* relay full */ + SetTextColor(_DrawItem->hDC,RGB(0,0,255)); +// SetBkColor(_DrawItem->hDC,RGB(255,255,255)); + } else { + /* relay ng */ + SetTextColor(_DrawItem->hDC,RGB(255,0,255)); +// SetBkColor(_DrawItem->hDC,RGB(255,255,255)); + } + } + } else { + /* no info */ + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); +// SetBkColor(_DrawItem->hDC,RGB(255,255,255)); + } + + if (sd->lastSkipTime + 120 > sys->getTime()){ + SetBkColor(_DrawItem->hDC,RGB(128,128,128)); + if (sd->type == Servent::T_RELAY){ + sprintf(buf, "¥(%d)",sd->lastSkipCount); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + } else { + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + sprintf(buf, "¤(%d)",sd->lastSkipCount); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + } + } else { + SetBkColor(_DrawItem->hDC,RGB(255,255,255)); + if (sd->type == Servent::T_RELAY){ + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + "¡", + 2); + } else { + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + " ", + 2); + } + } + + if ((_DrawItem->itemState) & (ODS_SELECTED)) + { + SetTextColor(_DrawItem->hDC,RGB(255,255,255)); + SetBkColor(_DrawItem->hDC,RGB(49,106,197)) ; + } else { + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } + if (sd->firewalled){ + if (!sd->numRelays){ + SetTextColor(_DrawItem->hDC,RGB(255,0,0)); + } else { + SetTextColor(_DrawItem->hDC,RGB(255,168,0)); + } + } + + char buf2[16]; + if (sd->ver_ex_number){ + sprintf(buf2, "(%c%c%04d)", sd->ver_ex_prefix[0], sd->ver_ex_prefix[1], sd->ver_ex_number); + } else if (sd->vp_ver){ + sprintf(buf2, "(VP%04d)", sd->vp_ver); + } else { + buf2[0] = '\0'; + } + if (sd->type == Servent::T_RELAY){ + if (sd->status == Servent::S_CONNECTED){ + sprintf(buf, "(%d)RELAYING-%ds - %d/%d - %s - %d - %s%s", + sd->lastSkipCount, + sd->tnum, + sd->totalListeners, sd->totalRelays, + hostName, + sd->syncpos, sd->agent.cstr(), buf2 + ); + } else { + sprintf(buf, "%s-%s-%ds - %d/%d - %s - %d - %s%s", + sd->typeStr, sd->statusStr, sd->tnum, + sd->totalListeners, sd->totalRelays, + hostName, + sd->syncpos, sd->agent.cstr(), buf2 + ); + } + } else if (sd->type == Servent::T_DIRECT){ + sprintf(buf, "%s-%s-%ds - %s - %d - %s ", + sd->typeStr, sd->statusStr, sd->tnum, + hostName, + sd->syncpos, sd->agent.cstr() + ); + } else { + if (sd->status == Servent::S_CONNECTED){ + sprintf(buf, "%s-%s-%ds - %s - %d/%d", + sd->typeStr, sd->statusStr, sd->tnum, + hostName, + sd->syncpos, sd->agent.cstr() + ); + } else { + sprintf(buf, "%s-%s-%ds - %s", + sd->typeStr, sd->statusStr, sd->tnum, + hostName + ); + } + } + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + } + sd_lock.off(); + } + break; + + case WM_SIZE: + MoveControls(lParam); + break; + + case WM_GETMINMAXINFO: + { + MINMAXINFO *pmmi = (MINMAXINFO *)lParam; + if ( pmmi ) + { + pmmi->ptMinTrackSize.x = 530; // Å¬• + pmmi->ptMinTrackSize.y = 435; // Å¬‚ + pmmi->ptMaxTrackSize.x = 530; // Å‘啝 + pmmi->ptMaxTrackSize.y = 1200; // Å‘卂 + } + return 0; + } + +/* case WM_NCHITTEST: + { + LRESULT lResult; // ƒJ[ƒ\ƒ‹ˆÊ’u”»’茋‰Ê + + // •ÏŠ·ˆê——‚É‚ ‚ê‚Εϊ·‚µ‚½’l‚ð•Ô‚·B + lResult = DefWindowProc( guiWnd, message, wParam, lParam ); + for( int i = 0; i < 8; i++ ) + { + if ( lResult == trans[ i ].from ) + { + return trans[ i ].to; + } + } +// return lResult; +// return HTCAPTION; +// return 0; + }*/ + + case WM_CLOSE: + GetWindowPlacement(hwnd, &winPlace); + guiFlg = true; + DestroyWindow( hwnd ); + break; + + case WM_DESTROY: + GetWindowPlacement(hwnd, &winPlace); + guiFlg = true; + guiThread.active = false; +// guiThread.lock(); + guiWnd = NULL; +// guiThread.unlock(); + EndDialog(hwnd, LOWORD(wParam)); + break; + + //default: + // do nothing + //return DefDlgProc(hwnd, message, wParam, lParam); // this recurses for ever + //return DefWindowProc(hwnd, message, wParam, lParam); // this stops window messages + } + return 0; +} diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.h b/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.h new file mode 100644 index 0000000..4eb0f3d --- /dev/null +++ b/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.h @@ -0,0 +1,44 @@ +// ------------------------------------------------ +// File : gui.h +// Date: 4-apr-2002 +// Author: giles +// +// (c) 2002 peercast.org +// ------------------------------------------------ +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// ------------------------------------------------ + +#ifndef _GUI_H +#define _GUI_H + +#include "sys.h" + +extern LRESULT CALLBACK GUIProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +extern void ADDLOG(const char *str,int id,bool sel,void *data, LogBuffer::TYPE type); + +extern String iniFileName; +extern HWND guiWnd; +extern int logID; + +enum +{ + WM_INITSETTINGS = WM_USER, + WM_GETPORTNUMBER, + WM_PLAYCHANNEL, + WM_TRAYICON, + WM_SHOWGUI, + WM_SHOWMENU, + WM_PROCURL + +}; + + +#endif \ No newline at end of file diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/resource.h b/PeerCast.root/PeerCast/ui/win32/Simple_vp/resource.h new file mode 100644 index 0000000..a9a2b6d --- /dev/null +++ b/PeerCast.root/PeerCast/ui/win32/Simple_vp/resource.h @@ -0,0 +1,110 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Simple.rc +// +#define IDC_MYICON 2 +#define IDD_MAINWINDOW 101 +#define IDD_SIMPLE_DIALOG 102 +#define IDD_ABOUTBOX 103 +#define IDS_APP_TITLE 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDS_HELLO 106 +#define IDI_SIMPLE 107 +#define IDI_SMALL 108 +#define IDC_SIMPLE 109 +#define IDI_SMALL2 109 +#define IDR_MAINFRAME 128 +#define IDR_TRAYMENU 130 +#define IDR_VERMENU 133 +#define IDD_CHANINFO 136 +#define IDR_LTRAYMENU 137 +#define IDC_LIST1 1000 +#define IDC_BUTTON7 1001 +#define IDC_ABOUTVER 1002 +#define IDC_CHECK1 1003 +#define IDC_EDIT1 1004 +#define IDC_LIST2 1005 +#define IDC_EDIT_PLAYING 1005 +#define IDC_COMBO1 1006 +#define IDC_EDIT_MESSAGE 1006 +#define IDC_CHECK2 1007 +#define IDC_EDIT_NAME 1007 +#define IDC_BUTTON1 1008 +#define IDC_EDIT_DESC 1008 +#define IDC_DETAILS 1009 +#define IDC_MAXRELAYS 1009 +#define IDC_LIST3 1010 +#define IDC_PLAY 1010 +#define IDC_CONTACT 1011 +#define IDC_EDIT2 1012 +#define IDC_FORMAT 1013 +#define IDC_EDIT_GENRE 1014 +#define IDC_KEEP 1015 +#define IDC_EDIT_STATUS 1016 +#define IDC_GROUPBOX_RELAY 1016 +#define IDC_EDIT_LISTENERS 1017 +#define IDC_STATIC_CONNECTION 1017 +#define IDC_LIST4 1018 +#define IDC_EDIT_HOSTS 1018 +#define IDC_STATIC_LOG 1018 +#define IDC_BUTTON4 1019 +#define IDC_BUTTON5 1020 +#define IDC_BUTTON6 1021 +#define IDC_EDIT3 1025 +#define IDC_EDIT5 1027 +#define IDC_LOGDEBUG 1037 +#define IDC_LOGNETWORK 1038 +#define IDC_LOGERRORS 1039 +#define IDC_CHECK9 1041 +#define IDC_BUTTON8 1043 +#define IDC_BUTTON10 1046 +#define IDC_BUTTON11 1047 +#define IDC_LOGCHANNELS 1050 +#define IDC_BUTTON2 1056 +#define IDC_EDIT4 1058 +#define IDC_BUTTON3 1059 +#define IDC_EDIT9 1060 +#define IDC_CHECK11 1061 +#define IDC_BUTTON9 1062 +#define IDM_SETTINGS_GUI 32771 +#define ID_POPUP_ABOUT 32779 +#define ID_POPUP_EXIT_CONFIRM 32781 +#define ID_POPUP_EXIT_NO 32782 +#define ID_POPUP_SETTINGS 32785 +#define ID_POPUP_CONNECTIONS 32786 +#define ID_POPUP_SHOWGUI 32788 +#define ID_POPUP_ALLCHANNELS 32791 +#define ID_POPUP_FAVORITES_EDIT 32792 +#define ID_POPUP_ADVANCED_INFORMATION 32793 +#define ID_POPUP_ADVANCED_SAVESETTINGS 32794 +#define ID_POPUP_UPGRADE 32795 +#define ID_POPUP_HELP 32796 +#define ID_POPUP_ADVANCED_VIEWLOG 32797 +#define ID_POPUP_FAVORITES_PLAYALL 32798 +#define ID_POPUP_ADVANCED_ALLCHANNELS 32799 +#define ID_POPUP_ADVANCED_RELAYEDCHANNELS 32800 +#define ID_POPUP_ADVANCED_BROADCAST 32801 +#define ID_FIND_CHANNELS 32808 +#define ID_POPUP_SHOWMESSAGES_PEERCAST 32814 +#define ID_POPUP_SHOWMESSAGES_BROADCASTERS 32815 +#define ID_POPUP_SHOWMESSAGES_TRACKINFO 32816 +#define ID_POPUP_POPUPMESSAGES_UPGRADEALERTS 32817 +#define ID_POPUP_YELLOWPAGES 32818 +#define ID_POPUP_ADVANCED_SHOWGUI 32819 +#define ID_POPUP_YELLOWPAGES1 32820 +#define ID_POPUP_YELLOWPAGES2 32821 +#define ID_POPUP_SAVE_GUI_POS 32823 +#define ID_POPUP_KEEP_DOWNSTREAMS 32825 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 142 +#define _APS_NEXT_COMMAND_VALUE 32826 +#define _APS_NEXT_CONTROL_VALUE 1019 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/small.ico b/PeerCast.root/PeerCast/ui/win32/Simple_vp/small.ico new file mode 100644 index 0000000000000000000000000000000000000000..c7dee299bec9d38ea44c45432b48fd10214e226c GIT binary patch literal 318 zcmZvYF%H5o3`Kt>Br|qmX5@I;!bUd6UMbw95*I*XXpvCObJ}h=dH*|(6Gf3aM&I{} zxOCDf9HMfDP6t$~P5()em?~v8loX0;t!#Lka*qrcQ3{bPgh;8`zO*&5gd*>1DL6F1z|v;;aqRdUw9l6_GaIu9mVEp76a%Gaif|-c9RHB_Cmi1)Tr! J2Rz{|{Q%s#L@@vW literal 0 HcmV?d00001 diff --git a/PeerCast.root/PeerCast/ui/win32/Simple_vp/small1.ico b/PeerCast.root/PeerCast/ui/win32/Simple_vp/small1.ico new file mode 100644 index 0000000000000000000000000000000000000000..fa5a5dcd8818b15900cbcef9bed4d88269fcdb31 GIT binary patch literal 318 zcmZvYF%H5o3`Kt>Br|qmX5@I;!bUdK6O`O0+@um0Kw>EpYIttShLiWd<2X?isblng zFOO3v9o)eyN9eRerLyWjNfJ{jHA6`usg%M-U8idG3>aQ=k<5h%VYT1VT4Di5qAbQ> z7PQZK^&#Kb3mWqHG+LU=&Us9J)`qd&9j|nGgw40BrKp7`d@jBr|qmX5@I;!bUd6UMbw95*I*XXpvCObJ}h=dH*|(6Gf3aM&I{} zxOCDf9HMfDP6t$~P5()em?~v8loX0;t!#Lka*qrcQ3{bPgh;8`zO*&5gd*>1DL6F1z|v;;aqRdUw9l6_GaIu9mVEp76a%Gaif|-c9RHB_Cmi1)Tr! J2Rz{|{Q%s#L@@vW literal 0 HcmV?d00001 diff --git a/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj b/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj index aabe10d..8cbbb27 100644 --- a/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj +++ b/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj @@ -17,6 +17,9 @@ + @@ -218,6 +221,108 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + @@ -772,8 +996,7 @@ BrowseInformation="1" WarningLevel="3" SuppressStartupBanner="true" - Detect64BitPortabilityProblems="true" - DebugInformationFormat="3" + DebugInformationFormat="4" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -840,7 +1599,254 @@ RelativePath="chkMemoryLeak.cpp" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -173,6 +176,94 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + - - - - + + - - - - + + - - - - + + - - - - + + + + + - - - - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +#include +#include "stdafx.h" +#include "resource.h" +#include "gui.h" +#include "channel.h" +#include "servent.h" +#include "servmgr.h" +#include "win32/wsys.h" +#include "peercast.h" +#include "simple.h" +#include "version2.h" +#ifdef _DEBUG +#include "chkMemoryLeak.h" +#define DEBUG_NEW new(__FILE__, __LINE__) +#define new DEBUG_NEW +#endif + +#define MAX_LOADSTRING 100 + +#define PLAY_CMD 7000 +#define RELAY_CMD 8000 +#define INFO_CMD 9000 +#define URL_CMD 10000 + +#define MAX_CHANNELS 999 + +extern "C" +{ + void loadIcons(HINSTANCE hInstance, HWND hWnd); +}; + +UINT g_iTaskbarCreated = ~0; // for PCRaw (tray icon) + +// PeerCast globals + +static int currNotify=0; +String iniFileName; +HWND guiWnd; +HWND mainWnd; +static HMENU trayMenu = NULL,ltrayMenu = NULL; // for PCRaw (tray icon) +bool showGUI=true; +bool allowMulti=false; +bool killMe=false; +bool allowTrayMenu=true; +static bool winDistinctionNT=false; +int seenNewVersionTime=0; +HICON icon1,icon2; +ChanInfo chanInfo; +bool chanInfoIsRelayed; +//GnuID lastPlayID; +String exePath; +FileStream fs; + +// --------------------------------- +Sys * APICALL MyPeercastInst::createSys() +{ + return new WSys(mainWnd); +} +// --------------------------------- +const char * APICALL MyPeercastApp ::getIniFilename() +{ + return iniFileName.cstr(); +} + +// --------------------------------- +const char *APICALL MyPeercastApp ::getClientTypeOS() +{ + return PCX_OS_WIN32; +} + +// --------------------------------- +const char * APICALL MyPeercastApp::getPath() +{ + return exePath.cstr(); +} + +// --------------------------------- JP-EX +void APICALL MyPeercastApp ::openLogFile() +{ + logFile.openWriteReplace("log.txt"); +} +// --------------------------------- JP-EX +void APICALL MyPeercastApp ::getDirectory() +{ + char path_buffer[256],drive[32],dir[128]; + GetModuleFileName(NULL,path_buffer,255); + _splitpath(path_buffer,drive,dir,NULL,NULL); + sprintf(servMgr->modulePath,"%s%s",drive,dir); +} +// --------------------------------- JP-EX +bool APICALL MyPeercastApp ::clearTemp() +{ + if (servMgr->clearPLS) + return true; + + return false; +} + + +class NOTIFYICONDATA2 +{ +public: + DWORD cbSize; // DWORD + HWND hWnd; // HWND + UINT uID; // UINT + UINT uFlags; // UINT + UINT uCallbackMessage; // UINT + HICON hIcon; // HICON + char szTip[128]; // char[128] + DWORD dwState; // DWORD + DWORD dwStateMask; // DWORD + char szInfo[256]; // char[256] + UINT uTimeoutOrVersion; // UINT + char szInfoTitle[64]; // char[64] + DWORD dwInfoFlags; // DWORD + //GUID guidItem; > IE 6 +}; + +NOTIFYICONDATA2 trayIcon; + + +// Global Variables: +HINSTANCE hInst; // current instance +TCHAR szTitle[MAX_LOADSTRING]; // The title bar text +TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text + +// Foward declarations of functions included in this code module: +ATOM MyRegisterClass(HINSTANCE hInstance); +BOOL InitInstance(HINSTANCE, int); +LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); +LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); +LRESULT CALLBACK ChanInfoProc(HWND, UINT, WPARAM, LPARAM); + +void setTrayIcon(int type, const char *,const char *,bool); +void flipNotifyPopup(int id, ServMgr::NOTIFY_TYPE nt); + + +HWND chWnd=NULL; + +// -------------------------------------------------- +void LOG2(const char *fmt,...) +{ + va_list ap; + va_start(ap, fmt); + char str[4096]; + vsprintf(str,fmt,ap); + OutputDebugString(str); + va_end(ap); +} + + + +// --------------------------------------- + +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ +#ifdef _DEBUG + // memory leak check + ::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); +#endif + + char tmpURL[8192]; + tmpURL[0]=0; + char *chanURL=NULL; + + //VERSION_EX = 0; + + iniFileName.set(".\\peercast.ini"); + + WIN32_FIND_DATA fd; //JP-EX + HANDLE hFind; //JP-EX + + OSVERSIONINFO osInfo; //JP-EX + osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); //JP-EX + GetVersionEx(&osInfo); + if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT) + winDistinctionNT = true; + else + winDistinctionNT = false; + + // off by default now + showGUI = false; + + if (strlen(lpCmdLine) > 0) + { + char *p; + if ((p = strstr(lpCmdLine,"-inifile"))!=NULL) + iniFileName.setFromString(p+8); + + if (strstr(lpCmdLine,"-zen")) + showGUI = false; + + if (strstr(lpCmdLine,"-multi")) + allowMulti = true; + + if (strstr(lpCmdLine,"-kill")) + killMe = true; + + if ((p = strstr(lpCmdLine,"-url"))!=NULL) + { + p+=4; + while (*p) + { + if (*p=='"') + { + p++; + break; + } + if (*p != ' ') + break; + p++; + } + if (*p) + strncpy(tmpURL,p,sizeof(tmpURL)-1); + } + } + + // get current path + { + exePath = iniFileName; + char *s = exePath.cstr(); + char *end = NULL; + while (*s) + { + if (*s++ == '\\') + end = s; + } + if (end) + *end = 0; + } + + + if (strnicmp(tmpURL,"peercast://",11)==0) + { + if (strnicmp(tmpURL+11,"pls/",4)==0) + chanURL = tmpURL+11+4; + else + chanURL = tmpURL+11; + showGUI = false; + } + + + MSG msg; + HACCEL hAccelTable; + + // Initialize global strings + //LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); + //LoadString(hInstance, IDC_APP_TITLE, szWindowClass, MAX_LOADSTRING); + + strcpy(szTitle,"PeerCast"); + strcpy(szWindowClass,"PeerCast"); + + if (!allowMulti) + { + HANDLE mutex = CreateMutex(NULL,TRUE,szWindowClass); + + if (GetLastError() == ERROR_ALREADY_EXISTS) + { + HWND oldWin = FindWindow(szWindowClass,NULL); + if (oldWin) + { + if (killMe) + { + SendMessage(oldWin,WM_DESTROY,0,0); + return 0; + } + + if (chanURL) + { + COPYDATASTRUCT copy; + copy.dwData = WM_PLAYCHANNEL; + copy.cbData = strlen(chanURL)+1; // plus null term + copy.lpData = chanURL; + SendMessage(oldWin,WM_COPYDATA,NULL,(LPARAM)©); + }else{ + if (showGUI) + SendMessage(oldWin,WM_SHOWGUI,0,0); + } + } + return 0; + } + } + + if (killMe) + return 0; + + MyRegisterClass(hInstance); + + // Perform application initialization: + if (!InitInstance (hInstance, nCmdShow)) + return FALSE; + + peercastInst = new MyPeercastInst(); + peercastApp = new MyPeercastApp(); + + peercastInst->init(); + + LOG_DEBUG("Set OS Type: %s",winDistinctionNT?"WinNT":"Win9x"); + + if (peercastApp->clearTemp()) //JP-EX + { + DeleteFile("play.pls"); + hFind = FindFirstFile("*.asx",&fd); + if (hFind != INVALID_HANDLE_VALUE) + { + do + { + DeleteFile((char *)&fd.cFileName); + } + while (FindNextFile(hFind,&fd)); + + FindClose(hFind); + } + } + + if (chanURL) + { + ChanInfo info; + servMgr->procConnectArgs(chanURL,info); + chanMgr->findAndPlayChannel(info,false); + } + + + hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SIMPLE); + + // setup menu notifes + int mask = peercastInst->getNotifyMask(); + if (mask & ServMgr::NT_PEERCAST) + CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_PEERCAST,MF_CHECKED|MF_BYCOMMAND); + if (mask & ServMgr::NT_BROADCASTERS) + CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_BROADCASTERS,MF_CHECKED|MF_BYCOMMAND); + if (mask & ServMgr::NT_TRACKINFO) + CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_TRACKINFO,MF_CHECKED|MF_BYCOMMAND); + + // Main message loop: + while (GetMessage(&msg, NULL, 0, 0)) + { + if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + } + + Shell_NotifyIcon(NIM_DELETE, (NOTIFYICONDATA*)&trayIcon); + + peercastInst->saveSettings(); + peercastInst->quit(); + + return msg.wParam; +} + + + +// +// FUNCTION: MyRegisterClass() +// +// PURPOSE: Registers the window class. +// +// COMMENTS: +// +// This function and its usage is only necessary if you want this code +// to be compatible with Win32 systems prior to the 'RegisterClassEx' +// function that was added to Windows 95. It is important to call this function +// so that the application will get 'well formed' small icons associated +// with it. +// +ATOM MyRegisterClass(HINSTANCE hInstance) +{ + WNDCLASSEX wcex; + + wcex.cbSize = sizeof(WNDCLASSEX); + + wcex.style = CS_HREDRAW | CS_VREDRAW; + wcex.lpfnWndProc = (WNDPROC)WndProc; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + wcex.hInstance = hInstance; + wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SIMPLE); + wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); + wcex.lpszMenuName = (LPCSTR)IDC_SIMPLE; + wcex.lpszClassName = szWindowClass; + wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); + + return RegisterClassEx(&wcex); + +} + +//----------------------------- +void loadIcons(HINSTANCE hInstance, HWND hWnd) +{ + icon1 = LoadIcon(hInstance, (LPCTSTR)IDI_SMALL); + icon2 = LoadIcon(hInstance, (LPCTSTR)IDI_SMALL2); + + trayIcon.cbSize = sizeof(trayIcon); + trayIcon.hWnd = hWnd; + trayIcon.uID = 100; + trayIcon.uFlags = NIF_MESSAGE + NIF_ICON + NIF_TIP; + trayIcon.uCallbackMessage = WM_TRAYICON; + trayIcon.hIcon = icon1; + strcpy(trayIcon.szTip, "PeerCast"); + + Shell_NotifyIcon(NIM_ADD, (NOTIFYICONDATA*)&trayIcon); + + //ShowWindow(hWnd, nCmdShow); + UpdateWindow(hWnd); + + if(!trayMenu) // for PCRaw (tray icon) + trayMenu = LoadMenu(hInstance,MAKEINTRESOURCE(IDR_TRAYMENU)); + if(!ltrayMenu) // for PCRaw (tray icon) + ltrayMenu = LoadMenu(hInstance,MAKEINTRESOURCE(IDR_LTRAYMENU)); + + +} + +//----------------------------- +// +// FUNCTION: InitInstance(HANDLE, int) +// +// PURPOSE: Saves instance handle and creates main window +// +// COMMENTS: +// +// In this function, we save the instance handle in a global variable and +// create and display the main program window. +// +BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +{ + HWND hWnd; + + hInst = hInstance; // Store instance handle in our global variable + + hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + + if (!hWnd) + { + return FALSE; + } + + mainWnd = hWnd; + + g_iTaskbarCreated = RegisterWindowMessage("TaskbarCreated"); // for PCRaw (tray icon) + + loadIcons(hInstance,hWnd); + + return TRUE; +} +//----------------------------- +//static String trackTitle; +//static String channelComment; + +//----------------------------- +void channelPopup(const char *title, const char *msg, bool isPopup = true) +{ + String both; + + if (*title == '\0') return; + both.append(msg); + both.append(" ("); + both.append(title); + both.append(")"); + + trayIcon.uFlags = NIF_ICON|NIF_TIP; + strncpy(trayIcon.szTip, both.cstr(),sizeof(trayIcon.szTip)-1); + trayIcon.szTip[sizeof(trayIcon.szTip)-1]=0; + + if (isPopup) trayIcon.uFlags |= 16; + trayIcon.uTimeoutOrVersion = 10000; + strncpy(trayIcon.szInfo,msg,sizeof(trayIcon.szInfo)-1); + strncpy(trayIcon.szInfoTitle,title,sizeof(trayIcon.szInfoTitle)-1); + + Shell_NotifyIcon(NIM_MODIFY, (NOTIFYICONDATA*)&trayIcon); +} +//----------------------------- +void clearChannelPopup() +{ + trayIcon.uFlags = NIF_ICON|16; + trayIcon.uTimeoutOrVersion = 10000; + strncpy(trayIcon.szInfo,"",sizeof(trayIcon.szInfo)-1); + strncpy(trayIcon.szInfoTitle,"",sizeof(trayIcon.szInfoTitle)-1); + Shell_NotifyIcon(NIM_MODIFY, (NOTIFYICONDATA*)&trayIcon); +} + +//----------------------------- +// PopupEntry +struct PopupEntry { + GnuID id; + String name; + String track; + String comment; + PopupEntry *next; +}; +static PopupEntry *PEList = NULL; +static WLock PELock; + +static void putPopupEntry(PopupEntry *pe) +{ + PELock.on(); + pe->next = PEList; + PEList = pe; + PELock.off(); +} + +static PopupEntry *getPopupEntry(GnuID id) +{ + PELock.on(); + PopupEntry *pe = PEList; + PopupEntry *prev = NULL; + while (pe) { + if (id.isSame(pe->id)) { + if (prev) prev->next = pe->next; + else PEList = pe->next; + PELock.off(); + pe->next = NULL; + return pe; + } + prev = pe; + pe = pe->next; + } + PELock.off(); + return NULL; +} + +static PopupEntry *getTopPopupEntry() +{ + PopupEntry *p = NULL; + PELock.on(); + if (PEList) { + p = PEList; + PEList = PEList->next; + } + PELock.off(); + return p; +} + +//----------------------------- +void APICALL MyPeercastApp::channelStart(ChanInfo *info) +{ + +// lastPlayID = info->id; +// +// if(!isIndexTxt(info)) // for PCRaw (popup) +// clearChannelPopup(); + + PopupEntry *pe = getPopupEntry(info->id); + if (!pe) { + pe = new PopupEntry; + pe->id = info->id; + } + if (!isIndexTxt(info)) + putPopupEntry(pe); + else + delete pe; +} +//----------------------------- +void APICALL MyPeercastApp::channelStop(ChanInfo *info) +{ +// if (info->id.isSame(lastPlayID)) +// { +// lastPlayID.clear(); +// +// if(!isIndexTxt(info)) // for PCRaw (popup) +// clearChannelPopup(); +// } + + PopupEntry *pe = getPopupEntry(info->id); + if (pe) delete pe; + + pe = getTopPopupEntry(); + if (!pe) { + clearChannelPopup(); + } else { + if (ServMgr::NT_TRACKINFO & peercastInst->getNotifyMask()) + { + String name,track; //JP-Patch + name = pe->name; //JP-Patch + track = pe->track; //JP-Patch + name.convertTo(String::T_SJIS); //JP-Patch + track.convertTo(String::T_SJIS); //JP-Patch + clearChannelPopup(); + // channelPopup(info->name.cstr(),trackTitle.cstr()); + channelPopup(name.cstr(),track.cstr(), false); //JP-Patch + } + putPopupEntry(pe); + } +} +//----------------------------- +void APICALL MyPeercastApp::channelUpdate(ChanInfo *info) +{ + if (info) + { + PopupEntry *pe = getPopupEntry(info->id); + if (!pe) return; + + String tmp; + tmp.append(info->track.artist); + tmp.append(" "); + tmp.append(info->track.title); + + + if (!tmp.isSame(pe->track)) + { + pe->name = info->name; + pe->track = tmp; + if (ServMgr::NT_TRACKINFO & peercastInst->getNotifyMask()) + { + //trackTitle=tmp; + String name,track; //JP-Patch + name = info->name; //JP-Patch + track = tmp; //JP-Patch + name.convertTo(String::T_SJIS); //JP-Patch + track.convertTo(String::T_SJIS); //JP-Patch + if(!isIndexTxt(info)) // for PCRaw (popup) + { + clearChannelPopup(); + // channelPopup(info->name.cstr(),trackTitle.cstr()); + channelPopup(name.cstr(),track.cstr()); //JP-Patch + } + } + } else if (!info->comment.isSame(pe->comment)) + { + pe->name = info->name; + pe->comment = info->comment; + if (ServMgr::NT_BROADCASTERS & peercastInst->getNotifyMask()) + { + //channelComment = info->comment; + String name,comment; //JP-Patch + name = info->name; //JP-Patch + comment = info->comment; //JP-Patch + name.convertTo(String::T_SJIS); //JP-Patch + comment.convertTo(String::T_SJIS); //JP-Patch + if(!isIndexTxt(info)) // for PCRaw (popup) + { + clearChannelPopup(); + // channelPopup(info->name.cstr(),channelComment.cstr()); + channelPopup(name.cstr(),comment.cstr()); + } + } + } + + if (!isIndexTxt(info)) + putPopupEntry(pe); + else + delete pe; + } +} +//----------------------------- +void APICALL MyPeercastApp::notifyMessage(ServMgr::NOTIFY_TYPE type, const char *msg) +{ + static bool shownUpgradeAlert=false; + + currNotify = type; + + trayIcon.uFlags = 0; + + if (!shownUpgradeAlert) + { + trayIcon.uFlags = NIF_ICON; + + if (type == ServMgr::NT_UPGRADE) + { + shownUpgradeAlert = true; + trayIcon.hIcon = icon2; + }else + { + trayIcon.hIcon = icon1; + } + }else + { + if (type == ServMgr::NT_UPGRADE) + return; + } + + const char *title=""; + + switch(type) + { + case ServMgr::NT_UPGRADE: + title = "Upgrade alert"; + break; + case ServMgr::NT_PEERCAST: + title = "Message from PeerCast:"; + break; + + } + + if (type & peercastInst->getNotifyMask()) + { + trayIcon.uFlags |= 16; + trayIcon.uTimeoutOrVersion = 10000; + strncpy(trayIcon.szInfo,msg,sizeof(trayIcon.szInfo)-1); + strncpy(trayIcon.szInfoTitle,title,sizeof(trayIcon.szInfoTitle)-1); + Shell_NotifyIcon(NIM_MODIFY, (NOTIFYICONDATA*)&trayIcon); + } +} +//----------------------------- + +// createGUI() +// +void createGUI(HWND hWnd) +{ + if (!guiWnd) + guiWnd = CreateDialog(hInst, (LPCTSTR)IDD_MAINWINDOW, hWnd, (DLGPROC)GUIProc); + ShowWindow(guiWnd,SW_SHOWNORMAL); +} + + +// +// addRelayedChannelsMenu(HMENU m) +// +// +void addRelayedChannelsMenu(HMENU cm) +{ + int cnt = GetMenuItemCount(cm); + for(int i=0; ichannel; + while(c) + { + if (c->isActive()) + { + char str[128],name[64]; + strncpy(name,c->info.name,32); + name[32]=0; + if (strlen(c->info.name) > 32) + strcat(name,"..."); + + + sprintf(str,"%s (%d kb/s %s)",name,c->info.bitrate,ChanInfo::getTypeStr(c->info.contentType)); + //InsertMenu(cm,0,MF_BYPOSITION,RELAY_CMD+i,str); + } + c=c->next; + } +} + +typedef int (*COMPARE_FUNC)(const void *,const void *); + +static int compareHitLists(ChanHitList **c2, ChanHitList **c1) +{ + return stricmp(c1[0]->info.name.cstr(),c2[0]->info.name.cstr()); +} + +static int compareChannels(Channel **c2, Channel **c1) +{ + return stricmp(c1[0]->info.name.cstr(),c2[0]->info.name.cstr()); +} + +// +// addAllChannelsMenu(HMENU m) +// +// +void addAllChannelsMenu(HMENU cm) +{ + int cnt = GetMenuItemCount(cm); +/* for(int i=0; irootHost2.isEmpty()){ + InsertMenu(yMenu,0,MF_BYPOSITION,ID_POPUP_YELLOWPAGES2,servMgr->rootHost2); + } + if (!servMgr->rootHost.isEmpty()){ + InsertMenu(yMenu,0,MF_BYPOSITION,ID_POPUP_YELLOWPAGES1,servMgr->rootHost); + } + + InsertMenu(cm,0,MF_BYPOSITION|MF_POPUP,(UINT)yMenu,"ƒCƒGƒ[ƒy[ƒW"); + InsertMenu(cm,0,MF_BYPOSITION|MF_SEPARATOR,NULL,NULL); + // add channels to menu + int numActive=0; + Channel *ch = chanMgr->channel; + while(ch) + { + char str[128],name[64]; + String sjis; //JP-Patch + sjis = ch->info.name; //JP-Patch + sjis.convertTo(String::T_SJIS); //JP-Patch + strncpy(name,sjis.cstr(),32); + //strncpy(name,ch->info.name,32); + name[32]=0; + //if (strlen(ch->info.name) > 32) + if (strlen(sjis.cstr()) > 32) //JP-Patch + strcat(name,"..."); + + sprintf(str,"%s (%d kb/s %s)",name,ch->info.bitrate,ChanInfo::getTypeStr(ch->info.contentType)); + + HMENU opMenu = CreatePopupMenu(); + InsertMenu(opMenu,0,MF_BYPOSITION,INFO_CMD+numActive,"Info"); + if (ch->info.url.isValidURL()) + InsertMenu(opMenu,0,MF_BYPOSITION,URL_CMD+numActive,"URL"); + InsertMenu(opMenu,0,MF_BYPOSITION,PLAY_CMD+numActive,"Play"); + + UINT fl = MF_BYPOSITION|MF_POPUP; + if (ch) + fl |= (ch->isPlaying()?MF_CHECKED:0); + + InsertMenu(cm,0,fl,(UINT)opMenu,str); + + numActive++; + + ch=ch->next; + } + + + //if (!numActive) + // InsertMenu(cm,0,MF_BYPOSITION,0,""); + + + + +} + + +// +// flipNotifyPopup(id, flag) +void flipNotifyPopup(int id, ServMgr::NOTIFY_TYPE nt) +{ + int mask = peercastInst->getNotifyMask(); + + mask ^= nt; + if (mask & nt) + CheckMenuItem(trayMenu,id,MF_CHECKED|MF_BYCOMMAND); + else + CheckMenuItem(trayMenu,id,MF_UNCHECKED|MF_BYCOMMAND); + + peercastInst->setNotifyMask(mask); + peercastInst->saveSettings(); +} + + +static void showHTML(const char *file) +{ + char url[256]; + sprintf(url,"%s/%s",servMgr->htmlPath,file); + +// sys->callLocalURL(url,servMgr->serverHost.port); + sys->callLocalURL(url, // for PCRaw (url) + (servMgr->allowServer1&Servent::ALLOW_HTML)?(servMgr->serverHost.port):(servMgr->serverHost.port+1)); +} + +static ChanInfo getChannelInfo(int index) +{ + Channel *c = chanMgr->findChannelByIndex(index); + if (c) + return c->info; + + ChanInfo info; + return info; +} + +// +// FUNCTION: WndProc(HWND, unsigned, WORD, LONG) +// +// PURPOSE: Processes messages for the main window. +// +// WM_COMMAND - process the application menu +// WM_PAINT - Paint the main window +// WM_DESTROY - post a quit message and return +// +// +LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + int wmId, wmEvent; + POINT point; + char buf[1024]; + + if(message == g_iTaskbarCreated) // for PCRaw (tray icon) + loadIcons(hInst, hWnd); + + switch (message) + { + case WM_SHOWGUI: + createGUI(hWnd); + break; + + + case WM_TRAYICON: + switch((UINT)lParam) + { + case WM_LBUTTONDOWN: + if (allowTrayMenu) + SendMessage(hWnd,WM_SHOWMENU,2,0); + SetForegroundWindow(hWnd); + break; + case WM_RBUTTONDOWN: + if (allowTrayMenu) + SendMessage(hWnd,WM_SHOWMENU,1,0); + SetForegroundWindow(hWnd); + break; + case WM_LBUTTONDBLCLK: + createGUI(hWnd); + break; + } + break; + + case WM_COPYDATA: + { + COPYDATASTRUCT *pc = (COPYDATASTRUCT *)lParam; + LOG_DEBUG("URL request: %s",pc->lpData); + if (pc->dwData == WM_PLAYCHANNEL) + { + ChanInfo info; + servMgr->procConnectArgs((char *)pc->lpData,info); + chanMgr->findAndPlayChannel(info,false); + } + //sys->callLocalURL((const char *)pc->lpData,servMgr->serverHost.port); + } + break; + case WM_GETPORTNUMBER: + { + int port; + port=servMgr->serverHost.port; + ReplyMessage(port); + } + break; + + case WM_SHOWMENU: + { + if (servMgr->saveGuiPos){ + CheckMenuItem(trayMenu, ID_POPUP_SAVE_GUI_POS, MF_CHECKED|MF_BYCOMMAND); + } else { + CheckMenuItem(trayMenu, ID_POPUP_SAVE_GUI_POS, MF_UNCHECKED|MF_BYCOMMAND); + } + + SetForegroundWindow(hWnd); + bool skipMenu=false; + + allowTrayMenu = false; + + // check for notifications + if (currNotify & ServMgr::NT_UPGRADE) + { + if (servMgr->downloadURL[0]) + { + if ((sys->getTime()-seenNewVersionTime) > (60*60)) // notify every hour + { + if (MessageBox(hWnd,"A newer version of PeerCast is available, press OK to upgrade.","PeerCast",MB_OKCANCEL|MB_APPLMODAL|MB_ICONEXCLAMATION) == IDOK) + sys->getURL(servMgr->downloadURL); + + seenNewVersionTime=sys->getTime(); + skipMenu=true; + } + } + } + + + if (!skipMenu) + { + RECT rcWnd; + HMENU menu; + UINT flg = 0; + + SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWnd, 0); + GetCursorPos(&point); + + if (point.x < rcWnd.left){ + point.x = rcWnd.left; + flg |= TPM_LEFTALIGN; + } + if (point.x > rcWnd.right){ + point.x = rcWnd.right; + flg |= TPM_RIGHTALIGN; + } + if (point.y < rcWnd.top){ + point.y = rcWnd.top; + flg |= TPM_TOPALIGN; + } + if (point.y > rcWnd.bottom){ + point.y = rcWnd.bottom; + flg |= TPM_BOTTOMALIGN; + } + if (flg == 0){ + flg = TPM_RIGHTALIGN; + } + + switch (wParam) + { + case 1: + menu = GetSubMenu(trayMenu,0); + addAllChannelsMenu(GetSubMenu(menu,0)); + addRelayedChannelsMenu(GetSubMenu(menu,1)); + break; + case 2: + menu = GetSubMenu(ltrayMenu,0); + addAllChannelsMenu(menu); + break; + } + if (!TrackPopupMenu(menu,flg,point.x,point.y,0,hWnd,NULL)) + { + LOG_ERROR("Can`t track popup menu: %d",GetLastError()); + } + PostMessage(hWnd,WM_NULL,0,0); + + } + allowTrayMenu = true; + } + break; + + case WM_CREATE: + if (showGUI) + createGUI(hWnd); + break; + + case WM_COMMAND: + wmId = LOWORD(wParam); + wmEvent = HIWORD(wParam); + + if ((wmId >= INFO_CMD) && (wmId < INFO_CMD+MAX_CHANNELS)) + { + int c = wmId - INFO_CMD; + chanInfo = getChannelInfo(c); + chanInfoIsRelayed = false; + if (winDistinctionNT) + DialogBox(hInst, (LPCTSTR)IDD_CHANINFO, hWnd, (DLGPROC)ChanInfoProc); + else + { + HWND WKDLG; //JP-Patch + WKDLG = CreateDialog(hInst, (LPCTSTR)IDD_CHANINFO, hWnd, (DLGPROC)ChanInfoProc); //JP-Patch + ShowWindow(WKDLG,SW_SHOWNORMAL); //JP-Patch + } + return 0; + } + if ((wmId >= URL_CMD) && (wmId < URL_CMD+MAX_CHANNELS)) + { + int c = wmId - URL_CMD; + chanInfo = getChannelInfo(c); + if (chanInfo.url.isValidURL()) + sys->getURL(chanInfo.url); + return 0; + } + if ((wmId >= PLAY_CMD) && (wmId < PLAY_CMD+MAX_CHANNELS)) + { + int c = wmId - PLAY_CMD; + chanInfo = getChannelInfo(c); + chanMgr->findAndPlayChannel(chanInfo,false); + return 0; + } + if ((wmId >= RELAY_CMD) && (wmId < RELAY_CMD+MAX_CHANNELS)) + { + int c = wmId - RELAY_CMD; + chanInfo = getChannelInfo(c); + chanMgr->findAndPlayChannel(chanInfo,true); + return 0; + } + + // Parse the menu selections: + switch (wmId) + { + case ID_POPUP_SHOWMESSAGES_PEERCAST: + flipNotifyPopup(ID_POPUP_SHOWMESSAGES_PEERCAST,ServMgr::NT_PEERCAST); + break; + case ID_POPUP_SHOWMESSAGES_BROADCASTERS: + flipNotifyPopup(ID_POPUP_SHOWMESSAGES_BROADCASTERS,ServMgr::NT_BROADCASTERS); + break; + case ID_POPUP_SHOWMESSAGES_TRACKINFO: + flipNotifyPopup(ID_POPUP_SHOWMESSAGES_TRACKINFO,ServMgr::NT_TRACKINFO); + break; + + case ID_POPUP_ABOUT: + case IDM_ABOUT: + DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); + break; + case ID_POPUP_SHOWGUI: + case IDM_SETTINGS_GUI: + case ID_POPUP_ADVANCED_SHOWGUI: + { + createGUI(hWnd); + break; + } + case ID_POPUP_YELLOWPAGES: + sys->getURL("http://yp.peercast.org/"); + break; + case ID_POPUP_YELLOWPAGES1: + sprintf(buf, "http://%s",servMgr->rootHost.cstr()); + sys->getURL(buf); + break; + case ID_POPUP_YELLOWPAGES2: + sprintf(buf, "http://%s",servMgr->rootHost2.cstr()); + sys->getURL(buf); + break; + + case ID_POPUP_ADVANCED_VIEWLOG: + showHTML("viewlog.html"); + break; + case ID_POPUP_ADVANCED_SAVESETTINGS: + servMgr->saveSettings(iniFileName.cstr()); + break; + case ID_POPUP_ADVANCED_INFORMATION: + showHTML("index.html"); + break; + case ID_FIND_CHANNELS: + case ID_POPUP_ADVANCED_ALLCHANNELS: + case ID_POPUP_UPGRADE: + sys->callLocalURL("admin?cmd=upgrade",servMgr->serverHost.port); + break; + case ID_POPUP_ADVANCED_RELAYEDCHANNELS: + case ID_POPUP_FAVORITES_EDIT: + showHTML("relays.html"); + break; + case ID_POPUP_ADVANCED_BROADCAST: + showHTML("broadcast.html"); + break; + case ID_POPUP_SETTINGS: + showHTML("settings.html"); + break; + case ID_POPUP_CONNECTIONS: + showHTML("connections.html"); + break; + case ID_POPUP_HELP: + sys->getURL("http://www.peercast.org/help.php"); + break; + + case ID_POPUP_SAVE_GUI_POS: + if (servMgr->saveGuiPos){ + servMgr->saveGuiPos = false; + CheckMenuItem(trayMenu, ID_POPUP_SAVE_GUI_POS, MF_UNCHECKED|MF_BYCOMMAND); + } else { + servMgr->saveGuiPos = true; + CheckMenuItem(trayMenu, ID_POPUP_SAVE_GUI_POS, MF_CHECKED|MF_BYCOMMAND); + } + peercastInst->saveSettings(); + break; + + case ID_POPUP_KEEP_DOWNSTREAMS: + if (servMgr->keepDownstreams){ + servMgr->keepDownstreams = false; + CheckMenuItem(trayMenu, ID_POPUP_KEEP_DOWNSTREAMS, MF_UNCHECKED|MF_BYCOMMAND); + } else { + servMgr->keepDownstreams = true; + CheckMenuItem(trayMenu, ID_POPUP_KEEP_DOWNSTREAMS, MF_CHECKED|MF_BYCOMMAND); + } + //peercastInst->saveSettings(); + break; + + case ID_POPUP_EXIT_CONFIRM: + case IDM_EXIT: + DestroyWindow(hWnd); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + break; + case WM_DESTROY: + PostQuitMessage(0); + break; + default: + return DefWindowProc(hWnd, message, wParam, lParam); + } + return 0; +} +// Mesage handler for about box. +LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + //SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENT); +// SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTJP); + //SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTVP); + + if (version_ex) + { + SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LPARAM)PCX_AGENTEX); // x64‘Ήž + } else + { + SendDlgItemMessage(hDlg,IDC_ABOUTVER,WM_SETTEXT,0,(LONG)PCX_AGENTVP); + } + + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) + { + case IDOK: + case IDCANCEL: + EndDialog(hDlg, LOWORD(wParam)); + return TRUE; + case IDC_BUTTON1: + sys->getURL("http://www.peercast.org"); + EndDialog(hDlg, LOWORD(wParam)); + return TRUE; + + } + break; + case WM_DESTROY: + break; + } + return FALSE; +} + +// Mesage handler for chaninfo box +LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case WM_INITDIALOG: + { + char str[1024]; + //strcpy(str,chanInfo.track.artist.cstr()); + strcpy(str,chanInfo.track.artist); //JP-Patch + strcat(str," - "); + //strcat(str,chanInfo.track.title.cstr()); + strcat(str,chanInfo.track.title); + String name,track,comment,desc,genre; //JP-Patch + name = chanInfo.name; //JP-Patch + track = str; //JP-Patch + comment = chanInfo.comment; //JP-Patch + desc = chanInfo.desc; //JP-Patc + genre = chanInfo.genre; //JP-Patch + name.convertTo(String::T_SJIS); //JP-Patc + track.convertTo(String::T_SJIS); //JP-Patch + comment.convertTo(String::T_SJIS); //JP-Patch + desc.convertTo(String::T_SJIS); //JP-Patch + genre.convertTo(String::T_SJIS); //JP-Patch + + //SendDlgItemMessage(hDlg,IDC_EDIT_NAME,WM_SETTEXT,0,(LONG)chanInfo.name.cstr()); + SendDlgItemMessage(hDlg,IDC_EDIT_NAME,WM_SETTEXT,0,(LONG)name.cstr()); //JP-Patch + //SendDlgItemMessage(hDlg,IDC_EDIT_PLAYING,WM_SETTEXT,0,(LONG)str); + SendDlgItemMessage(hDlg,IDC_EDIT_PLAYING,WM_SETTEXT,0,(LONG)track.cstr()); //JP-Patch + //SendDlgItemMessage(hDlg,IDC_EDIT_MESSAGE,WM_SETTEXT,0,(LONG)chanInfo.comment.cstr()); + SendDlgItemMessage(hDlg,IDC_EDIT_MESSAGE,WM_SETTEXT,0,(LONG)comment.cstr()); //JP-Patch + //SendDlgItemMessage(hDlg,IDC_EDIT_DESC,WM_SETTEXT,0,(LONG)chanInfo.desc.cstr()); + SendDlgItemMessage(hDlg,IDC_EDIT_DESC,WM_SETTEXT,0,(LONG)desc.cstr()); //JP-Patch + //SendDlgItemMessage(hDlg,IDC_EDIT_GENRE,WM_SETTEXT,0,(LONG)chanInfo.genre.cstr()); + SendDlgItemMessage(hDlg,IDC_EDIT_GENRE,WM_SETTEXT,0,(LONG)genre.cstr()); //JP-Patch + + sprintf(str,"%d kb/s %s",chanInfo.bitrate,ChanInfo::getTypeStr(chanInfo.contentType)); + SendDlgItemMessage(hDlg,IDC_FORMAT,WM_SETTEXT,0,(LONG)str); + + + if (!chanInfo.url.isValidURL()) + EnableWindow(GetDlgItem(hDlg,IDC_CONTACT),false); + + Channel *ch = chanMgr->findChannelByID(chanInfo.id); + if (ch) + { + SendDlgItemMessage(hDlg,IDC_EDIT_STATUS,WM_SETTEXT,0,(LONG)ch->getStatusStr()); + SendDlgItemMessage(hDlg, IDC_KEEP,BM_SETCHECK, ch->stayConnected, 0); + }else + { + SendDlgItemMessage(hDlg,IDC_EDIT_STATUS,WM_SETTEXT,0,(LONG)"OK"); + EnableWindow(GetDlgItem(hDlg,IDC_KEEP),false); + } + + + + POINT point; + RECT rect,drect; + HWND hDsk = GetDesktopWindow(); + GetWindowRect(hDsk,&drect); + GetWindowRect(hDlg,&rect); + GetCursorPos(&point); + + POINT pos,size; + size.x = rect.right-rect.left; + size.y = rect.bottom-rect.top; + + if (point.x-drect.left < size.x) + pos.x = point.x; + else + pos.x = point.x-size.x; + + if (point.y-drect.top < size.y) + pos.y = point.y; + else + pos.y = point.y-size.y; + + SetWindowPos(hDlg,HWND_TOPMOST,pos.x,pos.y,size.x,size.y,0); + chWnd = hDlg; + } + return TRUE; + + case WM_COMMAND: + { + char str[1024],idstr[64]; + chanInfo.id.toStr(idstr); + + switch (LOWORD(wParam)) + { + case IDC_CONTACT: + { + sys->getURL(chanInfo.url); + return TRUE; + } + case IDC_DETAILS: + { + sprintf(str,"admin?page=chaninfo&id=%s&relay=%d",idstr,chanInfoIsRelayed); + sys->callLocalURL(str,servMgr->serverHost.port); + return TRUE; + } + case IDC_KEEP: + { + Channel *ch = chanMgr->findChannelByID(chanInfo.id); + if (ch) + ch->stayConnected = SendDlgItemMessage(hDlg, IDC_KEEP,BM_GETCHECK, 0, 0) == BST_CHECKED;; + return TRUE; + } + + + case IDC_PLAY: + { + chanMgr->findAndPlayChannel(chanInfo,false); + return TRUE; + } + + } + } + break; + + case WM_CLOSE: + if (winDistinctionNT) + EndDialog(hDlg, 0); + else + DestroyWindow(hDlg); //JP-Patch + break; + + case WM_ACTIVATE: + if (LOWORD(wParam) == WA_INACTIVE) + if (winDistinctionNT) + EndDialog(hDlg, 0); + else + DestroyWindow(hDlg); //JP-Patch + break; + case WM_DESTROY: + chWnd = NULL; + break; + + + } + return FALSE; +} diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.h b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.h new file mode 100644 index 0000000..ad59a96 --- /dev/null +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.h @@ -0,0 +1,65 @@ + +// ------------------------------------------------ +// File : simple.h +// Date: 4-apr-2002 +// Author: giles +// +// (c) 2002 peercast.org +// ------------------------------------------------ +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// ------------------------------------------------ + +#if !defined(AFX_SIMPLE_H__F2E64B1B_62DE_473C_A6B6_E7826D41E0FA__INCLUDED_) +#define AFX_SIMPLE_H__F2E64B1B_62DE_473C_A6B6_E7826D41E0FA__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "resource.h" + +// --------------------------------- +class MyPeercastInst : public PeercastInstance +{ +public: + virtual Sys * APICALL createSys(); +}; +// --------------------------------- +class MyPeercastApp : public PeercastApplication +{ +public: + MyPeercastApp () + { + //logFile.openWriteReplace("log.txt"); + } + + virtual const char * APICALL getPath(); + + virtual const char * APICALL getIniFilename(); + virtual const char *APICALL getClientTypeOS(); + virtual void APICALL openLogFile(); //JP-EX + virtual void APICALL getDirectory(); //JP-EX + virtual bool APICALL clearTemp(); //JP-EX + virtual void APICALL printLog(LogBuffer::TYPE t, const char *str); + + virtual void APICALL updateSettings(); + virtual void APICALL notifyMessage(ServMgr::NOTIFY_TYPE, const char *); + + virtual void APICALL channelStart(ChanInfo *); + virtual void APICALL channelStop(ChanInfo *); + virtual void APICALL channelUpdate(ChanInfo *); + + FileStream logFile; + +}; + + +#endif // !defined(AFX_SIMPLE_H__F2E64B1B_62DE_473C_A6B6_E7826D41E0FA__INCLUDED_) diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.ico b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.ico new file mode 100644 index 0000000000000000000000000000000000000000..51811ea4819dbdb4726fbb0f5f4347425ca2a566 GIT binary patch literal 1078 zcma)6v2KGv41F|}%+&G+WvcQQ?I*Eaww%-}Ol7KSw$g}-y zpYJeMfDBJ4%L2B3o`84iqDXw30WTY1OJ7NR5*eN;fyms)D>BGPj7d?_BqG|jWkCH0 zRkH{_<}%?+!emUULbY@(xj+`-HLq6jb-61~$6mL)KZLYhs1f+s3L)(310e1N^180| z#`A{nqD-CQPKVu+_r_sW;qksUE-UU=_xNG3xZNS;hl#U9?#G={oYEa3Vs4XEtia=D z&N_|SK?Yxv8^3E~RWG^N#qQ#6U$c#M?IvU=1!iUXyL6pQi=Pm8WD^8c- zd^5phG#AA`=6vo(mAW=lNrqI^6am5swC?jGyKZz~tl}5!Pc|<}Lw4Fn+bd0Yi1o;Ujh literal 0 HcmV?d00001 diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.rc b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.rc new file mode 100644 index 0000000..78d8067 --- /dev/null +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple.rc @@ -0,0 +1,364 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +// Generated Help ID header file +#define APSTUDIO_HIDDEN_SYMBOLS +#include "resource.hm" +#undef APSTUDIO_HIDDEN_SYMBOLS + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +#include "resource.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Æ­°Ä×Ù (¼½ÃѕW€) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD) +#ifdef _WIN32 +LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT +#pragma code_page(932) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_TRAYMENU MENU DISCARDABLE +BEGIN + POPUP "popup" + BEGIN + MENUITEM "î•ñ", ID_POPUP_ABOUT + MENUITEM "ƒwƒ‹ƒv", ID_POPUP_HELP + MENUITEM SEPARATOR + POPUP "ƒ|ƒbƒvƒAƒbƒvƒƒbƒZ[ƒW" + BEGIN + MENUITEM "PeerCast", ID_POPUP_SHOWMESSAGES_PEERCAST + + MENUITEM "”zMŽÒ", ID_POPUP_SHOWMESSAGES_BROADCASTERS + + MENUITEM "ƒgƒ‰ƒbƒNî•ñ", ID_POPUP_SHOWMESSAGES_TRACKINFO + + MENUITEM "ƒAƒbƒvƒf[ƒgî•ñ", ID_POPUP_POPUPMESSAGES_UPGRADEALERTS + , CHECKED, GRAYED + END + POPUP "‚“x" + BEGIN + MENUITEM "î•ñ", ID_POPUP_ADVANCED_INFORMATION + + MENUITEM "ƒŠƒŒ[ƒ`ƒƒƒ“ƒlƒ‹", ID_POPUP_ADVANCED_RELAYEDCHANNELS + + MENUITEM "”zM", ID_POPUP_ADVANCED_BROADCAST + + MENUITEM "ƒRƒlƒNƒVƒ‡ƒ“", ID_POPUP_CONNECTIONS + MENUITEM "ƒƒO", ID_POPUP_ADVANCED_VIEWLOG + + MENUITEM "Ý’è", ID_POPUP_SETTINGS + MENUITEM "GUI‚ðŠJ‚­", ID_POPUP_ADVANCED_SHOWGUI + + END + POPUP "’ljÁÝ’è" + BEGIN + MENUITEM "I—¹ŽžA•\Ž¦ˆÊ’u‚ð•Û‘¶", ID_POPUP_SAVE_GUI_POS + , CHECKED + MENUITEM "ÄÚ‘±Žž‰º—¬ˆÛŽ", ID_POPUP_KEEP_DOWNSTREAMS + , CHECKED + END + MENUITEM SEPARATOR + POPUP "I—¹" + BEGIN + MENUITEM "‚Í‚¢", ID_POPUP_EXIT_CONFIRM + MENUITEM "‚¢‚¢‚¦", ID_POPUP_EXIT_NO + END + END +END + +IDR_LTRAYMENU MENU DISCARDABLE +BEGIN + POPUP "popup" + BEGIN + MENUITEM SEPARATOR + MENUITEM "ƒCƒGƒ[ƒy[ƒW", ID_POPUP_YELLOWPAGES + POPUP "ƒCƒGƒ[ƒy[ƒW" + BEGIN + MENUITEM "AAA", ID_POPUP_YELLOWPAGES1 + MENUITEM "BBB", ID_POPUP_YELLOWPAGES2 + END + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_MAINWINDOW DIALOGEX 0, 0, 298, 341 +STYLE DS_CENTER | WS_MINIMIZEBOX | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME +EXSTYLE WS_EX_APPWINDOW +CAPTION "PeerCast" +FONT 9, "MS UI Gothic", 0, 0, 0x1 +BEGIN + LISTBOX IDC_LIST1,3,291,291,43,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | + WS_TABSTOP + CONTROL "—LŒø",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,9,29,60,20,WS_EX_TRANSPARENT + EDITTEXT IDC_EDIT1,127,18,47,12,ES_AUTOHSCROLL + RTEXT "ƒ|[ƒg :",IDC_STATIC,107,20,18,8 + LISTBOX IDC_LIST2,3,206,291,71,LBS_OWNERDRAWFIXED | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + LTEXT "ƒƒO",IDC_STATIC_LOG,3,282,13,8 + LTEXT "ƒRƒlƒNƒVƒ‡ƒ“",IDC_STATIC_CONNECTION,3,184,40,8 + GROUPBOX "",IDC_STATIC,3,4,291,49 + PUSHBUTTON "ƒNƒŠƒA",IDC_BUTTON1,35,279,25,11 + LISTBOX IDC_LIST3,3,81,291,67,LBS_OWNERDRAWFIXED | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + PUSHBUTTON "Ø’f",IDC_BUTTON5,67,65,43,13 + GROUPBOX "ƒŠƒŒ[",IDC_GROUPBOX_RELAY,3,54,291,96 + EDITTEXT IDC_EDIT3,127,34,47,12,ES_PASSWORD | ES_AUTOHSCROLL + RTEXT "ƒpƒXƒ[ƒh :",IDC_STATIC,89,36,36,8 + CONTROL "ƒfƒoƒbƒO",IDC_LOGDEBUG,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,127,279,32,11 + CONTROL "ƒlƒbƒgƒ[ƒN",IDC_LOGNETWORK,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,185,279,35,11 + CONTROL "ƒGƒ‰[",IDC_LOGERRORS,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,159,279,25,11 + CONTROL "’âŽ~",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,60,279,30,11 + PUSHBUTTON "Ä¶",IDC_BUTTON8,10,65,22,13 + CONTROL "ƒ`ƒƒƒ“ƒlƒ‹",IDC_LOGCHANNELS,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,221,279,35,11 + PUSHBUTTON "ÄÚ‘±",IDC_BUTTON3,41,65,24,13 + EDITTEXT IDC_EDIT9,33,159,261,14,ES_AUTOHSCROLL + CONTROL "DJ",IDC_CHECK11,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,5,160,23,12 + RTEXT "Å‘僊ƒŒ[” :",IDC_STATIC,194,36,40,8 + EDITTEXT IDC_MAXRELAYS,241,33,40,14,ES_AUTOHSCROLL | ES_NUMBER + PUSHBUTTON "ƒL[ƒv",IDC_BUTTON9,112,65,24,13 + PUSHBUTTON "Ø’f",IDC_BUTTON6,47,179,43,13 + LTEXT "Peercast-VP",IDC_STATIC,21,14,39,8 +END + +IDD_CHANINFO DIALOGEX 0, 0, 184, 207 +STYLE DS_SETFOREGROUND | WS_POPUP | WS_CAPTION | WS_SYSMENU +EXSTYLE WS_EX_TOOLWINDOW +CAPTION "Channel Information" +FONT 9, "MS UI Gothic", 400, 0, 0x80 +BEGIN + LTEXT "–¼‘O:",IDC_STATIC,7,8,24,9 + EDITTEXT IDC_EDIT_NAME,7,18,170,21,ES_MULTILINE | ES_READONLY | + NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE + LTEXT "“à—e:",IDC_STATIC,7,79,93,9 + EDITTEXT IDC_EDIT_PLAYING,8,90,170,21,ES_MULTILINE | ES_READONLY | + NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE + LTEXT "DJ ƒƒbƒZ[ƒW:",IDC_STATIC,7,117,41,9 + EDITTEXT IDC_EDIT_MESSAGE,8,128,170,21,ES_MULTILINE | ES_READONLY | + NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE + PUSHBUTTON "URL",IDC_CONTACT,7,185,34,15,0,0,HIDC_CONTACT + LTEXT "Ú×:",IDC_STATIC,7,43,67,8 + EDITTEXT IDC_EDIT_DESC,8,53,170,21,ES_MULTILINE | ES_READONLY | + NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE + RTEXT "Œ`Ž®",IDC_FORMAT,69,80,107,8 + LTEXT "ƒWƒƒƒ“ƒ‹:",IDC_STATIC,63,5,22,8 + EDITTEXT IDC_EDIT_GENRE,87,3,90,12,ES_AUTOHSCROLL | ES_READONLY | + NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE + CONTROL "ƒL[ƒv",IDC_KEEP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 144,188,33,10 + LTEXT "ƒXƒe[ƒ^ƒX:",IDC_STATIC,7,153,41,9 + EDITTEXT IDC_EDIT_STATUS,8,163,82,12,ES_READONLY | NOT WS_BORDER | + NOT WS_TABSTOP,WS_EX_STATICEDGE + PUSHBUTTON "Ä¶",IDC_PLAY,56,185,34,15 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO MOVEABLE PURE +BEGIN + IDD_MAINWINDOW, DIALOG + BEGIN + LEFTMARGIN, 3 + RIGHTMARGIN, 294 + TOPMARGIN, 3 + BOTTOMMARGIN, 336 + END + + IDD_CHANINFO, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 177 + TOPMARGIN, 7 + BOTTOMMARGIN, 200 + END +END +#endif // APSTUDIO_INVOKED + +#endif // Æ­°Ä×Ù (¼½ÃѕW€) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// ‰pŒê (±Òض) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDC_SIMPLE MENU DISCARDABLE +BEGIN + POPUP "&File" + BEGIN + MENUITEM "E&xit", IDM_EXIT + END + POPUP "&Help" + BEGIN + MENUITEM "&About ...", IDM_ABOUT + END + POPUP "Settings" + BEGIN + MENUITEM "GUI", IDM_SETTINGS_GUI + END +END + +IDR_VERMENU MENU DISCARDABLE +BEGIN + POPUP "popup" + BEGIN + MENUITEM "Please upgrade PeerCast. Click here to download.", + ID_POPUP_UPGRADE + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ABOUTBOX DIALOG DISCARDABLE 22, 17, 163, 59 +STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_CENTER | WS_CAPTION | WS_SYSMENU +CAPTION "About" +FONT 8, "System" +BEGIN + ICON IDI_SIMPLE,IDC_MYICON,14,9,20,20 + LTEXT "PeerCast",IDC_ABOUTVER,43,9,103,8,SS_NOPREFIX + LTEXT "Copyright (C) 2005-2007",IDC_STATIC,43,22,119,8 + PUSHBUTTON "OK",IDOK,134,40,24,12,WS_GROUP + PUSHBUTTON "www.peercast.org",IDC_BUTTON1,42,40,66,12 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO MOVEABLE PURE +BEGIN + IDD_ABOUTBOX, DIALOG + BEGIN + BOTTOMMARGIN, 58 + END +END +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_SIMPLE ICON DISCARDABLE "Simple.ICO" +IDI_SMALL2 ICON DISCARDABLE "small1.ico" +IDI_SMALL ICON DISCARDABLE "small3.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDC_SIMPLE ACCELERATORS MOVEABLE PURE +BEGIN + "?", IDM_ABOUT, ASCII, ALT + "/", IDM_ABOUT, ASCII, ALT +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +2 TEXTINCLUDE MOVEABLE PURE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""resource.h""\r\n" + "\0" +END + +3 TEXTINCLUDE MOVEABLE PURE +BEGIN + "\r\n" + "\0" +END + +1 TEXTINCLUDE MOVEABLE PURE +BEGIN + "resource.h\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_APP_TITLE "PeerCast" +END + +#endif // ‰pŒê (±Òض) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj new file mode 100644 index 0000000..0b377e1 --- /dev/null +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj @@ -0,0 +1,767 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj.vspscc b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj.vspscc new file mode 100644 index 0000000..72b221b --- /dev/null +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/Simple_vp.vcproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "relative:ui\\win32\\Simple_vp" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROJECT" +} diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.cpp b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.cpp new file mode 100644 index 0000000..fe41f64 --- /dev/null +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.cpp @@ -0,0 +1,9 @@ +// stdafx.cpp : source file that includes just the standard includes +// Simple.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file + diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.h b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.h new file mode 100644 index 0000000..1e47eff --- /dev/null +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/StdAfx.h @@ -0,0 +1,32 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) +#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + + +// Windows Header Files: +#include + +// C RunTime Header Files +#include +#include +#include +#include + +// Local Header Files + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.cpp b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.cpp new file mode 100644 index 0000000..3cc4408 --- /dev/null +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.cpp @@ -0,0 +1,21 @@ +#ifdef _DEBUG +#include "stdafx.h" +#include "chkMemoryLeak.h" + +#ifdef __AFXWIN_H__ // MFC‚̃EƒBƒ“ƒhƒE‚ðŽg‚¤ê‡‚ÉŒÀ’肵‚Ä‚¢‚Ü‚· +#else + #if defined(_DEBUG) + #define __chkMemoryLeak_H__ + void* operator new(size_t size, const char *filename, int linenumber) + { + return _malloc_dbg(size, _NORMAL_BLOCK, filename, linenumber); + } + void operator delete(void * _P, const char *filename, int linenumber) + { + _free_dbg(_P, _NORMAL_BLOCK); + return; + } + + #endif +#endif +#endif diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.h b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.h new file mode 100644 index 0000000..cf72ed3 --- /dev/null +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/chkMemoryLeak.h @@ -0,0 +1,24 @@ +#ifndef _CHKMEMORYLEAK_H +#define _CHKMEMORYLEAK_H + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifdef _DEBUG + #define _CRTDBG_MAP_ALLOC + + #define SET_CRT_DEBUG_FIELD(a) _CrtSetDbgFlag((a) | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)) + #define CLEAR_CRT_DEBUG_FIELD(a) _CrtSetDbgFlag(~(a) & _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)) + + void* operator new(size_t size, const char *filename, int linenumber); + void operator delete(void * _P, const char *filename, int linenumber); +#else + #define SET_CRT_DEBUG_FIELD(a) ((void) 0) + #define CLEAR_CRT_DEBUG_FIELD(a) ((void) 0) +#endif + +#include +#include + +#endif diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.cpp b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.cpp new file mode 100644 index 0000000..5d933b2 --- /dev/null +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.cpp @@ -0,0 +1,1715 @@ +// ------------------------------------------------ +// File : gui.cpp +// Date: 4-apr-2002 +// Author: giles +// Desc: +// Windows front end GUI, PeerCast core is not dependant on any of this. +// Its very messy at the moment, but then again Windows UI always is. +// I really don`t like programming win32 UI.. I want my borland back.. +// +// (c) 2002 peercast.org +// ------------------------------------------------ +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// ------------------------------------------------ + +#include +#include "stdio.h" +#include "string.h" +#include "stdarg.h" +#include "resource.h" +#include "socket.h" +#include "win32/wsys.h" +#include "servent.h" +#include "win32/wsocket.h" +#include "inifile.h" +#include "gui.h" +#include "servmgr.h" +#include "peercast.h" +#include "simple.h" +#ifdef _DEBUG +#include "chkMemoryLeak.h" +#define DEBUG_NEW new(__FILE__, __LINE__) +#define new DEBUG_NEW +#endif + +ThreadInfo guiThread; +bool shownChannels=false; + +class ListData{ +public: + int channel_id; + char name[21]; + int bitRate; + int status; + const char *statusStr; + int totalListeners; + int totalRelays; + int localListeners; + int localRelays; + bool stayConnected; + ChanHit chDisp; + bool bTracker; + + bool flg; + ListData *next; +}; + +class ServentData{ +public: + int servent_id; + unsigned int tnum; + int type; + int status; + String agent; + Host h; + unsigned int syncpos; + char *typeStr; + char *statusStr; + bool infoFlg; + bool relay; + bool firewalled; + unsigned int numRelays; + unsigned int totalRelays; + unsigned int totalListeners; + int vp_ver; + char ver_ex_prefix[2]; + int ver_ex_number; + + bool flg; + ServentData *next; + + unsigned int lastSkipTime; + unsigned int lastSkipCount; +}; + +ListData *list_top = NULL; +ServentData *servent_top = NULL; + +// -------------------------------------------------- +// for PCRaw (connection list) start +WNDPROC wndOldListBox = NULL, wndOldConnListBox = NULL; +bool sleep_skip = false; + +LRESULT CALLBACK ListBoxProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch(message) + { + case WM_LBUTTONDOWN: + { + int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam); + if(index >= 0x10000) + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L); + } + sleep_skip = true; + } + break; + + case WM_LBUTTONDBLCLK: + { + int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam); + if(index < 0x10000) + { + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON8, NULL); + } + } + break; + + case WM_RBUTTONDOWN: + { + POINT pos; + MENUITEMINFO info, separator; + HMENU hMenu; + DWORD dwID; + + int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam); + if(index < 0x10000) + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)index, 1L); + } + else + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L); + sleep_skip = true; + break; + } + + hMenu = CreatePopupMenu(); + + memset(&separator, 0, sizeof(MENUITEMINFO)); + separator.cbSize = sizeof(MENUITEMINFO); + separator.fMask = MIIM_ID | MIIM_TYPE; + separator.fType = MFT_SEPARATOR; + separator.wID = 8000; + + memset(&info, 0, sizeof(MENUITEMINFO)); + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_ID | MIIM_TYPE; + info.fType = MFT_STRING; + + info.wID = 1001; + info.dwTypeData = "Ø’f(&X)"; + InsertMenuItem(hMenu, -1, true, &info); + + InsertMenuItem(hMenu, -1, true, &separator); + + info.wID = 1000; + info.dwTypeData = "Ä¶(&P)"; + InsertMenuItem(hMenu, -1, true, &info); + + InsertMenuItem(hMenu, -1, true, &separator); + + info.wID = 1002; + info.dwTypeData = "ÄÚ‘±(&R)"; + InsertMenuItem(hMenu, -1, true, &info); + + info.wID = 1003; + info.dwTypeData = "ƒL[ƒv(&K)"; + InsertMenuItem(hMenu, -1, true, &info); + + InsertMenuItem(hMenu, -1, true, &separator); + + info.wID = 2000; + info.dwTypeData = "‘I‘ð‰ðœ(&D)"; + InsertMenuItem(hMenu, -1, true, &info); + + GetCursorPos(&pos); + dwID = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pos.x, pos.y, 0, hwnd, NULL); + + DestroyMenu(hMenu); + + switch(dwID) + { + case 1000: + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON8, NULL); + break; + + case 1001: + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON5, NULL); + break; + + case 1002: + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON3, NULL); + break; + + case 1003: + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON9, NULL); + break; + + case 2000: + SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L); + sleep_skip = true; + break; + } + + } + break; + + case WM_KEYDOWN: + sleep_skip = true; + break; + } + + return CallWindowProc(wndOldListBox, hwnd, message, wParam, lParam); +} + +LRESULT CALLBACK ConnListBoxProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) +{ + switch(message) + { + case WM_LBUTTONDOWN: + { + int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam); + if(index >= 0x10000) + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L); + } + } + break; + + case WM_RBUTTONDOWN: + { + POINT pos; + MENUITEMINFO info; + HMENU hMenu; + DWORD dwID; + + int index = SendMessage(hwnd, LB_ITEMFROMPOINT, 0, lParam); + if(index < 0x10000) + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)index, 1L); + } + else + { + SendMessage(hwnd, LB_SETCURSEL, (DWORD)-1, 0L); + break; + } + + hMenu = CreatePopupMenu(); + + memset(&info, 0, sizeof(MENUITEMINFO)); + info.cbSize = sizeof(MENUITEMINFO); + info.fMask = MIIM_ID | MIIM_TYPE; + info.fType = MFT_STRING; + + info.wID = 1001; + info.dwTypeData = "Ø’f(&X)"; + InsertMenuItem(hMenu, -1, true, &info); + + GetCursorPos(&pos); + dwID = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RETURNCMD, pos.x, pos.y, 0, hwnd, NULL); + + DestroyMenu(hMenu); + + switch(dwID) + { + case 1001: + SendMessage(guiWnd, WM_COMMAND, IDC_BUTTON6, NULL); + break; + } + + } + break; + } + + return CallWindowProc(wndOldConnListBox, hwnd, message, wParam, lParam); +} +// for PCRaw (connection list) end +// -------------------------------------------------- +int logID,statusID,hitID,chanID; + +// -------------------------------------------------- +bool getButtonState(int id) +{ + return SendDlgItemMessage(guiWnd, id,BM_GETCHECK, 0, 0) == BST_CHECKED; +} + +// -------------------------------------------------- +void enableControl(int id, bool on) +{ + EnableWindow(GetDlgItem(guiWnd,id),on); +} + +// -------------------------------------------------- +void enableEdit(int id, bool on) +{ + SendDlgItemMessage(guiWnd, id,WM_ENABLE, on, 0); + SendDlgItemMessage(guiWnd, id,EM_SETREADONLY, !on, 0); +} +// -------------------------------------------------- +int getEditInt(int id) +{ + char str[128]; + SendDlgItemMessage(guiWnd, id,WM_GETTEXT, 128, (LONG)str); + return atoi(str); +} +// -------------------------------------------------- +char * getEditStr(int id) +{ + static char str[128]; + SendDlgItemMessage(guiWnd, id,WM_GETTEXT, 128, (LONG)str); + return str; +} +// -------------------------------------------------- +void setEditStr(int id, char *str) +{ + SendDlgItemMessage(guiWnd, id,WM_SETTEXT, 0, (LONG)str); +} +// -------------------------------------------------- +void setEditInt(int id, int v) +{ + char str[128]; + sprintf(str,"%d",v); + SendDlgItemMessage(guiWnd, id,WM_SETTEXT, 0, (LONG)str); +} + +// -------------------------------------------------- +void *getListBoxSelData(int id) +{ + int sel = SendDlgItemMessage(guiWnd, id,LB_GETCURSEL, 0, 0); + if (sel >= 0) + return (void *)SendDlgItemMessage(guiWnd, id,LB_GETITEMDATA, sel, 0); + return NULL; +} + +Channel *getListBoxChannel(){ + int sel = SendDlgItemMessage(guiWnd, chanID ,LB_GETCURSEL, 0, 0); + if (sel >= 0){ + ListData *ld = list_top; + int idx = 0; + + while(ld){ + if (sel == idx){ + return chanMgr->findChannelByChannelID(ld->channel_id); + } + ld = ld->next; + idx++; + } + } + return NULL; +} + +Servent *getListBoxServent(){ + int sel = SendDlgItemMessage(guiWnd, statusID ,LB_GETCURSEL, 0, 0); + if (sel >= 0){ + ServentData *sd = servent_top; + int idx = 0; + + while(sd){ + if (sel == idx){ + return servMgr->findServentByServentID(sd->servent_id); + } + sd = sd->next; + idx++; + } + } + return NULL; +} + +// -------------------------------------------------- +void setButtonState(int id, bool on) +{ + SendDlgItemMessage(guiWnd, id,BM_SETCHECK, on, 0); + SendMessage(guiWnd,WM_COMMAND,id,0); +} +// -------------------------------------------------- +void ADDLOG(const char *str,int id,bool sel,void *data, LogBuffer::TYPE type) +{ + if (guiWnd) + { + + String sjis; //JP-EX + int num = SendDlgItemMessage(guiWnd, id,LB_GETCOUNT, 0, 0); + if (num > 100) + { + SendDlgItemMessage(guiWnd, id, LB_DELETESTRING, 0, 0); + num--; + } + sjis = str; //JP-Patch + sjis.convertTo(String::T_SJIS); //JP-Patch + //int idx = SendDlgItemMessage(guiWnd, id, LB_ADDSTRING, 0, (LONG)(LPSTR)str); + int idx = SendDlgItemMessage(guiWnd, id, LB_ADDSTRING, 0, (LONG)(LPSTR)sjis.cstr()); + SendDlgItemMessage(guiWnd, id, LB_SETITEMDATA, idx, (LONG)data); + + if (sel) + SendDlgItemMessage(guiWnd, id, LB_SETCURSEL, num, 0); + + } + + if (type != LogBuffer::T_NONE) + { +#if _DEBUG + OutputDebugString(str); + OutputDebugString("\n"); +#endif + } + +} + + +// -------------------------------------------------- +void ADDLOG2(const char *fmt,va_list ap,int id,bool sel,void *data, LogBuffer::TYPE type) +{ + char str[4096]; + vsprintf(str,fmt,ap); + + ADDLOG(str,id,sel,data,type); +} + +// -------------------------------------------------- +void ADDCHAN(void *d, const char *fmt,...) +{ + va_list ap; + va_start(ap, fmt); + ADDLOG2(fmt,ap,chanID,false,d,LogBuffer::T_NONE); + va_end(ap); +} +// -------------------------------------------------- +void ADDHIT(void *d, const char *fmt,...) +{ + va_list ap; + va_start(ap, fmt); + ADDLOG2(fmt,ap,hitID,false,d,LogBuffer::T_NONE); + va_end(ap); +} +// -------------------------------------------------- +void ADDCONN(void *d, const char *fmt,...) +{ + va_list ap; + va_start(ap, fmt); + ADDLOG2(fmt,ap,statusID,false,d,LogBuffer::T_NONE); + va_end(ap); +} + +WLock sd_lock; +WLock ld_lock; + +// -------------------------------------------------- +THREAD_PROC showConnections(ThreadInfo *thread) +{ +// thread->lock(); + while (thread->active) + { + int sel,top,i; +/* sel = SendDlgItemMessage(guiWnd, statusID,LB_GETCURSEL, 0, 0); + top = SendDlgItemMessage(guiWnd, statusID,LB_GETTOPINDEX, 0, 0); + + SendDlgItemMessage(guiWnd, statusID, LB_RESETCONTENT, 0, 0); + Servent *s = servMgr->servents; + while (s) + { + if (s->type != Servent::T_NONE) + { + Host h = s->getHost(); + { + unsigned int ip = h.ip; + unsigned short port = h.port; + + Host h(ip,port); + char hostName[64]; + h.toStr(hostName); + + unsigned int tnum = 0; + char tdef = 's'; + if (s->lastConnect) + tnum = sys->getTime()-s->lastConnect; + + if ((s->type == Servent::T_RELAY) || (s->type == Servent::T_DIRECT)) + { + ADDCONN(s,"%s-%s-%d%c - %s - %d - %s ", + s->getTypeStr(),s->getStatusStr(),tnum,tdef, + hostName, + s->syncPos,s->agent.cstr() + ); //JP-Patch + }else{ + if (s->status == Servent::S_CONNECTED) + { + ADDCONN(s,"%s-%s-%d%c - %s - %d/%d", + s->getTypeStr(),s->getStatusStr(),tnum,tdef, + hostName, + s->gnuStream.packetsIn,s->gnuStream.packetsOut); + }else{ + ADDCONN(s,"%s-%s-%d%c - %s", + s->getTypeStr(),s->getStatusStr(),tnum,tdef, + hostName + ); + } + + } + + } + } + s=s->next; + } + if (sel >= 0) + SendDlgItemMessage(guiWnd, statusID,LB_SETCURSEL, sel, 0); + if (top >= 0) + SendDlgItemMessage(guiWnd, statusID,LB_SETTOPINDEX, top, 0);*/ + + int sd_count = 0; + int diff = 0; + + sel = SendDlgItemMessage(guiWnd, statusID,LB_GETCURSEL, 0, 0); + top = SendDlgItemMessage(guiWnd, statusID,LB_GETTOPINDEX, 0, 0); + + ServentData *sd = servent_top; + while(sd){ + sd->flg = false; + sd = sd->next; + sd_count++; + } + + servMgr->lock.on(); + Servent *s = servMgr->servents; + + Channel *sel_ch = getListBoxChannel(); // for PCRaw (connection list) + + while(s){ + Servent *next; + bool foundFlg = false; + ChanHitList *chl; + bool infoFlg = false; + bool relay = true; + bool firewalled = false; + unsigned int numRelays = 0; + unsigned int totalRelays = 0; + unsigned int totalListeners = 0; + int vp_ver = 0; + char ver_ex_prefix[2] = {' ', ' '}; + int ver_ex_number = 0; + + next = s->next; + + // for PCRaw (connection list) start + if(sel_ch && !sel_ch->info.id.isSame(s->chanID)) + { + s = next; + continue; + } + // for PCRaw (connection list) end + + if (s->type != Servent::T_NONE){ + + chanMgr->hitlistlock.on(); + + chl = chanMgr->findHitListByID(s->chanID); + if (chl){ + ChanHit *hit = chl->hit; + while(hit){ + if (hit->servent_id == s->servent_id){ + if ((hit->numHops == 1)/* && (hit->host.ip == s->getHost().ip)*/){ + infoFlg = true; + relay = hit->relay; + firewalled = hit->firewalled; + numRelays = hit->numRelays; + vp_ver = hit->version_vp; + ver_ex_prefix[0] = hit->version_ex_prefix[0]; + ver_ex_prefix[1] = hit->version_ex_prefix[1]; + ver_ex_number = hit->version_ex_number; + } + totalRelays += hit->numRelays; + totalListeners += hit->numListeners; + } + hit = hit->next; + } + } + chanMgr->hitlistlock.off(); + } + + sd = servent_top; + while(sd){ + if (sd->servent_id == s->servent_id){ + foundFlg = true; + if (s->thread.finish) break; + sd->flg = true; + sd->type = s->type; + sd->status = s->status; + sd->agent = s->agent; + sd->h = s->getHost(); + sd->syncpos = s->syncPos; + sd->tnum = (s->lastConnect) ? sys->getTime()-s->lastConnect : 0; + sd->typeStr = s->getTypeStr(); + sd->statusStr = s->getStatusStr(); + sd->infoFlg = infoFlg; + sd->relay = relay; + sd->firewalled = firewalled; + sd->numRelays = numRelays; + sd->totalRelays = totalRelays; + sd->totalListeners = totalListeners; + sd->vp_ver = vp_ver; + sd->lastSkipTime = s->lastSkipTime; + sd->lastSkipCount = s->lastSkipCount; + sd->ver_ex_prefix[0] = ver_ex_prefix[0]; + sd->ver_ex_prefix[1] = ver_ex_prefix[1]; + sd->ver_ex_number = ver_ex_number; + break; + } + sd = sd->next; + } + if (!foundFlg && (s->type != Servent::T_NONE) && !s->thread.finish){ + ServentData *newData = new ServentData(); + newData->next = servent_top; + servent_top = newData; + newData->flg = true; + newData->servent_id = s->servent_id; + newData->type = s->type; + newData->status = s->status; + newData->agent = s->agent; + newData->h = s->getHost(); + newData->syncpos = s->syncPos; + newData->tnum = (s->lastConnect) ? sys->getTime()-s->lastConnect : 0; + newData->typeStr = s->getTypeStr(); + newData->statusStr = s->getStatusStr(); + newData->infoFlg = infoFlg; + newData->relay = relay; + newData->firewalled = firewalled; + newData->numRelays = numRelays; + newData->totalRelays = totalRelays; + newData->totalListeners = totalListeners; + newData->vp_ver = vp_ver; + newData->lastSkipTime = s->lastSkipTime; + newData->lastSkipCount = s->lastSkipCount; + newData->ver_ex_prefix[0] = ver_ex_prefix[0]; + newData->ver_ex_prefix[1] = ver_ex_prefix[1]; + newData->ver_ex_number = ver_ex_number; + + int idx = SendDlgItemMessage(guiWnd, statusID, LB_ADDSTRING, 0, (LONG)""); + SendDlgItemMessage(guiWnd, statusID, LB_SETITEMDATA, idx, (LONG)(newData->servent_id)); + diff++; + } + s = next; + } + servMgr->lock.off(); + + sd_lock.on(); + sd = servent_top; + int idx = 0; + ServentData *prev = NULL; + //int *idxs; + //if (sd_count){ + // idxs = new int[sd_count]; + //} + while(sd){ + if (!sd->flg || (sd->type == Servent::T_NONE)){ + ServentData *next = sd->next; + if (!prev){ + servent_top = next; + } else { + prev->next = next; + } + delete sd; + + PostMessage(GetDlgItem(guiWnd, statusID), LB_DELETESTRING, idx, 0); +// SendDlgItemMessage(guiWnd, statusID, LB_DELETESTRING, idx, 0); + sd = next; +// diff--; + } else { + idx++; + prev = sd; + sd = sd->next; + } + } + sd_lock.off(); + + if ((sel >= 0) && (diff != 0)){ + PostMessage(GetDlgItem(guiWnd, statusID), LB_SETCURSEL, sel+diff, 0); + } + if (top >= 0){ + PostMessage(GetDlgItem(guiWnd, statusID), LB_SETTOPINDEX, top, 0); + } + InvalidateRect(GetDlgItem(guiWnd, statusID), NULL, FALSE); + + char cname[34]; + + { +// sel = SendDlgItemMessage(guiWnd, chanID,LB_GETCURSEL, 0, 0); +// top = SendDlgItemMessage(guiWnd, chanID,LB_GETTOPINDEX, 0, 0); +// SendDlgItemMessage(guiWnd, chanID, LB_RESETCONTENT, 0, 0); + + ListData *ld = list_top; + while(ld){ + ld->flg = false; + ld = ld->next; + } + + Channel *c = chanMgr->channel; + + while (c) + { + Channel *next; + bool foundFlg = false; + String sjis; + sjis = c->getName(); + sjis.convertTo(String::T_SJIS); + + next = c->next; + + ld = list_top; + while(ld){ + if (ld->channel_id == c->channel_id){ + foundFlg = true; + if (c->thread.finish) break; + ld->flg = true; + strncpy(ld->name, sjis, 20); + ld->name[20] = '\0'; + ld->bitRate = c->info.bitrate; + ld->status = c->status; + ld->statusStr = c->getStatusStr(); + ld->totalListeners = c->totalListeners(); + ld->totalRelays = c->totalRelays(); + ld->localListeners = c->localListeners(); + ld->localRelays = c->localRelays(); + ld->stayConnected = c->stayConnected; + ld->chDisp = c->chDisp; + ld->bTracker = c->sourceHost.tracker; + break; + } + ld = ld->next; + } + if (!foundFlg && !c->thread.finish){ + ListData *newData = new ListData(); + newData->next = list_top; + list_top = newData; + newData->flg = true; + newData->channel_id = c->channel_id; + strncpy(newData->name, sjis, 20); + newData->name[20] = '\0'; + newData->bitRate = c->info.bitrate; + newData->status = c->status; + newData->statusStr = c->getStatusStr(); + newData->totalListeners = c->totalListeners(); + newData->totalRelays = c->totalRelays(); + newData->localListeners = c->localListeners(); + newData->localRelays = c->localRelays(); + newData->stayConnected = c->stayConnected; + newData->chDisp = c->chDisp; + newData->bTracker = c->sourceHost.tracker; + + int idx = SendDlgItemMessage(guiWnd, chanID, LB_ADDSTRING, 0, (LONG)""); + SendDlgItemMessage(guiWnd, chanID, LB_SETITEMDATA, idx, (LONG)(newData->channel_id)); + } + c = next; + } + + ld = list_top; + int idx = 0; + ListData *prev = NULL; + while(ld){ + if (!ld->flg){ + ListData *next = ld->next; + if (!prev){ + list_top = next; + } else { + prev->next = next; + } + delete ld; + + SendDlgItemMessage(guiWnd, chanID, LB_DELETESTRING, idx, 0); + ld = next; + } else { + idx++; + prev = ld; + ld = ld->next; + } + } + + InvalidateRect(GetDlgItem(guiWnd, chanID), NULL, FALSE); + +/* String sjis; //JP-Patch + sjis = c->getName(); //JP-Patch + sjis.convertTo(String::T_SJIS); //JP-Patch + strncpy(cname,sjis.cstr(),16); //JP-Patch + //strncpy(cname,c->getName(),16); + cname[16] = 0; + //int sec = ((c->currSPacket*c->bitrate*SPacket::DATA_LEN)/8)/(c->bitrate*1024); + //int k = ((c->currSPacket*SPacket::DATA_LEN))/(1024); + //ADDCHAN(c,"%d. %s - %d KB/s - %du - %dk",num,cname,c->bitrate,c->listeners,k); + //ADDCHAN(c,"%d. %s - %d kb/s - %s",c->index,cname,c->getBitrate(),c->getStatusStr()); + ADDCHAN(c,"%s - %d kb/s - %s - %d/%d-[%d/%d] - %s",cname,c->getBitrate(),c->getStatusStr(), + c->totalListeners(),c->totalRelays(),c->localListeners(),c->localRelays(),c->stayConnected?"Yes":"No"); //JP-Patch + } + c=c->next; + }*/ +// if (sel >= 0) +// SendDlgItemMessage(guiWnd, chanID,LB_SETCURSEL, sel, 0); +// if (top >= 0) +// SendDlgItemMessage(guiWnd, chanID,LB_SETTOPINDEX, top, 0); + } + + + + bool update = ((sys->getTime() - chanMgr->lastHit) < 3)||(!shownChannels); + + if (update) + { + shownChannels = true; + { + sel = SendDlgItemMessage(guiWnd, hitID,LB_GETCURSEL, 0, 0); + top = SendDlgItemMessage(guiWnd, hitID,LB_GETTOPINDEX, 0, 0); + SendDlgItemMessage(guiWnd, hitID, LB_RESETCONTENT, 0, 0); + + chanMgr->hitlistlock.on(); + + ChanHitList *chl = chanMgr->hitlist; + + while (chl) + { + if (chl->isUsed()) + { + if (chl->info.match(chanMgr->searchInfo)) + { + strncpy(cname,chl->info.name.cstr(),16); + cname[16] = 0; + ADDHIT(chl,"%s - %d kb/s - %d/%d",cname,chl->info.bitrate,chl->numListeners(),chl->numHits()); + } + } + chl = chl->next; + } + chanMgr->hitlistlock.off(); + } + + if (sel >= 0) + SendDlgItemMessage(guiWnd, hitID,LB_SETCURSEL, sel, 0); + if (top >= 0) + SendDlgItemMessage(guiWnd, hitID,LB_SETTOPINDEX, top, 0); + } + + + + + { + switch (servMgr->getFirewall()) + { + case ServMgr::FW_ON: + SendDlgItemMessage(guiWnd, IDC_EDIT4,WM_SETTEXT, 0, (LONG)"Firewalled"); + break; + case ServMgr::FW_UNKNOWN: + SendDlgItemMessage(guiWnd, IDC_EDIT4,WM_SETTEXT, 0, (LONG)"Unknown"); + break; + case ServMgr::FW_OFF: + SendDlgItemMessage(guiWnd, IDC_EDIT4,WM_SETTEXT, 0, (LONG)"Normal"); + break; + } + } + + // sleep for 1 second .. check every 1/10th for shutdown + for(i=0; i<10; i++) + { + if(sleep_skip) // for PCRaw (connection list) + { + sleep_skip = false; + break; + } + + if (!thread->active) + break; + sys->sleep(100); + } + } + + ListData *ld = list_top; + while(ld){ + ListData *next; + next = ld->next; + + delete ld; + + ld = next; + } + list_top = NULL; + + ServentData *sd = servent_top; + while(sd){ + ServentData *next; + next = sd->next; + + delete sd; + + sd = next; + } + servent_top = NULL; + +// thread->unlock(); + return 0; +} + + +// -------------------------------------------------- +void tryConnect() +{ +#if 0 + ClientSocket sock; + + char tmp[32]; + + char *sendStr = "GET / HTTP/1.1\n\n"; + + try { + sock.open("taiyo",80); + sock.write(sendStr,strlen(sendStr)); + sock.read(tmp,32); + LOG("Connected: %s",tmp); + }catch(IOException &e) + { + LOG(e.msg); + } +#endif +} + + +// --------------------------------- +void APICALL MyPeercastApp ::printLog(LogBuffer::TYPE t, const char *str) +{ + ADDLOG(str,logID,true,NULL,t); + if (logFile.isOpen()) + { + logFile.writeLine(str); + logFile.flush(); + } +} + + +// -------------------------------------------------- +static void setControls(bool fromGUI) +{ + if (!guiWnd) + return; + setEditInt(IDC_EDIT1,servMgr->serverHost.port); + setEditStr(IDC_EDIT3,servMgr->password); + setEditStr(IDC_EDIT9,chanMgr->broadcastMsg.cstr()); + setEditInt(IDC_MAXRELAYS,servMgr->maxRelays); + + setButtonState(IDC_CHECK11,chanMgr->broadcastMsg[0]!=0); + + setButtonState(IDC_LOGDEBUG,(servMgr->showLog&(1<showLog&(1<showLog&(1<showLog&(1<pauseLog); + + + if (!fromGUI) + setButtonState(IDC_CHECK1,servMgr->autoServe); + + +} +// -------------------------------------------------- +void APICALL MyPeercastApp::updateSettings() +{ + setControls(true); +} + +void MoveControl(HWND hWnd, int cx, int cy, int y, HDWP& hDwp){ + RECT rc2; + POINT pos; + + GetWindowRect(hWnd, &rc2); + pos.x = rc2.left; + pos.y = rc2.top; + ScreenToClient(guiWnd, &pos); + hDwp = DeferWindowPos(hDwp, hWnd, HWND_TOP, + pos.x,cy-y-(rc2.bottom-rc2.top),rc2.right-rc2.left,rc2.bottom-rc2.top,SWP_SHOWWINDOW); +} + +void MoveControl2(HWND hWnd, int cx, int cy, int y, HDWP& hDwp){ + RECT rc; + POINT pos; + + GetWindowRect(hWnd, &rc); + pos.x = rc.left; + pos.y = rc.top; + ScreenToClient(guiWnd, &pos); + hDwp = DeferWindowPos(hDwp, hWnd, HWND_TOP, + pos.x,pos.y,rc.right-rc.left,cy-y,SWP_SHOWWINDOW); +} + +// -------------------------------------------------- +void MoveControls(LPARAM lParam){ + HDWP hDwp; + //IDC_LIST1 3,291,291,43 +/* CONTROL "—LŒø",IDC_CHECK1,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,9,29,60,20,WS_EX_TRANSPARENT + EDITTEXT IDC_EDIT1,127,18,47,12,ES_AUTOHSCROLL + RTEXT "ƒ|[ƒg :",IDC_STATIC,107,20,18,8 + GROUPBOX "",IDC_STATIC,3,4,291,49 + PUSHBUTTON "Ø’f",IDC_BUTTON5,67,65,43,13 + EDITTEXT IDC_EDIT3,127,34,47,12,ES_PASSWORD | ES_AUTOHSCROLL + RTEXT "ƒpƒXƒ[ƒh :",IDC_STATIC,89,36,36,8 + PUSHBUTTON "Ä¶",IDC_BUTTON8,10,65,22,13 + PUSHBUTTON "ÄÚ‘±",IDC_BUTTON3,41,65,24,13 + RTEXT "Å‘僊ƒŒ[” :",IDC_STATIC,203,20,40,8 + EDITTEXT IDC_MAXRELAYS,248,18,40,14,ES_AUTOHSCROLL | ES_NUMBER + PUSHBUTTON "ƒL[ƒv",IDC_BUTTON9,112,65,24,13 + LTEXT "Peercast-VP",IDC_STATIC,21,14,39,8*/ + +/* + GROUPBOX "ƒŠƒŒ[",IDC_GROUPBOX_RELAY,3,54,291,132 + LISTBOX IDC_LIST3,3,81,291,102,LBS_OWNERDRAWFIXED | + LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP + CONTROL "DJ",IDC_CHECK11,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,5,190,23,12 + EDITTEXT IDC_EDIT9,33,189,261,14,ES_AUTOHSCROLL + LTEXT "ƒRƒlƒNƒVƒ‡ƒ“",IDC_STATIC_CONNECTION,3,214,40,8 + PUSHBUTTON "Ø’f",IDC_BUTTON6,47,209,43,13 + LISTBOX IDC_LIST2,3,224,291,53,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | + WS_TABSTOP + LTEXT "ƒƒO",IDC_STATIC_LOG,3,282,13,8 + PUSHBUTTON "ƒNƒŠƒA",IDC_BUTTON1,35,279,25,11 + CONTROL "’âŽ~",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | BS_PUSHLIKE | + WS_TABSTOP,60,279,30,11 + CONTROL "ƒfƒoƒbƒO",IDC_LOGDEBUG,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,127,279,32,11 + CONTROL "ƒGƒ‰[",IDC_LOGERRORS,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,159,279,25,11 + CONTROL "ƒlƒbƒgƒ[ƒN",IDC_LOGNETWORK,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,185,279,35,11 + CONTROL "ƒ`ƒƒƒ“ƒlƒ‹",IDC_LOGCHANNELS,"Button",BS_AUTOCHECKBOX | + BS_PUSHLIKE | WS_TABSTOP,221,279,35,11 + LISTBOX IDC_LIST1,3,291,291,43,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | + WS_TABSTOP*/ + + hDwp = BeginDeferWindowPos(15); + int cx = LOWORD(lParam); + int cy = HIWORD(lParam); + + MoveControl2(GetDlgItem(guiWnd, IDC_GROUPBOX_RELAY), cx, cy, 343, hDwp); + MoveControl2(GetDlgItem(guiWnd, IDC_LIST3), cx, cy, 385, hDwp); + + MoveControl(GetDlgItem(guiWnd, IDC_EDIT9), cx, cy, 233, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_CHECK11), cx, cy, 232, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_STATIC_CONNECTION), cx, cy, 209, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_BUTTON6), cx, cy, 208, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LIST2), cx, cy, 94, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_STATIC_LOG), cx, cy, 72, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_CHECK9), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_BUTTON1), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LOGDEBUG), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LOGNETWORK), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LOGERRORS), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LOGCHANNELS), cx, cy, 71, hDwp); + MoveControl(GetDlgItem(guiWnd, IDC_LIST1), cx, cy, 3, hDwp); + + EndDeferWindowPos(hDwp); +} + +WINDOWPLACEMENT winPlace; +bool guiFlg = false; + +// -------------------------------------------------- +LRESULT CALLBACK GUIProc (HWND hwnd, UINT message, + WPARAM wParam, LPARAM lParam) +{ + + static const struct + { + LRESULT from; // •ÏŠ·Œ³ + LRESULT to; // •ÏŠ·æ + } + trans[] = + { + { HTLEFT, HTBORDER }, // ¶’[‚̍¶‰E–îˆó ¨ –îˆó‚È‚µ + { HTRIGHT, HTBORDER }, // ‰E’[‚̍¶‰E–îˆó ¨ –îˆó‚È‚µ + { HTTOPLEFT, HTTOP }, // ¶ã‹÷‚̎΂ߖîˆó ¨ c–îˆó + { HTTOPRIGHT, HTTOP }, // ‰Eã‹÷‚̎΂ߖîˆó ¨ c–îˆó + { HTBOTTOMLEFT, HTBOTTOM }, // ¶‰º‹÷‚̎΂ߖîˆó ¨ c–îˆó + { HTBOTTOMRIGHT, HTBOTTOM }, // ‰E‰º‹÷‚̎΂ߖîˆó ¨ c–îˆó + { HTTOP, HTTOP }, + { HTBOTTOM, HTBOTTOM } + }; + + + bool rectflg = false; + + switch (message) + { + case WM_INITDIALOG: + guiWnd = hwnd; + + shownChannels = false; + logID = IDC_LIST1; // log + statusID = IDC_LIST2; // status + hitID = IDC_LIST4; // hit + chanID = IDC_LIST3; // channels + + enableControl(IDC_BUTTON8,false); + enableControl(IDC_BUTTON11,false); + enableControl(IDC_BUTTON10,false); + + peercastApp->updateSettings(); + + if (servMgr->autoServe) + setButtonState(IDC_CHECK1,true); + if (servMgr->autoConnect) + setButtonState(IDC_CHECK2,true); + + + guiThread.func = showConnections; + if (!sys->startThread(&guiThread)) + { + MessageBox(hwnd,"Unable to start GUI","PeerCast",MB_OK|MB_ICONERROR); + PostMessage(hwnd,WM_DESTROY,0,0); + } + + if (guiFlg){ + SetWindowPlacement(hwnd, &winPlace); + } + + { // for PCRaw (connection list) + HWND hwndList; + + hwndList = GetDlgItem(guiWnd, chanID); + wndOldListBox = (WNDPROC)GetWindowLong(hwndList, GWL_WNDPROC); + SetWindowLong(hwndList, GWL_WNDPROC, (DWORD)ListBoxProc); + + hwndList = GetDlgItem(guiWnd, statusID); + wndOldConnListBox = (WNDPROC)GetWindowLong(hwndList, GWL_WNDPROC); + SetWindowLong(hwndList, GWL_WNDPROC, (DWORD)ConnListBoxProc); + } + + break; + + case WM_COMMAND: + switch( wParam ) + { + case IDC_CHECK1: // start server + if (getButtonState(IDC_CHECK1)) + { + //SendDlgItemMessage(hwnd, IDC_CHECK1,WM_SETTEXT, 0, (LPARAM)"Deactivate"); + + SendDlgItemMessage(hwnd, IDC_EDIT3,WM_GETTEXT, 64, (LONG)servMgr->password); + + servMgr->serverHost.port = (unsigned short)getEditInt(IDC_EDIT1); + servMgr->setMaxRelays(getEditInt(IDC_MAXRELAYS)); + + + enableControl(IDC_EDIT1,false); + enableControl(IDC_EDIT3,false); + enableControl(IDC_MAXRELAYS,false); + enableControl(IDC_BUTTON8,true); + enableControl(IDC_BUTTON11,true); + enableControl(IDC_BUTTON10,true); + + //writeSettings(); + servMgr->autoServe = true; + + setEditStr(IDC_CHECK1,"Enabled"); + + + }else{ + //SendDlgItemMessage(hwnd, IDC_CHECK1,WM_SETTEXT, 0, (LPARAM)"Activate"); + + servMgr->autoServe = false; + + enableControl(IDC_EDIT1,true); + enableControl(IDC_EDIT3,true); + enableControl(IDC_MAXRELAYS,true); + enableControl(IDC_BUTTON8,false); + enableControl(IDC_BUTTON11,false); + enableControl(IDC_BUTTON10,false); + + setEditStr(IDC_CHECK1,"Disabled"); + + } + setControls(true); + + break; + case IDC_CHECK11: // DJ message + if (getButtonState(IDC_CHECK11)) + { + enableControl(IDC_EDIT9,false); + SendDlgItemMessage(hwnd, IDC_EDIT9,WM_GETTEXT, 128, (LONG)chanMgr->broadcastMsg.cstr()); + }else{ + enableControl(IDC_EDIT9,true); + chanMgr->broadcastMsg.clear(); + } + break; + case IDC_LOGDEBUG: // log debug + servMgr->showLog = getButtonState(wParam) ? servMgr->showLog|(1<showLog&~(1<showLog = getButtonState(wParam) ? servMgr->showLog|(1<showLog&~(1<showLog = getButtonState(wParam) ? servMgr->showLog|(1<showLog&~(1<showLog = getButtonState(wParam) ? servMgr->showLog|(1<showLog&~(1<pauseLog = getButtonState(wParam); + break; + case IDC_CHECK2: // start outgoing + + if (getButtonState(IDC_CHECK2)) + { + + SendDlgItemMessage(hwnd, IDC_COMBO1,WM_GETTEXT, 128, (LONG)servMgr->connectHost); + servMgr->autoConnect = true; + //SendDlgItemMessage(hwnd, IDC_CHECK2,WM_SETTEXT, 0, (LPARAM)"Disconnect"); + enableControl(IDC_COMBO1,false); + }else{ + servMgr->autoConnect = false; + //SendDlgItemMessage(hwnd, IDC_CHECK2,WM_SETTEXT, 0, (LPARAM)"Connect"); + enableControl(IDC_COMBO1,true); + } + break; + case IDC_BUTTON11: // broadcast + { + Host sh = servMgr->serverHost; + if (sh.isValid()) + { + char cmd[256]; + sprintf(cmd,"http://localhost:%d/admin?page=broadcast",sh.port); + ShellExecute(hwnd, NULL, cmd, NULL, NULL, SW_SHOWNORMAL); + + }else{ + MessageBox(hwnd,"Server is not currently connected.\nPlease wait until you have a connection.","PeerCast",MB_OK); + } + } + break; + case IDC_BUTTON8: // play selected + { + Channel *c = getListBoxChannel(); + if (c){ + chanMgr->playChannel(c->info); + } + } + break; + case IDC_BUTTON7: // advanced + sys->callLocalURL("admin?page=settings",servMgr->serverHost.port); + break; + case IDC_BUTTON6: // servent disconnect + { +/* Servent *s = (Servent *)getListBoxSelData(statusID); + if (s) + s->thread.active = false;*/ + Servent *s = getListBoxServent(); + if (s){ + s->thread.active = false; + s->thread.finish = true; + } + sleep_skip = true; + } + break; + case IDC_BUTTON5: // chan disconnect + { +/* Channel *c = (Channel *)getListBoxSelData(chanID); + if (c) + c->thread.active = false;*/ + +// Channel *c = chanMgr->findChannelByChannelID((int)getListBoxSelData(chanID)); + Channel *c = getListBoxChannel(); + if (c){ + c->thread.active = false; + c->thread.finish = true; + } + sleep_skip = true; + } + break; + case IDC_BUTTON3: // chan bump + { +/* Channel *c = (Channel *)getListBoxSelData(chanID); + if (c) + c->bump = true;*/ + +// Channel *c = chanMgr->findChannelByChannelID((int)getListBoxSelData(chanID)); + Channel *c = getListBoxChannel(); + if (c){ + c->bump = true; + } + } + + break; + case IDC_BUTTON4: // get channel + { + ChanHitList *chl = (ChanHitList *)getListBoxSelData(hitID); + if (chl) + { + if (!chanMgr->findChannelByID(chl->info.id)) + { + Channel *c = chanMgr->createChannel(chl->info,NULL); + if (c) + c->startGet(); + } + }else{ + MessageBox(hwnd,"Please select a channel","PeerCast",MB_OK); + } + } + break; + + case IDC_BUTTON9: //JP-EX chan keep + { +/* Channel *c = (Channel *)getListBoxSelData(chanID); + if (c) + { + if (!c->stayConnected) + { + //if (servMgr->getFirewall() == ServMgr::FW_OFF) + c->stayConnected = true; + } + else + c->stayConnected = false; + }*/ + +// Channel *c = chanMgr->findChannelByChannelID((int)getListBoxSelData(chanID)); + Channel *c = getListBoxChannel(); + if (c){ + if (!c->stayConnected){ + c->stayConnected = true; + } else { + c->stayConnected = false; + } + } + } + break; + + case IDC_BUTTON1: // clear log + SendDlgItemMessage(guiWnd, logID, LB_RESETCONTENT, 0, 0); + sys->logBuf->clear(); // for PCRaw (clear log) + break; + + case IDC_BUTTON2: // find + { + char str[64]; + SendDlgItemMessage(hwnd, IDC_EDIT2,WM_GETTEXT, 64, (LONG)str); + SendDlgItemMessage(hwnd, hitID, LB_RESETCONTENT, 0, 0); + ChanInfo info; + info.init(); + info.name.set(str); + chanMgr->startSearch(info); + } + break; + + } + break; + + case WM_MEASUREITEM: + if ((UINT) wParam==IDC_LIST3){ + LPMEASUREITEMSTRUCT lpMI = (LPMEASUREITEMSTRUCT)lParam; + lpMI->itemHeight = 12; + } else if ((UINT) wParam==IDC_LIST2){ + LPMEASUREITEMSTRUCT lpMI = (LPMEASUREITEMSTRUCT)lParam; + lpMI->itemHeight = 12; + } + break; + case WM_DRAWITEM: + if ((UINT) wParam==IDC_LIST3) + { + LPDRAWITEMSTRUCT _DrawItem=(LPDRAWITEMSTRUCT)lParam; + HBRUSH hBrush; + ListData *ld; + unsigned int idx = 0; + bool flg = false; + + ld = list_top; + while(ld){ + if (_DrawItem->itemID == idx){ + flg = true; + break; + } + ld = ld->next; + idx++; + } + if ((_DrawItem->itemState) & (ODS_SELECTED)) + { + hBrush=CreateSolidBrush(RGB(49,106,197)); + } + else + { + hBrush=CreateSolidBrush(RGB(255,255,255)); + } + FillRect(_DrawItem->hDC,&_DrawItem->rcItem,hBrush); + DeleteObject(hBrush); + if (flg){ + char buf[256]; + if (ld->status == Channel::S_RECEIVING){ + if (ld->chDisp.status == Channel::S_RECEIVING){ + if (ld->chDisp.relay){ + /* relay ok */ + SetTextColor(_DrawItem->hDC,RGB(0,255,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } else { + /* no more relay */ + if (ld->chDisp.numRelays){ + /* relay full */ + SetTextColor(_DrawItem->hDC,RGB(0,0,255)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } else { + /* relay ng */ + SetTextColor(_DrawItem->hDC,RGB(255,0,255)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } + } + } else { + /* status unmatch */ + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + "¡", + 2); + } else { + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + " ", + 2); + } + if ((_DrawItem->itemState) & (ODS_SELECTED)) + { + SetTextColor(_DrawItem->hDC,RGB(255,255,255)); + SetBkColor(_DrawItem->hDC,RGB(49,106,197)) ; + } else { + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } + if (servMgr->getFirewall() == ServMgr::FW_ON){ + SetTextColor(_DrawItem->hDC,RGB(255,0,0)); + } else if (ld->bTracker && (ld->status == Channel::S_RECEIVING)){ + if ((_DrawItem->itemState) & (ODS_SELECTED)) + { + SetTextColor(_DrawItem->hDC,RGB(0,255,0)); + SetBkColor(_DrawItem->hDC,RGB(49,106,197)) ; + } else { + SetTextColor(_DrawItem->hDC,RGB(0,128,0)); + } + } + + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12, + _DrawItem->rcItem.top, + ld->name, + strlen(ld->name)); +/* sprintf(buf, "- %4dkbps -", ld->bitRate); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12 + 118, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12 + 118 + 80, + _DrawItem->rcItem.top, + ld->statusStr, + strlen(ld->statusStr)); + sprintf(buf, "- %3d/%3d - [%3d/%3d] -", ld->totalListeners, ld->totalRelays, ld->localListeners, ld->localRelays); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12 + 118 + 80 + 80, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + strcpy(buf, ld->stayConnected?"YES":"NO"); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12 + 118 + 80 + 80 + 130, + _DrawItem->rcItem.top, + buf, + strlen(buf));*/ + sprintf(buf, "- %4dkbps - %s - %3d/%3d - [%3d/%3d] - %s", + ld->bitRate, + ld->statusStr, + ld->totalListeners, + ld->totalRelays, + ld->localListeners, + ld->localRelays, + ld->stayConnected?"YES":"NO"); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12 + 118, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + } + } else if ((UINT) wParam==IDC_LIST2) { + LPDRAWITEMSTRUCT _DrawItem=(LPDRAWITEMSTRUCT)lParam; + HBRUSH hBrush; + ServentData *sd; + unsigned int idx = 0; + bool flg = false; + + sd_lock.on(); + + sd = servent_top; + while(sd){ + if (_DrawItem->itemID == idx){ + flg = true; + break; + } + sd = sd->next; + idx++; + } + if (flg){ + char buf[256]; + char hostName[64]; + sd->h.toStr(hostName); + + if ((_DrawItem->itemState) & (ODS_SELECTED)) + { + hBrush=CreateSolidBrush(RGB(49,106,197)); + } + else + { + hBrush=CreateSolidBrush(RGB(255,255,255)); + } + FillRect(_DrawItem->hDC,&_DrawItem->rcItem,hBrush); + DeleteObject(hBrush); + + if (sd->infoFlg){ + if (sd->relay){ + /* relay ok */ + SetTextColor(_DrawItem->hDC,RGB(0,255,0)); +// SetBkColor(_DrawItem->hDC,RGB(255,255,255)); + } else { + /* no more relay */ + if (sd->numRelays){ + /* relay full */ + SetTextColor(_DrawItem->hDC,RGB(0,0,255)); +// SetBkColor(_DrawItem->hDC,RGB(255,255,255)); + } else { + /* relay ng */ + SetTextColor(_DrawItem->hDC,RGB(255,0,255)); +// SetBkColor(_DrawItem->hDC,RGB(255,255,255)); + } + } + } else { + /* no info */ + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); +// SetBkColor(_DrawItem->hDC,RGB(255,255,255)); + } + + if (sd->lastSkipTime + 120 > sys->getTime()){ + SetBkColor(_DrawItem->hDC,RGB(128,128,128)); + if (sd->type == Servent::T_RELAY){ + sprintf(buf, "¥(%d)",sd->lastSkipCount); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + } else { + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + sprintf(buf, "¤(%d)",sd->lastSkipCount); + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + } + } else { + SetBkColor(_DrawItem->hDC,RGB(255,255,255)); + if (sd->type == Servent::T_RELAY){ + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + "¡", + 2); + } else { + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left, + _DrawItem->rcItem.top, + " ", + 2); + } + } + + if ((_DrawItem->itemState) & (ODS_SELECTED)) + { + SetTextColor(_DrawItem->hDC,RGB(255,255,255)); + SetBkColor(_DrawItem->hDC,RGB(49,106,197)) ; + } else { + SetTextColor(_DrawItem->hDC,RGB(0,0,0)); + SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ; + } + if (sd->firewalled){ + if (!sd->numRelays){ + SetTextColor(_DrawItem->hDC,RGB(255,0,0)); + } else { + SetTextColor(_DrawItem->hDC,RGB(255,168,0)); + } + } + + char buf2[16]; + if (sd->ver_ex_number){ + sprintf(buf2, "(%c%c%04d)", sd->ver_ex_prefix[0], sd->ver_ex_prefix[1], sd->ver_ex_number); + } else if (sd->vp_ver){ + sprintf(buf2, "(VP%04d)", sd->vp_ver); + } else { + buf2[0] = '\0'; + } + if (sd->type == Servent::T_RELAY){ + if (sd->status == Servent::S_CONNECTED){ + sprintf(buf, "(%d)RELAYING-%ds - %d/%d - %s - %d - %s%s", + sd->lastSkipCount, + sd->tnum, + sd->totalListeners, sd->totalRelays, + hostName, + sd->syncpos, sd->agent.cstr(), buf2 + ); + } else { + sprintf(buf, "%s-%s-%ds - %d/%d - %s - %d - %s%s", + sd->typeStr, sd->statusStr, sd->tnum, + sd->totalListeners, sd->totalRelays, + hostName, + sd->syncpos, sd->agent.cstr(), buf2 + ); + } + } else if (sd->type == Servent::T_DIRECT){ + sprintf(buf, "%s-%s-%ds - %s - %d - %s ", + sd->typeStr, sd->statusStr, sd->tnum, + hostName, + sd->syncpos, sd->agent.cstr() + ); + } else { + if (sd->status == Servent::S_CONNECTED){ + sprintf(buf, "%s-%s-%ds - %s - %d/%d", + sd->typeStr, sd->statusStr, sd->tnum, + hostName, + sd->syncpos, sd->agent.cstr() + ); + } else { + sprintf(buf, "%s-%s-%ds - %s", + sd->typeStr, sd->statusStr, sd->tnum, + hostName + ); + } + } + TextOut(_DrawItem->hDC, + _DrawItem->rcItem.left + 12, + _DrawItem->rcItem.top, + buf, + strlen(buf)); + } + sd_lock.off(); + } + break; + + case WM_SIZE: + MoveControls(lParam); + break; + + case WM_GETMINMAXINFO: + { + MINMAXINFO *pmmi = (MINMAXINFO *)lParam; + if ( pmmi ) + { + pmmi->ptMinTrackSize.x = 530; // Å¬• + pmmi->ptMinTrackSize.y = 435; // Å¬‚ + pmmi->ptMaxTrackSize.x = 530; // Å‘啝 + pmmi->ptMaxTrackSize.y = 1200; // Å‘卂 + } + return 0; + } + +/* case WM_NCHITTEST: + { + LRESULT lResult; // ƒJ[ƒ\ƒ‹ˆÊ’u”»’茋‰Ê + + // •ÏŠ·ˆê——‚É‚ ‚ê‚Εϊ·‚µ‚½’l‚ð•Ô‚·B + lResult = DefWindowProc( guiWnd, message, wParam, lParam ); + for( int i = 0; i < 8; i++ ) + { + if ( lResult == trans[ i ].from ) + { + return trans[ i ].to; + } + } +// return lResult; +// return HTCAPTION; +// return 0; + }*/ + + case WM_CLOSE: + GetWindowPlacement(hwnd, &winPlace); + guiFlg = true; + DestroyWindow( hwnd ); + break; + + case WM_DESTROY: + GetWindowPlacement(hwnd, &winPlace); + guiFlg = true; + guiThread.active = false; +// guiThread.lock(); + guiWnd = NULL; +// guiThread.unlock(); + EndDialog(hwnd, LOWORD(wParam)); + break; + + //default: + // do nothing + //return DefDlgProc(hwnd, message, wParam, lParam); // this recurses for ever + //return DefWindowProc(hwnd, message, wParam, lParam); // this stops window messages + } + return 0; +} diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.h b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.h new file mode 100644 index 0000000..4eb0f3d --- /dev/null +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/gui.h @@ -0,0 +1,44 @@ +// ------------------------------------------------ +// File : gui.h +// Date: 4-apr-2002 +// Author: giles +// +// (c) 2002 peercast.org +// ------------------------------------------------ +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// ------------------------------------------------ + +#ifndef _GUI_H +#define _GUI_H + +#include "sys.h" + +extern LRESULT CALLBACK GUIProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); +extern void ADDLOG(const char *str,int id,bool sel,void *data, LogBuffer::TYPE type); + +extern String iniFileName; +extern HWND guiWnd; +extern int logID; + +enum +{ + WM_INITSETTINGS = WM_USER, + WM_GETPORTNUMBER, + WM_PLAYCHANNEL, + WM_TRAYICON, + WM_SHOWGUI, + WM_SHOWMENU, + WM_PROCURL + +}; + + +#endif \ No newline at end of file diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/resource.h b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/resource.h new file mode 100644 index 0000000..a9a2b6d --- /dev/null +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/resource.h @@ -0,0 +1,110 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by Simple.rc +// +#define IDC_MYICON 2 +#define IDD_MAINWINDOW 101 +#define IDD_SIMPLE_DIALOG 102 +#define IDD_ABOUTBOX 103 +#define IDS_APP_TITLE 103 +#define IDM_ABOUT 104 +#define IDM_EXIT 105 +#define IDS_HELLO 106 +#define IDI_SIMPLE 107 +#define IDI_SMALL 108 +#define IDC_SIMPLE 109 +#define IDI_SMALL2 109 +#define IDR_MAINFRAME 128 +#define IDR_TRAYMENU 130 +#define IDR_VERMENU 133 +#define IDD_CHANINFO 136 +#define IDR_LTRAYMENU 137 +#define IDC_LIST1 1000 +#define IDC_BUTTON7 1001 +#define IDC_ABOUTVER 1002 +#define IDC_CHECK1 1003 +#define IDC_EDIT1 1004 +#define IDC_LIST2 1005 +#define IDC_EDIT_PLAYING 1005 +#define IDC_COMBO1 1006 +#define IDC_EDIT_MESSAGE 1006 +#define IDC_CHECK2 1007 +#define IDC_EDIT_NAME 1007 +#define IDC_BUTTON1 1008 +#define IDC_EDIT_DESC 1008 +#define IDC_DETAILS 1009 +#define IDC_MAXRELAYS 1009 +#define IDC_LIST3 1010 +#define IDC_PLAY 1010 +#define IDC_CONTACT 1011 +#define IDC_EDIT2 1012 +#define IDC_FORMAT 1013 +#define IDC_EDIT_GENRE 1014 +#define IDC_KEEP 1015 +#define IDC_EDIT_STATUS 1016 +#define IDC_GROUPBOX_RELAY 1016 +#define IDC_EDIT_LISTENERS 1017 +#define IDC_STATIC_CONNECTION 1017 +#define IDC_LIST4 1018 +#define IDC_EDIT_HOSTS 1018 +#define IDC_STATIC_LOG 1018 +#define IDC_BUTTON4 1019 +#define IDC_BUTTON5 1020 +#define IDC_BUTTON6 1021 +#define IDC_EDIT3 1025 +#define IDC_EDIT5 1027 +#define IDC_LOGDEBUG 1037 +#define IDC_LOGNETWORK 1038 +#define IDC_LOGERRORS 1039 +#define IDC_CHECK9 1041 +#define IDC_BUTTON8 1043 +#define IDC_BUTTON10 1046 +#define IDC_BUTTON11 1047 +#define IDC_LOGCHANNELS 1050 +#define IDC_BUTTON2 1056 +#define IDC_EDIT4 1058 +#define IDC_BUTTON3 1059 +#define IDC_EDIT9 1060 +#define IDC_CHECK11 1061 +#define IDC_BUTTON9 1062 +#define IDM_SETTINGS_GUI 32771 +#define ID_POPUP_ABOUT 32779 +#define ID_POPUP_EXIT_CONFIRM 32781 +#define ID_POPUP_EXIT_NO 32782 +#define ID_POPUP_SETTINGS 32785 +#define ID_POPUP_CONNECTIONS 32786 +#define ID_POPUP_SHOWGUI 32788 +#define ID_POPUP_ALLCHANNELS 32791 +#define ID_POPUP_FAVORITES_EDIT 32792 +#define ID_POPUP_ADVANCED_INFORMATION 32793 +#define ID_POPUP_ADVANCED_SAVESETTINGS 32794 +#define ID_POPUP_UPGRADE 32795 +#define ID_POPUP_HELP 32796 +#define ID_POPUP_ADVANCED_VIEWLOG 32797 +#define ID_POPUP_FAVORITES_PLAYALL 32798 +#define ID_POPUP_ADVANCED_ALLCHANNELS 32799 +#define ID_POPUP_ADVANCED_RELAYEDCHANNELS 32800 +#define ID_POPUP_ADVANCED_BROADCAST 32801 +#define ID_FIND_CHANNELS 32808 +#define ID_POPUP_SHOWMESSAGES_PEERCAST 32814 +#define ID_POPUP_SHOWMESSAGES_BROADCASTERS 32815 +#define ID_POPUP_SHOWMESSAGES_TRACKINFO 32816 +#define ID_POPUP_POPUPMESSAGES_UPGRADEALERTS 32817 +#define ID_POPUP_YELLOWPAGES 32818 +#define ID_POPUP_ADVANCED_SHOWGUI 32819 +#define ID_POPUP_YELLOWPAGES1 32820 +#define ID_POPUP_YELLOWPAGES2 32821 +#define ID_POPUP_SAVE_GUI_POS 32823 +#define ID_POPUP_KEEP_DOWNSTREAMS 32825 +#define IDC_STATIC -1 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 142 +#define _APS_NEXT_COMMAND_VALUE 32826 +#define _APS_NEXT_CONTROL_VALUE 1019 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/small.ico b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/small.ico new file mode 100644 index 0000000000000000000000000000000000000000..c7dee299bec9d38ea44c45432b48fd10214e226c GIT binary patch literal 318 zcmZvYF%H5o3`Kt>Br|qmX5@I;!bUd6UMbw95*I*XXpvCObJ}h=dH*|(6Gf3aM&I{} zxOCDf9HMfDP6t$~P5()em?~v8loX0;t!#Lka*qrcQ3{bPgh;8`zO*&5gd*>1DL6F1z|v;;aqRdUw9l6_GaIu9mVEp76a%Gaif|-c9RHB_Cmi1)Tr! J2Rz{|{Q%s#L@@vW literal 0 HcmV?d00001 diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/small1.ico b/c:/Git/PeerCast.root/PeerCast/ui/win32/Simple_vp/small1.ico new file mode 100644 index 0000000000000000000000000000000000000000..fa5a5dcd8818b15900cbcef9bed4d88269fcdb31 GIT binary patch literal 318 zcmZvYF%H5o3`Kt>Br|qmX5@I;!bUdK6O`O0+@um0Kw>EpYIttShLiWd<2X?isblng zFOO3v9o)eyN9eRerLyWjNfJ{jHA6`usg%M-U8idG3>aQ=k<5h%VYT1VT4Di5qAbQ> z7PQZK^&#Kb3mWqHG+LU=&Us9J)`qd&9j|nGgw40BrKp7`d@jBr|qmX5@I;!bUd6UMbw95*I*XXpvCObJ}h=dH*|(6Gf3aM&I{} zxOCDf9HMfDP6t$~P5()em?~v8loX0;t!#Lka*qrcQ3{bPgh;8`zO*&5gd*>1DL6F1z|v;;aqRdUw9l6_GaIu9mVEp76a%Gaif|-c9RHB_Cmi1)Tr! J2Rz{|{Q%s#L@@vW literal 0 HcmV?d00001 diff --git a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj index aabe10d..8cbbb27 100644 --- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj +++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj @@ -17,6 +17,9 @@ + @@ -218,6 +221,108 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + @@ -772,8 +996,7 @@ BrowseInformation="1" WarningLevel="3" SuppressStartupBanner="true" - Detect64BitPortabilityProblems="true" - DebugInformationFormat="3" + DebugInformationFormat="4" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -840,7 +1599,254 @@ RelativePath="chkMemoryLeak.cpp" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +