Give CamelNetworkService a private structure.
authorMatthew Barnes <mbarnes@redhat.com>
Thu, 21 Feb 2013 17:08:30 +0000 (12:08 -0500)
committerMatthew Barnes <mbarnes@redhat.com>
Thu, 21 Feb 2013 17:28:15 +0000 (12:28 -0500)
CamelNetworkService will do its own networking monitoring.

The interface is initialized during CamelService construction.

camel/camel-network-service.c
camel/camel-service.c

index fbf4392..df4e326 100644 (file)
 
 #include <camel/camel-tcp-stream-ssl.h>
 
+#define PRIVATE_KEY "CamelNetworkService:private"
+
+#define CAMEL_NETWORK_SERVICE_GET_PRIVATE(obj) \
+       (g_object_get_data (G_OBJECT (obj), PRIVATE_KEY))
+
+typedef struct _CamelNetworkServicePrivate CamelNetworkServicePrivate;
+
+struct _CamelNetworkServicePrivate {
+       gint placeholder;
+};
+
+/* Forward Declarations */
+void           camel_network_service_init      (CamelNetworkService *service);
+
 G_DEFINE_INTERFACE (
        CamelNetworkService,
        camel_network_service,
        CAMEL_TYPE_SERVICE)
 
+static CamelNetworkServicePrivate *
+network_service_private_new (CamelNetworkService *service)
+{
+       return g_slice_new0 (CamelNetworkServicePrivate);
+}
+
+static void
+network_service_private_free (CamelNetworkServicePrivate *priv)
+{
+       g_slice_free (CamelNetworkServicePrivate, priv);
+}
+
 static CamelStream *
 network_service_connect_sync (CamelNetworkService *service,
                               GCancellable *cancellable,
@@ -130,6 +156,20 @@ camel_network_service_default_init (CamelNetworkServiceInterface *interface)
        interface->connect_sync = network_service_connect_sync;
 }
 
+void
+camel_network_service_init (CamelNetworkService *service)
+{
+       /* This is called from CamelService during instance
+        * construction.  It is not part of the public API. */
+
+       g_return_if_fail (CAMEL_IS_NETWORK_SERVICE (service));
+
+       g_object_set_data_full (
+               G_OBJECT (service), PRIVATE_KEY,
+               network_service_private_new (service),
+               (GDestroyNotify) network_service_private_free);
+}
+
 /**
  * camel_network_service_get_service_name:
  * @service: a #CamelNetworkService
index b63ba9f..c34c07c 100644 (file)
@@ -38,6 +38,7 @@
 #include "camel-debug.h"
 #include "camel-enumtypes.h"
 #include "camel-local-settings.h"
+#include "camel-network-service.h"
 #include "camel-network-settings.h"
 #include "camel-operation.h"
 #include "camel-service.h"
@@ -112,6 +113,7 @@ enum {
 };
 
 /* Forward Declarations */
+void camel_network_service_init (CamelNetworkService *service);
 static void camel_service_initable_init (GInitableIface *interface);
 
 G_DEFINE_ABSTRACT_TYPE_WITH_CODE (
@@ -704,6 +706,10 @@ service_constructed (GObject *object)
        service->priv->user_cache_dir = g_build_filename (base_dir, uid, NULL);
 
        g_object_unref (session);
+
+       /* The CamelNetworkService interface needs initialization. */
+       if (CAMEL_IS_NETWORK_SERVICE (service))
+               camel_network_service_init (CAMEL_NETWORK_SERVICE (service));
 }
 
 static gchar *