| 32 | static constexpr int RET_CODE_CHANGE_SAVE_LOCATION_TYPE = 1234; |
| 33 | |
| 34 | RetVal<SaveLocation> OpenSaveProjectScenario::askSaveLocation(IAudacityProjectPtr project, SaveMode mode, |
| 35 | SaveLocationType preselectedType) const |
| 36 | { |
| 37 | SaveLocationType type = preselectedType; |
| 38 | |
| 39 | if (type == SaveLocationType::Undefined) { |
| 40 | RetVal<SaveLocationType> askedType = saveLocationType(); |
| 41 | if (!askedType.ret) { |
| 42 | return askedType.ret; |
| 43 | } |
| 44 | |
| 45 | type = askedType.val; |
| 46 | } |
| 47 | |
| 48 | IF_ASSERT_FAILED(type != SaveLocationType::Undefined) { |
| 49 | return make_ret(Ret::Code::UnknownError); |
| 50 | } |
| 51 | |
| 52 | // The user may switch between Local and Cloud as often as they want |
| 53 | for (;;) { |
| 54 | configuration()->setLastUsedSaveLocationType(type); |
| 55 | |
| 56 | switch (type) { |
| 57 | case SaveLocationType::Undefined: |
| 58 | return make_ret(Ret::Code::UnknownError); |
| 59 | |
| 60 | case SaveLocationType::Local: { |
| 61 | RetVal<muse::io::path_t> path = askLocalPath(project, mode); |
| 62 | switch (path.ret.code()) { |
| 63 | case int(Ret::Code::Ok): { |
| 64 | return RetVal<SaveLocation>::make_ok(SaveLocation(path.val)); |
| 65 | } |
| 66 | case RET_CODE_CHANGE_SAVE_LOCATION_TYPE: |
| 67 | type = SaveLocationType::Cloud; |
| 68 | continue; |
| 69 | default: |
| 70 | return path.ret; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | case SaveLocationType::Cloud: { |
| 75 | RetVal<CloudProjectInfo> info = askCloudLocation(project, mode); |
| 76 | switch (info.ret.code()) { |
| 77 | case int(Ret::Code::Ok): |
| 78 | return RetVal<SaveLocation>::make_ok(SaveLocation(info.val)); |
| 79 | case RET_CODE_CHANGE_SAVE_LOCATION_TYPE: |
| 80 | type = SaveLocationType::Local; |
| 81 | continue; |
| 82 | default: |
| 83 | return info.ret; |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | RetVal<muse::io::path_t> OpenSaveProjectScenario::askLocalPath(IAudacityProjectPtr project, SaveMode saveMode) const |
| 91 | { |
no test coverage detected