Merge lp:~phablet-team/telephony-service/expose_account_parameters into lp:telephony-service/staging
- expose_account_parameters
- Merge into staging
Proposed by
Gustavo Pichorim Boiko
Status: | Superseded |
---|---|
Proposed branch: | lp:~phablet-team/telephony-service/expose_account_parameters |
Merge into: | lp:telephony-service/staging |
Prerequisite: | lp:~phablet-team/telephony-service/multiple_performance_improvements1 |
Diff against target: |
636 lines (+388/-12) 11 files modified
Ubuntu/Telephony/CMakeLists.txt (+1/-0) Ubuntu/Telephony/components.cpp (+2/-0) Ubuntu/Telephony/participantsmodel.cpp (+229/-0) Ubuntu/Telephony/participantsmodel.h (+92/-0) handler/texthandler.cpp (+6/-0) libtelephonyservice/accountentry.cpp (+8/-0) libtelephonyservice/accountentry.h (+4/-0) libtelephonyservice/chatentry.cpp (+21/-8) libtelephonyservice/chatentry.h (+7/-1) libtelephonyservice/participant.cpp (+13/-2) libtelephonyservice/participant.h (+5/-1) |
To merge this branch: | bzr merge lp:~phablet-team/telephony-service/expose_account_parameters |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu Phablet Team | Pending | ||
Review via email: mp+318269@code.launchpad.net |
This proposal has been superseded by a proposal from 2017-03-22.
Commit message
Expose the account parameters to QML
Description of the change
Expose the account parameters to QML
To post a comment you must log in.
- 1245. By Tiago Salem Herrmann
-
merge parent branch
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Ubuntu/Telephony/CMakeLists.txt' |
2 | --- Ubuntu/Telephony/CMakeLists.txt 2016-07-05 03:34:11 +0000 |
3 | +++ Ubuntu/Telephony/CMakeLists.txt 2017-03-03 17:50:39 +0000 |
4 | @@ -2,6 +2,7 @@ |
5 | |
6 | set(plugin_SRCS |
7 | presencerequest.cpp |
8 | + participantsmodel.cpp |
9 | components.cpp |
10 | ) |
11 | |
12 | |
13 | === modified file 'Ubuntu/Telephony/components.cpp' |
14 | --- Ubuntu/Telephony/components.cpp 2016-11-23 19:28:18 +0000 |
15 | +++ Ubuntu/Telephony/components.cpp 2017-03-03 17:50:39 +0000 |
16 | @@ -39,6 +39,7 @@ |
17 | #include "accountentry.h" |
18 | #include "accountlist.h" |
19 | #include "audiooutput.h" |
20 | +#include "participantsmodel.h" |
21 | |
22 | #include <QQmlEngine> |
23 | #include <qqml.h> |
24 | @@ -87,5 +88,6 @@ |
25 | qmlRegisterType<ContactWatcher>(uri, 0, 1, "ContactWatcher"); |
26 | qmlRegisterType<Participant>(uri, 0, 1, "Participant"); |
27 | qmlRegisterType<PresenceRequest>(uri, 0, 1, "PresenceRequest"); |
28 | + qmlRegisterType<ParticipantsModel>(uri, 0, 1, "ParticipantsModel"); |
29 | qmlRegisterType<PhoneUtils>(uri, 0, 1, "PhoneUtils"); |
30 | } |
31 | |
32 | === added file 'Ubuntu/Telephony/participantsmodel.cpp' |
33 | --- Ubuntu/Telephony/participantsmodel.cpp 1970-01-01 00:00:00 +0000 |
34 | +++ Ubuntu/Telephony/participantsmodel.cpp 2017-03-03 17:50:39 +0000 |
35 | @@ -0,0 +1,229 @@ |
36 | +/* |
37 | + * Copyright (C) 2013-2017 Canonical, Ltd. |
38 | + * |
39 | + * Authors: |
40 | + * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> |
41 | + * Tiago Salem Herrmann <tiago.herrmann@canonical.com> |
42 | + * |
43 | + * This file is part of telephony-service. |
44 | + * |
45 | + * telephony-service is free software; you can redistribute it and/or modify |
46 | + * it under the terms of the GNU General Public License as published by |
47 | + * the Free Software Foundation; version 3. |
48 | + * |
49 | + * telephony-service is distributed in the hope that it will be useful, |
50 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
51 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
52 | + * GNU General Public License for more details. |
53 | + * |
54 | + * You should have received a copy of the GNU General Public License |
55 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
56 | + */ |
57 | + |
58 | +#include "participantsmodel.h" |
59 | +#include <participant.h> |
60 | +#include <QDebug> |
61 | + |
62 | +Q_DECLARE_METATYPE(Participant) |
63 | + |
64 | +ParticipantsModel::ParticipantsModel(QObject *parent) : |
65 | + QAbstractListModel(parent), mWaitingForQml(false), mCanFetchMore(true) |
66 | +{ |
67 | + qRegisterMetaType<Participant>(); |
68 | + mRoles[AliasRole] = "alias"; |
69 | + mRoles[IdentifierRole] = "identifier"; |
70 | + mRoles[RolesRole] = "roles"; |
71 | + mRoles[StateRole] = "state"; |
72 | + |
73 | + connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SIGNAL(countChanged())); |
74 | + connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SIGNAL(countChanged())); |
75 | + connect(this, SIGNAL(modelReset()), this, SIGNAL(countChanged())); |
76 | +} |
77 | + |
78 | +bool ParticipantsModel::canFetchMore(const QModelIndex &parent) const |
79 | +{ |
80 | + return !mParticipantsCache.isEmpty(); |
81 | +} |
82 | + |
83 | +ParticipantsModel::~ParticipantsModel() |
84 | +{ |
85 | +} |
86 | + |
87 | +void ParticipantsModel::fetchMore(const QModelIndex &parent) |
88 | +{ |
89 | + if (parent.isValid() ) { |
90 | + return; |
91 | + } |
92 | + |
93 | + int max = 14; |
94 | + while (max >= 0 && !mParticipantsCache.isEmpty()) { |
95 | + addParticipant(mParticipantsCache.takeFirst()); |
96 | + max--; |
97 | + } |
98 | + |
99 | + if (mParticipantsCache.isEmpty()) { |
100 | + mCanFetchMore = false; |
101 | + Q_EMIT canFetchMoreChanged(); |
102 | + } |
103 | +} |
104 | + |
105 | +int ParticipantsModel::rowCount(const QModelIndex &parent) const |
106 | +{ |
107 | + if (parent.isValid()) { |
108 | + return 0; |
109 | + } |
110 | + |
111 | + return mParticipants.count(); |
112 | +} |
113 | + |
114 | +QHash<int, QByteArray> ParticipantsModel::roleNames() const |
115 | +{ |
116 | + return mRoles; |
117 | +} |
118 | + |
119 | +void ParticipantsModel::addParticipantCache(Participant *participant) |
120 | +{ |
121 | + int pos = positionForItem(participant->identifier(), true); |
122 | + mParticipantsCache.insert(pos, participant); |
123 | +} |
124 | + |
125 | +void ParticipantsModel::addParticipant(Participant *participant) |
126 | +{ |
127 | + int pos = positionForItem(participant->identifier()); |
128 | + beginInsertRows(QModelIndex(), pos, pos); |
129 | + mParticipants.insert(pos, participant); |
130 | + endInsertRows(); |
131 | +} |
132 | + |
133 | +void ParticipantsModel::removeParticipant(Participant *participant) |
134 | +{ |
135 | + int pos = mParticipants.indexOf(participant); |
136 | + if (pos >= 0) { |
137 | + beginRemoveRows(QModelIndex(), pos, pos); |
138 | + mParticipants.removeAt(pos); |
139 | + endRemoveRows(); |
140 | + } |
141 | + pos = mParticipantsCache.indexOf(participant); |
142 | + if (pos >= 0) { |
143 | + mParticipantsCache.removeAt(pos); |
144 | + } |
145 | +} |
146 | + |
147 | +QVariant ParticipantsModel::data(const QModelIndex &index, int role) const |
148 | +{ |
149 | + if (!index.isValid() || index.row() < 0 || index.row() >= rowCount()) { |
150 | + return QVariant(); |
151 | + } |
152 | + switch (role) { |
153 | + case IdentifierRole: |
154 | + return mParticipants[index.row()]->identifier(); |
155 | + break; |
156 | + case AliasRole: |
157 | + return mParticipants[index.row()]->alias(); |
158 | + break; |
159 | + case StateRole: |
160 | + return 0; |
161 | + break; |
162 | + case RolesRole: |
163 | + return mParticipants[index.row()]->roles(); |
164 | + break; |
165 | + } |
166 | + return QVariant(); |
167 | +} |
168 | + |
169 | +bool ParticipantsModel::lessThan(const QString &left, const QString &right) const |
170 | +{ |
171 | + if (left.isEmpty() || right.isEmpty()) { |
172 | + return false; |
173 | + } |
174 | + if (left.at(0).isLetter() && right.at(0).isLetter()) { |
175 | + return left.localeAwareCompare(right) < 0; |
176 | + } |
177 | + if (!left.at(0).isLetter() && right.at(0).isLetter()) { |
178 | + return false; |
179 | + } |
180 | + if (left.at(0).isLetter() && !right.at(0).isLetter()) { |
181 | + return true; |
182 | + } |
183 | + |
184 | + return false; |
185 | +} |
186 | + |
187 | +int ParticipantsModel::positionForItem(const QString &item, bool cache) const |
188 | +{ |
189 | + // do a binary search for the item position on the list |
190 | + int lowerBound = 0; |
191 | + int upperBound = cache ? mParticipantsCache.count() - 1 : rowCount() - 1; |
192 | + if (upperBound < 0) { |
193 | + return 0; |
194 | + } |
195 | + |
196 | + while (true) { |
197 | + int pos = (upperBound + lowerBound) / 2; |
198 | + const QString posItem = cache ? mParticipantsCache[pos]->identifier() : index(pos).data(IdentifierRole).toString(); |
199 | + if (lowerBound == pos) { |
200 | + if (lessThan(item, posItem)) { |
201 | + return pos; |
202 | + } |
203 | + } |
204 | + if (lessThan(posItem, item)) { |
205 | + lowerBound = pos + 1; // its in the upper |
206 | + if (lowerBound > upperBound) { |
207 | + return pos += 1; |
208 | + } |
209 | + } else if (lowerBound > upperBound) { |
210 | + return pos; |
211 | + } else { |
212 | + upperBound = pos - 1; // its in the lower |
213 | + } |
214 | + } |
215 | +} |
216 | + |
217 | +void ParticipantsModel::classBegin() |
218 | +{ |
219 | + mWaitingForQml = true; |
220 | +} |
221 | + |
222 | +void ParticipantsModel::componentComplete() |
223 | +{ |
224 | + mWaitingForQml = false; |
225 | +} |
226 | + |
227 | +QVariant ParticipantsModel::get(int row) const |
228 | +{ |
229 | + QVariantMap data; |
230 | + QModelIndex idx = index(row, 0); |
231 | + if (idx.isValid()) { |
232 | + QHash<int, QByteArray> roles = roleNames(); |
233 | + Q_FOREACH(int role, roles.keys()) { |
234 | + data.insert(roles[role], idx.data(role)); |
235 | + } |
236 | + } |
237 | + |
238 | + return data; |
239 | +} |
240 | + |
241 | +ChatEntry* ParticipantsModel::chatEntry() const |
242 | +{ |
243 | + return mChatEntry; |
244 | +} |
245 | + |
246 | +void ParticipantsModel::setChatEntry(ChatEntry *entry) |
247 | +{ |
248 | + if (mChatEntry == entry) { |
249 | + return; |
250 | + } |
251 | + mChatEntry = entry; |
252 | + if (!entry) { |
253 | + return; |
254 | + } |
255 | + connect(mChatEntry, SIGNAL(participantAdded(Participant *)), SLOT(addParticipant(Participant *))); |
256 | + connect(mChatEntry, SIGNAL(participantRemoved(Participant *)), SLOT(removeParticipant(Participant *))); |
257 | + Q_FOREACH(Participant *participant, mChatEntry->allParticipants()) { |
258 | + addParticipantCache(participant); |
259 | + } |
260 | + fetchMore(); |
261 | + mCanFetchMore = !mParticipantsCache.isEmpty(); |
262 | + Q_EMIT canFetchMoreChanged(); |
263 | + Q_EMIT chatEntryChanged(); |
264 | +} |
265 | |
266 | === added file 'Ubuntu/Telephony/participantsmodel.h' |
267 | --- Ubuntu/Telephony/participantsmodel.h 1970-01-01 00:00:00 +0000 |
268 | +++ Ubuntu/Telephony/participantsmodel.h 2017-03-03 17:50:39 +0000 |
269 | @@ -0,0 +1,92 @@ |
270 | +/* |
271 | + * Copyright (C) 2013-2017 Canonical, Ltd. |
272 | + * |
273 | + * Authors: |
274 | + * Gustavo Pichorim Boiko <gustavo.boiko@canonical.com> |
275 | + * Tiago Salem Herrmann <tiago.herrmann@canonical.com> |
276 | + * |
277 | + * This file is part of telephony-service. |
278 | + * |
279 | + * telephony-service is free software; you can redistribute it and/or modify |
280 | + * it under the terms of the GNU General Public License as published by |
281 | + * the Free Software Foundation; version 3. |
282 | + * |
283 | + * telephony-service is distributed in the hope that it will be useful, |
284 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
285 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
286 | + * GNU General Public License for more details. |
287 | + * |
288 | + * You should have received a copy of the GNU General Public License |
289 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
290 | + */ |
291 | + |
292 | +#ifndef PARTICIPANTSMODEL_H |
293 | +#define PARTICIPANTSMODEL_H |
294 | + |
295 | +#include "chatentry.h" |
296 | +#include <QAbstractListModel> |
297 | +#include <QStringList> |
298 | +#include <QQmlParserStatus> |
299 | +#include <QQmlListProperty> |
300 | + |
301 | +class Participant; |
302 | + |
303 | +class ParticipantsModel : public QAbstractListModel, public QQmlParserStatus |
304 | +{ |
305 | + Q_OBJECT |
306 | + Q_INTERFACES(QQmlParserStatus) |
307 | + Q_PROPERTY(int count READ rowCount NOTIFY countChanged) |
308 | + Q_PROPERTY(bool canFetchMore READ canFetchMore NOTIFY canFetchMoreChanged) |
309 | + Q_PROPERTY(ChatEntry* chatEntry READ chatEntry WRITE setChatEntry NOTIFY chatEntryChanged) |
310 | + Q_ENUMS(Role) |
311 | + |
312 | +public: |
313 | + enum Role { |
314 | + IdentifierRole = Qt::UserRole, |
315 | + AliasRole, |
316 | + RolesRole, |
317 | + StateRole |
318 | + }; |
319 | + |
320 | + explicit ParticipantsModel(QObject *parent = 0); |
321 | + ~ParticipantsModel(); |
322 | + |
323 | + Q_INVOKABLE virtual bool canFetchMore(const QModelIndex &parent = QModelIndex()) const; |
324 | + Q_INVOKABLE virtual void fetchMore(const QModelIndex &parent = QModelIndex()); |
325 | + virtual QHash<int, QByteArray> roleNames() const; |
326 | + virtual QVariant data(const QModelIndex &index, int role) const; |
327 | + int rowCount(const QModelIndex &parent = QModelIndex()) const; |
328 | + |
329 | + Q_INVOKABLE virtual QVariant get(int row) const; |
330 | + |
331 | + Q_INVOKABLE void setChatEntry(ChatEntry *entry); |
332 | + ChatEntry* chatEntry() const; |
333 | + |
334 | + void addParticipantCache(Participant *participant); |
335 | + |
336 | + void classBegin(); |
337 | + void componentComplete(); |
338 | + |
339 | +private Q_SLOTS: |
340 | + void addParticipant(Participant *participant); |
341 | + void removeParticipant(Participant *participant); |
342 | + |
343 | +Q_SIGNALS: |
344 | + void countChanged(); |
345 | + void canFetchMoreChanged(); |
346 | + void chatEntryChanged(); |
347 | + |
348 | +protected: |
349 | + bool lessThan(const QString &left, const QString &right) const; |
350 | + int positionForItem(const QString &item, bool cache = false) const; |
351 | + |
352 | +private: |
353 | + QHash<int, QByteArray> mRoles; |
354 | + QList<Participant*> mParticipants; |
355 | + bool mWaitingForQml; |
356 | + bool mCanFetchMore; |
357 | + ChatEntry *mChatEntry; |
358 | + QList<Participant*> mParticipantsCache; |
359 | +}; |
360 | + |
361 | +#endif // HISTORYMODEL_H |
362 | |
363 | === modified file 'handler/texthandler.cpp' |
364 | --- handler/texthandler.cpp 2017-03-03 17:50:38 +0000 |
365 | +++ handler/texthandler.cpp 2017-03-03 17:50:39 +0000 |
366 | @@ -168,8 +168,14 @@ |
367 | if (chatType == Tp::HandleTypeNone && targetIds.size() == 1) { |
368 | chatType = Tp::HandleTypeContact; |
369 | } |
370 | + |
371 | QString roomId = properties["threadId"].toString(); |
372 | |
373 | + // try to use the threadId as participantId if empty |
374 | + if (chatType == Tp::HandleTypeContact && targetIds.isEmpty()) { |
375 | + targetIds << roomId; |
376 | + } |
377 | + |
378 | Q_FOREACH(const Tp::TextChannelPtr &channel, mChannels) { |
379 | int count = 0; |
380 | AccountEntry *channelAccount = TelepathyHelper::instance()->accountForConnection(channel->connection()); |
381 | |
382 | === modified file 'libtelephonyservice/accountentry.cpp' |
383 | --- libtelephonyservice/accountentry.cpp 2017-03-03 17:50:38 +0000 |
384 | +++ libtelephonyservice/accountentry.cpp 2017-03-03 17:50:39 +0000 |
385 | @@ -164,6 +164,11 @@ |
386 | Q_EMIT accountPropertiesChanged(); |
387 | } |
388 | |
389 | +QVariantMap AccountEntry::parameters() const |
390 | +{ |
391 | + return mAccount->parameters(); |
392 | +} |
393 | + |
394 | Tp::AccountPtr AccountEntry::account() const |
395 | { |
396 | return mAccount; |
397 | @@ -235,6 +240,9 @@ |
398 | SIGNAL(connectionStatusChanged(Tp::ConnectionStatus)), |
399 | SIGNAL(connectionStatusChanged(Tp::ConnectionStatus))); |
400 | |
401 | + connect(mAccount.data(), &Tp::Account::parametersChanged, |
402 | + this, &AccountEntry::parametersChanged); |
403 | + |
404 | connect(this, |
405 | SIGNAL(connectedChanged()), |
406 | SIGNAL(activeChanged())); |
407 | |
408 | === modified file 'libtelephonyservice/accountentry.h' |
409 | --- libtelephonyservice/accountentry.h 2017-03-03 17:50:38 +0000 |
410 | +++ libtelephonyservice/accountentry.h 2017-03-03 17:50:39 +0000 |
411 | @@ -48,6 +48,7 @@ |
412 | Q_PROPERTY(Protocol* protocolInfo READ protocolInfo CONSTANT) |
413 | Q_PROPERTY(Capabilities capabilities READ capabilities NOTIFY capabilitiesChanged) |
414 | Q_PROPERTY(QVariantMap accountProperties READ accountProperties WRITE setAccountProperties NOTIFY accountPropertiesChanged) |
415 | + Q_PROPERTY(QVariantMap parameters READ parameters NOTIFY parametersChanged) |
416 | Q_ENUMS(AccountType) |
417 | friend class AccountEntryFactory; |
418 | |
419 | @@ -86,6 +87,8 @@ |
420 | |
421 | QVariantMap accountProperties() const; |
422 | void setAccountProperties(const QVariantMap &properties); |
423 | + |
424 | + QVariantMap parameters() const; |
425 | |
426 | Protocol *protocolInfo() const; |
427 | |
428 | @@ -106,6 +109,7 @@ |
429 | void connectionStatusChanged(Tp::ConnectionStatus status); |
430 | void capabilitiesChanged(); |
431 | void accountPropertiesChanged(); |
432 | + void parametersChanged(); |
433 | |
434 | protected Q_SLOTS: |
435 | virtual void initialize(); |
436 | |
437 | === modified file 'libtelephonyservice/chatentry.cpp' |
438 | --- libtelephonyservice/chatentry.cpp 2017-03-03 17:50:38 +0000 |
439 | +++ libtelephonyservice/chatentry.cpp 2017-03-03 17:50:39 +0000 |
440 | @@ -141,15 +141,18 @@ |
441 | updateParticipants(mParticipants, |
442 | groupMembersAdded, |
443 | groupMembersRemoved, |
444 | - account); |
445 | + account, |
446 | + 0); |
447 | updateParticipants(mLocalPendingParticipants, |
448 | groupLocalPendingMembersAdded, |
449 | groupMembersRemoved + groupMembersAdded, // if contacts move to the main list, remove from the pending one |
450 | - account); |
451 | + account, |
452 | + 1); |
453 | updateParticipants(mRemotePendingParticipants, |
454 | groupRemotePendingMembersAdded, |
455 | groupMembersRemoved + groupMembersAdded, // if contacts move to the main list, remove from the pending one |
456 | - account); |
457 | + account, |
458 | + 2); |
459 | |
460 | // generate the list of participant IDs again |
461 | mParticipantIds.clear(); |
462 | @@ -265,6 +268,11 @@ |
463 | return mAutoRequest; |
464 | } |
465 | |
466 | +QList<Participant*> ChatEntry::allParticipants() const |
467 | +{ |
468 | + return mParticipants + mLocalPendingParticipants + mRemotePendingParticipants; |
469 | +} |
470 | + |
471 | bool ChatEntry::canUpdateConfiguration() const |
472 | { |
473 | return mCanUpdateConfiguration; |
474 | @@ -575,9 +583,6 @@ |
475 | |
476 | // FIXME: check how to handle multiple channels in a better way, |
477 | // for now, use the info from the last available channel |
478 | - Q_FOREACH(Participant *participant, mParticipants) { |
479 | - participant->deleteLater(); |
480 | - } |
481 | clearParticipants(); |
482 | |
483 | onGroupMembersChanged(channel->groupContacts(false), |
484 | @@ -669,26 +674,31 @@ |
485 | void ChatEntry::clearParticipants() |
486 | { |
487 | Q_FOREACH(Participant *participant, mParticipants) { |
488 | + Q_EMIT participantRemoved(participant); |
489 | participant->deleteLater(); |
490 | } |
491 | Q_FOREACH(Participant *participant, mLocalPendingParticipants) { |
492 | + Q_EMIT participantRemoved(participant); |
493 | participant->deleteLater(); |
494 | } |
495 | Q_FOREACH(Participant *participant, mRemotePendingParticipants) { |
496 | + Q_EMIT participantRemoved(participant); |
497 | participant->deleteLater(); |
498 | } |
499 | mParticipants.clear(); |
500 | mLocalPendingParticipants.clear(); |
501 | mRemotePendingParticipants.clear(); |
502 | + mRolesMap.clear(); |
503 | mSelfContactRoles = 0; |
504 | } |
505 | |
506 | -void ChatEntry::updateParticipants(QList<Participant *> &list, const Tp::Contacts &added, const Tp::Contacts &removed, AccountEntry *account) |
507 | +void ChatEntry::updateParticipants(QList<Participant *> &list, const Tp::Contacts &added, const Tp::Contacts &removed, AccountEntry *account, uint pending) |
508 | { |
509 | // first look for removed members |
510 | Q_FOREACH(Tp::ContactPtr contact, removed) { |
511 | Q_FOREACH(Participant *participant, list) { |
512 | if (account->compareIds(contact->id(), participant->identifier())) { |
513 | + Q_EMIT participantRemoved(participant); |
514 | participant->deleteLater(); |
515 | list.removeOne(participant); |
516 | break; |
517 | @@ -703,7 +713,9 @@ |
518 | // FIXME: check for duplicates? |
519 | Q_FOREACH(Tp::ContactPtr contact, added) { |
520 | uint handle = contact->handle().at(0); |
521 | - list << new Participant(contact->id(), mRolesMap[handle], handle, this); |
522 | + Participant* participant = new Participant(contact->id(), mRolesMap[handle], handle, QString(), pending, this); |
523 | + Q_EMIT participantAdded(participant); |
524 | + list << participant; |
525 | } |
526 | } |
527 | |
528 | @@ -794,6 +806,7 @@ |
529 | rolesInterface->disconnect(this); |
530 | rolesInterface = 0; |
531 | } |
532 | + clearParticipants(); |
533 | Q_EMIT activeChanged(); |
534 | Q_EMIT groupFlagsChanged(); |
535 | Q_EMIT selfContactRolesChanged(); |
536 | |
537 | === modified file 'libtelephonyservice/chatentry.h' |
538 | --- libtelephonyservice/chatentry.h 2017-03-03 17:50:38 +0000 |
539 | +++ libtelephonyservice/chatentry.h 2017-03-03 17:50:39 +0000 |
540 | @@ -25,6 +25,7 @@ |
541 | |
542 | #include <QObject> |
543 | #include <QQmlParserStatus> |
544 | +#include <QQmlListProperty> |
545 | #include <TelepathyQt/TextChannel> |
546 | #include "rolesinterface.h" |
547 | |
548 | @@ -146,6 +147,8 @@ |
549 | void classBegin(); |
550 | void componentComplete(); |
551 | |
552 | + QList<Participant*> allParticipants() const; |
553 | + |
554 | public Q_SLOTS: |
555 | // FIXME: void or return something? |
556 | void sendMessage(const QString &accountId, const QString &message, const QVariant &attachments = QVariant(), const QVariantMap &properties = QVariantMap()); |
557 | @@ -165,7 +168,7 @@ |
558 | QVariantMap generateProperties() const; |
559 | |
560 | void clearParticipants(); |
561 | - void updateParticipants(QList<Participant*> &list, const Tp::Contacts &added, const Tp::Contacts &removed, AccountEntry *account); |
562 | + void updateParticipants(QList<Participant*> &list, const Tp::Contacts &added, const Tp::Contacts &removed, AccountEntry *account, uint pending = 0); |
563 | |
564 | private Q_SLOTS: |
565 | void onTextChannelAvailable(const Tp::TextChannelPtr &channel); |
566 | @@ -207,6 +210,9 @@ |
567 | void chatReady(); |
568 | void startChatFailed(); |
569 | |
570 | + void participantAdded(Participant *participant); |
571 | + void participantRemoved(Participant *participant); |
572 | + |
573 | private: |
574 | QList<Tp::TextChannelPtr> mChannels; |
575 | QStringList mParticipantIds; |
576 | |
577 | === modified file 'libtelephonyservice/participant.cpp' |
578 | --- libtelephonyservice/participant.cpp 2016-09-26 20:38:38 +0000 |
579 | +++ libtelephonyservice/participant.cpp 2017-03-03 17:50:39 +0000 |
580 | @@ -22,8 +22,8 @@ |
581 | |
582 | #include "participant.h" |
583 | |
584 | -Participant::Participant(const QString &identifier, uint roles, uint handle, QObject *parent) |
585 | -: ContactWatcher(parent), mRoles(roles), mHandle(handle) |
586 | +Participant::Participant(const QString &identifier, uint roles, uint handle, const QString &avatar, uint state, QObject *parent) |
587 | +: ContactWatcher(parent), mRoles(roles), mHandle(handle), mAvatar(avatar), mState(state) |
588 | { |
589 | classBegin(); |
590 | setIdentifier(identifier); |
591 | @@ -61,3 +61,14 @@ |
592 | { |
593 | return mHandle; |
594 | } |
595 | + |
596 | +uint Participant::state() const |
597 | +{ |
598 | + return mState; |
599 | +} |
600 | + |
601 | +QString Participant::avatar() const |
602 | +{ |
603 | + return mAvatar; |
604 | +} |
605 | + |
606 | |
607 | === modified file 'libtelephonyservice/participant.h' |
608 | --- libtelephonyservice/participant.h 2016-09-26 20:38:38 +0000 |
609 | +++ libtelephonyservice/participant.h 2017-03-03 17:50:39 +0000 |
610 | @@ -30,7 +30,7 @@ |
611 | Q_OBJECT |
612 | Q_PROPERTY(uint roles READ roles NOTIFY rolesChanged) |
613 | public: |
614 | - explicit Participant(const QString &identifier, uint roles, uint handle, QObject *parent = 0); |
615 | + explicit Participant(const QString &identifier, uint roles, uint handle, const QString &avatar = QString(), uint state = 0, QObject *parent = 0); |
616 | explicit Participant(QObject *parent = 0); |
617 | explicit Participant(const Participant &other); |
618 | ~Participant(); |
619 | @@ -38,6 +38,8 @@ |
620 | void setRoles(uint roles); |
621 | uint roles() const; |
622 | uint handle() const; |
623 | + QString avatar() const; |
624 | + uint state() const; |
625 | |
626 | Q_SIGNAL |
627 | void rolesChanged(); |
628 | @@ -45,6 +47,8 @@ |
629 | private: |
630 | uint mRoles; |
631 | uint mHandle; |
632 | + QString mAvatar; |
633 | + uint mState; |
634 | }; |
635 | |
636 | #endif // PARTICIPANT_H |