497
497
/* we presume we'll need to get additional data only if we're not authenticated yet */
498
498
g_object_ref (ob);
499
camel_stream_printf((CamelStream *)ic->mem, "%s", camel_sasl_get_mechanism (CAMEL_SASL (ob)));
499
camel_stream_write_string (
500
(CamelStream *)ic->mem,
501
camel_sasl_get_mechanism (CAMEL_SASL (ob)),
500
503
if (!camel_sasl_get_authenticated ((CamelSasl *) ob))
501
504
type |= CAMEL_IMAPX_COMMAND_CONTINUATION;
526
529
if (type & CAMEL_IMAPX_COMMAND_LITERAL_PLUS) {
527
532
if (ic->is->cinfo && ic->is->cinfo->capa & IMAPX_CAPABILITY_LITERALPLUS) {
528
camel_stream_printf((CamelStream *)ic->mem, "{%u+}", ob_size);
533
string = g_strdup_printf ("{%u+}", ob_size);
530
535
type &= ~CAMEL_IMAPX_COMMAND_LITERAL_PLUS;
531
536
type |= CAMEL_IMAPX_COMMAND_CONTINUATION;
532
camel_stream_printf((CamelStream *)ic->mem, "{%u}", ob_size);
537
string = g_strdup_printf ("{%u}", ob_size);
540
camel_stream_write_string ((CamelStream *)ic->mem, string, NULL, NULL);
536
545
byte_array = camel_stream_mem_get_byte_array (ic->mem);
706
715
case 'd': /* int/unsigned */
708
717
if (llong == 1) {
709
719
l = va_arg (ap, glong);
710
720
c(ic->is->tagprefix, "got glong '%d'\n", (gint)l);
711
721
memcpy (buffer, start, p-start);
712
722
buffer[p-start] = 0;
713
camel_stream_printf ((CamelStream *) ic->mem, buffer, l);
723
string = g_strdup_printf (buffer, l);
724
camel_stream_write_string ((CamelStream *) ic->mem, string, ic->cancellable, NULL);
714
726
} else if (llong == 2) {
715
728
guint64 i64 = va_arg (ap, guint64);
716
729
c(ic->is->tagprefix, "got guint64 '%d'\n", (gint)i64);
717
730
memcpy (buffer, start, p-start);
718
731
buffer[p-start] = 0;
719
camel_stream_printf ((CamelStream *) ic->mem, buffer, i64);
732
string = g_strdup_printf (buffer, i64);
733
camel_stream_write_string ((CamelStream *) ic->mem, string, ic->cancellable, NULL);
721
737
d = va_arg (ap, gint);
722
738
c(ic->is->tagprefix, "got gint '%d'\n", d);
723
739
memcpy (buffer, start, p-start);
724
740
buffer[p-start] = 0;
725
camel_stream_printf ((CamelStream *) ic->mem, buffer, d);
741
string = g_strdup_printf (buffer, d);
742
camel_stream_write_string ((CamelStream *) ic->mem, string, ic->cancellable, NULL);
849
867
imapx_command_start (CamelIMAPXServer *imap, CamelIMAPXCommand *ic)
851
869
CamelIMAPXCommandPart *cp;
853
872
camel_imapx_command_close (ic);
854
873
cp = (CamelIMAPXCommandPart *) ic->parts.head;
866
885
g_static_rec_mutex_lock (&imap->ostream_lock);
868
887
c(imap->tagprefix, "Starting command (active=%d,%s) %c%05u %s\r\n", camel_dlist_length(&imap->active), imap->literal?" literal":"", imap->tagprefix, ic->tag, cp->data);
869
if (!imap->stream || camel_stream_printf((CamelStream *)imap->stream, "%c%05u %s\r\n", imap->tagprefix, ic->tag, cp->data) == -1) {
888
if (imap->stream != NULL) {
891
string = g_strdup_printf ("%c%05u %s\r\n", imap->tagprefix, ic->tag, cp->data);
892
retval = camel_stream_write_string ((CamelStream *) imap->stream, string, ic->cancellable, NULL);
871
898
&ic->error, CAMEL_IMAPX_ERROR, 1,
872
899
"Failed to issue the command");
1918
1945
if (cp->next) {
1919
1946
ic->current = cp;
1920
1947
c(imap->tagprefix, "next part of command \"%c%05u: %s\"\n", imap->tagprefix, ic->tag, cp->data);
1921
camel_stream_printf((CamelStream *)imap->stream, "%s\r\n", cp->data);
1948
camel_stream_write_string ((CamelStream *) imap->stream, cp->data, cancellable, NULL);
1949
camel_stream_write_string ((CamelStream *) imap->stream, "\r\n", cancellable, NULL);
1922
1950
if (cp->type & (CAMEL_IMAPX_COMMAND_CONTINUATION|CAMEL_IMAPX_COMMAND_LITERAL_PLUS)) {
1923
1951
newliteral = ic;
1928
1956
c(imap->tagprefix, "%p: queueing continuation\n", ic);
1929
camel_stream_printf((CamelStream *)imap->stream, "\r\n");
1957
camel_stream_write_string((CamelStream *)imap->stream, "\r\n", cancellable, NULL);
1932
1960
QUEUE_LOCK (imap);
2199
2227
static gboolean
2200
2228
imapx_command_idle_stop (CamelIMAPXServer *is, GError **error)
2202
if (!is->stream || camel_stream_printf((CamelStream *)is->stream, "%s", "DONE\r\n") == -1) {
2230
if (!is->stream || camel_stream_write_string ((CamelStream *)is->stream, "DONE\r\n", NULL, NULL) == -1) {
2204
2232
error, CAMEL_IMAPX_ERROR, 1,
2205
2233
"Unable to issue DONE");