diff --git a/indra/newview/lleventnotifier.cpp b/indra/newview/lleventnotifier.cpp index 1e915a266..f39e234ee 100644 --- a/indra/newview/lleventnotifier.cpp +++ b/indra/newview/lleventnotifier.cpp @@ -78,24 +78,42 @@ void LLEventNotifier::update() { LLEventNotification *np = iter->second; + iter++; if (np->getEventDate() < (alert_time)) { LLSD args; args["NAME"] = np->getEventName(); args["DATE"] = np->getEventDateStr(); LLNotifications::instance().add("EventNotification", args, LLSD(), - boost::bind(&LLEventNotification::handleResponse, np, _1, _2)); - mEventNotifications.erase(iter++); - } - else - { - iter++; + boost::bind(&LLEventNotifier::handleResponse, this, np->getEventID(), np->getEventPosGlobal(), _1, _2)); + remove(np->getEventID()); } } mNotificationTimer.reset(); } } +bool LLEventNotifier::handleResponse(U32 eventId, LLVector3d eventPos, const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotification::getSelectedOption(notification, response); + switch (option) + { + case 0: + gAgent.teleportViaLocation(eventPos); + gFloaterWorldMap->trackLocation(eventPos); + break; + case 1: + gDisplayEventHack = TRUE; + LLFloaterDirectory::showEvents(eventId); + break; + case 2: + break; + } + + // We could clean up the notification on the server now if we really wanted to. + return true; +} + void LLEventNotifier::load(const LLUserAuth::options_t& event_options) { LLUserAuth::options_t::const_iterator resp_it; @@ -117,6 +135,19 @@ void LLEventNotifier::load(const LLUserAuth::options_t& event_options) } } +void LLEventNotifier::add(U32 eventId) +{ + + gMessageSystem->newMessageFast(_PREHASH_EventInfoRequest); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() ); + gMessageSystem->nextBlockFast(_PREHASH_EventData); + gMessageSystem->addU32Fast(_PREHASH_EventID, eventId); + gAgent.sendReliableMessage(); + +} + BOOL LLEventNotifier::hasNotification(const U32 event_id) { if (mEventNotifications.find(event_id) != mEventNotifications.end()) @@ -137,14 +168,7 @@ void LLEventNotifier::add(LLEventInfo &event_info) return; } - // Push up a message to tell the server we have this notification. - gMessageSystem->newMessage("EventNotificationAddRequest"); - gMessageSystem->nextBlockFast(_PREHASH_AgentData); - gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); - gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - gMessageSystem->nextBlock("EventData"); - gMessageSystem->addU32("EventID", event_info.mID); - gAgent.sendReliableMessage(); + serverPushRequest(event_info.mID, true); LLEventNotification *enp = new LLEventNotification; enp->load(event_info); @@ -161,17 +185,22 @@ void LLEventNotifier::remove(const U32 event_id) return; } - // Push up a message to tell the server to remove this notification. - gMessageSystem->newMessage("EventNotificationRemoveRequest"); + serverPushRequest(event_id, false); + delete iter->second; + mEventNotifications.erase(iter); +} + + +void LLEventNotifier::serverPushRequest(U32 event_id, bool add) +{ + // Push up a message to tell the server we have this notification. + gMessageSystem->newMessage(add?"EventNotificationAddRequest":"EventNotificationRemoveRequest"); gMessageSystem->nextBlockFast(_PREHASH_AgentData); gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); gMessageSystem->nextBlock("EventData"); gMessageSystem->addU32("EventID", event_id); gAgent.sendReliableMessage(); - - delete iter->second; - mEventNotifications.erase(iter); } LLEventNotification::LLEventNotification() : @@ -185,26 +214,6 @@ LLEventNotification::~LLEventNotification() { } -bool LLEventNotification::handleResponse(const LLSD& notification, const LLSD& response) -{ - S32 option = LLNotification::getSelectedOption(notification, response); - switch (option) - { - case 0: - gAgent.teleportViaLocation(getEventPosGlobal()); - gFloaterWorldMap->trackLocation(getEventPosGlobal()); - break; - case 1: - gDisplayEventHack = TRUE; - LLFloaterDirectory::showEvents(getEventID()); - break; - case 2: - break; - } - - // We could clean up the notification on the server now if we really wanted to. - return false; -} BOOL LLEventNotification::load(const LLUserAuth::response_t &response) { diff --git a/indra/newview/lleventnotifier.h b/indra/newview/lleventnotifier.h index feb734948..f5e03a3fb 100644 --- a/indra/newview/lleventnotifier.h +++ b/indra/newview/lleventnotifier.h @@ -39,6 +39,7 @@ class LLEventInfo; class LLEventNotification; +class LLMessageSystem; class LLEventNotifier @@ -48,14 +49,17 @@ public: virtual ~LLEventNotifier(); void update(); // Notify the user of the event if it's coming up + void add(LLEventInfo &event_info); // Add a new notification for an event + void add(U32 eventId); void load(const LLUserAuth::options_t& event_options); // In the format that it comes in from LLUserAuth - void add(LLEventInfo &event_info); // Add a new notification for an event void remove(U32 event_id); BOOL hasNotification(const U32 event_id); + void serverPushRequest(U32 event_id, bool add); typedef std::map en_map; + bool handleResponse(U32 eventId, LLVector3d eventPos, const LLSD& notification, const LLSD& response); protected: en_map mEventNotifications; @@ -78,7 +82,6 @@ public: time_t getEventDate() const { return mEventDate; } const std::string &getEventDateStr() const { return mEventDateStr; } LLVector3d getEventPosGlobal() const { return mEventPosGlobal; } - bool handleResponse(const LLSD& notification, const LLSD& payload); protected: U32 mEventID; // EventID for this event std::string mEventName; diff --git a/indra/newview/llpanelevent.cpp b/indra/newview/llpanelevent.cpp index c8c49a872..4d8b96a6c 100644 --- a/indra/newview/llpanelevent.cpp +++ b/indra/newview/llpanelevent.cpp @@ -114,25 +114,10 @@ void LLPanelEvent::setEventID(const U32 event_id) if (event_id != 0) { - sendEventInfoRequest(); + gEventNotifier.add(event_id); } } - -void LLPanelEvent::sendEventInfoRequest() -{ - LLMessageSystem *msg = gMessageSystem; - - msg->newMessageFast(_PREHASH_EventInfoRequest); - msg->nextBlockFast(_PREHASH_AgentData); - msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); - msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID() ); - msg->nextBlockFast(_PREHASH_EventData); - msg->addU32Fast(_PREHASH_EventID, mEventID); - gAgent.sendReliableMessage(); -} - - //static void LLPanelEvent::processEventInfoReply(LLMessageSystem *msg, void **) {