aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/subsurfacewebservices.cpp
AgeCommit message (Collapse)Author
2014-04-14Add option to save userid in data filesGravatar Venkatesh Shukla
The userid of Subsurface Webservice can be included in locally saved xml files and git repository. For xml files, it is stored in userid tag. For git repo, it is stored in 00-Subsurface file present in the repo. Preference dialog and webservice dialog modified to include option for saving userid locally. In case of difference in default userid and userid in local file, some semantics are followed. These can be referred to here: http://lists.hohndel.org/pipermail/subsurface/2014-April/011422.html Fixes #473 Signed-off-by: Venkatesh Shukla <venkatesh.shukla.eee11@iitbhu.ac.in> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-11Remove some unneeded explicit paths in includesGravatar Gehad
The include path is set up correctly so we don't need these explicit paths in includes. Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-04-05Fix divelogs.de upload errorGravatar Venkatesh Shukla
The order of arguments to fread was incorrect. In case of arguments "streamsize, 1" the returning value is 1, and hence due to membuf[streamsize] = 0; line, membuf ends up being one character long. Fixed it by exchanging arguments to "1, streamsize". This way, streamsize has the correct value. Fixes #483 Signed-off-by: Venkatesh Shukla <venkatesh.shukla.eee11@iitbhu.ac.in> Acked-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-14Convert other users of showError() to the new world orderGravatar Linus Torvalds
The "report_error()" interface is a lot simpler, although some of the C++ code uses QStrings which make them a bit annoying, especially for the varargs model. Still, even with the explicit conversion to UTF8 and "char *", the report_error() model is much nicer. This also just makes refreshDisplay() do the error reporting in the UI automatically, so a number of error paths don't even have to worry. And the multi-line model of error reporting means that it all automatically does the right thing, and reports errors for each file rather than just for the last file that failed to open. So this removes closer to a hundred lines of cruft, while being a simpler interface and doing better error reporting. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-07Remove the old profile from the main screen of SubsurfaceGravatar Tomaz Canabrava
This patch partially removes the code for the old profile from Subsurface. It removes the use of the old profile on the mainwindow, but keeping the code in the tree for now. A bit of code-cleanup also entered this commit because I had to change every instance of the code that used the old profile. Now to the real code-cleanup Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-06Prevent another file descriptor leakGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-05Null terminate buffer at the correct spotGravatar Dirk Hohndel
fread tells us how many bytes it read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
I know everyone will hate it. Go ahead. Complain. Call me names. At least now things are consistent and reproducible. If you want changes, have your complaint come with a patch to scripts/whitespace.pl so that we can automate it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12Ensure the correct parent is used in the dialogGravatar Dirk Hohndel
This way the dialog is centered and the main window gets dimmed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12Replace mainWindow() with MainWindow::instance()Gravatar Boris Barbulovski
C++ style of accessing single instance class object. Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09DivelogsDeWebServices class cleanupGravatar Boris Barbulovski
* Initialize DivelogsDeWebServices::uploadMode in initialize list, instead of constructor body expression. Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-09Cleanup SubsurfaceWebServices classGravatar Boris Barbulovski
* Remove statuic SubsurfaceWebServices::instance() member. Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Whitespace and coding style updatesGravatar Dirk Hohndel
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>
2014-01-15Convert to TRUE/FALSE to stdbools true/falseGravatar Anton Lundin
I had problems with this one on Qt5. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15Port this code to work with Qt5Gravatar Anton Lundin
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>
2014-01-15Add some missing ; in the Qt5 pathGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-15After downloading GPS data show the new informationGravatar Dirk Hohndel
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>
2014-01-15Improve the download from Subsurface webservice dialogGravatar Dirk Hohndel
- 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>
2013-12-28Enable https for Windows binariesGravatar Dirk Hohndel
This requires the ssleay32.dll and libeay32.dll to be copied into packaging/windows, first. Fixes #367 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20Remove pointless codeGravatar Dirk Hohndel
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>
2013-12-20Don't use an array where none are necessaryGravatar Thiago Macieira
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>
2013-12-20Move the variable initialisations closer to use and add blanksGravatar Thiago Macieira
Makes the code easier to read, IMHO. Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20Get more descriptive error messages when uploading to divelogs.deGravatar Thiago Macieira
Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-20Move the divelogs.de preparation function into the C++ classGravatar Thiago Macieira
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>
2013-12-20Generate the file name for the dive log upload in the callerGravatar Thiago Macieira
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>
2013-12-20Use QFile::{encode,decode}Name for file namesGravatar Thiago Macieira
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>
2013-12-20Fix compilation with libzip < 0.10Gravatar Thiago Macieira
Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-19Files: prefer toUtf8() over toLocal8Bit()Gravatar Lubomir I. Ivanov
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-15Disable https on Windows for 4.0Gravatar Dirk Hohndel
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-13prepare_dives_for_divelogs(): remove unused variable 'doc'Gravatar Lubomir I. Ivanov
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12Don't check if a file exists right before trying to open itGravatar Thiago Macieira
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-12Make the streamsize variable actually intGravatar Thiago Macieira
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-12Don't call strlen() on something we already know the size ofGravatar Thiago Macieira
Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12Don't leak the zip structure in case of errorGravatar Thiago Macieira
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-12Don't leak the buffer or temporary file used to save the diveGravatar Thiago Macieira
Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-12Hoist the getting of the XSLT style-sheet out of the loopGravatar Thiago Macieira
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-12Make the errPrefix a static variableGravatar Thiago Macieira
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-12Don't leak the zip structure if no dives are selectedGravatar Thiago Macieira
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-12Fix compilation with older libzipGravatar Thiago Macieira
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-10Divelogs.de: prevent undefined behaviourGravatar Lubomir I. Ivanov
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-09Remove some unused variablesGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-09Re-enable login and password fields after uploadGravatar Sergey Starosek
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-09Divelogs.de: change the 'Apply' button to 'Done' for uploadGravatar Lubomir I. Ivanov
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-09Divelogs.de: use qDebug() instead of fprintf()Gravatar Lubomir I. Ivanov
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-09Divelogs.de: attempt to impletent 'Cancel' properlyGravatar Lubomir I. Ivanov
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-09Divelogs.de: store the user/pass on uploadGravatar Lubomir I. Ivanov
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-09Divelogs.de: Improve the error handling post DLD creationGravatar Lubomir I. Ivanov
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-09Divelogs.de: Add a 'filename' field when uploadingGravatar Lubomir I. Ivanov
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-09Divelogs.de: further improve reading the server reponseGravatar Lubomir I. Ivanov
We now check for the following entries: <Login>succeeded</Login> <FileCopy>failed</FileCopy> Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2013-12-09Divelogs.de: improve prepare_dives_for_divelogs()Gravatar Lubomir I. Ivanov
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>