CamelIMAPXServer: added untagged response handler registration API function
authorChristian Hilberg <chilberg@src.gnome.org>
Thu, 14 Jun 2012 16:47:41 +0000 (18:47 +0200)
committerMatthew Barnes <mbarnes@redhat.com>
Tue, 26 Jun 2012 15:20:28 +0000 (11:20 -0400)
* register new untagged response handlers with this function
* can also be used to replace existing handlers
  (think twice before doing that), while keeping track
  of the original handler function

camel/camel-imapx-server.c
camel/camel-imapx-server.h

index 20abae1..e60d0e9 100644 (file)
@@ -6963,3 +6963,50 @@ camel_imapx_server_get_job_queue_info (CamelIMAPXServer *is)
 
        return jinfo;
 }
+
+/**
+ * camel_imapx_server_register_untagged_handler:
+ * @is: a #CamelIMAPXServer instance
+ * @untagged_response: a string representation of the IMAP
+ *                     untagged response code. Must be
+ *                     all-uppercase with underscores allowed
+ *                     (see RFC 3501)
+ * @desc: a #CamelIMAPXUntaggedRespHandlerDesc handler description
+ *        structure. The descriptor structure is expected to
+ *        remain stable over the lifetime of the #CamelIMAPXServer
+ *        instance it was registered with. It is the responsibility
+ *        of the caller to ensure this
+ *
+ * Register a new handler function for IMAP untagged responses.
+ * Pass in a NULL descriptor to delete an existing handler (the
+ * untagged response will remain known, but will no longer be acted
+ * upon if the handler is deleted). The return value is intended
+ * to be used in cases where e.g. an extension to existing handler
+ * code is implemented with just some new code to be run before
+ * or after the original handler code
+ *
+ * Returns: the #CamelIMAPXUntaggedRespHandlerDesc previously
+ *          registered for this untagged response, if any,
+ *          NULL otherwise.
+ *
+ * Since: 3.6
+ */
+const CamelIMAPXUntaggedRespHandlerDesc*
+camel_imapx_server_register_untagged_handler (CamelIMAPXServer *is,
+                                              const gchar *untagged_response,
+                                              const CamelIMAPXUntaggedRespHandlerDesc *desc)
+{
+       CamelIMAPXServerPrivate *priv = NULL;
+       const CamelIMAPXUntaggedRespHandlerDesc *previous = NULL;
+
+       g_assert (CAMEL_IS_IMAPX_SERVER (is));
+       g_assert (untagged_response != NULL);
+       /* desc may be NULL */
+
+       priv = CAMEL_IMAPX_SERVER_GET_PRIVATE (is);
+
+       previous = replace_untagged_descriptor (priv->untagged_handlers,
+                                               untagged_response,
+                                               desc);
+       return previous;
+}
index 1d9d152..12ba7fd 100644 (file)
@@ -244,6 +244,13 @@ struct _IMAPXJobQueueInfo *
                camel_imapx_server_get_job_queue_info
                                                (CamelIMAPXServer *is);
 
+
+const CamelIMAPXUntaggedRespHandlerDesc*
+               camel_imapx_server_register_untagged_handler
+                                               (CamelIMAPXServer *is,
+                                                const gchar *untagged_response,
+                                                const CamelIMAPXUntaggedRespHandlerDesc *desc);
+
 G_END_DECLS
 
 #endif /* CAMEL_IMAPX_SERVER_H */