summaryrefslogtreecommitdiffstats
path: root/tdeprint
diff options
context:
space:
mode:
Diffstat (limited to 'tdeprint')
-rw-r--r--tdeprint/cups/kmcupsmanager.cpp12
-rw-r--r--tdeprint/cups/make_driver_db_cups.cpp5
-rw-r--r--tdeprint/driver.cpp2
-rw-r--r--tdeprint/driverparse.c3
-rw-r--r--tdeprint/ppdloader.cpp59
5 files changed, 76 insertions, 5 deletions
diff --git a/tdeprint/cups/kmcupsmanager.cpp b/tdeprint/cups/kmcupsmanager.cpp
index 7f06e0636..5271dcd12 100644
--- a/tdeprint/cups/kmcupsmanager.cpp
+++ b/tdeprint/cups/kmcupsmanager.cpp
@@ -114,6 +114,8 @@ TQString KMCupsManager::driverDirectory()
d.append(":/usr/local/share/foomatic/db/source");
#else
d.append(":/usr/share/foomatic/db/source");
+ // compressed foomatic support
+ d.append(":/usr/lib/cups/driver/foomatic-db-compressed-ppds");
#endif
return d;
}
@@ -626,6 +628,8 @@ DrMain* KMCupsManager::loadFileDriver(const TQString& filename)
{
if (filename.startsWith("ppd:"))
return loadDriverFile(filename.mid(4));
+ else if (filename.startsWith("compressed-ppd:"))
+ return loadDriverFile(filename);
else if (filename.startsWith("foomatic/"))
return loadMaticDriver(filename);
else
@@ -685,7 +689,7 @@ DrMain* KMCupsManager::loadMaticDriver(const TQString& drname)
DrMain* KMCupsManager::loadDriverFile(const TQString& fname)
{
- if (TQFile::exists(fname))
+ if ((fname.startsWith("compressed-ppd:")) || TQFile::exists(fname))
{
TQString msg; /* possible error message */
DrMain *driver = PPDLoader::loadDriver( fname, &msg );
@@ -704,7 +708,11 @@ DrMain* KMCupsManager::loadDriverFile(const TQString& fname)
void KMCupsManager::saveDriverFile(DrMain *driver, const TQString& filename)
{
kdDebug( 500 ) << "Saving PPD file with template=" << driver->get( "template" ) << endl;
- TQIODevice *in = KFilterDev::deviceForFile( driver->get( "template" ) );
+ TQString templateFile = driver->get( "template" );
+ if (templateFile.startsWith("compressed-ppd:")) {
+ templateFile = driver->get( "temporary-cppd" );
+ }
+ TQIODevice *in = KFilterDev::deviceForFile( templateFile );
TQFile out(filename);
if (in && in->open(IO_ReadOnly) && out.open(IO_WriteOnly))
{
diff --git a/tdeprint/cups/make_driver_db_cups.cpp b/tdeprint/cups/make_driver_db_cups.cpp
index 021c77b95..c658181a7 100644
--- a/tdeprint/cups/make_driver_db_cups.cpp
+++ b/tdeprint/cups/make_driver_db_cups.cpp
@@ -276,10 +276,15 @@ int parseCompressedPpdFile(const char *ppdfilename, const char *origin, const ch
}
}
+ manufacturer = manufacturer.stripWhiteSpace();
+ modelName = modelName.stripWhiteSpace();
+ driver = driver.stripWhiteSpace();
+
TQStringList driverList = TQStringList::split(",", driver, TRUE);
driver = driverList[0];
if (driver.startsWith("D")) {
driver = driver.mid(1);
+ driver = driver.stripWhiteSpace();
}
model = manufacturer + " " + modelName + " " + driver;
description = description + " [" + languageVersion + "]";
diff --git a/tdeprint/driver.cpp b/tdeprint/driver.cpp
index 6afc75d0f..92eb7fc84 100644
--- a/tdeprint/driver.cpp
+++ b/tdeprint/driver.cpp
@@ -110,6 +110,8 @@ DrMain::~DrMain()
// remove a possible temporary file
if (has("temporary"))
TQFile::remove(get("temporary"));
+ if (has("temporary-cppd"))
+ TQFile::remove(get("temporary-cppd"));
}
DriverItem* DrMain::createTreeView(TQListView *parent)
diff --git a/tdeprint/driverparse.c b/tdeprint/driverparse.c
index 4f733588a..891bdfe39 100644
--- a/tdeprint/driverparse.c
+++ b/tdeprint/driverparse.c
@@ -117,10 +117,11 @@ void initFiles(void)
void freeFiles(void)
{
int i;
- for (i=0; i<nfiles; i++)
+ for (i=0; i<nfiles; i++) {
free(files[i]);
free(fileorigins[i]);
free(filemetadata[i]);
+ }
free(files);
free(fileorigins);
free(filemetadata);
diff --git a/tdeprint/ppdloader.cpp b/tdeprint/ppdloader.cpp
index b829e2e17..a194c1c12 100644
--- a/tdeprint/ppdloader.cpp
+++ b/tdeprint/ppdloader.cpp
@@ -24,8 +24,10 @@
#include <kfilterdev.h>
#include <kdebug.h>
#include <tdelocale.h>
+#include <tdetempfile.h>
#include <tqfile.h>
#include <math.h>
+#include <stdlib.h>
void tdeprint_ppdscanner_init( TQIODevice* );
void tdeprint_ppdscanner_terminate( bool deleteIt = true );
@@ -119,12 +121,62 @@ PPDLoader::~PPDLoader()
DrMain* PPDLoader::readFromFile( const TQString& filename )
{
+ bool ppdFilenameIsTempFile = false;
+ TQString ppdFilename = filename;
+
+ if (filename.startsWith("compressed-ppd:")) {
+ KTempFile tempFile(TQString::null, "ppd", 0600);
+ tempFile.setAutoDelete(false);
+ ppdFilename = tempFile.name();
+
+ TQStringList filenameParts = TQStringList::split(":", filename);
+ TQString databaseFilename = TQString::null;
+ TQString compressedFilename = TQString::null;
+ int i = 0;
+ for (TQStringList::Iterator it = filenameParts.begin(); it != filenameParts.end(); ++it) {
+ if (i == 1) {
+ databaseFilename = *it;
+ }
+ else if (i > 1) {
+ compressedFilename += *it;
+ }
+ i++;
+ }
+
+ TQString command = databaseFilename + " cat " + compressedFilename;
+
+ FILE* file = popen(command.ascii(), "r");
+ if (file) {
+ char * line = NULL;
+ size_t len = 0;
+ ssize_t read;
+
+ FILE* tmpFileStream = tempFile.fstream();
+
+ while ((read = getline(&line, &len, file)) != -1) {
+ fputs(line, tmpFileStream);
+ }
+ if (line) {
+ free(line);
+ }
+
+ tempFile.close();
+ pclose(file);
+ }
+ else {
+ fprintf(stderr, "Can't open driver file : %s\n", compressedFilename.ascii());
+ return 0;
+ }
+
+ ppdFilenameIsTempFile = true;
+ }
+
// Initialization
m_groups.clear();
m_option = NULL;
m_fonts.clear();
// Open driver file
- TQIODevice *d = KFilterDev::deviceForFile( filename );
+ TQIODevice *d = KFilterDev::deviceForFile( ppdFilename );
if ( d && d->open( IO_ReadOnly ) )
{
DrMain *driver = new DrMain;
@@ -153,6 +205,9 @@ DrMain* PPDLoader::readFromFile( const TQString& filename )
processPageSizes( driver );
if ( !m_fonts.isEmpty() )
driver->set( "fonts", m_fonts.join( "," ) );
+ if (ppdFilenameIsTempFile) {
+ driver->set("temporary-cppd", ppdFilename);
+ }
return driver;
}
else
@@ -161,7 +216,7 @@ DrMain* PPDLoader::readFromFile( const TQString& filename )
m_ps.clear();
}
else
- kdWarning( 500 ) << "PPD read error, unable to open device for file " << filename << endl;
+ kdWarning( 500 ) << "PPD read error, unable to open device for file " << ppdFilename << endl;
return 0;
}