PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 4ms RepoModel.GetById 36ms app.codeStats 0ms

/src/libtomahawk/network/ControlConnection.h

http://github.com/tomahawk-player/tomahawk
C Header | 81 lines | 37 code | 15 blank | 29 comment | 0 complexity | 6c097a4db063ada928c8a5d02e760d4d MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *   Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
 5 *   Copyright 2013,      Uwe L. Korn <uwelk@xhochy.com>
 6 *
 7 *   Tomahawk 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 *   Tomahawk 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 Tomahawk. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21/*
22    One ControlConnection always remains open to each peer.
23
24    They arrange connections/reverse connections, inform us
25    when the peer goes offline, and own+setup DBSyncConnections.
26
27*/
28#ifndef CONTROLCONNECTION_H
29#define CONTROLCONNECTION_H
30
31#include "Connection.h"
32#include "DllMacro.h"
33#include "Typedefs.h"
34
35class ControlConnectionPrivate;
36class DBSyncConnection;
37class Servent;
38
39class DLLEXPORT ControlConnection : public Connection
40{
41Q_OBJECT
42
43public:
44    ControlConnection( Servent* parent );
45    ~ControlConnection();
46    Connection* clone();
47
48    DBSyncConnection* dbSyncConnection();
49
50    Tomahawk::source_ptr source() const;
51
52    /**
53     * Tell this ControlConnection that is no longer controlling the source and should not do any actions on it.
54     */
55    void unbindFromSource();
56
57    void addPeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
58    void removePeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
59    void setShutdownOnEmptyPeerInfos( bool shutdownOnEmptyPeerInfos );
60    const QSet< Tomahawk::peerinfo_ptr > peerInfos() const;
61
62protected:
63    virtual void setup();
64
65protected slots:
66    virtual void handleMsg( msg_ptr msg );
67    virtual void authCheckTimeout();
68
69private slots:
70    void dbSyncConnFinished( QObject* c );
71    void registerSource();
72    void onPingTimer();
73
74private:
75    Q_DECLARE_PRIVATE( ControlConnection )
76    ControlConnectionPrivate* d_ptr;
77
78    void setupDbSyncConnection( bool ondemand = false );
79};
80
81#endif // CONTROLCONNECTION_H