Commit 831f3516 authored by W. Michael Petullo's avatar W. Michael Petullo
Browse files

Added finalize function to TestDAAPRecord and TestDPAPRecord.

parent 93ece3d5
......@@ -5,7 +5,9 @@ daap-connection.c:96: note: initialized from here
Ensure client test catches newly shared files?
Ensure D[AP]APRecords are properly freed.
Do transcode based on client?
Ensure D[AP]APRecord's properly implement finalize.
daap-connection.c
daap-connection.h
......
......@@ -23,6 +23,11 @@
<chapter>
<title>Libdmapsharing Browsing Overview</title>
<xi:include href="mediadb.sgml"/>
<xi:include href="containerdb.sgml"/>
<xi:include href="browserapi.sgml"/>
<xi:include href="serviceaddedcb.sgml"/>
<xi:include href="connectedcb.sgml"/>
</chapter>
<chapter>
......
......@@ -27,11 +27,51 @@
G_BEGIN_DECLS
/**
* TYPE_DMAP_MDNS_BROWSER:
*
* The type for #DMAPMdnsBrowser.
*/
#define TYPE_DMAP_MDNS_BROWSER (dmap_mdns_browser_get_type ())
/**
* DMAP_MDNS_BROWSER:
* @o: Object which is subject to casting.
*
* Casts a #DMAPMdnsBrowser or derived pointer into a (DMAPMdnsBrowser *) pointer.
* Depending on the current debugging level, this function may invoke
* certain runtime checks to identify invalid casts.
*/
#define DMAP_MDNS_BROWSER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TYPE_DMAP_MDNS_BROWSER, DMAPMdnsBrowser))
/**
* DMAP_MDNS_BROWSER_CLASS:
* @k: a valid #DMAPMdnsBrowserClass
*
* Casts a derived #DAAPShareClass structure into a #DAAPShareClass structure.
*/
#define DMAP_MDNS_BROWSER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TYPE_DMAP_MDNS_BROWSER, DMAPMdnsBrowserClass))
/**
* IS_DMAP_MDNS_BROWSER:
* @o: Instance to check for being a %TYPE_DMAP_MDNS_BROWSER.
*
* Checks whether a valid #GTypeInstance pointer is of type %TYPE_DAAP_SHARE.
*/
#define IS_DMAP_MDNS_BROWSER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TYPE_DMAP_MDNS_BROWSER))
/**
* IS_DMAP_MDNS_BROWSER_CLASS:
* @k: a #DMAPMdnsBrowserClass
*
* Checks whether @k "is a" valid #DMAPMdnsBrowserClass structure of type
* %DMAP_MDNS_BROWSER or derived.
*/
#define IS_DMAP_MDNS_BROWSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TYPE_DMAP_MDNS_BROWSER))
/**
* DMAP_MDNS_BROWSER_GET_CLASS:
* @o: a #DMAPMdnsBrowser instance.
*
* Get the class structure associated to a #DMAPMdnsBrowser instance.
*
* Returns: pointer to object class structure.
*/
#define DMAP_MDNS_BROWSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TYPE_DMAP_MDNS_BROWSER, DMAPMdnsBrowserClass))
typedef struct _DMAPMdnsBrowser DMAPMdnsBrowser;
......@@ -85,10 +125,36 @@ GQuark dmap_mdns_browser_error_quark (void);
GType dmap_mdns_browser_get_type (void);
/**
* dmap_mdns_browser_new:
* @type: The type of service to browse.
*
* Creates a new mDNS browser.
*
* Returns: a pointer to a DMAPMdnsBrowser.
*/
DMAPMdnsBrowser *dmap_mdns_browser_new (DMAPMdnsBrowserServiceType type);
/**
* dmap_mdns_browser_start:
* @browser: A DMAPMdnsBrowser.
* @error: A GError.
*
* Starts a DMAPMdnsBrowser.
*
* Returns: TRUE on success, else FALSE.
*/
gboolean dmap_mdns_browser_start (DMAPMdnsBrowser *browser,
GError **error);
/**
* dmap_mdns_browser_stop:
* @browser: A DMAPMdnsBrowser.
* @error: A GError.
*
* Stops a DMAPMdnsBrowser.
*
* Returns: TRUE on success, else FALSE.
*/
gboolean dmap_mdns_browser_stop (DMAPMdnsBrowser *browser,
GError **error);
......
......@@ -25,16 +25,16 @@
struct TestDAAPRecordPrivate {
gint filesize;
gint rating;
const char *location;
const char *title;
const char *format;
const char *album;
const char *artist;
char *location;
char *title;
char *format;
char *album;
char *artist;
gulong bitrate;
gint32 firstseen;
gint32 mtime;
gint32 disc;
const char *genre;
char *genre;
gint32 duration;
gint32 track;
gint32 year;
......@@ -208,6 +208,8 @@ test_daap_record_init (TestDAAPRecord *record)
record->priv = TEST_DAAP_RECORD_GET_PRIVATE (record);
}
static void test_daap_record_finalize (GObject *object);
static void
test_daap_record_class_init (TestDAAPRecordClass *klass)
{
......@@ -217,6 +219,7 @@ test_daap_record_class_init (TestDAAPRecordClass *klass)
gobject_class->set_property = test_daap_record_set_property;
gobject_class->get_property = test_daap_record_get_property;
gobject_class->finalize = test_daap_record_finalize;
g_object_class_override_property (gobject_class, PROP_LOCATION, "location");
g_object_class_override_property (gobject_class, PROP_TITLE, "title");
......@@ -265,6 +268,21 @@ G_DEFINE_TYPE_WITH_CODE (TestDAAPRecord, test_daap_record, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (TYPE_DAAP_RECORD, test_daap_record_daap_iface_init)
G_IMPLEMENT_INTERFACE (TYPE_DMAP_RECORD, test_daap_record_dmap_iface_init))
static void
test_daap_record_finalize (GObject *object)
{
TestDAAPRecord *record = TEST_DAAP_RECORD (object);
g_free (record->priv->location);
g_free (record->priv->title);
g_free (record->priv->format);
g_free (record->priv->album);
g_free (record->priv->artist);
g_free (record->priv->genre);
G_OBJECT_CLASS (test_daap_record_parent_class)->finalize (object);
}
TestDAAPRecord *test_daap_record_new (void)
{
......@@ -275,11 +293,11 @@ TestDAAPRecord *test_daap_record_new (void)
record->priv->location = g_strdup_printf ("file://%s/media/test.mp3", g_get_current_dir ());
record->priv->title = "FIXME";
record->priv->title = g_strdup ("Unknown");
record->priv->album = "FIXME";
record->priv->album = g_strdup ("Unknown");
record->priv->artist = "FIXME";
record->priv->artist = g_strdup ("Unknown");
record->priv->bitrate = 128;
......@@ -289,7 +307,7 @@ TestDAAPRecord *test_daap_record_new (void)
record->priv->disc = 1;
record->priv->genre = "Blues";
record->priv->genre = g_strdup ("Unknown");
ext = strrchr (record->priv->location, '.');
if (ext == NULL) {
......
......@@ -27,12 +27,12 @@ struct TestDPAPRecordPrivate {
gint pixelwidth;
gint rating;
gint creationdate;
const char *location;
const char *title;
const char *aspectratio;
const char *filename;
const char *format;
const char *comments;
char *location;
char *title;
char *aspectratio;
char *filename;
char *format;
char *comments;
unsigned char *thumbnail;
};
......@@ -168,6 +168,8 @@ test_dpap_record_init (TestDPAPRecord *record)
record->priv = TEST_DPAP_RECORD_GET_PRIVATE (record);
}
static void test_dpap_record_finalize (GObject *object);
static void
test_dpap_record_class_init (TestDPAPRecordClass *klass)
{
......@@ -177,6 +179,7 @@ test_dpap_record_class_init (TestDPAPRecordClass *klass)
gobject_class->set_property = test_dpap_record_set_property;
gobject_class->get_property = test_dpap_record_get_property;
gobject_class->finalize = test_dpap_record_finalize;
g_object_class_override_property (gobject_class, PROP_FILESIZE, "filesize");
g_object_class_override_property (gobject_class, PROP_LARGE_FILESIZE, "large-filesize");
......@@ -214,6 +217,22 @@ G_DEFINE_TYPE_WITH_CODE (TestDPAPRecord, test_dpap_record, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (TYPE_DPAP_RECORD, test_dpap_record_dpap_iface_init)
G_IMPLEMENT_INTERFACE (TYPE_DMAP_RECORD, test_dpap_record_dmap_iface_init))
static void
test_dpap_record_finalize (GObject *object)
{
TestDPAPRecord *record = TEST_DPAP_RECORD (object);
g_free (record->priv->location);
g_free (record->priv->title);
g_free (record->priv->aspectratio);
g_free (record->priv->filename);
g_free (record->priv->format);
g_free (record->priv->comments);
g_free (record->priv->thumbnail);
G_OBJECT_CLASS (test_dpap_record_parent_class)->finalize (object);
}
TestDPAPRecord *
test_dpap_record_new (void)
{
......@@ -229,16 +248,16 @@ test_dpap_record_new (void)
record->priv->location = g_strdup_printf ("file://%s/media/test.jpeg",
g_get_current_dir ());
record->priv->title = "Title of Photograph";
record->priv->title = g_strdup ("Title of Photograph");
/* Width / Height as a string. */
record->priv->aspectratio = "1.333";
record->priv->aspectratio = g_strdup ("1.333");
record->priv->filename = g_basename (record->priv->location);
record->priv->filename = g_path_get_basename (record->priv->location);
record->priv->format = "JPEG";
record->priv->format = g_strdup ("JPEG");
record->priv->comments = "Test comments about an image.";
record->priv->comments = g_strdup ("Test comments about an image.");
record->priv->largefilesize = 13953;
......
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