From 37bf11cc138565f866b4deea519543832c7a3887 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 12 Apr 2011 11:01:21 -0400 Subject: CHOP-581: add getGroups query to LLAgent listener --- indra/newview/llagentlistener.cpp | 24 ++++++++++++++++++++++++ indra/newview/llagentlistener.h | 1 + 2 files changed, 25 insertions(+) (limited to 'indra/newview') diff --git a/indra/newview/llagentlistener.cpp b/indra/newview/llagentlistener.cpp index c453fe91f4..d6de25e42e 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::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; -- cgit v1.2.3 From e9f6de28b2e2be98bd8bb9e62fcffafebd29a939 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 12 Apr 2011 11:04:19 -0400 Subject: CHOP-581: Preliminary attempt to add enter/leave group chat hooks. Unstable! Using present "startIM" is known to crash the Mac viewer. Committing to migrate to different dev box for further debugging. --- indra/newview/CMakeLists.txt | 2 ++ indra/newview/groupchatlistener.cpp | 36 ++++++++++++++++++++++++++++++++++++ indra/newview/groupchatlistener.h | 23 +++++++++++++++++++++++ indra/newview/llgroupactions.cpp | 2 ++ 4 files changed, 63 insertions(+) create mode 100644 indra/newview/groupchatlistener.cpp create mode 100644 indra/newview/groupchatlistener.h (limited to 'indra/newview') 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..9b463c9a3f --- /dev/null +++ b/indra/newview/groupchatlistener.cpp @@ -0,0 +1,36 @@ +/** + * @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" + +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.", + &LLGroupActions::startIM, + LLSDArray("id")); + add("endIM", + "Leave a group chat in group with UUID [\"id\"]\n" + "Assumes a prior successful startIM request.", + &LLGroupActions::endIM, + LLSDArray("id")); +} 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/llgroupactions.cpp b/indra/newview/llgroupactions.cpp index 7c56e610ce..92fd84ff5b 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 { -- cgit v1.2.3 From 96f5a8e19cf36a59cd3b5afe413ec8e2d5fc33ce Mon Sep 17 00:00:00 2001 From: "Andrew A. de Laix" Date: Thu, 14 Apr 2011 15:23:09 -0700 Subject: add testing hook to send a group chat IM. --- indra/newview/groupchatlistener.cpp | 27 +++++++++++++++++++++++++-- indra/newview/llgroupactions.cpp | 7 ++++--- indra/newview/llgroupactions.h | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/groupchatlistener.cpp b/indra/newview/groupchatlistener.cpp index 9b463c9a3f..d9c705adf0 100644 --- a/indra/newview/groupchatlistener.cpp +++ b/indra/newview/groupchatlistener.cpp @@ -18,6 +18,22 @@ // 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", @@ -26,11 +42,18 @@ GroupChatListener::GroupChatListener(): add("startIM", "Enter a group chat in group with UUID [\"id\"]\n" "Assumes the logged-in agent is already a member of this group.", - &LLGroupActions::startIM, - LLSDArray("id")); + &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); +*/ \ No newline at end of file diff --git a/indra/newview/llgroupactions.cpp b/indra/newview/llgroupactions.cpp index 92fd84ff5b..97fa551441 100644 --- a/indra/newview/llgroupactions.cpp +++ b/indra/newview/llgroupactions.cpp @@ -322,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)) @@ -339,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. -- cgit v1.2.3 From 7187698f32031bf0e3cdb198aa0caa188038b88e Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 19 Apr 2011 21:47:34 -0400 Subject: Add newline to final line of groupchatlistener.cpp. The Linux compiler isn't happy when source files don't end with newline. --- indra/newview/groupchatlistener.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/groupchatlistener.cpp b/indra/newview/groupchatlistener.cpp index d9c705adf0..3758896b85 100644 --- a/indra/newview/groupchatlistener.cpp +++ b/indra/newview/groupchatlistener.cpp @@ -56,4 +56,4 @@ GroupChatListener::GroupChatListener(): /* static void sendMessage(const std::string& utf8_text, const LLUUID& im_session_id, const LLUUID& other_participant_id, EInstantMessage dialog); -*/ \ No newline at end of file +*/ -- cgit v1.2.3