LLNotificationChannelPanel::LLNotificationChannelPanel(const std::string& channel_name) 
	: LLPanel(channel_name)
{
	mChannelPtr = LLNotifications::instance().getChannel(channel_name);
	mChannelRejectsPtr = LLNotificationChannelPtr(
												  LLNotificationChannel::buildChannel(channel_name + "rejects", mChannelPtr->getParentChannelName(), !boost::bind(mChannelPtr->getFilter(), _1)));
	LLUICtrlFactory::instance().buildPanel(this, "panel_notifications_channel.xml");
}
LLNotificationChannelPanel::LLNotificationChannelPanel(const LLNotificationChannelPanel::Params& p) 
:	LLLayoutPanel(p)
{
	mChannelPtr = LLNotifications::instance().getChannel(p.name);
	mChannelRejectsPtr = LLNotificationChannelPtr(
		LLNotificationChannel::buildChannel(p.name() + "rejects", mChannelPtr->getParentChannelName(),
											!boost::bind(mChannelPtr->getFilter(), _1)));
	buildFromFile( "panel_notifications_channel.xml");
}
LLNotificationChannelPanel::LLNotificationChannelPanel(const std::string& channel_name) 
	: LLLayoutPanel(NOTIFICATION_PANEL_HEADER_HEIGHT,true,true)
{
	setName(channel_name);
	mChannelPtr = LLNotifications::instance().getChannel(channel_name);
	mChannelRejectsPtr = LLNotificationChannelPtr(
												  LLNotificationChannel::buildChannel(channel_name + "rejects", mChannelPtr->getParentChannelName(), !boost::bind(mChannelPtr->getFilter(), _1)));
	LLUICtrlFactory::instance().buildPanel(this, "panel_notifications_channel.xml");
}
LLNotificationChannelPtr LLNotifications::getChannel(const std::string& channelName)
{
	ChannelMap::iterator p = mChannels.find(channelName);
	if(p == mChannels.end())
	{
		llerrs << "Did not find channel named " << channelName << llendl;
		return LLNotificationChannelPtr();
	}
	return p->second;
}
LLNotificationChannel::LLNotificationChannel(const std::string& name, 
											 const std::string& parent,
											 LLNotificationFilter filter, 
											 LLNotificationComparator comparator) : 
LLNotificationChannelBase(filter, comparator),
mName(name),
mParent(parent)
{
	// store myself in the channel map
	LLNotifications::instance().addChannel(LLNotificationChannelPtr(this));
	// bind to notification broadcast
	if (parent.empty())
	{
		LLNotifications::instance().connectChanged(
			boost::bind(&LLNotificationChannelBase::updateItem, this, _1));
	}
	else
	{
		LLNotificationChannelPtr p = LLNotifications::instance().getChannel(parent);
		p->connectChanged(boost::bind(&LLNotificationChannelBase::updateItem, this, _1));
	}
}