~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to camel/providers/pop3/camel-pop3-store.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
#define POP3_PORT "110"
61
61
#define POP3S_PORT "995"
62
62
 
 
63
/* defines the length of the server error message we can display in the error dialog */
 
64
#define POP3_ERROR_SIZE_LIMIT 60
 
65
 
63
66
static CamelStoreClass *parent_class = NULL;
64
67
 
65
68
static void finalize (CamelObject *object);
147
150
#define STARTTLS_FLAGS (CAMEL_TCP_STREAM_SSL_ENABLE_TLS)
148
151
#endif
149
152
 
 
153
/* returns error message with ': ' as prefix */
 
154
static gchar *
 
155
get_valid_utf8_error (const gchar *text)
 
156
{
 
157
        gchar *tmp = camel_utf8_make_valid (text);
 
158
        gchar *ret = NULL;
 
159
 
 
160
        /*TODO If the error message > size limit log it somewhere */
 
161
        if (!tmp || g_utf8_strlen (tmp, -1) > POP3_ERROR_SIZE_LIMIT) {
 
162
                g_free (tmp);
 
163
                return NULL;
 
164
        }
 
165
 
 
166
        ret = g_strconcat (": ", tmp, NULL);
 
167
 
 
168
        g_free (tmp);
 
169
        return ret;
 
170
}
 
171
 
150
172
static gboolean
151
173
connect_to_server (CamelService *service, struct addrinfo *ai, gint ssl_mode, CamelException *ex)
152
174
{
234
256
        camel_pop3_engine_command_free (store->engine, pc);
235
257
 
236
258
        if (ret == FALSE) {
 
259
                gchar *tmp = get_valid_utf8_error ((gchar *) store->engine->line);
 
260
 
237
261
                camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM,
238
 
                        _("Failed to connect to POP server %s in secure mode: %s"),
239
 
                        service->url->host, store->engine->line);
 
262
                                /* Translators: Last %s is an optional explanation beginning with ": " separator */
 
263
                                _("Failed to connect to POP server %s in secure mode%s"),
 
264
                                service->url->host, tmp ? tmp:"");
 
265
 
 
266
                g_free (tmp);
240
267
                goto stls_exception;
241
268
        }
242
269
 
414
441
                if (strncmp((gchar *) line, "+OK", 3) == 0)
415
442
                        break;
416
443
                if (strncmp((gchar *) line, "-ERR", 4) == 0) {
 
444
                        gchar *tmp = get_valid_utf8_error ((gchar *) store->engine->line);
 
445
 
417
446
                        camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
418
 
                                              _("SASL '%s' Login failed for POP server %s: %s"),
419
 
                                              mech, CAMEL_SERVICE (store)->url->host, line);
 
447
                                              /* Translators: Last %s is an optional explanation beginning with ": " separator */
 
448
                                              _("SASL '%s' Login failed for POP server %s%s"),
 
449
                                              mech, CAMEL_SERVICE (store)->url->host, tmp ? tmp : "");
 
450
 
 
451
                        g_free (tmp);
420
452
                        goto done;
421
453
                }
422
454
                /* If we dont get continuation, or the sasl object's run out of work, or we dont get a challenge,
552
584
                                              errno ? g_strerror (errno) : _("Unknown error"));
553
585
                }
554
586
        } else if (pcu && pcu->state != CAMEL_POP3_COMMAND_OK) {
 
587
                gchar *tmp = get_valid_utf8_error ((gchar *) store->engine->line);
 
588
 
555
589
                camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
 
590
                                      /* Translators: Last %s is an optional explanation beginning with ": " separator */
556
591
                                      _("Unable to connect to POP server %s.\n"
557
 
                                        "Error sending username: %s"),
 
592
                                        "Error sending username%s"),
558
593
                                      CAMEL_SERVICE (store)->url->host,
559
 
                                      store->engine->line ? (gchar *)store->engine->line : _("Unknown error"));
 
594
                                      tmp ? tmp : "");
 
595
                g_free (tmp);
560
596
        } else if (pcp->state != CAMEL_POP3_COMMAND_OK) {
 
597
                gchar *tmp = get_valid_utf8_error ((gchar *) store->engine->line);
 
598
 
561
599
                camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE,
 
600
                                      /* Translators: Last %s is an optional explanation beginning with ": " separator */
562
601
                                      _("Unable to connect to POP server %s.\n"
563
 
                                        "Error sending password: %s"),
 
602
                                        "Error sending password%s"),
564
603
                                      CAMEL_SERVICE (store)->url->host,
565
 
                                      store->engine->line ? (gchar *)store->engine->line : _("Unknown error"));
 
604
                                      tmp ? tmp :"");
 
605
                g_free (tmp);
566
606
        }
567
607
 
568
608
        camel_pop3_engine_command_free (store->engine, pcp);
609
649
 
610
650
                /* we only re-prompt if we failed to authenticate, any other error and we just abort */
611
651
                if (status == 0 && camel_exception_get_id (ex) == CAMEL_EXCEPTION_SERVICE_CANT_AUTHENTICATE) {
612
 
                        gchar *tmp = camel_utf8_make_valid (camel_exception_get_description (ex));
613
 
                        errbuf = g_markup_printf_escaped ("%s\n\n", tmp);
614
 
                        g_free (tmp);
 
652
                        errbuf = g_markup_printf_escaped ("%s\n\n", camel_exception_get_description (ex));
615
653
                        camel_exception_clear (ex);
616
654
 
617
655
                        camel_session_forget_password (session, service, NULL, "password", ex);