Changeset 740 for vendor/current/source3/printing/notify.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/printing/notify.c
r414 r740 22 22 #include "includes.h" 23 23 #include "printing.h" 24 #include "../librpc/gen_ndr/spoolss.h" 25 #include "nt_printing.h" 26 #include "printing/notify.h" 27 #include "messages.h" 28 #include "util_tdb.h" 24 29 25 30 static TALLOC_CTX *send_ctx; … … 228 233 void *private_data) 229 234 { 235 struct messaging_context *msg_ctx = talloc_get_type_abort( 236 private_data, struct messaging_context); 230 237 /* Remove this timed event handler. */ 231 238 TALLOC_FREE(notify_event); 232 239 233 240 change_to_root_user(); 234 print_notify_send_messages( smbd_messaging_context(), 0);241 print_notify_send_messages(msg_ctx, 0); 235 242 } 236 243 … … 263 270 *******************************************************************/ 264 271 265 static void send_spoolss_notify2_msg(SPOOLSS_NOTIFY_MSG *msg) 272 static void send_spoolss_notify2_msg(struct tevent_context *ev, 273 struct messaging_context *msg_ctx, 274 SPOOLSS_NOTIFY_MSG *msg) 266 275 { 267 276 struct notify_queue *pnqueue, *tmp_ptr; … … 326 335 num_messages++; 327 336 328 if ((notify_event == NULL) && ( smbd_event_context()!= NULL)) {337 if ((notify_event == NULL) && (ev != NULL)) { 329 338 /* Add an event for 1 second's time to send this queue. */ 330 notify_event = tevent_add_timer(smbd_event_context(), NULL, 331 timeval_current_ofs(1,0), 332 print_notify_event_send_messages, NULL); 333 } 334 335 } 336 337 static void send_notify_field_values(const char *sharename, uint32 type, 339 notify_event = tevent_add_timer( 340 ev, NULL, timeval_current_ofs(1,0), 341 print_notify_event_send_messages, msg_ctx); 342 } 343 344 } 345 346 static void send_notify_field_values(struct tevent_context *ev, 347 struct messaging_context *msg_ctx, 348 const char *sharename, uint32 type, 338 349 uint32 field, uint32 id, uint32 value1, 339 350 uint32 value2, uint32 flags) … … 361 372 msg->flags = flags; 362 373 363 send_spoolss_notify2_msg(msg); 364 } 365 366 static void send_notify_field_buffer(const char *sharename, uint32 type, 374 send_spoolss_notify2_msg(ev, msg_ctx, msg); 375 } 376 377 static void send_notify_field_buffer(struct tevent_context *ev, 378 struct messaging_context *msg_ctx, 379 const char *sharename, uint32 type, 367 380 uint32 field, uint32 id, uint32 len, 368 381 const char *buffer) … … 389 402 msg->notify.data = CONST_DISCARD(char *,buffer); 390 403 391 send_spoolss_notify2_msg( msg);404 send_spoolss_notify2_msg(ev, msg_ctx, msg); 392 405 } 393 406 394 407 /* Send a message that the printer status has changed */ 395 408 396 void notify_printer_status_byname(const char *sharename, uint32 status) 409 void notify_printer_status_byname(struct tevent_context *ev, 410 struct messaging_context *msg_ctx, 411 const char *sharename, uint32 status) 397 412 { 398 413 /* Printer status stored in value1 */ … … 400 415 int snum = print_queue_snum(sharename); 401 416 402 send_notify_field_values( sharename, PRINTER_NOTIFY_TYPE,417 send_notify_field_values(ev, msg_ctx, sharename, PRINTER_NOTIFY_TYPE, 403 418 PRINTER_NOTIFY_FIELD_STATUS, snum, 404 419 status, 0, 0); 405 420 } 406 421 407 void notify_printer_status(int snum, uint32 status) 408 { 409 const char *sharename = SERVICE(snum); 422 void notify_printer_status(struct tevent_context *ev, 423 struct messaging_context *msg_ctx, 424 int snum, uint32 status) 425 { 426 const char *sharename = lp_servicename(snum); 410 427 411 428 if (sharename) 412 notify_printer_status_byname(sharename, status); 413 } 414 415 void notify_job_status_byname(const char *sharename, uint32 jobid, uint32 status, 429 notify_printer_status_byname(ev, msg_ctx, sharename, status); 430 } 431 432 void notify_job_status_byname(struct tevent_context *ev, 433 struct messaging_context *msg_ctx, 434 const char *sharename, uint32 jobid, 435 uint32 status, 416 436 uint32 flags) 417 437 { 418 438 /* Job id stored in id field, status in value1 */ 419 439 420 send_notify_field_values(sharename, JOB_NOTIFY_TYPE, 440 send_notify_field_values(ev, msg_ctx, 441 sharename, JOB_NOTIFY_TYPE, 421 442 JOB_NOTIFY_FIELD_STATUS, jobid, 422 443 status, 0, flags); 423 444 } 424 445 425 void notify_job_status(const char *sharename, uint32 jobid, uint32 status) 426 { 427 notify_job_status_byname(sharename, jobid, status, 0); 428 } 429 430 void notify_job_total_bytes(const char *sharename, uint32 jobid, 446 void notify_job_status(struct tevent_context *ev, 447 struct messaging_context *msg_ctx, 448 const char *sharename, uint32 jobid, uint32 status) 449 { 450 notify_job_status_byname(ev, msg_ctx, sharename, jobid, status, 0); 451 } 452 453 void notify_job_total_bytes(struct tevent_context *ev, 454 struct messaging_context *msg_ctx, 455 const char *sharename, uint32 jobid, 431 456 uint32 size) 432 457 { 433 458 /* Job id stored in id field, status in value1 */ 434 459 435 send_notify_field_values(sharename, JOB_NOTIFY_TYPE, 460 send_notify_field_values(ev, msg_ctx, 461 sharename, JOB_NOTIFY_TYPE, 436 462 JOB_NOTIFY_FIELD_TOTAL_BYTES, jobid, 437 463 size, 0, 0); 438 464 } 439 465 440 void notify_job_total_pages(const char *sharename, uint32 jobid, 466 void notify_job_total_pages(struct tevent_context *ev, 467 struct messaging_context *msg_ctx, 468 const char *sharename, uint32 jobid, 441 469 uint32 pages) 442 470 { 443 471 /* Job id stored in id field, status in value1 */ 444 472 445 send_notify_field_values(sharename, JOB_NOTIFY_TYPE, 473 send_notify_field_values(ev, msg_ctx, 474 sharename, JOB_NOTIFY_TYPE, 446 475 JOB_NOTIFY_FIELD_TOTAL_PAGES, jobid, 447 476 pages, 0, 0); 448 477 } 449 478 450 void notify_job_username(const char *sharename, uint32 jobid, char *name) 451 { 452 send_notify_field_buffer( 479 void notify_job_username(struct tevent_context *ev, 480 struct messaging_context *msg_ctx, 481 const char *sharename, uint32 jobid, char *name) 482 { 483 send_notify_field_buffer( 484 ev, msg_ctx, 453 485 sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_FIELD_USER_NAME, 454 486 jobid, strlen(name) + 1, name); 455 487 } 456 488 457 void notify_job_name(const char *sharename, uint32 jobid, char *name) 458 { 459 send_notify_field_buffer( 489 void notify_job_name(struct tevent_context *ev, 490 struct messaging_context *msg_ctx, 491 const char *sharename, uint32 jobid, char *name) 492 { 493 send_notify_field_buffer( 494 ev, msg_ctx, 460 495 sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_FIELD_DOCUMENT, 461 496 jobid, strlen(name) + 1, name); 462 497 } 463 498 464 void notify_job_submitted(const char *sharename, uint32 jobid, 499 void notify_job_submitted(struct tevent_context *ev, 500 struct messaging_context *msg_ctx, 501 const char *sharename, uint32 jobid, 465 502 time_t submitted) 466 503 { 467 504 send_notify_field_buffer( 505 ev, msg_ctx, 468 506 sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_FIELD_SUBMITTED, 469 507 jobid, sizeof(submitted), (char *)&submitted); 470 508 } 471 509 472 void notify_printer_driver(int snum, char *driver_name) 473 { 474 const char *sharename = SERVICE(snum); 475 476 send_notify_field_buffer( 510 void notify_printer_driver(struct tevent_context *ev, 511 struct messaging_context *msg_ctx, 512 int snum, const char *driver_name) 513 { 514 const char *sharename = lp_servicename(snum); 515 516 send_notify_field_buffer( 517 ev, msg_ctx, 477 518 sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_DRIVER_NAME, 478 519 snum, strlen(driver_name) + 1, driver_name); 479 520 } 480 521 481 void notify_printer_comment(int snum, char *comment) 482 { 483 const char *sharename = SERVICE(snum); 484 485 send_notify_field_buffer( 522 void notify_printer_comment(struct tevent_context *ev, 523 struct messaging_context *msg_ctx, 524 int snum, const char *comment) 525 { 526 const char *sharename = lp_servicename(snum); 527 528 send_notify_field_buffer( 529 ev, msg_ctx, 486 530 sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_COMMENT, 487 531 snum, strlen(comment) + 1, comment); 488 532 } 489 533 490 void notify_printer_sharename(int snum, char *share_name) 491 { 492 const char *sharename = SERVICE(snum); 493 494 send_notify_field_buffer( 534 void notify_printer_sharename(struct tevent_context *ev, 535 struct messaging_context *msg_ctx, 536 int snum, const char *share_name) 537 { 538 const char *sharename = lp_servicename(snum); 539 540 send_notify_field_buffer( 541 ev, msg_ctx, 495 542 sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_SHARE_NAME, 496 543 snum, strlen(share_name) + 1, share_name); 497 544 } 498 545 499 void notify_printer_printername(int snum, char *printername) 500 { 501 const char *sharename = SERVICE(snum); 502 503 send_notify_field_buffer( 546 void notify_printer_printername(struct tevent_context *ev, 547 struct messaging_context *msg_ctx, 548 int snum, const char *printername) 549 { 550 const char *sharename = lp_servicename(snum); 551 552 send_notify_field_buffer( 553 ev, msg_ctx, 504 554 sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_PRINTER_NAME, 505 555 snum, strlen(printername) + 1, printername); 506 556 } 507 557 508 void notify_printer_port(int snum, char *port_name) 509 { 510 const char *sharename = SERVICE(snum); 511 512 send_notify_field_buffer( 558 void notify_printer_port(struct tevent_context *ev, 559 struct messaging_context *msg_ctx, 560 int snum, const char *port_name) 561 { 562 const char *sharename = lp_servicename(snum); 563 564 send_notify_field_buffer( 565 ev, msg_ctx, 513 566 sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_PORT_NAME, 514 567 snum, strlen(port_name) + 1, port_name); 515 568 } 516 569 517 void notify_printer_location(int snum, char *location) 518 { 519 const char *sharename = SERVICE(snum); 520 521 send_notify_field_buffer( 570 void notify_printer_location(struct tevent_context *ev, 571 struct messaging_context *msg_ctx, 572 int snum, const char *location) 573 { 574 const char *sharename = lp_servicename(snum); 575 576 send_notify_field_buffer( 577 ev, msg_ctx, 522 578 sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_LOCATION, 523 579 snum, strlen(location) + 1, location); 524 580 } 525 581 526 void notify_printer_byname( const char *printername, uint32 change, const char *value ) 582 void notify_printer_sepfile(struct tevent_context *ev, 583 struct messaging_context *msg_ctx, 584 int snum, const char *sepfile) 585 { 586 const char *sharename = lp_servicename(snum); 587 588 send_notify_field_buffer( 589 ev, msg_ctx, 590 sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_SEPFILE, 591 snum, strlen(sepfile) + 1, sepfile); 592 } 593 594 595 void notify_printer_byname(struct tevent_context *ev, 596 struct messaging_context *msg_ctx, 597 const char *printername, uint32 change, 598 const char *value) 527 599 { 528 600 int snum = print_queue_snum(printername); … … 532 604 return; 533 605 534 send_notify_field_buffer( printername, type, change, snum, strlen(value)+1, value ); 606 send_notify_field_buffer( 607 ev, msg_ctx, 608 printername, type, change, snum, strlen(value)+1, value ); 535 609 } 536 610
Note:
See TracChangeset
for help on using the changeset viewer.