summaryrefslogtreecommitdiff
path: root/open-vm-tools/lib/hgfsServer/hgfsDirNotify.h
blob: b130bf5b84ce45fe0fe54956958d90e8e4d1039d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*********************************************************
 * Copyright (C) 2009-2015 VMware, Inc. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation version 2.1 and no later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
 *
 *********************************************************/

#ifndef _HGFS_DIRNOTIFY_H
#define _HGFS_DIRNOTIFY_H

/*
 * hgfsDirNotify.h --
 *
 *	Function definitions for directory change notification.
 */

#include "hgfsServer.h" // for HgfsSharedFolderHandle
#include "hgfsProto.h"  // for HgfsSubscriberHandle
#include "hgfsUtil.h"   // for HgfsInternalStatus

struct HgfsSessionInfo;
/*
 * Activate and deactivate reason.
 * Currently, there are two scenarios:
 * 1) HGFS server is check point synchronizing: the file system event
 * generation is deactivated at the start and activated at the end.
 * 2) The client has added the first subscriber or removed the last
 * subscriber. The file system event generation is activated on the
 * addition of the first subscriber and deactivated on removal of
 * the last one.
 *
 * Note, in case 1 above, if there are no subscribers even at the end
 * of the HGFS server check point syncing, the activation will not
 * activate the file system events.
 */
typedef enum {
   HGFS_NOTIFY_REASON_SERVER_SYNC,
   HGFS_NOTIFY_REASON_SUBSCRIBERS,
} HgfsNotifyActivateReason;

/* This is a callback that is implemented in hgfsServer.c */
typedef void HgfsNotifyEventReceiveCb(HgfsSharedFolderHandle sharedFolder,
                                      HgfsSubscriberHandle subscriber,
                                      char *name,
                                      uint32 mask,
                                      struct HgfsSessionInfo *session);
HgfsInternalStatus HgfsNotify_Init(void);
void HgfsNotify_Exit(void);
void HgfsNotify_Deactivate(HgfsNotifyActivateReason mode);
void HgfsNotify_Activate(HgfsNotifyActivateReason mode);

HgfsSharedFolderHandle HgfsNotify_AddSharedFolder(const char *path,
                                                  const char *shareName);
HgfsSubscriberHandle HgfsNotify_AddSubscriber(HgfsSharedFolderHandle sharedFolder,
                                              const char *path,
                                              uint32 eventFilter,
                                              uint32 recursive,
                                              HgfsNotifyEventReceiveCb notify,
                                              struct HgfsSessionInfo *session);

Bool HgfsNotify_RemoveSharedFolder(HgfsSharedFolderHandle sharedFolder);
Bool HgfsNotify_RemoveSubscriber(HgfsSubscriberHandle subscriber);
void HgfsNotify_RemoveSessionSubscribers(struct HgfsSessionInfo *session);

#endif // _HGFS_DIRNOTIFY_H