#ifndef AEECONFIG_H
#define AEECONFIG_H
/*======================================================
FILE:  AEEConfig.h

SERVICES:  Configuration Item interface to BREW

GENERAL DESCRIPTION:
   Base level definitions, typedefs, etc. for IConfig

        Copyright © 1999-2002 QUALCOMM Incorporated.
               All Rights Reserved.
            QUALCOMM Proprietary/GTDR
=====================================================*/

#include "AEEShell.h"

typedef struct _IConfig          IConfig;

//
// Configuration Items - Passed to ICONFIG_GetItem()/ICONFIG_SetItem()
//

#define   CFGI_DNS_IP1                       0     // 0: 32-bit IP, Domain Name Server(1) in network byte-order
#define   CFGI_DNS_IP2                       1     // 32-bit IP, Domain Name Server(2) in network byte-order
#define   CFGI_DOWNLOAD                      2     // AEEDownloadInfo, see AEEDownload.h
#define   CFGI_SUBSCRIBERID                  3     // 32-byte ASCIIZ
#define   CFGI_MOBILEINFO                    4     // AEEMobileInfo
#define   CFGI_AUTOSTART                     5     // 5: AEECLSID - Auto-Started Applet (AEE_Init())
#define   CFGI_BUSY_CURSOR_OFFSET            6     // Position of hourglass (AEERect *)
#define   CFGI_DOWNLOAD_BUFFER               7     // Size in bytes to buffer data during download before calling fs_write (default 10K)
#define   CFGI_HTTP_BUFFER                   8     // Size in bytes of HTTP read buffer (default 4K)
#define   CFGI_NET_CONNTIMEOUT               9     // time in milliseconds! to wait for connect()
#define   CFGI_SUBSCRIBERID_LEN              10    // 10: Size in bytes of subscriber ID (default used if error returned)
#define   CFGI_MAX_DISPATCH_TIME             11    // Maximum time BREW should spend in the dispatcher before relinquishing control (default = 250 msecs)
#define   CFGI_MIN_IDLE_TIME                 12    // Minimum time BREW must relinquish from dispatcher (default = 35 msecs)
#define   CFGI_SLEEP_TIMER_RESOLUTION        13    // Timer resolution during when processor/os is in SLEEP mode (default = 1.2 seconds)
#define   CFGI_SYSMEM_SIZE                   14    // Size in bytes reserved to the system in low-memory (default = 2K)
#define   CFGI_DOWNLOAD_FS_INFO              15    // DLItemSize * (Fill dwFSAvail, dwFSSize)
#define   CFGI_SCREEN_SAVER                  16    // AEEScreenSaverInfo *
#define   CFGI_CLOSE_KEYS                    19    // OEMCloseKeys * (see structure below)
#define   CFGI_FILE_CACHE_INFO               20    // OEMFileCacheInfo * (see structure below)
#define   CFGI_GPSONE_TRANSPORT              21    // OEM GPS transport(IP, Data burst)OEM GPS transport (IP, Data burst) 
#define   CFGI_GPSONE_SVRIP                  22    // GPS server IP address
#define   CFGI_GPSONE_SVRPORT                23    // GPS server IP port
#define   CFGI_GPSONE_LOCK                   24    // GPS lock
#define   CFGI_MODULE_FSLIMIT                25    // MIFFSLimit * (wMaxFiles and dwMaxSpace for the module)
#define   CFGI_CARDID_LEN                    26    // Size in bytes of #define   CFGI_CARDID
#define   CFGI_CARDID                        27    // byte * of size returned by #define   CFGI_CARDID_LEN
#define   CFGI_DEBUG_KEY                     28    // OEMDebugKey * below
#define   CFGI_ALLOW_3G_2G_FAILOVER          30    // boolean, if TRUE, allow failover (see OEMSock.c)
#define   CFGI_ISTATIC_SCROLL                31    // Time in milliseconds for IStatic scroll speed
#define   CFGI_APPX5_MPC_ADDR                32    // where the MPC specified in CU Appx5 lives (IP addr in network-byte order)
#define   CFGI_APPX5_MPC_PORT                33    // where the MPC specified in CU Appx5 lives (IP port in network-byte order)
#define   CFGI_MAX_DEMO_ITEMS                34    // Count of demo items (default = 20), int *
#define   CFGI_WEB_IDLECONNTIMEOUT           35    // default IWeb IDLECONNTIMEOUT, in seconds, used if unspecified by application (see AEEWeb.h)
#define   CFGI_APP_KEY_1                     36    // Application key to be used for authorization/signing (uses OEMConfigData below)
#define   CFGI_GSM1X_PRL                     37    // PRL access
#define   CFGI_GSM1X_RTRE_CONFIG             38    // RTRE_CONFIG variable access
#define   CFGI_GSM1X_IDENTITY_PARAMS         39    // Writing IMSI, ACCOLC and MSISDN to GSM1x assigned NAM
#define   CFGI_GSM1X_SID_NID_PARAMS          40    // Read/write home or locked SID/NID stored in NV.
#define   CFGI_OFFLINE_PPP_TIMEOUT           41    // time in milliseconds! to wait in offline state before closing PPP
#define   CFGI_CACHED_RESOURCES              42    // OEMResCacheInfo * below
#define   CFGI_SAFEMODE_STARTMODE            43    // Starting mode for the handset (Normal, Probation, or safe)
#define   CFGI_SAFEMODE_TIMER                44    // Time (in msecs) to wait before restoring device to normal mode
#define   CFGI_AUTOSTARTARGS                 45    // Auto start args
#define   CFGI_KB_AUTOREPEAT                 46    // OEMAutoRepeat * defined below
#define   CFGI_MOBILE_DIR_NUM                47    // Mobile Directory Number
#define   CFGI_MOBILE_DIR_NUM_LEN            48    // Mobile Directory Number length
#define   CFGI_FIRMWARE_ID                   49    // Firmware ID (OEM specific) 
#define   CFGI_FIRMWARE_ID_LEN               50    // Firmware ID length 
#define   CFGI_MAX_ACK_ATTEMPTS              51    // Max retries to flush preinstall/delete acks
#define   CFGI_SMS_EMAIL_DEST_LENGTH         52    // Length of destination referred by CFGI_SMS_EMAIL_DEST
#define   CFGI_SMS_EMAIL_DEST                53    // Destination to use if email needs to be sent as email address copied to payload (VZW IS-41 workaround) 
#define   CFGI_SMS_MAX_PAYLOAD_LENGTH        54    // Maximum payload length in terms of number of bytes
#define   CFGI_SMS_DEFAULT_MO_ENC            55    // Default encoding for MO SMS
#define   CFGI_SMS_MO_ENC_TYPES              56    // Encoding types available for MO SMS
#define   CFGI_SMS_MO_ENC_TYPES_COUNT        57    // Count of encoding types available for MO SMS
#define   CFGI_BREWDIR_SMS_TELESERVICE       58    // Teleservice ID of BREW directed SMS
#define   CFGI_SMS_MO_ON_ACCESS_CHANNEL      59    // boolean, if TRUE, SMS message is sent on access channel
#define   CFGI_SMS_MO_ON_TRAFFIC_CHANNEL     60    // boolean, if TRUE, SMS message is sent on traffic channel. If both of
                                                   // CFGI_SMS_MO_ON_ACCESS_CHANNEL and CFGI_SMS_MO_ON_TRAFFIC_CHANNEL
                                                   // are TRUE, SMS message is first sent on access channel and on being
                                                   // too large for access channel is sent on traffic channel
#define   CFGI_DORMANCY_TIMEOUT_DEFAULT      61    // Default value for packet data inactivity timeout, which initiates dormancy
#define   CFGI_DOWNLOAD_CACHE                62    // maximum download'able item size that can be cached. default is 1k
#define   CFGI_LNG                           63    // Device Language Code
#define   CFGI_MANNER_MODE                   64    // Set device manner mode. pSrc = AEE_MANNER_MODE_XXX, nSize = sizeof(uint32)
#define   CFGI_APPX5_ON                      65    // User plane position determination ON (boolean)
#define   CFGI_GPSONE_LOCATION_SERVER_NAME1  66    // location server fully qualified internet name.
#define   CFGI_GPSONE_LOCATION_SERVER_NAME2  67    // location server fully qualified internet name.
#define   CFGI_SMS_GW_SCADDRESS_LENGTH       68    // length of default SC address for GW messages
#define   CFGI_SMS_GW_SCADDRESS              69    // default SC address for GW messages
#define   CFGI_SMS_GW_DOMAIN_PREF            70    // domain preference for GW messages
#define   CFGI_PROVISION_FIRST               0x1000 //Offset to build dependent items
#define   CFGI_PROVISION_LAST                0x2fff //End of build dependent items
#define   CFGI_MAX                           0x3000 //Max AEE value
#define   CFGI_FIRST_OEM                     CFGI_MAX //OEM added config items should start at this value


#if defined(__cplusplus)
extern "C" {
#endif

typedef struct
{
   uint32 nSize;
   uint8* pData;
} OEMConfigData;

//
// OEM Keypad Auto-Repeat Parameters
//
// Allows the OEM to override KB_AUTOREPEAT_START and KB_AUTOREPEAT_RATE.  Both
// numbers are represented in milliseconds.
//
// Note the following:
//
// - If dwStart is 0, auto-repeat is disabled
// - If dwDelay is 0, only a single EVT_KEY with the KB_AUTOREPEAT bit set is sent.
//

typedef struct OEMKBAutoRepeat
{
   uint32   dwStart;          // Default KB_AUTOREPEAT_START
   uint32   dwRate;           // Default KB_AUTOREPEAT_RATE
} OEMKBAutoRepeat;

//
// MIFFSLimit: Used in OEMGetConfig() when CFGI_MODULE_FSLIMIT is passed
//
typedef PACKED struct
{
   uint16            wMaxFiles;     // Maximum number of files in EFS this Module is allowed to create
   uint16            wPad;          // padding
   uint32            dwMaxSpace;    // Maximum EFS Space this module is allowed to consume
} MIFFSLimit;

/* Definitions and types needed for CFGI_GSM1X_... parameters.*/
#define GSM1X_MAX_MINS         (2)
#define GSM1X_DIR_NUMB_SIZ     (10)
#define GSM1X_DIR_NUMB_PCS_SIZ (15)

#define GSM1X_HOME_SID_NID_MAX_CNT    (20)
#define GSM1X_LOCKED_SID_NID_MAX_CNT  (20)


typedef PACKED struct {
  uint8    *pRoamingListStruct;
  boolean   enabled;
  uint16    maxSizeBytes;
} AEEGSM1xPRLInfo;

typedef uint8  AEEGSM1xRTREConfig;

typedef PACKED struct {
   uint8   nam;
   uint32  imsi_s1[GSM1X_MAX_MINS];
   uint16  imsi_s2[GSM1X_MAX_MINS];
   uint16  mcc;
   byte    imsi_11_12;
   byte    addr_num;
   uint32  t_imsi_s1[GSM1X_MAX_MINS];
   uint16  t_imsi_s2[GSM1X_MAX_MINS];
   uint16  t_mcc;
   uint8   t_imsi_11_12;
   uint8   t_addr_num;
   uint8   accolc[GSM1X_MAX_MINS];
   uint8   msisdn[GSM1X_DIR_NUMB_SIZ];
   uint8   num_digits;
   uint8   digitn[GSM1X_DIR_NUMB_PCS_SIZ];
} AEEGSM1xIdentityParams;

typedef PACKED struct {
   uint8   nam;
   uint16  homePairCnt;
   uint16 *pHomeSID;
   uint16 *pHomeNID;
   uint16  lockedPairCnt;
   uint16 *pLockedSID;
   uint16 *pLockedNID;
} AEEGSM1xSIDNIDParams;

typedef int AEEConfigItem;

//
// OEM Debug Key Definition
//
// Default:
//
// key = AVK_POUND
// nRepeat = 3
//
typedef struct
{
   AVKType  key;
   int16    nRepeat;
} OEMDebugKey;

#define DEFAULT_DBG_KEY       (AVK_POUND)
#define DEFAULT_DBG_KEY_COUNT (3)

//
// File Cache Defaults
//
// nCacheDefault - Default file cache size
// nCacheMin - Minimum size to cache (if below file size)
// nCacheMax - Maximum size to cache (if below file size)
// bCloseCachedFiles - Close file handle for file that is fully cached in read-only mode
//

#define FCACHE_ANY_VALUE   (-1)
#define FCACHE_DEFAULT     (0x1000)             // default cache size
#define FCACHE_MIN         (FCACHE_ANY_VALUE)   // minimum cache size (-1 == Ignored)
#define FCACHE_MAX         (FCACHE_ANY_VALUE)   // maximum cache size (-1 == Ignored)

typedef struct
{
   int32    nCacheDefault;
   int32    nCacheMin;
   int32    nCacheMax;
   boolean  bCloseCachedFiles;
} OEMFileCacheInfo;

//
// Cached Resource File Information
//
// This configuration item allows the OEM to control how many resource files are
// cached and how much data is cached for each resource file.  The "nCachedFiles"
// value is used to preallocate a structure that contains information about the
// file.  However, the entries are only populated when used.  The "nCacheSize"
// value allows the OEM to control how much data is cached for each file.  By
// default, the SCS_BEST value indicates that the entire resource file will
// be cached.
//

#define RCACHE_DEFAULT_CACHE  (SCS_BEST)
#define RCACHE_DEFAULT_FILES  (24)

typedef struct
{
   int      nCachedFiles;     // Default is RCACHE_DEFAULT_FILES
   int      nCacheSize;       // Default is RCACHE_DEFAULT_CACHE
} OEMResCacheInfo;

//
// OEM Close Keys
//
typedef struct
{
   AVKType     wCloseApp;        // Virtual key to close current app
   AEEEvent    evtCloseApp;      // EVT_KEY_PRESS, EVT_KEY_RELEASE, EVT_KEY, EVT_KEY_HELD
   AVKType     wCloseAllApps;    // Virtual key to close all apps
   AEEEvent    evtCloseAllApps;  // EVT_KEY_PRESS, EVT_KEY_RELEASE, EVT_KEY, EVT_KEY_HELD
} OEMCloseKeys;

//
//
// CFGI_MOBILEINFO type - Mobile Info structure
//

typedef struct
{
   uint8                nCurrNAM;
   uint32               dwESN;
   char                 szMobileID[16];
} AEEMobileInfo;


//
// Download/Device Flags
//

#define DIF_USE_A_KEY            0x0001   // default OFF (use bKey).  If set, use AKey value
#define DIF_TEST_ALLOWED         0x0002   // This phone can be used to test local apps
#define DIF_MIN_FOR_SID          0x0004   // Use the MIN for the SID if not set
#define DIF_PREPAY               0x0008   // Prepay phone
#define DIF_NO_AUTO_ACK          0x0040   // Do not force ACKs until user runs MobileShop
#define DIF_SID_ENCODE           0x0080   // Uses SID rather than ESN for app encoding
#define DIF_SID_VALIDATE_ALL     0x0100   // Validates all apps rather than just SSN apps
#define DIF_RUIM_DEL_OVERRIDE    0x0200   // Allows one RUIM user to delete apps owned by another
#define DIF_AUTO_UPGRADE         0x0400   // Perform automatic upgrade when new uses purchased
#define DIF_NO_LAUNCH_MOD_ACK_DISABLED \
                                 0x0800   //Do not launch an app if it has flag MOD_ACK_DISABLED set
                                          //Use in prepay to confirm payment before app usage


//
// The protected flags cannot be set by the ADS.  They can only be set by the OEM or
// in debug modes. Note that the DIF_OEM_PROTECTED_FLAGS cannot be updated
// by anyone but the OEM.
//

#define DIF_OEM_PROTECTED_FLAGS  (DIF_TEST_ALLOWED|DIF_SID_ENCODE)
#define DIF_PROTECTED_FLAGS      (DIF_TEST_ALLOWED|DIF_SID_ENCODE|DIF_USE_A_KEY|DIF_MIN_FOR_SID)
#define DIF_ALL_FLAGS            (DIF_USE_A_KEY|DIF_TEST_ALLOWED|DIF_MIN_FOR_SID|DIF_PREPAY|\
                                  DIF_NO_AUTO_ACK|DIF_SID_ENCODE|DIF_SID_VALIDATE_ALL|\
                                  DIF_RUIM_DEL_OVERRIDE|DIF_AUTO_UPGRADE|DIF_NO_LAUNCH_MOD_ACK_DISABLED)

//
// Default Screen-Saver timeout
//

#define DEFAULT_SCREEN_SAVER_TIMEOUT   (30)


//
// CFGI_SUBSCRIBERID - Default length in characters/bytes
//

#define DEFAULT_SUBSCRIBERID_LEN    (32)

//*******************************************************************************
//
// Dynamic Config Interface - Can be called by dynamically linked code.  Implementation
// is controlled by PL_SYSTEM and cascades to static functions.
//
//*******************************************************************************

QINTERFACE(IConfig)
{
   DECLARE_IBASE(IConfig)

   int   (*GetItem)(IConfig * po, AEEConfigItem n, void * pDest, int nSize);
   int   (*SetItem)(IConfig * po, AEEConfigItem n, void * pSrc, int nSize);
};

#define ICONFIG_AddRef(po)                GET_PVTBL(po,IConfig)->AddRef(po)
#define ICONFIG_Release(po)               GET_PVTBL(po,IConfig)->Release(po)
#define ICONFIG_SetItem(po,n,ps,ns)       GET_PVTBL(po,IConfig)->SetItem(po,n,ps,ns)
#define ICONFIG_GetItem(po,n,ps,ns)       GET_PVTBL(po,IConfig)->GetItem(po,n,ps,ns)

#if defined(__cplusplus)
}
#endif

#endif   // AEECONFIG_H
