/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. One ControlConnection always remains open to each peer.
  22. They arrange connections/reverse connections, inform us
  23. when the peer goes offline, and own+setup DBSyncConnections.
  24. */
  25. #ifndef CONTROLCONNECTION_H
  26. #define CONTROLCONNECTION_H
  27. #include "Connection.h"
  28. #include "DllMacro.h"
  29. #include "Typedefs.h"
  30. class ControlConnectionPrivate;
  31. class DBSyncConnection;
  32. class Servent;
  33. class DLLEXPORT ControlConnection : public Connection
  34. {
  35. Q_OBJECT
  36. public:
  37. ControlConnection( Servent* parent );
  38. ~ControlConnection();
  39. Connection* clone();
  40. DBSyncConnection* dbSyncConnection();
  41. Tomahawk::source_ptr source() const;
  42. /**
  43. * Tell this ControlConnection that is no longer controlling the source and should not do any actions on it.
  44. */
  45. void unbindFromSource();
  46. void addPeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
  47. void removePeerInfo( const Tomahawk::peerinfo_ptr& peerInfo );
  48. void setShutdownOnEmptyPeerInfos( bool shutdownOnEmptyPeerInfos );
  49. const QSet< Tomahawk::peerinfo_ptr > peerInfos() const;
  50. protected:
  51. virtual void setup();
  52. protected slots:
  53. virtual void handleMsg( msg_ptr msg );
  54. virtual void authCheckTimeout();
  55. private slots:
  56. void dbSyncConnFinished( QObject* c );
  57. void registerSource();
  58. void onPingTimer();
  59. private:
  60. Q_DECLARE_PRIVATE( ControlConnection )
  61. ControlConnectionPrivate* d_ptr;
  62. void setupDbSyncConnection( bool ondemand = false );
  63. };
  64. #endif // CONTROLCONNECTION_H