summaryrefslogtreecommitdiff
path: root/indra/newview/llimview.cpp
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2009-10-21 04:58:23 +0000
committerSteven Bennetts <steve@lindenlab.com>2009-10-21 04:58:23 +0000
commit6f41747bc4d8afcb2b19ac02295575031bcf9021 (patch)
tree1e83d8fcf7af6b9416b49bb46cb9e7cf15abffbc /indra/newview/llimview.cpp
parent57fca109cae3105b6bc1319e9886c16631bc7374 (diff)
Merging revisions 2112-2128 of https://svn.aws.productengine.com/secondlife/pe/stable-2 into P:\svn\viewer-2.0.0, respecting ancestry
* Bugs: EXT-1605 EXT-1506 EXT-1663 EXT-1616 EXT-1599 EXT-1587 * Dev: EXT-748 EXT-1447 * IM Cleanup
Diffstat (limited to 'indra/newview/llimview.cpp')
-rw-r--r--indra/newview/llimview.cpp69
1 files changed, 41 insertions, 28 deletions
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 20b9cc1f8b..9974de0ef1 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -93,30 +93,45 @@ std::map<LLUUID, LLIMModel::LLIMSession*> LLIMModel::sSessionsMap;
void toast_callback(const LLSD& msg){
- // do not show toast in busy mode
- if (gAgent.getBusy())
+ // do not show toast in busy mode or it goes from agent
+ if (gAgent.getBusy() || gAgent.getID() == msg["from_id"])
{
return;
}
-
- //we send notifications to reset counter also
- if (msg["num_unread"].asInteger())
+
+ // check whether incoming IM belongs to an active session or not
+ if (LLIMModel::getInstance()->getActiveSessionID() == msg["session_id"])
{
- LLSD args;
- args["MESSAGE"] = msg["message"];
- args["TIME"] = msg["time"];
- args["FROM"] = msg["from"];
- args["FROM_ID"] = msg["from_id"];
- args["SESSION_ID"] = msg["session_id"];
+ return;
+ }
+
+ LLSD args;
+ args["MESSAGE"] = msg["message"];
+ args["TIME"] = msg["time"];
+ args["FROM"] = msg["from"];
+ args["FROM_ID"] = msg["from_id"];
+ args["SESSION_ID"] = msg["session_id"];
- LLNotifications::instance().add("IMToast", args, LLSD(), boost::bind(&LLIMFloater::show, msg["session_id"].asUUID()));
+ LLNotifications::instance().add("IMToast", args, LLSD(), boost::bind(&LLIMFloater::show, msg["session_id"].asUUID()));
+}
+
+void LLIMModel::setActiveSessionID(const LLUUID& session_id)
+{
+ // check if such an ID really exists
+ if (!findIMSession(session_id))
+ {
+ llwarns << "Trying to set as active a non-existent session!" << llendl;
+ return;
}
+
+ mActiveSessionID = session_id;
}
LLIMModel::LLIMModel()
{
- addChangedCallback(LLIMFloater::newIMCallback);
- addChangedCallback(toast_callback);
+ addNewMsgCallback(LLIMFloater::newIMCallback);
+ addNoUnreadMsgsCallback(LLIMFloater::newIMCallback);
+ addNewMsgCallback(toast_callback);
}
@@ -311,7 +326,7 @@ std::list<LLSD> LLIMModel::getMessages(LLUUID session_id, int start_index)
LLSD arg;
arg["session_id"] = session_id;
arg["num_unread"] = 0;
- mChangedSignal(arg);
+ mNoUnreadMsgsSignal(arg);
// TODO: in the future is there a more efficient way to return these
//of course there is - return as parameter (IB)
@@ -390,7 +405,7 @@ bool LLIMModel::addMessage(LLUUID session_id, std::string from, LLUUID from_id,
arg["from"] = from;
arg["from_id"] = from_id;
arg["time"] = LLLogChat::timestamp(false);
- mChangedSignal(arg);
+ mNewMsgSignal(arg);
return true;
}
@@ -623,11 +638,6 @@ void LLIMModel::sendMessage(const std::string& utf8_text,
//*TODO should be deleted, because speaker manager updates through callback the recent list
LLRecentPeople::instance().add(other_participant_id);
}
-
-boost::signals2::connection LLIMModel::addChangedCallback( boost::function<void (const LLSD& data)> cb )
-{
- return mChangedSignal.connect(cb);
-}
void session_starter_helper(
const LLUUID& temp_session_id,
@@ -1274,13 +1284,6 @@ void LLIMMgr::addMessage(
return;
}
- //not sure why...but if it is from ourselves we set the target_id
- //to be NULL
- if( other_participant_id == gAgent.getID() )
- {
- other_participant_id = LLUUID::null;
- }
-
LLFloaterIMPanel* floater;
LLUUID new_session_id = session_id;
if (new_session_id.isNull())
@@ -1549,6 +1552,16 @@ LLUUID LLIMMgr::addSession(
return session_id;
}
+bool LLIMMgr::leaveSession(const LLUUID& session_id)
+{
+ LLIMModel::LLIMSession* im_session = LLIMModel::getInstance()->findIMSession(session_id);
+ if (!im_session) return false;
+
+ LLIMModel::getInstance()->sendLeaveSession(session_id, im_session->mOtherParticipantID);
+ gIMMgr->removeSession(session_id);
+ return true;
+}
+
// This removes the panel referenced by the uuid, and then restores
// internal consistency. The internal pointer is not deleted? Did you mean
// a pointer to the corresponding LLIMSession? Session data is cleared now.