QtDataSync  4.2.0
A simple offline-first synchronisation framework, to synchronize data of Qt applications between devices
androidbackgroundservice.h
1 #ifndef QTDATASYNC_ANDROIDBACKGROUNDSERVICE_H
2 #define QTDATASYNC_ANDROIDBACKGROUNDSERVICE_H
3 
4 #include <QtCore/qscopedpointer.h>
5 
6 #include <QtService/service.h>
7 
8 #include <QtAndroidExtras/qandroidintent.h>
9 
10 #include <QtDataSync/setup.h>
11 #include <QtDataSync/syncmanager.h>
12 
13 #include "QtDataSyncAndroid/qtdatasyncandroid_global.h"
14 
15 namespace QtDataSync {
16 
17 class AndroidBackgroundServicePrivate;
19 class Q_DATASYNCANDROID_EXPORT AndroidBackgroundService : public QtService::Service // clazy:exclude=ctor-missing-parent-argument
20 {
21  Q_OBJECT
22 
24  Q_PROPERTY(bool waitFullSync READ waitFullSync WRITE setWaitFullSync NOTIFY waitFullSyncChanged)
25 
26 public:
32  static const int ForegroundNotificationId;
33 
35  AndroidBackgroundService(int &argc, char **argv, int = QCoreApplication::ApplicationFlags);
36  ~AndroidBackgroundService() override;
37 
39  bool waitFullSync() const;
40 
41 public Q_SLOTS:
43  void setWaitFullSync(bool waitFullSync);
44 
45 Q_SIGNALS:
47  void waitFullSyncChanged(bool waitFullSync, QPrivateSignal);
48 
49 protected:
51  virtual QString setupName() const;
53  virtual void prepareSetup(Setup &setup);
54 
56  CommandResult onStart() override;
58  CommandResult onStop(int &exitCode) override;
59 
61  virtual void onSyncCompleted(SyncManager::SyncState state);
63  void exitAfterSync();
64 
66  virtual int onStartCommand(const QAndroidIntent &intent, int flags, int startId);
68  virtual QAndroidJniObject createForegroundNotification() = 0;
70  virtual bool stopSelf(int startId);
71 
72 private Q_SLOTS:
73  void startBackgroundSync(int startId);
74  void registerSync(int startId, qint64 interval);
75  void backendReady();
76 
77 private:
79 };
80 
81 }
82 
83 #endif // QTDATASYNC_ANDROIDBACKGROUNDSERVICE_H
The class to setup and create datasync instances.
Definition: setup.h:59
static const QString RegisterSyncAction
The Intent Action used to register the service for background synchronization.
static const QString BackgroundSyncAction
The Intent Action used to start the background synchronization.
The primary namespace of the QtDataSync library.
SyncState
The possible states the sync engine can be in.
Definition: syncmanager.h:37
An extension of QtService to create a synchronization service for android.
static const int ForegroundNotificationId
The ID of the Foreground notification shown by the service while synchronizing.