MCPcopy Create free account
hub / github.com/IENT/YUView / startCheckForNewVersion

Method startCheckForNewVersion

YUViewLib/src/handler/UpdateHandler.cpp:126–172  ·  view source on GitHub ↗

Start the asynchronous checking for an update.

Source from the content-addressed store, hash-verified

124
125// Start the asynchronous checking for an update.
126void updateHandler::startCheckForNewVersion(bool userRequest, bool force)
127{
128 QSettings settings;
129 settings.beginGroup("updates");
130 bool checkForUpdates = settings.value("checkForUpdates", true).toBool();
131 forceUpdate = force;
132 settings.endGroup();
133 if (!userRequest && !checkForUpdates && !forceUpdate)
134 // The user did not request this, we are not automatocally checking for updates and it is not a forced check. Abort.
135 return;
136
137 if (updaterStatus != updaterIdle)
138 // The updater is busy. Do not start another check for updates.
139 return;
140
141 if (UPDATE_FEATURE_ENABLE && is_Q_OS_WIN)
142 {
143 // We are on windows and the update feature is available.
144 // Check the Github repository branch binariesAutoUpdate if there is a new version of the YUView executable available.
145 // First we will try to establish a secure connection to raw.githubusercontent.com
146#if ALLOW_UNENCRYPTED_CONNECTIONS
147 DEBUG_UPDATE("updateHandler::startCheckForNewVersion connectToHost raw.githubusercontent.com");
148 updaterStatus = updaterEstablishConnection;
149 userCheckRequest = userRequest;
150 networkManager.connectToHost("raw.githubusercontent.com");
151#else
152 DEBUG_UPDATE("updateHandler::startCheckForNewVersion connectToHostEncrypted raw.githubusercontent.com");
153 updaterStatus = updaterEstablishConnection;
154 userCheckRequest = userRequest;
155 networkManager.connectToHostEncrypted("raw.githubusercontent.com");
156#endif
157 }
158 else if (VERSION_CHECK)
159 {
160 // We can check the Github API for the commit hash. After that we can say if there is a new version available on Github.
161 updaterStatus = updaterChecking;
162 userCheckRequest = userRequest;
163 DEBUG_UPDATE("updateHandler::startCheckForNewVersion get https://api.github.com/repos/IENT/YUView/commits");
164 networkManager.get(QNetworkRequest(QUrl("https://api.github.com/repos/IENT/YUView/commits")));
165 }
166 else
167 {
168 // We don't know the current version. We cannot check if there is a newer one.
169 if (userRequest)
170 QMessageBox::information(mainWidget, "Can not check for updates", "Unfortunately no version information has been compiled into this YUView version. Because of this we cannot check for updates.");
171 }
172}
173
174// There is an answer from the server.
175void updateHandler::replyFinished(QNetworkReply *reply)

Callers 2

autoUpdateCheckMethod · 0.80
createMenusAndActionsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected