SipErrorCode.java revision 00a22064efef4f574e439079aae2deae1a087a31
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 code returned in
21 * {@link SipRegistrationListener#onRegistrationFailed},
22 * {@link ISipSessionListener#onError},
23 * {@link ISipSessionListener#onCallChangeFailed} and
24 * {@link ISipSessionListener#onRegistrationFailed}.
25 * @hide
26 */
27public class SipErrorCode {
28    /** Not an error. */
29    public static final int NO_ERROR = 0;
30
31    /** When some socket error occurs. */
32    public static final int SOCKET_ERROR = -1;
33
34    /** When server responds with an error. */
35    public static final int SERVER_ERROR = -2;
36
37    /** When transaction is terminated unexpectedly. */
38    public static final int TRANSACTION_TERMINTED = -3;
39
40    /** When some error occurs on the device, possibly due to a bug. */
41    public static final int CLIENT_ERROR = -4;
42
43    /** When the transaction gets timed out. */
44    public static final int TIME_OUT = -5;
45
46    /** When the remote URI is not valid. */
47    public static final int INVALID_REMOTE_URI = -6;
48
49    /** When the peer is not reachable. */
50    public static final int PEER_NOT_REACHABLE = -7;
51
52    /** When invalid credentials are provided. */
53    public static final int INVALID_CREDENTIALS = -8;
54
55    /** The client is in a transaction and cannot initiate a new one. */
56    public static final int IN_PROGRESS = -9;
57
58    /** When data connection is lost. */
59    public static final int DATA_CONNECTION_LOST = -10;
60
61    /** Cross-domain authentication required. */
62    public static final int CROSS_DOMAIN_AUTHENTICATION = -11;
63
64    public static String toString(int errorCode) {
65        switch (errorCode) {
66            case NO_ERROR:
67                return "NO_ERROR";
68            case SOCKET_ERROR:
69                return "SOCKET_ERROR";
70            case SERVER_ERROR:
71                return "SERVER_ERROR";
72            case TRANSACTION_TERMINTED:
73                return "TRANSACTION_TERMINTED";
74            case CLIENT_ERROR:
75                return "CLIENT_ERROR";
76            case TIME_OUT:
77                return "TIME_OUT";
78            case INVALID_REMOTE_URI:
79                return "INVALID_REMOTE_URI";
80            case PEER_NOT_REACHABLE:
81                return "PEER_NOT_REACHABLE";
82            case INVALID_CREDENTIALS:
83                return "INVALID_CREDENTIALS";
84            case IN_PROGRESS:
85                return "IN_PROGRESS";
86            case DATA_CONNECTION_LOST:
87                return "DATA_CONNECTION_LOST";
88            case CROSS_DOMAIN_AUTHENTICATION:
89                return "CROSS_DOMAIN_AUTHENTICATION";
90            default:
91                return "UNKNOWN";
92        }
93    }
94
95    private SipErrorCode() {
96    }
97}
98