修訂 | 68ed879837ccc3d81e0782684506f8ff5e0d7bc4 (tree) |
---|---|
時間 | 2007-12-30 00:19:04 |
作者 | eru <eru01@user...> |
Commiter | eru |
リレー数上限をチャンネル毎に設定出来るように修正。
@@ -143,7 +143,7 @@ int channel_count=1; | ||
143 | 143 | // ----------------------------------------------------------------------------- |
144 | 144 | // Initialise the channel to its default settings of unallocated and reset. |
145 | 145 | // ----------------------------------------------------------------------------- |
146 | -Channel::Channel() | |
146 | +Channel::Channel() : maxRelays(0) | |
147 | 147 | { |
148 | 148 | next = NULL; |
149 | 149 | reset(); |
@@ -306,7 +306,14 @@ bool Channel::isFull() | ||
306 | 306 | } |
307 | 307 | // for PCRaw (relay) end. |
308 | 308 | |
309 | - return chanMgr->maxRelaysPerChannel ? localRelays() >= chanMgr->maxRelaysPerChannel : false; | |
309 | + // チャンネル固有のリレー上限設定があるか | |
310 | + if (maxRelays > 0) | |
311 | + { | |
312 | + return localRelays() >= maxRelays; | |
313 | + } else | |
314 | + { | |
315 | + return chanMgr->maxRelaysPerChannel ? localRelays() >= chanMgr->maxRelaysPerChannel : false; | |
316 | + } | |
310 | 317 | } |
311 | 318 | // ----------------------------------- |
312 | 319 | int Channel::localRelays() |
@@ -532,6 +532,8 @@ public: | ||
532 | 532 | bool bumped; |
533 | 533 | unsigned int lastSkipTime; |
534 | 534 | unsigned int lastStopTime; |
535 | + | |
536 | + int maxRelays; // チャンネル固有のリレー最大数(コンストラクタで初期化) | |
535 | 537 | }; |
536 | 538 | |
537 | 539 | // ---------------------------------- |
@@ -42,9 +42,9 @@ static const char *PCX_VERSTRING = "v0.1218(VP0026)"; | ||
42 | 42 | #if 1 /* for VP extend version */ |
43 | 43 | #define VERSION_EX 1 |
44 | 44 | static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only |
45 | -static const int PCP_CLIENT_VERSION_EX_NUMBER = 26; | |
46 | -static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0026-2)"; | |
47 | -static const char *PCX_VERSTRING_EX = "v0.1218(IM0026-2)"; | |
45 | +static const int PCP_CLIENT_VERSION_EX_NUMBER = 27; | |
46 | +static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027)"; | |
47 | +static const char *PCX_VERSTRING_EX = "v0.1218(IM0027)"; | |
48 | 48 | #endif |
49 | 49 | |
50 | 50 | // ------------------------------------------------ |
@@ -8,6 +8,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simple", "simple\Simple.vcp | ||
8 | 8 | {7BCFE65B-8757-45F3-8DFB-1E7D683950D1} = {7BCFE65B-8757-45F3-8DFB-1E7D683950D1} |
9 | 9 | EndProjectSection |
10 | 10 | EndProject |
11 | +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{00D364AE-DB2F-4109-A925-31B4F129D613}" | |
12 | + ProjectSection(SolutionItems) = preProject | |
13 | + memo.txt = memo.txt | |
14 | + EndProjectSection | |
15 | +EndProject | |
11 | 16 | Global |
12 | 17 | GlobalSection(SourceCodeControl) = preSolution |
13 | 18 | SccNumberOfProjects = 3 |
@@ -0,0 +1,5 @@ | ||
1 | +・7144/7145のListenポートを捌くスレッド | |
2 | + int Servent::serverProc(ThreadInfo *thread); (servent.cpp) | |
3 | + | |
4 | +・リレー上限チェック | |
5 | + bool Channel::isFull(); (channel.cpp) |
@@ -1365,6 +1365,15 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa | ||
1365 | 1365 | { |
1366 | 1366 | SendDlgItemMessage(hDlg,IDC_EDIT_STATUS,WM_SETTEXT,0,(LONG)ch->getStatusStr()); |
1367 | 1367 | SendDlgItemMessage(hDlg, IDC_KEEP,BM_SETCHECK, ch->stayConnected, 0); |
1368 | + | |
1369 | + // 現在の固有リレー上限設定を表示(0は無効) | |
1370 | + ::SetDlgItemInt(hDlg, IDC_EDIT_MAXRELAYS, ch->maxRelays, false); | |
1371 | + if (isIndexTxt(ch)) | |
1372 | + { | |
1373 | + // index.txtなので無効に | |
1374 | + ::EnableWindow(::GetDlgItem(hDlg, IDC_EDIT_MAXRELAYS), false); | |
1375 | + ::EnableWindow(::GetDlgItem(hDlg, IDC_APPLY_MAXRELAYS), false); | |
1376 | + } | |
1368 | 1377 | }else |
1369 | 1378 | { |
1370 | 1379 | SendDlgItemMessage(hDlg,IDC_EDIT_STATUS,WM_SETTEXT,0,(LONG)"OK"); |
@@ -1406,18 +1415,18 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa | ||
1406 | 1415 | |
1407 | 1416 | switch (LOWORD(wParam)) |
1408 | 1417 | { |
1409 | - case IDC_CONTACT: | |
1418 | + case IDC_CONTACT: | |
1410 | 1419 | { |
1411 | 1420 | sys->getURL(chanInfo.url); |
1412 | 1421 | return TRUE; |
1413 | 1422 | } |
1414 | - case IDC_DETAILS: | |
1423 | + case IDC_DETAILS: | |
1415 | 1424 | { |
1416 | 1425 | sprintf(str,"admin?page=chaninfo&id=%s&relay=%d",idstr,chanInfoIsRelayed); |
1417 | 1426 | sys->callLocalURL(str,servMgr->serverHost.port); |
1418 | 1427 | return TRUE; |
1419 | 1428 | } |
1420 | - case IDC_KEEP: | |
1429 | + case IDC_KEEP: | |
1421 | 1430 | { |
1422 | 1431 | Channel *ch = chanMgr->findChannelByID(chanInfo.id); |
1423 | 1432 | if (ch) |
@@ -1426,12 +1435,36 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa | ||
1426 | 1435 | } |
1427 | 1436 | |
1428 | 1437 | |
1429 | - case IDC_PLAY: | |
1438 | + case IDC_PLAY: | |
1430 | 1439 | { |
1431 | 1440 | chanMgr->findAndPlayChannel(chanInfo,false); |
1432 | 1441 | return TRUE; |
1433 | 1442 | } |
1434 | 1443 | |
1444 | + case IDC_APPLY_MAXRELAYS: | |
1445 | + { | |
1446 | + // チャンネル固有の最大リレー数を設定 | |
1447 | + BOOL bSucc; | |
1448 | + unsigned int mr; | |
1449 | + | |
1450 | + // 入力値取得 | |
1451 | + mr = ::GetDlgItemInt(hDlg, IDC_EDIT_MAXRELAYS, &bSucc, false); | |
1452 | + | |
1453 | + if (bSucc) | |
1454 | + { | |
1455 | + Channel *ch = chanMgr->findChannelByID(chanInfo.id); | |
1456 | + if (ch && !isIndexTxt(ch)) | |
1457 | + { | |
1458 | + ch->maxRelays = mr; | |
1459 | + } | |
1460 | + } else | |
1461 | + { | |
1462 | + MessageBox(hDlg, "入力値が不正です。", "Error", MB_OK|MB_ICONERROR|MB_APPLMODAL); | |
1463 | + Channel *ch = chanMgr->findChannelByID(chanInfo.id); | |
1464 | + if (ch) | |
1465 | + ::SetDlgItemInt(hDlg, IDC_EDIT_MAXRELAYS, ch->maxRelays, false); | |
1466 | + } | |
1467 | + } | |
1435 | 1468 | } |
1436 | 1469 | } |
1437 | 1470 | break; |
@@ -166,6 +166,9 @@ BEGIN | ||
166 | 166 | LTEXT "ステータス:",IDC_STATIC,7,153,41,9 |
167 | 167 | EDITTEXT IDC_EDIT_STATUS,8,163,82,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE |
168 | 168 | PUSHBUTTON "再生",IDC_PLAY,56,185,34,15 |
169 | + EDITTEXT IDC_EDIT_MAXRELAYS,98,166,46,12,ES_AUTOHSCROLL | ES_NUMBER | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_RIGHT | WS_EX_STATICEDGE | |
170 | + PUSHBUTTON "適用",IDC_APPLY_MAXRELAYS,149,164,24,15 | |
171 | + GROUPBOX "最大リレー数",IDC_STATIC,94,156,83,27 | |
169 | 172 | END |
170 | 173 | |
171 | 174 |
@@ -50,7 +50,10 @@ | ||
50 | 50 | #define IDC_STATIC_LOG 1018 |
51 | 51 | #define IDC_BUTTON4 1019 |
52 | 52 | #define IDC_BUTTON5 1020 |
53 | +#define IDC_EDIT_MAXRELAYS 1020 | |
53 | 54 | #define IDC_BUTTON6 1021 |
55 | +#define IDC_APPLY_MAX_RELAYS 1021 | |
56 | +#define IDC_APPLY_MAXRELAYS 1021 | |
54 | 57 | #define IDC_EDIT3 1025 |
55 | 58 | #define IDC_EDIT5 1027 |
56 | 59 | #define IDC_LOGDEBUG 1037 |
@@ -107,9 +110,9 @@ | ||
107 | 110 | // |
108 | 111 | #ifdef APSTUDIO_INVOKED |
109 | 112 | #ifndef APSTUDIO_READONLY_SYMBOLS |
110 | -#define _APS_NEXT_RESOURCE_VALUE 142 | |
113 | +#define _APS_NEXT_RESOURCE_VALUE 143 | |
111 | 114 | #define _APS_NEXT_COMMAND_VALUE 32831 |
112 | -#define _APS_NEXT_CONTROL_VALUE 1019 | |
115 | +#define _APS_NEXT_CONTROL_VALUE 1022 | |
113 | 116 | #define _APS_NEXT_SYMED_VALUE 110 |
114 | 117 | #endif |
115 | 118 | #endif |
@@ -143,7 +143,7 @@ int channel_count=1; | ||
143 | 143 | // ----------------------------------------------------------------------------- |
144 | 144 | // Initialise the channel to its default settings of unallocated and reset. |
145 | 145 | // ----------------------------------------------------------------------------- |
146 | -Channel::Channel() | |
146 | +Channel::Channel() : maxRelays(0) | |
147 | 147 | { |
148 | 148 | next = NULL; |
149 | 149 | reset(); |
@@ -306,7 +306,14 @@ bool Channel::isFull() | ||
306 | 306 | } |
307 | 307 | // for PCRaw (relay) end. |
308 | 308 | |
309 | - return chanMgr->maxRelaysPerChannel ? localRelays() >= chanMgr->maxRelaysPerChannel : false; | |
309 | + // チャンネル固有のリレー上限設定があるか | |
310 | + if (maxRelays > 0) | |
311 | + { | |
312 | + return localRelays() >= maxRelays; | |
313 | + } else | |
314 | + { | |
315 | + return chanMgr->maxRelaysPerChannel ? localRelays() >= chanMgr->maxRelaysPerChannel : false; | |
316 | + } | |
310 | 317 | } |
311 | 318 | // ----------------------------------- |
312 | 319 | int Channel::localRelays() |
@@ -532,6 +532,8 @@ public: | ||
532 | 532 | bool bumped; |
533 | 533 | unsigned int lastSkipTime; |
534 | 534 | unsigned int lastStopTime; |
535 | + | |
536 | + int maxRelays; // チャンネル固有のリレー最大数(コンストラクタで初期化) | |
535 | 537 | }; |
536 | 538 | |
537 | 539 | // ---------------------------------- |
@@ -42,9 +42,9 @@ static const char *PCX_VERSTRING = "v0.1218(VP0026)"; | ||
42 | 42 | #if 1 /* for VP extend version */ |
43 | 43 | #define VERSION_EX 1 |
44 | 44 | static const char *PCP_CLIENT_VERSION_EX_PREFIX = "IM"; // 2bytes only |
45 | -static const int PCP_CLIENT_VERSION_EX_NUMBER = 26; | |
46 | -static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0026-2)"; | |
47 | -static const char *PCX_VERSTRING_EX = "v0.1218(IM0026-2)"; | |
45 | +static const int PCP_CLIENT_VERSION_EX_NUMBER = 27; | |
46 | +static const char *PCX_AGENTEX = "PeerCast/0.1218(IM0027)"; | |
47 | +static const char *PCX_VERSTRING_EX = "v0.1218(IM0027)"; | |
48 | 48 | #endif |
49 | 49 | |
50 | 50 | // ------------------------------------------------ |
@@ -8,6 +8,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simple", "simple\Simple.vcp | ||
8 | 8 | {7BCFE65B-8757-45F3-8DFB-1E7D683950D1} = {7BCFE65B-8757-45F3-8DFB-1E7D683950D1} |
9 | 9 | EndProjectSection |
10 | 10 | EndProject |
11 | +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{00D364AE-DB2F-4109-A925-31B4F129D613}" | |
12 | + ProjectSection(SolutionItems) = preProject | |
13 | + memo.txt = memo.txt | |
14 | + EndProjectSection | |
15 | +EndProject | |
11 | 16 | Global |
12 | 17 | GlobalSection(SourceCodeControl) = preSolution |
13 | 18 | SccNumberOfProjects = 3 |
@@ -0,0 +1,5 @@ | ||
1 | +・7144/7145のListenポートを捌くスレッド | |
2 | + int Servent::serverProc(ThreadInfo *thread); (servent.cpp) | |
3 | + | |
4 | +・リレー上限チェック | |
5 | + bool Channel::isFull(); (channel.cpp) |
@@ -1365,6 +1365,15 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa | ||
1365 | 1365 | { |
1366 | 1366 | SendDlgItemMessage(hDlg,IDC_EDIT_STATUS,WM_SETTEXT,0,(LONG)ch->getStatusStr()); |
1367 | 1367 | SendDlgItemMessage(hDlg, IDC_KEEP,BM_SETCHECK, ch->stayConnected, 0); |
1368 | + | |
1369 | + // 現在の固有リレー上限設定を表示(0は無効) | |
1370 | + ::SetDlgItemInt(hDlg, IDC_EDIT_MAXRELAYS, ch->maxRelays, false); | |
1371 | + if (isIndexTxt(ch)) | |
1372 | + { | |
1373 | + // index.txtなので無効に | |
1374 | + ::EnableWindow(::GetDlgItem(hDlg, IDC_EDIT_MAXRELAYS), false); | |
1375 | + ::EnableWindow(::GetDlgItem(hDlg, IDC_APPLY_MAXRELAYS), false); | |
1376 | + } | |
1368 | 1377 | }else |
1369 | 1378 | { |
1370 | 1379 | SendDlgItemMessage(hDlg,IDC_EDIT_STATUS,WM_SETTEXT,0,(LONG)"OK"); |
@@ -1406,18 +1415,18 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa | ||
1406 | 1415 | |
1407 | 1416 | switch (LOWORD(wParam)) |
1408 | 1417 | { |
1409 | - case IDC_CONTACT: | |
1418 | + case IDC_CONTACT: | |
1410 | 1419 | { |
1411 | 1420 | sys->getURL(chanInfo.url); |
1412 | 1421 | return TRUE; |
1413 | 1422 | } |
1414 | - case IDC_DETAILS: | |
1423 | + case IDC_DETAILS: | |
1415 | 1424 | { |
1416 | 1425 | sprintf(str,"admin?page=chaninfo&id=%s&relay=%d",idstr,chanInfoIsRelayed); |
1417 | 1426 | sys->callLocalURL(str,servMgr->serverHost.port); |
1418 | 1427 | return TRUE; |
1419 | 1428 | } |
1420 | - case IDC_KEEP: | |
1429 | + case IDC_KEEP: | |
1421 | 1430 | { |
1422 | 1431 | Channel *ch = chanMgr->findChannelByID(chanInfo.id); |
1423 | 1432 | if (ch) |
@@ -1426,12 +1435,36 @@ LRESULT CALLBACK ChanInfoProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lPa | ||
1426 | 1435 | } |
1427 | 1436 | |
1428 | 1437 | |
1429 | - case IDC_PLAY: | |
1438 | + case IDC_PLAY: | |
1430 | 1439 | { |
1431 | 1440 | chanMgr->findAndPlayChannel(chanInfo,false); |
1432 | 1441 | return TRUE; |
1433 | 1442 | } |
1434 | 1443 | |
1444 | + case IDC_APPLY_MAXRELAYS: | |
1445 | + { | |
1446 | + // チャンネル固有の最大リレー数を設定 | |
1447 | + BOOL bSucc; | |
1448 | + unsigned int mr; | |
1449 | + | |
1450 | + // 入力値取得 | |
1451 | + mr = ::GetDlgItemInt(hDlg, IDC_EDIT_MAXRELAYS, &bSucc, false); | |
1452 | + | |
1453 | + if (bSucc) | |
1454 | + { | |
1455 | + Channel *ch = chanMgr->findChannelByID(chanInfo.id); | |
1456 | + if (ch && !isIndexTxt(ch)) | |
1457 | + { | |
1458 | + ch->maxRelays = mr; | |
1459 | + } | |
1460 | + } else | |
1461 | + { | |
1462 | + MessageBox(hDlg, "入力値が不正です。", "Error", MB_OK|MB_ICONERROR|MB_APPLMODAL); | |
1463 | + Channel *ch = chanMgr->findChannelByID(chanInfo.id); | |
1464 | + if (ch) | |
1465 | + ::SetDlgItemInt(hDlg, IDC_EDIT_MAXRELAYS, ch->maxRelays, false); | |
1466 | + } | |
1467 | + } | |
1435 | 1468 | } |
1436 | 1469 | } |
1437 | 1470 | break; |
@@ -166,6 +166,9 @@ BEGIN | ||
166 | 166 | LTEXT "ステータス:",IDC_STATIC,7,153,41,9 |
167 | 167 | EDITTEXT IDC_EDIT_STATUS,8,163,82,12,ES_READONLY | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_STATICEDGE |
168 | 168 | PUSHBUTTON "再生",IDC_PLAY,56,185,34,15 |
169 | + EDITTEXT IDC_EDIT_MAXRELAYS,98,166,46,12,ES_AUTOHSCROLL | ES_NUMBER | NOT WS_BORDER | NOT WS_TABSTOP,WS_EX_RIGHT | WS_EX_STATICEDGE | |
170 | + PUSHBUTTON "適用",IDC_APPLY_MAXRELAYS,149,164,24,15 | |
171 | + GROUPBOX "最大リレー数",IDC_STATIC,94,156,83,27 | |
169 | 172 | END |
170 | 173 | |
171 | 174 |
@@ -50,7 +50,10 @@ | ||
50 | 50 | #define IDC_STATIC_LOG 1018 |
51 | 51 | #define IDC_BUTTON4 1019 |
52 | 52 | #define IDC_BUTTON5 1020 |
53 | +#define IDC_EDIT_MAXRELAYS 1020 | |
53 | 54 | #define IDC_BUTTON6 1021 |
55 | +#define IDC_APPLY_MAX_RELAYS 1021 | |
56 | +#define IDC_APPLY_MAXRELAYS 1021 | |
54 | 57 | #define IDC_EDIT3 1025 |
55 | 58 | #define IDC_EDIT5 1027 |
56 | 59 | #define IDC_LOGDEBUG 1037 |
@@ -107,9 +110,9 @@ | ||
107 | 110 | // |
108 | 111 | #ifdef APSTUDIO_INVOKED |
109 | 112 | #ifndef APSTUDIO_READONLY_SYMBOLS |
110 | -#define _APS_NEXT_RESOURCE_VALUE 142 | |
113 | +#define _APS_NEXT_RESOURCE_VALUE 143 | |
111 | 114 | #define _APS_NEXT_COMMAND_VALUE 32831 |
112 | -#define _APS_NEXT_CONTROL_VALUE 1019 | |
115 | +#define _APS_NEXT_CONTROL_VALUE 1022 | |
113 | 116 | #define _APS_NEXT_SYMED_VALUE 110 |
114 | 117 | #endif |
115 | 118 | #endif |