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("|");
}
Example #2
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 #3
0
// Calling this function with bEnable equals to true when
// shuffle is already enabled will re-shuffle the tracks.
void CPlaylist::SetShuffle(bool bEnable)
{
    m_bShuffle = bEnable;

    if (bEnable && !IsEmpty()) {
        m_nShuffledListSize = GetCount();
        CAtlArray<plsort_t> positions;
        positions.SetCount(m_nShuffledListSize + 1);
        srand((unsigned int)time(nullptr));
        POSITION pos = GetHeadPosition();
        for (size_t i = 0; pos; i++, GetNext(pos)) {
            positions[i].n = rand();
            positions[i].pos = pos;
        }
        qsort(positions.GetData(), m_nShuffledListSize, sizeof(plsort_t), compare);
        positions[m_nShuffledListSize].pos = nullptr; // Termination

        m_posHeadShuffle = positions[0].pos;
        m_posTailShuffle = nullptr;
        for (size_t i = 0; i < m_nShuffledListSize; i++) {
            pos = positions[i].pos;
            CPlaylistItem& pli = GetAt(pos);
            pli.m_posPrevShuffle = m_posTailShuffle;
            pli.m_posNextShuffle = positions[i + 1].pos;
            m_posTailShuffle = pos;
        }
    } else {
        m_posHeadShuffle = m_posTailShuffle = nullptr;
        m_nShuffledListSize = 0;
    }
}
Example #4
0
UINT_PTR CBkSafeMsgBox2::ShowMutlLineMsg(LPCWSTR pszMsg, 
										 LPCWSTR lpszCaption /* = NULL */, 
										 UINT uType /* = NULL */, 
										 BOOL *pbNoNotifyLater /* = NULL */, 
										 HWND hWndParent /* = ::GetActiveWindow */)
{
	CString strMsg = pszMsg, strXml(L""), strXmlPanel(L"");
	CAtlArray<CString> arrMsgLine;
	if ( 0 == ParseMsgLine(strMsg, arrMsgLine))
		return -1;

	int nWidth = 0, 
		nLineCount = arrMsgLine.GetCount(), 
		nHeight =  nLineCount* 18,
		nTop = 0;
	CRect rcText;

	for (int i = 0; i < nLineCount; i++)
	{
		if (1 == nLineCount)
			nTop = 10;
		else
			nTop = i*18;
		strXml.Format(L"<text pos=\"0,%d\">%s</text>", nTop, arrMsgLine[i]);
		strXmlPanel += strXml;
		rcText = GetTextRect(arrMsgLine[i]);
		if (nWidth < rcText.Width())
			nWidth = rcText.Width();
	}
	CRect rc(0, 0, nWidth+10, nHeight);
	
	return ShowPanelMsg(strXmlPanel, &rc, NULL, uType, pbNoNotifyLater, hWndParent);
}
Example #5
0
LRESULT CFunctionPage::OnToolbarDropDown(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
{
	LPNMTOOLBAR lpnmtb = (LPNMTOOLBAR) pnmh;

	CMenu Menu = m_FunctionManager.CreateSpecFunctionDropMenu();
	CToolBarCtrl Toolbar(lpnmtb->hdr.hwndFrom);
	CRect r = lpnmtb->rcButton;
	Toolbar.ClientToScreen(r);
	Toolbar.Detach();
	int ID = Menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RETURNCMD, r.left, r.bottom, m_hWnd);
	if (!ID)
		return 0;

	CAtlArray<MessageStruct*> Messages;
	VSFunction* pFunc = m_FunctionManager.AddSpecFunction(ID, Messages);
	if (pFunc)
	{
		for (size_t i = 0; i < Messages.GetCount(); i++)
		{
			HandlerStruct Handler;
			if (m_MessageManager.InsertWindowsMessageHandler(Messages[i], Handler))
			{
				AddHandler(&Handler);
			}
		}
		int k = m_Functions.AddString(pFunc->Name);
		m_Functions.SetItemDataPtr(k, pFunc);
	}
	return 0;
}
Example #6
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 #7
0
void SlimItem::ScanPathSync()
{
    DWORD dwAttributes;
    CAtlArray<CString> itemPaths;

    GetPaths(itemPaths);

    for (size_t i = 0; i < itemPaths.GetCount(); i++)
    {
        dwAttributes = ::GetFileAttributes(itemPaths[i]);
        if (INVALID_FILE_ATTRIBUTES == dwAttributes)
            continue;

        if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            if (!slimhelper::ScanDirectory(itemPaths[i], this))
                break;
        }
        else
        {
            slimhelper::ScanFile(itemPaths[i], 0, INVALID_FILE_ATTRIBUTES, this);
        }
    }

    CheckEnable();
    ::PostMessage(m_hNotifyWnd, SLIM_WM_ITEM_SCAN_END, 0, 0);
}
Example #8
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 #9
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 #10
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 #11
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 #12
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("|");
}
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;
}
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 #15
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("|");
}
Example #16
0
/*-----------------------------------------------------------------------------
-----------------------------------------------------------------------------*/
int	CWsHook::GetAddrInfoW(PCWSTR pNodeName, PCWSTR pServiceName, const ADDRINFOW * pHints, PADDRINFOW * ppResult)
{
	int ret = WSAEINVAL;
	bool overrideDNS = false;

	void * context = NULL;
	CString name = CW2T(pNodeName);
	CAtlArray<DWORD> addresses;
	if( dlg && pNodeName )
		overrideDNS = dlg->DnsLookupStart( name, context, addresses );

	if( _GetAddrInfoW && !overrideDNS )
		ret = _GetAddrInfoW(CT2W((LPCWSTR)name), pServiceName, pHints, ppResult);
	else if( overrideDNS ) {
		if( addresses.IsEmpty() )
			ret = EAI_NONAME;
		else {
			// build the response structure with the addresses we looked up
			ret = 0;
			DWORD count = addresses.GetCount();

			ADDRINFOW_ADDR * result = (ADDRINFOW_ADDR *)malloc(sizeof(ADDRINFOW_ADDR) * count);
			for (DWORD i = 0; i < count; i++) {
				memset( &result[i], 0, sizeof(ADDRINFOW_ADDR) );
				result->info.ai_family = AF_INET;
				result->info.ai_addrlen = sizeof(struct sockaddr_in);
				result->info.ai_addr = (struct sockaddr *)&(result->addr);
				result->addr.sin_family = AF_INET;
				result->addr.sin_addr.S_un.S_addr = addresses[i];
				if( i < count - 1 )
					result->info.ai_next = (PADDRINFOW)&result[i+1];
			}
			addrInfo.AddTail(result);

			*ppResult = (PADDRINFOW)result;
		}
	}

	if (!ret && dlg) {
		PADDRINFOW addr = *ppResult;
		while (addr) {
      if (addr->ai_canonname)
        dlg->DnsLookupAlias(name, addr->ai_canonname);

      if (context && 
          addr->ai_addrlen >= sizeof(struct sockaddr_in) &&
          addr->ai_family == AF_INET ) {
				struct sockaddr_in * ipName = (struct sockaddr_in *)addr->ai_addr;
				dlg->DnsLookupAddress(context, ipName->sin_addr);
			}

			addr = addr->ai_next;
		}
    
    if (context)
		  dlg->DnsLookupDone(context);
	}

	return ret;
}
Example #17
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("|");
}
Example #18
0
void COPCItem::getProperties(const CAtlArray<CPropertyDescription> &propsToRead, ATL::CAutoPtrArray<SPropertyValue> &propsRead){
	unsigned noProperties = (DWORD)propsToRead.GetCount();
	VARIANT *pValues = NULL;
	HRESULT *pErrors = NULL;
	DWORD *pPropertyIDs = new DWORD[noProperties];
	for (unsigned i = 0; i < noProperties; i++){
		pPropertyIDs[i] = propsToRead.GetAt(i).id;
	}
	propsRead.RemoveAll();
	propsRead.SetCount(noProperties);
	
	USES_CONVERSION;
	HRESULT res = group.getServer().getPropertiesInterface()->GetItemProperties(T2OLE(name), noProperties, pPropertyIDs, &pValues, &pErrors);
	delete []pPropertyIDs;
	if (FAILED(res)){
		throw OPCException("Failed to restrieve property values", res);
	}

	for (unsigned i = 0; i < noProperties; i++){
		CAutoPtr<SPropertyValue> v;
		if (!FAILED(pErrors[i])){
			v.Attach(new SPropertyValue(propsToRead[i], pValues[i]));
		}
		propsRead[i]=v;
	}

	COPCClient::comFree(pErrors);
	COPCClient::comFreeVariant(pValues, noProperties);
}
Example #19
0
bool CResources::LoadString(CTextFile& file)
{
	while(!file.Eof())
	{
		CString line;
		file.ReadLine(line);
		line.Trim();
		if (line == _T("BEGIN"))
			break;
	}
	if (file.Eof())
		return false;

	int sepcount = 0;

	while(!file.Eof())
	{
		CString line;
		file.ReadLine(line);
		CAtlArray<CString> Words;
		CutString(line, Words);
		CString word = Words[0];

		if(word == _T("END"))
			return true;
		
		ResString item;
		item.m_ID = word;
		if (Words.GetCount() > 1)
		{
			item.m_String = Words[1];
		}
	}
	return false;
}
Example #20
0
POSITION CPlaylist::Shuffle()
{
    static INT_PTR idx = 0;
    static INT_PTR count = 0;
    static CAtlArray<plsort_t> a;

    ASSERT(GetCount() > 2);
    // insert or remove items in playlist, or index out of bounds then recalculate
    if ((count != GetCount()) || (idx >= GetCount())) {
        a.RemoveAll();
        idx = 0;
        a.SetCount(count = GetCount());

        POSITION pos = GetHeadPosition();
        for (INT_PTR i = 0; pos; i++, GetNext(pos)) {
            a[i].pos = pos;    // initialize position array
        }

        //Use Fisher-Yates shuffle algorithm
        srand((unsigned)time(nullptr));
        for (INT_PTR i = 0; i < (count - 1); i++) {
            INT_PTR r = i + (rand() % (count - i));
            POSITION temp = a[i].pos;
            a[i].pos = a[r].pos;
            a[r].pos = temp;
        }
    }

    return a[idx++].pos;
}
Example #21
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 #22
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 #23
0
BOOL SlimItem::CompressPaths()
{
    DWORD dwAttributes;
    CAtlArray<CString> itemPaths;

    GetPaths(itemPaths);

    for (size_t i = 0; i < itemPaths.GetCount(); i++)
    {
        dwAttributes = ::GetFileAttributes(itemPaths[i]);
        if (INVALID_FILE_ATTRIBUTES == dwAttributes)
            continue;

        if (dwAttributes & FILE_ATTRIBUTE_COMPRESSED
            || dwAttributes & FILE_ATTRIBUTE_SPARSE_FILE)
        {
            continue;
        }

        if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)
        {
            slimhelper::CompressDirectory(itemPaths[i], this);
        }
        else
        {
            slimhelper::CompressFile(itemPaths[i], 0, dwAttributes, this);
        }
    }

    return TRUE;
}
Example #24
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 #25
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 #26
0
int CDTManager::GetTasks( CAtlArray<void*>& tasks )
{
	for (POSITION p=_tks.GetStartPosition();p;)
	{
		tasks.Add(_tks.GetNextKey(p));
	}
	return (int)tasks.GetCount();
}
Example #27
0
bool CJpegEncoderMem::PutBytes(const void* pData, int len)
{
	CAtlArray<BYTE> moredata;
	moredata.SetCount(len);
	memcpy(moredata.GetData(), pData, len);
	m_pdata->Append(moredata);
	return true;
}
Example #28
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]);
    }
}
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 #30
0
BOOL CPPageTweaks::OnInitDialog()
{
	__super::OnInitDialog();

	SetHandCursor(m_hWnd, IDC_COMBO1);

	AppSettings& s = AfxGetAppSettings();

	m_fDisableXPToolbars = s.fDisableXPToolbars;
	m_fUseWMASFReader = s.fUseWMASFReader;
	m_nJumpDistS = s.nJumpDistS;
	m_nJumpDistM = s.nJumpDistM;
	m_nJumpDistL = s.nJumpDistL;
	m_fNotifyMSN = s.fNotifyMSN;
	m_fNotifyGTSdll = s.fNotifyGTSdll;

	m_fPreventMinimize = s.m_fPreventMinimize;
	m_fUseWin7TaskBar = s.m_fUseWin7TaskBar;
	m_fDontUseSearchInFolder =s.m_fDontUseSearchInFolder;

	m_OSD_Size = s.nOSD_Size;
	m_OSD_Font = s.m_OSD_Font;

	CString str;
	int iSel = 0;
	m_FontType.Clear();
	m_FontSize.Clear();
	HDC dc = CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
	CAtlArray<CString> fntl;
	EnumFontFamilies(dc, NULL,(FONTENUMPROC)EnumFontProc, (LPARAM)&fntl);
	DeleteDC(dc);
	for (int i=0; i< fntl.GetCount(); i++)
	{
		if (i>0 && fntl[i-1] == fntl[i]) continue;
		m_FontType.AddString(fntl[i]);
	}
	for (int i=0; i< m_FontType.GetCount(); i++)
	{
		m_FontType.GetLBText(i,str);
		if (m_OSD_Font == str) iSel=i;
	}
	m_FontType.SetCurSel(iSel);

	for (int i=10; i<26; i++)
	{
		str.Format(_T("%d"), i);
		m_FontSize.AddString(str);
		if (m_OSD_Size == i) iSel=i;
	}
	m_FontSize.SetCurSel(iSel-10);

	UpdateData(FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}