configIni.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef NULLSOFT_WINAMP_OMCONFIG_INI_HEADER
  2. #define NULLSOFT_WINAMP_OMCONFIG_INI_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include "./ifc_omconfig.h"
  7. #include "./ifc_ombrowserconfig.h"
  8. #include "./ifc_omdebugconfig.h"
  9. #include "./ifc_omtoolbarconfig.h"
  10. #include "./ifc_omstatusbarconfig.h"
  11. #include <bfc/multipatch.h>
  12. #include <map>
  13. class api_application;
  14. #define MPIID_OMCONFIG 10
  15. #define MPIID_OMBROWSERCONFIG 20
  16. #define MPIID_OMDEBUGCONFIG 30
  17. #define MPIID_OMTOOLBARCONFIG 40
  18. #define MPIID_OMSTATUSBARCONFIG 50
  19. class OmConfigIni : public MultiPatch<MPIID_OMCONFIG, ifc_omconfig>,
  20. public MultiPatch<MPIID_OMBROWSERCONFIG, ifc_ombrowserconfig>,
  21. public MultiPatch<MPIID_OMDEBUGCONFIG, ifc_omdebugconfig>,
  22. public MultiPatch<MPIID_OMTOOLBARCONFIG, ifc_omtoolbarconfig>,
  23. public MultiPatch<MPIID_OMSTATUSBARCONFIG, ifc_omstatusbarconfig>
  24. {
  25. protected:
  26. OmConfigIni(LPCWSTR pszPath);
  27. ~OmConfigIni();
  28. public:
  29. static HRESULT CreateInstance(LPCWSTR pszName, OmConfigIni **instanceOut);
  30. public:
  31. /* Dispatchable */
  32. size_t AddRef();
  33. size_t Release();
  34. int QueryInterface(GUID interface_guid, void **object);
  35. /* ifc_omconfig */
  36. HRESULT GetPath(LPWSTR pszBuffer, INT cchBufferMax);
  37. DWORD ReadStr(LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpDefault, LPWSTR lpReturnedString, DWORD nSize);
  38. UINT ReadInt(LPCWSTR lpSectionName, LPCWSTR lpKeyName, INT nDefault);
  39. BOOL ReadBool(LPCWSTR lpSectionName, LPCWSTR lpKeyName, BOOL bDefault);
  40. HRESULT WriteStr(LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR lpString);
  41. HRESULT WriteInt(LPCWSTR lpSectionName, LPCWSTR lpKeyName, INT nValue);
  42. HRESULT WriteBool(LPCWSTR lpSectionName, LPCWSTR lpKeyName, BOOL bValue);
  43. HRESULT RegisterCallback(ifc_omconfigcallback *callback, UINT *cookie);
  44. HRESULT UnregisterCallback(UINT cookie);
  45. /* ifc_ombrowserconfig */
  46. HRESULT GetClientId(LPWSTR pszBuffer, INT cchBufferMax);
  47. HRESULT SetClientId(LPWSTR pszClientId);
  48. UINT GetX(void);
  49. UINT GetY(void);
  50. HRESULT SetX(UINT x);
  51. HRESULT SetY(UINT y);
  52. /* ifc_omdebugconfig */
  53. HRESULT GetMenuFilterEnabled(void);
  54. HRESULT GetScriptErrorEnabled(void);
  55. HRESULT GetScriptDebuggerEnabled(void);
  56. HRESULT GetBrowserPath(LPWSTR pszBuffer, INT cchBufferMax);
  57. HRESULT EnableMenuFilter(BOOL fEnable);
  58. HRESULT EnableScriptError(BOOL fEnable);
  59. HRESULT EnableScriptDebugger(BOOL fEnable);
  60. HRESULT SetBrowserPath(LPCWSTR pszPath);
  61. /* ifc_omtoolbarconfig */
  62. HRESULT Toolbar_GetBottomDockEnabled(void);
  63. HRESULT Toolbar_GetAutoHideEnabled(void);
  64. HRESULT Toolbar_GetTabStopEnabled(void);
  65. HRESULT Toolbar_GetForceAddressbarEnabled(void);
  66. HRESULT Toolbar_GetFancyAddressbarEnabled(void);
  67. HRESULT Toolbar_EnableBottomDock(BOOL fEnable);
  68. HRESULT Toolbar_EnableAutoHide(BOOL fEnable);
  69. HRESULT Toolbar_EnableTabStop(BOOL fEnable);
  70. HRESULT Toolbar_EnableForceAddressbar(BOOL fEnable);
  71. HRESULT Toolbar_EnableFancyAddressbar(BOOL fEnable);
  72. /* ifc_omstatusbarconfig */
  73. HRESULT Statusbar_GetEnabled(void);
  74. HRESULT Statusbar_EnableStatusbar(BOOL fEnable);
  75. public:
  76. void NotifyChange(const GUID *configUid, UINT valueId, ULONG_PTR value);
  77. protected:
  78. typedef std::map<UINT, ifc_omconfigcallback*> CallbackMap;
  79. protected:
  80. RECVS_MULTIPATCH;
  81. protected:
  82. ULONG ref;
  83. LPWSTR configPath;
  84. UINT lastCookie;
  85. CallbackMap callbackMap;
  86. CRITICAL_SECTION lock;
  87. BOOL pathValidated;
  88. };
  89. #endif //NULLSOFT_WINAMP_OMCONFIG_INI_HEADER