swift
Loading...
Searching...
No Matches
databasewriter.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
6#ifndef SWIFT_CORE_DATABASE_WRITER_H
7#define SWIFT_CORE_DATABASE_WRITER_H
8
9#include <QByteArray>
10#include <QList>
11#include <QObject>
12
14#include "misc/network/url.h"
18
19class QNetworkReply;
20
21namespace swift::misc::simulation
22{
23 class CAutoPublishData;
24}
25namespace swift::core::db
26{
29 {
31
32 public:
35
38 const QString &extraInfo);
39
42 const QString &extraInfo);
43
46
48 void gracefulShutdown();
49
51 bool isShuttingDown() const { return m_shutdown; }
52
54 const QString &getName();
55
57 const swift::misc::network::CUrlLogList &getWriteLog() const { return m_writeLog; }
58
60 static const QStringList &getLogCategories();
61
62 signals:
66 const swift::misc::CStatusMessageList &messages, bool sendingSuccessful, bool directWrite);
67
70 bool directWrite);
71
73 void autoPublished(bool success, const QString &url, const swift::misc::CStatusMessageList &msgs);
74
75 private:
77 swift::misc::network::CUrl m_modelPublishUrl;
78 swift::misc::network::CUrl m_autoPublishUrl;
79 QNetworkReply *m_pendingModelPublishReply = nullptr;
80 QNetworkReply *m_pendingAutoPublishReply = nullptr;
81 qint64 m_modelReplyPendingSince = -1;
82 qint64 m_autoPublishReplyPendingSince = -1;
83 bool m_shutdown = false;
84
86 void postedModelsResponse(QNetworkReply *nwReplyPtr);
87
89 void postedAutoPublishResponse(QNetworkReply *nwReplyPtr);
90
92 bool killPendingModelReply();
93
95 bool isModelReplyOverdue() const;
96
98 static swift::misc::network::CUrl getModelPublishUrl(const swift::misc::network::CUrl &baseUrl);
99
101 static swift::misc::network::CUrl getAutoPublishUrl(const swift::misc::network::CUrl &baseUrl);
102
104 static QList<QByteArray> splitData(const QByteArray &data, int size);
105
107 static bool parseSwiftPublishResponse(const QString &jsonResponse,
110 swift::misc::CStatusMessageList &messages, bool &directWrite);
111 };
112} // namespace swift::core::db
113
114#endif // SWIFT_CORE_DATABASE_WRITER_H
swift::misc::CStatusMessageList asyncPublishModel(const swift::misc::simulation::CAircraftModel &model, const QString &extraInfo)
Write model to DB.
swift::misc::CStatusMessageList asyncPublishModels(const swift::misc::simulation::CAircraftModelList &models, const QString &extraInfo)
Write models to DB.
swift::misc::CStatusMessageList asyncAutoPublish(const swift::misc::simulation::CAutoPublishData &data)
Write auto publis data.
bool isShuttingDown() const
Shutting down?
void publishedModelsSimplified(const swift::misc::simulation::CAircraftModelList &modelsPublished, bool directWrite)
Published models, simplified version of publishedModels.
const swift::misc::network::CUrlLogList & getWriteLog() const
Write log.
void autoPublished(bool success, const QString &url, const swift::misc::CStatusMessageList &msgs)
Auto publishing completed.
CDatabaseWriter(const swift::misc::network::CUrl &baseUrl, QObject *parent)
Constructor.
void publishedModels(const swift::misc::simulation::CAircraftModelList &modelsPublished, const swift::misc::simulation::CAircraftModelList &modelsSkipped, const swift::misc::CStatusMessageList &messages, bool sendingSuccessful, bool directWrite)
Published models, the response to.
Status messages, e.g. from Core -> GUI.
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
Definition url.h:27
Value object encapsulating a list of voice rooms.
Definition urlloglist.h:26
Aircraft model (used by another pilot, my models on disk).
Value object encapsulating a list of aircraft models.
Objects that can be use for auto-publishing. Auto publishing means we sent those data to the DB.
Core data traits (aka cached values) and classes.
Classes interacting with the swift database (aka "datastore").
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const
#define SWIFT_CORE_EXPORT
Export a class or function from the library.