[libdmapsharing] Adjust a number of methods to take a GError **
- From: W. Michael Petullo <wmpetullo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdmapsharing] Adjust a number of methods to take a GError **
- Date: Sun, 25 Mar 2018 22:57:29 +0000 (UTC)
commit d756418dd3e9d829352228e1bf411541b0627a35
Author: W. Michael Petullo <mike flyn org>
Date: Sun Mar 25 18:57:15 2018 -0400
Adjust a number of methods to take a GError **
Signed-off-by: W. Michael Petullo <mike flyn org>
libdmapsharing/dmap-av-connection.c | 7 ++-
libdmapsharing/dmap-av-record.c | 6 +-
libdmapsharing/dmap-av-share.c | 27 +++++++------
libdmapsharing/dmap-connection.c | 18 +++------
libdmapsharing/dmap-connection.h | 8 ++--
libdmapsharing/dmap-container-db.c | 4 +-
libdmapsharing/dmap-container-db.h | 6 ++-
libdmapsharing/dmap-container-record.c | 4 +-
libdmapsharing/dmap-container-record.h | 5 +-
libdmapsharing/dmap-db.c | 12 +++---
libdmapsharing/dmap-db.h | 21 ++++++----
libdmapsharing/dmap-image-connection.c | 3 +-
libdmapsharing/dmap-record-factory.c | 7 ++-
libdmapsharing/dmap-record-factory.h | 7 ++-
libdmapsharing/dmap-share.c | 35 +++++-----------
libdmapsharing/dmap-share.h | 6 ++-
libdmapsharing/test-dmap-av-record-factory.c | 4 +-
libdmapsharing/test-dmap-av-record-factory.h | 8 ++-
libdmapsharing/test-dmap-container-record.c | 5 +-
libdmapsharing/test-dmap-db.c | 2 +-
libdmapsharing/test-dmap-image-record-factory.c | 4 +-
libdmapsharing/test-dmap-image-record-factory.h | 8 ++-
tests/dmapserve.c | 48 +++++++++++++++++++----
tests/dmapserve.vala | 8 +++-
tests/test-dmap-server.c | 16 ++++++--
tests/vala-dmap-container-db.c | 6 +-
26 files changed, 168 insertions(+), 117 deletions(-)
---
diff --git a/libdmapsharing/dmap-av-connection.c b/libdmapsharing/dmap-av-connection.c
index 7a3fe49..d8dc1cb 100644
--- a/libdmapsharing/dmap-av-connection.c
+++ b/libdmapsharing/dmap-av-connection.c
@@ -123,9 +123,10 @@ _handle_mlcl (DmapConnection * connection, DmapRecordFactory * factory,
}
}
- record = dmap_record_factory_create (factory, NULL);
+ /* FIXME: third argument, NULL, is GError; how to handle? */
+ record = dmap_record_factory_create (factory, NULL, NULL);
if (record == NULL) {
- goto _return;
+ goto done;
}
/*
@@ -152,7 +153,7 @@ _handle_mlcl (DmapConnection * connection, DmapRecordFactory * factory,
"sort-artist", sort_artist,
"sort-album", sort_album, NULL);
- _return:
+done:
return record;
}
diff --git a/libdmapsharing/dmap-av-record.c b/libdmapsharing/dmap-av-record.c
index bc04242..65319ac 100644
--- a/libdmapsharing/dmap-av-record.c
+++ b/libdmapsharing/dmap-av-record.c
@@ -371,21 +371,21 @@ START_TEST(dmap_av_record_cmp_by_album_test)
record = test_dmap_av_record_new();
g_object_set(record, "songalbum", "a", NULL);
g_object_set(record, "sort-album", "a", NULL);
- id = dmap_db_add(db, DMAP_RECORD(record));
+ id = dmap_db_add(db, DMAP_RECORD(record), NULL);
g_object_unref(record);
records = g_list_append (records, GINT_TO_POINTER(id));
record = test_dmap_av_record_new();
g_object_set(record, "songalbum", "c", NULL);
g_object_set(record, "sort-album", "c", NULL);
- id = dmap_db_add(db, DMAP_RECORD(record));
+ id = dmap_db_add(db, DMAP_RECORD(record), NULL);
g_object_unref(record);
records = g_list_append (records, GINT_TO_POINTER(id));
record = test_dmap_av_record_new();
g_object_set(record, "songalbum", "b", NULL);
g_object_set(record, "sort-album", "b", NULL);
- id = dmap_db_add(db, DMAP_RECORD(record));
+ id = dmap_db_add(db, DMAP_RECORD(record), NULL);
g_object_unref(record);
records = g_list_append (records, GINT_TO_POINTER(id));
diff --git a/libdmapsharing/dmap-av-share.c b/libdmapsharing/dmap-av-share.c
index ed55f09..96f3c3f 100644
--- a/libdmapsharing/dmap-av-share.c
+++ b/libdmapsharing/dmap-av-share.c
@@ -1019,7 +1019,7 @@ _build_share_test(char *name)
g_object_set(record, "location", "file:///etc/services", NULL);
g_object_set(record, "filesize", statbuf.st_size, NULL);
- dmap_db_add(db, record);
+ dmap_db_add(db, record, NULL);
if (-1 == stat("/etc/group", &statbuf)) {
ck_abort();
@@ -1031,7 +1031,8 @@ _build_share_test(char *name)
g_object_set(record, "songalbum", "album2", NULL);
g_object_set(record, "location", "file:///etc/group", NULL);
g_object_set(record, "filesize", statbuf.st_size, NULL);
- dmap_db_add(db, record);
+
+ dmap_db_add(db, record, NULL);
share = DMAP_SHARE(dmap_av_share_new(name,
NULL,
@@ -1071,7 +1072,7 @@ START_TEST(dmap_av_share_new_test)
g_object_set(record, "songartist", "artist1", NULL);
g_object_set(record, "songalbum", "album1", NULL);
- dmap_db_add(db, record);
+ dmap_db_add(db, record, NULL);
share = DMAP_SHARE(dmap_av_share_new("name",
"password",
@@ -1117,7 +1118,7 @@ START_TEST(dmap_av_share_serve_publish_test)
g_object_set(record, "songartist", "artist1", NULL);
g_object_set(record, "songalbum", "album1", NULL);
- dmap_db_add(db, record);
+ dmap_db_add(db, record, NULL);
share = DMAP_SHARE(dmap_av_share_new("name",
"password",
@@ -1125,10 +1126,10 @@ START_TEST(dmap_av_share_serve_publish_test)
container_db,
"audio/mp3"));
- ok = dmap_share_serve(share);
+ ok = dmap_share_serve(share, NULL);
ck_assert(ok);
- ok = dmap_share_publish(share);
+ ok = dmap_share_publish(share, NULL);
ck_assert(ok);
g_object_unref(db);
@@ -1157,7 +1158,7 @@ START_TEST(dmap_av_share_serve_publish_collision_test)
g_object_set(record, "songartist", "artist1", NULL);
g_object_set(record, "songalbum", "album1", NULL);
- dmap_db_add(db, record);
+ dmap_db_add(db, record, NULL);
share1 = DMAP_SHARE(dmap_av_share_new("name",
"password",
@@ -1165,10 +1166,10 @@ START_TEST(dmap_av_share_serve_publish_collision_test)
container_db,
"audio/mp3"));
- ok = dmap_share_serve(share1);
+ ok = dmap_share_serve(share1, NULL);
ck_assert(ok);
- ok = dmap_share_publish(share1);
+ ok = dmap_share_publish(share1, NULL);
ck_assert(ok);
share2 = DMAP_SHARE(dmap_av_share_new("name",
@@ -1177,10 +1178,10 @@ START_TEST(dmap_av_share_serve_publish_collision_test)
container_db,
"audio/mp3"));
- ok = dmap_share_serve(share2);
+ ok = dmap_share_serve(share2, NULL);
ck_assert(ok);
- ok = dmap_share_publish(share2);
+ ok = dmap_share_publish(share2, NULL);
ck_assert(ok);
g_object_unref(db);
@@ -1206,12 +1207,12 @@ _tabulator_test(char *property,
record1 = DMAP_RECORD(test_dmap_av_record_new());
g_object_set(record1, property, "str1", NULL);
- id1 = dmap_db_add(db, record1);
+ id1 = dmap_db_add(db, record1, NULL);
record2 = DMAP_RECORD(test_dmap_av_record_new());
g_object_set(record2, property, "str2", NULL);
- id2 = dmap_db_add(db, record2);
+ id2 = dmap_db_add(db, record2, NULL);
ht = g_hash_table_new (g_str_hash, g_str_equal);
diff --git a/libdmapsharing/dmap-connection.c b/libdmapsharing/dmap-connection.c
index 9459663..e4bd1c5 100644
--- a/libdmapsharing/dmap-connection.c
+++ b/libdmapsharing/dmap-connection.c
@@ -1205,7 +1205,8 @@ _handle_song_listing (DmapConnection * connection,
/*} */
g_object_set (record, "location", uri, NULL);
- dmap_db_add (connection->priv->db, record);
+ /* FIXME: third argument, NULL, is GError; how to handle? */
+ dmap_db_add (connection->priv->db, record, NULL);
g_object_unref (record);
g_hash_table_insert (connection->priv->item_id_to_uri,
GINT_TO_POINTER (item_id),
@@ -1662,7 +1663,7 @@ dmap_connection_setup (DmapConnection * connection)
}
// FIXME: it would be nice if this mirrored the use of DmapMdnsBrowser. That is, connect callback handler to
a signal.
-// This would allow Vala to associated a lambda function with the signal.
+// This would allow Vala to associate a lambda function with the signal.
void
dmap_connection_start (DmapConnection * connection,
DmapConnectionFunc callback, gpointer user_data)
@@ -1677,13 +1678,6 @@ dmap_connection_start (DmapConnection * connection,
dmap_connection_setup (connection);
- if (connection->priv->base_uri == NULL) {
- g_debug ("Error parsing http://%s:%d", connection->priv->host,
- connection->priv->port);
- /* FIXME: do callback */
- return;
- }
-
connection->priv->daap_base_uri =
g_strdup_printf ("daap://%s:%d", connection->priv->host,
connection->priv->port);
@@ -1732,9 +1726,9 @@ _disconnected_cb (DmapConnection * connection, ConnectionResponseData * rdata)
}
void
-dmap_connection_disconnect (DmapConnection * connection,
- DmapConnectionFunc callback,
- gpointer user_data)
+dmap_connection_stop(DmapConnection * connection,
+ DmapConnectionFunc callback,
+ gpointer user_data)
{
DmapConnectionPrivate *priv = connection->priv;
ConnectionResponseData *rdata;
diff --git a/libdmapsharing/dmap-connection.h b/libdmapsharing/dmap-connection.h
index bf3ecb9..3f8c323 100644
--- a/libdmapsharing/dmap-connection.h
+++ b/libdmapsharing/dmap-connection.h
@@ -179,16 +179,16 @@ void dmap_connection_start (DmapConnection * connection,
gpointer user_data);
/**
- * dmap_connection_disconnect:
+ * dmap_connection_stop:
* @connection: The connection.
* @callback: (scope async): The function to call once the connection is complete.
* @user_data: The data to pass to the callback.
*
* Disconnect from the remote DMAP share.
*/
-void dmap_connection_disconnect (DmapConnection * connection,
- DmapConnectionFunc callback,
- gpointer user_data);
+void dmap_connection_stop(DmapConnection * connection,
+ DmapConnectionFunc callback,
+ gpointer user_data);
SoupMessageHeaders *dmap_connection_get_headers (DmapConnection * connection,
const char *uri);
diff --git a/libdmapsharing/dmap-container-db.c b/libdmapsharing/dmap-container-db.c
index c756d1e..c547fe0 100644
--- a/libdmapsharing/dmap-container-db.c
+++ b/libdmapsharing/dmap-container-db.c
@@ -28,9 +28,9 @@ dmap_container_db_default_init (DmapContainerDbInterface * iface)
G_DEFINE_INTERFACE(DmapContainerDb, dmap_container_db, G_TYPE_OBJECT)
void
-dmap_container_db_add (DmapContainerDb * db, DmapContainerRecord *record)
+dmap_container_db_add (DmapContainerDb *db, DmapContainerRecord *record, GError **error)
{
- return DMAP_CONTAINER_DB_GET_INTERFACE (db)->add (db, record);
+ return DMAP_CONTAINER_DB_GET_INTERFACE (db)->add (db, record, error);
}
DmapContainerRecord *
diff --git a/libdmapsharing/dmap-container-db.h b/libdmapsharing/dmap-container-db.h
index 882da0a..37ad40a 100644
--- a/libdmapsharing/dmap-container-db.h
+++ b/libdmapsharing/dmap-container-db.h
@@ -78,7 +78,7 @@ struct _DmapContainerDbInterface
{
GTypeInterface parent;
- void (*add) (DmapContainerDb * db, DmapContainerRecord * record);
+ void (*add) (DmapContainerDb *db, DmapContainerRecord *record, GError **error);
DmapContainerRecord *(*lookup_by_id) (DmapContainerDb * db, guint id);
@@ -93,11 +93,13 @@ GType dmap_container_db_get_type (void);
* dmap_container_db_add:
* @db: A container database.
* @record: A record.
+ * @error: return location for a GError, or NULL.
*
* Add a record to the database.
*/
void dmap_container_db_add (DmapContainerDb * db,
- DmapContainerRecord * record);
+ DmapContainerRecord * record,
+ GError **error);
/**
* dmap_container_db_lookup_by_id:
diff --git a/libdmapsharing/dmap-container-record.c b/libdmapsharing/dmap-container-record.c
index 6e188f3..19756d7 100644
--- a/libdmapsharing/dmap-container-record.c
+++ b/libdmapsharing/dmap-container-record.c
@@ -51,10 +51,10 @@ dmap_container_record_get_id (DmapContainerRecord * record)
*/
void
dmap_container_record_add_entry (DmapContainerRecord * container_record,
- DmapRecord * record, gint id)
+ DmapRecord * record, gint id, GError **error)
{
DMAP_CONTAINER_RECORD_GET_INTERFACE (container_record)->
- add_entry (container_record, record, id);
+ add_entry (container_record, record, id, error);
}
guint64
diff --git a/libdmapsharing/dmap-container-record.h b/libdmapsharing/dmap-container-record.h
index c74d672..4111e42 100644
--- a/libdmapsharing/dmap-container-record.h
+++ b/libdmapsharing/dmap-container-record.h
@@ -70,7 +70,7 @@ struct _DmapContainerRecordInterface
guint (*get_id) (DmapContainerRecord * record);
void (*add_entry) (DmapContainerRecord * container_record,
- DmapRecord * record, gint id);
+ DmapRecord * record, gint id, GError **error);
guint64 (*get_entry_count) (DmapContainerRecord * record);
@@ -92,12 +92,13 @@ guint dmap_container_record_get_id (DmapContainerRecord * record);
* @container_record: A DmapContainerRecord.
* @record: A DmapRecord.
* @id: The record's ID.
+ * @error: return location for a GError, or NULL.
*
* Add a record to the database. It is assumed that the record is placed
* directly into the database (not copied) and not freed.
*/
void dmap_container_record_add_entry (DmapContainerRecord * container_record,
- DmapRecord * record, gint id);
+ DmapRecord * record, gint id, GError **error);
/**
* dmap_container_record_get_entry_count:
diff --git a/libdmapsharing/dmap-db.c b/libdmapsharing/dmap-db.c
index 2441d71..b917139 100644
--- a/libdmapsharing/dmap-db.c
+++ b/libdmapsharing/dmap-db.c
@@ -56,21 +56,21 @@ dmap_db_foreach (const DmapDb * db, DmapIdRecordFunc func, gpointer data)
}
guint
-dmap_db_add (DmapDb * db, DmapRecord * record)
+dmap_db_add (DmapDb *db, DmapRecord *record, GError **error)
{
- return DMAP_DB_GET_INTERFACE (db)->add (db, record);
+ return DMAP_DB_GET_INTERFACE (db)->add (db, record, error);
}
guint
-dmap_db_add_with_id (DmapDb * db, DmapRecord * record, guint id)
+dmap_db_add_with_id (DmapDb *db, DmapRecord *record, guint id, GError **error)
{
- return DMAP_DB_GET_INTERFACE (db)->add_with_id (db, record, id);
+ return DMAP_DB_GET_INTERFACE (db)->add_with_id (db, record, id, error);
}
guint
-dmap_db_add_path (DmapDb * db, const gchar * path)
+dmap_db_add_path (DmapDb *db, const gchar *path, GError **error)
{
- return DMAP_DB_GET_INTERFACE (db)->add_path (db, path);
+ return DMAP_DB_GET_INTERFACE (db)->add_path (db, path, error);
}
gulong
diff --git a/libdmapsharing/dmap-db.h b/libdmapsharing/dmap-db.h
index bbeba44..a5c5fc4 100644
--- a/libdmapsharing/dmap-db.h
+++ b/libdmapsharing/dmap-db.h
@@ -77,14 +77,14 @@ struct _DmapDbInterface
{
GTypeInterface parent;
- guint (*add) (DmapDb * db, DmapRecord * record);
- guint (*add_with_id) (DmapDb * db, DmapRecord * record, guint id);
- guint (*add_path) (DmapDb * db, const gchar * path);
+ guint (*add) (DmapDb *db, DmapRecord *record, GError **error);
+ guint (*add_with_id) (DmapDb * db, DmapRecord * record, guint id, GError **error);
+ guint (*add_path) (DmapDb * db, const gchar * path, GError **error);
DmapRecord *(*lookup_by_id) (const DmapDb * db, guint id);
- guint (*lookup_id_by_location) (const DmapDb * db,
- const gchar * location);
+ guint (*lookup_id_by_location) (const DmapDb * db,
+ const gchar * location);
void (*foreach) (const DmapDb * db, DmapIdRecordFunc func, gpointer data);
- gint64 (*count) (const DmapDb * db);
+ gint64 (*count) (const DmapDb * db);
};
typedef struct DmapDbFilterDefinition
@@ -100,6 +100,7 @@ GType dmap_db_get_type (void);
* dmap_db_add:
* @db: A media database.
* @record: A database record.
+ * @error: return location for a GError, or NULL.
*
* Add a record to the database.
*
@@ -109,13 +110,14 @@ GType dmap_db_get_type (void);
* be placed elsewhere). In all cases, the record should be unrefed by the
* calling code.
*/
-guint dmap_db_add (DmapDb * db, DmapRecord * record);
+guint dmap_db_add (DmapDb *db, DmapRecord *record, GError **error);
/**
* dmap_db_add_with_id:
* @db: A media database.
* @record: A database record.
* @id: A database record ID.
+ * @error: return location for a GError, or NULL.
*
* Add a record to the database and assign it the given ID.
*
@@ -123,12 +125,13 @@ guint dmap_db_add (DmapDb * db, DmapRecord * record);
*
* See also the notes for dmap_db_add regarding reference counting.
*/
-guint dmap_db_add_with_id (DmapDb * db, DmapRecord * record, guint id);
+guint dmap_db_add_with_id (DmapDb *db, DmapRecord *record, guint id, GError **error);
/**
* dmap_db_add_path:
* @db: A media database.
* @path: A path to an appropriate media file.
+ * @error: return location for a GError, or NULL.
*
* Create a record and add it to the database.
*
@@ -136,7 +139,7 @@ guint dmap_db_add_with_id (DmapDb * db, DmapRecord * record, guint id);
*
* See also the notes for dmap_db_add regarding reference counting.
*/
-guint dmap_db_add_path (DmapDb * db, const gchar * path);
+guint dmap_db_add_path (DmapDb * db, const gchar * path, GError **error);
/**
* dmap_db_lookup_by_id:
diff --git a/libdmapsharing/dmap-image-connection.c b/libdmapsharing/dmap-image-connection.c
index 137b04f..2e6d1f3 100644
--- a/libdmapsharing/dmap-image-connection.c
+++ b/libdmapsharing/dmap-image-connection.c
@@ -112,7 +112,8 @@ _handle_mlcl (DmapConnection * connection, DmapRecordFactory * factory,
}
}
- record = dmap_record_factory_create (factory, NULL);
+ /* FIXME: third argument, NULL, is GError; how to handle? */
+ record = dmap_record_factory_create (factory, NULL, NULL);
if (record == NULL) {
goto _return;
}
diff --git a/libdmapsharing/dmap-record-factory.c b/libdmapsharing/dmap-record-factory.c
index f603cf8..9cee637 100644
--- a/libdmapsharing/dmap-record-factory.c
+++ b/libdmapsharing/dmap-record-factory.c
@@ -28,8 +28,11 @@ dmap_record_factory_default_init (DmapRecordFactoryInterface * iface)
G_DEFINE_INTERFACE(DmapRecordFactory, dmap_record_factory, G_TYPE_OBJECT)
DmapRecord *
-dmap_record_factory_create (DmapRecordFactory * factory, gpointer user_data)
+dmap_record_factory_create (DmapRecordFactory *factory,
+ gpointer user_data,
+ GError **error)
{
return DMAP_RECORD_FACTORY_GET_INTERFACE (factory)->create (factory,
- user_data);
+ user_data,
+ error);
}
diff --git a/libdmapsharing/dmap-record-factory.h b/libdmapsharing/dmap-record-factory.h
index 2d0b3ba..286a4cf 100644
--- a/libdmapsharing/dmap-record-factory.h
+++ b/libdmapsharing/dmap-record-factory.h
@@ -71,7 +71,8 @@ struct _DmapRecordFactoryInterface
GTypeInterface parent;
DmapRecord *(*create) (DmapRecordFactory * factory,
- gpointer user_data);
+ gpointer user_data,
+ GError **error);
};
GType dmap_record_factory_get_type (void);
@@ -80,11 +81,13 @@ GType dmap_record_factory_get_type (void);
* dmap_record_factory_create:
* @factory: A DmapRecordFactory.
* @user_data: Some piece of data that may be used to initialize return value.
+ * @error: return location for a GError, or NULL.
*
* Returns: (transfer full): a new DmapRecord.
*/
DmapRecord *dmap_record_factory_create (DmapRecordFactory * factory,
- gpointer user_data);
+ gpointer user_data,
+ GError **error);
#endif /* _DMAP_RECORD_FACTORY_H */
diff --git a/libdmapsharing/dmap-share.c b/libdmapsharing/dmap-share.c
index 00092dc..8681248 100644
--- a/libdmapsharing/dmap-share.c
+++ b/libdmapsharing/dmap-share.c
@@ -220,11 +220,10 @@ _ctrl_int_adapter (SoupServer * server,
}
gboolean
-dmap_share_serve (DmapShare *share)
+dmap_share_serve (DmapShare *share, GError **error)
{
guint desired_port = DMAP_SHARE_GET_CLASS (share)->get_desired_port (share);
gboolean password_required, ok = FALSE;
- GError *error = NULL;
GSList *listening_uri_list;
SoupURI *listening_uri;
gboolean ret;
@@ -279,20 +278,18 @@ dmap_share_serve (DmapShare *share)
(SoupServerCallback) _ctrl_int_adapter,
share, NULL);
- ret = soup_server_listen_all (share->priv->server, desired_port, 0, &error);
-
+ ret = soup_server_listen_all (share->priv->server, desired_port, 0, error);
if (ret == FALSE) {
g_debug ("Unable to start music sharing server on port %d: %s. "
- "Trying any open IPv6 port", desired_port, error->message);
- g_clear_error (&error);
+ "Trying any open IPv6 port", desired_port, (*error)->message);
+ g_clear_error (error);
ret = soup_server_listen_all (share->priv->server, SOUP_ADDRESS_ANY_PORT,
- 0, &error);
+ 0, error);
}
listening_uri_list = soup_server_get_uris (share->priv->server);
if (ret == FALSE || listening_uri_list == NULL) {
- g_warning ("Unable to start music sharing server on any port.");
goto done;
}
@@ -342,36 +339,25 @@ _server_stop (DmapShare * share)
}
gboolean
-dmap_share_publish (DmapShare * share)
+dmap_share_publish (DmapShare *share, GError **error)
{
- GError *error;
gboolean ok;
gboolean password_required;
password_required =
(share->priv->auth_method != DMAP_SHARE_AUTH_METHOD_NONE);
- error = NULL;
ok = dmap_mdns_publisher_publish (share->priv->publisher,
share->priv->name,
share->priv->port,
DMAP_SHARE_GET_CLASS (share)->
get_type_of_service (share),
password_required,
- share->priv->txt_records, &error);
+ share->priv->txt_records, error);
if (ok == FALSE) {
- if (error != NULL) {
- g_warning
- ("Unable to notify network of media sharing: %s",
- error->message);
- g_error_free (error);
- } else {
- g_warning
- ("Unable to notify network of media sharing");
- }
- }
goto done;
+ }
g_debug ("Published DMAP server information to mdns");
@@ -411,10 +397,11 @@ _restart (DmapShare * share)
gboolean res;
_server_stop (share);
- res = dmap_share_serve (share);
+ /* FIXME: second argument, NULL, is GError; how to handle? */
+ res = dmap_share_serve (share, NULL);
if (res) {
/* To update information just publish again */
- dmap_share_publish (share);
+ dmap_share_publish (share, NULL);
} else {
_publish_stop (share);
}
diff --git a/libdmapsharing/dmap-share.h b/libdmapsharing/dmap-share.h
index c808ef3..0817697 100644
--- a/libdmapsharing/dmap-share.h
+++ b/libdmapsharing/dmap-share.h
@@ -191,23 +191,25 @@ GType dmap_share_get_type (void);
/**
* dmap_share_serve:
* @share: a #DmapShare instance.
+ * @error: return location for a GError, or NULL.
*
* Begin serving the service defined by share. A program will normally also
* call dmap_share_publish.
*
* Returns: TRUE if serving succeeds, else FALSE.
*/
-gboolean dmap_share_serve(DmapShare *share);
+gboolean dmap_share_serve(DmapShare *share, GError **error);
/**
* dmap_share_publish:
* @share: a #DmapShare instance.
+ * @error: return location for a GError, or NULL.
*
* Publish the availability of the given share using mDNS-SD.
*
* Returns: TRUE if publishing succeeds, else FALSE.
*/
-gboolean dmap_share_publish(DmapShare *share);
+gboolean dmap_share_publish(DmapShare *share, GError **error);
/**
* dmap_share_free_filter:
diff --git a/libdmapsharing/test-dmap-av-record-factory.c b/libdmapsharing/test-dmap-av-record-factory.c
index e2010d1..5bf5ff1 100644
--- a/libdmapsharing/test-dmap-av-record-factory.c
+++ b/libdmapsharing/test-dmap-av-record-factory.c
@@ -22,7 +22,9 @@
#include "test-dmap-av-record.h"
DmapRecord *
-test_dmap_av_record_factory_create (DmapRecordFactory *factory, gpointer user_data)
+test_dmap_av_record_factory_create(DmapRecordFactory *factory,
+ gpointer user_data,
+ GError **error)
{
return DMAP_RECORD (test_dmap_av_record_new ());
}
diff --git a/libdmapsharing/test-dmap-av-record-factory.h b/libdmapsharing/test-dmap-av-record-factory.h
index 62faa77..c13a8f7 100644
--- a/libdmapsharing/test-dmap-av-record-factory.h
+++ b/libdmapsharing/test-dmap-av-record-factory.h
@@ -47,11 +47,13 @@ typedef struct {
GObjectClass parent;
} TestDmapAvRecordFactoryClass;
-GType test_dmap_av_record_factory_get_type (void);
+GType test_dmap_av_record_factory_get_type(void);
-TestDmapAvRecordFactory *test_dmap_av_record_factory_new (void);
+TestDmapAvRecordFactory *test_dmap_av_record_factory_new(void);
-DmapRecord *test_dmap_av_record_factory_create (DmapRecordFactory *factory, gpointer user_data);
+DmapRecord *test_dmap_av_record_factory_create(DmapRecordFactory *factory,
+ gpointer user_data,
+ GError **error);
G_END_DECLS
diff --git a/libdmapsharing/test-dmap-container-record.c b/libdmapsharing/test-dmap-container-record.c
index b24d045..b98e9c9 100644
--- a/libdmapsharing/test-dmap-container-record.c
+++ b/libdmapsharing/test-dmap-container-record.c
@@ -68,8 +68,9 @@ test_dmap_container_record_get_id (DmapContainerRecord *record)
void
test_dmap_container_record_add_entry (DmapContainerRecord *container_record,
- DmapRecord *record,
- gint id)
+ DmapRecord *record,
+ gint id,
+ GError **error)
{
}
diff --git a/libdmapsharing/test-dmap-db.c b/libdmapsharing/test-dmap-db.c
index 193d5d7..d272223 100644
--- a/libdmapsharing/test-dmap-db.c
+++ b/libdmapsharing/test-dmap-db.c
@@ -51,7 +51,7 @@ test_dmap_db_count (const DmapDb *db)
}
guint
-test_dmap_db_add (DmapDb *db, DmapRecord *record)
+test_dmap_db_add (DmapDb *db, DmapRecord *record, GError **error)
{
guint id;
id = TEST_DMAP_DB (db)->priv->nextid--;
diff --git a/libdmapsharing/test-dmap-image-record-factory.c b/libdmapsharing/test-dmap-image-record-factory.c
index 2171494..c1ceb3e 100644
--- a/libdmapsharing/test-dmap-image-record-factory.c
+++ b/libdmapsharing/test-dmap-image-record-factory.c
@@ -22,7 +22,9 @@
#include "test-dmap-image-record.h"
DmapRecord *
-test_dmap_image_record_factory_create (DmapRecordFactory *factory, gpointer user_data)
+test_dmap_image_record_factory_create(DmapRecordFactory *factory,
+ gpointer user_data,
+ GError **error)
{
return DMAP_RECORD (test_dmap_image_record_new ());
}
diff --git a/libdmapsharing/test-dmap-image-record-factory.h b/libdmapsharing/test-dmap-image-record-factory.h
index 98fb927..cf8a5e6 100644
--- a/libdmapsharing/test-dmap-image-record-factory.h
+++ b/libdmapsharing/test-dmap-image-record-factory.h
@@ -47,11 +47,13 @@ typedef struct {
GObjectClass parent;
} TestDmapImageRecordFactoryClass;
-GType test_dmap_image_record_factory_get_type (void);
+GType test_dmap_image_record_factory_get_type(void);
-TestDmapImageRecordFactory *test_dmap_image_record_factory_new (void);
+TestDmapImageRecordFactory *test_dmap_image_record_factory_new(void);
-DmapRecord *test_dmap_image_record_factory_create (DmapRecordFactory *factory, gpointer
user_data);
+DmapRecord *test_dmap_image_record_factory_create(DmapRecordFactory *factory,
+ gpointer user_data,
+ GError **error);
G_END_DECLS
diff --git a/tests/dmapserve.c b/tests/dmapserve.c
index bbe5079..0de6d1d 100644
--- a/tests/dmapserve.c
+++ b/tests/dmapserve.c
@@ -73,9 +73,10 @@ typedef struct _ValaDmapDbClass ValaDmapDbClass;
typedef struct _ValaDmapContainerDb ValaDmapContainerDb;
typedef struct _ValaDmapContainerDbClass ValaDmapContainerDbClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _dpap_serve_unref0(var) ((var == NULL) ? NULL : (var = (dpap_serve_unref (var), NULL)))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _ParamSpecDPAPServe ParamSpecDPAPServe;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
-#define _dpap_serve_unref0(var) ((var == NULL) ? NULL : (var = (dpap_serve_unref (var), NULL)))
struct _DPAPServe {
GTypeInstance parent_instance;
@@ -138,8 +139,7 @@ DPAPServe* dpap_serve_construct (GType object_type, GError** error) {
ValaDmapDb* _tmp5_;
ValaDmapContainerDb* _tmp6_;
DmapImageShare* _tmp7_;
- DmapImageShare* _tmp8_;
- DmapImageShare* _tmp9_;
+ GError * _inner_error_ = NULL;
self = (DPAPServe*) g_type_create_instance (object_type);
_tmp0_ = vala_image_record_new ();
_g_object_unref0 (self->priv->record);
@@ -149,7 +149,12 @@ DPAPServe* dpap_serve_construct (GType object_type, GError** error) {
self->priv->db = _tmp1_;
_tmp2_ = self->priv->db;
_tmp3_ = self->priv->record;
- dmap_db_add ((DmapDb*) _tmp2_, (DmapRecord*) _tmp3_);
+ dmap_db_add ((DmapDb*) _tmp2_, (DmapRecord*) _tmp3_, &_inner_error_);
+ if (G_UNLIKELY (_inner_error_ != NULL)) {
+ g_propagate_error (error, _inner_error_);
+ _dpap_serve_unref0 (self);
+ return NULL;
+ }
_tmp4_ = vala_dmap_container_db_new ();
_g_object_unref0 (self->priv->container_db);
self->priv->container_db = _tmp4_;
@@ -158,10 +163,37 @@ DPAPServe* dpap_serve_construct (GType object_type, GError** error) {
_tmp7_ = dmap_image_share_new ("dmapserve", NULL, _tmp5_, _tmp6_, NULL);
_g_object_unref0 (self->priv->share);
self->priv->share = _tmp7_;
- _tmp8_ = self->priv->share;
- dmap_share_serve ((DmapShare*) _tmp8_);
- _tmp9_ = self->priv->share;
- dmap_share_publish ((DmapShare*) _tmp9_);
+ {
+ DmapImageShare* _tmp8_;
+ DmapImageShare* _tmp9_;
+ _tmp8_ = self->priv->share;
+ dmap_share_serve ((DmapShare*) _tmp8_, &_inner_error_);
+ if (G_UNLIKELY (_inner_error_ != NULL)) {
+ goto __catch0_g_error;
+ }
+ _tmp9_ = self->priv->share;
+ dmap_share_publish ((DmapShare*) _tmp9_, &_inner_error_);
+ if (G_UNLIKELY (_inner_error_ != NULL)) {
+ goto __catch0_g_error;
+ }
+ }
+ goto __finally0;
+ __catch0_g_error:
+ {
+ GError* e = NULL;
+ const gchar* _tmp10_;
+ e = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp10_ = e->message;
+ g_error ("dmapserve.vala:39: Error starting server: %s", _tmp10_);
+ _g_error_free0 (e);
+ }
+ __finally0:
+ if (G_UNLIKELY (_inner_error_ != NULL)) {
+ g_propagate_error (error, _inner_error_);
+ _dpap_serve_unref0 (self);
+ return NULL;
+ }
return self;
}
diff --git a/tests/dmapserve.vala b/tests/dmapserve.vala
index cde90c1..9cba6bd 100644
--- a/tests/dmapserve.vala
+++ b/tests/dmapserve.vala
@@ -32,8 +32,12 @@ private class DPAPServe {
db.add (record);
container_db = new ValaDmapContainerDb ();
share = new Dmap.ImageShare ("dmapserve", null, db, container_db, null);
- share.serve();
- share.publish();
+ try {
+ share.serve();
+ share.publish();
+ } catch (GLib.Error e) {
+ GLib.error("Error starting server: %s", e.message);
+ }
}
}
diff --git a/tests/test-dmap-server.c b/tests/test-dmap-server.c
index 8d4200d..85f25a4 100644
--- a/tests/test-dmap-server.c
+++ b/tests/test-dmap-server.c
@@ -63,6 +63,8 @@ create_share (guint conn_type)
DmapRecordFactory *factory;
DmapRecord *record;
DmapShare *share = NULL;
+ GError *error = NULL;
+ gboolean ok;
DmapDb *db;
if (conn_type == DAAP) {
@@ -72,9 +74,9 @@ create_share (guint conn_type)
factory = DMAP_RECORD_FACTORY (test_dmap_image_record_factory_new ());
}
- record = DMAP_RECORD (dmap_record_factory_create (factory, NULL));
+ record = DMAP_RECORD (dmap_record_factory_create (factory, NULL, NULL));
db = DMAP_DB (test_dmap_db_new ());
- dmap_db_add (db, record);
+ dmap_db_add (db, record, NULL);
g_object_unref (record);
g_warning ("initialize DAAP sharing");
@@ -95,9 +97,15 @@ create_share (guint conn_type)
g_assert (NULL != share);
- dmap_share_serve(share);
+ ok = dmap_share_serve(share, &error);
+ if (!ok) {
+ g_error("Error starting server: %s", error->message);
+ }
- dmap_share_publish(share);
+ ok = dmap_share_publish(share, &error);
+ if (!ok) {
+ g_error("Error publishing server: %s", error->message);
+ }
g_free (name);
}
diff --git a/tests/vala-dmap-container-db.c b/tests/vala-dmap-container-db.c
index fe2dd3f..228d9eb 100644
--- a/tests/vala-dmap-container-db.c
+++ b/tests/vala-dmap-container-db.c
@@ -68,7 +68,7 @@ GType vala_dmap_container_db_get_type (void) G_GNUC_CONST;
static gint64 vala_dmap_container_db_real_count (DmapContainerDb* base);
static void vala_dmap_container_db_real_foreach (DmapContainerDb* base, GHFunc func, void* func_target);
static DmapContainerRecord* vala_dmap_container_db_real_lookup_by_id (DmapContainerDb* base, guint id);
-static void vala_dmap_container_db_real_add (DmapContainerDb* base, DmapContainerRecord* record);
+static void vala_dmap_container_db_real_add (DmapContainerDb* base, DmapContainerRecord* record, GError**
error);
ValaDmapContainerDb* vala_dmap_container_db_new (void);
ValaDmapContainerDb* vala_dmap_container_db_construct (GType object_type);
static void vala_dmap_container_db_finalize (GObject * obj);
@@ -144,7 +144,7 @@ static DmapContainerRecord* vala_dmap_container_db_real_lookup_by_id (DmapContai
}
-static void vala_dmap_container_db_real_add (DmapContainerDb* base, DmapContainerRecord* record) {
+static void vala_dmap_container_db_real_add (DmapContainerDb* base, DmapContainerRecord* record, GError**
error) {
ValaDmapContainerDb * self;
self = (ValaDmapContainerDb*) base;
g_return_if_fail (record != NULL);
@@ -176,7 +176,7 @@ static void vala_dmap_container_db_dmap_container_db_interface_init (DmapContain
iface->count = (gint64 (*) (DmapContainerDb *)) vala_dmap_container_db_real_count;
iface->foreach = (void (*) (DmapContainerDb *, DmapIdContainerRecordFunc, void*))
vala_dmap_container_db_real_foreach;
iface->lookup_by_id = (DmapContainerRecord* (*) (DmapContainerDb *, guint))
vala_dmap_container_db_real_lookup_by_id;
- iface->add = (void (*) (DmapContainerDb *, DmapContainerRecord*)) vala_dmap_container_db_real_add;
+ iface->add = (void (*) (DmapContainerDb *, DmapContainerRecord*, GError**))
vala_dmap_container_db_real_add;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]