1
0

main.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #define PLUGIN_VERSION L"0.1"
  2. #include <strsafe.h>
  3. #include "Main.h"
  4. #include "../nu/AutoWide.h"
  5. #include "../../General/gen_ml/menu.h"
  6. #include "../../General/gen_ml/ml_ipc_0313.h"
  7. #include "../WAT/WAT.h"
  8. static int Init();
  9. static void Quit();
  10. extern "C" winampMediaLibraryPlugin plugin =
  11. {
  12. MLHDR_VER,
  13. "nullsoft(ml_nft.dll)",
  14. Init,
  15. Quit,
  16. nft_pluginMessageProc,
  17. 0,
  18. 0,
  19. 0,
  20. };
  21. int nft_treeItem = 0;
  22. HCURSOR hDragNDropCursor;
  23. C_Config *g_config = 0;
  24. WNDPROC waProc = 0;
  25. // wasabi based services for localisation support
  26. api_language *WASABI_API_LNG = 0;
  27. HINSTANCE WASABI_API_LNG_HINST = 0;
  28. HINSTANCE WASABI_API_ORIG_HINST = 0;
  29. api_stats *AGAVE_API_STATS = 0;
  30. api_application *WASABI_API_APP = 0;
  31. static DWORD WINAPI wa_newWndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
  32. {
  33. if ( waProc )
  34. return (DWORD)CallWindowProcW( waProc, hwnd, msg, wParam, lParam );
  35. else
  36. return (DWORD)DefWindowProc( hwnd, msg, wParam, lParam );
  37. }
  38. int Init()
  39. {
  40. waProc = (WNDPROC)SetWindowLongPtrW( plugin.hwndWinampParent, GWLP_WNDPROC, (LONG_PTR)wa_newWndProc );
  41. mediaLibrary.library = plugin.hwndLibraryParent;
  42. mediaLibrary.winamp = plugin.hwndWinampParent;
  43. mediaLibrary.instance = plugin.hDllInstance;
  44. waServiceFactory *sf = plugin.service->service_getServiceByGuid( languageApiGUID );
  45. if ( sf )
  46. WASABI_API_LNG = reinterpret_cast<api_language *>( sf->getInterface() );
  47. sf = plugin.service->service_getServiceByGuid( AnonymousStatsGUID );
  48. if ( sf )
  49. AGAVE_API_STATS = reinterpret_cast<api_stats *>( sf->getInterface() );
  50. sf = plugin.service->service_getServiceByGuid( applicationApiServiceGuid );
  51. if ( sf )
  52. WASABI_API_APP = reinterpret_cast<api_application *>( sf->getInterface() );
  53. // need to have this initialised before we try to do anything with localisation features
  54. WASABI_API_START_LANG( plugin.hDllInstance, MlNFTLangGUID );
  55. static wchar_t szDescription[ 256 ];
  56. StringCchPrintfW( szDescription, ARRAYSIZE( szDescription ), WASABI_API_LNGSTRINGW( IDS_NULLSOFT_NFT ), PLUGIN_VERSION );
  57. plugin.description = (char *)szDescription;
  58. wchar_t inifile[ MAX_PATH ] = { 0 };
  59. mediaLibrary.BuildPath( L"Plugins", inifile, MAX_PATH );
  60. CreateDirectoryW( inifile, NULL );
  61. mediaLibrary.BuildPath( L"Plugins\\gen_ml.ini", inifile, MAX_PATH );
  62. g_config = new C_Config( inifile );
  63. hDragNDropCursor = LoadCursor( GetModuleHandle( L"gen_ml.dll" ), MAKEINTRESOURCE( ML_IDC_DRAGDROP ) );
  64. NAVINSERTSTRUCT nis = { 0 };
  65. nis.item.cbSize = sizeof( NAVITEM );
  66. nis.item.pszText = WASABI_API_LNGSTRINGW( IDS_NFT );
  67. nis.item.pszInvariant = L"NFT Library";
  68. nis.item.mask = NIMF_TEXT | NIMF_TEXTINVARIANT | NIMF_IMAGE | NIMF_IMAGESEL;
  69. nis.item.iSelectedImage = nis.item.iImage = mediaLibrary.AddTreeImageBmp( IDB_TREEITEM_NFT );
  70. // map to item id (will probably have to change but is a quick port to support invariant item naming)
  71. NAVITEM nvItem = { sizeof( NAVITEM ),0,NIMF_ITEMID, };
  72. nvItem.hItem = MLNavCtrl_InsertItem( plugin.hwndLibraryParent, &nis );
  73. MLNavItem_GetInfo( plugin.hwndLibraryParent, &nvItem );
  74. nft_treeItem = nvItem.id;
  75. return 0;
  76. }
  77. void Quit()
  78. {
  79. if ( g_config != 0 )
  80. delete g_config;
  81. }
  82. extern "C" __declspec(dllexport) winampMediaLibraryPlugin *winampGetMediaLibraryPlugin()
  83. {
  84. return &plugin;
  85. }