diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2011-05-02 21:02:53 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2011-05-02 21:02:53 -0400 |
commit | a13541bd0fc622f555da774bcb3daf2227868f2e (patch) | |
tree | 40442503a805ef75c010f47e92cf823a6c19a8ba /indra/newview | |
parent | 8f720b59d35d172b0a34ff73c7724d9bae258aa2 (diff) | |
parent | 6a5de7a829ca4fb2af37ff24098acf582ee93e9e (diff) |
Automated merge with file:///Users/nat/linden/viewer-summary-json
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/newview/groupchatlistener.cpp | 59 | ||||
-rw-r--r-- | indra/newview/groupchatlistener.h | 23 | ||||
-rw-r--r-- | indra/newview/llagentlistener.cpp | 24 | ||||
-rw-r--r-- | indra/newview/llagentlistener.h | 1 | ||||
-rw-r--r-- | indra/newview/llgroupactions.cpp | 9 | ||||
-rw-r--r-- | indra/newview/llgroupactions.h | 2 |
7 files changed, 116 insertions, 4 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index b1cb10665b..b2053d68a3 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -70,6 +70,7 @@ include_directories( ) set(viewer_SOURCE_FILES + groupchatlistener.cpp llagent.cpp llagentaccess.cpp llagentcamera.cpp @@ -612,6 +613,7 @@ endif (LINUX) set(viewer_HEADER_FILES CMakeLists.txt ViewerInstall.cmake + groupchatlistener.h llagent.h llagentaccess.h llagentcamera.h diff --git a/indra/newview/groupchatlistener.cpp b/indra/newview/groupchatlistener.cpp new file mode 100644 index 0000000000..3758896b85 --- /dev/null +++ b/indra/newview/groupchatlistener.cpp @@ -0,0 +1,59 @@ +/** + * @file groupchatlistener.cpp + * @author Nat Goodspeed + * @date 2011-04-11 + * @brief Implementation for groupchatlistener. + * + * $LicenseInfo:firstyear=2011&license=internal$ + * Copyright (c) 2011, Linden Research, Inc. + * $/LicenseInfo$ + */ + +// Precompiled header +#include "llviewerprecompiledheaders.h" +// associated header +#include "groupchatlistener.h" +// STL headers +// std headers +// external library headers +// other Linden headers +#include "llgroupactions.h" +#include "llimview.h" + + +namespace { + void startIm_wrapper(LLSD const & event) + { + LLUUID session_id = LLGroupActions::startIM(event["id"].asUUID()); + sendReply(LLSDMap("session_id", LLSD(session_id)), event); + } + + void send_message_wrapper(const std::string& text, const LLUUID& session_id, const LLUUID& group_id) + { + LLIMModel::sendMessage(text, session_id, group_id, IM_SESSION_GROUP_START); + } +} + + +GroupChatListener::GroupChatListener(): + LLEventAPI("GroupChat", + "API to enter, leave, send and intercept group chat messages") +{ + add("startIM", + "Enter a group chat in group with UUID [\"id\"]\n" + "Assumes the logged-in agent is already a member of this group.", + &startIm_wrapper); + add("endIM", + "Leave a group chat in group with UUID [\"id\"]\n" + "Assumes a prior successful startIM request.", + &LLGroupActions::endIM, + LLSDArray("id")); + add("sendIM", + "send a groupchat IM", + &send_message_wrapper, + LLSDArray("text")("session_id")("group_id")); +} +/* + static void sendMessage(const std::string& utf8_text, const LLUUID& im_session_id, + const LLUUID& other_participant_id, EInstantMessage dialog); +*/ diff --git a/indra/newview/groupchatlistener.h b/indra/newview/groupchatlistener.h new file mode 100644 index 0000000000..719e3e877f --- /dev/null +++ b/indra/newview/groupchatlistener.h @@ -0,0 +1,23 @@ +/** + * @file groupchatlistener.h + * @author Nat Goodspeed + * @date 2011-04-11 + * @brief + * + * $LicenseInfo:firstyear=2011&license=internal$ + * Copyright (c) 2011, Linden Research, Inc. + * $/LicenseInfo$ + */ + +#if ! defined(LL_GROUPCHATLISTENER_H) +#define LL_GROUPCHATLISTENER_H + +#include "lleventapi.h" + +class GroupChatListener: public LLEventAPI +{ +public: + GroupChatListener(); +}; + +#endif /* ! defined(LL_GROUPCHATLISTENER_H) */ diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp index ed24febf41..9cea33c7c6 100644 --- a/indra/newview/llagentlistener.cpp +++ b/indra/newview/llagentlistener.cpp @@ -64,6 +64,12 @@ LLAgentListener::LLAgentListener(LLAgent &agent) "[\"quat\"]: array of [x, y, z, w] quaternion values", &LLAgentListener::getAxes, LLSDMap("reply", LLSD())); + add("getGroups", + "Send on [\"reply\"], in [\"groups\"], an array describing agent's groups:\n" + "[\"id\"]: UUID of group\n" + "[\"name\"]: name of group", + &LLAgentListener::getGroups, + LLSDMap("reply", LLSD())); } void LLAgentListener::requestTeleport(LLSD const & event_data) const @@ -140,3 +146,21 @@ void LLAgentListener::getAxes(const LLSD& event) const ("euler", LLSDMap("roll", roll)("pitch", pitch)("yaw", yaw)), event); } + +void LLAgentListener::getGroups(const LLSD& event) const +{ + LLSD reply(LLSD::emptyArray()); + for (LLDynamicArray<LLGroupData>::const_iterator + gi(mAgent.mGroups.begin()), gend(mAgent.mGroups.end()); + gi != gend; ++gi) + { + reply.append(LLSDMap + ("id", gi->mID) + ("name", gi->mName) + ("insignia", gi->mInsigniaID) + ("notices", bool(gi->mAcceptNotices)) + ("display", bool(gi->mListInProfile)) + ("contrib", gi->mContribution)); + } + sendReply(LLSDMap("groups", reply), event); +} diff --git a/indra/newview/llagentlistener.h b/indra/newview/llagentlistener.h index 0aa58d0b16..5a89a99f6a 100644 --- a/indra/newview/llagentlistener.h +++ b/indra/newview/llagentlistener.h @@ -46,6 +46,7 @@ private: void requestStand(LLSD const & event_data) const; void resetAxes(const LLSD& event) const; void getAxes(const LLSD& event) const; + void getGroups(const LLSD& event) const; private: LLAgent & mAgent; diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp index 7c56e610ce..97fa551441 100644 --- a/indra/newview/llgroupactions.cpp +++ b/indra/newview/llgroupactions.cpp @@ -40,10 +40,12 @@ #include "llsidetray.h" #include "llstatusbar.h" // can_afford_transaction() #include "llimfloater.h" +#include "groupchatlistener.h" // // Globals // +static GroupChatListener sGroupChatListener; class LLGroupHandler : public LLCommandHandler { @@ -320,10 +322,9 @@ void LLGroupActions::closeGroup(const LLUUID& group_id) // static -void LLGroupActions::startIM(const LLUUID& group_id) +LLUUID LLGroupActions::startIM(const LLUUID& group_id) { - if (group_id.isNull()) - return; + if (group_id.isNull()) return LLUUID::null; LLGroupData group_data; if (gAgent.getGroupData(group_id, group_data)) @@ -337,12 +338,14 @@ void LLGroupActions::startIM(const LLUUID& group_id) LLIMFloater::show(session_id); } make_ui_sound("UISndStartIM"); + return session_id; } else { // this should never happen, as starting a group IM session // relies on you belonging to the group and hence having the group data make_ui_sound("UISndInvalidOp"); + return LLUUID::null; } } diff --git a/indra/newview/llgroupactions.h b/indra/newview/llgroupactions.h index c52a25818b..3f9852f194 100644 --- a/indra/newview/llgroupactions.h +++ b/indra/newview/llgroupactions.h @@ -87,7 +87,7 @@ public: /** * Start group instant messaging session. */ - static void startIM(const LLUUID& group_id); + static LLUUID startIM(const LLUUID& group_id); /** * End group instant messaging session. |