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.

282 lines
5.0 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 COMDLL 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. // ClassWizard generated virtual function overrides
  58. //{{AFX_VIRTUAL(CMimeEditDlg)
  59. protected:
  60. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  61. //}}AFX_VIRTUAL
  62. //
  63. // Implementation
  64. //
  65. protected:
  66. //
  67. // Enable/disable controls depending on window status
  68. //
  69. void SetControlStates();
  70. //
  71. // Extentions must start with a dot, add it if it isn't there
  72. //
  73. void CleanExtension(
  74. IN OUT CString & strExtension
  75. );
  76. // Generated message map functions
  77. //{{AFX_MSG(CMimeEditDlg)
  78. virtual BOOL OnInitDialog();
  79. virtual void OnOK();
  80. //}}AFX_MSG
  81. afx_msg void OnItemChanged();
  82. DECLARE_MESSAGE_MAP()
  83. };
  84. class COMDLL CMimeDlg : public CDialog
  85. /*++
  86. Class Description:
  87. MIME listings dialog
  88. Public Interface:
  89. CMimeDlg : Constructor for the dialog
  90. --*/
  91. {
  92. //
  93. // Construction
  94. //
  95. public:
  96. CMimeDlg(
  97. IN CStringListEx & strlMimeTypes,
  98. IN CWnd * pParent = NULL
  99. );
  100. //
  101. // Dialog Data
  102. //
  103. protected:
  104. //
  105. // Build the MIME list from the listbox
  106. //
  107. void FillFromListBox();
  108. //
  109. // Fill the listbox from the list of MIME types
  110. //
  111. void FillListBox();
  112. //
  113. // Enable/disable control states depending on dialog data
  114. //
  115. void SetControlStates();
  116. //
  117. // Build a listbox-suitable display string for the mime type
  118. //
  119. void BuildDisplayString(
  120. IN CString & strExt,
  121. IN CString & strMime,
  122. OUT CString & strOut
  123. );
  124. //
  125. // As above, but use a metabase internal formatted string for input
  126. //
  127. BOOL BuildDisplayString(
  128. IN CString & strIn,
  129. OUT CString & strOut
  130. );
  131. //
  132. // Build a string in the metabase internal format for this mime type
  133. //
  134. void BuildMetaString(
  135. IN CString & strExt,
  136. IN CString & strMime,
  137. OUT CString & strOut
  138. );
  139. //
  140. // Given the listbox suitable display string, break it in extension
  141. // and MIME type strings
  142. //
  143. BOOL CrackDisplayString(
  144. IN CString & strIn,
  145. OUT CString & strExt,
  146. OUT CString & strMime
  147. );
  148. //
  149. // Find a MIME entry for the given extension, or return -1 if not found
  150. //
  151. int FindMimeType(
  152. IN const CString & strTargetExt
  153. );
  154. //{{AFX_DATA(CMimeDlg)
  155. enum { IDD = IDD_MIME_TYPES };
  156. CEdit m_edit_Extention;
  157. CEdit m_edit_ContentType;
  158. CButton m_button_Remove;
  159. CButton m_button_Edit;
  160. CButton m_button_Ok;
  161. //}}AFX_DATA
  162. CStringListEx & m_strlMimeTypes;
  163. CRMCListBox m_list_MimeTypes;
  164. //
  165. // Overrides
  166. //
  167. protected:
  168. // ClassWizard generated virtual function overrides
  169. //{{AFX_VIRTUAL(CMimeDlg)
  170. protected:
  171. virtual void DoDataExchange(CDataExchange * pDX); // DDX/DDV support
  172. //}}AFX_VIRTUAL
  173. //
  174. // Implementation
  175. //
  176. protected:
  177. // Generated message map functions
  178. //{{AFX_MSG(CMimeDlg)
  179. virtual BOOL OnInitDialog();
  180. afx_msg void OnButtonEdit();
  181. afx_msg void OnButtonNewType();
  182. afx_msg void OnButtonRemove();
  183. afx_msg void OnDblclkListMimeTypes();
  184. afx_msg void OnSelchangeListMimeTypes();
  185. virtual void OnOK();
  186. //}}AFX_MSG
  187. afx_msg void OnItemChanged();
  188. DECLARE_MESSAGE_MAP()
  189. private:
  190. BOOL m_fDirty;
  191. };
  192. //
  193. // Inline Expansion
  194. //
  195. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  196. inline void CMimeEditDlg::CleanExtension(
  197. IN OUT CString & strExtension
  198. )
  199. {
  200. if (strExtension[0] != _T('.'))
  201. {
  202. strExtension = _T('.') + strExtension;
  203. }
  204. }
  205. inline void CMimeDlg::BuildDisplayString(
  206. IN CString & strExt,
  207. IN CString & strMime,
  208. OUT CString & strOut
  209. )
  210. {
  211. strOut.Format(_T("%s\t%s"), (LPCTSTR)strExt, (LPCTSTR)strMime);
  212. }
  213. inline void CMimeDlg::BuildMetaString(
  214. IN CString & strExt,
  215. IN CString & strMime,
  216. OUT CString & strOut
  217. )
  218. {
  219. strOut.Format(_T("%s,%s"), (LPCTSTR)strExt, (LPCTSTR)strMime);
  220. }
  221. #endif // _MIME_H_