#include <ws2tcpip.h>
#endif
-#define c(x) camel_imapx_debug(command, x)
-#define e(x) camel_imapx_debug(extra, x)
+#define c(...) camel_imapx_debug(command, __VA_ARGS__)
+#define e(...) camel_imapx_debug(extra, __VA_ARGS__)
#define CIF(x) ((CamelIMAPXFolder *)x)
ss->uids++;
- e(printf("uidset add '%s'\n", uid));
+ e("uidset add '%s'\n", uid);
if (ss->last == 0) {
- e(printf(" start\n"));
+ e(" start\n");
camel_imapx_command_add(ic, "%d", uidn);
ss->entries++;
ss->start = uidn;
} else {
if (ss->last != uidn-1) {
if (ss->last == ss->start) {
- e(printf(" ,next\n"));
+ e(" ,next\n");
camel_imapx_command_add(ic, ",%d", uidn);
ss->entries++;
} else {
- e(printf(" :range\n"));
+ e(" :range\n");
camel_imapx_command_add(ic, ":%d,%d", ss->last, uidn);
ss->entries+=2;
}
if ((ss->limit && ss->entries >= ss->limit)
|| (ss->total && ss->uids >= ss->total)) {
- e(printf(" done, %d entries, %d uids\n", ss->entries, ss->uids));
+ e(" done, %d entries, %d uids\n", ss->entries, ss->uids);
imapx_uidset_done (ss, ic);
return 1;
}
gchar *fname = NULL, *encoded = NULL;
const gchar *full_name;
- c(printf("adding command, fmt = '%s'\n", fmt));
+ c("adding command, fmt = '%s'\n", fmt);
p = fmt;
ps = fmt;
break;
case 'S': /* stream */
S = va_arg (ap, CamelStream *);
- c(printf("got stream '%p'\n", S));
+ c("got stream '%p'\n", S);
imapx_command_add_part (ic, CAMEL_IMAPX_COMMAND_STREAM, S);
break;
case 'D': /* datawrapper */
D = va_arg (ap, CamelDataWrapper *);
- c(printf("got data wrapper '%p'\n", D));
+ c("got data wrapper '%p'\n", D);
imapx_command_add_part (ic, CAMEL_IMAPX_COMMAND_DATAWRAPPER, D);
break;
case 'P': /* filename path */
P = va_arg (ap, gchar *);
- c(printf("got file path '%s'\n", P));
+ c("got file path '%s'\n", P);
imapx_command_add_part (ic, CAMEL_IMAPX_COMMAND_FILE, P);
break;
case 't': /* token */
break;
case 's': /* simple string */
s = va_arg (ap, gchar *);
- c(printf("got string '%s'\n", s));
+ c("got string '%s'\n", s);
output_string:
if (*s) {
guchar mask = imapx_is_mask (s);
case 'f': /* imap folder name */
folder = va_arg (ap, CamelFolder *);
full_name = camel_folder_get_full_name (folder);
- c(printf("got folder '%s'\n", full_name));
+ c("got folder '%s'\n", full_name);
parent_store = camel_folder_get_parent_store (folder);
fname = camel_imapx_store_summary_full_from_path (((CamelIMAPXStore *) parent_store)->summary, full_name);
if (fname) {
case 'u':
if (llong) {
l = va_arg (ap, glong);
- c(printf("got glong '%d'\n", (gint)l));
+ c("got glong '%d'\n", (gint)l);
memcpy (buffer, start, p-start);
buffer[p-start] = 0;
camel_stream_printf ((CamelStream *)ic->mem, buffer, l);
} else {
d = va_arg (ap, gint);
- c(printf("got gint '%d'\n", d));
+ c("got gint '%d'\n", d);
memcpy (buffer, start, p-start);
buffer[p-start] = 0;
camel_stream_printf ((CamelStream *)ic->mem, buffer, d);
byte_array = camel_stream_mem_get_byte_array (ic->mem);
- c(printf("completing command buffer is [%d] '%.*s'\n", byte_array->len, (gint)byte_array->len, byte_array->data));
+ c("completing command buffer is [%d] '%.*s'\n", byte_array->len, (gint)byte_array->len, byte_array->data);
if (byte_array->len > 0)
imapx_command_add_part (ic, CAMEL_IMAPX_COMMAND_SIMPLE, NULL);
g_static_rec_mutex_lock (&imap->ostream_lock);
- c(printf("Starting command (active=%d,%s) %c%05u %s\r\n", camel_dlist_length(&imap->active), imap->literal?" literal":"", imap->tagprefix, ic->tag, cp->data));
+ c("Starting command (active=%d,%s) %c%05u %s\r\n", camel_dlist_length(&imap->active), imap->literal?" literal":"", imap->tagprefix, ic->tag, cp->data);
if (!imap->stream || camel_stream_printf((CamelStream *)imap->stream, "%c%05u %s\r\n", imap->tagprefix, ic->tag, cp->data) == -1) {
g_set_error (
&ic->error, CAMEL_IMAPX_ERROR, 1,
return FALSE;
if (imapx_match_active_job (is, IMAPX_JOB_FETCH_NEW_MESSAGES|IMAPX_JOB_REFRESH_INFO, NULL)) {
- c(printf("Not yet sending duplicate fetch/refresh %s command\n", ic->name));
+ c("Not yet sending duplicate fetch/refresh %s command\n", ic->name);
return TRUE;
}
gint count = 0;
gint pri = -128;
- c(printf("** Starting next command\n"));
+ c("** Starting next command\n");
if (is->literal) {
- c(printf("* no; waiting for literal '%s'\n", is->literal->name));
+ c("* no; waiting for literal '%s'\n", is->literal->name);
return;
}
if (is->select_pending) {
- c(printf("-- Checking job queue for non-folder jobs\n"));
+ c("-- Checking job queue for non-folder jobs\n");
ic = (CamelIMAPXCommand *)is->queue.head;
nc = ic->next;
while (nc && is->literal == NULL && count < MAX_COMMANDS && ic->pri >= pri) {
- c(printf("-- %3d '%s'?\n", (gint)ic->pri, ic->name));
+ c("-- %3d '%s'?\n", (gint)ic->pri, ic->name);
if (!ic->select) {
- c(printf("--> starting '%s'\n", ic->name));
+ c("--> starting '%s'\n", ic->name);
pri = ic->pri;
camel_dlist_remove ((CamelDListNode *)ic);
imapx_command_start (is, ic);
if (count)
return;
- c(printf("* no, waiting for pending select '%s'\n", camel_folder_get_full_name (is->select_pending)));
+ c("* no, waiting for pending select '%s'\n", camel_folder_get_full_name (is->select_pending));
return;
}
pending and we can go ahead and send a new command
immediately. If it returns TRUE, we must wait. */
if (imapx_stop_idle (is, error)) {
- c(printf ("waiting for idle to stop \n"));
+ c("waiting for idle to stop \n");
return;
}
} else if (empty && !imapx_in_idle (is)) {
imapx_start_idle (is);
- c(printf ("starting idle \n"));
+ c("starting idle \n");
return;
}
}
ic = (CamelIMAPXCommand *)is->queue.head;
nc = ic->next;
if (nc == NULL) {
- c(printf("* no, no jobs\n"));
+ c("* no, no jobs\n");
return;
}
/* See if any queued jobs on this select first */
if (is->select_folder) {
- c(printf("- we're selected on '%s', current jobs?\n",
- camel_folder_get_full_name (is->select_folder)));
+ c("- we're selected on '%s', current jobs?\n",
+ camel_folder_get_full_name (is->select_folder));
for (ic = (CamelIMAPXCommand *)is->active.head;ic->next;ic=ic->next) {
- c(printf("- %3d '%s'\n", (gint)ic->pri, ic->name));
+ c("- %3d '%s'\n", (gint)ic->pri, ic->name);
if (ic->pri > pri)
pri = ic->pri;
count++;
if (count > MAX_COMMANDS) {
- c(printf("** too many jobs busy, waiting for results for now\n"));
+ c("** too many jobs busy, waiting for results for now\n");
return;
}
}
- c(printf("-- Checking job queue\n"));
+ c("-- Checking job queue\n");
count = 0;
ic = (CamelIMAPXCommand *)is->queue.head;
nc = ic->next;
while (nc && is->literal == NULL && count < MAX_COMMANDS && ic->pri >= pri) {
- c(printf("-- %3d '%s'?\n", (gint)ic->pri, ic->name));
+ c("-- %3d '%s'?\n", (gint)ic->pri, ic->name);
if (!ic->select || ((ic->select == is->select_folder) &&
!duplicate_fetch_or_refresh (is, ic))) {
- c(printf("--> starting '%s'\n", ic->name));
+ c("--> starting '%s'\n", ic->name);
pri = ic->pri;
camel_dlist_remove ((CamelDListNode *)ic);
imapx_command_start (is, ic);
/* If we need to select a folder for the first command, do it now, once
it is complete it will re-call us if it succeeded */
if (ic->select) {
- c(printf("Selecting folder '%s' for command '%s'(%p)\n",
- camel_folder_get_full_name (ic->select), ic->name, ic));
+ c("Selecting folder '%s' for command '%s'(%p)\n",
+ camel_folder_get_full_name (ic->select), ic->name, ic);
imapx_select (is, ic->select, FALSE, error);
} else {
pri = ic->pri;
while (nc && is->literal == NULL && count < MAX_COMMANDS && ic->pri >= pri) {
if (!ic->select || (ic->select == is->select_folder &&
!duplicate_fetch_or_refresh (is, ic))) {
- c(printf("* queueing job %3d '%s'\n", (gint)ic->pri, ic->name));
+ c("* queueing job %3d '%s'\n", (gint)ic->pri, ic->name);
pri = ic->pri;
camel_dlist_remove ((CamelDListNode *)ic);
imapx_command_start (is, ic);
camel_imapx_command_close (ic);
- c(printf("enqueue job '%.*s'\n", ((CamelIMAPXCommandPart *)ic->parts.head)->data_size, ((CamelIMAPXCommandPart *)ic->parts.head)->data));
+ c("enqueue job '%.*s'\n", ((CamelIMAPXCommandPart *)ic->parts.head)->data_size, ((CamelIMAPXCommandPart *)ic->parts.head)->data);
QUEUE_LOCK (is);
if (is->state == IMAPX_SHUTDOWN) {
- c(printf("refuse to queue job on disconnected server\n"));
+ c("refuse to queue job on disconnected server\n");
g_set_error (
&ic->error, CAMEL_IMAPX_ERROR, 1,
"Server disconnected");
gboolean lsub = FALSE;
struct _status_info *sinfo;
- e(printf("got untagged response\n"));
+ e("got untagged response\n");
id = 0;
tok = camel_imapx_stream_token (imap->stream, &token, &len, error);
if (tok < 0)
return -1;
}
- e(printf("Have token '%s' id %d\n", token, id));
+ e("Have token '%s' id %d\n", token, id);
p = token;
while ((c = *p))
*p++ = toupper((gchar) c);
imap->cinfo = imapx_parse_capability (imap->stream, error);
if (imap->cinfo == NULL)
return -1;
- c(printf("got capability flags %08x\n", imap->cinfo->capa));
+ c("got capability flags %08x\n", imap->cinfo->capa);
return 0;
case IMAPX_EXPUNGE: {
guint32 expunge = id;
if (job)
break;
- c(printf("expunged: %d\n", id));
+ c("expunged: %d\n", id);
if (imap->select_folder) {
gchar *uid = NULL;
return -1;
for (i = 0; i < uids->len; i++) {
gchar *uid = g_strdup_printf("%u", GPOINTER_TO_UINT(g_ptr_array_index (uids, i)));
- c(printf("vanished: %s\n", uid));
+ c("vanished: %s\n", uid);
imapx_expunge_uid_from_summary (imap, uid, unsolicited);
}
g_ptr_array_free (uids, FALSE);
return 0;
}
case IMAPX_EXISTS:
- c(printf("exists: %d\n", id));
+ c("exists: %d\n", id);
imap->exists = id;
if (imap->select_folder)
imapx_parse_flags (imap->stream, &flags, NULL, error);
- c(printf("flags: %08x\n", flags));
+ c("flags: %08x\n", flags);
break;
}
case IMAPX_FETCH: {
g_object_ref (imap->select_folder);
folder = imap->select_folder;
- c(printf("flag changed: %d\n", id));
+ c("flag changed: %d\n", id);
if (finfo->got & FETCH_UID) {
uid = finfo->uid;
} else {
/* This (UID + FLAGS for previously unknown message) might
happen during a SELECT (QRESYNC). We should use it. */
- c(printf("flags changed for unknown uid %s\n.", uid));
+ c("flags changed for unknown uid %s\n.", uid);
}
finfo->user_flags = NULL;
}
unsigned long long uidl = strtoull (mi->uid, NULL, 10);
if (uidl >= ifolder->uidnext_on_server) {
- c(printf("Updating unread count for new message %s\n", mi->uid));
+ c("Updating unread count for new message %s\n", mi->uid);
((CamelIMAPXFolder *)job->folder)->unread_on_server++;
} else {
- c(printf("Not updating unread count for new message %s\n", mi->uid));
+ c("Not updating unread count for new message %s\n", mi->uid);
}
}
// TODO: we want to make sure the names match?
if (job->u.list.flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) {
- c(printf("lsub: '%s' (%c)\n", linfo->name, linfo->separator));
+ c("lsub: '%s' (%c)\n", linfo->name, linfo->separator);
} else {
- c(printf("list: '%s' (%c)\n", linfo->name, linfo->separator));
+ c("list: '%s' (%c)\n", linfo->name, linfo->separator);
}
if (job && g_hash_table_lookup (job->u.list.folders, linfo->name) == NULL) {
break;
}
case IMAPX_RECENT:
- c(printf("recent: %d\n", id));
+ c("recent: %d\n", id);
imap->recent = id;
break;
case IMAPX_STATUS: {
gchar *path_name;
path_name = camel_imapx_store_summary_full_to_path (s, sinfo->name, ns->sep);
- c(printf("Got folder path '%s' for full '%s'\n", path_name, sinfo->name));
+ c("Got folder path '%s' for full '%s'\n", path_name, sinfo->name);
if (path_name) {
ifolder = (gpointer)camel_store_get_folder (imap->store, path_name, 0, error);
g_free (path_name);
ifolder->uidnext_on_server = sinfo->uidnext;
ifolder->uidvalidity_on_server = sinfo->uidvalidity;
} else {
- c(printf("Received STATUS for unknown folder '%s'\n", sinfo->name));
+ c("Received STATUS for unknown folder '%s'\n", sinfo->name);
}
g_free (sinfo->name);
guchar *token;
if (camel_imapx_stream_text (imap->stream, &token, NULL)) {
- c(printf("BYE: %s\n", token));
+ c("BYE: %s\n", token);
g_set_error (
error, CAMEL_IMAPX_ERROR, 1,
"IMAP server said BYE: %s", token);
return -1;
}
case IMAPX_PREAUTH:
- c(printf("preauthenticated\n"));
+ c("preauthenticated\n");
if (imap->state < IMAPX_AUTHENTICATED)
imap->state = IMAPX_AUTHENTICATED;
/* fall through... */
return -1;
switch (sinfo->condition) {
case IMAPX_CLOSED:
- c(printf("previously selected folder is now closed\n"));
+ c("previously selected folder is now closed\n");
if (imap->select_pending && !imap->select_folder) {
imap->select_folder = imap->select_pending;
}
break;
case IMAPX_READ_WRITE:
imap->mode = IMAPX_MODE_READ|IMAPX_MODE_WRITE;
- c(printf("folder is read-write\n"));
+ c("folder is read-write\n");
break;
case IMAPX_READ_ONLY:
imap->mode = IMAPX_MODE_READ;
- c(printf("folder is read-only\n"));
+ c("folder is read-only\n");
break;
case IMAPX_UIDVALIDITY:
imap->uidvalidity = sinfo->u.uidvalidity;
imap->uidnext = sinfo->u.uidnext;
break;
case IMAPX_ALERT:
- c(printf("ALERT!: %s\n", sinfo->text));
+ c("ALERT!: %s\n", sinfo->text);
break;
case IMAPX_PARSE:
- c(printf("PARSE: %s\n", sinfo->text));
+ c("PARSE: %s\n", sinfo->text);
break;
case IMAPX_CAPABILITY:
if (sinfo->u.cinfo) {
sinfo->u.cinfo = NULL;
if (cinfo)
imapx_free_capability (cinfo);
- c(printf("got capability flags %08x\n", imap->cinfo->capa));
+ c("got capability flags %08x\n", imap->cinfo->capa);
}
break;
default:
return 0;
default:
/* unknown response, just ignore it */
- c(printf("unknown token: %s\n", token));
+ c("unknown token: %s\n", token);
}
return camel_imapx_stream_skip (imap->stream, error);
if (imapx_idle_supported (imap) && imapx_in_idle (imap)) {
camel_imapx_stream_skip (imap->stream, error);
- c(printf("Got continuation response for IDLE \n"));
+ c("Got continuation response for IDLE \n");
IDLE_LOCK (imap->idle);
/* We might have actually sent the DONE already! */
if (imap->idle->state == IMAPX_IDLE_ISSUED)
imapx_command_idle_stop (imap, error);
imap->idle->state = IMAPX_IDLE_OFF;
} else {
- c(printf("idle starts in wrong state %d\n",
- imap->idle->state));
+ c("idle starts in wrong state %d\n",
+ imap->idle->state);
}
IDLE_UNLOCK (imap->idle);
if (!litplus) {
if (ic == NULL) {
camel_imapx_stream_skip (imap->stream, error);
- c(printf("got continuation response with no outstanding continuation requests?\n"));
+ c("got continuation response with no outstanding continuation requests?\n");
return 1;
}
- c(printf("got continuation response for data\n"));
+ c("got continuation response for data\n");
} else {
- c(printf("sending LITERAL+ continuation\n"));
+ c("sending LITERAL+ continuation\n");
}
cp = ic->current;
switch (cp->type & CAMEL_IMAPX_COMMAND_MASK) {
case CAMEL_IMAPX_COMMAND_DATAWRAPPER:
- c(printf("writing data wrapper to literal\n"));
+ c("writing data wrapper to literal\n");
camel_data_wrapper_write_to_stream ((CamelDataWrapper *)cp->ob, (CamelStream *)imap->stream, NULL);
break;
case CAMEL_IMAPX_COMMAND_STREAM:
- c(printf("writing stream to literal\n"));
+ c("writing stream to literal\n");
camel_stream_write_to_stream ((CamelStream *)cp->ob, (CamelStream *)imap->stream, NULL);
break;
case CAMEL_IMAPX_COMMAND_AUTH: {
g_free (token);
if (resp == NULL)
return -1;
- c(printf("got auth continuation, feeding token '%s' back to auth mech\n", resp));
+ c("got auth continuation, feeding token '%s' back to auth mech\n", resp);
camel_stream_write ((CamelStream *)imap->stream, resp, strlen (resp), NULL);
g_free (resp);
case CAMEL_IMAPX_COMMAND_FILE: {
CamelStream *file;
- c(printf("writing file '%s' to literal\n", (gchar *)cp->ob));
+ c("writing file '%s' to literal\n", (gchar *)cp->ob);
// FIXME: errors
if (cp->ob && (file = camel_stream_fs_new_with_name (cp->ob, O_RDONLY, 0, NULL))) {
cp = cp->next;
if (cp->next) {
ic->current = cp;
- c(printf("next part of command \"%c%05u: %s\"\n", imap->tagprefix, ic->tag, cp->data));
+ c("next part of command \"%c%05u: %s\"\n", imap->tagprefix, ic->tag, cp->data);
camel_stream_printf((CamelStream *)imap->stream, "%s\r\n", cp->data);
if (cp->type & (CAMEL_IMAPX_COMMAND_CONTINUATION|CAMEL_IMAPX_COMMAND_LITERAL_PLUS)) {
newliteral = ic;
g_assert (cp->next->next == NULL);
}
} else {
- c(printf("%p: queueing continuation\n", ic));
+ c("%p: queueing continuation\n", ic);
camel_stream_printf((CamelStream *)imap->stream, "\r\n");
}
return -1;
}
- c(printf("Got completion response for command %05u '%s'\n", ic->tag, ic->name));
+ c("Got completion response for command %05u '%s'\n", ic->tag, ic->name);
if (camel_folder_change_info_changed (imap->changes)) {
if (imap->changes->uid_changed->len)
QUEUE_UNLOCK (is);
} else {
- e(printf ("NO connection yet, maybe user cancelled jobs earlier ?"));
+ e ("NO connection yet, maybe user cancelled jobs earlier ?");
g_set_error (
error, CAMEL_SERVICE_ERROR,
CAMEL_SERVICE_ERROR_NOT_CONNECTED,
imapx_server_fetch_new_messages (is, is->select_folder, TRUE, TRUE, &local_error);
if (local_error != NULL) {
- e(printf ("Caught exception in idle thread: %s \n", local_error->message));
+ e ("Caught exception in idle thread: %s \n", local_error->message);
/* No way to asyncronously notify UI ? */
g_clear_error (&local_error);
}
imapx_command_idle_stop (is, error);
idle->state = IMAPX_IDLE_OFF;
stopped = TRUE;
- c(printf("Stopping idle after %ld seconds\n",
- (long)(now - idle->started)));
+ c("Stopping idle after %ld seconds\n",
+ (long)(now - idle->started));
case IMAPX_IDLE_PENDING:
idle->state = IMAPX_IDLE_OFF;
case IMAPX_IDLE_OFF:
CamelDList failed;
CamelIMAPXCommand *cw, *cn;
- c(printf("Select failed\n"));
+ c("Select failed\n");
camel_dlist_init (&failed);
QUEUE_LOCK (is);
if (is->select_pending) {
while (cn) {
if (cw->select && cw->select == is->select_pending) {
- c(printf("Cancelling command '%s'(%p) for folder '%s'\n",
- cw->name, cw, camel_folder_get_full_name (cw->select)));
+ c("Cancelling command '%s'(%p) for folder '%s'\n",
+ cw->name, cw, camel_folder_get_full_name (cw->select));
camel_dlist_remove ((CamelDListNode *)cw);
camel_dlist_addtail (&failed, (CamelDListNode *)cw);
}
is->state = IMAPX_INITIALISED;
} else {
CamelIMAPXFolder *ifolder = (CamelIMAPXFolder *) is->select_pending;
- c(printf("Select ok!\n"));
+ c("Select ok!\n");
if (!is->select_folder) {
/* This could have been done earlier by a [CLOSED] status */
uid = camel_folder_summary_uid_from_index (folder->summary, 0);
if (isum->modseq && ifolder->uidvalidity_on_server) {
- c(printf("SELECT QRESYNC %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT "\n", ifolder->uidvalidity_on_server, isum->modseq));
+ c("SELECT QRESYNC %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT "\n", ifolder->uidvalidity_on_server, isum->modseq);
camel_imapx_command_add(ic, " (QRESYNC (%" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT " %s:*", ifolder->uidvalidity_on_server, isum->modseq, uid?uid:"1");
if (total > 10) {
g_string_prepend(seqs, " (");
- c(printf("adding QRESYNC seq/uidset %s%s\n", seqs->str, uids->str));
+ c("adding QRESYNC seq/uidset %s%s\n", seqs->str, uids->str);
camel_imapx_command_add (ic, seqs->str);
camel_imapx_command_add (ic, uids->str);
camel_imapx_stream_ungettoken (is->stream, tok, token, len);
if (camel_imapx_stream_text (is->stream, &token, error))
return FALSE;
- e(printf("Got unexpected line before greeting: '%s'\n", token));
+ e("Got unexpected line before greeting: '%s'\n", token);
g_free (token);
}
if (ic->status->condition == IMAPX_CAPABILITY) {
is->cinfo = ic->status->u.cinfo;
ic->status->u.cinfo = NULL;
- c(printf("got capability flags %08x\n", is->cinfo->capa));
+ c("got capability flags %08x\n", is->cinfo->capa);
}
camel_imapx_command_free (ic);
exit:
if (local_error != NULL) {
- e(printf("Unable to connect %d %s \n", local_error->code, local_error->message));
+ e("Unable to connect %d %s \n", local_error->code, local_error->message);
g_propagate_error (error, local_error);
g_object_unref (is->stream);
is->stream = NULL;
if (ic->status->condition == IMAPX_CAPABILITY) {
is->cinfo = ic->status->u.cinfo;
ic->status->u.cinfo = NULL;
- c(printf("got capability flags %08x\n", is->cinfo->capa));
+ c("got capability flags %08x\n", is->cinfo->capa);
}
authenticated = TRUE;
if (ic->error == NULL && ic->status->result == IMAPX_OK) {
if (ic->status->condition == IMAPX_APPENDUID) {
- c(printf("Got appenduid %d %d\n", (gint)ic->status->u.appenduid.uidvalidity, (gint)ic->status->u.appenduid.uid));
+ c("Got appenduid %d %d\n", (gint)ic->status->u.appenduid.uidvalidity, (gint)ic->status->u.appenduid.uid);
if (ic->status->u.appenduid.uidvalidity == ifolder->uidvalidity_on_server) {
CamelFolderChangeInfo *changes;
gchar *uid;
if (info && (strchr (camel_message_info_uid (info), '-') != NULL)) {
camel_message_info_free (info);
- e(printf("Ignoring offline uid '%s'\n", camel_message_info_uid(info)));
+ e("Ignoring offline uid '%s'\n", camel_message_info_uid(info));
} else {
camel_message_info_free (info);
break;
uidl++;
if (uidl > ifolder->uidnext_on_server) {
- c(printf("Updating uidnext_on_server for '%s' to %lld\n",
- camel_folder_get_full_name (job->folder), uidl));
+ c("Updating uidnext_on_server for '%s' to %lld\n",
+ camel_folder_get_full_name (job->folder), uidl);
ifolder->uidnext_on_server = uidl;
}
}
continue;
}
- e(printf("Message %s vanished\n", s_minfo->uid));
+ e("Message %s vanished\n", s_minfo->uid);
removed = g_slist_prepend (removed, (gpointer) g_strdup (s_minfo->uid));
camel_message_info_free (s_minfo);
j++;
uidl++;
if (uidl > ifolder->uidnext_on_server) {
- c(printf("Updating uidnext_on_server for '%s' to %lld\n",
- camel_folder_get_full_name (ic->job->folder), uidl));
+ c("Updating uidnext_on_server for '%s' to %lld\n",
+ camel_folder_get_full_name (ic->job->folder), uidl);
ifolder->uidnext_on_server = uidl;
}
}
if (is->use_qresync && isum->modseq && ifolder->uidvalidity_on_server)
can_qresync = TRUE;
- e(printf("folder %s is %sselected, total %u / %u, unread %u / %u, modseq %llu / %llu, uidnext %u / %u: will %srescan\n",
- full_name, is_selected?"": "not ", total, ifolder->exists_on_server,
- folder->summary->unread_count, ifolder->unread_on_server,
- (unsigned long long)isum->modseq, (unsigned long long)ifolder->modseq_on_server,
- isum->uidnext, ifolder->uidnext_on_server,
- need_rescan?"":"not "));
+ e("folder %s is %sselected, total %u / %u, unread %u / %u, modseq %llu / %llu, uidnext %u / %u: will %srescan\n",
+ full_name, is_selected?"": "not ", total, ifolder->exists_on_server,
+ folder->summary->unread_count, ifolder->unread_on_server,
+ (unsigned long long)isum->modseq, (unsigned long long)ifolder->modseq_on_server,
+ isum->uidnext, ifolder->uidnext_on_server,
+ need_rescan?"":"not ");
/* Fetch new messages first, so that they appear to the user ASAP */
if (ifolder->exists_on_server > total ||
if (total != ifolder->exists_on_server ||
folder->summary->unread_count != ifolder->unread_on_server ||
(isum->modseq != ifolder->modseq_on_server)) {
- c(printf("Eep, after QRESYNC we're out of sync. total %u / %u, unread %u / %u, modseq %" G_GUINT64_FORMAT " / %" G_GUINT64_FORMAT "\n",
- total, ifolder->exists_on_server,
- folder->summary->unread_count, ifolder->unread_on_server,
- isum->modseq, ifolder->modseq_on_server));
+ c("Eep, after QRESYNC we're out of sync. total %u / %u, unread %u / %u, modseq %" G_GUINT64_FORMAT " / %" G_GUINT64_FORMAT "\n",
+ total, ifolder->exists_on_server,
+ folder->summary->unread_count, ifolder->unread_on_server,
+ isum->modseq, ifolder->modseq_on_server);
} else {
- c(printf("OK, after QRESYNC we're still in sync. total %u / %u, unread %u / %u, modseq %" G_GUINT64_FORMAT " / %" G_GUINT64_FORMAT "\n",
- total, ifolder->exists_on_server,
- folder->summary->unread_count, ifolder->unread_on_server,
- isum->modseq, ifolder->modseq_on_server));
+ c("OK, after QRESYNC we're still in sync. total %u / %u, unread %u / %u, modseq %" G_GUINT64_FORMAT " / %" G_GUINT64_FORMAT "\n",
+ total, ifolder->exists_on_server,
+ folder->summary->unread_count, ifolder->unread_on_server,
+ isum->modseq, ifolder->modseq_on_server);
goto done;
}
}
g_propagate_error (&ic->job->error, ic->error);
}
- e(printf ("==== list or lsub completed ==== \n"));
+ e ("==== list or lsub completed ==== \n");
imapx_job_done (is, ic->job);
camel_imapx_command_free (ic);
}
if ((orset & flag) == 0)
continue;
- c(printf("checking/storing %s flags '%s'\n", on?"on":"off", flags_table[j].name));
+ c("checking/storing %s flags '%s'\n", on?"on":"off", flags_table[j].name);
imapx_uidset_init (&ss, 0, 100);
for (i = 0; i < uids->len; i++) {
CamelIMAPXMessageInfo *info = (CamelIMAPXMessageInfo *)camel_folder_summary_uid
#include "camel-imapx-utils.h"
/* high-level parser state */
-#define p(x) camel_imapx_debug(parse, x)
+#define p(...) camel_imapx_debug(parse, __VA_ARGS__)
/* debug */
-#define d(x) camel_imapx_debug(debug, x)
+#define d(...) camel_imapx_debug(debug, __VA_ARGS__)
gint camel_imapx_debug_flags;
extern gint camel_verbose_debug;
else if (server_cleared & CAMEL_MESSAGE_JUNK)
junk = -1;
- d(printf("%s %s %s %s\n", xinfo->info.uid, read == 1 ? "read" : ( read == -1 ? "unread" : ""),
- deleted == 1 ? "deleted" : ( deleted == -1 ? "undeleted" : ""),
- junk == 1 ? "junk" : ( junk == -1 ? "unjunked" : "")));
+ d("%s %s %s %s\n", xinfo->info.uid, read == 1 ? "read" : ( read == -1 ? "unread" : ""),
+ deleted == 1 ? "deleted" : ( deleted == -1 ? "undeleted" : ""),
+ junk == 1 ? "junk" : ( junk == -1 ? "unjunked" : ""));
if (read) {
folder->summary->unread_count -= read;
break;
}
case IMAPX_TOK_INT:
- d(printf(" cap: '%s'\n", token));
+ d(" cap: '%s'\n", token);
for (i = 0; i < G_N_ELEMENTS (capa_table); i++)
if (!strcmp ((gchar *) token, capa_table[i].name))
cinfo->capa |= capa_table[i].flag;
guchar *token;
gchar *param;
- p(printf("body_fld_param\n"));
+ p("body_fld_param\n");
/* body_fld_param ::= "(" 1#(string SPACE string) ")" / nil */
tok = camel_imapx_stream_token (is, &token, &len, NULL);
dinfo->disposition = g_strdup ((gchar *) token);
imapx_parse_param_list (is, &dinfo->params, NULL);
case IMAPX_TOK_TOKEN:
- d(printf("body_fld_dsp: NIL\n"));
+ d("body_fld_dsp: NIL\n");
break;
default:
g_set_error (error, CAMEL_IMAPX_ERROR, 1, "body_fld_disp: expecting nil or list");
return NULL;
}
- p(printf("body_fld_lang\n"));
+ p("body_fld_lang\n");
/* body_fld_lang ::= nstring / "(" 1#string ")" */
}
break;
case IMAPX_TOK_TOKEN:
- d(printf("body_fld_lang = nil\n"));
+ d("body_fld_lang = nil\n");
/* treat as 'nil' */
break;
case IMAPX_TOK_STRING:
/* we have a literal string */
camel_imapx_stream_set_literal (is, len);
while ((tok = camel_imapx_stream_getl (is, &token, &len)) > 0) {
- d(printf("Skip literal data '%.*s'\n", (gint)len, token));
+ d("Skip literal data '%.*s'\n", (gint)len, token);
}
break;
body_fld_desc SPACE body_fld_enc SPACE
body_fld_octets */
- p(printf("body_fields\n"));
+ p("body_fields\n");
cinfo = g_malloc0 (sizeof (*cinfo));
if (mbox == NULL) {
group = NULL;
} else {
- d(printf("adding group '%s'\n", mbox));
+ d("adding group '%s'\n", mbox);
g_free (addr->name);
addr->name = mbox;
addr->type = CAMEL_HEADER_ADDRESS_GROUP;
} else {
addr->v.addr = g_strdup_printf("%s%s%s", mbox? mbox:"", host?"@":"", host?(gchar *)host:"");
g_free (mbox);
- d(printf("adding address '%s'\n", addr->v.addr));
+ d("adding address '%s'\n", addr->v.addr);
if (group != NULL)
camel_header_address_add_member (group, addr);
else
} while (tok != ')');
}
} else {
- d(printf("empty, nil '%s'\n", token));
+ d("empty, nil '%s'\n", token);
}
/* CHEN TODO handle exception at required places */
SPACE env_cc SPACE env_bcc SPACE env_in_reply_to
SPACE env_message_id ")" */
- p(printf("envelope\n"));
+ p("envelope\n");
minfo = (CamelMessageInfoBase *)camel_message_info_new (NULL);
/* body ::= "(" body_type_1part / body_type_mpart ")" */
- p(printf("body\n"));
+ p("body\n");
tok = camel_imapx_stream_token (is, &token, &len, &local_error);
if (tok != '(') {
camel_imapx_stream_ungettoken (is, tok, token, len);
} while (tok == '(');
- d(printf("media_subtype\n"));
+ d("media_subtype\n");
camel_imapx_stream_astring (is, &token, &local_error);
cinfo->type = camel_content_type_new("multipart", (gchar *) token);
;; MUST NOT be returned on non-extensible
;; "BODY" fetch */
- d(printf("body_ext_mpart\n"));
+ d("body_ext_mpart\n");
tok = camel_imapx_stream_token (is, &token, &len, &local_error);
camel_imapx_stream_ungettoken (is, tok, token, len);
body_type_msg ::= media_message SPACE body_fields SPACE envelope
SPACE body SPACE body_fld_lines */
- d(printf("Single part body\n"));
+ d("Single part body\n");
cinfo = imapx_parse_body_fields (is, &local_error);
- d(printf("envelope?\n"));
+ d("envelope?\n");
/* do we have an envelope following */
tok = camel_imapx_stream_token (is, &token, &len, &local_error);
//((CamelMessageInfoBase *)minfo)->content = imapx_parse_body (is);
camel_message_info_free (minfo);
minfo = NULL;
- d(printf("Scanned envelope - what do i do with it?\n"));
+ d("Scanned envelope - what do i do with it?\n");
}
- d(printf("fld_lines?\n"));
+ d("fld_lines?\n");
/* do we have fld_lines following? */
tok = camel_imapx_stream_token (is, &token, &len, &local_error);
if (tok == IMAPX_TOK_INT) {
- d(printf("field lines: %s\n", token));
+ d("field lines: %s\n", token);
tok = camel_imapx_stream_token (is, &token, &len, &local_error);
}
camel_imapx_stream_ungettoken (is, tok, token, len);
;; MUST NOT be returned on non-extensible
;; "BODY" fetch */
- d(printf("extension data?\n"));
+ d("extension data?\n");
if (tok != ')') {
camel_imapx_stream_nstring (is, &token, &local_error);
- d(printf("md5: %s\n", token?(gchar *)token:"NIL"));
+ d("md5: %s\n", token?(gchar *)token:"NIL");
/* body_fld_dsp ::= "(" string SPACE body_fld_param ")" / nil */
do {
tok = camel_imapx_stream_token (is, &token, &len, &local_error);
if (tok != ')') {
- d(printf("Dropping extension data '%s'\n", token));
+ d("Dropping extension data '%s'\n", token);
}
} while (tok != ')');
CamelStream *sout;
gint fd;
- d(printf("Fetch info:\n"));
+ d("Fetch info:\n");
if (finfo == NULL) {
- d(printf("Empty\n"));
+ d("Empty\n");
return;
}
break;
default:
sinfo->condition = IMAPX_UNKNOWN;
- d(printf("Got unknown response code: %s: ignored\n", token));
+ d("Got unknown response code: %s: ignored\n", token);
}
/* ignore anything we dont know about */