[evolution-data-server] IMAPX: Add camel_imapx_server_ref_input_stream().



commit d9550d32657d2807bfbac9c922586ca68910d1f5
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Jan 23 07:01:25 2014 -0500

    IMAPX: Add camel_imapx_server_ref_input_stream().
    
    Returns the GInputStream for a CamelIMAPXServer, which is owned by
    either a GTcpConnection or a GSubprocess.
    
    The function doesn't actually return anything yet; just roughing in
    the API.  Will make it work in subsequent commits.

 camel/providers/imapx/camel-imapx-server.c |   35 ++++++++++++++++++++++++++++
 camel/providers/imapx/camel-imapx-server.h |    2 +
 docs/reference/camel/camel-sections.txt    |    1 +
 3 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c
index 7369c92..97a5c7b 100644
--- a/camel/providers/imapx/camel-imapx-server.c
+++ b/camel/providers/imapx/camel-imapx-server.c
@@ -335,6 +335,7 @@ struct _CamelIMAPXServerPrivate {
 
        /* The 'stream_lock' also guards the GSubprocess. */
        CamelIMAPXStream *stream;
+       GInputStream *input_stream;
 #if GLIB_CHECK_VERSION(2,39,0)
        GSubprocess *subprocess;
 #endif
@@ -8021,6 +8022,38 @@ camel_imapx_server_ref_stream (CamelIMAPXServer *server)
 }
 
 /**
+ * camel_imapx_server_ref_input_stream:
+ * @is: a #CamelIMAPXServer
+ *
+ * Returns the #GInputStream for @is, which is owned by either a
+ * #GTcpConnection or a #GSubprocess.  If the #CamelIMAPXServer is not
+ * yet connected or has lost its connection, the function returns %NULL.
+ *
+ * The returned #GInputStream is referenced for thread-safety and must
+ * be unreferenced with g_object_unref() when finished with it.
+ *
+ * Returns: a #GInputStream, or %NULL
+ *
+ * Since: 3.12
+ **/
+GInputStream *
+camel_imapx_server_ref_input_stream (CamelIMAPXServer *is)
+{
+       GInputStream *input_stream = NULL;
+
+       g_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), NULL);
+
+       g_mutex_lock (&is->priv->stream_lock);
+
+       if (is->priv->input_stream != NULL)
+               input_stream = g_object_ref (is->priv->input_stream);
+
+       g_mutex_unlock (&is->priv->stream_lock);
+
+       return input_stream;
+}
+
+/**
  * camel_imapx_server_ref_namespaces:
  * @is: a #CamelIMAPXServer
  *
@@ -8183,6 +8216,8 @@ imapx_disconnect (CamelIMAPXServer *is)
                is->priv->stream = NULL;
        }
 
+       g_clear_object (&is->priv->input_stream);
+
        g_mutex_unlock (&is->priv->stream_lock);
 
        g_mutex_lock (&is->priv->select_lock);
diff --git a/camel/providers/imapx/camel-imapx-server.h b/camel/providers/imapx/camel-imapx-server.h
index c53e9bb..33eb522 100644
--- a/camel/providers/imapx/camel-imapx-server.h
+++ b/camel/providers/imapx/camel-imapx-server.h
@@ -145,6 +145,8 @@ struct _CamelIMAPXSettings *
                camel_imapx_server_ref_settings (CamelIMAPXServer *is);
 CamelIMAPXStream *
                camel_imapx_server_ref_stream   (CamelIMAPXServer *is);
+GInputStream * camel_imapx_server_ref_input_stream
+                                               (CamelIMAPXServer *is);
 CamelIMAPXNamespaceResponse *
                camel_imapx_server_ref_namespaces
                                                (CamelIMAPXServer *is);
diff --git a/docs/reference/camel/camel-sections.txt b/docs/reference/camel/camel-sections.txt
index 0c6a9ee..055ebdb 100644
--- a/docs/reference/camel/camel-sections.txt
+++ b/docs/reference/camel/camel-sections.txt
@@ -3570,6 +3570,7 @@ camel_imapx_server_new
 camel_imapx_server_ref_store
 camel_imapx_server_ref_settings
 camel_imapx_server_ref_stream
+camel_imapx_server_ref_input_stream
 camel_imapx_server_ref_namespaces
 camel_imapx_server_ref_mailbox
 camel_imapx_server_ref_selected


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