From 8f29df6e5aa555f28d88fb54da127a835a8629de Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Mon, 9 Dec 2013 19:23:31 +0200 Subject: Divelogs.de: use qDebug() instead of fprintf() Use qDebug() instead of fprintf(stderr, ...) in prepare_dives_for_divelogs(). Signed-off-by: Lubomir I. Ivanov Signed-off-by: Dirk Hohndel --- qt-ui/subsurfacewebservices.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'qt-ui/subsurfacewebservices.cpp') diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index a336a4864..abd5f6fc4 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -112,6 +112,7 @@ static char *prepare_dives_for_divelogs(const bool selected) struct zip_source *s[dive_table.nr]; struct zip *zip; char *error = NULL; + const QString errPrefix("divelog.de-upload:"); /* generate a random filename and create/open that file with zip_open */ QString tempfileQ = QDir::tempPath() + "/import-" + QString::number(qrand() % 99999999) + ".dld"; @@ -119,11 +120,11 @@ static char *prepare_dives_for_divelogs(const bool selected) zip = zip_open(tempfile, ZIP_CREATE, NULL); if (!zip) { - fprintf(stderr, "divelog.de-upload: cannot open file as zip\n"); + qDebug() << errPrefix << "cannot open file as zip"; return NULL; } if (!amount_selected) { - fprintf(stderr, "divelog.de-upload: no dives selected\n"); + qDebug() << errPrefix << "no dives selected"; return NULL; } @@ -136,7 +137,7 @@ static char *prepare_dives_for_divelogs(const bool selected) continue; f = tmpfile(); if (!f) { - fprintf(stderr, "divelog.de-upload: cannot create temp file\n"); + qDebug() << errPrefix << "cannot create temp file"; return NULL; } save_dive(f, dive); @@ -145,7 +146,7 @@ static char *prepare_dives_for_divelogs(const bool selected) rewind(f); membuf = (char *)malloc(streamsize + 1); if (!membuf || !fread(membuf, streamsize, 1, f)) { - fprintf(stderr, "divelog.de-upload: memory error\n"); + qDebug() << errPrefix << "memory error"; return NULL; } membuf[streamsize] = 0; @@ -157,14 +158,14 @@ static char *prepare_dives_for_divelogs(const bool selected) */ doc = xmlReadMemory(membuf, strlen(membuf), "divelog", NULL, 0); if (!doc) { - fprintf(stderr, "divelog.de-upload: xml error\n"); - continue; + qDebug() << errPrefix << "xml error"; + return NULL; } free((void *)membuf); // this call is overriding our local variable tempfile! not a good sign! xslt = get_stylesheet("divelogs-export.xslt"); if (!xslt) { - fprintf(stderr, "divelog.de-upload: missing stylesheet\n"); + qDebug() << errPrefix << "missing stylesheet"; return NULL; } transformed = xsltApplyStylesheet(xslt, doc, NULL); @@ -180,7 +181,7 @@ static char *prepare_dives_for_divelogs(const bool selected) if (s[i]) { int64_t ret = zip_add(zip, filename, s[i]); if (ret == -1) - fprintf(stderr, "divelog.de-upload: failed to include dive %d\n", i); + qDebug() << errPrefix << "failed to include dive:" << i; } } zip_close(zip); -- cgit v1.2.3-70-g09d2