[gvfs] [FTP] simplify debug id API



commit b07c3a9b238f03b203c09adbb764e88b585cfdc6
Author: Benjamin Otte <otte gnome org>
Date:   Thu Jun 11 17:32:28 2009 +0200

    [FTP] simplify debug id API
    
    Add a separate function for requesting the debug id

 daemon/gvfsbackendftp.c    |    2 +-
 daemon/gvfsftpconnection.c |   22 ++++++++++++++++++----
 daemon/gvfsftpconnection.h |    4 ++--
 daemon/gvfsftpdircache.c   |    7 ++-----
 4 files changed, 23 insertions(+), 12 deletions(-)
---
diff --git a/daemon/gvfsbackendftp.c b/daemon/gvfsbackendftp.c
index 19e5198..d137d6a 100644
--- a/daemon/gvfsbackendftp.c
+++ b/daemon/gvfsbackendftp.c
@@ -1269,7 +1269,7 @@ do_pull (GVfsBackend *         backend,
       goto out;
     }
 
-  input = g_io_stream_get_input_stream (g_vfs_ftp_connection_get_data_stream (task.conn, NULL));
+  input = g_io_stream_get_input_stream (g_vfs_ftp_connection_get_data_stream (task.conn));
   ftp_output_stream_splice (output,
                             input,
                             total_size,
diff --git a/daemon/gvfsftpconnection.c b/daemon/gvfsftpconnection.c
index 8182258..4c39874 100644
--- a/daemon/gvfsftpconnection.c
+++ b/daemon/gvfsftpconnection.c
@@ -239,9 +239,25 @@ g_vfs_ftp_connection_close_data_connection (GVfsFtpConnection *conn)
 }
 
 /**
+ * g_vfs_ftp_connection_get_debug_id:
+ * @conn: the connection
+ *
+ * Gets an ID that uniquely identifies this connection. Intended for use in 
+ * debug print statements.
+ *
+ * Returns: the ID to use for referring to this connection in debug messages
+ **/
+guint
+g_vfs_ftp_connection_get_debug_id (GVfsFtpConnection *conn)
+{
+  g_return_val_if_fail (conn != NULL, 0);
+
+  return conn->debug_id;
+}
+
+/**
  * g_vfs_ftp_connection_get_data_stream:
  * @conn: a connection
- * @debug_id: %NULL or pointer taking id to use for debugging purposes
  *
  * Gets the data stream in use by @conn. It is an error to call this function
  * when no data stream exists. Be sure to check the return value of
@@ -250,13 +266,11 @@ g_vfs_ftp_connection_close_data_connection (GVfsFtpConnection *conn)
  * Returns: the data stream of @conn
  **/
 GIOStream *
-g_vfs_ftp_connection_get_data_stream (GVfsFtpConnection *conn, int *debug_id)
+g_vfs_ftp_connection_get_data_stream (GVfsFtpConnection *conn)
 {
   g_return_val_if_fail (conn != NULL, NULL);
   g_return_val_if_fail (conn->data != NULL, NULL);
 
-  if (debug_id)
-    *debug_id = conn->debug_id;
   return conn->data;
 }
 
diff --git a/daemon/gvfsftpconnection.h b/daemon/gvfsftpconnection.h
index 534a176..12e9025 100644
--- a/daemon/gvfsftpconnection.h
+++ b/daemon/gvfsftpconnection.h
@@ -48,6 +48,7 @@ guint                   g_vfs_ftp_connection_receive          (GVfsFtpConnection
 gboolean                g_vfs_ftp_connection_is_usable        (GVfsFtpConnection *      conn);
 GSocketAddress *        g_vfs_ftp_connection_get_address      (GVfsFtpConnection *      conn,
                                                                GError **                error);
+guint                   g_vfs_ftp_connection_get_debug_id     (GVfsFtpConnection *      conn);
 
 gboolean                g_vfs_ftp_connection_open_data_connection
                                                               (GVfsFtpConnection *      conn,
@@ -56,8 +57,7 @@ gboolean                g_vfs_ftp_connection_open_data_connection
                                                                GError **                error);
 void                    g_vfs_ftp_connection_close_data_connection
                                                               (GVfsFtpConnection *      conn);
-GIOStream *             g_vfs_ftp_connection_get_data_stream  (GVfsFtpConnection *      conn,
-                                                               int *                    debug_id);
+GIOStream *             g_vfs_ftp_connection_get_data_stream  (GVfsFtpConnection *      conn);
 gssize                  g_vfs_ftp_connection_write_data       (GVfsFtpConnection *      conn,
                                                                const char *             data,
                                                                gsize                    len,
diff --git a/daemon/gvfsftpdircache.c b/daemon/gvfsftpdircache.c
index b94a3b3..26984f4 100644
--- a/daemon/gvfsftpdircache.c
+++ b/daemon/gvfsftpdircache.c
@@ -134,8 +134,6 @@ g_vfs_ftp_dir_cache_lookup_entry (GVfsFtpDirCache *  cache,
                                   guint              stamp)
 {
   GVfsFtpDirCacheEntry *entry;
-  GIOStream *stream;
-  int debug_id;
 
   g_mutex_lock (cache->lock);
   entry = g_hash_table_lookup (cache->directories, dir);
@@ -164,9 +162,8 @@ g_vfs_ftp_dir_cache_lookup_entry (GVfsFtpDirCache *  cache,
     return NULL;
 
   entry = g_vfs_ftp_dir_cache_entry_new (stamp);
-  stream = g_vfs_ftp_connection_get_data_stream (task->conn, &debug_id);
-  cache->funcs->process (g_io_stream_get_input_stream (stream),
-                         debug_id,
+  cache->funcs->process (g_io_stream_get_input_stream (g_vfs_ftp_connection_get_data_stream (task->conn)),
+                         g_vfs_ftp_connection_get_debug_id (task->conn),
                          dir,
                          entry,
                          task->cancellable,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]