1.1 --- a/gmyth/src/gmyth_backendinfo.c Fri Dec 08 23:16:15 2006 +0000
1.2 +++ b/gmyth/src/gmyth_backendinfo.c Thu Jan 04 21:16:44 2007 +0000
1.3 @@ -32,6 +32,10 @@
1.4 #include "gmyth_uri.h"
1.5 #include "gmyth_debug.h"
1.6
1.7 +#ifdef WITH_UPNP
1.8 +#include "gmyth_upnp.h"
1.9 +#endif
1.10 +
1.11 static void gmyth_backend_info_class_init (GMythBackendInfoClass *klass);
1.12 static void gmyth_backend_info_init (GMythBackendInfo *object);
1.13
1.14 @@ -107,7 +111,7 @@
1.15 {
1.16 GMythBackendInfo *backend_info =
1.17 GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
1.18 -
1.19 +
1.20 gmyth_backend_info_set_hostname (backend_info, hostname);
1.21 gmyth_backend_info_set_username (backend_info, username);
1.22 gmyth_backend_info_set_password (backend_info, password);
1.23 @@ -145,8 +149,21 @@
1.24 gmyth_backend_info_set_hostname (GMythBackendInfo *backend_info, const gchar *hostname)
1.25 {
1.26 g_return_if_fail (backend_info != NULL);
1.27 -
1.28 - backend_info->hostname = g_strdup (hostname);
1.29 +
1.30 + if ( NULL == hostname || strlen(hostname) <= 0 )
1.31 + {
1.32 + #ifdef WITH_UPNP
1.33 + GMythUPnP *gmyth_upnp = gmyth_upnp_new( backend_info );
1.34 + backend_info = gmyth_upnp_get_backend_info( gmyth_upnp );
1.35 + backend_info->hostname = g_strdup ( gmyth_upnp_get_host( gmyth_upnp ) );
1.36 + g_object_unref( gmyth_upnp );
1.37 + #else
1.38 + gmyth_debug ( "Error trying to set a hostname equals to NULL (it doesn't using UPnP)." );
1.39 + return NULL;
1.40 + #endif
1.41 + } else {
1.42 + backend_info->hostname = g_strdup (hostname);
1.43 + }
1.44 }
1.45
1.46 void
1.47 @@ -178,7 +195,20 @@
1.48 {
1.49 g_return_if_fail (backend_info != NULL);
1.50
1.51 - backend_info->port = port;
1.52 + if ( port <= 0 )
1.53 + {
1.54 + #ifdef WITH_UPNP
1.55 + GMythUPnP *gmyth_upnp = gmyth_upnp_new( backend_info );
1.56 + backend_info = gmyth_upnp_get_backend_info( gmyth_upnp );
1.57 + backend_info->port = gmyth_upnp_get_port( gmyth_upnp );
1.58 + g_object_unref( gmyth_upnp );
1.59 + #else
1.60 + gmyth_debug ( "Error trying to set a hostname equals to NULL (it doesn't using UPnP)." );
1.61 + return NULL;
1.62 + #endif
1.63 + } else {
1.64 + backend_info->port = port;
1.65 + }
1.66 }
1.67
1.68 const gchar*