[gupnp-tools] av-cp: Make network port configurable



commit d4d6ed7b36273dd6aadca0c29a60dafe3cbbb9e2
Author: Jens Georg <mail jensge org>
Date:   Wed Mar 20 11:05:27 2013 +0100

    av-cp: Make network port configurable

 configure.ac     |    2 +-
 src/av-cp/gui.c  |    5 +----
 src/av-cp/gui.h  |    3 +--
 src/av-cp/main.c |   29 +++++++++++++++++++++++++----
 4 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 14f748c..e7cf0da 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,7 +25,7 @@ LT_INIT([])
 
 GLIB_REQUIRED=2.24
 GSSDP_REQUIRED=0.13.3
-GUPNP_REQUIRED=0.13
+GUPNP_REQUIRED=0.18.0
 SOUP_REQUIRED=2.4
 GUPNP_AV_REQUIRED=0.5.5
 GTK_REQUIRED=3.0.0
diff --git a/src/av-cp/gui.c b/src/av-cp/gui.c
index 68056e6..47b72db 100644
--- a/src/av-cp/gui.c
+++ b/src/av-cp/gui.c
@@ -81,14 +81,11 @@ setup_icons (GtkBuilder *builder)
 }
 
 gboolean
-init_ui (gint   *argc,
-         gchar **argv[])
+init_ui ()
 {
         gint window_width, window_height;
         GError *error = NULL;
 
-        gtk_init (argc, argv);
-
         builder = gtk_builder_new ();
         g_assert (builder != NULL);
         gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
diff --git a/src/av-cp/gui.h b/src/av-cp/gui.h
index 9fbcf12..3126cc3 100644
--- a/src/av-cp/gui.h
+++ b/src/av-cp/gui.h
@@ -27,8 +27,7 @@
 #include "playlist-treeview.h"
 
 gboolean
-init_ui                         (gint             *argc,
-                                 gchar           **argv[]);
+init_ui                         (void);
 
 GtkButton *
 get_rescan_button               (void);
diff --git a/src/av-cp/main.c b/src/av-cp/main.c
index 944de91..07d24dc 100644
--- a/src/av-cp/main.c
+++ b/src/av-cp/main.c
@@ -37,6 +37,14 @@
 #define MEDIA_RENDERER "urn:schemas-upnp-org:device:MediaRenderer:1"
 #define MEDIA_SERVER "urn:schemas-upnp-org:device:MediaServer:1"
 
+static int upnp_port = 0;
+
+static GOptionEntry entries[] =
+{
+        { "port", 'p', 0, G_OPTION_ARG_INT, &upnp_port, N_("Network PORT to use for UPnP"), "PORT" },
+        { NULL }
+};
+
 static GUPnPContextManager *context_manager;
 
 static void
@@ -127,13 +135,13 @@ on_context_available (GUPnPContextManager *context_manager,
 }
 
 static gboolean
-init_upnp (void)
+init_upnp (int port)
 {
 #if !GLIB_CHECK_VERSION(2, 35, 0)
         g_type_init ();
 #endif
 
-        context_manager = gupnp_context_manager_new (NULL, 0);
+        context_manager = gupnp_context_manager_create (port);
         g_assert (context_manager != NULL);
 
         g_signal_connect (context_manager,
@@ -164,16 +172,29 @@ gint
 main (gint   argc,
       gchar *argv[])
 {
+        GError *error = NULL;
+        GOptionContext *context = NULL;
+
         setlocale (LC_ALL, "");
         bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
         bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
         textdomain (GETTEXT_PACKAGE);
 
-        if (!init_ui (&argc, &argv)) {
+        context = g_option_context_new (_("- UPnP AV control point"));
+        g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
+        g_option_context_add_group (context, gtk_get_option_group (TRUE));
+
+        if (!g_option_context_parse (context, &argc, &argv, &error)) {
+                g_print (_("Could not parse options: %s\n"), error->message);
+
+                return -4;
+        }
+
+        if (!init_ui ()) {
            return -2;
         }
 
-        if (!init_upnp ()) {
+        if (!init_upnp (upnp_port)) {
            return -3;
         }
 


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