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
100 const QUrl& getReceivedRedirectUrl() const noexcept { return mRedirectUrl; }
101
102 // General Methods
103
110 void startInfoRequest() noexcept;
111
123 void startUpload(const QByteArray& lppz, const QString& boardPath) noexcept;
124
125 // Operators
126 OrderPcbApiRequest& operator=(const OrderPcbApiRequest& rhs) = delete;
127
128signals:
135 void infoRequestSucceeded(QUrl infoUrl, int maxFileSize) const;
136
142 void infoRequestFailed(QString errorMsg) const;
143
149 void uploadProgressState(QString state) const;
150
156 void uploadProgressPercent(int percent) const;
157
163 void uploadSucceeded(QUrl redirectUrl) const;
164
170 void uploadFailed(QString errorMsg) const;
171
172private: // Methods
173 void infoRequestResponseReceived(const QByteArray& data) noexcept;
174 void uploadResponseReceived(const QByteArray& data) noexcept;
175
176private: // Data
178
179 // Data received from the info request
183
184 // Data received from the upload request
186};
187
188/*******************************************************************************
189 * End of File
190 ******************************************************************************/
191
192} // namespace librepcb
193
194#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) noexcept
Upload the project.
Definition orderpcbapirequest.cpp:70
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.
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:181
int mMaxFileSize
Definition orderpcbapirequest.h:182
void infoRequestResponseReceived(const QByteArray &data) noexcept
Definition orderpcbapirequest.cpp:123
QUrl mInfoUrl
Definition orderpcbapirequest.h:180
void uploadProgressPercent(int percent) const
Upload progress in percent changed.
const QUrl & getReceivedRedirectUrl() const noexcept
Get received URL where to continue the order process.
Definition orderpcbapirequest.h:100
QUrl mRedirectUrl
Definition orderpcbapirequest.h:185
int getReceivedMaxFileSize() const noexcept
Get maximum allowed project file size to upload.
Definition orderpcbapirequest.h:93
void uploadResponseReceived(const QByteArray &data) noexcept
Definition orderpcbapirequest.cpp:146
void startInfoRequest() noexcept
Request the upload information from the API server.
Definition orderpcbapirequest.cpp:55
OrderPcbApiRequest(const OrderPcbApiRequest &other)=delete
QUrl mApiServerUrl
Definition orderpcbapirequest.h:177
void infoRequestFailed(QString errorMsg) const
Information request failed.
Definition occmodel.cpp:77