Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/printing/notify.c

    r414 r740  
    2222#include "includes.h"
    2323#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"
    2429
    2530static TALLOC_CTX *send_ctx;
     
    228233                                             void *private_data)
    229234{
     235        struct messaging_context *msg_ctx = talloc_get_type_abort(
     236                private_data, struct messaging_context);
    230237        /* Remove this timed event handler. */
    231238        TALLOC_FREE(notify_event);
    232239
    233240        change_to_root_user();
    234         print_notify_send_messages(smbd_messaging_context(), 0);
     241        print_notify_send_messages(msg_ctx, 0);
    235242}
    236243
     
    263270*******************************************************************/
    264271
    265 static void send_spoolss_notify2_msg(SPOOLSS_NOTIFY_MSG *msg)
     272static void send_spoolss_notify2_msg(struct tevent_context *ev,
     273                                     struct messaging_context *msg_ctx,
     274                                     SPOOLSS_NOTIFY_MSG *msg)
    266275{
    267276        struct notify_queue *pnqueue, *tmp_ptr;
     
    326335        num_messages++;
    327336
    328         if ((notify_event == NULL) && (smbd_event_context() != NULL)) {
     337        if ((notify_event == NULL) && (ev != NULL)) {
    329338                /* 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
     346static void send_notify_field_values(struct tevent_context *ev,
     347                                     struct messaging_context *msg_ctx,
     348                                     const char *sharename, uint32 type,
    338349                                     uint32 field, uint32 id, uint32 value1,
    339350                                     uint32 value2, uint32 flags)
     
    361372        msg->flags = flags;
    362373
    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
     377static void send_notify_field_buffer(struct tevent_context *ev,
     378                                     struct messaging_context *msg_ctx,
     379                                     const char *sharename, uint32 type,
    367380                                     uint32 field, uint32 id, uint32 len,
    368381                                     const char *buffer)
     
    389402        msg->notify.data = CONST_DISCARD(char *,buffer);
    390403
    391         send_spoolss_notify2_msg(msg);
     404        send_spoolss_notify2_msg(ev, msg_ctx, msg);
    392405}
    393406
    394407/* Send a message that the printer status has changed */
    395408
    396 void notify_printer_status_byname(const char *sharename, uint32 status)
     409void notify_printer_status_byname(struct tevent_context *ev,
     410                                  struct messaging_context *msg_ctx,
     411                                  const char *sharename, uint32 status)
    397412{
    398413        /* Printer status stored in value1 */
     
    400415        int snum = print_queue_snum(sharename);
    401416
    402         send_notify_field_values(sharename, PRINTER_NOTIFY_TYPE,
     417        send_notify_field_values(ev, msg_ctx, sharename, PRINTER_NOTIFY_TYPE,
    403418                                 PRINTER_NOTIFY_FIELD_STATUS, snum,
    404419                                 status, 0, 0);
    405420}
    406421
    407 void notify_printer_status(int snum, uint32 status)
    408 {
    409         const char *sharename = SERVICE(snum);
     422void 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);
    410427
    411428        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
     432void notify_job_status_byname(struct tevent_context *ev,
     433                              struct messaging_context *msg_ctx,
     434                              const char *sharename, uint32 jobid,
     435                              uint32 status,
    416436                              uint32 flags)
    417437{
    418438        /* Job id stored in id field, status in value1 */
    419439
    420         send_notify_field_values(sharename, JOB_NOTIFY_TYPE,
     440        send_notify_field_values(ev, msg_ctx,
     441                                 sharename, JOB_NOTIFY_TYPE,
    421442                                 JOB_NOTIFY_FIELD_STATUS, jobid,
    422443                                 status, 0, flags);
    423444}
    424445
    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,
     446void 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
     453void notify_job_total_bytes(struct tevent_context *ev,
     454                            struct messaging_context *msg_ctx,
     455                            const char *sharename, uint32 jobid,
    431456                            uint32 size)
    432457{
    433458        /* Job id stored in id field, status in value1 */
    434459
    435         send_notify_field_values(sharename, JOB_NOTIFY_TYPE,
     460        send_notify_field_values(ev, msg_ctx,
     461                                 sharename, JOB_NOTIFY_TYPE,
    436462                                 JOB_NOTIFY_FIELD_TOTAL_BYTES, jobid,
    437463                                 size, 0, 0);
    438464}
    439465
    440 void notify_job_total_pages(const char *sharename, uint32 jobid,
     466void notify_job_total_pages(struct tevent_context *ev,
     467                            struct messaging_context *msg_ctx,
     468                            const char *sharename, uint32 jobid,
    441469                            uint32 pages)
    442470{
    443471        /* Job id stored in id field, status in value1 */
    444472
    445         send_notify_field_values(sharename, JOB_NOTIFY_TYPE,
     473        send_notify_field_values(ev, msg_ctx,
     474                                 sharename, JOB_NOTIFY_TYPE,
    446475                                 JOB_NOTIFY_FIELD_TOTAL_PAGES, jobid,
    447476                                 pages, 0, 0);
    448477}
    449478
    450 void notify_job_username(const char *sharename, uint32 jobid, char *name)
    451 {
    452         send_notify_field_buffer(
     479void 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,
    453485                sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_FIELD_USER_NAME,
    454486                jobid, strlen(name) + 1, name);
    455487}
    456488
    457 void notify_job_name(const char *sharename, uint32 jobid, char *name)
    458 {
    459         send_notify_field_buffer(
     489void 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,
    460495                sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_FIELD_DOCUMENT,
    461496                jobid, strlen(name) + 1, name);
    462497}
    463498
    464 void notify_job_submitted(const char *sharename, uint32 jobid,
     499void notify_job_submitted(struct tevent_context *ev,
     500                          struct messaging_context *msg_ctx,
     501                          const char *sharename, uint32 jobid,
    465502                          time_t submitted)
    466503{
    467504        send_notify_field_buffer(
     505                ev, msg_ctx,
    468506                sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_FIELD_SUBMITTED,
    469507                jobid, sizeof(submitted), (char *)&submitted);
    470508}
    471509
    472 void notify_printer_driver(int snum, char *driver_name)
    473 {
    474         const char *sharename = SERVICE(snum);
    475 
    476         send_notify_field_buffer(
     510void 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,
    477518                sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_DRIVER_NAME,
    478519                snum, strlen(driver_name) + 1, driver_name);
    479520}
    480521
    481 void notify_printer_comment(int snum, char *comment)
    482 {
    483         const char *sharename = SERVICE(snum);
    484 
    485         send_notify_field_buffer(
     522void 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,
    486530                sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_COMMENT,
    487531                snum, strlen(comment) + 1, comment);
    488532}
    489533
    490 void notify_printer_sharename(int snum, char *share_name)
    491 {
    492         const char *sharename = SERVICE(snum);
    493 
    494         send_notify_field_buffer(
     534void 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,
    495542                sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_SHARE_NAME,
    496543                snum, strlen(share_name) + 1, share_name);
    497544}
    498545
    499 void notify_printer_printername(int snum, char *printername)
    500 {
    501         const char *sharename = SERVICE(snum);
    502 
    503         send_notify_field_buffer(
     546void 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,
    504554                sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_PRINTER_NAME,
    505555                snum, strlen(printername) + 1, printername);
    506556}
    507557
    508 void notify_printer_port(int snum, char *port_name)
    509 {
    510         const char *sharename = SERVICE(snum);
    511 
    512         send_notify_field_buffer(
     558void 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,
    513566                sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_PORT_NAME,
    514567                snum, strlen(port_name) + 1, port_name);
    515568}
    516569
    517 void notify_printer_location(int snum, char *location)
    518 {
    519         const char *sharename = SERVICE(snum);
    520 
    521         send_notify_field_buffer(
     570void 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,
    522578                sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_LOCATION,
    523579                snum, strlen(location) + 1, location);
    524580}
    525581
    526 void notify_printer_byname( const char *printername, uint32 change, const char *value )
     582void 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
     595void notify_printer_byname(struct tevent_context *ev,
     596                           struct messaging_context *msg_ctx,
     597                           const char *printername, uint32 change,
     598                           const char *value)
    527599{
    528600        int snum = print_queue_snum(printername);
     
    532604                return;
    533605               
    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 );
    535609}
    536610
Note: See TracChangeset for help on using the changeset viewer.