summaryrefslogtreecommitdiff
path: root/indra/llui/llnotificationslistener.cpp
blob: 75f4d6177dc3958e5b1fc0b9f54dc6133e8a7ccb (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
/**
 * @file   llnotificationslistener.cpp
 * @author Brad Kittenbrink
 * @date   2009-07-08
 * @brief  Implementation for llnotificationslistener.
 * 
 * $LicenseInfo:firstyear=2009&license=viewergpl$
 * Copyright (c) 2009, Linden Research, Inc.
 * $/LicenseInfo$
 */

#include "linden_common.h"

#include "llnotificationslistener.h"

#include "llnotifications.h"

LLNotificationsListener::LLNotificationsListener(LLNotifications & notifications) :
    LLDispatchListener("LLNotifications", "op"),
    mNotifications(notifications)
{
    add("requestAdd", &LLNotificationsListener::requestAdd);
}

void LLNotificationsListener::requestAdd(const LLSD& event_data) const
{
	if(event_data.has("reply"))
	{
		mNotifications.add(event_data["name"], 
						   event_data["substitutions"], 
						   event_data["payload"],
						   boost::bind(&LLNotificationsListener::NotificationResponder, 
									   this, 
									   event_data["reply"].asString(), 
									   _1, _2
									   )
						   );
	}
	else
	{
		mNotifications.add(event_data["name"], 
						   event_data["substitutions"], 
						   event_data["payload"]);
	}
}

void LLNotificationsListener::NotificationResponder(const std::string& reply_pump, 
										const LLSD& notification, 
										const LLSD& response) const
{
	LLSD reponse_event;
	reponse_event["notification"] = notification;
	reponse_event["response"] = response;
	LLEventPumps::getInstance()->obtain(reply_pump).post(reponse_event);
}