/thirdparty/liblastfm2/src/ws/win/ComSetup.h

http://github.com/tomahawk-player/tomahawk · C Header · 64 lines · 28 code · 6 blank · 30 comment · 2 complexity · 274973bd9e3c2a3f4a3022541c3a738f MD5 · raw file

  1. /*
  2. Copyright 2009 Last.fm Ltd.
  3. - Primarily authored by Max Howell, Jono Cole and Doug Mansell
  4. This file is part of liblastfm.
  5. liblastfm is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. liblastfm is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with liblastfm. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef _WIN32_WINNT
  17. // bring in CoInitializeSecurity from objbase.h
  18. #define _WIN32_WINNT 0x0400
  19. #endif
  20. #include <objbase.h>
  21. #include "winable.h"
  22. //#include <atlbase.h>
  23. //#include <atlcom.h>
  24. /** @brief WsConnectionMonitor needs Com to work as early as possible so we do this
  25. * @author <doug@last.fm>
  26. */
  27. class ComSetup
  28. {
  29. public:
  30. ComSetup()
  31. {
  32. HRESULT hr = CoInitialize(0);
  33. m_bComInitialised = SUCCEEDED(hr);
  34. //_ASSERT(m_bComInitialised);
  35. if (m_bComInitialised) {
  36. setupSecurity();
  37. }
  38. }
  39. void setupSecurity()
  40. {
  41. //CSecurityDescriptor sd;
  42. //sd.InitializeFromThreadToken();
  43. //HRESULT hr = CoInitializeSecurity(sd, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_PKT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
  44. //_ASSERT(SUCCEEDED(hr));
  45. }
  46. ~ComSetup()
  47. {
  48. if (m_bComInitialised) {
  49. CoUninitialize();
  50. }
  51. }
  52. private:
  53. bool m_bComInitialised;
  54. };