libfuoten 0.8.1
Qt based library to access the ownCloud/Nextcloud News App API
Loading...
Searching...
No Matches
AbstractConfiguration Class Referenceabstract

#include <Fuoten/Helpers/AbstractConfiguration>

Public Member Functions

 AbstractConfiguration (QObject *parent=nullptr)
 ~AbstractConfiguration () override
virtual Q_INVOKABLE void deleteAccount ()
virtual QString getHost () const =0
virtual bool getIgnoreSSLErrors () const
virtual QString getInstallPath () const =0
virtual QDateTime getLastSync () const
virtual Q_INVOKABLE QString getLoginFlowUserAgent () const
virtual QString getPassword () const =0
virtual FuotenEnums::ItemDeletionStrategy getPerFeedDeletionStrategy (qint64 feedId) const
virtual quint16 getPerFeedDeletionValue (qint64 feedId) const
virtual int getServerPort () const
virtual QString getUserAgent () const
virtual QString getUsername () const =0
virtual bool getUseSSL () const
virtual bool isAccountValid () const =0
virtual void setHost (const QString &host)
virtual void setInstallPath (const QString &path)
virtual void setLastSync (const QDateTime &syncTime)
virtual void setPassword (const QString &password)
virtual void setServerPort (int port)
virtual void setUsername (const QString &username)
virtual void setUseSSL (bool useSSL)

Public Slots

bool setLoginFlowCredentials (const QByteArray &credentials)
bool setLoginFlowCredentials (const QJsonDocument &credentials)
bool setLoginFlowCredentials (const QJsonObject &credentials)
virtual bool setLoginFlowCredentials (const QUrl &credentialUrl)
bool setServerUrl (const QString &url)
bool setServerUrl (const QUrl &url)

Signals

void accountDeleted ()

Protected Member Functions

void checkAccountValidity ()
virtual void setIsAccountValid (bool nIsAccountValid)=0

Detailed Description

Server and authentication settings abstract base class.

In order to use libfuoten, you have to reimplement this class, especially all pure virtual functions that provide the necessary data to perform API requests.

The reimplemented class will than be used on all API call classes. All of the API classes have a configuration property that takes subclasses of AbstractConfiguration.

Constructor & Destructor Documentation

◆ AbstractConfiguration()

AbstractConfiguration ( QObject * parent = nullptr)
explicit

Constructs a new AbstractConfiguration object with the given parent.

◆ ~AbstractConfiguration()

~AbstractConfiguration ( )
override

Destroys the AbstractConfiguration object.

Member Function Documentation

◆ accountDeleted

void accountDeleted ( )
signal

Emitted when the account data has been deleted.

Emit this signal in your implementation of deleteAccount() after the account data has been deleted.

◆ checkAccountValidity()

void checkAccountValidity ( )
protected

Performs a simple check on the important account data.

This will check if username, password and host are not empty. You can use this function to set the account validity. The result of the check will be set to setIsAccountValid().

See also
setIsAccountValid(), isAccountValid()

◆ deleteAccount()

void deleteAccount ( )
virtual

Deletes all local account data.

Reimplement this to delete the configuration entries for username, password, host, path, port and current verion. Make sure to emit the accountDelted() signal after deleting the data. The default version does nothing.

◆ getHost()

virtual QString getHost ( ) const
pure virtual

Returns the host the ownCloud/Nextcloud is installed on.

Reimplement this function in a subclass.

◆ getIgnoreSSLErrors()

bool getIgnoreSSLErrors ( ) const
virtual

Returns true if SSL/TLS errors should be ignored.

The default implementation returns false.

◆ getInstallPath()

virtual QString getInstallPath ( ) const
pure virtual

Returns the optional installation path of the ownCloud/Nextcloud on the server.

Reimplement this function in a subclass.

◆ getLastSync()

QDateTime getLastSync ( ) const
virtual

Returns the last date and time in UTC a successful snychronization has been performed.

Reimplement this in a subclass if you want let the Synchronizer save the last sync time. The default implementation returns a invalid QDateTime. Your implementation should also return an invalid QDateTime if there has been no last sync.

See also
setLastSync()

◆ getLoginFlowUserAgent()

QString getLoginFlowUserAgent ( ) const
virtual

Returns a user agent string usable for the login flow.

In the login flow API, the user agent is used to show the user the application that requests a new application password and will also be used for the identifier of the generated application password.

See also https://docs.nextcloud.com/server/latest/developer_manual/client_apis/LoginFlow/index.html

Reimplement this in a subclass. The default implementation simply returns the same as getUserAgent(), the string "Libfuoten $VERSION" and that is not really meaningful to a user.

Since
0.8.0
Returns
user agent string

◆ getPassword()

virtual QString getPassword ( ) const
pure virtual

Returns the password used for authentiction.

Reimplement this function in a subclass.

◆ getPerFeedDeletionStrategy()

FuotenEnums::ItemDeletionStrategy getPerFeedDeletionStrategy ( qint64 feedId) const
virtual

Returns the item deletion strategy for the feed identified by feedId.

The default implementation returns FuotenEnums::NoItemDeletion.

Parameters
feedIdID of the feed to get the deletion strategy for

◆ getPerFeedDeletionValue()

quint16 getPerFeedDeletionValue ( qint64 feedId) const
virtual

Returns the deletion value for the feed identified by feedId.

If getPerFeedDeletionStrategy() returns FuotenEnums::DeleteItemsByTime, the returned value should be treated as older than n days. If for example 5 is returned, all items in the feed that are older than 5 days should be removed. Reference time should be the publication time.

If getPerFeedDeletionStrategy() return FuotenEnums::DeleteItemsByCount, the returned value should be treated as numer of items in the feed to keep. If for example 200 is returned, so many items should be deleted that after the deletion the feed contains 200 items.

The default implementation returns 0.

Parameters
feedIdID of the feed to get the deletion value for

◆ getServerPort()

int getServerPort ( ) const
virtual

Returns the server port used for the connection.

The default implementation returns 0, what means that the connection should use the default port for HTTP or HTTPS.

◆ getUserAgent()

QString getUserAgent ( ) const
virtual

Returns the user agent to send as request header.

The default implementation returns "Libfuoten VERSION"

◆ getUsername()

virtual QString getUsername ( ) const
pure virtual

Returns the user name used for authentication.

Reimplement this function in a subclass.

◆ getUseSSL()

bool getUseSSL ( ) const
virtual

Returns true if the connection should use SSL/TLS.

The default implementation returns true.

◆ isAccountValid()

virtual bool isAccountValid ( ) const
pure virtual

Returns true if the account data is valid.

Reimplement this function in a subclass. You can use checkAccountValidity() to perform a simple check if the important values are not empty.

See also
setIsAccountValid(), checkAccountValidity()

◆ setHost()

void setHost ( const QString & host)
virtual

Sets the host the remote Nextcloud instance runs on.

Reimplement this in a subclass. The default implementation does nothing.

◆ setInstallPath()

void setInstallPath ( const QString & path)
virtual

Sets the path under which the remote Nextcloud instance is installed.

Reimplement this in a subclass. The default implementation does nothing.

◆ setIsAccountValid()

virtual void setIsAccountValid ( bool nIsAccountValid)
protectedpure virtual

Set to true if the account data is valid.

Reimplement this in a subclass. You can use checkAccountValidity() to perform a simple check if the important data is not empty.

See also
isAccountValid(), checkAccountValidity()

◆ setLastSync()

void setLastSync ( const QDateTime & syncTime)
virtual

Sets the data and time in UTC the last successfule synchronization has been performed.

Reimplement this in a subclass if you want let the Synchronizer save the last sync time. The default implementation does nothing.

See also
getLastSync()
Parameters
syncTimethe date and time the last/current synchronization has successfully finished

◆ setLoginFlowCredentials [1/4]

bool setLoginFlowCredentials ( const QByteArray & credentials)
slot

Sets the login credentials requested from the login flow v2 API and returns true on success.

This has to be a valid JSON object requested from the polling endpoint. See also https://docs.nextcloud.com/server/latest/developer_manual/client_apis/LoginFlow/index.html

Since
0.8.0

◆ setLoginFlowCredentials [2/4]

bool setLoginFlowCredentials ( const QJsonDocument & credentials)
slot

Sets the login credentials requested from the login flow v2 API and returns true on success.

This has to be a valid JSON object requested from the polling endpoint. See also https://docs.nextcloud.com/server/latest/developer_manual/client_apis/LoginFlow/index.html

Since
0.8.0

◆ setLoginFlowCredentials [3/4]

bool setLoginFlowCredentials ( const QJsonObject & credentials)
slot

Sets the login credentials requested from the login flow v2 API and returns true on success.

This has to be a valid JSON object requested from the polling endpoint. See also https://docs.nextcloud.com/server/latest/developer_manual/client_apis/LoginFlow/index.html

Since
0.8.0

◆ setLoginFlowCredentials [4/4]

bool setLoginFlowCredentials ( const QUrl & credentialUrl)
virtualslot

Sets login credentials requested from the login flow API and returns true on success.

See also https://docs.nextcloud.com/server/latest/developer_manual/client_apis/LoginFlow/index.html

Reimplement this in a subclass. The default implementation does nothing.

Since
0.8.0

◆ setPassword()

void setPassword ( const QString & password)
virtual

Sets the password used for authentication.

Reimplement this in a subclass. The default implementation does nothing.

Parameters
passwordused for authentication

◆ setServerPort()

void setServerPort ( int port)
virtual

Sets the server port used for the connection.

Reimplement this in a subclass. The default implementation does nothing.

◆ setServerUrl [1/2]

bool setServerUrl ( const QString & url)
slot

Sets the server data via url and returns true on success, otherwise false.

This takes the scheme and the host and if available the port and the path from the url to set them to setUseSSL(), setHost(), setServerPort() and setInstallPath().

Since
0.8.0

◆ setServerUrl [2/2]

bool setServerUrl ( const QUrl & url)
slot

Sets the server data via url and returns true on success, otherwise false.

This takes the scheme and the host and if available the port and the path from the url to set them to setUseSSL(), setHost(), setServerPort() and setInstallPath().

Since
0.8.0

◆ setUsername()

void setUsername ( const QString & username)
virtual

Sets the username used for authentication.

Reimplement this in a subclass. The default implementation does nothing.

Parameters
usernameused for authentication

◆ setUseSSL()

void setUseSSL ( bool useSSL)
virtual

Set useSSL to true to let the connection use SSL/TLS.

Reimplement this in a subclass. The default implementation does nothing.