iPodDevice.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #ifndef _IPODDEVICE_H_
  2. #define _IPODDEVICE_H_
  3. #include <windows.h>
  4. #include <windowsx.h>
  5. #include <stdio.h>
  6. #include <shlobj.h>
  7. #include <time.h>
  8. #include "..\..\General\gen_ml/ml.h"
  9. #include "..\..\Library\ml_pmp/pmp.h"
  10. #include "..\..\Library\ml_pmp/transcoder.h"
  11. #include "../winamp/wa_ipc.h"
  12. #include "../winamp/ipc_pe.h"
  13. #include "iPodDB.h"
  14. #include "resource.h"
  15. #include "..\..\General\gen_ml/itemlist.h"
  16. #include "yail.h"
  17. #include "iPodArtworkDB.h"
  18. #include "iPodInfo.h"
  19. #include <vector>
  20. class iPodDevice : public Device {
  21. public:
  22. HWND gapscanner;
  23. C_ItemList playlists; // list of iPod_mhyp*
  24. Transcoder * transcoder;
  25. iPod_mhbd * db;
  26. char drive;
  27. wchar_t driveW;
  28. int dirnum;
  29. __int64 transferQueueLength;
  30. int image16;
  31. int image160;
  32. ArtDB * artdb;
  33. std::vector<const ArtworkFormat*> thumbs;
  34. uint8_t *fwid;
  35. const iPodInfo *info;
  36. iPodDevice(char drive);
  37. virtual ~iPodDevice();
  38. virtual int parseiTunesDB(bool parseArt);
  39. virtual int writeiTunesDB();
  40. virtual void getFilename(char * buf, int len, songid_t song);
  41. virtual void getFilename(wchar_t *buf, int len, songid_t song);
  42. virtual __int64 getDeviceCapacityAvailable(); // in bytes
  43. virtual __int64 getDeviceCapacityTotal(); // in bytes
  44. virtual void Eject(); // if you ejected successfully, you MUST call plugin.deviceDisconnected(this) and delete this;
  45. virtual void Close(); // save any changes, and call plugin.deviceDisconnected(this) AND delete this;
  46. // return 0 for success, -1 for failed or cancelled
  47. virtual int transferTrackToDevice(const itemRecordW * track, // the track to transfer
  48. void * callbackContext, //pass this to the callback
  49. void (*callback)(void * callbackContext, wchar_t * status), // call this with stats every so often so the GUI can be updated
  50. songid_t * songid, // fill in the songid when you are finished
  51. int * killswitch); // if this gets set to 1, the transfer has been cancelled by the user
  52. virtual int trackAddedToTransferQueue(const itemRecordW *track); // return 0 to accept, -1 for "not enough space", -2 for "incorrect format"
  53. virtual void trackRemovedFromTransferQueue(const itemRecordW *track);
  54. virtual __int64 getTrackSizeOnDevice(const itemRecordW *track); // return the amount of space taken up on the device by the track, or 0 for incompatable (usually the filesize, unless you are transcoding)
  55. virtual void deleteTrack(songid_t songid); // physically remove from device. Be sure to remove it from all the playlists!
  56. virtual void commitChanges(){writeiTunesDB();} // optional. Will be called at a good time to save changes
  57. virtual int getPlaylistCount(); // always at least 1. playlistnumber 0 is the Master Playlist containing all tracks.
  58. // PlaylistName(0) should return the name of the device.
  59. virtual void getPlaylistName(int playlistnumber, wchar_t *buf, int len);
  60. virtual int getPlaylistLength(int playlistnumber);
  61. virtual songid_t getPlaylistTrack(int playlistnumber,int songnum); // returns a songid
  62. virtual void setPlaylistName(int playlistnumber, const wchar_t *buf); // with playlistnumber==0, set the name of the device.
  63. virtual void playlistSwapItems(int playlistnumber, int posA, int posB); // swap the songs at position posA and posB
  64. virtual void sortPlaylist(int playlistnumber, int sortBy);
  65. virtual void addTrackToPlaylist(int playlistnumber, songid_t songid); // adds songid to the end of the playlist
  66. virtual void removeTrackFromPlaylist(int playlistnumber, int songnum); //where songnum is the position of the track in the playlist
  67. virtual void deletePlaylist(int playlistnumber);
  68. virtual int newPlaylist(const wchar_t *name); // create empty playlist, returns playlistnumber
  69. virtual void getTrackArtist(songid_t songid, wchar_t *buf, int len);
  70. virtual void getTrackAlbum(songid_t songid, wchar_t *buf, int len);
  71. virtual void getTrackTitle(songid_t songid, wchar_t *buf, int len);
  72. virtual int getTrackTrackNum(songid_t songid);
  73. virtual int getTrackDiscNum(songid_t songid);
  74. virtual void getTrackGenre(songid_t songid, wchar_t *buf, int len);
  75. virtual int getTrackYear(songid_t songid);
  76. virtual __int64 getTrackSize(songid_t songid); // in bytes
  77. virtual int getTrackLength(songid_t songid); // in millisecs
  78. virtual int getTrackBitrate(songid_t songid); // in kbps
  79. virtual int getTrackPlayCount(songid_t songid);
  80. virtual int getTrackRating(songid_t songid); //0-5
  81. virtual __time64_t getTrackLastPlayed(songid_t songid); // in unix time format
  82. virtual __time64_t getTrackLastUpdated(songid_t songid); // in unix time format
  83. virtual void getTrackAlbumArtist(songid_t songid, wchar_t * buf, int len);
  84. virtual void getTrackComposer(songid_t songid, wchar_t * buf, int len);
  85. virtual int getTrackType(songid_t songid);
  86. virtual void getTrackExtraInfo(songid_t songid, const wchar_t *field, wchar_t * buf, int len); //optional
  87. // feel free to ignore any you don't support
  88. virtual void setTrackArtist(intptr_t songid, const wchar_t *value);
  89. virtual void setTrackAlbum(intptr_t songid, const wchar_t *value);
  90. virtual void setTrackTitle(intptr_t songid, const wchar_t *value);
  91. virtual void setTrackTrackNum(intptr_t songid, int value);
  92. virtual void setTrackDiscNum(intptr_t songid, int value);
  93. virtual void setTrackGenre(intptr_t songid, const wchar_t *value);
  94. virtual void setTrackYear(intptr_t songid, int year);
  95. virtual void setTrackPlayCount(intptr_t songid, int value);
  96. virtual void setTrackRating(intptr_t songid, int value);
  97. virtual void setTrackLastPlayed(intptr_t songid, __time64_t value); // in unix time format
  98. virtual void setTrackLastUpdated(intptr_t songid, __time64_t value); // in unix time format
  99. virtual void setTrackAlbumArtist(songid_t songid, const wchar_t *value);
  100. virtual void setTrackComposer(songid_t songid, const wchar_t *value);
  101. virtual void setTrackExtraInfo(intptr_t songid, const wchar_t *field, const wchar_t *value) {}; //optional
  102. virtual bool playTracks(songid_t * songidList, int listLength, int startPlaybackAt, bool enqueue); // return false if unsupported
  103. virtual intptr_t extraActions(intptr_t param1, intptr_t param2, intptr_t param3,intptr_t param4); // This does nothing yet. For future use.
  104. virtual bool copyToHardDriveSupported() {return true;}
  105. virtual __int64 songSizeOnHardDrive(songid_t song) {return getTrackSize(song);} // how big a song will be when copied back. Return -1 for not supported.
  106. virtual int copyToHardDrive(songid_t song, // the song to copy
  107. wchar_t * path, // path to copy to, in the form "c:\directory\song". The directory will already be created, you must append ".mp3" or whatever to this string! (there is space for at least 10 new characters).
  108. void * callbackContext, //pass this to the callback
  109. void (*callback)(void * callbackContext, wchar_t * status), // call this every so often so the GUI can be updated. Including when finished!
  110. int * killswitch // if this gets set to anything other than zero, the transfer has been cancelled by the user
  111. ); // -1 for failed/not supported. 0 for success.
  112. // art functions
  113. virtual void setArt(songid_t songid, void *buf, int w, int h); //buf is in format ARGB32*
  114. virtual pmpart_t getArt(songid_t songid);
  115. virtual void releaseArt(pmpart_t art);
  116. virtual int drawArt(pmpart_t art, HDC dc, int x, int y, int w, int h);
  117. virtual void getArtNaturalSize(pmpart_t art, int *w, int *h);
  118. virtual void setArtNaturalSize(pmpart_t art, int w, int h);
  119. virtual void getArtData(pmpart_t art, void* data); // data ARGB32* is at natural size
  120. virtual bool artIsEqual(pmpart_t a, pmpart_t b);
  121. };
  122. #endif // _IPODDEVICE_H_