summaryrefslogtreecommitdiffstats
path: root/kget/kget_plug_in/links.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kget/kget_plug_in/links.cpp
downloadtdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz
tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kget/kget_plug_in/links.cpp')
-rw-r--r--kget/kget_plug_in/links.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/kget/kget_plug_in/links.cpp b/kget/kget_plug_in/links.cpp
new file mode 100644
index 00000000..a597257d
--- /dev/null
+++ b/kget/kget_plug_in/links.cpp
@@ -0,0 +1,41 @@
+#include "links.h"
+
+#include <kmimetype.h>
+#include <kprotocolinfo.h>
+
+#include <dom/html_misc.h>
+#include <dom/html_document.h>
+
+LinkItem::LinkItem( DOM::Element link )
+ : m_valid( false )
+{
+ DOM::NamedNodeMap attrs = link.attributes();
+ DOM::Node href = attrs.getNamedItem( "href" );
+
+ // qDebug("*** href: %s", href.nodeValue().string().latin1() );
+
+ QString urlString = link.ownerDocument().completeURL( href.nodeValue() ).string();
+ if ( urlString.isEmpty() )
+ return;
+
+ url = KURL::fromPathOrURL( urlString );
+ if ( !KProtocolInfo::supportsReading( url ) )
+ return;
+
+
+ // somehow getElementsByTagName("#text") doesn't work :(
+ DOM::NodeList children = link.childNodes();
+ for ( uint i = 0; i < children.length(); i++ )
+ {
+ DOM::Node node = children.item( i );
+ if ( node.nodeType() == DOM::Node::TEXT_NODE )
+ text.append( node.nodeValue().string() );
+ }
+
+ // force "local file" mimetype determination
+ KMimeType::Ptr mt = KMimeType::findByURL( url, 0, true, true);
+ icon = mt->icon( QString::null, false ); // dummy parameters
+ mimeType = mt->comment();
+
+ m_valid = true;
+}