summaryrefslogtreecommitdiffstats
path: root/tdeprint/kprinter
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-06 15:56:34 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2011-11-06 15:56:34 -0600
commitb529f046c9a64ac5fcfa60747af940cf972b3ebc (patch)
tree83c28cf7fa8fed1960ebd3924b579e7ed8c95cc6 /tdeprint/kprinter
parent6508fe4c40c60fd7a43bd3d9e19b762e10ea3f53 (diff)
downloadtdebase-b529f046c9a64ac5fcfa60747af940cf972b3ebc.tar.gz
tdebase-b529f046c9a64ac5fcfa60747af940cf972b3ebc.zip
Actually move the kde files that were renamed in the last commit
Diffstat (limited to 'tdeprint/kprinter')
-rw-r--r--tdeprint/kprinter/CMakeLists.txt34
-rw-r--r--tdeprint/kprinter/Makefile.am18
-rw-r--r--tdeprint/kprinter/configure.in.in1
-rw-r--r--tdeprint/kprinter/kprinter.desktop107
-rw-r--r--tdeprint/kprinter/main.cpp58
-rw-r--r--tdeprint/kprinter/printwrapper.cpp403
-rw-r--r--tdeprint/kprinter/printwrapper.h49
7 files changed, 670 insertions, 0 deletions
diff --git a/tdeprint/kprinter/CMakeLists.txt b/tdeprint/kprinter/CMakeLists.txt
new file mode 100644
index 000000000..0849ebe12
--- /dev/null
+++ b/tdeprint/kprinter/CMakeLists.txt
@@ -0,0 +1,34 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include( CheckFunctionExists )
+check_function_exists( sigset HAVE_SIGACTION )
+check_function_exists( sigaction HAVE_SIGSET )
+
+add_definitions( -D_KDEPRINT_COMPILE )
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### kprinter (tdeinit) ########################
+
+tde_add_tdeinit_executable( kprinter AUTOMOC
+ SOURCES main.cpp printwrapper.cpp
+ LINK tdeprint-shared
+)
diff --git a/tdeprint/kprinter/Makefile.am b/tdeprint/kprinter/Makefile.am
new file mode 100644
index 000000000..4cab98880
--- /dev/null
+++ b/tdeprint/kprinter/Makefile.am
@@ -0,0 +1,18 @@
+AM_CPPFLAGS = -D_KDEPRINT_COMPILE
+
+INCLUDES = $(all_includes)
+
+bin_PROGRAMS =
+lib_LTLIBRARIES =
+tdeinit_LTLIBRARIES = kprinter.la
+
+kprinter_la_SOURCES = main.cpp printwrapper.cpp
+kprinter_la_LIBADD = -ltdeprint
+kprinter_la_LDFLAGS = -module -avoid-version $(all_libraries) $(KDE_RPATH)
+kprinter_la_METASOURCES = AUTO
+
+noinst_HEADERS = printwrapper.h
+
+messages:
+ $(XGETTEXT) *.cpp -o $(podir)/kprinter.pot
+
diff --git a/tdeprint/kprinter/configure.in.in b/tdeprint/kprinter/configure.in.in
new file mode 100644
index 000000000..dd0767216
--- /dev/null
+++ b/tdeprint/kprinter/configure.in.in
@@ -0,0 +1 @@
+AC_CHECK_FUNCS(sigset sigaction)
diff --git a/tdeprint/kprinter/kprinter.desktop b/tdeprint/kprinter/kprinter.desktop
new file mode 100644
index 000000000..bb2de4735
--- /dev/null
+++ b/tdeprint/kprinter/kprinter.desktop
@@ -0,0 +1,107 @@
+[Desktop Entry]
+Exec=kprinter
+Icon=kjobviewer
+Terminal=false
+Type=Application
+DocPath=tdeprint/index.html
+X-KDE-StartupNotify=true
+Name=KPrinter
+Name[af]=KDrukker
+Name[cy]=KArgraffydd
+Name[eo]=KPrintilo
+Name[fy]=Kprinter
+Name[hi]=केप्रिंटर
+Name[ka]=პრინტერი
+Name[lo]=ເຄື່ອງພິມ - K
+Name[ne]=K मुद्रक
+Name[nl]=Kprinter
+Name[nso]=KSegatisi
+Name[pa]=ਕੇ-ਪਰਿੰਟਰ
+Name[ru]=Принтер
+Name[rw]=K-Mucapyi
+Name[sv]=Kskrivare
+Name[ta]=Kஅச்சியந்திரம்
+Name[te]=కెప్రింటర్
+Name[tg]=KЧопгар
+Name[th]=เครื่องพิมพ์ K
+Name[tr]=KYazıcı
+Name[ven]=Phirinthara ya K
+Name[vi]=In ấn KDE
+Name[wa]=KScrirece (KPrinter)
+GenericName=Printing Tool
+GenericName[af]=Drukker Program
+GenericName[ar]=أداة الطباعة
+GenericName[be]=Інструмент друку
+GenericName[bg]=Инструмент за печат
+GenericName[bn]=মুদ্রণ টুল
+GenericName[br]=Ostilh moulañ
+GenericName[bs]=Alat za štampu
+GenericName[ca]=Eina per a imprimir
+GenericName[cs]=Tiskový nástroj
+GenericName[csb]=Nôrzãdze do sprôwianiô wëdrëkama
+GenericName[cy]=Erfyn Argraffu
+GenericName[da]=Udskriftsværktøj
+GenericName[de]=Druckprogramm
+GenericName[el]=Εργαλείο εκτύπωσης
+GenericName[eo]=Ilo por printado
+GenericName[es]=Herramienta de impresión
+GenericName[et]=Trükkimise rakendus
+GenericName[eu]=Imprimatzeko tresna
+GenericName[fa]=ابزار چاپ
+GenericName[fi]=Tulostustyökalu
+GenericName[fr]=Outil d'impression
+GenericName[fy]=printprogramma
+GenericName[ga]=Uirlis Priontála
+GenericName[gl]=Ferramenta de Impresión
+GenericName[he]=כלי הדפסה
+GenericName[hi]=प्रिंटर औज़ार
+GenericName[hr]=Alata za ispisivanje
+GenericName[hu]=Nyomtatáskezelő
+GenericName[is]=Prentunartól
+GenericName[it]=Strumento di stampa
+GenericName[ja]=印刷ツール
+GenericName[ka]=საბეჭდი უტილიტა
+GenericName[kk]=Басып шығару құралы
+GenericName[km]=ឧបករណ៍​បោះពុម្ព
+GenericName[lo]=ເຄື່ອງມືລະບົບການພິມ์
+GenericName[lt]=Spausdinimo priemonė
+GenericName[lv]=Drukāšanas Rīks
+GenericName[mk]=Печатарска алатка
+GenericName[mn]=Хэвлэх програм
+GenericName[ms]=Alat Pencetakan
+GenericName[mt]=Għodda tal-ipprintjar
+GenericName[nb]=Verktøy for skriverbehandling
+GenericName[nds]=Druckwarktüüch
+GenericName[ne]=मुद्रण उपकरण
+GenericName[nl]=Afdrukprogramma
+GenericName[nn]=Utskriftsverktøy
+GenericName[nso]=Sebereka sa Kgatiso
+GenericName[pa]=ਛਪਾਈ (ਪਰਿੰਟਿੰਗ) ਸੰਦ
+GenericName[pl]=Narzędzie do zarządzania wydrukiem
+GenericName[pt]=Ferramenta de Impressão
+GenericName[pt_BR]=Ferramenta de Impressão
+GenericName[ro]=Utilitar de tipărire
+GenericName[ru]=Утилита печати
+GenericName[rw]=Igikoresho cyo Gucapa
+GenericName[se]=Čálihanreaidu
+GenericName[sk]=Tlačový nástroj
+GenericName[sl]=Orodje za tiskanje
+GenericName[sr]=Алат за штампу
+GenericName[sr@Latn]=Alat za štampu
+GenericName[sv]=Skrivarverktyg
+GenericName[ta]=அச்சசியந்திர கருவி
+GenericName[tg]=Обзори Чоп
+GenericName[th]=เครื่องมือระบบการพิมพ์
+GenericName[tr]=Yazdırma Aracı
+GenericName[tt]=Bastıru Qoralı
+GenericName[uk]=Засіб друку
+GenericName[uz]=Bosib chiqarish vositasi
+GenericName[uz@cyrillic]=Босиб чиқариш воситаси
+GenericName[ven]=Tshishumiswa tshau phirintha
+GenericName[vi]=Công cụ In ấn
+GenericName[wa]=Usteye d' imprimaedje
+GenericName[xh]=Isixhobo Sokushicilela
+GenericName[zh_CN]=打印工具
+GenericName[zh_TW]=列印工具
+GenericName[zu]=Ithuluzi Lokushicelela
+
diff --git a/tdeprint/kprinter/main.cpp b/tdeprint/kprinter/main.cpp
new file mode 100644
index 000000000..5d1667cee
--- /dev/null
+++ b/tdeprint/kprinter/main.cpp
@@ -0,0 +1,58 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ **/
+
+#include "printwrapper.h"
+
+#include <tqtimer.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+
+static KCmdLineOptions options[] =
+{
+ { "c", I18N_NOOP("Make an internal copy of the files to print"), 0},
+ { "P", 0, 0 },
+ { "d <printer>", I18N_NOOP("Printer/destination to print on"), 0},
+ { "J", 0, 0 },
+ { "t <title>", I18N_NOOP("Title/Name for the print job" ), 0},
+ { "#", 0, 0 },
+ { "n <number>", I18N_NOOP("Number of copies"), 0 },
+ { "o <option=value>", I18N_NOOP("Printer option" ), 0},
+ { "j <mode>", I18N_NOOP("Job output mode (gui, console, none)" ), "gui"},
+ { "system <printsys>",I18N_NOOP("Print system to use (lpd, cups)" ), 0},
+ { "stdin", I18N_NOOP("Allow printing from STDIN" ), 0},
+ { "nodialog", I18N_NOOP("Do not show the print dialog (print directly)"), 0},
+ { "+file(s)", I18N_NOOP("Files to load" ), 0},
+ KCmdLineLastOption
+};
+
+extern "C" int KDE_EXPORT kdemain(int argc, char *argv[])
+{
+ KCmdLineArgs::init(argc,argv,"kprinter",I18N_NOOP("KPrinter"),I18N_NOOP("A printer tool for KDE" ),"0.0.1");
+ KCmdLineArgs::addCmdLineOptions(options);
+ KApplication app;
+ PrintWrapper *wrap = new PrintWrapper;
+ app.setMainWidget(wrap);
+ TQTimer::singleShot(10,wrap,TQT_SLOT(slotPrint()));
+
+ int result = app.exec();
+ delete wrap;
+
+ return result;
+}
diff --git a/tdeprint/kprinter/printwrapper.cpp b/tdeprint/kprinter/printwrapper.cpp
new file mode 100644
index 000000000..effa3dea3
--- /dev/null
+++ b/tdeprint/kprinter/printwrapper.cpp
@@ -0,0 +1,403 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ **/
+
+#include "printwrapper.h"
+
+#include <unistd.h>
+#include <signal.h>
+#include <sys/time.h>
+
+#include <tqstring.h>
+#include <tqstringlist.h>
+#include <stdlib.h>
+#include <kmessagebox.h>
+#include <tqfile.h>
+#include <tqtimer.h>
+#include <tqregexp.h>
+#include <tqsocketnotifier.h>
+
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kio/netaccess.h>
+#include <kurl.h>
+#include <kdebug.h>
+#include <ktempfile.h>
+
+#include <kprinter.h>
+#include <tdeprint/kmmanager.h>
+#include <tdeprint/kmprinter.h>
+#include <tdeprint/kprintdialog.h>
+
+void signal_handler(int);
+TQString tempFile;
+bool fromStdin = false;
+char job_output = 0; // 0: dialog, 1: console, 2: none
+char readchar = '\0';
+bool dataread = false;
+bool docopy = false;
+
+void showmsgdialog(const TQString& msg, int type = 0)
+{
+ switch (type)
+ {
+ case 0: KMessageBox::information(NULL,msg,i18n("Print Information")); break;
+ case 1: KMessageBox::sorry(NULL,msg,i18n("Print Warning")); break;
+ case 2: KMessageBox::error(NULL,msg,i18n("Print Error")); break;
+ }
+}
+
+void showmsgconsole(const TQString& msg, int type = 0)
+{
+ TQString errmsg = TQString::tqfromLatin1("%1 : ").arg((type == 0 ? i18n("Print info") : (type == 1 ? i18n("Print warning") : i18n("Print error"))));
+ kdDebug() << errmsg << msg << endl;
+}
+
+void showmsg(const TQString& msg, int type = 0)
+{
+ switch (job_output) {
+ case 0: showmsgdialog(msg,type); break;
+ case 1: showmsgconsole(msg,type); break;
+ default: break;
+ }
+}
+
+void errormsg(const TQString& msg)
+{
+ showmsg(msg,2);
+ exit(1);
+}
+
+void signal_handler(int s)
+{
+ TQFile::remove(tempFile);
+ exit(s);
+}
+
+TQString copyfile( const TQString& filename )
+{
+ kdDebug( 500 ) << "Copying file " << filename << endl;
+ TQString result;
+ TQFile f( filename );
+ if ( f.open( IO_ReadOnly ) )
+ {
+ KTempFile temp;
+ temp.setAutoDelete( false );
+ TQFile *tf = temp.file();
+ if ( tf )
+ {
+ char buffer[ 0xFFFF ];
+ int b = 0;
+ while ( ( b = f.readBlock( buffer, 0xFFFF ) ) > 0 )
+ {
+ if ( tf->writeBlock( buffer, b ) != b )
+ break;
+ }
+ tf->close();
+ if ( b > 0 )
+ temp.setAutoDelete( true );
+ else
+ {
+ kdDebug( 500 ) << "File copied to " << temp.name() << endl;
+ result = temp.name();
+ }
+ }
+ else
+ temp.setAutoDelete( true );
+ f.close();
+ }
+ return result;
+}
+
+//******************************************************************************************************
+
+PrintWrapper::PrintWrapper()
+: TQWidget(), force_stdin(false), check_stdin(true)
+{
+}
+
+void PrintWrapper::slotPrint()
+{
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+#if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
+ struct sigaction action;
+#endif /* HAVE_SIGACTION && !HAVE_SIGSET*/
+
+ // read variables from command line
+ TQString printer = args->getOption("d");
+ TQString title = args->getOption("t");
+ int ncopies = TQString(args->getOption("n")).toInt();
+ TQString job_mode = args->getOption("j");
+ TQString system = args->getOption("system");
+ QCStringList optlist = args->getOptionList("o");
+ TQMap<TQString,TQString> opts;
+ KURL::List files;
+ TQStringList filestoprint;
+ force_stdin = args->isSet("stdin");
+ docopy = args->isSet( "c" );
+ bool nodialog = !(args->isSet("dialog"));
+
+ if( isatty( 0 ))
+ {
+ kdDebug( 500 ) << "stdin is a terminal, disabling it" << endl;
+ check_stdin = false;
+ }
+
+ // parse options
+ for (QCStringList::ConstIterator it=optlist.begin(); it!=optlist.end(); ++it)
+ {
+ TQStringList l = TQStringList::split('=',TQString(*it),false);
+ if (l.count() >= 1) opts[l[0]] = (l.count() == 2 ? l[1] : TQString::null);
+ }
+
+ // read file list
+ for (int i=0; i<args->count(); i++)
+ files.append(args->url(i));
+
+ // some clean-up
+ args->clear();
+
+ // set default values if necessary
+ if (job_mode == "console") job_output = 1;
+ else if (job_mode == "none") job_output = 2;
+ else job_output = 0;
+
+ // some checking
+ if ( files.count() > 0)
+ {
+ check_stdin = false;
+
+ if( force_stdin )
+ {
+ showmsg(i18n("A file has been specified on the command line. Printing from STDIN will be disabled."), 1);
+ force_stdin = false;
+ }
+ }
+ if (nodialog && files.count() == 0 &&!force_stdin && !check_stdin )
+ {
+ errormsg(i18n("When using '--nodialog', you must at least specify one file to print or use the '--stdin' flag."));
+ }
+
+ if( check_stdin )
+ { // check if there's any input on stdin
+ fd_set in;
+ struct timeval tm;
+ tm.tv_sec = 0;
+ tm.tv_usec = 0;
+ FD_ZERO( &in );
+ FD_SET( 0, &in );
+ if( select( 1, &in, NULL, NULL, &tm ) )
+ { // we have data on stdin
+ if ( read( 0, &readchar, 1 ) > 0 )
+ {
+ force_stdin = true;
+ check_stdin = false;
+ dataread = true;
+ kdDebug( 500 ) << "input detected on stdin" << endl;
+ }
+ else
+ {
+ force_stdin = check_stdin = false;
+ kdDebug( 500 ) << "stdin closed and empty" << endl;
+ }
+ }
+ else
+ kdDebug( 500 ) << "no input on stdin at startup" << endl;
+ }
+
+ // force_stdin ? or also check_stdin ?
+ KPrinter::ApplicationType dialog_mode = (force_stdin || nodialog ? KPrinter::StandAlone : KPrinter::StandAlonePersistent);
+ KPrinter::setApplicationType(dialog_mode);
+ if (!force_stdin)
+ KPrinter::addStandardPage(KPrinter::FilesPage);
+
+ KPrinter kprinter;
+ if (nodialog)
+ {
+ KMPrinter *prt(0);
+ KMManager *mgr = KMManager::self();
+
+ mgr->printerList(false);
+ if (!printer.isEmpty())
+ prt = mgr->findPrinter(printer);
+ else
+ prt = mgr->defaultPrinter();
+
+ if (prt == 0)
+ errormsg(i18n("The specified printer or the default printer could not be found."));
+ else if (!prt->autoConfigure(&kprinter))
+ errormsg(i18n("Operation aborted."));
+ }
+ else if (!printer.isEmpty())
+ kprinter.setSearchName(printer);
+ kprinter.setDocName(title);
+ kprinter.initOptions(opts);
+ kprinter.setOption("kde-filelist", files.toStringList().join("@@"));
+ kdDebug( 500 ) << kprinter.option( "kde-filelist" ) << endl;
+ if (ncopies > 0)
+ kprinter.setNumCopies(ncopies);
+
+ if (nodialog)
+ slotPrintRequested(&kprinter);
+ else
+ {
+ dlg = KPrintDialog::printerDialog(&kprinter, 0);
+ if (dlg)
+ {
+ connect(dlg, TQT_SIGNAL(printRequested(KPrinter*)), TQT_SLOT(slotPrintRequested(KPrinter*)));
+ if( check_stdin )
+ {
+ notif = new TQSocketNotifier( 0, TQSocketNotifier::Read, TQT_TQOBJECT(this) );
+ connect( notif, TQT_SIGNAL( activated( int )), this, TQT_SLOT( slotGotStdin()));
+ kdDebug( 500 ) << "waiting for input on stdin" << endl;
+ }
+ dlg->exec();
+ delete dlg;
+ }
+ else
+ errormsg(i18n("Unable to construct the print dialog."));
+ }
+
+ TQTimer::singleShot(10,kapp,TQT_SLOT(quit()));
+}
+
+void hack( KPrintDialog* dlg );
+
+void PrintWrapper::slotGotStdin()
+{
+ delete notif;
+ if ( read( 0, &readchar, 1 ) > 0 )
+ {
+ force_stdin = true;
+ check_stdin = false;
+ dataread = true;
+ dlg->enableDialogPage( 0, false );
+ kdDebug( 500 ) << "got delayed input on stdin" << endl;
+ }
+}
+
+void PrintWrapper::slotPrintRequested(KPrinter *kprinter)
+{
+ // re-initialize docName
+ kprinter->setDocName(TQString::null);
+
+ // download files if needed
+ TQStringList files = TQStringList::split("@@", kprinter->option("kde-filelist"), false), filestoprint;
+ for (TQStringList::ConstIterator it=files.begin(); it!=files.end(); ++it)
+ {
+ TQString tmpFile;
+ KURL url = KURL::fromPathOrURL(*it);
+ kdDebug( 500 ) << url.url() << endl;
+ if (KIO::NetAccess::download(url, tmpFile, this))
+ {
+ filestoprint << tmpFile;
+ kprinter->setDocName(url.fileName());
+ }
+ }
+
+ if (filestoprint.count() > 1)
+ kprinter->setDocName(i18n("Multiple files (%1)").arg(filestoprint.count()));
+ else if (kprinter->docName().isEmpty())
+ kprinter->setDocName(force_stdin ? "<STDIN>" : "KPrinter");
+ if (filestoprint.count() == 0)
+ {
+ // At this point force_stdin should be true
+ if (!force_stdin)
+ errormsg(i18n("Nothing to print."));
+
+ // print from stdin
+
+# if defined(HAVE_SIGSET)
+ sigset(SIGHUP, signal_handler);
+ sigset(SIGINT, signal_handler);
+ sigset(SIGTERM, signal_handler);
+# elif defined(HAVE_SIGACTION)
+ memset(&action, 0, sizeof(action));
+ action.sa_handler = signal_handler;
+
+ sigaction(SIGHUP, &action, NULL);
+ sigaction(SIGINT, &action, NULL);
+ sigaction(SIGTERM, &action, NULL);
+# else
+ signal(SIGHUP, signal_handler);
+ signal(SIGINT, signal_handler);
+ signal(SIGTERM, signal_handler);
+# endif
+
+ tempFile = locateLocal("tmp","kprinter_")+TQString::number(getpid());
+ filestoprint.append(tempFile);
+ fromStdin = true;
+ FILE *fout = fopen(TQFile::encodeName(filestoprint[0]),"w");
+ if (!fout) errormsg(i18n("Unable to open temporary file."));
+ char buffer[8192];
+ int s;
+
+ // check for previously read data
+ if ( dataread )
+ fwrite( &readchar, 1, 1, fout );
+ // read stdin and write to temporary file
+ while ((s=fread(buffer,1,sizeof(buffer),stdin)) > 0)
+ fwrite(buffer,1,s,fout);
+
+ s = ftell(fout);
+ fclose(fout);
+ if (s <= 0)
+ {
+ showmsg(i18n("Stdin is empty, no job sent."), 2);
+ TQFile::remove(filestoprint[0]);
+ return;
+ }
+ }
+ else if ( docopy )
+ {
+ for ( TQStringList::Iterator it=filestoprint.begin(); it!=filestoprint.end(); ++it )
+ {
+ TQString tmp = copyfile( *it );
+ if ( tmp.isEmpty() )
+ {
+ errormsg( i18n( "Unable to copy file %1." ).arg( *it ) );
+ return;
+ }
+ *it = tmp;
+ }
+ fromStdin = true;
+ }
+ else
+ fromStdin = false;
+
+ // print all files. Remove it after if printing from
+ // stdin. "kprinter" shouldn't remove temp file itself,
+ // otherwise the temp file might get removed before the
+ // print process finishes.
+ bool ok = kprinter->printFiles(filestoprint, fromStdin);
+
+ if (!ok)
+ showmsg(i18n("Error while printing files"), 2);
+ // Do not show this dialog anymore. Code sould be removed definitively
+ // if nobody complains.
+ /*else
+ {
+ QString msg = i18n("<nobr>File(s) sent to printer <b>%1</b>.</nobr>").arg(kprinter->printerName());
+ showmsg(msg,0);
+ }*/
+}
+
+#include "printwrapper.moc"
diff --git a/tdeprint/kprinter/printwrapper.h b/tdeprint/kprinter/printwrapper.h
new file mode 100644
index 000000000..e34e8d964
--- /dev/null
+++ b/tdeprint/kprinter/printwrapper.h
@@ -0,0 +1,49 @@
+/*
+ * This file is part of the KDE libraries
+ * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License version 2 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ **/
+
+#ifndef PRINTWRAPPER_H
+#define PRINTWRAPPER_H
+
+#include <tqwidget.h>
+
+class KPrinter;
+class KPrintDialog;
+class TQSocketNotifier;
+
+class PrintWrapper : public TQWidget
+{
+ Q_OBJECT
+public:
+ PrintWrapper();
+
+public slots:
+ void slotPrint();
+ void slotPrintRequested(KPrinter*);
+
+private slots:
+ void slotGotStdin();
+
+private:
+ bool force_stdin;
+ bool check_stdin;
+ KPrintDialog* dlg;
+ TQSocketNotifier* notif;
+};
+
+#endif