void vmsTrafficUsageModeMgr::CheckNeedResetAllSpeedsInfo(void)
{
	if (!(m_dwState & TUMM_SPEEDS_INFO_CAN_BE_INCORRECT))
		return;

	bool bAllUsesCurrentAdapter = true;

	vmsAUTOLOCKSECTION (m_csManageForSpeed);

	for (size_t i = 0; bAllUsesCurrentAdapter && i < m_vpManageForSpeed.size (); i++)
	{
		ManageForSpeedItemsList *pList = m_vpManageForSpeed [i];

		for (size_t j = 0; bAllUsesCurrentAdapter && j < pList->vItems.size (); j++)
		{
			if (pList->vItems [j].state & ManageForSpeedItem::MSIS_MAY_USE_NOT_CURRENT_ADAPTER)
				bAllUsesCurrentAdapter = false;
		}
	}

	vmsAUTOLOCKSECTION_UNLOCK (m_csManageForSpeed);

	if (!bAllUsesCurrentAdapter)
		return;

	vmsAUTOLOCKSECTION (m_csMisc);
	m_dwState &= ~TUMM_SPEEDS_INFO_CAN_BE_INCORRECT;
	vmsAUTOLOCKSECTION_UNLOCK (m_csMisc);

	ResetAllSpeedsInfo ();
	ReadCurrentAdapterInfo ();
}
void vmsTrafficUsageModeMgr::CheckIfBestInterfaceChanged ()
{
	vmsIpHelper iph;
	if (!iph.GetAdaptersInfo ())
		return;

	DWORD dwIfIndex;
	if (NO_ERROR != GetBestInterface (inet_addr ("8.8.8.8"), &dwIfIndex))
		return;

	PIP_ADAPTER_INFO pAdapter = iph.FindAdapterByIfIndex (dwIfIndex);
	if (!pAdapter)
		return;

	if (pAdapter->IpAddressList.IpAddress.String == m_strCurrentIP)
		return;

	if (!(m_dwState & TUMM_SPEEDS_INFO_CAN_BE_INCORRECT))
		SaveCurrentAdapterInfo ();

	std::string strAdapterAddress;
	for (UINT i = 0; i < pAdapter->AddressLength; i++)
	{
		char sz [10];
		itoa (pAdapter->Address [i], sz, 16);
		if (sz [1] == 0)
			strAdapterAddress += '0';
		strAdapterAddress += sz;
	}

	m_strCurrentAdapterAddress = strAdapterAddress;
	m_strCurrentIP = pAdapter->IpAddressList.IpAddress.String;

	vmsAUTOLOCKSECTION (m_csMisc);
	m_dwState |= TUMM_SPEEDS_INFO_CAN_BE_INCORRECT;
	vmsAUTOLOCKSECTION_UNLOCK (m_csMisc);

	vmsAUTOLOCKSECTION (m_csManageForSpeed);
	
	for (size_t i = 0; i < m_vpManageForSpeed.size (); i++)
	{
		ManageForSpeedItemsList *pList = m_vpManageForSpeed [i];

		for (size_t j = 0; j < pList->vItems.size (); j++)
			pList->vItems [j].state |= ManageForSpeedItem::MSIS_MAY_USE_NOT_CURRENT_ADAPTER;
	}
	vmsAUTOLOCKSECTION_UNLOCK (m_csManageForSpeed);

	ResetAllSpeedsInfo ();
}
Example #3
0
void vmsBtSessionImpl::RestoreDownloadHandle (vmsBtDownloadImpl* dld)
{
	vmsAUTOLOCKSECTION (m_csRestoreTorrentHandle);

	if (dld == NULL || dld->GetHandle().is_valid ())
		return;

	try 
	{
		vmsBtFileImplPtr dldImpl = dld->GetTorrentImpl();
		if (dldImpl == NULL || dldImpl->m_torrent == NULL)
		{
			return;
		}
		libtorrent::torrent_handle& handleLink = dld->GetHandle();
		handleLink = m_session.add_torrent(*dldImpl->m_torrent, dld->GetOutputPath());
		dld->GetHandle().pause();
	}
	catch (...) 
	{
		return;
	}

	vmsAUTOLOCKSECTION_UNLOCK (m_csRestoreTorrentHandle);

	if (m_pfnEvHandler)
	{
		vmsBtSessionEvent ev;
		ev.enType = BTSET_BTDLD_WAS_RESET;
		ev.pDownload = dld;
		ev.pszMsg = NULL;
		m_pfnEvHandler (this, &ev, m_pEvData);
	}
}
void vmsTrafficUsageModeMgr::setTUM(fsTUM tum, bool bByUser)
{
	if (GetTUM () != tum)
	{
		vmsAUTOLOCKSECTION (m_csMisc);
		m_cSecondsNoSpeedMeasure = 7;
		vmsAUTOLOCKSECTION_UNLOCK (m_csMisc);
		if (bByUser)
			m_enUserTUM = tum;
		m_enCurrentTUM = tum;
		BuildCurrentSettings ();
	}
}
Example #5
0
void fsSitesMgr::CheckGroups()
{
    std::vector <fsSiteInfoPtr> v;

    vmsAUTOLOCKSECTION (m_csSites);

    for (int i = m_vSites.size () - 1; i >= 0; i--)
    {
        fsSiteInfo *site = m_vSites [i];
        if (site->pGroup != NULL && site->pGroup->bAboutToBeDeleted)
        {
            site->pGroup = NULL;
            v.push_back (site);
        }
    }

    vmsAUTOLOCKSECTION_UNLOCK (m_csSites);

    for (size_t j = 0; j < v.size (); j++)
        SiteUpdated (v [j]);
}
BOOL fsPluginMgr::OnAppExit(BOOL bQueryForExit)
{
    vmsAUTOLOCKSECTION (m_csExit);

    if (m_bWasExit)
        return TRUE;

    if (bQueryForExit)
    {
        if (FALSE == QueryExit ())
            return FALSE;
    }

    m_bWasExit = TRUE;

    vmsAUTOLOCKSECTION_UNLOCK (m_csExit);

    _TumMgr.Shutdown ();

    vmsPluginSupport::o ().Shutdown ();

    for (int i = 0; i < m_vWndPlugs.size (); i++)
    {
        if (m_vWndPlugs [i].pfnShutdown)
            m_vWndPlugs [i].pfnShutdown ();
        else
            SendMessage (m_vWndPlugs [i].hWnd, WM_WGP_SHUTDOWN, 0, 0);
    }

    _DldsMgr.Shutdown ();

    vmsBtDownloadManager::Shutdown ();

    if (_BT.is_Initialized ())
        _BT.Shutdown ();

    return TRUE;
}
STDMETHODIMP CWgUrlListReceiver::ShowAddUrlListDialog()
{
	if (m_vUrls.size () == 0)
		return S_FALSE;

	UIThread *thr = (UIThread*) RUNTIME_CLASS (UIThread)->CreateObject ();

	threadAddUrlListDialogParam *param = new threadAddUrlListDialogParam;
	param->pthis = this;
	AddRef ();
	CComObject <CFdmUiWindow> *pUiWindow = NULL;
	CComObject <CFdmUiWindow>::CreateInstance (&pUiWindow);
	param->pUiWindow = pUiWindow;
	if (pUiWindow)
		pUiWindow->AddRef ();
	vmsAUTOLOCKSECTION (m_csLastUiWindow);
	m_spLastUiWindow = pUiWindow;
	vmsAUTOLOCKSECTION_UNLOCK (m_csLastUiWindow);
	thr->set_Thread (_threadAddUrlListDialog, param);
	thr->CreateThread ();

	return S_OK;
}
STDMETHODIMP CFDMFlashVideoDownloads::ShowAddDownloadsDialog(BSTR bstrSrcWebPageUrl, SAFEARRAY *psaDownloads)
{
	USES_CONVERSION;

	CComObject <CFdmUiWindow> *pUiWindow = NULL;
	CComObject <CFdmUiWindow>::CreateInstance (&pUiWindow);

	vmsAUTOLOCKSECTION (m_csLastUiWindow);
	m_spLastUiWindow = pUiWindow;
	vmsAUTOLOCKSECTION_UNLOCK (m_csLastUiWindow);

	if (psaDownloads == NULL)
		return E_INVALIDARG;

	UINT cDim = SafeArrayGetDim (psaDownloads);
	if (cDim != 1)
		return E_INVALIDARG;

	LONG lLBound = 0, lUBound = 0;
	SafeArrayGetLBound (psaDownloads, 1, &lLBound);
	SafeArrayGetUBound (psaDownloads, 1, &lUBound);

	std::vector <vmsNewDownloadInfo> *pvDlds = new std::vector <vmsNewDownloadInfo>;

	for (long i = lLBound; i <= lUBound; i++)
	{
		IDispatchPtr spDisp;
		SafeArrayGetElement (psaDownloads, &i, &spDisp);

		IFdmFlvDownloadPtr spFlvDld (spDisp);

		if (spFlvDld == NULL)
		{
			delete pvDlds;
			return E_INVALIDARG;
		}
		IWGUrlReceiverPtr spUrl;
		spFlvDld->get_Url (&spUrl);
		if (spUrl == NULL)
		{
			delete pvDlds;
			return E_INVALIDARG;
		}

		CComBSTR bstr;
		spUrl->get_Url (&bstr);

		CString strUrl = W2CT (bstr);
		bool bSkip = false;

		for (size_t j = 0; j < pvDlds->size (); j++)
		{
			if (pvDlds->at (j).strUrl == strUrl)
			{
				bSkip = true; 
				break;
			}
		}

		if (bSkip)
			continue;

		vmsNewDownloadInfo dlInfo;

		dlInfo.strUrl = W2CA (bstr);

		spUrl->get_Referer (&bstr);
		dlInfo.strReferer = W2CA (bstr);

		spUrl->get_Comment (&bstr);
		dlInfo.strComment = bstr;

		dlInfo.dwWhatIsValid = NDIV_AP;

		dlInfo.ap.dwMask = DWCDAP_FLAGS;
		dlInfo.ap.dwFlags = DWDCDAP_F_FLASHVIDEODOWNLOAD;

		spUrl->get_Cookies (&bstr);
		if (bstr.Length ())
		{
			dlInfo.ap.dwMask |= DWCDAP_COOKIES;
			dlInfo.ap.strCookies = W2CA (bstr);
		}

		spUrl->get_PostData (&bstr);
		if (bstr.Length ())
		{
			dlInfo.ap.dwMask |= DWCDAP_POSTDATA;
			dlInfo.ap.strPostData = W2CA (bstr);
		}

		spUrl->get_FileName (&bstr);
		if (bstr.Length ())
		{
			dlInfo.ap.dwMask |= DWCDAP_FILENAME;
			dlInfo.ap.strFileName = W2CA (bstr);
		}

		spUrl->get_FileSize (&bstr);
		if (bstr.Length ())
		{
			dlInfo.ap.dwMask |= DWCDAP_FILESIZE;
			dlInfo.ap.uFileSize = (UINT64)_wtoi64 (bstr);
		}

		pvDlds->push_back (dlInfo);
	}

	CFlashVideoDownloadsWnd::WmFvdwLparam *lp = new CFlashVideoDownloadsWnd::WmFvdwLparam;
	lp->strSrcWebPageUrl = W2CA(bstrSrcWebPageUrl);
	lp->pvDlds = pvDlds;
	lp->pUiWindow = pUiWindow; 
	if (pUiWindow)
		pUiWindow->AddRef ();
	_pwndFVDownloads->PostMessage (WM_FVDW_CREATEDOWNLOADS, 0, (LPARAM)lp);

	return S_OK;
}