Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

722 lines
22 KiB

  1. // LogGenPg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include <iadmw.h>
  5. #include "logui.h"
  6. #include "LogGenPg.h"
  7. #include <iiscnfg.h>
  8. #include <idlg.h>
  9. #include <shlobj.h>
  10. #include <shlwapi.h>
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. #define SIZE_MBYTE 1048576
  17. #define MAX_LOGFILE_SIZE 4000
  18. #define MD_LOGFILE_PERIOD_UNLIMITED MD_LOGFILE_PERIOD_HOURLY + 1
  19. //
  20. // Support functions to map & unmap the weird logfile ordering to the UI ordering
  21. //
  22. /////////////////////////////////////////////////////////////////////////////
  23. int MapLogFileTypeToUIIndex(int iLogFileType)
  24. {
  25. int iUIIndex;
  26. switch (iLogFileType)
  27. {
  28. case MD_LOGFILE_PERIOD_HOURLY: iUIIndex = 0; break;
  29. case MD_LOGFILE_PERIOD_DAILY: iUIIndex = 1; break;
  30. case MD_LOGFILE_PERIOD_WEEKLY: iUIIndex = 2; break;
  31. case MD_LOGFILE_PERIOD_MONTHLY: iUIIndex = 3; break;
  32. case MD_LOGFILE_PERIOD_UNLIMITED: iUIIndex = 4; break;
  33. case MD_LOGFILE_PERIOD_NONE: iUIIndex = 5; break;
  34. }
  35. return iUIIndex;
  36. }
  37. /////////////////////////////////////////////////////////////////////////////
  38. int MapUIIndexToLogFileType(int iUIIndex)
  39. {
  40. int iLogFileType;
  41. switch (iUIIndex)
  42. {
  43. case 0: iLogFileType = MD_LOGFILE_PERIOD_HOURLY; break;
  44. case 1: iLogFileType = MD_LOGFILE_PERIOD_DAILY; break;
  45. case 2: iLogFileType = MD_LOGFILE_PERIOD_WEEKLY; break;
  46. case 3: iLogFileType = MD_LOGFILE_PERIOD_MONTHLY; break;
  47. case 4: iLogFileType = MD_LOGFILE_PERIOD_UNLIMITED; break;
  48. case 5: iLogFileType = MD_LOGFILE_PERIOD_NONE; break;
  49. }
  50. return iLogFileType;
  51. }
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CLogGeneral property page
  54. IMPLEMENT_DYNCREATE(CLogGeneral, CPropertyPage)
  55. //--------------------------------------------------------------------------
  56. CLogGeneral::CLogGeneral() : CPropertyPage(CLogGeneral::IDD),
  57. m_fInitialized( FALSE ),
  58. m_pComboLog( NULL ),
  59. m_fLocalMachine( FALSE )
  60. {
  61. //{{AFX_DATA_INIT(CLogGeneral)
  62. m_sz_directory = _T("");
  63. m_sz_filesample = _T("");
  64. m_fShowLocalTimeCheckBox = FALSE;
  65. m_int_period = -1;
  66. //}}AFX_DATA_INIT
  67. m_dwVersionMajor = 5;
  68. m_dwVersionMinor = 1;
  69. m_fIsModified = FALSE;
  70. }
  71. //--------------------------------------------------------------------------
  72. CLogGeneral::~CLogGeneral()
  73. {
  74. }
  75. //--------------------------------------------------------------------------
  76. void CLogGeneral::DoDataExchange(CDataExchange* pDX)
  77. {
  78. CPropertyPage::DoDataExchange(pDX);
  79. //{{AFX_DATA_MAP(CLogGeneral)
  80. DDX_Control(pDX, IDC_LOG_HOURLY, m_wndPeriod);
  81. DDX_Control(pDX, IDC_USE_LOCAL_TIME, m_wndUseLocalTime);
  82. DDX_Control(pDX, IDC_LOG_BROWSE, m_cbttn_browse);
  83. DDX_Control(pDX, IDC_LOG_DIRECTORY, m_cedit_directory);
  84. DDX_Control(pDX, IDC_LOG_SIZE, m_cedit_size);
  85. DDX_Control(pDX, IDC_SPIN, m_cspin_spin);
  86. DDX_Control(pDX, IDC_LOG_SIZE_UNITS, m_cstatic_units);
  87. DDX_Text(pDX, IDC_LOG_FILE_SAMPLE, m_sz_filesample);
  88. DDX_Check(pDX, IDC_USE_LOCAL_TIME, m_fUseLocalTime);
  89. // DDX_Radio(pDX, IDC_LOG_HOURLY, m_int_period);
  90. //}}AFX_DATA_MAP
  91. DDX_Text(pDX, IDC_LOG_DIRECTORY, m_sz_directory);
  92. if (pDX->m_bSaveAndValidate)
  93. {
  94. if (PathIsUNCServerShare(m_sz_directory))
  95. {
  96. DDV_UNCFolderPath(pDX, m_sz_directory, m_fLocalMachine);
  97. }
  98. else
  99. {
  100. DDV_FolderPath(pDX, m_sz_directory, m_fLocalMachine);
  101. }
  102. }
  103. if (pDX->m_bSaveAndValidate)
  104. {
  105. DDX_Radio(pDX, IDC_LOG_HOURLY, m_int_period);
  106. m_int_period = MapUIIndexToLogFileType(m_int_period);
  107. if (m_int_period == MD_LOGFILE_PERIOD_NONE)
  108. {
  109. // this needs to come before DDX_TextBalloon
  110. DDV_MinMaxBalloon(pDX, IDC_LOG_SIZE, 0, MAX_LOGFILE_SIZE);
  111. DDX_Text(pDX, IDC_LOG_SIZE, m_dword_filesize);
  112. }
  113. }
  114. else
  115. {
  116. int iUIIndex = MapLogFileTypeToUIIndex(m_int_period);
  117. DDX_Radio(pDX, IDC_LOG_HOURLY, iUIIndex);
  118. }
  119. }
  120. BEGIN_MESSAGE_MAP(CLogGeneral, CPropertyPage)
  121. //{{AFX_MSG_MAP(CLogGeneral)
  122. ON_BN_CLICKED(IDC_LOG_BROWSE, OnBrowse)
  123. ON_BN_CLICKED(IDC_LOG_DAILY, OnLogDaily)
  124. ON_BN_CLICKED(IDC_LOG_MONTHLY, OnLogMonthly)
  125. ON_BN_CLICKED(IDC_LOG_WHENSIZE, OnLogWhensize)
  126. ON_BN_CLICKED(IDC_LOG_WEEKLY, OnLogWeekly)
  127. ON_EN_CHANGE(IDC_LOG_DIRECTORY, OnChangeLogDirectory)
  128. ON_EN_CHANGE(IDC_LOG_SIZE, OnChangeLogSize)
  129. ON_BN_CLICKED(IDC_LOG_UNLIMITED, OnLogUnlimited)
  130. ON_BN_CLICKED(IDC_LOG_HOURLY, OnLogHourly)
  131. ON_BN_CLICKED(IDC_USE_LOCAL_TIME, OnUseLocalTime)
  132. //}}AFX_MSG_MAP
  133. ON_COMMAND(ID_HELP_FINDER, DoHelp)
  134. ON_COMMAND(ID_HELP, DoHelp)
  135. ON_COMMAND(ID_CONTEXT_HELP, DoHelp)
  136. ON_COMMAND(ID_DEFAULT_HELP, DoHelp)
  137. END_MESSAGE_MAP()
  138. //---------------------------------------------------------------------------
  139. void CLogGeneral::DoHelp()
  140. {
  141. DebugTraceHelp(HIDD_LOGUI_GENERIC);
  142. WinHelp( HIDD_LOGUI_GENERIC );
  143. }
  144. HRESULT
  145. CLogGeneral::GetServiceVersion()
  146. {
  147. CError err;
  148. CString info_path;
  149. if (NULL != CMetabasePath::GetServiceInfoPath(m_szMeta, info_path))
  150. {
  151. CString csTempPassword;
  152. m_szPassword.CopyTo(csTempPassword);
  153. CComAuthInfo auth(m_szServer, m_szUserName, csTempPassword);
  154. CMetaKey mk(&auth, info_path, METADATA_PERMISSION_READ);
  155. err = mk.QueryResult();
  156. if (err.Succeeded())
  157. {
  158. err = mk.QueryValue(MD_SERVER_VERSION_MAJOR, m_dwVersionMajor);
  159. if (err.Succeeded())
  160. {
  161. err = mk.QueryValue(MD_SERVER_VERSION_MINOR, m_dwVersionMinor);
  162. }
  163. }
  164. }
  165. else
  166. {
  167. err = E_FAIL;
  168. }
  169. return err;
  170. }
  171. //--------------------------------------------------------------------------
  172. void CLogGeneral::UpdateDependants()
  173. {
  174. BOOL fEnable = (m_int_period == MD_LOGFILE_PERIOD_MAXSIZE);
  175. m_cspin_spin.EnableWindow(fEnable);
  176. m_cstatic_units.EnableWindow(fEnable);
  177. m_cedit_size.EnableWindow(fEnable);
  178. }
  179. //--------------------------------------------------------------------------
  180. // update the sample file stirng
  181. void CLogGeneral::UpdateSampleFileString()
  182. {
  183. CString szSample;
  184. // ok first we have to generate a string to show what sub-node the logging stuff
  185. // is going to go into. This would be of the general form of the name of the server
  186. // followed by the virtual node of the server. Example: LM/W3SVC/1 would
  187. // become "W3SVC1/example" Unfortunately, all we have to build this thing out of
  188. // is the target metabase path. So we strip off the preceding LM/. Then we find the
  189. // next / character and take the number that follows it. If we are editing the
  190. // master root properties then there will be no slash/number at the end at which point
  191. // we can just append a capital X character to signifiy this. The MMC is currently set
  192. // up to only show the logging properties if we are editing the master props or a virtual
  193. // server, so we shouldn't have to worry about stuff after the virtual server number
  194. // get rid of the preceding LM/ (Always three characters)
  195. m_sz_filesample = m_szMeta.Right( m_szMeta.GetLength() - 3 );
  196. // Find the location of the '/' character
  197. INT iSlash = m_sz_filesample.Find( _T('/') );
  198. // if there was no last slash, then append the X, otherwise append the number
  199. if ( iSlash < 0 )
  200. {
  201. m_sz_filesample += _T('X');
  202. }
  203. else
  204. {
  205. m_sz_filesample = m_sz_filesample.Left(iSlash) +
  206. m_sz_filesample.Right( m_sz_filesample.GetLength() - (iSlash+1) );
  207. }
  208. // add a final path type slash to signify that it is a partial path
  209. m_sz_filesample += _T('\\');
  210. // build the sample string
  211. switch( m_int_period )
  212. {
  213. case MD_LOGFILE_PERIOD_MAXSIZE:
  214. m_sz_filesample += szSizePrefix;
  215. szSample.LoadString( IDS_LOG_SIZE_FILESAMPLE );
  216. break;
  217. case MD_LOGFILE_PERIOD_DAILY:
  218. m_sz_filesample += szPrefix;
  219. szSample.LoadString( IDS_LOG_DAILY_FILESAMPLE );
  220. break;
  221. case MD_LOGFILE_PERIOD_WEEKLY:
  222. m_sz_filesample += szPrefix;
  223. szSample.LoadString( IDS_LOG_WEEKLY_FILESAMPLE );
  224. break;
  225. case MD_LOGFILE_PERIOD_MONTHLY:
  226. m_sz_filesample += szPrefix;
  227. szSample.LoadString( IDS_LOG_MONTHLY_FILESAMPLE );
  228. break;
  229. case MD_LOGFILE_PERIOD_HOURLY:
  230. m_sz_filesample += szPrefix;
  231. szSample.LoadString( IDS_LOG_HOURLY_FILE_SAMPLE );
  232. break;
  233. case MD_LOGFILE_PERIOD_UNLIMITED:
  234. m_sz_filesample += szSizePrefix;
  235. szSample.LoadString( IDS_LOG_UNLIMITED_FILESAMPLE );
  236. break;
  237. };
  238. // add the two together
  239. m_sz_filesample += szSample;
  240. // update the display
  241. ::SetWindowText(CONTROL_HWND(IDC_LOG_FILE_SAMPLE), m_sz_filesample);
  242. // Don't do this it will reset the logfile directory
  243. //UpdateData( FALSE );
  244. }
  245. /////////////////////////////////////////////////////////////////////////////
  246. // CLogGeneral message handlers
  247. //--------------------------------------------------------------------------
  248. BOOL CLogGeneral::OnInitDialog()
  249. {
  250. BOOL bRes = CPropertyPage::OnInitDialog();
  251. CError err = GetServiceVersion();
  252. if (err.Succeeded())
  253. {
  254. CString csTempPassword;
  255. m_szPassword.CopyTo(csTempPassword);
  256. CComAuthInfo auth(m_szServer, m_szUserName, csTempPassword);
  257. CMetaKey mk(&auth, m_szMeta, METADATA_PERMISSION_READ);
  258. do
  259. {
  260. err = mk.QueryResult();
  261. BREAK_ON_ERR_FAILURE(err);
  262. err = mk.QueryValue(MD_LOGFILE_PERIOD, m_int_period);
  263. BREAK_ON_ERR_FAILURE(err);
  264. err = mk.QueryValue(MD_LOGFILE_TRUNCATE_SIZE, m_dword_filesize);
  265. BREAK_ON_ERR_FAILURE(err);
  266. m_dword_filesize /= SIZE_MBYTE;
  267. if ( (m_dword_filesize > MAX_LOGFILE_SIZE) && (m_int_period == MD_LOGFILE_PERIOD_NONE) )
  268. {
  269. m_int_period = MD_LOGFILE_PERIOD_UNLIMITED;
  270. m_dword_filesize = 512;
  271. }
  272. err = mk.QueryValue(MD_LOGFILE_DIRECTORY, m_sz_directory);
  273. BREAK_ON_ERR_FAILURE(err);
  274. if (m_fShowLocalTimeCheckBox)
  275. {
  276. m_wndUseLocalTime.ShowWindow(SW_SHOW);
  277. if ((MD_LOGFILE_PERIOD_NONE == m_int_period) || (MD_LOGFILE_PERIOD_UNLIMITED == m_int_period))
  278. {
  279. m_wndUseLocalTime.EnableWindow(FALSE);
  280. }
  281. err = mk.QueryValue(MD_LOGFILE_LOCALTIME_ROLLOVER, m_fUseLocalTime);
  282. if (err.Failed())
  283. {
  284. err.Reset();
  285. }
  286. }
  287. // Set original values...
  288. m_orig_MD_LOGFILE_PERIOD = m_int_period;
  289. m_orig_MD_LOGFILE_TRUNCATE_SIZE = m_dword_filesize;
  290. m_orig_MD_LOGFILE_DIRECTORY = m_sz_directory;
  291. m_orig_MD_LOGFILE_LOCALTIME_ROLLOVER = m_fUseLocalTime;
  292. UpdateData( FALSE );
  293. UpdateDependants();
  294. UpdateSampleFileString();
  295. m_cbttn_browse.EnableWindow(m_fLocalMachine);
  296. m_cspin_spin.SetRange32(0, MAX_LOGFILE_SIZE);
  297. m_cspin_spin.SetPos(m_dword_filesize);
  298. } while (FALSE);
  299. }
  300. #ifdef SUPPORT_SLASH_SLASH_QUESTIONMARK_SLASH_TYPE_PATHS
  301. LimitInputPath(CONTROL_HWND(IDC_LOG_DIRECTORY),TRUE);
  302. #else
  303. LimitInputPath(CONTROL_HWND(IDC_LOG_DIRECTORY),FALSE);
  304. #endif
  305. #if defined(_DEBUG) || DBG
  306. err.MessageBoxOnFailure();
  307. #endif
  308. SetModified(FALSE);
  309. return bRes;
  310. }
  311. //--------------------------------------------------------------------------
  312. BOOL CLogGeneral::OnApply()
  313. {
  314. if (m_fIsModified)
  315. {
  316. UpdateData();
  317. if (!PathIsValid(m_sz_directory,FALSE))
  318. {
  319. AfxMessageBox(IDS_NEED_DIRECTORY);
  320. return FALSE;
  321. }
  322. if (m_fLocalMachine)
  323. {
  324. CString expanded;
  325. ExpandEnvironmentStrings(m_sz_directory, expanded.GetBuffer(MAX_PATH), MAX_PATH);
  326. expanded.ReleaseBuffer();
  327. if (PathIsNetworkPath(expanded))
  328. {
  329. if (m_dwVersionMajor < 6)
  330. {
  331. AfxMessageBox(IDS_REMOTE_NOT_SUPPORTED);
  332. return FALSE;
  333. }
  334. goto Verified;
  335. }
  336. if (PathIsRelative(expanded))
  337. {
  338. AfxMessageBox(IDS_NO_RELATIVE_PATH);
  339. return FALSE;
  340. }
  341. if (!PathIsDirectory(expanded))
  342. {
  343. AfxMessageBox(IDS_NOT_DIR_EXIST);
  344. return FALSE;
  345. }
  346. }
  347. Verified:
  348. CString csTempPassword;
  349. m_szPassword.CopyTo(csTempPassword);
  350. CComAuthInfo auth(m_szServer, m_szUserName, csTempPassword);
  351. CError err;
  352. CList<DWORD, DWORD> mdlist;
  353. int iNewValuePeriod = 0;
  354. DWORD dwNewValueTruncateSize = 0;
  355. BOOL fNewValueUseLocalTime = FALSE;
  356. BOOL fSomethingChanged = FALSE;
  357. do
  358. {
  359. CMetaKey mk(&auth, m_szMeta, METADATA_PERMISSION_WRITE);
  360. err = mk.QueryResult();
  361. BREAK_ON_ERR_FAILURE(err);
  362. // warning:
  363. // these values are all tied together:
  364. // MD_LOGFILE_PERIOD
  365. // MD_LOGFILE_TRUNCATE_SIZE
  366. // MD_LOGFILE_LOCALTIME_ROLLOVER
  367. //
  368. // if anyone of these values change
  369. // then it affects the other one.
  370. // if you change anyone of of these,
  371. // then you must force the inheritance dlg
  372. // to prompt for all of them.
  373. // you can get into a funky state if not.
  374. iNewValuePeriod = (m_int_period == MD_LOGFILE_PERIOD_UNLIMITED ? MD_LOGFILE_PERIOD_NONE : m_int_period);
  375. dwNewValueTruncateSize = (m_int_period == MD_LOGFILE_PERIOD_UNLIMITED ? 0xFFFFFFFF : m_dword_filesize * SIZE_MBYTE);
  376. fNewValueUseLocalTime = m_fUseLocalTime;
  377. if (iNewValuePeriod != m_orig_MD_LOGFILE_PERIOD)
  378. {
  379. fSomethingChanged = TRUE;
  380. }
  381. if (dwNewValueTruncateSize != m_orig_MD_LOGFILE_TRUNCATE_SIZE)
  382. {
  383. fSomethingChanged = TRUE;
  384. }
  385. if (m_fShowLocalTimeCheckBox)
  386. {
  387. if (fNewValueUseLocalTime != m_orig_MD_LOGFILE_LOCALTIME_ROLLOVER)
  388. {
  389. fSomethingChanged = TRUE;
  390. }
  391. }
  392. if (fSomethingChanged)
  393. {
  394. err = mk.SetValue(MD_LOGFILE_PERIOD, iNewValuePeriod);
  395. BREAK_ON_ERR_FAILURE(err);
  396. mdlist.AddTail(MD_LOGFILE_PERIOD);
  397. m_orig_MD_LOGFILE_PERIOD = iNewValuePeriod; // Set original value...
  398. err = mk.SetValue(MD_LOGFILE_TRUNCATE_SIZE, dwNewValueTruncateSize);
  399. BREAK_ON_ERR_FAILURE(err);
  400. mdlist.AddTail(MD_LOGFILE_TRUNCATE_SIZE);
  401. m_orig_MD_LOGFILE_TRUNCATE_SIZE = dwNewValueTruncateSize; // Set original value...
  402. err = mk.SetValue(MD_LOGFILE_LOCALTIME_ROLLOVER, fNewValueUseLocalTime);
  403. BREAK_ON_ERR_FAILURE(err);
  404. mdlist.AddTail(MD_LOGFILE_LOCALTIME_ROLLOVER);
  405. m_orig_MD_LOGFILE_LOCALTIME_ROLLOVER = fNewValueUseLocalTime; // Set original value...
  406. }
  407. if (0 != m_sz_directory.Compare(m_orig_MD_LOGFILE_DIRECTORY))
  408. {
  409. err = mk.SetValue(MD_LOGFILE_DIRECTORY, m_sz_directory);
  410. BREAK_ON_ERR_FAILURE(err);
  411. mdlist.AddTail(MD_LOGFILE_DIRECTORY);
  412. m_orig_MD_LOGFILE_DIRECTORY = m_sz_directory; // Set original value...
  413. }
  414. } while(FALSE);
  415. // Check inheritance
  416. if (!mdlist.IsEmpty())
  417. {
  418. POSITION pos = mdlist.GetHeadPosition();
  419. while (pos)
  420. {
  421. DWORD id = mdlist.GetNext(pos);
  422. {
  423. CInheritanceDlg dlg(id, TRUE, &auth, m_szMeta);
  424. if (!dlg.IsEmpty())
  425. {
  426. dlg.DoModal();
  427. }
  428. }
  429. }
  430. }
  431. }
  432. return CPropertyPage::OnApply();
  433. }
  434. //--------------------------------------------------------------------------
  435. static int CALLBACK
  436. FileChooserCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
  437. {
  438. CLogGeneral * pThis = (CLogGeneral *)lpData;
  439. ASSERT(pThis != NULL);
  440. return pThis->BrowseForFolderCallback(hwnd, uMsg, lParam);
  441. }
  442. int
  443. CLogGeneral::BrowseForFolderCallback(HWND hwnd, UINT uMsg, LPARAM lParam)
  444. {
  445. BOOL bNetwork;
  446. switch (uMsg)
  447. {
  448. case BFFM_INITIALIZED:
  449. ASSERT(m_pPathTemp != NULL);
  450. bNetwork = ::PathIsNetworkPath(m_pPathTemp);
  451. if (m_dwVersionMajor >= 6 && bNetwork)
  452. return 0;
  453. if (m_fLocalMachine && !bNetwork)
  454. {
  455. while (!::PathIsDirectory(m_pPathTemp))
  456. {
  457. if (0 == ::PathRemoveFileSpec(m_pPathTemp) && !::PathIsRoot(m_pPathTemp))
  458. {
  459. return 0;
  460. }
  461. DWORD attr = GetFileAttributes(m_pPathTemp);
  462. if ((attr & FILE_ATTRIBUTE_READONLY) == 0)
  463. break;
  464. }
  465. ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)m_pPathTemp);
  466. }
  467. break;
  468. case BFFM_SELCHANGED:
  469. {
  470. LPITEMIDLIST pidl = (LPITEMIDLIST)lParam;
  471. TCHAR path[MAX_PATH];
  472. if (SHGetPathFromIDList(pidl, path))
  473. {
  474. BOOL bEnable = TRUE;
  475. if (m_dwVersionMajor >= 6)
  476. {
  477. TCHAR prefix[MAX_PATH];
  478. if (PathCommonPrefix(m_NetHood, path, prefix) > 0)
  479. {
  480. if (m_NetHood.CompareNoCase(prefix) == 0)
  481. {
  482. bEnable = FALSE;
  483. }
  484. }
  485. }
  486. else
  487. {
  488. bEnable = !PathIsNetworkPath(path);
  489. }
  490. ::SendMessage(hwnd, BFFM_ENABLEOK, 0, bEnable);
  491. }
  492. else
  493. {
  494. ::SendMessage(hwnd, BFFM_ENABLEOK, 0, FALSE);
  495. }
  496. }
  497. break;
  498. case BFFM_VALIDATEFAILED:
  499. break;
  500. }
  501. return 0;
  502. }
  503. void CLogGeneral::OnBrowse()
  504. {
  505. BOOL bRes = FALSE;
  506. HRESULT hr;
  507. CString str;
  508. m_cedit_directory.GetWindowText(str);
  509. if (SUCCEEDED(hr = CoInitialize(NULL)))
  510. {
  511. LPITEMIDLIST pidl = NULL;
  512. int csidl = m_dwVersionMajor >= 6 ? CSIDL_DESKTOP : CSIDL_DRIVES;
  513. if (SUCCEEDED(SHGetFolderLocation(NULL, csidl, NULL, 0, &pidl)))
  514. {
  515. LPITEMIDLIST pidList = NULL;
  516. BROWSEINFO bi;
  517. TCHAR buf[MAX_PATH];
  518. ZeroMemory(&bi, sizeof(bi));
  519. int drive = PathGetDriveNumber(str);
  520. if (GetDriveType(PathBuildRoot(buf, drive)) == DRIVE_FIXED)
  521. {
  522. StrCpy(buf, str);
  523. }
  524. else
  525. {
  526. buf[0] = 0;
  527. }
  528. bi.hwndOwner = m_hWnd;
  529. bi.pidlRoot = pidl;
  530. bi.pszDisplayName = m_pPathTemp = buf;
  531. bi.lpszTitle = NULL;
  532. bi.ulFlags |= BIF_NEWDIALOGSTYLE;
  533. if (m_dwVersionMajor < 6)
  534. {
  535. bi.ulFlags |= BIF_RETURNONLYFSDIRS;
  536. }
  537. else
  538. {
  539. bi.ulFlags |= BIF_RETURNONLYFSDIRS;
  540. // this doesn't seem to work with BIF_RETURNONLYFSDIRS
  541. //bi.ulFlags |= BIF_SHAREABLE;
  542. }
  543. bi.lpfn = FileChooserCallback;
  544. bi.lParam = (LPARAM)this;
  545. // Get NetHood folder location
  546. SHGetFolderPath(NULL, CSIDL_NETHOOD, NULL, SHGFP_TYPE_CURRENT, m_NetHood.GetBuffer(MAX_PATH));
  547. m_NetHood.ReleaseBuffer();
  548. pidList = SHBrowseForFolder(&bi);
  549. if (pidList != NULL && SHGetPathFromIDList(pidList, buf))
  550. {
  551. str = buf;
  552. bRes = TRUE;
  553. }
  554. IMalloc * pMalloc;
  555. VERIFY(SUCCEEDED(SHGetMalloc(&pMalloc)));
  556. if (pidl != NULL)
  557. pMalloc->Free(pidl);
  558. pMalloc->Release();
  559. }
  560. CoUninitialize();
  561. }
  562. if (bRes)
  563. {
  564. m_cedit_directory.SetWindowText(str);
  565. }
  566. }
  567. //--------------------------------------------------------------------------
  568. void CLogGeneral::OnLogDaily()
  569. {
  570. m_wndUseLocalTime.EnableWindow(TRUE);
  571. m_int_period = MD_LOGFILE_PERIOD_DAILY;
  572. UpdateDependants();
  573. UpdateSampleFileString();
  574. SetModified();
  575. m_fIsModified = TRUE;
  576. }
  577. //--------------------------------------------------------------------------
  578. void CLogGeneral::OnLogMonthly()
  579. {
  580. m_wndUseLocalTime.EnableWindow(TRUE);
  581. m_int_period = MD_LOGFILE_PERIOD_MONTHLY;
  582. UpdateDependants();
  583. UpdateSampleFileString();
  584. SetModified();
  585. m_fIsModified = TRUE;
  586. }
  587. //--------------------------------------------------------------------------
  588. void CLogGeneral::OnLogWhensize()
  589. {
  590. m_wndUseLocalTime.EnableWindow(FALSE);
  591. m_int_period = MD_LOGFILE_PERIOD_MAXSIZE;
  592. UpdateDependants();
  593. UpdateSampleFileString();
  594. SetModified();
  595. m_fIsModified = TRUE;
  596. }
  597. //--------------------------------------------------------------------------
  598. void CLogGeneral::OnLogUnlimited()
  599. {
  600. m_wndUseLocalTime.EnableWindow(FALSE);
  601. m_int_period = MD_LOGFILE_PERIOD_UNLIMITED;
  602. UpdateDependants();
  603. UpdateSampleFileString();
  604. SetModified();
  605. m_fIsModified = TRUE;
  606. }
  607. //--------------------------------------------------------------------------
  608. void CLogGeneral::OnLogWeekly()
  609. {
  610. m_wndUseLocalTime.EnableWindow(TRUE);
  611. m_int_period = MD_LOGFILE_PERIOD_WEEKLY;
  612. UpdateDependants();
  613. UpdateSampleFileString();
  614. SetModified();
  615. m_fIsModified = TRUE;
  616. }
  617. //--------------------------------------------------------------------------
  618. void CLogGeneral::OnLogHourly()
  619. {
  620. m_wndUseLocalTime.EnableWindow(TRUE);
  621. m_int_period = MD_LOGFILE_PERIOD_HOURLY;
  622. UpdateDependants();
  623. UpdateSampleFileString();
  624. SetModified();
  625. m_fIsModified = TRUE;
  626. }
  627. //--------------------------------------------------------------------------
  628. void CLogGeneral::OnChangeLogDirectory()
  629. {
  630. SetModified();
  631. m_fIsModified = TRUE;
  632. }
  633. //--------------------------------------------------------------------------
  634. void CLogGeneral::OnChangeLogSize()
  635. {
  636. SetModified();
  637. m_fIsModified = TRUE;
  638. }
  639. //--------------------------------------------------------------------------
  640. void CLogGeneral::OnUseLocalTime()
  641. {
  642. SetModified();
  643. m_fIsModified = TRUE;
  644. }