Beispiel #1
0
BOOL CDlgDL::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_dldr.CreateByUrl (m_strUrl, TRUE);

	fsDownload_Properties *dp = m_dldr.GetDP ();
	fsDownload_NetworkProperties *dnp = m_dldr.GetDNP ();
	
	SAFE_DELETE_ARRAY (dp->pszFileName);
	fsnew (dp->pszFileName, TCHAR, m_strFile.GetLength () + 1);
	_tcscpy (dp->pszFileName, m_strFile);
	dp->uMaxSections = 1;
	dp->uMaxAttempts = 1;
	dp->dwFlags |= DPF_DONTRESTARTIFNORESUME;
	dp->enSCR = SCR_STOP;
	dp->enAER = AER_REWRITE;
	*dp->pszAdditionalExt = 0;
	
	SAFE_DELETE_ARRAY (dnp->pszReferer);
	fsnew (dnp->pszReferer, TCHAR, 1);
	*dnp->pszReferer = 0;

	m_dldr.StartDownloading ();

	SetTimer (1, 200, NULL);

	SetDlgItemText (IDC__MSG, m_strDlName);

	SetWindowText (LS (L_PLEASEWAIT));
	
	return TRUE;  
	              
}
void fsPluginMgr::OnNewLng(LPCSTR )
{
    for (int i = 0; i < m_vWndPlugs.size (); i++)
    {
        fsPluginInfo *plug = &m_vWndPlugs [i];
        LPCSTR pszLongName, pszShortName;

        if (plug->pfnSetLanguage)
            plug->pfnSetLanguage (WGL_UNKNOWN, plug->hMenuMain, plug->hMenuView);



        plug->pfnGPN (&pszLongName, &pszShortName);
        plug->pfnGMVI (&plug->pMenuViewItems, &plug->cMenuViewItems);

        plug->strLongName = pszLongName;
        plug->strName = pszShortName;

        wgTButtonInfo* pButtons;
        int cButtons;
        plug->pfnGTBI (&pButtons, &cButtons);

        LPCSTR *ppszToolTips;
        fsnew (ppszToolTips, LPCSTR, cButtons);
        for (int j = 0; j < cButtons; j++)
            ppszToolTips [j] = pButtons [j].pszToolTip;

        _TBMgr.UpdateGroupToolTips (i+1, ppszToolTips, cButtons);

        delete [] ppszToolTips;
    }
}
Beispiel #3
0
BOOL fsRASMgr::EnumEntries()
{
	LPRASENTRYNAME pREN;
	fsnew (pREN, RASENTRYNAME, 1);
	UINT nRet;
	ULONG cb = sizeof(RASENTRYNAME);
	ULONG cEntries;

	pREN->dwSize = sizeof(RASENTRYNAME);

	nRet = fsRasEnumEntries (NULL, NULL, pREN, &cb, &cEntries);
	
	if (nRet)
	{
		delete [] pREN;

		if (nRet == ERROR_BUFFER_TOO_SMALL)
		{
			BYTE *pb;
			fsnew (pb, BYTE, cb);
			pREN = (LPRASENTRYNAME) pb; 
			pREN->dwSize = sizeof(RASENTRYNAME);

			
			nRet = fsRasEnumEntries (NULL, NULL, pREN, &cb, &cEntries);

			if (nRet != ERROR_SUCCESS)
			{
				delete [] pREN;
				return FALSE;
			}
		}
		else
		{
			return FALSE;
		}
	}
 
	m_vEntries.clear ();

    for (UINT i=0; i < cEntries; i++)
          m_vEntries.add (pREN [i].szEntryName);

	delete [] pREN;

	return TRUE;
}
Beispiel #4
0
BOOL fsRASMgr::EnumConnections()
{
	LPRASCONN pRC;
	fsnew (pRC, RASCONN, 1);
	DWORD sz = sizeof (RASCONN);
	DWORD cConns;

	pRC->dwSize = sizeof (RASCONN);

	DWORD dwRet = fsRasEnumConnections (pRC, &sz, &cConns);

	if (dwRet != ERROR_SUCCESS)
	{
		delete [] pRC;

		if (dwRet == ERROR_BUFFER_TOO_SMALL)
		{
			BYTE *pb;
			fsnew (pb, BYTE, sz);
			pRC = (LPRASCONN) pb; 
			pRC->dwSize = sizeof (RASCONN);
			dwRet = fsRasEnumConnections (pRC, &sz, &cConns);

			if (dwRet != ERROR_SUCCESS)
			{
				delete [] pRC;
				return FALSE;
			}
		}
		else
		{
			return FALSE;
		}
	}

	m_vConns.clear ();

	for (DWORD i = 0; i < cConns; i++)
		m_vConns.add (pRC [i]);

	delete [] pRC;

	return TRUE;
}
void fsHttpFile::SetCookies(LPCSTR pszCookies)
{
	SAFE_DELETE_ARRAY (m_pszCookies);

	if (pszCookies && *pszCookies)
	{
		fsnew (m_pszCookies, CHAR, lstrlen (pszCookies) + 1);
		lstrcpy (m_pszCookies, pszCookies);
	}
}
void fsHttpFile::SetPostData(LPCSTR pszPostData)
{
	SAFE_DELETE_ARRAY (m_pszPostData);

	if (pszPostData && *pszPostData)
	{
		fsnew (m_pszPostData, CHAR, lstrlen (pszPostData) + 1);
		lstrcpy (m_pszPostData, pszPostData);
	}
}
void fsHttpFile::SetReferer(LPCSTR pszReferer)
{
	SAFE_DELETE_ARRAY (m_pszReferer);

	if (pszReferer)
	{
		fsnew (m_pszReferer, CHAR, strlen (pszReferer) + 1);
		strcpy (m_pszReferer, pszReferer);
	}
}
void fsTrayIconMgr::LoadIcons(UINT *pIcons, UINT cIcons)
{
	if (m_pIcons)
		delete [] m_pIcons;

	fsnew (m_pIcons, HICON, cIcons);
	m_cIcons = cIcons;

	for (UINT i = 0; i < cIcons; i++)
		m_pIcons [i] = SICOEX (pIcons [i], 16, 16);
}
Beispiel #9
0
std::wstring loadStringFromBufferW( LPBYTE& pB, DWORD dw ){
	if ( dw == 0 )
		return std::wstring();
	LPWSTR szStr;
	fsnew (szStr, WCHAR, dw+1);
	CopyMemory (szStr, pB, dw * sizeof(WCHAR));	
	szStr[dw] = 0;				
	pB += dw * sizeof(WCHAR);
	std::wstring res = szStr;
	delete szStr;
	return res;
}
Beispiel #10
0
static Obj oparse(FILE* const file)
{
    const int lines = flns(file);
    const int size = 128;
    Vertices vsv = vsnew(size);
    Vertices vsn = vsnew(size);
    Vertices vst = vsnew(size);
    Faces fs = fsnew(size);
    for(int i = 0; i < lines; i++)
    {
        Face f;
        Vertex v;
        char* line = freadln(file);
        if(line[0] == 'v' && line[1] == 'n')
        {
            if(vsn.count == vsn.max)
                vsn.vertex = (Vertex*) realloc(vsn.vertex, sizeof(Vertex) * (vsn.max *= 2));
            sscanf(line, "vn %f %f %f", &v.x, &v.y, &v.z);
            vsn.vertex[vsn.count++] = v;
        }
        else if(line[0] == 'v' && line[1] == 't')
        {
            if(vst.count == vst.max)
                vst.vertex = (Vertex*) realloc(vst.vertex, sizeof(Vertex) * (vst.max *= 2));
            sscanf(line, "vt %f %f %f", &v.x, &v.y, &v.z);
            vst.vertex[vst.count++] = v;
        }
        else if(line[0] == 'v')
        {
            if(vsv.count == vsv.max)
                vsv.vertex = (Vertex*) realloc(vsv.vertex, sizeof(Vertex) * (vsv.max *= 2));
            sscanf(line, "v %f %f %f", &v.x, &v.y, &v.z);
            vsv.vertex[vsv.count++] = v;
        }
        else if(line[0] == 'f')
        {
            if(fs.count == fs.max)
                fs.face = (Face*) realloc(fs.face, sizeof(Face) * (fs.max *= 2));
            sscanf(line, "f %d/%d/%d %d/%d/%d %d/%d/%d", &f.va, &f.ta, &f.na, &f.vb, &f.tb, &f.nb, &f.vc, &f.tc, &f.nc);
            const Face indexed = {
                f.va - 1, f.vb - 1, f.vc - 1,
                f.ta - 1, f.tb - 1, f.tc - 1,
                f.na - 1, f.nb - 1, f.nc - 1
            };
            fs.face[fs.count++] = indexed;
        }
        free(line);
    }
    rewind(file);
    const Obj obj = { vsv, vsn, vst, fs };
    return obj;
}
Beispiel #11
0
BOOL CCreateBatchDownload::ReadAuth()
{
	CString strUser, strPassword;

	if (IsDlgButtonChecked (IDC_USELOGIN) == BST_CHECKED)
	{
		GetDlgItemText (IDC_USER, strUser);
		GetDlgItemText (IDC_PASSWORD, strPassword);

		if (strUser.GetLength () == 0)
		{
			MessageBox (LS (L_ENTERUSER), LS (L_INPERR), MB_ICONEXCLAMATION);
			GetDlgItem (IDC_USER)->SetFocus ();
			return FALSE;
		}
	}
	else
	{
		fsURL url;
		url.Crack (m_strUrl);
		strUser = url.GetUserName ();
		strPassword = url.GetPassword ();
	}

	if (strUser != "")
	{
		fsDownload_NetworkProperties *dnp = m_dld->pMgr->GetDownloadMgr ()->GetDNP ();
		
		SAFE_DELETE_ARRAY (dnp->pszUserName);
		SAFE_DELETE_ARRAY (dnp->pszPassword);

		fsnew (dnp->pszUserName, CHAR, strUser.GetLength ()+1);
		fsnew (dnp->pszPassword, CHAR, strPassword.GetLength ()+1);
		strcpy (dnp->pszUserName, strUser);
		strcpy (dnp->pszPassword, strPassword);
	}

	return TRUE;
}
Beispiel #12
0
void fsUpdateMgr::Update(BOOL bByFull)
{
	if (m_bRunning == FALSE || m_bChecking)
		return;

	SAFE_DELETE (m_dldr);
	fsnew1 (m_dldr, fsDownloadMgr (NULL));
	m_dldr->SetEventFunc (_DownloadMgrEvents, this);
	m_dldr->SetEventDescFunc (_DownloadMgrDescEvents, this);

	m_bChecking = FALSE;

	CString strUrl;	
	if (bByFull)
		strUrl.Format (_T("%sfdminst.exe"), m_strDlFullInstallPath);
	else
	{
		
		if (m_strUpgFileName.GetLength () == 0)
			
			strUrl.Format (_T("%sfdm%sto%supg.exe"), m_strDlUpgradesPath, vmsFdmAppMgr::getBuildNumberAsString (), m_strBN);
		else
			
			strUrl.Format (_T("%s%s"), m_strDlUpgradesPath, m_strUpgFileName);
	}

	m_dldr->CreateByUrl (strUrl);
	
	fsDownload_Properties *dp = m_dldr->GetDP ();
	fsDownload_NetworkProperties *dnp = m_dldr->GetDNP ();

	SAFE_DELETE_ARRAY (dp->pszFileName);
	CString strFile = fsGetDataFilePath (_T("Update\\"));
	fsnew (dp->pszFileName, TCHAR, strFile.GetLength () + 1);
	_tcscpy (dp->pszFileName, strFile);
	dp->enAER = AER_REWRITE;
	dp->uMaxAttempts = 1;
	*dp->pszAdditionalExt = 0;

	dnp->dwFlags &= ~DNPF_RESTARTSECTIONWHENSPEEDTOOLOW;

	Event (UME_CONNECTING);

	m_dldr->StartDownloading ();
}
void fsHttpFile::SetAdditionalHeaders(LPCSTR pszAdditionalHeaders)
{
	SAFE_DELETE_ARRAY (m_pszAdditionalHeaders);

	if (pszAdditionalHeaders && *pszAdditionalHeaders)
	{
		
		int l = lstrlen (pszAdditionalHeaders);
		if (l < 2)
			return;
		if (pszAdditionalHeaders [l - 2] != '\r')
			return;
		if (pszAdditionalHeaders [l - 1] != '\n')
			return;

		fsnew (m_pszAdditionalHeaders, CHAR, lstrlen (pszAdditionalHeaders) + 1);
		lstrcpy (m_pszAdditionalHeaders, pszAdditionalHeaders);
	}
}
Beispiel #14
0
void fsUpdateMgr::CheckForUpdate(bool bByUser)
{
	if (m_bRunning || IS_PORTABLE_MODE)
		return;

	m_bCheckingByUser = bByUser;

	SAFE_DELETE (m_dldr);
	fsnew1 (m_dldr, fsDownloadMgr (NULL));
	m_dldr->SetEventFunc (_DownloadMgrEvents, this);
	m_dldr->SetEventDescFunc (_DownloadMgrDescEvents, this);
	
	m_bRunning = TRUE;
	m_bChecking = TRUE;

	CMainFrame* pFrm = (CMainFrame*) AfxGetApp ()->m_pMainWnd;

	CString strUrl = m_strUpdateUrl;

	strUrl += _T("proupd3.lst");

	if (!_App.Update_CheckedOnce ())
		strUrl += _T ("?initial");

	std::wstring Customizer = pFrm->get_Customizations ()->get_Customizer () ? 
		wideFromUtf8 (pFrm->get_Customizations ()->get_Customizer ()) : 
		L"";
	if (!Customizer.empty ())
	{
		strUrl += _T("?edition=");
		strUrl += Customizer.c_str ();
	}

	m_dldr->CreateByUrl (strUrl);
	
	fsDownload_Properties *dp = m_dldr->GetDP ();
	fsDownload_NetworkProperties *dnp = m_dldr->GetDNP ();

	SAFE_DELETE_ARRAY (dp->pszFileName);
	CString strFile = fsGetDataFilePath (_T("Update\\"));	
	fsnew (dp->pszFileName, TCHAR, strFile.GetLength () + 1);
	_tcscpy (dp->pszFileName, strFile);
	dp->uMaxSections = 1;
	dp->uMaxAttempts = 1;
	dp->dwFlags |= DPF_DONTRESTARTIFNORESUME | DPF_FORCE_NO_RECOVERY;
	dp->enSCR = SCR_STOP;
	dp->enAER = AER_REWRITE;
	*dp->pszAdditionalExt = 0;

	SAFE_DELETE_ARRAY (dnp->pszReferer);

	fsnew (dnp->pszReferer, TCHAR, 100);
	_stprintf (dnp->pszReferer, _T("fdm:version:%s"), 
		vmsFdmAppMgr::getVersion ()->m_fileVersion.ToString ().c_str ());

	dnp->dwFlags &= ~DNPF_RESTARTSECTIONWHENSPEEDTOOLOW;

	Event (UME_CONNECTING);

	m_dldr->StartDownloading ();
}
Beispiel #15
0
void CCreateBatchDownload::OnOK() 
{
	if (FALSE == ReadAuth ())
		return;

	if (FALSE == BuildBatchList ())
		return;

	CString strSaveAs;
	if (IsDlgButtonChecked (IDC_FILEAUTO) == BST_UNCHECKED)
	{
		GetDlgItemText (IDC_SAVEAS, strSaveAs);
	}

	if (strSaveAs != "")
	{
		CString strNumbers;
		GetDlgItemText (IDC_NUMBERS, strNumbers);

		m_blSaveAs.Create (strSaveAs, strNumbers, (char)('A' + m_iAlphaFrom), 
			(char)('A' + m_iAlphaTo));

		if (m_bl.get_ResultCount () != m_blSaveAs.get_ResultCount ())
		{
			MessageBox (LS (L_INVALID_SAVE_AS_TEMPLATE), LS (L_INPERR), MB_ICONERROR);
			GetDlgItem (IDC_SAVEAS)->SetFocus ();
			return;
		}

		if (strcspn (m_blSaveAs.get_Result (0), "\\/:*?\"<>|") != strlen (m_blSaveAs.get_Result (0)))
		{
			MessageBox (LS (L_INVFILENAME), LS (L_INPERR), MB_ICONEXCLAMATION);
			GetDlgItem (IDC_SAVEAS)->SetFocus ();
			return;
		}
	}
	else {
		m_blSaveAs.Clear ();
	}

	BOOL bUseZipPreview = _App.NewDL_UseZIPPreview ();

	if (bUseZipPreview)
		m_dld->pMgr->GetDownloadMgr ()->GetDP ()->dwFlags |= DPF_USEZIPPREVIEW;
	else
		m_dld->pMgr->GetDownloadMgr ()->GetDP ()->dwFlags &= ~DPF_USEZIPPREVIEW;

	CString strOutFolder;

	if (FALSE == CCreateDownloadDlg::_CheckFolderName (this, IDC_OUTFOLDER))
		return;

	GetDlgItemText (IDC_OUTFOLDER, strOutFolder);

	fsPathToGoodPath ((LPSTR)(LPCSTR)strOutFolder);

	if (strOutFolder.GetLength () == 0)
	{
		MessageBox (LS (L_ENTERFLRNAME), LS (L_INPERR), MB_ICONEXCLAMATION);
		GetDlgItem (IDC_OUTFOLDER)->SetFocus ();
		return;
	}

	_LastFolders.AddRecord (strOutFolder);
	_LastBatchUrls.AddRecord (m_strUrl);

	if (strOutFolder [strOutFolder.GetLength () - 1] != '\\' && 
		strOutFolder [strOutFolder.GetLength () - 1] != '/')
		strOutFolder += '\\';

        if (_App.NewGrp_SelectWay () == NGSW_USE_ALWAYS_SAME_GROUP_WITH_OUTFOLDER_AUTO_UPDATE)
	{
		vmsDownloadsGroupSmartPtr pGrp = _DldsGrps.FindGroup (_App.NewDL_GroupId ());
		if (pGrp != NULL) {
			pGrp->strOutFolder = strOutFolder;
			pGrp->setDirty();
			
			
			
		}
	}

	fsnew (m_dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName, CHAR, strOutFolder.GetLength () + 1);
	strcpy (m_dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName, strOutFolder);

	m_dld->pGroup = m_wndGroups.GetSelectedGroup ();

	m_wndGroups.RememberSelectedGroup ();
	
	_App.Last_Autostart (m_iAutostart);

	GenerateAndAddDownloads ();	

	
	_App.CreateBD_LastAtoZ (MAKELPARAM (m_wndA.GetCurSel (), m_wndZ.GetCurSel ()));
	CString str;
	GetDlgItemText (IDC_NUMBERS, str);
	_App.CreateBD_LastNumbers (str);
	_App.CreateBD_SaveAs_Template (strSaveAs);

	if (m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszUserName && *m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszUserName)
	{
		fsURL url;
		url.Crack (m_strUrl);
		LPCSTR pszServer = url.GetHostName ();
		if (strstr (pszServer, "(*)") == NULL &&
			strstr (pszServer, "(*a)") == NULL &&
			strstr (pszServer, "(*A)") == NULL)
		{
			CCreateDownloadDlg::_SavePassword (pszServer, fsSchemeToNP (url.GetInternetScheme ()),
				m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszUserName, m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszPassword);
		}
	}

	_App.OnDlHasBeenCreatedByUser ();

	CDialog::OnOK();
}
	bool fsDownload::loadObjectItselfFromStateBuffer(LPBYTE pb, LPDWORD pdwSize, DWORD dwVer)
	{
#define CHECK_BOUNDS(need) if (need < 0 || need > int(*pdwSize) - (pB - LPBYTE (pb))) return false;
	
	LPBYTE pB = LPBYTE (pb);
	DWORD dw = *pdwSize;
	LPSTR szStr;
	int iReserved;

	
	
	CHECK_BOUNDS (sizeof (DWORD));
	pB += sizeof (DWORD);

	if (pMgr == 0)
		return false;

	CHECK_BOUNDS (sizeof (BYTE));
	BYTE btType = *pB++;
	switch (btType) {
		case 0:
			{
				fsDownloadMgr* pdmMgr = new fsDownloadMgr();
				pMgr->Attach (pdmMgr);
			}
			break;
		case 1:
			{
				vmsBtDownloadManagerPtr spMgr; spMgr.CreateInstance ();
				pMgr->Attach (spMgr);
			}
			break;
		case 2:
			{
				vmsTpDownloadMgr* ptdmMgr = new vmsTpDownloadMgr();
				pMgr->Attach (ptdmMgr);
			}
			break;
		default:
			return false;
	}

	CHECK_BOUNDS (sizeof (bAutoStart));
	CopyMemory (&bAutoStart, pB, sizeof (bAutoStart));
	pB += sizeof (bAutoStart);

	CHECK_BOUNDS (sizeof (iReserved));

	CopyMemory (&iReserved, pB, sizeof (iReserved));
	pB += sizeof (iReserved);

	CHECK_BOUNDS (sizeof (nID));

	CopyMemory (&nID, pB, sizeof (nID));
	pB += sizeof (nID);

	CHECK_BOUNDS (sizeof (dw));

	CopyMemory (&dw, pB, sizeof (dw));
	CHECK_BOUNDS (int (dw));
	pB += sizeof (dw); fsnew (szStr, CHAR, dw+1);
	CopyMemory (szStr, pB, dw);
	szStr [dw] = 0; strComment = szStr; delete [] szStr;
	pB += dw;

	if (dwVer < 9)
	{
		CHECK_BOUNDS (sizeof (dw));

		CopyMemory (&dw, pB, sizeof (dw));
		CHECK_BOUNDS (int (dw));
		pB += sizeof (dw); fsnew (szStr, CHAR, dw+1);
		CopyMemory (szStr, pB, dw);
		szStr [dw] = 0; 
		pGroup = _DldsGrps.FindGroupByName (szStr);
		delete [] szStr;
		pB += dw;
	}
	else
	{
		UINT nGrpId;
		CHECK_BOUNDS (sizeof (UINT));
		CopyMemory (&nGrpId, pB, sizeof (UINT));
		pB += sizeof (UINT);
		pGroup = _DldsGrps.FindGroup (nGrpId);
	}

	if (pGroup == NULL)
		pGroup = _DldsGrps.FindGroup (GRP_OTHER_ID);

	CHECK_BOUNDS (sizeof (dwFlags));
	CopyMemory (&dwFlags, pB, sizeof (dwFlags));
	pB += sizeof (dwFlags);

	CHECK_BOUNDS (sizeof (dwReserved));
	CopyMemory (&dwReserved, pB, sizeof (dwReserved));
	pB += sizeof (dwReserved);

	CHECK_BOUNDS (sizeof (dateAdded));
	CopyMemory (&dateAdded, pB, sizeof (dateAdded));
	pB += sizeof (dateAdded);

	if (dwVer >= 15)
	{
		CHECK_BOUNDS (sizeof (dateCompleted));
		CopyMemory (&dateCompleted, pB, sizeof (dateCompleted));
		pB += sizeof (dateCompleted);
	}
	
	DWORD cEvents;
	CHECK_BOUNDS (sizeof (cEvents));
	CopyMemory (&cEvents, pB, sizeof (cEvents));
	pB += sizeof (cEvents);

	vEvents.clear ();

	while (cEvents--)
	{
		fsDownloadEvents ev;

		CHECK_BOUNDS (sizeof (ev.clrBg));
		
		CopyMemory (&ev.clrBg, pB, sizeof (ev.clrBg));
		pB += sizeof (ev.clrBg);

		CHECK_BOUNDS (sizeof (ev.clrText));

		CopyMemory (&ev.clrText, pB, sizeof (ev.clrText));
		pB += sizeof (ev.clrText);

		CHECK_BOUNDS (sizeof (ev.timeEvent));

		CopyMemory (&ev.timeEvent, pB, sizeof (ev.timeEvent));
		pB += sizeof (ev.timeEvent);

		CHECK_BOUNDS (sizeof (ev.iImage));

		CopyMemory (&ev.iImage, pB, sizeof (ev.iImage));
		pB += sizeof (ev.iImage);

		CHECK_BOUNDS (sizeof (dw));

		CopyMemory (&dw, pB, sizeof (dw));
		CHECK_BOUNDS (int (dw));
		pB += sizeof (dw); fsnew (szStr, CHAR, dw+1);
		CopyMemory (szStr, pB, dw);
		szStr [dw] = 0; ev.strEvent = szStr; delete [] szStr;
		pB += dw;

		vEvents.add (ev);
	}

	*pdwSize = pB - LPBYTE (pb);
	
	return true;
	}
void vmsTpDownloadMgr::RenameFile(BOOL bFormat1)
{
	int i = 1;
	DWORD dwResult;
	CHAR szFileWE [MY_MAX_PATH]; 
	CString strFile;

	

	strcpy (szFileWE, m_info.strOutputPath + m_info.strFileName);

	LPSTR pszExt = strrchr (szFileWE, '.');	
	LPSTR pszDirEnd = strrchr (szFileWE, '\\');	

	if (pszExt != NULL && pszDirEnd > pszExt)
		pszExt = NULL;	

	if (pszExt)
		*pszExt = 0;	

	if (m_bRename_CheckIfRenamed)
	{
		int l = lstrlen (szFileWE);
		if (szFileWE [l-1] == ')')
		{
			LPSTR psz = szFileWE + l - 2;
			while (*psz && *psz >= '0' && *psz <= '9')
				psz--;
			if (*psz == '(')
				
				
				*psz = 0;
		}
	}

	
	
	do
	{
		if (pszExt)
			strFile.Format ("%s(%d).%s", szFileWE, i++, pszExt+1);
		else
			strFile.Format ("%s(%d)", szFileWE, i++);

		dwResult = GetFileAttributes (strFile);
	}
	while (dwResult != DWORD (-1));

	char* szFileNameNew;
	fsnew (szFileNameNew, CHAR, strFile.GetLength () + 1);
	strcpy (szFileNameNew, strFile);
	
	HANDLE hFile = CreateFile (szFileNameNew, GENERIC_WRITE, 0, NULL, 
		CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hFile != INVALID_HANDLE_VALUE)
		CloseHandle (hFile);

	
	CHAR szFileName [MY_MAX_PATH];
	fsGetFileName (strFile, szFileName);
	CString strEv;
	if (bFormat1)
		strEv.Format ("%s \"%s\"", LS (L_FILEALREXISTSRENAMING), szFileName);
	else
		strEv.Format ("%s %s", LS (L_RENAMINGTO), szFileName);

	m_info.strFileName = szFileName;
	
	setDirty();

	RaiseEvent (strEv, EDT_WARNING);
	RaiseEvent (DE_EXTERROR, DMEE_FILEUPDATED);
}
fsInternetResult CCreateTPDownloadDlg::Crack(LPCSTR pszUrl)
{
	CHAR m_szScheme [URL_SCHEME_SIZE];	
	CHAR m_szHost [URL_HOSTNAME_SIZE];	
	CHAR m_szUser [URL_USERNAME_SIZE];	
	CHAR m_szPassword [URL_PASSWORD_SIZE];	
	CHAR m_szPath [URL_PATH_SIZE];		

	DWORD urlLen = strlen (pszUrl) * 2;
	CHAR *pszCanUrl = NULL;
	fsString strUrl;

	
	if (*pszUrl == '"' || *pszUrl == '\'')
	{
		
		
		strUrl = pszUrl + 1;
		if (strUrl [0] == 0)
			return IR_BADURL;
		strUrl [strUrl.Length () - 1] = 0;
		m_strUrl = pszUrl = strUrl;
	}

	fsnew (pszCanUrl, CHAR, urlLen);

	
	if (!InternetCanonicalizeUrl (pszUrl, pszCanUrl, &urlLen, ICU_BROWSER_MODE))
	{
		delete pszCanUrl;

		if (GetLastError () == ERROR_INSUFFICIENT_BUFFER)
		{
			fsnew (pszCanUrl, CHAR, urlLen+1);
			if (!InternetCanonicalizeUrl (pszUrl, pszCanUrl, &urlLen, ICU_BROWSER_MODE))
			{
				delete pszCanUrl;
				return fsWinInetErrorToIR ();
			}
		}
		else
		return fsWinInetErrorToIR ();
	}

	URL_COMPONENTS m_url;
	ZeroMemory (&m_url, sizeof (m_url));
	m_url.dwStructSize = sizeof (m_url);

	m_url.lpszHostName = m_szHost;
	m_url.lpszPassword = m_szPassword;
	m_url.lpszScheme = m_szScheme;
	m_url.lpszUrlPath = m_szPath;
	m_url.lpszUserName = m_szUser;

	m_url.dwHostNameLength = URL_HOSTNAME_SIZE;
	m_url.dwPasswordLength = URL_PASSWORD_SIZE;
	m_url.dwSchemeLength = URL_SCHEME_SIZE;
	m_url.dwUrlPathLength = URL_PATH_SIZE;
	m_url.dwUserNameLength = URL_USERNAME_SIZE;

	if (!InternetCrackUrl (pszCanUrl, urlLen, 0, &m_url))
	{
		delete pszCanUrl;
		return fsWinInetErrorToIR ();
	}

	delete pszCanUrl;

	if (strstr (m_url.lpszScheme, "mmsh") == NULL 
		&& strstr (m_url.lpszScheme, "mmst") == NULL
		&& strstr (m_url.lpszScheme, "mms") == NULL
		&& strstr (m_url.lpszScheme, "rtsp") == NULL
		|| m_url.dwHostNameLength == 0)
		return IR_BADURL;

	return IR_SUCCESS;
}