Commit 278fa76816597731198d3a99da943b95d58e384f
1 parent
f7ae0c93
progress toward serving images
Showing
1 changed file
with
22 additions
and
4 deletions
app/br-serve/br-serve.cpp
| @@ -57,10 +57,28 @@ public slots: | @@ -57,10 +57,28 @@ public slots: | ||
| 57 | message = process.readLine(); | 57 | message = process.readLine(); |
| 58 | response->setHeader("Content-Type", "application/json"); | 58 | response->setHeader("Content-Type", "application/json"); |
| 59 | } else if (urlQuery.hasQueryItem("ImageID")) { | 59 | } else if (urlQuery.hasQueryItem("ImageID")) { |
| 60 | - process.write(qPrintable(QString(urlQuery.queryItemValue("ImageID") + "\n"))); | ||
| 61 | - process.waitForReadyRead(); | ||
| 62 | - if (process.error() != QProcess::UnknownError) | ||
| 63 | - qFatal("%s\n", qPrintable(process.errorString())); | 60 | + const QByteArray imageID = QByteArray::fromHex(urlQuery.queryItemValue("ImageID").toLatin1()); |
| 61 | + if (imageID.size() == 16) { | ||
| 62 | + br_universal_template in; | ||
| 63 | + in.algorithmID = 2; | ||
| 64 | + memcpy(&in.imageID, imageID.data(), 16); | ||
| 65 | + memset(in.templateID, 0, 16); | ||
| 66 | + in.size = 0; | ||
| 67 | + | ||
| 68 | + process.write((const char *)&in, sizeof(br_universal_template)); | ||
| 69 | + process.waitForReadyRead(); | ||
| 70 | + if (process.error() != QProcess::UnknownError) | ||
| 71 | + qFatal("%s\n", qPrintable(process.errorString())); | ||
| 72 | + | ||
| 73 | + br_utemplate out = (br_utemplate) malloc(sizeof(br_universal_template)); | ||
| 74 | + if (process.read((char*) out, sizeof(br_universal_template)) == sizeof(br_universal_template)) { | ||
| 75 | + out = (br_utemplate) realloc(out, sizeof(br_universal_template) + out->size); | ||
| 76 | + if (process.read(reinterpret_cast<char*>(out+1), out->size) != out->size) | ||
| 77 | + qFatal("Unexepected EOF when reading universal template data."); | ||
| 78 | + message = QByteArray((char*)&out->data, out->size); | ||
| 79 | + } | ||
| 80 | + free(out); | ||
| 81 | + } | ||
| 64 | response->setHeader("Content-Type", "image/jpeg"); | 82 | response->setHeader("Content-Type", "image/jpeg"); |
| 65 | } else { | 83 | } else { |
| 66 | QString path = request->path(); | 84 | QString path = request->path(); |