⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 messages.cpp

📁 mtk simulator v2 new source code
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	U16  byte_index;
	U8   bit_index;

	byte_index = (index >> 3);  /* divide 8 */
	bit_index  = (index & 0x7);  /* reminder */

	if(bitmap[byte_index] & (1<<bit_index))
		ret_val=1;
	return ret_val;
}

void* DeleteSMSRequest()
{
	mmi_sms_del_msg_req_struct * DelReq = ( mmi_sms_del_msg_req_struct *)gSMSBuffer;
	mmi_sms_del_msg_rsp_struct * DelRsp = (	mmi_sms_del_msg_rsp_struct *)CMemAllocator::MyMallocDataPtr(sizeof(mmi_sms_del_msg_rsp_struct ));
	if(DelReq->del_flag==7)//SMSAL_DEL_BITMAP
	{
		U8 i;
		for(i=0;i<MAX_SMS_BOX_LIMIT;i++)
		{
			if(IsBitOnInBitmap(DelReq->del_bitmap,i))
			{
				sms_box.total_box_entries--;
				memset(&sms_box.sms_box_entries[i],0,sizeof(sms_box_entry));
				sms_box.sms_box_entries[i].status=0xff;
			}
		}
		write_sms_box_file();
	}
	DelRsp->cause=0;
	memcpy(DelRsp->del_bitmap,DelReq->del_bitmap,480);
	DelRsp->del_flag=7;
	DelRsp->index=DelReq->index;
	DelRsp->result=KAL_TRUE;
	return (void *)DelRsp;
}

#define SIM_INDEX_BEGIN 0
#define SIM_INDEX_END 39
#define ME_INDEX_BEGIN 40
#define ME_INDEX_END 49

void *SendSmsMemStatus()
{
	mmi_sms_get_msg_num_rsp_struct *get_msg_mem_num_resp= (mmi_sms_get_msg_num_rsp_struct *)CMemAllocator::MyMallocDataPtr(sizeof(mmi_sms_get_msg_num_rsp_struct));
	U8 i;
	memset( get_msg_mem_num_resp, 0, sizeof(mmi_sms_get_msg_num_rsp_struct) );
	for(i=SIM_INDEX_BEGIN;i<SIM_INDEX_END;i++)
	{
		switch(sms_box.sms_box_entries[i].status)
		{
		case 0://unread
		case 1://read
			get_msg_mem_num_resp->in_sim_no++;
			break;
		case 2://sent
		case 3://unsent
			get_msg_mem_num_resp->out_sim_no++;
			break;
		}
	}
	for(i=ME_INDEX_BEGIN;i<ME_INDEX_END;i++)
	{
		switch(sms_box.sms_box_entries[i].status)
		{
		case 0://unread
		case 1://read
			get_msg_mem_num_resp->in_me_no++;
			break;
		case 2://sent
		case 3://unsent
			get_msg_mem_num_resp->out_me_no++;
			break;
		}
	}
	get_msg_mem_num_resp->total_sim_num=SIM_INDEX_END-SIM_INDEX_BEGIN+1;
	get_msg_mem_num_resp->total_me_num=ME_INDEX_END-ME_INDEX_BEGIN+1;
	get_msg_mem_num_resp->result=KAL_TRUE;
	get_msg_mem_num_resp->is_sim_card_change=KAL_TRUE;
	return (void *)get_msg_mem_num_resp;
}

// Arvind Start: Added for Simulator Ver 2.5
/*****************************************************************************
* FUNCTION
*	ReadCallCostPriceUnitFile
* DESCRIPTION
*	read the Call Cost Price and Unit
* PARAMETERS
*	void 
* RETURNS
*	void
*****************************************************************************/
void ReadCallCostPriceUnitFile()
{
	FILE *fp;
	
	if( (fp = fopen( "PriceUnit.txt", "rb" )) != NULL )
	{
		fread(&PriceUnitData, sizeof(PriceUnitData), 1, fp );
	}

	if( fp != NULL )fclose(fp);

}
/*****************************************************************************
* FUNCTION
*	WriteCallCostPriceUnitFile
* DESCRIPTION
*	write the Call Cost Price and Unit
* PARAMETERS
*	void 
* RETURNS
*	void
*****************************************************************************/
void WriteCallCostPriceUnitFile()
{
	FILE *fp;

	if( (fp = fopen( "PriceUnit.txt", "wb" )) != NULL )
	{
		fwrite(&PriceUnitData, sizeof(PriceUnitData), 1, fp );
	}

	if( fp != NULL )fclose(fp);
}

/*****************************************************************************
* FUNCTION
*	SetCallPriceUnit
* DESCRIPTION
*	Set the Call Cost Price and Unit
* PARAMETERS
*	void 
* RETURNS
*	void*
*****************************************************************************/
void *SetCallPriceUnit(void)
{
	mmi_call_price_unit_req_struct *PriceUnitReq = ( mmi_call_price_unit_req_struct * )gSMSBuffer;
	mmi_sms_del_msg_rsp_struct *SetPriceUnitResponse = (mmi_sms_del_msg_rsp_struct *)
			CMemAllocator::MyMallocDataPtr(sizeof(mmi_sms_del_msg_rsp_struct));
	
	memset( SetPriceUnitResponse, 0, sizeof(SetPriceUnitResponse) );

	memcpy(&PriceUnitData,PriceUnitReq,sizeof(mmi_call_price_unit_req_struct));

	WriteCallCostPriceUnitFile();

	SetPriceUnitResponse->result = KAL_TRUE;
	
	return (void*)SetPriceUnitResponse;
}

/*****************************************************************************
* FUNCTION
*	GetCallPriceUnit
* DESCRIPTION
*	Get the Call Cost Price and Unit
* PARAMETERS
*	void 
* RETURNS
*	void*
*****************************************************************************/
void *GetCallPriceUnit(void)
{
	int i=0;

	mmi_call_price_unit_rsp_struct *GetPriceUnitResponse = (mmi_call_price_unit_rsp_struct *)
			CMemAllocator::MyMallocDataPtr(sizeof(mmi_call_price_unit_rsp_struct));


	memset( GetPriceUnitResponse, 0, sizeof(GetPriceUnitResponse) );

	ReadCallCostPriceUnitFile();

	GetPriceUnitResponse->result = 1;

	for(i=0;i<3;i++)
		GetPriceUnitResponse->currency[i] = PriceUnitData.currency[i];

	for(i=0;i<18;i++)
		GetPriceUnitResponse->ppu[i] = PriceUnitData.ppu[i];


	return (void*)GetPriceUnitResponse;
}

/*	For 1543 */
void *SendMessageNumber()
{
	static int smsNotReady;
	mmi_sms_get_msg_num_rsp_struct *ListResponse = (mmi_sms_get_msg_num_rsp_struct *)CMemAllocator::MyMallocDataPtr(sizeof(mmi_sms_get_msg_num_rsp_struct));
	memset( ListResponse, 0, sizeof(mmi_sms_get_msg_num_rsp_struct) );
	/*	Code Start For Inbox List */	
	readSMSFile(0);
	readSMSFile(1);

	ListResponse->unread_msg_num = unreadCount;
	ListResponse->is_sim_card_change = KAL_TRUE;
	ListResponse->in_sim_no = inbox.count;
	ListResponse->in_me_no = 0;
	ListResponse->out_me_no = 0;
	ListResponse->out_sim_no = outbox.count;
	ListResponse->total_sim_num = 10;
	ListResponse->total_me_num = 10;
/*	if(smsNotReady> 3)  // Delay for "SMS not Ready yet"
	{
	    ListResponse->result = KAL_TRUE;
		ListResponse->is_sms_ready = KAL_TRUE;
	}
	else
	{
		ListResponse->result = KAL_FALSE;
		ListResponse->is_sms_ready = KAL_FALSE;
		smsNotReady++;
	}
*/
    ListResponse->result = KAL_TRUE;	
	return (void *)ListResponse;
}

// Arvind End: Added for Simulator Ver 2.5
struct 
{
	kal_uint8	pid;
	kal_uint8	dcs;
	kal_uint8	vp;
	l4c_number_struct	sc_addr;
	l4_name_struct	profile_name;
} profile_setting_box;

void ReadProfileSettingsFile(void);
void WriteProfileSettingsInFile(void);
void SaveProfileSettings(void);

void *GetProfileParamsRsp(void)
{
//	mmi_sms_get_profile_params_req_struct *ProfileParamReq = (mmi_sms_get_profile_params_req_struct *)gSMSBuffer;
	
	mmi_sms_get_profile_params_rsp_struct *ProfileParamRsp= (mmi_sms_get_profile_params_rsp_struct *)
	CMemAllocator::MyMallocDataPtr(sizeof(*ProfileParamRsp));

	memset(ProfileParamRsp,0,sizeof(*ProfileParamRsp));
	ReadProfileSettingsFile();
	ProfileParamRsp->result = KAL_TRUE;
	ProfileParamRsp->pid = profile_setting_box.pid;
	ProfileParamRsp->dcs = profile_setting_box.dcs;
	ProfileParamRsp->vp = profile_setting_box.vp;
	ProfileParamRsp->sc_addr.length = profile_setting_box.sc_addr.length;
	ProfileParamRsp->sc_addr.type = profile_setting_box.sc_addr.type;
	strcpy((char *)ProfileParamRsp->sc_addr.number, (char*)profile_setting_box.sc_addr.number);
	ProfileParamRsp->profile_name.name_length = profile_setting_box.profile_name.name_length;
	ProfileParamRsp->profile_name.name_dcs = profile_setting_box.profile_name.name_dcs;
	strcpy((char*)ProfileParamRsp->profile_name.name, (char*)profile_setting_box.profile_name.name);

	return (void*)ProfileParamRsp; 
}


void ReadProfileSettingsFile(void)
{
	FILE *fp = NULL;

	fp = fopen("profile_settings.txt", "rb");

	if(fp == NULL)
		SaveProfileSettings();
	else {
	
		fread(&profile_setting_box, sizeof(profile_setting_box), 1, fp);
		fclose(fp);
	}
}



void WriteProfileSettingsInFile(void)
{

	FILE *fp;

	fp = fopen( "profile_settings.txt", "wb" );
	fwrite(&profile_setting_box, sizeof(profile_setting_box), 1, fp );
	if( fp != NULL )fclose(fp);
}

void SaveProfileSettings(void)
{
	
	memset(&profile_setting_box, 0x00, sizeof(profile_setting_box));
	
	profile_setting_box.pid = 0;
	profile_setting_box.dcs = 0;
	profile_setting_box.vp = 0;
	profile_setting_box.sc_addr.type = 145;
	profile_setting_box.sc_addr.length = 10;
	strcpy((char*)profile_setting_box.sc_addr.number, (char*)"9812345678");
	profile_setting_box.profile_name.name_length = 8;
	profile_setting_box.profile_name.name_dcs = 0;
	strcpy((char*)profile_setting_box.profile_name.name, (char*)"Profile1");

	WriteProfileSettingsInFile();
}


void *SetProfileSettingParamsRsp(void)
{
	mmi_sms_set_profile_params_req_struct	* SetProfileReq = (mmi_sms_set_profile_params_req_struct *)gSMSBuffer;

	mmi_sms_set_profile_params_rsp_struct	* SetProfileRsp = (mmi_sms_set_profile_params_rsp_struct * )
					CMemAllocator::MyMallocDataPtr(sizeof(*SetProfileRsp));

	

	memset(SetProfileRsp, 0x00, sizeof(*SetProfileRsp));



	SetProfileRsp->result = KAL_TRUE;
	
	profile_setting_box.pid = SetProfileReq->pid;
	profile_setting_box.dcs = SetProfileReq->dcs;
	profile_setting_box.vp = SetProfileReq->vp;
	profile_setting_box.sc_addr.type = SetProfileReq->sc_addr.type;
	profile_setting_box.sc_addr.length = SetProfileReq->sc_addr.length;
	strcpy((char*)profile_setting_box.sc_addr.number, (char*)SetProfileReq->sc_addr.number);
	profile_setting_box.profile_name.name_length = SetProfileReq->profile_name.name_length;
	profile_setting_box.profile_name.name_dcs = SetProfileReq->profile_name.name_dcs;
	strcpy((char*)profile_setting_box.profile_name.name, (char*)SetProfileReq->profile_name.name);

	WriteProfileSettingsInFile();

	return (void *)SetProfileRsp;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -