Example #1
0
void
LaunchDaemon::_HandleRegisterLaunchEvent(BMessage* message)
{
	uid_t user = _GetUserID(message);
	if (user < 0)
		return;

	if (user == 0 || fUserMode) {
		status_t status = B_OK;

		const char* name = message->GetString("name");
		const char* ownerName = message->GetString("owner");
		uint32 flags = message->GetUInt32("flags", 0);
		BMessenger source;
		if (name != NULL && ownerName != NULL
			&& message->FindMessenger("source", &source) == B_OK) {
			// Register event
			ownerName = get_leaf(ownerName);

			ExternalEventSource* event = new (std::nothrow)
				ExternalEventSource(source, ownerName, name, flags);
			if (event != NULL) {
				// Use short name, and fully qualified name
				BString eventName = name;
				fEvents.insert(std::make_pair(eventName, event));
				_ResolveExternalEvents(event, eventName);

				eventName.Prepend("/");
				eventName.Prepend(ownerName);
				fEvents.insert(std::make_pair(eventName, event));
				_ResolveExternalEvents(event, eventName);
			} else
				status = B_NO_MEMORY;
		} else
			status = B_BAD_VALUE;

		BMessage reply((uint32)status);
		message->SendReply(&reply);
	}

	_ForwardEventMessage(user, message);
}
Example #2
0
	static void UpdateEventMap()
	{
		EventMap map;
		Thread::Mutex::Scoped l(locker_event);
		for(IOMap::const_iterator it = ionew.begin(), ie = ionew.end(); it != ie; ++it)
		{
			PollIO *io = (*it).second;
			iomap[(*it).first] = io;
			if (io->newevent)
				eventset.insert(io);
		}
		ionew.clear();
		for (EventSet::iterator it = eventset.begin(), ie = eventset.end(); it != ie; ++it)
		{
			map.insert( std::make_pair(*it, (*it)->event) );
			(*it)->update   = false;
			(*it)->event    = (*it)->newevent;
			(*it)->newevent = 0;
		}
		eventset.clear();
		wakeup_flag = true;
		std::for_each(map.begin(), map.end(), std::ptr_fun(&LoadEvent));
	}