Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Server-side change notification management |
| 3 | * |
| 4 | * Copyright (C) 1998 Alexandre Julliard |
| 5 | */ |
| 6 | |
| 7 | #include <assert.h> |
| 8 | #include <stdio.h> |
| 9 | #include <stdlib.h> |
| 10 | |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 11 | #include "winnt.h" |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 12 | |
| 13 | #include "handle.h" |
| 14 | #include "thread.h" |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 15 | #include "request.h" |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 16 | |
| 17 | struct change |
| 18 | { |
| 19 | struct object obj; /* object header */ |
| 20 | int subtree; /* watch all the subtree */ |
| 21 | int filter; /* notification filter */ |
| 22 | }; |
| 23 | |
| 24 | static void change_dump( struct object *obj, int verbose ); |
| 25 | static int change_signaled( struct object *obj, struct thread *thread ); |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 26 | |
| 27 | static const struct object_ops change_ops = |
| 28 | { |
Alexandre Julliard | 1dca5e2 | 2000-01-01 00:56:27 +0000 | [diff] [blame] | 29 | sizeof(struct change), /* size */ |
| 30 | change_dump, /* dump */ |
| 31 | add_queue, /* add_queue */ |
| 32 | remove_queue, /* remove_queue */ |
| 33 | change_signaled, /* signaled */ |
| 34 | no_satisfied, /* satisfied */ |
| 35 | NULL, /* get_poll_events */ |
| 36 | NULL, /* poll_event */ |
| 37 | no_read_fd, /* get_read_fd */ |
| 38 | no_write_fd, /* get_write_fd */ |
| 39 | no_flush, /* flush */ |
| 40 | no_get_file_info, /* get_file_info */ |
| 41 | no_destroy /* destroy */ |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 45 | static struct change *create_change_notification( int subtree, int filter ) |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 46 | { |
| 47 | struct change *change; |
Alexandre Julliard | 1dca5e2 | 2000-01-01 00:56:27 +0000 | [diff] [blame] | 48 | if ((change = alloc_object( &change_ops, -1 ))) |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 49 | { |
| 50 | change->subtree = subtree; |
| 51 | change->filter = filter; |
| 52 | } |
| 53 | return change; |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | static void change_dump( struct object *obj, int verbose ) |
| 57 | { |
| 58 | struct change *change = (struct change *)obj; |
| 59 | assert( obj->ops == &change_ops ); |
Alexandre Julliard | 0562539 | 1999-01-03 11:55:56 +0000 | [diff] [blame] | 60 | fprintf( stderr, "Change notification sub=%d filter=%08x\n", |
| 61 | change->subtree, change->filter ); |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | static int change_signaled( struct object *obj, struct thread *thread ) |
| 65 | { |
| 66 | /* struct change *change = (struct change *)obj;*/ |
| 67 | assert( obj->ops == &change_ops ); |
| 68 | return 0; /* never signaled for now */ |
| 69 | } |
| 70 | |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 71 | /* create a change notification */ |
| 72 | DECL_HANDLER(create_change_notification) |
| 73 | { |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 74 | struct change *change; |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 75 | |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 76 | req->handle = -1; |
| 77 | if ((change = create_change_notification( req->subtree, req->filter ))) |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 78 | { |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 79 | req->handle = alloc_handle( current->process, change, |
| 80 | STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE, 0 ); |
| 81 | release_object( change ); |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 82 | } |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 83 | } |