[evolution-kolab/ek-wip-acl] libekolab: added command runner utils for extended IMAPX
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab/ek-wip-acl] libekolab: added command runner utils for extended IMAPX
- Date: Fri, 28 Sep 2012 13:40:24 +0000 (UTC)
commit 70b208c784e4c7c9ff00d5d7dc6d4fd2833cf82e
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Fri Sep 28 15:23:22 2012 +0200
libekolab: added command runner utils for extended IMAPX
* new utility function takes the IMAP command token
and a command string and runs the IMAP command
synchronously
* the function has a local static mutex so it can be
run safely in multiple threads (as far as the Camel
functions called therein permit for multiple thread
contexts)
src/libekolab/Makefile.am | 2 +
src/libekolab/camel-imapx-extd-utils.c | 71 ++++++++++++++++++++++++++++++++
src/libekolab/camel-imapx-extd-utils.h | 52 +++++++++++++++++++++++
3 files changed, 125 insertions(+), 0 deletions(-)
---
diff --git a/src/libekolab/Makefile.am b/src/libekolab/Makefile.am
index 0e3345f..23446d7 100644
--- a/src/libekolab/Makefile.am
+++ b/src/libekolab/Makefile.am
@@ -41,6 +41,7 @@ libekolab_la_SOURCES = \
camel-imapx-extd-server-metadata.c \
camel-imapx-extd-server.c \
camel-imapx-extd-store.c \
+ camel-imapx-extd-utils.c \
camel-imapx-acl.c \
camel-imapx-metadata.c \
kolab-data-folder-metadata.c \
@@ -61,6 +62,7 @@ noinst_HEADERS = \
camel-imapx-extd-server.h \
camel-imapx-extd-store.h \
camel-imapx-extd-store-friend.h \
+ camel-imapx-extd-utils.h \
camel-imapx-acl.h \
camel-imapx-metadata.h \
kolab-backend-types.h \
diff --git a/src/libekolab/camel-imapx-extd-utils.c b/src/libekolab/camel-imapx-extd-utils.c
new file mode 100644
index 0000000..7a7b07b
--- /dev/null
+++ b/src/libekolab/camel-imapx-extd-utils.c
@@ -0,0 +1,71 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ * camel-imapx-extd-utils.c
+ *
+ * 2012-09-28, 13:44:28
+ * Copyright 2012, Christian Hilberg
+ * <hilberg kernelconcepts de>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with main.c; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
+ */
+
+/*----------------------------------------------------------------------------*/
+
+#include "camel-imapx-extd-utils.h"
+
+/*----------------------------------------------------------------------------*/
+
+gboolean
+camel_imapx_extd_utils_command_run (CamelIMAPXServer *is,
+ const gchar *cmd_token,
+ const gchar *cmd,
+ GCancellable *cancellable,
+ GError **err)
+{
+ static GMutex runner_lock;
+ CamelIMAPXCommand *ic = NULL;
+ GError *tmp_err = NULL;
+ gboolean ok = FALSE;
+
+ g_assert (CAMEL_IS_IMAPX_SERVER (is));
+ g_return_val_if_fail (cmd_token != NULL, FALSE);
+ g_return_val_if_fail (cmd != NULL, FALSE);
+ /* cancellable may be NULL */
+ g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
+
+ g_mutex_lock (&runner_lock);
+
+ ic = camel_imapx_command_new (is, cmd_token, NULL, cmd);
+ /* TODO set some job details like priority? */
+
+ /* run IMAP command */
+ ok = camel_imapx_server_command_run (is,
+ ic,
+ cancellable,
+ &tmp_err);
+ camel_imapx_command_unref (ic);
+
+ if (! ok)
+ g_propagate_error (err, tmp_err);
+
+ g_mutex_unlock (&runner_lock);
+
+ return ok;
+}
+
+/*----------------------------------------------------------------------------*/
+
diff --git a/src/libekolab/camel-imapx-extd-utils.h b/src/libekolab/camel-imapx-extd-utils.h
new file mode 100644
index 0000000..f0855e6
--- /dev/null
+++ b/src/libekolab/camel-imapx-extd-utils.h
@@ -0,0 +1,52 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/***************************************************************************
+ * camel-imapx-extd-utils.h
+ *
+ * 2012-09-28, 13:44:28
+ * Copyright 2012, Christian Hilberg
+ * <hilberg kernelconcepts de>
+ ****************************************************************************/
+
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with main.c; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
+ */
+
+/*----------------------------------------------------------------------------*/
+
+#ifndef _CAMEL_IMAPX_EXTD_UTILS_H_
+#define _CAMEL_IMAPX_EXTD_UTILS_H_
+
+/*----------------------------------------------------------------------------*/
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+
+#include <libekolabutil/camel-system-headers.h>
+
+/*----------------------------------------------------------------------------*/
+
+gboolean
+camel_imapx_extd_utils_command_run (CamelIMAPXServer *is,
+ const gchar *cmd_token,
+ const gchar *cmd,
+ GCancellable *cancellable,
+ GError **err);
+
+/*----------------------------------------------------------------------------*/
+
+#endif /* CAMEL_IMAPX_EXTD_UTILS_H_ */
+
+/*----------------------------------------------------------------------------*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]