# HG changeset patch
# User rosfran
# Date 1176243893 -3600
# Node ID 4ff7cb1a27d2888322a56cf2dfbac8db2a27abf4
# Parent  348964b09e4a62f71975d3b98d1f13a8805cfcbc
[svn r523] Some addings on GObject gets/sets.

diff -r 348964b09e4a -r 4ff7cb1a27d2 gmyth/src/gmyth_file_local.c
--- a/gmyth/src/gmyth_file_local.c	Tue Apr 10 23:24:29 2007 +0100
+++ b/gmyth/src/gmyth_file_local.c	Tue Apr 10 23:24:53 2007 +0100
@@ -70,9 +70,9 @@
 static void gmyth_file_local_dispose             (GObject *object);
 static void gmyth_file_local_finalize            (GObject *object);
 
-static gboolean _control_acquire_context( GMythFileTransfer *transfer, gboolean do_wait );
+static gboolean _control_acquire_context( GMythFileLocal *file_local, gboolean do_wait );
 
-static gboolean _control_release_context( GMythFileTransfer *transfer );
+static gboolean _control_release_context( GMythFileLocal *file_local );
 
 G_DEFINE_TYPE(GMythFileLocal, gmyth_file_local, GMYTH_FILE_TYPE)
 
@@ -153,9 +153,16 @@
 GMythFileLocal*
 gmyth_file_local_new (GMythBackendInfo *backend_info)
 {
-  GMythFileLocal *file_local = GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_TYPE, backend_info, NULL));
+    GMythFileLocal *file_local = NULL;
+    GValue val = {0,};
+    g_value_init (&val, G_TYPE_OBJECT);
+    g_value_set_object (&val, backend_info);
+    g_object_set_property (G_OBJECT (file), "backend-info", &val);
 
-  return file_local;
+    file_local = GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_TYPE,
+            "backend-info", val, NULL));
+
+    return file_local;
 }
 
 /** 
@@ -163,20 +170,36 @@
  * 
  * @param uri_str The URI poiting to the MythTV backend server.
  * 
- * @return a new instance of the File Transfer. 
+ * @return a new instance of the File Transfer.
  */
 GMythFileLocal* 
 gmyth_file_local_new_with_uri (const gchar* uri_str)
 {
-  GMythFileLocal *file_local = GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_TYPE, uri_str, NULL));
-
-  return file_local;
+    GMythFileLocal *file_local = GMYTH_FILE_LOCAL (g_object_new (GMYTH_FILE_TYPE, NULL));
+    GMythURI *uri = gmyth_uri_new_with_value(uri_str);
+    
+    gmyth_debug( "GMythURI path segment = %s", gmyth_uri_get_path(uri) );
+    
+    g_object_set( GMYTH_FILE( file_local),
+            "backend-info", gmyth_backend_info_new_with_uri( uri_str ),
+            "filename", g_strdup( gmyth_uri_get_path(uri) ),
+            NULL );
+    
+    g_object_unref( uri );
+    
+    return file_local;
 }
 
 gchar*
 gmyth_file_local_get_file_name (GMythFileLocal *file_local)
 {
-    return gmyth_file_get_filename( g_type_peek_parent( file_local ) );
+    return gmyth_file_get_file_name( GMYTH_FILE( file_local ) );
+}
+
+void
+gmyth_file_local_set_file_name (GMythFileLocal *file_local, const gchar* filename)
+{
+    gmyth_file_set_file_name( GMYTH_FILE( file_local ), filename );
 }
 
 /** 
@@ -197,16 +220,13 @@
 
     priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
     file_name_uri = gmyth_file_local_get_file_name(file_local);
-    
+
     if ( file_name_uri != NULL )
     {
-        GMythURI *uri = gmyth_uri_new_with_value(file_name_uri);
-        gmyth_debug( "GMythURI path segment = %s", gmyth_uri_get_path(uri) );
-        priv->file_io = g_io_channel_new_file( g_strdup( gmyth_uri_get_path(uri) ), "r+", NULL );
-        g_object_unref( uri );
+        priv->file_io = g_io_channel_new_file( g_strdup( file_name_uri ), "r+", NULL );
         g_free( file_name_uri );
     }
-    
+
     if ( priv->file_io < 0 )
         ret = FALSE;
 
@@ -224,7 +244,6 @@
     GMythFileLocalPrivate *priv;
 
     g_return_if_fail (file_local != NULL);
-
 }
 
 /** 
@@ -242,7 +261,7 @@
     GMythFileLocalPrivate *priv;
 
     g_return_val_if_fail (file_local != NULL, FALSE);
-    priv = GMYTH_FILE_LOCAL_GET_PRIVATE (transfer);
+    priv = GMYTH_FILE_LOCAL_GET_PRIVATE (file_local);
 
     g_mutex_lock (priv->mutex);
     return ret;
@@ -331,13 +350,13 @@
         
         if (!read_unlimited && ( gmyth_file_local_get_file_size(file_local) > 0) && 
                 (gmyth_file_local_get_offset(file_local) == gmyth_file_local_get_file_size(file_local))) {
-            retval = GMYTH_FILE_TRANSFER_READ_EOF;
+            retval = GMYTH_FILE_READ_EOF;
             goto error;
         }
         
         g_free (data_buffer);
     } else { 
-        retval = GMYTH_FILE_TRANSFER_READ_ERROR;
+        retval = GMYTH_FILE_READ_ERROR;
     }
 
 error:
@@ -365,12 +384,9 @@
 guint64
 gmyth_file_local_get_filesize (GMythFileLocal *file_local)
 {
-    GMythFilePrivate *priv;
-
     g_return_val_if_fail (file_local != NULL, 0);
 
-    priv = GMYTH_FILE_GET_PRIVATE ( GMYTH_FILE(g_object_peek_parent(file_local)));
-    return priv->filesize;
+    return gmyth_file_get_filesize( GMYTH_FILE(g_type_peek_parent(file_local)) );
 }
 
 /** 
@@ -382,13 +398,9 @@
 void
 gmyth_file_local_set_filesize (GMythFileLocal *file_local, guint64 filesize)
 {
-    GMythFilePrivate *priv;
+    g_return_if_fail (file_local != NULL);
 
-    g_return_val_if_fail (file_local != NULL, 0);
-
-    priv = GMYTH_FILE_GET_PRIVATE (GMYTH_FILE(g_object_peek_parent(file_local)));
-    
-    priv->filesize = filesize;
+    gmyth_file_set_filesize( GMYTH_FILE(g_type_peek_parent(file_local)), filesize );
 }
 
 /** 
@@ -396,17 +408,14 @@
  * 
  * @param file_local The actual File Transfer instance.
  * 
- * @return The actual file offset in bytes. 
+ * @return The actual file offset in bytes.
  */
 gint64
 gmyth_file_local_get_offset (GMythFileLocal *file_local)
 {
-    GMythFilePrivate *priv;
-
     g_return_val_if_fail (file_local != NULL, 0);
 
-    priv = GMYTH_FILE_GET_PRIVATE ( GMYTH_FILE(g_object_peek_parent(file_local)));
-    return priv->offset;
+    return gmyth_file_get_offset ( GMYTH_FILE(g_type_peek_parent(file_local)));;
 }
 
 /** 
@@ -418,12 +427,8 @@
 void
 gmyth_file_local_set_offset (GMythFileLocal *file_local, gint64 offset)
 {
-    GMythFilePrivate *priv;
+    g_return_if_fail (file_local != NULL);
 
-    g_return_val_if_fail (file_local != NULL, 0);
-
-    priv = GMYTH_FILE_GET_PRIVATE (GMYTH_FILE(g_object_peek_parent(file_local)));
-    
-    priv->offset = offset;
+    gmyth_file_set_offset( GMYTH_FILE(g_type_peek_parent(file_local)), offset );
 }
 
diff -r 348964b09e4a -r 4ff7cb1a27d2 gmyth/src/gmyth_file_local.h
--- a/gmyth/src/gmyth_file_local.h	Tue Apr 10 23:24:29 2007 +0100
+++ b/gmyth/src/gmyth_file_local.h	Tue Apr 10 23:24:53 2007 +0100
@@ -46,9 +46,9 @@
 G_BEGIN_DECLS
 
 #define GMYTH_FILE_LOCAL_TYPE               (gmyth_file_local_get_type ())
-#define GMYTH_FILE_LOCAL_(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocal))
+#define GMYTH_FILE_LOCAL(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocal))
 #define GMYTH_FILE_LOCAL_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_LOCAL_TYPE, GMythFileLocalClass))
-#define IS_GMYTH_FILE_LOCAL_(obj)           (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_LOCAL_TYPE))
+#define IS_GMYTH_FILE_LOCAL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GMYTH_FILE_LOCAL_TYPE))
 #define IS_GMYTH_FILE_LOCAL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GMYTH_FILE_LOCAL_TYPE))
 #define GMYTH_FILE_LOCAL_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS ((obj), GMYTH_FILE_LOCAL_TYPE, GMythFileLocalClass))
 
@@ -69,12 +69,13 @@
 
 GType               gmyth_file_local_get_type        (void);
 GMythFileLocal*     gmyth_file_local_new             (GMythBackendInfo *backend_info);
+GMythFileLocal*     gmyth_file_local_new_with_uri    (GMythBackendInfo *backend_info, const gchar* uri);
 gchar*              gmyth_file_local_get_file_name   (GMythFileLocal *file_local);
-gboolean            gmyth_file_local_open            (GMythFileLocal *file_local, 
-                                					     const gchar* filename);
+void                gmyth_file_local_set_file_name   (GMythFileLocal *file_local, const gchar* filename);
+gboolean            gmyth_file_local_open            (GMythFileLocal *file_local);
 void                gmyth_file_local_close           (GMythFileLocal *file_local);
 gboolean            gmyth_file_local_is_open         (GMythFileLocal *file_local);
-GMythFileLocalReadResult
+GMythFileReadResult
                     gmyth_file_local_read            (GMythFileLocal *file_local, 
                                                          GByteArray *data, 
                                                          gint size, 
@@ -82,8 +83,8 @@
 guint64             gmyth_file_local_get_filesize   (GMythFileLocal *file_local);
 void                gmyth_file_local_set_filesize   (GMythFileLocal *file, guint64 filesize);
 
-gint64              gmyth_file_local_get_offset (GMythFileLocal *file_local);
-void                gmyth_file_local_set_offset (GMythFileLocal *file_local, gint64 offset);
+gint64              gmyth_file_local_get_offset     (GMythFileLocal *file_local);
+void                gmyth_file_local_set_offset     (GMythFileLocal *file_local, gint64 offset);
 
 G_END_DECLS