[wing/wip/pipe-name] named-pipe: add pipe-name property to the connection



commit 614f26997569d154a80fe0d92ebbf2b4b917d60a
Author: Ignacio Casal Quinteiro <ignacio casal nice-software com>
Date:   Mon Sep 12 13:15:14 2016 +0200

    named-pipe: add pipe-name property to the connection

 tests/named-pipe.c             |    1 +
 wing/wingnamedpipeclient.c     |    1 +
 wing/wingnamedpipeconnection.c |   36 ++++++++++++++++++++++++++++++++++++
 wing/wingnamedpipeconnection.h |    3 +++
 wing/wingnamedpipelistener.c   |    3 +++
 5 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/tests/named-pipe.c b/tests/named-pipe.c
index 897515f..0fc0c78 100644
--- a/tests/named-pipe.c
+++ b/tests/named-pipe.c
@@ -174,6 +174,7 @@ test_connect_sync (void)
                                                &error);
 
   g_assert_no_error (error);
+  g_assert_cmpstr ("\\\\.\\pipe\\gtest-connect-sync", ==, wing_named_pipe_connection_get_pipe_name 
(connection));
 
   g_object_unref (client);
   g_object_unref (listener);
diff --git a/wing/wingnamedpipeclient.c b/wing/wingnamedpipeclient.c
index 144b282..d013333 100644
--- a/wing/wingnamedpipeclient.c
+++ b/wing/wingnamedpipeclient.c
@@ -196,6 +196,7 @@ wing_named_pipe_client_connect (WingNamedPipeClient  *client,
           goto end;
 
       connection = g_object_new (WING_TYPE_NAMED_PIPE_CONNECTION,
+                                 "pipe-name", pipe_name,
                                  "handle", handle,
                                  "close-handle", TRUE,
                                  NULL);
diff --git a/wing/wingnamedpipeconnection.c b/wing/wingnamedpipeconnection.c
index 0e90998..a76d350 100644
--- a/wing/wingnamedpipeconnection.c
+++ b/wing/wingnamedpipeconnection.c
@@ -48,6 +48,7 @@ struct _WingNamedPipeConnection
 {
   GIOStream parent;
 
+  gchar *pipe_name;
   void *handle;
   gboolean close_handle;
 
@@ -65,6 +66,7 @@ typedef struct _WingNamedPipeConnectionClass WingNamedPipeConnectionClass;
 enum
 {
   PROP_0,
+  PROP_PIPE_NAME,
   PROP_HANDLE,
   PROP_CLOSE_HANDLE
 };
@@ -76,6 +78,8 @@ wing_named_pipe_connection_finalize (GObject *object)
 {
   WingNamedPipeConnection *connection = WING_NAMED_PIPE_CONNECTION (object);
 
+  g_free (connection->pipe_name);
+
   if (connection->input_stream)
     g_object_unref (connection->input_stream);
 
@@ -98,6 +102,10 @@ wing_named_pipe_connection_set_property (GObject      *object,
 
   switch (prop_id)
     {
+    case PROP_PIPE_NAME:
+      connection->pipe_name = g_value_dup_string (value);
+      break;
+
     case PROP_HANDLE:
       connection->handle = g_value_get_pointer (value);
       if (connection->handle != NULL && connection->handle != INVALID_HANDLE_VALUE)
@@ -127,6 +135,10 @@ wing_named_pipe_connection_get_property (GObject    *object,
 
   switch (prop_id)
     {
+    case PROP_PIPE_NAME:
+      g_value_set_string (value, connection->pipe_name);
+      break;
+
     case PROP_HANDLE:
       g_value_set_pointer (value, connection->handle);
       break;
@@ -171,6 +183,22 @@ wing_named_pipe_connection_class_init (WingNamedPipeConnectionClass *class)
   io_class->get_output_stream = wing_named_pipe_connection_get_output_stream;
 
   /**
+   * WingNamedPipeConnection:pipe-name:
+   *
+   * The name of the pipe.
+   *
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_PIPE_NAME,
+                                   g_param_spec_string ("pipe-name",
+                                                        "Pipe name",
+                                                        "The pipe name",
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_STRINGS));
+
+  /**
    * WingNamedPipeConnection:handle:
    *
    * The handle for the connection.
@@ -209,3 +237,11 @@ static void
 wing_named_pipe_connection_init (WingNamedPipeConnection *stream)
 {
 }
+
+const gchar *
+wing_named_pipe_connection_get_pipe_name (WingNamedPipeConnection *connection)
+{
+  g_return_val_if_fail (WING_IS_NAMED_PIPE_CONNECTION (connection), NULL);
+
+  return connection->pipe_name;
+}
diff --git a/wing/wingnamedpipeconnection.h b/wing/wingnamedpipeconnection.h
index 7162dc2..e98f8de 100644
--- a/wing/wingnamedpipeconnection.h
+++ b/wing/wingnamedpipeconnection.h
@@ -34,6 +34,9 @@ typedef struct _WingNamedPipeConnection WingNamedPipeConnection;
 WING_AVAILABLE_IN_ALL
 GType                         wing_named_pipe_connection_get_type         (void) G_GNUC_CONST;
 
+WING_AVAILABLE_IN_ALL
+const gchar                  *wing_named_pipe_connection_get_pipe_name    (WingNamedPipeConnection 
*connection);
+
 G_END_DECLS
 
 #endif /* __WING_NAMED_PIPE_CONNECTION_H__ */
diff --git a/wing/wingnamedpipelistener.c b/wing/wingnamedpipelistener.c
index 4fe21a5..27422cb 100644
--- a/wing/wingnamedpipelistener.c
+++ b/wing/wingnamedpipelistener.c
@@ -285,6 +285,7 @@ connect_ready (HANDLE   handle,
                                  g_object_unref);
 
       connection = g_object_new (WING_TYPE_NAMED_PIPE_CONNECTION,
+                                 "pipe-name", pipe_data->pipe_name,
                                  "handle", pipe_data->handle,
                                  "close-handle", TRUE,
                                  NULL);
@@ -488,6 +489,7 @@ wing_named_pipe_listener_accept (WingNamedPipeListener  *listener,
   if (pipe_data != NULL)
     {
       connection = g_object_new (WING_TYPE_NAMED_PIPE_CONNECTION,
+                                 "pipe-name", pipe_data->pipe_name,
                                  "handle", pipe_data->handle,
                                  "close-handle", TRUE,
                                  NULL);
@@ -550,6 +552,7 @@ wing_named_pipe_listener_accept_async (WingNamedPipeListener *listener,
                                  g_object_unref);
 
       connection = g_object_new (WING_TYPE_NAMED_PIPE_CONNECTION,
+                                 "pipe-name", pipe_data->pipe_name,
                                  "handle", pipe_data->handle,
                                  "close-handle", FALSE,
                                  NULL);


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