bonefish+axeld:

* Simplified the notification framework: removed the updater stuff completely;
  it was only there to account for some peculiarities of the node monitor which
  we now solved differently.
* NotificationListener no longer includes a doubly linked list link for convenience;
  it might want to listen to more than just one service.
* NotificationService cannot have an abstract destructor.
* Changed the _user_stop_watching() syscall to mirror the Be API; ie. it's no
  longer possible to just remove some flags separately, just to stop listening
  completely.
* Adapted the node monitor implementation to live in the NodeMonitorService class
  that uses the new notification framework.
* Removed the public kernel node monitor API - it wasn't useful that way since you
  couldn't do a lot with the KMessage in the kernel without using a private API.
  Now you will have to use the (private) notification manager to use the node monitor
  from inside the kernel. At a later point, we might introduce a public API for that,
  too.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21780 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2007-08-01 14:48:44 +00:00
parent 5102d49461
commit edb15b5565
8 changed files with 931 additions and 876 deletions
+29 -90
View File
@@ -30,11 +30,18 @@ NotificationListener::EventOccured(NotificationService& service,
void
NotificationListener::AllListenersNotified()
NotificationListener::AllListenersNotified(NotificationService& service)
{
}
bool
NotificationListener::operator==(const NotificationListener& other) const
{
return &other == this;
}
// #pragma mark - UserMessagingMessageSender
@@ -102,86 +109,18 @@ UserMessagingListener::EventOccured(NotificationService& service,
void
UserMessagingListener::AllListenersNotified()
UserMessagingListener::AllListenersNotified(NotificationService& service)
{
fSender.FlushMessage();
}
// #pragma mark - NotificationListenerUpdater
// #pragma mark - NotificationService
NotificationListenerUpdater::NotificationListenerUpdater(
const KMessage* eventSpecifier)
: fEventSpecifier(eventSpecifier)
{
}
NotificationListenerUpdater::~NotificationListenerUpdater()
{
}
status_t
NotificationListenerUpdater::UpdateListener(NotificationListener& listener,
enum update_action& action)
{
action = SKIP;
return B_OK;
}
status_t
NotificationListenerUpdater::CreateListener(NotificationListener** _listener)
{
return B_ERROR;
}
void
NotificationListenerUpdater::SetEventSpecifier(const KMessage* eventSpecifier)
{
fEventSpecifier = eventSpecifier;
}
// #pragma mark - NotificationListenerUpdater
UserMessagingListenerUpdater::UserMessagingListenerUpdater(
const KMessage* eventSpecifier, port_id port, int32 token)
:
NotificationListenerUpdater(eventSpecifier),
fPort(port),
fToken(token)
{
}
status_t
UserMessagingListenerUpdater::UpdateListener(NotificationListener& _listener,
enum update_action& action)
{
UserMessagingListener* listener
= dynamic_cast<UserMessagingListener*>(&_listener);
if (listener != NULL && listener->Port() == fPort
&& listener->Token() == fToken) {
return UpdateListener(*listener, action);
}
action = SKIP;
return B_OK;
}
// #pragma mark - NotificationManager
#if 0
NotificationService::~NotificationService()
{
}
#endif
// #pragma mark - NotificationManager
@@ -285,15 +224,31 @@ NotificationManager::AddListener(const char* serviceName,
status_t
NotificationManager::RemoveListener(const char* serviceName, uint32 eventMask,
NotificationListener& listener)
NotificationManager::UpdateListener(const char* serviceName,
uint32 eventMask, NotificationListener& listener)
{
char buffer[96];
KMessage specifier;
specifier.SetTo(buffer, sizeof(buffer), 0);
specifier.AddInt32("event mask", eventMask);
return RemoveListener(serviceName, &specifier, listener);
return UpdateListener(serviceName, &specifier, listener);
}
status_t
NotificationManager::UpdateListener(const char* serviceName,
const KMessage* eventSpecifier, NotificationListener& listener)
{
MutexLocker locker(fLock);
NotificationService* service = _ServiceFor(serviceName);
if (service == NULL)
return B_NAME_NOT_FOUND;
Reference<NotificationService> reference(service);
locker.Unlock();
return service->UpdateListener(eventSpecifier, listener);
}
@@ -313,22 +268,6 @@ NotificationManager::RemoveListener(const char* serviceName,
}
status_t
NotificationManager::UpdateListener(const char* serviceName,
NotificationListenerUpdater& updater)
{
MutexLocker locker(fLock);
NotificationService* service = _ServiceFor(serviceName);
if (service == NULL)
return B_NAME_NOT_FOUND;
Reference<NotificationService> reference(service);
locker.Unlock();
return service->UpdateListener(updater);
}
// #pragma mark -