aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/java/com/libmailcore/SMTPOperation.java
blob: 3eecb7920bb4e6a7dab9b6ce954311d2cbd63fd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.libmailcore;

public class SMTPOperation extends Operation {
    /**
        Returns error once the operation finished running. It will return null if the operation
        successfully ran.
    */
    public MailException exception() {
        if (errorCode() == ErrorCode.ErrorNone) {
            return null;
        }
        return new MailException(errorCode());
    }

    private native int errorCode();
    
    /**
        Calls the method succeeded() of the callback if the operation succeeded or failed()
        if the operation failed.
        @see com.libmailcore.OperationCallback
    */
    protected void callCallback()
    {
        if (callback != null) {
            if (errorCode() == ErrorCode.ErrorNone) {
                callback.succeeded();
            }
            else {
                callback.failed(exception());
            }
        }
    }
}