swift
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 
13 #include "core/swiftcoreexport.h"
14 #include "misc/network/url.h"
17 #include "misc/statusmessagelist.h"
18 
19 class QNetworkReply;
20 
21 namespace swift::misc::simulation
22 {
23  class CAutoPublishData;
24 }
25 namespace swift::core::db
26 {
28  class SWIFT_CORE_EXPORT CDatabaseWriter : public QObject
29  {
30  Q_OBJECT
31 
32  public:
34  CDatabaseWriter(const swift::misc::network::CUrl &baseUrl, QObject *parent);
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
Write to the swift DB.
const swift::misc::network::CUrlLogList & getWriteLog() const
Write log.
bool isShuttingDown() const
Shutting down?
void publishedModelsSimplified(const swift::misc::simulation::CAircraftModelList &modelsPublished, bool directWrite)
Published models, simplified version of publishedModels.
void autoPublished(bool success, const QString &url, const swift::misc::CStatusMessageList &msgs)
Auto publishing completed.
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)
Definition: aircraftmodel.h:71
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.
Classes interacting with the swift database (aka "datastore").
#define SWIFT_CORE_EXPORT
Export a class or function from the library.