Commit f002756b authored by Christian Loose's avatar Christian Loose
Browse files

* make CVS_SERVER configurable

* use KProcess::operator<<  to build command line

svn path=/trunk/kdesdk/cervisia/; revision=198600
parent 22441e45
......@@ -21,30 +21,31 @@
#include "cvsjob.h"
#include <qstring.h>
#include <qtextstream.h>
#include <kprocess.h>
struct CvsJob::Private
{
KProcess* childproc;
QString cvsCommand;
QString server;
QString rsh;
QString directory;
bool isRunning;
};
CvsJob::CvsJob(unsigned jobId, const QString& cvsCommand, const QString& rsh,
CvsJob::CvsJob(unsigned jobId, const QString& rsh, const QString& server,
const QString& directory)
: QObject()
, DCOPObject()
, d(new Private)
{
// initialize private data
d->cvsCommand = cvsCommand;
d->rsh = rsh;
d->directory = directory;
d->isRunning = false;
d->server = server;
d->rsh = rsh;
d->directory = directory;
d->isRunning = false;
QString objId("CvsJob" + QString::number(jobId));
setObjId(objId.local8Bit());
......@@ -61,9 +62,9 @@ CvsJob::~CvsJob()
}
void CvsJob::setCvsCommand(const QString& cvsCommand)
void CvsJob::clearCvsCommand()
{
d->cvsCommand = cvsCommand;
d->childproc->clearArguments();
}
......@@ -73,6 +74,12 @@ void CvsJob::setRSH(const QString& rsh)
}
void CvsJob::setServer(const QString& server)
{
d->server = server;
}
void CvsJob::setDirectory(const QString& directory)
{
d->directory = directory;
......@@ -85,9 +92,44 @@ bool CvsJob::isRunning() const
}
CvsJob& CvsJob::operator<<(const QString& arg)
{
*d->childproc << arg;
return *this;
}
CvsJob& CvsJob::operator<<(const char* arg)
{
*d->childproc << arg;
return *this;
}
CvsJob& CvsJob::operator<<(const QCString& arg)
{
*d->childproc << arg;
return *this;
}
CvsJob& CvsJob::operator<<(const QStringList& args)
{
*d->childproc << args;
return *this;
}
QString CvsJob::cvsCommand() const
{
return d->cvsCommand;
QString command;
QTextOStream stream(&command);
QValueList<QCString> args = d->childproc->args();
qCopy(args.begin(), args.end(),
QTextOStreamIterator<QCString>(stream, " "));
return command;
}
......@@ -95,12 +137,13 @@ bool CvsJob::execute()
{
if( !d->rsh.isEmpty() )
d->childproc->setEnvironment("CVS_RSH", d->rsh);
if( !d->server.isEmpty() )
d->childproc->setEnvironment("CVS_SERVER", d->server);
if( !d->directory.isEmpty() )
d->childproc->setWorkingDirectory(d->directory);
*d->childproc << d->cvsCommand;
connect(d->childproc, SIGNAL(processExited(KProcess*)),
SLOT(slotProcessExited()));
connect(d->childproc, SIGNAL(receivedStdout(KProcess*, char*, int)),
......
......@@ -34,13 +34,20 @@ class CvsJob : public QObject, public DCOPObject
K_DCOP
public:
CvsJob(unsigned jobId, const QString& cvsCommand, const QString& rsh = QString::null,
CvsJob(unsigned jobId, const QString& rsh = QString::null,
const QString& server = QString::null,
const QString& directory = QString::null);
~CvsJob();
void setCvsCommand(const QString& cvsCommand);
void clearCvsCommand();
void setRSH(const QString& rsh);
void setServer(const QString& server);
void setDirectory(const QString& directory);
CvsJob& operator<<(const QString& arg);
CvsJob& operator<<(const char* arg);
CvsJob& operator<<(const QCString& arg);
CvsJob& operator<<(const QStringList& args);
k_dcop:
bool execute();
......@@ -72,4 +79,3 @@ private:
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment