• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

ark

  • sources
  • kde-4.14
  • kdeutils
  • ark
  • kerfuffle
cliinterface.h
Go to the documentation of this file.
1 /*
2  * ark -- archiver for the KDE project
3  *
4  * Copyright (C) 2009 Harald Hvaal <haraldhv@stud.ntnu.no>
5  * Copyright (C) 2009-2011 Raphael Kubo da Costa <rakuco@FreeBSD.org>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 #ifndef CLIINTERFACE_H
29 #define CLIINTERFACE_H
30 
31 #include "archiveinterface.h"
32 #include "kerfuffle_export.h"
33 #include <QtCore/QProcess>
34 #include <QtCore/QRegExp>
35 
36 class KProcess;
37 class KPtyProcess;
38 
39 namespace Kerfuffle
40 {
41 
42 enum CliInterfaceParameters {
43 
45 
51  CaptureProgress = 0,
52 
58  PasswordPromptPattern,
59 
61 
67  ListProgram,
75  ListArgs,
76 
78 
84  ExtractProgram,
100  ExtractArgs,
108  NoTrailingSlashes,
122  PreservePathSwitch,
130  RootNodeSwitch,
141  PasswordSwitch,
148  FileExistsExpression,
157  FileExistsMode,
169  FileExistsInput,
170 
172 
178  DeleteProgram,
187  DeleteArgs,
194  ExtractionFailedPatterns,
201  WrongPasswordPatterns,
202 
204 
210  AddProgram,
219  AddArgs
220 };
221 
222 typedef QHash<int, QVariant> ParameterList;
223 
224 class KERFUFFLE_EXPORT CliInterface : public ReadWriteArchiveInterface
225 {
226  Q_OBJECT
227 
228 public:
229  enum OperationMode {
230  List, Copy, Add, Delete
231  };
232  OperationMode m_operationMode;
233 
234  explicit CliInterface(QObject *parent, const QVariantList & args);
235  virtual ~CliInterface();
236 
237  virtual bool list();
238  virtual bool copyFiles(const QList<QVariant> & files, const QString & destinationDirectory, ExtractionOptions options);
239  virtual bool addFiles(const QStringList & files, const CompressionOptions& options);
240  virtual bool deleteFiles(const QList<QVariant> & files);
241 
242  virtual ParameterList parameterList() const = 0;
243  virtual bool readListLine(const QString &line) = 0;
244 
245  bool doKill();
246  bool doSuspend();
247  bool doResume();
248 
256  QString escapedCharacters();
257 
264  void setEscapedCharacters(const QString& characters);
265 
271  void setListEmptyLines(bool emptyLines);
272 
273 private:
274  void substituteListVariables(QStringList& params);
275 
276  void cacheParameterList();
277 
290  bool checkForPasswordPromptMessage(const QString& line);
291 
292  bool checkForFileExistsMessage(const QString& line);
293  bool handleFileExistsMessage(const QString& filename);
294  bool checkForErrorMessage(const QString& line, int parameterIndex);
295  void handleLine(const QString& line);
296 
297  void failOperation();
298 
309  bool runProcess(const QStringList& programNames, const QStringList& arguments);
310 
319  virtual QString escapeFileName(const QString &fileName) const;
320 
325  void writeToProcess(const QByteArray& data);
326 
327  QByteArray m_stdOutData;
328  QRegExp m_existsPattern;
329  QRegExp m_passwordPromptPattern;
330  QHash<int, QList<QRegExp> > m_patternCache;
331 
332 #ifdef Q_OS_WIN
333  KProcess *m_process;
334 #else
335  KPtyProcess *m_process;
336 #endif
337 
338  ParameterList m_param;
339  QVariantList m_removedFiles;
340  bool m_listEmptyLines;
341  bool m_abortingOperation;
342 
343 private slots:
344  void readStdout(bool handleAll = false);
345  void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
346 };
347 }
348 
349 #endif /* CLIINTERFACE_H */
Kerfuffle::ExtractionFailedPatterns
QStringList Default: empty A list of regexp patterns that will cause the extraction to exit with a ge...
Definition: cliinterface.h:194
Kerfuffle::NoTrailingSlashes
Bool (default false) When passing directories to the extract program, do not include trailing slashes...
Definition: cliinterface.h:108
Kerfuffle::ExtractProgram
QStringList The names to the program that will handle extracting of this archive (eg "rar")...
Definition: cliinterface.h:84
Kerfuffle::FileExistsMode
int This sets on what output channel the FileExistsExpression regex should be applied on...
Definition: cliinterface.h:157
QByteArray
Kerfuffle::AddProgram
QStringList The names to the program that will handle adding in this archive format (eg "rar")...
Definition: cliinterface.h:210
kerfuffle_export.h
Kerfuffle::CliInterface
Definition: cliinterface.h:224
Kerfuffle::ListArgs
QStringList The arguments that are passed to the program above for listing the archive.
Definition: cliinterface.h:75
Kerfuffle::PasswordPromptPattern
QString Default: empty A regexp pattern that matches the program's password prompt.
Definition: cliinterface.h:58
Kerfuffle::CliInterface::OperationMode
OperationMode
Definition: cliinterface.h:229
Kerfuffle::ParameterList
QHash< int, QVariant > ParameterList
Definition: cliinterface.h:222
QRegExp
Kerfuffle::ReadWriteArchiveInterface
Definition: archiveinterface.h:121
archiveinterface.h
Kerfuffle::PreservePathSwitch
QStringList This should be a qstringlist with either two elements.
Definition: cliinterface.h:122
QHash< int, QVariant >
QObject
Kerfuffle::WrongPasswordPatterns
QStringList Default: empty A list of regexp patterns that will alert the user that the password was w...
Definition: cliinterface.h:201
Kerfuffle::ExtractArgs
QStringList The arguments that are passed to the program above for extracting the archive...
Definition: cliinterface.h:100
Kerfuffle::FileExistsExpression
QString This is a regexp, defining how to recognize a "File already exists" prompt when extracting...
Definition: cliinterface.h:148
QString
QList
KERFUFFLE_EXPORT
#define KERFUFFLE_EXPORT
Definition: kerfuffle_export.h:41
QStringList
Kerfuffle::CaptureProgress
Bool (default false) Will look for the %-sign in the stdout while working, in the form of (2%...
Definition: cliinterface.h:51
Kerfuffle::CliInterface::List
Definition: cliinterface.h:230
Kerfuffle::DeleteArgs
QStringList The arguments that are passed to the program above for deleting from the archive...
Definition: cliinterface.h:187
Kerfuffle::PasswordSwitch
QStringList (default empty) The format of the root node switch.
Definition: cliinterface.h:141
Kerfuffle::DeleteProgram
QStringList The names to the program that will handle deleting of elements in this archive format (eg...
Definition: cliinterface.h:178
Kerfuffle::FileExistsInput
QStringList The various responses that can be supplied as a response to the "file exists" prompt...
Definition: cliinterface.h:169
Kerfuffle::CliInterface::m_operationMode
OperationMode m_operationMode
Definition: cliinterface.h:232
Kerfuffle::AddArgs
QStringList The arguments that are passed to the program above for adding to the archive.
Definition: cliinterface.h:219
Kerfuffle::RootNodeSwitch
QStringList (default empty) The format of the root node switch.
Definition: cliinterface.h:130
Kerfuffle::ListProgram
QStringList The names to the program that will handle listing of this archive (eg "rar")...
Definition: cliinterface.h:67
Kerfuffle::CliInterfaceParameters
CliInterfaceParameters
Definition: cliinterface.h:42
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:42:37 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

ark

Skip menu "ark"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • ktimer
  • kwallet
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal