PageRenderTime 18ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/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
20#ifndef DBSYNCCONNECTION_H
21#define DBSYNCCONNECTION_H
22
23#include "network/Connection.h"
24#include "network/DBSyncConnectionState.h"
25#include "database/Op.h"
26#include "Typedefs.h"
27
28#include <QObject>
29#include <QTimer>
30#include <QSharedPointer>
31#include <QIODevice>
32
33
34
35class DatabaseCommand;
36
37class DBSyncConnection : public Connection
38{
39Q_OBJECT
40
41public:
42    explicit DBSyncConnection( Servent* s, const Tomahawk::source_ptr& src );
43    virtual ~DBSyncConnection();
44
45    void setup() override;
46    Connection* clone() override;
47
48signals:
49    void stateChanged( Tomahawk::DBSyncConnectionState newstate, Tomahawk::DBSyncConnectionState oldstate, const QString& info );
50
51protected slots:
52    void handleMsg( msg_ptr msg ) Q_DECL_OVERRIDE;
53
54public slots:
55    void sendOps();
56    /// trigger a re-sync to pick up any new ops
57    void trigger();
58
59private slots:
60    void gotThem( const QVariantMap& m );
61
62    void fetchOpsData( const QString& sinceguid );
63    void sendOpsData( QString sinceguid, QString lastguid, QList< dbop_ptr > ops );
64    void lastOpApplied();
65
66    void check();
67
68private:
69    void synced();
70    void changeState( Tomahawk::DBSyncConnectionState newstate );
71
72    int m_fetchCount;
73    Tomahawk::source_ptr m_source;
74    QVariantMap m_uscache;
75
76    QString m_lastSentOp;
77
78    Tomahawk::DBSyncConnectionState m_state;
79};
80
81#endif // DBSYNCCONNECTION_H