1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
|
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "printerqueueswrapper.h"
#include "support/generaldialogs.h"
using namespace std;
static char *getfilename(void *userdata)
{
return(File_Save_Dialog("Save printer spool file",NULL));
}
PrinterQueues::PrinterQueues()
{
queues=pqinfo_create();
queues->SetGetFilenameCallback(queues,getfilename,NULL);
}
PrinterQueues::~PrinterQueues()
{
cerr << "Disposing of printer queues\n" << endl;
if(queues)
queues->Dispose(queues);
cerr << "Done" << endl;
}
char *PrinterQueues::GetPrinterName(int idx)
{
return(queues->GetPrinterName(queues,idx));
}
int PrinterQueues::GetPrinterCount()
{
return(queues->GetPrinterCount(queues));
}
char *PrinterQueues::GetPrinterDriver(const char *printername)
{
queues->SetPrinterQueue(queues,printername);
return(queues->GetDriver(queues));
}
char *PrinterQueues::GetPrinterDriver()
{
return(queues->GetDriver(queues));
}
struct pqinfo *PrinterQueues::GetPQInfo()
{
return(queues);
}
const char *PrinterQueues::GetPrinterQueue()
{
return(queues->GetPrinterQueue(queues));
}
void PrinterQueues::SetPrinterQueue(const char *queue)
{
queues->SetPrinterQueue(queues,queue);
}
bool PrinterQueues::PrinterQueueExists(const char *queue)
{
int qc=GetPrinterCount();
for(int i=0;i<qc;++i)
{
char *tmp=GetPrinterName(i);
if(strcmp(queue,tmp)==0)
{
free(tmp);
return(true);
}
free(tmp);
}
return(false);
}
char *PrinterQueues::GetDriver()
{
return(queues->GetDriver(queues));
}
char *PrinterQueues::GetPPD()
{
cerr << "Current queue: " << GetPrinterQueue() << endl;
char *ppd=queues->GetPPD(queues);
if(ppd)
cerr << "PPD: " << ppd << endl;
else
cerr << "No PPD found" << endl;
return(queues->GetPPD(queues));
}
const char *PrinterQueues::GetCustomCommand()
{
#ifndef WIN32
return(queues->GetCustomCommand(queues));
#else
return(NULL);
#endif
}
void PrinterQueues::SetCustomCommand(const char *cmd)
{
#ifndef WIN32
queues->SetCustomCommand(queues,cmd);
#endif
}
bool PrinterQueues::InitialiseJob()
{
return(queues->InitialiseJob(queues)!=0);
}
void PrinterQueues::InitialisePage()
{
queues->InitialisePage(queues);
}
void PrinterQueues::EndPage()
{
queues->EndPage(queues);
}
void PrinterQueues::EndJob()
{
queues->EndJob(queues);
}
void PrinterQueues::CancelJob()
{
queues->CancelJob(queues);
}
int PrinterQueues::WriteData(const char *data,int bytecount)
{
return(queues->WriteData(queues,data,bytecount));
}
|