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