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

#include <Fuoten/Helpers/Synchronizer>

Properties

Fuoten::AbstractConfigurationconfiguration
QString currentAction
Fuoten::Errorerror
bool inOperation
Fuoten::AbstractNotificatornotificator
qreal progress
Fuoten::AbstractStoragestorage

Public Member Functions

 Synchronizer (QObject *parent=nullptr)
 ~Synchronizer () override
Q_INVOKABLE void clearError ()
AbstractConfigurationconfiguration () const
QString currentAction () const
virtual Q_INVOKABLE void deferredSync (quint32 miliseconds)
Errorerror () const
bool inOperation () const
AbstractNotificatornotificator () const
qreal progress () const
void setConfiguration (AbstractConfiguration *nAbstractConfiguration)
void setNotificator (AbstractNotificator *notificator)
void setStorage (AbstractStorage *nStorageHandler)
AbstractStoragestorage () const
virtual Q_INVOKABLE void sync ()

Public Slots

void start ()

Signals

void configurationChanged (Fuoten::AbstractConfiguration *configuration)
void currentActionChanged (const QString &currentAction)
void errorChanged (Fuoten::Error *error)
void failed (Fuoten::Error *error)
void inOperationChanged (bool inOperation)
void notificatorChanged (Fuoten::AbstractNotificator *notificator)
void progressChanged (qreal progress)
void storageChanged (Fuoten::AbstractStorage *storage)
void succeeded ()

Protected Slots

void finished ()
void notifyAboutRead ()
void notifyAboutStarred ()
void notifyAboutUnread ()
void notifyAboutUnstarred ()
void requestFeeds ()
void requestFolders ()
void requestStarred ()
void requestUnread ()
void requestUpdated ()
void setError (Fuoten::Error *nError)

Protected Member Functions

void setCurrentAction (const QString &nCurrentAction)
void setProgress (qreal nProgress)

Detailed Description

Combines updating of folders, feeds and articles.

Mandatory properties
Synchronizer::configuration

Property Documentation

◆ configuration

Fuoten::AbstractConfiguration * configuration
readwrite

Pointer to a AbstractConfiguration object.

You have to set a valid AbstractConfiguration object in order to start a synchronization. This property can not be changed while Component::inOperation() returns true.

Access functions:
AbstractConfiguration*configuration() const
voidsetConfiguration(AbstractConfiguration *nAbstractConfiguration)
Notifier signal:
voidconfigurationChanged(AbstractConfiguration *configuration)

◆ currentAction

QString currentAction
read

Returns the current performed action.

Access functions:
QStringcurrentAction() const
Notifier signal:
voidcurrentActionChanged(const QString &currentAction)
See also
setCurrentAction()

◆ error

Fuoten::Error * error
read

Pointer to an Error object, if an error occurred. Otherwise a nullptr.

Access functions:
Error*error() const
Notifier signal:
voiderrorChanged(Error *error)

◆ inOperation

bool inOperation
read

Returns true while the Synchronizer is in operational mode.

Access functions:
boolinOperation() const
Notifier signal:
voidinOperationChanged(bool inOperation)

◆ notificator

Fuoten::AbstractNotificator * notificator
readwrite

Pointer to an object derived from AbstractNotificator.

Set a notificator to notify users about errors and events. This is not mandatory. You have to derive your own notificator that uses the notification system of the target platform.

If no notificator has been set via setNotificator(), the one set via Component::setDefaultConfigurator() will be used - if any has been set. If you do not set a notificator either per instance or global, this property will hold a nullptr. If a notificator is set to an instance of this class via setNotificator(), this notificator will take precedence over the global default notificator object (if any set).

Access functions:
Notifier signal:

◆ progress

qreal progress
read

Pregress value between 0.0 and 1.0.

Access functions:
qrealprogress() const
Notifier signal:
voidprogressChanged(qreal progress)
See also
setProgress()

◆ storage

Fuoten::AbstractStorage * storage
readwrite

Pointer to an AbstractStorage derived object.

This property can not be changed while Component::inOperation() returns true.

Access functions:
AbstractStorage*storage() const
voidsetStorage(AbstractStorage *nStorageHandler)
Notifier signal:
voidstorageChanged(AbstractStorage *storage)

Constructor & Destructor Documentation

◆ Synchronizer()

Synchronizer ( QObject * parent = nullptr)
explicit

Constructs a new Synchronizer object with the given parent.

◆ ~Synchronizer()

~Synchronizer ( )
override

Deconstructs the Synchronizer object.

Member Function Documentation

◆ clearError()

void clearError ( )

Clears the current error and sets the error property to a nullptr.

◆ configuration()

AbstractConfiguration * configuration ( ) const

Returns the pointer to the currently set AbstractConfiguration object.

See also
configuration

◆ configurationChanged

void configurationChanged ( Fuoten::AbstractConfiguration * configuration)
signal

This signal is emitted if the pointer to the AbstractConfiguration object changes.

See also
configuration

◆ currentAction()

QString currentAction ( ) const

◆ currentActionChanged

void currentActionChanged ( const QString & currentAction)
signal

This is emitted if the value of the currentAction property changes.

See also
Synchronizer::currentAction(), Synchronizer::setCurrentAction()

◆ deferredSync()

void deferredSync ( quint32 miliseconds)
virtual

Invokes the synchronizing process after miliseconds.

The base implementation simply calls start() after the timeout in miliseconds.

◆ error()

Error * error ( ) const

Returns a pointer to an Error object if any error occurred, otherwise a nullptr.

See also
error

◆ errorChanged

void errorChanged ( Fuoten::Error * error)
signal

This signal is emitted if the pointer to an Error object changes.

Maybe a nullptr if the Error object was reset.

See also
error

◆ failed

void failed ( Fuoten::Error * error)
signal

This signal is emitted if the synchonization process failed for some reason.

See also
succeeded(), error

◆ finished

void finished ( )
protectedslot

Finishes the synchronization and cleans up.

◆ inOperation()

bool inOperation ( ) const

Returns true while the synchronization is active.

See also
inOperation

◆ inOperationChanged

void inOperationChanged ( bool inOperation)
signal

This signal is emitted if the oprational state changes.

See also
inOperation

◆ notificator()

AbstractNotificator * notificator ( ) const

Getter function for the notificator property.

See also
setNotificator(), notificatorChanged()

◆ notificatorChanged

void notificatorChanged ( Fuoten::AbstractNotificator * notificator)
signal

Notifier signal for the notificator property.

See also
setNotificator(), notificator()

◆ notifyAboutRead

void notifyAboutRead ( )
protectedslot

Notifies the News App about read articles from the local queue.

◆ notifyAboutStarred

void notifyAboutStarred ( )
protectedslot

Notifies the News App about starred articles from the local queue.

◆ notifyAboutUnread

void notifyAboutUnread ( )
protectedslot

Notifies the News App about unread articles from the local queue.

◆ notifyAboutUnstarred

void notifyAboutUnstarred ( )
protectedslot

Notifies the News app about unstarred articles from the local queue.

◆ progress()

qreal progress ( ) const

Getter function for the progress property.

See also
Synchronizer::setProgress(), Synchronizer::progressChanged()

◆ progressChanged

void progressChanged ( qreal progress)
signal

This is emitted if the value of the progress property changes.

See also
Synchronizer::progress(), Synchronizer::setProgress()

◆ requestFeeds

void requestFeeds ( )
protectedslot

Requests feed information from the News App.

◆ requestFolders

void requestFolders ( )
protectedslot

Requests folder information from the News App.

◆ requestStarred

void requestStarred ( )
protectedslot

Requests all starred articles from the News App.

◆ requestUnread

void requestUnread ( )
protectedslot

Requests all unread articles from the News App.

◆ requestUpdated

void requestUpdated ( )
protectedslot

Requests articles from the News App that are new or have been updated since last sync.

◆ setConfiguration()

void setConfiguration ( AbstractConfiguration * nAbstractConfiguration)

Sets the pointer to a AbstractConfiguration object.

See also
configuration

◆ setCurrentAction()

void setCurrentAction ( const QString & nCurrentAction)
protected

Sets the current action string. Emits the currentActionChanged() signal if nCurrentAction is not equal to the stored value.

See also
Synchronizer::currentAction(), Synchronizer::currentActionChanged(), Synchronizer::currentAction

◆ setError

void setError ( Fuoten::Error * nError)
protectedslot

Sets a new Error object to the error property.

See also
error

◆ setNotificator()

void setNotificator ( AbstractNotificator * notificator)

Setter function for the notificator property.

See also
notificator(), notificatorChanged()

◆ setProgress()

void setProgress ( qreal nProgress)
protected

Sets the current progress value. Emits the progressChanged() signal if nProgress is not equal to the stored value.

See also
Synchronizer::progress(), Synchronizer::progressChanged(), Synchronizer::progress

◆ setStorage()

void setStorage ( AbstractStorage * nStorageHandler)

Sets the pointer to an AbstractStorage object.

See also
storage

◆ start

void start ( )
slot

Starts the synchronizing process.

Prior to starting the synchronizing process, it checks inOperation(). If that returns true, nothing will happen. If inOperation() returns false, it will set it to true and will start the update process.

When you create a derived class, call start() in your implementation of sync().

◆ storage()

AbstractStorage * storage ( ) const

Returns the pointer to the currently set AbstractStorage object, if any, otherwise a nullptr.

◆ storageChanged

void storageChanged ( Fuoten::AbstractStorage * storage)
signal

This signall is emitted if the pointer to the AbstractStorage object changes.

See also
storage

◆ succeeded

void succeeded ( )
signal

This signal is emitted if the synchronization process was successful.

See also
failed()

◆ sync()

void sync ( )
virtual

Invokes the synchronizing process.

The base implementation simply calls start().