1
0

ifc_playlistloadercallback.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef NULLSOFT_IFC_PLAYLISTLOADERCALLBACK_H
  2. #define NULLSOFT_IFC_PLAYLISTLOADERCALLBACK_H
  3. #include <bfc/dispatch.h>
  4. #include <bfc/platform/types.h>
  5. #include "ifc_plentryinfo.h"
  6. #ifndef FILENAME_SIZE
  7. #define FILENAME_SIZE (MAX_PATH * 4)
  8. #endif
  9. #ifndef FILETITLE_SIZE
  10. #define FILETITLE_SIZE 400
  11. #endif
  12. class ifc_playlistinfo; // TODO
  13. class ifc_playlistloadercallback : public Dispatchable
  14. {
  15. protected:
  16. ifc_playlistloadercallback() {}
  17. ~ifc_playlistloadercallback() {}
  18. public:
  19. // return 0 to continue enumeration, or 1 to quit
  20. // title will be NULL if no title found, length will be -1
  21. int OnFile( const wchar_t *filename, const wchar_t *title, int lengthInMS, ifc_plentryinfo *info );
  22. void OnFileOld( const wchar_t *filename, const wchar_t *title, int lengthInMS, ifc_plentryinfo *info );
  23. // numEntries is just a hint, there is no gaurantee. 0 means "don't know"
  24. int OnPlaylistInfo( const wchar_t *playlistName, size_t numEntries, ifc_plentryinfo *info );
  25. void OnPlaylistInfoOld( const wchar_t *playlistName, size_t numEntries, ifc_plentryinfo *info );
  26. const wchar_t *GetBasePath(); // return 0 to use playlist file path as base (or just don't implement)
  27. DISPATCH_CODES
  28. {
  29. IFC_PLAYLISTLOADERCALLBACK_ONFILE = 10,
  30. IFC_PLAYLISTLOADERCALLBACK_ONFILE_RET = 11,
  31. IFC_PLAYLISTLOADERCALLBACK_ONPLAYLISTINFO = 20,
  32. IFC_PLAYLISTLOADERCALLBACK_ONPLAYLISTINFO_RET = 21,
  33. IFC_PLAYLISTLOADERCALLBACK_GETBASEPATH = 30,
  34. };
  35. enum
  36. {
  37. LOAD_CONTINUE = 0,
  38. LOAD_ABORT = 1,
  39. };
  40. };
  41. inline void ifc_playlistloadercallback::OnFileOld( const wchar_t *filename, const wchar_t *title, int lengthInMS, ifc_plentryinfo *info )
  42. {
  43. _voidcall( IFC_PLAYLISTLOADERCALLBACK_ONFILE, filename, title, lengthInMS, info );
  44. }
  45. inline int ifc_playlistloadercallback::OnFile( const wchar_t *filename, const wchar_t *title, int lengthInMS, ifc_plentryinfo *info )
  46. {
  47. void *params[ 4 ] = { &filename, &title, &lengthInMS, &info };
  48. int retval;
  49. if ( _dispatch( IFC_PLAYLISTLOADERCALLBACK_ONFILE_RET, &retval, params, 4 ) == 0 )
  50. {
  51. _dispatch( IFC_PLAYLISTLOADERCALLBACK_ONFILE, 0, params, 4 );
  52. return LOAD_CONTINUE;
  53. }
  54. return retval;
  55. }
  56. inline void ifc_playlistloadercallback::OnPlaylistInfoOld( const wchar_t *playlistName, size_t numEntries, ifc_plentryinfo *info )
  57. {
  58. _voidcall( IFC_PLAYLISTLOADERCALLBACK_ONPLAYLISTINFO, playlistName, numEntries, info );
  59. }
  60. inline int ifc_playlistloadercallback::OnPlaylistInfo( const wchar_t *playlistName, size_t numEntries, ifc_plentryinfo *info )
  61. {
  62. void *params[ 3 ] = { &playlistName, &numEntries, &info };
  63. int retval;
  64. if ( _dispatch( IFC_PLAYLISTLOADERCALLBACK_ONPLAYLISTINFO_RET, &retval, params, 3 ) == 0 )
  65. {
  66. _dispatch( IFC_PLAYLISTLOADERCALLBACK_ONPLAYLISTINFO, 0, params, 3 );
  67. return LOAD_CONTINUE;
  68. }
  69. return retval;
  70. }
  71. inline const wchar_t *ifc_playlistloadercallback::GetBasePath()
  72. {
  73. return _call( IFC_PLAYLISTLOADERCALLBACK_GETBASEPATH, (const wchar_t *)0 );
  74. }
  75. #endif