void Updater::infoFinished() { QNetworkReply *reply = ( QNetworkReply * )sender(); if ( !reply->error() ) { infoFile.write( reply->readAll() ); infoFile.close(); QSettings info( infoFile.fileName(), QSettings::IniFormat, this ); QString ThisVersion = QMPlay2Core.getSettings().getString( "Version" ); QString NewVersion = info.value( "Version" ).toString(); QDate NewVersionDate = ParseVersion( NewVersion ); if ( NewVersionDate.isValid() ) { if ( NewVersionDate > ParseVersion( ThisVersion ) ) { QString FileURL; #if defined Q_OS_WIN && defined QMPLAY2_CPU_X86 if ( sizeof( void * ) == 8 ) FileURL = info.value( "Win64" ).toString(); if ( FileURL.isEmpty() ) //32bit or 64bit does not exists on server FileURL = info.value( "Win32" ).toString(); #elif defined Q_OS_LINUX && defined QMPLAY2_CPU_X86 if ( sizeof( void * ) == 8 ) FileURL = info.value( "Linux64" ).toString(); if ( FileURL.isEmpty() ) //32bit or 64bit does not exists on server FileURL = info.value( "Linux32" ).toString(); #endif if ( FileURL.isEmpty() ) endWork( tr( "Brak dostępnej aktualizacji" ) ); else if ( updateFile.open( QFile::WriteOnly | QFile::Truncate ) ) getFile( QUrl( FileURL.replace( "$Version", NewVersion ) ) ); else endWork( tr( "Błąd zapisu aktualizacji" ) ); } else endWork( tr( "Program jest aktualny" ) ); } else endWork( tr( "Błąd sprawdzania aktualizacji" ) ); } else endWork( tr( "Błąd sprawdzania aktualizacji" ) ); infoFile.remove(); reply->deleteLater(); }
void acceptPlayer() { int fd; Player * p; Message mes; if ((fd = accept(srv.ld, NULL, NULL)) == -1) { merror("accept"); endWork(EXIT_FAILURE); } p = newPlayer(fd); p->pid = srv.nextPid++; addNilPlayer(p); mes.sndr_t = O_PLAYER; mes.sndr.player = p; mes.rcvr_t = O_SERVER; mes.type = MEST_PLAYER_JOIN_SERVER; mes.len = 0; mes.data = NULL; sendMessage(&mes); mes.sndr_t = O_SERVER; mes.rcvr_t = O_PLAYER; mes.rcvr.player = p; mes.type = MEST_PLAYER_PID; mes.len = 0; mes.data = NULL; sendMessage(&mes); }
void startServer() { struct sockaddr_in a; int opt; a.sin_family = AF_INET; a.sin_addr.s_addr = INADDR_ANY; a.sin_port = htons(cfg.port); if ((srv.ld = socket(AF_INET, SOCK_STREAM, 0)) == -1) { merror("socket"); endWork(EXIT_FAILURE); } else debug("Successfuly openned socket\n"); opt = 1; if (setsockopt(srv.ld, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(opt)) == -1) { merror("sersockopt"); endWork(EXIT_FAILURE); } else debug("Successfuly set sock option to reuse address\n"); if (bind(srv.ld, (struct sockaddr *)&a, sizeof(a)) == -1) { merror("bind"); endWork(EXIT_FAILURE); } else debug("Successfuly binded on *:%d\n", cfg.port); if (listen(srv.ld, 5) == -1) { merror("listen"); endWork(EXIT_FAILURE); } else debug("Starting listening...\n"); srv.started = 1; }
void mySignal(int sig) { switch (sig) { case SIGINT: info("Server got SIGINT.\n"); endWork(EXIT_SUCCESS); break; } }
CreateEditDataService::CreateEditDataService() : QDialog(NULL), current_row(-1), ui(new Ui::CreateEditDataService) { ui->setupUi(this); ui->lineEditEndpoint->setValidator(new QIntValidator(0,255, this)); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(endWork())); setModal(true); ui->lineEditDirectIOAddress->setText(QString::fromStdString("localhost:1672:30175")); }
int main (int argc, char ** argv, char ** envp) { initProgram(argc, argv, envp); for(;;) { pollServer(); checkCommands(); processEvents(); } endWork(EXIT_SUCCESS); return EXIT_SUCCESS; }
void initClient() { struct addrinfo hints; struct addrinfo *result, *rp; int s; int sfd; memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = 0; hints.ai_protocol = 0; s = getaddrinfo(cli.hoststr, cli.portstr, &hints, &result); if (s != 0) { error("getaddrinfo: %s\n", gai_strerror(s)); exit(EXIT_FAILURE); } for (rp = result; rp != NULL; rp = rp->ai_next) { sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (sfd == -1) continue; if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1) break; close(sfd); } if (rp == NULL) { error("Couldn't connect\n"); endWork(EXIT_FAILURE); } cli.sfd = sfd; cli.port = ntohs(((struct sockaddr_in *)rp->ai_addr)->sin_port); cli.host = (uint32_t)(((struct sockaddr_in *)rp->ai_addr)->sin_addr.s_addr); cli.sbuf = newBuffer(); cli.cbuf = newBuffer(); freeaddrinfo(result); }
CreateEditDataService::CreateEditDataService(int _current_row, const QString &unique_id, const QString &direct_io_address, int direct_io_endpoint): QDialog(NULL), current_row(_current_row), ui(new Ui::CreateEditDataService) { ui->setupUi(this); ui->lineEditEndpoint->setValidator(new QIntValidator(0,255, this)); connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(endWork())); setModal(true); ui->lineEditUniqueIdentifier->setText(unique_id); ui->lineEditUniqueIdentifier->setEnabled(false); ui->lineEditDirectIOAddress->setText(direct_io_address); ui->lineEditEndpoint->setText(QString::number(direct_io_endpoint)); }
void Updater::downloadFinished() { QNetworkReply *reply = ( QNetworkReply * )sender(); if ( updateFile.size() && !reply->error() ) { #ifndef Q_OS_WIN updateFile.setPermissions( updateFile.permissions() | QFile::ExeOwner | QFile::ExeGroup | QFile::ExeOther ); #endif updateFile.close(); QMPlay2Core.getSettings().set( "UpdateFile", updateFile.fileName() ); infoL->setText( tr( "Aktualizacja została pobrana" ) ); installB->show(); busy = false; } else { updateFile.remove(); endWork( tr( "Błąd pobierania aktualizacji" ) ); } reply->deleteLater(); }
// if doWork is complete or aborted, call endWork() and return true bool LLWorkerClass::checkWork(bool aborting) { LLMutexLock lock(&mMutex); bool complete = false, abort = false; if (mRequestHandle != LLWorkerThread::nullHandle()) { LLWorkerThread::WorkRequest* workreq = (LLWorkerThread::WorkRequest*)mWorkerThread->getRequest(mRequestHandle); llassert_always(workreq); LLQueuedThread::status_t status = workreq->getStatus(); if (status == LLWorkerThread::STATUS_ABORTED) { complete = true; abort = true; } else if (status == LLWorkerThread::STATUS_COMPLETE) { complete = true; } else { llassert_always(!aborting || (workreq->getFlags() & LLQueuedThread::FLAG_ABORT)); } if (complete) { llassert_always(!(getFlags(WCF_WORKING))); endWork(workreq->getParam(), abort); mWorkerThread->completeRequest(mRequestHandle); mRequestHandle = LLWorkerThread::nullHandle(); clearFlags(WCF_HAVE_WORK); } } else { complete = true; } return complete; }
int runExit() { endWork(EXIT_SUCCESS); return INTERNAL_COMMAND_SUCCESS; }