~ubuntu-branches/ubuntu/saucy/geary/saucy-updates

« back to all changes in this revision

Viewing changes to src/engine/smtp/smtp-client-session.vala

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-03-14 13:48:23 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130314134823-gyk5av1g508zyj8a
Tags: 0.3.0~pr1-0ubuntu1
New upstream version (FFE lp: #1154316), supports multiple account as
well as full conversation views with inline replies

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    public async Greeting? login_async(Credentials? creds, Cancellable? cancellable = null) throws Error {
37
37
        if (cx.is_connected())
38
38
            throw new SmtpError.ALREADY_CONNECTED("Connection to %s already exists", to_string());
39
 
 
 
39
        
40
40
        // Greet the SMTP server.
41
41
        Greeting? greeting = yield cx.connect_async(cancellable);
42
42
        if (greeting == null)
43
43
            throw new SmtpError.ALREADY_CONNECTED("Connection to %s already exists", to_string());
44
 
        yield cx.say_hello_async(cancellable);
45
 
 
 
44
        yield cx.establish_connection_async(cancellable);
 
45
        
46
46
        notify_connected(greeting);
47
 
 
 
47
        
48
48
        // authenticate if credentials supplied (they should be if ESMTP is supported)
49
49
        if (creds != null) {
50
50
            // detect which authentication is available, using PLAIN if none found as a hail mary
70
70
        
71
71
        return greeting;
72
72
    }
73
 
 
 
73
    
74
74
    public async Response? logout_async(Cancellable? cancellable = null) throws Error {
75
75
        Response? response = null;
76
76
        try {
146
146
        foreach (RFC822.MailboxAddress mailbox in addrlist) {
147
147
            RcptRequest rcpt_request = new RcptRequest.plain(mailbox.address);
148
148
            Response response = yield cx.transaction_async(rcpt_request, cancellable);
149
 
            if (!response.code.is_success_completed())
150
 
                response.throw_error("\"%s\" failed".printf(rcpt_request.to_string()));
 
149
 
 
150
            if (!response.code.is_success_completed()) {
 
151
                if (response.code.is_denied()) {
 
152
                    response.throw_error("recipient \"%s\" denied by smtp server".printf(rcpt_request.to_string()));
 
153
                } else {
 
154
                    response.throw_error("\"%s\" failed".printf(rcpt_request.to_string()));
 
155
                }
 
156
            }
151
157
        }
152
158
    }
153
159