diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index c69773f8c..3fefc23ff 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -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 diff --git a/coreapi/Makefile.am b/coreapi/Makefile.am index 3a7b6e835..5c03c9f7e 100644 --- a/coreapi/Makefile.am +++ b/coreapi/Makefile.am @@ -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 \ diff --git a/coreapi/error_info.c b/coreapi/error_info.c new file mode 100644 index 000000000..5ebab0a8f --- /dev/null +++ b/coreapi/error_info.c @@ -0,0 +1,135 @@ +/* +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; +} diff --git a/coreapi/im_encryption_engine.c b/coreapi/im_encryption_engine.c index 16e7b8c09..c09406e6e 100644 --- a/coreapi/im_encryption_engine.c +++ b/coreapi/im_encryption_engine.c @@ -1,5 +1,5 @@ /* -ImEncryptionEgine.c +im_encryption_engine.c Copyright (C) 2016 Belledonne Communications SARL This program is free software; you can redistribute it and/or diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index c7f7c554f..a91ccbb53 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -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) { diff --git a/coreapi/misc.c b/coreapi/misc.c index 125d632f1..6eaacc70d 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -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. diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 569216e78..cd7b3c129 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -32,6 +32,7 @@ set(HEADER_FILES content.h core.h core_utils.h + error_info.h event.h friend.h friendlist.h diff --git a/include/linphone/Makefile.am b/include/linphone/Makefile.am index 8e3d41917..f8d31657d 100644 --- a/include/linphone/Makefile.am +++ b/include/linphone/Makefile.am @@ -12,6 +12,7 @@ linphone_include_HEADERS=\ content.h \ core.h \ core_utils.h \ + error_info.h \ event.h \ friend.h \ friendlist.h \ diff --git a/include/linphone/core.h b/include/linphone/core.h index 3199f7826..e6991957a 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.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, /** @@ -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 */