[evolution-data-server/wip/camel-more-gobject] Make ServiceAuthType a boxed type.



commit c86368fac381bd61703ac25e9f805930ec94925d
Author: Corentin Noël <corentin elementary io>
Date:   Wed Oct 26 21:44:53 2016 +0200

    Make ServiceAuthType a boxed type.

 src/camel/camel-service.c |   37 +++++++++++++++++++++++++++++++++++++
 src/camel/camel-service.h |    5 +++++
 2 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/src/camel/camel-service.c b/src/camel/camel-service.c
index cd6e681..d996f54 100644
--- a/src/camel/camel-service.c
+++ b/src/camel/camel-service.c
@@ -121,6 +121,7 @@ static void service_task_dispatch           (CamelService *service,
 G_DEFINE_ABSTRACT_TYPE_WITH_CODE (
        CamelService, camel_service, CAMEL_TYPE_OBJECT,
        G_IMPLEMENT_INTERFACE (G_TYPE_INITABLE, camel_service_initable_init))
+G_DEFINE_BOXED_TYPE (CamelServiceAuthType, camel_service_auth_type, camel_service_auth_type_copy, 
camel_service_auth_type_free);
 
 static void
 async_context_free (AsyncContext *async_context)
@@ -2378,3 +2379,39 @@ camel_service_query_auth_types_finish (CamelService *service,
        return g_task_propagate_pointer (G_TASK (result), error);
 }
 
+/**
+ * camel_service_auth_type_free:
+ * @service_auth_type: an #CamelServiceAuthType
+ *
+ * Frees the @service_auth_type struct and its contents.
+ **/
+void
+camel_service_auth_type_free (CamelServiceAuthType *service_auth_type)
+{
+       if (!service_auth_type)
+               return;
+
+       g_free (service_auth_type->name);
+       g_free (service_auth_type->description);
+       g_free (service_auth_type->authproto);
+       g_free (service_auth_type);
+}
+
+/**
+ * camel_service_auth_type_copy:
+ * @service_auth_type: an #CamelServiceAuthType
+ *
+ * Copies the @service_auth_type struct.
+ * Returns: (transfer full): the copy of @service_auth_type
+ **/
+CamelServiceAuthType *
+camel_service_auth_type_copy           (const CamelServiceAuthType* service_auth_type)
+{
+       CamelServiceAuthType *new_service_auth_type = g_new0 (CamelServiceAuthType, 1);
+       new_service_auth_type->name = g_strdup (service_auth_type->name);
+       new_service_auth_type->description = g_strdup (service_auth_type->description);
+       new_service_auth_type->authproto = g_strdup (service_auth_type->authproto);
+       new_service_auth_type->need_password = service_auth_type->need_password;
+
+       return new_service_auth_type;
+}
diff --git a/src/camel/camel-service.h b/src/camel/camel-service.h
index 5dd70f7..ed9c06b 100644
--- a/src/camel/camel-service.h
+++ b/src/camel/camel-service.h
@@ -51,6 +51,8 @@
 #define CAMEL_SERVICE_GET_CLASS(obj) \
        (G_TYPE_INSTANCE_GET_CLASS \
        ((obj), CAMEL_TYPE_SERVICE, CamelServiceClass))
+#define CAMEL_TYPE_SERVICE_AUTH_TYPE \
+       (camel_service_auth_type_get_type ())
 
 /**
  * CAMEL_SERVICE_ERROR:
@@ -216,6 +218,9 @@ GList *             camel_service_query_auth_types_finish
                                                 GAsyncResult *result,
                                                 GError **error);
 
+GType                                  camel_service_auth_type_get_type        (void);
+CamelServiceAuthType*  camel_service_auth_type_copy            (const CamelServiceAuthType* 
service_auth_type);
+void                                   camel_service_auth_type_free            (CamelServiceAuthType* 
service_auth_type);
 G_END_DECLS
 
 #endif /* CAMEL_SERVICE_H */


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