diff options
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llinventory/llinventory.h | 4 | ||||
-rw-r--r-- | indra/llinventory/llpermissions.h | 6 | ||||
-rw-r--r-- | indra/newview/llinventorybridge.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llinventorymodel.cpp | 21 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.cpp | 20 | ||||
-rw-r--r-- | indra/newview/llviewerinventory.h | 9 | ||||
-rw-r--r-- | indra/newview/llviewermenu.cpp | 14 |
7 files changed, 70 insertions, 6 deletions
diff --git a/indra/llinventory/llinventory.h b/indra/llinventory/llinventory.h index ce64317f48..5b8f7ba661 100644 --- a/indra/llinventory/llinventory.h +++ b/indra/llinventory/llinventory.h @@ -263,6 +263,10 @@ public: void setInventoryType(LLInventoryType::EType inv_type); void setFlags(U32 flags); void setCreationDate(time_t creation_date_utc); + + // This is currently only used in the Viewer to handle calling cards + // where the creator is actually used to store the target. + void setCreator(const LLUUID& creator) { mPermissions.setCreator(creator); } // Put this inventory item onto the current outgoing mesage. It // assumes you have already called nextBlock(). diff --git a/indra/llinventory/llpermissions.h b/indra/llinventory/llpermissions.h index d4ec399436..864088148f 100644 --- a/indra/llinventory/llpermissions.h +++ b/indra/llinventory/llpermissions.h @@ -252,7 +252,11 @@ public: BOOL setGroupBits( const LLUUID& agent, const LLUUID& group, BOOL set, PermissionMask bits); BOOL setEveryoneBits(const LLUUID& agent, const LLUUID& group, BOOL set, PermissionMask bits); BOOL setNextOwnerBits(const LLUUID& agent, const LLUUID& group, BOOL set, PermissionMask bits); - + + // This is currently only used in the Viewer to handle calling cards + // where the creator is actually used to store the target. Use with care. + void setCreator(const LLUUID& creator) { mCreator = creator; } + // // METHODS // diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 5877a0b19c..bf09774203 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -1090,7 +1090,7 @@ LLFontGL::StyleFlags LLItemBridge::getLabelStyle() const } const LLViewerInventoryItem* item = getItem(); - if (LLAssetType::lookupIsLinkType(item->getActualType())) + if (item && LLAssetType::lookupIsLinkType(item->getActualType())) { font |= LLFontGL::ITALIC; } diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index bba0c9a90d..b4bd312cc0 100644 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -565,9 +565,11 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item) } LLViewerInventoryItem* old_item = getItem(item->getUUID()); + LLPointer<LLViewerInventoryItem> new_item; if(old_item) { // We already have an old item, modify its values + new_item = old_item; LLUUID old_parent_id = old_item->getParentUUID(); LLUUID new_parent_id = item->getParentUUID(); if(old_parent_id != new_parent_id) @@ -596,7 +598,7 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item) else { // Simply add this item - LLPointer<LLViewerInventoryItem> new_item = new LLViewerInventoryItem(item); + new_item = new LLViewerInventoryItem(item); addItem(new_item); if(item->getParentUUID().isNull()) @@ -656,11 +658,24 @@ U32 LLInventoryModel::updateItem(const LLViewerInventoryItem* item) } mask |= LLInventoryObserver::ADD; } - if(item->getType() == LLAssetType::AT_CALLINGCARD) + if(new_item->getType() == LLAssetType::AT_CALLINGCARD) { mask |= LLInventoryObserver::CALLING_CARD; + // Handle user created calling cards. + // Target ID is stored in the description field of the card. + LLUUID id; + std::string desc = new_item->getDescription(); + BOOL isId = desc.empty() ? FALSE : id.set(desc, FALSE); + if (isId) + { + // Valid UUID; set the item UUID and rename it + new_item->setCreator(id); + std::string avatar_name; + // Fetch the currect name + gCacheName->get(id, FALSE, boost::bind(&LLViewerInventoryItem::onCallingCardNameLookup, new_item.get(), _1, _2, _3)); + } } - addChangedMask(mask, item->getUUID()); + addChangedMask(mask, new_item->getUUID()); return mask; } diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index bb14a619c5..820abe2fbd 100644 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -728,6 +728,16 @@ void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id, gAgent.sendReliableMessage(); } +void create_inventory_callingcard(const LLUUID& avatar_id) +{ + std::string item_desc = avatar_id.asString(); + std::string item_name; + gCacheName->getFullName(avatar_id, item_name); + create_inventory_item(gAgent.getID(), gAgent.getSessionID(), + LLUUID::null, LLTransactionID::tnull, item_name, item_desc, LLAssetType::AT_CALLINGCARD, + LLInventoryType::IT_CALLINGCARD, NOT_WEARABLE, PERM_MOVE | PERM_TRANSFER, NULL); +} + void copy_inventory_item( const LLUUID& agent_id, const LLUUID& current_owner, @@ -1102,3 +1112,13 @@ const LLViewerInventoryCategory *LLViewerInventoryItem::getLinkedCategory() cons } return NULL; } + +//---------- + +void LLViewerInventoryItem::onCallingCardNameLookup(const LLUUID& id, const std::string& first_name, const std::string& last_name) +{ + rename(first_name + " " + last_name); + gInventory.addChangedMask(LLInventoryObserver::LABEL, getUUID()); + gInventory.notifyObservers(); +} + diff --git a/indra/newview/llviewerinventory.h b/indra/newview/llviewerinventory.h index 5198f5efc7..0ee9b21d3a 100644 --- a/indra/newview/llviewerinventory.h +++ b/indra/newview/llviewerinventory.h @@ -48,7 +48,7 @@ class LLViewerInventoryCategory; // their inventory. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class LLViewerInventoryItem : public LLInventoryItem +class LLViewerInventoryItem : public LLInventoryItem, public boost::signals2::trackable { public: typedef LLDynamicArray<LLPointer<LLViewerInventoryItem> > item_array_t; @@ -144,6 +144,10 @@ public: const LLViewerInventoryItem *getLinkedItem() const; const LLViewerInventoryCategory *getLinkedCategory() const; + // callback + void onCallingCardNameLookup(const LLUUID& id, const std::string& first_name, const std::string& last_name); + +public: BOOL mIsComplete; LLTransactionID mTransactionID; }; @@ -271,6 +275,7 @@ extern LLInventoryCallbackManager gInventoryCallbacks; #define NOT_WEARABLE (EWearableType)0 +// *TODO: Find a home for these void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id, const LLUUID& parent, const LLTransactionID& transaction_id, const std::string& name, @@ -279,6 +284,8 @@ void create_inventory_item(const LLUUID& agent_id, const LLUUID& session_id, U32 next_owner_perm, LLPointer<LLInventoryCallback> cb); +void create_inventory_callingcard(const LLUUID& avatar_id); + /** * @brief Securely create a new inventory item by copying from another. */ diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index c7df1d9d70..cbaee2ac70 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -5373,6 +5373,19 @@ class LLAvatarAddFriend : public view_listener_t } }; +class LLAvatarAddContact : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + LLVOAvatar* avatar = find_avatar_from_object( LLSelectMgr::getInstance()->getSelection()->getPrimaryObject() ); + if(avatar) + { + create_inventory_callingcard(avatar->getID()); + } + return true; + } +}; + bool complete_give_money(const LLSD& notification, const LLSD& response, LLObjectSelectionHandle handle) { S32 option = LLNotification::getSelectedOption(notification, response); @@ -7931,6 +7944,7 @@ void initialize_menus() // Avatar pie menu view_listener_t::addMenu(new LLObjectMute(), "Avatar.Mute"); view_listener_t::addMenu(new LLAvatarAddFriend(), "Avatar.AddFriend"); + view_listener_t::addMenu(new LLAvatarAddContact(), "Avatar.AddContact"); view_listener_t::addMenu(new LLAvatarFreeze(), "Avatar.Freeze"); view_listener_t::addMenu(new LLAvatarDebug(), "Avatar.Debug"); view_listener_t::addMenu(new LLAvatarVisibleDebug(), "Avatar.VisibleDebug"); |