Source code of Windows XP (NT5)
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.

195 lines
5.0 KiB

  1. #ifndef APDLGLOG_H
  2. #define APDLGLOG_H
  3. #include "dlglogic.h"
  4. #include "ctllogic.h"
  5. #include <dpa.h>
  6. #define MAX_CONTENTTYPEHANDLER 64
  7. #define MAX_CONTENTTYPEHANDLERFRIENDLYNAME 128
  8. #define MAX_DEVICENAME 50
  9. #define MAX_HANDLER 64
  10. class CHandlerData : public CDataImpl
  11. {
  12. public:
  13. // from CDataImpl
  14. void UpdateDirty();
  15. // from CHandlerData
  16. void Init(PWSTR pszHandler, PWSTR pszHandlerFriendlyName,
  17. PWSTR pszIconLocation, PWSTR pszTileText);
  18. HRESULT _GetCommand(PWSTR pszCommand, DWORD cchCommand)
  19. {
  20. WCHAR szProgid[260];
  21. WCHAR szVerb[CCH_KEYMAX];
  22. HRESULT hr = _GetHandlerInvokeProgIDAndVerb(_pszHandler,
  23. szProgid, ARRAYSIZE(szProgid),
  24. szVerb, ARRAYSIZE(szVerb));
  25. if (SUCCEEDED(hr))
  26. {
  27. hr = AssocQueryStringW(0, ASSOCSTR_COMMAND, szProgid, szVerb, pszCommand, &cchCommand);
  28. }
  29. return hr;
  30. }
  31. HRESULT Compare(LPCWSTR pszHandler, int* piResult)
  32. {
  33. (*piResult) = StrCmpW(pszHandler, _pszHandler);
  34. return S_OK;
  35. };
  36. ~CHandlerData();
  37. public:
  38. PWSTR _pszHandler;
  39. PWSTR _pszHandlerFriendlyName;
  40. PWSTR _pszIconLocation;
  41. PWSTR _pszTileText;
  42. };
  43. class CHandlerDataArray : public CDPA<CHandlerData>
  44. {
  45. public:
  46. static int CALLBACK _ReleaseHandler(CHandlerData *pdata, void *)
  47. {
  48. pdata->Release();
  49. return 1;
  50. }
  51. ~CHandlerDataArray();
  52. HRESULT AddHandler(CHandlerData *pdata);
  53. BOOL IsDuplicateCommand(PCWSTR pszCommand);
  54. protected:
  55. BOOL _IsDemotedHandler(PCWSTR pszHandler);
  56. };
  57. class CContentBase : public CDataImpl
  58. {
  59. public:
  60. CHandlerData* GetHandlerData(int i);
  61. int GetHandlerCount() { return _dpaHandlerData.IsDPASet() ? _dpaHandlerData.GetPtrCount() : 0; }
  62. void RemoveHandler(int i)
  63. {
  64. CHandlerData *pdata = _dpaHandlerData.DeletePtr(i);
  65. if (pdata)
  66. pdata->Release();
  67. }
  68. protected:
  69. HRESULT _AddLegacyHandler(DWORD dwContentType);
  70. HRESULT _EnumHandlerHelper(IAutoplayHandler* piah);
  71. public: // members
  72. CHandlerDataArray _dpaHandlerData;
  73. };
  74. class CNoContentData : public CContentBase
  75. {
  76. public:
  77. // from CDataImpl
  78. void UpdateDirty();
  79. HRESULT CommitChangesToStorage();
  80. // from CNoContentData
  81. HRESULT Init(LPCWSTR pszDeviceID);
  82. public:
  83. CNoContentData() : _dwHandlerDefaultFlags(0) {}
  84. ~CNoContentData();
  85. // MAX_DEVICE_ID_LEN == 200
  86. WCHAR _szDeviceID[200];
  87. LPWSTR _pszIconLabel; // e.g.: "Compaq iPaq"
  88. LPWSTR _pszIconLocation;
  89. // Latest settings (potentially modified by user)
  90. // Current selection in ComboBox
  91. LPWSTR _pszHandlerDefault;
  92. // Original settings (unmodified)
  93. // Current selection in ComboBox
  94. LPWSTR _pszHandlerDefaultOriginal;
  95. DWORD _dwHandlerDefaultFlags;
  96. BOOL _fSoftCommit;
  97. };
  98. class CContentTypeData : public CContentBase
  99. {
  100. public:
  101. // from CDataImpl
  102. void UpdateDirty();
  103. HRESULT CommitChangesToStorage();
  104. // from CContentTypeData
  105. HRESULT Init(LPCWSTR pszDrive, DWORD dwContentType);
  106. public:
  107. CContentTypeData() : _dwHandlerDefaultFlags(0) {}
  108. ~CContentTypeData();
  109. DWORD _dwContentType;
  110. WCHAR _szContentTypeHandler[MAX_CONTENTTYPEHANDLER];
  111. WCHAR _szDrive[MAX_PATH];
  112. // For ListView
  113. WCHAR _szIconLabel[MAX_CONTENTTYPEHANDLERFRIENDLYNAME]; // e.g.: "Pictures"
  114. WCHAR _szIconLocation[MAX_ICONLOCATION];
  115. // Latest settings (potentially modified by user)
  116. // Current selection in ComboBox
  117. LPWSTR _pszHandlerDefault;
  118. // Original settings (unmodified)
  119. // Current selection in ComboBox
  120. LPWSTR _pszHandlerDefaultOriginal;
  121. DWORD _dwHandlerDefaultFlags;
  122. BOOL _fSoftCommit;
  123. };
  124. class CContentTypeLVItem : public CDLUIDataLVItem<CContentTypeData>
  125. {
  126. public:
  127. HRESULT GetText(LPWSTR pszText, DWORD cchText);
  128. HRESULT GetIconLocation(LPWSTR pszIconLocation,
  129. DWORD cchIconLocation);
  130. };
  131. class CContentTypeCBItem : public CDLUIDataCBItem<CContentTypeData>
  132. {
  133. public:
  134. HRESULT GetText(LPWSTR pszText, DWORD cchText);
  135. HRESULT GetIconLocation(LPWSTR pszIconLocation,
  136. DWORD cchIconLocation);
  137. };
  138. class CHandlerCBItem : public CDLUIDataCBItem<CHandlerData>
  139. {
  140. HRESULT GetText(LPWSTR pszText, DWORD cchText);
  141. };
  142. class CHandlerLVItem : public CDLUIDataLVItem<CHandlerData>
  143. {
  144. public:
  145. HRESULT GetText(LPWSTR pszText, DWORD cchText);
  146. HRESULT GetIconLocation(LPWSTR pszIconLocation,
  147. DWORD cchIconLocation);
  148. HRESULT GetTileText(int i, LPWSTR pszTileText,
  149. DWORD cchTileText);
  150. };
  151. HRESULT _SetHandlerDefault(LPWSTR* ppszHandlerDefault, LPCWSTR pszHandler);
  152. #endif // APDLGLOG_H