aboutsummaryrefslogtreecommitdiff
path: root/src-qt5/desktop-utils/lumina-fm-dev/gitCompat.cpp
diff options
context:
space:
mode:
authorWeblate <noreply@weblate.org>2017-09-20 13:42:32 +0000
committerWeblate <noreply@weblate.org>2017-09-20 13:42:32 +0000
commita4fd58c9aae62207b131a13cc13187970495bdb5 (patch)
treecdabc3a0816c41f6f2a6f5191f3e38f698595c13 /src-qt5/desktop-utils/lumina-fm-dev/gitCompat.cpp
parentTranslated using Weblate (Lithuanian) (diff)
parentStreamline a bit more of the new Lumina2 window embed functionality. (diff)
downloadlumina-a4fd58c9aae62207b131a13cc13187970495bdb5.tar.gz
lumina-a4fd58c9aae62207b131a13cc13187970495bdb5.tar.bz2
lumina-a4fd58c9aae62207b131a13cc13187970495bdb5.zip
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src-qt5/desktop-utils/lumina-fm-dev/gitCompat.cpp')
-rw-r--r--src-qt5/desktop-utils/lumina-fm-dev/gitCompat.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src-qt5/desktop-utils/lumina-fm-dev/gitCompat.cpp b/src-qt5/desktop-utils/lumina-fm-dev/gitCompat.cpp
new file mode 100644
index 00000000..18e83e6a
--- /dev/null
+++ b/src-qt5/desktop-utils/lumina-fm-dev/gitCompat.cpp
@@ -0,0 +1,45 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2016, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+// This is the backend classe for interacting with the "git" utility
+//===========================================
+#include "gitCompat.h"
+#include <QApplication>
+
+#define TMPFILE QString("/tmp/.")
+GitProcess::GitProcess() : QProcess(){
+ this->setProcessChannelMode(QProcess::MergedChannels);
+ tmpfile.setFileName(TMPFILE +QString::number( (rand()%8999) + 1000 ));
+ //qDebug() << "Temporary File Name:" << tmpfile.fileName();
+ tmpfile.setParent(this);
+ connect(this, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(cleanup()) );
+ connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(printoutput()) );
+}
+
+GitProcess::~GitProcess(){
+ if(tmpfile.exists()){ tmpfile.remove(); } //ensure that password file never gets left behind
+}
+
+void GitProcess::setSSHPassword(QString pass){
+ //Save the password into the temporary file
+ if( tmpfile.open(QIODevice::WriteOnly) ){
+ QTextStream in(&tmpfile);
+ in << "#!/bin/sh"<<"\n";
+ in << "echo \""+pass+"\"" << "\n";
+ in << "rm "+tmpfile.fileName()+"\n"; //have the script clean itself up after running once
+ tmpfile.close();
+ }
+ tmpfile.setPermissions( QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner );
+ QApplication::processEvents();
+ QProcessEnvironment env = this->processEnvironment();
+ env.insert("SSH_ASKPASS", tmpfile.fileName());
+ env.insert("DISPLAY",":0"); //will not actually be used - the tmp file sends the password back instantly
+ this->setProcessEnvironment(env);
+}
+
+void GitProcess::cleanup(){
+ if(tmpfile.exists()){ tmpfile.remove(); } //ensure that password file never gets left behind
+}
bgstack15