Bug 95718 - Can't import feed on www.lwn.net
Summary: Can't import feed on www.lwn.net
Status: RESOLVED FIXED
Alias: None
Product: akregator
Classification: Applications
Component: akregator konqueror plugin (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-23 14:27 UTC by Ismail Donmez
Modified: 2004-12-23 14:46 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ismail Donmez 2004-12-23 14:27:09 UTC
Version:            (using KDE Devel)
Compiler:          gcc 3.4.3 
OS:                Linux

Go to http://www.lwn.net and try importing feed to aKregator. Notice that it fails.
Comment 1 Teemu Rytilahti 2004-12-23 14:46:42 UTC
CVS commit by rytilahti: 

Use fixRelativeURL() of konq menu plugin
BUG:95718


  M +2 -2      akregatorplugin.cpp   1.20
  M +4 -4      konqfeedicon.cpp   1.18
  M +28 -8     pluginbase.cpp   1.2
  M +1 -1      pluginbase.h   1.2


--- kdeaddons/konq-plugins/akregator/akregatorplugin.cpp  #1.19:1.20
@@ -120,7 +120,7 @@ void AkregatorMenu::slotAddFeed()
 {
     if(akregatorRunning())
-        addFeedViaDCOP(fixRelativeURL(m_part, m_feedURL));
+        addFeedViaDCOP(fixRelativeURL(m_feedURL, m_part->baseURL()));
     else
-        addFeedViaCmdLine(fixRelativeURL(m_part, m_feedURL));
+        addFeedViaCmdLine(fixRelativeURL(m_feedURL, m_part->baseURL()));
 }
 

--- kdeaddons/konq-plugins/akregator/konqfeedicon.cpp  #1.17:1.18
@@ -136,7 +136,7 @@ void KonqFeedIcon::addFeed(int id)
 {
     if(akregatorRunning())
-        addFeedViaDCOP(fixRelativeURL(m_part, m_feedList[id].url()));
+        addFeedViaDCOP(fixRelativeURL(m_feedList[id].url(), m_part->baseURL()));
     else
-        addFeedViaCmdLine(fixRelativeURL(m_part, m_feedList[id].url()));
+        addFeedViaCmdLine(fixRelativeURL(m_feedList[id].url(), m_part->baseURL()));
 }
 
@@ -146,5 +146,5 @@ void KonqFeedIcon::addFeeds()
     if(akregatorRunning()) {
         for ( FeedDetectorEntryList::Iterator it = m_feedList.begin(); it != m_feedList.end(); ++it )
-            addFeedViaDCOP(fixRelativeURL(m_part, (*it).url()));
+            addFeedViaDCOP(fixRelativeURL((*it).url(), m_part->baseURL()));
     }
     else {
@@ -153,5 +153,5 @@ void KonqFeedIcon::addFeeds()
 
         for ( FeedDetectorEntryList::Iterator it = m_feedList.begin(); it != m_feedList.end(); ++it ) {
-            *proc << "-a" << fixRelativeURL(m_part, (*it).url());
+            *proc << "-a" << fixRelativeURL((*it).url(), m_part->baseURL());
         }
 

--- kdeaddons/konq-plugins/akregator/pluginbase.cpp  #1.1:1.2
@@ -50,12 +50,32 @@ void PluginBase::addFeedViaCmdLine(QStri
 }
 
-QString PluginBase::fixRelativeURL(KHTMLPart *part, QString url)
+// handle all the wild stuff that KURL doesn't handle
+QString PluginBase::fixRelativeURL(const QString &s, const KURL &baseurl)
 {
-    KURL finalURL(url);
-    if(finalURL.protocol() != "file") return url;
-    /*kdDebug() << "procotol: " << finalURL.protocol() << endl
-    << "baseurl: " << m_part->baseURL() << endl;*/
-    finalURL.setProtocol(part->baseURL().protocol());
-    //kdDebug() << "final url: " << finalURL << endl;
-    return finalURL.url();
+    QString s2=s;
+    KURL u;
+    if (KURL::isRelativeURL(s2))
+    {
+        if (s2.startsWith("//"))
+        {
+            s2=s2.prepend(baseurl.protocol()+":");
+            u=s2;
+        }
+        else if (s2.startsWith("/"))
+        {
+            u=baseurl;
+            u.setPath(s2);
+        }
+        else
+        {
+            u=baseurl;
+            u.addPath(s2);
+        }
+        u.cleanPath();
+    }
+    else
+        u=s2;
+
+    u.cleanPath();
+    return u.url();
 }

--- kdeaddons/konq-plugins/akregator/pluginbase.h  #1.1:1.2
@@ -36,5 +36,5 @@ class PluginBase
          */
         void addFeedViaCmdLine(QString url);
-        QString fixRelativeURL(KHTMLPart *part, QString url);
+        QString fixRelativeURL(const QString &s, const KURL &baseurl);
 };