QtDataSync  4.2.0
A simple offline-first synchronisation framework, to synchronize data of Qt applications between devices
Public Slots | Signals | Public Member Functions | Properties | List of all members
QtDataSync::AndroidSyncControl Class Reference

A class to manage background synchronization for android. More...

#include <androidsynccontrol.h>

+ Inheritance diagram for QtDataSync::AndroidSyncControl:

Public Slots

void setServiceId (QString serviceId)
 WRITE accessor for AndroidSyncControl::serviceId.
 
void setInterval (qint64 interval)
 WRITE accessor for AndroidSyncControl::interval.
 
void setEnabled (bool enabled)
 WRITE accessor for AndroidSyncControl::enabled.
 
bool triggerSyncNow ()
 Immediatly triggers a background synchronization. More...
 

Signals

void validChanged (QPrivateSignal)
 NOTIFY accessor for AndroidSyncControl::valid.
 
void serviceIdChanged (const QString &serviceId, QPrivateSignal)
 NOTIFY accessor for AndroidSyncControl::serviceId.
 
void intervalChanged (qint64 interval, QPrivateSignal)
 NOTIFY accessor for AndroidSyncControl::interval.
 

Public Member Functions

 AndroidSyncControl (QObject *parent=nullptr)
 Default constructor.
 
 AndroidSyncControl (QString serviceId, QObject *parent=nullptr)
 Constructor with a service class.
 
bool isValid () const
 READ accessor for AndroidSyncControl::valid.
 
QString serviceId () const
 READ accessor for AndroidSyncControl::serviceId.
 
qint64 interval () const
 READ accessor for AndroidSyncControl::interval.
 
std::chrono::minutes intervalMinutes () const
 READ accessor for AndroidSyncControl::interval.
 
bool isEnabled () const
 READ accessor for AndroidSyncControl::enabled.
 
template<typename TRep , typename TPeriod >
void setInterval (const std::chrono::duration< TRep, TPeriod > &interval)
 WRITE accessor for AndroidSyncControl::interval.
 
void setInterval (std::chrono::minutes interval)
 WRITE accessor for AndroidSyncControl::interval.
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
virtual void * qt_metacast (const char *)
 
virtual int qt_metacall (QMetaObject::Call, int, void **)
 
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectList & children () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 

Properties

bool valid
 Holds whether the sync control is able to configure background sync. More...
 
QString serviceId
 The JAVA class name of the service to be used to do the background sync. More...
 
qint64 interval
 The interval in minutes between synchronizations. More...
 
bool enabled
 Specify if background synchronization is enabled or not. More...
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Detailed Description

A class to manage background synchronization for android.

This class is part of the QtDataSyncAndroid module, which is only available on the android platform. It can be used to configure background synchronization so that your application is able to update it's internal data periodically in the background, even if your app is not actively used.

Warning
This class alone is not sufficient to make this possible. You will also have to create a service based on AndroidBackgroundService and correctly set up the Manifest and other things. Have a look at the Android Background synchronization to learn how to add background synchronization to your project.
See also
AndroidBackgroundService, Android Background synchronization, IosSyncDelegate

Definition at line 15 of file androidsynccontrol.h.

Member Function Documentation

◆ triggerSyncNow

QtDataSync::AndroidSyncControl::triggerSyncNow ( )
slot

Immediatly triggers a background synchronization.

Returns
true, if the operating system accepted the synchronization request, false if not
Note
This only tells the OS to start the service specified by serviceId. It does not report back whether the service was actually correctly started or wether it finished gracefully.
See also
AndroidSyncControl::enabled

Property Documentation

◆ enabled

QtDataSync::AndroidSyncControl::enabled
readwrite

Specify if background synchronization is enabled or not.

Default: false

These property directly communicates with the OS and schedules (or unschedules) the task to run the service. This means you must always set serviceId and interval first before enabling a service

Attention
This property is persisted. This means after changing it and restarting it, the new value will be the same as the one you set. This does not apply to all other properties. For example, after creating this class, it could already return enabled, but the interval property might not match the interval the service actually uses.
Accessors
READisEnabled()
WRITEsetEnabled()
See also
AndroidSyncControl::serviceId, AndroidSyncControl::interval, AndroidSyncControl::triggerSyncNow

Definition at line 28 of file androidsynccontrol.h.

◆ interval

QtDataSync::AndroidSyncControl::interval
readwrite

The interval in minutes between synchronizations.

Default: 60 (minutes)

This value is passed to the operating system to schedule the background synchronization. There is no guarantee of exact delivery of those background synchronizations. It is only a suggestion to the system. However, android typically keeps the windows limited to twice the length of the interval.

Accessors
READinterval()
READintervalMinutes()
WRITEsetInterval()
NOTIFYintervalChanged()
See also
AndroidSyncControl::valid, AndroidSyncControl::enabled

Definition at line 25 of file androidsynccontrol.h.

◆ serviceId

QtDataSync::AndroidSyncControl::serviceId
readwrite

The JAVA class name of the service to be used to do the background sync.

Default: "de.skycoder42.qtservice.AndroidService"

The JAVA class name (not JNI name) of the android service that should be run to perform the background synchronization. The class must exist and must be declared as service in your AndroidManifest.xml

Accessors
READserviceId()
WRITEsetServiceId()
NOTIFYserviceIdChanged()
See also
AndroidSyncControl::valid, AndroidBackgroundService, AndroidSyncControl::enabled, Android Backend

Definition at line 23 of file androidsynccontrol.h.

◆ valid

QtDataSync::AndroidSyncControl::valid
read

Holds whether the sync control is able to configure background sync.

Default: false

Validity basically comes down to whether there is a background service that matches the given serviceId. Only if the control is valid, it is possible to actually do anything with this class

Accessors
READisValid()
NOTIFYvalidChanged()
See also
AndroidSyncControl::serviceId

Definition at line 20 of file androidsynccontrol.h.


The documentation for this class was generated from the following files: