Ejemplo n.º 1
0
STDMETHODIMP CWGUrlReceiver::AddDownload()
{
	
	if (m_bCheckExt && is_ExtToSkip ())
		return E_NOTIMPL;	

	if (m_bIgnoreSize == FALSE)
	{
		UINT iSize = _App.Monitor_SkipSmaller ();
		if (iSize)
		{
			USES_CONVERSION;
			fsDownloadMgr mgr (NULL);
			mgr.CreateByUrl (W2T (m_dlInfo.bstrUrl), TRUE);
			mgr.QuerySize ();
			UINT64 uSize = mgr.GetDownloader ()->GetSSFileSize ();
			if (iSize >= uSize)
				return E_NOTIMPL;	
		}
	}

	CheckYouTubePicture();
	StartJobThread (_threadAddDownload);
	return S_OK;
}
Ejemplo n.º 2
0
BOOL fsUrlToFdm (LPCSTR pszUrl, LPCSTR pszReferer, LPCSTR pszCookies, LPCSTR pszPostData, BOOL bUseSkipExtsList)
{
	if (is_ServerToSkip (pszUrl))
		return FALSE;

	if (pszReferer && is_ServerToSkip (pszReferer))
		return FALSE;

	if (is_ExtToSkip (pszUrl, bUseSkipExtsList))
		return FALSE;

	fsURL urlH;
	if (IR_SUCCESS != urlH.Crack (pszUrl))
		return FALSE;
	LPCSTR pszHost = urlH.GetHostName ();
	if (stricmp (pszHost, "megashares.com") == 0 ||
		(strlen (pszHost) > sizeof ("megashares.com") && stricmp (pszHost+strlen (pszHost)-sizeof("megashares.com"), ".megashares.com") == 0))
	{
		pszReferer = "";
	}

	IWGUrlReceiver* wg;
	HRESULT hr;
	if (FAILED (hr=CoCreateInstance (CLSID_WGUrlReceiver, NULL, CLSCTX_ALL, IID_IWGUrlReceiver, (void**) &wg)))
	{
		char szMsg [1000];
		lstrcpy (szMsg, "Free Download Manager is not properly installed! Please reinstall Free Download Manager or try to reboot your PC.\n\nError code: 0x");
		char sz [100];
		itoa ((UINT)hr, sz, 16);
		lstrcat (szMsg, sz);
		MessageBox (NULL, szMsg, "Error", MB_ICONERROR);
		return FALSE;
	}

	wg->put_IgnoreSize (FALSE);

	_bstr_t url = pszUrl;
	wg->put_Url (url);
	if (pszCookies)
	{
		_bstr_t cookies = pszCookies;
		wg->put_Cookies (cookies);
	}
	if (pszReferer)
	{
		_bstr_t referer = pszReferer;
		wg->put_Referer (referer);
	}
	if (pszPostData)
	{
		_bstr_t ah = pszPostData;
		wg->put_PostData (ah);
	}
	wg->put_CheckExtension (FALSE);
	hr = wg->AddDownload ();

	if (FAILED (hr))
		return FALSE;

	CRegKey wgKey;
	if (ERROR_SUCCESS == wgKey.Open (HKEY_CURRENT_USER, "Software\\FreeDownloadManager.ORG\\Free Download Manager\\Settings\\Monitor", KEY_READ))
	{
		DWORD b = FALSE;
		if (ERROR_SUCCESS != wgKey.QueryValue (b, "AllowDownload"))
			b = TRUE;
		if (b == FALSE)	
		{
			wg->Release ();
			return TRUE;
		}
	}
	
	CComBSTR bstrState;
	do {
		Sleep (10);
		wg->get_UIState (&bstrState);
	} while (bstrState == L"in_progress");

	wg->Release ();

	return bstrState == L"added";
}