svn commit: samba r2476 - branches/SAMBA_3_0/source/rpc_parse branches/SAMBA_3_0/source/utils trunk/source/rpc_parse trunk/source/utils

gd at samba.org gd at samba.org
Tue Sep 21 13:31:58 GMT 2004


Author: gd
Date: 2004-09-21 13:31:57 +0000 (Tue, 21 Sep 2004)
New Revision: 2476

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/&rev=2476&nolog=1

Log:
now that PRINTER_ATTRIBUTE_PUBLISHED does not get reset anymore, migrate
the publishing-state for migrated printers as well. 

Therefor added client-side-support for setprinter level 7.

Next will be a "net rpc printer publish"-command (just for completeness).

Guenther


Modified:
   branches/SAMBA_3_0/source/rpc_parse/parse_spoolss.c
   branches/SAMBA_3_0/source/utils/net_rpc_printer.c
   trunk/source/rpc_parse/parse_spoolss.c
   trunk/source/utils/net_rpc_printer.c


Changeset:
Modified: branches/SAMBA_3_0/source/rpc_parse/parse_spoolss.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_parse/parse_spoolss.c	2004-09-21 13:04:35 UTC (rev 2475)
+++ branches/SAMBA_3_0/source/rpc_parse/parse_spoolss.c	2004-09-21 13:31:57 UTC (rev 2476)
@@ -1077,6 +1077,32 @@
 }
 
 /*******************************************************************
+create a SPOOL_PRINTER_INFO_7 struct from a PRINTER_INFO_7 struct
+*******************************************************************/
+
+BOOL make_spoolss_printer_info_7(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7 **spool_info7, 
+				PRINTER_INFO_7 *info)
+{
+
+	SPOOL_PRINTER_INFO_LEVEL_7 *inf;
+
+	/* allocate the necessary memory */
+	if (!(inf=(SPOOL_PRINTER_INFO_LEVEL_7*)talloc(mem_ctx, sizeof(SPOOL_PRINTER_INFO_LEVEL_7)))) {
+		DEBUG(0,("make_spoolss_printer_info_7: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_7 struct!\n"));
+		return False;
+	}
+
+	inf->guid_ptr	 	= (info->guid.buffer!=NULL)?1:0;
+	inf->action		= info->action;
+	init_unistr2_from_unistr(&inf->guid,	 	&info->guid);
+
+	*spool_info7 = inf;
+
+	return True;
+}
+
+
+/*******************************************************************
  * read a structure.
  * called from spoolss_q_open_printer_ex (srv_spoolss.c)
  ********************************************************************/
@@ -4149,6 +4175,10 @@
 		q_u->secdesc_ctr->sec = secdesc;
 
 		break;
+	case 7:
+		make_spoolss_printer_info_7 (mem_ctx, &q_u->info.info_7, info->printers_7);
+		break;
+
 	default: 
 		DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level));
 			break;

Modified: branches/SAMBA_3_0/source/utils/net_rpc_printer.c
===================================================================
--- branches/SAMBA_3_0/source/utils/net_rpc_printer.c	2004-09-21 13:04:35 UTC (rev 2475)
+++ branches/SAMBA_3_0/source/utils/net_rpc_printer.c	2004-09-21 13:31:57 UTC (rev 2476)
@@ -2011,7 +2011,7 @@
 	BOOL got_hnd_dst = False;
 	BOOL got_dst_spoolss_pipe = False;
 	POLICY_HND hnd_src, hnd_dst;
-	PRINTER_INFO_CTR ctr_enum, ctr_dst;
+	PRINTER_INFO_CTR ctr_enum, ctr_dst, ctr_dst_publish;
 	REGVAL_CTR reg_ctr;
 	struct cli_state *cli_dst = NULL;
 	char *devicename = NULL, *unc_name = NULL, *url = NULL;
@@ -2095,10 +2095,19 @@
 		   is correctly installed (incl. driver ???) */
 		init_unistr( &ctr_dst.printers_2->portname, SAMBA_PRINTER_PORT_NAME);
 
-		/* check if printer is published -> no publish-migration for the moment */
+		/* check if printer is published */ 
 		if (ctr_enum.printers_2[i].attributes & PRINTER_ATTRIBUTE_PUBLISHED) {
-			printf("printer on originating server was published, ignoring that\n");
-			ctr_dst.printers_2->attributes = PRINTER_ATTRIBUTE_SAMBA;
+
+			/* check for existing dst printer */
+			if (!net_spoolss_getprinter(cli_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish))
+				goto done;
+
+			ctr_dst_publish.printers_7->action = SPOOL_DS_PUBLISH;
+
+			/* ignore False from setprinter due to WERR_IO_PENDING */
+	 		net_spoolss_setprinter(cli_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish);
+
+			DEBUG(3,("republished printer\n"));
 		}
 
 		/* copy devmode (info level 2) */

Modified: trunk/source/rpc_parse/parse_spoolss.c
===================================================================
--- trunk/source/rpc_parse/parse_spoolss.c	2004-09-21 13:04:35 UTC (rev 2475)
+++ trunk/source/rpc_parse/parse_spoolss.c	2004-09-21 13:31:57 UTC (rev 2476)
@@ -1077,6 +1077,32 @@
 }
 
 /*******************************************************************
+create a SPOOL_PRINTER_INFO_7 struct from a PRINTER_INFO_7 struct
+*******************************************************************/
+
+BOOL make_spoolss_printer_info_7(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7 **spool_info7, 
+				PRINTER_INFO_7 *info)
+{
+
+	SPOOL_PRINTER_INFO_LEVEL_7 *inf;
+
+	/* allocate the necessary memory */
+	if (!(inf=(SPOOL_PRINTER_INFO_LEVEL_7*)talloc(mem_ctx, sizeof(SPOOL_PRINTER_INFO_LEVEL_7)))) {
+		DEBUG(0,("make_spoolss_printer_info_7: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_7 struct!\n"));
+		return False;
+	}
+
+	inf->guid_ptr	 	= (info->guid.buffer!=NULL)?1:0;
+	inf->action		= info->action;
+	init_unistr2_from_unistr(&inf->guid,	 	&info->guid);
+
+	*spool_info7 = inf;
+
+	return True;
+}
+
+
+/*******************************************************************
  * read a structure.
  * called from spoolss_q_open_printer_ex (srv_spoolss.c)
  ********************************************************************/
@@ -4149,6 +4175,10 @@
 		q_u->secdesc_ctr->sec = secdesc;
 
 		break;
+	case 7:
+		make_spoolss_printer_info_7 (mem_ctx, &q_u->info.info_7, info->printers_7);
+		break;
+
 	default: 
 		DEBUG(0,("make_spoolss_q_setprinter: Unknown info level [%d]\n", level));
 			break;

Modified: trunk/source/utils/net_rpc_printer.c
===================================================================
--- trunk/source/utils/net_rpc_printer.c	2004-09-21 13:04:35 UTC (rev 2475)
+++ trunk/source/utils/net_rpc_printer.c	2004-09-21 13:31:57 UTC (rev 2476)
@@ -2011,7 +2011,7 @@
 	BOOL got_hnd_dst = False;
 	BOOL got_dst_spoolss_pipe = False;
 	POLICY_HND hnd_src, hnd_dst;
-	PRINTER_INFO_CTR ctr_enum, ctr_dst;
+	PRINTER_INFO_CTR ctr_enum, ctr_dst, ctr_dst_publish;
 	REGVAL_CTR reg_ctr;
 	struct cli_state *cli_dst = NULL;
 	char *devicename = NULL, *unc_name = NULL, *url = NULL;
@@ -2095,10 +2095,19 @@
 		   is correctly installed (incl. driver ???) */
 		init_unistr( &ctr_dst.printers_2->portname, SAMBA_PRINTER_PORT_NAME);
 
-		/* check if printer is published -> no publish-migration for the moment */
+		/* check if printer is published */ 
 		if (ctr_enum.printers_2[i].attributes & PRINTER_ATTRIBUTE_PUBLISHED) {
-			printf("printer on originating server was published, ignoring that\n");
-			ctr_dst.printers_2->attributes = PRINTER_ATTRIBUTE_SAMBA;
+
+			/* check for existing dst printer */
+			if (!net_spoolss_getprinter(cli_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish))
+				goto done;
+
+			ctr_dst_publish.printers_7->action = SPOOL_DS_PUBLISH;
+
+			/* ignore False from setprinter due to WERR_IO_PENDING */
+	 		net_spoolss_setprinter(cli_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish);
+
+			DEBUG(3,("republished printer\n"));
 		}
 
 		/* copy devmode (info level 2) */



More information about the samba-cvs mailing list