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.

280 lines
5.1 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. mime.h
  5. Abstract:
  6. Mime mapping dialog
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. #ifndef _MIME_H_
  14. #define _MIME_H_
  15. class CMimeEditDlg : public CDialog
  16. /*++
  17. Class Description:
  18. MIME editor dialog.
  19. Public Interface:
  20. CMimeEditDlg : MIME editor dialog constructor
  21. --*/
  22. {
  23. //
  24. // Construction
  25. //
  26. public:
  27. //
  28. // Create new mime mapping constructor
  29. //
  30. CMimeEditDlg(
  31. IN CWnd * pParent = NULL
  32. );
  33. //
  34. // Constructor to edit existing MIME mapping
  35. //
  36. CMimeEditDlg(
  37. IN LPCTSTR lpstrExt,
  38. IN LPCTSTR lpstrMime,
  39. IN CWnd * pParent = NULL
  40. );
  41. //
  42. // Dialog Data
  43. //
  44. public:
  45. //{{AFX_DATA(CMimeEditDlg)
  46. enum { IDD = IDD_MIME_PROPERTY };
  47. CButton m_button_Ok;
  48. CEdit m_edit_Mime;
  49. CEdit m_edit_Extent;
  50. //}}AFX_DATA
  51. CString m_strMime;
  52. CString m_strExt;
  53. //
  54. // Overrides
  55. //
  56. protected:
  57. //{{AFX_VIRTUAL(CMimeEditDlg)
  58. protected:
  59. virtual void DoDataExchange(CDataExchange * pDX);
  60. //}}AFX_VIRTUAL
  61. //
  62. // Implementation
  63. //
  64. protected:
  65. //
  66. // Enable/disable controls depending on window status
  67. //
  68. void SetControlStates();
  69. //
  70. // Extentions must start with a dot, add it if it isn't there
  71. //
  72. void CleanExtension(
  73. IN OUT CString & strExtension
  74. );
  75. //{{AFX_MSG(CMimeEditDlg)
  76. virtual BOOL OnInitDialog();
  77. virtual void OnOK();
  78. //}}AFX_MSG
  79. afx_msg void OnItemChanged();
  80. DECLARE_MESSAGE_MAP()
  81. };
  82. class CMimeDlg : public CDialog
  83. /*++
  84. Class Description:
  85. MIME listings dialog
  86. Public Interface:
  87. CMimeDlg : Constructor for the dialog
  88. --*/
  89. {
  90. //
  91. // Construction
  92. //
  93. public:
  94. CMimeDlg(
  95. IN CStringListEx & strlMimeTypes,
  96. IN CWnd * pParent = NULL
  97. );
  98. //
  99. // Dialog Data
  100. //
  101. protected:
  102. //
  103. // Build the MIME list from the listbox
  104. //
  105. void FillFromListBox();
  106. //
  107. // Fill the listbox from the list of MIME types
  108. //
  109. void FillListBox();
  110. //
  111. // Enable/disable control states depending on dialog data
  112. //
  113. void SetControlStates();
  114. //
  115. // Build a listbox-suitable display string for the mime type
  116. //
  117. void BuildDisplayString(
  118. IN CString & strExt,
  119. IN CString & strMime,
  120. OUT CString & strOut
  121. );
  122. //
  123. // As above, but use a metabase internal formatted string for input
  124. //
  125. BOOL BuildDisplayString(
  126. IN CString & strIn,
  127. OUT CString & strOut
  128. );
  129. //
  130. // Build a string in the metabase internal format for this mime type
  131. //
  132. void BuildMetaString(
  133. IN CString & strExt,
  134. IN CString & strMime,
  135. OUT CString & strOut
  136. );
  137. //
  138. // Given the listbox suitable display string, break it in extension
  139. // and MIME type strings
  140. //
  141. BOOL CrackDisplayString(
  142. IN CString & strIn,
  143. OUT CString & strExt,
  144. OUT CString & strMime
  145. );
  146. //
  147. // Find a MIME entry for the given extension, or return -1 if not found
  148. //
  149. int FindMimeType(
  150. IN const CString & strTargetExt
  151. );
  152. //{{AFX_DATA(CMimeDlg)
  153. enum { IDD = IDD_MIME_TYPES };
  154. CEdit m_edit_Extention;
  155. CEdit m_edit_ContentType;
  156. CButton m_button_Remove;
  157. CButton m_button_Edit;
  158. CButton m_button_Ok;
  159. //}}AFX_DATA
  160. CStringListEx & m_strlMimeTypes;
  161. CRMCListBox m_list_MimeTypes;
  162. //
  163. // Overrides
  164. //
  165. protected:
  166. // ClassWizard generated virtual function overrides
  167. //{{AFX_VIRTUAL(CMimeDlg)
  168. protected:
  169. virtual void DoDataExchange(CDataExchange * pDX); // DDX/DDV support
  170. //}}AFX_VIRTUAL
  171. //
  172. // Implementation
  173. //
  174. protected:
  175. // Generated message map functions
  176. //{{AFX_MSG(CMimeDlg)
  177. virtual BOOL OnInitDialog();
  178. afx_msg void OnButtonEdit();
  179. afx_msg void OnButtonNewType();
  180. afx_msg void OnButtonRemove();
  181. afx_msg void OnDblclkListMimeTypes();
  182. afx_msg void OnSelchangeListMimeTypes();
  183. afx_msg void OnHelp();
  184. virtual void OnOK();
  185. //}}AFX_MSG
  186. afx_msg void OnItemChanged();
  187. DECLARE_MESSAGE_MAP()
  188. private:
  189. BOOL m_fDirty;
  190. };
  191. //
  192. // Inline Expansion
  193. //
  194. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  195. inline void CMimeEditDlg::CleanExtension(
  196. IN OUT CString & strExtension
  197. )
  198. {
  199. if (strExtension[0] != _T('.'))
  200. {
  201. strExtension = _T('.') + strExtension;
  202. }
  203. }
  204. inline void CMimeDlg::BuildDisplayString(
  205. IN CString & strExt,
  206. IN CString & strMime,
  207. OUT CString & strOut
  208. )
  209. {
  210. strOut.Format(_T("%s\t%s"), (LPCTSTR)strExt, (LPCTSTR)strMime);
  211. }
  212. inline void CMimeDlg::BuildMetaString(
  213. IN CString & strExt,
  214. IN CString & strMime,
  215. OUT CString & strOut
  216. )
  217. {
  218. strOut.Format(_T("%s,%s"), (LPCTSTR)strExt, (LPCTSTR)strMime);
  219. }
  220. #endif // _MIME_H_