/*****************************************************************************
 * Copyright (C) Gemalto M2M GmbH
 *****************************************************************************
 * Project: IMC-RIL-Driver
 *****************************************************************************
 * Author : Wireless Modules RD SW A2
 *****************************************************************************
 * $Workfile: Y:/z_ms-d/src/working/Quinn/RilDrv/callctrl.h $
 * $Revision: /main/ms-d/23 $
 *     $Date: 2013-06-27 17:50:21 $
 *   $Author: pmackent $
 *****************************************************************************
 * Target:
 *  Microsoft Windows Mobile 5.0
 *****************************************************************************
 * Description:
 *  Gemalto IMC RIL
 *****************************************************************************
 *
 * $Log: Y:/z_ms-d/src/working/Quinn/RilDrv/callctrl.h$ 
 * 
 * /main/ms-d/23   2013-06-27 17:50:21   pmackent 
 * Workaround for wrong "null" response in EHS5
 *
 * /main/ms-d/22   2013-03-20 15:32:05   pmackent
 * Change handling of data calls in CDMA in Windows Mobile (IPIS100085910)
 *
 * /main/ms-d/21   2012-11-29 15:30:58   pmackent
 * Adaptions call control for EHS5 under CE6
 *
 * /main/ms-d/20   2012-11-27 13:56:31   pmackent
 * Changed timing for voice call status for the EHS5
 *
 * /main/ms-d/19   2012-06-13 10:43:59   pmackent
 * Added support for CDMA flash
 *
 * /main/ms-d/18   2012-04-19 08:13:12   ctna0256
 * Don't use AT+CMUT? outside active voice call (IPIS100078740)
 *
 * /main/ms-d/17   2010-05-27 15:19:27   ctna0256
 * Handle case 1st call ID not equal 1, but 2nd call ID is.
 *
 * /main/ms-d/16   2010-04-23 10:20:44   ctna0256
 * Workaround for increasing call IDs after GPRS
 *
 * /main/ms-d/15   2010-02-24 13:25:50   ctna0256
 * Made CE6 driver comply with radiometrics test
 *
 * /main/ms-d/14   2010-02-03 10:50:39   ctna0256
 * Introduction of WinCE6 support
 *
 * /main/ms-d/12   2009-01-22 10:17:23   ctna0256
 * Optional re-call of RHA_ConfirmAudioMode after RHA_ActivateVoicePath
 *
 * /main/ms-d/11   2008-12-01 12:02:21   ctna0256
 * Reject incoming video calls automatically
 *
 * /main/ms-d/10   2008-08-22 10:22:44   ctna0256
 * Set Cinterion copyright text
 *
 * /main/ms-d/9   2008-08-21 09:33:58   ctna0256
 * Prepared for new disclaimer handling
 *
 * /main/ms-d/8   2008-07-22 10:45:12   mp49210
 * Changed handling of emergency calls for Korea
 *
 * /main/ms-d/7   2008-03-13 11:53:39   mp49210
 * Increase ECC cache size
 *
 * /main/ms-d/6   2007-10-09 09:59:58   mp49210
 * Simulating missing error at AT+CMUT
 *
 * /main/ms-d/5   2007-03-26 14:57:13   mp49210
 * Minimum difference between +CLIP and AT+CLCC
 *
 * /main/ms-d/4   2007-01-03 17:00:38   mp49210
 * Changes for problems with emergency call without SIM and multiparty calls.
 *
 * /main/ms-d/3   2006-12-21 18:26:51   mp49210
 * Changed handling of call states
 *
 * /main/ms-d/2   2006-12-15 17:12:42   mp49210
 * Update calll management capabilities.
 * Prevent 2G/3G switch while active call.
 *
 * /main/ms-d/1   2006-10-25 16:52:51   wm36264
 * First transformation from classic RIL
 *
*/

//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2008 Gemalto M2M GmbH
// Copyright (C) 2006-2008 Siemens AG
// Copyright (C) 2003 Intrinsyc Europe Ltd.
//
// Version: 1.0
// Date:    dummy
//
//////////////////////////////////////////////////////////////////////////////

/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1999  Microsoft Corporation
--*/

#pragma once

//
// Call status values
//
static const DWORD g_rgdwCallStats[] =
{
    RIL_CALLSTAT_ACTIVE,            // 0
    RIL_CALLSTAT_ONHOLD,            // 1
    RIL_CALLSTAT_DIALING,           // 2
    RIL_CALLSTAT_ALERTING,          // 3
    RIL_CALLSTAT_INCOMING,          // 4
    RIL_CALLSTAT_WAITING,           // 5
    0,                              // 6 (terminating: The call is not active anymore, but inband information is still available)
    0,                              // 7 (dropped: The call has been suspended by the network, but may be resumed later)
};
#define NUM_CALLSTATS   (sizeof(g_rgdwCallStats) / sizeof(DWORD))

//
// Call type values
//
static const DWORD g_rgdwCallTypes[] =
{
    RIL_CALLTYPE_VOICE,             // 0
    RIL_CALLTYPE_DATA,              // 1
    RIL_CALLTYPE_FAX,               // 2
    RIL_CALLTYPE_UNKNOWN,           // 3
    RIL_CALLTYPE_UNKNOWN,           // 4
    RIL_CALLTYPE_UNKNOWN,           // 5
    RIL_CALLTYPE_UNKNOWN,           // 6
    RIL_CALLTYPE_UNKNOWN,           // 7
    RIL_CALLTYPE_UNKNOWN,           // 8
    RIL_CALLTYPE_UNKNOWN,           // 9
};
#define NUM_CALLTYPES   (sizeof(g_rgdwCallTypes) / sizeof(DWORD))

//static const DWORD g_rgdwCpiStat[] =
//{
//    RIL_CPISTAT_NEW_INCOMING,       // 0
//    RIL_CPISTAT_DISCONNECTED,       // 1
//    RIL_CPISTAT_NEW_OUTGOING,       // 2
//    RIL_CPISTAT_UNKNOWN,            // 3
//    RIL_CPISTAT_UNKNOWN,            // 4
//    RIL_CPISTAT_UNKNOWN,            // 5
//    RIL_CPISTAT_CONNECTED,          // 6
//};
//#define NUM_CPISTATS    (sizeof(g_rgdwCpiStat) / sizeof(DWORD))

#ifdef RILDRV_CE6
struct CHECKDIALSUCCESS_THREAD_DATA {
    CRilHandle *pHandle;
    HRESULT hrCmd;
};
#endif

// Number used for CDMA data connection
#define CDMA_DATACONNECTION   "#777"

#define CALLCTRL_ALLOC_NUMBER        16
#define MAX_EMERGENCYNO 10

// Specific value for Cinterion modules: maximum numbers of lines to be handled
#define MAX_NUMBERCALLS                 10

// Size of the cache for emergency numbers from ECC SIM field (see GSM 11.11).
#define ECC_CACHE_SIZE           10

// Minimum time between +CLIP-URC and AT+CLCC-command
#define TIME_AFTER_CLIP   300

// Problem: if the module doesn't use the 1 for the ID for the 1st call, the RIL
// must set the ID of this call to 1. In case a 2nd call is made and the module
// now uses the ID for this call, the RIL must replace the ID with some safe
// ID, the module would otherwise never use.
#define REPLACEMENT_CALL_ID   7

// The AT+CLCC command might fail in unusual timing situation. Therefore it is
// a good idea to retry on failure.
#define CLCC_RETRIES 2
#define CLCC_DELAY    1000

HRESULT RILDrv_Dial(DWORD dwParam, LPCSTR szAddress, DWORD dwType, DWORD dwOptions);
HRESULT RILDrv_Answer(DWORD dwParam);
HRESULT RILDrv_Hangup(DWORD dwParam);
HRESULT RILDrv_SendDTMF(DWORD dwParam, LPCSTR lpszChars, DWORD dwDuration);
#ifndef RILDRV_CE6
HRESULT RILDrv_GetCallList(DWORD dwParam);
#endif
HRESULT RILDrv_ManageCalls(DWORD dwParam, DWORD dwCommand, DWORD dwID);
HRESULT RILDrv_TransferCall(DWORD dwParam, const RILADDRESS* lpAddress, const RILSUBADDRESS* lpSubAddress);
#ifndef RILDRV_CE6
HRESULT RILDrv_GetLineStatus(DWORD dwParam);
#endif
HRESULT RILDrv_GetCurrentAddressId(DWORD dwParam);
HRESULT RILDrv_SetCurrentAddressId(DWORD dwParam, DWORD dwAddressId);

HRESULT RILDrv_SendFlash(DWORD dwParam, LPRILADDRESS raRilAddress);

void RHADeactivateVoicePath(CRilHandle *pRILHandle, BOOL bAcceptIntermediateState, BOOL bDoCheck);
void RHAActivateVoicePath(CRilHandle * pHandle);
void TestLastActiveCall(CRilHandle* const pRilDevice);
BOOL IsACallDialing(CRilHandle *pDevice);
BOOL IsVoiceCallActive(CRilHandle *pDevice);
BOOL StoreAudioSetting(DWORD dwDevice, BOOL bForceSetting);
BOOL TranslateATDCmds(char *szCmd, DWORD dwBufferLen);
#ifdef RILDRV_CE6
void SendDisconnectNotification(CRilHandle *pRilHandle, DWORD dwCode);
void SendCE6CallProgressInfo(CRilHandle *pRilHandle, const RILCALLINFO *pCallInfo, INT iNrCallInfo);
#endif
BOOL CheckCDMADataConnStatus(CRilHandle *pDevice, RILCALLINFO *pCurrent, INT nNum, RILCALLINFO *pAddInfo);

DWORD WINAPI ReCheckCallStatusThreadProc(LPVOID pVoid);
DWORD WINAPI RejectVCallThreadProc(LPVOID pVoid);

HRESULT ParseGetCallListCheck(LPCSTR szRsp, void*& pBlob, UINT& cbBlob, LPVOID pParam);
HRESULT ParseGetCallListForceCheck(LPCSTR szRsp, void*& pBlob, UINT& cbBlob, LPVOID pParam);

extern INT g_iNrCallInfo;    // Number of active CSD calls (voice + data)
extern INT g_iIdxForFirstCall;
extern CRITICAL_SECTION g_CallInfoSection;
extern RILCALLINFO g_CallInfo[MAX_NUMBERCALLS];
extern UINT g_uiECCCacheSize;
extern char g_szECCCache[ECC_CACHE_SIZE][MAX_EMERGENCYNO];
extern BOOL g_fECCFieldAvailable;

extern DWORD g_LastATD;         // GetTickCount() from last ATD (voice) command
extern DWORD g_dwLastCLIPURC;   // GetTickCount() from last +CLIP: URC
extern DWORD g_dwLastVoiceCmd;  // Last voice command: ATD, ATA, ATH, AT+CHLD and RING (EHS5 only)

#ifdef RILDRV_CE6
extern DWORD g_dwLastDisconnectCause;
extern INT g_iLastIdxDisconnected;
#endif

