[svn r523] Some addings on GObject gets/sets.
1.1 --- a/gmyth/src/gmyth_file_local.c Tue Apr 10 23:24:29 2007 +0100
1.2 +++ b/gmyth/src/gmyth_file_local.c Tue Apr 10 23:24:53 2007 +0100
1.3 @@ -70,9 +70,9 @@
1.4 static void gmyth_file_local_dispose (GObject *object);
1.5 static void gmyth_file_local_finalize (GObject *object);
1.6
1.7 -static gboolean _control_acquire_context( GMythFileTransfer *transfer, gboolean do_wait );
1.8 +static gboolean _control_acquire_context( GMythFileLocal *file_local, gboolean do_wait );
1.9
1.10 -static gboolean _control_release_context( GMythFileTransfer *transfer );
1.11 +static gboolean _control_release_context( GMythFileLocal *file_local );
1.12
1.13 G_DEFINE_TYPE(GMythFileLocal, gmyth_file_local, GMYTH_FILE_TYPE)
1.14
1.15 @@ -153,9 +153,16 @@
1.16 GMythFileLocal*
1.17 gmyth_file_local_new (GMythBackendInfo *backend_info)
1.18 {
1.19 - GMythFileLocal *file_local = GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_TYPE, backend_info, NULL));
1.20 + GMythFileLocal *file_local = NULL;
1.21 + GValue val = {0,};
1.22 + g_value_init (&val, G_TYPE_OBJECT);
1.23 + g_value_set_object (&val, backend_info);
1.24 + g_object_set_property (G_OBJECT (file), "backend-info", &val);
1.25
1.26 - return file_local;
1.27 + file_local = GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_TYPE,
1.28 + "backend-info", val, NULL));
1.29 +
1.30 + return file_local;
1.31 }
1.32
1.33 /**
1.34 @@ -163,20 +170,36 @@
1.35 *
1.36 * @param uri_str The URI poiting to the MythTV backend server.
1.37 *
1.38 - * @return a new instance of the File Transfer.
1.39 + * @return a new instance of the File Transfer.
1.40 */
1.41 GMythFileLocal*
1.42 gmyth_file_local_new_with_uri (const gchar* uri_str)
1.43 {
1.44 - GMythFileLocal *file_local = GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_TYPE, uri_str, NULL));
1.45 -
1.46 - return file_local;
1.47 + GMythFileLocal *file_local = GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_TYPE, NULL));
1.48 + GMythURI *uri = gmyth_uri_new_with_value(uri_str);
1.49 +
1.50 + gmyth_debug( "GMythURI path segment = %s", gmyth_uri_get_path(uri) );
1.51 +
1.52 + g_object_set( GMYTH_FILE( file_local),
1.53 + "backend-info", gmyth_backend_info_new_with_uri( uri_str ),
1.54 + "filename", g_strdup( gmyth_uri_get_path(uri) ),
1.55 + NULL );
1.56 +
1.57 + g_object_unref( uri );
1.58 +
1.59 + return file_local;
1.60 }
1.61
1.62 gchar*
1.63 gmyth_file_local_get_file_name (GMythFileLocal *file_local)
1.64 {
1.65 - return gmyth_file_get_filename( g_type_peek_parent( file_local ) );
1.66 + return gmyth_file_get_file_name( GMYTH_FILE( file_local ) );
1.67 +}
1.68 +
1.69 +void
1.70 +gmyth_file_local_set_file_name (GMythFileLocal *file_local, const gchar* filename)
1.71 +{
1.72 + gmyth_file_set_file_name( GMYTH_FILE( file_local ), filename );
1.73 }
1.74
1.75 /**
1.76 @@ -197,16 +220,13 @@
1.77
1.78 priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
1.79 file_name_uri = gmyth_file_local_get_file_name(file_local);
1.80 -
1.81 +
1.82 if ( file_name_uri != NULL )
1.83 {
1.84 - GMythURI *uri = gmyth_uri_new_with_value(file_name_uri);
1.85 - gmyth_debug( "GMythURI path segment = %s", gmyth_uri_get_path(uri) );
1.86 - priv->file_io = g_io_channel_new_file( g_strdup( gmyth_uri_get_path(uri) ), "r+", NULL );
1.87 - g_object_unref( uri );
1.88 + priv->file_io = g_io_channel_new_file( g_strdup( file_name_uri ), "r+", NULL );
1.89 g_free( file_name_uri );
1.90 }
1.91 -
1.92 +
1.93 if ( priv->file_io < 0 )
1.94 ret = FALSE;
1.95
1.96 @@ -224,7 +244,6 @@
1.97 GMythFileLocalPrivate *priv;
1.98
1.99 g_return_if_fail (file_local != NULL);
1.100 -
1.101 }
1.102
1.103 /**
1.104 @@ -242,7 +261,7 @@
1.105 GMythFileLocalPrivate *priv;
1.106
1.107 g_return_val_if_fail (file_local != NULL, FALSE);
1.108 - priv = GMYTH_FILE_LOCAL_GET_PRIVATE (transfer);
1.109 + priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
1.110
1.111 g_mutex_lock (priv->mutex);
1.112 return ret;
1.113 @@ -331,13 +350,13 @@
1.114
1.115 if (!read_unlimited && ( gmyth_file_local_get_file_size(file_local) > 0) &&
1.116 (gmyth_file_local_get_offset(file_local) == gmyth_file_local_get_file_size(file_local))) {
1.117 - retval = GMYTH_FILE_TRANSFER_READ_EOF;
1.118 + retval = GMYTH_FILE_READ_EOF;
1.119 goto error;
1.120 }
1.121
1.122 g_free (data_buffer);
1.123 } else {
1.124 - retval = GMYTH_FILE_TRANSFER_READ_ERROR;
1.125 + retval = GMYTH_FILE_READ_ERROR;
1.126 }
1.127
1.128 error:
1.129 @@ -365,12 +384,9 @@
1.130 guint64
1.131 gmyth_file_local_get_filesize (GMythFileLocal *file_local)
1.132 {
1.133 - GMythFilePrivate *priv;
1.134 -
1.135 g_return_val_if_fail (file_local != NULL, 0);
1.136
1.137 - priv = GMYTH_FILE_GET_PRIVATE ( GMYTH_FILE(g_object_peek_parent(file_local)));
1.138 - return priv->filesize;
1.139 + return gmyth_file_get_filesize( GMYTH_FILE(g_type_peek_parent(file_local)) );
1.140 }
1.141
1.142 /**
1.143 @@ -382,13 +398,9 @@
1.144 void
1.145 gmyth_file_local_set_filesize (GMythFileLocal *file_local, guint64 filesize)
1.146 {
1.147 - GMythFilePrivate *priv;
1.148 + g_return_if_fail (file_local != NULL);
1.149
1.150 - g_return_val_if_fail (file_local != NULL, 0);
1.151 -
1.152 - priv = GMYTH_FILE_GET_PRIVATE (GMYTH_FILE(g_object_peek_parent(file_local)));
1.153 -
1.154 - priv->filesize = filesize;
1.155 + gmyth_file_set_filesize( GMYTH_FILE(g_type_peek_parent(file_local)), filesize );
1.156 }
1.157
1.158 /**
1.159 @@ -396,17 +408,14 @@
1.160 *
1.161 * @param file_local The actual File Transfer instance.
1.162 *
1.163 - * @return The actual file offset in bytes.
1.164 + * @return The actual file offset in bytes.
1.165 */
1.166 gint64
1.167 gmyth_file_local_get_offset (GMythFileLocal *file_local)
1.168 {
1.169 - GMythFilePrivate *priv;
1.170 -
1.171 g_return_val_if_fail (file_local != NULL, 0);
1.172
1.173 - priv = GMYTH_FILE_GET_PRIVATE ( GMYTH_FILE(g_object_peek_parent(file_local)));
1.174 - return priv->offset;
1.175 + return gmyth_file_get_offset ( GMYTH_FILE(g_type_peek_parent(file_local)));;
1.176 }
1.177
1.178 /**
1.179 @@ -418,12 +427,8 @@
1.180 void
1.181 gmyth_file_local_set_offset (GMythFileLocal *file_local, gint64 offset)
1.182 {
1.183 - GMythFilePrivate *priv;
1.184 + g_return_if_fail (file_local != NULL);
1.185
1.186 - g_return_val_if_fail (file_local != NULL, 0);
1.187 -
1.188 - priv = GMYTH_FILE_GET_PRIVATE (GMYTH_FILE(g_object_peek_parent(file_local)));
1.189 -
1.190 - priv->offset = offset;
1.191 + gmyth_file_set_offset( GMYTH_FILE(g_type_peek_parent(file_local)), offset );
1.192 }
1.193
2.1 --- a/gmyth/src/gmyth_file_local.h Tue Apr 10 23:24:29 2007 +0100
2.2 +++ b/gmyth/src/gmyth_file_local.h Tue Apr 10 23:24:53 2007 +0100
2.3 @@ -46,9 +46,9 @@
2.4 G_BEGIN_DECLS
2.5
2.6 #define GMYTH_FILE_LOCAL_TYPE (gmyth_file_local_get_type ())
2.7 -#define GMYTH_FILE_LOCAL_(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocal))
2.8 +#define GMYTH_FILE_LOCAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocal))
2.9 #define GMYTH_FILE_LOCAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_LOCAL_TYPE, GMythFileLocalClass))
2.10 -#define IS_GMYTH_FILE_LOCAL_(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_LOCAL_TYPE))
2.11 +#define IS_GMYTH_FILE_LOCAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_LOCAL_TYPE))
2.12 #define IS_GMYTH_FILE_LOCAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_LOCAL_TYPE))
2.13 #define GMYTH_FILE_LOCAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocalClass))
2.14
2.15 @@ -69,12 +69,13 @@
2.16
2.17 GType gmyth_file_local_get_type (void);
2.18 GMythFileLocal* gmyth_file_local_new (GMythBackendInfo *backend_info);
2.19 +GMythFileLocal* gmyth_file_local_new_with_uri (GMythBackendInfo *backend_info, const gchar* uri);
2.20 gchar* gmyth_file_local_get_file_name (GMythFileLocal *file_local);
2.21 -gboolean gmyth_file_local_open (GMythFileLocal *file_local,
2.22 - const gchar* filename);
2.23 +void gmyth_file_local_set_file_name (GMythFileLocal *file_local, const gchar* filename);
2.24 +gboolean gmyth_file_local_open (GMythFileLocal *file_local);
2.25 void gmyth_file_local_close (GMythFileLocal *file_local);
2.26 gboolean gmyth_file_local_is_open (GMythFileLocal *file_local);
2.27 -GMythFileLocalReadResult
2.28 +GMythFileReadResult
2.29 gmyth_file_local_read (GMythFileLocal *file_local,
2.30 GByteArray *data,
2.31 gint size,
2.32 @@ -82,8 +83,8 @@
2.33 guint64 gmyth_file_local_get_filesize (GMythFileLocal *file_local);
2.34 void gmyth_file_local_set_filesize (GMythFileLocal *file, guint64 filesize);
2.35
2.36 -gint64 gmyth_file_local_get_offset (GMythFileLocal *file_local);
2.37 -void gmyth_file_local_set_offset (GMythFileLocal *file_local, gint64 offset);
2.38 +gint64 gmyth_file_local_get_offset (GMythFileLocal *file_local);
2.39 +void gmyth_file_local_set_offset (GMythFileLocal *file_local, gint64 offset);
2.40
2.41 G_END_DECLS
2.42