[libdmapsharing] Some work related to GObject introspection (there is a lot of work remaining)



commit 91879548a32c65b0897ecbe58aaafb7646743931
Author: W. Michael Petullo <mike flyn org>
Date:   Sun Nov 24 14:17:30 2013 -0500

    Some work related to GObject introspection (there is a lot of work remaining)
    
    Signed-off-by: W. Michael Petullo <mike flyn org>

 TODO                               |    4 ++
 configure.ac                       |    2 +
 distro/libdmapsharing.spec         |    9 +++-
 libdmapsharing/Makefile.am         |   29 +++++++++++
 libdmapsharing/daap-share.c        |    2 +-
 libdmapsharing/dacp-player.h       |   16 +++---
 libdmapsharing/dmap-connection.h   |    2 +-
 libdmapsharing/dmap-container-db.h |    2 +-
 libdmapsharing/dmap-db.c           |    2 +-
 libdmapsharing/dmap-db.h           |    8 ++--
 libdmapsharing/dmap-mdns-browser.h |    8 +++
 libdmapsharing/dmap-record.h       |    2 +-
 libdmapsharing/dmap-share.c        |   12 ++--
 libdmapsharing/dpap-share.c        |    2 +-
 m4/introspection.m4                |   96 ++++++++++++++++++++++++++++++++++++
 tests/vala-dpap-record.vala        |    2 +-
 16 files changed, 171 insertions(+), 27 deletions(-)
---
diff --git a/TODO b/TODO
index 6f4087e..32f55a0 100644
--- a/TODO
+++ b/TODO
@@ -18,6 +18,10 @@ Documentation:
 
 = Mid term =====================================================================
 
+Fix callbacks so that they do not provide a gpointer (see service-added
+callback). They need to provide a proper GObject type (e.g., a new
+DMAPMdnsBrowserService type) so that Python/GObject introspection works.
+
 Noah: Comment purpose of each source file and describe interfaces, using test
 programs as examples (Note: wait on doxygen vs. gtk-doc decision.
 
diff --git a/configure.ac b/configure.ac
index 44b6a94..f994043 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,6 +37,8 @@ AM_PROG_CC_STDC
 AC_HEADER_STDC
 AC_PROG_LIBTOOL
 
+GOBJECT_INTROSPECTION_CHECK([1.30.0])
+
 GTK_DOC_CHECK(1.0)
 AC_CONFIG_MACRO_DIR(m4)
 
diff --git a/distro/libdmapsharing.spec b/distro/libdmapsharing.spec
index 318d313..5ce5f83 100644
--- a/distro/libdmapsharing.spec
+++ b/distro/libdmapsharing.spec
@@ -1,12 +1,12 @@
 Name: libdmapsharing
-Version: 2.9.23
+Version: 2.9.24
 Release: 1%{?dist}
 License: LGPLv2+
 Source: http://www.flyn.org/projects/libdmapsharing/%{name}-%{version}.tar.gz
 URL: http://www.flyn.org/projects/libdmapsharing/
 Summary: A DMAP client and server library
 Group: Development/Libraries
-BuildRequires: pkgconfig, glib2-devel, libsoup-devel >= 2.32
+BuildRequires: pkgconfig, glib2-devel, libsoup-devel >= 2.32 gobject-introspection-devel
 BuildRequires: avahi-glib-devel, gdk-pixbuf2-devel, gstreamer1-plugins-base-devel
 
 %description 
@@ -15,6 +15,7 @@ DAAP and DPAP.
 
 %files 
 %{_libdir}/libdmapsharing-3.0.so.*
+%{_libdir}/girepository-1.0/DMAP*.typelib
 %doc AUTHORS COPYING ChangeLog NEWS README
 
 
@@ -32,6 +33,7 @@ other resources needed for developing applications using libdmapsharing.
 %{_libdir}/pkgconfig/libdmapsharing-3.0.pc
 %{_includedir}/libdmapsharing-3.0/
 %{_libdir}/libdmapsharing-3.0.so
+%{_datadir}/gir-1.0/DMAP*.gir
 %{_datadir}/gtk-doc/html/libdmapsharing-3.0
 
 %prep
@@ -50,6 +52,9 @@ rm -f ${RPM_BUILD_ROOT}%{_libdir}/libdmapsharing-3.0.la
 %postun -p /sbin/ldconfig
 
 %changelog
+* Sat Nov 23 2013 W. Michael Petullo <mike[ ]flyn org> - 2.9.24-1
+- new upstream version
+
 * Fri Jul 05 2013 W. Michael Petullo <mike[ ]flyn org> - 2.9.18-1
 - new upstream version
 
diff --git a/libdmapsharing/Makefile.am b/libdmapsharing/Makefile.am
index b2c5a08..b1fe686 100644
--- a/libdmapsharing/Makefile.am
+++ b/libdmapsharing/Makefile.am
@@ -60,6 +60,7 @@ libdmapsharing_3_0_la_CFLAGS = \
 
 libdmapsharing_3_0_la_LDFLAGS = \
        -version-info @SO_VERSION@ \
+       $(CHECK_LIBS) \
        $(GLIB_LIBS) \
        $(GTHREAD_LIBS) \
        $(GOBJECT_LIBS) \
@@ -135,4 +136,32 @@ dmap-enums.c: $(libdmapsharinginclude_headers) Makefile dmap-enums.h
 
 CLEANFILES = $(BUILT_SOURCES)
 
+if HAVE_INTROSPECTION
+include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = --symbol-prefix=dmap --add-include-path=$(srcdir) --warn-all
+INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
+
+introspection_sources = $(libdmapsharinginclude_HEADERS) $(libdmapsharinginclude_SOURCES)
+
+DMAP-3.0.gir: libdmapsharing-3.0.la
+DMAP_3_0_gir_INCLUDES = GObject-2.0 Soup-2.4
+DMAP_3_0_gir_CFLAGS = \
+       $(INCLUDES) \
+       $(libdmapsharing_3_0_la_CFLAGS)
+DMAP_3_0_gir_LIBS = \
+       libdmapsharing-3.0.la
+DMAP_3_0_gir_FILES = $(introspection_sources)
+
+INTROSPECTION_GIRS += DMAP-3.0.gir
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+CLEANFILES += $(gir_DATA) $(typelib_DATA)
+endif
+
 EXTRA_DIST = dmap-marshal.list
diff --git a/libdmapsharing/daap-share.c b/libdmapsharing/daap-share.c
index e182055..3accaf6 100644
--- a/libdmapsharing/daap-share.c
+++ b/libdmapsharing/daap-share.c
@@ -185,7 +185,7 @@ daap_share_message_add_standard_headers (DMAPShare * share,
                                         SoupMessage * message)
 {
        soup_message_headers_append (message->response_headers, "DMAP-Server",
-                                    "libdmapsharing" VERSION);
+                                    "libdmapsharing" "VERSION");
 }
 
 #define DMAP_VERSION 2.0
diff --git a/libdmapsharing/dacp-player.h b/libdmapsharing/dacp-player.h
index f203ef2..eb13241 100644
--- a/libdmapsharing/dacp-player.h
+++ b/libdmapsharing/dacp-player.h
@@ -91,13 +91,13 @@ struct _DACPPlayerIface
 GType dacp_player_get_type (void);
 
 /**
- * dacp_player_now_playing_record
+ * dacp_player_now_playing_record:
  * @player: a player
  */
 DAAPRecord *dacp_player_now_playing_record (DACPPlayer * player);
 
 /**
- * dacp_player_now_playing_artwork
+ * dacp_player_now_playing_artwork:
  * @player: a player
  * @width: width
  * @height: height
@@ -106,37 +106,37 @@ guchar *dacp_player_now_playing_artwork (DACPPlayer * player,
                                          guint width, guint height);
 
 /**
- * dacp_player_play_pause
+ * dacp_player_play_pause:
  * @player: a player
  */
 void dacp_player_play_pause (DACPPlayer * player);
 
 /**
- * dacp_player_pause
+ * dacp_player_pause:
  * @player: a player
  */
 void dacp_player_pause (DACPPlayer * player);
 
 /**
- * dacp_player_next_item
+ * dacp_player_next_item:
  * @player: a player
  */
 void dacp_player_next_item (DACPPlayer * player);
 
 /**
- * dacp_player_now_prev_item
+ * dacp_player_now_prev_item:
  * @player: a player
  */
 void dacp_player_prev_item (DACPPlayer * player);
 
 /**
- * dacp_player_cue_clear
+ * dacp_player_cue_clear:
  * @player: a player
  */
 void dacp_player_cue_clear (DACPPlayer * player);
 
 /**
- * dacp_player_cue_play
+ * dacp_player_cue_play:
  * @player: a player
  * @records : a list of records
  * @index: an index
diff --git a/libdmapsharing/dmap-connection.h b/libdmapsharing/dmap-connection.h
index f438e8c..ccf6f00 100644
--- a/libdmapsharing/dmap-connection.h
+++ b/libdmapsharing/dmap-connection.h
@@ -167,7 +167,7 @@ SoupMessage *dmap_connection_build_message (DMAPConnection * connection,
                                            gint req_id, gboolean send_close);
 
 /**
- * dmap_connection_authenticate_message
+ * dmap_connection_authenticate_message:
  * @connection: A #DMAPConnection
  * @session: A #SoupSession
  * @message: A #SoupMessage
diff --git a/libdmapsharing/dmap-container-db.h b/libdmapsharing/dmap-container-db.h
index 3f2aab0..f001a82 100644
--- a/libdmapsharing/dmap-container-db.h
+++ b/libdmapsharing/dmap-container-db.h
@@ -103,7 +103,7 @@ DMAPContainerRecord *dmap_container_db_lookup_by_id (DMAPContainerDb * db,
 /**
  * dmap_container_db_foreach:
  * @db: A container database.
- * @fn: The function to apply to each record in the database.
+ * @func: The function to apply to each record in the database.
  * @data: User data to pass to the function.
  *
  * Apply a function to each record in a container database.
diff --git a/libdmapsharing/dmap-db.c b/libdmapsharing/dmap-db.c
index 3dd88fa..e7dda13 100644
--- a/libdmapsharing/dmap-db.c
+++ b/libdmapsharing/dmap-db.c
@@ -268,7 +268,7 @@ apply_filter (gpointer id, DMAPRecord * record, gpointer data)
        for (list = fd->filter_def; list != NULL; list = list->next) {
                for (filter = list->data; filter != NULL;
                     filter = filter->next) {
-                       FilterDefinition *def = filter->data;
+                       DMAPDbFilterDefinition *def = filter->data;
                        const gchar *property_name;
 
                        query_key = def->key;
diff --git a/libdmapsharing/dmap-db.h b/libdmapsharing/dmap-db.h
index 86fec42..4fd54f1 100644
--- a/libdmapsharing/dmap-db.h
+++ b/libdmapsharing/dmap-db.h
@@ -79,12 +79,12 @@ struct _DMAPDbIface
 
 typedef const char *(*RecordGetValueFunc) (DMAPRecord * record);
 
-typedef struct FilterDefinition
+typedef struct DMAPDbFilterDefinition
 {
        gchar *key;
        gchar *value;
        gboolean negate;
-} FilterDefinition;
+} DMAPDbFilterDefinition;
 
 GType dmap_db_get_type (void);
 
@@ -104,7 +104,7 @@ GType dmap_db_get_type (void);
 guint dmap_db_add (DMAPDb * db, DMAPRecord * record);
 
 /**
- * dmap_db_add:
+ * dmap_db_add_with_id:
  * @db: A media database.
  * @record: A database record.
  * @id: A database record ID.
@@ -165,7 +165,7 @@ guint dmap_db_lookup_id_by_location (const DMAPDb * db,
 /**
  * dmap_db_foreach:
  * @db: A media database.
- * @fn: The function to apply to each record in the database.
+ * @func: The function to apply to each record in the database.
  * @data: User data to pass to the function.
  *
  * Apply a function to each record in a media database.
diff --git a/libdmapsharing/dmap-mdns-browser.h b/libdmapsharing/dmap-mdns-browser.h
index 65b6ce3..e9114dd 100644
--- a/libdmapsharing/dmap-mdns-browser.h
+++ b/libdmapsharing/dmap-mdns-browser.h
@@ -181,5 +181,13 @@ G_CONST_RETURN GSList *dmap_mdns_browser_get_services (DMAPMdnsBrowser *
 DMAPMdnsBrowserServiceType dmap_mdns_browser_get_service_type (DMAPMdnsBrowser
                                                               * browser);
 
+/**
+ * DMAPMdnsBrowser::service-added:
+ * @browser: the #DMAPMdnsBrowser which received the signal.
+ * @service: #DMAPMdnsBrowserService
+ *
+ * Emitted each time a service becomes available to @browser
+ */
+
 G_END_DECLS
 #endif
diff --git a/libdmapsharing/dmap-record.h b/libdmapsharing/dmap-record.h
index 723ca1c..a7856a8 100644
--- a/libdmapsharing/dmap-record.h
+++ b/libdmapsharing/dmap-record.h
@@ -49,7 +49,7 @@ G_BEGIN_DECLS
 #define IS_DMAP_RECORD(o)           (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
                                      DMAP_TYPE_RECORD))
 /**
- * DAAP_RECORD_GET_INTERFACE:
+ * DMAP_RECORD_GET_INTERFACE:
  * @o: a #DAAPRecord instance.
  *
  * Get the class structure associated to a #DAAPRecord instance.
diff --git a/libdmapsharing/dmap-share.c b/libdmapsharing/dmap-share.c
index d707861..a86cd04 100644
--- a/libdmapsharing/dmap-share.c
+++ b/libdmapsharing/dmap-share.c
@@ -1295,7 +1295,7 @@ _dmap_share_build_filter (gchar * filterstr)
        gboolean negate;
        gint parentheses_count;
        gint quotes_count;
-       FilterDefinition *def;
+       DMAPDbFilterDefinition *def;
 
        GSList *list = NULL;
        GSList *filter = NULL;
@@ -1419,11 +1419,11 @@ _dmap_share_build_filter (gchar * filterstr)
                } else if (value != NULL && *next_char != '!') {
                        // If we won't accept this character, we are ending a 
                        // query key or value, so we should save them in a new
-                       // FilterDefinition. If is_value is TRUE, we will still
+                       // DMAPDbFilterDefinition. If is_value is TRUE, we will still
                        // parse the query value, so we must keep our def around.
                        // Otherwise, save it in the list of filters.
                        if (!def) {
-                               def = g_new0 (FilterDefinition, 1);
+                               def = g_new0 (DMAPDbFilterDefinition, 1);
                        }
                        if (is_key) {
                                def->key = value->str;
@@ -1468,8 +1468,8 @@ _dmap_share_build_filter (gchar * filterstr)
        for (ptr1 = list; ptr1 != NULL; ptr1 = ptr1->next) {
                for (ptr2 = ptr1->data; ptr2 != NULL; ptr2 = ptr2->next) {
                        g_debug ("%s = %s",
-                                ((FilterDefinition *) ptr2->data)->key,
-                                ((FilterDefinition *) ptr2->data)->value);
+                                ((DMAPDbFilterDefinition *) ptr2->data)->key,
+                                ((DMAPDbFilterDefinition *) ptr2->data)->value);
                }
        }
 
@@ -1483,7 +1483,7 @@ dmap_share_free_filter (GSList * filter)
 
        for (ptr1 = filter; ptr1 != NULL; ptr1 = ptr1->next) {
                for (ptr2 = ptr1->data; ptr2 != NULL; ptr2 = ptr2->next) {
-                       g_free (((FilterDefinition *) ptr2->data)->value);
+                       g_free (((DMAPDbFilterDefinition *) ptr2->data)->value);
                        g_free (ptr2->data);
                }
        }
diff --git a/libdmapsharing/dpap-share.c b/libdmapsharing/dpap-share.c
index 72ef344..827e6e8 100644
--- a/libdmapsharing/dpap-share.c
+++ b/libdmapsharing/dpap-share.c
@@ -191,7 +191,7 @@ dpap_share_message_add_standard_headers (DMAPShare * share,
                                         SoupMessage * message)
 {
        soup_message_headers_append (message->response_headers, "DPAP-Server",
-                                    "libdmapsharing" VERSION);
+                                    "libdmapsharing" "VERSION");
 }
 
 #define DMAP_VERSION 2.0
diff --git a/m4/introspection.m4 b/m4/introspection.m4
new file mode 100644
index 0000000..d89c3d9
--- /dev/null
+++ b/m4/introspection.m4
@@ -0,0 +1,96 @@
+dnl -*- mode: autoconf -*-
+dnl Copyright 2009 Johan Dahlin
+dnl
+dnl This file is free software; the author(s) gives unlimited
+dnl permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+
+# serial 1
+
+m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
+[
+    AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
+
+    dnl enable/disable introspection
+    m4_if([$2], [require],
+    [dnl
+        enable_introspection=yes
+    ],[dnl
+        AC_ARG_ENABLE(introspection,
+                  AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
+                                 [Enable introspection for this build]),, 
+                                 [enable_introspection=auto])
+    ])dnl
+
+    AC_MSG_CHECKING([for gobject-introspection])
+
+    dnl presence/version checking
+    AS_CASE([$enable_introspection],
+    [no], [dnl
+        found_introspection="no (disabled, use --enable-introspection to enable)"
+    ],dnl
+    [yes],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0],,
+                         AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
+                         found_introspection=yes,
+                         AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build 
AC_PACKAGE_NAME]))
+    ],dnl
+    [auto],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
+       dnl Canonicalize enable_introspection
+       enable_introspection=$found_introspection
+    ],dnl
+    [dnl       
+        AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of 
@<:@no/auto/yes@:>@])
+    ])dnl
+
+    AC_MSG_RESULT([$found_introspection])
+
+    INTROSPECTION_SCANNER=
+    INTROSPECTION_COMPILER=
+    INTROSPECTION_GENERATE=
+    INTROSPECTION_GIRDIR=
+    INTROSPECTION_TYPELIBDIR=
+    if test "x$found_introspection" = "xyes"; then
+       INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+       INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+       INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+       INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+       INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+       INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir 
gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+    fi
+    AC_SUBST(INTROSPECTION_SCANNER)
+    AC_SUBST(INTROSPECTION_COMPILER)
+    AC_SUBST(INTROSPECTION_GENERATE)
+    AC_SUBST(INTROSPECTION_GIRDIR)
+    AC_SUBST(INTROSPECTION_TYPELIBDIR)
+    AC_SUBST(INTROSPECTION_CFLAGS)
+    AC_SUBST(INTROSPECTION_LIBS)
+    AC_SUBST(INTROSPECTION_MAKEFILE)
+
+    AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
+])
+
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
+
+AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
+])
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
+
+
+AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
+])
diff --git a/tests/vala-dpap-record.vala b/tests/vala-dpap-record.vala
index 6f3c921..dd76c43 100644
--- a/tests/vala-dpap-record.vala
+++ b/tests/vala-dpap-record.vala
@@ -95,7 +95,7 @@ private class ValaDPAPRecord : GLib.Object, DMAP.Record, DPAP.Record {
                GLib.error ("read not implemented");
        }
 
-       public unowned DMAP.Record set_from_blob (GLib.ByteArray blob) {
+       public unowned bool set_from_blob (GLib.ByteArray blob) {
                GLib.error ("set_from_blob not implemented");
        }
 


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