diff options
author | Jacek Antonelli | 2008-08-15 23:45:07 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:07 -0500 |
commit | 8465910c79b8e746e04fd581cca2d60399e569b9 (patch) | |
tree | f43fec3e83c46e0d6190dca923d6fb268b52ffdd /linden/indra/newview/llviewerinventory.cpp | |
parent | Second Life viewer sources 1.18.2.1 (diff) | |
download | meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.zip meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.tar.gz meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.tar.bz2 meta-impy-8465910c79b8e746e04fd581cca2d60399e569b9.tar.xz |
Second Life viewer sources 1.18.3.2-RC
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llviewerinventory.cpp | 88 |
1 files changed, 66 insertions, 22 deletions
diff --git a/linden/indra/newview/llviewerinventory.cpp b/linden/indra/newview/llviewerinventory.cpp index 6372ba8..c9cd52f 100644 --- a/linden/indra/newview/llviewerinventory.cpp +++ b/linden/indra/newview/llviewerinventory.cpp | |||
@@ -43,6 +43,9 @@ | |||
43 | 43 | ||
44 | #include "llinventoryview.h" | 44 | #include "llinventoryview.h" |
45 | 45 | ||
46 | #include "llviewerregion.h" | ||
47 | #include "llviewerobjectlist.h" | ||
48 | |||
46 | ///---------------------------------------------------------------------------- | 49 | ///---------------------------------------------------------------------------- |
47 | /// Local function declarations, constants, enums, and typedefs | 50 | /// Local function declarations, constants, enums, and typedefs |
48 | ///---------------------------------------------------------------------------- | 51 | ///---------------------------------------------------------------------------- |
@@ -551,13 +554,27 @@ void inventory_reliable_callback(void**, S32 status) | |||
551 | } | 554 | } |
552 | } | 555 | } |
553 | */ | 556 | */ |
557 | LLInventoryCallbackManager *LLInventoryCallbackManager::sInstance = NULL; | ||
558 | |||
554 | LLInventoryCallbackManager::LLInventoryCallbackManager() : | 559 | LLInventoryCallbackManager::LLInventoryCallbackManager() : |
555 | mLastCallback(0) | 560 | mLastCallback(0) |
556 | { | 561 | { |
562 | if( sInstance != NULL ) | ||
563 | { | ||
564 | llwarns << "LLInventoryCallbackManager::LLInventoryCallbackManager: unexpected multiple instances" << llendl; | ||
565 | return; | ||
566 | } | ||
567 | sInstance = this; | ||
557 | } | 568 | } |
558 | 569 | ||
559 | LLInventoryCallbackManager::~LLInventoryCallbackManager() | 570 | LLInventoryCallbackManager::~LLInventoryCallbackManager() |
560 | { | 571 | { |
572 | if( sInstance != this ) | ||
573 | { | ||
574 | llwarns << "LLInventoryCallbackManager::~LLInventoryCallbackManager: unexpected multiple instances" << llendl; | ||
575 | return; | ||
576 | } | ||
577 | sInstance = NULL; | ||
561 | } | 578 | } |
562 | 579 | ||
563 | U32 LLInventoryCallbackManager::registerCB(LLPointer<LLInventoryCallback> cb) | 580 | U32 LLInventoryCallbackManager::registerCB(LLPointer<LLInventoryCallback> cb) |
@@ -701,29 +718,56 @@ void move_inventory_item( | |||
701 | gAgent.sendReliableMessage(); | 718 | gAgent.sendReliableMessage(); |
702 | } | 719 | } |
703 | 720 | ||
704 | void _copy_inventory_from_notecard_hdr(const LLUUID& object_id, const LLUUID& notecard_inv_id) | 721 | class LLCopyInventoryFromNotecardResponder : public LLHTTPClient::Responder |
705 | { | 722 | { |
706 | LLMessageSystem* msg = gMessageSystem; | 723 | public: |
707 | msg->newMessageFast(_PREHASH_CopyInventoryFromNotecard); | 724 | //If we get back a normal response, handle it here |
708 | msg->nextBlock(_PREHASH_AgentData); | 725 | virtual void result(const LLSD& content) |
709 | msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); | 726 | { |
710 | msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); | 727 | // What do we do here? |
711 | msg->nextBlock(_PREHASH_NotecardData); | 728 | llinfos << "CopyInventoryFromNotecard request successful." << llendl; |
712 | msg->addUUIDFast(_PREHASH_NotecardItemID, notecard_inv_id); | 729 | } |
713 | msg->addUUIDFast(_PREHASH_ObjectID, object_id); | 730 | |
714 | } | 731 | //If we get back an error (not found, etc...), handle it here |
732 | virtual void error(U32 status, const std::string& reason) | ||
733 | { | ||
734 | llinfos << "LLCopyInventoryFromNotecardResponder::error " | ||
735 | << status << ": " << reason << llendl; | ||
736 | } | ||
737 | }; | ||
715 | 738 | ||
716 | void copy_inventory_from_notecard(const LLUUID& object_id, const LLUUID& notecard_inv_id, const LLInventoryItem *src) | 739 | void copy_inventory_from_notecard(const LLUUID& object_id, const LLUUID& notecard_inv_id, const LLInventoryItem *src, U32 callback_id) |
717 | { | 740 | { |
718 | LLMessageSystem* msg = gMessageSystem; | 741 | LLSD body; |
719 | /* | 742 | LLViewerRegion* viewer_region = NULL; |
720 | * I was going to handle multiple inventory items here, but then I realized that | 743 | if(object_id.notNull()) |
721 | * we are only handling one at a time. Perhaps you can only select one at a | 744 | { |
722 | * time from the notecard? | 745 | LLViewerObject* vo = gObjectList.findObject(object_id); |
723 | */ | 746 | if(vo) |
724 | _copy_inventory_from_notecard_hdr(object_id, notecard_inv_id); | 747 | { |
725 | msg->nextBlockFast(_PREHASH_InventoryData); | 748 | viewer_region = vo->getRegion(); |
726 | msg->addUUIDFast(_PREHASH_ItemID, src->getUUID()); | 749 | } |
727 | msg->addUUIDFast(_PREHASH_FolderID, gInventory.findCategoryUUIDForType(src->getType())); | 750 | } |
728 | gAgent.sendReliableMessage(); | 751 | |
752 | // Fallback to the agents region if for some reason the | ||
753 | // object isn't found in the viewer. | ||
754 | if(!viewer_region) | ||
755 | { | ||
756 | viewer_region = gAgent.getRegion(); | ||
757 | } | ||
758 | |||
759 | if(viewer_region) | ||
760 | { | ||
761 | std::string url = viewer_region->getCapability("CopyInventoryFromNotecard"); | ||
762 | if (!url.empty()) | ||
763 | { | ||
764 | body["notecard-id"] = notecard_inv_id; | ||
765 | body["object-id"] = object_id; | ||
766 | body["item-id"] = src->getUUID(); | ||
767 | body["folder-id"] = gInventory.findCategoryUUIDForType(src->getType()); | ||
768 | body["callback-id"] = (LLSD::Integer)callback_id; | ||
769 | |||
770 | LLHTTPClient::post(url, body, new LLCopyInventoryFromNotecardResponder()); | ||
771 | } | ||
772 | } | ||
729 | } | 773 | } |