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

http://github.com/tomahawk-player/tomahawk · C++ · 67 lines · 33 code · 10 blank · 24 comment · 0 complexity · ef34434287d10b9a9674e896390f3fc4 MD5 · raw file

  1. /*
  2. Copyright 2010 Last.fm Ltd.
  3. - Primarily authored by Jono Cole, Michael Coffey, and William Viana
  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 "WNetworkConnectionMonitor.h"
  17. // WsAccessManager needs special init (on Windows), and it needs to be done
  18. // early, so be careful about moving this
  19. #include "../win/ComSetup.h" //must be first header or compile fail results!
  20. #include "../win/NdisEvents.h"
  21. static ComSetup com_setup;
  22. namespace lastfm {
  23. // bounce NdisEvents signals through here so we don't have to expose the
  24. // NdisEvents interface in InternetConnectionMonitor :)
  25. class NdisEventsProxy : public NdisEvents
  26. {
  27. public:
  28. NdisEventsProxy(WNetworkConnectionMonitor* icm)
  29. :m_icm(icm)
  30. {
  31. }
  32. // WmiSink callbacks:
  33. void onConnectionUp( BSTR /*name*/ )
  34. {
  35. m_icm->setConnected( true );
  36. }
  37. void onConnectionDown( BSTR /*name*/ )
  38. {
  39. m_icm->setConnected( false );
  40. }
  41. WNetworkConnectionMonitor* m_icm;
  42. };
  43. }
  44. WNetworkConnectionMonitor::WNetworkConnectionMonitor( QObject* parent ) :
  45. NetworkConnectionMonitor( parent )
  46. {
  47. m_ndisEventsProxy = new lastfm::NdisEventsProxy( this );
  48. m_ndisEventsProxy->registerForNdisEvents();
  49. }
  50. WNetworkConnectionMonitor::~WNetworkConnectionMonitor()
  51. {
  52. delete m_ndisEventsProxy;
  53. }