27#include <tqstringlist.h> 
   28#include <tqvaluelist.h> 
   32#include "feeddetector.h" 
   37FeedDetectorEntryList FeedDetector::extractFromLinkTags(
const TQString& s)  
 
   40    TQString str = s.simplifyWhiteSpace();
 
   43    TQRegExp reLinkTag(
"<[\\s]?LINK[^>]*REL[\\s]?=[\\s]?\\\"[\\s]?(ALTERNATE|SERVICE\\.FEED)[\\s]?\\\"[^>]*>", 
false);
 
   46    TQRegExp reHref(
"HREF[\\s]?=[\\s]?\\\"([^\\\"]*)\\\"", 
false);
 
   48    TQRegExp reType(
"TYPE[\\s]?=[\\s]?\\\"([^\\\"]*)\\\"", 
false);
 
   50    TQRegExp reTitle(
"TITLE[\\s]?=[\\s]?\\\"([^\\\"]*)\\\"", 
false);
 
   56    TQStringList linkTags;
 
   58    while ( matchpos != -1 )
 
   60        matchpos = reLinkTag.search(str, pos);
 
   63            linkTags.append( str.mid(matchpos, reLinkTag.matchedLength()) );
 
   64            pos = matchpos + reLinkTag.matchedLength();
 
   68    FeedDetectorEntryList list;
 
   70    for ( TQStringList::Iterator it = linkTags.begin(); it != linkTags.end(); ++it )
 
   73        int pos = reType.search(*it, 0);
 
   75            type = TQString(reType.cap(1)).lower();
 
   78        if ( type != 
"application/rss+xml" && type != 
"application/rdf+xml" 
   79          && type != 
"application/atom+xml" && type != 
"text/xml" )
 
   83        pos = reTitle.search(*it, 0);
 
   85        title = reTitle.cap(1);
 
   87        title = KCharsets::resolveEntities(title);
 
   90        pos = reHref.search(*it, 0);
 
   94        url = KCharsets::resolveEntities(url);
 
   97        if ( title.isEmpty() )
 
  100        if ( !url.isEmpty() )
 
  101            list.append(FeedDetectorEntry(url, title) );        
 
  110    TQString str = s.simplifyWhiteSpace();
 
  112    TQRegExp reAhrefTag(
"<[\\s]?A[^>]?HREF=[\\s]?\\\"[^\\\"]*\\\"[^>]*>", 
false);
 
  115    TQRegExp reHref(
"HREF[\\s]?=[\\s]?\\\"([^\\\"]*)\\\"", 
false);
 
  117    TQRegExp rssrdfxml(
".*(RSS|RDF|XML)", 
false);
 
  125    while ( matchpos != -1 )
 
  127        matchpos = reAhrefTag.search(str, pos);
 
  128        if ( matchpos != -1 )
 
  130            TQString ahref = str.mid(matchpos, reAhrefTag.matchedLength());
 
  131            int hrefpos = reHref.search(ahref, 0);
 
  134                TQString url = reHref.cap(1);
 
  136                url = KCharsets::resolveEntities(url);
 
  138                if ( rssrdfxml.exactMatch(url) )
 
  142            pos = matchpos + reAhrefTag.matchedLength();
 
  149TQString FeedDetector::fixRelativeURL(
const TQString &s, 
const KURL &baseurl)
 
  153    if (KURL::isRelativeURL(s2))
 
  155        if (s2.startsWith(
"//"))
 
  157            s2=s2.prepend(baseurl.protocol()+
":");
 
  160        else if (s2.startsWith(
"/"))
 
  163            b2.setPath(TQString()); 
 
  164            b2.setQuery(TQString());
 
  165            u = KURL(b2, s2.remove(0,1)); 
 
  169            u = KURL(baseurl, s2);