|
| 1 | +/*! |
| 2 | +@class QtAutoUpdater::ProcessBackend |
| 3 | + |
| 4 | +When your custom updater plugin primarily uses some kind of commandline tool to check and install |
| 5 | +updates, using this class makes implementing such a plugin much easier than using UpdaterBackend |
| 6 | +directly. You should prefer this base class in such cases, unless there is a specific reason to not |
| 7 | +do so. |
| 8 | + |
| 9 | +@sa QtAutoUpdater::UpdaterBackend, QProcess |
| 10 | +*/ |
| 11 | + |
| 12 | +/*! |
| 13 | +@fn QtAutoUpdater::ProcessBackend::readPathList |
| 14 | + |
| 15 | +@param value The variant value to be parsed |
| 16 | +@returns A string list of paths extracted from the value |
| 17 | + |
| 18 | +This method first checks the value. If it already is a QStringList, it is simply returned as one. |
| 19 | +If not, the value is converted to a QString and the split using QString::split with the given |
| 20 | +native path seperator (QDir::listSeparator) to create a string list from it. |
| 21 | + |
| 22 | +Use this method over readStringList() when the list you are reading contains paths, as paths may |
| 23 | +contain spaces and other unexpected symbols. Using the native path seperator is the only safe way |
| 24 | +of splitting paths. |
| 25 | + |
| 26 | +@sa UpdaterBackend::readStringList, ProcessBackend::readArgumentList, QDir::listSeparator, |
| 27 | +QString::split |
| 28 | +*/ |
| 29 | + |
| 30 | +/*! |
| 31 | +@fn QtAutoUpdater::ProcessBackend::readArgumentList |
| 32 | + |
| 33 | +@param value The variant value to be parsed |
| 34 | +@returns A string list of arguments extracted from the value |
| 35 | + |
| 36 | +This method first checks the value. If it already is a QStringList, it is simply returned as one. |
| 37 | +If not, the value is converted to a QString and then parsed. The parsing tries to seperate the string |
| 38 | +into quoted arguments, as they would be passed on a commandline. The arguments are split by spaces, |
| 39 | +but single and double quoted as well as backslash escaped characters are respected. For example, the |
| 40 | +following string would be seperated as shown below: |
| 41 | + |
| 42 | +@code{.cpp} |
| 43 | +QString string = "hello world \"this is super\" and\\ very' use\"ful'" |
| 44 | +QStringList list = readArgumentList(string); |
| 45 | +// results in: |
| 46 | +{ |
| 47 | + "hello", |
| 48 | + "world", |
| 49 | + "this is super", |
| 50 | + "and very use\"ful" |
| 51 | +} |
| 52 | +@endcode |
| 53 | + |
| 54 | +@sa UpdaterBackend::readStringList, ProcessBackend::readPathList |
| 55 | +*/ |
| 56 | + |
| 57 | +/*! |
| 58 | +@fn QtAutoUpdater::ProcessBackend::runUpdateTool |
| 59 | + |
| 60 | +@param id An internal identifier for the started process |
| 61 | +@param toolInfo The information about how to start the process |
| 62 | + |
| 63 | +Call this method from checkForUpdates() to start a tool that performs the update check. The toolInfo |
| 64 | +struct holds all information about the process required to run it. The id is used to identify the |
| 65 | +process when it finished via onToolDone(). |
| 66 | + |
| 67 | +@note A process started this way will only emit onToolDone() if it executed without a crash. If it |
| 68 | +does crash, checkDone(false) is emitted automatically. If it does not crash, onToolDone() is called, |
| 69 | +even if the exit code is not 0. In that case, you are responsible for emitting that signal. |
| 70 | + |
| 71 | +@sa ProcessBackend::UpdateProcessInfo, ProcessBackend::cancelUpdateTool, ProcessBackend::onToolDone, |
| 72 | +UpdaterBackend::checkDone |
| 73 | +*/ |
| 74 | + |
| 75 | +/*! |
| 76 | +@fn QtAutoUpdater::ProcessBackend::cancelUpdateTool |
| 77 | + |
| 78 | +@param id The internal identifier of the process to be canceled |
| 79 | +@param kill Specify if the process should be terminated or killed |
| 80 | + |
| 81 | +Call this method to stop a running process prematurely. If kill is true, QProcess::kill will be used |
| 82 | +to stop the process, QProcess::terminate otherwise. In both cases, the result handling stays the |
| 83 | +same. If the signal crashes the process, that is handled automatically. Otherwise onToolDone() is |
| 84 | +called. |
| 85 | + |
| 86 | +@note The implementation of abort() of this class already does this automatically. Only use this |
| 87 | +method yourself, if you have to cancel a process for another reason. |
| 88 | + |
| 89 | +@sa ProcessBackend::runUpdateTool, ProcessBackend::onToolDone |
| 90 | +*/ |
| 91 | + |
| 92 | +/*! |
| 93 | +@fn QtAutoUpdater::ProcessBackend::onToolDone |
| 94 | + |
| 95 | +@param id The internal identifier of the finished process |
| 96 | +@param exitCode The code the process exited with |
| 97 | +@param processDevice The process as QIODevice to read data from it. |
| 98 | + |
| 99 | +This method gets called by the library if a process that was started via runUpdateTool() finished |
| 100 | +without crashing. The id is same as passed to runUpdateTool(), the exit code is the one that the |
| 101 | +process returned. processDevice is set depending on the UpdateProcessInfo that was used to run the |
| 102 | +tool, as shown in the table below: |
| 103 | + |
| 104 | + useStdout | useStderr | processDevice state |
| 105 | +------------|-----------|--------------------- |
| 106 | + false | false | `nullptr` |
| 107 | + false | true | `QProcess*`, with stderr as active read channel |
| 108 | + true | false | `QProcess*`, with stdout as active read channel |
| 109 | + true | true | `QProcess*`, with stdout as active read channel |
| 110 | + |
| 111 | +From withing this function, you should emit the checkDone() signals according to how you interpret |
| 112 | +the result exit code and output as soon as the last process you started finished. |
| 113 | + |
| 114 | +@sa ProcessBackend::runUpdateTool, ProcessBackend::cancelUpdateTool, |
| 115 | +ProcessBackend::UpdateProcessInfo, UpdaterBackend::checkDone |
| 116 | +*/ |
| 117 | + |
| 118 | +/*! |
| 119 | +@fn QtAutoUpdater::ProcessBackend::installerInfo |
| 120 | + |
| 121 | +@param infos A list of update infos to be updated |
| 122 | +@param track Specifies if the installers execution should be tracked |
| 123 | +@returns An optional install process information, if supported |
| 124 | + |
| 125 | +This method is called from this classes triggerUpdates() implementation to get information about the |
| 126 | +process to be launched as external installer. If your backend does support launching an installer, |
| 127 | +return a valid information here. If it does not, return `nullopt` to communicate this to the |
| 128 | +library. |
| 129 | + |
| 130 | +@note For this method to ever be called from the library, features() must have the |
| 131 | +UpdaterBackend::Feature::TriggerInstall flag set. Track can only be true if features() has the |
| 132 | +UpdaterBackend::Feature::ParallelTrigger flag set. |
| 133 | + |
| 134 | +The launching, monitoring and handling of stdin/stderr/stdout is done automatically and |
| 135 | +triggerInstallDone() will also be emitted completely automatically if the process is tracked and |
| 136 | +did finish. After this method was called, you don't have to do anything regaring the triggered |
| 137 | +install anymore. |
| 138 | + |
| 139 | +@sa UpdaterBackend::triggerUpdates, ProcessBackend::InstallProcessInfo, UpdaterBackend::features(), |
| 140 | +UpdaterBackend::Feature |
| 141 | +*/ |
0 commit comments