[evolution-data-server/gnome-3-8] IMAPX: Add macros for checking server capabilities.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-8] IMAPX: Add macros for checking server capabilities.
- Date: Wed, 8 May 2013 17:42:15 +0000 (UTC)
commit cff0347cdd749e9a0f6f874fc02674b73439180c
Author: Matthew Barnes <mbarnes redhat com>
Date: Wed May 8 12:20:11 2013 -0400
IMAPX: Add macros for checking server capabilities.
These just read better and are more compact.
CAMEL_IMAPX_HAVE_CAPABILITY(cinfo, capa)
CAMEL_IMAPX_LACK_CAPABILITY(cinfo, capa)
Both macros evaluate to FALSE if 'cinfo' is NULL.
(cherry picked from commit 6f935fd146476048b80b1f42e5176a587dc106d4)
camel/camel-imapx-command.c | 2 +-
camel/camel-imapx-server.c | 12 ++++++------
camel/camel-imapx-store.c | 4 ++--
camel/camel-imapx-utils.h | 8 ++++++++
4 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/camel/camel-imapx-command.c b/camel/camel-imapx-command.c
index 0226db6..bd42ee7 100644
--- a/camel/camel-imapx-command.c
+++ b/camel/camel-imapx-command.c
@@ -504,7 +504,7 @@ camel_imapx_command_add_part (CamelIMAPXCommand *ic,
if (type & CAMEL_IMAPX_COMMAND_LITERAL_PLUS) {
g_string_append_c (buffer, '{');
g_string_append_printf (buffer, "%u", ob_size);
- if (ic->is->cinfo && ic->is->cinfo->capa & IMAPX_CAPABILITY_LITERALPLUS) {
+ if (CAMEL_IMAPX_HAVE_CAPABILITY (ic->is->cinfo, LITERALPLUS)) {
g_string_append_c (buffer, '+');
} else {
type &= ~CAMEL_IMAPX_COMMAND_LITERAL_PLUS;
diff --git a/camel/camel-imapx-server.c b/camel/camel-imapx-server.c
index 4421e9a..c5a79dd 100644
--- a/camel/camel-imapx-server.c
+++ b/camel/camel-imapx-server.c
@@ -3463,7 +3463,7 @@ imapx_in_idle (CamelIMAPXServer *is)
static gboolean
imapx_idle_supported (CamelIMAPXServer *is)
{
- return (is->cinfo && (is->cinfo->capa & IMAPX_CAPABILITY_IDLE) != 0 && is->use_idle);
+ return CAMEL_IMAPX_HAVE_CAPABILITY (is->cinfo, IDLE) && is->use_idle;
}
// end IDLE
@@ -4062,7 +4062,7 @@ imapx_connect_to_server (CamelIMAPXServer *is,
if (method == CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT) {
- if (is->cinfo && !(is->cinfo->capa & IMAPX_CAPABILITY_STARTTLS)) {
+ if (CAMEL_IMAPX_LACK_CAPABILITY (is->cinfo, STARTTLS)) {
g_set_error (
&local_error, CAMEL_ERROR,
CAMEL_ERROR_GENERIC,
@@ -4333,7 +4333,7 @@ imapx_reconnect (CamelIMAPXServer *is,
imapx_init_idle (is);
/* Fetch namespaces */
- if (is->cinfo && (is->cinfo->capa & IMAPX_CAPABILITY_NAMESPACE) != 0) {
+ if (CAMEL_IMAPX_HAVE_CAPABILITY (is->cinfo, NAMESPACE)) {
ic = camel_imapx_command_new (
is, "NAMESPACE", NULL, "NAMESPACE");
if (!imapx_command_run (is, ic, cancellable, error)) {
@@ -4344,7 +4344,7 @@ imapx_reconnect (CamelIMAPXServer *is,
camel_imapx_command_unref (ic);
}
- if (use_qresync && is->cinfo && (is->cinfo->capa & IMAPX_CAPABILITY_QRESYNC) != 0) {
+ if (use_qresync && CAMEL_IMAPX_HAVE_CAPABILITY (is->cinfo, QRESYNC)) {
ic = camel_imapx_command_new (
is, "ENABLE", NULL, "ENABLE CONDSTORE QRESYNC");
if (!imapx_command_run (is, ic, cancellable, error)) {
@@ -5784,7 +5784,7 @@ imapx_job_refresh_info_start (CamelIMAPXJob *job,
} else
#endif
{
- if (is->cinfo && (is->cinfo->capa & IMAPX_CAPABILITY_CONDSTORE) != 0)
+ if (CAMEL_IMAPX_HAVE_CAPABILITY (is->cinfo, CONDSTORE))
ic = camel_imapx_command_new (
is, "STATUS", NULL,
"STATUS %f (MESSAGES UNSEEN UIDVALIDITY UIDNEXT HIGHESTMODSEQ)",
folder);
@@ -8364,7 +8364,7 @@ camel_imapx_server_update_quota_info (CamelIMAPXServer *is,
g_return_val_if_fail (CAMEL_IS_IMAPX_SERVER (is), FALSE);
g_return_val_if_fail (folder_name != NULL, FALSE);
- if (is->cinfo && (is->cinfo->capa & IMAPX_CAPABILITY_QUOTA) == 0) {
+ if (CAMEL_IMAPX_LACK_CAPABILITY (is->cinfo, QUOTA)) {
g_set_error_literal (
error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
_("IMAP server does not support quotas"));
diff --git a/camel/camel-imapx-store.c b/camel/camel-imapx-store.c
index 885c275..6290628 100644
--- a/camel/camel-imapx-store.c
+++ b/camel/camel-imapx-store.c
@@ -953,7 +953,7 @@ add_folders_to_summary (CamelIMAPXStore *istore,
new_flags = (si->info.flags & (CAMEL_STORE_INFO_FOLDER_SUBSCRIBED |
CAMEL_STORE_INFO_FOLDER_CHECK_FOR_NEW)) |
(li->flags & ~CAMEL_STORE_INFO_FOLDER_SUBSCRIBED);
- if (server->cinfo && !(server->cinfo->capa & IMAPX_CAPABILITY_NAMESPACE))
+ if (CAMEL_IMAPX_LACK_CAPABILITY (server->cinfo, NAMESPACE))
istore->dir_sep = li->separator;
if (si->info.flags != new_flags) {
@@ -1080,7 +1080,7 @@ fetch_folders_for_namespaces (CamelIMAPXStore *istore,
if (sync)
flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST;
- if (server->cinfo && (server->cinfo->capa & IMAPX_CAPABILITY_LIST_EXTENDED) != 0)
+ if (CAMEL_IMAPX_HAVE_CAPABILITY (server->cinfo, LIST_EXTENDED))
list_ext = "RETURN (SUBSCRIBED)";
flags |= CAMEL_STORE_FOLDER_INFO_RECURSIVE;
diff --git a/camel/camel-imapx-utils.h b/camel/camel-imapx-utils.h
index 9099843..b83e0ad 100644
--- a/camel/camel-imapx-utils.h
+++ b/camel/camel-imapx-utils.h
@@ -156,6 +156,14 @@ void imapx_set_message_info_flags_for_new_message
void imapx_update_store_summary (CamelFolder *folder);
/* ********************************************************************** */
+
+/* Handy server capability test macros.
+ * Both return FALSE if capabilities are unknown. */
+#define CAMEL_IMAPX_HAVE_CAPABILITY(info, name) \
+ ((info) != NULL && ((info)->capa & IMAPX_CAPABILITY_##name) != 0)
+#define CAMEL_IMAPX_LACK_CAPABILITY(info, name) \
+ ((info) != NULL && ((info)->capa & IMAPX_CAPABILITY_##name) == 0)
+
enum {
IMAPX_CAPABILITY_IMAP4 = (1 << 0),
IMAPX_CAPABILITY_IMAP4REV1 = (1 << 1),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]