[libdmapsharing] Small API clean ups and additions



commit 8726e252e9c78e181f0dd2e8145d525472644096
Author: W. Michael Petullo <mike flyn org>
Date:   Sat May 29 12:45:45 2010 -0500

    Small API clean ups and additions
    
    Made some API changes based on lessons learned from working
    on dmapd and Rhythmbox: Add lookup_by_path() to DMAPDb, add
    add_path() to DMAPDb and ensure dmap_container_db_lookup_by_id(),
    dmap_container_record_get_id() and dmap_db_lookup_by_id() all deal with
    guint ids.
    Signed-off-by: W. Michael Petullo <mike flyn org>

 ChangeLog                              |    8 ++++++++
 libdmapsharing/dmap-container-db.c     |    2 +-
 libdmapsharing/dmap-container-db.h     |    4 ++--
 libdmapsharing/dmap-container-record.c |    2 +-
 libdmapsharing/dmap-container-record.h |    4 ++--
 libdmapsharing/dmap-db.c               |   12 ++++++++++++
 libdmapsharing/dmap-db.h               |   27 +++++++++++++++++++++++++++
 tests/test-dmap-container-db.c         |    2 +-
 tests/test-dmap-container-record.c     |    2 +-
 tests/test-dmap-container-record.h     |    2 +-
 10 files changed, 56 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 40d28e1..f6b6cdd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,14 @@
 
 	* Add blob functions to DMAPRecord interface.
 
+	* Add lookup_by_path() to DMAPDb.
+
+	* Add add_path() to DMAPDb.
+
+	* Ensure dmap_container_db_lookup_by_id(),
+	dmap_container_record_get_id() and dmap_db_lookup_by_id() all
+	deal with guint ids.
+
 28 May 2010 W. Michael Petullo <mike flyn org>
 
 	* Install dmap-md5.h.
diff --git a/libdmapsharing/dmap-container-db.c b/libdmapsharing/dmap-container-db.c
index f1aff1f..7873228 100644
--- a/libdmapsharing/dmap-container-db.c
+++ b/libdmapsharing/dmap-container-db.c
@@ -54,7 +54,7 @@ dmap_container_db_get_type (void)
 }
 
 DMAPContainerRecord *
-dmap_container_db_lookup_by_id (DMAPContainerDb *db, gint id)
+dmap_container_db_lookup_by_id (DMAPContainerDb *db, guint id)
 {
 	return DMAP_CONTAINER_DB_GET_INTERFACE (db)->lookup_by_id (db, id);
 }
diff --git a/libdmapsharing/dmap-container-db.h b/libdmapsharing/dmap-container-db.h
index cfbf7e8..f2ef3a1 100644
--- a/libdmapsharing/dmap-container-db.h
+++ b/libdmapsharing/dmap-container-db.h
@@ -69,7 +69,7 @@ typedef struct _DMAPContainerDbInterface DMAPContainerDbInterface;
 struct _DMAPContainerDbInterface {
 	GTypeInterface parent;
 
-	DMAPContainerRecord *(*lookup_by_id)    (DMAPContainerDb *db, gint id);
+	DMAPContainerRecord *(*lookup_by_id)    (DMAPContainerDb *db, guint id);
 
 	void        (*foreach) (DMAPContainerDb *db,
 				GHFunc func,
@@ -88,7 +88,7 @@ GType	    dmap_container_db_get_type        (void);
  * Returns: the database record corresponding to @id. This record should
  * be unrefed when no longer required.
  */
-DMAPContainerRecord *dmap_container_db_lookup_by_id    (DMAPContainerDb *db, gint id);
+DMAPContainerRecord *dmap_container_db_lookup_by_id    (DMAPContainerDb *db, guint id);
 
 /**
  * dmap_container_db_foreach:
diff --git a/libdmapsharing/dmap-container-record.c b/libdmapsharing/dmap-container-record.c
index bbf255f..e300a4b 100644
--- a/libdmapsharing/dmap-container-record.c
+++ b/libdmapsharing/dmap-container-record.c
@@ -66,7 +66,7 @@ dmap_container_record_get_type (void)
 	return object_type;
 }
 
-gint
+guint
 dmap_container_record_get_id (DMAPContainerRecord *record)
 {
 	return DMAP_CONTAINER_RECORD_GET_INTERFACE (record)->get_id (record);
diff --git a/libdmapsharing/dmap-container-record.h b/libdmapsharing/dmap-container-record.h
index 2ccd53e..d9021f2 100644
--- a/libdmapsharing/dmap-container-record.h
+++ b/libdmapsharing/dmap-container-record.h
@@ -68,7 +68,7 @@ typedef struct _DMAPContainerRecordInterface DMAPContainerRecordInterface;
 struct _DMAPContainerRecordInterface {
 	GTypeInterface parent;
 	
-	gint		(*get_id)	    (DMAPContainerRecord *record);
+	guint		(*get_id)	    (DMAPContainerRecord *record);
 
 	void (*add_entry) (DMAPContainerRecord *container_record, DMAPRecord *record, gint id);
 
@@ -85,7 +85,7 @@ GType       dmap_container_record_get_type         (void);
  *
  * Returns: the ID for the given record.
  */
-gint        dmap_container_record_get_id           (DMAPContainerRecord *record);
+guint       dmap_container_record_get_id           (DMAPContainerRecord *record);
 
 /**
  * dmap_container_record_add_entry:
diff --git a/libdmapsharing/dmap-db.c b/libdmapsharing/dmap-db.c
index 6ece7fc..5188fe7 100644
--- a/libdmapsharing/dmap-db.c
+++ b/libdmapsharing/dmap-db.c
@@ -67,6 +67,12 @@ 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)
+{
+	return DMAP_DB_GET_INTERFACE (db)->lookup_by_path (db, path);
+}
+
 void
 dmap_db_foreach	(const DMAPDb *db,
 		 GHFunc func,
@@ -81,6 +87,12 @@ dmap_db_add (DMAPDb *db, DMAPRecord *record)
 	return DMAP_DB_GET_INTERFACE (db)->add (db, record);
 }
 
+guint
+dmap_db_add_path (DMAPDb *db, const gchar *path)
+{
+	return DMAP_DB_GET_INTERFACE (db)->add_path (db, path);
+}
+
 gulong
 dmap_db_count (const DMAPDb *db)
 {
diff --git a/libdmapsharing/dmap-db.h b/libdmapsharing/dmap-db.h
index ec42ee6..3d6c268 100644
--- a/libdmapsharing/dmap-db.h
+++ b/libdmapsharing/dmap-db.h
@@ -69,7 +69,9 @@ 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);
@@ -104,6 +106,19 @@ GType dmap_db_get_type		    (void);
 guint        dmap_db_add	    (DMAPDb *db, DMAPRecord *record);
 
 /**
+ * dmap_db_add_path:
+ * @db: A media database.
+ * @path: A path to an appropriate media file.
+ *
+ * Create a record and add it to the database. 
+ *
+ * Returns: The ID for the newly added record.
+ *
+ * See also the notes for dmap_db_add regarding reference counting.
+ */
+guint        dmap_db_add_path	    (DMAPDb *db, const gchar *path);
+
+/**
  * dmap_db_lookup_by_id:
  * @db: A media database. 
  * @id: A record ID.
@@ -125,6 +140,18 @@ guint        dmap_db_add	    (DMAPDb *db, DMAPRecord *record);
 DMAPRecord *dmap_db_lookup_by_id    (const DMAPDb *db, guint id);
 
 /**
+ * dmap_db_lookup_by_path:
+ * @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.
+ *
+ * See also the notes for dmap_db_lookup_by_id regarding reference counting.
+ */
+DMAPRecord *dmap_db_lookup_by_path  (const DMAPDb *db, const gchar *path);
+
+/**
  * dmap_db_foreach:
  * @db: A media database.
  * @fn: The function to apply to each record in the database.
diff --git a/tests/test-dmap-container-db.c b/tests/test-dmap-container-db.c
index daaf48f..2a04edf 100644
--- a/tests/test-dmap-container-db.c
+++ b/tests/test-dmap-container-db.c
@@ -27,7 +27,7 @@
 static DMAPContainerRecord *record = NULL;
 
 static DMAPContainerRecord *
-test_dmap_container_db_lookup_by_id (DMAPContainerDb *db, gint id)
+test_dmap_container_db_lookup_by_id (DMAPContainerDb *db, guint id)
 {
 	/* In reality, lookup the proper record and return it. */
 	return record;
diff --git a/tests/test-dmap-container-record.c b/tests/test-dmap-container-record.c
index 287ea43..5648839 100644
--- a/tests/test-dmap-container-record.c
+++ b/tests/test-dmap-container-record.c
@@ -60,7 +60,7 @@ test_dmap_container_record_get_property (GObject *object,
 }
 
 
-gint
+guint
 test_dmap_container_record_get_id (DMAPContainerRecord *record)
 {
 	return 2;
diff --git a/tests/test-dmap-container-record.h b/tests/test-dmap-container-record.h
index d5186ba..f6e35c8 100644
--- a/tests/test-dmap-container-record.h
+++ b/tests/test-dmap-container-record.h
@@ -55,7 +55,7 @@ GType test_dmap_container_record_get_type (void);
 
 TestDMAPContainerRecord *test_dmap_container_record_new           (void);
 
-gint            test_dmap_container_record_get_id        (DMAPContainerRecord *record);
+guint            test_dmap_container_record_get_id        (DMAPContainerRecord *record);
 
 const DMAPDb   *test_dmap_container_record_get_entries   (DMAPContainerRecord *record);
 



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