• R/O
  • HTTP
  • SSH
  • HTTPS

PeerCastIM: Commit


Commit MetaInfo

Revisão57517bd8ae64e1720b35e0a578f5c47b0afe7653 (tree)
Hora2009-03-10 14:56:25
Autoreru <eru01@user...>
Commitereru

Mensagem de Log

サービス化の下準備途中
Vista(笑)のWindows Defenderがhostsのlocalhostを消すのに対応

Mudança Sumário

Diff

--- a/PeerCast.root/PeerCast/core/common/channel.cpp
+++ b/PeerCast.root/PeerCast/core/common/channel.cpp
@@ -3108,7 +3108,7 @@ void ChanMgr::playChannel(ChanInfo &info)
31083108
31093109 char str[128],fname[256],idStr[128];
31103110
3111- sprintf(str,"http://localhost:%d",servMgr->serverHost.port);
3111+ sprintf(str,"http://127.0.0.1:%d",servMgr->serverHost.port);
31123112 info.id.toStr(idStr);
31133113
31143114 PlayList::TYPE type;
--- 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 = 32;
48-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0032)";
49-static const char *PCX_VERSTRING_EX = "v0.1218(IM0032)";
47+static const int PCP_CLIENT_VERSION_EX_NUMBER = 33;
48+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0033)";
49+static const char *PCX_VERSTRING_EX = "v0.1218(IM0033)";
5050 #endif
5151
5252 // ------------------------------------------------
--- a/PeerCast.root/PeerCast/core/win32/wsys.cpp
+++ b/PeerCast.root/PeerCast/core/win32/wsys.cpp
@@ -124,7 +124,7 @@ void WSys::appMsg(long msg, long arg)
124124 void WSys::callLocalURL(const char *str,int port)
125125 {
126126 char cmd[512];
127- sprintf(cmd,"http://localhost:%d/%s",port,str);
127+ sprintf(cmd,"http://127.0.0.1:%d/%s",port,str);
128128 ShellExecute(mainWindow, NULL, cmd, NULL, NULL, SW_SHOWNORMAL);
129129 }
130130
--- a/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
+++ b/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
@@ -186,6 +186,82 @@ void LOG2(const char *fmt,...)
186186 va_end(ap);
187187 }
188188
189+// --------------------------------------------------
190+void WINAPI ServiceMain(DWORD argc, LPSTR *argv)
191+{
192+ //hInst = hInstance;
193+
194+ version_ex = 1; // PP版拡張機能を無効に←大嘘。バージョン表記をEXに
195+
196+ //iniFileName.set(".\\peercast.ini");
197+
198+ WIN32_FIND_DATA fd; //JP-EX
199+ HANDLE hFind; //JP-EX
200+
201+ OSVERSIONINFO osInfo; //JP-EX
202+ osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); //JP-EX
203+ GetVersionEx(&osInfo);
204+ if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
205+ winDistinctionNT = true;
206+ else
207+ winDistinctionNT = false;
208+
209+ // off by default now
210+ showGUI = false;
211+
212+ // get current path
213+ {
214+ TCHAR buf[1024];
215+ DWORD ret;
216+
217+ ret = GetModuleFileName(NULL, buf, sizeof(buf)/sizeof(TCHAR));
218+ if (ret)
219+ {
220+ exit(-1);
221+ }
222+ for (int i=_tcslen(buf); i>0; --i)
223+ {
224+ if (buf[i] == '\\')
225+ {
226+ buf[i+1] = '\0';
227+ break;
228+ }
229+ }
230+
231+ exePath = buf;
232+ }
233+
234+ iniFileName.set(exePath.cstr());
235+ iniFileName.append("\\peercast.ini");
236+
237+ _chdir(exePath);
238+
239+ peercastInst = new MyPeercastInst();
240+ peercastApp = new MyPeercastApp();
241+
242+ peercastInst->init();
243+
244+ LOG_DEBUG("Set OS Type: %s",winDistinctionNT?"WinNT":"Win9x");
245+
246+ if (peercastApp->clearTemp()) //JP-EX
247+ {
248+ DeleteFile("play.pls");
249+ hFind = FindFirstFile("*.asx",&fd);
250+ if (hFind != INVALID_HANDLE_VALUE)
251+ {
252+ do
253+ {
254+ DeleteFile((char *)&fd.cFileName);
255+ }
256+ while (FindNextFile(hFind,&fd));
257+
258+ FindClose(hFind);
259+ }
260+ }
261+
262+ peercastInst->saveSettings();
263+ peercastInst->quit();
264+}
189265
190266 // --------------------------------------------------
191267 int WinMainDummy(HINSTANCE hInstance,
@@ -411,8 +487,22 @@ int APIENTRY WinMain(HINSTANCE hInstance,
411487 _EXCEPTION_POINTERS *lpExcept;
412488 __try
413489 {
414- WinMainDummy(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
415-
490+#if 0
491+ // switch to service
492+ if (lstrlen(lpCmdLine) && strstr(lpCmdLine, "-D") != NULL)
493+ {
494+ SERVICE_TABLE_ENTRY svctbl[] = {
495+ {"PeerCast", (LPSERVICE_MAIN_FUNCTION)ServiceMain},
496+ {NULL, NULL}
497+ };
498+
499+ if (!StartServiceCtrlDispatcher(svctbl))
500+ {
501+ //SvcReportEvent(TEXT("StartServiceCtrlDispatcher"));
502+ }
503+ } else
504+#endif
505+ WinMainDummy(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
416506 } __except(lpExcept = GetExceptionInformation(), EXCEPTION_EXECUTE_HANDLER)
417507 {
418508 DWORD nParams;
--- a/c:/Git/PeerCast.root/PeerCast/core/common/channel.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/core/common/channel.cpp
@@ -3108,7 +3108,7 @@ void ChanMgr::playChannel(ChanInfo &info)
31083108
31093109 char str[128],fname[256],idStr[128];
31103110
3111- sprintf(str,"http://localhost:%d",servMgr->serverHost.port);
3111+ sprintf(str,"http://127.0.0.1:%d",servMgr->serverHost.port);
31123112 info.id.toStr(idStr);
31133113
31143114 PlayList::TYPE type;
--- 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 = 32;
48-static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0032)";
49-static const char *PCX_VERSTRING_EX = "v0.1218(IM0032)";
47+static const int PCP_CLIENT_VERSION_EX_NUMBER = 33;
48+static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0033)";
49+static const char *PCX_VERSTRING_EX = "v0.1218(IM0033)";
5050 #endif
5151
5252 // ------------------------------------------------
--- a/c:/Git/PeerCast.root/PeerCast/core/win32/wsys.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/core/win32/wsys.cpp
@@ -124,7 +124,7 @@ void WSys::appMsg(long msg, long arg)
124124 void WSys::callLocalURL(const char *str,int port)
125125 {
126126 char cmd[512];
127- sprintf(cmd,"http://localhost:%d/%s",port,str);
127+ sprintf(cmd,"http://127.0.0.1:%d/%s",port,str);
128128 ShellExecute(mainWindow, NULL, cmd, NULL, NULL, SW_SHOWNORMAL);
129129 }
130130
--- a/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
+++ b/c:/Git/PeerCast.root/PeerCast/ui/win32/simple/Simple.cpp
@@ -186,6 +186,82 @@ void LOG2(const char *fmt,...)
186186 va_end(ap);
187187 }
188188
189+// --------------------------------------------------
190+void WINAPI ServiceMain(DWORD argc, LPSTR *argv)
191+{
192+ //hInst = hInstance;
193+
194+ version_ex = 1; // PP版拡張機能を無効に←大嘘。バージョン表記をEXに
195+
196+ //iniFileName.set(".\\peercast.ini");
197+
198+ WIN32_FIND_DATA fd; //JP-EX
199+ HANDLE hFind; //JP-EX
200+
201+ OSVERSIONINFO osInfo; //JP-EX
202+ osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); //JP-EX
203+ GetVersionEx(&osInfo);
204+ if (osInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
205+ winDistinctionNT = true;
206+ else
207+ winDistinctionNT = false;
208+
209+ // off by default now
210+ showGUI = false;
211+
212+ // get current path
213+ {
214+ TCHAR buf[1024];
215+ DWORD ret;
216+
217+ ret = GetModuleFileName(NULL, buf, sizeof(buf)/sizeof(TCHAR));
218+ if (ret)
219+ {
220+ exit(-1);
221+ }
222+ for (int i=_tcslen(buf); i>0; --i)
223+ {
224+ if (buf[i] == '\\')
225+ {
226+ buf[i+1] = '\0';
227+ break;
228+ }
229+ }
230+
231+ exePath = buf;
232+ }
233+
234+ iniFileName.set(exePath.cstr());
235+ iniFileName.append("\\peercast.ini");
236+
237+ _chdir(exePath);
238+
239+ peercastInst = new MyPeercastInst();
240+ peercastApp = new MyPeercastApp();
241+
242+ peercastInst->init();
243+
244+ LOG_DEBUG("Set OS Type: %s",winDistinctionNT?"WinNT":"Win9x");
245+
246+ if (peercastApp->clearTemp()) //JP-EX
247+ {
248+ DeleteFile("play.pls");
249+ hFind = FindFirstFile("*.asx",&fd);
250+ if (hFind != INVALID_HANDLE_VALUE)
251+ {
252+ do
253+ {
254+ DeleteFile((char *)&fd.cFileName);
255+ }
256+ while (FindNextFile(hFind,&fd));
257+
258+ FindClose(hFind);
259+ }
260+ }
261+
262+ peercastInst->saveSettings();
263+ peercastInst->quit();
264+}
189265
190266 // --------------------------------------------------
191267 int WinMainDummy(HINSTANCE hInstance,
@@ -411,8 +487,22 @@ int APIENTRY WinMain(HINSTANCE hInstance,
411487 _EXCEPTION_POINTERS *lpExcept;
412488 __try
413489 {
414- WinMainDummy(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
415-
490+#if 0
491+ // switch to service
492+ if (lstrlen(lpCmdLine) && strstr(lpCmdLine, "-D") != NULL)
493+ {
494+ SERVICE_TABLE_ENTRY svctbl[] = {
495+ {"PeerCast", (LPSERVICE_MAIN_FUNCTION)ServiceMain},
496+ {NULL, NULL}
497+ };
498+
499+ if (!StartServiceCtrlDispatcher(svctbl))
500+ {
501+ //SvcReportEvent(TEXT("StartServiceCtrlDispatcher"));
502+ }
503+ } else
504+#endif
505+ WinMainDummy(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
416506 } __except(lpExcept = GetExceptionInformation(), EXCEPTION_EXECUTE_HANDLER)
417507 {
418508 DWORD nParams;
Show on old repository browser