Removed job and operation attributes prefix
Added more attribute constants
This commit is contained in:
parent
6fab588008
commit
4018bb14e6
182
constants.go
182
constants.go
|
@ -208,7 +208,7 @@ const (
|
||||||
TagUnsupportedValue = 0x10
|
TagUnsupportedValue = 0x10
|
||||||
TagDefault = 0x11
|
TagDefault = 0x11
|
||||||
TagUnknown = 0x12
|
TagUnknown = 0x12
|
||||||
TagNoValue = 0x013
|
TagNoValue = 0x13
|
||||||
TagNotSettable = 0x15
|
TagNotSettable = 0x15
|
||||||
TagDeleteAttr = 0x16
|
TagDeleteAttr = 0x16
|
||||||
TagAdminDefine = 0x17
|
TagAdminDefine = 0x17
|
||||||
|
@ -300,88 +300,112 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
OperationAttributeCopies string = "copies"
|
AttributeCopies string = "copies"
|
||||||
OperationAttributeDocumentFormat = "document-format"
|
AttributeDocumentFormat = "document-format"
|
||||||
OperationAttributeDocumentName = "document-name"
|
AttributeDocumentName = "document-name"
|
||||||
OperationAttributeJobID = "job-id"
|
AttributeJobID = "job-id"
|
||||||
OperationAttributeJobName = "job-name"
|
AttributeJobName = "job-name"
|
||||||
OperationAttributeJobPriority = "job-priority"
|
AttributeJobPriority = "job-priority"
|
||||||
OperationAttributeJobURI = "job-uri"
|
AttributeJobURI = "job-uri"
|
||||||
OperationAttributeLastDocument = "last-document"
|
AttributeLastDocument = "last-document"
|
||||||
OperationAttributeMyJobs = "my-jobs"
|
AttributeMyJobs = "my-jobs"
|
||||||
OperationAttributePPDName = "ppd-name"
|
AttributePPDName = "ppd-name"
|
||||||
OperationAttributePrinterIsShared = "printer-is-shared"
|
AttributePrinterIsShared = "printer-is-shared"
|
||||||
OperationAttributePrinterURI = "printer-uri"
|
AttributePrinterURI = "printer-uri"
|
||||||
OperationAttributePurgeJobs = "purge-jobs"
|
AttributePurgeJobs = "purge-jobs"
|
||||||
OperationAttributeRequestedAttributes = "requested-attributes"
|
AttributeRequestedAttributes = "requested-attributes"
|
||||||
OperationAttributeRequestingUserName = "requesting-user-name"
|
AttributeRequestingUserName = "requesting-user-name"
|
||||||
OperationAttributeWhichJobs = "which-jobs"
|
AttributeWhichJobs = "which-jobs"
|
||||||
OperationAttributeFirstJobID = "first-job-id"
|
AttributeFirstJobID = "first-job-id"
|
||||||
OperationAttributeLimit = "limit"
|
AttributeLimit = "limit"
|
||||||
)
|
AttributeStatusMessage = "status-message"
|
||||||
|
AttributeCharset = "attributes-charset"
|
||||||
const (
|
AttributeNaturalLanguage = "attributes-natural-language"
|
||||||
PrinterAttributeDeviceURI string = "device-uri"
|
AttributeDeviceURI = "device-uri"
|
||||||
PrinterAttributeHoldJobUntil = "job-hold-until"
|
AttributeHoldJobUntil = "job-hold-until"
|
||||||
PrinterAttributePrinterErrorPolicy = "printer-error-policy"
|
AttributePrinterErrorPolicy = "printer-error-policy"
|
||||||
PrinterAttributePrinterInfo = "printer-info"
|
AttributePrinterInfo = "printer-info"
|
||||||
PrinterAttributePrinterLocation = "printer-location"
|
AttributePrinterLocation = "printer-location"
|
||||||
PrinterAttributePrinterName = "printer-name"
|
AttributePrinterName = "printer-name"
|
||||||
PrinterAttributePrinterStateReason = "printer-state-reason"
|
AttributePrinterStateReason = "printer-state-reason"
|
||||||
PrinterAttributeJobPrinterURI = "job-printer-uri"
|
AttributeJobPrinterURI = "job-printer-uri"
|
||||||
PrinterAttributeMemberURIs = "member-uris"
|
AttributeMemberURIs = "member-uris"
|
||||||
|
AttributeDocumentNumber = "document-number"
|
||||||
|
AttributeDocumentState = "document-state"
|
||||||
|
AttributeFinishings = "finishings"
|
||||||
|
AttributeJobHoldUntil = "hold-job-until"
|
||||||
|
AttributeJobSheets = "job-sheets"
|
||||||
|
AttributeJobState = "job-state"
|
||||||
|
AttributeJobStateReason = "job-state-reason"
|
||||||
|
AttributeMedia = "media"
|
||||||
|
AttributeNumberUp = "number-up"
|
||||||
|
AttributeOrientationRequested = "orientation-requested"
|
||||||
|
AttributePrintQuality = "print-quality"
|
||||||
|
AttributePrinterIsAcceptingJobs = "printer-is-accepting-jobs"
|
||||||
|
AttributePrinterResolution = "printer-resolution"
|
||||||
|
AttributePrinterState = "printer-state"
|
||||||
|
AttributeMemberNames = "member-names"
|
||||||
|
AttributePrinterType = "printer-type"
|
||||||
|
AttributePrinterMarkAndModel = "printer-make-and-model"
|
||||||
|
AttributePrinterStateMessage = "printer-state-message"
|
||||||
|
AttributePrinterUriSupported = "printer-uri-supported"
|
||||||
|
AttributeJobMediaProgress = "job-media-progress"
|
||||||
|
AttributeJobKilobyteOctets = "job-k-octets"
|
||||||
|
AttributeNumberOfDocuments = "number-of-documents"
|
||||||
|
AttributeJobOriginatingUserName = "job-originating-user-name"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
DefaultClassAttributes = []string{"printer-name", "member-names"}
|
DefaultClassAttributes = []string{AttributePrinterName, AttributeMemberNames}
|
||||||
DefaultPrinterAttributes = []string{"printer-name", "printer-type", "printer-location", "printer-info",
|
DefaultPrinterAttributes = []string{AttributePrinterName, AttributePrinterType, AttributePrinterLocation, AttributePrinterInfo,
|
||||||
"printer-make-and-model", "printer-state", "printer-state-message", "printer-state-reason",
|
AttributePrinterMarkAndModel, AttributePrinterState, AttributePrinterStateMessage, AttributePrinterStateReason,
|
||||||
"printer-uri-supported", "device-uri", "printer-is-shared"}
|
AttributePrinterUriSupported, AttributeDeviceURI, AttributePrinterIsShared}
|
||||||
DefaultJobAttributes = []string{"job-id", "job-name", "printer-uri", "job-state", "job-state-reasons",
|
DefaultJobAttributes = []string{AttributeJobID, AttributeJobName, AttributePrinterURI, AttributeJobState, AttributeJobStateReason,
|
||||||
"job-hold-until", "job-media-progress", "job-k-octets", "number-of-documents", "copies",
|
AttributeJobHoldUntil, AttributeJobMediaProgress, AttributeJobKilobyteOctets, AttributeNumberOfDocuments, AttributeCopies,
|
||||||
"job-originating-user-name"}
|
AttributeJobOriginatingUserName}
|
||||||
|
|
||||||
AttributeTagMapping = map[string]Tag{
|
AttributeTagMapping = map[string]Tag{
|
||||||
"attributes-charset": TagCharset,
|
AttributeCharset: TagCharset,
|
||||||
"attributes-natural-language": TagLanguage,
|
AttributeNaturalLanguage: TagLanguage,
|
||||||
"copies": TagInteger,
|
AttributeCopies: TagInteger,
|
||||||
"device-uri": TagUri,
|
AttributeDeviceURI: TagUri,
|
||||||
"document-format": TagMimeType,
|
AttributeDocumentFormat: TagMimeType,
|
||||||
"document-name": TagName,
|
AttributeDocumentName: TagName,
|
||||||
"document-number": TagInteger,
|
AttributeDocumentNumber: TagInteger,
|
||||||
"document-state": TagEnum,
|
AttributeDocumentState: TagEnum,
|
||||||
"finishings": TagEnum,
|
AttributeFinishings: TagEnum,
|
||||||
"hold-job-until": TagKeyword,
|
AttributeJobHoldUntil: TagKeyword,
|
||||||
"job-hold-until": TagKeyword,
|
AttributeHoldJobUntil: TagKeyword,
|
||||||
"job-id": TagInteger,
|
AttributeJobID: TagInteger,
|
||||||
"job-name": TagName,
|
AttributeJobName: TagName,
|
||||||
"job-printer-uri": TagUri,
|
AttributeJobPrinterURI: TagUri,
|
||||||
"job-priority": TagInteger,
|
AttributeJobPriority: TagInteger,
|
||||||
"job-sheets": TagName,
|
AttributeJobSheets: TagName,
|
||||||
"job-state": TagEnum,
|
AttributeJobState: TagEnum,
|
||||||
"job-state-reason": TagKeyword,
|
AttributeJobStateReason: TagKeyword,
|
||||||
"job-uri": TagUri,
|
AttributeJobURI: TagUri,
|
||||||
"last-document": TagBoolean,
|
AttributeLastDocument: TagBoolean,
|
||||||
"media": TagKeyword,
|
AttributeMedia: TagKeyword,
|
||||||
"member-uris": TagUri,
|
AttributeMemberURIs: TagUri,
|
||||||
"my-jobs": TagBoolean,
|
AttributeMyJobs: TagBoolean,
|
||||||
"number-up": TagInteger,
|
AttributeNumberUp: TagInteger,
|
||||||
"orientation-requested": TagEnum,
|
AttributeOrientationRequested: TagEnum,
|
||||||
"ppd-name": TagName,
|
AttributePPDName: TagName,
|
||||||
"print-quality": TagEnum,
|
AttributePrintQuality: TagEnum,
|
||||||
"printer-error-policy": TagName,
|
AttributePrinterErrorPolicy: TagName,
|
||||||
"printer-info": TagText,
|
AttributePrinterInfo: TagText,
|
||||||
"printer-is-accepting-jobs": TagBoolean,
|
AttributePrinterIsAcceptingJobs: TagBoolean,
|
||||||
"printer-is-shared": TagBoolean,
|
AttributePrinterIsShared: TagBoolean,
|
||||||
"printer-location": TagText,
|
AttributePrinterLocation: TagText,
|
||||||
"printer-resolution": TagResolution,
|
AttributePrinterResolution: TagResolution,
|
||||||
"printer-state": TagEnum,
|
AttributePrinterState: TagEnum,
|
||||||
"printer-state-reason": TagKeyword,
|
AttributePrinterStateReason: TagKeyword,
|
||||||
"printer-uri": TagUri,
|
AttributePrinterURI: TagUri,
|
||||||
"purge-jobs": TagBoolean,
|
AttributePurgeJobs: TagBoolean,
|
||||||
"requested-attributes": TagKeyword,
|
AttributeRequestedAttributes: TagKeyword,
|
||||||
"requesting-user-name": TagName,
|
AttributeRequestingUserName: TagName,
|
||||||
"which-jobs": TagKeyword,
|
AttributeWhichJobs: TagKeyword,
|
||||||
"first-job-id": TagInteger,
|
AttributeFirstJobID: TagInteger,
|
||||||
|
AttributeStatusMessage: TagText,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,7 +22,7 @@ func (c *CUPSClient) GetDevices() (map[string]Attributes, error) {
|
||||||
printerNameMap := make(map[string]Attributes)
|
printerNameMap := make(map[string]Attributes)
|
||||||
|
|
||||||
for _, printerAttributes := range resp.PrinterAttributes {
|
for _, printerAttributes := range resp.PrinterAttributes {
|
||||||
printerNameMap[printerAttributes[PrinterAttributeDeviceURI][0].Value.(string)] = printerAttributes
|
printerNameMap[printerAttributes[AttributeDeviceURI][0].Value.(string)] = printerAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
return printerNameMap, nil
|
return printerNameMap, nil
|
||||||
|
@ -30,8 +30,8 @@ func (c *CUPSClient) GetDevices() (map[string]Attributes, error) {
|
||||||
|
|
||||||
func (c *CUPSClient) MoveJob(jobID int, destPrinter string) error {
|
func (c *CUPSClient) MoveJob(jobID int, destPrinter string) error {
|
||||||
req := NewRequest(OperationCupsMoveJob, 1)
|
req := NewRequest(OperationCupsMoveJob, 1)
|
||||||
req.OperationAttributes[OperationAttributeJobURI] = c.getJobUri(jobID)
|
req.OperationAttributes[AttributeJobURI] = c.getJobUri(jobID)
|
||||||
req.PrinterAttributes[PrinterAttributeJobPrinterURI] = c.getPrinterUri(destPrinter)
|
req.PrinterAttributes[AttributeJobPrinterURI] = c.getPrinterUri(destPrinter)
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("jobs", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("jobs", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -39,8 +39,8 @@ func (c *CUPSClient) MoveJob(jobID int, destPrinter string) error {
|
||||||
|
|
||||||
func (c *CUPSClient) MoveAllJob(srcPrinter, destPrinter string) error {
|
func (c *CUPSClient) MoveAllJob(srcPrinter, destPrinter string) error {
|
||||||
req := NewRequest(OperationCupsMoveJob, 1)
|
req := NewRequest(OperationCupsMoveJob, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(srcPrinter)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(srcPrinter)
|
||||||
req.PrinterAttributes[PrinterAttributeJobPrinterURI] = c.getPrinterUri(destPrinter)
|
req.PrinterAttributes[AttributeJobPrinterURI] = c.getPrinterUri(destPrinter)
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("jobs", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("jobs", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -57,7 +57,7 @@ func (c *CUPSClient) GetPPDs() (map[string]Attributes, error) {
|
||||||
ppdNameMap := make(map[string]Attributes)
|
ppdNameMap := make(map[string]Attributes)
|
||||||
|
|
||||||
for _, printerAttributes := range resp.PrinterAttributes {
|
for _, printerAttributes := range resp.PrinterAttributes {
|
||||||
ppdNameMap[printerAttributes[OperationAttributePPDName][0].Value.(string)] = printerAttributes
|
ppdNameMap[printerAttributes[AttributePPDName][0].Value.(string)] = printerAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
return ppdNameMap, nil
|
return ppdNameMap, nil
|
||||||
|
@ -65,7 +65,7 @@ func (c *CUPSClient) GetPPDs() (map[string]Attributes, error) {
|
||||||
|
|
||||||
func (c *CUPSClient) AcceptJobs(printer string) error {
|
func (c *CUPSClient) AcceptJobs(printer string) error {
|
||||||
req := NewRequest(OperationCupsAcceptJobs, 1)
|
req := NewRequest(OperationCupsAcceptJobs, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -73,14 +73,14 @@ func (c *CUPSClient) AcceptJobs(printer string) error {
|
||||||
|
|
||||||
func (c *CUPSClient) RejectJobs(printer string) error {
|
func (c *CUPSClient) RejectJobs(printer string) error {
|
||||||
req := NewRequest(OperationCupsRejectJobs, 1)
|
req := NewRequest(OperationCupsRejectJobs, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CUPSClient) AddPrinterToClass(class, printer string) error {
|
func (c *CUPSClient) AddPrinterToClass(class, printer string) error {
|
||||||
attributes, err := c.GetPrinterAttributes(class, []string{PrinterAttributeMemberURIs})
|
attributes, err := c.GetPrinterAttributes(class, []string{AttributeMemberURIs})
|
||||||
if err != nil && !IsNotExistsError(err) {
|
if err != nil && !IsNotExistsError(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ func (c *CUPSClient) AddPrinterToClass(class, printer string) error {
|
||||||
memberURIList := make([]string, 0)
|
memberURIList := make([]string, 0)
|
||||||
|
|
||||||
if !IsNotExistsError(err) {
|
if !IsNotExistsError(err) {
|
||||||
for _, member := range attributes[PrinterAttributeMemberURIs] {
|
for _, member := range attributes[AttributeMemberURIs] {
|
||||||
memberString := strings.Split(member.Value.(string), "/")
|
memberString := strings.Split(member.Value.(string), "/")
|
||||||
printerName := memberString[len(memberString)-1]
|
printerName := memberString[len(memberString)-1]
|
||||||
|
|
||||||
|
@ -103,22 +103,22 @@ func (c *CUPSClient) AddPrinterToClass(class, printer string) error {
|
||||||
memberURIList = append(memberURIList, c.getPrinterUri(printer))
|
memberURIList = append(memberURIList, c.getPrinterUri(printer))
|
||||||
|
|
||||||
req := NewRequest(OperationCupsAddModifyClass, 1)
|
req := NewRequest(OperationCupsAddModifyClass, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getClassUri(class)
|
req.OperationAttributes[AttributePrinterURI] = c.getClassUri(class)
|
||||||
req.PrinterAttributes[PrinterAttributeMemberURIs] = memberURIList
|
req.PrinterAttributes[AttributeMemberURIs] = memberURIList
|
||||||
|
|
||||||
_, err = c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err = c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CUPSClient) DeletePrinterFromClass(class, printer string) error {
|
func (c *CUPSClient) DeletePrinterFromClass(class, printer string) error {
|
||||||
attributes, err := c.GetPrinterAttributes(class, []string{PrinterAttributeMemberURIs})
|
attributes, err := c.GetPrinterAttributes(class, []string{AttributeMemberURIs})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
memberURIList := make([]string, 0)
|
memberURIList := make([]string, 0)
|
||||||
|
|
||||||
for _, member := range attributes[PrinterAttributeMemberURIs] {
|
for _, member := range attributes[AttributeMemberURIs] {
|
||||||
memberString := strings.Split(member.Value.(string), "/")
|
memberString := strings.Split(member.Value.(string), "/")
|
||||||
printerName := memberString[len(memberString)-1]
|
printerName := memberString[len(memberString)-1]
|
||||||
|
|
||||||
|
@ -132,8 +132,8 @@ func (c *CUPSClient) DeletePrinterFromClass(class, printer string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
req := NewRequest(OperationCupsAddModifyClass, 1)
|
req := NewRequest(OperationCupsAddModifyClass, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getClassUri(class)
|
req.OperationAttributes[AttributePrinterURI] = c.getClassUri(class)
|
||||||
req.PrinterAttributes[PrinterAttributeMemberURIs] = memberURIList
|
req.PrinterAttributes[AttributeMemberURIs] = memberURIList
|
||||||
|
|
||||||
_, err = c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err = c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -141,7 +141,7 @@ func (c *CUPSClient) DeletePrinterFromClass(class, printer string) error {
|
||||||
|
|
||||||
func (c *CUPSClient) DeleteClass(class string) error {
|
func (c *CUPSClient) DeleteClass(class string) error {
|
||||||
req := NewRequest(OperationCupsDeleteClass, 1)
|
req := NewRequest(OperationCupsDeleteClass, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getClassUri(class)
|
req.OperationAttributes[AttributePrinterURI] = c.getClassUri(class)
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -149,14 +149,14 @@ func (c *CUPSClient) DeleteClass(class string) error {
|
||||||
|
|
||||||
func (c *CUPSClient) CreatePrinter(name, deviceURI, ppd string, shared bool, errorPolicy ErrorPolicy, information, location string) error {
|
func (c *CUPSClient) CreatePrinter(name, deviceURI, ppd string, shared bool, errorPolicy ErrorPolicy, information, location string) error {
|
||||||
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(name)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(name)
|
||||||
req.OperationAttributes[OperationAttributePPDName] = ppd
|
req.OperationAttributes[AttributePPDName] = ppd
|
||||||
req.OperationAttributes[OperationAttributePrinterIsShared] = shared
|
req.OperationAttributes[AttributePrinterIsShared] = shared
|
||||||
req.PrinterAttributes[PrinterAttributePrinterStateReason] = "none"
|
req.PrinterAttributes[AttributePrinterStateReason] = "none"
|
||||||
req.PrinterAttributes[PrinterAttributeDeviceURI] = deviceURI
|
req.PrinterAttributes[AttributeDeviceURI] = deviceURI
|
||||||
req.PrinterAttributes[PrinterAttributePrinterInfo] = information
|
req.PrinterAttributes[AttributePrinterInfo] = information
|
||||||
req.PrinterAttributes[PrinterAttributePrinterLocation] = location
|
req.PrinterAttributes[AttributePrinterLocation] = location
|
||||||
req.PrinterAttributes[PrinterAttributePrinterErrorPolicy] = string(errorPolicy)
|
req.PrinterAttributes[AttributePrinterErrorPolicy] = string(errorPolicy)
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -164,8 +164,8 @@ func (c *CUPSClient) CreatePrinter(name, deviceURI, ppd string, shared bool, err
|
||||||
|
|
||||||
func (c *CUPSClient) SetPrinterPPD(printer, ppd string) error {
|
func (c *CUPSClient) SetPrinterPPD(printer, ppd string) error {
|
||||||
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
req.OperationAttributes[OperationAttributePPDName] = ppd
|
req.OperationAttributes[AttributePPDName] = ppd
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -173,8 +173,8 @@ func (c *CUPSClient) SetPrinterPPD(printer, ppd string) error {
|
||||||
|
|
||||||
func (c *CUPSClient) SetPrinterDeviceURI(printer, deviceURI string) error {
|
func (c *CUPSClient) SetPrinterDeviceURI(printer, deviceURI string) error {
|
||||||
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
req.PrinterAttributes[PrinterAttributeDeviceURI] = deviceURI
|
req.PrinterAttributes[AttributeDeviceURI] = deviceURI
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -182,8 +182,8 @@ func (c *CUPSClient) SetPrinterDeviceURI(printer, deviceURI string) error {
|
||||||
|
|
||||||
func (c *CUPSClient) SetPrinterIsShared(printer string, shared bool) error {
|
func (c *CUPSClient) SetPrinterIsShared(printer string, shared bool) error {
|
||||||
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
req.OperationAttributes[OperationAttributePrinterIsShared] = shared
|
req.OperationAttributes[AttributePrinterIsShared] = shared
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -191,8 +191,8 @@ func (c *CUPSClient) SetPrinterIsShared(printer string, shared bool) error {
|
||||||
|
|
||||||
func (c *CUPSClient) SetPrinterErrorPolicy(printer string, errorPolicy ErrorPolicy) error {
|
func (c *CUPSClient) SetPrinterErrorPolicy(printer string, errorPolicy ErrorPolicy) error {
|
||||||
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
req.PrinterAttributes[PrinterAttributePrinterErrorPolicy] = string(errorPolicy)
|
req.PrinterAttributes[AttributePrinterErrorPolicy] = string(errorPolicy)
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -200,8 +200,8 @@ func (c *CUPSClient) SetPrinterErrorPolicy(printer string, errorPolicy ErrorPoli
|
||||||
|
|
||||||
func (c *CUPSClient) SetPrinterInformation(printer, information string) error {
|
func (c *CUPSClient) SetPrinterInformation(printer, information string) error {
|
||||||
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
req.PrinterAttributes[PrinterAttributePrinterInfo] = information
|
req.PrinterAttributes[AttributePrinterInfo] = information
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -209,8 +209,8 @@ func (c *CUPSClient) SetPrinterInformation(printer, information string) error {
|
||||||
|
|
||||||
func (c *CUPSClient) SetPrinterLocation(printer, location string) error {
|
func (c *CUPSClient) SetPrinterLocation(printer, location string) error {
|
||||||
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
req := NewRequest(OperationCupsAddModifyPrinter, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
req.PrinterAttributes[PrinterAttributePrinterLocation] = location
|
req.PrinterAttributes[AttributePrinterLocation] = location
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -218,7 +218,7 @@ func (c *CUPSClient) SetPrinterLocation(printer, location string) error {
|
||||||
|
|
||||||
func (c *CUPSClient) DeletePrinter(printer string) error {
|
func (c *CUPSClient) DeletePrinter(printer string) error {
|
||||||
req := NewRequest(OperationCupsDeletePrinter, 1)
|
req := NewRequest(OperationCupsDeletePrinter, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -228,9 +228,9 @@ func (c *CUPSClient) GetPrinters(attributes []string) (map[string]Attributes, er
|
||||||
req := NewRequest(OperationCupsGetPrinters, 1)
|
req := NewRequest(OperationCupsGetPrinters, 1)
|
||||||
|
|
||||||
if attributes == nil {
|
if attributes == nil {
|
||||||
req.OperationAttributes[OperationAttributeRequestedAttributes] = DefaultPrinterAttributes
|
req.OperationAttributes[AttributeRequestedAttributes] = DefaultPrinterAttributes
|
||||||
} else {
|
} else {
|
||||||
req.OperationAttributes[OperationAttributeRequestedAttributes] = append(attributes, PrinterAttributePrinterName)
|
req.OperationAttributes[AttributeRequestedAttributes] = append(attributes, AttributePrinterName)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := c.SendRequest(c.getHttpUri("", nil), req, nil)
|
resp, err := c.SendRequest(c.getHttpUri("", nil), req, nil)
|
||||||
|
@ -241,7 +241,7 @@ func (c *CUPSClient) GetPrinters(attributes []string) (map[string]Attributes, er
|
||||||
printerNameMap := make(map[string]Attributes)
|
printerNameMap := make(map[string]Attributes)
|
||||||
|
|
||||||
for _, printerAttributes := range resp.PrinterAttributes {
|
for _, printerAttributes := range resp.PrinterAttributes {
|
||||||
printerNameMap[printerAttributes[PrinterAttributePrinterName][0].Value.(string)] = printerAttributes
|
printerNameMap[printerAttributes[AttributePrinterName][0].Value.(string)] = printerAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
return printerNameMap, nil
|
return printerNameMap, nil
|
||||||
|
@ -251,9 +251,9 @@ func (c *CUPSClient) GetClasses(attributes []string) (map[string]Attributes, err
|
||||||
req := NewRequest(OperationCupsGetClasses, 1)
|
req := NewRequest(OperationCupsGetClasses, 1)
|
||||||
|
|
||||||
if attributes == nil {
|
if attributes == nil {
|
||||||
req.OperationAttributes[OperationAttributeRequestedAttributes] = DefaultClassAttributes
|
req.OperationAttributes[AttributeRequestedAttributes] = DefaultClassAttributes
|
||||||
} else {
|
} else {
|
||||||
req.OperationAttributes[OperationAttributeRequestedAttributes] = append(attributes, PrinterAttributePrinterName)
|
req.OperationAttributes[AttributeRequestedAttributes] = append(attributes, AttributePrinterName)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := c.SendRequest(c.getHttpUri("", nil), req, nil)
|
resp, err := c.SendRequest(c.getHttpUri("", nil), req, nil)
|
||||||
|
@ -264,7 +264,7 @@ func (c *CUPSClient) GetClasses(attributes []string) (map[string]Attributes, err
|
||||||
printerNameMap := make(map[string]Attributes)
|
printerNameMap := make(map[string]Attributes)
|
||||||
|
|
||||||
for _, printerAttributes := range resp.PrinterAttributes {
|
for _, printerAttributes := range resp.PrinterAttributes {
|
||||||
printerNameMap[printerAttributes[PrinterAttributePrinterName][0].Value.(string)] = printerAttributes
|
printerNameMap[printerAttributes[AttributePrinterName][0].Value.(string)] = printerAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
return printerNameMap, nil
|
return printerNameMap, nil
|
||||||
|
|
|
@ -124,13 +124,13 @@ func (c *IPPClient) PrintDocuments(docs []Document, printer string, jobAttribute
|
||||||
printerURI := c.getPrinterUri(printer)
|
printerURI := c.getPrinterUri(printer)
|
||||||
|
|
||||||
req := NewRequest(OperationCreateJob, 1)
|
req := NewRequest(OperationCreateJob, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = printerURI
|
req.OperationAttributes[AttributePrinterURI] = printerURI
|
||||||
req.OperationAttributes[OperationAttributeRequestingUserName] = c.username
|
req.OperationAttributes[AttributeRequestingUserName] = c.username
|
||||||
|
|
||||||
// set defaults for some attributes, may get overwritten
|
// set defaults for some attributes, may get overwritten
|
||||||
req.OperationAttributes[OperationAttributeJobName] = docs[0].Name
|
req.OperationAttributes[AttributeJobName] = docs[0].Name
|
||||||
req.OperationAttributes[OperationAttributeCopies] = 1
|
req.OperationAttributes[AttributeCopies] = 1
|
||||||
req.OperationAttributes[OperationAttributeJobPriority] = DefaultJobPriority
|
req.OperationAttributes[AttributeJobPriority] = DefaultJobPriority
|
||||||
|
|
||||||
for key, value := range jobAttributes {
|
for key, value := range jobAttributes {
|
||||||
req.JobAttributes[key] = value
|
req.JobAttributes[key] = value
|
||||||
|
@ -145,18 +145,18 @@ func (c *IPPClient) PrintDocuments(docs []Document, printer string, jobAttribute
|
||||||
return 0, errors.New("server doesn't returned a job id")
|
return 0, errors.New("server doesn't returned a job id")
|
||||||
}
|
}
|
||||||
|
|
||||||
jobID := resp.JobAttributes[0][OperationAttributeJobID][0].Value.(int)
|
jobID := resp.JobAttributes[0][AttributeJobID][0].Value.(int)
|
||||||
|
|
||||||
documentCount := len(docs) - 1
|
documentCount := len(docs) - 1
|
||||||
|
|
||||||
for docID, doc := range docs {
|
for docID, doc := range docs {
|
||||||
req = NewRequest(OperationSendDocument, 2)
|
req = NewRequest(OperationSendDocument, 2)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = printerURI
|
req.OperationAttributes[AttributePrinterURI] = printerURI
|
||||||
req.OperationAttributes[OperationAttributeRequestingUserName] = c.username
|
req.OperationAttributes[AttributeRequestingUserName] = c.username
|
||||||
req.OperationAttributes[OperationAttributeJobID] = jobID
|
req.OperationAttributes[AttributeJobID] = jobID
|
||||||
req.OperationAttributes[OperationAttributeDocumentName] = doc.Name
|
req.OperationAttributes[AttributeDocumentName] = doc.Name
|
||||||
req.OperationAttributes[OperationAttributeDocumentFormat] = doc.MimeType
|
req.OperationAttributes[AttributeDocumentFormat] = doc.MimeType
|
||||||
req.OperationAttributes[OperationAttributeLastDocument] = docID == documentCount
|
req.OperationAttributes[AttributeLastDocument] = docID == documentCount
|
||||||
req.File = doc.Document
|
req.File = doc.Document
|
||||||
req.FileSize = doc.Size
|
req.FileSize = doc.Size
|
||||||
|
|
||||||
|
@ -190,14 +190,14 @@ func (c *IPPClient) PrintJob(doc Document, printer string, jobAttributes map[str
|
||||||
printerURI := c.getPrinterUri(printer)
|
printerURI := c.getPrinterUri(printer)
|
||||||
|
|
||||||
req := NewRequest(OperationPrintJob, 1)
|
req := NewRequest(OperationPrintJob, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = printerURI
|
req.OperationAttributes[AttributePrinterURI] = printerURI
|
||||||
req.OperationAttributes[OperationAttributeRequestingUserName] = c.username
|
req.OperationAttributes[AttributeRequestingUserName] = c.username
|
||||||
req.OperationAttributes[OperationAttributeJobName] = doc.Name
|
req.OperationAttributes[AttributeJobName] = doc.Name
|
||||||
req.OperationAttributes[OperationAttributeDocumentFormat] = doc.MimeType
|
req.OperationAttributes[AttributeDocumentFormat] = doc.MimeType
|
||||||
|
|
||||||
// set defaults for some attributes, may get overwritten
|
// set defaults for some attributes, may get overwritten
|
||||||
req.OperationAttributes[OperationAttributeCopies] = 1
|
req.OperationAttributes[AttributeCopies] = 1
|
||||||
req.OperationAttributes[OperationAttributeJobPriority] = DefaultJobPriority
|
req.OperationAttributes[AttributeJobPriority] = DefaultJobPriority
|
||||||
|
|
||||||
for key, value := range jobAttributes {
|
for key, value := range jobAttributes {
|
||||||
req.JobAttributes[key] = value
|
req.JobAttributes[key] = value
|
||||||
|
@ -215,7 +215,7 @@ func (c *IPPClient) PrintJob(doc Document, printer string, jobAttributes map[str
|
||||||
return 0, errors.New("server doesn't returned a job id")
|
return 0, errors.New("server doesn't returned a job id")
|
||||||
}
|
}
|
||||||
|
|
||||||
jobID := resp.JobAttributes[0][OperationAttributeJobID][0].Value.(int)
|
jobID := resp.JobAttributes[0][AttributeJobID][0].Value.(int)
|
||||||
|
|
||||||
return jobID, nil
|
return jobID, nil
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ func (c *IPPClient) PrintFile(filePath, printer string, jobAttributes map[string
|
||||||
}
|
}
|
||||||
defer document.Close()
|
defer document.Close()
|
||||||
|
|
||||||
jobAttributes[OperationAttributeJobName] = fileName
|
jobAttributes[AttributeJobName] = fileName
|
||||||
|
|
||||||
return c.PrintDocuments([]Document{
|
return c.PrintDocuments([]Document{
|
||||||
{
|
{
|
||||||
|
@ -248,13 +248,13 @@ func (c *IPPClient) PrintFile(filePath, printer string, jobAttributes map[string
|
||||||
|
|
||||||
func (c *IPPClient) GetPrinterAttributes(printer string, attributes []string) (Attributes, error) {
|
func (c *IPPClient) GetPrinterAttributes(printer string, attributes []string) (Attributes, error) {
|
||||||
req := NewRequest(OperationGetPrinterAttributes, 1)
|
req := NewRequest(OperationGetPrinterAttributes, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
req.OperationAttributes[OperationAttributeRequestingUserName] = c.username
|
req.OperationAttributes[AttributeRequestingUserName] = c.username
|
||||||
|
|
||||||
if attributes == nil {
|
if attributes == nil {
|
||||||
req.OperationAttributes[OperationAttributeRequestedAttributes] = DefaultPrinterAttributes
|
req.OperationAttributes[AttributeRequestedAttributes] = DefaultPrinterAttributes
|
||||||
} else {
|
} else {
|
||||||
req.OperationAttributes[OperationAttributeRequestedAttributes] = attributes
|
req.OperationAttributes[AttributeRequestedAttributes] = attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := c.SendRequest(c.getHttpUri("printers", printer), req, nil)
|
resp, err := c.SendRequest(c.getHttpUri("printers", printer), req, nil)
|
||||||
|
@ -271,7 +271,7 @@ func (c *IPPClient) GetPrinterAttributes(printer string, attributes []string) (A
|
||||||
|
|
||||||
func (c *IPPClient) ResumePrinter(printer string) error {
|
func (c *IPPClient) ResumePrinter(printer string) error {
|
||||||
req := NewRequest(OperationResumePrinter, 1)
|
req := NewRequest(OperationResumePrinter, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -279,7 +279,7 @@ func (c *IPPClient) ResumePrinter(printer string) error {
|
||||||
|
|
||||||
func (c *IPPClient) PausePrinter(printer string) error {
|
func (c *IPPClient) PausePrinter(printer string) error {
|
||||||
req := NewRequest(OperationPausePrinter, 1)
|
req := NewRequest(OperationPausePrinter, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -287,12 +287,12 @@ func (c *IPPClient) PausePrinter(printer string) error {
|
||||||
|
|
||||||
func (c *IPPClient) GetJobAttributes(jobID int, attributes []string) (Attributes, error) {
|
func (c *IPPClient) GetJobAttributes(jobID int, attributes []string) (Attributes, error) {
|
||||||
req := NewRequest(OperationGetJobAttributes, 1)
|
req := NewRequest(OperationGetJobAttributes, 1)
|
||||||
req.OperationAttributes[OperationAttributeJobURI] = c.getJobUri(jobID)
|
req.OperationAttributes[AttributeJobURI] = c.getJobUri(jobID)
|
||||||
|
|
||||||
if attributes == nil {
|
if attributes == nil {
|
||||||
req.OperationAttributes[OperationAttributeRequestedAttributes] = DefaultJobAttributes
|
req.OperationAttributes[AttributeRequestedAttributes] = DefaultJobAttributes
|
||||||
} else {
|
} else {
|
||||||
req.OperationAttributes[OperationAttributeRequestedAttributes] = attributes
|
req.OperationAttributes[AttributeRequestedAttributes] = attributes
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := c.SendRequest(c.getHttpUri("jobs", jobID), req, nil)
|
resp, err := c.SendRequest(c.getHttpUri("jobs", jobID), req, nil)
|
||||||
|
@ -309,33 +309,33 @@ func (c *IPPClient) GetJobAttributes(jobID int, attributes []string) (Attributes
|
||||||
|
|
||||||
func (c *IPPClient) GetJobs(printer, class string, whichJobs JobStateFilter, myJobs bool, firstJobId, limit int, attributes []string) (map[int]Attributes, error) {
|
func (c *IPPClient) GetJobs(printer, class string, whichJobs JobStateFilter, myJobs bool, firstJobId, limit int, attributes []string) (map[int]Attributes, error) {
|
||||||
req := NewRequest(OperationGetJobs, 1)
|
req := NewRequest(OperationGetJobs, 1)
|
||||||
req.OperationAttributes[OperationAttributeWhichJobs] = string(whichJobs)
|
req.OperationAttributes[AttributeWhichJobs] = string(whichJobs)
|
||||||
req.OperationAttributes[OperationAttributeMyJobs] = myJobs
|
req.OperationAttributes[AttributeMyJobs] = myJobs
|
||||||
|
|
||||||
if printer != "" {
|
if printer != "" {
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
} else if class != "" {
|
} else if class != "" {
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getClassUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getClassUri(printer)
|
||||||
} else {
|
} else {
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = "ipp://localhost/"
|
req.OperationAttributes[AttributePrinterURI] = "ipp://localhost/"
|
||||||
}
|
}
|
||||||
|
|
||||||
if firstJobId > 0 {
|
if firstJobId > 0 {
|
||||||
req.OperationAttributes[OperationAttributeFirstJobID] = firstJobId
|
req.OperationAttributes[AttributeFirstJobID] = firstJobId
|
||||||
}
|
}
|
||||||
|
|
||||||
if limit > 0 {
|
if limit > 0 {
|
||||||
req.OperationAttributes[OperationAttributeLimit] = limit
|
req.OperationAttributes[AttributeLimit] = limit
|
||||||
}
|
}
|
||||||
|
|
||||||
if myJobs {
|
if myJobs {
|
||||||
req.OperationAttributes[OperationAttributeRequestingUserName] = c.username
|
req.OperationAttributes[AttributeRequestingUserName] = c.username
|
||||||
}
|
}
|
||||||
|
|
||||||
if attributes == nil {
|
if attributes == nil {
|
||||||
req.OperationAttributes[OperationAttributeRequestedAttributes] = DefaultJobAttributes
|
req.OperationAttributes[AttributeRequestedAttributes] = DefaultJobAttributes
|
||||||
} else {
|
} else {
|
||||||
req.OperationAttributes[OperationAttributeRequestedAttributes] = append(attributes, OperationAttributeJobID)
|
req.OperationAttributes[AttributeRequestedAttributes] = append(attributes, AttributeJobID)
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := c.SendRequest(c.getHttpUri("", nil), req, nil)
|
resp, err := c.SendRequest(c.getHttpUri("", nil), req, nil)
|
||||||
|
@ -346,7 +346,7 @@ func (c *IPPClient) GetJobs(printer, class string, whichJobs JobStateFilter, myJ
|
||||||
jobIDMap := make(map[int]Attributes)
|
jobIDMap := make(map[int]Attributes)
|
||||||
|
|
||||||
for _, jobAttributes := range resp.JobAttributes {
|
for _, jobAttributes := range resp.JobAttributes {
|
||||||
jobIDMap[jobAttributes[OperationAttributeJobID][0].Value.(int)] = jobAttributes
|
jobIDMap[jobAttributes[AttributeJobID][0].Value.(int)] = jobAttributes
|
||||||
}
|
}
|
||||||
|
|
||||||
return jobIDMap, nil
|
return jobIDMap, nil
|
||||||
|
@ -354,8 +354,8 @@ func (c *IPPClient) GetJobs(printer, class string, whichJobs JobStateFilter, myJ
|
||||||
|
|
||||||
func (c *IPPClient) CancelJob(jobID int, purge bool) error {
|
func (c *IPPClient) CancelJob(jobID int, purge bool) error {
|
||||||
req := NewRequest(OperationCancelJob, 1)
|
req := NewRequest(OperationCancelJob, 1)
|
||||||
req.OperationAttributes[OperationAttributeJobURI] = c.getJobUri(jobID)
|
req.OperationAttributes[AttributeJobURI] = c.getJobUri(jobID)
|
||||||
req.OperationAttributes[OperationAttributePurgeJobs] = purge
|
req.OperationAttributes[AttributePurgeJobs] = purge
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("jobs", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("jobs", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -363,8 +363,8 @@ func (c *IPPClient) CancelJob(jobID int, purge bool) error {
|
||||||
|
|
||||||
func (c *IPPClient) CancelAllJob(printer string, purge bool) error {
|
func (c *IPPClient) CancelAllJob(printer string, purge bool) error {
|
||||||
req := NewRequest(OperationCancelJobs, 1)
|
req := NewRequest(OperationCancelJobs, 1)
|
||||||
req.OperationAttributes[OperationAttributePrinterURI] = c.getPrinterUri(printer)
|
req.OperationAttributes[AttributePrinterURI] = c.getPrinterUri(printer)
|
||||||
req.OperationAttributes[OperationAttributePurgeJobs] = purge
|
req.OperationAttributes[AttributePurgeJobs] = purge
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("admin", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -372,7 +372,7 @@ func (c *IPPClient) CancelAllJob(printer string, purge bool) error {
|
||||||
|
|
||||||
func (c *IPPClient) RestartJob(jobID int) error {
|
func (c *IPPClient) RestartJob(jobID int) error {
|
||||||
req := NewRequest(OperationRestartJob, 1)
|
req := NewRequest(OperationRestartJob, 1)
|
||||||
req.OperationAttributes[OperationAttributeJobURI] = c.getJobUri(jobID)
|
req.OperationAttributes[AttributeJobURI] = c.getJobUri(jobID)
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("jobs", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("jobs", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -380,8 +380,8 @@ func (c *IPPClient) RestartJob(jobID int) error {
|
||||||
|
|
||||||
func (c *IPPClient) HoldJobUntil(jobID int, holdUntil string) error {
|
func (c *IPPClient) HoldJobUntil(jobID int, holdUntil string) error {
|
||||||
req := NewRequest(OperationRestartJob, 1)
|
req := NewRequest(OperationRestartJob, 1)
|
||||||
req.OperationAttributes[OperationAttributeJobURI] = c.getJobUri(jobID)
|
req.OperationAttributes[AttributeJobURI] = c.getJobUri(jobID)
|
||||||
req.JobAttributes[PrinterAttributeHoldJobUntil] = holdUntil
|
req.JobAttributes[AttributeHoldJobUntil] = holdUntil
|
||||||
|
|
||||||
_, err := c.SendRequest(c.getHttpUri("jobs", ""), req, nil)
|
_, err := c.SendRequest(c.getHttpUri("jobs", ""), req, nil)
|
||||||
return err
|
return err
|
||||||
|
@ -403,7 +403,7 @@ func (c *IPPClient) PrintTestPage(printer string) (int, error) {
|
||||||
MimeType: MimeTypePostscript,
|
MimeType: MimeTypePostscript,
|
||||||
},
|
},
|
||||||
}, printer, map[string]interface{}{
|
}, printer, map[string]interface{}{
|
||||||
OperationAttributeJobName: "Test Page",
|
AttributeJobName: "Test Page",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,11 +59,11 @@ func (r *Request) Encode() ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := enc.Encode("attributes-charset", Charset); err != nil {
|
if err := enc.Encode(AttributeCharset, Charset); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := enc.Encode("attributes-natural-language", CharsetLanguage); err != nil {
|
if err := enc.Encode(AttributeNaturalLanguage, CharsetLanguage); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -70,11 +70,11 @@ func (r *Response) Encode(data io.Writer) ([]byte, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := enc.Encode("attributes-charset", Charset); err != nil {
|
if err := enc.Encode(AttributeCharset, Charset); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := enc.Encode("attributes-natural-language", CharsetLanguage); err != nil {
|
if err := enc.Encode(AttributeNaturalLanguage, CharsetLanguage); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue