CString CDownload::GetDownloadSources() const { const int nTotalSources = GetSourceCount(); const int nSources = GetEffectiveSourceCount(); CString strText; if ( IsCompleted() ) { if ( m_bVerify == TRI_TRUE ) LoadString( strText, IDS_STATUS_VERIFIED ); else if ( m_bVerify == TRI_FALSE ) LoadString( strText, IDS_STATUS_UNVERIFIED ); } else if ( nTotalSources == 0 ) { LoadString( strText, IDS_STATUS_NOSOURCES ); } else if ( nSources == nTotalSources ) { CString strSource; LoadSourcesString( strSource, nSources ); strText.Format( L"(%i %s)", nSources, (LPCTSTR)strSource ); } else { CString strSource; LoadSourcesString( strSource, nTotalSources, true ); strText.Format( L"(%i/%i %s)", nSources, nTotalSources, (LPCTSTR)strSource ); } return strText; }
void CDownloadWithSearch::RunSearch(DWORD tNow) { if ( ! CanSearch() ) { StopSearch(); return; } if ( tNow > m_tSearchTime && tNow - m_tSearchTime < Settings.Downloads.SearchPeriod ) { StartManualSearch(); } else if ( tNow > m_tSearchCheck && tNow - m_tSearchCheck >= 1000 ) { BOOL bFewSources = GetSourceCount( FALSE, TRUE ) < Settings.Downloads.MinSources; BOOL bDataStarve = ( tNow > m_tReceived ? tNow - m_tReceived : 0 ) > Settings.Downloads.StarveTimeout * 1000; m_tSearchCheck = tNow; if ( IsPaused() == FALSE && ( bFewSources || bDataStarve ) ) { StartAutomaticSearch(); } else { StopSearch(); } } }
void CDownloadWithSources::Serialize(CArchive& ar, int nVersion) { CDownloadBase::Serialize( ar, nVersion ); if ( ar.IsStoring() ) { ar.WriteCount( GetSourceCount() ); for ( CDownloadSource* pSource = GetFirstSource() ; pSource ; pSource = pSource->m_pNext ) { pSource->Serialize( ar, nVersion ); } ar.WriteCount( m_pXML != NULL ? 1 : 0 ); if ( m_pXML ) m_pXML->Serialize( ar ); } else { for ( int nSources = ar.ReadCount() ; nSources ; nSources-- ) { // Create new source CDownloadSource* pSource = new CDownloadSource( (CDownload*)this ); // Add to the list m_nSourceCount ++; pSource->m_pPrev = m_pSourceLast; pSource->m_pNext = NULL; if ( m_pSourceLast != NULL ) { m_pSourceLast->m_pNext = pSource; m_pSourceLast = pSource; } else { m_pSourceFirst = m_pSourceLast = pSource; } // Load details from disk pSource->Serialize( ar, nVersion ); // Extract ed2k client ID from url (m_pAddress) because it wasn't saved if ( ( !pSource->m_nPort ) && ( _tcsnicmp( pSource->m_sURL, _T("ed2kftp://"), 10 ) == 0 ) ) { CString strURL = pSource->m_sURL.Mid(10); if ( strURL.GetLength()) _stscanf( strURL, _T("%lu"), &pSource->m_pAddress.S_un.S_addr ); } } if ( ar.ReadCount() ) { m_pXML = new CXMLElement(); m_pXML->Serialize( ar ); } } }
SjIcon SjServerScannerModule::GetSourceIcon(long index) { if( index >= 0 && index < GetSourceCount() ) { if( m_sources[index].m_flags&SJ_SERVERSCANNER_ENABLED ) { return m_sources[index].GetIcon(); } } return SJ_ICON_EMPTY; }
wxIAReturnCode wxIASaneProvider::SelectSource(const wxString &name, wxIAUIMode uiMode, wxWindow *parent) { wxCHECK_MSG(Ok(), wxIA_RC_NOTINITIALIZED, _T("wxIASane not valid!")); wxString selName = name; m_selDevice = -1; if (!m_deviceList) GetSourceCount(); if (m_numDevices <= 0) { wxMessageBox(_("No devices available"), wxTheApp->GetAppName(), wxOK | wxICON_EXCLAMATION | wxCENTRE); return wxIA_RC_NOSOURCE; } wxArrayString sources; sources.Alloc(m_numDevices); unsigned int sel = 0; for (unsigned int i = 0; i < m_numDevices; i++) { sources.Add(wxString::Format("%s %s", m_deviceList[i]->vendor, m_deviceList[i]->model)); if (name == wxString(m_deviceList[i]->name).Strip()) sel = i; } if (uiMode == wxIA_UIMODE_NORMAL) { wxSingleChoiceDialog d(parent, _("Available Devices:"), _("Select Source"), sources); d.SetSelection(sel); if(d.ShowModal() != wxID_OK) return wxIA_RC_CANCELLED; sel = d.GetSelection(); selName = wxString(m_deviceList[sel]->name).Strip(); } else if(!(sel <= m_numDevices)) return wxIA_RC_NOSOURCE; SANE_Status rc = m_sane->SaneOpen(selName); if(rc == SANE_STATUS_GOOD) m_selDevice = sel; return MapStatus(rc); }
bool SjServerScannerModule::ConfigSource(long index, wxWindow* parent) { if( index >= 0 && index < GetSourceCount() ) { SjServerScannerConfigDialog dlg(parent, m_sources[index]); if( dlg.ShowModal() == wxID_OK && dlg.GetChanges(m_sources[index]) ) { SaveSettings(); return TRUE; // needs update } } return FALSE; // no update needed }
bool SjServerScannerModule::DeleteSource(long index, wxWindow* parent) { if( index >= 0 && index < GetSourceCount() ) { if( SjMessageBox(wxString::Format(_("Remove \"%s\" from the music library?"), m_sources[index].m_serverName.c_str()), SJ_PROGRAM_NAME, wxYES_NO|wxNO_DEFAULT|wxICON_QUESTION, parent) == wxYES ) { m_sources.RemoveAt(index); SaveSettings(); return TRUE; } } return FALSE; }
wxString SjServerScannerModule::GetSourceNotes(long index) { if( index >= 0 && index < GetSourceCount() ) { if( !(m_sources[index].m_flags & SJ_SERVERSCANNER_ENABLED) ) { return _("Disabled"); } if( !(m_sources[index].m_flags & SJ_SERVERSCANNER_DO_UPDATE) ) { return _("No update"); } } return wxEmptyString; }
wxIASourceInfo wxIASaneProvider::GetSourceInfo(int i) { static struct typemap typeMaps[] = { { "file scanner", wxIA_SOURCE_FILMSCANNER }, { "flatbed scanner", wxIA_SOURCE_FLATBEDSCANNER }, { "frame grabber", wxIA_SOURCE_FRAMEGRABBER }, { "handheld scanner", wxIA_SOURCE_HANDHELDSCANNER }, { "multi-function peripheral", wxIA_SOURCE_MULTIFUNCTION }, { "sheetfed scanner", wxIA_SOURCE_SHEETFEDSCANNER }, { "still camera", wxIA_SOURCE_STILLCAMERA }, { "video camera", wxIA_SOURCE_VIDEOCAMERA }, { "virtual device", wxIA_SOURCE_UNKNOWN }, { NULL, wxIA_SOURCE_UNKNOWN } }; wxCHECK_MSG(Ok(), wxNullIASourceInfo, _T("wxIASane not valid!")); if (!m_deviceList) GetSourceCount(); if (i < m_numDevices) { wxIASourceInfo sourceInfo; sourceInfo.SetName(m_deviceList[i]->name); sourceInfo.SetModel(m_deviceList[i]->model); sourceInfo.SetVendor(m_deviceList[i]->vendor); sourceInfo.SetType(wxIA_SOURCE_UNKNOWN); for (unsigned int j = 0; typeMaps[j].typeName; j++) if (!wxStrcmp(m_deviceList[i]->type, typeMaps[j].typeName)) { sourceInfo.SetType(typeMaps[j].type); break; } return sourceInfo; } return wxNullIASourceInfo; }
bool SjServerScannerModule::IterateTrackInfo(SjColModule* receiver) { bool ret = true, doSaveSettings = false; int sourceCount = GetSourceCount(), s; SjServerScannerSource* currSource; // go through all sources for( s = 0; s < sourceCount; s++ ) { // get source currSource = &(m_sources.Item(s)); // source enabled? if( !(currSource->m_flags & SJ_SERVERSCANNER_ENABLED) ) { continue; } // read data if( currSource->m_serverType == SJ_SERVERSCANNER_TYPE_HTTP ) { if( !IterateHttp(receiver, currSource, doSaveSettings) ) { ret = false; break; // aborted } } } if( ret && doSaveSettings ) { SaveSettings(); } return ret; }
using namespace Microsoft::Graphics::Canvas::Effects; using AbiEffectNative = ABI::Microsoft::Graphics::Canvas::Effects::IGraphicsEffectD2D1Interop; using AbiEffectSource = ABI::Microsoft::Graphics::Canvas::Effects::IGraphicsEffectSource; using AbiPropertyValue = ABI::Windows::Foundation::IPropertyValue; // Exposes features of IGraphicsEffectD2D1Interop for use by test.managed.EffectTests. public ref class EffectAccessor sealed { public: static int GetSourceCount(IGraphicsEffect^ effect) { auto effectNative = As<AbiEffectNative>(reinterpret_cast<IInspectable*>(effect)); unsigned count; ThrowIfFailed(effectNative->GetSourceCount(&count)); return count; } static IGraphicsEffectSource^ GetSource(IGraphicsEffect^ effect, int index) { auto effectNative = As<AbiEffectNative>(reinterpret_cast<IInspectable*>(effect)); ComPtr<AbiEffectSource> source; ThrowIfFailed(effectNative->GetSource(index, &source)); return reinterpret_cast<IGraphicsEffectSource^>(source.Get()); } static int GetPropertyCount(IGraphicsEffect^ effect)