[libdmapsharing] Big indent patch Signed-off-by: W. Michael Petullo <mike flyn org>
- From: W. Michael Petullo <wmpetullo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdmapsharing] Big indent patch Signed-off-by: W. Michael Petullo <mike flyn org>
- Date: Fri, 4 Mar 2011 20:34:13 +0000 (UTC)
commit 39e643417d459780e5acc4ad3568aa3ddc073a12
Author: W. Michael Petullo <mike flyn org>
Date: Fri Mar 4 14:33:43 2011 -0600
Big indent patch
Signed-off-by: W. Michael Petullo <mike flyn org>
libdmapsharing/daap-connection.c | 174 ++--
libdmapsharing/daap-connection.h | 23 +-
libdmapsharing/daap-record.c | 278 +++---
libdmapsharing/daap-record.h | 19 +-
libdmapsharing/daap-share.c | 460 ++++++----
libdmapsharing/daap-share.h | 16 +-
libdmapsharing/dacp-connection.c | 45 +-
libdmapsharing/dacp-connection.h | 23 +-
libdmapsharing/dacp-player.c | 114 ++--
libdmapsharing/dacp-player.h | 46 +-
libdmapsharing/dacp-share.c | 709 ++++++++-------
libdmapsharing/dacp-share.h | 45 +-
libdmapsharing/dmap-connection.c | 954 ++++++++++---------
libdmapsharing/dmap-connection.h | 135 ++--
libdmapsharing/dmap-container-db.c | 26 +-
libdmapsharing/dmap-container-db.h | 25 +-
libdmapsharing/dmap-container-record.c | 47 +-
libdmapsharing/dmap-container-record.h | 29 +-
libdmapsharing/dmap-db.c | 125 ++--
libdmapsharing/dmap-db.h | 53 +-
libdmapsharing/dmap-gst-input-stream.c | 262 +++---
libdmapsharing/dmap-gst-input-stream.h | 21 +-
libdmapsharing/dmap-gst-mp3-input-stream.c | 88 ++-
libdmapsharing/dmap-gst-mp3-input-stream.h | 13 +-
libdmapsharing/dmap-gst-wav-input-stream.c | 94 ++-
libdmapsharing/dmap-gst-wav-input-stream.h | 13 +-
libdmapsharing/dmap-md5.c | 701 +++++++--------
libdmapsharing/dmap-md5.h | 11 +-
libdmapsharing/dmap-mdns-avahi.c | 36 +-
libdmapsharing/dmap-mdns-avahi.h | 5 +-
libdmapsharing/dmap-mdns-browser-avahi.c | 747 ++++++++--------
libdmapsharing/dmap-mdns-browser-howl.c | 745 ++++++++--------
libdmapsharing/dmap-mdns-browser.h | 67 +-
libdmapsharing/dmap-mdns-publisher-avahi.c | 252 +++---
libdmapsharing/dmap-mdns-publisher.h | 42 +-
libdmapsharing/dmap-record-factory.c | 18 +-
libdmapsharing/dmap-record-factory.h | 10 +-
libdmapsharing/dmap-record.c | 27 +-
libdmapsharing/dmap-record.h | 22 +-
libdmapsharing/dmap-share.c | 1367 +++++++++++++++-------------
libdmapsharing/dmap-share.h | 260 +++---
libdmapsharing/dmap-structure.c | 1320 +++++++++++++++------------
libdmapsharing/dmap-structure.h | 95 +-
libdmapsharing/dmap-utils.c | 12 +-
libdmapsharing/dmap-utils.h | 16 +-
libdmapsharing/dpap-connection.c | 147 ++--
libdmapsharing/dpap-connection.h | 23 +-
libdmapsharing/dpap-record.c | 157 ++--
libdmapsharing/dpap-record.h | 11 +-
libdmapsharing/dpap-share.c | 327 ++++---
libdmapsharing/dpap-share.h | 16 +-
libdmapsharing/gst-util.c | 4 +-
libdmapsharing/gst-util.h | 2 +-
53 files changed, 5383 insertions(+), 4894 deletions(-)
---
diff --git a/libdmapsharing/daap-connection.c b/libdmapsharing/daap-connection.c
index 2c24adf..af649d4 100644
--- a/libdmapsharing/daap-connection.c
+++ b/libdmapsharing/daap-connection.c
@@ -31,7 +31,7 @@ struct DAAPConnectionPrivate {
*/
static DMAPContentCode
-get_protocol_version_cc (DMAPConnection *connection)
+get_protocol_version_cc (DMAPConnection * connection)
{
return DMAP_CC_APRO;
}
@@ -48,7 +48,8 @@ get_query_metadata (void)
}
static DMAPRecord *
-handle_mlcl (DMAPConnection *connection, DMAPRecordFactory *factory, GNode *n, int *item_id)
+handle_mlcl (DMAPConnection * connection, DMAPRecordFactory * factory,
+ GNode * n, int *item_id)
{
GNode *n2;
DMAPRecord *record = NULL;
@@ -73,53 +74,57 @@ handle_mlcl (DMAPConnection *connection, DMAPRecordFactory *factory, GNode *n, i
meta_item = n2->data;
switch (meta_item->content_code) {
- case DMAP_CC_MIID:
- *item_id = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_MINM:
- title = g_value_get_string (&(meta_item->content));
- break;
- case DMAP_CC_ASAL:
- album = g_value_get_string (&(meta_item->content));
- break;
- case DMAP_CC_ASAR:
- artist = g_value_get_string (&(meta_item->content));
- break;
- case DMAP_CC_ASFM:
- format = g_value_get_string (&(meta_item->content));
- break;
- case DMAP_CC_ASGN:
- genre = g_value_get_string (&(meta_item->content));
- break;
- case DMAP_CC_ASTM:
- length = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_ASTN:
- track_number = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_ASDN:
- disc_number = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_ASYR:
- year = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_ASSZ:
- size = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_ASBR:
- bitrate = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_ASUL:
- streamURI = g_value_get_string (&(meta_item->content));
- break;
- case DMAP_CC_ASSA:
- sort_artist = g_value_get_string (&(meta_item->content));
- break;
- case DMAP_CC_ASSU:
- sort_album = g_value_get_string (&(meta_item->content));
- break;
- default:
- break;
+ case DMAP_CC_MIID:
+ *item_id = g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_MINM:
+ title = g_value_get_string (&(meta_item->content));
+ break;
+ case DMAP_CC_ASAL:
+ album = g_value_get_string (&(meta_item->content));
+ break;
+ case DMAP_CC_ASAR:
+ artist = g_value_get_string (&(meta_item->content));
+ break;
+ case DMAP_CC_ASFM:
+ format = g_value_get_string (&(meta_item->content));
+ break;
+ case DMAP_CC_ASGN:
+ genre = g_value_get_string (&(meta_item->content));
+ break;
+ case DMAP_CC_ASTM:
+ length = g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_ASTN:
+ track_number =
+ g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_ASDN:
+ disc_number = g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_ASYR:
+ year = g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_ASSZ:
+ size = g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_ASBR:
+ bitrate = g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_ASUL:
+ streamURI =
+ g_value_get_string (&(meta_item->content));
+ break;
+ case DMAP_CC_ASSA:
+ sort_artist =
+ g_value_get_string (&(meta_item->content));
+ break;
+ case DMAP_CC_ASSU:
+ sort_album =
+ g_value_get_string (&(meta_item->content));
+ break;
+ default:
+ break;
}
}
@@ -128,68 +133,65 @@ handle_mlcl (DMAPConnection *connection, DMAPRecordFactory *factory, GNode *n, i
goto _return;
}
g_object_set (record,
- "year", year,
- "track", track_number,
- "disc", disc_number,
- "bitrate", bitrate,
- "duration", length / 1000,
- "filesize", (guint64) size,
- "format", format,
- "title", title,
- "songalbum", album,
- "songartist", artist,
- "songgenre", genre,
- "sort-artist", sort_artist,
- "sort-album", sort_album,
- NULL);
-
-_return:
+ "year", year,
+ "track", track_number,
+ "disc", disc_number,
+ "bitrate", bitrate,
+ "duration", length / 1000,
+ "filesize", (guint64) size,
+ "format", format,
+ "title", title,
+ "songalbum", album,
+ "songartist", artist,
+ "songgenre", genre,
+ "sort-artist", sort_artist,
+ "sort-album", sort_album, NULL);
+
+ _return:
return record;
}
static void
-daap_connection_class_init (DAAPConnectionClass *klass)
+daap_connection_class_init (DAAPConnectionClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- DMAPConnectionClass *parent_class = DMAP_CONNECTION_CLASS (object_class);
+ DMAPConnectionClass *parent_class =
+ DMAP_CONNECTION_CLASS (object_class);
parent_class->get_protocol_version_cc = get_protocol_version_cc;
parent_class->get_query_metadata = get_query_metadata;
parent_class->handle_mlcl = handle_mlcl;
/* FIXME:
- g_type_class_add_private (klass, sizeof (DAAPConnectionPrivate));
- */
+ * g_type_class_add_private (klass, sizeof (DAAPConnectionPrivate));
+ */
}
DAAPConnection *
-daap_connection_new (const char *name,
- const char *host,
- guint port,
- gboolean password_protected,
- DMAPDb *db,
- DMAPRecordFactory *factory)
+daap_connection_new (const char *name,
+ const char *host,
+ guint port,
+ gboolean password_protected,
+ DMAPDb * db, DMAPRecordFactory * factory)
{
DAAPConnection *connection;
-
+
connection = g_object_new (DAAP_TYPE_CONNECTION,
- "name", name,
- "password-protected", password_protected,
- "db", db,
- "host", host,
- "port", port,
- "factory", factory,
- NULL);
+ "name", name,
+ "password-protected", password_protected,
+ "db", db,
+ "host", host,
+ "port", port, "factory", factory, NULL);
return connection;
}
static void
-daap_connection_init (DAAPConnection *connection)
+daap_connection_init (DAAPConnection * connection)
{
/* FIXME:
- connection->priv = DAAP_CONNECTION_GET_PRIVATE (connection);
- */
+ * connection->priv = DAAP_CONNECTION_GET_PRIVATE (connection);
+ */
}
G_DEFINE_TYPE (DAAPConnection, daap_connection, DMAP_TYPE_CONNECTION)
diff --git a/libdmapsharing/daap-connection.h b/libdmapsharing/daap-connection.h
index 0c1fd93..fdaf7dd 100644
--- a/libdmapsharing/daap-connection.h
+++ b/libdmapsharing/daap-connection.h
@@ -23,7 +23,6 @@
#include <libdmapsharing/dmap-db.h>
G_BEGIN_DECLS
-
/**
* DAAP_TYPE_CONNECTION:
*
@@ -71,26 +70,26 @@ G_BEGIN_DECLS
* Returns: pointer to object class structure.
*/
#define DAAP_CONNECTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DAAP_TYPE_CONNECTION, DAAPConnectionClass))
-
typedef struct DAAPConnectionPrivate DAAPConnectionPrivate;
-typedef struct {
+typedef struct
+{
DMAPConnectionClass dmap_connection_class;
} DAAPConnectionClass;
-typedef struct {
+typedef struct
+{
DMAPConnection dmap_connection_instance;
DAAPConnectionPrivate *priv;
} DAAPConnection;
-GType daap_connection_get_type (void);
+GType daap_connection_get_type (void);
-DAAPConnection * daap_connection_new (const char *name,
- const char *host,
- guint port,
- gboolean password_protected,
- DMAPDb *db,
- DMAPRecordFactory *factory);
+DAAPConnection *daap_connection_new (const char *name,
+ const char *host,
+ guint port,
+ gboolean password_protected,
+ DMAPDb * db,
+ DMAPRecordFactory * factory);
G_END_DECLS
-
#endif /* __DAAP_CONNECTION_H */
diff --git a/libdmapsharing/daap-record.c b/libdmapsharing/daap-record.c
index 1aaf39e..18047b0 100644
--- a/libdmapsharing/daap-record.c
+++ b/libdmapsharing/daap-record.c
@@ -23,184 +23,175 @@
static gint daap_record_init_count = 0;
static void
-daap_record_init (DAAPRecordIface *iface)
+daap_record_init (DAAPRecordIface * iface)
{
static gboolean is_initialized = FALSE;
- daap_record_init_count++;
+ daap_record_init_count++;
- if (! is_initialized) {
+ if (!is_initialized) {
g_object_interface_install_property (iface,
- g_param_spec_string ("location",
- "URI pointing to song data",
- "URI pointing to song data",
- NULL,
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("location",
+ "URI pointing to song data",
+ "URI pointing to song data",
+ NULL,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_string ("title",
- "Song title",
- "Song title",
- "Unknown",
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("title", "Song title",
+ "Song title", "Unknown",
+ G_PARAM_READWRITE));
/* FIXME: This is actually an enum */
g_object_interface_install_property (iface,
- g_param_spec_int ("mediakind",
- "Media kind",
- "Media kind",
- 0,
- G_MAXINT,
- 1,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("mediakind",
+ "Media kind",
+ "Media kind", 0,
+ G_MAXINT, 1,
+ G_PARAM_READWRITE));
/* NOTE: the name must match the part after the last dot of the
- DAAP name, so daap.songalbum becomes songalbum and so on.*/
+ * DAAP name, so daap.songalbum becomes songalbum and so on. */
g_object_interface_install_property (iface,
- g_param_spec_string ("songalbum",
- "Album name",
- "Album name",
- "Unknown",
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("songalbum",
+ "Album name",
+ "Album name", "Unknown",
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int64 ("songalbumid",
- "Album id",
- "Album id",
- G_MININT64,
- G_MAXINT64,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int64
+ ("songalbumid",
+ "Album id", "Album id",
+ G_MININT64, G_MAXINT64,
+ 0, G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_string ("sort-album",
- "Album sort name",
- "Album sort name",
- "Unknown",
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("sort-album",
+ "Album sort name",
+ "Album sort name",
+ "Unknown",
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_string ("songartist",
- "Song artist",
- "Song artist",
- "Unknown",
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("songartist",
+ "Song artist",
+ "Song artist",
+ "Unknown",
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_string ("sort-artist",
- "Song artist sort name",
- "Song artist sort name",
- "Unknown",
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("sort-artist",
+ "Song artist sort name",
+ "Song artist sort name",
+ "Unknown",
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_string ("songgenre",
- "Song genre",
- "Song genre",
- "Unknown",
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("songgenre",
+ "Song genre",
+ "Song genre", "Unknown",
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_string ("format",
- "Song data format",
- "Song data format",
- "Unknown",
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("format",
+ "Song data format",
+ "Song data format",
+ "Unknown",
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("rating",
- "Song rating",
- "Song rating",
- 0,
- 5,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("rating", "Song rating",
+ "Song rating", 0, 5, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_uint64 ("filesize",
- "Song data size in bytes",
- "Song data size in bytes",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_uint64
+ ("filesize",
+ "Song data size in bytes",
+ "Song data size in bytes",
+ 0, G_MAXINT, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("duration",
- "Song duration in seconds",
- "Song duration in seconds",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("duration",
+ "Song duration in seconds",
+ "Song duration in seconds",
+ 0, G_MAXINT, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("track",
- "Song track number",
- "Song track number",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("track",
+ "Song track number",
+ "Song track number", 0,
+ G_MAXINT, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("year",
- "Song publication year",
- "Song publication year",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int ("year",
+ "Song publication year",
+ "Song publication year",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("firstseen",
- "FIXME",
- "FIXME",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("firstseen", "FIXME",
+ "FIXME", 0, G_MAXINT, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("mtime",
- "Song modification time",
- "Song modification time",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("mtime",
+ "Song modification time",
+ "Song modification time",
+ 0, G_MAXINT, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("disc",
- "Song disc number",
- "Song disc number",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int ("disc",
+ "Song disc number",
+ "Song disc number",
+ 0,
+ G_MAXINT,
+ 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("bitrate",
- "Song data bitrate in Kb/s",
- "Song data bitrate in Kb/s",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("bitrate",
+ "Song data bitrate in Kb/s",
+ "Song data bitrate in Kb/s",
+ 0, G_MAXINT, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_boolean ("has-video",
- "Song has video component",
- "Song has video component",
- FALSE,
- G_PARAM_READWRITE));
+ g_param_spec_boolean
+ ("has-video",
+ "Song has video component",
+ "Song has video component",
+ FALSE,
+ G_PARAM_READWRITE));
is_initialized = TRUE;
}
}
static void
-daap_record_finalize (DAAPRecordIface *iface)
+daap_record_finalize (DAAPRecordIface * iface)
{
daap_record_init_count--;
}
@@ -210,34 +201,35 @@ GType
daap_record_get_type (void)
{
static GType object_type = 0;
+
if (!object_type) {
static const GTypeInfo object_info = {
- sizeof(DAAPRecordIface),
+ sizeof (DAAPRecordIface),
(GBaseInitFunc) daap_record_init,
(GBaseFinalizeFunc) daap_record_finalize
};
object_type =
- g_type_register_static(G_TYPE_INTERFACE,
- "DAAPRecord",
- &object_info, 0);
+ g_type_register_static (G_TYPE_INTERFACE,
+ "DAAPRecord",
+ &object_info, 0);
}
return object_type;
}
gboolean
-daap_record_itunes_compat (DAAPRecord *record)
+daap_record_itunes_compat (DAAPRecord * record)
{
return DAAP_RECORD_GET_INTERFACE (record)->itunes_compat (record);
}
GInputStream *
-daap_record_read (DAAPRecord *record, GError **err)
+daap_record_read (DAAPRecord * record, GError ** err)
{
return DAAP_RECORD_GET_INTERFACE (record)->read (record, err);
}
-gint
-daap_record_cmp_by_album (gpointer a, gpointer b, DMAPDb *db)
+gint
+daap_record_cmp_by_album (gpointer a, gpointer b, DMAPDb * db)
{
DAAPRecord *record_a, *record_b;
gchar *album_a, *album_b;
@@ -245,22 +237,26 @@ daap_record_cmp_by_album (gpointer a, gpointer b, DMAPDb *db)
gint track_a, track_b;
gint ret;
- record_a = DAAP_RECORD (dmap_db_lookup_by_id (db, GPOINTER_TO_UINT(a)));
- record_b = DAAP_RECORD (dmap_db_lookup_by_id (db, GPOINTER_TO_UINT(b)));
+ record_a =
+ DAAP_RECORD (dmap_db_lookup_by_id (db, GPOINTER_TO_UINT (a)));
+ record_b =
+ DAAP_RECORD (dmap_db_lookup_by_id (db, GPOINTER_TO_UINT (b)));
g_assert (record_a);
g_assert (record_b);
- g_object_get (record_a, "songalbum", &album_a, "sort-album", &sort_album_a, "track", &track_a, NULL);
- g_object_get (record_b, "songalbum", &album_b, "sort-album", &sort_album_b, "track", &track_b, NULL);
+ g_object_get (record_a, "songalbum", &album_a, "sort-album",
+ &sort_album_a, "track", &track_a, NULL);
+ g_object_get (record_b, "songalbum", &album_b, "sort-album",
+ &sort_album_b, "track", &track_b, NULL);
if (sort_album_a && sort_album_b)
ret = g_strcmp0 (sort_album_a, sort_album_b);
else
ret = g_strcmp0 (album_a, album_b);
if (ret == 0) {
- if (track_a < track_b)
+ if (track_a < track_b)
ret = -1;
- else
+ else
ret = (track_a == track_b) ? 0 : 1;
}
g_object_unref (record_a);
diff --git a/libdmapsharing/daap-record.h b/libdmapsharing/daap-record.h
index ffaebe1..b4a0aac 100644
--- a/libdmapsharing/daap-record.h
+++ b/libdmapsharing/daap-record.h
@@ -28,7 +28,6 @@
#include <libdmapsharing/dmap-db.h>
G_BEGIN_DECLS
-
/**
* DAAP_TYPE_RECORD:
*
@@ -63,18 +62,18 @@ G_BEGIN_DECLS
*/
#define DAAP_RECORD_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), \
DAAP_TYPE_RECORD, DAAPRecordIface))
-
typedef struct _DAAPRecord DAAPRecord;
typedef struct _DAAPRecordIface DAAPRecordIface;
-struct _DAAPRecordIface {
+struct _DAAPRecordIface
+{
GTypeInterface parent;
- gboolean (*itunes_compat) (DAAPRecord *record);
- GInputStream * (*read) (DAAPRecord *record, GError **err);
+ gboolean (*itunes_compat) (DAAPRecord * record);
+ GInputStream *(*read) (DAAPRecord * record, GError ** err);
};
-GType daap_record_get_type (void);
+GType daap_record_get_type (void);
/**
* daap_record_itunes_compat:
@@ -82,7 +81,7 @@ GType daap_record_get_type (void);
*
* Returns: TRUE if record is compatible with iTunes, else FALSE.
*/
-gboolean daap_record_itunes_compat (DAAPRecord *record);
+gboolean daap_record_itunes_compat (DAAPRecord * record);
/**
* daap_record_read:
@@ -92,7 +91,7 @@ gboolean daap_record_itunes_compat (DAAPRecord *record);
* Returns: A GInputStream that provides read-only access to the data stream
* associated with record.
*/
-GInputStream *daap_record_read (DAAPRecord *record, GError **err);
+GInputStream *daap_record_read (DAAPRecord * record, GError ** err);
/**
* daap_record_cmp_by_album:
@@ -102,8 +101,8 @@ GInputStream *daap_record_read (DAAPRecord *record, GError **err);
*
* Compares the two records associated with the provided keys according
* to album. Suitable to sort lists of albums.
- */
-gint daap_record_cmp_by_album (gpointer a, gpointer b, DMAPDb *db);
+ */
+gint daap_record_cmp_by_album (gpointer a, gpointer b, DMAPDb * db);
#endif /* __DAAP_RECORD_H */
diff --git a/libdmapsharing/daap-share.c b/libdmapsharing/daap-share.c
index 215c775..0a0f1f7 100644
--- a/libdmapsharing/daap-share.c
+++ b/libdmapsharing/daap-share.c
@@ -42,59 +42,56 @@
#include <libdmapsharing/dmap-gst-input-stream.h>
#endif /* HAVE_GSTREAMERAPP */
-static void daap_share_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void daap_share_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void daap_share_dispose (GObject *object);
-guint daap_share_get_desired_port (DMAPShare *share);
-const char *daap_share_get_type_of_service (DMAPShare *share);
-void daap_share_server_info (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
-void daap_share_message_add_standard_headers (DMAPShare *share,
- SoupMessage *message);
-static void databases_browse_xxx (DMAPShare *share,
- SoupServer *server,
- SoupMessage *msg,
+static void daap_share_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec);
+static void daap_share_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void daap_share_dispose (GObject * object);
+guint daap_share_get_desired_port (DMAPShare * share);
+const char *daap_share_get_type_of_service (DMAPShare * share);
+void daap_share_server_info (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context);
+void daap_share_message_add_standard_headers (DMAPShare * share,
+ SoupMessage * message);
+static void databases_browse_xxx (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * msg,
const char *path,
- GHashTable *query,
- SoupClientContext *context);
-static void databases_items_xxx (DMAPShare *share,
- SoupServer *server,
- SoupMessage *msg,
+ GHashTable * query,
+ SoupClientContext * context);
+static void databases_items_xxx (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * msg,
const char *path,
- GHashTable *query,
- SoupClientContext *context);
-static struct DMAPMetaDataMap *get_meta_data_map (DMAPShare *share);
-static void add_entry_to_mlcl (gpointer id,
- DMAPRecord *record,
- gpointer mb);
+ GHashTable * query,
+ SoupClientContext * context);
+static struct DMAPMetaDataMap *get_meta_data_map (DMAPShare * share);
+static void add_entry_to_mlcl (gpointer id, DMAPRecord * record, gpointer mb);
#define DAAP_TYPE_OF_SERVICE "_daap._tcp"
#define DAAP_PORT 3689
-struct DAAPSharePrivate {
+struct DAAPSharePrivate
+{
gchar unused;
};
#define DAAP_SHARE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DAAP_TYPE_SHARE, DAAPSharePrivate))
-enum {
+enum
+{
PROP_0,
};
G_DEFINE_TYPE (DAAPShare, daap_share, DMAP_TYPE_SHARE)
-static void
-daap_share_class_init (DAAPShareClass *klass)
+ static void daap_share_class_init (DAAPShareClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
DMAPShareClass *parent_class = DMAP_SHARE_CLASS (object_class);
@@ -103,30 +100,30 @@ daap_share_class_init (DAAPShareClass *klass)
object_class->set_property = daap_share_set_property;
object_class->dispose = daap_share_dispose;
- parent_class->get_desired_port = daap_share_get_desired_port;
- parent_class->get_type_of_service = daap_share_get_type_of_service;
- parent_class->message_add_standard_headers = daap_share_message_add_standard_headers;
- parent_class->get_meta_data_map = get_meta_data_map;
- parent_class->add_entry_to_mlcl = add_entry_to_mlcl;
+ parent_class->get_desired_port = daap_share_get_desired_port;
+ parent_class->get_type_of_service = daap_share_get_type_of_service;
+ parent_class->message_add_standard_headers =
+ daap_share_message_add_standard_headers;
+ parent_class->get_meta_data_map = get_meta_data_map;
+ parent_class->add_entry_to_mlcl = add_entry_to_mlcl;
parent_class->databases_browse_xxx = databases_browse_xxx;
- parent_class->databases_items_xxx = databases_items_xxx;
- parent_class->server_info = daap_share_server_info;
+ parent_class->databases_items_xxx = databases_items_xxx;
+ parent_class->server_info = daap_share_server_info;
g_type_class_add_private (klass, sizeof (DAAPSharePrivate));
}
static void
-daap_share_init (DAAPShare *share)
+daap_share_init (DAAPShare * share)
{
share->priv = DAAP_SHARE_GET_PRIVATE (share);
/* FIXME: do I need to manually call parent _init? */
}
static void
-daap_share_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+daap_share_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
// DAAPShare *share = DAAP_SHARE (object);
@@ -138,10 +135,8 @@ daap_share_set_property (GObject *object,
}
static void
-daap_share_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+daap_share_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
// DAAPShare *share = DAAP_SHARE (object);
@@ -153,18 +148,19 @@ daap_share_get_property (GObject *object,
}
static void
-daap_share_dispose (GObject *object)
+daap_share_dispose (GObject * object)
{
/* FIXME: implement in parent */
}
-static gchar *mime_to_format (const gchar *transcode_mimetype)
+static gchar *
+mime_to_format (const gchar * transcode_mimetype)
{
- if (! transcode_mimetype) {
+ if (!transcode_mimetype) {
return NULL;
- } else if (! strcmp (transcode_mimetype, "audio/wav")) {
+ } else if (!strcmp (transcode_mimetype, "audio/wav")) {
return g_strdup ("wav");
- } else if ( ! strcmp (transcode_mimetype, "audio/mp3")) {
+ } else if (!strcmp (transcode_mimetype, "audio/mp3")) {
return g_strdup ("mp3");
} else
return NULL;
@@ -173,9 +169,8 @@ static gchar *mime_to_format (const gchar *transcode_mimetype)
DAAPShare *
daap_share_new (const char *name,
const char *password,
- DMAPDb *db,
- DMAPContainerDb *container_db,
- gchar *transcode_mimetype)
+ DMAPDb * db,
+ DMAPContainerDb * container_db, gchar * transcode_mimetype)
{
DAAPShare *share;
@@ -183,12 +178,12 @@ daap_share_new (const char *name,
g_object_ref (container_db);
share = DAAP_SHARE (g_object_new (DAAP_TYPE_SHARE,
- "name", name,
- "password", password,
- "db", db,
- "container-db", container_db,
- "transcode-mimetype", transcode_mimetype,
- NULL));
+ "name", name,
+ "password", password,
+ "db", db,
+ "container-db", container_db,
+ "transcode-mimetype",
+ transcode_mimetype, NULL));
_dmap_share_server_start (DMAP_SHARE (share));
_dmap_share_publish_start (DMAP_SHARE (share));
@@ -197,9 +192,11 @@ daap_share_new (const char *name,
}
void
-daap_share_message_add_standard_headers (DMAPShare *share, SoupMessage *message)
+daap_share_message_add_standard_headers (DMAPShare * share,
+ SoupMessage * message)
{
- soup_message_headers_append (message->response_headers, "DMAP-Server", "libdmapsharing" VERSION);
+ soup_message_headers_append (message->response_headers, "DMAP-Server",
+ "libdmapsharing" VERSION);
}
#define DMAP_VERSION 2.0
@@ -207,24 +204,23 @@ daap_share_message_add_standard_headers (DMAPShare *share, SoupMessage *message)
#define DAAP_TIMEOUT 1800
guint
-daap_share_get_desired_port (DMAPShare *share)
+daap_share_get_desired_port (DMAPShare * share)
{
return DAAP_PORT;
}
const char *
-daap_share_get_type_of_service (DMAPShare *share)
+daap_share_get_type_of_service (DMAPShare * share)
{
return DAAP_TYPE_OF_SERVICE;
}
void
-daap_share_server_info (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
+daap_share_server_info (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
/* MSRV server info response
* MSTT status
@@ -264,7 +260,8 @@ daap_share_server_info (DMAPShare *share,
* 3.0 is 2/3
*/
dmap_structure_add (msrv, DMAP_CC_MINM, nameprop);
- dmap_structure_add (msrv, DMAP_CC_MSAU, _dmap_share_get_auth_method (share));
+ dmap_structure_add (msrv, DMAP_CC_MSAU,
+ _dmap_share_get_auth_method (share));
/* authentication method
* 0 is nothing
* 1 is name & password
@@ -288,7 +285,8 @@ daap_share_server_info (DMAPShare *share,
g_free (nameprop);
}
-typedef enum {
+typedef enum
+{
ITEM_ID = 0,
ITEM_NAME,
ITEM_KIND,
@@ -336,57 +334,60 @@ typedef enum {
} DAAPMetaData;
static struct DMAPMetaDataMap meta_data_map[] = {
- {"dmap.itemid", ITEM_ID},
- {"dmap.itemname", ITEM_NAME},
- {"dmap.itemkind", ITEM_KIND},
- {"dmap.persistentid", PERSISTENT_ID},
- {"dmap.containeritemid", CONTAINER_ITEM_ID},
- {"daap.songalbum", SONG_ALBUM},
- {"daap.songartist", SONG_ARTIST},
- {"daap.songbitrate", SONG_BITRATE},
- {"daap.songbeatsperminute", SONG_BPM},
- {"daap.songcomment", SONG_COMMENT},
- {"daap.songcompilation", SONG_COMPILATION},
- {"daap.songcomposer", SONG_COMPOSER},
- {"daap.songdatakind", SONG_DATA_KIND},
- {"daap.songdataurl", SONG_DATA_URL},
- {"daap.songdateadded", SONG_DATE_ADDED},
- {"daap.songdatemodified", SONG_DATE_MODIFIED},
- {"daap.songdescription", SONG_DESCRIPTION},
- {"daap.songdisabled", SONG_DISABLED},
- {"daap.songdisccount", SONG_DISC_COUNT},
- {"daap.songdiscnumber", SONG_DISC_NUMBER},
- {"daap.songeqpreset", SONG_EQ_PRESET},
- {"daap.songformat", SONG_FORMAT},
- {"daap.songgenre", SONG_GENRE},
- {"daap.songgrouping", SONG_GROUPING},
- {"daap.songrelativevolume", SONG_RELATIVE_VOLUME},
- {"daap.songsamplerate", SONG_SAMPLE_RATE},
- {"daap.songsize", SONG_SIZE},
- {"daap.songstarttime", SONG_START_TIME},
- {"daap.songstoptime", SONG_STOP_TIME},
- {"daap.songtime", SONG_TIME},
- {"daap.songtrackcount", SONG_TRACK_COUNT},
- {"daap.songtracknumber", SONG_TRACK_NUMBER},
- {"daap.songuserrating", SONG_USER_RATING},
- {"daap.songyear", SONG_YEAR},
- {"daap.sortalbum", SONG_SORT_ALBUM},
- {"daap.sortartist", SONG_SORT_ARTIST},
- {"com.apple.itunes.has-video", SONG_HAS_VIDEO},
- {"com.apple.itunes.smart-playlist", SONG_SMART_PLAYLIST},
- {"com.apple.itunes.is-podcast-playlist", SONG_IS_PODCAST_PLAYLIST},
- {"com.apple.itunes.special-playlist", SONG_SPECIAL_PLAYLIST},
- {"com.apple.itunes.saved-genius", SONG_SAVED_GENIUS},
- {"com.apple.itunes.mediakind", SONG_MEDIAKIND},
- {"dmap.haschildcontainers", HAS_CHILD_CONTAINERS},
- {"dmap.parentcontainerid", PARENT_CONTAINER_ID},
- { NULL, 0}};
+ {"dmap.itemid", ITEM_ID},
+ {"dmap.itemname", ITEM_NAME},
+ {"dmap.itemkind", ITEM_KIND},
+ {"dmap.persistentid", PERSISTENT_ID},
+ {"dmap.containeritemid", CONTAINER_ITEM_ID},
+ {"daap.songalbum", SONG_ALBUM},
+ {"daap.songartist", SONG_ARTIST},
+ {"daap.songbitrate", SONG_BITRATE},
+ {"daap.songbeatsperminute", SONG_BPM},
+ {"daap.songcomment", SONG_COMMENT},
+ {"daap.songcompilation", SONG_COMPILATION},
+ {"daap.songcomposer", SONG_COMPOSER},
+ {"daap.songdatakind", SONG_DATA_KIND},
+ {"daap.songdataurl", SONG_DATA_URL},
+ {"daap.songdateadded", SONG_DATE_ADDED},
+ {"daap.songdatemodified", SONG_DATE_MODIFIED},
+ {"daap.songdescription", SONG_DESCRIPTION},
+ {"daap.songdisabled", SONG_DISABLED},
+ {"daap.songdisccount", SONG_DISC_COUNT},
+ {"daap.songdiscnumber", SONG_DISC_NUMBER},
+ {"daap.songeqpreset", SONG_EQ_PRESET},
+ {"daap.songformat", SONG_FORMAT},
+ {"daap.songgenre", SONG_GENRE},
+ {"daap.songgrouping", SONG_GROUPING},
+ {"daap.songrelativevolume", SONG_RELATIVE_VOLUME},
+ {"daap.songsamplerate", SONG_SAMPLE_RATE},
+ {"daap.songsize", SONG_SIZE},
+ {"daap.songstarttime", SONG_START_TIME},
+ {"daap.songstoptime", SONG_STOP_TIME},
+ {"daap.songtime", SONG_TIME},
+ {"daap.songtrackcount", SONG_TRACK_COUNT},
+ {"daap.songtracknumber", SONG_TRACK_NUMBER},
+ {"daap.songuserrating", SONG_USER_RATING},
+ {"daap.songyear", SONG_YEAR},
+ {"daap.sortalbum", SONG_SORT_ALBUM},
+ {"daap.sortartist", SONG_SORT_ARTIST},
+ {"com.apple.itunes.has-video", SONG_HAS_VIDEO},
+ {"com.apple.itunes.smart-playlist", SONG_SMART_PLAYLIST},
+ {"com.apple.itunes.is-podcast-playlist", SONG_IS_PODCAST_PLAYLIST},
+ {"com.apple.itunes.special-playlist", SONG_SPECIAL_PLAYLIST},
+ {"com.apple.itunes.saved-genius", SONG_SAVED_GENIUS},
+ {"com.apple.itunes.mediakind", SONG_MEDIAKIND},
+ {"dmap.haschildcontainers", HAS_CHILD_CONTAINERS},
+ {"dmap.parentcontainerid", PARENT_CONTAINER_ID},
+ {NULL, 0}
+};
#define DAAP_ITEM_KIND_AUDIO 2
#define DAAP_SONG_DATA_KIND_NONE 0
static void
-send_chunked_file (SoupServer *server, SoupMessage *message, DAAPRecord *record, guint64 filesize, guint64 offset, const gchar *transcode_mimetype)
+send_chunked_file (SoupServer * server, SoupMessage * message,
+ DAAPRecord * record, guint64 filesize, guint64 offset,
+ const gchar * transcode_mimetype)
{
gchar *format = NULL;
GInputStream *stream;
@@ -408,22 +409,27 @@ send_chunked_file (SoupServer *server, SoupMessage *message, DAAPRecord *record,
if (error != NULL) {
g_warning ("Couldn't open %s: %s.", location, error->message);
g_error_free (error);
- soup_message_set_status (message, SOUP_STATUS_INTERNAL_SERVER_ERROR);
+ soup_message_set_status (message,
+ SOUP_STATUS_INTERNAL_SERVER_ERROR);
g_free (cd);
return;
}
g_object_get (record, "format", &format, NULL);
- if (transcode_mimetype == NULL || ! strcmp (format, mime_to_format (transcode_mimetype))) {
+ if (transcode_mimetype == NULL
+ || !strcmp (format, mime_to_format (transcode_mimetype))) {
g_debug ("Not transcoding");
cd->stream = stream;
#ifdef HAVE_GSTREAMERAPP
} else {
- cd->stream = dmap_gst_input_stream_new (transcode_mimetype, stream);
+ cd->stream =
+ dmap_gst_input_stream_new (transcode_mimetype,
+ stream);
}
#else
} else {
- g_warning ("Transcode format %s not supported", transcode_mimetype);
+ g_warning ("Transcode format %s not supported",
+ transcode_mimetype);
cd->stream = stream;
}
#endif /* HAVE_GSTREAMERAPP */
@@ -435,13 +441,16 @@ send_chunked_file (SoupServer *server, SoupMessage *message, DAAPRecord *record,
}
if (offset != 0) {
- if (g_seekable_seek (G_SEEKABLE (cd->stream), offset, G_SEEK_SET, NULL, &error) == FALSE) {
+ if (g_seekable_seek
+ (G_SEEKABLE (cd->stream), offset, G_SEEK_SET, NULL,
+ &error) == FALSE) {
g_warning ("Error seeking: %s.", error->message);
g_input_stream_close (cd->stream, NULL, NULL);
- soup_message_set_status (message, SOUP_STATUS_INTERNAL_SERVER_ERROR);
+ soup_message_set_status (message,
+ SOUP_STATUS_INTERNAL_SERVER_ERROR);
g_free (cd);
return;
- }
+ }
filesize -= offset;
}
@@ -450,20 +459,22 @@ send_chunked_file (SoupServer *server, SoupMessage *message, DAAPRecord *record,
g_object_get (record, "has-video", &has_video, NULL);
if (has_video
- /* NOTE: iTunes seems to require this or it stops reading
- * video data after about 2.5MB. Perhaps this is so iTunes
- * knows how much data to buffer.
- */
+ /* NOTE: iTunes seems to require this or it stops reading
+ * video data after about 2.5MB. Perhaps this is so iTunes
+ * knows how much data to buffer.
+ */
|| transcode_mimetype == NULL) {
- /* NOTE: iTunes 8 (and other versions?) will not seek
+ /* NOTE: iTunes 8 (and other versions?) will not seek
* properly without a Content-Length header.
*/
g_debug ("Using HTTP 1.1 content length encoding.");
soup_message_headers_set_encoding (message->response_headers,
- SOUP_ENCODING_CONTENT_LENGTH);
- g_debug ("Content length is %" G_GUINT64_FORMAT ".", filesize);
- soup_message_headers_set_content_length (
- message->response_headers, filesize);
+ SOUP_ENCODING_CONTENT_LENGTH);
+ g_debug ("Content length is %" G_GUINT64_FORMAT ".",
+ filesize);
+ soup_message_headers_set_content_length (message->
+ response_headers,
+ filesize);
} else if (soup_message_get_http_version (message) == SOUP_HTTP_1_0) {
/* NOTE: Roku clients support only HTTP 1.0. */
#ifdef HAVE_ENCODING_EOF
@@ -471,7 +482,8 @@ send_chunked_file (SoupServer *server, SoupMessage *message, DAAPRecord *record,
soup_message_headers_set_encoding (message->response_headers,
SOUP_ENCODING_EOF);
#else
- g_warning ("Received HTTP 1.0 request, but not built with HTTP 1.0 support");
+ g_warning
+ ("Received HTTP 1.0 request, but not built with HTTP 1.0 support");
soup_message_headers_set_encoding (message->response_headers,
SOUP_ENCODING_CHUNKED);
#endif
@@ -484,30 +496,38 @@ send_chunked_file (SoupServer *server, SoupMessage *message, DAAPRecord *record,
SOUP_ENCODING_CHUNKED);
}
- soup_message_headers_append (message->response_headers, "Connection", "Close");
- soup_message_headers_append (message->response_headers, "Content-Type", "application/x-dmap-tagged");
-
- g_signal_connect (message, "wrote_headers", G_CALLBACK (dmap_write_next_chunk), cd);
- g_signal_connect (message, "wrote_chunk", G_CALLBACK (dmap_write_next_chunk), cd);
- g_signal_connect (message, "finished", G_CALLBACK (dmap_chunked_message_finished), cd);
+ soup_message_headers_append (message->response_headers, "Connection",
+ "Close");
+ soup_message_headers_append (message->response_headers,
+ "Content-Type",
+ "application/x-dmap-tagged");
+
+ g_signal_connect (message, "wrote_headers",
+ G_CALLBACK (dmap_write_next_chunk), cd);
+ g_signal_connect (message, "wrote_chunk",
+ G_CALLBACK (dmap_write_next_chunk), cd);
+ g_signal_connect (message, "finished",
+ G_CALLBACK (dmap_chunked_message_finished), cd);
/* NOTE: cd g_free'd by chunked_message_finished(). */
}
static void
-add_entry_to_mlcl (gpointer id,
- DMAPRecord *record,
- gpointer _mb)
+add_entry_to_mlcl (gpointer id, DMAPRecord * record, gpointer _mb)
{
GNode *mlit;
struct MLCL_Bits *mb = (struct MLCL_Bits *) _mb;
+
mlit = dmap_structure_add (mb->mlcl, DMAP_CC_MLIT);
if (_dmap_share_client_requested (mb->bits, ITEM_KIND))
- dmap_structure_add (mlit, DMAP_CC_MIKD, (gchar) DAAP_ITEM_KIND_AUDIO);
+ dmap_structure_add (mlit, DMAP_CC_MIKD,
+ (gchar) DAAP_ITEM_KIND_AUDIO);
if (_dmap_share_client_requested (mb->bits, ITEM_ID))
- dmap_structure_add (mlit, DMAP_CC_MIID, GPOINTER_TO_UINT (id));
+ dmap_structure_add (mlit, DMAP_CC_MIID,
+ GPOINTER_TO_UINT (id));
if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) {
gchar *title = NULL;
+
g_object_get (record, "title", &title, NULL);
if (title) {
dmap_structure_add (mlit, DMAP_CC_MINM, title);
@@ -516,17 +536,21 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Title requested but not available");
}
if (_dmap_share_client_requested (mb->bits, PERSISTENT_ID))
- dmap_structure_add (mlit, DMAP_CC_MPER, GPOINTER_TO_UINT (id));
+ dmap_structure_add (mlit, DMAP_CC_MPER,
+ GPOINTER_TO_UINT (id));
if (_dmap_share_client_requested (mb->bits, CONTAINER_ITEM_ID))
- dmap_structure_add (mlit, DMAP_CC_MCTI, GPOINTER_TO_UINT (id));
+ dmap_structure_add (mlit, DMAP_CC_MCTI,
+ GPOINTER_TO_UINT (id));
if (_dmap_share_client_requested (mb->bits, SONG_DATA_KIND))
- dmap_structure_add (mlit, DMAP_CC_ASDK, (gchar) DAAP_SONG_DATA_KIND_NONE);
+ dmap_structure_add (mlit, DMAP_CC_ASDK,
+ (gchar) DAAP_SONG_DATA_KIND_NONE);
/* FIXME: Any use for this?
- if (_dmap_share_client_requested (mb->bits, SONG_DATA_URL))
- dmap_structure_add (mlit, DMAP_CC_ASUL, "daap://192.168.0.100:%u/databases/1/items/%d.%s?session-id=%s", data->port, *id, daap_record_get_format (DAAP_RECORD (record)), data->session_id);
- */
+ * if (_dmap_share_client_requested (mb->bits, SONG_DATA_URL))
+ * dmap_structure_add (mlit, DMAP_CC_ASUL, "daap://192.168.0.100:%u/databases/1/items/%d.%s?session-id=%s", data->port, *id, daap_record_get_format (DAAP_RECORD (record)), data->session_id);
+ */
if (_dmap_share_client_requested (mb->bits, SONG_ALBUM)) {
gchar *album = NULL;
+
g_object_get (record, "songalbum", &album, NULL);
if (album) {
dmap_structure_add (mlit, DMAP_CC_ASAL, album);
@@ -538,6 +562,7 @@ add_entry_to_mlcl (gpointer id,
dmap_structure_add (mlit, DMAP_CC_AGRP, "");
if (_dmap_share_client_requested (mb->bits, SONG_ARTIST)) {
gchar *artist = NULL;
+
g_object_get (record, "songartist", &artist, NULL);
if (artist) {
dmap_structure_add (mlit, DMAP_CC_ASAR, artist);
@@ -547,9 +572,11 @@ add_entry_to_mlcl (gpointer id,
}
if (_dmap_share_client_requested (mb->bits, SONG_BITRATE)) {
gint32 bitrate = 0;
+
g_object_get (record, "bitrate", &bitrate, NULL);
if (bitrate != 0)
- dmap_structure_add (mlit, DMAP_CC_ASBR, (gint32) bitrate);
+ dmap_structure_add (mlit, DMAP_CC_ASBR,
+ (gint32) bitrate);
}
if (_dmap_share_client_requested (mb->bits, SONG_BPM))
dmap_structure_add (mlit, DMAP_CC_ASBT, (gint32) 0);
@@ -561,11 +588,13 @@ add_entry_to_mlcl (gpointer id,
dmap_structure_add (mlit, DMAP_CC_ASCP, "");
if (_dmap_share_client_requested (mb->bits, SONG_DATE_ADDED)) {
gint32 firstseen = 0;
+
g_object_get (record, "firstseen", &firstseen, NULL);
dmap_structure_add (mlit, DMAP_CC_ASDA, firstseen);
}
if (_dmap_share_client_requested (mb->bits, SONG_DATE_MODIFIED)) {
gint32 mtime = 0;
+
g_object_get (record, "mtime", &mtime, NULL);
dmap_structure_add (mlit, DMAP_CC_ASDM, mtime);
}
@@ -573,6 +602,7 @@ add_entry_to_mlcl (gpointer id,
dmap_structure_add (mlit, DMAP_CC_ASDC, (gint32) 0);
if (_dmap_share_client_requested (mb->bits, SONG_DISC_NUMBER)) {
gint32 disc = 0;
+
g_object_get (record, "disc", &disc, NULL);
dmap_structure_add (mlit, DMAP_CC_ASDN, disc);
}
@@ -583,10 +613,13 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_FORMAT)) {
gchar *format = NULL;
gchar *transcode_mimetype = NULL;
+
/* FIXME: This should be share, not record: */
- g_object_get (record, "transcode-mimetype", &transcode_mimetype, NULL);
+ g_object_get (record, "transcode-mimetype",
+ &transcode_mimetype, NULL);
if (transcode_mimetype) {
- format = g_strdup (mime_to_format (transcode_mimetype));
+ format = g_strdup (mime_to_format
+ (transcode_mimetype));
g_free (transcode_mimetype);
} else {
g_object_get (record, "format", &format, NULL);
@@ -599,6 +632,7 @@ add_entry_to_mlcl (gpointer id,
}
if (_dmap_share_client_requested (mb->bits, SONG_GENRE)) {
gchar *genre = NULL;
+
g_object_get (record, "songgenre", &genre, NULL);
if (genre) {
dmap_structure_add (mlit, DMAP_CC_ASGN, genre);
@@ -607,13 +641,14 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Genre requested but not available");
}
if (_dmap_share_client_requested (mb->bits, SONG_DESCRIPTION))
- dmap_structure_add (mlit, DMAP_CC_ASDT, ""); /* FIXME: e.g., wav audio file */
+ dmap_structure_add (mlit, DMAP_CC_ASDT, ""); /* FIXME: e.g., wav audio file */
if (_dmap_share_client_requested (mb->bits, SONG_RELATIVE_VOLUME))
dmap_structure_add (mlit, DMAP_CC_ASRV, 0);
if (_dmap_share_client_requested (mb->bits, SONG_SAMPLE_RATE))
dmap_structure_add (mlit, DMAP_CC_ASSR, 0);
if (_dmap_share_client_requested (mb->bits, SONG_SIZE)) {
guint64 filesize = 0;
+
g_object_get (record, "filesize", &filesize, NULL);
dmap_structure_add (mlit, DMAP_CC_ASSZ, (gint32) filesize);
}
@@ -623,6 +658,7 @@ add_entry_to_mlcl (gpointer id,
dmap_structure_add (mlit, DMAP_CC_ASSP, 0);
if (_dmap_share_client_requested (mb->bits, SONG_TIME)) {
gint32 duration;
+
g_object_get (record, "duration", &duration, NULL);
dmap_structure_add (mlit, DMAP_CC_ASTM, (1000 * duration));
}
@@ -630,26 +666,31 @@ add_entry_to_mlcl (gpointer id,
dmap_structure_add (mlit, DMAP_CC_ASTC, 0);
if (_dmap_share_client_requested (mb->bits, SONG_TRACK_NUMBER)) {
gint32 track = 0;
+
g_object_get (record, "track", &track, NULL);
dmap_structure_add (mlit, DMAP_CC_ASTN, track);
}
if (_dmap_share_client_requested (mb->bits, SONG_USER_RATING)) {
gint32 rating = 0;
+
g_object_get (record, "rating", &rating, NULL);
dmap_structure_add (mlit, DMAP_CC_ASUR, rating);
}
if (_dmap_share_client_requested (mb->bits, SONG_YEAR)) {
gint32 year = 0;
+
g_object_get (record, "year", &year, NULL);
dmap_structure_add (mlit, DMAP_CC_ASYR, year);
}
if (_dmap_share_client_requested (mb->bits, SONG_HAS_VIDEO)) {
gboolean has_video = 0;
+
g_object_get (record, "has-video", &has_video, NULL);
dmap_structure_add (mlit, DMAP_CC_AEHV, has_video);
}
if (_dmap_share_client_requested (mb->bits, SONG_SORT_ARTIST)) {
gchar *sort_artist = NULL;
+
g_object_get (record, "sort-artist", &sort_artist, NULL);
if (sort_artist) {
dmap_structure_add (mlit, DMAP_CC_ASSA, sort_artist);
@@ -660,6 +701,7 @@ add_entry_to_mlcl (gpointer id,
}
if (_dmap_share_client_requested (mb->bits, SONG_SORT_ALBUM)) {
gchar *sort_album = NULL;
+
g_object_get (record, "sort-album", &sort_album, NULL);
if (sort_album) {
dmap_structure_add (mlit, DMAP_CC_ASSU, sort_album);
@@ -670,41 +712,45 @@ add_entry_to_mlcl (gpointer id,
}
if (_dmap_share_client_requested (mb->bits, SONG_MEDIAKIND)) {
gint mediakind = 0;
+
g_object_get (record, "mediakind", &mediakind, NULL);
dmap_structure_add (mlit, DMAP_CC_AEMK, mediakind);
}
}
static void
-genre_tabulator (gpointer id, DMAPRecord *record, GHashTable *ht)
+genre_tabulator (gpointer id, DMAPRecord * record, GHashTable * ht)
{
const gchar *genre;
+
g_object_get (record, "songgenre", &genre, NULL);
if (!genre)
return;
- if (! g_hash_table_lookup (ht, genre))
+ if (!g_hash_table_lookup (ht, genre))
g_hash_table_insert (ht, (gchar *) genre, NULL);
}
static void
-artist_tabulator (gpointer id, DMAPRecord *record, GHashTable *ht)
+artist_tabulator (gpointer id, DMAPRecord * record, GHashTable * ht)
{
const gchar *artist;
+
g_object_get (record, "songartist", &artist, NULL);
if (!artist)
return;
- if (! g_hash_table_lookup (ht, artist))
+ if (!g_hash_table_lookup (ht, artist))
g_hash_table_insert (ht, (gchar *) artist, NULL);
}
static void
-album_tabulator (gpointer id, DMAPRecord *record, GHashTable *ht)
+album_tabulator (gpointer id, DMAPRecord * record, GHashTable * ht)
{
const gchar *album;
+
g_object_get (record, "songalbum", &album, NULL);
if (!album)
return;
- if (! g_hash_table_lookup (ht, album))
+ if (!g_hash_table_lookup (ht, album))
g_hash_table_insert (ht, (gchar *) album, NULL);
}
@@ -719,22 +765,21 @@ add_to_category_listing (gpointer key, gpointer user_data)
}
static void
-databases_browse_xxx (DMAPShare *share,
- SoupServer *server,
- SoupMessage *msg,
+databases_browse_xxx (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * msg,
const char *path,
- GHashTable *query,
- SoupClientContext *context)
+ GHashTable * query, SoupClientContext * context)
{
/* ABRO database browse
- * MSTT status
- * MUTY update type
- * MTCO specified total count
- * MRCO returned count
- * ABGN genre listing
- * MLIT listing item
- * ...
- */
+ * MSTT status
+ * MUTY update type
+ * MTCO specified total count
+ * MRCO returned count
+ * ABGN genre listing
+ * MLIT listing item
+ * ...
+ */
DMAPDb *db;
const gchar *rest_of_path;
GNode *abro, *node;
@@ -757,13 +802,16 @@ databases_browse_xxx (DMAPShare *share,
filtered = dmap_db_apply_filter (db, filter_def);
if (g_ascii_strcasecmp (browse_category, "genres") == 0) {
- g_hash_table_foreach (filtered, (GHFunc) genre_tabulator, category_items);
+ g_hash_table_foreach (filtered, (GHFunc) genre_tabulator,
+ category_items);
category_cc = DMAP_CC_ABGN;
} else if (g_ascii_strcasecmp (browse_category, "artists") == 0) {
- g_hash_table_foreach (filtered, (GHFunc) artist_tabulator, category_items);
+ g_hash_table_foreach (filtered, (GHFunc) artist_tabulator,
+ category_items);
category_cc = DMAP_CC_ABAR;
} else if (g_ascii_strcasecmp (browse_category, "albums") == 0) {
- g_hash_table_foreach (filtered, (GHFunc) album_tabulator, category_items);
+ g_hash_table_foreach (filtered, (GHFunc) album_tabulator,
+ category_items);
category_cc = DMAP_CC_ABAL;
} else {
g_warning ("Unsupported browse category: %s",
@@ -784,16 +832,17 @@ databases_browse_xxx (DMAPShare *share,
values = g_hash_table_get_keys (category_items);
if (values && g_hash_table_lookup (query, "include-sort-headers")) {
g_debug ("Sorting...");
- values = g_list_sort (values, (GCompareFunc) g_ascii_strcasecmp);
+ values = g_list_sort (values,
+ (GCompareFunc) g_ascii_strcasecmp);
}
g_list_foreach (values, add_to_category_listing, node);
-
+
g_list_free (values);
_dmap_share_message_set_from_dmap_structure (share, msg, abro);
dmap_structure_destroy (abro);
-_bad_category:
+ _bad_category:
dmap_share_free_filter (filter_def);
/* Free's hash table but not data (points into real DB): */
g_hash_table_destroy (filtered);
@@ -801,12 +850,11 @@ _bad_category:
}
static void
-databases_items_xxx (DMAPShare *share,
- SoupServer *server,
- SoupMessage *msg,
+databases_items_xxx (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * msg,
const char *path,
- GHashTable *query,
- SoupClientContext *context)
+ GHashTable * query, SoupClientContext * context)
{
DMAPDb *db;
const gchar *transcode_mimetype;
@@ -827,19 +875,26 @@ databases_items_xxx (DMAPShare *share,
g_object_get (record, "filesize", &filesize, NULL);
DMAP_SHARE_GET_CLASS (share)->message_add_standard_headers
- (share, msg);
- soup_message_headers_append (msg->response_headers, "Accept-Ranges", "bytes");
+ (share, msg);
+ soup_message_headers_append (msg->response_headers, "Accept-Ranges",
+ "bytes");
- range_header = soup_message_headers_get (msg->request_headers, "Range");
+ range_header =
+ soup_message_headers_get (msg->request_headers, "Range");
if (range_header) {
const gchar *s;
gchar *content_range;
- s = range_header + 6; /* bytes= */
+ s = range_header + 6; /* bytes= */
offset = atoll (s);
- content_range = g_strdup_printf ("bytes %" G_GUINT64_FORMAT "-%" G_GUINT64_FORMAT "/%" G_GUINT64_FORMAT, offset, filesize, filesize);
- soup_message_headers_append (msg->response_headers, "Content-Range", content_range);
+ content_range =
+ g_strdup_printf ("bytes %" G_GUINT64_FORMAT "-%"
+ G_GUINT64_FORMAT "/%"
+ G_GUINT64_FORMAT, offset, filesize,
+ filesize);
+ soup_message_headers_append (msg->response_headers,
+ "Content-Range", content_range);
g_debug ("Content range is %s.", content_range);
g_free (content_range);
soup_message_set_status (msg, SOUP_STATUS_PARTIAL_CONTENT);
@@ -847,13 +902,14 @@ databases_items_xxx (DMAPShare *share,
soup_message_set_status (msg, SOUP_STATUS_OK);
}
g_object_get (share, "transcode-mimetype", &transcode_mimetype, NULL);
- send_chunked_file (server, msg, record, filesize, offset, transcode_mimetype);
-
+ send_chunked_file (server, msg, record, filesize, offset,
+ transcode_mimetype);
+
g_object_unref (record);
}
static struct DMAPMetaDataMap *
-get_meta_data_map (DMAPShare *share)
+get_meta_data_map (DMAPShare * share)
{
return meta_data_map;
}
diff --git a/libdmapsharing/daap-share.h b/libdmapsharing/daap-share.h
index 7b09d15..50d0d2d 100644
--- a/libdmapsharing/daap-share.h
+++ b/libdmapsharing/daap-share.h
@@ -31,7 +31,6 @@
#include <libdmapsharing/dmap-container-db.h>
G_BEGIN_DECLS
-
/**
* DAAP_TYPE_SHARE:
*
@@ -83,19 +82,20 @@ G_BEGIN_DECLS
*/
#define DAAP_SHARE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
DAAP_TYPE_SHARE, DAAPShareClass))
-
typedef struct DAAPSharePrivate DAAPSharePrivate;
-typedef struct {
+typedef struct
+{
DMAPShareClass dmap_share_class;
} DAAPShareClass;
-typedef struct {
+typedef struct
+{
DMAPShare dmap_share_instance;
DAAPSharePrivate *priv;
} DAAPShare;
-GType daap_share_get_type (void);
+GType daap_share_get_type (void);
/**
* daap_share_new:
@@ -109,9 +109,9 @@ GType daap_share_get_type (void);
*
* Returns: a pointer to a DAAPShare.
*/
-DAAPShare *daap_share_new (const char *name, const char *password,
- DMAPDb *db, DMAPContainerDb *container_db,
- gchar *transcode_mimetype);
+DAAPShare *daap_share_new (const char *name, const char *password,
+ DMAPDb * db, DMAPContainerDb * container_db,
+ gchar * transcode_mimetype);
#endif /* __DAAP_SHARE_H */
diff --git a/libdmapsharing/dacp-connection.c b/libdmapsharing/dacp-connection.c
index d1989e5..92f0c99 100644
--- a/libdmapsharing/dacp-connection.c
+++ b/libdmapsharing/dacp-connection.c
@@ -31,7 +31,7 @@ struct DACPConnectionPrivate {
*/
static DMAPContentCode
-get_protocol_version_cc (DMAPConnection *connection)
+get_protocol_version_cc (DMAPConnection * connection)
{
/* FIXME: */
g_error ("Not implemented");
@@ -45,55 +45,54 @@ get_query_metadata (void)
}
static DMAPRecord *
-handle_mlcl (DMAPConnection *connection, DMAPRecordFactory *factory, GNode *n, int *item_id)
+handle_mlcl (DMAPConnection * connection, DMAPRecordFactory * factory,
+ GNode * n, int *item_id)
{
/* FIXME: */
g_error ("Not implemented");
}
static void
-dacp_connection_class_init (DACPConnectionClass *klass)
+dacp_connection_class_init (DACPConnectionClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- DMAPConnectionClass *parent_class = DMAP_CONNECTION_CLASS (object_class);
+ DMAPConnectionClass *parent_class =
+ DMAP_CONNECTION_CLASS (object_class);
parent_class->get_protocol_version_cc = get_protocol_version_cc;
parent_class->get_query_metadata = get_query_metadata;
parent_class->handle_mlcl = handle_mlcl;
/* FIXME:
- g_type_class_add_private (klass, sizeof (DACPConnectionPrivate));
- */
+ * g_type_class_add_private (klass, sizeof (DACPConnectionPrivate));
+ */
}
DACPConnection *
-dacp_connection_new (const char *name,
- const char *host,
- guint port,
- gboolean password_protected,
- DMAPDb *db,
- DMAPRecordFactory *factory)
+dacp_connection_new (const char *name,
+ const char *host,
+ guint port,
+ gboolean password_protected,
+ DMAPDb * db, DMAPRecordFactory * factory)
{
DACPConnection *connection;
-
+
connection = g_object_new (DACP_TYPE_CONNECTION,
- "name", name,
- "password-protected", password_protected,
- "db", db,
- "host", host,
- "port", port,
- "factory", factory,
- NULL);
+ "name", name,
+ "password-protected", password_protected,
+ "db", db,
+ "host", host,
+ "port", port, "factory", factory, NULL);
return connection;
}
static void
-dacp_connection_init (DACPConnection *connection)
+dacp_connection_init (DACPConnection * connection)
{
/* FIXME:
- connection->priv = DACP_CONNECTION_GET_PRIVATE (connection);
- */
+ * connection->priv = DACP_CONNECTION_GET_PRIVATE (connection);
+ */
}
G_DEFINE_TYPE (DACPConnection, dacp_connection, DMAP_TYPE_CONNECTION)
diff --git a/libdmapsharing/dacp-connection.h b/libdmapsharing/dacp-connection.h
index cc5a17a..59691a1 100644
--- a/libdmapsharing/dacp-connection.h
+++ b/libdmapsharing/dacp-connection.h
@@ -23,7 +23,6 @@
#include <libdmapsharing/dmap-db.h>
G_BEGIN_DECLS
-
/**
* DACP_TYPE_CONNECTION:
*
@@ -71,26 +70,26 @@ G_BEGIN_DECLS
* Returns: pointer to object class structure.
*/
#define DACP_CONNECTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DACP_TYPE_CONNECTION, DACPConnectionClass))
-
typedef struct DACPConnectionPrivate DACPConnectionPrivate;
-typedef struct {
+typedef struct
+{
DMAPConnectionClass dmap_connection_class;
} DACPConnectionClass;
-typedef struct {
+typedef struct
+{
DMAPConnection dmap_connection_instance;
DACPConnectionPrivate *priv;
} DACPConnection;
-GType dacp_connection_get_type (void);
+GType dacp_connection_get_type (void);
-DACPConnection * dacp_connection_new (const char *name,
- const char *host,
- guint port,
- gboolean password_protected,
- DMAPDb *db,
- DMAPRecordFactory *factory);
+DACPConnection *dacp_connection_new (const char *name,
+ const char *host,
+ guint port,
+ gboolean password_protected,
+ DMAPDb * db,
+ DMAPRecordFactory * factory);
G_END_DECLS
-
#endif /* __DACP_CONNECTION_H */
diff --git a/libdmapsharing/dacp-player.c b/libdmapsharing/dacp-player.c
index 1cc0a69..1a8bed5 100644
--- a/libdmapsharing/dacp-player.c
+++ b/libdmapsharing/dacp-player.c
@@ -20,7 +20,7 @@
#include <libdmapsharing/daap-record.h>
static void
-dacp_player_init (DACPPlayerIface *iface)
+dacp_player_init (DACPPlayerIface * iface)
{
static gboolean initialized = FALSE;
@@ -28,50 +28,48 @@ dacp_player_init (DACPPlayerIface *iface)
initialized = TRUE;
g_object_interface_install_property (iface,
- g_param_spec_ulong ("playing-time",
- "Playing time",
- "Playing time (ms)",
- 0,
- G_MAXULONG,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_ulong
+ ("playing-time",
+ "Playing time",
+ "Playing time (ms)", 0,
+ G_MAXULONG, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_boolean ("shuffle-state",
- "Shuffle state",
- "Shufle state",
- FALSE,
- G_PARAM_READWRITE));
+ g_param_spec_boolean
+ ("shuffle-state",
+ "Shuffle state",
+ "Shufle state", FALSE,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_enum ("repeat-state",
- "Repeat state",
- "Repeat state",
- DMAP_TYPE_DACP_REPEAT_STATE,
- REPEAT_NONE,
- G_PARAM_READWRITE));
+ g_param_spec_enum
+ ("repeat-state",
+ "Repeat state",
+ "Repeat state",
+ DMAP_TYPE_DACP_REPEAT_STATE,
+ REPEAT_NONE,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_enum ("play-state",
- "Play state",
- "Play state",
- DMAP_TYPE_DACP_PLAY_STATE,
- PLAY_STOPPED,
- G_PARAM_READWRITE));
-
+ g_param_spec_enum
+ ("play-state",
+ "Play state",
+ "Play state",
+ DMAP_TYPE_DACP_PLAY_STATE,
+ PLAY_STOPPED,
+ G_PARAM_READWRITE));
+
g_object_interface_install_property (iface,
- g_param_spec_ulong ("volume",
- "Volume",
- "Volume",
- 0,
- 100,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_ulong
+ ("volume", "Volume",
+ "Volume", 0, 100, 0,
+ G_PARAM_READWRITE));
}
}
static void
-dacp_player_finalize (DACPPlayerIface *iface)
+dacp_player_finalize (DACPPlayerIface * iface)
{
}
@@ -79,65 +77,69 @@ GType
dacp_player_get_type (void)
{
static GType object_type = 0;
+
if (!object_type) {
static const GTypeInfo object_info = {
- sizeof(DACPPlayerIface),
+ sizeof (DACPPlayerIface),
(GBaseInitFunc) dacp_player_init,
(GBaseFinalizeFunc) dacp_player_finalize
};
- object_type = g_type_register_static(G_TYPE_INTERFACE,
- "DACPPlayer",
- &object_info, 0);
- g_type_interface_add_prerequisite (object_type, G_TYPE_OBJECT);
+ object_type = g_type_register_static (G_TYPE_INTERFACE,
+ "DACPPlayer",
+ &object_info, 0);
+ g_type_interface_add_prerequisite (object_type,
+ G_TYPE_OBJECT);
}
return object_type;
}
DAAPRecord *
-dacp_player_now_playing_record (DACPPlayer *player)
+dacp_player_now_playing_record (DACPPlayer * player)
{
- return DACP_PLAYER_GET_INTERFACE (player)->now_playing_record (player);
+ return DACP_PLAYER_GET_INTERFACE (player)->
+ now_playing_record (player);
}
const guchar *
-dacp_player_now_playing_artwork (DACPPlayer *player, guint width, guint height)
+dacp_player_now_playing_artwork (DACPPlayer * player, guint width,
+ guint height)
{
- return DACP_PLAYER_GET_INTERFACE (player)->now_playing_artwork (player, width, height);
+ return DACP_PLAYER_GET_INTERFACE (player)->
+ now_playing_artwork (player, width, height);
}
-void
-dacp_player_play_pause (DACPPlayer *player)
+void
+dacp_player_play_pause (DACPPlayer * player)
{
DACP_PLAYER_GET_INTERFACE (player)->play_pause (player);
}
-
-void
-dacp_player_pause (DACPPlayer *player)
+void
+dacp_player_pause (DACPPlayer * player)
{
DACP_PLAYER_GET_INTERFACE (player)->pause (player);
}
-void
-dacp_player_next_item (DACPPlayer *player)
+void
+dacp_player_next_item (DACPPlayer * player)
{
DACP_PLAYER_GET_INTERFACE (player)->next_item (player);
}
-void
-dacp_player_prev_item (DACPPlayer *player)
+void
+dacp_player_prev_item (DACPPlayer * player)
{
DACP_PLAYER_GET_INTERFACE (player)->prev_item (player);
}
-void
-dacp_player_cue_clear (DACPPlayer *player)
+void
+dacp_player_cue_clear (DACPPlayer * player)
{
DACP_PLAYER_GET_INTERFACE (player)->cue_clear (player);
}
-void
-dacp_player_cue_play (DACPPlayer *player, GList *records, guint index)
+void
+dacp_player_cue_play (DACPPlayer * player, GList * records, guint index)
{
DACP_PLAYER_GET_INTERFACE (player)->cue_play (player, records, index);
}
diff --git a/libdmapsharing/dacp-player.h b/libdmapsharing/dacp-player.h
index 61b39b7..2b7ddcd 100644
--- a/libdmapsharing/dacp-player.h
+++ b/libdmapsharing/dacp-player.h
@@ -23,14 +23,12 @@
#include "daap-record.h"
G_BEGIN_DECLS
-
/**
* DACP_TYPE_PLAYER:
*
* The type for #DACPPlayer.
*/
#define DACP_TYPE_PLAYER (dacp_player_get_type ())
-
/**
* DACP_PLAYER:
* @o: Object which is subject to casting.
@@ -40,7 +38,6 @@ G_BEGIN_DECLS
* certain runtime checks to identify invalid casts.
*/
#define DACP_PLAYER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DACP_TYPE_PLAYER, DACPPlayer))
-
/**
* IS_DACP_PLAYER:
* @o: Instance to check for being a %DACP_TYPE_PLAYER.
@@ -48,7 +45,6 @@ G_BEGIN_DECLS
* Checks whether a valid #GTypeInstance pointer is of type %DACP_TYPE_PLAYER.
*/
#define IS_DACP_PLAYER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DACP_TYPE_PLAYER))
-
/**
* DACP_PLAYER_GET_INTERFACE:
* @o: a #DACPPlayer instance.
@@ -59,17 +55,18 @@ G_BEGIN_DECLS
*/
#define DACP_PLAYER_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), \
DACP_TYPE_PLAYER, DACPPlayerIface))
-
typedef struct _DACPPlayerIface DACPPlayerIface;
typedef struct _DACPPlayer DACPPlayer;
-typedef enum {
+typedef enum
+{
REPEAT_NONE = 0,
REPEAT_SINGLE = 1,
REPEAT_ALL = 2
} DACPRepeatState;
-typedef enum {
+typedef enum
+{
PLAY_STOPPED = 2,
PLAY_PAUSED = 3,
PLAY_PLAYING = 4
@@ -79,15 +76,16 @@ struct _DACPPlayerIface
{
GTypeInterface parent_class;
- DAAPRecord *(*now_playing_record) (DACPPlayer *player);
- const guchar *(*now_playing_artwork) (DACPPlayer *player, guint width, guint height);
- void (*play_pause) (DACPPlayer *player);
- void (*pause) (DACPPlayer *player);
- void (*next_item) (DACPPlayer *player);
- void (*prev_item) (DACPPlayer *player);
+ DAAPRecord *(*now_playing_record) (DACPPlayer * player);
+ const guchar *(*now_playing_artwork) (DACPPlayer * player,
+ guint width, guint height);
+ void (*play_pause) (DACPPlayer * player);
+ void (*pause) (DACPPlayer * player);
+ void (*next_item) (DACPPlayer * player);
+ void (*prev_item) (DACPPlayer * player);
- void (*cue_clear) (DACPPlayer *player);
- void (*cue_play) (DACPPlayer *player, GList *records, guint index);
+ void (*cue_clear) (DACPPlayer * player);
+ void (*cue_play) (DACPPlayer * player, GList * records, guint index);
};
GType dacp_player_get_type (void);
@@ -96,7 +94,7 @@ GType dacp_player_get_type (void);
* dacp_player_now_playing_record
* @player: a player
*/
-DAAPRecord *dacp_player_now_playing_record (DACPPlayer *player);
+DAAPRecord *dacp_player_now_playing_record (DACPPlayer * player);
/**
* dacp_player_now_playing_artwork
@@ -104,37 +102,38 @@ DAAPRecord *dacp_player_now_playing_record (DACPPlayer *player);
* @width: width
* @height: height
*/
-const guchar *dacp_player_now_playing_artwork (DACPPlayer *player, guint width, guint height);
+const guchar *dacp_player_now_playing_artwork (DACPPlayer * player,
+ guint width, guint height);
/**
* dacp_player_play_pause
* @player: a player
*/
-void dacp_player_play_pause (DACPPlayer *player);
+void dacp_player_play_pause (DACPPlayer * player);
/**
* dacp_player_pause
* @player: a player
*/
-void dacp_player_pause (DACPPlayer *player);
+void dacp_player_pause (DACPPlayer * player);
/**
* dacp_player_next_item
* @player: a player
*/
-void dacp_player_next_item (DACPPlayer *player);
+void dacp_player_next_item (DACPPlayer * player);
/**
* dacp_player_now_prev_item
* @player: a player
*/
-void dacp_player_prev_item (DACPPlayer *player);
+void dacp_player_prev_item (DACPPlayer * player);
/**
* dacp_player_cue_clear
* @player: a player
*/
-void dacp_player_cue_clear (DACPPlayer *player);
+void dacp_player_cue_clear (DACPPlayer * player);
/**
* dacp_player_cue_play
@@ -142,8 +141,7 @@ void dacp_player_cue_clear (DACPPlayer *player);
* @records : a list of records
* @index: an index
*/
-void dacp_player_cue_play (DACPPlayer *player, GList *records, guint index);
+void dacp_player_cue_play (DACPPlayer * player, GList * records, guint index);
G_END_DECLS
-
#endif /* _DACP_PLAYER_H_ */
diff --git a/libdmapsharing/dacp-share.c b/libdmapsharing/dacp-share.c
index bea225b..7c945e9 100644
--- a/libdmapsharing/dacp-share.c
+++ b/libdmapsharing/dacp-share.c
@@ -45,37 +45,37 @@
#include <libdmapsharing/dacp-share.h>
#include <libdmapsharing/dacp-player.h>
-static void dacp_share_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void dacp_share_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void dacp_share_dispose (GObject *object);
-const char *dacp_share_get_type_of_service (DMAPShare *share);
-void dacp_share_ctrl_int (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
-void dacp_share_login (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
-
-static gchar *dacp_share_pairing_code(DACPShare *share, gchar* pair_txt, gchar passcode[4]);
-static void dacp_share_send_playstatusupdate (DACPShare *share);
-static void dacp_share_fill_playstatusupdate (DACPShare *share, SoupMessage *message);
+static void dacp_share_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec);
+static void dacp_share_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void dacp_share_dispose (GObject * object);
+const char *dacp_share_get_type_of_service (DMAPShare * share);
+void dacp_share_ctrl_int (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context);
+void dacp_share_login (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context);
+
+static gchar *dacp_share_pairing_code (DACPShare * share, gchar * pair_txt,
+ gchar passcode[4]);
+static void dacp_share_send_playstatusupdate (DACPShare * share);
+static void dacp_share_fill_playstatusupdate (DACPShare * share,
+ SoupMessage * message);
#define DACP_TYPE_OF_SERVICE "_touch-able._tcp"
#define DACP_PORT 3689
-struct DACPSharePrivate {
+struct DACPSharePrivate
+{
DMAPMdnsBrowser *mdns_browser;
gchar *library_name;
@@ -91,7 +91,8 @@ struct DACPSharePrivate {
/*
* Internal representation of a DACP remote.
*/
-typedef struct {
+typedef struct
+{
gchar *host;
guint port;
gchar *pair_txt;
@@ -100,13 +101,15 @@ typedef struct {
#define DACP_SHARE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DACP_TYPE_SHARE, DACPSharePrivate))
-enum {
+enum
+{
PROP_0,
PROP_LIBRARY_NAME,
PROP_PLAYER
};
-enum {
+enum
+{
REMOTE_FOUND,
REMOTE_LOST,
REMOTE_PAIRED,
@@ -117,12 +120,11 @@ enum {
LAST_SIGNAL
};
-static guint signals [LAST_SIGNAL] = { 0, };
+static guint signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (DACPShare, dacp_share, DAAP_TYPE_SHARE)
-static void
-dacp_share_class_init (DACPShareClass *klass)
+ static void dacp_share_class_init (DACPShareClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
DMAPShareClass *dmap_class = DMAP_SHARE_CLASS (object_class);
@@ -131,26 +133,28 @@ dacp_share_class_init (DACPShareClass *klass)
object_class->set_property = dacp_share_set_property;
object_class->dispose = dacp_share_dispose;
- dmap_class->get_type_of_service = dacp_share_get_type_of_service;
+ dmap_class->get_type_of_service = dacp_share_get_type_of_service;
dmap_class->ctrl_int = dacp_share_ctrl_int;
dmap_class->login = dacp_share_login;
g_object_class_install_property (object_class,
- PROP_LIBRARY_NAME,
- g_param_spec_string ("library-name",
- "Library Name",
- "Library name as will be shown in the Remote",
- NULL,
- G_PARAM_READWRITE));
+ PROP_LIBRARY_NAME,
+ g_param_spec_string ("library-name",
+ "Library Name",
+ "Library name as will be shown in the Remote",
+ NULL,
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
- PROP_PLAYER,
- g_param_spec_object ("player",
- "Player",
- "Player",
- G_TYPE_OBJECT,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
+ PROP_PLAYER,
+ g_param_spec_object ("player",
+ "Player",
+ "Player",
+ G_TYPE_OBJECT,
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY));
+
/**
* DACPShare::remote-found
* @share: the #DACPShare that received the signal.
@@ -159,7 +163,7 @@ dacp_share_class_init (DACPShareClass *klass)
*
* Signal emited when a remote is found in the local network.
*/
- signals [REMOTE_FOUND] =
+ signals[REMOTE_FOUND] =
g_signal_new ("remote-found",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
@@ -167,9 +171,8 @@ dacp_share_class_init (DACPShareClass *klass)
NULL,
NULL,
dmap_marshal_VOID__STRING_STRING,
- G_TYPE_NONE,
- 2, G_TYPE_STRING, G_TYPE_STRING);
-
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
+
/**
* DACPShare::remote-lost
* @share: the #DACPShare that received the signal
@@ -177,7 +180,7 @@ dacp_share_class_init (DACPShareClass *klass)
*
* Signal emited when a remote is lost in the local network.
*/
- signals [REMOTE_LOST] =
+ signals[REMOTE_LOST] =
g_signal_new ("remote-lost",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
@@ -185,8 +188,7 @@ dacp_share_class_init (DACPShareClass *klass)
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
+ G_TYPE_NONE, 1, G_TYPE_STRING);
/**
* DACPShare::remote-paired
@@ -196,7 +198,7 @@ dacp_share_class_init (DACPShareClass *klass)
*
* Signal emited when a remote is paired.
*/
- signals [REMOTE_PAIRED] =
+ signals[REMOTE_PAIRED] =
g_signal_new ("remote-paired",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
@@ -204,8 +206,7 @@ dacp_share_class_init (DACPShareClass *klass)
NULL,
NULL,
dmap_marshal_VOID__STRING_BOOLEAN,
- G_TYPE_NONE,
- 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
/**
* DACPShare::lookup-guid
@@ -216,7 +217,7 @@ dacp_share_class_init (DACPShareClass *klass)
* validated. An implementation must implement this signal to lookup
* for guids saved by ::add-guid
*/
- signals [LOOKUP_GUID] =
+ signals[LOOKUP_GUID] =
g_signal_new ("lookup-guid",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
@@ -224,8 +225,7 @@ dacp_share_class_init (DACPShareClass *klass)
NULL,
NULL,
dmap_marshal_BOOLEAN__STRING,
- G_TYPE_BOOLEAN,
- 1, G_TYPE_STRING);
+ G_TYPE_BOOLEAN, 1, G_TYPE_STRING);
/**
* DACPShare::add-guid
@@ -240,7 +240,7 @@ dacp_share_class_init (DACPShareClass *klass)
* a button to forget previously connected remotes, so that the user may
* disconnect all previously connected remotes.
*/
- signals [ADD_GUID] =
+ signals[ADD_GUID] =
g_signal_new ("add-guid",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
@@ -248,63 +248,69 @@ dacp_share_class_init (DACPShareClass *klass)
NULL,
NULL,
g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
-
+ G_TYPE_NONE, 1, G_TYPE_STRING);
+
g_type_class_add_private (klass, sizeof (DACPSharePrivate));
}
static void
-dacp_share_init (DACPShare *share)
+dacp_share_init (DACPShare * share)
{
share->priv = DACP_SHARE_GET_PRIVATE (share);
share->priv->current_revision = 2;
-
- share->priv->remotes = g_hash_table_new_full ((GHashFunc)g_str_hash,
- (GEqualFunc)g_str_equal,
- (GDestroyNotify)g_free,
- (GDestroyNotify)g_free);
+
+ share->priv->remotes = g_hash_table_new_full ((GHashFunc) g_str_hash,
+ (GEqualFunc)
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify)
+ g_free);
}
static gchar *
-get_dbid (void)
+get_dbid (void)
{
static gchar *dbid;
+
if (!dbid) {
GString *name;
+
// Creates a service name 14 characters long concatenating the hostname
// hash hex value with itself.
// Idea taken from stereo.
name = g_string_new (NULL);
- g_string_printf (name, "%.8x", g_str_hash(g_get_host_name ()));
+ g_string_printf (name, "%.8x",
+ g_str_hash (g_get_host_name ()));
g_string_ascii_up (name);
g_string_append_len (name, name->str, 4);
dbid = name->str;
-
+
g_string_free (name, FALSE);
}
return dbid;
}
static void
-dacp_share_update_txt_records (DACPShare *share)
+dacp_share_update_txt_records (DACPShare * share)
{
gchar *dbid_record;
gchar *library_name_record;
- library_name_record = g_strdup_printf ("CtlN=%s", share->priv->library_name);
- dbid_record = g_strdup_printf("DbId=%s", get_dbid());
-
- gchar *txt_records[] = {"Ver=131073",
- "DvSv=2049",
- dbid_record,
- "DvTy=iTunes",
- "OSsi=0x1F6",
- "txtvers=1",
- library_name_record,
- NULL};
+ library_name_record =
+ g_strdup_printf ("CtlN=%s", share->priv->library_name);
+ dbid_record = g_strdup_printf ("DbId=%s", get_dbid ());
+
+ gchar *txt_records[] = { "Ver=131073",
+ "DvSv=2049",
+ dbid_record,
+ "DvTy=iTunes",
+ "OSsi=0x1F6",
+ "txtvers=1",
+ library_name_record,
+ NULL
+ };
g_object_set (share, "txt-records", txt_records, NULL);
@@ -313,10 +319,9 @@ dacp_share_update_txt_records (DACPShare *share)
}
static void
-dacp_share_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+dacp_share_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
DACPShare *share = DACP_SHARE (object);
@@ -329,7 +334,8 @@ dacp_share_set_property (GObject *object,
case PROP_PLAYER:
if (share->priv->player)
g_object_unref (share->priv->player);
- share->priv->player = DACP_PLAYER (g_value_dup_object (value));
+ share->priv->player =
+ DACP_PLAYER (g_value_dup_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -338,10 +344,8 @@ dacp_share_set_property (GObject *object,
}
static void
-dacp_share_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+dacp_share_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
DACPShare *share = DACP_SHARE (object);
@@ -359,7 +363,7 @@ dacp_share_get_property (GObject *object,
}
static void
-dacp_share_dispose (GObject *object)
+dacp_share_dispose (GObject * object)
{
DACPShare *share = DACP_SHARE (object);
@@ -372,77 +376,64 @@ dacp_share_dispose (GObject *object)
g_object_unref (share->priv->player);
g_slist_free (share->priv->update_queue);
-
+
g_hash_table_destroy (share->priv->remotes);
}
-void
-mdns_remote_added (DMAPMdnsBrowser *browser,
- DMAPMdnsBrowserService *service,
- DACPShare *share)
+void
+mdns_remote_added (DMAPMdnsBrowser * browser,
+ DMAPMdnsBrowserService * service, DACPShare * share)
{
DACPRemoteInfo *remote_info;
-
+
remote_info = g_new (DACPRemoteInfo, 1);
remote_info->host = g_strdup (service->host);
remote_info->port = service->port;
remote_info->connection = NULL;
remote_info->pair_txt = g_strdup (service->pair);
-
+
g_debug ("New Remote found: %s name=%s host=%s port=%u pair=%s",
- service->service_name,
- service->name,
- remote_info->host,
- remote_info->port,
- remote_info->pair_txt);
-
+ service->service_name,
+ service->name,
+ remote_info->host, remote_info->port, remote_info->pair_txt);
+
g_hash_table_insert (share->priv->remotes,
- service->service_name,
- remote_info);
-
- g_signal_emit (share,
- signals [REMOTE_FOUND],
- 0,
- service->service_name,
- service->name);
+ service->service_name, remote_info);
+
+ g_signal_emit (share,
+ signals[REMOTE_FOUND],
+ 0, service->service_name, service->name);
}
void
-mdns_remote_removed (DMAPMdnsBrowser *browser,
- const char *service_name,
- DACPShare *share)
+mdns_remote_removed (DMAPMdnsBrowser * browser,
+ const char *service_name, DACPShare * share)
{
- g_signal_emit (share,
- signals [REMOTE_LOST],
- 0,
- service_name);
-
- g_hash_table_remove (share->priv->remotes,
- service_name);
+ g_signal_emit (share, signals[REMOTE_LOST], 0, service_name);
+
+ g_hash_table_remove (share->priv->remotes, service_name);
}
DACPShare *
-dacp_share_new (const gchar *library_name,
- DACPPlayer *player,
- DMAPDb *db,
- DMAPContainerDb *container_db)
+dacp_share_new (const gchar * library_name,
+ DACPPlayer * player,
+ DMAPDb * db, DMAPContainerDb * container_db)
{
DACPShare *share;
-
+
g_object_ref (db);
g_object_ref (container_db);
-
+
share = DACP_SHARE (g_object_new (DACP_TYPE_SHARE,
- "name", get_dbid (),
- "library-name", library_name,
- "password", NULL,
- "db", db,
- "container-db", container_db,
- "player", G_OBJECT (player),
- "transcode-mimetype", NULL,
- NULL));
-
- g_debug("Starting DACP server");
+ "name", get_dbid (),
+ "library-name", library_name,
+ "password", NULL,
+ "db", db,
+ "container-db", container_db,
+ "player", G_OBJECT (player),
+ "transcode-mimetype", NULL, NULL));
+
+ g_debug ("Starting DACP server");
_dmap_share_server_start (DMAP_SHARE (share));
_dmap_share_publish_start (DMAP_SHARE (share));
@@ -450,99 +441,104 @@ dacp_share_new (const gchar *library_name,
}
void
-dacp_share_start_lookup (DACPShare *share)
+dacp_share_start_lookup (DACPShare * share)
{
GError *error;
-
+
if (share->priv->mdns_browser) {
g_warning ("DACP browsing already started");
return;
}
-
- share->priv->mdns_browser = dmap_mdns_browser_new (DMAP_MDNS_BROWSER_SERVICE_TYPE_DACP);
-
+
+ share->priv->mdns_browser =
+ dmap_mdns_browser_new (DMAP_MDNS_BROWSER_SERVICE_TYPE_DACP);
+
g_signal_connect_object (share->priv->mdns_browser,
"service-added",
- G_CALLBACK (mdns_remote_added),
- share,
- 0);
+ G_CALLBACK (mdns_remote_added), share, 0);
g_signal_connect_object (share->priv->mdns_browser,
"service-removed",
- G_CALLBACK (mdns_remote_removed),
- share,
- 0);
-
+ G_CALLBACK (mdns_remote_removed), share, 0);
+
error = NULL;
dmap_mdns_browser_start (share->priv->mdns_browser, &error);
if (error != NULL) {
- g_warning ("Unable to start Remote lookup: %s", error->message);
+ g_warning ("Unable to start Remote lookup: %s",
+ error->message);
g_error_free (error);
}
}
static gboolean
-remove_remotes_cb (gpointer service_name, gpointer remote_info, gpointer share)
+remove_remotes_cb (gpointer service_name, gpointer remote_info,
+ gpointer share)
{
- g_signal_emit ((DACPShare*) share,
- signals [REMOTE_LOST],
- 0,
- (gchar *) service_name);
+ g_signal_emit ((DACPShare *) share,
+ signals[REMOTE_LOST], 0, (gchar *) service_name);
return TRUE;
}
void
-dacp_share_stop_lookup (DACPShare *share)
+dacp_share_stop_lookup (DACPShare * share)
{
GError *error;
-
+
if (!share->priv->mdns_browser) {
g_warning ("DACP browsing not started");
return;
}
-
- g_hash_table_foreach_remove (share->priv->remotes, remove_remotes_cb, share);
-
+
+ g_hash_table_foreach_remove (share->priv->remotes, remove_remotes_cb,
+ share);
+
error = NULL;
dmap_mdns_browser_stop (share->priv->mdns_browser, &error);
if (error != NULL) {
- g_warning ("Unable to stop Remote lookup: %s", error->message);
+ g_warning ("Unable to stop Remote lookup: %s",
+ error->message);
g_error_free (error);
}
-
+
share->priv->mdns_browser = NULL;
}
const char *
-dacp_share_get_type_of_service (DMAPShare *share)
+dacp_share_get_type_of_service (DMAPShare * share)
{
return DACP_TYPE_OF_SERVICE;
}
void
-dacp_share_player_updated (DACPShare *share)
+dacp_share_player_updated (DACPShare * share)
{
share->priv->current_revision++;
dacp_share_send_playstatusupdate (share);
}
static void
-status_update_message_finished (SoupMessage *message, DACPShare *share)
+status_update_message_finished (SoupMessage * message, DACPShare * share)
{
- share->priv->update_queue = g_slist_remove (share->priv->update_queue, message);
+ share->priv->update_queue =
+ g_slist_remove (share->priv->update_queue, message);
g_object_unref (message);
}
static void
-dacp_share_send_playstatusupdate (DACPShare *share)
+dacp_share_send_playstatusupdate (DACPShare * share)
{
GSList *list;
SoupServer *server = NULL;
g_object_get (share, "server-ipv4", &server, NULL);
if (server) {
- for (list = share->priv->update_queue; list; list = list->next) {
- dacp_share_fill_playstatusupdate (share, (SoupMessage*) list->data);
- soup_server_unpause_message (server, (SoupMessage*) list->data);
+ for (list = share->priv->update_queue; list;
+ list = list->next) {
+ dacp_share_fill_playstatusupdate (share,
+ (SoupMessage *)
+ list->data);
+ soup_server_unpause_message (server,
+ (SoupMessage *) list->
+ data);
}
}
@@ -551,9 +547,14 @@ dacp_share_send_playstatusupdate (DACPShare *share)
g_object_get (share, "server-ipv6", &server, NULL);
if (server) {
- for (list = share->priv->update_queue; list; list = list->next) {
- dacp_share_fill_playstatusupdate (share, (SoupMessage*) list->data);
- soup_server_unpause_message (server, (SoupMessage*) list->data);
+ for (list = share->priv->update_queue; list;
+ list = list->next) {
+ dacp_share_fill_playstatusupdate (share,
+ (SoupMessage *)
+ list->data);
+ soup_server_unpause_message (server,
+ (SoupMessage *) list->
+ data);
}
}
@@ -564,7 +565,7 @@ dacp_share_send_playstatusupdate (DACPShare *share)
}
static void
-dacp_share_fill_playstatusupdate (DACPShare *share, SoupMessage *message)
+dacp_share_fill_playstatusupdate (DACPShare * share, SoupMessage * message)
{
GNode *cmst;
DAAPRecord *record;
@@ -572,19 +573,19 @@ dacp_share_fill_playstatusupdate (DACPShare *share, SoupMessage *message)
DACPRepeatState repeat_state;
gboolean shuffle_state;
guint playing_time;
-
- g_object_get (share->priv->player,
- "play-state", &play_state,
- "repeat-state", &repeat_state,
- "shuffle-state", &shuffle_state,
- "playing-time", &playing_time,
- NULL);
+
+ g_object_get (share->priv->player,
+ "play-state", &play_state,
+ "repeat-state", &repeat_state,
+ "shuffle-state", &shuffle_state,
+ "playing-time", &playing_time, NULL);
record = dacp_player_now_playing_record (share->priv->player);
cmst = dmap_structure_add (NULL, DMAP_CC_CMST);
dmap_structure_add (cmst, DMAP_CC_MSTT, (gint32) DMAP_STATUS_OK);
- dmap_structure_add (cmst, DMAP_CC_CMSR, share->priv->current_revision);
+ dmap_structure_add (cmst, DMAP_CC_CMSR,
+ share->priv->current_revision);
dmap_structure_add (cmst, DMAP_CC_CAPS, (gint32) play_state);
dmap_structure_add (cmst, DMAP_CC_CASH, shuffle_state ? 1 : 0);
dmap_structure_add (cmst, DMAP_CC_CARP, (gint32) repeat_state);
@@ -594,12 +595,12 @@ dacp_share_fill_playstatusupdate (DACPShare *share, SoupMessage *message)
gchar *album;
gint duration;
guint track_time;
- g_object_get (record,
- "title", &title,
- "songartist", &artist,
- "songalbum", &album,
- "duration", &duration,
- NULL);
+
+ g_object_get (record,
+ "title", &title,
+ "songartist", &artist,
+ "songalbum", &album,
+ "duration", &duration, NULL);
track_time = duration * 1000;
//dmap_structure_add (cmst, DMAP_CC_CAVC, 1);
dmap_structure_add (cmst, DMAP_CC_CAAS, 2);
@@ -614,8 +615,10 @@ dacp_share_fill_playstatusupdate (DACPShare *share, SoupMessage *message)
dmap_structure_add (cmst, DMAP_CC_CANG, "");
dmap_structure_add (cmst, DMAP_CC_ASAI, 0);
//dmap_structure_add (cmst, DMAP_CC_AEMK, 1);
- g_debug ("Playing time: %u, Track time: %u", playing_time, track_time);
- dmap_structure_add (cmst, DMAP_CC_CANT, track_time - playing_time);
+ g_debug ("Playing time: %u, Track time: %u", playing_time,
+ track_time);
+ dmap_structure_add (cmst, DMAP_CC_CANT,
+ track_time - playing_time);
dmap_structure_add (cmst, DMAP_CC_CAST, track_time);
g_free (title);
@@ -624,28 +627,27 @@ dacp_share_fill_playstatusupdate (DACPShare *share, SoupMessage *message)
g_object_unref (record);
}
-
- _dmap_share_message_set_from_dmap_structure (DMAP_SHARE (share), message, cmst);
+
+ _dmap_share_message_set_from_dmap_structure (DMAP_SHARE (share),
+ message, cmst);
dmap_structure_destroy (cmst);
}
static void
debug_param (gpointer key, gpointer val, gpointer user_data)
{
- g_debug ("%s %s", (char *) key, (char *) val);
+ g_debug ("%s %s", (char *) key, (char *) val);
}
void
-dacp_share_login (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
+dacp_share_login (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
gchar *pairing_guid;
-
-
+
g_debug ("(DACP) Path is %s.", path);
if (query) {
g_hash_table_foreach (query, debug_param, NULL);
@@ -656,69 +658,74 @@ dacp_share_login (DMAPShare *share,
if (pairing_guid != NULL) {
gboolean allow_login;
- g_signal_emit (share, signals [LOOKUP_GUID], 0, pairing_guid, &allow_login);
+ g_signal_emit (share, signals[LOOKUP_GUID], 0, pairing_guid,
+ &allow_login);
if (!allow_login) {
g_debug ("Unknown remote trying to connect");
- soup_message_set_status (message, SOUP_STATUS_FORBIDDEN);
+ soup_message_set_status (message,
+ SOUP_STATUS_FORBIDDEN);
return;
}
}
-
+
_dmap_share_login (share, server, message, path, query, context);
}
void
-dacp_share_ctrl_int (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
+dacp_share_ctrl_int (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
const char *rest_of_path;
DACPShare *dacp_share = DACP_SHARE (share);
-
+
g_debug ("Path is %s.", path);
if (query) {
g_hash_table_foreach (query, debug_param, NULL);
}
-
+
rest_of_path = strchr (path + 1, '/');
/* If calling /ctrl-int without args, the client doesnt need a
- session-id, otherwise it does and it should be validated. */
- if ((rest_of_path != NULL) && (! _dmap_share_session_id_validate (share, context, message, query, NULL))) {
+ * session-id, otherwise it does and it should be validated. */
+ if ((rest_of_path != NULL)
+ &&
+ (!_dmap_share_session_id_validate
+ (share, context, message, query, NULL))) {
soup_message_set_status (message, SOUP_STATUS_FORBIDDEN);
return;
}
if (rest_of_path == NULL) {
- /* CACI control-int
- * MSTT status
- * MUTY update type
- * MTCO specified total count
- * MRCO returned count
- * MLCL listing
- * MLIT listing item
- * MIID item id
- * CMIK Unknown (TRUE)
- * CMSP Unknown (TRUE)
- * CMSV Unknown (TRUE)
- * CASS Unknown (TRUE)
- * CASU Unknown (TRUE)
- * CASG Unknown (TRUE)
- */
-
+ /* CACI control-int
+ * MSTT status
+ * MUTY update type
+ * MTCO specified total count
+ * MRCO returned count
+ * MLCL listing
+ * MLIT listing item
+ * MIID item id
+ * CMIK Unknown (TRUE)
+ * CMSP Unknown (TRUE)
+ * CMSV Unknown (TRUE)
+ * CASS Unknown (TRUE)
+ * CASU Unknown (TRUE)
+ * CASG Unknown (TRUE)
+ */
+
GNode *caci;
GNode *mlcl;
GNode *mlit;
-
+
// dacp.controlint
caci = dmap_structure_add (NULL, DMAP_CC_CACI);
// dmap.status
- dmap_structure_add (caci, DMAP_CC_MSTT, (gint32) DMAP_STATUS_OK);
+ dmap_structure_add (caci, DMAP_CC_MSTT,
+ (gint32) DMAP_STATUS_OK);
// dmap.updatetype
dmap_structure_add (caci, DMAP_CC_MUTY, 0);
// dmap.specifiedtotalcount
@@ -744,14 +751,15 @@ dacp_share_ctrl_int (DMAPShare *share,
// Unknown (TRUE)
dmap_structure_add (mlit, DMAP_CC_CASG, (gint32) 1);
- _dmap_share_message_set_from_dmap_structure (share, message, caci);
+ _dmap_share_message_set_from_dmap_structure (share, message,
+ caci);
dmap_structure_destroy (caci);
} else if (g_ascii_strcasecmp ("/1/getproperty", rest_of_path) == 0) {
gchar *properties_query, **properties, **property;
GNode *cmgt;
-
+
properties_query = g_hash_table_lookup (query, "properties");
-
+
if (!properties_query) {
g_warning ("No property specified");
return;
@@ -759,57 +767,73 @@ dacp_share_ctrl_int (DMAPShare *share,
cmgt = dmap_structure_add (NULL, DMAP_CC_CMGT);
dmap_structure_add (cmgt, DMAP_CC_MSTT, DMAP_STATUS_OK);
-
+
properties = g_strsplit (properties_query, ",", -1);
for (property = properties; *property; property++) {
- if (g_ascii_strcasecmp (*property, "dmcp.volume") == 0) {
+ if (g_ascii_strcasecmp (*property, "dmcp.volume") ==
+ 0) {
gulong volume;
- g_object_get (dacp_share->priv->player, "volume", &volume, NULL);
+
+ g_object_get (dacp_share->priv->player,
+ "volume", &volume, NULL);
//g_debug ("Sending volume: %lu", volume);
- dmap_structure_add (cmgt, DMAP_CC_CMVO, volume);
+ dmap_structure_add (cmgt, DMAP_CC_CMVO,
+ volume);
} else {
- g_warning ("Unhandled property %s", *property);
+ g_warning ("Unhandled property %s",
+ *property);
}
}
g_strfreev (properties);
- _dmap_share_message_set_from_dmap_structure (share, message, cmgt);
+ _dmap_share_message_set_from_dmap_structure (share, message,
+ cmgt);
dmap_structure_destroy (cmgt);
} else if (g_ascii_strcasecmp ("/1/setproperty", rest_of_path) == 0) {
if (g_hash_table_lookup (query, "dmcp.volume")) {
- gdouble volume = strtod (g_hash_table_lookup (query, "dmcp.volume"), NULL);
- g_object_set (dacp_share->priv->player, "volume", (gulong) volume, NULL);
+ gdouble volume =
+ strtod (g_hash_table_lookup
+ (query, "dmcp.volume"), NULL);
+ g_object_set (dacp_share->priv->player, "volume",
+ (gulong) volume, NULL);
}
soup_message_set_status (message, SOUP_STATUS_NO_CONTENT);
} else if (g_ascii_strcasecmp ("/1/getspeakers", rest_of_path) == 0) {
GNode *casp;
GNode *mdcl;
-
+
casp = dmap_structure_add (NULL, DMAP_CC_CASP);
- dmap_structure_add (casp, DMAP_CC_MSTT, (gint32) DMAP_STATUS_OK);
+ dmap_structure_add (casp, DMAP_CC_MSTT,
+ (gint32) DMAP_STATUS_OK);
mdcl = dmap_structure_add (casp, DMAP_CC_MDCL);
-
+
dmap_structure_add (casp, DMAP_CC_CAIA, TRUE);
dmap_structure_add (casp, DMAP_CC_MINM, "Computer");
dmap_structure_add (casp, DMAP_CC_MSMA, (gint32) 0);
-
- _dmap_share_message_set_from_dmap_structure (share, message, casp);
+
+ _dmap_share_message_set_from_dmap_structure (share, message,
+ casp);
dmap_structure_destroy (casp);
- } else if (g_ascii_strcasecmp ("/1/playstatusupdate", rest_of_path) == 0) {
- gchar *revision = g_hash_table_lookup (query, "revision-number");
+ } else if (g_ascii_strcasecmp ("/1/playstatusupdate", rest_of_path) ==
+ 0) {
+ gchar *revision =
+ g_hash_table_lookup (query, "revision-number");
gint revision_number = atoi (revision);
if (revision_number >= dacp_share->priv->current_revision) {
g_object_ref (message);
- dacp_share->priv->update_queue = g_slist_prepend (dacp_share->priv->update_queue, message);
- g_signal_connect_object (message,
- "finished",
- G_CALLBACK (status_update_message_finished),
- dacp_share, 0);
+ dacp_share->priv->update_queue =
+ g_slist_prepend (dacp_share->priv->
+ update_queue, message);
+ g_signal_connect_object (message, "finished",
+ G_CALLBACK
+ (status_update_message_finished),
+ dacp_share, 0);
soup_server_pause_message (server, message);
} else {
- dacp_share_fill_playstatusupdate (dacp_share, message);
+ dacp_share_fill_playstatusupdate (dacp_share,
+ message);
}
} else if (g_ascii_strcasecmp ("/1/playpause", rest_of_path) == 0) {
dacp_player_play_pause (dacp_share->priv->player);
@@ -823,62 +847,79 @@ dacp_share_ctrl_int (DMAPShare *share,
} else if (g_ascii_strcasecmp ("/1/previtem", rest_of_path) == 0) {
dacp_player_prev_item (dacp_share->priv->player);
soup_message_set_status (message, SOUP_STATUS_NO_CONTENT);
- } else if (g_ascii_strcasecmp ("/1/nowplayingartwork", rest_of_path) == 0) {
+ } else if (g_ascii_strcasecmp ("/1/nowplayingartwork", rest_of_path)
+ == 0) {
guint width = 320;
guint height = 320;
gchar *artwork_filename;
gchar *buffer;
gsize buffer_len;
-
+
if (g_hash_table_lookup (query, "mw"))
width = atoi (g_hash_table_lookup (query, "mw"));
if (g_hash_table_lookup (query, "mh"))
height = atoi (g_hash_table_lookup (query, "mh"));
- artwork_filename = dacp_player_now_playing_artwork (dacp_share->priv->player, width, height);
+ artwork_filename =
+ dacp_player_now_playing_artwork (dacp_share->priv->
+ player, width,
+ height);
if (!artwork_filename) {
g_debug ("No artwork for currently playing song");
- soup_message_set_status (message, SOUP_STATUS_NOT_FOUND);
+ soup_message_set_status (message,
+ SOUP_STATUS_NOT_FOUND);
return;
}
#ifdef HAVE_GDKPIXBUF
- GdkPixbuf *artwork = gdk_pixbuf_new_from_file_at_scale (artwork_filename, width, height, TRUE, NULL);
+ GdkPixbuf *artwork =
+ gdk_pixbuf_new_from_file_at_scale (artwork_filename,
+ width, height,
+ TRUE, NULL);
if (!artwork) {
g_debug ("Error loading image file");
g_free (artwork_filename);
- soup_message_set_status (message, SOUP_STATUS_INTERNAL_SERVER_ERROR);
+ soup_message_set_status (message,
+ SOUP_STATUS_INTERNAL_SERVER_ERROR);
return;
}
- if (!gdk_pixbuf_save_to_buffer (artwork, &buffer, &buffer_len, "png", NULL, NULL)) {
+ if (!gdk_pixbuf_save_to_buffer
+ (artwork, &buffer, &buffer_len, "png", NULL, NULL)) {
g_debug ("Error saving artwork to PNG");
g_object_unref (artwork);
g_free (artwork_filename);
- soup_message_set_status (message, SOUP_STATUS_INTERNAL_SERVER_ERROR);
+ soup_message_set_status (message,
+ SOUP_STATUS_INTERNAL_SERVER_ERROR);
return;
}
g_object_unref (artwork);
#else
- if (!g_file_get_contents (artwork_filename, &buffer, &buffer_len, NULL)) {
+ if (!g_file_get_contents
+ (artwork_filename, &buffer, &buffer_len, NULL)) {
g_debug ("Error getting artwork data");
g_free (artwork_filename);
- soup_message_set_status (message, SOUP_STATUS_INTERNAL_SERVER_ERROR);
+ soup_message_set_status (message,
+ SOUP_STATUS_INTERNAL_SERVER_ERROR);
return;
}
#endif
g_free (artwork_filename);
soup_message_set_status (message, SOUP_STATUS_OK);
- soup_message_set_response (message, "image/png", SOUP_MEMORY_TAKE, buffer, buffer_len);
+ soup_message_set_response (message, "image/png",
+ SOUP_MEMORY_TAKE, buffer,
+ buffer_len);
} else if (g_ascii_strcasecmp ("/1/cue", rest_of_path) == 0) {
gchar *command;
-
+
command = g_hash_table_lookup (query, "command");
if (!command) {
g_debug ("No CUE command specified");
- soup_message_set_status (message, SOUP_STATUS_NO_CONTENT);
+ soup_message_set_status (message,
+ SOUP_STATUS_NO_CONTENT);
return;
} else if (g_ascii_strcasecmp ("clear", command) == 0) {
dacp_player_cue_clear (dacp_share->priv->player);
- soup_message_set_status (message, SOUP_STATUS_NO_CONTENT);
+ soup_message_set_status (message,
+ SOUP_STATUS_NO_CONTENT);
} else if (g_ascii_strcasecmp ("play", command) == 0) {
GNode *cacr;
gchar *record_query;
@@ -887,7 +928,8 @@ dacp_share_ctrl_int (DMAPShare *share,
GList *sorted_records;
GSList *filter_def;
DMAPDb *db;
- gint index = atoi (g_hash_table_lookup (query, "index"));
+ gint index =
+ atoi (g_hash_table_lookup (query, "index"));
g_object_get (share, "db", &db, NULL);
record_query = g_hash_table_lookup (query, "query");
@@ -896,26 +938,36 @@ dacp_share_ctrl_int (DMAPShare *share,
sorted_records = g_hash_table_get_values (records);
sort_by = g_hash_table_lookup (query, "sort");
if (g_strcmp0 (sort_by, "album") == 0) {
- sorted_records = g_list_sort_with_data (sorted_records, (GCompareDataFunc) daap_record_cmp_by_album, db);
+ sorted_records =
+ g_list_sort_with_data (sorted_records,
+ (GCompareDataFunc)
+ daap_record_cmp_by_album,
+ db);
} else if (sort_by != NULL) {
- g_warning ("Unknown sort column: %s", sort_by);
+ g_warning ("Unknown sort column: %s",
+ sort_by);
}
-
- dacp_player_cue_play (dacp_share->priv->player, sorted_records, index);
+
+ dacp_player_cue_play (dacp_share->priv->player,
+ sorted_records, index);
g_list_free (sorted_records);
g_hash_table_unref (records);
dmap_share_free_filter (filter_def);
cacr = dmap_structure_add (NULL, DMAP_CC_CACR);
- dmap_structure_add (cacr, DMAP_CC_MSTT, DMAP_STATUS_OK);
+ dmap_structure_add (cacr, DMAP_CC_MSTT,
+ DMAP_STATUS_OK);
dmap_structure_add (cacr, DMAP_CC_MIID, index);
- _dmap_share_message_set_from_dmap_structure (share, message, cacr);
+ _dmap_share_message_set_from_dmap_structure (share,
+ message,
+ cacr);
dmap_structure_destroy (cacr);
} else {
g_warning ("Unhandled cue command: %s", command);
- soup_message_set_status (message, SOUP_STATUS_NO_CONTENT);
+ soup_message_set_status (message,
+ SOUP_STATUS_NO_CONTENT);
return;
}
} else {
@@ -928,33 +980,38 @@ dacp_share_ctrl_int (DMAPShare *share,
#define PASSCODE_LENGTH 4
static gchar *
-dacp_share_pairing_code(DACPShare *share, gchar* pair_txt, gchar passcode[4]) {
+dacp_share_pairing_code (DACPShare * share, gchar * pair_txt,
+ gchar passcode[4])
+{
int i;
GString *pairing_code;
gchar *pairing_string;
gchar *ret;
-
+
/* The pairing code is the MD5 sum of the concatenation of pair_txt
- with the passcode, but the passcode takes 16-bits unicodes characters */
- pairing_string = g_strnfill(PAIR_TXT_LENGTH + PASSCODE_LENGTH * 2, '\0');
- g_strlcpy(pairing_string, pair_txt, PAIR_TXT_LENGTH + PASSCODE_LENGTH * 2);
+ * with the passcode, but the passcode takes 16-bits unicodes characters */
+ pairing_string =
+ g_strnfill (PAIR_TXT_LENGTH + PASSCODE_LENGTH * 2, '\0');
+ g_strlcpy (pairing_string, pair_txt,
+ PAIR_TXT_LENGTH + PASSCODE_LENGTH * 2);
for (i = 0; i < 4; i++) {
pairing_string[PAIR_TXT_LENGTH + i * 2] = passcode[i];
}
-
- pairing_code = g_string_new (
- g_compute_checksum_for_data(G_CHECKSUM_MD5,
- (guchar*)pairing_string,
- PAIR_TXT_LENGTH + PASSCODE_LENGTH * 2));
+
+ pairing_code =
+ g_string_new (g_compute_checksum_for_data
+ (G_CHECKSUM_MD5, (guchar *) pairing_string,
+ PAIR_TXT_LENGTH + PASSCODE_LENGTH * 2));
g_string_ascii_up (pairing_code);
ret = pairing_code->str;
g_string_free (pairing_code, FALSE);
-
+
return ret;
}
void
-connection_handler_cb (DMAPConnection *connection, guint status, GNode *structure, gpointer user_data)
+connection_handler_cb (DMAPConnection * connection, guint status,
+ GNode * structure, gpointer user_data)
{
gboolean connected;
GHashTableIter iter;
@@ -971,24 +1028,26 @@ connection_handler_cb (DMAPConnection *connection, guint status, GNode *structur
} else {
connected = FALSE;
}
-
+
/* Get the pairing-guid to identify this remote in the future. */
if (structure)
item = dmap_structure_find_item (structure, DMAP_CC_CMPG);
if (item) {
guint64 guid = g_value_get_int64 (&(item->content));
- pairing_guid = g_strdup_printf ("0x%.16" G_GINT64_MODIFIER "X", guid);
- g_signal_emit (share, signals [ADD_GUID], 0, pairing_guid);
+
+ pairing_guid =
+ g_strdup_printf ("0x%.16" G_GINT64_MODIFIER "X",
+ guid);
+ g_signal_emit (share, signals[ADD_GUID], 0, pairing_guid);
g_free (pairing_guid);
}
/* Find the remote that initiated this connection */
g_hash_table_iter_init (&iter, share->priv->remotes);
- while (g_hash_table_iter_next (&iter, &key, &value))
- {
- if (((DACPRemoteInfo*) value)->connection == connection) {
+ while (g_hash_table_iter_next (&iter, &key, &value)) {
+ if (((DACPRemoteInfo *) value)->connection == connection) {
service_name = (gchar *) key;
- remote_info = (DACPRemoteInfo*) value;
+ remote_info = (DACPRemoteInfo *) value;
break;
}
}
@@ -999,24 +1058,25 @@ connection_handler_cb (DMAPConnection *connection, guint status, GNode *structur
}
/* Frees the connection */
- remote_info->connection = NULL;
+ remote_info->connection = NULL;
g_object_unref (connection);
/* FIXME: Send more detailed error info, such as wrong pair code, etc */
- g_signal_emit (share, signals [REMOTE_PAIRED], 0, service_name, connected);
+ g_signal_emit (share, signals[REMOTE_PAIRED], 0, service_name,
+ connected);
}
void
-dacp_share_pair (DACPShare *share, gchar *service_name, gchar passcode[4])
+dacp_share_pair (DACPShare * share, gchar * service_name, gchar passcode[4])
{
gchar *pairing_code;
gchar *name;
gchar *path;
DACPRemoteInfo *remote_info;
-
+
remote_info = g_hash_table_lookup (share->priv->remotes,
- service_name);
-
+ service_name);
+
if (remote_info == NULL) {
g_warning ("Remote %s not found.", service_name);
return;
@@ -1026,29 +1086,30 @@ dacp_share_pair (DACPShare *share, gchar *service_name, gchar passcode[4])
g_warning ("Already pairing remote %s.", service_name);
return;
}
-
+
g_object_get (share, "name", &name, NULL);
-
- remote_info->connection = dacp_connection_new (name,
- remote_info->host,
- remote_info->port,
- FALSE,
- NULL,
- NULL);
+
+ remote_info->connection = dacp_connection_new (name,
+ remote_info->host,
+ remote_info->port,
+ FALSE, NULL, NULL);
/* This is required since we don't call DMAPConnection default handler */
dmap_connection_setup (remote_info->connection);
-
+
/* Get the remote path for pairing */
- pairing_code = dacp_share_pairing_code (share, remote_info->pair_txt, passcode);
- path = g_strdup_printf ("/pair?pairingcode=%s&servicename=%s",
- pairing_code,
- name);
+ pairing_code =
+ dacp_share_pairing_code (share, remote_info->pair_txt,
+ passcode);
+ path = g_strdup_printf ("/pair?pairingcode=%s&servicename=%s",
+ pairing_code, name);
g_free (pairing_code);
-
- g_debug ("Pairing remote in %s:%d/%s", remote_info->host, remote_info->port, path);
+
+ g_debug ("Pairing remote in %s:%d/%s", remote_info->host,
+ remote_info->port, path);
/* Let DMAPConnection do the heavy work */
- dmap_connection_get (remote_info->connection, path, FALSE, connection_handler_cb, share);
+ dmap_connection_get (remote_info->connection, path, FALSE,
+ connection_handler_cb, share);
g_free (path);
}
diff --git a/libdmapsharing/dacp-share.h b/libdmapsharing/dacp-share.h
index d24633c..f0e5fc7 100644
--- a/libdmapsharing/dacp-share.h
+++ b/libdmapsharing/dacp-share.h
@@ -31,7 +31,6 @@
#include <libdmapsharing/daap-share.h>
G_BEGIN_DECLS
-
/**
* DACP_TYPE_SHARE:
*
@@ -83,31 +82,29 @@ G_BEGIN_DECLS
*/
#define DACP_SHARE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
DACP_TYPE_SHARE, DACPShareClass))
-
typedef struct DACPSharePrivate DACPSharePrivate;
-typedef struct {
+typedef struct
+{
DAAPShare daap_share_instance;
DACPSharePrivate *priv;
} DACPShare;
-typedef struct {
+typedef struct
+{
DAAPShareClass daap_share_class;
-
- gboolean (*lookup_guid) (DACPShare *share, gchar *guid);
- void (*add_guid) (DACPShare *share, gchar *guid);
-
- void (*remote_found) (DACPShare *share,
- gchar *service_name,
- gchar *remote_name);
- void (*remote_lost) (DACPShare *share,
- gchar *service_name);
- void (*remote_paired) (DACPShare *share,
- gchar *service_name,
- gboolean connected);
+
+ gboolean (*lookup_guid) (DACPShare * share, gchar * guid);
+ void (*add_guid) (DACPShare * share, gchar * guid);
+
+ void (*remote_found) (DACPShare * share,
+ gchar * service_name, gchar * remote_name);
+ void (*remote_lost) (DACPShare * share, gchar * service_name);
+ void (*remote_paired) (DACPShare * share,
+ gchar * service_name, gboolean connected);
} DACPShareClass;
-GType dacp_share_get_type (void);
+GType dacp_share_get_type (void);
/**
* dacp_share_new:
@@ -122,7 +119,8 @@ GType dacp_share_get_type (void);
*
* Returns: a pointer to a #DACPShare.
*/
-DACPShare *dacp_share_new (const gchar *library_name, DACPPlayer *player, DMAPDb *db, DMAPContainerDb *container_db);
+DACPShare *dacp_share_new (const gchar * library_name, DACPPlayer * player,
+ DMAPDb * db, DMAPContainerDb * container_db);
/**
* dacp_share_pair:
@@ -134,7 +132,8 @@ DACPShare *dacp_share_new (const gchar *library_name, DACPPlayer *player, DMAPDb
* correct (the same as shown on the remote), the remote will start connecting
* to this server.
*/
-void dacp_share_pair (DACPShare *share, gchar *service_name, gchar passcode[4]);
+void dacp_share_pair (DACPShare * share, gchar * service_name,
+ gchar passcode[4]);
/**
* dacp_share_start_lookup:
@@ -145,7 +144,7 @@ void dacp_share_pair (DACPShare *share, gchar *service_name, gchar passcode[4]);
* after calling this function is that it starts looking up for Remotes on the
* network.
*/
-void dacp_share_start_lookup (DACPShare *share);
+void dacp_share_start_lookup (DACPShare * share);
/**
* dacp_share_stop_lookup:
@@ -153,7 +152,7 @@ void dacp_share_start_lookup (DACPShare *share);
*
* Stop looking up for DACP remotes.
*/
-void dacp_share_stop_lookup (DACPShare *share);
+void dacp_share_stop_lookup (DACPShare * share);
/**
* dacp_share_player_update:
@@ -161,8 +160,8 @@ void dacp_share_stop_lookup (DACPShare *share);
*
* Signals that the player has been updated (different track playing, playing
* state changed, suffle state changed, etc).
- */
-void dacp_share_player_updated (DACPShare *share);
+ */
+void dacp_share_player_updated (DACPShare * share);
#endif /* __DACP_SHARE_H */
diff --git a/libdmapsharing/dmap-connection.c b/libdmapsharing/dmap-connection.c
index 0c53e1d..e9ebbeb 100644
--- a/libdmapsharing/dmap-connection.c
+++ b/libdmapsharing/dmap-connection.c
@@ -39,95 +39,95 @@
#define ITUNES_7_SERVER "iTunes/7"
-static void dmap_connection_dispose (GObject *obj);
-static void dmap_connection_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void dmap_connection_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static gboolean dmap_connection_do_something (DMAPConnection *connection);
-static void dmap_connection_state_done (DMAPConnection *connection,
- gboolean result);
-
-static gboolean emit_progress_idle (DMAPConnection *connection);
+static void dmap_connection_dispose (GObject * obj);
+static void dmap_connection_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec);
+static void dmap_connection_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec);
-G_DEFINE_TYPE (DMAPConnection, dmap_connection, G_TYPE_OBJECT)
-
-#define DMAP_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DMAP_TYPE_CONNECTION, DMAPConnectionPrivate))
-
-struct DMAPConnectionPrivate {
- char *name;
- gboolean password_protected;
- char *username;
- char *password;
- char *host;
- guint port;
-
- gboolean is_connected;
- gboolean is_connecting;
-
- SoupSession *session;
- SoupURI *base_uri;
- gchar *daap_base_uri;
-
- gdouble dmap_version;
- guint32 session_id;
- gint revision_number;
-
- gint request_id;
- gint database_id;
-
- guint reading_playlist;
- GSList *playlists;
- GHashTable *item_id_to_uri;
-
- DMAPDb *db;
- DMAPRecordFactory *record_factory;
+static gboolean dmap_connection_do_something (DMAPConnection * connection);
+static void dmap_connection_state_done (DMAPConnection * connection,
+ gboolean result);
- DMAPConnectionState state;
- gboolean use_response_handler_thread;
- float progress;
+static gboolean emit_progress_idle (DMAPConnection * connection);
- guint emit_progress_id;
- guint do_something_id;
-
- gboolean result;
- char *last_error_message;
-};
-
-enum {
- PROP_0,
- PROP_DB,
- PROP_FACTORY,
- PROP_NAME,
- PROP_ENTRY_TYPE,
- PROP_PASSWORD_PROTECTED,
- PROP_HOST,
- PROP_PORT,
- PROP_BASE_URI,
- PROP_DATABASE_ID,
- PROP_SESSION_ID,
- PROP_DMAP_VERSION,
- PROP_REVISION_NUMBER,
-};
-
-enum {
- AUTHENTICATE,
- CONNECTING,
- CONNECTED,
- DISCONNECTED,
- OPERATION_DONE,
- LAST_SIGNAL
-};
-
-static guint signals [LAST_SIGNAL] = { 0, };
+G_DEFINE_TYPE (DMAPConnection, dmap_connection, G_TYPE_OBJECT)
+#define DMAP_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DMAP_TYPE_CONNECTION, DMAPConnectionPrivate))
+ struct DMAPConnectionPrivate
+ {
+ char *name;
+ gboolean password_protected;
+ char *username;
+ char *password;
+ char *host;
+ guint port;
+
+ gboolean is_connected;
+ gboolean is_connecting;
+
+ SoupSession *session;
+ SoupURI *base_uri;
+ gchar *daap_base_uri;
+
+ gdouble dmap_version;
+ guint32 session_id;
+ gint revision_number;
+
+ gint request_id;
+ gint database_id;
+
+ guint reading_playlist;
+ GSList *playlists;
+ GHashTable *item_id_to_uri;
+
+ DMAPDb *db;
+ DMAPRecordFactory *record_factory;
+
+ DMAPConnectionState state;
+ gboolean use_response_handler_thread;
+ float progress;
+
+ guint emit_progress_id;
+ guint do_something_id;
+
+ gboolean result;
+ char *last_error_message;
+ };
+
+ enum
+ {
+ PROP_0,
+ PROP_DB,
+ PROP_FACTORY,
+ PROP_NAME,
+ PROP_ENTRY_TYPE,
+ PROP_PASSWORD_PROTECTED,
+ PROP_HOST,
+ PROP_PORT,
+ PROP_BASE_URI,
+ PROP_DATABASE_ID,
+ PROP_SESSION_ID,
+ PROP_DMAP_VERSION,
+ PROP_REVISION_NUMBER,
+ };
+
+ enum
+ {
+ AUTHENTICATE,
+ CONNECTING,
+ CONNECTED,
+ DISCONNECTED,
+ OPERATION_DONE,
+ LAST_SIGNAL
+ };
+
+ static guint signals[LAST_SIGNAL] = { 0, };
static void
-dmap_connection_finalize (GObject *object)
+dmap_connection_finalize (GObject * object)
{
DMAPConnection *connection;
@@ -144,7 +144,7 @@ dmap_connection_finalize (GObject *object)
}
static void
-dmap_connection_class_init (DMAPConnectionClass *klass)
+dmap_connection_class_init (DMAPConnectionClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -152,8 +152,8 @@ dmap_connection_class_init (DMAPConnectionClass *klass)
klass->get_query_metadata = NULL;
klass->handle_mlcl = NULL;
- object_class->finalize = dmap_connection_finalize;
- object_class->dispose = dmap_connection_dispose;
+ object_class->finalize = dmap_connection_finalize;
+ object_class->dispose = dmap_connection_dispose;
object_class->set_property = dmap_connection_set_property;
object_class->get_property = dmap_connection_get_property;
@@ -164,44 +164,49 @@ dmap_connection_class_init (DMAPConnectionClass *klass)
g_param_spec_pointer ("db",
"DMAPDb",
"DMAPDb object",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_FACTORY,
g_param_spec_pointer ("factory",
"record factory",
"record factory",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_PASSWORD_PROTECTED,
- g_param_spec_boolean ("password-protected",
- "password protected",
- "connection is password protected",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_NAME,
+ g_param_spec_boolean
+ ("password-protected",
+ "password protected",
+ "connection is password protected",
+ FALSE,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_NAME,
g_param_spec_string ("name",
- "connection name",
+ "connection name",
"connection name",
NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_HOST,
- g_param_spec_string ("host",
- "host",
- "host",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
- g_object_class_install_property (object_class,
- PROP_PORT,
- g_param_spec_uint ("port",
- "port",
- "port",
- 0, G_MAXINT, 0,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_HOST,
+ g_param_spec_string ("host", "host",
+ "host", NULL,
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY));
+ g_object_class_install_property (object_class, PROP_PORT,
+ g_param_spec_uint ("port", "port",
+ "port", 0,
+ G_MAXINT, 0,
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_BASE_URI,
@@ -229,10 +234,11 @@ dmap_connection_class_init (DMAPConnectionClass *klass)
g_object_class_install_property (object_class,
PROP_DMAP_VERSION,
g_param_spec_double ("dmap-version",
- "DMAP version",
- "DMAP version",
- 0, G_MAXDOUBLE, 0,
- G_PARAM_READWRITE));
+ "DMAP version",
+ "DMAP version",
+ 0, G_MAXDOUBLE,
+ 0,
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_REVISION_NUMBER,
@@ -242,124 +248,108 @@ dmap_connection_class_init (DMAPConnectionClass *klass)
0, G_MAXINT, 0,
G_PARAM_READWRITE));
- signals [AUTHENTICATE] = g_signal_new ("authenticate",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DMAPConnectionClass, authenticate),
- NULL,
- NULL,
- dmap_marshal_STRING__STRING,
- G_TYPE_STRING,
- 1, G_TYPE_STRING);
- signals [CONNECTING] = g_signal_new ("connecting",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DMAPConnectionClass, connecting),
- NULL,
- NULL,
- dmap_marshal_VOID__ULONG_FLOAT,
- G_TYPE_NONE,
- 2, G_TYPE_ULONG, G_TYPE_FLOAT);
- signals [CONNECTED] = g_signal_new ("connected",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DMAPConnectionClass, connected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [DISCONNECTED] = g_signal_new ("disconnected",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DMAPConnectionClass, disconnected),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
- signals [OPERATION_DONE] = g_signal_new ("operation-done",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (DMAPConnectionClass, operation_done),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ signals[AUTHENTICATE] = g_signal_new ("authenticate",
+ G_TYPE_FROM_CLASS
+ (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET
+ (DMAPConnectionClass,
+ authenticate), NULL, NULL,
+ dmap_marshal_STRING__STRING,
+ G_TYPE_STRING, 1,
+ G_TYPE_STRING);
+ signals[CONNECTING] =
+ g_signal_new ("connecting", G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (DMAPConnectionClass,
+ connecting), NULL, NULL,
+ dmap_marshal_VOID__ULONG_FLOAT, G_TYPE_NONE, 2,
+ G_TYPE_ULONG, G_TYPE_FLOAT);
+ signals[CONNECTED] =
+ g_signal_new ("connected", G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (DMAPConnectionClass,
+ connected), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ signals[DISCONNECTED] =
+ g_signal_new ("disconnected",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (DMAPConnectionClass,
+ disconnected), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ signals[OPERATION_DONE] =
+ g_signal_new ("operation-done",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (DMAPConnectionClass,
+ operation_done), NULL, NULL,
+ g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}
static void
-dmap_connection_init (DMAPConnection *connection)
+dmap_connection_init (DMAPConnection * connection)
{
connection->priv = DMAP_CONNECTION_GET_PRIVATE (connection);
- connection->priv->username = g_strdup_printf ("libdmapsharing_%s", VERSION);
+ connection->priv->username =
+ g_strdup_printf ("libdmapsharing_%s", VERSION);
}
static char *
-connection_get_password (DMAPConnection *connection)
+connection_get_password (DMAPConnection * connection)
{
char *password = NULL;;
// FIXME: GDK_THREADS_ENTER ();
g_signal_emit (connection,
- signals [AUTHENTICATE],
- 0,
- connection->priv->name,
- &password);
+ signals[AUTHENTICATE],
+ 0, connection->priv->name, &password);
// FIXME: GDK_THREADS_LEAVE ();
return password;
}
static void
-connection_connected (DMAPConnection *connection)
+connection_connected (DMAPConnection * connection)
{
g_debug ("Emitting connected");
connection->priv->is_connected = TRUE;
// FIXME: GDK_THREADS_ENTER ();
- g_signal_emit (connection,
- signals [CONNECTED],
- 0);
+ g_signal_emit (connection, signals[CONNECTED], 0);
// FIXME: GDK_THREADS_LEAVE ();
}
static void
-connection_disconnected (DMAPConnection *connection)
+connection_disconnected (DMAPConnection * connection)
{
g_debug ("Emitting disconnected");
connection->priv->is_connected = FALSE;
// FIXME: GDK_THREADS_ENTER ();
- g_signal_emit (connection,
- signals [DISCONNECTED],
- 0);
+ g_signal_emit (connection, signals[DISCONNECTED], 0);
// FIXME: GDK_THREADS_LEAVE ();
}
static void
-connection_operation_done (DMAPConnection *connection)
+connection_operation_done (DMAPConnection * connection)
{
g_debug ("Emitting operation done");
// FIXME: GDK_THREADS_ENTER ();
- g_signal_emit (connection,
- signals [OPERATION_DONE],
- 0);
+ g_signal_emit (connection, signals[OPERATION_DONE], 0);
// FIXME: GDK_THREADS_LEAVE ();
}
SoupMessage *
-dmap_connection_build_message (DMAPConnection *connection,
- const char *path,
- gboolean need_hash,
- gdouble version,
- gint req_id,
- gboolean send_close)
+dmap_connection_build_message (DMAPConnection * connection,
+ const char *path,
+ gboolean need_hash,
+ gdouble version,
+ gint req_id, gboolean send_close)
{
SoupMessage *message = NULL;
SoupURI *base_uri = NULL;
@@ -385,9 +375,9 @@ dmap_connection_build_message (DMAPConnection *connection,
dmap_connection_get_headers (connection, uri_str);
soup_message_headers_append (message->request_headers,
- "User-Agent", DMAP_USER_AGENT);
+ "User-Agent", DMAP_USER_AGENT);
soup_message_headers_append (message->request_headers,
- "Connection", "close");
+ "Connection", "close");
soup_uri_free (uri);
g_free (uri_str);
@@ -396,13 +386,13 @@ dmap_connection_build_message (DMAPConnection *connection,
}
#ifdef HAVE_LIBZ
-static void
-*g_zalloc_wrapper (voidpf opaque, uInt items, uInt size)
+static void *
+g_zalloc_wrapper (voidpf opaque, uInt items, uInt size)
{
- if ((items != 0) && (size >= G_MAXUINT/items)) {
+ if ((items != 0) && (size >= G_MAXUINT / items)) {
return Z_NULL;
}
- if ((size != 0) && (items >= G_MAXUINT/size)) {
+ if ((size != 0) && (items >= G_MAXUINT / size)) {
return Z_NULL;
}
return g_malloc0 (items * size);
@@ -416,8 +406,8 @@ g_zfree_wrapper (voidpf opaque, voidpf address)
#endif
static void
-connection_set_error_message (DMAPConnection *connection,
- const char *message)
+connection_set_error_message (DMAPConnection * connection,
+ const char *message)
{
/* FIXME: obtain a lock */
g_free (connection->priv->last_error_message);
@@ -428,7 +418,8 @@ connection_set_error_message (DMAPConnection *connection,
}
}
-typedef struct {
+typedef struct
+{
SoupMessage *message;
int status;
DMAPConnection *connection;
@@ -438,7 +429,7 @@ typedef struct {
} DAAPResponseData;
static void
-actual_http_response_handler (DAAPResponseData *data)
+actual_http_response_handler (DAAPResponseData * data)
{
DMAPConnectionPrivate *priv;
GNode *structure;
@@ -455,48 +446,58 @@ actual_http_response_handler (DAAPResponseData *data)
response = data->message->response_body->data;
response_length = data->message->response_body->length;
- message_path = soup_uri_to_string (soup_message_get_uri (data->message), FALSE);
+ message_path =
+ soup_uri_to_string (soup_message_get_uri (data->message),
+ FALSE);
g_debug ("Received response from %s: %d, %s\n",
- message_path,
- data->message->status_code,
- data->message->reason_phrase);
+ message_path,
+ data->message->status_code, data->message->reason_phrase);
if (data->message->response_headers) {
const char *server;
- encoding_header = soup_message_headers_get (data->message->response_headers, "Content-Encoding");
+ encoding_header =
+ soup_message_headers_get (data->message->
+ response_headers,
+ "Content-Encoding");
- server = soup_message_headers_get (data->message->response_headers, "DAAP-Server");
- if (server != NULL && strstr (server, ITUNES_7_SERVER) != NULL) {
+ server = soup_message_headers_get (data->message->
+ response_headers,
+ "DAAP-Server");
+ if (server != NULL
+ && strstr (server, ITUNES_7_SERVER) != NULL) {
g_debug ("giving up. we can't talk to %s", server);
compatible_server = FALSE;
}
}
- if (SOUP_STATUS_IS_SUCCESSFUL (data->status) && encoding_header && strcmp (encoding_header, "gzip") == 0) {
+ if (SOUP_STATUS_IS_SUCCESSFUL (data->status) && encoding_header
+ && strcmp (encoding_header, "gzip") == 0) {
#ifdef HAVE_LIBZ
z_stream stream;
unsigned int factor = 4;
unsigned int unc_size = response_length * factor;
- stream.next_in = (unsigned char *)response;
+ stream.next_in = (unsigned char *) response;
stream.avail_in = response_length;
stream.total_in = 0;
new_response = g_malloc (unc_size + 1);
- stream.next_out = (unsigned char *)new_response;
+ stream.next_out = (unsigned char *) new_response;
stream.avail_out = unc_size;
stream.total_out = 0;
stream.zalloc = g_zalloc_wrapper;
stream.zfree = g_zfree_wrapper;
stream.opaque = NULL;
- if (inflateInit2 (&stream, 32 /* auto-detect */ + 15 /* max */ ) != Z_OK) {
+ if (inflateInit2
+ (&stream,
+ 32 /* auto-detect */ + 15 /* max */ ) != Z_OK) {
inflateEnd (&stream);
g_free (new_response);
g_debug ("Unable to decompress response from %s",
- message_path);
+ message_path);
data->status = SOUP_STATUS_MALFORMED;
} else {
do {
@@ -506,7 +507,9 @@ actual_http_response_handler (DAAPResponseData *data)
if (z_res == Z_STREAM_END) {
break;
}
- if ((z_res != Z_OK && z_res != Z_BUF_ERROR) || stream.avail_out != 0 || unc_size > 40*1000*1000) {
+ if ((z_res != Z_OK && z_res != Z_BUF_ERROR)
+ || stream.avail_out != 0
+ || unc_size > 40 * 1000 * 1000) {
inflateEnd (&stream);
g_free (new_response);
new_response = NULL;
@@ -519,9 +522,14 @@ actual_http_response_handler (DAAPResponseData *data)
* unc_size can't overflow, and this realloc
* call is safe
*/
- new_response = g_realloc (new_response, unc_size + 1);
- stream.next_out = (unsigned char *)(new_response + stream.total_out);
- stream.avail_out = unc_size - stream.total_out;
+ new_response =
+ g_realloc (new_response,
+ unc_size + 1);
+ stream.next_out =
+ (unsigned char *) (new_response +
+ stream.total_out);
+ stream.avail_out =
+ unc_size - stream.total_out;
} while (1);
}
@@ -530,8 +538,7 @@ actual_http_response_handler (DAAPResponseData *data)
response_length = stream.total_out;
}
#else
- g_debug ("Received compressed response from %s but can't handle it",
- message_path);
+ g_debug ("Received compressed response from %s but can't handle it", message_path);
data->status = SOUP_STATUS_MALFORMED;
#endif
}
@@ -545,50 +552,58 @@ actual_http_response_handler (DAAPResponseData *data)
} else if (SOUP_STATUS_IS_SUCCESSFUL (data->status)) {
DMAPStructureItem *item;
- if (/* FIXME: !rb_is_main_thread () */ TRUE) {
+ if ( /* FIXME: !rb_is_main_thread () */ TRUE) {
priv->progress = -1.0f;
if (priv->emit_progress_id != 0) {
g_source_remove (priv->emit_progress_id);
}
- priv->emit_progress_id = g_idle_add ((GSourceFunc) emit_progress_idle, data->connection);
+ priv->emit_progress_id =
+ g_idle_add ((GSourceFunc) emit_progress_idle,
+ data->connection);
}
structure = dmap_structure_parse (response, response_length);
if (structure == NULL) {
g_debug ("No daap structure returned from %s",
- message_path);
+ message_path);
data->status = SOUP_STATUS_MALFORMED;
} else {
int dmap_status = 0;
- item = dmap_structure_find_item (structure, DMAP_CC_MSTT);
+
+ item = dmap_structure_find_item (structure,
+ DMAP_CC_MSTT);
if (item) {
- dmap_status = g_value_get_int (&(item->content));
+ dmap_status =
+ g_value_get_int (&(item->content));
if (dmap_status != 200) {
- g_debug ("Error, dmap.status is not 200 in response from %s",
- message_path);
+ g_debug ("Error, dmap.status is not 200 in response from %s", message_path);
data->status = SOUP_STATUS_MALFORMED;
}
}
}
- if (/* FIXME: ! rb_is_main_thread () */ TRUE) {
+ if ( /* FIXME: ! rb_is_main_thread () */ TRUE) {
priv->progress = 1.0f;
if (priv->emit_progress_id != 0) {
g_source_remove (priv->emit_progress_id);
}
- priv->emit_progress_id = g_idle_add ((GSourceFunc) emit_progress_idle, data->connection);
+ priv->emit_progress_id =
+ g_idle_add ((GSourceFunc) emit_progress_idle,
+ data->connection);
}
} else {
g_debug ("Error getting %s: %d, %s\n",
- message_path,
- data->message->status_code,
- data->message->reason_phrase);
- connection_set_error_message (data->connection, data->message->reason_phrase);
+ message_path,
+ data->message->status_code,
+ data->message->reason_phrase);
+ connection_set_error_message (data->connection,
+ data->message->reason_phrase);
}
if (data->response_handler) {
- (*(data->response_handler)) (data->connection, data->status, structure, data->user_data);
+ (*(data->response_handler)) (data->connection, data->status,
+ structure, data->user_data);
}
if (structure) {
@@ -603,9 +618,8 @@ actual_http_response_handler (DAAPResponseData *data)
}
static void
-http_response_handler (SoupSession *session,
- SoupMessage *message,
- DAAPResponseData *data)
+http_response_handler (SoupSession * session,
+ SoupMessage * message, DAAPResponseData * data)
{
int response_length;
@@ -621,7 +635,7 @@ http_response_handler (SoupSession *session,
g_object_ref (G_OBJECT (message));
data->message = message;
- if (response_length >= G_MAXUINT/4 - 1) {
+ if (response_length >= G_MAXUINT / 4 - 1) {
/* If response_length is too big,
* the g_malloc (unc_size + 1) below would overflow
*/
@@ -629,13 +643,13 @@ http_response_handler (SoupSession *session,
}
/* to avoid blocking the UI, handle big responses in a separate thread */
- if (SOUP_STATUS_IS_SUCCESSFUL (data->status) && data->connection->priv->use_response_handler_thread) {
+ if (SOUP_STATUS_IS_SUCCESSFUL (data->status)
+ && data->connection->priv->use_response_handler_thread) {
GError *error = NULL;
+
g_debug ("creating thread to handle daap response");
g_thread_create ((GThreadFunc) actual_http_response_handler,
- data,
- FALSE,
- &error);
+ data, FALSE, &error);
if (error) {
g_warning ("fuck");
}
@@ -645,79 +659,72 @@ http_response_handler (SoupSession *session,
}
static gboolean
-http_get (DMAPConnection *connection,
- const char *path,
- gboolean need_hash,
- gdouble version,
- gint req_id,
- gboolean send_close,
- DMAPResponseHandler handler,
- gpointer user_data,
- gboolean use_thread)
+http_get (DMAPConnection * connection,
+ const char *path,
+ gboolean need_hash,
+ gdouble version,
+ gint req_id,
+ gboolean send_close,
+ DMAPResponseHandler handler,
+ gpointer user_data, gboolean use_thread)
{
DMAPConnectionPrivate *priv = connection->priv;
DAAPResponseData *data;
SoupMessage *message;
- message = dmap_connection_build_message (connection, path, need_hash, version, req_id, send_close);
+ message =
+ dmap_connection_build_message (connection, path, need_hash,
+ version, req_id, send_close);
if (message == NULL) {
g_debug ("Error building message for http://%s:%d/%s",
- priv->base_uri->host,
- priv->base_uri->port,
- path);
+ priv->base_uri->host, priv->base_uri->port, path);
return FALSE;
}
priv->use_response_handler_thread = use_thread;
-
+
data = g_new0 (DAAPResponseData, 1);
data->response_handler = handler;
data->user_data = user_data;
-
+
g_object_ref (G_OBJECT (connection));
data->connection = connection;
-
+
soup_session_queue_message (priv->session, message,
- (SoupSessionCallback) http_response_handler,
- data);
- g_debug ("Queued message for http://%s:%d/%s",
- priv->base_uri->host,
- priv->base_uri->port,
- path);
+ (SoupSessionCallback)
+ http_response_handler, data);
+ g_debug ("Queued message for http://%s:%d/%s", priv->base_uri->host,
+ priv->base_uri->port, path);
return TRUE;
}
gboolean
-dmap_connection_get (DMAPConnection *self,
- const gchar *path,
- gboolean need_hash,
- DMAPResponseHandler handler,
- gpointer user_data)
+dmap_connection_get (DMAPConnection * self,
+ const gchar * path,
+ gboolean need_hash,
+ DMAPResponseHandler handler, gpointer user_data)
{
- return http_get (self, path, need_hash,
- self->priv->dmap_version, 0, FALSE,
- (DMAPResponseHandler) handler, user_data, FALSE);
+ return http_get (self, path, need_hash,
+ self->priv->dmap_version, 0, FALSE,
+ (DMAPResponseHandler) handler, user_data, FALSE);
}
static gboolean
-emit_progress_idle (DMAPConnection *connection)
+emit_progress_idle (DMAPConnection * connection)
{
g_debug ("Emitting progress");
// FIXME: GDK_THREADS_ENTER ();
g_signal_emit (G_OBJECT (connection), signals[CONNECTING], 0,
- connection->priv->state,
- connection->priv->progress);
+ connection->priv->state, connection->priv->progress);
connection->priv->emit_progress_id = 0;
// FIXME: GDK_THREADS_LEAVE ();
return FALSE;
}
static void
-handle_server_info (DMAPConnection *connection,
- guint status,
- GNode *structure,
- gpointer user_data)
+handle_server_info (DMAPConnection * connection,
+ guint status, GNode * structure, gpointer user_data)
{
DMAPConnectionPrivate *priv = connection->priv;
DMAPStructureItem *item = NULL;
@@ -728,8 +735,11 @@ handle_server_info (DMAPConnection *connection,
}
/* get the daap version number */
- item = dmap_structure_find_item (structure,
- DMAP_CONNECTION_GET_CLASS(connection)->get_protocol_version_cc (connection));
+ item = dmap_structure_find_item (structure,
+ DMAP_CONNECTION_GET_CLASS
+ (connection)->
+ get_protocol_version_cc
+ (connection));
if (item == NULL) {
dmap_connection_state_done (connection, FALSE);
return;
@@ -740,21 +750,22 @@ handle_server_info (DMAPConnection *connection,
}
static void
-handle_login (DMAPConnection *connection,
- guint status,
- GNode *structure,
- gpointer user_data)
+handle_login (DMAPConnection * connection,
+ guint status, GNode * structure, gpointer user_data)
{
DMAPConnectionPrivate *priv = connection->priv;
DMAPStructureItem *item = NULL;
- if (status == SOUP_STATUS_UNAUTHORIZED || status == SOUP_STATUS_FORBIDDEN) {
+ if (status == SOUP_STATUS_UNAUTHORIZED
+ || status == SOUP_STATUS_FORBIDDEN) {
g_debug ("Incorrect password");
priv->state = DMAP_GET_PASSWORD;
if (priv->do_something_id != 0) {
g_source_remove (priv->do_something_id);
}
- priv->do_something_id = g_idle_add ((GSourceFunc) dmap_connection_do_something, connection);
+ priv->do_something_id =
+ g_idle_add ((GSourceFunc)
+ dmap_connection_do_something, connection);
return;
}
@@ -778,10 +789,8 @@ handle_login (DMAPConnection *connection,
}
static void
-handle_update (DMAPConnection *connection,
- guint status,
- GNode *structure,
- gpointer user_data)
+handle_update (DMAPConnection * connection,
+ guint status, GNode * structure, gpointer user_data)
{
DMAPConnectionPrivate *priv = connection->priv;
DMAPStructureItem *item;
@@ -804,10 +813,8 @@ handle_update (DMAPConnection *connection,
}
static void
-handle_database_info (DMAPConnection *connection,
- guint status,
- GNode *structure,
- gpointer user_data)
+handle_database_info (DMAPConnection * connection,
+ guint status, GNode * structure, gpointer user_data)
{
DMAPConnectionPrivate *priv = connection->priv;
DMAPStructureItem *item = NULL;
@@ -840,7 +847,8 @@ handle_database_info (DMAPConnection *connection,
return;
}
- item = dmap_structure_find_item (listing_node->children, DMAP_CC_MIID);
+ item = dmap_structure_find_item (listing_node->children,
+ DMAP_CC_MIID);
if (item == NULL) {
g_debug ("Could not find dmap.itemid item in /databases");
dmap_connection_state_done (connection, FALSE);
@@ -852,10 +860,8 @@ handle_database_info (DMAPConnection *connection,
}
static void
-handle_song_listing (DMAPConnection *connection,
- guint status,
- GNode *structure,
- gpointer user_data)
+handle_song_listing (DMAPConnection * connection,
+ guint status, GNode * structure, gpointer user_data)
{
DMAPConnectionPrivate *priv = connection->priv;
DMAPStructureItem *item = NULL;
@@ -876,8 +882,7 @@ handle_song_listing (DMAPConnection *connection,
item = dmap_structure_find_item (structure, DMAP_CC_MRCO);
if (item == NULL) {
- g_debug ("Could not find dmap.returnedcount item in /databases/%d/items",
- priv->database_id);
+ g_debug ("Could not find dmap.returnedcount item in /databases/%d/items", priv->database_id);
dmap_connection_state_done (connection, FALSE);
return;
}
@@ -890,8 +895,7 @@ handle_song_listing (DMAPConnection *connection,
item = dmap_structure_find_item (structure, DMAP_CC_MTCO);
if (item == NULL) {
- g_debug ("Could not find dmap.specifiedtotalcount item in /databases/%d/items",
- priv->database_id);
+ g_debug ("Could not find dmap.specifiedtotalcount item in /databases/%d/items", priv->database_id);
dmap_connection_state_done (connection, FALSE);
return;
}
@@ -899,8 +903,7 @@ handle_song_listing (DMAPConnection *connection,
item = dmap_structure_find_item (structure, DMAP_CC_MUTY);
if (item == NULL) {
- g_debug ("Could not find dmap.updatetype item in /databases/%d/items",
- priv->database_id);
+ g_debug ("Could not find dmap.updatetype item in /databases/%d/items", priv->database_id);
dmap_connection_state_done (connection, FALSE);
return;
}
@@ -908,40 +911,45 @@ handle_song_listing (DMAPConnection *connection,
listing_node = dmap_structure_find_node (structure, DMAP_CC_MLCL);
if (listing_node == NULL) {
- g_debug ("Could not find dmap.listing item in /databases/%d/items",
- priv->database_id);
+ g_debug ("Could not find dmap.listing item in /databases/%d/items", priv->database_id);
dmap_connection_state_done (connection, FALSE);
return;
}
/* FIXME: refstring: */
- priv->item_id_to_uri = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) g_free);
+ priv->item_id_to_uri =
+ g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
+ (GDestroyNotify) g_free);
priv->progress = 0.0f;
if (priv->emit_progress_id != 0) {
g_source_remove (priv->emit_progress_id);
}
- priv->emit_progress_id = g_idle_add ((GSourceFunc) emit_progress_idle, connection);
+ priv->emit_progress_id =
+ g_idle_add ((GSourceFunc) emit_progress_idle, connection);
for (i = 0, n = listing_node->children; n; i++, n = n->next) {
gint item_id = 0;
- DMAPRecord *record = DMAP_CONNECTION_GET_CLASS(connection)->handle_mlcl (connection, priv->record_factory, n, &item_id);
+ DMAPRecord *record =
+ DMAP_CONNECTION_GET_CLASS (connection)->
+ handle_mlcl (connection, priv->record_factory, n,
+ &item_id);
if (record) {
gchar *uri = NULL;
gchar *format = NULL;
-
+
g_object_get (record, "format", &format, NULL);
if (format == NULL) {
format = g_strdup ("Unknown");
}
- /*if (connection->dmap_version == 3.0) {*/
- uri = g_strdup_printf ("%s/databases/%d/items/%d.%s?session-id=%u",
- connection->priv->daap_base_uri,
- connection->priv->database_id,
- item_id, format,
- connection->priv->session_id);
- /*} else {*/
+ /*if (connection->dmap_version == 3.0) { */
+ uri = g_strdup_printf
+ ("%s/databases/%d/items/%d.%s?session-id=%u",
+ connection->priv->daap_base_uri,
+ connection->priv->database_id, item_id,
+ format, connection->priv->session_id);
+ /*} else { */
/* uri should be
* "/databases/%d/items/%d.%s?session-id=%u&revision-id=%d";
* but its not going to work cause the other parts of the code
@@ -950,12 +958,14 @@ handle_song_listing (DMAPConnection *connection,
* maybe just /dont/ support older itunes. doesn't seem
* unreasonable to me, honestly
*/
- /*}*/
+ /*} */
g_object_set (record, "location", uri, NULL);
dmap_db_add (connection->priv->db, record);
g_object_unref (record);
- g_hash_table_insert (connection->priv->item_id_to_uri, GINT_TO_POINTER (item_id), g_strdup (uri));
+ g_hash_table_insert (connection->priv->item_id_to_uri,
+ GINT_TO_POINTER (item_id),
+ g_strdup (uri));
g_free (uri);
g_free (format);
} else {
@@ -965,9 +975,12 @@ handle_song_listing (DMAPConnection *connection,
if (i % commit_batch == 0) {
priv->progress = ((float) i / (float) returned_count);
if (priv->emit_progress_id != 0) {
- g_source_remove (connection->priv->emit_progress_id);
+ g_source_remove (connection->priv->
+ emit_progress_id);
}
- priv->emit_progress_id = g_idle_add ((GSourceFunc) emit_progress_idle, connection);
+ priv->emit_progress_id =
+ g_idle_add ((GSourceFunc) emit_progress_idle,
+ connection);
}
}
@@ -975,12 +988,12 @@ handle_song_listing (DMAPConnection *connection,
}
static int
-compare_playlists_by_name(gconstpointer a, gconstpointer b)
+compare_playlists_by_name (gconstpointer a, gconstpointer b)
{
const DMAPPlaylist *playlist1 = a;
const DMAPPlaylist *playlist2 = b;
- return strcmp(playlist1->name, playlist2->name);
+ return strcmp (playlist1->name, playlist2->name);
}
/* FIXME
@@ -991,10 +1004,8 @@ compare_playlists_by_name(gconstpointer a, gconstpointer b)
*/
static void
-handle_playlists (DMAPConnection *connection,
- guint status,
- GNode *structure,
- gpointer user_data)
+handle_playlists (DMAPConnection * connection,
+ guint status, GNode * structure, gpointer user_data)
{
DMAPConnectionPrivate *priv = connection->priv;
GNode *listing_node;
@@ -1008,8 +1019,7 @@ handle_playlists (DMAPConnection *connection,
listing_node = dmap_structure_find_node (structure, DMAP_CC_MLCL);
if (listing_node == NULL) {
- g_debug ("Could not find dmap.listing item in /databases/%d/containers",
- priv->database_id);
+ g_debug ("Could not find dmap.listing item in /databases/%d/containers", priv->database_id);
dmap_connection_state_done (connection, FALSE);
return;
}
@@ -1027,16 +1037,14 @@ handle_playlists (DMAPConnection *connection,
item = dmap_structure_find_item (n, DMAP_CC_MIID);
if (item == NULL) {
- g_debug ("Could not find dmap.itemid item in /databases/%d/containers",
- priv->database_id);
+ g_debug ("Could not find dmap.itemid item in /databases/%d/containers", priv->database_id);
continue;
}
id = g_value_get_int (&(item->content));
item = dmap_structure_find_item (n, DMAP_CC_MINM);
if (item == NULL) {
- g_debug ("Could not find dmap.itemname item in /databases/%d/containers",
- priv->database_id);
+ g_debug ("Could not find dmap.itemname item in /databases/%d/containers", priv->database_id);
continue;
}
name = g_value_dup_string (&(item->content));
@@ -1044,23 +1052,23 @@ handle_playlists (DMAPConnection *connection,
playlist = g_new0 (DMAPPlaylist, 1);
playlist->id = id;
playlist->name = name;
- g_debug ("Got playlist %p: name %s, id %d", playlist, playlist->name, playlist->id);
+ g_debug ("Got playlist %p: name %s, id %d", playlist,
+ playlist->name, playlist->id);
priv->playlists = g_slist_prepend (priv->playlists, playlist);
}
/* Sort the playlists into lexical order. Established DAAP clients already
* do this leading to an absence of sorting functionality in DAAP servers. */
- priv->playlists = g_slist_sort (priv->playlists, compare_playlists_by_name);
+ priv->playlists =
+ g_slist_sort (priv->playlists, compare_playlists_by_name);
dmap_connection_state_done (connection, TRUE);
}
static void
-handle_playlist_entries (DMAPConnection *connection,
- guint status,
- GNode *structure,
- gpointer user_data)
+handle_playlist_entries (DMAPConnection * connection,
+ guint status, GNode * structure, gpointer user_data)
{
DMAPConnectionPrivate *priv = connection->priv;
DMAPPlaylist *playlist;
@@ -1074,40 +1082,44 @@ handle_playlist_entries (DMAPConnection *connection,
return;
}
- playlist = (DMAPPlaylist *)g_slist_nth_data (priv->playlists, priv->reading_playlist);
+ playlist =
+ (DMAPPlaylist *) g_slist_nth_data (priv->playlists,
+ priv->reading_playlist);
g_assert (playlist);
listing_node = dmap_structure_find_node (structure, DMAP_CC_MLCL);
if (listing_node == NULL) {
- g_debug ("Could not find dmap.listing item in /databases/%d/containers/%d/items",
- priv->database_id, playlist->id);
+ g_debug ("Could not find dmap.listing item in /databases/%d/containers/%d/items", priv->database_id, playlist->id);
dmap_connection_state_done (connection, FALSE);
return;
}
- for (i = 0, node = listing_node->children; node; node = node->next, i++) {
+ for (i = 0, node = listing_node->children; node;
+ node = node->next, i++) {
gchar *item_uri;
gint playlist_item_id;
DMAPStructureItem *item;
item = dmap_structure_find_item (node, DMAP_CC_MIID);
if (item == NULL) {
- g_debug ("Could not find dmap.itemid item in /databases/%d/containers/%d/items",
- priv->database_id, playlist->id);
+ g_debug ("Could not find dmap.itemid item in /databases/%d/containers/%d/items", priv->database_id, playlist->id);
continue;
}
playlist_item_id = g_value_get_int (&(item->content));
- item_uri = g_hash_table_lookup (priv->item_id_to_uri, GINT_TO_POINTER (playlist_item_id));
+ item_uri =
+ g_hash_table_lookup (priv->item_id_to_uri,
+ GINT_TO_POINTER
+ (playlist_item_id));
if (item_uri == NULL) {
- g_debug ("Entry %d in playlist %s doesn't exist in the database\n",
- playlist_item_id, playlist->name);
+ g_debug ("Entry %d in playlist %s doesn't exist in the database\n", playlist_item_id, playlist->name);
continue;
}
/* FIXME: Rhythmbox used "refstrings," so that the same memory would exist in both
* this list and the hash table. See FIXME: refstring thoughout. */
- playlist_uris = g_list_prepend (playlist_uris, g_strdup (item_uri));
+ playlist_uris =
+ g_list_prepend (playlist_uris, g_strdup (item_uri));
}
playlist->uris = g_list_reverse (playlist_uris);
@@ -1115,10 +1127,8 @@ handle_playlist_entries (DMAPConnection *connection,
}
static void
-handle_logout (DMAPConnection *connection,
- guint status,
- GNode *structure,
- gpointer user_data)
+handle_logout (DMAPConnection * connection,
+ guint status, GNode * structure, gpointer user_data)
{
connection_disconnected (connection);
@@ -1127,18 +1137,19 @@ handle_logout (DMAPConnection *connection,
}
gboolean
-dmap_connection_is_connected (DMAPConnection *connection)
+dmap_connection_is_connected (DMAPConnection * connection)
{
g_return_val_if_fail (IS_DMAP_CONNECTION (connection), FALSE);
return connection->priv->is_connected;
}
-typedef struct {
- DMAPConnection *connection;
+typedef struct
+{
+ DMAPConnection *connection;
DMAPConnectionCallback callback;
- gpointer data;
- GDestroyNotify destroy;
+ gpointer data;
+ GDestroyNotify destroy;
} ConnectionResponseData;
static void
@@ -1151,8 +1162,7 @@ connection_response_data_free (gpointer data)
}
static void
-connected_cb (DMAPConnection *connection,
- ConnectionResponseData *rdata)
+connected_cb (DMAPConnection * connection, ConnectionResponseData * rdata)
{
gboolean result;
@@ -1179,57 +1189,65 @@ connected_cb (DMAPConnection *connection,
}
}
-void
-dmap_connection_setup (DMAPConnection *connection)
+void
+dmap_connection_setup (DMAPConnection * connection)
{
connection->priv->session = soup_session_async_new ();
connection->priv->base_uri = soup_uri_new (NULL);
- soup_uri_set_scheme (connection->priv->base_uri, SOUP_URI_SCHEME_HTTP);
- soup_uri_set_host (connection->priv->base_uri, connection->priv->host);
- soup_uri_set_port (connection->priv->base_uri, connection->priv->port);
+ soup_uri_set_scheme (connection->priv->base_uri,
+ SOUP_URI_SCHEME_HTTP);
+ soup_uri_set_host (connection->priv->base_uri,
+ connection->priv->host);
+ soup_uri_set_port (connection->priv->base_uri,
+ connection->priv->port);
}
void
-dmap_connection_connect (DMAPConnection *connection,
- DMAPConnectionCallback callback,
- gpointer user_data)
+dmap_connection_connect (DMAPConnection * connection,
+ DMAPConnectionCallback callback, gpointer user_data)
{
ConnectionResponseData *rdata;
g_return_if_fail (IS_DMAP_CONNECTION (connection));
g_return_if_fail (connection->priv->state == DMAP_GET_INFO);
- g_debug ("Creating new DAAP connection to %s:%d", connection->priv->host, connection->priv->port);
+ g_debug ("Creating new DAAP connection to %s:%d",
+ connection->priv->host, connection->priv->port);
dmap_connection_setup (connection);
if (connection->priv->base_uri == NULL) {
- g_debug ("Error parsing http://%s:%d", connection->priv->host, connection->priv->port);
+ g_debug ("Error parsing http://%s:%d", connection->priv->host,
+ connection->priv->port);
/* FIXME: do callback */
return;
}
- connection->priv->daap_base_uri = g_strdup_printf ("daap://%s:%d", connection->priv->host, connection->priv->port);
+ connection->priv->daap_base_uri =
+ g_strdup_printf ("daap://%s:%d", connection->priv->host,
+ connection->priv->port);
rdata = g_new (ConnectionResponseData, 1);
rdata->connection = g_object_ref (connection);
rdata->callback = callback;
rdata->data = user_data;
rdata->destroy = connection_response_data_free;
- g_signal_connect (connection, "operation-done", G_CALLBACK (connected_cb), rdata);
+ g_signal_connect (connection, "operation-done",
+ G_CALLBACK (connected_cb), rdata);
if (connection->priv->do_something_id != 0) {
g_source_remove (connection->priv->do_something_id);
}
connection->priv->is_connecting = TRUE;
- connection->priv->do_something_id = g_idle_add ((GSourceFunc) dmap_connection_do_something, connection);
+ connection->priv->do_something_id =
+ g_idle_add ((GSourceFunc) dmap_connection_do_something,
+ connection);
}
static void
-disconnected_cb (DMAPConnection *connection,
- ConnectionResponseData *rdata)
+disconnected_cb (DMAPConnection * connection, ConnectionResponseData * rdata)
{
gboolean result;
@@ -1240,7 +1258,7 @@ disconnected_cb (DMAPConnection *connection,
rdata);
/* if not connected then we succeeded */
- result = ! dmap_connection_is_connected (connection);
+ result = !dmap_connection_is_connected (connection);
if (rdata->callback) {
rdata->callback (rdata->connection,
@@ -1255,7 +1273,7 @@ disconnected_cb (DMAPConnection *connection,
}
static void
-dmap_connection_finish (DMAPConnection *connection)
+dmap_connection_finish (DMAPConnection * connection)
{
g_return_if_fail (IS_DMAP_CONNECTION (connection));
@@ -1267,12 +1285,12 @@ dmap_connection_finish (DMAPConnection *connection)
}
void
-dmap_connection_disconnect (DMAPConnection *connection,
- DMAPConnectionCallback callback,
- gpointer user_data)
+dmap_connection_disconnect (DMAPConnection * connection,
+ DMAPConnectionCallback callback,
+ gpointer user_data)
{
DMAPConnectionPrivate *priv = connection->priv;
- ConnectionResponseData *rdata;
+ ConnectionResponseData *rdata;
g_return_if_fail (IS_DMAP_CONNECTION (connection));
@@ -1280,8 +1298,8 @@ dmap_connection_disconnect (DMAPConnection *connection,
if (connection->priv->is_connecting) {
/* this is a special case where the async connection
- hasn't returned yet so we need to force the connection
- to finish */
+ * hasn't returned yet so we need to force the connection
+ * to finish */
priv->state = DMAP_DONE;
// FIXME: GDK_THREADS_LEAVE ();
dmap_connection_finish (connection);
@@ -1294,13 +1312,14 @@ dmap_connection_disconnect (DMAPConnection *connection,
rdata->data = user_data;
rdata->destroy = connection_response_data_free;
- g_signal_connect (connection, "operation-done", G_CALLBACK (disconnected_cb), rdata);
+ g_signal_connect (connection, "operation-done",
+ G_CALLBACK (disconnected_cb), rdata);
if (priv->do_something_id != 0) {
g_source_remove (priv->do_something_id);
}
- if (! connection->priv->is_connected) {
+ if (!connection->priv->is_connected) {
priv->state = DMAP_DONE;
// FIXME: GDK_THREADS_LEAVE ();
dmap_connection_finish (connection);
@@ -1308,13 +1327,14 @@ dmap_connection_disconnect (DMAPConnection *connection,
} else {
priv->state = DMAP_LOGOUT;
- priv->do_something_id = g_idle_add ((GSourceFunc) dmap_connection_do_something, connection);
+ priv->do_something_id =
+ g_idle_add ((GSourceFunc)
+ dmap_connection_do_something, connection);
}
}
static void
-dmap_connection_state_done (DMAPConnection *connection,
- gboolean result)
+dmap_connection_state_done (DMAPConnection * connection, gboolean result)
{
DMAPConnectionPrivate *priv = connection->priv;
@@ -1333,7 +1353,8 @@ dmap_connection_state_done (DMAPConnection *connection,
break;
case DMAP_GET_PLAYLIST_ENTRIES:
/* keep reading playlists until we've got them all */
- if (++priv->reading_playlist >= g_slist_length (priv->playlists))
+ if (++priv->reading_playlist >=
+ g_slist_length (priv->playlists))
priv->state = DMAP_DONE;
break;
@@ -1360,17 +1381,21 @@ dmap_connection_state_done (DMAPConnection *connection,
if (connection->priv->emit_progress_id != 0) {
g_source_remove (connection->priv->emit_progress_id);
}
- connection->priv->emit_progress_id = g_idle_add ((GSourceFunc) emit_progress_idle, connection);
+ connection->priv->emit_progress_id =
+ g_idle_add ((GSourceFunc) emit_progress_idle,
+ connection);
}
if (priv->do_something_id != 0) {
g_source_remove (priv->do_something_id);
}
- priv->do_something_id = g_idle_add ((GSourceFunc) dmap_connection_do_something, connection);
+ priv->do_something_id =
+ g_idle_add ((GSourceFunc) dmap_connection_do_something,
+ connection);
}
static gboolean
-dmap_connection_do_something (DMAPConnection *connection)
+dmap_connection_do_something (DMAPConnection * connection)
{
DMAPConnectionPrivate *priv = connection->priv;
char *meta;
@@ -1383,8 +1408,9 @@ dmap_connection_do_something (DMAPConnection *connection)
switch (priv->state) {
case DMAP_GET_INFO:
g_debug ("Getting DAAP server info");
- if (! http_get (connection, "/server-info", FALSE, 0.0, 0, FALSE,
- (DMAPResponseHandler) handle_server_info, NULL, FALSE)) {
+ if (!http_get
+ (connection, "/server-info", FALSE, 0.0, 0, FALSE,
+ (DMAPResponseHandler) handle_server_info, NULL, FALSE)) {
g_debug ("Could not get DAAP connection info");
dmap_connection_state_done (connection, FALSE);
}
@@ -1397,7 +1423,8 @@ dmap_connection_do_something (DMAPConnection *connection)
g_free (priv->password);
priv->password = connection_get_password (connection);
- if (priv->password == NULL || priv->password[0] == '\0') {
+ if (priv->password == NULL
+ || priv->password[0] == '\0') {
g_debug ("Password entry cancelled");
priv->result = FALSE;
priv->state = DMAP_DONE;
@@ -1418,8 +1445,9 @@ dmap_connection_do_something (DMAPConnection *connection)
case DMAP_LOGIN:
g_debug ("Logging into DAAP server");
- if (! http_get (connection, "/login", FALSE, 0.0, 0, FALSE,
- (DMAPResponseHandler) handle_login, NULL, FALSE)) {
+ if (!http_get (connection, "/login", FALSE, 0.0, 0, FALSE,
+ (DMAPResponseHandler) handle_login, NULL,
+ FALSE)) {
g_debug ("Could not login to DAAP server");
/* FIXME: set state back to GET_PASSWORD to try again */
dmap_connection_state_done (connection, FALSE);
@@ -1429,9 +1457,12 @@ dmap_connection_do_something (DMAPConnection *connection)
case DMAP_GET_REVISION_NUMBER:
g_debug ("Getting DAAP server database revision number");
- path = g_strdup_printf ("/update?session-id=%u&revision-number=1", priv->session_id);
- if (! http_get (connection, path, TRUE, priv->dmap_version, 0, FALSE,
- (DMAPResponseHandler) handle_update, NULL, FALSE)) {
+ path = g_strdup_printf
+ ("/update?session-id=%u&revision-number=1",
+ priv->session_id);
+ if (!http_get
+ (connection, path, TRUE, priv->dmap_version, 0, FALSE,
+ (DMAPResponseHandler) handle_update, NULL, FALSE)) {
g_debug ("Could not get server database revision number");
dmap_connection_state_done (connection, FALSE);
}
@@ -1440,10 +1471,13 @@ dmap_connection_do_something (DMAPConnection *connection)
case DMAP_GET_DB_INFO:
g_debug ("Getting DAAP database info");
- path = g_strdup_printf ("/databases?session-id=%u&revision-number=%d",
- priv->session_id, priv->revision_number);
- if (! http_get (connection, path, TRUE, priv->dmap_version, 0, FALSE,
- (DMAPResponseHandler) handle_database_info, NULL, FALSE)) {
+ path = g_strdup_printf
+ ("/databases?session-id=%u&revision-number=%d",
+ priv->session_id, priv->revision_number);
+ if (!http_get
+ (connection, path, TRUE, priv->dmap_version, 0, FALSE,
+ (DMAPResponseHandler) handle_database_info, NULL,
+ FALSE)) {
g_debug ("Could not get DAAP database info");
dmap_connection_state_done (connection, FALSE);
}
@@ -1452,15 +1486,15 @@ dmap_connection_do_something (DMAPConnection *connection)
case DMAP_GET_SONGS:
g_debug ("Getting DAAP song listing");
- meta = DMAP_CONNECTION_GET_CLASS(connection)->get_query_metadata (connection);
- path = g_strdup_printf ("/databases/%i/items?session-id=%u&revision-number=%i"
- "&meta=%s",
- priv->database_id,
- priv->session_id,
- priv->revision_number,
- meta);
- if (! http_get (connection, path, TRUE, priv->dmap_version, 0, FALSE,
- (DMAPResponseHandler) handle_song_listing, NULL, TRUE)) {
+ meta = DMAP_CONNECTION_GET_CLASS (connection)->
+ get_query_metadata (connection);
+ path = g_strdup_printf
+ ("/databases/%i/items?session-id=%u&revision-number=%i"
+ "&meta=%s", priv->database_id, priv->session_id,
+ priv->revision_number, meta);
+ if (!http_get
+ (connection, path, TRUE, priv->dmap_version, 0, FALSE,
+ (DMAPResponseHandler) handle_song_listing, NULL, TRUE)) {
g_debug ("Could not get DAAP song listing");
dmap_connection_state_done (connection, FALSE);
}
@@ -1470,12 +1504,13 @@ dmap_connection_do_something (DMAPConnection *connection)
case DMAP_GET_PLAYLISTS:
g_debug ("Getting DAAP playlists");
- path = g_strdup_printf ("/databases/%d/containers?session-id=%u&revision-number=%d",
- priv->database_id,
- priv->session_id,
- priv->revision_number);
- if (! http_get (connection, path, TRUE, priv->dmap_version, 0, FALSE,
- (DMAPResponseHandler) handle_playlists, NULL, TRUE)) {
+ path = g_strdup_printf
+ ("/databases/%d/containers?session-id=%u&revision-number=%d",
+ priv->database_id, priv->session_id,
+ priv->revision_number);
+ if (!http_get
+ (connection, path, TRUE, priv->dmap_version, 0, FALSE,
+ (DMAPResponseHandler) handle_playlists, NULL, TRUE)) {
g_debug ("Could not get DAAP playlists");
dmap_connection_state_done (connection, FALSE);
}
@@ -1485,19 +1520,25 @@ dmap_connection_do_something (DMAPConnection *connection)
case DMAP_GET_PLAYLIST_ENTRIES:
{
DMAPPlaylist *playlist =
- (DMAPPlaylist *) g_slist_nth_data (priv->playlists,
- priv->reading_playlist);
+ (DMAPPlaylist *) g_slist_nth_data (priv->
+ playlists,
+ priv->
+ reading_playlist);
g_assert (playlist);
- g_debug ("Reading DAAP playlist %d entries", priv->reading_playlist);
- path = g_strdup_printf ("/databases/%d/containers/%d/items?session-id=%u&revision-number=%d&meta=dmap.itemid",
- priv->database_id,
- playlist->id,
- priv->session_id, priv->revision_number);
- if (! http_get (connection, path, TRUE, priv->dmap_version, 0, FALSE,
- (DMAPResponseHandler) handle_playlist_entries, NULL, TRUE)) {
- g_debug ("Could not get entries for DAAP playlist %d",
- priv->reading_playlist);
- dmap_connection_state_done (connection, FALSE);
+ g_debug ("Reading DAAP playlist %d entries",
+ priv->reading_playlist);
+ path = g_strdup_printf
+ ("/databases/%d/containers/%d/items?session-id=%u&revision-number=%d&meta=dmap.itemid",
+ priv->database_id, playlist->id,
+ priv->session_id, priv->revision_number);
+ if (!http_get
+ (connection, path, TRUE, priv->dmap_version, 0,
+ FALSE,
+ (DMAPResponseHandler) handle_playlist_entries,
+ NULL, TRUE)) {
+ g_debug ("Could not get entries for DAAP playlist %d", priv->reading_playlist);
+ dmap_connection_state_done (connection,
+ FALSE);
}
g_free (path);
}
@@ -1505,9 +1546,11 @@ dmap_connection_do_something (DMAPConnection *connection)
case DMAP_LOGOUT:
g_debug ("Logging out of DAAP server");
- path = g_strdup_printf ("/logout?session-id=%u", priv->session_id);
- if (! http_get (connection, path, TRUE, priv->dmap_version, 0, FALSE,
- (DMAPResponseHandler) handle_logout, NULL, FALSE)) {
+ path = g_strdup_printf ("/logout?session-id=%u",
+ priv->session_id);
+ if (!http_get
+ (connection, path, TRUE, priv->dmap_version, 0, FALSE,
+ (DMAPResponseHandler) handle_logout, NULL, FALSE)) {
g_debug ("Could not log out of DAAP server");
dmap_connection_state_done (connection, FALSE);
}
@@ -1527,13 +1570,12 @@ dmap_connection_do_something (DMAPConnection *connection)
}
SoupMessageHeaders *
-dmap_connection_get_headers (DMAPConnection *connection,
- const gchar *uri)
+dmap_connection_get_headers (DMAPConnection * connection, const gchar * uri)
{
DMAPConnectionPrivate *priv = connection->priv;
SoupMessageHeaders *headers = NULL;
- char hash[33] = {0};
- char *norb_daap_uri = (char *)uri;
+ char hash[33] = { 0 };
+ char *norb_daap_uri = (char *) uri;
char *request_id;
priv->request_id++;
@@ -1542,19 +1584,18 @@ dmap_connection_get_headers (DMAPConnection *connection,
norb_daap_uri = strstr (uri, "/data");
}
- dmap_hash_generate ((short)floorf (priv->dmap_version),
- (const guchar*)norb_daap_uri, 2,
- (guchar*)hash,
- priv->request_id);
+ dmap_hash_generate ((short) floorf (priv->dmap_version),
+ (const guchar *) norb_daap_uri, 2,
+ (guchar *) hash, priv->request_id);
headers = soup_message_headers_new (SOUP_MESSAGE_HEADERS_REQUEST);
soup_message_headers_append (headers, "Accept", "*/*");
soup_message_headers_append (headers, "Cache-Control", "no-cache");
soup_message_headers_append (headers, "Accept-Language",
- "en-us, en;q=5.0");
+ "en-us, en;q=5.0");
soup_message_headers_append (headers, "Client-DAAP-Access-Index",
- "2");
+ "2");
soup_message_headers_append (headers, "Client-DAAP-Version", "3.0");
soup_message_headers_append (headers, "Client-DAAP-Validation", hash);
@@ -1572,14 +1613,18 @@ dmap_connection_get_headers (DMAPConnection *connection,
g_debug ("No username or no password provided");
} else {
- user_pass = g_strdup_printf ("%s:%s", priv->username, priv->password);
- token = g_base64_encode ((guchar *)user_pass, strlen (user_pass));
+ user_pass =
+ g_strdup_printf ("%s:%s", priv->username,
+ priv->password);
+ token = g_base64_encode ((guchar *) user_pass,
+ strlen (user_pass));
h = g_strdup_printf ("Basic %s", token);
g_free (token);
g_free (user_pass);
- soup_message_headers_append (headers, "Authentication", h);
+ soup_message_headers_append (headers,
+ "Authentication", h);
g_free (h);
}
}
@@ -1588,13 +1633,13 @@ dmap_connection_get_headers (DMAPConnection *connection,
}
GSList *
-dmap_connection_get_playlists (DMAPConnection *connection)
+dmap_connection_get_playlists (DMAPConnection * connection)
{
return connection->priv->playlists;
}
static void
-dmap_connection_dispose (GObject *object)
+dmap_connection_dispose (GObject * object)
{
DMAPConnectionPrivate *priv = DMAP_CONNECTION (object)->priv;
GSList *l;
@@ -1687,10 +1732,9 @@ dmap_connection_dispose (GObject *object)
}
static void
-dmap_connection_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+dmap_connection_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
DMAPConnectionPrivate *priv = DMAP_CONNECTION (object)->priv;
@@ -1703,7 +1747,8 @@ dmap_connection_set_property (GObject *object,
priv->db = DMAP_DB (g_value_get_pointer (value));
break;
case PROP_FACTORY:
- priv->record_factory = DMAP_RECORD_FACTORY (g_value_get_pointer (value));
+ priv->record_factory =
+ DMAP_RECORD_FACTORY (g_value_get_pointer (value));
break;
case PROP_PASSWORD_PROTECTED:
priv->password_protected = g_value_get_boolean (value);
@@ -1737,10 +1782,9 @@ dmap_connection_set_property (GObject *object,
}
static void
-dmap_connection_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+dmap_connection_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
DMAPConnectionPrivate *priv = DMAP_CONNECTION (object)->priv;
diff --git a/libdmapsharing/dmap-connection.h b/libdmapsharing/dmap-connection.h
index c628fc0..22b8fed 100644
--- a/libdmapsharing/dmap-connection.h
+++ b/libdmapsharing/dmap-connection.h
@@ -29,11 +29,10 @@
#include <libdmapsharing/dmap-db.h>
#include <libdmapsharing/dmap-record-factory.h>
-G_BEGIN_DECLS
-
-typedef struct {
- char *name;
- int id;
+G_BEGIN_DECLS typedef struct
+{
+ char *name;
+ int id;
GList *uris;
} DMAPPlaylist;
@@ -87,7 +86,8 @@ typedef struct {
typedef struct DMAPConnectionPrivate DMAPConnectionPrivate;
-typedef enum {
+typedef enum
+{
DMAP_GET_INFO = 0,
DMAP_GET_PASSWORD,
DMAP_LOGIN,
@@ -100,79 +100,78 @@ typedef enum {
DMAP_DONE
} DMAPConnectionState;
-typedef struct {
+typedef struct
+{
GObject parent;
DMAPConnectionPrivate *priv;
} DMAPConnection;
-typedef struct {
+typedef struct
+{
GObjectClass parent;
/* Pure virtual methods: */
- DMAPContentCode (*get_protocol_version_cc) (DMAPConnection *connection);
- gchar * (*get_query_metadata) (DMAPConnection *connection);
- DMAPRecord *(*handle_mlcl) (DMAPConnection *connection, DMAPRecordFactory *factory, GNode *mlcl, gint *item_id);
-
- SoupMessage * (*build_message)
- (DMAPConnection *connection,
- const gchar *path,
- gboolean need_hash,
- gdouble version,
- gint req_id,
- gboolean send_close);
- void (* connected) (DMAPConnection *connection);
- void (* disconnected) (DMAPConnection *connection);
-
- char * (* authenticate) (DMAPConnection *connection,
- const char *name);
- void (* connecting) (DMAPConnection *connection,
- DMAPConnectionState state,
- float progress);
-
- void (* operation_done) (DMAPConnection *connection);
+ DMAPContentCode (*get_protocol_version_cc) (DMAPConnection *
+ connection);
+ gchar *(*get_query_metadata) (DMAPConnection * connection);
+ DMAPRecord *(*handle_mlcl) (DMAPConnection * connection,
+ DMAPRecordFactory * factory, GNode * mlcl,
+ gint * item_id);
+
+ SoupMessage *(*build_message)
+
+ (DMAPConnection * connection,
+ const gchar * path,
+ gboolean need_hash,
+ gdouble version, gint req_id, gboolean send_close);
+ void (*connected) (DMAPConnection * connection);
+ void (*disconnected) (DMAPConnection * connection);
+
+ char *(*authenticate) (DMAPConnection * connection, const char *name);
+ void (*connecting) (DMAPConnection * connection,
+ DMAPConnectionState state, float progress);
+
+ void (*operation_done) (DMAPConnection * connection);
} DMAPConnectionClass;
/* hmm, maybe should give more error information? */
-typedef gboolean (* DMAPConnectionCallback) (DMAPConnection *connection,
- gboolean result,
- const char *reason,
- gpointer user_data);
-
-typedef void (* DMAPResponseHandler) (DMAPConnection *connection,
- guint status,
- GNode *structure,
- gpointer user_data);
-
-GType dmap_connection_get_type (void);
-
-gboolean dmap_connection_is_connected (DMAPConnection *connection);
-void dmap_connection_setup (DMAPConnection *connection);
-void dmap_connection_connect (DMAPConnection *connection,
- DMAPConnectionCallback callback,
- gpointer user_data);
-void dmap_connection_disconnect (DMAPConnection *connection,
- DMAPConnectionCallback callback,
- gpointer user_data);
-
-SoupMessageHeaders *dmap_connection_get_headers (DMAPConnection *connection,
- const char *uri);
-
-GSList * dmap_connection_get_playlists (DMAPConnection *connection);
-
-SoupMessage * dmap_connection_build_message (DMAPConnection *connection,
- const gchar *path,
- gboolean need_hash,
- gdouble version,
- gint req_id,
- gboolean send_close);
-
-gboolean dmap_connection_get (DMAPConnection *self,
- const gchar *path,
- gboolean need_hash,
- DMAPResponseHandler handler,
- gpointer user_data);
+typedef gboolean (*DMAPConnectionCallback) (DMAPConnection * connection,
+ gboolean result,
+ const char *reason,
+ gpointer user_data);
+
+typedef void (*DMAPResponseHandler) (DMAPConnection * connection,
+ guint status,
+ GNode * structure, gpointer user_data);
+
+GType dmap_connection_get_type (void);
+
+gboolean dmap_connection_is_connected (DMAPConnection * connection);
+void dmap_connection_setup (DMAPConnection * connection);
+void dmap_connection_connect (DMAPConnection * connection,
+ DMAPConnectionCallback callback,
+ gpointer user_data);
+void dmap_connection_disconnect (DMAPConnection * connection,
+ DMAPConnectionCallback callback,
+ gpointer user_data);
+
+SoupMessageHeaders *dmap_connection_get_headers (DMAPConnection * connection,
+ const char *uri);
+
+GSList *dmap_connection_get_playlists (DMAPConnection * connection);
+
+SoupMessage *dmap_connection_build_message (DMAPConnection * connection,
+ const gchar * path,
+ gboolean need_hash,
+ gdouble version,
+ gint req_id, gboolean send_close);
+
+gboolean dmap_connection_get (DMAPConnection * self,
+ const gchar * path,
+ gboolean need_hash,
+ DMAPResponseHandler handler,
+ gpointer user_data);
G_END_DECLS
-
#endif /* __DMAP_CONNECTION_H */
diff --git a/libdmapsharing/dmap-container-db.c b/libdmapsharing/dmap-container-db.c
index 4198301..fdce883 100644
--- a/libdmapsharing/dmap-container-db.c
+++ b/libdmapsharing/dmap-container-db.c
@@ -23,13 +23,13 @@
static gint dmap_container_db_init_count = 0;
static void
-dmap_container_db_init (DMAPContainerDbIface *iface)
+dmap_container_db_init (DMAPContainerDbIface * iface)
{
- dmap_container_db_init_count++;
+ dmap_container_db_init_count++;
}
static void
-dmap_container_db_finalize (DMAPContainerDbIface *iface)
+dmap_container_db_finalize (DMAPContainerDbIface * iface)
{
dmap_container_db_init_count--;
}
@@ -39,37 +39,37 @@ GType
dmap_container_db_get_type (void)
{
static GType object_type = 0;
+
if (!object_type) {
static const GTypeInfo object_info = {
- sizeof(DMAPContainerDbIface),
+ sizeof (DMAPContainerDbIface),
(GBaseInitFunc) dmap_container_db_init,
(GBaseFinalizeFunc) dmap_container_db_finalize
};
object_type =
- g_type_register_static(G_TYPE_INTERFACE,
- "DMAPContainerDb",
- &object_info, 0);
- g_type_interface_add_prerequisite (object_type, G_TYPE_OBJECT);
+ g_type_register_static (G_TYPE_INTERFACE,
+ "DMAPContainerDb",
+ &object_info, 0);
+ g_type_interface_add_prerequisite (object_type,
+ G_TYPE_OBJECT);
}
return object_type;
}
DMAPContainerRecord *
-dmap_container_db_lookup_by_id (DMAPContainerDb *db, guint id)
+dmap_container_db_lookup_by_id (DMAPContainerDb * db, guint id)
{
return DMAP_CONTAINER_DB_GET_INTERFACE (db)->lookup_by_id (db, id);
}
void
-dmap_container_db_foreach (DMAPContainerDb *db,
- GHFunc func,
- gpointer data)
+dmap_container_db_foreach (DMAPContainerDb * db, GHFunc func, gpointer data)
{
DMAP_CONTAINER_DB_GET_INTERFACE (db)->foreach (db, func, data);
}
gulong
-dmap_container_db_count (DMAPContainerDb *db)
+dmap_container_db_count (DMAPContainerDb * db)
{
return DMAP_CONTAINER_DB_GET_INTERFACE (db)->count (db);
}
diff --git a/libdmapsharing/dmap-container-db.h b/libdmapsharing/dmap-container-db.h
index 528f3fb..e19d23f 100644
--- a/libdmapsharing/dmap-container-db.h
+++ b/libdmapsharing/dmap-container-db.h
@@ -26,7 +26,6 @@
#include <libdmapsharing/dmap-container-record.h>
G_BEGIN_DECLS
-
/**
* DMAP_TYPE_CONTAINER_DB:
*
@@ -62,23 +61,21 @@ G_BEGIN_DECLS
*/
#define DMAP_CONTAINER_DB_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), \
DMAP_TYPE_CONTAINER_DB, DMAPContainerDbIface))
-
typedef struct _DMAPContainerDb DMAPContainerDb;
typedef struct _DMAPContainerDbIface DMAPContainerDbIface;
-struct _DMAPContainerDbIface {
+struct _DMAPContainerDbIface
+{
GTypeInterface parent;
- DMAPContainerRecord *(*lookup_by_id) (DMAPContainerDb *db, guint id);
+ DMAPContainerRecord *(*lookup_by_id) (DMAPContainerDb * db, guint id);
- void (*foreach) (DMAPContainerDb *db,
- GHFunc func,
- gpointer data);
+ void (*foreach) (DMAPContainerDb * db, GHFunc func, gpointer data);
- gint64 (*count) (DMAPContainerDb *db);
+ gint64 (*count) (DMAPContainerDb * db);
};
-GType dmap_container_db_get_type (void);
+GType dmap_container_db_get_type (void);
/**
* dmap_container_db_lookup_by_id:
@@ -88,7 +85,8 @@ GType dmap_container_db_get_type (void);
* Returns: the database record corresponding to @id. This record should
* be unrefed when no longer required.
*/
-DMAPContainerRecord *dmap_container_db_lookup_by_id (DMAPContainerDb *db, guint id);
+DMAPContainerRecord *dmap_container_db_lookup_by_id (DMAPContainerDb * db,
+ guint id);
/**
* dmap_container_db_foreach:
@@ -98,9 +96,8 @@ DMAPContainerRecord *dmap_container_db_lookup_by_id (DMAPContainerDb *db, gui
*
* Apply a function to each record in a container database.
*/
-void dmap_container_db_foreach (DMAPContainerDb *db,
- GHFunc func,
- gpointer data);
+void dmap_container_db_foreach (DMAPContainerDb * db,
+ GHFunc func, gpointer data);
/**
* dmap_container_db_count:
@@ -108,7 +105,7 @@ void dmap_container_db_foreach (DMAPContainerDb *db,
*
* Returns: the number of records in the database.
*/
-gulong dmap_container_db_count (DMAPContainerDb *db);
+gulong dmap_container_db_count (DMAPContainerDb * db);
#endif /* __DMAP_CONTAINER_DB_H */
diff --git a/libdmapsharing/dmap-container-record.c b/libdmapsharing/dmap-container-record.c
index 932fedb..2d1a227 100644
--- a/libdmapsharing/dmap-container-record.c
+++ b/libdmapsharing/dmap-container-record.c
@@ -23,26 +23,26 @@
static gint dmap_container_record_init_count = 0;
static void
-dmap_container_record_init (DMAPContainerRecordIface *iface)
+dmap_container_record_init (DMAPContainerRecordIface * iface)
{
static gboolean is_initialized = FALSE;
- dmap_container_record_init_count++;
+ dmap_container_record_init_count++;
- if (! is_initialized) {
+ if (!is_initialized) {
g_object_interface_install_property (iface,
- g_param_spec_string ("name",
- "Container name",
- "Container name",
- NULL,
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("name",
+ "Container name",
+ "Container name", NULL,
+ G_PARAM_READWRITE));
is_initialized = TRUE;
}
}
static void
-dmap_container_record_finalize (DMAPContainerRecordIface *iface)
+dmap_container_record_finalize (DMAPContainerRecordIface * iface)
{
dmap_container_record_init_count--;
}
@@ -52,42 +52,45 @@ GType
dmap_container_record_get_type (void)
{
static GType object_type = 0;
+
if (!object_type) {
static const GTypeInfo object_info = {
- sizeof(DMAPContainerRecordIface),
+ sizeof (DMAPContainerRecordIface),
(GBaseInitFunc) dmap_container_record_init,
(GBaseFinalizeFunc) dmap_container_record_finalize
};
object_type =
- g_type_register_static(G_TYPE_INTERFACE,
- "DMAPContainerRecord",
- &object_info, 0);
+ g_type_register_static (G_TYPE_INTERFACE,
+ "DMAPContainerRecord",
+ &object_info, 0);
}
return object_type;
}
guint
-dmap_container_record_get_id (DMAPContainerRecord *record)
+dmap_container_record_get_id (DMAPContainerRecord * record)
{
return DMAP_CONTAINER_RECORD_GET_INTERFACE (record)->get_id (record);
}
void
-dmap_container_record_add_entry (DMAPContainerRecord *container_record,
- DMAPRecord *record,
- gint id)
+dmap_container_record_add_entry (DMAPContainerRecord * container_record,
+ DMAPRecord * record, gint id)
{
- DMAP_CONTAINER_RECORD_GET_INTERFACE (container_record)->add_entry (container_record, record, id);
+ DMAP_CONTAINER_RECORD_GET_INTERFACE (container_record)->
+ add_entry (container_record, record, id);
}
guint64
-dmap_container_record_get_entry_count (DMAPContainerRecord *record)
+dmap_container_record_get_entry_count (DMAPContainerRecord * record)
{
- return DMAP_CONTAINER_RECORD_GET_INTERFACE (record)->get_entry_count (record);
+ return DMAP_CONTAINER_RECORD_GET_INTERFACE (record)->
+ get_entry_count (record);
}
DMAPDb *
-dmap_container_record_get_entries (DMAPContainerRecord *record)
+dmap_container_record_get_entries (DMAPContainerRecord * record)
{
- return DMAP_CONTAINER_RECORD_GET_INTERFACE (record)->get_entries (record);
+ return DMAP_CONTAINER_RECORD_GET_INTERFACE (record)->
+ get_entries (record);
}
diff --git a/libdmapsharing/dmap-container-record.h b/libdmapsharing/dmap-container-record.h
index 5567e63..a2df44b 100644
--- a/libdmapsharing/dmap-container-record.h
+++ b/libdmapsharing/dmap-container-record.h
@@ -25,7 +25,6 @@
#include <libdmapsharing/dmap-db.h>
G_BEGIN_DECLS
-
/**
* DMAP_TYPE_CONTAINER_RECORD:
*
@@ -61,23 +60,24 @@ G_BEGIN_DECLS
*/
#define DMAP_CONTAINER_RECORD_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), \
DMAP_TYPE_CONTAINER_RECORD, DMAPContainerRecordIface))
-
typedef struct _DMAPContainerRecord DMAPContainerRecord;
typedef struct _DMAPContainerRecordIface DMAPContainerRecordIface;
-struct _DMAPContainerRecordIface {
+struct _DMAPContainerRecordIface
+{
GTypeInterface parent;
-
- guint (*get_id) (DMAPContainerRecord *record);
- void (*add_entry) (DMAPContainerRecord *container_record, DMAPRecord *record, gint id);
+ guint (*get_id) (DMAPContainerRecord * record);
+
+ void (*add_entry) (DMAPContainerRecord * container_record,
+ DMAPRecord * record, gint id);
- guint64 (*get_entry_count) (DMAPContainerRecord *record);
+ guint64 (*get_entry_count) (DMAPContainerRecord * record);
- DMAPDb *(*get_entries) (DMAPContainerRecord *record);
+ DMAPDb *(*get_entries) (DMAPContainerRecord * record);
};
-GType dmap_container_record_get_type (void);
+GType dmap_container_record_get_type (void);
/**
* dmap_container_record_get_id:
@@ -85,7 +85,7 @@ GType dmap_container_record_get_type (void);
*
* Returns: the ID for the given record.
*/
-guint dmap_container_record_get_id (DMAPContainerRecord *record);
+guint dmap_container_record_get_id (DMAPContainerRecord * record);
/**
* dmap_container_record_add_entry:
@@ -96,9 +96,8 @@ guint dmap_container_record_get_id (DMAPContainerRecord *record)
* Add a record to the database. It is assumed that the record is placed
* directly into the database (not copied) and not freed.
*/
-void dmap_container_record_add_entry (DMAPContainerRecord *container_record,
- DMAPRecord *record,
- gint id);
+void dmap_container_record_add_entry (DMAPContainerRecord * container_record,
+ DMAPRecord * record, gint id);
/**
* dmap_container_record_get_entry_count:
@@ -106,7 +105,7 @@ void dmap_container_record_add_entry (DMAPContainerRecord *contain
*
* Returns: the number of records in the container record.
*/
-guint64 dmap_container_record_get_entry_count (DMAPContainerRecord *record);
+guint64 dmap_container_record_get_entry_count (DMAPContainerRecord * record);
/**
* dmap_container_record_get_entries:
@@ -114,7 +113,7 @@ guint64 dmap_container_record_get_entry_count (DMAPContainerRecord *record)
*
* Returns: A pointer to a DMAPDb containing the entries contained in record.
*/
-DMAPDb *dmap_container_record_get_entries (DMAPContainerRecord *record);
+DMAPDb *dmap_container_record_get_entries (DMAPContainerRecord * record);
#endif /* __DMAP_CONTAINER_RECORD_H */
diff --git a/libdmapsharing/dmap-db.c b/libdmapsharing/dmap-db.c
index 193073f..fab799e 100644
--- a/libdmapsharing/dmap-db.c
+++ b/libdmapsharing/dmap-db.c
@@ -22,7 +22,8 @@
#include <string.h>
#include <libdmapsharing/dmap-db.h>
-typedef struct FilterData {
+typedef struct FilterData
+{
DMAPDb *db;
GSList *filter_def;
GHashTable *ht;
@@ -31,13 +32,13 @@ typedef struct FilterData {
static gint dmap_db_init_count = 0;
static void
-dmap_db_init (DMAPDbIface *iface)
+dmap_db_init (DMAPDbIface * iface)
{
dmap_db_init_count++;
}
static void
-dmap_db_finalize (DMAPDbIface *iface)
+dmap_db_finalize (DMAPDbIface * iface)
{
dmap_db_init_count--;
}
@@ -47,67 +48,67 @@ GType
dmap_db_get_type (void)
{
static GType object_type = 0;
+
if (!object_type) {
static const GTypeInfo object_info = {
- sizeof(DMAPDbIface),
+ sizeof (DMAPDbIface),
(GBaseInitFunc) dmap_db_init,
(GBaseFinalizeFunc) dmap_db_finalize
};
object_type =
- g_type_register_static(G_TYPE_INTERFACE,
- "DMAPDb",
- &object_info, 0);
- g_type_interface_add_prerequisite (object_type, G_TYPE_OBJECT);
+ g_type_register_static (G_TYPE_INTERFACE,
+ "DMAPDb", &object_info, 0);
+ g_type_interface_add_prerequisite (object_type,
+ G_TYPE_OBJECT);
}
return object_type;
}
DMAPRecord *
-dmap_db_lookup_by_id (const DMAPDb *db, guint id)
+dmap_db_lookup_by_id (const DMAPDb * db, guint id)
{
return DMAP_DB_GET_INTERFACE (db)->lookup_by_id (db, id);
}
guint
-dmap_db_lookup_id_by_location (const DMAPDb *db, const gchar *location)
+dmap_db_lookup_id_by_location (const DMAPDb * db, const gchar * location)
{
- return DMAP_DB_GET_INTERFACE (db)->lookup_id_by_location (db, location);
+ return DMAP_DB_GET_INTERFACE (db)->lookup_id_by_location (db,
+ location);
}
void
-dmap_db_foreach (const DMAPDb *db,
- GHFunc func,
- gpointer data)
+dmap_db_foreach (const DMAPDb * db, GHFunc func, gpointer data)
{
DMAP_DB_GET_INTERFACE (db)->foreach (db, func, data);
}
guint
-dmap_db_add (DMAPDb *db, DMAPRecord *record)
+dmap_db_add (DMAPDb * db, DMAPRecord * record)
{
return DMAP_DB_GET_INTERFACE (db)->add (db, record);
}
guint
-dmap_db_add_with_id (DMAPDb *db, DMAPRecord *record, guint id)
+dmap_db_add_with_id (DMAPDb * db, DMAPRecord * record, guint id)
{
return DMAP_DB_GET_INTERFACE (db)->add_with_id (db, record, id);
}
guint
-dmap_db_add_path (DMAPDb *db, const gchar *path)
+dmap_db_add_path (DMAPDb * db, const gchar * path)
{
return DMAP_DB_GET_INTERFACE (db)->add_path (db, path);
}
gulong
-dmap_db_count (const DMAPDb *db)
+dmap_db_count (const DMAPDb * db)
{
return DMAP_DB_GET_INTERFACE (db)->count (db);
}
gchar **
-_dmap_db_strsplit_using_quotes (const gchar *str)
+_dmap_db_strsplit_using_quotes (const gchar * str)
{
/* What we are splitting looks something like this:
* 'foo'text to ignore'bar'.
@@ -117,6 +118,7 @@ _dmap_db_strsplit_using_quotes (const gchar *str)
if (str != NULL) {
int i, j;
+
fnval = g_strsplit (str, "\'", 0);
for (i = j = 0; fnval[i]; i++) {
@@ -134,10 +136,11 @@ _dmap_db_strsplit_using_quotes (const gchar *str)
continue;
/* Handle mistaken split at escaped '. */
- if (token[strlen(token) - 1] == '\\') {
- token = g_strconcat (fnval[i], "'", fnval[i+1], NULL);
+ if (token[strlen (token) - 1] == '\\') {
+ token = g_strconcat (fnval[i], "'",
+ fnval[i + 1], NULL);
g_free (fnval[i]);
- g_free (fnval[i+1]);
+ g_free (fnval[i + 1]);
i++;
}
@@ -148,19 +151,21 @@ _dmap_db_strsplit_using_quotes (const gchar *str)
fnval[j] = 0x00;
}
- return fnval;
+ return fnval;
}
static gboolean
-compare_record_property (DMAPRecord *record, const gchar *property_name, const gchar *property_value)
+compare_record_property (DMAPRecord * record, const gchar * property_name,
+ const gchar * property_value)
{
GParamSpec *pspec;
- GValue value = {0,};
- /* Note that this string belongs to value and will not be freed explicitely.*/
+ GValue value = { 0, };
+ /* Note that this string belongs to value and will not be freed explicitely. */
const gchar *str_value;
gboolean accept;
-
- pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (record), property_name);
+
+ pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (record),
+ property_name);
if (pspec == NULL)
// Can't find the property in this record, so don't accept it.
@@ -174,37 +179,45 @@ compare_record_property (DMAPRecord *record, const gchar *property_name, const g
if (G_VALUE_HOLDS_STRING (&value)) {
str_value = g_value_get_string (&value);
} else if (G_VALUE_HOLDS_BOOLEAN (&value)) {
- accept = (g_value_get_boolean (&value) && \
- g_strcmp0 (property_value, "1") == 0);
+ accept = (g_value_get_boolean (&value) &&
+ g_strcmp0 (property_value, "1") == 0);
g_value_unset (&value);
return accept;
- } else if (g_value_type_transformable (G_VALUE_TYPE (&value), G_TYPE_LONG)) {
+ } else if (g_value_type_transformable
+ (G_VALUE_TYPE (&value), G_TYPE_LONG)) {
// Prefer integer conversion.
- GValue dest = {0,};
+ GValue dest = { 0, };
g_value_init (&dest, G_TYPE_LONG);
if (!g_value_transform (&value, &dest)) {
- g_warning ("Failed to convert value into long for property %s", property_name);
+ g_warning
+ ("Failed to convert value into long for property %s",
+ property_name);
g_value_unset (&value);
return FALSE;
}
- accept = (g_value_get_long (&dest) == strtol (property_value, NULL, 10));
+ accept = (g_value_get_long (&dest) ==
+ strtol (property_value, NULL, 10));
g_value_unset (&value);
return accept;
- } else if (g_value_type_transformable (G_VALUE_TYPE (&value), G_TYPE_STRING)) {
+ } else if (g_value_type_transformable
+ (G_VALUE_TYPE (&value), G_TYPE_STRING)) {
// Use standard transform functions from GLib (note that these
// functions are unreliable and known cases should be handled
// above).
GValue dest;
+
g_value_init (&dest, G_TYPE_STRING);
if (!g_value_transform (&value, &dest)) {
- g_warning ("Failed to convert value into string for property %s", property_name);
+ g_warning
+ ("Failed to convert value into string for property %s",
+ property_name);
g_value_unset (&value);
return FALSE;
}
str_value = g_value_dup_string (&dest);
g_value_reset (&value);
//Sets the string to value so that it will be freed later.
- g_value_take_string (&value, (gchar *)str_value);
+ g_value_take_string (&value, (gchar *) str_value);
g_value_unset (&dest);
} else {
g_value_unset (&value);
@@ -212,7 +225,7 @@ compare_record_property (DMAPRecord *record, const gchar *property_name, const g
}
// Only arrive here if we are handling strings.
- if (str_value != NULL && property_value != NULL && \
+ if (str_value != NULL && property_value != NULL &&
g_ascii_strcasecmp (str_value, property_value) == 0) {
accept = TRUE;
} else if (str_value == NULL && property_value == NULL) {
@@ -228,7 +241,7 @@ compare_record_property (DMAPRecord *record, const gchar *property_name, const g
}
static void
-apply_filter (gpointer id, DMAPRecord *record, gpointer data)
+apply_filter (gpointer id, DMAPRecord * record, gpointer data)
{
FilterData *fd;
gboolean accept = FALSE;
@@ -238,24 +251,28 @@ apply_filter (gpointer id, DMAPRecord *record, gpointer data)
g_return_if_fail (record != NULL);
g_return_if_fail (G_IS_OBJECT (record));
-
+
fd = data;
if (fd->filter_def == NULL) {
- g_hash_table_insert (fd->ht, GUINT_TO_POINTER (id), g_object_ref (record));
+ g_hash_table_insert (fd->ht, GUINT_TO_POINTER (id),
+ g_object_ref (record));
return;
- }
-
+ }
+
GSList *list, *filter;
+
for (list = fd->filter_def; list != NULL; list = list->next) {
- for (filter = list->data; filter != NULL; filter = filter->next) {
+ for (filter = list->data; filter != NULL;
+ filter = filter->next) {
FilterDefinition *def = filter->data;
const gchar *property_name;
- query_key = def->key;
+ query_key = def->key;
query_value = def->value;
if (g_strcmp0 (query_key, "dmap.itemid") == 0) {
- if (GPOINTER_TO_UINT (id) == strtoul (query_value, NULL, 10)) {
+ if (GPOINTER_TO_UINT (id) ==
+ strtoul (query_value, NULL, 10)) {
accept = TRUE;
break;
}
@@ -270,11 +287,13 @@ apply_filter (gpointer id, DMAPRecord *record, gpointer data)
//Don't include the dot in the property name.
property_name++;
- accept = compare_record_property (record, property_name, query_value);
-
+ accept = compare_record_property (record,
+ property_name,
+ query_value);
+
if (def->negate)
accept = !accept;
-
+
// If we accept this value, then quit looking at this
// group (groups are always OR)
if (accept)
@@ -286,17 +305,19 @@ apply_filter (gpointer id, DMAPRecord *record, gpointer data)
break;
}
if (accept) {
- g_hash_table_insert (fd->ht, GUINT_TO_POINTER (id), g_object_ref (record));
+ g_hash_table_insert (fd->ht, GUINT_TO_POINTER (id),
+ g_object_ref (record));
}
}
GHashTable *
-dmap_db_apply_filter (DMAPDb *db, GSList *filter_def)
+dmap_db_apply_filter (DMAPDb * db, GSList * filter_def)
{
GHashTable *ht;
FilterData data;
- ht = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_object_unref);
+ ht = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
+ g_object_unref);
data.db = db;
data.filter_def = filter_def;
data.ht = ht;
diff --git a/libdmapsharing/dmap-db.h b/libdmapsharing/dmap-db.h
index ea40fa7..86fec42 100644
--- a/libdmapsharing/dmap-db.h
+++ b/libdmapsharing/dmap-db.h
@@ -26,7 +26,6 @@
#include <libdmapsharing/dmap-record.h>
G_BEGIN_DECLS
-
/**
* DMAP_TYPE_DB:
*
@@ -61,36 +60,33 @@ G_BEGIN_DECLS
*/
#define DMAP_DB_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), \
DMAP_TYPE_DB, DMAPDbIface))
-
typedef struct _DMAPDb DMAPDb;
typedef struct _DMAPDbIface DMAPDbIface;
-struct _DMAPDbIface {
+struct _DMAPDbIface
+{
GTypeInterface parent;
- guint (*add) (DMAPDb *db, DMAPRecord *record);
- guint (*add_with_id) (DMAPDb *db,
- DMAPRecord *record,
- guint id);
- guint (*add_path) (DMAPDb *db, const gchar *path);
- DMAPRecord *(*lookup_by_id) (const DMAPDb *db, guint id);
- guint (*lookup_id_by_location) (const DMAPDb *db,
- const gchar *location);
- void (*foreach) (const DMAPDb *db,
- GHFunc func,
- gpointer data);
- gint64 (*count) (const DMAPDb *db);
+ guint (*add) (DMAPDb * db, DMAPRecord * record);
+ guint (*add_with_id) (DMAPDb * db, DMAPRecord * record, guint id);
+ guint (*add_path) (DMAPDb * db, const gchar * path);
+ DMAPRecord *(*lookup_by_id) (const DMAPDb * db, guint id);
+ guint (*lookup_id_by_location) (const DMAPDb * db,
+ const gchar * location);
+ void (*foreach) (const DMAPDb * db, GHFunc func, gpointer data);
+ gint64 (*count) (const DMAPDb * db);
};
-typedef const char *(*RecordGetValueFunc) (DMAPRecord *record);
+typedef const char *(*RecordGetValueFunc) (DMAPRecord * record);
-typedef struct FilterDefinition {
+typedef struct FilterDefinition
+{
gchar *key;
gchar *value;
gboolean negate;
} FilterDefinition;
-GType dmap_db_get_type (void);
+GType dmap_db_get_type (void);
/**
* dmap_db_add:
@@ -105,7 +101,7 @@ GType dmap_db_get_type (void);
* be placed elsewhere). In all cases, the record should be unrefed by the
* calling code.
*/
-guint dmap_db_add (DMAPDb *db, DMAPRecord *record);
+guint dmap_db_add (DMAPDb * db, DMAPRecord * record);
/**
* dmap_db_add:
@@ -119,7 +115,7 @@ guint dmap_db_add (DMAPDb *db, DMAPRecord *record);
*
* See also the notes for dmap_db_add regarding reference counting.
*/
-guint dmap_db_add_with_id (DMAPDb *db, DMAPRecord *record, guint id);
+guint dmap_db_add_with_id (DMAPDb * db, DMAPRecord * record, guint id);
/**
* dmap_db_add_path:
@@ -132,7 +128,7 @@ guint dmap_db_add_with_id (DMAPDb *db, DMAPRecord *record, guint id);
*
* See also the notes for dmap_db_add regarding reference counting.
*/
-guint dmap_db_add_path (DMAPDb *db, const gchar *path);
+guint dmap_db_add_path (DMAPDb * db, const gchar * path);
/**
* dmap_db_lookup_by_id:
@@ -153,7 +149,7 @@ guint dmap_db_add_path (DMAPDb *db, const gchar *path);
* In this case, the reference count should not be incremented before
* returning a record pointer.
*/
-DMAPRecord *dmap_db_lookup_by_id (const DMAPDb *db, guint id);
+DMAPRecord *dmap_db_lookup_by_id (const DMAPDb * db, guint id);
/**
* dmap_db_lookup_id_by_location:
@@ -163,7 +159,8 @@ DMAPRecord *dmap_db_lookup_by_id (const DMAPDb *db, guint id);
* Returns: the database id for the record corresponding to @path or 0 if
* such a record does not exist.
*/
-guint dmap_db_lookup_id_by_location (const DMAPDb *db, const gchar *location);
+guint dmap_db_lookup_id_by_location (const DMAPDb * db,
+ const gchar * location);
/**
* dmap_db_foreach:
@@ -173,9 +170,7 @@ guint dmap_db_lookup_id_by_location (const DMAPDb *db, const gchar *location);
*
* Apply a function to each record in a media database.
*/
-void dmap_db_foreach (const DMAPDb *db,
- GHFunc func,
- gpointer data);
+void dmap_db_foreach (const DMAPDb * db, GHFunc func, gpointer data);
/**
* dmap_db_count:
@@ -183,11 +178,11 @@ void dmap_db_foreach (const DMAPDb *db,
*
* Returns: the number of records in the database.
*/
-gulong dmap_db_count (const DMAPDb *db);
+gulong dmap_db_count (const DMAPDb * db);
-gchar **_dmap_db_strsplit_using_quotes (const gchar *str);
+gchar **_dmap_db_strsplit_using_quotes (const gchar * str);
-GHashTable *dmap_db_apply_filter (DMAPDb *db, GSList *filter_def);
+GHashTable *dmap_db_apply_filter (DMAPDb * db, GSList * filter_def);
#endif /* __DMAP_DB_H */
diff --git a/libdmapsharing/dmap-gst-input-stream.c b/libdmapsharing/dmap-gst-input-stream.c
index a2438a6..e18f0b1 100644
--- a/libdmapsharing/dmap-gst-input-stream.c
+++ b/libdmapsharing/dmap-gst-input-stream.c
@@ -33,7 +33,8 @@
#define QUEUE_PUSH_WAIT_SECONDS 10
#define QUEUE_POP_WAIT_SECONDS 1
-struct dmap_gst_format {
+struct dmap_gst_format
+{
gchar *id; /* E.g., used as command line arguments. */
gchar *extension; /* E.g., iTunes uses URI extension to
* determine stream format.
@@ -41,22 +42,23 @@ struct dmap_gst_format {
};
/* NOTE: Roku clients require lower case extension. */
-static const struct dmap_gst_format dmap_gst_formats[] = {
- { "raw", "raw" },
- { "wav16", "wav" },
- { "mp3", "mp3" },
- { NULL, NULL }
+static const struct dmap_gst_format dmap_gst_formats[] = {
+ {"raw", "raw"},
+ {"wav16", "wav"},
+ {"mp3", "mp3"},
+ {NULL, NULL}
};
-struct DMAPGstInputStreamPrivate {
+struct DMAPGstInputStreamPrivate
+{
GQueue *buffer;
- gsize read_request; /* Size of data asked for */
- gsize write_request; /* Number of bytes that must be read
- * to make room for write */
+ gsize read_request; /* Size of data asked for */
+ gsize write_request; /* Number of bytes that must be read
+ * to make room for write */
GCond *buffer_read_ready; /* Signals when buffer >= read_req. */
GCond *buffer_write_ready; /* Signals when buffer not full. */
- GMutex *buffer_mutex; /* Protects buffer and read_request */
- gboolean buffer_closed; /* May close before decoding complete */
+ GMutex *buffer_mutex; /* Protects buffer and read_request */
+ gboolean buffer_closed; /* May close before decoding complete */
};
#define DMAP_GST_INPUT_STREAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
@@ -64,7 +66,7 @@ struct DMAPGstInputStreamPrivate {
DMAPGstInputStreamPrivate))
static goffset
-dmap_gst_input_stream_tell (GSeekable *seekable)
+dmap_gst_input_stream_tell (GSeekable * seekable)
{
/* FIXME: implement return current position in stream. */
g_error ("Not implemented");
@@ -72,17 +74,16 @@ dmap_gst_input_stream_tell (GSeekable *seekable)
}
static gboolean
-dmap_gst_input_stream_can_seek (GSeekable *seekable)
+dmap_gst_input_stream_can_seek (GSeekable * seekable)
{
return TRUE;
}
static gboolean
-dmap_gst_input_stream_seek (GSeekable *seekable,
- goffset offset,
- GSeekType type,
- GCancellable *cacellable,
- GError **error)
+dmap_gst_input_stream_seek (GSeekable * seekable,
+ goffset offset,
+ GSeekType type,
+ GCancellable * cacellable, GError ** error)
{
DMAPGstInputStream *stream;
goffset absolute;
@@ -92,64 +93,63 @@ dmap_gst_input_stream_seek (GSeekable *seekable,
switch (type) {
/* FIXME: implement:
* case G_SEEK_CUR:
- * absolute = stream->priv->pos + offset;
- * break;
+ * absolute = stream->priv->pos + offset;
+ * break;
*
* case G_SEEK_END:
- * absolute = stream->priv->len + offset;
- * break;
+ * absolute = stream->priv->len + offset;
+ * break;
*/
- case G_SEEK_SET:
- absolute = offset;
- break;
+ case G_SEEK_SET:
+ absolute = offset;
+ break;
- default:
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_INVALID_ARGUMENT,
- "Invalid GSeekType supplied");
+ default:
+ g_set_error (error,
+ G_IO_ERROR,
+ G_IO_ERROR_INVALID_ARGUMENT,
+ "Invalid GSeekType supplied");
return FALSE;
}
/* FIXME: implement:
* if (absolute < 0 || absolute > stream->priv->len) {
- * g_set_error_literal (error,
- * G_IO_ERROR,
- * G_IO_ERROR_INVALID_ARGUMENT,
- * _("Invalid seek request"));
- * return FALSE;
+ * g_set_error_literal (error,
+ * G_IO_ERROR,
+ * G_IO_ERROR_INVALID_ARGUMENT,
+ * _("Invalid seek request"));
+ * return FALSE;
* }
*/
/* FIXME:
- if (! gst_element_seek_simple (DMAP_GST_INPUT_STREAM (seekable)->priv->pipeline,
- GST_FORMAT_BYTES,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
- absolute)) {
- g_set_error (error,
- G_IO_ERROR,
- G_IO_ERROR_FAILED,
- "Seek failed");
- return FALSE;
- }
- */
+ * if (! gst_element_seek_simple (DMAP_GST_INPUT_STREAM (seekable)->priv->pipeline,
+ * GST_FORMAT_BYTES,
+ * GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
+ * absolute)) {
+ * g_set_error (error,
+ * G_IO_ERROR,
+ * G_IO_ERROR_FAILED,
+ * "Seek failed");
+ * return FALSE;
+ * }
+ */
return TRUE;
}
static gboolean
-dmap_gst_input_stream_can_truncate (GSeekable *seekable)
+dmap_gst_input_stream_can_truncate (GSeekable * seekable)
{
return FALSE;
}
static gboolean
-dmap_gst_input_stream_truncate (GSeekable *seekable,
- goffset offset,
- GCancellable *cancellable,
- GError **error)
+dmap_gst_input_stream_truncate (GSeekable * seekable,
+ goffset offset,
+ GCancellable * cancellable, GError ** error)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"Cannot truncate DMAPGstInputStream");
@@ -157,17 +157,18 @@ dmap_gst_input_stream_truncate (GSeekable *seekable,
}
static void
-dmap_gst_input_stream_seekable_iface_init (GSeekableIface *iface)
+dmap_gst_input_stream_seekable_iface_init (GSeekableIface * iface)
{
- iface->tell = dmap_gst_input_stream_tell;
- iface->can_seek = dmap_gst_input_stream_can_seek;
- iface->seek = dmap_gst_input_stream_seek;
+ iface->tell = dmap_gst_input_stream_tell;
+ iface->can_seek = dmap_gst_input_stream_can_seek;
+ iface->seek = dmap_gst_input_stream_seek;
iface->can_truncate = dmap_gst_input_stream_can_truncate;
- iface->truncate_fn = dmap_gst_input_stream_truncate;
+ iface->truncate_fn = dmap_gst_input_stream_truncate;
}
void
-dmap_gst_input_stream_new_buffer_cb (GstElement *element, DMAPGstInputStream *stream)
+dmap_gst_input_stream_new_buffer_cb (GstElement * element,
+ DMAPGstInputStream * stream)
{
gsize i;
guint8 *ptr;
@@ -196,11 +197,13 @@ dmap_gst_input_stream_new_buffer_cb (GstElement *element, DMAPGstInputStream *st
}
/* FIXME: this actually allows buffer to grow larger than max. */
- if (g_queue_get_length (stream->priv->buffer) + GST_BUFFER_SIZE (buffer)> DECODED_BUFFER_SIZE) {
+ if (g_queue_get_length (stream->priv->buffer) +
+ GST_BUFFER_SIZE (buffer) > DECODED_BUFFER_SIZE) {
stream->priv->write_request = GST_BUFFER_SIZE (buffer);
- if (! g_cond_timed_wait (stream->priv->buffer_write_ready,
- stream->priv->buffer_mutex, &time)) {
- g_warning ("Timeout waiting for buffer to empty; will drop");
+ if (!g_cond_timed_wait (stream->priv->buffer_write_ready,
+ stream->priv->buffer_mutex, &time)) {
+ g_warning
+ ("Timeout waiting for buffer to empty; will drop");
}
/* Required again because g_cond_timed_wait released mutex. */
if (stream->priv->buffer_closed) {
@@ -211,11 +214,13 @@ dmap_gst_input_stream_new_buffer_cb (GstElement *element, DMAPGstInputStream *st
stream->priv->write_request = 0;
}
- if (g_queue_get_length (stream->priv->buffer) + GST_BUFFER_SIZE (buffer) <= DECODED_BUFFER_SIZE) {
+ if (g_queue_get_length (stream->priv->buffer) +
+ GST_BUFFER_SIZE (buffer) <= DECODED_BUFFER_SIZE) {
ptr = GST_BUFFER_DATA (buffer);
for (i = 0; i < GST_BUFFER_SIZE (buffer); i++) {
- g_queue_push_tail (stream->priv->buffer, GINT_TO_POINTER((gint) *ptr++));
+ g_queue_push_tail (stream->priv->buffer,
+ GINT_TO_POINTER ((gint) * ptr++));
}
}
@@ -227,22 +232,27 @@ dmap_gst_input_stream_new_buffer_cb (GstElement *element, DMAPGstInputStream *st
g_cond_signal (stream->priv->buffer_read_ready);
}
-_return:
+ _return:
g_mutex_unlock (stream->priv->buffer_mutex);
}
-GInputStream* dmap_gst_input_stream_new (const gchar *transcode_mimetype, GInputStream *src_stream)
+GInputStream *
+dmap_gst_input_stream_new (const gchar * transcode_mimetype,
+ GInputStream * src_stream)
{
GInputStream *stream;
- if (! transcode_mimetype) {
+ if (!transcode_mimetype) {
stream = src_stream;
- } else if (! strcmp (transcode_mimetype, "audio/mp3")) {
- stream = G_INPUT_STREAM (dmap_gst_mp3_input_stream_new (src_stream));
- } else if (! strcmp (transcode_mimetype, "audio/wav")) {
- stream = G_INPUT_STREAM (dmap_gst_wav_input_stream_new (src_stream));
+ } else if (!strcmp (transcode_mimetype, "audio/mp3")) {
+ stream = G_INPUT_STREAM (dmap_gst_mp3_input_stream_new
+ (src_stream));
+ } else if (!strcmp (transcode_mimetype, "audio/wav")) {
+ stream = G_INPUT_STREAM (dmap_gst_wav_input_stream_new
+ (src_stream));
} else {
- g_warning ("Transcode format %s not supported", transcode_mimetype);
+ g_warning ("Transcode format %s not supported",
+ transcode_mimetype);
stream = src_stream;
}
@@ -262,11 +272,10 @@ min (gssize a, gssize b)
}
static gssize
-dmap_gst_input_stream_read (GInputStream *stream,
- void *buffer,
- gsize count,
- GCancellable *cancellable,
- GError **error)
+dmap_gst_input_stream_read (GInputStream * stream,
+ void *buffer,
+ gsize count,
+ GCancellable * cancellable, GError ** error)
{
int i;
DMAPGstInputStream *gst_stream = DMAP_GST_INPUT_STREAM (stream);
@@ -279,9 +288,8 @@ dmap_gst_input_stream_read (GInputStream *stream,
gst_stream->priv->read_request = count;
if (g_queue_get_length (gst_stream->priv->buffer) < count
- && ! g_cond_timed_wait (gst_stream->priv->buffer_read_ready,
- gst_stream->priv->buffer_mutex,
- &time)) {
+ && !g_cond_timed_wait (gst_stream->priv->buffer_read_ready,
+ gst_stream->priv->buffer_mutex, &time)) {
/* Timeout: Count is now what's remaining. Let's hope
* we have enough of a lead on encoding so that this one
* second timeout will go unnoticed.
@@ -290,13 +298,14 @@ dmap_gst_input_stream_read (GInputStream *stream,
/* Depending on timing, more data may have been written
* since check: do not pull more than count:
*/
- count = min (count, g_queue_get_length (
- gst_stream->priv->buffer));
+ count = min (count,
+ g_queue_get_length (gst_stream->priv->buffer));
}
for (i = 0; i < count; i++) {
- ((guint8 *) buffer)[i] = GPOINTER_TO_INT (
- g_queue_pop_head (gst_stream->priv->buffer));
+ ((guint8 *) buffer)[i] =
+ GPOINTER_TO_INT (g_queue_pop_head
+ (gst_stream->priv->buffer));
}
if (gst_stream->priv->write_request > count)
@@ -314,25 +323,23 @@ dmap_gst_input_stream_read (GInputStream *stream,
}
static gssize
-dmap_gst_input_stream_skip (GInputStream *stream,
+dmap_gst_input_stream_skip (GInputStream * stream,
gsize count,
- GCancellable *cancellable,
- GError **error)
+ GCancellable * cancellable, GError ** error)
{
g_error ("Not implemented");
return 0;
}
static void
-dmap_gst_input_stream_kill_pipeline (DMAPGstInputStream *stream)
+dmap_gst_input_stream_kill_pipeline (DMAPGstInputStream * stream)
{
DMAP_GST_INPUT_STREAM_GET_CLASS (stream)->kill_pipeline (stream);
}
static gboolean
-dmap_gst_input_stream_close (GInputStream *stream,
- GCancellable *cancellable,
- GError **error)
+dmap_gst_input_stream_close (GInputStream * stream,
+ GCancellable * cancellable, GError ** error)
{
DMAPGstInputStream *gst_stream = DMAP_GST_INPUT_STREAM (stream);
@@ -349,83 +356,80 @@ dmap_gst_input_stream_close (GInputStream *stream,
}
static gssize
-dmap_gst_input_stream_read_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
+dmap_gst_input_stream_read_finish (GInputStream * stream,
+ GAsyncResult * result, GError ** error)
{
g_error ("Not implemented");
return 0;
}
static gssize
-dmap_gst_input_stream_skip_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
+dmap_gst_input_stream_skip_finish (GInputStream * stream,
+ GAsyncResult * result, GError ** error)
{
g_error ("Not implemented");
return 0;
}
static void
-dmap_gst_input_stream_close_async (GInputStream *stream,
- int io_priority,
- GCancellable *cancellabl,
- GAsyncReadyCallback callback,
- gpointer data)
+dmap_gst_input_stream_close_async (GInputStream * stream,
+ int io_priority,
+ GCancellable * cancellabl,
+ GAsyncReadyCallback callback,
+ gpointer data)
{
}
static void
-dmap_gst_input_stream_read_async (GInputStream *stream,
- void *buffer,
- gsize count,
- int io_priority,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data)
+dmap_gst_input_stream_read_async (GInputStream * stream,
+ void *buffer,
+ gsize count,
+ int io_priority,
+ GCancellable * cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
}
static void
-dmap_gst_input_stream_skip_async (GInputStream *stream,
- gsize count,
- int io_priority,
- GCancellable *cancellabl,
- GAsyncReadyCallback callback,
- gpointer datae)
+dmap_gst_input_stream_skip_async (GInputStream * stream,
+ gsize count,
+ int io_priority,
+ GCancellable * cancellabl,
+ GAsyncReadyCallback callback,
+ gpointer datae)
{
}
static gboolean
-dmap_gst_input_stream_close_finish (GInputStream *stream,
- GAsyncResult *result,
- GError **error)
+dmap_gst_input_stream_close_finish (GInputStream * stream,
+ GAsyncResult * result, GError ** error)
{
g_error ("Not implemented");
return FALSE;
}
static void
-dmap_gst_input_stream_class_init (DMAPGstInputStreamClass *klass)
+dmap_gst_input_stream_class_init (DMAPGstInputStreamClass * klass)
{
GInputStreamClass *istream_class;
g_type_class_add_private (klass, sizeof (DMAPGstInputStreamPrivate));
istream_class = G_INPUT_STREAM_CLASS (klass);
- istream_class->read_fn = dmap_gst_input_stream_read;
- istream_class->skip = dmap_gst_input_stream_skip;
- istream_class->close_fn = dmap_gst_input_stream_close;
- istream_class->read_async = dmap_gst_input_stream_read_async;
- istream_class->read_finish = dmap_gst_input_stream_read_finish;
- istream_class->skip_async = dmap_gst_input_stream_skip_async;
- istream_class->skip_finish = dmap_gst_input_stream_skip_finish;
- istream_class->close_async = dmap_gst_input_stream_close_async;
+ istream_class->read_fn = dmap_gst_input_stream_read;
+ istream_class->skip = dmap_gst_input_stream_skip;
+ istream_class->close_fn = dmap_gst_input_stream_close;
+ istream_class->read_async = dmap_gst_input_stream_read_async;
+ istream_class->read_finish = dmap_gst_input_stream_read_finish;
+ istream_class->skip_async = dmap_gst_input_stream_skip_async;
+ istream_class->skip_finish = dmap_gst_input_stream_skip_finish;
+ istream_class->close_async = dmap_gst_input_stream_close_async;
istream_class->close_finish = dmap_gst_input_stream_close_finish;
}
static void
-dmap_gst_input_stream_init (DMAPGstInputStream *stream)
+dmap_gst_input_stream_init (DMAPGstInputStream * stream)
{
stream->priv = DMAP_GST_INPUT_STREAM_GET_PRIVATE (stream);
@@ -441,4 +445,4 @@ dmap_gst_input_stream_init (DMAPGstInputStream *stream)
G_DEFINE_TYPE_WITH_CODE (DMAPGstInputStream, dmap_gst_input_stream,
G_TYPE_INPUT_STREAM,
G_IMPLEMENT_INTERFACE (G_TYPE_SEEKABLE,
- dmap_gst_input_stream_seekable_iface_init))
+ dmap_gst_input_stream_seekable_iface_init))
diff --git a/libdmapsharing/dmap-gst-input-stream.h b/libdmapsharing/dmap-gst-input-stream.h
index 3493d19..1abfa25 100644
--- a/libdmapsharing/dmap-gst-input-stream.h
+++ b/libdmapsharing/dmap-gst-input-stream.h
@@ -27,7 +27,6 @@
#include <gio/gio.h>
G_BEGIN_DECLS
-
#define DMAP_TYPE_GST_INPUT_STREAM (dmap_gst_input_stream_get_type ())
#define DMAP_GST_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
DMAP_TYPE_GST_INPUT_STREAM, \
@@ -42,31 +41,34 @@ G_BEGIN_DECLS
#define DMAP_GST_INPUT_STREAM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
DMAP_TYPE_GST_INPUT_STREAM, \
DMAPGstInputStreamClass))
-
typedef struct DMAPGstInputStreamPrivate DMAPGstInputStreamPrivate;
-typedef struct {
+typedef struct
+{
GInputStream parent;
DMAPGstInputStreamPrivate *priv;
} DMAPGstInputStream;
-typedef struct {
+typedef struct
+{
GInputStreamClass parent;
void (*kill_pipeline) (DMAPGstInputStream *);
} DMAPGstInputStreamClass;
-GType dmap_gst_input_stream_get_type (void);
+GType dmap_gst_input_stream_get_type (void);
/* Supported transcode target formats (data read from DMAPGstInputStream
* will be in one of these formats): */
-enum {
- RAW, /* No transcoding performed. */
- WAV16,
+enum
+{
+ RAW, /* No transcoding performed. */
+ WAV16,
MP3
};
-GInputStream* dmap_gst_input_stream_new (const gchar *transcode_mimetype, GInputStream *src_stream);
+GInputStream *dmap_gst_input_stream_new (const gchar * transcode_mimetype,
+ GInputStream * src_stream);
/* FIXME: this prototype was moved to the specific implementations in order to make this header file work without GStreamer installed:
void dmap_gst_input_stream_new_buffer_cb (GstElement *element,
@@ -76,5 +78,4 @@ void dmap_gst_input_stream_new_buffer_cb (GstElement *element,
gchar *dmapd_input_stream_strdup_format_extension (const gint format_code);
G_END_DECLS
-
#endif /* __DMAP_GST_INPUT_STREAM */
diff --git a/libdmapsharing/dmap-gst-mp3-input-stream.c b/libdmapsharing/dmap-gst-mp3-input-stream.c
index 9c31a3c..d543641 100644
--- a/libdmapsharing/dmap-gst-mp3-input-stream.c
+++ b/libdmapsharing/dmap-gst-mp3-input-stream.c
@@ -28,7 +28,8 @@
#define GST_APP_MAX_BUFFERS 1024
-struct DMAPGstMP3InputStreamPrivate {
+struct DMAPGstMP3InputStreamPrivate
+{
GstElement *pipeline;
GstElement *src;
GstElement *decode;
@@ -38,14 +39,13 @@ struct DMAPGstMP3InputStreamPrivate {
};
/* FIXME: See note in dmap-gst-input-stream.h */
-void dmap_gst_input_stream_new_buffer_cb (GstElement *element,
- DMAPGstInputStream *stream);
+void dmap_gst_input_stream_new_buffer_cb (GstElement * element,
+ DMAPGstInputStream * stream);
static void
-new_decoded_pad_cb (GstElement *element,
- GstPad *pad,
- gboolean arg,
- DMAPGstMP3InputStream *stream)
+new_decoded_pad_cb (GstElement * element,
+ GstPad * pad,
+ gboolean arg, DMAPGstMP3InputStream * stream)
{
/* Link remaining pad after decodebin does its magic. */
GstPad *conv_pad;
@@ -54,8 +54,9 @@ new_decoded_pad_cb (GstElement *element,
g_assert (conv_pad != NULL);
if (pads_compatible (pad, conv_pad)) {
- g_assert (! GST_PAD_IS_LINKED (
- gst_element_get_static_pad (stream->priv->convert, "sink")));
+ g_assert (!GST_PAD_IS_LINKED
+ (gst_element_get_static_pad
+ (stream->priv->convert, "sink")));
gst_pad_link (pad, conv_pad);
@@ -70,64 +71,76 @@ new_decoded_pad_cb (GstElement *element,
}
}
-GInputStream* dmap_gst_mp3_input_stream_new (GInputStream *src_stream)
+GInputStream *
+dmap_gst_mp3_input_stream_new (GInputStream * src_stream)
{
GstStateChangeReturn sret;
GstState state;
DMAPGstMP3InputStream *stream;
- stream = DMAP_GST_MP3_INPUT_STREAM (g_object_new (DMAP_TYPE_GST_MP3_INPUT_STREAM,
- NULL));
+ stream = DMAP_GST_MP3_INPUT_STREAM (g_object_new
+ (DMAP_TYPE_GST_MP3_INPUT_STREAM,
+ NULL));
stream->priv->pipeline = gst_pipeline_new ("pipeline");
- stream->priv->src = gst_element_factory_make ("giostreamsrc", "src");
+ stream->priv->src = gst_element_factory_make ("giostreamsrc", "src");
g_assert (GST_IS_ELEMENT (stream->priv->src));
- stream->priv->decode = gst_element_factory_make ("decodebin", "decode");
+ stream->priv->decode =
+ gst_element_factory_make ("decodebin", "decode");
g_assert (GST_IS_ELEMENT (stream->priv->decode));
- stream->priv->convert = gst_element_factory_make ("audioconvert", "convert");
+ stream->priv->convert =
+ gst_element_factory_make ("audioconvert", "convert");
g_assert (GST_IS_ELEMENT (stream->priv->convert));
- stream->priv->encode = gst_element_factory_make ("lame", "encode");
+ stream->priv->encode = gst_element_factory_make ("lame", "encode");
g_assert (GST_IS_ELEMENT (stream->priv->encode));
- stream->priv->sink = gst_element_factory_make ("appsink", "sink");
+ stream->priv->sink = gst_element_factory_make ("appsink", "sink");
g_assert (GST_IS_ELEMENT (stream->priv->sink));
gst_bin_add_many (GST_BIN (stream->priv->pipeline),
stream->priv->src,
stream->priv->decode,
stream->priv->convert,
- stream->priv->encode,
- stream->priv->sink,
- NULL);
+ stream->priv->encode, stream->priv->sink, NULL);
- if (gst_element_link (stream->priv->src, stream->priv->decode) == FALSE) {
+ if (gst_element_link (stream->priv->src, stream->priv->decode) ==
+ FALSE) {
g_warning ("Error linking source and decode elements");
}
g_assert (G_IS_INPUT_STREAM (src_stream));
- g_object_set (G_OBJECT (stream->priv->src), "stream", src_stream, NULL);
+ g_object_set (G_OBJECT (stream->priv->src), "stream", src_stream,
+ NULL);
/* quality=9 is important for fast, realtime transcoding: */
g_object_set (G_OBJECT (stream->priv->encode), "quality", 9, NULL);
g_object_set (G_OBJECT (stream->priv->encode), "bitrate", 128, NULL);
g_object_set (G_OBJECT (stream->priv->encode), "vbr", 0, NULL);
- g_signal_connect (stream->priv->decode, "new-decoded-pad", G_CALLBACK (new_decoded_pad_cb), stream);
+ g_signal_connect (stream->priv->decode, "new-decoded-pad",
+ G_CALLBACK (new_decoded_pad_cb), stream);
- g_object_set (G_OBJECT (stream->priv->sink), "emit-signals", TRUE, "sync", FALSE, NULL);
+ g_object_set (G_OBJECT (stream->priv->sink), "emit-signals", TRUE,
+ "sync", FALSE, NULL);
gst_app_sink_set_max_buffers (GST_APP_SINK (stream->priv->sink),
GST_APP_MAX_BUFFERS);
gst_app_sink_set_drop (GST_APP_SINK (stream->priv->sink), FALSE);
- g_signal_connect (stream->priv->sink, "new-buffer", G_CALLBACK (dmap_gst_input_stream_new_buffer_cb), stream);
+ g_signal_connect (stream->priv->sink, "new-buffer",
+ G_CALLBACK (dmap_gst_input_stream_new_buffer_cb),
+ stream);
/* FIXME: this technique is shared with dmapd-daap-share.c */
- sret = gst_element_set_state (stream->priv->pipeline, GST_STATE_PLAYING);
+ sret = gst_element_set_state (stream->priv->pipeline,
+ GST_STATE_PLAYING);
if (GST_STATE_CHANGE_ASYNC == sret) {
- if (GST_STATE_CHANGE_SUCCESS != gst_element_get_state (GST_ELEMENT (stream->priv->pipeline), &state, NULL, 5 * GST_SECOND)) {
+ if (GST_STATE_CHANGE_SUCCESS !=
+ gst_element_get_state (GST_ELEMENT
+ (stream->priv->pipeline), &state,
+ NULL, 5 * GST_SECOND)) {
g_warning ("State change failed for stream.");
}
} else if (sret != GST_STATE_CHANGE_SUCCESS) {
@@ -139,28 +152,33 @@ GInputStream* dmap_gst_mp3_input_stream_new (GInputStream *src_stream)
}
static void
-dmap_gst_mp3_input_stream_kill_pipeline (DMAPGstInputStream *stream)
+dmap_gst_mp3_input_stream_kill_pipeline (DMAPGstInputStream * stream)
{
- DMAPGstMP3InputStream *mp3_stream = DMAP_GST_MP3_INPUT_STREAM (stream);
+ DMAPGstMP3InputStream *mp3_stream =
+ DMAP_GST_MP3_INPUT_STREAM (stream);
gst_element_set_state (mp3_stream->priv->pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (mp3_stream->priv->pipeline));
}
-G_DEFINE_TYPE (DMAPGstMP3InputStream, dmap_gst_mp3_input_stream, DMAP_TYPE_GST_INPUT_STREAM)
+G_DEFINE_TYPE (DMAPGstMP3InputStream, dmap_gst_mp3_input_stream,
+ DMAP_TYPE_GST_INPUT_STREAM)
-static void
-dmap_gst_mp3_input_stream_class_init (DMAPGstMP3InputStreamClass *klass)
+ static void
+ dmap_gst_mp3_input_stream_class_init (DMAPGstMP3InputStreamClass
+ * klass)
{
- DMAPGstInputStreamClass *parent_class = DMAP_GST_INPUT_STREAM_CLASS (klass);
+ DMAPGstInputStreamClass *parent_class =
+ DMAP_GST_INPUT_STREAM_CLASS (klass);
- g_type_class_add_private (klass, sizeof (DMAPGstMP3InputStreamPrivate));
+ g_type_class_add_private (klass,
+ sizeof (DMAPGstMP3InputStreamPrivate));
parent_class->kill_pipeline = dmap_gst_mp3_input_stream_kill_pipeline;
}
static void
-dmap_gst_mp3_input_stream_init (DMAPGstMP3InputStream *stream)
+dmap_gst_mp3_input_stream_init (DMAPGstMP3InputStream * stream)
{
stream->priv = DMAP_GST_MP3_INPUT_STREAM_GET_PRIVATE (stream);
diff --git a/libdmapsharing/dmap-gst-mp3-input-stream.h b/libdmapsharing/dmap-gst-mp3-input-stream.h
index 87b0fd7..eee2320 100644
--- a/libdmapsharing/dmap-gst-mp3-input-stream.h
+++ b/libdmapsharing/dmap-gst-mp3-input-stream.h
@@ -28,7 +28,6 @@
#include "dmap-gst-input-stream.h"
G_BEGIN_DECLS
-
#define DMAP_TYPE_GST_MP3_INPUT_STREAM (dmap_gst_mp3_input_stream_get_type ())
#define DMAP_GST_MP3_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
DMAP_TYPE_GST_MP3_INPUT_STREAM, \
@@ -46,22 +45,22 @@ G_BEGIN_DECLS
#define DMAP_GST_MP3_INPUT_STREAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
DMAP_TYPE_GST_MP3_INPUT_STREAM, \
DMAPGstMP3InputStreamPrivate))
-
typedef struct DMAPGstMP3InputStreamPrivate DMAPGstMP3InputStreamPrivate;
-typedef struct {
+typedef struct
+{
DMAPGstInputStream parent;
DMAPGstMP3InputStreamPrivate *priv;
} DMAPGstMP3InputStream;
-typedef struct {
+typedef struct
+{
DMAPGstInputStreamClass parent;
} DMAPGstMP3InputStreamClass;
-GType dmap_gst_mp3_input_stream_get_type (void);
+GType dmap_gst_mp3_input_stream_get_type (void);
-GInputStream* dmap_gst_mp3_input_stream_new (GInputStream *stream);
+GInputStream *dmap_gst_mp3_input_stream_new (GInputStream * stream);
G_END_DECLS
-
#endif /* __DMAP_GST_MP3_INPUT_STREAM */
diff --git a/libdmapsharing/dmap-gst-wav-input-stream.c b/libdmapsharing/dmap-gst-wav-input-stream.c
index 84e876c..7f97fac 100644
--- a/libdmapsharing/dmap-gst-wav-input-stream.c
+++ b/libdmapsharing/dmap-gst-wav-input-stream.c
@@ -28,7 +28,8 @@
#define GST_APP_MAX_BUFFERS 1024
-struct DMAPGstWAVInputStreamPrivate {
+struct DMAPGstWAVInputStreamPrivate
+{
GstElement *pipeline;
GstElement *src;
GstElement *decode;
@@ -39,14 +40,13 @@ struct DMAPGstWAVInputStreamPrivate {
};
/* FIXME: See note in dmap-gst-input-stream.h */
-void dmap_gst_input_stream_new_buffer_cb (GstElement *element,
- DMAPGstInputStream *stream);
+void dmap_gst_input_stream_new_buffer_cb (GstElement * element,
+ DMAPGstInputStream * stream);
static void
-new_decoded_pad_cb (GstElement *element,
- GstPad *pad,
- gboolean arg,
- DMAPGstWAVInputStream *stream)
+new_decoded_pad_cb (GstElement * element,
+ GstPad * pad,
+ gboolean arg, DMAPGstWAVInputStream * stream)
{
/* Link remaining pad after decodebin does its magic. */
GstPad *conv_pad;
@@ -55,15 +55,18 @@ new_decoded_pad_cb (GstElement *element,
g_assert (conv_pad != NULL);
if (pads_compatible (pad, conv_pad)) {
- g_assert (! GST_PAD_IS_LINKED (
- gst_element_get_static_pad (stream->priv->convert, "sink")));
+ g_assert (!GST_PAD_IS_LINKED
+ (gst_element_get_static_pad
+ (stream->priv->convert, "sink")));
gst_pad_link (pad, conv_pad);
if (gst_element_link_filtered (stream->priv->convert,
stream->priv->encode,
- stream->priv->filter) == FALSE) {
- g_warning ("Error linking convert and encode elements");
+ stream->priv->filter) ==
+ FALSE) {
+ g_warning
+ ("Error linking convert and encode elements");
}
if (gst_element_link (stream->priv->encode,
stream->priv->sink) == FALSE) {
@@ -74,24 +77,28 @@ new_decoded_pad_cb (GstElement *element,
}
}
-GInputStream* dmap_gst_wav_input_stream_new (GInputStream *src_stream)
+GInputStream *
+dmap_gst_wav_input_stream_new (GInputStream * src_stream)
{
GstStateChangeReturn sret;
GstState state;
DMAPGstWAVInputStream *stream;
- stream = DMAP_GST_WAV_INPUT_STREAM (g_object_new (DMAP_TYPE_GST_WAV_INPUT_STREAM,
- NULL));
+ stream = DMAP_GST_WAV_INPUT_STREAM (g_object_new
+ (DMAP_TYPE_GST_WAV_INPUT_STREAM,
+ NULL));
stream->priv->pipeline = gst_pipeline_new ("pipeline");
- stream->priv->src = gst_element_factory_make ("giostreamsrc", "src");
+ stream->priv->src = gst_element_factory_make ("giostreamsrc", "src");
g_assert (GST_IS_ELEMENT (stream->priv->src));
- stream->priv->decode = gst_element_factory_make ("decodebin", "decode");
+ stream->priv->decode =
+ gst_element_factory_make ("decodebin", "decode");
g_assert (GST_IS_ELEMENT (stream->priv->decode));
- stream->priv->convert = gst_element_factory_make ("audioconvert", "convert");
+ stream->priv->convert =
+ gst_element_factory_make ("audioconvert", "convert");
g_assert (GST_IS_ELEMENT (stream->priv->convert));
/* Roku clients support a subset of the WAV format. */
@@ -100,39 +107,47 @@ GInputStream* dmap_gst_wav_input_stream_new (GInputStream *src_stream)
"width", G_TYPE_INT, 16,
"depth", G_TYPE_INT, 16,
NULL);
- stream->priv->encode = gst_element_factory_make ("wavenc", "encode");
+ stream->priv->encode = gst_element_factory_make ("wavenc", "encode");
g_assert (GST_IS_ELEMENT (stream->priv->encode));
- stream->priv->sink = gst_element_factory_make ("appsink", "sink");
+ stream->priv->sink = gst_element_factory_make ("appsink", "sink");
g_assert (GST_IS_ELEMENT (stream->priv->sink));
gst_bin_add_many (GST_BIN (stream->priv->pipeline),
stream->priv->src,
stream->priv->decode,
stream->priv->convert,
- stream->priv->encode,
- stream->priv->sink,
- NULL);
+ stream->priv->encode, stream->priv->sink, NULL);
- if (gst_element_link (stream->priv->src, stream->priv->decode) == FALSE) {
+ if (gst_element_link (stream->priv->src, stream->priv->decode) ==
+ FALSE) {
g_warning ("Error linking source and decode elements");
}
- g_object_set (G_OBJECT (stream->priv->src), "stream", src_stream, NULL);
+ g_object_set (G_OBJECT (stream->priv->src), "stream", src_stream,
+ NULL);
- g_signal_connect (stream->priv->decode, "new-decoded-pad", G_CALLBACK (new_decoded_pad_cb), stream);
+ g_signal_connect (stream->priv->decode, "new-decoded-pad",
+ G_CALLBACK (new_decoded_pad_cb), stream);
- g_object_set (G_OBJECT (stream->priv->sink), "emit-signals", TRUE, "sync", FALSE, NULL);
+ g_object_set (G_OBJECT (stream->priv->sink), "emit-signals", TRUE,
+ "sync", FALSE, NULL);
gst_app_sink_set_max_buffers (GST_APP_SINK (stream->priv->sink),
GST_APP_MAX_BUFFERS);
gst_app_sink_set_drop (GST_APP_SINK (stream->priv->sink), FALSE);
- g_signal_connect (stream->priv->sink, "new-buffer", G_CALLBACK (dmap_gst_input_stream_new_buffer_cb), stream);
+ g_signal_connect (stream->priv->sink, "new-buffer",
+ G_CALLBACK (dmap_gst_input_stream_new_buffer_cb),
+ stream);
/* FIXME: this technique is shared with dmapd-daap-share.c */
- sret = gst_element_set_state (stream->priv->pipeline, GST_STATE_PLAYING);
+ sret = gst_element_set_state (stream->priv->pipeline,
+ GST_STATE_PLAYING);
if (GST_STATE_CHANGE_ASYNC == sret) {
- if (GST_STATE_CHANGE_SUCCESS != gst_element_get_state (GST_ELEMENT (stream->priv->pipeline), &state, NULL, 5 * GST_SECOND)) {
+ if (GST_STATE_CHANGE_SUCCESS !=
+ gst_element_get_state (GST_ELEMENT
+ (stream->priv->pipeline), &state,
+ NULL, 5 * GST_SECOND)) {
g_warning ("State change failed for stream.");
}
} else if (sret != GST_STATE_CHANGE_SUCCESS) {
@@ -144,28 +159,33 @@ GInputStream* dmap_gst_wav_input_stream_new (GInputStream *src_stream)
}
static void
-dmap_gst_wav_input_stream_kill_pipeline (DMAPGstInputStream *stream)
+dmap_gst_wav_input_stream_kill_pipeline (DMAPGstInputStream * stream)
{
- DMAPGstWAVInputStream *wav_stream = DMAP_GST_WAV_INPUT_STREAM (stream);
+ DMAPGstWAVInputStream *wav_stream =
+ DMAP_GST_WAV_INPUT_STREAM (stream);
gst_element_set_state (wav_stream->priv->pipeline, GST_STATE_NULL);
gst_object_unref (GST_OBJECT (wav_stream->priv->pipeline));
}
-G_DEFINE_TYPE (DMAPGstWAVInputStream, dmap_gst_wav_input_stream, DMAP_TYPE_GST_INPUT_STREAM)
+G_DEFINE_TYPE (DMAPGstWAVInputStream, dmap_gst_wav_input_stream,
+ DMAP_TYPE_GST_INPUT_STREAM)
-static void
-dmap_gst_wav_input_stream_class_init (DMAPGstWAVInputStreamClass *klass)
+ static void
+ dmap_gst_wav_input_stream_class_init (DMAPGstWAVInputStreamClass
+ * klass)
{
- DMAPGstInputStreamClass *parent_class = DMAP_GST_INPUT_STREAM_CLASS (klass);
+ DMAPGstInputStreamClass *parent_class =
+ DMAP_GST_INPUT_STREAM_CLASS (klass);
- g_type_class_add_private (klass, sizeof (DMAPGstWAVInputStreamPrivate));
+ g_type_class_add_private (klass,
+ sizeof (DMAPGstWAVInputStreamPrivate));
parent_class->kill_pipeline = dmap_gst_wav_input_stream_kill_pipeline;
}
static void
-dmap_gst_wav_input_stream_init (DMAPGstWAVInputStream *stream)
+dmap_gst_wav_input_stream_init (DMAPGstWAVInputStream * stream)
{
stream->priv = DMAP_GST_WAV_INPUT_STREAM_GET_PRIVATE (stream);
diff --git a/libdmapsharing/dmap-gst-wav-input-stream.h b/libdmapsharing/dmap-gst-wav-input-stream.h
index 84440d0..5b7a7c0 100644
--- a/libdmapsharing/dmap-gst-wav-input-stream.h
+++ b/libdmapsharing/dmap-gst-wav-input-stream.h
@@ -28,7 +28,6 @@
#include "dmap-gst-input-stream.h"
G_BEGIN_DECLS
-
#define DMAP_TYPE_GST_WAV_INPUT_STREAM (dmap_gst_wav_input_stream_get_type ())
#define DMAP_GST_WAV_INPUT_STREAM(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
DMAP_TYPE_GST_WAV_INPUT_STREAM, \
@@ -46,22 +45,22 @@ G_BEGIN_DECLS
#define DMAP_GST_WAV_INPUT_STREAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
DMAP_TYPE_GST_WAV_INPUT_STREAM, \
DMAPGstWAVInputStreamPrivate))
-
typedef struct DMAPGstWAVInputStreamPrivate DMAPGstWAVInputStreamPrivate;
-typedef struct {
+typedef struct
+{
DMAPGstInputStream parent;
DMAPGstWAVInputStreamPrivate *priv;
} DMAPGstWAVInputStream;
-typedef struct {
+typedef struct
+{
DMAPGstInputStreamClass parent;
} DMAPGstWAVInputStreamClass;
-GType dmap_gst_wav_input_stream_get_type (void);
+GType dmap_gst_wav_input_stream_get_type (void);
-GInputStream* dmap_gst_wav_input_stream_new (GInputStream *stream);
+GInputStream *dmap_gst_wav_input_stream_new (GInputStream * stream);
G_END_DECLS
-
#endif /* __DMAP_GST_WAV_INPUT_STREAM */
diff --git a/libdmapsharing/dmap-md5.c b/libdmapsharing/dmap-md5.c
index d0fd38b..ec5363c 100644
--- a/libdmapsharing/dmap-md5.c
+++ b/libdmapsharing/dmap-md5.c
@@ -31,11 +31,12 @@
* Copyright (c) 2004 David Hammerton
*/
-typedef struct {
- guint32 buf[4];
- guint32 bits[2];
- unsigned char in[64];
- gint version;
+typedef struct
+{
+ guint32 buf[4];
+ guint32 bits[2];
+ unsigned char in[64];
+ gint version;
} MD5_CTX;
/*
@@ -60,8 +61,8 @@ static void MD5Transform (guint32 buf[4], guint32 const in[16], gint version);
* I don't really know why... but otherwise it fails..
* Any MD5 gurus out there know why???
*/
-#if 0 //ndef WORDS_BIGENDIAN /* was: HIGHFIRST */
-#define byteReverse(buf, len) /* Nothing */
+#if 0 //ndef WORDS_BIGENDIAN /* was: HIGHFIRST */
+#define byteReverse(buf, len) /* Nothing */
#else
static void byteReverse (unsigned char *buf, unsigned longs);
@@ -70,126 +71,122 @@ static void byteReverse (unsigned char *buf, unsigned longs);
* Note: this code is harmless on little-endian machines.
*/
static void
-byteReverse (unsigned char *buf,
- unsigned longs)
+byteReverse (unsigned char *buf, unsigned longs)
{
- guint32 t;
- do {
- t = (guint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
- ((unsigned) buf[1] << 8 | buf[0]);
- *(guint32 *) buf = t;
- buf += 4;
- } while (--longs);
+ guint32 t;
+
+ do {
+ t = (guint32) ((unsigned) buf[3] << 8 | buf[2]) << 16 |
+ ((unsigned) buf[1] << 8 | buf[0]);
+ *(guint32 *) buf = t;
+ buf += 4;
+ } while (--longs);
}
#endif /* ! ASM_MD5 */
#endif /* #if 0 */
static void
-DMAP_MD5Init (MD5_CTX *ctx,
- gint version)
+DMAP_MD5Init (MD5_CTX * ctx, gint version)
{
- memset (ctx, 0, sizeof (MD5_CTX));
- ctx->buf[0] = 0x67452301;
- ctx->buf[1] = 0xefcdab89;
- ctx->buf[2] = 0x98badcfe;
- ctx->buf[3] = 0x10325476;
+ memset (ctx, 0, sizeof (MD5_CTX));
+ ctx->buf[0] = 0x67452301;
+ ctx->buf[1] = 0xefcdab89;
+ ctx->buf[2] = 0x98badcfe;
+ ctx->buf[3] = 0x10325476;
- ctx->bits[0] = 0;
- ctx->bits[1] = 0;
+ ctx->bits[0] = 0;
+ ctx->bits[1] = 0;
- ctx->version = version;
+ ctx->version = version;
}
static void
-DMAP_MD5Update (MD5_CTX *ctx,
- unsigned char const *buf,
- unsigned int len)
+DMAP_MD5Update (MD5_CTX * ctx, unsigned char const *buf, unsigned int len)
{
- guint32 t;
-
- /* Update bitcount */
-
- t = ctx->bits[0];
- if ((ctx->bits[0] = t + ((guint32) len << 3)) < t)
- ctx->bits[1]++; /* Carry from low to high */
- ctx->bits[1] += len >> 29;
-
- t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
-
- /* Handle any leading odd-sized chunks */
-
- if (t) {
- unsigned char *p = (unsigned char *) ctx->in + t;
-
- t = 64 - t;
- if (len < t) {
- memcpy (p, buf, len);
- return;
- }
- memcpy (p, buf, t);
- byteReverse (ctx->in, 16);
- MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
- buf += t;
- len -= t;
- }
- /* Process data in 64-byte chunks */
-
- while (len >= 64) {
- memcpy (ctx->in, buf, 64);
- byteReverse (ctx->in, 16);
- MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
- buf += 64;
- len -= 64;
- }
-
- /* Handle any remaining bytes of data. */
-
- memcpy (ctx->in, buf, len);
+ guint32 t;
+
+ /* Update bitcount */
+
+ t = ctx->bits[0];
+ if ((ctx->bits[0] = t + ((guint32) len << 3)) < t)
+ ctx->bits[1]++; /* Carry from low to high */
+ ctx->bits[1] += len >> 29;
+
+ t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
+
+ /* Handle any leading odd-sized chunks */
+
+ if (t) {
+ unsigned char *p = (unsigned char *) ctx->in + t;
+
+ t = 64 - t;
+ if (len < t) {
+ memcpy (p, buf, len);
+ return;
+ }
+ memcpy (p, buf, t);
+ byteReverse (ctx->in, 16);
+ MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
+ buf += t;
+ len -= t;
+ }
+ /* Process data in 64-byte chunks */
+
+ while (len >= 64) {
+ memcpy (ctx->in, buf, 64);
+ byteReverse (ctx->in, 16);
+ MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
+ buf += 64;
+ len -= 64;
+ }
+
+ /* Handle any remaining bytes of data. */
+
+ memcpy (ctx->in, buf, len);
}
static void
-DMAP_MD5Final (MD5_CTX *ctx,
- unsigned char digest[16])
+DMAP_MD5Final (MD5_CTX * ctx, unsigned char digest[16])
{
- unsigned count;
- unsigned char *p;
-
- /* Compute number of bytes mod 64 */
- count = (ctx->bits[0] >> 3) & 0x3F;
-
- /* Set the first gchar of padding to 0x80. This is safe since there is
- always at least one byte free */
- p = ctx->in + count;
- *p++ = 0x80;
-
- /* Bytes of padding needed to make 64 bytes */
- count = 64 - 1 - count;
-
- /* Pad out to 56 mod 64 */
- if (count < 8) {
- /* Two lots of padding: Pad the first block to 64 bytes */
- memset (p, 0, count);
- byteReverse (ctx->in, 16);
- MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
-
- /* Now fill the next block with 56 bytes */
- memset (ctx->in, 0, 56);
- } else {
- /* Pad block to 56 bytes */
- memset (p, 0, count - 8);
- }
- byteReverse (ctx->in, 14);
-
- /* Append length in bits and transform */
- ((guint32 *) ctx->in)[14] = ctx->bits[0];
- ((guint32 *) ctx->in)[15] = ctx->bits[1];
-
- MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
- byteReverse ((unsigned char *) ctx->buf, 4);
- memcpy (digest, ctx->buf, 16);
- memset (ctx, 0, sizeof(ctx)); /* In case it's sensitive */
-
- return;
+ unsigned count;
+ unsigned char *p;
+
+ /* Compute number of bytes mod 64 */
+ count = (ctx->bits[0] >> 3) & 0x3F;
+
+ /* Set the first gchar of padding to 0x80. This is safe since there is
+ * always at least one byte free */
+ p = ctx->in + count;
+ *p++ = 0x80;
+
+ /* Bytes of padding needed to make 64 bytes */
+ count = 64 - 1 - count;
+
+ /* Pad out to 56 mod 64 */
+ if (count < 8) {
+ /* Two lots of padding: Pad the first block to 64 bytes */
+ memset (p, 0, count);
+ byteReverse (ctx->in, 16);
+ MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
+
+ /* Now fill the next block with 56 bytes */
+ memset (ctx->in, 0, 56);
+ } else {
+ /* Pad block to 56 bytes */
+ memset (p, 0, count - 8);
+ }
+ byteReverse (ctx->in, 14);
+
+ /* Append length in bits and transform */
+ ((guint32 *) ctx->in)[14] = ctx->bits[0];
+ ((guint32 *) ctx->in)[15] = ctx->bits[1];
+
+ MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
+ byteReverse ((unsigned char *) ctx->buf, 4);
+ memcpy (digest, ctx->buf, 16);
+ memset (ctx, 0, sizeof (ctx)); /* In case it's sensitive */
+
+ return;
}
#ifndef ASM_MD5
@@ -212,287 +209,279 @@ DMAP_MD5Final (MD5_CTX *ctx,
* data and converts bytes into longwords for this routine.
*/
static void
-MD5Transform (guint32 buf[4],
- guint32 const in[16],
- gint version)
+MD5Transform (guint32 buf[4], guint32 const in[16], gint version)
{
- guint32 a, b, c, d;
-
- a = buf[0];
- b = buf[1];
- c = buf[2];
- d = buf[3];
-
- MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
- MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
- MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
- MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
- MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
- MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
- MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
- MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
- MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
- MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
- MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
- MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
- MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
- MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
- MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
- MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
-
- MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
- MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
- MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
- MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
- MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
- MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
- MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
- MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
- MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
- MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
- MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
-
- if (version == 1)
- {
- MD5STEP(F2, b, c, d, a, in[8] + 0x445a14ed, 20);
- }
- else
- {
- MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
- }
- MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
- MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
- MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
- MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
-
- MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
- MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
- MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
- MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
- MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
- MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
- MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
- MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
- MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
- MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
- MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
- MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
- MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
- MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
- MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
- MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
-
- MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
- MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
- MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
- MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
- MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
- MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
- MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
- MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
- MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
- MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
- MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
- MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
- MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
- MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
- MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
- MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
-
- buf[0] += a;
- buf[1] += b;
- buf[2] += c;
- buf[3] += d;
+ guint32 a, b, c, d;
+
+ a = buf[0];
+ b = buf[1];
+ c = buf[2];
+ d = buf[3];
+
+ MD5STEP (F1, a, b, c, d, in[0] + 0xd76aa478, 7);
+ MD5STEP (F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
+ MD5STEP (F1, c, d, a, b, in[2] + 0x242070db, 17);
+ MD5STEP (F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
+ MD5STEP (F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
+ MD5STEP (F1, d, a, b, c, in[5] + 0x4787c62a, 12);
+ MD5STEP (F1, c, d, a, b, in[6] + 0xa8304613, 17);
+ MD5STEP (F1, b, c, d, a, in[7] + 0xfd469501, 22);
+ MD5STEP (F1, a, b, c, d, in[8] + 0x698098d8, 7);
+ MD5STEP (F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
+ MD5STEP (F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
+ MD5STEP (F1, b, c, d, a, in[11] + 0x895cd7be, 22);
+ MD5STEP (F1, a, b, c, d, in[12] + 0x6b901122, 7);
+ MD5STEP (F1, d, a, b, c, in[13] + 0xfd987193, 12);
+ MD5STEP (F1, c, d, a, b, in[14] + 0xa679438e, 17);
+ MD5STEP (F1, b, c, d, a, in[15] + 0x49b40821, 22);
+
+ MD5STEP (F2, a, b, c, d, in[1] + 0xf61e2562, 5);
+ MD5STEP (F2, d, a, b, c, in[6] + 0xc040b340, 9);
+ MD5STEP (F2, c, d, a, b, in[11] + 0x265e5a51, 14);
+ MD5STEP (F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
+ MD5STEP (F2, a, b, c, d, in[5] + 0xd62f105d, 5);
+ MD5STEP (F2, d, a, b, c, in[10] + 0x02441453, 9);
+ MD5STEP (F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
+ MD5STEP (F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
+ MD5STEP (F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
+ MD5STEP (F2, d, a, b, c, in[14] + 0xc33707d6, 9);
+ MD5STEP (F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
+
+ if (version == 1) {
+ MD5STEP (F2, b, c, d, a, in[8] + 0x445a14ed, 20);
+ } else {
+ MD5STEP (F2, b, c, d, a, in[8] + 0x455a14ed, 20);
+ }
+ MD5STEP (F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
+ MD5STEP (F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
+ MD5STEP (F2, c, d, a, b, in[7] + 0x676f02d9, 14);
+ MD5STEP (F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
+
+ MD5STEP (F3, a, b, c, d, in[5] + 0xfffa3942, 4);
+ MD5STEP (F3, d, a, b, c, in[8] + 0x8771f681, 11);
+ MD5STEP (F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
+ MD5STEP (F3, b, c, d, a, in[14] + 0xfde5380c, 23);
+ MD5STEP (F3, a, b, c, d, in[1] + 0xa4beea44, 4);
+ MD5STEP (F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
+ MD5STEP (F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
+ MD5STEP (F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
+ MD5STEP (F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
+ MD5STEP (F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
+ MD5STEP (F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
+ MD5STEP (F3, b, c, d, a, in[6] + 0x04881d05, 23);
+ MD5STEP (F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
+ MD5STEP (F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
+ MD5STEP (F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
+ MD5STEP (F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
+
+ MD5STEP (F4, a, b, c, d, in[0] + 0xf4292244, 6);
+ MD5STEP (F4, d, a, b, c, in[7] + 0x432aff97, 10);
+ MD5STEP (F4, c, d, a, b, in[14] + 0xab9423a7, 15);
+ MD5STEP (F4, b, c, d, a, in[5] + 0xfc93a039, 21);
+ MD5STEP (F4, a, b, c, d, in[12] + 0x655b59c3, 6);
+ MD5STEP (F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
+ MD5STEP (F4, c, d, a, b, in[10] + 0xffeff47d, 15);
+ MD5STEP (F4, b, c, d, a, in[1] + 0x85845dd1, 21);
+ MD5STEP (F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
+ MD5STEP (F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
+ MD5STEP (F4, c, d, a, b, in[6] + 0xa3014314, 15);
+ MD5STEP (F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
+ MD5STEP (F4, a, b, c, d, in[4] + 0xf7537e82, 6);
+ MD5STEP (F4, d, a, b, c, in[11] + 0xbd3af235, 10);
+ MD5STEP (F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
+ MD5STEP (F4, b, c, d, a, in[9] + 0xeb86d391, 21);
+
+ buf[0] += a;
+ buf[1] += b;
+ buf[2] += c;
+ buf[3] += d;
}
#endif
static gint staticHashDone = 0;
-static unsigned char staticHash_42[256*65] = {0};
-static unsigned char staticHash_45[256*65] = {0};
+static unsigned char staticHash_42[256 * 65] = { 0 };
+static unsigned char staticHash_45[256 * 65] = { 0 };
static const gchar hexchars[] = "0123456789ABCDEF";
-static gchar ac[] = "Dpqzsjhiu!3114!Bqqmf!Dpnqvufs-!Jod/"; /* +1 */
+static gchar ac[] = "Dpqzsjhiu!3114!Bqqmf!Dpnqvufs-!Jod/"; /* +1 */
static gboolean ac_unfudged = FALSE;
static void
-DigestToString (const unsigned char *digest,
- gchar *string)
+DigestToString (const unsigned char *digest, gchar * string)
{
- gint i;
- for (i = 0; i < 16; i++)
- {
- unsigned char tmp = digest[i];
- string[i*2+1] = hexchars[tmp & 0x0f];
- string[i*2] = hexchars[(tmp >> 4) & 0x0f];
- }
+ gint i;
+
+ for (i = 0; i < 16; i++) {
+ unsigned char tmp = digest[i];
+
+ string[i * 2 + 1] = hexchars[tmp & 0x0f];
+ string[i * 2] = hexchars[(tmp >> 4) & 0x0f];
+ }
}
-static void
+static void
GenerateStatic_42 ()
{
- MD5_CTX ctx;
- unsigned char *p = staticHash_42;
- int i;
- unsigned char buf[16];
+ MD5_CTX ctx;
+ unsigned char *p = staticHash_42;
+ int i;
+ unsigned char buf[16];
- for (i = 0; i < 256; i++)
- {
- DMAP_MD5Init (&ctx, 0);
+ for (i = 0; i < 256; i++) {
+ DMAP_MD5Init (&ctx, 0);
#define MD5_STRUPDATE(str) DMAP_MD5Update(&ctx, (unsigned char const *)str, strlen(str))
- if ((i & 0x80) != 0)
- MD5_STRUPDATE("Accept-Language");
- else
- MD5_STRUPDATE("user-agent");
-
- if ((i & 0x40) != 0)
- MD5_STRUPDATE("max-age");
- else
- MD5_STRUPDATE("Authorization");
-
- if ((i & 0x20) != 0)
- MD5_STRUPDATE("Client-DAAP-Version");
- else
- MD5_STRUPDATE("Accept-Encoding");
-
- if ((i & 0x10) != 0)
- MD5_STRUPDATE("daap.protocolversion");
- else
- MD5_STRUPDATE("daap.songartist");
-
- if ((i & 0x08) != 0)
- MD5_STRUPDATE("daap.songcomposer");
- else
- MD5_STRUPDATE("daap.songdatemodified");
-
- if ((i & 0x04) != 0)
- MD5_STRUPDATE("daap.songdiscnumber");
- else
- MD5_STRUPDATE("daap.songdisabled");
-
- if ((i & 0x02) != 0)
- MD5_STRUPDATE("playlist-item-spec");
- else
- MD5_STRUPDATE("revision-number");
-
- if ((i & 0x01) != 0)
- MD5_STRUPDATE("session-id");
- else
- MD5_STRUPDATE("content-codes");
+ if ((i & 0x80) != 0)
+ MD5_STRUPDATE ("Accept-Language");
+ else
+ MD5_STRUPDATE ("user-agent");
+
+ if ((i & 0x40) != 0)
+ MD5_STRUPDATE ("max-age");
+ else
+ MD5_STRUPDATE ("Authorization");
+
+ if ((i & 0x20) != 0)
+ MD5_STRUPDATE ("Client-DAAP-Version");
+ else
+ MD5_STRUPDATE ("Accept-Encoding");
+
+ if ((i & 0x10) != 0)
+ MD5_STRUPDATE ("daap.protocolversion");
+ else
+ MD5_STRUPDATE ("daap.songartist");
+
+ if ((i & 0x08) != 0)
+ MD5_STRUPDATE ("daap.songcomposer");
+ else
+ MD5_STRUPDATE ("daap.songdatemodified");
+
+ if ((i & 0x04) != 0)
+ MD5_STRUPDATE ("daap.songdiscnumber");
+ else
+ MD5_STRUPDATE ("daap.songdisabled");
+
+ if ((i & 0x02) != 0)
+ MD5_STRUPDATE ("playlist-item-spec");
+ else
+ MD5_STRUPDATE ("revision-number");
+
+ if ((i & 0x01) != 0)
+ MD5_STRUPDATE ("session-id");
+ else
+ MD5_STRUPDATE ("content-codes");
#undef MD5_STRUPDATE
- DMAP_MD5Final (&ctx, buf);
- DigestToString (buf, (char *)p);
- p += 65;
- }
+ DMAP_MD5Final (&ctx, buf);
+ DigestToString (buf, (char *) p);
+ p += 65;
+ }
}
-static void GenerateStatic_45()
+static void
+GenerateStatic_45 ()
{
- MD5_CTX ctx;
- unsigned char *p = staticHash_45;
- int i;
- unsigned char buf[16];
+ MD5_CTX ctx;
+ unsigned char *p = staticHash_45;
+ int i;
+ unsigned char buf[16];
- for (i = 0; i < 256; i++)
- {
- DMAP_MD5Init (&ctx, 1);
+ for (i = 0; i < 256; i++) {
+ DMAP_MD5Init (&ctx, 1);
#define MD5_STRUPDATE(str) DMAP_MD5Update(&ctx, (unsigned char const *)str, strlen(str))
- if ((i & 0x40) != 0)
- MD5_STRUPDATE("eqwsdxcqwesdc");
- else
- MD5_STRUPDATE("op[;lm,piojkmn");
-
- if ((i & 0x20) != 0)
- MD5_STRUPDATE("876trfvb 34rtgbvc");
- else
- MD5_STRUPDATE("=-0ol.,m3ewrdfv");
-
- if ((i & 0x10) != 0)
- MD5_STRUPDATE("87654323e4rgbv ");
- else
- MD5_STRUPDATE("1535753690868867974342659792");
-
- if ((i & 0x08) != 0)
- MD5_STRUPDATE("Song Name");
- else
- MD5_STRUPDATE("DAAP-CLIENT-ID:");
-
- if ((i & 0x04) != 0)
- MD5_STRUPDATE("111222333444555");
- else
- MD5_STRUPDATE("4089961010");
-
- if ((i & 0x02) != 0)
- MD5_STRUPDATE("playlist-item-spec");
- else
- MD5_STRUPDATE("revision-number");
-
- if ((i & 0x01) != 0)
- MD5_STRUPDATE("session-id");
- else
- MD5_STRUPDATE("content-codes");
-
- if ((i & 0x80) != 0)
- MD5_STRUPDATE("IUYHGFDCXWEDFGHN");
- else
- MD5_STRUPDATE("iuytgfdxwerfghjm");
+ if ((i & 0x40) != 0)
+ MD5_STRUPDATE ("eqwsdxcqwesdc");
+ else
+ MD5_STRUPDATE ("op[;lm,piojkmn");
+
+ if ((i & 0x20) != 0)
+ MD5_STRUPDATE ("876trfvb 34rtgbvc");
+ else
+ MD5_STRUPDATE ("=-0ol.,m3ewrdfv");
+
+ if ((i & 0x10) != 0)
+ MD5_STRUPDATE ("87654323e4rgbv ");
+ else
+ MD5_STRUPDATE ("1535753690868867974342659792");
+
+ if ((i & 0x08) != 0)
+ MD5_STRUPDATE ("Song Name");
+ else
+ MD5_STRUPDATE ("DAAP-CLIENT-ID:");
+
+ if ((i & 0x04) != 0)
+ MD5_STRUPDATE ("111222333444555");
+ else
+ MD5_STRUPDATE ("4089961010");
+
+ if ((i & 0x02) != 0)
+ MD5_STRUPDATE ("playlist-item-spec");
+ else
+ MD5_STRUPDATE ("revision-number");
+
+ if ((i & 0x01) != 0)
+ MD5_STRUPDATE ("session-id");
+ else
+ MD5_STRUPDATE ("content-codes");
+
+ if ((i & 0x80) != 0)
+ MD5_STRUPDATE ("IUYHGFDCXWEDFGHN");
+ else
+ MD5_STRUPDATE ("iuytgfdxwerfghjm");
#undef MD5_STRUPDATE
- DMAP_MD5Final (&ctx, buf);
- DigestToString (buf, (char *)p);
- p += 65;
- }
+ DMAP_MD5Final (&ctx, buf);
+ DigestToString (buf, (char *) p);
+ p += 65;
+ }
}
void
dmap_hash_generate (short version_major,
- const guchar *url,
- guchar hash_select,
- guchar *out,
- gint request_id)
+ const guchar * url,
+ guchar hash_select, guchar * out, gint request_id)
{
- unsigned char buf[16];
- MD5_CTX ctx;
- gint i;
-
- unsigned char *hashTable = (version_major == 3) ?
- staticHash_45 : staticHash_42;
-
- if (!staticHashDone)
- {
- GenerateStatic_42 ();
- GenerateStatic_45 ();
- staticHashDone = 1;
- }
-
- DMAP_MD5Init (&ctx, (version_major == 3) ? 1 : 0);
-
- DMAP_MD5Update (&ctx, url, strlen ((const gchar*)url));
- if (ac_unfudged == FALSE) {
- for (i = 0; i < strlen (ac); i++) {
- ac[i] = ac[i]-1;
- }
- ac_unfudged = TRUE;
- }
- DMAP_MD5Update (&ctx, (const guchar*)ac, strlen (ac));
-
- DMAP_MD5Update (&ctx, &hashTable[hash_select * 65], 32);
-
- if (request_id && version_major == 3)
- {
- gchar scribble[20];
- sprintf (scribble, "%u", request_id);
- DMAP_MD5Update (&ctx, (const guchar*)scribble, strlen (scribble));
- }
-
- DMAP_MD5Final (&ctx, buf);
- DigestToString (buf, (gchar *)out);
-
- return;
+ unsigned char buf[16];
+ MD5_CTX ctx;
+ gint i;
+
+ unsigned char *hashTable = (version_major == 3) ?
+ staticHash_45 : staticHash_42;
+
+ if (!staticHashDone) {
+ GenerateStatic_42 ();
+ GenerateStatic_45 ();
+ staticHashDone = 1;
+ }
+
+ DMAP_MD5Init (&ctx, (version_major == 3) ? 1 : 0);
+
+ DMAP_MD5Update (&ctx, url, strlen ((const gchar *) url));
+ if (ac_unfudged == FALSE) {
+ for (i = 0; i < strlen (ac); i++) {
+ ac[i] = ac[i] - 1;
+ }
+ ac_unfudged = TRUE;
+ }
+ DMAP_MD5Update (&ctx, (const guchar *) ac, strlen (ac));
+
+ DMAP_MD5Update (&ctx, &hashTable[hash_select * 65], 32);
+
+ if (request_id && version_major == 3) {
+ gchar scribble[20];
+
+ sprintf (scribble, "%u", request_id);
+ DMAP_MD5Update (&ctx, (const guchar *) scribble,
+ strlen (scribble));
+ }
+
+ DMAP_MD5Final (&ctx, buf);
+ DigestToString (buf, (gchar *) out);
+
+ return;
}
diff --git a/libdmapsharing/dmap-md5.h b/libdmapsharing/dmap-md5.h
index 7ff39f8..8e12862 100644
--- a/libdmapsharing/dmap-md5.h
+++ b/libdmapsharing/dmap-md5.h
@@ -24,13 +24,10 @@
#include <glib.h>
G_BEGIN_DECLS
-
-void dmap_hash_generate (short version_major,
- const guchar *url,
- guchar hash_select,
- guchar *out,
- gint request_id);
+ void dmap_hash_generate (short version_major,
+ const guchar * url,
+ guchar hash_select,
+ guchar * out, gint request_id);
G_END_DECLS
-
#endif
diff --git a/libdmapsharing/dmap-mdns-avahi.c b/libdmapsharing/dmap-mdns-avahi.c
index d5b6a94..2bde822 100644
--- a/libdmapsharing/dmap-mdns-avahi.c
+++ b/libdmapsharing/dmap-mdns-avahi.c
@@ -32,9 +32,7 @@ static AvahiEntryGroup *entry_group = NULL;
static gsize client_init = 0;
static void
-client_cb (AvahiClient *client,
- AvahiClientState state,
- gpointer data)
+client_cb (AvahiClient * client, AvahiClientState state, gpointer data)
{
/* FIXME
* check to make sure we're in the _RUNNING state before we publish
@@ -53,18 +51,19 @@ client_cb (AvahiClient *client,
case AVAHI_CLIENT_S_COLLISION:
- /* Let's drop our registered services. When the server is back
- * in AVAHI_SERVER_RUNNING state we will register them
- * again with the new host name.
- */
- if (entry_group) {
- avahi_entry_group_reset (entry_group);
- }
- break;
+ /* Let's drop our registered services. When the server is back
+ * in AVAHI_SERVER_RUNNING state we will register them
+ * again with the new host name.
+ */
+ if (entry_group) {
+ avahi_entry_group_reset (entry_group);
+ }
+ break;
case AVAHI_CLIENT_FAILURE:
- g_warning ("Client failure: %s\n", avahi_strerror (avahi_client_errno (client)));
- break;
+ g_warning ("Client failure: %s\n",
+ avahi_strerror (avahi_client_errno (client)));
+ break;
case AVAHI_CLIENT_CONNECTING:
case AVAHI_CLIENT_S_REGISTERING:
@@ -85,16 +84,17 @@ dmap_mdns_avahi_get_client (void)
apoll = avahi_glib_poll_new (NULL, G_PRIORITY_DEFAULT);
if (apoll == NULL) {
- g_warning ("Unable to create AvahiGlibPoll object for mDNS");
+ g_warning
+ ("Unable to create AvahiGlibPoll object for mDNS");
}
client = avahi_client_new (avahi_glib_poll_get (apoll),
flags,
(AvahiClientCallback) client_cb,
- NULL,
- &error);
+ NULL, &error);
if (error != 0) {
- g_warning ("Unable to initialize mDNS: %s", avahi_strerror (error));
+ g_warning ("Unable to initialize mDNS: %s",
+ avahi_strerror (error));
}
g_once_init_leave (&client_init, 1);
@@ -104,7 +104,7 @@ dmap_mdns_avahi_get_client (void)
}
void
-dmap_mdns_avahi_set_entry_group (AvahiEntryGroup *eg)
+dmap_mdns_avahi_set_entry_group (AvahiEntryGroup * eg)
{
/* FIXME: No longer a valid assumption with new multiple-protocol
* per process code. Refactor?
diff --git a/libdmapsharing/dmap-mdns-avahi.h b/libdmapsharing/dmap-mdns-avahi.h
index 4f2c2ff..dba28fb 100644
--- a/libdmapsharing/dmap-mdns-avahi.h
+++ b/libdmapsharing/dmap-mdns-avahi.h
@@ -24,9 +24,8 @@
#include <avahi-client/client.h>
#include <avahi-client/publish.h>
-AvahiClient * dmap_mdns_avahi_get_client (void);
+AvahiClient *dmap_mdns_avahi_get_client (void);
-void dmap_mdns_avahi_set_entry_group (AvahiEntryGroup *group);
+void dmap_mdns_avahi_set_entry_group (AvahiEntryGroup * group);
#endif
-
diff --git a/libdmapsharing/dmap-mdns-browser-avahi.c b/libdmapsharing/dmap-mdns-browser-avahi.c
index ca572c6..6b59534 100644
--- a/libdmapsharing/dmap-mdns-browser-avahi.c
+++ b/libdmapsharing/dmap-mdns-browser-avahi.c
@@ -44,495 +44,500 @@
struct _DMAPMdnsBrowserPrivate
{
- DMAPMdnsBrowserServiceType service_type;
- AvahiClient *client;
- AvahiGLibPoll *poll;
- AvahiServiceBrowser *service_browser;
- GSList *services;
- GSList *resolvers;
+ DMAPMdnsBrowserServiceType service_type;
+ AvahiClient *client;
+ AvahiGLibPoll *poll;
+ AvahiServiceBrowser *service_browser;
+ GSList *services;
+ GSList *resolvers;
};
-enum {
- SERVICE_ADDED,
- SERVICE_REMOVED,
- LAST_SIGNAL
+enum
+{
+ SERVICE_ADDED,
+ SERVICE_REMOVED,
+ LAST_SIGNAL
};
#ifdef HAVE_AVAHI_0_5
-#define AVAHI_ADDRESS_STR_MAX (40) /* IPv6 Max = 4*8 + 7 + 1 for NUL */
+#define AVAHI_ADDRESS_STR_MAX (40) /* IPv6 Max = 4*8 + 7 + 1 for NUL */
#endif
-static void dmap_mdns_browser_class_init (DMAPMdnsBrowserClass *klass);
-static void dmap_mdns_browser_init (DMAPMdnsBrowser *browser);
-static void dmap_mdns_browser_dispose (GObject *object);
-static void dmap_mdns_browser_finalize (GObject *object);
-static void avahi_client_init (DMAPMdnsBrowser *browser);
-static void resolve_cb (AvahiServiceResolver *service_resolver,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- AvahiResolverEvent event,
- const gchar *service_name,
- const gchar *type,
- const gchar *domain,
- const gchar *host_name,
- const AvahiAddress *address,
- uint16_t port,
- AvahiStringList *text,
+static void dmap_mdns_browser_class_init (DMAPMdnsBrowserClass * klass);
+static void dmap_mdns_browser_init (DMAPMdnsBrowser * browser);
+static void dmap_mdns_browser_dispose (GObject * object);
+static void dmap_mdns_browser_finalize (GObject * object);
+static void avahi_client_init (DMAPMdnsBrowser * browser);
+static void resolve_cb (AvahiServiceResolver * service_resolver,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiResolverEvent event,
+ const gchar * service_name,
+ const gchar * type,
+ const gchar * domain,
+ const gchar * host_name,
+ const AvahiAddress * address,
+ uint16_t port, AvahiStringList * text,
#ifdef HAVE_AVAHI_0_6
- AvahiLookupResultFlags flags,
+ AvahiLookupResultFlags flags,
#endif
- DMAPMdnsBrowser *browser);
-static gboolean dmap_mdns_browser_resolve (DMAPMdnsBrowser *browser,
- const gchar *name,
- const gchar *domain);
-static void browser_add_service (DMAPMdnsBrowser *browser,
- const gchar *service_name,
- const gchar *domain);
-static void browser_remove_service (DMAPMdnsBrowser *browser,
- const gchar *service_name);
-static void browse_cb (AvahiServiceBrowser *service_browser,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- AvahiBrowserEvent event,
- const gchar *name,
- const gchar *type,
- const gchar *domain,
+ DMAPMdnsBrowser * browser);
+static gboolean dmap_mdns_browser_resolve (DMAPMdnsBrowser * browser,
+ const gchar * name,
+ const gchar * domain);
+static void browser_add_service (DMAPMdnsBrowser * browser,
+ const gchar * service_name,
+ const gchar * domain);
+static void browser_remove_service (DMAPMdnsBrowser * browser,
+ const gchar * service_name);
+static void browse_cb (AvahiServiceBrowser * service_browser,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiBrowserEvent event,
+ const gchar * name,
+ const gchar * type, const gchar * domain,
#ifdef HAVE_AVAHI_0_6
- AvahiLookupResultFlags flags,
+ AvahiLookupResultFlags flags,
#endif
- DMAPMdnsBrowser *browser);
-static void free_service (DMAPMdnsBrowserService *service);
+ DMAPMdnsBrowser * browser);
+static void free_service (DMAPMdnsBrowserService * service);
#define DMAP_MDNS_BROWSER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DMAP_TYPE_MDNS_BROWSER, DMAPMdnsBrowserPrivate))
-static guint dmap_mdns_browser_signals [LAST_SIGNAL] = { 0, };
+static guint dmap_mdns_browser_signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (DMAPMdnsBrowser, dmap_mdns_browser, G_TYPE_OBJECT)
-static gchar *service_type_name [] = {
- NULL,
- "_daap._tcp",
- "_dpap._tcp",
- "_touch-remote._tcp"
-};
+ static gchar *service_type_name[] = {
+ NULL,
+ "_daap._tcp",
+ "_dpap._tcp",
+ "_touch-remote._tcp"
+ };
GQuark
dmap_mdns_browser_error_quark (void)
{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("dmap_mdns_browser_error");
+ static GQuark quark = 0;
- return quark;
+ if (!quark)
+ quark = g_quark_from_static_string
+ ("dmap_mdns_browser_error");
+
+ return quark;
}
static void
-dmap_mdns_browser_class_init (DMAPMdnsBrowserClass *klass)
+dmap_mdns_browser_class_init (DMAPMdnsBrowserClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- dmap_mdns_browser_parent_class = g_type_class_peek_parent (klass);
-
- object_class->dispose = dmap_mdns_browser_dispose;
- object_class->finalize = dmap_mdns_browser_finalize;
-
- g_type_class_add_private (klass, sizeof (DMAPMdnsBrowserPrivate));
-
- dmap_mdns_browser_signals [SERVICE_ADDED] =
- g_signal_new ("service-added",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DMAPMdnsBrowserClass, service_added),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1, G_TYPE_POINTER);
- dmap_mdns_browser_signals [SERVICE_REMOVED] =
- g_signal_new ("service-removed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DMAPMdnsBrowserClass, service_removed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ dmap_mdns_browser_parent_class = g_type_class_peek_parent (klass);
+
+ object_class->dispose = dmap_mdns_browser_dispose;
+ object_class->finalize = dmap_mdns_browser_finalize;
+
+ g_type_class_add_private (klass, sizeof (DMAPMdnsBrowserPrivate));
+
+ dmap_mdns_browser_signals[SERVICE_ADDED] =
+ g_signal_new ("service-added",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (DMAPMdnsBrowserClass,
+ service_added), NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE,
+ 1, G_TYPE_POINTER);
+ dmap_mdns_browser_signals[SERVICE_REMOVED] =
+ g_signal_new ("service-removed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (DMAPMdnsBrowserClass,
+ service_removed), NULL, NULL,
+ g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1,
+ G_TYPE_STRING);
}
static void
-dmap_mdns_browser_init (DMAPMdnsBrowser *browser)
+dmap_mdns_browser_init (DMAPMdnsBrowser * browser)
{
- browser->priv = DMAP_MDNS_BROWSER_GET_PRIVATE (browser);
- avahi_client_init (browser);
+ browser->priv = DMAP_MDNS_BROWSER_GET_PRIVATE (browser);
+ avahi_client_init (browser);
}
static void
-dmap_mdns_browser_dispose (GObject *object)
+dmap_mdns_browser_dispose (GObject * object)
{
- DMAPMdnsBrowser *browser = DMAP_MDNS_BROWSER (object);
- GSList *walk;
- DMAPMdnsBrowserService *service;
-
- for (walk = browser->priv->services; walk; walk = walk->next) {
- service = (DMAPMdnsBrowserService *) walk->data;
- free_service (service);
- }
- g_slist_free (browser->priv->services);
-
- if (browser->priv->resolvers) {
- g_slist_foreach (browser->priv->resolvers,
- (GFunc)avahi_service_resolver_free,
- NULL);
- g_slist_free (browser->priv->resolvers);
- }
-
- if (browser->priv->service_browser) {
- avahi_service_browser_free (browser->priv->service_browser);
- }
-
- if (browser->priv->client) {
- avahi_client_free (browser->priv->client);
- }
-
- if (browser->priv->poll) {
- avahi_glib_poll_free (browser->priv->poll);
- }
-
- G_OBJECT_CLASS (dmap_mdns_browser_parent_class)->dispose (object);
+ DMAPMdnsBrowser *browser = DMAP_MDNS_BROWSER (object);
+ GSList *walk;
+ DMAPMdnsBrowserService *service;
+
+ for (walk = browser->priv->services; walk; walk = walk->next) {
+ service = (DMAPMdnsBrowserService *) walk->data;
+ free_service (service);
+ }
+ g_slist_free (browser->priv->services);
+
+ if (browser->priv->resolvers) {
+ g_slist_foreach (browser->priv->resolvers,
+ (GFunc) avahi_service_resolver_free, NULL);
+ g_slist_free (browser->priv->resolvers);
+ }
+
+ if (browser->priv->service_browser) {
+ avahi_service_browser_free (browser->priv->service_browser);
+ }
+
+ if (browser->priv->client) {
+ avahi_client_free (browser->priv->client);
+ }
+
+ if (browser->priv->poll) {
+ avahi_glib_poll_free (browser->priv->poll);
+ }
+
+ G_OBJECT_CLASS (dmap_mdns_browser_parent_class)->dispose (object);
}
static void
-dmap_mdns_browser_finalize (GObject *object)
+dmap_mdns_browser_finalize (GObject * object)
{
- g_signal_handlers_destroy (object);
- G_OBJECT_CLASS (dmap_mdns_browser_parent_class)->finalize (object);
+ g_signal_handlers_destroy (object);
+ G_OBJECT_CLASS (dmap_mdns_browser_parent_class)->finalize (object);
}
DMAPMdnsBrowser *
dmap_mdns_browser_new (DMAPMdnsBrowserServiceType type)
{
- DMAPMdnsBrowser *browser_object;
+ DMAPMdnsBrowser *browser_object;
- g_return_val_if_fail (type >= DMAP_MDNS_BROWSER_SERVICE_TYPE_INVALID &&
- type <= DMAP_MDNS_BROWSER_SERVICE_TYPE_LAST, NULL);
+ g_return_val_if_fail (type >= DMAP_MDNS_BROWSER_SERVICE_TYPE_INVALID
+ && type <= DMAP_MDNS_BROWSER_SERVICE_TYPE_LAST,
+ NULL);
- browser_object = DMAP_MDNS_BROWSER (g_object_new (DMAP_TYPE_MDNS_BROWSER, NULL));
- browser_object->priv->service_type = type;
+ browser_object =
+ DMAP_MDNS_BROWSER (g_object_new
+ (DMAP_TYPE_MDNS_BROWSER, NULL));
+ browser_object->priv->service_type = type;
- return browser_object;
+ return browser_object;
}
gboolean
-dmap_mdns_browser_start (DMAPMdnsBrowser *browser,
- GError **error)
+dmap_mdns_browser_start (DMAPMdnsBrowser * browser, GError ** error)
{
- if (browser->priv->client == NULL) {
- g_set_error (error,
- DMAP_MDNS_BROWSER_ERROR,
- DMAP_MDNS_BROWSER_ERROR_NOT_RUNNING,
- "%s",
- _("MDNS service is not running"));
- return FALSE;
- }
- if (browser->priv->service_browser != NULL) {
- g_debug ("Browser already active");
- return TRUE;
- }
-
- browser->priv->service_browser = avahi_service_browser_new (browser->priv->client,
- AVAHI_IF_UNSPEC,
- AVAHI_PROTO_UNSPEC,
- service_type_name [browser->priv->service_type],
- NULL,
+ if (browser->priv->client == NULL) {
+ g_set_error (error,
+ DMAP_MDNS_BROWSER_ERROR,
+ DMAP_MDNS_BROWSER_ERROR_NOT_RUNNING,
+ "%s", _("MDNS service is not running"));
+ return FALSE;
+ }
+ if (browser->priv->service_browser != NULL) {
+ g_debug ("Browser already active");
+ return TRUE;
+ }
+
+ browser->priv->service_browser =
+ avahi_service_browser_new (browser->priv->client,
+ AVAHI_IF_UNSPEC,
+ AVAHI_PROTO_UNSPEC,
+ service_type_name[browser->priv->
+ service_type],
+ NULL,
#ifdef HAVE_AVAHI_0_6
- 0,
+ 0,
#endif
- (AvahiServiceBrowserCallback) browse_cb,
- browser);
- if (browser->priv->service_browser == NULL) {
- g_debug ("Error starting mDNS discovery using AvahiServiceBrowser");
- g_set_error (error,
- DMAP_MDNS_BROWSER_ERROR,
- DMAP_MDNS_BROWSER_ERROR_FAILED,
- "%s",
- _("Unable to activate browser"));
-
- return FALSE;
- }
-
- return TRUE;
+ (AvahiServiceBrowserCallback)
+ browse_cb, browser);
+ if (browser->priv->service_browser == NULL) {
+ g_debug ("Error starting mDNS discovery using AvahiServiceBrowser");
+ g_set_error (error,
+ DMAP_MDNS_BROWSER_ERROR,
+ DMAP_MDNS_BROWSER_ERROR_FAILED,
+ "%s", _("Unable to activate browser"));
+
+ return FALSE;
+ }
+
+ return TRUE;
}
gboolean
-dmap_mdns_browser_stop (DMAPMdnsBrowser *browser,
- GError **error)
+dmap_mdns_browser_stop (DMAPMdnsBrowser * browser, GError ** error)
{
- if (browser->priv->client == NULL) {
- g_set_error (error,
- DMAP_MDNS_BROWSER_ERROR,
- DMAP_MDNS_BROWSER_ERROR_NOT_RUNNING,
- "%s",
- _("MDNS service is not running"));
- return FALSE;
- }
- if (browser->priv->service_browser == NULL) {
- g_set_error (error,
- DMAP_MDNS_BROWSER_ERROR,
- DMAP_MDNS_BROWSER_ERROR_FAILED,
- "%s",
- _("Browser is not active"));
- return FALSE;
- }
- avahi_service_browser_free (browser->priv->service_browser);
- browser->priv->service_browser = NULL;
-
- return TRUE;
+ if (browser->priv->client == NULL) {
+ g_set_error (error,
+ DMAP_MDNS_BROWSER_ERROR,
+ DMAP_MDNS_BROWSER_ERROR_NOT_RUNNING,
+ "%s", _("MDNS service is not running"));
+ return FALSE;
+ }
+ if (browser->priv->service_browser == NULL) {
+ g_set_error (error,
+ DMAP_MDNS_BROWSER_ERROR,
+ DMAP_MDNS_BROWSER_ERROR_FAILED,
+ "%s", _("Browser is not active"));
+ return FALSE;
+ }
+ avahi_service_browser_free (browser->priv->service_browser);
+ browser->priv->service_browser = NULL;
+
+ return TRUE;
}
G_CONST_RETURN GSList *
-dmap_mdns_browser_get_services (DMAPMdnsBrowser *browser)
+dmap_mdns_browser_get_services (DMAPMdnsBrowser * browser)
{
- g_return_val_if_fail (browser != NULL, NULL);
- return browser->priv->services;
+ g_return_val_if_fail (browser != NULL, NULL);
+ return browser->priv->services;
}
DMAPMdnsBrowserServiceType
-dmap_mdns_browser_get_service_type (DMAPMdnsBrowser *browser)
+dmap_mdns_browser_get_service_type (DMAPMdnsBrowser * browser)
{
- g_return_val_if_fail (browser != NULL, DMAP_MDNS_BROWSER_SERVICE_TYPE_INVALID);
- return browser->priv->service_type;
+ g_return_val_if_fail (browser != NULL,
+ DMAP_MDNS_BROWSER_SERVICE_TYPE_INVALID);
+ return browser->priv->service_type;
}
static void
-client_cb (AvahiClient *client,
- AvahiClientState state,
- DMAPMdnsBrowser *browser)
+client_cb (AvahiClient * client,
+ AvahiClientState state, DMAPMdnsBrowser * browser)
{
- /* Called whenever the client or server state changes */
+ /* Called whenever the client or server state changes */
- switch (state) {
+ switch (state) {
#ifdef HAVE_AVAHI_0_6
- case AVAHI_CLIENT_FAILURE:
- g_warning ("Client failure: %s\n", avahi_strerror (avahi_client_errno (client)));
- break;
+ case AVAHI_CLIENT_FAILURE:
+ g_warning ("Client failure: %s\n",
+ avahi_strerror (avahi_client_errno (client)));
+ break;
#endif
- default:
- break;
- }
+ default:
+ break;
+ }
}
static void
-avahi_client_init (DMAPMdnsBrowser *browser)
+avahi_client_init (DMAPMdnsBrowser * browser)
{
- gint error = 0;
-
- avahi_set_allocator (avahi_glib_allocator ());
+ gint error = 0;
- browser->priv->poll = avahi_glib_poll_new (NULL, G_PRIORITY_DEFAULT);
+ avahi_set_allocator (avahi_glib_allocator ());
- if (!browser->priv->poll) {
- g_debug ("Unable to create AvahiGlibPoll object for mDNS");
- }
+ browser->priv->poll = avahi_glib_poll_new (NULL, G_PRIORITY_DEFAULT);
+ if (!browser->priv->poll) {
+ g_debug ("Unable to create AvahiGlibPoll object for mDNS");
+ }
#ifdef HAVE_AVAHI_0_5
- browser->priv->client = avahi_client_new (avahi_glib_poll_get (browser->priv->poll),
- (AvahiClientCallback) client_cb,
- browser,
- &error);
+ browser->priv->client =
+ avahi_client_new (avahi_glib_poll_get (browser->priv->poll),
+ (AvahiClientCallback) client_cb, browser,
+ &error);
#endif
#ifdef HAVE_AVAHI_0_6
- {
- AvahiClientFlags flags = 0;
-
- browser->priv->client = avahi_client_new (avahi_glib_poll_get (browser->priv->poll),
- flags,
- (AvahiClientCallback) client_cb,
- browser,
- &error);
- }
+ {
+ AvahiClientFlags flags = 0;
+
+ browser->priv->client =
+ avahi_client_new (avahi_glib_poll_get
+ (browser->priv->poll), flags,
+ (AvahiClientCallback) client_cb,
+ browser, &error);
+ }
#endif
}
static void
-resolve_cb (AvahiServiceResolver *service_resolver,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- AvahiResolverEvent event,
- const gchar *service_name,
- const gchar *type,
- const gchar *domain,
- const gchar *host_name,
- const AvahiAddress *address,
- uint16_t port,
- AvahiStringList *text,
+resolve_cb (AvahiServiceResolver * service_resolver,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiResolverEvent event,
+ const gchar * service_name,
+ const gchar * type,
+ const gchar * domain,
+ const gchar * host_name,
+ const AvahiAddress * address,
+ uint16_t port, AvahiStringList * text,
#ifdef HAVE_AVAHI_0_6
- AvahiLookupResultFlags flags,
+ AvahiLookupResultFlags flags,
#endif
- DMAPMdnsBrowser *browser)
+ DMAPMdnsBrowser * browser)
{
- gchar *name = NULL;
- gchar *pair = NULL; /* FIXME: extract DACP-specific items into sub-class? See also howl code. */
- gchar host[AVAHI_ADDRESS_STR_MAX];
- gboolean pp = FALSE;
- DMAPMdnsBrowserService *service;
-
- switch (event) {
- case AVAHI_RESOLVER_FAILURE:
- g_warning ("Failed to resolve service '%s' of type '%s' in domain '%s': %s\n", service_name, type, domain, avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(service_resolver))));
- break;
- case AVAHI_RESOLVER_FOUND:
-
- if (text) {
- AvahiStringList *l;
-
- for (l = text; l != NULL; l = l->next) {
- size_t size;
- gchar *key;
- gchar *value;
- gint ret;
-
- ret = avahi_string_list_get_pair (l, &key, &value, &size);
- if (ret != 0 || key == NULL) {
- continue;
- }
-
- if (strcmp (key, "Password") == 0) {
- if (size >= 4 && strncmp (value, "true", 4) == 0) {
- pp = TRUE;
- } else if (size >= 1 && strncmp (value, "1", 1) == 0) {
- pp = TRUE;
- }
- } else if (strcmp (key, "Machine Name") == 0) {
- if (name == NULL)
- name = g_strdup (value);
- } else if (strcmp (key, "DvNm") == 0) {
- if (name != NULL)
- g_free (name);
- /* Remote's name is presented as DvNm in DACP */
- name = g_strdup(value);
- } else if (strcmp (key, "Pair") == 0) {
- /* Pair is used when first connecting to a DACP remote */
- pair = g_strdup(value);
- }
-
- g_free (key);
- g_free (value);
- }
- }
-
- if (name == NULL) {
- name = g_strdup (service_name);
- }
-
- avahi_address_snprint (host, AVAHI_ADDRESS_STR_MAX, address);
-
- service = g_new (DMAPMdnsBrowserService, 1);
- service->service_name = g_strdup (service_name);
- service->name = name;
- service->host = g_strdup (host);
- service->port = port;
- service->pair = pair;
- service->password_protected = pp;
- browser->priv->services = g_slist_append (browser->priv->services, service);
- g_signal_emit (browser,
- dmap_mdns_browser_signals [SERVICE_ADDED], 0, service);
- break;
- default:
- g_warning ("Unhandled event");
- break;
- }
-
- browser->priv->resolvers = g_slist_remove (browser->priv->resolvers, service_resolver);
- avahi_service_resolver_free (service_resolver);
+ gchar *name = NULL;
+ gchar *pair = NULL; /* FIXME: extract DACP-specific items into sub-class? See also howl code. */
+ gchar host[AVAHI_ADDRESS_STR_MAX];
+ gboolean pp = FALSE;
+ DMAPMdnsBrowserService *service;
+
+ switch (event) {
+ case AVAHI_RESOLVER_FAILURE:
+ g_warning
+ ("Failed to resolve service '%s' of type '%s' in domain '%s': %s\n",
+ service_name, type, domain,
+ avahi_strerror (avahi_client_errno
+ (avahi_service_resolver_get_client
+ (service_resolver))));
+ break;
+ case AVAHI_RESOLVER_FOUND:
+
+ if (text) {
+ AvahiStringList *l;
+
+ for (l = text; l != NULL; l = l->next) {
+ size_t size;
+ gchar *key;
+ gchar *value;
+ gint ret;
+
+ ret = avahi_string_list_get_pair (l, &key,
+ &value,
+ &size);
+ if (ret != 0 || key == NULL) {
+ continue;
+ }
+
+ if (strcmp (key, "Password") == 0) {
+ if (size >= 4
+ && strncmp (value, "true",
+ 4) == 0) {
+ pp = TRUE;
+ } else if (size >= 1
+ && strncmp (value, "1",
+ 1) == 0) {
+ pp = TRUE;
+ }
+ } else if (strcmp (key, "Machine Name") == 0) {
+ if (name == NULL)
+ name = g_strdup (value);
+ } else if (strcmp (key, "DvNm") == 0) {
+ if (name != NULL)
+ g_free (name);
+ /* Remote's name is presented as DvNm in DACP */
+ name = g_strdup (value);
+ } else if (strcmp (key, "Pair") == 0) {
+ /* Pair is used when first connecting to a DACP remote */
+ pair = g_strdup (value);
+ }
+
+ g_free (key);
+ g_free (value);
+ }
+ }
+
+ if (name == NULL) {
+ name = g_strdup (service_name);
+ }
+
+ avahi_address_snprint (host, AVAHI_ADDRESS_STR_MAX, address);
+
+ service = g_new (DMAPMdnsBrowserService, 1);
+ service->service_name = g_strdup (service_name);
+ service->name = name;
+ service->host = g_strdup (host);
+ service->port = port;
+ service->pair = pair;
+ service->password_protected = pp;
+ browser->priv->services =
+ g_slist_append (browser->priv->services, service);
+ g_signal_emit (browser,
+ dmap_mdns_browser_signals[SERVICE_ADDED], 0,
+ service);
+ break;
+ default:
+ g_warning ("Unhandled event");
+ break;
+ }
+
+ browser->priv->resolvers =
+ g_slist_remove (browser->priv->resolvers, service_resolver);
+ avahi_service_resolver_free (service_resolver);
}
static gboolean
-dmap_mdns_browser_resolve (DMAPMdnsBrowser *browser,
- const gchar *name,
- const gchar *domain)
+dmap_mdns_browser_resolve (DMAPMdnsBrowser * browser,
+ const gchar * name, const gchar * domain)
{
- AvahiServiceResolver *service_resolver;
-
- service_resolver = avahi_service_resolver_new (browser->priv->client,
- AVAHI_IF_UNSPEC,
- AVAHI_PROTO_INET,
- name,
- service_type_name [browser->priv->service_type],
- domain,
- AVAHI_PROTO_UNSPEC,
+ AvahiServiceResolver *service_resolver;
+
+ service_resolver = avahi_service_resolver_new (browser->priv->client,
+ AVAHI_IF_UNSPEC,
+ AVAHI_PROTO_INET,
+ name,
+ service_type_name
+ [browser->priv->
+ service_type], domain,
+ AVAHI_PROTO_UNSPEC,
#ifdef HAVE_AVAHI_0_6
- 0,
+ 0,
#endif
- (AvahiServiceResolverCallback)resolve_cb,
- browser);
- if (service_resolver == NULL) {
- g_debug ("Error starting mDNS resolving using AvahiServiceResolver");
- return FALSE;
- }
+ (AvahiServiceResolverCallback) resolve_cb, browser);
+ if (service_resolver == NULL) {
+ g_debug ("Error starting mDNS resolving using AvahiServiceResolver");
+ return FALSE;
+ }
- browser->priv->resolvers = g_slist_prepend (browser->priv->resolvers, service_resolver);
+ browser->priv->resolvers =
+ g_slist_prepend (browser->priv->resolvers, service_resolver);
- return TRUE;
+ return TRUE;
}
static void
-browser_add_service (DMAPMdnsBrowser *browser,
- const gchar *service_name,
- const gchar *domain)
+browser_add_service (DMAPMdnsBrowser * browser,
+ const gchar * service_name, const gchar * domain)
{
- dmap_mdns_browser_resolve (browser, service_name, domain);
+ dmap_mdns_browser_resolve (browser, service_name, domain);
}
static void
-browser_remove_service (DMAPMdnsBrowser *browser,
- const gchar *service_name)
+browser_remove_service (DMAPMdnsBrowser * browser, const gchar * service_name)
{
- g_signal_emit (browser,
- dmap_mdns_browser_signals [SERVICE_REMOVED],
- 0,
- service_name);
+ g_signal_emit (browser,
+ dmap_mdns_browser_signals[SERVICE_REMOVED],
+ 0, service_name);
}
static void
-browse_cb (AvahiServiceBrowser *service_browser,
- AvahiIfIndex interface,
- AvahiProtocol protocol,
- AvahiBrowserEvent event,
- const gchar *name,
- const gchar *type,
- const gchar *domain,
+browse_cb (AvahiServiceBrowser * service_browser,
+ AvahiIfIndex interface,
+ AvahiProtocol protocol,
+ AvahiBrowserEvent event,
+ const gchar * name, const gchar * type, const gchar * domain,
#ifdef HAVE_AVAHI_0_6
- AvahiLookupResultFlags flags,
+ AvahiLookupResultFlags flags,
#endif
- DMAPMdnsBrowser *browser)
+ DMAPMdnsBrowser * browser)
{
- gboolean local;
+ gboolean local;
#ifdef HAVE_AVAHI_0_5
- local = avahi_client_is_service_local (browser->priv->client, interface, protocol, name, type, domain);
+ local = avahi_client_is_service_local (browser->priv->client,
+ interface, protocol, name,
+ type, domain);
#endif
#ifdef HAVE_AVAHI_0_6
- local = ((flags & AVAHI_LOOKUP_RESULT_LOCAL) != 0);
+ local = ((flags & AVAHI_LOOKUP_RESULT_LOCAL) != 0);
#endif
- if (local && getenv ("LIBDMAPSHARING_ENABLE_LOCAL") == NULL) {
- g_warning ("Ignoring local service %s", name);
- return;
- }
-
- if (event == AVAHI_BROWSER_NEW) {
- browser_add_service (browser, name, domain);
- } else if (event == AVAHI_BROWSER_REMOVE) {
- browser_remove_service (browser, name);
- }
+ if (local && getenv ("LIBDMAPSHARING_ENABLE_LOCAL") == NULL) {
+ g_warning ("Ignoring local service %s", name);
+ return;
+ }
+
+ if (event == AVAHI_BROWSER_NEW) {
+ browser_add_service (browser, name, domain);
+ } else if (event == AVAHI_BROWSER_REMOVE) {
+ browser_remove_service (browser, name);
+ }
}
static void
-free_service (DMAPMdnsBrowserService *service)
+free_service (DMAPMdnsBrowserService * service)
{
- g_free (service->service_name);
- g_free (service->name);
- g_free (service->host);
+ g_free (service->service_name);
+ g_free (service->name);
+ g_free (service->host);
g_free (service->pair);
- g_free (service);
+ g_free (service);
}
diff --git a/libdmapsharing/dmap-mdns-browser-howl.c b/libdmapsharing/dmap-mdns-browser-howl.c
index 2258b9a..dc9c6c7 100644
--- a/libdmapsharing/dmap-mdns-browser-howl.c
+++ b/libdmapsharing/dmap-mdns-browser-howl.c
@@ -46,20 +46,21 @@
struct DMAPMdnsBrowserPrivate
{
- DMAPMdnsBrowserServiceType service_type;
- sw_discovery *discovery;
- sw_discovery_oid *oid;
-
- GnomeVFSAddress *local_address;
- guint watch_id;
- GSList *services;
- GSList *resolvers;
+ DMAPMdnsBrowserServiceType service_type;
+ sw_discovery *discovery;
+ sw_discovery_oid *oid;
+
+ GnomeVFSAddress *local_address;
+ guint watch_id;
+ GSList *services;
+ GSList *resolvers;
};
-enum {
- SERVICE_ADDED,
- SERVICE_REMOVED,
- LAST_SIGNAL
+enum
+{
+ SERVICE_ADDED,
+ SERVICE_REMOVED,
+ LAST_SIGNAL
};
/* stupid howl includes howl_config.h */
@@ -71,470 +72,460 @@ enum {
#undef VERSION
#include <howl.h>
-static void dmap_mdns_browser_class_init (DMAPMdnsBrowserClass *klass);
-static void dmap_mdns_browser_init (DMAPMdnsBrowser *browser);
-static void dmap_mdns_browser_dispose (GObject *object);
-static void dmap_mdns_browser_finalize (GObject *object);
+static void dmap_mdns_browser_class_init (DMAPMdnsBrowserClass * klass);
+static void dmap_mdns_browser_init (DMAPMdnsBrowser * browser);
+static void dmap_mdns_browser_dispose (GObject * object);
+static void dmap_mdns_browser_finalize (GObject * object);
-static void free_service (DMAPMdnsBrowserService *service);
+static void free_service (DMAPMdnsBrowserService * service);
#define DMAP_MDNS_BROWSER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DMAP_TYPE_MDNS_BROWSER, DMAPMdnsBrowserPrivate))
-static guint signals [LAST_SIGNAL] = { 0, };
+static guint signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (DMAPMdnsBrowser, dmap_mdns_browser, G_TYPE_OBJECT)
-GQuark
+ GQuark
dmap_mdns_browser_error_quark (void)
{
- static GQuark quark = 0;
- if (!quark)
- quark = g_quark_from_static_string ("dmap_mdns_browser_error");
+ static GQuark quark = 0;
+
+ if (!quark)
+ quark = g_quark_from_static_string
+ ("dmap_mdns_browser_error");
- return quark;
+ return quark;
}
static gboolean
-howl_in_cb (GIOChannel *io_channel,
- GIOCondition condition,
- DMAPMdnsBrowser *browser)
+howl_in_cb (GIOChannel * io_channel,
+ GIOCondition condition, DMAPMdnsBrowser * browser)
{
- sw_salt salt;
-
- if (sw_discovery_salt (*browser->priv->discovery, &salt) == SW_OKAY) {
- sw_salt_lock (salt);
- sw_discovery_read_socket (*browser->priv->discovery);
- sw_salt_unlock (salt);
- }
-
- return TRUE;
+ sw_salt salt;
+
+ if (sw_discovery_salt (*browser->priv->discovery, &salt) == SW_OKAY) {
+ sw_salt_lock (salt);
+ sw_discovery_read_socket (*browser->priv->discovery);
+ sw_salt_unlock (salt);
+ }
+
+ return TRUE;
}
static void
-howl_client_init (DMAPMdnsBrowser *browser)
+howl_client_init (DMAPMdnsBrowser * browser)
{
- sw_result result;
- int fd;
- GIOChannel *channel;
-
- browser->priv->discovery = g_new0 (sw_discovery, 1);
- result = sw_discovery_init (browser->priv->discovery);
-
- if (result != SW_OKAY) {
- g_free (browser->priv->discovery);
- browser->priv->discovery = NULL;
- return;
- }
-
- fd = sw_discovery_socket (*browser->priv->discovery);
-
- channel = g_io_channel_unix_new (fd);
- browser->priv->watch_id = g_io_add_watch (channel, G_IO_IN, (GIOFunc)howl_in_cb, browser);
- g_io_channel_unref (channel);
+ sw_result result;
+ int fd;
+ GIOChannel *channel;
+
+ browser->priv->discovery = g_new0 (sw_discovery, 1);
+ result = sw_discovery_init (browser->priv->discovery);
+
+ if (result != SW_OKAY) {
+ g_free (browser->priv->discovery);
+ browser->priv->discovery = NULL;
+ return;
+ }
+
+ fd = sw_discovery_socket (*browser->priv->discovery);
+
+ channel = g_io_channel_unix_new (fd);
+ browser->priv->watch_id =
+ g_io_add_watch (channel, G_IO_IN, (GIOFunc) howl_in_cb,
+ browser);
+ g_io_channel_unref (channel);
}
static gboolean
-host_is_local (DMAPMdnsBrowser *browser,
- const char *host)
+host_is_local (DMAPMdnsBrowser * browser, const char *host)
{
- GnomeVFSAddress *remote;
- gboolean equal;
- guint32 l_ip;
- guint32 r_ip;
+ GnomeVFSAddress *remote;
+ gboolean equal;
+ guint32 l_ip;
+ guint32 r_ip;
- if (browser->priv->local_address == NULL) {
- g_warning ("Unable to resolve address");
- return FALSE;
- }
+ if (browser->priv->local_address == NULL) {
+ g_warning ("Unable to resolve address");
+ return FALSE;
+ }
- remote = gnome_vfs_address_new_from_string (host);
- if (remote == NULL) {
- g_warning ("Unable to resolve address for %s", host);
- return FALSE;
- }
+ remote = gnome_vfs_address_new_from_string (host);
+ if (remote == NULL) {
+ g_warning ("Unable to resolve address for %s", host);
+ return FALSE;
+ }
- l_ip = gnome_vfs_address_get_ipv4 (browser->priv->local_address);
- r_ip = gnome_vfs_address_get_ipv4 (remote);
- equal = l_ip == r_ip;
+ l_ip = gnome_vfs_address_get_ipv4 (browser->priv->local_address);
+ r_ip = gnome_vfs_address_get_ipv4 (remote);
+ equal = l_ip == r_ip;
- /* FIXME: Use this when we can depend on gnome-vfs 2.14 */
- /*equal = gnome_vfs_address_equal (browser->priv->local_address, remote);*/
+ /* FIXME: Use this when we can depend on gnome-vfs 2.14 */
+ /*equal = gnome_vfs_address_equal (browser->priv->local_address, remote); */
- gnome_vfs_address_free (remote);
+ gnome_vfs_address_free (remote);
- return equal;
+ return equal;
}
static void
-set_local_address (DMAPMdnsBrowser *browser)
+set_local_address (DMAPMdnsBrowser * browser)
{
- char host_name [256];
- GnomeVFSResolveHandle *rh;
- GnomeVFSAddress *address;
- GnomeVFSResult res;
-
- if (gethostname (host_name, sizeof (host_name)) != 0) {
- g_warning ("gethostname failed: %s", g_strerror (errno));
- return;
- }
-
- res = gnome_vfs_resolve (host_name, &rh);
-
- if (res != GNOME_VFS_OK) {
- return;
- }
-
- address = NULL;
- while (gnome_vfs_resolve_next_address (rh, &address)) {
- if (browser->priv->local_address == NULL) {
- browser->priv->local_address = gnome_vfs_address_dup (address);
- }
- gnome_vfs_address_free (address);
- }
-
- gnome_vfs_resolve_free (rh);
+ char host_name[256];
+ GnomeVFSResolveHandle *rh;
+ GnomeVFSAddress *address;
+ GnomeVFSResult res;
+
+ if (gethostname (host_name, sizeof (host_name)) != 0) {
+ g_warning ("gethostname failed: %s", g_strerror (errno));
+ return;
+ }
+
+ res = gnome_vfs_resolve (host_name, &rh);
+
+ if (res != GNOME_VFS_OK) {
+ return;
+ }
+
+ address = NULL;
+ while (gnome_vfs_resolve_next_address (rh, &address)) {
+ if (browser->priv->local_address == NULL) {
+ browser->priv->local_address =
+ gnome_vfs_address_dup (address);
+ }
+ gnome_vfs_address_free (address);
+ }
+
+ gnome_vfs_resolve_free (rh);
}
static sw_result
resolve_cb (sw_discovery discovery,
- sw_discovery_oid oid,
- sw_uint32 interface_index,
- sw_const_string service_name,
- sw_const_string type,
- sw_const_string domain,
- sw_ipv4_address address,
- sw_port port,
- sw_octets text_record,
- sw_ulong text_record_length,
- DMAPMdnsBrowser *browser)
+ sw_discovery_oid oid,
+ sw_uint32 interface_index,
+ sw_const_string service_name,
+ sw_const_string type,
+ sw_const_string domain,
+ sw_ipv4_address address,
+ sw_port port,
+ sw_octets text_record,
+ sw_ulong text_record_length, DMAPMdnsBrowser * browser)
{
- char *host;
- char *name;
- char *pair;
- sw_text_record_iterator it;
- gboolean pp = FALSE;
- DMAPMdnsBrowserService *service;
-
- host = g_malloc (16);
- name = NULL;
-
- sw_ipv4_address_name (address, host, 16);
-
- /* skip local services */
- if (host_is_local (browser, host)) {
- goto done;
- }
-
- if (sw_text_record_iterator_init (&it, text_record, text_record_length) == SW_OKAY) {
- sw_char key [SW_TEXT_RECORD_MAX_LEN];
- sw_octet val [SW_TEXT_RECORD_MAX_LEN];
- sw_ulong val_len;
-
- while (sw_text_record_iterator_next (it, (char *)key, val, &val_len) == SW_OKAY) {
- if (strcmp ((char *)key, "Password") == 0) {
- if (val_len >= 4 && strncmp ((char *)val, "true", 4) == 0) {
- pp = TRUE;
- }
- }
- if (strcmp ((char *)key, "Machine Name") == 0) {
- if (name != NULL)
- g_free (name);
- name = g_strdup ((char *)val);
- } else if (strcmp ((char *)key, "DvNm") == 0) {
- if (name != NULL)
- g_free (name);
- /* Remote's name is presented as DvNm in DACP */
- name = g_strdup ((char *)val);
- } else if (strcmp ((char *)key, "Pair") == 0) {
- if (pair != NULL)
- g_free (pair);
- /* Pair is used when first connecting to a DACP remote */
- pair = g_strdup ((char *)val);
- }
- }
-
- sw_text_record_iterator_fina (it);
- }
-
- if (name == NULL) {
- name = g_strdup (service_name);
- }
-
- service = g_new (DMAPMdnsBrowserService, 1);
- service->service_name = g_strdup (service_name);
- service->name = name;
- service->host = g_strdup (host);
- service->port = port;
- service->password_protected = pp;
- service->pair = pair;
- browser->priv->services = g_slist_append (browser->priv->services, service);
-
- g_signal_emit (browser,
- signals [SERVICE_ADDED],
- 0,
- service);
-done:
- g_free (host);
- g_free (name);
-
- return SW_OKAY;
+ char *host;
+ char *name;
+ char *pair;
+ sw_text_record_iterator it;
+ gboolean pp = FALSE;
+ DMAPMdnsBrowserService *service;
+
+ host = g_malloc (16);
+ name = NULL;
+
+ sw_ipv4_address_name (address, host, 16);
+
+ /* skip local services */
+ if (host_is_local (browser, host)) {
+ goto done;
+ }
+
+ if (sw_text_record_iterator_init
+ (&it, text_record, text_record_length) == SW_OKAY) {
+ sw_char key[SW_TEXT_RECORD_MAX_LEN];
+ sw_octet val[SW_TEXT_RECORD_MAX_LEN];
+ sw_ulong val_len;
+
+ while (sw_text_record_iterator_next
+ (it, (char *) key, val, &val_len) == SW_OKAY) {
+ if (strcmp ((char *) key, "Password") == 0) {
+ if (val_len >= 4
+ && strncmp ((char *) val, "true",
+ 4) == 0) {
+ pp = TRUE;
+ }
+ }
+ if (strcmp ((char *) key, "Machine Name") == 0) {
+ if (name != NULL)
+ g_free (name);
+ name = g_strdup ((char *) val);
+ } else if (strcmp ((char *) key, "DvNm") == 0) {
+ if (name != NULL)
+ g_free (name);
+ /* Remote's name is presented as DvNm in DACP */
+ name = g_strdup ((char *) val);
+ } else if (strcmp ((char *) key, "Pair") == 0) {
+ if (pair != NULL)
+ g_free (pair);
+ /* Pair is used when first connecting to a DACP remote */
+ pair = g_strdup ((char *) val);
+ }
+ }
+
+ sw_text_record_iterator_fina (it);
+ }
+
+ if (name == NULL) {
+ name = g_strdup (service_name);
+ }
+
+ service = g_new (DMAPMdnsBrowserService, 1);
+ service->service_name = g_strdup (service_name);
+ service->name = name;
+ service->host = g_strdup (host);
+ service->port = port;
+ service->password_protected = pp;
+ service->pair = pair;
+ browser->priv->services =
+ g_slist_append (browser->priv->services, service);
+
+ g_signal_emit (browser, signals[SERVICE_ADDED], 0, service);
+ done:
+ g_free (host);
+ g_free (name);
+
+ return SW_OKAY;
}
static gboolean
-dmap_mdns_browser_resolve (DMAPMdnsBrowser *browser,
- const char *name)
+dmap_mdns_browser_resolve (DMAPMdnsBrowser * browser, const char *name)
{
- sw_result result;
- sw_discovery_oid oid;
-
- result = sw_discovery_resolve (*browser->priv->discovery,
- 0,
- name,
- "_dmap._tcp",
- "local",
- (sw_discovery_resolve_reply) resolve_cb,
- (sw_opaque) browser,
- (sw_discovery_oid *) &oid);
-
- return TRUE;
+ sw_result result;
+ sw_discovery_oid oid;
+
+ result = sw_discovery_resolve (*browser->priv->discovery,
+ 0,
+ name,
+ "_dmap._tcp",
+ "local",
+ (sw_discovery_resolve_reply)
+ resolve_cb, (sw_opaque) browser,
+ (sw_discovery_oid *) & oid);
+
+ return TRUE;
}
static void
-browser_add_service (DMAPMdnsBrowser *browser,
- const char *service_name)
+browser_add_service (DMAPMdnsBrowser * browser, const char *service_name)
{
- dmap_mdns_browser_resolve (browser, service_name);
+ dmap_mdns_browser_resolve (browser, service_name);
}
static void
-browser_remove_service (DMAPMdnsBrowser *browser,
- const char *service_name)
+browser_remove_service (DMAPMdnsBrowser * browser, const char *service_name)
{
- g_signal_emit (browser,
- dmap_mdns_browser_signals [SERVICE_REMOVED],
- 0,
- service_name);
+ g_signal_emit (browser,
+ dmap_mdns_browser_signals[SERVICE_REMOVED],
+ 0, service_name);
}
static sw_result
browse_cb (sw_discovery discovery,
- sw_discovery_oid oid,
- sw_discovery_browse_status status,
- sw_uint32 interface_index,
- sw_const_string name,
- sw_const_string type,
- sw_const_string domain,
- DMAPMdnsBrowser *browser)
+ sw_discovery_oid oid,
+ sw_discovery_browse_status status,
+ sw_uint32 interface_index,
+ sw_const_string name,
+ sw_const_string type,
+ sw_const_string domain, DMAPMdnsBrowser * browser)
{
- if (status == SW_DISCOVERY_BROWSE_ADD_SERVICE) {
- browser_add_service (browser, name);
- } else if (status == SW_DISCOVERY_BROWSE_REMOVE_SERVICE) {
- browser_remove_service (browser, name);
- }
+ if (status == SW_DISCOVERY_BROWSE_ADD_SERVICE) {
+ browser_add_service (browser, name);
+ } else if (status == SW_DISCOVERY_BROWSE_REMOVE_SERVICE) {
+ browser_remove_service (browser, name);
+ }
- return SW_OKAY;
+ return SW_OKAY;
}
DMAPMdnsBrowser *
dmap_mdns_browser_new (DMAPMdnsBrowserServiceType type)
{
- DMAPMdnsBrowser *browser_object;
+ DMAPMdnsBrowser *browser_object;
- g_return_val_if_fail (type >= DMAP_MDNS_BROWSER_SERVICE_TYPE_INVALID &&
- type <= DMAP_MDNS_BROWSER_SERVICE_TYPE_LAST, NULL);
+ g_return_val_if_fail (type >= DMAP_MDNS_BROWSER_SERVICE_TYPE_INVALID
+ && type <= DMAP_MDNS_BROWSER_SERVICE_TYPE_LAST,
+ NULL);
- browser_object = DMAP_MDNS_BROWSER (g_object_new (DMAP_TYPE_MDNS_BROWSER, NULL));
- browser_object->priv->service_type = type;
+ browser_object =
+ DMAP_MDNS_BROWSER (g_object_new
+ (DMAP_TYPE_MDNS_BROWSER, NULL));
+ browser_object->priv->service_type = type;
- return browser_object;
+ return browser_object;
}
gboolean
-dmap_mdns_browser_start (DMAPMdnsBrowser *browser,
- GError **error)
+dmap_mdns_browser_start (DMAPMdnsBrowser * browser, GError ** error)
{
- sw_result result;
-
- if (browser->priv->discovery == NULL) {
- g_set_error (error,
- DMAP_MDNS_BROWSER_ERROR,
- DMAP_MDNS_BROWSER_ERROR_NOT_RUNNING,
- "%s",
- _("MDNS service is not running"));
- return FALSE;
- }
-
- if (browser->priv->oid != NULL) {
- g_debug ("Browser already active");
- return FALSE;
- }
-
- browser->priv->oid = g_new0 (sw_discovery_oid, 1);
-
- result = sw_discovery_browse (*browser->priv->discovery,
- 0,
- "_dmap._tcp",
- "local",
- (sw_discovery_browse_reply) browse_cb,
- (sw_opaque) browser,
- (sw_discovery_oid *) browser->priv->oid);
-
-
- if (result != SW_OKAY) {
- g_debug ("Error starting mDNS discovery using Howl");
- g_set_error (error,
- DMAP_MDNS_BROWSER_ERROR,
- DMAP_MDNS_BROWSER_ERROR_FAILED,
- "%s",
- _("Unable to activate browser"));
-
- return FALSE;
- }
-
- return TRUE;
+ sw_result result;
+
+ if (browser->priv->discovery == NULL) {
+ g_set_error (error,
+ DMAP_MDNS_BROWSER_ERROR,
+ DMAP_MDNS_BROWSER_ERROR_NOT_RUNNING,
+ "%s", _("MDNS service is not running"));
+ return FALSE;
+ }
+
+ if (browser->priv->oid != NULL) {
+ g_debug ("Browser already active");
+ return FALSE;
+ }
+
+ browser->priv->oid = g_new0 (sw_discovery_oid, 1);
+
+ result = sw_discovery_browse (*browser->priv->discovery,
+ 0,
+ "_dmap._tcp",
+ "local",
+ (sw_discovery_browse_reply) browse_cb,
+ (sw_opaque) browser,
+ (sw_discovery_oid *) browser->priv->
+ oid);
+
+ if (result != SW_OKAY) {
+ g_debug ("Error starting mDNS discovery using Howl");
+ g_set_error (error,
+ DMAP_MDNS_BROWSER_ERROR,
+ DMAP_MDNS_BROWSER_ERROR_FAILED,
+ "%s", _("Unable to activate browser"));
+
+ return FALSE;
+ }
+
+ return TRUE;
}
gboolean
-dmap_mdns_browser_stop (DMAPMdnsBrowser *browser,
- GError **error)
+dmap_mdns_browser_stop (DMAPMdnsBrowser * browser, GError ** error)
{
- if (browser->priv->discovery == NULL) {
- g_set_error (error,
- DMAP_MDNS_BROWSER_ERROR,
- DMAP_MDNS_BROWSER_ERROR_NOT_RUNNING,
- "%s",
- _("MDNS service is not running"));
- return FALSE;
- }
- if (browser->priv->oid == NULL) {
- g_set_error (error,
- DMAP_MDNS_BROWSER_ERROR,
- DMAP_MDNS_BROWSER_ERROR_FAILED,
- "%s",
- _("Browser is not active"));
- return FALSE;
-
- }
-
- sw_discovery_cancel (*browser->priv->discovery, *browser->priv->oid);
-
- g_free (browser->priv->oid);
- browser->priv->oid = NULL;
-
- return TRUE;
+ if (browser->priv->discovery == NULL) {
+ g_set_error (error,
+ DMAP_MDNS_BROWSER_ERROR,
+ DMAP_MDNS_BROWSER_ERROR_NOT_RUNNING,
+ "%s", _("MDNS service is not running"));
+ return FALSE;
+ }
+ if (browser->priv->oid == NULL) {
+ g_set_error (error,
+ DMAP_MDNS_BROWSER_ERROR,
+ DMAP_MDNS_BROWSER_ERROR_FAILED,
+ "%s", _("Browser is not active"));
+ return FALSE;
+
+ }
+
+ sw_discovery_cancel (*browser->priv->discovery, *browser->priv->oid);
+
+ g_free (browser->priv->oid);
+ browser->priv->oid = NULL;
+
+ return TRUE;
}
DMAPMdnsBrowserServiceType
-dmap_mdns_browser_get_service_type (DMAPMdnsBrowser *browser)
+dmap_mdns_browser_get_service_type (DMAPMdnsBrowser * browser)
{
- g_return_val_if_fail (browser != NULL, DMAP_MDNS_BROWSER_SERVICE_TYPE_INVALID);
- return browser->priv->service_type;
+ g_return_val_if_fail (browser != NULL,
+ DMAP_MDNS_BROWSER_SERVICE_TYPE_INVALID);
+ return browser->priv->service_type;
}
static void
-dmap_mdns_browser_class_init (DMAPMdnsBrowserClass *klass)
+dmap_mdns_browser_class_init (DMAPMdnsBrowserClass * klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->dispose = dmap_mdns_browser_dispose;
- object_class->finalize = dmap_mdns_browser_finalize;
-
- signals [SERVICE_ADDED] =
- g_signal_new ("service-added",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DMAPMdnsBrowserClass, service_added),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__POINTER,
- G_TYPE_NONE,
- 1, G_TYPE_POINTER);
- signals [SERVICE_REMOVED] =
- g_signal_new ("service-removed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DMAPMdnsBrowserClass, service_removed),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
-
- g_type_class_add_private (klass, sizeof (DMAPMdnsBrowserPrivate));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = dmap_mdns_browser_dispose;
+ object_class->finalize = dmap_mdns_browser_finalize;
+
+ signals[SERVICE_ADDED] =
+ g_signal_new ("service-added",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (DMAPMdnsBrowserClass,
+ service_added), NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE,
+ 1, G_TYPE_POINTER);
+ signals[SERVICE_REMOVED] =
+ g_signal_new ("service-removed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (DMAPMdnsBrowserClass,
+ service_removed), NULL, NULL,
+ g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+
+ g_type_class_add_private (klass, sizeof (DMAPMdnsBrowserPrivate));
}
static void
-dmap_mdns_browser_init (DMAPMdnsBrowser *browser)
+dmap_mdns_browser_init (DMAPMdnsBrowser * browser)
{
- browser->priv = DMAP_MDNS_BROWSER_GET_PRIVATE (browser);
- memset (browser->priv, 0, sizeof (DMAPMdnsBrowserPrivate));
+ browser->priv = DMAP_MDNS_BROWSER_GET_PRIVATE (browser);
+ memset (browser->priv, 0, sizeof (DMAPMdnsBrowserPrivate));
- set_local_address (browser);
+ set_local_address (browser);
- howl_client_init (browser);
+ howl_client_init (browser);
}
static void
-resolver_free (sw_discovery_oid *oid,
- DMAPMdnsBrowser *browser)
+resolver_free (sw_discovery_oid * oid, DMAPMdnsBrowser * browser)
{
- sw_discovery_cancel (*browser->priv->discovery,
- *oid);
- g_free (oid);
+ sw_discovery_cancel (*browser->priv->discovery, *oid);
+ g_free (oid);
}
static void
-dmap_mdns_browser_dispose (GObject *object)
+dmap_mdns_browser_dispose (GObject * object)
{
- DMAPMdnsBrowser *browser = DMAP_MDNS_BROWSER (object);
- GSList *walk;
- DMAPMdnsBrowserService *service;
-
- if (browser->priv->oid) {
- dmap_mdns_browser_stop (browser, NULL);
- }
-
- for (walk = browser->priv->services; walk; walk = walk->next) {
- service = (DMAPMdnsBrowserService *) walk->data;
- free_service (service);
- }
- g_slist_free (browser->priv->services);
-
- if (browser->priv->resolvers) {
- g_slist_foreach (browser->priv->resolvers,
- (GFunc)resolver_free,
- browser);
- g_slist_free (browser->priv->resolvers);
- }
-
- if (browser->priv->discovery) {
- sw_discovery_fina (*browser->priv->discovery);
- g_free (browser->priv->discovery);
- }
-
- if (browser->priv->watch_id > 0) {
- g_source_remove (browser->priv->watch_id);
- }
-
- if (browser->priv->local_address) {
- gnome_vfs_address_free (browser->priv->local_address);
- }
-
- G_OBJECT_CLASS (dmap_mdns_browser_parent_class)->dispose (object);
+ DMAPMdnsBrowser *browser = DMAP_MDNS_BROWSER (object);
+ GSList *walk;
+ DMAPMdnsBrowserService *service;
+
+ if (browser->priv->oid) {
+ dmap_mdns_browser_stop (browser, NULL);
+ }
+
+ for (walk = browser->priv->services; walk; walk = walk->next) {
+ service = (DMAPMdnsBrowserService *) walk->data;
+ free_service (service);
+ }
+ g_slist_free (browser->priv->services);
+
+ if (browser->priv->resolvers) {
+ g_slist_foreach (browser->priv->resolvers,
+ (GFunc) resolver_free, browser);
+ g_slist_free (browser->priv->resolvers);
+ }
+
+ if (browser->priv->discovery) {
+ sw_discovery_fina (*browser->priv->discovery);
+ g_free (browser->priv->discovery);
+ }
+
+ if (browser->priv->watch_id > 0) {
+ g_source_remove (browser->priv->watch_id);
+ }
+
+ if (browser->priv->local_address) {
+ gnome_vfs_address_free (browser->priv->local_address);
+ }
+
+ G_OBJECT_CLASS (dmap_mdns_browser_parent_class)->dispose (object);
}
static void
-dmap_mdns_browser_finalize (GObject *object)
+dmap_mdns_browser_finalize (GObject * object)
{
- g_signal_handlers_destroy (object);
- G_OBJECT_CLASS (dmap_mdns_browser_parent_class)->finalize (object);
+ g_signal_handlers_destroy (object);
+ G_OBJECT_CLASS (dmap_mdns_browser_parent_class)->finalize (object);
}
static void
-free_service (DMAPMdnsBrowserService *service)
+free_service (DMAPMdnsBrowserService * service)
{
- g_free (service->service_name);
- g_free (service->name);
- g_free (service->host);
- g_free (service);
+ g_free (service->service_name);
+ g_free (service->name);
+ g_free (service->host);
+ g_free (service);
}
diff --git a/libdmapsharing/dmap-mdns-browser.h b/libdmapsharing/dmap-mdns-browser.h
index a0b9c95..dd79380 100644
--- a/libdmapsharing/dmap-mdns-browser.h
+++ b/libdmapsharing/dmap-mdns-browser.h
@@ -26,7 +26,6 @@
#include <glib-object.h>
G_BEGIN_DECLS
-
/**
* DMAP_TYPE_MDNS_BROWSER:
*
@@ -73,59 +72,59 @@ G_BEGIN_DECLS
* Returns: pointer to object class structure.
*/
#define DMAP_MDNS_BROWSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DMAP_TYPE_MDNS_BROWSER, DMAPMdnsBrowserClass))
-
-typedef struct _DMAPMdnsBrowser DMAPMdnsBrowser;
-typedef struct _DMAPMdnsBrowserClass DMAPMdnsBrowserClass;
+typedef struct _DMAPMdnsBrowser DMAPMdnsBrowser;
+typedef struct _DMAPMdnsBrowserClass DMAPMdnsBrowserClass;
typedef struct _DMAPMdnsBrowserPrivate DMAPMdnsBrowserPrivate;
typedef struct _DMAPMdnsBrowserService DMAPMdnsBrowserService;
typedef enum
{
- DMAP_MDNS_BROWSER_SERVICE_TYPE_INVALID = 0,
- DMAP_MDNS_BROWSER_SERVICE_TYPE_DAAP,
- DMAP_MDNS_BROWSER_SERVICE_TYPE_DPAP,
- DMAP_MDNS_BROWSER_SERVICE_TYPE_DACP,
- DMAP_MDNS_BROWSER_SERVICE_TYPE_LAST = DMAP_MDNS_BROWSER_SERVICE_TYPE_DACP
+ DMAP_MDNS_BROWSER_SERVICE_TYPE_INVALID = 0,
+ DMAP_MDNS_BROWSER_SERVICE_TYPE_DAAP,
+ DMAP_MDNS_BROWSER_SERVICE_TYPE_DPAP,
+ DMAP_MDNS_BROWSER_SERVICE_TYPE_DACP,
+ DMAP_MDNS_BROWSER_SERVICE_TYPE_LAST =
+ DMAP_MDNS_BROWSER_SERVICE_TYPE_DACP
} DMAPMdnsBrowserServiceType;
typedef enum
{
- DMAP_MDNS_BROWSER_ERROR_NOT_RUNNING = 0,
- DMAP_MDNS_BROWSER_ERROR_FAILED,
+ DMAP_MDNS_BROWSER_ERROR_NOT_RUNNING = 0,
+ DMAP_MDNS_BROWSER_ERROR_FAILED,
} DMAPMdnsBrowserError;
struct _DMAPMdnsBrowserService
{
- gchar *service_name;
- gchar *name;
- gchar *host;
- guint port;
- gboolean password_protected;
- gchar *pair;
+ gchar *service_name;
+ gchar *name;
+ gchar *host;
+ guint port;
+ gboolean password_protected;
+ gchar *pair;
};
struct _DMAPMdnsBrowserClass
{
- GObjectClass parent_class;
+ GObjectClass parent_class;
- void (* service_added) (DMAPMdnsBrowser *browser,
- DMAPMdnsBrowserService *service);
- void (* service_removed ) (DMAPMdnsBrowser *browser,
- DMAPMdnsBrowserService *service);
+ void (*service_added) (DMAPMdnsBrowser * browser,
+ DMAPMdnsBrowserService * service);
+ void (*service_removed) (DMAPMdnsBrowser * browser,
+ DMAPMdnsBrowserService * service);
};
struct _DMAPMdnsBrowser
{
- GObject object;
+ GObject object;
- DMAPMdnsBrowserPrivate *priv;
+ DMAPMdnsBrowserPrivate *priv;
};
#define DMAP_MDNS_BROWSER_ERROR dmap_mdns_browser_error_quark ()
-GQuark dmap_mdns_browser_error_quark (void);
+GQuark dmap_mdns_browser_error_quark (void);
-GType dmap_mdns_browser_get_type (void);
+GType dmap_mdns_browser_get_type (void);
/**
* dmap_mdns_browser_new:
@@ -135,7 +134,7 @@ GType dmap_mdns_browser_get_type (void);
*
* Returns: a pointer to a DMAPMdnsBrowser.
*/
-DMAPMdnsBrowser *dmap_mdns_browser_new (DMAPMdnsBrowserServiceType type);
+DMAPMdnsBrowser *dmap_mdns_browser_new (DMAPMdnsBrowserServiceType type);
/**
* dmap_mdns_browser_start:
@@ -146,8 +145,8 @@ DMAPMdnsBrowser *dmap_mdns_browser_new (DMAPMdnsBrowserSe
*
* Returns: TRUE on success, else FALSE.
*/
-gboolean dmap_mdns_browser_start (DMAPMdnsBrowser *browser,
- GError **error);
+gboolean dmap_mdns_browser_start (DMAPMdnsBrowser * browser, GError ** error);
+
/**
* dmap_mdns_browser_stop:
* @browser: A DMAPMdnsBrowser.
@@ -157,12 +156,12 @@ gboolean dmap_mdns_browser_start (DMAPMdnsBrowser *
*
* Returns: TRUE on success, else FALSE.
*/
-gboolean dmap_mdns_browser_stop (DMAPMdnsBrowser *browser,
- GError **error);
+gboolean dmap_mdns_browser_stop (DMAPMdnsBrowser * browser, GError ** error);
-G_CONST_RETURN GSList *dmap_mdns_browser_get_services (DMAPMdnsBrowser *browser);
-DMAPMdnsBrowserServiceType dmap_mdns_browser_get_service_type (DMAPMdnsBrowser *browser);
+G_CONST_RETURN GSList *dmap_mdns_browser_get_services (DMAPMdnsBrowser *
+ browser);
+DMAPMdnsBrowserServiceType dmap_mdns_browser_get_service_type (DMAPMdnsBrowser
+ * browser);
G_END_DECLS
-
#endif
diff --git a/libdmapsharing/dmap-mdns-publisher-avahi.c b/libdmapsharing/dmap-mdns-publisher-avahi.c
index 3e661dc..5be28f7 100644
--- a/libdmapsharing/dmap-mdns-publisher-avahi.c
+++ b/libdmapsharing/dmap-mdns-publisher-avahi.c
@@ -38,81 +38,85 @@
#include "dmap-mdns-avahi.h"
#include "dmap-mdns-publisher.h"
-static void dmap_mdns_publisher_class_init (DMAPMdnsPublisherClass *klass);
-static void dmap_mdns_publisher_init (DMAPMdnsPublisher *publisher);
-static void dmap_mdns_publisher_finalize (GObject *object);
+static void dmap_mdns_publisher_class_init (DMAPMdnsPublisherClass * klass);
+static void dmap_mdns_publisher_init (DMAPMdnsPublisher * publisher);
+static void dmap_mdns_publisher_finalize (GObject * object);
#define DMAP_MDNS_PUBLISHER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DMAP_TYPE_MDNS_PUBLISHER, DMAPMdnsPublisherPrivate))
struct DMAPMdnsPublisherService
{
- char *name;
- guint port;
- char *type_of_service;
- gboolean password_required;
- gchar **txt_records;
+ char *name;
+ guint port;
+ char *type_of_service;
+ gboolean password_required;
+ gchar **txt_records;
};
struct DMAPMdnsPublisherPrivate
{
- AvahiClient *client;
+ AvahiClient *client;
AvahiEntryGroup *entry_group;
- GSList *service;
+ GSList *service;
};
-enum {
+enum
+{
PUBLISHED,
NAME_COLLISION,
LAST_SIGNAL
};
-enum {
+enum
+{
PROP_0
};
-static guint signals [LAST_SIGNAL] = { 0, };
+static guint signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (DMAPMdnsPublisher, dmap_mdns_publisher, G_TYPE_OBJECT)
-static gpointer publisher_object = NULL;
+ static gpointer publisher_object = NULL;
GQuark
dmap_mdns_publisher_error_quark (void)
{
static GQuark quark = 0;
+
if (!quark)
- quark = g_quark_from_static_string ("dmap_mdns_publisher_error");
+ quark = g_quark_from_static_string
+ ("dmap_mdns_publisher_error");
return quark;
}
static void
-emit_published (char *name, DMAPMdnsPublisher *publisher)
+emit_published (char *name, DMAPMdnsPublisher * publisher)
{
- g_signal_emit (publisher, signals [PUBLISHED], 0, name);
+ g_signal_emit (publisher, signals[PUBLISHED], 0, name);
}
static void
-entry_group_cb (AvahiEntryGroup *group,
- AvahiEntryGroupState state,
- DMAPMdnsPublisher *publisher)
+entry_group_cb (AvahiEntryGroup * group,
+ AvahiEntryGroupState state, DMAPMdnsPublisher * publisher)
{
if (state == AVAHI_ENTRY_GROUP_ESTABLISHED) {
- g_slist_foreach (publisher->priv->service, (GFunc) emit_published, publisher);
+ g_slist_foreach (publisher->priv->service,
+ (GFunc) emit_published, publisher);
} else if (state == AVAHI_ENTRY_GROUP_COLLISION) {
g_warning ("MDNS name collision");
/* FIXME: how to know which name collided?
- g_signal_emit (publisher, signals [NAME_COLLISION], 0, publisher->priv->name);
- */
- g_signal_emit (publisher, signals [NAME_COLLISION], 0, "unknown");
+ * g_signal_emit (publisher, signals [NAME_COLLISION], 0, publisher->priv->name);
+ */
+ g_signal_emit (publisher, signals[NAME_COLLISION], 0,
+ "unknown");
}
}
static gboolean
create_service (struct DMAPMdnsPublisherService *service,
- DMAPMdnsPublisher *publisher,
- GError **error)
+ DMAPMdnsPublisher * publisher, GError ** error)
{
int ret;
const char *password_record;
@@ -123,30 +127,31 @@ create_service (struct DMAPMdnsPublisherService *service,
} else {
password_record = "Password=false";
}
-
- txt_records = avahi_string_list_new(password_record, NULL);
-
+
+ txt_records = avahi_string_list_new (password_record, NULL);
+
if (service->txt_records) {
//g_debug("Number of txt records: %d", service->txt_records);
gchar **txt_record = service->txt_records;
+
while (*txt_record) {
- txt_records = avahi_string_list_add(txt_records, *txt_record);
+ txt_records =
+ avahi_string_list_add (txt_records,
+ *txt_record);
txt_record++;
}
}
- ret = avahi_entry_group_add_service_strlst (publisher->priv->entry_group,
- AVAHI_IF_UNSPEC,
- AVAHI_PROTO_UNSPEC,
- 0,
- service->name,
- service->type_of_service,
- NULL,
- NULL,
- service->port,
- txt_records);
-
- avahi_string_list_free(txt_records);
+ ret = avahi_entry_group_add_service_strlst (publisher->priv->
+ entry_group,
+ AVAHI_IF_UNSPEC,
+ AVAHI_PROTO_UNSPEC, 0,
+ service->name,
+ service->type_of_service,
+ NULL, NULL, service->port,
+ txt_records);
+
+ avahi_string_list_free (txt_records);
if (ret < 0) {
g_set_error (error,
@@ -162,17 +167,18 @@ create_service (struct DMAPMdnsPublisherService *service,
}
static gboolean
-create_services (DMAPMdnsPublisher *publisher,
- GError **error)
+create_services (DMAPMdnsPublisher * publisher, GError ** error)
{
- GSList *ptr;
- int ret;
+ GSList *ptr;
+ int ret;
if (publisher->priv->entry_group == NULL) {
- publisher->priv->entry_group = avahi_entry_group_new (publisher->priv->client,
- (AvahiEntryGroupCallback)entry_group_cb,
- publisher);
- dmap_mdns_avahi_set_entry_group (publisher->priv->entry_group);
+ publisher->priv->entry_group =
+ avahi_entry_group_new (publisher->priv->client,
+ (AvahiEntryGroupCallback)
+ entry_group_cb, publisher);
+ dmap_mdns_avahi_set_entry_group (publisher->priv->
+ entry_group);
} else {
avahi_entry_group_reset (publisher->priv->entry_group);
}
@@ -183,12 +189,13 @@ create_services (DMAPMdnsPublisher *publisher,
DMAP_MDNS_PUBLISHER_ERROR,
DMAP_MDNS_PUBLISHER_ERROR_FAILED,
"%s",
- _("Could not create AvahiEntryGroup for publishing"));
+ _
+ ("Could not create AvahiEntryGroup for publishing"));
return FALSE;
}
for (ptr = publisher->priv->service; ptr; ptr = g_slist_next (ptr)) {
- if (! create_service (ptr->data, publisher, error)) {
+ if (!create_service (ptr->data, publisher, error)) {
return FALSE;
}
}
@@ -209,19 +216,19 @@ create_services (DMAPMdnsPublisher *publisher,
}
static gboolean
-refresh_services (DMAPMdnsPublisher *publisher,
- GError **error)
+refresh_services (DMAPMdnsPublisher * publisher, GError ** error)
{
return create_services (publisher, error);
}
static struct DMAPMdnsPublisherService *
-find_service_by_port (GSList *list, guint port)
+find_service_by_port (GSList * list, guint port)
{
GSList *ptr;
for (ptr = list; ptr; ptr = g_slist_next (ptr)) {
- if (port == ((struct DMAPMdnsPublisherService *) ptr->data)->port)
+ if (port ==
+ ((struct DMAPMdnsPublisherService *) ptr->data)->port)
break;
}
@@ -229,23 +236,21 @@ find_service_by_port (GSList *list, guint port)
}
gboolean
-dmap_mdns_publisher_rename_at_port (DMAPMdnsPublisher *publisher,
- guint port,
- const char *name,
- GError **error)
+dmap_mdns_publisher_rename_at_port (DMAPMdnsPublisher * publisher,
+ guint port,
+ const char *name, GError ** error)
{
struct DMAPMdnsPublisherService *ptr;
- g_return_val_if_fail (publisher != NULL, FALSE);
+ g_return_val_if_fail (publisher != NULL, FALSE);
ptr = find_service_by_port (publisher->priv->service, port);
if (ptr == NULL) {
- g_set_error (error,
+ g_set_error (error,
DMAP_MDNS_PUBLISHER_ERROR,
DMAP_MDNS_PUBLISHER_ERROR_FAILED,
- "%s",
- _("No service at port"));
+ "%s", _("No service at port"));
return FALSE;
}
@@ -260,35 +265,34 @@ dmap_mdns_publisher_rename_at_port (DMAPMdnsPublisher *publisher,
}
gboolean
-dmap_mdns_publisher_publish (DMAPMdnsPublisher *publisher,
- const char *name,
- guint port,
- const char *type_of_service,
- gboolean password_required,
- gchar **txt_records,
- GError **error)
+dmap_mdns_publisher_publish (DMAPMdnsPublisher * publisher,
+ const char *name,
+ guint port,
+ const char *type_of_service,
+ gboolean password_required,
+ gchar ** txt_records, GError ** error)
{
struct DMAPMdnsPublisherService *service;
if (publisher->priv->client == NULL) {
- g_set_error (error,
+ g_set_error (error,
DMAP_MDNS_PUBLISHER_ERROR,
DMAP_MDNS_PUBLISHER_ERROR_NOT_RUNNING,
- "%s",
- _("The avahi MDNS service is not running"));
+ "%s",
+ _("The avahi MDNS service is not running"));
return FALSE;
}
-
service = g_new (struct DMAPMdnsPublisherService, 1);
- service->name = g_strdup(name);
+ service->name = g_strdup (name);
service->port = port;
service->type_of_service = g_strdup (type_of_service);
service->password_required = password_required;
service->txt_records = g_strdupv (txt_records);
- publisher->priv->service = g_slist_append (publisher->priv->service, service);
+ publisher->priv->service =
+ g_slist_append (publisher->priv->service, service);
return create_services (publisher, error);
}
@@ -302,33 +306,32 @@ free_service (struct DMAPMdnsPublisherService *service, gpointer user_data)
}
gboolean
-dmap_mdns_publisher_withdraw (DMAPMdnsPublisher *publisher,
- guint port,
- GError **error)
+dmap_mdns_publisher_withdraw (DMAPMdnsPublisher * publisher,
+ guint port, GError ** error)
{
struct DMAPMdnsPublisherService *ptr;
if (publisher->priv->client == NULL) {
- g_set_error (error,
+ g_set_error (error,
DMAP_MDNS_PUBLISHER_ERROR,
DMAP_MDNS_PUBLISHER_ERROR_NOT_RUNNING,
- "%s",
- _("The avahi MDNS service is not running"));
+ "%s",
+ _("The avahi MDNS service is not running"));
return FALSE;
}
if (publisher->priv->entry_group == NULL
- || ! (ptr = find_service_by_port (publisher->priv->service, port))) {
- g_set_error (error,
- DMAP_MDNS_PUBLISHER_ERROR,
- DMAP_MDNS_PUBLISHER_ERROR_FAILED,
- "%s",
- _("The MDNS service is not published"));
+ || !(ptr =
+ find_service_by_port (publisher->priv->service, port))) {
+ g_set_error (error, DMAP_MDNS_PUBLISHER_ERROR,
+ DMAP_MDNS_PUBLISHER_ERROR_FAILED, "%s",
+ _("The MDNS service is not published"));
return FALSE;
}
free_service (ptr, NULL);
- publisher->priv->service = g_slist_remove (publisher->priv->service, ptr);
+ publisher->priv->service =
+ g_slist_remove (publisher->priv->service, ptr);
if (publisher->priv->service == NULL) {
avahi_entry_group_reset (publisher->priv->entry_group);
@@ -344,10 +347,9 @@ dmap_mdns_publisher_withdraw (DMAPMdnsPublisher *publisher,
}
static void
-dmap_mdns_publisher_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+dmap_mdns_publisher_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
switch (prop_id) {
default:
@@ -357,10 +359,9 @@ dmap_mdns_publisher_set_property (GObject *object,
}
static void
-dmap_mdns_publisher_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+dmap_mdns_publisher_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
switch (prop_id) {
default:
@@ -372,15 +373,16 @@ dmap_mdns_publisher_get_property (GObject *object,
static GObject *
dmap_mdns_publisher_constructor (GType type,
guint n_construct_params,
- GObjectConstructParam *construct_params)
+ GObjectConstructParam * construct_params)
{
/* This class is a singleton. */
static GObject *self = NULL;
if (self == NULL) {
- self = G_OBJECT_CLASS (dmap_mdns_publisher_parent_class)->constructor (
- type, n_construct_params, construct_params);
- g_object_add_weak_pointer (self, (gpointer) &self);
+ self = G_OBJECT_CLASS (dmap_mdns_publisher_parent_class)->
+ constructor (type, n_construct_params,
+ construct_params);
+ g_object_add_weak_pointer (self, (gpointer) & self);
return self;
}
@@ -388,51 +390,47 @@ dmap_mdns_publisher_constructor (GType type,
}
static void
-dmap_mdns_publisher_class_init (DMAPMdnsPublisherClass *klass)
+dmap_mdns_publisher_class_init (DMAPMdnsPublisherClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->constructor = dmap_mdns_publisher_constructor;
- object_class->finalize = dmap_mdns_publisher_finalize;
+ object_class->constructor = dmap_mdns_publisher_constructor;
+ object_class->finalize = dmap_mdns_publisher_finalize;
object_class->get_property = dmap_mdns_publisher_get_property;
object_class->set_property = dmap_mdns_publisher_set_property;
- signals [PUBLISHED] =
+ signals[PUBLISHED] =
g_signal_new ("published",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DMAPMdnsPublisherClass, published),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
- signals [NAME_COLLISION] =
+ G_STRUCT_OFFSET (DMAPMdnsPublisherClass,
+ published), NULL, NULL,
+ g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+ signals[NAME_COLLISION] =
g_signal_new ("name-collision",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (DMAPMdnsPublisherClass, name_collision),
- NULL,
- NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE,
- 1, G_TYPE_STRING);
+ G_STRUCT_OFFSET (DMAPMdnsPublisherClass,
+ name_collision), NULL, NULL,
+ g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1,
+ G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (DMAPMdnsPublisherPrivate));
}
static void
-dmap_mdns_publisher_init (DMAPMdnsPublisher *publisher)
+dmap_mdns_publisher_init (DMAPMdnsPublisher * publisher)
{
publisher->priv = DMAP_MDNS_PUBLISHER_GET_PRIVATE (publisher);
- publisher->priv->client = dmap_mdns_avahi_get_client ();
+ publisher->priv->client = dmap_mdns_avahi_get_client ();
publisher->priv->entry_group = NULL;
- publisher->priv->service = NULL;
+ publisher->priv->service = NULL;
}
static void
-dmap_mdns_publisher_finalize (GObject *object)
+dmap_mdns_publisher_finalize (GObject * object)
{
DMAPMdnsPublisher *publisher;
@@ -458,7 +456,8 @@ dmap_mdns_publisher_finalize (GObject *object)
* avahi_client_free (publisher->priv->client);
*/
- g_slist_foreach (publisher->priv->service, (GFunc) free_service, NULL);
+ g_slist_foreach (publisher->priv->service, (GFunc) free_service,
+ NULL);
g_slist_free (publisher->priv->service);
publisher_object = NULL;
@@ -472,9 +471,10 @@ dmap_mdns_publisher_new (void)
if (publisher_object) {
g_object_ref (publisher_object);
} else {
- publisher_object = g_object_new (DMAP_TYPE_MDNS_PUBLISHER, NULL);
+ publisher_object =
+ g_object_new (DMAP_TYPE_MDNS_PUBLISHER, NULL);
g_object_add_weak_pointer (publisher_object,
- (gpointer *) &publisher_object);
+ (gpointer *) & publisher_object);
}
return DMAP_MDNS_PUBLISHER (publisher_object);
diff --git a/libdmapsharing/dmap-mdns-publisher.h b/libdmapsharing/dmap-mdns-publisher.h
index 9040c78..25a3db5 100644
--- a/libdmapsharing/dmap-mdns-publisher.h
+++ b/libdmapsharing/dmap-mdns-publisher.h
@@ -28,14 +28,12 @@
#include <glib-object.h>
G_BEGIN_DECLS
-
#define DMAP_TYPE_MDNS_PUBLISHER (dmap_mdns_publisher_get_type ())
#define DMAP_MDNS_PUBLISHER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DMAP_TYPE_MDNS_PUBLISHER, DMAPMdnsPublisher))
#define DMAP_MDNS_PUBLISHER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), DMAP_TYPE_MDNS_PUBLISHER, DMAPMdnsPublisherClass))
#define IS_DMAP_MDNS_PUBLISHER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DMAP_TYPE_MDNS_PUBLISHER))
#define IS_DMAP_MDNS_PUBLISHER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), DMAP_TYPE_MDNS_PUBLISHER))
#define DMAP_MDNS_PUBLISHER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DMAP_TYPE_MDNS_PUBLISHER, DMAPMdnsPublisherClass))
-
typedef struct DMAPMdnsPublisherPrivate DMAPMdnsPublisherPrivate;
typedef struct
@@ -49,10 +47,9 @@ typedef struct
{
GObjectClass parent_class;
- void (* published) (DMAPMdnsPublisher *publisher,
- const char *name);
- void (* name_collision) (DMAPMdnsPublisher *publisher,
- const char *name);
+ void (*published) (DMAPMdnsPublisher * publisher, const char *name);
+ void (*name_collision) (DMAPMdnsPublisher * publisher,
+ const char *name);
} DMAPMdnsPublisherClass;
typedef enum
@@ -63,26 +60,23 @@ typedef enum
#define DMAP_MDNS_PUBLISHER_ERROR dmap_mdns_publisher_error_quark ()
-GQuark dmap_mdns_publisher_error_quark (void);
+GQuark dmap_mdns_publisher_error_quark (void);
-GType dmap_mdns_publisher_get_type (void);
+GType dmap_mdns_publisher_get_type (void);
-DMAPMdnsPublisher *dmap_mdns_publisher_new (void);
-gboolean dmap_mdns_publisher_publish (DMAPMdnsPublisher *publisher,
- const char *name,
- guint port,
- const char *type_of_service,
- gboolean password_required,
- gchar **txt_records,
- GError **error);
-gboolean dmap_mdns_publisher_rename_at_port (DMAPMdnsPublisher *publisher,
- guint port,
- const char *name,
- GError **error);
-gboolean dmap_mdns_publisher_withdraw (DMAPMdnsPublisher *publisher,
- guint port,
- GError **error);
+DMAPMdnsPublisher *dmap_mdns_publisher_new (void);
+gboolean dmap_mdns_publisher_publish (DMAPMdnsPublisher * publisher,
+ const char *name,
+ guint port,
+ const char *type_of_service,
+ gboolean password_required,
+ gchar ** txt_records, GError ** error);
+gboolean dmap_mdns_publisher_rename_at_port (DMAPMdnsPublisher * publisher,
+ guint port,
+ const char *name,
+ GError ** error);
+gboolean dmap_mdns_publisher_withdraw (DMAPMdnsPublisher * publisher,
+ guint port, GError ** error);
G_END_DECLS
-
#endif /* __DMAP_MDNS_PUBLISHER_H */
diff --git a/libdmapsharing/dmap-record-factory.c b/libdmapsharing/dmap-record-factory.c
index 37b7df6..6b77862 100644
--- a/libdmapsharing/dmap-record-factory.c
+++ b/libdmapsharing/dmap-record-factory.c
@@ -23,13 +23,13 @@
static gint dmap_record_factory_init_count = 0;
static void
-dmap_record_factory_init (DMAPRecordFactoryIface *iface)
+dmap_record_factory_init (DMAPRecordFactoryIface * iface)
{
dmap_record_factory_init_count++;
}
static void
-dmap_record_factory_finalize (DMAPRecordFactoryIface *iface)
+dmap_record_factory_finalize (DMAPRecordFactoryIface * iface)
{
dmap_record_factory_init_count--;
}
@@ -39,22 +39,24 @@ GType
dmap_record_factory_get_type (void)
{
static GType object_type = 0;
+
if (!object_type) {
static const GTypeInfo object_info = {
- sizeof(DMAPRecordFactoryIface),
+ sizeof (DMAPRecordFactoryIface),
(GBaseInitFunc) dmap_record_factory_init,
(GBaseFinalizeFunc) dmap_record_factory_finalize
};
object_type =
- g_type_register_static(G_TYPE_INTERFACE,
- "DMAPRecordFactory",
- &object_info, 0);
+ g_type_register_static (G_TYPE_INTERFACE,
+ "DMAPRecordFactory",
+ &object_info, 0);
}
return object_type;
}
DMAPRecord *
-dmap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data)
+dmap_record_factory_create (DMAPRecordFactory * factory, gpointer user_data)
{
- return DMAP_RECORD_FACTORY_GET_INTERFACE (factory)->create (factory, user_data);
+ return DMAP_RECORD_FACTORY_GET_INTERFACE (factory)->create (factory,
+ user_data);
}
diff --git a/libdmapsharing/dmap-record-factory.h b/libdmapsharing/dmap-record-factory.h
index e953ce2..d6773b7 100644
--- a/libdmapsharing/dmap-record-factory.h
+++ b/libdmapsharing/dmap-record-factory.h
@@ -26,7 +26,6 @@
#include <libdmapsharing/dmap-record.h>
G_BEGIN_DECLS
-
/**
* DMAP_TYPE_RECORD_FACTORY:
*
@@ -64,14 +63,15 @@ G_BEGIN_DECLS
(G_TYPE_INSTANCE_GET_INTERFACE ((o), \
DMAP_TYPE_RECORD_FACTORY, \
DMAPRecordFactoryIface))
-
typedef struct _DMAPRecordFactory DMAPRecordFactory;
typedef struct _DMAPRecordFactoryIface DMAPRecordFactoryIface;
-struct _DMAPRecordFactoryIface {
+struct _DMAPRecordFactoryIface
+{
GTypeInterface parent;
- DMAPRecord *(*create) (DMAPRecordFactory *factory, gpointer user_data);
+ DMAPRecord *(*create) (DMAPRecordFactory * factory,
+ gpointer user_data);
};
GType dmap_record_factory_get_type (void);
@@ -83,7 +83,7 @@ GType dmap_record_factory_get_type (void);
*
* Returns: a new DMAPRecord as read from path.
*/
-DMAPRecord *dmap_record_factory_create (DMAPRecordFactory *factory,
+DMAPRecord *dmap_record_factory_create (DMAPRecordFactory * factory,
gpointer user_data);
#endif /* __DMAP_RECORD_FACTORY_H */
diff --git a/libdmapsharing/dmap-record.c b/libdmapsharing/dmap-record.c
index e40f8a4..3df63f7 100644
--- a/libdmapsharing/dmap-record.c
+++ b/libdmapsharing/dmap-record.c
@@ -23,13 +23,13 @@
static gint dmap_record_init_count = 0;
static void
-dmap_record_init (DMAPRecordIface *iface)
+dmap_record_init (DMAPRecordIface * iface)
{
- dmap_record_init_count++;
+ dmap_record_init_count++;
}
static void
-dmap_record_finalize (DMAPRecordIface *iface)
+dmap_record_finalize (DMAPRecordIface * iface)
{
dmap_record_init_count--;
}
@@ -39,29 +39,32 @@ GType
dmap_record_get_type (void)
{
static GType object_type = 0;
+
if (!object_type) {
static const GTypeInfo object_info = {
- sizeof(DMAPRecordIface),
+ sizeof (DMAPRecordIface),
(GBaseInitFunc) dmap_record_init,
(GBaseFinalizeFunc) dmap_record_finalize
};
object_type =
- g_type_register_static(G_TYPE_INTERFACE,
- "DMAPRecord",
- &object_info, 0);
- g_type_interface_add_prerequisite (object_type, G_TYPE_OBJECT);
+ g_type_register_static (G_TYPE_INTERFACE,
+ "DMAPRecord",
+ &object_info, 0);
+ g_type_interface_add_prerequisite (object_type,
+ G_TYPE_OBJECT);
}
return object_type;
}
GByteArray *
-dmap_record_to_blob (DMAPRecord *record)
+dmap_record_to_blob (DMAPRecord * record)
{
- return DMAP_RECORD_GET_INTERFACE (record)->to_blob (record);
+ return DMAP_RECORD_GET_INTERFACE (record)->to_blob (record);
}
DMAPRecord *
-dmap_record_set_from_blob (DMAPRecord *record, GByteArray *blob)
+dmap_record_set_from_blob (DMAPRecord * record, GByteArray * blob)
{
- return DMAP_RECORD_GET_INTERFACE (record)->set_from_blob (record, blob);
+ return DMAP_RECORD_GET_INTERFACE (record)->set_from_blob (record,
+ blob);
}
diff --git a/libdmapsharing/dmap-record.h b/libdmapsharing/dmap-record.h
index 35823e0..800e069 100644
--- a/libdmapsharing/dmap-record.h
+++ b/libdmapsharing/dmap-record.h
@@ -24,7 +24,6 @@
#include <glib-object.h>
G_BEGIN_DECLS
-
/**
* DMAP_TYPE_RECORD:
*
@@ -59,30 +58,32 @@ G_BEGIN_DECLS
*/
#define DMAP_RECORD_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), \
DMAP_TYPE_RECORD, DMAPRecordIface))
-
typedef struct _DMAPRecord DMAPRecord;
typedef struct _DMAPRecordIface DMAPRecordIface;
-struct _DMAPRecordIface {
+struct _DMAPRecordIface
+{
GTypeInterface parent;
- GByteArray * (*to_blob) (DMAPRecord *record);
- DMAPRecord * (*set_from_blob) (DMAPRecord *record, GByteArray *blob);
+ GByteArray *(*to_blob) (DMAPRecord * record);
+ DMAPRecord *(*set_from_blob) (DMAPRecord * record, GByteArray * blob);
};
typedef unsigned long long bitwise;
-struct MLCL_Bits {
+struct MLCL_Bits
+{
GNode *mlcl;
bitwise bits;
};
-typedef enum {
+typedef enum
+{
DMAP_MEDIA_KIND_MUSIC = 1,
DMAP_MEDIA_KIND_MOVIE = 2
} DMAPMediaKind;
-GType dmap_record_get_type (void);
+GType dmap_record_get_type (void);
/**
* dmap_record_to_blob:
@@ -90,7 +91,7 @@ GType dmap_record_get_type (void);
*
* Returns: A byte array representation of the record.
*/
-GByteArray *dmap_record_to_blob (DMAPRecord *record);
+GByteArray *dmap_record_to_blob (DMAPRecord * record);
/**
* dmap_record_from_blob:
@@ -98,7 +99,8 @@ GByteArray *dmap_record_to_blob (DMAPRecord *record);
*
* Returns: The record.
*/
-DMAPRecord *dmap_record_set_from_blob (DMAPRecord *record, GByteArray *blob);
+DMAPRecord *dmap_record_set_from_blob (DMAPRecord * record,
+ GByteArray * blob);
#endif /* __DMAP_RECORD_H */
diff --git a/libdmapsharing/dmap-share.c b/libdmapsharing/dmap-share.c
index 47d7ebc..9c9dd28 100644
--- a/libdmapsharing/dmap-share.c
+++ b/libdmapsharing/dmap-share.c
@@ -39,13 +39,15 @@
#define DMAP_TIMEOUT 1800
#define DMAP_STATUS_OK 200
-typedef enum {
- DMAP_SHARE_AUTH_METHOD_NONE = 0,
+typedef enum
+{
+ DMAP_SHARE_AUTH_METHOD_NONE = 0,
DMAP_SHARE_AUTH_METHOD_NAME_AND_PASSWORD = 1,
- DMAP_SHARE_AUTH_METHOD_PASSWORD = 2
+ DMAP_SHARE_AUTH_METHOD_PASSWORD = 2
} DMAPShareAuthMethod;
-enum {
+enum
+{
PROP_0,
/* I'd be nice to unify these, once libsoup supports it. See:
* http://mail.gnome.org/archives/libsoup-list/2011-January/msg00000.html
@@ -62,7 +64,8 @@ enum {
PROP_TXT_RECORDS
};
-struct DMAPSharePrivate {
+struct DMAPSharePrivate
+{
gchar *name;
guint port;
char *password;
@@ -87,7 +90,7 @@ struct DMAPSharePrivate {
/* The media database */
DMAPDb *db;
DMAPContainerDb *container_db;
-
+
/* TXT-RECORDS published by mDNS */
gchar **txt_records;
@@ -95,9 +98,10 @@ struct DMAPSharePrivate {
};
/* FIXME: name this something else, as it is more than just share/bitwise now */
-struct share_bitwise_t {
+struct share_bitwise_t
+{
DMAPShare *share;
- SoupServer *server; /* Also in share, but we need to know whether server_ipv6 or _ipv4. */
+ SoupServer *server; /* Also in share, but we need to know whether server_ipv6 or _ipv4. */
struct MLCL_Bits mb;
GSList *id_list;
guint32 size;
@@ -110,22 +114,20 @@ struct share_bitwise_t {
void (*destroy) (void *);
};
-static void dmap_share_init (DMAPShare *share);
-static void dmap_share_class_init (DMAPShareClass *klass);
+static void dmap_share_init (DMAPShare * share);
+static void dmap_share_class_init (DMAPShareClass * klass);
G_DEFINE_ABSTRACT_TYPE (DMAPShare, dmap_share, G_TYPE_OBJECT)
-
#define DMAP_SHARE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
DMAP_TYPE_SHARE, DMAPSharePrivate))
-
-static gboolean
-_dmap_share_soup_auth_callback (SoupAuthDomain *auth_domain,
- SoupMessage *msg,
- const char *username,
- gpointer password,
- DMAPShare *share)
+ static gboolean
+ _dmap_share_soup_auth_callback (SoupAuthDomain * auth_domain,
+ SoupMessage * msg,
+ const char *username,
+ gpointer password,
+ DMAPShare * share)
{
- gboolean allowed;
+ gboolean allowed;
const char *path;
path = soup_message_get_uri (msg)->path;
@@ -137,128 +139,120 @@ _dmap_share_soup_auth_callback (SoupAuthDomain *auth_domain,
return allowed;
}
-static void server_info_adapter (SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context,
- DMAPShare *share)
+static void
+server_info_adapter (SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query,
+ SoupClientContext * context, DMAPShare * share)
{
DMAP_SHARE_GET_CLASS (share)->server_info (share,
server,
message,
- path,
- query,
- context);
+ path, query, context);
}
-static void content_codes_adapter (SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context,
- DMAPShare *share)
+static void
+content_codes_adapter (SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query,
+ SoupClientContext * context, DMAPShare * share)
{
DMAP_SHARE_GET_CLASS (share)->content_codes (share,
server,
message,
- path,
- query,
- context);
+ path, query, context);
}
-static void login_adapter (SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context,
- DMAPShare *share)
+static void
+login_adapter (SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query,
+ SoupClientContext * context, DMAPShare * share)
{
DMAP_SHARE_GET_CLASS (share)->login (share,
server,
- message,
- path,
- query,
- context);
+ message, path, query, context);
}
-static void logout_adapter (SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context,
- DMAPShare *share)
+static void
+logout_adapter (SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query,
+ SoupClientContext * context, DMAPShare * share)
{
DMAP_SHARE_GET_CLASS (share)->logout (share,
server,
- message,
- path,
- query,
- context);
+ message, path, query, context);
}
-static void update_adapter (SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context,
- DMAPShare *share)
+static void
+update_adapter (SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query,
+ SoupClientContext * context, DMAPShare * share)
{
DMAP_SHARE_GET_CLASS (share)->update (share,
server,
- message,
- path,
- query,
- context);
+ message, path, query, context);
}
-static void databases_adapter (SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context,
- DMAPShare *share)
+static void
+databases_adapter (SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query,
+ SoupClientContext * context, DMAPShare * share)
{
DMAP_SHARE_GET_CLASS (share)->databases (share,
server,
message,
- path,
- query,
- context);
+ path, query, context);
}
-static void ctrl_int_adapter (SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context,
- DMAPShare *share)
+static void
+ctrl_int_adapter (SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query,
+ SoupClientContext * context, DMAPShare * share)
{
DMAP_SHARE_GET_CLASS (share)->ctrl_int (share,
- server,
- message,
- path,
- query,
- context);
+ server,
+ message,
+ path, query, context);
}
static void
-_dmap_share_server_setup_handlers (DMAPShare *share, SoupServer *server)
+_dmap_share_server_setup_handlers (DMAPShare * share, SoupServer * server)
{
- gboolean password_required = (share->priv->auth_method != DMAP_SHARE_AUTH_METHOD_NONE);
+ gboolean password_required =
+ (share->priv->auth_method != DMAP_SHARE_AUTH_METHOD_NONE);
if (password_required) {
SoupAuthDomain *auth_domain;
- auth_domain = soup_auth_domain_basic_new (SOUP_AUTH_DOMAIN_REALM, "Music Sharing",
- SOUP_AUTH_DOMAIN_ADD_PATH, "/login",
- SOUP_AUTH_DOMAIN_ADD_PATH, "/update",
- SOUP_AUTH_DOMAIN_ADD_PATH, "/database",
- SOUP_AUTH_DOMAIN_FILTER, _dmap_share_soup_auth_filter,
- NULL);
+ auth_domain =
+ soup_auth_domain_basic_new (SOUP_AUTH_DOMAIN_REALM,
+ "Music Sharing",
+ SOUP_AUTH_DOMAIN_ADD_PATH,
+ "/login",
+ SOUP_AUTH_DOMAIN_ADD_PATH,
+ "/update",
+ SOUP_AUTH_DOMAIN_ADD_PATH,
+ "/database",
+ SOUP_AUTH_DOMAIN_FILTER,
+ _dmap_share_soup_auth_filter,
+ NULL);
soup_auth_domain_basic_set_auth_callback (auth_domain,
- (SoupAuthDomainBasicAuthCallback) _dmap_share_soup_auth_callback,
- g_object_ref (share),
+ (SoupAuthDomainBasicAuthCallback)
+ _dmap_share_soup_auth_callback,
+ g_object_ref
+ (share),
g_object_unref);
soup_server_add_auth_domain (server, auth_domain);
}
@@ -289,13 +283,14 @@ _dmap_share_server_setup_handlers (DMAPShare *share, SoupServer *server)
}
gboolean
-_dmap_share_server_start (DMAPShare *share)
+_dmap_share_server_start (DMAPShare * share)
{
SoupAddress *addr;
guint port = DMAP_SHARE_GET_CLASS (share)->get_desired_port (share);
addr = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV6, port);
- share->priv->server_ipv6 = soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
+ share->priv->server_ipv6 =
+ soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
g_object_unref (addr);
/* NOTE: On Linux, opening a socket may give a IPv6-wrapped IPv4 address.
@@ -303,9 +298,13 @@ _dmap_share_server_start (DMAPShare *share)
* IPv6 and IPv4 clients.
*/
if (share->priv->server_ipv6 == NULL) {
- g_warning ("Unable to start music sharing server on port %d, trying any open port", port);
- addr = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV6, SOUP_ADDRESS_ANY_PORT);
- share->priv->server_ipv6 = soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
+ g_warning
+ ("Unable to start music sharing server on port %d, trying any open port",
+ port);
+ addr = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV6,
+ SOUP_ADDRESS_ANY_PORT);
+ share->priv->server_ipv6 =
+ soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
g_object_unref (addr);
}
@@ -321,15 +320,21 @@ _dmap_share_server_start (DMAPShare *share)
* and server_ipv4 is NULL.
*/
addr = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV4, port);
- share->priv->server_ipv4 = soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
+ share->priv->server_ipv4 =
+ soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
g_object_unref (addr);
/* Don't try any port on IPv4 unless IPv6 failed. We don't want to listen to one
* port on IPv6 and another on IPv4 */
- if (share->priv->server_ipv6 == NULL && share->priv->server_ipv4 == NULL) {
- g_warning ("Unable to start music sharing server on port %d, trying IPv4 only, any open port", port);
- addr = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV4, SOUP_ADDRESS_ANY_PORT);
- share->priv->server_ipv4 = soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
+ if (share->priv->server_ipv6 == NULL
+ && share->priv->server_ipv4 == NULL) {
+ g_warning
+ ("Unable to start music sharing server on port %d, trying IPv4 only, any open port",
+ port);
+ addr = soup_address_new_any (SOUP_ADDRESS_FAMILY_IPV4,
+ SOUP_ADDRESS_ANY_PORT);
+ share->priv->server_ipv4 =
+ soup_server_new (SOUP_SERVER_INTERFACE, addr, NULL);
g_object_unref (addr);
}
@@ -341,22 +346,27 @@ _dmap_share_server_start (DMAPShare *share)
}
if (share->priv->server_ipv6)
- share->priv->port = (guint) soup_server_get_port (share->priv->server_ipv6);
+ share->priv->port =
+ (guint) soup_server_get_port (share->priv->
+ server_ipv6);
else
- share->priv->port = (guint) soup_server_get_port (share->priv->server_ipv4);
- g_debug ("Started DMAP server on port %u (IPv6: %s, explicit IPv4: %s)",
- share->priv->port,
- share->priv->server_ipv6 ? "yes" : "no",
- share->priv->server_ipv4 ? "yes" : "no");
+ share->priv->port =
+ (guint) soup_server_get_port (share->priv->
+ server_ipv4);
+ g_debug ("Started DMAP server on port %u (IPv6: %s, explicit IPv4: %s)", share->priv->port, share->priv->server_ipv6 ? "yes" : "no", share->priv->server_ipv4 ? "yes" : "no");
if (share->priv->server_ipv6)
- _dmap_share_server_setup_handlers (share, share->priv->server_ipv6);
+ _dmap_share_server_setup_handlers (share,
+ share->priv->server_ipv6);
if (share->priv->server_ipv4)
- _dmap_share_server_setup_handlers (share, share->priv->server_ipv4);
+ _dmap_share_server_setup_handlers (share,
+ share->priv->server_ipv4);
/* using direct since there is no g_uint_hash or g_uint_equal */
- share->priv->session_ids = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
+ share->priv->session_ids =
+ g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
+ g_free);
share->priv->server_active = TRUE;
@@ -364,9 +374,10 @@ _dmap_share_server_start (DMAPShare *share)
}
static gboolean
-_dmap_share_server_stop (DMAPShare *share)
+_dmap_share_server_stop (DMAPShare * share)
{
- g_debug ("Stopping music sharing server on port %d", share->priv->port);
+ g_debug ("Stopping music sharing server on port %d",
+ share->priv->port);
if (share->priv->server_ipv4) {
soup_server_quit (share->priv->server_ipv4);
@@ -391,33 +402,37 @@ _dmap_share_server_stop (DMAPShare *share)
}
gboolean
-_dmap_share_publish_start (DMAPShare *share)
+_dmap_share_publish_start (DMAPShare * share)
{
gchar *nameprop;
- GError *error;
+ GError *error;
gboolean res;
gboolean password_required;
/* FIXME: this is done throughout dmap-share.c. Is this the best way? */
g_object_get ((gpointer) share, "name", &nameprop, NULL);
- password_required = (share->priv->auth_method != DMAP_SHARE_AUTH_METHOD_NONE);
+ password_required =
+ (share->priv->auth_method != DMAP_SHARE_AUTH_METHOD_NONE);
error = NULL;
res = dmap_mdns_publisher_publish (share->priv->publisher,
- nameprop,
- share->priv->port,
- DMAP_SHARE_GET_CLASS (share)->get_type_of_service (share),
- password_required,
- share->priv->txt_records,
- &error);
+ nameprop,
+ share->priv->port,
+ DMAP_SHARE_GET_CLASS (share)->
+ get_type_of_service (share),
+ password_required,
+ share->priv->txt_records, &error);
if (res == FALSE) {
if (error != NULL) {
- g_warning ("Unable to notify network of media sharing: %s", error->message);
+ g_warning
+ ("Unable to notify network of media sharing: %s",
+ error->message);
g_error_free (error);
} else {
- g_warning ("Unable to notify network of media sharing");
+ g_warning
+ ("Unable to notify network of media sharing");
}
return FALSE;
} else {
@@ -430,15 +445,20 @@ _dmap_share_publish_start (DMAPShare *share)
}
static gboolean
-_dmap_share_publish_stop (DMAPShare *share)
+_dmap_share_publish_stop (DMAPShare * share)
{
if (share->priv->publisher) {
gboolean res;
- GError *error;
+ GError *error;
+
error = NULL;
- res = dmap_mdns_publisher_withdraw (share->priv->publisher, share->priv->port, &error);
+ res = dmap_mdns_publisher_withdraw (share->priv->publisher,
+ share->priv->port,
+ &error);
if (error != NULL) {
- g_warning ("Unable to withdraw music sharing service: %s", error->message);
+ g_warning
+ ("Unable to withdraw music sharing service: %s",
+ error->message);
g_error_free (error);
}
return res;
@@ -449,7 +469,7 @@ _dmap_share_publish_stop (DMAPShare *share)
}
static void
-_dmap_share_restart (DMAPShare *share)
+_dmap_share_restart (DMAPShare * share)
{
gboolean res;
@@ -464,7 +484,7 @@ _dmap_share_restart (DMAPShare *share)
}
static void
-_dmap_share_maybe_restart (DMAPShare *share)
+_dmap_share_maybe_restart (DMAPShare * share)
{
if (share->priv->published) {
_dmap_share_restart (share);
@@ -472,7 +492,7 @@ _dmap_share_maybe_restart (DMAPShare *share)
}
static void
-_dmap_share_set_name (DMAPShare *share, const char *name)
+_dmap_share_set_name (DMAPShare * share, const char *name)
{
GError *error;
gboolean res;
@@ -484,10 +504,10 @@ _dmap_share_set_name (DMAPShare *share, const char *name)
if (share->priv->published) {
error = NULL;
- res = dmap_mdns_publisher_rename_at_port (share->priv->publisher,
+ res = dmap_mdns_publisher_rename_at_port (share->priv->
+ publisher,
share->priv->port,
- name,
- &error);
+ name, &error);
if (error != NULL) {
g_warning ("Unable to change MDNS service name: %s",
error->message);
@@ -497,7 +517,7 @@ _dmap_share_set_name (DMAPShare *share, const char *name)
}
static void
-_dmap_share_set_password (DMAPShare *share, const char *password)
+_dmap_share_set_password (DMAPShare * share, const char *password)
{
g_return_if_fail (share != NULL);
@@ -518,10 +538,9 @@ _dmap_share_set_password (DMAPShare *share, const char *password)
}
static void
-_dmap_share_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+_dmap_share_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
DMAPShare *share = DMAP_SHARE (object);
@@ -533,18 +552,19 @@ _dmap_share_set_property (GObject *object,
_dmap_share_set_password (share, g_value_get_string (value));
break;
case PROP_DB:
- share->priv->db = (DMAPDb *) g_value_get_pointer (value);
- break;
- case PROP_CONTAINER_DB:
- share->priv->container_db = (DMAPContainerDb *) g_value_get_pointer (value);
- break;
- case PROP_TRANSCODE_MIMETYPE:
+ share->priv->db = (DMAPDb *) g_value_get_pointer (value);
+ break;
+ case PROP_CONTAINER_DB:
+ share->priv->container_db =
+ (DMAPContainerDb *) g_value_get_pointer (value);
+ break;
+ case PROP_TRANSCODE_MIMETYPE:
/* FIXME: get or dup? */
- share->priv->transcode_mimetype = g_value_dup_string (value);
- break;
- case PROP_TXT_RECORDS:
- share->priv->txt_records = g_value_dup_boxed (value);
- break;
+ share->priv->transcode_mimetype = g_value_dup_string (value);
+ break;
+ case PROP_TXT_RECORDS:
+ share->priv->txt_records = g_value_dup_boxed (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -552,10 +572,8 @@ _dmap_share_set_property (GObject *object,
}
static void
-_dmap_share_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+_dmap_share_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
DMAPShare *share = DMAP_SHARE (object);
@@ -575,25 +593,25 @@ _dmap_share_get_property (GObject *object,
case PROP_REVISION_NUMBER:
g_value_set_uint (value,
_dmap_share_get_revision_number
- (DMAP_SHARE (object)));
+ (DMAP_SHARE (object)));
break;
case PROP_AUTH_METHOD:
g_value_set_uint (value,
_dmap_share_get_auth_method
- (DMAP_SHARE (object)));
+ (DMAP_SHARE (object)));
break;
case PROP_DB:
- g_value_set_pointer (value, share->priv->db);
- break;
- case PROP_CONTAINER_DB:
- g_value_set_pointer (value, share->priv->container_db);
- break;
- case PROP_TRANSCODE_MIMETYPE:
- g_value_set_string (value, share->priv->transcode_mimetype);
- break;
- case PROP_TXT_RECORDS:
- g_value_set_boxed (value, share->priv->txt_records);
- break;
+ g_value_set_pointer (value, share->priv->db);
+ break;
+ case PROP_CONTAINER_DB:
+ g_value_set_pointer (value, share->priv->container_db);
+ break;
+ case PROP_TRANSCODE_MIMETYPE:
+ g_value_set_string (value, share->priv->transcode_mimetype);
+ break;
+ case PROP_TXT_RECORDS:
+ g_value_set_boxed (value, share->priv->txt_records);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -601,7 +619,7 @@ _dmap_share_get_property (GObject *object,
}
static void
-_dmap_share_finalize (GObject *object)
+_dmap_share_finalize (GObject * object)
{
DMAPShare *share = DMAP_SHARE (object);
@@ -620,7 +638,7 @@ _dmap_share_finalize (GObject *object)
g_object_unref (share->priv->db);
g_object_unref (share->priv->container_db);
-
+
g_strfreev (share->priv->txt_records);
if (share->priv->publisher) {
@@ -631,32 +649,32 @@ _dmap_share_finalize (GObject *object)
}
static void
-dmap_share_class_init (DMAPShareClass *klass)
+dmap_share_class_init (DMAPShareClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->get_property = _dmap_share_get_property;
object_class->set_property = _dmap_share_set_property;
- object_class->finalize = _dmap_share_finalize;
+ object_class->finalize = _dmap_share_finalize;
/* Pure virtual methods: */
- klass->get_desired_port = NULL;
- klass->get_type_of_service = NULL;
+ klass->get_desired_port = NULL;
+ klass->get_type_of_service = NULL;
klass->message_add_standard_headers = NULL;
- klass->get_meta_data_map = NULL;
- klass->add_entry_to_mlcl = NULL;
+ klass->get_meta_data_map = NULL;
+ klass->add_entry_to_mlcl = NULL;
klass->databases_browse_xxx = NULL;
- klass->databases_items_xxx = NULL;
+ klass->databases_items_xxx = NULL;
/* Virtual methods: */
- klass->content_codes = _dmap_share_content_codes;
- klass->login = _dmap_share_login;
- klass->logout = _dmap_share_logout;
- klass->update = _dmap_share_update;
- klass->published = _dmap_share_published;
+ klass->content_codes = _dmap_share_content_codes;
+ klass->login = _dmap_share_login;
+ klass->logout = _dmap_share_logout;
+ klass->update = _dmap_share_update;
+ klass->published = _dmap_share_published;
klass->name_collision = _dmap_share_name_collision;
- klass->databases = _dmap_share_databases;
- klass->ctrl_int = _dmap_share_ctrl_int;
+ klass->databases = _dmap_share_databases;
+ klass->ctrl_int = _dmap_share_ctrl_int;
g_object_class_install_property (object_class,
PROP_SERVER_IPV4,
@@ -665,7 +683,7 @@ dmap_share_class_init (DMAPShareClass *klass)
"Soup server",
SOUP_TYPE_SERVER,
G_PARAM_READABLE));
-
+
g_object_class_install_property (object_class,
PROP_SERVER_IPV6,
g_param_spec_object ("server-ipv6",
@@ -673,26 +691,26 @@ dmap_share_class_init (DMAPShareClass *klass)
"Soup server",
SOUP_TYPE_SERVER,
G_PARAM_READABLE));
-
+
g_object_class_install_property (object_class,
PROP_NAME,
g_param_spec_string ("name",
- "Name",
- "Share Name",
- NULL,
- G_PARAM_READWRITE));
+ "Name",
+ "Share Name",
+ NULL,
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_PASSWORD,
g_param_spec_string ("password",
- "Authentication password",
- "Authentication password",
- NULL,
- G_PARAM_READWRITE));
+ "Authentication password",
+ "Authentication password",
+ NULL,
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_REVISION_NUMBER,
g_param_spec_uint ("revision_number",
- "Revision number",
+ "Revision number",
"Revision number",
0,
G_MAXINT,
@@ -702,62 +720,67 @@ dmap_share_class_init (DMAPShareClass *klass)
g_object_class_install_property (object_class,
PROP_AUTH_METHOD,
g_param_spec_uint ("auth_method",
- "Authentication method",
- "Authentication method",
- DMAP_SHARE_AUTH_METHOD_NONE,
- DMAP_SHARE_AUTH_METHOD_PASSWORD,
- 0,
- G_PARAM_READWRITE));
+ "Authentication method",
+ "Authentication method",
+ DMAP_SHARE_AUTH_METHOD_NONE,
+ DMAP_SHARE_AUTH_METHOD_PASSWORD,
+ 0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_DB,
+ g_param_spec_pointer ("db",
+ "DB",
+ "DB object",
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY));
+
g_object_class_install_property (object_class,
- PROP_DB,
- g_param_spec_pointer ("db",
- "DB",
- "DB object",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
- g_object_class_install_property (object_class,
- PROP_CONTAINER_DB,
- g_param_spec_pointer ("container-db",
- "Container DB",
- "Container DB object",
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+ PROP_CONTAINER_DB,
+ g_param_spec_pointer ("container-db",
+ "Container DB",
+ "Container DB object",
+ G_PARAM_READWRITE
+ |
+ G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
- PROP_TRANSCODE_MIMETYPE,
- g_param_spec_string ("transcode-mimetype",
- "Transcode mimetype",
- "Set mimetype of stream after transcoding",
- NULL,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-
+ PROP_TRANSCODE_MIMETYPE,
+ g_param_spec_string
+ ("transcode-mimetype",
+ "Transcode mimetype",
+ "Set mimetype of stream after transcoding",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
- PROP_TXT_RECORDS,
- g_param_spec_boxed ("txt-records",
- "TXT-Records",
- "Set TXT-Records used for MDNS publishing",
- G_TYPE_STRV,
- G_PARAM_READWRITE));
+ PROP_TXT_RECORDS,
+ g_param_spec_boxed ("txt-records",
+ "TXT-Records",
+ "Set TXT-Records used for MDNS publishing",
+ G_TYPE_STRV,
+ G_PARAM_READWRITE));
g_type_class_add_private (klass, sizeof (DMAPSharePrivate));
}
-static void published_adapter (DMAPMdnsPublisher *publisher,
- const char *name,
- DMAPShare *share)
+static void
+published_adapter (DMAPMdnsPublisher * publisher,
+ const char *name, DMAPShare * share)
{
DMAP_SHARE_GET_CLASS (share)->published (share, publisher, name);
}
-static void name_collision_adapter (DMAPMdnsPublisher *publisher,
- const char *name,
- DMAPShare *share)
+static void
+name_collision_adapter (DMAPMdnsPublisher * publisher,
+ const char *name, DMAPShare * share)
{
DMAP_SHARE_GET_CLASS (share)->name_collision (share, publisher, name);
}
static void
-dmap_share_init (DMAPShare *share)
+dmap_share_init (DMAPShare * share)
{
share->priv = DMAP_SHARE_GET_PRIVATE (share);
@@ -767,8 +790,7 @@ dmap_share_init (DMAPShare *share)
g_signal_connect_object (share->priv->publisher,
"published",
- G_CALLBACK (published_adapter),
- share, 0);
+ G_CALLBACK (published_adapter), share, 0);
g_signal_connect_object (share->priv->publisher,
"name-collision",
G_CALLBACK (name_collision_adapter),
@@ -776,22 +798,19 @@ dmap_share_init (DMAPShare *share)
}
guint
-_dmap_share_get_auth_method (DMAPShare *share)
+_dmap_share_get_auth_method (DMAPShare * share)
{
return share->priv->auth_method;
}
guint
-_dmap_share_get_revision_number (DMAPShare *share)
+_dmap_share_get_revision_number (DMAPShare * share)
{
return share->priv->revision_number;
}
-
-
static gboolean
-get_session_id (GHashTable *query,
- guint32 *id)
+get_session_id (GHashTable * query, guint32 * id)
{
char *session_id_str;
guint32 session_id;
@@ -810,15 +829,16 @@ get_session_id (GHashTable *query,
}
gboolean
-_dmap_share_get_revision_number_from_query (GHashTable *query,
- guint *number)
+_dmap_share_get_revision_number_from_query (GHashTable * query,
+ guint * number)
{
char *revision_number_str;
guint revision_number;
revision_number_str = g_hash_table_lookup (query, "revision-number");
if (revision_number_str == NULL) {
- g_warning ("Client asked for an update without a rev. number");
+ g_warning
+ ("Client asked for an update without a rev. number");
return FALSE;
}
@@ -830,14 +850,13 @@ _dmap_share_get_revision_number_from_query (GHashTable *query,
}
gboolean
-_dmap_share_session_id_validate (DMAPShare *share,
- SoupClientContext *context,
- SoupMessage *message,
- GHashTable *query,
- guint32 *id)
+_dmap_share_session_id_validate (DMAPShare * share,
+ SoupClientContext * context,
+ SoupMessage * message,
+ GHashTable * query, guint32 * id)
{
- guint32 session_id;
- gboolean res;
+ guint32 session_id;
+ gboolean res;
const char *addr;
const char *remote_address;
@@ -846,7 +865,7 @@ _dmap_share_session_id_validate (DMAPShare *share,
}
res = get_session_id (query, &session_id);
- if (! res) {
+ if (!res) {
g_warning ("Validation failed: Unable to parse session id");
return FALSE;
}
@@ -855,16 +874,18 @@ _dmap_share_session_id_validate (DMAPShare *share,
addr = g_hash_table_lookup (share->priv->session_ids,
GUINT_TO_POINTER (session_id));
if (addr == NULL) {
- g_warning ("Validation failed: Unable to lookup session id %u",
- session_id);
+ g_warning
+ ("Validation failed: Unable to lookup session id %u",
+ session_id);
return FALSE;
}
remote_address = soup_client_context_get_host (context);
g_debug ("Validating session id %u from %s matches %s",
- session_id, remote_address, addr);
+ session_id, remote_address, addr);
if (remote_address == NULL || strcmp (addr, remote_address) != 0) {
- g_warning ("Validation failed: Remote address does not match stored address");
+ g_warning
+ ("Validation failed: Remote address does not match stored address");
return FALSE;
}
@@ -876,8 +897,7 @@ _dmap_share_session_id_validate (DMAPShare *share,
}
static guint32
-session_id_generate (DMAPShare *share,
- SoupClientContext *context)
+session_id_generate (DMAPShare * share, SoupClientContext * context)
{
guint32 id;
@@ -887,12 +907,11 @@ session_id_generate (DMAPShare *share,
}
guint32
-_dmap_share_session_id_create (DMAPShare *share,
- SoupClientContext *context)
+_dmap_share_session_id_create (DMAPShare * share, SoupClientContext * context)
{
- guint32 id;
+ guint32 id;
const char *addr;
- char *remote_address;
+ char *remote_address;
do {
/* create a unique session id */
@@ -902,7 +921,7 @@ _dmap_share_session_id_create (DMAPShare *share,
/* if already used, try again */
addr = g_hash_table_lookup (share->priv->session_ids,
GUINT_TO_POINTER (id));
- } while (addr != NULL);
+ } while (addr != NULL);
/* store session id and remote address */
remote_address = g_strdup (soup_client_context_get_host (context));
@@ -913,17 +932,16 @@ _dmap_share_session_id_create (DMAPShare *share,
}
void
-_dmap_share_session_id_remove (DMAPShare *share,
- SoupClientContext *context,
- guint32 id)
+_dmap_share_session_id_remove (DMAPShare * share,
+ SoupClientContext * context, guint32 id)
{
g_hash_table_remove (share->priv->session_ids, GUINT_TO_POINTER (id));
}
void
-_dmap_share_message_set_from_dmap_structure (DMAPShare *share,
- SoupMessage *message,
- GNode *structure)
+_dmap_share_message_set_from_dmap_structure (DMAPShare * share,
+ SoupMessage * message,
+ GNode * structure)
{
gchar *resp;
guint length;
@@ -944,10 +962,8 @@ _dmap_share_message_set_from_dmap_structure (DMAPShare *share,
soup_message_set_status (message, SOUP_STATUS_OK);
}
-
gboolean
-_dmap_share_client_requested (bitwise bits,
- gint field)
+_dmap_share_client_requested (bitwise bits, gint field)
{
return 0 != (bits & (((bitwise) 1) << field));
}
@@ -955,13 +971,12 @@ _dmap_share_client_requested (bitwise bits,
gboolean
_dmap_share_uri_is_local (const char *text_uri)
{
- return g_str_has_prefix (text_uri, "file://");
+ return g_str_has_prefix (text_uri, "file://");
}
gboolean
-_dmap_share_soup_auth_filter (SoupAuthDomain *auth_domain,
- SoupMessage *msg,
- gpointer user_data)
+_dmap_share_soup_auth_filter (SoupAuthDomain * auth_domain,
+ SoupMessage * msg, gpointer user_data)
{
const char *path;
@@ -980,61 +995,58 @@ _dmap_share_soup_auth_filter (SoupAuthDomain *auth_domain,
}
void
-_dmap_share_published (DMAPShare *share,
- DMAPMdnsPublisher *publisher,
- const char *name)
+_dmap_share_published (DMAPShare * share,
+ DMAPMdnsPublisher * publisher, const char *name)
{
gchar *nameprop;
g_object_get ((gpointer) share, "name", &nameprop, NULL);
- if (nameprop == NULL || name == NULL) {
+ if (nameprop == NULL || name == NULL) {
g_free (nameprop);
- return;
- }
+ return;
+ }
- if (strcmp (nameprop, name) == 0) {
- g_debug ("mDNS publish successful");
- share->priv->published = TRUE;
- }
+ if (strcmp (nameprop, name) == 0) {
+ g_debug ("mDNS publish successful");
+ share->priv->published = TRUE;
+ }
g_free (nameprop);
}
void
-_dmap_share_name_collision (DMAPShare *share,
- DMAPMdnsPublisher *publisher,
- const char *name)
+_dmap_share_name_collision (DMAPShare * share,
+ DMAPMdnsPublisher * publisher, const char *name)
{
gchar *nameprop;
- char *new_name = "FIXME";
+ char *new_name = "FIXME";
g_object_get ((gpointer) share, "name", &nameprop, NULL);
- if (nameprop == NULL || name == NULL) {
+ if (nameprop == NULL || name == NULL) {
g_free (nameprop);
- return;
- }
+ return;
+ }
- if (strcmp (nameprop, name) == 0) {
- g_warning ("Duplicate share name on mDNS");
+ if (strcmp (nameprop, name) == 0) {
+ g_warning ("Duplicate share name on mDNS");
- _dmap_share_set_name (DMAP_SHARE(share), new_name);
- g_free (new_name);
- }
+ _dmap_share_set_name (DMAP_SHARE (share), new_name);
+ g_free (new_name);
+ }
g_free (nameprop);
- return;
+ return;
}
void
-_dmap_share_content_codes (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
+_dmap_share_content_codes (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
/* MCCR content codes response
* MSTT status
@@ -1061,9 +1073,13 @@ _dmap_share_content_codes (DMAPShare *share,
GNode *mdcl;
mdcl = dmap_structure_add (mccr, DMAP_CC_MDCL);
- dmap_structure_add (mdcl, DMAP_CC_MCNM, dmap_content_code_string_as_int32(defs[i].string));
+ dmap_structure_add (mdcl, DMAP_CC_MCNM,
+ dmap_content_code_string_as_int32 (defs
+ [i].
+ string));
dmap_structure_add (mdcl, DMAP_CC_MCNA, defs[i].name);
- dmap_structure_add (mdcl, DMAP_CC_MCTY, (gint32) defs[i].type);
+ dmap_structure_add (mdcl, DMAP_CC_MCTY,
+ (gint32) defs[i].type);
}
_dmap_share_message_set_from_dmap_structure (share, message, mccr);
@@ -1071,12 +1087,11 @@ _dmap_share_content_codes (DMAPShare *share,
}
void
-_dmap_share_login (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
+_dmap_share_login (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
/* MLOG login response
* MSTT status
@@ -1098,19 +1113,19 @@ _dmap_share_login (DMAPShare *share,
}
void
-_dmap_share_logout (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
+_dmap_share_logout (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
- int status;
+ int status;
guint32 id;
g_debug ("Path is %s.", path);
- if (_dmap_share_session_id_validate (share, context, message, query, &id)) {
+ if (_dmap_share_session_id_validate
+ (share, context, message, query, &id)) {
_dmap_share_session_id_remove (share, context, id);
status = SOUP_STATUS_NO_CONTENT;
@@ -1122,32 +1137,36 @@ _dmap_share_logout (DMAPShare *share,
}
void
-_dmap_share_update (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
+_dmap_share_update (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
- guint revision_number;
+ guint revision_number;
gboolean res;
g_debug ("Path is %s.", path);
- res = _dmap_share_get_revision_number_from_query (query, &revision_number);
+ res = _dmap_share_get_revision_number_from_query (query,
+ &revision_number);
if (res && revision_number != _dmap_share_get_revision_number (share)) {
/* MUPD update response
- * MSTT status
- * MUSR server revision
+ * MSTT status
+ * MUSR server revision
*/
GNode *mupd;
mupd = dmap_structure_add (NULL, DMAP_CC_MUPD);
- dmap_structure_add (mupd, DMAP_CC_MSTT, (gint32) DMAP_STATUS_OK);
- dmap_structure_add (mupd, DMAP_CC_MUSR, (gint32) _dmap_share_get_revision_number (share));
-
- _dmap_share_message_set_from_dmap_structure (share, message, mupd);
+ dmap_structure_add (mupd, DMAP_CC_MSTT,
+ (gint32) DMAP_STATUS_OK);
+ dmap_structure_add (mupd, DMAP_CC_MUSR,
+ (gint32)
+ _dmap_share_get_revision_number (share));
+
+ _dmap_share_message_set_from_dmap_structure (share, message,
+ mupd);
dmap_structure_destroy (mupd);
} else {
/* FIXME: This seems like a bug. It just leaks the
@@ -1169,7 +1188,7 @@ _dmap_share_parse_meta_str (const char *attrs, struct DMAPMetaDataMap *mdm)
bits = ~0;
} else {
gchar **attrsv;
-
+
attrsv = g_strsplit (attrs, ",", -1);
for (i = 0; attrsv[i]; i++) {
@@ -1184,16 +1203,17 @@ _dmap_share_parse_meta_str (const char *attrs, struct DMAPMetaDataMap *mdm)
}
if (found == FALSE)
- g_debug ("Unknown meta request: %s", attrsv[i]);
+ g_debug ("Unknown meta request: %s",
+ attrsv[i]);
}
g_strfreev (attrsv);
- }
+ }
return bits;
}
bitwise
-_dmap_share_parse_meta (GHashTable *query, struct DMAPMetaDataMap *mdm)
+_dmap_share_parse_meta (GHashTable * query, struct DMAPMetaDataMap * mdm)
{
const gchar *attrs;
@@ -1205,7 +1225,8 @@ _dmap_share_parse_meta (GHashTable *query, struct DMAPMetaDataMap *mdm)
}
void
-_dmap_share_add_playlist_to_mlcl (gpointer id, DMAPContainerRecord *record, gpointer _mb)
+_dmap_share_add_playlist_to_mlcl (gpointer id, DMAPContainerRecord * record,
+ gpointer _mb)
{
/* MLIT listing item
* MIID item id
@@ -1226,9 +1247,11 @@ _dmap_share_add_playlist_to_mlcl (gpointer id, DMAPContainerRecord *record, gpoi
*/
mlit = dmap_structure_add (mb->mlcl, DMAP_CC_MLIT);
- dmap_structure_add (mlit, DMAP_CC_MIID, dmap_container_record_get_id (record));
+ dmap_structure_add (mlit, DMAP_CC_MIID,
+ dmap_container_record_get_id (record));
/* we don't have a persistant ID for playlists, unfortunately */
- dmap_structure_add (mlit, DMAP_CC_MPER, (gint64) dmap_container_record_get_id (record));
+ dmap_structure_add (mlit, DMAP_CC_MPER,
+ (gint64) dmap_container_record_get_id (record));
dmap_structure_add (mlit, DMAP_CC_MINM, name);
dmap_structure_add (mlit, DMAP_CC_MIMC, (gint32) num_songs);
@@ -1243,10 +1266,10 @@ _dmap_share_add_playlist_to_mlcl (gpointer id, DMAPContainerRecord *record, gpoi
g_free (name);
return;
-}
+}
GSList *
-_dmap_share_build_filter (gchar *filterstr)
+_dmap_share_build_filter (gchar * filterstr)
{
/* Produces a list of lists, each being a filter definition that may
* be one or more filter criteria.
@@ -1257,19 +1280,20 @@ _dmap_share_build_filter (gchar *filterstr)
* or (Roku):
* 'daap.songgenre:Other' 'daap.songartist:Band'.
* or
- * 'dmap.itemid:1000'
+ * 'dmap.itemid:1000'
* or
- * 'dmap.itemid:1000','dmap:itemid:1001'
+ * 'dmap.itemid:1000','dmap:itemid:1001'
* or
* 'daap.songgenre:Foo'+'daap.songartist:Bar'+'daap.songalbum:Baz'
* or (iPhoto '09)
* ('daap.idemid:1000','dmap:itemid:1001')
* or (DACP):
* ('com.apple.itunes.mediakind:1','com.apple.itunes.mediakind:32') 'daap.songartist!:'
- */
+ */
gchar *next_char;
GString *value;
+
//gboolean save_value;
gboolean is_key;
gboolean is_value;
@@ -1279,7 +1303,7 @@ _dmap_share_build_filter (gchar *filterstr)
gint parentheses_count;
gint quotes_count;
FilterDefinition *def;
-
+
GSList *list = NULL;
GSList *filter = NULL;
@@ -1287,9 +1311,9 @@ _dmap_share_build_filter (gchar *filterstr)
if (filterstr == NULL)
return NULL;
-
+
next_char = filterstr;
-
+
parentheses_count = 0;
quotes_count = 0;
is_key = TRUE;
@@ -1298,7 +1322,7 @@ _dmap_share_build_filter (gchar *filterstr)
negate = FALSE;
value = NULL;
def = NULL;
-
+
// The query string is divided in groups of AND separated by a space,
// each group containing queries of OR separated by comma enclosed in
// parentheses. Queries are key, value pairs separated by ':' enclosed
@@ -1332,64 +1356,64 @@ _dmap_share_build_filter (gchar *filterstr)
next_char++;
} else {
switch (*next_char) {
- case '(':
- if (is_value) {
- accept = TRUE;
- } else {
- parentheses_count++;
- }
- break;
- case ')':
- if (is_value) {
- accept = TRUE;
- } else {
- parentheses_count--;
- }
- break;
- case '\'':
- if (quotes_count > 0) {
- quotes_count = 0;
- } else {
- quotes_count = 1;
- }
- break;
- case ' ':
- if (is_value) {
- accept = TRUE;
- } else {
- new_group = TRUE;
- }
- break;
- case ':':
- // Inside values, they will be included in the
- // query string, otherwise it indicates there
- // will be a value next.
- if (is_value) {
- accept = TRUE;
- } else if (is_key) {
- is_value = TRUE;
- }
- break;
- case '!':
- if (is_value) {
- accept = TRUE;
- } else if (is_key && value) {
- negate = TRUE;
- }
- break;
- case ',':
- case '+':
- // Accept these characters only if inside quotes
- if (is_value) {
- accept = TRUE;
- }
- break;
- case '\0':
- // Never accept
- break;
- default:
+ case '(':
+ if (is_value) {
+ accept = TRUE;
+ } else {
+ parentheses_count++;
+ }
+ break;
+ case ')':
+ if (is_value) {
accept = TRUE;
- break;
+ } else {
+ parentheses_count--;
+ }
+ break;
+ case '\'':
+ if (quotes_count > 0) {
+ quotes_count = 0;
+ } else {
+ quotes_count = 1;
+ }
+ break;
+ case ' ':
+ if (is_value) {
+ accept = TRUE;
+ } else {
+ new_group = TRUE;
+ }
+ break;
+ case ':':
+ // Inside values, they will be included in the
+ // query string, otherwise it indicates there
+ // will be a value next.
+ if (is_value) {
+ accept = TRUE;
+ } else if (is_key) {
+ is_value = TRUE;
+ }
+ break;
+ case '!':
+ if (is_value) {
+ accept = TRUE;
+ } else if (is_key && value) {
+ negate = TRUE;
+ }
+ break;
+ case ',':
+ case '+':
+ // Accept these characters only if inside quotes
+ if (is_value) {
+ accept = TRUE;
+ }
+ break;
+ case '\0':
+ // Never accept
+ break;
+ default:
+ accept = TRUE;
+ break;
}
}
//g_debug ("Char: %c, Accept: %s", *next_char, accept?"TRUE":"FALSE");
@@ -1441,36 +1465,39 @@ _dmap_share_build_filter (gchar *filterstr)
if (def) {
filter = g_slist_append (filter, def);
}
-
+
if (filter) {
list = g_slist_append (list, filter);
- }
+ }
GSList *ptr1, *ptr2;
- for (ptr1 = list; ptr1 != NULL; ptr1 = ptr1->next) {
- for (ptr2 = ptr1->data; ptr2 != NULL; ptr2 = ptr2->next) {
- g_debug ("%s = %s", ((FilterDefinition *) ptr2->data)->key, ((FilterDefinition *) ptr2->data)->value);
- }
- }
+ for (ptr1 = list; ptr1 != NULL; ptr1 = ptr1->next) {
+ for (ptr2 = ptr1->data; ptr2 != NULL; ptr2 = ptr2->next) {
+ g_debug ("%s = %s",
+ ((FilterDefinition *) ptr2->data)->key,
+ ((FilterDefinition *) ptr2->data)->value);
+ }
+ }
- return list;
+ return list;
}
void
-dmap_share_free_filter (GSList *filter)
+dmap_share_free_filter (GSList * filter)
{
- GSList *ptr1, *ptr2;
-
- for (ptr1 = filter; ptr1 != NULL; ptr1 = ptr1->next) {
- for (ptr2 = ptr1->data; ptr2 != NULL; ptr2 = ptr2->next) {
- g_free (((FilterDefinition *) ptr2->data)->value);
- g_free (ptr2->data);
- }
- }
+ GSList *ptr1, *ptr2;
+
+ for (ptr1 = filter; ptr1 != NULL; ptr1 = ptr1->next) {
+ for (ptr2 = ptr1->data; ptr2 != NULL; ptr2 = ptr2->next) {
+ g_free (((FilterDefinition *) ptr2->data)->value);
+ g_free (ptr2->data);
+ }
+ }
}
-typedef struct {
+typedef struct
+{
gchar *name;
gint64 group_id;
gchar *artist;
@@ -1478,13 +1505,14 @@ typedef struct {
} GroupInfo;
static void
-group_items (gpointer key, DMAPRecord *record, GHashTable *groups)
+group_items (gpointer key, DMAPRecord * record, GHashTable * groups)
{
gchar *album, *artist;
GroupInfo *group_info;
gint64 group_id;
-
- g_object_get (record, "songartist", &artist, "songalbum", &album, "songalbumid", &group_id, NULL);
+
+ g_object_get (record, "songartist", &artist, "songalbum", &album,
+ "songalbumid", &group_id, NULL);
if (!album) {
g_free (artist);
return;
@@ -1505,46 +1533,49 @@ group_items (gpointer key, DMAPRecord *record, GHashTable *groups)
}
static gint
-group_info_cmp (gconstpointer group1, gconstpointer group2)
+group_info_cmp (gconstpointer group1, gconstpointer group2)
{
- return g_ascii_strcasecmp (((GroupInfo*)group1)->name, ((GroupInfo*)group2)->name);
+ return g_ascii_strcasecmp (((GroupInfo *) group1)->name,
+ ((GroupInfo *) group2)->name);
}
static void
debug_param (gpointer key, gpointer val, gpointer user_data)
{
- g_debug ("%s %s", (char *) key, (char *) val);
+ g_debug ("%s %s", (char *) key, (char *) val);
}
void
-_dmap_share_ctrl_int (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
+_dmap_share_ctrl_int (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
g_debug ("Path is %s.", path);
if (query) {
g_hash_table_foreach (query, debug_param, NULL);
}
-
+
g_debug ("ctrl-int not implemented");
}
static void
accumulate_mlcl_size_and_ids (gpointer id,
- DMAPRecord *record,
+ DMAPRecord * record,
struct share_bitwise_t *share_bitwise)
{
share_bitwise->id_list = g_slist_append (share_bitwise->id_list, id);
/* Make copy and set mlcl to NULL so real MLCL does not get changed */
struct MLCL_Bits mb_copy = share_bitwise->mb;
+
mb_copy.mlcl = dmap_structure_add (NULL, DMAP_CC_MLCL);;
- DMAP_SHARE_GET_CLASS (share_bitwise->share)->add_entry_to_mlcl (id, record, &mb_copy);
- share_bitwise->size += dmap_structure_get_size(mb_copy.mlcl);
+ DMAP_SHARE_GET_CLASS (share_bitwise->share)->add_entry_to_mlcl (id,
+ record,
+ &mb_copy);
+ share_bitwise->size += dmap_structure_get_size (mb_copy.mlcl);
/* Minus eight because we do not want to add size of MLCL CC field + size field n times,
* where n == number of records.
@@ -1556,19 +1587,18 @@ accumulate_mlcl_size_and_ids (gpointer id,
}
static void
-write_dmap_preamble (SoupMessage *message, GNode *node)
+write_dmap_preamble (SoupMessage * message, GNode * node)
{
guint length;
gchar *data = dmap_structure_serialize (node, &length);
+
soup_message_body_append (message->response_body,
- SOUP_MEMORY_TAKE,
- data,
- length);
+ SOUP_MEMORY_TAKE, data, length);
dmap_structure_destroy (node);
}
static void
-write_next_mlit (SoupMessage *message, struct share_bitwise_t *share_bitwise)
+write_next_mlit (SoupMessage * message, struct share_bitwise_t *share_bitwise)
{
if (share_bitwise->id_list == NULL) {
g_debug ("No more ID's, sending message complete.");
@@ -1577,24 +1607,31 @@ write_next_mlit (SoupMessage *message, struct share_bitwise_t *share_bitwise)
gchar *data = NULL;
guint length;
DMAPRecord *record;
- struct MLCL_Bits mb = {NULL,0};
+ struct MLCL_Bits mb = { NULL, 0 };
- record = share_bitwise->lookup_by_id (share_bitwise->db, GPOINTER_TO_UINT (share_bitwise->id_list->data));
+ record = share_bitwise->lookup_by_id (share_bitwise->db,
+ GPOINTER_TO_UINT
+ (share_bitwise->
+ id_list->data));
mb.bits = share_bitwise->mb.bits;
mb.mlcl = dmap_structure_add (NULL, DMAP_CC_MLCL);
- DMAP_SHARE_GET_CLASS (share_bitwise->share)->add_entry_to_mlcl (share_bitwise->id_list->data, record, &mb);
- data = dmap_structure_serialize (g_node_first_child(mb.mlcl), &length);
+ DMAP_SHARE_GET_CLASS (share_bitwise->share)->
+ add_entry_to_mlcl (share_bitwise->id_list->data,
+ record, &mb);
+ data = dmap_structure_serialize (g_node_first_child (mb.mlcl),
+ &length);
soup_message_body_append (message->response_body,
- SOUP_MEMORY_TAKE,
- data,
- length);
- g_debug ("Sending ID %u.", GPOINTER_TO_UINT (share_bitwise->id_list->data));
+ SOUP_MEMORY_TAKE, data, length);
+ g_debug ("Sending ID %u.",
+ GPOINTER_TO_UINT (share_bitwise->id_list->data));
dmap_structure_destroy (mb.mlcl);
- share_bitwise->id_list = g_slist_remove (share_bitwise->id_list, share_bitwise->id_list->data);
+ share_bitwise->id_list =
+ g_slist_remove (share_bitwise->id_list,
+ share_bitwise->id_list->data);
g_object_unref (record);
}
@@ -1603,7 +1640,8 @@ write_next_mlit (SoupMessage *message, struct share_bitwise_t *share_bitwise)
}
static void
-chunked_message_finished (SoupMessage *message, struct share_bitwise_t *share_bitwise)
+chunked_message_finished (SoupMessage * message,
+ struct share_bitwise_t *share_bitwise)
{
g_debug ("Finished sending chunked data.");
if (share_bitwise->destroy)
@@ -1612,7 +1650,7 @@ chunked_message_finished (SoupMessage *message, struct share_bitwise_t *share_bi
}
DMAPRecord *
-g_hash_table_lookup_adapter (GHashTable *ht, guint id)
+g_hash_table_lookup_adapter (GHashTable * ht, guint id)
{
/* NOTE: each time this is called by write_next_mlit(), the
* returned value will be unref'ed by write_next_mlit(). We
@@ -1622,20 +1660,19 @@ g_hash_table_lookup_adapter (GHashTable *ht, guint id)
}
void
-_dmap_share_databases (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
-
+_dmap_share_databases (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
const char *rest_of_path;
g_debug ("Path is %s.", path);
g_hash_table_foreach (query, debug_param, NULL);
- if (! _dmap_share_session_id_validate (share, context, message, query, NULL)) {
+ if (!_dmap_share_session_id_validate
+ (share, context, message, query, NULL)) {
soup_message_set_status (message, SOUP_STATUS_FORBIDDEN);
return;
}
@@ -1643,19 +1680,19 @@ _dmap_share_databases (DMAPShare *share,
rest_of_path = strchr (path + 1, '/');
if (rest_of_path == NULL) {
- /* AVDB server databases
- * MSTT status
- * MUTY update type
- * MTCO specified total count
- * MRCO returned count
- * MLCL listing
- * MLIT listing item
- * MIID item id
- * MPER persistent id
- * MINM item name
- * MIMC item count
- * MCTC container count
- */
+ /* AVDB server databases
+ * MSTT status
+ * MUTY update type
+ * MTCO specified total count
+ * MRCO returned count
+ * MLCL listing
+ * MLIT listing item
+ * MIID item id
+ * MPER persistent id
+ * MINM item name
+ * MIMC item count
+ * MCTC container count
+ */
gchar *nameprop;
GNode *avdb;
GNode *mlcl;
@@ -1664,7 +1701,8 @@ _dmap_share_databases (DMAPShare *share,
g_object_get ((gpointer) share, "name", &nameprop, NULL);
avdb = dmap_structure_add (NULL, DMAP_CC_AVDB);
- dmap_structure_add (avdb, DMAP_CC_MSTT, (gint32) DMAP_STATUS_OK);
+ dmap_structure_add (avdb, DMAP_CC_MSTT,
+ (gint32) DMAP_STATUS_OK);
dmap_structure_add (avdb, DMAP_CC_MUTY, 0);
dmap_structure_add (avdb, DMAP_CC_MTCO, (gint32) 1);
dmap_structure_add (avdb, DMAP_CC_MRCO, (gint32) 1);
@@ -1673,25 +1711,27 @@ _dmap_share_databases (DMAPShare *share,
dmap_structure_add (mlit, DMAP_CC_MIID, (gint32) 1);
dmap_structure_add (mlit, DMAP_CC_MPER, (gint64) 1);
dmap_structure_add (mlit, DMAP_CC_MINM, nameprop);
- dmap_structure_add (mlit, DMAP_CC_MIMC, dmap_db_count (share->priv->db));
+ dmap_structure_add (mlit, DMAP_CC_MIMC,
+ dmap_db_count (share->priv->db));
dmap_structure_add (mlit, DMAP_CC_MCTC, (gint32) 1);
- _dmap_share_message_set_from_dmap_structure (share, message, avdb);
+ _dmap_share_message_set_from_dmap_structure (share, message,
+ avdb);
dmap_structure_destroy (avdb);
g_free (nameprop);
} else if (g_ascii_strcasecmp ("/1/groups", rest_of_path) == 0) {
- /* ADBS database songs
- * MSTT status
- * MUTY update type
- * MTCO specified total count
- * MRCO returned count
- * MLCL listing
- * MLIT
- * attrs
- * MLIT
- * ...
- */
+ /* ADBS database songs
+ * MSTT status
+ * MUTY update type
+ * MTCO specified total count
+ * MRCO returned count
+ * MLCL listing
+ * MLIT
+ * attrs
+ * MLIT
+ * ...
+ */
GSList *filter_def;
gchar *record_query;
@@ -1706,27 +1746,34 @@ _dmap_share_databases (DMAPShare *share,
GNode *mlit;
gint num;
- if (g_strcmp0 (g_hash_table_lookup (query, "group-type"), "albums") != 0) {
+ if (g_strcmp0
+ (g_hash_table_lookup (query, "group-type"),
+ "albums") != 0) {
g_warning ("Unsupported grouping");
- soup_message_set_status (message, SOUP_STATUS_INTERNAL_SERVER_ERROR);
+ soup_message_set_status (message,
+ SOUP_STATUS_INTERNAL_SERVER_ERROR);
return;
}
record_query = g_hash_table_lookup (query, "query");
filter_def = _dmap_share_build_filter (record_query);
- records = dmap_db_apply_filter (DMAP_DB (share->priv->db), filter_def);
+ records =
+ dmap_db_apply_filter (DMAP_DB (share->priv->db),
+ filter_def);
- groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ groups = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, g_free);
g_hash_table_foreach (records, (GHFunc) group_items, groups);
-
+
agal = dmap_structure_add (NULL, DMAP_CC_AGAL);
- dmap_structure_add (agal, DMAP_CC_MSTT, (gint32) DMAP_STATUS_OK);
+ dmap_structure_add (agal, DMAP_CC_MSTT,
+ (gint32) DMAP_STATUS_OK);
dmap_structure_add (agal, DMAP_CC_MUTY, 0);
-
+
num = g_hash_table_size (groups);
dmap_structure_add (agal, DMAP_CC_MTCO, (gint32) num);
dmap_structure_add (agal, DMAP_CC_MRCO, (gint32) num);
-
+
mlcl = dmap_structure_add (agal, DMAP_CC_MLCL);
values = g_hash_table_get_values (groups);
@@ -1735,18 +1782,24 @@ _dmap_share_databases (DMAPShare *share,
if (g_strcmp0 (sort_by, "album") == 0) {
values = g_list_sort (values, group_info_cmp);
} else {
- g_warning ("Unknown sort column: %s", sort_by);
+ g_warning ("Unknown sort column: %s",
+ sort_by);
}
}
for (value = values; value; value = g_list_next (value)) {
- group_info = (GroupInfo*) value->data;
+ group_info = (GroupInfo *) value->data;
mlit = dmap_structure_add (mlcl, DMAP_CC_MLIT);
- dmap_structure_add (mlit, DMAP_CC_MIID, (gint) group_info->group_id);
- dmap_structure_add (mlit, DMAP_CC_MPER, group_info->group_id);
- dmap_structure_add (mlit, DMAP_CC_MINM, group_info->name);
- dmap_structure_add (mlit, DMAP_CC_ASAA, group_info->artist);
- dmap_structure_add (mlit, DMAP_CC_MIMC, (gint32) group_info->count);
+ dmap_structure_add (mlit, DMAP_CC_MIID,
+ (gint) group_info->group_id);
+ dmap_structure_add (mlit, DMAP_CC_MPER,
+ group_info->group_id);
+ dmap_structure_add (mlit, DMAP_CC_MINM,
+ group_info->name);
+ dmap_structure_add (mlit, DMAP_CC_ASAA,
+ group_info->artist);
+ dmap_structure_add (mlit, DMAP_CC_MIMC,
+ (gint32) group_info->count);
// Free this now, since the hash free func won't.
// Name will be freed when the hash table keys are freed.
@@ -1756,36 +1809,41 @@ _dmap_share_databases (DMAPShare *share,
g_list_free (values);
dmap_share_free_filter (filter_def);
- _dmap_share_message_set_from_dmap_structure (share, message, agal);
+ _dmap_share_message_set_from_dmap_structure (share, message,
+ agal);
g_hash_table_destroy (records);
g_hash_table_destroy (groups);
dmap_structure_destroy (agal);
} else if (g_ascii_strcasecmp ("/1/items", rest_of_path) == 0) {
- /* ADBS database songs
- * MSTT status
- * MUTY update type
- * MTCO specified total count
- * MRCO returned count
- * MLCL listing
- * MLIT
- * attrs
- * MLIT
- * ...
- */
+ /* ADBS database songs
+ * MSTT status
+ * MUTY update type
+ * MTCO specified total count
+ * MRCO returned count
+ * MLCL listing
+ * MLIT
+ * attrs
+ * MLIT
+ * ...
+ */
GNode *adbs;
gchar *record_query;
GHashTable *records = NULL;
struct DMAPMetaDataMap *map;
gint32 num_songs;
- struct MLCL_Bits mb = {NULL,0};
+ struct MLCL_Bits mb = { NULL, 0 };
struct share_bitwise_t *share_bitwise;
record_query = g_hash_table_lookup (query, "query");
if (record_query) {
GSList *filter_def;
+
filter_def = _dmap_share_build_filter (record_query);
- records = dmap_db_apply_filter (DMAP_DB (share->priv->db), filter_def);
+ records =
+ dmap_db_apply_filter (DMAP_DB
+ (share->priv->db),
+ filter_def);
num_songs = g_hash_table_size (records);
g_debug ("Found %d records", num_songs);
dmap_share_free_filter (filter_def);
@@ -1812,6 +1870,7 @@ _dmap_share_databases (DMAPShare *share,
/* 1: */
share_bitwise = g_new (struct share_bitwise_t, 1);
+
share_bitwise->share = share;
share_bitwise->server = server;
share_bitwise->mb = mb;
@@ -1819,62 +1878,86 @@ _dmap_share_databases (DMAPShare *share,
share_bitwise->size = 0;
if (record_query) {
share_bitwise->db = records;
- share_bitwise->lookup_by_id = g_hash_table_lookup_adapter;
+ share_bitwise->lookup_by_id =
+ g_hash_table_lookup_adapter;
share_bitwise->destroy = g_hash_table_destroy;
- g_hash_table_foreach (records, (GHFunc) accumulate_mlcl_size_and_ids, share_bitwise);
+ g_hash_table_foreach (records,
+ (GHFunc)
+ accumulate_mlcl_size_and_ids,
+ share_bitwise);
} else {
share_bitwise->db = share->priv->db;
share_bitwise->lookup_by_id = dmap_db_lookup_by_id;
share_bitwise->destroy = NULL;
- dmap_db_foreach (share->priv->db, (GHFunc) accumulate_mlcl_size_and_ids, share_bitwise);
+ dmap_db_foreach (share->priv->db,
+ (GHFunc)
+ accumulate_mlcl_size_and_ids,
+ share_bitwise);
}
/* 2: */
adbs = dmap_structure_add (NULL, DMAP_CC_ADBS);
- dmap_structure_add (adbs, DMAP_CC_MSTT, (gint32) DMAP_STATUS_OK);
+ dmap_structure_add (adbs, DMAP_CC_MSTT,
+ (gint32) DMAP_STATUS_OK);
dmap_structure_add (adbs, DMAP_CC_MUTY, 0);
dmap_structure_add (adbs, DMAP_CC_MTCO, (gint32) num_songs);
dmap_structure_add (adbs, DMAP_CC_MRCO, (gint32) num_songs);
mb.mlcl = dmap_structure_add (adbs, DMAP_CC_MLCL);
- dmap_structure_increase_by_predicted_size (adbs, share_bitwise->size);
- dmap_structure_increase_by_predicted_size (mb.mlcl, share_bitwise->size);
+ dmap_structure_increase_by_predicted_size (adbs,
+ share_bitwise->
+ size);
+ dmap_structure_increase_by_predicted_size (mb.mlcl,
+ share_bitwise->
+ size);
/* 3: */
/* Free memory after each chunk sent out over network. */
- soup_message_body_set_accumulate (message->response_body, FALSE);
- soup_message_headers_append (message->response_headers, "Content-Type", "application/x-dmap-tagged");
- DMAP_SHARE_GET_CLASS (share)->message_add_standard_headers (share, message);
- soup_message_headers_set_content_length (message->response_headers, dmap_structure_get_size(adbs));
+ soup_message_body_set_accumulate (message->response_body,
+ FALSE);
+ soup_message_headers_append (message->response_headers,
+ "Content-Type",
+ "application/x-dmap-tagged");
+ DMAP_SHARE_GET_CLASS (share)->
+ message_add_standard_headers (share, message);
+ soup_message_headers_set_content_length (message->
+ response_headers,
+ dmap_structure_get_size
+ (adbs));
soup_message_set_status (message, SOUP_STATUS_OK);
/* 4: */
- g_signal_connect (message, "wrote_headers", G_CALLBACK (write_dmap_preamble), adbs);
+ g_signal_connect (message, "wrote_headers",
+ G_CALLBACK (write_dmap_preamble), adbs);
/* 5: */
- g_signal_connect (message, "wrote_chunk", G_CALLBACK (write_next_mlit), share_bitwise);
- g_signal_connect (message, "finished", G_CALLBACK (chunked_message_finished), share_bitwise);
+ g_signal_connect (message, "wrote_chunk",
+ G_CALLBACK (write_next_mlit),
+ share_bitwise);
+ g_signal_connect (message, "finished",
+ G_CALLBACK (chunked_message_finished),
+ share_bitwise);
} else if (g_ascii_strcasecmp ("/1/containers", rest_of_path) == 0) {
- /* APLY database playlists
- * MSTT status
- * MUTY update type
- * MTCO specified total count
- * MRCO returned count
- * MLCL listing
- * MLIT listing item
- * MIID item id
- * MPER persistent item id
- * MINM item name
- * MIMC item count
- * ABPL baseplaylist (only for base)
- * MLIT
- * ...
- */
+ /* APLY database playlists
+ * MSTT status
+ * MUTY update type
+ * MTCO specified total count
+ * MRCO returned count
+ * MLCL listing
+ * MLIT listing item
+ * MIID item id
+ * MPER persistent item id
+ * MINM item name
+ * MIMC item count
+ * ABPL baseplaylist (only for base)
+ * MLIT
+ * ...
+ */
gchar *nameprop;
GNode *aply;
GNode *mlit;
struct DMAPMetaDataMap *map;
- struct MLCL_Bits mb = {NULL,0};
+ struct MLCL_Bits mb = { NULL, 0 };
map = DMAP_SHARE_GET_CLASS (share)->get_meta_data_map (share);
mb.bits = _dmap_share_parse_meta (query, map);
@@ -1882,10 +1965,19 @@ _dmap_share_databases (DMAPShare *share,
g_object_get ((gpointer) share, "name", &nameprop, NULL);
aply = dmap_structure_add (NULL, DMAP_CC_APLY);
- dmap_structure_add (aply, DMAP_CC_MSTT, (gint32) DMAP_STATUS_OK);
+ dmap_structure_add (aply, DMAP_CC_MSTT,
+ (gint32) DMAP_STATUS_OK);
dmap_structure_add (aply, DMAP_CC_MUTY, 0);
- dmap_structure_add (aply, DMAP_CC_MTCO, (gint32) dmap_container_db_count (share->priv->container_db) + 1);
- dmap_structure_add (aply, DMAP_CC_MRCO, (gint32) dmap_container_db_count (share->priv->container_db) + 1);
+ dmap_structure_add (aply, DMAP_CC_MTCO,
+ (gint32) dmap_container_db_count (share->
+ priv->
+ container_db)
+ + 1);
+ dmap_structure_add (aply, DMAP_CC_MRCO,
+ (gint32) dmap_container_db_count (share->
+ priv->
+ container_db)
+ + 1);
mb.mlcl = dmap_structure_add (aply, DMAP_CC_MLCL);
/* Base playlist: */
@@ -1893,32 +1985,38 @@ _dmap_share_databases (DMAPShare *share,
dmap_structure_add (mlit, DMAP_CC_MIID, (gint32) 1);
dmap_structure_add (mlit, DMAP_CC_MPER, (gint64) 1);
dmap_structure_add (mlit, DMAP_CC_MINM, nameprop);
- dmap_structure_add (mlit, DMAP_CC_MIMC, dmap_db_count (share->priv->db));
+ dmap_structure_add (mlit, DMAP_CC_MIMC,
+ dmap_db_count (share->priv->db));
dmap_structure_add (mlit, DMAP_CC_ABPL, (gchar) 1);
- dmap_container_db_foreach (share->priv->container_db, (GHFunc) _dmap_share_add_playlist_to_mlcl, &mb);
+ dmap_container_db_foreach (share->priv->container_db,
+ (GHFunc)
+ _dmap_share_add_playlist_to_mlcl,
+ &mb);
- _dmap_share_message_set_from_dmap_structure (share, message, aply);
+ _dmap_share_message_set_from_dmap_structure (share, message,
+ aply);
dmap_structure_destroy (aply);
g_free (nameprop);
- } else if (g_ascii_strncasecmp ("/1/containers/", rest_of_path, 14) == 0) {
- /* APSO playlist songs
- * MSTT status
- * MUTY update type
- * MTCO specified total count
- * MRCO returned count
- * MLCL listing
- * MLIT listing item
- * MIKD item kind
- * MIID item id
- * MCTI container item id
- * MLIT
- * ...
- */
+ } else if (g_ascii_strncasecmp ("/1/containers/", rest_of_path, 14) ==
+ 0) {
+ /* APSO playlist songs
+ * MSTT status
+ * MUTY update type
+ * MTCO specified total count
+ * MRCO returned count
+ * MLCL listing
+ * MLIT listing item
+ * MIKD item kind
+ * MIID item id
+ * MCTI container item id
+ * MLIT
+ * ...
+ */
GNode *apso;
struct DMAPMetaDataMap *map;
- struct MLCL_Bits mb = {NULL,0};
+ struct MLCL_Bits mb = { NULL, 0 };
guint pl_id;
gchar *record_query;
GSList *filter_def;
@@ -1928,34 +2026,52 @@ _dmap_share_databases (DMAPShare *share,
mb.bits = _dmap_share_parse_meta (query, map);
apso = dmap_structure_add (NULL, DMAP_CC_APSO);
- dmap_structure_add (apso, DMAP_CC_MSTT, (gint32) DMAP_STATUS_OK);
+ dmap_structure_add (apso, DMAP_CC_MSTT,
+ (gint32) DMAP_STATUS_OK);
dmap_structure_add (apso, DMAP_CC_MUTY, 0);
-
+
if (g_ascii_strcasecmp ("/1/items", rest_of_path + 13) == 0) {
GList *id;
gchar *sort_by;
GList *keys;
+
record_query = g_hash_table_lookup (query, "query");
filter_def = _dmap_share_build_filter (record_query);
- records = dmap_db_apply_filter (DMAP_DB (share->priv->db), filter_def);
+ records =
+ dmap_db_apply_filter (DMAP_DB
+ (share->priv->db),
+ filter_def);
gint32 num_songs = g_hash_table_size (records);
+
g_debug ("Found %d records", num_songs);
dmap_share_free_filter (filter_def);
- dmap_structure_add (apso, DMAP_CC_MTCO, (gint32) num_songs);
- dmap_structure_add (apso, DMAP_CC_MRCO, (gint32) num_songs);
+ dmap_structure_add (apso, DMAP_CC_MTCO,
+ (gint32) num_songs);
+ dmap_structure_add (apso, DMAP_CC_MRCO,
+ (gint32) num_songs);
mb.mlcl = dmap_structure_add (apso, DMAP_CC_MLCL);
sort_by = g_hash_table_lookup (query, "sort");
keys = g_hash_table_get_keys (records);
if (g_strcmp0 (sort_by, "album") == 0) {
- keys = g_list_sort_with_data (keys, (GCompareDataFunc) daap_record_cmp_by_album, share->priv->db);
+ keys = g_list_sort_with_data (keys,
+ (GCompareDataFunc)
+ daap_record_cmp_by_album,
+ share->priv->
+ db);
} else if (sort_by != NULL) {
- g_warning ("Unknown sort column: %s", sort_by);
+ g_warning ("Unknown sort column: %s",
+ sort_by);
}
for (id = keys; id; id = id->next) {
- (*(DMAP_SHARE_GET_CLASS (share)->add_entry_to_mlcl)) (id->data, g_hash_table_lookup(records, id->data), &mb);
+ (*
+ (DMAP_SHARE_GET_CLASS (share)->
+ add_entry_to_mlcl)) (id->data,
+ g_hash_table_lookup
+ (records, id->data),
+ &mb);
}
g_list_free (keys);
@@ -1963,54 +2079,73 @@ _dmap_share_databases (DMAPShare *share,
} else {
pl_id = strtoul (rest_of_path + 14, NULL, 10);
if (pl_id == 1) {
- gint32 num_songs = dmap_db_count (share->priv->db);
- dmap_structure_add (apso, DMAP_CC_MTCO, (gint32) num_songs);
- dmap_structure_add (apso, DMAP_CC_MRCO, (gint32) num_songs);
- mb.mlcl = dmap_structure_add (apso, DMAP_CC_MLCL);
-
- dmap_db_foreach (share->priv->db, (GHFunc) DMAP_SHARE_GET_CLASS (share)->add_entry_to_mlcl, &mb);
+ gint32 num_songs =
+ dmap_db_count (share->priv->db);
+ dmap_structure_add (apso, DMAP_CC_MTCO,
+ (gint32) num_songs);
+ dmap_structure_add (apso, DMAP_CC_MRCO,
+ (gint32) num_songs);
+ mb.mlcl =
+ dmap_structure_add (apso,
+ DMAP_CC_MLCL);
+
+ dmap_db_foreach (share->priv->db,
+ (GHFunc)
+ DMAP_SHARE_GET_CLASS
+ (share)->add_entry_to_mlcl,
+ &mb);
} else {
DMAPContainerRecord *record;
DMAPDb *entries;
guint num_songs;
-
- record = dmap_container_db_lookup_by_id (share->priv->container_db, pl_id);
- entries = dmap_container_record_get_entries (record);
+
+ record = dmap_container_db_lookup_by_id
+ (share->priv->container_db, pl_id);
+ entries =
+ dmap_container_record_get_entries
+ (record);
/* FIXME: what if entries is NULL (handled in dmapd but should be [also] handled here)? */
num_songs = dmap_db_count (entries);
-
- dmap_structure_add (apso, DMAP_CC_MTCO, (gint32) num_songs);
- dmap_structure_add (apso, DMAP_CC_MRCO, (gint32) num_songs);
- mb.mlcl = dmap_structure_add (apso, DMAP_CC_MLCL);
- dmap_db_foreach (entries, (GHFunc) DMAP_SHARE_GET_CLASS (share)->add_entry_to_mlcl, &mb);
+ dmap_structure_add (apso, DMAP_CC_MTCO,
+ (gint32) num_songs);
+ dmap_structure_add (apso, DMAP_CC_MRCO,
+ (gint32) num_songs);
+ mb.mlcl =
+ dmap_structure_add (apso,
+ DMAP_CC_MLCL);
+
+ dmap_db_foreach (entries,
+ (GHFunc)
+ DMAP_SHARE_GET_CLASS
+ (share)->add_entry_to_mlcl,
+ &mb);
g_object_unref (entries);
g_object_unref (record);
}
}
- _dmap_share_message_set_from_dmap_structure (share, message, apso);
+ _dmap_share_message_set_from_dmap_structure (share, message,
+ apso);
dmap_structure_destroy (apso);
} else if (g_ascii_strncasecmp ("/1/browse/", rest_of_path, 9) == 0) {
- DMAP_SHARE_GET_CLASS (share)->databases_browse_xxx (
- share,
- server,
- message,
- path,
- query,
- context);
+ DMAP_SHARE_GET_CLASS (share)->databases_browse_xxx (share,
+ server,
+ message,
+ path,
+ query,
+ context);
} else if (g_ascii_strncasecmp ("/1/items/", rest_of_path, 9) == 0) {
- /* just the file :) */
- DMAP_SHARE_GET_CLASS (share)->databases_items_xxx (
- share,
- server,
- message,
- path,
- query,
- context);
- } else if (g_str_has_prefix(rest_of_path, "/1/groups/") &&
- g_str_has_suffix(rest_of_path, "/extra_data/artwork")) {
+ /* just the file :) */
+ DMAP_SHARE_GET_CLASS (share)->databases_items_xxx (share,
+ server,
+ message,
+ path,
+ query,
+ context);
+ } else if (g_str_has_prefix (rest_of_path, "/1/groups/") &&
+ g_str_has_suffix (rest_of_path, "/extra_data/artwork")) {
/* We don't yet implement cover requests here, say no cover */
g_debug ("Assuming no artwork for requested group/album");
soup_message_set_status (message, SOUP_STATUS_NOT_FOUND);
diff --git a/libdmapsharing/dmap-share.h b/libdmapsharing/dmap-share.h
index 7efc893..8cda7e2 100644
--- a/libdmapsharing/dmap-share.h
+++ b/libdmapsharing/dmap-share.h
@@ -36,7 +36,6 @@
#include <libdmapsharing/dmap-container-record.h>
G_BEGIN_DECLS
-
/**
* DMAP_TYPE_SHARE:
*
@@ -67,7 +66,6 @@ G_BEGIN_DECLS
*
* Checks whether a valid #GTypeInstance pointer is of type %DMAP_TYPE_SHARE.
*/
-
#define IS_DMAP_SHARE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
DMAP_TYPE_SHARE))
/**
@@ -89,195 +87,185 @@ G_BEGIN_DECLS
*/
#define DMAP_SHARE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
DMAP_TYPE_SHARE, DMAPShareClass))
-
#define DMAP_STATUS_OK 200
-
typedef struct DMAPSharePrivate DMAPSharePrivate;
-typedef struct {
+typedef struct
+{
GObject parent;
DMAPSharePrivate *priv;
} DMAPShare;
typedef struct _DMAPMetaDataMap DMAPMetaDataMap;
-typedef struct {
+typedef struct
+{
GObjectClass parent;
/* Pure virtual methods: */
- guint (*get_desired_port) (DMAPShare *share);
- const char * (*get_type_of_service) (DMAPShare *share);
- void (*message_add_standard_headers) (DMAPShare *share,
- SoupMessage *msg);
- struct DMAPMetaDataMap * (*get_meta_data_map) (DMAPShare *share);
- void (*add_entry_to_mlcl) (gpointer id,
- DMAPRecord *record,
- gpointer mb);
- void (*databases_browse_xxx) (DMAPShare *share,
- SoupServer *server,
- SoupMessage *msg,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
- void (*databases_items_xxx) (DMAPShare *share,
- SoupServer *server,
- SoupMessage *msg,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
+ guint (*get_desired_port) (DMAPShare * share);
+ const char *(*get_type_of_service) (DMAPShare * share);
+ void (*message_add_standard_headers) (DMAPShare * share,
+ SoupMessage * msg);
+ struct DMAPMetaDataMap *(*get_meta_data_map) (DMAPShare * share);
+ void (*add_entry_to_mlcl) (gpointer id,
+ DMAPRecord * record, gpointer mb);
+ void (*databases_browse_xxx) (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * msg,
+ const char *path,
+ GHashTable * query,
+ SoupClientContext * context);
+ void (*databases_items_xxx) (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * msg,
+ const char *path,
+ GHashTable * query,
+ SoupClientContext * context);
/* Pure virtual methods: libsoup callbacks */
- void (*server_info) (DMAPShare *share, SoupServer *server,
- SoupMessage *message, const char *path,
- GHashTable *query, SoupClientContext *ctx);
-
- void (*content_codes) (DMAPShare *share, SoupServer *server,
- SoupMessage *message, const char *path,
- GHashTable *query, SoupClientContext *ctx);
-
- void (*login) (DMAPShare *share, SoupServer *server,
- SoupMessage *message, const char *path,
- GHashTable *query, SoupClientContext *ctx);
-
- void (*logout) (DMAPShare *share, SoupServer *server,
- SoupMessage *message, const char *path,
- GHashTable *query, SoupClientContext *ctx);
-
- void (*update) (DMAPShare *share, SoupServer *server,
- SoupMessage *message, const char *path,
- GHashTable *query, SoupClientContext *ctx);
-
- void (*ctrl_int) (DMAPShare *share, SoupServer *server,
- SoupMessage *message, const char *path,
- GHashTable *query, SoupClientContext *ctx);
+ void (*server_info) (DMAPShare * share, SoupServer * server,
+ SoupMessage * message, const char *path,
+ GHashTable * query, SoupClientContext * ctx);
+
+ void (*content_codes) (DMAPShare * share, SoupServer * server,
+ SoupMessage * message, const char *path,
+ GHashTable * query, SoupClientContext * ctx);
+
+ void (*login) (DMAPShare * share, SoupServer * server,
+ SoupMessage * message, const char *path,
+ GHashTable * query, SoupClientContext * ctx);
+
+ void (*logout) (DMAPShare * share, SoupServer * server,
+ SoupMessage * message, const char *path,
+ GHashTable * query, SoupClientContext * ctx);
+
+ void (*update) (DMAPShare * share, SoupServer * server,
+ SoupMessage * message, const char *path,
+ GHashTable * query, SoupClientContext * ctx);
+
+ void (*ctrl_int) (DMAPShare * share, SoupServer * server,
+ SoupMessage * message, const char *path,
+ GHashTable * query, SoupClientContext * ctx);
/* Virtual methods: MDNS callbacks */
- void (*published) (DMAPShare *share,
- DMAPMdnsPublisher *publisher,
- const char *name);
+ void (*published) (DMAPShare * share,
+ DMAPMdnsPublisher * publisher, const char *name);
- void (*name_collision)(DMAPShare *share,
- DMAPMdnsPublisher *publisher,
- const char *name);
+ void (*name_collision) (DMAPShare * share,
+ DMAPMdnsPublisher * publisher,
+ const char *name);
/* Virtual methods: */
- void (*databases) (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
+ void (*databases) (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context);
} DMAPShareClass;
-struct DMAPMetaDataMap {
- gchar *tag;
+struct DMAPMetaDataMap
+{
+ gchar *tag;
guint md;
};
-GType dmap_share_get_type (void);
+GType dmap_share_get_type (void);
/* Non-virtual methods */
-guint _dmap_share_get_auth_method (DMAPShare *share);
+guint _dmap_share_get_auth_method (DMAPShare * share);
-guint _dmap_share_get_revision_number (DMAPShare *share);
+guint _dmap_share_get_revision_number (DMAPShare * share);
-gboolean _dmap_share_get_revision_number_from_query (GHashTable *query,
- guint *number);
+gboolean _dmap_share_get_revision_number_from_query (GHashTable * query,
+ guint * number);
-gboolean _dmap_share_session_id_validate (DMAPShare *share,
- SoupClientContext *context,
- SoupMessage *msg, GHashTable *query,
- guint32 *id);
+gboolean _dmap_share_session_id_validate (DMAPShare * share,
+ SoupClientContext * context,
+ SoupMessage * msg,
+ GHashTable * query, guint32 * id);
-guint32 _dmap_share_session_id_create (DMAPShare *share,
- SoupClientContext *ctx);
+guint32 _dmap_share_session_id_create (DMAPShare * share,
+ SoupClientContext * ctx);
-void _dmap_share_session_id_remove (DMAPShare *share,
- SoupClientContext *ctx,
- guint32 id);
+void _dmap_share_session_id_remove (DMAPShare * share,
+ SoupClientContext * ctx, guint32 id);
gboolean _dmap_share_client_requested (bitwise bits, gint field);
gboolean _dmap_share_uri_is_local (const char *text_uri);
-gboolean _dmap_share_soup_auth_filter (SoupAuthDomain *auth_domain,
- SoupMessage *msg, gpointer user_data);
+gboolean _dmap_share_soup_auth_filter (SoupAuthDomain * auth_domain,
+ SoupMessage * msg, gpointer user_data);
-gboolean _dmap_share_server_start (DMAPShare *share);
+gboolean _dmap_share_server_start (DMAPShare * share);
-gboolean _dmap_share_publish_start (DMAPShare *share);
+gboolean _dmap_share_publish_start (DMAPShare * share);
-void _dmap_share_message_set_from_dmap_structure (DMAPShare *share,
- SoupMessage *message,
- GNode *structure);
+void _dmap_share_message_set_from_dmap_structure (DMAPShare * share,
+ SoupMessage * message,
+ GNode * structure);
-bitwise _dmap_share_parse_meta (GHashTable *query,
+bitwise _dmap_share_parse_meta (GHashTable * query,
struct DMAPMetaDataMap *mdm);
-bitwise _dmap_share_parse_meta_str (const char *attrs,
+bitwise _dmap_share_parse_meta_str (const char *attrs,
struct DMAPMetaDataMap *mdm);
void _dmap_share_add_playlist_to_mlcl (gpointer id,
- DMAPContainerRecord *record,
+ DMAPContainerRecord * record,
gpointer mb);
-GSList * _dmap_share_build_filter (gchar *filterstr);
+GSList *_dmap_share_build_filter (gchar * filterstr);
-void dmap_share_free_filter (GSList *filter);
+void dmap_share_free_filter (GSList * filter);
/* Virtual methods (libsoup callbacks with default implementation): */
-void _dmap_share_content_codes (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
-
-void _dmap_share_login (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
-
-void _dmap_share_logout (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
-
-void _dmap_share_update (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
+void _dmap_share_content_codes (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query,
+ SoupClientContext * context);
+
+void _dmap_share_login (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context);
+
+void _dmap_share_logout (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context);
+
+void _dmap_share_update (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context);
void
-_dmap_share_databases (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
-
-void _dmap_share_ctrl_int (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
+_dmap_share_databases (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context);
+
+void _dmap_share_ctrl_int (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context);
/* Virtual methods: MDNS callbacks */
-void _dmap_share_published (DMAPShare *share,
- DMAPMdnsPublisher *publisher,
- const char *name);
-
-void _dmap_share_name_collision(DMAPShare *share,
- DMAPMdnsPublisher *publisher,
- const char *name);
+void _dmap_share_published (DMAPShare * share,
+ DMAPMdnsPublisher * publisher, const char *name);
+void _dmap_share_name_collision (DMAPShare * share,
+ DMAPMdnsPublisher * publisher,
+ const char *name);
#endif /* __DMAP_SHARE_H */
diff --git a/libdmapsharing/dmap-structure.c b/libdmapsharing/dmap-structure.c
index 538eca0..e126f8d 100644
--- a/libdmapsharing/dmap-structure.c
+++ b/libdmapsharing/dmap-structure.c
@@ -34,541 +34,707 @@
( (gint32)(gchar)(ch3) << 24 ) ))
static const DMAPContentCodeDefinition cc_defs[] = {
- {DMAP_RAW, 0, "", "", DMAP_TYPE_STRING},
- {DMAP_CC_MDCL, MAKE_CONTENT_CODE('m','d','c','l'), "dmap.dictionary", "mdcl", DMAP_TYPE_CONTAINER},
- {DMAP_CC_MSTT, MAKE_CONTENT_CODE('m','s','t','t'), "dmap.status", "mstt", DMAP_TYPE_INT},
- {DMAP_CC_MIID, MAKE_CONTENT_CODE('m','i','i','d'), "dmap.itemid", "miid", DMAP_TYPE_INT},
- {DMAP_CC_MINM, MAKE_CONTENT_CODE('m','i','n','m'), "dmap.itemname", "minm", DMAP_TYPE_STRING},
- {DMAP_CC_MIKD, MAKE_CONTENT_CODE('m','i','k','d'), "dmap.itemkind", "mikd", DMAP_TYPE_BYTE},
- {DMAP_CC_MPER, MAKE_CONTENT_CODE('m','p','e','r'), "dmap.persistentid", "mper", DMAP_TYPE_INT64},
- {DMAP_CC_MCON, MAKE_CONTENT_CODE('m','c','o','n'), "dmap.container", "mcon", DMAP_TYPE_CONTAINER},
- {DMAP_CC_MCTI, MAKE_CONTENT_CODE('m','c','t','i'), "dmap.containeritemid", "mcti", DMAP_TYPE_INT},
- {DMAP_CC_MPCO, MAKE_CONTENT_CODE('m','p','c','o'), "dmap.parentcontainerid", "mpco", DMAP_TYPE_INT},
- {DMAP_CC_MSTS, MAKE_CONTENT_CODE('m','s','t','s'), "dmap.statusstring", "msts", DMAP_TYPE_STRING},
- {DMAP_CC_MIMC, MAKE_CONTENT_CODE('m','i','m','c'), "dmap.itemcount", "mimc", DMAP_TYPE_INT},
- {DMAP_CC_MCTC, MAKE_CONTENT_CODE('m','c','t','c'), "dmap.containercount", "mctc", DMAP_TYPE_INT},
- {DMAP_CC_MRCO, MAKE_CONTENT_CODE('m','r','c','o'), "dmap.returnedcount", "mrco", DMAP_TYPE_INT},
- {DMAP_CC_MTCO, MAKE_CONTENT_CODE('m','t','c','o'), "dmap.specifiedtotalcount", "mtco", DMAP_TYPE_INT},
- {DMAP_CC_MLCL, MAKE_CONTENT_CODE('m','l','c','l'), "dmap.listing", "mlcl", DMAP_TYPE_CONTAINER},
- {DMAP_CC_MLIT, MAKE_CONTENT_CODE('m','l','i','t'), "dmap.listingitem", "mlit", DMAP_TYPE_CONTAINER},
- {DMAP_CC_MBCL, MAKE_CONTENT_CODE('m','b','c','l'), "dmap.bag", "mbcl", DMAP_TYPE_CONTAINER},
- {DMAP_CC_MSRV, MAKE_CONTENT_CODE('m','s','r','v'), "dmap.serverinforesponse", "msrv", DMAP_TYPE_CONTAINER},
- {DMAP_CC_MSAU, MAKE_CONTENT_CODE('m','s','a','u'), "dmap.authenticationmethod", "msau", DMAP_TYPE_BYTE},
- {DMAP_CC_MSLR, MAKE_CONTENT_CODE('m','s','l','r'), "dmap.loginrequired", "mslr", DMAP_TYPE_BYTE},
- {DMAP_CC_MPRO, MAKE_CONTENT_CODE('m','p','r','o'), "dmap.protocolversion", "mpro", DMAP_TYPE_VERSION},
- {DMAP_CC_MSAL, MAKE_CONTENT_CODE('m','s','a','l'), "dmap.supportsautologout", "msal", DMAP_TYPE_BYTE},
- {DMAP_CC_MSUP, MAKE_CONTENT_CODE('m','s','u','p'), "dmap.supportsupdate", "msup", DMAP_TYPE_BYTE},
- {DMAP_CC_MSPI, MAKE_CONTENT_CODE('m','s','p','i'), "dmap.supportspersistenids", "mspi", DMAP_TYPE_BYTE},
- {DMAP_CC_MSEX, MAKE_CONTENT_CODE('m','s','e','x'), "dmap.supportsextensions", "msex", DMAP_TYPE_BYTE},
- {DMAP_CC_MSBR, MAKE_CONTENT_CODE('m','s','b','r'), "dmap.supportsbrowse", "msbr", DMAP_TYPE_BYTE},
- {DMAP_CC_MSQY, MAKE_CONTENT_CODE('m','s','q','y'), "dmap.supportsquery", "msqy", DMAP_TYPE_BYTE},
- {DMAP_CC_MSIX, MAKE_CONTENT_CODE('m','s','i','x'), "dmap.supportsindex", "msix", DMAP_TYPE_BYTE},
- {DMAP_CC_MSRS, MAKE_CONTENT_CODE('m','s','r','s'), "dmap.supportsresolve", "msrs", DMAP_TYPE_BYTE},
- {DMAP_CC_MSTM, MAKE_CONTENT_CODE('m','s','t','m'), "dmap.timeoutinterval", "mstm", DMAP_TYPE_INT},
- {DMAP_CC_MSDC, MAKE_CONTENT_CODE('m','s','d','c'), "dmap.databasescount", "msdc", DMAP_TYPE_INT},
- {DMAP_CC_MCCR, MAKE_CONTENT_CODE('m','c','c','r'), "dmap.contentcodesresponse", "mccr", DMAP_TYPE_CONTAINER},
- {DMAP_CC_MCNM, MAKE_CONTENT_CODE('m','c','n','m'), "dmap.contentcodesnumber", "mcnm", DMAP_TYPE_INT},
- {DMAP_CC_MCNA, MAKE_CONTENT_CODE('m','c','n','a'), "dmap.contentcodesname", "mcna", DMAP_TYPE_STRING},
- {DMAP_CC_MCTY, MAKE_CONTENT_CODE('m','c','t','y'), "dmap.contentcodestype", "mcty", DMAP_TYPE_SHORT},
- {DMAP_CC_MLOG, MAKE_CONTENT_CODE('m','l','o','g'), "dmap.loginresponse", "mlog", DMAP_TYPE_CONTAINER},
- {DMAP_CC_MLID, MAKE_CONTENT_CODE('m','l','i','d'), "dmap.sessionid", "mlid", DMAP_TYPE_INT},
- {DMAP_CC_MUPD, MAKE_CONTENT_CODE('m','u','p','d'), "dmap.updateresponse", "mupd", DMAP_TYPE_CONTAINER},
- {DMAP_CC_MUSR, MAKE_CONTENT_CODE('m','u','s','r'), "dmap.serverrevision", "musr", DMAP_TYPE_INT},
- {DMAP_CC_MUTY, MAKE_CONTENT_CODE('m','u','t','y'), "dmap.updatetype", "muty", DMAP_TYPE_BYTE},
- {DMAP_CC_MUDL, MAKE_CONTENT_CODE('m','u','d','l'), "dmap.deletedidlisting", "mudl", DMAP_TYPE_CONTAINER},
- {DMAP_CC_MSMA, MAKE_CONTENT_CODE('m','s','m','a'), "dmap.speakermachineaddress", "msma", DMAP_TYPE_INT},
- {DMAP_CC_FQUESCH, MAKE_CONTENT_CODE('f','?','c','h'), "dmap.haschildcontainers", "f?ch", DMAP_TYPE_BYTE},
-
- {DMAP_CC_APRO, MAKE_CONTENT_CODE('a','p','r','o'), "daap.protocolversion", "apro", DMAP_TYPE_VERSION},
- {DMAP_CC_AVDB, MAKE_CONTENT_CODE('a','v','d','b'), "daap.serverdatabases", "avdb", DMAP_TYPE_CONTAINER},
- {DMAP_CC_ABRO, MAKE_CONTENT_CODE('a','b','r','o'), "daap.databasebrowse", "abro", DMAP_TYPE_CONTAINER},
- {DMAP_CC_ABAL, MAKE_CONTENT_CODE('a','b','a','l'), "daap.browsealbumlisting", "abal", DMAP_TYPE_CONTAINER},
- {DMAP_CC_ABAR, MAKE_CONTENT_CODE('a','b','a','r'), "daap.browseartistlisting", "abar", DMAP_TYPE_CONTAINER},
- {DMAP_CC_ABCP, MAKE_CONTENT_CODE('a','b','c','p'), "daap.browsecomposerlisting", "abcp", DMAP_TYPE_CONTAINER},
- {DMAP_CC_ABGN, MAKE_CONTENT_CODE('a','b','g','n'), "daap.browsegenrelisting", "abgn", DMAP_TYPE_CONTAINER},
- {DMAP_CC_ADBS, MAKE_CONTENT_CODE('a','d','b','s'), "daap.returndatabasesongs", "adbs", DMAP_TYPE_CONTAINER},
- {DMAP_CC_ASAL, MAKE_CONTENT_CODE('a','s','a','l'), "daap.songalbum", "asal", DMAP_TYPE_STRING},
- {DMAP_CC_ASAI, MAKE_CONTENT_CODE('a','s','a','i'), "daap.songalbumid", "asai", DMAP_TYPE_INT},
- {DMAP_CC_ASAA, MAKE_CONTENT_CODE('a','s','a','a'), "daap.songalbumartist", "asaa", DMAP_TYPE_STRING},
- {DMAP_CC_ASAR, MAKE_CONTENT_CODE('a','s','a','r'), "daap.songartist", "asar", DMAP_TYPE_STRING},
- {DMAP_CC_ASBT, MAKE_CONTENT_CODE('a','s','b','t'), "daap.songsbeatsperminute", "asbt", DMAP_TYPE_SHORT},
- {DMAP_CC_ASBR, MAKE_CONTENT_CODE('a','s','b','r'), "daap.songbitrate", "asbr", DMAP_TYPE_SHORT},
- {DMAP_CC_ASCM, MAKE_CONTENT_CODE('a','s','c','m'), "daap.songcomment", "ascm", DMAP_TYPE_STRING},
- {DMAP_CC_ASCO, MAKE_CONTENT_CODE('a','s','c','o'), "daap.songcompliation", "asco", DMAP_TYPE_BYTE},
- {DMAP_CC_ASDA, MAKE_CONTENT_CODE('a','s','d','a'), "daap.songdateadded", "asda", DMAP_TYPE_DATE},
- {DMAP_CC_ASDM, MAKE_CONTENT_CODE('a','s','d','m'), "daap.songdatemodified", "asdm", DMAP_TYPE_DATE},
- {DMAP_CC_ASDC, MAKE_CONTENT_CODE('a','s','d','c'), "daap.songdisccount", "asdc", DMAP_TYPE_SHORT},
- {DMAP_CC_ASDN, MAKE_CONTENT_CODE('a','s','d','n'), "daap.songdiscnumber", "asdn", DMAP_TYPE_SHORT},
- {DMAP_CC_ASDB, MAKE_CONTENT_CODE('a','s','d','b'), "daap.songdisabled", "asdb", DMAP_TYPE_BYTE},
- {DMAP_CC_ASEQ, MAKE_CONTENT_CODE('a','s','e','q'), "daap.songeqpreset", "aseq", DMAP_TYPE_STRING},
- {DMAP_CC_ASFM, MAKE_CONTENT_CODE('a','s','f','m'), "daap.songformat", "asfm", DMAP_TYPE_STRING},
- {DMAP_CC_ASGN, MAKE_CONTENT_CODE('a','s','g','n'), "daap.songgenre", "asgn", DMAP_TYPE_STRING},
- {DMAP_CC_ASDT, MAKE_CONTENT_CODE('a','s','d','t'), "daap.songdescription", "asdt", DMAP_TYPE_STRING},
- {DMAP_CC_ASRV, MAKE_CONTENT_CODE('a','s','r','v'), "daap.songrelativevolume", "asrv", DMAP_TYPE_SIGNED_INT},
- {DMAP_CC_ASSR, MAKE_CONTENT_CODE('a','s','s','r'), "daap.songsamplerate", "assr", DMAP_TYPE_INT},
- {DMAP_CC_ASSZ, MAKE_CONTENT_CODE('a','s','s','z'), "daap.songsize", "assz", DMAP_TYPE_INT},
- {DMAP_CC_ASST, MAKE_CONTENT_CODE('a','s','s','t'), "daap.songstarttime", "asst", DMAP_TYPE_INT},
- {DMAP_CC_ASSP, MAKE_CONTENT_CODE('a','s','s','p'), "daap.songstoptime", "assp", DMAP_TYPE_INT},
- {DMAP_CC_ASTM, MAKE_CONTENT_CODE('a','s','t','m'), "daap.songtime", "astm", DMAP_TYPE_INT},
- {DMAP_CC_ASTC, MAKE_CONTENT_CODE('a','s','t','c'), "daap.songtrackcount", "astc", DMAP_TYPE_SHORT},
- {DMAP_CC_ASTN, MAKE_CONTENT_CODE('a','s','t','n'), "daap.songtracknumber", "astn", DMAP_TYPE_SHORT},
- {DMAP_CC_ASUR, MAKE_CONTENT_CODE('a','s','u','r'), "daap.songuserrating", "asur", DMAP_TYPE_BYTE},
- {DMAP_CC_ASYR, MAKE_CONTENT_CODE('a','s','y','r'), "daap.songyear", "asyr", DMAP_TYPE_SHORT},
- {DMAP_CC_ASDK, MAKE_CONTENT_CODE('a','s','d','k'), "daap.songdatakind", "asdk", DMAP_TYPE_BYTE},
- {DMAP_CC_ASUL, MAKE_CONTENT_CODE('a','s','u','l'), "daap.songdataurl", "asul", DMAP_TYPE_STRING},
- {DMAP_CC_ASSU, MAKE_CONTENT_CODE('a','s','s','u'), "daap.sortalbum", "assu", DMAP_TYPE_STRING},
- {DMAP_CC_ASSA, MAKE_CONTENT_CODE('a','s','s','a'), "daap.sortartist", "assa", DMAP_TYPE_STRING},
- {DMAP_CC_APLY, MAKE_CONTENT_CODE('a','p','l','y'), "daap.databaseplaylists", "aply", DMAP_TYPE_CONTAINER},
- {DMAP_CC_ABPL, MAKE_CONTENT_CODE('a','b','p','l'), "daap.baseplaylist", "abpl", DMAP_TYPE_BYTE},
- {DMAP_CC_APSO, MAKE_CONTENT_CODE('a','p','s','o'), "daap.playlistsongs", "apso", DMAP_TYPE_CONTAINER},
- {DMAP_CC_PRSV, MAKE_CONTENT_CODE('p','r','s','v'), "daap.resolve", "prsv", DMAP_TYPE_CONTAINER},
- {DMAP_CC_ARIF, MAKE_CONTENT_CODE('a','r','i','f'), "daap.resolveinfo", "arif", DMAP_TYPE_CONTAINER},
- {DMAP_CC_MSAS, MAKE_CONTENT_CODE('m','s','a','s'), "daap.authentication.schemes", "msas", DMAP_TYPE_BYTE},
- {DMAP_CC_AGRP, MAKE_CONTENT_CODE('a','g','r','p'), "daap.songgrouping", "agrp", DMAP_TYPE_STRING},
- {DMAP_CC_AGAL, MAKE_CONTENT_CODE('a','g','a','l'), "daap.albumgrouping", "agal", DMAP_TYPE_CONTAINER},
- {DMAP_CC_ASCP, MAKE_CONTENT_CODE('a','s','c','p'), "daap.songcomposer", "ascp", DMAP_TYPE_STRING},
- {DMAP_CC_PPRO, MAKE_CONTENT_CODE('p','p','r','o'), "dpap.protocolversion", "ppro", DMAP_TYPE_VERSION},
- {DMAP_CC_PASP, MAKE_CONTENT_CODE('p','a','s','p'), "dpap.aspectratio", "pasp", DMAP_TYPE_STRING},
- {DMAP_CC_PFDT, MAKE_CONTENT_CODE('p','f','d','t'), "dpap.filedata", "pfdt", DMAP_TYPE_POINTER},
- {DMAP_CC_PICD, MAKE_CONTENT_CODE('p','i','c','d'), "dpap.creationdate", "picd", DMAP_TYPE_INT},
- {DMAP_CC_PIMF, MAKE_CONTENT_CODE('p','i','m','f'), "dpap.imagefilename", "pimf", DMAP_TYPE_STRING},
- {DMAP_CC_PFMT, MAKE_CONTENT_CODE('p','f','m','t'), "dpap.imageformat", "pfmt", DMAP_TYPE_STRING},
- {DMAP_CC_PIFS, MAKE_CONTENT_CODE('p','i','f','s'), "dpap.imagefilesize", "pifs", DMAP_TYPE_INT},
- {DMAP_CC_PLSZ, MAKE_CONTENT_CODE('p','l','s','z'), "dpap.imagelargefilesize", "plsz", DMAP_TYPE_INT},
- {DMAP_CC_PHGT, MAKE_CONTENT_CODE('p','h','g','t'), "dpap.imagepixelheight", "phgt", DMAP_TYPE_INT},
- {DMAP_CC_PWTH, MAKE_CONTENT_CODE('p','w','t','h'), "dpap.imagepixelwidth", "pwth", DMAP_TYPE_INT},
- {DMAP_CC_PRAT, MAKE_CONTENT_CODE('p','r','a','t'), "dpap.imagerating", "prat", DMAP_TYPE_INT},
- {DMAP_CC_PCMT, MAKE_CONTENT_CODE('p','c','m','t'), "dpap.imagecomments", "pcmt", DMAP_TYPE_STRING},
- {DMAP_CC_PRET, MAKE_CONTENT_CODE('p','r','e','t'), "dpap.pret", "pret", DMAP_TYPE_STRING},
- {DMAP_CC_AESV, MAKE_CONTENT_CODE('a','e','S','V'), "com.apple.itunes.music-sharing-version", "aesv", DMAP_TYPE_INT},
- {DMAP_CC_AEHV, MAKE_CONTENT_CODE('a','e','H','V'), "com.apple.itunes.has-video", "aeHV", DMAP_TYPE_BYTE},
- {DMAP_CC_AESP, MAKE_CONTENT_CODE('a','e','S','P'), "com.apple.itunes.smart-playlist", "aeSP", DMAP_TYPE_BYTE},
- {DMAP_CC_AEPP, MAKE_CONTENT_CODE('a','e','P','P'), "com.apple.itunes.is-podcast-playlist", "aePP", DMAP_TYPE_BYTE},
- {DMAP_CC_AEPS, MAKE_CONTENT_CODE('a','e','P','S'), "com.apple.itunes.special-playlist", "aePS", DMAP_TYPE_BYTE},
- {DMAP_CC_AESG, MAKE_CONTENT_CODE('a','e','S','G'), "com.apple.itunes.saved-genius", "aeSG", DMAP_TYPE_BYTE},
- {DMAP_CC_AEMK, MAKE_CONTENT_CODE('a','e','M','K'), "com.apple.itunes.mediakind", "aeMK", DMAP_TYPE_BYTE},
- {DMAP_CC_AEFP, MAKE_CONTENT_CODE('a','e','F','P'), "com.apple.itunes.req-fplay", "aeFP", DMAP_TYPE_BYTE},
-
- /* DACP */
- {DMAP_CC_CMPA, MAKE_CONTENT_CODE('c','m','p','a'), "dacp.contentcontainer", "cmpa", DMAP_TYPE_CONTAINER},
- {DMAP_CC_CMNM, MAKE_CONTENT_CODE('c','m','n','m'), "dacp.contentname", "cmnm", DMAP_TYPE_STRING},
- {DMAP_CC_CMTY, MAKE_CONTENT_CODE('c','m','t','y'), "dacp.contentvalue", "cmty", DMAP_TYPE_STRING},
- {DMAP_CC_CMPG, MAKE_CONTENT_CODE('c','m','p','g'), "dacp.passguid", "cmpy", DMAP_TYPE_INT64},
-
- {DMAP_CC_CACI, MAKE_CONTENT_CODE('c','a','c','i'), "dacp.controlint", "caci", DMAP_TYPE_CONTAINER},
- {DMAP_CC_CAPS, MAKE_CONTENT_CODE('c','a','p','s'), "dacp.playstatus", "caci", DMAP_TYPE_BYTE},
- {DMAP_CC_CASH, MAKE_CONTENT_CODE('c','a','s','h'), "dacp.shufflestate", "caci", DMAP_TYPE_BYTE},
- {DMAP_CC_CARP, MAKE_CONTENT_CODE('c','a','r','p'), "dacp.repeatstate", "caci", DMAP_TYPE_BYTE},
- {DMAP_CC_CAAS, MAKE_CONTENT_CODE('c','a','a','s'), "dacp.albumshuffle", "caas", DMAP_TYPE_INT},
- {DMAP_CC_CAAR, MAKE_CONTENT_CODE('c','a','a','r'), "dacp.albumrepeat", "caci", DMAP_TYPE_INT},
- {DMAP_CC_CAIA, MAKE_CONTENT_CODE('c','a','i','a'), "dacp.isavailiable", "caia", DMAP_TYPE_BYTE},
- {DMAP_CC_CANP, MAKE_CONTENT_CODE('c','a','n','p'), "dacp.nowplaying", "canp", DMAP_TYPE_INT64},
- {DMAP_CC_CANN, MAKE_CONTENT_CODE('c','a','n','n'), "dacp.nowplayingtrack", "cann", DMAP_TYPE_STRING},
- {DMAP_CC_CANA, MAKE_CONTENT_CODE('c','a','n','a'), "dacp.nowplayingartist", "cana", DMAP_TYPE_STRING},
- {DMAP_CC_CANL, MAKE_CONTENT_CODE('c','a','n','l'), "dacp.nowplayingalbum", "canl", DMAP_TYPE_STRING},
- {DMAP_CC_CANG, MAKE_CONTENT_CODE('c','a','n','g'), "dacp.nowplayinggenre", "cang", DMAP_TYPE_STRING},
- {DMAP_CC_CANT, MAKE_CONTENT_CODE('c','a','n','t'), "dacp.remainingtime", "cant", DMAP_TYPE_INT},
- {DMAP_CC_CASP, MAKE_CONTENT_CODE('c','a','s','p'), "dacp.speakers", "casp", DMAP_TYPE_CONTAINER},
- {DMAP_CC_CASS, MAKE_CONTENT_CODE('c','a','s','s'), "dacp.ss", "cass", DMAP_TYPE_BYTE},
- {DMAP_CC_CAST, MAKE_CONTENT_CODE('c','a','s','t'), "dacp.tracklength", "cast", DMAP_TYPE_INT},
- {DMAP_CC_CASU, MAKE_CONTENT_CODE('c','a','s','u'), "dacp.su", "casu", DMAP_TYPE_BYTE},
- {DMAP_CC_CASG, MAKE_CONTENT_CODE('c','a','s','g'), "dacp.sg", "caSG", DMAP_TYPE_BYTE},
- {DMAP_CC_CACR, MAKE_CONTENT_CODE('c','a','c','r'), "dacp.cacr", "cacr", DMAP_TYPE_CONTAINER},
-
- {DMAP_CC_CMCP, MAKE_CONTENT_CODE('c','m','c','p'), "dmcp.controlprompt", "cmcp", DMAP_TYPE_CONTAINER},
- {DMAP_CC_CMGT, MAKE_CONTENT_CODE('c','m','g','t'), "dmcp.getpropertyresponse", "cmgt", DMAP_TYPE_CONTAINER},
- {DMAP_CC_CMIK, MAKE_CONTENT_CODE('c','m','i','k'), "dmcp.ik", "cmik", DMAP_TYPE_BYTE},
- {DMAP_CC_CMSP, MAKE_CONTENT_CODE('c','m','s','p'), "dmcp.ik", "cmsp", DMAP_TYPE_BYTE},
- {DMAP_CC_CMST, MAKE_CONTENT_CODE('c','m','s','t'), "dmcp.status", "cmst", DMAP_TYPE_CONTAINER},
- {DMAP_CC_CMSV, MAKE_CONTENT_CODE('c','m','s','v'), "dmcp.sv", "cmsv", DMAP_TYPE_BYTE},
- {DMAP_CC_CMSR, MAKE_CONTENT_CODE('c','m','s','r'), "dmcp.mediarevision", "cmsr", DMAP_TYPE_INT},
- {DMAP_CC_CMMK, MAKE_CONTENT_CODE('c','m','m','k'), "dmcp.mediakind", "cmmk", DMAP_TYPE_INT},
- {DMAP_CC_CMVO, MAKE_CONTENT_CODE('c','m','v','o'), "dmcp.volume", "cmvo", DMAP_TYPE_INT},
-
+ {DMAP_RAW, 0, "", "", DMAP_TYPE_STRING},
+ {DMAP_CC_MDCL, MAKE_CONTENT_CODE ('m', 'd', 'c', 'l'),
+ "dmap.dictionary", "mdcl", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_MSTT, MAKE_CONTENT_CODE ('m', 's', 't', 't'), "dmap.status",
+ "mstt", DMAP_TYPE_INT},
+ {DMAP_CC_MIID, MAKE_CONTENT_CODE ('m', 'i', 'i', 'd'), "dmap.itemid",
+ "miid", DMAP_TYPE_INT},
+ {DMAP_CC_MINM, MAKE_CONTENT_CODE ('m', 'i', 'n', 'm'),
+ "dmap.itemname", "minm", DMAP_TYPE_STRING},
+ {DMAP_CC_MIKD, MAKE_CONTENT_CODE ('m', 'i', 'k', 'd'),
+ "dmap.itemkind", "mikd", DMAP_TYPE_BYTE},
+ {DMAP_CC_MPER, MAKE_CONTENT_CODE ('m', 'p', 'e', 'r'),
+ "dmap.persistentid", "mper", DMAP_TYPE_INT64},
+ {DMAP_CC_MCON, MAKE_CONTENT_CODE ('m', 'c', 'o', 'n'),
+ "dmap.container", "mcon", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_MCTI, MAKE_CONTENT_CODE ('m', 'c', 't', 'i'),
+ "dmap.containeritemid", "mcti", DMAP_TYPE_INT},
+ {DMAP_CC_MPCO, MAKE_CONTENT_CODE ('m', 'p', 'c', 'o'),
+ "dmap.parentcontainerid", "mpco", DMAP_TYPE_INT},
+ {DMAP_CC_MSTS, MAKE_CONTENT_CODE ('m', 's', 't', 's'),
+ "dmap.statusstring", "msts", DMAP_TYPE_STRING},
+ {DMAP_CC_MIMC, MAKE_CONTENT_CODE ('m', 'i', 'm', 'c'),
+ "dmap.itemcount", "mimc", DMAP_TYPE_INT},
+ {DMAP_CC_MCTC, MAKE_CONTENT_CODE ('m', 'c', 't', 'c'),
+ "dmap.containercount", "mctc", DMAP_TYPE_INT},
+ {DMAP_CC_MRCO, MAKE_CONTENT_CODE ('m', 'r', 'c', 'o'),
+ "dmap.returnedcount", "mrco", DMAP_TYPE_INT},
+ {DMAP_CC_MTCO, MAKE_CONTENT_CODE ('m', 't', 'c', 'o'),
+ "dmap.specifiedtotalcount", "mtco", DMAP_TYPE_INT},
+ {DMAP_CC_MLCL, MAKE_CONTENT_CODE ('m', 'l', 'c', 'l'), "dmap.listing",
+ "mlcl", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_MLIT, MAKE_CONTENT_CODE ('m', 'l', 'i', 't'),
+ "dmap.listingitem", "mlit", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_MBCL, MAKE_CONTENT_CODE ('m', 'b', 'c', 'l'), "dmap.bag",
+ "mbcl", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_MSRV, MAKE_CONTENT_CODE ('m', 's', 'r', 'v'),
+ "dmap.serverinforesponse", "msrv", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_MSAU, MAKE_CONTENT_CODE ('m', 's', 'a', 'u'),
+ "dmap.authenticationmethod", "msau", DMAP_TYPE_BYTE},
+ {DMAP_CC_MSLR, MAKE_CONTENT_CODE ('m', 's', 'l', 'r'),
+ "dmap.loginrequired", "mslr", DMAP_TYPE_BYTE},
+ {DMAP_CC_MPRO, MAKE_CONTENT_CODE ('m', 'p', 'r', 'o'),
+ "dmap.protocolversion", "mpro", DMAP_TYPE_VERSION},
+ {DMAP_CC_MSAL, MAKE_CONTENT_CODE ('m', 's', 'a', 'l'),
+ "dmap.supportsautologout", "msal", DMAP_TYPE_BYTE},
+ {DMAP_CC_MSUP, MAKE_CONTENT_CODE ('m', 's', 'u', 'p'),
+ "dmap.supportsupdate", "msup", DMAP_TYPE_BYTE},
+ {DMAP_CC_MSPI, MAKE_CONTENT_CODE ('m', 's', 'p', 'i'),
+ "dmap.supportspersistenids", "mspi", DMAP_TYPE_BYTE},
+ {DMAP_CC_MSEX, MAKE_CONTENT_CODE ('m', 's', 'e', 'x'),
+ "dmap.supportsextensions", "msex", DMAP_TYPE_BYTE},
+ {DMAP_CC_MSBR, MAKE_CONTENT_CODE ('m', 's', 'b', 'r'),
+ "dmap.supportsbrowse", "msbr", DMAP_TYPE_BYTE},
+ {DMAP_CC_MSQY, MAKE_CONTENT_CODE ('m', 's', 'q', 'y'),
+ "dmap.supportsquery", "msqy", DMAP_TYPE_BYTE},
+ {DMAP_CC_MSIX, MAKE_CONTENT_CODE ('m', 's', 'i', 'x'),
+ "dmap.supportsindex", "msix", DMAP_TYPE_BYTE},
+ {DMAP_CC_MSRS, MAKE_CONTENT_CODE ('m', 's', 'r', 's'),
+ "dmap.supportsresolve", "msrs", DMAP_TYPE_BYTE},
+ {DMAP_CC_MSTM, MAKE_CONTENT_CODE ('m', 's', 't', 'm'),
+ "dmap.timeoutinterval", "mstm", DMAP_TYPE_INT},
+ {DMAP_CC_MSDC, MAKE_CONTENT_CODE ('m', 's', 'd', 'c'),
+ "dmap.databasescount", "msdc", DMAP_TYPE_INT},
+ {DMAP_CC_MCCR, MAKE_CONTENT_CODE ('m', 'c', 'c', 'r'),
+ "dmap.contentcodesresponse", "mccr", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_MCNM, MAKE_CONTENT_CODE ('m', 'c', 'n', 'm'),
+ "dmap.contentcodesnumber", "mcnm", DMAP_TYPE_INT},
+ {DMAP_CC_MCNA, MAKE_CONTENT_CODE ('m', 'c', 'n', 'a'),
+ "dmap.contentcodesname", "mcna", DMAP_TYPE_STRING},
+ {DMAP_CC_MCTY, MAKE_CONTENT_CODE ('m', 'c', 't', 'y'),
+ "dmap.contentcodestype", "mcty", DMAP_TYPE_SHORT},
+ {DMAP_CC_MLOG, MAKE_CONTENT_CODE ('m', 'l', 'o', 'g'),
+ "dmap.loginresponse", "mlog", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_MLID, MAKE_CONTENT_CODE ('m', 'l', 'i', 'd'),
+ "dmap.sessionid", "mlid", DMAP_TYPE_INT},
+ {DMAP_CC_MUPD, MAKE_CONTENT_CODE ('m', 'u', 'p', 'd'),
+ "dmap.updateresponse", "mupd", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_MUSR, MAKE_CONTENT_CODE ('m', 'u', 's', 'r'),
+ "dmap.serverrevision", "musr", DMAP_TYPE_INT},
+ {DMAP_CC_MUTY, MAKE_CONTENT_CODE ('m', 'u', 't', 'y'),
+ "dmap.updatetype", "muty", DMAP_TYPE_BYTE},
+ {DMAP_CC_MUDL, MAKE_CONTENT_CODE ('m', 'u', 'd', 'l'),
+ "dmap.deletedidlisting", "mudl", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_MSMA, MAKE_CONTENT_CODE ('m', 's', 'm', 'a'),
+ "dmap.speakermachineaddress", "msma", DMAP_TYPE_INT},
+ {DMAP_CC_FQUESCH, MAKE_CONTENT_CODE ('f', '?', 'c', 'h'),
+ "dmap.haschildcontainers", "f?ch", DMAP_TYPE_BYTE},
+
+ {DMAP_CC_APRO, MAKE_CONTENT_CODE ('a', 'p', 'r', 'o'),
+ "daap.protocolversion", "apro", DMAP_TYPE_VERSION},
+ {DMAP_CC_AVDB, MAKE_CONTENT_CODE ('a', 'v', 'd', 'b'),
+ "daap.serverdatabases", "avdb", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_ABRO, MAKE_CONTENT_CODE ('a', 'b', 'r', 'o'),
+ "daap.databasebrowse", "abro", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_ABAL, MAKE_CONTENT_CODE ('a', 'b', 'a', 'l'),
+ "daap.browsealbumlisting", "abal", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_ABAR, MAKE_CONTENT_CODE ('a', 'b', 'a', 'r'),
+ "daap.browseartistlisting", "abar", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_ABCP, MAKE_CONTENT_CODE ('a', 'b', 'c', 'p'),
+ "daap.browsecomposerlisting", "abcp", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_ABGN, MAKE_CONTENT_CODE ('a', 'b', 'g', 'n'),
+ "daap.browsegenrelisting", "abgn", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_ADBS, MAKE_CONTENT_CODE ('a', 'd', 'b', 's'),
+ "daap.returndatabasesongs", "adbs", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_ASAL, MAKE_CONTENT_CODE ('a', 's', 'a', 'l'),
+ "daap.songalbum", "asal", DMAP_TYPE_STRING},
+ {DMAP_CC_ASAI, MAKE_CONTENT_CODE ('a', 's', 'a', 'i'),
+ "daap.songalbumid", "asai", DMAP_TYPE_INT},
+ {DMAP_CC_ASAA, MAKE_CONTENT_CODE ('a', 's', 'a', 'a'),
+ "daap.songalbumartist", "asaa", DMAP_TYPE_STRING},
+ {DMAP_CC_ASAR, MAKE_CONTENT_CODE ('a', 's', 'a', 'r'),
+ "daap.songartist", "asar", DMAP_TYPE_STRING},
+ {DMAP_CC_ASBT, MAKE_CONTENT_CODE ('a', 's', 'b', 't'),
+ "daap.songsbeatsperminute", "asbt", DMAP_TYPE_SHORT},
+ {DMAP_CC_ASBR, MAKE_CONTENT_CODE ('a', 's', 'b', 'r'),
+ "daap.songbitrate", "asbr", DMAP_TYPE_SHORT},
+ {DMAP_CC_ASCM, MAKE_CONTENT_CODE ('a', 's', 'c', 'm'),
+ "daap.songcomment", "ascm", DMAP_TYPE_STRING},
+ {DMAP_CC_ASCO, MAKE_CONTENT_CODE ('a', 's', 'c', 'o'),
+ "daap.songcompliation", "asco", DMAP_TYPE_BYTE},
+ {DMAP_CC_ASDA, MAKE_CONTENT_CODE ('a', 's', 'd', 'a'),
+ "daap.songdateadded", "asda", DMAP_TYPE_DATE},
+ {DMAP_CC_ASDM, MAKE_CONTENT_CODE ('a', 's', 'd', 'm'),
+ "daap.songdatemodified", "asdm", DMAP_TYPE_DATE},
+ {DMAP_CC_ASDC, MAKE_CONTENT_CODE ('a', 's', 'd', 'c'),
+ "daap.songdisccount", "asdc", DMAP_TYPE_SHORT},
+ {DMAP_CC_ASDN, MAKE_CONTENT_CODE ('a', 's', 'd', 'n'),
+ "daap.songdiscnumber", "asdn", DMAP_TYPE_SHORT},
+ {DMAP_CC_ASDB, MAKE_CONTENT_CODE ('a', 's', 'd', 'b'),
+ "daap.songdisabled", "asdb", DMAP_TYPE_BYTE},
+ {DMAP_CC_ASEQ, MAKE_CONTENT_CODE ('a', 's', 'e', 'q'),
+ "daap.songeqpreset", "aseq", DMAP_TYPE_STRING},
+ {DMAP_CC_ASFM, MAKE_CONTENT_CODE ('a', 's', 'f', 'm'),
+ "daap.songformat", "asfm", DMAP_TYPE_STRING},
+ {DMAP_CC_ASGN, MAKE_CONTENT_CODE ('a', 's', 'g', 'n'),
+ "daap.songgenre", "asgn", DMAP_TYPE_STRING},
+ {DMAP_CC_ASDT, MAKE_CONTENT_CODE ('a', 's', 'd', 't'),
+ "daap.songdescription", "asdt", DMAP_TYPE_STRING},
+ {DMAP_CC_ASRV, MAKE_CONTENT_CODE ('a', 's', 'r', 'v'),
+ "daap.songrelativevolume", "asrv", DMAP_TYPE_SIGNED_INT},
+ {DMAP_CC_ASSR, MAKE_CONTENT_CODE ('a', 's', 's', 'r'),
+ "daap.songsamplerate", "assr", DMAP_TYPE_INT},
+ {DMAP_CC_ASSZ, MAKE_CONTENT_CODE ('a', 's', 's', 'z'),
+ "daap.songsize", "assz", DMAP_TYPE_INT},
+ {DMAP_CC_ASST, MAKE_CONTENT_CODE ('a', 's', 's', 't'),
+ "daap.songstarttime", "asst", DMAP_TYPE_INT},
+ {DMAP_CC_ASSP, MAKE_CONTENT_CODE ('a', 's', 's', 'p'),
+ "daap.songstoptime", "assp", DMAP_TYPE_INT},
+ {DMAP_CC_ASTM, MAKE_CONTENT_CODE ('a', 's', 't', 'm'),
+ "daap.songtime", "astm", DMAP_TYPE_INT},
+ {DMAP_CC_ASTC, MAKE_CONTENT_CODE ('a', 's', 't', 'c'),
+ "daap.songtrackcount", "astc", DMAP_TYPE_SHORT},
+ {DMAP_CC_ASTN, MAKE_CONTENT_CODE ('a', 's', 't', 'n'),
+ "daap.songtracknumber", "astn", DMAP_TYPE_SHORT},
+ {DMAP_CC_ASUR, MAKE_CONTENT_CODE ('a', 's', 'u', 'r'),
+ "daap.songuserrating", "asur", DMAP_TYPE_BYTE},
+ {DMAP_CC_ASYR, MAKE_CONTENT_CODE ('a', 's', 'y', 'r'),
+ "daap.songyear", "asyr", DMAP_TYPE_SHORT},
+ {DMAP_CC_ASDK, MAKE_CONTENT_CODE ('a', 's', 'd', 'k'),
+ "daap.songdatakind", "asdk", DMAP_TYPE_BYTE},
+ {DMAP_CC_ASUL, MAKE_CONTENT_CODE ('a', 's', 'u', 'l'),
+ "daap.songdataurl", "asul", DMAP_TYPE_STRING},
+ {DMAP_CC_ASSU, MAKE_CONTENT_CODE ('a', 's', 's', 'u'),
+ "daap.sortalbum", "assu", DMAP_TYPE_STRING},
+ {DMAP_CC_ASSA, MAKE_CONTENT_CODE ('a', 's', 's', 'a'),
+ "daap.sortartist", "assa", DMAP_TYPE_STRING},
+ {DMAP_CC_APLY, MAKE_CONTENT_CODE ('a', 'p', 'l', 'y'),
+ "daap.databaseplaylists", "aply", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_ABPL, MAKE_CONTENT_CODE ('a', 'b', 'p', 'l'),
+ "daap.baseplaylist", "abpl", DMAP_TYPE_BYTE},
+ {DMAP_CC_APSO, MAKE_CONTENT_CODE ('a', 'p', 's', 'o'),
+ "daap.playlistsongs", "apso", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_PRSV, MAKE_CONTENT_CODE ('p', 'r', 's', 'v'), "daap.resolve",
+ "prsv", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_ARIF, MAKE_CONTENT_CODE ('a', 'r', 'i', 'f'),
+ "daap.resolveinfo", "arif", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_MSAS, MAKE_CONTENT_CODE ('m', 's', 'a', 's'),
+ "daap.authentication.schemes", "msas", DMAP_TYPE_BYTE},
+ {DMAP_CC_AGRP, MAKE_CONTENT_CODE ('a', 'g', 'r', 'p'),
+ "daap.songgrouping", "agrp", DMAP_TYPE_STRING},
+ {DMAP_CC_AGAL, MAKE_CONTENT_CODE ('a', 'g', 'a', 'l'),
+ "daap.albumgrouping", "agal", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_ASCP, MAKE_CONTENT_CODE ('a', 's', 'c', 'p'),
+ "daap.songcomposer", "ascp", DMAP_TYPE_STRING},
+ {DMAP_CC_PPRO, MAKE_CONTENT_CODE ('p', 'p', 'r', 'o'),
+ "dpap.protocolversion", "ppro", DMAP_TYPE_VERSION},
+ {DMAP_CC_PASP, MAKE_CONTENT_CODE ('p', 'a', 's', 'p'),
+ "dpap.aspectratio", "pasp", DMAP_TYPE_STRING},
+ {DMAP_CC_PFDT, MAKE_CONTENT_CODE ('p', 'f', 'd', 't'),
+ "dpap.filedata", "pfdt", DMAP_TYPE_POINTER},
+ {DMAP_CC_PICD, MAKE_CONTENT_CODE ('p', 'i', 'c', 'd'),
+ "dpap.creationdate", "picd", DMAP_TYPE_INT},
+ {DMAP_CC_PIMF, MAKE_CONTENT_CODE ('p', 'i', 'm', 'f'),
+ "dpap.imagefilename", "pimf", DMAP_TYPE_STRING},
+ {DMAP_CC_PFMT, MAKE_CONTENT_CODE ('p', 'f', 'm', 't'),
+ "dpap.imageformat", "pfmt", DMAP_TYPE_STRING},
+ {DMAP_CC_PIFS, MAKE_CONTENT_CODE ('p', 'i', 'f', 's'),
+ "dpap.imagefilesize", "pifs", DMAP_TYPE_INT},
+ {DMAP_CC_PLSZ, MAKE_CONTENT_CODE ('p', 'l', 's', 'z'),
+ "dpap.imagelargefilesize", "plsz", DMAP_TYPE_INT},
+ {DMAP_CC_PHGT, MAKE_CONTENT_CODE ('p', 'h', 'g', 't'),
+ "dpap.imagepixelheight", "phgt", DMAP_TYPE_INT},
+ {DMAP_CC_PWTH, MAKE_CONTENT_CODE ('p', 'w', 't', 'h'),
+ "dpap.imagepixelwidth", "pwth", DMAP_TYPE_INT},
+ {DMAP_CC_PRAT, MAKE_CONTENT_CODE ('p', 'r', 'a', 't'),
+ "dpap.imagerating", "prat", DMAP_TYPE_INT},
+ {DMAP_CC_PCMT, MAKE_CONTENT_CODE ('p', 'c', 'm', 't'),
+ "dpap.imagecomments", "pcmt", DMAP_TYPE_STRING},
+ {DMAP_CC_PRET, MAKE_CONTENT_CODE ('p', 'r', 'e', 't'), "dpap.pret",
+ "pret", DMAP_TYPE_STRING},
+ {DMAP_CC_AESV, MAKE_CONTENT_CODE ('a', 'e', 'S', 'V'),
+ "com.apple.itunes.music-sharing-version", "aesv", DMAP_TYPE_INT},
+ {DMAP_CC_AEHV, MAKE_CONTENT_CODE ('a', 'e', 'H', 'V'),
+ "com.apple.itunes.has-video", "aeHV", DMAP_TYPE_BYTE},
+ {DMAP_CC_AESP, MAKE_CONTENT_CODE ('a', 'e', 'S', 'P'),
+ "com.apple.itunes.smart-playlist", "aeSP", DMAP_TYPE_BYTE},
+ {DMAP_CC_AEPP, MAKE_CONTENT_CODE ('a', 'e', 'P', 'P'),
+ "com.apple.itunes.is-podcast-playlist", "aePP", DMAP_TYPE_BYTE},
+ {DMAP_CC_AEPS, MAKE_CONTENT_CODE ('a', 'e', 'P', 'S'),
+ "com.apple.itunes.special-playlist", "aePS", DMAP_TYPE_BYTE},
+ {DMAP_CC_AESG, MAKE_CONTENT_CODE ('a', 'e', 'S', 'G'),
+ "com.apple.itunes.saved-genius", "aeSG", DMAP_TYPE_BYTE},
+ {DMAP_CC_AEMK, MAKE_CONTENT_CODE ('a', 'e', 'M', 'K'),
+ "com.apple.itunes.mediakind", "aeMK", DMAP_TYPE_BYTE},
+ {DMAP_CC_AEFP, MAKE_CONTENT_CODE ('a', 'e', 'F', 'P'),
+ "com.apple.itunes.req-fplay", "aeFP", DMAP_TYPE_BYTE},
+
+ /* DACP */
+ {DMAP_CC_CMPA, MAKE_CONTENT_CODE ('c', 'm', 'p', 'a'),
+ "dacp.contentcontainer", "cmpa", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_CMNM, MAKE_CONTENT_CODE ('c', 'm', 'n', 'm'),
+ "dacp.contentname", "cmnm", DMAP_TYPE_STRING},
+ {DMAP_CC_CMTY, MAKE_CONTENT_CODE ('c', 'm', 't', 'y'),
+ "dacp.contentvalue", "cmty", DMAP_TYPE_STRING},
+ {DMAP_CC_CMPG, MAKE_CONTENT_CODE ('c', 'm', 'p', 'g'),
+ "dacp.passguid", "cmpy", DMAP_TYPE_INT64},
+
+ {DMAP_CC_CACI, MAKE_CONTENT_CODE ('c', 'a', 'c', 'i'),
+ "dacp.controlint", "caci", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_CAPS, MAKE_CONTENT_CODE ('c', 'a', 'p', 's'),
+ "dacp.playstatus", "caci", DMAP_TYPE_BYTE},
+ {DMAP_CC_CASH, MAKE_CONTENT_CODE ('c', 'a', 's', 'h'),
+ "dacp.shufflestate", "caci", DMAP_TYPE_BYTE},
+ {DMAP_CC_CARP, MAKE_CONTENT_CODE ('c', 'a', 'r', 'p'),
+ "dacp.repeatstate", "caci", DMAP_TYPE_BYTE},
+ {DMAP_CC_CAAS, MAKE_CONTENT_CODE ('c', 'a', 'a', 's'),
+ "dacp.albumshuffle", "caas", DMAP_TYPE_INT},
+ {DMAP_CC_CAAR, MAKE_CONTENT_CODE ('c', 'a', 'a', 'r'),
+ "dacp.albumrepeat", "caci", DMAP_TYPE_INT},
+ {DMAP_CC_CAIA, MAKE_CONTENT_CODE ('c', 'a', 'i', 'a'),
+ "dacp.isavailiable", "caia", DMAP_TYPE_BYTE},
+ {DMAP_CC_CANP, MAKE_CONTENT_CODE ('c', 'a', 'n', 'p'),
+ "dacp.nowplaying", "canp", DMAP_TYPE_INT64},
+ {DMAP_CC_CANN, MAKE_CONTENT_CODE ('c', 'a', 'n', 'n'),
+ "dacp.nowplayingtrack", "cann", DMAP_TYPE_STRING},
+ {DMAP_CC_CANA, MAKE_CONTENT_CODE ('c', 'a', 'n', 'a'),
+ "dacp.nowplayingartist", "cana", DMAP_TYPE_STRING},
+ {DMAP_CC_CANL, MAKE_CONTENT_CODE ('c', 'a', 'n', 'l'),
+ "dacp.nowplayingalbum", "canl", DMAP_TYPE_STRING},
+ {DMAP_CC_CANG, MAKE_CONTENT_CODE ('c', 'a', 'n', 'g'),
+ "dacp.nowplayinggenre", "cang", DMAP_TYPE_STRING},
+ {DMAP_CC_CANT, MAKE_CONTENT_CODE ('c', 'a', 'n', 't'),
+ "dacp.remainingtime", "cant", DMAP_TYPE_INT},
+ {DMAP_CC_CASP, MAKE_CONTENT_CODE ('c', 'a', 's', 'p'),
+ "dacp.speakers", "casp", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_CASS, MAKE_CONTENT_CODE ('c', 'a', 's', 's'), "dacp.ss",
+ "cass", DMAP_TYPE_BYTE},
+ {DMAP_CC_CAST, MAKE_CONTENT_CODE ('c', 'a', 's', 't'),
+ "dacp.tracklength", "cast", DMAP_TYPE_INT},
+ {DMAP_CC_CASU, MAKE_CONTENT_CODE ('c', 'a', 's', 'u'), "dacp.su",
+ "casu", DMAP_TYPE_BYTE},
+ {DMAP_CC_CASG, MAKE_CONTENT_CODE ('c', 'a', 's', 'g'), "dacp.sg",
+ "caSG", DMAP_TYPE_BYTE},
+ {DMAP_CC_CACR, MAKE_CONTENT_CODE ('c', 'a', 'c', 'r'), "dacp.cacr",
+ "cacr", DMAP_TYPE_CONTAINER},
+
+ {DMAP_CC_CMCP, MAKE_CONTENT_CODE ('c', 'm', 'c', 'p'),
+ "dmcp.controlprompt", "cmcp", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_CMGT, MAKE_CONTENT_CODE ('c', 'm', 'g', 't'),
+ "dmcp.getpropertyresponse", "cmgt", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_CMIK, MAKE_CONTENT_CODE ('c', 'm', 'i', 'k'), "dmcp.ik",
+ "cmik", DMAP_TYPE_BYTE},
+ {DMAP_CC_CMSP, MAKE_CONTENT_CODE ('c', 'm', 's', 'p'), "dmcp.ik",
+ "cmsp", DMAP_TYPE_BYTE},
+ {DMAP_CC_CMST, MAKE_CONTENT_CODE ('c', 'm', 's', 't'), "dmcp.status",
+ "cmst", DMAP_TYPE_CONTAINER},
+ {DMAP_CC_CMSV, MAKE_CONTENT_CODE ('c', 'm', 's', 'v'), "dmcp.sv",
+ "cmsv", DMAP_TYPE_BYTE},
+ {DMAP_CC_CMSR, MAKE_CONTENT_CODE ('c', 'm', 's', 'r'),
+ "dmcp.mediarevision", "cmsr", DMAP_TYPE_INT},
+ {DMAP_CC_CMMK, MAKE_CONTENT_CODE ('c', 'm', 'm', 'k'),
+ "dmcp.mediakind", "cmmk", DMAP_TYPE_INT},
+ {DMAP_CC_CMVO, MAKE_CONTENT_CODE ('c', 'm', 'v', 'o'), "dmcp.volume",
+ "cmvo", DMAP_TYPE_INT},
+
};
-const gchar *
+const gchar *
dmap_content_code_name (DMAPContentCode code)
{
- return cc_defs[code-1].name;
+ return cc_defs[code - 1].name;
}
-DMAPType
+DMAPType
dmap_content_code_dmap_type (DMAPContentCode code)
{
- return cc_defs[code-1].type;
+ return cc_defs[code - 1].type;
}
-const gchar *
+const gchar *
dmap_content_code_string (DMAPContentCode code)
{
- return cc_defs[code-1].string;
+ return cc_defs[code - 1].string;
}
-
+
static GType
dmap_content_code_gtype (DMAPContentCode code)
{
- switch (dmap_content_code_dmap_type (code)) {
- case DMAP_TYPE_BYTE:
- case DMAP_TYPE_SIGNED_INT:
- return G_TYPE_CHAR;
- case DMAP_TYPE_SHORT:
- case DMAP_TYPE_INT:
- case DMAP_TYPE_DATE:
- return G_TYPE_INT;
- case DMAP_TYPE_INT64:
- return G_TYPE_INT64;
- case DMAP_TYPE_VERSION:
- return G_TYPE_DOUBLE;
- case DMAP_TYPE_STRING:
- return G_TYPE_STRING;
- case DMAP_TYPE_POINTER:
- return G_TYPE_POINTER;
- case DMAP_TYPE_CONTAINER:
- default:
- return G_TYPE_NONE;
- }
+ switch (dmap_content_code_dmap_type (code)) {
+ case DMAP_TYPE_BYTE:
+ case DMAP_TYPE_SIGNED_INT:
+ return G_TYPE_CHAR;
+ case DMAP_TYPE_SHORT:
+ case DMAP_TYPE_INT:
+ case DMAP_TYPE_DATE:
+ return G_TYPE_INT;
+ case DMAP_TYPE_INT64:
+ return G_TYPE_INT64;
+ case DMAP_TYPE_VERSION:
+ return G_TYPE_DOUBLE;
+ case DMAP_TYPE_STRING:
+ return G_TYPE_STRING;
+ case DMAP_TYPE_POINTER:
+ return G_TYPE_POINTER;
+ case DMAP_TYPE_CONTAINER:
+ default:
+ return G_TYPE_NONE;
+ }
}
-static gboolean
-dmap_structure_node_serialize (GNode *node,
- GByteArray *array)
+static gboolean
+dmap_structure_node_serialize (GNode * node, GByteArray * array)
{
- DMAPStructureItem *item = node->data;
- DMAPType dmap_type;
- guint32 size = GINT32_TO_BE (item->size);
-
- if (item->content_code != DMAP_RAW) {
- g_byte_array_append (array, (const guint8 *)dmap_content_code_string (item->content_code), 4);
- g_byte_array_append (array, (const guint8 *)&size, 4);
- }
-
- dmap_type = dmap_content_code_dmap_type (item->content_code);
-
- switch (dmap_type) {
- case DMAP_TYPE_BYTE:
- case DMAP_TYPE_SIGNED_INT: {
- gchar c = g_value_get_char (&(item->content));
-
- g_byte_array_append (array, (const guint8 *)&c, 1);
-
- break;
- }
- case DMAP_TYPE_SHORT: {
- gint32 i = g_value_get_int (&(item->content));
- gint16 s = GINT16_TO_BE ((gint16) i);
-
- g_byte_array_append (array, (const guint8 *)&s, 2);
-
- break;
- }
- case DMAP_TYPE_DATE:
- case DMAP_TYPE_INT: {
- gint32 i = g_value_get_int (&(item->content));
- gint32 s = GINT32_TO_BE (i);
-
- g_byte_array_append (array, (const guint8 *)&s, 4);
-
- break;
- }
- case DMAP_TYPE_VERSION: {
- gdouble v = g_value_get_double (&(item->content));
- gint16 major;
- gint8 minor;
- gint8 patch = 0;
-
- major = (gint16)v;
- minor = (gint8)(v - ((gdouble)major));
-
- major = GINT16_TO_BE (major);
-
- g_byte_array_append (array, (const guint8 *)&major, 2);
- g_byte_array_append (array, (const guint8 *)&minor, 1);
- g_byte_array_append (array, (const guint8 *)&patch, 1);
-
- break;
- }
- case DMAP_TYPE_INT64: {
- gint64 i = g_value_get_int64 (&(item->content));
- gint64 s = GINT64_TO_BE (i);
-
- g_byte_array_append (array, (const guint8 *)&s, 8);
-
- break;
- }
- case DMAP_TYPE_STRING: {
- const gchar *s = g_value_get_string (&(item->content));
-
- g_byte_array_append (array, (const guint8 *)s, strlen (s));
-
- break;
- }
- case DMAP_TYPE_POINTER: {
- const gpointer *data = g_value_get_pointer (&(item->content));
-
- g_byte_array_append (array, (const guint8 *)data, item->size);
-
- break;
- }
- case DMAP_TYPE_CONTAINER:
- default:
- break;
- }
-
- return FALSE;
+ DMAPStructureItem *item = node->data;
+ DMAPType dmap_type;
+ guint32 size = GINT32_TO_BE (item->size);
+
+ if (item->content_code != DMAP_RAW) {
+ g_byte_array_append (array,
+ (const guint8 *)
+ dmap_content_code_string (item->
+ content_code),
+ 4);
+ g_byte_array_append (array, (const guint8 *) &size, 4);
+ }
+
+ dmap_type = dmap_content_code_dmap_type (item->content_code);
+
+ switch (dmap_type) {
+ case DMAP_TYPE_BYTE:
+ case DMAP_TYPE_SIGNED_INT:{
+ gchar c = g_value_get_char (&(item->content));
+
+ g_byte_array_append (array, (const guint8 *) &c, 1);
+
+ break;
+ }
+ case DMAP_TYPE_SHORT:{
+ gint32 i = g_value_get_int (&(item->content));
+ gint16 s = GINT16_TO_BE ((gint16) i);
+
+ g_byte_array_append (array, (const guint8 *) &s, 2);
+
+ break;
+ }
+ case DMAP_TYPE_DATE:
+ case DMAP_TYPE_INT:{
+ gint32 i = g_value_get_int (&(item->content));
+ gint32 s = GINT32_TO_BE (i);
+
+ g_byte_array_append (array, (const guint8 *) &s, 4);
+
+ break;
+ }
+ case DMAP_TYPE_VERSION:{
+ gdouble v = g_value_get_double (&(item->content));
+ gint16 major;
+ gint8 minor;
+ gint8 patch = 0;
+
+ major = (gint16) v;
+ minor = (gint8) (v - ((gdouble) major));
+
+ major = GINT16_TO_BE (major);
+
+ g_byte_array_append (array, (const guint8 *) &major,
+ 2);
+ g_byte_array_append (array, (const guint8 *) &minor,
+ 1);
+ g_byte_array_append (array, (const guint8 *) &patch,
+ 1);
+
+ break;
+ }
+ case DMAP_TYPE_INT64:{
+ gint64 i = g_value_get_int64 (&(item->content));
+ gint64 s = GINT64_TO_BE (i);
+
+ g_byte_array_append (array, (const guint8 *) &s, 8);
+
+ break;
+ }
+ case DMAP_TYPE_STRING:{
+ const gchar *s =
+ g_value_get_string (&(item->content));
+
+ g_byte_array_append (array, (const guint8 *) s,
+ strlen (s));
+
+ break;
+ }
+ case DMAP_TYPE_POINTER:{
+ const gpointer *data =
+ g_value_get_pointer (&(item->content));
+
+ g_byte_array_append (array, (const guint8 *) data,
+ item->size);
+
+ break;
+ }
+ case DMAP_TYPE_CONTAINER:
+ default:
+ break;
+ }
+
+ return FALSE;
}
-
-gchar *
-dmap_structure_serialize (GNode *structure,
- guint *length)
+
+gchar *
+dmap_structure_serialize (GNode * structure, guint * length)
{
- GByteArray *array;
- gchar *data;
-
- array = g_byte_array_new ();
-
- if (structure) {
- g_node_traverse (structure, G_PRE_ORDER, G_TRAVERSE_ALL, -1, (GNodeTraverseFunc)dmap_structure_node_serialize, array);
- }
-
- data = (gchar *) array->data;
- *length = array->len;
- g_byte_array_free (array, FALSE);
-
- return data;
+ GByteArray *array;
+ gchar *data;
+
+ array = g_byte_array_new ();
+
+ if (structure) {
+ g_node_traverse (structure, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+ (GNodeTraverseFunc)
+ dmap_structure_node_serialize, array);
+ }
+
+ data = (gchar *) array->data;
+ *length = array->len;
+ g_byte_array_free (array, FALSE);
+
+ return data;
}
-DMAPContentCode
-dmap_content_code_read_from_buffer (const gchar *buf)
+DMAPContentCode
+dmap_content_code_read_from_buffer (const gchar * buf)
{
- gint32 c = MAKE_CONTENT_CODE (buf[0], buf[1], buf[2], buf[3]);
- guint i;
-
- for (i = 0; i < G_N_ELEMENTS (cc_defs); i++) {
- if (cc_defs[i].int_code == c) {
- return cc_defs[i].code;
- }
- }
-
- g_warning ("Content code %4s is invalid.", buf);
-
- return DMAP_CC_INVALID;
+ gint32 c = MAKE_CONTENT_CODE (buf[0], buf[1], buf[2], buf[3]);
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (cc_defs); i++) {
+ if (cc_defs[i].int_code == c) {
+ return cc_defs[i].code;
+ }
+ }
+
+ g_warning ("Content code %4s is invalid.", buf);
+
+ return DMAP_CC_INVALID;
}
static gchar *
-dmap_buffer_read_string (const gchar *buf, gssize size)
+dmap_buffer_read_string (const gchar * buf, gssize size)
{
- if (g_utf8_validate (buf, size, NULL) == TRUE) {
- return g_strndup (buf, size);
- } else {
- return g_strdup ("");
- }
+ if (g_utf8_validate (buf, size, NULL) == TRUE) {
+ return g_strndup (buf, size);
+ } else {
+ return g_strdup ("");
+ }
}
-static void
-dmap_structure_parse_container_buffer (GNode *parent,
- const guchar *buf,
- gint buf_length)
+static void
+dmap_structure_parse_container_buffer (GNode * parent,
+ const guchar * buf, gint buf_length)
{
- gint l = 0;
-
- while (l < buf_length) {
- DMAPContentCode cc;
- gint codesize = 0;
- DMAPStructureItem *item = NULL;
- GNode *node = NULL;
- GType gtype;
-
- /* we need at least 8 bytes, 4 of content_code and 4 of size */
- if (buf_length - l < 8) {
- g_debug ("Malformed response recieved\n");
- return;
- }
-
- cc = dmap_content_code_read_from_buffer ((const gchar*)&(buf[l]));
- if (cc == DMAP_CC_INVALID) {
- return;
- }
- l += 4;
-
- codesize = DMAP_READ_UINT32_BE(&(buf[l]));
- /* CCCCSIZECONTENT
- * if the buffer length (minus 8 for the content code & size)
- * is smaller than the read codesize (ie, someone sent us
- * a codesize that is larger than the remaining data)
- * then get out before we start processing it
- */
- if (codesize > buf_length - l - 4 || codesize < 0) {
- g_debug ("Invalid codesize %d recieved in buf_length %d\n", codesize, buf_length);
- return;
- }
- l += 4;
-
- item = g_new0 (DMAPStructureItem, 1);
- item->content_code = cc;
- node = g_node_new (item);
- g_node_append (parent, node);
-
- gtype = dmap_content_code_gtype (item->content_code);
-
- if (gtype != G_TYPE_NONE) {
- g_value_init (&(item->content), gtype);
- }
-
+ gint l = 0;
+
+ while (l < buf_length) {
+ DMAPContentCode cc;
+ gint codesize = 0;
+ DMAPStructureItem *item = NULL;
+ GNode *node = NULL;
+ GType gtype;
+
+ /* we need at least 8 bytes, 4 of content_code and 4 of size */
+ if (buf_length - l < 8) {
+ g_debug ("Malformed response recieved\n");
+ return;
+ }
+
+ cc = dmap_content_code_read_from_buffer ((const gchar *)
+ &(buf[l]));
+ if (cc == DMAP_CC_INVALID) {
+ return;
+ }
+ l += 4;
+
+ codesize = DMAP_READ_UINT32_BE (&(buf[l]));
+ /* CCCCSIZECONTENT
+ * if the buffer length (minus 8 for the content code & size)
+ * is smaller than the read codesize (ie, someone sent us
+ * a codesize that is larger than the remaining data)
+ * then get out before we start processing it
+ */
+ if (codesize > buf_length - l - 4 || codesize < 0) {
+ g_debug ("Invalid codesize %d recieved in buf_length %d\n", codesize, buf_length);
+ return;
+ }
+ l += 4;
+
+ item = g_new0 (DMAPStructureItem, 1);
+ item->content_code = cc;
+ node = g_node_new (item);
+ g_node_append (parent, node);
+
+ gtype = dmap_content_code_gtype (item->content_code);
+
+ if (gtype != G_TYPE_NONE) {
+ g_value_init (&(item->content), gtype);
+ }
// FIXME USE THE G_TYPE CONVERTOR FUNCTION dmap_type_to_gtype
- switch (dmap_content_code_dmap_type (item->content_code)) {
- case DMAP_TYPE_SIGNED_INT:
- case DMAP_TYPE_BYTE: {
- gchar c = 0;
-
- if (codesize == 1) {
- c = (gchar) DMAP_READ_UINT8(&(buf[l]));
- }
-
- item->size = 1;
- g_value_set_char (&(item->content), c);
- break;
- }
- case DMAP_TYPE_SHORT: {
- gint16 s = 0;
-
- if (codesize == 2) {
- s = DMAP_READ_UINT16_BE(&(buf[l]));
- }
-
- item->size = 2;
- g_value_set_int (&(item->content),(gint32)s);
- break;
- }
- case DMAP_TYPE_DATE:
- case DMAP_TYPE_INT: {
- gint32 i = 0;
-
- if (codesize == 4) {
- i = DMAP_READ_UINT32_BE(&(buf[l]));
- }
-
- item->size = 4;
- g_value_set_int (&(item->content), i);
- break;
- }
- case DMAP_TYPE_INT64: {
- gint64 i = 0;
-
- if (codesize == 8) {
- i = DMAP_READ_UINT64_BE(&(buf[l]));
- }
-
- item->size = 8;
- g_value_set_int64 (&(item->content), i);
- break;
- }
- case DMAP_TYPE_STRING: {
- gchar *s = dmap_buffer_read_string ((const gchar*)&(buf[l]), codesize);
-
- item->size = strlen (s);
- g_value_take_string (&(item->content), s);
- break;
- }
- case DMAP_TYPE_POINTER: {
- gpointer *data = g_memdup ((const gchar*)&(buf[l]), codesize);
-
- item->size = codesize;
- g_value_set_pointer (&(item->content), data);
-
- break;
- }
- case DMAP_TYPE_VERSION: {
- gint16 major = 0;
- gint16 minor = 0;
- gint16 patch = 0;
- gdouble v = 0;
-
- if (codesize == 4) {
- major = DMAP_READ_UINT16_BE(&(buf[l]));
- minor = DMAP_READ_UINT8(&(buf[l]) + 2);
- patch = DMAP_READ_UINT8(&(buf[l]) + 3);
- }
-
- v = (gdouble)major;
- v += (gdouble)(minor * 0.1);
- v += (gdouble)(patch * 0.01);
-
- item->size = 4;
- g_value_set_double (&(item->content), v);
- break;
- }
- case DMAP_TYPE_CONTAINER: {
- dmap_structure_parse_container_buffer (node,&(buf[l]), codesize);
- break;
- }
- }
-
- l += codesize;
- }
-
- return;
+ switch (dmap_content_code_dmap_type (item->content_code)) {
+ case DMAP_TYPE_SIGNED_INT:
+ case DMAP_TYPE_BYTE:{
+ gchar c = 0;
+
+ if (codesize == 1) {
+ c = (gchar)
+ DMAP_READ_UINT8 (&(buf[l]));
+ }
+
+ item->size = 1;
+ g_value_set_char (&(item->content), c);
+ break;
+ }
+ case DMAP_TYPE_SHORT:{
+ gint16 s = 0;
+
+ if (codesize == 2) {
+ s = DMAP_READ_UINT16_BE (&(buf[l]));
+ }
+
+ item->size = 2;
+ g_value_set_int (&(item->content),
+ (gint32) s);
+ break;
+ }
+ case DMAP_TYPE_DATE:
+ case DMAP_TYPE_INT:{
+ gint32 i = 0;
+
+ if (codesize == 4) {
+ i = DMAP_READ_UINT32_BE (&(buf[l]));
+ }
+
+ item->size = 4;
+ g_value_set_int (&(item->content), i);
+ break;
+ }
+ case DMAP_TYPE_INT64:{
+ gint64 i = 0;
+
+ if (codesize == 8) {
+ i = DMAP_READ_UINT64_BE (&(buf[l]));
+ }
+
+ item->size = 8;
+ g_value_set_int64 (&(item->content), i);
+ break;
+ }
+ case DMAP_TYPE_STRING:{
+ gchar *s =
+ dmap_buffer_read_string ((const gchar
+ *)
+ &(buf[l]),
+ codesize);
+
+ item->size = strlen (s);
+ g_value_take_string (&(item->content), s);
+ break;
+ }
+ case DMAP_TYPE_POINTER:{
+ gpointer *data =
+ g_memdup ((const gchar *) &(buf[l]),
+ codesize);
+
+ item->size = codesize;
+ g_value_set_pointer (&(item->content), data);
+
+ break;
+ }
+ case DMAP_TYPE_VERSION:{
+ gint16 major = 0;
+ gint16 minor = 0;
+ gint16 patch = 0;
+ gdouble v = 0;
+
+ if (codesize == 4) {
+ major = DMAP_READ_UINT16_BE (&
+ (buf
+ [l]));
+ minor = DMAP_READ_UINT8 (&(buf[l]) +
+ 2);
+ patch = DMAP_READ_UINT8 (&(buf[l]) +
+ 3);
+ }
+
+ v = (gdouble) major;
+ v += (gdouble) (minor * 0.1);
+ v += (gdouble) (patch * 0.01);
+
+ item->size = 4;
+ g_value_set_double (&(item->content), v);
+ break;
+ }
+ case DMAP_TYPE_CONTAINER:{
+ dmap_structure_parse_container_buffer (node,
+ &(buf
+ [l]),
+ codesize);
+ break;
+ }
+ }
+
+ l += codesize;
+ }
+
+ return;
}
-GNode *
-dmap_structure_parse (const gchar *buf,
- gint buf_length)
+GNode *
+dmap_structure_parse (const gchar * buf, gint buf_length)
{
- GNode *root = NULL;
- GNode *child = NULL;
+ GNode *root = NULL;
+ GNode *child = NULL;
+
+ root = g_node_new (NULL);
- root = g_node_new (NULL);
+ dmap_structure_parse_container_buffer (root, (guchar *) buf,
+ buf_length);
- dmap_structure_parse_container_buffer (root, (guchar *)buf, buf_length);
+ child = root->children;
+ if (child) {
+ g_node_unlink (child);
+ }
+ g_node_destroy (root);
- child = root->children;
- if (child) {
- g_node_unlink (child);
- }
- g_node_destroy (root);
-
- return child;
+ return child;
}
-struct NodeFinder {
- DMAPContentCode code;
- GNode *node;
+struct NodeFinder
+{
+ DMAPContentCode code;
+ GNode *node;
};
-static gboolean
-gnode_find_node (GNode *node,
- gpointer data)
+static gboolean
+gnode_find_node (GNode * node, gpointer data)
{
- struct NodeFinder *finder = (struct NodeFinder *)data;
- DMAPStructureItem *item = node->data;
+ struct NodeFinder *finder = (struct NodeFinder *) data;
+ DMAPStructureItem *item = node->data;
- if (item->content_code == finder->code) {
- finder->node = node;
- return TRUE;
- }
+ if (item->content_code == finder->code) {
+ finder->node = node;
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
-DMAPStructureItem *
-dmap_structure_find_item (GNode *structure,
- DMAPContentCode code)
+DMAPStructureItem *
+dmap_structure_find_item (GNode * structure, DMAPContentCode code)
{
- GNode *node = NULL;
-
- node = dmap_structure_find_node (structure, code);
+ GNode *node = NULL;
+
+ node = dmap_structure_find_node (structure, code);
- if (node) {
- return node->data;
- }
+ if (node) {
+ return node->data;
+ }
- return NULL;
+ return NULL;
}
GNode *
-dmap_structure_add (GNode *parent,
- DMAPContentCode cc,
- ...)
+dmap_structure_add (GNode * parent, DMAPContentCode cc, ...)
{
DMAPType dmap_type;
GType gtype;
@@ -582,15 +748,17 @@ dmap_structure_add (GNode *parent,
dmap_type = dmap_content_code_dmap_type (cc);
gtype = dmap_content_code_gtype (cc);
- item = g_new0(DMAPStructureItem, 1);
+ item = g_new0 (DMAPStructureItem, 1);
item->content_code = cc;
if (gtype != G_TYPE_NONE) {
g_value_init (&(item->content), gtype);
}
- if (dmap_type != DMAP_TYPE_STRING && dmap_type != DMAP_TYPE_CONTAINER && dmap_type != DMAP_TYPE_POINTER) {
- G_VALUE_COLLECT (&(item->content), list, G_VALUE_NOCOPY_CONTENTS, &error);
+ if (dmap_type != DMAP_TYPE_STRING && dmap_type != DMAP_TYPE_CONTAINER
+ && dmap_type != DMAP_TYPE_POINTER) {
+ G_VALUE_COLLECT (&(item->content), list,
+ G_VALUE_NOCOPY_CONTENTS, &error);
if (error) {
g_warning ("%s", error);
g_free (error);
@@ -598,22 +766,22 @@ dmap_structure_add (GNode *parent,
}
switch (dmap_type) {
- case DMAP_TYPE_BYTE:
- case DMAP_TYPE_SIGNED_INT:
- item->size = 1;
- break;
- case DMAP_TYPE_SHORT:
- item->size = 2;
- break;
- case DMAP_TYPE_DATE:
- case DMAP_TYPE_INT:
- case DMAP_TYPE_VERSION:
- item->size = 4;
- break;
- case DMAP_TYPE_INT64:
- item->size = 8;
- break;
- case DMAP_TYPE_STRING: {
+ case DMAP_TYPE_BYTE:
+ case DMAP_TYPE_SIGNED_INT:
+ item->size = 1;
+ break;
+ case DMAP_TYPE_SHORT:
+ item->size = 2;
+ break;
+ case DMAP_TYPE_DATE:
+ case DMAP_TYPE_INT:
+ case DMAP_TYPE_VERSION:
+ item->size = 4;
+ break;
+ case DMAP_TYPE_INT64:
+ item->size = 8;
+ break;
+ case DMAP_TYPE_STRING:{
gchar *s = va_arg (list, gchar *);
g_value_set_string (&(item->content), s);
@@ -623,7 +791,7 @@ dmap_structure_add (GNode *parent,
item->size = strlen (s);
break;
}
- case DMAP_TYPE_POINTER: {
+ case DMAP_TYPE_POINTER:{
gpointer p = va_arg (list, gpointer);
gint s = va_arg (list, gint);
@@ -635,9 +803,9 @@ dmap_structure_add (GNode *parent,
break;
}
- case DMAP_TYPE_CONTAINER:
- default:
- break;
+ case DMAP_TYPE_CONTAINER:
+ default:
+ break;
}
node = g_node_new (item);
@@ -660,125 +828,127 @@ dmap_structure_add (GNode *parent,
return node;
}
-GNode *
-dmap_structure_find_node (GNode *structure,
- DMAPContentCode code)
+GNode *
+dmap_structure_find_node (GNode * structure, DMAPContentCode code)
{
- struct NodeFinder *finder;
- GNode *node = NULL;
-
- finder = g_new0(struct NodeFinder,1);
- finder->code = code;
+ struct NodeFinder *finder;
+ GNode *node = NULL;
- g_node_traverse (structure, G_IN_ORDER, G_TRAVERSE_ALL, -1, gnode_find_node, finder);
+ finder = g_new0 (struct NodeFinder, 1);
- node = finder->node;
- g_free (finder);
- finder = NULL;
+ finder->code = code;
- return node;
-}
+ g_node_traverse (structure, G_IN_ORDER, G_TRAVERSE_ALL, -1,
+ gnode_find_node, finder);
+ node = finder->node;
+ g_free (finder);
+ finder = NULL;
+ return node;
+}
static void
-dmap_item_free (DMAPStructureItem *item)
+dmap_item_free (DMAPStructureItem * item)
{
- if (dmap_content_code_dmap_type (item->content_code) != DMAP_TYPE_CONTAINER) {
- g_value_unset (&(item->content));
- }
+ if (dmap_content_code_dmap_type (item->content_code) !=
+ DMAP_TYPE_CONTAINER) {
+ g_value_unset (&(item->content));
+ }
- g_free (item);
+ g_free (item);
}
static gboolean
-gnode_free_dmap_item (GNode *node,
- gpointer data)
+gnode_free_dmap_item (GNode * node, gpointer data)
{
- dmap_item_free ((DMAPStructureItem *)node->data);
+ dmap_item_free ((DMAPStructureItem *) node->data);
- return FALSE;
+ return FALSE;
}
-void
-dmap_structure_destroy (GNode *structure)
+void
+dmap_structure_destroy (GNode * structure)
{
- if (structure) {
- g_node_traverse (structure, G_IN_ORDER, G_TRAVERSE_ALL, -1, gnode_free_dmap_item, NULL);
+ if (structure) {
+ g_node_traverse (structure, G_IN_ORDER, G_TRAVERSE_ALL, -1,
+ gnode_free_dmap_item, NULL);
- g_node_destroy (structure);
+ g_node_destroy (structure);
- structure = NULL;
- }
+ structure = NULL;
+ }
}
const DMAPContentCodeDefinition *
-dmap_content_codes (guint *number)
+dmap_content_codes (guint * number)
{
- *number = G_N_ELEMENTS (cc_defs);
+ *number = G_N_ELEMENTS (cc_defs);
- return cc_defs;
+ return cc_defs;
}
-gint32
-dmap_content_code_string_as_int32 (const gchar *str)
+gint32
+dmap_content_code_string_as_int32 (const gchar * str)
{
- union {
- gint32 i;
- gchar str[4];
- } u;
+ union
+ {
+ gint32 i;
+ gchar str[4];
+ } u;
- strncpy (u.str, str, 4);
+ strncpy (u.str, str, 4);
- return g_htonl (u.i);
+ return g_htonl (u.i);
}
-static gboolean
-print_dmap_item (GNode *node,
- gpointer data)
+static gboolean
+print_dmap_item (GNode * node, gpointer data)
{
- DMAPStructureItem *item;
- const gchar *name;
- gchar *value;
- gint i;
+ DMAPStructureItem *item;
+ const gchar *name;
+ gchar *value;
+ gint i;
- for (i = 1; i < g_node_depth (node); i++) {
- g_print ("\t");
- }
+ for (i = 1; i < g_node_depth (node); i++) {
+ g_print ("\t");
+ }
- item = node->data;
+ item = node->data;
- name = dmap_content_code_name (item->content_code);
+ name = dmap_content_code_name (item->content_code);
- if (G_IS_VALUE (&(item->content))) {
- value = g_strdup_value_contents (&(item->content));
- } else {
- value = g_strdup ("");
- }
+ if (G_IS_VALUE (&(item->content))) {
+ value = g_strdup_value_contents (&(item->content));
+ } else {
+ value = g_strdup ("");
+ }
- g_print ("%d, %s = %s (%d)\n", g_node_depth (node), name, value, item->size);
- g_free (value);
+ g_print ("%d, %s = %s (%d)\n", g_node_depth (node), name, value,
+ item->size);
+ g_free (value);
- return FALSE;
+ return FALSE;
}
void
-dmap_structure_print (GNode *structure)
+dmap_structure_print (GNode * structure)
{
- if (structure) {
- g_node_traverse (structure, G_PRE_ORDER, G_TRAVERSE_ALL, -1, (GNodeTraverseFunc)print_dmap_item, NULL);
- }
+ if (structure) {
+ g_node_traverse (structure, G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+ (GNodeTraverseFunc) print_dmap_item, NULL);
+ }
}
guint
-dmap_structure_get_size (GNode *structure)
+dmap_structure_get_size (GNode * structure)
{
- return ((DMAPStructureItem *) structure->data)->size + 8 /* FIXME: 8 = actual CC field + size field */;
+ return ((DMAPStructureItem *) structure->data)->size +
+ 8 /* FIXME: 8 = actual CC field + size field */ ;
}
-
void
-dmap_structure_increase_by_predicted_size (GNode *structure, guint size)
+dmap_structure_increase_by_predicted_size (GNode * structure, guint size)
{
- ((DMAPStructureItem *) structure->data)->size += size;
+ ((DMAPStructureItem *) structure->data)->size += size;
}
diff --git a/libdmapsharing/dmap-structure.h b/libdmapsharing/dmap-structure.h
index 83e59a5..cceae5b 100644
--- a/libdmapsharing/dmap-structure.h
+++ b/libdmapsharing/dmap-structure.h
@@ -24,16 +24,15 @@
#include <glib.h>
#include <glib-object.h>
-G_BEGIN_DECLS
-
-typedef enum {
+G_BEGIN_DECLS typedef enum
+{
DMAP_CC_INVALID = 0,
- DMAP_RAW, /* The RAW type does not use a content code.
- * Instead of:
- * CCCC BYTECOUNT DATA
- * RAW sends:
- * DATA
- */
+ DMAP_RAW, /* The RAW type does not use a content code.
+ * Instead of:
+ * CCCC BYTECOUNT DATA
+ * RAW sends:
+ * DATA
+ */
DMAP_CC_MDCL,
DMAP_CC_MSTT,
DMAP_CC_MIID,
@@ -51,10 +50,10 @@ typedef enum {
DMAP_CC_MLCL,
DMAP_CC_MLIT,
DMAP_CC_MBCL,
- DMAP_CC_MSRV,
+ DMAP_CC_MSRV,
DMAP_CC_MSAU,
DMAP_CC_MSLR,
- DMAP_CC_MPRO,
+ DMAP_CC_MPRO,
DMAP_CC_MSAL,
DMAP_CC_MSUP,
DMAP_CC_MSPI,
@@ -63,7 +62,7 @@ typedef enum {
DMAP_CC_MSQY,
DMAP_CC_MSIX,
DMAP_CC_MSRS,
- DMAP_CC_MSTM,
+ DMAP_CC_MSTM,
DMAP_CC_MSDC,
DMAP_CC_MCCR,
DMAP_CC_MCNM,
@@ -73,11 +72,11 @@ typedef enum {
DMAP_CC_MLID,
DMAP_CC_MUPD,
DMAP_CC_MUSR,
- DMAP_CC_MUTY,
+ DMAP_CC_MUTY,
DMAP_CC_MUDL,
DMAP_CC_MSMA,
DMAP_CC_FQUESCH,
-
+
DMAP_CC_APRO,
DMAP_CC_AVDB,
DMAP_CC_ABRO,
@@ -89,7 +88,7 @@ typedef enum {
DMAP_CC_ASAL,
DMAP_CC_ASAI,
DMAP_CC_ASAA,
- DMAP_CC_ASAR,
+ DMAP_CC_ASAR,
DMAP_CC_ASBT,
DMAP_CC_ASBR,
DMAP_CC_ASCM,
@@ -109,7 +108,7 @@ typedef enum {
DMAP_CC_ASST,
DMAP_CC_ASSP,
DMAP_CC_ASTM,
- DMAP_CC_ASTC,
+ DMAP_CC_ASTC,
DMAP_CC_ASTN,
DMAP_CC_ASUR,
DMAP_CC_ASYR,
@@ -121,12 +120,12 @@ typedef enum {
DMAP_CC_ABPL,
DMAP_CC_APSO,
DMAP_CC_PRSV,
- DMAP_CC_ARIF,
+ DMAP_CC_ARIF,
DMAP_CC_MSAS,
DMAP_CC_AGRP,
DMAP_CC_AGAL,
DMAP_CC_ASCP,
- DMAP_CC_PPRO,
+ DMAP_CC_PPRO,
DMAP_CC_PASP,
DMAP_CC_PFDT,
DMAP_CC_PICD,
@@ -139,7 +138,7 @@ typedef enum {
DMAP_CC_PRAT,
DMAP_CC_PCMT,
DMAP_CC_PRET,
-
+
/* iTunes 6.02+ */
DMAP_CC_AESV,
DMAP_CC_AEHV,
@@ -150,13 +149,13 @@ typedef enum {
DMAP_CC_AESG,
DMAP_CC_AEMK,
DMAP_CC_AEFP,
-
+
/* DACP */
DMAP_CC_CMPA,
DMAP_CC_CMNM,
DMAP_CC_CMTY,
DMAP_CC_CMPG,
-
+
DMAP_CC_CACI,
DMAP_CC_CAPS,
DMAP_CC_CASH,
@@ -190,29 +189,27 @@ typedef enum {
typedef struct _DMAPStructureItem DMAPStructureItem;
-struct _DMAPStructureItem {
+struct _DMAPStructureItem
+{
DMAPContentCode content_code;
GValue content;
guint size;
};
-GNode *dmap_structure_add (GNode *parent,
- DMAPContentCode cc,
- ...);
-gchar *dmap_structure_serialize (GNode *structure,
- guint *length);
-GNode *dmap_structure_parse (const gchar *buf,
- gint buf_length);
-DMAPStructureItem *dmap_structure_find_item (GNode *structure,
- DMAPContentCode code);
-GNode *dmap_structure_find_node (GNode *structure,
- DMAPContentCode code);
-void dmap_structure_print (GNode *structure);
-void dmap_structure_destroy (GNode *structure);
-guint dmap_structure_get_size (GNode *structure);
-void dmap_structure_increase_by_predicted_size (GNode *structure, guint size);
-
-typedef enum {
+GNode *dmap_structure_add (GNode * parent, DMAPContentCode cc, ...);
+gchar *dmap_structure_serialize (GNode * structure, guint * length);
+GNode *dmap_structure_parse (const gchar * buf, gint buf_length);
+DMAPStructureItem *dmap_structure_find_item (GNode * structure,
+ DMAPContentCode code);
+GNode *dmap_structure_find_node (GNode * structure, DMAPContentCode code);
+void dmap_structure_print (GNode * structure);
+void dmap_structure_destroy (GNode * structure);
+guint dmap_structure_get_size (GNode * structure);
+void dmap_structure_increase_by_predicted_size (GNode * structure,
+ guint size);
+
+typedef enum
+{
DMAP_TYPE_BYTE = 0x0001,
DMAP_TYPE_SIGNED_INT = 0x0002,
DMAP_TYPE_SHORT = 0x0003,
@@ -227,7 +224,8 @@ typedef enum {
typedef struct _DMAPContentCodeDefinition DMAPContentCodeDefinition;
-struct _DMAPContentCodeDefinition {
+struct _DMAPContentCodeDefinition
+{
DMAPContentCode code;
gint32 int_code;
const gchar *name;
@@ -235,16 +233,13 @@ struct _DMAPContentCodeDefinition {
DMAPType type;
};
-const DMAPContentCodeDefinition
- *dmap_content_codes (guint *number);
-gint32 dmap_content_code_string_as_int32 (const gchar *str);
-const gchar *dmap_content_code_name (DMAPContentCode code);
-DMAPType dmap_content_code_dmap_type (DMAPContentCode code);
-const gchar *dmap_content_code_string (DMAPContentCode code);
-
-DMAPContentCode
- dmap_content_code_read_from_buffer (const gchar *buf);
+const DMAPContentCodeDefinition * dmap_content_codes (guint * number);
+gint32 dmap_content_code_string_as_int32 (const gchar * str);
+const gchar *dmap_content_code_name (DMAPContentCode code);
+DMAPType dmap_content_code_dmap_type (DMAPContentCode code);
+const gchar *dmap_content_code_string (DMAPContentCode code);
-G_END_DECLS
+DMAPContentCode dmap_content_code_read_from_buffer (const gchar * buf);
+G_END_DECLS
#endif
diff --git a/libdmapsharing/dmap-utils.c b/libdmapsharing/dmap-utils.c
index cf0562a..7323df4 100644
--- a/libdmapsharing/dmap-utils.c
+++ b/libdmapsharing/dmap-utils.c
@@ -25,7 +25,7 @@
#define DMAP_SHARE_CHUNK_SIZE 16384
void
-dmap_write_next_chunk (SoupMessage *message, ChunkData *cd)
+dmap_write_next_chunk (SoupMessage * message, ChunkData * cd)
{
gssize read_size;
GError *error = NULL;
@@ -33,14 +33,10 @@ dmap_write_next_chunk (SoupMessage *message, ChunkData *cd)
read_size = g_input_stream_read (cd->stream,
chunk,
- DMAP_SHARE_CHUNK_SIZE,
- NULL,
- &error);
+ DMAP_SHARE_CHUNK_SIZE, NULL, &error);
if (read_size > 0) {
soup_message_body_append (message->response_body,
- SOUP_MEMORY_TAKE,
- chunk,
- read_size);
+ SOUP_MEMORY_TAKE, chunk, read_size);
} else {
if (error != NULL) {
g_warning ("Error reading from input stream: %s",
@@ -55,7 +51,7 @@ dmap_write_next_chunk (SoupMessage *message, ChunkData *cd)
}
void
-dmap_chunked_message_finished (SoupMessage *message, ChunkData *cd)
+dmap_chunked_message_finished (SoupMessage * message, ChunkData * cd)
{
g_debug ("Finished sending chunked file.");
g_input_stream_close (cd->stream, NULL, NULL);
diff --git a/libdmapsharing/dmap-utils.h b/libdmapsharing/dmap-utils.h
index 5ec7065..72c6f93 100644
--- a/libdmapsharing/dmap-utils.h
+++ b/libdmapsharing/dmap-utils.h
@@ -26,22 +26,16 @@
#include <libdmapsharing/dmap-config.h>
G_BEGIN_DECLS
-
#if DMAP_HAVE_UNALIGNED_ACCESS
-
#define _DMAP_GET(__data, __size, __end) \
(GUINT##__size##_FROM_##__end (* ((guint##__size *) (__data))))
-
#define DMAP_READ_UINT64_BE(data) _DMAP_GET (data, 64, BE)
#define DMAP_READ_UINT32_BE(data) _DMAP_GET (data, 32, BE)
#define DMAP_READ_UINT16_BE(data) _DMAP_GET (data, 16, BE)
#define DMAP_READ_UINT8(data) (* ((guint8 *) (data)))
-
#else
-
#define _DMAP_GET(__data, __idx, __size, __shift) \
(((guint##__size) (((guint8 *) (__data))[__idx])) << __shift)
-
#define DMAP_READ_UINT64_BE(data) \
(_DMAP_GET (data, 0, 64, 56) | \
_DMAP_GET (data, 1, 64, 48) | \
@@ -60,17 +54,15 @@ G_BEGIN_DECLS
(_DMAP_GET (data, 0, 16, 8) | \
_DMAP_GET (data, 1, 16, 0))
#define DMAP_READ_UINT8(data) (_DMAP_GET (data, 0, 8, 0))
-
#endif
-
-typedef struct ChunkData {
+ typedef struct ChunkData
+{
SoupServer *server;
GInputStream *stream;
} ChunkData;
-void dmap_write_next_chunk (SoupMessage *message, ChunkData *cd);
-void dmap_chunked_message_finished (SoupMessage *message, ChunkData *cd);
+void dmap_write_next_chunk (SoupMessage * message, ChunkData * cd);
+void dmap_chunked_message_finished (SoupMessage * message, ChunkData * cd);
G_END_DECLS
-
#endif
diff --git a/libdmapsharing/dpap-connection.c b/libdmapsharing/dpap-connection.c
index f593beb..30cc758 100644
--- a/libdmapsharing/dpap-connection.c
+++ b/libdmapsharing/dpap-connection.c
@@ -31,7 +31,7 @@ struct DPAPConnectionPrivate {
*/
static DMAPContentCode
-get_protocol_version_cc (DMAPConnection *connection)
+get_protocol_version_cc (DMAPConnection * connection)
{
return DMAP_CC_PPRO;
}
@@ -43,7 +43,8 @@ get_query_metadata (void)
}
static DMAPRecord *
-handle_mlcl (DMAPConnection *connection, DMAPRecordFactory *factory, GNode *n, int *item_id)
+handle_mlcl (DMAPConnection * connection, DMAPRecordFactory * factory,
+ GNode * n, int *item_id)
{
GNode *n2;
DMAPRecord *record = NULL;
@@ -66,44 +67,48 @@ handle_mlcl (DMAPConnection *connection, DMAPRecordFactory *factory, GNode *n, i
meta_item = n2->data;
switch (meta_item->content_code) {
- case DMAP_CC_MIID:
- *item_id = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_PIMF:
- filename = g_value_get_string (&(meta_item->content));
- break;
- case DMAP_CC_PASP:
- aspect_ratio = g_value_get_string (&(meta_item->content));
- break;
- case DMAP_CC_PICD:
- creation_date = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_PFMT:
- format = g_value_get_string (&(meta_item->content));
- break;
- case DMAP_CC_PIFS:
- filesize = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_PLSZ:
- large_filesize = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_PHGT:
- height = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_PWTH:
- width = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_PRAT:
- rating = g_value_get_int (&(meta_item->content));
- break;
- case DMAP_CC_PCMT:
- comments = g_value_get_string (&(meta_item->content));
- break;
- case DMAP_CC_PFDT:
- thumbnail = g_value_get_pointer (&(meta_item->content));
- break;
- default:
- break;
+ case DMAP_CC_MIID:
+ *item_id = g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_PIMF:
+ filename = g_value_get_string (&(meta_item->content));
+ break;
+ case DMAP_CC_PASP:
+ aspect_ratio =
+ g_value_get_string (&(meta_item->content));
+ break;
+ case DMAP_CC_PICD:
+ creation_date =
+ g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_PFMT:
+ format = g_value_get_string (&(meta_item->content));
+ break;
+ case DMAP_CC_PIFS:
+ filesize = g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_PLSZ:
+ large_filesize =
+ g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_PHGT:
+ height = g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_PWTH:
+ width = g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_PRAT:
+ rating = g_value_get_int (&(meta_item->content));
+ break;
+ case DMAP_CC_PCMT:
+ comments = g_value_get_string (&(meta_item->content));
+ break;
+ case DMAP_CC_PFDT:
+ thumbnail =
+ g_value_get_pointer (&(meta_item->content));
+ break;
+ default:
+ break;
}
}
@@ -118,69 +123,65 @@ handle_mlcl (DMAPConnection *connection, DMAPRecordFactory *factory, GNode *n, i
}
g_object_set (record,
- "filename", filename,
- "aspect-ratio", aspect_ratio,
- "creation-date", creation_date,
- "format", format,
- "large-filesize", large_filesize,
- "pixel-height", height,
- "pixel-width", width,
- "rating", rating,
- "comments", comments,
- "thumbnail", ptr,
- NULL);
+ "filename", filename,
+ "aspect-ratio", aspect_ratio,
+ "creation-date", creation_date,
+ "format", format,
+ "large-filesize", large_filesize,
+ "pixel-height", height,
+ "pixel-width", width,
+ "rating", rating,
+ "comments", comments, "thumbnail", ptr, NULL);
if (ptr) {
g_byte_array_unref (ptr);
}
-_return:
+ _return:
return record;
}
static void
-dpap_connection_class_init (DPAPConnectionClass *klass)
+dpap_connection_class_init (DPAPConnectionClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- DMAPConnectionClass *parent_class = DMAP_CONNECTION_CLASS (object_class);
+ DMAPConnectionClass *parent_class =
+ DMAP_CONNECTION_CLASS (object_class);
parent_class->get_protocol_version_cc = get_protocol_version_cc;
parent_class->get_query_metadata = get_query_metadata;
parent_class->handle_mlcl = handle_mlcl;
/* FIXME:
- g_type_class_add_private (klass, sizeof (DPAPConnectionPrivate));
- */
+ * g_type_class_add_private (klass, sizeof (DPAPConnectionPrivate));
+ */
}
DPAPConnection *
-dpap_connection_new (const char *name,
- const char *host,
- guint port,
- gboolean password_protected,
- DMAPDb *db,
- DMAPRecordFactory *factory)
+dpap_connection_new (const char *name,
+ const char *host,
+ guint port,
+ gboolean password_protected,
+ DMAPDb * db, DMAPRecordFactory * factory)
{
DPAPConnection *connection;
-
+
connection = g_object_new (DPAP_TYPE_CONNECTION,
- "name", name,
- "password-protected", password_protected,
- "db", db,
- "host", host,
- "port", port,
- "factory", factory,
- NULL);
+ "name", name,
+ "password-protected", password_protected,
+ "db", db,
+ "host", host,
+ "port", port, "factory", factory, NULL);
return connection;
}
static void
-dpap_connection_init (DPAPConnection *connection)
+dpap_connection_init (DPAPConnection * connection)
{
/* FIXME:
- connection->priv = DPAP_CONNECTION_GET_PRIVATE (connection);
- */
+ * connection->priv = DPAP_CONNECTION_GET_PRIVATE (connection);
+ */
}
G_DEFINE_TYPE (DPAPConnection, dpap_connection, DMAP_TYPE_CONNECTION)
diff --git a/libdmapsharing/dpap-connection.h b/libdmapsharing/dpap-connection.h
index 0af223d..915b1e9 100644
--- a/libdmapsharing/dpap-connection.h
+++ b/libdmapsharing/dpap-connection.h
@@ -23,7 +23,6 @@
#include <libdmapsharing/dmap-db.h>
G_BEGIN_DECLS
-
/**
* DPAP_TYPE_CONNECTION:
*
@@ -71,26 +70,26 @@ G_BEGIN_DECLS
* Returns: pointer to object class structure.
*/
#define DPAP_CONNECTION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), DPAP_TYPE_CONNECTION, DPAPConnectionClass))
-
typedef struct DPAPConnectionPrivate DPAPConnectionPrivate;
-typedef struct {
+typedef struct
+{
DMAPConnectionClass dmap_connection_class;
} DPAPConnectionClass;
-typedef struct {
+typedef struct
+{
DMAPConnection dmap_connection_instance;
DPAPConnectionPrivate *priv;
} DPAPConnection;
-GType dpap_connection_get_type (void);
+GType dpap_connection_get_type (void);
-DPAPConnection * dpap_connection_new (const char *name,
- const char *host,
- guint port,
- gboolean password_protected,
- DMAPDb *db,
- DMAPRecordFactory *factory);
+DPAPConnection *dpap_connection_new (const char *name,
+ const char *host,
+ guint port,
+ gboolean password_protected,
+ DMAPDb * db,
+ DMAPRecordFactory * factory);
G_END_DECLS
-
#endif /* __DPAP_CONNECTION_H */
diff --git a/libdmapsharing/dpap-record.c b/libdmapsharing/dpap-record.c
index 6070839..eefabc9 100644
--- a/libdmapsharing/dpap-record.c
+++ b/libdmapsharing/dpap-record.c
@@ -24,110 +24,108 @@
static gint dpap_record_init_count = 0;
static void
-dpap_record_init (DPAPRecordIface *iface)
+dpap_record_init (DPAPRecordIface * iface)
{
static gboolean is_initialized = FALSE;
- dpap_record_init_count++;
+ dpap_record_init_count++;
- if (! is_initialized) {
+ if (!is_initialized) {
g_object_interface_install_property (iface,
- g_param_spec_string ("location",
- "URI pointing to photo data",
- "URI pointing to photo data",
- NULL,
- G_PARAM_READWRITE));
-
-
- /* iTunes does not require to this to match the datatype for the image
- * to be displayed (set to "JPEG" and served a PNG). I think this is
- * for display to the user only.
- */
+ g_param_spec_string
+ ("location",
+ "URI pointing to photo data",
+ "URI pointing to photo data",
+ NULL,
+ G_PARAM_READWRITE));
+
+ /* iTunes does not require to this to match the datatype for the image
+ * to be displayed (set to "JPEG" and served a PNG). I think this is
+ * for display to the user only.
+ */
g_object_interface_install_property (iface,
- g_param_spec_string ("format",
- "Photo data format",
- "Photo data format",
- NULL,
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("format",
+ "Photo data format",
+ "Photo data format",
+ NULL,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_string ("aspect-ratio",
- "Photo aspect ratio",
- "Photo aspect ratio",
- NULL,
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("aspect-ratio",
+ "Photo aspect ratio",
+ "Photo aspect ratio",
+ NULL,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_string ("filename",
- "Photo filename",
- "Photo filename",
- NULL,
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("filename",
+ "Photo filename",
+ "Photo filename", NULL,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_string ("comments",
- "Photo comments",
- "Photo comments",
- NULL,
- G_PARAM_READWRITE));
+ g_param_spec_string
+ ("comments",
+ "Photo comments",
+ "Photo comments", NULL,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_pointer ("thumbnail",
- "Photo thumbnail",
- "Photo thumbnail",
- G_PARAM_READWRITE));
+ g_param_spec_pointer
+ ("thumbnail",
+ "Photo thumbnail",
+ "Photo thumbnail",
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("rating",
- "Photo rating",
- "Photo rating",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("rating",
+ "Photo rating",
+ "Photo rating", 0,
+ G_MAXINT, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("creation-date",
- "Photo creation date",
- "Photo creation date",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("creation-date",
+ "Photo creation date",
+ "Photo creation date",
+ 0, G_MAXINT, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("large-filesize",
- "Photo large file size",
- "Photo large file size",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("large-filesize",
+ "Photo large file size",
+ "Photo large file size",
+ 0, G_MAXINT, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("pixel-height",
- "Photo pixel height",
- "Photo pixel height",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("pixel-height",
+ "Photo pixel height",
+ "Photo pixel height", 0,
+ G_MAXINT, 0,
+ G_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_int ("pixel-width",
- "Photo pixel width",
- "Photo pixel width",
- 0,
- G_MAXINT,
- 0,
- G_PARAM_READWRITE));
+ g_param_spec_int
+ ("pixel-width",
+ "Photo pixel width",
+ "Photo pixel width", 0,
+ G_MAXINT, 0,
+ G_PARAM_READWRITE));
is_initialized = TRUE;
}
}
static void
-dpap_record_finalize (DPAPRecordIface *iface)
+dpap_record_finalize (DPAPRecordIface * iface)
{
dpap_record_init_count--;
}
@@ -137,22 +135,23 @@ GType
dpap_record_get_type (void)
{
static GType object_type = 0;
+
if (!object_type) {
static const GTypeInfo object_info = {
- sizeof(DPAPRecordIface),
+ sizeof (DPAPRecordIface),
(GBaseInitFunc) dpap_record_init,
(GBaseFinalizeFunc) dpap_record_finalize
};
object_type =
- g_type_register_static(G_TYPE_INTERFACE,
- "DPAPRecord",
- &object_info, 0);
+ g_type_register_static (G_TYPE_INTERFACE,
+ "DPAPRecord",
+ &object_info, 0);
}
return object_type;
}
GInputStream *
-dpap_record_read (DPAPRecord *record, GError **err)
+dpap_record_read (DPAPRecord * record, GError ** err)
{
return DPAP_RECORD_GET_INTERFACE (record)->read (record, err);
}
diff --git a/libdmapsharing/dpap-record.h b/libdmapsharing/dpap-record.h
index cf506cc..0e9c1c4 100644
--- a/libdmapsharing/dpap-record.h
+++ b/libdmapsharing/dpap-record.h
@@ -27,7 +27,6 @@
#include <libdmapsharing/dmap-record.h>
G_BEGIN_DECLS
-
/**
* DPAP_TYPE_RECORD:
*
@@ -62,17 +61,17 @@ G_BEGIN_DECLS
*/
#define DPAP_RECORD_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), \
DPAP_TYPE_RECORD, DPAPRecordIface))
-
typedef struct _DPAPRecord DPAPRecord;
typedef struct _DPAPRecordIface DPAPRecordIface;
-struct _DPAPRecordIface {
+struct _DPAPRecordIface
+{
GTypeInterface parent;
- GInputStream * (*read) (DPAPRecord *record, GError **err);
+ GInputStream *(*read) (DPAPRecord * record, GError ** err);
};
-GType dpap_record_get_type (void);
+GType dpap_record_get_type (void);
/**
* dpap_record_read:
@@ -82,7 +81,7 @@ GType dpap_record_get_type (void);
* Returns: A GInputStream that provides read-only access to the data stream
* associated with record.
*/
-GInputStream *dpap_record_read (DPAPRecord *record, GError **err);
+GInputStream *dpap_record_read (DPAPRecord * record, GError ** err);
#endif /* __DPAP_RECORD_H */
diff --git a/libdmapsharing/dpap-share.c b/libdmapsharing/dpap-share.c
index 44795e8..89e7296 100644
--- a/libdmapsharing/dpap-share.c
+++ b/libdmapsharing/dpap-share.c
@@ -45,46 +45,43 @@
#include <libdmapsharing/dmap-utils.h>
#include <libdmapsharing/dmap-structure.h>
-static void dpap_share_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void dpap_share_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void dpap_share_dispose (GObject *object);
-guint dpap_share_get_desired_port (DMAPShare *share);
-const char *dpap_share_get_type_of_service (DMAPShare *share);
-void dpap_share_server_info (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context);
-void dpap_share_message_add_standard_headers (DMAPShare *share,
- SoupMessage *message);
-static void databases_browse_xxx (DMAPShare *share,
- SoupServer *server,
- SoupMessage *msg,
+static void dpap_share_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value,
+ GParamSpec * pspec);
+static void dpap_share_get_property (GObject * object,
+ guint prop_id,
+ GValue * value, GParamSpec * pspec);
+static void dpap_share_dispose (GObject * object);
+guint dpap_share_get_desired_port (DMAPShare * share);
+const char *dpap_share_get_type_of_service (DMAPShare * share);
+void dpap_share_server_info (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context);
+void dpap_share_message_add_standard_headers (DMAPShare * share,
+ SoupMessage * message);
+static void databases_browse_xxx (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * msg,
const char *path,
- GHashTable *query,
- SoupClientContext *context);
-static void databases_items_xxx (DMAPShare *share,
- SoupServer *server,
- SoupMessage *msg,
+ GHashTable * query,
+ SoupClientContext * context);
+static void databases_items_xxx (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * msg,
const char *path,
- GHashTable *query,
- SoupClientContext *context);
-static struct DMAPMetaDataMap *get_meta_data_map (DMAPShare *share);
-static void add_entry_to_mlcl (gpointer id,
- DMAPRecord *record,
- gpointer mb);
+ GHashTable * query,
+ SoupClientContext * context);
+static struct DMAPMetaDataMap *get_meta_data_map (DMAPShare * share);
+static void add_entry_to_mlcl (gpointer id, DMAPRecord * record, gpointer mb);
#define DPAP_TYPE_OF_SERVICE "_dpap._tcp"
#define DPAP_PORT 8770
-struct DPAPSharePrivate {
+struct DPAPSharePrivate
+{
gchar unused;
};
@@ -95,14 +92,14 @@ static GMappedFile *mapped_file = NULL;
#define DPAP_SHARE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), DPAP_TYPE_SHARE, DPAPSharePrivate))
-enum {
+enum
+{
PROP_0,
};
G_DEFINE_TYPE (DPAPShare, dpap_share, DMAP_TYPE_SHARE)
-static void
-dpap_share_class_init (DPAPShareClass *klass)
+ static void dpap_share_class_init (DPAPShareClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
DMAPShareClass *parent_class = DMAP_SHARE_CLASS (object_class);
@@ -111,35 +108,35 @@ dpap_share_class_init (DPAPShareClass *klass)
object_class->set_property = dpap_share_set_property;
object_class->dispose = dpap_share_dispose;
- parent_class->get_desired_port = dpap_share_get_desired_port;
- parent_class->get_type_of_service = dpap_share_get_type_of_service;
- parent_class->message_add_standard_headers = dpap_share_message_add_standard_headers;
- parent_class->get_meta_data_map = get_meta_data_map;
- parent_class->add_entry_to_mlcl = add_entry_to_mlcl;
+ parent_class->get_desired_port = dpap_share_get_desired_port;
+ parent_class->get_type_of_service = dpap_share_get_type_of_service;
+ parent_class->message_add_standard_headers =
+ dpap_share_message_add_standard_headers;
+ parent_class->get_meta_data_map = get_meta_data_map;
+ parent_class->add_entry_to_mlcl = add_entry_to_mlcl;
parent_class->databases_browse_xxx = databases_browse_xxx;
- parent_class->databases_items_xxx = databases_items_xxx;
- parent_class->server_info = dpap_share_server_info;
+ parent_class->databases_items_xxx = databases_items_xxx;
+ parent_class->server_info = dpap_share_server_info;
g_type_class_add_private (klass, sizeof (DPAPSharePrivate));
}
static void
-dpap_share_init (DPAPShare *share)
+dpap_share_init (DPAPShare * share)
{
share->priv = DPAP_SHARE_GET_PRIVATE (share);
/* FIXME: do I need to manually call parent _init? */
}
static void
-dpap_share_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+dpap_share_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
// DPAPShare *share = DPAP_SHARE (object);
switch (prop_id) {
- /* FIXME: */
+ /* FIXME: */
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -147,10 +144,8 @@ dpap_share_set_property (GObject *object,
}
static void
-dpap_share_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+dpap_share_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
// DPAPShare *share = DPAP_SHARE (object);
@@ -162,7 +157,7 @@ dpap_share_get_property (GObject *object,
}
static void
-dpap_share_dispose (GObject *object)
+dpap_share_dispose (GObject * object)
{
/* FIXME: implement in parent */
}
@@ -174,17 +169,16 @@ DPAPShare *
dpap_share_new (const char *name,
const char *password,
gpointer db,
- gpointer container_db,
- gchar *transcode_mimetype)
+ gpointer container_db, gchar * transcode_mimetype)
{
DPAPShare *share;
share = DPAP_SHARE (g_object_new (DPAP_TYPE_SHARE,
- "name", name,
- "password", password,
- "db", db,
- "container-db", container_db,
- NULL));
+ "name", name,
+ "password", password,
+ "db", db,
+ "container-db", container_db,
+ NULL));
_dmap_share_server_start (DMAP_SHARE (share));
_dmap_share_publish_start (DMAP_SHARE (share));
@@ -193,9 +187,11 @@ dpap_share_new (const char *name,
}
void
-dpap_share_message_add_standard_headers (DMAPShare *share, SoupMessage *message)
+dpap_share_message_add_standard_headers (DMAPShare * share,
+ SoupMessage * message)
{
- soup_message_headers_append (message->response_headers, "DPAP-Server", "libdmapsharing" VERSION);
+ soup_message_headers_append (message->response_headers, "DPAP-Server",
+ "libdmapsharing" VERSION);
}
#define DMAP_VERSION 2.0
@@ -203,24 +199,23 @@ dpap_share_message_add_standard_headers (DMAPShare *share, SoupMessage *message)
#define DPAP_TIMEOUT 1800
guint
-dpap_share_get_desired_port (DMAPShare *share)
+dpap_share_get_desired_port (DMAPShare * share)
{
return DPAP_PORT;
}
const char *
-dpap_share_get_type_of_service (DMAPShare *share)
+dpap_share_get_type_of_service (DMAPShare * share)
{
return DPAP_TYPE_OF_SERVICE;
}
void
-dpap_share_server_info (DMAPShare *share,
- SoupServer *server,
- SoupMessage *message,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
+dpap_share_server_info (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * message,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
/* MSRV server info response
* MSTT status
@@ -252,7 +247,7 @@ dpap_share_server_info (DMAPShare *share,
dmap_structure_add (msrv, DMAP_CC_MPRO, (gdouble) DMAP_VERSION);
dmap_structure_add (msrv, DMAP_CC_PPRO, (gdouble) DPAP_VERSION);
dmap_structure_add (msrv, DMAP_CC_MINM, nameprop);
- /*dmap_structure_add (msrv, DMAP_CC_MSAU, _dmap_share_get_auth_method (share));*/
+ /*dmap_structure_add (msrv, DMAP_CC_MSAU, _dmap_share_get_auth_method (share)); */
/* authentication method
* 0 is nothing
* 1 is name & password
@@ -276,7 +271,8 @@ dpap_share_server_info (DMAPShare *share,
g_free (nameprop);
}
-typedef enum {
+typedef enum
+{
ITEM_ID = 0,
ITEM_NAME,
ITEM_KIND,
@@ -298,73 +294,76 @@ typedef enum {
} DPAPMetaData;
static struct DMAPMetaDataMap meta_data_map[] = {
- {"dmap.itemid", ITEM_ID},
- {"dmap.itemname", ITEM_NAME},
- {"dmap.itemkind", ITEM_KIND},
- {"dmap.persistentid", PERSISTENT_ID},
- {"dmap.containeritemid", CONTAINER_ITEM_ID},
- {"dpap.aspectratio", PHOTO_ASPECTRATIO},
- {"dpap.creationdate", PHOTO_CREATIONDATE},
- {"dpap.imagefilename", PHOTO_IMAGEFILENAME},
- {"dpap.imageformat", PHOTO_IMAGEFORMAT},
- {"dpap.imagefilesize", PHOTO_IMAGEFILESIZE},
- {"dpap.imagelargefilesize", PHOTO_IMAGELARGEFILESIZE},
- {"dpap.imagepixelheight", PHOTO_IMAGEPIXELHEIGHT},
- {"dpap.imagepixelwidth", PHOTO_IMAGEPIXELWIDTH},
- {"dpap.imagerating", PHOTO_IMAGERATING},
- {"dpap.thumb", PHOTO_THUMB},
- {"dpap.hires", PHOTO_HIRES},
- {"dpap.filedata", PHOTO_FILEDATA},
- {"dpap.imagecomments", PHOTO_IMAGECOMMENTS},
- { NULL, 0}};
-
-#define DPAP_ITEM_KIND_PHOTO 3 /* This is the constant that dpap-sharp uses. */
+ {"dmap.itemid", ITEM_ID},
+ {"dmap.itemname", ITEM_NAME},
+ {"dmap.itemkind", ITEM_KIND},
+ {"dmap.persistentid", PERSISTENT_ID},
+ {"dmap.containeritemid", CONTAINER_ITEM_ID},
+ {"dpap.aspectratio", PHOTO_ASPECTRATIO},
+ {"dpap.creationdate", PHOTO_CREATIONDATE},
+ {"dpap.imagefilename", PHOTO_IMAGEFILENAME},
+ {"dpap.imageformat", PHOTO_IMAGEFORMAT},
+ {"dpap.imagefilesize", PHOTO_IMAGEFILESIZE},
+ {"dpap.imagelargefilesize", PHOTO_IMAGELARGEFILESIZE},
+ {"dpap.imagepixelheight", PHOTO_IMAGEPIXELHEIGHT},
+ {"dpap.imagepixelwidth", PHOTO_IMAGEPIXELWIDTH},
+ {"dpap.imagerating", PHOTO_IMAGERATING},
+ {"dpap.thumb", PHOTO_THUMB},
+ {"dpap.hires", PHOTO_HIRES},
+ {"dpap.filedata", PHOTO_FILEDATA},
+ {"dpap.imagecomments", PHOTO_IMAGECOMMENTS},
+ {NULL, 0}
+};
+
+#define DPAP_ITEM_KIND_PHOTO 3 /* This is the constant that dpap-sharp uses. */
static GMappedFile *
file_to_mmap (const char *location)
{
- GFile *file;
- GMappedFile *mapped_file = NULL;
- char *path;
- GError *error = NULL;
+ GFile *file;
+ GMappedFile *mapped_file = NULL;
+ char *path;
+ GError *error = NULL;
- file = g_file_new_for_uri (location);
+ file = g_file_new_for_uri (location);
/* NOTE: this is broken if original filename contains "%20" etc. This
* is because g_file_get_path() will translate this to " ", etc. But
* the filename really may have used "%20" (not " ").
*/
- path = g_file_get_path (file);
- if (path == NULL) {
- g_warning ("Couldn't mmap %s: couldn't get path", path);
- g_object_unref (file);
- return mapped_file;
- }
- g_object_unref (file);
-
- mapped_file = g_mapped_file_new (path, FALSE, &error);
- if (mapped_file == NULL) {
- g_warning ("Unable to map file %s: %s", path, error->message);
- }
-
- g_free (path);
+ path = g_file_get_path (file);
+ if (path == NULL) {
+ g_warning ("Couldn't mmap %s: couldn't get path", path);
+ g_object_unref (file);
+ return mapped_file;
+ }
+ g_object_unref (file);
+
+ mapped_file = g_mapped_file_new (path, FALSE, &error);
+ if (mapped_file == NULL) {
+ g_warning ("Unable to map file %s: %s", path, error->message);
+ }
+
+ g_free (path);
return mapped_file;
}
static void
-add_entry_to_mlcl (gpointer id,
- DMAPRecord *record,
- gpointer _mb)
+add_entry_to_mlcl (gpointer id, DMAPRecord * record, gpointer _mb)
{
GNode *mlit;
struct MLCL_Bits *mb = (struct MLCL_Bits *) _mb;
+
mlit = dmap_structure_add (mb->mlcl, DMAP_CC_MLIT);
if (_dmap_share_client_requested (mb->bits, ITEM_KIND))
- dmap_structure_add (mlit, DMAP_CC_MIKD, (gchar) DPAP_ITEM_KIND_PHOTO);
+ dmap_structure_add (mlit, DMAP_CC_MIKD,
+ (gchar) DPAP_ITEM_KIND_PHOTO);
if (_dmap_share_client_requested (mb->bits, ITEM_ID))
- dmap_structure_add (mlit, DMAP_CC_MIID, GPOINTER_TO_UINT (id));
+ dmap_structure_add (mlit, DMAP_CC_MIID,
+ GPOINTER_TO_UINT (id));
if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) {
gchar *filename = NULL;
+
g_object_get (record, "filename", &filename, NULL);
if (filename) {
dmap_structure_add (mlit, DMAP_CC_MINM, filename);
@@ -373,25 +372,30 @@ add_entry_to_mlcl (gpointer id,
g_warning ("Filename requested but not available");
}
if (_dmap_share_client_requested (mb->bits, PERSISTENT_ID))
- dmap_structure_add (mlit, DMAP_CC_MPER, GPOINTER_TO_UINT (id));
+ dmap_structure_add (mlit, DMAP_CC_MPER,
+ GPOINTER_TO_UINT (id));
if (TRUE) {
/* dpap-sharp claims iPhoto '08 will not show thumbnails without PASP
* and this does seem to be the case when testing. */
gchar *aspect_ratio = NULL;
+
g_object_get (record, "aspect-ratio", &aspect_ratio, NULL);
if (aspect_ratio) {
dmap_structure_add (mlit, DMAP_CC_PASP, aspect_ratio);
g_free (aspect_ratio);
} else
- g_warning ("Aspect ratio requested but not available");
+ g_warning
+ ("Aspect ratio requested but not available");
}
if (_dmap_share_client_requested (mb->bits, PHOTO_CREATIONDATE)) {
gint creation_date = 0;
+
g_object_get (record, "creation-date", &creation_date, NULL);
dmap_structure_add (mlit, DMAP_CC_PICD, creation_date);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFILENAME)) {
gchar *filename = NULL;
+
g_object_get (record, "filename", &filename, NULL);
if (filename) {
dmap_structure_add (mlit, DMAP_CC_PIMF, filename);
@@ -401,6 +405,7 @@ add_entry_to_mlcl (gpointer id,
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFORMAT)) {
gchar *format = NULL;
+
g_object_get (record, "format", &format, NULL);
if (format) {
dmap_structure_add (mlit, DMAP_CC_PFMT, format);
@@ -411,31 +416,39 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFILESIZE)) {
GByteArray *thumbnail = NULL;
gint filesize = 0;
+
g_object_get (record, "thumbnail", &thumbnail, NULL);
- dmap_structure_add (mlit, DMAP_CC_PIFS, thumbnail ? thumbnail->len : 0);
+ dmap_structure_add (mlit, DMAP_CC_PIFS,
+ thumbnail ? thumbnail->len : 0);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGELARGEFILESIZE)) {
gint large_filesize = 0;
- g_object_get (record, "large-filesize", &large_filesize, NULL);
+
+ g_object_get (record, "large-filesize", &large_filesize,
+ NULL);
dmap_structure_add (mlit, DMAP_CC_PLSZ, large_filesize);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEPIXELHEIGHT)) {
gint pixel_height = 0;
+
g_object_get (record, "pixel-height", &pixel_height, NULL);
dmap_structure_add (mlit, DMAP_CC_PHGT, pixel_height);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEPIXELWIDTH)) {
gint pixel_width = 0;
+
g_object_get (record, "pixel-width", &pixel_width, NULL);
dmap_structure_add (mlit, DMAP_CC_PWTH, pixel_width);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGERATING)) {
gint rating = 0;
+
g_object_get (record, "rating", &rating, NULL);
dmap_structure_add (mlit, DMAP_CC_PRAT, rating);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGECOMMENTS)) {
gchar *comments = NULL;
+
g_object_get (record, "comments", &comments, NULL);
if (comments) {
dmap_structure_add (mlit, DMAP_CC_PCMT, comments);
@@ -447,6 +460,7 @@ add_entry_to_mlcl (gpointer id,
size_t size = 0;
unsigned char *data = NULL;
GByteArray *thumbnail = NULL;
+
if (_dmap_share_client_requested (mb->bits, PHOTO_THUMB)) {
g_object_get (record, "thumbnail", &thumbnail, NULL);
if (thumbnail) {
@@ -458,6 +472,7 @@ add_entry_to_mlcl (gpointer id,
} else {
/* Should be PHOTO_HIRES */
char *location = NULL;
+
g_object_get (record, "location", &location, NULL);
if (mapped_file) {
/* Free any previously mapped image */
@@ -471,7 +486,9 @@ add_entry_to_mlcl (gpointer id,
data = NULL;
size = 0;
} else {
- data = (unsigned char *) g_mapped_file_get_contents (mapped_file);
+ data = (unsigned char *)
+ g_mapped_file_get_contents
+ (mapped_file);
size = g_mapped_file_get_length (mapped_file);
}
g_free (location);
@@ -481,18 +498,18 @@ add_entry_to_mlcl (gpointer id,
}
static void
-databases_browse_xxx (DMAPShare *share,
- SoupServer *server,
- SoupMessage *msg,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
+databases_browse_xxx (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * msg,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
g_warning ("Unhandled: %s\n", path);
}
static void
-send_chunked_file (SoupServer *server, SoupMessage *message, DPAPRecord *record, guint64 filesize)
+send_chunked_file (SoupServer * server, SoupMessage * message,
+ DPAPRecord * record, guint64 filesize)
{
GInputStream *stream;
const char *location;
@@ -508,7 +525,8 @@ send_chunked_file (SoupServer *server, SoupMessage *message, DPAPRecord *record,
if (error != NULL) {
g_warning ("Couldn't open %s: %s.", location, error->message);
g_error_free (error);
- soup_message_set_status (message, SOUP_STATUS_INTERNAL_SERVER_ERROR);
+ soup_message_set_status (message,
+ SOUP_STATUS_INTERNAL_SERVER_ERROR);
g_free (cd);
return;
}
@@ -521,25 +539,32 @@ send_chunked_file (SoupServer *server, SoupMessage *message, DPAPRecord *record,
return;
}
- soup_message_headers_set_encoding (message->response_headers, SOUP_ENCODING_CONTENT_LENGTH);
- soup_message_headers_set_content_length (message->response_headers, filesize);
-
- soup_message_headers_append (message->response_headers, "Connection", "Close");
- soup_message_headers_append (message->response_headers, "Content-Type", "application/x-dmap-tagged");
-
- g_signal_connect (message, "wrote_headers", G_CALLBACK (dmap_write_next_chunk), cd);
- g_signal_connect (message, "wrote_chunk", G_CALLBACK (dmap_write_next_chunk), cd);
- g_signal_connect (message, "finished", G_CALLBACK (dmap_chunked_message_finished), cd);
+ soup_message_headers_set_encoding (message->response_headers,
+ SOUP_ENCODING_CONTENT_LENGTH);
+ soup_message_headers_set_content_length (message->response_headers,
+ filesize);
+
+ soup_message_headers_append (message->response_headers, "Connection",
+ "Close");
+ soup_message_headers_append (message->response_headers,
+ "Content-Type",
+ "application/x-dmap-tagged");
+
+ g_signal_connect (message, "wrote_headers",
+ G_CALLBACK (dmap_write_next_chunk), cd);
+ g_signal_connect (message, "wrote_chunk",
+ G_CALLBACK (dmap_write_next_chunk), cd);
+ g_signal_connect (message, "finished",
+ G_CALLBACK (dmap_chunked_message_finished), cd);
/* NOTE: cd g_free'd by chunked_message_finished(). */
}
static void
-databases_items_xxx (DMAPShare *share,
- SoupServer *server,
- SoupMessage *msg,
- const char *path,
- GHashTable *query,
- SoupClientContext *context)
+databases_items_xxx (DMAPShare * share,
+ SoupServer * server,
+ SoupMessage * msg,
+ const char *path,
+ GHashTable * query, SoupClientContext * context)
{
DMAPDb *db;
const gchar *rest_of_path;
@@ -557,16 +582,16 @@ databases_items_xxx (DMAPShare *share,
g_object_get (record, "large-filesize", &filesize, NULL);
DMAP_SHARE_GET_CLASS (share)->message_add_standard_headers
- (share, msg);
+ (share, msg);
soup_message_set_status (msg, SOUP_STATUS_OK);
send_chunked_file (server, msg, record, filesize);
-
+
g_object_unref (record);
}
static struct DMAPMetaDataMap *
-get_meta_data_map (DMAPShare *share)
+get_meta_data_map (DMAPShare * share)
{
- return meta_data_map;
+ return meta_data_map;
}
diff --git a/libdmapsharing/dpap-share.h b/libdmapsharing/dpap-share.h
index 5f5ab94..fd3f4f3 100644
--- a/libdmapsharing/dpap-share.h
+++ b/libdmapsharing/dpap-share.h
@@ -29,7 +29,6 @@
#include <libdmapsharing/dmap-share.h>
G_BEGIN_DECLS
-
/**
* DPAP_TYPE_SHARE:
*
@@ -80,19 +79,20 @@ G_BEGIN_DECLS
*/
#define DPAP_SHARE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
DPAP_TYPE_SHARE, DPAPShareClass))
-
typedef struct DPAPSharePrivate DPAPSharePrivate;
-typedef struct {
+typedef struct
+{
DMAPShareClass dmap_share_class;
} DPAPShareClass;
-typedef struct {
+typedef struct
+{
DMAPShare dmap_share_instance;
DPAPSharePrivate *priv;
} DPAPShare;
-GType dpap_share_get_type (void);
+GType dpap_share_get_type (void);
/**
* dpap_share_new:
@@ -106,9 +106,9 @@ GType dpap_share_get_type (void);
*
* Returns: a pointer to a DPAPShare.
*/
-DPAPShare *dpap_share_new (const char *name, const char *password,
- gpointer db, gpointer container_db,
- gchar *transcode_mimetype);
+DPAPShare *dpap_share_new (const char *name, const char *password,
+ gpointer db, gpointer container_db,
+ gchar * transcode_mimetype);
#endif /* __DPAP_SHARE_H */
diff --git a/libdmapsharing/gst-util.c b/libdmapsharing/gst-util.c
index a62db06..ebff1cb 100644
--- a/libdmapsharing/gst-util.c
+++ b/libdmapsharing/gst-util.c
@@ -24,7 +24,7 @@
#include "dmap-gst-input-stream.h"
gboolean
-pads_compatible (GstPad *pad1, GstPad *pad2)
+pads_compatible (GstPad * pad1, GstPad * pad2)
{
gboolean fnval;
GstCaps *res, *caps1, *caps2;
@@ -32,7 +32,7 @@ pads_compatible (GstPad *pad1, GstPad *pad2)
caps1 = gst_pad_get_caps (pad1);
caps2 = gst_pad_get_caps (pad2);
res = gst_caps_intersect (caps1, caps2);
- fnval = res && ! gst_caps_is_empty (res);
+ fnval = res && !gst_caps_is_empty (res);
gst_caps_unref (res);
gst_caps_unref (caps2);
diff --git a/libdmapsharing/gst-util.h b/libdmapsharing/gst-util.h
index 4dffb60..66f33c8 100644
--- a/libdmapsharing/gst-util.h
+++ b/libdmapsharing/gst-util.h
@@ -23,7 +23,7 @@
#include <gst/gst.h>
-gboolean pads_compatible (GstPad *pad1, GstPad *pad2);
+gboolean pads_compatible (GstPad * pad1, GstPad * pad2);
#endif /* __GST_UTIL */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]