Merge lp:~renatofilho/address-book-service/missing-features into lp:address-book-service

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Renato Araujo Oliveira Filho
Approved revision: 41
Merged at revision: 37
Proposed branch: lp:~renatofilho/address-book-service/missing-features
Merge into: lp:address-book-service
Prerequisite: lp:~renatofilho/address-book-service/fix-edit
Diff against target: 215 lines (+80/-18)
7 files modified
common/sort-clause.cpp (+7/-1)
common/sort-clause.h (+3/-1)
src/addressbook-adaptor.cpp (+6/-2)
src/addressbook-adaptor.h (+1/-1)
src/addressbook.cpp (+49/-10)
src/addressbook.h (+4/-1)
src/view.cpp (+10/-2)
To merge this branch: bzr merge lp:~renatofilho/address-book-service/missing-features
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Bill Filler (community) Approve
Review via email: mp+170610@code.launchpad.net

This proposal supersedes a proposal from 2013-06-18.

Commit message

Implemented AddressBook::availableSources.
Implemented support to change sort clause in the view.
Implemented AddressBook::sortFields.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

approved

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'common/sort-clause.cpp'
2--- common/sort-clause.cpp 2013-06-11 19:36:01 +0000
3+++ common/sort-clause.cpp 2013-06-21 17:49:24 +0000
4@@ -94,7 +94,13 @@
5 return m_sortOrders;
6 }
7
8-void SortClause::initialize() const
9+QStringList SortClause::supportedFields()
10+{
11+ initialize();
12+ return clauseFieldMap.keys();
13+}
14+
15+void SortClause::initialize()
16 {
17 if (clauseFieldMap.isEmpty()) {
18 clauseFieldMap["NAME_PREFIX"] = QPair<QContactDetail::DetailType, int>(QContactDetail::TypeName, QContactName::FieldPrefix);
19
20=== modified file 'common/sort-clause.h'
21--- common/sort-clause.h 2013-06-11 13:00:01 +0000
22+++ common/sort-clause.h 2013-06-21 17:49:24 +0000
23@@ -38,12 +38,14 @@
24 QString toString() const;
25 QList<QtContacts::QContactSortOrder> toContactSortOrder() const;
26
27+ static QStringList supportedFields();
28+
29 private:
30 QList<QtContacts::QContactSortOrder> m_sortOrders;
31
32 QtContacts::QContactSortOrder fromString(const QString &clause) const;
33 QString toString(const QtContacts::QContactSortOrder &sort) const;
34- void initialize() const;
35+ static void initialize();
36 };
37
38 }
39
40=== modified file 'src/addressbook-adaptor.cpp'
41--- src/addressbook-adaptor.cpp 2013-06-21 17:49:24 +0000
42+++ src/addressbook-adaptor.cpp 2013-06-21 17:49:24 +0000
43@@ -36,9 +36,13 @@
44 // destructor
45 }
46
47-SourceList AddressBookAdaptor::availableSources()
48+SourceList AddressBookAdaptor::availableSources(const QDBusMessage &message)
49 {
50- return m_addressBook->availableSources();
51+ message.setDelayedReply(true);
52+ QMetaObject::invokeMethod(m_addressBook, "availableSources",
53+ Qt::QueuedConnection,
54+ Q_ARG(const QDBusMessage&, message));
55+ return SourceList();
56 }
57
58 QString AddressBookAdaptor::createContact(const QString &contact, const QString &source, const QDBusMessage &message)
59
60=== modified file 'src/addressbook-adaptor.h'
61--- src/addressbook-adaptor.h 2013-06-21 17:49:24 +0000
62+++ src/addressbook-adaptor.h 2013-06-21 17:49:24 +0000
63@@ -98,7 +98,7 @@
64 virtual ~AddressBookAdaptor();
65
66 public Q_SLOTS:
67- SourceList availableSources();
68+ SourceList availableSources(const QDBusMessage &message);
69 QStringList sortFields();
70 QDBusObjectPath query(const QString &clause, const QString &sort, const QStringList &sources);
71 int removeContacts(const QStringList &contactIds, const QDBusMessage &message);
72
73=== modified file 'src/addressbook.cpp'
74--- src/addressbook.cpp 2013-06-21 17:49:24 +0000
75+++ src/addressbook.cpp 2013-06-21 17:49:24 +0000
76@@ -115,12 +115,54 @@
77 this);
78 }
79
80-SourceList AddressBook::availableSources()
81-{
82- //TODO
83- QList<Source> sources;
84- sources << Source("Facebook", false) << Source("Telepathy", true) << Source("Google", true);
85- return sources;
86+SourceList AddressBook::availableSources(const QDBusMessage &message)
87+{
88+ FolksBackendStore *backendStore = folks_backend_store_dup();
89+ QDBusMessage *msg = new QDBusMessage(message);
90+
91+ if (folks_backend_store_get_is_prepared(backendStore)) {
92+ availableSourcesReply(backendStore, 0, msg);
93+ } else {
94+ folks_backend_store_prepare(backendStore, (GAsyncReadyCallback) availableSourcesReply, msg);
95+ }
96+ return SourceList();
97+}
98+
99+void AddressBook::availableSourcesReply(FolksBackendStore *backendStore, GAsyncResult *res, QDBusMessage *message)
100+{
101+ if (res) {
102+ folks_backend_store_prepare_finish(backendStore, res);
103+ }
104+ GeeCollection *backends = folks_backend_store_list_backends(backendStore);
105+ SourceList result;
106+
107+ GeeIterator *iter = gee_iterable_iterator(GEE_ITERABLE(backends));
108+ while(gee_iterator_next(iter)) {
109+ FolksBackend *backend = FOLKS_BACKEND(gee_iterator_get(iter));
110+
111+ GeeMap *stores = folks_backend_get_persona_stores(backend);
112+ GeeCollection *values = gee_map_get_values(stores);
113+ GeeIterator *backendIter = gee_iterable_iterator(GEE_ITERABLE(values));
114+
115+ while(gee_iterator_next(backendIter)) {
116+ FolksPersonaStore *store = FOLKS_PERSONA_STORE(gee_iterator_get(backendIter));
117+
118+ QString id = QString::fromUtf8(folks_persona_store_get_id(store));
119+ bool canWrite = folks_persona_store_get_is_writeable(store);
120+ result << Source(id, !canWrite);
121+
122+ g_object_unref(store);
123+ }
124+
125+ g_object_unref(backendIter);
126+ g_object_unref(backend);
127+ g_object_unref(values);
128+ }
129+ g_object_unref(iter);
130+
131+ QDBusMessage reply = message->createReply(QVariant::fromValue<SourceList>(result));
132+ QDBusConnection::sessionBus().send(reply);
133+ delete message;
134 }
135
136 QString AddressBook::createContact(const QString &contact, const QString &source, const QDBusMessage &message)
137@@ -220,10 +262,7 @@
138
139 QStringList AddressBook::sortFields()
140 {
141- //TODO
142- QStringList fields;
143- fields << "id" << "name" << "full-name";
144- return fields;
145+ return SortClause::supportedFields();
146 }
147
148 bool AddressBook::unlinkContacts(const QString &parent, const QStringList &contacts)
149
150=== modified file 'src/addressbook.h'
151--- src/addressbook.h 2013-06-21 17:49:24 +0000
152+++ src/addressbook.h 2013-06-21 17:49:24 +0000
153@@ -52,7 +52,6 @@
154 bool registerObject(QDBusConnection &connection);
155
156 // Adaptor
157- SourceList availableSources();
158 QString linkContacts(const QStringList &contacts);
159 View *query(const QString &clause, const QString &sort, const QStringList &sources);
160 QStringList sortFields();
161@@ -60,6 +59,7 @@
162 bool isReady() const;
163
164 public Q_SLOTS:
165+ SourceList availableSources(const QDBusMessage &message);
166 QString createContact(const QString &contact, const QString &source, const QDBusMessage &message);
167 int removeContacts(const QStringList &contactIds, const QDBusMessage &message);
168 QStringList updateContacts(const QStringList &contacts, const QDBusMessage &message);
169@@ -84,6 +84,9 @@
170 QString removeContact(FolksIndividual *individual);
171 QString addContact(FolksIndividual *individual);
172
173+ static void availableSourcesReply(FolksBackendStore *backendStore,
174+ GAsyncResult *res,
175+ QDBusMessage *message);
176 static void individualsChangedCb(FolksIndividualAggregator *individualAggregator,
177 GeeMultiMap *changes,
178 AddressBook *self);
179
180=== modified file 'src/view.cpp'
181--- src/view.cpp 2013-06-21 17:49:24 +0000
182+++ src/view.cpp 2013-06-21 17:49:24 +0000
183@@ -86,6 +86,13 @@
184 return m_contacts.removeAll(entry);
185 }
186
187+ void chageSort(SortClause clause)
188+ {
189+ m_sortClause = clause;
190+ ContactLessThan lessThan(m_sortClause);
191+ qSort(m_contacts.begin(), m_contacts.end(), lessThan);
192+ }
193+
194 protected:
195 void run()
196 {
197@@ -95,8 +102,8 @@
198 m_contacts << entry;
199 }
200 }
201- ContactLessThan lessThan(m_sortClause);
202- qSort(m_contacts.begin(), m_contacts.end(), lessThan);
203+
204+ chageSort(m_sortClause);
205 }
206
207 private:
208@@ -185,6 +192,7 @@
209
210 void View::sort(const QString &field)
211 {
212+ m_filterThread->chageSort(SortClause(field));
213 }
214
215 QString View::objectPath()

Subscribers

People subscribed via source and target branches