1{$INLINE ON} 2{$MACRO ON} 3 4{$define Rsc := } 5(*********************************************************************** 6 * 7 * Copyright (c) 1998-2000 Palm, Inc. or its subsidiaries. 8 * All rights reserved. 9 * 10 * File: ConnectionMgr.h 11 * 12 * Release: Palm OS SDK 4.0 (63220) 13 * 14 * Description: 15 * Connection Manager Interface. The Connection Manager allows 16 * other applications to access, add, and delete connection profiles 17 * contained in the Connection Panel. 18 * 19 * History: 20 * 8/19/98 ADH Initial Implementation 21 * 03/01/2000 PPL Rewrite API for New Connection Manager 22 * 03/30/2000 PPL Constant change from cncXXXX to kCncXXXX 23 * and # defining old names (cncXXXX) for compatibility. 24 * 10/19/00 PPL Update the header with GuideLines 25 * 10/20/00 PPL Remove CncProfileBroacast - The notification it sent 26 * is always in usage. 27 * 10/23/00 PPL Update Connection Manager API 28 * 11/06/2000 PPL Use the CncProfileId abstract type for profileIDs 29 * 30 ***********************************************************************) 31 32unit connectionmgr; 33 34interface 35 36uses palmos, coretraps, errorbase, datamgr, modemmgr; 37 38(*********************************************************************** 39 * Definition 40 ***********************************************************************) 41 42type 43 CncProfileID = UInt32; 44 45(*********************************************************************** 46 * Connection Profile Broadcasting 47 ***********************************************************************) 48 49const 50 kCncProfileNotifyCurrentVersion = 1; 51 52type 53 CncProfileNotifyDetailsTag = record 54 // In: version - This definition is version 1 (kCncProfileNotifyCurrentVersion) 55 // later versions should include all the fields of version 1 plus 56 // any additional fields of CncProfileNotifyDetailsType 57 version: UInt16; 58 59 // In: Broacasted Profile ID 60 profileID: CncProfileID; 61 62 // In: Device Kind of the profile 63 deviceKind: UInt16; 64 65 // In: Resquested Action 66 request: UInt16; 67 end; 68 CncProfileNotifyDetailsType = CncProfileNotifyDetailsTag; 69 70(*********************************************************************** 71 * Constants 72 ***********************************************************************) 73const 74 kCncProfileInvalidId = CncProfileID(0); 75 76// Request's modifiers flags 77const 78 kCncNotifyBecomeCurrentModifier = $8000; // Change the Client current settings 79 kCncNotifyAlertUserModifier = $4000; // ask for Client UI 80 kNotifyRequestMofifiersMask = kCncNotifyBecomeCurrentModifier or kCncNotifyAlertUserModifier; 81 82// Requests 83 kCncNotifyCreateRequest = 1; // the profile has been created 84 kCncNotifyModifyRequest = 2; // the profile has been modified 85 kCncNotifyDeleteRequest = 3; // the profile has been deleted 86 kCncNotifyUpdateListRequest = 4; // the profile has been deleted 87 88(*********************************************************************** 89 * Connection Profile ParamID Definition Macros and Constants 90 ***********************************************************************) 91 92const 93 kCncParamOSRange = $0000; // bit #15 set at 0 94 kCncParamThirdPartiesRange = $8000; // bit #15 set at 1 95 96 kCncParamFixedLength = $0000; // bit #14 set to 0 97 kCncParamVariableLength = $4000; // bit #14 set to 1 98 99 kCncParamIDMask = $07FF; // bit #0 to #10 set to 1 (11 bits) 100 kCncParamTypeMask = $7800; // bit #11 to #14 set to 1 (4 bits) 101 102// parameter type definition macros 103 kCncParamFixedLen = $00; // higth bit of 4 set to 0 104 kCncParamVariableLen = $08; // higth bit of 4 set to 1 105 106//#define CncDefineParameterType( variableBit , typeOrder) ( ( (variableBit) | (typeOrder) ) << 11) 107 108// bit number is comprised between 0 and 31 109 110// #define CncDefineSystemFlagMask(bitnum) (1 << (bitnum)) 111 112const 113 kCncParamSystemFlag = (kCncParamFixedLen or 0) shl 11; // 0x0000 114 kCncParamUInt8 = (kCncParamFixedLen or 1) shl 11; // 0x0800 115 kCncParamUInt16 = (kCncParamFixedLen or 2) shl 11; // 0x1000 116 kCncParamUInt32 = (kCncParamFixedLen or 3) shl 11; // 0x1800 117// [free slot from 4 to 7] 118 119 kCncParamUInt8Size = SizeOf(UInt8); 120 kCncParamUInt16Size = SizeOf(UInt16); 121 kCncParamUInt32Size = SizeOf(UInt32); 122 123 kCncParamSystemFlagSize = kCncParamUInt8Size; 124 125 kCncParamString = (kCncParamVariableLen or 1) shl 11; // 0x4800 126 kCncParamBuffer = (kCncParamVariableLen or 2) shl 11; // 0x5000 127// [free slot from 3 to 7] 128 129// full Parameter ID definition macro 130(* 131#define CncDefineParamID(parameterRange, parameterType, parameterID) ( (parameterRange) | (parameterType) | (parameterID) ) 132 133#define CncIsSystemRange(parameterID) ( ( (parameterID) & kCncParamThirdPartiesRange) != kCncParamThirdPartiesRange) 134#define CncIsThirdPartiesRange(parameterID) ( ( (parameterID) & kCncParamThirdPartiesRange ) == kCncParamThirdPartiesRange) 135 136#define CncIsFixedLengthParamType(parameterID) ( ( (parameterID) & kCncParamVariableLength) != kCncParamVariableLength ) 137#define CncIsVariableLengthParamType(parameterID) ( ( (parameterID) & kCncParamVariableLength ) == kCncParamVariableLength) 138 139#define CncGetTrueParamID(parameterID) ( (parameterID) & kCncParamIDMask) 140#define CncGetParamType(parameterID) ( (parameterID) & kCncParamTypeMask) 141 142#define CncIsSystemFlags(parameterID) ( ! (CncGetParamType( (parameterID) ) ) ) 143#define CncGetSystemFlagBitnum(parameterID) CncGetTrueParamID(parameterID) 144*) 145 146// Some tests 147 148(*********************************************************************** 149 * Cnc Manager Feature 150 ***********************************************************************) 151 152const 153 kCncFtrCncMgrCreator = Rsc('cmgr'); 154 155 kCncFtrCncMgrVersion = 0; 156 kCncMgrVersion = $00040001; // 4.0 = 4->high 0->low 157// feature index 1 and 2 are reserved 158 159(*********************************************************************** 160 * Parameter size values 161 ***********************************************************************) 162 163const 164// 22 for compatibility 165 kCncProfileNameSize = 22; 166 167// 81 defined in ModemMgr.h 168 kCncProfileUsualInitStringSize = mdmCmdBufSize; 169 170// 81 defined in ModemMgr.h 171 kCncProfileClassicResetStringSize = mdmCmdSize; // Old size was 8 172 kCncProfileUsualResetStringSize = mdmCmdBufSize; 173 174(*********************************************************************** 175 * Parameters values 176 ***********************************************************************) 177 178// device kinds 179 kCncDeviceKindSerial = 0; 180 kCncDeviceKindModem = 1; 181 kCncDeviceKindPhone = 2; 182 kCncDeviceKindLocalNetwork = 3; 183 184// Old flow controls 185 kCncFlowControlAuto = 0; 186 kCncFlowControlOFF = 1; 187 kCncFlowControlON = 2; 188 189 kCncProfileVersion = 4; 190 191(*********************************************************************** 192 * Error Codes 193 ***********************************************************************) 194 195 kCncErrAddProfileFailed = cncErrorClass or $01; // Add profile attempt failed 196 kCncErrProfileListFull = cncErrorClass or $02; // Add attempt failed because the 197 // profile list is full. 198 kCncErrGetProfileFailed = cncErrorClass or $03; // Get profile attempt failed 199 kCncErrDBAccessFailed = cncErrorClass or $04; // Connection database not found or access failed 200 kCncErrGetProfileListFailed = cncErrorClass or $05; // Could not get profile list 201 kCncErrProfileReadOnly = cncErrorClass or $06; // The profile can not be altered 202 kCncErrProfileNotFound = cncErrorClass or $07; // The profile could not be found 203 204// New API error code 205 kCncErrProfileParamNotFound = cncErrorClass or $08; // The profile parameter could not be found 206 kCncErrProfileParamReadOnly = cncErrorClass or $09; // The profile parameter can only be read 207 kCncErrProfileParamNameHasChange = cncErrorClass or $0a; // The profile parameter Name has been modified to be unique 208 kCncErrProfileGetParamFailed = cncErrorClass or $0b; // failed to get a parameter in a profile 209 kCncErrProfileSetParamFailed = cncErrorClass or $0c; // failed to Set a parameter in a profile 210 kCncErrProfileBadParamSize = cncErrorClass or $0d; // failed to Set a parameter in a profile 211 kCncErrProfileBadSystemFlagBitnum = cncErrorClass or $0e; // the bit num of a system flag is not comprise between 0 and 31 212 213(*********************************************************************** 214 * Parameters ID and Sizes 215 ***********************************************************************) 216 217const 218// void param has a size of zero bytes 219 kCncNoParam = 0; 220 kCncNoParamSize = 0; 221 222// 22 bytes limited - for compatibility 223 kCncParamName = kCncParamOSRange or kCncParamString or 1; 224 kCncParamNameMaxSize = kCncProfileNameSize; 225 226 kCncParamPort = kCncParamOSRange or kCncParamUInt32 or 2; 227 kCncParamPortSize = kCncParamUInt32Size; 228 229 kCncParamBaud = kCncParamOSRange or kCncParamUInt32 or 3; 230 kCncParamBaudSize = kCncParamUInt32Size; 231 232 kCncParamVolume = kCncParamOSRange or kCncParamUInt16 or 4; 233 kCncParamVolumeSize = kCncParamUInt16Size; 234 235 kCncParamFlowControl = kCncParamOSRange or kCncParamUInt16 or 5; 236 kCncParamFlowControlSize = kCncParamUInt16Size; 237 238// New piece of info - communication time Out (CTS) 239 kCncParamTimeOut = kCncParamOSRange or kCncParamUInt32 or 6; 240 kCncParamTimeOutSize = kCncParamUInt32Size; 241 242 kCncParamInitString = kCncParamOSRange or kCncParamString or 7; 243 kCncParamInitStringMaxSize = mdmCmdBufSize; 244 245 kCncParamResetString = kCncParamOSRange or kCncParamString or 8; 246 kCncParamResetStringMaxSize = mdmCmdBufSize; 247 248// New piece of info - extented device kind cf kCncDeviveXXX after 249 kCncParamDeviceKind = kCncParamOSRange or kCncParamUInt16 or 9; 250 kCncParamDeviceKindSize = kCncParamUInt16Size; 251 252// country index for the profile 253 kCncParamCountryIndex = kCncParamOSRange or kCncParamUInt16 or 11; 254 kCncParamCountryIndexSize = kCncParamUInt16Size; 255 256// dialing mode, old pulse param 257 kCncParamDialingMode = kCncParamOSRange or kCncParamUInt8 or 12; 258 kCncParamDialingModeSize = kCncParamUInt8Size; 259 260 kCncParamVersion = kCncParamOSRange or kCncParamUInt8 or 13; 261 kCncParamVersionSize = kCncParamUInt8Size; 262 263 kCncParamReceiveTimeOut = kCncParamOSRange or kCncParamUInt32 or 14; 264 kCncParamReceiveTimeOutSize = kCncParamUInt32Size; 265 266// International Reset string (count [strings]) 267 kCncParamIntlModemResetStringList = kCncParamOSRange or kCncParamBuffer or 15; 268 269 270// International country string (count [strings]) 271 kCncParamIntlModemCountryStringList = kCncParamOSRange or kCncParamBuffer or 16; 272 273// special parameters : system flags 274// the meaning of these parameters is for the connection panel 275// up to 32 flags system flag will be possible 276 277// bit numbering 278 kCncParamReadOnlyBit = 0; 279 kCncParamInvisibleBit = 1; 280 kCncParamNonEditableBit = 2; 281 kCncParamNoDetailsBit = 3; 282 kCncParamLockedBit = 4; 283 kCncParamReservedBit5 = 5; 284 kCncParamReservedBit6 = 6; 285 kCncParamReservedBit7 = 7; 286 kCncParamReservedBit8 = 8; 287 kCncParamReservedBit9 = 9; 288 kCncParamReservedBit10 = 10; 289 kCncParamReservedBit11 = 11; 290 kCncParamReservedBit12 = 12; 291 kCncParamReservedBit13 = 13; 292 kCncParamReservedBit14 = 14; 293 kCncParamReservedBit15 = 15; 294 kCncParamSystemBit16 = 16; 295 kCncParamSystemBit17 = 17; 296 kCncParamReservedBit18 = 18; 297 kCncParamReservedBit19 = 19; 298 kCncParamReservedBit20 = 20; 299 kCncParamReservedBit21 = 21; 300 kCncParamReservedBit22 = 22; 301 kCncParamReservedBit23 = 23; 302 kCncParamReservedBit24 = 24; 303 kCncParamReservedBit25 = 25; 304 kCncParamReservedBit26 = 26; 305 kCncParamReservedBit27 = 27; 306 kCncParamReservedBit28 = 28; 307 kCncParamReservedBit29 = 29; 308 kCncParamReservedBit30 = 30; 309 kCncParamReservedBit31 = 31; 310 311 kCncParamSystemFlagsNum = $07FF; 312 313// the following parameter handles the system flags as an UInt32 integer (all the flags, at once) 314 kCncParamSystemFlags = kCncParamOSRange or kCncParamSystemFlag or kCncParamSystemFlagsNum; 315 kCncParamSystemFlagsSize = kCncParamUInt32Size; 316 317// bit parameters definition : to handle flags bit per bit 318 kCncParamReadOnly = kCncParamOSRange or kCncParamSystemFlag or 0; 319 320 kCncParamReadOnlySize = kCncParamSystemFlagSize; 321 322 kCncParamInvisible = kCncParamOSRange or kCncParamSystemFlag or 1; 323 kCncParamInvisibleSize = kCncParamSystemFlagSize; 324 325 kCncParamNonEditable = kCncParamOSRange or kCncParamSystemFlag or 2; 326 kCncParamNonEditableSize = kCncParamSystemFlagSize; 327 328 kCncParamNoDetails = kCncParamOSRange or kCncParamSystemFlag or 3; 329 kCncParamNoDetailsSize = kCncParamSystemFlagSize; 330 331 kCncParamLocked = kCncParamOSRange or kCncParamSystemFlag or 4; 332 kCncParamLockedSize = kCncParamSystemFlagSize; 333 334(* Bluetooth parameter IDs - New pieces of info *) 335 336// 48 bit blue Tooth address (BD_ADDR) - This address is derived from the IEEE802 standard 337 338 kCncParamBluetoothDeviceAddr = kCncParamOSRange or kCncParamBuffer or 50; 339 kCncParamBluetoothDeviceAddrSize = 8; 340 341// Bluetooth device name - 248 bytes coded according to the UTF-8 standard at max + NULL terninaison 342 kCncParamBluetoothDeviceName = kCncParamOSRange or kCncParamString or 51; 343 kCncParamBluetoothDeviceNameMaxSize = 249; 344 345// Caution : system parameter range ID from 80 to 200 are reserved for telephony services 346// and should never be reused by any other component 347 348(*********************************************************************** 349 * Telephony Manager parameter 350 ***********************************************************************) 351 352(* TT-AT specific parameters *) 353 354// New piece gathering several parts (uses the serial manager flags cf SerialMgr.h ) 355 kCncParamSerialPortFlags = kCncParamOSRange or kCncParamUInt32 or 84; 356 kCncParamSerialPortFlagsSize = kCncParamUInt32Size; 357 358// Telephony Task type - mobile telephony 359 kCncParamTTType = kCncParamOSRange or kCncParamUInt32 or 90; 360 kCncParamTTTypeSize = kCncParamUInt32Size; 361 362// Telephony Task Creator - mobile telephony 363 kCncParamTTCreator = kCncParamOSRange or kCncParamUInt32 or 91; 364 kCncParamTTCreatorSize = kCncParamUInt32Size; 365 366// Phone Driver Name - mobile telephony 367 kCncParam_PSDName = kCncParamOSRange or kCncParamString or 92; 368 kCncParam_PSDNameSize = dmDBNameLength; 369 370// Phone Driver creator - mobile telephony 371 kCncParam_PSDCreator = kCncParamOSRange or kCncParamUInt32 or 93; 372 kCncParam_PSDCreatorSize = kCncParamUInt32Size; 373 374// Phone Driver type - mobile telephony 375 kCncParam_PSDType = kCncParamOSRange or kCncParamUInt32 or 94; 376 kCncParam_PSDTypeSize = kCncParamUInt32Size; 377 378// Phone Driver Param Buffer - mobile telephony 379 kCncParam_PSDParameterBuffer = kCncParamOSRange or kCncParamBuffer or 100; 380 381(*********************************************************************** 382 * New Connection Manager trap selectors 383 ***********************************************************************) 384 385 sysTrapCncMgrProfileSettingGet = 1; 386 sysTrapCncMgrProfileSettingSet = 2; 387 sysTrapCncMgrProfileGetCurrent = 3; 388 sysTrapCncMgrProfileSetCurrent = 4; 389 sysTrapCncMgrProfileGetIDFromName = 5; 390 sysTrapCncMgrProfileCreate = 6; 391 sysTrapCncMgrProfileDelete = 7; 392 sysTrapCncMgrProfileGetIDFromIndex = 8; 393 sysTrapCncMgrProfileGetIndex = 9; 394 sysTrapCncMgrProfileCount = 10; 395 sysTrapCncMgrProfileOpenDB = 11; 396 sysTrapCncMgrProfileCloseDB = 12; 397 398(*********************************************************************** 399 * Connection Manager Library Macros 400 ***********************************************************************) 401 402(*********************************************************************** 403 * New Connection Mgr API 404 ***********************************************************************) 405 406function CncProfileSettingGet(profileId: CncProfileID; paramId: UInt16; paramBufferP: Pointer; var ioParamSizeP: UInt16): Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileSettingGet; 407 408function CncProfileSettingSet(iProfileId: CncProfileID; paramId: UInt16; const paramBufferP: Pointer; paramSize: UInt16): Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileSettingSet; 409 410function CncProfileSetCurrent(profileId: CncProfileID): Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileSetCurrent; 411 412function CncProfileGetCurrent(var profileIdP: CncProfileID): Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileGetCurrent; 413 414function CncProfileGetIDFromName(const profileNameP: PChar; var profileIdP: CncProfileID): Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileGetIDFromName; 415 416function CncProfileCreate(var profileIdP: CncProfileID): Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileCreate; 417 418function CncProfileDelete(profileId: CncProfileID): Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileDelete; 419 420function CncProfileGetIDFromIndex(index: UInt16; var profileIdP: CncProfileID): Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileGetIDFromIndex; 421 422function CncProfileGetIndex(profileId: CncProfileID; var indexP: UInt16): Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileGetIndex; 423 424function CncProfileCount(var profilesCountP: UInt16): Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileCount; 425 426function CncProfileOpenDB: Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileOpenDB; 427 428function CncProfileCloseDB: Err; syscall sysTrapCncMgrDispatch, sysTrapCncMgrProfileCloseDB; 429 430 431(*********************************************************************** 432 * Old Connection Mgr API, For compatibility only 433 ***********************************************************************) 434 435const 436// Maximum size for a Connection Profile Name 437 cncProfileNameSize = 22; 438 439// Error Codes 440 cncErrAddProfileFailed = cncErrorClass or 1; // Add profile attempt failed 441 cncErrProfileListFull = cncErrorClass or 2; // Add attempt failed because the 442 // profile list is full. 443 cncErrGetProfileFailed = cncErrorClass or 3; // Get profile attempt failed 444 cncErrConDBNotFound = cncErrorClass or 4; // Connection database not found 445 cncErrGetProfileListFailed = cncErrorClass or 5; // Could not get profile list 446 cncErrProfileReadOnly = cncErrorClass or 6; // The profile can not be altered 447 cncErrProfileNotFound = cncErrorClass or 7; // The profile could not be found 448 449// Functions 450 451function CncGetProfileList(var nameListPPP: PCharPtr; var countP: UInt16): Err; syscall sysTrapCncGetProfileList; 452 453function CncGetProfileInfo(name: PChar; var port, baud: UInt32; var volume, handShake: UInt16; 454 initString: PChar; var resetString: Char; var isModem, isPulse: Boolean): Err; syscall sysTrapCncGetProfileInfo; 455 456function CncAddProfile(name: PChar; port, baud: UInt32; volum, handShake: UInt16; 457 const initString, resetString: PChar; isMode, isPulse: Boolean): Err; syscall sysTrapCncAddProfile; 458 459function CncDeleteProfile(const name: PChar): Err; syscall sysTrapCncDeleteProfile; 460 461 462implementation 463 464end. 465