本文整理匯總了Golang中github.com/google/cups-connector/lib.Printer.SetTagshash方法的典型用法代碼示例。如果您正苦於以下問題:Golang Printer.SetTagshash方法的具體用法?Golang Printer.SetTagshash怎麽用?Golang Printer.SetTagshash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/cups-connector/lib.Printer
的用法示例。
在下文中一共展示了Printer.SetTagshash方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: tagsToPrinter
// tagsToPrinter converts a map of tags to a Printer.
func tagsToPrinter(printerTags map[string][]string, systemTags map[string]string, infoToDisplayName bool) lib.Printer {
tags := make(map[string]string)
for k, v := range printerTags {
tags[k] = strings.Join(v, ",")
}
for k, v := range systemTags {
tags[k] = v
}
var name string
if n, ok := printerTags[attrPrinterName]; ok {
name = n[0]
}
var uuid string
if u, ok := printerTags[attrPrinterUUID]; ok {
uuid = u[0]
}
state := cdd.PrinterStateSection{}
if s, ok := printerTags[attrPrinterState]; ok {
switch s[0] {
case "3":
state.State = cdd.CloudDeviceStateIdle
case "4":
state.State = cdd.CloudDeviceStateProcessing
case "5":
state.State = cdd.CloudDeviceStateStopped
default:
state.State = cdd.CloudDeviceStateIdle
}
}
if reasons, ok := printerTags[attrPrinterStateReasons]; ok && len(reasons) > 0 {
sort.Strings(reasons)
state.VendorState = &cdd.VendorState{Item: make([]cdd.VendorStateItem, len(reasons))}
for i, reason := range reasons {
vendorState := cdd.VendorStateItem{DescriptionLocalized: cdd.NewLocalizedString(reason)}
if strings.HasSuffix(reason, "-error") {
vendorState.State = cdd.VendorStateError
} else if strings.HasSuffix(reason, "-warning") {
vendorState.State = cdd.VendorStateWarning
} else if strings.HasSuffix(reason, "-report") {
vendorState.State = cdd.VendorStateInfo
} else {
vendorState.State = cdd.VendorStateInfo
}
state.VendorState.Item[i] = vendorState
}
}
markers, markerState := convertMarkers(printerTags[attrMarkerNames], printerTags[attrMarkerTypes], printerTags[attrMarkerLevels])
state.MarkerState = markerState
description := cdd.PrinterDescriptionSection{Marker: markers}
p := lib.Printer{
Name: name,
UUID: uuid,
State: &state,
Description: &description,
Tags: tags,
}
p.SetTagshash()
if pi, ok := printerTags[attrPrinterInfo]; ok && infoToDisplayName {
p.DefaultDisplayName = pi[0]
}
return p
}