/thirdparty/liblastfm2/src/ws/win/NdisEvents.cpp

http://github.com/tomahawk-player/tomahawk · C++ · 87 lines · 19 code · 12 blank · 56 comment · 2 complexity · c494fe2675cafdf395fc6571c41d3adc 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. #include "NdisEvents.h"
  17. #include "WmiSink.h"
  18. // see http://msdn.microsoft.com/en-us/magazine/cc301850.aspx for
  19. // more about Ndis and wmi and getting these events
  20. // Link to wbemuuid.lib to resolve IWbemObjectSink and IWbemClassObject
  21. // interface definitions.
  22. NdisEvents::NdisEvents()
  23. : m_pSink(0)
  24. {}
  25. NdisEvents::~NdisEvents()
  26. {
  27. // if (m_pSink)
  28. // m_pSink->disconnect();
  29. // if (m_pServices && m_pSink)
  30. // m_pServices->CancelAsyncCall(m_pSink);
  31. // and reference counting will take care of the WmiSink object
  32. }
  33. HRESULT
  34. NdisEvents::registerForNdisEvents()
  35. {
  36. HRESULT hr = 0; // m_pLocator.CoCreateInstance(CLSID_WbemLocator);
  37. if (FAILED(hr))
  38. return hr;
  39. // Connect to the root\wmi namespace with the current user.
  40. hr = 0; /*m_pLocator->ConnectServer(CComBSTR("ROOT\\WMI"), // strNetworkResource
  41. NULL, // strUser
  42. NULL, // strPassword
  43. NULL, // strLocale
  44. 0, // lSecurityFlags
  45. CComBSTR(""), // strAuthority
  46. NULL, // pCtx
  47. &m_pServices
  48. );*/
  49. if (FAILED(hr))
  50. return hr;
  51. // m_pSink = new WmiSink(this);
  52. //////////////////////////
  53. // other notifications we're not interested in right now include...
  54. // MSNdis_NotifyAdapterArrival \DEVICE\<guid>
  55. // MSNdis_NotifyAdapterRemoval
  56. // MSNdis_StatusLinkSpeedChange
  57. // MSNdis_NotifyVcArrival
  58. // MSNdis_NotifyVcRemoval
  59. // MSNdis_StatusResetStart
  60. // MSNdis_StatusResetEnd
  61. // MSNdis_StatusProtocolBind
  62. // MSNdis_StatusProtocolUnbind
  63. // MSNdis_StatusMediaSpecificIndication
  64. /* CComBSTR wql("WQL");
  65. CComBSTR query("SELECT * FROM MSNdis_StatusMediaDisconnect");
  66. hr = m_pServices->ExecNotificationQueryAsync(wql, query, 0, 0, m_pSink);
  67. query = "SELECT * FROM MSNdis_StatusMediaConnect";
  68. hr = m_pServices->ExecNotificationQueryAsync(wql, query, 0, 0, m_pSink);*/
  69. return S_OK;
  70. }