// HttpDlg.cpp : implementation file
//

#include "stdafx.h"
#include "palmtool.h"
#include "HttpDlg.h"
#include "DirectoryDlg.h"
#include "p_strs.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#include "sdram.h"
#include "p_http.h"

static TCHAR szHFilter[] = _T("C Header files (*.h)|*.h|All files (*.*)|*.*||");
static TCHAR szHtmlFilter[] = _T("Html files (*.htm)|*.htm|All files (*.*)|*.*||");

#define WEB_OEM_NONE			0
#define WEB_OEM_HUAWEI3COM		1
#define WEB_OEM_NGTEL			2
#define WEB_OEM_DLINK			3
#define WEB_OEM_VIRTTEL			4
#define WEB_OEM_MAX				5

const char m_strOemType[WEB_OEM_MAX][32] = {"common", "huawei3com", "ngtel", "dlink", "virttel"};

#define WEB_LANGUAGE_BR			0
#define WEB_LANGUAGE_CN			1
#define WEB_LANGUAGE_CZ			2
#define WEB_LANGUAGE_DE			3
#define WEB_LANGUAGE_ES			4
#define WEB_LANGUAGE_ES_C		5
#define WEB_LANGUAGE_FR			6
#define WEB_LANGUAGE_IT			7
#define WEB_LANGUAGE_NL			8
#define WEB_LANGUAGE_PL			9
#define WEB_LANGUAGE_PT			10
#define WEB_LANGUAGE_US			11
#define WEB_LANGUAGE_MAX		12

const char m_strLanguageDisplay[WEB_LANGUAGE_MAX][32] = {"Brazil", "Chinese", "Czech", "Germany", "Spanish", "Catalonian(Spanish)", "France", "Italy", "Netherlands", "Poland", "Portugal", "United States"};
const char m_strLanguage[WEB_LANGUAGE_MAX][16] = {"br", "cn", "cz", "de", "es", "es_c", "fr", "it", "nl", "pl", "pt", "us"};

/////////////////////////////////////////////////////////////////////////////
// CHttpDlg dialog


CHttpDlg::CHttpDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CHttpDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CHttpDlg)
	m_iPageNum = 0;
	m_bReplaceTitle = FALSE;
	m_bHidePassword = FALSE;
	m_iWebType = -1;
	m_iWebLanguage = -1;
	m_strDstDir = _T("");
	//}}AFX_DATA_INIT
	m_strSettingsFile = _T("");
	m_iProtocol = PROTOCOL_H323;
}


void CHttpDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CHttpDlg)
	DDX_Control(pDX, IDC_COMBO_WEB_LANGUAGE, m_ctlWebLanguage);
	DDX_Control(pDX, IDC_COMBO_WEB_TYPE, m_ctlWebType);
	DDX_Text(pDX, IDC_EDIT_PAGENUM, m_iPageNum);
	DDX_Check(pDX, IDC_CHECK_REPLACE_TITLE, m_bReplaceTitle);
	DDX_Check(pDX, IDC_CHECK_HIDE_PASSWORD, m_bHidePassword);
	DDX_CBIndex(pDX, IDC_COMBO_WEB_TYPE, m_iWebType);
	DDX_CBIndex(pDX, IDC_COMBO_WEB_LANGUAGE, m_iWebLanguage);
	DDX_Text(pDX, IDC_EDIT_DST_DIR, m_strDstDir);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CHttpDlg, CDialog)
	//{{AFX_MSG_MAP(CHttpDlg)
	ON_BN_CLICKED(IDC_START_CONVERSION, OnStartConversion)
	ON_BN_CLICKED(IDC_BROWSE_SRCFILE, OnBrowseSrcfile)
	ON_BN_CLICKED(IDC_BUTTON_DST_DIR, OnButtonDstDir)
	ON_BN_CLICKED(IDC_BROWSE_SETTINGSFILE, OnBrowseSettingsfile)
	ON_BN_CLICKED(IDC_START_CONVERT_SETTINGS, OnStartConvertSettings)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHttpDlg helping functions

void CHttpDlg::SaveSettings()
{
	UpdateData();
	AfxGetApp()->WriteProfileInt(_T("GenHttp"), _T("WebType"), m_iWebType);
	AfxGetApp()->WriteProfileInt(_T("GenHttp"), _T("WebLanguage"), m_iWebLanguage);
	AfxGetApp()->WriteProfileInt(_T("GenHttp"), _T("ReplaceTitle"), (int)m_bReplaceTitle);
	AfxGetApp()->WriteProfileInt(_T("GenHttp"), _T("ReplaceTitle"), (int)m_bReplaceTitle);
	AfxGetApp()->WriteProfileInt(_T("GenHttp"), _T("HidePassword"), (int)m_bHidePassword);
	AfxGetApp()->WriteProfileInt(_T("GenHttp"), _T("PageNum"), m_iPageNum);	
	AfxGetApp()->WriteProfileString(_T("GenHttp"), _T("OutputDir"), m_strDstDir);
}

void CHttpDlg::TrimFile(CStdioFile & fileRead, CString & strOuput)
{
	CString strItem;

	strOuput = "";
	while (fileRead.ReadString(strItem))
	{
		strItem.TrimLeft();
		strOuput += strItem;
	}
}

BOOLEAN CHttpDlg::ConvertFile(CString strInput, CString & strOutput) 
{
	int iBeginPos, iEndPos, iStartIndex;
	int iPos1, iPos2, iType;
	CString strItem, strNew;

	iStartIndex = 0;
	strOutput = "";
	while (iStartIndex < strInput.GetLength())
	{
		iBeginPos = strInput.Find('<', iStartIndex);
		iEndPos = strInput.Find('>', iStartIndex);
		if (iBeginPos == -1 || iEndPos == -1)	break;
		if (iEndPos - iBeginPos < 6)	
		{
			iStartIndex = iEndPos + 1;
			continue;
		}
		
		strItem = strInput.Mid(iBeginPos, 6);
		if (strItem.CompareNoCase("<input") == 0)
		{
			strItem = strInput.Mid(iBeginPos, (iEndPos + 1 - iBeginPos));
			if (!GetItemType(strItem, iType))	return FALSE;
		}
		else 
		{
			strItem = strInput.Mid(iBeginPos, 7);
			if (strItem.CompareNoCase("<select") == 0)
			{
				strItem = strInput.Mid(iBeginPos, (iEndPos + 1 - iBeginPos));
				if (!GetItemType(strItem, iType))	return FALSE;
				iPos1 = strInput.Find("</select>", iStartIndex);
				iPos2 = strInput.Find("</SELECT>", iStartIndex);
				if (iPos1 == -1 && iPos2 == -1)
				{
					iStartIndex = iEndPos + 1;
					continue;
				}
				else if (iPos1 == -1)
				{
					iEndPos = iPos2 + 8;
				}
				else if (iPos2 == -1)
				{
					iEndPos = iPos1 + 8;
				}
				else
				{
					 if (iPos2 < iPos1)		iEndPos = iPos2 + 8;
					 else					iEndPos = iPos1 + 8;
				}
				strItem = strInput.Mid(iBeginPos, (iEndPos + 1 - iBeginPos));
			}
			else if (strItem.CompareNoCase("<title>") == 0 && m_bReplaceTitle)
			{
				iType = HTTP_TITLE;
				iPos1 = strInput.Find("</title>", iStartIndex);
				iPos2 = strInput.Find("</TITLE>", iStartIndex);
				if (iPos1 == -1 && iPos2 == -1)
				{
					iStartIndex = iEndPos + 1;
					continue;
				}
				else if (iPos1 == -1)
				{
					iEndPos = iPos2 + 7;
				}
				else if (iPos2 == -1)
				{
					iEndPos = iPos1 + 7;
				}
				else
				{
					 if (iPos2 < iPos1)		iEndPos = iPos2 + 7;
					 else					iEndPos = iPos1 + 7;
				}
				strItem = strInput.Mid(iBeginPos, (iEndPos + 1 - iBeginPos));
			}
			else
			{
				iStartIndex = iEndPos + 1;
				continue;
			}
		}
		strOutput += strInput.Left(iBeginPos);
		if (iType == -1)	strNew = strItem;
		else strNew = UpdateInput(iType, strOutput.GetLength());			
		strOutput += strNew;
		strInput = strInput.Right(strInput.GetLength() - iEndPos - 1);
		iStartIndex = 0;
	}

	strOutput += strInput;
	return TRUE;
}

void CHttpDlg::WriteCommonHeader(CStdioFile & fileWrite, CString strName, int iLength)
{
	CString strWrite, strTemp, strUpperName;
	int iBlockNum;

	if (iLength % 256 == 0)		iBlockNum = iLength / 256;
	else						iBlockNum = (iLength / 256) + 1;

	strUpperName = strName;
	strUpperName.MakeUpper();
	strWrite = "#define ";
	strWrite += strUpperName;
	strTemp.Format("_BLOCK_NUM\t%d\n", iBlockNum);
	strWrite += strTemp;
	strWrite += "#define ";
	strWrite += strUpperName;
	strTemp.Format("_MSG_LEN\t\t%d\n", iLength);
	strWrite += strTemp;

	fileWrite.WriteString(strWrite);
}

void CHttpDlg::WriteMsgFile(CStdioFile & fileWrite, CString strName, CString strInput)
{
	CString strWrite, strItem, strUpperName;
	int i, iLength;

	iLength = strInput.GetLength();

	WriteCommonHeader(fileWrite, strName, iLength);

	strUpperName = strName;
	strUpperName.MakeUpper();

	strWrite = "static CCHAR _c" + strName + "_msg[";
	strWrite += strUpperName + "_MSG_LEN]=\n{\n";

	for (i = 0; i < iLength; i ++)
	{
		if (i != 0 && (i % 16) == 0) 
		{
			strWrite += "\n";
		}
		strItem.Format("0x%02x", (unsigned char)strInput[i]);
		strWrite += strItem;

		if (i < (iLength - 1))
		{
			strWrite += ", ";
		}
	}
	strWrite += "\n};\n\n";

	fileWrite.WriteString(strWrite);
}


void CHttpDlg::WrtieInfoFile(CStdioFile & fileWrite, CString strName, CString strInput)
{
	CString strWrite, strItem, strTemp, strUpperName;
	int i, iPos, iLength;

	iLength = strInput.GetLength();
	WriteCommonHeader(fileWrite, strName, iLength);

	strUpperName = strName;
	strUpperName.MakeUpper();

	strWrite = "#define " + strUpperName + "_OPTION_NUM";
	strItem.Format("\t%d\n", m_iInfoNum);
	strWrite += strItem;
	if (m_iInfoNum == 0)	
	{
		fileWrite.WriteString(strWrite);
		return;
	}

	strWrite += "CCHAR _c" + strName + "_info[";
	strWrite += strUpperName;
	strWrite += "_OPTION_NUM][HTTP_INFO_NUM]= \n{\n";
	for (i = 0; i < m_iInfoNum; i ++)
	{
		iPos = i * HTTP_INFO_NUM;
		strItem.Format("{%3d, %3d, %3d, %3d, %3d}", m_pInfo[iPos+HTTP_INFO_TYPE], 
													m_pInfo[iPos+HTTP_INFO_BLOCK], 
													m_pInfo[iPos+HTTP_INFO_MAXLEN], 
													m_pInfo[iPos+HTTP_INFO_BEGINPOS], 
													m_pInfo[iPos+HTTP_INFO_LEFTLEN]);
		if (i < (m_iInfoNum-1))
		{
			strItem += ",\n";
		}
		strWrite += strItem;
	}
	strWrite += "\n};\n\n";

	fileWrite.WriteString(strWrite);
}

BOOLEAN CHttpDlg::GetItemType(CString strItem, int & iType)
{
	int i, iPos, iChar;
	CString strName;

	iPos = strItem.Find("name=");
	if (iPos == -1)	
	{
		iPos = strItem.Find("NAME=");
		if (iPos == -1) 
		{
			iType = -1;
			return TRUE;
		}
	}
	
	iPos += 5;
	iChar = strItem.GetAt(iPos);
	strName = "";
	for (i = iPos; i < strItem.GetLength(); i ++)
	{
		iChar = strItem.GetAt(i);
		if (iChar == '>' || iChar == ' ')
			break;
#if _MSC_VER >= 1300
		char c[2];
		itoa(iChar,c,2);
		strName += c;
#else
		strName += iChar;
#endif
	}
	
	if (strName.GetLength() == 0)	
	{
		iType = -1;
		return FALSE;
	}

	iPos = strName.GetLength() - 1;
	if (strName.GetAt(0) == '"' && strName.GetAt(iPos) == '"')
		strName = strName.Mid(1, iPos - 1);

	if (strName.GetLength() == 4)	
	{
		iPos = atoi(strName.Mid(1, 3));
		if (iPos)
		{
			 if (strName.GetAt(0) == 'n')
			 {
				 m_iSpeedDialIndex = iPos;
				 iType = HTTP_SPEEDDIAL_NAME;
				 return TRUE;
			 }
			 else if (strName.GetAt(0) == 'p')
			 {
				 m_iSpeedDialIndex = iPos;
				 iType = HTTP_SPEEDDIAL_PHONE;
				 return TRUE;
			 }
		}
	}

	if (strName == "ip")				iType = HTTP_IP_ADDR;
	else if (strName == "service")		iType = HTTP_USE_GK;
	else if (strName == "ringtype")		iType = HTTP_RING_TYPE;
	else if (strName == "phonenumber")	iType = HTTP_PHONE_NUMBER;
	else if (strName == "subnetmask")	iType = HTTP_SUBNET_MASK;
	else if (strName == "router")		iType = HTTP_ROUTER_ADDR;
	else if (strName == "handsetin")	iType = HTTP_HANDSET_INPUT;
	else if (strName == "handsetout")	iType = HTTP_HANDSET_OUTPUT;
	else if (strName == "agc")			iType = HTTP_USE_AGC;
	else if (strName == "dns")			iType = HTTP_DNS_ADDR;
	else if (strName == "dns2")			iType = HTTP_DNS_ADDR2;
	else if (strName == "answer")		iType = HTTP_RING_NUMBER;
	else if (strName == "localtype")	iType = HTTP_LOCAL_ALIAS;
	else if (strName == "speakerout")	iType = HTTP_HANDFREE_OUTPUT;
	else if (strName == "audioframes")	iType = HTTP_AUDIO_FRAMES;
	else if (strName == "q931port")		iType = HTTP_Q931_PORT;
	else if (strName == "vad")			iType = HTTP_USE_VAD;
	else if (strName == "6.3k")			iType = HTTP_USE_HIGH_RATE;
	else if (strName == "speakerin")	iType = HTTP_HANDFREE_INPUT;
	else if (strName == "nattraversal")	iType = HTTP_NAT_TRAVERSAL;
	else if (strName == "nataddr")		iType = HTTP_NAT_DNS;
	else if (strName == "faststart")	iType = HTTP_FAST_START;
	else if (strName == "prack")		iType = HTTP_SIP_PRACK;
	else if (strName == "dtmf")			iType = HTTP_DTMF_TYPE;
	else if (strName == "password")		iType = HTTP_PASSWORD;
	else if (strName == "iddcode")		iType = HTTP_COUNTRY_CODE;
	else if (strName == "iddprefix")	iType = HTTP_INTL_PREFIX;
	else if (strName == "dialplan")		iType = HTTP_USE_DIALPLAN;
	else if (strName == "dddcode")		iType = HTTP_AREA_CODE;
	else if (strName == "dddprefix")	iType = HTTP_LONG_PREFIX;
	else if (strName == "innerline")	iType = HTTP_INNER_LINE;
	else if (strName == "dualmode")		iType = HTTP_DUAL_MODE;
	else if (strName == "dualmodeprefix")	iType = HTTP_DUALMODE_PREFIX;
	else if (strName == "innerlineprefix")	iType = HTTP_INNERLINE_PREFIX;
	else if (strName == "servicetype")		iType = HTTP_SERVICE_TYPE;
	else if (strName == "account")		iType = HTTP_ACCOUNT;
	else if (strName == "pin")			iType = HTTP_PIN;
	else if (strName == "remotealias")	iType = HTTP_REMOTE_ALIAS;
	else if (strName == "pppid")		iType = HTTP_PPP_ID;
	else if (strName == "ppppin")		iType = HTTP_PPP_PASSWORD;
	else if (strName == "serviceid")	iType = HTTP_GKID;
	else if (strName == "registerport")	iType = HTTP_RAS_PORT;
	else if (strName == "h245port")		iType = HTTP_H245_PORT;
	else if (strName == "rtpport")		iType = HTTP_RTP_PORT;
	else if (strName == "aec")			iType = HTTP_USE_AEC;
	else if (strName == "firmware")		iType = HTTP_FIRMWARE;
	else if (strName == "debug")		iType = HTTP_OUTPUT_DEBUG;
	else if (strName == "digitmap")		iType = HTTP_USE_DIGITMAP;
	else if (strName == "superpassword")	iType = HTTP_SUPER_PASSWORD;
	else if (strName == "dialnumber")	iType = HTTP_DIAL_NUMBER;
	else if (strName == "serviceaddr")	iType = HTTP_SERVICE_DNS;
	else if (strName == "upgradeaddr")	iType = HTTP_UPGRADE_ADDR;
	else if (strName == "mac")			iType = HTTP_MAC_ADDR;
	else if (strName == "fwdalways")	iType = HTTP_FWD_ALWAYS;
	else if (strName == "fwdbusy")		iType = HTTP_FWD_BUSY;
	else if (strName == "fwdnoanswer")	iType = HTTP_FWD_NOANSWER;
	else if (strName == "fwdpoweroff")	iType = HTTP_FWD_POWEROFF;
	else if (strName == "fwdnumber")	iType = HTTP_FORWARD_NUMBER;
	else if (strName == "iptype")		iType = HTTP_IP_TYPE;
	else if (strName == "tos")			iType = HTTP_RTP_TOS;
	else if (strName == "sntpip")		iType = HTTP_NTS_ADDR;
	else if (strName == "timezone")		iType = HTTP_TIME_ZONE;
	else if (strName == "daylight")		iType = HTTP_DAYLIGHT;
	else if (strName == "registerttl")	iType = HTTP_REGISTER_TTL;
	else if (strName == "natttl")		iType = HTTP_NAT_TTL;
	else if (strName == "callwaiting")	iType = HTTP_CALL_WAITING;
	else if (strName == "jittersize")	iType = HTTP_JITTER_SIZE;
	else if (strName == "dtmfpayload")	iType = HTTP_DTMF_PTYPE;
	else if (strName == "codec1")		iType = HTTP_CODEC_TYPE1;
	else if (strName == "codec2")		iType = HTTP_CODEC_TYPE2;
	else if (strName == "codec3")		iType = HTTP_CODEC_TYPE3;
	else if (strName == "codec4")		iType = HTTP_CODEC_TYPE4;
	else if (strName == "codec5")		iType = HTTP_CODEC_TYPE5;
	else if (strName == "codec6")		iType = HTTP_CODEC_TYPE6;
	else if (strName == "upgradetype")	iType = HTTP_UPGRADE_TYPE;
	else if (strName == "ilbcpayload")	iType = HTTP_ILBC_PTYPE;
	else if (strName == "remotedialplan")		iType = HTTP_REMOTE_DIALPLAN;
	else if (strName == "vlan")			iType = HTTP_VLAN_ENABLE;
	else if (strName == "vlanid")		iType = HTTP_VLAN_ID;
	else		iType = -1;
	return TRUE;
}

void CHttpDlg::GetInfo(int iType, int iPos, int iMaxLen)
{
	int iBeginPos, iBlockNum, iLeftLen;
	int * pCur;

	pCur = m_pInfo + m_iInfoNum * HTTP_INFO_NUM;
	
	iBlockNum = iPos / 256;
	iBeginPos = iPos - iBlockNum * 256;
	
	iLeftLen = 0;
	if ((iBeginPos + iMaxLen) >= 256)
	{
		iLeftLen = iBeginPos + iMaxLen - 256;
	}

	pCur[HTTP_INFO_TYPE] = iType; 
	pCur[HTTP_INFO_BLOCK] = iBlockNum;
	pCur[HTTP_INFO_MAXLEN] = iMaxLen;
	pCur[HTTP_INFO_BEGINPOS] = iBeginPos;
	pCur[HTTP_INFO_LEFTLEN] = iLeftLen;
	m_iInfoNum ++;
}

CString CHttpDlg::WriteStrInfo(int iType, CString strNew, int iPos, int iMaxLen, int iDisplayLen, unsigned char *p)
{
	char strNum[4];
	int iLen, i;

	for(i = 0; i < iMaxLen-1; i++)
	{
		itoa((i+1), strNum, 10);
		strNew = strNew + "        >" + (p + i*iDisplayLen) + "</OPTION><OPTION value=" + strNum + " ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);
	}
	strNew = strNew + "        >" + (p + i*iDisplayLen) + "</OPTION></SELECT>";

	return strNew;
}

CString CHttpDlg::UpdateInput(int iType,  int iBeginPos)
{
	CString strNew, strTemp;
	int iPos, iLen;

	strNew = "";
	iPos = iBeginPos;
	switch(iType)
	{
	case HTTP_IP_ADDR:
		strNew = "<INPUT name=ip value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 15);
		strNew += "255.255.255.255 size=16 maxlength=15>";
		break;
	case HTTP_USE_GK:
		strNew = "<INPUT name=service ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		if (m_iWebType == WEB_OEM_HUAWEI3COM)
		{
			switch(m_iProtocol)
			{
			case PROTOCOL_SIP:
				strNew += "CHECKED onClick=service_value() type=checkbox>";
				break;

			default:
				strNew += "CHECKED type=checkbox>";
				break;
			}
		}
		else
		{
			strNew += "CHECKED type=checkbox>";
		}
		break;
	case HTTP_VLAN_ENABLE:
		strNew = "<INPUT name=vlan ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_VLAN_ID:
		strNew = "<INPUT name=vlanid value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 5);
		strNew += "xxxxx size=5 maxlength=5>";
		break;
	case HTTP_RING_TYPE:
		strNew = "<SELECT name=ringtype size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);
		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CN:
		case WEB_LANGUAGE_US:
		case WEB_LANGUAGE_DE:
		case WEB_LANGUAGE_FR:
		case WEB_LANGUAGE_IT:
		case WEB_LANGUAGE_NL:
		case WEB_LANGUAGE_ES:
		case WEB_LANGUAGE_ES_C:
		case WEB_LANGUAGE_PT:
		case WEB_LANGUAGE_BR:
			strNew = WriteStrInfo(iType, strNew, iPos, RING_TYPE_MAX, RING_TYPE_DISPLAY_LEN, g_cRingTypeDisplay[0]);
			break;

		case WEB_LANGUAGE_PL:
			strNew = WriteStrInfo(iType, strNew, iPos, RING_TYPE_MAX, PL_RING_TYPE_DISPLAY_LEN, g_cRingTypeDisplay_PL[0]);
			break;

		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, RING_TYPE_MAX, CZ_RING_TYPE_DISPLAY_LEN, g_cRingTypeDisplay_CZ[0]);
			break;
		}
		break;
	case HTTP_IP_TYPE:
		if ((m_iWebType == WEB_OEM_HUAWEI3COM) || (m_iWebType == WEB_OEM_VIRTTEL))
		{
			strNew = "<SELECT name=iptype onChange=change_value() size=1><OPTION value=0 ";
		}
		else
		{
			strNew = "<SELECT name=iptype onChange=selchange_iptype() size=1><OPTION value=0 ";
		}
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);

		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CN:
			strNew = WriteStrInfo(iType, strNew, iPos, IP_TYPE_MAX, IPTYPE_DISPLAY_LEN, g_cIpTypeDisplay_GB[0]);
			break;

		case WEB_LANGUAGE_US:
		case WEB_LANGUAGE_DE:
		case WEB_LANGUAGE_FR:
		case WEB_LANGUAGE_IT:
		case WEB_LANGUAGE_NL:
		case WEB_LANGUAGE_ES:
		case WEB_LANGUAGE_ES_C:
		case WEB_LANGUAGE_PT:
		case WEB_LANGUAGE_BR:
			strNew = WriteStrInfo(iType, strNew, iPos, IP_TYPE_MAX, IPTYPE_DISPLAY_LEN, g_cIpTypeDisplay[0]);
			break;

		case WEB_LANGUAGE_PL:
			strNew = WriteStrInfo(iType, strNew, iPos, IP_TYPE_MAX, PL_IPTYPE_DISPLAY_LEN, g_cIpTypeDisplay_PL[0]);
			break;

		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, IP_TYPE_MAX, CZ_IPTYPE_DISPLAY_LEN, g_cIpTypeDisplay_CZ[0]);
			break;
		}
		break;
	case HTTP_PHONE_NUMBER:
		strNew = "<INPUT name=phonenumber value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 17);
		strNew += "\"xxxxxxxxxxxxxxxx\" size=16 maxlength=16>";
		break;
	case HTTP_SUBNET_MASK:
		strNew = "<INPUT name=subnetmask value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 15);
		strNew += "255.255.255.255 size=16 maxlength=15>";
		break;
	case HTTP_ROUTER_ADDR:
		strNew = "<INPUT name=router value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 15);
		strNew += "255.255.255.255 size=16 maxlength=15>";
		break;
	case HTTP_HANDSET_INPUT:
		strNew = "<INPUT name=handsetin value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 2);
		strNew += "xx size=5 maxlength=2>";
		break;
	case HTTP_HANDSET_OUTPUT:
		strNew = "<INPUT name=handsetout value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 2);
		strNew += "xx size=5 maxlength=2>";
		break;
	case HTTP_USE_AGC:
		strNew = "<INPUT name=agc ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_DNS_ADDR:
		strNew = "<INPUT name=dns value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 15);
		strNew += "255.255.255.255 size=16 maxlength=15>";
		break;
	case HTTP_DNS_ADDR2:
		strNew = "<INPUT name=dns2 value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 15);
		strNew += "255.255.255.255 size=16 maxlength=15>";
		break;
	case HTTP_RING_NUMBER:
		strNew = "<INPUT name=answer value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 2);
		strNew += "xx size=5 maxlength=2>";
		break;
	case HTTP_LOCAL_ALIAS:
		strNew = "<SELECT name=localtype size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);

		switch(m_iProtocol)
		{
		case PROTOCOL_H323:
			switch(m_iWebLanguage)
			{
			case WEB_LANGUAGE_CN:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_LOCAL_TYPE_MAX, H323_LOCALALIAS_GB_DISPLAY_LEN, g_cH323LocalTypeDisplay_GB[0]);
				break;

			case WEB_LANGUAGE_US:
			case WEB_LANGUAGE_DE:
			case WEB_LANGUAGE_FR:
			case WEB_LANGUAGE_IT:
			case WEB_LANGUAGE_NL:
			case WEB_LANGUAGE_ES:
			case WEB_LANGUAGE_ES_C:
			case WEB_LANGUAGE_PT:
			case WEB_LANGUAGE_BR:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_LOCAL_TYPE_MAX, H323_LOCALALIAS_DISPLAY_LEN, g_cH323LocalTypeDisplay[0]);
				break;

			case WEB_LANGUAGE_PL:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_LOCAL_TYPE_MAX, PL_H323_LOCALALIAS_DISPLAY_LEN, g_cH323LocalTypeDisplay_PL[0]);
				break;

			case WEB_LANGUAGE_CZ:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_LOCAL_TYPE_MAX, CZ_H323_LOCALALIAS_DISPLAY_LEN, g_cH323LocalTypeDisplay_CZ[0]);
				break;
			}
			break;

		case PROTOCOL_MGCP:
			switch(m_iWebLanguage)
			{
			case WEB_LANGUAGE_CN:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_LOCAL_TYPE_MAX, MGCP_LOCALALIAS_GB_DISPLAY_LEN, g_cMgcpLocalTypeDisplay_GB[0]);
				break;

			case WEB_LANGUAGE_US:
			case WEB_LANGUAGE_DE:
			case WEB_LANGUAGE_FR:
			case WEB_LANGUAGE_IT:
			case WEB_LANGUAGE_NL:
			case WEB_LANGUAGE_ES:
			case WEB_LANGUAGE_ES_C:
			case WEB_LANGUAGE_PT:
			case WEB_LANGUAGE_BR:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_LOCAL_TYPE_MAX, MGCP_LOCALALIAS_DISPLAY_LEN, g_cMgcpLocalTypeDisplay[0]);
				break;

			case WEB_LANGUAGE_PL:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_LOCAL_TYPE_MAX, PL_MGCP_LOCALALIAS_DISPLAY_LEN, g_cMgcpLocalTypeDisplay_PL[0]);
				break;

			case WEB_LANGUAGE_CZ:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_LOCAL_TYPE_MAX, CZ_MGCP_LOCALALIAS_DISPLAY_LEN, g_cMgcpLocalTypeDisplay_CZ[0]);
				break;
			}
			break;
		}
		break;

	case HTTP_HANDFREE_INPUT:
		strNew = "<INPUT name=speakerin value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 2);
		strNew += "xx size=5 maxlength=2>";
		break;

	case HTTP_HANDFREE_OUTPUT:
		strNew = "<INPUT name=speakerout value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 2);
		strNew += "xx size=5 maxlength=2>";
		break;
	case HTTP_CODEC_TYPE1:
		strNew = "<SELECT name=codec1 size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);
		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, CZ_AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay_CZ[0]);
			break;

		default:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay[0]);
			break;
		}
		break;
	case HTTP_CODEC_TYPE2:
		strNew = "<SELECT name=codec2 size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);
		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, CZ_AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay_CZ[0]);
			break;

		default:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay[0]);
			break;
		}
		break;
	case HTTP_CODEC_TYPE3:
		strNew = "<SELECT name=codec3 size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);
		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, CZ_AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay_CZ[0]);
			break;

		default:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay[0]);
			break;
		}
		break;
	case HTTP_CODEC_TYPE4:
		strNew = "<SELECT name=codec4 size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);
		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, CZ_AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay_CZ[0]);
			break;

		default:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay[0]);
			break;
		}
		break;
	case HTTP_CODEC_TYPE5:
		strNew = "<SELECT name=codec5 size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);
		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, CZ_AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay_CZ[0]);
			break;

		default:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay[0]);
			break;
		}
		break;
	case HTTP_CODEC_TYPE6:
		strNew = "<SELECT name=codec6 size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);
		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, CZ_AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay_CZ[0]);
			break;

		default:
			strNew = WriteStrInfo(iType, strNew, iPos, CODEC_MAX, AUDIO_TYPE_DISPLAY_LEN, g_cAudioTypeDisplay[0]);
			break;
		}
		break;
	case HTTP_AUDIO_FRAMES:
		strNew = "<INPUT name=audioframes value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 2);
		strNew += "xx size=5 maxlength=2>";
		break;
	case HTTP_Q931_PORT:
		strNew = "<INPUT name=q931port value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 5);
		strNew += "xxxxx size=5 maxlength=5>";
		break;
	case HTTP_USE_VAD:
		strNew = "<INPUT name=vad ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_USE_HIGH_RATE:
		strNew = "<INPUT name=6.3k ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_NAT_TRAVERSAL:
		strNew = "<SELECT name=nattraversal size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);

		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CN:
			switch(m_iProtocol)
			{
			case PROTOCOL_H323:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_NAT_TRAVERSAL_MAX, H323_NAT_TRAVERSAL_GB_DISPLAY_LEN, g_cH323NatTraversalDisplay_GB[0]);
				break;
			case PROTOCOL_SIP:
				strNew = WriteStrInfo(iType, strNew, iPos, SIP_NAT_TRAVERSAL_MAX, SIP_NAT_TRAVERSAL_GB_DISPLAY_LEN, g_cSipNatTraversalDisplay_GB[0]);
				break;
			case PROTOCOL_MGCP:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_NAT_TRAVERSAL_MAX, MGCP_NAT_TRAVERSAL_GB_DISPLAY_LEN, g_cMgcpNatTraversalDisplay_GB[0]);
				break;
			}
			break;

		case WEB_LANGUAGE_US:
		case WEB_LANGUAGE_DE:
		case WEB_LANGUAGE_FR:
		case WEB_LANGUAGE_IT:
		case WEB_LANGUAGE_NL:
		case WEB_LANGUAGE_ES:
		case WEB_LANGUAGE_ES_C:
		case WEB_LANGUAGE_PT:
		case WEB_LANGUAGE_BR:
			switch(m_iProtocol)
			{
			case PROTOCOL_H323:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_NAT_TRAVERSAL_MAX, H323_NAT_TRAVERSAL_DISPLAY_LEN, g_cH323NatTraversalDisplay[0]);
				break;
			case PROTOCOL_SIP:
				strNew = WriteStrInfo(iType, strNew, iPos, SIP_NAT_TRAVERSAL_MAX, SIP_NAT_TRAVERSAL_DISPLAY_LEN, g_cSipNatTraversalDisplay[0]);
				break;
			case PROTOCOL_MGCP:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_NAT_TRAVERSAL_MAX, MGCP_NAT_TRAVERSAL_DISPLAY_LEN, g_cMgcpNatTraversalDisplay[0]);
				break;
			}
			break;

		case WEB_LANGUAGE_PL:
			switch(m_iProtocol)
			{
			case PROTOCOL_H323:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_NAT_TRAVERSAL_MAX, PL_H323_NAT_TRAVERSAL_DISPLAY_LEN, g_cH323NatTraversalDisplay_PL[0]);
				break;
			case PROTOCOL_SIP:
				strNew = WriteStrInfo(iType, strNew, iPos, SIP_NAT_TRAVERSAL_MAX, PL_SIP_NAT_TRAVERSAL_DISPLAY_LEN, g_cSipNatTraversalDisplay_PL[0]);
				break;
			case PROTOCOL_MGCP:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_NAT_TRAVERSAL_MAX, PL_MGCP_NAT_TRAVERSAL_DISPLAY_LEN, g_cMgcpNatTraversalDisplay_PL[0]);
				break;
			}
			break;

		case WEB_LANGUAGE_CZ:
			switch(m_iProtocol)
			{
			case PROTOCOL_H323:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_NAT_TRAVERSAL_MAX, CZ_H323_NAT_TRAVERSAL_DISPLAY_LEN, g_cH323NatTraversalDisplay_CZ[0]);
				break;
			case PROTOCOL_SIP:
				strNew = WriteStrInfo(iType, strNew, iPos, SIP_NAT_TRAVERSAL_MAX, CZ_SIP_NAT_TRAVERSAL_DISPLAY_LEN, g_cSipNatTraversalDisplay_CZ[0]);
				break;
			case PROTOCOL_MGCP:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_NAT_TRAVERSAL_MAX, CZ_MGCP_NAT_TRAVERSAL_DISPLAY_LEN, g_cMgcpNatTraversalDisplay_CZ[0]);
				break;
			}
			break;
		}
		break;
	case HTTP_NAT_DNS:
		strNew = "<INPUT name=nataddr value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 33);
		strNew += "\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" size=24 maxlength=32>";
		break;
	case HTTP_FAST_START:	//sip
		strNew = "<INPUT name=outboundproxy ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_SIP_PRACK:
		strNew = "<INPUT name=prack ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_REMOTE_DIALPLAN:
		strNew = "<INPUT name=remotedialplan ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_DTMF_TYPE:
		strNew = "<SELECT name=dtmf size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);
		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CN:
		case WEB_LANGUAGE_US:
		case WEB_LANGUAGE_DE:
		case WEB_LANGUAGE_FR:
		case WEB_LANGUAGE_IT:
		case WEB_LANGUAGE_NL:
		case WEB_LANGUAGE_ES:
		case WEB_LANGUAGE_ES_C:
		case WEB_LANGUAGE_PT:
		case WEB_LANGUAGE_BR:
			switch(m_iProtocol)
			{
			case PROTOCOL_H323:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_DTMF_TYPE_MAX, H323_DTMF_DISPLAY_LEN, g_cH323DtmfDisplay[0]);
				break;

			case PROTOCOL_SIP:
				strNew = WriteStrInfo(iType, strNew, iPos, SIP_DTMF_TYPE_MAX, SIP_DTMF_DISPLAY_LEN, g_cSipDtmfDisplay[0]);
				break;

			case PROTOCOL_MGCP:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_DTMF_TYPE_MAX, MGCP_DTMF_DISPLAY_LEN, g_cMgcpDtmfDisplay[0]);
				break;

			case PROTOCOL_N2P:
				strNew = WriteStrInfo(iType, strNew, iPos, N2P_DTMF_TYPE_MAX, N2P_DTMF_DISPLAY_LEN, g_cN2pDtmfDisplay[0]);
				break;

			default:
				strNew = WriteStrInfo(iType, strNew, iPos, DTMF_TYPE_MAX, DTMF_DISPLAY_LEN, g_cDtmfDisplay[0]);
				break;
			}
			break;
		case WEB_LANGUAGE_PL:
			switch(m_iProtocol)
			{
			case PROTOCOL_H323:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_DTMF_TYPE_MAX, PL_H323_DTMF_DISPLAY_LEN, g_cH323DtmfDisplay_PL[0]);
				break;

			case PROTOCOL_SIP:
				strNew = WriteStrInfo(iType, strNew, iPos, SIP_DTMF_TYPE_MAX, PL_SIP_DTMF_DISPLAY_LEN, g_cSipDtmfDisplay_PL[0]);
				break;

			case PROTOCOL_MGCP:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_DTMF_TYPE_MAX, PL_MGCP_DTMF_DISPLAY_LEN, g_cMgcpDtmfDisplay_PL[0]);
				break;

			case PROTOCOL_N2P:
				strNew = WriteStrInfo(iType, strNew, iPos, N2P_DTMF_TYPE_MAX, PL_N2P_DTMF_DISPLAY_LEN, g_cN2pDtmfDisplay_PL[0]);
				break;

			default:
				strNew = WriteStrInfo(iType, strNew, iPos, DTMF_TYPE_MAX, PL_DTMF_DISPLAY_LEN, g_cDtmfDisplay_PL[0]);
				break;
			}
			break;

		case WEB_LANGUAGE_CZ:
			switch(m_iProtocol)
			{
			case PROTOCOL_H323:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_DTMF_TYPE_MAX, CZ_H323_DTMF_DISPLAY_LEN, g_cH323DtmfDisplay_CZ[0]);
				break;

			case PROTOCOL_SIP:
				strNew = WriteStrInfo(iType, strNew, iPos, SIP_DTMF_TYPE_MAX, CZ_SIP_DTMF_DISPLAY_LEN, g_cSipDtmfDisplay_CZ[0]);
				break;

			case PROTOCOL_MGCP:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_DTMF_TYPE_MAX, CZ_MGCP_DTMF_DISPLAY_LEN, g_cMgcpDtmfDisplay_CZ[0]);
				break;

			case PROTOCOL_N2P:
				strNew = WriteStrInfo(iType, strNew, iPos, N2P_DTMF_TYPE_MAX, CZ_N2P_DTMF_DISPLAY_LEN, g_cN2pDtmfDisplay_CZ[0]);
				break;

			default:
				strNew = WriteStrInfo(iType, strNew, iPos, DTMF_TYPE_MAX, CZ_DTMF_DISPLAY_LEN, g_cDtmfDisplay_CZ[0]);
				break;
			}
			break;
		}
		break;
	case HTTP_PASSWORD:
		if (m_bHidePassword)
		{
			strNew = "<INPUT name=password type=password value=";
		}
		else
		{
			strNew = "<INPUT name=password value=";
		}
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 17);
		strNew += "\"xxxxxxxxxxxxxxxx\" size=16 maxlength=16>";
		break;
	case HTTP_COUNTRY_CODE:
		strNew = "<INPUT name=iddcode value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 5);
		strNew += "\"xxxx\" size=5 maxlength=4>";
		break;
	case HTTP_INTL_PREFIX:
		strNew = "<INPUT name=iddprefix value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 5);
		strNew += "\"xxxx\" size=5 maxlength=4>";
		break;
	case HTTP_USE_DIALPLAN:
		strNew = "<SELECT name=dialplan size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);

		switch (m_iWebLanguage)
		{
		case WEB_LANGUAGE_CN:
			strNew = WriteStrInfo(iType, strNew, iPos, DIALPLAN_MAX, DIALPLAN_DISPLAY_LEN, g_cDialplanDisplay_GB[0]);
			break;
		
		case WEB_LANGUAGE_US:
		case WEB_LANGUAGE_DE:
		case WEB_LANGUAGE_FR:
		case WEB_LANGUAGE_IT:
		case WEB_LANGUAGE_NL:
		case WEB_LANGUAGE_ES:
		case WEB_LANGUAGE_ES_C:
		case WEB_LANGUAGE_PT:
		case WEB_LANGUAGE_BR:
			strNew = WriteStrInfo(iType, strNew, iPos, DIALPLAN_MAX, DIALPLAN_DISPLAY_LEN, g_cDialplanDisplay[0]);
			break;

		case WEB_LANGUAGE_PL:
			strNew = WriteStrInfo(iType, strNew, iPos, DIALPLAN_MAX, PL_DIALPLAN_DISPLAY_LEN, g_cDialplanDisplay_PL[0]);
			break;

		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, DIALPLAN_MAX, CZ_DIALPLAN_DISPLAY_LEN, g_cDialplanDisplay_CZ[0]);
			break;
		}
		break;
	case HTTP_AREA_CODE:
		strNew = "<INPUT name=dddcode value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 5);
		strNew += "\"xxxx\" size=5 maxlength=4>";
		break;
	case HTTP_LONG_PREFIX:
		strNew = "<INPUT name=dddprefix value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 4);
		strNew += "\"xxx\" size=5 maxlength=3>";
		break;
	case HTTP_INNER_LINE:
		strNew = "<SELECT name=innerline size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);

		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CN:
			strNew = WriteStrInfo(iType, strNew, iPos, INNER_LINE_MAX, INNERLINE_DISPLAY_LEN, g_cInnerLineDisplay_GB[0]);
			break;

		case WEB_LANGUAGE_US:
		case WEB_LANGUAGE_DE:
		case WEB_LANGUAGE_FR:
		case WEB_LANGUAGE_IT:
		case WEB_LANGUAGE_NL:
		case WEB_LANGUAGE_ES:
		case WEB_LANGUAGE_ES_C:
		case WEB_LANGUAGE_PT:
		case WEB_LANGUAGE_BR:
			strNew = WriteStrInfo(iType, strNew, iPos, INNER_LINE_MAX, INNERLINE_DISPLAY_LEN, g_cInnerLineDisplay[0]);
			break;

		case WEB_LANGUAGE_PL:
			strNew = WriteStrInfo(iType, strNew, iPos, INNER_LINE_MAX, PL_INNERLINE_DISPLAY_LEN, g_cInnerLineDisplay_PL[0]);
			break;

		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, INNER_LINE_MAX, CZ_INNERLINE_DISPLAY_LEN, g_cInnerLineDisplay_CZ[0]);
			break;
		}
		break;
	case HTTP_DUAL_MODE:
		strNew = "<SELECT name=dualmode size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);

		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CN:
			strNew = WriteStrInfo(iType, strNew, iPos, DUAL_MODE_MAX, DUALMODE_DISPLAY_LEN, g_cDualModeDisplay_GB[0]);
			break;

		case WEB_LANGUAGE_US:
		case WEB_LANGUAGE_DE:
		case WEB_LANGUAGE_FR:
		case WEB_LANGUAGE_IT:
		case WEB_LANGUAGE_NL:
		case WEB_LANGUAGE_ES:
		case WEB_LANGUAGE_ES_C:
		case WEB_LANGUAGE_PT:
		case WEB_LANGUAGE_BR:
			strNew = WriteStrInfo(iType, strNew, iPos, DUAL_MODE_MAX, DUALMODE_DISPLAY_LEN, g_cDualModeDisplay[0]);
			break;

		case WEB_LANGUAGE_PL:
			strNew = WriteStrInfo(iType, strNew, iPos, DUAL_MODE_MAX, PL_DUALMODE_DISPLAY_LEN, g_cDualModeDisplay_PL[0]);
			break;

		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, DUAL_MODE_MAX, CZ_DUALMODE_DISPLAY_LEN, g_cDualModeDisplay_CZ[0]);
			break;
		}
		break;
	case HTTP_DUALMODE_PREFIX:
		strNew = "<INPUT name=dualmodeprefix value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 3);
		strNew += "\"xx\" size=5 maxlength=2>";
		break;
	case HTTP_INNERLINE_PREFIX:
		strNew = "<INPUT name=innerlineprefix value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 3);
		strNew += "\"xx\" size=5 maxlength=2>";
		break;
	case HTTP_SERVICE_TYPE:
		strNew = "<SELECT name=servicetype size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);
		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CN:
		case WEB_LANGUAGE_US:
		case WEB_LANGUAGE_DE:
		case WEB_LANGUAGE_FR:
		case WEB_LANGUAGE_IT:
		case WEB_LANGUAGE_NL:
		case WEB_LANGUAGE_ES:
		case WEB_LANGUAGE_ES_C:
		case WEB_LANGUAGE_PT:
		case WEB_LANGUAGE_BR:
			switch(m_iProtocol)
			{
			case PROTOCOL_H323:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_SERVICE_TYPE_MAX, H323_SERVICE_TYPE_DISPLAY_LEN, g_cH323ServiceTypeDisplay[0]);
				break;

			case PROTOCOL_SIP:
				strNew = WriteStrInfo(iType, strNew, iPos, SIP_SERVICE_TYPE_MAX, SIP_SERVICE_TYPE_DISPLAY_LEN, g_cSipServiceTypeDisplay[0]);
				break;

			case PROTOCOL_MGCP:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_SERVICE_TYPE_MAX, MGCP_SERVICE_TYPE_DISPLAY_LEN, g_cMgcpServiceTypeDisplay[0]);
				break;
			}
			break;
		case WEB_LANGUAGE_PL:
			switch(m_iProtocol)
			{
			case PROTOCOL_H323:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_SERVICE_TYPE_MAX, H323_SERVICE_TYPE_DISPLAY_LEN, g_cH323ServiceTypeDisplay_PL[0]);
				break;

			case PROTOCOL_SIP:
				strNew = WriteStrInfo(iType, strNew, iPos, SIP_SERVICE_TYPE_MAX, SIP_SERVICE_TYPE_DISPLAY_LEN, g_cSipServiceTypeDisplay_PL[0]);
				break;

			case PROTOCOL_MGCP:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_SERVICE_TYPE_MAX, MGCP_SERVICE_TYPE_DISPLAY_LEN, g_cMgcpServiceTypeDisplay_PL[0]);
				break;
			}
			break;

		case WEB_LANGUAGE_CZ:
			switch(m_iProtocol)
			{
			case PROTOCOL_H323:
				strNew = WriteStrInfo(iType, strNew, iPos, H323_SERVICE_TYPE_MAX, H323_SERVICE_TYPE_DISPLAY_LEN, g_cH323ServiceTypeDisplay_CZ[0]);
				break;

			case PROTOCOL_SIP:
				strNew = WriteStrInfo(iType, strNew, iPos, SIP_SERVICE_TYPE_MAX, SIP_SERVICE_TYPE_DISPLAY_LEN, g_cSipServiceTypeDisplay_CZ[0]);
				break;

			case PROTOCOL_MGCP:
				strNew = WriteStrInfo(iType, strNew, iPos, MGCP_SERVICE_TYPE_MAX, MGCP_SERVICE_TYPE_DISPLAY_LEN, g_cMgcpServiceTypeDisplay_CZ[0]);
				break;
			}
			break;
		}
		break;
	case HTTP_ACCOUNT:
		switch(m_iProtocol)
		{
		case PROTOCOL_MGCP:
			strNew = "<INPUT name=endpointid value=";
			break;

		default:
			strNew = "<INPUT name=account value=";
			break;
		}
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 33);
		strNew += "\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" size=24 maxlength=32>";
		break;
	case HTTP_PIN:
		switch(m_iProtocol)
		{
		case PROTOCOL_MGCP:
			if (m_bHidePassword)
			{
				strNew = "<INPUT name=domain type=password value=";
			}
			else
			{
				strNew = "<INPUT name=domain value=";
			}
			break;

		default:
			if (m_bHidePassword)
			{
				strNew = "<INPUT name=pin type=password value=";
			}
			else
			{
				strNew = "<INPUT name=pin value=";
			}
			break;
		}
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 33);
		strNew += "\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" size=24 maxlength=32>";
		break;
	case HTTP_PPP_ID:
		strNew = "<INPUT name=pppid value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 41);
		strNew += "\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" size=24 maxlength=40>";
		break;
	case HTTP_PPP_PASSWORD:
		if (m_bHidePassword)
		{
			strNew = "<INPUT name=ppppin type=password value=";
		}
		else
		{
			strNew = "<INPUT name=ppppin value=";
		}
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 25);
		strNew += "\"xxxxxxxxxxxxxxxxxxxxxxxx\" size=24 maxlength=24>";
		break;
	case HTTP_GKID:
		switch(m_iProtocol)
		{
		case PROTOCOL_SIP:
			strNew = "<INPUT name=domain value=";
			break;

		case PROTOCOL_N2P:
			strNew = "<INPUT name=serviceid value=";
			break;
		}
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 33);
		strNew += "\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" size=24 maxlength=32>";
		break;
	case HTTP_RAS_PORT:
		switch(m_iProtocol)
		{
		case PROTOCOL_H323:
			strNew = "<INPUT name=rasport value=";
			break;

		case PROTOCOL_SIP:
		case PROTOCOL_MGCP:
		case PROTOCOL_N2P:
			strNew = "<INPUT name=registerport value=";
			break;

		case PROTOCOL_IAX2:
			strNew = "<INPUT name=localport value=";
			break;
		}
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 5);
		strNew += "xxxxx size=5 maxlength=5>";
		break;
	case HTTP_H245_PORT:
		strNew = "<INPUT name=h245port value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 5);
		strNew += "xxxxx size=5 maxlength=5>";
		break;
	case HTTP_RTP_PORT:
		switch(m_iProtocol)
		{
		case PROTOCOL_N2P:
		case PROTOCOL_WP:
			strNew = "<INPUT name=voiceport value=";
			break;

		case PROTOCOL_H323:
		case PROTOCOL_SIP:
		case PROTOCOL_MGCP:
		case PROTOCOL_EPN:
			strNew = "<INPUT name=rtpport value=";
			break;
		}
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 5);
		strNew += "xxxxx size=5 maxlength=5>";
		break;
	case HTTP_RTP_TOS:
		strNew = "<INPUT name=tos value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 3);
		strNew += "xxx size=5 maxlength=3>";
		break;
	case HTTP_ILBC_PTYPE:
		strNew = "<INPUT name=ilbcpayload value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 3);
		strNew += "xxx size=5 maxlength=3>";
		break;
	case HTTP_DTMF_PTYPE:
		strNew = "<INPUT name=dtmfpayload value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 3);
		strNew += "xxx size=5 maxlength=3>";
		break;
	case HTTP_REGISTER_TTL:
		strNew = "<INPUT name=registerttl value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 5);
		strNew += "xxxxx size=5 maxlength=5>";
		break;
	case HTTP_JITTER_SIZE:
		strNew = "<INPUT name=jittersize value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 2);
		strNew += "xx size=5 maxlength=2>";
		break;
	case HTTP_NAT_TTL:
		strNew = "<INPUT name=natttl value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 5);
		strNew += "xxxxx size=5 maxlength=5>";
		break;
	case HTTP_USE_AEC:
		strNew = "<INPUT name=aec ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_OUTPUT_DEBUG:
		strNew = "<SELECT name=debug size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);

		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CN:
			strNew = WriteStrInfo(iType, strNew, iPos, DEBUG_LEVEL_MAX, DEBUG_GB_DISPLAY_LEN, g_cDebugDisplay_GB[0]);
			break;

		case WEB_LANGUAGE_US:
		case WEB_LANGUAGE_DE:
		case WEB_LANGUAGE_FR:
		case WEB_LANGUAGE_IT:
		case WEB_LANGUAGE_NL:
		case WEB_LANGUAGE_ES:
		case WEB_LANGUAGE_ES_C:
		case WEB_LANGUAGE_PT:
		case WEB_LANGUAGE_BR:
			strNew = WriteStrInfo(iType, strNew, iPos, DEBUG_LEVEL_MAX, DEBUG_DISPLAY_LEN, g_cDebugDisplay[0]);
			break;

		case WEB_LANGUAGE_PL:
			strNew = WriteStrInfo(iType, strNew, iPos, DEBUG_LEVEL_MAX, PL_DEBUG_DISPLAY_LEN, g_cDebugDisplay_PL[0]);
			break;

		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, DEBUG_LEVEL_MAX, CZ_DEBUG_DISPLAY_LEN, g_cDebugDisplay_CZ[0]);
			break;
		}
		break;
	case HTTP_USE_DIGITMAP:
		strNew = "<INPUT name=digitmap ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_SUPER_PASSWORD:
		if (m_bHidePassword)
		{
			strNew = "<INPUT name=superpassword type=password value=";
		}
		else
		{
			strNew = "<INPUT name=superpassword value=";
		}
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 17);
		strNew += "\"xxxxxxxxxxxxxxxx\" size=16 maxlength=16>";
		break;
	case HTTP_DIAL_NUMBER:
		strNew = "<INPUT name=dialnumber value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 17);
		strNew += "\"xxxxxxxxxxxxxxxx\" size=16 maxlength=16>";
		break;
	case HTTP_SERVICE_DNS:
		switch(m_iProtocol)
		{
		case PROTOCOL_SIP:
			strNew = "<INPUT name=sipproxy value=";
			break;

		case PROTOCOL_MGCP:
			strNew = "<INPUT name=caaddr value=";
			break;

		default:
			strNew = "<INPUT name=serviceaddr value=";
			break;
		}
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 33);
		strNew += "\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" size=24 maxlength=32>";
		break;
	case HTTP_UPGRADE_TYPE:
		strNew = "<SELECT name=upgradetype size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);

		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CN:
			strNew = WriteStrInfo(iType, strNew, iPos, UPGRADE_TYPE_MAX, UPGRADE_TYPE_GB_DISPLAY_LEN, g_cUpgradeTypeDisplay_GB[0]);
			break;

		case WEB_LANGUAGE_US:
		case WEB_LANGUAGE_DE:
		case WEB_LANGUAGE_FR:
		case WEB_LANGUAGE_IT:
		case WEB_LANGUAGE_NL:
		case WEB_LANGUAGE_ES:
		case WEB_LANGUAGE_ES_C:
		case WEB_LANGUAGE_PT:
		case WEB_LANGUAGE_BR:
			strNew = WriteStrInfo(iType, strNew, iPos, UPGRADE_TYPE_MAX, UPGRADE_TYPE_DISPLAY_LEN, g_cUpgradeTypeDisplay[0]);
			break;

		case WEB_LANGUAGE_PL:
			strNew = WriteStrInfo(iType, strNew, iPos, UPGRADE_TYPE_MAX, PL_UPGRADE_TYPE_DISPLAY_LEN, g_cUpgradeTypeDisplay_PL[0]);
			break;

		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, UPGRADE_TYPE_MAX, CZ_UPGRADE_TYPE_DISPLAY_LEN, g_cUpgradeTypeDisplay_CZ[0]);
			break;
		}
		break;
	case HTTP_UPGRADE_ADDR:
		strNew = "<INPUT name=upgradeaddr value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 33);
		strNew += "\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" size=24 maxlength=32>";
		break;
	case HTTP_TITLE:
		strNew = "<TITLE>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</TITLE>";
		GetInfo(iType, iPos+7, 32);
		break;
	case HTTP_SPEEDDIAL_NAME:
		strNew = "<INPUT name=n001 value=\"xxxxxxxxxxxxxxxx\" size=16 maxlength=16>";
		strTemp.Format("%03d", m_iSpeedDialIndex);
		strNew.SetAt(13, strTemp.GetAt(0));
		strNew.SetAt(14, strTemp.GetAt(1));
		strNew.SetAt(15, strTemp.GetAt(2));
		GetInfo(iType, iPos+24, 17);
		break;
	case HTTP_SPEEDDIAL_PHONE:
		strNew = "<INPUT name=p001 value=\"xxxxxxxxxxxxxxxx\" size=16 maxlength=16>";
		strTemp.Format("%03d", m_iSpeedDialIndex);
		strNew.SetAt(13, strTemp.GetAt(0));
		strNew.SetAt(14, strTemp.GetAt(1));
		strNew.SetAt(15, strTemp.GetAt(2));
		GetInfo(iType, iPos+24, 17);
		break;
	case HTTP_MAC_ADDR:
		strNew = "<INPUT name=mac value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 17);
		strNew += "xxxxxxxxxxxxxxxxx size=17 maxlength=17>";
		break;
	case HTTP_FWD_ALWAYS:
		strNew = "<INPUT name=fwdalways ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_FWD_BUSY:
		strNew = "<INPUT name=fwdbusy ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_FWD_NOANSWER:
		strNew = "<INPUT name=fwdnoanswer ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_FWD_POWEROFF:
		strNew = "<INPUT name=fwdpoweroff ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_CALL_WAITING:
		strNew = "<INPUT name=callwaiting ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_FORWARD_NUMBER:
		strNew = "<INPUT name=fwdnumber value=";
		iLen = strNew.GetLength() + 1;
		GetInfo(iType, iPos+iLen, 25);
		strNew += "\"xxxxxxxxxxxxxxxxxxxxxxxx\" size=16 maxlength=24>";
		break;
	case HTTP_NTS_ADDR:
		strNew = "<INPUT name=sntpip value=";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 15);
		strNew += "xxx.xxx.xxx.xxx size=16 maxlength=15>";
		break;
	case HTTP_DAYLIGHT:
		strNew = "<INPUT name=daylight ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos+iLen, 7);
		strNew += "CHECKED type=checkbox>";
		break;
	case HTTP_TIME_ZONE:
		strNew = "<SELECT name=timezone size=1><OPTION value=0 ";
		iLen = strNew.GetLength();
		GetInfo(iType, iPos + iLen, 8);
		switch(m_iWebLanguage)
		{
		case WEB_LANGUAGE_CN:
			strNew = WriteStrInfo(iType, strNew, iPos, TIME_ZONE_MAX, TIMEZONE_GB_DISPLAY_LEN, g_cTimezoneDisplay_GB[0]);
			break;

		case WEB_LANGUAGE_US:
		case WEB_LANGUAGE_DE:
		case WEB_LANGUAGE_FR:
		case WEB_LANGUAGE_IT:
		case WEB_LANGUAGE_NL:
		case WEB_LANGUAGE_ES:
		case WEB_LANGUAGE_ES_C:
		case WEB_LANGUAGE_PL:
		case WEB_LANGUAGE_PT:
		case WEB_LANGUAGE_BR:
			strNew = WriteStrInfo(iType, strNew, iPos, TIME_ZONE_MAX, TIMEZONE_DISPLAY_LEN, g_cTimezoneDisplay[0]);
			break;

		case WEB_LANGUAGE_CZ:
			strNew = WriteStrInfo(iType, strNew, iPos, TIME_ZONE_MAX, CZ_TIMEZONE_DISPLAY_LEN, g_cTimezoneDisplay_CZ[0]);
			break;
		}
		break;
	default:
		return strNew;
	}
	return strNew;
}


/////////////////////////////////////////////////////////////////////////////
// CHttpDlg message handlers

BOOL CHttpDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	int i;
	CString strText;
	
	// TODO: Add extra initialization here

	for(i = 0; i < WEB_LANGUAGE_MAX; i++)
	{
		m_ctlWebLanguage.AddString(m_strLanguageDisplay[i]);
	}
	for (i = 0; i < WEB_OEM_MAX; i ++)
	{
		m_ctlWebType.AddString(m_strOemType[i]);
	}
	m_iWebLanguage = AfxGetApp()->GetProfileInt(_T("GenHttp"), _T("WebLanguage"), 0);
    m_ctlWebLanguage.SetCurSel(m_iWebLanguage);
	m_iWebType = AfxGetApp()->GetProfileInt(_T("GenHttp"), _T("WebType"), 0);
	m_ctlWebType.SetCurSel(m_iWebType);
	m_bReplaceTitle = (BOOL)AfxGetApp()->GetProfileInt(_T("GenHttp"), _T("ReplaceTitle"), 1);
	m_bHidePassword = (BOOL)AfxGetApp()->GetProfileInt(_T("GenHttp"), _T("HidePassword"), 0);
	m_iPageNum = AfxGetApp()->GetProfileInt(_T("GenHttp"), _T("PageNum"), 0);	
	m_strDstDir = AfxGetApp()->GetProfileString(_T("GenHttp"), _T("OutputDir"), _T(""));

	UpdateData(FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CHttpDlg::OnButtonDstDir() 
{
	CDirectoryDlg dlg;
	if (dlg.DoModal() != IDOK)	return;

	CString strPathName = dlg.GetPathName();
	CString strName = dlg.GetFileName();
	m_strDstDir = strPathName.Left(strPathName.GetLength() - strName.GetLength());
	UpdateData(FALSE);
}

void CHttpDlg::OnBrowseSrcfile() 
{
	int i;
	CFileDialog dlgOpen(TRUE, _T("*.htm"), NULL, OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST, szHtmlFilter);
	
	UpdateData();
	m_strList.RemoveAll();
	for (i = 0; i < m_iPageNum; i ++)
	{
		if (dlgOpen.DoModal() != IDOK)
		{
			m_strList.RemoveAll();
			return;
		}
		m_strList.AddTail(dlgOpen.GetPathName());
	}
}


void CHttpDlg::OnBrowseSettingsfile() 
{
	CFileDialog dlgOpen(TRUE, _T("*.htm"), NULL, OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST, szHtmlFilter);

	if (dlgOpen.DoModal() != IDOK)
	{
		m_strSettingsFile = _T("");
		return;
	}
	m_strSettingsFile = dlgOpen.GetPathName();
}

void CHttpDlg::GetFileName(CString strInput, CString & strInfoFile, CString & strMsgFile)
{
	CString strOutput;

	strOutput = m_strDstDir;
	strOutput += strInput;
	strOutput += "_";
	strOutput += m_strLanguage[m_iWebLanguage];
	if (m_iWebType != WEB_OEM_NONE)
	{
		strOutput += "_";
		strOutput += m_strOemType[m_iWebType];
	}
	strInfoFile = strOutput + "_i.h";
	strMsgFile = strOutput + "_m.h";
}

void CHttpDlg::OnStartConvertSettings() 
{
	CStdioFile fileInput, fileInfo, fileMsg;
	CString strInfoFile, strMsgFile;
	CString strInput, strOutput, strItem, strName;
	int iBeginPos, iEndPos;

	UpdateData();
	if (m_strSettingsFile.IsEmpty())
	{
		AfxMessageBox("Please browse for the source file first!");
		return;
	}

	if (!fileInput.Open(m_strSettingsFile, CFile::modeRead|CFile::typeText))
	{
		AfxMessageBox("Can not open settings file");
		return;
	}

	AfxGetApp()->BeginWaitCursor();
	m_pInfo = (int *)malloc(sizeof(int) * 512 * HTTP_INFO_NUM);

	strInput = "";
	while (fileInput.ReadString(strItem))
	{
		strItem.TrimLeft();
		if(strItem.Left(10) == "<!--begin=")
		{
			iBeginPos = strItem.Find('[', 0);
			iEndPos = strItem.Find(']', iBeginPos);
			strName = strItem.Mid(iBeginPos + 1, (iEndPos - iBeginPos - 1));
			if (strName == "settings_h323")			m_iProtocol = PROTOCOL_H323;
			else if (strName == "settings_sip")		m_iProtocol = PROTOCOL_SIP;
			else if (strName == "settings_mgcp")	m_iProtocol = PROTOCOL_MGCP;
			else if (strName == "settings_n2p")		m_iProtocol = PROTOCOL_N2P;
			else if (strName == "settings_iax2")	m_iProtocol = PROTOCOL_IAX2;
			else if (strName == "settings_epn")		m_iProtocol = PROTOCOL_EPN;
			else if (strName == "settings_wp")		m_iProtocol = PROTOCOL_WP;
			GetFileName(strName, strInfoFile, strMsgFile);
		}
		else if (strItem.Left(10) == "<!--end-->")
		{
			m_iInfoNum = 0;
			if (!ConvertFile(strInput, strOutput))
			{
				AfxMessageBox("Settings Html has format error, possibly space after \"name=\" !");
				goto End;
			}
			fileMsg.Open(strMsgFile, CFile::modeCreate|CFile::modeWrite|CFile::typeText);
			fileInfo.Open(strInfoFile, CFile::modeCreate|CFile::modeWrite|CFile::typeText);
			WriteMsgFile(fileMsg, strName, strOutput);
			WrtieInfoFile(fileInfo, strName, strOutput);
			fileMsg.Close();
			fileInfo.Close();
			strInput = "";
		}
		else
		{
			strInput += strItem;
		}
	}

End:
	free(m_pInfo);
	fileInput.Close();
}


void CHttpDlg::OnStartConversion() 
{
	CStdioFile fileRead, fileMsg, fileInfo;
	CString strSrcFile, strOutput, strInput;
	CString strMsgFile, strInfoFile, strName;
	POSITION pos;
	int iPageNo;

	UpdateData();
	GetFileName((CString)"web_common", strInfoFile, strMsgFile);
	
	AfxGetApp()->BeginWaitCursor();
	m_pInfo = (int *)malloc(sizeof(int) * 512 * HTTP_INFO_NUM);

	fileMsg.Open(strMsgFile, CFile::modeCreate|CFile::modeWrite|CFile::typeText);
	fileInfo.Open(strInfoFile, CFile::modeCreate|CFile::modeWrite|CFile::typeText);

	iPageNo = 0;
	for (pos = m_strList.GetHeadPosition(); pos != NULL;)
	{
		strSrcFile = m_strList.GetNext(pos);
		if (!fileRead.Open(strSrcFile, CFile::modeRead|CFile::typeText))
		{
			AfxMessageBox("Can not open source file");
			goto End;
		}
		m_iInfoNum = 0;
		TrimFile(fileRead, strInput);

		if (!ConvertFile(strInput, strOutput))
		{
			strName.Format("Source Html %s has format error, possibly space after \"name=\" !", m_strList.GetAt(m_strList.FindIndex(iPageNo)));
			AfxMessageBox(strName);
			fileRead.Close();
			goto End;
		}
		else
		{
			fileRead.Close();
		}
		strName.Format("http_page%d", iPageNo);
		WriteMsgFile(fileMsg, strName, strOutput);
		WrtieInfoFile(fileInfo, strName, strOutput);
		iPageNo ++;
	}
	AfxGetApp()->EndWaitCursor();
End:
	free(m_pInfo);
	fileMsg.Close();
	fileInfo.Close();
}



void CHttpDlg::OnCancel() 
{
	SaveSettings();	
	CDialog::OnCancel();
}
