|
|
|
date: 21 Jun 2005 02:27:48 -0700,
group: microsoft.public.inetsdk.programming.urlmonikers
back
pdf download fails in pluggable protocol environment
Hello,
i'm trying to open an url of pdf file(prot://somethig/test.pdf) in the
pluggable environment. whenever i do that i'm getting a file download
dialog to open the pdf. if i choose adobe reader and click open then it
opens. however i want to open the pdf with in the pluggable environment
and with in the browser. This is happpening even though i'm reporting
mimetype to the ProtocolSink interface. do any one have a problem
earlier like this?
my start and read function would look like as follows:
HRESULT STDMETHODCALLTYPE CPOPPLpluggable::Start(
/* [in] */ LPCWSTR pwzUrl,
/* [in] */ IInternetProtocolSink __RPC_FAR *pOIProtSink,
/* [in] */ IInternetBindInfo __RPC_FAR *pOIBindInfo,
/* [in] */ DWORD grfPI,
/* [in] */ DWORD dwReserved)
{
USES_CONVERSION;
HRESULT hr = E_FAIL;
m_grfPI = grfPI;
m_pProtocolSink = pOIProtSink;
m_pBindInfo = pOIBindInfo;
m_pRequest = CreateRequest();
m_bindinfo.cbSize = sizeof(BINDINFO);
if (pOIBindInfo)
hr = pOIBindInfo->GetBindInfo(&m_bindf, &m_bindinfo);
// Parse URL and store results inside
hr = m_pRequest->ParseUrl((wchar_t *)pwzUrl);
if (FAILED(hr))
return hr;
if (m_grfPI & PI_PARSE_URL)
{
if (FAILED(hr))
return S_FALSE;
else
return S_OK;
}
CString strMimeType = m_pRequest->m_ContentType;
if (m_pRequest && BINDF_NEEDFILE && m_bindf &&
m_pRequest->m_Flag && strMimeType.Length() > 0)
{
LPWSTR realMime;
HRESULT hr = FindMimeFromData(0, 0,
m_pRequest->Buffer().GetBuffer(), m_pRequest->GetBufferLength(), NULL,
0, &realMime, 0);
if(FAILED(hr))
realMime = LPWSTR(strMimeType.GetBuffer());
CString strTempDir;
strTempDir = getenv("TEMP");
if (strTempDir.Length() == 0)
strTempDir = getenv("TMP");
else if (strTempDir.Length() == 0)
strTempDir = "C:\\Temp";
char strPath[100];
sprintf(strPath, "%s\\%s", strTempDir,
m_pRequest->m_FileName.Substr(1));
m_pRequest->WriteToFile(strPath);
m_pProtocolSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE,
realMime);
m_pProtocolSink->ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE,
LPCWSTR(strPath));
m_pProtocolSink->ReportData(BSCF_DATAFULLYAVAILABLE,
m_pRequest->GetBufferLength(), m_pRequest->GetBufferLength());
}
if(SUCCEEDED(hr))
{
m_pWorkerThread = new CWorkerThread(this);
m_pWorkerThread->Start();
hr = E_PENDING;
}
return hr;
}
HRESULT STDMETHODCALLTYPE CPOPPLpluggable::Read(
/* [length_is][size_is][out][in] */ void __RPC_FAR *pv,
/* [in] */ ULONG cb,
/* [out] */ ULONG __RPC_FAR *pcbRead)
{
HRESULT hr;
*pcbRead = m_pRequest->Read(pv, cb);
hr = (m_pRequest->Eof()) ? S_FALSE : S_OK;
return hr;
}
date: 21 Jun 2005 02:27:48 -0700
author: Raghavulu
|
|