int FTP::GetFindData(PluginPanelItem **pPanelItem, int *pItemsNumber, int OpMode) { PROC(("FTP::GetFindData",NULL)) DWORD b,e; char *Data[3]; *pPanelItem = NULL; *pItemsNumber = 0; //Hosts if(ShowHosts) { EnumHost Enum(HostsPath); FP_SizeItemList il(FALSE); PluginPanelItem tmp; FTPHost h; if(!IS_SILENT(OpMode)) { memset(&tmp, 0, sizeof(tmp)); strcpy(tmp.FindData.cFileName,".."); tmp.FindData.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY; if(!IS_SILENT(OpMode)) { tmp.Description = (char *)".."; tmp.CustomColumnNumber = 3; tmp.CustomColumnData = Data; tmp.CustomColumnData[0] = (char *)".."; tmp.CustomColumnData[1] = (char *)".."; tmp.CustomColumnData[2] = (char *)".."; } if(!il.Add(&tmp)) return FALSE; } while(true) { if(!Enum.GetNextHost(&h)) break; if(!h.Read(NULL)) continue; memset(&tmp, 0, sizeof(tmp)); /* Panel item MUST have name the save as file saved to disk in case you want to copy between panels work. */ h.MkINIFile(tmp.FindData.cFileName,NULL,""); tmp.FindData.ftLastWriteTime = h.LastWrite; tmp.FindData.dwFileAttributes = h.Folder ? FILE_ATTRIBUTE_DIRECTORY : 0; tmp.Flags = PPIF_USERDATA; tmp.PackSizeHigh = FTP_HOSTID; tmp.UserData = (DWORD_PTR)&h; if(!IS_SILENT(OpMode)) { tmp.Description = h.HostDescr; tmp.CustomColumnNumber = 3; tmp.CustomColumnData = Data; tmp.CustomColumnData[0] = h.Host; //C0 tmp.CustomColumnData[1] = h.Home; //C1 tmp.CustomColumnData[2] = h.User; //C2 } if(!il.Add(&tmp)) return FALSE; Log(("Item[%d]=[%s] attr=%08X", il.Count()-1, FTP_FILENAME(il.Item(il.Count()-1)), il.Item(il.Count()-1)->FindData.dwFileAttributes)); } *pPanelItem = il.Items(); *pItemsNumber = il.Count(); return TRUE; } //FTP FP_Screen _scr; FTPFileInfo FileInfo; if(!hConnect) { goto AskConnect; } Restart: if(!FtpFindFirstFile(hConnect, "*", &FileInfo, &ResetCache)) { if(GetLastError() == ERROR_NO_MORE_FILES) { *pItemsNumber = 0; return TRUE; } if(SwitchingToFTP && GetLastError() == ERROR_CANCELLED) { ; } else { if(CurrentState == fcsExpandList) { FreeFindData(*pPanelItem,*pItemsNumber); *pPanelItem = NULL; *pItemsNumber = 0; return FALSE; } //Query reconnect do { if(!hConnect) break; if(GetLastError() == ERROR_CANCELLED) break; if(!hConnect->ConnectMessageTimeout(MConnectionLost,Host.HostName,-MRestore)) { Log(("WaitMessage cancelled")); break; } if(FtpCmdLineAlive(hConnect) && FtpKeepAlive(hConnect)) goto Restart; if(SelectFile.Length() && CurrentState != fcsExpandList) SaveUsedDirNFile(); AskConnect: if(Connect()) goto Restart; else break; } while(true); } if(!ShowHosts) BackToHosts(); FreeFindData(*pPanelItem, *pItemsNumber); return GetFindData(pPanelItem,pItemsNumber,OpMode); } GET_TIME(b); do { if(Opt.ShowIdle) { char str[ 200 ]; GET_TIME(e); if(CMP_TIME(e,b) > 0.5) { _snprintf(str,ARRAYSIZE(str),"%s%d", FP_GetMsg(MReaded), *pItemsNumber); SetLastError(ERROR_SUCCESS); IdleMessage(str,Opt.ProcessColor); b = e; if(CheckForEsc(FALSE)) { SetLastError(ERROR_CANCELLED); return FALSE; } } } PluginPanelItem *NewPanelItem=*pPanelItem; if((*pItemsNumber % 1024) == 0) { if(!NewPanelItem) NewPanelItem = (PluginPanelItem *)malloc((1024+1)*sizeof(PluginPanelItem)); else NewPanelItem = (PluginPanelItem *)realloc(NewPanelItem,(*pItemsNumber+1024+1)*sizeof(PluginPanelItem)); if(NewPanelItem == NULL) { /*-*/Log(("GetFindData(file)::!reallocate plugin panels items %d -> %d",*pItemsNumber,*pItemsNumber+1024+1)); return FALSE; } *pPanelItem=NewPanelItem; } PluginPanelItem *CurItem = &NewPanelItem[*pItemsNumber]; memset(CurItem, 0, sizeof(PluginPanelItem)); CurItem->FindData = FileInfo.FindData; if(!IS_SILENT(OpMode)) { CurItem->CustomColumnNumber = FTP_COL_MAX; CurItem->Owner = FileInfo.FTPOwner[0] ? strdup(FileInfo.FTPOwner) : NULL; CurItem->CustomColumnData = (LPSTR*)malloc(sizeof(LPSTR*)*FTP_COL_MAX); CurItem->CustomColumnData[FTP_COL_MODE] = strdup(FileInfo.UnixMode); CurItem->CustomColumnData[FTP_COL_LINK] = strdup(FileInfo.Link); hConnect->ToOEM(CurItem->CustomColumnData[FTP_COL_LINK]); } (*pItemsNumber)++; } while(FtpFindNextFile(hConnect,&FileInfo)); return TRUE; }
/** * Return property information. */ HRESULT CNseBaseItem::GetProperty(REFPROPERTYKEY pkey, CComPropVariant& v) { ATLASSERT(v.vt==VT_EMPTY); if( pkey == PKEY_ParsingName ) { const VFS_FIND_DATA wfd = GetFindData(); return ::InitPropVariantFromString(wfd.cFileName, &v); } if( pkey == PKEY_ItemName ) { const VFS_FIND_DATA wfd = GetFindData(); return ::InitPropVariantFromString(wfd.cFileName, &v); } if( pkey == PKEY_ItemNameDisplay ) { const VFS_FIND_DATA wfd = GetFindData(); return ::InitPropVariantFromString(wfd.cFileName, &v); } if( pkey == PKEY_FileName ) { const VFS_FIND_DATA wfd = GetFindData(); return ::InitPropVariantFromString(wfd.cFileName, &v); } if( pkey == PKEY_FileAttributes ) { const VFS_FIND_DATA wfd = GetFindData(); return ::InitPropVariantFromUInt32(wfd.dwFileAttributes, &v); } if( pkey == PKEY_ParsingPath ) { CCoTaskString strPath; CPidl pidlFull(m_pFolder->m_pidlRoot, m_pidlFolder, m_pidlItem); HR( ::SHGetNameFromIDList(pidlFull, SIGDN_DESKTOPABSOLUTEPARSING, &strPath) ); return ::InitPropVariantFromString(strPath, &v); } if( pkey == PKEY_ItemPathDisplay ) { CCoTaskString strPath; CPidl pidlFull(m_pFolder->m_pidlRoot, m_pidlFolder, m_pidlItem); HR( ::SHGetNameFromIDList(pidlFull, SIGDN_DESKTOPABSOLUTEEDITING, &strPath) ); return ::InitPropVariantFromString(strPath, &v); } if( pkey == PKEY_ItemPathDisplayNarrow ) { CComPropVariant vDispName; HR( GetProperty(PKEY_ItemNameDisplay, vDispName) ); HR( vDispName.ChangeType(VT_LPWSTR) ); CCoTaskString strParent; HR( ::SHGetNameFromIDList(m_pFolder->m_pidlMonitor, SIGDN_DESKTOPABSOLUTEEDITING, &strParent) ); WCHAR wszNarrow[MAX_PATH + 4] = { 0 }; ::wnsprintf(wszNarrow, lengthof(wszNarrow) - 1, L"%s (%s)", vDispName.pwszVal, static_cast<LPCWSTR>(strParent)); return ::InitPropVariantFromString(strParent.IsEmpty() ? vDispName.pwszVal : wszNarrow, &v); } if( pkey == PKEY_ItemFolderPathDisplay ) { CCoTaskString strFolder; HR( ::SHGetNameFromIDList(m_pFolder->m_pidlMonitor, SIGDN_DESKTOPABSOLUTEEDITING, &strFolder) ); return ::InitPropVariantFromString(strFolder, &v); } if( pkey == PKEY_ItemFolderPathDisplayNarrow ) { CCoTaskString strFolder; HR( ::SHGetNameFromIDList(m_pFolder->m_pidlMonitor, SIGDN_DESKTOPABSOLUTEEDITING, &strFolder) ); LPWSTR pstrSep = wcsrchr(strFolder, '\\'); if( pstrSep == NULL ) pstrSep = L"\0\0"; else *pstrSep = '\0'; WCHAR wszNarrow[MAX_PATH + 4] = { 0 }; ::wnsprintf(wszNarrow, lengthof(wszNarrow) - 1, L"%s (%s)", pstrSep + 1, static_cast<LPCWSTR>(strFolder)); return ::InitPropVariantFromString(pstrSep[1] == '\0' ? static_cast<LPCWSTR>(strFolder) : wszNarrow, &v); } if( pkey == PKEY_ItemType ) { // Assume no canonical type; return V_EMPTY return S_OK; } if( pkey == PKEY_ItemTypeText ) { // Assume no canonical type; return V_EMPTY return S_OK; } if( pkey == PKEY_PerceivedType ) { return ::InitPropVariantFromInt32(PERCEIVED_TYPE_UNKNOWN, &v); } if( pkey == PKEY_FindData ) { const VFS_FIND_DATA wfd = GetFindData(); return ::InitPropVariantFromBuffer(&wfd, sizeof(WIN32_FIND_DATAW), &v); } if( pkey == PKEY_SFGAOFlags ) { return ::InitPropVariantFromUInt32(GetSFGAOF((SFGAOF)(~SFGAO_VALIDATE)), &v); } if( pkey == PKEY_DescriptionID ) { SHDESCRIPTIONID did = { SHDID_FS_OTHER, CLSID_ShellFolder }; return ::InitPropVariantFromBuffer(&did, sizeof(did), &v); } if( pkey == PKEY_Volume_IsRoot ) { return ::InitPropVariantFromBoolean(IsRoot(), &v); } #if _WINVER > _WIN32_WINNT_LONGHORN if( pkey == PKEY_NamespaceCLSID ) { return ::InitPropVariantFromCLSID(CLSID_ShellFolder, &v); } if( pkey == PKEY_IsPinnedToNameSpaceTree ) { return ::InitPropVariantFromBoolean(IsRoot(), &v); } #endif // _WIN32_WINNT_LONGHORN return E_FAIL; }