LocationManager.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:14k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /*
  2.      File:       LocationManager.h
  3.  
  4.      Contains:   LocationManager (manages groups of settings)
  5.  
  6.      Version:    Technology: Mac OS 8
  7.                  Release:    QuickTime 6.0.2
  8.  
  9.      Copyright:  (c) 1995-2001 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:      For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __LOCATIONMANAGER__
  18. #define __LOCATIONMANAGER__
  19. #ifndef __APPLEEVENTS__
  20. #include "AppleEvents.h"
  21. #endif
  22. #ifndef __COMPONENTS__
  23. #include "Components.h"
  24. #endif
  25. #ifndef __DIALOGS__
  26. #include "Dialogs.h"
  27. #endif
  28. #ifndef __PROCESSES__
  29. #include "Processes.h"
  30. #endif
  31. #ifndef __STANDARDFILE__
  32. #include "StandardFile.h"
  33. #endif
  34. #if PRAGMA_ONCE
  35. #pragma once
  36. #endif
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. #if PRAGMA_IMPORT
  41. #pragma import on
  42. #endif
  43. #if PRAGMA_STRUCT_ALIGN
  44.     #pragma options align=mac68k
  45. #elif PRAGMA_STRUCT_PACKPUSH
  46.     #pragma pack(push, 2)
  47. #elif PRAGMA_STRUCT_PACK
  48.     #pragma pack(2)
  49. #endif
  50. /* Location Manager API Support -------------------------------------------------------------------- */
  51. /* A Location Token uniquely identifies a Location on a machine... */
  52. typedef struct OpaqueALMToken*          ALMToken;
  53. #define kALMNoLocationToken ((ALMToken)(-1))  // ALMToken of "off" Location...
  54. enum {
  55.     kALMLocationNameMaxLen      = 31,                           /* name (actually imposed by file system)... */
  56.     kALMNoLocationIndex         = -1                            /* index for the "off" Location (kALMNoLocationToken)... */
  57. };
  58. typedef Str31                           ALMLocationName;
  59. /* Returned from ALMConfirmName... */
  60. typedef SInt16 ALMConfirmChoice;
  61. enum {
  62.     kALMConfirmRename           = 1,
  63.     kALMConfirmReplace          = 2
  64. };
  65. /* ALMConfirmName dialog item numbers for use in callbacks (ALM 2.0)... */
  66. enum {
  67.     kALMDuplicateRenameButton   = 1,                            /* if Window refcon is kALMDuplicateDialogRefCon... */
  68.     kALMDuplicateReplaceButton  = 2,
  69.     kALMDuplicateCancelButton   = 3,
  70.     kALMDuplicatePromptText     = 5
  71. };
  72. enum {
  73.     kALMRenameRenameButton      = 1,                            /* if Window refcon is kALMRenameDialogRefCon... */
  74.     kALMRenameCancelButton      = 2,
  75.     kALMRenameEditText          = 3,
  76.     kALMRenamePromptText        = 4
  77. };
  78. /* Refcons of two windows in ALMConfirmName (ALM 2.0)... */
  79. enum {
  80.     kALMDuplicateDialogRefCon   = FOUR_CHAR_CODE('dupl'),
  81.     kALMRenameDialogRefCon      = FOUR_CHAR_CODE('rnam')
  82. };
  83. /* Callback routine for Location awareness (mimics AppleEvents) in non-application code... */
  84. typedef CALLBACK_API( void , ALMNotificationProcPtr )(AppleEvent *theEvent);
  85. typedef STACK_UPP_TYPE(ALMNotificationProcPtr)                  ALMNotificationUPP;
  86. #if OPAQUE_UPP_TYPES
  87. #if CALL_NOT_IN_CARBON
  88.     EXTERN_API(ALMNotificationUPP)
  89.     NewALMNotificationUPP          (ALMNotificationProcPtr  userRoutine);
  90.     EXTERN_API(void)
  91.     DisposeALMNotificationUPP      (ALMNotificationUPP      userUPP);
  92.     EXTERN_API(void)
  93.     InvokeALMNotificationUPP       (AppleEvent *            theEvent,
  94.                                     ALMNotificationUPP      userUPP);
  95. #endif  /* CALL_NOT_IN_CARBON */
  96. #else
  97.     enum { uppALMNotificationProcInfo = 0x000000C0 };               /* pascal no_return_value Func(4_bytes) */
  98.     #define NewALMNotificationUPP(userRoutine)                      (ALMNotificationUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppALMNotificationProcInfo, GetCurrentArchitecture())
  99.     #define DisposeALMNotificationUPP(userUPP)                      DisposeRoutineDescriptor(userUPP)
  100.     #define InvokeALMNotificationUPP(theEvent, userUPP)             CALL_ONE_PARAMETER_UPP((userUPP), uppALMNotificationProcInfo, (theEvent))
  101. #endif
  102. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  103. #define NewALMNotificationProc(userRoutine)                     NewALMNotificationUPP(userRoutine)
  104. #define CallALMNotificationProc(userRoutine, theEvent)          InvokeALMNotificationUPP(theEvent, userRoutine)
  105. /* Notification AppleEvents sent to apps/registered code...  */
  106. enum {
  107.     kAELocationChangedNoticeKey = FOUR_CHAR_CODE('walk'),       /* Current Location changed... */
  108.     kAELocationRescanNoticeKey  = FOUR_CHAR_CODE('trip')        /* Location created/renamed/deleted... */
  109. };
  110. /* ALMSwitchToLocation masks... */
  111. typedef SInt32 ALMSwitchActionFlags;
  112. enum {
  113.     kALMDefaultSwitchFlags      = 0x00000000,                   /* No special action to take... */
  114.     kALMDontShowStatusWindow    = 0x00000001,                   /* Suppress "switching" window... */
  115.     kALMSignalViaAE             = 0x00000002                    /* Switch by sending Finder AppleEvent... */
  116. };
  117. /* Parameters for Get/Put/Merge Location calls... */
  118. typedef const OSType *                  ConstALMModuleTypeListPtr;
  119. enum {
  120.     kALMAddAllOnSimple          = 0,                            /* Add all single-instance, non-action modules... */
  121.     kALMAddAllOff               = -1                            /* Add all modules but turn them off... */
  122. };
  123. /* Item numbers for use in Get/Put/Merge Location filters... */
  124. enum {
  125.     kALMLocationSelectButton    = 1,
  126.     kALMLocationCancelButton    = 2,
  127.     kALMLocationBalloonHelp     = 3,
  128.     kALMLocationLocationList    = 7,
  129.     kALMLocationLocationNameEdit = 10,
  130.     kALMLocationPromptText      = 11
  131. };
  132. enum {
  133.     kALMLocationSaveButton      = kALMLocationSelectButton
  134. };
  135. /* Location Manager Module API Support ------------------------------------------------------------- */
  136. /* ALMGetScriptInfo stuff... */
  137. enum {
  138.     kALMScriptInfoVersion       = 2                             /* Customarily put in resource for localization... */
  139. };
  140. struct ALMScriptManagerInfo {
  141.     SInt16                          version;                    /* Set to kALMScriptInfoVersion... */
  142.     SInt16                          scriptCode;
  143.     SInt16                          regionCode;
  144.     SInt16                          langCode;
  145.     SInt16                          fontNum;
  146.     SInt16                          fontSize;
  147. };
  148. typedef struct ALMScriptManagerInfo     ALMScriptManagerInfo;
  149. typedef ALMScriptManagerInfo *          ALMScriptManagerInfoPtr;
  150. /*
  151.    Alternate form of ScriptInfo is easier to localize in resources; it is used extensively in
  152.    samples and internally, so....
  153. */
  154. struct ALMAltScriptManagerInfo {
  155.     SInt16                          version;
  156.     SInt16                          scriptCode;
  157.     SInt16                          regionCode;
  158.     SInt16                          langCode;
  159.     SInt16                          fontSize;
  160.     Str63                           fontName;
  161. };
  162. typedef struct ALMAltScriptManagerInfo  ALMAltScriptManagerInfo;
  163. typedef ALMAltScriptManagerInfo *       ALMAltScriptManagerInfoPtr;
  164. typedef ALMAltScriptManagerInfoPtr *    ALMAltScriptManagerInfoHandle;
  165. enum {
  166.     kALMAltScriptManagerInfoRsrcType = FOUR_CHAR_CODE('trip'),
  167.     kALMAltScriptManagerInfoRsrcID = 0
  168. };
  169. /* Reboot information used on ALMSetCurrent (input/output parameter)... */
  170. typedef UInt32 ALMRebootFlags;
  171. enum {
  172.     kALMNoChange                = 0,
  173.     kALMAvailableNow            = 1,
  174.     kALMFinderRestart           = 2,
  175.     kALMProcesses               = 3,
  176.     kALMExtensions              = 4,
  177.     kALMWarmBoot                = 5,
  178.     kALMColdBoot                = 6,
  179.     kALMShutdown                = 7
  180. };
  181. /*
  182.    File types and signatures...
  183.    Note: auto-routing of modules will not be supported for 'thng' files...
  184. */
  185. enum {
  186.     kALMFileCreator             = FOUR_CHAR_CODE('fall'),       /* Creator of Location Manager files... */
  187.     kALMComponentModuleFileType = FOUR_CHAR_CODE('thng'),       /* Type of a Component Manager Module file [v1.0]... */
  188.     kALMComponentStateModuleFileType = FOUR_CHAR_CODE('almn'),  /* Type of a CM 'state' Module file... */
  189.     kALMComponentActionModuleFileType = FOUR_CHAR_CODE('almb'), /* Type of a CM 'action' Module file... */
  190.     kALMCFMStateModuleFileType  = FOUR_CHAR_CODE('almm'),       /* Type of a CFM 'state' Module file... */
  191.     kALMCFMActionModuleFileType = FOUR_CHAR_CODE('alma')        /* Type of a CFM 'action' Module file... */
  192. };
  193. /* Component Manager 'thng' info... */
  194. enum {
  195.     kALMComponentRsrcType       = FOUR_CHAR_CODE('thng'),
  196.     kALMComponentType           = FOUR_CHAR_CODE('walk')
  197. };
  198. /* CFM Modules require a bit of information (replacing some of the 'thng' resource)... */
  199. enum {
  200.     kALMModuleInfoRsrcType      = FOUR_CHAR_CODE('walk'),
  201.     kALMModuleInfoOriginalVersion = 0
  202. };
  203. /* These masks apply to the "Flags" field in the 'thng' or 'walk' resource... */
  204. enum {
  205.     kALMMultiplePerLocation     = 0x00000001,                   /* Module can be added more than once to a Location... */
  206.     kALMDescriptionGetsStale    = 0x00000002                    /* Descriptions may change though the setting didn't...  */
  207. };
  208. /* Misc stuff for older implementations ------------------------------------------------------------ */
  209. #if OLDROUTINENAMES
  210. /* Old error codes for compatibility - new names are in Errors interface... */
  211. enum {
  212.     ALMInternalErr              = -30049,                       /* use kALMInternalErr */
  213.     ALMLocationNotFound         = -30048,                       /* use kALMLocationNotFoundErr */
  214.     ALMNoSuchModuleErr          = -30047,                       /* use kALMNoSuchModuleErr */
  215.     ALMModuleCommunicationErr   = -30046,                       /* use kALMModuleCommunicationErr */
  216.     ALMDuplicateModuleErr       = -30045,                       /* use kALMDuplicateModuleErr */
  217.     ALMInstallationErr          = -30044,                       /* use kALMInstallationErr */
  218.     ALMDeferSwitchErr           = -30043                        /* use kALMDeferSwitchErr */
  219. };
  220. /* Old ALMConfirmName constants... */
  221. enum {
  222.     ALMConfirmRenameConfig      = kALMConfirmRename,
  223.     ALMConfirmReplaceConfig     = kALMConfirmReplace
  224. };
  225. /* Old AppleEvents... */
  226. enum {
  227.     kAELocationNotice           = kAELocationChangedNoticeKey
  228. };
  229. typedef ALMScriptManagerInfo            ALMScriptMgrInfo;
  230. typedef UInt32                          ALMComponentFlagsEnum;
  231. #endif  /* OLDROUTINENAMES */
  232. /* Location Manager API ---------------------------------------------------------------------------- */
  233. /* The following 7 routines are present if gestaltALMAttr has bit gestaltALMPresent set... */
  234. #if CALL_NOT_IN_CARBON
  235. EXTERN_API( OSErr )
  236. ALMGetCurrentLocation           (SInt16 *               index,
  237.                                  ALMToken *             token,
  238.                                  ALMLocationName        name)                               THREEWORDINLINE(0x303C, 0x0600, 0xAAA4);
  239. EXTERN_API( OSErr )
  240. ALMGetIndLocation               (SInt16                 index,
  241.                                  ALMToken *             token,
  242.                                  ALMLocationName        name)                               THREEWORDINLINE(0x303C, 0x0501, 0xAAA4);
  243. EXTERN_API( OSErr )
  244. ALMCountLocations               (SInt16 *               locationCount)                      THREEWORDINLINE(0x303C, 0x0202, 0xAAA4);
  245. EXTERN_API( OSErr )
  246. ALMSwitchToLocation             (ALMToken               newLocation,
  247.                                  ALMSwitchActionFlags   switchFlags)                        THREEWORDINLINE(0x303C, 0x0403, 0xAAA4);
  248. EXTERN_API( OSErr )
  249. ALMRegisterNotifyProc           (ALMNotificationUPP     notificationProc,
  250.                                  const ProcessSerialNumber * whichPSN)                      THREEWORDINLINE(0x303C, 0x0404, 0xAAA4);
  251. EXTERN_API( OSErr )
  252. ALMRemoveNotifyProc             (ALMNotificationUPP     notificationProc,
  253.                                  const ProcessSerialNumber * whichPSN)                      THREEWORDINLINE(0x303C, 0x0405, 0xAAA4);
  254. EXTERN_API( OSErr )
  255. ALMConfirmName                  (ConstStr255Param       message,
  256.                                  Str255                 theName,
  257.                                  ALMConfirmChoice *     choice,
  258.                                  ModalFilterUPP         filter)                             THREEWORDINLINE(0x303C, 0x0806, 0xAAA4);
  259. /* The following 3 routines are present if gestaltALMAttr has bit gestaltALMHasSFLocation set... */
  260. EXTERN_API( OSErr )
  261. ALMPutLocation                  (ConstStr255Param       prompt,
  262.                                  ALMLocationName        name,
  263.                                  SInt16                 numTypes,
  264.                                  ConstALMModuleTypeListPtr  typeList,
  265.                                  ModalFilterYDUPP       filter,
  266.                                  void *                 yourDataPtr)                        THREEWORDINLINE(0x303C, 0x0B07, 0xAAA4);
  267. EXTERN_API( OSErr )
  268. ALMGetLocation                  (ConstStr255Param       prompt,
  269.                                  ALMLocationName        name,
  270.                                  ModalFilterYDUPP       filter,
  271.                                  void *                 yourDataPtr)                        THREEWORDINLINE(0x303C, 0x0808, 0xAAA4);
  272. EXTERN_API( OSErr )
  273. ALMMergeLocation                (ConstStr255Param       prompt,
  274.                                  ALMLocationName        name,
  275.                                  SInt16                 numTypes,
  276.                                  ConstALMModuleTypeListPtr  typeList,
  277.                                  ModalFilterYDUPP       filter,
  278.                                  void *                 yourDataPtr)                        THREEWORDINLINE(0x303C, 0x0B09, 0xAAA4);
  279. #endif  /* CALL_NOT_IN_CARBON */
  280. #if PRAGMA_STRUCT_ALIGN
  281.     #pragma options align=reset
  282. #elif PRAGMA_STRUCT_PACKPUSH
  283.     #pragma pack(pop)
  284. #elif PRAGMA_STRUCT_PACK
  285.     #pragma pack()
  286. #endif
  287. #ifdef PRAGMA_IMPORT_OFF
  288. #pragma import off
  289. #elif PRAGMA_IMPORT
  290. #pragma import reset
  291. #endif
  292. #ifdef __cplusplus
  293. }
  294. #endif
  295. #endif /* __LOCATIONMANAGER__ */