ekiga r6030 - in trunk: . src/endpoints



Author: dsandras
Date: Tue Mar  4 21:52:26 2008
New Revision: 6030
URL: http://svn.gnome.org/viewvc/ekiga?rev=6030&view=rev

Log:
Fixed account registration/unregistration.
Fixed default outgoing identity : 
- use the registered account as outgoing identity
when calling users corresponding to that account
or
- use the default account if no corresponding registered account
or
- use the local IP address if we are exchanging messages with somebody
on the local LAN and in all other cases.

That ensures that if we are registered to a local PBX, we are always
using that identity when calling local users on the same LAN. If we
are not registered to a local PBX, then we prefer using local IP
addressing than a default registered account to which the remote user
could not reply.


Modified:
   trunk/ChangeLog
   trunk/src/endpoints/sip.cpp

Modified: trunk/src/endpoints/sip.cpp
==============================================================================
--- trunk/src/endpoints/sip.cpp	(original)
+++ trunk/src/endpoints/sip.cpp	Tue Mar  4 21:52:26 2008
@@ -498,11 +498,18 @@
 
 
 void
-GMSIPEndpoint::OnRegistrationFailed (const PString & aor,
+GMSIPEndpoint::OnRegistrationFailed (const PString & _aor,
                                      SIP_PDU::StatusCodes r,
                                      bool wasRegistering)
 {
+  std::stringstream strm;
   std::string info;
+  std::string aor = (const char *) _aor;
+
+  if (aor.find (uri_prefix) == std::string::npos) 
+    strm << uri_prefix << aor;
+  else
+    strm << aor;
 
   switch (r) {
 
@@ -590,10 +597,10 @@
   }
 
   /* Signal the OpalManager */
-  endpoint.OnRegistrationFailed (aor, wasRegistering, info);
+  endpoint.OnRegistrationFailed (strm.str ().c_str (), wasRegistering, info);
 
   /* Signal the SIP Endpoint */
-  SIPEndPoint::OnRegistrationFailed (aor, r, wasRegistering);
+  SIPEndPoint::OnRegistrationFailed (strm.str ().c_str (), r, wasRegistering);
 }
 
 
@@ -736,34 +743,38 @@
   PString url;
   SIPURL registration_address;
 
+  /* If we are registered to an account corresponding to host, use it.
+   */
   PSafePtr<SIPHandler> info = activeSIPHandlers.FindSIPHandlerByDomain(host.GetHostName (), SIP_PDU::Method_REGISTER, PSafeReadOnly);
+  if (info != NULL) {
 
-  if (info != NULL)
-    registration_address = info->GetTargetAddress();
-
-  // If we are not exchanging messages with a local party, use the default account
-  // otherwise, use a direct call address in the from field
-  if (host.GetHostAddress ().GetIpAndPort (address, port) && !manager.IsLocalAddress (address)) {
+    return SIPURL ("\"" + GetDefaultDisplayName () + "\" <" + info->GetTargetAddress ().AsString () + ">");
+  }
+  else {
 
-    account = gnomemeeting_get_default_account ("SIP");
-    if (account && account->enabled) {
+    /* If we are not registered to host, 
+     * then use the default account as outgoing identity.
+     * If we are exchanging messages with a peer on our network,
+     * then do not use the default account as outgoing identity.
+     */
+    if (host.GetHostAddress ().GetIpAndPort (address, port) && !manager.IsLocalAddress (address)) {
 
-      if (info == NULL || registration_address.GetHostName () == account->host) {
+      account = gnomemeeting_get_default_account ("SIP");
+      if (account && account->enabled) {
 
         if (PString(account->username).Find("@") == P_MAX_INDEX)
           url = PString (account->username) + "@" + PString (account->host);
         else
           url = PString (account->username);
 
-        return url;
+        return SIPURL ("\"" + GetDefaultDisplayName () + "\" <" + url + ">");
       }
     }
   }
 
-  if (!manager.IsLocalAddress (address))
-    return SIPEndPoint::GetRegisteredPartyName (host);
-
-  // Not found (or local party)
+  /* As a last resort, ie not registered to host, no default account or
+   * dialog with a local peer, then use the local address 
+   */
   local_address = GetListeners()[0].GetLocalAddress();
 
   PINDEX j = local_address.Find ('$');



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