Update of /cvsroot/mahogany/M/src/classes
In directory usw-pr-cvs1:/tmp/cvs-serv17955/src/classes

Modified Files:
        MessageView.cpp 
Log Message:
detect wrapped URLs (bug 525)

Index: MessageView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/MessageView.cpp,v
retrieving revision 1.84
retrieving revision 1.85
diff -b -u -2 -r1.84 -r1.85
--- MessageView.cpp     25 Apr 2002 18:27:18 -0000      1.84
+++ MessageView.cpp     25 Apr 2002 18:52:43 -0000      1.85
@@ -2662,18 +2662,37 @@
       case ClickableInfo::CI_URL:
       {
-         wxString url = ci->GetUrl();
+         // URL taken from the text may contain the line breaks if it had been
+         // broken so remove them
+         wxString url;
+         url.reserve(ci->GetUrl().length());
+         for ( const char *p = ci->GetUrl().c_str(); *p; p++ )
+         {
+            if ( *p != '\r' && *p != '\n' )
+               url += *p;
+         }
 
-         // treat mail urls separately:
+         // treat mail urls separately: we handle them ourselves
          wxString protocol = url.BeforeFirst(':');
-         if ( protocol == "mailto" )
+         if ( protocol == url )
          {
-            Composer *cv = Composer::CreateNewMessage(GetProfile());
+            protocol.clear();
+         }
 
-            cv->SetAddresses(ci->GetUrl().Right(ci->GetUrl().Length()-7));
-            cv->InitText();
+         if ( protocol == "mailto" ||
+               (protocol.empty() && url.find('@') != String::npos) )
+         {
+            Composer *cv = Composer::CreateNewMessage(GetProfile());
 
-            break;
+            String address = url;
+            if ( !protocol.empty() )
+            {
+               address.erase(0, 7); // 7 == strlen("mailto:";)
          }
 
+            cv->SetAddresses(address);
+            cv->InitText();
+         }
+         else // not mailto URL
+         {
          if ( id == WXMENU_LAYOUT_RCLICK )
          {
@@ -2683,4 +2702,5 @@
          {
             OpenURL(url, m_ProfileValues.browserInNewWindow);
+            }
          }
       }


_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to