helperprocess.cpp

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.cpp
00037 ** \version $Id: helperprocess.cpp 2675 2008-06-06 23:28:53Z edmanm $
00038 ** \brief Invokes a web browser process (originally by Steven. J. Murdoch)
00039 */
00040 
00041 #include <QString>
00042   
00043 #include "helperprocess.h"
00044 
00045 
00046 /** Default constructor */
00047 HelperProcess::HelperProcess(QObject *parent)
00048 : QProcess(parent)
00049 {
00050   // Call error handling routine on errors
00051   QObject::connect(this, SIGNAL(error(QProcess::ProcessError)),
00052                    this, SLOT(onError(QProcess::ProcessError)));
00053 }
00054 
00055 /** Start the specified application. */
00056 void
00057 HelperProcess::start(const QString &app, const QStringList &args) 
00058 {
00059   // Start the specified application
00060   QProcess::start(app, args, QIODevice::ReadOnly | QIODevice::Text);
00061 }
00062 
00063 /** Invoked when underlying QProcess fails. */
00064 void
00065 HelperProcess::onError(QProcess::ProcessError error)
00066 {
00067   // Pass up error messages on startup, but ignore the rest
00068   if (error == QProcess::FailedToStart) {
00069     emit startFailed(errorString());
00070   }
00071 }
00072 
00073 /** Returns true iff process is not running. */
00074 bool
00075 HelperProcess::isDone() const
00076 {
00077   return state() == NotRunning;
00078 }
00079 

Generated on Wed Nov 26 21:04:19 2008 for Vidalia by  doxygen 1.5.7.1