LibrePCB Developers Documentation
Loading...
Searching...
No Matches
orderpcbapirequest.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program 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 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_CORE_ORDERPCBAPIREQUEST_H
21#define LIBREPCB_CORE_ORDERPCBAPIREQUEST_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include <QtCore>
27
28/*******************************************************************************
29 * Namespace / Forward Declarations
30 ******************************************************************************/
31namespace librepcb {
32
33/*******************************************************************************
34 * Class OrderPcbApiRequest
35 ******************************************************************************/
36
42class OrderPcbApiRequest final : public QObject {
43 Q_OBJECT
44
45public:
46 // Constructors / Destructor
48 OrderPcbApiRequest(const OrderPcbApiRequest& other) = delete;
49
56 explicit OrderPcbApiRequest(const QUrl& apiServerUrl,
57 QObject* parent = nullptr) noexcept;
58
62 ~OrderPcbApiRequest() noexcept;
63
64 // Getters
65
72 bool isReadyForUpload() const noexcept { return mUploadUrl.isValid(); }
73
79 const QUrl& getReceivedInfoUrl() const noexcept { return mInfoUrl; }
80
86 const QUrl& getReceivedUploadUrl() const noexcept { return mUploadUrl; }
87
93 int getReceivedMaxFileSize() const noexcept { return mMaxFileSize; }
94
95 // General Methods
96
103 void startInfoRequest() noexcept;
104
116 void startUpload(const QByteArray& lppz,
117 const QString& boardPath) const noexcept;
118
119 // Operators
120 OrderPcbApiRequest& operator=(const OrderPcbApiRequest& rhs) = delete;
121
122signals:
129 void infoRequestSucceeded(QUrl infoUrl, int maxFileSize) const;
130
136 void infoRequestFailed(QString errorMsg) const;
137
143 void uploadProgressState(QString state) const;
144
150 void uploadProgressPercent(int percent) const;
151
157 void uploadSucceeded(QUrl redirectUrl) const;
158
164 void uploadFailed(QString errorMsg) const;
165
166private: // Methods
167 void infoRequestResponseReceived(const QByteArray& data) noexcept;
168 void uploadResponseReceived(const QByteArray& data) const noexcept;
169
170private: // Data
172
173 // Data received from the info request
177};
178
179/*******************************************************************************
180 * End of File
181 ******************************************************************************/
182
183} // namespace librepcb
184
185#endif
Order a PCB via a LibrePCB API server.
Definition orderpcbapirequest.h:42
void uploadSucceeded(QUrl redirectUrl) const
Upload succeeded.
void startUpload(const QByteArray &lppz, const QString &boardPath) const noexcept
Upload the project.
Definition orderpcbapirequest.cpp:69
const QUrl & getReceivedInfoUrl() const noexcept
Get received URL to service information.
Definition orderpcbapirequest.h:79
void uploadProgressState(QString state) const
Upload progress state changed.
void uploadFailed(QString errorMsg) const
Information request failed.
void infoRequestSucceeded(QUrl infoUrl, int maxFileSize) const
Information request succeeded.
void uploadResponseReceived(const QByteArray &data) const noexcept
Definition orderpcbapirequest.cpp:142
const QUrl & getReceivedUploadUrl() const noexcept
Get received URL where to upload the project.
Definition orderpcbapirequest.h:86
bool isReadyForUpload() const noexcept
Check if the information for upload was successfully received.
Definition orderpcbapirequest.h:72
QUrl mUploadUrl
Definition orderpcbapirequest.h:175
int mMaxFileSize
Definition orderpcbapirequest.h:176
void infoRequestResponseReceived(const QByteArray &data) noexcept
Definition orderpcbapirequest.cpp:119
QUrl mInfoUrl
Definition orderpcbapirequest.h:174
void uploadProgressPercent(int percent) const
Upload progress in percent changed.
int getReceivedMaxFileSize() const noexcept
Get maximum allowed project file size to upload.
Definition orderpcbapirequest.h:93
void startInfoRequest() noexcept
Request the upload information from the API server.
Definition orderpcbapirequest.cpp:54
OrderPcbApiRequest(const OrderPcbApiRequest &other)=delete
QUrl mApiServerUrl
Definition orderpcbapirequest.h:171
void infoRequestFailed(QString errorMsg) const
Information request failed.
Definition occmodel.cpp:76