Compare commits

..

28 Commits

Author SHA1 Message Date
5ecc35ddd2 save 2019-10-07 18:18:50 +02:00
42efea67d8 Add git plugin TG-41 closed 2019-10-07 18:18:49 +02:00
1818d3d7e8 Add libgit2 as third dependencies TG-40 2019-10-07 18:18:49 +02:00
df5321644a bump version 2019-10-07 18:18:49 +02:00
774019f4d0 Bump version 0.0.2 2019-10-07 18:12:13 +02:00
Reda
a1b87a7b45 Translated using Weblate (French)
Currently translated at 100.0% (40 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/fr/
2019-10-07 18:07:10 +02:00
Reda
5d92b767a7 Translated using Weblate (French)
Currently translated at 100.0% (40 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/fr/
2019-10-07 18:07:10 +02:00
6a419c5a05 Translated using Weblate (French)
Currently translated at 100.0% (40 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/fr/
2019-10-07 18:07:10 +02:00
Reda
5bb5d36630 Translated using Weblate (French)
Currently translated at 100.0% (40 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/fr/
2019-10-07 18:07:10 +02:00
3264c26358 Translated using Weblate (French)
Currently translated at 100.0% (40 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/fr/
2019-10-07 18:07:10 +02:00
d53a012565 Update headers translation files 2019-10-07 18:07:10 +02:00
Joan CiberSheep
49c992aa8d Translated using Weblate (Catalan)
Currently translated at 100.0% (40 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/ca/
2019-10-07 18:07:10 +02:00
Advocatux
123df71a5b Translated using Weblate (Spanish)
Currently translated at 100.0% (40 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:10 +02:00
Reda
fab14a395e Translated using Weblate (French)
Currently translated at 100.0% (40 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/fr/
2019-10-07 18:07:10 +02:00
Richard Lee
cd3dc273b0 Translated using Weblate (French)
Currently translated at 100.0% (40 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/fr/
2019-10-07 18:07:10 +02:00
Reda
30727fde23 Translated using Weblate (Spanish)
Currently translated at 92.5% (37 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:10 +02:00
Advocatux
a6113f26ec Translated using Weblate (Spanish)
Currently translated at 92.5% (37 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:10 +02:00
Reda
09a58ee24b Translated using Weblate (Spanish)
Currently translated at 85.0% (34 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:10 +02:00
Advocatux
a722e7c261 Translated using Weblate (Spanish)
Currently translated at 85.0% (34 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:09 +02:00
Reda
17a533a2ef Translated using Weblate (Spanish)
Currently translated at 77.5% (31 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:09 +02:00
Advocatux
98ae4cc3d9 Translated using Weblate (Spanish)
Currently translated at 77.5% (31 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:09 +02:00
Reda
b48d9381f2 Translated using Weblate (Spanish)
Currently translated at 65.0% (26 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:09 +02:00
Advocatux
378e19e205 Translated using Weblate (Spanish)
Currently translated at 65.0% (26 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:09 +02:00
Reda
2e98d4356b Translated using Weblate (Spanish)
Currently translated at 50.0% (20 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:09 +02:00
Advocatux
7e4ef02f8c Translated using Weblate (Spanish)
Currently translated at 50.0% (20 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:09 +02:00
Reda
418b64a191 Translated using Weblate (Spanish)
Currently translated at 0.0% (0 of 40 strings)

Translation: UTPass/UTPass
Translate-URL: https://translate-ut.org/projects/utpass/utpass/es/
2019-10-07 18:07:09 +02:00
Joan CiberSheep
96e79d97c4 Added translation using Weblate (Catalan) 2019-10-07 18:07:09 +02:00
Advocatux
ace251c209 Added translation using Weblate (Spanish) 2019-10-07 18:07:09 +02:00
19 changed files with 403 additions and 54 deletions

3
.gitmodules vendored
View File

@ -16,3 +16,6 @@
[submodule "libs/libgit2"]
path = libs/libgit2
url = https://github.com/libgit2/libgit2
[submodule "libs/git/openssl"]
path = libs/git/openssl
url = https://github.com/openssl/openssl

View File

@ -55,6 +55,8 @@ install(
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${BIN_DIR}
)
install(FILES /usr/lib/${ARCH_TRIPLET}/libssl.so DESTINATION /lib/${ARCH_TRIPLET})
install(FILES /usr/lib/${ARCH_TRIPLET}/libcrypto.so DESTINATION /lib/${ARCH_TRIPLET})
# Translations
file(GLOB_RECURSE I18N_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po qml/*.qml qml/*.js)

View File

@ -21,7 +21,10 @@
"libgit2": {
"template": "cmake",
"make_jobs": 4,
"build_args": "-DBUILD_SHARED_LIBS=OFF"
"build_args": "-DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC"
}
}
},
"dependencies_target": [
"libssl-dev"
]
}

35
libs/git/CMakeLists.txt Normal file
View File

@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.5.1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
execute_process(
COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
OUTPUT_VARIABLE ARCH_TRIPLET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process (
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/clean.sh ${ARCH_TRIPLET}
)
set(THIRD_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
set(OPENSSL_PATH "${THIRD_PATH}/libgit2")
set(LIBGIT2_PATH "${THIRD_PATH}/openssl/")
ExternalProject_Add(
OPENSSL_PATH
INSTALL_DIR ${EXTERNAL_LIBS}
DOWNLOAD_COMMAND ""
SOURCE_DIR ${OPENSSL_PATH}
CONFIGURE_COMMAND <SOURCE_DIR>/configure
BUILD_COMMAND make
INSTALL_COMMAND make install
)
ExternalProject_Add(
LIBGIT2_PATH
INSTALL_DIR ${EXTERNAL_LIBS}
DOWNLOAD_COMMAND ""
SOURCE_DIR ${LIBGIT2_PATH}
)

1
libs/git/openssl Submodule

@ -0,0 +1 @@
Subproject commit 894da2fb7ed5d314ee5c2fc9fd2d9b8b74111596

View File

@ -10,7 +10,7 @@
"content-hub": "UTPass.contenthub"
}
},
"version": "0.0.2-dev",
"version": "0.0.3-dev",
"maintainer": "Quentin Rouland <quentin@qrouland.com>",
"framework" : "ubuntu-sdk-16.04"
}

View File

@ -30,7 +30,9 @@ INCLUDE_DIRECTORIES(${EXTERNAL_LIBS}/include)
add_library(libgit2 STATIC IMPORTED)
set_property(TARGET libgit2 PROPERTY IMPORTED_LOCATION "${EXTERNAL_LIBS}/lib/libgit2.a")
target_link_libraries(${PLUGIN} libgit2)
find_package(OpenSSL REQUIRED)
target_link_libraries(${PLUGIN} libgit2 ${OPENSSL_LIBRARIES})
set(QT_IMPORTS_DIR "/lib/${ARCH_TRIPLET}")

View File

@ -1,10 +1,68 @@
#include <QDebug>
#include <QUrl>
#include <QStandardPaths>
#include <QDir>
extern "C" {
#include <git2.h>
}
#include "git.h"
#include "passphraseprovider.h"
Git::Git() {};
Git::Git() {
git_libgit2_init();
};
Git::~Git() {
git_libgit2_shutdown();
};
bool Git::clone(QUrl url, QString dir_out_path) {
auto ret = false;
auto tmp_dir_path = QStandardPaths::writableLocation(
QStandardPaths::CacheLocation).append("/clone");
auto gitCred = new UTGitCredProvider();
pt2cred_acquire_cb = gitCred->cred_acquire_cb;
QDir tmp_dir(tmp_dir_path);
tmp_dir.removeRecursively();
git_repository *cloned_repo = NULL;
git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT;
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE;
clone_opts.checkout_opts = checkout_opts;
clone_opts.fetch_opts.callbacks.credentials = gitCred->*pt2cred_acquire_cb;
qDebug() << "Cloning " << url << " in " << tmp_dir_path;
auto error = git_clone(&cloned_repo, url.toString().toLocal8Bit().constData(), tmp_dir_path.toLocal8Bit().constData(), &clone_opts);
if (cloned_repo) {
git_repository_free(cloned_repo);
}
if(error) {
const git_error *err = giterr_last();
if (err) {
qDebug() << "ERROR " << err->klass << ": " << err->message;
}
else {
qDebug() << "ERROR " << error << ": no detailed info";
}
}
else {
qDebug() << "Removing destination";
QDir dir_out(dir_out_path);
dir_out.removeRecursively();
qDebug() << "Moving cloned dir to destination";
QDir dir;
qDebug() << tmp_dir_path << " to " << dir_out_path;
ret = dir.rename(tmp_dir_path, dir_out_path);
}
tmp_dir.removeRecursively();
delete gitCred;
return !error and ret;
}

View File

@ -10,7 +10,9 @@ class Git : public QObject
public:
Git();
~Git() override = default;
~Git();
Q_INVOKABLE bool clone(QUrl clone_url, QString dir_out);
};

View File

@ -0,0 +1,77 @@
#ifndef UTGITCREDPROVIDER_H
#define UTGITCREDPROVIDER_H
class UTGitCredProvider : public QObject, public PassphraseProvider
{
Q_OBJECT
private:
std::unique_ptr<QEventLoop> m_loop;
std::unique_ptr<QSemaphore> m_sem;
char *m_user;
char *m_password;
bool m_canceled;
public slots:
void handleResponse(bool canceled, QString user, QString password)
{
if (!canceled) {
gpgrt_asprintf(&m_user, "%s", user.toUtf8().constData());
gpgrt_asprintf(&m_passphrase, "%s", password.toUtf8().constData());
}
else
m_canceled = true;
m_loop->quit();
};
public:
UTGitCredProvider():
m_loop(std::unique_ptr<QEventLoop>(new QEventLoop)),
m_sem(std::unique_ptr<QSemaphore>(new QSemaphore(1))),
m_user(nullptr),
m_password(nullptr),
m_canceled(false)
{}
int cred_acquire_cb(git_cred **out,
const char *url,
const char *username_from_url,
unsigned int allowed_types,
void *payload) {
if (!m_sem->tryAcquire(1, 3000))
{
qWarning() << "Cannot acquire UTGitCredProvider semaphore.";
canceled = true;
return nullptr;
}
m_passphrase = nullptr;
m_canceled = false;
qDebug() << "Call the QML Dialog Cred Provider";
QMetaObject::invokeMethod(
Gpg::instance()->getWindow(), "callCredDialog",
Q_ARG(QVariant, username_from_url)
);
qDebug() << "Waiting for response";
QObject::connect(
Gpg::instance()->getWindow(), SIGNAL(responseCredDialog(bool, QString, QString)),
this, SLOT(handleResponse(bool, QString, QString))
);
m_loop->exec();
qDebug() << "Set Cred";
error = git_cred_userpass_plaintext_new(out, username, password);
qDebug() << "Clean";
if (m_passphrase) free(m_passphrase);
if (m_user) free(m_user);
m_canceled = false;
m_sem->release(1);
return ret;
};
};
#endif

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: utpass.qrouland\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-09-21 14:01+0000\n"
"POT-Creation-Date: 2019-09-25 17:36+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -103,63 +103,67 @@ msgid ""
"No password found<br>You can import a password store zip in the settings"
msgstr ""
#: ../qml/pages/settings/ImportKeyFile.qml:17
#: ../qml/pages/settings/gpg/ImportKeyFile.qml:17
msgid "GPG Key Import"
msgstr ""
#: ../qml/pages/settings/ImportKeyFile.qml:69
#: ../qml/pages/settings/gpg/ImportKeyFile.qml:69
msgid "Key import failed !"
msgstr ""
#: ../qml/pages/settings/ImportKeyFile.qml:76
#: ../qml/pages/settings/gpg/ImportKeyFile.qml:76
msgid "Key successfully imported !"
msgstr ""
#: ../qml/pages/settings/ImportZip.qml:17
#: ../qml/pages/settings/gpg/InfoKeys.qml:16
msgid "Info Keys"
msgstr ""
#: ../qml/pages/settings/gpg/InfoKeys.qml:44
msgid "Key id : %1"
msgstr ""
#: ../qml/pages/settings/gpg/InfoKeys.qml:49
msgid "Delete this key"
msgstr ""
#: ../qml/pages/settings/gpg/InfoKeys.qml:68
msgid "You're are about to delete<br>%1<br>Continue ?"
msgstr ""
#: ../qml/pages/settings/gpg/InfoKeys.qml:71
msgid "%1<br>will be definitively removed.<br>Continue ?"
msgstr ""
#: ../qml/pages/settings/gpg/InfoKeys.qml:87
msgid "Key removal failed !"
msgstr ""
#: ../qml/pages/settings/gpg/InfoKeys.qml:94
msgid "Key successfully deleted !"
msgstr ""
#: ../qml/pages/settings/passwordstore/ImportGit.qml:13
msgid "Git clone"
msgstr ""
#: ../qml/pages/settings/passwordstore/ImportZip.qml:17
msgid "Zip Password Store Import"
msgstr ""
#: ../qml/pages/settings/ImportZip.qml:72
#: ../qml/pages/settings/passwordstore/ImportZip.qml:72
msgid ""
"Importing a new zip will delete<br>any existing password store!<br>Continue ?"
msgstr ""
#: ../qml/pages/settings/ImportZip.qml:82
#: ../qml/pages/settings/passwordstore/ImportZip.qml:82
msgid "Password store import failed !"
msgstr ""
#: ../qml/pages/settings/ImportZip.qml:89
#: ../qml/pages/settings/passwordstore/ImportZip.qml:89
msgid "Password store sucessfully imported !"
msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:16
msgid "Info Keys"
msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:44
msgid "Key id : %1"
msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:49
msgid "Delete this key"
msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:68
msgid "You're are about to delete<br>%1<br>Continue ?"
msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:71
msgid "%1<br>will be definitively removed.<br>Continue ?"
msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:87
msgid "Key removal failed !"
msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:94
msgid "Key successfully deleted !"
msgstr ""
#: ../qml/pages/settings/Settings.qml:28
msgid "GPG"
msgstr ""
@ -180,6 +184,14 @@ msgstr ""
msgid "Import a Password Store Zip"
msgstr ""
#: ../qml/pages/settings/Settings.qml:56
#: ../qml/pages/settings/Settings.qml:51
msgid "Import a Password Store Git"
msgstr ""
#: ../qml/pages/settings/Settings.qml:60
msgid "Warning: importing delete any exiting Password Store"
msgstr ""
#: ../qml/pages/settings/Settings.qml:67
msgid "Git"
msgstr ""

View File

@ -38,6 +38,24 @@ MainView {
passphraseDialog.validated.connect(validated)
passphraseDialog.canceled.connect(canceled)
}
function callCredDialog() {
//TODO add parameters to impove passphrase dialog
var credDialog = PopupUtils.open(
Qt.resolvedUrl("dialogs/CredDialog.qml"))
credDialog.activateFocus()
var validated = function (user, password) {
responseCredDialog(false, user, password)
}
var canceled = function () {
responseCredDialog(true, "", "")
}
credDialog.validated.connect(validated)
credDialog.canceled.connect(canceled)
}
PageStack {
id: pageStack

View File

@ -0,0 +1,63 @@
import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Components.Popups 1.3
Dialog {
id: credProvider
title: i18n.tr("Authentication required")
text_user: i18n.tr("Enter user :")
text_password: i18n.tr("Enter password :")
signal validated(string user, string password)
signal canceled
function activateFocus() {
user.forceActiveFocus()
}
TextField {
id: userField
placeholderText: i18n.tr("user")
echoMode: TextInput.Password
onAccepted: passwordField.forceActiveFocus()
}
TextField {
id: passwordField
placeholderText: i18n.tr("password")
echoMode: TextInput.Password
onAccepted: okButton.clicked(text)
}
Button {
id: okButton
text: i18n.tr("Ok")
color: UbuntuColors.green
onClicked: {
validated(userField.text, passwordField.text)
userField.text = ""
passwordField.text = ""
PopupUtils.close(credProvider)
}
}
Button {
id: cancelButton
text: i18n.tr("Cancel")
color: UbuntuColors.red
onClicked: {
userField.text = ""
passwordField.text = ""
canceled()
PopupUtils.close(credProvider)
}
}
}

View File

@ -43,6 +43,7 @@ Dialog {
color: UbuntuColors.red
onClicked: {
passphraseField.text = ""
canceled()
PopupUtils.close(passphraseProvider)
}

View File

@ -28,11 +28,11 @@ Page {
text: i18n.tr('GPG')
}
PageStackLink {
page: Qt.resolvedUrl("ImportKeyFile.qml")
page: Qt.resolvedUrl("gpg/ImportKeyFile.qml")
text: i18n.tr('Import a GPG key file')
}
PageStackLink {
page: Qt.resolvedUrl("InfoKeys.qml")
page: Qt.resolvedUrl("gpg/InfoKeys.qml")
text: i18n.tr('Show GPG keys')
}
Text {
@ -43,9 +43,13 @@ Page {
text: i18n.tr('Password Store')
}
PageStackLink {
page: Qt.resolvedUrl("ImportZip.qml")
page: Qt.resolvedUrl("passwordstore/ImportZip.qml")
text: i18n.tr('Import a Password Store Zip')
}
PageStackLink {
page: Qt.resolvedUrl("passwordstore/ImportGit.qml")
text: i18n.tr('Import a Password Store Git')
}
Text {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
@ -55,5 +59,12 @@ Page {
text: i18n.tr(
'Warning: importing delete any exiting Password Store')
}
Text {
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
width: parent.width
height: units.gu(4)
text: i18n.tr('Git')
}
}
}

View File

@ -4,8 +4,8 @@ import Ubuntu.Content 1.3
import Ubuntu.Components.Popups 1.3
import Pass 1.0
import Utils 1.0
import "../headers"
import "../../dialogs"
import "../../headers"
import "../../../dialogs"
Page {
id: importKeyFilePage

View File

@ -2,9 +2,9 @@ import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Components.Popups 1.3
import Pass 1.0
import "../headers"
import "../../components"
import "../../dialogs"
import "../../headers"
import "../../../components"
import "../../../dialogs"
Page {
id: infoKeysPage

View File

@ -0,0 +1,61 @@
import QtQuick 2.4
import Ubuntu.Components 1.3
import Git 1.0
import Pass 1.0
import "../../headers"
import "../../../styles"
Page {
id: importGit
header: StackHeader {
id: importGitHeader
title: i18n.tr('Git clone')
}
Row {
anchors.top: importGitHeader.bottom
anchors.topMargin: units.gu(1)
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
height: units.gu(4)
Rectangle {
height: units.gu(4)
width: units.gu(2)
}
TextField {
id: gitUrlTextField
placeholderText: "https://..."
height: units.gu(4)
width: parent.width - units.gu(8)
}
Icon {
id: ico
name: "document-save"
color: UbuntuColors.orange
height: units.gu(4)
width: units.gu(4)
MouseArea {
anchors.fill: parent
onPressed: {
parent.color = UbuntuColors.warmGrey
}
onClicked: {
Git.clone(gitUrlTextField.text, Pass.getPasswordStore())
}
onReleased: {
parent.color = theme.palette.normal.background
}
}
}
}
Component.onCompleted : {
gitUrlTextField.forceActiveFocus()
}
}

View File

@ -4,8 +4,8 @@ import Ubuntu.Content 1.3
import Ubuntu.Components.Popups 1.3
import Pass 1.0
import Utils 1.0
import "../headers"
import "../../dialogs"
import "../../headers"
import "../../../dialogs"
Page {
id: importZipPage