166
166
void ChatEntry::onRolesChanged(const HandleRolesMap &added, const HandleRolesMap &removed)
172
168
Tp::TextChannel* channel = 0;
173
169
if (rolesInterface) {
174
rolesMap = rolesInterface->getRoles();
170
if (mRolesMap.isEmpty()) {
171
mRolesMap = rolesInterface->getRoles();
175
173
channel = qvariant_cast<Tp::TextChannel*>(rolesInterface->property("channel"));
176
QMapIterator<uint, uint> it(removed);
177
while (it.hasNext()) {
179
mRolesMap.remove(it.key());
182
QMapIterator<uint, uint> it2(added);
183
while (it2.hasNext()) {
185
mRolesMap[it2.key()] = it2.value();
188
// TODO avoid iterating over all participants when not needed
178
189
Q_FOREACH(Participant* participant, mParticipants) {
179
if (rolesMap.contains(participant->handle())) {
180
participant->setRoles(rolesMap[participant->handle()]);
190
if (mRolesMap.contains(participant->handle())) {
191
participant->setRoles(mRolesMap[participant->handle()]);
184
195
Q_FOREACH(Participant* participant, mLocalPendingParticipants) {
185
if (rolesMap.contains(participant->handle())) {
186
participant->setRoles(rolesMap[participant->handle()]);
196
if (mRolesMap.contains(participant->handle())) {
197
participant->setRoles(mRolesMap[participant->handle()]);
190
201
Q_FOREACH(Participant* participant, mRemotePendingParticipants) {
191
if (rolesMap.contains(participant->handle())) {
192
participant->setRoles(rolesMap[participant->handle()]);
202
if (mRolesMap.contains(participant->handle())) {
203
participant->setRoles(mRolesMap[participant->handle()]);
689
if (rolesInterface) {
690
rolesMap = rolesInterface->getRoles();
699
if (rolesInterface && mRolesMap.isEmpty()) {
700
mRolesMap = rolesInterface->getRoles();
692
702
// now add the new participants
693
703
// FIXME: check for duplicates?
694
704
Q_FOREACH(Tp::ContactPtr contact, added) {
695
705
uint handle = contact->handle().at(0);
696
list << new Participant(contact->id(), rolesMap[handle], handle, this);
706
list << new Participant(contact->id(), mRolesMap[handle], handle, this);