Changeset View
Changeset View
Standalone View
Standalone View
kded/engine/vault.cpp
Show First 20 Lines • Show All 203 Lines • ▼ Show 20 Line(s) | 198 | return | |||
---|---|---|---|---|---|
204 | // If the mount point is empty, we can not do anything | 204 | // If the mount point is empty, we can not do anything | ||
205 | vaultData.mountPoint.isEmpty() ? | 205 | vaultData.mountPoint.isEmpty() ? | ||
206 | errorData(Error::MountPointError, | 206 | errorData(Error::MountPointError, | ||
207 | i18n("Mount point is not specified")) : | 207 | i18n("Mount point is not specified")) : | ||
208 | 208 | | |||
209 | // Lets try to create the mount point | 209 | // Lets try to create the mount point | ||
210 | !mountPointDir.exists() && !QDir().mkpath(vaultData.mountPoint) ? | 210 | !mountPointDir.exists() && !QDir().mkpath(vaultData.mountPoint) ? | ||
211 | errorData(Error::MountPointError, | 211 | errorData(Error::MountPointError, | ||
212 | i18n("Can not create the mount point")) : | 212 | i18n("Cannot create the mount point")) : | ||
213 | 213 | | |||
214 | // Instantiate the backend if possible | 214 | // Instantiate the backend if possible | ||
215 | !(vaultData.backend = Backend::instance(vaultData.backendName)) ? | 215 | !(vaultData.backend = Backend::instance(vaultData.backendName)) ? | ||
216 | errorData(Error::BackendError, | 216 | errorData(Error::BackendError, | ||
217 | i18n("Configured backend can not be instantiated: %1", vaultData.backendName)) : | 217 | i18n("Configured backend cannot be instantiated: %1", vaultData.backendName)) : | ||
218 | 218 | | |||
219 | // otherwise | 219 | // otherwise | ||
220 | ExpectedData::success(vaultData); | 220 | ExpectedData::success(vaultData); | ||
221 | } | 221 | } | ||
222 | 222 | | |||
223 | 223 | | |||
224 | 224 | | |||
225 | Private(Vault *parent, const Device &device) | 225 | Private(Vault *parent, const Device &device) | ||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | |||||
307 | { | 307 | { | ||
308 | using namespace AsynQt::operators; | 308 | using namespace AsynQt::operators; | ||
309 | 309 | | |||
310 | return | 310 | return | ||
311 | // If the backend is already known, and the device is initialized, | 311 | // If the backend is already known, and the device is initialized, | ||
312 | // we do not want to do it again | 312 | // we do not want to do it again | ||
313 | d->data && d->data->backend->isInitialized(d->device) ? | 313 | d->data && d->data->backend->isInitialized(d->device) ? | ||
314 | errorResult(Error::DeviceError, | 314 | errorResult(Error::DeviceError, | ||
315 | i18n("This device is already registered. Can not recreate it.")) : | 315 | i18n("This device is already registered. Cannot recreate it.")) : | ||
316 | 316 | | |||
317 | // Mount not open, check the error messages | 317 | // Mount not open, check the error messages | ||
318 | !(d->data = d->loadVault(d->device, name, mountPoint, payload)) ? | 318 | !(d->data = d->loadVault(d->device, name, mountPoint, payload)) ? | ||
319 | errorResult(Error::BackendError, | 319 | errorResult(Error::BackendError, | ||
320 | i18n("Unknown error, unable to create the backend.")) : | 320 | i18n("Unknown error, unable to create the backend.")) : | ||
321 | 321 | | |||
322 | // otherwise | 322 | // otherwise | ||
323 | d->followFuture(VaultInfo::Creating, | 323 | d->followFuture(VaultInfo::Creating, | ||
Show All 12 Lines | |||||
336 | 336 | | |||
337 | 337 | | |||
338 | FutureResult<> Vault::open(const Payload &payload) | 338 | FutureResult<> Vault::open(const Payload &payload) | ||
339 | { | 339 | { | ||
340 | return | 340 | return | ||
341 | // We can not mount something that has not been registered | 341 | // We can not mount something that has not been registered | ||
342 | // with us before | 342 | // with us before | ||
343 | !d->data ? errorResult(Error::BackendError, | 343 | !d->data ? errorResult(Error::BackendError, | ||
344 | i18n("Can not open an unknown vault.")) : | 344 | i18n("Cannot open an unknown vault.")) : | ||
345 | 345 | | |||
346 | // otherwise | 346 | // otherwise | ||
347 | d->followFuture(VaultInfo::Opening, | 347 | d->followFuture(VaultInfo::Opening, | ||
348 | d->data->backend->open(d->device, d->data->mountPoint, payload)); | 348 | d->data->backend->open(d->device, d->data->mountPoint, payload)); | ||
349 | } | 349 | } | ||
350 | 350 | | |||
351 | 351 | | |||
352 | 352 | | |||
353 | FutureResult<> Vault::close() | 353 | FutureResult<> Vault::close() | ||
354 | { | 354 | { | ||
355 | using namespace AsynQt::operators; | 355 | using namespace AsynQt::operators; | ||
356 | 356 | | |||
357 | return | 357 | return | ||
358 | // We can not mount something that has not been registered | 358 | // We can not mount something that has not been registered | ||
359 | // with us before | 359 | // with us before | ||
360 | !d->data ? errorResult(Error::BackendError, | 360 | !d->data ? errorResult(Error::BackendError, | ||
361 | i18n("The vault is unknown, can not close it.")) : | 361 | i18n("The vault is unknown, cannot close it.")) : | ||
362 | 362 | | |||
363 | // otherwise | 363 | // otherwise | ||
364 | d->followFuture(VaultInfo::Closing, | 364 | d->followFuture(VaultInfo::Closing, | ||
365 | d->data->backend->close(d->device, d->data->mountPoint)) | 365 | d->data->backend->close(d->device, d->data->mountPoint)) | ||
366 | | onSuccess([this] (const Result<> &result) { | 366 | | onSuccess([this] (const Result<> &result) { | ||
367 | if (!isOpened() || result) { | 367 | if (!isOpened() || result) { | ||
368 | d->updateMessage(QString()); | 368 | d->updateMessage(QString()); | ||
369 | 369 | | |||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Line(s) | |||||
459 | 459 | | |||
460 | 460 | | |||
461 | FutureResult<> Vault::destroy(const Payload &payload) | 461 | FutureResult<> Vault::destroy(const Payload &payload) | ||
462 | { | 462 | { | ||
463 | return | 463 | return | ||
464 | // We can not mount something that has not been registered | 464 | // We can not mount something that has not been registered | ||
465 | // with us before | 465 | // with us before | ||
466 | !d->data ? errorResult(Error::BackendError, | 466 | !d->data ? errorResult(Error::BackendError, | ||
467 | i18n("The vault is unknown, can not destroy it.")) : | 467 | i18n("The vault is unknown, cannot destroy it.")) : | ||
468 | 468 | | |||
469 | // otherwise | 469 | // otherwise | ||
470 | d->followFuture(VaultInfo::Destroying, | 470 | d->followFuture(VaultInfo::Destroying, | ||
471 | d->data->backend->destroy(d->device, d->data->mountPoint, payload)); | 471 | d->data->backend->destroy(d->device, d->data->mountPoint, payload)); | ||
472 | } | 472 | } | ||
473 | 473 | | |||
474 | 474 | | |||
475 | 475 | | |||
▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines |