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

📄 popselectmsgdlg.cpp

📁 mtk simulator v2 new source code
💻 CPP
字号:
/*****************************************************************************
*  Copyright Statement:
*  --------------------
*  This software is protected by Copyright and the information contained
*  herein is confidential. The software may not be copied and the information
*  contained herein may not be used or disclosed except with the written
*  permission of MediaTek Inc. (C) 2005
*
*  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
*  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
*  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
*  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
*  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
*  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
*  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
*  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
*  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
*  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
*  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
*  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
*  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
*  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
*  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
*  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
*  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE. 
*
*  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
*  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
*  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
*  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
*  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
/**
 *	Copyright Notice
 *	?2002 - 2003, Pixtel Communications, Inc., 1489 43rd Ave. W.,
 *	Vancouver, B.C. V6M 4K8 Canada. All Rights Reserved.
 *  (It is illegal to remove this copyright notice from this software or any
 *  portion of it)
 */
/**************************************************************

	FILENAME	: PopSelectMsgDlg.cpp

  	PURPOSE		: Pop up class for showing the message selection.

	REMARKS		: nil

	AUTHOR		:  Kuldeep

	DATE		: Oct 10,03

**************************************************************/

#include "stdafx.h"
#include "resource.h"
//#include "MMINWSimulator.h"
#include "PopSelectMsgDlg.h"
#include "GlobalDefines.h"
#include "OutgoingMessage.h"
#include "stdlib.h"
#include "MessageManager.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CPopSelectMsgDlg::CPopSelectMsgDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPopSelectMsgDlg::IDD, pParent)
	, DataSetName(_T(""))
	, edtFreq(_T(""))
	, edtTimer(_T(""))
{
	//{{AFX_DATA_INIT(CPopSelectMsgDlg)
	m_strMessageId = _T("");
	m_strMsgResponse = _T("");
	m_strMsgValue = _T("");	
	//}}AFX_DATA_INIT
}


void CPopSelectMsgDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPopSelectMsgDlg)
	DDX_Control(pDX, IDC_COMBO_MSG_RESPONSE_VALUE, m_cmbResponseVal);
	DDX_Control(pDX, IDC_COMBO_MSG_RESPONSE, m_cmbResponseId);
	DDX_Text(pDX, IDC_EDIT_MESSAGE_ID, m_strMessageId);
	DDX_CBString(pDX, IDC_COMBO_MSG_RESPONSE, m_strMsgResponse);
	DDX_CBString(pDX, IDC_COMBO_MSG_RESPONSE_VALUE, m_strMsgValue);
	//}}AFX_DATA_MAP
	DDX_Text(pDX, IDC_EDT_DATASET, DataSetName);
	DDX_Text(pDX, IDC_EDT_FREQ, edtFreq);
	DDX_Text(pDX, IDC_EDT_TIMER, edtTimer);
	DDX_Control(pDX, IDC_STATIC_MSG_DETAIL, static_msg_details);
	DDX_Control(pDX, IDC_STATIC_MSGID, static_msg_id);
	DDX_Control(pDX, IDC_STATIC_RESP_MSG, static_resp_msg);
	DDX_Control(pDX, IDC_STATIC_RESP_VAL, static_resp_val);
	DDX_Control(pDX, IDC_STATIC_DATASET, static_dataset);
	DDX_Control(pDX, IDC_STATIC_FREQUENCY, static_freq);
	DDX_Control(pDX, IDC_STATIC_TIMER, static_timer);
	DDX_Control(pDX, IDOK, send_button);
	DDX_Control(pDX, IDCANCEL, close_button);
}


BEGIN_MESSAGE_MAP(CPopSelectMsgDlg, CDialog)
	//{{AFX_MSG_MAP(CPopSelectMsgDlg)
	ON_CBN_SELCHANGE(IDC_COMBO_MSG_RESPONSE, OnSelchangeComboMsgResponse)	
	//}}AFX_MSG_MAP
	ON_CBN_SELCHANGE(IDC_COMBO_MSG_RESPONSE_VALUE, OnCbnSelchangeComboMsgResponseValue)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPopSelectMsgDlg message handlers

BOOL CPopSelectMsgDlg::OnInitDialog()

{
	CDialog::OnInitDialog();
	//initialise text
	InitText();
	//initiliase the message id 
	//message id is there in the edit field
	//now stuff the values in the combobox from the CList
	DisplayResponseMsgs();
	UpdateData(FALSE);

	//Load all the Application in the list in initDialog
	//Load all the subitems also in the list
	return TRUE;
}


void CPopSelectMsgDlg::SetLibraryIdentifier(HINSTANCE lib_id)
{
	library_identifier = lib_id;

}
/****************InitText function for initialising text*******************/
void CPopSelectMsgDlg::InitText()
{
	LoadString(library_identifier,IDS_STRING_MSG_DETAIL, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
	static_msg_details.SetWindowText(stringID_to_string);

	LoadString(library_identifier,IDS_STRING_MESSAGE_ID, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
	static_msg_id.SetWindowText(stringID_to_string);

	LoadString(library_identifier,IDS_STRING_RESP_MSG, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
	static_resp_msg.SetWindowText(stringID_to_string);

	LoadString(library_identifier,IDS_STRING_RESP_VAL, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
	static_resp_val.SetWindowText(stringID_to_string);

	LoadString(library_identifier,IDS_STRING_DS_INPUT_MODE, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
	static_dataset.SetWindowText(stringID_to_string);

	LoadString(library_identifier,IDS_STRING_STATIC_FREQ, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
	static_freq.SetWindowText(stringID_to_string);

	LoadString(library_identifier,IDS_STRING_STATIC_TIMER, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
	static_timer.SetWindowText(stringID_to_string);

	LoadString(library_identifier,IDS_STRING_SEND, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
	send_button.SetWindowText(stringID_to_string);

	LoadString(library_identifier,IDS_STRING_CLOSE, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
	close_button.SetWindowText(stringID_to_string);

	LoadString(library_identifier,IDS_STRING_DLG_POP_UP, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
	SetWindowText(stringID_to_string);


}

/**************************************************************

	FUNCTION NAME		: OnSelchangeComboMsgResponse

  	PURPOSE				: Called by the MFC framework if a message selection is changed.

	INPUT PARAMETERS	: nil

	OUTPUT PARAMETERS	: nil

	RETURNS				: void

	REMARKS				: MFC framework calls this function if a combo is selected.
**************************************************************/

void CPopSelectMsgDlg::OnSelchangeComboMsgResponse() 
{
	// TODO: Add your control notification handler code here
	//add the code here for getting the message from xml and popup the dialog
	//get the data values from the XML
	COutgoingMessage *pOutGoingMessage;
	CFormat *pFormat;
	CDataList dataList;
	CData dataObj;
	int iCount = 0;
	int iValue = 0;
	UINT32 iMsgId = 0;
	CString PluginName;
	//initialize the combo once again
	//iCount = m_cmbResponseVal.GetCount();	
	m_cmbResponseVal.ResetContent();
	m_cmbResponseVal.EnableWindow(1);

	/*------------- To Reset the content of Dataset, Freq and  Timer -------*/
	DataSetName = _T("");
	edtFreq		= _T("");
	edtTimer	= _T("");
	UpdateData(FALSE);
	/*----------------------------------------------------------------------*/

	//UpdateData(FALSE);
	if(m_cmbResponseId.GetCurSel() != CB_ERR)
		m_cmbResponseId.GetLBText(m_cmbResponseId.GetCurSel(),m_strMsgResponse);

	PluginName=GetPluginNameforResponse(m_strMsgResponse);
	if(PluginName.GetLength()>0)
	{
		m_cmbResponseVal.ResetContent();
		m_cmbResponseVal.SetWindowText(CString("Plugin - ")+PluginName);
		m_cmbResponseVal.EnableWindow(0);
	}
	else
	{
		//static_resp_val.SetWindowText(stringID_to_string);
	iMsgId = GetMessageIdforResponse(m_strMsgResponse);
	if(iMsgId > 0)
	{
		for( POSITION pos = m_lstRespMessages->GetHeadPosition(); pos != NULL;iCount++)
			{
				pOutGoingMessage = (COutgoingMessage*)(m_lstRespMessages->GetNext( pos ));
				if(pOutGoingMessage->GetMessageId() == iMsgId)
				{
					pFormat = GetFormatForMessage(pOutGoingMessage);
					dataList = pFormat->GetDataList();
					CList<CData,CData&>& data= dataList.GetData();
					if(data.GetCount() > 0)
					{
						for( POSITION datapos = data.GetHeadPosition(); datapos != NULL;iValue++)
						{
							dataObj = (data.GetNext( datapos ));
							m_cmbResponseVal.InsertString(iValue,dataObj.GetName());
						}//insert the exact value name of the data
					}//if data count  list exist
				}//if message id is mapped 
			}//for loop		
	}//if msg id > 0
}
}

/**************************************************************

	FUNCTION NAME		: OnOK

  	PURPOSE				: Called by the MFC framework if OK button is pressed.
	
	INPUT PARAMETERS	: nil

	OUTPUT PARAMETERS	: nil

	RETURNS				: void

	REMARKS				: It is called when the OK button on the dialog box is selected
**************************************************************/

void CPopSelectMsgDlg::OnOK() 
{
	// TODO: Add extra validation here
	//send the WM_SEND_POP_MSG message with the message id and the value if exist
	UpdateData(TRUE);
	HWND hWnd = ::GetParent(this->m_hWnd);
	PopUpMsgStruct *stMsgStruct = new PopUpMsgStruct;	
	//get the message id and the value
	if(m_cmbResponseId.GetCurSel() != CB_ERR)
	m_cmbResponseId.GetLBText(m_cmbResponseId.GetCurSel(),m_strMsgResponse);
	

	if(m_cmbResponseVal.GetCurSel() != CB_ERR)
	m_cmbResponseVal.GetLBText(m_cmbResponseVal.GetCurSel(),m_strMsgValue);
	//stuff these three values in the structure of three string and post it 
	stMsgStruct->strMsgValue = m_strMsgValue;
	stMsgStruct->strMsgId = m_strMessageId;
	stMsgStruct->strMsgResponse = m_strMsgResponse;

	stMsgStruct->nMsgId = GetMessageIdforResponse(m_strMsgResponse);
	if(!m_strMsgResponse.CompareNoCase(_T("")))
		AfxMessageBox(_T("Error Please select Response"));
	else
	{
	::PostMessage(hWnd,WM_SEND_POP_MSG,0,(LPARAM) stMsgStruct);
	//delete stMsgStruct;
	CDialog::OnOK();
       }
}

/**************************************************************

	FUNCTION NAME		: DisplayResponseMsgs

  	PURPOSE				: Displays the list of response messages in the combo box.
	
	INPUT PARAMETERS	: nil

	OUTPUT PARAMETERS	: nil

	RETURNS				: void

	REMARKS				: nil
**************************************************************/

void CPopSelectMsgDlg::DisplayResponseMsgs()
{
	//stuff the combo box with the CList values
	COutgoingMessage *pOutGoingMessage;	
	int iCount = 0;
	for( POSITION pos = m_lstRespMessages->GetHeadPosition(); pos != NULL;iCount++)
		{
			pOutGoingMessage = (COutgoingMessage*)(m_lstRespMessages->GetNext( pos ));
			m_cmbResponseId.InsertString(iCount,pOutGoingMessage->GetMessageName());
		}	
	if(iCount)
	//m_cmbResponseId.SetCurSel(0);	
	UpdateData(TRUE);
}

/**************************************************************

	FUNCTION NAME		: GetMessageIdforResponse

  	PURPOSE				: Gets the message id of a message with a name
	
	INPUT PARAMETERS	: CString

	OUTPUT PARAMETERS	: nil

	RETURNS				: UINT32

	REMARKS				: Searches for a message id with a particular name
**************************************************************/


UINT32 CPopSelectMsgDlg::GetMessageIdforResponse(CString strMsgResponse)
{
	COutgoingMessage *pOutGoingMessage;
	for( POSITION pos = m_lstRespMessages->GetHeadPosition(); pos != NULL;)
		{
			pOutGoingMessage = (COutgoingMessage*)(m_lstRespMessages->GetNext( pos ));
			if(!pOutGoingMessage->GetMessageName().CompareNoCase(strMsgResponse))
				return(pOutGoingMessage->GetMessageId());
			//m_cmbResponseId.InsertString(iCount,m_lstRespMessages.GetNext( pos ));		
		}	
	return NULL;
}

CString CPopSelectMsgDlg::GetPluginNameforResponse(CString strMsgResponse)
{
	COutgoingMessage *pOutGoingMessage;
	for( POSITION pos = m_lstRespMessages->GetHeadPosition(); pos != NULL;)

	{
		pOutGoingMessage = (COutgoingMessage*)(m_lstRespMessages->GetNext( pos ));
		if(!pOutGoingMessage->GetMessageName().CompareNoCase(strMsgResponse))
		{
			return(pOutGoingMessage->GetPluginName());
		}

	}	
	return CString("");
}

/**************************************************************

	FUNCTION NAME		: GetFormatForMessage

  	PURPOSE				: Gets the format object of a message
	
	INPUT PARAMETERS	: CMessage

	OUTPUT PARAMETERS	: nil

	RETURNS				: CFormat*

	REMARKS				: Searches for a message and returns the format in the message
**************************************************************/

CFormat* CPopSelectMsgDlg::GetFormatForMessage(CMessage *pMessage)
{
	if(pMessage!=NULL)
	{
		CFormat *pFormat;
		if(cmessagemanager.m_pFormatList->GetCount() > 0)//check if emtpy message list 
		{	
			for( POSITION pos = cmessagemanager.m_pFormatList->GetHeadPosition(); pos != NULL;)
			{
				pFormat = (CFormat*)(cmessagemanager.m_pFormatList->GetNext( pos )) ;
				if(!(pMessage->GetFormat().CompareNoCase(pFormat->GetName())))				
				{
					return pFormat;
				}
			}
		}	
	}
	return NULL;
}

void CPopSelectMsgDlg::OnCbnSelchangeComboMsgResponseValue()//Gurdev Code
{
	// TODO: Add your control notification handler code here
	CString str_msgname,str_datasetname,str_temp;
	CMessageManager  *ob_messagemanager = new CMessageManager();

	m_cmbResponseId.GetLBText  (m_cmbResponseId.GetCurSel()  ,str_msgname);
	m_cmbResponseVal.GetLBText ( m_cmbResponseVal.GetCurSel(),str_datasetname);
	
	DataSetName = str_datasetname;	
	UpdateData(FALSE);
	// dummy is for itoa conversion
	char *dummy = (char*) malloc(sizeof(char)*10);
	
	UINT32 frequency =  ob_messagemanager->GetFreq(str_msgname,str_datasetname);
	edtFreq = CString(itoa(frequency,dummy,10));
	UpdateData(FALSE);

	UINT32 timer =   ob_messagemanager->GetTimer(str_msgname,str_datasetname);
	edtTimer = CString(itoa(timer,dummy,10));
	UpdateData(FALSE);

	free(dummy);
	free(ob_messagemanager );
}

⌨️ 快捷键说明

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