[libdmapsharing] Clean up code following previous Content-Length fix Signed-off-by: W. Michael Petullo <mike flyn org



commit 84dee699de91cb051774c9e9481f1af280ea41ea
Author: W. Michael Petullo <mike flyn org>
Date:   Thu Nov 18 10:29:14 2010 -0600

    Clean up code following previous Content-Length fix
    Signed-off-by: W. Michael Petullo <mike flyn org>

 ChangeLog                       |    4 ++++
 libdmapsharing/daap-share.c     |    6 ++----
 libdmapsharing/dmap-share.c     |   10 ++++++++--
 libdmapsharing/dmap-share.h     |    2 +-
 libdmapsharing/dmap-structure.c |    2 +-
 libdmapsharing/dpap-share.c     |    6 ++----
 6 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 00d9817..9c82f41 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+18 November 2010 W. Michael Petullo <mike flyn org>
+
+	* Fix problem sharing to iTunes due to incorrect Content-Length
+
 11 November 2010 W. Michael Petullo <mike flyn org>
 
 	* Bump version number.
diff --git a/libdmapsharing/daap-share.c b/libdmapsharing/daap-share.c
index 7207d3b..bfc64f3 100644
--- a/libdmapsharing/daap-share.c
+++ b/libdmapsharing/daap-share.c
@@ -76,7 +76,7 @@ static void databases_items_xxx (DMAPShare *share,
 				 GHashTable *query,
 				 SoupClientContext *context);
 static struct DMAPMetaDataMap *get_meta_data_map (DMAPShare *share);
-static guint32 add_entry_to_mlcl (gpointer id,
+static void add_entry_to_mlcl (gpointer id,
 			       DMAPRecord *record,
 			       gpointer mb);
 
@@ -542,7 +542,7 @@ send_chunked_file (SoupServer *server, SoupMessage *message, DAAPRecord *record,
 	/* NOTE: cd g_free'd by chunked_message_finished(). */
 }
 
-static guint32
+static void
 add_entry_to_mlcl (gpointer id,
 		   DMAPRecord *record,
 		   gpointer _mb)
@@ -713,8 +713,6 @@ add_entry_to_mlcl (gpointer id,
 		g_object_get (record, "mediakind", &mediakind, NULL);
 		dmap_structure_add (mlit, DMAP_CC_AEMK, mediakind);
 	}
-
-	return ((DMAPStructureItem *) mlit->data)->size;
 }
 
 static void
diff --git a/libdmapsharing/dmap-share.c b/libdmapsharing/dmap-share.c
index 7b8b2b6..3f0bab7 100644
--- a/libdmapsharing/dmap-share.c
+++ b/libdmapsharing/dmap-share.c
@@ -1459,7 +1459,13 @@ accumulate_mlcl_size (gpointer id,
 	struct MLCL_Bits mb_copy = *((struct MLCL_Bits *) mb);
 	mb_copy.mlcl = dmap_structure_add (NULL, DMAP_CC_MLCL);;
 
-	*((guint *) ((struct MLCL_Bits *) mb)->user_data1) += DMAP_SHARE_GET_CLASS (((struct MLCL_Bits *) mb)->user_data2)->add_entry_to_mlcl (id, record, &mb_copy) + 8 /* FIXME: sizeof MLIT */;
+	DMAP_SHARE_GET_CLASS (((struct MLCL_Bits *) mb)->user_data2)->add_entry_to_mlcl (id, record, &mb_copy);
+	*((guint *) ((struct MLCL_Bits *) mb)->user_data1) += dmap_structure_get_size(mb_copy.mlcl);
+
+	/* Minus eight because we do not want to add size of MLCL CC field + size field n times,
+	 * where n == number of records.
+	 */
+	*((guint *) ((struct MLCL_Bits *) mb)->user_data1) -= 8;
 
 	/* Destroy created structures as we go. */
 	dmap_structure_destroy (mb_copy.mlcl);
@@ -1746,7 +1752,7 @@ _dmap_share_databases (DMAPShare *share,
 
 			/* 3: */
 			soup_message_set_status (message, SOUP_STATUS_OK);
-			soup_message_headers_set_content_length (message->response_headers, dmap_structure_get_size(adbs) + 8 /* FIXME: sizeof MLCL */);
+			soup_message_headers_set_content_length (message->response_headers, dmap_structure_get_size(adbs));
 			/* Free memory after each chunk sent out over network. */
 			soup_message_body_set_accumulate (message->response_body, FALSE);
 
diff --git a/libdmapsharing/dmap-share.h b/libdmapsharing/dmap-share.h
index b4d7f0d..947150b 100644
--- a/libdmapsharing/dmap-share.h
+++ b/libdmapsharing/dmap-share.h
@@ -112,7 +112,7 @@ typedef struct {
 	void              (*message_add_standard_headers) (DMAPShare *share,
 							   SoupMessage *msg);
 	struct DMAPMetaDataMap * (*get_meta_data_map)     (DMAPShare *share);
-	guint32           (*add_entry_to_mlcl)            (gpointer id,
+	void              (*add_entry_to_mlcl)            (gpointer id,
 							   DMAPRecord *record,
 							   gpointer mb);
 	void		  (*databases_browse_xxx)	  (DMAPShare *share,
diff --git a/libdmapsharing/dmap-structure.c b/libdmapsharing/dmap-structure.c
index e7ac140..47e7f1c 100644
--- a/libdmapsharing/dmap-structure.c
+++ b/libdmapsharing/dmap-structure.c
@@ -789,7 +789,7 @@ dmap_structure_print (GNode *structure)
 guint
 dmap_structure_get_size (GNode *structure)
 {
-	return ((DMAPStructureItem *) structure->data)->size;
+	return ((DMAPStructureItem *) structure->data)->size + 8 /* FIXME: 8 = actual CC field + size field */;
 }
 
 
diff --git a/libdmapsharing/dpap-share.c b/libdmapsharing/dpap-share.c
index 8b99be7..8ca8bac 100644
--- a/libdmapsharing/dpap-share.c
+++ b/libdmapsharing/dpap-share.c
@@ -78,7 +78,7 @@ static void databases_items_xxx (DMAPShare *share,
 				 GHashTable *query,
 				 SoupClientContext *context);
 static struct DMAPMetaDataMap *get_meta_data_map (DMAPShare *share);
-static guint32 add_entry_to_mlcl (gpointer id,
+static void add_entry_to_mlcl (gpointer id,
 			       DMAPRecord *record,
 			       gpointer mb);
 
@@ -347,7 +347,7 @@ file_to_mmap (const char *location)
 	return mapped_file;
 }
 
-static guint32
+static void
 add_entry_to_mlcl (gpointer id,
 		   DMAPRecord *record,
 		   gpointer _mb)
@@ -466,8 +466,6 @@ add_entry_to_mlcl (gpointer id,
 		}
 		dmap_structure_add (mlit, DMAP_CC_PFDT, data, size);
 	}
-
-	return ((DMAPStructureItem *) mlit->data)->size;
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]