PageRenderTime 25ms CodeModel.GetById 14ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 1ms

/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
 5   This file is part of liblastfm.
 6
 7   liblastfm is free software: you can redistribute it and/or modify
 8   it under the terms of the GNU General Public License as published by
 9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   liblastfm is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with liblastfm.  If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#include "WNetworkConnectionMonitor.h"
22
23// WsAccessManager needs special init (on Windows), and it needs to be done
24// early, so be careful about moving this
25#include "../win/ComSetup.h" //must be first header or compile fail results!
26#include "../win/NdisEvents.h"
27static ComSetup com_setup;
28
29namespace lastfm {
30
31// bounce NdisEvents signals through here so we don't have to expose the
32// NdisEvents interface in InternetConnectionMonitor  :)
33class NdisEventsProxy : public NdisEvents
34{
35public:
36    NdisEventsProxy(WNetworkConnectionMonitor* icm)
37        :m_icm(icm)
38    {
39    }
40
41    // WmiSink callbacks:
42    void onConnectionUp( BSTR /*name*/ )
43    {
44        m_icm->setConnected( true );
45    }
46
47    void onConnectionDown( BSTR /*name*/ )
48    {
49        m_icm->setConnected( false );
50    }
51
52    WNetworkConnectionMonitor* m_icm;
53};
54
55}
56
57WNetworkConnectionMonitor::WNetworkConnectionMonitor( QObject* parent ) :
58    NetworkConnectionMonitor( parent )
59{
60    m_ndisEventsProxy = new lastfm::NdisEventsProxy( this );
61    m_ndisEventsProxy->registerForNdisEvents();
62}
63
64WNetworkConnectionMonitor::~WNetworkConnectionMonitor()
65{
66    delete m_ndisEventsProxy;
67}