KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_git_repository.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 (C) 2023 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, you may find one here:
18 * http://www.gnu.org/licenses/gpl-3.0.html
19 * or you may search the http://www.gnu.org website for the version 3 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef DIALOG_GIT_REPOSITORY_H_
25#define DIALOG_GIT_REPOSITORY_H_
26
28
30#include <git2.h>
31
33{
34public:
35 DIALOG_GIT_REPOSITORY( wxWindow* aParent, git_repository* aRepository,
36 wxString aURL = wxEmptyString );
37 ~DIALOG_GIT_REPOSITORY() override;
38
39 void SetTestResult( bool aFailed, const wxString& aError )
40 {
41 m_failedTest = aFailed;
42 m_testError = aError;
43 }
44
46 {
47 m_ConnType->SetSelection( static_cast<int>( aType ) );
49 }
50
52 {
53 return static_cast<KIGIT_COMMON::GIT_CONN_TYPE>( m_ConnType->GetSelection() );
54 }
55
56 void SetRepoName( const wxString& aName ) { m_txtName->SetValue( aName ); }
57 wxString GetRepoName() const { return m_txtName->GetValue(); }
58
59 void SetRepoURL( const wxString& aURL ) { m_txtURL->SetValue( aURL ); }
60 wxString GetRepoURL() const { return m_txtURL->GetValue(); }
61
67 wxString GetBareRepoURL() const
68 {
69 wxString url = m_txtURL->GetValue();
70
71 if( url.StartsWith( "https://" ) )
72 url = url.Mid( 8 );
73 else if( url.StartsWith( "http://" ) )
74 url = url.Mid( 7 );
75 else if( url.StartsWith( "ssh://" ) )
76 url = url.Mid( 6 );
77
78 return url;
79 }
80
81 void SetUsername( const wxString& aUsername ) { m_txtUsername->SetValue( aUsername ); }
82 wxString GetUsername() const { return m_txtUsername->GetValue(); }
83
84 void SetPassword( const wxString& aPassword ) { m_txtPassword->SetValue( aPassword ); }
85 wxString GetPassword() const { return m_txtPassword->GetValue(); }
86
87 void SetRepoSSHPath( const wxString& aPath ) { m_fpSSHKey->SetFileName( aPath ); m_prevFile = aPath; }
88 wxString GetRepoSSHPath() const { return m_fpSSHKey->GetFileName().GetFullPath(); }
89
90 unsigned& GetTested() { return m_tested; }
91
92 void SetEncrypted( bool aEncrypted = true );
93
94private:
95 void OnUpdateUI( wxUpdateUIEvent& event ) override;
96 void OnLocationExit( wxFocusEvent& event ) override;
97 void OnOKClick( wxCommandEvent& event ) override;
98
99 void OnSelectConnType( wxCommandEvent& event ) override;
100 void OnTestClick( wxCommandEvent& event ) override;
101
102 void OnFileUpdated( wxFileDirPickerEvent& event ) override;
103
104 void setDefaultSSHKey();
105
106 void updateAuthControls();
107 void updateURLData();
109
110 std::tuple<bool,wxString,wxString,wxString> isValidHTTPS( const wxString& url );
111 std::tuple<bool,wxString, wxString> isValidSSH( const wxString& url );
112
113private:
114 git_repository* m_repository;
115
116 wxString m_prevFile;
117
118 unsigned m_tested;
120 wxString m_testError;
121
123 wxString m_tempPath;
124};
125
126#endif /* DIALOG_GIT_REPOSITORY_H_ */
Class DIALOG_GIT_REPOSITORY_BASE.
void OnSelectConnType(wxCommandEvent &event) override
void SetRepoType(KIGIT_COMMON::GIT_CONN_TYPE aType)
std::tuple< bool, wxString, wxString > isValidSSH(const wxString &url)
void SetRepoSSHPath(const wxString &aPath)
KIGIT_COMMON::GIT_CONN_TYPE GetRepoType() const
void OnFileUpdated(wxFileDirPickerEvent &event) override
void SetRepoName(const wxString &aName)
wxString GetBareRepoURL() const
Get the Bare Repo U R L object.
void SetPassword(const wxString &aPassword)
wxString GetRepoSSHPath() const
void SetTestResult(bool aFailed, const wxString &aError)
void SetEncrypted(bool aEncrypted=true)
void OnLocationExit(wxFocusEvent &event) override
void OnTestClick(wxCommandEvent &event) override
void SetRepoURL(const wxString &aURL)
wxString GetUsername() const
void OnOKClick(wxCommandEvent &event) override
wxString GetRepoName() const
void SetUsername(const wxString &aUsername)
std::tuple< bool, wxString, wxString, wxString > isValidHTTPS(const wxString &url)
void OnUpdateUI(wxUpdateUIEvent &event) override
wxString GetPassword() const