/src/libtomahawk/network/DbSyncConnection.h

http://github.com/tomahawk-player/tomahawk · C Header · 81 lines · 42 code · 20 blank · 19 comment · 0 complexity · 6287090494abc527df06993e83e5dcfa 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 2013, Uwe L. Korn <uwelk@xhochy.com>
  5. *
  6. * Tomahawk is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Tomahawk is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef DBSYNCCONNECTION_H
  20. #define DBSYNCCONNECTION_H
  21. #include "network/Connection.h"
  22. #include "network/DBSyncConnectionState.h"
  23. #include "database/Op.h"
  24. #include "Typedefs.h"
  25. #include <QObject>
  26. #include <QTimer>
  27. #include <QSharedPointer>
  28. #include <QIODevice>
  29. class DatabaseCommand;
  30. class DBSyncConnection : public Connection
  31. {
  32. Q_OBJECT
  33. public:
  34. explicit DBSyncConnection( Servent* s, const Tomahawk::source_ptr& src );
  35. virtual ~DBSyncConnection();
  36. void setup() override;
  37. Connection* clone() override;
  38. signals:
  39. void stateChanged( Tomahawk::DBSyncConnectionState newstate, Tomahawk::DBSyncConnectionState oldstate, const QString& info );
  40. protected slots:
  41. void handleMsg( msg_ptr msg ) Q_DECL_OVERRIDE;
  42. public slots:
  43. void sendOps();
  44. /// trigger a re-sync to pick up any new ops
  45. void trigger();
  46. private slots:
  47. void gotThem( const QVariantMap& m );
  48. void fetchOpsData( const QString& sinceguid );
  49. void sendOpsData( QString sinceguid, QString lastguid, QList< dbop_ptr > ops );
  50. void lastOpApplied();
  51. void check();
  52. private:
  53. void synced();
  54. void changeState( Tomahawk::DBSyncConnectionState newstate );
  55. int m_fetchCount;
  56. Tomahawk::source_ptr m_source;
  57. QVariantMap m_uscache;
  58. QString m_lastSentOp;
  59. Tomahawk::DBSyncConnectionState m_state;
  60. };
  61. #endif // DBSYNCCONNECTION_H