|
| 1 | +/*! |
| 2 | +@class QtDataSync::IosSyncDelegate |
| 3 | + |
| 4 | +This class is part of the `QtDataSyncIos` module, which is only available on the ios platform. |
| 5 | +It can be used to configure and run background synchronization so that your application is able |
| 6 | +to update it's internal data periodically in the background, even if your app is not actively |
| 7 | +used. |
| 8 | + |
| 9 | +@warning This class alone is **not** sufficient to make this possible. You will also have to |
| 10 | +correctly set up the Info.plist and other things. Have a look at the |
| 11 | +@ref qtdatasync_sync_guide_ios to learn how to add background synchronization to your project. |
| 12 | + |
| 13 | +@sa @ref qtdatasync_sync_guide_ios, AndroidSyncControl, AndroidBackgroundService |
| 14 | +*/ |
| 15 | + |
| 16 | +/*! |
| 17 | +@property QtDataSync::IosSyncDelegate::interval |
| 18 | + |
| 19 | +@default{`60` (minutes)} |
| 20 | + |
| 21 | +This value is passed to the operating system to schedule the background synchronization. There |
| 22 | +is no guarantee of exact delivery of those background synchronizations. For ios, this is only |
| 23 | +a minimal wait time, i.e. it is guaranteed that the synchronization will not be started before |
| 24 | +that time has passed. |
| 25 | + |
| 26 | +@note Due to the stupidity of Ios, this means sometimes the system won't even run the sync task |
| 27 | +in days, even though you specify an interval of an hour or less. There is nothing that can be |
| 28 | +done here, as you are fully at the mercy of apples proprietary optimization logic. |
| 29 | + |
| 30 | +@accessors{ |
| 31 | + @readAc{interval()} |
| 32 | + @readAc{intervalMinutes()} |
| 33 | + @writeAc{setInterval()} |
| 34 | + @notifyAc{intervalChanged()} |
| 35 | +} |
| 36 | + |
| 37 | +@note if persistState is enabled, this property is persisted |
| 38 | + |
| 39 | +@sa IosSyncDelegate::enabled, IosSyncDelegate::persistState |
| 40 | +*/ |
| 41 | + |
| 42 | +/*! |
| 43 | +@property QtDataSync::IosSyncDelegate::enabled |
| 44 | + |
| 45 | +@default{`false`} |
| 46 | + |
| 47 | +These property directly communicates with the OS and schedules (or unschedules) the task to run |
| 48 | +the sync task. This means you must always set the interval first before enabling a task. |
| 49 | + |
| 50 | +@accessors{ |
| 51 | + @readAc{isEnabled()} |
| 52 | + @writeAc{setEnabled()} |
| 53 | + @notifyAc{enabledChanged()} |
| 54 | +} |
| 55 | + |
| 56 | +@note if persistState is enabled, this property is persisted |
| 57 | + |
| 58 | +@sa IosSyncDelegate::interval, IosSyncDelegate::persistState |
| 59 | +*/ |
| 60 | + |
| 61 | +/*! |
| 62 | +@property QtDataSync::IosSyncDelegate::waitFullSync |
| 63 | + |
| 64 | +@default{`true`} |
| 65 | + |
| 66 | +If set to true, the delegate will internally call SyncManager::runOnSynchronized() with the |
| 67 | +onSyncCompleted() as handler. If disable, SyncManager::runOnDownloaded() is used instead. Check |
| 68 | +the documentation of these two methods. |
| 69 | + |
| 70 | +@accessors{ |
| 71 | + @readAc{waitFullSync()} |
| 72 | + @writeAc{setWaitFullSync()} |
| 73 | + @notifyAc{waitFullSyncChanged()} |
| 74 | +} |
| 75 | + |
| 76 | +@note if persistState is enabled, this property is persisted |
| 77 | + |
| 78 | +@sa IosSyncDelegate::onSyncCompleted, SyncManager::runOnSynchronized, |
| 79 | +SyncManager::runOnDownloaded, IosSyncDelegate::persistState |
| 80 | +*/ |
| 81 | + |
| 82 | +/*! |
| 83 | +@property QtDataSync::IosSyncDelegate::persistState |
| 84 | + |
| 85 | +@default{`true`} |
| 86 | + |
| 87 | +If set to true, the delegate will store it's current state whenver the interval or the enabled |
| 88 | +properties are changed. The that will be automatically reloaded when passed to init(). |
| 89 | + |
| 90 | +For the default implementation of the delegate, persistance is always enabled. You can override |
| 91 | +this method in a custom class to deactivate it. |
| 92 | + |
| 93 | +Properties that are stored are: |
| 94 | + |
| 95 | +- IosSyncDelegate::enabled |
| 96 | +- IosSyncDelegate::interval |
| 97 | +- IosSyncDelegate::waitFullSync |
| 98 | + |
| 99 | +@accessors{ |
| 100 | + @readAc{persistState()} |
| 101 | + @constantAc |
| 102 | +} |
| 103 | + |
| 104 | +@sa IosSyncDelegate::init, IosSyncDelegate::enabled, IosSyncDelegate::interval, |
| 105 | +IosSyncDelegate::waitFullSync |
| 106 | +*/ |
| 107 | + |
| 108 | +/*! |
| 109 | +@fn QtDataSync::IosSyncDelegate::init |
| 110 | + |
| 111 | +@param delegate The delegate to be set as sync delegate |
| 112 | + |
| 113 | +You must call this method after creating the core app (but before executing it) to register a |
| 114 | +delegate as "active" delegate. This delegate will then control whether sync is enabled and handle |
| 115 | +the sync requests if your application is in the background. |
| 116 | + |
| 117 | +@note If persistState is true (the default), the init method will also restore the previously |
| 118 | +persisted state |
| 119 | + |
| 120 | +@sa IosSyncDelegate::persistState, IosSyncDelegate::currentDelegate |
| 121 | +*/ |
| 122 | + |
| 123 | +/*! |
| 124 | +@fn QtDataSync::IosSyncDelegate::currentDelegate |
| 125 | + |
| 126 | +@returns The delegate currently set via init() or `nullptr`, if no delegate was set |
| 127 | + |
| 128 | +@sa IosSyncDelegate::init |
| 129 | +*/ |
| 130 | + |
| 131 | +/*! |
| 132 | +@fn QtDataSync::IosSyncDelegate::setupName |
| 133 | + |
| 134 | +@returns The name of the setup |
| 135 | + |
| 136 | +The default implementation returns `QtDataSync::DefaultSetup`. You can override the method if you |
| 137 | +need the delegate to create the setup under a different name. |
| 138 | + |
| 139 | +@sa QtDataSync::DefaultSetup, IosSyncDelegate::prepareSetup |
| 140 | +*/ |
| 141 | + |
| 142 | +/*! |
| 143 | +@fn QtDataSync::IosSyncDelegate::prepareSetup |
| 144 | + |
| 145 | +@param setup The setup to be prepared |
| 146 | + |
| 147 | +You should override this method to configure the setup before creation (i.e. set properties on |
| 148 | +it). The default implementation does nothing. |
| 149 | + |
| 150 | +@sa QtDataSync::Setup, IosSyncDelegate::setupName |
| 151 | +*/ |
| 152 | + |
| 153 | +/*! |
| 154 | +@fn QtDataSync::IosSyncDelegate::onSyncCompleted |
| 155 | + |
| 156 | +@param state The state in which the synchronization finished |
| 157 | +@returns A sync result to tell the operating system how the synchronization finished |
| 158 | + |
| 159 | +This method is called as soon as the datasync instance has finished the data synchronization. You |
| 160 | +can override it to perform additional operations with the data before quitting the service. |
| 161 | + |
| 162 | +The default implementation only returns a sync result based on the sync state. You must |
| 163 | +do the same in your implementation. If you do not want to return synchronously, you must override |
| 164 | +the performSync() method instead. |
| 165 | + |
| 166 | +Possible states that are typically passed to the method can be: |
| 167 | +- Uploading (only if waitFullSync is set to false) |
| 168 | +- Synchronized |
| 169 | +- Error |
| 170 | +- Disconnected |
| 171 | + |
| 172 | +The default return value mapping is this method does is: |
| 173 | + |
| 174 | +SyncState | SyncResult |
| 175 | +----------------|------------ |
| 176 | +Downloading | NewData |
| 177 | +Uploading | NewData |
| 178 | +Synchronized | NewData |
| 179 | +Disconnected | NoData |
| 180 | +Error | Error |
| 181 | + |
| 182 | +@sa IosSyncDelegate::waitFullSync, IosSyncDelegate::performSync |
| 183 | +*/ |
| 184 | + |
| 185 | +/*! |
| 186 | +@fn QtDataSync::IosSyncDelegate::performSync |
| 187 | + |
| 188 | +@param callback A callback to be called with the sync result once the sync is done |
| 189 | + |
| 190 | +This method is called by the operating system and contains the actual code to synchronize the |
| 191 | +data. If you want to reimplement this method, you should always call the base implementation |
| 192 | +as well to make shure synchronization works as expected. |
| 193 | + |
| 194 | +In case you want to override this method to allow asynchronous sync result handling, you can use |
| 195 | +the following pattern. Simpyl impelement onSyncCompleted() as usual, but always return NewData |
| 196 | +(ignored). Instead add a signal with the SyncResult as parameter and emit this once the async |
| 197 | +sync operation has finished. Now implement this method and call the base implementation as usual, |
| 198 | +but pass an empty, self constructed callback to it that does nothing. Instead connect the actual |
| 199 | +callback to the previously declared signal (before calling the base impl.) |
| 200 | + |
| 201 | +@sa IosSyncDelegate::onSyncCompleted |
| 202 | +*/ |
0 commit comments