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 |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame^] | 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 19 | */ |
| 20 | |
| 21 | #include <assert.h> |
| 22 | #include <stdio.h> |
| 23 | #include <stdlib.h> |
| 24 | |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 25 | #include "winnt.h" |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 26 | |
| 27 | #include "handle.h" |
| 28 | #include "thread.h" |
Alexandre Julliard | 5bc7808 | 1999-06-22 17:26:53 +0000 | [diff] [blame] | 29 | #include "request.h" |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 30 | |
| 31 | struct change |
| 32 | { |
| 33 | struct object obj; /* object header */ |
| 34 | int subtree; /* watch all the subtree */ |
| 35 | int filter; /* notification filter */ |
| 36 | }; |
| 37 | |
| 38 | static void change_dump( struct object *obj, int verbose ); |
| 39 | static int change_signaled( struct object *obj, struct thread *thread ); |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 40 | |
| 41 | static const struct object_ops change_ops = |
| 42 | { |
Alexandre Julliard | 1dca5e2 | 2000-01-01 00:56:27 +0000 | [diff] [blame] | 43 | sizeof(struct change), /* size */ |
| 44 | change_dump, /* dump */ |
| 45 | add_queue, /* add_queue */ |
| 46 | remove_queue, /* remove_queue */ |
| 47 | change_signaled, /* signaled */ |
| 48 | no_satisfied, /* satisfied */ |
| 49 | NULL, /* get_poll_events */ |
| 50 | NULL, /* poll_event */ |
Alexandre Julliard | 1ab243b | 2000-12-19 02:12:45 +0000 | [diff] [blame] | 51 | no_get_fd, /* get_fd */ |
Alexandre Julliard | 1dca5e2 | 2000-01-01 00:56:27 +0000 | [diff] [blame] | 52 | no_flush, /* flush */ |
| 53 | no_get_file_info, /* get_file_info */ |
Mike McCormack | 6f011c0 | 2001-12-20 00:07:05 +0000 | [diff] [blame] | 54 | NULL, /* queue_async */ |
Alexandre Julliard | 1dca5e2 | 2000-01-01 00:56:27 +0000 | [diff] [blame] | 55 | no_destroy /* destroy */ |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 59 | static struct change *create_change_notification( int subtree, int filter ) |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 60 | { |
| 61 | struct change *change; |
Alexandre Julliard | 1dca5e2 | 2000-01-01 00:56:27 +0000 | [diff] [blame] | 62 | if ((change = alloc_object( &change_ops, -1 ))) |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 63 | { |
| 64 | change->subtree = subtree; |
| 65 | change->filter = filter; |
| 66 | } |
| 67 | return change; |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | static void change_dump( struct object *obj, int verbose ) |
| 71 | { |
| 72 | struct change *change = (struct change *)obj; |
| 73 | assert( obj->ops == &change_ops ); |
Alexandre Julliard | 0562539 | 1999-01-03 11:55:56 +0000 | [diff] [blame] | 74 | fprintf( stderr, "Change notification sub=%d filter=%08x\n", |
| 75 | change->subtree, change->filter ); |
Alexandre Julliard | 63cb0f8 | 1998-12-31 15:43:48 +0000 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | static int change_signaled( struct object *obj, struct thread *thread ) |
| 79 | { |
| 80 | /* struct change *change = (struct change *)obj;*/ |
| 81 | assert( obj->ops == &change_ops ); |
| 82 | return 0; /* never signaled for now */ |
| 83 | } |
| 84 | |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 85 | /* create a change notification */ |
| 86 | DECL_HANDLER(create_change_notification) |
| 87 | { |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 88 | struct change *change; |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 89 | |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 90 | reply->handle = 0; |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 91 | if ((change = create_change_notification( req->subtree, req->filter ))) |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 92 | { |
Alexandre Julliard | 9caa71e | 2001-11-30 18:46:42 +0000 | [diff] [blame] | 93 | reply->handle = alloc_handle( current->process, change, |
| 94 | STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE, 0 ); |
Alexandre Julliard | ebe29ef | 1999-06-26 08:43:26 +0000 | [diff] [blame] | 95 | release_object( change ); |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 96 | } |
Alexandre Julliard | 43c190e | 1999-05-15 10:48:19 +0000 | [diff] [blame] | 97 | } |