33 #include "symcryptrunprocessbase.h"
35 #include <tdetempfile.h>
44 Kleo::SymCryptRunProcessBase::SymCryptRunProcessBase(
const TQString & class_,
const TQString & program,
45 const TQString & keyFile,
const TQString & options,
47 TQObject * parent,
const char * name )
48 : TDEProcess( parent, name ),
49 mOperation( mode ), mOptions( options )
51 *
this <<
"symcryptrun"
52 <<
"--class" << class_
53 <<
"--program" << program
54 <<
"--keyfile" << keyFile
55 << ( mode == Encrypt ?
"--encrypt" :
"--decrypt" );
58 Kleo::SymCryptRunProcessBase::~SymCryptRunProcessBase() {}
60 bool Kleo::SymCryptRunProcessBase::launch(
const TQByteArray & input, RunMode rm ) {
61 connect(
this, TQ_SIGNAL(receivedStdout(TDEProcess*,
char*,
int)),
62 this, TQ_SLOT(slotReceivedStdout(TDEProcess*,
char*,
int)) );
63 connect(
this, TQ_SIGNAL(receivedStderr(TDEProcess*,
char*,
int)),
64 this, TQ_SLOT(slotReceivedStderr(TDEProcess*,
char*,
int)) );
67 tempfile.setAutoDelete(
true );
68 if ( TQFile * file = tempfile.file() )
69 file->writeBlock( input );
73 *
this <<
"--input" << tempfile.name();
75 return TDEProcess::start( Block, All );
78 const bool ok = TDEProcess::start( rm, All );
81 mInput = input.copy();
82 writeStdin( mInput.begin(), mInput.size() );
83 connect(
this, TQ_SIGNAL(wroteStdin(TDEProcess*)),
this, TQ_SLOT(closeStdin()) );
88 void Kleo::SymCryptRunProcessBase::addOptions() {
89 if ( !mOptions.isEmpty() )
91 const TQStringList args = KShell::splitArgs( mOptions );
92 *
this <<
"--" << args;
96 void Kleo::SymCryptRunProcessBase::slotReceivedStdout( TDEProcess * proc,
char * buf,
int len ) {
97 Q_ASSERT( proc ==
this );
98 const int oldsize = mOutput.size();
99 mOutput.resize( oldsize + len );
100 memcpy( mOutput.data() + oldsize, buf, len );
103 void Kleo::SymCryptRunProcessBase::slotReceivedStderr( TDEProcess * proc,
char * buf,
int len ) {
104 Q_ASSERT( proc ==
this );
106 mStderr += TQString::fromLocal8Bit( buf, len );
109 #include "symcryptrunprocessbase.moc"