simmgr.pp 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2007-2008 Free Pascal development team.
  4. See the file COPYING.FPC, included in this distribution,
  5. for details about the copyright.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. **********************************************************************}
  10. { Declarations for tapi WinCE API, note than on WinCE simmgr functions originally
  11. based in coredll.dll
  12. SIM Manager is an API set that allows access to information stored on the SIM Card
  13. This port based on Windows Mobile 5 Smartphone Edition SDK
  14. contact S0vNark0m for more information [email protected] (en, ru)
  15. }
  16. {$IFNDEF FPC_DOTTEDUNITS}
  17. unit simmgr;
  18. {$ENDIF FPC_DOTTEDUNITS}
  19. interface
  20. {$IFDEF FPC_DOTTEDUNITS}
  21. uses WinApi.Windows;
  22. {$ELSE FPC_DOTTEDUNITS}
  23. uses windows;
  24. {$ENDIF FPC_DOTTEDUNITS}
  25. {$calling cdecl}
  26. //*****************************************************************************
  27. // consts
  28. //*****************************************************************************
  29. const
  30. SIM_ERRORCLASS_SIM = $02; // Problem with the SIM
  31. SIM_ERRORCLASS_PASSWORD = $01; // Unspecified phone failure
  32. SIM_ERRORCLASS_STORAGE = $03; // Error relating to storage
  33. SIM_ERRORCLASS_NONE = $00; // Misc error
  34. FACILITY_SIM = $800;
  35. ERROR_BASE = Longword(SEVERITY_ERROR) shl 31 or Longword(FACILITY_SIM) shl 16; // C Macros conversion, internal def
  36. // Internal def = errclass shl 8
  37. MSE_ERRORCLASS_SIM = ERROR_BASE or Word(SIM_ERRORCLASS_SIM) shl 8;
  38. MSE_ERRORCLASS_PASSWORD = ERROR_BASE or Word(SIM_ERRORCLASS_PASSWORD) shl 8;
  39. MSE_ERRORCLASS_STORAGE = ERROR_BASE or Word(SIM_ERRORCLASS_STORAGE) shl 8;
  40. MSE_ERRERRORCLASS_NONE = ERROR_BASE or Word(SIM_ERRORCLASS_NONE) shl 8;
  41. // Error | Various errors
  42. SIM_E_SIMFAILURE = MSE_ERRORCLASS_SIM or $01; // SIM failure was detected
  43. SIM_E_SIMBUSY = MSE_ERRORCLASS_SIM or $02; // SIM is busy
  44. SIM_E_SIMWRONG = MSE_ERRORCLASS_SIM or $03; // Inorrect SIM was inserted
  45. SIM_E_NOSIMMSGSTORAGE = MSE_ERRORCLASS_SIM or $04; // SIM isn't capable of storing messages
  46. SIM_E_SIMTOOLKITBUSY = MSE_ERRORCLASS_SIM or $05; // SIM Application Toolkit is busy
  47. SIM_E_SIMDOWNLOADERROR = MSE_ERRORCLASS_SIM or $06; // SIM data download error
  48. SIM_E_SIMNOTINSERTED = MSE_ERRORCLASS_SIM or $07; // SIM isn't inserted into the phone
  49. SIM_E_PHSIMPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $20; // PH-SIM PIN is required to perform this operation
  50. SIM_E_PHFSIMPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $21; // PH-FSIM PIN is required to perform this operation
  51. SIM_E_PHFSIMPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $22; // PH-FSIM PUK is required to perform this operation
  52. SIM_E_SIMPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $23; // SIM PIN is required to perform this operation
  53. SIM_E_SIMPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $24; // SIM PUK is required to perform this operation
  54. SIM_E_INCORRECTPASSWORD = MSE_ERRORCLASS_PASSWORD or $25; // Incorrect password was supplied
  55. SIM_E_SIMPIN2REQUIRED = MSE_ERRORCLASS_PASSWORD or $26; // SIM PIN2 is required to perform this operation
  56. SIM_E_SIMPUK2REQUIRED = MSE_ERRORCLASS_PASSWORD or $27; // SIM PUK2 is required to perform this operation
  57. SIM_E_NETWKPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $28; // Network Personalization PIN is required to perform this operation
  58. SIM_E_NETWKPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $29; // Network Personalization PUK is required to perform this operation
  59. SIM_E_SUBSETPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $2A; // Network Subset Personalization PIN is required to perform this operation
  60. SIM_E_SUBSETPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $2B; // Network Subset Personalization PUK is required to perform this operation
  61. SIM_E_SVCPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $2C; // Service Provider Personalization PIN is required to perform this operation
  62. SIM_E_SVCPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $2D; // Service Provider Personalization PUK is required to perform this operation
  63. SIM_E_CORPPINREQUIRED = MSE_ERRORCLASS_PASSWORD or $2E; // Corporate Personalization PIN is required to perform this operation
  64. SIM_E_CORPPUKREQUIRED = MSE_ERRORCLASS_PASSWORD or $2F; // Corporate Personalization PUK is required to perform this operation
  65. SIM_E_MEMORYFULL = MSE_ERRORCLASS_STORAGE or $40; // Storage memory is full
  66. SIM_E_INVALIDINDEX = MSE_ERRORCLASS_STORAGE or $41; // Invalid storage index was supplied
  67. SIM_E_NOTFOUND = MSE_ERRORCLASS_STORAGE or $42; // A requested storage entry was not found
  68. SIM_E_MEMORYFAILURE = MSE_ERRORCLASS_STORAGE or $43; // Storage memory failure
  69. SIM_E_SIMMSGSTORAGEFULL = MSE_ERRORCLASS_STORAGE or $44; // Message storage on the SIM is full
  70. SIM_E_EMPTYINDEX = MSE_ERRORCLASS_STORAGE or $45; // Storage location is empty
  71. SIM_E_NOTREADY = MSE_ERRERRORCLASS_NONE or $60; // SIM isn't yet ready to perform the requested operation
  72. SIM_E_SECURITYFAILURE = MSE_ERRERRORCLASS_NONE or $61; // SIM isn't yet ready to perform the requested operation
  73. SIM_E_BUFFERTOOSMALL = MSE_ERRERRORCLASS_NONE or $62; // Buffer too small
  74. SIM_E_NOTTEXTMESSAGE = MSE_ERRERRORCLASS_NONE or $63; // Requested SMS message is not a text message
  75. SIM_E_NOSIM = MSE_ERRERRORCLASS_NONE or $64; // Device doesn't have a SIM
  76. SIM_E_NETWORKERROR = MSE_ERRERRORCLASS_NONE or $65; // There was a network error
  77. SIM_E_MOBILEERROR = MSE_ERRERRORCLASS_NONE or $66; // Mobile error
  78. SIM_E_UNSUPPORTED = MSE_ERRERRORCLASS_NONE or $67; // The command is unsupported
  79. SIM_E_BADPARAM = MSE_ERRERRORCLASS_NONE or $68; // Bad parameter
  80. SIM_E_UNDETERMINED = MSE_ERRERRORCLASS_NONE or $69; // Undetermined error
  81. SIM_E_RADIONOTPRESENT = MSE_ERRERRORCLASS_NONE or $6A; // The Radio is not present
  82. SIM_E_RADIOOFF = MSE_ERRERRORCLASS_NONE or $6B; // The Radio is off
  83. // Callback | Various notifications that are passed to the callback
  84. SIM_NOTIFY_CARD_REMOVED = $100; // SIM card was removed; lpData is NULL
  85. SIM_NOTIFY_FILE_REFRESH = $101; // Files on the SIM were refreshed; lpData points to a SIMFILEREFRESH structure
  86. SIM_NOTIFY_MSG_STORED = $102; // A message was stored to the SIM; lpData points to a SIMMESSAGECHANGE structure
  87. SIM_NOTIFY_MSG_DELETED = $103; // A message was removed from the SIM; lpData points to a SIMMESSAGECHANGE structure
  88. SIM_NOTIFY_PBE_STORED = $104; // A phone book entry was stored to the SIM; lpData points to a SIMPBECHANGE structure
  89. SIM_NOTIFY_PBE_DELETED = $105; // A phone book entry was removed from the SIM; lpData points to a SIMPBECHANGE structure
  90. SIM_NOTIFY_MSG_RECEIVED = $106; // Class 2 SMS was sent directly to the SIM; lpData points to a SIMMESSAGECHANGE structure
  91. SIM_NOTIFY_RADIOOFF = $107; // The Radio has been turned off but AT interpreter is still on; lpData is NULL
  92. SIM_NOTIFY_RADIOON = $108; // The Radio is present and is now on; lpData is NULL
  93. SIM_NOTIFY_RADIOPRESENT = $109; // A Radio Module/Driver has been installed; lpData is points to a DWORD which is 0 if the radio is OFF and 1 if the radio is ON
  94. SIM_NOTIFY_RADIOREMOVED = $10A; // A Radio Module/Driver has been removed; lpData is NULL }
  95. // Parameter flags for SimInitialize
  96. SIM_INIT_NONE = $00000000; // Do not send any notifications
  97. SIM_INIT_SIMCARD_NOTIFICATIONS = $00000001; // Send SIM card related notifications
  98. // SIMPHONEBOOKENTRY
  99. SIM_PARAM_PBE_ADDRESS = $00000001; // lpszAddress field is valid
  100. SIM_PARAM_PBE_ADDRESS_TYPE = $00000002; // dwAddressType field is valid
  101. SIM_PARAM_PBE_NUMPLAN = $00000004; // dwNumPlan field is valid
  102. SIM_PARAM_PBE_TEXT = $00000008; // lpszText field is valid
  103. SIM_PARAM_PBE_ALL = $0000000f; // All fields are valid
  104. // SIMMESSAGE
  105. SIM_PARAM_MSG_ADDRESS = $00000001; // lpszAddress field is valid
  106. SIM_PARAM_MSG_ADDRESS_TYPE = $00000002; // dwAddressType field is valid
  107. SIM_PARAM_MSG_NUMPLAN = $00000004; // dwNumPlan field is valid
  108. SIM_PARAM_MSG_RECEIVE_TIME = $00000008; // stReceiveTime field is valid
  109. SIM_PARAM_MSG_HEADER = $00000010; // rgbHeader field is valid
  110. SIM_PARAM_MSG_HEADER_LENGTH = $00000020; // cbHdrLength field is valid
  111. SIM_PARAM_MSG_MESSAGE = $00000040; // lpszMessage field is valid
  112. SIM_PARAM_MSG_ALL = $0000007f; // All fields are valid
  113. // SIMCAPS }
  114. SIM_PARAM_CAPS_PBSTORAGES = $00000001; // dwPBStorages field is valid
  115. SIM_PARAM_CAPS_PBEMAXADDRESSLENGTH = $00000002; // dwPBEMaxAddressLength field is valid
  116. SIM_PARAM_CAPS_PBEMAXTEXTLENGTH = $00000004; // dwPBEMaxTextLength field is valid
  117. SIM_PARAM_CAPS_PBEMININDEX = $00000008; // dwMinPBIndex field is valid
  118. SIM_PARAM_CAPS_PBEMAXINDEX = $00000010; // dwMaxPBIndex field is valid
  119. SIM_PARAM_CAPS_LOCKFACILITIES = $00000020; // dwLockFacilities field is valid
  120. SIM_PARAM_CAPS_LOCKINGPWDLENGTH = $00000040; // dwNumLockingPwdLengths and rgLockingPwdLengths fields are valid
  121. SIM_PARAM_CAPS_READMSGSTORAGES = $00000080; // dwReadMsgStorages field is valid
  122. SIM_PARAM_CAPS_WRITEMSGSTORAGES = $00000100; // dwWriteMsgStorages field is valid
  123. SIM_PARAM_CAPS_ALL = $000001ff; // All fields are valid
  124. // SIMRECORDINFO
  125. SIM_PARAM_RECORDINFO_RECORDTYPE = $00000001; // dwRecordType field is valid
  126. SIM_PARAM_RECORDINFO_ITEMCOUNT = $00000002; // dwItemCount field is valid
  127. SIM_PARAM_RECORDINFO_SIZE = $00000004; // dwSize field is valid
  128. SIM_PARAM_RECORDINFO_ALL = $00000007; // All fields are valid
  129. // SIMFILEREFRESH }
  130. SIM_PARAM_FILEREFRESH_FLAGS = $00000001; // dwFlags field is valid
  131. SIM_PARAM_FILEREFRESH_FILECOUNT = $00000002; // dwFileCount field is valid
  132. SIM_PARAM_FILEREFRESH_FILEARRAY = $00000004; // rgdwAddress field is valid
  133. SIM_PARAM_FILEREFRESH_ALL = $00000007; // All fields are valid
  134. // Phonebook Storage | Phone book storage locations }
  135. SIM_PBSTORAGE_EMERGENCY = $00000001; // Emergency dial list
  136. SIM_PBSTORAGE_FIXEDDIALING = $00000002; // SIM fixed dialing list
  137. SIM_PBSTORAGE_LASTDIALING = $00000004; // SIM last dialing list
  138. SIM_PBSTORAGE_OWNNUMBERS = $00000008; // SIM ownnumbers lists
  139. SIM_PBSTORAGE_SIM = $00000010; // General SIM Storage
  140. SIM_NUMPBSTORAGES = 5; // Number of phonebook storages
  141. // SIM DevCaps | Device Capabilities }
  142. SIM_CAPSTYPE_PBENTRYLENGTH = $00000001; // Phonebook entry lengths
  143. SIM_CAPSTYPE_PBSTORELOCATIONS = $00000002; // Phonebook storage locations
  144. SIM_CAPSTYPE_LOCKFACILITIES = $00000004; // Lock facilities
  145. SIM_CAPSTYPE_PBINDEXRANGE = $00000008; // Valid phonebook entry indexes
  146. SIM_CAPSTYPE_LOCKINGPWDLENGTHS = $00000010; // Locking password lengths
  147. SIM_CAPSTYPE_MSGMEMORYLOCATIONS = $00000020; // Message memory locations
  148. SIM_CAPSTYPE_ALL = $0000003F; // All of the above
  149. // SMS Storage | SMS storage locations }
  150. SIM_SMSSTORAGE_BROADCAST = $00000001; // Broadcast message storage location
  151. SIM_SMSSTORAGE_SIM = $00000002; // SIM storage location
  152. SIM_NUMSMSSTORAGES = 2; // Number of message storage locations
  153. // Address Type | Defines different address types }
  154. SIM_ADDRTYPE_UNKNOWN = $00000000; // Unknown
  155. SIM_ADDRTYPE_INTERNATIONAL = $00000001; // International number
  156. SIM_ADDRTYPE_NATIONAL = $00000002; // National number
  157. SIM_ADDRTYPE_NETWKSPECIFIC = $00000003; // Network specific number
  158. SIM_ADDRTYPE_SUBSCRIBER = $00000004; // Subscriber number (protocol-specific)
  159. SIM_ADDRTYPE_ALPHANUM = $00000005; // Alphanumeric address
  160. SIM_ADDRTYPE_ABBREV = $00000006; // Abbreviated number
  161. // Numbering Plan | Defines different numbering plans for SIM_ADDRTYPE_UNKNOWN,
  162. // SIM_ADDRTYPE_INTERNATIONAL, and SIM_ADDRTYPE_NATIONAL
  163. SIM_NUMPLAN_UNKNOWN = $00000000; // Unknown
  164. SIM_NUMPLAN_TELEPHONE = $00000001; // ISDN/telephone numbering plan (E.164/E.163)
  165. SIM_NUMPLAN_DATA = $00000002; // Data numbering plan (X.121)
  166. SIM_NUMPLAN_TELEX = $00000003; // Telex numbering plan
  167. SIM_NUMPLAN_NATIONAL = $00000004; // National numbering plan
  168. SIM_NUMPLAN_PRIVATE = $00000005; // Private numbering plan
  169. SIM_NUMPLAN_ERMES = $00000006; // ERMES numbering plan (ETSI DE/PS 3 01-3)
  170. // Phone Locked | Indicates if the phone is currently locked (i.e.
  171. // awaiting password) and what password to enter
  172. SIM_LOCKEDSTATE_UNKNOWN = $00000000; // Locking state is unknown
  173. SIM_LOCKEDSTATE_READY = $00000001; // Not awaiting a password (unlocked)
  174. SIM_LOCKEDSTATE_SIM_PIN = $00000002; // Awaiting the SIM PIN
  175. SIM_LOCKEDSTATE_SIM_PUK = $00000003; // Awaiting the SIM PUK
  176. SIM_LOCKEDSTATE_PH_SIM_PIN = $00000004; // Awaiting the Phone to SIM Personalization PIN
  177. SIM_LOCKEDSTATE_PH_FSIM_PIN = $00000005; // Awaiting the Phone to first SIM Personalization PIN
  178. SIM_LOCKEDSTATE_PH_FSIM_PUK = $00000006; // Awaiting the Phone to first SIM Personalization PUK
  179. SIM_LOCKEDSTATE_SIM_PIN2 = $00000007; // Awaiting the SIM PIN2
  180. SIM_LOCKEDSTATE_SIM_PUK2 = $00000008; // Awaiting the SIM PUK2
  181. SIM_LOCKEDSTATE_PH_NET_PIN = $00000009; // Awaiting the Network Personalization PIN
  182. SIM_LOCKEDSTATE_PH_NET_PUK = $0000000a; // Awaiting the Network Personalization PUK
  183. SIM_LOCKEDSTATE_PH_NETSUB_PIN = $0000000b; // Awaiting the Network Subset Personalization PIN
  184. SIM_LOCKEDSTATE_PH_NETSUB_PUK = $0000000c; // Awaiting the Network Subset Personalization PUK
  185. SIM_LOCKEDSTATE_PH_SP_PIN = $0000000d; // Awaiting the Service Provider Personalization PIN
  186. SIM_LOCKEDSTATE_PH_SP_PUK = $0000000e; // Awaiting the Service Provider Personalization PUK
  187. SIM_LOCKEDSTATE_PH_CORP_PIN = $0000000f; // Awaiting the Corporate Personalization PIN
  188. SIM_LOCKEDSTATE_PH_CORP_PUK = $00000010; // Awaiting the Corporate Personalization PUK
  189. // Phonebook Misc | Special phonebook constants }
  190. SIM_PBINDEX_FIRSTAVAILABLE = $ffffffff; // Use first phonebook storage entry available
  191. // Phone Locking | Indicates the phone's locking behavior }
  192. SIM_LOCKFACILITY_CNTRL = $00000001; // Lock control curface
  193. SIM_LOCKFACILITY_PH_SIM = $00000002; // Lock phone to SIM card
  194. SIM_LOCKFACILITY_PH_FSIM = $00000004; // Lock phone to first SIM card
  195. SIM_LOCKFACILITY_SIM = $00000008; // Lock SIM card
  196. SIM_LOCKFACILITY_SIM_PIN2 = $00000010; // Lock SIM card
  197. SIM_LOCKFACILITY_SIM_FIXEDIALING = $00000020; // SIM fixed dialing memory
  198. SIM_LOCKFACILITY_NETWORKPERS = $00000040; // Network personalization
  199. SIM_LOCKFACILITY_NETWORKSUBPERS = $00000080; // Network subset personalization
  200. SIM_LOCKFACILITY_SERVICEPROVPERS = $00000100; // Service provider personalization
  201. SIM_LOCKFACILITY_CORPPERS = $00000200; // Corporate personalization
  202. SIM_NUMLOCKFACILITIES = 10; // Number of locking facilities
  203. // SIM Record | Different SIM file types
  204. SIM_RECORDTYPE_UNKNOWN = $00000000; // An unknown file type
  205. SIM_RECORDTYPE_TRANSPARENT = $00000001; // A single veriable lengthed record
  206. SIM_RECORDTYPE_CYCLIC = $00000002; // A cyclic set of records, each of the same length
  207. SIM_RECORDTYPE_LINEAR = $00000003; // A linear set of records, each of the same length
  208. SIM_RECORDTYPE_MASTER = $00000004; // Every SIM has a single master record, effectively the head node
  209. SIM_RECORDTYPE_DEDICATED = $00000005; // Effectively a "directory" file which is a parent of other records
  210. // SIM Record Refresh | Different ways of being notified that SIM
  211. // have been updated
  212. SIMFILE_FULLFILECHANGE = $00000001; // All files have been changed
  213. SIMFILE_FILECHANGE = $00000002; // Only a few files have been changed
  214. SIMFILE_SIMINIT = $00000004; // SIM Initiailization
  215. SIMFILE_SIMRESET = $00000008; // Reset the SIM
  216. // Max_Length | Maximum length constants }
  217. MAX_LENGTH_ADDRESS = 256; // Maximum length of an address
  218. MAX_LENGTH_PHONEBOOKENTRYTEXT = 256; // Maximum length of text in a phonebook entry
  219. MAX_LENGTH_HEADER = 256; // Maximum length of a SMS header
  220. MAX_LENGTH_MESSAGE = 256; // Maximum length of a SMS message
  221. MAX_FILES = 32; // Maximum number of files in a file change list
  222. //*****************************************************************************
  223. // types
  224. //*****************************************************************************
  225. type
  226. // HSIM | Handle to a SIM }
  227. HSIM = HANDLE;
  228. LPHSIM = ^HSIM;
  229. // SIMPHONEBOOKENTRY | A SIM phonebook entry
  230. simphonebookentry_tag = record
  231. cbSize : DWORD; // Size of the structure in bytes
  232. dwParams : DWORD; // Indicates valid parameter values
  233. lpszAddress : array[0..(MAX_LENGTH_ADDRESS)-1] of TCHAR; // The actual phone number
  234. dwAddressType : DWORD; // A SIM_ADDRTYPE_* constant
  235. dwNumPlan : DWORD; // A SIM_NUMPLAN_* constant
  236. lpszText : array[0..(MAX_LENGTH_PHONEBOOKENTRYTEXT)-1] of TCHAR; // Text assocaited with the entry
  237. end;
  238. TSIMPHONEBOOKENTRY = simphonebookentry_tag;
  239. LPSIMPHONEBOOKENTRY = ^simphonebookentry_tag;
  240. // SIMMESSAGE | A SIM message entry
  241. simmessage_tag = record
  242. cbSize : DWORD; // Size of the structure in bytes
  243. dwParams : DWORD; // Indicates valid parameter values
  244. lpszAddress : array[0..(MAX_LENGTH_ADDRESS)-1] of TCHAR; // The actual phone number
  245. dwAddressType : DWORD; // A SIM_ADDRTYPE_* constant
  246. dwNumPlan : DWORD; // A SIM_NUMPLAN_* constant
  247. stReceiveTime : SYSTEMTIME; // Timestamp for the incoming message
  248. cbHdrLength : DWORD; // Header length in bytes
  249. rgbHeader : array[0..(MAX_LENGTH_HEADER)-1] of BYTE; // The actual header data
  250. lpszMessage : array[0..(MAX_LENGTH_MESSAGE)-1] of TCHAR; // The actual message data
  251. end;
  252. TSIMMESSAGE = simmessage_tag;
  253. LPSIMMESSAGE = ^simmessage_tag;
  254. // SIMLOCKINGPWDLENGTH | Minimum password length }
  255. simlockingpwdlength = record
  256. dwFacility : DWORD; // The locking facility
  257. dwPasswordLength : DWORD; // The minimum password length
  258. end;
  259. LPSIMLOCKINGPWDLENGTH = ^simlockingpwdlength;
  260. // SIMCAPS | Capabilities of the SIM
  261. simcaps_tag = record
  262. cbSize : DWORD; // Size of the structure in bytes
  263. dwParams : DWORD; // Indicates valid parameter values
  264. dwPBStorages : DWORD; // Supported phonebook storages
  265. dwMinPBIndex : DWORD; // Minimum phonebook storages
  266. dwMaxPBIndex : DWORD; // Maximum phonebook storages
  267. dwMaxPBEAddressLength : DWORD; // Maximum address length of phonebook entries
  268. dwMaxPBETextLength : DWORD; // Maximum text length of phonebook entries
  269. dwLockFacilities : DWORD; // Supported locking facilities
  270. dwReadMsgStorages : DWORD; // Supported read message stores
  271. dwWriteMsgStorages : DWORD; // Supported write message stores
  272. dwNumLockingPwdLengths : DWORD; // Number of entries in rgLockingPwdLengths
  273. rgLockingPwdLengths : array[0..(SIM_NUMLOCKFACILITIES)-1] of SIMLOCKINGPWDLENGTH; // Password lengths for each facility
  274. end;
  275. TSIMCAPS = simcaps_tag;
  276. LPSIMCAPS = ^simcaps_tag;
  277. // SIMRECORDINFO | Information about a particular SIM file
  278. simrecordinfo_tag = record
  279. cbSize : DWORD; // Size of the structure in bytes
  280. dwParams : DWORD; // Indicates valid parameter values
  281. dwRecordType : DWORD; // SIM_RECORDTYPE_* Constant
  282. dwItemCount : DWORD; // Number of items in the record
  283. dwSize : DWORD; // Size in bytes of each item
  284. end;
  285. TSIMRECORDINFO = simrecordinfo_tag;
  286. LPSIMRECORDINFO = ^simrecordinfo_tag;
  287. // SIMFILEREFRESH | Information about which file(s) have been updated
  288. simfilerefresh_tag = record
  289. cbSize : DWORD; // Size of the structure in bytes
  290. dwParams : DWORD; // Indicates valid parameter values
  291. dwFlags : DWORD; // Combination of SIMFILE_* constants
  292. dwFileCount : DWORD; // Number of files in the update list
  293. rgdwAddress : array[0..(MAX_FILES)-1] of DWORD; // Array of files
  294. end;
  295. TSIMFILEREFRESH = simfilerefresh_tag;
  296. LPSIMFILEREFRESH = ^simfilerefresh_tag;
  297. // SIMPBECHANGE | Information about which SIM Phonebook entries have changed
  298. simpbechange_tag = record
  299. dwEntry : DWORD; // The index of the entry that has changed
  300. dwStorage : DWORD; // SIM_PBSTORAGE_* constant detailing which phonebook this entry is in
  301. end;
  302. TSIMPBECHANGE = simpbechange_tag;
  303. LPSIMPBECHANGE = ^simpbechange_tag;
  304. // SIMMESSAGECHANGE | Information about which SMS messages on the SIM have changed }
  305. simmessagechange_tag = record
  306. dwEntry : DWORD; // The index of the entry that has changed
  307. dwStorage : DWORD; // SIM_SMSSTORAGE_* constant details which storage location this entry is in
  308. end;
  309. TSIMMESSAGECHANGE = simmessagechange_tag;
  310. LPSIMMESSAGECHANGE = ^simmessagechange_tag;
  311. // This is the callback function prototype used by SIM Manager when
  312. // sending notifications.
  313. // -
  314. // Indicates type of notification received
  315. // Points to data structure specific to the notification
  316. // Size of data structure in bytes
  317. // Parameter passed to simInititialize
  318. TSIMCALLBACK = procedure (dwNotifyCode:DWORD; const pData:pointer; dwDataSize:DWORD; dwParam:DWORD);
  319. //*****************************************************************************
  320. // functions
  321. //*****************************************************************************
  322. const
  323. CellCoreDLL = 'cellcore.dll';
  324. // This function must be called by applications in order to use any of the
  325. // functions in this API.
  326. // Passing in a function callback is required only for applications that
  327. // wish to obtain notifications.
  328. // -
  329. // Indicates which notifications to receive
  330. // Function callback for notifications, may be NULL if notifications are not desired
  331. // Parameter to pass on each notification function call, may be NULL
  332. // Points to a HSIM handle to use on subsequent function calls
  333. function SimInitialize(dwFlags:DWORD; lpfnCallBack:TSIMCALLBACK; dwParam:DWORD; lphSim:LPHSIM):HRESULT;external CellCoreDLL name 'SimInitialize';
  334. // This function deinitializes an HSIM handle.
  335. // -
  336. // A valid HSIM handle to deinitialize
  337. function SimDeinitialize(hSim:HSIM):HRESULT;external CellCoreDLL name 'SimDeinitialize';
  338. // Gets the device capabilities of the SIM.
  339. // -
  340. // Points to a valid HSIM handle
  341. // Which device capabilities are we interested in?
  342. // Capabilities structure
  343. function SimGetDevCaps(hSim:HSIM; dwCapsType:DWORD; lpSimCaps:LPSIMCAPS):HRESULT;external CellCoreDLL name 'SimGetDevCaps';
  344. // Reads a phonebook entry off the SIM card.
  345. // -
  346. // Points to a valid HSIM handle
  347. // A SIMPBSTORAGE_* Constant
  348. // Index of the entry to retrieve
  349. // Points to a phonebook entry structure
  350. function SimReadPhonebookEntry(hSim:HSIM; dwLocation:DWORD; dwIndex:DWORD; lpPhonebookEntry:LPSIMPHONEBOOKENTRY):HRESULT;external CellCoreDLL name 'SimReadPhonebookEntry';
  351. // Gets the status of a phonebook location.
  352. // -
  353. // Points to a valid HSIM handle
  354. // A SIMPBSTORAGE_* Constant
  355. // Nubmer of used locations
  356. // Total number of locations
  357. function SimGetPhonebookStatus(hSim:HSIM; dwLocation:DWORD; lpdwUsed:LPDWORD; lpdwTotal:LPDWORD):HRESULT;external CellCoreDLL name 'SimGetPhonebookStatus';
  358. // Writes a phonebook entry to the SIM card.
  359. // -
  360. // Points to a valid HSIM handle
  361. // A SIMPBSTORAGE_* Constant
  362. // Index of the entry to retrieve (may be SIM_PBINDEX_FIRSTAVAILABLE)
  363. // Points to a phonebook entry structure
  364. function SimWritePhonebookEntry(hSim:HSIM; dwLocation:DWORD; dwIndex:DWORD; lpPhonebookEntry:LPSIMPHONEBOOKENTRY):HRESULT;external CellCoreDLL name 'SimWritePhonebookEntry';
  365. // Deletes a phonebook entry from the SIM card.
  366. // -
  367. // Points to a valid HSIM handle
  368. // A SIMPBSTORAGE_* Constant
  369. // Index of the entry to retrieve
  370. function SimDeletePhonebookEntry(hSim:HSIM; dwLocation:DWORD; dwIndex:DWORD):HRESULT;external CellCoreDLL name 'SimDeletePhonebookEntry';
  371. // Checks if the SIM is currently awaiting a password.
  372. // This is called when powering on the phone.
  373. // -
  374. // Points to a valid HSIM handle
  375. // Points to a SIM_LOCKEDSTATE_* constant
  376. function SimGetPhoneLockedState(hSim:HSIM; lpdwLockedState:LPDWORD):HRESULT;external CellCoreDLL name 'SimGetPhoneLockedState';
  377. // Sends a password to unlock the phone.
  378. // -
  379. // Points to a valid HSIM handle
  380. // Points to password string
  381. // Some locked states require a second password (e.g. PUK requires a new PIN to replace the old, presumably forgotten PIN)
  382. function SimUnlockPhone(hSim:HSIM; lpszPassword:LPTSTR; lpszNewPin:LPTSTR):HRESULT;external CellCoreDLL name 'SimUnlockPhone';
  383. // Gets the locking status of the phone.
  384. // -
  385. // Points to a valid HSIM handle
  386. // A SIMLOCKFACILITY_* constant
  387. // Some facilities require a password
  388. // Enabled or diabled
  389. function SimGetLockingStatus(hSim:HSIM; dwLockingFacility:DWORD; lpszPassword:LPTSTR; var pfEnabled:BOOL):HRESULT;external CellCoreDLL name 'SimGetLockingStatus';
  390. // Sets the locking status of the phone.
  391. // -
  392. // Points to a valid HSIM handle
  393. // A SIMLOCKFACILITY_* constant
  394. // Some facilities require a password
  395. // Enable or diable
  396. function SimSetLockingStatus(hSim:HSIM; dwLockingFacility:DWORD; lpszPassword:LPTSTR; fEnabled:BOOL):HRESULT;external CellCoreDLL name 'SimSetLockingStatus';
  397. // Changes a locking password.
  398. // -
  399. // Points to a valid HSIM handle
  400. // A SIMLOCKFACILITY_* constant
  401. // The old password
  402. // The new password
  403. function SimChangeLockingPassword(hSim:HSIM; dwLockingFacility:DWORD; lpszOldPassword:LPTSTR; lpszNewPassword:LPTSTR):HRESULT;external CellCoreDLL name 'SimChangeLockingPassword';
  404. // Gets the status of a SMS storage location.
  405. // -
  406. // Points to a valid HSIM handle
  407. // A SIM_SMSSTORAGE_* constant
  408. // Nubmer of used locations
  409. // Total number of locations
  410. function SimGetSmsStorageStatus(hSim:HSIM; dwStorage:DWORD; lpdwUsed:LPDWORD; lpdwTotal:LPDWORD):HRESULT;external CellCoreDLL name 'SimGetSmsStorageStatus';
  411. // Reads an SMS from a particular storage location.
  412. // -
  413. // Points to a valid HSIM handle
  414. // A SIM_SMSSTORAGE_* constant
  415. // Index of the entry to retrieve
  416. // Points to an SMS message structure
  417. function SimReadMessage(hSim:HSIM; dwStorage:DWORD; dwIndex:DWORD; lpSimMessage:LPSIMMESSAGE):HRESULT;external CellCoreDLL name 'SimReadMessage';
  418. // Writes an SMS to a particular storage location.
  419. // Note that SMS messages are always written to the first available storage location
  420. // -
  421. // lpdwIndex will be set to the index to which the message was written
  422. // Points to a valid HSIM handle
  423. // A SIM_SMSSTORAGE_* constant
  424. // Set to the index where the message was written
  425. // Points to an SMS message structure
  426. function SimWriteMessage(hSim:HSIM; dwStorage:DWORD; lpdwIndex:LPDWORD; lpSimMessage:LPSIMMESSAGE):HRESULT;external CellCoreDLL name 'SimWriteMessage';
  427. // Deletes an SMS from a particular storage location.
  428. // -
  429. // Points to a valid HSIM handle
  430. // A SIM_SMSSTORAGE_* constant
  431. // Index of the entry to retrieve
  432. function SimDeleteMessage(hSim:HSIM; dwStorage:DWORD; dwIndex:DWORD):HRESULT;external CellCoreDLL name 'SimDeleteMessage';
  433. // Reads a file form the SIM.
  434. // -
  435. // Points to a valid HSIM handle
  436. // SIM address
  437. // A SIM_RECORDTYPE_* constant
  438. // Applies only to SIM_RECORDTYPE_CYCLIC and SIM_RECORDTYPE_LINEAR, otherwise ignored
  439. // Data buffer
  440. // Size of data buffer
  441. // Number of bytes read
  442. function SimReadRecord(hSim:HSIM; dwAddress:DWORD; dwRecordType:DWORD; dwIndex:DWORD;
  443. lpData: LPBYTE; dwBufferSize: DWORD; lpdwBytesRead: LPDWORD):HRESULT;external CellCoreDLL name 'SimReadRecord';
  444. // Writes a file to the SIM.
  445. // -
  446. // Points to a valid HSIM handle
  447. // SIM address
  448. // A SIM_RECORDTYPE_* constant
  449. // Applies only to SIM_RECORDTYPE_CYCLIC and SIM_RECORDTYPE_LINEAR, otherwise ignored
  450. function SimWriteRecord(hSim:HSIM; dwAddress:DWORD; dwRecordType:DWORD; dwIndex:DWORD;
  451. lpData: LPBYTE; dwByteCount: DWORD):HRESULT;external CellCoreDLL name 'SimWriteRecord';
  452. // Gets information about a particular record.
  453. // -
  454. // Points to a valid HSIM handle
  455. // SIM address
  456. // Points to a SIM record information structure
  457. function SimGetRecordInfo(hSim:HSIM; dwAddress:DWORD; lpSimRecordInfo:LPSIMRECORDINFO):HRESULT;external CellCoreDLL name 'SimGetRecordInfo';
  458. implementation
  459. end.