summaryrefslogtreecommitdiff
path: root/indra/newview/llimview.cpp
diff options
context:
space:
mode:
authorDon Kjer <don@lindenlab.com>2007-05-01 21:39:25 +0000
committerDon Kjer <don@lindenlab.com>2007-05-01 21:39:25 +0000
commit4ecb9cb63e4993b3b4bc65d73ed255139b5c3f75 (patch)
tree48d9bb9a1ae468ecdbd53cf21a598d66ee8eced3 /indra/newview/llimview.cpp
parentf5e9ce7e47694e349a4eb28b052016b11e1bdf81 (diff)
svn merge -r 59163:61099 svn+ssh://svn/svn/linden/branches/release-candidate into release
Diffstat (limited to 'indra/newview/llimview.cpp')
-rw-r--r--indra/newview/llimview.cpp350
1 files changed, 310 insertions, 40 deletions
diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index c093faa1ca..553c6ec6c3 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -23,6 +23,7 @@
#include "llviewerwindow.h"
#include "llresmgr.h"
#include "llfloaternewim.h"
+#include "llhttpnode.h"
#include "llimpanel.h"
#include "llresizebar.h"
#include "lltabcontainer.h"
@@ -35,7 +36,6 @@
#include "llcallingcard.h"
#include "lltoolbar.h"
-const EInstantMessage EVERYONE_DIALOG = IM_NOTHING_SPECIAL;
const EInstantMessage GROUP_DIALOG = IM_SESSION_GROUP_START;
const EInstantMessage DEFAULT_DIALOG = IM_NOTHING_SPECIAL;
@@ -50,6 +50,9 @@ LLIMView* gIMView = NULL;
static LLString sOnlyUserMessage;
static LLString sOfflineMessage;
+static std::map<std::string,LLString> sEventStringsMap;
+static std::map<std::string,LLString> sErrorStringsMap;
+static std::map<std::string,LLString> sForceCloseSessionMap;
//
// Helper Functions
//
@@ -63,7 +66,8 @@ static BOOL group_dictionary_sort( LLGroupData* a, LLGroupData* b )
// the other_participant_id is either an agent_id, a group_id, or an inventory
// folder item_id (collection of calling cards)
-static LLUUID compute_session_id(EInstantMessage dialog, const LLUUID& other_participant_id)
+static LLUUID compute_session_id(EInstantMessage dialog,
+ const LLUUID& other_participant_id)
{
LLUUID session_id;
if (IM_SESSION_GROUP_START == dialog)
@@ -71,6 +75,10 @@ static LLUUID compute_session_id(EInstantMessage dialog, const LLUUID& other_par
// slam group session_id to the group_id (other_participant_id)
session_id = other_participant_id;
}
+ else if (IM_SESSION_CONFERENCE_START == dialog)
+ {
+ session_id.generate();
+ }
else
{
LLUUID agent_id = gAgent.getID();
@@ -102,11 +110,34 @@ BOOL LLFloaterIM::postBuild()
{
requires("only_user_message", WIDGET_TYPE_TEXT_BOX);
requires("offline_message", WIDGET_TYPE_TEXT_BOX);
+ requires("generic_request_error", WIDGET_TYPE_TEXT_BOX);
+ requires("insufficient_perms_error", WIDGET_TYPE_TEXT_BOX);
+ requires("generic_request_error", WIDGET_TYPE_TEXT_BOX);
+ requires("add_session_event", WIDGET_TYPE_TEXT_BOX);
+ requires("message_session_event", WIDGET_TYPE_TEXT_BOX);
+ requires("removed_from_group", WIDGET_TYPE_TEXT_BOX);
if (checkRequirements())
{
sOnlyUserMessage = childGetText("only_user_message");
sOfflineMessage = childGetText("offline_message");
+
+ sErrorStringsMap["generic"] =
+ childGetText("generic_request_error");
+ sErrorStringsMap["unverified"] =
+ childGetText("insufficient_perms_error");
+ sErrorStringsMap["no_user_911"] =
+ childGetText("user_no_help");
+
+ sEventStringsMap["add"] = childGetText("add_session_event");;
+ sEventStringsMap["message"] =
+ childGetText("message_session_event");;
+ sEventStringsMap["teleport"] =
+ childGetText("teleport_session_event");;
+
+ sForceCloseSessionMap["removed"] =
+ childGetText("removed_from_group");
+
return TRUE;
}
return FALSE;
@@ -190,16 +221,12 @@ protected:
// static
EInstantMessage LLIMView::defaultIMTypeForAgent(const LLUUID& agent_id)
{
- EInstantMessage type = IM_SESSION_CARDLESS_START;
+ EInstantMessage type = IM_NOTHING_SPECIAL;
if(is_agent_friend(agent_id))
{
if(LLAvatarTracker::instance().isBuddyOnline(agent_id))
{
- type = IM_SESSION_ADD;
- }
- else
- {
- type = IM_SESSION_OFFLINE_ADD;
+ type = IM_SESSION_CONFERENCE_START;
}
}
return type;
@@ -327,11 +354,21 @@ void LLIMView::addMessage(
}
else
{
+ //if we have recently requsted to be dropped from a session
+ //but are still receiving messages from the session, don't make
+ //a new floater
+// if ( mSessionsDropRequested.has(session_id.asString()) )
+// {
+// return ;
+// }
+
const char* name = from;
if(session_name && (strlen(session_name)>1))
{
name = session_name;
}
+
+
floater = createFloater(new_session_id, other_participant_id, name, dialog, FALSE);
// When we get a new IM, and if you are a god, display a bit
@@ -407,18 +444,25 @@ BOOL LLIMView::isIMSessionOpen(const LLUUID& uuid)
// exists, it is brought forward. Specifying id = NULL results in an
// im session to everyone. Returns the uuid of the session.
LLUUID LLIMView::addSession(const std::string& name,
- EInstantMessage dialog,
- const LLUUID& other_participant_id)
+ EInstantMessage dialog,
+ const LLUUID& other_participant_id)
{
LLUUID session_id = compute_session_id(dialog, other_participant_id);
+
LLFloaterIMPanel* floater = findFloaterBySession(session_id);
if(!floater)
{
- floater = createFloater(session_id, other_participant_id, name, dialog, TRUE);
LLDynamicArray<LLUUID> ids;
ids.put(other_participant_id);
+
+ floater = createFloater(session_id,
+ other_participant_id,
+ name,
+ ids,
+ dialog,
+ TRUE);
+
noteOfflineUsers(floater, ids);
- floater->addParticipants(ids);
mTalkFloater->showFloater(floater);
}
else
@@ -433,30 +477,34 @@ LLUUID LLIMView::addSession(const std::string& name,
// Adds a session using the given session_id. If the session already exists
// the dialog type is assumed correct. Returns the uuid of the session.
LLUUID LLIMView::addSession(const std::string& name,
- EInstantMessage dialog,
- const LLUUID& session_id,
- const LLDynamicArray<LLUUID>& ids)
+ EInstantMessage dialog,
+ const LLUUID& other_participant_id,
+ const LLDynamicArray<LLUUID>& ids)
{
if (0 == ids.getLength())
{
return LLUUID::null;
}
- LLUUID other_participant_id = ids[0];
- LLUUID new_session_id = session_id;
- if (new_session_id.isNull())
- {
- new_session_id = compute_session_id(dialog, other_participant_id);
- }
+ LLUUID session_id = compute_session_id(dialog,
+ other_participant_id);
- LLFloaterIMPanel* floater = findFloaterBySession(new_session_id);
+ LLFloaterIMPanel* floater = findFloaterBySession(session_id);
if(!floater)
{
- // On creation, use the first element of ids as the "other_participant_id"
- floater = createFloater(new_session_id, other_participant_id, name, dialog, TRUE);
+ // On creation, use the first element of ids as the
+ // "other_participant_id"
+ floater = createFloater(session_id,
+ other_participant_id,
+ name,
+ ids,
+ dialog,
+ TRUE);
+
+ if ( !floater ) return LLUUID::null;
+
noteOfflineUsers(floater, ids);
}
- floater->addParticipants(ids);
mTalkFloater->showFloater(floater);
//mTabContainer->selectTabPanel(panel);
floater->setInputFocus(TRUE);
@@ -474,6 +522,11 @@ void LLIMView::removeSession(const LLUUID& session_id)
mTalkFloater->removeFloater(floater);
//mTabContainer->removeTabPanel(floater);
}
+
+// if ( session_id.notNull() )
+// {
+// mSessionsDropRequested[session_id.asString()] = LLSD();
+// }
}
void LLIMView::refresh()
@@ -499,8 +552,7 @@ void LLIMView::refresh()
group;
group = group_list.getNextData())
{
- mNewIMFloater->addTarget(group->mID, group->mName,
- (void*)(&GROUP_DIALOG), TRUE, FALSE);
+ mNewIMFloater->addGroup(group->mID, (void*)(&GROUP_DIALOG), TRUE, FALSE);
}
// build a set of buddies in the current buddy list.
@@ -520,13 +572,6 @@ void LLIMView::refresh()
{
mNewIMFloater->addAgent((*it).second, (void*)(&DEFAULT_DIALOG), FALSE);
}
-
- if(gAgent.isGodlike())
- {
- // XUI:translate
- mNewIMFloater->addTarget(LLUUID::null, "All Residents, All Grids",
- (void*)(&EVERYONE_DIALOG), TRUE, FALSE);
- }
mNewIMFloater->setScrollPos( old_scroll_pos );
}
@@ -600,12 +645,17 @@ void LLIMView::disconnectAllSessions()
std::set<LLViewHandle>::iterator handle_it;
for(handle_it = mFloaters.begin();
handle_it != mFloaters.end();
- ++handle_it)
+ )
{
floater = (LLFloaterIMPanel*)LLFloater::getFloaterByHandle(*handle_it);
+
+ // MUST do this BEFORE calling floater->onClose() because that may remove the item from the set, causing the subsequent increment to crash.
+ ++handle_it;
+
if (floater)
{
floater->setEnabled(FALSE);
+ floater->onClose(TRUE);
}
}
}
@@ -643,16 +693,45 @@ BOOL LLIMView::hasSession(const LLUUID& session_id)
// consistency. Returns the pointer, caller (the class instance since
// it is a private method) is not responsible for deleting the
// pointer. Add the floater to this but do not select it.
-LLFloaterIMPanel* LLIMView::createFloater(const LLUUID& session_id,
- const LLUUID& other_participant_id,
- const std::string& session_label,
- EInstantMessage dialog,
- BOOL user_initiated)
+LLFloaterIMPanel* LLIMView::createFloater(
+ const LLUUID& session_id,
+ const LLUUID& other_participant_id,
+ const std::string& session_label,
+ EInstantMessage dialog,
+ BOOL user_initiated)
+{
+ if (session_id.isNull())
+ {
+ llwarns << "Creating LLFloaterIMPanel with null session ID" << llendl;
+ }
+
+ llinfos << "LLIMView::createFloater: from " << other_participant_id
+ << " in session " << session_id << llendl;
+ LLFloaterIMPanel* floater = new LLFloaterIMPanel(session_label,
+ LLRect(),
+ session_label,
+ session_id,
+ other_participant_id,
+ dialog);
+ LLTabContainerCommon::eInsertionPoint i_pt = user_initiated ? LLTabContainerCommon::RIGHT_OF_CURRENT : LLTabContainerCommon::END;
+ mTalkFloater->addFloater(floater, FALSE, i_pt);
+ mFloaters.insert(floater->getHandle());
+ return floater;
+}
+
+LLFloaterIMPanel* LLIMView::createFloater(
+ const LLUUID& session_id,
+ const LLUUID& other_participant_id,
+ const std::string& session_label,
+ const LLDynamicArray<LLUUID>& ids,
+ EInstantMessage dialog,
+ BOOL user_initiated)
{
if (session_id.isNull())
{
llwarns << "Creating LLFloaterIMPanel with null session ID" << llendl;
}
+
llinfos << "LLIMView::createFloater: from " << other_participant_id
<< " in session " << session_id << llendl;
LLFloaterIMPanel* floater = new LLFloaterIMPanel(session_label,
@@ -660,6 +739,7 @@ LLFloaterIMPanel* LLIMView::createFloater(const LLUUID& session_id,
session_label,
session_id,
other_participant_id,
+ ids,
dialog);
LLTabContainerCommon::eInsertionPoint i_pt = user_initiated ? LLTabContainerCommon::RIGHT_OF_CURRENT : LLTabContainerCommon::END;
mTalkFloater->addFloater(floater, FALSE, i_pt);
@@ -715,3 +795,193 @@ void LLIMView::processIMTypingCore(const LLIMInfo* im_info, BOOL typing)
floater->processIMTyping(im_info, typing);
}
}
+
+void LLIMView::updateFloaterSessionID(const LLUUID& old_session_id,
+ const LLUUID& new_session_id)
+{
+ LLFloaterIMPanel* floater = findFloaterBySession(old_session_id);
+ if (floater)
+ {
+ floater->sessionInitReplyReceived(new_session_id);
+ }
+}
+
+void LLIMView::onDropRequestReplyReceived(const LLUUID& session_id)
+{
+ mSessionsDropRequested.erase(session_id.asString());
+}
+
+void onConfirmForceCloseError(S32 option, void* data)
+{
+ //only 1 option really
+ LLFloaterIMPanel* floater = ((LLFloaterIMPanel*) data);
+
+ if ( floater ) floater->onClose(FALSE);
+}
+
+class LLViewerIMSessionStartReply : public LLHTTPNode
+{
+public:
+ virtual void describe(Description& desc) const
+ {
+ desc.shortInfo("Used for receiving a reply to a request to initialize an IM session");
+ desc.postAPI();
+ desc.input(
+ "{\"client_session_id\": UUID, \"session_id\": UUID, \"success\" boolean, \"reason\": string");
+ desc.source(__FILE__, __LINE__);
+ }
+
+ virtual void post(ResponsePtr response,
+ const LLSD& context,
+ const LLSD& input) const
+ {
+ LLSD body;
+ LLUUID temp_session_id;
+ LLUUID session_id;
+ bool success;
+
+ body = input["body"];
+ success = body["success"].asBoolean();
+ temp_session_id = body["temp_session_id"].asUUID();
+
+ if ( success )
+ {
+ session_id = body["session_id"].asUUID();
+ gIMView->updateFloaterSessionID(temp_session_id,
+ session_id);
+ }
+ else
+ {
+ //throw an error dialog and close the temp session's
+ //floater
+ LLFloaterIMPanel* floater =
+ gIMView->findFloaterBySession(temp_session_id);
+ if (floater)
+ {
+ LLString::format_map_t args;
+ args["[REASON]"] =
+ sErrorStringsMap[body["error"].asString()];
+ args["[RECIPIENT]"] = floater->getTitle();
+
+ gViewerWindow->alertXml("IMSessionStartError",
+ args,
+ onConfirmForceCloseError,
+ floater);
+
+ }
+ }
+ }
+};
+
+class LLViewerIMSessionEventReply : public LLHTTPNode
+{
+public:
+ virtual void describe(Description& desc) const
+ {
+ desc.shortInfo("Used for receiving a reply to a IM session event");
+ desc.postAPI();
+ desc.input(
+ "{\"event\": string, \"reason\": string, \"success\": boolean, \"session_id\": UUID");
+ desc.source(__FILE__, __LINE__);
+ }
+
+ virtual void post(ResponsePtr response,
+ const LLSD& context,
+ const LLSD& input) const
+ {
+ LLUUID session_id;
+ bool success;
+
+ LLSD body = input["body"];
+ success = body["success"].asBoolean();
+ session_id = body["session_id"].asUUID();
+
+ if ( !success )
+ {
+ //throw an error dialog
+ LLFloaterIMPanel* floater =
+ gIMView->findFloaterBySession(session_id);
+ if (floater)
+ {
+ LLString::format_map_t args;
+ args["[REASON]"] =
+ sErrorStringsMap[body["error"].asString()];
+ args["[EVENT]"] =
+ sEventStringsMap[body["event"].asString()];
+ args["[RECIPIENT]"] = floater->getTitle();
+
+ gViewerWindow->alertXml("IMSessionEventError",
+ args);
+ }
+ }
+ }
+};
+
+class LLViewerForceCloseIMSession: public LLHTTPNode
+{
+public:
+ virtual void post(ResponsePtr response,
+ const LLSD& context,
+ const LLSD& input) const
+ {
+ LLUUID session_id;
+ LLString reason;
+
+ session_id = input["body"]["session_id"].asUUID();
+ reason = input["body"]["reason"].asString();
+
+ LLFloaterIMPanel* floater =
+ gIMView ->findFloaterBySession(session_id);
+
+ if ( floater )
+ {
+ LLString::format_map_t args;
+
+ args["[NAME]"] = floater->getTitle();
+ args["[REASON]"] = sForceCloseSessionMap[reason];
+
+ gViewerWindow->alertXml("ForceCloseIMSession",
+ args,
+ onConfirmForceCloseError,
+ floater);
+ }
+ }
+};
+
+class LLViewerIMSessionDropReply : public LLHTTPNode
+{
+public:
+ virtual void post(ResponsePtr response,
+ const LLSD& context,
+ const LLSD& input) const
+ {
+ LLUUID session_id;
+ bool success;
+
+ success = input["body"]["success"].asBoolean();
+ session_id = input["body"]["session_id"].asUUID();
+
+ if ( !success )
+ {
+ //throw an error alert?
+ }
+
+ gIMView->onDropRequestReplyReceived(session_id);
+ }
+};
+
+LLHTTPRegistration<LLViewerIMSessionStartReply>
+ gHTTPRegistrationMessageImsessionstartreply(
+ "/message/IMSessionStartReply");
+
+LLHTTPRegistration<LLViewerIMSessionEventReply>
+ gHTTPRegistrationMessageImsessioneventreply(
+ "/message/IMSessionEventReply");
+
+LLHTTPRegistration<LLViewerForceCloseIMSession>
+ gHTTPRegistrationMessageForceCloseImSession(
+ "/message/ForceCloseIMSession");
+
+LLHTTPRegistration<LLViewerIMSessionDropReply>
+ gHTTPRegistrationMessageImSessionDropReply(
+ "/message/IMSessionDropReply");