1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 15:32:50 -05:00

cups: add comprehensive CUPs setting page

- Add printers
- Delete printers
- Use polkit APIs as fallback on auth errors
- Fix ref system to conditionally subscribe to cups when wanted
This commit is contained in:
bbedward
2025-11-29 17:35:21 -05:00
parent df663aceb9
commit e6c3ae9397
31 changed files with 5993 additions and 558 deletions

View File

@@ -288,6 +288,7 @@ const (
// useful mime types for ipp
const (
MimeTypePostscript = "application/postscript"
MimeTypePDF = "application/pdf"
MimeTypeOctetStream = "application/octet-stream"
)

View File

@@ -1,7 +1,7 @@
package ipp
import (
"bytes"
"io"
"strings"
)
@@ -300,22 +300,13 @@ func (c *CUPSClient) GetClasses(attributes []string) (map[string]Attributes, err
return printerNameMap, nil
}
// PrintTestPage prints a test page of type application/vnd.cups-pdf-banner
func (c *CUPSClient) PrintTestPage(printer string) (int, error) {
testPage := new(bytes.Buffer)
testPage.WriteString("#PDF-BANNER\n")
testPage.WriteString("Template default-testpage.pdf\n")
testPage.WriteString("Show printer-name printer-info printer-location printer-make-and-model printer-driver-name")
testPage.WriteString("printer-driver-version paper-size imageable-area job-id options time-at-creation")
testPage.WriteString("time-at-processing\n\n")
return c.PrintDocuments([]Document{
{
Document: testPage,
Name: "Test Page",
Size: testPage.Len(),
MimeType: MimeTypePostscript,
},
// PrintTestPage prints a test page using the provided PDF data
func (c *CUPSClient) PrintTestPage(printer string, testPageData io.Reader, size int) (int, error) {
return c.PrintJob(Document{
Document: testPageData,
Name: "Test Page",
Size: size,
MimeType: MimeTypePDF,
}, printer, map[string]interface{}{
AttributeJobName: "Test Page",
})