|
|
- diff --git a/meson.build b/meson.build
- index 33a6f40..8a590b9 100644
- --- a/meson.build
- +++ b/meson.build
- @@ -62,7 +62,12 @@ gstreamer_dep = dependency('gstreamer-1.0', required: false)
- gthread_dep = dependency('gthread-2.0', required: false)
- json_glib_dep = dependency('json-glib-1.0', required: false)
- libarchive_dep = dependency('libarchive', required: false)
- -libdmapsharing_dep = dependency('libdmapsharing-3.0', version: '>= 2.9.12', required: false)
- +libdmapsharing4_dep = dependency('libdmapsharing-4.0', version: '>= 3.9.4', required: false)
- +if libdmapsharing4_dep.found()
- + libdmapsharing_dep = libdmapsharing4_dep
- +else
- + libdmapsharing_dep = dependency('libdmapsharing-3.0', version: '>= 2.9.12', required: false)
- +endif
- libgdata_dep = dependency('libgdata', version: '>= 0.9.1', required: false)
- libmediaart_dep = dependency('libmediaart-2.0', required: false)
- libsoup_dep = dependency('libsoup-2.4', required: false)
- diff --git a/src/dmap/grl-common.c b/src/dmap/grl-common.c
- index 6a1da5e..74a965f 100644
- --- a/src/dmap/grl-common.c
- +++ b/src/dmap/grl-common.c
- @@ -33,13 +33,27 @@
- #include <stdlib.h>
- #include <libdmapsharing/dmap.h>
-
- +#include "grl-dmap-compat.h"
- #include "grl-common.h"
-
- gchar *
- -grl_dmap_build_url (DMAPMdnsBrowserService *service)
- +grl_dmap_build_url (DmapMdnsService *service)
- {
- - return g_strdup_printf ("%s://%s:%u",
- - service->service_name,
- - service->host,
- - service->port);
- + gchar *url = NULL;
- + gchar *service_name, *host;
- + guint port;
- +
- + service_name = grl_dmap_service_get_service_name (service);
- + host = grl_dmap_service_get_host (service);
- + port = grl_dmap_service_get_port (service);
- +
- + url = g_strdup_printf ("%s://%s:%u",
- + service_name,
- + host,
- + port);
- +
- + g_free (service_name);
- + g_free (host);
- +
- + return url;
- }
- diff --git a/src/dmap/grl-common.h b/src/dmap/grl-common.h
- index e9c8327..d61df63 100644
- --- a/src/dmap/grl-common.h
- +++ b/src/dmap/grl-common.h
- @@ -24,9 +24,6 @@
- #ifndef _GRL_COMMON_H_
- #define _GRL_COMMON_H_
-
- -#include <grilo.h>
- -#include <libdmapsharing/dmap.h>
- -
- typedef struct {
- GrlSourceResultCb callback;
- GrlSource *source;
- @@ -41,9 +38,9 @@ typedef struct {
-
- typedef struct {
- ResultCbAndArgs cb;
- - DMAPDb *db;
- + DmapDb *db;
- } ResultCbAndArgsAndDb;
-
- -gchar *grl_dmap_build_url (DMAPMdnsBrowserService *service);
- +gchar *grl_dmap_build_url (DmapMdnsService *service);
-
- #endif /* _GRL_COMMON_H_ */
- diff --git a/src/dmap/grl-daap-compat.h b/src/dmap/grl-daap-compat.h
- new file mode 100644
- index 0000000..da9025f
- --- /dev/null
- +++ b/src/dmap/grl-daap-compat.h
- @@ -0,0 +1,76 @@
- +/*
- + * Copyright (C) 2019 W. Michael Petullo
- + * Copyright (C) 2019 Igalia S.L.
- + *
- + * Contact: W. Michael Petullo <mike@flyn.org>
- + *
- + * This library is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU Lesser General Public License
- + * as published by the Free Software Foundation; version 2.1 of
- + * the License, or (at your option) any later version.
- + *
- + * This library is distributed in the hope that it will be useful, but
- + * WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * Lesser General Public License for more details.
- + *
- + * You should have received a copy of the GNU Lesser General Public
- + * License along with this library; if not, write to the Free Software
- + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- + * 02110-1301 USA
- + *
- + */
- +
- +#ifndef _GRL_DAAP_COMPAT_H_
- +#define _GRL_DAAP_COMPAT_H_
- +
- +#include "grl-dmap-compat.h"
- +
- +#ifdef LIBDMAPSHARING_COMPAT
- +
- +DMAPRecord *grl_daap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data, GError **error);
- +guint grl_daap_db_add (DMAPDb *_db, DMAPRecord *_record, GError **error);
- +
- +/* Building against libdmapsharing 3 API. */
- +
- +#define dmap_av_connection_new daap_connection_new
- +#define DmapAvRecord DAAPRecord
- +#define DmapAvRecordInterface DAAPRecordIface
- +#define DMAP_AV_RECORD DAAP_RECORD
- +#define DMAP_TYPE_AV_RECORD DAAP_TYPE_RECORD
- +#define IS_DMAP_AV_RECORD IS_DAAP_RECORD
- +
- +static inline DmapRecord *
- +grl_daap_record_factory_create_compat (DmapRecordFactory *factory, gpointer user_data)
- +{
- + return grl_daap_record_factory_create (factory, user_data, NULL);
- +}
- +
- +static inline guint
- +grl_daap_db_add_compat (DmapDb *_db, DmapRecord *_record)
- +{
- + return grl_daap_db_add (_db, _record, NULL);
- +}
- +
- +#else
- +
- +/* Building against libdmapsharing 4 API. */
- +
- +DmapRecord *grl_daap_record_factory_create (DmapRecordFactory *factory, gpointer user_data, GError **error);
- +guint grl_daap_db_add (DmapDb *_db, DmapRecord *_record, GError **error);
- +
- +static inline DmapRecord *
- +grl_daap_record_factory_create_compat (DmapRecordFactory *factory, gpointer user_data, GError **error)
- +{
- + return grl_daap_record_factory_create (factory, user_data, error);
- +}
- +
- +static inline guint
- +grl_daap_db_add_compat (DmapDb *_db, DmapRecord *_record, GError **error)
- +{
- + return grl_daap_db_add (_db, _record, error);
- +}
- +
- +#endif
- +
- +#endif /* _GRL_DAAP_COMPAT_H_ */
- diff --git a/src/dmap/grl-daap-db.c b/src/dmap/grl-daap-db.c
- index f460113..315370e 100644
- --- a/src/dmap/grl-daap-db.c
- +++ b/src/dmap/grl-daap-db.c
- @@ -54,8 +54,12 @@
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <glib.h>
- +#include <grilo.h>
- #include <string.h>
- +#include <libdmapsharing/dmap.h>
-
- +#include "grl-daap-compat.h"
- +#include "grl-common.h"
- #include "grl-daap-db.h"
-
- #define ALBUMS_ID "albums"
- @@ -103,23 +107,23 @@ grl_daap_db_new (void)
- return db;
- }
-
- -static DMAPRecord *
- -grl_daap_db_lookup_by_id (const DMAPDb *db, guint id)
- +static DmapRecord *
- +grl_daap_db_lookup_by_id (const DmapDb *db, guint id)
- {
- g_error ("Not implemented");
- return NULL;
- }
-
- static void
- -grl_daap_db_foreach (const DMAPDb *db,
- - GHFunc func,
- +grl_daap_db_foreach (const DmapDb *db,
- + DmapIdRecordFunc func,
- gpointer data)
- {
- g_error ("Not implemented");
- }
-
- static gint64
- -grl_daap_db_count (const DMAPDb *db)
- +grl_daap_db_count (const DmapDb *db)
- {
- g_error ("Not implemented");
- return 0;
- @@ -150,14 +154,14 @@ set_insert (GHashTable *category, const char *category_name, char *set_name, Grl
- g_object_unref (container);
- }
-
- -static guint
- -grl_daap_db_add (DMAPDb *_db, DMAPRecord *_record)
- +guint
- +grl_daap_db_add (DmapDb *_db, DmapRecord *_record, GError **error)
- {
- g_assert (IS_GRL_DAAP_DB (_db));
- - g_assert (IS_DAAP_RECORD (_record));
- + g_assert (IS_DMAP_AV_RECORD (_record));
-
- GrlDAAPDb *db = GRL_DAAP_DB (_db);
- - DAAPRecord *record = DAAP_RECORD (_record);
- + DmapAvRecord *record = DMAP_AV_RECORD (_record);
-
- gint duration = 0;
- gint32 bitrate = 0,
- @@ -232,11 +236,11 @@ grl_daap_db_add (DMAPDb *_db, DMAPRecord *_record)
-
- g_free (id_s);
- g_object_unref (media);
- - g_free(album);
- - g_free(artist);
- - g_free(genre);
- - g_free(title);
- - g_free(url);
- + g_free (album);
- + g_free (artist);
- + g_free (genre);
- + g_free (title);
- + g_free (url);
-
- return --nextid;
- }
- @@ -359,11 +363,11 @@ grl_daap_db_search (GrlDAAPDb *db,
- static void
- dmap_db_interface_init (gpointer iface, gpointer data)
- {
- - DMAPDbIface *daap_db = iface;
- + DmapDbInterface *daap_db = iface;
-
- g_assert (G_TYPE_FROM_INTERFACE (daap_db) == DMAP_TYPE_DB);
-
- - daap_db->add = grl_daap_db_add;
- + daap_db->add = grl_daap_db_add_compat;
- daap_db->lookup_by_id = grl_daap_db_lookup_by_id;
- daap_db->foreach = grl_daap_db_foreach;
- daap_db->count = grl_daap_db_count;
- diff --git a/src/dmap/grl-daap-db.h b/src/dmap/grl-daap-db.h
- index 2548c50..1a37a3a 100644
- --- a/src/dmap/grl-daap-db.h
- +++ b/src/dmap/grl-daap-db.h
- @@ -24,6 +24,8 @@
- #include <libdmapsharing/dmap.h>
- #include <grilo.h>
-
- +#include "grl-daap-compat.h"
- +
- G_BEGIN_DECLS
-
- #define TYPE_GRL_DAAP_DB (grl_daap_db_get_type ())
- diff --git a/src/dmap/grl-daap-record-factory.c b/src/dmap/grl-daap-record-factory.c
- index 648fd85..d0c590f 100644
- --- a/src/dmap/grl-daap-record-factory.c
- +++ b/src/dmap/grl-daap-record-factory.c
- @@ -1,5 +1,5 @@
- /*
- - * DAAPRecord factory class
- + * DmapAvRecord factory class
- *
- * Copyright (C) 2008 W. Michael Petullo <mike@flyn.org>
- *
- @@ -18,11 +18,16 @@
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- +#include <grilo.h>
- +#include <libdmapsharing/dmap.h>
- +
- +#include "grl-daap-compat.h"
- +#include "grl-common.h"
- #include "grl-daap-record-factory.h"
- #include "grl-daap-record.h"
-
- -DMAPRecord *
- -grl_daap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data)
- +DmapRecord *
- +grl_daap_record_factory_create (DmapRecordFactory *factory, gpointer user_data, GError **error)
- {
- return DMAP_RECORD (grl_daap_record_new ());
- }
- @@ -40,11 +45,11 @@ grl_daap_record_factory_class_init (GrlDAAPRecordFactoryClass *klass)
- static void
- grl_daap_record_factory_interface_init (gpointer iface, gpointer data)
- {
- - DMAPRecordFactoryIface *factory = iface;
- + DmapRecordFactoryInterface *factory = iface;
-
- g_assert (G_TYPE_FROM_INTERFACE (factory) == DMAP_TYPE_RECORD_FACTORY);
-
- - factory->create = grl_daap_record_factory_create;
- + factory->create = grl_daap_record_factory_create_compat;
- }
-
- G_DEFINE_TYPE_WITH_CODE (GrlDAAPRecordFactory, grl_daap_record_factory, G_TYPE_OBJECT,
- diff --git a/src/dmap/grl-daap-record-factory.h b/src/dmap/grl-daap-record-factory.h
- index 45aa69a..f114bad 100644
- --- a/src/dmap/grl-daap-record-factory.h
- +++ b/src/dmap/grl-daap-record-factory.h
- @@ -23,6 +23,8 @@
-
- #include <libdmapsharing/dmap.h>
-
- +#include "grl-daap-compat.h"
- +
- G_BEGIN_DECLS
-
- #define TYPE_SIMPLE_DAAP_RECORD_FACTORY (grl_daap_record_factory_get_type ())
- @@ -64,8 +66,6 @@ GType grl_daap_record_factory_get_type (void);
-
- GrlDAAPRecordFactory *grl_daap_record_factory_new (void);
-
- -DMAPRecord *grl_daap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data);
- -
- #endif /* __SIMPLE_DAAP_RECORD_FACTORY */
-
- G_END_DECLS
- diff --git a/src/dmap/grl-daap-record.c b/src/dmap/grl-daap-record.c
- index 82bf2f9..4fa0c54 100644
- --- a/src/dmap/grl-daap-record.c
- +++ b/src/dmap/grl-daap-record.c
- @@ -20,6 +20,11 @@
- *
- */
-
- +#include <grilo.h>
- +#include <libdmapsharing/dmap.h>
- +
- +#include "grl-daap-compat.h"
- +#include "grl-common.h"
- #include "grl-daap-record.h"
-
- struct GrlDAAPRecordPrivate {
- @@ -226,7 +231,7 @@ grl_daap_record_new (void)
- }
-
- GInputStream *
- -grl_daap_record_read (DAAPRecord *record, GError **error)
- +grl_daap_record_read (DmapAvRecord *record, GError **error)
- {
- GFile *file;
- GInputStream *stream;
- @@ -280,9 +285,9 @@ grl_daap_record_class_init (GrlDAAPRecordClass *klass)
- static void
- grl_daap_record_daap_iface_init (gpointer iface, gpointer data)
- {
- - DAAPRecordIface *daap_record = iface;
- + DmapAvRecordInterface *daap_record = iface;
-
- - g_assert (G_TYPE_FROM_INTERFACE (daap_record) == DAAP_TYPE_RECORD);
- + g_assert (G_TYPE_FROM_INTERFACE (daap_record) == DMAP_TYPE_AV_RECORD);
-
- daap_record->read = grl_daap_record_read;
- }
- @@ -290,7 +295,7 @@ grl_daap_record_daap_iface_init (gpointer iface, gpointer data)
- static void
- grl_daap_record_dmap_iface_init (gpointer iface, gpointer data)
- {
- - DMAPRecordIface *dmap_record = iface;
- + DmapRecordInterface *dmap_record = iface;
-
- g_assert (G_TYPE_FROM_INTERFACE (dmap_record) == DMAP_TYPE_RECORD);
- }
- @@ -298,7 +303,7 @@ grl_daap_record_dmap_iface_init (gpointer iface, gpointer data)
-
- G_DEFINE_TYPE_WITH_CODE (GrlDAAPRecord, grl_daap_record, G_TYPE_OBJECT,
- G_ADD_PRIVATE (GrlDAAPRecord)
- - G_IMPLEMENT_INTERFACE (DAAP_TYPE_RECORD, grl_daap_record_daap_iface_init)
- + G_IMPLEMENT_INTERFACE (DMAP_TYPE_AV_RECORD, grl_daap_record_daap_iface_init)
- G_IMPLEMENT_INTERFACE (DMAP_TYPE_RECORD, grl_daap_record_dmap_iface_init))
-
- static void
- diff --git a/src/dmap/grl-daap-record.h b/src/dmap/grl-daap-record.h
- index 7aae82d..42782b1 100644
- --- a/src/dmap/grl-daap-record.h
- +++ b/src/dmap/grl-daap-record.h
- @@ -23,6 +23,8 @@
-
- #include <libdmapsharing/dmap.h>
-
- +#include "grl-daap-compat.h"
- +
- G_BEGIN_DECLS
-
- #define TYPE_SIMPLE_DAAP_RECORD (grl_daap_record_get_type ())
- @@ -69,8 +71,8 @@ typedef struct {
- GType grl_daap_record_get_type (void);
-
- GrlDAAPRecord *grl_daap_record_new (void);
- -GInputStream *grl_daap_record_read (DAAPRecord *record, GError **error);
- -gint grl_daap_record_get_id (DAAPRecord *record);
- +GInputStream *grl_daap_record_read (DmapAvRecord *record, GError **error);
- +gint grl_daap_record_get_id (DmapAvRecord *record);
-
- #endif /* __SIMPLE_DAAP_RECORD */
-
- diff --git a/src/dmap/grl-daap.c b/src/dmap/grl-daap.c
- index f3c4115..962f2b8 100644
- --- a/src/dmap/grl-daap.c
- +++ b/src/dmap/grl-daap.c
- @@ -33,6 +33,7 @@
- #include <stdlib.h>
- #include <libdmapsharing/dmap.h>
-
- +#include "grl-daap-compat.h"
- #include "grl-common.h"
- #include "grl-daap.h"
- #include "grl-daap-db.h"
- @@ -52,12 +53,12 @@ GRL_LOG_DOMAIN_STATIC (daap_log_domain);
- /* --- Grilo DAAP Private --- */
-
- struct _GrlDaapSourcePrivate {
- - DMAPMdnsBrowserService *service;
- + DmapMdnsService *service;
- };
-
- /* --- Data types --- */
-
- -static GrlDaapSource *grl_daap_source_new (DMAPMdnsBrowserService *service);
- +static GrlDaapSource *grl_daap_source_new (DmapMdnsService *service);
-
- static void grl_daap_source_finalize (GObject *object);
-
- @@ -74,16 +75,16 @@ static void grl_daap_source_search (GrlSource *source,
- GrlSourceSearchSpec *ss);
-
-
- -static void grl_daap_service_added_cb (DMAPMdnsBrowser *browser,
- - DMAPMdnsBrowserService *service,
- +static void grl_daap_service_added_cb (DmapMdnsBrowser *browser,
- + DmapMdnsService *service,
- GrlPlugin *plugin);
-
- -static void grl_daap_service_removed_cb (DMAPMdnsBrowser *browser,
- +static void grl_daap_service_removed_cb (DmapMdnsBrowser *browser,
- const gchar *service_name,
- GrlPlugin *plugin);
-
- /* ===================== Globals ======================= */
- -static DMAPMdnsBrowser *browser;
- +static DmapMdnsBrowser *browser;
- /* Maps URIs to DBs */
- static GHashTable *connections;
- /* Map DAAP services to Grilo media sources */
- @@ -106,7 +107,7 @@ grl_daap_plugin_init (GrlRegistry *registry,
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-
- - browser = dmap_mdns_browser_new (DMAP_MDNS_BROWSER_SERVICE_TYPE_DAAP);
- + browser = dmap_mdns_browser_new (DMAP_MDNS_SERVICE_TYPE_DAAP);
- connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- sources = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-
- @@ -153,8 +154,10 @@ GRL_PLUGIN_DEFINE (GRL_MAJOR,
- G_DEFINE_TYPE_WITH_PRIVATE (GrlDaapSource, grl_daap_source, GRL_TYPE_SOURCE)
-
- static GrlDaapSource *
- -grl_daap_source_new (DMAPMdnsBrowserService *service)
- +grl_daap_source_new (DmapMdnsService *service)
- {
- + gchar *name;
- + gchar *service_name;
- gchar *source_desc;
- gchar *source_id;
-
- @@ -162,12 +165,15 @@ grl_daap_source_new (DMAPMdnsBrowserService *service)
-
- GRL_DEBUG ("grl_daap_source_new");
-
- - source_desc = g_strdup_printf (SOURCE_DESC_TEMPLATE, service->name);
- - source_id = g_strdup_printf (SOURCE_ID_TEMPLATE, service->name);
- + name = grl_dmap_service_get_name (service);
- + service_name = grl_dmap_service_get_service_name (service);
- +
- + source_desc = g_strdup_printf (SOURCE_DESC_TEMPLATE, name);
- + source_id = g_strdup_printf (SOURCE_ID_TEMPLATE, name);
-
- source = g_object_new (GRL_DAAP_SOURCE_TYPE,
- "source-id", source_id,
- - "source-name", service->name,
- + "source-name", service_name,
- "source-desc", source_desc,
- "supported-media", GRL_SUPPORTED_MEDIA_AUDIO,
- NULL);
- @@ -176,6 +182,8 @@ grl_daap_source_new (DMAPMdnsBrowserService *service)
-
- g_free (source_desc);
- g_free (source_id);
- + g_free (service_name);
- + g_free (name);
-
- return source;
- }
- @@ -209,7 +217,7 @@ grl_daap_source_finalize (GObject *object)
- static void
- grl_daap_do_browse (ResultCbAndArgsAndDb *cb_and_db)
- {
- - grl_daap_db_browse (GRL_DAAP_DB(cb_and_db->db),
- + grl_daap_db_browse (GRL_DAAP_DB (cb_and_db->db),
- cb_and_db->cb.container,
- cb_and_db->cb.source,
- cb_and_db->cb.op_id,
- @@ -236,7 +244,7 @@ grl_daap_do_search (ResultCbAndArgsAndDb *cb_and_db)
- }
-
- static void
- -browse_connected_cb (DMAPConnection *connection,
- +browse_connected_cb (DmapConnection *connection,
- gboolean result,
- const char *reason,
- ResultCbAndArgsAndDb *cb_and_db)
- @@ -261,7 +269,7 @@ browse_connected_cb (DMAPConnection *connection,
- }
-
- static void
- -search_connected_cb (DMAPConnection *connection,
- +search_connected_cb (DmapConnection *connection,
- gboolean result,
- const char *reason,
- ResultCbAndArgsAndDb *cb_and_db)
- @@ -286,8 +294,8 @@ search_connected_cb (DMAPConnection *connection,
- }
-
- static void
- -grl_daap_service_added_cb (DMAPMdnsBrowser *browser,
- - DMAPMdnsBrowserService *service,
- +grl_daap_service_added_cb (DmapMdnsBrowser *browser,
- + DmapMdnsService *service,
- GrlPlugin *plugin)
- {
- GrlRegistry *registry = grl_registry_get_default ();
- @@ -301,13 +309,16 @@ grl_daap_service_added_cb (DMAPMdnsBrowser *browser,
- GRL_SOURCE (source),
- NULL);
- if (source != NULL) {
- - g_hash_table_insert (sources, g_strdup (service->name), g_object_ref (source));
- + gchar *name;
- + name = grl_dmap_service_get_name (service);
- + g_hash_table_insert (sources, g_strdup (name), g_object_ref (source));
- g_object_remove_weak_pointer (G_OBJECT (source), (gpointer *) &source);
- + g_free (name);
- }
- }
-
- static void
- -grl_daap_service_removed_cb (DMAPMdnsBrowser *browser,
- +grl_daap_service_removed_cb (DmapMdnsBrowser *browser,
- const gchar *service_name,
- GrlPlugin *plugin)
- {
- @@ -323,14 +334,14 @@ grl_daap_service_removed_cb (DMAPMdnsBrowser *browser,
- }
-
- static void
- -grl_daap_connect (gchar *name, gchar *host, guint port, ResultCbAndArgsAndDb *cb_and_db, DMAPConnectionCallback callback)
- +grl_daap_connect (gchar *name, gchar *host, guint port, ResultCbAndArgsAndDb *cb_and_db, DmapConnectionFunc callback)
- {
- - DMAPRecordFactory *factory;
- - DMAPConnection *connection;
- + DmapRecordFactory *factory;
- + DmapConnection *connection;
-
- factory = DMAP_RECORD_FACTORY (grl_daap_record_factory_new ());
- - connection = DMAP_CONNECTION (daap_connection_new (name, host, port, DMAP_DB (cb_and_db->db), factory));
- - dmap_connection_connect (connection, (DMAPConnectionCallback) callback, cb_and_db);
- + connection = DMAP_CONNECTION (dmap_av_connection_new (name, host, port, DMAP_DB (cb_and_db->db), factory));
- + dmap_connection_start (connection, (DmapConnectionFunc) callback, cb_and_db);
- }
-
- static gboolean
- @@ -397,15 +408,25 @@ grl_daap_source_browse (GrlSource *source,
- browse_connected_cb (NULL, TRUE, NULL, cb_and_db);
- } else {
- /* Connect */
- + gchar *name, *host;
- + guint port;
- +
- cb_and_db->db = DMAP_DB (grl_daap_db_new ());
-
- - grl_daap_connect (dmap_source->priv->service->name,
- - dmap_source->priv->service->host,
- - dmap_source->priv->service->port,
- + name = grl_dmap_service_get_name (dmap_source->priv->service);
- + host = grl_dmap_service_get_host (dmap_source->priv->service);
- + port = grl_dmap_service_get_port (dmap_source->priv->service);
- +
- + grl_daap_connect (name,
- + host,
- + port,
- cb_and_db,
- - (DMAPConnectionCallback) browse_connected_cb);
- + (DmapConnectionFunc) browse_connected_cb);
-
- g_hash_table_insert (connections, g_strdup (url), cb_and_db->db);
- +
- + g_free (name);
- + g_free (host);
- }
-
- g_free (url);
- @@ -417,7 +438,7 @@ static void grl_daap_source_search (GrlSource *source,
- GrlDaapSource *dmap_source = GRL_DAAP_SOURCE (source);
-
- ResultCbAndArgsAndDb *cb_and_db;
- - DMAPMdnsBrowserService *service = dmap_source->priv->service;
- + DmapMdnsService *service = dmap_source->priv->service;
- gchar *url = grl_dmap_build_url (service);
-
- cb_and_db = g_new (ResultCbAndArgsAndDb, 1);
- @@ -435,9 +456,25 @@ static void grl_daap_source_search (GrlSource *source,
- search_connected_cb (NULL, TRUE, NULL, cb_and_db);
- } else {
- /* Connect */
- + gchar *name, *host;
- + guint port;
- +
- cb_and_db->db = DMAP_DB (grl_daap_db_new ());
- - grl_daap_connect (service->name, service->host, service->port, cb_and_db, (DMAPConnectionCallback) search_connected_cb);
- +
- + name = grl_dmap_service_get_name (dmap_source->priv->service);
- + host = grl_dmap_service_get_host (dmap_source->priv->service);
- + port = grl_dmap_service_get_port (dmap_source->priv->service);
- +
- + grl_daap_connect (name,
- + host,
- + port,
- + cb_and_db,
- + (DmapConnectionFunc) search_connected_cb);
- +
- g_hash_table_insert (connections, g_strdup (url), cb_and_db->db);
- +
- + g_free (name);
- + g_free (host);
- }
-
- g_free (url);
- diff --git a/src/dmap/grl-daap.h b/src/dmap/grl-daap.h
- index 1119495..5271435 100644
- --- a/src/dmap/grl-daap.h
- +++ b/src/dmap/grl-daap.h
- @@ -26,6 +26,8 @@
-
- #include <grilo.h>
-
- +#include "grl-daap-compat.h"
- +
- #define GRL_DAAP_SOURCE_TYPE (grl_daap_source_get_type ())
-
- #define GRL_DAAP_SOURCE(obj) \
- diff --git a/src/dmap/grl-dmap-compat.h b/src/dmap/grl-dmap-compat.h
- new file mode 100644
- index 0000000..cd1934f
- --- /dev/null
- +++ b/src/dmap/grl-dmap-compat.h
- @@ -0,0 +1,108 @@
- +/*
- + * Copyright (C) 2019 W. Michael Petullo
- + * Copyright (C) 2019 Igalia S.L.
- + *
- + * Contact: W. Michael Petullo <mike@flyn.org>
- + *
- + * This library is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU Lesser General Public License
- + * as published by the Free Software Foundation; version 2.1 of
- + * the License, or (at your option) any later version.
- + *
- + * This library is distributed in the hope that it will be useful, but
- + * WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * Lesser General Public License for more details.
- + *
- + * You should have received a copy of the GNU Lesser General Public
- + * License along with this library; if not, write to the Free Software
- + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- + * 02110-1301 USA
- + *
- + */
- +
- +#ifndef _GRL_DMAP_COMPAT_H_
- +#define _GRL_DMAP_COMPAT_H_
- +
- +#ifdef LIBDMAPSHARING_COMPAT
- +
- +/* Building against libdmapsharing 3 API. */
- +
- +#define DmapConnection DMAPConnection
- +#define DmapConnectionFunc DMAPConnectionCallback
- +#define dmap_connection_start dmap_connection_connect
- +#define DmapDb DMAPDb
- +#define DmapDbInterface DMAPDbIface
- +#define DmapIdRecordFunc GHFunc
- +#define DmapMdnsBrowser DMAPMdnsBrowser
- +#define DmapMdnsService DMAPMdnsBrowserService
- +#define DMAP_MDNS_SERVICE_TYPE_DAAP DMAP_MDNS_BROWSER_SERVICE_TYPE_DAAP
- +#define DMAP_MDNS_SERVICE_TYPE_DPAP DMAP_MDNS_BROWSER_SERVICE_TYPE_DPAP
- +#define DmapRecord DMAPRecord
- +#define DmapRecordFactory DMAPRecordFactory
- +#define DmapRecordFactoryInterface DMAPRecordFactoryIface
- +#define DmapRecordInterface DMAPRecordIface
- +
- +static inline gchar *
- +grl_dmap_service_get_name (DmapMdnsService *service)
- +{
- + return g_strdup (service->name);
- +}
- +
- +static inline gchar *
- +grl_dmap_service_get_service_name (DmapMdnsService *service)
- +{
- + return g_strdup (service->service_name);
- +}
- +
- +static inline gchar *
- +grl_dmap_service_get_host (DmapMdnsService *service)
- +{
- + return g_strdup (service->host);
- +}
- +
- +static inline guint
- +grl_dmap_service_get_port (DmapMdnsService *service)
- +{
- + return service->port;
- +}
- +
- +#else
- +
- +/* Building against libdmapsharing 4 API. */
- +
- +static inline gchar *
- +grl_dmap_service_get_name (DmapMdnsService *service)
- +{
- + gchar *name;
- + g_object_get (service, "name", &name, NULL);
- + return name;
- +}
- +
- +static inline gchar *
- +grl_dmap_service_get_service_name (DmapMdnsService *service)
- +{
- + gchar *service_name;
- + g_object_get (service, "service-name", &service_name, NULL);
- + return service_name;
- +}
- +
- +static inline gchar *
- +grl_dmap_service_get_host (DmapMdnsService *service)
- +{
- + gchar *host;
- + g_object_get (service, "host", &host, NULL);
- + return host;
- +}
- +
- +static inline guint
- +grl_dmap_service_get_port (DmapMdnsService *service)
- +{
- + guint port;
- + g_object_get (service, "port", &port, NULL);
- + return port;
- +}
- +
- +#endif
- +
- +#endif /* _GRL_DMAP_COMPAT_H_ */
- diff --git a/src/dmap/grl-dpap-compat.h b/src/dmap/grl-dpap-compat.h
- new file mode 100644
- index 0000000..b996464
- --- /dev/null
- +++ b/src/dmap/grl-dpap-compat.h
- @@ -0,0 +1,116 @@
- +/*
- + * Copyright (C) 2019 W. Michael Petullo
- + * Copyright (C) 2019 Igalia S.L.
- + *
- + * Contact: W. Michael Petullo <mike@flyn.org>
- + *
- + * This library is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU Lesser General Public License
- + * as published by the Free Software Foundation; version 2.1 of
- + * the License, or (at your option) any later version.
- + *
- + * This library is distributed in the hope that it will be useful, but
- + * WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * Lesser General Public License for more details.
- + *
- + * You should have received a copy of the GNU Lesser General Public
- + * License along with this library; if not, write to the Free Software
- + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- + * 02110-1301 USA
- + *
- + */
- +
- +#ifndef _GRL_DPAP_COMPAT_H_
- +#define _GRL_DPAP_COMPAT_H_
- +
- +#include "grl-dmap-compat.h"
- +
- +#ifdef LIBDMAPSHARING_COMPAT
- +
- +DMAPRecord *grl_dpap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data, GError **error);
- +guint grl_dpap_db_add (DMAPDb *_db, DMAPRecord *_record, GError **error);
- +
- +/* Building against libdmapsharing 3 API. */
- +
- +#define dmap_image_connection_new dpap_connection_new
- +#define DmapImageRecord DPAPRecord
- +#define DmapImageRecordInterface DPAPRecordIface
- +#define DMAP_IMAGE_RECORD DPAP_RECORD
- +#define DMAP_TYPE_IMAGE_RECORD DPAP_TYPE_RECORD
- +#define IS_DMAP_IMAGE_RECORD IS_DPAP_RECORD
- +
- +static inline DmapRecord *
- +grl_dpap_record_factory_create_compat (DmapRecordFactory *factory, gpointer user_data)
- +{
- + return grl_dpap_record_factory_create (factory, user_data, NULL);
- +}
- +
- +static inline void
- +set_thumbnail (GValue *value, GByteArray *thumbnail)
- +{
- + g_value_set_pointer (value, thumbnail);
- +}
- +
- +static inline GByteArray *
- +get_thumbnail (GByteArray *thumbnail, const GValue *value)
- +{
- + if (thumbnail)
- + g_byte_array_unref (thumbnail);
- + return g_byte_array_ref (g_value_get_pointer (value));
- +}
- +
- +static inline void
- +unref_thumbnail (GByteArray *thumbnail)
- +{
- + g_byte_array_unref (thumbnail);
- +}
- +
- +static inline guint
- +grl_dpap_db_add_compat (DMAPDb *_db, DmapRecord *_record)
- +{
- + return grl_dpap_db_add (_db, _record, NULL);
- +}
- +
- +#else
- +
- +/* Building against libdmapsharing 4 API. */
- +
- +DmapRecord *grl_dpap_record_factory_create (DmapRecordFactory *factory, gpointer user_data, GError **error);
- +guint grl_dpap_db_add (DmapDb *_db, DmapRecord *_record, GError **error);
- +
- +static inline void
- +set_thumbnail (GValue *value, GArray *thumbnail)
- +{
- + g_value_set_boxed (value, thumbnail);
- +}
- +
- +static inline GArray *
- +get_thumbnail (GArray *thumbnail, const GValue *value)
- +{
- + if (thumbnail)
- + g_array_unref (thumbnail);
- + return g_value_get_boxed (value);
- +}
- +
- +static inline void
- +unref_thumbnail (GArray *thumbnail)
- +{
- + g_array_unref (thumbnail);
- +}
- +
- +static inline DmapRecord *
- +grl_dpap_record_factory_create_compat (DmapRecordFactory *factory, gpointer user_data, GError **error)
- +{
- + return grl_dpap_record_factory_create (factory, user_data, error);
- +}
- +
- +static inline guint
- +grl_dpap_db_add_compat (DmapDb *_db, DmapRecord *_record, GError **error)
- +{
- + return grl_dpap_db_add (_db, _record, error);
- +}
- +
- +#endif
- +
- +#endif /* _GRL_DPAP_COMPAT_H_ */
- diff --git a/src/dmap/grl-dpap-db.c b/src/dmap/grl-dpap-db.c
- index 8be278b..cd647ee 100644
- --- a/src/dmap/grl-dpap-db.c
- +++ b/src/dmap/grl-dpap-db.c
- @@ -24,12 +24,16 @@
- #include "config.h"
- #endif
-
- +#include <grilo.h>
- #include <glib/gi18n-lib.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <glib.h>
- #include <string.h>
- +#include <libdmapsharing/dmap.h>
-
- +#include "grl-dpap-compat.h"
- +#include "grl-common.h"
- #include "grl-dpap-db.h"
-
- #define PHOTOS_ID "photos"
- @@ -71,23 +75,23 @@ grl_dpap_db_new (void)
- return db;
- }
-
- -static DMAPRecord *
- -grl_dpap_db_lookup_by_id (const DMAPDb *db, guint id)
- +static DmapRecord *
- +grl_dpap_db_lookup_by_id (const DmapDb *db, guint id)
- {
- g_warning ("Not implemented");
- return NULL;
- }
-
- static void
- -grl_dpap_db_foreach (const DMAPDb *db,
- - GHFunc func,
- +grl_dpap_db_foreach (const DmapDb *db,
- + DmapIdRecordFunc func,
- gpointer data)
- {
- g_warning ("Not implemented");
- }
-
- static gint64
- -grl_dpap_db_count (const DMAPDb *db)
- +grl_dpap_db_count (const DmapDb *db)
- {
- g_warning ("Not implemented");
- return 0;
- @@ -118,21 +122,21 @@ set_insert (GHashTable *category, const char *category_name, char *set_name, Grl
- g_object_unref (container);
- }
-
- -static guint
- -grl_dpap_db_add (DMAPDb *_db, DMAPRecord *_record)
- +guint
- +grl_dpap_db_add (DmapDb *_db, DmapRecord *_record, GError **error)
- {
- g_assert (IS_GRL_DPAP_DB (_db));
- - g_assert (IS_DPAP_RECORD (_record));
- + g_assert (IS_DMAP_IMAGE_RECORD (_record));
-
- GrlDPAPDb *db = GRL_DPAP_DB (_db);
- - DPAPRecord *record = DPAP_RECORD (_record);
- + DmapImageRecord *record = DMAP_IMAGE_RECORD (_record);
-
- gint height = 0,
- width = 0,
- largefilesize = 0,
- creationdate = 0,
- rating = 0;
- - GByteArray *thumbnail = NULL;
- + GArray *thumbnail = NULL;
- gchar *id_s = NULL,
- *filename = NULL,
- *aspectratio = NULL,
- @@ -177,12 +181,12 @@ grl_dpap_db_add (DMAPDb *_db, DMAPRecord *_record)
-
- g_free (id_s);
- g_object_unref (media);
- - g_free(filename);
- - g_free(aspectratio);
- - g_free(format);
- - g_free(comments);
- - g_free(url);
- - g_byte_array_unref(thumbnail);
- + g_free (filename);
- + g_free (aspectratio);
- + g_free (format);
- + g_free (comments);
- + g_free (url);
- + g_array_unref (thumbnail);
-
- return --nextid;
- }
- @@ -298,11 +302,11 @@ grl_dpap_db_search (GrlDPAPDb *db,
- static void
- dmap_db_interface_init (gpointer iface, gpointer data)
- {
- - DMAPDbIface *dpap_db = iface;
- + DmapDbInterface *dpap_db = iface;
-
- g_assert (G_TYPE_FROM_INTERFACE (dpap_db) == DMAP_TYPE_DB);
-
- - dpap_db->add = grl_dpap_db_add;
- + dpap_db->add = grl_dpap_db_add_compat;
- dpap_db->lookup_by_id = grl_dpap_db_lookup_by_id;
- dpap_db->foreach = grl_dpap_db_foreach;
- dpap_db->count = grl_dpap_db_count;
- diff --git a/src/dmap/grl-dpap-db.h b/src/dmap/grl-dpap-db.h
- index d3abcba..a21ad7a 100644
- --- a/src/dmap/grl-dpap-db.h
- +++ b/src/dmap/grl-dpap-db.h
- @@ -24,6 +24,8 @@
- #include <libdmapsharing/dmap.h>
- #include <grilo.h>
-
- +#include "grl-dpap-compat.h"
- +
- G_BEGIN_DECLS
-
- #define TYPE_GRL_DPAP_DB (grl_dpap_db_get_type ())
- diff --git a/src/dmap/grl-dpap-record-factory.c b/src/dmap/grl-dpap-record-factory.c
- index 3d0c87a..860d957 100644
- --- a/src/dmap/grl-dpap-record-factory.c
- +++ b/src/dmap/grl-dpap-record-factory.c
- @@ -18,11 +18,18 @@
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
- +#include <grilo.h>
- +#include <libdmapsharing/dmap.h>
- +
- +#include "grl-dpap-compat.h"
- +#include "grl-common.h"
- #include "grl-dpap-record-factory.h"
- #include "grl-dpap-record.h"
-
- -DMAPRecord *
- -grl_dpap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data)
- +DmapRecord *
- +grl_dpap_record_factory_create (DmapRecordFactory *factory,
- + gpointer user_data,
- + GError **error)
- {
- return DMAP_RECORD (grl_dpap_record_new ());
- }
- @@ -40,11 +47,11 @@ grl_dpap_record_factory_class_init (GrlDPAPRecordFactoryClass *klass)
- static void
- grl_dpap_record_factory_interface_init (gpointer iface, gpointer data)
- {
- - DMAPRecordFactoryIface *factory = iface;
- + DmapRecordFactoryInterface *factory = iface;
-
- g_assert (G_TYPE_FROM_INTERFACE (factory) == DMAP_TYPE_RECORD_FACTORY);
-
- - factory->create = grl_dpap_record_factory_create;
- + factory->create = grl_dpap_record_factory_create_compat;
- }
-
- G_DEFINE_TYPE_WITH_CODE (GrlDPAPRecordFactory, grl_dpap_record_factory, G_TYPE_OBJECT,
- diff --git a/src/dmap/grl-dpap-record-factory.h b/src/dmap/grl-dpap-record-factory.h
- index 3f4ca54..899fd0a 100644
- --- a/src/dmap/grl-dpap-record-factory.h
- +++ b/src/dmap/grl-dpap-record-factory.h
- @@ -23,6 +23,8 @@
-
- #include <libdmapsharing/dmap.h>
-
- +#include "grl-dpap-compat.h"
- +
- G_BEGIN_DECLS
-
- #define TYPE_SIMPLE_DPAP_RECORD_FACTORY (grl_dpap_record_factory_get_type ())
- @@ -64,7 +66,7 @@ GType grl_dpap_record_factory_get_type (void);
-
- GrlDPAPRecordFactory *grl_dpap_record_factory_new (void);
-
- -DMAPRecord *grl_dpap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data);
- +DmapRecord *grl_dpap_record_factory_create (DmapRecordFactory *factory, gpointer user_data, GError **error);
-
- #endif /* __SIMPLE_DPAP_RECORD_FACTORY */
-
- diff --git a/src/dmap/grl-dpap-record.c b/src/dmap/grl-dpap-record.c
- index 14eb1de..0afb2b8 100644
- --- a/src/dmap/grl-dpap-record.c
- +++ b/src/dmap/grl-dpap-record.c
- @@ -20,6 +20,11 @@
- *
- */
-
- +#include <grilo.h>
- +#include <libdmapsharing/dmap.h>
- +
- +#include "grl-dpap-compat.h"
- +#include "grl-common.h"
- #include "grl-dpap-record.h"
-
- struct GrlDPAPRecordPrivate {
- @@ -28,7 +33,7 @@ struct GrlDPAPRecordPrivate {
- gint creationdate;
- gint rating;
- char *filename;
- - GByteArray *thumbnail;
- + void *thumbnail; /* GByteArray or GArray, depending on libdmapsharing ver. */
- char *aspectratio;
- gint height;
- gint width;
- @@ -56,7 +61,7 @@ static void grl_dpap_record_dpap_iface_init (gpointer iface, gpointer data);
-
- G_DEFINE_TYPE_WITH_CODE (GrlDPAPRecord, grl_dpap_record, G_TYPE_OBJECT,
- G_ADD_PRIVATE (GrlDPAPRecord)
- - G_IMPLEMENT_INTERFACE (DPAP_TYPE_RECORD, grl_dpap_record_dpap_iface_init)
- + G_IMPLEMENT_INTERFACE (DMAP_TYPE_IMAGE_RECORD, grl_dpap_record_dpap_iface_init)
- G_IMPLEMENT_INTERFACE (DMAP_TYPE_RECORD, grl_dpap_record_dmap_iface_init))
-
- static void
- @@ -104,9 +109,7 @@ grl_dpap_record_set_property (GObject *object,
- record->priv->comments = g_value_dup_string (value);
- break;
- case PROP_THUMBNAIL:
- - if (record->priv->thumbnail)
- - g_byte_array_unref (record->priv->thumbnail);
- - record->priv->thumbnail = g_byte_array_ref (g_value_get_pointer (value));
- + record->priv->thumbnail = get_thumbnail (record->priv->thumbnail, value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- @@ -154,7 +157,7 @@ grl_dpap_record_get_property (GObject *object,
- g_value_set_static_string (value, record->priv->comments);
- break;
- case PROP_THUMBNAIL:
- - g_value_set_pointer (value, record->priv->thumbnail);
- + set_thumbnail (value, record->priv->thumbnail);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- @@ -169,7 +172,7 @@ grl_dpap_record_new (void)
- }
-
- GInputStream *
- -grl_dpap_record_read (DPAPRecord *record, GError **error)
- +grl_dpap_record_read (DmapImageRecord *record, GError **error)
- {
- GFile *file;
- GInputStream *stream;
- @@ -215,9 +218,9 @@ grl_dpap_record_class_init (GrlDPAPRecordClass *klass)
- static void
- grl_dpap_record_dpap_iface_init (gpointer iface, gpointer data)
- {
- - DPAPRecordIface *dpap_record = iface;
- + DmapImageRecordInterface *dpap_record = iface;
-
- - g_assert (G_TYPE_FROM_INTERFACE (dpap_record) == DPAP_TYPE_RECORD);
- + g_assert (G_TYPE_FROM_INTERFACE (dpap_record) == DMAP_TYPE_IMAGE_RECORD);
-
- dpap_record->read = grl_dpap_record_read;
- }
- @@ -225,7 +228,7 @@ grl_dpap_record_dpap_iface_init (gpointer iface, gpointer data)
- static void
- grl_dpap_record_dmap_iface_init (gpointer iface, gpointer data)
- {
- - DMAPRecordIface *dmap_record = iface;
- + DmapRecordInterface *dmap_record = iface;
-
- g_assert (G_TYPE_FROM_INTERFACE (dmap_record) == DMAP_TYPE_RECORD);
- }
- @@ -242,7 +245,7 @@ grl_dpap_record_finalize (GObject *object)
- g_free (record->priv->comments);
-
- if (record->priv->thumbnail)
- - g_byte_array_unref (record->priv->thumbnail);
- + unref_thumbnail (record->priv->thumbnail);
-
- G_OBJECT_CLASS (grl_dpap_record_parent_class)->finalize (object);
- }
- diff --git a/src/dmap/grl-dpap-record.h b/src/dmap/grl-dpap-record.h
- index 203e57e..77eece0 100644
- --- a/src/dmap/grl-dpap-record.h
- +++ b/src/dmap/grl-dpap-record.h
- @@ -23,6 +23,8 @@
-
- #include <libdmapsharing/dmap.h>
-
- +#include "grl-dpap-compat.h"
- +
- G_BEGIN_DECLS
-
- #define TYPE_SIMPLE_DPAP_RECORD (grl_dpap_record_get_type ())
- @@ -69,8 +71,8 @@ typedef struct {
- GType grl_dpap_record_get_type (void);
-
- GrlDPAPRecord *grl_dpap_record_new (void);
- -GInputStream *grl_dpap_record_read (DPAPRecord *record, GError **error);
- -gint grl_dpap_record_get_id (DPAPRecord *record);
- +GInputStream *grl_dpap_record_read (DmapImageRecord *record, GError **error);
- +gint grl_dpap_record_get_id (DmapImageRecord *record);
-
- #endif /* __SIMPLE_DPAP_RECORD */
-
- diff --git a/src/dmap/grl-dpap.c b/src/dmap/grl-dpap.c
- index 9829ec2..6339654 100644
- --- a/src/dmap/grl-dpap.c
- +++ b/src/dmap/grl-dpap.c
- @@ -33,6 +33,7 @@
- #include <stdlib.h>
- #include <libdmapsharing/dmap.h>
-
- +#include "grl-dpap-compat.h"
- #include "grl-common.h"
- #include "grl-dpap.h"
- #include "grl-dpap-db.h"
- @@ -57,12 +58,12 @@ GRL_LOG_DOMAIN_STATIC (dmap_log_domain);
- GrlDpapSourcePrivate))
-
- struct _GrlDpapSourcePrivate {
- - DMAPMdnsBrowserService *service;
- + DmapMdnsService *service;
- };
-
- /* --- Data types --- */
-
- -static GrlDpapSource *grl_dpap_source_new (DMAPMdnsBrowserService *service);
- +static GrlDpapSource *grl_dpap_source_new (DmapMdnsService *service);
-
- static void grl_dpap_source_finalize (GObject *object);
-
- @@ -79,16 +80,16 @@ static void grl_dpap_source_search (GrlSource *source,
- GrlSourceSearchSpec *ss);
-
-
- -static void grl_dpap_service_added_cb (DMAPMdnsBrowser *browser,
- - DMAPMdnsBrowserService *service,
- +static void grl_dpap_service_added_cb (DmapMdnsBrowser *browser,
- + DmapMdnsService *service,
- GrlPlugin *plugin);
-
- -static void grl_dpap_service_removed_cb (DMAPMdnsBrowser *browser,
- +static void grl_dpap_service_removed_cb (DmapMdnsBrowser *browser,
- const gchar *service_name,
- GrlPlugin *plugin);
-
- /* ===================== Globals ======================= */
- -static DMAPMdnsBrowser *browser;
- +static DmapMdnsBrowser *browser;
- /* Maps URIs to DBs */
- static GHashTable *connections;
- /* Map DPAP services to Grilo media sources */
- @@ -111,7 +112,7 @@ grl_dpap_plugin_init (GrlRegistry *registry,
- bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-
- - browser = dmap_mdns_browser_new (DMAP_MDNS_BROWSER_SERVICE_TYPE_DPAP);
- + browser = dmap_mdns_browser_new (DMAP_MDNS_SERVICE_TYPE_DPAP);
- connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- sources = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
-
- @@ -158,8 +159,10 @@ GRL_PLUGIN_DEFINE (GRL_MAJOR,
- G_DEFINE_TYPE_WITH_PRIVATE (GrlDpapSource, grl_dpap_source, GRL_TYPE_SOURCE)
-
- static GrlDpapSource *
- -grl_dpap_source_new (DMAPMdnsBrowserService *service)
- +grl_dpap_source_new (DmapMdnsService *service)
- {
- + gchar *name;
- + gchar *service_name;
- gchar *source_desc;
- gchar *source_id;
-
- @@ -167,12 +170,14 @@ grl_dpap_source_new (DMAPMdnsBrowserService *service)
-
- GRL_DEBUG ("grl_dpap_source_new");
-
- - source_desc = g_strdup_printf (SOURCE_DESC_TEMPLATE, service->name);
- - source_id = g_strdup_printf (SOURCE_ID_TEMPLATE, service->name);
- + name = grl_dmap_service_get_name (service);
- + service_name = grl_dmap_service_get_service_name (service);
- + source_desc = g_strdup_printf (SOURCE_DESC_TEMPLATE, name);
- + source_id = g_strdup_printf (SOURCE_ID_TEMPLATE, name);
-
- source = g_object_new (GRL_DPAP_SOURCE_TYPE,
- "source-id", source_id,
- - "source-name", service->name,
- + "source-name", service_name,
- "source-desc", source_desc,
- "supported-media", GRL_SUPPORTED_MEDIA_IMAGE,
- NULL);
- @@ -181,6 +186,8 @@ grl_dpap_source_new (DMAPMdnsBrowserService *service)
-
- g_free (source_desc);
- g_free (source_id);
- + g_free (service_name);
- + g_free (name);
-
- return source;
- }
- @@ -241,7 +248,7 @@ grl_dpap_do_search (ResultCbAndArgsAndDb *cb_and_db)
- }
-
- static void
- -browse_connected_cb (DMAPConnection *connection,
- +browse_connected_cb (DmapConnection *connection,
- gboolean result,
- const char *reason,
- ResultCbAndArgsAndDb *cb_and_db)
- @@ -266,7 +273,7 @@ browse_connected_cb (DMAPConnection *connection,
- }
-
- static void
- -search_connected_cb (DMAPConnection *connection,
- +search_connected_cb (DmapConnection *connection,
- gboolean result,
- const char *reason,
- ResultCbAndArgsAndDb *cb_and_db)
- @@ -291,8 +298,8 @@ search_connected_cb (DMAPConnection *connection,
- }
-
- static void
- -grl_dpap_service_added_cb (DMAPMdnsBrowser *browser,
- - DMAPMdnsBrowserService *service,
- +grl_dpap_service_added_cb (DmapMdnsBrowser *browser,
- + DmapMdnsService *service,
- GrlPlugin *plugin)
- {
- GrlRegistry *registry = grl_registry_get_default ();
- @@ -306,13 +313,16 @@ grl_dpap_service_added_cb (DMAPMdnsBrowser *browser,
- GRL_SOURCE (source),
- NULL);
- if (source != NULL) {
- - g_hash_table_insert (sources, g_strdup (service->name), g_object_ref (source));
- + gchar *name;
- + name = grl_dmap_service_get_name (service);
- + g_hash_table_insert (sources, g_strdup (name), g_object_ref (source));
- g_object_remove_weak_pointer (G_OBJECT (source), (gpointer *) &source);
- + g_free (name);
- }
- }
-
- static void
- -grl_dpap_service_removed_cb (DMAPMdnsBrowser *browser,
- +grl_dpap_service_removed_cb (DmapMdnsBrowser *browser,
- const gchar *service_name,
- GrlPlugin *plugin)
- {
- @@ -328,14 +338,14 @@ grl_dpap_service_removed_cb (DMAPMdnsBrowser *browser,
- }
-
- static void
- -grl_dpap_connect (gchar *name, gchar *host, guint port, ResultCbAndArgsAndDb *cb_and_db, DMAPConnectionCallback callback)
- +grl_dpap_connect (gchar *name, gchar *host, guint port, ResultCbAndArgsAndDb *cb_and_db, DmapConnectionFunc callback)
- {
- - DMAPRecordFactory *factory;
- - DMAPConnection *connection;
- + DmapRecordFactory *factory;
- + DmapConnection *connection;
-
- factory = DMAP_RECORD_FACTORY (grl_dpap_record_factory_new ());
- - connection = DMAP_CONNECTION (dpap_connection_new (name, host, port, DMAP_DB (cb_and_db->db), factory));
- - dmap_connection_connect (connection, (DMAPConnectionCallback) callback, cb_and_db);
- + connection = DMAP_CONNECTION (dmap_image_connection_new (name, host, port, DMAP_DB (cb_and_db->db), factory));
- + dmap_connection_start (connection, (DmapConnectionFunc) callback, cb_and_db);
- }
-
- static gboolean
- @@ -396,15 +406,25 @@ grl_dpap_source_browse (GrlSource *source,
- browse_connected_cb (NULL, TRUE, NULL, cb_and_db);
- } else {
- /* Connect */
- + gchar *name, *host;
- + guint port;
- +
- cb_and_db->db = DMAP_DB (grl_dpap_db_new ());
-
- - grl_dpap_connect (dmap_source->priv->service->name,
- - dmap_source->priv->service->host,
- - dmap_source->priv->service->port,
- + name = grl_dmap_service_get_name (dmap_source->priv->service);
- + host = grl_dmap_service_get_host (dmap_source->priv->service);
- + port = grl_dmap_service_get_port (dmap_source->priv->service);
- +
- + grl_dpap_connect (name,
- + host,
- + port,
- cb_and_db,
- - (DMAPConnectionCallback) browse_connected_cb);
- + (DmapConnectionFunc) browse_connected_cb);
-
- g_hash_table_insert (connections, g_strdup (url), cb_and_db->db);
- +
- + g_free (name);
- + g_free (host);
- }
-
- g_free (url);
- @@ -416,7 +436,7 @@ static void grl_dpap_source_search (GrlSource *source,
- GrlDpapSource *dmap_source = GRL_DPAP_SOURCE (source);
-
- ResultCbAndArgsAndDb *cb_and_db;
- - DMAPMdnsBrowserService *service = dmap_source->priv->service;
- + DmapMdnsService *service = dmap_source->priv->service;
- gchar *url = grl_dmap_build_url (service);
-
- cb_and_db = g_new (ResultCbAndArgsAndDb, 1);
- @@ -434,9 +454,25 @@ static void grl_dpap_source_search (GrlSource *source,
- search_connected_cb (NULL, TRUE, NULL, cb_and_db);
- } else {
- /* Connect */
- + gchar *name, *host;
- + guint port;
- +
- cb_and_db->db = DMAP_DB (grl_dpap_db_new ());
- - grl_dpap_connect (service->name, service->host, service->port, cb_and_db, (DMAPConnectionCallback) search_connected_cb);
- +
- + name = grl_dmap_service_get_name (dmap_source->priv->service);
- + host = grl_dmap_service_get_host (dmap_source->priv->service);
- + port = grl_dmap_service_get_port (dmap_source->priv->service);
- +
- + grl_dpap_connect (name,
- + host,
- + port,
- + cb_and_db,
- + (DmapConnectionFunc) search_connected_cb);
- +
- g_hash_table_insert (connections, g_strdup (url), cb_and_db->db);
- +
- + g_free (name);
- + g_free (host);
- }
-
- g_free (url);
- diff --git a/src/dmap/grl-dpap.h b/src/dmap/grl-dpap.h
- index ee596b5..30cd61e 100644
- --- a/src/dmap/grl-dpap.h
- +++ b/src/dmap/grl-dpap.h
- @@ -26,6 +26,8 @@
-
- #include <grilo.h>
-
- +#include "grl-dpap-compat.h"
- +
- #define GRL_DPAP_SOURCE_TYPE (grl_dpap_source_get_type ())
-
- #define GRL_DPAP_SOURCE(obj) \
- diff --git a/src/dmap/meson.build b/src/dmap/meson.build
- index 2907a80..817ff5d 100644
- --- a/src/dmap/meson.build
- +++ b/src/dmap/meson.build
- @@ -31,6 +31,15 @@ dpap_sources = [
- 'grl-dpap.h',
- ]
-
- +args = [
- + '-DG_LOG_DOMAIN="GrlDmap"',
- + '-DHAVE_CONFIG_H',
- +]
- +
- +if not libdmapsharing4_dep.found()
- + args += '-DLIBDMAPSHARING_COMPAT'
- +endif
- +
- configure_file(output: 'config.h',
- configuration: cdata)
-
- @@ -39,17 +48,11 @@ shared_library('grldaap',
- install: true,
- install_dir: pluginsdir,
- dependencies: must_deps + plugins[dmap_idx][REQ_DEPS] + plugins[dmap_idx][OPT_DEPS],
- - c_args: [
- - '-DG_LOG_DOMAIN="GrlDmap"',
- - '-DHAVE_CONFIG_H',
- - ])
- + c_args: args)
-
- shared_library('grldpap',
- sources: dpap_sources,
- install: true,
- install_dir: pluginsdir,
- dependencies: must_deps + plugins[dmap_idx][REQ_DEPS] + plugins[dmap_idx][OPT_DEPS],
- - c_args: [
- - '-DG_LOG_DOMAIN="GrlDmap"',
- - '-DHAVE_CONFIG_H',
- - ])
- + c_args: args)
|