blob: 15a7767772a6d5399776ae05fd773ec4cdbebcef (
plain)
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
|
/*
* Copyright (c) 2013 Tobias Markmann
* Licensed under the simplified BSD license.
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
#include <Swift/Controllers/ContactsFromXMPPRoster.h>
#include <Swiften/Base/foreach.h>
#include <Swiften/Avatars/AvatarManager.h>
#include <Swiften/Presence/PresenceOracle.h>
#include <Swiften/Roster/XMPPRoster.h>
#include <Swiften/Roster/XMPPRosterItem.h>
namespace Swift {
ContactsFromXMPPRoster::ContactsFromXMPPRoster(XMPPRoster* roster, AvatarManager* avatarManager, PresenceOracle* presenceOracle) : roster_(roster), avatarManager_(avatarManager), presenceOracle_(presenceOracle) {
}
ContactsFromXMPPRoster::~ContactsFromXMPPRoster() {
}
std::vector<Contact> ContactsFromXMPPRoster::getContacts() {
std::vector<Contact> results;
std::vector<XMPPRosterItem> rosterItems = roster_->getItems();
foreach(const XMPPRosterItem& rosterItem, rosterItems) {
Contact contact(rosterItem.getName().empty() ? rosterItem.getJID().toString() : rosterItem.getName(), rosterItem.getJID(), StatusShow::None,"");
contact.statusType = presenceOracle_->getHighestPriorityPresence(contact.jid) ? presenceOracle_->getHighestPriorityPresence(contact.jid)->getShow() : StatusShow::None;
contact.avatarPath = avatarManager_->getAvatarPath(contact.jid);
results.push_back(contact);
}
return results;
}
}
|