void VersionChecker::replyFinished(QNetworkReply* reply) { QString newestVersion = QString(reply->readAll()); if (!newestVersion.isEmpty()) { QString currentVersion = getVersion(); if (compareVersions(currentVersion, newestVersion) > 0) emit updateFound(newestVersion); } }
Window::Window() { QCommandLineParser parser; QCommandLineOption pathToAgentOption("p", "Path to sync agent", "agentPath"); parser.addOption(pathToAgentOption); QCommandLineOption skipAgentStartOption("s", "Do not try to start agent on start up", "skipAgentStart"); parser.addOption(skipAgentStartOption); QCommandLineOption dumbTestOption("test", "Super simple start/stop test."); parser.addOption(dumbTestOption); parser.process(*qApp); bool startAgent = true; if(parser.isSet(skipAgentStartOption) && parser.value(skipAgentStartOption) == "true"){ startAgent = false; } cmdHelper = new CmdHelper(this, (parser.isSet(pathToAgentOption))?parser.value(pathToAgentOption):""); if(parser.isSet(dumbTestOption)){ QTimer *t = new QTimer(this); connect(t, SIGNAL(timeout()), qApp, SLOT(quit())); t->setInterval(5000); t->setSingleShot(true); t->start(); qDebug()<<"Dumb test, will exit in 5 seconds..."; } else{ if(startAgent){ #if defined(Q_OS_WIN) || defined(Q_OS_LINUX) cmdHelper->launchAgentProcess(); #elif defined(Q_OS_MAC) qDebug()<<"Starting agent via launchctl command."; cmdHelper->launchAgentMac(); #endif } if(CHECK_FOR_UPDATE){ updateDialog = new UpdateDialog(this); updatePinger = new PydioUpdatePinger(this); connect(updatePinger, SIGNAL(updateFound(QString,QString,QString,QString)), updateDialog, SLOT(proposeDownload(QString,QString,QString,QString))); updatePinger->lookForUpdate(); } QString dataDir = CmdHelper::getAppDataDir() +'/'+ PORT_CONFIG_FILE_NAME; portConfigurer = new PortConfigurer(dataDir); pollTimer = new QTimer(this); pollTimer->setInterval(POLL_INTERVAL); pollTimer->setSingleShot(true); httpManager = new HTTPManager(this); this->createTrayIcon(); tray->show(); aboutDialog = new AboutDialog(this); connect(pollTimer, SIGNAL(timeout()), httpManager, SLOT(poll())); connect(httpManager, SIGNAL(requestFinished()), pollTimer, SLOT(start())); connect(httpManager, SIGNAL(newJob(Job*)), tray, SLOT(onNewJob(Job*))); connect(httpManager, SIGNAL(jobUpdated(QString)), tray, SLOT(onJobUpdate(QString))); connect(httpManager, SIGNAL(jobDeleted(QString)), tray, SLOT(onJobDeleted(QString))); connect(httpManager, SIGNAL(connectionProblem()), tray, SLOT(connectionLost())); connect(httpManager, SIGNAL(agentReached()), this, SLOT(agentReached())); connect(httpManager, SIGNAL(noActiveJobsAtLaunch()), this, SLOT(show())); connect(httpManager, SIGNAL(jobsCleared()), tray, SLOT(jobsCleared())); connect(httpManager, SIGNAL(webUI404()), this, SLOT(notFoundFromPython())); connect(httpManager, SIGNAL(noInternetConnection()), tray, SLOT(noInternetConnection())); connect(httpManager, SIGNAL(internetConnectionOk()), tray, SLOT(internetConnectionOk())); connect(httpManager, SIGNAL(connectionProblem()), this, SLOT(connectionLost())); connect(httpManager, SIGNAL(jobNotifyMessage(QString,QString,QString)), tray, SLOT(notificationReceived(QString,QString,QString))); connect(tray, SIGNAL(about()), this, SLOT(about())); connect(tray, SIGNAL(pauseSync()), httpManager, SLOT(pauseSync())); connect(tray, SIGNAL(resumeSync()), httpManager, SLOT(resumeSync())); connect(tray, SIGNAL(quit()), this, SLOT(cleanQuit())); connect(tray, SIGNAL(launchAgentSignal()), cmdHelper, SLOT(launchAgentProcess())); // connect(cmdHelper, SIGNAL(winAgentLaunched()), this, SLOT(show())); settingsWebView = new QWebView(); jsDialog = new JSEventHandler(this); portConfigurer->updatePorts(); httpManager->setUrl(AGENT_SERVER_URL + portConfigurer->port(), portConfigurer->username(), portConfigurer->password()); httpManager->poll(); //this->setWindowFlags(Qt::Tool); setWindowTitle(PYDIO_DATA_DIR); setWindowIcon(QIcon(":/images/PydioSync-Systray-Mac.png")); } }