MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / runPrivileged

Method runPrivileged

launcher/FileSystem.cpp:514–612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

512}
513
514void create_link::runPrivileged(const QString& offset)
515{
516 m_linked = 0; // reset counter
517 m_path_results.clear();
518 m_links_to_make.clear();
519
520 bool gotResults = false;
521
522 make_link_list(offset);
523
524 QString serverName = BuildConfig.LAUNCHER_APP_BINARY_NAME + "_filelink_server" + StringUtils::getRandomAlphaNumeric();
525
526 connect(&m_linkServer, &QLocalServer::newConnection, this, [&]() {
527 qDebug() << "Client connected, sending out pairs";
528 // construct block of data to send
529 QByteArray block;
530 QDataStream out(&block, QIODevice::WriteOnly);
531
532 qint32 blocksize = quint32(sizeof(quint32));
533 for (auto link : m_links_to_make) {
534 blocksize += quint32(link.src.size());
535 blocksize += quint32(link.dst.size());
536 }
537 qDebug() << "About to write block of size:" << blocksize;
538 out << blocksize;
539
540 out << quint32(m_links_to_make.length());
541 for (auto link : m_links_to_make) {
542 out << link.src;
543 out << link.dst;
544 }
545
546 QLocalSocket* clientConnection = m_linkServer.nextPendingConnection();
547 connect(clientConnection, &QLocalSocket::disconnected, clientConnection, &QLocalSocket::deleteLater);
548
549 connect(clientConnection, &QLocalSocket::readyRead, this, [&, clientConnection]() {
550 QDataStream in;
551 quint32 blockSize = 0;
552 in.setDevice(clientConnection);
553
554 qDebug() << "Reading path results from client";
555 qDebug() << "bytes available" << clientConnection->bytesAvailable();
556
557 // Relies on the fact that QDataStream serializes a quint32 into
558 // sizeof(quint32) bytes
559 if (clientConnection->bytesAvailable() < (int)sizeof(quint32))
560 return;
561 qDebug() << "reading block size";
562 in >> blockSize;
563
564 qDebug() << "blocksize is" << blockSize;
565 qDebug() << "bytes available" << clientConnection->bytesAvailable();
566 if (clientConnection->bytesAvailable() < blockSize || in.atEnd())
567 return;
568
569 quint32 numResults;
570 in >> numResults;
571 qDebug() << "numResults" << numResults;

Callers 2

executeTaskMethod · 0.45
executeTaskMethod · 0.45

Calls 9

appendMethod · 0.80
closeMethod · 0.80
listenMethod · 0.80
errorStringMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
writeMethod · 0.45
flushMethod · 0.45
startMethod · 0.45

Tested by 1

executeTaskMethod · 0.36