include #include #include */
| 81 | #include <QTextStream> |
| 82 | #include <QDateTime>*/ |
| 83 | void YACReaderClientConnectionWorker::run() |
| 84 | { |
| 85 | /*{ |
| 86 | QFile f(QString("c:/temp/thread%1.txt").arg(count)); |
| 87 | f.open(QIODevice::Append); |
| 88 | QTextStream out(&f); |
| 89 | out << QString("Thread%1 starts").arg(count) << endl; |
| 90 | f.close(); |
| 91 | } |
| 92 | uint t1 = QDateTime::currentMSecsSinceEpoch();*/ |
| 93 | |
| 94 | quint64 libraryId; |
| 95 | ComicDB comic; |
| 96 | OpenComicSource source = { OpenComicSource::ReadingList, 0 }; |
| 97 | qulonglong nextComicId; |
| 98 | int tries = 0; |
| 99 | int dataAvailable = 0; |
| 100 | QByteArray packageSize; |
| 101 | clientConnection->waitForReadyRead(1000); |
| 102 | while (((long unsigned int)packageSize.size() < sizeof(quint32)) && (tries < 20)) { |
| 103 | packageSize.append(clientConnection->read(sizeof(quint32) - packageSize.size())); |
| 104 | clientConnection->waitForReadyRead(100); |
| 105 | if (dataAvailable == packageSize.size()) { |
| 106 | tries++; |
| 107 | } |
| 108 | dataAvailable = packageSize.size(); |
| 109 | } |
| 110 | if (tries == 20) { |
| 111 | QLOG_ERROR() << "Local connection: unable to read the message size" << clientConnection->errorString(); |
| 112 | return; |
| 113 | } |
| 114 | |
| 115 | QDataStream sizeStream(packageSize); |
| 116 | sizeStream.setVersion(QDataStream::Qt_4_8); |
| 117 | quint32 totalSize = 0; |
| 118 | sizeStream >> totalSize; |
| 119 | |
| 120 | tries = 0; |
| 121 | QByteArray data; |
| 122 | int dataRead = 0; |
| 123 | while ((quint32)data.size() < totalSize && tries < 200) { |
| 124 | data.append(clientConnection->readAll()); |
| 125 | if ((quint32)data.length() < totalSize) |
| 126 | clientConnection->waitForReadyRead(100); |
| 127 | if (dataRead == data.length()) // no bytes were read |
| 128 | tries++; |
| 129 | dataRead = data.length(); |
| 130 | } |
| 131 | if (tries == 200) { |
| 132 | QLOG_ERROR() << QString("Local connection: unable to read message (%1,%2)").arg(data.size()).arg(totalSize); |
| 133 | return; |
| 134 | } |
| 135 | QDataStream dataStream(data); |
| 136 | quint8 msgType; |
| 137 | dataStream >> msgType; |
| 138 | |
| 139 | switch (msgType) { |
| 140 | case YACReader::RequestComicInfo: { |
nothing calls this directly
no test coverage detected