diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/Library/ml_wire/Downloaded.h | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Plugins/Library/ml_wire/Downloaded.h')
-rw-r--r-- | Src/Plugins/Library/ml_wire/Downloaded.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/Src/Plugins/Library/ml_wire/Downloaded.h b/Src/Plugins/Library/ml_wire/Downloaded.h new file mode 100644 index 00000000..2ba1ace8 --- /dev/null +++ b/Src/Plugins/Library/ml_wire/Downloaded.h @@ -0,0 +1,79 @@ +#ifndef NULLSOFT_DOWNLOADEDH +#define NULLSOFT_DOWNLOADEDH + +#include "../nu/AutoLock.h" +#include "../nu/AutoCharFn.h" +#include "..\..\General\gen_ml/ml.h" +#include <vector> +#include "../nu/MediaLibraryInterface.h" + +class DownloadedFile +{ +public: + DownloadedFile(); + DownloadedFile( const wchar_t *_url, const wchar_t *_path, const wchar_t *_channel, const wchar_t *_item, __time64_t publishDate ); + DownloadedFile( const DownloadedFile © ); + ~DownloadedFile(); + + const DownloadedFile &operator =( const DownloadedFile © ); + + void SetPath( const wchar_t *_path ); + void SetURL( const wchar_t *_url ); + void SetItem( const wchar_t *_item ); + void SetChannel( const wchar_t *_channel ); + + size_t bytesDownloaded = 0; + size_t totalSize = 0; + + __time64_t publishDate; + __time64_t downloadDate = 0; + + wchar_t *path = 0; + wchar_t *url = 0; + wchar_t *channel = 0; + wchar_t *item = 0; + + +private: + void Init(); + void Reset(); +}; + +class DownloadList +{ +public: + typedef std::vector<DownloadedFile> DownloadedFileList; + typedef DownloadedFileList::iterator iterator; + typedef DownloadedFileList::const_iterator const_iterator; + + operator Nullsoft::Utility::LockGuard &() { return downloadedLock; } + + void Remove( size_t index ) { downloadList.erase( downloadList.begin() + index ); } + + bool RemoveAndDelete( int index ) + { + SendMessage( mediaLibrary.library, WM_ML_IPC, (WPARAM)downloadList[ index ].path, ML_IPC_DB_REMOVEITEMW ); + + if ( !DeleteFile( downloadList[ index ].path ) && GetLastError() != ERROR_FILE_NOT_FOUND ) + return false; + + downloadList.erase( downloadList.begin() + index ); + + return true; + } + + DownloadedFileList downloadList; + Nullsoft::Utility::LockGuard downloadedLock; + + iterator begin() { return downloadList.begin(); } + iterator end() { return downloadList.end(); } +}; + +extern DownloadList downloadedFiles; +extern int downloadsItemSort; +extern bool downloadsSortAscending; + +void CleanupDownloads(); +__time64_t filetime(const wchar_t *file); + +#endif
\ No newline at end of file |