From d754c09d47e7081277e0785b71847d07d361c4d9 Mon Sep 17 00:00:00 2001 From: davidpanderson Date: Thu, 20 Aug 2020 17:49:29 -0700 Subject: [PATCH] client: if project_init.xml specifies project and account, attach to it without involving the Manager. --- client/client_state.cpp | 6 ++++++ clientgui/WizardAttach.cpp | 2 +- clientsetup/win/CACreateProjectInitFile.cpp | 17 ++++++++++++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/client/client_state.cpp b/client/client_state.cpp index ffd6f29bdd..1b119ab673 100644 --- a/client/client_state.cpp +++ b/client/client_state.cpp @@ -767,6 +767,12 @@ int CLIENT_STATE::init() { process_autologin(true); acct_mgr_info.init(); project_init.init(); + // if project_init.xml specifies an account, attach + // + if (strlen(project_init.url) && strlen(project_init.account_key)) { + add_project(project_init.url, project_init.account_key, project_init.name, false); + project_init.remove(); + } log_show_projects(); // this must follow acct_mgr_info.init() diff --git a/clientgui/WizardAttach.cpp b/clientgui/WizardAttach.cpp index 01c33ef3e6..2966134248 100644 --- a/clientgui/WizardAttach.cpp +++ b/clientgui/WizardAttach.cpp @@ -285,7 +285,7 @@ bool CWizardAttach::Run( if (m_ProjectPropertiesPage && m_ProjectInfoPage && m_ProjectWelcomePage) { IsAttachToProjectWizard = true; IsAccountManagerWizard = false; - if ((strProjectName.size() && strProjectURL.size())) { + if (strProjectName.size() && strProjectURL.size()) { return RunWizard(m_ProjectWelcomePage); } else if (strProjectURL.size() && (IsCredentialsCached() || IsCredentialsDetected())) { return RunWizard(m_ProjectPropertiesPage); diff --git a/clientsetup/win/CACreateProjectInitFile.cpp b/clientsetup/win/CACreateProjectInitFile.cpp index adcca59659..019ed733f6 100644 --- a/clientsetup/win/CACreateProjectInitFile.cpp +++ b/clientsetup/win/CACreateProjectInitFile.cpp @@ -69,6 +69,7 @@ UINT CACreateProjectInitFile::OnExecution() tstring strDataDirectory; tstring strProjectInitUrl; tstring strProjectInitAuthenticator; + tstring project_name; PROJECT_INIT pi; UINT uiReturnValue = 0; @@ -78,6 +79,9 @@ UINT CACreateProjectInitFile::OnExecution() uiReturnValue = GetProperty( _T("PROJINIT_URL"), strProjectInitUrl ); if ( uiReturnValue ) return uiReturnValue; + uiReturnValue = GetProperty(_T("PROJINIT_NAME"), project_name); + if (uiReturnValue) return uiReturnValue; + uiReturnValue = GetProperty( _T("PROJINIT_AUTH"), strProjectInitAuthenticator ); if ( uiReturnValue ) return uiReturnValue; @@ -99,7 +103,7 @@ UINT CACreateProjectInitFile::OnExecution() if (!strProjectInitUrl.empty()) { LogMessage( INSTALLMESSAGE_INFO, - NULL, + NULL, NULL, NULL, NULL, @@ -108,10 +112,13 @@ UINT CACreateProjectInitFile::OnExecution() pi.init(); - strncpy(pi.url, CW2A(strProjectInitUrl.c_str()), sizeof(pi.url)-1); - strncpy(pi.name, CW2A(strProjectInitUrl.c_str()), sizeof(pi.name)-1); - // Use project URL as name - // TODO: add a cmdline arg for project name + strncpy(pi.url, CW2A(strProjectInitUrl.c_str()), sizeof(pi.url) - 1); + if (!project_name.empty()) { + strncpy(pi.name, CW2A(project_name.c_str()), sizeof(pi.name) - 1); + } else { + strncpy(pi.name, CW2A(strProjectInitUrl.c_str()), sizeof(pi.name) - 1); + } + strncpy(pi.account_key, CW2A(strProjectInitAuthenticator.c_str()), sizeof(pi.account_key)-1); pi.embedded = false;