summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorSteven Bennetts <steve@lindenlab.com>2009-08-05 01:05:39 +0000
committerSteven Bennetts <steve@lindenlab.com>2009-08-05 01:05:39 +0000
commit85f940092705281f1040081ca5ebc207c3cb4a5b (patch)
treec3ba20351cd7ce83dcf09d65b5a8c5998625d2cc /indra/newview
parent7447454e7e733699f57f545bac13f46a72b916b7 (diff)
EXT-316 Enable the Viewer to generate calling cards for any agent
Added code to store agent ID in the description field of calling cards so that we can use them to store user generated contacts. Currently enabled as a context menu for avatars (just for initial testing). reviewed by richard
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llinventorybridge.cpp2
-rw-r--r--indra/newview/llinventorymodel.cpp21
-rw-r--r--indra/newview/llviewerinventory.cpp20
-rw-r--r--indra/newview/llviewerinventory.h9
-rw-r--r--indra/newview/llviewermenu.cpp14
5 files changed, 61 insertions, 5 deletions
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");