home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Beta / Quicktime 2.0 Beta.iso / Extensions / Macintosh Easy Open / Documentation / Developer / Interfaces / CIncludes / TranslationExtensions.h < prev   
Encoding:
C/C++ Source or Header  |  1993-04-28  |  5.3 KB  |  160 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TranslationExtensions.h 
  3.  
  4.     Contains:    Interface definitions for translation extension writers.
  5.  
  6.     Copyright:    © 1992-1993 by Apple Computer, Inc., all rights reserved.
  7. */
  8.  
  9.  
  10. #ifndef __TRANSLATIONEXTENSIONS__
  11. #define __TRANSLATIONEXTENSIONS__
  12.  
  13. #define kSupportsFileTranslation     1
  14. #define kSupportsScrapTranslation     2
  15.  
  16. // special error codes that DoTranslateFile can return
  17. //        userCanceledErr                -128        // user hit cancel button in progress dialog, or error handled by extension
  18. #define invalidTranslationPathErr    -3025        // srcType to dstType is not a valid path         ••• move into Errors.h
  19. #define couldNotParseSourceFileErr    -3026        // the source document does not contain srcType    ••• move into Errors.h
  20.  
  21. #ifndef REZ
  22.  
  23. #include <Memory.h>
  24. #include <Files.h>
  25. #include <Quickdraw.h>
  26. #include "Components.h"
  27.  
  28. // better names for 4-char codes
  29. typedef    OSType    FileType;
  30. typedef    ResType    ScrapType;
  31.  
  32.  
  33. typedef unsigned long TranslationAttributes;
  34. #define taDstDocNeedsResourceFork    1
  35. #define taDstIsAppTranslation        2
  36.  
  37.  
  38. struct FileTypeSpec
  39. {
  40.     FileType                format;
  41.     long                    hint;
  42.     TranslationAttributes    flags;                // taDstDocNeedsResourceFork, taDstIsAppTranslation
  43.     OSType                    catInfoType;
  44.     OSType                    catInfoCreator;
  45. };
  46. typedef struct FileTypeSpec FileTypeSpec;
  47.  
  48. struct FileTranslationList
  49. {
  50.     unsigned long        modDate;
  51.     unsigned long        groupCount;
  52.     //     unsigned long    group1SrcCount;
  53.     //     unsigned long    group1SrcEntrySize = sizeof(FileTypeSpec);
  54.     //  FileTypeSpec    group1SrcTypes[group1SrcCount]
  55.     //  unsigned long    group1DstCount;
  56.     //  unsigned long    group1DstEntrySize = sizeof(FileTypeSpec);
  57.     //  FileTypeSpec    group1DstTypes[group1DstCount]
  58. };
  59. typedef struct FileTranslationList FileTranslationList;
  60. typedef FileTranslationList *FileTranslationListPtr, **FileTranslationListHandle;
  61.  
  62.  
  63.  
  64. struct ScrapTypeSpec
  65. {
  66.     ScrapType    format;
  67.     long        hint;
  68. };
  69. typedef struct ScrapTypeSpec ScrapTypeSpec;
  70.  
  71. struct ScrapTranslationList
  72. {
  73.     unsigned long            modDate;
  74.     unsigned long            groupCount;
  75.     //     unsigned long        group1SrcCount;
  76.     //     unsigned long        group1SrcEntrySize = sizeof(ScrapTypeSpec);
  77.     //  ScrapTypeSpec        group1SrcTypes[group1SrcCount]
  78.     //  unsigned long        group1DstCount;
  79.     //     unsigned long        group1DstEntrySize = sizeof(ScrapTypeSpec);
  80.     //  ScrapTypeSpec        group1DstTypes[group1DstCount]
  81. };
  82. typedef struct ScrapTranslationList ScrapTranslationList;
  83. typedef ScrapTranslationList *ScrapTranslationListPtr, **ScrapTranslationListHandle;
  84.  
  85.  
  86.  
  87. // definition of callbacks to update progress dialog
  88. typedef long TranslationRefNum;
  89.  
  90.  
  91. //////////////////////////////////////////////////////////////////////////////////////////////
  92. //
  93. // This routine sets the advertisement in the top half of the progress dialog.
  94. // It is called once at the beginning of your DoTranslateFile routine.
  95. //
  96. // Enter:    refNum            Translation reference supplied to DoTranslateFile.
  97. //            advertisement    A handle to the picture to display.  This must be non-purgable.
  98. //                            Before returning from DoTranslateFile, you should dispose
  99. //                            of the memory.  (Normally, it is in the temp translation heap
  100. //                            so it is cleaned up for you.)
  101. //
  102. // Exit:    returns            noErr, paramErr, or memFullErr
  103. //
  104. pascal OSErr SetTranslationAdvertisement(TranslationRefNum     refNum,
  105.                                          PicHandle             advertisement)
  106.      = {0x7002,0xABFC}; 
  107.  
  108.  
  109. //////////////////////////////////////////////////////////////////////////////////////////////
  110. //
  111. // This routine updates the progress bar in the progress dialog.
  112. // It is called repeatedly from within your DoTranslateFile routine.
  113. // It should be called often, so that the user will get feedback if he tries to cancel.
  114. //
  115. // Enter:    refNum        translation reference supplied to DoTranslateFile.
  116. //            progress    percent complete (0-100)
  117. //
  118. // Exit:    canceled    TRUE if the user clicked the Cancel button, FALSE otherwise
  119. //            returns        noErr, paramErr, or memFullErr
  120. //
  121. pascal OSErr UpdateTranslationProgress(TranslationRefNum    refNum,
  122.                                       short                 percentDone,
  123.                                       Boolean*                 canceled)
  124.      = {0x7001,0xABFC}; 
  125.  
  126.  
  127.  
  128. // ComponentMgr selectors for routines
  129. enum {
  130.     kTranslateGetFileTranslationList = 0,        // component selectors
  131.     kTranslateIdentifyFile,
  132.     kTranslateTranslateFile,
  133.     kTranslateGetScrapTranslationList = 10,        // skip to scrap routines
  134.     kTranslateIdentifyScrap,
  135.     kTranslateTranslateScrap
  136. };
  137.  
  138.  
  139. // implement these if you are writing a File Translation Extension
  140. pascal ComponentResult DoGetFileTranslationList(ComponentInstance self, FileTranslationListHandle translationList);
  141. pascal ComponentResult DoIdentifyFile(ComponentInstance self, const FSSpec* theDoc, FileType* docKind);
  142. pascal ComponentResult DoTranslateFile(ComponentInstance self, TranslationRefNum refNum,
  143.                                             const FSSpec* srcDoc, FileType srcType, long srcTypeHint, 
  144.                                             const FSSpec* dstDoc, FileType dstType, long dstTypeHint);
  145.  
  146.  
  147.  
  148. // implement these if you are writing a Scrap Translation Extension
  149. pascal ComponentResult DoGetScrapTranslationList(ComponentInstance self, ScrapTranslationListHandle list);
  150. pascal ComponentResult DoIdentifyScrap(ComponentInstance self, const void* dataPtr, Size dataLength, ScrapType* dataFormat);
  151. pascal ComponentResult DoTranslateScrap(ComponentInstance self, TranslationRefNum refNum,
  152.                                         const void* srcDataPtr, Size srcDataLength, ScrapType srcType, long srcTypeHint,
  153.                                         Handle dstData, ScrapType dstType, long dstTypeHint);
  154.  
  155.  
  156. #endif    //  REZ
  157.  
  158.  
  159. #endif  // __TRANSLATIONEXTENSIONS__
  160.