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);
+/* These are the callbacks that are implemented in hgfsServer.c */
+typedef void (*HgfsNotifyRegisterThreadCb)(struct HgfsSessionInfo *session);
+typedef void (*HgfsNotifyUnregisterThreadCb)(struct HgfsSessionInfo *session);
+typedef void (*HgfsNotifyEventReceiveCb)(HgfsSharedFolderHandle sharedFolder,
+ HgfsSubscriberHandle subscriber,
+ char *name,
+ uint32 mask,
+ struct HgfsSessionInfo *session);
+
+typedef struct HgfsServerNotifyCallbacks {
+ HgfsNotifyRegisterThreadCb registerThread;
+ HgfsNotifyUnregisterThreadCb unregisterThread;
+ HgfsNotifyEventReceiveCb eventReceive;
+} HgfsServerNotifyCallbacks;
+
+HgfsInternalStatus HgfsNotify_Init(const HgfsServerNotifyCallbacks *serverCbData);
void HgfsNotify_Exit(void);
void HgfsNotify_Deactivate(HgfsNotifyActivateReason mode,
struct HgfsSessionInfo *session);
const char *path,
uint32 eventFilter,
uint32 recursive,
- HgfsNotifyEventReceiveCb notify,
struct HgfsSessionInfo *session);
Bool HgfsNotify_RemoveSharedFolder(HgfsSharedFolderHandle sharedFolder);
},
};
+
+static void HgfsServerNotifyRegisterThreadCb(struct HgfsSessionInfo *session);
+static void HgfsServerNotifyUnregisterThreadCb(struct HgfsSessionInfo *session);
+static void HgfsServerNotifyReceiveEventCb(HgfsSharedFolderHandle sharedFolder,
+ HgfsSubscriberHandle subscriber,
+ char* fileName,
+ uint32 mask,
+ struct HgfsSessionInfo *session);
+
+/*
+ * Callback table passed to the directory change notification component.
+ */
+static const HgfsServerNotifyCallbacks gHgfsServerNotifyCBTable = {
+ HgfsServerNotifyRegisterThreadCb,
+ HgfsServerNotifyUnregisterThreadCb,
+ HgfsServerNotifyReceiveEventCb,
+};
+
/* Lock that protects shared folders list. */
static MXUserExclLock *gHgfsSharedFoldersLock = NULL;
char **fileName,
size_t *fileNameSize,
HgfsSharedFolderHandle *folderHandle);
-static void HgfsServerNotifyReceiveEventCb(HgfsSharedFolderHandle sharedFolder,
- HgfsSubscriberHandle subscriber,
- char* fileName,
- uint32 mask,
- struct HgfsSessionInfo *session);
static void HgfsFreeSearchDirents(HgfsSearch *search);
static HgfsInternalStatus
*callbackTable = &gHgfsServerCBTable;
if (0 != (gHgfsCfgSettings.flags & HGFS_CONFIG_NOTIFY_ENABLED)) {
- gHgfsDirNotifyActive = HgfsNotify_Init() == HGFS_STATUS_SUCCESS;
+ gHgfsDirNotifyActive = HgfsNotify_Init(&gHgfsServerNotifyCBTable) == HGFS_STATUS_SUCCESS;
Log("%s: initialized notification %s.\n", __FUNCTION__,
(gHgfsDirNotifyActive ? "active" : "inactive"));
}
LOG(4, ("%s: adding a subscriber on shared folder handle %#x\n", __FUNCTION__,
sharedFolder));
*watchId = HgfsNotify_AddSubscriber(sharedFolder, fileName, events, watchTree,
- HgfsServerNotifyReceiveEventCb, input->session);
+ input->session);
status = (HGFS_INVALID_SUBSCRIBER_HANDLE == *watchId) ? HGFS_ERROR_INTERNAL :
HGFS_ERROR_SUCCESS;
LOG(4, ("%s: result of add subscriber id %"FMT64"x status %u\n", __FUNCTION__,
LOG(8, ("%s: session %p id %"FMT64"x on share hnd %#x\n", __FUNCTION__,
input->session, input->session->sessionId, sharedFolder));
*watchId = HgfsNotify_AddSubscriber(sharedFolder, tempBuf, events,
- watchTree, HgfsServerNotifyReceiveEventCb,
+ watchTree,
input->session);
status = (HGFS_INVALID_SUBSCRIBER_HANDLE == *watchId) ?
HGFS_ERROR_INTERNAL : HGFS_ERROR_SUCCESS;
} else {
LOG(8, ("%s: adding subscriber on share hnd %#x\n", __FUNCTION__, sharedFolder));
*watchId = HgfsNotify_AddSubscriber(sharedFolder, "", events, watchTree,
- HgfsServerNotifyReceiveEventCb,
input->session);
status = (HGFS_INVALID_SUBSCRIBER_HANDLE == *watchId) ? HGFS_ERROR_INTERNAL :
HGFS_ERROR_SUCCESS;
- LOG(8, ("%s: adding subscriber on share hnd %#x result %u\n", __FUNCTION__,
- sharedFolder, status));
+ LOG(8, ("%s: adding subscriber on share hnd %#x watchId %"FMT64"x result %u\n",
+ __FUNCTION__, sharedFolder, *watchId, status));
}
} else if (HGFS_NAME_STATUS_INCOMPLETE_BASE == nameStatus) {
LOG(4, ("%s: Notification for root share is not supported yet\n",
}
-#ifdef HGFS_NOTIFY_THREAD_REGISTER_SUPPORTED
/*
*-----------------------------------------------------------------------------
*
ASSERT(session);
transportSession = session->transportSession;
+ LOG(4, ("%s: Registering thread on session %"FMT64"x\n", __FUNCTION__, session->sessionId));
+
if (transportSession->channelCbTable->registerThread != NULL) {
transportSession->channelCbTable->registerThread();
}
ASSERT(session);
transportSession = session->transportSession;
+ LOG(4, ("%s: Unregistering thread on session %"FMT64"x\n", __FUNCTION__, session->sessionId));
+
if (transportSession->channelCbTable->unregisterThread != NULL) {
transportSession->channelCbTable->unregisterThread();
}
}
-#endif // HGFS_NOTIFY_THREAD_REGISTER_SUPPORTED
/*