LibrePCB Developers Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
apiendpoint.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_APIENDPOINT_H
21#define LIBREPCB_CORE_APIENDPOINT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../types/uuid.h"
27#include "../types/version.h"
28
29#include <QtCore>
30
31/*******************************************************************************
32 * Namespace / Forward Declarations
33 ******************************************************************************/
34namespace librepcb {
35
36/*******************************************************************************
37 * Class ApiEndpoint
38 ******************************************************************************/
39
45class ApiEndpoint final : public QObject {
46 Q_OBJECT
47
48public:
49 // Types
50 struct Part {
51 QString mpn;
52 QString manufacturer;
53 };
54 struct Library {
56 QString name;
57 QString description;
58 QString author;
61 QSet<Uuid> dependencies;
62 QUrl iconUrl;
65 QByteArray downloadSha256;
66 };
67
68 // Constructors / Destructor
69 ApiEndpoint() = delete;
70 ApiEndpoint(const ApiEndpoint& other) = delete;
71 explicit ApiEndpoint(const QUrl& url) noexcept;
72 ~ApiEndpoint() noexcept;
73
74 // Getters
75 const QUrl& getUrl() const noexcept { return mUrl; }
76
77 // General Methods
78 void requestLibraryList() const noexcept;
79 void requestPartsInformationStatus() const noexcept;
80 void requestPartsInformation(const QUrl& url,
81 const QVector<Part>& parts) const noexcept;
82
83 // Operators
84 ApiEndpoint& operator=(const ApiEndpoint& rhs) = delete;
85
86signals:
87 void libraryListReceived(QList<Library> libs);
88 void errorWhileFetchingLibraryList(const QString& errorMsg);
89 void errorWhileFetchingPartsInformationStatus(const QString& errorMsg);
90 void partsInformationStatusReceived(const QJsonObject& status);
91 void partsInformationReceived(const QJsonObject& info);
92 void errorWhileFetchingPartsInformation(const QString& errorMsg);
93
94private: // Methods
95 void requestLibraryList(const QUrl& url) const noexcept;
96 void libraryListResponseReceived(const QByteArray& data) noexcept;
97 void partsInformationStatusResponseReceived(const QByteArray& data) noexcept;
98 void partsInformationResponseReceived(const QByteArray& data) noexcept;
99
100private: // Data
101 QUrl mUrl;
102};
103
104/*******************************************************************************
105 * End of File
106 ******************************************************************************/
107
108} // namespace librepcb
109
110#endif
Access to a LibrePCB API endpoint.
Definition apiendpoint.h:45
QUrl mUrl
Definition apiendpoint.h:101
void requestLibraryList() const noexcept
Definition apiendpoint.cpp:51
ApiEndpoint(const ApiEndpoint &other)=delete
void errorWhileFetchingPartsInformationStatus(const QString &errorMsg)
void partsInformationResponseReceived(const QByteArray &data) noexcept
Definition apiendpoint.cpp:195
void errorWhileFetchingPartsInformation(const QString &errorMsg)
void libraryListReceived(QList< Library > libs)
void libraryListResponseReceived(const QByteArray &data) noexcept
Definition apiendpoint.cpp:115
void partsInformationStatusResponseReceived(const QByteArray &data) noexcept
Definition apiendpoint.cpp:184
~ApiEndpoint() noexcept
Definition apiendpoint.cpp:44
void requestPartsInformationStatus() const noexcept
Definition apiendpoint.cpp:57
void requestPartsInformation(const QUrl &url, const QVector< Part > &parts) const noexcept
Definition apiendpoint.cpp:71
const QUrl & getUrl() const noexcept
Definition apiendpoint.h:75
void partsInformationReceived(const QJsonObject &info)
void errorWhileFetchingLibraryList(const QString &errorMsg)
void partsInformationStatusReceived(const QJsonObject &status)
The Part class.
Definition part.h:46
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The Version class represents a version number in the format "1.42.7".
Definition version.h:58
Definition occmodel.cpp:77
Definition apiendpoint.h:54
QString author
Definition apiendpoint.h:58
QUrl iconUrl
Definition apiendpoint.h:62
bool recommended
Definition apiendpoint.h:60
Uuid uuid
Definition apiendpoint.h:55
QUrl downloadUrl
Definition apiendpoint.h:63
QByteArray downloadSha256
Definition apiendpoint.h:65
QSet< Uuid > dependencies
Definition apiendpoint.h:61
QString description
Definition apiendpoint.h:57
qint64 downloadSize
Definition apiendpoint.h:64
QString name
Definition apiendpoint.h:56
Version version
Definition apiendpoint.h:59
Definition apiendpoint.h:50
QString mpn
Definition apiendpoint.h:51
QString manufacturer
Definition apiendpoint.h:52