You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1490 lines
48 KiB

  1. diff --git a/meson.build b/meson.build
  2. index 33a6f40..8a590b9 100644
  3. --- a/meson.build
  4. +++ b/meson.build
  5. @@ -62,7 +62,12 @@ gstreamer_dep = dependency('gstreamer-1.0', required: false)
  6. gthread_dep = dependency('gthread-2.0', required: false)
  7. json_glib_dep = dependency('json-glib-1.0', required: false)
  8. libarchive_dep = dependency('libarchive', required: false)
  9. -libdmapsharing_dep = dependency('libdmapsharing-3.0', version: '>= 2.9.12', required: false)
  10. +libdmapsharing4_dep = dependency('libdmapsharing-4.0', version: '>= 3.9.4', required: false)
  11. +if libdmapsharing4_dep.found()
  12. + libdmapsharing_dep = libdmapsharing4_dep
  13. +else
  14. + libdmapsharing_dep = dependency('libdmapsharing-3.0', version: '>= 2.9.12', required: false)
  15. +endif
  16. libgdata_dep = dependency('libgdata', version: '>= 0.9.1', required: false)
  17. libmediaart_dep = dependency('libmediaart-2.0', required: false)
  18. libsoup_dep = dependency('libsoup-2.4', required: false)
  19. diff --git a/src/dmap/grl-common.c b/src/dmap/grl-common.c
  20. index 6a1da5e..74a965f 100644
  21. --- a/src/dmap/grl-common.c
  22. +++ b/src/dmap/grl-common.c
  23. @@ -33,13 +33,27 @@
  24. #include <stdlib.h>
  25. #include <libdmapsharing/dmap.h>
  26. +#include "grl-dmap-compat.h"
  27. #include "grl-common.h"
  28. gchar *
  29. -grl_dmap_build_url (DMAPMdnsBrowserService *service)
  30. +grl_dmap_build_url (DmapMdnsService *service)
  31. {
  32. - return g_strdup_printf ("%s://%s:%u",
  33. - service->service_name,
  34. - service->host,
  35. - service->port);
  36. + gchar *url = NULL;
  37. + gchar *service_name, *host;
  38. + guint port;
  39. +
  40. + service_name = grl_dmap_service_get_service_name (service);
  41. + host = grl_dmap_service_get_host (service);
  42. + port = grl_dmap_service_get_port (service);
  43. +
  44. + url = g_strdup_printf ("%s://%s:%u",
  45. + service_name,
  46. + host,
  47. + port);
  48. +
  49. + g_free (service_name);
  50. + g_free (host);
  51. +
  52. + return url;
  53. }
  54. diff --git a/src/dmap/grl-common.h b/src/dmap/grl-common.h
  55. index e9c8327..d61df63 100644
  56. --- a/src/dmap/grl-common.h
  57. +++ b/src/dmap/grl-common.h
  58. @@ -24,9 +24,6 @@
  59. #ifndef _GRL_COMMON_H_
  60. #define _GRL_COMMON_H_
  61. -#include <grilo.h>
  62. -#include <libdmapsharing/dmap.h>
  63. -
  64. typedef struct {
  65. GrlSourceResultCb callback;
  66. GrlSource *source;
  67. @@ -41,9 +38,9 @@ typedef struct {
  68. typedef struct {
  69. ResultCbAndArgs cb;
  70. - DMAPDb *db;
  71. + DmapDb *db;
  72. } ResultCbAndArgsAndDb;
  73. -gchar *grl_dmap_build_url (DMAPMdnsBrowserService *service);
  74. +gchar *grl_dmap_build_url (DmapMdnsService *service);
  75. #endif /* _GRL_COMMON_H_ */
  76. diff --git a/src/dmap/grl-daap-compat.h b/src/dmap/grl-daap-compat.h
  77. new file mode 100644
  78. index 0000000..da9025f
  79. --- /dev/null
  80. +++ b/src/dmap/grl-daap-compat.h
  81. @@ -0,0 +1,76 @@
  82. +/*
  83. + * Copyright (C) 2019 W. Michael Petullo
  84. + * Copyright (C) 2019 Igalia S.L.
  85. + *
  86. + * Contact: W. Michael Petullo <mike@flyn.org>
  87. + *
  88. + * This library is free software; you can redistribute it and/or
  89. + * modify it under the terms of the GNU Lesser General Public License
  90. + * as published by the Free Software Foundation; version 2.1 of
  91. + * the License, or (at your option) any later version.
  92. + *
  93. + * This library is distributed in the hope that it will be useful, but
  94. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  95. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  96. + * Lesser General Public License for more details.
  97. + *
  98. + * You should have received a copy of the GNU Lesser General Public
  99. + * License along with this library; if not, write to the Free Software
  100. + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  101. + * 02110-1301 USA
  102. + *
  103. + */
  104. +
  105. +#ifndef _GRL_DAAP_COMPAT_H_
  106. +#define _GRL_DAAP_COMPAT_H_
  107. +
  108. +#include "grl-dmap-compat.h"
  109. +
  110. +#ifdef LIBDMAPSHARING_COMPAT
  111. +
  112. +DMAPRecord *grl_daap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data, GError **error);
  113. +guint grl_daap_db_add (DMAPDb *_db, DMAPRecord *_record, GError **error);
  114. +
  115. +/* Building against libdmapsharing 3 API. */
  116. +
  117. +#define dmap_av_connection_new daap_connection_new
  118. +#define DmapAvRecord DAAPRecord
  119. +#define DmapAvRecordInterface DAAPRecordIface
  120. +#define DMAP_AV_RECORD DAAP_RECORD
  121. +#define DMAP_TYPE_AV_RECORD DAAP_TYPE_RECORD
  122. +#define IS_DMAP_AV_RECORD IS_DAAP_RECORD
  123. +
  124. +static inline DmapRecord *
  125. +grl_daap_record_factory_create_compat (DmapRecordFactory *factory, gpointer user_data)
  126. +{
  127. + return grl_daap_record_factory_create (factory, user_data, NULL);
  128. +}
  129. +
  130. +static inline guint
  131. +grl_daap_db_add_compat (DmapDb *_db, DmapRecord *_record)
  132. +{
  133. + return grl_daap_db_add (_db, _record, NULL);
  134. +}
  135. +
  136. +#else
  137. +
  138. +/* Building against libdmapsharing 4 API. */
  139. +
  140. +DmapRecord *grl_daap_record_factory_create (DmapRecordFactory *factory, gpointer user_data, GError **error);
  141. +guint grl_daap_db_add (DmapDb *_db, DmapRecord *_record, GError **error);
  142. +
  143. +static inline DmapRecord *
  144. +grl_daap_record_factory_create_compat (DmapRecordFactory *factory, gpointer user_data, GError **error)
  145. +{
  146. + return grl_daap_record_factory_create (factory, user_data, error);
  147. +}
  148. +
  149. +static inline guint
  150. +grl_daap_db_add_compat (DmapDb *_db, DmapRecord *_record, GError **error)
  151. +{
  152. + return grl_daap_db_add (_db, _record, error);
  153. +}
  154. +
  155. +#endif
  156. +
  157. +#endif /* _GRL_DAAP_COMPAT_H_ */
  158. diff --git a/src/dmap/grl-daap-db.c b/src/dmap/grl-daap-db.c
  159. index f460113..315370e 100644
  160. --- a/src/dmap/grl-daap-db.c
  161. +++ b/src/dmap/grl-daap-db.c
  162. @@ -54,8 +54,12 @@
  163. #include <sys/stat.h>
  164. #include <sys/types.h>
  165. #include <glib.h>
  166. +#include <grilo.h>
  167. #include <string.h>
  168. +#include <libdmapsharing/dmap.h>
  169. +#include "grl-daap-compat.h"
  170. +#include "grl-common.h"
  171. #include "grl-daap-db.h"
  172. #define ALBUMS_ID "albums"
  173. @@ -103,23 +107,23 @@ grl_daap_db_new (void)
  174. return db;
  175. }
  176. -static DMAPRecord *
  177. -grl_daap_db_lookup_by_id (const DMAPDb *db, guint id)
  178. +static DmapRecord *
  179. +grl_daap_db_lookup_by_id (const DmapDb *db, guint id)
  180. {
  181. g_error ("Not implemented");
  182. return NULL;
  183. }
  184. static void
  185. -grl_daap_db_foreach (const DMAPDb *db,
  186. - GHFunc func,
  187. +grl_daap_db_foreach (const DmapDb *db,
  188. + DmapIdRecordFunc func,
  189. gpointer data)
  190. {
  191. g_error ("Not implemented");
  192. }
  193. static gint64
  194. -grl_daap_db_count (const DMAPDb *db)
  195. +grl_daap_db_count (const DmapDb *db)
  196. {
  197. g_error ("Not implemented");
  198. return 0;
  199. @@ -150,14 +154,14 @@ set_insert (GHashTable *category, const char *category_name, char *set_name, Grl
  200. g_object_unref (container);
  201. }
  202. -static guint
  203. -grl_daap_db_add (DMAPDb *_db, DMAPRecord *_record)
  204. +guint
  205. +grl_daap_db_add (DmapDb *_db, DmapRecord *_record, GError **error)
  206. {
  207. g_assert (IS_GRL_DAAP_DB (_db));
  208. - g_assert (IS_DAAP_RECORD (_record));
  209. + g_assert (IS_DMAP_AV_RECORD (_record));
  210. GrlDAAPDb *db = GRL_DAAP_DB (_db);
  211. - DAAPRecord *record = DAAP_RECORD (_record);
  212. + DmapAvRecord *record = DMAP_AV_RECORD (_record);
  213. gint duration = 0;
  214. gint32 bitrate = 0,
  215. @@ -232,11 +236,11 @@ grl_daap_db_add (DMAPDb *_db, DMAPRecord *_record)
  216. g_free (id_s);
  217. g_object_unref (media);
  218. - g_free(album);
  219. - g_free(artist);
  220. - g_free(genre);
  221. - g_free(title);
  222. - g_free(url);
  223. + g_free (album);
  224. + g_free (artist);
  225. + g_free (genre);
  226. + g_free (title);
  227. + g_free (url);
  228. return --nextid;
  229. }
  230. @@ -359,11 +363,11 @@ grl_daap_db_search (GrlDAAPDb *db,
  231. static void
  232. dmap_db_interface_init (gpointer iface, gpointer data)
  233. {
  234. - DMAPDbIface *daap_db = iface;
  235. + DmapDbInterface *daap_db = iface;
  236. g_assert (G_TYPE_FROM_INTERFACE (daap_db) == DMAP_TYPE_DB);
  237. - daap_db->add = grl_daap_db_add;
  238. + daap_db->add = grl_daap_db_add_compat;
  239. daap_db->lookup_by_id = grl_daap_db_lookup_by_id;
  240. daap_db->foreach = grl_daap_db_foreach;
  241. daap_db->count = grl_daap_db_count;
  242. diff --git a/src/dmap/grl-daap-db.h b/src/dmap/grl-daap-db.h
  243. index 2548c50..1a37a3a 100644
  244. --- a/src/dmap/grl-daap-db.h
  245. +++ b/src/dmap/grl-daap-db.h
  246. @@ -24,6 +24,8 @@
  247. #include <libdmapsharing/dmap.h>
  248. #include <grilo.h>
  249. +#include "grl-daap-compat.h"
  250. +
  251. G_BEGIN_DECLS
  252. #define TYPE_GRL_DAAP_DB (grl_daap_db_get_type ())
  253. diff --git a/src/dmap/grl-daap-record-factory.c b/src/dmap/grl-daap-record-factory.c
  254. index 648fd85..d0c590f 100644
  255. --- a/src/dmap/grl-daap-record-factory.c
  256. +++ b/src/dmap/grl-daap-record-factory.c
  257. @@ -1,5 +1,5 @@
  258. /*
  259. - * DAAPRecord factory class
  260. + * DmapAvRecord factory class
  261. *
  262. * Copyright (C) 2008 W. Michael Petullo <mike@flyn.org>
  263. *
  264. @@ -18,11 +18,16 @@
  265. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  266. */
  267. +#include <grilo.h>
  268. +#include <libdmapsharing/dmap.h>
  269. +
  270. +#include "grl-daap-compat.h"
  271. +#include "grl-common.h"
  272. #include "grl-daap-record-factory.h"
  273. #include "grl-daap-record.h"
  274. -DMAPRecord *
  275. -grl_daap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data)
  276. +DmapRecord *
  277. +grl_daap_record_factory_create (DmapRecordFactory *factory, gpointer user_data, GError **error)
  278. {
  279. return DMAP_RECORD (grl_daap_record_new ());
  280. }
  281. @@ -40,11 +45,11 @@ grl_daap_record_factory_class_init (GrlDAAPRecordFactoryClass *klass)
  282. static void
  283. grl_daap_record_factory_interface_init (gpointer iface, gpointer data)
  284. {
  285. - DMAPRecordFactoryIface *factory = iface;
  286. + DmapRecordFactoryInterface *factory = iface;
  287. g_assert (G_TYPE_FROM_INTERFACE (factory) == DMAP_TYPE_RECORD_FACTORY);
  288. - factory->create = grl_daap_record_factory_create;
  289. + factory->create = grl_daap_record_factory_create_compat;
  290. }
  291. G_DEFINE_TYPE_WITH_CODE (GrlDAAPRecordFactory, grl_daap_record_factory, G_TYPE_OBJECT,
  292. diff --git a/src/dmap/grl-daap-record-factory.h b/src/dmap/grl-daap-record-factory.h
  293. index 45aa69a..f114bad 100644
  294. --- a/src/dmap/grl-daap-record-factory.h
  295. +++ b/src/dmap/grl-daap-record-factory.h
  296. @@ -23,6 +23,8 @@
  297. #include <libdmapsharing/dmap.h>
  298. +#include "grl-daap-compat.h"
  299. +
  300. G_BEGIN_DECLS
  301. #define TYPE_SIMPLE_DAAP_RECORD_FACTORY (grl_daap_record_factory_get_type ())
  302. @@ -64,8 +66,6 @@ GType grl_daap_record_factory_get_type (void);
  303. GrlDAAPRecordFactory *grl_daap_record_factory_new (void);
  304. -DMAPRecord *grl_daap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data);
  305. -
  306. #endif /* __SIMPLE_DAAP_RECORD_FACTORY */
  307. G_END_DECLS
  308. diff --git a/src/dmap/grl-daap-record.c b/src/dmap/grl-daap-record.c
  309. index 82bf2f9..4fa0c54 100644
  310. --- a/src/dmap/grl-daap-record.c
  311. +++ b/src/dmap/grl-daap-record.c
  312. @@ -20,6 +20,11 @@
  313. *
  314. */
  315. +#include <grilo.h>
  316. +#include <libdmapsharing/dmap.h>
  317. +
  318. +#include "grl-daap-compat.h"
  319. +#include "grl-common.h"
  320. #include "grl-daap-record.h"
  321. struct GrlDAAPRecordPrivate {
  322. @@ -226,7 +231,7 @@ grl_daap_record_new (void)
  323. }
  324. GInputStream *
  325. -grl_daap_record_read (DAAPRecord *record, GError **error)
  326. +grl_daap_record_read (DmapAvRecord *record, GError **error)
  327. {
  328. GFile *file;
  329. GInputStream *stream;
  330. @@ -280,9 +285,9 @@ grl_daap_record_class_init (GrlDAAPRecordClass *klass)
  331. static void
  332. grl_daap_record_daap_iface_init (gpointer iface, gpointer data)
  333. {
  334. - DAAPRecordIface *daap_record = iface;
  335. + DmapAvRecordInterface *daap_record = iface;
  336. - g_assert (G_TYPE_FROM_INTERFACE (daap_record) == DAAP_TYPE_RECORD);
  337. + g_assert (G_TYPE_FROM_INTERFACE (daap_record) == DMAP_TYPE_AV_RECORD);
  338. daap_record->read = grl_daap_record_read;
  339. }
  340. @@ -290,7 +295,7 @@ grl_daap_record_daap_iface_init (gpointer iface, gpointer data)
  341. static void
  342. grl_daap_record_dmap_iface_init (gpointer iface, gpointer data)
  343. {
  344. - DMAPRecordIface *dmap_record = iface;
  345. + DmapRecordInterface *dmap_record = iface;
  346. g_assert (G_TYPE_FROM_INTERFACE (dmap_record) == DMAP_TYPE_RECORD);
  347. }
  348. @@ -298,7 +303,7 @@ grl_daap_record_dmap_iface_init (gpointer iface, gpointer data)
  349. G_DEFINE_TYPE_WITH_CODE (GrlDAAPRecord, grl_daap_record, G_TYPE_OBJECT,
  350. G_ADD_PRIVATE (GrlDAAPRecord)
  351. - G_IMPLEMENT_INTERFACE (DAAP_TYPE_RECORD, grl_daap_record_daap_iface_init)
  352. + G_IMPLEMENT_INTERFACE (DMAP_TYPE_AV_RECORD, grl_daap_record_daap_iface_init)
  353. G_IMPLEMENT_INTERFACE (DMAP_TYPE_RECORD, grl_daap_record_dmap_iface_init))
  354. static void
  355. diff --git a/src/dmap/grl-daap-record.h b/src/dmap/grl-daap-record.h
  356. index 7aae82d..42782b1 100644
  357. --- a/src/dmap/grl-daap-record.h
  358. +++ b/src/dmap/grl-daap-record.h
  359. @@ -23,6 +23,8 @@
  360. #include <libdmapsharing/dmap.h>
  361. +#include "grl-daap-compat.h"
  362. +
  363. G_BEGIN_DECLS
  364. #define TYPE_SIMPLE_DAAP_RECORD (grl_daap_record_get_type ())
  365. @@ -69,8 +71,8 @@ typedef struct {
  366. GType grl_daap_record_get_type (void);
  367. GrlDAAPRecord *grl_daap_record_new (void);
  368. -GInputStream *grl_daap_record_read (DAAPRecord *record, GError **error);
  369. -gint grl_daap_record_get_id (DAAPRecord *record);
  370. +GInputStream *grl_daap_record_read (DmapAvRecord *record, GError **error);
  371. +gint grl_daap_record_get_id (DmapAvRecord *record);
  372. #endif /* __SIMPLE_DAAP_RECORD */
  373. diff --git a/src/dmap/grl-daap.c b/src/dmap/grl-daap.c
  374. index f3c4115..962f2b8 100644
  375. --- a/src/dmap/grl-daap.c
  376. +++ b/src/dmap/grl-daap.c
  377. @@ -33,6 +33,7 @@
  378. #include <stdlib.h>
  379. #include <libdmapsharing/dmap.h>
  380. +#include "grl-daap-compat.h"
  381. #include "grl-common.h"
  382. #include "grl-daap.h"
  383. #include "grl-daap-db.h"
  384. @@ -52,12 +53,12 @@ GRL_LOG_DOMAIN_STATIC (daap_log_domain);
  385. /* --- Grilo DAAP Private --- */
  386. struct _GrlDaapSourcePrivate {
  387. - DMAPMdnsBrowserService *service;
  388. + DmapMdnsService *service;
  389. };
  390. /* --- Data types --- */
  391. -static GrlDaapSource *grl_daap_source_new (DMAPMdnsBrowserService *service);
  392. +static GrlDaapSource *grl_daap_source_new (DmapMdnsService *service);
  393. static void grl_daap_source_finalize (GObject *object);
  394. @@ -74,16 +75,16 @@ static void grl_daap_source_search (GrlSource *source,
  395. GrlSourceSearchSpec *ss);
  396. -static void grl_daap_service_added_cb (DMAPMdnsBrowser *browser,
  397. - DMAPMdnsBrowserService *service,
  398. +static void grl_daap_service_added_cb (DmapMdnsBrowser *browser,
  399. + DmapMdnsService *service,
  400. GrlPlugin *plugin);
  401. -static void grl_daap_service_removed_cb (DMAPMdnsBrowser *browser,
  402. +static void grl_daap_service_removed_cb (DmapMdnsBrowser *browser,
  403. const gchar *service_name,
  404. GrlPlugin *plugin);
  405. /* ===================== Globals ======================= */
  406. -static DMAPMdnsBrowser *browser;
  407. +static DmapMdnsBrowser *browser;
  408. /* Maps URIs to DBs */
  409. static GHashTable *connections;
  410. /* Map DAAP services to Grilo media sources */
  411. @@ -106,7 +107,7 @@ grl_daap_plugin_init (GrlRegistry *registry,
  412. bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  413. bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  414. - browser = dmap_mdns_browser_new (DMAP_MDNS_BROWSER_SERVICE_TYPE_DAAP);
  415. + browser = dmap_mdns_browser_new (DMAP_MDNS_SERVICE_TYPE_DAAP);
  416. connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
  417. sources = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
  418. @@ -153,8 +154,10 @@ GRL_PLUGIN_DEFINE (GRL_MAJOR,
  419. G_DEFINE_TYPE_WITH_PRIVATE (GrlDaapSource, grl_daap_source, GRL_TYPE_SOURCE)
  420. static GrlDaapSource *
  421. -grl_daap_source_new (DMAPMdnsBrowserService *service)
  422. +grl_daap_source_new (DmapMdnsService *service)
  423. {
  424. + gchar *name;
  425. + gchar *service_name;
  426. gchar *source_desc;
  427. gchar *source_id;
  428. @@ -162,12 +165,15 @@ grl_daap_source_new (DMAPMdnsBrowserService *service)
  429. GRL_DEBUG ("grl_daap_source_new");
  430. - source_desc = g_strdup_printf (SOURCE_DESC_TEMPLATE, service->name);
  431. - source_id = g_strdup_printf (SOURCE_ID_TEMPLATE, service->name);
  432. + name = grl_dmap_service_get_name (service);
  433. + service_name = grl_dmap_service_get_service_name (service);
  434. +
  435. + source_desc = g_strdup_printf (SOURCE_DESC_TEMPLATE, name);
  436. + source_id = g_strdup_printf (SOURCE_ID_TEMPLATE, name);
  437. source = g_object_new (GRL_DAAP_SOURCE_TYPE,
  438. "source-id", source_id,
  439. - "source-name", service->name,
  440. + "source-name", service_name,
  441. "source-desc", source_desc,
  442. "supported-media", GRL_SUPPORTED_MEDIA_AUDIO,
  443. NULL);
  444. @@ -176,6 +182,8 @@ grl_daap_source_new (DMAPMdnsBrowserService *service)
  445. g_free (source_desc);
  446. g_free (source_id);
  447. + g_free (service_name);
  448. + g_free (name);
  449. return source;
  450. }
  451. @@ -209,7 +217,7 @@ grl_daap_source_finalize (GObject *object)
  452. static void
  453. grl_daap_do_browse (ResultCbAndArgsAndDb *cb_and_db)
  454. {
  455. - grl_daap_db_browse (GRL_DAAP_DB(cb_and_db->db),
  456. + grl_daap_db_browse (GRL_DAAP_DB (cb_and_db->db),
  457. cb_and_db->cb.container,
  458. cb_and_db->cb.source,
  459. cb_and_db->cb.op_id,
  460. @@ -236,7 +244,7 @@ grl_daap_do_search (ResultCbAndArgsAndDb *cb_and_db)
  461. }
  462. static void
  463. -browse_connected_cb (DMAPConnection *connection,
  464. +browse_connected_cb (DmapConnection *connection,
  465. gboolean result,
  466. const char *reason,
  467. ResultCbAndArgsAndDb *cb_and_db)
  468. @@ -261,7 +269,7 @@ browse_connected_cb (DMAPConnection *connection,
  469. }
  470. static void
  471. -search_connected_cb (DMAPConnection *connection,
  472. +search_connected_cb (DmapConnection *connection,
  473. gboolean result,
  474. const char *reason,
  475. ResultCbAndArgsAndDb *cb_and_db)
  476. @@ -286,8 +294,8 @@ search_connected_cb (DMAPConnection *connection,
  477. }
  478. static void
  479. -grl_daap_service_added_cb (DMAPMdnsBrowser *browser,
  480. - DMAPMdnsBrowserService *service,
  481. +grl_daap_service_added_cb (DmapMdnsBrowser *browser,
  482. + DmapMdnsService *service,
  483. GrlPlugin *plugin)
  484. {
  485. GrlRegistry *registry = grl_registry_get_default ();
  486. @@ -301,13 +309,16 @@ grl_daap_service_added_cb (DMAPMdnsBrowser *browser,
  487. GRL_SOURCE (source),
  488. NULL);
  489. if (source != NULL) {
  490. - g_hash_table_insert (sources, g_strdup (service->name), g_object_ref (source));
  491. + gchar *name;
  492. + name = grl_dmap_service_get_name (service);
  493. + g_hash_table_insert (sources, g_strdup (name), g_object_ref (source));
  494. g_object_remove_weak_pointer (G_OBJECT (source), (gpointer *) &source);
  495. + g_free (name);
  496. }
  497. }
  498. static void
  499. -grl_daap_service_removed_cb (DMAPMdnsBrowser *browser,
  500. +grl_daap_service_removed_cb (DmapMdnsBrowser *browser,
  501. const gchar *service_name,
  502. GrlPlugin *plugin)
  503. {
  504. @@ -323,14 +334,14 @@ grl_daap_service_removed_cb (DMAPMdnsBrowser *browser,
  505. }
  506. static void
  507. -grl_daap_connect (gchar *name, gchar *host, guint port, ResultCbAndArgsAndDb *cb_and_db, DMAPConnectionCallback callback)
  508. +grl_daap_connect (gchar *name, gchar *host, guint port, ResultCbAndArgsAndDb *cb_and_db, DmapConnectionFunc callback)
  509. {
  510. - DMAPRecordFactory *factory;
  511. - DMAPConnection *connection;
  512. + DmapRecordFactory *factory;
  513. + DmapConnection *connection;
  514. factory = DMAP_RECORD_FACTORY (grl_daap_record_factory_new ());
  515. - connection = DMAP_CONNECTION (daap_connection_new (name, host, port, DMAP_DB (cb_and_db->db), factory));
  516. - dmap_connection_connect (connection, (DMAPConnectionCallback) callback, cb_and_db);
  517. + connection = DMAP_CONNECTION (dmap_av_connection_new (name, host, port, DMAP_DB (cb_and_db->db), factory));
  518. + dmap_connection_start (connection, (DmapConnectionFunc) callback, cb_and_db);
  519. }
  520. static gboolean
  521. @@ -397,15 +408,25 @@ grl_daap_source_browse (GrlSource *source,
  522. browse_connected_cb (NULL, TRUE, NULL, cb_and_db);
  523. } else {
  524. /* Connect */
  525. + gchar *name, *host;
  526. + guint port;
  527. +
  528. cb_and_db->db = DMAP_DB (grl_daap_db_new ());
  529. - grl_daap_connect (dmap_source->priv->service->name,
  530. - dmap_source->priv->service->host,
  531. - dmap_source->priv->service->port,
  532. + name = grl_dmap_service_get_name (dmap_source->priv->service);
  533. + host = grl_dmap_service_get_host (dmap_source->priv->service);
  534. + port = grl_dmap_service_get_port (dmap_source->priv->service);
  535. +
  536. + grl_daap_connect (name,
  537. + host,
  538. + port,
  539. cb_and_db,
  540. - (DMAPConnectionCallback) browse_connected_cb);
  541. + (DmapConnectionFunc) browse_connected_cb);
  542. g_hash_table_insert (connections, g_strdup (url), cb_and_db->db);
  543. +
  544. + g_free (name);
  545. + g_free (host);
  546. }
  547. g_free (url);
  548. @@ -417,7 +438,7 @@ static void grl_daap_source_search (GrlSource *source,
  549. GrlDaapSource *dmap_source = GRL_DAAP_SOURCE (source);
  550. ResultCbAndArgsAndDb *cb_and_db;
  551. - DMAPMdnsBrowserService *service = dmap_source->priv->service;
  552. + DmapMdnsService *service = dmap_source->priv->service;
  553. gchar *url = grl_dmap_build_url (service);
  554. cb_and_db = g_new (ResultCbAndArgsAndDb, 1);
  555. @@ -435,9 +456,25 @@ static void grl_daap_source_search (GrlSource *source,
  556. search_connected_cb (NULL, TRUE, NULL, cb_and_db);
  557. } else {
  558. /* Connect */
  559. + gchar *name, *host;
  560. + guint port;
  561. +
  562. cb_and_db->db = DMAP_DB (grl_daap_db_new ());
  563. - grl_daap_connect (service->name, service->host, service->port, cb_and_db, (DMAPConnectionCallback) search_connected_cb);
  564. +
  565. + name = grl_dmap_service_get_name (dmap_source->priv->service);
  566. + host = grl_dmap_service_get_host (dmap_source->priv->service);
  567. + port = grl_dmap_service_get_port (dmap_source->priv->service);
  568. +
  569. + grl_daap_connect (name,
  570. + host,
  571. + port,
  572. + cb_and_db,
  573. + (DmapConnectionFunc) search_connected_cb);
  574. +
  575. g_hash_table_insert (connections, g_strdup (url), cb_and_db->db);
  576. +
  577. + g_free (name);
  578. + g_free (host);
  579. }
  580. g_free (url);
  581. diff --git a/src/dmap/grl-daap.h b/src/dmap/grl-daap.h
  582. index 1119495..5271435 100644
  583. --- a/src/dmap/grl-daap.h
  584. +++ b/src/dmap/grl-daap.h
  585. @@ -26,6 +26,8 @@
  586. #include <grilo.h>
  587. +#include "grl-daap-compat.h"
  588. +
  589. #define GRL_DAAP_SOURCE_TYPE (grl_daap_source_get_type ())
  590. #define GRL_DAAP_SOURCE(obj) \
  591. diff --git a/src/dmap/grl-dmap-compat.h b/src/dmap/grl-dmap-compat.h
  592. new file mode 100644
  593. index 0000000..cd1934f
  594. --- /dev/null
  595. +++ b/src/dmap/grl-dmap-compat.h
  596. @@ -0,0 +1,108 @@
  597. +/*
  598. + * Copyright (C) 2019 W. Michael Petullo
  599. + * Copyright (C) 2019 Igalia S.L.
  600. + *
  601. + * Contact: W. Michael Petullo <mike@flyn.org>
  602. + *
  603. + * This library is free software; you can redistribute it and/or
  604. + * modify it under the terms of the GNU Lesser General Public License
  605. + * as published by the Free Software Foundation; version 2.1 of
  606. + * the License, or (at your option) any later version.
  607. + *
  608. + * This library is distributed in the hope that it will be useful, but
  609. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  610. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  611. + * Lesser General Public License for more details.
  612. + *
  613. + * You should have received a copy of the GNU Lesser General Public
  614. + * License along with this library; if not, write to the Free Software
  615. + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  616. + * 02110-1301 USA
  617. + *
  618. + */
  619. +
  620. +#ifndef _GRL_DMAP_COMPAT_H_
  621. +#define _GRL_DMAP_COMPAT_H_
  622. +
  623. +#ifdef LIBDMAPSHARING_COMPAT
  624. +
  625. +/* Building against libdmapsharing 3 API. */
  626. +
  627. +#define DmapConnection DMAPConnection
  628. +#define DmapConnectionFunc DMAPConnectionCallback
  629. +#define dmap_connection_start dmap_connection_connect
  630. +#define DmapDb DMAPDb
  631. +#define DmapDbInterface DMAPDbIface
  632. +#define DmapIdRecordFunc GHFunc
  633. +#define DmapMdnsBrowser DMAPMdnsBrowser
  634. +#define DmapMdnsService DMAPMdnsBrowserService
  635. +#define DMAP_MDNS_SERVICE_TYPE_DAAP DMAP_MDNS_BROWSER_SERVICE_TYPE_DAAP
  636. +#define DMAP_MDNS_SERVICE_TYPE_DPAP DMAP_MDNS_BROWSER_SERVICE_TYPE_DPAP
  637. +#define DmapRecord DMAPRecord
  638. +#define DmapRecordFactory DMAPRecordFactory
  639. +#define DmapRecordFactoryInterface DMAPRecordFactoryIface
  640. +#define DmapRecordInterface DMAPRecordIface
  641. +
  642. +static inline gchar *
  643. +grl_dmap_service_get_name (DmapMdnsService *service)
  644. +{
  645. + return g_strdup (service->name);
  646. +}
  647. +
  648. +static inline gchar *
  649. +grl_dmap_service_get_service_name (DmapMdnsService *service)
  650. +{
  651. + return g_strdup (service->service_name);
  652. +}
  653. +
  654. +static inline gchar *
  655. +grl_dmap_service_get_host (DmapMdnsService *service)
  656. +{
  657. + return g_strdup (service->host);
  658. +}
  659. +
  660. +static inline guint
  661. +grl_dmap_service_get_port (DmapMdnsService *service)
  662. +{
  663. + return service->port;
  664. +}
  665. +
  666. +#else
  667. +
  668. +/* Building against libdmapsharing 4 API. */
  669. +
  670. +static inline gchar *
  671. +grl_dmap_service_get_name (DmapMdnsService *service)
  672. +{
  673. + gchar *name;
  674. + g_object_get (service, "name", &name, NULL);
  675. + return name;
  676. +}
  677. +
  678. +static inline gchar *
  679. +grl_dmap_service_get_service_name (DmapMdnsService *service)
  680. +{
  681. + gchar *service_name;
  682. + g_object_get (service, "service-name", &service_name, NULL);
  683. + return service_name;
  684. +}
  685. +
  686. +static inline gchar *
  687. +grl_dmap_service_get_host (DmapMdnsService *service)
  688. +{
  689. + gchar *host;
  690. + g_object_get (service, "host", &host, NULL);
  691. + return host;
  692. +}
  693. +
  694. +static inline guint
  695. +grl_dmap_service_get_port (DmapMdnsService *service)
  696. +{
  697. + guint port;
  698. + g_object_get (service, "port", &port, NULL);
  699. + return port;
  700. +}
  701. +
  702. +#endif
  703. +
  704. +#endif /* _GRL_DMAP_COMPAT_H_ */
  705. diff --git a/src/dmap/grl-dpap-compat.h b/src/dmap/grl-dpap-compat.h
  706. new file mode 100644
  707. index 0000000..b996464
  708. --- /dev/null
  709. +++ b/src/dmap/grl-dpap-compat.h
  710. @@ -0,0 +1,116 @@
  711. +/*
  712. + * Copyright (C) 2019 W. Michael Petullo
  713. + * Copyright (C) 2019 Igalia S.L.
  714. + *
  715. + * Contact: W. Michael Petullo <mike@flyn.org>
  716. + *
  717. + * This library is free software; you can redistribute it and/or
  718. + * modify it under the terms of the GNU Lesser General Public License
  719. + * as published by the Free Software Foundation; version 2.1 of
  720. + * the License, or (at your option) any later version.
  721. + *
  722. + * This library is distributed in the hope that it will be useful, but
  723. + * WITHOUT ANY WARRANTY; without even the implied warranty of
  724. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  725. + * Lesser General Public License for more details.
  726. + *
  727. + * You should have received a copy of the GNU Lesser General Public
  728. + * License along with this library; if not, write to the Free Software
  729. + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  730. + * 02110-1301 USA
  731. + *
  732. + */
  733. +
  734. +#ifndef _GRL_DPAP_COMPAT_H_
  735. +#define _GRL_DPAP_COMPAT_H_
  736. +
  737. +#include "grl-dmap-compat.h"
  738. +
  739. +#ifdef LIBDMAPSHARING_COMPAT
  740. +
  741. +DMAPRecord *grl_dpap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data, GError **error);
  742. +guint grl_dpap_db_add (DMAPDb *_db, DMAPRecord *_record, GError **error);
  743. +
  744. +/* Building against libdmapsharing 3 API. */
  745. +
  746. +#define dmap_image_connection_new dpap_connection_new
  747. +#define DmapImageRecord DPAPRecord
  748. +#define DmapImageRecordInterface DPAPRecordIface
  749. +#define DMAP_IMAGE_RECORD DPAP_RECORD
  750. +#define DMAP_TYPE_IMAGE_RECORD DPAP_TYPE_RECORD
  751. +#define IS_DMAP_IMAGE_RECORD IS_DPAP_RECORD
  752. +
  753. +static inline DmapRecord *
  754. +grl_dpap_record_factory_create_compat (DmapRecordFactory *factory, gpointer user_data)
  755. +{
  756. + return grl_dpap_record_factory_create (factory, user_data, NULL);
  757. +}
  758. +
  759. +static inline void
  760. +set_thumbnail (GValue *value, GByteArray *thumbnail)
  761. +{
  762. + g_value_set_pointer (value, thumbnail);
  763. +}
  764. +
  765. +static inline GByteArray *
  766. +get_thumbnail (GByteArray *thumbnail, const GValue *value)
  767. +{
  768. + if (thumbnail)
  769. + g_byte_array_unref (thumbnail);
  770. + return g_byte_array_ref (g_value_get_pointer (value));
  771. +}
  772. +
  773. +static inline void
  774. +unref_thumbnail (GByteArray *thumbnail)
  775. +{
  776. + g_byte_array_unref (thumbnail);
  777. +}
  778. +
  779. +static inline guint
  780. +grl_dpap_db_add_compat (DMAPDb *_db, DmapRecord *_record)
  781. +{
  782. + return grl_dpap_db_add (_db, _record, NULL);
  783. +}
  784. +
  785. +#else
  786. +
  787. +/* Building against libdmapsharing 4 API. */
  788. +
  789. +DmapRecord *grl_dpap_record_factory_create (DmapRecordFactory *factory, gpointer user_data, GError **error);
  790. +guint grl_dpap_db_add (DmapDb *_db, DmapRecord *_record, GError **error);
  791. +
  792. +static inline void
  793. +set_thumbnail (GValue *value, GArray *thumbnail)
  794. +{
  795. + g_value_set_boxed (value, thumbnail);
  796. +}
  797. +
  798. +static inline GArray *
  799. +get_thumbnail (GArray *thumbnail, const GValue *value)
  800. +{
  801. + if (thumbnail)
  802. + g_array_unref (thumbnail);
  803. + return g_value_get_boxed (value);
  804. +}
  805. +
  806. +static inline void
  807. +unref_thumbnail (GArray *thumbnail)
  808. +{
  809. + g_array_unref (thumbnail);
  810. +}
  811. +
  812. +static inline DmapRecord *
  813. +grl_dpap_record_factory_create_compat (DmapRecordFactory *factory, gpointer user_data, GError **error)
  814. +{
  815. + return grl_dpap_record_factory_create (factory, user_data, error);
  816. +}
  817. +
  818. +static inline guint
  819. +grl_dpap_db_add_compat (DmapDb *_db, DmapRecord *_record, GError **error)
  820. +{
  821. + return grl_dpap_db_add (_db, _record, error);
  822. +}
  823. +
  824. +#endif
  825. +
  826. +#endif /* _GRL_DPAP_COMPAT_H_ */
  827. diff --git a/src/dmap/grl-dpap-db.c b/src/dmap/grl-dpap-db.c
  828. index 8be278b..cd647ee 100644
  829. --- a/src/dmap/grl-dpap-db.c
  830. +++ b/src/dmap/grl-dpap-db.c
  831. @@ -24,12 +24,16 @@
  832. #include "config.h"
  833. #endif
  834. +#include <grilo.h>
  835. #include <glib/gi18n-lib.h>
  836. #include <sys/stat.h>
  837. #include <sys/types.h>
  838. #include <glib.h>
  839. #include <string.h>
  840. +#include <libdmapsharing/dmap.h>
  841. +#include "grl-dpap-compat.h"
  842. +#include "grl-common.h"
  843. #include "grl-dpap-db.h"
  844. #define PHOTOS_ID "photos"
  845. @@ -71,23 +75,23 @@ grl_dpap_db_new (void)
  846. return db;
  847. }
  848. -static DMAPRecord *
  849. -grl_dpap_db_lookup_by_id (const DMAPDb *db, guint id)
  850. +static DmapRecord *
  851. +grl_dpap_db_lookup_by_id (const DmapDb *db, guint id)
  852. {
  853. g_warning ("Not implemented");
  854. return NULL;
  855. }
  856. static void
  857. -grl_dpap_db_foreach (const DMAPDb *db,
  858. - GHFunc func,
  859. +grl_dpap_db_foreach (const DmapDb *db,
  860. + DmapIdRecordFunc func,
  861. gpointer data)
  862. {
  863. g_warning ("Not implemented");
  864. }
  865. static gint64
  866. -grl_dpap_db_count (const DMAPDb *db)
  867. +grl_dpap_db_count (const DmapDb *db)
  868. {
  869. g_warning ("Not implemented");
  870. return 0;
  871. @@ -118,21 +122,21 @@ set_insert (GHashTable *category, const char *category_name, char *set_name, Grl
  872. g_object_unref (container);
  873. }
  874. -static guint
  875. -grl_dpap_db_add (DMAPDb *_db, DMAPRecord *_record)
  876. +guint
  877. +grl_dpap_db_add (DmapDb *_db, DmapRecord *_record, GError **error)
  878. {
  879. g_assert (IS_GRL_DPAP_DB (_db));
  880. - g_assert (IS_DPAP_RECORD (_record));
  881. + g_assert (IS_DMAP_IMAGE_RECORD (_record));
  882. GrlDPAPDb *db = GRL_DPAP_DB (_db);
  883. - DPAPRecord *record = DPAP_RECORD (_record);
  884. + DmapImageRecord *record = DMAP_IMAGE_RECORD (_record);
  885. gint height = 0,
  886. width = 0,
  887. largefilesize = 0,
  888. creationdate = 0,
  889. rating = 0;
  890. - GByteArray *thumbnail = NULL;
  891. + GArray *thumbnail = NULL;
  892. gchar *id_s = NULL,
  893. *filename = NULL,
  894. *aspectratio = NULL,
  895. @@ -177,12 +181,12 @@ grl_dpap_db_add (DMAPDb *_db, DMAPRecord *_record)
  896. g_free (id_s);
  897. g_object_unref (media);
  898. - g_free(filename);
  899. - g_free(aspectratio);
  900. - g_free(format);
  901. - g_free(comments);
  902. - g_free(url);
  903. - g_byte_array_unref(thumbnail);
  904. + g_free (filename);
  905. + g_free (aspectratio);
  906. + g_free (format);
  907. + g_free (comments);
  908. + g_free (url);
  909. + g_array_unref (thumbnail);
  910. return --nextid;
  911. }
  912. @@ -298,11 +302,11 @@ grl_dpap_db_search (GrlDPAPDb *db,
  913. static void
  914. dmap_db_interface_init (gpointer iface, gpointer data)
  915. {
  916. - DMAPDbIface *dpap_db = iface;
  917. + DmapDbInterface *dpap_db = iface;
  918. g_assert (G_TYPE_FROM_INTERFACE (dpap_db) == DMAP_TYPE_DB);
  919. - dpap_db->add = grl_dpap_db_add;
  920. + dpap_db->add = grl_dpap_db_add_compat;
  921. dpap_db->lookup_by_id = grl_dpap_db_lookup_by_id;
  922. dpap_db->foreach = grl_dpap_db_foreach;
  923. dpap_db->count = grl_dpap_db_count;
  924. diff --git a/src/dmap/grl-dpap-db.h b/src/dmap/grl-dpap-db.h
  925. index d3abcba..a21ad7a 100644
  926. --- a/src/dmap/grl-dpap-db.h
  927. +++ b/src/dmap/grl-dpap-db.h
  928. @@ -24,6 +24,8 @@
  929. #include <libdmapsharing/dmap.h>
  930. #include <grilo.h>
  931. +#include "grl-dpap-compat.h"
  932. +
  933. G_BEGIN_DECLS
  934. #define TYPE_GRL_DPAP_DB (grl_dpap_db_get_type ())
  935. diff --git a/src/dmap/grl-dpap-record-factory.c b/src/dmap/grl-dpap-record-factory.c
  936. index 3d0c87a..860d957 100644
  937. --- a/src/dmap/grl-dpap-record-factory.c
  938. +++ b/src/dmap/grl-dpap-record-factory.c
  939. @@ -18,11 +18,18 @@
  940. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  941. */
  942. +#include <grilo.h>
  943. +#include <libdmapsharing/dmap.h>
  944. +
  945. +#include "grl-dpap-compat.h"
  946. +#include "grl-common.h"
  947. #include "grl-dpap-record-factory.h"
  948. #include "grl-dpap-record.h"
  949. -DMAPRecord *
  950. -grl_dpap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data)
  951. +DmapRecord *
  952. +grl_dpap_record_factory_create (DmapRecordFactory *factory,
  953. + gpointer user_data,
  954. + GError **error)
  955. {
  956. return DMAP_RECORD (grl_dpap_record_new ());
  957. }
  958. @@ -40,11 +47,11 @@ grl_dpap_record_factory_class_init (GrlDPAPRecordFactoryClass *klass)
  959. static void
  960. grl_dpap_record_factory_interface_init (gpointer iface, gpointer data)
  961. {
  962. - DMAPRecordFactoryIface *factory = iface;
  963. + DmapRecordFactoryInterface *factory = iface;
  964. g_assert (G_TYPE_FROM_INTERFACE (factory) == DMAP_TYPE_RECORD_FACTORY);
  965. - factory->create = grl_dpap_record_factory_create;
  966. + factory->create = grl_dpap_record_factory_create_compat;
  967. }
  968. G_DEFINE_TYPE_WITH_CODE (GrlDPAPRecordFactory, grl_dpap_record_factory, G_TYPE_OBJECT,
  969. diff --git a/src/dmap/grl-dpap-record-factory.h b/src/dmap/grl-dpap-record-factory.h
  970. index 3f4ca54..899fd0a 100644
  971. --- a/src/dmap/grl-dpap-record-factory.h
  972. +++ b/src/dmap/grl-dpap-record-factory.h
  973. @@ -23,6 +23,8 @@
  974. #include <libdmapsharing/dmap.h>
  975. +#include "grl-dpap-compat.h"
  976. +
  977. G_BEGIN_DECLS
  978. #define TYPE_SIMPLE_DPAP_RECORD_FACTORY (grl_dpap_record_factory_get_type ())
  979. @@ -64,7 +66,7 @@ GType grl_dpap_record_factory_get_type (void);
  980. GrlDPAPRecordFactory *grl_dpap_record_factory_new (void);
  981. -DMAPRecord *grl_dpap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data);
  982. +DmapRecord *grl_dpap_record_factory_create (DmapRecordFactory *factory, gpointer user_data, GError **error);
  983. #endif /* __SIMPLE_DPAP_RECORD_FACTORY */
  984. diff --git a/src/dmap/grl-dpap-record.c b/src/dmap/grl-dpap-record.c
  985. index 14eb1de..0afb2b8 100644
  986. --- a/src/dmap/grl-dpap-record.c
  987. +++ b/src/dmap/grl-dpap-record.c
  988. @@ -20,6 +20,11 @@
  989. *
  990. */
  991. +#include <grilo.h>
  992. +#include <libdmapsharing/dmap.h>
  993. +
  994. +#include "grl-dpap-compat.h"
  995. +#include "grl-common.h"
  996. #include "grl-dpap-record.h"
  997. struct GrlDPAPRecordPrivate {
  998. @@ -28,7 +33,7 @@ struct GrlDPAPRecordPrivate {
  999. gint creationdate;
  1000. gint rating;
  1001. char *filename;
  1002. - GByteArray *thumbnail;
  1003. + void *thumbnail; /* GByteArray or GArray, depending on libdmapsharing ver. */
  1004. char *aspectratio;
  1005. gint height;
  1006. gint width;
  1007. @@ -56,7 +61,7 @@ static void grl_dpap_record_dpap_iface_init (gpointer iface, gpointer data);
  1008. G_DEFINE_TYPE_WITH_CODE (GrlDPAPRecord, grl_dpap_record, G_TYPE_OBJECT,
  1009. G_ADD_PRIVATE (GrlDPAPRecord)
  1010. - G_IMPLEMENT_INTERFACE (DPAP_TYPE_RECORD, grl_dpap_record_dpap_iface_init)
  1011. + G_IMPLEMENT_INTERFACE (DMAP_TYPE_IMAGE_RECORD, grl_dpap_record_dpap_iface_init)
  1012. G_IMPLEMENT_INTERFACE (DMAP_TYPE_RECORD, grl_dpap_record_dmap_iface_init))
  1013. static void
  1014. @@ -104,9 +109,7 @@ grl_dpap_record_set_property (GObject *object,
  1015. record->priv->comments = g_value_dup_string (value);
  1016. break;
  1017. case PROP_THUMBNAIL:
  1018. - if (record->priv->thumbnail)
  1019. - g_byte_array_unref (record->priv->thumbnail);
  1020. - record->priv->thumbnail = g_byte_array_ref (g_value_get_pointer (value));
  1021. + record->priv->thumbnail = get_thumbnail (record->priv->thumbnail, value);
  1022. break;
  1023. default:
  1024. G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  1025. @@ -154,7 +157,7 @@ grl_dpap_record_get_property (GObject *object,
  1026. g_value_set_static_string (value, record->priv->comments);
  1027. break;
  1028. case PROP_THUMBNAIL:
  1029. - g_value_set_pointer (value, record->priv->thumbnail);
  1030. + set_thumbnail (value, record->priv->thumbnail);
  1031. break;
  1032. default:
  1033. G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
  1034. @@ -169,7 +172,7 @@ grl_dpap_record_new (void)
  1035. }
  1036. GInputStream *
  1037. -grl_dpap_record_read (DPAPRecord *record, GError **error)
  1038. +grl_dpap_record_read (DmapImageRecord *record, GError **error)
  1039. {
  1040. GFile *file;
  1041. GInputStream *stream;
  1042. @@ -215,9 +218,9 @@ grl_dpap_record_class_init (GrlDPAPRecordClass *klass)
  1043. static void
  1044. grl_dpap_record_dpap_iface_init (gpointer iface, gpointer data)
  1045. {
  1046. - DPAPRecordIface *dpap_record = iface;
  1047. + DmapImageRecordInterface *dpap_record = iface;
  1048. - g_assert (G_TYPE_FROM_INTERFACE (dpap_record) == DPAP_TYPE_RECORD);
  1049. + g_assert (G_TYPE_FROM_INTERFACE (dpap_record) == DMAP_TYPE_IMAGE_RECORD);
  1050. dpap_record->read = grl_dpap_record_read;
  1051. }
  1052. @@ -225,7 +228,7 @@ grl_dpap_record_dpap_iface_init (gpointer iface, gpointer data)
  1053. static void
  1054. grl_dpap_record_dmap_iface_init (gpointer iface, gpointer data)
  1055. {
  1056. - DMAPRecordIface *dmap_record = iface;
  1057. + DmapRecordInterface *dmap_record = iface;
  1058. g_assert (G_TYPE_FROM_INTERFACE (dmap_record) == DMAP_TYPE_RECORD);
  1059. }
  1060. @@ -242,7 +245,7 @@ grl_dpap_record_finalize (GObject *object)
  1061. g_free (record->priv->comments);
  1062. if (record->priv->thumbnail)
  1063. - g_byte_array_unref (record->priv->thumbnail);
  1064. + unref_thumbnail (record->priv->thumbnail);
  1065. G_OBJECT_CLASS (grl_dpap_record_parent_class)->finalize (object);
  1066. }
  1067. diff --git a/src/dmap/grl-dpap-record.h b/src/dmap/grl-dpap-record.h
  1068. index 203e57e..77eece0 100644
  1069. --- a/src/dmap/grl-dpap-record.h
  1070. +++ b/src/dmap/grl-dpap-record.h
  1071. @@ -23,6 +23,8 @@
  1072. #include <libdmapsharing/dmap.h>
  1073. +#include "grl-dpap-compat.h"
  1074. +
  1075. G_BEGIN_DECLS
  1076. #define TYPE_SIMPLE_DPAP_RECORD (grl_dpap_record_get_type ())
  1077. @@ -69,8 +71,8 @@ typedef struct {
  1078. GType grl_dpap_record_get_type (void);
  1079. GrlDPAPRecord *grl_dpap_record_new (void);
  1080. -GInputStream *grl_dpap_record_read (DPAPRecord *record, GError **error);
  1081. -gint grl_dpap_record_get_id (DPAPRecord *record);
  1082. +GInputStream *grl_dpap_record_read (DmapImageRecord *record, GError **error);
  1083. +gint grl_dpap_record_get_id (DmapImageRecord *record);
  1084. #endif /* __SIMPLE_DPAP_RECORD */
  1085. diff --git a/src/dmap/grl-dpap.c b/src/dmap/grl-dpap.c
  1086. index 9829ec2..6339654 100644
  1087. --- a/src/dmap/grl-dpap.c
  1088. +++ b/src/dmap/grl-dpap.c
  1089. @@ -33,6 +33,7 @@
  1090. #include <stdlib.h>
  1091. #include <libdmapsharing/dmap.h>
  1092. +#include "grl-dpap-compat.h"
  1093. #include "grl-common.h"
  1094. #include "grl-dpap.h"
  1095. #include "grl-dpap-db.h"
  1096. @@ -57,12 +58,12 @@ GRL_LOG_DOMAIN_STATIC (dmap_log_domain);
  1097. GrlDpapSourcePrivate))
  1098. struct _GrlDpapSourcePrivate {
  1099. - DMAPMdnsBrowserService *service;
  1100. + DmapMdnsService *service;
  1101. };
  1102. /* --- Data types --- */
  1103. -static GrlDpapSource *grl_dpap_source_new (DMAPMdnsBrowserService *service);
  1104. +static GrlDpapSource *grl_dpap_source_new (DmapMdnsService *service);
  1105. static void grl_dpap_source_finalize (GObject *object);
  1106. @@ -79,16 +80,16 @@ static void grl_dpap_source_search (GrlSource *source,
  1107. GrlSourceSearchSpec *ss);
  1108. -static void grl_dpap_service_added_cb (DMAPMdnsBrowser *browser,
  1109. - DMAPMdnsBrowserService *service,
  1110. +static void grl_dpap_service_added_cb (DmapMdnsBrowser *browser,
  1111. + DmapMdnsService *service,
  1112. GrlPlugin *plugin);
  1113. -static void grl_dpap_service_removed_cb (DMAPMdnsBrowser *browser,
  1114. +static void grl_dpap_service_removed_cb (DmapMdnsBrowser *browser,
  1115. const gchar *service_name,
  1116. GrlPlugin *plugin);
  1117. /* ===================== Globals ======================= */
  1118. -static DMAPMdnsBrowser *browser;
  1119. +static DmapMdnsBrowser *browser;
  1120. /* Maps URIs to DBs */
  1121. static GHashTable *connections;
  1122. /* Map DPAP services to Grilo media sources */
  1123. @@ -111,7 +112,7 @@ grl_dpap_plugin_init (GrlRegistry *registry,
  1124. bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  1125. bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  1126. - browser = dmap_mdns_browser_new (DMAP_MDNS_BROWSER_SERVICE_TYPE_DPAP);
  1127. + browser = dmap_mdns_browser_new (DMAP_MDNS_SERVICE_TYPE_DPAP);
  1128. connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
  1129. sources = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
  1130. @@ -158,8 +159,10 @@ GRL_PLUGIN_DEFINE (GRL_MAJOR,
  1131. G_DEFINE_TYPE_WITH_PRIVATE (GrlDpapSource, grl_dpap_source, GRL_TYPE_SOURCE)
  1132. static GrlDpapSource *
  1133. -grl_dpap_source_new (DMAPMdnsBrowserService *service)
  1134. +grl_dpap_source_new (DmapMdnsService *service)
  1135. {
  1136. + gchar *name;
  1137. + gchar *service_name;
  1138. gchar *source_desc;
  1139. gchar *source_id;
  1140. @@ -167,12 +170,14 @@ grl_dpap_source_new (DMAPMdnsBrowserService *service)
  1141. GRL_DEBUG ("grl_dpap_source_new");
  1142. - source_desc = g_strdup_printf (SOURCE_DESC_TEMPLATE, service->name);
  1143. - source_id = g_strdup_printf (SOURCE_ID_TEMPLATE, service->name);
  1144. + name = grl_dmap_service_get_name (service);
  1145. + service_name = grl_dmap_service_get_service_name (service);
  1146. + source_desc = g_strdup_printf (SOURCE_DESC_TEMPLATE, name);
  1147. + source_id = g_strdup_printf (SOURCE_ID_TEMPLATE, name);
  1148. source = g_object_new (GRL_DPAP_SOURCE_TYPE,
  1149. "source-id", source_id,
  1150. - "source-name", service->name,
  1151. + "source-name", service_name,
  1152. "source-desc", source_desc,
  1153. "supported-media", GRL_SUPPORTED_MEDIA_IMAGE,
  1154. NULL);
  1155. @@ -181,6 +186,8 @@ grl_dpap_source_new (DMAPMdnsBrowserService *service)
  1156. g_free (source_desc);
  1157. g_free (source_id);
  1158. + g_free (service_name);
  1159. + g_free (name);
  1160. return source;
  1161. }
  1162. @@ -241,7 +248,7 @@ grl_dpap_do_search (ResultCbAndArgsAndDb *cb_and_db)
  1163. }
  1164. static void
  1165. -browse_connected_cb (DMAPConnection *connection,
  1166. +browse_connected_cb (DmapConnection *connection,
  1167. gboolean result,
  1168. const char *reason,
  1169. ResultCbAndArgsAndDb *cb_and_db)
  1170. @@ -266,7 +273,7 @@ browse_connected_cb (DMAPConnection *connection,
  1171. }
  1172. static void
  1173. -search_connected_cb (DMAPConnection *connection,
  1174. +search_connected_cb (DmapConnection *connection,
  1175. gboolean result,
  1176. const char *reason,
  1177. ResultCbAndArgsAndDb *cb_and_db)
  1178. @@ -291,8 +298,8 @@ search_connected_cb (DMAPConnection *connection,
  1179. }
  1180. static void
  1181. -grl_dpap_service_added_cb (DMAPMdnsBrowser *browser,
  1182. - DMAPMdnsBrowserService *service,
  1183. +grl_dpap_service_added_cb (DmapMdnsBrowser *browser,
  1184. + DmapMdnsService *service,
  1185. GrlPlugin *plugin)
  1186. {
  1187. GrlRegistry *registry = grl_registry_get_default ();
  1188. @@ -306,13 +313,16 @@ grl_dpap_service_added_cb (DMAPMdnsBrowser *browser,
  1189. GRL_SOURCE (source),
  1190. NULL);
  1191. if (source != NULL) {
  1192. - g_hash_table_insert (sources, g_strdup (service->name), g_object_ref (source));
  1193. + gchar *name;
  1194. + name = grl_dmap_service_get_name (service);
  1195. + g_hash_table_insert (sources, g_strdup (name), g_object_ref (source));
  1196. g_object_remove_weak_pointer (G_OBJECT (source), (gpointer *) &source);
  1197. + g_free (name);
  1198. }
  1199. }
  1200. static void
  1201. -grl_dpap_service_removed_cb (DMAPMdnsBrowser *browser,
  1202. +grl_dpap_service_removed_cb (DmapMdnsBrowser *browser,
  1203. const gchar *service_name,
  1204. GrlPlugin *plugin)
  1205. {
  1206. @@ -328,14 +338,14 @@ grl_dpap_service_removed_cb (DMAPMdnsBrowser *browser,
  1207. }
  1208. static void
  1209. -grl_dpap_connect (gchar *name, gchar *host, guint port, ResultCbAndArgsAndDb *cb_and_db, DMAPConnectionCallback callback)
  1210. +grl_dpap_connect (gchar *name, gchar *host, guint port, ResultCbAndArgsAndDb *cb_and_db, DmapConnectionFunc callback)
  1211. {
  1212. - DMAPRecordFactory *factory;
  1213. - DMAPConnection *connection;
  1214. + DmapRecordFactory *factory;
  1215. + DmapConnection *connection;
  1216. factory = DMAP_RECORD_FACTORY (grl_dpap_record_factory_new ());
  1217. - connection = DMAP_CONNECTION (dpap_connection_new (name, host, port, DMAP_DB (cb_and_db->db), factory));
  1218. - dmap_connection_connect (connection, (DMAPConnectionCallback) callback, cb_and_db);
  1219. + connection = DMAP_CONNECTION (dmap_image_connection_new (name, host, port, DMAP_DB (cb_and_db->db), factory));
  1220. + dmap_connection_start (connection, (DmapConnectionFunc) callback, cb_and_db);
  1221. }
  1222. static gboolean
  1223. @@ -396,15 +406,25 @@ grl_dpap_source_browse (GrlSource *source,
  1224. browse_connected_cb (NULL, TRUE, NULL, cb_and_db);
  1225. } else {
  1226. /* Connect */
  1227. + gchar *name, *host;
  1228. + guint port;
  1229. +
  1230. cb_and_db->db = DMAP_DB (grl_dpap_db_new ());
  1231. - grl_dpap_connect (dmap_source->priv->service->name,
  1232. - dmap_source->priv->service->host,
  1233. - dmap_source->priv->service->port,
  1234. + name = grl_dmap_service_get_name (dmap_source->priv->service);
  1235. + host = grl_dmap_service_get_host (dmap_source->priv->service);
  1236. + port = grl_dmap_service_get_port (dmap_source->priv->service);
  1237. +
  1238. + grl_dpap_connect (name,
  1239. + host,
  1240. + port,
  1241. cb_and_db,
  1242. - (DMAPConnectionCallback) browse_connected_cb);
  1243. + (DmapConnectionFunc) browse_connected_cb);
  1244. g_hash_table_insert (connections, g_strdup (url), cb_and_db->db);
  1245. +
  1246. + g_free (name);
  1247. + g_free (host);
  1248. }
  1249. g_free (url);
  1250. @@ -416,7 +436,7 @@ static void grl_dpap_source_search (GrlSource *source,
  1251. GrlDpapSource *dmap_source = GRL_DPAP_SOURCE (source);
  1252. ResultCbAndArgsAndDb *cb_and_db;
  1253. - DMAPMdnsBrowserService *service = dmap_source->priv->service;
  1254. + DmapMdnsService *service = dmap_source->priv->service;
  1255. gchar *url = grl_dmap_build_url (service);
  1256. cb_and_db = g_new (ResultCbAndArgsAndDb, 1);
  1257. @@ -434,9 +454,25 @@ static void grl_dpap_source_search (GrlSource *source,
  1258. search_connected_cb (NULL, TRUE, NULL, cb_and_db);
  1259. } else {
  1260. /* Connect */
  1261. + gchar *name, *host;
  1262. + guint port;
  1263. +
  1264. cb_and_db->db = DMAP_DB (grl_dpap_db_new ());
  1265. - grl_dpap_connect (service->name, service->host, service->port, cb_and_db, (DMAPConnectionCallback) search_connected_cb);
  1266. +
  1267. + name = grl_dmap_service_get_name (dmap_source->priv->service);
  1268. + host = grl_dmap_service_get_host (dmap_source->priv->service);
  1269. + port = grl_dmap_service_get_port (dmap_source->priv->service);
  1270. +
  1271. + grl_dpap_connect (name,
  1272. + host,
  1273. + port,
  1274. + cb_and_db,
  1275. + (DmapConnectionFunc) search_connected_cb);
  1276. +
  1277. g_hash_table_insert (connections, g_strdup (url), cb_and_db->db);
  1278. +
  1279. + g_free (name);
  1280. + g_free (host);
  1281. }
  1282. g_free (url);
  1283. diff --git a/src/dmap/grl-dpap.h b/src/dmap/grl-dpap.h
  1284. index ee596b5..30cd61e 100644
  1285. --- a/src/dmap/grl-dpap.h
  1286. +++ b/src/dmap/grl-dpap.h
  1287. @@ -26,6 +26,8 @@
  1288. #include <grilo.h>
  1289. +#include "grl-dpap-compat.h"
  1290. +
  1291. #define GRL_DPAP_SOURCE_TYPE (grl_dpap_source_get_type ())
  1292. #define GRL_DPAP_SOURCE(obj) \
  1293. diff --git a/src/dmap/meson.build b/src/dmap/meson.build
  1294. index 2907a80..817ff5d 100644
  1295. --- a/src/dmap/meson.build
  1296. +++ b/src/dmap/meson.build
  1297. @@ -31,6 +31,15 @@ dpap_sources = [
  1298. 'grl-dpap.h',
  1299. ]
  1300. +args = [
  1301. + '-DG_LOG_DOMAIN="GrlDmap"',
  1302. + '-DHAVE_CONFIG_H',
  1303. +]
  1304. +
  1305. +if not libdmapsharing4_dep.found()
  1306. + args += '-DLIBDMAPSHARING_COMPAT'
  1307. +endif
  1308. +
  1309. configure_file(output: 'config.h',
  1310. configuration: cdata)
  1311. @@ -39,17 +48,11 @@ shared_library('grldaap',
  1312. install: true,
  1313. install_dir: pluginsdir,
  1314. dependencies: must_deps + plugins[dmap_idx][REQ_DEPS] + plugins[dmap_idx][OPT_DEPS],
  1315. - c_args: [
  1316. - '-DG_LOG_DOMAIN="GrlDmap"',
  1317. - '-DHAVE_CONFIG_H',
  1318. - ])
  1319. + c_args: args)
  1320. shared_library('grldpap',
  1321. sources: dpap_sources,
  1322. install: true,
  1323. install_dir: pluginsdir,
  1324. dependencies: must_deps + plugins[dmap_idx][REQ_DEPS] + plugins[dmap_idx][OPT_DEPS],
  1325. - c_args: [
  1326. - '-DG_LOG_DOMAIN="GrlDmap"',
  1327. - '-DHAVE_CONFIG_H',
  1328. - ])
  1329. + c_args: args)