• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
kprintprocess.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License version 2 as published by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  **/
19 
20 #include "kprintprocess.h"
21 #include <tdeapplication.h>
22 #include <tdelocale.h>
23 #include <tqfile.h>
24 
25 KPrintProcess::KPrintProcess()
26 : KShellProcess()
27 {
28  // redirect everything to a single buffer
29  connect(this,TQT_SIGNAL(receivedStdout(TDEProcess*,char*,int)),TQT_SLOT(slotReceivedStderr(TDEProcess*,char*,int)));
30  connect(this,TQT_SIGNAL(receivedStderr(TDEProcess*,char*,int)),TQT_SLOT(slotReceivedStderr(TDEProcess*,char*,int)));
31  connect( this, TQT_SIGNAL( processExited( TDEProcess* ) ), TQT_SLOT( slotExited( TDEProcess* ) ) );
32  m_state = None;
33 }
34 
35 KPrintProcess::~KPrintProcess()
36 {
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 );
42 }
43 
44 TQString KPrintProcess::errorMessage() const
45 {
46  return m_buffer;
47 }
48 
49 bool KPrintProcess::print()
50 {
51  m_buffer = TQString();
52  m_state = Printing;
53  return start(NotifyOnExit,All);
54 }
55 
56 void KPrintProcess::slotReceivedStderr(TDEProcess *proc, char *buf, int len)
57 {
58  if (proc == this)
59  {
60  TQCString str = TQCString(buf,len).stripWhiteSpace();
61  m_buffer.append(str.append("\n"));
62  }
63 }
64 
65 void KPrintProcess::slotExited( TDEProcess* )
66 {
67  switch ( m_state )
68  {
69  case Printing:
70  if ( !m_output.isEmpty() )
71  {
72  clearArguments();
73  *this << "kfmclient" << "copy" << m_tempoutput << m_output;
74  m_state = Finishing;
75  m_buffer = i18n( "File transfer failed." );
76  if ( start( NotifyOnExit ) )
77  return;
78  }
79  case Finishing:
80  if ( !normalExit() )
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 ) );
84  else
85  emit printTerminated( this );
86  break;
87  default:
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>." );
90  break;
91  }
92 }
93 
94 #include "kprintprocess.moc"

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.8.8
This website is maintained by Timothy Pearson.