Debian Codegraph @

src/win/WNetworkConnectionMonitor_win.cpp

raw symbols SCIP
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 #include "moc_WNetworkConnectionMonitor.cpp"
23
24 // WsAccessManager needs special init (on Windows), and it needs to be done
25 // early, so be careful about moving this
26 #include "../win/ComSetup.h" //must be first header or compile fail results!
27 #include "../win/NdisEvents.h"
28 static ComSetup com_setup;
29
30 namespace lastfm {
31
32 // bounce NdisEvents signals through here so we don't have to expose the
33 // NdisEvents interface in InternetConnectionMonitor :)
34 class NdisEventsProxy : public NdisEvents
35 {
36 public:
37 NdisEventsProxy(WNetworkConnectionMonitor* icm)
38 :m_icm(icm)
39 {
40 }
41
42 // WmiSink callbacks:
43 void onConnectionUp( BSTR /*name*/ )
44 {
45 m_icm->setConnected( true );
46 }
47
48 void onConnectionDown( BSTR /*name*/ )
49 {
50 m_icm->setConnected( false );
51 }
52
53 WNetworkConnectionMonitor* m_icm;
54 };
55
56
57 WNetworkConnectionMonitor::WNetworkConnectionMonitor( QObject* parent ) :
58 NetworkConnectionMonitor( parent )
59 {
60 m_ndisEventsProxy = new lastfm::NdisEventsProxy( this );
61 m_ndisEventsProxy->registerForNdisEvents();
62 }
63
64 WNetworkConnectionMonitor::~WNetworkConnectionMonitor()
65 {
66 delete m_ndisEventsProxy;
67 }
68
69 }