[libdmapsharing] Various code clean ups



commit 763b76e1f2e4439f06db7dfa289dc2479aaa5841
Author: W. Michael Petullo <mike flyn org>
Date:   Fri May 28 00:39:26 2010 -0500

    Various code clean ups
    
    Increase the reference count of the databases passed to
    d[ap]ap_share_new(). dmap_db_lookup_by_id() now takes a const DMAPDb *.
    Add a _dmap_share_build_filter() prototype.
    Signed-off-by: W. Michael Petullo <mike flyn org>

 ChangeLog                                  |    7 +++++++
 libdmapsharing/daap-share.c                |    5 ++++-
 libdmapsharing/dmap-db.c                   |    2 +-
 libdmapsharing/dmap-db.h                   |    4 ++--
 libdmapsharing/dmap-mdns-publisher-avahi.c |    2 ++
 libdmapsharing/dmap-record-factory.h       |    3 ++-
 libdmapsharing/dmap-share.c                |    6 +++---
 libdmapsharing/dmap-share.h                |    2 ++
 8 files changed, 23 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6675bff..0e5656e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,13 @@
 	* Fix crash upon finalizing DMAPShare that was caused by misuse of
 	avahi_entry_group_free().
 
+	* Increase the reference count of the databases passed to
+	d[ap]ap_share_new().
+
+	* dmap_db_lookup_by_id now takes a const DMAPDb *.
+
+	* Add a _dmap_share_build_filter() prototype.
+
 25 May 2010 W. Michael Petullo <mike flyn org>
 
 	* Refactor build_filter into dmap_share_build_factor.
diff --git a/libdmapsharing/daap-share.c b/libdmapsharing/daap-share.c
index aacd0fe..1758037 100644
--- a/libdmapsharing/daap-share.c
+++ b/libdmapsharing/daap-share.c
@@ -191,6 +191,9 @@ daap_share_new (const char *name,
 {
 	DAAPShare *share;
 
+	g_object_ref (db);
+	g_object_ref (container_db);
+
 	share = DAAP_SHARE (g_object_new (TYPE_DAAP_SHARE,
 					     "name", name,
 					     "password", password,
@@ -746,7 +749,7 @@ databases_browse_xxx (DMAPShare *share,
 	category_items = g_hash_table_new (g_str_hash, g_str_equal);
 
 	filter = g_hash_table_lookup (query, "filter");
-	filter_def = dmap_share_build_filter (filter);
+	filter_def = _dmap_share_build_filter (filter);
 	g_object_get (share, "db", &db, NULL);
 	filtered = dmap_db_apply_filter (db, filter_def);
 
diff --git a/libdmapsharing/dmap-db.c b/libdmapsharing/dmap-db.c
index 3a168c3..6ece7fc 100644
--- a/libdmapsharing/dmap-db.c
+++ b/libdmapsharing/dmap-db.c
@@ -62,7 +62,7 @@ dmap_db_get_type (void)
 }
 
 DMAPRecord *
-dmap_db_lookup_by_id (DMAPDb *db, guint id)
+dmap_db_lookup_by_id (const DMAPDb *db, guint id)
 {
 	return DMAP_DB_GET_INTERFACE (db)->lookup_by_id (db, id);
 }
diff --git a/libdmapsharing/dmap-db.h b/libdmapsharing/dmap-db.h
index cad5fe7..ec42ee6 100644
--- a/libdmapsharing/dmap-db.h
+++ b/libdmapsharing/dmap-db.h
@@ -69,7 +69,7 @@ struct _DMAPDbInterface {
 	GTypeInterface parent;
 
 	guint (*add)			(DMAPDb *db, DMAPRecord *record);
-	DMAPRecord *(*lookup_by_id)	(DMAPDb *db, guint id);
+	DMAPRecord *(*lookup_by_id)	(const DMAPDb *db, guint id);
 	void (*foreach)			(const DMAPDb *db,
 					 GHFunc func,
 					 gpointer data);
@@ -122,7 +122,7 @@ guint        dmap_db_add	    (DMAPDb *db, DMAPRecord *record);
  * In this case, the reference count should not be incremented before
  * returning a record pointer.
  */
-DMAPRecord *dmap_db_lookup_by_id    (DMAPDb *db, guint id);
+DMAPRecord *dmap_db_lookup_by_id    (const DMAPDb *db, guint id);
 
 /**
  * dmap_db_foreach:
diff --git a/libdmapsharing/dmap-mdns-publisher-avahi.c b/libdmapsharing/dmap-mdns-publisher-avahi.c
index f77e885..487f293 100644
--- a/libdmapsharing/dmap-mdns-publisher-avahi.c
+++ b/libdmapsharing/dmap-mdns-publisher-avahi.c
@@ -425,6 +425,8 @@ dmap_mdns_publisher_finalize (GObject *object)
 		publisher->priv->entry_group = NULL;
 	}
 
+	avahi_client_free (publisher->priv->client);
+
 	g_free (publisher->priv->name);
 	g_free (publisher->priv->type_of_service);
 
diff --git a/libdmapsharing/dmap-record-factory.h b/libdmapsharing/dmap-record-factory.h
index a0f068a..b02c85f 100644
--- a/libdmapsharing/dmap-record-factory.h
+++ b/libdmapsharing/dmap-record-factory.h
@@ -83,7 +83,8 @@ GType dmap_record_factory_get_type (void);
  *
  * Returns: a new DMAPRecord as read from path.
  */
-DMAPRecord *dmap_record_factory_create (DMAPRecordFactory *factory, gpointer user_data);
+DMAPRecord *dmap_record_factory_create (DMAPRecordFactory *factory,
+					gpointer user_data);
 
 #endif /* __DMAP_RECORD_FACTORY_H */
 
diff --git a/libdmapsharing/dmap-share.c b/libdmapsharing/dmap-share.c
index a07d42c..0451dea 100644
--- a/libdmapsharing/dmap-share.c
+++ b/libdmapsharing/dmap-share.c
@@ -272,7 +272,7 @@ _dmap_share_server_start (DMAPShare *share)
 static gboolean
 _dmap_share_server_stop (DMAPShare *share)
 {
-	g_warning ("Stopping music sharing server on port %d", share->priv->port);
+	g_debug ("Stopping music sharing server on port %d", share->priv->port);
 
 	if (share->priv->server) {
 		soup_server_quit (share->priv->server);
@@ -1082,7 +1082,7 @@ _dmap_share_add_playlist_to_mlcl (gpointer id, DMAPContainerRecord *record, gpoi
 } 
 
 GSList *
-dmap_share_build_filter (gchar *filterstr)
+_dmap_share_build_filter (gchar *filterstr)
 {
 	/* Produces a list of lists, each being a filter definition that may
 	 * be one or more filter criteria.
@@ -1255,7 +1255,7 @@ _dmap_share_databases (DMAPShare *share,
 		record_query = g_hash_table_lookup (query, "query");
 		if (record_query) {
 			GSList *filter_def;
-			filter_def = dmap_share_build_filter (record_query);
+			filter_def = _dmap_share_build_filter (record_query);
 			records = dmap_db_apply_filter (DMAP_DB (share->priv->db), filter_def);
 			g_debug ("Found %d records", g_hash_table_size (records));
 			num_songs = g_hash_table_size (records);
diff --git a/libdmapsharing/dmap-share.h b/libdmapsharing/dmap-share.h
index 08aed91..1f5a2df 100644
--- a/libdmapsharing/dmap-share.h
+++ b/libdmapsharing/dmap-share.h
@@ -219,6 +219,8 @@ void _dmap_share_add_playlist_to_mlcl (gpointer id,
 				       DMAPContainerRecord *record,
 				       gpointer mlcl);
 
+GSList * _dmap_share_build_filter (gchar *filterstr);
+
 /* Virtual methods (libsoup callbacks with default implementation): */
 void _dmap_share_content_codes (DMAPShare *share,
 		  SoupServer        *server,



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