[libdmapsharing] iPhoto does not like record ID 0; fix vala-dmap-db.vala Signed-off-by: W. Michael Petullo <mike flyn



commit 2ff02e80d7602998c8e70502b9a84af512d41c4e
Author: W. Michael Petullo <mike flyn org>
Date:   Mon Mar 21 21:53:36 2011 -0500

    iPhoto does not like record ID 0; fix vala-dmap-db.vala
    Signed-off-by: W. Michael Petullo <mike flyn org>

 tests/vala-dmap-db.c    |   11 ++++++-----
 tests/vala-dmap-db.vala |    9 +++++++--
 2 files changed, 13 insertions(+), 7 deletions(-)
---
diff --git a/tests/vala-dmap-db.c b/tests/vala-dmap-db.c
index 0030381..1e49b8b 100644
--- a/tests/vala-dmap-db.c
+++ b/tests/vala-dmap-db.c
@@ -84,6 +84,7 @@ static guint vala_dmap_db_real_add (DMAPDb* base, DMAPRecord* record) {
 	self = (ValaDMAPDb*) base;
 	g_return_val_if_fail (record != NULL, 0U);
 	gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->db, DMAP_RECORD (record));
+	gee_abstract_collection_add ((GeeAbstractCollection*) self->priv->db, DMAP_RECORD (record));
 	_tmp0_ = gee_collection_get_size ((GeeCollection*) self->priv->db);
 	result = (guint) _tmp0_;
 	return result;
@@ -95,7 +96,7 @@ static guint vala_dmap_db_real_add_path (DMAPDb* base, const gchar* path) {
 	guint result = 0U;
 	self = (ValaDMAPDb*) base;
 	g_return_val_if_fail (path != NULL, 0U);
-	g_error ("vala-dmap-db.vala:35: add_path not implemented");
+	g_error ("vala-dmap-db.vala:36: add_path not implemented");
 	return result;
 }
 
@@ -105,7 +106,7 @@ static guint vala_dmap_db_real_add_with_id (DMAPDb* base, DMAPRecord* record, gu
 	guint result = 0U;
 	self = (ValaDMAPDb*) base;
 	g_return_val_if_fail (record != NULL, 0U);
-	g_error ("vala-dmap-db.vala:39: add_with_id not implemented");
+	g_error ("vala-dmap-db.vala:40: add_with_id not implemented");
 	return result;
 }
 
@@ -141,7 +142,7 @@ static void vala_dmap_db_real_foreach (DMAPDb* base, GHFunc func, void* func_tar
 			if (!(i < _tmp1_)) {
 				break;
 			}
-			_tmp2_ = GINT_TO_POINTER (i);
+			_tmp2_ = GINT_TO_POINTER (i + 1);
 			_tmp3_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->db, i);
 			func (_tmp2_, (DMAPRecord*) _tmp3_, func_target);
 		}
@@ -154,7 +155,7 @@ static DMAPRecord* vala_dmap_db_real_lookup_by_id (DMAPDb* base, guint id) {
 	DMAPRecord* result = NULL;
 	gpointer _tmp0_ = NULL;
 	self = (ValaDMAPDb*) base;
-	_tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->db, (gint) id);
+	_tmp0_ = gee_abstract_list_get ((GeeAbstractList*) self->priv->db, ((gint) id) - 1);
 	result = (DMAPRecord*) _tmp0_;
 	return result;
 }
@@ -165,7 +166,7 @@ static guint vala_dmap_db_real_lookup_id_by_location (DMAPDb* base, const gchar*
 	guint result = 0U;
 	self = (ValaDMAPDb*) base;
 	g_return_val_if_fail (location != NULL, 0U);
-	g_error ("vala-dmap-db.vala:59: lookup_id_by_location not implemented");
+	g_error ("vala-dmap-db.vala:64: lookup_id_by_location not implemented");
 	return result;
 }
 
diff --git a/tests/vala-dmap-db.vala b/tests/vala-dmap-db.vala
index 92ca811..de67dd1 100644
--- a/tests/vala-dmap-db.vala
+++ b/tests/vala-dmap-db.vala
@@ -28,6 +28,7 @@ private class ValaDMAPDb : GLib.Object, DMAP.Db {
 
 	public uint add (DMAP.Record record) {
 		db.add (((DMAP.Record) record));
+		db.add (((DMAP.Record) record));
 		return db.size;
 	}
 
@@ -46,12 +47,16 @@ private class ValaDMAPDb : GLib.Object, DMAP.Db {
 	public void @foreach (GLib.HFunc func) {
 		int i;
 		for (i = 0; i < db.size; i++) {
-			func (i.to_pointer (), db[i]);
+			// NOTE: iPhoto does not like a record ID of 0,
+			// so we pretend to start with 1
+			func ((i + 1).to_pointer (), db[i]);
 		}
 	}
 
 	public unowned DMAP.Record lookup_by_id (uint id) {
-		return db.get ((int) id);
+		// NOTE: iPhoto does not like a record ID of 0,
+		// so we pretend to start with 1
+		return db.get ((int) id - 1);
 	}
 
 



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