1
0

main.cpp 3.3 KB

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