[libdmapsharing] Extend API to support dmapd work
- From: W. Michael Petullo <wmpetullo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdmapsharing] Extend API to support dmapd work
- Date: Mon, 24 May 2010 16:33:05 +0000 (UTC)
commit f6900fff43e65639a25bc34f114cd0d759cf1e28
Author: W. Michael Petullo <mike flyn org>
Date: Sat May 22 12:12:16 2010 -0500
Extend API to support dmapd work
Add new to_blob/new_from_blob interface to D[AP]PRecord and modify
DMAPShare's finalize code.
Signed-off-by: W. Michael Petullo <mike flyn org>
ChangeLog | 8 ++++++++
libdmapsharing/daap-record.c | 12 ++++++++++++
libdmapsharing/daap-record.h | 18 ++++++++++++++++++
libdmapsharing/dmap-share.c | 8 +++++---
libdmapsharing/dpap-record.c | 12 ++++++++++++
libdmapsharing/dpap-record.h | 20 +++++++++++++++++++-
6 files changed, 74 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b151435..5a298e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+22 May 2010 W. Michael Petullo <mike flyn org>
+
+ * Add new to_blob/new_from_blob interface to D[AP]PRecord.
+
+20 May 2010 W. Michael Petullo <mike flyn org>
+
+ * Fix finalize code for DMAPShare.
+
18 May 2010 W. Michael Petullo <mike flyn org>
* Add another case to dpap-share.c:build_filter() in an attempt
diff --git a/libdmapsharing/daap-record.c b/libdmapsharing/daap-record.c
index 765cc1d..0bb1e4b 100644
--- a/libdmapsharing/daap-record.c
+++ b/libdmapsharing/daap-record.c
@@ -214,3 +214,15 @@ daap_record_read (DAAPRecord *record, GError **err)
{
return DAAP_RECORD_GET_INTERFACE (record)->read (record, err);
}
+
+GByteArray *
+daap_record_to_blob (DAAPRecord *record)
+{
+ return DAAP_RECORD_GET_INTERFACE (record)->to_blob (record);
+}
+
+DAAPRecord *
+daap_record_new_from_blob (DAAPRecord *record, GByteArray *blob)
+{
+ return DAAP_RECORD_GET_INTERFACE (record)->new_from_blob (record, blob);
+}
diff --git a/libdmapsharing/daap-record.h b/libdmapsharing/daap-record.h
index e1b8a57..7194b31 100644
--- a/libdmapsharing/daap-record.h
+++ b/libdmapsharing/daap-record.h
@@ -71,6 +71,8 @@ struct _DAAPRecordInterface {
gboolean (*itunes_compat) (DAAPRecord *record);
GInputStream * (*read) (DAAPRecord *record, GError **err);
+ GByteArray * (*to_blob) (DAAPRecord *record);
+ DAAPRecord * (*new_from_blob) (DAAPRecord *record, GByteArray *blob);
};
GType daap_record_get_type (void);
@@ -93,6 +95,22 @@ gboolean daap_record_itunes_compat (DAAPRecord *record);
*/
GInputStream *daap_record_read (DAAPRecord *record, GError **err);
+/**
+ * daap_record_to_blob:
+ * @record: a DAAPRecord.
+ *
+ * Returns: A serialized representation of the record.
+ */
+GByteArray *daap_record_to_blob (DAAPRecord *record);
+
+/**
+ * daap_record_new_from_blob:
+ * @blob: a serialized DAAPRecord representation.
+ *
+ * Returns: A DAAPRecord.
+ */
+DAAPRecord *daap_record_new_from_blob (DAAPRecord *record, GByteArray *blob);
+
#endif /* __DAAP_RECORD_H */
G_END_DECLS
diff --git a/libdmapsharing/dmap-share.c b/libdmapsharing/dmap-share.c
index 102bc51..4e3e161 100644
--- a/libdmapsharing/dmap-share.c
+++ b/libdmapsharing/dmap-share.c
@@ -454,10 +454,12 @@ _dmap_share_get_property (GObject *object,
}
static void
-_dmap_share_dispose (GObject *object)
+_dmap_share_finalize (GObject *object)
{
DMAPShare *share = DMAP_SHARE (object);
+ g_debug ("Finalizing DMAPShare");
+
if (share->priv->published) {
_dmap_share_publish_stop (share);
}
@@ -472,7 +474,7 @@ _dmap_share_dispose (GObject *object)
g_object_unref (share->priv->publisher);
}
- G_OBJECT_CLASS (dmap_share_parent_class)->dispose (object);
+ G_OBJECT_CLASS (dmap_share_parent_class)->finalize (object);
}
static void
@@ -482,7 +484,7 @@ dmap_share_class_init (DMAPShareClass *klass)
object_class->get_property = _dmap_share_get_property;
object_class->set_property = _dmap_share_set_property;
- object_class->dispose = _dmap_share_dispose;
+ object_class->finalize = _dmap_share_finalize;
/* Pure virtual methods: */
klass->get_desired_port = NULL;
diff --git a/libdmapsharing/dpap-record.c b/libdmapsharing/dpap-record.c
index fe22d9a..58a1a0d 100644
--- a/libdmapsharing/dpap-record.c
+++ b/libdmapsharing/dpap-record.c
@@ -165,3 +165,15 @@ dpap_record_read (DPAPRecord *record, GError **err)
{
return DPAP_RECORD_GET_INTERFACE (record)->read (record, err);
}
+
+GByteArray *
+dpap_record_to_blob (DPAPRecord *record)
+{
+ return DPAP_RECORD_GET_INTERFACE (record)->to_blob (record);
+}
+
+DPAPRecord *
+dpap_record_new_from_blob (DPAPRecord *record, GByteArray *blob)
+{
+ return DPAP_RECORD_GET_INTERFACE (record)->new_from_blob (record, blob);
+}
diff --git a/libdmapsharing/dpap-record.h b/libdmapsharing/dpap-record.h
index 0cdd11c..f1c7ddc 100644
--- a/libdmapsharing/dpap-record.h
+++ b/libdmapsharing/dpap-record.h
@@ -69,7 +69,9 @@ typedef struct _DPAPRecordInterface DPAPRecordInterface;
struct _DPAPRecordInterface {
GTypeInterface parent;
- GInputStream * (*read) (DPAPRecord *record, GError **err);
+ GInputStream * (*read) (DPAPRecord *record, GError **err);
+ GByteArray * (*to_blob) (DPAPRecord *record);
+ DPAPRecord * (*new_from_blob) (DPAPRecord *record, GByteArray *blob);
};
GType dpap_record_get_type (void);
@@ -84,6 +86,22 @@ GType dpap_record_get_type (void);
*/
GInputStream *dpap_record_read (DPAPRecord *record, GError **err);
+/**
+ * dpap_record_to_blob:
+ * @record: a DPAPRecord.
+ *
+ * Returns: A serialized representation of the record.
+ */
+GByteArray *dpap_record_to_blob (DPAPRecord *record);
+
+/**
+ * dpap_record_new_from_blob:
+ * @blob: a serialized DPAPRecord representation.
+ *
+ * Returns: A DPAPRecord.
+ */
+DPAPRecord *dpap_record_new_from_blob (DPAPRecord *record, GByteArray *blob);
+
#endif /* __DPAP_RECORD_H */
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]