mirror of
https://github.com/QRouland/UTPass.git
synced 2026-01-10 03:26:57 +00:00
Refactor cloning feature and ui
This commit is contained in:
53
plugins/Git/jobs/gitjob.cpp
Normal file
53
plugins/Git/jobs/gitjob.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "gitjob.h"
|
||||
#include "../utils.h"
|
||||
|
||||
extern "C" {
|
||||
#include <git2.h>
|
||||
}
|
||||
|
||||
GitJob::GitJob(cred_type cred) :
|
||||
m_cred(cred)
|
||||
{
|
||||
git_libgit2_init();
|
||||
}
|
||||
|
||||
GitJob::~GitJob()
|
||||
{
|
||||
git_libgit2_shutdown();
|
||||
}
|
||||
|
||||
int GitJob::credentialsCB(git_cred **out, const char *url, const char *username_from_url,
|
||||
unsigned int allowed_types, void *payload)
|
||||
{
|
||||
cred_type *cred = (cred_type *)payload;
|
||||
auto v = overload {
|
||||
[](const HTTP & x)
|
||||
{
|
||||
qDebug() << "credentialsCB : HTTP ";
|
||||
qWarning() << "credentialsCB : callback should never be call for HTTP ";
|
||||
return (int) GIT_EUSER;
|
||||
},
|
||||
[&out, &username_from_url](const HTTPUserPass & x)
|
||||
{
|
||||
qDebug() << "credentialsCB : HTTPUserPass ";
|
||||
if (!username_from_url) {
|
||||
qWarning() << "credentials_cb : no username provided ";
|
||||
return (int) GIT_EUSER;
|
||||
}
|
||||
return git_cred_userpass_plaintext_new(out, username_from_url, x.pass.toLocal8Bit().constData());
|
||||
},
|
||||
[](const SSHPass & x)
|
||||
{
|
||||
qWarning() << "credentials_cb : SSHAuth to be implemented ";
|
||||
return (int) GIT_EUSER;
|
||||
}, // TODO
|
||||
[](const SSHKey & x)
|
||||
{
|
||||
qWarning() << "credentials_cb : SSHKey to be implemented ";
|
||||
return (int) GIT_EUSER;
|
||||
} // TODO
|
||||
};
|
||||
return std::visit(v, *cred);
|
||||
}
|
||||
Reference in New Issue
Block a user