1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
/**
* @file llrecentpeople.cpp
* @brief List of people with which the user has recently interacted.
*
* $LicenseInfo:firstyear=2009&license=viewerlgpl$
* Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License only.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
#include "llviewerprecompiledheaders.h"
#include "llrecentpeople.h"
#include "llgroupmgr.h"
#include "llagent.h"
using namespace LLOldEvents;
bool LLRecentPeople::add(const LLUUID& id, const LLSD& userdata)
{
if (id == gAgent.getID())
return false;
bool is_not_group_id = LLGroupMgr::getInstance()->getGroupData(id) == NULL;
if (is_not_group_id)
{
// For each avaline call the id of caller is different even if
// the phone number is the same.
// To avoid duplication of avaline list items in the recent list
// of panel People, deleting id's with similar phone number.
const LLUUID& caller_id = getIDByPhoneNumber(userdata);
if (caller_id.notNull())
mPeople.erase(caller_id);
//[] instead of insert to replace existing id->llsd["date"] with new date value
mPeople[id] = userdata;
mChangedSignal();
}
return is_not_group_id;
}
bool LLRecentPeople::contains(const LLUUID& id) const
{
return mPeople.find(id) != mPeople.end();
}
void LLRecentPeople::get(uuid_vec_t& result) const
{
result.clear();
for (recent_people_t::const_iterator pos = mPeople.begin(); pos != mPeople.end(); ++pos)
result.push_back((*pos).first);
}
const LLDate LLRecentPeople::getDate(const LLUUID& id) const
{
recent_people_t::const_iterator it = mPeople.find(id);
if (it!= mPeople.end()) return it->second["date"].asDate();
static LLDate no_date = LLDate();
return no_date;
}
const LLSD& LLRecentPeople::getData(const LLUUID& id) const
{
recent_people_t::const_iterator it = mPeople.find(id);
if (it != mPeople.end())
return it->second;
static LLSD no_data = LLSD();
return no_data;
}
bool LLRecentPeople::isAvalineCaller(const LLUUID& id) const
{
recent_people_t::const_iterator it = mPeople.find(id);
if (it != mPeople.end())
{
const LLSD& user = it->second;
return user["avaline_call"].asBoolean();
}
return false;
}
const LLUUID& LLRecentPeople::getIDByPhoneNumber(const LLSD& userdata)
{
if (!userdata["avaline_call"].asBoolean())
return LLUUID::null;
for (recent_people_t::const_iterator it = mPeople.begin(); it != mPeople.end(); ++it)
{
const LLSD& user_info = it->second;
if (user_info["call_number"].asString() == userdata["call_number"].asString())
return it->first;
}
return LLUUID::null;
}
// virtual
bool LLRecentPeople::handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
(void) userdata;
add(event->getValue().asUUID());
return true;
}
void LLRecentPeople::updateAvatarsArrivalTime(uuid_vec_t& uuids)
{
id_to_time_map_t buf = mAvatarsArrivalTime;
mAvatarsArrivalTime.clear();
for (uuid_vec_t::const_iterator id_it = uuids.begin(); id_it != uuids.end(); ++id_it)
{
if (buf.find(*id_it) != buf.end())
{
mAvatarsArrivalTime[*id_it] = buf[*id_it];
}
else
{
mAvatarsArrivalTime[*id_it] = LLDate::now().secondsSinceEpoch();
}
}
}
F32 LLRecentPeople::getArrivalTimeByID(const LLUUID& id)
{
id_to_time_map_t::const_iterator it = mAvatarsArrivalTime.find(id);
if (it != mAvatarsArrivalTime.end())
{
return it->second;
}
return LLDate::now().secondsSinceEpoch();
}
|