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

kdeprint

  • kdeprint
kprintprocess.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001 Michael Goffioul <kdeprint@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 <kapplication.h>
22 #include <klocale.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(KProcess*,char*,int)),TQT_SLOT(slotReceivedStderr(KProcess*,char*,int)));
30  connect(this,TQT_SIGNAL(receivedStderr(KProcess*,char*,int)),TQT_SLOT(slotReceivedStderr(KProcess*,char*,int)));
31  connect( this, TQT_SIGNAL( processExited( KProcess* ) ), TQT_SLOT( slotExited( KProcess* ) ) );
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(KProcess *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( KProcess* )
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.kde.org\">http://bugs.kde.org</a>." );
90  break;
91  }
92 }
93 
94 #include "kprintprocess.moc"

kdeprint

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

kdeprint

Skip menu "kdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdeprint by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |