~ubuntu-branches/ubuntu/precise/evolution-data-server/precise

« back to all changes in this revision

Viewing changes to camel/providers/imapx/camel-imapx-server.c

  • Committer: Bazaar Package Importer
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2011-07-14 15:00:38 UTC
  • Revision ID: james.westby@ubuntu.com-20110714150038-aha2wqajqp2i8s5v
Tags: 3.1.3.1-0ubuntu3
debian/patches/999git_EDS_3_1_3_1_to_f94a069.patch: apply changes from git
branch up to commit f94a069.

Show diffs side-by-side

added added

removed removed

Lines of Context:
496
496
 
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)),
 
502
                        NULL, NULL);
500
503
                if (!camel_sasl_get_authenticated ((CamelSasl *) ob))
501
504
                        type |= CAMEL_IMAPX_COMMAND_CONTINUATION;
502
505
                break;
524
527
        }
525
528
 
526
529
        if (type & CAMEL_IMAPX_COMMAND_LITERAL_PLUS) {
 
530
                gchar *string;
 
531
 
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);
529
534
                } else {
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);
533
538
                }
 
539
 
 
540
                camel_stream_write_string ((CamelStream *)ic->mem, string, NULL, NULL);
 
541
 
 
542
                g_free (string);
534
543
        }
535
544
 
536
545
        byte_array = camel_stream_mem_get_byte_array (ic->mem);
706
715
                                case 'd': /* int/unsigned */
707
716
                                case 'u':
708
717
                                        if (llong == 1) {
 
718
                                                gchar *string;
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);
 
725
                                                g_free (string);
714
726
                                        } else if (llong == 2) {
 
727
                                                gchar *string;
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);
 
734
                                                g_free (string);
720
735
                                        } else {
 
736
                                                gchar *string;
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);
 
743
                                                g_free (string);
726
744
                                        }
727
745
                                        break;
728
746
                                }
849
867
imapx_command_start (CamelIMAPXServer *imap, CamelIMAPXCommand *ic)
850
868
{
851
869
        CamelIMAPXCommandPart *cp;
 
870
        gint retval;
852
871
 
853
872
        camel_imapx_command_close (ic);
854
873
        cp = (CamelIMAPXCommandPart *) ic->parts.head;
866
885
        g_static_rec_mutex_lock (&imap->ostream_lock);
867
886
 
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) {
 
889
                gchar *string;
 
890
 
 
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);
 
893
                g_free (string);
 
894
        } else
 
895
                retval = -1;
 
896
        if (retval == -1) {
870
897
                g_set_error (
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;
1924
1952
                } else {
1926
1954
                }
1927
1955
        } else {
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);
1930
1958
        }
1931
1959
 
1932
1960
        QUEUE_LOCK (imap);
2199
2227
static gboolean
2200
2228
imapx_command_idle_stop (CamelIMAPXServer *is, GError **error)
2201
2229
{
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) {
2203
2231
                g_set_error (
2204
2232
                        error, CAMEL_IMAPX_ERROR, 1,
2205
2233
                        "Unable to issue DONE");