00001 // 00002 // LibraryFolders.h 00003 // 00004 // Copyright (c) Shareaza Development Team, 2002-2005. 00005 // This file is part of SHAREAZA (www.shareaza.com) 00006 // 00007 // Shareaza is free software; you can redistribute it 00008 // and/or modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 of 00010 // the License, or (at your option) any later version. 00011 // 00012 // Shareaza is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with Shareaza; if not, write to the Free Software 00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 // 00021 00022 #pragma once 00023 00024 class CLibraryFolder; 00025 class CAlbumFolder; 00026 class CLibraryFile; 00027 class CXMLElement; 00028 class CCollectionFile; 00029 00030 00031 class CLibraryFolders : public CComObject 00032 { 00033 // Construction 00034 public: 00035 CLibraryFolders(); 00036 virtual ~CLibraryFolders(); 00037 00038 DECLARE_DYNAMIC(CLibraryFolders) 00039 00040 // Attributes 00041 protected: 00042 CObList m_pFolders; 00043 CAlbumFolder* m_pAlbumRoot; 00044 BOOL m_bRemoveMask; 00045 00046 // Physical Folder Operations 00047 public: 00048 POSITION GetFolderIterator() const; 00049 CLibraryFolder* GetNextFolder(POSITION& pos) const; 00050 int GetFolderCount() const; 00051 CLibraryFolder* GetFolder(LPCTSTR pszPath) const; 00052 BOOL CheckFolder(CLibraryFolder* pFolder, BOOL bRecursive = FALSE) const; 00053 public: 00054 CLibraryFolder* AddFolder(LPCTSTR pszPath); 00055 CLibraryFolder* AddFolder(LPCTSTR pszPath, BOOL bShared); 00056 BOOL RemoveFolder(CLibraryFolder* pFolder); 00057 CLibraryFolder* IsFolderShared(LPCTSTR pszPath); 00058 CLibraryFolder* IsSubFolderShared(LPCTSTR pszPath); 00059 static BOOL IsShareable(LPCTSTR pszPath); 00060 00061 // Virtual Album Operations 00062 public: 00063 CAlbumFolder* GetAlbumRoot(); 00064 BOOL CheckAlbum(CAlbumFolder* pFolder) const; 00065 CAlbumFolder* GetAlbumTarget(LPCTSTR pszSchemaURI, LPCTSTR pszMember, LPCTSTR pszValue) const; 00066 CAlbumFolder* GetCollection(SHA1* pSHA1); 00067 BOOL MountCollection(SHA1* pSHA1, CCollectionFile* pCollection); 00068 protected: 00069 void CreateAlbumTree(); 00070 void OnFileDelete(CLibraryFile* pFile); 00071 00072 // Core 00073 protected: 00074 void Clear(); 00075 BOOL ThreadScan(BOOL* pbContinue, BOOL bForce = FALSE); 00076 void Serialize(CArchive& ar, int nVersion); 00077 00078 // COM 00079 protected: 00080 BEGIN_INTERFACE_PART(LibraryFolders, ILibraryFolders) 00081 DECLARE_DISPATCH() 00082 STDMETHOD(get_Application)(IApplication FAR* FAR* ppApplication); 00083 STDMETHOD(get_Library)(ILibrary FAR* FAR* ppLibrary); 00084 STDMETHOD(get__NewEnum)(IUnknown FAR* FAR* ppEnum); 00085 STDMETHOD(get_Item)(VARIANT vIndex, ILibraryFolder FAR* FAR* ppFolder); 00086 STDMETHOD(get_Count)(LONG FAR* pnCount); 00087 END_INTERFACE_PART(LibraryFolders) 00088 00089 DECLARE_INTERFACE_MAP() 00090 00091 friend class CLibrary; 00092 }; 00093 00094 extern CLibraryFolders LibraryFolders;