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; }
void CFDMFlashVideoDownloads::ProcessHtml(LPCSTR pszHost, LPCSTR pszHtml) { vmsVideoSiteHtmlCodeParser vshcp; if (FALSE == vshcp.Parse (pszHost, pszHtml)) return; USES_CONVERSION; IWGUrlReceiverPtr spRcvr; spRcvr.CreateInstance (__uuidof (WGUrlReceiver)); spRcvr->put_Url (A2W (vshcp.get_VideoUrl ())); if (vshcp.get_IsVideoUrlDirectLink ()) { CString str = vshcp.get_VideoTitle (); str += "."; str += vshcp.get_VideoType (); spRcvr->put_FileName (A2W (str)); spRcvr->put_Comment (A2W (vshcp.get_VideoTitle ())); spRcvr->put_FlashVideoDownload (TRUE); } spRcvr->AddDownload (); }
BOOL vmsFdmWebInterfaceServer::RequestCreateNewDownload(LPCSTR pszRes, vmsHttpResponse &response) { CoInitialize (NULL); IWGUrlReceiverPtr spUrlRcvr; spUrlRcvr.CreateInstance (__uuidof (WGUrlReceiver)); ASSERT (spUrlRcvr != NULL); if (spUrlRcvr == NULL) { CoUninitialize (); _bstr_t bstrAddDownloadRes_err(m_strAddDownloadRes_err.c_str ()); response.set_Body ((const char*)bstrAddDownloadRes_err, m_strAddDownloadRes_err.length ()); return TRUE; } spUrlRcvr->put_ForceSilentEx (TRUE); spUrlRcvr->put_CheckExtension (FALSE); spUrlRcvr->put_ForceDownloadAutoStart (TRUE); spUrlRcvr->put_DisableMaliciousChecking (TRUE); spUrlRcvr->put_DisableURLExistsCheck (TRUE); CStringA strUrl; pszRes += lstrlenA ("/adddownload.req?"); if (strnicmp (pszRes, "URL=", 4)) { CoUninitialize (); _bstr_t bstrAddDownloadRes_err(m_strAddDownloadRes_err.c_str ()); response.set_Body ((const char*)bstrAddDownloadRes_err, m_strAddDownloadRes_err.length ()); return FALSE; } pszRes += 4; while (*pszRes) { char c; if (*pszRes == '%') { pszRes++; char sz [3]; sz [0] = *pszRes++; if (*pszRes == 0) return FALSE; sz [1] = *pszRes++; sz [2] = 0; int i; sscanf (sz, "%x", &i); c = (char)i; } else { c = *pszRes++; if (c == '+') c = ' '; } strUrl += c; } CString str; int i = 0; for (i = 0; i < strUrl.GetLength () - 1;) { if (strUrl [i] == '&' && strUrl [i+1] == '#') { int k = i + 2; CStringA str2; bool bHex = false; if (k < strUrl.GetLength ()) bHex = strUrl [k] == 'x'; if (bHex) k++; while (isdigit (strUrl [k])) str2 += strUrl [k++]; if (str2.IsEmpty () == FALSE && (strUrl [k] == ';' || strUrl.GetLength () == k)) { i = ++k; wchar_t wsz [2]; if (bHex) { int j; sscanf (str2, "%x", &j); wsz [0] = (wchar_t)j; } else { wsz [0] = atoi (str2); } wsz [1] = 0; char sz [2]; WideCharToMultiByte (CP_ACP, 0, wsz, -1, sz, 1, NULL, NULL); sz [1] = 0; str += sz; continue; } } str += strUrl [i++]; } if (i == strUrl.GetLength () - 1) str += strUrl [i]; strUrl = str; USES_CONVERSION; CComBSTR bstr = A2W (strUrl); spUrlRcvr->put_Url (bstr); HRESULT hr = spUrlRcvr->AddDownload (); BOOL bAdded = FALSE; if (SUCCEEDED (hr)) { CComBSTR bstrState; do { Sleep (10); spUrlRcvr->get_UIState (&bstrState); } while (bstrState == L"in_progress"); bAdded = bstrState == L"added"; } _bstr_t bstrAddDownloadRes_err(m_strAddDownloadRes_err.c_str ()); _bstr_t bstrAddDownloadRes_ok(m_strAddDownloadRes_ok.c_str ()); if (bAdded == FALSE) response.set_Body ((const char*)bstrAddDownloadRes_err, m_strAddDownloadRes_err.length ()); else response.set_Body ((const char*)bstrAddDownloadRes_ok, m_strAddDownloadRes_ok.length ()); spUrlRcvr = NULL; CoUninitialize (); return TRUE; }
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; }