bool Client::connectToServer(const QString &serverName) { if (!m_jsonRpcClient) { m_jsonRpcClient = new JsonRpcClient(this); connect(m_jsonRpcClient, SIGNAL(resultReceived(QJsonObject)), SLOT(processResult(QJsonObject))); connect(m_jsonRpcClient, SIGNAL(notificationReceived(QJsonObject)), SLOT(processNotification(QJsonObject))); connect(m_jsonRpcClient, SIGNAL(errorReceived(QJsonObject)), SLOT(processError(QJsonObject))); connect(m_jsonRpcClient, SIGNAL(connectionStateChanged()), SIGNAL(connectionStateChanged())); } return m_jsonRpcClient->connectToServer(serverName); }
void SqlNotificationDispatcher::registerNotification(const QSqlDatabase &database, const QString ¬ificationName, QObject *target, const QString &signal) { QPair<QSqlDriver *, QString> dbSignal(database.driver(), notificationName); QList<QPair<QObject*, QString>> mappedTargets; bool needToRegister = true; if (this->notificationMapping.contains(dbSignal)) { mappedTargets = this->notificationMapping[dbSignal]; needToRegister = false; } mappedTargets.append(QPair<QObject*, QString>(target, signal)); notificationMapping[dbSignal] = mappedTargets; if (needToRegister) { database.driver()->subscribeToNotification(notificationName); connect(database.driver(), SIGNAL(notification(QString)), this, SLOT(notificationReceived(QString))); } }
void LoadSaveThread::thumbnailLoaded(const LoadingDescription& loadingDescription, const QImage& img) { notificationReceived(); emit signalThumbnailLoaded(loadingDescription, img); }
void LoadSaveThread::imageSaved(const QString& filePath, bool success) { notificationReceived(); emit signalImageSaved(filePath, success); }
void LoadSaveThread::savingProgress(const QString& filePath, float progress) { notificationReceived(); emit signalSavingProgress(filePath, progress); }
void LoadSaveThread::imageStartedSaving(const QString& filePath) { notificationReceived(); emit signalImageStartedSaving(filePath); }
void LoadSaveThread::moreCompleteLoadingAvailable(const LoadingDescription& oldLoadingDescription, const LoadingDescription& newLoadingDescription) { notificationReceived(); emit signalMoreCompleteLoadingAvailable(oldLoadingDescription, newLoadingDescription); }
void LoadSaveThread::imageLoaded(const LoadingDescription& loadingDescription, const DImg& img) { notificationReceived(); emit signalImageLoaded(loadingDescription, img); }
void LoadSaveThread::loadingProgress(const LoadingDescription& loadingDescription, float progress) { notificationReceived(); emit signalLoadingProgress(loadingDescription, progress); }
void LoadSaveThread::imageStartedLoading(const LoadingDescription& loadingDescription) { notificationReceived(); emit signalImageStartedLoading(loadingDescription); }
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")); } }
void JsonRpc::processJson(const QString& json) { QList<QVariantMap> objects; try { objects = JsonToVariant::multiParse(json); } catch(ParseException) { sendError(QVariant(), InvalidJson, "Parse error."); return; } Q_FOREACH(const QVariantMap& object, objects) { if(object.value("jsonrpc").toString() != "2.0") { sendError(object.value("id"), InvalidJsonRpc, "JSON-RPC version not specified or not supported.", object); continue; } // Notification or request if(object.contains("method")) { if(object.value("method").type() != QVariant::String) { sendError(object.value("id"), InvalidJsonRpc, "'method' member of request must be a string.", object); continue; } QString method = object.value("method").toString(); QVariant parameters = object.value("params"); if(parameters.isNull()) parameters = QVariantList(); if(parameters.type() != QVariant::List && parameters.type() != QVariant::Map) { sendError(object.value("id"), InvalidJsonRpc, "'parameters' member of request must be omitted, a list, or an object.", object); continue; } // Request or notification if(object.contains("id")) { emit requestReceived(object.value("id"), method, parameters); } else { emit notificationReceived(method, parameters); } continue; } // Request successful if(object.contains("result")) { if(!object.contains("id")) { sendError(QVariant(), InvalidJsonRpc, "ID not specified in response.", object); continue; } emit responseReceived(object.value("id"), object.value("result")); continue; } // Request failed if(object.contains("error")) { if(!object.contains("id")) { sendError(QVariant(), InvalidJsonRpc, "ID not specified in response.", object); continue; } if(object.value("error").type() != QVariant::Map) { sendError(object.value("id"), InvalidJsonRpc, "'error' member is not an Error object.", object); continue; } QVariantMap error = object.value("error").toMap(); if(error.value("code").type() != QVariant::Int) { sendError(object.value("id"), InvalidJsonRpc, "'code' member of error object is not an integer.", object); continue; } if(error.value("message").type() != QVariant::String) { sendError(object.value("id"), InvalidJsonRpc, "'message' member of error object is not a string.", object); continue; } emit errorReceived(object.value("id"), error.value("code").toInt(), error.value("message").toString(), error.value("data")); continue; } // Not a notification, request, or response sendError(object.value("id"), InvalidJsonRpc, "JSON object doesn't appear to be a JSON-RPC request, notification, or response.", object); } }