xref: /haiku/src/add-ons/print/drivers/postscript/PSEntry.cpp (revision f7b0c08caed76819599e50c30f1f48b13fbb9cf6)
1 /*
2  * PSEntry.cpp
3  * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
4  * Copyright 2003 Michael Pfeiffer.
5  * Copyright 2010 Ithamar Adema.
6  */
7 
8 #include "PS.h"
9 #include "PSCap.h"
10 #include "PSData.h"
11 #include "PrinterDriver.h"
12 #include "SelectPPDDlg.h"
13 
14 #include <Entry.h>
15 #include <Path.h>
16 
17 class PSPrinterDriver : public PrinterDriver {
18 public:
19 	PSPrinterDriver(BNode *printerFolder) : PrinterDriver(printerFolder) {}
20 
21 	const char *GetSignature() const
22 	{
23 		return "application/x-vnd.PS-compatible";
24 	}
25 
26 	const char *GetDriverName() const
27 	{
28 		return "PS compatible";
29 	}
30 
31 	const char *GetVersion() const
32 	{
33 		return "0.1";
34 	}
35 
36 	const char *GetCopyright() const
37 	{
38 		return "PS driver Copyright © 2003,04 Michael Pfeiffer.\n";
39 	}
40 
41 	char *AddPrinter(char *printerName)
42 	{
43 		BPath path;
44 		if (find_directory(B_SYSTEM_DATA_DIRECTORY, &path) == B_OK
45 			&& path.Append("ppd") == B_OK
46 			&& BEntry(path.Path()).Exists()) {
47 			SelectPPDDlg *dialog = new SelectPPDDlg(dynamic_cast<PSData*>(GetPrinterData()));
48 			if (dialog->Go() != B_OK)
49 				return NULL;
50 		}
51 
52 		return printerName;
53 	}
54 
55 	PrinterData *InstantiatePrinterData(BNode *node)
56 	{
57 		return new PSData(node);
58 	}
59 
60 	PrinterCap *InstantiatePrinterCap(PrinterData *printerData)
61 	{
62 		return new PSCap(printerData);
63 	}
64 
65 	GraphicsDriver *InstantiateGraphicsDriver(BMessage *settings, PrinterData *printerData, PrinterCap *printerCap)
66 	{
67 		return new PSDriver(settings, printerData, printerCap);
68 	}
69 };
70 
71 
72 PrinterDriver *
73 instantiate_printer_driver(BNode *printerFolder)
74 {
75 	return new PSPrinterDriver(printerFolder);
76 }
77