summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorCarl-Anton Ingmarsson <ca.ingmarsson@gmail.com>2011-11-06 19:03:00 +0100
committerCarl-Anton Ingmarsson <ca.ingmarsson@gmail.com>2012-01-22 09:47:27 +0100
commit86cca680ec185d0a74fa948485d221bc9efe9181 (patch)
tree8c2821fb16291e3b8ee9629578795bdbc137039d /daemon
parent88866fdc3c34e8b9ce2d4435098885e67212ac40 (diff)
downloadgvfs-86cca680ec185d0a74fa948485d221bc9efe9181.tar.gz
afp: change g_vfs_afp_connection_get_server_info to g_vfs_afp_query_server_info
It's unnecessary to create a GVfsAfpConnection to retreive the server info
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gvfsafpconnection.c173
-rw-r--r--daemon/gvfsafpconnection.h6
-rw-r--r--daemon/gvfsafpserver.c4
3 files changed, 90 insertions, 93 deletions
diff --git a/daemon/gvfsafpconnection.c b/daemon/gvfsafpconnection.c
index 87c7f027..5c2312db 100644
--- a/daemon/gvfsafpconnection.c
+++ b/daemon/gvfsafpconnection.c
@@ -610,17 +610,6 @@ typedef enum
DSI_ATTENTION = 8
} DsiCommand;
-static void read_reply (GVfsAfpConnection *afp_connection);
-static void send_request (GVfsAfpConnection *afp_connection);
-
-static guint16
-get_request_id (GVfsAfpConnection *afp_connection)
-{
- GVfsAfpConnectionPrivate *priv = afp_connection->priv;
-
- return priv->request_id++;
-}
-
typedef enum
{
REQUEST_TYPE_COMMAND,
@@ -651,6 +640,73 @@ free_request_data (RequestData *req_data)
}
static void
+g_vfs_afp_connection_init (GVfsAfpConnection *afp_connection)
+{
+ GVfsAfpConnectionPrivate *priv;
+
+ afp_connection->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (afp_connection,
+ G_VFS_TYPE_AFP_CONNECTION,
+ GVfsAfpConnectionPrivate);
+
+ priv->addr = NULL;
+ priv->conn = NULL;
+ priv->request_id = 0;
+
+ priv->kRequestQuanta = -1;
+ priv->kServerReplayCacheSize = -1;
+
+ priv->request_queue = g_queue_new ();
+ priv->request_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
+ NULL, (GDestroyNotify)free_request_data);
+
+ priv->send_loop_running = FALSE;
+ priv->read_loop_running = FALSE;
+}
+
+static void
+g_vfs_afp_connection_finalize (GObject *object)
+{
+ GVfsAfpConnection *afp_connection = (GVfsAfpConnection *)object;
+ GVfsAfpConnectionPrivate *priv = afp_connection->priv;
+
+ if (priv->addr)
+ g_object_unref (priv->addr);
+
+ if (priv->conn)
+ g_object_unref (priv->conn);
+
+ G_OBJECT_CLASS (g_vfs_afp_connection_parent_class)->finalize (object);
+}
+
+static void
+g_vfs_afp_connection_class_init (GVfsAfpConnectionClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GVfsAfpConnectionPrivate));
+
+ object_class->finalize = g_vfs_afp_connection_finalize;
+
+ signals[ATTENTION] =
+ g_signal_new ("attention",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+ 0, NULL, NULL, g_cclosure_marshal_VOID__UINT,
+ G_TYPE_NONE, 1, G_TYPE_UINT);
+}
+
+static void read_reply (GVfsAfpConnection *afp_connection);
+static void send_request (GVfsAfpConnection *afp_connection);
+
+static guint16
+get_request_id (GVfsAfpConnection *afp_connection)
+{
+ GVfsAfpConnectionPrivate *priv = afp_connection->priv;
+
+ return priv->request_id++;
+}
+
+static void
run_loop (GVfsAfpConnection *afp_connection)
{
GVfsAfpConnectionPrivate *priv = afp_connection->priv;
@@ -1538,13 +1594,25 @@ g_vfs_afp_connection_open (GVfsAfpConnection *afp_connection,
return TRUE;
}
+GVfsAfpConnection *
+g_vfs_afp_connection_new (GSocketConnectable *addr)
+{
+ GVfsAfpConnection *afp_connection;
+ GVfsAfpConnectionPrivate *priv;
+
+ afp_connection = g_object_new (G_VFS_TYPE_AFP_CONNECTION, NULL);
+ priv = afp_connection->priv;
+
+ priv->addr = g_object_ref (addr);
+
+ return afp_connection;
+}
+
GVfsAfpReply *
-g_vfs_afp_connection_get_server_info (GVfsAfpConnection *afp_connection,
- GCancellable *cancellable,
- GError **error)
+g_vfs_afp_query_server_info (GSocketConnectable *addr,
+ GCancellable *cancellable,
+ GError **error)
{
- GVfsAfpConnectionPrivate *priv = afp_connection->priv;
-
GSocketClient *client;
GIOStream *conn;
gboolean res;
@@ -1552,7 +1620,7 @@ g_vfs_afp_connection_get_server_info (GVfsAfpConnection *afp_connection,
char *data;
client = g_socket_client_new ();
- conn = G_IO_STREAM (g_socket_client_connect (client, priv->addr, cancellable, error));
+ conn = G_IO_STREAM (g_socket_client_connect (client, addr, cancellable, error));
g_object_unref (client);
if (!conn)
@@ -1579,74 +1647,3 @@ g_vfs_afp_connection_get_server_info (GVfsAfpConnection *afp_connection,
return g_vfs_afp_reply_new (dsi_header.errorCode, data,
dsi_header.totalDataLength, TRUE);
}
-
-GVfsAfpConnection *
-g_vfs_afp_connection_new (GSocketConnectable *addr)
-{
- GVfsAfpConnection *afp_connection;
- GVfsAfpConnectionPrivate *priv;
-
- afp_connection = g_object_new (G_VFS_TYPE_AFP_CONNECTION, NULL);
- priv = afp_connection->priv;
-
- priv->addr = g_object_ref (addr);
-
- return afp_connection;
-}
-
-static void
-g_vfs_afp_connection_init (GVfsAfpConnection *afp_connection)
-{
- GVfsAfpConnectionPrivate *priv;
-
- afp_connection->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (afp_connection,
- G_VFS_TYPE_AFP_CONNECTION,
- GVfsAfpConnectionPrivate);
-
- priv->addr = NULL;
- priv->conn = NULL;
- priv->request_id = 0;
-
- priv->kRequestQuanta = -1;
- priv->kServerReplayCacheSize = -1;
-
- priv->request_queue = g_queue_new ();
- priv->request_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- NULL, (GDestroyNotify)free_request_data);
-
- priv->send_loop_running = FALSE;
- priv->read_loop_running = FALSE;
-}
-
-static void
-g_vfs_afp_connection_finalize (GObject *object)
-{
- GVfsAfpConnection *afp_connection = (GVfsAfpConnection *)object;
- GVfsAfpConnectionPrivate *priv = afp_connection->priv;
-
- if (priv->addr)
- g_object_unref (priv->addr);
-
- if (priv->conn)
- g_object_unref (priv->conn);
-
- G_OBJECT_CLASS (g_vfs_afp_connection_parent_class)->finalize (object);
-}
-
-static void
-g_vfs_afp_connection_class_init (GVfsAfpConnectionClass *klass)
-{
- GObjectClass* object_class = G_OBJECT_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (GVfsAfpConnectionPrivate));
-
- object_class->finalize = g_vfs_afp_connection_finalize;
-
- signals[ATTENTION] =
- g_signal_new ("attention",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL, g_cclosure_marshal_VOID__UINT,
- G_TYPE_NONE, 1, G_TYPE_UINT);
-}
-
diff --git a/daemon/gvfsafpconnection.h b/daemon/gvfsafpconnection.h
index 8e4ed0ff..d02b1f80 100644
--- a/daemon/gvfsafpconnection.h
+++ b/daemon/gvfsafpconnection.h
@@ -345,12 +345,12 @@ struct _GVfsAfpConnection
GType g_vfs_afp_connection_get_type (void) G_GNUC_CONST;
-GVfsAfpConnection* g_vfs_afp_connection_new (GSocketConnectable *addr);
-
-GVfsAfpReply* g_vfs_afp_connection_get_server_info (GVfsAfpConnection *afp_connection,
+GVfsAfpReply* g_vfs_afp_query_server_info (GSocketConnectable *addr,
GCancellable *cancellable,
GError **error);
+GVfsAfpConnection* g_vfs_afp_connection_new (GSocketConnectable *addr);
+
gboolean g_vfs_afp_connection_open (GVfsAfpConnection *afp_connection,
GCancellable *cancellable,
GError **error);
diff --git a/daemon/gvfsafpserver.c b/daemon/gvfsafpserver.c
index 58456645..6ecd18e7 100644
--- a/daemon/gvfsafpserver.c
+++ b/daemon/gvfsafpserver.c
@@ -724,8 +724,8 @@ get_server_info (GVfsAfpServer *afp_serv,
guint8 count;
guint i;
- reply = g_vfs_afp_connection_get_server_info (afp_serv->conn, cancellable,
- error);
+ reply = g_vfs_afp_query_server_info (G_SOCKET_CONNECTABLE (afp_serv->addr),
+ cancellable, error);
if (!reply)
return FALSE;