예제 #1
0
PRBool CFDMForFirefox::TransferUrlToFDM(IFDMUrl *url)
{
	IWGUrlReceiverPtr spUrlRcvr;
	spUrlRcvr.CreateInstance (__uuidof (WGUrlReceiver));

	assert (spUrlRcvr != NULL);
    if (spUrlRcvr == NULL)
		return FALSE;

	if (NS_OK != CFDMUrlReceiver::ApplyUrlToReceiver (spUrlRcvr, url))
		return FALSE;

	spUrlRcvr->put_IgnoreSize (FALSE);

	if (FAILED (spUrlRcvr->ShowAddDownloadDialog ()))
		return FALSE;

	DWORD dwAllow = TRUE;
	m_keyFDMMonitor.QueryValue (dwAllow, "AllowDownload");
	if (dwAllow == FALSE)
		return TRUE;	

	BSTR bstrState = NULL;
	do {
		if (bstrState)
			SysFreeString (bstrState);
		Sleep (5);
		spUrlRcvr->get_UIState (&bstrState);
	} while (wcsicmp (bstrState, L"in_progress") == 0);

	BOOL bAdded = wcsicmp (bstrState, L"added") == 0;
	SysFreeString (bstrState);

	return bAdded;
}  
예제 #2
0
PRBool CFDMForFirefox::TransferUrlToFDM(IFDMUrl *url)
{
	assert (url != NULL);
	if (!url)
		return FALSE;

	IWGUrlReceiverPtr spUrlRcvr;
	spUrlRcvr.CreateInstance (__uuidof (WGUrlReceiver));

	assert (spUrlRcvr != NULL);
    if (spUrlRcvr == NULL)
		return FALSE;

	if (NS_OK != CFDMUrlReceiver::ApplyUrlToReceiver (spUrlRcvr, url))
		return FALSE;

	spUrlRcvr->put_IgnoreSize (FALSE);

	if (FAILED (spUrlRcvr->ShowAddDownloadDialog ()))
		return FALSE;

	IServiceProviderPtr spSP (spUrlRcvr);
	IFdmUiWindowPtr spUiWindow;
	if (spSP)
		spSP->QueryService (__uuidof (IFdmUiWindow), __uuidof (IFdmUiWindow), (void**)&spUiWindow);
	if (spUiWindow != NULL)
	{
		spUiWindow->WaitForWindowCreation (5000);
		ULONG u = 0;
		spUiWindow->get_Handle (&u);
		if (u)
		{
			SetForegroundWindow ((HWND)u);
			BringWindowToTop ((HWND)u);
		}
	}

	DWORD dwAllow = TRUE;
	m_keyFDMMonitor.QueryValue (dwAllow, "AllowDownload");
	if (dwAllow == FALSE)
		return TRUE;	

	BSTR bstrState = NULL;
	do {
		if (bstrState)
		{
			SysFreeString (bstrState);
			bstrState = NULL;
		}
		Sleep (5);
		spUrlRcvr->get_UIState (&bstrState);
		assert (bstrState != NULL);
		if (!bstrState)
			return FALSE;
	} while (wcsicmp (bstrState, L"in_progress") == 0);

	BOOL bAdded = wcsicmp (bstrState, L"added") == 0;
	SysFreeString (bstrState);

	return bAdded;
}