Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Driver #481

Open
wants to merge 91 commits into
base: driver
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
67f6c03
Read/write sparse config files.
Feb 24, 2016
f0b903a
Merge pull request #196 from jacobmarble/config
vitalybuka Feb 29, 2016
46211b0
fix build on FreeBSD
swills Mar 9, 2016
085313b
windows: Add build tags to winspool directory.
Mar 9, 2016
45dfb6b
Merge remote-tracking branch 'upstream/master' into freebsd-support
swills Mar 9, 2016
bcf210a
incorporate comments from review
swills Mar 9, 2016
3466cd7
Initial version of Windows installer
arastooz Feb 22, 2016
176b429
Merge pull request #198 from arastooz/master
Mar 10, 2016
13c0c53
Merge pull request #199 from swills/freebsd-support
Mar 10, 2016
7560bbe
add travis support
swills Mar 9, 2016
1fdc26d
Merge pull request #201 from swills/travis
Mar 11, 2016
433f5fb
Parse page sizes specified in points, like "w81h252"
stvnrhodes Mar 22, 2016
d1f3668
Merge pull request #204 from stvnrhodes/master
Mar 22, 2016
aee65e8
privet: HTTP API server port range.
Mar 1, 2016
7438aa0
Improve HTTP API server listen() function.
Mar 1, 2016
197b0a9
Merge pull request #211 from jacobmarble/ephemeral
vitalybuka Apr 11, 2016
0d8d28a
Implemented cups_job_full_username option in Windows port (and more) …
sicklittlemonkey Apr 18, 2016
62f24f5
Add mailing list info to README.md (#240)
agoode Jun 6, 2016
0c86a83
Correct the use of color when translated from attrs (not PPD) (#234)
agoode Jun 6, 2016
e79d3e1
Add omitempty to fields marked (optional) in the privet specification…
agoode Jun 6, 2016
f0989d2
Add support for the optional "note" privet TXT field that matches "de…
agoode Jun 6, 2016
389f93a
Fix Windows build break in Privet from #237 (#249)
sicklittlemonkey Jun 11, 2016
7e23ca7
Update group to cloud-print-connector@
jay0lee Jun 13, 2016
ea9f1d3
Initial renaming from google/cups-connector to google/cloud-print-con…
agoode Jun 13, 2016
ecf66a5
Update travis
agoode Jun 13, 2016
2f4e164
Update jenkins
agoode Jun 13, 2016
f142da2
Merge pull request #251 from agoode/renaming
jay0lee Jun 13, 2016
70dfe26
Add util flags: gcp-oauth-client-id, gcp-oauth-client-secret (#257)
sicklittlemonkey Jun 15, 2016
8ef57e0
Rename cups-connector to cloud-print-connector (#253)
agoode Jun 15, 2016
2d95107
Add exponential backoff and use it (#250)
agoode Jun 15, 2016
1fe98ab
Ensure we don't forget about Color and Duplex options on restart (#256)
agoode Jun 15, 2016
e797578
Add printer whitelist (#263)
sicklittlemonkey Jul 6, 2016
f84bb04
Windows installer improvements. (#276)
arastooz Jul 27, 2016
05bbb77
windows: Do not prompt to enable local/cloud in init tool. (#281)
Jul 29, 2016
3b9ffa1
CUPS: Allow any PPD option as CDD vendor capability. (#282)
Jul 29, 2016
fe125b8
Update usage of codegangsta/cli package. (#283)
Jul 30, 2016
84508df
Add systemd unit file to repository (#274)
agoode Jul 30, 2016
e7a886a
Mark offline printers as stopped (#285)
mfly Aug 3, 2016
a588dde
Change the Windows installer to install the config file to CommonAppD…
arastooz Aug 3, 2016
36ff70d
Wait for job to finish before releasing it from spooler (#289)
mfly Aug 3, 2016
c4a2feb
Add custom action that deletes GCP printers during uninstall. (#292)
arastooz Aug 4, 2016
e1a47b7
Fix some CLI error messages. (#293)
Aug 5, 2016
7afe5a4
log when fetch sees zero jobs (#298)
jay0lee Aug 30, 2016
5701480
Windows installer dependencies.wxs sorted fixes #297 (#303)
sicklittlemonkey Sep 1, 2016
7818031
Windows Connector util name fixes #296 (#302)
sicklittlemonkey Sep 6, 2016
89eea6f
Implement Privet on Windows fixes #246
jay0lee Sep 19, 2016
6c53620
Revert "Implement Privet on Windows fixes #246"
jay0lee Sep 19, 2016
79f973a
Generate a v4 UUID for proxy name instead of asking user
jay0lee Sep 19, 2016
6985e8f
go fmt cleaup
jay0lee Sep 19, 2016
e3c2bdd
Merge pull request #307 from jay0lee/remove-proxy-prmpt
jay0lee Sep 19, 2016
d3cc60c
init: combine sharing prompts and move after authentication
jay0lee Sep 21, 2016
be52dbb
"leave blank" instead of "press enter"
jay0lee Sep 22, 2016
97d0b1c
Merge pull request #310 from jay0lee/simplify-init-questions
jay0lee Sep 22, 2016
4a34480
Improvements to WIX to allow automation and silent install (#314)
jay0lee Sep 29, 2016
22c6214
Fix ServiceControl elements' Name attribute (#317)
arastooz Oct 5, 2016
012f157
Fix issues with temp folder being different between UI and execute se…
arastooz Aug 3, 2016
2d59eae
Merge pull request #318 from arastooz/master
arastooz Oct 5, 2016
6d97016
Use Trimspace() for universal whitespace removal
jay0lee Oct 6, 2016
552df2c
Merge pull request #319 from google/fix-share-scope-windows
jay0lee Oct 6, 2016
989303a
Shell script to build MSI
jay0lee Oct 27, 2016
7079eeb
Merge pull request #327 from google/jay0lee-build-msi-sh
jay0lee Oct 29, 2016
913d31d
include ppd.h (#328)
jay0lee Nov 7, 2016
d353d01
pull MSI version from environment (#326)
jay0lee Nov 11, 2016
481ad13
Fix of issue 340 : Failed to submit to native print system with some …
sbeaufort Jan 19, 2017
6726fb9
Retry XMPP connection on startup (#356)
agoode Apr 26, 2017
d9058bc
Don't return success to the OS if a problem occurs (#358)
agoode Apr 26, 2017
f0829cc
retry only 5xx errors. Fixes #349 (#354)
jay0lee May 2, 2017
343bb8d
Handle mDNS collisions in privet with Avahi (#359)
agoode May 15, 2017
cd1943f
Added support for Brother duplexing (BRDuplex) (#351)
elitegreg May 16, 2017
7f96e58
Listen for printer changes and refresh the printers list when it happ…
pastarmovj May 26, 2017
30b5178
This CL parameterized oauth credentials, oauth URLs and Google
Sep 7, 2017
27a84c8
Merge pull request #369 from google/testingURLs
dannikay Sep 11, 2017
57740aa
Add Firebase Messaging capabilities to connector.
pendyala82 Sep 12, 2017
e9ed5e0
Add capability to switch b/w XMPP and FCM.
pendyala82 Nov 16, 2017
fef5912
Fix minor string formatting issue.
pendyala82 Nov 17, 2017
e20d45f
Fix windows build (#380)
gabsource Nov 28, 2017
d4c039d
Move enable fcm notifications flag to config file.
pendyala82 Nov 29, 2017
2516088
Update gcp-windows-connector.go
jay0lee Nov 30, 2017
60e7485
More Windows Fixes (#391)
jay0lee Dec 1, 2017
36f6d56
Notification channel tag (#392)
jay0lee Dec 1, 2017
c1ec5ef
Fix uuid.NewV4 usage to allow gcp-connector-util to build again (#397)
agoode Jan 26, 2018
11d2968
Update list of travis go versions (#401)
agoode Mar 2, 2018
7d5f127
generalize build-msi.sh for 32/64 builds (#408)
jay0lee Apr 3, 2018
a780351
Migrate from fixed retry interval to exponential back off.
pendyala82 Apr 25, 2018
9386e53
Windows connector: don't retain paused jobs (#419)
sicklittlemonkey Jul 20, 2018
57abc1f
Replace package satori/go.uuid with google/uuid (#447)
ItsMattL Apr 8, 2019
fec18af
Ubuntu 16.04 (default is 14.04) to avoid ld issues (#450)
jay0lee Apr 8, 2019
c8280e2
reduce level info > debug for sync messages (#448)
jay0lee Apr 8, 2019
7e2d4bf
Windows: move whitelist/blacklist checks earlier (#449)
jay0lee Apr 8, 2019
cee4c3e
Migrate usage of urfave/cli from v1 to v2 (#470)
jkcdarunday Nov 24, 2019
4deba1b
Merge branch 'master' into driver
TeoCrack Jul 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: go
dist: xenial

go:
- "1.10.x"
- "1.11.x"
- "1.x"
- master

os:
- linux
- osx

before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get -qq update ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libcups2-dev libavahi-client-dev ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install bazaar ; fi
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Google Cloud Print Connector

## Introduction
Share printers from your Windows, Linux, or OS X computer with ChromeOS and Android devices, using the Cloud Print Connector. The Connector is a purpose-built system process. It can share hundreds of printers on a powerful server, or one printer on a Raspberry Pi.
Share printers from your Windows, Linux, FreeBSD or OS X computer with ChromeOS and Android devices, using the Cloud Print Connector. The Connector is a purpose-built system process. It can share hundreds of printers on a powerful server, or one printer on a Raspberry Pi.

Lots of help can be found in [the wiki](https://github.com/google/cups-connector/wiki).
Lots of help can be found in [the wiki](https://github.com/google/cloud-print-connector/wiki).

## Mailing list
Please join the mailing list at https://groups.google.com/forum/#!forum/cloud-print-connector. Anyone can post and view messages.

## Build Status
* Linux/OSX: [![Build Status](https://travis-ci.org/google/cloud-print-connector.svg?branch=master)](https://travis-ci.org/google/cloud-print-connector)

* FreeBSD: [![Build Status](http://jenkins.mouf.net/job/cloud-print-connector/badge/icon)](http://jenkins.mouf.net/job/cloud-print-connector/)

## License
Copyright 2015 Google Inc. All rights reserved.
Expand Down
7 changes: 2 additions & 5 deletions cdd/cdd.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ type TypedValueCapability struct {
}

type Color struct {
Option []ColorOption `json:"option"`
VendorKey string `json:"-"`
Option []ColorOption `json:"option"`
}

type ColorType string
Expand All @@ -339,8 +338,7 @@ type ColorOption struct {
}

type Duplex struct {
Option []DuplexOption `json:"option"`
VendorKey string `json:"-"`
Option []DuplexOption `json:"option"`
}

type DuplexType string
Expand All @@ -354,7 +352,6 @@ const (
type DuplexOption struct {
Type DuplexType `json:"type"` // default = "NO_DUPLEX"
IsDefault bool `json:"is_default"` // default = false
VendorID string `json:"-"`
}

type PageOrientation struct {
Expand Down
8 changes: 5 additions & 3 deletions cups/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

// +build linux darwin
// +build linux darwin freebsd

package cups

/*
#cgo freebsd CFLAGS: -I/usr/local/include
#cgo freebsd LDFLAGS: -L/usr/local/lib
#include "cups.h"
*/
import "C"
Expand All @@ -21,8 +23,8 @@ import (
"time"
"unsafe"

"github.com/google/cups-connector/lib"
"github.com/google/cups-connector/log"
"github.com/google/cloud-print-connector/lib"
"github.com/google/cloud-print-connector/log"
)

const (
Expand Down
81 changes: 57 additions & 24 deletions cups/cups.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd

// +build linux darwin
// +build linux darwin freebsd

package cups

Expand All @@ -26,9 +26,9 @@ import (
"time"
"unsafe"

"github.com/google/cups-connector/cdd"
"github.com/google/cups-connector/lib"
"github.com/google/cups-connector/log"
"github.com/google/cloud-print-connector/cdd"
"github.com/google/cloud-print-connector/lib"
"github.com/google/cloud-print-connector/log"
)

const (
Expand Down Expand Up @@ -136,11 +136,15 @@ type CUPS struct {
printerAttributes []string
systemTags map[string]string
printerBlacklist map[string]interface{}
printerWhitelist map[string]interface{}
ignoreRawPrinters bool
ignoreClassPrinters bool
}

func NewCUPS(infoToDisplayName, prefixJobIDToJobTitle bool, displayNamePrefix string, printerAttributes []string, maxConnections uint, connectTimeout time.Duration, printerBlacklist []string, ignoreRawPrinters bool, ignoreClassPrinters bool) (*CUPS, error) {
func NewCUPS(infoToDisplayName, prefixJobIDToJobTitle bool, displayNamePrefix string,
printerAttributes, vendorPPDOptions []string, maxConnections uint, connectTimeout time.Duration,
printerBlacklist, printerWhitelist []string, ignoreRawPrinters bool, ignoreClassPrinters bool,
fcmNotificationsEnable bool) (*CUPS, error) {
if err := checkPrinterAttributes(printerAttributes); err != nil {
return nil, err
}
Expand All @@ -149,9 +153,9 @@ func NewCUPS(infoToDisplayName, prefixJobIDToJobTitle bool, displayNamePrefix st
if err != nil {
return nil, err
}
pc := newPPDCache(cc)
pc := newPPDCache(cc, vendorPPDOptions)

systemTags, err := getSystemTags()
systemTags, err := getSystemTags(fcmNotificationsEnable)
if err != nil {
return nil, err
}
Expand All @@ -161,6 +165,11 @@ func NewCUPS(infoToDisplayName, prefixJobIDToJobTitle bool, displayNamePrefix st
pb[p] = struct{}{}
}

pw := map[string]interface{}{}
for _, p := range printerWhitelist {
pw[p] = struct{}{}
}

c := &CUPS{
cc: cc,
pc: pc,
Expand All @@ -169,6 +178,7 @@ func NewCUPS(infoToDisplayName, prefixJobIDToJobTitle bool, displayNamePrefix st
printerAttributes: printerAttributes,
systemTags: systemTags,
printerBlacklist: pb,
printerWhitelist: pw,
ignoreRawPrinters: ignoreRawPrinters,
ignoreClassPrinters: ignoreClassPrinters,
}
Expand Down Expand Up @@ -212,7 +222,7 @@ func (c *CUPS) GetPrinters() ([]lib.Printer, error) {
}

printers := c.responseToPrinters(response)
printers = c.filterBlacklistPrinters(printers)

if c.ignoreRawPrinters {
printers = filterRawPrinters(printers)
}
Expand Down Expand Up @@ -241,6 +251,26 @@ func (c *CUPS) responseToPrinters(response *C.ipp_t) []lib.Printer {
}
mAttributes := attributesToMap(attributes)
pds, pss, name, defaultDisplayName, uuid, tags := translateAttrs(mAttributes)

// Check whitelist/blacklist in loop once we have printer name.
// Avoids unnecessary processing of excluded printers.
if _, exists := c.printerBlacklist[name]; exists {
log.Debugf("Ignoring blacklisted printer %s", name)
if a == nil {
break
}
continue
}
if len(c.printerWhitelist) != 0 {
if _, exists := c.printerWhitelist[name]; !exists {
log.Debugf("Ignoring non-whitelisted printer %s", name)
if a == nil {
break
}
continue
}
}

if !c.infoToDisplayName || defaultDisplayName == "" {
defaultDisplayName = name
}
Expand All @@ -263,27 +293,17 @@ func (c *CUPS) responseToPrinters(response *C.ipp_t) []lib.Printer {
return printers
}

func (c *CUPS) filterBlacklistPrinters(printers []lib.Printer) []lib.Printer {
// filterClassPrinters removes class printers from the slice.
func filterClassPrinters(printers []lib.Printer) []lib.Printer {
result := make([]lib.Printer, 0, len(printers))
for i := range printers {
if _, exists := c.printerBlacklist[printers[i].Name]; !exists {
if !lib.PrinterIsClass(printers[i]) {
result = append(result, printers[i])
}
}
return result
}

// filterClassPrinters removes class printers from the slice.
func filterClassPrinters(printers []lib.Printer) []lib.Printer {
result := make([]lib.Printer, 0, len(printers))
for i := range printers {
if !lib.PrinterIsClass(printers[i]) {
result = append(result, printers[i])
}
}
return result
}

// filterRawPrinters removes raw printers from the slice.
func filterRawPrinters(printers []lib.Printer) []lib.Printer {
result := make([]lib.Printer, 0, len(printers))
Expand All @@ -304,10 +324,13 @@ func (c *CUPS) addPPDDescriptionToPrinters(printers []lib.Printer) []lib.Printer
for i := range printers {
wg.Add(1)
go func(p *lib.Printer) {
if description, manufacturer, model, err := c.pc.getPPDCacheEntry(p.Name); err == nil {
if description, manufacturer, model, duplexMap, err := c.pc.getPPDCacheEntry(p.Name); err == nil {
p.Description.Absorb(description)
p.Manufacturer = manufacturer
p.Model = model
if duplexMap != nil {
p.DuplexMap = duplexMap
}
ch <- p
} else {
log.ErrorPrinter(p.Name, err)
Expand Down Expand Up @@ -365,7 +388,7 @@ func uname() (string, string, string, string, string, error) {
C.GoString(&name.machine[0]), nil
}

func getSystemTags() (map[string]string, error) {
func getSystemTags(fcmNotificationsEnable bool) (map[string]string, error) {
tags := make(map[string]string)

tags["connector-version"] = lib.BuildDate
Expand All @@ -375,7 +398,11 @@ func getSystemTags() (map[string]string, error) {
}
tags["system-arch"] = runtime.GOARCH
tags["system-golang-version"] = runtime.Version()

if fcmNotificationsEnable {
tags["system-notifications-channel"] = "fcm"
} else {
tags["system-notifications-channel"] = "xmpp"
}
sysname, nodename, release, version, machine, err := uname()
if err != nil {
return nil, fmt.Errorf("CUPS failed to call uname while initializing: %s", err)
Expand Down Expand Up @@ -628,3 +655,9 @@ func checkPrinterAttributes(printerAttributes []string) error {

return nil
}

// The following functions are not relevant to CUPS printing, but are required by the NativePrintSystem interface.

func (c *CUPS) ReleaseJob(printerName string, jobID uint32) error {
return nil
}
1 change: 1 addition & 0 deletions cups/cups.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ license that can be found in the LICENSE file or at
#define _IPP_PRIVATE_STRUCTURES 1

#include <cups/cups.h>
#include <cups/ppd.h>
#include <stddef.h> // size_t
#include <stdlib.h> // free, calloc, malloc
#include <sys/socket.h> // AF_UNSPEC
Expand Down
Loading