home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / Implementation / DocShell / ODPrcs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-13  |  9.0 KB  |  278 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        ODPrcs.h
  3.  
  4.     Contains:    OpenDoc Process runtime functions
  5.  
  6.     Owned by:    Nick Pilch
  7.  
  8.     Copyright:    © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.         <14>      10/22/96    DH        1336808    •OpenDoc 1.0.4: does not run when
  13.                                     memory is set to high value. Now allows
  14.                                     user to reset document size if it cannot be
  15.                                     opened because of out-of-memory.
  16.         <13>     10/4/96    CSL        1334277: Moved AboutBox declarations to
  17.                                     AboutBox.h
  18.         <12>    11.09.1996    NP        1386084: make another routine public
  19.         <11>     7/11/96    TJ        Fixed Name of function to check for MacOS 8
  20.         <10>     6/26/96    NP        10002: Launch time speedups.
  21.          <9>     6/24/96    NP        10002: Launch time speedups
  22.          <8>     6/23/96    NP        10002: Launch time speedups.
  23.          <7>     6/19/96    NP        10002: Launch time speedups.
  24.          <6>     6/18/96    NP        10002: Launch time speedups.
  25.          <5>     6/14/96    NP        10002: Launch time speedups
  26.          <4>    .05.1996    NP        1352438: Added const to parameter in
  27.                                     GetLaunchFailedParams.
  28.          <3>      3/1/96    JP        1314798: Added param to
  29.                                     VerifyAndLaunchDocumentStub
  30.          <2>     1/15/96    JA        1269485: Added GetPrefsFileSpec.
  31.         <19>    10/25/95    TÇ        1281409 GM: OpenDoc needs an AboutBox.
  32.         <18>    10/12/95    eeh        1287143: add keyODRefnumFromResource
  33.         <17>      6/2/95    TÇ        Need to copy resources into newly created
  34.                                     documents.  Completes fix to 4
  35.                                     BB:1233106,1242232, 1254312, 1242283
  36.         <16>     5/19/95    TÇ        1155852 BB: String constants need to be
  37.                                     moved to resource for Localization, 1249396
  38.                                     (was BB) OpenDoc shell should serialize
  39.                                     stationery creation.
  40.         <15>     4/29/95    TÇ        1216130 BB: Shell should open top draft
  41.                                     upon receipt of open document Apple event
  42.         <14>     4/24/95    eeh        1240662: define keyODActivateEventCause
  43.         <13>     4/15/95    TÇ        #1216915 DR/BB:Trying to open a document
  44.                                     that is already open causes an error.
  45.         <12>      4/7/95    eeh        1221297: eventID param to
  46.                                     VerifyAndLaunchDocumentStub
  47.         <11>     3/31/95    TÇ        1223465 BB: Opening and creating documents
  48.                                     under low disk space.  (Creating documents
  49.                                     under low disk space part fixed).
  50.                                     1211032 BB: Invalid Permissions error
  51.                                     opening locked document
  52.         <10>     2/20/95    TÇ        #1210979 BB: 5-$ Bugs need to be evaluated
  53.                                     and removed from Shell
  54.                                     #1221861 BB: Incomplete AOCE support needs
  55.                                     to be removed from OpenDoc
  56.          <9>      2/2/95    CG        #1205177:  "Editors" and "OpenDoc
  57.                                     Libraries" folders are being registered
  58.                                     with cfm (PPC only).
  59.          <8>      1/6/95    jpa        Added GetDescFSSpec [1198075]
  60.          <7>     12/5/94    jpa        Added GetLaunchFailedParams [1198075,
  61.                                     1158966]
  62.          <6>    11/30/94    RR        #1188078 include PlfmFile.h
  63.          <5>      9/8/94    eeh        #1185443: FileIsReadOnly() and contants for
  64.                                     mailer info.
  65.          <4>     8/29/94    TÇ        #1158280 OpenDoc™ should not overwrite old
  66.                                     stationery files when creating new ones
  67.          <3>     8/25/94    TÇ        #1183223 Enabled launching of documents in
  68.                                     folders other than that of the OpenDoc
  69.                                     libraries.  Added new call:
  70.                                     VerifyAndLaunchDocument
  71.          <2>     8/22/94    TÇ        #1182448 System Process quits when no
  72.                                     OpenDoc documents are running
  73.          <1>     8/22/94    TÇ        first checked in
  74.     
  75.     In Progress:
  76.         
  77. */
  78.  
  79. #ifndef _ODPRCS_
  80. #define _ODPRCS_
  81.  
  82. #define ppcinterfaces        /* keeps GX headers quiet */
  83.  
  84. #ifndef _ODTYPES_
  85. #include <ODTypes.h>
  86. #endif
  87.  
  88. #ifndef _PLFMFILE_
  89. #include "PlfmFile.h"
  90. #endif
  91.  
  92. #ifndef __DIALOGS__
  93. #include "Dialogs.h"
  94. #endif
  95.  
  96.  
  97. //==============================================================================
  98. // Constants
  99. //==============================================================================
  100.  
  101. const    ODSShort    kMaxFileNameSize            = 64;
  102. const     ODULong        kSpaceNeededForNewDocument    = 32767/1024;
  103.  
  104. const     DescType     kODActivateEvent            = 0x61637476;    // 'actv';
  105. const     DescType     keyODActivateEventCause        = 0x77687961;    // 'whya';
  106. const     DescType     keyODRefnumFromResource        = 0x72667273;    // 'rfrs';
  107.  
  108. const    OSType        kODTempSizeRsrcType            = 'tpsz';
  109. //==============================================================================
  110. // Functions
  111. //==============================================================================
  112.  
  113. ODFileSpec    GetOpenDocLibsFldrSpec();
  114.  
  115. ODFileSpec    GetOpenDocBinaryFileSpec(char* binaryName);
  116.  
  117. OSErr        GetPrefsFileSpec(ODFileSpec* prefFileSpec);
  118.  
  119. #ifdef NEEDSYSTEMPROCESS
  120. ODBoolean    IsODSysProcessRunning();
  121. #endif
  122.  
  123. ODBoolean    AreODDocumentsRunning();
  124.  
  125. OSErr        FileIsReadOnly( ODFileSpec* fs, ODBoolean* result );
  126.  
  127. ODULong    GetVolumeWritableSpace(ODFileSpec* fs, ODULong* error);
  128.     // returns number of writeable K bytes avail on volume that the fs is on.
  129.  
  130. OSErr        GetDescFSSpec( AEDesc *, FSSpec & );
  131.  
  132. // Document Launching
  133.  
  134. OSErr    VerifyDocumentStub(FSSpecPtr documentStub, FSSpec* seedFSSPtr);
  135. OSErr    LaunchDocumentStub(AEDesc* theDocument, FSSpec* documentStub,
  136.         AEDesc* theAlias, AEDescList* otherParams, ProcessSerialNumber* psn,
  137.         DescType eventID);
  138.  
  139. OSErr    VerifyAndLaunchDocumentStub(AEDesc *theDocument,
  140.         AEDescList* otherParams, ProcessSerialNumber *launchedPSN,
  141.         DescType eventID, FSSpec* seedFSSPtr, ODBoolean unsavedDoc = kODFalse);
  142.  
  143. const DescType kCFMLaunchFailedEventClass = 'dave';
  144. const DescType kCFMLaunchFailedEventID    = 'sean';
  145.  
  146. void    GetLaunchFailedParams( const AppleEvent*, long &launchErr, ProcessSerialNumber *psn,
  147.                                             Str255 appName, Str255 libName );
  148. ODBoolean    WasLaunchedThenActivate(
  149.                         FSSpec* fileSpec, 
  150.                         DescType eventID,
  151.                         OSErr & err);
  152.  
  153. OSErr ReplaceResourceWithNewType( ResType typeToDelete, ResType typeToAdd, short id );
  154.  
  155. /*****************************************************************************/
  156.  
  157. typedef short *RefNumPtr;
  158.  
  159. /* Constants to specify the file fork GetLocalPaths should match */
  160. enum
  161. {
  162.     kDataFork        = 0,
  163.     kResourceFork    = 1
  164. };
  165. typedef short ForkType;
  166.  
  167. /*****************************************************************************/
  168.  
  169. pascal    OSErr    GetLocalPaths(FSSpec *spec,
  170.                               ForkType fork,
  171.                               unsigned long *refNumCount,
  172.                               RefNumPtr *refNums);
  173. /*    Determine if local access paths to a file fork are open.
  174.     The GetLocalPaths function looks through the FCB list to see if
  175.     the fork of the file specified by spec and fork is open by the 
  176.     local File Manager (you should use PBGetCatInfo and check
  177.     ioFlAttrib if you need to see if *anyone* has the file fork open
  178.     *anywhere*). If the result is noErr, GetLocalPaths returns a
  179.     count and a pointer to an array of file refNums (if count is
  180.     not zero) of local access paths to the specified file fork.
  181.  
  182.     spec        input:    An FSSpec record specifying the file.
  183.     fork        input:    Specifies the file fork - either kDataFork
  184.                         or kResourceFork.
  185.     refNumCount    output:    The number of local access paths found.
  186.     refNums        output: If not NULL, a pointer to an array of
  187.                         file refNums - the number of which is
  188.                         specified by refNumCount.  The caller is
  189.                         responsible for disposing of this pointer.
  190. */
  191.  
  192. ODBoolean    IsSystem753OrGreater();
  193. ODBoolean    IsSystem8OrGreater();
  194. ODBoolean    IsCertainSystemVersionOrGreater(long systemVersion);
  195.  
  196. const ODBoolean kODAddAPPL = kODTrue;
  197. const ODBoolean kODRemoveAPPL = kODFalse;
  198. void        ChangeDesktopDatabase(FSSpec* fileSpec, ODBoolean add);
  199.  
  200. OSErr    GetOpenDocLibsFolderInfo(long* dirID, short* vRefNum);
  201. OSErr    FindODLibFileWithSignature(Str255 fileName,
  202.                                     short vRefNum,
  203.                                     long dirID,
  204.                                     OSType signature);
  205. inline void        CopyPascalString(StringPtr destStr, StringPtr srcStr)
  206.                 { BlockMoveData(srcStr, destStr, srcStr[0] + 1); }
  207. ODBoolean            RunningUnderMacOS8();
  208.  
  209. class ODSetUpPrefs
  210. {
  211.   public:
  212.       ODSetUpPrefs(short refNum, short permissions);
  213.         // refNum == -1 means to open file, otherwise, just use this refnum.
  214.         //    if refNum is valid, then permissions indicates the currents perms,
  215.         //    otherwise, permissions is ignored.
  216.     ~ODSetUpPrefs();
  217. //    Boolean    GetRunAtSysStartup(); // LOOK AT ALIAS FILE
  218.     Boolean    GetRunTilSysShutdown();
  219. //    OSErr    SetRunAtSysStartup(Boolean runAtSysStartup); // LOOK AT ALIAS FILE
  220.     OSErr    SetRunTilSysShutdown(Boolean runTilSysShutdown);
  221.     OSErr    GetDefaultSize(Size& size);
  222.     OSErr    SetDefaultSize(Size newSize);
  223.   private:
  224.     #if PRAGMA_ALIGN_SUPPORTED
  225.     #pragma options align=mac68k
  226.     #endif
  227.     
  228.     struct ODSetupPrefsResource
  229.     {
  230.         long    version;
  231.         Boolean    runAtSysStartup;
  232.         Boolean    runTilSysShutdown;
  233.     };
  234.     
  235.     typedef ODSetupPrefsResource *ODSetupPrefsResourcePtr,
  236.                                     **ODSetupPrefsResourceH;
  237.     
  238.     #if PRAGMA_ALIGN_SUPPORTED
  239.     #pragma options align=reset
  240.     #endif
  241.  
  242.       short                    fPermissions;
  243.     short                    fRefNum;
  244.     ODSetupPrefsResourceH    fResource;
  245.     Boolean                    fRunAtSysStartup;
  246.     Boolean                    fRunTilSysShutdown;
  247.     Boolean                    fOpenedFileMyself;
  248.  
  249.     OSErr                    UpdateFile();
  250. };
  251.  
  252. const AEEventID        kSysProcControlEventID = 'spcl';
  253. const AEKeyword        kControlMessageKeyword = 'mmsg';
  254.  
  255. #define kNoMessage                0 // used to see if the process returns noErr
  256. #define kStartAtSysStartup        1 // not currently used
  257. #define kStartAtFirstDocOpen    2 // not currently used
  258. #define kRunUntilQuitEvent        3
  259. #define kShutdownAtLastDocQuit    4
  260.  
  261.  
  262. #if PRAGMA_ALIGN_SUPPORTED
  263. #pragma options align=mac68k
  264. #endif
  265.  
  266.         struct VersRsrc {
  267.             long    versJunk;
  268.             short    region;
  269.             Str255    versionStr;
  270.         };
  271.  
  272. #if PRAGMA_ALIGN_SUPPORTED
  273. #pragma options align=reset
  274. #endif
  275.  
  276.  
  277. #endif /* _ODPRCS_ */
  278.