Example #1
0
void CMediaFormats::GetAudioFilter(CString& filter, CAtlArray<CString>& mask)
{
	CString		strTemp;
	filter += _T("Audio files (all types)|");
	mask.Add(_T(""));

	for(size_t i = 0; i < GetCount(); i++)
	{
		CMediaFormatCategory& mfc = GetAt(i);
		if(mfc.IsAudioOnly() != 1 || mfc.GetEngineType() != DirectShow) continue;
		strTemp  = GetAt(i).GetFilter() + _T(";");
		mask[0] += strTemp;
		filter  += strTemp;
	}

	mask[0].TrimRight(_T(";"));
	filter.TrimRight(_T(";"));
	filter += _T("|");

	for(size_t i = 0; i < GetCount(); i++)
	{
		CMediaFormatCategory& mfc = GetAt(i);
		if(mfc.IsAudioOnly() != 1 || mfc.GetEngineType() != DirectShow) continue;
		filter += mfc.GetLabel() + _T("|") + GetAt(i).GetFilter() + _T("|");
		mask.Add(mfc.GetFilter());
	}

	filter += _T("All files (*.*)|(*.*)|");
	mask.Add(_T("*.*"));

	filter += _T("|");
}
void CMediaFormats::GetAudioFilter(CString& filter, CAtlArray<CString>& mask)
{
	CString		strTemp;
	filter += ResStr(IDS_AG_AUDIOFILES);
	mask.Add(_T(""));

	for (size_t i = 0; i < GetCount(); i++) {
		CMediaFormatCategory& mfc = GetAt(i);
		if (mfc.GetFileType() == TAudio/* && mfc.GetEngineType() == DirectShow*/) {
			strTemp	= GetAt(i).GetFilter() + _T(";");
			mask[0]	+= strTemp;
			filter	+= strTemp;
		}
	}

	mask[0].TrimRight(_T(';'));
	filter.TrimRight(_T(';'));
	filter += _T("|");

	for (size_t i = 0; i < GetCount(); i++) {
		CMediaFormatCategory& mfc = GetAt(i);
		if (mfc.GetFileType() == TAudio/* && mfc.GetEngineType() == DirectShow*/) {
			filter += mfc.GetDescription() + _T("|") + GetAt(i).GetFilter() + _T("|");
			mask.Add(mfc.GetFilter());
		}
	}

	filter += ResStr(IDS_AG_ALLFILES);
	mask.Add(_T("*.*"));

	filter += _T("|");
}
Example #3
0
void CMediaFormats::GetFilter(CString& filter, CAtlArray<CString>& mask)
{
	CString		strTemp;

	filter += ResStr(IDS_MEDIAFORMATS_34);
	mask.Add(_T(""));

	for(int i = 0; i < GetCount(); i++)
	{
		strTemp  = GetAt(i).GetFilter() + _T(";");
		mask[0] += strTemp;
		filter  += strTemp;
	}
	mask[0].TrimRight(_T(";"));
	filter.TrimRight(_T(";"));
	filter += _T("|");

	for(int i = 0; i < GetCount(); i++)
	{
		CMediaFormatCategory& mfc = GetAt(i);
		filter += mfc.GetLabel() + _T("|" + GetAt(i).GetFilter() + _T("|"));
		mask.Add(mfc.GetFilter());
	}

	filter += ResStr(IDS_MEDIAFORMATS_35);
	mask.Add(_T("*.*"));

	filter += _T("|");
}
Example #4
0
void CMediaFormats::GetFilter(CString& filter, CAtlArray<CString>& mask)
{
	CString		strTemp;

	filter += _T("Media files (all types)|");
	mask.Add(_T(""));

	for(size_t i = 0; i < GetCount(); i++) 
	{
		strTemp  = GetAt(i).GetFilter() + _T(";");;
		mask[0] += strTemp;
		filter  += strTemp;
	}
	mask[0].TrimRight(_T(";"));
	filter.TrimRight(_T(";"));
	filter += _T("|");

	for(size_t i = 0; i < GetCount(); i++)
	{
		CMediaFormatCategory& mfc = GetAt(i);
		filter += mfc.GetLabel() + _T("|" + GetAt(i).GetFilter() + _T("|"));
		mask.Add(mfc.GetFilter());
	}

	filter.Append( ResStr(IDS_FILEOPEN_DISLOG_ALL_MEDIA_TYPE) );
	mask.Add(_T("*.*"));

	filter += _T("|");
}
Example #5
0
void CMediaFormats::GetAudioFilter(CString& filter, CAtlArray<CString>& mask)
{
	CString		strTemp;
	filter += ResStr(IDS_MEDIAFORMATS_36);
	mask.Add(_T(""));

	for(int i = 0; i < GetCount(); i++)
	{
		CMediaFormatCategory& mfc = GetAt(i);
		if(!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) continue;
		strTemp  = GetAt(i).GetFilter() + _T(";");
		mask[0] += strTemp;
		filter  += strTemp;
	}

	mask[0].TrimRight(_T(";"));
	filter.TrimRight(_T(";"));
	filter += _T("|");

	for(int i = 0; i < GetCount(); i++)
	{
		CMediaFormatCategory& mfc = GetAt(i);
		if(!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) continue;
		filter += mfc.GetLabel() + _T("|") + GetAt(i).GetFilter() + _T("|");
		mask.Add(mfc.GetFilter());
	}

	filter += ResStr(IDS_MEDIAFORMATS_35);
	mask.Add(_T("*.*"));

	filter += _T("|");
}
Example #6
0
void CMediaFormats::GetFilter(CString& filter, CAtlArray<CString>& mask) const
{
    CString strTemp;

    filter += ResStr(IDS_AG_MEDIAFILES);
    mask.Add(_T(""));

    for (size_t i = 0; i < GetCount(); i++) {
        strTemp = GetAt(i).GetFilter() + _T(";");
        mask[0] += strTemp;
        filter  += strTemp;
    }
    mask[0].TrimRight(_T(';'));
    filter.TrimRight(_T(';'));
    filter += _T("|");

    for (size_t i = 0; i < GetCount(); i++) {
        const CMediaFormatCategory& mfc = GetAt(i);
        filter += mfc.GetDescription() + _T("|" + GetAt(i).GetFilter() + _T("|"));
        mask.Add(mfc.GetFilter());
    }

    filter += ResStr(IDS_AG_ALLFILES);
    mask.Add(_T("*.*"));

    filter += _T("|");
}
LRESULT CHistoryWindow::OnViewBBCode(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	TreeItem* item = m_treeView.selectedItem();
	if(!item) return 0;
	CAtlArray<CUrlListItem> items;

	if(item->level()==0)
	{
		CHistorySession* ses = reinterpret_cast<CHistorySession*>(item->userData());
		for(int i=0; i<ses->entriesCount(); i++)
		{
			CUrlListItem it  =fromHistoryItem(ses->entry(i));
			items.Add(it);
		}
	}
	else
	{
		HistoryItem* hit = reinterpret_cast<HistoryItem*>(item->userData());
		CUrlListItem it  = fromHistoryItem(*hit);
		items.Add(it);
	}
	CResultsWindow rp( pWizardDlg, items,false);
	rp.DoModal(m_hWnd);
	return 0;
}
Example #8
0
void CMediaFormats::GetAudioFilter(CString& filter, CAtlArray<CString>& mask) const
{
    CString strTemp;

    filter += ResStr(IDS_AG_AUDIOFILES);
    mask.Add(_T(""));

    for (size_t i = 0; i < GetCount(); i++) {
        const CMediaFormatCategory& mfc = GetAt(i);
        if (!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) {
            continue;
        }
        strTemp  = GetAt(i).GetFilter() + _T(";");
        mask[0] += strTemp;
        filter  += strTemp;
    }

    mask[0].TrimRight(_T(';'));
    filter.TrimRight(_T(';'));
    filter += _T("|");

    for (size_t i = 0; i < GetCount(); i++) {
        const CMediaFormatCategory& mfc = GetAt(i);
        if (!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) {
            continue;
        }
        filter += mfc.GetDescription() + _T("|") + GetAt(i).GetFilter() + _T("|");
        mask.Add(mfc.GetFilter());
    }

    filter += ResStr(IDS_AG_ALLFILES);
    mask.Add(_T("*.*"));

    filter += _T("|");
}
void CMediaFormats::GetFilter(CString& filter, CAtlArray<CString>& mask)
{
	CString strTemp;

	// Add All Media formats
	filter += ResStr(IDS_AG_MEDIAFILES);
	mask.Add(_T(""));

	for (size_t i = 0; i < GetCount(); i++) {
		strTemp	= GetAt(i).GetFilter() + _T(";");
		mask[0]	+= strTemp;
		filter	+= strTemp;
	}
	// add graphics formats
	mask[0]	+= GRAPHIC_FMT;
	filter	+= GRAPHIC_FMT;
	filter	+= _T("|");

	// Add Video formats
	filter += ResStr(IDS_AG_VIDEOFILES);
	mask.Add(_T(""));

	for (size_t i = 0; i < GetCount(); i++) {
		if (GetAt(i).GetFileType() == TVideo) {
			strTemp = GetAt(i).GetFilter() + _T(";");
			mask[1] += strTemp;
			filter += strTemp;
		}
	}
	filter.TrimRight(_T(';'));
	filter += _T("|");

	// Add Audio formats
	filter += ResStr(IDS_AG_AUDIOFILES);
	mask.Add(_T(""));

	for (size_t i = 0; i < GetCount(); i++) {
		if (GetAt(i).GetFileType() == TAudio) {
			strTemp	= GetAt(i).GetFilter() + _T(";");
			mask[1]	+= strTemp;
			filter	+= strTemp;
		}
	}
	filter.TrimRight(_T(';'));
	filter += _T("|");

	for (size_t i = 0; i < GetCount(); i++) {
		CMediaFormatCategory& mfc	= GetAt(i);
		filter						+= mfc.GetDescription() + _T("|" + GetAt(i).GetFilter() + _T("|"));
		mask.Add(mfc.GetFilter());
	}

	filter += ResStr(IDS_AG_ALLFILES);
	mask.Add(_T("*.*"));

	filter += _T("|");
}
Example #10
0
bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps)
{
	SyncPoint sp = {0, 0};
	sps.RemoveAll();

	while (len > 0) {
		bool fSign = !!BitRead(1);
		int iTimeStamp = (int)BitRead(3);
		int iFilePos = (int)BitRead(3);
		BitRead(1); // reserved

		sp.rt += (REFERENCE_TIME)BitRead(iTimeStamp<<3) * (fSign ? -1 : 1);
		sp.fp += BitRead(iFilePos<<3);
		sps.Add(sp);

		len -= 1 + iTimeStamp + iFilePos;
	}

	if (len != 0) {
		sps.RemoveAll();
		return false;
	}

	// TODO: sort sps

	return true;
}
Example #11
0
bool TrackEntry::Expand(CBinary& data, UINT64 Scope)
{
    if (ces.ce.IsEmpty()) {
        return true;
    }

    CAtlArray<ContentEncoding*> cearray;
    POSITION pos = ces.ce.GetHeadPosition();
    while (pos) {
        cearray.Add(ces.ce.GetNext(pos));
    }
    qsort(cearray.GetData(), cearray.GetCount(), sizeof(ContentEncoding*), cesort);

    for (int i = (int)cearray.GetCount() - 1; i >= 0; i--) {
        ContentEncoding* ce = cearray[i];

        if (!(ce->ContentEncodingScope & Scope)) {
            continue;
        }

        if (ce->ContentEncodingType == ContentEncoding::Compression) {
            if (!data.Decompress(ce->cc)) {
                return false;
            }
        } else if (ce->ContentEncodingType == ContentEncoding::Encryption) {
            // TODO
            return false;
        }
    }

    return true;
}
Example #12
0
static void LoadInternalExceptionList()
{
	g_aException.SetCount( 0, 32 );

	LPCTSTR rs = NULL;
	size_t len = AtlLoadString(
		IDS_INTERNAL_EXCEPTIONS,
		reinterpret_cast<LPTSTR>(&rs),
		0
		);

	LPTSTR buf = reinterpret_cast<LPTSTR>( malloc((len + 1) * sizeof(TCHAR)) );
	_tcsncpy( buf, rs, len );
	buf[len] = 0;

	LPCTSTR p = _tcstok( buf, _T("|") );
	while( p != NULL )
	{
		CExceptionInfo ei;
		ei.bUser = false;
		ei.bFiltered = false;
		ei.dwCode = _tcstoul( p, NULL, 0 );
		p = _tcstok( NULL, _T("|") );
		_tcsncpy( ei.szName, p, _countof(ei.szName) );
		ei.szName[_countof(ei.szName) - 1] = 0;
		g_aException.Add( ei );
		p = _tcstok( NULL, _T("|") );
	}

	free( buf );
}
Example #13
0
int CBkSafeMsgBox2::ParseMsgLine(CString strMsg, CAtlArray<CString>& arrMsg)
{
	int nRet = -1;
	if (TRUE == strMsg.IsEmpty())
		return nRet;
	arrMsg.RemoveAll();

	strMsg.Replace(_T("\\n"), _T("\n"));

	int nIndex = -1;
	strMsg += L"\n";
	CString strTmp(L""), msg = strMsg;;
	nIndex = msg.Find(L"\n");

	while (-1 != nIndex)
	{
		strTmp = msg.Left(nIndex);
		if (strTmp.GetLength())
			arrMsg.Add(strTmp);
		msg = msg.Mid(nIndex+1);

		nIndex = msg.Find(L"\n");
	} 

	return arrMsg.GetCount();
}
Example #14
0
HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
	CheckPointer(pAsyncReader, E_POINTER);

	HRESULT hr = E_FAIL;

	m_pFile.Free();

	m_pFile.Attach(new CMpaSplitterFile(pAsyncReader, hr));
	if(!m_pFile) return E_OUTOFMEMORY;
	if(FAILED(hr)) {m_pFile.Free(); return hr;}

	CAtlArray<CMediaType> mts;
	mts.Add(m_pFile->GetMediaType());

	CAutoPtr<CBaseSplitterOutputPin> pPinOut(new CBaseSplitterOutputPin(mts, L"Audio", this, this, &hr));
	AddOutputPin(0, pPinOut);

	m_rtNewStart = m_rtCurrent = 0;
	m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();

	CStringW str, title;
	if(m_pFile->m_tags.Lookup('TIT2', str)) title = str;
	if(m_pFile->m_tags.Lookup('TYER', str) && !title.IsEmpty() && !str.IsEmpty()) title += L" (" + str + L")";
	if(!title.IsEmpty()) SetProperty(L"TITL", title);
	if(m_pFile->m_tags.Lookup('TPE1', str)) SetProperty(L"AUTH", str);
	if(m_pFile->m_tags.Lookup('TCOP', str)) SetProperty(L"CPYR", str);
	if(m_pFile->m_tags.Lookup('COMM', str)) SetProperty(L"DESC", str);

	return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
Example #15
0
HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
	CheckPointer(pAsyncReader, E_POINTER);

	HRESULT hr = E_FAIL;

	m_pFile.Free();

	m_pFile.Attach(DNew CMpaSplitterFile(pAsyncReader, hr));
	if (!m_pFile) {
		return E_OUTOFMEMORY;
	}
	if (FAILED(hr)) {
		m_pFile.Free();
		return hr;
	}

	CAtlArray<CMediaType> mts;
	mts.Add(m_pFile->GetMediaType());

	CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Audio", this, this, &hr));
	AddOutputPin(0, pPinOut);

	m_rtNewStart = m_rtCurrent = 0;
	m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();

	SetID3TagProperties(this, m_pFile->ID3Tag);

	return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
Example #16
0
int CutString(const CString InStr, CAtlArray<CString>& OutStrings, LPCTSTR Separators)
{
	int Pos = 0;
	int StartPos = 0;
	bool bQuotas = false;
	OutStrings.RemoveAll();

	while (Pos < InStr.GetLength())
	{
		TCHAR ch = InStr[Pos];
		if (ch == _T('\"'))
		{
			if (InStr[Pos + 1]  == _T('\"'))
			{
				Pos += 2;
				continue;
			}
			else
			{
				bQuotas = !bQuotas;
			}
		}
		if (!bQuotas && _tcsrchr(Separators, ch))
		{
			//нашли сепаратор
			int WordLen = Pos - StartPos;
			if (WordLen)
			{
				CString NewWord = InStr.Mid(StartPos, WordLen);
				OutStrings.Add(NewWord);
			}
			StartPos = Pos + 1;
		}
		Pos++;
	}
	int WordLen = Pos - StartPos;
	if (WordLen)
	{
		CString NewWord = InStr.Mid(StartPos, WordLen);
		OutStrings.Add(NewWord);
	}
	else
	{
		OutStrings.Add(CString());
	}
	return (int)OutStrings.GetCount();
}
Example #17
0
/*
HRESULT CBDictionary::UTF82VARIANT(const char *pstr, int nCount, VARIANT* pvar)
{
	if (pvar==NULL) return E_INVALIDARG;

	if (nCount == 0)
		nCount = lstrlen(pstr);
	
	int _nTempCount = ::MultiByteToWideChar(65001, 0, pstr, nCount, NULL, NULL);
	CComBSTR bstr(_nTempCount);

	if (bstr==NULL) return E_OUTOFMEMORY;
	::MultiByteToWideChar(65001, 0, pstr, nCount, bstr, _nTempCount);

	pvar->vt = VT_BSTR;
	pvar->bstrVal = bstr.Detach();
	return S_OK;
}

LPSTR CBDictionary::BSTR2UTF8(BSTR strData, int *pCount)
{
	UINT strLen = SysStringByteLen(strData);
	int _nTempCount = ::WideCharToMultiByte(65001, 0, strData, strLen / 2, NULL, 0, NULL, NULL);
	LPSTR pstr = new char[_nTempCount+1];
	::WideCharToMultiByte(65001, 0, strData, strLen / 2, pstr, _nTempCount, NULL, NULL);
	pstr[_nTempCount] = 0;
	if (pCount!=NULL) *pCount = _nTempCount;
	return pstr;
}
*/
STDMETHODIMP CBDictionary::JSON_join( IStream *pStrm, int indent, CAtlArray<void*> &arrObjects)
{
	POSITION pos;
	CRBMap<CBVariant, CComVariant>::CPair* pPair;
	HRESULT hr;
	ULONG n1;
	int indent1 = indent >= 0 ? indent + 1 : indent;

	hr = pStrm->Write(L"{\r\n", (indent != -1 ? 3 : 1) * sizeof(WCHAR), &n1);
	if(FAILED(hr))return hr;

	CBLock l(&m_cs);
	arrObjects.Add((void *)(IDispatch *)this);

	pos = m_mapItems.GetHeadPosition();
	while(pos)
	{
		pPair = (CRBMap<CBVariant, CComVariant>::CPair*)m_mapItems.GetNext(pos);

		hr = JSON_putTabs(pStrm, indent1);
		if(FAILED(hr))return hr;

		if(pPair->m_key.vt == VT_BSTR)
			hr = JSON_putVariant(pStrm, &pPair->m_key, indent1, arrObjects);
		else
		{
			CComVariant var;

			hr = ::VariantChangeType(&var, (VARIANTARG*)&pPair->m_key, VARIANT_ALPHABOOL, VT_BSTR);
			if(FAILED(hr))return hr;

			hr = JSON_putVariant(pStrm, &var, indent1, arrObjects);
		}
		if(FAILED(hr))return hr;

		if(indent != -1)
			hr = pStrm->Write(L": ", 2 * sizeof(WCHAR), &n1);
		else
			hr = pStrm->Write(L":", 1 * sizeof(WCHAR), &n1);
		if(FAILED(hr))return hr;

		hr = JSON_putVariant(pStrm, &pPair->m_value, indent1, arrObjects);
		if(FAILED(hr))return hr;

		if(pos)
			hr = pStrm->Write(L",\r\n", (indent != -1 ? 3 : 1) * sizeof(WCHAR), &n1);
		else if(indent != -1)
			hr = pStrm->Write(L"\r\n", 2 * sizeof(WCHAR), &n1);
		if(FAILED(hr))return hr;
	}

	hr = JSON_putTabs(pStrm, indent);
	if(FAILED(hr))return hr;
	hr = pStrm->Write(L"}", 1 * sizeof(WCHAR), &n1);
	if(FAILED(hr))return hr;

	arrObjects.RemoveAt(arrObjects.GetCount()-1);
	return S_OK;
}
Example #18
0
bool ParseCommandLine(int argc, LPTSTR argv[])
{
	for (int i=1; i<argc; i++)
	{
		LPCTSTR szOption = argv[i];
		if (szOption[0] == '-' || szOption[0] == '/')
		{
			szOption++;
			if (strcmp(szOption, "?") == 0)
				return DisplayHelp();
			else if (_stricmp(szOption, "at") == 0)
			{
				if (g_eat != ExamineAccessTokenDefault)
					return DisplayHelp();
				g_eat = ExamineAccessTokenYes;
			}
			else if (_stricmp(szOption, "no_at") == 0)
			{
				if (g_eat != ExamineAccessTokenDefault)
					return DisplayHelp();
				g_eat = ExamineAccessTokenNo;
			}
			else if (_stricmp(szOption, "file") == 0)
			{
				if (g_eot != ExamineObjectTypeDefault)
					return DisplayHelp();
				g_eot = ExamineObjectTypeFile;
			}
			else if (_stricmp(szOption, "regkey") == 0)
			{
				if (g_eot != ExamineObjectTypeDefault)
					return DisplayHelp();
				g_eot = ExamineObjectTypeRegkey;
			}
			else if (_stricmp(szOption, "service") == 0)
			{
				if (g_eot != ExamineObjectTypeDefault)
					return DisplayHelp();
				g_eot = ExamineObjectTypeService;
			}
			else if (_stricmp(szOption, "kernel") == 0)
			{
				if (g_eot != ExamineObjectTypeDefault)
					return DisplayHelp();
				g_eot = ExamineObjectTypeKernel;
			}
			else if (_stricmp(szOption, "printer") == 0)
			{
				if (g_eot != ExamineObjectTypeDefault)
					return DisplayHelp();
				g_eot = ExamineObjectTypePrinter;
			}
		}
		else
			g_aObjects.Add(szOption);
	}

	return true;
}
Example #19
0
void CMediaFormatCategory::GetExtArray(CAtlArray<CString>& szaExts)
{
	CString filter;
	POSITION pos = m_exts.GetHeadPosition();
	while(pos){
		szaExts.Add(_T("*.") + m_exts.GetNext(pos) );
	}
}
Example #20
0
int CDTManager::GetTasks( CAtlArray<void*>& tasks )
{
	for (POSITION p=_tks.GetStartPosition();p;)
	{
		tasks.Add(_tks.GetNextKey(p));
	}
	return (int)tasks.GetCount();
}
Example #21
0
int CALLBACK EnumFontProc(ENUMLOGFONT FAR* lf, NEWTEXTMETRIC FAR* tm, int FontType, LPARAM dwData)
{
    CAtlArray<CString>* fntl = (CAtlArray<CString>*)dwData;
    if (FontType == TRUETYPE_FONTTYPE) {
        fntl->Add(lf->elfFullName);
    }
    return 1; /* Continue the enumeration */
}
Example #22
0
void SlimItem::GetPaths(CAtlArray<CString>& itemPaths) const
{
    itemPaths.RemoveAll();
    for (size_t i = 0; i < m_itemPaths.GetCount(); i++)
    {
        itemPaths.Add(m_itemPaths[i]);
    }
}
Example #23
0
void CDirWatcher::ProcessDirectory(const CString& dir)
{
	if(dir.IsEmpty())
		return;

	// scan directory for .nzb files
	WIN32_FIND_DATA wfd;
	HANDLE h = FindFirstFile(dir + _T("\\*"), &wfd);
	if(h == INVALID_HANDLE_VALUE)
		return;

	CAtlArray<CString> filesToCheck;
	do {
		// skip everything that's not a file
		if(wfd.dwFileAttributes & (FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_HIDDEN))
			continue;

		// filter extension
		CString s(wfd.cFileName);
		s.MakeLower();
		if(s.Right(4) != _T(".nzb"))
			continue;

		// skip if in filesToIgnore
		bool ignore = false;
		for(size_t i = 0; i < filesToIgnore.GetCount(); i++) {
			if(!filesToIgnore[i].CompareNoCase(wfd.cFileName)) {
				ignore = true;
				break;
			}
		}
		if(ignore)
			continue;

		// skip if we can't get exclusive access (probably some other application is still writing)
		CFile ftest;
		if(!ftest.Open(dir + _T("\\") + wfd.cFileName, GENERIC_READ, 0, OPEN_EXISTING))
			continue;

		filesToCheck.Add(wfd.cFileName);
	} while(FindNextFile(h, &wfd));
	FindClose(h);

	for(size_t i = 0; i < filesToCheck.GetCount(); i++) {
		CNzb* nzb = new CNzb;
		if(nzb->CreateFromPath(dir + _T("\\") + filesToCheck[i])) {
			CNewzflow::Instance()->controlThread->AddNZB(nzb);
			if(CNewzflow::Instance()->settings->GetDeleteWatch())
				CFile::Delete(dir + _T("\\") + filesToCheck[i]);
			else
				filesToIgnore.Add(filesToCheck[i]);
		} else {
			delete nzb;
		}
	}
}
Example #24
0
void CUIHandlerSystemSlim::OnCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
{
    BOOL bRet = FALSE;
    
    if (nID >= DEF_SLIM_MENU_ID_BASE && nID <= DEF_SLIM_MENU_ID_BASE_END)
    {
        SlimItem& slimItem = m_slimData.GetItem(m_nCurrentIndex);
        CAtlArray<CString> vPaths;
        int index = nID - 1000;

        slimItem.GetPaths(vPaths);

        if (slimItem.Id() == 0) //壁纸 暂时先这样写
        {
            //        ExpandEnvironmentStrings(L"%Systemroot%\\Web\\Wallpaper\\", temp, MAX_PATH * 2);
            TCHAR szLocate[MAX_PATH] = { 0 };
            _tcscpy_s(szLocate, MAX_PATH, vPaths[0]);
            if (KGetWinVersion() != WINVERSION_XP)
            {
                PathRemoveFileSpec(szLocate);   
            }
            PathRemoveFileSpec(szLocate);

            vPaths.RemoveAll();
            vPaths.Add(szLocate);
        }
        else if (slimItem.Id() == 1 || slimItem.Id() == 3 || slimItem.Id() == 2|| slimItem.Id() == 4)
        {
            CString strPath = vPaths[0];
            TCHAR szLocate[MAX_PATH] = { 0 };

            _tcscpy_s(szLocate, MAX_PATH, strPath);

            PathRemoveFileSpec(szLocate);

            vPaths.RemoveAll();
            vPaths.Add(szLocate);
        }

        slimhelper::LocateFile(vPaths[index]);
    }
    SetMsgHandled(FALSE);
}
Example #25
0
int CCommon::ParsexmlCmdLine(LPCTSTR pszCmdLine, CAtlArray<CString>& arrStr)
{
	int nRet = -1;
	if (NULL == pszCmdLine)
		return nRet;

	arrStr.RemoveAll();
	LPTSTR _pszCmdLine = StrDupW(pszCmdLine);
	if (NULL == _pszCmdLine)
		return nRet;

	LPTSTR pValue = _pszCmdLine;

	LPTSTR pos = NULL;
	LPTSTR NewPos = NULL;
	NewPos = StrStr(_pszCmdLine, TEXT("\","));
	while(NULL != NewPos && _tcslen(NewPos) > 2)
	{
		pos = NewPos+2;
		*NewPos = 0;
		_pszCmdLine += 1;
		arrStr.Add((_pszCmdLine));
		_pszCmdLine = pos;
		NewPos = StrStr(_pszCmdLine, TEXT("\","));
	}
	if (NULL != _pszCmdLine && _tcslen(_pszCmdLine) > 1)
	{
		_pszCmdLine += 1;
		pos = StrRChr(_pszCmdLine, NULL, TEXT('\"'));
		if (NULL != pos)
			*pos = 0;
		arrStr.Add(_pszCmdLine);
	}

	nRet = 0;
	if (NULL != pValue)
	{
		LocalFree(pValue);
		pValue = NULL;
	}
	return nRet;
}
Example #26
0
static void LoadSettings()
{
	CIniFile ini;
	ini.OpenDefault();

	Settings.lVersion = 0;

	// general section
	CIniSection* sctn = ini.GetSection( g_szGeneralSection );
	Settings.dwSnapshot = sctn->GetValueInt( g_szSnapshot, ED_MINI_DUMP );
	LPCTSTR str = sctn->GetValueString( g_szDumpPath, _T("") );
	_tcsncpy( Settings.szDumpPath, str, _countof(Settings.szDumpPath) );
	Settings.szDumpPath[_countof(Settings.szDumpPath) - 1] = 0;

	// crash section
	sctn = ini.GetSection( g_szCrashSection );
	Settings.dwFirstChance = sctn->GetValueInt( g_szFirstChance, ED_DONT_DUMP );
	Settings.dwSecondChance = sctn->GetValueInt(g_szSecondChance, ED_MINI_DUMP);
	Settings.bAutoDelete = sctn->GetValueBool( g_szAutoDelete, true );

	// user exception list
	sctn = ini.GetSection( g_szUserExceptionSection );
	size_t pos = sctn->GetFirstKeyPosition();
	while( pos != 0xffffffff )
	{
		CIniKey* key = sctn->GetNextKey( pos );

		CExceptionInfo ei;
		ei.bUser = true;
		ei.bFiltered = false;
		ei.dwCode = _tcstoul( key->GetName(), NULL, 0 );
		_tcsncpy( ei.szName, key->GetValueString(), _countof(ei.szName) );
		ei.szName[_countof(ei.szName) - 1] = 0;
		g_aException.Add( ei );
	}

	// filter section
	sctn = ini.GetSection( g_szFilterSection );
	pos = sctn->GetFirstKeyPosition();
	while( pos != 0xffffffff )
	{
		CIniKey* key = sctn->GetNextKey( pos );
		DWORD code = _tcstoul( key->GetName(), NULL, 0 );
		CExceptionInfo* pei = GetExceptionInfoByCode( code );
		if( pei != NULL )
			pei->bFiltered = key->GetValueBool();
	}
}
Example #27
0
void COPCItem::readSync(OPCItemData &data, OPCDATASOURCE source){
	CAtlArray<COPCItem *> items;
	items.Add(this);
	COPCItem_DataMap opcData;
	group->readSync(items, opcData, source);
		
	COPCItem_DataMap::CPair* pos = opcData.Lookup(this);
	if (pos){
		OPCItemData * readData = opcData.GetValueAt(pos);
		if (readData && !FAILED(readData->error)){
			data = *readData;
			return;
		}
	} 

	throw OPCException("Read failed");
}
Example #28
0
HRESULT CReportFileDB::GetUnRescanList( CAtlArray<CReportFile>& rfArray )
{
    HRESULT hr = S_OK;
    CComPtr<Skylark::ISQLiteComResultSet3>  piRtm;
    CReportFile rfile;

    if ( NULL == m_piSlDB )
    {
        hr = E_NOINTERFACE;
        goto Exit0;
    }

    hr = m_piSlDB->ExecuteQuery( REPORT_FILE_LOAD_RESCANLIST, &piRtm );
    if ( FAILED( hr ) )
    {
        CRunTimeLog::WriteLog(WINMOD_LLVL_DEBUG, L"[GetUnRescanList] query rfl.db failed %08x", hr );
        goto Exit0;
    }

    rfArray.RemoveAll();

    while( !piRtm->IsEof() )
    {
        rfile.m_strFilePath = piRtm->GetAsString( 0 );
        rfile.m_nFileSize = piRtm->GetInt( 1 );
        rfile.m_nReportState = piRtm->GetInt( 2 );
        rfile.m_nTrack = piRtm->GetInt( 3 );
        rfile.SetCreateTime( piRtm->GetInt64( 4 ) );
        rfile.SetCommitTime( piRtm->GetInt64( 5 ) );
        rfile.SetReportTime( piRtm->GetInt64( 6 ) );
        rfile.m_nRescanState = piRtm->GetInt( 7 );

        if ( FILE_TRACK_FILE & rfile.m_nTrack)
        {
            rfArray.Add( rfile );
        }

        piRtm->NextRow();
    }
Exit0:
    return hr;
}
Example #29
0
void COPCItem::getSupportedProperties(CAtlArray<CPropertyDescription> &desc){
	DWORD noProperties = 0;
	DWORD *pPropertyIDs;
	LPWSTR *pDescriptions;
	VARTYPE *pvtDataTypes;

	USES_CONVERSION;
	HRESULT res = group.getServer().getPropertiesInterface()->QueryAvailableProperties(T2OLE(name), &noProperties, &pPropertyIDs, &pDescriptions, &pvtDataTypes);
	if (FAILED(res)){
		throw OPCException("Failed to restrieve properties", res);
	}

	for (unsigned i = 0; i < noProperties; i++){
		desc.Add(CPropertyDescription(pPropertyIDs[i], pDescriptions[i], pvtDataTypes[i]));
	}

	COPCClient::comFree(pPropertyIDs);
	COPCClient::comFree(pDescriptions);
	COPCClient::comFree(pvtDataTypes);
}
Example #30
0
CTransaction * COPCItem::writeAsynch(VARIANT &data, ITransactionComplete *transactionCB){
	DWORD cancelID;
	HRESULT * individualResults;
	CAtlArray<COPCItem *> items;
	items.Add(this);
	CTransaction * trans = new CTransaction(items,transactionCB);

	HRESULT result = group.getAsych2IOInterface()->Write(1,&serversItemHandle,&data,(DWORD)trans,&cancelID,&individualResults); 
	
	if (FAILED(result)){
		delete trans;
		throw OPCException("Asynch Write failed");
	}

	trans->setCancelId(cancelID);
	if (FAILED(individualResults[0])){
		trans->setItemError(this,individualResults[0]);
		trans->setCompleted(); // if all items return error then no callback will occur. p 104
	}

	COPCClient::comFree(individualResults);
	return trans;
}