|
libfuoten 0.8.2
Qt based library to access the Nextcloud News App API.
|
Requests the server status from status.php. More...
#include <Fuoten/API/GetServerStatus>
Public Types | |
| enum | SetupPossible { NotPossible = 0 , Manual = 1 , LoginFlow = 2 , LoginFlowV2 = 3 } |
| This enum describes the setup possibility. More... | |
| Public Types inherited from Fuoten::Component | |
| enum | ExpectedJSONType : quint8 { Empty = 0 , Array = 1 , Object = 2 } |
| Defines the expected JSON type. More... | |
Properties | |
| QString | edition |
| This property holds the edition of the Nextcloud. | |
| bool | hasExtendedSupport |
Returns true when the Nextcloud has extended support, otherwise false. | |
| bool | isInMaintenance |
Returns true when the Nextcloud is in maintenance mode, otherwise false. | |
| bool | isInstalled |
Returns true when the Nextcloud is completely installed, otherwise false. | |
| bool | needsDbUpgrade |
Returns true when the Nextcloud needs a database upgrade, otherwise false. | |
| QString | productname |
| This property holds the product name of the Nextcloud. | |
| Fuoten::GetServerStatus::SetupPossible | setupPossible |
| This property describes the possibility of setting up an account for the Nextcloud. | |
| QString | versionString |
| This property holds the version of the Nextcloud as string. | |
| Properties inherited from Fuoten::Component | |
| Fuoten::AbstractConfiguration * | configuration |
| Pointer to an AbstractConfiguration derived object. | |
| Fuoten::Error * | error |
| Pointer to an error object, if any error occurred. | |
| bool | inOperation |
| Returns true while the request is in operation. | |
| Fuoten::AbstractNotificator * | notificator |
| Pointer to an object derived from AbstractNotificator. | |
| quint16 | requestTimeout |
| Timeout in seconds for network requests. | |
| Fuoten::AbstractStorage * | storage |
| Pointer to an AbstractStorage derived object. | |
| bool | useStorage |
If true (the default), a local storage should be used in the successCallback() function to further process the request results. | |
| Fuoten::WipeManager * | wipeManager |
| Pointer to a WipeManager to handle remote wipe requests. | |
Public Member Functions | |
| GetServerStatus (QObject *parent=nullptr) | |
| Constructs a new GetServerStatus object with the given parent. | |
| ~GetServerStatus () override | |
| Deconstructs the GetServerStatus object. | |
| Q_INVOKABLE int | compareVersion (const QString &versionString) const |
| Compares versionString with the requested Nextcloud version. | |
| int | compareVersion (const QVersionNumber &version) const |
| Compares version with the requested Nextcloud version. | |
| QString | edition () const |
| Returns the edition of the Nextcloud. | |
| Q_INVOKABLE void | execute () override |
| Executes the API request to get the server status. | |
| bool | hasExtendedSupport () const |
Returns true when the Nextcloud has extended support, otherwise false. | |
| bool | isInMaintenance () const |
Returns true when the Nextcloud is in maintenance mode, otherwise false. | |
| bool | isInstalled () const |
Returns true when the Nextcloud is completely installed, otherwise false. | |
| bool | needsDbUpgrade () const |
Returns true when the Nextcloud needs a database upgrade, otherwise false. | |
| QString | productname () const |
| Returns the product name of the Nextcloud. | |
| Fuoten::GetServerStatus::SetupPossible | setupPossible () const |
| This property describes the possibility of setting up an account for the Nextcloud. | |
| QVersionNumber | version () const |
| Returns the version of the Nextcloud. | |
| QString | versionString () const |
| Returns the version of the Nextcloud as a string. | |
| Public Member Functions inherited from Fuoten::Component | |
| Component (QObject *parent=nullptr) | |
| Constructs a component with the given parent. | |
| ~Component () override | |
| Destroys the Component object. | |
| AbstractConfiguration * | configuration () const |
| Returns a pointer to the AbstractConfiguration that is currently set. | |
| Error * | error () const |
| Returns a pointer to an Error object, if any error occurred. | |
| bool | inOperation () const |
| Returns true while the API request is running. | |
| bool | isUseStorageEnabled () const |
| Getter function for the useStorage property. | |
| AbstractNotificator * | notificator () const |
| Getter function for the notificator property. | |
| quint16 | requestTimeout () const |
| Returns the currently set request timeout. | |
| void | setConfiguration (AbstractConfiguration *nAbstractConfiguration) |
| Sets a pointer to a AbstractConfiguration to use for the API request. | |
| void | setNotificator (AbstractNotificator *notificator) |
| Setter function for the notificator property. | |
| void | setRequestTimeout (quint16 seconds) |
| Sets the timeout for the API request in seconds. | |
| void | setStorage (AbstractStorage *localStorage) |
| Setter function for the storage property. | |
| void | setUseStorage (bool useStorage) |
| Setter function for the useStorage property. | |
| void | setWipeManager (WipeManager *wipeManager) |
| Setter function for the wipeManager property. | |
| AbstractStorage * | storage () const |
| Getter function for the storage property. | |
| WipeManager * | wipeManager () const |
| Getter function for the wipeManager property. | |
Signals | |
| void | editionChanged (const QString &edition) |
| Emitted when the value of edition changes. | |
| void | hasExtendedSupportChanged (bool hasExtendedSupport) |
| Emitted when the value of hasExtendedSupport changes. | |
| void | isInMaintenanceChanged (bool isInMaitenance) |
| Emitted when the isInMaintenance values changes. | |
| void | isInstalledChanged (bool isInstalled) |
| Emitted when the isInstalled value changes. | |
| void | needsDbUpgradeChanged (bool needsDbUpgrade) |
| Emitted when the needsDbUpgrade values changes. | |
| void | productnameChanged (const QString &productname) |
| Emitted when the value of productname changes. | |
| void | setupPossibleChanged (Fuoten::GetServerStatus::SetupPossible setupPossible) |
| Emitted when the value of setupPossible changes. | |
| void | versionChanged (const QVersionNumber &version) |
| Emitted when the value of version() changes. | |
| void | versionStringChanged (const QString &versionString) |
| Emitted when the value of versionString changes. | |
| Signals inherited from Fuoten::Component | |
| void | configurationChanged (Fuoten::AbstractConfiguration *configuration) |
| This signal is emitted when the pointer to the AbstractConfiguration object changes. | |
| void | errorChanged (Fuoten::Error *error) |
| This signal is emitted when the pointer to the Error object changes. error will be a nullptr if no error occurred or the current error has been reset. | |
| void | failed (Fuoten::Error *error) |
| Emit this signal in a subclass when the request failed for some reason. | |
| void | inOperationChanged (bool inOperation) |
| This signal is emitted when the in operation status changes. | |
| void | notificatorChanged (Fuoten::AbstractNotificator *notificator) |
| Notifier signal for the notificator property. | |
| void | requestTimeoutChanged (quint16 requestTimeout) |
| This signal is emitte when the timeout for the request changes. | |
| void | sslErrors (QNetworkReply *reply, const QList< QSslError > &errors) |
| This signal is emitted if the SSL/TLS session encountered errors during the set up. | |
| void | storageChanged (Fuoten::AbstractStorage *storage) |
| Notifier signal for the storage property. | |
| void | succeeded (const QJsonDocument &result) |
| Emit this signal in a subclass when the request was successful. | |
| void | useStorageChanged (bool useStorage) |
| Notifier signal for the useStorage property. | |
| void | wipeManagerChanged (Fuoten::WipeManager *wipeManager) |
| Notifier signal for the wipeManager property. | |
Protected Member Functions | |
| void | successCallback () override |
| Extracts the server response and sets the property values. | |
| Protected Member Functions inherited from Fuoten::Component | |
| void | addRequestHeader (const QByteArray &headerName, const QByteArray &headerValue) |
| Adds a header to the HTTP request. | |
| void | addRequestHeaders (const QHash< QByteArray, QByteArray > &headers) |
| Adds headers to the HTTP request. | |
| virtual bool | checkInput () |
| Performs basic input checks. | |
| virtual bool | checkOutput () |
| Performs basic output checks. | |
| virtual void | extractError (QNetworkReply *reply) |
| Extracts error data from the network reply. | |
| QJsonDocument | jsonResult () const |
| Returns the JSON result document. | |
| void | notify (AbstractNotificator::Type type, QtMsgType severity, const QVariant &data) const |
| Checks if a notificator has been set and will use it to notify the user. | |
| void | notify (const Error *e) const |
| Checks if a notificator has been set and will use it to notify about an occured error. | |
| QHash< QByteArray, QByteArray > | requestHeaders () const |
| Returns the currently set HTTP headers for the request. | |
| void | sendRequest () |
| Sends the request to the server. | |
| void | setApiRoute (const QString &route) |
| Sets the API route. | |
| void | setApiRoute (const QStringList &routeParts) |
| Sets the API route constructed from a route part list. | |
| void | setError (Error *nError) |
| Sets the pointer of the error property. | |
| void | setExpectedJSONType (ExpectedJSONType type) |
| Sets the expected JSON type for initial output check. | |
| void | setInOperation (bool nInOperation) |
| Sets the value of the inOperation property. | |
| void | setNetworkOperation (QNetworkAccessManager::Operation operation) |
| Sets the operation the network manager should perform for this call. | |
| void | setPayload (const QByteArray &payload) |
| Sets the payload for the request. | |
| void | setPayload (const QJsonObject &payload) |
| Sets the payload for the request. | |
| void | setRequestHeaders (const QHash< QByteArray, QByteArray > &headers) |
| Sets the headers to use for the HTTP request. | |
| void | setRequiresAuth (bool reqAuth) |
| Set this to true if the request requires authentication. | |
| void | setUrlQuery (const QUrlQuery &query) |
| Sets the URL query for the request. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from Fuoten::Component | |
| static AbstractConfiguration * | defaultConfiguration () |
| Returns the global default configuration. | |
| static QNetworkAccessManager * | defaultNam () |
| Returns the global network access manager. | |
| static AbstractNotificator * | defaultNotificator () |
| Returns the global default notificator. | |
| static AbstractStorage * | defaultStorage () |
| Returns the global default storage. | |
| static WipeManager * | defaultWipeManager () |
| Returns the global default wipe manager. | |
| static AbstractNamFactory * | networkAccessManagerFactory () |
| Returns the currently set network access manager factory. | |
| static void | setDefaultConfiguration (AbstractConfiguration *config) |
| Sets the global default configuration. | |
| static void | setDefaultNam (QNetworkAccessManager *nam) |
| Sets the global default network access manager. | |
| static void | setDefaultNotificator (AbstractNotificator *notificator) |
| Sets the global default notificator. | |
| static void | setDefaultStorage (AbstractStorage *storage) |
| Sets the global default storage. | |
| static void | setDefaultWipeManager (WipeManager *wipeManager) |
| Sets the global default wipe manager. | |
| static void | setNetworkAccessManagerFactory (AbstractNamFactory *factory) |
| Sets the network access manager factory. The factory will be used to create QNetworkAccessManager objects on demand. If no factory is set, a default QNetworkAccessManager object will be created. The Component class will take ownership of the created QNetworkAccessManager. | |
Requests the server status from status.php.
This is not really part of the News App API but a helper class. It should be especially helpful to support the login flow. The request gets the information every Nextcloud server publicly exports via its status.php file. That returns a JSON object containing some helpful information about the Nextcloud instance like state of maintenance mode and current version.
The result is exposed to the appropriate properties of this class as well as QJsonDocument via the Component::succeeded() signal.
This enum describes the setup possibility.
| Enumerator | |
|---|---|
| NotPossible | Setup is not possible, either the Nextcloud instance is not completely installed and/or it is in maintenance mode. |
| Manual | Only manual setup is possible. This means, that account setup via Login Flow is not possible. |
| LoginFlow | Login Flow setup is possible. |
| LoginFlowV2 | Login Flow v2 setup is possible. |
|
read |
This property holds the edition of the Nextcloud.
The default value is an empty string. It will be set in the successCallback().
| QString | edition() const |
| void | editionChanged(const QString &edition) |
|
read |
Returns true when the Nextcloud has extended support, otherwise false.
The default value is false. It will be set in the successCallback().
| bool | hasExtendedSupport() const |
| void | hasExtendedSupportChanged(bool hasExtendedSupport) |
|
read |
Returns true when the Nextcloud is in maintenance mode, otherwise false.
The default value is false. It will be set in the successCallback().
| bool | isInMaintenance() const |
| void | isInMaintenanceChanged(bool isInMaintenance) |
|
read |
Returns true when the Nextcloud is completely installed, otherwise false.
The default value is false. It will be set in the successCallback().
| bool | isInstalled() const |
| void | isInstalledChanged(bool isInstalled) |
|
read |
Returns true when the Nextcloud needs a database upgrade, otherwise false.
The default value is false. It will be set in the successCallback().
| bool | needsDbUpgrade() const |
| void | needsDbUpgradeChanged(bool needsDbUpgrade) |
|
read |
This property holds the product name of the Nextcloud.
The default value is an empty string. It will be set in the successCallback().
| QString | productname() const |
| void | productnameChanged(const QString &productname) |
|
read |
This property describes the possibility of setting up an account for the Nextcloud.
The default value is GetServerStatus::NotPossible. It will be set in the successCallback(). The value of this property will be calculated by the values of isInstalled(), isInMaintenance(), needsDbUpgrade() and version().
| GetServerStatus::SetupPossible | setupPossible() const |
| void | setupPossibleChanged(GetServerStatus::SetupPossible setupPossible) |
|
read |
This property holds the version of the Nextcloud as string.
The default value is an empty string. It will be set in the successCallback().
| QString | versionString() const |
| void | versionStringChanged(const QString &versionString) |
|
explicit |
Constructs a new GetServerStatus object with the given parent.
|
override |
Deconstructs the GetServerStatus object.
| int GetServerStatus::compareVersion | ( | const QString & | versionString | ) | const |
Compares versionString with the requested Nextcloud version.
Returns an integer less than, equal to, or greater than zero depending on wether the requested Nextcloud version is less than, equal to, or greater than versionString.
| int GetServerStatus::compareVersion | ( | const QVersionNumber & | version | ) | const |
Compares version with the requested Nextcloud version.
Returns an integer less than, equal to, or greater than zero depending on wether the requested Nextcloud version is less than, equal to, or greater than version.
| QString GetServerStatus::edition | ( | ) | const |
Returns the edition of the Nextcloud.
The default value is an empty string.
|
signal |
Emitted when the value of edition changes.
This signal will be triggered in the successCallback().
|
overridevirtual |
Executes the API request to get the server status.
Implements Fuoten::Component.
| bool GetServerStatus::hasExtendedSupport | ( | ) | const |
Returns true when the Nextcloud has extended support, otherwise false.
The default value is false. It will be set in the successCallback().
|
signal |
Emitted when the value of hasExtendedSupport changes.
This signal will be triggered in the successCallback().
| bool GetServerStatus::isInMaintenance | ( | ) | const |
Returns true when the Nextcloud is in maintenance mode, otherwise false.
The default value for this is false.
|
signal |
Emitted when the isInMaintenance values changes.
This signal will be triggered in the successCallback().
| bool GetServerStatus::isInstalled | ( | ) | const |
Returns true when the Nextcloud is completely installed, otherwise false.
The default value for this is false.
|
signal |
Emitted when the isInstalled value changes.
This signal will be triggered in the successCallback().
| bool GetServerStatus::needsDbUpgrade | ( | ) | const |
Returns true when the Nextcloud needs a database upgrade, otherwise false.
The default value for this is false.
|
signal |
Emitted when the needsDbUpgrade values changes.
This signal will be triggered in the successCallback().
| QString GetServerStatus::productname | ( | ) | const |
Returns the product name of the Nextcloud.
The default value is an empty string.
|
signal |
Emitted when the value of productname changes.
This signal will be triggered in the successCallback().
| Fuoten::GetServerStatus::SetupPossible GetServerStatus::setupPossible | ( | ) | const |
This property describes the possibility of setting up an account for the Nextcloud.
The default value is GetServerStatus::NotPossible. It will be set in the successCallback(). The value of this property will be calculated by the values of isInstalled(), isInMaintenance(), needsDbUpgrade() and version().
|
signal |
Emitted when the value of setupPossible changes.
This signal will be triggered in the successCallback().
|
overrideprotectedvirtual |
Extracts the server response and sets the property values.
Implements Fuoten::Component.
| QVersionNumber GetServerStatus::version | ( | ) | const |
Returns the version of the Nextcloud.
The default value is a null version.
|
signal |
Emitted when the value of version() changes.
This signal will be triggered in the successCallback().
| QString GetServerStatus::versionString | ( | ) | const |
Returns the version of the Nextcloud as a string.
The default value is an empty string.
|
signal |
Emitted when the value of versionString changes.
This signal will be triggered in the successCallback().