diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2012-04-05 20:38:52 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2012-04-05 20:38:52 -0400 |
commit | 86f1d77943a377053f06d898767535f36a3f0a24 (patch) | |
tree | 186ba0fde408f03b723ffdbeeb00ffbd1b1c9c28 /rakia | |
parent | b82012fae3c5a5425b5ae1784e15c9a0ed029f5b (diff) |
Transform TP reason into appropriate SIP reasons
Diffstat (limited to 'rakia')
-rw-r--r-- | rakia/call-channel.c | 65 |
1 files changed, 59 insertions, 6 deletions
diff --git a/rakia/call-channel.c b/rakia/call-channel.c index 11eee5a..51267f2 100644 --- a/rakia/call-channel.c +++ b/rakia/call-channel.c @@ -22,12 +22,15 @@ #include "rakia/call-channel.h" +#include <string.h> + #include "rakia/call-content.h" #include "rakia/sip-session.h" #define DEBUG_FLAG RAKIA_DEBUG_CALL #include "rakia/debug.h" + #include <telepathy-glib/exportable-channel.h> @@ -53,7 +56,7 @@ static TpBaseCallContent * rakia_call_channel_add_content ( GError **error); static void rakia_call_channel_hangup ( TpBaseCallChannel *base, - guint reason, + TpCallStateChangeReason reason, const gchar *detailed_reason, const gchar *message); static void rakia_call_channel_set_ringing (TpBaseCallChannel *base); @@ -389,16 +392,66 @@ rakia_call_channel_add_content ( static void rakia_call_channel_hangup ( TpBaseCallChannel *base, - guint reason, + TpCallStateChangeReason reason, const gchar *detailed_reason, const gchar *message) { RakiaCallChannel *self = RAKIA_CALL_CHANNEL (base); RakiaCallChannelPrivate *priv = self->priv; - - /* FIXME: We need to convert the dbus reason into a SIP status code */ - - rakia_sip_session_terminate (priv->session, 480, "Terminated"); + guint status = 486; + const gchar *sipmessage; + + switch (reason) { + break; + case TP_CALL_STATE_CHANGE_REASON_NO_ANSWER: + status = 480; + sipmessage = "No answer"; + break; + case TP_CALL_STATE_CHANGE_REASON_INVALID_CONTACT: + sipmessage = "Not Found"; + break; + case TP_CALL_STATE_CHANGE_REASON_PERMISSION_DENIED: + sipmessage = "Permission denied"; + break; + case TP_CALL_STATE_CHANGE_REASON_REJECTED: + sipmessage = "Rejected"; + break; + case TP_CALL_STATE_CHANGE_REASON_BUSY: + sipmessage = "Busy"; + break; + case TP_CALL_STATE_CHANGE_REASON_INTERNAL_ERROR: + status = 480; + sipmessage = "Internal Error"; + break; + case TP_CALL_STATE_CHANGE_REASON_SERVICE_ERROR: + sipmessage = "Service Error"; + break; + case TP_CALL_STATE_CHANGE_REASON_NETWORK_ERROR: + status = 480; + sipmessage = "Network error"; + break; + case TP_CALL_STATE_CHANGE_REASON_MEDIA_ERROR: + status = 488; + if (!strcmp (detailed_reason, TP_ERROR_STR_MEDIA_UNSUPPORTED_TYPE)) + sipmessage = "Unsupported type"; + else if (!strcmp (detailed_reason, TP_ERROR_STR_MEDIA_CODECS_INCOMPATIBLE)) + sipmessage = "Codecs Incompatible"; + else + sipmessage = "Media error"; + break; + case TP_CALL_STATE_CHANGE_REASON_CONNECTIVITY_ERROR: + sipmessage = "Connectivity Error"; + break; + case TP_CALL_STATE_CHANGE_REASON_USER_REQUESTED: + sipmessage = "User ended call"; + break; + case TP_CALL_STATE_CHANGE_REASON_PROGRESS_MADE: + case TP_CALL_STATE_CHANGE_REASON_UNKNOWN: + default: + sipmessage = "Terminated by unknown reason"; + } + + rakia_sip_session_terminate (priv->session, status, sipmessage); } static void |