blob: daa0cadb3baa109a40858efa851d4114215322e8 [file] [log] [blame]
Alexandre Julliard63cb0f81998-12-31 15:43:48 +00001/*
2 * Server-side change notification management
3 *
4 * Copyright (C) 1998 Alexandre Julliard
Alexandre Julliard0799c1a2002-03-09 23:29:33 +00005 *
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 Julliard63cb0f81998-12-31 15:43:48 +000019 */
20
21#include <assert.h>
22#include <stdio.h>
23#include <stdlib.h>
24
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000025#include "winnt.h"
Alexandre Julliard43c190e1999-05-15 10:48:19 +000026
27#include "handle.h"
28#include "thread.h"
Alexandre Julliard5bc78081999-06-22 17:26:53 +000029#include "request.h"
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000030
31struct change
32{
33 struct object obj; /* object header */
34 int subtree; /* watch all the subtree */
35 int filter; /* notification filter */
36};
37
38static void change_dump( struct object *obj, int verbose );
39static int change_signaled( struct object *obj, struct thread *thread );
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000040
41static const struct object_ops change_ops =
42{
Alexandre Julliard1dca5e22000-01-01 00:56:27 +000043 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 Julliard1ab243b2000-12-19 02:12:45 +000051 no_get_fd, /* get_fd */
Alexandre Julliard1dca5e22000-01-01 00:56:27 +000052 no_flush, /* flush */
53 no_get_file_info, /* get_file_info */
Mike McCormack6f011c02001-12-20 00:07:05 +000054 NULL, /* queue_async */
Alexandre Julliard1dca5e22000-01-01 00:56:27 +000055 no_destroy /* destroy */
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000056};
57
58
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000059static struct change *create_change_notification( int subtree, int filter )
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000060{
61 struct change *change;
Alexandre Julliard1dca5e22000-01-01 00:56:27 +000062 if ((change = alloc_object( &change_ops, -1 )))
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000063 {
64 change->subtree = subtree;
65 change->filter = filter;
66 }
67 return change;
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000068}
69
70static void change_dump( struct object *obj, int verbose )
71{
72 struct change *change = (struct change *)obj;
73 assert( obj->ops == &change_ops );
Alexandre Julliard05625391999-01-03 11:55:56 +000074 fprintf( stderr, "Change notification sub=%d filter=%08x\n",
75 change->subtree, change->filter );
Alexandre Julliard63cb0f81998-12-31 15:43:48 +000076}
77
78static 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 Julliard43c190e1999-05-15 10:48:19 +000085/* create a change notification */
86DECL_HANDLER(create_change_notification)
87{
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000088 struct change *change;
Alexandre Julliard43c190e1999-05-15 10:48:19 +000089
Alexandre Julliard9caa71e2001-11-30 18:46:42 +000090 reply->handle = 0;
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000091 if ((change = create_change_notification( req->subtree, req->filter )))
Alexandre Julliard43c190e1999-05-15 10:48:19 +000092 {
Alexandre Julliard9caa71e2001-11-30 18:46:42 +000093 reply->handle = alloc_handle( current->process, change,
94 STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE, 0 );
Alexandre Julliardebe29ef1999-06-26 08:43:26 +000095 release_object( change );
Alexandre Julliard43c190e1999-05-15 10:48:19 +000096 }
Alexandre Julliard43c190e1999-05-15 10:48:19 +000097}