1
0

MediaLibraryInterface.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #ifndef MEDIALIBRARYINTERFACEH
  2. #define MEDIALIBRARYINTERFACEH
  3. #include <windows.h>
  4. #include <tchar.h>
  5. #include "..\Plugins\General\gen_ml/ml.h"
  6. #include "../winamp/wa_ipc.h"
  7. #ifndef REPLICANT_COMPAT
  8. #include <vector>
  9. #endif
  10. class MediaLibraryInterface
  11. {
  12. public:
  13. MediaLibraryInterface() : httpRetrieveFile( 0 ) {}
  14. // children communicate back to the media library by SendMessage(plugin.hwndLibraryParent,WM_ML_IPC,param,ML_IPC_X);
  15. int AddTreeImage( int resourceId ); // returns index of the image.
  16. int AddTreeImage( int resourceId, int imageIndex, BMPFILTERPROC filter );
  17. int AddTreeImageBmp( int resourceId );
  18. void AddTreeItem( MLTREEITEM &newItem );
  19. void AddTreeItem( MLTREEITEMW &newItem );
  20. void SetTreeItem( MLTREEITEM &item );
  21. void SetTreeItem( MLTREEITEMW &item );
  22. void RemoveTreeItem( INT_PTR treeId );
  23. void SelectTreeItem( INT_PTR treeId );
  24. void UpdateTreeItem( MLTREEITEMINFO &newItem );
  25. void UpdateTreeItem( MLTREEITEMINFOW &newItem );
  26. INT_PTR GetSelectedTreeItem( void );
  27. void RenameTreeId( INT_PTR treeId, const wchar_t *newName );
  28. INT_PTR GetChildId( INT_PTR id );
  29. INT_PTR GetNextId( INT_PTR id );
  30. void AddToSendTo( char description[], INT_PTR context, INT_PTR unique );
  31. void AddToSendTo( wchar_t description[], INT_PTR context, INT_PTR unique );
  32. void BranchSendTo( INT_PTR context );
  33. void AddToBranchSendTo( const wchar_t description[], INT_PTR context, INT_PTR unique );
  34. void EndBranchSendTo( const wchar_t description[], INT_PTR context );
  35. const char *GetIniDirectory();
  36. const wchar_t *GetIniDirectoryW();
  37. const char *GetWinampIni();
  38. const wchar_t *GetWinampIniW();
  39. void BuildPath( const wchar_t *pathEnd, wchar_t *path, size_t numChars );
  40. int SkinList( HWND list );
  41. void UnskinList( int token );
  42. void ListViewShowSort( int token, BOOL show );
  43. void ListViewSort( int token, int columnIndex, BOOL ascending );
  44. void ListSkinUpdateView( int listSkin );
  45. void OpenURL( const wchar_t *url ) { SendMessage( winamp, WM_WA_IPC, (WPARAM)url, IPC_OPEN_URL ); }
  46. int SkinComboBox( HWND comboBox );
  47. void UnskinComboBox( int token );
  48. void *GetWADLGFunc( int num );
  49. #ifndef REPLICANT_COMPAT
  50. void PlayStreams( std::vector<const wchar_t *> &urls, bool force = false );
  51. #endif
  52. void PlayStream( wchar_t *url, bool force = false );
  53. void PlayFile( const wchar_t *url );
  54. void EnqueueFile( const wchar_t *url );
  55. void EnqueueStream( wchar_t *url, bool force = true );
  56. void GetFileInfo( const char *filename, char *title, int titleCch, int *length );
  57. void GetFileInfo( const wchar_t *filename, wchar_t *title, int titleCch, int *length );
  58. void ClearPlaylist() { SendMessage( winamp, WM_WA_IPC, 0, IPC_DELETE ); }
  59. void SwitchToPluginView( int itemId ) { SendMessage( library, WM_ML_IPC, itemId, ML_IPC_SETCURTREEITEM ); }
  60. int GetWinampVersion() { return (int)(INT_PTR)SendMessage( winamp, WM_WA_IPC, 0, IPC_GETVERSION ); }
  61. HWND library = 0;
  62. HWND winamp = 0;
  63. HINSTANCE instance = 0;
  64. const char *iniDirectory = 0;
  65. const wchar_t *iniDirectoryW = 0;
  66. const char *winampIni = 0;
  67. const wchar_t *winampIniW = 0;
  68. const char *pluginDirectory = 0;
  69. void AddPreferences( prefsDlgRec &prefs ) { SendMessage( winamp, WM_WA_IPC, (WPARAM)&prefs, IPC_ADD_PREFS_DLG ); }
  70. void AddPreferences( prefsDlgRecW &prefs ) { SendMessage( winamp, WM_WA_IPC, (WPARAM)&prefs, IPC_ADD_PREFS_DLGW ); }
  71. void InsertTreeItem( MLTREEITEM &newItem );
  72. void InsertTreeItem( MLTREEITEMW &newItem );
  73. char *GetProxy()
  74. {
  75. char *proxy = (char *)SendMessage( winamp, WM_WA_IPC, 0, IPC_GET_PROXY_STRING );
  76. if ( proxy == (char *)1 || strlen(proxy) == 0 )
  77. return 0;
  78. else
  79. return proxy;
  80. }
  81. void BuildPluginPath( const TCHAR *filename, TCHAR *path, size_t pathSize );
  82. int ( *httpRetrieveFile )( HWND hwnd, const char *url, const char *file, const char *dlgtitle );
  83. IDispatch *GetDispatchObject();
  84. int GetUniqueDispatchId();
  85. void ListSkinDisableHorizontalScrollbar( int listSkin );
  86. void AddToMediaLibrary( const char *filename );
  87. void AddToMediaLibrary( const wchar_t *filename );
  88. void GoToPreferences( int id ) { SendMessage( winamp, WM_WA_IPC, id, IPC_OPENPREFSTOPAGE ); }
  89. void GoToPreferences( prefsDlgRec &prefs ) { SendMessage( winamp, WM_WA_IPC, (WPARAM)&prefs, IPC_OPENPREFSTOPAGE ); }
  90. void GoToPreferences( prefsDlgRecW &prefs ) { SendMessage( winamp, WM_WA_IPC, (WPARAM)&prefs, IPC_OPENPREFSTOPAGE ); }
  91. const char *GetFontName() { return (const char *)SendMessage( winamp, WM_WA_IPC, 1, IPC_GET_GENSKINBITMAP ); }
  92. int GetFontSize() { return (int)SendMessage( winamp, WM_WA_IPC, 3, IPC_GET_GENSKINBITMAP ); }
  93. void AddBookmark( char *bookmark )
  94. {
  95. COPYDATASTRUCT cds;
  96. cds.dwData = IPC_ADDBOOKMARK;
  97. cds.lpData = bookmark;
  98. cds.cbData = (int)strlen( bookmark ) + 1;
  99. SendMessage( winamp, WM_COPYDATA, NULL, (LPARAM)&cds );
  100. }
  101. void AddBookmarkW( wchar_t *bookmark )
  102. {
  103. COPYDATASTRUCT cds;
  104. cds.dwData = IPC_ADDBOOKMARKW;
  105. cds.lpData = bookmark;
  106. cds.cbData = (int)( sizeof( wchar_t ) * wcslen( bookmark ) + sizeof( wchar_t ) );
  107. SendMessage( winamp, WM_COPYDATA, NULL, (LPARAM)&cds );
  108. }
  109. void ShowMediaLibrary() { SendMessage( library, WM_ML_IPC, 0, ML_IPC_ENSURE_VISIBLE ); }
  110. const char *GetExtensionList() { return (const char *)SendMessage( winamp, WM_WA_IPC, 0, IPC_GET_EXTLIST ); }
  111. bool IsShowing() { return !!SendMessage( library, WM_ML_IPC, 0, ML_IPC_IS_VISIBLE ); }
  112. void RefreshPrefs( int prefs ) { SendMessage( library, WM_ML_IPC, prefs, ML_IPC_REFRESH_PREFS ); }
  113. void GracenoteCancelRequest() { SendMessage( library, WM_ML_IPC, GRACENOTE_CANCEL_REQUEST, ML_IPC_GRACENOTE ); }// TODO: should we post this?
  114. DWORD AddDispatch( wchar_t *name, IDispatch *object );
  115. };
  116. extern MediaLibraryInterface mediaLibrary;
  117. #endif