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 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 DIALOG_GIT_REPOSITORY_H_
21#define DIALOG_GIT_REPOSITORY_H_
22
24
26#include <git2.h>
27
29{
30public:
31 DIALOG_GIT_REPOSITORY( wxWindow* aParent, git_repository* aRepository,
32 wxString aURL = wxEmptyString );
33 ~DIALOG_GIT_REPOSITORY() override;
34
36 {
37 m_ConnType->SetSelection( static_cast<int>( aType ) );
39 }
40
42 {
43 return static_cast<KIGIT_COMMON::GIT_CONN_TYPE>( m_ConnType->GetSelection() );
44 }
45
46 void SetRepoName( const wxString& aName ) { m_txtName->SetValue( aName ); }
47 wxString GetRepoName() const { return m_txtName->GetValue(); }
48
49 void SetRepoURL( const wxString& aURL ) { m_txtURL->SetValue( aURL ); }
50 wxString GetRepoURL() const { return m_txtURL->GetValue(); }
51
57 wxString GetBareRepoURL() const
58 {
59 wxString url = m_txtURL->GetValue();
60
61 if( url.StartsWith( "https://" ) )
62 url = url.Mid( 8 );
63 else if( url.StartsWith( "http://" ) )
64 url = url.Mid( 7 );
65 else if( url.StartsWith( "ssh://" ) )
66 url = url.Mid( 6 );
67
68 return url;
69 }
70
71 const wxString& GetFullURL() const { return m_fullURL; }
72
73 void SetUsername( const wxString& aUsername ) { m_txtUsername->SetValue( aUsername ); }
74 wxString GetUsername() const { return m_txtUsername->GetValue(); }
75
76 void SetPassword( const wxString& aPassword ) { m_txtPassword->SetValue( aPassword ); }
77 wxString GetPassword() const { return m_txtPassword->GetValue(); }
78
79 void SetRepoSSHPath( const wxString& aPath ) { m_fpSSHKey->SetFileName( aPath ); m_prevFile = aPath; }
80 wxString GetRepoSSHPath() const { return m_fpSSHKey->GetFileName().GetFullPath(); }
81
82 void SetEncrypted( bool aEncrypted = true );
83
84 void SetSkipButtonLabel( const wxString& aLabel )
85 {
87 {
88 m_sdbSizerCancel->SetLabel( aLabel );
89 m_sdbSizerCancel->Layout();
90 }
91 }
92
93protected:
94 virtual bool TransferDataToWindow() override;
95
96private:
97 void OnUpdateUI( wxUpdateUIEvent& event ) override;
98 void OnLocationExit( wxFocusEvent& event ) override;
99 void OnOKClick( wxCommandEvent& event ) override;
100
101 void OnSelectConnType( wxCommandEvent& event ) override;
102 void OnTestClick( wxCommandEvent& event ) override;
103
104 void OnFileUpdated( wxFileDirPickerEvent& event ) override;
105 void onCbCustom( wxCommandEvent& event ) override;
106
107 void setDefaultSSHKey();
108
109 void updateAuthControls();
110 void updateURLData();
112
113 std::tuple<bool,wxString,wxString,wxString> isValidHTTPS( const wxString& url );
114 std::tuple<bool,wxString, wxString> isValidSSH( const wxString& url );
115
116 git_repository* m_repository;
117 wxString m_fullURL;
118 wxString m_incomeURL;
119
120 wxString m_prevFile;
121
123 wxString m_tempPath;
124};
125
126#endif /* DIALOG_GIT_REPOSITORY_H_ */
DIALOG_GIT_REPOSITORY_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Git Repository"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxCAPTION|wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void OnSelectConnType(wxCommandEvent &event) override
const wxString & GetFullURL() const
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)
void onCbCustom(wxCommandEvent &event) override
wxString GetRepoSSHPath() const
void SetEncrypted(bool aEncrypted=true)
void OnLocationExit(wxFocusEvent &event) override
DIALOG_GIT_REPOSITORY(wxWindow *aParent, git_repository *aRepository, wxString aURL=wxEmptyString)
void OnTestClick(wxCommandEvent &event) override
void SetRepoURL(const wxString &aURL)
void OnOKClick(wxCommandEvent &event) override
void SetUsername(const wxString &aUsername)
std::tuple< bool, wxString, wxString, wxString > isValidHTTPS(const wxString &url)
virtual bool TransferDataToWindow() override
void OnUpdateUI(wxUpdateUIEvent &event) override
void SetSkipButtonLabel(const wxString &aLabel)