1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.net.sip;
18
19/**
20 * Defines error codes returned during SIP actions. For example, during
21 * {@link SipRegistrationListener#onRegistrationFailed onRegistrationFailed()},
22 * {@link SipSession.Listener#onError onError()},
23 * {@link SipSession.Listener#onCallChangeFailed onCallChangeFailed()} and
24 * {@link SipSession.Listener#onRegistrationFailed onRegistrationFailed()}.
25 */
26public class SipErrorCode {
27    /** Not an error. */
28    public static final int NO_ERROR = 0;
29
30    /** When some socket error occurs. */
31    public static final int SOCKET_ERROR = -1;
32
33    /** When server responds with an error. */
34    public static final int SERVER_ERROR = -2;
35
36    /** When transaction is terminated unexpectedly. */
37    public static final int TRANSACTION_TERMINTED = -3;
38
39    /** When some error occurs on the device, possibly due to a bug. */
40    public static final int CLIENT_ERROR = -4;
41
42    /** When the transaction gets timed out. */
43    public static final int TIME_OUT = -5;
44
45    /** When the remote URI is not valid. */
46    public static final int INVALID_REMOTE_URI = -6;
47
48    /** When the peer is not reachable. */
49    public static final int PEER_NOT_REACHABLE = -7;
50
51    /** When invalid credentials are provided. */
52    public static final int INVALID_CREDENTIALS = -8;
53
54    /** The client is in a transaction and cannot initiate a new one. */
55    public static final int IN_PROGRESS = -9;
56
57    /** When data connection is lost. */
58    public static final int DATA_CONNECTION_LOST = -10;
59
60    /** Cross-domain authentication required. */
61    public static final int CROSS_DOMAIN_AUTHENTICATION = -11;
62
63    /** When the server is not reachable. */
64    public static final int SERVER_UNREACHABLE = -12;
65
66    public static String toString(int errorCode) {
67        switch (errorCode) {
68            case NO_ERROR:
69                return "NO_ERROR";
70            case SOCKET_ERROR:
71                return "SOCKET_ERROR";
72            case SERVER_ERROR:
73                return "SERVER_ERROR";
74            case TRANSACTION_TERMINTED:
75                return "TRANSACTION_TERMINTED";
76            case CLIENT_ERROR:
77                return "CLIENT_ERROR";
78            case TIME_OUT:
79                return "TIME_OUT";
80            case INVALID_REMOTE_URI:
81                return "INVALID_REMOTE_URI";
82            case PEER_NOT_REACHABLE:
83                return "PEER_NOT_REACHABLE";
84            case INVALID_CREDENTIALS:
85                return "INVALID_CREDENTIALS";
86            case IN_PROGRESS:
87                return "IN_PROGRESS";
88            case DATA_CONNECTION_LOST:
89                return "DATA_CONNECTION_LOST";
90            case CROSS_DOMAIN_AUTHENTICATION:
91                return "CROSS_DOMAIN_AUTHENTICATION";
92            case SERVER_UNREACHABLE:
93                return "SERVER_UNREACHABLE";
94            default:
95                return "UNKNOWN";
96        }
97    }
98
99    private SipErrorCode() {
100    }
101}
102