/****************************************************************************
Get a printer queue listing.
+ set queue = NULL and status = NULL if you just want to update the cache
****************************************************************************/
int print_queue_status(int snum,
struct traverse_count_struct tsc;
fstring keystr;
TDB_DATA data, key;
- const char *printername = lp_const_servicename(snum);
- struct tdb_print_db *pdb = get_print_db_byname(printername);
-
- *queue = NULL;
-
- if (!pdb)
- return 0;
+ const char *printername;
+ struct tdb_print_db *pdb;
/* make sure the database is up to date */
+
if (print_cache_expired(snum))
print_queue_update(snum);
+ /* return if we are done */
+
+ if ( !queue || !status )
+ return 0;
+
+ *queue = NULL;
+ printername = lp_const_servicename(snum);
+ pdb = get_print_db_byname(printername);
+
+ if (!pdb)
+ return 0;
+
/*
* Fetch the queue status. We must do this first, as there may
* be no jobs in the queue.
uint32 printerlocal;
SPOOL_NOTIFY_OPTION *option;
POLICY_HND client_hnd;
- uint32 client_connected;
+ BOOL client_connected;
uint32 change;
+ /* are we in a FindNextPrinterChangeNotify() call? */
+ BOOL fnpcn;
} notify;
struct {
fstring machine;
/* devmode sent in the OpenPrinter() call */
NT_DEVICEMODE *nt_devmode;
+
} Printer_entry;
static Printer_entry *printers_list;
SPOOL_NOTIFY_INFO_DATA *data;
uint32 data_len = 0;
uint32 id;
- int i;
+ int i, event_index;
/* Is there notification on this handle? */
data = talloc( mem_ctx, msg_group->num_msgs*sizeof(SPOOL_NOTIFY_INFO_DATA) );
ZERO_STRUCTP(data);
+ event_index = 0;
+
/* build the array of change notifications */
for ( i=0; i<msg_group->num_msgs; i++ )
switch(msg->type) {
case PRINTER_NOTIFY_TYPE:
- if ( !printer_notify_table[msg->field].fn )
- goto done;
- printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx);
-
+ if ( printer_notify_table[msg->field].fn )
+ printer_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx);
break;
case JOB_NOTIFY_TYPE:
- if ( !job_notify_table[msg->field].fn )
- goto done;
- job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx);
-
+ if ( job_notify_table[msg->field].fn )
+ job_notify_table[msg->field].fn(msg, &data[data_len], mem_ctx);
break;
default:
/* all done */
}
+/********************************************************************
+ Update the cahce for all printq's with a registered client
+ connection
+ ********************************************************************/
+
+void update_monitored_printq_cache( void )
+{
+ Printer_entry *printer = printers_list;
+ int snum;
+
+ /* loop through all printers and update the cache where
+ client_connected == True */
+ while ( printer )
+ {
+ if ( (printer->printer_type == PRINTER_HANDLE_IS_PRINTER)
+ && printer->notify.client_connected )
+ {
+ snum = print_queue_snum_dos(printer->dev.handlename);
+ print_queue_status( snum, NULL, NULL );
+ }
+
+ printer = printer->next;
+ }
+
+ return;
+}
/********************************************************************
Send a message to ourself about new driver being installed
so we can upgrade the information for each printer bound to this
/* We need to keep track of the change value to send back in
RRPCN replies otherwise our updates are ignored. */
+ Printer->notify.fnpcn = True;
+
if (Printer->notify.client_connected) {
DEBUG(10,("_spoolss_rfnpcnex: Saving change value in request [%x]\n", q_u->change));
Printer->notify.change = q_u->change;
break;
}
- done:
+ Printer->notify.fnpcn = False;
+
+done:
return result;
}