1
0

transfer_thread.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef __TRANSFER_THREAD_
  2. #define __TRANSFER_THREAD_
  3. #include <wchar.h>
  4. class DeviceView;
  5. #define STATUS_ERROR -1
  6. #define STATUS_WAITING 0
  7. #define STATUS_TRANSFERRING 1
  8. #define STATUS_DONE 3
  9. #define STATUS_CANCELLED 4
  10. extern int SynchronousProcedureCall(void * p, ULONG_PTR dwParam);
  11. extern BOOL RecursiveCreateDirectory(wchar_t* buf1); // from replaceVars.cpp
  12. extern wchar_t * FixReplacementVars(wchar_t *str, int str_size, Device * dev, songid_t song); // from replaceVars.cpp
  13. class CopyInst {
  14. public:
  15. CopyInst() : status(STATUS_WAITING), res(0), dev(NULL), equalsType(-1), usesPreCopy(false), usesPostCopy(true), songid(NULL) {
  16. typeCaption[0] = 0;
  17. statusCaption[0] = 0;
  18. trackCaption[0] = 0;
  19. sourceDevice[0] = 0;
  20. destDevice[0] = 0;
  21. lastChanged[0] = 0;
  22. sourceFile[0] = 0;
  23. }
  24. virtual bool PreCopyAction() {return false;} // called in main window thread. Return true to skip.
  25. virtual bool CopyAction()=0; // Do the actual transfer, called in transfer thread. Return true if failed.
  26. virtual void PostCopyAction() {} // called in main window thread
  27. virtual void Cancelled() {} // the transfer has been cancelled
  28. virtual bool Equals(CopyInst * b)=0; // use equalsType to check if it is safe to cast b to your own type. Return true if equal.
  29. int status; // one of STATUS_*
  30. int res; // don't mess with this!
  31. DeviceView * dev;
  32. wchar_t typeCaption[128];
  33. wchar_t statusCaption[128];
  34. wchar_t trackCaption[128];
  35. wchar_t sourceDevice[128];
  36. wchar_t destDevice[128];
  37. wchar_t lastChanged[128];
  38. wchar_t sourceFile[MAX_PATH];
  39. int equalsType; // 0 for SongCopyInst, 1 for ReverseCopyInst, -1 for unknown
  40. bool usesPreCopy;
  41. bool usesPostCopy;
  42. songid_t songid;
  43. };
  44. class SongCopyInst : public CopyInst {
  45. public:
  46. SongCopyInst(DeviceView * dev,itemRecordW * song);
  47. virtual ~SongCopyInst();
  48. itemRecordW song;
  49. virtual bool CopyAction();
  50. virtual void PostCopyAction();
  51. virtual void Cancelled();
  52. virtual bool Equals(CopyInst * b);
  53. };
  54. class PlaylistCopyInst : public SongCopyInst {
  55. public:
  56. wchar_t plName[256];
  57. int plid;
  58. C_ItemList * plAddSongs;
  59. PlaylistCopyInst(DeviceView * dev, itemRecordW * song, wchar_t * plName0, int plid0);
  60. virtual ~PlaylistCopyInst();
  61. virtual bool PreCopyAction();
  62. virtual void PostCopyAction();
  63. };
  64. class ReverseCopyInst : public CopyInst {
  65. public:
  66. ReverseCopyInst(DeviceView * dev, const wchar_t * filepath, const wchar_t * format, songid_t song, bool addToLibrary, bool uppercaseext);
  67. virtual bool CopyAction(); // Do the actual transfer, called in transfer thread. Return true if failed.
  68. virtual void PostCopyAction();
  69. virtual bool Equals(CopyInst * b); // use equalsType to check if it is safe to cast b to your own type. Return true if equal.
  70. wchar_t path[2048];
  71. bool uppercaseext;
  72. };
  73. // simple subclass which appends the copied filename to an m3u playlist file after copy.
  74. class ReversePlaylistCopyInst : public ReverseCopyInst {
  75. public:
  76. ReversePlaylistCopyInst(DeviceView * dev, const wchar_t * filepath, const wchar_t * format, songid_t song, wchar_t * playlistFile, wchar_t * playlistName, bool last,bool addToLibrary=true);
  77. virtual bool CopyAction();
  78. virtual void PostCopyAction();
  79. wchar_t playlistFile[MAX_PATH];
  80. wchar_t playlistName[128];
  81. bool last;
  82. };
  83. //DWORD WINAPI ThreadFunc_Transfer(LPVOID lpParam);
  84. #endif //__TRANSFER_THREAD_