From 55a0ab7b484e22b391e45d115eea5aa863a40d25 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 29 Feb 2016 23:34:24 +0100 Subject: [PATCH] refs #485, renamed the trait for authenticated user to AuthenticatedDbUser * there is no single authenticated user, this one has a specific usage * adjusted classed * formatting --- src/blackcore/data/authenticateduser.h | 7 ++++--- src/blackcore/databaseauthentication.cpp | 4 ++-- src/blackcore/databaseauthentication.h | 4 ++-- src/blackgui/components/dblogincomponent.h | 2 +- src/blackgui/components/dbmappingcomponent.cpp | 2 +- src/blackgui/components/dbmappingcomponent.h | 12 ++++++------ src/blackgui/editors/form.cpp | 4 ++-- src/blackgui/editors/form.h | 4 ++-- src/blackgui/editors/modelmappingform.cpp | 2 +- 9 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/blackcore/data/authenticateduser.h b/src/blackcore/data/authenticateduser.h index df70106a6..152aabcb1 100644 --- a/src/blackcore/data/authenticateduser.h +++ b/src/blackcore/data/authenticateduser.h @@ -20,11 +20,12 @@ namespace BlackCore { namespace Data { - //! Trait for for global setup data - struct AuthenticatedUser : public BlackMisc::CDataTrait + //! Trait for for global cached DB user. + //! This user has authenticated with the swift DB. + struct AuthenticatedDbUser : public BlackMisc::CDataTrait { //! Key in data cache - static const char *key() { return "readers/global/user"; } + static const char *key() { return "dbuser"; } //! Default value static const BlackMisc::Network::CAuthenticatedUser &defaultValue() diff --git a/src/blackcore/databaseauthentication.cpp b/src/blackcore/databaseauthentication.cpp index 3faf9a6db..5d7d4af89 100644 --- a/src/blackcore/databaseauthentication.cpp +++ b/src/blackcore/databaseauthentication.cpp @@ -78,7 +78,7 @@ namespace BlackCore url.setQuery("logoff=true"); QNetworkRequest request(CNetworkUtils::getNetworkRequest(url)); sApp->getFromNetwork(request, { this, &CDatabaseAuthenticationService::ps_parseServerResponse }); - this->m_user.set(CAuthenticatedUser()); + this->m_swiftDbUser.set(CAuthenticatedUser()); } void CDatabaseAuthenticationService::ps_parseServerResponse(QNetworkReply *nwReplyPtr) @@ -124,7 +124,7 @@ namespace BlackCore msgs.push_back(CStatusMessage(cats, CStatusMessage::SeverityError, "User has no roles")); } } - this->m_user.set(user); + this->m_swiftDbUser.set(user); emit userAuthenticationFinished(user, msgs); } else diff --git a/src/blackcore/databaseauthentication.h b/src/blackcore/databaseauthentication.h index de65783c3..21c3a249d 100644 --- a/src/blackcore/databaseauthentication.h +++ b/src/blackcore/databaseauthentication.h @@ -59,8 +59,8 @@ namespace BlackCore void ps_userChanged(); private: - BlackMisc::CData m_setup {this}; //!< data cache - BlackMisc::CData m_user {this, &CDatabaseAuthenticationService::ps_userChanged}; + BlackMisc::CData m_setup {this}; //!< data cache + BlackMisc::CData m_swiftDbUser {this, &CDatabaseAuthenticationService::ps_userChanged}; bool m_shutdown = false; }; } // namespace diff --git a/src/blackgui/components/dblogincomponent.h b/src/blackgui/components/dblogincomponent.h index a7030f946..c627358be 100644 --- a/src/blackgui/components/dblogincomponent.h +++ b/src/blackgui/components/dblogincomponent.h @@ -41,7 +41,7 @@ namespace BlackGui private: QScopedPointer ui; BlackMisc::CData m_setup {this, &CDbLoginComponent::ps_setupChanged}; //!< data cache - BlackCore::CDatabaseAuthenticationService m_loginService {this}; //!< login service + BlackCore::CDatabaseAuthenticationService m_loginService {this}; //!< login service //! Overlay messages void displayOverlayMessages(const BlackMisc::CStatusMessageList &msgs); diff --git a/src/blackgui/components/dbmappingcomponent.cpp b/src/blackgui/components/dbmappingcomponent.cpp index 33b9f5c46..78d8dcb03 100644 --- a/src/blackgui/components/dbmappingcomponent.cpp +++ b/src/blackgui/components/dbmappingcomponent.cpp @@ -91,7 +91,7 @@ namespace BlackGui void CDbMappingComponent::initVPilotLoading() { bool canUseVPilot = true; // general flag if vPilot can be used/not used - this->m_withVPilot = canUseVPilot && this->m_user.get().isMappingAdmin(); + this->m_withVPilot = canUseVPilot && this->m_swiftDbUser.get().isMappingAdmin(); static const QString tabName(this->ui->tw_ModelsToBeMapped->tabText(TabVPilot)); if (this->m_vPilot1stInit && canUseVPilot) diff --git a/src/blackgui/components/dbmappingcomponent.h b/src/blackgui/components/dbmappingcomponent.h index a2ef69279..cebc28cec 100644 --- a/src/blackgui/components/dbmappingcomponent.h +++ b/src/blackgui/components/dbmappingcomponent.h @@ -213,16 +213,16 @@ namespace BlackGui private: QScopedPointer ui; - QScopedPointer m_autoStashDialog; - QScopedPointer m_modelModifyDialog; - BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules + QScopedPointer m_autoStashDialog; + QScopedPointer m_modelModifyDialog; + BlackMisc::Simulation::FsCommon::CVPilotRulesReader m_vPilotReader; //!< read vPilot rules + std::unique_ptr m_modelLoader; //!< read own aircraft models BlackMisc::CData m_cachedVPilotModels { this, &CDbMappingComponent::ps_onVPilotCacheChanged }; //!< cache for latest vPilot rules - std::unique_ptr m_modelLoader; //!< read own aircraft models BlackMisc::CData m_cachedOwnModels { this, &CDbMappingComponent::ps_ownModelsCacheChanged }; //!< cache for own installed models - BlackMisc::CData m_user {this, &CDbMappingComponent::ps_userChanged}; + BlackMisc::CData m_swiftDbUser {this, &CDbMappingComponent::ps_userChanged}; bool m_vPilot1stInit = true; bool m_withVPilot = false; - bool m_autoFilterInDbViews = false; //!< automatically filter the DB view by the current model + bool m_autoFilterInDbViews = false; //!< automatically filter the DB view by the current model //! Init vPilot if rights and suitable void initVPilotLoading(); diff --git a/src/blackgui/editors/form.cpp b/src/blackgui/editors/form.cpp index 2699b9dbd..97106a700 100644 --- a/src/blackgui/editors/form.cpp +++ b/src/blackgui/editors/form.cpp @@ -19,9 +19,9 @@ namespace BlackGui CForm::~CForm() { } - const BlackMisc::Network::CAuthenticatedUser &CForm::getUser() const + const BlackMisc::Network::CAuthenticatedUser &CForm::getSwiftDbUser() const { - return this->m_user.get(); + return this->m_swiftDbUser.get(); } void CForm::ps_userChanged() diff --git a/src/blackgui/editors/form.h b/src/blackgui/editors/form.h index 4e74c418a..c7fdceb8b 100644 --- a/src/blackgui/editors/form.h +++ b/src/blackgui/editors/form.h @@ -46,11 +46,11 @@ namespace BlackGui bool isReadOnly() const { return m_readOnly; } //! Authenticated user - const BlackMisc::Network::CAuthenticatedUser &getUser() const; + const BlackMisc::Network::CAuthenticatedUser &getSwiftDbUser() const; protected: bool m_readOnly = false; //!< read only - BlackMisc::CData m_user {this, &CForm::ps_userChanged}; //!< authenticated user + BlackMisc::CData m_swiftDbUser {this, &CForm::ps_userChanged}; //!< authenticated user protected slots: //! User has been changed diff --git a/src/blackgui/editors/modelmappingform.cpp b/src/blackgui/editors/modelmappingform.cpp index 5120b08e4..623fafc67 100644 --- a/src/blackgui/editors/modelmappingform.cpp +++ b/src/blackgui/editors/modelmappingform.cpp @@ -79,7 +79,7 @@ namespace BlackGui void CModelMappingForm::ps_userChanged() { - const CAuthenticatedUser user(this->getUser()); + const CAuthenticatedUser user(this->getSwiftDbUser()); if (user.isAdmin()) { ui->selector_ModelMode->setValue(CAircraftModel::Include);