SipErrorCode.java revision d012595fd71a41159ec437d072f5dc56db8444a2
1639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright/*
2639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * Copyright (C) 2010 The Android Open Source Project
3639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright *
4639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * Licensed under the Apache License, Version 2.0 (the "License");
5639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * you may not use this file except in compliance with the License.
6639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * You may obtain a copy of the License at
7639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright *
8639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright *      http://www.apache.org/licenses/LICENSE-2.0
9639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright *
10639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * Unless required by applicable law or agreed to in writing, software
11639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * distributed under the License is distributed on an "AS IS" BASIS,
12639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * See the License for the specific language governing permissions and
14639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * limitations under the License.
15639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright */
16639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright
17131206b8a9d07400d7c98aea50cc45c38769448fJeff Brownpackage android.net.sip;
18639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright
19a576b4d3be8687f0a65fc5777424955d551604e4Jeff Brown/**
20131206b8a9d07400d7c98aea50cc45c38769448fJeff Brown * Defines error codes returned during SIP actions. For example, during
21639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * {@link SipRegistrationListener#onRegistrationFailed onRegistrationFailed()},
22908b86c796443ba4ec55c669e8a0297fc80574a6Justin Klaassen * {@link SipSession.Listener#onError onError()},
23639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * {@link SipSession.Listener#onCallChangeFailed onCallChangeFailed()} and
24639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright * {@link SipSession.Listener#onRegistrationFailed onRegistrationFailed()}.
25639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright */
26639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wrightpublic class SipErrorCode {
27eef0e13f018f33bf3db2f8311bbb429369e13394Michael Wright    /** Not an error. */
28d846023804ddadcd692666152db420c54594ddb9Michael Wright    public static final int NO_ERROR = 0;
29639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright
30639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    /** When some socket error occurs. */
31639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    public static final int SOCKET_ERROR = -1;
32639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright
33639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    /** When server responds with an error. */
34b0a1d3d08fc459e0d9937e299e16de17d1388ac4Michael Wright    public static final int SERVER_ERROR = -2;
35639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright
36a576b4d3be8687f0a65fc5777424955d551604e4Jeff Brown    /** When transaction is terminated unexpectedly. */
37639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    public static final int TRANSACTION_TERMINTED = -3;
38639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright
39639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    /** When some error occurs on the device, possibly due to a bug. */
40639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    public static final int CLIENT_ERROR = -4;
41639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright
42639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    /** When the transaction gets timed out. */
43639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    public static final int TIME_OUT = -5;
44639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright
45639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    /** When the remote URI is not valid. */
46639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    public static final int INVALID_REMOTE_URI = -6;
47639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright
48639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    /** When the peer is not reachable. */
49639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    public static final int PEER_NOT_REACHABLE = -7;
50daf7d410fc97647f2b3ab4254f73c09c923018deAdrian Roos
51639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    /** When invalid credentials are provided. */
52639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    public static final int INVALID_CREDENTIALS = -8;
53639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright
54639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    /** The client is in a transaction and cannot initiate a new one. */
55639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright    public static final int IN_PROGRESS = -9;
56639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright
57a576b4d3be8687f0a65fc5777424955d551604e4Jeff Brown    /** When data connection is lost. */
58a576b4d3be8687f0a65fc5777424955d551604e4Jeff Brown    public static final int DATA_CONNECTION_LOST = -10;
59a576b4d3be8687f0a65fc5777424955d551604e4Jeff Brown
60a576b4d3be8687f0a65fc5777424955d551604e4Jeff Brown    /** Cross-domain authentication required. */
61d846023804ddadcd692666152db420c54594ddb9Michael Wright    public static final int CROSS_DOMAIN_AUTHENTICATION = -11;
62d846023804ddadcd692666152db420c54594ddb9Michael Wright
63d846023804ddadcd692666152db420c54594ddb9Michael Wright    /** When the server is not reachable. */
64d846023804ddadcd692666152db420c54594ddb9Michael Wright    public static final int SERVER_UNREACHABLE = -12;
65d846023804ddadcd692666152db420c54594ddb9Michael Wright
66d846023804ddadcd692666152db420c54594ddb9Michael Wright    public static String toString(int errorCode) {
67d846023804ddadcd692666152db420c54594ddb9Michael Wright        switch (errorCode) {
68639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright            case NO_ERROR:
69a576b4d3be8687f0a65fc5777424955d551604e4Jeff Brown                return "NO_ERROR";
70c5d3291487d4b6a09cbeac222831bb1b2203d957Dan Gittik            case SOCKET_ERROR:
71639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright                return "SOCKET_ERROR";
720a933141e2dd72bc868598cfa2146b2c72b85d5dMichael Wright            case SERVER_ERROR:
730a933141e2dd72bc868598cfa2146b2c72b85d5dMichael Wright                return "SERVER_ERROR";
740a933141e2dd72bc868598cfa2146b2c72b85d5dMichael Wright            case TRANSACTION_TERMINTED:
750a933141e2dd72bc868598cfa2146b2c72b85d5dMichael Wright                return "TRANSACTION_TERMINTED";
760a933141e2dd72bc868598cfa2146b2c72b85d5dMichael Wright            case CLIENT_ERROR:
770a933141e2dd72bc868598cfa2146b2c72b85d5dMichael Wright                return "CLIENT_ERROR";
780a933141e2dd72bc868598cfa2146b2c72b85d5dMichael Wright            case TIME_OUT:
79428aed01e1e2923968027dff57132d8d8d5c4905Julius D'souza                return "TIME_OUT";
80639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright            case INVALID_REMOTE_URI:
81639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright                return "INVALID_REMOTE_URI";
82639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright            case PEER_NOT_REACHABLE:
83639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright                return "PEER_NOT_REACHABLE";
84639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright            case INVALID_CREDENTIALS:
85639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright                return "INVALID_CREDENTIALS";
86639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright            case IN_PROGRESS:
87639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright                return "IN_PROGRESS";
88eef0e13f018f33bf3db2f8311bbb429369e13394Michael Wright            case DATA_CONNECTION_LOST:
89eef0e13f018f33bf3db2f8311bbb429369e13394Michael Wright                return "DATA_CONNECTION_LOST";
90639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright            case CROSS_DOMAIN_AUTHENTICATION:
91639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright                return "CROSS_DOMAIN_AUTHENTICATION";
92639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright            case SERVER_UNREACHABLE:
93639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright                return "SERVER_UNREACHABLE";
94a15aa7d426972daecc0e8cd31dcf4d6bc656f1e9Filip Gruszczynski            default:
95639c8becc6d0efe9c205f3abf1e9347464a95020Michael Wright                return "UNKNOWN";
965d7170963ac0cfa30400292841c3673b8cdea5b5Julius D'souza        }
975d7170963ac0cfa30400292841c3673b8cdea5b5Julius D'souza    }
985d7170963ac0cfa30400292841c3673b8cdea5b5Julius D'souza
995d7170963ac0cfa30400292841c3673b8cdea5b5Julius D'souza    private SipErrorCode() {
1005d7170963ac0cfa30400292841c3673b8cdea5b5Julius D'souza    }
1015d7170963ac0cfa30400292841c3673b8cdea5b5Julius D'souza}
1025d7170963ac0cfa30400292841c3673b8cdea5b5Julius D'souza