Another futile attempt to cleanup the code and make coding style and
whitespace consistent. I tried to add a file that describes the key points
of our coding style. I have no illusions that this will help the least
bit...
This commit should ONLY change whitespace
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This code had parts that where Qt5-compatible, this introduces the last
bits that it needs to be completely compatible.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Recreate the labels in the marble window (this adds all the new locations
with the correct labels), center on the selected dive (this makes sense in
case this is one of the dives that got location information) and redisplay
the main tab (again, as this might now have location information).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- make the User ID input field wide enough
- use the progress bar for an explanatory text
- mark it as 100% completed once the download succeeds
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Why calculate the number of entries in the zip downloaded from Divelogs.De
if you don't do anything with that number?
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We don't need to keep the array of zip_source structs. We just need the
latest we created so we can add to the zip file.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is so we can mark the error messages for translation.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is a cleaner approach, according to the discussion in the mailing
list. It is also better because we can use QTemporaryDir in Qt 5.
Finally, it avoids having to remember to free it at every point.s
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
And make them use UTF-8 on Windows instead of the local 8 bit encoding.
This will also get us the proper NFD encoding on OS X.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We may want to use toUtf8() for win32 considerations.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We appear to be missing the correct dll. I'm out of time trying to track
this down, so I just switched Subsurface to access divelogs.de via http on
Windwos.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The open call will tell us what we need to know. Obviously we can't open
a file that doesn't exist. This saves us one stat() or Windows
equivalent.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Casting a pointer to a size_t variable to a pointer to int is wrong on
big endian machines. Not that I expect anyone to compile Subsurface 4
for Mac on PowerPC 64-bit, but just in case... Who knows, we may have
some Solaris-on-UltraSPARC or AIX-on-POWER6 users.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We don't need to get it for every file, since it's the same. This also
avoids leaking temporary files and memory if the stylesheet cannot be
found.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
No need to allocate memory for something that will show in debugging
only. Besides, qDebug() of a QString adds quotes around it, which we
can do without.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Older libzip lack zip_get_num_entries. Thanks to Lubomir for spotting
the version macro.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
prepare_dives_for_divelogs() did a silly thing, which I was
responsible for. When populating 'tempfile' we benefit
from QString, but then return a pointer to a local variable
(char *) without alocating it on the heap. This resulted
in undefined behavior, as we don't know the lifespan of that
local memory on the stack.
Patch fixes that by using strdup() and freeing the memory
when/if needed.
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Give user the possibility to re-enter username and password
after unsuccessful upload due to wrong credentials.
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Post downloading we have an 'Apply' button that can be clicked
to apply/merge the downloaded dives. When uploading we
rename the button to 'Done' and enable the button if the
upload was successful. The 'Cancel' button on the other hand
becomes disabled.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Use qDebug() instead of fprintf(stderr, ...) in
prepare_dives_for_divelogs().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The correct way to stop the upload/download is to use
reply->abort(). If the dialog closes, post exec()
we check if the reply 'isOpen' and abort and delete it.
Without this modification the program seems to crash
as the connection is still in action and it attempts
to read an already deleted file.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
We store the user/pass for 'Apply' when downloading, but
we also want to store these values for 'Upload'.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Only show a filename in the error report if such was previsly
set. We also add a string for translation, that is shown
in the main window.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
The 'Content-Disposition' header, requires that we pass
'name' but also a 'filename' field.
Suggested-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
prepare_dives_for_divelogs() is based on GTK / C code
where we used GLib methods to generate a temp zip file.
Qt has QTemporaryFile, but it seems there is some sort
of a problem when using with with zip_open
(ZIP_CREATE considered) or at least in this particular case.
To workaround that, we generate a random name ourself with qrand()
and simply pass it to zip_open (with ZIP_CREATE) and then return
the filename.
Also (!), there is memory corruption when trying to return
'tempfile'. This wasn't the case with the C compiler,
to my knowledge. Regardless of this fact the generated
zip does not look corrupt.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
prepare_dives_for_divelogs() comes from the GTK version, originally.
The upload seems to fail at this point with an error.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This patch adds commands to the dialog buttons, to apply
(and possibly show an error if 'parse_file' fails',
reject, or show help - which is a link to the 'divelogs.de'
website.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Silly mistake in commit 93b5c0cd14 ("Finish download from divelogs.de"):
parse_file() doesn't call process_dives() - the caller needs to do that.
Fixes#344
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is far from perfect.
Avoid a weird warning when total = -1 is passed into the progress bar.
Enable the Accept button once the download completes.
Merge the downloaded dives into the existing dive list on Apply.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This implements support for:
* uploading a zip file containing dives - untested
(the zip file must have been prepared elsewhere)
* downloading the dive list and the dive XML files
The networking part is finished, but it's missing the actual import of
the XML files sent by divelogs.de.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
The time out is 30 seconds from the start of the request or from the
last time we got any data from the server.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
QNetworkReply might emit signals after it's been told to go away. We
don't want to change the status after that.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Re-enable buttons that should be enabled by default, disable the others,
set the status to empty, make the progress bar go back to zero.
Signed-off-by: Thiago Macieira <thiago@macieira.org>