Vidalia 0.2.12

HelperProcess.h

Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 /*
00011 **  This file was originally written by Steven J. Murdoch, and 
00012 **  modified by Matt Edman. It is distributed under the following
00013 **  license:
00014 **
00015 **  Copyright (C) 2007, Matt Edman
00016 **  Copyright (C) 2007, Steven J. Murdoch 
00017 **                      <http://www.cl.cam.ac.uk/users/sjm217/>
00018 **
00019 **  This program is free software; you can redistribute it and/or
00020 **  modify it under the terms of the GNU General Public License
00021 **  as published by the Free Software Foundation; either version 2
00022 **  of the License, or (at your option) any later version.
00023 **
00024 **  This program is distributed in the hope that it will be useful,
00025 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
00026 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00027 **  GNU General Public License for more details.
00028 **
00029 **  You should have received a copy of the GNU General Public License
00030 **  along with this program; if not, write to the Free Software
00031 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
00032 **  Boston, MA  02110-1301, USA.
00033 */
00034 
00035 /*
00036 ** \file HelperProcess.h
00037 ** \brief Invokes a web browser process (originally by Steven. J. Murdoch)
00038 */
00039 
00040 #ifndef _HELPERPROCESS_H
00041 #define _HELPERPROCESS_H
00042 
00043 #include <QProcess>
00044 
00045 
00046 class HelperProcess : public QProcess
00047 {
00048   Q_OBJECT
00049 
00050 public:
00051   /** Default constructor */
00052   HelperProcess(QObject *parent = 0);
00053   /** Start <b>app</b> with <b>args</b> appended to the end of the command
00054    * line. <b>app</b> will be quoted, so an executable name with spaces is
00055    * acceptable. */
00056   void start(const QString &app, const QString &args);
00057   /** Start the specified application. */
00058   void start(const QString &app, const QStringList &args);
00059   /** Returns true iff process is not running. */
00060   bool isDone() const;
00061 
00062 signals:
00063   /** Invoked when start() fails. */
00064   void startFailed(const QString &errorMessage);
00065     
00066 private slots:
00067   /** Invoked when underlying QProcess fails. */
00068   void onError(QProcess::ProcessError error);
00069   /** Invoked when output is written to the process's stderr. */
00070   void onReadyReadStandardError();
00071   /** Invoked when output is written to the process's stdout. */
00072   void onReadyReadStandardOutput();
00073 
00074 private:
00075   QString _processName;
00076 };
00077 
00078 #endif
00079