storageXml.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #include "main.h"
  2. #include "./storageXml.h"
  3. #include "./resource.h"
  4. #include "./ifc_omservice.h"
  5. #include "./ifc_omserviceenum.h"
  6. #include "./enumXmlFile.h"
  7. #include <strsafe.h>
  8. OmStorageXml::OmStorageXml()
  9. : ref(1)
  10. {
  11. }
  12. OmStorageXml::~OmStorageXml()
  13. {
  14. }
  15. HRESULT OmStorageXml::CreateInstance(OmStorageXml **instance)
  16. {
  17. if (NULL == instance) return E_POINTER;
  18. *instance = new OmStorageXml();
  19. if (NULL == *instance) return E_OUTOFMEMORY;
  20. return S_OK;
  21. }
  22. size_t OmStorageXml::AddRef()
  23. {
  24. return InterlockedIncrement((LONG*)&ref);
  25. }
  26. size_t OmStorageXml::Release()
  27. {
  28. if (0 == ref)
  29. return ref;
  30. LONG r = InterlockedDecrement((LONG*)&ref);
  31. if (0 == r)
  32. delete(this);
  33. return r;
  34. }
  35. int OmStorageXml::QueryInterface(GUID interface_guid, void **object)
  36. {
  37. if (NULL == object) return E_POINTER;
  38. if (IsEqualIID(interface_guid, IFC_OmStorage))
  39. *object = static_cast<ifc_omstorage*>(this);
  40. else if (IsEqualIID(interface_guid, STID_OmFileStorage))
  41. *object = static_cast<ifc_omfilestorage*>(this);
  42. else if (IsEqualIID(interface_guid, SUID_OmStorageXml))
  43. *object = static_cast<ifc_omstorage*>(this);
  44. else
  45. {
  46. *object = NULL;
  47. return E_NOINTERFACE;
  48. }
  49. if (NULL == *object)
  50. return E_UNEXPECTED;
  51. AddRef();
  52. return S_OK;
  53. }
  54. HRESULT OmStorageXml::GetId(GUID *storageUid)
  55. {
  56. if (NULL == storageUid) return E_POINTER;
  57. *storageUid = SUID_OmStorageXml;
  58. return S_OK;
  59. }
  60. HRESULT OmStorageXml::GetType(GUID *storageType)
  61. {
  62. if (NULL == storageType) return E_POINTER;
  63. *storageType = STID_OmFileStorage;
  64. return S_OK;
  65. }
  66. UINT OmStorageXml::GetCapabilities()
  67. {
  68. return capLoad | capPublic;
  69. }
  70. HRESULT OmStorageXml::GetDescription(LPWSTR pszBuffer, UINT cchBufferMax)
  71. {
  72. if (NULL == pszBuffer) return E_POINTER;
  73. Plugin_LoadString(IDS_STORAGE_XML, pszBuffer, cchBufferMax);
  74. return S_OK;
  75. }
  76. HRESULT OmStorageXml::Load(LPCWSTR pszAddress, ifc_omservicehost *host, ifc_omserviceenum **ppEnum)
  77. {
  78. if (NULL == ppEnum) return E_POINTER;
  79. *ppEnum = NULL;
  80. if (NULL == pszAddress || L'\0' == *pszAddress)
  81. return E_INVALIDARG;
  82. return EnumXmlFile::CreateInstance(pszAddress, host, (EnumXmlFile**)ppEnum);
  83. }
  84. HRESULT OmStorageXml::Save(ifc_omservice **serviceList, ULONG listCount, UINT saveFlags, ULONG *savedCount)
  85. {
  86. return E_NOTIMPL;
  87. }
  88. HRESULT OmStorageXml::Delete(ifc_omservice **serviceList, ULONG listCount, ULONG *deletedCount)
  89. {
  90. return E_NOTIMPL;
  91. }
  92. HRESULT OmStorageXml::GetFilter(LPWSTR pszBuffer, UINT cchBufferMax)
  93. {
  94. if (NULL == pszBuffer) return E_POINTER;
  95. return StringCchCopy(pszBuffer, cchBufferMax, L"*.xml");
  96. }
  97. #define CBCLASS OmStorageXml
  98. START_MULTIPATCH;
  99. START_PATCH(MPIID_OMSTORAGE)
  100. M_CB(MPIID_OMSTORAGE, ifc_omstorage, ADDREF, AddRef);
  101. M_CB(MPIID_OMSTORAGE, ifc_omstorage, RELEASE, Release);
  102. M_CB(MPIID_OMSTORAGE, ifc_omstorage, QUERYINTERFACE, QueryInterface);
  103. M_CB(MPIID_OMSTORAGE, ifc_omstorage, API_GETID, GetId);
  104. M_CB(MPIID_OMSTORAGE, ifc_omstorage, API_GETTYPE, GetType);
  105. M_CB(MPIID_OMSTORAGE, ifc_omstorage, API_GETCAPABILITIES, GetCapabilities);
  106. M_CB(MPIID_OMSTORAGE, ifc_omstorage, API_GETDESCRIPTION, GetDescription);
  107. M_CB(MPIID_OMSTORAGE, ifc_omstorage, API_LOAD, Load);
  108. M_CB(MPIID_OMSTORAGE, ifc_omstorage, API_SAVE, Save);
  109. M_CB(MPIID_OMSTORAGE, ifc_omstorage, API_DELETE, Delete);
  110. NEXT_PATCH(MPIID_OMFILESTORAGE)
  111. M_CB(MPIID_OMFILESTORAGE, ifc_omfilestorage, ADDREF, AddRef);
  112. M_CB(MPIID_OMFILESTORAGE, ifc_omfilestorage, RELEASE, Release);
  113. M_CB(MPIID_OMFILESTORAGE, ifc_omfilestorage, QUERYINTERFACE, QueryInterface);
  114. M_CB(MPIID_OMFILESTORAGE, ifc_omfilestorage, API_GETFILTER, GetFilter);
  115. END_PATCH
  116. END_MULTIPATCH;
  117. #undef CBCLASS