source: trunk/samba-3.0.25pre1/source/rpc_client/cli_spoolss_notify.c@ 1

Last change on this file since 1 was 1, checked in by Paul Smedley, 19 years ago

Initial code import

File size: 6.3 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
4
5 Copyright (C) Gerald Carter 2001-2002,
6 Copyright (C) Tim Potter 2000-2002,
7 Copyright (C) Andrew Tridgell 1994-2000,
8 Copyright (C) Jean-Francois Micouleau 1999-2000.
9 Copyright (C) Jeremy Allison 2005.
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24*/
25
26#include "includes.h"
27
28/*
29 * SPOOLSS Client RPC's used by servers as the notification
30 * back channel.
31 */
32
33/* Send a ReplyOpenPrinter request. This rpc is made by the printer
34 server to the printer client in response to a rffpcnex request.
35 The rrfpcnex request names a printer and a handle (the printerlocal
36 value) and this rpc establishes a back-channel over which printer
37 notifications are performed. */
38
39WERROR rpccli_spoolss_reply_open_printer(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
40 const char *printer, uint32 printerlocal, uint32 type,
41 POLICY_HND *handle)
42{
43 prs_struct qbuf, rbuf;
44 SPOOL_Q_REPLYOPENPRINTER q;
45 SPOOL_R_REPLYOPENPRINTER r;
46 WERROR result = W_ERROR(ERRgeneral);
47
48 /* Initialise input parameters */
49
50 make_spoolss_q_replyopenprinter(&q, printer, printerlocal, type);
51
52 /* Marshall data and send request */
53
54 CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_REPLYOPENPRINTER,
55 q, r,
56 qbuf, rbuf,
57 spoolss_io_q_replyopenprinter,
58 spoolss_io_r_replyopenprinter,
59 WERR_GENERAL_FAILURE );
60
61 /* Return result */
62
63 memcpy(handle, &r.handle, sizeof(r.handle));
64 result = r.status;
65
66 return result;
67}
68
69/* Close a back-channel notification connection */
70
71WERROR rpccli_spoolss_reply_close_printer(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
72 POLICY_HND *handle)
73{
74 prs_struct qbuf, rbuf;
75 SPOOL_Q_REPLYCLOSEPRINTER q;
76 SPOOL_R_REPLYCLOSEPRINTER r;
77 WERROR result = W_ERROR(ERRgeneral);
78
79 /* Initialise input parameters */
80
81 make_spoolss_q_reply_closeprinter(&q, handle);
82
83 /* Marshall data and send request */
84
85 CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_REPLYCLOSEPRINTER,
86 q, r,
87 qbuf, rbuf,
88 spoolss_io_q_replycloseprinter,
89 spoolss_io_r_replycloseprinter,
90 WERR_GENERAL_FAILURE );
91
92 /* Return result */
93
94 result = r.status;
95 return result;
96}
97
98/*********************************************************************
99 This SPOOLSS_ROUTERREPLYPRINTER function is used to send a change
100 notification event when the registration **did not** use
101 SPOOL_NOTIFY_OPTION_TYPE structure to specify the events to monitor.
102 Also see cli_spolss_reply_rrpcn()
103 *********************************************************************/
104
105WERROR rpccli_spoolss_routerreplyprinter(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
106 POLICY_HND *pol, uint32 condition, uint32 change_id)
107{
108 prs_struct qbuf, rbuf;
109 SPOOL_Q_ROUTERREPLYPRINTER q;
110 SPOOL_R_ROUTERREPLYPRINTER r;
111 WERROR result = W_ERROR(ERRgeneral);
112
113 /* Initialise input parameters */
114
115 make_spoolss_q_routerreplyprinter(&q, pol, condition, change_id);
116
117 /* Marshall data and send request */
118
119 CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_ROUTERREPLYPRINTER,
120 q, r,
121 qbuf, rbuf,
122 spoolss_io_q_routerreplyprinter,
123 spoolss_io_r_routerreplyprinter,
124 WERR_GENERAL_FAILURE );
125
126 /* Return output parameters */
127
128 result = r.status;
129 return result;
130}
131
132/*********************************************************************
133 This SPOOLSS_REPLY_RRPCN function is used to send a change
134 notification event when the registration **did** use
135 SPOOL_NOTIFY_OPTION_TYPE structure to specify the events to monitor
136 Also see cli_spoolss_routereplyprinter()
137 *********************************************************************/
138
139WERROR rpccli_spoolss_rrpcn(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
140 POLICY_HND *pol, uint32 notify_data_len,
141 SPOOL_NOTIFY_INFO_DATA *notify_data,
142 uint32 change_low, uint32 change_high)
143{
144 prs_struct qbuf, rbuf;
145 SPOOL_Q_REPLY_RRPCN q;
146 SPOOL_R_REPLY_RRPCN r;
147 WERROR result = W_ERROR(ERRgeneral);
148 SPOOL_NOTIFY_INFO notify_info;
149
150 ZERO_STRUCT(q);
151 ZERO_STRUCT(r);
152
153 ZERO_STRUCT(notify_info);
154
155 /* Initialise input parameters */
156
157 notify_info.version = 0x2;
158 notify_info.flags = 0x00020000; /* ?? */
159 notify_info.count = notify_data_len;
160 notify_info.data = notify_data;
161
162 /* create and send a MSRPC command with api */
163 /* store the parameters */
164
165 make_spoolss_q_reply_rrpcn(&q, pol, change_low, change_high,
166 &notify_info);
167
168 /* Marshall data and send request */
169
170 CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_RRPCN,
171 q, r,
172 qbuf, rbuf,
173 spoolss_io_q_reply_rrpcn,
174 spoolss_io_r_reply_rrpcn,
175 WERR_GENERAL_FAILURE );
176
177 if (r.unknown0 == 0x00080000)
178 DEBUG(8,("cli_spoolss_reply_rrpcn: I think the spooler resonded that the notification was ignored.\n"));
179 else if ( r.unknown0 != 0x0 )
180 DEBUG(8,("cli_spoolss_reply_rrpcn: unknown0 is non-zero [0x%x]\n", r.unknown0));
181
182 result = r.status;
183 return result;
184}
185
186/*********************************************************************
187 *********************************************************************/
188
189WERROR rpccli_spoolss_rffpcnex(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
190 POLICY_HND *pol, uint32 flags, uint32 options,
191 const char *localmachine, uint32 printerlocal,
192 SPOOL_NOTIFY_OPTION *option)
193{
194 prs_struct qbuf, rbuf;
195 SPOOL_Q_RFFPCNEX q;
196 SPOOL_R_RFFPCNEX r;
197 WERROR result = W_ERROR(ERRgeneral);
198
199 ZERO_STRUCT(q);
200 ZERO_STRUCT(r);
201
202 /* Initialise input parameters */
203
204 make_spoolss_q_rffpcnex(
205 &q, pol, flags, options, localmachine, printerlocal,
206 option);
207
208 /* Marshall data and send request */
209
210 CLI_DO_RPC_WERR( cli, mem_ctx, PI_SPOOLSS, SPOOLSS_RFFPCNEX,
211 q, r,
212 qbuf, rbuf,
213 spoolss_io_q_rffpcnex,
214 spoolss_io_r_rffpcnex,
215 WERR_GENERAL_FAILURE );
216
217 result = r.status;
218 return result;
219}
Note: See TracBrowser for help on using the repository browser.