void QGalleryTrackerResultSetPrivate::_q_queryFinished(QDBusPendingCallWatcher *watcher) { if (queryWatcher.data() == watcher) { queryWatcher.take()->deleteLater(); queryFinished(*watcher); } }
void K3bCddbLocalQuery::doQuery() { emit infoMessage( i18n("Searching entry in %1").arg( m_cddbDir ) ); kapp->processEvents(); //BAD! QString path = preparePath( m_cddbDir ); kdDebug() << "(K3bCddbLocalQuery) searching in dir " << path << " for " << QString::number( toc().discId(), 16 ).rightJustify( 8, '0' ) << endl; for( QStringList::const_iterator it = categories().begin(); it != categories().end(); ++it ) { QString file = path + *it + "/" + QString::number( toc().discId(), 16 ).rightJustify( 8, '0' ); if( QFile::exists( file ) ) { // found file QFile f( file ); if( !f.open( IO_ReadOnly ) ) { kdDebug() << "(K3bCddbLocalQuery) Could not open file" << endl; } else { QTextStream t( &f ); K3bCddbResultEntry entry; parseEntry( t, entry ); K3bCddbResultHeader header; header.discid = QString::number( toc().discId(), 16 ).rightJustify( 8, '0' ); header.category = *it; header.title = entry.cdTitle; header.artist = entry.cdArtist; m_inexactMatches.append(header); } } else { kdDebug() << "(K3bCddbLocalQuery) Could not find local entry in category " << *it << endl; } } if( m_inexactMatches.count() > 0 ) { setError( SUCCESS ); if( m_inexactMatches.count() == 1 ) { queryMatch( m_inexactMatches.first() ); } else { emit inexactMatches( this ); } } else { setError( NO_ENTRY_FOUND ); emit queryFinished( this ); } }
void QGalleryTrackerTypeResultSetPrivate::_q_queryFinished(QDBusPendingCallWatcher *watcher) { if (queryWatcher == watcher) { queryWatcher->deleteLater(); queryWatcher = 0; watcher->deleteLater(); queryFinished(*watcher); } }
void ProcessMonitor::queryProcess(Process* process) { QString msg; switch (process->status()) { case Process::NotRunning: msg = "Process not yet started"; break; case Process::Queued: case Process::Running: case Process::Suspended: { Server* server = ServerRegistry::instance().get(process->serverName()); if (server) { ServerTask::Base* task = server->query(process); if (task) { connect(task, SIGNAL(finished()), this, SLOT(queryFinished())); task->start(); } return; }else { msg = "Server not found"; } } break; case Process::Copying: msg = "Copying files from server"; break; case Process::Killed: msg = "Process killed. R.I.P."; break; case Process::Error: msg = "Job failed:\n" + process->comment(); break; case Process::Finished: if (process->jobInfo()->localFilesExist()) { msg = "Job finished. Results are in\n"; msg += process->jobInfo()->get(JobInfo::LocalWorkingDirectory); }else { msg = "Job finished. Results not yet copied from server"; } break; case Process::Unknown: msg = "Status unknown, possibly due to a timeout on the server"; break; } QMsgBox::information(this, "IQmol", msg); }
void LibraryWidget::connectModelSignals(QLibraryTreeWidgetItem *root, Library *p, BibGlobals::ResourceSelection resourceType) { QSortFilterProxyModel *viewModel = p->viewModel(resourceType); if(!viewModel) return; NepomukModel *nm = qobject_cast<NepomukModel *>(viewModel->sourceModel()); if(!nm) return; connect(nm, SIGNAL(queryStarted()), root, SLOT(startQueryFetch())); connect(nm, SIGNAL(queryFinished()), root, SLOT(stopQueryFetch())); connect(nm, SIGNAL(dataSizeChaged(int)), root, SLOT(updateItemCount(int))); }
void QGalleryTrackerResultSetPrivate::_q_parseFinished() { processSyncEvents(); if (parseWatcher.result()) { Q_ASSERT(rCache.offset == rCache.count); Q_ASSERT(iCache.cutoff == iCache.count); rCache.values.clear(); rCache.count = 0; flags &= ~Active; if (flags & Refresh) update(); else emit q_func()->progressChanged(progressMaximum, progressMaximum); q_func()->finish(flags & Live); } else if (flags & Canceled) { iCache.count = 0; flags &= ~Active; q_func()->QGalleryAbstractResponse::cancel(); } else { const int offset = queryOffset + iCache.count; const int limit = queryLimit < 1 || queryLimit - iCache.count > 1024 ? 1024 : queryLimit - iCache.count; QDBusPendingCall call = queryInterface->asyncCallWithArgumentList( queryMethod, QVariantList(queryArguments) << offset << limit); if (call.isFinished()) { queryFinished(call); } else { queryWatcher.reset(new QDBusPendingCallWatcher(call)); QObject::connect( queryWatcher.data(), SIGNAL(finished(QDBusPendingCallWatcher*)), q_func(), SLOT(_q_queryFinished(QDBusPendingCallWatcher*))); progressMaximum += 2; emit q_func()->progressChanged(progressMaximum - 2, progressMaximum); } } }
bool BookmarkSelectionPageListModel::fetch(void) { QSparqlQuery q = QSparqlQuery("select ?b where { ?b a nfo:Bookmark }"); m_result = m_connection->exec(q); if (m_result == 0 || m_result->hasError() == true) { mDebug(__func__) << "Failed to execute query: " << ((m_result == 0) ? "Null result" : m_result->lastError().message()); return false; } connect(m_result, SIGNAL(finished()), this, SLOT(queryFinished())); return true; }
void Server::updateProcesses() { if (m_watchList.isEmpty() || !isConnected() ) return; // query may trigger the process to be removed from m_watchList, so we make // a copy of the list so we don't iterate past the end. QList<Process*> watchList(m_watchList); QList<Process*>::iterator iter; for (iter = watchList.begin(); iter != watchList.end(); ++iter) { ServerTask::Base* task(query(*iter)); if (task) { connect(task, SIGNAL(finished()), this, SLOT(queryFinished())); task->start(); } } }
void RunnerModel::createManager() { if (!m_manager) { // RunnerManager must have its own config group to store instance-specific config // (we don't want the manager from this RunnerModel to overwrite the config from another RunnerModel manager) m_manager = new Plasma::RunnerManager(m_configGroup, this); connect(m_manager, SIGNAL(matchesChanged(QList<Plasma::QueryMatch>)), this, SLOT(matchesChanged(QList<Plasma::QueryMatch>))); connect(m_manager, SIGNAL(queryFinished()), this, SLOT(queryHasFinished())); if (!m_pendingRunnersList.isEmpty()) { loadRunners(); } //connect(m_manager, SIGNAL(queryFinished()), this, SLOT(queryFinished())); } }
void ServiceBrowser::serviceResolved(bool success) { QObject* sender_obj = const_cast<QObject*>(sender()); RemoteService* svr = static_cast<RemoteService*>(sender_obj); disconnect(svr,SIGNAL(resolved(bool)),this,SLOT(serviceResolved(bool))); QValueList<RemoteService::Ptr>::Iterator it = d->m_duringResolve.begin(); QValueList<RemoteService::Ptr>::Iterator itEnd = d->m_duringResolve.end(); while ( it!= itEnd && svr!= (*it)) ++it; if (it != itEnd) { if (success) { d->m_services+=(*it); emit serviceAdded(svr); } d->m_duringResolve.remove(it); queryFinished(); } }
void QGalleryTrackerTypeResultSetPrivate::queryCount() { QVariantList arguments = queryArguments; if (accumulative) arguments << currentOffset << int(0); QDBusPendingCall call = queryInterface->asyncCallWithArgumentList(queryMethod, arguments); if (call.isFinished()) { queryFinished(call); } else { queryWatcher = new QDBusPendingCallWatcher(call, q_func()); QObject::connect(queryWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)), q_func(), SLOT(_q_queryFinished(QDBusPendingCallWatcher*))); } }
void K3bCddbLocalQuery::doMatchQuery() { QString path = preparePath( m_cddbDir ) + header().category + "/" + header().discid; QFile f( path ); if( !f.open( IO_ReadOnly ) ) { kdDebug() << "(K3bCddbLocalQuery) Could not open file" << endl; setError( READ_ERROR ); } else { QTextStream t( &f ); parseEntry( t, result() ); result().discid = header().discid; result().category = header().category; setError( SUCCESS ); } emit queryFinished( this ); }
/*! \internal */ void QDeclarativeSearchModelBase::update() { if (m_reply) return; setStatus(Loading); if (!m_plugin) { clearData(); setStatus(Error, QCoreApplication::translate(CONTEXT_NAME, PLUGIN_PROPERTY_NOT_SET)); return; } QGeoServiceProvider *serviceProvider = m_plugin->sharedGeoServiceProvider(); if (!serviceProvider) { clearData(); setStatus(Error, QCoreApplication::translate(CONTEXT_NAME, PLUGIN_PROVIDER_ERROR) .arg(m_plugin->name())); return; } QPlaceManager *placeManager = serviceProvider->placeManager(); if (!placeManager) { clearData(); setStatus(Error, QCoreApplication::translate(CONTEXT_NAME, PLUGIN_ERROR) .arg(m_plugin->name()).arg(serviceProvider->errorString())); return; } m_reply = sendQuery(placeManager, m_request); if (!m_reply) { clearData(); setStatus(Error, QCoreApplication::translate(CONTEXT_NAME, UNABLE_TO_MAKE_REQUEST)); return; } m_reply->setParent(this); connect(m_reply, SIGNAL(finished()), this, SLOT(queryFinished())); }
DWORD JoinGameDelegate::onMessage(SimObject *sender, DWORD msg) { //get the root SimGui::Canvas *root; if (curGui) root = curGui->getCanvas(); else return Parent::onMessage(sender, msg); if (! root) return -1; IRCClient *objIRCClient = static_cast<IRCClient *>(IRCClient::find(manager)); AssertFatal(objIRCClient, "JoinDelegate: could not locate IRC client"); //check for a new MOTD verifyMasterMOTD(); if (msg == IDCTG_SERVER_REFRESH_LIST) { mbMasterTimedOut = FALSE; Console->evaluate("rebuildServerList();", FALSE); if (cg.gameServerList) cg.gameServerList->rebuildList(); //grey out the refresh button SimGui::ActiveCtrl *ctrl = dynamic_cast<SimGui::ActiveCtrl*>(curGui->findControlWithTag(IDCTG_SERVER_REFRESH_LIST)); if (ctrl) ctrl->active = FALSE; ctrl = dynamic_cast<SimGui::ActiveCtrl*>(curGui->findControlWithTag(IDCTG_SERVER_REFRESH_VISIBLE)); if (ctrl) ctrl->active = FALSE; //initialize the progress controls FearGui::FearGuiBox *boxCtrl = dynamic_cast<FearGui::FearGuiBox*>(curGui->findControlWithTag(IDCTG_SERVER_REFRESH_BOX)); if (boxCtrl) { boxCtrl->setVisible(TRUE); boxCtrl->setUpdate(); } SimGui::ProgressCtrl *prog = dynamic_cast<SimGui::ProgressCtrl*>(curGui->findControlWithTag(IDCTG_SERVER_REFRESH_PROGRESS)); if (prog) prog->setPercentDone(0.0f); SimGui::SimpleText *textCtrl = dynamic_cast<SimGui::SimpleText*>(curGui->findControlWithTag(IDCTG_SERVER_REFRESH_TEXT)); if (textCtrl) { bool lanOnly = Console->getBoolVariable("pref::lanOnly", false) || Console->getIntVariable("Server::NumMasters", 0) == 0; if (lanOnly) textCtrl->setText("Searching for LAN servers"); else textCtrl->setText("Querying master servers"); } return -1; } else if (msg == IDCTG_SERVER_REFRESH_VISIBLE) { mbMasterTimedOut = TRUE; bool result = FALSE; if (cg.gameServerList) { result = cg.gameServerList->refreshVisible(); } if (! result) return -1; //grey out the refresh button SimGui::ActiveCtrl *ctrl = dynamic_cast<SimGui::ActiveCtrl*>(curGui->findControlWithTag(IDCTG_SERVER_REFRESH_LIST)); if (ctrl) ctrl->active = FALSE; ctrl = dynamic_cast<SimGui::ActiveCtrl*>(curGui->findControlWithTag(IDCTG_SERVER_REFRESH_VISIBLE)); if (ctrl) ctrl->active = FALSE; //initialize the progress controls FearGui::FearGuiBox *boxCtrl = dynamic_cast<FearGui::FearGuiBox*>(curGui->findControlWithTag(IDCTG_SERVER_REFRESH_BOX)); if (boxCtrl) { boxCtrl->setVisible(TRUE); boxCtrl->setUpdate(); } SimGui::ProgressCtrl *prog = dynamic_cast<SimGui::ProgressCtrl*>(curGui->findControlWithTag(IDCTG_SERVER_REFRESH_PROGRESS)); if (prog) prog->setPercentDone(0.0f); SimGui::SimpleText *textCtrl = dynamic_cast<SimGui::SimpleText*>(curGui->findControlWithTag(IDCTG_SERVER_REFRESH_TEXT)); if (textCtrl) { textCtrl->setText("Pinging visible servers"); } return -1; } else if (msg == IDCTG_SERVER_REFRESH_CANCEL) { if (cg.csDelegate) { cg.csDelegate->clearPingRequestList(); cg.csDelegate->clearGameRequestList(); } if (cg.gameServerList) cg.gameServerList->rebuildCancel(); mbMasterTimedOut = TRUE; queryFinished(); return -1; } else if (msg == IDDLG_MASTER_MOTD) { char buf[1024]; const char *newMOTD; const char *name; newMOTD = Console->getVariable("pref::MSMOTD"); name = Console->getVariable("pref::MSName"); //push the dialog Console->executef(3, "GuiPushDialog", "MainWindow", "gui\\MasterMOTD.gui"); //set the server name in the dialog box sprintf(buf, "<f1>Message of the day from: %s<f0>\n\n", name); int length = 1023 - strlen(buf); strncpy(&buf[strlen(buf)], newMOTD, length); buf[1023] = '\0'; //set the message of the day in the dialog box FearGui::FGTextFormat *motd = dynamic_cast<FearGui::FGTextFormat*>(root->getTopDialog()->findControlWithTag(IDCTG_MASTER_MOTD)); if (motd) motd->formatControlString(buf, motd->extent.x); //now update the pref variable Console->setVariable("pref::MSprevMOTD", newMOTD); verifyMasterMOTD(); return -1; } else if (msg == IDCTG_SERVER_JOIN) { if (cg.csDelegate) { cg.csDelegate->clearPingRequestList(); cg.csDelegate->clearGameRequestList(); } if (cg.gameServerList) cg.gameServerList->rebuildCancel(); mbMasterTimedOut = TRUE; queryFinished(); //find the server list ctrl, and the server info FearGui::ServerListCtrl *slCtrl = (FearGui::ServerListCtrl*)curGui->findControlWithTag(IDCTG_SERVER_SELECT_LIST); FearCSDelegate::ServerInfo *info = NULL; bool infoAvail; if (slCtrl) info = slCtrl->getServerSelected(infoAvail); if (! info) return -1; //see if the server requires a password if (info->password) { CMDConsole::getLocked()->executef(3, "GuiPushDialog", "MainWindow", "gui\\Password.gui"); } else { //join the game... if (Console->getBoolVariable("$IRC::BroadcastIP")) { objIRCClient->onJoinServer(info->missionName, info->name, Console->getVariable("$Server::Address"), false, info->password); } Console->evaluate("JoinGame();", FALSE); } return -1; } else if (msg == IDCTG_SERVER_JOIN_PASSWORD) { //kill the dialog root->makeFirstResponder(NULL); root->popDialogControl(); //join the game... if (Console->getBoolVariable("$IRC::BroadcastIP")) { //find the server list ctrl, and the server info FearGui::ServerListCtrl *slCtrl = (FearGui::ServerListCtrl*)curGui->findControlWithTag(IDCTG_SERVER_SELECT_LIST); FearCSDelegate::ServerInfo *info = NULL; bool infoAvail; if (slCtrl) info = slCtrl->getServerSelected(infoAvail); if (info) { objIRCClient->onJoinServer(info->missionName, info->name, Console->getVariable("$Server::Address"), false, info->password); } } Console->evaluate("JoinGame();", FALSE); } //used to quit while in the process of joining a server else if (msg == IDCTG_SERVER_JOIN_CANCEL) { if(cg.packetStream) { cg.packetStream->disconnect(); manager->unregisterObject(cg.packetStream); delete cg.packetStream; cg.packetStream = NULL; } else if (cg.csDelegate) { cg.csDelegate->cancelDuringConnection(); } Console->executef(3, "GuiLoadContentCtrl", "MainWindow", "gui\\JoinGame.gui"); } else if (msg == IDDLG_SERVER_INFO) { //find the server list dialog FearGui::ServerListCtrl *slCtrl = (FearGui::ServerListCtrl*)curGui->findControlWithTag(IDCTG_SERVER_SELECT_LIST); //push the dialog const char *dlgName = SimTagDictionary::getString(manager, msg); CMDConsole::getLocked()->executef(3, "GuiPushDialog", "MainWindow", dlgName); //get the info char buf[256]; SimGui::SimpleText *ctrl; FearGui::FGUniversalButton *btnCtrl; FearCSDelegate::ServerInfo *info = NULL; bool infoAvail; if (slCtrl) info = slCtrl->getServerSelected(infoAvail); //plug the info into the various controls if (info && infoAvail) { //server name ctrl = (SimGui::SimpleText*)root->getTopDialog()->findControlWithTag(IDCTG_SRVR_INFO_NAME); if (ctrl) ctrl->setText(info->name); //server address ctrl = (SimGui::SimpleText*)root->getTopDialog()->findControlWithTag(IDCTG_SRVR_INFO_ADDRESS); if (ctrl) ctrl->setText(info->transportAddress); //server version ctrl = (SimGui::SimpleText*)root->getTopDialog()->findControlWithTag(IDCTG_SRVR_INFO_VERSION); if (ctrl) ctrl->setText(info->version); //server Ping ctrl = (SimGui::SimpleText*)root->getTopDialog()->findControlWithTag(IDCTG_SRVR_INFO_PING); if (ctrl) { sprintf(buf, "%d", info->pingTime); ctrl->setText(buf); } //server dedicated ctrl = (SimGui::SimpleText*)root->getTopDialog()->findControlWithTag(IDCTG_SRVR_INFO_DEDICATED); if (ctrl) ctrl->setText((info->dedicated ? "YES" : "NO")); //server game ctrl = (SimGui::SimpleText*)root->getTopDialog()->findControlWithTag(IDCTG_SRVR_INFO_GAME); if (ctrl) ctrl->setText(info->modName); //server mission ctrl = (SimGui::SimpleText*)root->getTopDialog()->findControlWithTag(IDCTG_SRVR_INFO_MISSION); if (ctrl) ctrl->setText(info->missionName); //server password ctrl = (SimGui::SimpleText*)root->getTopDialog()->findControlWithTag(IDCTG_SRVR_INFO_PASSWORD); if (ctrl) ctrl->setText((info->password ? "YES" : "NO")); //server favorite btnCtrl = (FearGui::FGUniversalButton*)root->getTopDialog()->findControlWithTag(IDCTG_SERVER_INFO_FAVORITE); if (btnCtrl) btnCtrl->setMode(info->favorite); //server neverPing btnCtrl = (FearGui::FGUniversalButton*)root->getTopDialog()->findControlWithTag(IDCTG_SERVER_INFO_NEVER_PING); if (btnCtrl) btnCtrl->setMode(info->neverPing); //server text Console->executef(3, "Control::setValue", "ServerInfoText", info->hostInfo); //server info list FearGui::ServerInfoCtrl *siCtrl = dynamic_cast<FearGui::ServerInfoCtrl*>(root->getTopDialog()->findControlWithTag(IDCTG_SRVR_INFO_LIST)); if (siCtrl) siCtrl->setServerInfo(info); } return -1; } else if (msg == IDCTG_SERVER_INFO_FAVORITE) { //find the server list dialog FearGui::ServerListCtrl *slCtrl = (FearGui::ServerListCtrl*)curGui->findControlWithTag(IDCTG_SERVER_SELECT_LIST); //get the info FearGui::FGUniversalButton *btnCtrl; FearCSDelegate::ServerInfo *info = NULL; bool infoAvail; if (slCtrl) info = slCtrl->getServerSelected(infoAvail); btnCtrl = (FearGui::FGUniversalButton*)root->getTopDialog()->findControlWithTag(IDCTG_SERVER_INFO_FAVORITE); if (info && infoAvail && btnCtrl) { slCtrl->setFavorite(info->transportAddress, btnCtrl->isSet()); } return -1; } else if (msg == IDCTG_SERVER_INFO_NEVER_PING) { //find the server list dialog FearGui::ServerListCtrl *slCtrl = (FearGui::ServerListCtrl*)curGui->findControlWithTag(IDCTG_SERVER_SELECT_LIST); //get the info FearGui::FGUniversalButton *btnCtrl; FearCSDelegate::ServerInfo *info = NULL; bool infoAvail; if (slCtrl) info = slCtrl->getServerSelected(infoAvail); btnCtrl = (FearGui::FGUniversalButton*)root->getTopDialog()->findControlWithTag(IDCTG_SERVER_INFO_NEVER_PING); if (info && infoAvail && btnCtrl) { slCtrl->setNeverPing(info->transportAddress, btnCtrl->isSet()); } return -1; } else if (msg == IDCTG_SERVER_INFO_REFRESH) { //find the server list dialog FearGui::ServerListCtrl *slCtrl = (FearGui::ServerListCtrl*)curGui->findControlWithTag(IDCTG_SERVER_SELECT_LIST); //get the info FearCSDelegate::ServerInfo *info = NULL; bool infoAvail; if (slCtrl) info = slCtrl->getServerSelected(infoAvail); if (info && infoAvail && cg.csDelegate) { cg.csDelegate->pushPingInfoRequest(info->transportAddress); } } else { //since there are more than a few things that alter the current server... verifyServer(); } return Parent::onMessage(sender, msg); }
void MetadataUpdater::error ( const QString& message ) { emit queryFinished(); }
void MetadataUpdater::finishedListing() { emit queryFinished(); qobject_cast<Nepomuk2::Query::QueryServiceClient*>(sender())->close(); }
// The QHttp object retrieved data. void Service::slotRequestFinished() { QNetworkReply * reply = qobject_cast<QNetworkReply *>(sender()); qDebug() << "UPnP::Service: received HTTP response for request " << endl; if(!reply) { qWarning() << "UPnP::Service - HTTP Request failed: " << reply->errorString() << endl; m_iPendingRequests--; emit queryFinished(true); return; } if(reply->error() != QNetworkReply::NoError) { qWarning() << "UPnP::Service - HTTP Request failed: " << reply->errorString() << endl; m_iPendingRequests--; emit queryFinished(true); reply->deleteLater(); return; } // Get the XML content QByteArray response = reply->readAll(); QDomDocument xml; qDebug() << "Response:\n" << response << "\n---\n"; // Parse the XML QString errorMessage; bool error = !xml.setContent(response, false, &errorMessage); if(!error) { QString baseNamespace = xml.documentElement().tagName(); if(baseNamespace.length() > 0) { int cutAt = baseNamespace.indexOf(':'); if(cutAt > -1) { baseNamespace.truncate(cutAt); qDebug() << "Device is using " << baseNamespace << " as XML namespace" << endl; m_szBaseXmlPrefix = baseNamespace; } } // Determine how to process the data if(xml.namedItem(m_szBaseXmlPrefix + ":Envelope").isNull()) { qDebug() << "UPnP::Service: plain XML detected, calling gotInformationResponse()." << endl; // No SOAP envelope found, this is a normal response to callService() gotInformationResponse(xml.lastChild()); } else { qDebug() << xml.toString() << endl; // Got a SOAP message response to callAction() QDomNode resultNode = XmlFunctions::getNode(xml, "/" + m_szBaseXmlPrefix + ":Envelope/" + m_szBaseXmlPrefix + ":Body").firstChild(); error = (resultNode.nodeName() == m_szBaseXmlPrefix + ":Fault"); if(!error) { if(resultNode.nodeName().startsWith("m:") || resultNode.nodeName().startsWith("u:")) { qDebug() << "UPnP::Service: SOAP envelope detected, calling gotActionResponse()." << endl; // Action success, return SOAP body QMap<QString, QString> resultValues; // Parse all parameters // It's possible to pass the entire QDomNode object to the gotActionResponse() // function, but this is somewhat nicer, and reduces code boat in the subclasses QDomNodeList children = resultNode.childNodes(); for(int i = 0; i < children.count(); i++) { QString key = children.item(i).nodeName(); resultValues[key] = children.item(i).toElement().text(); } // Call the gotActionResponse() gotActionResponse(resultNode.nodeName().mid(2), resultValues); } } else { qDebug() << "UPnP::Service: SOAP error detected, calling gotActionResponse()." << endl; // Action failed gotActionErrorResponse(resultNode); } } } else { qWarning() << "UPnP::Service - XML parsing failed: " << errorMessage << endl; } // Only emit when bytes>0 m_iPendingRequests--; emit queryFinished(error); }
int main(int argc, char** argv) { /*File Pointers*/ FILE *namef; FILE *entrantf; FILE *nodef; FILE *trackf; FILE *timef; FILE *coursef; FILE *logf; /*Filenames*/ char namefile[30]; char nodesfile[30]; char tracksfile[30]; char entrantsfile[30]; char coursesfile[30]; char cp_timesfile1[30]; char logfile[30]; /*These are the structures that will contain all the data read in*/ NAME title[3]; COURSE courses[26]; ENTRANT *entrant_head = NULL; NODE *node_head = NULL; TRACK *track_head = NULL; TIME *time_head = NULL; char my_buffer[100]; /*These variables are used when reading in files and calculating queries*/ char name[100]; int i, j, n1, n2, n3, h, m, timesanswer, answer, qh, qm, node; char t; i = 0; answer = 0; timesanswer = 0; /*This is where the user is asked to enter all the files that are needed to run the program They are entered sequentially to ensure that all files are read in and that none conflict with each other.*/ printf("Please enter the name of the log file: \n"); scanf(" %[a-z,A-Z,.,_,0-9]", logfile); logf = fopen(logfile, "a"); fprintf(logf, "Log File Opened\n"); printf("Please enter the names file: \n"); scanf(" %[a-z,A-Z,.,_,0-9]", namefile); namef = fopen(namefile, "r"); while (fgets(my_buffer, 80, namef) != NULL) { strcpy(title[i].line, my_buffer); i++; } fclose(namef); printf("Please enter the nodes file: \n"); scanf(" %[a-z,A-Z,.,_,0-9]", nodesfile); createLinkedNodes(&node_head, nodef, nodesfile); printf("Please enter the tracks file: \n"); scanf(" %[a-z,A-Z,.,_,0-9]", tracksfile); createLinkedTracks(&track_head, trackf, tracksfile); printf("Please enter the entrants file: \n"); scanf(" %[a-z,A-Z,.,_,0-9]", entrantsfile); createLinkedEntrants(&entrant_head, entrantf, entrantsfile); printf("Please enter the courses file: \n"); scanf(" %[a-z,A-Z,.,_,0-9]", coursesfile); coursef = fopen(coursesfile, "r"); while (!feof(coursef)) { i = 0; if (fscanf(coursef, "%c %d", &(courses[i].name), &(courses[i].amount)) == 2) { for (j = 0; j < courses[i].amount; j++) { while (fscanf(coursef, " %d", &(courses[i].nodes[j])) == 1); } fscanf(coursef, "\n"); i++; } else { fprintf(stderr, "Error: file format wrong.\n"); break; } } /*This prompts the user to choose how they will enter the first competitor's time. There is an option to add more later.*/ printf(" Choose how times for competitors are entered.\n"); printf(" 1. Enter a pre-prepared file of all competitors' times.\n"); printf(" 2. Manually enter more times for competitors.\n"); scanf("%d", ×answer); if (timesanswer == 1) { printf("Please enter the times file: \n"); scanf(" %[a-z,A-Z,.,_,0-9]", cp_timesfile1); timef = fopen(cp_timesfile1, "r"); while (fgets(my_buffer, 100, timef) != NULL) { sscanf(my_buffer, "%c %d %d %d:%d", &t, &n1, &n2, &h, &m); createLinkedTimes(&time_head, t, n1, n2, h, m); } fclose(timef); } else if (timesanswer == 2) { printf("How many times do you wish to enter? "); scanf(" %d", &i); int count = 0; while (count != i) { printf("Please enter the type of checkpoint :"); scanf(" %[A-Z]", &t); printf("Please enter the checkpoint node :"); scanf(" %d", &n2); printf("Please enter the competitor number :"); scanf(" %d", &n3); printf("Please enter the hours :"); scanf(" %d", &h); printf("Please enter the minutes :"); scanf(" %d", &m); createLinkedTimes(&time_head, t, n2, n3, h, m); count += 1; } printTimes(&time_head); } while (answer != 11) { for (i = 0; i < 3; i++) { printf("%s", title[i].line); } /*This prints out the last time entered into the linked list of times. This is assumed to be the current time.*/ printf("Current Time : %02d:%02d\n", h, m); /*MENU*/ printf("Please choose an option :\n"); printf("1. Query the status and location of a competitor.\n"); printf("2. Query how many competitors have not yet started.\n"); printf("3. Query how many competitors are out on the course.\n"); printf("4. Query how many competitors are finished.\n"); printf("5. Add more times\n"); printf("6. Results\n"); printf("7. Query which competitors were excluded for going to an incorrect checkpoint\n"); printf("8. Query which competitors were excluded for medical reasons\n"); printf("9. Query when a competitor entered a medical checkpoint\n"); printf("10. Query when a competitor left a medical checkpoint\n"); printf("11. Quit\n"); scanf("%d", &answer); /*Allows the user to query the location and status of one competitor*/ if (answer == 1) { fprintf(logf, "Time : %02d:%02d Date : %s Activity : Queried location and status of a competitor\n", h, m, title[1].line); printf("Enter a time you wish to query for : \n"); scanf("%d:%d", &qh, &qm); if (compareTime(h, m, qh, qm) == 0) { printf("Time entered is after current time, please enter an appropriate time\n"); } else { printf("Enter competitor's number: \n"); scanf("%d", &n1); findCompetitor(&entrant_head, n1, name); if ((strcmp(name, "Not Found")) != 0) { printf("Name : %s\n", name); node = 0; node = findLocation(&time_head, n1, qh, qm); if (node == 100) { printf("Location : %d\n", node); printf("Status : Finished\n"); printf("\n"); } if (node == 0) { printf("Status : Not Started\n"); printf("\n"); } else { printf("Location : %d\n", node); printf("Status : On Course\n"); printf("\n"); } } else { printf("%s\n", name); } } /*Allows the user to query all the competitors that have not started*/ } else if (answer == 2) { fprintf(logf, "Time : %02d:%02d Date : %s Activity : Queried which competitors had not started\n", h, m, title[1].line); printf("Enter a time for you wish to query for : \n"); scanf("%d:%d", &qh, &qm); queryNotStarted(&time_head, &entrant_head, qh, qm); /*Allows the user to query all the competitors that are out on course*/ } else if (answer == 3) { fprintf(logf, "Time : %02d:%02d Date : %s Activity : Queried which competitors are out on course\n", h, m, title[1].line); printf("Enter a time for you wish to query for : \n"); scanf("%d:%d", &qh, &qm); queryOnCourse(&time_head, &entrant_head, qh, qm); /*Allows the user to query all the competitors that are finished*/ }else if (answer == 4) { fprintf(logf, "Time : %02d:%02d Date : %s Activity : Queried which competitors are finished\n", h, m, title[1].line); printf("Enter a time for you wish to query for : \n"); scanf("%d:%d", &qh, &qm); queryFinished(&time_head, &entrant_head, qh, qm); /*Allows the user to enter more times*/ } else if (answer == 5) { printf(" Choose how times for competitors are entered.\n"); printf(" 1. Enter a pre-prepared file of all competitors' times.\n"); printf(" 2. Manually enter more times for competitors.\n"); scanf("%d", ×answer); if (timesanswer == 1) { fprintf(logf, "Time : %02d:%02d Date : %s Activity : Added more times from a file\n", h, m, title[1].line); printf("Please enter the times file: \n"); scanf(" %[a-z,A-Z,.,_,0-9]", cp_timesfile1); timef = fopen(cp_timesfile1, "r"); while (fgets(my_buffer, 100, timef) != NULL) { sscanf(my_buffer, "%c %d %d %d:%d", &t, &n1, &n2, &h, &m); createLinkedTimes(&time_head, t, n1, n2, h, m); } fclose(timef); printTimes(&time_head); } else if (timesanswer == 2) { fprintf(logf, "Time : %02d:%02d Date : %s Activity : Manually entered more times\n", h, m, title[1].line); printf("How many times do you wish to enter? "); scanf(" %d", &i); int count = 0; while (count != i) { printf("Please enter the type of checkpoint :"); scanf(" %[A-Z]", &t); printf("Please enter the checkpoint node :"); scanf(" %d", &n2); printf("Please enter the competitor number :"); scanf(" %d", &n3); printf("Please enter the hours :"); scanf(" %d", &h); printf("Please enter the minutes :"); scanf(" %d", &m); createLinkedTimes(&time_head, t, n2, n3, h, m); count += 1; } printTimes(&time_head); } } /*Allows the user to print out the results*/ else if (answer == 6) { fprintf(logf, "Time : %02d:%02d Date : %s Activity : Checked results\n", h, m, title[1].line); queryResults(&time_head, &entrant_head, h, m); } else if(answer == 7){ fprintf(logf, "Time : %02d:%02d Date : %s Activity : Queried which competitors were excluded for incorrect checkpoints \n", h, m, title[1].line); printf("Enter a time for you wish to query for : \n"); scanf("%d:%d", &qh, &qm); queryWrongExclusion(&time_head, &entrant_head, qh, qm); } else if(answer == 8){ fprintf(logf, "Time : %02d:%02d Date : %s Activity : Queried which competitors were excluded for medical reasons \n", h, m, title[1].line); printf("Enter a time for you wish to query for : \n"); scanf("%d:%d", &qh, &qm); queryMedicalExclusion(&time_head, &entrant_head, qh, qm); } else if (answer == 9) { fprintf(logf, "Time : %02d:%02d Date : %s Activity : Queried a competitor's entry into a medical checkpoint \n", h, m, title[1].line); int compNum = 0; printf("Enter a time you wish to query for : \n"); scanf("%d:%d", &qh, &qm); if (compareTime(h, m, qh, qm) == 0) { printf("Time entered is after current time, please enter an appropriate time\n"); } else { printf("Enter competitor's number: \n"); scanf("%d", &compNum); findCompetitor(&entrant_head, compNum, name); if ((strcmp(name, "Not Found")) != 0) { printf("Name : %s\n", name); char type; type = findType(&time_head, compNum, qh, qm); if(type == 'A'){ int h = findHourTime(&time_head, compNum, qh, qm); int m = findMinutesTime(&time_head, compNum, qh, qm); printf("Time : %d:%d", h, m); } } else { printf("%s\n", name); } } } else if(answer == 10){ fprintf(logf, "Time : %02d:%02d Date : %s Activity : Queried a competitor's departure from a medical checkpoint \n", h, m, title[1].line); int compNum = 0; printf("Enter a time you wish to query for : \n"); scanf("%d:%d", &qh, &qm); if (compareTime(h, m, qh, qm) == 0) { printf("Time entered is after current time, please enter an appropriate time\n"); } else { printf("Enter competitor's number: \n"); scanf("%d", &compNum); findCompetitor(&entrant_head, compNum, name); if ((strcmp(name, "Not Found")) != 0) { printf("Name : %s\n", name); char type; type = findType(&time_head, compNum, qh, qm); if(type == 'D'){ int h = findHourTime(&time_head, compNum, qh, qm); int m = findMinutesTime(&time_head, compNum, qh, qm); printf("Time : %d:%d \n", h, m); } } else { printf("%s\n", name); } } } } return (EXIT_SUCCESS); }