示例#1
0
void __stdcall RemoveLinebreaks( CMString& Message )
{
    while ( Message.Find( _T("\r\n\r\n"), 0) != -1 )
        ReplaceString( Message, _T("\r\n\r\n"), _T("\r\n"));

    if (Message.Find( _T("\r\n"), 0) == 0)
        Message.Delete(0,2);

    if ( (Message.GetLength() > 1) && (Message.Find(_T("\r\n"), Message.GetLength()-2) == 0) )
        Message.Delete(Message.GetLength()-2, 2);
}
示例#2
0
static void DecodeHTML(CMString& str)
{
	if (str.Find('&') != -1) {
		str = _TPattern::replace(CMString(_T("&lt;")), str, CMString(_T("<")));
		str = _TPattern::replace(CMString(_T("&gt;")), str, CMString(_T(">")));
	}
}
示例#3
0
CMString& __stdcall ReplaceString ( CMString& text, const TCHAR* replaceme, const TCHAR* newword)
{
	if ( !text.IsEmpty() && replaceme != NULL) {
		int i = 0;
		while (( i = text.Find(replaceme, i)) != -1 ) {
			text.Delete(i,lstrlen(replaceme));
			text.Insert(i, newword);
			i = i + lstrlen(newword);
	}	}

	return text;
}
示例#4
0
CVKNewsItem* CVkProto::GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers)
{
    debugLogA("CVkProto::GetVkNotificationsItem");
    if (!jnItem)
        return NULL;

    CMString tszType(jnItem["type"].as_mstring());
    VKObjType vkFeedbackType = vkNull, vkParentType = vkNull;
    CMString tszNotificationTranslate = SpanVKNotificationType(tszType, vkFeedbackType, vkParentType);

    const JSONNode &jnFeedback = jnItem["feedback"];
    const JSONNode &jnParent = jnItem["parent"];

    if (!jnFeedback || !jnParent)
        return NULL;

    CVkUserInfo *vkUser = NULL;
    CMString tszFeedback = GetVkFeedback(jnFeedback, vkFeedbackType, vkUsers, vkUser);
    CVKNewsItem* vkNotification = GetVkParent(jnParent, vkParentType);

    if (!vkNotification)
        return NULL;

    if (vkNotification && !tszFeedback.IsEmpty()) {
        CMString tszNotificaton;
        tszNotificaton.AppendFormat(tszFeedback, tszNotificationTranslate, vkNotification->tszText);
        vkNotification->tszText = tszNotificaton;

        tszFeedback = RemoveBBC(tszFeedback);
        int idx = tszFeedback.Find(_T(" %s %s"));

        vkNotification->tszPopupTitle.AppendFormat(_T("%s %s"), tszFeedback.Mid(0, idx), tszNotificationTranslate);
        if (tszFeedback.GetLength() > idx + 7) {
            if (!vkNotification->tszPopupText.IsEmpty())
                vkNotification->tszPopupText += _T("\n>> ");
            vkNotification->tszPopupText += tszFeedback.Mid(idx + 7, tszFeedback.GetLength() - idx - 7);
        }

        vkNotification->tszType = tszType;
        vkNotification->tDate = jnItem["date"].as_int();
        vkNotification->vkFeedbackType = vkFeedbackType;
        vkNotification->vkParentType = vkParentType;
        vkNotification->vkUser = vkUser;
        return vkNotification;
    }

    delete vkNotification;
    return NULL;
}
示例#5
0
void SmileyCategoryListType::AddAllProtocolsAsCategory(void)
{
	CMString displayName = TranslateT("Standard");
	CMString tname = _T("Standard");
	AddCategory(tname, displayName, smcStd);

	const CMString &defaultFile = GetSmileyCategory(tname)->GetFilename();

	PROTOCOLDESCRIPTOR **proto;
	int protoCount = 0;
	Proto_EnumProtocols(&protoCount, &proto);

	for (int i = 0; i < protoCount; i++) {
		PROTOCOLDESCRIPTOR *pd = proto[i];
		if (pd->type == PROTOTYPE_PROTOCOL && pd->cbSize == sizeof(*pd))
			AddProtoAsCategory(pd->szName, defaultFile);
	}

	PROTOACCOUNT **accList;
	Proto_EnumAccounts(&protoCount, &accList);
	for (int i = 0; i < protoCount; i++)
		AddAccountAsCategory(accList[i], defaultFile);

	for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
		AddContactTransportAsCategory(hContact, defaultFile);

	CMString cats;
	opt.ReadCustomCategories(cats);

	int cppv = 0;
	for (;;) {
		int cp = cats.Find('#', cppv);
		if (cp == -1)
			break;

		displayName = cats.Mid(cppv, cp - cppv);
		AddCategory(displayName, displayName, smcCustom, defaultFile);
		cppv = cp + 1;
	}

	if (cppv != cats.GetLength()) {
		displayName = cats.Mid(cppv);
		AddCategory(displayName, displayName, smcCustom, defaultFile);
	}
}
示例#6
0
CVKNewsItem* CVkProto::GetVkGroupInvates(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers)
{
	debugLogA("CVkProto::GetVkGroupInvates");
	if (!jnItem)
		return NULL;

	CMString tszType(jnItem["type"].as_mstring());
	VKObjType vkFeedbackType = vkNull, vkParentType = vkNull;
	CMString tszNotificationTranslate = SpanVKNotificationType(tszType, vkFeedbackType, vkParentType);
	
	if (!jnItem["id"])
		return NULL;

	LONG iGroupId = jnItem["id"].as_int();
	CMString tszId;
	tszId.AppendFormat(_T("%d,"), iGroupId);
	CMString tszIds = ptrT(db_get_tsa(NULL, m_szModuleName, "InviteGroupIds"));

	if (tszIds.Find(tszId, 0) != -1)
		return NULL;
		
	LONG iUserId = !jnItem["invited_by"] ? 0 : jnItem["invited_by"].as_int();
	CVKNewsItem *vkNotification = new CVKNewsItem();
	vkNotification->tDate = time(NULL);
	vkNotification->vkUser = GetVkUserInfo(iUserId, vkUsers);
	vkNotification->tszType = tszType;
	vkNotification->tszId = tszId;
	vkNotification->vkFeedbackType = vkFeedbackType;
	vkNotification->vkParentType = vkParentType;

	CMString tszGroupName, tszGLink;
	CMString tszGName = jnItem["name"].as_mstring();
	tszGLink.AppendFormat(_T("https://vk.com/%s"), jnItem["screen_name"].as_mstring());
	tszGroupName = SetBBCString(tszGName, m_iBBCForNews, vkbbcUrl, tszGLink);

	CMString tszUsers = SetBBCString(iUserId ? vkNotification->vkUser->m_tszUserNick : TranslateT("Unknown"), m_iBBCForNews, vkbbcUrl, iUserId ? vkNotification->vkUser->m_tszLink : _T("https://vk.com/"));

	vkNotification->tszText.AppendFormat(_T("%s %s %s"), tszUsers, tszNotificationTranslate, tszGroupName);
	
	tszIds += tszId;
	setTString("InviteGroupIds", tszIds);	

	return vkNotification;	
}
示例#7
0
bool GetSmileyFile(CMString& url, const CMString& packstr)
{
	_TPattern *urlsplit = _TPattern::compile(_T(".*/(.*)"));
	_TMatcher *m0 = urlsplit->createTMatcher(url);

	m0->findFirstMatch();

	CMString filename;
	filename.AppendFormat(_T("%s\\%s\\"), cachepath, packstr.c_str());
	int pathpos = filename.GetLength();
	filename += m0->getGroup(1);

	delete m0;
	delete urlsplit;

	bool needext = filename.Find('.') == -1;
	if (needext)
		filename += _T(".*");

	_tfinddata_t c_file;
	INT_PTR hFile = _tfindfirst((TCHAR*)filename.c_str(), &c_file);
	if (hFile > -1) {
		_findclose(hFile);
		filename.Truncate(pathpos);
		filename += c_file.name;
		url = filename;
		return false;
	}
	if (needext)
		filename.Truncate(filename.GetLength() - 1);

	WaitForSingleObject(g_hDlMutex, 3000);
	dlQueue.insert(new QueueElem(url, filename, needext));
	ReleaseMutex(g_hDlMutex);

	if (!threadRunning) {
		threadRunning = true;
		mir_forkthread(SmileyDownloadThread, NULL);
	}

	url = filename;
	return false;
}
示例#8
0
BOOL IsHighlighted(SESSION_INFO *si, GCEVENT *gce)
{
	if (!g_Settings->bHighlightEnabled || !g_Settings->pszHighlightWords || !gce || !si || !si->pMe)
		return FALSE;

	if (gce->ptszText == NULL)
		return FALSE;

	TCHAR *buf = RemoveFormatting(NEWTSTR_ALLOCA(gce->ptszText));

	int iStart = 0;
	CMString tszHighlightWords(g_Settings->pszHighlightWords);

	while (true) {
		CMString tszToken = tszHighlightWords.Tokenize(_T("\t "), iStart);
		if (iStart == -1)
			break;

		// replace %m with the users nickname
		if (tszToken == _T("%m"))
			tszToken = si->pMe->pszNick;

		if (tszToken.Find('*') == -1)
			tszToken = '*' + tszToken + '*';

		// time to get the next/first word in the incoming text string
		for (const TCHAR *p = buf; *p != '\0'; p += _tcscspn(p, _T(" "))) {
			p += _tcsspn(p, _T(" "));

			// compare the words, using wildcards
			if (wildcmpit(p, tszToken))
				return TRUE;
		}
	}

	return FALSE;
}
示例#9
0
void CMSession::OnResponse(UINT32 nCode, const CMHTTPRspHeader* pRespHeader)
{
    UINT32 nRet = MERE_SERVER;
    if (nCode == MER_OK)
    {
        ASSERT(pRespHeader != NULL);

        UINT32 httpRet = pRespHeader->GetHttpReturn();

        if (httpRet == 200 || httpRet == 206)
        {
            CMString sVal;

            //判断是否wap网关的无聊返回,如果是则继续请求一次
            if (pRespHeader->GetValue(HH_CTYPE, sVal))
            {
                if (sVal.Find(L"text/vnd.wap.wml") >= 0)
                {
                    m_pHttp->Request();
                    return;
                }
            }
            if (pRespHeader->GetValue(HH_CLENGTH, sVal))
            {
                sVal.Trim();
                INT32 nLen = _mwtoi(sVal);
                if (nLen >= SESSION_RET_MAX)
                {
                    //命令获取返回不能大于最大限制
                    CM_ERRP("CMSession::OnResponse %d too large", nLen);
                    goto err;
                }
                if (nLen > 0)
                {
                    if (m_pBuf)
                    {
                        delete m_pBuf;
                        m_pBuf = NULL;
                    }
                    m_pBuf = new INT8[nLen + 1];
                    m_pHttp->Read(m_pBuf, nLen);
                }
                else
                {
                    CM_ERRP("CMSession::OnResponse content-length is %s, not valid", (const CHAR*)sVal);
                    goto err;
                }
            }
            else if(pRespHeader->IsChunked())
            {
                //不支持断点续传
                if (m_pBuf)
                {
                    delete m_pBuf;
                    m_pBuf = NULL;
                }
                m_pBuf = new INT8[SESSION_RET_MAX];
                m_pHttp->Read(m_pBuf, SESSION_RET_MAX);
            }
            else
            {
                CM_ERR("CMSession::OnResponse no content-length and no encoder");
                goto err;
            }

            //对于nLen <= 0的情况不做一般错误处理
            return;
        }
        else
        {
            CM_ERRP("CMSession::OnResponse http ret %d error", httpRet);
            nRet = httpRet;
        }
    }
    else
    {
        CM_ERRP("CMSession::OnResponse ret %d error", nCode);
        nRet = nCode;
    }

err:
    //未成功获取信息,清理,等待下次获取
    if (m_pBuf)
    {
        delete m_pBuf;
        m_pBuf = NULL;
    }

    UINT32 nTmp = m_nCurCmd;
    m_nCurCmd = 0;
    m_sParams.Empty();

    m_bRun = FALSE;
    //重置http
    m_pHttp->Cancel();

    if (m_sSequence.length() > 0)
    {
        CMSessionSequence::GetInstance()->Remove(this);
        m_sSequence = "";
    }

    if(m_pNotify)
    {
        m_pNotify->OnSessionCmd(nTmp, nRet, NULL);
    }
}
示例#10
0
INT_PTR CALLBACK DlgProcOptionsPage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg) {
	case WM_INITDIALOG:
		{
			char key[64];
			int count = 0;
			CMString replies;

			TranslateDialogDefault(hwndDlg);
			variables_skin_helpbutton(hwndDlg, IDC_VARIABLES);
			ShowWindow(GetDlgItem(hwndDlg, IDC_VARIABLES_HINT), ServiceExists(MS_VARS_FORMATSTRING));

			mir_subclassWindow(GetDlgItem(hwndDlg, IDC_REPLIES), MessageEditSubclassProc);

			mir_snprintf(key, _countof(key), "ImmediatelySend_%x", iNumber);
			CheckDlgButton(hwndDlg, IDC_IMMEDIATELY, db_get_w(NULL, MODULE, key, 1) ? BST_CHECKED : BST_UNCHECKED);

			mir_snprintf(key, _countof(key), "RepliesCount_%x", iNumber);
			count = db_get_w(NULL, MODULE, key, 0);

			for (int i = 0; i < count; i++)
			{
				mir_snprintf(key, _countof(key), "Reply_%x_%x", iNumber, i);
				wchar_t *value = db_get_wsa(NULL, MODULE, key);
				if (value)
				{
					replies.Append(value);
					replies.Append(_T("\r\n"));
				}
				mir_free(value);
			}
			SetDlgItemText(hwndDlg, IDC_REPLIES, replies.GetBuffer());
		}
		return TRUE;

	case WM_COMMAND:
		if (HIWORD(wParam) == BN_CLICKED) {
			switch(LOWORD(wParam)) {
			case IDC_VARIABLES:
				variables_showhelp(hwndDlg, IDC_REPLIES, VHF_SIMPLEDLG, NULL, NULL);
				break;

			case IDC_IMMEDIATELY:
				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				break;
			}
		}
		break;

	case WM_NOTIFY:
		{
			NMHDR *p = ((LPNMHDR)lParam);

			switch (p->code) {
			case PSN_APPLY:
				{
					char key[64];
					int count = 0;
					wchar_t *tszReplies;

					mir_snprintf(key, _countof(key), "RepliesCount_%x", iNumber);
					count = db_get_b(NULL, MODULE, key, 0);

					for (int i = 0; i < count; i++)
					{
						mir_snprintf(key, _countof(key), "Reply_%x_%x", iNumber, i);
						db_unset(NULL, MODULE, key);
					}

					int length = SendDlgItemMessage(hwndDlg, IDC_REPLIES, WM_GETTEXTLENGTH, 0, 0);
					tszReplies = (wchar_t*)mir_alloc(sizeof(wchar_t)* (length + 1));
					GetDlgItemText(hwndDlg, IDC_REPLIES, tszReplies, length + 1);
					tszReplies[length] = '\0';
					{
						CMString replies = tszReplies;
						if (replies.Right(2) != _T("\r\n"))
							replies.Append(_T("\r\n"));

						count = 0;
						int pos = -1, prev = 0;
						while ((pos = replies.Find(_T("\r\n"), prev)) != -1)
						{
							mir_snprintf(key, _countof(key), "Reply_%x_%x", iNumber, count++);
							db_set_ws(NULL, MODULE, key, replies.Mid(prev, pos - prev).GetBuffer());
							prev = pos + 2;
						}
					}
					mir_free(tszReplies);

					mir_snprintf(key, _countof(key), "RepliesCount_%x", iNumber);
					db_set_w(NULL, MODULE, key, count);

					mir_snprintf(key, _countof(key), "ImmediatelySend_%x", iNumber);
					db_set_b(NULL, MODULE, key, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_IMMEDIATELY));

					return TRUE;
				}
				break;
			}
		}
		break;
	}

	if (HIWORD(wParam) == EN_CHANGE && GetFocus() == (HWND)lParam)
		SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);

	return FALSE;
}
示例#11
0
bool SmileyPackType::LoadSmileyFileMSL(CMString &tbuf, bool onlyInfo, CMString &modpath)
{
	CMString pathstr, packstr;
	{
		_TPattern *pathsplit = _TPattern::compile(_T("(.*\\\\)(.*)\\.|$"));
		_TMatcher *m0 = pathsplit->createTMatcher(modpath);
		m0->findFirstMatch();
		pathstr = m0->getGroup(1);
		packstr = m0->getGroup(2);
		delete m0;
		delete pathsplit;
	}
	{
		_TPattern *otherf = _TPattern::compile(
			_T("^\\s*(Name|Author|Date|Version|ButtonSmiley)\\s*=\\s*\"(.*)\""),
			_TPattern::MULTILINE_MATCHING);

		_TMatcher *m0 = otherf->createTMatcher(tbuf);
		while (m0->findNextMatch()) {
			if (m0->getGroup(1) == _T("Name")) m_Name = m0->getGroup(2);
			if (m0->getGroup(1) == _T("Author")) m_Author = m0->getGroup(2);
			if (m0->getGroup(1) == _T("Date")) m_Date = m0->getGroup(2);
			if (m0->getGroup(1) == _T("Version")) m_Version = m0->getGroup(2);
			if (m0->getGroup(1) == _T("ButtonSmiley")) m_ButtonSmiley = m0->getGroup(2);
		}
		delete m0;
		delete otherf;
	}

	if (!onlyInfo) {
		selec.x = selec.y = win.x = win.y = 0;
		{
			_TPattern *pat = _TPattern::compile(
				_T("^\\s*(Selection|Window)Size\\s*=\\s*(\\d+)\\s*,\\s*(\\d+)"),
				_TPattern::MULTILINE_MATCHING);
			_TMatcher *m0 = pat->createTMatcher(tbuf);
			while (m0->findNextMatch()) {
				POINT tpt;
				tpt.x = _ttol(m0->getGroup(2).c_str());
				tpt.y = _ttol(m0->getGroup(3).c_str());

				if (m0->getGroup(1) == _T("Selection"))
					selec = tpt;
				else if (m0->getGroup(1) == _T("Window"))
					win = tpt;
			}
			delete m0;
			delete pat;
		}

		_TPattern *smiley = _TPattern::compile(
			_T("^\\s*Smiley(\\*)?\\s*=")	// Is Hidden
			_T("(?:\\s*\"(.*)\")")			// Smiley file name
			_T("(?:[\\s,]+(\\-?\\d+))")		// Icon resource id
			_T("(?:[\\s,]+(R|S)?\"(.*?)\")")	// Trigger text
			_T("(?:[\\s,]+\"(.*?)\")?")		// Tooltip or insert text
			_T("(?:[\\s,]+\"(.*?)\")?"),		// Tooltip text
			_TPattern::MULTILINE_MATCHING);

		SmileyVectorType hiddenSmileys;
		unsigned smnum = 0;
		{
			_TMatcher *m0 = smiley->createTMatcher(tbuf);
			while (m0->findNextMatch()) {
				CMString resname = m0->getGroup(2);
				if (resname.Find(_T("http://")) != -1) {
					if (GetSmileyFile(resname, packstr))
						continue;
				}
				else if (!resname.IsEmpty())
					resname.Insert(0, pathstr);

				SmileyType *dat = new SmileyType;

				const int iconIndex = _ttol(m0->getGroup(3).c_str());

				dat->SetHidden(m0->getStartingIndex(1) >= 0);
				if (m0->getStartingIndex(4) >= 0) {
					dat->SetRegEx(m0->getGroup(4) == _T("R"));
					dat->SetService(m0->getGroup(4) == _T("S"));
				}
				dat->m_TriggerText = m0->getGroup(5);
				if (dat->IsRegEx()) {
					if (m0->getStartingIndex(6) >= 0)
						ReplaceAllSpecials(m0->getGroup(6), dat->m_InsertText);

					if (m0->getStartingIndex(7) >= 0)
						ReplaceAllSpecials(m0->getGroup(7), dat->m_ToolText);
					else
						dat->m_ToolText = dat->m_InsertText;
				}
				else {
					if (m0->getStartingIndex(6) >= 0)
						ReplaceAllSpecials(m0->getGroup(6), dat->m_ToolText);
					else
						ReplaceAllSpecials(dat->m_TriggerText, dat->m_ToolText);
				}

				bool noerr;
				if (resname.IsEmpty()) {
					dat->SetHidden(true);
					dat->SetText(true);
					noerr = true;
				}
				else noerr = dat->LoadFromResource(resname, iconIndex);

				if (dat->IsHidden())
					hiddenSmileys.insert(dat);
				else
					m_SmileyList.insert(dat);

				if (!noerr) {
					static const TCHAR errmsg[] = LPGENT("Smiley #%u in file %s for smiley pack %s not found.");
					TCHAR msgtxt[1024];
					mir_sntprintf(msgtxt, TranslateTS(errmsg), smnum, resname.c_str(), modpath.c_str());
					CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, _T2A(msgtxt));
					errorFound = true;
				}
				smnum++;
			}
			delete smiley;
			delete m0;
		}

		m_VisibleCount = m_SmileyList.getCount();

		m_SmileyList.splice(hiddenSmileys);

		AddTriggersToSmileyLookup();
	}

	return true;
}
示例#12
0
bool SmileyPackType::LoadSmileyFile(const CMString& filename, const CMString& packname, bool onlyInfo, bool noerr)
{
	Clear();

	if (filename.IsEmpty()) {
		m_Name = _T("Nothing loaded");
		return false;
	}

	CMString modpath;
	pathToAbsolute(filename, modpath);

	// Load xep file
	int fh = _topen(modpath.c_str(), _O_BINARY | _O_RDONLY);
	if (fh == -1) {
		if (!noerr) {
			static const TCHAR errmsg[] = LPGENT("Smiley pack %s for category \"%s\" not found.\nSelect correct smiley pack in the Options -> Customize -> Smileys.");
			TCHAR msgtxt[1024];
			mir_sntprintf(msgtxt, TranslateTS(errmsg), modpath.c_str(), packname);
			ReportError(msgtxt);
		}

		m_Name = _T("Nothing loaded");
		return false;
	}

	m_Filename = filename;

	// Find file size
	const long flen = _filelength(fh);

	// Allocate file buffer
	char* buf = new char[flen + sizeof(wchar_t)];

	// Read xep file in
	int len = _read(fh, buf, flen);
	*(wchar_t*)(buf + len) = 0;

	// Close file
	_close(fh);

	CMString tbuf;

	if (len > 2 && *(wchar_t*)buf == 0xfeff)
		tbuf = W2T_SM((wchar_t*)buf + 1);
	else if (len > 3 && buf[0] == '\xef' && buf[1] == '\xbb' && buf[2] == '\xbf')
		tbuf = W2T_SM(A2W_SM(buf + 3, CP_UTF8));
	else
		tbuf = A2T_SM(buf);

	delete[] buf;

	bool res;
	if (filename.Find(_T(".xep")) == -1)
		res = LoadSmileyFileMSL(tbuf, onlyInfo, modpath);
	else
		res = LoadSmileyFileXEP(tbuf, onlyInfo, modpath);

	if (errorFound)
		ReportError(TranslateT("There were problems loading smiley pack (it should be corrected).\nSee network log for details."));

	return res;
}
示例#13
0
void CMHttpSNotify::OnResponse(UINT32 nCode, const CMHTTPRspHeader* pRespHeader)
{
    UINT32 nRet = MER_OK;
    if (nCode == MER_OK)
    {
        ASSERT(pRespHeader != NULL);

        UINT32 httpRet = pRespHeader->GetHttpReturn();

        if (httpRet == 200 || httpRet == 206)
        {
            CMString sVal;

            //判断是否wap网关的无聊返回,如果是则继续请求一次
            if (pRespHeader->GetValue(HH_CTYPE, sVal))
            {
                if (sVal.Find(L"text/vnd.wap.wml") >= 0)
                {
                    m_pHttpC->Request();
                    return;
                }
            }            

            sVal.Empty();
            pRespHeader->GetValue(HH_CRANGE, sVal);

            sVal.Trim();

            CMHTTPRspHeader header;
            header.SetRet(200, CMString("OK"));
            header.AddValue(HH_CTYPE, L"application/x-shockwave-flash");

            if (!sVal.IsEmpty())
            {
                INT32 nPos1 = sVal.Find(L" ");
                INT32 nPos2 = sVal.Find(L"-");
                INT32 nPos3 = sVal.Find(L"/");
                if (nPos1 <= 0 || nPos2 <= 0 || nPos3 <= 0)
                {
                    CM_ERRP("CMHttpSNotify::OnResponse wrong content-range %s", (const CHAR*)sVal);
                    goto err;
                }

                m_nStart= _mwtoi((const WCHAR*)sVal.Mid(nPos1 + 1, nPos2 - nPos1 - 1));
                m_nEnd = _mwtoi((const WCHAR*)sVal.Mid(nPos2 + 1, nPos3 - nPos2 - 1));
                m_nSize = m_nEnd - m_nStart + 1;

                if (m_nTotalSize == 0)
                {
                    //对于第一次http返回,需要返回结果给socket
                    m_nTotalSize = _mwtoi((const WCHAR*)sVal.Mid(nPos3 + 1));
                    CMString sSendSize;
                    sSendSize.Format(L"%d", m_nTotalSize);
                    header.AddValue(HH_CLENGTH, sSendSize);
                    CMString sHeader = header.ToString();

                    CM_LOGP(CM_LOGL_INFO, "%s", (const CHAR*)sHeader);

                    m_pSocketC->Send((INT8*)(const CHAR*)sHeader, sHeader.GetLength());
                }
                else
                {
                    ASSERT(m_nTotalSize == _mwtoi((const WCHAR*)sVal.Mid(nPos3 + 1)));
                    ASSERT(m_nStatus == 2);
                    ASSERT(m_nEnd - m_nStart < REQ_SIZE);

                    UINT32 nLen = m_nSize;
                    if (m_nSize > BUF_SIZE)
                    {
                        nLen = BUF_SIZE;
                    }
                    m_pHttpC->Read(m_pBuf, nLen);
                }
            }
            else
            {
                if (!pRespHeader->GetValue(HH_CLENGTH, sVal))
                {
                    CM_ERR("CMHttpSNotify::OnResponse no content-length");
                    goto err;
                }

                m_nTotalSize = 0;  //此值无效
                m_nSize = _mwtoi(sVal);

                //获取响应头成功,返回结果到Socket处
                CMString sSendSize;
                sSendSize.Format(L"%d", m_nSize);
                header.AddValue(HH_CLENGTH, sSendSize);
                CMString sHeader = header.ToString();

                CM_LOGP(CM_LOGL_INFO, "%s", (const CHAR*)sHeader);

                m_pSocketC->Send((INT8*)(const CHAR*)sHeader, sHeader.GetLength());
            }
           
            return;
        }
        else
        {
            CM_ERRP("CMHttpSNotify::OnResponse http ret %d error", httpRet);
            nRet = httpRet;
        }
    }
    else
    {
        CM_ERRP("CMHttpSNotify::OnResponse ret %d error", nCode);
        nRet = nCode;
    }

err:
    //未成功获取信息,清理,等待下次获取
    //if (m_pBuf)
    //{
    //    delete m_pBuf;
    //    m_pBuf = NULL;
    //}

    m_bInService = FALSE;

    //if (nCode == MERN_TIMEOUT)
    //{
    //    m_pSocketC->Close();
    //}
    //else
    //{
        char response[] = "HTTP/1.1 404 NOT FOUND\r\n\r\n";
        m_nSize = 0;
        m_pSocketC->Send((INT8*)response, strlen(response));
    //}

    //重置http
    m_pHttpC->Cancel();
}