| 57 |
#include "themedlg.h" |
#include "themedlg.h" |
| 58 |
#include "theme.h" |
#include "theme.h" |
| 59 |
#include "ttcmn_notify2.h" |
#include "ttcmn_notify2.h" |
| 60 |
|
#include "filesys_log.h" // for ConvertLognameW() |
| 61 |
|
|
| 62 |
const mouse_cursor_t MouseCursor[] = { |
const mouse_cursor_t MouseCursor[] = { |
| 63 |
{"ARROW", IDC_ARROW}, |
{"ARROW", IDC_ARROW}, |
| 1354 |
} |
} |
| 1355 |
|
|
| 1356 |
// CLogPropPageDlg ダイアログ |
// CLogPropPageDlg ダイアログ |
| 1357 |
|
class CLogPropPageDlg : public TTCPropertyPage |
| 1358 |
|
{ |
| 1359 |
|
public: |
| 1360 |
|
CLogPropPageDlg(HINSTANCE inst); |
| 1361 |
|
virtual ~CLogPropPageDlg(); |
| 1362 |
|
private: |
| 1363 |
|
void OnInitDialog(); |
| 1364 |
|
void OnOK(); |
| 1365 |
|
void OnOKLogFilename(); |
| 1366 |
|
enum { IDD = IDD_TABSHEET_LOG }; |
| 1367 |
|
BOOL OnCommand(WPARAM wParam, LPARAM lParam); |
| 1368 |
|
void OnHelp(); |
| 1369 |
|
wchar_t *CreateLogFilename(const wchar_t *format); |
| 1370 |
|
CTipWin *m_TipWin; |
| 1371 |
|
}; |
| 1372 |
|
|
| 1373 |
CLogPropPageDlg::CLogPropPageDlg(HINSTANCE inst) |
CLogPropPageDlg::CLogPropPageDlg(HINSTANCE inst) |
| 1374 |
: TTCPropertyPage(inst, CLogPropPageDlg::IDD) |
: TTCPropertyPage(inst, CLogPropPageDlg::IDD) |
| 1378 |
L"Log", ts.UILanguageFileW, &UIMsg); |
L"Log", ts.UILanguageFileW, &UIMsg); |
| 1379 |
m_psp.pszTitle = UIMsg; |
m_psp.pszTitle = UIMsg; |
| 1380 |
m_psp.dwFlags |= (PSP_USETITLE | PSP_HASHELP); |
m_psp.dwFlags |= (PSP_USETITLE | PSP_HASHELP); |
| 1381 |
|
m_TipWin = new CTipWin(inst); |
| 1382 |
} |
} |
| 1383 |
|
|
| 1384 |
CLogPropPageDlg::~CLogPropPageDlg() |
CLogPropPageDlg::~CLogPropPageDlg() |
| 1385 |
{ |
{ |
| 1386 |
free((void *)m_psp.pszTitle); |
free((void *)m_psp.pszTitle); |
| 1387 |
|
m_TipWin->Destroy(); |
| 1388 |
|
delete m_TipWin; |
| 1389 |
|
m_TipWin = NULL; |
| 1390 |
} |
} |
| 1391 |
|
|
| 1392 |
// CLogPropPageDlg メッセージ ハンドラ |
// CLogPropPageDlg メッセージ ハンドラ |
| 1441 |
// Viewlog Editor path (2005.1.29 yutaka) |
// Viewlog Editor path (2005.1.29 yutaka) |
| 1442 |
SetDlgItemTextA(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor); |
SetDlgItemTextA(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor); |
| 1443 |
|
|
| 1444 |
// Log Default File Name (2006.8.28 maya) |
// Log Default File Name |
| 1445 |
SetDlgItemTextA(IDC_DEFAULTNAME_EDITOR, ts.LogDefaultName); |
SetDlgItemTextA(IDC_DEFAULTNAME_EDITOR, ts.LogDefaultName); |
| 1446 |
|
static const wchar_t *logfile_patterns[] = { |
| 1447 |
|
L"%H%M%S.log", |
| 1448 |
|
L"%y%m%d%H%M%S.log", |
| 1449 |
|
L"%Y%m%d_%H%M%S.log", |
| 1450 |
|
L"%y%m%d_%H%M%S.log", |
| 1451 |
|
L"%y%m%d_%H%M%S_&h.log", |
| 1452 |
|
L"%Y%m%d_%H%M%S_%z.log", |
| 1453 |
|
L"%y%m%d_%H%M%S_%z.log", |
| 1454 |
|
L"%Y%m%dT%H%M%S%z.log", |
| 1455 |
|
}; |
| 1456 |
|
for (int i = 0; i < _countof(logfile_patterns); i++) { |
| 1457 |
|
const wchar_t *pattern = logfile_patterns[i]; |
| 1458 |
|
SendDlgItemMessageW(IDC_DEFAULTNAME_EDITOR, CB_ADDSTRING, 0, (LPARAM)pattern); |
| 1459 |
|
} |
| 1460 |
|
|
| 1461 |
// Log Default File Path (2007.5.30 maya) |
// Log Default File Path (2007.5.30 maya) |
| 1462 |
SetDlgItemTextW(IDC_DEFAULTPATH_EDITOR, ts.LogDefaultPathW); |
SetDlgItemTextW(IDC_DEFAULTPATH_EDITOR, ts.LogDefaultPathW); |
| 1528 |
break; |
break; |
| 1529 |
} |
} |
| 1530 |
*/ |
*/ |
| 1531 |
|
m_TipWin->Create(m_hWnd); |
| 1532 |
|
|
| 1533 |
// ダイアログにフォーカスを当てる |
// ダイアログにフォーカスを当てる |
| 1534 |
::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_VIEWLOG_EDITOR)); |
::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_VIEWLOG_EDITOR)); |
| 1535 |
} |
} |
| 1536 |
|
|
| 1537 |
|
wchar_t *CLogPropPageDlg::CreateLogFilename(const wchar_t *format) |
| 1538 |
|
{ |
| 1539 |
|
time_t time_local; |
| 1540 |
|
struct tm tm_local; |
| 1541 |
|
time(&time_local); |
| 1542 |
|
localtime_s(&tm_local, &time_local); |
| 1543 |
|
wchar_t *str; |
| 1544 |
|
|
| 1545 |
|
if (isInvalidStrftimeCharW(format)) { |
| 1546 |
|
str = _wcsdup(L"Invalid character is included in log file name."); |
| 1547 |
|
} |
| 1548 |
|
else { |
| 1549 |
|
size_t len = 128; |
| 1550 |
|
str = (wchar_t*)malloc(sizeof(wchar_t) * len); |
| 1551 |
|
wcsftime(str, len, format, &tm_local); |
| 1552 |
|
wchar_t *replace = replaceInvalidFileNameCharW(str, L'_'); |
| 1553 |
|
free(str); |
| 1554 |
|
str = replace; |
| 1555 |
|
|
| 1556 |
|
if (isInvalidFileNameCharW(str)) { |
| 1557 |
|
free(str); |
| 1558 |
|
str = _wcsdup(L"Invalid character is included in log file name."); |
| 1559 |
|
} |
| 1560 |
|
else { |
| 1561 |
|
wchar_t *str2 = ConvertLognameW(&cv, str); |
| 1562 |
|
free(str); |
| 1563 |
|
str = str2; |
| 1564 |
|
} |
| 1565 |
|
} |
| 1566 |
|
return str; |
| 1567 |
|
} |
| 1568 |
|
|
| 1569 |
BOOL CLogPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam) |
BOOL CLogPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam) |
| 1570 |
{ |
{ |
| 1571 |
switch (wParam) { |
switch (wParam) { |
| 1658 |
} |
} |
| 1659 |
} |
} |
| 1660 |
return TRUE; |
return TRUE; |
| 1661 |
|
|
| 1662 |
|
case IDC_DEFAULTNAME_EDITOR | (CBN_SELCHANGE << 16) : |
| 1663 |
|
case IDC_DEFAULTNAME_EDITOR | (CBN_EDITCHANGE << 16): |
| 1664 |
|
case IDC_DEFAULTNAME_EDITOR | (CBN_CLOSEUP << 16): |
| 1665 |
|
case IDC_DEFAULTNAME_EDITOR | (CBN_SETFOCUS << 16): { |
| 1666 |
|
wchar_t *format = NULL; |
| 1667 |
|
if (wParam == (IDC_DEFAULTNAME_EDITOR | (CBN_SELCHANGE << 16))) { |
| 1668 |
|
LRESULT r = SendDlgItemMessageW(IDC_DEFAULTNAME_EDITOR, CB_GETCURSEL, 0, 0); |
| 1669 |
|
if (r != CB_ERR) { |
| 1670 |
|
format = (wchar_t*)malloc(50 * sizeof(wchar_t)); |
| 1671 |
|
SendDlgItemMessageW(IDC_DEFAULTNAME_EDITOR, CB_GETLBTEXT, r, (LPARAM)format); |
| 1672 |
|
} |
| 1673 |
|
} |
| 1674 |
|
if (format == NULL) { |
| 1675 |
|
hGetDlgItemTextW(m_hWnd, IDC_DEFAULTNAME_EDITOR, &format); |
| 1676 |
|
} |
| 1677 |
|
wchar_t *str = CreateLogFilename(format); |
| 1678 |
|
if (wcslen(str) > 0) { |
| 1679 |
|
RECT rc; |
| 1680 |
|
::GetWindowRect(::GetDlgItem(m_hWnd, IDC_DEFAULTNAME_EDITOR), &rc); |
| 1681 |
|
m_TipWin->SetText(str); |
| 1682 |
|
m_TipWin->SetPos(rc.left, rc.bottom); |
| 1683 |
|
m_TipWin->SetHideTimer(5 * 1000); // 表示時間 |
| 1684 |
|
if (!m_TipWin->IsVisible()) { |
| 1685 |
|
m_TipWin->SetVisible(TRUE); |
| 1686 |
|
} |
| 1687 |
|
} |
| 1688 |
|
else { |
| 1689 |
|
m_TipWin->SetVisible(FALSE); |
| 1690 |
|
} |
| 1691 |
|
free(str); |
| 1692 |
|
free(format); |
| 1693 |
|
return TRUE; |
| 1694 |
|
} |
| 1695 |
|
|
| 1696 |
|
case IDC_DEFAULTNAME_EDITOR | (CBN_KILLFOCUS << 16): { |
| 1697 |
|
if (m_TipWin->IsVisible()) { |
| 1698 |
|
m_TipWin->SetVisible(FALSE); |
| 1699 |
|
} |
| 1700 |
|
return TRUE; |
| 1701 |
|
} |
| 1702 |
} |
} |
| 1703 |
|
|
| 1704 |
return TTCPropertyPage::OnCommand(wParam, lParam); |
return TTCPropertyPage::OnCommand(wParam, lParam); |
| 1705 |
} |
} |
| 1706 |
|
|
| 1707 |
void CLogPropPageDlg::OnOK() |
void CLogPropPageDlg::OnOKLogFilename() |
| 1708 |
{ |
{ |
| 1709 |
char buf[80], buf2[80]; |
wchar_t *def_name; |
| 1710 |
time_t time_local; |
time_t time_local; |
| 1711 |
struct tm tm_local; |
struct tm tm_local; |
| 1712 |
|
|
| 1713 |
// Viewlog Editor path (2005.1.29 yutaka) |
hGetDlgItemTextW(m_hWnd, IDC_DEFAULTNAME_EDITOR, &def_name); |
| 1714 |
GetDlgItemTextA(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor, _countof(ts.ViewlogEditor)); |
if (isInvalidStrftimeCharW(def_name)) { |
|
|
|
|
// Log Default File Name (2006.8.28 maya) |
|
|
GetDlgItemTextA(IDC_DEFAULTNAME_EDITOR, buf, sizeof(buf)); |
|
|
if (isInvalidStrftimeChar(buf)) { |
|
| 1715 |
static const TTMessageBoxInfoW info = { |
static const TTMessageBoxInfoW info = { |
| 1716 |
"Tera Term", |
"Tera Term", |
| 1717 |
"MSG_ERROR", L"ERROR", |
"MSG_ERROR", L"ERROR", |
| 1725 |
time(&time_local); |
time(&time_local); |
| 1726 |
localtime_s(&tm_local, & time_local); |
localtime_s(&tm_local, & time_local); |
| 1727 |
// 時刻文字列に変換 |
// 時刻文字列に変換 |
| 1728 |
if (strlen(buf) != 0 && strftime(buf2, sizeof(buf2), buf, &tm_local) == 0) { |
wchar_t buf2[MAX_PATH]; |
| 1729 |
|
if (wcslen(def_name) != 0 && wcsftime(buf2, _countof(buf2), def_name, &tm_local) == 0) { |
| 1730 |
static const TTMessageBoxInfoW info = { |
static const TTMessageBoxInfoW info = { |
| 1731 |
"Tera Term", |
"Tera Term", |
| 1732 |
"MSG_ERROR", L"ERROR", |
"MSG_ERROR", L"ERROR", |
| 1733 |
"MSG_LOGFILE_TOOLONG_ERROR", L"The log file name is too long.", |
"MSG_LOGFILE_TOOLONG_ERROR", L"The log file name is too long.", |
| 1734 |
MB_ICONEXCLAMATION }; |
MB_ICONEXCLAMATION }; |
| 1735 |
TTMessageBoxA(m_hWnd, &info, ts.UILanguageFile); |
TTMessageBoxA(m_hWnd, &info, ts.UILanguageFile); |
| 1736 |
|
free(def_name); |
| 1737 |
return; |
return; |
| 1738 |
} |
} |
| 1739 |
if (isInvalidFileNameChar(buf2)) { |
|
| 1740 |
|
wchar_t *buf3 = replaceInvalidFileNameCharW(buf2, '_'); |
| 1741 |
|
|
| 1742 |
|
if (isInvalidFileNameCharW(buf3)) { |
| 1743 |
static const TTMessageBoxInfoW info = { |
static const TTMessageBoxInfoW info = { |
| 1744 |
"Tera Term", |
"Tera Term", |
| 1745 |
"MSG_ERROR", L"ERROR", |
"MSG_ERROR", L"ERROR", |
| 1746 |
"MSG_LOGFILE_INVALID_CHAR_ERROR", L"Invalid character is included in log file name.", |
"MSG_LOGFILE_INVALID_CHAR_ERROR", L"Invalid character is included in log file name.", |
| 1747 |
MB_ICONEXCLAMATION }; |
MB_ICONEXCLAMATION }; |
| 1748 |
TTMessageBoxA(m_hWnd, &info, ts.UILanguageFile); |
TTMessageBoxA(m_hWnd, &info, ts.UILanguageFile); |
| 1749 |
|
free(def_name); |
| 1750 |
|
free(buf3); |
| 1751 |
return; |
return; |
| 1752 |
} |
} |
| 1753 |
strncpy_s(ts.LogDefaultName, sizeof(ts.LogDefaultName), buf, _TRUNCATE); |
|
| 1754 |
|
WideCharToACP_t(def_name, ts.LogDefaultName, sizeof(ts.LogDefaultName)); |
| 1755 |
|
free(def_name); |
| 1756 |
|
free(buf3); |
| 1757 |
|
} |
| 1758 |
|
|
| 1759 |
|
void CLogPropPageDlg::OnOK() |
| 1760 |
|
{ |
| 1761 |
|
// Viewlog Editor path (2005.1.29 yutaka) |
| 1762 |
|
GetDlgItemTextA(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor, _countof(ts.ViewlogEditor)); |
| 1763 |
|
|
| 1764 |
|
// Log Default File Name |
| 1765 |
|
OnOKLogFilename(); |
| 1766 |
|
|
| 1767 |
// Log Default File Path (2007.5.30 maya) |
// Log Default File Path (2007.5.30 maya) |
| 1768 |
free(ts.LogDefaultPathW); |
free(ts.LogDefaultPathW); |
| 1773 |
|
|
| 1774 |
/* Log Rotate */ |
/* Log Rotate */ |
| 1775 |
if (GetCheck(IDC_LOG_ROTATE)) { /* on */ |
if (GetCheck(IDC_LOG_ROTATE)) { /* on */ |
| 1776 |
|
char buf[80]; |
| 1777 |
ts.LogRotate = ROTATE_SIZE; |
ts.LogRotate = ROTATE_SIZE; |
| 1778 |
GetDlgItemTextA(IDC_ROTATE_SIZE_TYPE, buf, _countof(buf)); |
GetDlgItemTextA(IDC_ROTATE_SIZE_TYPE, buf, _countof(buf)); |
| 1779 |
ts.LogRotateSizeType = 0; |
ts.LogRotateSizeType = 0; |