~hkdb/geary/disco-3.34.1

« back to all changes in this revision

Viewing changes to src/engine/imap-engine/imap-engine.vala

  • Committer: hkdb
  • Date: 2019-10-08 10:54:21 UTC
  • Revision ID: hkdb@3df.io-20191008105421-3dkwnpnhcamm77to
Tags: upstream-3.34.1-disco
ImportĀ upstreamĀ versionĀ 3.34.1-disco

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2016 Software Freedom Conservancy Inc.
 
2
 *
 
3
 * This software is licensed under the GNU Lesser General Public License
 
4
 * (version 2.1 or later).  See the COPYING file in this distribution.
 
5
 */
 
6
 
 
7
namespace Geary.ImapEngine {
 
8
 
 
9
    /**
 
10
     * Determines if retrying an operation might succeed or not.
 
11
     *
 
12
     * A recoverable failure is defined as one that may not occur
 
13
     * again if the operation that caused it is retried, without
 
14
     * needing to make some change in the mean time. For example,
 
15
     * recoverable failures may occur due to transient network
 
16
     * connectivity issues or server rate limiting. On the other hand,
 
17
     * an unrecoverable failure is due to some problem that will not
 
18
     * succeed if tried again unless some action is taken, such as
 
19
     * authentication failures, protocol parsing errors, and so on.
 
20
     */
 
21
    private static bool is_recoverable_failure(GLib.Error err) {
 
22
        return (
 
23
            err is EngineError.SERVER_UNAVAILABLE ||
 
24
            err is IOError.BROKEN_PIPE ||
 
25
            err is IOError.BUSY ||
 
26
            err is IOError.CONNECTION_CLOSED ||
 
27
            err is IOError.NOT_CONNECTED ||
 
28
            err is IOError.TIMED_OUT ||
 
29
            err is ImapError.NOT_CONNECTED ||
 
30
            err is ImapError.TIMED_OUT ||
 
31
            err is ImapError.UNAVAILABLE
 
32
        );
 
33
    }
 
34
 
 
35
    /**
 
36
     * Determines if an error was caused by the remote host or not.
 
37
     */
 
38
    private static bool is_remote_error(GLib.Error err) {
 
39
        return (
 
40
            err is EngineError.NOT_FOUND ||
 
41
            err is EngineError.SERVER_UNAVAILABLE ||
 
42
            err is IOError.CONNECTION_CLOSED ||
 
43
            err is IOError.CONNECTION_REFUSED ||
 
44
            err is IOError.HOST_UNREACHABLE ||
 
45
            err is IOError.MESSAGE_TOO_LARGE ||
 
46
            err is IOError.NETWORK_UNREACHABLE ||
 
47
            err is IOError.NOT_CONNECTED ||
 
48
            err is IOError.PROXY_AUTH_FAILED ||
 
49
            err is IOError.PROXY_FAILED ||
 
50
            err is IOError.PROXY_NEED_AUTH ||
 
51
            err is IOError.PROXY_NOT_ALLOWED ||
 
52
            err is ImapError
 
53
        );
 
54
    }
 
55
 
 
56
}