void ProgramUpdater::rssDownloadFailed(const QString &url, const QString &error) { Q_UNUSED(url); qDebug() << "Downloading the new qBittorrent updates RSS failed:" << error; emit updateCheckFinished(false, QString(), m_invokedByUser); }
void ProgramUpdater::rssDownloadFinished(const QString &url, const QByteArray &data) { Q_UNUSED(url); qDebug("Finished downloading the new qBittorrent updates RSS"); #ifdef Q_OS_MAC const QString OS_TYPE {"Mac OS X"}; #elif defined(Q_OS_WIN) const QString OS_TYPE {((QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS7) && QSysInfo::currentCpuArchitecture().endsWith("64")) ? "Windows x64" : "Windows"}; #endif QString version; QXmlStreamReader xml(data); bool inItem = false; QString updateLink; QString type; while (!xml.atEnd()) { xml.readNext(); if (xml.isStartElement()) { if (xml.name() == "item") inItem = true; else if (inItem && xml.name() == "link") updateLink = getStringValue(xml); else if (inItem && xml.name() == "type") type = getStringValue(xml); else if (inItem && xml.name() == "version") version = getStringValue(xml); } else if (xml.isEndElement()) { if (inItem && xml.name() == "item") { if (type.compare(OS_TYPE, Qt::CaseInsensitive) == 0) { qDebug("The last update available is %s", qUtf8Printable(version)); if (!version.isEmpty()) { qDebug("Detected version is %s", qUtf8Printable(version)); if (isVersionMoreRecent(version)) m_updateUrl = updateLink; } break; } inItem = false; updateLink.clear(); type.clear(); version.clear(); } } } emit updateCheckFinished(!m_updateUrl.isEmpty(), version, m_invokedByUser); }
void UpdateChecker::checkForUpdate(bool notifyNoUpdate) { QLOG_DEBUG() << "Checking for updates."; // If the channel list hasn't loaded yet, load it and defer checking for updates until // later. if (!m_chanListLoaded) { QLOG_DEBUG() << "Channel list isn't loaded yet. Loading channel list and deferring " "update check."; m_checkUpdateWaiting = true; updateChanList(notifyNoUpdate); return; } if (m_updateChecking) { QLOG_DEBUG() << "Ignoring update check request. Already checking for updates."; return; } m_updateChecking = true; // Get the channel we're checking. QString updateChannel = MMC->settings()->get("UpdateChannel").toString(); // Find the desired channel within the channel list and get its repo URL. If if cannot be // found, error. m_repoUrl = ""; for (ChannelListEntry entry : m_channels) { if (entry.id == updateChannel) m_repoUrl = entry.url; } // If we didn't find our channel, error. if (m_repoUrl.isEmpty()) { emit updateCheckFailed(); return; } QUrl indexUrl = QUrl(m_repoUrl).resolved(QUrl("index.json")); auto job = new NetJob("GoUpdate Repository Index"); job->addNetAction(ByteArrayDownload::make(indexUrl)); connect(job, &NetJob::succeeded, [this, notifyNoUpdate]() { updateCheckFinished(notifyNoUpdate); }); connect(job, SIGNAL(failed()), SLOT(updateCheckFailed())); indexJob.reset(job); job->start(); }
void Application::periodicUpdateCheck() { UpdateChecker *updateChecker = new UpdateChecker(this); connect(updateChecker, SIGNAL(finished(QList<UpdateInformation>)), this, SLOT(updateCheckFinished(QList<UpdateInformation>))); const int interval = SettingsManager::getValue(QLatin1String("Updates/CheckInterval")).toInt(); if (interval > 0 && !SettingsManager::getValue(QLatin1String("Updates/ActiveChannels")).toStringList().isEmpty()) { LongTermTimer::runTimer((interval * SECONDS_IN_DAY), this, SLOT(periodicUpdateCheck())); } }
AvailableUpdateInfoDialog::AvailableUpdateInfoDialog(QWidget *parent) : QDialog{parent, Qt::Dialog | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint} , ui{new Ui::AvailableUpdateInfoDialog} { // Setup UI controls. ui->setupUi(this); setWindowTitle(QY("Online check for updates")); setChangeLogContent(Q("")); ui->status->setText(QY("Downloading release information")); auto thread = new UpdateCheckThread(parent); connect(thread, SIGNAL(checkFinished(mtx::gui::UpdateCheckStatus, mtx_release_version_t)), this, SLOT(updateCheckFinished(mtx::gui::UpdateCheckStatus, mtx_release_version_t))); connect(thread, SIGNAL(releaseInformationRetrieved(std::shared_ptr<pugi::xml_document>)), this, SLOT(setReleaseInformation(std::shared_ptr<pugi::xml_document>))); thread->start(); }
void MainWindow::silentlyCheckForUpdates() { auto forceUpdateCheck = mtx::sys::get_environment_variable("FORCE_UPDATE_CHECK") == "1"; if (!forceUpdateCheck && !Util::Settings::get().m_checkForUpdates) return; auto lastCheck = Util::Settings::get().m_lastUpdateCheck; if (!forceUpdateCheck && lastCheck.isValid() && (lastCheck.addDays(1) >= QDateTime::currentDateTime())) return; auto thread = new UpdateCheckThread(this); connect(thread, SIGNAL(checkFinished(mtx::gui::UpdateCheckStatus, mtx_release_version_t)), this, SLOT(updateCheckFinished(mtx::gui::UpdateCheckStatus, mtx_release_version_t))); thread->start(); }
void CheckUpdatesDialogLauncher::downloadFinished() { if(m_reply->error() && m_reply->errorString() != "Connection closed") { //Download failed qDebug() << "CheckUpdatesDialogLauncher::downloadFinished(): Error downloading "<<m_reply->url().toString()<<": "<<m_reply->errorString(); AppSettings::sendCheckin("/update/error",tr("Error downloading %1: %2").arg(m_reply->url().toString()).arg(m_reply->errorString())); emit updateCheckFinished(); return; } // Process reply QString info(m_buffer); // Format: // - First line: Single integer denoting the latest release's build SVN rev // - Next line: Direct link to the download // - If containing ',', pairs of OS:URL, eg. unix:http://...,win:http://...,macx:http://... // - Remaining lines to EOF: Text description of release (changes, etc) QStringList lines = info.split("\n"); if(lines.size() < 3) { qDebug() << "CheckUpdatesDialogLauncher::downloadFinished(): Not enough info in " << UPDATE_INFO_URL << ": "<<info; AppSettings::sendCheckin("/update/error",tr("Not enough info in %1: %2").arg(UPDATE_INFO_URL).arg(info)); emit updateCheckFinished(); return; } int latestRev = lines.takeFirst().toInt(); if(BUILD_SVN_REV >= latestRev) // BUILD_SVN_REV is defined by dviz.pro { // Nothing to do here, return qDebug() << "CheckUpdatesDialogLauncher::downloadFinished(): current rev "<<BUILD_SVN_REV<<" newer than rev online: "<<latestRev; emit updateCheckFinished(); return; } QString urlInfo = lines.takeFirst(); QString diz = lines.join("\n"); QString downloadUrl; if(urlInfo.contains(",")) { QStringList downloads = urlInfo.split(","); QString osInfo; #ifdef Q_OS_LINUX osInfo = "unix"; #endif #ifdef Q_OS_WIN osInfo = "win"; #endif #ifdef Q_OS_MAC osInfo = "mac"; #endif foreach(QString item, downloads) { QStringList itemInfo = item.split(":"); QString itemOs = itemInfo.takeFirst(); QString itemUrl = itemInfo.takeFirst(); if(itemOs == osInfo) downloadUrl = itemUrl; }
int main(int argc, char **argv) { // #ifdef Q_WS_X11 // XInitThreads(); // #endif // #if !defined(Q_OS_MAC) // raster on OSX == b0rken // use the Raster GraphicsSystem as default on 4.5+ #if QT_VERSION >= 0x040500 QApplication::setGraphicsSystem("raster"); #endif #endif #if defined(Q_OS_WIN) // QApplication::setStyle(new QtDotNetStyle()); //QtDotNetStyle::Office)); #endif QApplication app(argc, argv); QPixmap pixmap(":/data/DViz-splash.png"); QSplashScreen splash(pixmap); splash.show(); app.processEvents(); app.processEvents(); AppSettings::initApp("DVizControl"); AppSettings::load(); QSettings s; //if(s.value("first-run-date").isValid()) //{ QDate today = QDate::currentDate(); QDate expires(2010,12,31); //QDate f = s.value("first-run-date").toDate(); //int days = f.daysTo(d); QString ver = "DViz Beta"; #define VER "r701" #ifdef VER ver += QString(", Build %1").arg(VER); #endif /* if(today > expires) { QMessageBox::critical(0,QString("%1 Expired").arg(ver),"Sorry, but this evaluation copy of DViz has expired. You can buy the non-eval version from Josiah Bryan - email [email protected] for more information.\n\nOr, you can set your computer's clock back a day or two and keep using this evaluation version till you make up your mind. Thanks for trying out DViz!"); return 0; } else { QMessageBox::information(0,ver,QString("Thanks for trying %1! This evaluation copy is valid until 2010-12-31, at which time you'll be asked to purchase the non-eval verson from Josiah Bryan. If you find ANY issues or have any ideas for improvement, PLEASE speak up and log a new issue at:\n\n http://code.google.com/p/dviz/issues/list\n").arg(ver)); } */ //} if(AppSettings::registrationName().isEmpty() || AppSettings::registrationOrgName().isEmpty()) { QString nameGuess = AppSettings::registrationName(); QString orgGuess = AppSettings::registrationOrgName(); qDebug() << "main debug:"<<nameGuess<<orgGuess; #ifdef Q_OS_WIN /* QSettings settings; settings.insertSearchPath( QSettings::Windows,"/Microsoft/Windows/CurrentVersion"); nameGuess = settings.readEntry( "/RegisteredOwner" ); orgGuess = settings.readEntry( "/RegisteredOrganization" ); if(nameGuess.isEmpty()) { LPTSTR lpszSystemInfo; // pointer to system information DWORD cchBuff = 256; // size of user name TCHAR tchBuffer[UNLEN + 1]; // buffer for expanded string lpszSystemInfo = tchBuffer; // Get and display the user name. GetUserName(lpszSystemInfo, &cchBuff); //Unicode string needs to be converted nameGuess = QString::fromUcs2(lpszSystemInfo); } */ #endif #ifdef Q_OS_LINUX nameGuess = QString( getenv("USER") ); #endif bool ok; QString text = QInputDialog::getText(0, QObject::tr("Confirm Your Name"), QObject::tr("Your name:"), QLineEdit::Normal, nameGuess, &ok); if (ok && !text.isEmpty()) AppSettings::setRegistrationName(text); text = QInputDialog::getText(0, QObject::tr("Confirm Your Organization"), QObject::tr("Your organization:"), QLineEdit::Normal, orgGuess, &ok); if (ok && !text.isEmpty()) AppSettings::setRegistrationOrgName(text); AppSettings::save(); } MainWindow *mw = new MainWindow(); mw->show(); CheckUpdatesDialogLauncher *update = new CheckUpdatesDialogLauncher(); QObject::connect(update, SIGNAL(updateCheckFinished()), update, SLOT(deleteLater())); update->start(); splash.hide(); int ret = app.exec(); AppSettings::save(); // dont delete mw because something in the Qt library is causing // a SEGFLT on windows and I cant get gdb to work right on windows // inorder to trace it. Therefore, just bypass the bug by not deleting // mw - the memory will be released to the OS anyway since we are // exiting the program here. return ret; }