0) { m_bstrCrossLinksHTML += OLESTR(" title=\""); m_bstrCrossLinksHTML += wszToolTip; m_bstrCrossLinksHTML += OLESTR("\""); } m_bstrCrossLinksHTML += OLESTR(" name=\""); m_bstrCrossLinksHTML += WV_LINKNAME; m_bstrCrossLinksHTML += OLESTR("\""); m_bstrCrossLinksHTML += OLESTR(">"); m_bstrCrossLinksHTML += pwszDisplayName; m_bstrCrossLinksHTML += OLESTR(""); return S_OK; } HRESULT CFileListWrapper::GetCrossLink(int nFolder, UINT uIDToolTip) { HRESULT hres = E_FAIL; // Assume error // Get the links. WCHAR wszDisplayName[MAX_PATH], wszUrlPath[MAX_PATH]; BOOL bThisFolder; if (SUCCEEDED(IsItThisFolder(nFolder, bThisFolder, wszDisplayName, ARRAYSIZE(wszDisplayName), wszUrlPath, ARRAYSIZE(wszUrlPath))) && !bThisFolder) { hres = FormatCrossLink(wszDisplayName, wszUrlPath, uIDToolTip); } return hres; } HRESULT CFileListWrapper::GetCrossLinks() { WCHAR wszSeeAlso[MAX_PATH]; m_bstrCrossLinksHTML += OLESTR("
");
LoadStringW(_Module.GetResourceInstance(), IDS_SEEALSO, wszSeeAlso, ARRAYSIZE(wszSeeAlso));
m_bstrCrossLinksHTML += wszSeeAlso;
GetCrossLink(CSIDL_PERSONAL, IDS_MYDOCSTEXT);
if (!SHRestricted(REST_NONETHOOD))
{
GetCrossLink(CSIDL_NETWORK, IDS_MYNETPLACESTEXT);
}
if (FAILED(GetCrossLink(CSIDL_DRIVES, IDS_MYCOMPTEXT)) && !SHRestricted(REST_NONETHOOD))
{
// This is the My Computer folder - Add a link to Network and Dial-up Connections folder
WCHAR wszNDC[MAX_PATH];
wszNDC[0] = L'\0';
LoadStringW(_Module.GetResourceInstance(), IDS_NDC, wszNDC, ARRAYSIZE(wszNDC));
FormatCrossLink(wszNDC, L"shell:ConnectionsFolder", IDS_NDCTEXT);
}
return S_OK;
}
// The Media Player folks haven't published the IMediaPlayer interface, so I define it here.
// Should strip it out when their declaration makes it to the public headers.
const IID IID_IMediaPlayer = {0x22D6F311,0xB0F6,0x11D0,{0x94,0xAB,0x00,0x80,0xC7,0x4C,0x7E,0x95}};
HRESULT CFileListWrapper::Init(
CComPtr ");
}
if (SUCCEEDED(m_pThumbNailWrapper->UsedSpace(bstrSpace)))
{
m_bstrInfoHTML += OLESTR(" ");
m_bstrInfoHTML += bstrDesc;
m_bstrInfoHTML += OLESTR(": ");
m_bstrInfoHTML += bstrDateTime;
}
return hr;
}
HRESULT CFileListWrapper::GetItemSize()
{
WCHAR wszTemp[MAX_PATH];
long lSize = 0;
HRESULT hr = m_spFolderItem->get_Size(&lSize);
if (SUCCEEDED(hr))
{
if (lSize > 0L)
{
m_bstrInfoHTML += OLESTR(" ");
IfFalseRet(LoadStringW(_Module.GetResourceInstance(), IDS_SIZE, wszTemp, ARRAYSIZE(wszTemp)), E_FAIL);
m_bstrInfoHTML += wszTemp;
StrFormatByteSizeW(lSize, wszTemp, ARRAYSIZE(wszTemp));
m_bstrInfoHTML += wszTemp;
}
}
else
{
CComBSTR bstrDesc, bstrSize;
hr = GetItemInfo(IDS_SIZE_COL, L"Size", bstrDesc, bstrSize);
if (SUCCEEDED(hr) && (bstrSize.Length() > 0))
{
m_bstrInfoHTML += OLESTR(" ");
m_bstrInfoHTML += bstrDesc;
m_bstrInfoHTML += OLESTR(": ");
m_bstrInfoHTML += bstrSize;
}
}
return hr;
}
const WCHAR c_wszAttributeCodes[] = {L"RHSCE"};
const int c_iaAttribStringIDs[] = {IDS_READONLY, IDS_HIDDEN, IDS_SYSTEM, //IDS_ARCHIVE,
IDS_COMPRESSED, IDS_ENCRYPTED};
HRESULT FormatAttributes(CComBSTR& bstrDetails, CComBSTR& bstrText)
{
HRESULT hr = S_OK;
BOOL bFlag = FALSE;
WCHAR wszDelimiter[10], wszTemp[MAX_PATH];
IfFalseRet(LoadStringW(_Module.GetResourceInstance(), IDS_DELIMITER, wszDelimiter, ARRAYSIZE(wszDelimiter)), E_FAIL);
for (int i = 0; i < (int)bstrDetails.Length(); i++)
{
WCHAR* pwCh;
if ((pwCh = StrChrIW(c_wszAttributeCodes, bstrDetails[i]))) // Is the value, one of "RHSCE"?
{
if (bFlag)
{
bstrText += wszDelimiter;
bstrText += OLESTR(" ");
}
else
{
bFlag = TRUE;
}
int iPos = (int)(pwCh - c_wszAttributeCodes);
ASSERT((iPos >= 0) && (iPos < ARRAYSIZE(c_iaAttribStringIDs)));
IfFalseRet(LoadStringW(_Module.GetResourceInstance(), c_iaAttribStringIDs[iPos], wszTemp, ARRAYSIZE(wszTemp)), E_FAIL);
bstrText += wszTemp;
}
}
if (!bFlag)
{
IfFalseRet(LoadStringW(_Module.GetResourceInstance(), IDS_NOATTRIBUTES, wszTemp, ARRAYSIZE(wszTemp)), E_FAIL);
bstrText += wszTemp;
}
return hr;
}
HRESULT CFileListWrapper::GetItemAttributes()
{
VARIANT_BOOL fIsFolder;
HRESULT hr = m_spFolderItem->get_IsFolder(&fIsFolder);
if (SUCCEEDED(hr) && (fIsFolder == VARIANT_FALSE))
{
VARIANT_BOOL fIsFileSystem;
hr = m_spFolderItem->get_IsFileSystem(&fIsFileSystem);
if (SUCCEEDED(hr) && (fIsFileSystem == VARIANT_TRUE))
{
CComBSTR bstrDesc, bstrAttributes;
hr = GetItemInfo(IDS_ATTRIBUTES_COL, L"Attributes", bstrDesc, bstrAttributes);
if (SUCCEEDED(hr)) // Go ahead evenif (bstrAttributes.Length() > 0)
{
m_bstrInfoHTML += OLESTR(" ");
m_bstrInfoHTML += bstrDesc;
m_bstrInfoHTML += OLESTR(": ");
FormatAttributes(bstrAttributes, m_bstrInfoHTML);
}
}
}
return hr;
}
HRESULT MakeMailLink(LPCWSTR pwszMailee, CComBSTR& bstrText)
{
HRESULT hr = S_OK;
bstrText += OLESTR("");
bstrText += pwszMailee;
bstrText += OLESTR("");
return hr;
}
HRESULT CFileListWrapper::GetItemAuthor()
{
CComBSTR bstrDesc, bstrAuthor;
HRESULT hr = GetItemInfo(IDS_AUTHOR_COL, L"Author", bstrDesc, bstrAuthor);
if (SUCCEEDED(hr) && (bstrAuthor.Length() > 0))
{
m_bstrInfoHTML += OLESTR(" ");
m_bstrInfoHTML += bstrDesc;
m_bstrInfoHTML += OLESTR(": ");
if (StrChrW(bstrAuthor, L'@')) // This is most likely to be an e-mail address
{
MakeMailLink(bstrAuthor, m_bstrInfoHTML);
}
else
{
m_bstrInfoHTML += bstrAuthor;
}
m_bFoundAuthor = TRUE;
}
return hr;
}
HRESULT MakeLinksHyper(LPCWSTR pwszStr, CComBSTR& bstrText)
{
HRESULT hr = S_OK;
LPWSTR pwszBegin;
if ((pwszBegin = StrStrIW(pwszStr, L"http://"))
|| (pwszBegin = StrStrIW(pwszStr, L"file://")))
{
WCHAR wszTemp[INTERNET_MAX_URL_LENGTH];
int i;
for (i = 0; &pwszStr[i] != pwszBegin; i++)
{
wszTemp[i] = pwszStr[i];
}
wszTemp[i] = L'\0';
bstrText += wszTemp;
WCHAR* pwChEnd = StrStrW(pwszBegin, L" ");
if (!pwChEnd)
{
pwChEnd = &pwszBegin[lstrlenW(pwszBegin)];
}
for (i = 0; &pwszBegin[i] != pwChEnd; i++) // Seperate out the http://... or file://... string
{
wszTemp[i] = pwszBegin[i];
}
wszTemp[i] = L'\0';
MakeLink(wszTemp, wszTemp, bstrText);
for (i = 0; pwChEnd[i]; i++) // Copy out the rest, till the end
{
wszTemp[i] = pwChEnd[i];
}
wszTemp[i] = L'\0';
bstrText += wszTemp;
}
else
{
bstrText += pwszStr;
}
return hr;
}
HRESULT FormatDetails(LPCWSTR pwszDesc, LPCWSTR pwszDetails, CComBSTR& bstrText)
{
HRESULT hr = S_OK;
bstrText += OLESTR(" ");
bstrText += pwszDesc;
bstrText += OLESTR(":");
if ((lstrlenW(pwszDesc) + lstrlenW(pwszDetails)) > 32)
{
bstrText += OLESTR(" ");
}
return hr;
}
HRESULT CFileListWrapper::GetItemInfo(long lResId, LPWSTR wszInfoDescCanonical, CComBSTR& bstrInfoDesc, CComBSTR& bstrInfo)
{
HRESULT hr = E_FAIL;
WCHAR wszInfoDesc[MAX_PATH];
LoadStringW(_Module.GetResourceInstance(), lResId, wszInfoDesc, ARRAYSIZE(wszInfoDesc));
bstrInfoDesc = wszInfoDesc;
if (m_spFolderItem2)
{
CComBSTR bstrInfoDescCanonical = wszInfoDescCanonical;
CComVariant var;
hr = m_spFolderItem2->ExtendedProperty(bstrInfoDescCanonical, &var);
if (SUCCEEDED(hr))
{
WCHAR wszTemp[80];
if (var.vt == VT_BSTR)
{
// Of the three types of data we care about one is dangerous. The BSTR data that
// we read from the file could contain HTML code which we would render in WebView.
// This could cause potential security problems. To get around this we sanatize
// the BSTR before we return it. We need to do the following replacements:
//
// original replace with
// < <
// > >
// " " <= this would be paranoid and isn't 100% critical
// ' ‘ <= this would be paranoid and isn't 100% critical
LPWSTR psz = var.bstrVal;
LPWSTR pszBad;
if (psz == NULL)
{
// we probably cant depend on hr and the out param matching (since this is
// scriptable and therefore must return success)
psz = L"";
}
while (pszBad = StrPBrkW(psz, L"<>"))
{
// store the bad character
WCHAR chBadChar = *pszBad;
// null the string
*pszBad = NULL;
// add the good part of the string, if there is any
if ( *psz )
bstrInfo += psz;
// based on which bad character we found add the correct HTLM special character code
switch ( chBadChar )
{
case L'<':
bstrInfo += L"<";
break;
case L'>':
bstrInfo += L">";
break;
}
// Advance the psz pointer. Note it might be an empty string after this.
psz = pszBad+1;
}
// Add the remaining portion of the good string, even if it's an empty string.
// bstrInfo is passed in uninitialized so we need to set it to something even
// if that something is an empty string.
bstrInfo += psz;
}
else if (var.vt == VT_DATE)
{
SYSTEMTIME st;
FILETIME ft;
if (VariantTimeToSystemTime(var.date, &st)
&& SystemTimeToFileTime(&st, &ft)
&& SHFormatDateTimeW(&ft, &m_dwDateFlags, wszTemp, ARRAYSIZE(wszTemp)))
{
bstrInfo += wszTemp;
}
else
{
hr = E_FAIL;
}
}
else if (var.vt == VT_UI8 && StrCmpIW(wszInfoDescCanonical, L"size") == 0)
{
StrFormatByteSize64(var.ullVal, wszTemp, ARRAYSIZE(wszTemp));
bstrInfo += wszTemp;
}
else
{
hr = E_FAIL;
}
}
}
return hr;
}
HRESULT CFileListWrapper::NoneSelected()
{
WCHAR wszIntro[MAX_PATH];
CComPtr ");
CComPtr ");
}
if (cSelection <= MAX_SELECTEDFILES_FOR_DISPLAYING_NAMES)
{
CComBSTR bstrTemp;
for (int i = 0; i < cSelection; i++)
{
if (SUCCEEDED(m_spFolderItems->Item(CComVariant(i), &spFolderItem)))
{
if (SUCCEEDED(spFolderItem->get_Name(&bstrTemp)))
{
m_bstrInfoHTML += " ");
}
return S_OK;
}
HRESULT CFileListWrapper::GetCSCFolderStatus(LONG* plStatus)
{
return m_spFolder2 ? m_spFolder2->get_OfflineStatus(plStatus) : E_FAIL;
}
HRESULT CFileListWrapper::CSCShowStatusInfo()
{
LONG lStatus;
if (m_spCSCText && m_spCSCPlusMin && m_spCSCDetail && m_spCSCButton && m_spCSCStyle
&& m_spCSCDetailStyle && m_spCSCButtonStyle)
{
CComBSTR bstrCSC_Display;
if (SUCCEEDED(GetCSCFolderStatus(&lStatus)) && (lStatus >= 0))
{
CComBSTR bstrCSCText;
CSCGetStatusText(lStatus, bstrCSCText);
bstrCSCText += OLESTR("
");
IfFalseRet(LoadStringW(_Module.GetResourceInstance(), IDS_TOTALSIZE, wszTemp, ARRAYSIZE(wszTemp)), E_FAIL);
m_bstrInfoHTML += wszTemp;
m_bstrInfoHTML += bstrSpace;
bstrSpace.Empty();
m_bstrInfoHTML += OLESTR("");
m_bstrInfoHTML += OLESTR("
");
IfFalseRet(LoadStringW(_Module.GetResourceInstance(), IDS_USEDSPACE, wszTemp, ARRAYSIZE(wszTemp)), E_FAIL);
m_bstrInfoHTML += wszTemp;
m_bstrInfoHTML += bstrSpace;
bstrSpace.Empty();
}
if (SUCCEEDED(m_pThumbNailWrapper->FreeSpace(bstrSpace)))
{
m_bstrInfoHTML += OLESTR("");
m_bstrInfoHTML += OLESTR("
");
IfFalseRet(LoadStringW(_Module.GetResourceInstance(), IDS_FREESPACE, wszTemp, ARRAYSIZE(wszTemp)), E_FAIL);
m_bstrInfoHTML += wszTemp;
m_bstrInfoHTML += bstrSpace;
}
m_pThumbNailWrapper->SetDisplay(CComBSTR(""));
}
}
else if (!bRootFolder)
{
BOOL bDisplayFlag = FALSE;
BOOL bMovieFile = IsMovieFile(bstrPath);
if (bMovieFile || IsSoundFile(bstrPath))
{
CComPtr
");
m_bstrInfoHTML += bstrType;
}
return hr;
}
HRESULT CFileListWrapper::GetItemDateTime()
{
CComBSTR bstrDesc, bstrDateTime;
HRESULT hr = GetItemInfo(IDS_MODIFIED_COL, L"Modified", bstrDesc, bstrDateTime);
if (SUCCEEDED(hr) && (bstrDateTime.Length() > 0))
{
m_bstrInfoHTML += OLESTR("
");
}
else
{
bstrText += OLESTR(" ");
}
MakeLinksHyper(pwszDetails, bstrText);
return hr;
}
HRESULT CFileListWrapper::GetItemComment()
{
CComBSTR bstrDesc, bstrComment;
HRESULT hr = GetItemInfo(IDS_COMMENT_COL, L"Comment", bstrDesc, bstrComment);
if (SUCCEEDED(hr) && (bstrComment.Length() > 0))
{
m_bstrInfoHTML += OLESTR("
";
m_bstrInfoHTML += bstrTemp;
bstrTemp.Empty();
}
spFolderItem = NULL;
}
}
}
}
hr = S_OK;
}
return hr;
}
HRESULT CFileListWrapper::OneSelected()
{
HRESULT hr = E_FAIL;
m_bFoundAuthor = FALSE;
m_bFoundComment = FALSE;
// Get the name of the item, making it a hyper-link if appropriate.
GetItemNameForDisplay();
// Get the type of the item
GetItemType();
if (!m_bPathIsSlow)
{
// Get the comment for the item
GetItemComment();
// Get the HTMLInfoTip
GetItemHTMLInfoTip();
// Get the date/time stamp on the item
GetItemDateTime();
// Get the size of the item
GetItemSize();
// Get the attributes (hidden, RO etc.) of the item
GetItemAttributes();
// Get the author of the document
GetItemAuthor();
DealWithDriveInfo();
}
hr = S_OK;
return hr;
}
HRESULT CFileListWrapper::OnCSCClick()
{
HRESULT hres = E_FAIL;
CComPtr
");
CComBSTR bstrCSCPlusMin;
CComBSTR bstrCSCDetail;
CComBSTR bstrCSCDetail_Display;
if (m_bExpanded)
{
bstrCSCPlusMin = m_bHotTracked ? CSC_MINUSHOT : CSC_MINUSCOLD;
bstrCSCText += OLESTR("
");
CSCGetStatusDetail(lStatus, bstrCSCDetail);
bstrCSCDetail += OLESTR("
");
bstrCSCDetail_Display = OLESTR("");
if (m_bRTLDocument)
{
// [msadek]; Life would be easier if the object model has exposed
// right offset through get_offsetRight().
CComPtr