[ekiga] Add back and improve failure indication when sending instant messages



commit 6eb6995892c492261209b927c9d427906255b9e9
Author: Eugen Dedu <Eugen Dedu pu-pm univ-fcomte fr>
Date:   Sat Jun 4 13:13:10 2011 +0200

    Add back and improve failure indication when sending instant messages
    
    It was removed with commit 10015db.

 lib/engine/components/opal/sip-endpoint.cpp |   28 +++++++++++++++++++++++++-
 lib/engine/components/opal/sip-endpoint.h   |    3 ++
 2 files changed, 29 insertions(+), 2 deletions(-)
---
diff --git a/lib/engine/components/opal/sip-endpoint.cpp b/lib/engine/components/opal/sip-endpoint.cpp
index 39a0aaf..d01f4e9 100644
--- a/lib/engine/components/opal/sip-endpoint.cpp
+++ b/lib/engine/components/opal/sip-endpoint.cpp
@@ -898,6 +898,31 @@ Opal::Sip::EndPoint::OnReceivedMESSAGE (OpalTransport & transport,
 }
 
 
+void
+Opal::Sip::EndPoint::OnMESSAGECompleted (const SIPMessage::Params & params,
+                                         SIP_PDU::StatusCodes reason)
+{
+  PTRACE (4, "IM sending completed, reason: " << reason);
+
+  // after TemporarilyUnavailable, RequestTimeout appears too, hence do not process it too
+  if (reason == SIP_PDU::Successful_OK || reason == SIP_PDU::Failure_RequestTimeout)
+    return;
+
+  SIPURL to = params.m_remoteAddress;
+  to.Sanitise (SIPURL::ToURI);
+  std::string uri = (const char*) to.AsString ();
+  std::string display_name = (const char*) to.GetDisplayName ();
+
+  std::string reason_shown = _("Could not send message");
+  if (reason == SIP_PDU::Failure_TemporarilyUnavailable)
+    reason_shown += _(": user offline");
+  else
+    reason_shown += SIP_PDU::GetStatusCodeDescription (reason);  // too many to translate them with _()...
+
+  Ekiga::Runtime::run_in_main (boost::bind (&Opal::Sip::EndPoint::push_notice_in_main, this, uri, display_name, reason_shown));
+}
+
+
 SIPURL
 Opal::Sip::EndPoint::GetRegisteredPartyName (const SIPURL & aor,
 					     const OpalTransport & transport)
@@ -908,8 +933,7 @@ Opal::Sip::EndPoint::GetRegisteredPartyName (const SIPURL & aor,
   if (!local_aor.empty ())
     return local_aor.c_str ();
 
-  /* As a last resort, use the local address
-   */
+  // as a last resort, use the local address
   return GetDefaultRegisteredPartyName (transport);
 }
 
diff --git a/lib/engine/components/opal/sip-endpoint.h b/lib/engine/components/opal/sip-endpoint.h
index 2113a82..d254bde 100644
--- a/lib/engine/components/opal/sip-endpoint.h
+++ b/lib/engine/components/opal/sip-endpoint.h
@@ -169,6 +169,9 @@ namespace Opal {
       bool OnReceivedMESSAGE (OpalTransport & transport,
                               SIP_PDU & pdu);
 
+      void OnMESSAGECompleted (const SIPMessage::Params & params,
+                               SIP_PDU::StatusCodes reason);
+
       SIPURL GetRegisteredPartyName (const SIPURL & host,
 				     const OpalTransport & transport);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]