[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bchoqok/1=2E0=5D_plugins/untiny=3A_BUG=3A265013?=
From: Mehrdad Momeny <mehrdad.momeny () gmail ! com>
Date: 2011-02-25 11:17:25
Message-ID: 20110225111725.ACFBBA60B0 () git ! kde ! org
[Download RAW message or body]
Git commit b596e4539cf284a5491bc707d6dad2cd470b5022 by Mehrdad Momeny. on behalf of \
Andrey Esin Committed on 03/02/2011 at 21:32.
Pushed by momeny into branch '1.0'.
BUG:265013
This commit must solve this bug.
Using XML reply instead of raw text.
M +17 -2 plugins/untiny/untiny.cpp
http://commits.kde.org/choqok/b596e4539cf284a5491bc707d6dad2cd470b5022
diff --git a/plugins/untiny/untiny.cpp b/plugins/untiny/untiny.cpp
index 548a0ae..2992525 100644
--- a/plugins/untiny/untiny.cpp
+++ b/plugins/untiny/untiny.cpp
@@ -31,6 +31,7 @@
#include <shortenmanager.h>
#include <untinysettings.h>
#include <qmutex.h>
+#include <QDomDocument>
K_PLUGIN_FACTORY( MyPluginFactory, registerPlugin < UnTiny > (); )
K_EXPORT_PLUGIN( MyPluginFactory( "choqok_untiny" ) )
@@ -90,7 +91,7 @@ void UnTiny::parse(QPointer<Choqok::UI::PostWidget> postToParse)
}
if(UnTinySettings::useUntinyDotCom()) {
foreach(const QString &url, redirectList) {
- QString untinyDotComUrl = \
QString("http://untiny.com/api/1.0/extract/?url=%1&format=text").arg(url); + \
QString untinyDotComUrl = \
QString("http://untiny.com/api/1.0/extract/?url=%1&format=xml").arg(url);
KIO::StoredTransferJob *job = KIO::storedGet( untinyDotComUrl, \
KIO::NoReload,
KIO::HideProgressInfo );
if ( !job ) {
@@ -122,9 +123,23 @@ void UnTiny::slotUntinyDotComResult(KJob* job)
{
if(!job)
return;
- QString toUrl = qobject_cast<KIO::StoredTransferJob *>(job)->data();
+ QByteArray reply = qobject_cast<KIO::StoredTransferJob *>(job)->data();
QPointer<Choqok::UI::PostWidget> postToParse = mParsingList.take(job);
QString fromUrl = mShortUrlsList.take(job);
+ QString toUrl;
+
+ QDomDocument doc;
+ if (doc.setContent(reply)){
+ QDomNode n = doc.documentElement().firstChild();
+ while(!n.isNull()) {
+ QDomElement e = n.toElement();
+ if(!e.isNull())
+ if (e.tagName() == "org_url")
+ toUrl = e.text();
+ n = n.nextSibling();
+ }
+ }
+
if( postToParse && toUrl.startsWith(QString("http"), Qt::CaseInsensitive)){
// kDebug()<<"Got redirect: "<<fromUrl<<toUrl;
QString content = postToParse->content();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic