notifymgr.pp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. {$MACRO ON}
  2. {$define Rsc := }
  3. (******************************************************************************
  4. *
  5. * Copyright (c) 1998-2000 Palm, Inc. or its subsidiaries.
  6. * All rights reserved.
  7. *
  8. * File: NotifyMgr.h
  9. *
  10. * Release: Palm OS SDK 4.0 (63220)
  11. *
  12. * Description:
  13. * Include file for Notification Manager
  14. *
  15. * History:
  16. * 6/15/98 JED - Created by Jesse Donaldson
  17. * 12/23/99 jmp - Fix <> vs. "" problem.
  18. * 10/19/00 PPL - Change cncNotifyCurrentConfigurationChange 'conf'
  19. * to cncNotifyProfileEvent 'cncp'
  20. *
  21. *****************************************************************************)
  22. unit notifymgr;
  23. interface
  24. uses palmos, coretraps, datamgr, localemgr, systemresources;
  25. type
  26. SysNotifyParamType = record
  27. notifyType: UInt32; // What type of event occurred?
  28. broadcaster: UInt32; // normally creator code of broadcasting app
  29. notifyDetailsP: Pointer; // ptr to notification-specific data, if any
  30. userDataP: Pointer; // user specified ptr passed back with notification
  31. handled: Boolean; // true if event is handled yet
  32. reserved2: UInt8;
  33. end;
  34. type
  35. SysNotifyProc = function (var notifyParamsP: SysNotifyParamType): Err;
  36. SysNotifyProcPtr = SysNotifyProc;
  37. const
  38. sysNotifyNormalPriority = 0; // clients should use this priority
  39. sysNotifyBroadcasterCode = sysFileCSystem; // broadcaster code for events broadcast by the system
  40. sysNotifyNoDatabaseID = $FFFFFFFF; // for system use only!!!
  41. sysNotifyVersionNum = 1; // version of the NotifyMgr, obtained from the feature
  42. // The queue is much smaller in debug builds so that we aren't tempted to overflow it
  43. // (and larger for release builds so that when we do, it will work).
  44. sysNotifyDefaultQueueSize = 30;
  45. (*
  46. Notify Manager Events:
  47. Note that in general, for notifications regarding the creation of information
  48. (e.g. sysNotifyDBAddedEvent) the broadcast goes out AFTER the fact (e.g.,
  49. after the database has been created) and that notifications regarding
  50. the deletion of information are broadcast BEFORE the fact. A notable and
  51. unfortunate exception to this rule is the database deleted notification, which
  52. is sent out after the fact.
  53. The sleep & wake notifications require a little special attention. These
  54. notifications are _not_ guaranteed to always be broadcast, and hence are unsuitable
  55. for applications where syscall hardware must be shut off to conserve power when
  56. we go to sleep. For example, the sleep notification will not be broadcast when
  57. we do an emergency shutdown due to low battery conditions. Also note that any
  58. sort of prolonged activity (especially displaying UI sich as a dialog) in response
  59. to these noticfications can complicate things immensely. UI is very tricky because
  60. these notifications are broadcast from SysHandleEvent. The result is that you may
  61. receive more than one sleep notification if one of the notification clients puts up
  62. a dialog or something, and it remains there long enough for another AutoOff event
  63. to come through. There are also possible problems with reentrancy and stack space
  64. usage since the notification is broadcast from SysHandleEvent inside an application's
  65. event loop.
  66. *)
  67. sysNotifySyncStartEvent = Rsc('hots');
  68. // Sent at the start of a hotsync.
  69. // Always sent from UI thread.
  70. // param: none
  71. sysNotifySyncFinishEvent = Rsc('sync');
  72. // Sent at the end of a hotsync.
  73. // Always sent from UI thread.
  74. // param: none
  75. sysNotifyAntennaRaisedEvent = Rsc('tena');
  76. // Sent when the antenna is raised on a
  77. // Palm VII series device.
  78. // Always sent from UI thread.
  79. // param: none
  80. sysNotifyResetFinishedEvent = Rsc('rstf');
  81. // Broadcast after all app launchcodes
  82. // are sent after a reset.
  83. // Always sent from UI thread.
  84. // param: none
  85. sysNotifyForgotPasswordEvent = Rsc('bozo');
  86. // Broadcast when the user presses the
  87. // 'Forgotten Password' button in the
  88. // security app, just before every database's
  89. // private records are deleted.
  90. sysNotifyTimeChangeEvent = Rsc('time');
  91. // Broadcast when the time is changed by the user.
  92. // param: Int32*, ptr to time change delta in
  93. // seconds (e.g., a value of 100 means that the
  94. // user set the clock ahead 100 seconds).
  95. sysNotifySleepRequestEvent = Rsc('slpq');
  96. // A "Sleep Request Event" is broadcast when the device
  97. // is about to go to sleep, and is a chance for clients
  98. // to do perform an action or even delay going to sleep
  99. // for a little while. This may be broadcast multiple
  100. // times if one or more clients defer the sleep. Parameter
  101. // is a pointer to a SleepEventParamType. See below
  102. // details on this structure. Note that this event is
  103. // NOT guaranteed to be broadcast. See the big comment
  104. // at the top of this list for important detials & warnings.
  105. // Always sent from UI thread.
  106. sysNotifySleepNotifyEvent = Rsc('slp!');
  107. // A "Sleep Notify Event" is broadcast when the device is
  108. // definitely going to sleep as soon as the broadcast
  109. // is finished. Parameter is unused.
  110. // Note that this event is NOT guaranteed to be broadcast.
  111. // See the big comment at the top of this list for
  112. // important detials & warnings.
  113. // Always sent from UI thread.
  114. sysNotifyEarlyWakeupEvent = Rsc('worm');
  115. // ...the early bird gets the worm...
  116. // Broadcast just after the device wakes up
  117. // at the early stage where the screen may
  118. // still be turned off and we may quickly go
  119. // back to sleep after handling an alarm or
  120. // charger event.
  121. // Always sent from UI thread.
  122. sysNotifyLateWakeupEvent = Rsc('lazy');
  123. // Broadcast after the device wakes up
  124. // at the later stage of the wakeup
  125. // process after we turn the screen on,
  126. // broadcast from EvtResetAutoOffEvent
  127. // the first time it is called implying
  128. // that the device will remain awake
  129. // for at least a little while.
  130. // Always sent from UI thread.
  131. sysNotifyDisplayChangeEvent = Rsc('scrd');
  132. // Sent when the display depth is
  133. // changed, notifyDetailsP has old/new depth
  134. // see SysNotifyDisplayChangeDetailsType
  135. sysNotifyMenuCmdBarOpenEvent = Rsc('cbar');
  136. // Sent by FormHandleEvent when a menuCmdBarOpenEvent
  137. // passes through. The system will not open the toolbar
  138. // if the 'handled' field is set in the parameter block,
  139. // so most clients should not set it. The notification
  140. // is provided so that Hack-like entities can catch
  141. // it and add their own buttons to the bar. These
  142. // buttons will show up to the left of cut/copy/paste/undo and
  143. // to the right of everything else. Without this
  144. // notification, people would hack SysHandleEvent... ick.
  145. cncNotifyProfileEvent = Rsc('cncp');
  146. // sent by the Connection Panel to inform its clients
  147. // that the current configuration has change
  148. // void * notifyDetailsP : has to be casted as UInt32
  149. // to get the Broadcasted Profile ID user specified ptr
  150. // passed back with notification
  151. // void * userDataP : has to be casted as UInt16
  152. // to get the device kind of the Broadcasted Profile ID
  153. syssyscallConnectorAttachEvent = Rsc('ecna');
  154. // Broadcast when anything is attached to
  155. // the syscall connector.
  156. syssyscallConnectorDetachEvent = Rsc('ecnd');
  157. // Broadcast when anything is detached from
  158. // the syscall connector.
  159. sysNotifyCardInsertedEvent = Rsc('crdi');
  160. // Broadcast when an ExpansionMgr card is
  161. // inserted into a slot, and the slot driver
  162. // calls ExpCardInserted. Always broadcast
  163. // from UI task.
  164. // ExpansionMgr will play a sound & attempt to
  165. // mount a volume unless the corresponding
  166. // bits in the 'handled' field are set by a
  167. // notification handler (see ExpansionMgr.h).
  168. // PARAMETER: slot number cast as void*
  169. sysNotifyCardRemovedEvent = Rsc('crdo');
  170. // Broadcast when an ExpansionMgr card is
  171. // removed from a slot, and the slot driver
  172. // calls ExpCardRemoved. Always broadcast
  173. // from UI task.
  174. // ExpansionMgr will play a sound & attempt to
  175. // unmount a volume unless the corresponding
  176. // bits in the 'handled' field are set by a
  177. // notification handler (see ExpansionMgr.h).
  178. // PARAMETER: slot number cast as void*
  179. sysNotifyVolumeMountedEvent = Rsc('volm');
  180. // Broadcast when a VFSMgr volume is
  181. // mounted, Always broadcast from UI task.
  182. // VFSMgr will run start.prc (if present),
  183. // and SysUIAppSwitch to it or the Launcher
  184. // unless the appropriate bits in the 'handled'
  185. // field are set by a notification handler.
  186. // PARAMETER: VFSAnyMountParamPtr cast as void*
  187. sysNotifyVolumeUnmountedEvent = Rsc('volu');
  188. // Broadcast AFTER a VFSMgr volume is
  189. // unmounted, Always broadcast from UI task.
  190. // VFSMgr will delete start.prc (if it was loaded).
  191. // The volume ref number for the unmounted volume is
  192. // NO LONGER VALID, so don't bother trying to use it.
  193. // PARAMETER: volume refNum cast as void*
  194. sysNotifyHelperEvent = Rsc('hlpr');
  195. // Sent by Address Book (or any
  196. // 3rd party application) to
  197. // communicate with Phone Apps
  198. sysNotifyPOSEMountEvent = Rsc('pose');
  199. // Sent by HostFS to communicate with itself,
  200. // saving on stack depth.
  201. sysNotifyLocaleChangedEvent = Rsc('locc');
  202. // Notify apps/panel that the system locale
  203. // has changed.
  204. // This is broadcast by the language picker after it
  205. // has changed the locale.
  206. // Always sent from UI thread.
  207. // param: ptr to SysNotifyLocaleChangedType
  208. sysNotifyRetryEnqueueKey = Rsc('retk');
  209. // An EvtEnqueueKey failed, so retry.
  210. sysNotifyGotUsersAttention = Rsc('attn');
  211. // Got users attention.
  212. sysNotifyDBDeletedEvent = Rsc('dbs-');
  213. // broadcast AFTER a database is removed from the device.
  214. // Note that the database ID in the parameter block is
  215. // NO LONGER VALID, and you WILL CRASH the device if you
  216. // try to pass it to any DataMgr routines.
  217. // notifyDetailsP: ptr to SysNotifyDBDeletedType.
  218. sysNotifyDeviceUnlocked = Rsc('unlk');
  219. // Broadcasted by the Security app After the device is
  220. //unlocked.
  221. //notifyDetailsP: none
  222. sysNotifyPhoneEvent = Rsc('fone');
  223. // Sent by third-party applications to communicate
  224. // with built-in or syscall phones.
  225. // NOTE THAT THIS EVENT IS FOR FUTURE USE
  226. sysNotifyNetLibIFMediaEvent = Rsc('neti');
  227. // Broadcasted by NetLib to communicate its interfaces media Up and Down requests
  228. // to registered Apps.
  229. // notifyDetailsP: ptr to SysNotifyNetLibIFMediaType.
  230. sysNotifyDeleteProtectedEvent = Rsc('-pdb');
  231. // Broadcast BEFORE a database is removed from the device when a user
  232. // or installer application wants to remove a protected database. This
  233. // will ONLY be issued from the UI task and should be issued before each
  234. // user driven deletion that targets a protected database that the app
  235. // running does not own (i.e. needs to request be unprotected).
  236. // This gives the unlucky client a chance to do any required
  237. // cleanup work. Note that if an application has multiple protected
  238. // databases, this notification may be sent out more than once.
  239. // notifyDetailsP: ptr to SysNotifyDBInfoType.
  240. sysNotifyIrDASniffEvent = Rsc('irda');
  241. // Sent by IrDA sniffing code when an incomming IrDA frame is detected
  242. // for sysNotifyDisplayChangeEvent
  243. type
  244. SysNotifyDisplayChangeDetailsTag = record
  245. oldDepth: UInt32;
  246. newDepth: UInt32;
  247. end;
  248. SysNotifyDisplayChangeDetailsType = SysNotifyDisplayChangeDetailsTag;
  249. // For sysNotifyLocaleChangedEvent
  250. type
  251. SysNotifyLocaleChangedTag = record
  252. oldLocale: LmLocaleType;
  253. newLocale: LmLocaleType;
  254. end;
  255. SysNotifyLocaleChangedType = SysNotifyLocaleChangedTag;
  256. // Possible values for the sleep-reason for the sysNotifySleepEvent
  257. const
  258. sysSleepPowerButton = 0;
  259. sysSleepAutoOff = 1;
  260. sysSleepResumed = 2;
  261. sysSleepUnknown = 3;
  262. // for sysNotifySleepRequestEvent
  263. type
  264. SleepEventParamTag = record
  265. reason: UInt16; // contains the reason we are going to sleep. See above list for possible values.
  266. deferSleep: UInt16; // Only used for the sysNotifySleepRequestEvent, this should be incremented by
  267. // clients that want to defer the sleep. They are then responsible for enqueing
  268. // a resumeSleepChr in the event queue.
  269. end;
  270. SleepEventParamType = SleepEventParamTag;
  271. // for sysNotifyDeleteProtectedEvent, and possibly others...
  272. type
  273. SysNotifyDBInfoTag = record
  274. dbID: LocalID; // database ID of dabatase
  275. cardNo: UInt16; // card number that dabatase resides on
  276. attributes: UInt16; // database attributes
  277. dbName: array [0..dmDBNameLength-1] of Char; // name of database
  278. creator: UInt32; // creator code of dabatase
  279. type_: UInt32; // type of dabatase
  280. end;
  281. SysNotifyDBInfoType = SysNotifyDBInfoTag;
  282. // for sysNotifyDBDeletedEvent
  283. type
  284. SysNotifyDBDeletedTag = record
  285. oldDBID: LocalID; // old database ID of dabatase, no longer valid
  286. cardNo: UInt16; // card number that dabatase resides on
  287. attributes: UInt16; // database attributes
  288. dbName: array [0..dmDBNameLength-1] of Char; // name of database
  289. creator: UInt32; // creator code of dabatase
  290. type_: UInt32; // type code of dabatase
  291. end;
  292. SysNotifyDBDeletedType = SysNotifyDBDeletedTag;
  293. (*
  294. Possible event types to be added in the future:
  295. NOTE that these are NOT implemented yet!!!!
  296. sysNotifyDBAddedEvent = Rsc('dbs+');
  297. // Broadcast after a database is added to the device
  298. // param: ptr to SysNotifyDBInfoType.
  299. sysNotifyInitializeEvent = Ord('helo');
  300. // broadcast to an app after its installed
  301. // so it can do any necessary initalization
  302. // This event is always broadcast.
  303. // param: ptr to SysNotifyDBInfoType.
  304. sysNotifyCleanupEvent = Ord('gbye');
  305. // broadcast to an app just before its deleted
  306. // so it can do any necessary cleanup work.
  307. // This event is always broadcast.
  308. // The database's type will have been set to
  309. // sysFileTTemp so that if case the handler
  310. // crashes, the DB will be deleted on reset.
  311. // param: ptr to SysNotifyDBInfoType.
  312. sysNotifyCardChangedEvent = Ord('card');
  313. // broadcast when the owner's business card
  314. // has changed, allowing apps to adjust for that.
  315. // param: ptr to new owner data.
  316. *)
  317. function SysNotifyRegister(cardNo: UInt16; dbID: LocalID; notifyType: UInt32;
  318. callbackP: SysNotifyProcPtr; priority: Int8; userDataP: Pointer): Err; syscall sysTrapSysNotifyRegister;
  319. function SysNotifyUnregister(cardNo: UInt16; dbID: LocalID; notifyType: UInt32; priority: Int8): Err; syscall sysTrapSysNotifyUnregister;
  320. (*
  321. * WARNING: Never call SysNotifyBroadcast from a background task
  322. * (or from any code that might be called from a BG task)
  323. * with the memory semaphore reserved. Deadlock will
  324. * result when the broadcast is deferred and the UI task
  325. * tries to acquire the mem semaphore in order to send it out.
  326. *)
  327. function SysNotifyBroadcast(var notify: SysNotifyParamType): Err; syscall sysTrapSysNotifyBroadcast;
  328. function SysNotifyBroadcastDeferred(var notify: SysNotifyParamType; paramSize: Int16): Err; syscall sysTrapSysNotifyBroadcastDeferred;
  329. // Kick off a notification from an interrupt handler.
  330. // Note: non-interrupt code should use SysNotifyBroadcast
  331. function SysNotifyBroadcastFromInterrupt(notifyType: UInt32; broadcaster: UInt32;
  332. notifyDetailsP: Pointer): Err; syscall sysTrapSysNotifyBroadcastFromInterrupt;
  333. implementation
  334. end.