# HG changeset patch # User rosfran # Date 1164665279 0 # Node ID 96d4296e449240587ac8e801b6afbd8aa7b99555 # Parent 1374c8f47f33efda94f0b9b8e26adec35b8b5019 [svn r120] Added new constructor to BackendInfo, using the GMythURI. diff -r 1374c8f47f33 -r 96d4296e4492 gmyth/src/gmyth_backendinfo.c --- a/gmyth/src/gmyth_backendinfo.c Mon Nov 27 22:07:09 2006 +0000 +++ b/gmyth/src/gmyth_backendinfo.c Mon Nov 27 22:07:59 2006 +0000 @@ -25,6 +25,7 @@ */ #include "gmyth_backendinfo.h" +#include "gmyth_uri.h" static void gmyth_backend_info_class_init (GMythBackendInfoClass *klass); static void gmyth_backend_info_init (GMythBackendInfo *object); @@ -32,9 +33,6 @@ static void gmyth_backend_info_dispose (GObject *object); static void gmyth_backend_info_finalize (GObject *object); -static gint get_record_id_from_database (GMythBackendInfo *scheduler); -static void update_backend (gint record_id); - G_DEFINE_TYPE(GMythBackendInfo, gmyth_backend_info, G_TYPE_OBJECT) static void @@ -114,6 +112,23 @@ return backend_info; } +GMythBackendInfo* +gmyth_backend_info_new_with_uri (const gchar *uri_str ) +{ + GMythBackendInfo *backend_info = + GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL)); + + GMythURI* uri = gmyth_uri_new( (gchar*)uri_str ); + + gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host (uri ) ); + gmyth_backend_info_set_username (backend_info, gmyth_uri_get_user( uri ) ); + gmyth_backend_info_set_password (backend_info, gmyth_uri_get_password( uri ) ); + gmyth_backend_info_set_db_name (backend_info, gmyth_uri_get_path( uri ) ); + gmyth_backend_info_set_port (backend_info, gmyth_uri_get_port( uri ) ); + + return backend_info; +} + void gmyth_backend_info_set_hostname (GMythBackendInfo *backend_info, const char *hostname) { @@ -146,6 +161,14 @@ backend_info->db_name = g_strdup (db_name); } +void +gmyth_backend_info_set_port (GMythBackendInfo *backend_info, const gint port ) +{ + g_return_if_fail (backend_info != NULL); + + backend_info->port = port; +} + char* gmyth_backend_info_get_hostname (GMythBackendInfo *backend_info) { diff -r 1374c8f47f33 -r 96d4296e4492 gmyth/src/gmyth_backendinfo.h --- a/gmyth/src/gmyth_backendinfo.h Mon Nov 27 22:07:09 2006 +0000 +++ b/gmyth/src/gmyth_backendinfo.h Mon Nov 27 22:07:59 2006 +0000 @@ -68,6 +68,7 @@ GMythBackendInfo* gmyth_backend_info_new_full ( const char *hostname, const char *username, const char *password, const char *db_name, gint port); +GMythBackendInfo* gmyth_backend_info_new_with_uri (const gchar *uri_str ); void gmyth_backend_info_set_hostname (GMythBackendInfo *backend_info, const char *hostname); void gmyth_backend_info_set_username (GMythBackendInfo *backend_info, const char *username); diff -r 1374c8f47f33 -r 96d4296e4492 gmyth/src/gmyth_uri.c --- a/gmyth/src/gmyth_uri.c Mon Nov 27 22:07:09 2006 +0000 +++ b/gmyth/src/gmyth_uri.c Mon Nov 27 22:07:59 2006 +0000 @@ -133,7 +133,7 @@ uri->host = g_string_append_len( uri->host, value+currIdx, shashIdx ); else if ( gmyth_uri_isabsolute(uri) == TRUE ) uri->host = g_string_append_len( uri->host, value+currIdx, strlen(value) - currIdx ); - host = g_strdup( gmyth_uri_gethost(uri) ); + host = g_strdup( gmyth_uri_get_host(uri) ); colonIdx = gmyth_strrchr( host, GMYTH_URI_COLON_DELIM, 1 ); eblacketIdx = gmyth_strrchr( host, GMYTH_URI_EBLACET_DELIM, 1 ); if ( ( 0 < colonIdx ) && ( eblacketIdx < colonIdx ) ) { @@ -157,7 +157,7 @@ } else { uri->port = GMYTH_URI_KNKOWN_PORT; - protocol = gmyth_uri_getprotocol(uri); + protocol = gmyth_uri_get_protocol(uri); if ( strcmp(protocol, GMYTH_URI_PROTOCOL_HTTP) == 0 ) uri->port = GMYTH_URI_DEFAULT_HTTP_PORT; if ( strcmp(protocol, GMYTH_URI_PROTOCOL_FTP) == 0 ) @@ -210,7 +210,7 @@ gboolean gmyth_uri_is_equals( GMythURI* uri1, GMythURI* uri2 ) { - return ( g_ascii_strcasecmp( gmyth_uri_gethost( uri1 ), gmyth_uri_gethost( uri2 ) ) == 0 && - gmyth_uri_getport( uri1 ) == gmyth_uri_getport( uri2 ) ); + return ( g_ascii_strcasecmp( gmyth_uri_get_host( uri1 ), gmyth_uri_get_host( uri2 ) ) == 0 && + gmyth_uri_get_port( uri1 ) == gmyth_uri_get_port( uri2 ) ); } diff -r 1374c8f47f33 -r 96d4296e4492 gmyth/src/gmyth_uri.h --- a/gmyth/src/gmyth_uri.h Mon Nov 27 22:07:09 2006 +0000 +++ b/gmyth/src/gmyth_uri.h Mon Nov 27 22:07:59 2006 +0000 @@ -57,9 +57,11 @@ gboolean gmyth_uri_is_equals( GMythURI* uri1, GMythURI* uri2 ); -#define gmyth_uri_gethost(urip) (urip->host->str) -#define gmyth_uri_getport(urip) (urip->port) -#define gmyth_uri_getprotocol(urip) (urip->protocol->str) -#define gmyth_uri_getpath(urip) (urip->path->str) +#define gmyth_uri_get_host(urip) (urip->host->str) +#define gmyth_uri_get_port(urip) (urip->port) +#define gmyth_uri_get_protocol(urip) (urip->protocol->str) +#define gmyth_uri_get_path(urip) (urip->path->str) +#define gmyth_uri_get_user(urip) (urip->user->str) +#define gmyth_uri_get_password(urip) (urip->password->str) #endif