summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt7
-rw-r--r--dive.c15
-rw-r--r--dive.h3
-rw-r--r--parse-xml.c2
-rw-r--r--pref.h2
-rw-r--r--qt-ui/subsurfacewebservices.cpp25
-rw-r--r--qt-ui/subsurfacewebservices.h2
-rw-r--r--save-git.c4
-rw-r--r--save-xml.c4
9 files changed, 32 insertions, 32 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 69d9949b0..95872d1b4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -100,6 +100,8 @@ SET(SUBSURFACE_CORE_LIB_SRCS
uemis.c
uemis-downloader.c
linux.c
+ #gettextfrommoc should be added because we are using it on the c-code.
+ gettextfromc.cpp
)
#the interface, in C++
@@ -152,7 +154,6 @@ SET(SUBSURFACE_PROFILE_LIB_SRCS
#the main app.
SET(SUBSURFACE_APP
main.cpp
- gettextfromc.cpp
qt-gui.cpp
qthelper.cpp
)
@@ -193,3 +194,7 @@ ENABLE_TESTING()
ADD_EXECUTABLE( TestUnitConversion tests/testunitconversion.cpp )
TARGET_LINK_LIBRARIES( TestUnitConversion ${QT_LIBRARIES})
ADD_TEST( NAME TestUnitConversion COMMAND TestUnitConversion)
+
+ADD_EXECUTABLE( TestProfile tests/testprofile.cpp )
+TARGET_LINK_LIBRARIES( TestProfile ${QT_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES} -lzip -ldivecomputer subsurface_corelib)
+ADD_TEST( NAME TestProfile COMMAND TestProfile) \ No newline at end of file
diff --git a/dive.c b/dive.c
index 9a836038d..48fd020ef 100644
--- a/dive.c
+++ b/dive.c
@@ -2,6 +2,7 @@
/* maintains the internal dive list structure */
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
#include <limits.h>
#include "gettext.h"
#include "dive.h"
@@ -2188,3 +2189,17 @@ timestamp_t get_times()
}
return dive->when;
}
+
+#define MAX_USERID_SIZE 32
+void set_save_userid_local(short value)
+{
+ prefs.save_userid_local = value;
+}
+
+void set_userid(char *rUserId)
+{
+ prefs.userid = (char *) malloc(MAX_USERID_SIZE);
+ if (prefs.userid && rUserId)
+ strcpy(prefs.userid, rUserId);
+}
+#undef MAX_USERID_SIZE \ No newline at end of file
diff --git a/dive.h b/dive.h
index 12f190c41..be81ca44b 100644
--- a/dive.h
+++ b/dive.h
@@ -895,9 +895,6 @@ extern double strtod_flags(const char *str, const char **ptr, unsigned int flags
#define ascii_strtod(str, ptr) strtod_flags(str, ptr, STRTOD_ASCII)
-extern short save_userid_local;
-extern char* userid;
-
extern void set_save_userid_local(short value);
extern void set_userid(char* user_id);
diff --git a/parse-xml.c b/parse-xml.c
index 966e56726..f6806d28a 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -861,7 +861,7 @@ static void try_to_fill_sample(struct sample *sample, const char *name, char *bu
void try_to_fill_userid(const char *name, char *buf)
{
- if (save_userid_local)
+ if (prefs.save_userid_local)
set_userid(buf);
}
diff --git a/pref.h b/pref.h
index fd7aa82a7..6ee02a3cb 100644
--- a/pref.h
+++ b/pref.h
@@ -43,6 +43,8 @@ struct preferences {
short show_average_depth;
short zoomed_plot;
short hrgraph;
+ short save_userid_local;
+ char *userid;
};
enum unit_system_values {
METRIC,
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index 50f195635..87cd6006e 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -313,16 +313,16 @@ void WebServices::resetState()
SubsurfaceWebServices::SubsurfaceWebServices(QWidget *parent, Qt::WindowFlags f) : WebServices(parent, f)
{
QSettings s;
- if (!save_userid_local || !*userid)
+ if (!prefs.save_userid_local || !*prefs.userid)
ui.userID->setText(s.value("subsurface_webservice_uid").toString().toUpper());
else
- ui.userID->setText(userid);
+ ui.userID->setText(prefs.userid);
hidePassword();
hideUpload();
ui.progressBar->setFormat("Enter User ID and click Download");
ui.progressBar->setRange(0, 1);
ui.progressBar->setValue(-1);
- ui.saveUidLocal->setChecked(save_userid_local);
+ ui.saveUidLocal->setChecked(prefs.save_userid_local);
}
void SubsurfaceWebServices::buttonClicked(QAbstractButton *button)
@@ -349,7 +349,7 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton *button)
set_save_userid_local(qSaveUid);
if (qSaveUid) {
QString qSettingUid = s.value("subsurface_webservice_uid").toString();
- QString qFileUid = QString::fromStdString(userid);
+ QString qFileUid = QString(prefs.userid);
bool s_eq_d = (qSettingUid == qDialogUid);
bool d_eq_f = (qDialogUid == qFileUid);
if (!d_eq_f || s_eq_d)
@@ -904,20 +904,3 @@ void DivelogsDeWebServices::buttonClicked(QAbstractButton *button)
break;
}
}
-
-#define MAX_USERID_SIZE 32
-short save_userid_local = false;
-char *userid = NULL;
-void set_save_userid_local(short value)
-{
- QSettings s;
- s.setValue("save_uid_local", value);
- save_userid_local = value;
-}
-
-void set_userid(char *rUserId)
-{
- userid = (char *) malloc(MAX_USERID_SIZE);
- if (userid && rUserId)
- strcpy(userid, rUserId);
-}
diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h
index f3fbb5b63..4419b1c6b 100644
--- a/qt-ui/subsurfacewebservices.h
+++ b/qt-ui/subsurfacewebservices.h
@@ -101,8 +101,6 @@ private:
#ifdef __cplusplus
extern "C" {
#endif
-extern short save_userid_local;
-extern char *userid;
extern void set_save_userid_local(short value);
extern void set_userid(char *user_id);
#ifdef __cplusplus
diff --git a/save-git.c b/save-git.c
index 76175a197..e418b9830 100644
--- a/save-git.c
+++ b/save-git.c
@@ -681,8 +681,8 @@ static struct dir *mktree(struct dir *dir, const char *fmt, ...)
static void save_userid(void *_b)
{
struct membuffer *b = _b;
- if (save_userid_local)
- put_format(b, "userid %30s", userid);
+ if (prefs.save_userid_local)
+ put_format(b, "userid %30s", prefs.userid);
}
static void save_one_device(void *_b, const char *model, uint32_t deviceid,
diff --git a/save-xml.c b/save-xml.c
index 0aed92094..4ad03dbf6 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -508,8 +508,8 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
put_format(b, "<divelog program='subsurface' version='%d'>\n<settings>\n", VERSION);
- if (save_userid_local)
- put_format(b, " <userid>%s</userid>\n", userid);
+ if (prefs.save_userid_local)
+ put_format(b, " <userid>%s</userid>\n", prefs.userid);
/* save the dive computer nicknames, if any */
call_for_each_dc(b, save_one_device);