|
| 1 | +--- |
| 2 | +id: PluginInterface |
| 3 | +title: AppImage Updater Bridge Plugin Interface |
| 4 | +sidebar_label: Qt Plugin Interface |
| 5 | +--- |
| 6 | + |
| 7 | +A plugin interface is a specification of public slots and signals that can be used to access |
| 8 | +the functionality of the plugin itself. The interface is not bound to any specific programming |
| 9 | +language and easily translates to any Qt bindings and programming language. |
| 10 | + |
| 11 | +All slots are [reentrant](https://doc.qt.io/qt-5/threads-reentrancy.html) and thread safe. |
| 12 | + |
| 13 | +Please refer the C++ documentation for info on how the slots act. |
| 14 | + |
| 15 | +> IMPORTANT: You have to start your Qt event loop for AppImageUpdaterBridge to function. |
| 16 | +
|
| 17 | +### A note on Data Types |
| 18 | + |
| 19 | +Since plugins are not C++ specific, The data types are vaguely defined. |
| 20 | +In dynamic languages like python, you can just use native data types. (i.e) For QString, you can use str or QString from your Qt binding itself. |
| 21 | + |
| 22 | +I'm not sure about other Qt bindings, So help is much welcomed. |
| 23 | + |
| 24 | +## Slots |
| 25 | + |
| 26 | +| Name | Description | |
| 27 | +|------|------------------------------------| |
| 28 | +| [start()](#start) | Starts the update. | |
| 29 | +| [cancel()](#cancel) | Cancels current update process. | |
| 30 | +| [setAppImage(QString)](#setappimage-qstring) | Assume the given string as path to AppImage to update. | |
| 31 | +| [setShowLog(bool)](#setshowlogbool) | If the given boolean is true then prints log. | |
| 32 | +| [setOutputDirectory(QString)](#setoutputdirectory-qstring) | Set the output directory as given string. | |
| 33 | +| [setProxy(QNetworkProxy)](#setproxyconst-qnetworkproxy-https-docqtio-qt-5-qnetworkproxyhtml) | Use proxy as given in QNetworkProxy object. | |
| 34 | +| [checkForUpdate()](#checkforupdate) | Checks for new update. | |
| 35 | +| [clear()](#clear) | Clears internal cache and stores. | |
| 36 | + |
| 37 | +## Signals |
| 38 | + |
| 39 | +| Name | Description | |
| 40 | +|------|---------------| |
| 41 | +| [started()](#started) | Emitted when the update is actually started. | |
| 42 | +| [canceled()](#canceled) | Emitted when the update is canceled. | |
| 43 | +| [finished(QJsonObject , QString)](#finishedqjsonobject-qstring) | Emitted when update finishes. | |
| 44 | +| [updateAvailable(bool, QJsonObject)](#updateavailablebool-qjsonobject) | Emitted when checkForUpdate() is called. | |
| 45 | +| [error(short)](#errorshort) | Emitted when some error occurs. | |
| 46 | +| [progress(int, qint64, qint64, double, QString)](#progressint-percentage--qint64-bytesreceived--qint64-bytestotal--double-speed--qstring-speedunits) | Emitted on progress of update. See here for more information. | |
| 47 | +| [logger(QString, QString)](#loggerqstring-qstring) | See here for more information. | |
| 48 | + |
| 49 | + |
| 50 | +## Documentation |
| 51 | + |
| 52 | +### start() |
| 53 | +<p align="right"> <b>[SLOT]</b> </p> |
| 54 | + |
| 55 | +Starts the updater. |
| 56 | +Emits **started()** signal when starts. |
| 57 | + |
| 58 | + |
| 59 | +> Minor Note: You don't have to worry about anything if you called checkForUpdate or getAppImageEmbededInformation |
| 60 | +slots before start , Don't worry about overheads too , Since when you call checkForUpdate slot , The information |
| 61 | +is cached and when start slot is called again , it will be faster than normal. |
| 62 | + |
| 63 | +> Important Note: You should also call clear and set the settings again if you want to clear the cache. |
| 64 | +
|
| 65 | +### cancel() |
| 66 | +<p align="right"> <b>[SLOT]</b> </p> |
| 67 | + |
| 68 | +Cancels the update. |
| 69 | +Emits **canceled()** signal when cancel was successfull. |
| 70 | + |
| 71 | + |
| 72 | +### setAppImage(QString) |
| 73 | +<p align="right"> <b>[SLOT]</b> </p> |
| 74 | + |
| 75 | +Sets the AppImage Path as the given **QString**. |
| 76 | + |
| 77 | + |
| 78 | +### setShowLog(bool) |
| 79 | +<p align="right"> <b>[SLOT]</b> </p> |
| 80 | + |
| 81 | +Turns on and off the log printer. |
| 82 | + |
| 83 | +> Note: logger signal will be emitted all the time if the library is compiled with LOGGING_DISABLED undefined, |
| 84 | +setShowLog will not affect this activity at all, But setShowLog will print these log messages |
| 85 | +if set to true. |
| 86 | + |
| 87 | +### setOutputDirectory(QString) |
| 88 | +<p align="right"> <b>[SLOT]</b> </p> |
| 89 | + |
| 90 | +Writes the new version of the AppImage to the given Output directory , Assuming the given QString a directory path. |
| 91 | +The default is the old version AppImage's directory. |
| 92 | + |
| 93 | + |
| 94 | +### setProxy([QNetworkProxy](https://doc.qt.io/qt-5/qnetworkproxy.html)) |
| 95 | +<p align="right"> <b>[SLOT]</b> </p> |
| 96 | + |
| 97 | +Sets the given [QNetworkProxy](https://doc.qt.io/qt-5/qnetworkproxy.html) as the proxy |
| 98 | + |
| 99 | +### checkForUpdate() |
| 100 | +<p align="right"> <b>[SLOT]</b> </p> |
| 101 | + |
| 102 | +Checks update for the current operating AppImage. |
| 103 | +emits **updateAvailable(bool , QJsonObject)** , Where the *bool* will be **true** if the AppImage |
| 104 | +needs update. The QJsonObject in the signal will have the details of the current operating |
| 105 | +AppImage. |
| 106 | + |
| 107 | + |
| 108 | +### clear() |
| 109 | +<p align="right"> <b>[SLOT]</b> </p> |
| 110 | + |
| 111 | +Clears all internal **cache** and stores. |
| 112 | + |
| 113 | + |
| 114 | +### started() |
| 115 | +<p align="right"> <b>[SIGNAL]</b> </p> |
| 116 | + |
| 117 | +Emitted when the updater is started successfully. |
| 118 | + |
| 119 | +### canceled() |
| 120 | +<p align="right"> <b>[SIGNAL]</b> </p> |
| 121 | + |
| 122 | +Emitted when the update is canceled successfully. |
| 123 | + |
| 124 | +### finished(QJsonObject , QString) |
| 125 | +<p align="right"> <b>[SIGNAL]</b> </p> |
| 126 | + |
| 127 | +Emitted when the update is finished successfully. The given *QJsonObject* has the details of the new version |
| 128 | +of the AppImage and the given *QString* has the absolute path to the old versioin of the AppImage. |
| 129 | + |
| 130 | +The *QJsonObject* will follow the folloing format with respect to json , |
| 131 | + |
| 132 | + { |
| 133 | + "AbsolutePath" : "Absolute path of the new version of the AppImage" , |
| 134 | + "Sha1Hash" : "Sha1 hash of the new version of the AppImage" |
| 135 | + } |
| 136 | + |
| 137 | +> Note: If the absolute path of the new version of the AppImage is same as the old version then |
| 138 | +it could mean that there were no updates needed , You can however listen to the *updateAvailable* |
| 139 | +signal to know the exact state of updates. You should call *checkForUpdate* and then call *start* |
| 140 | +if updates were really available. |
| 141 | + |
| 142 | + |
| 143 | +### updateAvailable(bool , QJsonObject) |
| 144 | +<p align="right"> <b>[SIGNAL]</b> </p> |
| 145 | + |
| 146 | +Emitted when *[checkForUpdate()](#checkforupdate)* is called. |
| 147 | +The given *bool* states if the operating AppImage needs update and the *QJsonObject* gives the details of |
| 148 | +the current operating AppImage. |
| 149 | + |
| 150 | +The *QJsonObject* will follow the following format with respect to json , |
| 151 | + |
| 152 | + { |
| 153 | + "AbsolutePath" : "The absolute path of the current operating AppImage" , |
| 154 | + "Sha1Hash" : "The Sha1 hash of the current operating AppImage" , |
| 155 | + "RemoteSha1Hash" : "The Sha1 hash of the lastest AppImage" , |
| 156 | + "ReleaseNotes" : "Release notes if available" |
| 157 | + } |
| 158 | + |
| 159 | +### error(short) |
| 160 | +<p align="right"> <b>[SIGNAL]</b> </p> |
| 161 | + |
| 162 | +Emitted when the updater is errored. The given short integer is the error code. |
| 163 | +See [error codes](AppImageUpdaterBridgeErrorCodes.html). |
| 164 | + |
| 165 | + |
| 166 | +### progress(int percentage , qint64 bytesReceived , qint64 bytesTotal , double speed , QString speedUnits) |
| 167 | +<p align="right"> <b>[SIGNAL]</b> </p> |
| 168 | + |
| 169 | +The updater's progress is emitted through this unified signal. |
| 170 | + |
| 171 | +**Where** , |
| 172 | + |
| 173 | +| Variable | Description | |
| 174 | +|----------------|------------------------------------------------------------------| |
| 175 | +| percentage | % Finished revising the latest AppImage. | |
| 176 | +| bytesReceived | The received bytes of the latest AppImage. | |
| 177 | +| bytesTotal | The total bytes of the latest AppImage. | |
| 178 | +| speed | The transfer speed value. | |
| 179 | +| speedUnit | The transfer speed unit(e.g. KiB/s , etc... ) for **speed**. | |
| 180 | + |
| 181 | +### logger(QString , QString) |
| 182 | +<p align="right"> <b>[SIGNAL]</b> </p> |
| 183 | + |
| 184 | +Emitted when the updater issues a log message with the *first QString* as the log message and |
| 185 | +the *second QString* as the path to the respective AppImage. |
| 186 | + |
0 commit comments