[libdmapsharing] Many small changes after running pedansee
- From: W. Michael Petullo <wmpetullo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdmapsharing] Many small changes after running pedansee
- Date: Wed, 7 Mar 2018 02:04:24 +0000 (UTC)
commit fecabc23ddce6be16a707c1542875b962f5df596
Author: W. Michael Petullo <mike flyn org>
Date: Tue Mar 6 21:04:11 2018 -0500
Many small changes after running pedansee
Signed-off-by: W. Michael Petullo <mike flyn org>
README-Porting | 8 +
.../{libdmapsharing.spec => libdmapsharing4.spec} | 12 +-
libdmapsharing/Makefile.am | 23 +-
libdmapsharing/dmap-av-connection.h | 6 +-
libdmapsharing/dmap-av-record.c | 11 +-
libdmapsharing/dmap-av-record.h | 6 +-
libdmapsharing/dmap-av-share.c | 498 ++++++++++---
libdmapsharing/dmap-av-share.h | 6 +-
libdmapsharing/dmap-cc.h | 176 +++++
libdmapsharing/dmap-connection-private.h | 25 +
libdmapsharing/dmap-connection.c | 442 +++++++------
libdmapsharing/dmap-connection.h | 8 +-
libdmapsharing/dmap-container-db.h | 6 +-
libdmapsharing/dmap-container-record.h | 6 +-
libdmapsharing/dmap-control-connection.c | 12 +-
libdmapsharing/dmap-control-connection.h | 6 +-
libdmapsharing/dmap-control-share.c | 212 +++---
libdmapsharing/dmap-control-share.h | 6 +-
libdmapsharing/dmap-db.c | 61 +-
libdmapsharing/dmap-db.h | 8 +-
libdmapsharing/dmap-gst-input-stream.h | 6 +-
libdmapsharing/dmap-gst-mp3-input-stream.h | 6 +-
libdmapsharing/dmap-gst-qt-input-stream.h | 6 +-
libdmapsharing/dmap-gst-wav-input-stream.h | 6 +-
libdmapsharing/dmap-image-connection.h | 6 +-
libdmapsharing/dmap-image-record.h | 6 +-
libdmapsharing/dmap-image-share.h | 6 +-
libdmapsharing/dmap-md5.c | 272 ++++----
libdmapsharing/dmap-md5.h | 24 +-
libdmapsharing/dmap-mdns-avahi.h | 4 +-
libdmapsharing/dmap-mdns-browser.h | 4 +-
libdmapsharing/dmap-mdns-publisher-avahi.c | 2 +-
libdmapsharing/dmap-mdns-publisher.h | 6 +-
libdmapsharing/dmap-mdns-service.h | 4 +-
libdmapsharing/dmap-record-factory.h | 6 +-
libdmapsharing/dmap-record.h | 6 +-
libdmapsharing/dmap-share.c | 2 +-
libdmapsharing/dmap-share.h | 6 +-
libdmapsharing/dmap-structure.h | 172 +-----
libdmapsharing/dmap.h | 6 +-
libdmapsharing/gst-util.h | 6 +-
libdmapsharing/test-dmap-av-record-factory.h | 6 +-
libdmapsharing/test-dmap-av-record.h | 6 +-
libdmapsharing/test-dmap-container-db.h | 6 +-
libdmapsharing/test-dmap-container-record.h | 6 +-
libdmapsharing/test-dmap-db.h | 6 +-
libdmapsharing/test-dmap-image-record-factory.h | 6 +-
libdmapsharing/test-dmap-image-record.h | 6 +-
tests/dacplisten.c | 2 +-
tests/dmapcopy.c | 7 +-
tests/dmapserve.c | 7 +-
tests/vala-dmap-container-db.c | 2 +-
vala/libdmapsharing-4.0.vapi | 732 --------------------
53 files changed, 1273 insertions(+), 1619 deletions(-)
---
diff --git a/README-Porting b/README-Porting
index 2dc8f32..e79b823 100644
--- a/README-Porting
+++ b/README-Porting
@@ -39,6 +39,14 @@ instead of "Iface".
dmap_connection_connect became dmap_connection_start.
+ The dmap_hash functions became dmap_md5 functions.
+
+ DACP_PLAY_STOPPED and so on became, for example, CONTROL_PLAY_STOPPED.
+
+ DACPRepeatState became DmapControlRepeatState.
+
+ DACPPlayState became DmapControlPlayState.
+
(4) The new API replaces the use of GHFunc with DMAPIdRecordFunc and
DMAPContainerIdFunc.
diff --git a/distro/libdmapsharing.spec b/distro/libdmapsharing4.spec
similarity index 96%
rename from distro/libdmapsharing.spec
rename to distro/libdmapsharing4.spec
index c1217af..edf5035 100644
--- a/distro/libdmapsharing.spec
+++ b/distro/libdmapsharing4.spec
@@ -1,8 +1,8 @@
-Name: libdmapsharing
+Name: libdmapsharing4
Version: 3.9.0
Release: 1%{?dist}
License: LGPLv2+
-Source: http://www.flyn.org/projects/libdmapsharing/%{name}-%{version}.tar.gz
+Source: http://www.flyn.org/projects/libdmapsharing/libdmapsharing-%{version}.tar.gz
URL: http://www.flyn.org/projects/libdmapsharing/
Summary: A DMAP client and server library
Group: Development/Libraries
@@ -33,11 +33,9 @@ other resources needed for developing applications using libdmapsharing.
%{_libdir}/pkgconfig/libdmapsharing-4.0.pc
%{_includedir}/libdmapsharing-4.0/
%{_libdir}/libdmapsharing-4.0.so
-%{_libdir}/girepository-1.0/DMAP-4.0.typelib
-%{_libdir}/girepository-1.0/DAAP-4.0.typelib
+%{_libdir}/girepository-1.0/Dmap-4.0.typelib
%{_datadir}/gtk-doc/html/libdmapsharing-4.0
-%{_datadir}/gir-1.0/DMAP-4.0.gir
-%{_datadir}/gir-1.0/DAAP-4.0.gir
+%{_datadir}/gir-1.0/Dmap-4.0.gir
%package vala
Summary: Vala language bindings for libdmapsharing
@@ -53,7 +51,7 @@ libdmapsharing.
%{_datadir}/vala/vapi/libdmapsharing-4.0.vapi
%prep
-%setup -q
+%setup -q -n libdmapsharing-%{version}
%build
%configure --disable-static --disable-tests --disable-check
diff --git a/libdmapsharing/Makefile.am b/libdmapsharing/Makefile.am
index 7e2bb3e..6ddc8cd 100644
--- a/libdmapsharing/Makefile.am
+++ b/libdmapsharing/Makefile.am
@@ -88,6 +88,7 @@ libdmapsharinginclude_HEADERS = \
dmap-av-connection.h \
dmap-av-record.h \
dmap-av-share.h \
+ dmap-cc.h \
dmap-control-connection.h \
dmap-control-share.h \
dmap-control-player.h \
@@ -152,10 +153,10 @@ dmap-enums.c: $(libdmapsharinginclude_headers) Makefile dmap-enums.h
dmap-enums.h: $(libdmapsharinginclude_HEADERS) Makefile
@glib-mkenums \
- --fhead "/* Automatically generated by glib-mkenums */\n\n#ifndef
DMAP_ENUMS_H\n#define DMAP_ENUMS_H\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n\n" \
+ --fhead "/* Automatically generated by glib-mkenums */\n\n#ifndef
_DMAP_ENUMS_H\n#define _DMAP_ENUMS_H\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n\n" \
--fprod "\n/* enumerations from \"@filename@\" */\n" \
--vhead "GType @enum_name@_get_type (void) G_GNUC_CONST;\n#define
DMAP_TYPE_@ENUMNAME@ (@enum_name@_get_type())\n" \
- --ftail "G_END_DECLS\n\n#endif /* !DMAP_ENUMS_H */" $(addprefix
$(srcdir)/,$(libdmapsharinginclude_HEADERS)) > $@.tmp \
+ --ftail "G_END_DECLS\n\n#endif /* _DMAP_ENUMS_H */" $(addprefix
$(srcdir)/,$(libdmapsharinginclude_HEADERS)) > $@.tmp \
&& sed -e "s/d_map/dmap/" -e "s/D_MAP/DMAP/" -e "s/d_acp/dacp/" -e "s/D_ACP/DACP/" $@.tmp > $@ \
&& rm -f $@.tmp
@@ -191,7 +192,20 @@ endif
check:
if HAVE_PEDANSEE
- echo "[ignore]" > pedansee.conf
+ echo "[flags]" > pedansee.conf
+ echo " skip-unit-test-present = true" >> pedansee.conf
+ echo " skip-return-value-used = true" >> pedansee.conf
+ echo "[ignore-return-check]" >> pedansee.conf
+ echo " # Ignore dmap_structure_add; return cannot indicate error." >> pedansee.conf
+ echo " # Ignore g_object_ref; return value merely a convenience." >> pedansee.conf
+ echo -n " name = " >> pedansee.conf
+ echo -n "dmap_structure_add;" >> pedansee.conf
+ echo -n "g_object_ref;" >> pedansee.conf
+ echo -n "g_string_ascii_up;" >> pedansee.conf
+ echo -n "g_string_append_len;" >> pedansee.conf
+ echo >> pedansee.conf
+ echo "[ignore-entirely]" >> pedansee.conf
+ echo " # Ignore CPP-generated GObject code." >> pedansee.conf
echo -n " name = " >> pedansee.conf
for i in $$(grep G_DEFINE_INTERFACE *.c | sed 's/[^,]*, \([^,]*\),.*/\1/g'); do \
echo -n $${i}_default_init\;; \
@@ -209,6 +223,9 @@ if HAVE_PEDANSEE
echo -n $${i}_private_offset\;; \
done >> pedansee.conf
set -e; for i in $(libdmapsharing_4_0_la_SOURCES); do \
+ if [ $$i = dmap-enums.c ]; then # Skip this generated code. \
+ continue; \
+ fi; \
$(PEDANSEE) -c pedansee.conf $$i -- -x c $(DEFS) $(libdmapsharing_4_0_la_CFLAGS); \
done
set -e; for i in $(libdmapsharinginclude_HEADERS) \
diff --git a/libdmapsharing/dmap-av-connection.h b/libdmapsharing/dmap-av-connection.h
index 21542d7..414d249 100644
--- a/libdmapsharing/dmap-av-connection.h
+++ b/libdmapsharing/dmap-av-connection.h
@@ -14,8 +14,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_AV_CONNECTION_H
-#define __DMAP_AV_CONNECTION_H
+#ifndef _DMAP_AV_CONNECTION_H
+#define _DMAP_AV_CONNECTION_H
#include <glib-object.h>
@@ -104,4 +104,4 @@ DmapAvConnection *dmap_av_connection_new (const char *name,
DmapRecordFactory * factory);
G_END_DECLS
-#endif /* __DMAP_AV_CONNECTION_H */
+#endif /* _DMAP_AV_CONNECTION_H */
diff --git a/libdmapsharing/dmap-av-record.c b/libdmapsharing/dmap-av-record.c
index 875ac37..bc04242 100644
--- a/libdmapsharing/dmap-av-record.c
+++ b/libdmapsharing/dmap-av-record.c
@@ -266,7 +266,7 @@ START_TEST(dmap_av_record_read_test)
DmapAvRecord *record;
GInputStream *stream;
GError *error = NULL;
- gssize count;
+ gssize count1, count2;
char buf[PATH_MAX];
char template[PATH_MAX];
char uri[PATH_MAX];
@@ -280,11 +280,13 @@ START_TEST(dmap_av_record_read_test)
}
/* Use randomization of template name for test data. */
- count = write(tmp, template, strlen(template));
- if (-1 == count) {
+ count1 = write(tmp, template, strlen(template));
+ if (-1 == count1) {
ck_abort();
}
+ ck_assert_int_eq(count1, strlen(template));
+
sprintf(uri, "file://%s", template);
record = DMAP_AV_RECORD(test_dmap_av_record_new());
@@ -294,12 +296,13 @@ START_TEST(dmap_av_record_read_test)
ck_assert(NULL == error);
- count = g_input_stream_read(stream,
+ count2 = g_input_stream_read(stream,
buf,
BUFSIZ,
NULL,
&error);
ck_assert(NULL == error);
+ ck_assert_int_eq(count1, count2);
ck_assert_str_eq(buf, template);
g_input_stream_close(stream, NULL, NULL);
diff --git a/libdmapsharing/dmap-av-record.h b/libdmapsharing/dmap-av-record.h
index 44c8ea1..4b772d9 100644
--- a/libdmapsharing/dmap-av-record.h
+++ b/libdmapsharing/dmap-av-record.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_AV_RECORD_H
-#define __DMAP_AV_RECORD_H
+#ifndef _DMAP_AV_RECORD_H
+#define _DMAP_AV_RECORD_H
#include <glib.h>
#include <gio/gio.h>
@@ -104,6 +104,6 @@ GInputStream *dmap_av_record_read (DmapAvRecord * record, GError ** err);
*/
gint dmap_av_record_cmp_by_album (gpointer a, gpointer b, DmapDb * db);
-#endif /* __DMAP_AV_RECORD_H */
+#endif /* _DMAP_AV_RECORD_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-av-share.c b/libdmapsharing/dmap-av-share.c
index 0d1737c..8ecc183 100644
--- a/libdmapsharing/dmap-av-share.c
+++ b/libdmapsharing/dmap-av-share.c
@@ -52,20 +52,20 @@ void dmap_av_share_server_info (DmapShare * share,
GHashTable * query, SoupClientContext * context);
void dmap_av_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,
- const char *path,
- GHashTable * query,
- SoupClientContext * context);
-static struct DmapMetaDataMap *get_meta_data_map (DmapShare * share);
-static void add_entry_to_mlcl (guint id, DmapRecord * record, gpointer mb);
+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,
+ const char *path,
+ GHashTable * query,
+ SoupClientContext * context);
+static struct DmapMetaDataMap *_get_meta_data_map (DmapShare * share);
+static void _add_entry_to_mlcl (guint id, DmapRecord * record, gpointer mb);
#define DAAP_TYPE_OF_SERVICE "_daap._tcp"
#define DAAP_PORT 3689
@@ -82,10 +82,10 @@ dmap_av_share_class_init (DmapAvShareClass * klass)
parent_class->get_type_of_service = dmap_av_share_get_type_of_service;
parent_class->message_add_standard_headers =
dmap_av_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->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 = dmap_av_share_server_info;
}
@@ -113,9 +113,19 @@ dmap_av_share_new (const char *name,
"transcode-mimetype",
transcode_mimetype, NULL));
- _dmap_share_server_start (DMAP_SHARE (share));
- _dmap_share_publish_start (DMAP_SHARE (share));
+ if (!_dmap_share_server_start (DMAP_SHARE (share))) {
+ g_object_unref(share);
+ share = NULL;
+ goto done;
+ }
+
+ if (!_dmap_share_publish_start (DMAP_SHARE (share))) {
+ g_object_unref(share);
+ share = NULL;
+ goto done;
+ }
+done:
return share;
}
@@ -256,7 +266,7 @@ typedef enum
PARENT_CONTAINER_ID
} DAAPMetaData;
-static struct DmapMetaDataMap meta_data_map[] = {
+static struct DmapMetaDataMap _meta_data_map[] = {
{"dmap.itemid", ITEM_ID},
{"dmap.itemname", ITEM_NAME},
{"dmap.itemkind", ITEM_KIND},
@@ -307,7 +317,10 @@ static struct DmapMetaDataMap meta_data_map[] = {
#define DAAP_ITEM_KIND_AUDIO 2
#define DAAP_SONG_DATA_KIND_NONE 0
-static gboolean should_transcode (const gchar *format, const gboolean has_video, const gchar
*transcode_mimetype)
+static gboolean
+_should_transcode (const gchar *format,
+ const gboolean has_video,
+ const gchar *transcode_mimetype)
{
gboolean fnval = FALSE;
char *format2 = NULL;
@@ -340,7 +353,7 @@ done:
}
static void
-send_chunked_file (SoupServer * server, SoupMessage * message,
+_send_chunked_file (SoupServer * server, SoupMessage * message,
DmapAvRecord * record, guint64 filesize, guint64 offset,
const gchar * transcode_mimetype)
{
@@ -379,7 +392,7 @@ send_chunked_file (SoupServer * server, SoupMessage * message,
}
// Not presently transcoding videos (see also same comments elsewhere).
- if (should_transcode (format, has_video, transcode_mimetype)) {
+ if (_should_transcode (format, has_video, transcode_mimetype)) {
#ifdef HAVE_GSTREAMERAPP
cd->original_stream = stream;
cd->stream = dmap_gst_input_stream_new (transcode_mimetype, stream);
@@ -410,8 +423,8 @@ send_chunked_file (SoupServer * server, SoupMessage * message,
/* Free memory after each chunk sent out over network. */
soup_message_body_set_accumulate (message->response_body, FALSE);
- if (! should_transcode (format, has_video, transcode_mimetype)) {
- /* NOTE: iTunes seems to require this or it stops reading
+ if (! _should_transcode (format, has_video, transcode_mimetype)) {
+ /* 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.
*/
@@ -441,26 +454,45 @@ send_chunked_file (SoupServer * server, SoupMessage * message,
"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);
+ if (0 == g_signal_connect (message, "wrote_headers",
+ G_CALLBACK (dmap_write_next_chunk), cd)) {
+ g_warning ("Error connecting to wrote_headers signal.");
+ goto done;
+ }
+
+ if (0 == g_signal_connect (message, "wrote_chunk",
+ G_CALLBACK (dmap_write_next_chunk), cd)) {
+ g_warning ("Error connecting to wrote_chunk signal.");
+ goto done;
+ }
+
+ if (0 == g_signal_connect (message, "finished",
+ G_CALLBACK (dmap_chunked_message_finished), cd)) {
+ g_warning ("Error connecting to finished signal.");
+ goto done;
+ }
/* NOTE: cd g_free'd by chunked_message_finished(). */
teardown = FALSE;
done:
if (teardown) {
+ gboolean ok;
+
soup_message_set_status (message, SOUP_STATUS_INTERNAL_SERVER_ERROR);
if (NULL != cd && NULL != cd->stream) {
- g_input_stream_close (cd->stream, NULL, NULL);
+ ok = g_input_stream_close (cd->stream, NULL, &error);
+ if (!ok) {
+ g_warning ("Error closing transcode stream: %s.", error->message);
+ }
}
if (NULL != stream) {
- g_input_stream_close (stream, NULL, NULL);
+ ok = g_input_stream_close (stream, NULL, &error);
+ if (!ok) {
+ g_warning ("Error closing stream: %s.", error->message);
+ }
}
g_free (cd);
@@ -478,7 +510,7 @@ done:
}
static void
-add_entry_to_mlcl (guint id, DmapRecord * record, gpointer _mb)
+_add_entry_to_mlcl (guint id, DmapRecord * record, gpointer _mb)
{
GNode *mlit;
gboolean has_video = 0;
@@ -487,11 +519,15 @@ add_entry_to_mlcl (guint id, DmapRecord * record, gpointer _mb)
mlit = dmap_structure_add (mb->mlcl, DMAP_CC_MLIT);
g_object_get (record, "has-video", &has_video, NULL);
- if (_dmap_share_client_requested (mb->bits, ITEM_KIND))
+ if (_dmap_share_client_requested (mb->bits, ITEM_KIND)) {
dmap_structure_add (mlit, DMAP_CC_MIKD,
(gchar) DAAP_ITEM_KIND_AUDIO);
- if (_dmap_share_client_requested (mb->bits, ITEM_ID))
+ }
+
+ if (_dmap_share_client_requested (mb->bits, ITEM_ID)) {
dmap_structure_add (mlit, DMAP_CC_MIID, id);
+ }
+
if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) {
gchar *title = NULL;
@@ -499,16 +535,24 @@ add_entry_to_mlcl (guint id, DmapRecord * record, gpointer _mb)
if (title) {
dmap_structure_add (mlit, DMAP_CC_MINM, title);
g_free (title);
- } else
+ } else {
g_debug ("Title requested but not available");
+ }
}
- if (_dmap_share_client_requested (mb->bits, PERSISTENT_ID))
+
+ if (_dmap_share_client_requested (mb->bits, PERSISTENT_ID)) {
dmap_structure_add (mlit, DMAP_CC_MPER, id);
- if (_dmap_share_client_requested (mb->bits, CONTAINER_ITEM_ID))
+ }
+
+ if (_dmap_share_client_requested (mb->bits, CONTAINER_ITEM_ID)) {
dmap_structure_add (mlit, DMAP_CC_MCTI, id);
- if (_dmap_share_client_requested (mb->bits, SONG_DATA_KIND))
+ }
+
+ if (_dmap_share_client_requested (mb->bits, SONG_DATA_KIND)) {
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, dmap_av_record_get_format
(DMAP_AV_RECORD (record)), data->session_id);
@@ -520,11 +564,15 @@ add_entry_to_mlcl (guint id, DmapRecord * record, gpointer _mb)
if (album) {
dmap_structure_add (mlit, DMAP_CC_ASAL, album);
g_free (album);
- } else
+ } else {
g_debug ("Album requested but not available");
+ }
}
- if (_dmap_share_client_requested (mb->bits, SONG_GROUPING))
+
+ if (_dmap_share_client_requested (mb->bits, SONG_GROUPING)) {
dmap_structure_add (mlit, DMAP_CC_AGRP, "");
+ }
+
if (_dmap_share_client_requested (mb->bits, SONG_ARTIST)) {
gchar *artist = NULL;
@@ -532,49 +580,70 @@ add_entry_to_mlcl (guint id, DmapRecord * record, gpointer _mb)
if (artist) {
dmap_structure_add (mlit, DMAP_CC_ASAR, artist);
g_free (artist);
- } else
+ } else {
g_debug ("Artist requested but not available");
+ }
}
+
if (_dmap_share_client_requested (mb->bits, SONG_BITRATE)) {
gint32 bitrate = 0;
g_object_get (record, "bitrate", &bitrate, NULL);
- if (bitrate != 0)
+ if (bitrate != 0) {
dmap_structure_add (mlit, DMAP_CC_ASBR,
(gint32) bitrate);
+ }
}
- if (_dmap_share_client_requested (mb->bits, SONG_BPM))
+
+ if (_dmap_share_client_requested (mb->bits, SONG_BPM)) {
dmap_structure_add (mlit, DMAP_CC_ASBT, (gint32) 0);
- if (_dmap_share_client_requested (mb->bits, SONG_COMMENT))
+ }
+
+ if (_dmap_share_client_requested (mb->bits, SONG_COMMENT)) {
dmap_structure_add (mlit, DMAP_CC_ASCM, "");
- if (_dmap_share_client_requested (mb->bits, SONG_COMPILATION))
+ }
+
+ if (_dmap_share_client_requested (mb->bits, SONG_COMPILATION)) {
dmap_structure_add (mlit, DMAP_CC_ASCO, (gchar) FALSE);
- if (_dmap_share_client_requested (mb->bits, SONG_COMPOSER))
+ }
+
+ if (_dmap_share_client_requested (mb->bits, SONG_COMPOSER)) {
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);
}
- if (_dmap_share_client_requested (mb->bits, SONG_DISC_COUNT))
+
+ if (_dmap_share_client_requested (mb->bits, SONG_DISC_COUNT)) {
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);
}
- if (_dmap_share_client_requested (mb->bits, SONG_DISABLED))
+
+ if (_dmap_share_client_requested (mb->bits, SONG_DISABLED)) {
dmap_structure_add (mlit, DMAP_CC_ASDB, (gchar) FALSE);
- if (_dmap_share_client_requested (mb->bits, SONG_EQ_PRESET))
+ }
+
+ if (_dmap_share_client_requested (mb->bits, SONG_EQ_PRESET)) {
dmap_structure_add (mlit, DMAP_CC_ASEQ, "");
+ }
+
if (_dmap_share_client_requested (mb->bits, SONG_FORMAT)) {
gchar *format = NULL;
gchar *transcode_mimetype = NULL;
@@ -591,9 +660,11 @@ add_entry_to_mlcl (guint id, DmapRecord * record, gpointer _mb)
if (format) {
dmap_structure_add (mlit, DMAP_CC_ASFM, format);
g_free (format);
- } else
+ } else {
g_debug ("Format requested but not available");
+ }
}
+
if (_dmap_share_client_requested (mb->bits, SONG_GENRE)) {
gchar *genre = NULL;
@@ -601,54 +672,74 @@ add_entry_to_mlcl (guint id, DmapRecord * record, gpointer _mb)
if (genre) {
dmap_structure_add (mlit, DMAP_CC_ASGN, genre);
g_free (genre);
- } else
+ } else {
g_debug ("Genre requested but not available");
+ }
}
- if (_dmap_share_client_requested (mb->bits, SONG_DESCRIPTION))
+
+ if (_dmap_share_client_requested (mb->bits, SONG_DESCRIPTION)) {
dmap_structure_add (mlit, DMAP_CC_ASDT, ""); /* FIXME: e.g., wav audio file */
- if (_dmap_share_client_requested (mb->bits, SONG_RELATIVE_VOLUME))
+ }
+
+ 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))
+ }
+
+ 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);
}
- if (_dmap_share_client_requested (mb->bits, SONG_START_TIME))
+
+ if (_dmap_share_client_requested (mb->bits, SONG_START_TIME)) {
dmap_structure_add (mlit, DMAP_CC_ASST, 0);
- if (_dmap_share_client_requested (mb->bits, SONG_STOP_TIME))
+ }
+
+ if (_dmap_share_client_requested (mb->bits, SONG_STOP_TIME)) {
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));
}
- if (_dmap_share_client_requested (mb->bits, SONG_TRACK_COUNT))
+
+ if (_dmap_share_client_requested (mb->bits, SONG_TRACK_COUNT)) {
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)) {
dmap_structure_add (mlit, DMAP_CC_AEHV, has_video);
}
+
if (_dmap_share_client_requested (mb->bits, SONG_SORT_ARTIST)) {
gchar *sort_artist = NULL;
@@ -660,6 +751,7 @@ add_entry_to_mlcl (guint id, DmapRecord * record, gpointer _mb)
g_debug ("Sort artist requested but not available");
}
}
+
if (_dmap_share_client_requested (mb->bits, SONG_SORT_ALBUM)) {
gchar *sort_album = NULL;
@@ -671,6 +763,7 @@ add_entry_to_mlcl (guint id, DmapRecord * record, gpointer _mb)
g_debug ("Sort album requested but not available");
}
}
+
if (_dmap_share_client_requested (mb->bits, SONG_MEDIAKIND)) {
gint mediakind = 0;
@@ -680,43 +773,67 @@ add_entry_to_mlcl (guint id, DmapRecord * record, gpointer _mb)
}
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)
+ if (!genre) {
return;
- if (!g_hash_table_lookup (ht, genre))
- g_hash_table_insert (ht, (gchar *) genre, NULL);
+ }
+
+ if (!g_hash_table_lookup (ht, genre)) {
+ gboolean ok;
+
+ ok = g_hash_table_insert (ht, (gchar *) genre, NULL);
+ if (!ok) {
+ g_warning("error inserting %s\n", genre);
+ }
+ }
}
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)
+ if (!artist) {
return;
- if (!g_hash_table_lookup (ht, artist))
- g_hash_table_insert (ht, (gchar *) artist, NULL);
+ }
+
+ if (!g_hash_table_lookup (ht, artist)) {
+ gboolean ok;
+
+ ok = g_hash_table_insert (ht, (gchar *) artist, NULL);
+ if (!ok) {
+ g_warning("error inserting %s\n", artist);
+ }
+ }
}
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)
+ if (!album) {
return;
- if (!g_hash_table_lookup (ht, album))
- g_hash_table_insert (ht, (gchar *) album, NULL);
+ }
+
+ if (!g_hash_table_lookup (ht, album)) {
+ gboolean ok;
+
+ ok = g_hash_table_insert (ht, (gchar *) album, NULL);
+ if (!ok) {
+ g_warning("error inserting %s\n", album);
+ }
+ }
}
static void
-add_to_category_listing (gpointer key, gpointer user_data)
+_add_to_category_listing (gpointer key, gpointer user_data)
{
GNode *mlit;
GNode *node = (GNode *) user_data;
@@ -726,11 +843,11 @@ add_to_category_listing (gpointer key, gpointer user_data)
}
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)
{
/* ABRO database browse
* MSTT status
@@ -763,15 +880,15 @@ 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,
+ 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,
+ 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,
+ g_hash_table_foreach (filtered, (GHFunc) _album_tabulator,
category_items);
category_cc = DMAP_CC_ABAL;
} else {
@@ -797,7 +914,7 @@ databases_browse_xxx (DmapShare * share,
(GCompareFunc) g_ascii_strcasecmp);
}
- g_list_foreach (values, add_to_category_listing, node);
+ g_list_foreach (values, _add_to_category_listing, node);
g_list_free (values);
@@ -811,11 +928,11 @@ databases_browse_xxx (DmapShare * share,
}
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;
gchar *transcode_mimetype = NULL;
@@ -868,7 +985,7 @@ 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,
+ _send_chunked_file (server, msg, record, filesize, offset,
transcode_mimetype);
g_object_unref (record);
@@ -877,9 +994,9 @@ databases_items_xxx (DmapShare * share,
}
static struct DmapMetaDataMap *
-get_meta_data_map (DmapShare * share)
+_get_meta_data_map (DmapShare * share)
{
- return meta_data_map;
+ return _meta_data_map;
}
#ifdef HAVE_CHECK
@@ -894,7 +1011,7 @@ get_meta_data_map (DmapShare * share)
#include <unistd.h>
static DmapShare *
-_build_share(char *name)
+_build_share_test(char *name)
{
DmapDb *db;
DmapContainerRecord *container_record;
@@ -917,6 +1034,7 @@ _build_share(char *name)
g_object_set(record, "songalbum", "album1", NULL);
g_object_set(record, "location", "file:///etc/services", NULL);
g_object_set(record, "filesize", statbuf.st_size, NULL);
+
dmap_db_add(db, record);
if (-1 == stat("/etc/group", &statbuf)) {
@@ -944,9 +1062,160 @@ _build_share(char *name)
return share;
}
+START_TEST(_get_meta_data_map_test)
+{
+ ck_assert_ptr_eq(_meta_data_map, _get_meta_data_map(NULL));
+}
+END_TEST
+
+START_TEST(dmap_av_share_new_test)
+{
+ DmapDb *db;
+ DmapContainerRecord *container_record;
+ DmapContainerDb *container_db;
+ DmapRecord *record;
+ DmapShare *share;
+ char *str;
+
+ db = DMAP_DB(test_dmap_db_new());
+ container_record = DMAP_CONTAINER_RECORD (test_dmap_container_record_new ());
+ container_db = DMAP_CONTAINER_DB(test_dmap_container_db_new(container_record));
+
+
+ record = DMAP_RECORD(test_dmap_av_record_new());
+ g_object_set(record, "songgenre", "genre1", NULL);
+ g_object_set(record, "songartist", "artist1", NULL);
+ g_object_set(record, "songalbum", "album1", NULL);
+
+ dmap_db_add(db, record);
+
+ share = DMAP_SHARE(dmap_av_share_new("name",
+ "password",
+ db,
+ container_db,
+ "audio/mp3"));
+
+ g_object_get(share, "name", &str, NULL);
+ ck_assert_str_eq("name", str);
+ g_free(str);
+
+ g_object_get(share, "password", &str, NULL);
+ ck_assert_str_eq("password", str);
+ g_free(str);
+
+ g_object_get(share, "transcode-mimetype", &str, NULL);
+ ck_assert_str_eq("audio/mp3", str);
+ g_free(str);
+
+ g_object_unref(db);
+ g_object_unref(container_record);
+ g_object_unref(container_db);
+ g_object_unref(share);
+}
+END_TEST
+
+static void
+_tabulator_test(char *property,
+ void (*tabulator) (gpointer id, DmapRecord * record, GHashTable * ht))
+{
+ guint id1, id2;
+ DmapRecord *record1, *record2;
+ DmapDb *db;
+ GHashTable *ht;
+ gboolean ok;
+
+ db = DMAP_DB(test_dmap_db_new());
+
+ record1 = DMAP_RECORD(test_dmap_av_record_new());
+ g_object_set(record1, property, "str1", NULL);
+
+ id1 = dmap_db_add(db, record1);
+
+ record2 = DMAP_RECORD(test_dmap_av_record_new());
+ g_object_set(record2, property, "str2", NULL);
+
+ id2 = dmap_db_add(db, record2);
+
+ ht = g_hash_table_new (g_str_hash, g_str_equal);
+
+ tabulator (GINT_TO_POINTER(id1), record1, ht);
+ tabulator (GINT_TO_POINTER(id2), record2, ht);
+
+ ok = g_hash_table_contains(ht, "str1");
+ ck_assert_int_eq(TRUE, ok);
+
+ ok = g_hash_table_contains(ht, "str2");
+ ck_assert_int_eq(TRUE, ok);
+
+ g_object_unref(record1);
+ g_object_unref(record2);
+ g_object_unref(db);
+ g_hash_table_destroy(ht);
+}
+
+START_TEST(_genre_tabulator_test)
+{
+ _tabulator_test("songgenre", _genre_tabulator);
+}
+END_TEST
+
+START_TEST(_artist_tabulator_test)
+{
+ _tabulator_test("songartist", _artist_tabulator);
+}
+END_TEST
+
+START_TEST(_album_tabulator_test)
+{
+ _tabulator_test("songalbum", _album_tabulator);
+}
+END_TEST
+
+START_TEST(_should_transcode_test)
+{
+ ck_assert_int_eq(FALSE, _should_transcode("mp3", TRUE, "audio/wav"));
+}
+END_TEST
+
+START_TEST(_should_transcode_test_no_trancode_mimetype)
+{
+ ck_assert_int_eq(FALSE, _should_transcode("foo", FALSE, NULL));
+}
+END_TEST
+
+START_TEST(_should_transcode_test_no_trancode_mimetype_unknown_mimetype)
+{
+ ck_assert_int_eq(FALSE, _should_transcode("mp3", FALSE, "foo"));
+}
+END_TEST
+
+START_TEST(_should_transcode_test_no_trancode_mimetype_already_good)
+{
+ ck_assert_int_eq(FALSE, _should_transcode("mp3", FALSE, "audio/mp3"));
+}
+END_TEST
+
+START_TEST(_should_transcode_test_yes_trancode_mimetype_to_wav)
+{
+ ck_assert_int_eq(TRUE, _should_transcode("mp3", FALSE, "audio/wav"));
+}
+END_TEST
+
+START_TEST(_should_transcode_test_yes_trancode_mimetype_to_mp3)
+{
+ ck_assert_int_eq(TRUE, _should_transcode("wav", FALSE, "audio/mp3"));
+}
+END_TEST
+
+START_TEST(_should_transcode_test_yes_trancode_mimetype_to_mp4)
+{
+ ck_assert_int_eq(TRUE, _should_transcode("wav", FALSE, "video/quicktime"));
+}
+END_TEST
+
START_TEST(dmap_av_share_get_desired_port_test)
{
- DmapShare *share = _build_share("dmap_av_share_get_desired_port_test");
+ DmapShare *share = _build_share_test("dmap_av_share_get_desired_port_test");
ck_assert_int_eq(DAAP_PORT, dmap_av_share_get_desired_port(share));
g_object_unref(share);
}
@@ -954,7 +1223,7 @@ END_TEST
START_TEST(dmap_av_share_get_type_of_service_test)
{
- DmapShare *share = _build_share("dmap_av_share_get_type_of_service_test");
+ DmapShare *share = _build_share_test("dmap_av_share_get_type_of_service_test");
ck_assert_str_eq(DAAP_TYPE_OF_SERVICE, dmap_av_share_get_type_of_service(share));
g_object_unref(share);
}
@@ -973,7 +1242,7 @@ START_TEST(dmap_av_share_server_info_test)
GNode *root;
DmapStructureItem *item;
- share = _build_share(nameprop);
+ share = _build_share_test(nameprop);
server = soup_server_new(NULL, NULL);
message = soup_message_new(SOUP_METHOD_GET, "http://test/");
@@ -1047,7 +1316,7 @@ START_TEST(dmap_av_share_message_add_standard_headers_test)
SoupMessage *message;
SoupMessageHeaders *headers;
- share = _build_share("dmap_av_share_message_add_standard_headers_test");
+ share = _build_share_test("dmap_av_share_message_add_standard_headers_test");
message = soup_message_new(SOUP_METHOD_GET, "http://test/");
soup_message_headers_append(message->response_headers,
@@ -1064,7 +1333,7 @@ START_TEST(dmap_av_share_message_add_standard_headers_test)
}
END_TEST
-START_TEST(databases_browse_xxx_test)
+START_TEST(_databases_browse_xxx_test)
{
char *nameprop = "databases_browse_xxx_test";
DmapShare *share;
@@ -1078,14 +1347,14 @@ START_TEST(databases_browse_xxx_test)
GNode *root;
DmapStructureItem *item;
- share = _build_share(nameprop);
+ share = _build_share_test(nameprop);
server = soup_server_new(NULL, NULL);
message = soup_message_new(SOUP_METHOD_GET, "http://test");
query = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(query, "filter", "");
- databases_browse_xxx(share, server, message, "/db/1/browse/genres", query, NULL);
+ _databases_browse_xxx(share, server, message, "/db/1/browse/genres", query, NULL);
g_object_get(message, "response-body", &body, NULL);
buffer = soup_message_body_flatten(body);
@@ -1121,7 +1390,7 @@ START_TEST(databases_browse_xxx_test)
}
END_TEST
-START_TEST(databases_browse_xxx_artists_test)
+START_TEST(_databases_browse_xxx_artists_test)
{
char *nameprop = "databases_browse_xxx_artists_test";
DmapShare *share;
@@ -1134,14 +1403,14 @@ START_TEST(databases_browse_xxx_artists_test)
gsize length;
GNode *root;
- share = _build_share(nameprop);
+ share = _build_share_test(nameprop);
server = soup_server_new(NULL, NULL);
message = soup_message_new(SOUP_METHOD_GET, "http://test");
query = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(query, "filter", "");
- databases_browse_xxx(share, server, message, "/db/1/browse/artists", query, NULL);
+ _databases_browse_xxx(share, server, message, "/db/1/browse/artists", query, NULL);
g_object_get(message, "response-body", &body, NULL);
buffer = soup_message_body_flatten(body);
@@ -1162,7 +1431,7 @@ START_TEST(databases_browse_xxx_artists_test)
}
END_TEST
-START_TEST(databases_browse_xxx_albums_test)
+START_TEST(_databases_browse_xxx_albums_test)
{
char *nameprop = "databases_browse_xxx_albums_test";
DmapShare *share;
@@ -1175,14 +1444,14 @@ START_TEST(databases_browse_xxx_albums_test)
gsize length;
GNode *root;
- share = _build_share(nameprop);
+ share = _build_share_test(nameprop);
server = soup_server_new(NULL, NULL);
message = soup_message_new(SOUP_METHOD_GET, "http://test");
query = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(query, "filter", "");
- databases_browse_xxx(share, server, message, "/db/1/browse/albums", query, NULL);
+ _databases_browse_xxx(share, server, message, "/db/1/browse/albums", query, NULL);
g_object_get(message, "response-body", &body, NULL);
buffer = soup_message_body_flatten(body);
@@ -1203,7 +1472,7 @@ START_TEST(databases_browse_xxx_albums_test)
}
END_TEST
-START_TEST(databases_browse_xxx_bad_category_test)
+START_TEST(_databases_browse_xxx_bad_category_test)
{
char *nameprop = "databases_browse_xxx_bad_category_test";
DmapShare *share;
@@ -1216,14 +1485,14 @@ START_TEST(databases_browse_xxx_bad_category_test)
gsize length;
GNode *root;
- share = _build_share(nameprop);
+ share = _build_share_test(nameprop);
server = soup_server_new(NULL, NULL);
message = soup_message_new(SOUP_METHOD_GET, "http://test");
query = g_hash_table_new(g_str_hash, g_str_equal);
g_hash_table_insert(query, "filter", "");
- databases_browse_xxx(share, server, message, "/db/1/browse/bad_category", query, NULL);
+ _databases_browse_xxx(share, server, message, "/db/1/browse/bad_category", query, NULL);
g_object_get(message, "response-body", &body, NULL);
buffer = soup_message_body_flatten(body);
@@ -1237,7 +1506,7 @@ START_TEST(databases_browse_xxx_bad_category_test)
}
END_TEST
-START_TEST(databases_items_xxx_test)
+START_TEST(_databases_items_xxx_test)
{
char *nameprop = "databases_items_xxx_test";
DmapShare *share;
@@ -1252,17 +1521,16 @@ START_TEST(databases_items_xxx_test)
const guint8 *contents1;
char *location, *contents2, *etag_out;
GFile *file;
- GCancellable cancellable;
GError *error = NULL;
gboolean ok;
- share = _build_share(nameprop);
+ share = _build_share_test(nameprop);
server = soup_server_new(NULL, NULL);
message = soup_message_new(SOUP_METHOD_GET, "http://test");
g_snprintf(path, sizeof path, "/db/1/items/%d", G_MAXINT);
- databases_items_xxx(share, server, message, path, NULL, NULL);
+ _databases_items_xxx(share, server, message, path, NULL, NULL);
g_object_get(share, "db", &db, NULL);
ck_assert(NULL != db);
@@ -1292,7 +1560,7 @@ START_TEST(databases_items_xxx_test)
file = g_file_new_for_uri(location);
ck_assert(NULL != file);
- ok = g_file_load_contents(file, &cancellable, &contents2, &size2, &etag_out, &error);
+ ok = g_file_load_contents(file, NULL, &contents2, &size2, &etag_out, &error);
ck_assert(ok);
ck_assert(size1 == size2);
@@ -1304,7 +1572,7 @@ START_TEST(databases_items_xxx_test)
}
END_TEST
-START_TEST(databases_items_xxx_test_bad_id)
+START_TEST(_databases_items_xxx_test_bad_id)
{
char *nameprop = "databases_items_xxx_test";
DmapShare *share;
@@ -1312,13 +1580,13 @@ START_TEST(databases_items_xxx_test_bad_id)
SoupMessage *message;
char path[PATH_MAX + 1];
- share = _build_share(nameprop);
+ share = _build_share_test(nameprop);
server = soup_server_new(NULL, NULL);
message = soup_message_new(SOUP_METHOD_GET, "http://test");
/* IDs go from G_MAXINT down, so 0 does not exist. */
g_snprintf(path, sizeof path, "/db/1/items/%d", 0);
- databases_items_xxx(share, server, message, path, NULL, NULL);
+ _databases_items_xxx(share, server, message, path, NULL, NULL);
g_object_unref(share);
}
diff --git a/libdmapsharing/dmap-av-share.h b/libdmapsharing/dmap-av-share.h
index c84c93d..fcb8c4c 100644
--- a/libdmapsharing/dmap-av-share.h
+++ b/libdmapsharing/dmap-av-share.h
@@ -21,8 +21,8 @@
*
*/
-#ifndef __DMAP_AV_SHARE_H
-#define __DMAP_AV_SHARE_H
+#ifndef _DMAP_AV_SHARE_H
+#define _DMAP_AV_SHARE_H
#include <glib-object.h>
@@ -113,6 +113,6 @@ DmapAvShare *dmap_av_share_new (const char *name, const char *password,
DmapDb * db, DmapContainerDb * container_db,
gchar * transcode_mimetype);
-#endif /* __DMAP_AV_SHARE_H */
+#endif /* _DMAP_AV_SHARE_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-cc.h b/libdmapsharing/dmap-cc.h
new file mode 100644
index 0000000..19fb927
--- /dev/null
+++ b/libdmapsharing/dmap-cc.h
@@ -0,0 +1,176 @@
+#ifndef _DMAP_CC_H
+#define _DMAP_CC_H
+
+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_CC_MDCL,
+ DMAP_CC_MSTT,
+ DMAP_CC_MIID,
+ DMAP_CC_MINM,
+ DMAP_CC_MIKD,
+ DMAP_CC_MPER,
+ DMAP_CC_MCON,
+ DMAP_CC_MCTI,
+ DMAP_CC_MPCO,
+ DMAP_CC_MSTS,
+ DMAP_CC_MIMC,
+ DMAP_CC_MCTC,
+ DMAP_CC_MRCO,
+ DMAP_CC_MTCO,
+ DMAP_CC_MLCL,
+ DMAP_CC_MLIT,
+ DMAP_CC_MBCL,
+ DMAP_CC_MSRV,
+ DMAP_CC_MSAU,
+ DMAP_CC_MSLR,
+ DMAP_CC_MPRO,
+ DMAP_CC_MSAL,
+ DMAP_CC_MSUP,
+ DMAP_CC_MSPI,
+ DMAP_CC_MSEX,
+ DMAP_CC_MSBR,
+ DMAP_CC_MSQY,
+ DMAP_CC_MSIX,
+ DMAP_CC_MSRS,
+ DMAP_CC_MSTM,
+ DMAP_CC_MSDC,
+ DMAP_CC_MCCR,
+ DMAP_CC_MCNM,
+ DMAP_CC_MCNA,
+ DMAP_CC_MCTY,
+ DMAP_CC_MLOG,
+ DMAP_CC_MLID,
+ DMAP_CC_MUPD,
+ DMAP_CC_MUSR,
+ DMAP_CC_MUTY,
+ DMAP_CC_MUDL,
+ DMAP_CC_MSMA,
+ DMAP_CC_FQUESCH,
+
+ DMAP_CC_APRO,
+ DMAP_CC_AVDB,
+ DMAP_CC_ABRO,
+ DMAP_CC_ABAL,
+ DMAP_CC_ABAR,
+ DMAP_CC_ABCP,
+ DMAP_CC_ABGN,
+ DMAP_CC_ADBS,
+ DMAP_CC_ASAL,
+ DMAP_CC_ASAI,
+ DMAP_CC_ASAA,
+ DMAP_CC_ASAR,
+ DMAP_CC_ASBT,
+ DMAP_CC_ASBR,
+ DMAP_CC_ASCM,
+ DMAP_CC_ASCO,
+ DMAP_CC_ASDA,
+ DMAP_CC_ASDM,
+ DMAP_CC_ASDC,
+ DMAP_CC_ASDN,
+ DMAP_CC_ASDB,
+ DMAP_CC_ASEQ,
+ DMAP_CC_ASFM,
+ DMAP_CC_ASGN,
+ DMAP_CC_ASDT,
+ DMAP_CC_ASRV,
+ DMAP_CC_ASSR,
+ DMAP_CC_ASSZ,
+ DMAP_CC_ASST,
+ DMAP_CC_ASSP,
+ DMAP_CC_ASTM,
+ DMAP_CC_ASTC,
+ DMAP_CC_ASTN,
+ DMAP_CC_ASUR,
+ DMAP_CC_ASYR,
+ DMAP_CC_ASDK,
+ DMAP_CC_ASUL,
+ DMAP_CC_ASSU,
+ DMAP_CC_ASSA,
+ DMAP_CC_APLY,
+ DMAP_CC_ABPL,
+ DMAP_CC_APSO,
+ DMAP_CC_PRSV,
+ DMAP_CC_ARIF,
+ DMAP_CC_MSAS,
+ DMAP_CC_AGRP,
+ DMAP_CC_AGAL,
+ DMAP_CC_ASCP,
+ DMAP_CC_PPRO,
+ DMAP_CC_PASP,
+ DMAP_CC_PFDT,
+ DMAP_CC_PICD,
+ DMAP_CC_PIMF,
+ DMAP_CC_PFMT,
+ DMAP_CC_PIFS,
+ DMAP_CC_PLSZ,
+ DMAP_CC_PHGT,
+ DMAP_CC_PWTH,
+ DMAP_CC_PRAT,
+ DMAP_CC_PCMT,
+ DMAP_CC_PRET,
+
+ /* iTunes 6.02+ */
+ DMAP_CC_AESV,
+ DMAP_CC_AEHV,
+
+ DMAP_CC_AESP,
+ DMAP_CC_AEPP,
+ DMAP_CC_AEPS,
+ 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,
+ DMAP_CC_CARP,
+ DMAP_CC_CAAS,
+ DMAP_CC_CAAR,
+ DMAP_CC_CAIA,
+ DMAP_CC_CANP,
+ DMAP_CC_CANN,
+ DMAP_CC_CANA,
+ DMAP_CC_CANL,
+ DMAP_CC_CANG,
+ DMAP_CC_CANT,
+ DMAP_CC_CASP,
+ DMAP_CC_CASS,
+ DMAP_CC_CAST,
+ DMAP_CC_CASU,
+ DMAP_CC_CASG,
+ DMAP_CC_CACR,
+
+ DMAP_CC_CMCP,
+ DMAP_CC_CMGT,
+ DMAP_CC_CMIK,
+ DMAP_CC_CMSP,
+ DMAP_CC_CMST,
+ DMAP_CC_CMSV,
+ DMAP_CC_CMSR,
+ DMAP_CC_CMMK,
+ DMAP_CC_CMVO,
+
+ DMAP_CC_CMPR,
+ DMAP_CC_CAPR,
+ DMAP_CC_AEFR,
+ DMAP_CC_CAOV,
+ DMAP_CC_CMRL,
+ DMAP_CC_CAHP,
+ DMAP_CC_CAIV,
+ DMAP_CC_CAVC
+} DmapContentCode;
+
+#endif
diff --git a/libdmapsharing/dmap-connection-private.h b/libdmapsharing/dmap-connection-private.h
index e5e3f0d..58d24b4 100644
--- a/libdmapsharing/dmap-connection-private.h
+++ b/libdmapsharing/dmap-connection-private.h
@@ -1,5 +1,30 @@
+/* Header for DMAP (e.g., iTunes Music or iPhoto Picture) sharing
+ *
+ * Copyright (C) 2018 W. Michael Petullo <mike flyn org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef _DMAP_CONNECTION_PRIVATE_H
+#define _DMAP_CONNECTION_PRIVATE_H
+
gboolean dmap_connection_get (DmapConnection * self,
const gchar * path,
gboolean need_hash,
DmapResponseHandler handler,
gpointer user_data);
+
+#endif
diff --git a/libdmapsharing/dmap-connection.c b/libdmapsharing/dmap-connection.c
index b936cf5..a8b9ee0 100644
--- a/libdmapsharing/dmap-connection.c
+++ b/libdmapsharing/dmap-connection.c
@@ -34,12 +34,13 @@
#include "dmap-connection.h"
#include "dmap-record-factory.h"
#include "dmap-marshal.h"
+#include "dmap-structure.h"
#define DMAP_USER_AGENT "iTunes/4.6 (Windows; N)"
#define ITUNES_7_SERVER "iTunes/7"
-static gboolean dmap_connection_do_something (DmapConnection * connection);
+static gboolean _do_something (DmapConnection * connection);
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))
@@ -112,10 +113,10 @@ enum
LAST_SIGNAL
};
-static guint signals[LAST_SIGNAL] = { 0, };
+static guint _signals[LAST_SIGNAL] = { 0, };
static void
-dmap_connection_dispose (GObject * object)
+_dispose (GObject * object)
{
DmapConnectionPrivate *priv = DMAP_CONNECTION (object)->priv;
GSList *l;
@@ -181,18 +182,16 @@ dmap_connection_dispose (GObject * object)
}
static void
-dmap_connection_finalize (GObject * object)
+_finalize (GObject * object)
{
g_debug ("Finalize");
- DmapConnection *connection;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (IS_DMAP_CONNECTION (object));
-
- connection = DMAP_CONNECTION (object);
+ g_assert(IS_DMAP_CONNECTION (object));
- g_return_if_fail (connection->priv != NULL);
+ DmapConnection *connection = DMAP_CONNECTION (object);
+ if (NULL == connection->priv) {
+ goto done;
+ }
g_free (connection->priv->name);
g_free (connection->priv->username);
@@ -200,12 +199,14 @@ dmap_connection_finalize (GObject * object)
g_free (connection->priv->host);
G_OBJECT_CLASS (dmap_connection_parent_class)->finalize (object);
+
+done:
+ return;
}
static void
-dmap_connection_set_property (GObject * object,
- guint prop_id,
- const GValue * value, GParamSpec * pspec)
+_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
DmapConnectionPrivate *priv = DMAP_CONNECTION (object)->priv;
@@ -267,9 +268,8 @@ dmap_connection_set_property (GObject * object,
}
static void
-dmap_connection_get_property (GObject * object,
- guint prop_id,
- GValue * value, GParamSpec * pspec)
+_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec)
{
DmapConnectionPrivate *priv = DMAP_CONNECTION (object)->priv;
@@ -322,10 +322,10 @@ dmap_connection_class_init (DmapConnectionClass * klass)
klass->get_query_metadata = NULL;
klass->handle_mlcl = NULL;
- object_class->dispose = dmap_connection_dispose;
- object_class->finalize = dmap_connection_finalize;
- object_class->set_property = dmap_connection_set_property;
- object_class->get_property = dmap_connection_get_property;
+ object_class->dispose = _dispose;
+ object_class->finalize = _finalize;
+ object_class->set_property = _set_property;
+ object_class->get_property = _get_property;
g_type_class_add_private (klass, sizeof (DmapConnectionPrivate));
@@ -427,7 +427,7 @@ dmap_connection_class_init (DmapConnectionClass * klass)
NULL,
G_PARAM_WRITABLE));
- signals[AUTHENTICATE] = g_signal_new ("authenticate",
+ _signals[AUTHENTICATE] = g_signal_new ("authenticate",
G_TYPE_FROM_CLASS
(object_class),
G_SIGNAL_RUN_LAST,
@@ -441,27 +441,27 @@ dmap_connection_class_init (DmapConnectionClass * klass)
SOUP_TYPE_MESSAGE,
SOUP_TYPE_AUTH,
G_TYPE_BOOLEAN);
- signals[CONNECTING] =
+ _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_generated_VOID__ULONG_FLOAT, G_TYPE_NONE, 2,
G_TYPE_ULONG, G_TYPE_FLOAT);
- signals[CONNECTED] =
+ _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] =
+ _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] =
+ _signals[OPERATION_DONE] =
g_signal_new ("operation-done",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
@@ -477,45 +477,45 @@ dmap_connection_init (DmapConnection * connection)
}
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 ();
}
static SoupMessage *
-dmap_connection_build_message (DmapConnection * connection,
- const char *path,
- gboolean need_hash,
- gdouble version,
- gint req_id, gboolean send_close)
+_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;
@@ -524,12 +524,12 @@ dmap_connection_build_message (DmapConnection * connection,
g_object_get (connection, "base-uri", &base_uri, NULL);
if (base_uri == NULL) {
- return NULL;
+ goto done;
}
uri = soup_uri_new_with_base (base_uri, path);
if (uri == NULL) {
- return NULL;
+ goto done;
}
message = soup_message_new_from_uri (SOUP_METHOD_GET, uri);
@@ -545,6 +545,7 @@ dmap_connection_build_message (DmapConnection * connection,
soup_message_headers_append (message->request_headers,
"Connection", "close");
+done:
soup_uri_free (base_uri);
soup_uri_free (uri);
g_free (uri_str);
@@ -554,27 +555,33 @@ dmap_connection_build_message (DmapConnection * connection,
#ifdef HAVE_LIBZ
static void *
-g_zalloc_wrapper (voidpf opaque, uInt items, uInt size)
+_zalloc_wrapper (voidpf opaque, uInt items, uInt size)
{
+ void *fnval = Z_NULL;
+
if ((items != 0) && (size >= G_MAXUINT / items)) {
- return Z_NULL;
+ goto done;
}
if ((size != 0) && (items >= G_MAXUINT / size)) {
- return Z_NULL;
+ goto done;
}
- return g_malloc0 (items * size);
+
+ fnval = g_malloc0 (items * size);
+
+done:
+ return fnval;
}
static void
-g_zfree_wrapper (voidpf opaque, voidpf address)
+_zfree_wrapper (voidpf opaque, voidpf address)
{
g_free (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);
@@ -596,12 +603,12 @@ typedef struct
} DAAPResponseData;
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,
+ g_signal_emit (G_OBJECT (connection), _signals[CONNECTING], 0,
connection->priv->state, connection->priv->progress);
connection->priv->emit_progress_id = 0;
// FIXME: GDK_THREADS_LEAVE ();
@@ -609,7 +616,7 @@ emit_progress_idle (DmapConnection * connection)
}
static void
-actual_http_response_handler (DAAPResponseData * data)
+_actual_http_response_handler (DAAPResponseData * data)
{
DmapConnectionPrivate *priv;
GNode *structure;
@@ -671,8 +678,8 @@ actual_http_response_handler (DAAPResponseData * data)
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.zalloc = _zalloc_wrapper;
+ stream.zfree = _zfree_wrapper;
stream.opaque = NULL;
if (inflateInit2
@@ -680,6 +687,7 @@ actual_http_response_handler (DAAPResponseData * data)
32 /* auto-detect */ + 15 /* max */ ) != Z_OK) {
inflateEnd (&stream);
g_free (new_response);
+ new_response = NULL;
g_debug ("Unable to decompress response from %s",
message_path);
data->status = SOUP_STATUS_MALFORMED;
@@ -731,7 +739,7 @@ actual_http_response_handler (DAAPResponseData * data)
/* leaving structure == NULL here causes the connection process
* to fail at the first step.
*/
- connection_set_error_message (data->connection,
+ _connection_set_error_message (data->connection,
("libdmapsharing is not able to connect to iTunes 7 shares"));
} else if (SOUP_STATUS_IS_SUCCESSFUL (data->status)) {
DmapStructureItem *item;
@@ -742,7 +750,7 @@ actual_http_response_handler (DAAPResponseData * data)
g_source_remove (priv->emit_progress_id);
}
priv->emit_progress_id =
- g_idle_add ((GSourceFunc) emit_progress_idle,
+ g_idle_add ((GSourceFunc) _emit_progress_idle,
data->connection);
}
structure = dmap_structure_parse (response, response_length);
@@ -773,7 +781,7 @@ actual_http_response_handler (DAAPResponseData * data)
g_source_remove (priv->emit_progress_id);
}
priv->emit_progress_id =
- g_idle_add ((GSourceFunc) emit_progress_idle,
+ g_idle_add ((GSourceFunc) _emit_progress_idle,
data->connection);
}
} else {
@@ -781,7 +789,7 @@ actual_http_response_handler (DAAPResponseData * data)
message_path,
data->message->status_code,
data->message->reason_phrase);
- connection_set_error_message (data->connection,
+ _connection_set_error_message (data->connection,
data->message->reason_phrase);
}
@@ -802,8 +810,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;
@@ -830,36 +838,36 @@ http_response_handler (SoupSession * session,
if (SOUP_STATUS_IS_SUCCESSFUL (data->status)
&& data->connection->priv->use_response_handler_thread) {
g_debug ("creating thread to handle daap response");
- GThread *thread = g_thread_new (NULL, (GThreadFunc) actual_http_response_handler, data);
+ GThread *thread = g_thread_new (NULL, (GThreadFunc) _actual_http_response_handler, data);
if (NULL == thread) {
g_warning ("failed to create new thread");
}
} else {
- actual_http_response_handler (data);
+ _actual_http_response_handler (data);
}
}
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)
{
+ gboolean ok = FALSE;
DmapConnectionPrivate *priv = connection->priv;
DAAPResponseData *data;
SoupMessage *message;
- message =
- dmap_connection_build_message (connection, path, need_hash,
- version, req_id, send_close);
+ message = _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);
- return FALSE;
+ goto done;
}
priv->use_response_handler_thread = use_thread;
@@ -872,11 +880,15 @@ http_get (DmapConnection * connection,
data->connection = connection;
soup_session_queue_message (priv->session, message,
- (SoupSessionCallback)
- http_response_handler, data);
+ (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;
+
+ ok = TRUE;
+
+done:
+ return ok;
}
gboolean
@@ -885,13 +897,13 @@ dmap_connection_get (DmapConnection * self,
gboolean need_hash,
DmapResponseHandler handler, gpointer user_data)
{
- return http_get (self, path, need_hash,
+ return _http_get (self, path, need_hash,
self->priv->dmap_version, 0, FALSE,
(DmapResponseHandler) handler, user_data, FALSE);
}
static void
-dmap_connection_state_done (DmapConnection * connection, gboolean result)
+_state_done (DmapConnection * connection, gboolean result)
{
DmapConnectionPrivate *priv = connection->priv;
@@ -903,16 +915,18 @@ dmap_connection_state_done (DmapConnection * connection, gboolean result)
} else {
switch (priv->state) {
case DMAP_GET_PLAYLISTS:
- if (priv->playlists == NULL)
+ if (priv->playlists == NULL) {
priv->state = DMAP_DONE;
- else
+ } else {
priv->state = DMAP_GET_PLAYLIST_ENTRIES;
+ }
break;
case DMAP_GET_PLAYLIST_ENTRIES:
/* keep reading playlists until we've got them all */
if (++priv->reading_playlist >=
- g_slist_length (priv->playlists))
+ g_slist_length (priv->playlists)) {
priv->state = DMAP_DONE;
+ }
break;
case DMAP_LOGOUT:
@@ -939,7 +953,7 @@ dmap_connection_state_done (DmapConnection * connection, gboolean result)
g_source_remove (connection->priv->emit_progress_id);
}
connection->priv->emit_progress_id =
- g_idle_add ((GSourceFunc) emit_progress_idle,
+ g_idle_add ((GSourceFunc) _emit_progress_idle,
connection);
}
@@ -947,20 +961,19 @@ dmap_connection_state_done (DmapConnection * connection, gboolean result)
g_source_remove (priv->do_something_id);
}
priv->do_something_id =
- g_idle_add ((GSourceFunc) dmap_connection_do_something,
- connection);
+ g_idle_add ((GSourceFunc) _do_something, connection);
}
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)
{
+ gboolean ok = FALSE;
DmapConnectionPrivate *priv = connection->priv;
DmapStructureItem *item = NULL;
if (!SOUP_STATUS_IS_SUCCESSFUL (status) || structure == NULL) {
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
/* get the daap version number */
@@ -969,18 +982,22 @@ handle_server_info (DmapConnection * connection,
(connection)->get_protocol_version_cc
(connection));
if (item == NULL) {
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
priv->dmap_version = g_value_get_double (&(item->content));
- dmap_connection_state_done (connection, TRUE);
+ ok = TRUE;
+
+done:
+ _state_done (connection, ok);
+ return;
}
static void
-handle_login (DmapConnection * connection,
- guint status, GNode * structure, gpointer user_data)
+_handle_login (DmapConnection * connection,
+ guint status, GNode * structure, gpointer user_data)
{
+ gboolean ok = FALSE;
DmapConnectionPrivate *priv = connection->priv;
DmapStructureItem *item = NULL;
@@ -991,59 +1008,65 @@ handle_login (DmapConnection * 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,
+ priv->do_something_id = g_idle_add ((GSourceFunc) _do_something,
connection);
- return;
+ goto done;
}
if (structure == NULL || SOUP_STATUS_IS_SUCCESSFUL (status) == FALSE) {
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
item = dmap_structure_find_item (structure, DMAP_CC_MLID);
if (item == NULL) {
g_debug ("Could not find daap.sessionid item in /login");
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
priv->session_id = (guint32) g_value_get_int (&(item->content));
- connection_connected (connection);
+ _connection_connected (connection);
+
+ ok = TRUE;
- dmap_connection_state_done (connection, TRUE);
+done:
+ _state_done (connection, ok);
+ return;
}
static void
-handle_update (DmapConnection * connection,
- guint status, GNode * structure, gpointer user_data)
+_handle_update (DmapConnection * connection,
+ guint status, GNode * structure, gpointer user_data)
{
+ gboolean ok = FALSE;
DmapConnectionPrivate *priv = connection->priv;
DmapStructureItem *item;
if (structure == NULL || SOUP_STATUS_IS_SUCCESSFUL (status) == FALSE) {
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
/* get a revision number */
item = dmap_structure_find_item (structure, DMAP_CC_MUSR);
if (item == NULL) {
g_debug ("Could not find daap.serverrevision item in /update");
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
priv->revision_number = g_value_get_int (&(item->content));
- dmap_connection_state_done (connection, TRUE);
+
+ ok = TRUE;
+
+done:
+ _state_done (connection, ok);
+ return;
}
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)
{
+ gboolean ok = FALSE;
DmapConnectionPrivate *priv = connection->priv;
DmapStructureItem *item = NULL;
GNode *listing_node;
@@ -1052,15 +1075,13 @@ handle_database_info (DmapConnection * connection,
/* get a list of databases, there should be only 1 */
if (structure == NULL || SOUP_STATUS_IS_SUCCESSFUL (status) == FALSE) {
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
item = dmap_structure_find_item (structure, DMAP_CC_MRCO);
if (item == NULL) {
g_debug ("Could not find dmap.returnedcount item in /databases");
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
n_databases = g_value_get_int (&(item->content));
@@ -1071,26 +1092,30 @@ handle_database_info (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");
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
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);
- return;
+ goto done;
}
priv->database_id = g_value_get_int (&(item->content));
- dmap_connection_state_done (connection, TRUE);
+
+ ok = TRUE;
+
+done:
+ _state_done (connection, ok);
+ return;
}
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)
{
+ gboolean ok = FALSE;
DmapConnectionPrivate *priv = connection->priv;
DmapStructureItem *item = NULL;
GNode *listing_node;
@@ -1102,15 +1127,13 @@ handle_song_listing (DmapConnection * connection,
/* get the songs */
if (structure == NULL || SOUP_STATUS_IS_SUCCESSFUL (status) == FALSE) {
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
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);
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
returned_count = g_value_get_int (&(item->content));
if (returned_count > 20) {
@@ -1122,22 +1145,19 @@ 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);
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
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);
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
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);
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
/* FIXME: refstring: */
@@ -1150,7 +1170,7 @@ handle_song_listing (DmapConnection * connection,
g_source_remove (priv->emit_progress_id);
}
priv->emit_progress_id =
- g_idle_add ((GSourceFunc) emit_progress_idle, connection);
+ g_idle_add ((GSourceFunc) _emit_progress_idle, connection);
for (i = 0, n = listing_node->children; n; i++, n = n->next) {
gint item_id = 0;
@@ -1204,16 +1224,20 @@ handle_song_listing (DmapConnection * connection,
priv->emit_progress_id);
}
priv->emit_progress_id =
- g_idle_add ((GSourceFunc) emit_progress_idle,
+ g_idle_add ((GSourceFunc) _emit_progress_idle,
connection);
}
}
- dmap_connection_state_done (connection, TRUE);
+ ok = TRUE;
+
+done:
+ _state_done (connection, ok);
+ return;
}
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;
@@ -1229,24 +1253,23 @@ 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)
{
+ gboolean ok = FALSE;
DmapConnectionPrivate *priv = connection->priv;
GNode *listing_node;
gint i;
GNode *n;
if (structure == NULL || SOUP_STATUS_IS_SUCCESSFUL (status) == FALSE) {
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
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);
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
for (i = 0, n = listing_node->children; n; n = n->next, i++) {
@@ -1286,15 +1309,20 @@ handle_playlists (DmapConnection * connection,
/* 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);
+ g_slist_sort (priv->playlists, _compare_playlists_by_name);
+
+ ok = TRUE;
- dmap_connection_state_done (connection, TRUE);
+done:
+ _state_done (connection, ok);
+ return;
}
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)
{
+ gboolean ok = FALSE;
DmapConnectionPrivate *priv = connection->priv;
DmapPlaylist *playlist;
GNode *listing_node;
@@ -1303,8 +1331,7 @@ handle_playlist_entries (DmapConnection * connection,
GList *playlist_uris = NULL;
if (structure == NULL || SOUP_STATUS_IS_SUCCESSFUL (status) == FALSE) {
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
playlist =
@@ -1315,8 +1342,7 @@ handle_playlist_entries (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/%d/items",
priv->database_id, playlist->id);
- dmap_connection_state_done (connection, FALSE);
- return;
+ goto done;
}
for (i = 0, node = listing_node->children; node;
@@ -1348,33 +1374,40 @@ handle_playlist_entries (DmapConnection * connection,
}
playlist->uris = g_list_reverse (playlist_uris);
- dmap_connection_state_done (connection, TRUE);
+
+ ok = TRUE;
+
+done:
+ _state_done (connection, ok);
+ return;
}
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);
+ _connection_disconnected (connection);
/* is there any point handling errors here? */
- dmap_connection_state_done (connection, TRUE);
+ _state_done (connection, TRUE);
}
static void
-dmap_connection_finish (DmapConnection * connection)
+_finish (DmapConnection * connection)
{
- g_return_if_fail (IS_DMAP_CONNECTION (connection));
+ g_assert(IS_DMAP_CONNECTION (connection));
g_debug ("DAAP finish");
connection->priv->state = DMAP_DONE;
connection->priv->progress = 1.0f;
- connection_operation_done (connection);
+ _connection_operation_done (connection);
+
+ return;
}
static gboolean
-dmap_connection_do_something (DmapConnection * connection)
+_do_something (DmapConnection * connection)
{
DmapConnectionPrivate *priv = connection->priv;
char *meta;
@@ -1387,22 +1420,22 @@ dmap_connection_do_something (DmapConnection * connection)
switch (priv->state) {
case DMAP_GET_INFO:
g_debug ("Getting DAAP server info");
- if (!http_get
+ if (!_http_get
(connection, "/server-info", FALSE, 0.0, 0, FALSE,
- (DmapResponseHandler) handle_server_info, NULL, FALSE)) {
+ (DmapResponseHandler) _handle_server_info, NULL, FALSE)) {
g_debug ("Could not get DAAP connection info");
- dmap_connection_state_done (connection, FALSE);
+ _state_done (connection, FALSE);
}
break;
case DMAP_LOGIN:
// NOTE: libsoup will signal if password required and not present.
g_debug ("Logging into DAAP server");
- if (!http_get (connection, "/login", FALSE, 0.0, 0, FALSE,
- (DmapResponseHandler) handle_login, NULL,
+ if (!_http_get (connection, "/login", FALSE, 0.0, 0, FALSE,
+ (DmapResponseHandler) _handle_login, NULL,
FALSE)) {
g_debug ("Could not login to DAAP server");
- dmap_connection_state_done (connection, FALSE);
+ _state_done (connection, FALSE);
}
break;
@@ -1412,11 +1445,11 @@ dmap_connection_do_something (DmapConnection * connection)
path = g_strdup_printf
("/update?session-id=%u&revision-number=1",
priv->session_id);
- if (!http_get
+ if (!_http_get
(connection, path, TRUE, priv->dmap_version, 0, FALSE,
- (DmapResponseHandler) handle_update, NULL, FALSE)) {
+ (DmapResponseHandler) _handle_update, NULL, FALSE)) {
g_debug ("Could not get server database revision number");
- dmap_connection_state_done (connection, FALSE);
+ _state_done (connection, FALSE);
}
g_free (path);
break;
@@ -1426,12 +1459,12 @@ dmap_connection_do_something (DmapConnection * connection)
path = g_strdup_printf
("/databases?session-id=%u&revision-number=%d",
priv->session_id, priv->revision_number);
- if (!http_get
+ if (!_http_get
(connection, path, TRUE, priv->dmap_version, 0, FALSE,
- (DmapResponseHandler) handle_database_info, NULL,
+ (DmapResponseHandler) _handle_database_info, NULL,
FALSE)) {
g_debug ("Could not get DAAP database info");
- dmap_connection_state_done (connection, FALSE);
+ _state_done (connection, FALSE);
}
g_free (path);
break;
@@ -1444,11 +1477,11 @@ dmap_connection_do_something (DmapConnection * connection)
("/databases/%i/items?session-id=%u&revision-number=%i"
"&meta=%s", priv->database_id, priv->session_id,
priv->revision_number, meta);
- if (!http_get
+ if (!_http_get
(connection, path, TRUE, priv->dmap_version, 0, FALSE,
- (DmapResponseHandler) handle_song_listing, NULL, TRUE)) {
+ (DmapResponseHandler) _handle_song_listing, NULL, TRUE)) {
g_debug ("Could not get DAAP song listing");
- dmap_connection_state_done (connection, FALSE);
+ _state_done (connection, FALSE);
}
g_free (path);
g_free (meta);
@@ -1460,11 +1493,11 @@ dmap_connection_do_something (DmapConnection * connection)
("/databases/%d/containers?session-id=%u&revision-number=%d",
priv->database_id, priv->session_id,
priv->revision_number);
- if (!http_get
+ if (!_http_get
(connection, path, TRUE, priv->dmap_version, 0, FALSE,
- (DmapResponseHandler) handle_playlists, NULL, TRUE)) {
+ (DmapResponseHandler) _handle_playlists, NULL, TRUE)) {
g_debug ("Could not get DAAP playlists");
- dmap_connection_state_done (connection, FALSE);
+ _state_done (connection, FALSE);
}
g_free (path);
break;
@@ -1483,13 +1516,13 @@ dmap_connection_do_something (DmapConnection * connection)
("/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
+ if (!_http_get
(connection, path, TRUE, priv->dmap_version, 0,
FALSE,
- (DmapResponseHandler) handle_playlist_entries,
+ (DmapResponseHandler) _handle_playlist_entries,
NULL, TRUE)) {
g_debug ("Could not get entries for DAAP playlist %d",
priv->reading_playlist);
- dmap_connection_state_done (connection,
+ _state_done (connection,
FALSE);
}
g_free (path);
@@ -1500,11 +1533,11 @@ dmap_connection_do_something (DmapConnection * connection)
g_debug ("Logging out of DAAP server");
path = g_strdup_printf ("/logout?session-id=%u",
priv->session_id);
- if (!http_get
+ if (!_http_get
(connection, path, TRUE, priv->dmap_version, 0, FALSE,
- (DmapResponseHandler) handle_logout, NULL, FALSE)) {
+ (DmapResponseHandler) _handle_logout, NULL, FALSE)) {
g_debug ("Could not log out of DAAP server");
- dmap_connection_state_done (connection, FALSE);
+ _state_done (connection, FALSE);
}
g_free (path);
@@ -1513,7 +1546,7 @@ dmap_connection_do_something (DmapConnection * connection)
case DMAP_DONE:
g_debug ("DAAP done");
- dmap_connection_finish (connection);
+ _finish (connection);
break;
}
@@ -1524,7 +1557,7 @@ dmap_connection_do_something (DmapConnection * connection)
gboolean
dmap_connection_is_connected (DmapConnection * connection)
{
- g_return_val_if_fail (IS_DMAP_CONNECTION (connection), FALSE);
+ g_assert(IS_DMAP_CONNECTION (connection));
return connection->priv->is_connected;
}
@@ -1538,7 +1571,7 @@ typedef struct
} ConnectionResponseData;
static void
-connection_response_data_free (gpointer data)
+_connection_response_data_free (gpointer data)
{
ConnectionResponseData *rdata = data;
@@ -1547,7 +1580,7 @@ connection_response_data_free (gpointer data)
}
static void
-connected_cb (DmapConnection * connection, ConnectionResponseData * rdata)
+_connected_cb (DmapConnection * connection, ConnectionResponseData * rdata)
{
gboolean result;
@@ -1556,7 +1589,7 @@ connected_cb (DmapConnection * connection, ConnectionResponseData * rdata)
connection->priv->is_connecting = FALSE;
g_signal_handlers_disconnect_by_func (connection,
- G_CALLBACK (connected_cb),
+ G_CALLBACK (_connected_cb),
rdata);
/* if connected then we succeeded */
@@ -1575,14 +1608,15 @@ connected_cb (DmapConnection * connection, ConnectionResponseData * rdata)
}
static void
-authenticate_cb (SoupSession *session, SoupMessage *msg, SoupAuth *auth, gboolean retrying, DmapConnection
*connection)
+_authenticate_cb (SoupSession *session, SoupMessage *msg, SoupAuth *auth,
+ gboolean retrying, DmapConnection *connection)
{
if (retrying || ! connection->priv->password) {
g_debug ("Requesting password from application");
soup_session_pause_message (session, msg);
// FIXME: GDK_THREADS_ENTER ();
g_signal_emit (connection,
- signals[AUTHENTICATE],
+ _signals[AUTHENTICATE],
0,
connection->priv->name,
session,
@@ -1617,7 +1651,7 @@ dmap_connection_setup (DmapConnection * connection)
{
connection->priv->session = soup_session_new ();
- g_signal_connect (connection->priv->session, "authenticate", G_CALLBACK(authenticate_cb), connection);
+ g_signal_connect (connection->priv->session, "authenticate", G_CALLBACK(_authenticate_cb),
connection);
connection->priv->base_uri = soup_uri_new (NULL);
soup_uri_set_scheme (connection->priv->base_uri,
@@ -1637,8 +1671,8 @@ dmap_connection_start (DmapConnection * connection,
{
ConnectionResponseData *rdata;
- g_return_if_fail (IS_DMAP_CONNECTION (connection));
- g_return_if_fail (connection->priv->state == DMAP_GET_INFO);
+ g_assert(IS_DMAP_CONNECTION (connection));
+ g_assert(connection->priv->state == DMAP_GET_INFO);
g_debug ("Creating new DAAP connection to %s:%d",
connection->priv->host, connection->priv->port);
@@ -1660,9 +1694,9 @@ dmap_connection_start (DmapConnection * connection,
rdata->connection = g_object_ref (connection);
rdata->callback = callback;
rdata->user_data = user_data;
- rdata->destroy = connection_response_data_free;
+ rdata->destroy = _connection_response_data_free;
g_signal_connect (connection, "operation-done",
- G_CALLBACK (connected_cb), rdata);
+ G_CALLBACK (_connected_cb), rdata);
if (connection->priv->do_something_id != 0) {
g_source_remove (connection->priv->do_something_id);
@@ -1670,19 +1704,18 @@ dmap_connection_start (DmapConnection * connection,
connection->priv->is_connecting = TRUE;
connection->priv->do_something_id =
- g_idle_add ((GSourceFunc) dmap_connection_do_something,
- connection);
+ g_idle_add ((GSourceFunc) _do_something, connection);
}
static void
-disconnected_cb (DmapConnection * connection, ConnectionResponseData * rdata)
+_disconnected_cb (DmapConnection * connection, ConnectionResponseData * rdata)
{
gboolean result;
g_debug ("Disconnected callback");
g_signal_handlers_disconnect_by_func (connection,
- G_CALLBACK (disconnected_cb),
+ G_CALLBACK (_disconnected_cb),
rdata);
/* if not connected then we succeeded */
@@ -1708,7 +1741,7 @@ dmap_connection_disconnect (DmapConnection * connection,
DmapConnectionPrivate *priv = connection->priv;
ConnectionResponseData *rdata;
- g_return_if_fail (IS_DMAP_CONNECTION (connection));
+ g_assert(IS_DMAP_CONNECTION (connection));
g_debug ("Disconnecting");
@@ -1718,7 +1751,7 @@ dmap_connection_disconnect (DmapConnection * connection,
* to finish */
priv->state = DMAP_DONE;
// FIXME: GDK_THREADS_LEAVE ();
- dmap_connection_finish (connection);
+ _finish (connection);
// FIXME: GDK_THREADS_ENTER ();
}
@@ -1726,10 +1759,10 @@ dmap_connection_disconnect (DmapConnection * connection,
rdata->connection = g_object_ref (connection);
rdata->callback = callback;
rdata->user_data = user_data;
- rdata->destroy = connection_response_data_free;
+ rdata->destroy = _connection_response_data_free;
g_signal_connect (connection, "operation-done",
- G_CALLBACK (disconnected_cb), rdata);
+ G_CALLBACK (_disconnected_cb), rdata);
if (priv->do_something_id != 0) {
g_source_remove (priv->do_something_id);
@@ -1738,13 +1771,12 @@ dmap_connection_disconnect (DmapConnection * connection,
if (!connection->priv->is_connected) {
priv->state = DMAP_DONE;
// FIXME: GDK_THREADS_LEAVE ();
- dmap_connection_finish (connection);
+ _finish (connection);
// FIXME: GDK_THREADS_ENTER ();
} else {
priv->state = DMAP_LOGOUT;
- priv->do_something_id = g_idle_add ((GSourceFunc)
- dmap_connection_do_something,
+ priv->do_something_id = g_idle_add ((GSourceFunc) _do_something,
connection);
}
}
@@ -1764,7 +1796,7 @@ dmap_connection_get_headers (DmapConnection * connection, const gchar * uri)
norb_daap_uri = strstr (uri, "/data");
}
- dmap_hash_generate ((short) floorf (priv->dmap_version),
+ dmap_md5_generate ((short) floorf (priv->dmap_version),
(const guchar *) norb_daap_uri, 2,
(guchar *) hash, priv->request_id);
diff --git a/libdmapsharing/dmap-connection.h b/libdmapsharing/dmap-connection.h
index 9df7bd2..2519591 100644
--- a/libdmapsharing/dmap-connection.h
+++ b/libdmapsharing/dmap-connection.h
@@ -18,14 +18,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_CONNECTION_H
-#define __DMAP_CONNECTION_H
+#ifndef _DMAP_CONNECTION_H
+#define _DMAP_CONNECTION_H
#include <glib.h>
#include <glib-object.h>
#include <libsoup/soup.h>
-#include <libdmapsharing/dmap-structure.h>
+#include <libdmapsharing/dmap-cc.h>
#include <libdmapsharing/dmap-db.h>
#include <libdmapsharing/dmap-record-factory.h>
@@ -209,4 +209,4 @@ void dmap_connection_authenticate_message (DmapConnection *connection,
const char *password);
G_END_DECLS
-#endif /* __DMAP_CONNECTION_H */
+#endif /* _DMAP_CONNECTION_H */
diff --git a/libdmapsharing/dmap-container-db.h b/libdmapsharing/dmap-container-db.h
index f19d999..882da0a 100644
--- a/libdmapsharing/dmap-container-db.h
+++ b/libdmapsharing/dmap-container-db.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_CONTAINER_DB_H
-#define __DMAP_CONTAINER_DB_H
+#ifndef _DMAP_CONTAINER_DB_H
+#define _DMAP_CONTAINER_DB_H
#include <glib-object.h>
@@ -129,6 +129,6 @@ void dmap_container_db_foreach (DmapContainerDb * db,
*/
gulong dmap_container_db_count (DmapContainerDb * db);
-#endif /* __DMAP_CONTAINER_DB_H */
+#endif /* _DMAP_CONTAINER_DB_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-container-record.h b/libdmapsharing/dmap-container-record.h
index 1930c83..c74d672 100644
--- a/libdmapsharing/dmap-container-record.h
+++ b/libdmapsharing/dmap-container-record.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_CONTAINER_RECORD_H
-#define __DMAP_CONTAINER_RECORD_H
+#ifndef _DMAP_CONTAINER_RECORD_H
+#define _DMAP_CONTAINER_RECORD_H
#include <glib-object.h>
#include <libdmapsharing/dmap-db.h>
@@ -115,6 +115,6 @@ guint64 dmap_container_record_get_entry_count (DmapContainerRecord * record);
*/
DmapDb *dmap_container_record_get_entries (DmapContainerRecord * record);
-#endif /* __DMAP_CONTAINER_RECORD_H */
+#endif /* _DMAP_CONTAINER_RECORD_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-control-connection.c b/libdmapsharing/dmap-control-connection.c
index 554b71d..875768c 100644
--- a/libdmapsharing/dmap-control-connection.c
+++ b/libdmapsharing/dmap-control-connection.c
@@ -31,7 +31,7 @@ struct DmapControlConnectionPrivate {
*/
static DmapContentCode
-get_protocol_version_cc (DmapConnection * connection)
+_get_protocol_version_cc (DmapConnection * connection)
{
/* FIXME: */
g_error ("Not implemented");
@@ -39,7 +39,7 @@ get_protocol_version_cc (DmapConnection * connection)
}
static gchar *
-get_query_metadata (DmapConnection * connection)
+_get_query_metadata (DmapConnection * connection)
{
/* FIXME: */
g_error ("Not implemented");
@@ -47,7 +47,7 @@ get_query_metadata (DmapConnection * connection)
}
static DmapRecord *
-handle_mlcl (DmapConnection * connection, DmapRecordFactory * factory,
+_handle_mlcl (DmapConnection * connection, DmapRecordFactory * factory,
GNode * n, int *item_id)
{
/* FIXME: */
@@ -62,9 +62,9 @@ dmap_control_connection_class_init (DmapControlConnectionClass * klass)
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;
+ 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 (DmapControlConnectionPrivate));
diff --git a/libdmapsharing/dmap-control-connection.h b/libdmapsharing/dmap-control-connection.h
index 044e1d6..e6ead09 100644
--- a/libdmapsharing/dmap-control-connection.h
+++ b/libdmapsharing/dmap-control-connection.h
@@ -14,8 +14,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_CONTROL_CONNECTION_H
-#define __DMAP_CONTROL_CONNECTION_H
+#ifndef _DMAP_CONTROL_CONNECTION_H
+#define _DMAP_CONTROL_CONNECTION_H
#include <glib-object.h>
@@ -91,4 +91,4 @@ DmapControlConnection *dmap_control_connection_new (const char *name,
DmapDb * db,
DmapRecordFactory * factory);
G_END_DECLS
-#endif /* __DMAP_CONTROL_CONNECTION_H */
+#endif /* _DMAP_CONTROL_CONNECTION_H */
diff --git a/libdmapsharing/dmap-control-share.c b/libdmapsharing/dmap-control-share.c
index eb31737..cf2adda 100644
--- a/libdmapsharing/dmap-control-share.c
+++ b/libdmapsharing/dmap-control-share.c
@@ -107,12 +107,12 @@ enum
LAST_SIGNAL
};
-static guint signals[LAST_SIGNAL] = { 0, };
+static guint _signals[LAST_SIGNAL] = { 0, };
G_DEFINE_TYPE (DmapControlShare, dmap_control_share, DMAP_TYPE_SHARE);
static gchar *
-get_dbid (void)
+_get_dbid (void)
{
static gchar *dbid;
@@ -128,22 +128,20 @@ get_dbid (void)
g_string_ascii_up (name);
g_string_append_len (name, name->str, 4);
- dbid = name->str;
-
- g_string_free (name, FALSE);
+ dbid = g_string_free (name, FALSE);
}
return dbid;
}
static void
-dmap_control_share_update_txt_records (DmapControlShare * share)
+_update_txt_records (DmapControlShare * 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 ());
+ dbid_record = g_strdup_printf ("DbId=%s", _get_dbid ());
gchar *txt_records[] = { "Ver=131073",
"DvSv=2049",
@@ -162,9 +160,9 @@ dmap_control_share_update_txt_records (DmapControlShare * share)
}
static void
-dmap_control_share_set_property (GObject * object,
- guint prop_id,
- const GValue * value, GParamSpec * pspec)
+_set_property (GObject * object,
+ guint prop_id,
+ const GValue * value, GParamSpec * pspec)
{
DmapControlShare *share = DMAP_CONTROL_SHARE (object);
@@ -172,7 +170,7 @@ dmap_control_share_set_property (GObject * object,
case PROP_LIBRARY_NAME:
g_free (share->priv->library_name);
share->priv->library_name = g_value_dup_string (value);
- dmap_control_share_update_txt_records (share);
+ _update_txt_records (share);
break;
case PROP_PLAYER:
if (share->priv->player) {
@@ -187,8 +185,8 @@ dmap_control_share_set_property (GObject * object,
}
static void
-dmap_control_share_get_property (GObject * object,
- guint prop_id, GValue * value, GParamSpec * pspec)
+_get_property (GObject * object,
+ guint prop_id, GValue * value, GParamSpec * pspec)
{
DmapControlShare *share = DMAP_CONTROL_SHARE (object);
@@ -206,7 +204,7 @@ dmap_control_share_get_property (GObject * object,
}
static void
-dmap_control_share_dispose (GObject * object)
+_dispose (GObject * object)
{
DmapControlShare *share = DMAP_CONTROL_SHARE (object);
@@ -227,7 +225,7 @@ dmap_control_share_dispose (GObject * object)
}
static void
-dmap_control_share_finalize (GObject * object)
+_finalize (GObject * object)
{
DmapControlShare *share = DMAP_CONTROL_SHARE (object);
@@ -248,10 +246,10 @@ dmap_control_share_class_init (DmapControlShareClass * klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
DmapShareClass *dmap_class = DMAP_SHARE_CLASS (object_class);
- object_class->get_property = dmap_control_share_get_property;
- object_class->set_property = dmap_control_share_set_property;
- object_class->dispose = dmap_control_share_dispose;
- object_class->finalize = dmap_control_share_finalize;
+ object_class->get_property = _get_property;
+ object_class->set_property = _set_property;
+ object_class->dispose = _dispose;
+ object_class->finalize = _finalize;
dmap_class->get_type_of_service = dmap_control_share_get_type_of_service;
dmap_class->ctrl_int = dmap_control_share_ctrl_int;
@@ -283,7 +281,7 @@ dmap_control_share_class_init (DmapControlShareClass * 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,
@@ -300,7 +298,7 @@ dmap_control_share_class_init (DmapControlShareClass * 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,
@@ -318,7 +316,7 @@ dmap_control_share_class_init (DmapControlShareClass * 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,
@@ -337,7 +335,7 @@ dmap_control_share_class_init (DmapControlShareClass * 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,
@@ -360,7 +358,7 @@ dmap_control_share_class_init (DmapControlShareClass * 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,
@@ -388,10 +386,11 @@ dmap_control_share_init (DmapControlShare * share)
g_free);
}
-void
-mdns_remote_added (DmapMdnsBrowser * browser,
- DmapMdnsService * service, DmapControlShare * share)
+static void
+_mdns_remote_added (DmapMdnsBrowser * browser,
+ DmapMdnsService * service, DmapControlShare * share)
{
+ gboolean new;
guint port;
DACPRemoteInfo *remote_info;
gchar *service_name, *name, *host, *pair;
@@ -413,25 +412,26 @@ mdns_remote_added (DmapMdnsBrowser * browser,
name,
remote_info->host, remote_info->port, remote_info->pair_txt);
- g_hash_table_insert (share->priv->remotes,
- service_name, remote_info);
+ new = g_hash_table_insert (share->priv->remotes,
+ service_name, remote_info);
+ g_assert(new);
- g_signal_emit (share,
- signals[REMOTE_FOUND],
- 0, service_name, name);
+ g_signal_emit (share, _signals[REMOTE_FOUND], 0, service_name, name);
g_free(name);
g_free(host);
g_free(pair);
}
-void
-mdns_remote_removed (DmapMdnsBrowser * browser,
- const char *service_name, DmapControlShare * share)
+static void
+_mdns_remote_removed (DmapMdnsBrowser * browser,
+ const char *service_name, DmapControlShare * share)
{
- g_signal_emit (share, signals[REMOTE_LOST], 0, service_name);
+ gboolean found;
+ g_signal_emit (share, _signals[REMOTE_LOST], 0, service_name);
- g_hash_table_remove (share->priv->remotes, service_name);
+ found = g_hash_table_remove (share->priv->remotes, service_name);
+ g_assert(found);
}
DmapControlShare *
@@ -442,7 +442,7 @@ dmap_control_share_new (const gchar * library_name,
DmapControlShare *share;
share = DMAP_CONTROL_SHARE (g_object_new (DMAP_TYPE_CONTROL_SHARE,
- "name", get_dbid (),
+ "name", _get_dbid (),
"library-name", library_name,
"password", NULL,
"db", db,
@@ -460,6 +460,7 @@ dmap_control_share_new (const gchar * library_name,
void
dmap_control_share_start_lookup (DmapControlShare * share)
{
+ gboolean ok;
GError *error;
if (share->priv->mdns_browser) {
@@ -472,14 +473,14 @@ dmap_control_share_start_lookup (DmapControlShare * share)
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) {
+ ok = dmap_mdns_browser_start (share->priv->mdns_browser, &error);
+ if (!ok) {
g_warning ("Unable to start Remote lookup: %s",
error->message);
g_error_free (error);
@@ -487,17 +488,18 @@ dmap_control_share_start_lookup (DmapControlShare * share)
}
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 ((DmapControlShare *) share,
- signals[REMOTE_LOST], 0, (gchar *) service_name);
+ _signals[REMOTE_LOST], 0, (gchar *) service_name);
return TRUE;
}
void
dmap_control_share_stop_lookup (DmapControlShare * share)
{
+ gboolean ok;
GError *error;
if (!share->priv->mdns_browser) {
@@ -505,12 +507,13 @@ dmap_control_share_stop_lookup (DmapControlShare * share)
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) {
+ ok = dmap_mdns_browser_stop (share->priv->mdns_browser, &error);
+ if (!ok) {
g_warning ("Unable to stop Remote lookup: %s",
error->message);
g_error_free (error);
@@ -520,7 +523,7 @@ dmap_control_share_stop_lookup (DmapControlShare * share)
}
static void
-dmap_control_share_fill_playstatusupdate (DmapControlShare * share, SoupMessage * message)
+_fill_playstatusupdate (DmapControlShare * share, SoupMessage * message)
{
GNode *cmst;
DmapAvRecord *record;
@@ -561,12 +564,15 @@ dmap_control_share_fill_playstatusupdate (DmapControlShare * share, SoupMessage
dmap_structure_add (cmst, DMAP_CC_CAAS, 2);
dmap_structure_add (cmst, DMAP_CC_CAAR, 6);
dmap_structure_add (cmst, DMAP_CC_CANP, (gint64) 0); // FIXME: may be wrong.
- if (title)
+ if (title) {
dmap_structure_add (cmst, DMAP_CC_CANN, title);
- if (artist)
+ }
+ if (artist) {
dmap_structure_add (cmst, DMAP_CC_CANA, artist);
- if (album)
+ }
+ if (album) {
dmap_structure_add (cmst, DMAP_CC_CANL, album);
+ }
dmap_structure_add (cmst, DMAP_CC_CANG, "");
dmap_structure_add (cmst, DMAP_CC_ASAI, 0);
//dmap_structure_add (cmst, DMAP_CC_AEMK, 1);
@@ -589,7 +595,7 @@ dmap_control_share_fill_playstatusupdate (DmapControlShare * share, SoupMessage
}
static void
-dmap_control_share_send_playstatusupdate (DmapControlShare * share)
+_send_playstatusupdate (DmapControlShare * share)
{
GSList *list;
SoupServer *server = NULL;
@@ -598,8 +604,8 @@ dmap_control_share_send_playstatusupdate (DmapControlShare * share)
if (server) {
for (list = share->priv->update_queue; list;
list = list->next) {
- dmap_control_share_fill_playstatusupdate (share,
- (SoupMessage*) list->data);
+ _fill_playstatusupdate (share,
+ (SoupMessage*) list->data);
soup_server_unpause_message (server,
(SoupMessage*) list->data);
}
@@ -613,11 +619,11 @@ void
dmap_control_share_player_updated (DmapControlShare * share)
{
share->priv->current_revision++;
- dmap_control_share_send_playstatusupdate (share);
+ _send_playstatusupdate (share);
}
static void
-status_update_message_finished (SoupMessage * message, DmapControlShare * share)
+_status_update_message_finished (SoupMessage * message, DmapControlShare * share)
{
share->priv->update_queue =
g_slist_remove (share->priv->update_queue, message);
@@ -625,7 +631,7 @@ status_update_message_finished (SoupMessage * message, DmapControlShare * share)
}
static void
-debug_param (gpointer key, gpointer val, gpointer user_data)
+_debug_param (gpointer key, gpointer val, gpointer user_data)
{
g_debug ("%s %s", (char *) key, (char *) val);
}
@@ -641,7 +647,7 @@ dmap_control_share_login (DmapShare * share,
g_debug ("Path is %s.", path);
if (query) {
- g_hash_table_foreach (query, debug_param, NULL);
+ g_hash_table_foreach (query, _debug_param, NULL);
}
pairing_guid = g_hash_table_lookup (query, "pairing-guid");
@@ -649,7 +655,7 @@ dmap_control_share_login (DmapShare * share,
if (pairing_guid != NULL) {
gboolean allow_login;
- g_signal_emit (share, signals[LOOKUP_GUID], 0, pairing_guid,
+ g_signal_emit (share, _signals[LOOKUP_GUID], 0, pairing_guid,
&allow_login);
if (!allow_login) {
@@ -676,7 +682,7 @@ dmap_control_share_ctrl_int (DmapShare * share,
g_debug ("Path is %s.", path);
if (query) {
- g_hash_table_foreach (query, debug_param, NULL);
+ g_hash_table_foreach (query, _debug_param, NULL);
}
rest_of_path = strchr (path + 1, '/');
@@ -688,7 +694,7 @@ dmap_control_share_ctrl_int (DmapShare * share,
(!_dmap_share_session_id_validate
(share, context, message, query, NULL))) {
soup_message_set_status (message, SOUP_STATUS_FORBIDDEN);
- return;
+ goto done;
}
if (rest_of_path == NULL) {
@@ -758,7 +764,7 @@ dmap_control_share_ctrl_int (DmapShare * share,
if (!properties_query) {
g_warning ("No property specified");
- return;
+ goto done;
}
cmgt = dmap_structure_add (NULL, DMAP_CC_CMGT);
@@ -828,12 +834,11 @@ dmap_control_share_ctrl_int (DmapShare * share,
priv->update_queue, message);
g_signal_connect_object (message, "finished",
G_CALLBACK
- (status_update_message_finished),
+ (_status_update_message_finished),
dmap_control_share, 0);
soup_server_pause_message (server, message);
} else {
- dmap_control_share_fill_playstatusupdate (dmap_control_share,
- message);
+ _fill_playstatusupdate (dmap_control_share, message);
}
} else if (g_ascii_strcasecmp ("/1/playpause", rest_of_path) == 0) {
dmap_control_player_play_pause (dmap_control_share->priv->player);
@@ -855,10 +860,12 @@ dmap_control_share_ctrl_int (DmapShare * share,
gchar *buffer;
gsize buffer_len;
- if (g_hash_table_lookup (query, "mw"))
+ if (g_hash_table_lookup (query, "mw")) {
width = atoi (g_hash_table_lookup (query, "mw"));
- if (g_hash_table_lookup (query, "mh"))
+ }
+ if (g_hash_table_lookup (query, "mh")) {
height = atoi (g_hash_table_lookup (query, "mh"));
+ }
artwork_filename =
dmap_control_player_now_playing_artwork (dmap_control_share->
priv->player, width,
@@ -867,7 +874,7 @@ dmap_control_share_ctrl_int (DmapShare * share,
g_debug ("No artwork for currently playing song");
soup_message_set_status (message,
SOUP_STATUS_NOT_FOUND);
- return;
+ goto done;
}
#ifdef HAVE_GDKPIXBUF
GdkPixbuf *artwork =
@@ -880,7 +887,7 @@ dmap_control_share_ctrl_int (DmapShare * share,
g_free (artwork_filename);
soup_message_set_status (message,
SOUP_STATUS_INTERNAL_SERVER_ERROR);
- return;
+ goto done;
}
if (!gdk_pixbuf_save_to_buffer
(artwork, &buffer, &buffer_len, "png", NULL, NULL)) {
@@ -889,7 +896,7 @@ dmap_control_share_ctrl_int (DmapShare * share,
g_free (artwork_filename);
soup_message_set_status (message,
SOUP_STATUS_INTERNAL_SERVER_ERROR);
- return;
+ goto done;
}
g_object_unref (artwork);
#else
@@ -899,7 +906,7 @@ dmap_control_share_ctrl_int (DmapShare * share,
g_free (artwork_filename);
soup_message_set_status (message,
SOUP_STATUS_INTERNAL_SERVER_ERROR);
- return;
+ goto done;
}
#endif
g_free (artwork_filename);
@@ -916,7 +923,7 @@ dmap_control_share_ctrl_int (DmapShare * share,
g_debug ("No CUE command specified");
soup_message_set_status (message,
SOUP_STATUS_NO_CONTENT);
- return;
+ goto done;
} else if (g_ascii_strcasecmp ("clear", command) == 0) {
dmap_control_player_cue_clear (dmap_control_share->priv->player);
soup_message_set_status (message,
@@ -970,22 +977,25 @@ dmap_control_share_ctrl_int (DmapShare * share,
g_warning ("Unhandled cue command: %s", command);
soup_message_set_status (message,
SOUP_STATUS_NO_CONTENT);
- return;
+ goto done;
}
} else {
g_warning ("Unhandled ctrl-int command: %s", rest_of_path);
soup_message_set_status (message, SOUP_STATUS_BAD_REQUEST);
}
+
+done:
+ return;
}
#define PAIR_TXT_LENGTH 16
#define PASSCODE_LENGTH 4
static gchar *
-dmap_control_share_pairing_code (DmapControlShare * share, gchar * pair_txt,
- gchar passcode[4])
+_pairing_code (DmapControlShare * share, gchar * pair_txt, gchar passcode[4])
{
int i;
+ gsize ssize, dsize;
GString *pairing_code;
gchar *pairing_string;
gchar *ret;
@@ -994,8 +1004,11 @@ dmap_control_share_pairing_code (DmapControlShare * share, gchar * 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);
+
+ dsize = PAIR_TXT_LENGTH + PASSCODE_LENGTH * 2;
+ ssize = g_strlcpy (pairing_string, pair_txt, dsize);
+ g_assert(dsize >= ssize);
+
for (i = 0; i < 4; i++) {
pairing_string[PAIR_TXT_LENGTH + i * 2] = passcode[i];
}
@@ -1005,14 +1018,13 @@ dmap_control_share_pairing_code (DmapControlShare * share, gchar * pair_txt,
(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);
+ ret = g_string_free (pairing_code, FALSE);
return ret;
}
-void
-connection_handler_cb (DmapConnection * connection, guint status,
+static void
+_connection_handler_cb (DmapConnection * connection, guint status,
GNode * structure, gpointer user_data)
{
gboolean connected;
@@ -1032,15 +1044,16 @@ connection_handler_cb (DmapConnection * connection, guint status,
}
/* Get the pairing-guid to identify this remote in the future. */
- if (structure)
+ 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);
+ g_signal_emit (share, _signals[ADD_GUID], 0, pairing_guid);
g_free (pairing_guid);
}
@@ -1064,29 +1077,28 @@ connection_handler_cb (DmapConnection * connection, guint status,
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,
+ g_signal_emit (share, _signals[REMOTE_PAIRED], 0, service_name,
connected);
}
void
dmap_control_share_pair (DmapControlShare * share, gchar * service_name, gchar passcode[4])
{
+ gboolean ok;
gchar *pairing_code;
- gchar *name;
- gchar *path;
+ gchar *name = NULL;
+ gchar *path = NULL;
DACPRemoteInfo *remote_info;
- remote_info = g_hash_table_lookup (share->priv->remotes,
- service_name);
-
+ remote_info = g_hash_table_lookup (share->priv->remotes, service_name);
if (remote_info == NULL) {
g_warning ("Remote %s not found.", service_name);
- return;
+ goto done;
}
if (remote_info->connection != NULL) {
g_warning ("Already pairing remote %s.", service_name);
- return;
+ goto done;
}
g_object_get (share, "name", &name, NULL);
@@ -1099,9 +1111,7 @@ dmap_control_share_pair (DmapControlShare * share, gchar * service_name, gchar p
dmap_connection_setup (remote_info->connection);
/* Get the remote path for pairing */
- pairing_code =
- dmap_control_share_pairing_code (share, remote_info->pair_txt,
- passcode);
+ pairing_code = _pairing_code (share, remote_info->pair_txt, passcode);
path = g_strdup_printf ("/pair?pairingcode=%s&servicename=%s",
pairing_code, name);
g_free (pairing_code);
@@ -1109,10 +1119,14 @@ dmap_control_share_pair (DmapControlShare * share, gchar * service_name, gchar p
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);
+ /* Let DmapConnection do the heavy lifting. */
+ ok = dmap_connection_get (remote_info->connection, path, FALSE,
+ _connection_handler_cb, share);
+ if (!ok) {
+ g_debug("Error pairing remote");
+ }
+done:
g_free (name);
g_free (path);
}
diff --git a/libdmapsharing/dmap-control-share.h b/libdmapsharing/dmap-control-share.h
index 0c3b9b2..cdad864 100644
--- a/libdmapsharing/dmap-control-share.h
+++ b/libdmapsharing/dmap-control-share.h
@@ -19,8 +19,8 @@
*
*/
-#ifndef __DMAP_CONTROL_SHARE_H
-#define __DMAP_CONTROL_SHARE_H
+#ifndef _DMAP_CONTROL_SHARE_H
+#define _DMAP_CONTROL_SHARE_H
#include <glib-object.h>
@@ -163,6 +163,6 @@ void dmap_control_share_stop_lookup (DmapControlShare * share);
*/
void dmap_control_share_player_updated (DmapControlShare * share);
-#endif /* __DMAP_CONTROL_SHARE_H */
+#endif /* _DMAP_CONTROL_SHARE_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-db.c b/libdmapsharing/dmap-db.c
index 7d6b5d5..2441d71 100644
--- a/libdmapsharing/dmap-db.c
+++ b/libdmapsharing/dmap-db.c
@@ -79,8 +79,8 @@ dmap_db_count (const DmapDb * db)
return DMAP_DB_GET_INTERFACE (db)->count (db);
}
-gchar **
-_dmap_db_strsplit_using_quotes (const gchar * str)
+static gchar **
+_strsplit_using_quotes (const gchar * str)
{
/* What we are splitting looks something like this:
* 'foo'text to ignore'bar'.
@@ -104,8 +104,9 @@ _dmap_db_strsplit_using_quotes (const gchar * str)
* 'foo'+'bar'
* ^
*/
- if (*token == '\0' || *token == ' ' || *token == '+')
+ if (*token == '\0' || *token == ' ' || *token == '+') {
continue;
+ }
/* Handle mistaken split at escaped '. */
if (token[strlen (token) - 1] == '\\') {
@@ -127,21 +128,22 @@ _dmap_db_strsplit_using_quotes (const gchar * str)
}
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)
{
+ gboolean accept = FALSE;
GParamSpec *pspec;
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);
- if (pspec == NULL)
+ if (pspec == NULL) {
// Can't find the property in this record, so don't accept it.
- return FALSE;
+ goto done;
+ }
// Get the property value as a GValue set to the type of this
// property.
@@ -155,7 +157,7 @@ compare_record_property (DmapRecord * record, const gchar * property_name,
accept = (g_value_get_boolean (&value) &&
g_strcmp0 (property_value, "1") == 0);
g_value_unset (&value);
- return accept;
+ goto done;
} else if (g_value_type_transformable
(G_VALUE_TYPE (&value), G_TYPE_LONG)) {
// Prefer integer conversion.
@@ -166,13 +168,13 @@ compare_record_property (DmapRecord * record, const gchar * property_name,
("Failed to convert value into long for property %s",
property_name);
g_value_unset (&value);
- return FALSE;
+ goto done;
}
g_debug ("Compare %s (long): %ld %s", property_name, g_value_get_long (&dest),
property_value);
accept = (g_value_get_long (&dest) ==
strtol (property_value, NULL, 10));
g_value_unset (&value);
- return accept;
+ goto done;
} else if (g_value_type_transformable
(G_VALUE_TYPE (&value), G_TYPE_STRING)) {
// Use standard transform functions from GLib (note that these
@@ -186,7 +188,7 @@ compare_record_property (DmapRecord * record, const gchar * property_name,
("Failed to convert value into string for property %s",
property_name);
g_value_unset (&value);
- return FALSE;
+ goto done;
}
str_value = g_value_dup_string (&dest);
g_value_reset (&value);
@@ -196,7 +198,7 @@ compare_record_property (DmapRecord * record, const gchar * property_name,
} else {
g_warning ("Attempt to compare unhandled type");
g_value_unset (&value);
- return FALSE;
+ goto done;
}
// Only arrive here if we are handling strings.
@@ -206,33 +208,31 @@ compare_record_property (DmapRecord * record, const gchar * property_name,
accept = TRUE;
} else if (str_value == NULL && property_value == NULL) {
accept = TRUE;
- } else {
- accept = FALSE;
}
// This will destroy str_value since it belongs to value.
g_value_unset (&value);
+done:
return accept;
}
static void
-apply_filter (guint id, DmapRecord * record, gpointer data)
+_apply_filter (guint id, DmapRecord * record, gpointer data)
{
+ g_assert(IS_DMAP_RECORD (record));
+
FilterData *fd;
gboolean accept = FALSE;
const gchar *query_key;
const gchar *query_value;
- 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));
- return;
+ goto done;
}
GSList *list, *filter;
@@ -257,33 +257,40 @@ apply_filter (guint id, DmapRecord * record, gpointer data)
// Use only the part after the last dot.
// For instance, dmap.songgenre becomes songgenre.
property_name = strrchr (query_key, '.');
- if (property_name == NULL)
+ if (property_name == NULL) {
property_name = query_key;
- else
+ } else {
//Don't include the dot in the property name.
property_name++;
+ }
- accept = compare_record_property (record,
+ accept = _compare_record_property (record,
property_name,
query_value);
- if (def->negate)
+ if (def->negate) {
accept = !accept;
+ }
// If we accept this value, then quit looking at this
// group (groups are always OR)
- if (accept)
+ if (accept) {
break;
+ }
}
// Don't look any further, because groups are AND between
// each other, the first FALSE means FALSE at the end.
- if (!accept)
+ if (!accept) {
break;
+ }
}
if (accept) {
g_hash_table_insert (fd->ht, GUINT_TO_POINTER (id),
g_object_ref (record));
}
+
+done:
+ return;
}
GHashTable *
@@ -298,7 +305,7 @@ dmap_db_apply_filter (DmapDb * db, GSList * filter_def)
data.filter_def = filter_def;
data.ht = ht;
- dmap_db_foreach (db, (DmapIdRecordFunc) apply_filter, &data);
+ dmap_db_foreach (db, (DmapIdRecordFunc) _apply_filter, &data);
return data.ht;
}
diff --git a/libdmapsharing/dmap-db.h b/libdmapsharing/dmap-db.h
index ff5be8b..bbeba44 100644
--- a/libdmapsharing/dmap-db.h
+++ b/libdmapsharing/dmap-db.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_DB_H
-#define __DMAP_DB_H
+#ifndef _DMAP_DB_H
+#define _DMAP_DB_H
#include <glib-object.h>
@@ -188,8 +188,6 @@ void dmap_db_foreach (const DmapDb * db, DmapIdRecordFunc func, gpointer data);
*/
gulong dmap_db_count (const DmapDb * db);
-gchar **_dmap_db_strsplit_using_quotes (const gchar * str);
-
/**
* dmap_db_apply_filter:
* @db: A media database.
@@ -199,6 +197,6 @@ gchar **_dmap_db_strsplit_using_quotes (const gchar * str);
*/
GHashTable *dmap_db_apply_filter (DmapDb * db, GSList * filter_def);
-#endif /* __DMAP_DB_H */
+#endif /* _DMAP_DB_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-gst-input-stream.h b/libdmapsharing/dmap-gst-input-stream.h
index 581ffcf..18a21d4 100644
--- a/libdmapsharing/dmap-gst-input-stream.h
+++ b/libdmapsharing/dmap-gst-input-stream.h
@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_GST_INPUT_STREAM
-#define __DMAP_GST_INPUT_STREAM
+#ifndef _DMAP_GST_INPUT_STREAM
+#define _DMAP_GST_INPUT_STREAM
#include <glib-object.h>
#include <gio/gio.h>
@@ -76,4 +76,4 @@ void dmap_gst_input_stream_new_buffer_cb (GstElement *element,
*/
G_END_DECLS
-#endif /* __DMAP_GST_INPUT_STREAM */
+#endif /* _DMAP_GST_INPUT_STREAM */
diff --git a/libdmapsharing/dmap-gst-mp3-input-stream.h b/libdmapsharing/dmap-gst-mp3-input-stream.h
index aebbdeb..7222785 100644
--- a/libdmapsharing/dmap-gst-mp3-input-stream.h
+++ b/libdmapsharing/dmap-gst-mp3-input-stream.h
@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_GST_MP3_INPUT_STREAM
-#define __DMAP_GST_MP3_INPUT_STREAM
+#ifndef _DMAP_GST_MP3_INPUT_STREAM
+#define _DMAP_GST_MP3_INPUT_STREAM
#include <gio/gio.h>
@@ -63,4 +63,4 @@ GType dmap_gst_mp3_input_stream_get_type (void);
GInputStream *dmap_gst_mp3_input_stream_new (GInputStream * stream);
G_END_DECLS
-#endif /* __DMAP_GST_MP3_INPUT_STREAM */
+#endif /* _DMAP_GST_MP3_INPUT_STREAM */
diff --git a/libdmapsharing/dmap-gst-qt-input-stream.h b/libdmapsharing/dmap-gst-qt-input-stream.h
index 20d69c4..6bde664 100644
--- a/libdmapsharing/dmap-gst-qt-input-stream.h
+++ b/libdmapsharing/dmap-gst-qt-input-stream.h
@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_GST_QT_INPUT_STREAM
-#define __DMAP_GST_QT_INPUT_STREAM
+#ifndef _DMAP_GST_QT_INPUT_STREAM
+#define _DMAP_GST_QT_INPUT_STREAM
#include <gio/gio.h>
@@ -63,4 +63,4 @@ GType dmap_gst_qt_input_stream_get_type (void);
GInputStream *dmap_gst_qt_input_stream_new (GInputStream * stream);
G_END_DECLS
-#endif /* __DMAP_GST_QT_INPUT_STREAM */
+#endif /* _DMAP_GST_QT_INPUT_STREAM */
diff --git a/libdmapsharing/dmap-gst-wav-input-stream.h b/libdmapsharing/dmap-gst-wav-input-stream.h
index a2d366a..ab50f1b 100644
--- a/libdmapsharing/dmap-gst-wav-input-stream.h
+++ b/libdmapsharing/dmap-gst-wav-input-stream.h
@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_GST_WAV_INPUT_STREAM
-#define __DMAP_GST_WAV_INPUT_STREAM
+#ifndef _DMAP_GST_WAV_INPUT_STREAM
+#define _DMAP_GST_WAV_INPUT_STREAM
#include <gio/gio.h>
@@ -63,4 +63,4 @@ GType dmap_gst_wav_input_stream_get_type (void);
GInputStream *dmap_gst_wav_input_stream_new (GInputStream * stream);
G_END_DECLS
-#endif /* __DMAP_GST_WAV_INPUT_STREAM */
+#endif /* _DMAP_GST_WAV_INPUT_STREAM */
diff --git a/libdmapsharing/dmap-image-connection.h b/libdmapsharing/dmap-image-connection.h
index 07d422e..3b9b9f1 100644
--- a/libdmapsharing/dmap-image-connection.h
+++ b/libdmapsharing/dmap-image-connection.h
@@ -14,8 +14,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_IMAGE_CONNECTION_H
-#define __DMAP_IMAGE_CONNECTION_H
+#ifndef _DMAP_IMAGE_CONNECTION_H
+#define _DMAP_IMAGE_CONNECTION_H
#include <glib-object.h>
@@ -91,4 +91,4 @@ DmapImageConnection *dmap_image_connection_new (const char *name,
DmapDb * db,
DmapRecordFactory * factory);
G_END_DECLS
-#endif /* __DMAP_IMAGE_CONNECTION_H */
+#endif /* _DMAP_IMAGE_CONNECTION_H */
diff --git a/libdmapsharing/dmap-image-record.h b/libdmapsharing/dmap-image-record.h
index 63909ee..dd0f74c 100644
--- a/libdmapsharing/dmap-image-record.h
+++ b/libdmapsharing/dmap-image-record.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_IMAGE_RECORD_H
-#define __DMAP_IMAGE_RECORD_H
+#ifndef _DMAP_IMAGE_RECORD_H
+#define _DMAP_IMAGE_RECORD_H
#include <glib.h>
#include <gio/gio.h>
@@ -83,6 +83,6 @@ GType dmap_image_record_get_type (void);
*/
GInputStream *dmap_image_record_read (DmapImageRecord * record, GError ** err);
-#endif /* __DMAP_IMAGE_RECORD_H */
+#endif /* _DMAP_IMAGE_RECORD_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-image-share.h b/libdmapsharing/dmap-image-share.h
index bb9338f..701a630 100644
--- a/libdmapsharing/dmap-image-share.h
+++ b/libdmapsharing/dmap-image-share.h
@@ -21,8 +21,8 @@
*
*/
-#ifndef __DMAP_IMAGE_SHARE_H
-#define __DMAP_IMAGE_SHARE_H
+#ifndef _DMAP_IMAGE_SHARE_H
+#define _DMAP_IMAGE_SHARE_H
#include <glib-object.h>
@@ -110,6 +110,6 @@ DmapImageShare *dmap_image_share_new (const char *name, const char *password,
gpointer db, gpointer container_db,
gchar * transcode_mimetype);
-#endif /* __DMAP_IMAGE_SHARE_H */
+#endif /* _DMAP_IMAGE_SHARE_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-md5.c b/libdmapsharing/dmap-md5.c
index c164dac..e5cd2da 100644
--- a/libdmapsharing/dmap-md5.c
+++ b/libdmapsharing/dmap-md5.c
@@ -43,27 +43,27 @@
* with every copy.
*
* To compute the message digest of a chunk of bytes, declare an MD5Context
- * structure, pass it to DMAP_MD5Init, call DMAP_MD5Update as needed
- * on buffers full of bytes, and then call DMAP_MD5Final, which will fill
+ * structure, pass it to _init, call _update as needed
+ * on buffers full of bytes, and then call _final, which will fill
* a supplied 16-byte array with the digest.
*/
-static void MD5Transform (guint32 buf[4], guint32 const in[16], gint version);
+static void _transform (guint32 buf[4], guint32 const in[16], gint version);
/* for some reason we still have to reverse bytes on bigendian machines
* 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 */
+#define _byte_reverse(buf, len) /* Nothing */
#else
-static void byteReverse (unsigned char *buf, unsigned longs);
+static void _byte_reverse (unsigned char *buf, unsigned longs);
#ifndef ASM_MD5
/*
* Note: this code is harmless on little-endian machines.
*/
static void
-byteReverse (unsigned char *buf, unsigned longs)
+_byte_reverse (unsigned char *buf, unsigned longs)
{
guint32 t;
@@ -78,7 +78,7 @@ byteReverse (unsigned char *buf, unsigned longs)
#endif /* #if 0 */
static void
-DMAP_MD5Init (DmapHashContext * ctx, gint version)
+_init (DmapHashContext * ctx, gint version)
{
memset (ctx, 0, sizeof (DmapHashContext));
ctx->buf[0] = 0x67452301;
@@ -93,15 +93,16 @@ DMAP_MD5Init (DmapHashContext * ctx, gint version)
}
static void
-DMAP_MD5Update (DmapHashContext * ctx, unsigned char const *buf, unsigned int len)
+_update (DmapHashContext * 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)
+ 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 */
@@ -117,8 +118,8 @@ DMAP_MD5Update (DmapHashContext * ctx, unsigned char const *buf, unsigned int le
return;
}
memcpy (p, buf, t);
- byteReverse (ctx->in, 16);
- MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
+ _byte_reverse (ctx->in, 16);
+ _transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
buf += t;
len -= t;
}
@@ -126,8 +127,8 @@ DMAP_MD5Update (DmapHashContext * ctx, unsigned char const *buf, unsigned int le
while (len >= 64) {
memcpy (ctx->in, buf, 64);
- byteReverse (ctx->in, 16);
- MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
+ _byte_reverse (ctx->in, 16);
+ _transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
buf += 64;
len -= 64;
}
@@ -138,7 +139,7 @@ DMAP_MD5Update (DmapHashContext * ctx, unsigned char const *buf, unsigned int le
}
static void
-DMAP_MD5Final (DmapHashContext * ctx, unsigned char digest[16])
+_final (DmapHashContext * ctx, unsigned char digest[16])
{
unsigned count;
unsigned char *p;
@@ -159,8 +160,8 @@ DMAP_MD5Final (DmapHashContext * ctx, unsigned char digest[16])
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);
+ _byte_reverse (ctx->in, 16);
+ _transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
/* Now fill the next block with 56 bytes */
memset (ctx->in, 0, 56);
@@ -168,15 +169,15 @@ DMAP_MD5Final (DmapHashContext * ctx, unsigned char digest[16])
/* Pad block to 56 bytes */
memset (p, 0, count - 8);
}
- byteReverse (ctx->in, 14);
+ _byte_reverse (ctx->in, 14);
/* Append length in bits and transform */
tmp = (guint32 *) ctx->in;
tmp[14] = ctx->bits[0];
tmp[15] = ctx->bits[1];
- MD5Transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
- byteReverse ((unsigned char *) ctx->buf, 4);
+ _transform (ctx->buf, (guint32 *) ctx->in, ctx->version);
+ _byte_reverse ((unsigned char *) ctx->buf, 4);
memcpy (digest, ctx->buf, 16);
memset (ctx, 0, sizeof (*ctx)); /* In case it's sensitive */
@@ -199,11 +200,11 @@ DMAP_MD5Final (DmapHashContext * ctx, unsigned char digest[16])
/*
* The core of the MD5 algorithm, this alters an existing MD5 hash to reflect
-* the addition of 16 longwords of new data. DMAP_MD5Update blocks the
+* the addition of 16 longwords of new data. _update blocks the
* data and converts bytes into longwords for this routine.
*/
static void
-MD5Transform (guint32 buf[4], guint32 const in[16], gint version)
+_transform (guint32 buf[4], guint32 const in[16], gint version)
{
guint32 a, b, c, d;
@@ -294,250 +295,269 @@ MD5Transform (guint32 buf[4], guint32 const in[16], gint version)
#endif
-static gint staticHashDone = 0;
-static unsigned char staticHash_42[256 * 65] = { 0 };
-static unsigned char staticHash_45[256 * 65] = { 0 };
+static gint _done = 0;
+static unsigned char _42[256 * 65] = { 0 };
+static unsigned char _45[256 * 65] = { 0 };
-static const gchar hexchars[] = "0123456789ABCDEF";
-static gchar ac[] = "Dpqzsjhiu!3114!Bqqmf!Dpnqvufs-!Jod/"; /* +1 */
-static gboolean ac_unfudged = FALSE;
+static const gchar _hexchars[] = "0123456789ABCDEF";
+static gchar _ac[] = "Dpqzsjhiu!3114!Bqqmf!Dpnqvufs-!Jod/"; /* +1 */
+static gboolean _ac_unfudged = FALSE;
void
-dmap_hash_progressive_to_string (const unsigned char *digest, gchar * string)
+dmap_md5_progressive_to_string (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];
+ string[i * 2 + 1] = _hexchars[tmp & 0x0f];
+ string[i * 2] = _hexchars[(tmp >> 4) & 0x0f];
}
}
static void
-GenerateStatic_42 ()
+_generate_static_42 ()
{
DmapHashContext ctx;
- unsigned char *p = staticHash_42;
+ unsigned char *p = _42;
int i;
unsigned char buf[16];
for (i = 0; i < 256; i++) {
- DMAP_MD5Init (&ctx, 0);
+ _init (&ctx, 0);
-#define MD5_STRUPDATE(str) DMAP_MD5Update(&ctx, (unsigned char const *)str, strlen(str))
+#define MD5_STRUPDATE(str) _update(&ctx, (unsigned char const *)str, strlen(str))
- if ((i & 0x80) != 0)
+ if ((i & 0x80) != 0) {
MD5_STRUPDATE ("Accept-Language");
- else
+ } else {
MD5_STRUPDATE ("user-agent");
+ }
- if ((i & 0x40) != 0)
+ if ((i & 0x40) != 0) {
MD5_STRUPDATE ("max-age");
- else
+ } else {
MD5_STRUPDATE ("Authorization");
+ }
- if ((i & 0x20) != 0)
+ if ((i & 0x20) != 0) {
MD5_STRUPDATE ("Client-DAAP-Version");
- else
+ } else {
MD5_STRUPDATE ("Accept-Encoding");
+ }
- if ((i & 0x10) != 0)
+ if ((i & 0x10) != 0) {
MD5_STRUPDATE ("daap.protocolversion");
- else
+ } else {
MD5_STRUPDATE ("daap.songartist");
+ }
- if ((i & 0x08) != 0)
+ if ((i & 0x08) != 0) {
MD5_STRUPDATE ("daap.songcomposer");
- else
+ } else {
MD5_STRUPDATE ("daap.songdatemodified");
+ }
- if ((i & 0x04) != 0)
+ if ((i & 0x04) != 0) {
MD5_STRUPDATE ("daap.songdiscnumber");
- else
+ } else {
MD5_STRUPDATE ("daap.songdisabled");
+ }
- if ((i & 0x02) != 0)
+ if ((i & 0x02) != 0) {
MD5_STRUPDATE ("playlist-item-spec");
- else
+ } else {
MD5_STRUPDATE ("revision-number");
+ }
- if ((i & 0x01) != 0)
+ if ((i & 0x01) != 0) {
MD5_STRUPDATE ("session-id");
- else
+ } else {
MD5_STRUPDATE ("content-codes");
+ }
#undef MD5_STRUPDATE
- DMAP_MD5Final (&ctx, buf);
- dmap_hash_progressive_to_string (buf, (char *) p);
+ _final (&ctx, buf);
+ dmap_md5_progressive_to_string (buf, (char *) p);
p += 65;
}
}
static void
-GenerateStatic_45 ()
+_generate_static_45 ()
{
DmapHashContext ctx;
- unsigned char *p = staticHash_45;
+ unsigned char *p = _45;
int i;
unsigned char buf[16];
for (i = 0; i < 256; i++) {
- DMAP_MD5Init (&ctx, 1);
+ _init (&ctx, 1);
-#define MD5_STRUPDATE(str) DMAP_MD5Update(&ctx, (unsigned char const *)str, strlen(str))
+#define MD5_STRUPDATE(str) _update(&ctx, (unsigned char const *)str, strlen(str))
- if ((i & 0x40) != 0)
+ if ((i & 0x40) != 0) {
MD5_STRUPDATE ("eqwsdxcqwesdc");
- else
+ } else {
MD5_STRUPDATE ("op[;lm,piojkmn");
+ }
- if ((i & 0x20) != 0)
+ if ((i & 0x20) != 0) {
MD5_STRUPDATE ("876trfvb 34rtgbvc");
- else
+ } else {
MD5_STRUPDATE ("=-0ol.,m3ewrdfv");
+ }
- if ((i & 0x10) != 0)
+ if ((i & 0x10) != 0) {
MD5_STRUPDATE ("87654323e4rgbv ");
- else
+ } else {
MD5_STRUPDATE ("1535753690868867974342659792");
+ }
- if ((i & 0x08) != 0)
+ if ((i & 0x08) != 0) {
MD5_STRUPDATE ("Song Name");
- else
+ } else {
MD5_STRUPDATE ("DAAP-CLIENT-ID:");
+ }
- if ((i & 0x04) != 0)
+ if ((i & 0x04) != 0) {
MD5_STRUPDATE ("111222333444555");
- else
+ } else {
MD5_STRUPDATE ("4089961010");
+ }
- if ((i & 0x02) != 0)
+ if ((i & 0x02) != 0) {
MD5_STRUPDATE ("playlist-item-spec");
- else
+ } else {
MD5_STRUPDATE ("revision-number");
+ }
- if ((i & 0x01) != 0)
+ if ((i & 0x01) != 0) {
MD5_STRUPDATE ("session-id");
- else
+ } else {
MD5_STRUPDATE ("content-codes");
+ }
- if ((i & 0x80) != 0)
+ if ((i & 0x80) != 0) {
MD5_STRUPDATE ("IUYHGFDCXWEDFGHN");
- else
+ } else {
MD5_STRUPDATE ("iuytgfdxwerfghjm");
+ }
#undef MD5_STRUPDATE
- DMAP_MD5Final (&ctx, buf);
- dmap_hash_progressive_to_string (buf, (char *) p);
+ _final (&ctx, buf);
+ dmap_md5_progressive_to_string (buf, (char *) p);
p += 65;
}
}
void
-dmap_hash_generate (short version_major,
- const guchar * url,
- guchar hash_select, guchar * out, gint request_id)
+dmap_md5_generate (short version_major,
+ const guchar * url,
+ guchar hash_select, guchar * out, gint request_id)
{
unsigned char buf[16];
DmapHashContext ctx;
gint i;
unsigned char *hashTable = (version_major == 3) ?
- staticHash_45 : staticHash_42;
+ _45 : _42;
- if (!staticHashDone) {
- GenerateStatic_42 ();
- GenerateStatic_45 ();
- staticHashDone = 1;
+ if (!_done) {
+ _generate_static_42 ();
+ _generate_static_45 ();
+ _done = 1;
}
- DMAP_MD5Init (&ctx, (version_major == 3) ? 1 : 0);
+ _init (&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;
+ _update (&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;
+ _ac_unfudged = TRUE;
}
- DMAP_MD5Update (&ctx, (const guchar *) ac, strlen (ac));
+ _update (&ctx, (const guchar *) _ac, strlen (_ac));
- DMAP_MD5Update (&ctx, &hashTable[hash_select * 65], 32);
+ _update (&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,
+ _update (&ctx, (const guchar *) scribble,
strlen (scribble));
}
- DMAP_MD5Final (&ctx, buf);
- dmap_hash_progressive_to_string (buf, (gchar *) out);
+ _final (&ctx, buf);
+ dmap_md5_progressive_to_string (buf, (gchar *) out);
return;
}
-void dmap_hash_progressive_init (DmapHashContext *context)
+void
+dmap_md5_progressive_init (DmapHashContext *context)
{
- /* FIXME: Share this stuff with dmap_hash_generate() */
- if (!staticHashDone) {
- GenerateStatic_42 ();
- GenerateStatic_45 ();
- staticHashDone = 1;
+ /* FIXME: Share this stuff with dmap_md5_generate() */
+ if (!_done) {
+ _generate_static_42 ();
+ _generate_static_45 ();
+ _done = 1;
}
- DMAP_MD5Init (context, 1);
+ _init (context, 1);
}
-void dmap_hash_progressive_update (DmapHashContext *context,
+void
+dmap_md5_progressive_update (DmapHashContext *context,
unsigned char const *buffer,
unsigned int length)
{
- DMAP_MD5Update (context, buffer, length);
+ _update (context, buffer, length);
}
-void dmap_hash_progressive_final (DmapHashContext *context,
+void
+dmap_md5_progressive_final (DmapHashContext *context,
unsigned char digest[16])
{
- /* FIXME: This is only equivalent to dmap_hash_generate()
+ /* FIXME: This is only equivalent to dmap_md5_generate()
* when it is called with (3, x, 2, y, 0).
*/
int i;
- /* FIXME: Share this stuff with dmap_hash_generate() */
- if (ac_unfudged == FALSE) {
- for (i = 0; i < strlen (ac); i++) {
- ac[i] = ac[i] - 1;
+ /* FIXME: Share this stuff with dmap_md5_generate() */
+ if (_ac_unfudged == FALSE) {
+ for (i = 0; i < strlen (_ac); i++) {
+ _ac[i] = _ac[i] - 1;
}
- ac_unfudged = TRUE;
+ _ac_unfudged = TRUE;
}
- DMAP_MD5Update (context, (const guchar *) ac, strlen (ac));
+ _update (context, (const guchar *) _ac, strlen (_ac));
- DMAP_MD5Update (context, &staticHash_45[2 * 65], 32);
+ _update (context, &_45[2 * 65], 32);
- DMAP_MD5Final (context, digest);
+ _final (context, digest);
}
#ifdef HAVE_CHECK
#include <check.h>
-START_TEST(test_dmap_hash_generate_v3_h2)
+START_TEST(test_dmap_md5_generate_v3_h2)
{
guchar hash[33] = { 0 };
guchar *url = (guchar *) "test://foo";
- dmap_hash_generate (3, url, 2, hash, 0);
+ dmap_md5_generate (3, url, 2, hash, 0);
fail_unless (! memcmp (hash, "798A9D80B6F08E339603BE83E0FEAD03", strlen
("798A9D80B6F08E339603BE83E0FEAD03")));
}
END_TEST
-START_TEST(test_dmap_hash_progressive)
+START_TEST(test_dmap_md5_progressive)
{
guchar buf[16] = { 0 };
guchar hash1[33] = { 0 };
@@ -545,17 +565,17 @@ START_TEST(test_dmap_hash_progressive)
guchar *value = (guchar *) "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
DmapHashContext context;
- dmap_hash_progressive_init (&context);
- dmap_hash_progressive_update (&context, value, 5);
- dmap_hash_progressive_update (&context, value + 5, 5);
- dmap_hash_progressive_update (&context, value + 10, 5);
- dmap_hash_progressive_update (&context, value + 15, 5);
- dmap_hash_progressive_update (&context, value + 20, 5);
- dmap_hash_progressive_update (&context, value + 25, 1);
- dmap_hash_progressive_final (&context, buf);
- dmap_hash_progressive_to_string (buf, (gchar *) hash1);
-
- dmap_hash_generate (3, value, 2, hash2, 0);
+ dmap_md5_progressive_init (&context);
+ dmap_md5_progressive_update (&context, value, 5);
+ dmap_md5_progressive_update (&context, value + 5, 5);
+ dmap_md5_progressive_update (&context, value + 10, 5);
+ dmap_md5_progressive_update (&context, value + 15, 5);
+ dmap_md5_progressive_update (&context, value + 20, 5);
+ dmap_md5_progressive_update (&context, value + 25, 1);
+ dmap_md5_progressive_final (&context, buf);
+ dmap_md5_progressive_to_string (buf, (gchar *) hash1);
+
+ dmap_md5_generate (3, value, 2, hash2, 0);
fail_unless (! memcmp (hash1, hash2, 32));
}
diff --git a/libdmapsharing/dmap-md5.h b/libdmapsharing/dmap-md5.h
index 1101d62..ed8b346 100644
--- a/libdmapsharing/dmap-md5.h
+++ b/libdmapsharing/dmap-md5.h
@@ -35,22 +35,22 @@ typedef struct DmapHashContext
gint version;
} DmapHashContext;
-void dmap_hash_progressive_init (DmapHashContext *context);
+void dmap_md5_progressive_init (DmapHashContext *context);
-void dmap_hash_progressive_update (DmapHashContext *context,
- unsigned char const *buffer,
- unsigned int length);
+void dmap_md5_progressive_update (DmapHashContext *context,
+ unsigned char const *buffer,
+ unsigned int length);
-void dmap_hash_progressive_final (DmapHashContext *context,
- unsigned char digest[16]);
+void dmap_md5_progressive_final (DmapHashContext *context,
+ unsigned char digest[16]);
-void dmap_hash_progressive_to_string (const unsigned char *digest, gchar * string);
+void dmap_md5_progressive_to_string (const unsigned char *digest, gchar * string);
-void dmap_hash_generate (short version_major,
- const guchar *url,
- guchar hash_select,
- guchar *out,
- gint request_id);
+void dmap_md5_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.h b/libdmapsharing/dmap-mdns-avahi.h
index dba28fb..f52c92e 100644
--- a/libdmapsharing/dmap-mdns-avahi.h
+++ b/libdmapsharing/dmap-mdns-avahi.h
@@ -18,8 +18,8 @@
*
*/
-#ifndef __DMAP_MDNS_AVAHI_H
-#define __DMAP_MDNS_AVAHI_H
+#ifndef _DMAP_MDNS_AVAHI_H
+#define _DMAP_MDNS_AVAHI_H
#include <avahi-client/client.h>
#include <avahi-client/publish.h>
diff --git a/libdmapsharing/dmap-mdns-browser.h b/libdmapsharing/dmap-mdns-browser.h
index d2d7c11..91178ec 100644
--- a/libdmapsharing/dmap-mdns-browser.h
+++ b/libdmapsharing/dmap-mdns-browser.h
@@ -19,8 +19,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA*
*/
-#ifndef __DMAP_MDNS_BROWSER_H__
-#define __DMAP_MDNS_BROWSER_H__
+#ifndef _DMAP_MDNS_BROWSER_H
+#define _DMAP_MDNS_BROWSER_H
#include <glib.h>
#include <glib-object.h>
diff --git a/libdmapsharing/dmap-mdns-publisher-avahi.c b/libdmapsharing/dmap-mdns-publisher-avahi.c
index 27387cd..1ca1657 100644
--- a/libdmapsharing/dmap-mdns-publisher-avahi.c
+++ b/libdmapsharing/dmap-mdns-publisher-avahi.c
@@ -326,9 +326,9 @@ dmap_mdns_publisher_withdraw (DmapMdnsPublisher * publisher,
return FALSE;
}
- free_service (ptr, NULL);
publisher->priv->service =
g_slist_remove (publisher->priv->service, ptr);
+ free_service (ptr, NULL);
if (publisher->priv->service == NULL) {
avahi_entry_group_reset (publisher->priv->entry_group);
diff --git a/libdmapsharing/dmap-mdns-publisher.h b/libdmapsharing/dmap-mdns-publisher.h
index 2df449f..c748159 100644
--- a/libdmapsharing/dmap-mdns-publisher.h
+++ b/libdmapsharing/dmap-mdns-publisher.h
@@ -21,8 +21,8 @@
*
*/
-#ifndef __DMAP_MDNS_PUBLISHER_H
-#define __DMAP_MDNS_PUBLISHER_H
+#ifndef _DMAP_MDNS_PUBLISHER_H
+#define _DMAP_MDNS_PUBLISHER_H
#include <glib.h>
#include <glib-object.h>
@@ -79,4 +79,4 @@ gboolean dmap_mdns_publisher_withdraw (DmapMdnsPublisher * publisher,
guint port, GError ** error);
G_END_DECLS
-#endif /* __DMAP_MDNS_PUBLISHER_H */
+#endif /* _DMAP_MDNS_PUBLISHER_H */
diff --git a/libdmapsharing/dmap-mdns-service.h b/libdmapsharing/dmap-mdns-service.h
index 920cea0..d911f66 100644
--- a/libdmapsharing/dmap-mdns-service.h
+++ b/libdmapsharing/dmap-mdns-service.h
@@ -16,8 +16,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA*
*/
-#ifndef __DMAP_MDNS_SERVICE_H__
-#define __DMAP_MDNS_SERVICE_H__
+#ifndef _DMAP_MDNS_SERVICE_H
+#define _DMAP_MDNS_SERVICE_H
#include <glib.h>
#include <glib-object.h>
diff --git a/libdmapsharing/dmap-record-factory.h b/libdmapsharing/dmap-record-factory.h
index 4e1de37..2d0b3ba 100644
--- a/libdmapsharing/dmap-record-factory.h
+++ b/libdmapsharing/dmap-record-factory.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_RECORD_FACTORY_H
-#define __DMAP_RECORD_FACTORY_H
+#ifndef _DMAP_RECORD_FACTORY_H
+#define _DMAP_RECORD_FACTORY_H
#include <glib-object.h>
@@ -86,6 +86,6 @@ GType dmap_record_factory_get_type (void);
DmapRecord *dmap_record_factory_create (DmapRecordFactory * factory,
gpointer user_data);
-#endif /* __DMAP_RECORD_FACTORY_H */
+#endif /* _DMAP_RECORD_FACTORY_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-record.h b/libdmapsharing/dmap-record.h
index 1f85f9c..382dc20 100644
--- a/libdmapsharing/dmap-record.h
+++ b/libdmapsharing/dmap-record.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __DMAP_RECORD_H
-#define __DMAP_RECORD_H
+#ifndef _DMAP_RECORD_H
+#define _DMAP_RECORD_H
#include <glib-object.h>
@@ -97,6 +97,6 @@ GArray *dmap_record_to_blob (DmapRecord * record);
gboolean dmap_record_set_from_blob (DmapRecord * record,
GArray * blob);
-#endif /* __DMAP_RECORD_H */
+#endif /* _DMAP_RECORD_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-share.c b/libdmapsharing/dmap-share.c
index b029202..78feafa 100644
--- a/libdmapsharing/dmap-share.c
+++ b/libdmapsharing/dmap-share.c
@@ -948,7 +948,7 @@ void
_dmap_share_name_collision (DmapShare * share,
DmapMdnsPublisher * publisher, const char *name)
{
- char *new_name = "FIXME";
+ char *new_name = g_strdup("FIXME");
if (share->priv->name == NULL || name == NULL) {
return;
diff --git a/libdmapsharing/dmap-share.h b/libdmapsharing/dmap-share.h
index f960da8..d0f12cf 100644
--- a/libdmapsharing/dmap-share.h
+++ b/libdmapsharing/dmap-share.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef __DMAP_SHARE_H
-#define __DMAP_SHARE_H
+#ifndef _DMAP_SHARE_H
+#define _DMAP_SHARE_H
#include <glib-object.h>
@@ -292,6 +292,6 @@ void _dmap_share_name_collision (DmapShare * share,
DmapMdnsPublisher * publisher,
const char *name);
-#endif /* __DMAP_SHARE_H */
+#endif /* _DMAP_SHARE_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-structure.h b/libdmapsharing/dmap-structure.h
index 435758a..a840513 100644
--- a/libdmapsharing/dmap-structure.h
+++ b/libdmapsharing/dmap-structure.h
@@ -24,177 +24,7 @@
#include <glib.h>
#include <glib-object.h>
-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_CC_MDCL,
- DMAP_CC_MSTT,
- DMAP_CC_MIID,
- DMAP_CC_MINM,
- DMAP_CC_MIKD,
- DMAP_CC_MPER,
- DMAP_CC_MCON,
- DMAP_CC_MCTI,
- DMAP_CC_MPCO,
- DMAP_CC_MSTS,
- DMAP_CC_MIMC,
- DMAP_CC_MCTC,
- DMAP_CC_MRCO,
- DMAP_CC_MTCO,
- DMAP_CC_MLCL,
- DMAP_CC_MLIT,
- DMAP_CC_MBCL,
- DMAP_CC_MSRV,
- DMAP_CC_MSAU,
- DMAP_CC_MSLR,
- DMAP_CC_MPRO,
- DMAP_CC_MSAL,
- DMAP_CC_MSUP,
- DMAP_CC_MSPI,
- DMAP_CC_MSEX,
- DMAP_CC_MSBR,
- DMAP_CC_MSQY,
- DMAP_CC_MSIX,
- DMAP_CC_MSRS,
- DMAP_CC_MSTM,
- DMAP_CC_MSDC,
- DMAP_CC_MCCR,
- DMAP_CC_MCNM,
- DMAP_CC_MCNA,
- DMAP_CC_MCTY,
- DMAP_CC_MLOG,
- DMAP_CC_MLID,
- DMAP_CC_MUPD,
- DMAP_CC_MUSR,
- DMAP_CC_MUTY,
- DMAP_CC_MUDL,
- DMAP_CC_MSMA,
- DMAP_CC_FQUESCH,
-
- DMAP_CC_APRO,
- DMAP_CC_AVDB,
- DMAP_CC_ABRO,
- DMAP_CC_ABAL,
- DMAP_CC_ABAR,
- DMAP_CC_ABCP,
- DMAP_CC_ABGN,
- DMAP_CC_ADBS,
- DMAP_CC_ASAL,
- DMAP_CC_ASAI,
- DMAP_CC_ASAA,
- DMAP_CC_ASAR,
- DMAP_CC_ASBT,
- DMAP_CC_ASBR,
- DMAP_CC_ASCM,
- DMAP_CC_ASCO,
- DMAP_CC_ASDA,
- DMAP_CC_ASDM,
- DMAP_CC_ASDC,
- DMAP_CC_ASDN,
- DMAP_CC_ASDB,
- DMAP_CC_ASEQ,
- DMAP_CC_ASFM,
- DMAP_CC_ASGN,
- DMAP_CC_ASDT,
- DMAP_CC_ASRV,
- DMAP_CC_ASSR,
- DMAP_CC_ASSZ,
- DMAP_CC_ASST,
- DMAP_CC_ASSP,
- DMAP_CC_ASTM,
- DMAP_CC_ASTC,
- DMAP_CC_ASTN,
- DMAP_CC_ASUR,
- DMAP_CC_ASYR,
- DMAP_CC_ASDK,
- DMAP_CC_ASUL,
- DMAP_CC_ASSU,
- DMAP_CC_ASSA,
- DMAP_CC_APLY,
- DMAP_CC_ABPL,
- DMAP_CC_APSO,
- DMAP_CC_PRSV,
- DMAP_CC_ARIF,
- DMAP_CC_MSAS,
- DMAP_CC_AGRP,
- DMAP_CC_AGAL,
- DMAP_CC_ASCP,
- DMAP_CC_PPRO,
- DMAP_CC_PASP,
- DMAP_CC_PFDT,
- DMAP_CC_PICD,
- DMAP_CC_PIMF,
- DMAP_CC_PFMT,
- DMAP_CC_PIFS,
- DMAP_CC_PLSZ,
- DMAP_CC_PHGT,
- DMAP_CC_PWTH,
- DMAP_CC_PRAT,
- DMAP_CC_PCMT,
- DMAP_CC_PRET,
-
- /* iTunes 6.02+ */
- DMAP_CC_AESV,
- DMAP_CC_AEHV,
-
- DMAP_CC_AESP,
- DMAP_CC_AEPP,
- DMAP_CC_AEPS,
- 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,
- DMAP_CC_CARP,
- DMAP_CC_CAAS,
- DMAP_CC_CAAR,
- DMAP_CC_CAIA,
- DMAP_CC_CANP,
- DMAP_CC_CANN,
- DMAP_CC_CANA,
- DMAP_CC_CANL,
- DMAP_CC_CANG,
- DMAP_CC_CANT,
- DMAP_CC_CASP,
- DMAP_CC_CASS,
- DMAP_CC_CAST,
- DMAP_CC_CASU,
- DMAP_CC_CASG,
- DMAP_CC_CACR,
-
- DMAP_CC_CMCP,
- DMAP_CC_CMGT,
- DMAP_CC_CMIK,
- DMAP_CC_CMSP,
- DMAP_CC_CMST,
- DMAP_CC_CMSV,
- DMAP_CC_CMSR,
- DMAP_CC_CMMK,
- DMAP_CC_CMVO,
-
- DMAP_CC_CMPR,
- DMAP_CC_CAPR,
- DMAP_CC_AEFR,
- DMAP_CC_CAOV,
- DMAP_CC_CMRL,
- DMAP_CC_CAHP,
- DMAP_CC_CAIV,
- DMAP_CC_CAVC
-} DmapContentCode;
+#include <libdmapsharing/dmap-cc.h>
typedef struct _DmapStructureItem DmapStructureItem;
diff --git a/libdmapsharing/dmap.h b/libdmapsharing/dmap.h
index 084b76c..e2cc88c 100644
--- a/libdmapsharing/dmap.h
+++ b/libdmapsharing/dmap.h
@@ -1,5 +1,5 @@
-#ifndef __DMAP_H
-#define __DMAP_H
+#ifndef _DMAP_H
+#define _DMAP_H
#include <libdmapsharing/dmap-av-connection.h>
#include <libdmapsharing/dmap-av-record.h>
@@ -25,4 +25,4 @@
#include <libdmapsharing/dmap-control-player.h>
#include <libdmapsharing/dmap-control-connection.h>
-#endif /* __DMAP_H */
+#endif /* _DMAP_H */
diff --git a/libdmapsharing/gst-util.h b/libdmapsharing/gst-util.h
index 66f33c8..e11bc4b 100644
--- a/libdmapsharing/gst-util.h
+++ b/libdmapsharing/gst-util.h
@@ -18,13 +18,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __GST_UTIL
-#define __GST_UTIL
+#ifndef _GST_UTIL
+#define _GST_UTIL
#include <gst/gst.h>
gboolean pads_compatible (GstPad * pad1, GstPad * pad2);
-#endif /* __GST_UTIL */
+#endif /* _GST_UTIL */
G_END_DECLS
diff --git a/libdmapsharing/test-dmap-av-record-factory.h b/libdmapsharing/test-dmap-av-record-factory.h
index 9180664..1bb7796 100644
--- a/libdmapsharing/test-dmap-av-record-factory.h
+++ b/libdmapsharing/test-dmap-av-record-factory.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __TEST_DMAP_AV_RECORD_FACTORY
-#define __TEST_DMAP_AV_RECORD_FACTORY
+#ifndef _TEST_DMAP_AV_RECORD_FACTORY
+#define _TEST_DMAP_AV_RECORD_FACTORY
#include <libdmapsharing/dmap.h>
@@ -53,6 +53,6 @@ TestDmapAvRecordFactory *test_dmap_av_record_factory_new (void);
DmapRecord *test_dmap_av_record_factory_create (DmapRecordFactory *factory, gpointer user_data);
-#endif /* __TEST_DMAP_AV_RECORD_FACTORY */
+#endif /* _TEST_DMAP_AV_RECORD_FACTORY */
G_END_DECLS
diff --git a/libdmapsharing/test-dmap-av-record.h b/libdmapsharing/test-dmap-av-record.h
index fca7dd1..0ec794b 100644
--- a/libdmapsharing/test-dmap-av-record.h
+++ b/libdmapsharing/test-dmap-av-record.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __TEST_DMAP_AV_RECORD
-#define __TEST_DMAP_AV_RECORD
+#ifndef _TEST_DMAP_AV_RECORD
+#define _TEST_DMAP_AV_RECORD
#include <libdmapsharing/dmap.h>
@@ -59,6 +59,6 @@ TestDmapAvRecord *test_dmap_av_record_new (void);
GInputStream *test_dmap_av_record_read (DmapAvRecord *record, GError **err);
-#endif /* __TEST_DMAP_AV_RECORD */
+#endif /* _TEST_DMAP_AV_RECORD */
G_END_DECLS
diff --git a/libdmapsharing/test-dmap-container-db.h b/libdmapsharing/test-dmap-container-db.h
index e04fb7f..1cce76c 100644
--- a/libdmapsharing/test-dmap-container-db.h
+++ b/libdmapsharing/test-dmap-container-db.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __TEST_DMAP_CONTAINER_DB
-#define __TEST_DMAP_CONTAINER_DB
+#ifndef _TEST_DMAP_CONTAINER_DB
+#define _TEST_DMAP_CONTAINER_DB
#include <libdmapsharing/dmap.h>
@@ -51,6 +51,6 @@ TestDmapContainerDb *test_dmap_container_db_new (DmapContainerRecord
GType test_dmap_container_db_get_type (void);
-#endif /* __TEST_DMAP_CONTAINER_DB */
+#endif /* _TEST_DMAP_CONTAINER_DB */
G_END_DECLS
diff --git a/libdmapsharing/test-dmap-container-record.h b/libdmapsharing/test-dmap-container-record.h
index ecd9269..1f7fc7a 100644
--- a/libdmapsharing/test-dmap-container-record.h
+++ b/libdmapsharing/test-dmap-container-record.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __TEST_DMAP_CONTAINER_RECORD
-#define __TEST_DMAP_CONTAINER_RECORD
+#ifndef _TEST_DMAP_CONTAINER_RECORD
+#define _TEST_DMAP_CONTAINER_RECORD
#include <libdmapsharing/dmap.h>
#include <libdmapsharing/test-dmap-db.h>
@@ -56,6 +56,6 @@ TestDmapContainerRecord *test_dmap_container_record_new (void);
guint test_dmap_container_record_get_id (DmapContainerRecord *record);
-#endif /* __TEST_DMAP_CONTAINER_RECORD */
+#endif /* _TEST_DMAP_CONTAINER_RECORD */
G_END_DECLS
diff --git a/libdmapsharing/test-dmap-db.h b/libdmapsharing/test-dmap-db.h
index eb30c74..cbe944d 100644
--- a/libdmapsharing/test-dmap-db.h
+++ b/libdmapsharing/test-dmap-db.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __TEST_DMAP_DB
-#define __TEST_DMAP_DB
+#ifndef _TEST_DMAP_DB
+#define _TEST_DMAP_DB
#include <libdmapsharing/dmap.h>
@@ -54,6 +54,6 @@ typedef struct {
TestDmapDb *test_dmap_db_new (void);
GType test_dmap_db_get_type (void);
-#endif /* __TEST_DMAP_DB */
+#endif /* _TEST_DMAP_DB */
G_END_DECLS
diff --git a/libdmapsharing/test-dmap-image-record-factory.h b/libdmapsharing/test-dmap-image-record-factory.h
index 803a40a..32303c3 100644
--- a/libdmapsharing/test-dmap-image-record-factory.h
+++ b/libdmapsharing/test-dmap-image-record-factory.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __TEST_DMAP_IMAGE_RECORD_FACTORY
-#define __TEST_DMAP_IMAGE_RECORD_FACTORY
+#ifndef _TEST_DMAP_IMAGE_RECORD_FACTORY
+#define _TEST_DMAP_IMAGE_RECORD_FACTORY
#include <libdmapsharing/dmap.h>
@@ -53,6 +53,6 @@ TestDmapImageRecordFactory *test_dmap_image_record_factory_new (void);
DmapRecord *test_dmap_image_record_factory_create (DmapRecordFactory *factory, gpointer
user_data);
-#endif /* __TEST_DMAP_IMAGE_RECORD_FACTORY */
+#endif /* _TEST_DMAP_IMAGE_RECORD_FACTORY */
G_END_DECLS
diff --git a/libdmapsharing/test-dmap-image-record.h b/libdmapsharing/test-dmap-image-record.h
index bc941ca..3950bf2 100644
--- a/libdmapsharing/test-dmap-image-record.h
+++ b/libdmapsharing/test-dmap-image-record.h
@@ -18,8 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef __TEST_DMAP_IMAGE_RECORD
-#define __TEST_DMAP_IMAGE_RECORD
+#ifndef _TEST_DMAP_IMAGE_RECORD
+#define _TEST_DMAP_IMAGE_RECORD
#include <libdmapsharing/dmap.h>
@@ -60,6 +60,6 @@ TestDmapImageRecord *test_dmap_image_record_new (void);
GInputStream *test_dmap_image_record_read (DmapImageRecord *record,
GError **err);
-#endif /* __TEST_DMAP_IMAGE_RECORD */
+#endif /* _TEST_DMAP_IMAGE_RECORD */
G_END_DECLS
diff --git a/tests/dacplisten.c b/tests/dacplisten.c
index 7549bd5..7cf6d5a 100644
--- a/tests/dacplisten.c
+++ b/tests/dacplisten.c
@@ -1,4 +1,4 @@
-/* dacplisten.c generated by valac 0.38.4, the Vala compiler
+/* dacplisten.c generated by valac 0.38.7, the Vala compiler
* generated from dacplisten.vala, do not modify */
/* FILE: dacplisten.vala -- Listen to DACP remotes
diff --git a/tests/dmapcopy.c b/tests/dmapcopy.c
index e8d0873..eb99c18 100644
--- a/tests/dmapcopy.c
+++ b/tests/dmapcopy.c
@@ -1,4 +1,4 @@
-/* dmapcopy.c generated by valac 0.38.4, the Vala compiler
+/* dmapcopy.c generated by valac 0.38.7, the Vala compiler
* generated from dmapcopy.vala, do not modify */
/* FILE: dmapcopy.vala -- Copy files from a DMAP server
@@ -62,11 +62,6 @@ typedef struct _ValaDmapDbClass ValaDmapDbClass;
typedef struct _ValaImageRecordFactory ValaImageRecordFactory;
typedef struct _ValaImageRecordFactoryClass ValaImageRecordFactoryClass;
-enum {
- DPAP_COPY_0_PROPERTY,
- DPAP_COPY_NUM_PROPERTIES
-};
-static GParamSpec* dpap_copy_properties[DPAP_COPY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define TYPE_VALA_IMAGE_RECORD (vala_image_record_get_type ())
diff --git a/tests/dmapserve.c b/tests/dmapserve.c
index 9b27987..142ca6b 100644
--- a/tests/dmapserve.c
+++ b/tests/dmapserve.c
@@ -1,4 +1,4 @@
-/* dmapserve.c generated by valac 0.38.4, the Vala compiler
+/* dmapserve.c generated by valac 0.38.7, the Vala compiler
* generated from dmapserve.vala, do not modify */
/* FILE: dmapserve.vala -- Serve media using DMAP
@@ -72,11 +72,6 @@ typedef struct _ValaDmapDbClass ValaDmapDbClass;
typedef struct _ValaDmapContainerDb ValaDmapContainerDb;
typedef struct _ValaDmapContainerDbClass ValaDmapContainerDbClass;
-enum {
- DPAP_SERVE_0_PROPERTY,
- DPAP_SERVE_NUM_PROPERTIES
-};
-static GParamSpec* dpap_serve_properties[DPAP_SERVE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _ParamSpecDPAPServe ParamSpecDPAPServe;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
diff --git a/tests/vala-dmap-container-db.c b/tests/vala-dmap-container-db.c
index 1b33805..4edd675 100644
--- a/tests/vala-dmap-container-db.c
+++ b/tests/vala-dmap-container-db.c
@@ -1,4 +1,4 @@
-/* vala-dmap-container-db.c generated by valac 0.38.4, the Vala compiler
+/* vala-dmap-container-db.c generated by valac 0.38.7, the Vala compiler
* generated from vala-dmap-container-db.vala, do not modify */
/* FILE: vala-dmap-db.vala -- A DmapContainerDb implementation in Vala
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]