Commit b7b409e0 authored by Ghislain MARY's avatar Ghislain MARY

Put error info code in its own files.

parent 6ee6437b
......@@ -76,6 +76,7 @@ set(LINPHONE_SOURCE_FILES_C
ec-calibrator.c
echo-tester.c
enum.c
error_info.c
event.c
friend.c
friendlist.c
......
......@@ -43,6 +43,7 @@ liblinphone_la_SOURCES=\
ec-calibrator.c \
echo-tester.c \
enum.c enum.h \
error_info.c \
event.c \
friend.c \
friendlist.c \
......
/*
error_info.c
Copyright (C) 2016 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "linphone/core.h"
#include "private.h"
const char *linphone_reason_to_string(LinphoneReason err){
switch(err) {
case LinphoneReasonNone:
return "No error";
case LinphoneReasonNoResponse:
return "No response";
case LinphoneReasonForbidden:
return "Bad credentials";
case LinphoneReasonDeclined:
return "Call declined";
case LinphoneReasonNotFound:
return "User not found";
case LinphoneReasonNotAnswered:
return "Not answered";
case LinphoneReasonBusy:
return "Busy";
case LinphoneReasonMedia:
return "Incompatible media capabilities";
case LinphoneReasonIOError:
return "IO error";
case LinphoneReasonDoNotDisturb:
return "Do not disturb";
case LinphoneReasonUnauthorized:
return "Unauthorized";
case LinphoneReasonNotAcceptable:
return "Not acceptable here";
case LinphoneReasonNoMatch:
return "No match";
case LinphoneReasonMovedPermanently:
return "Moved permanently";
case LinphoneReasonGone:
return "Gone";
case LinphoneReasonTemporarilyUnavailable:
return "Temporarily unavailable";
case LinphoneReasonAddressIncomplete:
return "Address incomplete";
case LinphoneReasonNotImplemented:
return "Not implemented";
case LinphoneReasonBadGateway:
return "Bad gateway";
case LinphoneReasonServerTimeout:
return "Server timeout";
case LinphoneReasonUnknown:
return "Unknown error";
}
return "unknown error";
}
LinphoneReason linphone_error_code_to_reason(int err) {
switch (err) {
case 200:
return LinphoneReasonNone;
case 301:
return LinphoneReasonMovedPermanently;
case 400:
return LinphoneReasonUnknown;
case 401:
return LinphoneReasonUnauthorized;
case 403:
return LinphoneReasonForbidden;
case 404:
return LinphoneReasonNotFound;
case 410:
return LinphoneReasonGone;
case 415:
return LinphoneReasonUnsupportedContent;
case 480:
return LinphoneReasonTemporarilyUnavailable;
case 481:
return LinphoneReasonNoMatch;
case 484:
return LinphoneReasonAddressIncomplete;
case 486:
return LinphoneReasonBusy;
case 488:
return LinphoneReasonNotAcceptable;
case 501:
return LinphoneReasonNotImplemented;
case 502:
return LinphoneReasonBadGateway;
case 503:
return LinphoneReasonIOError;
case 504:
return LinphoneReasonServerTimeout;
case 600:
return LinphoneReasonDoNotDisturb;
case 603:
return LinphoneReasonDeclined;
}
return LinphoneReasonUnknown;
}
LinphoneReason linphone_error_info_get_reason(const LinphoneErrorInfo *ei) {
const SalErrorInfo *sei = (const SalErrorInfo *)ei;
return linphone_reason_from_sal(sei->reason);
}
const char *linphone_error_info_get_phrase(const LinphoneErrorInfo *ei) {
const SalErrorInfo *sei = (const SalErrorInfo *)ei;
return sei->status_string;
}
const char *linphone_error_info_get_details(const LinphoneErrorInfo *ei) {
const SalErrorInfo *sei = (const SalErrorInfo *)ei;
return sei->warnings;
}
int linphone_error_info_get_protocol_code(const LinphoneErrorInfo *ei) {
const SalErrorInfo *sei = (const SalErrorInfo *)ei;
return sei->protocol_code;
}
/*
ImEncryptionEgine.c
im_encryption_engine.c
Copyright (C) 2016 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
......
......@@ -6252,101 +6252,6 @@ LinphoneCallParams *linphone_core_create_call_params(LinphoneCore *lc, LinphoneC
return NULL;
}
const char *linphone_reason_to_string(LinphoneReason err){
switch(err){
case LinphoneReasonNone:
return "No error";
case LinphoneReasonNoResponse:
return "No response";
case LinphoneReasonForbidden:
return "Bad credentials";
case LinphoneReasonDeclined:
return "Call declined";
case LinphoneReasonNotFound:
return "User not found";
case LinphoneReasonNotAnswered:
return "Not answered";
case LinphoneReasonBusy:
return "Busy";
case LinphoneReasonMedia:
return "Incompatible media capabilities";
case LinphoneReasonIOError:
return "IO error";
case LinphoneReasonDoNotDisturb:
return "Do not disturb";
case LinphoneReasonUnauthorized:
return "Unauthorized";
case LinphoneReasonNotAcceptable:
return "Not acceptable here";
case LinphoneReasonNoMatch:
return "No match";
case LinphoneReasonMovedPermanently:
return "Moved permanently";
case LinphoneReasonGone:
return "Gone";
case LinphoneReasonTemporarilyUnavailable:
return "Temporarily unavailable";
case LinphoneReasonAddressIncomplete:
return "Address incomplete";
case LinphoneReasonNotImplemented:
return "Not implemented";
case LinphoneReasonBadGateway:
return "Bad gateway";
case LinphoneReasonServerTimeout:
return "Server timeout";
case LinphoneReasonUnknown:
return "Unknown error";
}
return "unknown error";
}
LinphoneReason linphone_error_code_to_reason(int err) {
if (err == 200) {
return LinphoneReasonNone;
} else if (err == 503) {
return LinphoneReasonIOError;
} else if (err == 400) {
return LinphoneReasonUnknown;
} else if (err == 486) {
return LinphoneReasonBusy;
} else if (err == 603) {
return LinphoneReasonDeclined;
} else if (err == 600) {
return LinphoneReasonDoNotDisturb;
} else if (err == 403) {
return LinphoneReasonForbidden;
} else if (err == 415) {
return LinphoneReasonUnsupportedContent;
} else if (err == 404) {
return LinphoneReasonNotFound;
} else if (err == 480) {
return LinphoneReasonTemporarilyUnavailable;
} else if (err == 401) {
return LinphoneReasonUnauthorized;
} else if (err == 488) {
return LinphoneReasonNotAcceptable;
} else if (err == 481) {
return LinphoneReasonNoMatch;
} else if (err == 301) {
return LinphoneReasonMovedPermanently;
} else if (err == 410) {
return LinphoneReasonGone;
} else if (err == 484) {
return LinphoneReasonAddressIncomplete;
} else if (err == 501) {
return LinphoneReasonNotImplemented;
} else if (err == 504) {
return LinphoneReasonServerTimeout;
} else if (err == 502) {
return LinphoneReasonBadGateway;
}
return LinphoneReasonUnknown;
}
const char *linphone_error_to_string(LinphoneReason err){
return linphone_reason_to_string(err);
}
void linphone_core_enable_keep_alive(LinphoneCore* lc,bool_t enable) {
#ifdef BUILD_UPNP
if (linphone_core_get_firewall_policy(lc)==LinphonePolicyUseUpnp) {
......
......@@ -1237,52 +1237,6 @@ LinphoneReason linphone_reason_from_sal(SalReason r){
return ret;
}
/**
* Get reason code from the error info.
* @param ei the error info.
* @return a #LinphoneReason
* @ingroup misc
**/
LinphoneReason linphone_error_info_get_reason(const LinphoneErrorInfo *ei){
const SalErrorInfo *sei=(const SalErrorInfo*)ei;
return linphone_reason_from_sal(sei->reason);
}
/**
* Get textual phrase from the error info.
* This is the text that is provided by the peer in the protocol (SIP).
* @param ei the error info.
* @return the error phrase
* @ingroup misc
**/
const char *linphone_error_info_get_phrase(const LinphoneErrorInfo *ei){
const SalErrorInfo *sei=(const SalErrorInfo*)ei;
return sei->status_string;
}
/**
* Provides additional information regarding the failure.
* With SIP protocol, the "Reason" and "Warning" headers are returned.
* @param ei the error info.
* @return more details about the failure.
* @ingroup misc
**/
const char *linphone_error_info_get_details(const LinphoneErrorInfo *ei){
const SalErrorInfo *sei=(const SalErrorInfo*)ei;
return sei->warnings;
}
/**
* Get the status code from the low level protocol (ex a SIP status code).
* @param ei the error info.
* @return the status code.
* @ingroup misc
**/
int linphone_error_info_get_protocol_code(const LinphoneErrorInfo *ei){
const SalErrorInfo *sei=(const SalErrorInfo*)ei;
return sei->protocol_code;
}
/**
* Set the name of the mediastreamer2 filter to be used for rendering video.
* This is for advanced users of the library, mainly to workaround hardware/driver bugs.
......
......@@ -32,6 +32,7 @@ set(HEADER_FILES
content.h
core.h
core_utils.h
error_info.h
event.h
friend.h
friendlist.h
......
......@@ -12,6 +12,7 @@ linphone_include_HEADERS=\
content.h \
core.h \
core_utils.h \
error_info.h \
event.h \
friend.h \
friendlist.h \
......
......@@ -158,67 +158,7 @@ struct _LinphoneCall;
**/
typedef struct _LinphoneCall LinphoneCall;
/**
* Enum describing various failure reasons or contextual information for some events.
* @see linphone_call_get_reason()
* @see linphone_proxy_config_get_error()
* @see linphone_error_info_get_reason()
* @ingroup misc
**/
enum _LinphoneReason{
LinphoneReasonNone,
LinphoneReasonNoResponse, /**<No response received from remote*/
LinphoneReasonForbidden, /**<Authentication failed due to bad credentials or resource forbidden*/
LinphoneReasonDeclined, /**<The call has been declined*/
LinphoneReasonNotFound, /**<Destination of the call was not found.*/
LinphoneReasonNotAnswered, /**<The call was not answered in time (request timeout)*/
LinphoneReasonBusy, /**<Phone line was busy */
LinphoneReasonUnsupportedContent, /**<Unsupported content */
LinphoneReasonIOError, /**<Transport error: connection failures, disconnections etc...*/
LinphoneReasonDoNotDisturb, /**<Do not disturb reason*/
LinphoneReasonUnauthorized, /**<Operation is unauthorized because missing credential*/
LinphoneReasonNotAcceptable, /**<Operation is rejected due to incompatible or unsupported media parameters*/
LinphoneReasonNoMatch, /**<Operation could not be executed by server or remote client because it didn't have any context for it*/
LinphoneReasonMovedPermanently, /**<Resource moved permanently*/
LinphoneReasonGone, /**<Resource no longer exists*/
LinphoneReasonTemporarilyUnavailable, /**<Temporarily unavailable*/
LinphoneReasonAddressIncomplete, /**<Address incomplete*/
LinphoneReasonNotImplemented, /**<Not implemented*/
LinphoneReasonBadGateway, /**<Bad gateway*/
LinphoneReasonServerTimeout, /**<Server timeout*/
LinphoneReasonUnknown /**Unknown reason*/
};
#define LinphoneReasonBadCredentials LinphoneReasonForbidden
/*for compatibility*/
#define LinphoneReasonMedia LinphoneReasonUnsupportedContent
/**
* Enum describing failure reasons.
* @ingroup misc
**/
typedef enum _LinphoneReason LinphoneReason;
/**
* Converts a LinphoneReason enum to a string.
* @ingroup misc
**/
LINPHONE_PUBLIC const char *linphone_reason_to_string(LinphoneReason err);
/**
* Converts a error code to a LinphoneReason.
* @ingroup misc
**/
LINPHONE_PUBLIC LinphoneReason linphone_error_code_to_reason(int err);
/**
* Object representing full details about a signaling error or status.
* All LinphoneErrorInfo object returned by the liblinphone API are readonly and transcients. For safety they must be used immediately
* after obtaining them. Any other function call to the liblinphone may change their content or invalidate the pointer.
* @ingroup misc
**/
typedef struct _LinphoneErrorInfo LinphoneErrorInfo;
#include "linphone/error_info.h"
/**
* Enum describing the authentication methods
......@@ -235,11 +175,6 @@ enum _LinphoneAuthMethod {
**/
typedef enum _LinphoneAuthMethod LinphoneAuthMethod;
LINPHONE_PUBLIC LinphoneReason linphone_error_info_get_reason(const LinphoneErrorInfo *ei);
LINPHONE_PUBLIC const char *linphone_error_info_get_phrase(const LinphoneErrorInfo *ei);
LINPHONE_PUBLIC const char *linphone_error_info_get_details(const LinphoneErrorInfo *ei);
LINPHONE_PUBLIC int linphone_error_info_get_protocol_code(const LinphoneErrorInfo *ei);
/* linphone dictionary */
LINPHONE_PUBLIC LinphoneDictionary* linphone_dictionary_new(void);
LINPHONE_PUBLIC LinphoneDictionary * linphone_dictionary_clone(const LinphoneDictionary* src);
......@@ -3381,6 +3316,7 @@ LINPHONE_PUBLIC const bctbx_list_t *linphone_core_get_auth_info_list(const Linph
* @param username the SIP username to be authenticated (mandatory)
* @param sip_domain the SIP domain name (optional)
* @return a #LinphoneAuthInfo
* @ingroup authentication
**/
LINPHONE_PUBLIC const LinphoneAuthInfo *linphone_core_find_auth_info(LinphoneCore *lc, const char *realm, const char *username, const char *sip_domain);
......
/*
error_info.h
Copyright (C) 2016 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef LINPHONE_ERROR_INFO_H
#define LINPHONE_ERROR_INFO_H
/**
* @addtogroup misc
* @{
*/
/**
* Enum describing various failure reasons or contextual information for some events.
* @see linphone_call_get_reason()
* @see linphone_proxy_config_get_error()
* @see linphone_error_info_get_reason()
**/
enum _LinphoneReason{
LinphoneReasonNone,
LinphoneReasonNoResponse, /**< No response received from remote */
LinphoneReasonForbidden, /**< Authentication failed due to bad credentials or resource forbidden */
LinphoneReasonDeclined, /**< The call has been declined */
LinphoneReasonNotFound, /**< Destination of the call was not found */
LinphoneReasonNotAnswered, /**< The call was not answered in time (request timeout) */
LinphoneReasonBusy, /**< Phone line was busy */
LinphoneReasonUnsupportedContent, /**< Unsupported content */
LinphoneReasonIOError, /**< Transport error: connection failures, disconnections etc... */
LinphoneReasonDoNotDisturb, /**< Do not disturb reason */
LinphoneReasonUnauthorized, /**< Operation is unauthorized because missing credential */
LinphoneReasonNotAcceptable, /**< Operation is rejected due to incompatible or unsupported media parameters */
LinphoneReasonNoMatch, /**< Operation could not be executed by server or remote client because it didn't have any context for it */
LinphoneReasonMovedPermanently, /**< Resource moved permanently */
LinphoneReasonGone, /**< Resource no longer exists */
LinphoneReasonTemporarilyUnavailable, /**< Temporarily unavailable */
LinphoneReasonAddressIncomplete, /**< Address incomplete */
LinphoneReasonNotImplemented, /**< Not implemented */
LinphoneReasonBadGateway, /**< Bad gateway */
LinphoneReasonServerTimeout, /**< Server timeout */
LinphoneReasonUnknown /**< Unknown reason */
};
#define LinphoneReasonBadCredentials LinphoneReasonForbidden
/*for compatibility*/
#define LinphoneReasonMedia LinphoneReasonUnsupportedContent
/**
* Enum describing failure reasons.
**/
typedef enum _LinphoneReason LinphoneReason;
/**
* Converts a LinphoneReason enum to a string.
* @param[in] err A #LinphoneReason
* @return The string representation of the specified LinphoneReason
**/
LINPHONE_PUBLIC const char *linphone_reason_to_string(LinphoneReason err);
/**
* Converts a error code to a LinphoneReason.
* @param[in] err An error code
* @return The LinphoneReason corresponding to the specified error code
**/
LINPHONE_PUBLIC LinphoneReason linphone_error_code_to_reason(int err);
/**
* Object representing full details about a signaling error or status.
* All LinphoneErrorInfo object returned by the liblinphone API are readonly and transcients. For safety they must be used immediately
* after obtaining them. Any other function call to the liblinphone may change their content or invalidate the pointer.
**/
typedef struct _LinphoneErrorInfo LinphoneErrorInfo;
/**
* Get reason code from the error info.
* @param[in] ei ErrorInfo object
* @return A #LinphoneReason
**/
LINPHONE_PUBLIC LinphoneReason linphone_error_info_get_reason(const LinphoneErrorInfo *ei);
/**
* Get textual phrase from the error info.
* This is the text that is provided by the peer in the protocol (SIP).
* @param[in] ei ErrorInfo object
* @return The error phrase
**/
LINPHONE_PUBLIC const char * linphone_error_info_get_phrase(const LinphoneErrorInfo *ei);
/**
* Provides additional information regarding the failure.
* With SIP protocol, the "Reason" and "Warning" headers are returned.
* @param[in] ei ErrorInfo object
* @return More details about the failure
**/
LINPHONE_PUBLIC const char * linphone_error_info_get_details(const LinphoneErrorInfo *ei);
/**
* Get the status code from the low level protocol (ex a SIP status code).
* @param[in] ei ErrorInfo object
* @return The status code
**/
LINPHONE_PUBLIC int linphone_error_info_get_protocol_code(const LinphoneErrorInfo *ei);
/**
* @}
*/
#endif /* LINPHONE_ERROR_INFO_H */
/*
ImEncryptionEgine.h
im_encryption_engine.h
Copyright (C) 2016 Belledonne Communications SARL
This program is free software; you can redistribute it and/or
......@@ -17,8 +17,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef IM_ENCRYPTION_ENGINE_H
#define IM_ENCRYPTION_ENGINE_H
#ifndef LINPHONE_IM_ENCRYPTION_ENGINE_H
#define LINPHONE_IM_ENCRYPTION_ENGINE_H
#include <mediastreamer2/mscommon.h>
......@@ -254,4 +254,4 @@ LINPHONE_PUBLIC void linphone_im_encryption_engine_cbs_set_generate_file_transfe
* @}
*/
#endif /* IM_ENCRYPTION_ENGINE_H */
#endif /* LINPHONE_IM_ENCRYPTION_ENGINE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment