ZCABProvider.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #include <kopano/platform.h>
  18. #include <new>
  19. #include "ZCABProvider.h"
  20. #include "ZCABLogon.h"
  21. #include <mapidefs.h>
  22. #include <mapicode.h>
  23. #include <mapiguid.h>
  24. #include <kopano/ECGuid.h>
  25. #include <kopano/ECInterfaceDefs.h>
  26. #include <kopano/ECDebug.h>
  27. #include <kopano/Trace.h>
  28. #include <kopano/memory.hpp>
  29. using namespace KCHL;
  30. ZCABProvider::ZCABProvider(ULONG ulFlags, const char *szClassName) :
  31. ECUnknown(szClassName)
  32. {
  33. }
  34. HRESULT ZCABProvider::Create(ZCABProvider **lppZCABProvider)
  35. {
  36. auto lpZCABProvider = new(std::nothrow) ZCABProvider(0, "ZCABProvider");
  37. if (lpZCABProvider == nullptr)
  38. return MAPI_E_NOT_ENOUGH_MEMORY;
  39. HRESULT hr = lpZCABProvider->QueryInterface(IID_ZCABProvider,
  40. reinterpret_cast<void **>(lppZCABProvider));
  41. if(hr != hrSuccess)
  42. delete lpZCABProvider;
  43. return hrSuccess;
  44. }
  45. HRESULT ZCABProvider::QueryInterface(REFIID refiid, void **lppInterface)
  46. {
  47. REGISTER_INTERFACE2(ZCABProvider, this);
  48. REGISTER_INTERFACE2(ECUnknown, this);
  49. REGISTER_INTERFACE2(IABProvider, &this->m_xABProvider);
  50. REGISTER_INTERFACE2(IUnknown, &this->m_xABProvider);
  51. return MAPI_E_INTERFACE_NOT_SUPPORTED;
  52. }
  53. HRESULT ZCABProvider::Shutdown(ULONG * lpulFlags)
  54. {
  55. *lpulFlags = 0;
  56. return hrSuccess;
  57. }
  58. HRESULT ZCABProvider::Logon(LPMAPISUP lpMAPISup, ULONG ulUIParam, LPTSTR lpszProfileName, ULONG ulFlags, ULONG * lpulcbSecurity, LPBYTE * lppbSecurity, LPMAPIERROR * lppMAPIError, LPABLOGON * lppABLogon)
  59. {
  60. HRESULT hr = hrSuccess;
  61. object_ptr<ZCABLogon> lpABLogon;
  62. if (lpMAPISup == nullptr || lppABLogon == nullptr)
  63. return MAPI_E_INVALID_PARAMETER;
  64. // todo: remove flags & guid .. probably add other stuff from profile?
  65. hr = ZCABLogon::Create(lpMAPISup, 0, nullptr, &~lpABLogon);
  66. if(hr != hrSuccess)
  67. return hr;
  68. AddChild(lpABLogon);
  69. hr = lpABLogon->QueryInterface(IID_IABLogon, (void **)lppABLogon);
  70. if(hr != hrSuccess)
  71. return hr;
  72. if (lpulcbSecurity)
  73. *lpulcbSecurity = 0;
  74. if (lppbSecurity)
  75. *lppbSecurity = NULL;
  76. if (lppMAPIError)
  77. *lppMAPIError = NULL;
  78. return hrSuccess;
  79. }
  80. DEF_ULONGMETHOD1(TRACE_MAPI, ZCABProvider, ABProvider, AddRef, (void))
  81. DEF_ULONGMETHOD1(TRACE_MAPI, ZCABProvider, ABProvider, Release, (void))
  82. DEF_HRMETHOD1(TRACE_MAPI, ZCABProvider, ABProvider, QueryInterface, (REFIID, refiid), (void **, lppInterface))
  83. DEF_HRMETHOD1(TRACE_MAPI, ZCABProvider, ABProvider, Shutdown, (ULONG *, lpulFlags))
  84. DEF_HRMETHOD1(TRACE_MAPI, ZCABProvider, ABProvider, Logon, (LPMAPISUP, lpMAPISup), (ULONG, ulUIParam), (LPTSTR, lpszProfileName), (ULONG, ulFlags), (ULONG *, lpulcbSecurity), (LPBYTE *, lppbSecurity), (LPMAPIERROR *, lppMAPIError), (LPABLOGON *, lppABLogon))