mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 07:22:50 -05:00
core: replace all use of interface{} with any (#848)
This commit is contained in:
@@ -102,7 +102,7 @@ func (h *HttpAdapter) SendRequest(url string, req *Request, additionalResponseDa
|
||||
return ippResp, nil
|
||||
}
|
||||
|
||||
func (h *HttpAdapter) GetHttpUri(namespace string, object interface{}) string {
|
||||
func (h *HttpAdapter) GetHttpUri(namespace string, object any) string {
|
||||
proto := "http"
|
||||
if h.useTLS {
|
||||
proto = "https"
|
||||
|
||||
@@ -4,6 +4,6 @@ import "io"
|
||||
|
||||
type Adapter interface {
|
||||
SendRequest(url string, req *Request, additionalResponseData io.Writer) (*Response, error)
|
||||
GetHttpUri(namespace string, object interface{}) string
|
||||
GetHttpUri(namespace string, object any) string
|
||||
TestConnection() error
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func NewAttributeEncoder(w io.Writer) *AttributeEncoder {
|
||||
|
||||
// Encode encodes a attribute and its value to a io.Writer
|
||||
// the tag is determined by the AttributeTagMapping map
|
||||
func (e *AttributeEncoder) Encode(attribute string, value interface{}) error {
|
||||
func (e *AttributeEncoder) Encode(attribute string, value any) error {
|
||||
tag, ok := AttributeTagMapping[attribute]
|
||||
if !ok {
|
||||
return fmt.Errorf("cannot get tag of attribute %s", attribute)
|
||||
@@ -346,7 +346,7 @@ func (e *AttributeEncoder) writeNullByte() error {
|
||||
type Attribute struct {
|
||||
Tag int8
|
||||
Name string
|
||||
Value interface{}
|
||||
Value any
|
||||
}
|
||||
|
||||
// Resolution defines the resolution attribute
|
||||
|
||||
@@ -307,7 +307,7 @@ func (c *CUPSClient) PrintTestPage(printer string, testPageData io.Reader, size
|
||||
Name: "Test Page",
|
||||
Size: size,
|
||||
MimeType: MimeTypePDF,
|
||||
}, printer, map[string]interface{}{
|
||||
}, printer, map[string]any{
|
||||
AttributeJobName: "Test Page",
|
||||
})
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ func (c *IPPClient) SendRequest(url string, req *Request, additionalResponseData
|
||||
}
|
||||
|
||||
// PrintDocuments prints one or more documents using a Create-Job operation followed by one or more Send-Document operation(s). custom job settings can be specified via the jobAttributes parameter
|
||||
func (c *IPPClient) PrintDocuments(docs []Document, printer string, jobAttributes map[string]interface{}) (int, error) {
|
||||
func (c *IPPClient) PrintDocuments(docs []Document, printer string, jobAttributes map[string]any) (int, error) {
|
||||
printerURI := c.getPrinterUri(printer)
|
||||
|
||||
req := NewRequest(OperationCreateJob, 1)
|
||||
@@ -112,7 +112,7 @@ func (c *IPPClient) PrintDocuments(docs []Document, printer string, jobAttribute
|
||||
}
|
||||
|
||||
// PrintJob prints a document using a Print-Job operation. custom job settings can be specified via the jobAttributes parameter
|
||||
func (c *IPPClient) PrintJob(doc Document, printer string, jobAttributes map[string]interface{}) (int, error) {
|
||||
func (c *IPPClient) PrintJob(doc Document, printer string, jobAttributes map[string]any) (int, error) {
|
||||
printerURI := c.getPrinterUri(printer)
|
||||
|
||||
req := NewRequest(OperationPrintJob, 1)
|
||||
@@ -147,7 +147,7 @@ func (c *IPPClient) PrintJob(doc Document, printer string, jobAttributes map[str
|
||||
}
|
||||
|
||||
// PrintFile prints a local file on the file system. custom job settings can be specified via the jobAttributes parameter
|
||||
func (c *IPPClient) PrintFile(filePath, printer string, jobAttributes map[string]interface{}) (int, error) {
|
||||
func (c *IPPClient) PrintFile(filePath, printer string, jobAttributes map[string]any) (int, error) {
|
||||
fileStats, err := os.Stat(filePath)
|
||||
if os.IsNotExist(err) {
|
||||
return -1, err
|
||||
|
||||
@@ -14,10 +14,10 @@ type Request struct {
|
||||
Operation int16
|
||||
RequestId int32
|
||||
|
||||
OperationAttributes map[string]interface{}
|
||||
JobAttributes map[string]interface{}
|
||||
PrinterAttributes map[string]interface{}
|
||||
SubscriptionAttributes map[string]interface{} // Added for subscription operations
|
||||
OperationAttributes map[string]any
|
||||
JobAttributes map[string]any
|
||||
PrinterAttributes map[string]any
|
||||
SubscriptionAttributes map[string]any // Added for subscription operations
|
||||
|
||||
File io.Reader
|
||||
FileSize int
|
||||
@@ -30,10 +30,10 @@ func NewRequest(op int16, reqID int32) *Request {
|
||||
ProtocolVersionMinor: ProtocolVersionMinor,
|
||||
Operation: op,
|
||||
RequestId: reqID,
|
||||
OperationAttributes: make(map[string]interface{}),
|
||||
JobAttributes: make(map[string]interface{}),
|
||||
PrinterAttributes: make(map[string]interface{}),
|
||||
SubscriptionAttributes: make(map[string]interface{}),
|
||||
OperationAttributes: make(map[string]any),
|
||||
JobAttributes: make(map[string]any),
|
||||
PrinterAttributes: make(map[string]any),
|
||||
SubscriptionAttributes: make(map[string]any),
|
||||
File: nil,
|
||||
FileSize: -1,
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func (r *Request) Encode() ([]byte, error) {
|
||||
}
|
||||
|
||||
if r.OperationAttributes == nil {
|
||||
r.OperationAttributes = make(map[string]interface{}, 2)
|
||||
r.OperationAttributes = make(map[string]any, 2)
|
||||
}
|
||||
|
||||
if _, found := r.OperationAttributes[AttributeCharset]; !found {
|
||||
@@ -232,7 +232,7 @@ func (d *RequestDecoder) Decode(data io.Writer) (*Request, error) {
|
||||
|
||||
if startByte == TagOperation {
|
||||
if req.OperationAttributes == nil {
|
||||
req.OperationAttributes = make(map[string]interface{})
|
||||
req.OperationAttributes = make(map[string]any)
|
||||
}
|
||||
|
||||
tag = TagOperation
|
||||
@@ -242,7 +242,7 @@ func (d *RequestDecoder) Decode(data io.Writer) (*Request, error) {
|
||||
|
||||
if startByte == TagJob {
|
||||
if req.JobAttributes == nil {
|
||||
req.JobAttributes = make(map[string]interface{})
|
||||
req.JobAttributes = make(map[string]any)
|
||||
}
|
||||
tag = TagJob
|
||||
tagSet = true
|
||||
@@ -250,7 +250,7 @@ func (d *RequestDecoder) Decode(data io.Writer) (*Request, error) {
|
||||
|
||||
if startByte == TagPrinter {
|
||||
if req.PrinterAttributes == nil {
|
||||
req.PrinterAttributes = make(map[string]interface{})
|
||||
req.PrinterAttributes = make(map[string]any)
|
||||
}
|
||||
tag = TagPrinter
|
||||
tagSet = true
|
||||
@@ -287,7 +287,7 @@ func (d *RequestDecoder) Decode(data io.Writer) (*Request, error) {
|
||||
return req, nil
|
||||
}
|
||||
|
||||
func appendAttributeToRequest(req *Request, tag int8, name string, value interface{}) {
|
||||
func appendAttributeToRequest(req *Request, tag int8, name string, value any) {
|
||||
switch tag {
|
||||
case TagOperation:
|
||||
req.OperationAttributes[name] = value
|
||||
|
||||
@@ -114,7 +114,7 @@ func (r *Response) Encode() ([]byte, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
values := make([]interface{}, len(attr))
|
||||
values := make([]any, len(attr))
|
||||
for i, v := range attr {
|
||||
values[i] = v.Value
|
||||
}
|
||||
@@ -143,7 +143,7 @@ func (r *Response) Encode() ([]byte, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
values := make([]interface{}, len(attr))
|
||||
values := make([]any, len(attr))
|
||||
for i, v := range attr {
|
||||
values[i] = v.Value
|
||||
}
|
||||
@@ -199,7 +199,7 @@ func encodeOperationAttribute(enc *AttributeEncoder, name string, attr []Attribu
|
||||
return nil
|
||||
}
|
||||
|
||||
values := make([]interface{}, len(attr))
|
||||
values := make([]any, len(attr))
|
||||
for i, v := range attr {
|
||||
values[i] = v.Value
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user