propautodownload.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // PropAutoDownload.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "srvconfig.h"
  5. #include "PropAutoDownload.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CPropAutoDownload property page
  13. IMPLEMENT_DYNCREATE(CPropAutoDownload, CPropertyPage)
  14. CPropAutoDownload::CPropAutoDownload() : CPropertyPage(CPropAutoDownload::IDD)
  15. {
  16. //{{AFX_DATA_INIT(CPropAutoDownload)
  17. m_strFtpPassword = _T("");
  18. m_strFtpServer = _T("");
  19. m_strFtpUserID = _T("");
  20. m_bWatchArtDir = FALSE;
  21. m_strFtpRoot = _T("");
  22. //}}AFX_DATA_INIT
  23. }
  24. CPropAutoDownload::~CPropAutoDownload()
  25. {
  26. }
  27. void CPropAutoDownload::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CPropertyPage::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(CPropAutoDownload)
  31. DDX_Text(pDX, IDC_FTPPASSWORD, m_strFtpPassword);
  32. DDX_Text(pDX, IDC_FTPSERVER, m_strFtpServer);
  33. DDX_Text(pDX, IDC_FTPUSERID, m_strFtpUserID);
  34. DDX_Check(pDX, IDC_WATCHARTDIR, m_bWatchArtDir);
  35. DDX_Text(pDX, IDC_FTPROOT, m_strFtpRoot);
  36. //}}AFX_DATA_MAP
  37. }
  38. BEGIN_MESSAGE_MAP(CPropAutoDownload, CPropertyPage)
  39. //{{AFX_MSG_MAP(CPropAutoDownload)
  40. //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CPropAutoDownload message handlers
  44. BOOL CPropAutoDownload::OnInitDialog()
  45. {
  46. CPropertyPage::OnInitDialog();
  47. // get the stuff from the registry
  48. HKEY hKey;
  49. DWORD dwType;
  50. char szValue[MAX_PATH];
  51. DWORD dwValue;
  52. DWORD cbValue;
  53. if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, HKLM_AllLobby, 0, KEY_READ, &hKey))
  54. {
  55. dwValue=0;
  56. cbValue = MAX_PATH;
  57. if (ERROR_SUCCESS == ::RegQueryValueEx(hKey, "AutoUpdateActive", NULL, &dwType, (unsigned char*)&dwValue, &cbValue))
  58. m_bWatchArtDir = (dwValue==1) ? TRUE : FALSE;
  59. szValue[0]='\0';
  60. cbValue = MAX_PATH;
  61. if (ERROR_SUCCESS == ::RegQueryValueEx(hKey, "FTPArtServer", NULL, &dwType, (unsigned char*)&szValue, &cbValue))
  62. m_strFtpServer = szValue;
  63. szValue[0]='\0';
  64. cbValue = MAX_PATH;
  65. if (ERROR_SUCCESS == ::RegQueryValueEx(hKey, "FTPArtRoot", NULL, &dwType, (unsigned char*)&szValue, &cbValue))
  66. m_strFtpRoot = szValue;
  67. szValue[0]='\0';
  68. cbValue = MAX_PATH;
  69. if (ERROR_SUCCESS == ::RegQueryValueEx(hKey, "FTPAccount", NULL, &dwType, (unsigned char*)&szValue, &cbValue))
  70. m_strFtpUserID = szValue;
  71. szValue[0]='\0';
  72. cbValue = MAX_PATH;
  73. if (ERROR_SUCCESS == ::RegQueryValueEx(hKey, "FTPPW", NULL, &dwType, (unsigned char*)&szValue, &cbValue))
  74. m_strFtpPassword = szValue;
  75. RegCloseKey(hKey);
  76. }
  77. UpdateData(false);
  78. return TRUE; // return TRUE unless you set the focus to a control
  79. // EXCEPTION: OCX Property Pages should return FALSE
  80. }
  81. void CPropAutoDownload::OnOK()
  82. {
  83. UpdateData(true);
  84. CDefaultRegKey key;
  85. if (ERROR_SUCCESS == key.Create(HKEY_LOCAL_MACHINE, HKLM_AllLobby))
  86. {
  87. key.SetValue(m_bWatchArtDir ? 1 : 0, "AutoUpdateActive", 0 );
  88. key.SetValue(m_strFtpServer, "FtpArtServer", "" );
  89. key.SetValue(m_strFtpRoot, "FtpArtRoot", "" );
  90. key.SetValue(m_strFtpUserID, "FtpAccount", "" );
  91. key.SetValue(m_strFtpPassword, "FtpPW", "" );
  92. }
  93. CPropertyPage::OnOK();
  94. }