@@ -8,22 +8,23 @@ ImitatePass::ImitatePass() {}
8
8
* @brief ImitatePass::GitInit git init wrapper
9
9
*/
10
10
void ImitatePass::GitInit () {
11
- executeWrapper (QtPassSettings::getGitExecutable (),
12
- " init \" " + QtPassSettings::getPassStore () + ' "' );
11
+ executeGit (" init \" " + QtPassSettings::getPassStore () + ' "' );
13
12
}
14
13
15
14
/* *
16
15
* @brief ImitatePass::GitPull git init wrapper
17
16
*/
18
17
void ImitatePass::GitPull () {
19
- executeWrapper ( QtPassSettings::getGitExecutable (), " pull" );
18
+ executeGit ( " pull" );
20
19
}
21
20
22
21
/* *
23
22
* @brief ImitatePass::GitPush git init wrapper
24
23
*/
25
24
void ImitatePass::GitPush () {
26
- executeWrapper (QtPassSettings::getGitExecutable (), " push" );
25
+ if (QtPassSettings::isUseGit ()){
26
+ executeGit (" push" );
27
+ }
27
28
}
28
29
29
30
/* *
@@ -32,8 +33,7 @@ void ImitatePass::GitPush() {
32
33
QProcess::ExitStatus ImitatePass::Show (QString file, bool block) {
33
34
// TODO(bezet): apparently not yet needed
34
35
// file += ".gpg";
35
- executeWrapper (QtPassSettings::getGpgExecutable (),
36
- " -d --quiet --yes --no-encrypt-to --batch --use-agent \" " +
36
+ executeGpg (" -d --quiet --yes --no-encrypt-to --batch --use-agent \" " +
37
37
file + ' "' );
38
38
if (block)
39
39
return waitForProcess ();
@@ -59,17 +59,15 @@ void ImitatePass::Insert(QString file, QString newValue, bool overwrite) {
59
59
return ;
60
60
}
61
61
QString force (overwrite ? " --yes " : " " );
62
- executeWrapper (QtPassSettings::getGpgExecutable (),
63
- force + " --batch -eq --output \" " + file + " \" " + recipients +
62
+ executeGpg (force + " --batch -eq --output \" " + file + " \" " + recipients +
64
63
" -" ,
65
64
newValue);
66
65
if (!QtPassSettings::isUseWebDav () && QtPassSettings::isUseGit ()) {
67
66
if (!overwrite)
68
- executeWrapper ( QtPassSettings::getGitExecutable (), " add \" " + file + ' "' );
67
+ executeGit ( " add \" " + file + ' "' );
69
68
QString path = QDir (QtPassSettings::getPassStore ()).relativeFilePath (file);
70
69
path.replace (QRegExp (" \\ .gpg$" ), " " );
71
- executeWrapper (QtPassSettings::getGitExecutable (),
72
- " commit \" " + file + " \" -m \" " +
70
+ executeGit (" commit \" " + file + " \" -m \" " +
73
71
(overwrite ? " Edit" : " Add" ) + " for " + path +
74
72
" using QtPass.\" " );
75
73
}
@@ -80,13 +78,11 @@ void ImitatePass::Insert(QString file, QString newValue, bool overwrite) {
80
78
*/
81
79
void ImitatePass::Remove (QString file, bool isDir) {
82
80
if (QtPassSettings::isUseGit ()) {
83
- executeWrapper (QtPassSettings::getGitExecutable (),
84
- QString (" rm " ) + (isDir ? " -rf " : " -f " ) + ' "' + file +
81
+ executeGit (QString (" rm " ) + (isDir ? " -rf " : " -f " ) + ' "' + file +
85
82
' "' );
86
83
// TODO(bezet): commit message used to have pass-like file name inside(ie.
87
84
// getFile(file, true)
88
- executeWrapper (QtPassSettings::getGitExecutable (),
89
- " commit \" " + file + " \" -m \" Remove for " + file +
85
+ executeGit (" commit \" " + file + " \" -m \" Remove for " + file +
90
86
" using QtPass.\" " );
91
87
} else {
92
88
if (isDir) {
@@ -140,12 +136,10 @@ void ImitatePass::Init(QString path, const QList<UserInfo> &users) {
140
136
if (!QtPassSettings::isUseWebDav () && QtPassSettings::isUseGit () &&
141
137
!QtPassSettings::getGitExecutable ().isEmpty ()) {
142
138
if (addFile)
143
- executeWrapper (QtPassSettings::getGitExecutable (),
144
- " add \" " + gpgIdFile + ' "' );
139
+ executeGit (" add \" " + gpgIdFile + ' "' );
145
140
QString path = gpgIdFile;
146
141
path.replace (QRegExp (" \\ .gpg$" ), " " );
147
- executeWrapper (QtPassSettings::getGitExecutable (),
148
- " commit \" " + gpgIdFile + " \" -m \" Added " + path +
142
+ executeGit (" commit \" " + gpgIdFile + " \" -m \" Added " + path +
149
143
" using QtPass.\" " );
150
144
}
151
145
reencryptPath (path);
@@ -206,8 +200,7 @@ void ImitatePass::reencryptPath(QString dir) {
206
200
gpgId.sort ();
207
201
}
208
202
process.waitForFinished ();
209
- executeWrapper (QtPassSettings::getGpgExecutable (),
210
- " -v --no-secmem-warning "
203
+ executeGpg ( " -v --no-secmem-warning "
211
204
" --no-permission-warning --list-only "
212
205
" --keyid-format long " +
213
206
fileName);
@@ -233,8 +226,7 @@ void ImitatePass::reencryptPath(QString dir) {
233
226
qDebug () << " reencrypt " << fileName << " for " << gpgId;
234
227
QString local_lastDecrypt = " Could not decrypt" ;
235
228
emit lastDecrypt (local_lastDecrypt);
236
- executeWrapper (QtPassSettings::getGpgExecutable (),
237
- " -d --quiet --yes --no-encrypt-to --batch --use-agent \" " +
229
+ executeGpg (" -d --quiet --yes --no-encrypt-to --batch --use-agent \" " +
238
230
fileName + ' "' );
239
231
process.waitForFinished (30000 ); // long wait (passphrase stuff)
240
232
local_lastDecrypt = process.readAllStandardOutput ();
@@ -253,20 +245,18 @@ void ImitatePass::reencryptPath(QString dir) {
253
245
" file missing or invalid." ));
254
246
return ;
255
247
}
256
- executeWrapper ( QtPassSettings::getGpgExecutable (),
248
+ executeGpg (
257
249
" --yes --batch -eq --output \" " + fileName + " \" " +
258
250
recipients + " -" ,
259
251
local_lastDecrypt);
260
252
process.waitForFinished (3000 );
261
253
262
254
if (!QtPassSettings::isUseWebDav () && QtPassSettings::isUseGit ()) {
263
- executeWrapper (QtPassSettings::getGitExecutable (),
264
- " add \" " + fileName + ' "' );
255
+ executeGit (" add \" " + fileName + ' "' );
265
256
QString path =
266
257
QDir (QtPassSettings::getPassStore ()).relativeFilePath (fileName);
267
258
path.replace (QRegExp (" \\ .gpg$" ), " " );
268
- executeWrapper (QtPassSettings::getGitExecutable (),
269
- " commit \" " + fileName + " \" -m \" " + " Edit for " +
259
+ executeGit (" commit \" " + fileName + " \" -m \" " + " Edit for " +
270
260
path + " using QtPass.\" " );
271
261
process.waitForFinished (3000 );
272
262
}
@@ -283,24 +273,22 @@ void ImitatePass::reencryptPath(QString dir) {
283
273
emit endReencryptPath ();
284
274
}
285
275
286
- void ImitatePass::Move (QDir srcDir, QDir destDir, bool force)
276
+ void ImitatePass::Move (const QString src, const QString dest, const bool force)
287
277
{
288
- QString src = srcDir.absolutePath ();
289
- QString dest= destDir.absolutePath ();
290
278
if (QtPassSettings::isUseGit ()) {
291
279
QString args = QString (" mv %1 %2 %3" );
292
- // do we need force mode?
280
+ // force mode?
293
281
if (force){
294
282
args = args.arg (" -f" );
295
283
}else {
296
284
args = args.arg (" " );
297
285
}
298
286
args = args.arg (src).arg (dest);
299
- executeWrapper ( QtPassSettings::getGitExecutable (), args);
287
+ executeGit ( args);
300
288
301
- QString args1=QString (" commit -m \" moved dir from %1 to %2 using QTPass.\" " );
289
+ QString args1=QString (" commit -m \" moved from %1 to %2 using QTPass.\" " );
302
290
args1= args1.arg (src).arg (dest);
303
- executeWrapper ( QtPassSettings::getGitExecutable (), args1);
291
+ executeGit ( args1);
304
292
305
293
if (QtPassSettings::isAutoPush ()){
306
294
GitPush ();
@@ -315,14 +303,33 @@ void ImitatePass::Move(QDir srcDir, QDir destDir, bool force)
315
303
}
316
304
}
317
305
318
- void ImitatePass::Move (QFile srcFile, QFile destFile, bool force)
319
- {
320
- }
321
306
322
- void ImitatePass::Copy (QDir srcDir, QDir destDir, bool force)
307
+ void ImitatePass::Copy (const QString src, const QString dest, const bool force)
323
308
{
324
- }
309
+ if (QtPassSettings::isUseGit ()) {
310
+ QString args = QString (" cp %1 %2 %3" );
311
+ // do we need force mode?
312
+ if (force){
313
+ args = args.arg (" -f" );
314
+ }else {
315
+ args = args.arg (" " );
316
+ }
317
+ args = args.arg (src).arg (dest);
318
+ executeGit (args);
325
319
326
- void ImitatePass::Copy (QFile srcFile, QFile destFile, bool force)
327
- {
320
+ QString args1=QString (" commit -m \" copied from %1 to %2 using QTPass.\" " );
321
+ args1= args1.arg (src).arg (dest);
322
+ executeGit (args1);
323
+
324
+ if (QtPassSettings::isAutoPush ()){
325
+ GitPush ();
326
+ }
327
+
328
+ } else {
329
+ QDir qDir;
330
+ if (force){
331
+ qDir.remove (dest);
332
+ }
333
+ qDir.rename (src, dest);
334
+ }
328
335
}
0 commit comments