1// SPDX-FileCopyrightText: 2015 Felix Rohrbach <kde@fxrh.de>
2// SPDX-FileCopyrightText: 2016 Kitsune Ral <Kitsune-Ral@users.sf.net>
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#pragma once
6
7#include "util.h"
8
9#include <QtCore/QUrl>
10
11#include <chrono>
12
13namespace Quotient {
14
15class NetworkAccessManager;
16class BaseJob;
17
18class ConnectionData {
19public:
20 explicit ConnectionData(QUrl baseUrl);
21 Q_DISABLE_COPY_MOVE(ConnectionData)
22 virtual ~ConnectionData();
23
24 void submit(BaseJob* job);
25 void limitRate(std::chrono::milliseconds nextCallAfter);
26
27 QByteArray accessToken() const;
28 QUrl baseUrl() const;
29 const QString& deviceId() const;
30 const QString& userId() const;
31 bool needsToken(const QString& requestName) const;
32 Quotient::NetworkAccessManager *nam() const;
33
34 void setBaseUrl(QUrl baseUrl);
35 void setToken(QByteArray accessToken);
36 void setDeviceId(const QString& deviceId);
37 void setUserId(const QString& userId);
38 void setNeedsToken(const QString& requestName);
39
40 QString lastEvent() const;
41 void setLastEvent(QString identifier);
42
43 QString generateTxnId() const;
44
45private:
46 class Private;
47 ImplPtr<Private> d;
48};
49} // namespace Quotient
50