nsIMIMEService.idl 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsISupports.idl"
  6. interface nsIFile;
  7. interface nsIMIMEInfo;
  8. interface nsIURI;
  9. %{C++
  10. #define NS_MIMESERVICE_CID \
  11. { /* 03af31da-3109-11d3-8cd0-0060b0fc14a3 */ \
  12. 0x03af31da, \
  13. 0x3109, \
  14. 0x11d3, \
  15. {0x8c, 0xd0, 0x00, 0x60, 0xb0, 0xfc, 0x14, 0xa3} \
  16. }
  17. %}
  18. /**
  19. * The MIME service is responsible for mapping file extensions to MIME-types
  20. * (see RFC 2045). It also provides access to nsIMIMEInfo interfaces and
  21. * acts as a general convenience wrapper of nsIMIMEInfo interfaces.
  22. *
  23. * The MIME service maintains a database with a <b>one</b> MIME type <b>to many</b>
  24. * file extensions rule. Adding the same file extension to multiple MIME types
  25. * is illegal and behavior is undefined.
  26. *
  27. * @see nsIMIMEInfo
  28. */
  29. [scriptable, main_process_scriptable_only, uuid(5b3675a1-02db-4f8f-a560-b34736635f47)]
  30. interface nsIMIMEService : nsISupports {
  31. /**
  32. * Retrieves an nsIMIMEInfo using both the extension
  33. * and the type of a file. The type is given preference
  34. * during the lookup. One of aMIMEType and aFileExt
  35. * can be an empty string. At least one of aMIMEType and aFileExt
  36. * must be nonempty.
  37. */
  38. nsIMIMEInfo getFromTypeAndExtension(in ACString aMIMEType, in AUTF8String aFileExt);
  39. /**
  40. * Retrieves a ACString representation of the MIME type
  41. * associated with this file extension.
  42. *
  43. * @param A file extension (excluding the dot ('.')).
  44. * @return The MIME type, if any.
  45. */
  46. ACString getTypeFromExtension(in AUTF8String aFileExt);
  47. /**
  48. * Retrieves a ACString representation of the MIME type
  49. * associated with this URI. The association is purely
  50. * file extension to MIME type based. No attempt to determine
  51. * the type via server headers or byte scanning is made.
  52. *
  53. * @param The URI the user wants MIME info on.
  54. * @return The MIME type, if any.
  55. */
  56. ACString getTypeFromURI(in nsIURI aURI);
  57. //
  58. ACString getTypeFromFile(in nsIFile aFile);
  59. /**
  60. * Given a Type/Extension combination, returns the default extension
  61. * for this type. This may be identical to the passed-in extension.
  62. *
  63. * @param aMIMEType The Type to get information on. Must not be empty.
  64. * @param aFileExt File Extension. Can be empty.
  65. */
  66. AUTF8String getPrimaryExtension(in ACString aMIMEType, in AUTF8String aFileExt);
  67. };