[svn r120] Added new constructor to BackendInfo, using the GMythURI.
1.1 --- a/gmyth/src/gmyth_backendinfo.c Mon Nov 27 22:07:09 2006 +0000
1.2 +++ b/gmyth/src/gmyth_backendinfo.c Mon Nov 27 22:07:59 2006 +0000
1.3 @@ -25,6 +25,7 @@
1.4 */
1.5
1.6 #include "gmyth_backendinfo.h"
1.7 +#include "gmyth_uri.h"
1.8
1.9 static void gmyth_backend_info_class_init (GMythBackendInfoClass *klass);
1.10 static void gmyth_backend_info_init (GMythBackendInfo *object);
1.11 @@ -32,9 +33,6 @@
1.12 static void gmyth_backend_info_dispose (GObject *object);
1.13 static void gmyth_backend_info_finalize (GObject *object);
1.14
1.15 -static gint get_record_id_from_database (GMythBackendInfo *scheduler);
1.16 -static void update_backend (gint record_id);
1.17 -
1.18 G_DEFINE_TYPE(GMythBackendInfo, gmyth_backend_info, G_TYPE_OBJECT)
1.19
1.20 static void
1.21 @@ -114,6 +112,23 @@
1.22 return backend_info;
1.23 }
1.24
1.25 +GMythBackendInfo*
1.26 +gmyth_backend_info_new_with_uri (const gchar *uri_str )
1.27 +{
1.28 + GMythBackendInfo *backend_info =
1.29 + GMYTH_BACKEND_INFO (g_object_new(GMYTH_BACKEND_INFO_TYPE, NULL));
1.30 +
1.31 + GMythURI* uri = gmyth_uri_new( (gchar*)uri_str );
1.32 +
1.33 + gmyth_backend_info_set_hostname (backend_info, gmyth_uri_get_host (uri ) );
1.34 + gmyth_backend_info_set_username (backend_info, gmyth_uri_get_user( uri ) );
1.35 + gmyth_backend_info_set_password (backend_info, gmyth_uri_get_password( uri ) );
1.36 + gmyth_backend_info_set_db_name (backend_info, gmyth_uri_get_path( uri ) );
1.37 + gmyth_backend_info_set_port (backend_info, gmyth_uri_get_port( uri ) );
1.38 +
1.39 + return backend_info;
1.40 +}
1.41 +
1.42 void
1.43 gmyth_backend_info_set_hostname (GMythBackendInfo *backend_info, const char *hostname)
1.44 {
1.45 @@ -146,6 +161,14 @@
1.46 backend_info->db_name = g_strdup (db_name);
1.47 }
1.48
1.49 +void
1.50 +gmyth_backend_info_set_port (GMythBackendInfo *backend_info, const gint port )
1.51 +{
1.52 + g_return_if_fail (backend_info != NULL);
1.53 +
1.54 + backend_info->port = port;
1.55 +}
1.56 +
1.57 char*
1.58 gmyth_backend_info_get_hostname (GMythBackendInfo *backend_info)
1.59 {
2.1 --- a/gmyth/src/gmyth_backendinfo.h Mon Nov 27 22:07:09 2006 +0000
2.2 +++ b/gmyth/src/gmyth_backendinfo.h Mon Nov 27 22:07:59 2006 +0000
2.3 @@ -68,6 +68,7 @@
2.4 GMythBackendInfo* gmyth_backend_info_new_full (
2.5 const char *hostname, const char *username, const char *password,
2.6 const char *db_name, gint port);
2.7 +GMythBackendInfo* gmyth_backend_info_new_with_uri (const gchar *uri_str );
2.8
2.9 void gmyth_backend_info_set_hostname (GMythBackendInfo *backend_info, const char *hostname);
2.10 void gmyth_backend_info_set_username (GMythBackendInfo *backend_info, const char *username);
3.1 --- a/gmyth/src/gmyth_uri.c Mon Nov 27 22:07:09 2006 +0000
3.2 +++ b/gmyth/src/gmyth_uri.c Mon Nov 27 22:07:59 2006 +0000
3.3 @@ -133,7 +133,7 @@
3.4 uri->host = g_string_append_len( uri->host, value+currIdx, shashIdx );
3.5 else if ( gmyth_uri_isabsolute(uri) == TRUE )
3.6 uri->host = g_string_append_len( uri->host, value+currIdx, strlen(value) - currIdx );
3.7 - host = g_strdup( gmyth_uri_gethost(uri) );
3.8 + host = g_strdup( gmyth_uri_get_host(uri) );
3.9 colonIdx = gmyth_strrchr( host, GMYTH_URI_COLON_DELIM, 1 );
3.10 eblacketIdx = gmyth_strrchr( host, GMYTH_URI_EBLACET_DELIM, 1 );
3.11 if ( ( 0 < colonIdx ) && ( eblacketIdx < colonIdx ) ) {
3.12 @@ -157,7 +157,7 @@
3.13 }
3.14 else {
3.15 uri->port = GMYTH_URI_KNKOWN_PORT;
3.16 - protocol = gmyth_uri_getprotocol(uri);
3.17 + protocol = gmyth_uri_get_protocol(uri);
3.18 if ( strcmp(protocol, GMYTH_URI_PROTOCOL_HTTP) == 0 )
3.19 uri->port = GMYTH_URI_DEFAULT_HTTP_PORT;
3.20 if ( strcmp(protocol, GMYTH_URI_PROTOCOL_FTP) == 0 )
3.21 @@ -210,7 +210,7 @@
3.22 gboolean
3.23 gmyth_uri_is_equals( GMythURI* uri1, GMythURI* uri2 )
3.24 {
3.25 - return ( g_ascii_strcasecmp( gmyth_uri_gethost( uri1 ), gmyth_uri_gethost( uri2 ) ) == 0 &&
3.26 - gmyth_uri_getport( uri1 ) == gmyth_uri_getport( uri2 ) );
3.27 + return ( g_ascii_strcasecmp( gmyth_uri_get_host( uri1 ), gmyth_uri_get_host( uri2 ) ) == 0 &&
3.28 + gmyth_uri_get_port( uri1 ) == gmyth_uri_get_port( uri2 ) );
3.29 }
3.30
4.1 --- a/gmyth/src/gmyth_uri.h Mon Nov 27 22:07:09 2006 +0000
4.2 +++ b/gmyth/src/gmyth_uri.h Mon Nov 27 22:07:59 2006 +0000
4.3 @@ -57,9 +57,11 @@
4.4
4.5 gboolean gmyth_uri_is_equals( GMythURI* uri1, GMythURI* uri2 );
4.6
4.7 -#define gmyth_uri_gethost(urip) (urip->host->str)
4.8 -#define gmyth_uri_getport(urip) (urip->port)
4.9 -#define gmyth_uri_getprotocol(urip) (urip->protocol->str)
4.10 -#define gmyth_uri_getpath(urip) (urip->path->str)
4.11 +#define gmyth_uri_get_host(urip) (urip->host->str)
4.12 +#define gmyth_uri_get_port(urip) (urip->port)
4.13 +#define gmyth_uri_get_protocol(urip) (urip->protocol->str)
4.14 +#define gmyth_uri_get_path(urip) (urip->path->str)
4.15 +#define gmyth_uri_get_user(urip) (urip->user->str)
4.16 +#define gmyth_uri_get_password(urip) (urip->password->str)
4.17
4.18 #endif