12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256 |
- #ifndef __IPODDB_H__
- #define __IPODDB_H__
- #pragma once
- #pragma warning( disable : 4786)
- #include <algorithm>
- #include <windows.h>
- #include <bfc/platform/types.h>
- #include <map>
- #include <vector>
- #ifdef _DEBUG
- #undef ASSERT
- #define ASSERT(x) assert(x)
- #else
- #define ASSERT(x) {}
- #endif
- #define MHOD_TITLE 1
- #define MHOD_LOCATION 2
- #define MHOD_ALBUM 3
- #define MHOD_ARTIST 4
- #define MHOD_GENRE 5
- #define MHOD_FILETYPE 6
- #define MHOD_EQSETTING 7
- #define MHOD_COMMENT 8
- #define MHOD_CATEGORY 9
- #define MHOD_COMPOSER 12
- #define MHOD_GROUPING 13
- #define MHOD_DESCRIPTION 14
- #define MHOD_ENCLOSUREURL 15
- #define MHOD_RSSFEEDURL 16
- #define MHOD_CHAPTER 17
- #define MHOD_SUBTITLE 18
- #define MHOD_SHOW 19
- #define MHOD_EPISODE 20
- #define MHOD_TVNETWORK 21
- #define MHOD_ALBUMARTIST 22
- #define MHOD_ARTIST_SORT 23
- #define MHOD_TITLE_SORT 27
- #define MHOD_ALBUM_SORT 28
- #define MHOD_ALBUMARTIST_SORT 29
- #define MHOD_COMPOSER_SORT 30
- #define MHOD_SHOW_SORT 31
- #define MHOD_SPLPREF 50
- #define MHOD_SPLDATA 51
- #define MHOD_LIBRARY 52
- #define MHOD_LIBRARY_LETTER 53
- #define MHOD_PLAYLIST 100
- #define MHOD_ALBUMLIST_ALBUM 200
- #define MHOD_ALBUMLIST_ARTIST 201
- #define MHOD_ALBUMLIST_ARTIST_SORT 202
- #define MHOD_ALBUMLIST_PODCASTURL 203
- #define MHOD_ALBUMLIST_SHOW 204
- #define EQ_NONE -1
- #define EQ_ACOUSTIC 100
- #define EQ_BASSBOOSTER 101
- #define EQ_BASSREDUCER 102
- #define EQ_CLASSICAL 103
- #define EQ_DANCE 104
- #define EQ_DEEP 105
- #define EQ_ELECTRONIC 106
- #define EQ_FLAT 107
- #define EQ_HIPHOP 108
- #define EQ_JAZZ 109
- #define EQ_LATIN 110
- #define EQ_LOUDNESS 111
- #define EQ_LOUNGE 112
- #define EQ_PIANO 113
- #define EQ_POP 114
- #define EQ_RNB 115
- #define EQ_ROCK 116
- #define EQ_SMALLSPEAKERS 117
- #define EQ_SPOKENWORD 118
- #define EQ_TREBLEBOOSTER 119
- #define EQ_TREBLEREDUCER 120
- #define EQ_VOCALBOOSTER 121
- #define SPLMATCH_AND 0
- #define SPLMATCH_OR 1
- #define LIMITTYPE_MINUTES 0x01
- #define LIMITTYPE_MB 0x02
- #define LIMITTYPE_SONGS 0x03
- #define LIMITTYPE_HOURS 0x04
- #define LIMITTYPE_GB 0x05
- #define LIMITSORT_RANDOM 0x02
- #define LIMITSORT_SONG_NAME 0x03
- #define LIMITSORT_ALBUM 0x04
- #define LIMITSORT_ARTIST 0x05
- #define LIMITSORT_GENRE 0x07
- #define LIMITSORT_MOST_RECENTLY_ADDED 0x10
- #define LIMITSORT_COMPOSER 0x12
- #define LIMITSORT_LEAST_RECENTLY_ADDED 0x80000010
- #define LIMITSORT_MOST_OFTEN_PLAYED 0x14
- #define LIMITSORT_LEAST_OFTEN_PLAYED 0x80000014
- #define LIMITSORT_MOST_RECENTLY_PLAYED 0x15
- #define LIMITSORT_LEAST_RECENTLY_PLAYED 0x80000015
- #define LIMITSORT_HIGHEST_RATING 0x17
- #define LIMITSORT_LOWEST_RATING 0x80000017
- #define SPLACTION_IS_INT 0x00000001
- #define SPLACTION_IS_GREATER_THAN 0x00000010
- #define SPLACTION_IS_LESS_THAN 0x00000040
- #define SPLACTION_IS_IN_THE_RANGE 0x00000100
- #define SPLACTION_IS_IN_THE_LAST 0x00000200
- #define SPLACTION_BINARY_AND 0x00000400
- #define SPLACTION_IS_STRING 0x01000001
- #define SPLACTION_CONTAINS 0x01000002
- #define SPLACTION_STARTS_WITH 0x01000004
- #define SPLACTION_ENDS_WITH 0x01000008
- #define SPLACTION_IS_NOT_INT 0x02000001
- #define SPLACTION_IS_NOT_GREATER_THAN 0x02000010
- #define SPLACTION_IS_NOT_LESS_THAN 0x02000040
- #define SPLACTION_IS_NOT_IN_THE_RANGE 0x02000100
- #define SPLACTION_IS_NOT_IN_THE_LAST 0x02000200
- #define SPLACTION_UNKNOWN2 0x02000800
- #define SPLACTION_IS_NOT 0x03000001
- #define SPLACTION_DOES_NOT_CONTAIN 0x03000002
- #define SPLACTION_DOES_NOT_START_WITH 0x03000004
- #define SPLACTION_DOES_NOT_END_WITH 0x03000008
- #define SPLACTION_LAST_DAYS_VALUE 86400
- #define SPLACTION_LAST_WEEKS_VALUE 604800
- #define SPLACTION_LAST_MONTHS_VALUE 2628000
- #define SPLACTION_LAST_SECONDS_RULE 1
- #define SPLACTION_LAST_HOURS_VALUE 3600
- #define SPLACTION_LAST_MINUTES_VALUE 60
- #define SPLACTION_LAST_YEARS_VALUE 31536000
- #define SPLACTION_LAST_LUNARCYCLE_VALUE 2551443
- #define SPLACTION_LAST_SIDEREAL_DAY 86164
- #define SPLACTION_LAST_SWATCH_BEAT 86
- #define SPLACTION_LAST_MOMENT 90
- #define SPLACTION_LAST_OSTENT 600
- #define SPLACTION_LAST_FORTNIGHT 1209600
- #define SPLACTION_LAST_VINAL 1728000
- #define SPLACTION_LAST_QUARTER 7889231
- #define SPLACTION_LAST_SOLAR_YEAR 31556926
- #define SPLACTION_LAST_SIDEREAL_YEAR 31558150
- #define SPLFIELD_SONG_NAME 0x02
- #define SPLFIELD_ALBUM 0x03
- #define SPLFIELD_ARTIST 0x04
- #define SPLFIELD_BITRATE 0x05
- #define SPLFIELD_SAMPLE_RATE 0x06
- #define SPLFIELD_YEAR 0x07
- #define SPLFIELD_GENRE 0x08
- #define SPLFIELD_KIND 0x09
- #define SPLFIELD_DATE_MODIFIED 0x0a
- #define SPLFIELD_TRACKNUMBER 0x0b
- #define SPLFIELD_SIZE 0x0c
- #define SPLFIELD_TIME 0x0d
- #define SPLFIELD_COMMENT 0x0e
- #define SPLFIELD_DATE_ADDED 0x10
- #define SPLFIELD_COMPOSER 0x12
- #define SPLFIELD_PLAYCOUNT 0x16
- #define SPLFIELD_LAST_PLAYED 0x17
- #define SPLFIELD_DISC_NUMBER 0x18
- #define SPLFIELD_RATING 0x19
- #define SPLFIELD_COMPILATION 0x1f
- #define SPLFIELD_BPM 0x23
- #define SPLFIELD_GROUPING 0x27
- #define SPLFIELD_PLAYLIST 0x28
- #define SPLFIELD_VIDEO_KIND 0x3C
- #define SPLFIELD_TVSHOW 0x3E
- #define SPLFIELD_SEASON_NR 0x3F
- #define SPLFIELD_SKIPCOUNT 0x44
- #define SPLFIELD_ALBUMARTIST 0x47
- #define SPLDATE_IDENTIFIER 0x2dae2dae2dae2dae
- #define TYPE52_SONG_NAME 0x03
- #define TYPE52_ARTIST 0x05
- #define TYPE52_ALBUM 0x04
- #define TYPE52_GENRE 0x07
- #define TYPE52_COMPOSER 0x12
- static const uint32_t FILETYPE_M4A=0x4d344120;
- static const uint32_t FILETYPE_MP3=0x4d503320;
- static const uint32_t FILETYPE_WAV=0x57415620;
- time_t mactime_to_wintime (const unsigned long mactime);
- unsigned long wintime_to_mactime (const __time64_t time);
- char * UTF16_to_char(wchar_t * str, int length);
- class iPod_mhbd;
- class iPod_mhsd;
- class iPod_mhlt;
- class iPod_mhit;
- class iPod_mhlp;
- class iPod_mhyp;
- class iPod_slst;
- class iPod_mhip;
- class iPod_mhod;
- class iPod_mqed;
- class iPod_mhpo;
- class iPod_pqed;
- class iPod_mhla;
- #define SPL_MAXSTRINGLENGTH 255
- struct SPLRule
- {
- SPLRule() :
- field(0),
- action(0),
- length(0),
- fromvalue(0),
- fromdate(0),
- fromunits(0),
- tovalue(0),
- todate(0),
- tounits(0),
- unk1(0),
- unk2(0),
- unk3(0),
- unk4(0),
- unk5(0)
- {
- memset(string, 0, sizeof(string));
- }
- void SetString(const wchar_t *value)
- {
- if(value)
- {
- lstrcpynW(string, value, SPL_MAXSTRINGLENGTH);
- length = lstrlenW(string) * 2;
- }
- else
- {
- memset(string, 0, sizeof(string));
- length = 0;
- }
- }
- unsigned long field;
- unsigned long action;
- unsigned long length;
- wchar_t string[SPL_MAXSTRINGLENGTH + 1];
-
-
-
-
-
-
-
-
-
- uint64_t fromvalue;
- int64_t fromdate;
- uint64_t fromunits;
- uint64_t tovalue;
- int64_t todate;
- uint64_t tounits;
- unsigned long unk1;
- unsigned long unk2;
- unsigned long unk3;
- unsigned long unk4;
- unsigned long unk5;
- };
- struct PCEntry
- {
- unsigned long playcount;
- unsigned long lastplayedtime;
- unsigned long bookmarktime;
- unsigned long stars;
- uint32_t unk1;
- uint32_t skipcount;
- uint32_t skippedtime;
- };
- class iPodObj
- {
- public:
- iPodObj();
- virtual ~iPodObj();
-
-
- virtual long parse(const uint8_t *data) = 0;
-
-
-
-
- virtual long write(uint8_t * data, const unsigned long datasize) = 0;
- unsigned long size_head;
- unsigned long size_total;
- };
- class iPod_mhbd : public iPodObj
- {
- public:
- iPod_mhbd();
- virtual ~iPod_mhbd();
- virtual long parse(const uint8_t *data);
- virtual long write(uint8_t * data, const unsigned long datasize);
- virtual long write(uint8_t * data, const unsigned long datasize, uint8_t * fwid);
- uint32_t unk1;
- uint32_t dbversion;
- uint32_t children;
- uint64_t id;
- uint16_t platform;
- uint16_t language;
- uint64_t library_id;
- uint32_t unk80;
- uint32_t unk84;
- int32_t timezone;
- uint16_t audio_language;
- uint16_t subtitle_language;
- uint16_t unk164;
- uint16_t unk166;
- uint16_t unk168;
- iPod_mhsd *mhsdsongs;
- iPod_mhsd *mhsdplaylists;
- iPod_mhsd *mhsdsmartplaylists;
- };
- class iPod_mhsd : public iPodObj
- {
- public:
- iPod_mhsd();
- iPod_mhsd(int newindex);
- virtual ~iPod_mhsd();
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize) {return write(data,datasize,1);}
- virtual long write(unsigned char * data, const unsigned long datasize, int index);
- uint32_t index;
- iPod_mhlt * mhlt;
- iPod_mhlp * mhlp;
- iPod_mhlp * mhlp_smart;
- iPod_mhla * mhla;
- };
- class iPod_mhia : public iPodObj
- {
- public:
- iPod_mhia();
- virtual ~iPod_mhia();
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize);
- uint16_t unk1;
- uint16_t albumid;
- uint64_t dbid;
- uint32_t type;
- std::vector<iPod_mhod*> mhod;
- };
- class ArtistAlbumPair
- {
- public:
- const wchar_t* artist;
- const wchar_t* album;
- ArtistAlbumPair() : artist(0), album(0) {}
- ArtistAlbumPair(const wchar_t* artist, const wchar_t* album) : artist(artist), album(album) {}
-
- };
- struct ArtistAlbumPairComparer
- {
- int operator ()(const ArtistAlbumPair &a, const ArtistAlbumPair &b) const
- {
- int yy = _wcsicmp(a.artist, b.artist);
- if(yy) return yy;
- return _wcsicmp(a.album, b.album);
- }
- };
- class iPod_mhla : public iPodObj
- {
- public:
- iPod_mhla();
- virtual ~iPod_mhla();
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize);
- uint16_t GetAlbumId(const wchar_t* artist, const wchar_t* album);
- void ClearAlbumsList();
-
- typedef std::map<ArtistAlbumPair, uint16_t, ArtistAlbumPairComparer> albums_map_t;
- albums_map_t albums;
- uint16_t nextAlbumId;
- };
- class iPod_mhlt : public iPodObj
- {
- public:
- typedef std::map<uint32_t, iPod_mhit*> mhit_map_t;
-
- typedef mhit_map_t::value_type mhit_value_t;
- iPod_mhlt();
- virtual ~iPod_mhlt();
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize);
- const unsigned long GetChildrenCount() const { return mhit.size(); }
-
- iPod_mhit *NewTrack();
- void AddTrack(iPod_mhit *new_track);
-
- iPod_mhit *GetTrack(uint32_t index) const;
-
- iPod_mhit * GetTrackByID(const unsigned long id);
-
- bool DeleteTrack(const unsigned long index);
- bool DeleteTrackByID(const unsigned long id);
-
- bool ClearTracks(const bool clearMap = true);
-
- mhit_map_t mhit;
- std::vector<uint32_t> mhit_indexer;
- uint32_t GetNextID();
- private:
- volatile uint32_t next_mhit_id;
- };
- class iPod_mhit : public iPodObj
- {
- public:
- iPod_mhit();
- virtual ~iPod_mhit();
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize);
- const unsigned long GetChildrenCount() const { return(mhod.size()); }
-
-
-
- iPod_mhod * AddString(const int type=0);
-
- iPod_mhod * FindString(const unsigned long type) const;
-
-
-
-
- unsigned long DeleteString(const unsigned long type);
-
-
- static void Duplicate(const iPod_mhit *src, iPod_mhit *dst);
- iPod_mhit& operator=(const iPod_mhit& src);
- int GetRating() { return stars/20; }
- void SetRating(int rating) { stars=rating*20; }
- int GetEQSetting();
- void SetEQSetting(int value);
- unsigned int GetFileTypeID(const wchar_t *filename);
- uint32_t id;
- uint32_t visible;
- uint32_t filetype;
- uint8_t vbr;
- uint8_t type;
- uint8_t compilation;
- uint8_t stars;
- uint32_t lastmodifiedtime;
- uint32_t size;
- uint32_t length;
- uint32_t tracknum;
- uint32_t totaltracks;
- uint32_t year;
- uint32_t bitrate;
- uint16_t samplerate;
- uint16_t samplerate_fixedpoint;
- uint32_t volume;
- uint32_t starttime;
- uint32_t stoptime;
- uint32_t soundcheck;
- uint32_t playcount;
- uint32_t playcount2;
- uint32_t lastplayedtime;
- uint32_t cdnum;
- uint32_t totalcds;
- uint32_t userID;
- uint32_t addedtime;
- uint32_t bookmarktime;
- uint64_t dbid;
- uint32_t BPM;
- uint32_t app_rating;
- uint8_t checked;
- uint16_t unk9;
- uint16_t artworkcount;
- uint32_t artworksize;
- uint32_t unk11;
- float samplerate2;
- uint32_t releasedtime;
- uint32_t unk14;
- uint32_t unk15;
- uint32_t unk16;
-
- uint32_t skipcount;
- uint32_t skippedtime;
- uint8_t hasArtwork;
- uint8_t skipShuffle;
- uint8_t rememberPosition;
- uint8_t unk19;
- uint64_t dbid2;
- uint8_t lyrics_flag;
- uint8_t movie_flag;
- uint8_t mark_unplayed;
- uint8_t unk20;
- uint32_t unk21;
- uint32_t pregap;
- uint64_t samplecount;
- uint32_t unk25;
- uint32_t postgap;
- uint32_t unk27;
- uint32_t mediatype;
- uint32_t seasonNumber;
- uint32_t episodeNumber;
- uint32_t unk31;
- uint32_t unk32;
- uint32_t unk33;
- uint32_t unk34;
- uint32_t unk35;
- uint32_t unk36;
-
- uint32_t unk37;
- uint32_t gaplessData;
- uint32_t unk39;
- uint16_t albumgapless;
- uint16_t trackgapless;
- uint32_t unk40;
- uint32_t unk41;
- uint32_t unk42;
- uint32_t unk43;
- uint32_t unk44;
- uint32_t unk45;
- uint32_t unk46;
- uint32_t album_id;
- uint32_t unk48;
- uint32_t unk49;
- uint32_t unk50;
- uint32_t unk51;
- uint32_t unk52;
- uint32_t unk53;
- uint32_t unk54;
- uint32_t unk55;
- uint32_t unk56;
-
-
-
- uint32_t mhii_link;
-
-
- protected:
- std::vector<iPod_mhod*> mhod;
- iPod_mhod * mhodcache[25];
- };
- class iPod_mhlp : public iPodObj
- {
- public:
- iPod_mhlp();
- virtual ~iPod_mhlp();
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize) {return write(data,datasize,3);}
- virtual long write(unsigned char * data, const unsigned long datasize, int index);
- const unsigned long GetChildrenCount() const { return mhyp.size(); }
-
- iPod_mhyp * AddPlaylist();
-
- iPod_mhyp * GetPlaylist(const unsigned long pos) const { return mhyp.at(pos); }
-
- iPod_mhyp * FindPlaylist(const uint64_t playlistID);
-
- bool DeletePlaylist(const unsigned long pos);
-
- bool DeletePlaylistByID(const uint64_t playlistID);
-
-
-
- iPod_mhyp * GetDefaultPlaylist();
-
-
- bool ClearPlaylists(const bool createDefaultPlaylist = false);
-
- void RemoveDeadPlaylistEntries(iPod_mhlt *mhlt);
- std::vector<iPod_mhyp*> mhyp;
-
- void SortPlaylists();
- private:
- bool beingDeleted;
- };
- int STRCMP_NULLOK(const wchar_t *pa, const wchar_t *pb);
- class iPod_mhyp : public iPodObj
- {
- public:
- iPod_mhyp();
- virtual ~iPod_mhyp();
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize) {return write(data,datasize,3);}
- virtual long write(unsigned char * data, const unsigned long datasize, int index);
- bool IsSmartPlaylist(void) const { return(isSmartPlaylist); }
-
-
- long AddPlaylistEntry(iPod_mhip * entry, const unsigned long id=0);
-
-
-
- long FindPlaylistEntry(const unsigned long id) const;
-
- iPod_mhip * GetPlaylistEntry(const unsigned long pos) const { return mhip.at(pos); }
-
- bool DeletePlaylistEntry(const unsigned long pos);
-
- bool DeletePlaylistEntryByID(unsigned long songindex);
-
- bool ClearPlaylist();
-
-
-
-
- long PopulatePlaylist(iPod_mhlt * tracks, int hidden_field=1);
-
-
-
- iPod_mhod * AddString(const int type=0);
-
-
- iPod_mhod * FindString(const unsigned long type);
-
-
-
-
- unsigned long DeleteString(const unsigned long type);
- void SetPlaylistTitle(const wchar_t *string);
- const unsigned long GetMhodChildrenCount() const { return mhod.size(); }
- const unsigned long GetMhipChildrenCount() const { return mhip.size(); }
- static void Duplicate(iPod_mhyp *src, iPod_mhyp *dst);
- unsigned long hidden;
- unsigned long timestamp;
- uint64_t playlistID;
- unsigned long unk3;
- unsigned short numStringMHODs;
- unsigned short podcastflag;
- unsigned long numLibraryMHODs;
- std::vector<iPod_mhod*> mhod;
- std::vector<iPod_mhip*> mhip;
- struct indexMhit
- {
- __forceinline bool operator()(indexMhit*& one, indexMhit*& two)
- {
- #define RETIFNZ(x) { int yy = x; if(yy != 0) return yy < 0; }
-
- RETIFNZ(STRCMP_NULLOK(one->str[0],two->str[0]));
- RETIFNZ(STRCMP_NULLOK(one->str[1],two->str[1]));
- RETIFNZ(STRCMP_NULLOK(one->str[2],two->str[2]));
- RETIFNZ(one->track - two->track);
- RETIFNZ(STRCMP_NULLOK(one->str[3],two->str[3]));
- return true;
- #undef RETIFNZ
- }
- unsigned int index;
- const wchar_t *str[4];
- int track;
- };
- iPod_mhlt::mhit_map_t *mhit;
- std::vector<uint32_t> mhit_indexer;
- bool writeLibraryMHODs;
- bool operator()(iPod_mhyp*& one, iPod_mhyp*& two);
- protected:
- bool isSmartPlaylist;
- bool isPopulated;
- };
- class iPod_mhip : public iPodObj
- {
- public:
- iPod_mhip();
- virtual ~iPod_mhip();
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize) { return write(data,datasize,0); }
- virtual long write(unsigned char * data, const unsigned long datasize, int entrynum);
- static void Duplicate(iPod_mhip *src, iPod_mhip *dst);
- unsigned long dataobjectcount;
- unsigned long podcastgroupflag;
- unsigned long groupid;
- unsigned long songindex;
- unsigned long timestamp;
- unsigned long podcastgroupref;
- std::vector<iPod_mhod*> mhod;
- };
- class iPod_mhod : public iPodObj
- {
- public:
- iPod_mhod();
- virtual ~iPod_mhod();
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize);
- void SetString(const wchar_t *string);
- static void Duplicate(iPod_mhod *src, iPod_mhod *dst);
-
- static bool IsSimpleStringType(const unsigned int type);
- uint32_t type;
- uint32_t unk1;
- uint32_t unk2;
-
-
-
- union
- {
- uint32_t position;
- uint32_t encoding_type;
- };
- uint32_t length;
- uint32_t unk3;
- uint32_t unk4;
-
-
- wchar_t *str;
-
-
-
- uint8_t * binary;
-
- uint8_t liveupdate;
- uint8_t checkrules;
- uint8_t checklimits;
- uint8_t matchcheckedonly;
- uint8_t limitsort_opposite;
- uint32_t limittype;
- uint32_t limitsort;
- uint32_t limitvalue;
-
- uint32_t unk5;
- uint32_t rules_operator;
- std::vector<SPLRule*> rule;
- bool parseSmartPlaylists;
- };
- class iPod_slst : public iPod_mhyp
- {
- public:
- enum FieldType
- {
- ftString,
- ftInt,
- ftBoolean,
- ftDate,
- ftPlaylist,
- ftUnknown,
- ftBinaryAnd,
- };
- enum ActionType
- {
- atString,
- atInt,
- atBoolean,
- atDate,
- atRange,
- atInTheLast,
- atPlaylist,
- atNone,
- atInvalid,
- atUnknown,
- atBinaryAnd,
- };
- iPod_slst();
- virtual ~iPod_slst();
- iPod_mhod* GetPrefs(void) { UpdateMHODPointers(); return(splPref); }
- void SetPrefs(const bool liveupdate = true, const bool rules_enabled = true, const bool limits_enabled = false,
- const unsigned long limitvalue = 0, const unsigned long limittype = 0, const unsigned long limitsort = 0);
- static FieldType GetFieldType(const unsigned long field);
- static ActionType GetActionType(const unsigned long field, const unsigned long action);
- static uint64_t ConvertDateValueToNum(const uint64_t val) { return(-(int64_t)val); }
- static uint64_t ConvertNumToDateValue(const uint64_t val) { return(-(int64_t)val); }
-
- iPod_mhod* GetRules() { UpdateMHODPointers(); return(splData); }
-
- unsigned long GetRuleCount();
-
- int AddRule(const unsigned long field,
- const unsigned long action,
- const wchar_t * string = NULL,
- const uint64_t value = 0,
- const uint64_t from = 0,
- const uint64_t to = 0,
- const uint64_t units = 0);
- int AddRule(const SPLRule& rule);
-
- void RemoveAllRules(void);
-
-
-
-
- long PopulateSmartPlaylist(iPod_mhlt * tracks, iPod_mhlp * playlists);
-
- static bool EvalRule(
- SPLRule * r,
- iPod_mhit * track,
- iPod_mhlt * tracks = NULL,
- iPod_mhlp * playlists = NULL
- );
-
- void Reset(void);
- protected:
- void UpdateMHODPointers(void);
- iPod_mhod *splPref;
- iPod_mhod *splData;
- };
- class iPod_mhdp
- {
- public:
- iPod_mhdp();
- ~iPod_mhdp();
- unsigned long size_head;
- unsigned long entrysize;
- const unsigned long GetChildrenCount() const { return children; }
-
-
-
- virtual long parse(const uint8_t *data);
-
-
- const PCEntry &GetPlayCount(const unsigned int pos) const { return entry[pos]; }
-
-
-
-
- PCEntry *entry;
- uint32_t children;
- };
- class iPod_mhpo
- {
- public:
- iPod_mhpo();
- virtual ~iPod_mhpo();
- unsigned long size_head;
- unsigned long unk1;
- unsigned long unk2;
- const unsigned long GetChildrenCount() const { return children; }
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize);
-
-
-
-
-
- iPod_mhyp * CreatePlaylistFromOTG(iPod_mhbd * iPodDB, wchar_t * name);
-
-
-
-
- uint32_t *idList;
- uint32_t children;
- };
- class iPod_mqed
- {
- public:
- iPod_mqed();
- virtual ~iPod_mqed();
- unsigned long size_head;
- unsigned long unk1;
- unsigned long unk2;
- const unsigned long GetChildrenCount() const { return eqList.size(); }
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize);
- std::vector<iPod_pqed*> eqList;
- };
- class iPod_pqed
- {
- public:
- iPod_pqed();
- virtual ~iPod_pqed();
- unsigned long length;
- wchar_t * name;
- signed long preamp;
- signed long eq[10];
- signed long short_eq[5];
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize);
- };
- struct iTunesStatsEntry
- {
- unsigned int GetBookmarkTimeInMilliseconds() { if(bookmarktime == 0xffffff) return(0); return(bookmarktime * 256); }
-
- unsigned int entry_size;
- unsigned int bookmarktime;
- unsigned int unk1;
- unsigned int unk2;
- unsigned int playcount;
- unsigned int skippedcount;
- };
- class iTunesStats
- {
- public:
- iTunesStats();
- ~iTunesStats();
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char * data, const unsigned long datasize);
- const unsigned long GetChildrenCount() const { return children; }
- const iTunesStatsEntry &GetEntry(const unsigned int pos) const { return entry[pos];}
-
- unsigned int unk1;
- iTunesStatsEntry *entry;
- uint32_t children;
- iPod_mhlt *mhlt;
- };
- class iTunesShuffle
- {
- public:
- iTunesShuffle();
- ~iTunesShuffle();
- virtual long parse(const uint8_t *data);
- virtual long write(unsigned char *data, const unsigned long datasize);
- unsigned int GetChildrenCount() const { return numentries; }
- unsigned int GetEntry(const unsigned int pos) const { return entry[pos]; }
-
- void Randomize();
- void Randomize(const unsigned int numsongs);
- uint32_t *entry;
- uint32_t numentries;
- unsigned int datasize;
- };
- #endif
|