r19715 - in /trunk/libnet-cups-perl: CUPS.xs Changes README debian/changelog lib/Net/CUPS.pm lib/Net/CUPS/Destination.pm lib/Net/CUPS/IPP.pm lib/Net/CUPS/PPD.pm t/03_destination.t typemap
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Thu May 8 19:57:08 UTC 2008
Author: gregoa
Date: Thu May 8 19:57:08 2008
New Revision: 19715
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=19715
Log:
New upstream release.
Added:
trunk/libnet-cups-perl/t/03_destination.t
- copied unchanged from r19714, branches/upstream/libnet-cups-perl/current/t/03_destination.t
Modified:
trunk/libnet-cups-perl/CUPS.xs
trunk/libnet-cups-perl/Changes
trunk/libnet-cups-perl/README
trunk/libnet-cups-perl/debian/changelog
trunk/libnet-cups-perl/lib/Net/CUPS.pm
trunk/libnet-cups-perl/lib/Net/CUPS/Destination.pm
trunk/libnet-cups-perl/lib/Net/CUPS/IPP.pm
trunk/libnet-cups-perl/lib/Net/CUPS/PPD.pm
trunk/libnet-cups-perl/typemap
Modified: trunk/libnet-cups-perl/CUPS.xs
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnet-cups-perl/CUPS.xs?rev=19715&op=diff
==============================================================================
--- trunk/libnet-cups-perl/CUPS.xs (original)
+++ trunk/libnet-cups-perl/CUPS.xs Thu May 8 19:57:08 2008
@@ -175,11 +175,262 @@
httpClose( http );
XSRETURN( 1 );
+void
+NETCUPS_getPPDMakes()
+ http_t *http; /* HTTP object */
+ ipp_t *request; /* IPP request object */
+ ipp_t *response; /* IPP response object */
+ ipp_attribute_t *attr; /* Current IPP attribute */
+
+ PPCODE:
+ SV* rv = NULL;
+ int count = 0;
+ cups_lang_t *language;
+ language = cupsLangDefault();
+ http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
+ request = ippNewRequest(CUPS_GET_PPDS);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
+ "attributes-charset", NULL, "utf-8");
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
+ "attributes-natural-language", NULL, language->language);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "requested-attributes", NULL, "ppd-make");
+
+ response = cupsDoRequest(http, request, "/");
+
+ if (response != NULL) {
+ attr = ippFindAttribute(response, "ppd-make", IPP_TAG_TEXT);
+ rv = sv_newmortal();
+ sv_setpv(rv, attr->values[0].string.text);
+ XPUSHs(rv);
+ count++;
+
+ while (attr != NULL) {
+ attr = ippFindNextAttribute(response, "ppd-make", IPP_TAG_TEXT);
+ if (attr == NULL) {
+ break;
+ }
+
+ rv = sv_newmortal();
+ sv_setpv(rv, attr->values[0].string.text);
+ XPUSHs(rv);
+ count++;
+ }
+
+ ippDelete(response);
+ httpClose(http);
+ }
+ else {
+ XSRETURN ( 0 );
+ }
+ XSRETURN( count );
+
+
+void
+NETCUPS_getAllPPDs ()
+ http_t *http; /* HTTP object */
+ ipp_t *request; /* IPP request object */
+ ipp_t *response; /* IPP response object */
+ ipp_attribute_t *attr; /* Current IPP attribute */
+
+ PPCODE:
+ SV* rv = NULL;
+ int count = 0;
+ cups_lang_t *language;
+ language = cupsLangDefault();
+ http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
+ request = ippNewRequest(CUPS_GET_PPDS);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
+ "attributes-charset", NULL, "utf-8");
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
+ "attributes-natural-language", NULL, language->language);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
+ "requested-attributes", NULL, "ppd-make-and-model");
+ response = cupsDoRequest(http, request, "/");
+
+ if (response != NULL) {
+ attr = ippFindAttribute(response,
+ "ppd-make-and-model",
+ IPP_TAG_TEXT);
+ rv = sv_newmortal();
+ sv_setpv(rv, attr->values[0].string.text);
+ XPUSHs(rv);
+ count++;
+ while (attr != NULL) {
+ attr = ippFindNextAttribute(response,
+ "ppd-make-and-model",
+ IPP_TAG_TEXT);
+ if (attr == NULL) {
+ break;
+ }
+ rv = sv_newmortal();
+ sv_setpv(rv, attr->values[0].string.text);
+ XPUSHs(rv);
+ count++;
+ }
+
+ ippDelete(response);
+ httpClose(http);
+ }
+ else {
+ XSRETURN ( 0 );
+ }
+ XSRETURN( count );
+
+void
+NETCUPS_deleteDestination( destination );
+ const char* destination;
+
+ PPCODE:
+ ipp_t *request;
+ http_t *http;
+ char uri[HTTP_MAX_URI];
+
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ cupsServer(), 0, "/printers/%s", destination);
+ http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
+ request = ippNewRequest(CUPS_DELETE_PRINTER);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
+ NULL, uri);
+ ippDelete(cupsDoRequest(http, request, "/admin/"));
+
+void
+NETCUPS_addDestination(name, location, printer_info, ppd_name, device_uri);
+ const char* name;
+ const char* location;
+ const char* printer_info;
+ const char* ppd_name;
+ const char* device_uri;
+
+ PPCODE:
+ http_t *http = NULL; /* HTTP object */
+ ipp_t *request = NULL; /* IPP request object */
+ char uri[HTTP_MAX_URI]; /* Job URI */
+
+ http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
+
+ request = ippNewRequest(CUPS_ADD_PRINTER);
+
+ httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL,
+ cupsServer(), 0, "/printers/%s", name);
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
+ NULL, uri);
+ ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-location",
+ NULL, location);
+ ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-info",
+ NULL, printer_info );
+ ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME, "ppd-name",
+ NULL, ppd_name);
+ strncpy(uri, device_uri, sizeof(uri));
+ ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_URI, "device-uri",
+ NULL, uri);
+ ippAddBoolean(request, IPP_TAG_PRINTER, "printer-is-accepting-jobs", 1);
+ ippAddInteger(request, IPP_TAG_PRINTER, IPP_TAG_ENUM, "printer-state",
+ IPP_PRINTER_IDLE);
+ ippDelete(cupsDoRequest(http, request, "/admin/"));
+
+void
+NETCUPS_getPPDFileName(ppdfilename);
+ const char* ppdfilename;
+
+ PPCODE:
+ http_t *http; /* HTTP object */
+ ipp_t *request; /* IPP request object */
+ ipp_t *response; /* IPP response object */
+ ipp_attribute_t *attr; /* Current IPP attribute */
+ int i = 0;
+ char* tmpppd;
+ char test[1024];
+ SV* rv = NULL;
+
+ http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption());
+
+ request = ippNewRequest(CUPS_GET_PPDS);
+
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
+ "attributes-charset", NULL, "utf-8");
+ ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE,
+ "attributes-natural-language", NULL, "en");
+
+ response = cupsDoRequest(http, request, "/");
+
+ if (response != NULL) {
+ attr = ippFindAttribute(response, "ppd-name", IPP_TAG_NAME );
+ while ((attr != NULL) && (i < 1)) {
+ tmpppd = attr->values[0].string.text;
+ attr = ippFindNextAttribute(response,
+ "ppd-make",
+ IPP_TAG_TEXT);
+ attr = ippFindNextAttribute(response,
+ "ppd-make-and-model",
+ IPP_TAG_TEXT);
+ if (strcmp(attr->values[0].string.text, ppdfilename) == 0 ) {
+ /* return tmpppd; */
+ strcpy(test, tmpppd);
+ break;
+ }
+ attr = ippFindNextAttribute(response, "ppd-name", IPP_TAG_NAME);
+ }
+ }
+ ippDelete(response);
+ httpClose(http);
+ rv = sv_newmortal();
+ sv_setpv( rv, test);
+ XPUSHs( rv );
+
MODULE = Net::CUPS PACKAGE = Net::CUPS::Destination
PROTOTYPES: DISABLE
INCLUDE: const-xs.inc
+
+void
+NETCUPS_getDeviceAttribute( device, attribute, attribute_type )
+ const char* device;
+ const char* attribute;
+ int attribute_type;
+
+ PPCODE:
+ http_t *http = NULL; /* HTTP object */
+ ipp_t *request = NULL; /* IPP request */
+ ipp_t *response = NULL; /* IPP response */
+ ipp_attribute_t *attr = NULL; /* IPP attribute */
+ SV* rv = NULL;
+ char *description = NULL;
+
+ http = httpConnectEncrypt( cupsServer(), ippPort(), cupsEncryption() );
+
+ if (http == NULL) {
+ perror ("Unable to connect to server");
+ /* return (1); */
+ }
+
+ request = ippNewRequest (CUPS_GET_PRINTERS);
+
+ if ((response = cupsDoRequest (http, request, "/")) != NULL) {
+ attr = ippFindNextAttribute(response, "printer-name", IPP_TAG_NAME);
+
+ while (attr != NULL) {
+ if (strcmp(attr->values[0].string.text, device) == 0) {
+ attr = ippFindNextAttribute( response,
+ attribute,
+ attribute_type);
+ rv = sv_newmortal();
+ sv_setpv( rv, attr->values[0].string.text);
+ XPUSHs( rv );
+ break;
+ }
+ attr = ippFindNextAttribute( response,
+ "printer-name",
+ IPP_TAG_NAME);
+ if (attr == NULL) {
+ break;
+ }
+ }
+ }
+ ippDelete( response );
+ httpClose( http );
+ XSRETURN( 1 );
int
NETCUPS_addOption( self, name, value )
@@ -699,7 +950,6 @@
XPUSHs( rv );
XSRETURN( 1 );
-
int
NETCUPS_setPort( port )
int port;
Modified: trunk/libnet-cups-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnet-cups-perl/Changes?rev=19715&op=diff
==============================================================================
--- trunk/libnet-cups-perl/Changes (original)
+++ trunk/libnet-cups-perl/Changes Thu May 8 19:57:08 2008
@@ -1,4 +1,13 @@
Revision history for Perl extension Net::CUPS.
+
+0.56 Wed Mar 26 19:35:05 2008
+ + Most of the changes below were added by Mark Gannon <mark at truenorth.nu>
+ - Added methods to Net::CUPS::Destination to get Uri, Location and
+ Description.
+ - Added methods to Net::CUPS to get PPDs.
+ - Added methods to Net::CUPS to create and delete destinations.
+ - Corrected the issue of creating bastardized objects as reported by
+ Gunnar Wolf.
0.55 Tue Oct 09 20:46:58 2007
- Fixed a segfault in getJobs [Sven-Haegar Koch]
Modified: trunk/libnet-cups-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnet-cups-perl/README?rev=19715&op=diff
==============================================================================
--- trunk/libnet-cups-perl/README (original)
+++ trunk/libnet-cups-perl/README Thu May 8 19:57:08 2008
@@ -41,6 +41,9 @@
Sven-Haegar Koch <haegar at sdinet.de> has graciously provided patches
to fix issues and make improvements to Net::CUPS.
+Mark Gannon <mark at truenorth.nu> has provided patches to add quite a bit of
+additional functionality to Net::CUPS.
+
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
Modified: trunk/libnet-cups-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnet-cups-perl/debian/changelog?rev=19715&op=diff
==============================================================================
--- trunk/libnet-cups-perl/debian/changelog (original)
+++ trunk/libnet-cups-perl/debian/changelog Thu May 8 19:57:08 2008
@@ -1,3 +1,9 @@
+libnet-cups-perl (0.56-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+
+ -- gregor herrmann <gregoa at debian.org> Thu, 08 May 2008 21:55:20 +0200
+
libnet-cups-perl (0.55-3) unstable; urgency=medium
* Set build dependency on libcupsys2-dev to >= 1.3.7-3; fixes
Modified: trunk/libnet-cups-perl/lib/Net/CUPS.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnet-cups-perl/lib/Net/CUPS.pm?rev=19715&op=diff
==============================================================================
--- trunk/libnet-cups-perl/lib/Net/CUPS.pm (original)
+++ trunk/libnet-cups-perl/lib/Net/CUPS.pm Thu May 8 19:57:08 2008
@@ -959,7 +959,7 @@
PPD_VERSION
);
-our $VERSION = '0.55';
+our $VERSION = '0.56';
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
@@ -987,6 +987,10 @@
require XSLoader;
XSLoader::load('Net::CUPS', $VERSION);
+use Net::CUPS::PPD;
+use Net::CUPS::IPP;
+use Net::CUPS::Destination;
+
##==================================================================##
## Constructors ##
##==================================================================##
@@ -1131,6 +1135,60 @@
return;
}
+##----------------------------------------------##
+## getPPDMakes ##
+##----------------------------------------------##
+sub getPPDMakes
+{
+ my $self = shift;
+
+ return( NETCUPS_getPPDMakes() );
+}
+
+
+##----------------------------------------------##
+## getAllPPs ##
+##----------------------------------------------##
+sub getAllPPDs
+{
+ my $self = shift;
+
+ return( NETCUPS_getAllPPDs() );
+}
+
+##----------------------------------------------##
+## deleteDestination ##
+##----------------------------------------------##
+sub deleteDestination
+{
+ my( $self, $destination ) = @_;
+ NETCUPS_deleteDestination( $destination );
+ return;
+}
+
+##----------------------------------------------##
+## getPPDFileName ##
+##----------------------------------------------##
+sub getPPDFileName
+{
+ my( $self, $ppdname) = @_;
+ return( NETCUPS_getPPDFileName( $ppdname ) );
+}
+
+##----------------------------------------------##
+## addDestination ##
+##----------------------------------------------##
+sub addDestination
+{
+ my( $self, $name, $location, $printer_info, $ppd_name, $device_uri) = @_;
+
+ return( NETCUPS_addDestination( $name,
+ $location,
+ $printer_info,
+ $ppd_name,
+ $device_uri ) );
+}
+
##==================================================================##
## End of Code ##
##==================================================================##
@@ -1178,17 +1236,39 @@
=item B<getPassword>
-my $password = $cups->getPassword( $prompt )
+my $password = $cups->getPassword( $prompt );
Method to retrieve the password from the user via the password
callback.
=item B<getPPD>
-my $ppd = $cups->getPPD( $name )
+my $ppd = $cups->getPPD( $name );
Returns a Net::CUPS::PPD object for the default printer or for the
specified printer or class.
+
+=item B<getPPDMakes>
+
+my $makes = $cups->getPPDMakes();
+
+Returns an arrary of scalers holding the names of all the makers (e.g. HP or Lexmark)
+of PPD files installed on the CUPS server
+
+=item B<getAllPPDs>
+
+my $ppds = $cups->getAllPPDs();
+
+Returns an array of scalers with the maker and model of all the PPDs
+installed on the CUPS server
+
+=item B<getPPDFileName>
+
+$cups->getPPDFileName($ppd_name_and_make);
+
+Returns the file name of the PPD specified by the name and make as found in the array
+returned by getAllPPDs. The file name is used by addDestination and is relative
+to where the CUPS server is instructed to look (e.g /usr/share/ppd).
=item B<getServer>
@@ -1230,6 +1310,20 @@
A method to change the username associated with CUPS interaction.
+=item B<deleteDestination>
+
+$cups->deleteDestination( $destination_name );
+
+A method to delete an existing destination
+
+=item B<addDestination>
+
+$cups->addDestination( $name, $location, $printer_info, $ppd_name, $device_uri)
+A method to create a new destination. The $ppd_name variable should be
+the one returned for that printer by the getPPDFileName method. It will
+be relative to where the CUPS server is configured to look for PPD
+files (e.g. /usr/share/ppd).
+
=back
=head1 SEE ALSO
@@ -1248,6 +1342,9 @@
=head1 ACKNOWLEDGEMENTS
Aike Reyer <aike at users.sourceforge.net> supplied the password handling code.
+
+Mark Gannon <mark at truenorth.nu> supplied the code for PPD acquisition,
+destination creation and destination deletion.
=head1 COPYRIGHT AND LICENSE
Modified: trunk/libnet-cups-perl/lib/Net/CUPS/Destination.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnet-cups-perl/lib/Net/CUPS/Destination.pm?rev=19715&op=diff
==============================================================================
--- trunk/libnet-cups-perl/lib/Net/CUPS/Destination.pm (original)
+++ trunk/libnet-cups-perl/lib/Net/CUPS/Destination.pm Thu May 8 19:57:08 2008
@@ -961,7 +961,7 @@
PPD_VERSION
);
-our $VERSION = '0.55';
+our $VERSION = '0.56';
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
@@ -1048,6 +1048,19 @@
}
##----------------------------------------------##
+## getDescription ##
+##----------------------------------------------##
+sub getDescription
+{
+ my $self = shift;
+
+ return( NETCUPS_getDeviceAttribute( $self->getName(),
+ "printer-info",
+ IPP_TAG_TEXT ) );
+}
+
+
+##----------------------------------------------##
## getError ##
##----------------------------------------------##
sub getError
@@ -1082,6 +1095,18 @@
}
##----------------------------------------------##
+## getLocation ##
+##----------------------------------------------##
+sub getLocation
+{
+ my $self = shift;
+
+ return( NETCUPS_getDeviceAttribute( $self->getName(),
+ "printer-location",
+ IPP_TAG_TEXT ) );
+}
+
+##----------------------------------------------##
## getName ##
##----------------------------------------------##
sub getName
@@ -1109,6 +1134,18 @@
my $self = shift;
return( NETCUPS_getDestinationOptions( $self ) );
+}
+
+##----------------------------------------------##
+## getUri ##
+##----------------------------------------------##
+sub getUri
+{
+ my $self = shift;
+
+ return( NETCUPS_getDeviceAttribute( $self->getName(),
+ "device-uri",
+ IPP_TAG_URI ) );
}
##----------------------------------------------##
@@ -1174,6 +1211,12 @@
Method to chancel a job sent to this destination.
+=item B<getDescription>
+
+my $description = $dest->getDescription();
+
+Provides the description string associated with this printer.
+
=item B<getError>
my $error = $dest->getError();
@@ -1200,6 +1243,10 @@
all users and 1 is just for the selected user. $scope is -1 for all
jobs, 0 for active jobs and 1 for completed jobs.
+=item B<getLocation>
+
+Returns the location string for this destination.
+
=item B<getOptionValue>
my $value = $dest->getOptionValue( $name );
@@ -1221,6 +1268,13 @@
what you will use to send a file to handled by the destination. You
must provide the name of the file and a title for the job.
+=item B<getUri>
+
+my $uri = $dest->getUri();
+
+This function returns the device URI of a destination.
+For example, a network printer might appear as socket://192.168.1.1
+
=back
=head1 SEE ALSO
Modified: trunk/libnet-cups-perl/lib/Net/CUPS/IPP.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnet-cups-perl/lib/Net/CUPS/IPP.pm?rev=19715&op=diff
==============================================================================
--- trunk/libnet-cups-perl/lib/Net/CUPS/IPP.pm (original)
+++ trunk/libnet-cups-perl/lib/Net/CUPS/IPP.pm Thu May 8 19:57:08 2008
@@ -961,7 +961,7 @@
PPD_VERSION
);
-our $VERSION = '0.55';
+our $VERSION = '0.56';
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
Modified: trunk/libnet-cups-perl/lib/Net/CUPS/PPD.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnet-cups-perl/lib/Net/CUPS/PPD.pm?rev=19715&op=diff
==============================================================================
--- trunk/libnet-cups-perl/lib/Net/CUPS/PPD.pm (original)
+++ trunk/libnet-cups-perl/lib/Net/CUPS/PPD.pm Thu May 8 19:57:08 2008
@@ -964,7 +964,7 @@
PPD_VERSION
);
-our $VERSION = '0.55';
+our $VERSION = '0.56';
sub AUTOLOAD {
# This AUTOLOAD is used to 'autoload' constants from the constant()
Modified: trunk/libnet-cups-perl/typemap
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libnet-cups-perl/typemap?rev=19715&op=diff
==============================================================================
--- trunk/libnet-cups-perl/typemap (original)
+++ trunk/libnet-cups-perl/typemap Thu May 8 19:57:08 2008
@@ -8,3 +8,4 @@
size_t * T_IV
ipp_tag_e T_IV
ipp_tag_t T_IV
+const char * T_PV
More information about the Pkg-perl-cvs-commits
mailing list