From: Matthew Barnes Date: Thu, 21 Feb 2013 17:08:30 +0000 (-0500) Subject: Give CamelNetworkService a private structure. X-Git-Tag: upstream/3.7.91~108 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69282509f57837e7b8b20b9a8703a854c7fccf9d;p=platform%2Fupstream%2Fevolution-data-server.git Give CamelNetworkService a private structure. CamelNetworkService will do its own networking monitoring. The interface is initialized during CamelService construction. --- diff --git a/camel/camel-network-service.c b/camel/camel-network-service.c index fbf4392..df4e326 100644 --- a/camel/camel-network-service.c +++ b/camel/camel-network-service.c @@ -29,11 +29,37 @@ #include +#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 diff --git a/camel/camel-service.c b/camel/camel-service.c index b63ba9f..c34c07c 100644 --- a/camel/camel-service.c +++ b/camel/camel-service.c @@ -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 *