📄 mminwsimulatordlg.cpp
字号:
void CMMINWSimulatorDlg::SendMsgSequence(UINT32 MessageSequenceId)
{
CAsyncMessageSeq *pAsyncMessage;
if(m_pMessageManager->m_plstAsyncMsg->GetCount() > 0)//check if emtpy message list
{
for( POSITION pos = m_pMessageManager->m_plstAsyncMsg->GetHeadPosition(); pos != NULL;)
{
pAsyncMessage = (CAsyncMessageSeq*)(m_pMessageManager->m_plstAsyncMsg->GetNext( pos )) ;
if(pAsyncMessage->GetMessageId()==MessageSequenceId)
break;
}
}
SendAsyncMessageToMMI(pAsyncMessage->GetMessageName());
}
/*-------------------- Implementing Bootup sequence --------------------------*/
void CMMINWSimulatorDlg::SendBootupMessage()
{
CPtrList *ptrCPtrList;
UINT32 messageid;
CBootUpMsg *pBootUpMsg;
ptrCPtrList = (CPtrList*)m_pMessageManager->m_pBootupList;
if(ptrCPtrList)
{
if(ptrCPtrList->GetCount() > 0)//check if emtpy message list
{
POSITION pos = ptrCPtrList->GetHeadPosition();
pBootUpMsg = (CBootUpMsg *)(ptrCPtrList->GetNext( pos )) ;
CList <UINT32, UINT32>& messageidlist = pBootUpMsg->GetBootMessageList();
if(messageidlist.GetCount()>0)
{
for(pos=messageidlist.GetHeadPosition();pos!=NULL;)
{
messageid = (UINT32) messageidlist.GetNext(pos);
SendMsg(messageid);
}
}
}
}
}
void CMMINWSimulatorDlg::SendMsgFromTBR(UINT nID)
{
SendAsyncMessageToMMI(GetSeqNameForButton(nID));
}
////can be taken if dependency for ptr list is removed
CString CMMINWSimulatorDlg::GetSeqNameForButton(UINT32 nID)
{
for(int index= 0; index<10; index++)
{
if(nID == buttons[index])
break;
}
int to_be_sent_msg_id = MsgIdArray[index];
CAsyncMessageSeq *pAsyncMessage;
if(m_pMessageManager->m_plstAsyncMsg->GetCount() > 0)//check if emtpy message list
{
for( POSITION pos = m_pMessageManager->m_plstAsyncMsg->GetHeadPosition(); pos != NULL;)
{
pAsyncMessage = (CAsyncMessageSeq*)(m_pMessageManager->m_plstAsyncMsg->GetNext( pos )) ;
if(to_be_sent_msg_id == pAsyncMessage->GetMessageId())
break;
}
}
if(to_be_sent_msg_id == pAsyncMessage->GetMessageId())
return(pAsyncMessage->GetMessageName());
else
return (CString(_T("")));
}
BOOL CMMINWSimulatorDlg::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
{
ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW);
// if there is a top level routing frame then let it handle the message
if (GetRoutingFrame() != NULL) return FALSE;
// to be thorough we will need to handle UNICODE versions of the message also !!
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
TCHAR szFullText[512];
CString strTipText;
UINT nID = pNMHDR->idFrom;
if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
{
// idFrom is actually the HWND of the tool
nID = ::GetDlgCtrlID((HWND)nID);
}
if (nID != 0) // will be zero on a separator
{
AfxLoadString(nID, szFullText);
strTipText= GetSeqNameForButton(nID);
#ifndef _UNICODE
if (pNMHDR->code == TTN_NEEDTEXTA)
{
lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText));
}
else
{
_mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
}
#else
if (pNMHDR->code == TTN_NEEDTEXTA)
{
_wcstombsz(pTTTA->szText, strTipText,sizeof(pTTTA->szText));
}
else
{
lstrcpyn(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
}
#endif
*pResult = 0;
// bring the tooltip window above other popup windows
::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0,SWP_NOACTIVATE|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); return TRUE;
}
return TRUE;
}
void CMMINWSimulatorDlg::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
{
if (lpwndpos->cx == -1)
if (lpwndpos->cy == -1) // is init time
{
lpwndpos->x = 257; // change here if you want to move left or right the window.
lpwndpos->y = 41; // change here if you want to move top or bottom the window.
// lpwndpos->cx=1;
// lpwndpos->cy=1;
CDialog::OnWindowPosChanging(lpwndpos);
}
//return 1;
}
void CMMINWSimulatorDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDialog dlgAbout;
dlgAbout.SetTheLibraryIdentifier(library_identifier);
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMMINWSimulatorDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMMINWSimulatorDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMMINWSimulatorDlg::InitializeControls()
{
//m_pMessageManager->LoadStringE(library_identifier,IDS_STRING_MESSAGE_ID,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);
int iError = m_lstIncomingMessages.InsertColumn(0,stringID_to_string,NON_EDITABLE,NULL,MAX_STR_RES_LEN,LVCFMT_LEFT,70,0);
iError = m_lstOutGoingMessages.InsertColumn(0,stringID_to_string,NON_EDITABLE,NULL,MAX_STR_RES_LEN,LVCFMT_LEFT,70,0);
LoadString(library_identifier,IDS_STRING_MESSAGE_NAME,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
iError = m_lstIncomingMessages.InsertColumn(1,stringID_to_string,SELECTABLE,NULL,MAX_STR_RES_LEN,LVCFMT_LEFT,300,0);
iError = m_lstOutGoingMessages.InsertColumn(1,stringID_to_string,SELECTABLE,NULL,MAX_STR_RES_LEN,LVCFMT_LEFT,300,0);
LoadString(library_identifier,IDS_STRING_MESSAGE_TIME,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
iError = m_lstIncomingMessages.InsertColumn(2,stringID_to_string,SELECTABLE,NULL,MAX_STR_RES_LEN,LVCFMT_LEFT,200,0);
iError = m_lstOutGoingMessages.InsertColumn(2,stringID_to_string,SELECTABLE,NULL,MAX_STR_RES_LEN,LVCFMT_LEFT,200,0);
//iError = m_lstIncomingMessages.InsertColumn(2,_T("Message Response"),SELECTABLE,NULL,MAX_STR_RES_LEN,LVCFMT_LEFT,200,0);
//initialize the Incoming Messages List control
//m_lstOutGoingMessages.SetEditableColumns(2);
LoadString(library_identifier,IDS_STRING_DLG_NWS,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
SetWindowText(stringID_to_string);
DWORD dwStyleOld = m_lstOutGoingMessages.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE,0,0);
dwStyleOld = dwStyleOld^LVS_EX_FULLROWSELECT;
m_lstOutGoingMessages.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE,0,(LPARAM)dwStyleOld);
dwStyleOld = m_lstIncomingMessages.SendMessage(LVM_GETEXTENDEDLISTVIEWSTYLE,0,0);
dwStyleOld = dwStyleOld^LVS_EX_FULLROWSELECT;
m_lstIncomingMessages.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE,0,(LPARAM)dwStyleOld);
}
void CMMINWSimulatorDlg::StartSockets()
{
//to start the sockets threads
// myNSRThread = new CNSRThread();
myNSRThread->m_hWindow = NULL;
// myNSWThread = new CNSWThread();
myNSRThread->m_hWindow = NULL;
// if(!myNSWThread->CreateThread())
// {
// AMLOGERROR(_T("Error in Creating thread for NSR thread"));
// exit(0);
// }
// if(!myNSRThread->CreateThread())
// {
// AMLOGERROR(_T("Error in Creating thread for NSW thread"));
// exit(0);
// }
//set the handle first for the post message option
myNSWThread->SetWindowHandle(this->m_hWnd);
myNSRThread->SetWindowHandle(this->m_hWnd);
//Sleep(1000);
}
LRESULT CMMINWSimulatorDlg::OnMessageRecieve(WPARAM wParam, LPARAM lParam)
{
m_IncomingMsg = myNSWThread->GetMessage();
AMLOGINFO(_T("Message Recieved by simulator"));
AMLOGINFO(_T("Event Type is -> %d & Message id is -> %d"),m_IncomingMsg.nEventType,m_IncomingMsg.nMsgType);
DisplayMessageInList(m_IncomingMsg,TRUE);
m_MessageId = m_IncomingMsg.nMsgType;
CMessage *pMessage = m_pMessageManager->LocateMessageInList(m_pMessageManager->m_plstIncomingMsg,m_IncomingMsg.nMsgType);
CIncomingMsg *incomingmsg;
incomingmsg =(CIncomingMsg*) pMessage;
CList <UINT32, UINT32>& asyncseqlist = incomingmsg->GetAsyncMessageList();
UINT32 sequenceid;
if(pMessage)
{
//call the plugin if exist
CString strPluginName = pMessage->GetPluginName();
if(strPluginName!= _T(""))
{
//call the plugin function
PluginFunctionForMessage(strPluginName);
//commented return so as to handle the case when
//incoming msg has a plugin as well as response is auto
//return(TRUE);
}
}
//send the message if application is auto that is send it in the background if its auto
if(pMessage!=NULL)
{
if(!(CString("auto").CompareNoCase(pMessage->GetResponseMode()))) // If response mode is auto
{
CPtrList *ptRespList = GetAllResponseMsgs(pMessage->GetMessageId());
CMessage *pOutGoingMsg;
if(ptRespList->GetCount() > 0)//this means response message exist
{
for( POSITION pos = ptRespList->GetHeadPosition(); pos != NULL; )
{
pOutGoingMsg = (COutgoingMessage*)(ptRespList->GetNext( pos )) ;
pMessage = m_pMessageManager->LocateMessageInList(m_pMessageManager->m_plstOutGoingMsg,pOutGoingMsg->GetMessageId());
if(pMessage!=NULL)
SendMessageToMMI(pMessage,_T(""));
}
}
/*------------ Check if there is async sequence ------------------*/
if(asyncseqlist.GetCount() > 0)//this means response message exist
{
for( POSITION pos = asyncseqlist.GetHeadPosition(); pos != NULL; )
{
//evaluating the sequence id
sequenceid= (UINT32)(asyncseqlist.GetNext( pos )) ;
//sending the async sequence
SendMsgSequence(sequenceid);
}
}
}
}
return(TRUE);
//call the message plugin if exist
}
void CMMINWSimulatorDlg::DisplayMessageInList(MYQUEUE1 msg, BOOL Flag)
{
//get the current location from the list
//display the current message on the list
if(Flag)//incoming messsages
{
LVITEM stItem;
int Count= m_lstIncomingMessages.GetItemCount();
CString strMsgId;
strMsgId.Format(_T("%d"),msg.nMsgType);
stItem.mask = LVIF_IMAGE | LVIF_TEXT;
stItem.iItem = Count;
stItem.pszText = strMsgId.GetBuffer(0);
stItem.cchTextMax = strMsgId.GetLength()+1;
stItem.iSubItem = 0;
stItem.state = LVIS_SELECTED;
stItem.stateMask = LVIS_SELECTED;
stItem.lParam = m_IndexInIncomingMsgList;
stItem.iImage = 1;
int val = m_lstIncomingMessages.InsertItem(&stItem);
//m_lstIncomingMessages.InsertItem(Count,strMsgId,NULL);
CString message_name;
message_name = m_pMessageManager->LocateMessageNameInList(m_pMessageManager->m_plstIncomingMsg,(UINT)msg.nMsgType);
if(!message_name.CompareNoCase(_T("")))
{
LoadString(library_identifier,IDS_STRING_MSG_NAME_NOT_SUPPORTED,message_name.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
}
m_lstIncomingMessages.SetItemText(Count,1,message_name);
strMsgId = GetSystemTimeString();
m_lstIncomingMessages.SetItemText(Count,2,strMsgId);
//m_lstIncomingMessages.SetItemText(Count,2,_T("haa haai haai haai"));
AddMessageToList(m_IncomingMsg);//addd the item in the CList
m_IndexInIncomingMsgList++;//add and then increment
m_lstIncomingMessages.SetItemState(val,LVIS_SELECTED,LVIS_SELECTED);
m_lstIncomingMessages.EnsureVisible(val,FALSE);
}
else
{
int Count= m_lstOutGoingMessages.GetItemCount();
CString strMsgId;
strMsgId.Format(_T("%d"),msg.nMsgType);
int val = m_lstOutGoingMessages.InsertItem(Count,strMsgId,NULL);
strMsgId = GetSystemTimeString();
m_lstOutGoingMessages.SetItemText(Count,1,m_pMessageManager->LocateMessageNameInList(m_pMessageManager->m_plstOutGoingMsg,msg.nMsgType));
m_lstOutGoingMessages.SetItemText(Count,2,strMsgId);
m_lstOutGoingMessages.EnsureVisible(val,FALSE);
}
}
LRESULT CMMINWSimulatorDlg::OnMessageSend(WPARAM wParam, LPARAM lParam)
{
m_OutGoingMsg = (MYQUEUE1*)lParam;
AMLOGINFO(_T("Message Send by simulator"));
AMLOGINFO(_T("Event Type is -> %d & Message id is -> %d"),m_OutGoingMsg->nEventType,m_OutGoingMsg->nMsgType);
DisplayMessageInList(*m_OutGoingMsg,FALSE);
RetDataPointerForInMessage((m_OutGoingMsg->nMsgType)-1);
//delete m_OutGoingMsg;
//display it in the list now or call up the DCML query for gettting the mesages
return(TRUE);
}
int CMMINWSimulatorDlg::GetRspMode(UINT32 MsgId)
{
CIncomingMsg *IncMsg;
if(m_pMessageManager->m_plstIncomingMsg && m_pMessageManager->m_plstIncomingMsg->GetCount())
{
for(POSITION pos = m_pMessageManager->m_plstIncomingMsg->GetHeadPosition();pos!=NULL;)
{
IncMsg = (CIncomingMsg *) m_pMessageManager->m_plstIncomingMsg->GetNext(pos);
if(IncMsg->GetMessageId() ==MsgId)
{
if(!IncMsg->GetResponseMode().CompareNoCase(_T("manual")))
{
return RSP_MANUAL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -