summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorayp <none@none>2009-11-02 15:32:51 +0200
committerayp <none@none>2009-11-02 15:32:51 +0200
commit04d59cdace3d93d62c86f5669003e8e24f8ccf9d (patch)
tree7c1638675883c0552782d7087d9c2f1bf9366d9e /indra
parent7ed3d636cb4ea31f5215f96005e41ee2bf22dd14 (diff)
implemented major task EXT-1718 Add drag-&-drop functinality to the new IM Floaters
--HG-- branch : product-engine
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llimfloater.cpp157
-rw-r--r--indra/newview/llimfloater.h15
2 files changed, 171 insertions, 1 deletions
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index f61a928813..dee86f4a22 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -51,6 +51,7 @@
#include "llviewerwindow.h"
#include "llvoicechannel.h"
#include "lltransientfloatermgr.h"
+#include "llinventorymodel.h"
@@ -602,6 +603,162 @@ void LLIMFloater::processSessionUpdate(const LLSD& session_update)
}
}
+BOOL LLIMFloater::handleDragAndDrop(S32 x, S32 y, MASK mask,
+ BOOL drop, EDragAndDropType cargo_type,
+ void *cargo_data, EAcceptance *accept,
+ std::string& tooltip_msg)
+{
+
+ if (mDialog == IM_NOTHING_SPECIAL)
+ {
+ LLToolDragAndDrop::handleGiveDragAndDrop(mOtherParticipantUUID, mSessionID, drop,
+ cargo_type, cargo_data, accept);
+ }
+
+ // handle case for dropping calling cards (and folders of calling cards) onto invitation panel for invites
+ else if (isInviteAllowed())
+ {
+ *accept = ACCEPT_NO;
+
+ if (cargo_type == DAD_CALLINGCARD)
+ {
+ if (dropCallingCard((LLInventoryItem*)cargo_data, drop))
+ {
+ *accept = ACCEPT_YES_MULTI;
+ }
+ }
+ else if (cargo_type == DAD_CATEGORY)
+ {
+ if (dropCategory((LLInventoryCategory*)cargo_data, drop))
+ {
+ *accept = ACCEPT_YES_MULTI;
+ }
+ }
+ }
+ return TRUE;
+}
+
+BOOL LLIMFloater::dropCallingCard(LLInventoryItem* item, BOOL drop)
+{
+ BOOL rv = isInviteAllowed();
+ if(rv && item && item->getCreatorUUID().notNull())
+ {
+ if(drop)
+ {
+ std::vector<LLUUID> ids;
+ ids.push_back(item->getCreatorUUID());
+ inviteToSession(ids);
+ }
+ }
+ else
+ {
+ // set to false if creator uuid is null.
+ rv = FALSE;
+ }
+ return rv;
+}
+
+BOOL LLIMFloater::dropCategory(LLInventoryCategory* category, BOOL drop)
+{
+ BOOL rv = isInviteAllowed();
+ if(rv && category)
+ {
+ LLInventoryModel::cat_array_t cats;
+ LLInventoryModel::item_array_t items;
+ LLUniqueBuddyCollector buddies;
+ gInventory.collectDescendentsIf(category->getUUID(),
+ cats,
+ items,
+ LLInventoryModel::EXCLUDE_TRASH,
+ buddies);
+ S32 count = items.count();
+ if(count == 0)
+ {
+ rv = FALSE;
+ }
+ else if(drop)
+ {
+ std::vector<LLUUID> ids;
+ ids.reserve(count);
+ for(S32 i = 0; i < count; ++i)
+ {
+ ids.push_back(items.get(i)->getCreatorUUID());
+ }
+ inviteToSession(ids);
+ }
+ }
+ return rv;
+}
+
+BOOL LLIMFloater::isInviteAllowed() const
+{
+
+ return ( (IM_SESSION_CONFERENCE_START == mDialog)
+ || (IM_SESSION_INVITE == mDialog) );
+}
+
+class LLSessionInviteResponder : public LLHTTPClient::Responder
+{
+public:
+ LLSessionInviteResponder(const LLUUID& session_id)
+ {
+ mSessionID = session_id;
+ }
+
+ void error(U32 statusNum, const std::string& reason)
+ {
+ llinfos << "Error inviting all agents to session" << llendl;
+ //throw something back to the viewer here?
+ }
+
+private:
+ LLUUID mSessionID;
+};
+
+BOOL LLIMFloater::inviteToSession(const std::vector<LLUUID>& ids)
+{
+ LLViewerRegion* region = gAgent.getRegion();
+ if (!region)
+ {
+ return FALSE;
+ }
+
+ S32 count = ids.size();
+
+ if( isInviteAllowed() && (count > 0) )
+ {
+ llinfos << "LLIMFloater::inviteToSession() - inviting participants" << llendl;
+
+ std::string url = region->getCapability("ChatSessionRequest");
+
+ LLSD data;
+
+ data["params"] = LLSD::emptyArray();
+ for (int i = 0; i < count; i++)
+ {
+ data["params"].append(ids[i]);
+ }
+
+ data["method"] = "invite";
+ data["session-id"] = mSessionID;
+ LLHTTPClient::post(
+ url,
+ data,
+ new LLSessionInviteResponder(
+ mSessionID));
+ }
+ else
+ {
+ llinfos << "LLIMFloater::inviteToSession -"
+ << " no need to invite agents for "
+ << mDialog << llendl;
+ // successful add, because everyone that needed to get added
+ // was added.
+ }
+
+ return TRUE;
+}
+
void LLIMFloater::addTypingIndicator(const LLIMInfo* im_info)
{
// We may have lost a "stop-typing" packet, don't add it twice
diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h
index d2aac57ee2..f5edb3188a 100644
--- a/indra/newview/llimfloater.h
+++ b/indra/newview/llimfloater.h
@@ -35,11 +35,13 @@
#include "lltransientdockablefloater.h"
#include "lllogchat.h"
+#include "lltooldraganddrop.h"
class LLLineEditor;
class LLPanelChatControlPanel;
class LLChatHistory;
-
+class LLInventoryItem;
+class LLInventoryCategory;
/**
* Individual IM window that appears at the bottom of the screen,
@@ -90,10 +92,21 @@ public:
void processIMTyping(const LLIMInfo* im_info, BOOL typing);
void processSessionUpdate(const LLSD& session_update);
+ BOOL handleDragAndDrop(S32 x, S32 y, MASK mask,
+ BOOL drop, EDragAndDropType cargo_type,
+ void *cargo_data, EAcceptance *accept,
+ std::string& tooltip_msg);
+
private:
// process focus events to set a currently active session
/* virtual */ void onFocusLost();
/* virtual */ void onFocusReceived();
+
+ BOOL dropCallingCard(LLInventoryItem* item, BOOL drop);
+ BOOL dropCategory(LLInventoryCategory* category, BOOL drop);
+
+ BOOL isInviteAllowed() const;
+ BOOL inviteToSession(const std::vector<LLUUID>& agent_ids);
static void onInputEditorFocusReceived( LLFocusableElement* caller, void* userdata );
static void onInputEditorFocusLost(LLFocusableElement* caller, void* userdata);