KiCad PCB EDA Suite
Loading...
Searching...
No Matches
git_credentials_prompt.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 3
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef GIT_CREDENTIALS_PROMPT_H
21#define GIT_CREDENTIALS_PROMPT_H
22
26
27#include <memory>
28#include <optional>
29#include <wx/string.h>
30
31class EDA_BASE_FRAME;
32class wxWindow;
33class KIGIT_COMMON;
34class PROJECT;
35
36namespace KIGIT
37{
38
45
58PROMPT_ANSWER PromptForCredentials( wxWindow* aParent, KIGIT_COMMON* aCommon, PROJECT* aProject = nullptr,
59 const wxString& aExplanation = wxEmptyString );
60
68PROMPT_ANSWER PromptToTrustHost( wxWindow* aParent, const HOST_KEY_FAILURE& aFailure, bool aRetriedAfterTrust );
69
72constexpr int MAX_CREDENTIAL_PROMPTS = 3;
73
76{
77 bool cancelled = false;
78 bool authFailure = false;
79 std::optional<HOST_KEY_FAILURE> hostKey;
80 wxString error;
81};
82
93
99TRANSFER_RETRY AnswerTransferFailure( wxWindow* aParent, const std::weak_ptr<bool>& aAlive, KIGIT_COMMON* aCommon,
100 PROJECT* aProject, const TRANSFER_FAILURE& aFailure, bool aRetriedAfterTrust,
101 int& aPrompts );
102
104inline constexpr const wxChar* SYNC_WARNING_SOURCE = wxS( "git" );
105
107void ClearSyncWarnings( wxWindow* aWindow );
108
111void ClearSyncWarnings( const KIGIT_COMMON* aCommon );
112
115{
117 bool configured = false;
118};
119
122
124GitUserConfig ResolveGitIdentity( const GIT_IDENTITY& aIdentity, const COMMON_SETTINGS::GIT& aPreferences,
125 const wxString& aUserName );
126
129bool EditGitIdentity( wxWindow* aParent, EDA_BASE_FRAME* aFrame, const std::shared_ptr<KIGIT_COMMON>& aCommon,
130 const GIT_IDENTITY& aIdentity );
131
133bool EnsureGitIdentity( wxWindow* aParent, EDA_BASE_FRAME* aFrame, const std::shared_ptr<KIGIT_COMMON>& aCommon,
134 const GIT_IDENTITY& aIdentity );
135
136} // namespace KIGIT
137
138#endif // GIT_CREDENTIALS_PROMPT_H
The base frame for deriving all KiCad main window classes.
The project's git session.
Container for project specific data.
Definition project.h:63
constexpr int MAX_CREDENTIAL_PROMPTS
Keyring reads and credential prompts that may follow a request's failures before one is reported inst...
void ClearSyncWarnings(wxWindow *aWindow)
Clear the background fetch's warnings from the frame holding aWindow.
GitUserConfig ResolveGitIdentity(const GIT_IDENTITY &aIdentity, const COMMON_SETTINGS::GIT &aPreferences, const wxString &aUserName)
Fill missing values from custom preferences, then use the OS user name if needed.
@ ABANDONED
The parent closed while the prompt was up, so the caller must not touch it.
constexpr const wxChar * SYNC_WARNING_SOURCE
The status bar source under which background fetch failures are listed.
GIT_IDENTITY ReadGitIdentity(KIGIT_COMMON &aCommon)
Read on a worker while holding the session's action lock.
bool EnsureGitIdentity(wxWindow *aParent, EDA_BASE_FRAME *aFrame, const std::shared_ptr< KIGIT_COMMON > &aCommon, const GIT_IDENTITY &aIdentity)
Open the same editor when the worker snapshot has no usable Git identity.
TRANSFER_RETRY AnswerTransferFailure(wxWindow *aParent, const std::weak_ptr< bool > &aAlive, KIGIT_COMMON *aCommon, PROJECT *aProject, const TRANSFER_FAILURE &aFailure, bool aRetriedAfterTrust, int &aPrompts)
Answer a failed transfer the way every window does.
PROMPT_ANSWER PromptForCredentials(wxWindow *aParent, KIGIT_COMMON *aCommon, PROJECT *aProject=nullptr, const wxString &aExplanation=wxEmptyString)
Ask the user for the credentials of the session's remote and apply them to the session.
PROMPT_ANSWER PromptToTrustHost(wxWindow *aParent, const HOST_KEY_FAILURE &aFailure, bool aRetriedAfterTrust)
Ask whether to trust a server seen for the first time, and remember its key when the user agrees.
TRANSFER_RETRY
What a window does after AnswerTransferFailure.
@ RETRY_TRUSTED
Run it again, now that the server's key is trusted.
@ GONE
The window closed during a prompt, so the caller must not touch it.
@ CANCELLED
Stop and say so, the user cancelled the transfer or a prompt.
@ RETRY
Run the transfer again.
@ HOST_DECLINED
Stop without a message, the user chose not to trust the server.
bool EditGitIdentity(wxWindow *aParent, EDA_BASE_FRAME *aFrame, const std::shared_ptr< KIGIT_COMMON > &aCommon, const GIT_IDENTITY &aIdentity)
Edit the repository's author and refresh Git views after saving.
Repository values and whether Git can use them to record a commit.
Why a transfer to a remote failed.
bool cancelled
The user cancelled the transfer.
std::optional< HOST_KEY_FAILURE > hostKey
The server's key is unknown or has changed.
bool authFailure
The remote refused every credential offered.
wxString error
Shown above the credential fields.