|
| 1 | +/*! |
| 2 | +@class QtDataSync::UserInfo |
| 3 | + |
| 4 | +This class is used by the UserExchangeManager class to provide information about discovered |
| 5 | +users. The name can be choosen by the remote that sent the user information, address and port |
| 6 | +are detected from the message. |
| 7 | + |
| 8 | +@sa UserExchangeManager, UserExchangeManager::devices |
| 9 | +*/ |
| 10 | + |
| 11 | +/*! |
| 12 | +@property QtDataSync::UserInfo::name |
| 13 | + |
| 14 | +@default{`"<Unnamed>"` (Translated)} |
| 15 | + |
| 16 | +The name can be choosen by whoever sent the message. It is |
| 17 | +typically used to identify a device from a users view. |
| 18 | + |
| 19 | +@accessors{ |
| 20 | + @readAc{name()} |
| 21 | + @constantAc |
| 22 | +} |
| 23 | + |
| 24 | +@sa UserExchangeManager::deviceName |
| 25 | +*/ |
| 26 | + |
| 27 | +/*! |
| 28 | +@property QtDataSync::UserInfo::address |
| 29 | + |
| 30 | +@default{<i>Unknown</i>} |
| 31 | + |
| 32 | +The address from where the message came. Is also used |
| 33 | +as target address to send a message back. |
| 34 | + |
| 35 | +@accessors{ |
| 36 | + @readAc{address()} |
| 37 | + @constantAc |
| 38 | +} |
| 39 | + |
| 40 | +@sa UserInfo::port |
| 41 | +*/ |
| 42 | + |
| 43 | +/*! |
| 44 | +@property QtDataSync::UserInfo::port |
| 45 | + |
| 46 | +@default{<i>Unknown</i>} |
| 47 | + |
| 48 | +The port from where the message came. Is also used |
| 49 | +as target port to send a message back. |
| 50 | + |
| 51 | +@accessors{ |
| 52 | + @readAc{port()} |
| 53 | + @constantAc |
| 54 | +} |
| 55 | + |
| 56 | +@sa UserInfo::address |
| 57 | +*/ |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +/*! |
| 62 | +@class QtDataSync::UserExchangeManager |
| 63 | + |
| 64 | +This class can be used to exchange the user identity af a setup via the local network. It |
| 65 | +provides an easy way to transfer the identity between devices, without any need of external |
| 66 | +transport mediums to get the exported data to another device. |
| 67 | + |
| 68 | +@note The class makes use of UDP-Broadcasts to discover other devices on the local network. |
| 69 | +This only works if both devices have an active UserExchangeManager running and if the network |
| 70 | +they both are connected to supports broadcasts. It does <b>not</b> work across networks. |
| 71 | + |
| 72 | +@sa AccountManager |
| 73 | +*/ |
| 74 | + |
| 75 | +/*! |
| 76 | +@property QtDataSync::UserExchangeManager::active |
| 77 | + |
| 78 | +@default{`false`} |
| 79 | + |
| 80 | +The UserExchangeManager is considered active when actively searching for other devices, ready |
| 81 | +to export or import data from and to other devices. |
| 82 | + |
| 83 | +When inactive, the device is disconnected from the network and does not send or receive any |
| 84 | +data. |
| 85 | + |
| 86 | +@accessors{ |
| 87 | + @readAc{isActive()} |
| 88 | + @notifyAc{activeChanged()} |
| 89 | +} |
| 90 | + |
| 91 | +@sa UserExchangeManager::startExchange, UserExchangeManager::stopExchange |
| 92 | +*/ |
| 93 | + |
| 94 | +/*! |
| 95 | +@property QtDataSync::UserExchangeManager::devices |
| 96 | + |
| 97 | +@default{<i>Empty</i>} |
| 98 | + |
| 99 | +This list contains all devices discovered on the local network (excluding yourself). It only can |
| 100 | +find devices that have the exchange active on the same port. The list will only contain any |
| 101 | +users if active. |
| 102 | + |
| 103 | +@accessors{ |
| 104 | + @readAc{users()} |
| 105 | + @notifyAc{usersChanged()} |
| 106 | +} |
| 107 | + |
| 108 | +@sa UserInfo, UserExchangeManager::active, UserExchangeManager::userDataReceived, |
| 109 | +UserExchangeManager::exportTo, UserExchangeManager::exportTrustedTo, |
| 110 | +UserExchangeManager::importFrom, UserExchangeManager::importTrustedFrom |
| 111 | +*/ |
| 112 | + |
| 113 | +/*! |
| 114 | +@fn QtDataSync::UserExchangeManager::UserExchangeManager(AccountManager *, QObject *) |
| 115 | + |
| 116 | +@param manager The account manager to use to import and export account data |
| 117 | +@param parent The parent object |
| 118 | + |
| 119 | +@attention The exchange manager does **not** take ownership of the passed account manager. Thus, |
| 120 | +the account manager must stay valid as long as the exchange manager exists. |
| 121 | +*/ |
| 122 | + |
| 123 | +/*! |
| 124 | +@fn QtDataSync::UserExchangeManager::accountManager |
| 125 | + |
| 126 | +@returns A pointer to the interal account manager object |
| 127 | + |
| 128 | +Returns a reference to the internally used manager. The manager is only valid as long as the |
| 129 | +UserExchangeManager exists. You can use the manager reference to get information about it's |
| 130 | +state etc. |
| 131 | +*/ |
| 132 | + |
| 133 | +/*! |
| 134 | +@fn QtDataSync::UserExchangeManager::port |
| 135 | + |
| 136 | +@returns The currently used port, if active |
| 137 | + |
| 138 | +The returned port is only valid whne activly exchanging. Can be used to retrieve the choosen |
| 139 | +port when working with random ports. If not connected, 0 is returned |
| 140 | + |
| 141 | +@sa UserExchangeManager::active, UserExchangeManager::startExchange |
| 142 | +*/ |
| 143 | + |
| 144 | +/*! |
| 145 | +@fn QtDataSync::UserExchangeManager::exportTo |
| 146 | + |
| 147 | +@param userInfo The user to send the identity to |
| 148 | +@param includeServer Specify whether the server address and configuration should be included |
| 149 | +into the export data |
| 150 | + |
| 151 | +The identity of the current user for the setup used on this instance is exported and sent to the |
| 152 | +address represented by the passed userInfo. The userInfo should be a user discovered by the |
| 153 | +exchange from UserExchangeManager::devices |
| 154 | + |
| 155 | +Internally, AccountManager::exportAccount is used to perform the actual export. That data is |
| 156 | +then sent over the network to the partner device. See that documentation for more details. |
| 157 | + |
| 158 | +@sa UserExchangeManager::userDataReceived, UserExchangeManager::importFrom, |
| 159 | +UserExchangeManager::exportTrustedTo, AccountManager::exportAccount |
| 160 | +*/ |
| 161 | + |
| 162 | +/*! |
| 163 | +@fn QtDataSync::UserExchangeManager::exportTrustedTo |
| 164 | + |
| 165 | +@param userInfo The user to send the identity to |
| 166 | +@param includeServer Specify whether the server address and configuration should be included |
| 167 | +into the export data |
| 168 | +@param password The password used to encrypt the exported data with |
| 169 | + |
| 170 | +The identity of the current user for the setup used on this instance is exported and sent to the |
| 171 | +address represented by the passed userInfo. The userInfo should be a user discovered by the |
| 172 | +exchange from UserExchangeManager::devices |
| 173 | + |
| 174 | +Internally, AccountManager::exportAccountTrusted is used to perform the actual export. That data |
| 175 | +is then sent over the network to the partner device. See that documentation for more details. |
| 176 | + |
| 177 | +@sa UserExchangeManager::userDataReceived, UserExchangeManager::importTrustedFrom, |
| 178 | +UserExchangeManager::exportTo, AccountManager::exportAccountTrusted |
| 179 | +*/ |
| 180 | + |
| 181 | +/*! |
| 182 | +@fn QtDataSync::UserExchangeManager::importFrom |
| 183 | + |
| 184 | +@param userInfo The user to that sent the data to import |
| 185 | +@param completedFn A function that is called once the import has been finished |
| 186 | +@param keepData Specify whether the stored data should be preserved |
| 187 | + |
| 188 | +Use this method to perform the actual import of an identity after receiving it via |
| 189 | +userDataReceived(). This only works if data has been received from the user that way. Otherwise |
| 190 | +the operation will fail. |
| 191 | + |
| 192 | +Internally, AccountManager::importAccount is used to perform the actual import. The received |
| 193 | +data is simply passed to that method. See that documentation for more details. |
| 194 | + |
| 195 | +@sa UserExchangeManager::userDataReceived, UserExchangeManager::exportTo, |
| 196 | +UserExchangeManager::importTrustedFrom, AccountManager::importAccount |
| 197 | +*/ |
| 198 | + |
| 199 | +/*! |
| 200 | +@fn QtDataSync::UserExchangeManager::importTrustedFrom |
| 201 | + |
| 202 | +@param userInfo The user to that sent the data to import |
| 203 | +@param password The password used to decrypt the imported data with. Must be the same as used |
| 204 | +for the export |
| 205 | +@param completedFn A function that is called once the import has been finished |
| 206 | +@param keepData Specify whether the stored data should be preserved |
| 207 | + |
| 208 | +Use this method to perform the actual import of an identity after receiving it via |
| 209 | +userDataReceived(). This only works if data has been received from the user that way. Otherwise |
| 210 | +the operation will fail. |
| 211 | + |
| 212 | +Internally, AccountManager::importAccountTrusted is used to perform the actual import. The |
| 213 | +received data is simply passed to that method. See that documentation for more details. |
| 214 | + |
| 215 | +@sa UserExchangeManager::userDataReceived, UserExchangeManager::exportTrustedTo, |
| 216 | +UserExchangeManager::importFrom, AccountManager::importAccountTrusted |
| 217 | +*/ |
| 218 | + |
| 219 | +/*! |
| 220 | +@fn QtDataSync::UserExchangeManager::startExchange(quint16) |
| 221 | + |
| 222 | +@param port The port to start the exchange on |
| 223 | +@returns true, if successfully started, false if not |
| 224 | + |
| 225 | +The exchange is run for all addresses, allowing connections from anywhere and broadcasting to |
| 226 | +anyone in the local network. |
| 227 | + |
| 228 | +If the function fails, the error string describing what went wrong is emitted via |
| 229 | +exchangeError(). |
| 230 | + |
| 231 | +@sa UserExchangeManager::active, UserExchangeManager::exchangeError, |
| 232 | +UserExchangeManager::stopExchange |
| 233 | +*/ |
| 234 | + |
| 235 | +/*! |
| 236 | +@fn QtDataSync::UserExchangeManager::startExchange(const QHostAddress &, quint16) |
| 237 | + |
| 238 | +@param listenAddress The address to listen on for incoming messages |
| 239 | +@param port The port to start the exchange on |
| 240 | +@returns true, if successfully started, false if not |
| 241 | + |
| 242 | +The exchange is run for the given addresses, allowing connections only from addresses matching |
| 243 | +the given address and broadcasting to anyone in the local network. |
| 244 | + |
| 245 | +If the function fails, the error string describing what went wrong is emitted via |
| 246 | +exchangeError(). |
| 247 | + |
| 248 | +@sa UserExchangeManager::active, UserExchangeManager::exchangeError, |
| 249 | +UserExchangeManager::stopExchange |
| 250 | +*/ |
| 251 | + |
| 252 | +/*! |
| 253 | +@fn QtDataSync::UserExchangeManager::stopExchange |
| 254 | + |
| 255 | +Stops sending and receiving messages, clears all users and pending imports. After stopping, |
| 256 | +this device disappears from the network and can neither be discovered by other exchanges, nor |
| 257 | +discover them. |
| 258 | + |
| 259 | +@sa UserExchangeManager::active, UserExchangeManager::startExchange |
| 260 | +*/ |
| 261 | + |
| 262 | +/*! |
| 263 | +@fn QtDataSync::UserExchangeManager::userDataReceived |
| 264 | + |
| 265 | +@param userInfo The user that sent his identity to this device |
| 266 | +@param trusted `true` if the received data is a trusted export, `false` if it is untrusted |
| 267 | + |
| 268 | +When a user exports his identity to this device via exportTo() or exportTrustedTo(), this signal |
| 269 | +is emitted. Connect to it to react an proposed identity data. The data is <b>not</b> imported |
| 270 | +immediatly. You can use the importFrom() and importTrustedFrom() methods to perform the actual |
| 271 | +import of the data, if you want to accept it. Choose the correct import method based on the |
| 272 | +`trusted` parameter. |
| 273 | + |
| 274 | +@sa UserExchangeManager::importFrom, UserExchangeManager::importTrustedFrom, |
| 275 | +UserExchangeManager::exportTo, UserExchangeManager::exportTrustedTo |
| 276 | +*/ |
| 277 | + |
| 278 | +/*! |
| 279 | +@fn QtDataSync::UserExchangeManager::exchangeError |
| 280 | + |
| 281 | +@param errorString A localized error string describing what went wrong |
| 282 | + |
| 283 | +Can be shown to the user to tell him something regarding the import or export (or the general |
| 284 | +exchange) failed. |
| 285 | +*/ |
0 commit comments