PageRenderTime 77ms CodeModel.GetById 40ms app.highlight 17ms RepoModel.GetById 13ms app.codeStats 0ms

/indra/newview/llrecentpeople.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 127 lines | 29 code | 17 blank | 81 comment | 0 complexity | 9b82df4973444d6a559d58ca067b6336 MD5 | raw file
  1/** 
  2 * @file llrecentpeople.h
  3 * @brief List of people with which the user has recently interacted.
  4 *
  5 * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLRECENTPEOPLE_H
 28#define LL_LLRECENTPEOPLE_H
 29
 30#include "llevent.h"
 31#include "llsingleton.h"
 32#include "lluuid.h"
 33
 34#include <vector>
 35#include <set>
 36#include <boost/signals2.hpp>
 37
 38class LLDate;
 39
 40/**
 41 * List of people the agent recently interacted with.
 42 * 
 43 * Includes: anyone with whom the user IM'd or called
 44 * (1:1 and ad-hoc but not SL Group chat),
 45 * anyone with whom the user has had a transaction
 46 * (inventory offer, friend request, etc),
 47 * and anyone that has chatted within chat range of the user in-world. 
 48 * 
 49 *TODO: purge least recently added items? 
 50 */
 51class LLRecentPeople: public LLSingleton<LLRecentPeople>, public LLOldEvents::LLSimpleListener
 52{
 53	LOG_CLASS(LLRecentPeople);
 54public:
 55	typedef boost::signals2::signal<void ()> signal_t;
 56	
 57	/**
 58	 * Add specified avatar to the list if it's not there already.
 59	 *
 60	 * @param id avatar to add.
 61	 *
 62	 * @param userdata additional information about last interaction party.
 63	 *				   For example when last interaction party is not an avatar
 64	 *				   but an avaline caller, additional info (such as phone
 65	 *				   number, session id and etc.) should be added.
 66	 *
 67	 * @return false if the avatar is in the list already, true otherwise
 68	 */
 69	bool add(const LLUUID& id, const LLSD& userdata = LLSD().with("date", LLDate::now()));
 70
 71	/**
 72	 * @param id avatar to search.
 73	 * @return true if the avatar is in the list, false otherwise.
 74	 */
 75	bool contains(const LLUUID& id) const;
 76
 77	/**
 78	 * Get the whole list.
 79	 * 
 80	 * @param result where to put the result.
 81	 */
 82	void get(uuid_vec_t& result) const;
 83
 84	/**
 85	 * Returns last interaction time with specified participant
 86	 *
 87	 */
 88	const LLDate getDate(const LLUUID& id) const;
 89
 90	/**
 91	 * Returns data about specified participant
 92	 *
 93	 * @param id identifier of specific participant
 94	 */
 95	const LLSD& getData(const LLUUID& id) const;
 96
 97	/**
 98	 * Checks whether specific participant is an avaline caller
 99	 *
100	 * @param id identifier of specific participant
101	 */
102	bool isAvalineCaller(const LLUUID& id) const;
103
104	/**
105	 * Set callback to be called when the list changed.
106	 * 
107	 * Multiple callbacks can be set.
108	 * 
109	 * @return no connection; use boost::bind + boost::signals2::trackable to disconnect slots.
110	 */
111	void setChangedCallback(const signal_t::slot_type& cb) { mChangedSignal.connect(cb); }
112
113	/**
114	 * LLSimpleListener interface.
115	 */
116	/*virtual*/ bool handleEvent(LLPointer<LLOldEvents::LLEvent> event, const LLSD& userdata);
117
118private:
119
120	const LLUUID& getIDByPhoneNumber(const LLSD& userdata);
121
122	typedef std::map<LLUUID, LLSD> recent_people_t;
123	recent_people_t		mPeople;
124	signal_t			mChangedSignal;
125};
126
127#endif // LL_LLRECENTPEOPLE_H