📄 respmodechg.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).
*
*****************************************************************************/
// RespModeChg.cpp : implementation file
//
#include "stdafx.h"
#include "QMMINWSimulator.h"
#include "RespModeChg.h"
#include "AsyncMessageSeq.h"
#include "AsyncSendMessage.h"
#include "Message.h"
#include "Format.h"
#include "NWGCMLHandler.h"
#include "IncomingMsg.h"
// CRespModeChg dialog
IMPLEMENT_DYNAMIC(CRespModeChg, CDialog)
CRespModeChg::CRespModeChg(CWnd* pParent /*=NULL*/)
: CDialog(CRespModeChg::IDD, pParent)
{
}
CRespModeChg::~CRespModeChg()
{
}
void CRespModeChg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_BUTTON_SAVECHANGE, SaveModeChange);
DDX_Control(pDX, IDC_STATIC_MODE_CHG_IND, static_mode_chg);
DDX_Control(pDX, IDC_BUTTON_CANCELCHANGES, close_button);
}
void CRespModeChg::SetTheLibraryIdentifier(HINSTANCE lib_id)
{
library_identifier = lib_id;
}
BOOL CRespModeChg::OnInitDialog()
{
CDialog::OnInitDialog();
/*ModeChangeTree.Create ( WS_CHILD | WS_VISIBLE | WS_BORDER | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES |TVS_CHECKBOXES,
CRect ( 38, 55, 500, 420 ), this, 100 ) ;*/
ModeChangeTree.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | TVS_HASBUTTONS |
TVS_LINESATROOT | TVS_HASLINES |TVS_CHECKBOXES | TVS_SHOWSELALWAYS | WS_TABSTOP,
CRect (25, 30, 350, 210), this, 101 ) ;
ModeChangeTree.ModifyStyle( TVS_CHECKBOXES, 0 );
ModeChangeTree.ModifyStyle( 0, TVS_CHECKBOXES );
//ModeChangeTree.ModifyStyle(0, TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_HASLINES );
HTREEITEM hRoot = ModeChangeTree.InsertItem(_T("Events"));
ModeChangeTree.SetItemData(hRoot, 0);
int iCount = 0;
CPtrList * p_lstAppLst= cmessagemanager.m_pAppList;
CString strXMLEvent;
if(p_lstAppLst->GetCount() > 0)//check if emtpy message list
{
for( POSITION pos = p_lstAppLst->GetHeadPosition(); pos != NULL;)
{
CApplication *pApplication = (CApplication *)p_lstAppLst->GetNext( pos ) ;
strXMLEvent = pApplication->GetApplicationName();
UINT32 AppId = pApplication->GetAppId();
char * buffer_for_appid;
/*the buffer being allocated memory below is used only for the purpose of itoa function and nothing else*/
buffer_for_appid = (char*)malloc(10);
buffer_for_appid = itoa(AppId,buffer_for_appid,10);
CPtrList *ptrAyncEventsList = GetAllIncMsgForApp(AppId);
HTREEITEM h1 =ModeChangeTree.InsertItem(CString(buffer_for_appid)+":"+strXMLEvent, hRoot);
ModeChangeTree.SetItemData(h1,1);
AddDataListInTree(ptrAyncEventsList,strXMLEvent,h1);
free(buffer_for_appid);
}
}
LoadString(library_identifier,IDS_STRING_SAVE, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
SaveModeChange.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_MODECHG_INDICATION, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
static_mode_chg.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_RES_MOD, stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
SetWindowText(stringID_to_string);
SaveModeChange.EnableWindow(0);
SetSaveFlag(0);
return 1;
}
CPtrList * CRespModeChg::GetAllIncMsgForApp(UINT32 AppId)
{
CPtrList* list_associated_msg =new CPtrList();
if(cmessagemanager.m_plstIncomingMsg->GetCount())
{
for(POSITION pos = cmessagemanager.m_plstIncomingMsg->GetHeadPosition();pos!=NULL;)
{
CIncomingMsg *IncMsg = (CIncomingMsg *) (cmessagemanager.m_plstIncomingMsg->GetNext(pos));
if(IncMsg->GetAppId()==AppId)
list_associated_msg->AddTail(IncMsg);
}
}
return list_associated_msg;
}
CPtrList* CRespModeChg::GetAllAsyncEventsForApp(CString strRecvd)
{
CPtrList *ptrList = new CPtrList();
CAsyncMessageSeq *pAsyncMessage;
CString strXMLEvent;
if(cmessagemanager.m_plstAsyncMsg->GetCount() > 0)//check if emtpy message list
{
for( POSITION pos = cmessagemanager.m_plstAsyncMsg->GetHeadPosition(); pos != NULL;)
{
pAsyncMessage = (CAsyncMessageSeq*)(cmessagemanager.m_plstAsyncMsg->GetNext( pos )) ;
strXMLEvent = pAsyncMessage->GetMessageName();
if(!strXMLEvent.CompareNoCase(strRecvd))
//add it into the Map
{
//now peek into the outgoing message list for this messagid
//and get the CMessage object to be done
//keep on adding into the Ptr List and return it
CList<UINT32, UINT32&>& messageList = pAsyncMessage->GetMessageList();
if(messageList.GetCount() > 0)
{
for( POSITION posResp = messageList.GetHeadPosition(); posResp != NULL; )
{
ptrList->AddTail(LocateMessageInList(cmessagemanager.m_plstOutGoingMsg,messageList.GetNext(posResp)));
}
}
if(ptrList->GetCount() <= 0)
AMLOGERROR(_T("Inside GetAllAsync Messages for App no found error"));
}
}
}
return ptrList;
}
void CRespModeChg::AddDataListInTree(CPtrList *ptrAyncEventsList,CString strRecvd,HTREEITEM htree)
{
int iCount1=0;
CFormat *pFormat;// = new CFormat();
CDataList dataList;
char * buffer_for_msgid;
CData dataObj;
for( POSITION pos = ptrAyncEventsList->GetHeadPosition(); pos != NULL;)
{
CMessage* pMessage = (CMessage*)(ptrAyncEventsList->GetNext( pos ));
pFormat = GetFormatForMessage(pMessage);
/*the buffer being allocated memory below is used only for the purpose of itoa function and nothing else*/
buffer_for_msgid = (char*)malloc(10);
buffer_for_msgid = itoa(pMessage->GetMessageId(),buffer_for_msgid,10);
HTREEITEM h3 = ModeChangeTree.InsertItem(CString (buffer_for_msgid) + ":" +pMessage->GetMessageName(), htree);
ModeChangeTree.SetItemData(h3,2);
if(!pMessage->GetResponseMode().CompareNoCase(_T("auto")))
{
ModeChangeTree.SetCheck(h3,1);
ModeChangeTree.SetParentalCheckState(h3,1);
}
}
}
CFormat* CRespModeChg::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;
}
CMessage* CRespModeChg::LocateMessageInList(CPtrList *msgList,UINT32 iMsgId)
{
//returns the CMessage Object for the iMsgId
CMessage *pMsg ;
if(msgList->GetCount())
{
for( POSITION pos = msgList->GetHeadPosition(); pos != NULL;)
{
pMsg = (CMessage*)(msgList->GetNext( pos )) ;
CString cs1= pMsg->GetPluginName();
if(pMsg->GetMessageId() == iMsgId)
return pMsg;
}
}
return NULL;
}
BEGIN_MESSAGE_MAP(CRespModeChg, CDialog)
ON_WM_WINDOWPOSCHANGING()
ON_BN_CLICKED(IDC_BUTTON_CANCELCHANGES, OnBnClickedButtonCancelchanges)
ON_BN_CLICKED(IDC_BUTTON_SAVECHANGE, OnBnClickedButtonSavechange)
ON_MESSAGE(WM_ENABLE_SAVE_BUTTON,EnableSaveButton)
ON_WM_CLOSE()
END_MESSAGE_MAP()
// CRespModeChg message handlers
void CRespModeChg::OnClose()
{
OnBnClickedButtonCancelchanges();
}
LRESULT CRespModeChg::EnableSaveButton(WPARAM wide, LPARAM log_val)
{
SaveModeChange.EnableWindow(1);
SetSaveFlag(1);
return 1;
}
void CRespModeChg::SetSaveFlag(BOOL flag_val)
{
save_flag = flag_val;
}
void CRespModeChg::OnBnClickedButtonCancelchanges()
{
if(save_flag)
{
int response = AfxMessageBox(IDS_STRING_WANT_TO_SAVE_CHANGES,MB_YESNOCANCEL);
if(response == IDYES)
{
if(IDYES == AfxMessageBox(IDS_STRING_RESP_MODE_SAVE_CONFIRM,MB_YESNO))
{
SaveTheResponseModeForMessages(ModeChangeTree.GetRootItem(),0);
}
OnOK();
}
else if(response == IDNO)
{
OnOK();
}
else
return;
}
else
OnOK();
// TODO: Add your control notification handler code here
}
void CRespModeChg::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.
CDialog::OnWindowPosChanging(lpwndpos);
}
}
void CRespModeChg::OnBnClickedButtonSavechange()
{
if(IDYES == AfxMessageBox(IDS_STRING_RESP_MODE_SAVE_CONFIRM,MB_YESNO))
{
//HCURSOR cursor_to_be_shown = GetCursor();
HCURSOR cursor_to_be_shown = LoadCursor(NULL,IDC_APPSTARTING);
SetCursor(cursor_to_be_shown);
SaveTheResponseModeForMessages(ModeChangeTree.GetRootItem(),0);
SetSaveFlag(0);
SaveModeChange.EnableWindow(0);
close_button.SetFocus();
cursor_to_be_shown = LoadCursor(NULL,IDC_ARROW);
SetCursor(cursor_to_be_shown);
//AfxMessageBox(IDS_STRING_RESP_MODE_SAVED);
}
}
void CRespModeChg::SaveTheResponseModeForMessages(HTREEITEM root,int node_level)
{
if(root!=NULL)
{
if(node_level ==2)
{
if(cmessagemanager.m_plstIncomingMsg)
{
if(cmessagemanager.m_plstIncomingMsg->GetCount())
{
for(POSITION pos = cmessagemanager.m_plstIncomingMsg->GetHeadPosition();pos!=NULL;)
{
CIncomingMsg * IncMsgPtr = (CIncomingMsg*) cmessagemanager.m_plstIncomingMsg->GetAt(pos);
CNWGCMLHandler gcmlHandler;
if(_ttoi(ModeChangeTree.GetItemText(root)) == IncMsgPtr->GetMessageId())
{
if(ModeChangeTree.GetCheck(root))
{
if(IncMsgPtr->GetResponseMode().CompareNoCase(CString("auto")))
{
IncMsgPtr->SetResponseMode(CString("auto"));
gcmlHandler.UpDateResponseModeInDom(*IncMsgPtr);
}
}
else
{ if(IncMsgPtr->GetResponseMode().CompareNoCase(CString("manual")))
{
IncMsgPtr->SetResponseMode(CString("manual"));
gcmlHandler.UpDateResponseModeInDom(*IncMsgPtr);
}
}
cmessagemanager.m_plstIncomingMsg->SetAt(pos,IncMsgPtr);
//cmessagemanager.m_plstIncomingMsg->AddTail(IncMsgPtr);
break;
}
cmessagemanager.m_plstIncomingMsg->GetNext(pos);
}
}
}
SaveTheResponseModeForMessages(ModeChangeTree.GetChildItem(root),node_level + 1);
SaveTheResponseModeForMessages(ModeChangeTree.GetNextSiblingItem(root),node_level);
}
else
{
SaveTheResponseModeForMessages(ModeChangeTree.GetChildItem(root),node_level + 1);
SaveTheResponseModeForMessages(ModeChangeTree.GetNextSiblingItem(root),node_level);
}
}
}
BOOL CRespModeChg::PreTranslateMessage(MSG * pMsg)
{
if(pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam == VK_RETURN)
{
if(GetFocus() == &SaveModeChange || GetFocus() == &close_button)
return(CDialog::PreTranslateMessage(pMsg));
else
return 1;
}
else if(pMsg->wParam == VK_ESCAPE)
{
OnBnClickedButtonCancelchanges();
}
else
return(CDialog::PreTranslateMessage(pMsg));
}
else
return(CDialog::PreTranslateMessage(pMsg));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -