File indexing completed on 2025-01-05 05:14:45
0001 /* 0002 SPDX-FileCopyrightText: 2022 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "libkommit_export.h" 0010 0011 #include <QObject> 0012 0013 #include <git2/credential.h> 0014 #include <git2/indexer.h> 0015 #include <git2/types.h> 0016 0017 namespace Git 0018 { 0019 0020 namespace FetchObserverCallbacks 0021 { 0022 int git_helper_update_tips_cb(const char *refname, const git_oid *a, const git_oid *b, void *data); 0023 int git_helper_sideband_progress_cb(const char *str, int len, void *payload); 0024 int git_helper_transfer_progress_cb(const git_indexer_progress *stats, void *payload); 0025 int git_helper_credentials_cb(git_credential **out, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload); 0026 int git_helper_packbuilder_progress(int stage, uint32_t current, uint32_t total, void *payload); 0027 int git_helper_transport_cb(git_transport **out, git_remote *owner, void *param); 0028 } 0029 0030 class LIBKOMMIT_EXPORT Credential 0031 { 0032 Q_GADGET 0033 public: 0034 enum class AllowedType { 0035 UserpassPlaintext, 0036 SshKey, 0037 SshCustom, 0038 Defaut, 0039 SshInteractive, 0040 Username, 0041 SshMemory, 0042 }; 0043 Q_DECLARE_FLAGS(AllowedTypes, AllowedType) 0044 Q_FLAG(AllowedTypes) 0045 0046 Q_REQUIRED_RESULT QString username() const; 0047 void setUsername(const QString &username); 0048 0049 Q_REQUIRED_RESULT QString password() const; 0050 void setPassword(const QString &password); 0051 0052 Q_REQUIRED_RESULT AllowedTypes allowedTypes() const; 0053 void setAllowedTypes(const AllowedTypes &allowedTypes); 0054 0055 private: 0056 QString mUsername; 0057 QString mPassword; 0058 AllowedTypes mAllowedTypes; 0059 }; 0060 0061 class LIBKOMMIT_EXPORT FetchObserver : public QObject 0062 { 0063 Q_OBJECT 0064 0065 Q_PROPERTY(unsigned int totalObjects READ totalObjects WRITE setTotalObjects NOTIFY totalObjectsChanged FINAL) 0066 Q_PROPERTY(unsigned int indexedObjects READ indexedObjects WRITE setIndexedObjects NOTIFY indexedObjectsChanged FINAL) 0067 Q_PROPERTY(unsigned int receivedObjects READ receivedObjects WRITE setReceivedObjects NOTIFY receivedObjectsChanged FINAL) 0068 Q_PROPERTY(unsigned int localObjects READ localObjects WRITE setLocalObjects NOTIFY localObjectsChanged FINAL) 0069 Q_PROPERTY(unsigned int totalDeltas READ totalDeltas WRITE setTotalDeltas NOTIFY totalDeltasChanged FINAL) 0070 Q_PROPERTY(unsigned int indexedDeltas READ indexedDeltas WRITE setIndexedDeltas NOTIFY indexedDeltasChanged FINAL) 0071 0072 public: 0073 FetchObserver(QObject *parent = nullptr); 0074 0075 Q_REQUIRED_RESULT unsigned int totalObjects() const; 0076 void setTotalObjects(unsigned int totalObjects); 0077 0078 Q_REQUIRED_RESULT unsigned int indexedObjects() const; 0079 void setIndexedObjects(unsigned int indexedObjects); 0080 0081 Q_REQUIRED_RESULT unsigned int receivedObjects() const; 0082 void setReceivedObjects(unsigned int receivedObjects); 0083 0084 Q_REQUIRED_RESULT unsigned int localObjects() const; 0085 void setLocalObjects(unsigned int localObjects); 0086 0087 Q_REQUIRED_RESULT unsigned int totalDeltas() const; 0088 void setTotalDeltas(unsigned int totalDeltas); 0089 0090 Q_REQUIRED_RESULT unsigned int indexedDeltas() const; 0091 void setIndexedDeltas(unsigned int indexedDeltas); 0092 0093 void setCredential(const QString &username, const QString &password); 0094 Q_REQUIRED_RESULT QString username() const; 0095 Q_REQUIRED_RESULT QString password() const; 0096 0097 Q_SIGNALS: 0098 void totalObjectsChanged(int value); 0099 void indexedObjectsChanged(); 0100 void receivedObjectsChanged(int value); 0101 void localObjectsChanged(); 0102 void totalDeltasChanged(); 0103 void indexedDeltasChanged(); 0104 0105 void message(const QString &message); 0106 // void credentialRequeted(); 0107 void credentialRequeted(const QString &url, Credential *cred); 0108 0109 private: 0110 unsigned int mTotalObjects{}; 0111 unsigned int mIndexedObjects{}; 0112 unsigned int mReceivedObjects{}; 0113 unsigned int mLocalObjects{}; 0114 unsigned int mTotalDeltas{}; 0115 unsigned int mIndexedDeltas{}; 0116 0117 QString mUsername; 0118 QString mPassword; 0119 }; 0120 0121 }