~kzapalowicz/bluez/new-upstream-version-5.41

« back to all changes in this revision

Viewing changes to debian/patches/0001-obexd-plugins-port-ebook-support-to-the-latest-EDS.patch

  • Committer: Simon Fels
  • Date: 2016-02-03 09:16:08 UTC
  • mfrom: (9.1.3 bluez-bzr)
  • Revision ID: simon.fels@canonical.com-20160203091608-qri1wro86pfgztbz
Merging lp:~bluetooth/bluez/new-rel-5-37-plus-touch-xenial-sync

* New upstream version
* Add 0001-obexd-plugins-import-PBAP-ebook-support-from-upstrea.patch:
  - Pull in obexd ebook plugin from upstream git.
* Add 0001-obexd-plugins-port-ebook-support-to-the-latest-EDS.patch
* Add 0002-hostname-handle-chassis-type-handset.patch
* Add 0003-tools-mpris-proxy-allow-user-to-specify-different-mp.patch:
  - Allow use of an alternate DBus name by MPRIS if 'org.mpris' is not
    available.
* Add 0004-obexd-enable-ebook-backend-conditionally.patch:
  - Add a new configuration switch for EDS support.
* Add 0005-audio-media-return-empty-string-when-player-name-is-.patch:
  - If the name for the player is set as NULL we will crash later on
    so taking a valid default is required.
* Update bluez.install to include new btattach binary and manpage.
* Update rules:
      - enable obex phonebook-ebook by default
      - add enable-experimental to build and install additional
        tools/test scripts
* Update control:
  - add libebook-dev (>= 3.12) to Build-Depends
  - rename bluez-test-scripts to bluez-tests to reflect it does not only
    contain scripts but more utilities which can be used for wider testing
    of the BlueZ stack.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 7c7d01ec54cdde2e6d782e398c7b2a9600867e80 Mon Sep 17 00:00:00 2001
 
2
From: Simon Fels <simon.fels@canonical.com>
 
3
Date: Fri, 11 Sep 2015 18:46:26 +0200
 
4
Subject: [PATCH 1/4] obexd: plugins: port ebook support to the latest EDS
 
5
 
 
6
Signed-off-by: Simon Fels <simon.fels@canonical.com>
 
7
---
 
8
 obexd/plugins/phonebook-ebook.c | 132 ++++++++++++++++++----------------------
 
9
 1 file changed, 60 insertions(+), 72 deletions(-)
 
10
 
 
11
diff --git a/obexd/plugins/phonebook-ebook.c b/obexd/plugins/phonebook-ebook.c
 
12
index c422585..d1e6159 100644
 
13
--- a/obexd/plugins/phonebook-ebook.c
 
14
+++ b/obexd/plugins/phonebook-ebook.c
 
15
@@ -28,9 +28,9 @@
 
16
 
 
17
 #include <string.h>
 
18
 #include <errno.h>
 
19
-
 
20
 #include <glib.h>
 
21
-#include <libebook/e-book.h>
 
22
+
 
23
+#include <libebook/libebook.h>
 
24
 
 
25
 #include "lib/bluetooth.h"
 
26
 
 
27
@@ -158,13 +158,17 @@ static char *evcard_to_string(EVCard *evcard, unsigned int format,
 
28
        return vcard;
 
29
 }
 
30
 
 
31
-static void ebookpull_cb(EBook *book, const GError *gerr, GList *contacts,
 
32
-                                                       void *user_data)
 
33
+static void ebookpull_cb(EBookClient *client, GAsyncResult *res,
 
34
+                               gpointer user_data)
 
35
 {
 
36
        struct query_context *data = user_data;
 
37
-       GList *l;
 
38
+       GSList *l;
 
39
+       GSList *contacts = NULL;
 
40
+       GError *gerr = NULL;
 
41
        unsigned int count, maxcount;
 
42
 
 
43
+       e_book_client_get_contacts_finish(client, res, &contacts, &gerr);
 
44
+
 
45
        data->queued_calls--;
 
46
 
 
47
        if (data->canceled)
 
48
@@ -184,13 +188,13 @@ static void ebookpull_cb(EBook *book, const GError *gerr, GList *contacts,
 
49
         */
 
50
        maxcount = data->params->maxlistcount;
 
51
        if (maxcount == 0) {
 
52
-               data->count += g_list_length(contacts);
 
53
+               data->count += g_slist_length(contacts);
 
54
                goto done;
 
55
        }
 
56
 
 
57
-       l = g_list_nth(contacts, data->params->liststartoffset);
 
58
+       l = g_slist_nth(contacts, data->params->liststartoffset);
 
59
 
 
60
-       for (count = 0; l && count + data->count < maxcount; l = g_list_next(l),
 
61
+       for (count = 0; l && count + data->count < maxcount; l = g_slist_next(l),
 
62
                                                                count++) {
 
63
                EContact *contact = E_CONTACT(l->data);
 
64
                EVCard *evcard = E_VCARD(contact);
 
65
@@ -208,7 +212,7 @@ static void ebookpull_cb(EBook *book, const GError *gerr, GList *contacts,
 
66
 
 
67
        data->count += count;
 
68
 
 
69
-       g_list_free_full(contacts, g_object_unref);
 
70
+       g_slist_free_full(contacts, g_object_unref);
 
71
 
 
72
 done:
 
73
        if (data->queued_calls == 0) {
 
74
@@ -229,14 +233,18 @@ canceled:
 
75
                free_query_context(data);
 
76
 }
 
77
 
 
78
-static void ebook_entry_cb(EBook *book, const GError *gerr,
 
79
-                               EContact *contact, void *user_data)
 
80
+static void ebook_entry_cb(EBookClient *client, GAsyncResult *res,
 
81
+                               gpointer user_data)
 
82
 {
 
83
        struct query_context *data = user_data;
 
84
+       EContact *contact;
 
85
+       GError *gerr = NULL;
 
86
        EVCard *evcard;
 
87
        char *vcard;
 
88
        size_t len;
 
89
 
 
90
+       e_book_client_get_contact_finish(client, res, &contact, &gerr);
 
91
+
 
92
        data->queued_calls--;
 
93
 
 
94
        if (data->canceled)
 
95
@@ -244,6 +252,7 @@ static void ebook_entry_cb(EBook *book, const GError *gerr,
 
96
 
 
97
        if (gerr != NULL) {
 
98
                error("E-Book query failed: %s", gerr->message);
 
99
+               g_error_free(gerr);
 
100
                goto done;
 
101
        }
 
102
 
 
103
@@ -367,81 +376,55 @@ canceled:
 
104
                free_query_context(data);
 
105
 }
 
106
 
 
107
-static GSList *traverse_sources(GSList *ebooks, GSList *sources,
 
108
-                                                       char **default_src) {
 
109
+static GSList *traverse_sources(GSList *ebooks, ESource *source)
 
110
+{
 
111
        GError *gerr = NULL;
 
112
 
 
113
-       for (; sources != NULL; sources = g_slist_next(sources)) {
 
114
-               char *uri;
 
115
-               ESource *source = E_SOURCE(sources->data);
 
116
-               EBook *ebook = e_book_new(source, &gerr);
 
117
-
 
118
-               if (ebook == NULL) {
 
119
-                       error("Can't create user's address book: %s",
 
120
-                                                               gerr->message);
 
121
-                       g_clear_error(&gerr);
 
122
-                       continue;
 
123
-               }
 
124
-
 
125
-               uri = e_source_get_uri(source);
 
126
-               if (g_strcmp0(*default_src, uri) == 0) {
 
127
-                       g_free(uri);
 
128
-                       continue;
 
129
-               }
 
130
-               g_free(uri);
 
131
-
 
132
-               if (e_book_open(ebook, FALSE, &gerr) == FALSE) {
 
133
-                       error("Can't open e-book address book: %s",
 
134
+       EClient *client = e_book_client_connect_sync(source, -1, NULL, &gerr);
 
135
+       if (client == NULL) {
 
136
+               error("Can't create user's address book: %s",
 
137
                                                        gerr->message);
 
138
-                       g_object_unref(ebook);
 
139
-                       g_clear_error(&gerr);
 
140
-                       continue;
 
141
-               }
 
142
-
 
143
-               if (*default_src == NULL)
 
144
-                       *default_src = e_source_get_uri(source);
 
145
+               g_clear_error(&gerr);
 
146
+               return NULL;
 
147
+       }
 
148
 
 
149
-               DBG("%s address book opened", e_source_peek_name(source));
 
150
+       DBG("%s address book opened", e_source_get_display_name(source));
 
151
 
 
152
-               ebooks = g_slist_append(ebooks, ebook);
 
153
-       }
 
154
+       ebooks = g_slist_append(ebooks, client);
 
155
 
 
156
        return ebooks;
 
157
 }
 
158
 
 
159
 int phonebook_init(void)
 
160
 {
 
161
-       g_type_init();
 
162
-
 
163
        return 0;
 
164
 }
 
165
 
 
166
 static GSList *open_ebooks(void)
 
167
 {
 
168
        GError *gerr = NULL;
 
169
-       ESourceList *src_list;
 
170
-       GSList *list;
 
171
-       char *default_src = NULL;
 
172
+       GList *list;
 
173
        GSList *ebooks = NULL;
 
174
+       ESourceRegistry *registry;
 
175
 
 
176
-       if (e_book_get_addressbooks(&src_list, &gerr) == FALSE) {
 
177
+       registry = e_source_registry_new_sync(NULL, &gerr);
 
178
+       if (gerr) {
 
179
                error("Can't list user's address books: %s", gerr->message);
 
180
                g_error_free(gerr);
 
181
                return NULL;
 
182
        }
 
183
 
 
184
-       list = e_source_list_peek_groups(src_list);
 
185
+       list = e_source_registry_list_sources(registry, E_SOURCE_EXTENSION_ADDRESS_BOOK);
 
186
        while (list != NULL) {
 
187
-               ESourceGroup *group = E_SOURCE_GROUP(list->data);
 
188
-               GSList *sources = e_source_group_peek_sources(group);
 
189
+               ESource *source = E_SOURCE(list->data);
 
190
 
 
191
-               ebooks = traverse_sources(ebooks, sources, &default_src);
 
192
+               ebooks = traverse_sources(ebooks, source);
 
193
 
 
194
                list = list->next;
 
195
        }
 
196
 
 
197
-       g_free(default_src);
 
198
-       g_object_unref(src_list);
 
199
+       g_list_free_full(list, g_object_unref);
 
200
+       g_object_unref(registry);
 
201
 
 
202
        return ebooks;
 
203
 }
 
204
@@ -579,14 +562,13 @@ int phonebook_pull_read(void *request)
 
205
                return -ENOENT;
 
206
 
 
207
        for (l = data->ebooks; l != NULL; l = g_slist_next(l)) {
 
208
-               EBook *ebook = l->data;
 
209
-
 
210
-               if (e_book_is_opened(ebook) == FALSE)
 
211
-                       continue;
 
212
+               EClient *client = l->data;
 
213
+               gchar *query = e_book_query_to_string(data->query);
 
214
 
 
215
-               if (e_book_get_contacts_async(ebook, data->query,
 
216
-                                               ebookpull_cb, data) == TRUE)
 
217
-                       data->queued_calls++;
 
218
+               e_book_client_get_contacts(E_BOOK_CLIENT(client), query,
 
219
+                                               NULL, (GAsyncReadyCallback) ebookpull_cb, data);
 
220
+               data->queued_calls++;
 
221
+               g_free(query);
 
222
        }
 
223
 
 
224
        if (data->queued_calls == 0)
 
225
@@ -610,14 +592,11 @@ void *phonebook_get_entry(const char *folder, const char *id,
 
226
        data->ebooks = open_ebooks();
 
227
 
 
228
        for (l = data->ebooks; l != NULL; l = g_slist_next(l)) {
 
229
-               EBook *ebook = l->data;
 
230
-
 
231
-               if (e_book_is_opened(ebook) == FALSE)
 
232
-                       continue;
 
233
+               EClient *client = l->data;
 
234
 
 
235
-               if (e_book_get_contact_async(ebook, data->id,
 
236
-                                               ebook_entry_cb, data) == TRUE)
 
237
-                       data->queued_calls++;
 
238
+               e_book_client_get_contact(E_BOOK_CLIENT(client), data->id,
 
239
+                                       NULL, (GAsyncReadyCallback) ebook_entry_cb, data);
 
240
+               data->queued_calls++;
 
241
        }
 
242
 
 
243
        if (err)
 
244
@@ -630,12 +609,13 @@ void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
 
245
                phonebook_cache_ready_cb ready_cb, void *user_data, int *err)
 
246
 {
 
247
        struct query_context *data;
 
248
+       ESourceRegistry *registry;
 
249
        EBookQuery *query;
 
250
        GSList *l;
 
251
        EContact *me;
 
252
        EVCard *evcard;
 
253
        GError *gerr = NULL;
 
254
-       EBook *eb;
 
255
+       EBookClient *eb;
 
256
        EVCardAttribute *attrib;
 
257
        char *uid, *tel, *cname;
 
258
 
 
259
@@ -648,6 +628,13 @@ void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
 
260
 
 
261
        DBG("");
 
262
 
 
263
+       registry = e_source_registry_new_sync(NULL, &gerr);
 
264
+       if (gerr) {
 
265
+               error("Can't access user's address books: %s", gerr->message);
 
266
+               g_error_free(gerr);
 
267
+               return NULL;
 
268
+       }
 
269
+
 
270
        query = e_book_query_any_field_contains("");
 
271
 
 
272
        data = g_new0(struct query_context, 1);
 
273
@@ -658,7 +645,7 @@ void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
 
274
        data->ebooks = open_ebooks();
 
275
 
 
276
        /* Add 0.vcf */
 
277
-       if (e_book_get_self(&me, &eb, &gerr) == FALSE) {
 
278
+       if (e_book_client_get_self(registry, &me, &eb, &gerr) == FALSE) {
 
279
                g_error_free(gerr);
 
280
                goto next;
 
281
        }
 
282
@@ -688,6 +675,7 @@ void *phonebook_create_cache(const char *name, phonebook_entry_cb entry_cb,
 
283
        g_free(uid);
 
284
        g_free(tel);
 
285
        g_object_unref(eb);
 
286
+       g_object_unref(registry);
 
287
 
 
288
 next:
 
289
        for (l = data->ebooks; l != NULL; l = g_slist_next(l)) {
 
290
-- 
 
291
2.5.0
 
292