20 #include "kprintprocess.h"
21 #include <tdeapplication.h>
22 #include <tdelocale.h>
25 KPrintProcess::KPrintProcess()
29 connect(
this,TQ_SIGNAL(receivedStdout(TDEProcess*,
char*,
int)),TQ_SLOT(slotReceivedStderr(TDEProcess*,
char*,
int)));
30 connect(
this,TQ_SIGNAL(receivedStderr(TDEProcess*,
char*,
int)),TQ_SLOT(slotReceivedStderr(TDEProcess*,
char*,
int)));
31 connect(
this, TQ_SIGNAL( processExited( TDEProcess* ) ), TQ_SLOT( slotExited( TDEProcess* ) ) );
35 KPrintProcess::~KPrintProcess()
37 if ( !m_tempoutput.isEmpty() )
38 TQFile::remove( m_tempoutput );
39 if ( m_tempfiles.size() > 0 )
40 for ( TQStringList::ConstIterator it=m_tempfiles.begin(); it!=m_tempfiles.end(); ++it )
41 TQFile::remove( *it );
44 TQString KPrintProcess::errorMessage()
const
49 bool KPrintProcess::print()
51 m_buffer = TQString();
53 return start(NotifyOnExit,All);
56 void KPrintProcess::slotReceivedStderr(TDEProcess *proc,
char *buf,
int len)
60 TQCString str = TQCString(buf,len).stripWhiteSpace();
61 m_buffer.append(str.append(
"\n"));
65 void KPrintProcess::slotExited( TDEProcess* )
70 if ( !m_output.isEmpty() )
73 *
this <<
"kfmclient" <<
"copy" << m_tempoutput << m_output;
75 m_buffer = i18n(
"File transfer failed." );
76 if ( start( NotifyOnExit ) )
81 emit printError(
this, i18n(
"Abnormal process termination (<b>%1</b>)." ).arg( m_command ) );
82 else if ( exitStatus() != 0 )
83 emit printError(
this, i18n(
"<b>%1</b>: execution failed with message:<p>%2</p>" ).arg( m_command ).arg( m_buffer ) );
85 emit printTerminated(
this );
88 emit printError(
this,
"Internal error, printing terminated in unexpected state. "
89 "Report bug at <a href=\"http://bugs.trinitydesktop.org\">http://bugs.trinitydesktop.org</a>." );
94 #include "kprintprocess.moc"