Commit 475c5cc6 authored by W. Michael Petullo's avatar W. Michael Petullo

Small API change and bump release to 1.9.0.21

Add dmap_db_add_with_id() to DMAPDb
interface. map_container_record_get_entries() must not return a const
because the return value should be free'd. Unref value returned
by dmap_container_record_get_entries(). Free strings returned by
g_object_get(). Change lookup_by_path() to lookup_by_location().
Signed-off-by: W. Michael Petullo's avatarW. Michael Petullo <mike@flyn.org>
parent 491a3235
04 June 2010 W. Michael Petullo <mike@flyn.org>
* Add dmap_db_add_with_id() to DMAPDb interface.
* dmap_container_record_get_entries() must not return a const
because the return value should be free'd.
01 June 2010 W. Michael Petullo <mike@flyn.org>
* Unref value returned by dmap_container_record_get_entries().
* Free strings returned by g_object_get().
30 May 2010 W. Michael Petullo <mike@flyn.org>
* Change lookup_by_path() to lookup_by_location().
29 May 2010 W. Michael Petullo <mike@flyn.org>
* Add blob functions to DMAPRecord interface.
......
......@@ -2,15 +2,12 @@ iTunes '09, segfault:
dmap_container_record_get_entry_count:86
_dmap_share_add_playlist_to_mlcl:1016
Combine daap- and dpap-share.c filter parser (see filterstr). USE DPAP's
BECUASE IT IS NEWER!
Replace dmap-md5.[ch] with GChecksum.
Ensure client test catches newly shared files?
Do transcode based on client?
Ensure D[AP]APRecord's properly implement finalize.
daap-music.c
daap-music.h
daap-playlist.c
......@@ -86,7 +83,6 @@ Fix seeking.
Documentation, see README (put documentation in test code?).
Clean up test_dmap_server.
Fix code that determines path of test.jpeg.
See FIXME's in dmap-share.c, daap-share.c and dpap-share.c.
......
AC_INIT(libdmapsharing, 1.9.0.20)
AC_INIT(libdmapsharing, 1.9.0.21)
dnl when going to/from release please set the nano (fourth number) right !
dnl releases only do Wall, cvs and prerelease does Werror too
AS_VERSION(libdmapsharing, LIBDMAPSHARING, 1, 9, 0, 20, LIBDMAPSHARING_CVS="no", LIBDMAPSHARING_CVS="yes")
AS_VERSION(libdmapsharing, LIBDMAPSHARING, 1, 9, 0, 21, LIBDMAPSHARING_CVS="no", LIBDMAPSHARING_CVS="yes")
AM_INIT_AUTOMAKE
......
Name: libdmapsharing
Version: 1.9.0.16
Version: 1.9.0.19
Release: 1%{?dist}
License: LGPLv2+
Source: http://downloads.sourceforge.net/%name/%{name}-%{version}.tar.gz
......@@ -58,10 +58,7 @@ rm -rf $RPM_BUILD_ROOT
%postun -p /sbin/ldconfig
%changelog
* Sun Apr 04 2010 W. Michael Petullo <mike[@]flyn.org> - 1.9.0.16-1
- New upstream version.
* Sun Nov 29 2009 W. Michael Petullo <mike[@]flyn.org> - 1.9.0.14-1
* Fri Aug 28 2009 W. Michael Petullo <mike[@]flyn.org> - 1.9.0.18-1
- New upstream version.
* Fri Aug 28 2009 W. Michael Petullo <mike[@]flyn.org> - 1.9.0.13-1
......
......@@ -543,9 +543,10 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, ITEM_ID))
dmap_structure_add (mlit, DMAP_CC_MIID, GPOINTER_TO_UINT (id));
if (_dmap_share_client_requested (mb->bits, ITEM_NAME)) {
const gchar *title;
gchar *title;
g_object_get (record, "title", &title, NULL);
dmap_structure_add (mlit, DMAP_CC_MINM, title);
g_free (title);
}
if (_dmap_share_client_requested (mb->bits, PERSISTENT_ID))
dmap_structure_add (mlit, DMAP_CC_MPER, GPOINTER_TO_UINT (id));
......@@ -558,16 +559,18 @@ add_entry_to_mlcl (gpointer id,
dmap_structure_add (mlit, DMAP_CC_ASUL, "daap://192.168.0.100:%u/databases/1/items/%d.%s?session-id=%s", data->port, *id, daap_record_get_format (DAAP_RECORD (record)), data->session_id);
*/
if (_dmap_share_client_requested (mb->bits, SONG_ALBUM)) {
const gchar *album;
gchar *album;
g_object_get (record, "daap.songalbum", &album, NULL);
dmap_structure_add (mlit, DMAP_CC_ASAL, album);
g_free (album);
}
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)) {
const gchar *artist;
gchar *artist;
g_object_get (record, "daap.songartist", &artist, NULL);
dmap_structure_add (mlit, DMAP_CC_ASAR, artist);
g_free (artist);
}
if (_dmap_share_client_requested (mb->bits, SONG_BITRATE)) {
gint32 bitrate;
......@@ -607,15 +610,17 @@ add_entry_to_mlcl (gpointer id,
if (_dmap_share_client_requested (mb->bits, SONG_FORMAT)) {
gchar *format;
if (transcode_format)
format = transcode_format;
format = g_strdup (transcode_format);
else
g_object_get (record, "format", &format, NULL);
dmap_structure_add (mlit, DMAP_CC_ASFM, format);
g_free (format);
}
if (_dmap_share_client_requested (mb->bits, SONG_GENRE)) {
gchar *genre;
g_object_get (record, "daap.songgenre", &genre, NULL);
dmap_structure_add (mlit, DMAP_CC_ASGN, genre);
g_free (genre);
}
if (_dmap_share_client_requested (mb->bits, SONG_DESCRIPTION))
dmap_structure_add (mlit, DMAP_CC_ASDT, ""); /* FIXME: e.g., wav audio file */
......
......@@ -86,7 +86,7 @@ dmap_container_record_get_entry_count (DMAPContainerRecord *record)
return DMAP_CONTAINER_RECORD_GET_INTERFACE (record)->get_entry_count (record);
}
const DMAPDb *
DMAPDb *
dmap_container_record_get_entries (DMAPContainerRecord *record)
{
return DMAP_CONTAINER_RECORD_GET_INTERFACE (record)->get_entries (record);
......
......@@ -74,7 +74,7 @@ struct _DMAPContainerRecordInterface {
guint64 (*get_entry_count) (DMAPContainerRecord *record);
const DMAPDb *(*get_entries) (DMAPContainerRecord *record);
DMAPDb *(*get_entries) (DMAPContainerRecord *record);
};
GType dmap_container_record_get_type (void);
......@@ -114,7 +114,7 @@ guint64 dmap_container_record_get_entry_count (DMAPContainerRecord *record)
*
* Returns: A pointer to a DMAPDb containing the entries contained in record.
*/
const DMAPDb *dmap_container_record_get_entries (DMAPContainerRecord *record);
DMAPDb *dmap_container_record_get_entries (DMAPContainerRecord *record);
#endif /* __DMAP_CONTAINER_RECORD_H */
......
......@@ -67,10 +67,10 @@ dmap_db_lookup_by_id (const DMAPDb *db, guint id)
return DMAP_DB_GET_INTERFACE (db)->lookup_by_id (db, id);
}
DMAPRecord *
dmap_db_lookup_by_path (const DMAPDb *db, const gchar *path)
guint
dmap_db_lookup_id_by_location (const DMAPDb *db, const gchar *location)
{
return DMAP_DB_GET_INTERFACE (db)->lookup_by_path (db, path);
return DMAP_DB_GET_INTERFACE (db)->lookup_id_by_location (db, location);
}
void
......@@ -87,6 +87,12 @@ dmap_db_add (DMAPDb *db, DMAPRecord *record)
return DMAP_DB_GET_INTERFACE (db)->add (db, record);
}
guint
dmap_db_add_with_id (DMAPDb *db, DMAPRecord *record, guint id)
{
return DMAP_DB_GET_INTERFACE (db)->add_with_id (db, record, id);
}
guint
dmap_db_add_path (DMAPDb *db, const gchar *path)
{
......
......@@ -68,14 +68,18 @@ typedef struct _DMAPDbInterface DMAPDbInterface;
struct _DMAPDbInterface {
GTypeInterface parent;
guint (*add) (DMAPDb *db, DMAPRecord *record);
guint (*add_path) (DMAPDb *db, const gchar *path);
DMAPRecord *(*lookup_by_id) (const DMAPDb *db, guint id);
DMAPRecord *(*lookup_by_path) (const DMAPDb *db, const gchar *path);
void (*foreach) (const DMAPDb *db,
GHFunc func,
gpointer data);
gint64 (*count) (const DMAPDb *db);
guint (*add) (DMAPDb *db, DMAPRecord *record);
guint (*add_with_id) (DMAPDb *db,
DMAPRecord *record,
guint id);
guint (*add_path) (DMAPDb *db, const gchar *path);
DMAPRecord *(*lookup_by_id) (const DMAPDb *db, guint id);
guint (*lookup_id_by_location) (const DMAPDb *db,
const gchar *location);
void (*foreach) (const DMAPDb *db,
GHFunc func,
gpointer data);
gint64 (*count) (const DMAPDb *db);
};
typedef const char *(*RecordGetValueFunc) (DMAPRecord *record);
......@@ -105,6 +109,20 @@ GType dmap_db_get_type (void);
*/
guint dmap_db_add (DMAPDb *db, DMAPRecord *record);
/**
* dmap_db_add:
* @db: A media database.
* @record: A database record.
* @id: A database record ID.
*
* Add a record to the database and assign it the given ID.
*
* Returns: The ID for the newly added record.
*
* See also the notes for dmap_db_add regarding reference counting.
*/
guint dmap_db_add_with_id (DMAPDb *db, DMAPRecord *record, guint id);
/**
* dmap_db_add_path:
* @db: A media database.
......@@ -140,16 +158,14 @@ guint dmap_db_add_path (DMAPDb *db, const gchar *path);
DMAPRecord *dmap_db_lookup_by_id (const DMAPDb *db, guint id);
/**
* dmap_db_lookup_by_path:
* dmap_db_lookup_id_by_location:
* @db: A media database.
* @path: A record path.
*
* Returns: the database record corresponding to @path. This record should
* be unrefed by the calling code when no longer required.
* @location: A record location.
*
* See also the notes for dmap_db_lookup_by_id regarding reference counting.
* Returns: the database id for the record corresponding to @path or 0 if
* such a record does not exist.
*/
DMAPRecord *dmap_db_lookup_by_path (const DMAPDb *db, const gchar *path);
guint dmap_db_lookup_id_by_location (const DMAPDb *db, const gchar *location);
/**
* dmap_db_foreach:
......
......@@ -1078,6 +1078,8 @@ _dmap_share_add_playlist_to_mlcl (gpointer id, DMAPContainerRecord *record, gpoi
dmap_structure_add (mlit, DMAP_CC_MINM, name);
dmap_structure_add (mlit, DMAP_CC_MIMC, (gint32) num_songs);
g_free (name);
return;
}
......@@ -1364,7 +1366,7 @@ _dmap_share_databases (DMAPShare *share,
dmap_db_foreach (share->priv->db, (GHFunc) DMAP_SHARE_GET_CLASS (share)->add_entry_to_mlcl, &mb);
} else {
DMAPContainerRecord *record;
const DMAPDb *entries;
DMAPDb *entries;
guint num_songs;
record = dmap_container_db_lookup_by_id (share->priv->container_db, pl_id);
......@@ -1377,6 +1379,7 @@ _dmap_share_databases (DMAPShare *share,
dmap_db_foreach (entries, (GHFunc) DMAP_SHARE_GET_CLASS (share)->add_entry_to_mlcl, &mb);
g_object_unref (entries);
g_object_unref (record);
}
......
......@@ -314,15 +314,6 @@ dmap_buffer_read_string (const gchar *buf, gssize size)
}
}
//#define PARSE_DEBUG
#define PARSE_DEBUG_FILE "dmapbuffer"
#ifdef PARSE_DEBUG
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#endif
static void
dmap_structure_parse_container_buffer (GNode *parent,
const guchar *buf,
......@@ -337,23 +328,17 @@ dmap_structure_parse_container_buffer (GNode *parent,
GNode *node = NULL;
GType gtype;
#ifdef PARSE_DEBUG
g_print ("l is %d and buf_length is %d\n", l, buf_length);
#endif
g_debug ("l is %d and buf_length is %d\n", l, buf_length);
/* we need at least 8 bytes, 4 of content_code and 4 of size */
if (buf_length - l < 8) {
#ifdef PARSE_DEBUG
g_print ("Malformed response recieved\n");
#endif
g_debug ("Malformed response recieved\n");
return;
}
cc = dmap_content_code_read_from_buffer ((const gchar*)&(buf[l]));
if (cc == DMAP_CC_INVALID) {
#ifdef PARSE_DEBUG
g_print ("Invalid/Unknown content_code recieved\n");
#endif
g_debug ("Invalid/Unknown content_code recieved\n");
return;
}
l += 4;
......@@ -366,16 +351,12 @@ dmap_structure_parse_container_buffer (GNode *parent,
* then get out before we start processing it
*/
if (codesize > buf_length - l - 4 || codesize < 0) {
#ifdef PARSE_DEBUG
g_print ("Invalid codesize %d recieved in buf_length %d\n", codesize, buf_length);
#endif
g_debug ("Invalid codesize %d recieved in buf_length %d\n", codesize, buf_length);
return;
}
l += 4;
#ifdef PARSE_DEBUG
g_print ("content_code = %d, codesize is %d, l is %d\n", cc, codesize, l);
#endif
g_debug ("content_code = %d, codesize is %d, l is %d\n", cc, codesize, l);
item = g_new0 (DMAPStructureItem, 1);
item->content_code = cc;
......@@ -388,16 +369,6 @@ dmap_structure_parse_container_buffer (GNode *parent,
g_value_init (&(item->content), gtype);
}
#ifdef PARSE_DEBUG
{
guint i;
for (i = 2; i < g_node_depth (node); i++) {
g_print ("\t");
}
}
#endif
// FIXME USE THE G_TYPE CONVERTOR FUNCTION dmap_type_to_gtype
switch (dmap_content_code_dmap_type (item->content_code)) {
case DMAP_TYPE_SIGNED_INT:
......@@ -410,9 +381,7 @@ dmap_structure_parse_container_buffer (GNode *parent,
item->size = 1;
g_value_set_char (&(item->content), c);
#ifdef PARSE_DEBUG
g_print ("Code: %s, content (%d): \"%c\"\n", dmap_content_code_string (item->content_code), codesize, (gchar)c);
#endif
g_debug ("Code: %s, content (%d): \"%c\"\n", dmap_content_code_string (item->content_code), codesize, (gchar)c);
break;
}
......@@ -425,9 +394,7 @@ dmap_structure_parse_container_buffer (GNode *parent,
item->size = 2;
g_value_set_int (&(item->content),(gint32)s);
#ifdef PARSE_DEBUG
g_print ("Code: %s, content (%d): %hi\n", dmap_content_code_string (item->content_code), codesize, s);
#endif
g_debug ("Code: %s, content (%d): %hi\n", dmap_content_code_string (item->content_code), codesize, s);
break;
}
......@@ -441,9 +408,7 @@ dmap_structure_parse_container_buffer (GNode *parent,
item->size = 4;
g_value_set_int (&(item->content), i);
#ifdef PARSE_DEBUG
g_print ("Code: %s, content (%d): %d\n", dmap_content_code_string (item->content_code), codesize, i);
#endif
g_debug ("Code: %s, content (%d): %d\n", dmap_content_code_string (item->content_code), codesize, i);
break;
}
case DMAP_TYPE_INT64: {
......@@ -455,9 +420,7 @@ dmap_structure_parse_container_buffer (GNode *parent,
item->size = 8;
g_value_set_int64 (&(item->content), i);
#ifdef PARSE_DEBUG
g_print ("Code: %s, content (%d): %"G_GINT64_FORMAT"\n", dmap_content_code_string (item->content_code), codesize, i);
#endif
g_debug ("Code: %s, content (%d): %"G_GINT64_FORMAT"\n", dmap_content_code_string (item->content_code), codesize, i);
break;
}
......@@ -466,9 +429,7 @@ dmap_structure_parse_container_buffer (GNode *parent,
item->size = strlen (s);
g_value_set_string (&(item->content), s);
#ifdef PARSE_DEBUG
g_print ("Code: %s, content (%d): \"%s\"\n", dmap_content_code_string (item->content_code), codesize, s);
#endif
g_debug ("Code: %s, content (%d): \"%s\"\n", dmap_content_code_string (item->content_code), codesize, s);
break;
}
......@@ -498,16 +459,12 @@ dmap_structure_parse_container_buffer (GNode *parent,
item->size = 4;
g_value_set_double (&(item->content), v);
#ifdef PARSE_DEBUG
g_print ("Code: %s, content: %f\n", dmap_content_code_string (item->content_code), v);
#endif
g_debug ("Code: %s, content: %f\n", dmap_content_code_string (item->content_code), v);
break;
}
case DMAP_TYPE_CONTAINER: {
#ifdef PARSE_DEBUG
g_print ("Code: %s, container\n", dmap_content_code_string (item->content_code));
#endif
g_debug ("Code: %s, container\n", dmap_content_code_string (item->content_code));
dmap_structure_parse_container_buffer (node,&(buf[l]), codesize);
break;
}
......@@ -526,16 +483,6 @@ dmap_structure_parse (const gchar *buf,
GNode *root = NULL;
GNode *child = NULL;
#ifdef PARSE_DEBUG
{
gint fd;
fd = open (PARSE_DEBUG_FILE, O_WRONLY | O_CREAT);
write (fd, (const void *)buf, (size_t)buf_length);
close (fd);
}
#endif
root = g_node_new (NULL);
dmap_structure_parse_container_buffer (root, (guchar *)buf, buf_length);
......
......@@ -366,12 +366,14 @@ add_entry_to_mlcl (gpointer id,
gchar *filename;
g_object_get (record, "filename", &filename, NULL);
dmap_structure_add (mlit, DMAP_CC_MINM, filename);
g_free (filename);
}
if (_dmap_share_client_requested (mb->bits, PERSISTENT_ID))
dmap_structure_add (mlit, DMAP_CC_MPER, (gint64) GPOINTER_TO_UINT (id));
/* dpap-sharp claims iPhoto '08 will not show thumbnails without PASP: */
g_object_get (record, "aspect-ratio", &aspect_ratio, NULL);
dmap_structure_add (mlit, DMAP_CC_PASP, aspect_ratio);
g_free (aspect_ratio);
if (_dmap_share_client_requested (mb->bits, PHOTO_CREATIONDATE)) {
gint creation_date;
g_object_get (record, "creation-date", &creation_date, NULL);
......@@ -381,11 +383,13 @@ add_entry_to_mlcl (gpointer id,
gchar *filename;
g_object_get (record, "filename", &filename, NULL);
dmap_structure_add (mlit, DMAP_CC_PIMF, filename);
g_free (filename);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFORMAT)) {
gchar *format;
g_object_get (record, "format", &format, NULL);
dmap_structure_add (mlit, DMAP_CC_PFMT, format);
g_free (format);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_IMAGEFILESIZE)) {
gint filesize;
......@@ -416,6 +420,7 @@ add_entry_to_mlcl (gpointer id,
gchar *comments;
g_object_get (record, "comments", &comments, NULL);
dmap_structure_add (mlit, DMAP_CC_PCMT, comments);
g_free (comments);
}
if (_dmap_share_client_requested (mb->bits, PHOTO_FILEDATA)) {
size_t size = 0;
......@@ -425,7 +430,7 @@ add_entry_to_mlcl (gpointer id,
g_object_get (record, "filesize", &size, NULL);
} else {
/* Should be PHOTO_HIRES */
const char *location;
char *location;
g_object_get (record, "location", &location, NULL);
if (mapped_file) {
/* Free any previously mapped image */
......@@ -440,6 +445,7 @@ add_entry_to_mlcl (gpointer id,
data = (unsigned char *) g_mapped_file_get_contents (mapped_file);
size = g_mapped_file_get_length (mapped_file);
}
g_free (location);
}
dmap_structure_add (mlit, DMAP_CC_PFDT, data, size);
}
......
......@@ -79,10 +79,10 @@ test_dmap_container_record_get_entry_count (DMAPContainerRecord *record)
return 1;
}
const DMAPDb *
DMAPDb *
test_dmap_container_record_get_entries (DMAPContainerRecord *record)
{
return entries;
return g_object_ref (entries);
}
static void
......
......@@ -57,8 +57,6 @@ TestDMAPContainerRecord *test_dmap_container_record_new (void);
guint test_dmap_container_record_get_id (DMAPContainerRecord *record);
const DMAPDb *test_dmap_container_record_get_entries (DMAPContainerRecord *record);
#endif /* __TEST_DMAP_CONTAINER_RECORD */
G_END_DECLS
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment