1
0

iPodInfo.cpp 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040
  1. #include "api.h"
  2. #include "iPodInfo.h"
  3. #include "resource.h"
  4. #include "../../General/gen_ml/ml.h"
  5. #include "../../Library/ml_pmp/pmp.h"
  6. #include "../xml/obj_xml.h"
  7. #include "../plist/loader.h"
  8. #include <api/service/waservicefactory.h>
  9. #include <stdio.h>
  10. #include <windows.h>
  11. #include <strsafe.h>
  12. extern PMPDevicePlugin plugin;
  13. static const ArtworkFormat ipod_color_artwork_info[] =
  14. {
  15. {THUMB_COVER_SMALL, 56, 56, 1017, RGB_565, 4, 4},
  16. {THUMB_COVER_LARGE, 140, 140, 1016, RGB_565, 4, 4},
  17. {THUMB_PHOTO_TV_SCREEN, 720, 480, 1019, RGB_565, 4, 4},
  18. {THUMB_PHOTO_LARGE, 130, 88, 1015, RGB_565, 4, 4},
  19. {THUMB_PHOTO_FULL_SCREEN, 220, 176, 1013, RGB_565, 4, 4},
  20. {THUMB_PHOTO_SMALL, 42, 30, 1009, RGB_565, 4, 4},
  21. {THUMB_INVALID, -1, -1, -1, RGB_565, 4, 4}
  22. };
  23. static const ArtworkFormat ipod_nano_artwork_info[] =
  24. {
  25. {THUMB_COVER_SMALL, 42, 42, 1031, RGB_565, 4, 4},
  26. {THUMB_COVER_LARGE, 100, 100, 1027, RGB_565, 4, 4},
  27. {THUMB_PHOTO_LARGE, 42, 37, 1032, RGB_565, 4, 4},
  28. {THUMB_PHOTO_FULL_SCREEN, 176, 132, 1023, RGB_565, 4, 4},
  29. {THUMB_INVALID, -1, -1, -1, RGB_565, 4, 4}
  30. };
  31. static const ArtworkFormat ipod_video_artwork_info[] =
  32. {
  33. {THUMB_COVER_SMALL, 100, 100, 1028, RGB_565, 4, 4},
  34. {THUMB_COVER_LARGE, 200, 200, 1029, RGB_565, 4, 4},
  35. {THUMB_PHOTO_TV_SCREEN, 720, 480, 1019, RGB_565, 4, 4},
  36. {THUMB_PHOTO_LARGE, 130, 88, 1015, RGB_565, 4, 4},
  37. {THUMB_PHOTO_FULL_SCREEN, 320, 240, 1024, RGB_565, 4, 4},
  38. {THUMB_PHOTO_SMALL, 50, 41, 1036, RGB_565, 4, 4},
  39. {THUMB_INVALID, -1, -1, -1, RGB_565, 4, 4}
  40. };
  41. static const ArtworkFormat ipod_7g_artwork_info[] =
  42. {
  43. {THUMB_COVER_SMALL, 55, 55, 1061, RGB_565, 4, 4},
  44. {THUMB_COVER_MEDIUM1, 128, 128, 1055, RGB_565, 4, 4},
  45. {THUMB_COVER_LARGE, 320, 320, 1060, RGB_565, 4, 4},
  46. {THUMB_INVALID, -1, -1, -1, RGB_565, 4, 4}
  47. };
  48. static const ArtworkFormat ipod_touch_artwork_info[] =
  49. {
  50. {THUMB_COVER_SMALL, 55, 55, 3006, RGB_555, 16, 4096},
  51. {THUMB_COVER_MEDIUM1, 64, 64, 3003, RGB_555_REC, 16, 4096},
  52. {THUMB_COVER_MEDIUM2, 88, 88, 3007, RGB_555, 16, 4096},
  53. {THUMB_COVER_MEDIUM3, 128, 128, 3002, RGB_555_REC, 16, 4096},
  54. {THUMB_COVER_MEDIUM4, 256, 256, 3001, RGB_555_REC, 16, 4096},
  55. {THUMB_COVER_LARGE, 320, 320, 3005, RGB_555, 16, 4096},
  56. {THUMB_INVALID, -1, -1, -1, RGB_555, 4, 4}
  57. };
  58. /*
  59. static const ArtworkFormat ipod_mobile_1_artwork_info[] = {
  60. {THUMB_COVER_SMALL, 50, 50, 2002},
  61. {THUMB_COVER_LARGE, 150, 150, 2003},
  62. {THUMB_INVALID, -1, -1, -1}
  63. };
  64. */
  65. //maps model to artwork format
  66. static const ArtworkFormat *ipod_artwork_info_table[] =
  67. {
  68. NULL, // invalid
  69. ipod_color_artwork_info, // color
  70. NULL, // regular
  71. NULL, // mini
  72. NULL, // shuffle
  73. ipod_video_artwork_info, // video
  74. ipod_nano_artwork_info, // nano
  75. ipod_7g_artwork_info, // classic
  76. ipod_7g_artwork_info, // fat nano
  77. ipod_touch_artwork_info, // touch
  78. };
  79. // this list compiled from http://www.thismuchiknow.co.uk/?page_id=27 and is kept in the same order as that table for easy updating
  80. // when new ipods come out, let's keep this up to date.
  81. // at the moment this is just used as a mapping from part number to model, for album art
  82. static const iPodModelInfo ipod_info_table[] =
  83. {
  84. //1st gen ipods
  85. {L"8513", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160}, //mac
  86. {L"8541", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160}, //mac
  87. {L"8697", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160}, //pc
  88. {L"8709", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160}, //mac
  89. //2nd gen ipods
  90. {L"8737", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160}, //mac
  91. {L"8740", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160}, //pc
  92. {L"8738", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160}, //mac
  93. {L"8741", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160}, //pc
  94. //3rd gen ipods
  95. {L"8976", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  96. {L"8946", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  97. {L"8948", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  98. {L"9244", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  99. {L"9245", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  100. {L"9460", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  101. //1st gen mini
  102. {L"9160", IPOD_MODEL_MINI, IPOD_COLOR_SILVER, IDB_CLASSIC_16, IDB_CLASSIC_160},
  103. {L"9436", IPOD_MODEL_MINI, IPOD_COLOR_BLUE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  104. {L"9435", IPOD_MODEL_MINI, IPOD_COLOR_PINK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  105. {L"9434", IPOD_MODEL_MINI, IPOD_COLOR_GREEN, IDB_CLASSIC_16, IDB_CLASSIC_160},
  106. {L"9437", IPOD_MODEL_MINI, IPOD_COLOR_GOLD, IDB_CLASSIC_16, IDB_CLASSIC_160},
  107. //4th gen ipods
  108. {L"9282", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  109. {L"9268", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  110. {L"E435", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160}, //HP branded
  111. {L"E436", IPOD_MODEL_REGULAR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160}, //HP branded
  112. {L"9787", IPOD_MODEL_REGULAR, IPOD_COLOR_U2, IDB_CLASSIC_16, IDB_CLASSIC_160},
  113. //4th gen ipod photos
  114. {L"9585", IPOD_MODEL_COLOR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  115. {L"9586", IPOD_MODEL_COLOR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  116. //shuffles
  117. {L"A133", IPOD_MODEL_SHUFFLE, IPOD_COLOR_WHITE, IDB_SHUFFLE1G_16, IDB_SHUFFLE1G_160},
  118. {L"9724", IPOD_MODEL_SHUFFLE, IPOD_COLOR_WHITE, IDB_SHUFFLE1G_16, IDB_SHUFFLE1G_160},
  119. {L"9725", IPOD_MODEL_SHUFFLE, IPOD_COLOR_WHITE, IDB_SHUFFLE1G_16, IDB_SHUFFLE1G_160},
  120. // more ipod photos
  121. {L"9829", IPOD_MODEL_COLOR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  122. {L"9830", IPOD_MODEL_COLOR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  123. // ipod mini 2nd gen
  124. {L"9959", IPOD_MODEL_MINI, IPOD_COLOR_SILVER, IDB_CLASSIC_16, IDB_CLASSIC_160}, // pepsi giveaway ipod
  125. {L"9800", IPOD_MODEL_MINI, IPOD_COLOR_SILVER, IDB_CLASSIC_16, IDB_CLASSIC_160},
  126. {L"9802", IPOD_MODEL_MINI, IPOD_COLOR_BLUE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  127. {L"9804", IPOD_MODEL_MINI, IPOD_COLOR_PINK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  128. {L"9806", IPOD_MODEL_MINI, IPOD_COLOR_GREEN, IDB_CLASSIC_16, IDB_CLASSIC_160},
  129. {L"9801", IPOD_MODEL_MINI, IPOD_COLOR_SILVER, IDB_CLASSIC_16, IDB_CLASSIC_160},
  130. {L"9803", IPOD_MODEL_MINI, IPOD_COLOR_BLUE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  131. {L"9805", IPOD_MODEL_MINI, IPOD_COLOR_PINK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  132. {L"9807", IPOD_MODEL_MINI, IPOD_COLOR_GREEN, IDB_CLASSIC_16, IDB_CLASSIC_160},
  133. //HP colour ipods
  134. {L"S492", IPOD_MODEL_COLOR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  135. {L"S493", IPOD_MODEL_COLOR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  136. //HP ipod mini 2nd gen
  137. {L"W753", IPOD_MODEL_MINI, IPOD_COLOR_SILVER, IDB_CLASSIC_16, IDB_CLASSIC_160},
  138. {L"X762", IPOD_MODEL_MINI, IPOD_COLOR_SILVER, IDB_CLASSIC_16, IDB_CLASSIC_160},
  139. //more 4th gen ipod photos
  140. {L"A079", IPOD_MODEL_COLOR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  141. {L"A127", IPOD_MODEL_COLOR, IPOD_COLOR_U2, IDB_CLASSIC_16, IDB_CLASSIC_160},
  142. //HP ipod shuffles
  143. {L"X765", IPOD_MODEL_SHUFFLE, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  144. {L"X766", IPOD_MODEL_SHUFFLE, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  145. /*
  146. //harry potter ipod 4G, don't know serial number. but that's ok because it was only on sale for a month, so fuck it.
  147. {L"????", IPOD_MODEL_COLOR, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  148. */
  149. //ipod nano 1st gen
  150. {L"A004", IPOD_MODEL_NANO, IPOD_COLOR_WHITE, IDB_NANO1G_16, IDB_NANO1G_160},
  151. {L"A099", IPOD_MODEL_NANO, IPOD_COLOR_BLACK, IDB_NANO1G_16, IDB_NANO1G_160},
  152. {L"A005", IPOD_MODEL_NANO, IPOD_COLOR_WHITE, IDB_NANO1G_16, IDB_NANO1G_160},
  153. {L"A107", IPOD_MODEL_NANO, IPOD_COLOR_BLACK, IDB_NANO1G_16, IDB_NANO1G_160},
  154. //ipod video
  155. {L"A002", IPOD_MODEL_VIDEO, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  156. {L"A146", IPOD_MODEL_VIDEO, IPOD_COLOR_BLACK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  157. {L"A003", IPOD_MODEL_VIDEO, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  158. {L"A147", IPOD_MODEL_VIDEO, IPOD_COLOR_BLACK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  159. {L"A253", IPOD_MODEL_VIDEO, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160}, //harry potter ipod 5G
  160. //1gig nano
  161. {L"A350", IPOD_MODEL_NANO, IPOD_COLOR_WHITE, IDB_NANO1G_16, IDB_NANO1G_160},
  162. {L"A352", IPOD_MODEL_NANO, IPOD_COLOR_BLACK, IDB_NANO1G_16, IDB_NANO1G_160},
  163. // U2 ipod video
  164. {L"A452", IPOD_MODEL_VIDEO, IPOD_COLOR_U2, IDB_CLASSIC_16, IDB_CLASSIC_160},
  165. //2nd gen nano
  166. {L"A477", IPOD_MODEL_NANO, IPOD_COLOR_SILVER, IDB_NANO2G_16, IDB_NANO2G_160},
  167. {L"A426", IPOD_MODEL_NANO, IPOD_COLOR_SILVER, IDB_NANO2G_16, IDB_NANO2G_160},
  168. {L"A428", IPOD_MODEL_NANO, IPOD_COLOR_BLUE, IDB_NANO2G_16, IDB_NANO2G_160},
  169. {L"A487", IPOD_MODEL_NANO, IPOD_COLOR_GREEN, IDB_NANO2G_16, IDB_NANO2G_160},
  170. {L"A489", IPOD_MODEL_NANO, IPOD_COLOR_PINK, IDB_NANO2G_16, IDB_NANO2G_160},
  171. {L"A497", IPOD_MODEL_NANO, IPOD_COLOR_BLACK, IDB_NANO2G_16, IDB_NANO2G_160},
  172. // ipod video 6th gen
  173. {L"A444", IPOD_MODEL_VIDEO, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  174. {L"A446", IPOD_MODEL_VIDEO, IPOD_COLOR_BLACK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  175. {L"A448", IPOD_MODEL_VIDEO, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  176. {L"A450", IPOD_MODEL_VIDEO, IPOD_COLOR_BLACK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  177. //2nd gen shuffle
  178. {L"A564", IPOD_MODEL_SHUFFLE, IPOD_COLOR_SILVER, IDB_SHUFFLE2G_16, IDB_SHUFFLE2G_160},
  179. // ipod video u2 6th gen
  180. {L"A664", IPOD_MODEL_VIDEO, IPOD_COLOR_U2, IDB_CLASSIC_16, IDB_CLASSIC_160},
  181. //product red ipod nano
  182. {L"A725", IPOD_MODEL_NANO, IPOD_COLOR_RED, IDB_CLASSIC_16, IDB_CLASSIC_160},
  183. {L"A899", IPOD_MODEL_NANO, IPOD_COLOR_RED, IDB_CLASSIC_16, IDB_CLASSIC_160},
  184. // coloured versions of ipod shuffle 2nd gen
  185. {L"A947", IPOD_MODEL_SHUFFLE, IPOD_COLOR_PINK, IDB_SHUFFLE2G_16, IDB_SHUFFLE2G_160},
  186. {L"A949", IPOD_MODEL_SHUFFLE, IPOD_COLOR_BLUE, IDB_SHUFFLE2G_16, IDB_SHUFFLE2G_160},
  187. {L"A951", IPOD_MODEL_SHUFFLE, IPOD_COLOR_GREEN, IDB_SHUFFLE2G_16, IDB_SHUFFLE2G_160},
  188. {L"A953", IPOD_MODEL_SHUFFLE, IPOD_COLOR_ORANGE, IDB_SHUFFLE2G_16, IDB_SHUFFLE2G_160},
  189. // fat nanos
  190. {L"A978", IPOD_MODEL_FATNANO, IPOD_COLOR_SILVER, IDB_CLASSIC_16, IDB_CLASSIC_160},
  191. {L"A980", IPOD_MODEL_FATNANO, IPOD_COLOR_SILVER, IDB_CLASSIC_16, IDB_CLASSIC_160},
  192. {L"B249", IPOD_MODEL_FATNANO, IPOD_COLOR_BLUE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  193. {L"B253", IPOD_MODEL_FATNANO, IPOD_COLOR_GREEN, IDB_CLASSIC_16, IDB_CLASSIC_160},
  194. {L"B261", IPOD_MODEL_FATNANO, IPOD_COLOR_BLACK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  195. {L"B257", IPOD_MODEL_FATNANO, IPOD_COLOR_RED, IDB_CLASSIC_16, IDB_CLASSIC_160},
  196. // ipod classic
  197. {L"B147", IPOD_MODEL_CLASSIC, IPOD_COLOR_BLACK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  198. {L"B029", IPOD_MODEL_CLASSIC, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  199. {L"B150", IPOD_MODEL_CLASSIC, IPOD_COLOR_BLACK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  200. {L"B145", IPOD_MODEL_CLASSIC, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  201. // ipod touch
  202. {L"A623", IPOD_MODEL_TOUCH, IPOD_COLOR_BLACK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  203. {L"A627", IPOD_MODEL_TOUCH, IPOD_COLOR_BLACK, IDB_CLASSIC_16, IDB_CLASSIC_160},
  204. //insert info about new models here (be sure to take first char off the product code)...
  205. };
  206. static const iPodModelInfo
  207. shuffle1g_info = {L"XXXX", IPOD_MODEL_SHUFFLE, IPOD_COLOR_PINK, IDB_SHUFFLE1G_16, IDB_SHUFFLE1G_160},
  208. shuffle2g_info = {L"XXXX", IPOD_MODEL_SHUFFLE, IPOD_COLOR_PINK, IDB_SHUFFLE2G_16, IDB_SHUFFLE2G_160},
  209. shuffle3g_info = {L"XXXX", IPOD_MODEL_SHUFFLE, IPOD_COLOR_SILVER, IDB_SHUFFLE3G_16, IDB_SHUFFLE3G_160},
  210. shuffle4g_info = {L"XXXX", IPOD_MODEL_SHUFFLE, IPOD_COLOR_SILVER, IDB_SHUFFLE4G_16, IDB_SHUFFLE4G_160},
  211. classic_info = {L"XXXX", IPOD_MODEL_CLASSIC, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  212. video_info = {L"XXXX", IPOD_MODEL_VIDEO, IPOD_COLOR_WHITE, IDB_CLASSIC_16, IDB_CLASSIC_160},
  213. nano1g_info = {L"XXXX", IPOD_MODEL_NANO, IPOD_COLOR_WHITE, IDB_NANO1G_16, IDB_NANO1G_160},
  214. nano2g_info = {L"XXXX", IPOD_MODEL_NANO, IPOD_COLOR_WHITE, IDB_NANO2G_16, IDB_NANO2G_160},
  215. nano3g_info = {L"XXXX", IPOD_MODEL_NANO, IPOD_COLOR_WHITE, IDB_NANO3G_16, IDB_NANO3G_160},
  216. nano4g_info = {L"XXXX", IPOD_MODEL_NANO, IPOD_COLOR_WHITE, IDB_NANO4G_16, IDB_NANO4G_160};
  217. static INT_PTR CALLBACK selectipodtype_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam)
  218. {
  219. switch (uMsg)
  220. {
  221. case WM_INITDIALOG:
  222. {
  223. BringWindowToTop(hwndDlg);
  224. wchar_t * sysinfo = (wchar_t*)lParam;
  225. SetWindowLongPtr(hwndDlg,GWLP_USERDATA,lParam);
  226. wchar_t path[] = {sysinfo[0],L":\\"};
  227. wchar_t name[32] = {0};
  228. GetVolumeInformation(path,name,32,NULL,NULL,NULL,NULL,0);
  229. wchar_t buf[100] = {0};
  230. wchar_t s[32] = {0};
  231. GetDlgItemText(hwndDlg,IDC_IPODINFO,s,32);
  232. StringCchPrintf(buf,100,L"%s (%s) %s",path,name,s);
  233. SetDlgItemText(hwndDlg,IDC_IPODINFO,buf);
  234. }
  235. break;
  236. case WM_COMMAND:
  237. switch (LOWORD(wParam))
  238. {
  239. case IDC_RADIO1:
  240. case IDC_RADIO2:
  241. case IDC_RADIO3:
  242. case IDC_RADIO4:
  243. case IDC_RADIO5:
  244. case IDC_RADIO6:
  245. case IDC_RADIO7:
  246. case IDC_RADIO8:
  247. EnableWindow(GetDlgItem(hwndDlg,IDOK),TRUE);
  248. break;
  249. case IDCANCEL:
  250. EndDialog(hwndDlg,1);
  251. break;
  252. case IDOK:
  253. {
  254. char *m;
  255. if (IsDlgButtonChecked(hwndDlg,IDC_RADIO1)) m = "A133"; //shuffle
  256. else if (IsDlgButtonChecked(hwndDlg,IDC_RADIO2)) m = "9586"; //photo
  257. else if (IsDlgButtonChecked(hwndDlg,IDC_RADIO3)) m = "A002"; //video
  258. else if (IsDlgButtonChecked(hwndDlg,IDC_RADIO4)) m = "A005"; //nano
  259. else if (IsDlgButtonChecked(hwndDlg,IDC_RADIO6)) m = "A623"; //touch
  260. else if (IsDlgButtonChecked(hwndDlg,IDC_RADIO7)) m = "B145"; //classic
  261. else if (IsDlgButtonChecked(hwndDlg,IDC_RADIO8)) m = "B257"; //fatnano
  262. else m = "8976"; //other
  263. wchar_t * sysinfo = (wchar_t*)GetWindowLongPtr(hwndDlg,GWLP_USERDATA);
  264. FILE *f = _wfopen(sysinfo,L"a+b");
  265. if (f)
  266. {
  267. fprintf(f,"ModelNumStr: M%s\n",m);
  268. fclose(f);
  269. }
  270. }
  271. EndDialog(hwndDlg,0);
  272. break;
  273. }
  274. break;
  275. }
  276. return 0;
  277. }
  278. /* This table was extracted from ipod-model-table from podsleuth svn trunk
  279. * on 2008-06-14 (which seems to match podsleuth 0.6.2)
  280. */
  281. static const iPodSerialToModel serial_to_model_mapping[] =
  282. {
  283. { L"LG6", L"8541" },
  284. { L"NAM", L"8541" },
  285. { L"MJ2", L"8541" },
  286. { L"ML1", L"8709" },
  287. { L"MME", L"8709" },
  288. { L"MMB", L"8737" },
  289. { L"MMC", L"8738" },
  290. { L"NGE", L"8740" },
  291. { L"NGH", L"8740" },
  292. { L"MMF", L"8741" },
  293. { L"NLW", L"8946" },
  294. { L"NRH", L"8976" },
  295. { L"QQF", L"9460" },
  296. { L"PQ5", L"9244" },
  297. { L"PNT", L"9244" },
  298. { L"NLY", L"8948" },
  299. { L"NM7", L"8948" },
  300. { L"PNU", L"9245" },
  301. { L"PS9", L"9282" },
  302. { L"Q8U", L"9282" },
  303. { L"V9V", L"9787" },
  304. { L"S2X", L"9787" },
  305. { L"PQ7", L"9268" },
  306. { L"TDU", L"A079" },
  307. { L"TDS", L"A079" },
  308. { L"TM2", L"A127" },
  309. { L"SAZ", L"9830" },
  310. { L"SB1", L"9830" },
  311. { L"SAY", L"9829" },
  312. { L"R5Q", L"9585" },
  313. { L"R5R", L"9586" },
  314. { L"R5T", L"9586" },
  315. { L"PFW", L"9160" },
  316. { L"PRC", L"9160" },
  317. { L"QKL", L"9436" },
  318. { L"QKQ", L"9436" },
  319. { L"QKK", L"9435" },
  320. { L"QKP", L"9435" },
  321. { L"QKJ", L"9434" },
  322. { L"QKN", L"9434" },
  323. { L"QKM", L"9437" },
  324. { L"QKR", L"9437" },
  325. { L"S41", L"9800" },
  326. { L"S4C", L"9800" },
  327. { L"S43", L"9802" },
  328. { L"S45", L"9804" },
  329. { L"S47", L"9806" },
  330. { L"S4J", L"9806" },
  331. { L"S42", L"9801" },
  332. { L"S44", L"9803" },
  333. { L"S48", L"9807" },
  334. { L"RS9", L"9724" },
  335. { L"QGV", L"9724" },
  336. { L"TSX", L"9724" },
  337. { L"PFV", L"9724" },
  338. { L"R80", L"9724" },
  339. { L"RSA", L"9725" },
  340. { L"TSY", L"9725" },
  341. { L"C60", L"9725" },
  342. { L"VTE", L"A546" },
  343. { L"VTF", L"A546" },
  344. { L"XQ5", L"A947" },
  345. { L"XQS", L"A947" },
  346. { L"XQV", L"A949" },
  347. { L"XQX", L"A949" },
  348. { L"YX7", L"A949" },
  349. { L"XQY", L"A951" },
  350. { L"YX8", L"A951" },
  351. { L"XR1", L"A953" },
  352. { L"YXA", L"B233" },
  353. { L"YX6", L"B225" },
  354. { L"YX7", L"B228" },
  355. { L"YX9", L"B225" },
  356. { L"UNA", L"A350" },
  357. { L"UNB", L"A350" },
  358. { L"UPR", L"A352" },
  359. { L"UPS", L"A352" },
  360. { L"SZB", L"A004" },
  361. { L"SZV", L"A004" },
  362. { L"SZW", L"A004" },
  363. { L"SZC", L"A005" },
  364. { L"SZT", L"A005" },
  365. { L"TJT", L"A099" },
  366. { L"TJU", L"A099" },
  367. { L"TK2", L"A107" },
  368. { L"TK3", L"A107" },
  369. { L"VQ5", L"A477" },
  370. { L"VQ6", L"A477" },
  371. { L"V8T", L"A426" },
  372. { L"V8U", L"A426" },
  373. { L"V8W", L"A428" },
  374. { L"V8X", L"A428" },
  375. { L"VQH", L"A487" },
  376. { L"VQJ", L"A487" },
  377. { L"VQK", L"A489" },
  378. { L"VKL", L"A489" },
  379. { L"WL2", L"A725" },
  380. { L"WL3", L"A725" },
  381. { L"X9A", L"A726" },
  382. { L"X9B", L"A726" },
  383. { L"VQT", L"A497" },
  384. { L"VQU", L"A497" },
  385. { L"Y0P", L"A978" },
  386. { L"Y0R", L"A980" },
  387. { L"YXR", L"B249" },
  388. { L"YXV", L"B257" },
  389. { L"YXT", L"B253" },
  390. { L"YXX", L"B261" },
  391. { L"SZ9", L"A002" },
  392. { L"WEC", L"A002" },
  393. { L"WED", L"A002" },
  394. { L"WEG", L"A002" },
  395. { L"WEH", L"A002" },
  396. { L"WEL", L"A002" },
  397. { L"TXK", L"A146" },
  398. { L"TXM", L"A146" },
  399. { L"WEE", L"A146" },
  400. { L"WEF", L"A146" },
  401. { L"WEJ", L"A146" },
  402. { L"WEK", L"A146" },
  403. { L"SZA", L"A003" },
  404. { L"SZU", L"A003" },
  405. { L"TXL", L"A147" },
  406. { L"TXN", L"A147" },
  407. { L"V9K", L"A444" },
  408. { L"V9L", L"A444" },
  409. { L"WU9", L"A444" },
  410. { L"VQM", L"A446" },
  411. { L"V9M", L"A446" },
  412. { L"V9N", L"A446" },
  413. { L"WEE", L"A446" },
  414. { L"V9P", L"A448" },
  415. { L"V9Q", L"A448" },
  416. { L"V9R", L"A450" },
  417. { L"V9S", L"A450" },
  418. { L"V95", L"A450" },
  419. { L"V96", L"A450" },
  420. { L"WUC", L"A450" },
  421. { L"W9G", L"A664" }, /* 30GB iPod Video U2 5.5g */
  422. { L"Y5N", L"B029" }, /* Silver Classic 80GB */
  423. { L"YMV", L"B147" }, /* Black Classic 80GB */
  424. { L"YMU", L"B145" }, /* Silver Classic 160GB */
  425. { L"YMX", L"B150" }, /* Black Classic 160GB */
  426. { L"2C5", L"B562" }, /* Silver Classic 120GB */
  427. { L"2C7", L"B565" }, /* Black Classic 120GB */
  428. { L"9ZS", L"C293" }, /* Silver Classic 160GB (2009) */
  429. { L"9ZU", L"C297" }, /* Black Classic 160GB (2009) */
  430. { L"37P", L"B663" }, /* 4GB Green Nano 4g */
  431. { L"37Q", L"B666" }, /* 4GB Yellow Nano 4g */
  432. { L"37H", L"B654" }, /* 4GB Pink Nano 4g */
  433. { L"1P1", L"B480" }, /* 4GB Silver Nano 4g */
  434. { L"37K", L"B657" }, /* 4GB Purple Nano 4g */
  435. { L"37L", L"B660" }, /* 4GB Orange Nano 4g */
  436. { L"2ME", L"B598" }, /* 8GB Silver Nano 4g */
  437. { L"3QS", L"B732" }, /* 8GB Blue Nano 4g */
  438. { L"3QT", L"B735" }, /* 8GB Pink Nano 4g */
  439. { L"3QU", L"B739" }, /* 8GB Purple Nano 4g */
  440. { L"3QW", L"B742" }, /* 8GB Orange Nano 4g */
  441. { L"3QX", L"B745" }, /* 8GB Green Nano 4g */
  442. { L"3QY", L"B748" }, /* 8GB Yellow Nano 4g */
  443. { L"3R0", L"B754" }, /* 8GB Black Nano 4g */
  444. { L"3QZ", L"B751" }, /* 8GB Red Nano 4g */
  445. { L"5B7", L"B903" }, /* 16GB Silver Nano 4g */
  446. { L"5B8", L"B905" }, /* 16GB Blue Nano 4g */
  447. { L"5B9", L"B907" }, /* 16GB Pink Nano 4g */
  448. { L"5BA", L"B909" }, /* 16GB Purple Nano 4g */
  449. { L"5BB", L"B911" }, /* 16GB Orange Nano 4g */
  450. { L"5BC", L"B913" }, /* 16GB Green Nano 4g */
  451. { L"5BD", L"B915" }, /* 16GB Yellow Nano 4g */
  452. { L"5BE", L"B917" }, /* 16GB Red Nano 4g */
  453. { L"5BF", L"B918" }, /* 16GB Black Nano 4g */
  454. { L"71V", L"C027" }, /* 8GB Silver Nano 5g */
  455. { L"71Y", L"C031" }, /* 8GB Black Nano 5g */
  456. { L"721", L"C034" }, /* 8GB Purple Nano 5g */
  457. { L"726", L"C037" }, /* 8GB Blue Nano 5g */
  458. { L"72A", L"C040" }, /* 8GB Green Nano 5g */
  459. { L"72F", L"C046" }, /* 8GB Orange Nano 5g */
  460. { L"72L", L"C050" }, /* 8GB Pink Nano 5g */
  461. { L"72Q", L"C060" }, /* 16GB Silver Nano 5g */
  462. { L"72R", L"C062" }, /* 16GB Black Nano 5g */
  463. { L"72S", L"C064" }, /* 16GB Purple Nano 5g */
  464. { L"72X", L"C066" }, /* 16GB Blue Nano 5g */
  465. { L"734", L"C068" }, /* 16GB Green Nano 5g */
  466. { L"738", L"C070" }, /* 16GB Yellow Nano 5g */
  467. { L"739", L"C072" }, /* 16GB Orange Nano 5g */
  468. { L"73A", L"C074" }, /* 16GB Red Nano 5g */
  469. { L"73B", L"C075" }, /* 16GB Pink Nano 5g */
  470. { L"4NZ", L"B867" }, /* 4GB Silver Shuffle 4g */
  471. { L"891", L"C164" }, /* 4GB Black Shuffle 4g */
  472. { L"W4T", L"A627" }, /* 16GB Silver iPod Touch (1st gen) */
  473. { L"0JW", L"B376" }, /* 32GB Silver iPod Touch (1st gen) */
  474. { L"201", L"B528" }, /* 8GB Silver iPod Touch (2nd gen) */
  475. { L"203", L"B531" }, /* 16GB Silver iPod Touch (2nd gen) */
  476. { L"75J", L"C086" }, /* 8GB Silver iPod Touch (3rd gen) */
  477. { L"6K2", L"C008" }, /* 32GB Silver iPod Touch (3rd gen) */
  478. { L"6K4", L"C011" }, /* 64GB Silver iPod Touch (3rd gen) */
  479. { L"VR0", L"A501" }, /* 4GB Silver iPhone 1st gen */
  480. { L"WH8", L"A712" }, /* 8GB Silver iPhone */
  481. { L"0KH", L"B384" }, /* 16GB Silver iPhone */
  482. { L"Y7H", L"B046" }, /* 8GB Black iPhone 3G */
  483. { L"Y7K", L"B496" }, /* 16GB Black iPhone 3G */
  484. { L"3NP", L"C131" }, /* 16GB Black iPhone 3GS */
  485. { L"3NR", L"C133" } /* 32GB Black iPhone 3GS */
  486. };
  487. static const wchar_t *GetModelStrForFamilyID(unsigned int familyID)
  488. {
  489. switch (familyID)
  490. {
  491. case 4: // iPod 4
  492. return L"9282";
  493. case 5: // iPod 4 (photo)
  494. return L"9830";
  495. case 6: // iPod 5
  496. return L"A002";
  497. case 7: // nano 1
  498. return L"A004";
  499. case 9: // nano 2
  500. return L"A477";
  501. case 11: // classic
  502. return L"B147";
  503. case 12: // fat nano
  504. return L"A978";
  505. case 128: // shuffle
  506. return L"A133";
  507. case 130: // shuffle 2
  508. return L"A947";
  509. default:
  510. return 0;
  511. }
  512. }
  513. static const iPodModelInfo *GetiPodInfoForModelStr(const wchar_t *modelstr)
  514. {
  515. // now locate this ipod in our table
  516. int l = sizeof(ipod_info_table)/sizeof(ipod_info_table[0]);
  517. for (int i=0; i<l; i++)
  518. {
  519. if (_wcsnicmp(ipod_info_table[i].model_number,modelstr,wcslen(ipod_info_table[i].model_number))==0)
  520. return &ipod_info_table[i]; // success!
  521. }
  522. return 0;
  523. }
  524. static const iPodModelInfo *GetiPodInfoForFamilyID(unsigned int familyID)
  525. {
  526. switch(familyID)
  527. {
  528. case 6:
  529. return &video_info;
  530. case 7:
  531. return &nano1g_info;
  532. case 9:
  533. return &nano2g_info;
  534. case 11:
  535. return &classic_info;
  536. case 12:
  537. return &nano3g_info;
  538. case 15:
  539. return &nano4g_info;
  540. case 128:
  541. return &shuffle1g_info;
  542. case 130: // shuffle 2G
  543. return &shuffle2g_info;
  544. case 132: // shuffle 3G
  545. return &shuffle3g_info;
  546. case 133: // shuffle 4G
  547. return &shuffle4g_info;
  548. }
  549. return 0;
  550. }
  551. const wchar_t* GetModelStrForSerialNumber(const wchar_t *serialNumber)
  552. {
  553. // now locate this ipod in our table
  554. int l = sizeof(serial_to_model_mapping)/sizeof(iPodSerialToModel);
  555. INT serialNumberLen = lstrlen(serialNumber);
  556. if (serialNumberLen < 3)
  557. {
  558. return NULL;
  559. }
  560. const wchar_t *last3OfSerialNumber = &serialNumber[serialNumberLen-3];
  561. for (int i=0; i<l; i++)
  562. {
  563. int compareRet = CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, last3OfSerialNumber, -1, serial_to_model_mapping[i].serial, -1)-2;
  564. if (compareRet==0)
  565. return serial_to_model_mapping[i].model_number; // success!
  566. }
  567. return 0;
  568. }
  569. extern bool ParseSysInfoXML(wchar_t drive_letter, char * xml, int xmllen);
  570. iPodInfo::iPodInfo(const iPodModelInfo *_model)
  571. {
  572. family_id = 0;
  573. color = _model->color;
  574. model = _model->model;
  575. model_number = _wcsdup(_model->model_number);
  576. image16 = _model->image16;
  577. image160 = _model->image160;
  578. fwid=0;
  579. supportedArtworkFormats=0;
  580. numberOfSupportedFormats=0;
  581. shadow_db_version=0;
  582. }
  583. iPodInfo::~iPodInfo()
  584. {
  585. free(fwid);
  586. free(model_number);
  587. delete supportedArtworkFormats;
  588. }
  589. void iPodInfo::SetFWID(const uint8_t *new_fwid)
  590. {
  591. fwid = (uint8_t *)malloc(8);
  592. memcpy(fwid, new_fwid, 8);
  593. }
  594. iPodInfo *GetiPodInfo(wchar_t drive)
  595. {
  596. static const iPodModelInfo unknown = {NULL, IPOD_MODEL_INVALID, IPOD_COLOR_WHITE};
  597. unsigned char fwid[8]={0};
  598. bool have_fwid=false;
  599. char xml[65536] = {0};
  600. if (ParseSysInfoXML(drive, xml, sizeof(xml)/sizeof(char)))
  601. {
  602. // go fetch the FamilyID so we can construct a model string
  603. DWORD bytesRead = strlen(xml);//sizeof(xml)/sizeof(char);
  604. // use the plist handler here instead of fishing for the familyid string
  605. // in the xml
  606. // instantiate the plist loader
  607. plistLoader it;
  608. obj_xml *parser=0;
  609. waServiceFactory *factory = plugin.service->service_getServiceByGuid(obj_xmlGUID);
  610. if (factory)
  611. {
  612. parser = (obj_xml *)factory->getInterface();
  613. }
  614. if (parser)
  615. {
  616. // load the XML, this creates an iTunes DB in memory, and returns the root key
  617. parser->xmlreader_open();
  618. parser->xmlreader_registerCallback(L"plist\f*", &it);
  619. parser->xmlreader_feed(xml, bytesRead);
  620. parser->xmlreader_feed(0, 0);
  621. parser->xmlreader_unregisterCallback(&it);
  622. parser->xmlreader_close();
  623. plistKey *root_key = &it;
  624. plistData *root_dict = root_key->getData();
  625. if (root_dict)
  626. {
  627. // get Firewire ID
  628. plistKey *fwidKey = ((plistDict*)root_dict)->getKey(L"FireWireGUID");
  629. if (fwidKey)
  630. {
  631. plistData *fwidData = fwidKey->getData();
  632. if (fwidData)
  633. {
  634. const wchar_t* p = fwidData->getString();
  635. for (int i=0; i<8 && *p; i++)
  636. {
  637. char num[3]={0,0,0};
  638. num[0] = *(p++);
  639. num[1] = *(p++);
  640. fwid[i] = (uint8_t)strtoul(num,NULL,16);
  641. }
  642. have_fwid=true;
  643. }
  644. }
  645. // check for the existance of sqlite
  646. plistKey *sqliteKey = ((plistDict*)root_dict)->getKey(L"SQLiteDB");
  647. if (sqliteKey)
  648. {
  649. plistData *sqliteData = sqliteKey->getData();
  650. if (sqliteData)
  651. {
  652. const wchar_t* sqliteString = sqliteData->getString();
  653. if (sqliteString)
  654. {
  655. int compareRet = CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, sqliteString, -1, L"1", -1)-2;
  656. // At this point we dont want to support the sqlite family of ipods
  657. // so, return unknown if sqlite found
  658. if (compareRet == 0)
  659. {
  660. return 0;
  661. }
  662. }
  663. }
  664. } // end sqlite check
  665. // check for FamilyID
  666. plistKey *familyKey = ((plistDict*)root_dict)->getKey(L"FamilyID");
  667. if (familyKey)
  668. {
  669. plistData *familyData = familyKey->getData();
  670. if (familyData)
  671. {
  672. const wchar_t* familyIDString = familyData->getString();
  673. if (familyIDString)
  674. {
  675. const wchar_t *modelStr = NULL;
  676. unsigned int familyID = _wtoi(familyIDString);
  677. // first, try to look up the iPod by family ID
  678. const iPodModelInfo *info = GetiPodInfoForFamilyID(familyID);
  679. if (!info)
  680. {
  681. modelStr = GetModelStrForFamilyID(familyID);
  682. // if modelString not apparent, as the case is in most
  683. // 5th gen nanos and classics
  684. if (!info && !modelStr)
  685. {
  686. plistKey *serialNumberKey = ((plistDict*)root_dict)->getKey(L"SerialNumber");
  687. if (serialNumberKey)
  688. {
  689. plistData *serialNumberData = serialNumberKey->getData();
  690. if (serialNumberData)
  691. {
  692. const wchar_t* serialNumberString = serialNumberData->getString();
  693. if (serialNumberString)
  694. {
  695. modelStr = GetModelStrForSerialNumber(serialNumberString);
  696. }
  697. }
  698. }
  699. }
  700. }
  701. if (modelStr || info)
  702. {
  703. if (!info)
  704. info = GetiPodInfoForModelStr(modelStr);
  705. if (info)
  706. {
  707. iPodInfo* retInfo = new iPodInfo(info);
  708. if (have_fwid)
  709. retInfo->SetFWID(fwid);
  710. plistKey *shadow_db_key = ((plistDict*)root_dict)->getKey(L"ShadowDB");
  711. if (shadow_db_key)
  712. {
  713. plistData *shadow_db_data = shadow_db_key->getData();
  714. if (shadow_db_data && shadow_db_data->getType() == PLISTDATA_BOOLEAN)
  715. {
  716. plistBoolean *shadow_db_boolean = (plistBoolean *)shadow_db_data;
  717. if (shadow_db_boolean->getValue())
  718. retInfo->shadow_db_version = 1;
  719. plistKey *shadow_db_version_key = ((plistDict*)root_dict)->getKey(L"ShadowDBVersion");
  720. if (shadow_db_version_key)
  721. {
  722. plistData *shadow_db_version_data = shadow_db_version_key->getData();
  723. if (shadow_db_version_data && shadow_db_version_data->getType() == PLISTDATA_INTEGER)
  724. {
  725. plistInteger *shadow_db_version_integer= (plistInteger *)shadow_db_version_data;
  726. retInfo->shadow_db_version = shadow_db_version_integer->getValue();
  727. }
  728. }
  729. }
  730. }
  731. // now try and populate the ArtworkFormats from the plist
  732. // looks something like this
  733. /*****************************************************
  734. <key>AlbumArt</key>
  735. <array>
  736. <key>1069</key>
  737. <dict>
  738. <key>FormatId</key>
  739. <integer>1069</integer>
  740. <key>RenderWidth</key>
  741. <integer>142</integer>
  742. <key>RenderHeight</key>
  743. <integer>142</integer>
  744. <key>PixelFormat</key>
  745. <string>4C353635</string>
  746. <key>Interlaced</key>
  747. <false/>
  748. <key>ColorAdjustment</key>
  749. <integer>0</integer>
  750. <key>GammaAdjustment</key>
  751. <real>2.2</real>
  752. <key>Crop</key>
  753. <false/>
  754. <key>AlignRowBytes</key>
  755. <true/>
  756. <key>BackColor</key>
  757. <string>00000000</string>
  758. <key>AssociatedFormat</key>
  759. <integer>131072</integer>
  760. <key>ExcludedFormats</key>
  761. <integer>-1</integer>
  762. </dict>
  763. <key>1055</key>
  764. <dict>
  765. <key>FormatId</key>
  766. <integer>1055</integer>
  767. <key>RenderWidth</key>
  768. <integer>128</integer>
  769. <key>RenderHeight</key>
  770. <integer>128</integer>
  771. <key>PixelFormat</key>
  772. <string>4C353635</string>
  773. <key>Interlaced</key>
  774. <false/>
  775. <key>ColorAdjustment</key>
  776. <integer>0</integer>
  777. <key>GammaAdjustment</key>
  778. <real>2.2</real>
  779. <key>Crop</key>
  780. <true/>
  781. <key>AlignRowBytes</key>
  782. <true/>
  783. <key>BackColor</key>
  784. <string>00000000</string>
  785. <key>AssociatedFormat</key>
  786. <integer>0</integer>
  787. </dict>
  788. </array>
  789. *******************************************************************/
  790. // look for the AlbumArt dict
  791. plistKey *albumArtKey = ((plistDict*)root_dict)->getKey(L"AlbumArt");
  792. if (albumArtKey)
  793. {
  794. plistArray* albumArtArray = (plistArray *) albumArtKey->getData();
  795. if (albumArtArray)
  796. {
  797. int numFormats = albumArtArray->getNumItems();
  798. ArtworkFormat* artworkFormats = new ArtworkFormat[numFormats];
  799. retInfo->supportedArtworkFormats = &artworkFormats[0];
  800. retInfo->numberOfSupportedFormats = numFormats;
  801. for (int i=0;i<numFormats;i++)
  802. {
  803. // we need to populate this structure
  804. /**
  805. static const ArtworkFormat ipod_color_artwork_info[] = {
  806. {THUMB_COVER_SMALL, 56, 56, 1017, RGB_565, 4, 4},
  807. {THUMB_COVER_LARGE, 140, 140, 1016, RGB_565, 4, 4},
  808. {THUMB_PHOTO_TV_SCREEN, 720, 480, 1019, RGB_565, 4, 4},
  809. {THUMB_PHOTO_LARGE, 130, 88, 1015, RGB_565, 4, 4},
  810. {THUMB_PHOTO_FULL_SCREEN, 220, 176, 1013, RGB_565, 4, 4},
  811. {THUMB_PHOTO_SMALL, 42, 30, 1009, RGB_565, 4, 4},
  812. {THUMB_INVALID, -1, -1, -1, RGB_565, 4, 4}
  813. };
  814. */
  815. plistDict *albumArtFormatDict = 0;
  816. plistData *albumArtFormatKey = (plistKey *)albumArtArray->enumItem(i);
  817. if (albumArtFormatKey->getType() == PLISTDATA_KEY)
  818. {
  819. albumArtFormatDict = (plistDict *)((plistKey *)albumArtFormatKey)->getData();
  820. }
  821. else
  822. { // Nano 4G doesn't store keys in the AlbumArt array
  823. albumArtFormatDict = (plistDict *)albumArtFormatKey;
  824. }
  825. int numKeys = albumArtFormatDict->getNumKeys();
  826. if (numKeys)
  827. {
  828. for (int j=0; j<numKeys; j++)
  829. {
  830. plistKey *albumArtFormatItemKey = albumArtFormatDict->enumKey(j);
  831. const wchar_t* albumArtFormatKeyName = albumArtFormatItemKey->getName();
  832. // we need all the arwork formats under AlbumArt, just use
  833. // a thumb type that we know is accepted
  834. artworkFormats[i].type = THUMB_COVER_SMALL;
  835. // these are 4, they just are
  836. artworkFormats[i].row_align = 4;
  837. artworkFormats[i].image_align = 4;
  838. // gather the FormatId
  839. if (CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, albumArtFormatKeyName, -1, L"FormatId", -1)-2 == 0)
  840. {
  841. const wchar_t* albumArtFormatValue = albumArtFormatItemKey->getData()->getString();
  842. if (albumArtFormatValue != NULL)
  843. {
  844. artworkFormats[i].correlation_id = _wtoi(albumArtFormatValue);
  845. }
  846. }
  847. // gather the RenderWidth
  848. if (CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, albumArtFormatKeyName, -1, L"RenderWidth", -1)-2 == 0)
  849. {
  850. const wchar_t* albumArtFormatValue = albumArtFormatItemKey->getData()->getString();
  851. if (albumArtFormatValue != NULL)
  852. {
  853. artworkFormats[i].width = _wtoi(albumArtFormatValue);
  854. }
  855. }
  856. // gather the RenderHeight
  857. if (CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, albumArtFormatKeyName, -1, L"RenderHeight", -1)-2 == 0)
  858. {
  859. const wchar_t* albumArtFormatValue = albumArtFormatItemKey->getData()->getString();
  860. if (albumArtFormatValue != NULL)
  861. {
  862. artworkFormats[i].height = _wtoi(albumArtFormatValue);
  863. }
  864. }
  865. // gather the PixelFormat
  866. if (CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, albumArtFormatKeyName, -1, L"PixelFormat", -1)-2 == 0)
  867. {
  868. const wchar_t* albumArtFormatValue = albumArtFormatItemKey->getData()->getString();
  869. if (albumArtFormatValue != NULL)
  870. {
  871. artworkFormats[i].format = RGB_565;
  872. }
  873. }
  874. }
  875. }
  876. }
  877. }
  878. }
  879. retInfo->family_id = familyID;
  880. return retInfo;
  881. }
  882. }
  883. }
  884. }
  885. } // end familyid
  886. }
  887. } // end plist parser
  888. }
  889. for (int yy=0; yy<2; yy++)
  890. {
  891. wchar_t sysinfo[] = {drive,L":\\iPod_Control\\Device\\SysInfo"};
  892. FILE *f = _wfopen(sysinfo,L"rt");
  893. if (f)
  894. {
  895. wchar_t *modelnr=NULL;
  896. wchar_t buf[1024] = {0};
  897. while (fgetws(buf,1024,f))
  898. {
  899. int len = wcslen(buf);
  900. //snip off trailing newline
  901. if (len>0 && buf[len-1]==10)
  902. {
  903. buf[len-1]=0; len--;
  904. }
  905. wchar_t *colon = wcschr(buf,L':');
  906. if (colon)
  907. {
  908. *colon=0;
  909. if (!wcscmp(L"ModelNumStr",buf)) // found ModelNumStr line..
  910. {
  911. modelnr = colon+1;
  912. while (modelnr && *modelnr == L' ') modelnr++;
  913. if (!(*modelnr >= L'0' && *modelnr <= L'9')) modelnr++;
  914. break; // modelnr found, so we're done
  915. }
  916. }
  917. }
  918. fclose(f);
  919. if (modelnr && *modelnr)
  920. {
  921. const iPodModelInfo *info = GetiPodInfoForModelStr(modelnr);
  922. if (info)
  923. {
  924. iPodInfo* retInfo = new iPodInfo(info);
  925. if (have_fwid)
  926. retInfo->SetFWID(fwid);
  927. return retInfo;
  928. }
  929. }
  930. }
  931. if (!yy)
  932. {
  933. int d = WASABI_API_DIALOGBOXPARAM(IDD_SELECTIPODTYPE,plugin.hwndWinampParent,selectipodtype_dlgproc,(LPARAM)sysinfo);
  934. if (d) return NULL;
  935. }
  936. }
  937. return new iPodInfo(&unknown);
  938. }
  939. const ArtworkFormat* GetArtworkFormats(const iPodInfo* info)
  940. {
  941. if (!info) return NULL;
  942. return ipod_artwork_info_table[info->model];
  943. }