• R/O
  • HTTP
  • SSH
  • HTTPS

PeerCastIM: Commit


Commit MetaInfo

Revisão0fb421d21251117d91eec0554b0d0ea1df525d33 (tree)
Hora2008-08-18 22:33:25
Autoreru <eru01@user...>
Commitereru

Mensagem de Log

SEH実装(一般保護例外対策)

Mudança Sumário

Diff

--- a/PeerCast.root/PeerCast/core/common/servmgr.cpp
+++ b/PeerCast.root/PeerCast/core/common/servmgr.cpp
@@ -140,6 +140,7 @@ ServMgr::ServMgr()
140140
141141 topmostGui = false;
142142 startWithGui = false;
143+ preventSS = false;
143144
144145 chanLog="";
145146
@@ -1106,6 +1107,7 @@ void ServMgr::saveSettings(const char *fn)
11061107
11071108 iniFile.writeBoolValue("topmostGui", servMgr->topmostGui);
11081109 iniFile.writeBoolValue("startWithGui", servMgr->startWithGui);
1110+ iniFile.writeBoolValue("preventSS", servMgr->preventSS);
11091111 #endif
11101112 int i;
11111113
@@ -1517,12 +1519,11 @@ void ServMgr::loadSettings(const char *fn)
15171519 servMgr->guiAntennaNotifyIcon = iniFile.getBoolValue();
15181520
15191521 else if (iniFile.isName("topmostGui"))
1520- {
15211522 servMgr->topmostGui = iniFile.getBoolValue();
1522- } else if (iniFile.isName("startWithGui"))
1523- {
1523+ else if (iniFile.isName("startWithGui"))
15241524 servMgr->startWithGui = iniFile.getBoolValue();
1525- }
1525+ else if (iniFile.isName("preventSS"))
1526+ servMgr->preventSS = iniFile.getBoolValue();
15261527 #endif
15271528
15281529 // debug
--- a/PeerCast.root/PeerCast/core/common/servmgr.h
+++ b/PeerCast.root/PeerCast/core/common/servmgr.h
@@ -419,6 +419,7 @@ public:
419419
420420 bool topmostGui; // 最前面
421421 bool startWithGui; // 起動時にGUI
422+ bool preventSS; // スクリーンセーバーを抑止
422423
423424 int maxRelaysIndexTxt; // for PCRaw (relay)
424425
--- a/PeerCast.root/PeerCast/core/common/version2.h
+++ b/PeerCast.root/PeerCast/core/common/version2.h
@@ -44,9 +44,9 @@ extern int version_ex; // PP
4444 #if 1 /* for VP extend version */
4545 //#define VERSION_EX 1
4646 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
47-static const int PCP_CLIENT_VERSION_EX_NUMBER = 27;
48-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-5-2)";
49-static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-5-2)";
47+static const int PCP_CLIENT_VERSION_EX_NUMBER = 28;
48+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0028)";
49+static const char *PCX_VERSTRING_EX = "v0.1218(IM0028)";
5050 #endif
5151
5252 // ------------------------------------------------
--- a/PeerCast.root/PeerCast/ui/win32/memo.txt
+++ b/PeerCast.root/PeerCast/ui/win32/memo.txt
@@ -3,3 +3,6 @@
33
44 ・リレー上限チェック
55   bool Channel::isFull(); (channel.cpp)
6+
7+・下流への転送
8+  void Servent::sendPCPChannel()
--- a/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
+++ b/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
@@ -80,6 +80,7 @@ ULONG_PTR gdiplusToken;
8080 extern Stats stats;
8181 ThreadInfo trafficDlgThread;
8282 HWND trafficDlg = NULL;
83+FileStream fs;
8384
8485 // プロトタイプ宣言
8586 void createGUI(HWND);
@@ -178,20 +179,19 @@ HWND chWnd=NULL;
178179 void LOG2(const char *fmt,...)
179180 {
180181 va_list ap;
181- va_start(ap, fmt);
182+ va_start(ap, fmt);
182183 char str[4096];
183184 vsprintf(str,fmt,ap);
184185 OutputDebugString(str);
185- va_end(ap);
186+ va_end(ap);
186187 }
187188
188189
189-
190-// ---------------------------------------
191-int APIENTRY WinMain(HINSTANCE hInstance,
192- HINSTANCE hPrevInstance,
193- LPSTR lpCmdLine,
194- int nCmdShow)
190+// --------------------------------------------------
191+int WinMainDummy(HINSTANCE hInstance,
192+ HINSTANCE hPrevInstance,
193+ LPSTR lpCmdLine,
194+ int nCmdShow)
195195 {
196196 #ifdef _DEBUG
197197 // memory leak check
@@ -270,7 +270,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
270270 *end = 0;
271271 }
272272
273-
273+
274274 if (strnicmp(tmpURL,"peercast://",11)==0)
275275 {
276276 if (strnicmp(tmpURL+11,"pls/",4)==0)
@@ -295,13 +295,13 @@ int APIENTRY WinMain(HINSTANCE hInstance,
295295 if (!allowMulti)
296296 {
297297 HANDLE mutex = CreateMutex(NULL,TRUE,szWindowClass);
298-
298+
299299 if (GetLastError() == ERROR_ALREADY_EXISTS)
300300 {
301301 HWND oldWin = FindWindow(szWindowClass,NULL);
302302 if (oldWin)
303303 {
304- //SendMessage(oldWin,WM_SHOWGUI,0,0);
304+ //SendMessage(oldWin,WM_SHOWGUI,0,0);
305305 if (killMe)
306306 {
307307 SendMessage(oldWin,WM_DESTROY,0,0);
@@ -326,7 +326,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
326326
327327 if (killMe)
328328 return 0;
329-
329+
330330 MyRegisterClass(hInstance);
331331 MyRegisterClass2(hInstance);
332332
@@ -390,7 +390,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
390390 }
391391 }
392392
393- Shell_NotifyIcon(NIM_DELETE, (NOTIFYICONDATA*)&trayIcon);
393+ Shell_NotifyIcon(NIM_DELETE, (NOTIFYICONDATA*)&trayIcon);
394394
395395 peercastInst->saveSettings();
396396 peercastInst->quit();
@@ -401,6 +401,242 @@ int APIENTRY WinMain(HINSTANCE hInstance,
401401 }
402402
403403
404+// ---------------------------------------
405+int APIENTRY WinMain(HINSTANCE hInstance,
406+ HINSTANCE hPrevInstance,
407+ LPSTR lpCmdLine,
408+ int nCmdShow)
409+{
410+ // SEH handling
411+ __try
412+ {
413+#if 0
414+#ifdef _DEBUG
415+ // memory leak check
416+ ::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
417+#endif
418+
419+ char tmpURL[8192];
420+ tmpURL[0]=0;
421+ char *chanURL=NULL;
422+
423+ hInst = hInstance;
424+
425+ version_ex = 1; // PP版拡張機能を無効に←大嘘。バージョン表記をEXに
426+
427+ iniFileName.set(".\\peercast.ini");
428+
429+ WIN32_FIND_DATA fd; //JP-EX
430+ HANDLE hFind; //JP-EX
431+
432+ OSVERSIONINFO osInfo; //JP-EX
433+ osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); //JP-EX
434+ GetVersionEx(&osInfo);
435+ if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
436+ winDistinctionNT = true;
437+ else
438+ winDistinctionNT = false;
439+
440+ // off by default now
441+ showGUI = false;
442+
443+ if (strlen(lpCmdLine) > 0)
444+ {
445+ char *p;
446+ if ((p = strstr(lpCmdLine,"-inifile"))!=NULL)
447+ iniFileName.setFromString(p+8);
448+
449+ if (strstr(lpCmdLine,"-zen"))
450+ showGUI = false;
451+
452+ if (strstr(lpCmdLine,"-multi"))
453+ allowMulti = true;
454+
455+ if (strstr(lpCmdLine,"-kill"))
456+ killMe = true;
457+
458+ if ((p = strstr(lpCmdLine,"-url"))!=NULL)
459+ {
460+ p+=4;
461+ while (*p)
462+ {
463+ if (*p=='"')
464+ {
465+ p++;
466+ break;
467+ }
468+ if (*p != ' ')
469+ break;
470+ p++;
471+ }
472+ if (*p)
473+ strncpy(tmpURL,p,sizeof(tmpURL)-1);
474+ }
475+ }
476+
477+ // get current path
478+ {
479+ exePath = iniFileName;
480+ char *s = exePath.cstr();
481+ char *end = NULL;
482+ while (*s)
483+ {
484+ if (*s++ == '\\')
485+ end = s;
486+ }
487+ if (end)
488+ *end = 0;
489+ }
490+
491+
492+ if (strnicmp(tmpURL,"peercast://",11)==0)
493+ {
494+ if (strnicmp(tmpURL+11,"pls/",4)==0)
495+ chanURL = tmpURL+11+4;
496+ else
497+ chanURL = tmpURL+11;
498+ showGUI = false;
499+ }
500+
501+
502+ MSG msg;
503+ HACCEL hAccelTable;
504+
505+ // Initialize global strings
506+ //LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
507+ //LoadString(hInstance, IDC_APP_TITLE, szWindowClass, MAX_LOADSTRING);
508+
509+ strcpy(szTitle,"PeerCast");
510+ strcpy(szWindowClass,"PeerCast");
511+ strcpy(szWindowClass2,"Main");
512+
513+ if (!allowMulti)
514+ {
515+ HANDLE mutex = CreateMutex(NULL,TRUE,szWindowClass);
516+
517+ if (GetLastError() == ERROR_ALREADY_EXISTS)
518+ {
519+ HWND oldWin = FindWindow(szWindowClass,NULL);
520+ if (oldWin)
521+ {
522+ //SendMessage(oldWin,WM_SHOWGUI,0,0);
523+ if (killMe)
524+ {
525+ SendMessage(oldWin,WM_DESTROY,0,0);
526+ return 0;
527+ }
528+
529+ if (chanURL)
530+ {
531+ COPYDATASTRUCT copy;
532+ copy.dwData = WM_PLAYCHANNEL;
533+ copy.cbData = strlen(chanURL)+1; // plus null term
534+ copy.lpData = chanURL;
535+ SendMessage(oldWin,WM_COPYDATA,NULL,(LPARAM)&copy);
536+ }else{
537+ if (showGUI)
538+ SendMessage(oldWin,WM_SHOWGUI,0,0);
539+ }
540+ }
541+ return 0;
542+ }
543+ }
544+
545+ if (killMe)
546+ return 0;
547+
548+ MyRegisterClass(hInstance);
549+ MyRegisterClass2(hInstance);
550+
551+ // Perform application initialization:
552+ if (!InitInstance (hInstance, nCmdShow))
553+ return FALSE;
554+
555+ peercastInst = new MyPeercastInst();
556+ peercastApp = new MyPeercastApp();
557+
558+ peercastInst->init();
559+
560+ LOG_DEBUG("Set OS Type: %s",winDistinctionNT?"WinNT":"Win9x");
561+
562+ if (peercastApp->clearTemp()) //JP-EX
563+ {
564+ DeleteFile("play.pls");
565+ hFind = FindFirstFile("*.asx",&fd);
566+ if (hFind != INVALID_HANDLE_VALUE)
567+ {
568+ do
569+ {
570+ DeleteFile((char *)&fd.cFileName);
571+ }
572+ while (FindNextFile(hFind,&fd));
573+
574+ FindClose(hFind);
575+ }
576+ }
577+
578+ if (chanURL)
579+ {
580+ ChanInfo info;
581+ servMgr->procConnectArgs(chanURL,info);
582+ chanMgr->findAndPlayChannel(info,false);
583+ }
584+
585+ hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SIMPLE);
586+
587+ // setup menu notifes
588+ int mask = peercastInst->getNotifyMask();
589+ if (mask & ServMgr::NT_PEERCAST)
590+ CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_PEERCAST,MF_CHECKED|MF_BYCOMMAND);
591+ if (mask & ServMgr::NT_BROADCASTERS)
592+ CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_BROADCASTERS,MF_CHECKED|MF_BYCOMMAND);
593+ if (mask & ServMgr::NT_TRACKINFO)
594+ CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_TRACKINFO,MF_CHECKED|MF_BYCOMMAND);
595+
596+ if (servMgr->startWithGui)
597+ {
598+ createGUI((HWND)0);
599+ }
600+
601+ // Main message loop:
602+ while (GetMessage(&msg, NULL, 0, 0))
603+ {
604+ if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
605+ {
606+ TranslateMessage(&msg);
607+ DispatchMessage(&msg);
608+ }
609+ }
610+
611+ Shell_NotifyIcon(NIM_DELETE, (NOTIFYICONDATA*)&trayIcon);
612+
613+ peercastInst->saveSettings();
614+ peercastInst->quit();
615+
616+ Gdiplus::GdiplusShutdown(gdiplusToken);
617+
618+ return msg.wParam;
619+#endif
620+ WinMainDummy(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
621+
622+ } __except(EXCEPTION_EXECUTE_HANDLER)
623+ {
624+ fs.openWriteReplace(".\\dump.html");
625+ sys->logBuf->dumpHTML(fs);
626+ fs.close();
627+
628+ MessageBox(NULL, "一般保護違反の為、プログラムは強制終了されます。\n"
629+ "問題解決のためにダンプデータ(dump.html)を提供してください。", "SEH",
630+ MB_OK|MB_ICONWARNING);
631+
632+ return GetExceptionCode();
633+ }
634+
635+ // dummy
636+ return 0;
637+}
638+
639+
404640
405641 //
406642 // FUNCTION: MyRegisterClass()
@@ -1037,6 +1273,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
10371273 CheckMenuItem(trayMenu, ID_POPUP_START_WITH_GUI, MF_UNCHECKED|MF_BYCOMMAND);
10381274 }
10391275
1276+ // スクリーンセーバー抑止
1277+ if (servMgr->preventSS)
1278+ {
1279+ CheckMenuItem(trayMenu, ID_POPUP_PREVENT_SS, MF_CHECKED|MF_BYCOMMAND);
1280+ } else
1281+ {
1282+ CheckMenuItem(trayMenu, ID_POPUP_PREVENT_SS, MF_UNCHECKED|MF_BYCOMMAND);
1283+ }
1284+
10401285 SetForegroundWindow(hWnd);
10411286 bool skipMenu=false;
10421287
@@ -1287,6 +1532,20 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
12871532 }
12881533 break;
12891534
1535+ case ID_POPUP_PREVENT_SS:
1536+ // スクリーンセーバー抑止
1537+ if (servMgr->preventSS)
1538+ {
1539+ servMgr->preventSS = false;
1540+ CheckMenuItem(trayMenu, ID_POPUP_PREVENT_SS, MF_UNCHECKED|MF_BYCOMMAND);
1541+ } else
1542+ {
1543+ servMgr->preventSS = true;
1544+ CheckMenuItem(trayMenu, ID_POPUP_PREVENT_SS, MF_CHECKED|MF_BYCOMMAND);
1545+ }
1546+ peercastInst->saveSettings();
1547+ break;
1548+
12901549 case ID_POPUP_EXIT_CONFIRM:
12911550 case IDM_EXIT:
12921551 DestroyWindow(hWnd);
@@ -1298,6 +1557,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
12981557 case WM_DESTROY:
12991558 PostQuitMessage(0);
13001559 break;
1560+
1561+ case WM_SYSCOMMAND:
1562+ // なんかアクティブじゃないと送られてこないらしい
1563+ if (servMgr->preventSS && (wParam == SC_SCREENSAVE) && chanMgr->isBroadcasting())
1564+ return 1;
1565+ else
1566+ return DefWindowProc(hWnd, message, wParam, lParam);
1567+ break;
1568+
13011569 default:
13021570 return DefWindowProc(hWnd, message, wParam, lParam);
13031571 }
--- a/PeerCast.root/PeerCast/ui/win32/simple/Simple.rc
+++ b/PeerCast.root/PeerCast/ui/win32/simple/Simple.rc
@@ -113,6 +113,7 @@ BEGIN
113113 MENUITEM "再接続時下流維持", ID_POPUP_SHOWGUI, CHECKED
114114 MENUITEM "常に手前に表示", ID_POPUP_TOPMOST
115115 MENUITEM "起動時、GUIを表示", ID_POPUP_START_WITH_GUI
116+ MENUITEM "配信時、ScreenSaverを抑止", ID_POPUP_PREVENT_SS, GRAYED
116117 END
117118 MENUITEM SEPARATOR
118119 POPUP "終了"
--- a/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj
+++ b/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj
@@ -158,6 +158,7 @@
158158 AdditionalIncludeDirectories="../../../core,../../../core/common"
159159 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
160160 StringPooling="true"
161+ ExceptionHandling="1"
161162 RuntimeLibrary="0"
162163 EnableFunctionLevelLinking="true"
163164 PrecompiledHeaderFile=".\Release/Simple.pch"
--- a/PeerCast.root/PeerCast/ui/win32/simple/resource.h
+++ b/PeerCast.root/PeerCast/ui/win32/simple/resource.h
@@ -108,6 +108,8 @@
108108 #define ID_POPUP_START_WITH_GUI 32830
109109 #define ID_POPUP_32831 32831
110110 #define ID_POPUP_TRAFFIC 32832
111+#define ID_32833 32833
112+#define ID_POPUP_PREVENT_SS 32834
111113 #define IDC_STATIC -1
112114
113115 // Next default values for new objects
@@ -115,7 +117,7 @@
115117 #ifdef APSTUDIO_INVOKED
116118 #ifndef APSTUDIO_READONLY_SYMBOLS
117119 #define _APS_NEXT_RESOURCE_VALUE 144
118-#define _APS_NEXT_COMMAND_VALUE 32833
120+#define _APS_NEXT_COMMAND_VALUE 32835
119121 #define _APS_NEXT_CONTROL_VALUE 1025
120122 #define _APS_NEXT_SYMED_VALUE 110
121123 #endif
--- a/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.cpp
@@ -140,6 +140,7 @@ ServMgr::ServMgr()
140140
141141 topmostGui = false;
142142 startWithGui = false;
143+ preventSS = false;
143144
144145 chanLog="";
145146
@@ -1106,6 +1107,7 @@ void ServMgr::saveSettings(const char *fn)
11061107
11071108 iniFile.writeBoolValue("topmostGui", servMgr->topmostGui);
11081109 iniFile.writeBoolValue("startWithGui", servMgr->startWithGui);
1110+ iniFile.writeBoolValue("preventSS", servMgr->preventSS);
11091111 #endif
11101112 int i;
11111113
@@ -1517,12 +1519,11 @@ void ServMgr::loadSettings(const char *fn)
15171519 servMgr->guiAntennaNotifyIcon = iniFile.getBoolValue();
15181520
15191521 else if (iniFile.isName("topmostGui"))
1520- {
15211522 servMgr->topmostGui = iniFile.getBoolValue();
1522- } else if (iniFile.isName("startWithGui"))
1523- {
1523+ else if (iniFile.isName("startWithGui"))
15241524 servMgr->startWithGui = iniFile.getBoolValue();
1525- }
1525+ else if (iniFile.isName("preventSS"))
1526+ servMgr->preventSS = iniFile.getBoolValue();
15261527 #endif
15271528
15281529 // debug
--- a/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/servmgr.h
@@ -419,6 +419,7 @@ public:
419419
420420 bool topmostGui; // 最前面
421421 bool startWithGui; // 起動時にGUI
422+ bool preventSS; // スクリーンセーバーを抑止
422423
423424 int maxRelaysIndexTxt; // for PCRaw (relay)
424425
--- a/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/version2.h
@@ -44,9 +44,9 @@ extern int version_ex; // PP
4444 #if 1 /* for VP extend version */
4545 //#define VERSION_EX 1
4646 static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only
47-static const int PCP_CLIENT_VERSION_EX_NUMBER = 27;
48-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027-5-2)";
49-static const char *PCX_VERSTRING_EX = "v0.1218(IM0027-5-2)";
47+static const int PCP_CLIENT_VERSION_EX_NUMBER = 28;
48+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0028)";
49+static const char *PCX_VERSTRING_EX = "v0.1218(IM0028)";
5050 #endif
5151
5252 // ------------------------------------------------
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/memo.txt
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/memo.txt
@@ -3,3 +3,6 @@
33
44 ・リレー上限チェック
55   bool Channel::isFull(); (channel.cpp)
6+
7+・下流への転送
8+  void Servent::sendPCPChannel()
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
@@ -80,6 +80,7 @@ ULONG_PTR gdiplusToken;
8080 extern Stats stats;
8181 ThreadInfo trafficDlgThread;
8282 HWND trafficDlg = NULL;
83+FileStream fs;
8384
8485 // プロトタイプ宣言
8586 void createGUI(HWND);
@@ -178,20 +179,19 @@ HWND chWnd=NULL;
178179 void LOG2(const char *fmt,...)
179180 {
180181 va_list ap;
181- va_start(ap, fmt);
182+ va_start(ap, fmt);
182183 char str[4096];
183184 vsprintf(str,fmt,ap);
184185 OutputDebugString(str);
185- va_end(ap);
186+ va_end(ap);
186187 }
187188
188189
189-
190-// ---------------------------------------
191-int APIENTRY WinMain(HINSTANCE hInstance,
192- HINSTANCE hPrevInstance,
193- LPSTR lpCmdLine,
194- int nCmdShow)
190+// --------------------------------------------------
191+int WinMainDummy(HINSTANCE hInstance,
192+ HINSTANCE hPrevInstance,
193+ LPSTR lpCmdLine,
194+ int nCmdShow)
195195 {
196196 #ifdef _DEBUG
197197 // memory leak check
@@ -270,7 +270,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
270270 *end = 0;
271271 }
272272
273-
273+
274274 if (strnicmp(tmpURL,"peercast://",11)==0)
275275 {
276276 if (strnicmp(tmpURL+11,"pls/",4)==0)
@@ -295,13 +295,13 @@ int APIENTRY WinMain(HINSTANCE hInstance,
295295 if (!allowMulti)
296296 {
297297 HANDLE mutex = CreateMutex(NULL,TRUE,szWindowClass);
298-
298+
299299 if (GetLastError() == ERROR_ALREADY_EXISTS)
300300 {
301301 HWND oldWin = FindWindow(szWindowClass,NULL);
302302 if (oldWin)
303303 {
304- //SendMessage(oldWin,WM_SHOWGUI,0,0);
304+ //SendMessage(oldWin,WM_SHOWGUI,0,0);
305305 if (killMe)
306306 {
307307 SendMessage(oldWin,WM_DESTROY,0,0);
@@ -326,7 +326,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
326326
327327 if (killMe)
328328 return 0;
329-
329+
330330 MyRegisterClass(hInstance);
331331 MyRegisterClass2(hInstance);
332332
@@ -390,7 +390,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
390390 }
391391 }
392392
393- Shell_NotifyIcon(NIM_DELETE, (NOTIFYICONDATA*)&trayIcon);
393+ Shell_NotifyIcon(NIM_DELETE, (NOTIFYICONDATA*)&trayIcon);
394394
395395 peercastInst->saveSettings();
396396 peercastInst->quit();
@@ -401,6 +401,242 @@ int APIENTRY WinMain(HINSTANCE hInstance,
401401 }
402402
403403
404+// ---------------------------------------
405+int APIENTRY WinMain(HINSTANCE hInstance,
406+ HINSTANCE hPrevInstance,
407+ LPSTR lpCmdLine,
408+ int nCmdShow)
409+{
410+ // SEH handling
411+ __try
412+ {
413+#if 0
414+#ifdef _DEBUG
415+ // memory leak check
416+ ::_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
417+#endif
418+
419+ char tmpURL[8192];
420+ tmpURL[0]=0;
421+ char *chanURL=NULL;
422+
423+ hInst = hInstance;
424+
425+ version_ex = 1; // PP版拡張機能を無効に←大嘘。バージョン表記をEXに
426+
427+ iniFileName.set(".\\peercast.ini");
428+
429+ WIN32_FIND_DATA fd; //JP-EX
430+ HANDLE hFind; //JP-EX
431+
432+ OSVERSIONINFO osInfo; //JP-EX
433+ osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); //JP-EX
434+ GetVersionEx(&osInfo);
435+ if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
436+ winDistinctionNT = true;
437+ else
438+ winDistinctionNT = false;
439+
440+ // off by default now
441+ showGUI = false;
442+
443+ if (strlen(lpCmdLine) > 0)
444+ {
445+ char *p;
446+ if ((p = strstr(lpCmdLine,"-inifile"))!=NULL)
447+ iniFileName.setFromString(p+8);
448+
449+ if (strstr(lpCmdLine,"-zen"))
450+ showGUI = false;
451+
452+ if (strstr(lpCmdLine,"-multi"))
453+ allowMulti = true;
454+
455+ if (strstr(lpCmdLine,"-kill"))
456+ killMe = true;
457+
458+ if ((p = strstr(lpCmdLine,"-url"))!=NULL)
459+ {
460+ p+=4;
461+ while (*p)
462+ {
463+ if (*p=='"')
464+ {
465+ p++;
466+ break;
467+ }
468+ if (*p != ' ')
469+ break;
470+ p++;
471+ }
472+ if (*p)
473+ strncpy(tmpURL,p,sizeof(tmpURL)-1);
474+ }
475+ }
476+
477+ // get current path
478+ {
479+ exePath = iniFileName;
480+ char *s = exePath.cstr();
481+ char *end = NULL;
482+ while (*s)
483+ {
484+ if (*s++ == '\\')
485+ end = s;
486+ }
487+ if (end)
488+ *end = 0;
489+ }
490+
491+
492+ if (strnicmp(tmpURL,"peercast://",11)==0)
493+ {
494+ if (strnicmp(tmpURL+11,"pls/",4)==0)
495+ chanURL = tmpURL+11+4;
496+ else
497+ chanURL = tmpURL+11;
498+ showGUI = false;
499+ }
500+
501+
502+ MSG msg;
503+ HACCEL hAccelTable;
504+
505+ // Initialize global strings
506+ //LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
507+ //LoadString(hInstance, IDC_APP_TITLE, szWindowClass, MAX_LOADSTRING);
508+
509+ strcpy(szTitle,"PeerCast");
510+ strcpy(szWindowClass,"PeerCast");
511+ strcpy(szWindowClass2,"Main");
512+
513+ if (!allowMulti)
514+ {
515+ HANDLE mutex = CreateMutex(NULL,TRUE,szWindowClass);
516+
517+ if (GetLastError() == ERROR_ALREADY_EXISTS)
518+ {
519+ HWND oldWin = FindWindow(szWindowClass,NULL);
520+ if (oldWin)
521+ {
522+ //SendMessage(oldWin,WM_SHOWGUI,0,0);
523+ if (killMe)
524+ {
525+ SendMessage(oldWin,WM_DESTROY,0,0);
526+ return 0;
527+ }
528+
529+ if (chanURL)
530+ {
531+ COPYDATASTRUCT copy;
532+ copy.dwData = WM_PLAYCHANNEL;
533+ copy.cbData = strlen(chanURL)+1; // plus null term
534+ copy.lpData = chanURL;
535+ SendMessage(oldWin,WM_COPYDATA,NULL,(LPARAM)&copy);
536+ }else{
537+ if (showGUI)
538+ SendMessage(oldWin,WM_SHOWGUI,0,0);
539+ }
540+ }
541+ return 0;
542+ }
543+ }
544+
545+ if (killMe)
546+ return 0;
547+
548+ MyRegisterClass(hInstance);
549+ MyRegisterClass2(hInstance);
550+
551+ // Perform application initialization:
552+ if (!InitInstance (hInstance, nCmdShow))
553+ return FALSE;
554+
555+ peercastInst = new MyPeercastInst();
556+ peercastApp = new MyPeercastApp();
557+
558+ peercastInst->init();
559+
560+ LOG_DEBUG("Set OS Type: %s",winDistinctionNT?"WinNT":"Win9x");
561+
562+ if (peercastApp->clearTemp()) //JP-EX
563+ {
564+ DeleteFile("play.pls");
565+ hFind = FindFirstFile("*.asx",&fd);
566+ if (hFind != INVALID_HANDLE_VALUE)
567+ {
568+ do
569+ {
570+ DeleteFile((char *)&fd.cFileName);
571+ }
572+ while (FindNextFile(hFind,&fd));
573+
574+ FindClose(hFind);
575+ }
576+ }
577+
578+ if (chanURL)
579+ {
580+ ChanInfo info;
581+ servMgr->procConnectArgs(chanURL,info);
582+ chanMgr->findAndPlayChannel(info,false);
583+ }
584+
585+ hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SIMPLE);
586+
587+ // setup menu notifes
588+ int mask = peercastInst->getNotifyMask();
589+ if (mask & ServMgr::NT_PEERCAST)
590+ CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_PEERCAST,MF_CHECKED|MF_BYCOMMAND);
591+ if (mask & ServMgr::NT_BROADCASTERS)
592+ CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_BROADCASTERS,MF_CHECKED|MF_BYCOMMAND);
593+ if (mask & ServMgr::NT_TRACKINFO)
594+ CheckMenuItem(trayMenu,ID_POPUP_SHOWMESSAGES_TRACKINFO,MF_CHECKED|MF_BYCOMMAND);
595+
596+ if (servMgr->startWithGui)
597+ {
598+ createGUI((HWND)0);
599+ }
600+
601+ // Main message loop:
602+ while (GetMessage(&msg, NULL, 0, 0))
603+ {
604+ if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
605+ {
606+ TranslateMessage(&msg);
607+ DispatchMessage(&msg);
608+ }
609+ }
610+
611+ Shell_NotifyIcon(NIM_DELETE, (NOTIFYICONDATA*)&trayIcon);
612+
613+ peercastInst->saveSettings();
614+ peercastInst->quit();
615+
616+ Gdiplus::GdiplusShutdown(gdiplusToken);
617+
618+ return msg.wParam;
619+#endif
620+ WinMainDummy(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
621+
622+ } __except(EXCEPTION_EXECUTE_HANDLER)
623+ {
624+ fs.openWriteReplace(".\\dump.html");
625+ sys->logBuf->dumpHTML(fs);
626+ fs.close();
627+
628+ MessageBox(NULL, "一般保護違反の為、プログラムは強制終了されます。\n"
629+ "問題解決のためにダンプデータ(dump.html)を提供してください。", "SEH",
630+ MB_OK|MB_ICONWARNING);
631+
632+ return GetExceptionCode();
633+ }
634+
635+ // dummy
636+ return 0;
637+}
638+
639+
404640
405641 //
406642 // FUNCTION: MyRegisterClass()
@@ -1037,6 +1273,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
10371273 CheckMenuItem(trayMenu, ID_POPUP_START_WITH_GUI, MF_UNCHECKED|MF_BYCOMMAND);
10381274 }
10391275
1276+ // スクリーンセーバー抑止
1277+ if (servMgr->preventSS)
1278+ {
1279+ CheckMenuItem(trayMenu, ID_POPUP_PREVENT_SS, MF_CHECKED|MF_BYCOMMAND);
1280+ } else
1281+ {
1282+ CheckMenuItem(trayMenu, ID_POPUP_PREVENT_SS, MF_UNCHECKED|MF_BYCOMMAND);
1283+ }
1284+
10401285 SetForegroundWindow(hWnd);
10411286 bool skipMenu=false;
10421287
@@ -1287,6 +1532,20 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
12871532 }
12881533 break;
12891534
1535+ case ID_POPUP_PREVENT_SS:
1536+ // スクリーンセーバー抑止
1537+ if (servMgr->preventSS)
1538+ {
1539+ servMgr->preventSS = false;
1540+ CheckMenuItem(trayMenu, ID_POPUP_PREVENT_SS, MF_UNCHECKED|MF_BYCOMMAND);
1541+ } else
1542+ {
1543+ servMgr->preventSS = true;
1544+ CheckMenuItem(trayMenu, ID_POPUP_PREVENT_SS, MF_CHECKED|MF_BYCOMMAND);
1545+ }
1546+ peercastInst->saveSettings();
1547+ break;
1548+
12901549 case ID_POPUP_EXIT_CONFIRM:
12911550 case IDM_EXIT:
12921551 DestroyWindow(hWnd);
@@ -1298,6 +1557,15 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
12981557 case WM_DESTROY:
12991558 PostQuitMessage(0);
13001559 break;
1560+
1561+ case WM_SYSCOMMAND:
1562+ // なんかアクティブじゃないと送られてこないらしい
1563+ if (servMgr->preventSS && (wParam == SC_SCREENSAVE) && chanMgr->isBroadcasting())
1564+ return 1;
1565+ else
1566+ return DefWindowProc(hWnd, message, wParam, lParam);
1567+ break;
1568+
13011569 default:
13021570 return DefWindowProc(hWnd, message, wParam, lParam);
13031571 }
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.rc
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.rc
@@ -113,6 +113,7 @@ BEGIN
113113 MENUITEM "再接続時下流維持", ID_POPUP_SHOWGUI, CHECKED
114114 MENUITEM "常に手前に表示", ID_POPUP_TOPMOST
115115 MENUITEM "起動時、GUIを表示", ID_POPUP_START_WITH_GUI
116+ MENUITEM "配信時、ScreenSaverを抑止", ID_POPUP_PREVENT_SS, GRAYED
116117 END
117118 MENUITEM SEPARATOR
118119 POPUP "終了"
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.vcproj
@@ -158,6 +158,7 @@
158158 AdditionalIncludeDirectories="../../../core,../../../core/common"
159159 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
160160 StringPooling="true"
161+ ExceptionHandling="1"
161162 RuntimeLibrary="0"
162163 EnableFunctionLevelLinking="true"
163164 PrecompiledHeaderFile=".\Release/Simple.pch"
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/resource.h
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/resource.h
@@ -108,6 +108,8 @@
108108 #define ID_POPUP_START_WITH_GUI 32830
109109 #define ID_POPUP_32831 32831
110110 #define ID_POPUP_TRAFFIC 32832
111+#define ID_32833 32833
112+#define ID_POPUP_PREVENT_SS 32834
111113 #define IDC_STATIC -1
112114
113115 // Next default values for new objects
@@ -115,7 +117,7 @@
115117 #ifdef APSTUDIO_INVOKED
116118 #ifndef APSTUDIO_READONLY_SYMBOLS
117119 #define _APS_NEXT_RESOURCE_VALUE 144
118-#define _APS_NEXT_COMMAND_VALUE 32833
120+#define _APS_NEXT_COMMAND_VALUE 32835
119121 #define _APS_NEXT_CONTROL_VALUE 1025
120122 #define _APS_NEXT_SYMED_VALUE 110
121123 #endif
Show on old repository browser