Merge lp:~phablet-team/telephony-service/online-account-match into lp:telephony-service/staging

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 1246
Merged at revision: 1250
Proposed branch: lp:~phablet-team/telephony-service/online-account-match
Merge into: lp:telephony-service/staging
Prerequisite: lp:~phablet-team/telephony-service/qml-start-chat
Diff against target: 100 lines (+43/-14)
2 files modified
libtelephonyservice/contactwatcher.cpp (+41/-14)
libtelephonyservice/contactwatcher.h (+2/-0)
To merge this branch: bzr merge lp:~phablet-team/telephony-service/online-account-match
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
Review via email: mp+318022@code.launchpad.net

Commit message

Implemented contact match by online accounts (IRC).

To post a comment you must log in.
1246. By Tiago Salem Herrmann

merge parent branch

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

I think the correct solution for this would be to use the addressableFields each account provides, but for now this implementation will do.

Can you just add an entry to the TODO list saying that maybe the X-IRC match should be done by providing the correct vcard fields in the messaging-framework plugin?

review: Needs Fixing
Revision history for this message
Renato Araujo Oliveira Filho (renatofilho) wrote :

> I think the correct solution for this would be to use the addressableFields
> each account provides, but for now this implementation will do.
>
> Can you just add an entry to the TODO list saying that maybe the X-IRC match
> should be done by providing the correct vcard fields in the messaging-
> framework plugin?

I am not sure if I understand what do you expect from "addressableFields". The contacts are not stored as Vcards and some fields does not have 1 to 1 relationship with the QContactFields, some kind of translation is inevitable.

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

> > I think the correct solution for this would be to use the addressableFields
> > each account provides, but for now this implementation will do.
> >
> > Can you just add an entry to the TODO list saying that maybe the X-IRC match
> > should be done by providing the correct vcard fields in the messaging-
> > framework plugin?
>
> I am not sure if I understand what do you expect from "addressableFields". The
> contacts are not stored as Vcards and some fields does not have 1 to 1
> relationship with the QContactFields, some kind of translation is inevitable.

For the IRC case, I would expect the addressableFields reported by the connection to contain the value "x-irc", and then use that to generate the contact filters. Doing a translation is fine, as long as we use the fields that the account reports as the reference for that.

Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

The code looks good, so approving it.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libtelephonyservice/contactwatcher.cpp'
2--- libtelephonyservice/contactwatcher.cpp 2017-03-03 17:51:11 +0000
3+++ libtelephonyservice/contactwatcher.cpp 2017-03-03 17:51:11 +0000
4@@ -34,6 +34,7 @@
5 #include <QContactDetailFilter>
6 #include <QContactIntersectionFilter>
7 #include <QContactUnionFilter>
8+#include <QContactOnlineAccount>
9
10 namespace C {
11 #include <libintl.h>
12@@ -63,6 +64,28 @@
13 }
14 }
15
16+QContactIntersectionFilter ContactWatcher::filterForField(const QString &field, const QString &identifier)
17+{
18+ QContactIntersectionFilter intersectionFilter;
19+
20+ if (field == "X-IRC") {
21+ QContactDetailFilter nameFilter = QContactDetailFilter();
22+ nameFilter.setDetailType(QContactOnlineAccount::Type, QContactOnlineAccount::FieldProtocol);
23+ nameFilter.setMatchFlags(QContactFilter::MatchExactly);
24+ nameFilter.setValue(QContactOnlineAccount::ProtocolIrc);
25+
26+ QContactDetailFilter valueFilter = QContactDetailFilter();
27+ valueFilter.setDetailType(QContactOnlineAccount::Type, QContactOnlineAccount::FieldAccountUri);
28+ valueFilter.setMatchFlags(QContactFilter::MatchExactly);
29+ valueFilter.setValue(identifier);
30+
31+ intersectionFilter.append(nameFilter);
32+ intersectionFilter.append(valueFilter);
33+ }
34+
35+ return intersectionFilter;
36+}
37+
38 void ContactWatcher::startSearching()
39 {
40 if (!mCompleted || mIdentifier.isEmpty() || !mInteractive || mAddressableFields.isEmpty()) {
41@@ -85,21 +108,25 @@
42 if (field == "tel") {
43 topLevelFilter.append(QContactPhoneNumber::match(mIdentifier));
44 } else {
45- // FIXME: handle more fields
46- // rely on a generic field filter
47- QContactDetailFilter nameFilter = QContactDetailFilter();
48- nameFilter.setDetailType(QContactExtendedDetail::Type, QContactExtendedDetail::FieldName);
49- nameFilter.setMatchFlags(QContactFilter::MatchExactly);
50- nameFilter.setValue(field);
51-
52- QContactDetailFilter valueFilter = QContactDetailFilter();
53- valueFilter.setDetailType(QContactExtendedDetail::Type, QContactExtendedDetail::FieldData);
54- valueFilter.setMatchFlags(QContactFilter::MatchExactly);
55- valueFilter.setValue(mIdentifier);
56-
57 QContactIntersectionFilter intersectionFilter;
58- intersectionFilter.append(nameFilter);
59- intersectionFilter.append(valueFilter);
60+ // try a special filter
61+ intersectionFilter = filterForField(field, mIdentifier);
62+ if (intersectionFilter.filters().isEmpty()) {
63+ // FIXME: handle more fields
64+ // rely on a generic field filter
65+ QContactDetailFilter nameFilter = QContactDetailFilter();
66+ nameFilter.setDetailType(QContactExtendedDetail::Type, QContactExtendedDetail::FieldName);
67+ nameFilter.setMatchFlags(QContactFilter::MatchExactly);
68+ nameFilter.setValue(field);
69+
70+ QContactDetailFilter valueFilter = QContactDetailFilter();
71+ valueFilter.setDetailType(QContactExtendedDetail::Type, QContactExtendedDetail::FieldData);
72+ valueFilter.setMatchFlags(QContactFilter::MatchExactly);
73+ valueFilter.setValue(mIdentifier);
74+
75+ intersectionFilter.append(nameFilter);
76+ intersectionFilter.append(valueFilter);
77+ }
78
79 topLevelFilter.append(intersectionFilter);
80 }
81
82=== modified file 'libtelephonyservice/contactwatcher.h'
83--- libtelephonyservice/contactwatcher.h 2017-03-03 17:51:11 +0000
84+++ libtelephonyservice/contactwatcher.h 2017-03-03 17:51:11 +0000
85@@ -27,6 +27,7 @@
86 #include <QContactManager>
87 #include <QContactAbstractRequest>
88 #include <QContactFetchRequest>
89+#include <QContactIntersectionFilter>
90 #include <QQmlParserStatus>
91
92 QTCONTACTS_USE_NAMESPACE
93@@ -99,6 +100,7 @@
94 void startSearching();
95 void clear();
96 void updateAlias();
97+ QContactIntersectionFilter filterForField(const QString &field, const QString &identifier);
98
99 QContactFetchRequest *mRequest;
100 QString mContactId;

Subscribers

People subscribed via source and target branches

to all changes: