preferences.pp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. (******************************************************************************
  2. *
  3. * Copyright (c) 1995-2000 Palm, Inc. or its subsidiaries.
  4. * All rights reserved.
  5. *
  6. * File: Preferences.h
  7. *
  8. * Release: Palm OS SDK 4.0 (63220)
  9. *
  10. * Description:
  11. * Header for the system preferences
  12. *
  13. * History:
  14. * 02/31/95 rsf Created by Roger Flores
  15. * 06/26/99 kwk Added LanguageType.
  16. * 06/30/99 CS Added MeasurementSystemType, then added it to both
  17. * CountryPreferencesType and SystemPreferencesType,
  18. * and bumped the version to 7.
  19. * CS Added prefMeasurementSystem to select this
  20. * preference.
  21. * CS Added filler fields to CountryPreferencesType
  22. * structure, since this guy gets saved as a
  23. * resource.
  24. * 09/20/99 gap added additional cXXXX country values.
  25. * 09/20/99 gap cPRC -> cRepChina.
  26. * 10/4/99 jmp Add support for auto-off duration times in seconds
  27. * instead of minutes (the new seconds-based auto-off
  28. * duration time is preferred; the minutes-based auto-ff
  29. * duration times are maintained for compatibility).
  30. * 10/5/99 jmp Make the seconds auto-off duration field a UInt16
  31. * instead of a UInt8; also define constants for the
  32. * "pegged" auto-off duration values (when the value
  33. * is pegged, we no longer automatically shut off).
  34. * 12/23/99 jmp Fix <> vs. "" problem.
  35. * 04/30/00 CS Use LmCountryType instead of CountryType. Also removed
  36. * deprecated countryNameLength, currencyNameLength, and
  37. * currencySymbolLength, replacing usage with new
  38. * kMaxCountryNameLen, kMaxCurrencyNameLen, and
  39. * kMaxCurrencySymbolLen.
  40. * 05/16/00 CS LmCountryType/LmLanguageType are now back to
  41. * CountryType/LanguageType.
  42. * 08/01/00 CS Added prefLanguage & prefLocale to selector set, and
  43. * locale to SystemPreferencesType.
  44. * 08/01/00 kwk Added timeZoneCountry to SystemPreferencesType, and
  45. * prefTimeZoneCountry to SystemPreferencesChoice.
  46. * 08/08/00 CS Moved obsolete CountryPreferencesType to RezConvert.cp,
  47. * since that's the only code that still needs access to
  48. * this private, obsolete resource.
  49. * 08/08/00 peter Added attentionFlags to SystemPreferencesType, and
  50. * prefAttentionFlags to SystemPreferencesChoice.
  51. * 11/07/00 grant Added button default assignment resource type.
  52. *
  53. *****************************************************************************)
  54. unit preferences;
  55. interface
  56. uses palmos, coretraps, datamgr, localemgr, datetime, localize, attentionmgr, systemmgr;
  57. (***********************************************************************
  58. * Constants
  59. ***********************************************************************)
  60. const
  61. noPreferenceFound = -1;
  62. // Preference version constants
  63. preferenceDataVer2 = 2; // Palm OS 2.0
  64. preferenceDataVer3 = 3; // Palm OS 3.0
  65. preferenceDataVer4 = 4; // Palm OS 3.1
  66. preferenceDataVer5 = 5; // Palm OS 3.2a
  67. preferenceDataVer6 = 6; // Palm OS 3.2b/3.3
  68. preferenceDataVer8 = 8; // Palm OS 3.5
  69. preferenceDataVer9 = 9; // Palm OS 4.0
  70. // Be SURE to update "preferenceDataVerLatest" when adding a new prefs version...
  71. preferenceDataVerLatest = preferenceDataVer9;
  72. defaultAutoOffDuration = 2; // minutes
  73. defaultAutoOffDurationSecs = 2 * minutesInSeconds; // seconds
  74. peggedAutoOffDuration = $FF; // minutes (UInt8)
  75. peggedAutoOffDurationSecs = $FFFF; // seconds (UInt16)
  76. defaultAutoLockType = 0; //!!!never; // Never auto lock device
  77. defaultAutoLockTime = 0;
  78. defaultAutoLockTimeFlag = 0;
  79. // Obsolete after V20
  80. {!!!
  81. defaultSysSoundLevel = slOn;
  82. defaultGameSoundLevel = slOn;
  83. defaultAlarmSoundLevel = slOn;
  84. defaultSysSoundVolume = sndMaxAmp;
  85. defaultGameSoundVolume = sndMaxAmp;
  86. defaultAlarmSoundVolume = sndMaxAmp;
  87. !!!}
  88. type
  89. MeasurementSystemType = Enum;
  90. const
  91. unitsEnglish = 0; // Feet, yards, miles, gallons, pounds, slugs, etc.
  92. unitsMetric = Succ(unitsEnglish); // Meters, liters, grams, newtons, etc.
  93. // These sound levels must corrospond to positions in the popup lists
  94. // used by the preferences app. These are made obsolete after V20. The
  95. // loudness of the sound is now represented as a number from 0 to sndMaxAmp.
  96. type
  97. SoundLevelTypeV20 = Enum;
  98. const
  99. slOn = 0;
  100. slOff = 1;
  101. // Device Automatic Locking options.
  102. type
  103. SecurityAutoLockType = Enum;
  104. const
  105. never = 0; // Auto-Lock disabled.
  106. uponPowerOff = Succ(never); // Auto lock when the device powers off.
  107. atPresetTime = Succ(uponPowerOff); // Auto lock at HH:MM every day.
  108. afterPresetDelay = Succ(atPresetTime); // Auto lock after x minutes or hours.
  109. // The number format (thousands separator and decimal point). This defines
  110. // how numbers are formatted and not neccessarily currency numbers (i.e. Switzerland).
  111. type
  112. AnimationLevelType = Enum;
  113. const
  114. alOff = 0; // Never show an animation
  115. alEventsOnly = Succ(alOff); // Show an animation for an event
  116. alEventsAndRandom = Succ(alEventsOnly); // Also show random animation
  117. alEventsAndMoreRandom = Succ(alEventsAndRandom); // Show random animations more frequently
  118. type
  119. SystemPreferencesChoice = Enum;
  120. const
  121. prefVersion = 0;
  122. prefCountry = Succ(prefVersion);
  123. prefDateFormat = Succ(prefCountry);
  124. prefLongDateFormat = Succ(prefDateFormat);
  125. prefWeekStartDay = Succ(prefLongDateFormat);
  126. prefTimeFormat = Succ(prefWeekStartDay);
  127. prefNumberFormat = Succ(prefTimeFormat);
  128. prefAutoOffDuration = Succ(prefNumberFormat); // prefAutoOffDurationSecs is now preferred (prefAutoOffDuration is in minutes)
  129. prefSysSoundLevelV20 = Succ(prefAutoOffDuration); // slOn or slOff - error beeps and other non-alarm/game sounds
  130. prefGameSoundLevelV20 = Succ(prefSysSoundLevelV20); // slOn or slOff - game sound effects
  131. prefAlarmSoundLevelV20 = Succ(prefGameSoundLevelV20); // slOn or slOff - alarm sound effects
  132. prefHidePrivateRecordsV33 = Succ(prefAlarmSoundLevelV20);
  133. prefDeviceLocked = Succ(prefHidePrivateRecordsV33);
  134. prefLocalSyncRequiresPassword = Succ(prefDeviceLocked);
  135. prefRemoteSyncRequiresPassword = Succ(prefLocalSyncRequiresPassword);
  136. prefSysBatteryKind = Succ(prefRemoteSyncRequiresPassword);
  137. prefAllowEasterEggs = Succ(prefSysBatteryKind);
  138. prefMinutesWestOfGMT = Succ(prefAllowEasterEggs); // deprecated old unsigned minutes EAST of GMT
  139. prefDaylightSavings = Succ(prefMinutesWestOfGMT); // deprecated old daylight saving time rule
  140. prefRonamaticChar = Succ(prefDaylightSavings);
  141. prefHard1CharAppCreator = Succ(prefRonamaticChar); // App creator for hard key #1
  142. prefHard2CharAppCreator = Succ(prefHard1CharAppCreator); // App creator for hard key #2
  143. prefHard3CharAppCreator = Succ(prefHard2CharAppCreator); // App creator for hard key #3
  144. prefHard4CharAppCreator = Succ(prefHard3CharAppCreator); // App creator for hard key #4
  145. prefCalcCharAppCreator = Succ(prefHard4CharAppCreator); // App creator for calculator soft key
  146. prefHardCradleCharAppCreator = Succ(prefCalcCharAppCreator); // App creator for hard cradle key
  147. prefLauncherAppCreator = Succ(prefHardCradleCharAppCreator); // App creator for launcher soft key
  148. prefSysPrefFlags = Succ(prefLauncherAppCreator);
  149. prefHardCradle2CharAppCreator = Succ(prefSysPrefFlags); // App creator for 2nd hard cradle key
  150. prefAnimationLevel = Succ(prefHardCradle2CharAppCreator);
  151. // Additions for PalmOS 3.0:
  152. prefSysSoundVolume = Succ(prefAnimationLevel); // actual amplitude - error beeps and other non-alarm/game sounds
  153. prefGameSoundVolume = Succ(prefSysSoundVolume); // actual amplitude - game sound effects
  154. prefAlarmSoundVolume = Succ(prefGameSoundVolume); // actual amplitude - alarm sound effects
  155. prefBeamReceive = Succ(prefAlarmSoundVolume); // not used - use ExgLibControl with ir(Get/Set)ScanningMode instead
  156. prefCalibrateDigitizerAtReset = Succ(prefBeamReceive); // True makes the user calibrate at soft reset time
  157. prefSystemKeyboardID = Succ(prefCalibrateDigitizerAtReset); // ID of the preferred keyboard resource
  158. prefDefSerialPlugIn = Succ(prefSystemKeyboardID); // creator ID of the default serial plug-in
  159. // Additions for PalmOS 3.1:
  160. prefStayOnWhenPluggedIn = Succ(prefDefSerialPlugIn); // don't sleep after timeout when using line current
  161. prefStayLitWhenPluggedIn = Succ(prefStayOnWhenPluggedIn); // keep backlight on when not sleeping on line current
  162. // Additions for PalmOS 3.2:
  163. prefAntennaCharAppCreator = Succ(prefStayLitWhenPluggedIn); // App creator for antenna key
  164. // Additions for PalmOS 3.3:
  165. prefMeasurementSystem = Succ(prefAntennaCharAppCreator); // English, Metric, etc.
  166. // Additions for PalmOS 3.5:
  167. prefShowPrivateRecords = Succ(prefMeasurementSystem); // returns privateRecordViewEnum
  168. prefAutoOffDurationSecs = Succ(prefShowPrivateRecords); // auto-off duration in seconds
  169. // Additions for PalmOS 4.0:
  170. prefTimeZone = Succ(prefAutoOffDurationSecs); // GMT offset in minutes = Succ(); + for east of GMT = Succ(); - for west
  171. prefDaylightSavingAdjustment = Succ(prefTimeZone); // current DST adjustment in minutes (typically 0 or 60)
  172. prefAutoLockType = Succ(prefDaylightSavingAdjustment); // Never = Succ(); on poweroff = Succ(); after preset delay or at preset time.
  173. prefAutoLockTime = Succ(prefAutoLockType); // Auto lock preset time or delay.
  174. prefAutoLockTimeFlag = Succ(prefAutoLockTime); // For Minutes or Hours.
  175. prefLanguage = Succ(prefAutoLockTimeFlag); // Language spoken in country selected via Setup app/Formats panel
  176. prefLocale = Succ(prefLanguage); // Locale for country selected via Setup app/Formats panel
  177. prefTimeZoneCountry = Succ(prefLocale); // Country used to specify time zone.
  178. prefAttentionFlags = Succ(prefTimeZoneCountry); // User prefs for getting user's attention
  179. prefDefaultAppCreator = Succ(prefAttentionFlags); // Default application launched on reset.
  180. type
  181. SystemPreferencesTypeV10 = record
  182. version: UInt16; // Version of preference info
  183. // International preferences
  184. country: CountryType; // Country the device is in
  185. dateFormat: DateFormatType; // Format to display date in
  186. longDateFormat: DateFormatType; // Format to display date in
  187. weekStartDay: UInt8; // Sunday or Monday
  188. timeFormat: TimeFormatType; // Format to display time in
  189. numberFormat: NumberFormatType; // Format to display numbers in
  190. // system preferences
  191. autoOffDuration: UInt8; // Time period before shutting off (in minutes)
  192. sysSoundLevel: SoundLevelTypeV20; // slOn or slOff - error beeps and other non-alarm sounds
  193. alarmSoundLevel: SoundLevelTypeV20; // slOn or slOff - alarm only
  194. hideSecretRecords: Boolean; // True to not display records with
  195. // their secret bit attribute set
  196. deviceLocked: Boolean; // Device locked until the system
  197. // password is entered
  198. reserved1: UInt8;
  199. sysPrefFlags: UInt16; // Miscellaneous system pref flags
  200. // copied into the global GSysPrefFlags
  201. // at boot time.
  202. sysBatteryKind: SysBatteryKind; // The type of batteries installed. This
  203. // is copied into the globals GSysbatteryKind
  204. // at boot time.
  205. reserved2: UInt8;
  206. end;
  207. // Any entries added to this structure must be initialized in
  208. // Prefereces.c:GetPreferenceResource
  209. // DOLATER CS - We should move SystemPreferencesType, SystemPreferencesTypeV10,
  210. // PrefGetPreferences, and PrefSetPreferences to a private header
  211. // file, since any code compiled against an old version of this
  212. // struct will trash memory when run on a version of the Palm OS
  213. // that makes the struct longer.
  214. SystemPreferencesType = record
  215. version: UInt16; // Version of preference info
  216. // International preferences
  217. country: CountryType; // Country the device is in (see PalmLocale.pas)
  218. dateFormat: DateFormatType; // Format to display date in
  219. longDateFormat: DateFormatType; // Format to display date in
  220. weekStartDay: Int8; // Sunday or Monday
  221. timeFormat: TimeFormatType; // Format to display time in
  222. numberFormat: NumberFormatType; // Format to display numbers in
  223. // system preferences
  224. autoOffDuration: UInt8; // Time period in minutes before shutting off (use autoOffDurationSecs instead).
  225. sysSoundLevelV20: SoundLevelTypeV20; // slOn or slOff - error beeps and other non-alarm/game sounds
  226. gameSoundLevelV20: SoundLevelTypeV20; // slOn or slOff - game sound effects
  227. alarmSoundLevelV20: SoundLevelTypeV20; // slOn or slOff - alarm sound effects
  228. hideSecretRecords: Boolean; // True to not display records with
  229. // their secret bit attribute set
  230. deviceLocked: Boolean; // Device locked until the system
  231. // password is entered
  232. localSyncRequiresPassword: Boolean; // User must enter password on Pilot
  233. remoteSyncRequiresPassword: Boolean; // User must enter password on Pilot
  234. sysPrefFlags: UInt16; // Miscellaneous system pref flags
  235. // copied into the global GSysPrefFlags
  236. // at boot time. Constants are
  237. // sysPrefFlagXXX defined in SystemPrv.h
  238. sysBatteryKind: SysBatteryKind; // The type of batteries installed. This
  239. // is copied into the globals GSysbatteryKind
  240. // at boot time.
  241. reserved1: UInt8;
  242. minutesWestOfGMT: UInt32; // minutes west of Greenwich
  243. daylightSavings: DaylightSavingsTypes; // Type of daylight savings correction
  244. reserved2: UInt8;
  245. ronamaticChar: UInt16; // character to generate from ronamatic stroke.
  246. // Typically it popups the onscreen keyboard.
  247. hard1CharAppCreator: UInt32; // creator of application to launch in response
  248. // to the hard button #1. Used by SysHandleEvent.
  249. hard2CharAppCreator: UInt32; // creator of application to launch in response
  250. // to the hard button #2. Used by SysHandleEvent.
  251. hard3CharAppCreator: UInt32; // creator of application to launch in response
  252. // to the hard button #3. Used by SysHandleEvent.
  253. hard4CharAppCreator: UInt32; // creator of application to launch in response
  254. // to the hard button #4. Used by SysHandleEvent.
  255. calcCharAppCreator: UInt32; // creator of application to launch in response
  256. // to the Calculator icon. Used by SysHandleEvent.
  257. hardCradleCharAppCreator: UInt32; // creator of application to launch in response
  258. // to the Cradle button. Used by SysHandleEvent.
  259. launcherCharAppCreator: UInt32; // creator of application to launch in response
  260. // to the launcher button. Used by SysHandleEvent.
  261. hardCradle2CharAppCreator: UInt32; // creator of application to launch in response
  262. // to the 2nd Cradle button. Used by SysHandleEvent.
  263. animationLevel: AnimationLevelType; // amount of animation to display
  264. maskPrivateRecords: Boolean; // Only meaningful if hideSecretRecords is true.
  265. //true to show a grey placeholder box for secret records.
  266. //was reserved3 - added for 3.5
  267. // Additions for PalmOS 3.0:
  268. sysSoundVolume: UInt16; // system amplitude (0 - sndMaxAmp) - taps, beeps
  269. gameSoundVolume: UInt16; // game amplitude (0 - sndMaxAmp) - explosions
  270. alarmSoundVolume: UInt16; // alarm amplitude (0 - sndMaxAmp)
  271. beamReceive: Boolean; // False turns off IR sniffing, sends still work.
  272. calibrateDigitizerAtReset: Boolean; // True makes the user calibrate at soft reset time
  273. systemKeyboardID: UInt16; // ID of the preferred keyboard resource
  274. defSerialPlugIn: UInt32; // creator ID of the default serial plug-in
  275. // Additions for PalmOS 3.1:
  276. stayOnWhenPluggedIn: Boolean; // don't sleep after timeout when using line current
  277. stayLitWhenPluggedIn: Boolean; // keep backlight on when not sleeping on line current
  278. // Additions for PalmOS 3.2:
  279. antennaCharAppCreator: UInt32; // creator of application to launch in response
  280. // to the antenna key. Used by SysHandleEvent.
  281. // Additions for PalmOS 3.5:
  282. measurementSystem: MeasurementSystemType; // metric, english, etc.
  283. reserved3: UInt8;
  284. autoOffDurationSecs: UInt16; // Time period in seconds before shutting off.
  285. // Additions for PalmOS 4.0:
  286. timeZone: Int16; // minutes east of Greenwich
  287. daylightSavingAdjustment: Int16; // current daylight saving correction in minutes
  288. timeZoneCountry: CountryType; // country used to specify time zone.
  289. autoLockType: SecurityAutoLockType; // Never, on power off, after preset delay or at preset time
  290. autoLockTime: UInt32; // Auto lock preset time or delay.
  291. autoLockTimeFlag: Boolean; // For Minutes or Hours.
  292. language: LanguageType; // Language spoken in country selected via Setup app/Formats panel
  293. attentionFlags: AttnFlagsType; // User prefs for getting user's attention
  294. defaultAppCreator: UInt32; // Creator of the default "safe" app that is launched
  295. // on a reset.
  296. end;
  297. SystemPreferencesPtr = ^SystemPreferencesType;
  298. // structure of the resource that holds hard/soft button defaults
  299. type
  300. ButtonDefaultAppType = record
  301. keyCode: UInt16; // virtual key code of the hard/soft button
  302. creator: UInt32; // app creator code
  303. end;
  304. type
  305. ButtonDefaultListType = record
  306. numButtons: UInt16; // number of default button assignments
  307. button: array [0..0] of ButtonDefaultAppType; // array of button assignments
  308. end;
  309. //-------------------------------------------------------------------
  310. // Preferences routines
  311. //-------------------------------------------------------------------
  312. function PrefOpenPreferenceDBV10: DmOpenRef; syscall sysTrapPrefOpenPreferenceDBV10;
  313. function PrefOpenPreferenceDB(saved: Boolean): DmOpenRef; syscall sysTrapPrefOpenPreferenceDB;
  314. procedure PrefGetPreferences(p: SystemPreferencesPtr); syscall sysTrapPrefGetPreferences;
  315. procedure PrefSetPreferences(p: SystemPreferencesPtr); syscall sysTrapPrefSetPreferences;
  316. function PrefGetPreference(choice: SystemPreferencesChoice): UInt32; syscall sysTrapPrefGetPreference;
  317. procedure PrefSetPreference(choice: SystemPreferencesChoice; value: UInt32); syscall sysTrapPrefSetPreference;
  318. function PrefGetAppPreferences(creator: UInt32; id: UInt16; prefs: Pointer;
  319. var prefsSize: UInt16; saved: Boolean): Int16; syscall sysTrapPrefGetAppPreferences;
  320. function PrefGetAppPreferencesV10(type_: UInt32; version: Int16; prefs: Pointer; prefsSize: UInt16): Boolean; syscall sysTrapPrefGetAppPreferencesV10;
  321. procedure PrefSetAppPreferences(creator: UInt32; id: UInt16; version: Int16;
  322. const prefs: Pointer; prefsSize: UInt16; saved: Boolean); syscall sysTrapPrefSetAppPreferences;
  323. procedure PrefSetAppPreferencesV10(creator: UInt32; version: Int16; prefs: Pointer; prefsSize: UInt16); syscall sysTrapPrefSetAppPreferencesV10;
  324. implementation
  325. end.