Commit graph

111 commits

Author SHA1 Message Date
Thiago Macieira
dbdf50d03c Fix compilation with libzip < 0.10
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20 09:53:05 -08:00
Lubomir I. Ivanov
1bb7ab30c6 Files: prefer toUtf8() over toLocal8Bit()
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>
2013-12-19 07:28:25 -08:00
Dirk Hohndel
5c2ded5840 Disable https on Windows for 4.0
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>
2013-12-15 14:24:30 -08:00
Lubomir I. Ivanov
92476c76f3 prepare_dives_for_divelogs(): remove unused variable 'doc'
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-13 07:42:39 -08:00
Thiago Macieira
0f3928f315 Don't check if a file exists right before trying to open it
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>
2013-12-12 03:37:24 +01:00
Thiago Macieira
841bdf3462 Make the streamsize variable actually int
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>
2013-12-12 03:37:07 +01:00
Thiago Macieira
0a57befb69 Don't call strlen() on something we already know the size of
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:36:36 +01:00
Thiago Macieira
cb39bb5e9c Don't leak the zip structure in case of error
This also erases the zip file that we created

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:36:16 +01:00
Thiago Macieira
b3d59cb890 Don't leak the buffer or temporary file used to save the dive
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:35:46 +01:00
Thiago Macieira
04ec3cf31f Hoist the getting of the XSLT style-sheet out of the loop
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>
2013-12-12 03:35:37 +01:00
Thiago Macieira
a17880ca02 Make the errPrefix a static variable
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>
2013-12-12 03:34:54 +01:00
Thiago Macieira
aadf2cd19c Don't leak the zip structure if no dives are selected
Just move the check above the zip_open call.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12 03:34:25 +01:00
Thiago Macieira
1b5b562da8 Fix compilation with older libzip
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>
2013-12-12 03:33:34 +01:00
Lubomir I. Ivanov
643f404036 Divelogs.de: prevent undefined behaviour
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>
2013-12-10 22:35:13 +01:00
Anton Lundin
26a1904cf8 Remove some unused variables
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-09 22:47:28 +01:00
Sergey Starosek
a0eb9013b1 Re-enable login and password fields after upload
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>
2013-12-09 20:29:38 +01:00
Lubomir I. Ivanov
7c4b083c2b Divelogs.de: change the 'Apply' button to 'Done' for upload
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>
2013-12-09 18:40:52 +01:00
Lubomir I. Ivanov
8f29df6e5a Divelogs.de: use qDebug() instead of fprintf()
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>
2013-12-09 18:40:02 +01:00
Lubomir I. Ivanov
04b62a46e9 Divelogs.de: attempt to impletent 'Cancel' properly
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>
2013-12-09 17:42:06 +02:00
Lubomir I. Ivanov
e0acad42aa Divelogs.de: store the user/pass on upload
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>
2013-12-09 16:45:54 +02:00
Lubomir I. Ivanov
de8d532adb Divelogs.de: Improve the error handling post DLD creation
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>
2013-12-09 16:23:58 +02:00
Lubomir I. Ivanov
ca731cef89 Divelogs.de: Add a 'filename' field when uploading
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>
2013-12-09 16:23:58 +02:00
Lubomir I. Ivanov
70fce6ce6b Divelogs.de: further improve reading the server reponse
We now check for the following entries:
<Login>succeeded</Login>
<FileCopy>failed</FileCopy>

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-12-09 16:23:57 +02:00
Lubomir I. Ivanov
5514499867 Divelogs.de: improve prepare_dives_for_divelogs()
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>
2013-12-09 16:23:57 +02:00
Lubomir I. Ivanov
231e02f97d Divelogs.de: parse response once the upload is finished
This is based on the GTK version.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-12-09 15:51:18 +02:00
Lubomir I. Ivanov
0905e4f0ab Divelogs.de: add code for zipping up all dives
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>
2013-12-09 15:51:17 +02:00
Lubomir I. Ivanov
be16ade038 Divelogs.de: allow import of downloaded dives
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>
2013-12-09 15:51:17 +02:00
Dirk Hohndel
4beb53f27e Actually process the dives downloaded from divelogs.de
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>
2013-12-08 06:42:24 +01:00
Dirk Hohndel
93b5c0cd14 Finish download from divelogs.de
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>
2013-12-06 17:13:03 -08:00
Dirk Hohndel
3a0f138023 Whitespace cleanup
That one slipped by me...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-06 17:09:08 -08:00
Dirk Hohndel
20d924a16e Compile fix
Otherwise errno is undefined (at least for me on Linux).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-04 16:29:55 -08:00
Lubomir I. Ivanov
662e642ac9 Webservices: fix QString argument for zip_open()
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Thiago Macieira <thiago@macieira.org>
2013-12-04 15:39:35 -08:00
Thiago Macieira
a1972bc343 Implement the network part of the support for divelogs.de
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>
2013-12-03 13:53:00 -08:00
Thiago Macieira
919c7045b7 Add support for timing the download out
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>
2013-12-03 13:53:00 -08:00
Thiago Macieira
ab1b314a84 Set the download reply pointer to NULL after dismissing it
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>
2013-12-03 13:53:00 -08:00
Thiago Macieira
fa07f554e2 Properly reset the state of the download dialog before dismissing
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>
2013-12-03 13:53:00 -08:00
Thiago Macieira
481ddf43c6 Improve the status message in the download dialog
This also fixes a typo (untill -> until).

Signed-off-by: Thiago Macieira <thiago@macieira.org>
2013-12-03 13:53:00 -08:00
Thiago Macieira
be7bbb2a7d webservices: Move the static functions to the top of the file
Just my OCD asserting itself. It looks cleaner this way, if the static
functions aren't interleaved in the middle of the WebServices class.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
2013-12-03 13:53:00 -08:00
Thiago Macieira
ff96bcb0fc Make the QNetworkAccessManager a singleton available to all
One of the rules of using QNetworkAccessManager is to share it among all
users, since sockets and other state can be shared. Looks like Marble
doesn't allow us to set it, though, and it creates multiple instances.
I'll prepare an upstream patch to fix that sometime.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
2013-12-03 13:53:00 -08:00
Thiago Macieira
b38eac89e4 General fixes and improvements 2013-12-03 13:52:59 -08:00
Thiago Macieira
0ed95678ba Whitespace: fix indentation in subsurfacewebservices.* to use tabs
Signed-off-by: Thiago Macieira <thiago@macieira.org>
2013-12-03 13:52:59 -08:00
Thiago Macieira
b22f1da59e Fix all leak-at-exit from singletons in Subsurface
Subsurface creates a lot of singleton instances on demand, but nothing
ever deleted them. Since they are singletons, these memory allocations
are technically not leaks. However, they clutter the output in valgrind
and other memory analysers, hiding the real issues.

The solution is to delete these items at exit. For the models and for
gettextFromC, the solution is to use a QScopedPointer, which will delete
its payload when it gets destroyed. For the dialogs and other widgets,
we can't do that: they need to be deleted before QApplication exits, so
we just set the parent in all of them to the main window.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30 09:28:42 -08:00
Alexandre Belloni
1ea1c24292 QT-UI: fix some typos
Signed-off-by: Alexandre Belloni <alexandre.belloni@piout.net>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-30 07:16:08 -08:00
Dirk Hohndel
766b6b3e52 Don't call deleteLater on ui elements
I'll admit that I don't fully understand this part of Qt.
But commenting out the deleteLater (like we already do for another one)
fixes the crash - and shouldn't do more than add a potential small memory
leak.

Fixes #309

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-29 11:39:36 -08:00
Dirk Hohndel
7c28cb989b Make sure Subsurface webservice user id is always uppercase
Otherwise the download will fail.

Fixes #308

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-29 11:36:06 -08:00
Tomaz Canabrava
7bea2e1be0 Minimum hooking-up done, divelogs.de shows on menu-activation.
This patch does the hooking up to show the dialog of the
divelogs.de window when the user selects it on the menu.:

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-24 23:02:59 -02:00
Tomaz Canabrava
216f9212b9 Added the skeleton for the Download / Upload from Divelogs.de
Added the skeleton code for the Download / Upload from Divelogs.
de webservice. Now I need to hoopup things from the .ui side and
do the actual implementation of the code.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-24 22:52:11 -02:00
Tomaz Canabrava
06ba04ab78 fix the string of the subsurfice webservice on the settings.
The setting was 'webservice', but this is too wide, since we are
supporting more than one. changed it to 'subsurface_webservice_uid'

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-24 22:39:21 -02:00
Tomaz Canabrava
d2b87e0eb5 Fixed a crash when the user canceled the download from webservice dialog.
Null references, ah, love them.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-24 22:38:41 -02:00
Tomaz Canabrava
5eb2cc4594 Created a 'WebService' dialog that will handle download and upload.
Created a WebService dialog that will handle download and upload
from all child based webservices. Also, ported the currently - only
- one webservice to use the new dialog.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-24 22:30:21 -02:00
Miika Turkia
4c49670cdb GUI for CSV import
This patch implements GUI for importing CSV log files. One is able to
configure what columns contain time, depth and temperature fields.
Pre-configured log applications currently included are ADP log viewer
and XP5. (Both of these use actually tab as separator, so the field
separator currently hard-coded.)

[Dirk Hohndel: minor fixes]

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-16 12:44:07 -07:00
Tomaz Canabrava
26c87fafc2 Begin to Cleanup the Models, trying to reduce boilerplate.
The Model View system in Qt is *very* verbose, this is the
beginning of a series of patches that will concentrate
the boilerplate somewhere and reduce the amount of lines
and will also try to make the code cleaner and easyer to
understand,

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-11 10:50:40 -03:00
Dirk Hohndel
4b12f28ca4 First steps towards removing glib dependencies
- remove the build flags and libraries from the Makefile / Configure.mk
- remove the glib types (gboolean, gchar, gint64, gint)
- comment out / hack around gettext
- replace the glib file helper functions
- replace g_ascii_strtod
- replace g_build_filename
- use environment variables instead of g_get_home_dir() & g_get_user_name()
- comment out GPS string parsing (uses glib utf8 macros)

This needs massive cleanup, but it's a snapshot of what I have right now, in
case people want to look at it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-06 10:41:44 -07:00
Thiago Macieira
8e81d3f100 Make the classes generated by uic be real members of our classes
This means we don't have to new/delete them, which is a waste of
overhead.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 12:13:48 -07:00
Thiago Macieira
f0f76056ac Include the ui_*.h headers in the main headers.
This means we can also remove the forward declarations.

This is the first step in removing the memory allocation for the ui
sub-classes. Without the second step, this commit is just making the
compilation time increase for no good reason :-)

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-03 12:13:15 -07:00
Lubomir I. Ivanov
fb4dcbc685 A couple of dialog modality considerations
While most dialogs can be open and the main application window
can still be accessed, certain should possibly be modal
in these terms.

This patch proposes the download from webservice and DC dialogs
to lock the main application window until they are closed, with
the consideration of preventing eventual unexpected behavior
in the divelist if both dialogs are active at the same time.

To solve that QtDialog::exec() is used instead of
QtWidget::show().

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-28 20:24:14 +08:00
Lubomir I. Ivanov
880b8394d2 Close child windows and dialogs with main window
Most child windows should be closed with the main application
window otherwise if left open and if making specific
modifictions could potentially cause a SIGSEGV.

To solve that we mark all custom windows/dialogs with
the Qt::WA_QuitOnClose attribute on instance creation.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-28 20:23:59 +08:00
Dirk Hohndel
bdee5ea9a6 Fix webservice download dialog
We need to close the dialog after applying what was downloaded, and we
should not try to delete the manager in case of cancel (as that reliably
causes the SIGSEGV.

Suggested-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-08 21:11:07 -07:00
Tomaz Canabrava
2d05f4227e Hoocked up the Apply button.
Hoocked up the apply button - Didn't tested ( as I frankly don't know
what the expected result should be. ). but the app is not crashing, yey.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-06 11:57:12 -03:00
Tomaz Canabrava
f55ae15707 Hoocked up the buttons and the parsing of the XML.
The XML is now being correctly parsed, Clicking on Help
will open the browser pointing to the api site, and clicking
on cancel will cancel the download.

Clicking on Apply still doesn't apply, but that's next. :)

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-06 11:31:55 -03:00
Tomaz Canabrava
c1cf6c02a8 Added initial support for download dive info from the subsurface web service.
Added initial support for download dive info from subsurface web service,
the current code only downloads and output the xml downloaded in the debug
area. Now I need to parse things up and plug the unplugged stuff.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-06 10:33:15 -03:00