MCPcopy Create free account
hub / github.com/amule-project/amule / FindFriend

Method FindFriend

src/FriendList.cpp:154–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152
153
154CFriend* CFriendList::FindFriend(const CMD4Hash& userhash, uint32 dwIP, uint16 nPort)
155{
156
157 for(FriendList::iterator it = m_FriendList.begin(); it != m_FriendList.end(); ++it) {
158
159 CFriend* cur_friend = *it;
160 // to avoid that unwanted clients become a friend, we have to distinguish between friends with
161 // a userhash and of friends which are identified by IP+port only.
162 if ( !userhash.IsEmpty() && cur_friend->HasHash() ) {
163 // check for a friend which has the same userhash as the specified one
164 if (cur_friend->GetUserHash() == userhash) {
165 return cur_friend;
166 }
167 } else if (cur_friend->GetIP() == dwIP && cur_friend->GetPort() == nPort) {
168 if (!userhash.IsEmpty() && !cur_friend->HasHash() ) {
169 // Friend without hash (probably IP entered through dialog)
170 // -> save the hash
171 cur_friend->SetUserHash(userhash);
172 SaveList();
173 }
174 return cur_friend;
175 }
176 }
177
178 return NULL;
179}
180
181
182CFriend* CFriendList::FindFriend(uint32 ecid)

Callers 3

Get_EC_Response_FriendFunction · 0.80
CUpDownClientMethod · 0.80

Calls 8

HasHashMethod · 0.80
ECIDMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
IsEmptyMethod · 0.45
GetIPMethod · 0.45
GetPortMethod · 0.45
SetUserHashMethod · 0.45

Tested by

no test coverage detected