17 #include <QDomDocument>
18 #include <QDomElement>
19 #include <QDomNodeList>
28 connect(
this, SIGNAL(readyReadStandardError()),
30 connect(
this, SIGNAL(readyReadStandardOutput()),
32 connect(
this, SIGNAL(finished(
int, QProcess::ExitStatus)),
33 this, SLOT(
onFinished(
int, QProcess::ExitStatus)));
35 setEnvironment(systemEnvironment());
43 args <<
"update" <<
"--force-check"
44 <<
" --controller-log-format"
48 args <<
"--socks-port=" + QString::number(
_socksPort);
52 vNotice(
"updater: launching auto-update executable: %1 %2")
65 args <<
"update" <<
"--controller-log-format"
69 args <<
"--socks-port=" + QString::number(
_socksPort);
73 vNotice(
"updater: launching auto-update executable: %1 %2")
90 return (state() != QProcess::NotRunning);
97 #if defined(Q_OS_WIN32)
111 QHash<QString,QString> args;
113 setReadChannel(QProcess::StandardError);
114 while (canReadLine()) {
115 line = readLine().trimmed();
116 vInfo(
"updater (stderr): %1").arg(line);
118 idx = line.indexOf(
" ");
119 if (idx < 0 || idx == line.length()-1)
121 type = line.mid(0, idx);
122 line = line.mid(idx + 1);
127 else if (line.startsWith(
"thandy.InstallFailed: ", Qt::CaseInsensitive)) {
138 if (! type.compare(
"CAN_INSTALL", Qt::CaseInsensitive)) {
139 QString
package = args.value("PKG");
140 if (! package.isEmpty()) {
146 && ! type.compare(
"DEBUG")
147 && args.value(
"msg").startsWith(
"Got ")) {
157 QStringList parts = args.value(
"msg").split(
" ");
158 if (parts.size() == 5) {
159 QStringList progress = parts.at(1).split(
"/");
160 if (progress.size() == 2) {
161 int bytesReceived = progress.at(0).toUInt();
162 int bytesTotal = progress.at(1).toUInt();
163 vInfo(
"updater: Downloaded %1 of %2 bytes of file %3").arg(bytesReceived)
178 setReadChannel(QProcess::StandardOutput);
179 while (canReadLine()) {
180 line = readLine().trimmed();
181 vInfo(
"updater (stdout): %1").arg(line);
188 vInfo(
"updater: update process finished with exit code %1").arg(exitCode);
191 if (exitStatus == QProcess::NormalExit) {
195 "software updates because Tor's update process "
196 "exited unexpectedly."));
199 if (exitStatus == QProcess::NormalExit && exitCode == 0)
208 if (
error == QProcess::FailedToStart) {
209 vWarn(
"updater: failed to start");
211 "software updates because it could not find "
233 return (QDateTime::currentDateTime().toUTC() >= nextCheckAt);
253 return "/bundleinfo/tor/win32/";
268 vNotice(
"updater: launching auto-update executable: %1 %2")
270 .arg(args.join(
" "));
272 proc.setEnvironment(proc.systemEnvironment());
274 if (! proc.waitForStarted())
276 if (! proc.waitForFinished())
285 QDomElement dict, elem;
286 QDomNodeList nodeList;
288 QStringList versionParts;
291 if (! doc.setContent(xml,
false, &errmsg, 0, 0))
298 elem = doc.documentElement().firstChildElement(
"signed");
300 errmsg =
"Signed element not found";
304 dict = elem.firstChildElement(
"dict");
306 errmsg =
"no Dict element as a child of Signed";
310 elem = dict.firstChildElement(
"name");
312 errmsg =
"Name element not found";
317 elem = dict.firstChildElement(
"version").firstChildElement(
"list");
319 errmsg =
"no valid Version element found";
322 elem = elem.firstChildElement(
"item");
323 for ( ; ! elem.isNull(); elem = elem.nextSiblingElement(
"item")) {
324 versionParts << elem.text();
328 elem = dict.firstChildElement(
"shortdesc").firstChildElement(
"dict");
330 errmsg =
"no valid Shortdesc element found";
333 elem = elem.firstChildElement();
334 for ( ; ! elem.isNull(); elem = elem.nextSiblingElement()) {
338 elem = dict.firstChildElement(
"longdesc").firstChildElement(
"dict");
340 errmsg =
"no valid Longdesc element found";
343 elem = elem.firstChildElement();
344 for ( ; ! elem.isNull(); elem = elem.nextSiblingElement()) {
351 vWarn(
"updater: invalid package info XML document: %1").arg(errmsg);