main.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #include "Main.h"
  2. #include "api.h"
  3. #include "loadini.h"
  4. #include "FileTypes.h"
  5. #include <commctrl.h>
  6. #include "../nu/Config.h"
  7. #include "../nu/CCVersion.h"
  8. #include "resource.h"
  9. wchar_t INI_FILE[MAX_PATH] = L"";
  10. IDispatch *winampExternal = 0;
  11. Nullsoft::Utility::Config wmConfig;
  12. WMDRM mod;
  13. HINSTANCE WASABI_API_LNG_HINST_WAV = 0;
  14. HINSTANCE WASABI_API_LNG_HINST_DS = 0;
  15. int Init()
  16. {
  17. if (!IsWindow(plugin.hMainWindow))
  18. return IN_INIT_FAILURE;
  19. if (!LoadWasabi())
  20. return IN_INIT_FAILURE;
  21. plugin.UsesOutputPlug |= 8;
  22. // need to have this initialised before we try to do anything with localisation features
  23. WASABI_API_START_LANG(plugin.hDllInstance,InWmLangGUID);
  24. static wchar_t szDescription[256];
  25. swprintf(szDescription,256,WASABI_API_LNGSTRINGW(IDS_NULLSOFT_WINDOWS_MEDIA_DECODER),WMDRM_VERSION);
  26. plugin.description = (char*)szDescription;
  27. IniFile(plugin.hMainWindow);
  28. wmConfig.SetFile(INI_FILE, L"in_wm");
  29. ReadConfig();
  30. fileTypes.ReadConfig();
  31. if (NULL == winampExternal)
  32. {
  33. winampExternal = (IDispatch *)SendMessage(plugin.hMainWindow, WM_WA_IPC, 0, IPC_GET_DISPATCH_OBJECT); // ask for winamp's
  34. if (winampExternal == (IDispatch *)1)
  35. winampExternal = 0;
  36. }
  37. mod.Init();
  38. return IN_INIT_SUCCESS;
  39. }
  40. void Quit()
  41. {
  42. mod.Quit();
  43. UnloadWasabi();
  44. fileTypes.types.clear();
  45. if (NULL != winampExternal)
  46. {
  47. winampExternal->Release();
  48. winampExternal = NULL;
  49. }
  50. }
  51. void Config(HWND parent)
  52. {
  53. mod.Config(parent);
  54. fileTypes.SaveConfig();
  55. WriteConfig();
  56. }
  57. void About(HWND parent)
  58. {
  59. wchar_t message[1024] = {0}, text[1024] = {0};
  60. WASABI_API_LNGSTRINGW_BUF(IDS_NULLSOFT_WINDOWS_MEDIA_DECODER_OLD,text,1024);
  61. wsprintfW(message, WASABI_API_LNGSTRINGW(IDS_ABOUT_TEXT),
  62. plugin.description, TEXT(__DATE__));
  63. DoAboutMessageBox(parent,text,message);
  64. }
  65. void GetFileInfo(const in_char *file, wchar_t *title, int *length_in_ms) { mod.GetFileInfo(file, title, length_in_ms); }
  66. int InfoDialog(const in_char *file, HWND parent) { return mod.InfoBox(file, parent); }
  67. int IsOurFile(const in_char *fn) { return mod.IsOurFile(fn); }
  68. int Play(const in_char *fn) {return mod.Play(fn); }
  69. void Pause() { mod.Pause(); }
  70. void Resume() { mod.UnPause(); }
  71. int IsPaused() { return mod.IsPaused(); }
  72. void Stop() { mod.Stop(); }
  73. int GetLength() { return mod.GetLength(); }
  74. int GetOutputTime() { return mod.GetOutputTime(); }
  75. void SetOutputTime(int time_in_ms) { return mod.SetOutputTime(time_in_ms); }
  76. void SetVolume(int volume) { mod.SetVolume(volume); }
  77. void SetPan(int pan) { mod.SetPan(pan); }
  78. void EQSet(int on, char data[10], int preamp) { mod.EQSet(on, data, preamp); }
  79. In_Module plugin =
  80. {
  81. IN_VER_RET, // defined in IN2.H
  82. "nullsoft(in_wm.dll)",
  83. 0, // hMainWindow (filled in by winamp)
  84. 0, // hDllInstance (filled in by winamp)
  85. 0, // this is a double-null limited list. "EXT\0Description\0EXT\0Description\0" etc.
  86. 0, // is_seekable
  87. 1, // uses output plug-in system
  88. Config,
  89. About,
  90. Init,
  91. Quit,
  92. GetFileInfo,
  93. InfoDialog,
  94. IsOurFile,
  95. Play,
  96. Pause,
  97. Resume,
  98. IsPaused,
  99. Stop,
  100. GetLength,
  101. GetOutputTime,
  102. SetOutputTime,
  103. SetVolume,
  104. SetPan,
  105. 0,0,0,0,0,0,0,0,0, // visualization calls filled in by winamp
  106. 0,0, // dsp calls filled in by winamp
  107. EQSet,
  108. NULL, // setinfo call filled in by winamp
  109. 0, // out_mod filled in by winamp
  110. };
  111. extern "C" __declspec( dllexport ) In_Module * winampGetInModule2()
  112. {
  113. return &plugin;
  114. }